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 = turns.ErrOverCap 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, inputs map[string]any) (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 Request ¶
type Request struct {
Unit unit.Unit
Items []string // item ids acted on
Task string
Intent turn.Intent // "" is the Service's Default
Guidance string
Inputs map[string]any
Trigger turn.Trigger
Workflow string // "" by hand
// ResumeOf is the headless turn whose question this run answers, 0 none.
ResumeOf int64
// ByPerson is a turn a person asked for, whatever its Trigger.
ByPerson bool
}
type Service ¶
type Service struct {
Turns *turns.Service // records the turn; its Items ledger applies the record's ops with provenance turn
// Starter admits each new turn; a run again resumes through it.
Starter *turns.Starter
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
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 resumes q through the Starter and runs its intent on q's unit, items, task and 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 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.