proto

package
v0.0.13-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 17 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 proto defines the JSON wire format spoken by oac-daemon over the reverse WebSocket tunnel to the OpenAgentCore server. Both ends import this package. See docs/runtime-protocol.md for the integration contract. Adding an event means updating the shared definition and both sides at once.

Topology: daemon dials OUT (firewall-friendly). Every frame is one JSON Envelope; the receiver routes by Type without partial-decoding Payload. Downstream = server → daemon (outbound.go), upstream = daemon → server (inbound.go). Event names match connector.PromptEvent.Type 1:1 so the gateway can translate without a lookup table.

Envelope.ID correlation:

  • prompt_cancel: ID = RunID.
  • delta / tool_call / usage / error / done: ID = originating RunID.
  • execution_prepare / execution_start / execution_release and preparation_status: ID = preparation request ID, never RunID.
  • runtime_prepare / runtime_prepare_result: ID = connection-local transfer ID.
  • heartbeats carry no ID.

Index

Constants

View Source
const (
	TypeFunctionCall          = "function_call"
	TypeFunctionCallWithdrawn = "function_call_withdrawn"
	TypeFunctionResult        = "function_result"
)
View Source
const (
	// TypeDelta carries an incremental text fragment. Daemon
	// accumulates these so the matching done frame can carry the
	// full Final.Content.
	TypeDelta = "delta"

	// TypeOutputMessage carries opt-in native message boundaries and completion snapshots.
	TypeOutputMessage = "output_message"

	// TypeThinking carries an internal-thinking fragment. Gateway
	// forwards as a plain EventDelta so existing renderers keep
	// working.
	TypeThinking = "thinking"

	// TypeToolCall carries a tool invocation. Stage=="before" runs
	// before the call, "after" runs after.
	TypeToolCall = "tool_call"

	// TypeInteractionDecisionAck confirms that the daemon-side agent
	// accepted (or definitively rejected) a function result or cancellation.
	// The server must not mark the delivery terminal before this frame arrives.
	TypeInteractionDecisionAck = "interaction_decision_ack"

	// TypeUsage reports a cumulative usage snapshot for the current execution.
	// Repeated snapshots, including the final Done snapshot, replace rather than add.
	TypeUsage = "usage"

	// TypeError signals the prompt failed. Daemon MUST emit a Done
	// frame immediately after to close the stream.
	TypeError = "error"

	// TypeDone signals the prompt completed. Payload carries the
	// equivalent of a sync PromptOutput.
	TypeDone = "done"

	// TypeHeartbeat is the daemon's liveness signal. Carries no ID.
	// Gateway uses arrival time to detect dead sessions.
	TypeHeartbeat = "heartbeat"
)

Type constants for daemon → server frames. Names match connector.PromptEvent.Type 1:1 so the gateway can translate without a per-event lookup table.

View Source
const (
	DoneMetaAgentSessionID   = "agent_session_id"
	DoneMetaAgentSessionType = "agent_session_type"
)
View Source
const (
	TypeExecutionPrepare  = "execution_prepare"
	TypeExecutionStart    = "execution_start"
	TypeExecutionRelease  = "execution_release"
	TypePreparationStatus = "preparation_status"
)

Preparation controls use a caller request ID on Envelope.ID, never a RunID. Handles are daemon-generated and valid only on the accepting connection.

View Source
const (
	TypeRuntimePrepare             = "runtime_prepare"
	TypeRuntimePrepareResult       = "runtime_prepare_result"
	RuntimePrepareMaxBudgetMS      = 30 * 60 * 1000
	RuntimePrepareTransferBudgetMS = 2 * 60 * 1000
	RuntimePrepareMaxBytes         = 50 << 20
	RuntimePrepareChunkBytes       = WorkspaceWriteChunkBytes
	RuntimePrepareMaxFrameBytes    = 1 << 20
)
View Source
const (
	TypeSubagentLifecycle = "subagent_lifecycle"
	TypeSubagentTurn      = "subagent_turn"
	TypeSubagentItem      = "subagent_item"
)
View Source
const (
	TypeEnvironmentQuiesce  = "environment_quiesce"
	TypeEnvironmentQuiesced = "environment_quiesced"
	TypeEnvironmentResume   = "environment_resume"
	TypeEnvironmentResumed  = "environment_resumed"
)

Suspension is private hosted lifecycle traffic. Envelope.ID correlates each request; SuspendID fences one persisted suspension attempt across connections.

View Source
const (
	TypeWorkspaceExport          = "workspace_export"
	TypeWorkspaceExportResult    = "workspace_export_result"
	WorkspaceExportChunkBytes    = 64 << 10
	WorkspaceExportMaxFrameBytes = 96 << 10
	// The archive allowance includes bounded headers and padding above 500 MiB of files.
	WorkspaceExportMaxBytes int64 = 528 << 20
)
View Source
const (
	TypeWorkspaceRead            = "workspace_read"
	TypeWorkspaceReadResult      = "workspace_read_result"
	WorkspaceReadMaxBytes        = 1 << 20
	WorkspaceReadMaxRequestBytes = 8 << 10
	WorkspaceReadMaxIDBytes      = 128
	// WorkspaceReadNotDirectory rejects a directory read whose own path is
	// missing, a regular file or a symbolic link. The link is never followed.
	WorkspaceReadNotDirectory = "not_directory"
)
View Source
const (
	TypeWorkspaceWrite          = "workspace_write"
	TypeWorkspaceWriteResult    = "workspace_write_result"
	WorkspaceWriteMaxBytes      = 50 << 20
	WorkspaceWriteChunkBytes    = 64 << 10
	WorkspaceWriteMaxFrameBytes = 96 << 10
)
View Source
const (
	WorkspaceWriteReasonDirectory = "destination_directory"
	WorkspaceWriteReasonUnsafe    = "unsafe_destination"
)

Files.create destination refusals carried in Reason.

View Source
const TypeCommandOutput = "command_output"

TypeCommandOutput carries opt-in incremental output for an observed command.

View Source
const (
	// TypePromptCancel aborts an in-flight prompt. Envelope.ID =
	// RunID. Idempotent — cancelling an unknown / already-finished
	// run is a no-op on the daemon side.
	TypePromptCancel = "prompt_cancel"
)

Type constants for server → daemon frames.

View Source
const TypePromptSteer = "prompt_steer"

TypePromptSteer appends messages to an active run; Envelope.ID is the run ID.

View Source
const TypePromptSteerAck = "prompt_steer_ack"

TypePromptSteerAck reports input receipt phases on the originating run ID.

View Source
const TypeSubagentCoordination = "subagent_coordination"
View Source
const TypeSubagentIdentity = "subagent_identity"

TypeSubagentIdentity carries verified native identity facts; lifecycle uses a separate effect.

View Source
const Version = "0.21.0"

Version identifies the complete Core–Runtime wire contract. Change it when removing or changing a payload or its semantics; deploy both endpoints together.

View Source
const WorkspaceDirectoryMaxEntries = 1024

Variables

This section is empty.

Functions

func NormalizeEngineFailure

func NormalizeEngineFailure(code string, status *int) (string, *int)

NormalizeEngineFailure accepts only neutral, finite classifications. Optional metadata from newer or malformed peers never changes terminal/usage decoding.

func ValidRuntimePrepareRequest

func ValidRuntimePrepareRequest(p RuntimePreparePayload) bool

func ValidRuntimePrepareResult

func ValidRuntimePrepareResult(r RuntimePrepareResultPayload, expected string, offset, size int) bool

ValidRuntimePrepareResult accepts only the expected success receipt or a finite terminal category. An unknown effect can never be represented as rejection.

func ValidWorkspaceDirectory

func ValidWorkspaceDirectory(result *WorkspaceDirectoryResult, limit int) bool

func ValidWorkspaceExportRequest

func ValidWorkspaceExportRequest(p WorkspaceExportPayload) bool

func ValidWorkspaceReadPreparation

func ValidWorkspaceReadPreparation(r PromptRequestPayload) bool

ValidWorkspaceReadPreparation excludes execution configuration. The native adapter supplies temporary state; this request cannot resume or start.

func ValidWorkspaceReadRequest

func ValidWorkspaceReadRequest(request WorkspaceReadPayload) bool

func ValidWorkspaceWriteRequest

func ValidWorkspaceWriteRequest(p WorkspaceWritePayload) bool

func ValidateBinary64Schema

func ValidateBinary64Schema(raw json.RawMessage) error

ValidateBinary64Schema is an adapter restriction for runtimes that deserialize schemas through IEEE-754 JSON numbers. It never rewrites the caller's schema. Other adapters need not apply this restriction.

func VersionCompatible

func VersionCompatible(clientVersion string) bool

VersionCompatible accepts only this contract. Patch drift, prerelease suffixes and malformed versions do not select an implicit compatibility path.

Types

type AgentKindCapabilities

type AgentKindCapabilities struct {
	SubagentObservations  CapabilitySupport `json:"subagent_observations"`
	Streaming             CapabilitySupport `json:"streaming"`
	Usage                 CapabilitySupport `json:"usage"`
	Resume                CapabilitySupport `json:"resume"`
	NativeSessionRecovery CapabilitySupport `json:"native_session_recovery"`
	// RetainedNativeHistory resumes the same native Session after confirmed
	// process shutdown using its retained private state, without replaying input.
	// It does not promise process memory or external connection restoration.
	RetainedNativeHistory CapabilitySupport `json:"retained_native_history"`
	MessageItems          CapabilitySupport `json:"message_items"`

	ToolObservations         CapabilitySupport `json:"tool_observations"`
	EnvironmentNone          CapabilitySupport `json:"environment_none"`
	LocalEnvironment         CapabilitySupport `json:"local_environment"`
	Preparation              CapabilitySupport `json:"preparation"`
	WorkspaceReadPreparation CapabilitySupport `json:"workspace_read_preparation"`
	WorkspaceOutputExport    CapabilitySupport `json:"workspace_output_export"`
	// ExecutionControls accepts the typed execution controls.
	ExecutionControls    CapabilitySupport `json:"execution_controls"`
	StructuredOutput     CapabilitySupport `json:"structured_output"`
	ToolSearch           CapabilitySupport `json:"tool_search"`
	MessageImages        CapabilitySupport `json:"message_images"`
	FunctionResultImages CapabilitySupport `json:"function_result_images"`
	SubagentControl      CapabilitySupport `json:"subagent_control"`
	DurableInputReceipts CapabilitySupport `json:"durable_input_receipts"`
	// DurableTurns includes strict resume, completion release and cancellation snapshots.
	DurableTurns      CapabilitySupport `json:"durable_turns"`
	FunctionTools     CapabilitySupport `json:"function_tools"`
	MCPHTTPTools      CapabilitySupport `json:"mcp_http_tools"`
	MCPHTTPRequired   CapabilitySupport `json:"mcp_http_required"`
	MCPHTTPBearerAuth CapabilitySupport `json:"mcp_http_bearer_auth"`
}

AgentKindCapabilities describes what a daemon-side agent_kind can do inside one prompt session. Every field requires an explicit support decision, including for unavailable engines. Runtime lifecycle requirements are mandatory independently of these optional operations.

func UnsupportedCapabilities added in v0.0.12

func UnsupportedCapabilities() AgentKindCapabilities

UnsupportedCapabilities declares every capability explicitly unsupported.

func (AgentKindCapabilities) MarshalJSON

func (c AgentKindCapabilities) MarshalJSON() ([]byte, error)

func (*AgentKindCapabilities) UnmarshalJSON

func (c *AgentKindCapabilities) UnmarshalJSON(data []byte) error

func (AgentKindCapabilities) ValidateDeclaration

func (c AgentKindCapabilities) ValidateDeclaration() error

ValidateDeclaration covers every field, including future additions. The struct remains flat so new fields cannot bypass validation through nesting.

type CapabilitySupport

type CapabilitySupport uint8

CapabilitySupport requires a deliberate decision. Its zero value is invalid; adding a field cannot silently advertise an implementation as unsupported.

const (
	CapabilityUnspecified CapabilitySupport = iota
	CapabilityUnsupported
	CapabilitySupported
)

func CapabilityFromBool

func CapabilityFromBool(supported bool) CapabilitySupport

CapabilityFromBool converts one explicitly selected capability decision.

func (CapabilitySupport) IsSupported

func (s CapabilitySupport) IsSupported() bool

func (CapabilitySupport) MarshalJSON

func (s CapabilitySupport) MarshalJSON() ([]byte, error)

func (*CapabilitySupport) UnmarshalJSON

func (s *CapabilitySupport) UnmarshalJSON(data []byte) error

type CommandOutputPayload

type CommandOutputPayload struct {
	ID    string `json:"id"`
	Delta string `json:"delta"`
}

CommandOutputPayload references an existing command observation in this run. Delta contains native text, not a complete or byte-exact process output stream.

type DeltaPayload

type DeltaPayload struct {
	ItemID   string `json:"item_id,omitempty"`
	Delta    string `json:"delta"`
	Sequence uint64 `json:"sequence"`
}

DeltaPayload carries an incremental text fragment from the agent.

type DonePayload

type DonePayload struct {
	// SourceCompletedAtMS freezes the native root completion before child settlement.
	SourceCompletedAtMS *int64         `json:"source_completed_at_ms,omitempty"`
	Content             string         `json:"content"`
	Transcript          string         `json:"transcript,omitempty"`
	Usage               Usage          `json:"usage,omitzero"`
	Metadata            map[string]any `json:"metadata,omitempty"`
}

DonePayload mirrors connector.PromptOutput shape. Redeclared (not embedded) so a refactor of PromptOutput doesn't silently flip the wire shape.

type Envelope

type Envelope struct {
	// Type tags the payload shape. Must be one of the constants in
	// inbound.go (upstream) or outbound.go (downstream).
	Type string `json:"type"`

	// ID correlates frames to a logical work unit; meaning depends on
	// Type (see per-event comments). Omitted when empty (heartbeats).
	ID string `json:"id,omitempty"`

	// Payload is the type-specific body, marshalled separately so the
	// gateway can route on Type without double-decoding.
	Payload json.RawMessage `json:"payload,omitempty"`

	// Trace is the W3C `traceparent` value
	// ("00-{32hex trace_id}-{16hex span_id}-{2hex flags}") for the
	// logical request. Server-issued envelopes carry the gateway's
	// ctx carrier; daemon-issued envelopes carry the daemon's. Omitted
	// when no trace is in scope (for example, heartbeats).
	// Receivers MUST tolerate missing/unparseable values — both mean
	// "mint a fresh trace locally", never reject.
	Trace string `json:"trace,omitempty"`
}

Envelope is the outer JSON frame. Payload is held as raw JSON so the routing layer can dispatch by Type before paying a per-event decode.

func NewEnvelope

func NewEnvelope(typ string, id string, payload any) (Envelope, error)

NewEnvelope marshals payload into an Envelope. A nil payload yields an Envelope with no Payload field (for bodyless types like prompt_cancel).

func NewEnvelopeWithTrace

func NewEnvelopeWithTrace(typ string, id string, payload any, traceparent string) (Envelope, error)

NewEnvelopeWithTrace stamps the given W3C traceparent string into Envelope.Trace. Pass "" to skip. String (not typed Carrier) so this package stays free of an import on internal/obs/log.

func (Envelope) DecodePayload

func (e Envelope) DecodePayload(out any) error

DecodePayload unpacks Envelope.Payload into out. An empty Payload is a non-error so a bodyless prompt_cancel decodes cleanly.

type EnvironmentMCP

type EnvironmentMCP struct {
	InstallationRoot string
	WorkspaceRoot    string
	PackageRoot      string
	Server           agentplugin.MCPServer
	BearerToken      *string
}

EnvironmentMCP is transient Runtime configuration. Do not log it: HTTP headers and the selected user bearer may be confidential. It is not agent.tools MCP.

type EnvironmentSuspendPayload

type EnvironmentSuspendPayload struct {
	// Rollback permits a no-op resume on the still-running source after an
	// uncertain quiesce. It never authorizes cold replacement on snapshot restore.
	Rollback      bool   `json:"rollback,omitempty"`
	EnvironmentID string `json:"environment_id"`
	SuspendID     string `json:"suspend_id"`
}

func (EnvironmentSuspendPayload) SameSuspension

SameSuspension compares ownership, independently of the requested recovery mode.

type EnvironmentSuspendResultPayload

type EnvironmentSuspendResultPayload struct {
	EnvironmentID string `json:"environment_id"`
	SuspendID     string `json:"suspend_id"`
	Accepted      bool   `json:"accepted"`
	ErrorCode     string `json:"error_code,omitempty"`
}

An accepted quiesce confirms closed admission, drained work and receipts, and retention of settled idle native Executors with idle expiry fenced until exact authenticated resume. It does not confirm a filesystem checkpoint or that provider-owned compute has stopped.

type ErrorPayload

type ErrorPayload struct {
	Error      string `json:"error"`
	Code       string `json:"code,omitempty"`
	HTTPStatus *int   `json:"http_status,omitempty"`
}

ErrorPayload reports a prompt-level failure.

func (*ErrorPayload) UnmarshalJSON

func (p *ErrorPayload) UnmarshalJSON(raw []byte) error

type ExecutionControls

type ExecutionControls struct {
	WebSearch *WebSearchControl `json:"web_search,omitempty"`
	// ProgrammaticToolCalling is the official programmatic_tool_calling.enabled value.
	ProgrammaticToolCalling *bool  `json:"programmatic_tool_calling,omitempty"`
	ReasoningEffort         string `json:"reasoning_effort,omitempty"`
	ReasoningSummary        string `json:"reasoning_summary,omitempty"`
	// ServiceTier is never "auto": auto means unset.
	ServiceTier   string        `json:"service_tier,omitempty"`
	TextVerbosity string        `json:"text_verbosity,omitempty"`
	OutputFormat  *OutputFormat `json:"output_format,omitempty"`
}

ExecutionControls carries the official execution options the Session sets or whose official default applies. An absent member means the Harness's native default: Core never sends a value the official configuration does not define. Send only to a peer advertising execution_controls.

type ExecutionPreparePayload

type ExecutionPreparePayload struct {
	SessionID     string               `json:"session_id"`
	Configuration PromptRequestPayload `json:"configuration"`
}

ExecutionPreparePayload reuses execution configuration without accepting input. SessionID identifies the immutable configuration owner; each request reserves a separate Turn admission on its Runtime Executor.

type ExecutionReleasePayload

type ExecutionReleasePayload struct {
	Handle string `json:"handle"`
}

type ExecutionStartPayload

type ExecutionStartPayload struct {
	ExecutorID string       `json:"executor_id"`
	Handle     string       `json:"handle"`
	RunID      string       `json:"run_id"`
	Input      MessageInput `json:"input"`
}

type FunctionCallPayload

type FunctionCallPayload struct {
	CallID    string          `json:"call_id"`
	NativeID  string          `json:"native_id,omitempty"`
	TurnID    string          `json:"turn_id,omitempty"`
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments"`
}

FunctionCallPayload belongs to the Run identified by Envelope.ID. NativeID and TurnID name the native child and its Turn when a Subagent made the call, with the meaning they have in SubagentTurnPayload; both are empty for a call of the Run itself.

type FunctionCallWithdrawnPayload added in v0.0.12

type FunctionCallWithdrawnPayload struct {
	CallID   string `json:"call_id"`
	NativeID string `json:"native_id,omitempty"`
	TurnID   string `json:"turn_id,omitempty"`
}

FunctionCallWithdrawnPayload tells that the native Harness will never apply a result for the call, which CallID, NativeID and TurnID identify as in FunctionCallPayload.

type FunctionResultPayload

type FunctionResultPayload struct {
	DeliveryID string         `json:"delivery_id"`
	CallID     string         `json:"call_id"`
	Success    bool           `json:"success"`
	Content    []InputContent `json:"content"`
}

func (FunctionResultPayload) ValidateContent

func (r FunctionResultPayload) ValidateContent() error

type FunctionTool

type FunctionTool struct {
	Name         string          `json:"name"`
	Description  string          `json:"description"`
	Parameters   json.RawMessage `json:"parameters"`
	DeferLoading bool            `json:"defer_loading,omitempty"`
}

type HarnessConfig

type HarnessConfig = map[string]any

HarnessConfig is the shared JSON-object wire shape for native model parameters. The selected Harness owns its field semantics; no cross-Harness translation is implied. Omission and {} mean empty configuration; null, arrays and encoded objects larger than 16 KiB of serialized UTF-8 bytes are invalid. Unknown and reserved fields must fail before model input, without echoing submitted keys or values. Connection, authentication, execution policy and lifecycle are not configurable here. Runtime validates the copied Session snapshot against shared native support before adapters configure the direct provider connection. The Executor retains that configuration across Turns and rebuilds. Incompatible snapshots fail explicitly; no protocol conversion, rewrite or migration is performed.

type HeartbeatPayload

type HeartbeatPayload struct {
	Timestamp           int64                `json:"ts"`
	ActiveRequests      int                  `json:"active_requests"`
	DaemonVersion       string               `json:"daemon_version,omitempty"`
	SupportedAgentKinds []SupportedAgentKind `json:"supported_agent_kinds,omitempty"`
}

HeartbeatPayload advertises only explicit engine descriptors. Missing supported_agent_kinds establishes no engine availability or capabilities.

type InputContent

type InputContent struct {
	Type     string  `json:"type"`
	Text     *string `json:"text,omitempty"`
	ImageURL *string `json:"image_url,omitempty"`
}

InputContent is an ordered text or image part, shared by user and tool input. ImageURL is passed unchanged; native encoding belongs to the adapter.

func (InputContent) Validate

func (p InputContent) Validate() error

type InputMessage

type InputMessage struct {
	Content []InputContent `json:"content"`
}

type InteractionDecisionAckPayload

type InteractionDecisionAckPayload struct {
	DeliveryID string `json:"delivery_id"`
	Applied    bool   `json:"applied"`
	ErrorCode  string `json:"error_code,omitempty"`
	Error      string `json:"error,omitempty"`
	// Outcome preserves native continuity when cancellation does not emit Done.
	Outcome *DonePayload `json:"outcome,omitempty"`
}

InteractionDecisionAckPayload is the daemon's application-level receipt for a server decision. DeliveryID correlates one resolve attempt without relying on the request id, which may outlive a reconnect or timeout race.

type LocalEnvironment

type LocalEnvironment struct {
	CapabilityRoot     string                   `json:"-"`
	ID                 string                   `json:"id"`
	WorkspaceDirectory string                   `json:"workspace_directory"`
	CapabilitySources  *agentcapabilities.Input `json:"capability_sources"`
	// WorkspaceRoot is the bound local root the daemon supplies for execution;
	// wire input cannot supply it. Read-only preparation leaves it empty.
	WorkspaceRoot string `json:"-"`
	// Capabilities is derived from the frozen selection for engine qualification;
	// Runtime still ensures and loads the protected installation before execution.
	Capabilities bool `json:"capabilities,omitempty"`
	// Skills is resolved by the bound daemon; wire input cannot supply paths.
	Skills []agentcapabilities.InstalledSkill `json:"-"`
	// MCP is resolved from the same protected installation, never from wire input.
	MCP []EnvironmentMCP `json:"-"`
	// ToolEnvironment consumes Core-completed confidential initialization.
	ToolEnvironment bool `json:"tool_environment,omitempty"`
}

LocalEnvironment names a frozen workspace selection. Runtime must verify it against the bound local root before resolving capabilities or native execution.

type MCPHTTPServer

type MCPHTTPServer struct {
	ConnectionOrigin string    `json:"connection_origin"`
	ServerLabel      string    `json:"server_label"`
	ServerURL        string    `json:"server_url"`
	AllowedTools     *[]string `json:"allowed_tools"`
	Required         bool      `json:"required,omitempty"`
	BearerToken      *string   `json:"bearer_token,omitempty"`
	// Headers are non-secret; credentials travel only in BearerToken.
	Headers map[string]string `json:"headers,omitempty"`
	Stdio   *MCPStdio         `json:"stdio,omitempty"`
}

MCPHTTPServer declares public MCP tools with an explicit outbound connection origin. It is an HTTP server by ServerURL, or a process in the Environment when Stdio is set (origin "environment", ServerURL empty, no headers or bearer). Send only to a peer advertising mcp_http_tools; a transient BearerToken additionally requires mcp_http_bearer_auth. Required initialization requires mcp_http_required. Never persist or log this private request as configuration.

func (MCPHTTPServer) ValidateConnectionOrigin

func (server MCPHTTPServer) ValidateConnectionOrigin(req PromptRequestPayload) error

ValidateConnectionOrigin rejects relocation before dispatch and adapter setup.

type MCPStdio added in v0.0.12

type MCPStdio struct {
	Command string   `json:"command"`
	Args    []string `json:"args"`
	Cwd     string   `json:"cwd"`
	EnvVars []string `json:"env_vars"`
}

MCPStdio starts an MCP server as a process of the Runtime's Environment. EnvVars name variables the process inherits from that Environment; values never cross the wire.

func (MCPStdio) Valid added in v0.0.12

func (s MCPStdio) Valid() bool

Valid reports a startable declaration: a nonempty command, an absolute cwd, variable names in EnvVars and no NUL in the command or its arguments.

type MessageInput

type MessageInput []InputMessage

MessageInput preserves user-message boundaries and content order on every Runtime input path. Adapters map these messages to their native input format.

func TextInput

func TextInput(text string) MessageInput

TextInput constructs one message without normalizing its text.

func (MessageInput) HasImages

func (m MessageInput) HasImages() bool

func (MessageInput) TextOnly

func (m MessageInput) TextOnly() (string, error)

TextOnly is for text-only native transports. It rejects images rather than dropping them, and retains the existing blank-line boundary between messages.

func (MessageInput) Validate

func (m MessageInput) Validate() error

Validate requires every message to have an image or non-empty text. Text is never trimmed: whitespace-only text is user content, as officially admitted, while a message whose text parts are all empty still rejects.

type OutputFormat

type OutputFormat struct {
	Type   string          `json:"type"`
	Schema json.RawMessage `json:"schema"`
}

OutputFormat passes the public schema unchanged to a qualified native adapter.

type OutputMessagePayload

type OutputMessagePayload struct {
	ID     string  `json:"id"`
	Status string  `json:"status"`
	Phase  string  `json:"phase,omitempty"`
	Text   *string `json:"text,omitempty"`
}

OutputMessagePayload describes a native assistant message; Text is a completion snapshot.

type PreparationStatusPayload

type PreparationStatusPayload struct {
	// ExecutorID identifies the native resource owner, independently of this admission handle.
	ExecutorID string `json:"executor_id,omitempty"`
	// Reused is true when readiness reused an existing settled Executor.
	Reused    bool   `json:"reused,omitempty"`
	Handle    string `json:"handle,omitempty"`
	Revision  uint64 `json:"revision"`
	State     string `json:"state"`
	ExpiresAt int64  `json:"expires_at,omitempty"`
	RunID     string `json:"run_id,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
	// Operation is supplied for a rejected control operation (no resource revision).
	Operation string `json:"operation,omitempty"`
}

PreparationStatusPayload is a connection-local observation, not a public event. Keep the highest Revision for each Handle; concurrent sends may arrive out of order. ExpiresAt is Unix milliseconds. Repeated requests do not extend it. Retired request IDs may allocate a fresh handle, but an old handle can never start its replacement.

type PromptCancelPayload

type PromptCancelPayload struct {
	DeliveryID string `json:"delivery_id,omitempty"`
}

PromptCancelPayload optionally requests an application receipt; identity is on Envelope.ID.

type PromptRequestPayload

type PromptRequestPayload struct {
	MaxConcurrentSubagents *int `json:"max_concurrent_subagents,omitempty"`
	// AgentKind selects which agent implementation the daemon
	// dispatches to.
	AgentKind string `json:"agent_kind"`

	// RunID and Input are empty in an execution_prepare configuration.
	// Adapters set them from execution_start when they start a Turn.
	RunID string `json:"run_id"`

	// Input preserves ordered user messages and content.
	Input MessageInput `json:"input,omitempty"`

	// AgentOptions carries only the keys ValidateAgentOptions accepts. The
	// daemon's agent interprets them; the gateway never inspects them.
	AgentOptions map[string]any `json:"agent_options,omitempty"`

	// ExecutionControls are authoritative engine-neutral settings, translated by the adapter.
	ExecutionControls *ExecutionControls `json:"execution_controls,omitempty"`
	// MCPHTTPServers supplies public HTTP declarations with explicit connection origins.
	// Nil preserves existing behavior; an empty list explicitly declares no servers.
	MCPHTTPServers *[]MCPHTTPServer `json:"mcp_http_servers,omitempty"`

	LocalEnvironment *LocalEnvironment `json:"local_environment,omitempty"`

	// AgentSessionID is the upstream engine session id to resume.
	AgentSessionID string `json:"agent_session_id,omitempty"`

	// AgentStateKey is the stable daemon-side state directory key.
	// WorkspaceReadOnly prepares temporary native state that cannot start a Run.
	WorkspaceReadOnly            bool           `json:"workspace_read_only,omitempty"`
	AgentStateKey                string         `json:"agent_state_key,omitempty"`
	RequireExistingNativeSession bool           `json:"require_existing_native_session,omitempty"`
	ObserveSubagentIdentities    bool           `json:"observe_subagent_identities,omitempty"`
	FunctionTools                []FunctionTool `json:"function_tools,omitempty"`
	ToolSearch                   bool           `json:"tool_search,omitempty"`
	DisableExecutionEnvironment  bool           `json:"disable_execution_environment,omitempty"`
	DisableSubagents             bool           `json:"disable_subagents,omitempty"`
}

PromptRequestPayload is the execution configuration that execution_prepare carries. execution_start supplies the Run identity and input.

func (PromptRequestPayload) EnvironmentID

func (r PromptRequestPayload) EnvironmentID() string

func (PromptRequestPayload) ValidateAgentOptions added in v0.0.10

func (r PromptRequestPayload) ValidateAgentOptions() error

ValidateAgentOptions rejects any agent_options key other than model, system_prompt, model_provider and harness_config.

func (PromptRequestPayload) ValidateToolSearch

func (r PromptRequestPayload) ValidateToolSearch(supported bool) error

ValidateToolSearch checks only the requested function discovery operation. Native search configuration and discovery stay inside the adapter.

type PromptSteerAckPayload

type PromptSteerAckPayload struct {
	InputID  string `json:"input_id"`
	Accepted bool   `json:"accepted"`
	// Written is an intermediate transport phase, never native acceptance.
	Written   bool   `json:"written,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
	Error     string `json:"error,omitempty"`
}

PromptSteerAckPayload distinguishes a completed write from native acceptance.

type PromptSteerPayload

type PromptSteerPayload struct {
	InputID string       `json:"input_id"`
	Input   MessageInput `json:"input"`
}

PromptSteerPayload identifies one input batch within an active run.

type RuntimeInitialFile

type RuntimeInitialFile struct {
	Path string `json:"path"`
}

RuntimeInitialFile addresses a file within the logical workspace.

type RuntimeInitialization

type RuntimeInitialization struct {
	Action   string            `json:"action"`
	Env      map[string]string `json:"env,omitempty"`
	Packages []string          `json:"packages,omitempty"`
	Command  string            `json:"command,omitempty"`
	CWD      string            `json:"cwd,omitempty"`
}

type RuntimePreparePayload

type RuntimePreparePayload struct {
	BudgetMS       int64                    `json:"budget_ms,omitempty"`
	Step           string                   `json:"step"`
	EnvironmentID  string                   `json:"environment_id,omitempty"`
	SessionID      string                   `json:"session_id,omitempty"`
	Action         string                   `json:"action,omitempty"`
	Slot           int                      `json:"slot,omitempty"`
	Skill          *agentskill.Metadata     `json:"skill,omitempty"`
	Plugin         *agentplugin.Metadata    `json:"plugin,omitempty"`
	File           *RuntimeInitialFile      `json:"file,omitempty"`
	Initialization *RuntimeInitialization   `json:"initialization,omitempty"`
	Sources        *agentcapabilities.Input `json:"sources,omitempty"`
	SizeBytes      int                      `json:"size_bytes,omitempty"`
	SHA256         string                   `json:"sha256,omitempty"`
	Offset         int                      `json:"offset,omitempty"`
	Data           []byte                   `json:"data,omitempty"`
}

RuntimePreparePayload carries typed initialization or capability preparation. Runtime resolves logical paths and owns installation destinations. Envelope.ID identifies one connection-local transfer.

type RuntimePrepareResultPayload

type RuntimePrepareResultPayload struct {
	ExitCode  int    `json:"exit_code,omitempty"`
	Outcome   string `json:"outcome"`
	Offset    int    `json:"offset,omitempty"`
	SizeBytes int    `json:"size_bytes,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
}

type SearchLocation added in v0.0.12

type SearchLocation struct {
	City     *string `json:"city,omitempty"`
	Country  *string `json:"country,omitempty"`
	Region   *string `json:"region,omitempty"`
	Timezone *string `json:"timezone,omitempty"`
}

SearchLocation carries only the keys the Session set.

type SubagentCoordinationPayload

type SubagentCoordinationPayload struct {
	ID              string   `json:"id"`
	Kind            string   `json:"kind"`
	Status          string   `json:"status"`
	ActorID         string   `json:"actor_id"`
	Recipients      []string `json:"recipients"`
	Text            *string  `json:"text"`
	Model           *string  `json:"model"`
	ReasoningEffort *string  `json:"reasoning_effort"`
}

SubagentCoordinationPayload reports the native coordination operation in the common vocabulary. Actor/recipients are native identities, resolved by Core. An empty ActorID denotes the authenticated root, never an arbitrary Agent. A child-owned operation is carried as a SubagentItem with this payload.

type SubagentIdentityPayload

type SubagentIdentityPayload struct {
	NativeID        string  `json:"native_id"`
	ParentNativeID  string  `json:"parent_native_id"`
	NativeCreatedAt int64   `json:"native_created_at"`
	ParentTurnID    string  `json:"parent_turn_id"`
	SourceItemID    string  `json:"source_item_id"`
	Name            *string `json:"name"`
	Instructions    *string `json:"instructions"`
}

SubagentIdentityPayload is scoped by the authenticated Run envelope. The service supplies its Session, project, device and public identity; none comes from here.

type SubagentItemPayload

type SubagentItemPayload struct {
	NativeID string          `json:"native_id"`
	TurnID   string          `json:"turn_id"`
	ItemID   string          `json:"item_id"`
	Position int32           `json:"position"`
	Kind     string          `json:"kind"`
	Payload  json.RawMessage `json:"payload"`
}

SubagentItemPayload reuses ordinary message/tool observations. Payload is a complete snapshot, not a delta. Position is the native order within its Turn. Engine-specific payloads are not admitted by this contract.

type SubagentLifecyclePayload

type SubagentLifecyclePayload struct {
	NativeID     string `json:"native_id"`
	EffectID     string `json:"effect_id"`
	Status       string `json:"status"`
	OccurredAtMS int64  `json:"occurred_at_ms"`
}

SubagentLifecyclePayload reports a successful native effect, never a task's completion or a process disconnect. EffectID is stable across history reads. Active is emitted only for an actual reopen; an already-active resume is a no-op.

type SubagentTurnPayload

type SubagentTurnPayload struct {
	NativeID      string        `json:"native_id"`
	TurnID        string        `json:"turn_id"`
	Status        string        `json:"status"`
	CreatedAtMS   int64         `json:"created_at_ms"`
	StartedAtMS   *int64        `json:"started_at_ms"`
	CompletedAtMS *int64        `json:"completed_at_ms"`
	Usage         *UsagePayload `json:"usage"`
}

SubagentTurnPayload describes child-owned work. Timestamps are native facts or an immutable receipt of confirmed cancellation when native history omits it. Converting seconds to milliseconds does not establish finer precision. Emit identity first, then an active Turn, its Items, and its terminal snapshot. Unknown token measurements stay nil. Core owns all public resource IDs.

type SupportedAgentKind

type SupportedAgentKind struct {
	Kind         string                `json:"kind"`
	Available    bool                  `json:"available"`
	Version      string                `json:"version,omitempty"`
	Capabilities AgentKindCapabilities `json:"capabilities"`
}

SupportedAgentKind is one daemon-advertised agent engine. Daemons can report unavailable kinds with Available=false when the adapter exists but the underlying CLI binary is missing.

func (*SupportedAgentKind) UnmarshalJSON

func (k *SupportedAgentKind) UnmarshalJSON(data []byte) error

func (SupportedAgentKind) ValidateDeclaration

func (k SupportedAgentKind) ValidateDeclaration() error

type ThinkingPayload

type ThinkingPayload struct {
	Text     string `json:"text"`
	Sequence uint64 `json:"sequence,omitempty"`
}

ThinkingPayload carries an internal-thinking fragment.

type TokenUsage

type TokenUsage struct {
	InputTokens           int64 `json:"input_tokens"`
	CachedInputTokens     int64 `json:"cached_input_tokens"`
	OutputTokens          int64 `json:"output_tokens"`
	ReasoningOutputTokens int64 `json:"reasoning_output_tokens"`
	TotalTokens           int64 `json:"total_tokens"`
}

TokenUsage is a complete cumulative measurement for the current execution. Adapters publish observed snapshots promptly; historical resume totals belong to the adapter baseline, not this execution. Unknown fields must not become zero.

func (*TokenUsage) UnmarshalJSON

func (u *TokenUsage) UnmarshalJSON(raw []byte) error

type ToolCallPayload

type ToolCallPayload struct {
	Observation *ToolObservation `json:"observation,omitempty"`
	ID          string           `json:"id"`
	Name        string           `json:"name"`
	Stage       string           `json:"stage"`
	Args        map[string]any   `json:"args,omitempty"`
	Result      map[string]any   `json:"result,omitempty"`
}

ToolCallPayload carries a tool invocation event. Stage is "before" when the agent is about to call the tool, "after" when the result is back.

func (*ToolCallPayload) UnmarshalJSON

func (p *ToolCallPayload) UnmarshalJSON(raw []byte) error

type ToolObservation

type ToolObservation struct {
	Kind       string               `json:"kind"`
	Status     string               `json:"status"`
	Name       string               `json:"name,omitempty"`
	Command    string               `json:"command,omitempty"`
	Cwd        *string              `json:"cwd,omitempty"`
	ExitCode   *int64               `json:"exit_code,omitempty"`
	DurationMS *int64               `json:"duration_ms,omitempty"`
	Server     string               `json:"server,omitempty"`
	Arguments  json.RawMessage      `json:"arguments,omitempty"`
	Output     json.RawMessage      `json:"output,omitempty"`
	Error      json.RawMessage      `json:"error,omitempty"`
	Content    *[]InputContent      `json:"content,omitempty"`
	Action     *ToolWebSearchAction `json:"action,omitempty"`
}

ToolObservation is an engine-neutral execution snapshot, not a public API Item.

type ToolWebSearchAction

type ToolWebSearchAction struct {
	Type    string   `json:"type"`
	Query   *string  `json:"query,omitempty"`
	Queries []string `json:"queries,omitempty"`
	URL     *string  `json:"url,omitempty"`
	Pattern *string  `json:"pattern,omitempty"`
}

type Usage

type Usage struct {
	Tokens       *TokenUsage    `json:"tokens,omitempty"`
	Provider     string         `json:"provider,omitempty"`
	Model        string         `json:"model,omitempty"`
	InputTokens  int32          `json:"input_tokens,omitempty"`
	OutputTokens int32          `json:"output_tokens,omitempty"`
	CostUSD      float64        `json:"cost_usd,omitempty"`
	Raw          map[string]any `json:"raw,omitempty"`
}

Usage retains native evidence independently of the optional public breakdown. Tokens is absent when a complete, correctly scoped measurement is unavailable. Core does not reconstruct token counts, prices or provider identity from Raw.

type UsagePayload

type UsagePayload struct {
	Usage
}

UsagePayload carries a Usage update mid-stream.

type WebSearchControl added in v0.0.12

type WebSearchControl struct {
	Mode           string          `json:"mode"`
	ContextSize    string          `json:"context_size"`
	AllowedDomains []string        `json:"allowed_domains"`
	Location       *SearchLocation `json:"location,omitempty"`
}

WebSearchControl is the resolved official web_search tool. A nil AllowedDomains is the official null; an empty list is kept distinct.

type WorkspaceDirectoryEntry

type WorkspaceDirectoryEntry struct {
	Name      string `json:"name"`
	Kind      string `json:"kind"`
	SizeBytes *int64 `json:"size_bytes"`
}

type WorkspaceDirectoryResult

type WorkspaceDirectoryResult struct {
	Entries   []WorkspaceDirectoryEntry `json:"entries"`
	Truncated bool                      `json:"truncated"`
}

func (*WorkspaceDirectoryResult) UnmarshalJSON

func (result *WorkspaceDirectoryResult) UnmarshalJSON(data []byte) error

type WorkspaceExportPayload

type WorkspaceExportPayload struct {
	Step          string `json:"step"`
	Handle        string `json:"handle,omitempty"`
	EnvironmentID string `json:"environment_id,omitempty"`
	Offset        int64  `json:"offset,omitempty"`
}

type WorkspaceExportResultPayload

type WorkspaceExportResultPayload struct {
	Outcome   string `json:"outcome"`
	Offset    int64  `json:"offset"`
	Data      []byte `json:"data,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
}

type WorkspaceReadPayload

type WorkspaceReadPayload struct {
	Handle        string `json:"handle,omitempty"`
	RunID         string `json:"run_id,omitempty"`
	EnvironmentID string `json:"environment_id"`
	Path          string `json:"path"`
	MaxBytes      int    `json:"max_bytes"`
	Operation     string `json:"operation,omitempty"`
	MaxEntries    int    `json:"max_entries,omitempty"`
}

WorkspaceReadPayload targets one existing resource on the current daemon connection.

type WorkspaceReadResultPayload

type WorkspaceReadResultPayload struct {
	Outcome           string                    `json:"outcome"`
	Data              []byte                    `json:"data,omitempty"`
	Truncated         bool                      `json:"truncated,omitempty"`
	CloseAcknowledged bool                      `json:"close_acknowledged,omitempty"`
	ErrorCode         string                    `json:"error_code,omitempty"`
	Directory         *WorkspaceDirectoryResult `json:"directory,omitempty"`
}

WorkspaceReadResultPayload never infers file settlement from local process exit.

type WorkspaceWritePayload

type WorkspaceWritePayload struct {
	Step          string `json:"step"`
	EnvironmentID string `json:"environment_id,omitempty"`
	SessionID     string `json:"session_id,omitempty"`
	Path          string `json:"path,omitempty"`
	SizeBytes     int    `json:"size_bytes,omitempty"`
	SHA256        string `json:"sha256,omitempty"`
	Offset        int    `json:"offset,omitempty"`
	Data          []byte `json:"data,omitempty"`
}

WorkspaceWritePayload transfers one complete body over the existing daemon connection. Envelope.ID is the durable Core mutation ID, never a retry key.

type WorkspaceWriteResultPayload

type WorkspaceWriteResultPayload struct {
	Outcome   string `json:"outcome"`
	Offset    int    `json:"offset,omitempty"`
	SizeBytes int    `json:"size_bytes,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
	// Reason optionally refines a write_rejected result.
	Reason string `json:"reason,omitempty"`
}

Directories

Path Synopsis
Package prototest provides explicit capability fixtures and the shared wire scenarios for Core–Runtime contract tests.
Package prototest provides explicit capability fixtures and the shared wire scenarios for Core–Runtime contract tests.

Jump to

Keyboard shortcuts

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