Documentation
¶
Overview ¶
Package hookspool is the file the agents' lifecycle hooks leave their events in before they call the runtime: an event told while the runtime was away, restarting or too busy to answer is read from the file once it is back, so the end of a turn is not lost with the request that carried it. The hook appends a line and delivers; the runtime applies the lines in the order they were written, each once, and empties the file.
Index ¶
Constants ¶
const File = "hook-spool.jsonl"
File is the spool's name in the runtime's data folder.
Variables ¶
var ( ErrFull = errors.New("hookspool: the spool is full") ErrBusy = errors.New("hookspool: the spool is locked") )
ErrFull is a spool at its limit; ErrBusy, one whose lock did not come in time.
Functions ¶
Types ¶
type Queue ¶
type Queue struct {
// Path is the spool file.
Path string
// Apply takes one event; it is called for the events in the order they were written, never twice for an id.
Apply func(event map[string]any)
// Ready says whether events can be applied now (nil: always). Until then they stay in the file.
Ready func() bool
// contains filtered or unexported fields
}
Queue is the runtime's end of the spool.
func (*Queue) Deliver ¶
Deliver is an event the hook brought itself. What the spool holds goes first, so an event the runtime missed is applied before the one that came after it; the event is then applied unless the spool had it. False: events cannot be applied yet, and the event waits in the spool.