hookpayload

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hookpayload normalizes the hook payloads MemSpace's hook-based agents send on stdin into spool records.

Claude Code defines this payload shape; DSH's hook bridge and the OMP extension reuse it, so one normalizer serves every hook-based adapter. The agent_type stored on sessions is the caller's, not the shape's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppliedFiles

func AppliedFiles(name string, toolInput map[string]any, response any, cwd string) []string

AppliedFiles is the set of files the tool actually changed.

omp's ast_edit rewrites files, directories and globs, so its input names targets, not results: a preview or a zero-replacement run changes nothing, and one glob can hit several files. Its tool response carries the applied file list, which is what MemSpace records. A write to an internal xd:// URL dispatches another tool; that tool's result is nested under tool_response.xdev.inner.sourceResultDetails, so the write's own "path" is never recorded as a changed file. Every other file tool names its single target in the input.

func FilePath

func FilePath(toolInput map[string]any) string

FilePath returns the single file a tool names in its input, when it names one directly.

func IsFileTool

func IsFileTool(name string) bool

IsFileTool reports whether a tool writes files.

func Normalize

func Normalize(agentType string, raw []byte, now time.Time, projectDir func(cwd string) string) ([]spool.Record, error)

Normalize maps one hook invocation to MemSpace events for agentType. Unknown or uninteresting hook events yield no events. projectDir resolves the directory that identifies the session's project; nil means the payload's cwd.

func ReferencedFiles

func ReferencedFiles(name string, toolInput map[string]any, response any, cwd string) []string

ReferencedFiles is every file the tool's result mentions, including files an ast_edit preview would touch. Sensitivity checks use it so staged edits of secret files are redacted even before they are applied.

Types

type Input

type Input struct {
	SessionID            string         `json:"session_id"`
	TranscriptPath       string         `json:"transcript_path"`
	Cwd                  string         `json:"cwd"`
	HookEventName        string         `json:"hook_event_name"`
	PermissionMode       string         `json:"permission_mode"`
	Source               string         `json:"source"`
	Model                string         `json:"model"`
	Prompt               string         `json:"prompt"`
	PromptID             string         `json:"prompt_id"`
	ToolName             string         `json:"tool_name"`
	ToolInput            map[string]any `json:"tool_input"`
	ToolResponse         any            `json:"tool_response"`
	ToolUseID            string         `json:"tool_use_id"`
	Error                string         `json:"error"`
	IsInterrupt          bool           `json:"is_interrupt"`
	DurationMS           *int64         `json:"duration_ms"`
	LastAssistantMessage string         `json:"last_assistant_message"`
	Reason               string         `json:"reason"`
	Trigger              string         `json:"trigger"`
	CustomInstructions   string         `json:"custom_instructions"`
}

Input is the union of the hook payload fields MemSpace uses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL