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_request / prompt_cancel: ID = RunID.
- delta / tool_call / usage / error / done: ID = originating RunID.
- permission_request: ID = RunID; payload.request_id is the interaction ID.
- permission_decision / permission_cancel: ID = interaction ID.
- 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
- func NormalizeEngineFailure(code string, status *int) (string, *int)
- func ValidRuntimePrepareRequest(p RuntimePreparePayload) bool
- func ValidRuntimePrepareResult(r RuntimePrepareResultPayload, expected string, offset, size int) bool
- func ValidWorkspaceDirectory(result *WorkspaceDirectoryResult, limit int) bool
- func ValidWorkspaceExportRequest(p WorkspaceExportPayload) bool
- func ValidWorkspaceReadPreparation(r PromptRequestPayload) bool
- func ValidWorkspaceReadRequest(request WorkspaceReadPayload) bool
- func ValidWorkspaceWriteRequest(p WorkspaceWritePayload) bool
- func ValidateBinary64Schema(raw json.RawMessage) error
- func VersionCompatible(clientVersion string) bool
- type AgentKindCapabilities
- type AuthoringRequestPayload
- type AuthoringResponsePayload
- type CapabilitySupport
- type CommandOutputPayload
- type DeltaPayload
- type DeviceShutdownPayload
- type DonePayload
- type Envelope
- type EnvironmentMCP
- type EnvironmentSuspendPayload
- type EnvironmentSuspendResultPayload
- type ErrorPayload
- type ExecutionControls
- type ExecutionPreparePayload
- type ExecutionReleasePayload
- type ExecutionStartPayload
- type FunctionCallPayload
- type FunctionResultPayload
- type FunctionTool
- type HarnessConfig
- type HeartbeatPayload
- type InputContent
- type InputMessage
- type InteractionDecisionAckPayload
- type LocalEnvironment
- type MCPHTTPServer
- type MessageInput
- type OutputFormat
- type OutputMessagePayload
- type PermissionDecisionPayload
- type PermissionRequestPayload
- type PreparationStatusPayload
- type PromptCancelPayload
- type PromptForUserChoiceDecisionPayload
- type PromptForUserChoiceOption
- type PromptForUserChoicePayload
- type PromptForUserChoiceQuestion
- type PromptForUserChoiceQuestionAnswer
- type PromptRequestPayload
- type PromptSteerAckPayload
- type PromptSteerPayload
- type RuntimeInitialFile
- type RuntimeInitialization
- type RuntimePreparePayload
- type RuntimePrepareResultPayload
- type SubagentCoordinationPayload
- type SubagentIdentityPayload
- type SubagentItemPayload
- type SubagentLifecyclePayload
- type SubagentTurnPayload
- type SupportedAgentKind
- type ThinkingPayload
- type TokenUsage
- type ToolCallPayload
- type ToolObservation
- type ToolWebSearchAction
- type Usage
- type UsagePayload
- type WorkspaceDirectoryEntry
- type WorkspaceDirectoryResult
- type WorkspaceExportPayload
- type WorkspaceExportResultPayload
- type WorkspaceReadPayload
- type WorkspaceReadResultPayload
- type WorkspaceWritePayload
- type WorkspaceWriteResultPayload
Constants ¶
const ( TypeAuthoringRequest = "authoring_request" TypeAuthoringResponse = "authoring_response" AuthoringContext = "context" AuthoringSkillList = "skill.list" AuthoringSkillRead = "skill.read" AuthoringSkillCreate = "skill.create" AuthoringSkillUpdate = "skill.update" AuthoringPromptRead = "instructions.read" AuthoringPromptWrite = "instructions.write" AuthoringMaxBytes = 1 << 20 AuthoringSocketEnv = "OAC_RUNTIME_DAEMON_SOCKET" )
const ( TypeFunctionCall = "function_call" TypeFunctionResult = "function_result" )
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" // TypePermissionRequest carries an agent's request for human // approval. Envelope.ID is the RunID; payload.request_id identifies the decision. TypePermissionRequest = "permission_request" // TypePermissionCancel signals the agent withdrew an earlier // permission request (e.g. its internal timeout fired). Used by // the gateway to unblock pending SubmitPermission calls. TypePermissionCancel = "permission_cancel" // TypePromptForUserChoice asks the human to pick one (or more) // answers from a closed list before the agent can continue. Used // to intercept Claude Code's built-in AskUserQuestion tool so the // daemon doesn't deadlock waiting for a tool_result no one will // send. Envelope.ID is the RunID; payload.ask_id identifies the decision. TypePromptForUserChoice = "prompt_for_user_choice" // TypeInteractionDecisionAck confirms that the daemon-side agent // accepted (or definitively rejected) a permission/user-input decision or cancellation. // The server must not mark the durable interaction 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.
const ( DoneMetaAgentSessionID = "agent_session_id" DoneMetaAgentSessionType = "agent_session_type" )
const ( // TypePromptRequest triggers one prompt cycle. Envelope.ID = RunID; // the daemon stamps every resulting upstream frame with the same // ID so the gateway can fan them back to the matching StreamPrompt // subscriber. TypePromptRequest = "prompt_request" // 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" // TypePermissionDecision delivers a human verdict back to the // daemon. Envelope.ID = the perm_<8hex> id the daemon minted in // the matching permission_request. TypePermissionDecision = "permission_decision" // TypePromptForUserChoiceDecision delivers the human's answer back // to the daemon. Envelope.ID = the ask_<8hex> id the daemon minted // in the matching prompt_for_user_choice frame. TypePromptForUserChoiceDecision = "prompt_for_user_choice_decision" // TypeDeviceShutdown asks the daemon to exit gracefully (SIGTERM // child processes, flush state, close the socket). Ignored by // long-lived local devices unless the operator explicitly // requested it. TypeDeviceShutdown = "device_shutdown" )
Type constants for server → daemon frames.
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.
const ( TypeRuntimePrepare = "runtime_prepare" TypeRuntimePrepareResult = "runtime_prepare_result" RuntimePrepareMaxBytes = 50 << 20 RuntimePrepareChunkBytes = WorkspaceWriteChunkBytes RuntimePrepareMaxFrameBytes = 1 << 20 )
const ( TypeSubagentLifecycle = "subagent_lifecycle" TypeSubagentTurn = "subagent_turn" TypeSubagentItem = "subagent_item" )
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.
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 )
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" )
const ( TypeWorkspaceWrite = "workspace_write" TypeWorkspaceWriteResult = "workspace_write_result" WorkspaceWriteMaxBytes = 50 << 20 WorkspaceWriteChunkBytes = 64 << 10 WorkspaceWriteMaxFrameBytes = 96 << 10 )
const ( WorkspaceWriteReasonDirectory = "destination_directory" WorkspaceWriteReasonUnsafe = "unsafe_destination" )
Files.create destination refusals carried in Reason.
const TypeCommandOutput = "command_output"
TypeCommandOutput carries opt-in incremental output for an observed command.
const TypePromptSteer = "prompt_steer"
TypePromptSteer appends messages to an active run; Envelope.ID is the run ID.
const TypePromptSteerAck = "prompt_steer_ack"
TypePromptSteerAck reports input receipt phases on the originating run ID.
const TypeSubagentCoordination = "subagent_coordination"
const TypeSubagentIdentity = "subagent_identity"
TypeSubagentIdentity carries verified native identity facts; lifecycle uses a separate effect.
const Version = "0.11.0"
Version identifies the complete Core–Runtime wire contract. Change it when removing or changing a payload or its semantics; deploy both endpoints together.
const WorkspaceDirectoryMaxEntries = 1024
Variables ¶
This section is empty.
Functions ¶
func NormalizeEngineFailure ¶
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 ¶
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"`
Permissions CapabilitySupport `json:"permissions"`
Usage CapabilitySupport `json:"usage"`
Resume CapabilitySupport `json:"resume"`
NativeSessionRecovery CapabilitySupport `json:"native_session_recovery"`
WorkspaceAuthoring CapabilitySupport `json:"workspace_authoring"`
Steering CapabilitySupport `json:"steering"`
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"`
ProgrammaticToolCallingDisable CapabilitySupport `json:"programmatic_tool_calling_disable"`
WebSearchControl CapabilitySupport `json:"web_search_control"`
// ExecutionControls supports typed search and verbosity controls.
ExecutionControls CapabilitySupport `json:"execution_controls"`
TextVerbosity CapabilitySupport `json:"text_verbosity"`
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 (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 AuthoringRequestPayload ¶
type AuthoringRequestPayload struct {
RequestID string `json:"request_id,omitempty"`
Operation string `json:"operation"`
CapabilityID string `json:"capability_id,omitempty"`
Content string `json:"content,omitempty"`
}
AuthoringRequestPayload uses Envelope.ID for the active run, never a client-supplied workspace or user.
type AuthoringResponsePayload ¶
type AuthoringResponsePayload struct {
RequestID string `json:"request_id,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
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 ¶
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 DeviceShutdownPayload ¶
type DeviceShutdownPayload struct {
Reason string `json:"reason,omitempty"`
}
DeviceShutdownPayload tells the daemon why we're closing it (for log lines / metrics on the daemon side). Optional.
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 ¶
NewEnvelope marshals payload into an Envelope. A nil payload yields an Envelope with no Payload field (for bodyless types like prompt_cancel).
func NewEnvelopeWithTrace ¶
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 ¶
DecodePayload unpacks Envelope.Payload into out. An empty Payload is a non-error so bodyless types (prompt_cancel, permission_cancel) decode 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 ¶
func (p EnvironmentSuspendPayload) SameSuspension(other EnvironmentSuspendPayload) bool
SameSuspension compares ownership, independently of the requested recovery mode.
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 {
DisableProgrammaticToolCalling bool `json:"disable_programmatic_tool_calling,omitempty"`
WebSearch string `json:"web_search"`
TextVerbosity string `json:"text_verbosity"`
OutputFormat *OutputFormat `json:"output_format,omitempty"`
}
ExecutionControls requires both values when supplied; omitting the block preserves agent options. Send only to a peer advertising execution_controls, independently of older option capabilities.
type ExecutionPreparePayload ¶
type ExecutionPreparePayload struct {
SessionID string `json:"session_id"`
Configuration PromptRequestPayload `json:"configuration"`
}
ExecutionPreparePayload reuses execution configuration without accepting input or product authoring. 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"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments"`
}
FunctionCallPayload belongs to the Run identified by Envelope.ID.
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 ¶
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"`
// NetworkAccess must match the immutable Runtime policy for execution.
NetworkAccess string `json:"network_access,omitempty"`
AllowedDomains []string `json:"allowed_domains,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"`
}
MCPHTTPServer declares HTTP tools with an explicit outbound connection origin. 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 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.
func (MessageInput) ValidateInlineImages ¶
func (m MessageInput) ValidateInlineImages() error
ValidateInlineImages checks inline PNG/JPEG content without downloading or rewriting it. Callers separately qualify message/function-result support.
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 PermissionDecisionPayload ¶
type PermissionDecisionPayload struct {
DeliveryID string `json:"delivery_id"`
Approved bool `json:"approved"`
Message string `json:"message,omitempty"`
UpdatedInput map[string]any `json:"updated_input,omitempty"`
}
PermissionDecisionPayload carries the human verdict. UpdatedInput lets the approver edit the tool input before letting the call proceed (Claude Code's allow-with-changes path).
type PermissionRequestPayload ¶
type PermissionRequestPayload struct {
RequestID string `json:"request_id"`
Tool string `json:"tool"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
PermissionRequestPayload carries an agent's request for human approval. RequestID is the daemon-minted handle used to route a later decision. It lives in the payload because Envelope.ID is the run ID used by the server gateway to deliver the request to the active run subscriber.
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 PromptForUserChoiceDecisionPayload ¶
type PromptForUserChoiceDecisionPayload struct {
DeliveryID string `json:"delivery_id"`
QuestionAnswers []PromptForUserChoiceQuestionAnswer `json:"question_answers,omitempty"`
Cancelled bool `json:"cancelled,omitempty"`
Reason string `json:"reason,omitempty"`
}
PromptForUserChoiceDecisionPayload carries either explicitly identified answers or cancellation. Omitted questions remain unanswered; adapters never reassign answers by position or display text. Native choice validation stays in the adapter.
func (PromptForUserChoiceDecisionPayload) AnswersFor ¶
func (p PromptForUserChoiceDecisionPayload) AnswersFor(questionIDs []string) (map[string][]string, error)
AnswersFor binds a decision to the exact emitted question identities. It never derives identity from a header, answer text or array position. Call it before consuming the pending interaction or submitting a native response.
func (*PromptForUserChoiceDecisionPayload) UnmarshalJSON ¶
func (p *PromptForUserChoiceDecisionPayload) UnmarshalJSON(raw []byte) error
UnmarshalJSON rejects fields outside the current decision contract, including unrecognized fields nested inside question_answers. Do not silently discard an answer from a peer using a different wire shape.
func (PromptForUserChoiceDecisionPayload) Validate ¶
func (p PromptForUserChoiceDecisionPayload) Validate() error
Validate checks answer identity independently of delivery correlation and native question constraints. An empty answer array is an explicit non-answer.
type PromptForUserChoiceOption ¶
type PromptForUserChoiceOption struct {
Label string `json:"label"`
Description string `json:"description,omitempty"`
}
PromptForUserChoiceOption is one button / checkbox the user can pick when answering a PromptForUserChoice. Label is the human- readable choice; Description is optional inline help.
type PromptForUserChoicePayload ¶
type PromptForUserChoicePayload struct {
AskID string `json:"ask_id"`
Questions []PromptForUserChoiceQuestion `json:"questions"`
ToolUseID string `json:"tool_use_id,omitempty"`
AutoResolutionMs *uint64 `json:"auto_resolution_ms,omitempty"`
}
PromptForUserChoicePayload carries the AskUserQuestion interception.
AskID is the daemon-minted "ask_<8hex>" handle the server uses to route SubmitPromptForUserChoice back to the right session. It rides on the payload (not Envelope.ID) because Envelope.ID is reserved for the run id — that's the field server-side session.dispatch fans on to deliver the frame to the run's subscriber channel. ToolUseID is the originating Claude Code tool_use id; empty when the call came through the control_request channel (CCRequestID then identifies the daemon-side waiter instead but it doesn't ride on the wire).
type PromptForUserChoiceQuestion ¶
type PromptForUserChoiceQuestion struct {
ID string `json:"id"`
Header string `json:"header,omitempty"`
Question string `json:"question"`
MultiSelect bool `json:"multi_select,omitempty"`
IsOther bool `json:"is_other,omitempty"`
IsSecret bool `json:"is_secret,omitempty"`
Options []PromptForUserChoiceOption `json:"options"`
}
PromptForUserChoiceQuestion is one question in a (possibly multi- question) AskUserQuestion call. Mirrors the Claude Code built-in schema verbatim so the daemon doesn't translate the shape twice.
type PromptForUserChoiceQuestionAnswer ¶
type PromptForUserChoiceQuestionAnswer struct {
QuestionID string `json:"question_id"`
Answers []string `json:"answers"`
}
PromptForUserChoiceQuestionAnswer binds answer values to one emitted question ID. Headers and array positions never identify a question.
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"`
// ConversationID lets the daemon scope per-conversation state
// (Claude --resume session id, scratch dir).
ConversationID string `json:"conversation_id"`
// RunID is the ID of the Core Turn this prompt executes; mirrored
// back on every upstream frame via Envelope.ID.
RunID string `json:"run_id"`
// Input preserves ordered user messages and content.
Input MessageInput `json:"input,omitempty"`
// AgentOptions carries agent-specific overrides (model, mode,
// allowed_tools, system_prompt, mcp_servers, plugin_dirs, env,
// ...). The daemon's agent interprets these; 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"`
WorkspaceAuthoring bool `json:"workspace_authoring,omitempty"`
// ReleaseOnCompletion closes the native writer before acknowledging Done.
ReleaseOnCompletion bool `json:"release_on_completion,omitempty"`
StrictResume bool `json:"strict_resume,omitempty"`
RequireExistingNativeSession bool `json:"require_existing_native_session,omitempty"`
ObserveMessages bool `json:"observe_messages,omitempty"`
ObserveToolObservations bool `json:"observe_tool_observations,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 daemon-side view of a connector.PromptInput, trimmed to fields a daemon agent actually needs. Kept separate from PromptInput so future agent implementations can evolve the wire shape without touching the connector surface.
func (PromptRequestPayload) EnvironmentID ¶
func (r PromptRequestPayload) EnvironmentID() string
func (PromptRequestPayload) ValidateProgrammaticToolCallingDisable ¶
func (r PromptRequestPayload) ValidateProgrammaticToolCallingDisable(supported bool) error
ValidateProgrammaticToolCallingDisable applies only to explicit tool disabling. Omission preserves the adapter's ordinary native behavior.
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"`
DurableReceipt bool `json:"durable_receipt,omitempty"`
}
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 RuntimePreparePayload ¶
type RuntimePreparePayload struct {
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 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 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 WorkspaceDirectoryEntry ¶
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 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. Older peers omit or
// ignore it and keep the generic rejection.
Reason string `json:"reason,omitempty"`
}
Source Files
¶
- authoring.go
- capabilities.go
- command_output.go
- engine_failure.go
- envelope.go
- environment.go
- execution_controls.go
- functions.go
- harness_config.go
- inbound.go
- mcp.go
- message_images.go
- message_input.go
- outbound.go
- output_format.go
- preparation.go
- runtime_prepare.go
- steering.go
- subagents.go
- suspend.go
- token_usage.go
- tool_call.go
- tool_observations.go
- user_choice.go
- version.go
- workspace_directory.go
- workspace_export.go
- workspace_read.go
- workspace_read_preparation.go
- workspace_write.go