Skip to main content

Crate locode_protocol

Crate locode_protocol 

Source
Expand description

locode-protocol — shared, provider-neutral types with no I/O.

Two concerns live here:

  • the conversation model (4-role, Anthropic-shaped content blocks — ADR-0013), which the loop accumulates and hands to a Provider; and
  • the report envelope (ADR-0009), the single JSON artifact locode-exec prints.

Types are Rust-native and serialize with serde for our own persistence/reporting; conversion to a specific provider wire (Anthropic, OpenAI) lives in each Provider impl, not here.

Structs§

Conversation
A full conversation: one uniform stream of role-tagged messages (ADR-0013).
Message
One message: a role plus an ordered list of content blocks.
Report
The single JSON document locode-exec prints to stdout (ADR-0009).
ToolCallRecord
A report-side record of one tool call (distinct from the in-conversation ContentBlock::ToolUse): the structured output view, not the model-facing text.
ToolSpec
A provider-neutral tool spec: name + description + args JSON Schema.
Usage
Token accounting parsed from the provider’s terminal usage event.

Enums§

ContentBlock
A typed piece of message content, modeled on Anthropic’s content blocks.
Event
One event in the stream-json trajectory (one JSON object per line).
GrammarSyntax
The grammar language of a ToolInputFormat::Freeform tool.
ImageSource
The source of an image block.
ReasoningFormat
The encoding/replay contract of a ContentBlock::Reasoning block.
ResultChunk
A single chunk of a tool result (a restricted set of block kinds).
Role
The author of a message (ADR-0013).
Status
The terminal state of a run. Serializes to the exact strings in ADR-0009.
ToolInputFormat
How a tool’s input is specified: a JSON-schema function tool, or a freeform tool whose raw-text input is constrained by a server-side grammar (OpenAI Responses custom tools — codex’s apply_patch). Exactly one of the two — an enum, not optional fields, so invalid states are unrepresentable.

Functions§

reconstruct_conversation
Reconstruct the full Conversation from a stream-json event trajectory.