Documentation
¶
Overview ¶
Package headless runs a turn as one restricted agent call, with no session.
Index ¶
Constants ¶
const DefaultTimeout = 10 * time.Minute
DefaultTimeout bounds a headless call when Service.Timeout is zero.
const MaxDrafts = 3
MaxDrafts is how many drafts one headless answer may propose.
Variables ¶
var ( ErrBusy = turns.ErrHeadlessBusy ErrOverCap = errors.New("the headless spend cap is reached") ErrNotHeadless = errors.New("the turn is not headless") )
Functions ¶
Types ¶
type Builder ¶
type Builder interface {
Instructions(ctx context.Context, u unit.Unit, intent turn.Intent, items []string) (string, error)
}
Builder renders a unit's instructions for an intent; implemented in internal/cli over internal/turn.
type Placer ¶
type Placer interface {
Checkout(ctx context.Context, u unit.Unit, item string) (dir string, ok bool, err error)
}
Placer resolves a placement to an existing directory, implemented in internal/cli: an absolute Checkout as is, "main" the repo's main checkout path; "" (a new worktree) and ErrUnplaced give ok false: a headless turn never creates a worktree.
type Service ¶
type Service struct {
Turns *turns.Service // records the turn; its Items ledger applies the record's ops with provenance turn
Build Builder
Place Placer
Asker turns.Asker
// Ledger reads the unit's items, which a draft's items must name; nil checks none.
Ledger items.Applier
Outbox *outbox.Service
Intents func(name turn.Intent) (intent.Def, bool)
Caps Caps // from config "headless"
// Context is the daemon's lifetime: a stop cancels the calls Start runs; nil is context.Background.
Context context.Context
Timeout time.Duration // a call's limit; 0 is DefaultTimeout
Spent func(ctx context.Context, day time.Time) (float64, error) // turn_usage of headless turns that day
Dossier func(ctx context.Context, u unit.Unit) (path string, ok bool)
// Logged writes the answer's log to the unit's dossier once the turn's record is stored; nil writes none.
Logged func(ctx context.Context, u unit.Unit, seq int64, log string)
Clock port.Clock
// Go runs a started call in the background, for Start and Again; nil runs it on a new goroutine.
Go func(run func())
Log func(format string, args ...any)
// contains filtered or unexported fields
}
func (*Service) Again ¶
Again runs q's intent on q's unit, items and entry (kept in q.Inputs) with said as Guidance, q.Trigger and q.Workflow; ErrNotHeadless when q.Mode is not headless. The route is Resumed.