Help us shape the future of Go! Take the 2026 Go Developer Survey

wire

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package wire converts between the hand-written api domain types (the SPI programmed against internally) and the generated protobuf wire types in api/genpb. Keeping the two representations pinned by an explicit, compile-checked conversion layer is what keeps them from drifting: if a field is added to one side and not the other, the conversion (and its round-trip test) fails to compile or fails the test. The api.Event is the load-bearing type — it crosses both the Harness.Connect stream and Sessions.Exec/Replay, and it is what the event log hash-chains — so its durable fields must survive a round-trip. ToolResult.Approval is a transient direct-sink decision carrier, intentionally not serialized; EVENT_PARKED is convertible for transport but MUST NOT be journaled.

Content constraint: structured content maps (ToolCall.Args, ToolResult.Output, DataPart) MUST hold JSON-shaped values. They cross the wire as a protobuf Struct, whose numbers are float64 — so a Go int round-trips hash-equal but not reflect-equal, and an int64 above 2^53 is silently lossy. Producers must normalize to JSON-native types at ingest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeStateFromProto

func ComputeStateFromProto(c v1.ComputeState) api.ComputeState

ComputeStateFromProto converts a wire ComputeState enum to its domain form.

func ComputeStateToProto

func ComputeStateToProto(c api.ComputeState) v1.ComputeState

ComputeStateToProto converts a domain ComputeState to its wire enum.

func DeletionStateFromProto

func DeletionStateFromProto(d v1.DeletionState) api.DeletionState

DeletionStateFromProto converts a wire DeletionState enum to its domain form.

func DeletionStateToProto

func DeletionStateToProto(d api.DeletionState) v1.DeletionState

DeletionStateToProto converts a domain DeletionState to its wire enum.

func DeltaToProto

func DeltaToProto(d api.Delta) *v1.Delta

DeltaToProto converts an ephemeral streaming chunk. Deltas are transport only, so unlike Event this has no canonical form and never reaches the hash chain.

func EventFromProto

func EventFromProto(p *v1.Event) api.Event

EventFromProto converts a wire Event back to the domain type.

func EventToProto

func EventToProto(e api.Event) *v1.Event

EventToProto converts a domain Event to its wire form. Ordering/integrity fields are not on Event (they live on LogRecord), so this is a pure body+envelope conversion.

func ExecStateFromProto

func ExecStateFromProto(e v1.ExecState) api.ExecState

ExecStateFromProto converts a wire ExecState enum to its domain form.

func ExecStateToProto

func ExecStateToProto(e api.ExecState) v1.ExecState

ExecStateToProto converts a domain ExecState to its wire enum.

func MessageFromProto

func MessageFromProto(p *v1.Message) *api.Message

MessageFromProto converts a wire Message to the domain type (exported for the Sessions service).

func MessageToProto

func MessageToProto(m *api.Message) *v1.Message

MessageToProto converts a domain Message to its wire form (exported for the Sessions service).

func ToolCallFromProto

func ToolCallFromProto(t *v1.ToolCall) *api.ToolCall

func ToolCallToProto

func ToolCallToProto(t *api.ToolCall) *v1.ToolCall

ToolCallToProto / ToolCallFromProto / ToolResultToProto / ToolResultFromProto are exported for the harness wire bridge, which mediates a CONTROLLER_MEDIATED tool call out of process exactly as it mediates a model call.

func ToolChoiceFromProto

func ToolChoiceFromProto(p *v1.ToolChoice) (*api.ToolChoice, error)

ToolChoiceFromProto is the inverse of ToolChoiceToProto. Proto3 enums are open, so a mode this build does not know (a newer peer's value) is an error rather than the provider default.

func ToolChoiceToProto

func ToolChoiceToProto(c *api.ToolChoice) (*v1.ToolChoice, error)

ToolChoiceToProto converts a tool choice. An unknown mode is an error rather than the provider default: a choice that silently loosened would let the model do what the harness ruled out.

func ToolDefinitionsFromProto

func ToolDefinitionsFromProto(ps []*v1.ToolDefinition) []api.ToolDefinition

ToolDefinitionsFromProto is the inverse of ToolDefinitionsToProto.

func ToolDefinitionsToProto

func ToolDefinitionsToProto(ts []api.ToolDefinition) []*v1.ToolDefinition

ToolDefinitionsToProto converts the tools offered on a model call. They ride ModelCall on the harness stream only; the recorded MODEL_CALL keeps the input hash that covers them.

func ToolResultFromProto

func ToolResultFromProto(t *v1.ToolResult) *api.ToolResult

func ToolResultToProto

func ToolResultToProto(t *api.ToolResult) *v1.ToolResult

func ToolSpecFromProto

func ToolSpecFromProto(p *v1.ToolSpec) api.ToolSpec

ToolSpecFromProto converts a wire tool declaration to the domain type. A nil p yields the zero value.

func ToolSpecToProto

func ToolSpecToProto(t api.ToolSpec) *v1.ToolSpec

ToolSpecToProto converts a declared tool to its wire form (exported for the harness wire bridge, which carries a harness's declared tools in its descriptor).

Types

This section is empty.

Jump to

Keyboard shortcuts

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