subagent

package
v0.94.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 15 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
	// CardsOff is whether the user keeps this provider's subagents inside
	// the session (Settings › Subagents).
	CardsOff bool
}

Asker is what a decision reads of the session asking.

type Card

type Card struct {
	// Lean is whether the provider can start with less; a card that cannot
	// brings everything, and the rest is empty.
	Lean bool
	// Left are the MCP servers and plugins it leaves out.
	Left []api.SubagentCardItem
	// Brought are the IDs of what it brings, listed items and also ones.
	Brought []string
}

Card is what one card spawn of a provider brings and leaves out.

func (Card) Brings

func (c Card) Brings(id string) bool

Brings reports whether the card brings item id.

func (Card) LeftNames

func (c Card) LeftNames(kind string) []string

LeftNames are the names of the items of kind it leaves out: a server's name, a plugin's name@marketplace.

type CardItems

type CardItems interface {
	CardItems(provider string) []api.SubagentCardItem
}

CardItems reads the MCP servers and plugins of the user's own setup a session of provider loads (library.CardItems).

type CardStore

type CardStore interface {
	SubagentCards(providerID string) bool
	SetSubagentCards(providerID string, on bool) error
	SubagentBrings(providerID string) []string
	SetSubagentBring(providerID, item string, on bool) error
	SessionKind(sessionID string) string
}

CardStore keeps the settings.

type Cards

type Cards struct {
	// contains filtered or unexported fields
}

Cards is the settings over RPC and what a card spawn reads of them.

func NewCards

func NewCards(store CardStore, items CardItems, emit func()) *Cards

NewCards is the settings in store, listing items, telling emit of each change once it is stored.

func (*Cards) Card

func (c *Cards) Card(provider string) Card

Card is what a card of provider spawned now brings.

func (*Cards) CardsOn

CardsOn answers api.SubagentCardsOn.

func (*Cards) List

List answers api.SubagentCards.

func (*Cards) On

func (c *Cards) On(provider string) bool

On reports whether provider's subagents open as cards.

func (*Cards) SetBring

func (c *Cards) SetBring(_ context.Context, opts api.SubagentSetBringOptions) (api.None, error)

SetBring answers api.SubagentSetBring.

func (*Cards) SetCards

func (c *Cards) SetCards(_ context.Context, opts api.SubagentSetCardsOptions) (api.None, error)

SetCards answers api.SubagentSetCards.

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
	// CardsOff is whether the user turned a provider's cards off (Cards.On);
	// nil turns none off.
	CardsOff func(provider string) bool
}

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, subagent depth and whether its provider's cards are off.

Jump to

Keyboard shortcuts

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