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.
const WrapperFile = "prompts/headless.md.tmpl"
WrapperFile is the profile file of the headless call's prompt.
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)
// Default is the intent a request that names none runs on units of p.
Default func(p unit.ProviderID) (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)
// Wrapper is the profile's prompt around the unit's instructions, read at each call.
Wrapper func() (Wrapper, error)
// contains filtered or unexported fields
}
func (*Service) Again ¶
Again runs q's intent on q's unit, items and task (kept in q.Inputs) with said as Guidance, q.Trigger and q.Workflow; ErrNotHeadless when q.Mode is not headless. The route is Resumed.
type Wrapper ¶ added in v0.2.0
type Wrapper struct {
// contains filtered or unexported fields
}
Wrapper is the headless call's prompt around the unit's instructions, a template defining "before", the text ahead of the unit data's markers, and "after", the text between the end marker and the answer schema. The markers, the instructions between them and the schema are written in Go.
func ParseWrapper ¶ added in v0.2.0
ParseWrapper reads a wrapper template; it must define before and after.
type WrapperData ¶ added in v0.2.0
type WrapperData struct {
Name, Unit, Checkout, Dossier string
// Items is the items acted on, each in backquotes, comma-separated.
Items string
// Guidance is the user's guidance, each line indented four spaces.
Guidance string
// Begin and End are the unit data's markers; Nonce is their code.
Begin, End, Nonce string
MaxDrafts int
}
WrapperData is what the wrapper's templates read.