agent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 12 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 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.

func (Agent) Matches

func (a Agent) Matches(toolName string) bool

Matches reports whether toolName is in the agent's cage. A bare group name ("http") also matches its members under any of the separators tool names use: "http_read" (underscore, the agentkit convention), "http.read", or "http/get".

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

func NewScheduler(agents Set, log *slog.Logger, fire func(ctx context.Context, a Agent)) *Scheduler

NewScheduler builds a Scheduler over a Set, calling fire for each agent whose schedule matches.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context)

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

type Set map[string]Agent

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).

func (Set) All

func (s Set) All() []Agent

All returns the agents sorted by name.

func (Set) Get

func (s Set) Get(name string) (Agent, bool)

Get returns the named agent.

Jump to

Keyboard shortcuts

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