runner

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 8 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 runner defines the handler interface and the structured result every handler returns (RFC 6.3, 7.5, R-RUN-2).

Index

Constants

View Source
const ResultSchema = `{"type":"object","additionalProperties":false,"required":["status","summary"],"properties":{` +
	`"status":{"type":"string","enum":["done","needs_human","failed"]},` +
	`"summary":{"type":"string","maxLength":280},` +
	`"reply":{"type":"string","maxLength":32768},` +
	`"reply_data":{"type":"object"},` +
	`"artifacts":{"type":"array","items":{"type":"object","required":["path"],"properties":{"path":{"type":"string"},"description":{"type":"string"}}}},` +
	`"human_question":{"type":"string"},` +
	`"followups":{"type":"array","items":{"type":"object","required":["to","kind","intent","subject"],"properties":{` +
	`"to":{"type":"string"},"kind":{"type":"string","enum":["tell","ask","event"]},"intent":{"type":"string"},` +
	`"subject":{"type":"string"},"body":{"type":"string"},"priority":{"type":"string","enum":["low","normal","high","urgent"]}}}}}}`

ResultSchema is the JSON Schema passed to --json-schema.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	Path        string `json:"path"`
	Description string `json:"description,omitempty"`
}

Artifact is a file the handler produced, relative to its workspace.

type Failure

type Failure string

Failure classifies why a run did not produce a result.

const (
	FailNone          Failure = ""
	FailTimeout       Failure = "timeout"
	FailOutput        Failure = "output_exceeded"
	FailExit          Failure = "exit"
	FailInvalid       Failure = "invalid_result"
	FailOverload      Failure = "overload"
	FailContext       Failure = "context_length"
	FailUnavailable   Failure = "claude_unavailable"
	FailCancelled     Failure = "cancelled"
	FailHandlerFailed Failure = "handler_failed" // result status failed
	FailMaxTurns      Failure = "max_turns"
	FailBudget        Failure = "run_budget"
	FailSessionLost   Failure = "session_lost" // --resume id no longer exists
)

Failure kinds.

type Followup

type Followup struct {
	To       string          `json:"to"`
	Kind     string          `json:"kind"`
	Intent   string          `json:"intent"`
	Subject  string          `json:"subject"`
	Body     string          `json:"body,omitempty"`
	Priority string          `json:"priority,omitempty"`
	Data     json.RawMessage `json:"data,omitempty"`
}

Followup is a message the daemon sends after the run on the worker's behalf.

type Outcome

type Outcome struct {
	Result       *Result
	Failure      Failure
	Error        string
	SessionID    string
	CostUSD      float64
	InputTokens  int64
	OutputTokens int64
	UsageJSON    string
	Stderr       string
	NumTurns     int
	Repaired     bool
}

Outcome is what a runner returns.

type Request

type Request struct {
	Agent      *config.Agent
	Message    *envelope.Envelope
	Attempt    int
	RunID      string
	RunToken   string
	Profile    config.Profile
	Workspace  string            // cwd
	BlobDir    string            // per-run read-only attachment copies
	Attachment map[string]string // attachment name -> read-only path
	SessionID  string            // worker session to resume ("" = new)
	// ForkSession resumes SessionID as a new session (--fork-session): a
	// worker that answers with an interactive session's context (ADR-0013).
	ForkSession bool
	Memory      string   // memory.md contents for the policy prompt
	Transcript  string   // where to write the raw stream
	Command     []string // command handler argv
	Timeout     int      // command handler timeout in seconds
	// OnStart reports the process ids; OnSession reports the session id.
	OnStart   func(pid, pgid int)
	OnSession func(id string)
}

Request is what the daemon hands a runner.

type Result

type Result struct {
	Status        string          `json:"status"`
	Summary       string          `json:"summary"`
	Reply         string          `json:"reply,omitempty"`
	ReplyData     json.RawMessage `json:"reply_data,omitempty"`
	Artifacts     []Artifact      `json:"artifacts,omitempty"`
	HumanQuestion string          `json:"human_question,omitempty"`
	Followups     []Followup      `json:"followups,omitempty"`
}

Result is the validated handler result.

func ParseResult

func ParseResult(b []byte) (*Result, error)

ParseResult decodes and validates a result object.

func (*Result) Validate

func (r *Result) Validate() error

Validate enforces the RFC 6.3 schema.

type Runner

type Runner interface {
	Run(ctx context.Context, req *Request) *Outcome
}

Runner runs one handler invocation.

Directories

Path Synopsis
Package claude runs Claude Code workers headless (RFC 6.3).
Package claude runs Claude Code workers headless (RFC 6.3).
Package codex runs a read-only mail worker on `codex exec` (ADR-0022).
Package codex runs a read-only mail worker on `codex exec` (ADR-0022).
Package command runs deterministic command handlers (RFC 7.5): the envelope on stdin, one JSON result object on stdout, no LLM.
Package command runs deterministic command handlers (RFC 7.5): the envelope on stdin, one JSON result object on stdout, no LLM.

Jump to

Keyboard shortcuts

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