Typed engine event stream: the openseek run/serve stdout wire contract.
Dependencies
| Package | Contents | Targets | Deps |
|---|---|---|---|
| bobzhang/openseek_protocol | Event, Usage, Command, SteerKind, to_json, parse | js, wasm, wasm-gc, native | core/json |
| bobzhang/openseek_protocol/emit | emit (to_json + stdout writer) | native | async, above |
{"event":"assistant_delta","content":"Hel"}// Report an event. The line is `to_json`, nothing more.
@emit.emit(AssistantDelta(content="Hel"))
@emit.emit(AgentAborted(reason="interrupted"))
// Or build the line without logging it — what the desktop host forwards for a
// compaction whose engine died before reporting one itself.
let line = CompactionFailed(error="engine exited").to_json()
// Read one back. `None` means "not an event this engine emits" — an unknown
// name or a malformed payload — so a client stays tolerant of a newer engine.
match @protocol.parse(line) {
Some(AssistantDelta(content~)) => render(content)
Some(_) | None => ()
}// A controller writes a line.
let line = (Prompt(text="do it") : @protocol.Command).to_jsonl()
// The engine reads one back. `Err` is a line it cannot read — and only that:
// whether a readable command is *acceptable* is the engine's to say, which is
// why `serve`, not `parse`, refuses a blank goal.
match @protocol.Command::parse(line) {
Ok(Prompt(text~)) => start_turn(text)
Ok(_) => ()
Err(message) => report(message)
}pub(all) enum Event {
AgentSetupFailed(error~ : String)
AgentStep(step~ : Int)
AgentAborted(reason~ : String)
AgentFinished(answer~ : String)
MaxStepsExhausted
TurnFailed(error~ : String)
AssistantDelta(content~ : String)
ReasoningDelta(content~ : String)
AssistantMessage(content~ : String)
ReasoningMessage(content~ : String)
Usage(usage~ : Usage)
ToolResult(tool_call_id~ : String, tool_name~ : String, is_error~ : Bool, content~ : String, brief~ : String?)
ToolCallDecodeError(tool_call_id~ : String, tool_name~ : String, error~ : String)
ApprovalRequested(id~ : String, tool_name~ : String, detail~ : String, body~ : String?)
ApprovalResolved(id~ : String, outcome~ : String)
SteerApplied(kind~ : String, content~ : String)
SteerDropped(content~ : String)
BackgroundNotice(content~ : String)
GoalUpdated(goal~ : String?)
GoalBlocked(reason~ : String)
GoalUnblocked
GoalCheck(content~ : String)
GoalReminder(content~ : String)
GoalContinue(remaining~ : Int)
GoalBudgetExhausted(turns~ : Int)
PlanReminder(content~ : String)
CompactionStarted(from_sequence~ : Int, to_sequence~ : Int)
CompactionFinished(from_sequence~ : Int, to_sequence~ : Int, summary~ : String)
CompactionFailed(error~ : String)
AutoCompactionStarted(from_sequence~ : Int, to_sequence~ : Int)
AutoCompactionFinished(from_sequence~ : Int, to_sequence~ : Int, summary~ : String)
AutoCompactionFailed(error~ : String)
ContextYield(to_sequence~ : Int, answer~ : String)
SubrunStarted(id~ : String, kind~ : String, label~ : String)
SubrunFinished(id~ : String, status~ : String, steps~ : Int, prompt_tokens~ : Int, completion_tokens~ : Int)
SessionStarted(session~ : String, session_root~ : String, workspace_root~ : String?)
SessionError(error~ : String)
WorkspaceCreated(dir~ : String)
CommandError(error~ : String)
FleetStarted(runs~ : Int, task~ : String)
McpConfigIgnored(reason~ : String)
McpConfigUnreadable(path~ : String, error~ : String)
McpConfigInvalid(path~ : String, error~ : String)
McpToolsRegistered(servers~ : Int, tools~ : Int, names~ : Array[String])
McpToolDuplicate(server~ : String, tool~ : String)
McpToolRenamed(from~ : String, to~ : String)
McpToolsCapped(server~ : String, kept~ : Int)
McpServerSkippedOverCap(server~ : String)
McpConnectFailed(server~ : String, error~ : String?)
McpListToolsFailed(server~ : String, error~ : String)
McpListToolsTimeout(server~ : String)
McpNoTools(server~ : String)
} derive(Eq, Debug)fn split_child_session_id(id : String) -> (String, Int)?Install
Download zipTyped engine event stream: the openseek run/serve stdout wire contract.
Dependencies