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 ¶
- func AppliedFiles(name string, toolInput map[string]any, response any, cwd string) []string
- func FilePath(toolInput map[string]any) string
- func IsFileTool(name string) bool
- func Normalize(agentType string, raw []byte, now time.Time, ...) ([]spool.Record, error)
- func ReferencedFiles(name string, toolInput map[string]any, response any, cwd string) []string
- type Input
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppliedFiles ¶
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 ¶
FilePath returns the single file a tool names in its input, when it names one directly.
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 ¶
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.