Documentation
¶
Overview ¶
Package workers reads workers: scheduled workflows a workspace defines in workers/<name>/WORKER.md (ROADMAP item 24). The frontmatter says when the worker runs and what it may do unattended; the body is the workflow the agent is given.
Index ¶
Constants ¶
const FileName = "WORKER.md"
FileName is the file that defines a worker, in its own directory.
Variables ¶
This section is empty.
Functions ¶
func Allows ¶
func Allows(perms []Permission, req api.ApprovalRequest) bool
Allows reports whether the permissions cover the request: its kind has a permission matching every one of its targets. A request without targets is never covered.
Types ¶
type Effective ¶
type Effective struct {
Permissions []Permission
Limits api.Limits
Notes []string
}
Effective is what a worker may actually do and spend: its permissions without those the host policy doesn't allow, and its limits with the policy's defaults filled in and its maximums applied. Notes say what the policy changed.
type InvalidError ¶
InvalidError lists what makes a WORKER.md unusable. Load still returns what it could read, so a listing can show the worker and why.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
Error names the WORKER.md and its problems.
type Permission ¶
Permission is something a worker may do without approval, as written in its frontmatter: "<kind>:<pattern>".
shell:go test ./... a command, exactly, or a glob ("go list *")
write:reports/*.md creating or editing workspace files (glob)
delete:tmp/* deleting workspace files (glob)
web:proxy.golang.org fetching from a host, or searching with a provider
mcp:github:create_issue an MCP tool, as server:tool (glob)
Globs use path.Match, where * doesn't cross "/"; a pattern ending in "/" covers everything under that directory. A shell glob never covers a command that chains, pipes, redirects or substitutes (see shellMeta): "go list *" must not cover "go list x; rm -rf ~". Such a command is covered only by a permission that is exactly it. Reading never needs permission. Anything a worker isn't permitted is refused and recorded.
func ParsePermission ¶
func ParsePermission(s string) (Permission, error)
ParsePermission reads "<kind>:<pattern>".
func (Permission) String ¶
func (p Permission) String() string
String is the permission as written: kind:pattern.
type RunLog ¶
type RunLog struct {
// contains filtered or unexported fields
}
RunLog keeps finished runs, one JSON line each, in a file per worker.
type Schedule ¶
type Schedule struct {
// Text is the schedule as written.
Text string
// Cron is how it was understood: a five-field cron expression, or a
// descriptor ("@hourly", "@every 90m").
Cron string
Location *time.Location
// contains filtered or unexported fields
}
Schedule is when a worker runs.
func ParseSchedule ¶
ParseSchedule understands a cron expression, a descriptor, or plain text ("Every two hours", "Daily at 6 AM", "Weekdays at 9:30", "Every Monday at 8 PM") in the time zone named tz ("" for the machine's). Plain text is translated by fixed rules, never guessed: anything else is an error.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps which workers are enabled, at which hash, in one file for the user (~/.blitz/workers.json). The service is its only writer.
func (*Store) State ¶
State says whether the worker w, found in the workspace dir, may run. A worker Load reported invalid is StateInvalid.
func (*Store) Workspaces ¶
Workspaces are the directories with at least one enabled worker, which the service watches even when no client has them open.
type Worker ¶
type Worker struct {
Name string
Description string
// Dir is the worker's directory; Path its WORKER.md.
Dir, Path string
// Hash identifies the worker's files: enabling pins it, so any change
// needs re-enabling. Format "sha256:<hex>", as for skills.
Hash string
Schedule Schedule
Agent string
Model string
// Permissions are what the worker asks to do without approval.
Permissions []Permission
Limits api.Limits
// Overlap is "skip" (a run still going when the next is due skips it).
Overlap string
// CatchUp is "none" or "once" (run once for runs missed while the
// service wasn't running).
CatchUp string
// Prompt is the workflow: WORKER.md's body.
Prompt string
}
Worker is a worker as read from its directory.