/** * GENERATED — DO NOT EDIT BY HAND. * * Source: schemas/qar/envelope.json * QAR commit: c0157c5c4aaa9304910c6be075e81d253f15c763 * QAR ref: c0157c5c4aaa9304910c6be075e81d253f15c763 * Fetched: 2026-10-07 * * Edit the upstream Pydantic models in qodo-ai/qodo-agent-runtime, * re-run `python scripts/export-schemas.py` there, bump * schemas/qar/.qar-version + the vendored JSON files, then * `npm run codegen:qar` regenerates this file. */ export type Envelope = (TaskStart | TaskContinue | TaskCancel | TaskResubscribe | TaskDelta | TaskDone | ToolRequest | ToolResponse | StateUpdate | AgentSpawn | ToolActivity | BulletinPost | ArtifactAdd | FlowPause | FlowResume | ErrorEnv); export interface TaskStart { envelope_version?: 1; kind?: "task.start"; message_id: string; parent_message_id?: (string | null); payload: TaskStartPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Client kicks off a fresh task on the session. */ export interface TaskStartPayload { agent_id: string; input: QodoTaskStartPayload; skill?: (string | null); } /** * Typed shape of ``task.start.input`` — owned by QAR, consumed by the SDK. * * QAR is the runtime, so it owns every wire shape; the SDK is the * typed bindings, never a parallel source of truth. * * Fields: * * * ``user_query`` — natural-language prompt the agent receives. Optional * because non-prompt agents (pure-tool sub-agents driven by orchestrators) * may carry only ``params``. When unset, the dispatcher passes * an empty user prompt to the agent — ``params`` and * ``metadata`` are NEVER serialised into the prompt string (they may * carry tenant-scoped credentials; see ``_input_to_prompt`` in * ``qar.protocol.ws_handler`` for the secrecy boundary). * * ``params`` — opaque per-tenant / per-session deps the runtime * merges into the agent's typed ``deps`` schema before dispatch. * Values are validated against the agent's ``deps_schema``. * Dispatcher-owned keys win the merge: ``tenant_id`` and ``session_id`` * are always written from server-trusted state, so a malicious * client cannot spoof either by stuffing them into this map. The * ``bulletin`` key is dispatcher-owned *for orchestrator agents* — * i.e., topologies declaring ``multi_agent.bulletin_topics``; * non-orchestrator topologies don't have a ``bulletin`` field on * their deps schema and rejecting it falls out of Pydantic * ``extra="forbid"`` validation. This field stays ``dict`` here * because the wire envelope is generic over the union of every * agent's deps schema. * * ``metadata`` — string-keyed/string-valued tracing metadata. Cardinality * is the operator's concern (don't put session ids here — they're already * on the envelope); included so Studio + downstream traces can stamp * arbitrary correlation tags without growing the envelope shape. * * ``content`` — optional ordered list of :data:`ContentPart` carrying a * multimodal user turn (text interleaved with inline files). Additive * and mutually exclusive with ``user_query``: a message carries the user * turn as the plain string OR as ordered parts, never both. Order is * semantically meaningful. The dispatcher maps a ``text`` part to a * ``str`` and a ``file`` part to a ``pydantic_ai.BinaryContent`` (see * ``_input_to_prompt`` / :mod:`qar.protocol.content`); ``params`` * and ``metadata`` are still never serialised into the prompt. * * Back-compat: ``content`` is additive and optional, so an old client that * only sends ``user_query`` works against the new server unchanged. The * new field uses ``extra="forbid"`` like every payload, so a new client * sending ``content`` is rejected by an old server — the rollout rule is * therefore server-before-client. */ export interface QodoTaskStartPayload { content?: ((TextPart | FilePart)[] | null); params?: ({ [k: string]: unknown | undefined; } | null); metadata?: ({ [k: string]: string | undefined; } | null); schema_version?: 1; user_query?: (string | null); } /** * A text segment of a multimodal user message. * * Carries the same natural-language content the flat ``user_query`` * string would; it exists as a part so a message can interleave text * and files in a single ordered sequence. */ export interface TextPart { text: string; type?: "text"; } /** * An inline file (image or PDF) segment of a multimodal user message. * * One part type serves both images and PDFs — the kind is carried by * ``media_type``, never by a separate image/file shape, so there is a * single code path downstream. * * ``media_type`` is a plain validated ``str``, NOT a frozen * :class:`~typing.Literal`. The set of *accepted* media types is an * operator-extensible allowlist enforced at dispatch (see * :mod:`qar.protocol.content`), deliberately kept OUT of this wire * schema: enabling a new provider/format is then an operator-config * change, not a wire-schema bump that would ripple to every generated * SDK binding. * * ``data`` is the base64-encoded file bytes (decoded + validated at * dispatch). ``filename`` is optional client metadata; it is treated as * sensitive downstream (kept out of span attributes), so it is never * required and never load-bearing. */ export interface FilePart { data: string; filename?: (string | null); media_type: string; type?: "file"; } /** * W3C Trace Context (https://www.w3.org/TR/trace-context/). */ export interface TraceContext { traceparent: string; tracestate?: (string | null); } export interface TaskContinue { envelope_version?: 1; kind?: "task.continue"; message_id: string; parent_message_id?: (string | null); payload: TaskContinuePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Client sends additional input mid-task. */ export interface TaskContinuePayload { input: { [k: string]: unknown | undefined; }; task_id: string; } export interface TaskCancel { envelope_version?: 1; kind?: "task.cancel"; message_id: string; parent_message_id?: (string | null); payload: TaskCancelPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Client requests cancellation of a running task. */ export interface TaskCancelPayload { reason?: (string | null); task_id: string; } export interface TaskResubscribe { envelope_version?: 1; kind?: "task.resubscribe"; message_id: string; parent_message_id?: (string | null); payload: TaskResubscribePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * A2A ``tasks/resubscribe`` semantics — replay since a known message_id. */ export interface TaskResubscribePayload { since_message_id?: (string | null); task_id?: (string | null); } export interface TaskDelta { envelope_version?: 1; kind?: "task.delta"; message_id: string; parent_message_id?: (string | null); payload: TaskDeltaPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Streaming delta for a running task (text chunk, partial state, etc.). */ export interface TaskDeltaPayload { delta: { [k: string]: unknown | undefined; }; task_id: string; } export interface TaskDone { envelope_version?: 1; kind?: "task.done"; message_id: string; parent_message_id?: (string | null); payload: TaskDonePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Final outcome for a task — success or terminal error. * * ``terminus_reason`` is an optional, additive discriminator for *why* * the run ended (see :data:`TerminusReason`). A run rescued by a final * synthesis turn lands ``status="completed"`` with a populated ``output`` * and the reason carrying *why* the run could not self-complete * (``max_steps_reached`` when it exhausted its step/usage budget, * ``output_unstable`` when it could not finalize a clean structured * output); if even the synthesis turn cannot run it lands * ``status="failed"`` with the same reason. A run the server cancelled * because its consumer vanished lands ``status="canceled"`` with * ``consumer_disconnected``. * * Backward compatibility: the field is serialised **only** when set, so * every pre-existing terminus (a clean completion, a consumer-requested * cancellation, a pre-dispatch rejection) emits the exact byte shape it * did before this field existed — a consumer still validating against the * older, ``additionalProperties: false`` schema never sees an unknown key * on those envelopes. The key appears solely on the synthesis-rescued * terminals and the grace-cancel terminal; consumers opting into that * behaviour regenerate their bindings from the updated schema. */ export interface TaskDonePayload { error?: (string | null); output?: ({ [k: string]: unknown | undefined; } | null); status: ("completed" | "failed" | "canceled"); task_id: string; terminus_reason?: (("max_steps_reached" | "output_unstable" | "consumer_disconnected") | null); } export interface ToolRequest { envelope_version?: 1; kind?: "tool.request"; message_id: string; parent_message_id?: (string | null); payload: ToolRequestPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Server asks the SDK side to execute an MCP tool. MCP tunneled inside. */ export interface ToolRequestPayload { arguments: { [k: string]: unknown | undefined; }; mcp_server?: (string | null); tool_call_id: string; tool_name: string; } export interface ToolResponse { envelope_version?: 1; kind?: "tool.response"; message_id: string; parent_message_id?: (string | null); payload: ToolResponsePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * SDK side returns the tool result. */ export interface ToolResponsePayload { error?: (string | null); outcome: ("success" | "error" | "denied"); result?: ({ [k: string]: unknown | undefined; } | null); tool_call_id: string; } export interface StateUpdate { envelope_version?: 1; kind?: "state.update"; message_id: string; parent_message_id?: (string | null); payload: StateUpdatePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Per-skill state change. ``skill`` keys the state schema; ``op`` is the * mutation kind (``patch``/``replace``/``init``). */ export interface StateUpdatePayload { op: ("patch" | "replace" | "init"); schema_version: number; skill: string; state: { [k: string]: unknown | undefined; }; } export interface AgentSpawn { envelope_version?: 1; kind?: "agent.spawn"; message_id: string; parent_message_id?: (string | null); payload: AgentSpawnPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * A sub-agent has been spawned. Surfacing this to the client lets Studio * render the multi-agent topology live. */ export interface AgentSpawnPayload { child_agent_id: string; parent_agent_id: string; spawn_protocol: ("bulletin" | "direct"); } /** * The ``tool.activity`` envelope — one-way managed-tool notification. * * Fire-and-forget, server→client only (no response kind). Parented to the * originating ``task.start`` so Studio / consumers can stitch it under the * run that produced it, same as :class:`AgentSpawn`. */ export interface ToolActivity { envelope_version?: 1; kind?: "tool.activity"; message_id: string; parent_message_id?: (string | null); payload: ToolActivityPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * A QAR-managed tool ran server-side. One-way notification, server→client. * * Managed tools (the catalog the runtime executes in-process, e.g. the * repository-search family) never round-trip through ``tool.request`` / * ``tool.response`` — they execute inside QAR and would otherwise be * invisible to the consumer. This payload surfaces the bare fact that one * ran so a consumer can render a progress line ("searched code with …"). * * **Redaction is part of the contract.** Only the tool ``name`` and the * coarse ``outcome`` leave the runtime — never the principal bearer, the * call arguments, or the tool result. ``code`` carries the typed managed- * tool error code (``MT-*``) on the failure path and is absent on success; * it is a stable taxonomy identifier, not user content. */ export interface ToolActivityPayload { code?: (string | null); outcome: ("ok" | "error"); tool_name: string; } export interface BulletinPost { envelope_version?: 1; kind?: "bulletin.post"; message_id: string; parent_message_id?: (string | null); payload: { [k: string]: unknown | undefined; }; session_id: string; trace_context: TraceContext; ts: string; } export interface ArtifactAdd { envelope_version?: 1; kind?: "artifact.add"; message_id: string; parent_message_id?: (string | null); payload: { [k: string]: unknown | undefined; }; session_id: string; trace_context: TraceContext; ts: string; } export interface FlowPause { envelope_version?: 1; kind?: "flow.pause"; message_id: string; parent_message_id?: (string | null); payload: FlowPausePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Server signals backpressure: client should pause non-critical sends. */ export interface FlowPausePayload { high_watermark: number; in_flight: number; } export interface FlowResume { envelope_version?: 1; kind?: "flow.resume"; message_id: string; parent_message_id?: (string | null); payload: FlowResumePayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Server signals backpressure cleared. */ export interface FlowResumePayload { in_flight: number; low_watermark: number; } export interface ErrorEnv { envelope_version?: 1; kind?: "error"; message_id: string; parent_message_id?: (string | null); payload: ErrorPayload; session_id: string; trace_context: TraceContext; ts: string; } /** * Protocol-level error — schema mismatch, dispatch failure, etc. */ export interface ErrorPayload { code: string; message: string; offending_message_id?: (string | null); } //# sourceMappingURL=envelope.d.ts.map