runtime

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package runtime defines the execution seam (backlog AO-014, spec §6.2).

core depends only on these interfaces; the concrete executors live in the exec module (exec/native spawns real CLIs, exec/fake powers unit tests) and are wired in by cmd/fort. This is the only path from core to execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType string

EventType enumerates normalized run events streamed from any runtime.

const (
	EventStarted EventType = "started" // process spawned
	EventStdout  EventType = "stdout"  // raw stdout line
	EventStderr  EventType = "stderr"  // raw stderr line
	EventMessage EventType = "message" // normalized assistant/output message
	EventExited  EventType = "exited"  // process exited (Code set)
	EventError   EventType = "error"   // runtime-level error (Data set)
	// EventTool: the agent invoked a tool (spec 030). Data is a compact JSON
	// object {"name":..., "summary":...}.
	EventTool EventType = "tool"
	// EventSubagent: the agent spawned a sub-task (spec 030; claude's Task
	// tool). Data is {"description":..., "agent":...}.
	EventSubagent EventType = "subagent"
)

type Run

type Run interface {
	ID() string
	// Stream returns the event channel; it is closed when the run terminates.
	Stream() <-chan RunEvent
	// Signal injects input into a running interactive task (HITL).
	Signal(input string) error
	// Cancel terminates the run.
	Cancel() error
	// Status returns the current status.
	Status() Status
	// Wait blocks until the run terminates and returns the terminal status.
	Wait() Status
}

Run is a handle to a dispatched invocation: stream (events), status, and signal (stdin injection for human-in-the-loop) + cancel.

type RunEvent

type RunEvent struct {
	RunID string    `json:"run_id"`
	Type  EventType `json:"type"`
	Time  time.Time `json:"time"`
	Data  string    `json:"data,omitempty"`
	Code  int       `json:"code,omitempty"` // exit code for EventExited
}

RunEvent is one normalized event in a run's stream.

type RunSpec

type RunSpec struct {
	RunID   string   // caller-assigned id, echoed back on the Run
	Agent   string   // provider key: claude | codex | openclaw | hermes
	Prompt  string   // the task body handed to the CLI
	Workdir string   // scoped working directory
	Env     []string // additional KEY=VALUE pairs
	// Machine is the resolved target host (spec 022). Empty means "here": the
	// local runtime handles it. A non-local name routes the spec to that
	// machine's runtime (exec/cluster). Providers ignore this field.
	Machine string
}

RunSpec describes one agent invocation.

type Runtime

type Runtime interface {
	// Dispatch launches spec and returns a Run handle. The returned Run begins
	// streaming immediately; the caller drains Stream() and/or calls Wait().
	Dispatch(ctx context.Context, spec RunSpec) (Run, error)
	// Name identifies the runtime implementation (for diagnostics).
	Name() string
}

Runtime spawns agent invocations. Implementations must be safe for concurrent Dispatch calls.

type State

type State string

State is a run's lifecycle state.

const (
	StateRunning   State = "running"
	StateSucceeded State = "succeeded"
	StateFailed    State = "failed"
	StateCanceled  State = "canceled"
)

type Status

type Status struct {
	State    State  `json:"state"`
	ExitCode int    `json:"exit_code"`
	Err      string `json:"err,omitempty"`
}

Status is a run's terminal-or-current status.

func (Status) Terminal

func (s Status) Terminal() bool

Terminal reports whether the run has finished.

Jump to

Keyboard shortcuts

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