Documentation
¶
Overview ¶
Package agent is the declaration layer for autonomous assistants: the Agent type, discovery of agent.md files into an immutable Set, and a cron Scheduler. It depends on nothing from the composition layer (no runtime, gate, or chat) — execution (FireAgent) lives in the workspace, which injects a fire callback into the Scheduler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
Name string
Description string // one-line summary for listing/selection
Instructions string // the markdown body: the agent's system prompt / task framing
Tools []string // tool-name filter for the cage; empty = a pure reasoner
When string // cron schedule; "" = manual only
Effort agentkit.Effort // reasoning effort for the agent's runs
Budget time.Duration // per-run wall-clock; 0 = the workspace default
Autonomy Autonomy // how a scheduled firing resolves an Ask
}
Agent is a declared assistant: a scoped persona that runs on a schedule or on demand. Its authority is its tool cage (Tools → ToolSet.Select) plus the workspace gate; a scheduled firing's Autonomy decides whether a fresh Ask reaches a human or is denied.
type Autonomy ¶
type Autonomy string
Autonomy dictates how a SCHEDULED firing resolves an Ask — the one moment no human is in the loop by default. It is inert for in-chat sub-agent calls, which inherit the caller's gate ctx (approver already present) and are attended by construction.
const ( // Strict runs with no approver: any fresh Ask is denied (gate.ErrDeniedUnattended). The zero // value resolves here, so a missing or typo'd dial never silently escalates authority. Strict Autonomy = "strict" // Guarded routes an Ask out-of-band to the human approver (the phone) — nocturn's thesis applied // to a background agent: it may reach past its standing grants, but only with a human's consent. Guarded Autonomy = "guarded" )
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler fires agents on their cron schedule. It holds each agent's next due time, computed from the WALL clock, and sleeps until the earliest — it does not poll. agentkit has no notion of time, so scheduling lives here; execution is the caller's, injected as fire.
func NewScheduler ¶
NewScheduler builds a Scheduler over a Set, calling fire for each agent whose schedule matches.
func (*Scheduler) Start ¶
Start schedules until ctx is cancelled. It computes each agent's next due time and sleeps until the earliest one, rather than waking every minute to test every schedule: a sampling loop misses everything between samples, and the samples stop entirely while the machine sleeps.
Every due time is derived from the wall clock, so a sleep or clock jump is absorbed — on wake the overdue agents are simply due, and catchUpGrace decides whether each still runs. An agent that missed several firings in one gap fires once, not once per missed slot.
Startup does not catch up: due times are computed forward from now, so a schedule missed while the daemon was down does not fire at boot (that would need a persisted last-run record).
Schedules are local wall-clock times, so daylight-saving transitions are visible. A fall-back repeats an hour: firing the same wall-clock minute twice is suppressed (see fireDue), so a daily agent still runs once. A spring-forward skips an hour outright: an agent scheduled inside the skipped hour has no wall-clock minute to run at that day and does not run. Removing the second case would mean scheduling in UTC, which changes what every existing cron spec means.
type Set ¶
Set is a read-only-by-convention collection of declared agents, keyed by name (mirrors agentkit's ToolSet / SkillSet). Build one with Discover; read it with Get and All.
func Discover ¶
func Discover(dir string, diag *agentkit.Diagnostics) Set
Discover reads dir/<name>/agent.md for every subdirectory into a Set. A missing dir yields an empty Set. A malformed agent.md is SKIPPED with a diagnostic rather than aborting the scan — a broken agent's authority is then simply absent (fail-closed), and the other agents still load. A duplicate name keeps the first (shadowing).