runtime

package
v0.32.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentEvent added in v0.31.0

type AgentEvent interface {
	// contains filtered or unexported methods
}

AgentEvent is the normalized event interface for runtime-agnostic rendering. Each concrete event type implements this with a no-op marker method.

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 Claude Code backend. Prefer ResolveFromConfig for org-aware selection.

func Resolve added in v0.30.0

func Resolve(name string) (Backend, error)

Resolve returns the agent backend for the given runtime name.

func ResolveFromConfig added in v0.30.0

func ResolveFromConfig(cfg *config.OrgConfig) (Backend, error)

ResolveFromConfig selects the runtime backend from org config defaults.

func ResolveFromPerRepoConfig added in v0.30.0

func ResolveFromPerRepoConfig(cfg *config.PerRepoConfig) (Backend, error)

ResolveFromPerRepoConfig selects the runtime backend from per-repo config.

type BehaviourOpResult added in v0.30.0

type BehaviourOpResult struct {
	Description string `json:"description"`
	Success     bool   `json:"success"`
	Error       string `json:"error,omitempty"`
}

BehaviourOpResult records the outcome of one scripted operation.

type BehaviourOperation added in v0.30.0

type BehaviourOperation struct {
	Description string `yaml:"description" json:"description"`
	Op          string `yaml:"op" json:"op"`
	Args        string `yaml:"args" json:"args"`
	Content     string `yaml:"content,omitempty" json:"content,omitempty"`
}

BehaviourOperation is a single scripted step for the dummy runtime.

type BehaviourResults added in v0.30.0

type BehaviourResults struct {
	Operations []BehaviourOpResult `json:"operations"`
}

BehaviourResults is written to output/behaviour-results.json in the sandbox.

type BehaviourScript added in v0.30.0

type BehaviourScript struct {
	Ops []BehaviourOperation `yaml:"ops"`
}

BehaviourScript is the YAML committed to .fullsend/behaviour/current-scenario.yaml.

func LoadBehaviourScript added in v0.30.0

func LoadBehaviourScript(path string) (*BehaviourScript, error)

LoadBehaviourScript reads and parses a behaviour scenario script from disk.

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 DummyRuntime added in v0.30.0

type DummyRuntime struct {
	ExecFn         sandboxExecFunc
	UploadFn       sandboxUploadFunc
	WriteResultsFn writeBehaviourResultsFunc
}

DummyRuntime executes scripted operations in the real OpenShell sandbox. ExecFn, UploadFn, and WriteResultsFn are optional test overrides; production uses sandbox.Exec, sandbox.Upload, and writeBehaviourResults.

func (DummyRuntime) Bootstrap added in v0.30.0

func (r DummyRuntime) Bootstrap(input BootstrapInput) error

func (DummyRuntime) ClearIterationArtifacts added in v0.30.0

func (r DummyRuntime) ClearIterationArtifacts(sandboxName string) error

func (DummyRuntime) ConfigDir added in v0.30.0

func (DummyRuntime) ConfigDir() string

func (DummyRuntime) EmitTranscriptErrors added in v0.30.0

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

func (DummyRuntime) EnvExports added in v0.30.0

func (DummyRuntime) EnvExports() []string

func (DummyRuntime) ExtractDebugLog added in v0.30.0

func (DummyRuntime) ExtractDebugLog(_ string, _ string, _ string) error

func (DummyRuntime) ExtractTranscripts added in v0.30.0

func (DummyRuntime) ExtractTranscripts(_ string, _ string, _ string) error

func (DummyRuntime) Name added in v0.30.0

func (DummyRuntime) Name() string

func (DummyRuntime) ParseTranscriptErrors added in v0.30.0

func (DummyRuntime) ParseTranscriptErrors(_ string) []TranscriptError

func (DummyRuntime) ParseTranscriptFile added in v0.30.0

func (DummyRuntime) ParseTranscriptFile(_ string) (TranscriptError, bool)

func (DummyRuntime) Run added in v0.30.0

func (r DummyRuntime) Run(ctx context.Context, params RunParams, printer *ui.Printer, _ time.Time, _ *RunMetrics) (int, error)

func (DummyRuntime) System added in v0.30.0

func (DummyRuntime) System() string

func (DummyRuntime) WorkspaceDir added in v0.30.0

func (DummyRuntime) WorkspaceDir() string

type ErrorEvent added in v0.31.0

type ErrorEvent struct {
	ErrorType string
	Message   string
}

ErrorEvent is emitted when the runtime reports an error.

type EventRenderer added in v0.31.0

type EventRenderer struct {
	// contains filtered or unexported fields
}

EventRenderer renders normalized AgentEvent values to a Printer. It tracks block state (text/thinking) so transitions between event types produce clean output boundaries.

func NewEventRenderer added in v0.31.0

func NewEventRenderer(printer *ui.Printer) *EventRenderer

NewEventRenderer creates a renderer that writes to the given printer.

func (*EventRenderer) Handle added in v0.31.0

func (r *EventRenderer) Handle(evt AgentEvent)

Handle dispatches a single AgentEvent to the appropriate rendering method.

type InitEvent added in v0.31.0

type InitEvent struct {
	Model   string
	Version string
}

InitEvent is emitted once at stream start with runtime metadata.

type ResultEvent added in v0.31.0

type ResultEvent struct {
	NumTurns                 int
	TotalCostUSD             float64
	IsError                  bool
	ErrorMessage             string
	Subtype                  string
	InputTokens              int
	OutputTokens             int
	CacheCreationInputTokens int
	CacheReadInputTokens     int
}

ResultEvent is emitted once at stream end with final metrics.

type RetryEvent added in v0.31.0

type RetryEvent struct {
	Attempt    int
	MaxRetries int
	DelayMs    int
	Error      string
}

RetryEvent is emitted when the runtime retries an API call.

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
	FullsendDir   string
	PluginDirs    []string
	Debug         string
	Timeout       time.Duration
	OutputPath    string           // if set, tee stream-json stdout to this file
	OnEvent       func(AgentEvent) // if non-nil, called with normalized events during Run
}

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 TextEvent added in v0.31.0

type TextEvent struct {
	Text string
}

TextEvent carries an incremental assistant text delta.

type ThinkingEvent added in v0.31.0

type ThinkingEvent struct {
	Text string
}

ThinkingEvent carries an incremental thinking text delta.

type TokensEvent added in v0.31.0

type TokensEvent struct {
	InputTokens  int
	OutputTokens int
	CacheRead    int
	CacheWrite   int
}

TokensEvent carries incremental token usage counters.

type ToolUseEvent added in v0.31.0

type ToolUseEvent struct {
	Name    string
	Summary string
}

ToolUseEvent is emitted when a tool invocation completes. Name is the raw tool name from the runtime stream. Summary is a one-line context string from extractSafeContext; it is empty for tools not recognized by that function.

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