本文へスキップ

DOCS

Stream

1 つの POST、1 つの SSE 応答。@sveda-ai/core と sveda-server のイベントは整合。

Stream

1 つの POST、1 つの SSE 応答。@sveda-ai/core と sveda-server のイベントは整合。

イベント型、Accept と Content-Type、クライアントでの tool.call と message.end の処理。

Framing

Each event is an SSE line data: {json} followed by a blank line. The stream ends with data: [DONE]. Client Accept in sveda mode is application/vnd.sveda.stream+json. Response Content-Type is text/event-stream. The runtime sets x-sveda-protocol-version: 1.0.

POST /sveda/stream
Accept: application/vnd.sveda.stream+json
Content-Type: application/json
x-sveda-embed-token: sveda_embed_…

Content-Type: text/event-stream
x-sveda-protocol-version: 1.0
data: {"type":"message.start","chatId":"chat_1"}

data: {"type":"text.delta","delta":"Hello","chatId":"chat_1"}

data: {"type":"message.end","finishReason":"stop","chatId":"chat_1"}

data: [DONE]

Event list

Closed set from StreamEvent. Do not invent aliases.

message.start

Turn opened. Optional chatId, messageId, timestamp.

text.delta

Assistant token. Field delta.

reasoning.delta

Reasoning token. Field delta.

tool.call

toolCallId, toolName, input, target backend | frontend. Optional confirmation: "required" pauses until toolDecisions.

tool.result

toolCallId, toolName, output; optional renderHint, renderData.

tool.progress

Optional phase plus tasks[{ id, label, status, detail }].

context.usage

usedTokens, maxTokens, percent.

chat.title

Generated title for the chat.

max_steps

maxSteps, canContinue. Client may continueAfterMaxSteps().

message.end

Optional finishReason and usage. Turn closed.

error

code and message.

tool.call target

target is backend or frontend. Backend tools run in sveda-server (builtins and host MCP). Frontend tools run in the browser via SvedaToolRegistry — MCP and tools.

data: {"type":"tool.call","toolCallId":"call_1","toolName":"search_code","target":"backend","input":{"query":"SvedaClient"}}

data: {"type":"tool.call","toolCallId":"call_2","toolName":"get_selection","target":"frontend","input":{}}

When a tool requires chat confirmation, the same event includes confirmation: "required" and the runtime does not execute it until the client sends toolDecisions on the next POST. See tool confirmation.

Tools ride the same stream.

search_code, frontend register, host MCP — one event list, two targets.

MCP and tools