Documentation
¶
Overview ¶
Package hooks reads the hook calls of vendor agent CLIs and edits their hook config files. It does not import the visor.
Index ¶
Constants ¶
const MaxPayload = 1 << 20
MaxPayload is the largest hook payload, in bytes.
const Version = 1
Version is the shape of the hook command. Increase it when the command changes, so that Status reports outdated.
Variables ¶
var ( ErrUnsupported = errors.New("hooks: harness has no hook support") ErrPayload = errors.New("hooks: bad payload") )
Errors.
var ErrCommand = errors.New("hooks: bad hook command")
ErrCommand means that the hook command is not usable.
Functions ¶
func ConfigPath ¶
ConfigPath gives the hook config file in the vendor home dir.
Types ¶
type Event ¶
type Event struct {
Harness string
// Name is the vendor event name.
Name string
Kind Kind
// VendorID is the vendor session id.
VendorID string
Cwd string
Transcript string
Prompt string
Tool string
ToolUseID string
ToolInput json.RawMessage
// Ask is set on a request.
Ask Ask
// Question and Options are the first question of a question tool.
Question string
Options []string
// Message is the last assistant message of a stop.
Message string
Interrupted bool
// Error is set on a stop that failed.
Error string
}
Event is one hook call in a neutral form.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer adds and removes the hook entries of one visor in the vendor hook configs. It keeps the other entries and the rest of each file.
func NewInstaller ¶
NewInstaller takes the hook command before the harness name, with an absolute program path first, and a tag that names the visor.
func (*Installer) Command ¶
Command is the hook command line for a harness. It reads stdin and does nothing when the program is gone.
func (*Installer) Install ¶
Install adds or updates the hook entries of the harness in the vendor home dir.
type Kind ¶
type Kind string
Kind is the neutral kind of a hook event.
const ( KindSessionStart Kind = "session_start" KindPrompt Kind = "prompt" // KindTool is a tool that starts. The turn runs. KindTool Kind = "tool" KindToolDone Kind = "tool_done" // KindRequest is a permission or a question with its details. KindRequest Kind = "request" // KindAttention means that the harness waits for the user, with no // details. KindAttention Kind = "attention" KindStop Kind = "stop" KindSessionEnd Kind = "session_end" )
Event kinds.