Documentation
¶
Overview ¶
Package hook holds what a grelot hook decides before it asks the server: the fields of the host's hook input, which session the hook acts for, and the per-session marks it keeps between runs.
Index ¶
Constants ¶
const ( // MarkOnce is a role's first print for a session, for a role under once. MarkOnce = "once" // MarkHostHooked is a hook run of a host on this machine, keyed by the // provider's name, and MarkSessionHooked one of a session, keyed by the // session as the CLI sends it (<provider>:<id>). MarkHostHooked = "hooks" MarkSessionHooked = "hooked" )
The kinds of mark a hook keeps.
Variables ¶
This section is empty.
Functions ¶
func OneShot ¶
func OneShot(p *provider.Provider, lookup func(string) (string, bool), ancestors func() []proctree.Process) bool
OneShot reports whether the hook runs in a one-shot run of p's host, by p's one_shot: one of its variables holding a listed value, or a listed argument, in one of provider.OneShot.Args' forms, on a process of the host's own run of ancestors (proctree.Host). ancestors is called only when no variable matches. It answers false when neither is seen, so an ancestor whose arguments cannot be read keeps the run interactive.
Types ¶
type Class ¶
type Class struct {
// Stdin is the hook input's session id, "" when the provider names
// no session.stdin or the input holds none.
Stdin string
Kind Kind
// Fork marks a Child whose record names a parent: a second chat beside
// it, which gets the fork's one line.
Fork bool
}
Class is a hook's classification.
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input is a hook's stdin, one JSON object.
func ReadInput ¶
ReadInput reads r as one JSON object. Empty input is an empty object, so a host that sends nothing still gets its environment session's hook.
type Kind ¶
type Kind int
Kind is whose hook this is.
const ( // SameAgent is the same agent going on in a new session: it runs as // parent does. SameAgent Kind // Child is a subagent, a workflow step or a fork beside a parent that // goes on: it never acts for the parent. Child // Replaced is a session a same-agent fork has replaced: it prints // nothing. Replaced )
type Marks ¶
type Marks struct {
// contains filtered or unexported fields
}
Marks are small per-session files under the client's state directory. Every write is best effort: a failed one never fails a hook.
func ReadMarks ¶
ReadMarks reads the marks NewMarks keeps and never writes one: the marks of a client with no usable config, which leaves no state behind.
func (*Marks) Set ¶
Set sets the mark to now and drops the marks not set within markLife. ReadMarks' Set writes nothing.