Documentation
¶
Overview ¶
Package subagent decides what becomes of a provider's own subagent call: lich's /subagent endpoint (docs/hooks/subagent-cards.md). A deny opens each task as a lich session, a card the user can watch, and hands it its task; an allow lets the native subagent run.
Index ¶
Constants ¶
const MaxDepth = 2
MaxDepth is how many levels of subagent cards lich nests: a session opens cards, and so does a card it opened; a card one level further keeps its own subagents native. Every level multiplies the cards on screen and the sessions a report climbs back through, and two let a worker split its own task once more, which is the case nesting was asked for.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Relay ¶
type Relay interface {
HandSubagent(ctx context.Context, opts relay.SendOptions) (relay.Result, error)
ErrandOpen(ticket string) bool
}
Relay hands a session its task as a subagent errand, and says whether one still waits on its worker.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the decisions and what they remember: the answers given by tool call, the workers running by prompt, and each conversation's spawns for the waits that follow them.
func New ¶
func New(sessions Sessions, spawner Spawner, rl Relay, lang func() prompt.Lang, emit func(api.SubagentVeto)) *Service
New is a decider over sessions, spawner and relay, writing in the prompt language lang gives and telling emit of every veto once it is written.
func (*Service) Decide ¶
func (s *Service) Decide(ctx context.Context, req api.SubagentRequest) (api.SubagentAnswer, func(written bool))
Decide answers req. commit is to be called once the answer was written, or failed to be: a deny that never reached the hook closes what it opened, so a card and a native subagent never do the same task.
type Spawner ¶
type Spawner interface {
OpenSubagentNow(ctx context.Context, opts api.OpenSubagentOptions) (api.OpenedSession, error)
Close(ctx context.Context, opts api.CloseSessionOptions) (api.ClosedSession, error)
}
Spawner opens a task as a session, answering once the session exists rather than once its agent is up (contract › Timing), and closes one again.