Documentation
¶
Overview ¶
Package claude runs Claude Code workers headless (RFC 6.3).
The argv is built only from validated config; nothing from the message can reach it. The envelope is passed on stdin, wrapped as untrusted data.
Index ¶
- Constants
- Variables
- func CompareVersions(a, b string) int
- func LastJSONBlock(text string) []byte
- func Policy(agent string, p config.Profile, memory string) (string, error)
- func Prompt(agent string, e *envelope.Envelope, attempt int, attachments map[string]string, ...) string
- func SameMinor(a, b string) bool
- func ToolBase(t string) string
- func WorkerEnv(base []string, req *runner.Request) []string
- type Caps
- type Runner
Constants ¶
const VerifiedVersion = "2.1.316"
VerifiedVersion is the Claude Code version the flags were checked against (docs/compat.md).
Variables ¶
var AlwaysDenied = []string{"Bash(*--output*)"}
AlwaysDenied are rules every worker gets: git can write files through --output, which a Bash(git log:*) allowlist would otherwise permit.
Functions ¶
func CompareVersions ¶
CompareVersions compares two dotted versions ("2.1.316"): -1, 0 or 1. Missing or non-numeric parts count as 0.
func LastJSONBlock ¶
LastJSONBlock returns the last fenced json block in text.
func Prompt ¶
func Prompt(agent string, e *envelope.Envelope, attempt int, attachments map[string]string, schema bool) string
Prompt renders the inbound prompt (stdin) for a message.
Types ¶
type Caps ¶
type Caps struct {
Version string
StreamJSON bool
Resume bool
SessionID bool
AppendSystemPrompt bool
AllowedTools bool
DisallowedTools bool
PermissionModes []string
PermissionPrompts bool
MCPConfig bool
StrictMCP bool
JSONSchema bool
SafeMode bool
Effort bool
MaxBudget bool
Settings bool
Name bool
Tools bool
Problems []string
}
Caps records which CLI features the installed Claude Code supports (RFC 10.2). Each has a fallback in the runner.
func AssumedCaps ¶
func AssumedCaps() *Caps
AssumedCaps is the verified feature set, used when no probe ran.
func Probe ¶
Probe runs `claude --version` and `claude --help` and parses the flags. It never calls the API.
type Runner ¶
type Runner struct {
Command string // claude binary (absolute path preferred)
Caps *Caps
MaxOutput int64
SmifBinary string // for the onward MCP server
Socket string
BaseEnv []string
// Protected are directories no worker may read or write whatever its
// profile says: Smif's config (tokens) and data (other agents' mail).
Protected []string
}
Runner runs `claude -p` workers.
func (*Runner) Argv ¶
func (r *Runner) Argv(req *runner.Request, mcpConfig, policy string, schema string, maxTurns int) []string
Argv builds the claude argv for a request. prompt is not part of argv.