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 ¶
- func ComputeStateFromProto(c v1.ComputeState) api.ComputeState
- func ComputeStateToProto(c api.ComputeState) v1.ComputeState
- func DeletionStateFromProto(d v1.DeletionState) api.DeletionState
- func DeletionStateToProto(d api.DeletionState) v1.DeletionState
- func DeltaToProto(d api.Delta) *v1.Delta
- func EventFromProto(p *v1.Event) api.Event
- func EventToProto(e api.Event) *v1.Event
- func ExecStateFromProto(e v1.ExecState) api.ExecState
- func ExecStateToProto(e api.ExecState) v1.ExecState
- func MessageFromProto(p *v1.Message) *api.Message
- func MessageToProto(m *api.Message) *v1.Message
- func ToolCallFromProto(t *v1.ToolCall) *api.ToolCall
- func ToolCallToProto(t *api.ToolCall) *v1.ToolCall
- func ToolChoiceFromProto(p *v1.ToolChoice) (*api.ToolChoice, error)
- func ToolChoiceToProto(c *api.ToolChoice) (*v1.ToolChoice, error)
- func ToolDefinitionsFromProto(ps []*v1.ToolDefinition) []api.ToolDefinition
- func ToolDefinitionsToProto(ts []api.ToolDefinition) []*v1.ToolDefinition
- func ToolResultFromProto(t *v1.ToolResult) *api.ToolResult
- func ToolResultToProto(t *api.ToolResult) *v1.ToolResult
- func ToolSpecFromProto(p *v1.ToolSpec) api.ToolSpec
- func ToolSpecToProto(t api.ToolSpec) *v1.ToolSpec
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 ¶
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 ¶
EventFromProto converts a wire Event back to the domain type.
func EventToProto ¶
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 ¶
ExecStateFromProto converts a wire ExecState enum to its domain form.
func ExecStateToProto ¶
ExecStateToProto converts a domain ExecState to its wire enum.
func MessageFromProto ¶
MessageFromProto converts a wire Message to the domain type (exported for the Sessions service).
func MessageToProto ¶
MessageToProto converts a domain Message to its wire form (exported for the Sessions service).
func ToolCallToProto ¶
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 ¶
ToolSpecFromProto converts a wire tool declaration to the domain type. A nil p yields the zero value.
Types ¶
This section is empty.