claude

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 16 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 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

View Source
const VerifiedVersion = "2.1.316"

VerifiedVersion is the Claude Code version the flags were checked against (docs/compat.md).

Variables

View Source
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

func CompareVersions(a, b string) int

CompareVersions compares two dotted versions ("2.1.316"): -1, 0 or 1. Missing or non-numeric parts count as 0.

func LastJSONBlock

func LastJSONBlock(text string) []byte

LastJSONBlock returns the last fenced json block in text.

func Policy

func Policy(agent string, p config.Profile, memory string) (string, error)

Policy renders the system-prompt addition for a worker.

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.

func SameMinor

func SameMinor(a, b string) bool

SameMinor reports whether two versions share major and minor ("2.1").

func ToolBase

func ToolBase(t string) string

ToolBase strips a permission pattern to the tool name: "Bash(git log:*)" -> "Bash".

func WorkerEnv

func WorkerEnv(base []string, req *runner.Request) []string

WorkerEnv builds the child environment: the daemon's environment minus Claude Code session variables and stale SMIF_* values, plus the run's own SMIF_* variables.

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

func Probe(ctx context.Context, command string) *Caps

Probe runs `claude --version` and `claude --help` and parses the flags. It never calls the API.

func (*Caps) Lines

func (c *Caps) Lines() []string

Lines describes each probed item for doctor and admin.health.

func (*Caps) OK

func (c *Caps) OK() bool

OK reports whether worker runs can proceed.

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.

func (*Runner) Compact

func (r *Runner) Compact(ctx context.Context, req *runner.Request, previous string) (string, *runner.Outcome)

Compact runs one compaction turn on the old session and returns the new memory text (max 4000 chars) (RFC 6.8).

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, req *runner.Request) *runner.Outcome

Run implements runner.Runner.

Jump to

Keyboard shortcuts

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