subagent

package
v0.93.0-rc.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 Asker

type Asker struct {
	Kind  string
	Label string
	Depth int
}

Asker is what a decision reads of the session asking.

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.

func (*Service) Vetoed

func (s *Service) Vetoed(context.Context, api.None) ([]api.SubagentVeto, error)

Vetoed is every veto written since lich started, for a window that attaches later.

type Sessions

type Sessions interface {
	Asker(id string) (Asker, bool)
}

Sessions finds the session asking.

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.

type Workspace

type Workspace struct {
	Load  func(context.Context, api.None) ([]store.Project, error)
	Depth func(id string) int
}

Workspace is Sessions over lich's store.

func (Workspace) Asker

func (w Workspace) Asker(id string) (Asker, bool)

Asker is session id's provider, label and subagent depth.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL