Documentation
¶
Index ¶
- Constants
- type Event
- type Registry
- func (r *Registry) Adopt(description, agentType, result string, elapsed time.Duration) *Task
- func (r *Registry) AdoptAgent(agentID, description, agentType, result string, elapsed time.Duration, ...) (*Task, error)
- func (r *Registry) Close()
- func (r *Registry) Counts() (running, total int)
- func (r *Registry) Done() <-chan struct{}
- func (r *Registry) Events() <-chan Event
- func (r *Registry) Get(id string) *Task
- func (r *Registry) Launch(description, agentType string, ...) (*Task, error)
- func (r *Registry) LaunchAgent(agentID, description, agentType string, prepare func(*Task) error, ...) (*Task, error)
- func (r *Registry) List() []*Task
- func (r *Registry) Publish(ev Event)
- func (r *Registry) Relaunch(t *Task, run func(ctx context.Context, t *Task) (string, error)) error
- func (r *Registry) RunAgent(ctx context.Context, agentID, description, agentType string, ...) (*Task, string, error)
- func (r *Registry) Stop(id string) error
- type Status
- type Task
- func (t *Task) Activity() string
- func (t *Task) AppendAgentEvents(events []agent.RuntimeEvent) error
- func (t *Task) DurableAgent() (string, agent.State, json.RawMessage)
- func (t *Task) Elapsed() time.Duration
- func (t *Task) PeekMessages() []agent.Message
- func (t *Task) Result() string
- func (t *Task) Resume(prompt string) error
- func (t *Task) ResumeContext(ctx context.Context, prompt string) error
- func (t *Task) Seq() int
- func (t *Task) SetActivity(text string)
- func (t *Task) SetAgentState(state agent.State) error
- func (t *Task) SetDurableAgent(agentID string, state agent.State, resumeData json.RawMessage) error
- func (t *Task) SetPeek(fn func() []agent.Message)
- func (t *Task) SetResume(fn func(prompt string) error)
- func (t *Task) SetResumeContext(fn func(context.Context, string) error)
- func (t *Task) Status() Status
- func (t *Task) SupportsResume() bool
Constants ¶
const ( // MaxConcurrent guards provider rate limits, not local resources — the // runs are IO-bound model streams, so CPU count is irrelevant. MaxConcurrent = 16 MaxPerSession = 50 // MaxRunDuration bounds one background run so a hung model stream cannot // occupy a concurrency slot forever. MaxRunDuration = 30 * time.Minute )
const KindCommand = "command"
KindCommand marks events published for backgrounded shell commands rather than subagent runs; those have no Task in the registry.
const KindSchedule = "schedule"
KindSchedule marks a scheduled task coming due. Unlike the other kinds it carries work to do rather than a finished result: Description holds the schedule expression and Result the task prompt.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Task *Task
ID string
Kind string
Description string
AgentType string
Seq int
Status Status
Result string
Elapsed time.Duration
}
Event is an immutable snapshot of one finished run, taken before the task can be resumed — delivery must never read the live task, which a relaunch may already have reset.
func (Event) Label ¶ added in v0.11.4
Label names the event source for status lines and notifications.
func (Event) Notice ¶ added in v0.12.19
Notice renders the one-line user-facing announcement shown in the chat when the event is delivered.
func (Event) Notification ¶
Notification renders the model-facing completion block delivered as hidden context by every UI surface.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks the subagents of one session. Completed tasks stay listed for task_output until the session ends; background completion events are buffered so a consumer that attaches late still receives them.
func NewFileRegistry ¶ added in v0.15.8
NewFileRegistry restores a session registry. Runs that were active when the process stopped become failed terminal snapshots and emit one notification; they are never replayed automatically.
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) Adopt ¶ added in v0.12.2
Adopt registers an already-finished run (a synchronous agent call) so it can be inspected and resumed like a background task. It emits no event — the result was already delivered inline. Returns nil when the registry is closed or at capacity; the caller then skips follow-up support.
func (*Registry) AdoptAgent ¶ added in v0.15.8
func (r *Registry) AdoptAgent(agentID, description, agentType, result string, elapsed time.Duration, prepare func(*Task) error) (*Task, error)
AdoptAgent is Adopt with durable child state installed before it becomes visible to task_send or UI readers.
func (*Registry) Close ¶
func (r *Registry) Close()
Close cancels all running tasks and stops event delivery.
func (*Registry) Done ¶
func (r *Registry) Done() <-chan struct{}
Done is closed when the registry shuts down, so event consumers can exit.
func (*Registry) Events ¶
Events delivers one snapshot per finished background run, plus published events.
func (*Registry) Launch ¶
func (r *Registry) Launch(description, agentType string, run func(ctx context.Context, t *Task) (string, error)) (*Task, error)
Launch starts run in a goroutine detached from the launching tool call; it is canceled only by Stop or Close. The returned error reports cap or shutdown rejections, never run failures — those surface via the task. run receives the task so it can publish activity and a transcript peek.
func (*Registry) LaunchAgent ¶ added in v0.15.8
func (r *Registry) LaunchAgent(agentID, description, agentType string, prepare func(*Task) error, run func(ctx context.Context, t *Task) (string, error)) (*Task, error)
LaunchAgent is Launch with a stable child identity and a preparation step that is persisted before the goroutine can start.
func (*Registry) Publish ¶ added in v0.11.4
Publish delivers an external background event (e.g. an exec_command exit) through the session's notification channel alongside subagent completions.
func (*Registry) Relaunch ¶
Relaunch restarts a finished task with a new run — the task_send follow-up path. The task keeps its id and history; status, timing, and cancellation reset for the new run, and completion fires another event.
func (*Registry) RunAgent ¶ added in v0.18.0
func (r *Registry) RunAgent(ctx context.Context, agentID, description, agentType string, prepare func(*Task) error, run func(context.Context, *Task) (string, error)) (*Task, string, error)
RunAgent tracks a synchronous call from its start, including activity, cancellation and durable history. Its result is returned inline, so it emits no completion notification. At the session limit it runs without tracking, preserving synchronous calls as a fallback when background work is capped.
type Task ¶
type Task struct {
ID string
AgentID string
Description string
AgentType string
Started time.Time
// contains filtered or unexported fields
}
func (*Task) AppendAgentEvents ¶ added in v0.15.8
func (t *Task) AppendAgentEvents(events []agent.RuntimeEvent) error
AppendAgentEvents implements the child's live durability boundary. Events have already been assigned monotonically by that child Agent.
func (*Task) DurableAgent ¶ added in v0.15.8
func (*Task) PeekMessages ¶
func (*Task) ResumeContext ¶ added in v0.15.8
func (*Task) Seq ¶
Seq counts the task's runs: 1 for the initial launch, +1 per resume. It distinguishes the completion notifications of successive runs.
func (*Task) SetActivity ¶
SetActivity records what the agent is currently doing (e.g. its running tool call) for live status displays.
func (*Task) SetDurableAgent ¶ added in v0.15.8
SetDurableAgent installs the child's current event ledger and opaque resume specification for its admitted identity. The subagent package owns the format; Registry only guarantees atomic persistence.
func (*Task) SetPeek ¶
SetPeek installs a snapshot function for the agent's transcript so UIs can watch a running task and re-read a finished one.
func (*Task) SetResume ¶
SetResume installs the follow-up hook used by task_send: it restarts the finished agent with a new prompt and its full prior context.