@arbidocs/sdk 0.5.54 → 0.5.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/testing/sse-frames.ts","../src/testing/sse-fake.ts","../src/testing/chat-scenarios.ts"],"names":[],"mappings":";AA8CO,SAAS,KAAA,CAAM,OAAe,IAAA,EAAsB;AACzD,EAAA,OAAO,UAAU,KAAK;AAAA,MAAA,EAAW,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC;;AAAA,CAAA;AACvD;AAGA,IAAM,QAAQ,CAAC,EAAA,KAAgB,uBAAM,IAAI,IAAA,IAAO,WAAA,EAAY;AAC5D,IAAM,OAAA,GAAU,CAAC,EAAA,KAAgB,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,KAAA,CAAM,EAAE,CAAC,CAAA,GAAI,GAAI,CAAA;AAGjE,SAAS,QAAA,CAAS,EAAA,EAAY,IAAA,EAAc,IAAA,GAAa,EAAC,EAAS;AACxE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,eAAA;AAAA,IACN,EAAA;AAAA,IACA,OAAA,EAAS,EAAA;AAAA,IACT,IAAA;AAAA,IACA,SAAA,EAAW,IAAA;AAAA,IACX,MAAA,EAAQ,WAAA;AAAA,IACR,IAAA,EAAM,EAAE,MAAA,EAAQ,CAAC,EAAE,MAAM,IAAA,EAAM,CAAA,EAAG,GAAG,IAAA;AAAK,GAC5C;AACF;AAQO,SAAS,aAAA,CAAc,EAAA,EAAY,IAAA,GAAa,IAAI,OAAA,EAAwB;AACjF,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,EAAA;AAAA,IACA,MAAA,EAAQ,WAAA;AAAA,IACR,OAAA,EAAS,OAAA,GAAU,CAAC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,OAAA,EAAS,WAAA,EAAa,EAAC,EAAG,IAAI,EAAC;AAA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,cACP,MAAA,EAAQ,EAAA;AAAA,cACR,cAAA,EAAgB,OAAA;AAAA,cAChB,OAAA,EAAS;AAAA;AACX;AACF;AACF,OACF;AAAA,MACA,EAAE,MAAM,sBAAA;AAAuB;AACjC,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,cAAA;AAAA,IACN,WAAA,EAAa,+DAAA;AAAA,IACb,IAAA,EAAM,YAAA;AAAA,IACN,KAAA,EAAO;AAAA,MACL,EAAE,MAAM,4BAAA,EAA6B;AAAA,MACrC;AAAA,QACE,IAAA,EAAM;AAAA,UACJ,IAAA,CAAK,8BAA8B,QAAQ,CAAA;AAAA,UAC3C,QAAQ,QAAQ,CAAA;AAAA,UAChB,cAAA,CAAe;AAAA,YACb,IAAA,EAAM,gBAAA;AAAA,YACN,OAAA,EAAS,qCAAA;AAAA,YACT,KAAA,EAAO,EAAA;AAAA,YACP,MAAA,EAAQ,EAAA;AAAA,YACR,YAAA,EAAc;AAAA,WACf,CAAA;AAAA,UACD,YAAY,qCAAqC;AAAA;AACnD,OACF;AAAA,MACA,EAAE,OAAO,IAAA;AAAK;AAChB;AAEJ","file":"testing.js","sourcesContent":["/**\n * Assistant streams in the CURRENT wire protocol (SSE v3), written as frames.\n *\n * Every test that replays an assistant turn builds its body here: the e2e specs (through\n * `page.route` or the staged stream in `e2e/staged-sse.ts`), the chat parity scenarios and any\n * consumer's own tests (`@arbidocs/sdk/testing`). Bodies written out by hand rot silently the\n * moment the protocol moves: the client ignores frames it no longer knows, renders an empty trace,\n * and the test fails on a timeout that says nothing about why. That is what happened to\n * `arbi.agent_step`, retired by SSE protocol v3 (#2079). With the frames in one place the next\n * protocol change is one edit.\n *\n * ## The protocol, as clients consume it\n *\n * - `arbi.user_message` — the user's own message, stored. There is no optimistic insert on send:\n * a body without it renders the conversation with the prompt MISSING.\n * - `response.created` — carries `response.id`, the assistant message's external id. This creates\n * the assistant row (`streamSSE` maps it to `onStreamStart`).\n * - `response.output_item.done` — one settled Responses output item. Only these build the trace:\n * * `function_call` → a tool step,\n * * `reasoning` → a lifecycle step (goal / planning / goal check / interjection …),\n * * `message` → body text, and a trace row ONLY when it declares `arbi.step` (the answer\n * does; narration doesn't).\n * Display metadata rides under `item.arbi`; nesting is by `arbi.parent_id`, which names a parent\n * ITEM ID (the client derives the display index itself).\n * - `response.output_text.delta` — streams body text, keyed by `item_id`.\n * - `response.completed` — ends the stream and carries the authoritative final message metadata.\n *\n * Step rows render as `agent-step-{index}`, where index is assigned by the client in first-seen\n * order starting at 1 — so the Nth distinct item id is `agent-step-N`.\n */\n\nimport type {\n ArtifactEvent,\n MailDraftSSEEvent,\n ProbeAnswerEvent,\n TokenBudgetContext,\n UserInputRequestEvent,\n} from '../sse-types.js'\n\n/** ARBI's trace extension on an output item (`ArbiItemMeta`). */\nexport type Arbi = Record<string, unknown>\n\n/** One Responses output item. */\nexport type Item = Record<string, unknown>\n\n/** One `event:`/`data:` frame. */\nexport function frame(event: string, data: object): string {\n return `event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`\n}\n\n/** Frames are stamped now unless the caller fixes the time (`at`), as golden scenarios do. */\nconst isoAt = (at?: string) => at ?? new Date().toISOString()\nconst epochAt = (at?: string) => Math.floor(Date.parse(isoAt(at)) / 1000)\n\n/** A tool call — the workhorse trace row. `arbi.detail[0].tool` names the tool. */\nexport function toolItem(id: string, name: string, arbi: Arbi = {}): Item {\n return {\n type: 'function_call',\n id,\n call_id: id,\n name,\n arguments: '{}',\n status: 'completed',\n arbi: { detail: [{ tool: name }], ...arbi },\n }\n}\n\n/**\n * A lifecycle step (goal, plan, goal check, interjection, skill ack). `arbi.step` declares which —\n * the backend states it rather than the client sniffing labels. `summary` is the item's extended\n * text (a plan's checklist, an interjection's message), which the client surfaces as the step's\n * content.\n */\nexport function reasoningItem(id: string, arbi: Arbi = {}, summary?: string): Item {\n return {\n type: 'reasoning',\n id,\n status: 'completed',\n summary: summary ? [{ type: 'output_text', text: summary, annotations: [] }] : [],\n arbi,\n }\n}\n\n/**\n * The answer. A `message` item that declares `step: \"answering\"` — so it is both the body text AND\n * the closing trace row that carries the answering model and that call's token cost.\n */\nexport function answerItem(id: string, text: string, arbi: Arbi = {}): Item {\n return {\n type: 'message',\n id,\n status: 'completed',\n role: 'assistant',\n content: [{ type: 'output_text', text, annotations: [] }],\n arbi: { label: 'Answered', step: 'answering', ...arbi },\n }\n}\n\n/** A working note the server settles as Narration: it leaves the body and lives on in the trace. */\nexport function narrationItem(id: string, text: string): Item {\n return {\n type: 'message',\n id,\n status: 'completed',\n role: 'assistant',\n content: [{ type: 'output_text', text, annotations: [] }],\n arbi: { label: 'Narration' },\n }\n}\n\nexport interface UserMessageFrameOptions {\n content: string\n conversationId: string\n externalId?: string\n /** `queued` for a follow-up the server holds behind a running turn. */\n status?: 'completed' | 'queued'\n parentMessageId?: string | null\n createdBy?: string\n /** ISO time the server stored it (default now). */\n at?: string\n}\n\n/** The user message as the server stored it (the body of `arbi.user_message`). */\nexport function userMessage(opts: UserMessageFrameOptions) {\n return {\n type: 'user_message',\n role: 'user',\n content: opts.content,\n shared: false,\n tokens: 0,\n status: opts.status ?? 'completed',\n external_id: opts.externalId ?? 'msg-e2e-user',\n created_at: isoAt(opts.at),\n created_by_ext_id: opts.createdBy ?? 'usr-e2e',\n conversation_ext_id: opts.conversationId,\n ...(opts.parentMessageId !== undefined ? { parent_message_ext_id: opts.parentMessageId } : {}),\n }\n}\n\n/**\n * The `arbi.user_message` echo — the user's own message coming back from the backend. NOT\n * optional dressing: clients add the user row only from this event.\n */\nexport function userMessageFrame(opts: UserMessageFrameOptions): string {\n return frame('arbi.user_message', userMessage(opts))\n}\n\n/** A follow-up the server accepted while a turn runs (`arbi.message_queued`). */\nexport function messageQueuedFrame(opts: {\n responseId: string\n input: string\n previousResponseId?: string | null\n user: UserMessageFrameOptions\n}): string {\n return frame('arbi.message_queued', {\n type: 'arbi.message_queued',\n response_id: opts.responseId,\n input: opts.input,\n queue_action: 'created',\n previous_response_id: opts.previousResponseId ?? null,\n user_message_id: opts.user.externalId ?? 'msg-e2e-user',\n user_message: userMessage({ ...opts.user, status: opts.user.status ?? 'queued' }),\n })\n}\n\n/** `response.created`: the assistant message exists on the server under `id`. */\nexport function responseCreatedFrame(id: string, t?: number, at?: string): string {\n return frame('response.created', {\n type: 'response.created',\n sequence_number: 1,\n ...(t != null ? { t } : {}),\n response: {\n id,\n object: 'response',\n status: 'in_progress',\n created_at: epochAt(at),\n model: 'e2e-mock',\n output: [],\n },\n })\n}\n\n/** Body text streaming into message item `itemId`. */\nexport function textDeltaFrame(itemId: string, delta: string): string {\n return frame('response.output_text.delta', {\n type: 'response.output_text.delta',\n item_id: itemId,\n output_index: 0,\n content_index: 0,\n delta,\n })\n}\n\n/** One settled output item (`response.output_item.done`). */\nexport function itemDoneFrame(item: Item, opts: { index?: number; t?: number } = {}): string {\n return frame('response.output_item.done', {\n type: 'response.output_item.done',\n sequence_number: (opts.index ?? 0) + 2,\n output_index: opts.index ?? 0,\n item,\n ...(opts.t != null ? { t: opts.t } : {}),\n })\n}\n\nexport interface CompletedFrameOptions {\n /** External id of the assistant message (`response.id`). */\n assistantId: string\n conversationId: string\n /** The authoritative answer. */\n content: string\n /** Stored tools of the answer (citations, trace…), as `message_metadata.tools`. */\n tools?: Record<string, unknown>\n /** Backend-suggested follow-up (SUGGESTED_QUERIES). */\n suggestedQuery?: string\n /** The per-turn token budget snapshot. */\n context?: TokenBudgetContext\n t?: number\n status?: 'completed' | 'failed'\n /** ISO time the answer was stored (default now). */\n at?: string\n}\n\n/** `response.completed`: ends the turn and carries the stored answer. */\nexport function completedFrame(opts: CompletedFrameOptions): string {\n return frame('response.completed', {\n type: 'response.completed',\n sequence_number: 99,\n ...(opts.t != null ? { t: opts.t } : {}),\n ...(opts.context ? { context: opts.context } : {}),\n response: {\n id: opts.assistantId,\n object: 'response',\n status: 'completed',\n created_at: epochAt(opts.at),\n model: 'e2e-mock',\n output: [],\n usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },\n metadata: {\n type: 'message_metadata',\n external_id: opts.assistantId,\n role: 'assistant',\n content: opts.content,\n conversation_ext_id: opts.conversationId,\n created_at: isoAt(opts.at),\n created_by_ext_id: 'usr-e2e',\n shared: false,\n tokens: 0,\n status: opts.status ?? 'completed',\n ...(opts.tools ? { tools: opts.tools } : {}),\n ...(opts.suggestedQuery ? { suggested_query: opts.suggestedQuery } : {}),\n },\n },\n })\n}\n\n/** `response.failed`: the server failed the answer. */\nexport function failedFrame(message: string): string {\n return frame('response.failed', {\n type: 'response.failed',\n sequence_number: 99,\n response: { id: 'failed', object: 'response', status: 'failed', error: { message } },\n })\n}\n\n/** `arbi.error`, e.g. a mid-stream `QUOTA_EXCEEDED`. */\nexport function arbiErrorFrame(opts: {\n code: string\n message: string\n spend?: number\n budget?: number\n projectExtId?: string\n}): string {\n return frame('arbi.error', {\n type: 'arbi.error',\n code: opts.code,\n message: opts.message,\n ...(opts.spend != null ? { spend: opts.spend } : {}),\n ...(opts.budget != null ? { budget: opts.budget } : {}),\n ...(opts.projectExtId ? { project_ext_id: opts.projectExtId } : {}),\n })\n}\n\n/** `arbi.artifact`: a document the assistant is writing (or has written). */\nexport function artifactFrame(event: Omit<ArtifactEvent, 'type'>): string {\n return frame('arbi.artifact', { type: 'arbi.artifact', ...event })\n}\n\n/** `arbi.mail_draft`: the assistant saved an email draft. */\nexport function mailDraftFrame(event: Omit<MailDraftSSEEvent, 'type'>): string {\n return frame('arbi.mail_draft', { type: 'arbi.mail_draft', ...event })\n}\n\n/** `arbi.deferred_interjection`: steering that arrived after the agent committed to its answer. */\nexport function deferredInterjectionFrame(message: string): string {\n return frame('arbi.deferred_interjection', { type: 'arbi.deferred_interjection', message })\n}\n\n/** `arbi.agent_control_state`: the server confirmed a pause or resume. */\nexport function agentControlStateFrame(state: 'paused' | 'running'): string {\n return frame('arbi.agent_control_state', { type: 'arbi.agent_control_state', state })\n}\n\n/** `arbi.probe_answer`: an out-of-band status answer. */\nexport function probeAnswerFrame(event: Omit<ProbeAnswerEvent, 'type'>): string {\n return frame('arbi.probe_answer', { type: 'arbi.probe_answer', ...event })\n}\n\n/** `arbi.user_input_request`: the agent asks the person a question mid-turn. */\nexport function userInputRequestFrame(event: Omit<UserInputRequestEvent, 'type'>): string {\n return frame('arbi.user_input_request', { type: 'arbi.user_input_request', ...event })\n}\n\nexport interface StreamOptions {\n /** External id of the assistant message (`response.id`). */\n assistantId: string\n /** Trace items, in emission order. Their order fixes the `agent-step-N` numbering. */\n items: Item[]\n /** Conversation the message belongs to — required if `userContent` is set. */\n conversationId?: string\n /** When set, the stream opens with an `arbi.user_message` echo (the user row). */\n userContent?: string\n /** External id for that user row. */\n userMessageId?: string\n /** Final answer text, set authoritatively by `response.completed`. */\n answer?: string\n /** Seconds-since-start for the first item; each later item advances by this much. */\n step?: number\n}\n\n/**\n * A complete assistant stream. Each item is stamped with an increasing `t` (seconds since stream\n * start) because the trace derives step durations from the gap between consecutive stamps.\n */\nexport function agentStream({\n assistantId,\n items,\n conversationId = 'cnv-e2e',\n userContent,\n userMessageId = 'msg-e2e-user',\n answer = '',\n step = 1,\n}: StreamOptions): string {\n let body = ''\n if (userContent) {\n body += userMessageFrame({ content: userContent, conversationId, externalId: userMessageId })\n }\n body += responseCreatedFrame(assistantId)\n items.forEach((item, i) => {\n body += itemDoneFrame(item, { index: i, t: Number(((i + 1) * step).toFixed(2)) })\n })\n body += completedFrame({\n assistantId,\n conversationId,\n content: answer,\n t: Number(((items.length + 2) * step).toFixed(2)),\n })\n return body\n}\n","/**\n * A `fetch` that answers the assistant endpoints with streams a test owns.\n *\n * The client under test is the real one: its request builder, the SDK's SSE parser and whatever\n * engine sits on top. Only the network is replaced. Each assistant request opens a staged stream\n * the test feeds frame by frame (`push`), ends (`close`), cuts (`drop`) or that the client aborts;\n * so a turn can be paused anywhere and inspected, exactly as `e2e/staged-sse.ts` does in the\n * browser. A test can also queue a plain HTTP reply (a 402, a 409) for the next request.\n *\n * Every request is recorded with its parsed JSON body, so request bodies can be asserted (or\n * snapshotted) as well as what the client did with the answer.\n */\n\n/** One request the client made. */\nexport interface RecordedRequest {\n method: string\n /** The path and query, without origin. */\n path: string\n body: unknown\n}\n\n/** A stream the test feeds. */\nexport interface StagedStream {\n /** The request that opened it. */\n readonly request: RecordedRequest\n /** Feed one or more SSE frames. */\n push(...frames: string[]): void\n /** End the stream normally. */\n close(): void\n /** Cut the connection mid-stream (the client sees a network error). */\n drop(error?: Error): void\n /** Whether the client aborted it, or it was closed or dropped. */\n readonly ended: boolean\n}\n\n/** A plain HTTP answer for the next matching request. */\nexport interface HttpReply {\n status: number\n body?: unknown\n}\n\nexport interface SseFake {\n /** Install as `globalThis.fetch` (or pass to the client). */\n fetch: typeof fetch\n /** Every request, in order. */\n readonly requests: RecordedRequest[]\n /** Streams opened by assistant requests (queries and run attaches), in order. */\n readonly streams: StagedStream[]\n /** The newest stream that has not ended. */\n current(): StagedStream | undefined\n /** Answer the next `POST /v1/assistant/query` with a plain HTTP reply instead of a stream. */\n replyNextQuery(reply: HttpReply): void\n /** Answer the next attach (`GET /v1/assistant/run/{id}/stream`) with a stream (default 404). */\n streamNextAttach(): void\n /** Answer other requests (default: 200 `{}`), e.g. cancel and interject. */\n setFallback(handler: (request: RecordedRequest) => HttpReply): void\n}\n\nconst QUERY_PATH = /\\/v1\\/assistant\\/query$/\nconst ATTACH_PATH = /\\/v1\\/assistant\\/run\\/[^/]+\\/stream$/\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted.')\n error.name = 'AbortError'\n return error\n}\n\nfunction json(reply: HttpReply): Response {\n return new Response(reply.body === undefined ? null : JSON.stringify(reply.body), {\n status: reply.status,\n headers: { 'content-type': 'application/json' },\n })\n}\n\n/** A request body as data: JSON parsed, and no body (absent or empty) as null. */\nfunction parseBody(body: unknown): unknown {\n if (body === '' || body === undefined) return null\n if (typeof body !== 'string') return body\n try {\n return JSON.parse(body)\n } catch {\n return body\n }\n}\n\nexport function createSseFake(): SseFake {\n const requests: RecordedRequest[] = []\n const streams: StagedStream[] = []\n const queryReplies: HttpReply[] = []\n let attachStreams = 0\n let fallback: (request: RecordedRequest) => HttpReply = () => ({ status: 200, body: {} })\n const encoder = new TextEncoder()\n\n const openStream = (request: RecordedRequest, signal?: AbortSignal | null): Response => {\n let controller!: ReadableStreamDefaultController<Uint8Array>\n let ended = false\n const end = (fn: () => void) => {\n if (ended) return\n ended = true\n try {\n fn()\n } catch {\n /* already closed */\n }\n }\n const body = new ReadableStream<Uint8Array>({\n start(c) {\n controller = c\n },\n cancel() {\n ended = true\n },\n })\n const stream: StagedStream = {\n request,\n push: (...frames) => {\n if (ended) throw new Error(`stream for ${request.path} has ended`)\n for (const f of frames) controller.enqueue(encoder.encode(f))\n },\n close: () => end(() => controller.close()),\n drop: (error = new TypeError('network error')) => end(() => controller.error(error)),\n get ended() {\n return ended\n },\n }\n signal?.addEventListener('abort', () => end(() => controller.error(abortError())))\n streams.push(stream)\n return new Response(body, {\n status: 200,\n headers: { 'content-type': 'text/event-stream; charset=utf-8' },\n })\n }\n\n const fakeFetch = async (\n input: string | URL | Request,\n init?: RequestInit\n ): Promise<Response> => {\n const request = typeof input === 'object' && 'url' in input ? input : null\n const url = request ? request.url : String(input)\n const method = (init?.method ?? request?.method ?? 'GET').toUpperCase()\n const signal = init?.signal ?? request?.signal\n const rawBody =\n init?.body ?? (request && method !== 'GET' ? await request.clone().text() : null)\n const parsed = new URL(url, 'http://localhost')\n const recorded: RecordedRequest = {\n method,\n path: parsed.pathname + parsed.search,\n body: parseBody(rawBody),\n }\n requests.push(recorded)\n if (signal?.aborted) throw abortError()\n\n if (method === 'POST' && QUERY_PATH.test(parsed.pathname)) {\n const reply = queryReplies.shift()\n return reply ? json(reply) : openStream(recorded, signal)\n }\n if (method === 'GET' && ATTACH_PATH.test(parsed.pathname)) {\n if (attachStreams === 0) return json({ status: 404, body: { detail: 'not active' } })\n attachStreams -= 1\n return openStream(recorded, signal)\n }\n return json(fallback(recorded))\n }\n\n return {\n fetch: fakeFetch as typeof fetch,\n requests,\n streams,\n current: () => [...streams].reverse().find((s) => !s.ended),\n replyNextQuery: (reply) => {\n queryReplies.push(reply)\n },\n streamNextAttach: () => {\n attachStreams += 1\n },\n setFallback: (handler) => {\n fallback = handler\n },\n }\n}\n","/**\n * Chat parity scenarios: assistant turns as the server streams them, plus what the person does\n * while they run.\n *\n * Each scenario is data, so any chat engine can replay it: the runner sends the prompts through\n * the engine under test, feeds the frames through `createSseFake`, presses Stop when told, and\n * snapshots what the engine left behind (the thread, the list, the session) next to the\n * scenario's golden file. While the engine moves between layers (#1720 A1–A9) the runner changes\n * and the golden files must not.\n */\n\nimport type { HttpReply } from './sse-fake.js'\nimport {\n agentControlStateFrame,\n answerItem,\n arbiErrorFrame,\n artifactFrame,\n completedFrame,\n deferredInterjectionFrame,\n failedFrame,\n itemDoneFrame,\n mailDraftFrame,\n messageQueuedFrame,\n narrationItem,\n probeAnswerFrame,\n reasoningItem,\n responseCreatedFrame,\n textDeltaFrame,\n toolItem,\n userInputRequestFrame,\n userMessageFrame,\n} from './sse-frames.js'\n\n/** One thing that happens during a scenario, in order. */\nexport type ChatStep =\n /** The person types `send` into the composer and sends it. */\n | { send: string }\n /** The server sends frames on stream `stream` (index in opening order; default: the newest open). */\n | { push: string[]; stream?: number }\n /** The server ends a stream normally. */\n | { close: true; stream?: number }\n /** The connection drops mid-stream. */\n | { drop: true; stream?: number }\n /** The person presses Stop. */\n | { stop: true }\n /** The next assistant request gets a plain HTTP reply. */\n | { replyNextQuery: HttpReply }\n /** Time passes (ms), on the fake clock. */\n | { wait: number }\n /** Record the engine's state under this label (the final state is always recorded). */\n | { snapshot: string }\n\n/** A message already in the thread when the scenario starts. */\nexport interface SeedMessage {\n id: string\n role: 'user' | 'assistant'\n content: string\n parent: string | null\n}\n\nexport interface ChatScenario {\n name: string\n description: string\n /** Start in this existing conversation; otherwise a new chat. */\n seed?: { conversationId: string; history: SeedMessage[] }\n /** Documents and facts added to the chat before the first send. */\n context?: { documents?: string[]; facts?: string[] }\n steps: ChatStep[]\n}\n\n/** Every frame is stamped with this time, so the golden files are reproducible. */\nconst AT = '2026-01-01T00:00:00.000Z'\n\nconst SEED_CONVERSATION = 'cnv-seeded'\nconst seededThread = {\n conversationId: SEED_CONVERSATION,\n history: [\n { id: 'msg-u0', role: 'user', content: 'Earlier question', parent: null },\n { id: 'msg-a0', role: 'assistant', content: 'Earlier answer', parent: 'msg-u0' },\n ] satisfies SeedMessage[],\n}\n\nconst user = (content: string, externalId: string, parent: string | null = 'msg-a0') =>\n userMessageFrame({\n content,\n conversationId: SEED_CONVERSATION,\n externalId,\n parentMessageId: parent,\n at: AT,\n })\n\nconst created = (assistantId: string, t?: number) => responseCreatedFrame(assistantId, t, AT)\n\nconst done = (assistantId: string, content: string, extra: Record<string, unknown> = {}) =>\n completedFrame({ assistantId, conversationId: SEED_CONVERSATION, content, at: AT, ...extra })\n\nconst CONTEXT = {\n context_window: 200000,\n budget: 180000,\n system: 2000,\n history: 300,\n compaction: 0,\n retrieval: 1200,\n query: 40,\n output: 500,\n total_input: 3540,\n truncated: false,\n reasoning: 0,\n total_output: 500,\n}\n\nexport const CHAT_SCENARIOS: ChatScenario[] = [\n {\n name: 'plain-answer',\n description:\n 'A new chat with a document and a fact: the first turn moves \"new\" to the server id and the answer streams, then resolves with its context and a suggested follow-up.',\n context: { documents: ['doc-1'], facts: ['fact-1'] },\n steps: [\n { send: 'What does the contract say about termination?' },\n {\n push: [\n userMessageFrame({\n content: 'What does the contract say about termination?',\n conversationId: 'cnv-new-1',\n externalId: 'msg-u1',\n parentMessageId: null,\n at: AT,\n }),\n created('msg-a1', 0.2),\n textDeltaFrame('it-answer', 'Either party may '),\n ],\n },\n { snapshot: 'streaming' },\n {\n push: [\n textDeltaFrame('it-answer', 'terminate on 30 days notice.'),\n itemDoneFrame(answerItem('it-answer', 'Either party may terminate on 30 days notice.'), {\n t: 1.4,\n }),\n completedFrame({\n assistantId: 'msg-a1',\n conversationId: 'cnv-new-1',\n content: 'Either party may terminate on 30 days notice.',\n suggestedQuery: 'What notice period applies?',\n context: CONTEXT,\n t: 1.6,\n at: AT,\n }),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'agent-steps',\n description:\n 'A follow-up in an existing thread that works through tools: steps fold into the trace, narration leaves the body, and the answer resolves after the narration dwell.',\n seed: seededThread,\n steps: [\n { send: 'Find the liability cap' },\n {\n push: [\n user('Find the liability cap', 'msg-u1'),\n created('msg-a1', 0.1),\n itemDoneFrame(reasoningItem('rs-1', { step: 'goal', label: 'Thinking…' }, 'Find it'), {\n index: 0,\n t: 0.5,\n }),\n textDeltaFrame('it-n1', 'Let me search the documents.'),\n itemDoneFrame(toolItem('fc-2', 'search_inside_documents', { label: 'Searching' }), {\n index: 1,\n t: 1.5,\n }),\n textDeltaFrame('it-n2', 'Now reading the clause. '),\n itemDoneFrame(narrationItem('it-n2', 'Now reading the clause. '), { index: 2, t: 2 }),\n itemDoneFrame(toolItem('fc-3', 'get_document_passages', { label: 'Reading' }), {\n index: 3,\n t: 2.5,\n }),\n textDeltaFrame('it-answer', 'The cap is £1m.'),\n itemDoneFrame(answerItem('it-answer', 'The cap is £1m.'), { index: 4, t: 3 }),\n ],\n },\n { snapshot: 'before-completed' },\n { push: [done('msg-a1', 'The cap is £1m.', { t: 3.2 })] },\n { close: true },\n { wait: 5000 },\n ],\n },\n {\n name: 'subagents',\n description: 'A run_skill sub-agent whose relayed child steps nest under the parent step.',\n seed: seededThread,\n steps: [\n { send: 'Run the research-helper skill' },\n {\n push: [\n user('Run the research-helper skill', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(\n toolItem('fc-1', 'run_skill', {\n label: 'Skill',\n focus: 'Invoking the research-helper skill',\n detail: [{ tool: 'run_skill', summary: 'research-helper' }],\n }),\n { index: 0, t: 1 }\n ),\n itemDoneFrame(\n toolItem('fc-2', 'search_inside_documents', {\n label: 'Searching documents',\n parent_id: 'fc-1',\n }),\n { index: 1, t: 2 }\n ),\n itemDoneFrame(\n toolItem('fc-3', 'goal_progress', { label: 'Goal check', parent_id: 'fc-1' }),\n { index: 2, t: 3 }\n ),\n textDeltaFrame('msg-4', 'The skill found the clauses.'),\n itemDoneFrame(answerItem('msg-4', 'The skill found the clauses.'), { index: 3, t: 4 }),\n done('msg-a1', 'The skill found the clauses.', { t: 4.2 }),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'interjection',\n description:\n 'A message sent while the agent works is queued, steered into the running turn at the next tool boundary, and settled by the interjection step.',\n seed: seededThread,\n steps: [\n { send: 'Research the company financials' },\n {\n push: [\n user('Research the company financials', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(toolItem('fc-1', 'web_search', { label: 'Searching the web' }), {\n index: 0,\n t: 1,\n }),\n ],\n },\n { send: 'Focus on 2026' },\n { snapshot: 'queued' },\n {\n stream: 1,\n push: [\n messageQueuedFrame({\n responseId: 'resp-steer',\n input: 'Focus on 2026',\n previousResponseId: 'msg-a1',\n user: {\n content: 'Focus on 2026',\n conversationId: SEED_CONVERSATION,\n externalId: 'msg-u2',\n parentMessageId: 'msg-a1',\n at: AT,\n },\n }),\n ],\n },\n { close: true, stream: 1 },\n { snapshot: 'acknowledged' },\n {\n stream: 0,\n push: [\n itemDoneFrame(\n reasoningItem('rs-2', { step: 'interjection', label: 'Your message' }, 'Focus on 2026'),\n { index: 1, t: 2 }\n ),\n textDeltaFrame('msg-3', 'Focusing on 2026.'),\n itemDoneFrame(answerItem('msg-3', 'Focusing on 2026.'), { index: 2, t: 3 }),\n done('msg-a1', 'Focusing on 2026.', { t: 3.1 }),\n ],\n },\n { close: true, stream: 0 },\n { wait: 1000 },\n ],\n },\n {\n name: 'queued-followup',\n description:\n 'A follow-up the server queues behind the running turn: shown in the agent bar, moved to the next turn when it starts, and answered in its own turn.',\n seed: seededThread,\n steps: [\n { send: 'Summarise the report' },\n {\n push: [\n user('Summarise the report', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'The report covers'),\n ],\n },\n { send: 'Then list the risks' },\n {\n stream: 1,\n push: [\n messageQueuedFrame({\n responseId: 'resp-queued',\n input: 'Then list the risks',\n previousResponseId: 'msg-a1',\n user: {\n content: 'Then list the risks',\n conversationId: SEED_CONVERSATION,\n externalId: 'msg-u2',\n parentMessageId: 'msg-a1',\n at: AT,\n },\n }),\n ],\n },\n { snapshot: 'queued' },\n {\n stream: 0,\n push: [\n textDeltaFrame('msg-x', ' three areas.'),\n itemDoneFrame(answerItem('msg-x', 'The report covers three areas.'), { t: 2 }),\n done('msg-a1', 'The report covers three areas.', { t: 2.1 }),\n ],\n },\n { close: true, stream: 0 },\n {\n stream: 1,\n push: [user('Then list the risks', 'msg-u2', 'msg-a1'), created('msg-a2')],\n },\n { snapshot: 'second-turn' },\n { wait: 1000 },\n {\n stream: 1,\n push: [\n textDeltaFrame('msg-y', 'Risks: delay and cost.'),\n itemDoneFrame(answerItem('msg-y', 'Risks: delay and cost.'), { t: 1 }),\n done('msg-a2', 'Risks: delay and cost.', { t: 1.1 }),\n ],\n },\n { close: true, stream: 1 },\n ],\n },\n {\n name: 'deferred-interjection',\n description:\n 'Steering that reached the agent after it committed to its answer is resubmitted as a new turn once the turn completes.',\n seed: seededThread,\n steps: [\n { send: 'Draft the summary' },\n {\n push: [\n user('Draft the summary', 'msg-u1'),\n created('msg-a1'),\n deferredInterjectionFrame('Also mention the dates'),\n textDeltaFrame('msg-x', 'Summary drafted.'),\n itemDoneFrame(answerItem('msg-x', 'Summary drafted.'), { t: 1 }),\n done('msg-a1', 'Summary drafted.', { t: 1.1 }),\n ],\n },\n { close: true, stream: 0 },\n { snapshot: 'resubmitted' },\n {\n stream: 1,\n push: [\n user('Also mention the dates', 'msg-u2', 'msg-a1'),\n created('msg-a2'),\n done('msg-a2', 'Dates: 1 May and 1 June.'),\n ],\n },\n { close: true, stream: 1 },\n ],\n },\n {\n name: 'agent-control',\n description:\n 'Pause, report and resume while the agent works: optimistic state, the server confirmation and the probe answer, cleared when the turn ends.',\n seed: seededThread,\n steps: [\n { send: 'Audit every contract' },\n {\n push: [\n user('Audit every contract', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(toolItem('fc-1', 'search_inside_documents'), { t: 1 }),\n ],\n },\n { send: '/pause' },\n { snapshot: 'pausing' },\n { push: [agentControlStateFrame('paused')] },\n { send: '/report' },\n { push: [probeAnswerFrame({ question: '/report', answer: 'Two of five contracts read.' })] },\n { snapshot: 'paused-with-report' },\n { send: '/resume' },\n {\n push: [\n agentControlStateFrame('running'),\n userInputRequestFrame({\n question: 'Include expired contracts?',\n options: ['Yes', 'No'],\n timeout_seconds: 120,\n }),\n ],\n },\n { snapshot: 'asking' },\n { push: [done('msg-a1', 'Audit complete.')] },\n { close: true },\n ],\n },\n {\n name: 'stop',\n description:\n 'Stop cancels the run on the server first, then closes the stream; the stopped turn is never shown as failed.',\n seed: seededThread,\n steps: [\n { send: 'Write a long essay' },\n {\n push: [\n user('Write a long essay', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'Once upon a time'),\n ],\n },\n { stop: true },\n { wait: 100 },\n ],\n },\n {\n name: 'drop',\n description:\n 'The connection drops after the server stored the question: the turn is not failed, the thread is re-read and generation is held while it is.',\n seed: seededThread,\n steps: [\n { send: 'Explain clause 4' },\n {\n push: [\n user('Explain clause 4', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'Clause 4'),\n ],\n },\n { drop: true },\n { wait: 6000 },\n ],\n },\n {\n name: 'server-failed',\n description: 'The server fails the answer (`response.failed`): it is marked failed.',\n seed: seededThread,\n steps: [\n { send: 'Explain clause 5' },\n {\n push: [\n user('Explain clause 5', 'msg-u1'),\n created('msg-a1'),\n failedFrame('This answer stopped making progress.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'artifact',\n description:\n 'A streamed html artifact opens in the viewer, joins the chat documents and becomes the pinned document once complete.',\n seed: seededThread,\n steps: [\n { send: 'Make a landing page' },\n {\n push: [\n user('Make a landing page', 'msg-u1'),\n created('msg-a1'),\n artifactFrame({\n doc_ext_id: 'doc-art',\n title: 'Landing page',\n mode: 'html',\n content: '<h1>Hi',\n file_type: 'text/html',\n is_complete: false,\n version: 1,\n message_ext_id: 'msg-a1',\n }),\n ],\n },\n { snapshot: 'streaming-artifact' },\n {\n push: [\n artifactFrame({\n doc_ext_id: 'doc-art',\n title: 'Landing page',\n mode: 'html',\n content: '<h1>Hi</h1>',\n file_type: 'text/html',\n is_complete: true,\n version: 1,\n message_ext_id: 'msg-a1',\n }),\n done('msg-a1', 'I made the landing page.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'mail-draft',\n description: 'A mail draft the assistant saved opens the mail side beside the chat.',\n seed: seededThread,\n steps: [\n { send: 'Draft a reply to Sam' },\n {\n push: [\n user('Draft a reply to Sam', 'msg-u1'),\n created('msg-a1'),\n mailDraftFrame({ draft_id: 'draft-1', message_ext_id: 'msg-a1' }),\n done('msg-a1', 'The reply is drafted.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'quota-402',\n description:\n \"The project's AI usage is used up: the query is refused with a 402 and the quota modal opens.\",\n seed: seededThread,\n steps: [\n {\n replyNextQuery: {\n status: 402,\n body: {\n detail: {\n code: 'QUOTA_EXCEEDED',\n spend: 10,\n budget: 10,\n project_ext_id: 'prj-1',\n message: 'AI usage for this month is used up.',\n },\n },\n },\n },\n { send: 'Summarise everything' },\n ],\n },\n {\n name: 'quota-stream',\n description: 'The AI usage runs out mid-turn (`arbi.error` QUOTA_EXCEEDED).',\n seed: seededThread,\n steps: [\n { send: 'Summarise everything again' },\n {\n push: [\n user('Summarise everything again', 'msg-u1'),\n created('msg-a1'),\n arbiErrorFrame({\n code: 'QUOTA_EXCEEDED',\n message: 'AI usage for this month is used up.',\n spend: 10,\n budget: 10,\n projectExtId: 'prj-1',\n }),\n failedFrame('AI usage for this month is used up.'),\n ],\n },\n { close: true },\n ],\n },\n]\n"]}
1
+ {"version":3,"sources":["../src/testing/sse-frames.ts","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;AAAA,IACE,IAAA,EAAM,cAAA;AAAA,IACN,WAAA,EAAa,+DAAA;AAAA,IACb,IAAA,EAAM,YAAA;AAAA,IACN,KAAA,EAAO;AAAA,MACL,EAAE,MAAM,4BAAA,EAA6B;AAAA,MACrC;AAAA,QACE,IAAA,EAAM;AAAA,UACJ,IAAA,CAAK,8BAA8B,QAAQ,CAAA;AAAA,UAC3C,QAAQ,QAAQ,CAAA;AAAA,UAChB,cAAA,CAAe;AAAA,YACb,IAAA,EAAM,gBAAA;AAAA,YACN,OAAA,EAAS,qCAAA;AAAA,YACT,KAAA,EAAO,EAAA;AAAA,YACP,MAAA,EAAQ,EAAA;AAAA,YACR,YAAA,EAAc;AAAA,WACf,CAAA;AAAA,UACD,YAAY,qCAAqC;AAAA;AACnD,OACF;AAAA,MACA,EAAE,OAAO,IAAA;AAAK;AAChB;AAEJ","file":"testing.js","sourcesContent":["/**\n * Assistant streams in the CURRENT wire protocol (SSE v3), written as frames.\n *\n * Every test that replays an assistant turn builds its body here: the e2e specs (through\n * `page.route` or the staged stream in `e2e/staged-sse.ts`), the chat parity scenarios and any\n * consumer's own tests (`@arbidocs/sdk/testing`). Bodies written out by hand rot silently the\n * moment the protocol moves: the client ignores frames it no longer knows, renders an empty trace,\n * and the test fails on a timeout that says nothing about why. That is what happened to\n * `arbi.agent_step`, retired by SSE protocol v3 (#2079). With the frames in one place the next\n * protocol change is one edit.\n *\n * ## The protocol, as clients consume it\n *\n * - `arbi.user_message` — the user's own message, stored. There is no optimistic insert on send:\n * a body without it renders the conversation with the prompt MISSING.\n * - `response.created` — carries `response.id`, the assistant message's external id. This creates\n * the assistant row (`streamSSE` maps it to `onStreamStart`).\n * - `response.output_item.done` — one settled Responses output item. Only these build the trace:\n * * `function_call` → a tool step,\n * * `reasoning` → a lifecycle step (goal / planning / goal check / interjection …),\n * * `message` → body text, and a trace row ONLY when it declares `arbi.step` (the answer\n * does; narration doesn't).\n * Display metadata rides under `item.arbi`; nesting is by `arbi.parent_id`, which names a parent\n * ITEM ID (the client derives the display index itself).\n * - `response.output_text.delta` — streams body text, keyed by `item_id`.\n * - `response.completed` — ends the stream and carries the authoritative final message metadata.\n *\n * Step rows render as `agent-step-{index}`, where index is assigned by the client in first-seen\n * order starting at 1 — so the Nth distinct item id is `agent-step-N`.\n */\n\nimport type {\n ArtifactEvent,\n MailDraftSSEEvent,\n ProbeAnswerEvent,\n TokenBudgetContext,\n UserInputRequestEvent,\n} from '../sse-types.js'\n\n/** ARBI's trace extension on an output item (`ArbiItemMeta`). */\nexport type Arbi = Record<string, unknown>\n\n/** One Responses output item. */\nexport type Item = Record<string, unknown>\n\n/** One `event:`/`data:` frame. */\nexport function frame(event: string, data: object): string {\n return `event: ${event}\\ndata: ${JSON.stringify(data)}\\n\\n`\n}\n\n/** Frames are stamped now unless the caller fixes the time (`at`), as golden scenarios do. */\nconst isoAt = (at?: string) => at ?? new Date().toISOString()\nconst epochAt = (at?: string) => Math.floor(Date.parse(isoAt(at)) / 1000)\n\n/** A tool call — the workhorse trace row. `arbi.detail[0].tool` names the tool. */\nexport function toolItem(id: string, name: string, arbi: Arbi = {}): Item {\n return {\n type: 'function_call',\n id,\n call_id: id,\n name,\n arguments: '{}',\n status: 'completed',\n arbi: { detail: [{ tool: name }], ...arbi },\n }\n}\n\n/**\n * A lifecycle step (goal, plan, goal check, interjection, skill ack). `arbi.step` declares which —\n * the backend states it rather than the client sniffing labels. `summary` is the item's extended\n * text (a plan's checklist, an interjection's message), which the client surfaces as the step's\n * content.\n */\nexport function reasoningItem(id: string, arbi: Arbi = {}, summary?: string): Item {\n return {\n type: 'reasoning',\n id,\n status: 'completed',\n summary: summary ? [{ type: 'output_text', text: summary, annotations: [] }] : [],\n arbi,\n }\n}\n\n/**\n * The answer. A `message` item that declares `step: \"answering\"` — so it is both the body text AND\n * the closing trace row that carries the answering model and that call's token cost.\n */\nexport function answerItem(id: string, text: string, arbi: Arbi = {}): Item {\n return {\n type: 'message',\n id,\n status: 'completed',\n role: 'assistant',\n content: [{ type: 'output_text', text, annotations: [] }],\n arbi: { label: 'Answered', step: 'answering', ...arbi },\n }\n}\n\n/** A working note the server settles as Narration: it leaves the body and lives on in the trace. */\nexport function narrationItem(id: string, text: string): Item {\n return {\n type: 'message',\n id,\n status: 'completed',\n role: 'assistant',\n content: [{ type: 'output_text', text, annotations: [] }],\n arbi: { label: 'Narration' },\n }\n}\n\nexport interface UserMessageFrameOptions {\n content: string\n conversationId: string\n externalId?: string\n /** `queued` for a follow-up the server holds behind a running turn. */\n status?: 'completed' | 'queued'\n parentMessageId?: string | null\n createdBy?: string\n /** ISO time the server stored it (default now). */\n at?: string\n}\n\n/** The user message as the server stored it (the body of `arbi.user_message`). */\nexport function userMessage(opts: UserMessageFrameOptions) {\n return {\n type: 'user_message',\n role: 'user',\n content: opts.content,\n shared: false,\n tokens: 0,\n status: opts.status ?? 'completed',\n external_id: opts.externalId ?? 'msg-e2e-user',\n created_at: isoAt(opts.at),\n created_by_ext_id: opts.createdBy ?? 'usr-e2e',\n conversation_ext_id: opts.conversationId,\n ...(opts.parentMessageId !== undefined ? { parent_message_ext_id: opts.parentMessageId } : {}),\n }\n}\n\n/**\n * The `arbi.user_message` echo — the user's own message coming back from the backend. NOT\n * optional dressing: clients add the user row only from this event.\n */\nexport function userMessageFrame(opts: UserMessageFrameOptions): string {\n return frame('arbi.user_message', userMessage(opts))\n}\n\n/** A follow-up the server accepted while a turn runs (`arbi.message_queued`). */\nexport function messageQueuedFrame(opts: {\n responseId: string\n input: string\n previousResponseId?: string | null\n user: UserMessageFrameOptions\n}): string {\n return frame('arbi.message_queued', {\n type: 'arbi.message_queued',\n response_id: opts.responseId,\n input: opts.input,\n queue_action: 'created',\n previous_response_id: opts.previousResponseId ?? null,\n user_message_id: opts.user.externalId ?? 'msg-e2e-user',\n user_message: userMessage({ ...opts.user, status: opts.user.status ?? 'queued' }),\n })\n}\n\n/** `response.created`: the assistant message exists on the server under `id`. */\nexport function responseCreatedFrame(id: string, t?: number, at?: string): string {\n return frame('response.created', {\n type: 'response.created',\n sequence_number: 1,\n ...(t != null ? { t } : {}),\n response: {\n id,\n object: 'response',\n status: 'in_progress',\n created_at: epochAt(at),\n model: 'e2e-mock',\n output: [],\n },\n })\n}\n\n/** Body text streaming into message item `itemId`. */\nexport function textDeltaFrame(itemId: string, delta: string): string {\n return frame('response.output_text.delta', {\n type: 'response.output_text.delta',\n item_id: itemId,\n output_index: 0,\n content_index: 0,\n delta,\n })\n}\n\n/** One settled output item (`response.output_item.done`). */\nexport function itemDoneFrame(item: Item, opts: { index?: number; t?: number } = {}): string {\n return frame('response.output_item.done', {\n type: 'response.output_item.done',\n sequence_number: (opts.index ?? 0) + 2,\n output_index: opts.index ?? 0,\n item,\n ...(opts.t != null ? { t: opts.t } : {}),\n })\n}\n\nexport interface CompletedFrameOptions {\n /** External id of the assistant message (`response.id`). */\n assistantId: string\n conversationId: string\n /** The authoritative answer. */\n content: string\n /** Stored tools of the answer (citations, trace…), as `message_metadata.tools`. */\n tools?: Record<string, unknown>\n /** Backend-suggested follow-up (SUGGESTED_QUERIES). */\n suggestedQuery?: string\n /** The per-turn token budget snapshot. */\n context?: TokenBudgetContext\n t?: number\n status?: 'completed' | 'failed'\n /** ISO time the answer was stored (default now). */\n at?: string\n}\n\n/** `response.completed`: ends the turn and carries the stored answer. */\nexport function completedFrame(opts: CompletedFrameOptions): string {\n return frame('response.completed', {\n type: 'response.completed',\n sequence_number: 99,\n ...(opts.t != null ? { t: opts.t } : {}),\n ...(opts.context ? { context: opts.context } : {}),\n response: {\n id: opts.assistantId,\n object: 'response',\n status: 'completed',\n created_at: epochAt(opts.at),\n model: 'e2e-mock',\n output: [],\n usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },\n metadata: {\n type: 'message_metadata',\n external_id: opts.assistantId,\n role: 'assistant',\n content: opts.content,\n conversation_ext_id: opts.conversationId,\n created_at: isoAt(opts.at),\n created_by_ext_id: 'usr-e2e',\n shared: false,\n tokens: 0,\n status: opts.status ?? 'completed',\n ...(opts.tools ? { tools: opts.tools } : {}),\n ...(opts.suggestedQuery ? { suggested_query: opts.suggestedQuery } : {}),\n },\n },\n })\n}\n\n/** `response.failed`: the server failed the answer. */\nexport function failedFrame(message: string): string {\n return frame('response.failed', {\n type: 'response.failed',\n sequence_number: 99,\n response: { id: 'failed', object: 'response', status: 'failed', error: { message } },\n })\n}\n\n/** `arbi.error`, e.g. a mid-stream `QUOTA_EXCEEDED`. */\nexport function arbiErrorFrame(opts: {\n code: string\n message: string\n spend?: number\n budget?: number\n projectExtId?: string\n}): string {\n return frame('arbi.error', {\n type: 'arbi.error',\n code: opts.code,\n message: opts.message,\n ...(opts.spend != null ? { spend: opts.spend } : {}),\n ...(opts.budget != null ? { budget: opts.budget } : {}),\n ...(opts.projectExtId ? { project_ext_id: opts.projectExtId } : {}),\n })\n}\n\n/** `arbi.artifact`: a document the assistant is writing (or has written). */\nexport function artifactFrame(event: Omit<ArtifactEvent, 'type'>): string {\n return frame('arbi.artifact', { type: 'arbi.artifact', ...event })\n}\n\n/** `arbi.mail_draft`: the assistant saved an email draft. */\nexport function mailDraftFrame(event: Omit<MailDraftSSEEvent, 'type'>): string {\n return frame('arbi.mail_draft', { type: 'arbi.mail_draft', ...event })\n}\n\n/** `arbi.deferred_interjection`: steering that arrived after the agent committed to its answer. */\nexport function deferredInterjectionFrame(message: string): string {\n return frame('arbi.deferred_interjection', { type: 'arbi.deferred_interjection', message })\n}\n\n/** `arbi.agent_control_state`: the server confirmed a pause or resume. */\nexport function agentControlStateFrame(state: 'paused' | 'running'): string {\n return frame('arbi.agent_control_state', { type: 'arbi.agent_control_state', state })\n}\n\n/** `arbi.probe_answer`: an out-of-band status answer. */\nexport function probeAnswerFrame(event: Omit<ProbeAnswerEvent, 'type'>): string {\n return frame('arbi.probe_answer', { type: 'arbi.probe_answer', ...event })\n}\n\n/** `arbi.user_input_request`: the agent asks the person a question mid-turn. */\nexport function userInputRequestFrame(event: Omit<UserInputRequestEvent, 'type'>): string {\n return frame('arbi.user_input_request', { type: 'arbi.user_input_request', ...event })\n}\n\nexport interface StreamOptions {\n /** External id of the assistant message (`response.id`). */\n assistantId: string\n /** Trace items, in emission order. Their order fixes the `agent-step-N` numbering. */\n items: Item[]\n /** Conversation the message belongs to — required if `userContent` is set. */\n conversationId?: string\n /** When set, the stream opens with an `arbi.user_message` echo (the user row). */\n userContent?: string\n /** External id for that user row. */\n userMessageId?: string\n /** Final answer text, set authoritatively by `response.completed`. */\n answer?: string\n /** Seconds-since-start for the first item; each later item advances by this much. */\n step?: number\n}\n\n/**\n * A complete assistant stream. Each item is stamped with an increasing `t` (seconds since stream\n * start) because the trace derives step durations from the gap between consecutive stamps.\n */\nexport function agentStream({\n assistantId,\n items,\n conversationId = 'cnv-e2e',\n userContent,\n userMessageId = 'msg-e2e-user',\n answer = '',\n step = 1,\n}: StreamOptions): string {\n let body = ''\n if (userContent) {\n body += userMessageFrame({ content: userContent, conversationId, externalId: userMessageId })\n }\n body += responseCreatedFrame(assistantId)\n items.forEach((item, i) => {\n body += itemDoneFrame(item, { index: i, t: Number(((i + 1) * step).toFixed(2)) })\n })\n body += completedFrame({\n assistantId,\n conversationId,\n content: answer,\n t: Number(((items.length + 2) * step).toFixed(2)),\n })\n return body\n}\n","/**\n * A `fetch` that answers the assistant endpoints with streams a test owns.\n *\n * The client under test is the real one: its request builder, the SDK's SSE parser and whatever\n * engine sits on top. Only the network is replaced. Each assistant request opens a staged stream\n * the test feeds frame by frame (`push`), ends (`close`), cuts (`drop`) or that the client aborts;\n * so a turn can be paused anywhere and inspected, exactly as `e2e/staged-sse.ts` does in the\n * browser. A test can also queue a plain HTTP reply (a 402, a 409) for the next request.\n *\n * Every request is recorded with its parsed JSON body, so request bodies can be asserted (or\n * snapshotted) as well as what the client did with the answer.\n */\n\n/** One request the client made. */\nexport interface RecordedRequest {\n method: string\n /** The path and query, without origin. */\n path: string\n body: unknown\n}\n\n/** A stream the test feeds. */\nexport interface StagedStream {\n /** The request that opened it. */\n readonly request: RecordedRequest\n /** Feed one or more SSE frames. */\n push(...frames: string[]): void\n /** End the stream normally. */\n close(): void\n /** Cut the connection mid-stream (the client sees a network error). */\n drop(error?: Error): void\n /** Whether the client aborted it, or it was closed or dropped. */\n readonly ended: boolean\n}\n\n/** A plain HTTP answer for the next matching request. */\nexport interface HttpReply {\n status: number\n body?: unknown\n}\n\nexport interface SseFake {\n /** Install as `globalThis.fetch` (or pass to the client). */\n fetch: typeof fetch\n /** Every request, in order. */\n readonly requests: RecordedRequest[]\n /** Streams opened by assistant requests (queries and run attaches), in order. */\n readonly streams: StagedStream[]\n /** The newest stream that has not ended. */\n current(): StagedStream | undefined\n /** Answer the next `POST /v1/responses` with a plain HTTP reply instead of a stream. */\n replyNextQuery(reply: HttpReply): void\n /** Answer the next attach (`GET /v1/assistant/run/{id}/stream`) with a stream (default 404). */\n streamNextAttach(): void\n /** Answer other requests (default: 200 `{}`), e.g. cancel and interject. */\n setFallback(handler: (request: RecordedRequest) => HttpReply): void\n}\n\nconst QUERY_PATH = /\\/v1\\/responses$/\nconst ATTACH_PATH = /\\/v1\\/assistant\\/run\\/[^/]+\\/stream$/\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted.')\n error.name = 'AbortError'\n return error\n}\n\nfunction json(reply: HttpReply): Response {\n return new Response(reply.body === undefined ? null : JSON.stringify(reply.body), {\n status: reply.status,\n headers: { 'content-type': 'application/json' },\n })\n}\n\n/** A request body as data: JSON parsed, and no body (absent or empty) as null. */\nfunction parseBody(body: unknown): unknown {\n if (body === '' || body === undefined) return null\n if (typeof body !== 'string') return body\n try {\n return JSON.parse(body)\n } catch {\n return body\n }\n}\n\nexport function createSseFake(): SseFake {\n const requests: RecordedRequest[] = []\n const streams: StagedStream[] = []\n const queryReplies: HttpReply[] = []\n let attachStreams = 0\n let fallback: (request: RecordedRequest) => HttpReply = () => ({ status: 200, body: {} })\n const encoder = new TextEncoder()\n\n const openStream = (request: RecordedRequest, signal?: AbortSignal | null): Response => {\n let controller!: ReadableStreamDefaultController<Uint8Array>\n let ended = false\n const end = (fn: () => void) => {\n if (ended) return\n ended = true\n try {\n fn()\n } catch {\n /* already closed */\n }\n }\n const body = new ReadableStream<Uint8Array>({\n start(c) {\n controller = c\n },\n cancel() {\n ended = true\n },\n })\n const stream: StagedStream = {\n request,\n push: (...frames) => {\n if (ended) throw new Error(`stream for ${request.path} has ended`)\n for (const f of frames) controller.enqueue(encoder.encode(f))\n },\n close: () => end(() => controller.close()),\n drop: (error = new TypeError('network error')) => end(() => controller.error(error)),\n get ended() {\n return ended\n },\n }\n signal?.addEventListener('abort', () => end(() => controller.error(abortError())))\n streams.push(stream)\n return new Response(body, {\n status: 200,\n headers: { 'content-type': 'text/event-stream; charset=utf-8' },\n })\n }\n\n const fakeFetch = async (\n input: string | URL | Request,\n init?: RequestInit\n ): Promise<Response> => {\n const request = typeof input === 'object' && 'url' in input ? input : null\n const url = request ? request.url : String(input)\n const method = (init?.method ?? request?.method ?? 'GET').toUpperCase()\n const signal = init?.signal ?? request?.signal\n const rawBody =\n init?.body ?? (request && method !== 'GET' ? await request.clone().text() : null)\n const parsed = new URL(url, 'http://localhost')\n const recorded: RecordedRequest = {\n method,\n path: parsed.pathname + parsed.search,\n body: parseBody(rawBody),\n }\n requests.push(recorded)\n if (signal?.aborted) throw abortError()\n\n if (method === 'POST' && QUERY_PATH.test(parsed.pathname)) {\n const reply = queryReplies.shift()\n return reply ? json(reply) : openStream(recorded, signal)\n }\n if (method === 'GET' && ATTACH_PATH.test(parsed.pathname)) {\n if (attachStreams === 0) return json({ status: 404, body: { detail: 'not active' } })\n attachStreams -= 1\n return openStream(recorded, signal)\n }\n return json(fallback(recorded))\n }\n\n return {\n fetch: fakeFetch as typeof fetch,\n requests,\n streams,\n current: () => [...streams].reverse().find((s) => !s.ended),\n replyNextQuery: (reply) => {\n queryReplies.push(reply)\n },\n streamNextAttach: () => {\n attachStreams += 1\n },\n setFallback: (handler) => {\n fallback = handler\n },\n }\n}\n","/**\n * Chat parity scenarios: assistant turns as the server streams them, plus what the person does\n * while they run.\n *\n * Each scenario is data, so any chat engine can replay it: the runner sends the prompts through\n * the engine under test, feeds the frames through `createSseFake`, presses Stop when told, and\n * snapshots what the engine left behind (the thread, the list, the session) next to the\n * scenario's golden file. While the engine moves between layers (#1720 A1–A9) the runner changes\n * and the golden files must not.\n */\n\nimport type { HttpReply } from './sse-fake.js'\nimport {\n agentControlStateFrame,\n answerItem,\n arbiErrorFrame,\n artifactFrame,\n completedFrame,\n deferredInterjectionFrame,\n failedFrame,\n itemDoneFrame,\n mailDraftFrame,\n messageQueuedFrame,\n narrationItem,\n probeAnswerFrame,\n reasoningItem,\n responseCreatedFrame,\n textDeltaFrame,\n toolItem,\n userInputRequestFrame,\n userMessageFrame,\n} from './sse-frames.js'\n\n/** One thing that happens during a scenario, in order. */\nexport type ChatStep =\n /** The person types `send` into the composer and sends it. */\n | { send: string }\n /** The server sends frames on stream `stream` (index in opening order; default: the newest open). */\n | { push: string[]; stream?: number }\n /** The server ends a stream normally. */\n | { close: true; stream?: number }\n /** The connection drops mid-stream. */\n | { drop: true; stream?: number }\n /** The person presses Stop. */\n | { stop: true }\n /** The next assistant request gets a plain HTTP reply. */\n | { replyNextQuery: HttpReply }\n /** Time passes (ms), on the fake clock. */\n | { wait: number }\n /** Record the engine's state under this label (the final state is always recorded). */\n | { snapshot: string }\n\n/** A message already in the thread when the scenario starts. */\nexport interface SeedMessage {\n id: string\n role: 'user' | 'assistant'\n content: string\n parent: string | null\n}\n\nexport interface ChatScenario {\n name: string\n description: string\n /** Start in this existing conversation; otherwise a new chat. */\n seed?: { conversationId: string; history: SeedMessage[] }\n /** Documents and facts added to the chat before the first send. */\n context?: { documents?: string[]; facts?: string[] }\n steps: ChatStep[]\n}\n\n/** Every frame is stamped with this time, so the golden files are reproducible. */\nconst AT = '2026-01-01T00:00:00.000Z'\n\nconst SEED_CONVERSATION = 'cnv-seeded'\nconst seededThread = {\n conversationId: SEED_CONVERSATION,\n history: [\n { id: 'msg-u0', role: 'user', content: 'Earlier question', parent: null },\n { id: 'msg-a0', role: 'assistant', content: 'Earlier answer', parent: 'msg-u0' },\n ] satisfies SeedMessage[],\n}\n\nconst user = (content: string, externalId: string, parent: string | null = 'msg-a0') =>\n userMessageFrame({\n content,\n conversationId: SEED_CONVERSATION,\n externalId,\n parentMessageId: parent,\n at: AT,\n })\n\nconst created = (assistantId: string, t?: number) => responseCreatedFrame(assistantId, t, AT)\n\nconst done = (assistantId: string, content: string, extra: Record<string, unknown> = {}) =>\n completedFrame({ assistantId, conversationId: SEED_CONVERSATION, content, at: AT, ...extra })\n\nconst CONTEXT = {\n context_window: 200000,\n budget: 180000,\n system: 2000,\n history: 300,\n compaction: 0,\n retrieval: 1200,\n query: 40,\n output: 500,\n total_input: 3540,\n truncated: false,\n reasoning: 0,\n total_output: 500,\n}\n\nexport const CHAT_SCENARIOS: ChatScenario[] = [\n {\n name: 'plain-answer',\n description:\n 'A new chat with a document and a fact: the first turn moves \"new\" to the server id and the answer streams, then resolves with its context and a suggested follow-up.',\n context: { documents: ['doc-1'], facts: ['fact-1'] },\n steps: [\n { send: 'What does the contract say about termination?' },\n {\n push: [\n userMessageFrame({\n content: 'What does the contract say about termination?',\n conversationId: 'cnv-new-1',\n externalId: 'msg-u1',\n parentMessageId: null,\n at: AT,\n }),\n created('msg-a1', 0.2),\n textDeltaFrame('it-answer', 'Either party may '),\n ],\n },\n { snapshot: 'streaming' },\n {\n push: [\n textDeltaFrame('it-answer', 'terminate on 30 days notice.'),\n itemDoneFrame(answerItem('it-answer', 'Either party may terminate on 30 days notice.'), {\n t: 1.4,\n }),\n completedFrame({\n assistantId: 'msg-a1',\n conversationId: 'cnv-new-1',\n content: 'Either party may terminate on 30 days notice.',\n suggestedQuery: 'What notice period applies?',\n context: CONTEXT,\n t: 1.6,\n at: AT,\n }),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'agent-steps',\n description:\n 'A follow-up in an existing thread that works through tools: steps fold into the trace, narration leaves the body, and the answer resolves after the narration dwell.',\n seed: seededThread,\n steps: [\n { send: 'Find the liability cap' },\n {\n push: [\n user('Find the liability cap', 'msg-u1'),\n created('msg-a1', 0.1),\n itemDoneFrame(reasoningItem('rs-1', { step: 'goal', label: 'Thinking…' }, 'Find it'), {\n index: 0,\n t: 0.5,\n }),\n textDeltaFrame('it-n1', 'Let me search the documents.'),\n itemDoneFrame(toolItem('fc-2', 'search_inside_documents', { label: 'Searching' }), {\n index: 1,\n t: 1.5,\n }),\n textDeltaFrame('it-n2', 'Now reading the clause. '),\n itemDoneFrame(narrationItem('it-n2', 'Now reading the clause. '), { index: 2, t: 2 }),\n itemDoneFrame(toolItem('fc-3', 'get_document_passages', { label: 'Reading' }), {\n index: 3,\n t: 2.5,\n }),\n textDeltaFrame('it-answer', 'The cap is £1m.'),\n itemDoneFrame(answerItem('it-answer', 'The cap is £1m.'), { index: 4, t: 3 }),\n ],\n },\n { snapshot: 'before-completed' },\n { push: [done('msg-a1', 'The cap is £1m.', { t: 3.2 })] },\n { close: true },\n { wait: 5000 },\n ],\n },\n {\n name: 'subagents',\n description: 'A run_skill sub-agent whose relayed child steps nest under the parent step.',\n seed: seededThread,\n steps: [\n { send: 'Run the research-helper skill' },\n {\n push: [\n user('Run the research-helper skill', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(\n toolItem('fc-1', 'run_skill', {\n label: 'Skill',\n focus: 'Invoking the research-helper skill',\n detail: [{ tool: 'run_skill', summary: 'research-helper' }],\n }),\n { index: 0, t: 1 }\n ),\n itemDoneFrame(\n toolItem('fc-2', 'search_inside_documents', {\n label: 'Searching documents',\n parent_id: 'fc-1',\n }),\n { index: 1, t: 2 }\n ),\n itemDoneFrame(\n toolItem('fc-3', 'goal_progress', { label: 'Goal check', parent_id: 'fc-1' }),\n { index: 2, t: 3 }\n ),\n textDeltaFrame('msg-4', 'The skill found the clauses.'),\n itemDoneFrame(answerItem('msg-4', 'The skill found the clauses.'), { index: 3, t: 4 }),\n done('msg-a1', 'The skill found the clauses.', { t: 4.2 }),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'interjection',\n description:\n 'A message sent while the agent works is queued, steered into the running turn at the next tool boundary, and settled by the interjection step.',\n seed: seededThread,\n steps: [\n { send: 'Research the company financials' },\n {\n push: [\n user('Research the company financials', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(toolItem('fc-1', 'web_search', { label: 'Searching the web' }), {\n index: 0,\n t: 1,\n }),\n ],\n },\n { send: 'Focus on 2026' },\n { snapshot: 'queued' },\n {\n stream: 1,\n push: [\n messageQueuedFrame({\n responseId: 'resp-steer',\n input: 'Focus on 2026',\n previousResponseId: 'msg-a1',\n user: {\n content: 'Focus on 2026',\n conversationId: SEED_CONVERSATION,\n externalId: 'msg-u2',\n parentMessageId: 'msg-a1',\n at: AT,\n },\n }),\n ],\n },\n { close: true, stream: 1 },\n { snapshot: 'acknowledged' },\n {\n stream: 0,\n push: [\n itemDoneFrame(\n reasoningItem('rs-2', { step: 'interjection', label: 'Your message' }, 'Focus on 2026'),\n { index: 1, t: 2 }\n ),\n textDeltaFrame('msg-3', 'Focusing on 2026.'),\n itemDoneFrame(answerItem('msg-3', 'Focusing on 2026.'), { index: 2, t: 3 }),\n done('msg-a1', 'Focusing on 2026.', { t: 3.1 }),\n ],\n },\n { close: true, stream: 0 },\n { wait: 1000 },\n ],\n },\n {\n name: 'queued-followup',\n description:\n 'A follow-up the server queues behind the running turn: shown in the agent bar, moved to the next turn when it starts, and answered in its own turn.',\n seed: seededThread,\n steps: [\n { send: 'Summarise the report' },\n {\n push: [\n user('Summarise the report', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'The report covers'),\n ],\n },\n { send: 'Then list the risks' },\n {\n stream: 1,\n push: [\n messageQueuedFrame({\n responseId: 'resp-queued',\n input: 'Then list the risks',\n previousResponseId: 'msg-a1',\n user: {\n content: 'Then list the risks',\n conversationId: SEED_CONVERSATION,\n externalId: 'msg-u2',\n parentMessageId: 'msg-a1',\n at: AT,\n },\n }),\n ],\n },\n { snapshot: 'queued' },\n {\n stream: 0,\n push: [\n textDeltaFrame('msg-x', ' three areas.'),\n itemDoneFrame(answerItem('msg-x', 'The report covers three areas.'), { t: 2 }),\n done('msg-a1', 'The report covers three areas.', { t: 2.1 }),\n ],\n },\n { close: true, stream: 0 },\n {\n stream: 1,\n push: [user('Then list the risks', 'msg-u2', 'msg-a1'), created('msg-a2')],\n },\n { snapshot: 'second-turn' },\n { wait: 1000 },\n {\n stream: 1,\n push: [\n textDeltaFrame('msg-y', 'Risks: delay and cost.'),\n itemDoneFrame(answerItem('msg-y', 'Risks: delay and cost.'), { t: 1 }),\n done('msg-a2', 'Risks: delay and cost.', { t: 1.1 }),\n ],\n },\n { close: true, stream: 1 },\n ],\n },\n {\n name: 'deferred-interjection',\n description:\n 'Steering that reached the agent after it committed to its answer is resubmitted as a new turn once the turn completes.',\n seed: seededThread,\n steps: [\n { send: 'Draft the summary' },\n {\n push: [\n user('Draft the summary', 'msg-u1'),\n created('msg-a1'),\n deferredInterjectionFrame('Also mention the dates'),\n textDeltaFrame('msg-x', 'Summary drafted.'),\n itemDoneFrame(answerItem('msg-x', 'Summary drafted.'), { t: 1 }),\n done('msg-a1', 'Summary drafted.', { t: 1.1 }),\n ],\n },\n { close: true, stream: 0 },\n { snapshot: 'resubmitted' },\n {\n stream: 1,\n push: [\n user('Also mention the dates', 'msg-u2', 'msg-a1'),\n created('msg-a2'),\n done('msg-a2', 'Dates: 1 May and 1 June.'),\n ],\n },\n { close: true, stream: 1 },\n ],\n },\n {\n name: 'agent-control',\n description:\n 'Pause, report and resume while the agent works: optimistic state, the server confirmation and the probe answer, cleared when the turn ends.',\n seed: seededThread,\n steps: [\n { send: 'Audit every contract' },\n {\n push: [\n user('Audit every contract', 'msg-u1'),\n created('msg-a1'),\n itemDoneFrame(toolItem('fc-1', 'search_inside_documents'), { t: 1 }),\n ],\n },\n { send: '/pause' },\n { snapshot: 'pausing' },\n { push: [agentControlStateFrame('paused')] },\n { send: '/report' },\n { push: [probeAnswerFrame({ question: '/report', answer: 'Two of five contracts read.' })] },\n { snapshot: 'paused-with-report' },\n { send: '/resume' },\n {\n push: [\n agentControlStateFrame('running'),\n userInputRequestFrame({\n question: 'Include expired contracts?',\n options: ['Yes', 'No'],\n timeout_seconds: 120,\n }),\n ],\n },\n { snapshot: 'asking' },\n { push: [done('msg-a1', 'Audit complete.')] },\n { close: true },\n ],\n },\n {\n name: 'stop',\n description:\n 'Stop cancels the run on the server first, then closes the stream; the stopped turn is never shown as failed.',\n seed: seededThread,\n steps: [\n { send: 'Write a long essay' },\n {\n push: [\n user('Write a long essay', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'Once upon a time'),\n ],\n },\n { stop: true },\n { wait: 100 },\n ],\n },\n {\n name: 'drop',\n description:\n 'The connection drops after the server stored the question: the turn is not failed, the thread is re-read and generation is held while it is.',\n seed: seededThread,\n steps: [\n { send: 'Explain clause 4' },\n {\n push: [\n user('Explain clause 4', 'msg-u1'),\n created('msg-a1'),\n textDeltaFrame('msg-x', 'Clause 4'),\n ],\n },\n { drop: true },\n { wait: 6000 },\n ],\n },\n {\n name: 'server-failed',\n description: 'The server fails the answer (`response.failed`): it is marked failed.',\n seed: seededThread,\n steps: [\n { send: 'Explain clause 5' },\n {\n push: [\n user('Explain clause 5', 'msg-u1'),\n created('msg-a1'),\n failedFrame('This answer stopped making progress.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'artifact',\n description:\n 'A streamed html artifact opens in the viewer, joins the chat documents and becomes the pinned document once complete.',\n seed: seededThread,\n steps: [\n { send: 'Make a landing page' },\n {\n push: [\n user('Make a landing page', 'msg-u1'),\n created('msg-a1'),\n artifactFrame({\n doc_ext_id: 'doc-art',\n title: 'Landing page',\n mode: 'html',\n content: '<h1>Hi',\n file_type: 'text/html',\n is_complete: false,\n version: 1,\n message_ext_id: 'msg-a1',\n }),\n ],\n },\n { snapshot: 'streaming-artifact' },\n {\n push: [\n artifactFrame({\n doc_ext_id: 'doc-art',\n title: 'Landing page',\n mode: 'html',\n content: '<h1>Hi</h1>',\n file_type: 'text/html',\n is_complete: true,\n version: 1,\n message_ext_id: 'msg-a1',\n }),\n done('msg-a1', 'I made the landing page.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'mail-draft',\n description: 'A mail draft the assistant saved opens the mail side beside the chat.',\n seed: seededThread,\n steps: [\n { send: 'Draft a reply to Sam' },\n {\n push: [\n user('Draft a reply to Sam', 'msg-u1'),\n created('msg-a1'),\n mailDraftFrame({ draft_id: 'draft-1', message_ext_id: 'msg-a1' }),\n done('msg-a1', 'The reply is drafted.'),\n ],\n },\n { close: true },\n ],\n },\n {\n name: 'quota-402',\n description:\n \"The project's AI usage is used up: the query is refused with a 402 and the quota modal opens.\",\n seed: seededThread,\n steps: [\n {\n replyNextQuery: {\n status: 402,\n body: {\n detail: {\n code: 'QUOTA_EXCEEDED',\n spend: 10,\n budget: 10,\n project_ext_id: 'prj-1',\n message: 'AI usage for this month is used up.',\n },\n },\n },\n },\n { send: 'Summarise everything' },\n ],\n },\n {\n name: 'quota-stream',\n description: 'The AI usage runs out mid-turn (`arbi.error` QUOTA_EXCEEDED).',\n seed: seededThread,\n steps: [\n { send: 'Summarise everything again' },\n {\n push: [\n user('Summarise everything again', 'msg-u1'),\n created('msg-a1'),\n arbiErrorFrame({\n code: 'QUOTA_EXCEEDED',\n message: 'AI usage for this month is used up.',\n spend: 10,\n budget: 10,\n projectExtId: 'prj-1',\n }),\n failedFrame('AI usage for this month is used up.'),\n ],\n },\n { close: true },\n ],\n },\n]\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/sdk",
3
- "version": "0.5.54",
3
+ "version": "0.5.56",
4
4
  "description": "Shared operations layer for ARBI — auth, config, SSE, WebSocket, and API operations",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -44,7 +44,7 @@
44
44
  "typecheck": "tsc --noEmit"
45
45
  },
46
46
  "dependencies": {
47
- "@arbidocs/client": "0.5.54",
47
+ "@arbidocs/client": "0.5.56",
48
48
  "jszip": "^3.10.1"
49
49
  },
50
50
  "devDependencies": {