runtime

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Runtime
	Transcripts TranscriptHandler
}

Backend pairs the active runtime with its transcript/debug artifact handler.

func Default

func Default() Backend

Default returns the configured agent backend (Claude Code today).

type BootstrapInput

type BootstrapInput interface {
	SandboxName() string
	// AgentPath returns the local filesystem path to the agent definition file.
	// For cached agents this may be a content-addressed path with a generic basename.
	AgentPath() string
	// AgentName returns the logical agent name (e.g. "review") used to construct
	// the destination filename as {name}.md inside the sandbox. Populated from
	// the CLI positional argument; must not be empty in production (enforced by
	// cobra arg validation in cmd/fullsend).
	AgentName() string
	SkillDirs() []string
	PluginDirs() []string
}

BootstrapInput is the portable contract every runtime needs to provision agent content into the sandbox. Implementations live outside this package (runner adapter, tests).

type ClaudeHooksBootstrap

type ClaudeHooksBootstrap interface {
	ClaudeSandboxHooks() security.ClaudeSandboxHooks
}

ClaudeHooksBootstrap is an optional extension for Claude Code sandbox tool hooks. ClaudeRuntime.Bootstrap type-asserts for this; other runtimes ignore it.

type ClaudeRuntime

type ClaudeRuntime struct{}

ClaudeRuntime implements Runtime using the Claude Code CLI.

func (ClaudeRuntime) Bootstrap

func (r ClaudeRuntime) Bootstrap(input BootstrapInput) error

func (ClaudeRuntime) ClearIterationArtifacts

func (r ClaudeRuntime) ClearIterationArtifacts(sandboxName string) error

func (ClaudeRuntime) ConfigDir

func (ClaudeRuntime) ConfigDir() string

func (ClaudeRuntime) EmitTranscriptErrors

func (ClaudeRuntime) EmitTranscriptErrors(w io.Writer, summaries []TranscriptError)

func (ClaudeRuntime) EnvExports

func (r ClaudeRuntime) EnvExports() []string

func (ClaudeRuntime) ExtractDebugLog

func (r ClaudeRuntime) ExtractDebugLog(sandboxName, localPath, debug string) error

func (ClaudeRuntime) ExtractTranscripts

func (r ClaudeRuntime) ExtractTranscripts(sandboxName, agentLabel, outputDir string) error

func (ClaudeRuntime) Name

func (ClaudeRuntime) Name() string

func (ClaudeRuntime) ParseTranscriptErrors

func (ClaudeRuntime) ParseTranscriptErrors(transcriptDir string) []TranscriptError

func (ClaudeRuntime) ParseTranscriptFile added in v0.27.0

func (ClaudeRuntime) ParseTranscriptFile(path string) (TranscriptError, bool)

func (ClaudeRuntime) Run

func (ClaudeRuntime) Run(ctx context.Context, params RunParams, printer *ui.Printer, start time.Time, metrics *RunMetrics) (int, error)

func (ClaudeRuntime) System added in v0.25.0

func (ClaudeRuntime) System() string

System returns the OTEL GenAI `gen_ai.system` vendor for Claude Code's models.

func (ClaudeRuntime) WorkspaceDir

func (ClaudeRuntime) WorkspaceDir() string

type RunMetrics

type RunMetrics struct {
	ToolCalls                atomic.Int32
	NumTurns                 int     `json:"num_turns"`
	TotalCostUSD             float64 `json:"total_cost_usd"`
	InputTokens              int     `json:"input_tokens"`
	OutputTokens             int     `json:"output_tokens"`
	CacheCreationInputTokens int     `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int     `json:"cache_read_input_tokens"`
	Model                    string  `json:"model"`
}

RunMetrics collects execution statistics from stream parsing.

type RunParams

type RunParams struct {
	SandboxName   string
	AgentBaseName string
	Model         string
	RepoDir       string
	PluginDirs    []string
	Debug         string
	Timeout       time.Duration
	OutputPath    string // if set, tee stream-json stdout to this file
}

RunParams configures a single agent invocation inside the sandbox.

type Runtime

type Runtime interface {
	Name() string
	// System returns the OTEL GenAI `gen_ai.system` value (the model vendor) for
	// this runtime, e.g. "anthropic". Kept on the runtime so telemetry stays
	// runtime-agnostic rather than hardcoding a vendor in the CLI (ADR 0050).
	System() string
	ConfigDir() string
	WorkspaceDir() string
	EnvExports() []string
	Bootstrap(input BootstrapInput) error
	Run(ctx context.Context, params RunParams, printer *ui.Printer, start time.Time, metrics *RunMetrics) (exitCode int, err error)
	ClearIterationArtifacts(sandboxName string) error
}

Runtime is an agent execution backend (LLM tool-use loop) inside the sandbox.

type TranscriptError

type TranscriptError struct {
	Source       string
	IsError      bool
	ErrorMessage string
	Subtype      string
}

TranscriptError holds extracted error information from a runtime transcript.

type TranscriptHandler

type TranscriptHandler interface {
	ExtractTranscripts(sandboxName, agentLabel, outputDir string) error
	ExtractDebugLog(sandboxName, localPath, debug string) error
	ParseTranscriptErrors(transcriptDir string) []TranscriptError
	// ParseTranscriptFile parses a single JSONL transcript or output file
	// and returns the last result event, if any. Use this to check a tee'd
	// output.jsonl for is_error:true without scanning an entire directory.
	ParseTranscriptFile(path string) (TranscriptError, bool)
	EmitTranscriptErrors(w io.Writer, summaries []TranscriptError)
}

TranscriptHandler extracts runtime conversation artifacts from the sandbox and surfaces errors in operator-facing logs (e.g. GitHub Actions annotations). Implementations are runtime-specific (Claude stream-json today).

Jump to

Keyboard shortcuts

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