Documentation
¶
Index ¶
- func ValidateEvent(e Event) error
- type AgentContext
- type ClaudeSource
- type CodexDecodeFunc
- type CodexSource
- type CodexTurnEnricher
- type Event
- type EventKind
- type EventPayload
- type EventSource
- type Handler
- type HookData
- type NotificationPayload
- type PermissionRequestPayload
- type PreToolUsePayload
- type Product
- type SessionContext
- type StopPayload
- type SubagentStopPayload
- type TeammateIdlePayload
- type TurnInsight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateEvent ¶
ValidateEvent checks the invariants every source must satisfy immediately after mapping, before policy or side effects run.
Types ¶
type AgentContext ¶
type AgentContext struct {
ID string
Type string
TranscriptPath string
ParentSessionID string
ParentToolUseID string
}
AgentContext identifies a subagent on hosts that report one.
type ClaudeSource ¶
type ClaudeSource struct{}
ClaudeSource decodes the legacy Claude Code hook wire format into the product event contract. It preserves the historical decoder semantics: UTF-8 BOM skipping, decoding exactly the first JSON value from the reader without waiting for EOF, and ignoring trailing data.
type CodexDecodeFunc ¶
type CodexDecodeFunc func(ctx context.Context, publicEvent string, payload []byte) (codexsource.Decoded, error)
CodexDecodeFunc is the narrow DTO-returning seam between this package and internal/codexsource; this package never imports the SDK itself.
type CodexSource ¶
type CodexSource struct {
DecodeFn CodexDecodeFunc
}
CodexSource decodes Codex hook payloads through the SDK adapter into the product event contract. Wire names never leak past this mapping.
func NewCodexSource ¶
func NewCodexSource() CodexSource
NewCodexSource wires the source to the real SDK adapter.
func (CodexSource) Decode ¶
func (s CodexSource) Decode(ctx context.Context, publicEvent string, input io.Reader) (Event, error)
Decode reads the bounded payload and maps it to an Event. The reader is expected to hold the pre-read stdin bytes; the size guard here is a second line of defense behind the composition root's bounded read.
type CodexTurnEnricher ¶
type CodexTurnEnricher interface {
// EnrichStop classifies a completed (sub)agent turn.
EnrichStop(ctx context.Context, ev Event, p StopPayload) TurnInsight
// EnrichPreToolUse classifies an interactive-tool call. A returned
// StatusUnknown means "no notification for this tool".
EnrichPreToolUse(ctx context.Context, ev Event, p PreToolUsePayload) TurnInsight
}
CodexTurnEnricher derives notification policy inputs for Codex events.
This is the seam for richer turn analysis: the default implementation is a pure heuristic over the hook payload, and a future adapter may consult the Codex app-server thread/turn API instead. Implementations must be side-effect-free and fast — they run inside the hook's time budget and must never block delivery on external state.
type Event ¶
type Event struct {
Product Product
PayloadEventName string // diagnostic only; never selects the route
Session SessionContext
Payload EventPayload
Raw json.RawMessage // sensitive, retained for forward compatibility
}
Event is the product-owned envelope. Host DTO types never cross this boundary.
type EventKind ¶
type EventKind string
EventKind is the product-level event classification derived from the sealed payload type, never stored separately.
const ( EventUnknown EventKind = "" EventPreToolUse EventKind = "pre_tool_use" EventNotification EventKind = "notification" EventStop EventKind = "stop" EventSubagentStop EventKind = "subagent_stop" EventPermissionRequest EventKind = "permission_request" EventTeammateIdle EventKind = "teammate_idle" )
type EventPayload ¶
type EventPayload interface {
// contains filtered or unexported methods
}
EventPayload is sealed inside this package by the unexported method.
type EventSource ¶
EventSource decodes one host invocation into the product event contract. The string argument is the validated public event name from argv.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles hook events
func NewHandler ¶
NewHandler creates a new hook handler
func NewHandlerWithSource ¶
func NewHandlerWithSource(pluginRoot string, product Product, source EventSource) (*Handler, error)
NewHandlerWithSource creates a handler for the composition root with an explicit product and event source. Unlike NewHandler, config warnings go to the file log only: observation routes must not write to stderr.
type HookData ¶
type HookData struct {
TranscriptPath string `json:"transcript_path"`
LastAssistantMessage string `json:"last_assistant_message,omitempty"`
SessionID string `json:"session_id"`
CWD string `json:"cwd"`
ToolName string `json:"tool_name,omitempty"`
HookEventName string `json:"hook_event_name,omitempty"`
// Team-related fields (present in TeammateIdle, TaskCreated, TaskCompleted hooks)
TeamName string `json:"team_name,omitempty"`
TeammateName string `json:"teammate_name,omitempty"`
}
HookData represents the data received from Claude Code hooks
type NotificationPayload ¶
type NotificationPayload struct{}
NotificationPayload is the Claude permission-prompt Notification event.
type PermissionRequestPayload ¶
type PermissionRequestPayload struct {
ToolName string
ToolInput json.RawMessage
Agent *AgentContext // optional on the Codex wire
}
PermissionRequestPayload is a host request for user approval of a tool call.
type PreToolUsePayload ¶
type PreToolUsePayload struct {
ToolName string
ToolUseID string
ToolInput json.RawMessage
}
PreToolUsePayload is an interactive-tool event (Claude PreToolUse, or Codex PreToolUse for notification-relevant tools). ToolUseID is set on the Codex wire and empty for legacy Claude payloads.
type SessionContext ¶
type SessionContext struct {
SessionID string
TurnID string
CWD string
TranscriptPath string
Model string
PermissionMode string
}
SessionContext carries the host-neutral session identity shared by all events.
type StopPayload ¶
StopPayload is the main-agent turn completion.
type SubagentStopPayload ¶
type SubagentStopPayload struct {
Stop StopPayload
Agent *AgentContext // required for Codex, absent for legacy Claude payloads
}
SubagentStopPayload is a subagent turn completion.
type TeammateIdlePayload ¶
TeammateIdlePayload is the Claude team event.
type TurnInsight ¶
TurnInsight is the policy-relevant view of a Codex event derived by an enricher: the notification status plus an optional pre-rendered body. An empty Body means "let the message generator use its defaults".