Translator

Trait Translator 

Source
pub trait Translator: Send {
    // Required method
    fn translate(&mut self, frame: Value) -> Vec<AgentEvent>;
}
Expand description

A streaming translator: feeds raw provider frames as parsed JSON values and emits zero-or-more AgentEvents per frame.

Using a concrete serde_json::Value frame type (rather than an associated type) keeps the trait dyn-dispatchable so the runner can hold Box<dyn Translator> and switch providers at run time. All currently-planned providers (Claude Code stream-json, ACP, future Aider/Codex/Gemini) speak JSON over stdout, so the lowest-common-denominator frame fits them. Providers with binary framing would wrap their parser to emit Value envelopes before this layer.

PR 0 ships only the trait + Claude skeleton. PR 1 fills in the translation logic.

Required Methods§

Source

fn translate(&mut self, frame: Value) -> Vec<AgentEvent>

Translate a single frame into zero-or-more events. Returning Vec (not Option) because some provider frames produce multiple events (e.g. a message_start with embedded tool_use blocks).

Implementors§