Expand description
Wire protocol — server→client event envelopes built to match spec/.
Every constructor here produces a serde_json::Value whose field names and
nesting match the JSON Schemas in smooth-operator/spec/events/*.json exactly,
so the generated TS/Go/.NET/Python clients deserialize them unmodified.
All events are serialized as a flat envelope with a type discriminator
plus the per-event fields documented in envelope.schema.json’s
EventEnvelope (requestId, status, data, node, token, error,
timestamp).
Structs§
- Turn
Usage - Per-turn token-accounting + cost, captured from the engine’s terminal
AgentEvent::Completedand surfaced on theeventual_responseso clients can accumulate a live session cost. All fields are accumulated across every LLM call in the turn.Copyso it threads through the runner → handler → protocol by value.
Functions§
- error
error— an unrecoverable error. The{ code, message }descriptor is duplicated at the envelope level and nested underdata.errorfor wire backward-compatibility (pererror.schema.json).- eventual_
response eventual_response— the terminal event of a streaming turn. The payload is double-nested (data.data) pereventual-response.schema.json.- immediate_
response immediate_response— synchronous ack. For non-streaming actions this also carries the full response payload indata.- now_ms
- Current Unix epoch milliseconds (for the
timestampfield). - otp_
invalid otp_invalid— emitted when averify_otpattempt is rejected.erroris an optional machine-readable reason (INVALID_CODE/MAX_ATTEMPTS/NOT_FOUND/EXPIRED);attempts_remainingof 0 means the code is locked and the client must restart the flow. Wire shape matchesspec/events/otp-invalid.schema.json.- otp_
sent otp_sent— acknowledgement that a code was dispatched to the caller. Wire shape matchesspec/events/otp-sent.schema.json.masked_destinationis a partially masked address safe to display (e.g.j***@example.com).- otp_
verification_ required otp_verification_required— emitted after a turn’s auth gate refused anend_usertool on an unverified session and the host has an OTP service installed. Tells the client to collect a one-time code. Wire shape matchesspec/events/otp-verification-required.schema.json(double-nesteddata.data).available_channelsare the delivery channels the server can offer given the session’s known contacts (email/sms).- otp_
verified otp_verified— emitted when averify_otpattempt succeeds. The session is now identity-verified; the client re-sends its message to run the gated tool. Wire shape matchesspec/events/otp-verified.schema.json.- pong
pong— reply to aping. Carries the server timestamp both at the top level and insidedata(perpong.schema.json).- stream_
chunk stream_chunk— a per-node state snapshot.nodeis mirrored at the envelope level and insidedata(perstream-chunk.schema.json).stateonly carries safe-to-expose fields.- stream_
reasoning stream_reasoning— a single streamed reasoning token from a reasoning model’s separate thinking channel. Shaped exactly likestream_token, but on a distincttypeso clients render it as “thinking” and never fold it into the answer. Clients that don’t know the type simply ignore it (the answer still streams viastream_token).- stream_
token stream_token— a single streamed LLM token. The token is mirrored both at the envelope level (token) and insidedata(perstream-token.schema.json).- write_
confirmation_ required write_confirmation_required— emitted mid-turn when the agent calls a state-mutating tool that requires explicit human approval before it runs. The turn is parked (the agent loop blocks inside the coreConfirmationHook::pre_call, corresponding toAgentEvent::HumanInputRequired { Confirm }) until the client replies with aconfirm_tool_actionaction carrying the samerequestIdand anapprovedboolean.