@agent-native/core 0.66.6 → 0.66.7
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.
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +29 -4
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +2 -2
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +1 -1
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +3 -1
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
- package/dist/client/blocks/library/annotation-rail.js +32 -4
- package/dist/client/blocks/library/annotation-rail.js.map +1 -1
- package/dist/client/chat/runtime.d.ts.map +1 -1
- package/dist/client/chat/runtime.js +5 -2
- package/dist/client/chat/runtime.js.map +1 -1
- package/dist/client/error-format.d.ts +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +23 -2
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +3 -2
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +11 -0
- package/docs/content/messaging.md +24 -0
- package/docs/content/template-clips.md +13 -0
- package/package.json +1 -1
- package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-event-processor.js","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,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E,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,qEAAqE;QACvE,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB;QAAE,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACxE,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { ChatModelRunResult } from \"@assistant-ui/react\";\nimport type { ActionChatUIConfig } from \"../action-ui.js\";\nimport {\n LLM_MISSING_CREDENTIALS_ERROR_CODE,\n LLM_MISSING_CREDENTIALS_MESSAGE,\n} from \"../agent/engine/credential-errors.js\";\nimport type { AgentMcpAppPayload } from \"../mcp-client/app-result.js\";\nimport { formatChatErrorText, normalizeChatError } from \"./error-format.js\";\nimport { humanizeToolLabelText, runningToolLabel } from \"./tool-display.js\";\n\nexport type ContentPart =\n | { type: \"text\"; text: string }\n | {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n argsText: string;\n args: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n activity?: boolean;\n /**\n * Set when the server emitted an `approval_required` event for this tool\n * call (opt-in `needsApproval` actions). The action did NOT run; the UI\n * renders an Approve/Deny affordance. `approvalKey` is echoed back in\n * `approvedToolCalls` to approve, `dismissed` records a local Deny.\n */\n approval?: { approvalKey: string; dismissed?: boolean };\n /**\n * Structured metadata from the coding-tools executor side-channel.\n * Present only on code-agent tool calls from executors new enough to\n * emit it. The `toolKind` discriminant identifies the shape.\n */\n structuredMeta?: Record<string, unknown>;\n };\n\nexport interface SSEEvent {\n type: string;\n text?: string;\n tool?: string;\n /** Server-assigned call identifier emitted on tool_start / tool_done events. */\n id?: string;\n label?: string;\n input?: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n /** Stable key the client echoes back in `approvedToolCalls` to approve a\n * paused `needsApproval` tool call. Present on `approval_required` events. */\n approvalKey?: string;\n error?: string;\n seq?: number;\n agent?: string;\n status?: string;\n reason?: string;\n // Agent task fields\n taskId?: string;\n threadId?: string;\n description?: string;\n preview?: string;\n currentStep?: string;\n summary?: string;\n // Structured error metadata — Builder gateway sets these on quota/auth/setup\n // failures so the UI can render a CTA alongside the error text.\n errorCode?: string;\n upgradeUrl?: string;\n details?: string;\n recoverable?: boolean;\n maxIterations?: number;\n}\n\nexport type AgentAutoContinueReason =\n | \"run_timeout\"\n | \"loop_limit\"\n | \"no_progress\"\n | \"stream_ended\"\n | \"stale_run\";\n\nexport type AgentActivityTrailEntry = { label: string; tool?: string };\n\nconst INTERRUPTED_TOOL_RESULT =\n \"Interrupted before this tool returned a result.\";\n\nexport function settleInterruptedToolCalls(\n content: ContentPart[],\n result = INTERRUPTED_TOOL_RESULT,\n): boolean {\n let changed = false;\n for (const part of content) {\n if (\n part.type === \"tool-call\" &&\n part.result === undefined &&\n part.activity !== true\n ) {\n part.result = result;\n changed = true;\n }\n }\n return changed;\n}\n\nexport class AgentAutoContinueSignal extends Error {\n readonly reason: AgentAutoContinueReason;\n readonly maxIterations?: number;\n readonly activityTrail: AgentActivityTrailEntry[];\n\n constructor(options: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n activityTrail?: AgentActivityTrailEntry[];\n }) {\n super(`Agent run needs automatic continuation: ${options.reason}`);\n this.name = \"AgentAutoContinueSignal\";\n this.reason = options.reason;\n this.maxIterations = options.maxIterations;\n this.activityTrail = options.activityTrail ?? [];\n }\n}\n\nexport const SSE_NO_PROGRESS_TIMEOUT_MS = 75_000;\n\ntype ActivityTrailEntry = AgentActivityTrailEntry;\n\nfunction findPendingToolCallIndex(\n content: ContentPart[],\n toolName: string,\n toolCallId?: string,\n): number {\n // Prefer id-based match when the event carries an id: parallel same-name\n // calls can be in flight simultaneously, and name-only matching would\n // attach a result to the wrong call.\n if (toolCallId) {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolCallId === toolCallId &&\n part.result === undefined\n ) {\n return i;\n }\n }\n // Fall through to name-matching: the start event may have arrived before\n // the server started emitting ids (e.g. older server build), so the\n // stored toolCallId is the locally-generated \"tc_N\" value rather than the\n // server-assigned one. In that case match by name as a fallback.\n }\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === toolName &&\n part.result === undefined\n ) {\n return i;\n }\n }\n return -1;\n}\n\nfunction appendActivityTrail(\n trail: ActivityTrailEntry[],\n next: ActivityTrailEntry,\n) {\n const label = next.label.trim();\n if (!label) return;\n const tool = next.tool?.trim();\n const last = trail[trail.length - 1];\n if (last?.label === label && last.tool === tool) return;\n trail.push({ label, ...(tool ? { tool } : {}) });\n if (trail.length > 8) {\n trail.splice(0, trail.length - 8);\n }\n}\n\nasync function readChunkWithProgressTimeout(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n lastMeaningfulEventAt: number,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n const elapsed = Date.now() - lastMeaningfulEventAt;\n const timeoutMs = Math.max(0, SSE_NO_PROGRESS_TIMEOUT_MS - elapsed);\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const readPromise = reader.read();\n // If the timeout wins and cancellation causes the pending read to reject,\n // swallow that rejection because the generator is already recovering.\n void readPromise.catch(() => {});\n\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timeoutId = setTimeout(() => resolve(\"timeout\"), timeoutMs);\n });\n const result = await Promise.race([readPromise, timeoutPromise]);\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (result === \"timeout\") {\n await reader.cancel(\"no_progress\").catch(() => {});\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n return result;\n}\n\nfunction isAutoRecoverableError(ev: SSEEvent, errMsg: string): boolean {\n const code = String(ev.errorCode ?? \"\").toLowerCase();\n const msg = errMsg.toLowerCase();\n\n if (\n code === \"context_length_exceeded\" ||\n code === \"input_too_long\" ||\n code.startsWith(\"credits-limit\") ||\n code === \"billing_error\" ||\n code === \"unauthorized\" ||\n code === \"authentication_error\" ||\n code === \"permission_error\" ||\n code === \"http_401\" ||\n code === \"http_403\" ||\n code === \"rate_limit_exceeded\" ||\n code === \"gateway_not_enabled\" ||\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n code === \"invalid_request_error\" ||\n code === \"request_too_large\" ||\n code === \"not_found_error\" ||\n code === \"model_not_found\" ||\n // `builder_gateway_error` is the no-detail fallback the Builder engine\n // emits when the gateway returns `{type:\"stop\",reason:\"error\"}` with no\n // explanation — almost always the upstream provider giving up (model\n // quota hit, account misconfiguration, opaque downstream failure). The\n // production-agent already retries this synchronously up to MAX_RETRIES\n // before the error escapes to the SSE stream, so by the time the client\n // sees it, retrying again with another POST /agent-chat will hit the\n // same wall. This used to send the chat into a 32-continuation runaway\n // (each turn cleared+regenerated visible content) for users hitting a\n // misbehaving Builder route. Surface the error instead.\n code === \"builder_gateway_error\"\n ) {\n return false;\n }\n\n if (\n code === \"builder_gateway_network_error\" ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\"\n ) {\n return true;\n }\n\n if (ev.recoverable === true) return true;\n\n if (msg.includes(\"daily gateway request cap\")) return false;\n\n // \"gateway error\" intentionally absent — that's the no-detail Builder\n // gateway fallback and the production-agent already retries it\n // synchronously up to MAX_RETRIES before the error escapes here. Treating\n // it as auto-recoverable on top of that produced a 32-continuation\n // runaway in production for users hitting a misbehaving Builder route.\n // (See `code === \"builder_gateway_error\"` in the not-recoverable list.)\n return (\n msg.includes(\"overloaded\") ||\n msg.includes(\"rate_limit\") ||\n msg.includes(\"too many requests\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"connection reset\") ||\n msg.includes(\"connection\") ||\n msg.includes(\"network\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\nfunction isMissingCredentialText(message: string, errorCode?: string): boolean {\n const code = String(errorCode ?? \"\").toLowerCase();\n const msg = message.toLowerCase();\n return (\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n msg.includes(\"apikey\") ||\n msg.includes(\"authtoken\") ||\n msg.includes(\"anthropic_api_key\") ||\n msg.includes(\"missing_api_key\") ||\n msg.includes(\"missing api key\") ||\n msg.includes(\"missing credentials\") ||\n msg.includes(\"no llm provider\") ||\n msg.includes(\"llm provider is connected\")\n );\n}\n\nfunction dispatchActivityClear(tabId: string | undefined) {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity-clear\", {\n detail: { tabId },\n }),\n );\n}\n\n/**\n * Process a single SSE event and update the content accumulator.\n * Returns: \"continue\" to keep going, \"done\" to stop, or a yield-ready result.\n */\nexport function processEvent(\n ev: SSEEvent,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n): {\n action:\n | \"continue\"\n | \"done\"\n | \"yield\"\n | \"error\"\n | \"missing_api_key\"\n | \"auto_continue\";\n result?: ChatModelRunResult;\n autoContinue?: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n };\n} {\n if (ev.type === \"clear\") {\n // Server is retrying — discard partial text/tool output from the failed attempt\n content.length = 0;\n dispatchActivityClear(tabId);\n return { action: \"continue\" };\n }\n\n if (ev.type === \"text\") {\n const lastPart = content[content.length - 1];\n if (lastPart && lastPart.type === \"text\") {\n lastPart.text += ev.text ?? \"\";\n } else {\n content.push({ type: \"text\", text: ev.text ?? \"\" });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n const label = humanizeToolLabelText(ev.label ?? \"Working\", tool);\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label,\n ...(tool ? { tool } : {}),\n tabId,\n },\n }),\n );\n }\n if (!tool) return { action: \"continue\" };\n\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool);\n if (pendingToolCallIndex === -1) {\n content.push({\n type: \"tool-call\",\n toolCallId: `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: \"\",\n args: {},\n activity: true,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_start\") {\n const args = (ev.input ?? {}) as Record<string, string>;\n const tool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-start\", {\n detail: { tool, input: args },\n }),\n );\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label: runningToolLabel(tool),\n tool,\n tabId,\n },\n }),\n );\n }\n // Pass the server-assigned id so we upgrade the pending activity card\n // using id-match when available (parallel same-name calls stay separate).\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool, ev.id);\n const pendingToolCall =\n pendingToolCallIndex >= 0 ? content[pendingToolCallIndex] : undefined;\n if (\n pendingToolCall &&\n pendingToolCall.type === \"tool-call\" &&\n pendingToolCall.activity === true &&\n pendingToolCall.argsText === \"\" &&\n Object.keys(pendingToolCall.args).length === 0\n ) {\n // Upgrade the pending activity card in place. Prefer the server-assigned\n // id so the subsequent tool_done can match it precisely (parallel\n // same-name calls each carry their own id). Fall back to the\n // locally-generated id already on the card.\n content[pendingToolCallIndex] = {\n type: \"tool-call\",\n toolCallId: ev.id ?? pendingToolCall.toolCallId,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n };\n } else {\n content.push({\n type: \"tool-call\",\n toolCallId: ev.id ?? `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"approval_required\") {\n // Opt-in `needsApproval` gate: the server emitted `tool_start` immediately\n // before this, so the matching tool-call part already exists. Mark it as\n // awaiting approval so the UI can render the Approve/Deny affordance. The\n // action did NOT execute; a paused `tool_done` follows.\n const approvalTool = ev.tool ?? \"unknown\";\n const approvalKey = ev.approvalKey;\n if (approvalKey) {\n const idx = findPendingToolCallIndex(content, approvalTool, ev.id);\n if (idx >= 0) {\n const part = content[idx];\n if (part.type === \"tool-call\") {\n part.approval = { approvalKey };\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_done\") {\n // Normalize identically to tool_start (which stores `ev.tool ?? \"unknown\"`)\n // so a tool_done frame with an undefined tool name still matches its\n // pending tool-call entry instead of leaving it forever unresolved.\n const doneTool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-done\", {\n detail: { tool: doneTool, result: ev.result },\n }),\n );\n }\n // Use id-based lookup when available so parallel same-name tool calls\n // get their results correctly assigned; fall back to name-matching.\n const doneIdx = findPendingToolCallIndex(content, doneTool, ev.id);\n if (doneIdx >= 0) {\n const part = content[doneIdx];\n if (part.type === \"tool-call\") {\n part.result = ev.result ?? \"\";\n if (ev.mcpApp) part.mcpApp = ev.mcpApp;\n if (ev.chatUI) part.chatUI = ev.chatUI;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call\") {\n const agentName = ev.agent ?? \"agent\";\n if (ev.status === \"start\") {\n const toolCallId = `tc_${++toolCallCounter.value}`;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: `agent:${agentName}`,\n argsText: \"\",\n args: {},\n });\n } else if (ev.status === \"done\" || ev.status === \"error\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.result = ev.status === \"error\" ? \"Error calling agent\" : \"Done\";\n break;\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call_text\") {\n const agentName = ev.agent ?? \"agent\";\n // Find the in-progress agent tool-call and append streaming text to argsText\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.argsText += ev.text ?? \"\";\n break;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n // ─── Agent task events (sub-agent chips) ─────────────────────────\n // These events are dispatched as CustomEvents so AgentTaskCard components\n // can listen for updates to their specific taskId.\n if (\n ev.type === \"agent_task\" ||\n ev.type === \"agent_task_update\" ||\n ev.type === \"agent_task_complete\"\n ) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new CustomEvent(\"agent-task-event\", { detail: ev }));\n }\n // Don't add to content — the agent-teams tool call handles rendering\n return { action: \"continue\" };\n }\n\n if (ev.type === \"missing_api_key\") {\n const errMsg = LLM_MISSING_CREDENTIALS_MESSAGE;\n const errorCode = LLM_MISSING_CREDENTIALS_ERROR_CODE;\n const runError = {\n message: normalizeChatError(errMsg).message,\n errorCode,\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, undefined, errorCode),\n });\n return {\n action: \"missing_api_key\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"loop_limit\") {\n const maxIterations =\n typeof ev.maxIterations === \"number\" ? ev.maxIterations : undefined;\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason: \"loop_limit\",\n ...(maxIterations ? { maxIterations } : {}),\n },\n };\n }\n\n if (ev.type === \"auto_continue\") {\n const reason =\n ev.reason === \"stream_ended\" ||\n ev.reason === \"loop_limit\" ||\n ev.reason === \"no_progress\" ||\n ev.reason === \"run_timeout\"\n ? ev.reason\n : ev.errorCode === \"stream_ended\" ||\n ev.errorCode === \"loop_limit\" ||\n ev.errorCode === \"no_progress\" ||\n ev.errorCode === \"run_timeout\"\n ? ev.errorCode\n : ev.error === \"stream_ended\" ||\n ev.error === \"loop_limit\" ||\n ev.error === \"no_progress\" ||\n ev.error === \"run_timeout\"\n ? ev.error\n : ev.status === \"stream_ended\" ||\n ev.status === \"loop_limit\" ||\n ev.status === \"no_progress\" ||\n ev.status === \"run_timeout\"\n ? ev.status\n : \"run_timeout\";\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason,\n ...(typeof ev.maxIterations === \"number\"\n ? { maxIterations: ev.maxIterations }\n : {}),\n },\n };\n }\n\n if (ev.type === \"error\") {\n const errMsg = ev.error ?? \"Unknown error\";\n if (\n (ev.errorCode === \"run_timeout\" && ev.recoverable) ||\n isAutoRecoverableError(ev, errMsg)\n ) {\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason:\n ev.errorCode === \"stale_run\"\n ? \"stale_run\"\n : ev.errorCode === \"builder_gateway_timeout\" ||\n ev.errorCode === \"run_timeout\" ||\n errMsg.toLowerCase().includes(\"timeout\")\n ? \"run_timeout\"\n : \"stream_ended\",\n },\n };\n }\n const normalized = normalizeChatError(errMsg);\n if (isMissingCredentialText(errMsg, ev.errorCode)) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n }\n }\n const runError = {\n message: normalized.message,\n ...(normalized.details || ev.details\n ? { details: ev.details ?? normalized.details }\n : {}),\n ...(ev.errorCode ? { errorCode: ev.errorCode } : {}),\n ...(ev.recoverable ? { recoverable: ev.recoverable } : {}),\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, ev.upgradeUrl, ev.errorCode),\n });\n return {\n action: \"error\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"done\") {\n return {\n action: \"done\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n return { action: \"continue\" };\n}\n\n/**\n * Read and process SSE events from a ReadableStream response body.\n * Yields ChatModelRunResult for each meaningful event.\n *\n * When `runId` is provided, every yielded result carries\n * `metadata.custom.runId` so the UI can expose the trace ID via\n * \"Copy Request ID\" — including mid-stream, so users can grab it before\n * the run completes (or if the run hangs / ends prematurely).\n */\nexport async function* readSSEStream(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onSeq?: (seq: number) => void,\n runId?: string | null,\n): AsyncGenerator<ChatModelRunResult> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n const activityTrail: ActivityTrailEntry[] = [];\n\n const withStreamMetadata = (r: ChatModelRunResult): ChatModelRunResult => {\n if (!runId && activityTrail.length === 0) return r;\n const metadata = (r.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n const runError =\n runId && custom.runError && typeof custom.runError === \"object\"\n ? {\n ...(custom.runError as Record<string, unknown>),\n runId,\n }\n : custom.runError;\n return {\n ...r,\n metadata: {\n ...metadata,\n custom: {\n ...custom,\n ...(runId ? { runId } : {}),\n ...(runError ? { runError } : {}),\n ...(activityTrail.length > 0\n ? { activityTrail: [...activityTrail] }\n : {}),\n },\n },\n };\n };\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n let sawDataEvent = false;\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n // Track sequence number for reconnection\n if (ev.seq !== undefined && onSeq) {\n onSeq(ev.seq);\n }\n\n if (ev.type === \"clear\") {\n activityTrail.length = 0;\n } else if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n appendActivityTrail(activityTrail, {\n label: humanizeToolLabelText(ev.label ?? \"Working\", tool),\n ...(tool ? { tool } : {}),\n });\n } else if (ev.type === \"tool_start\") {\n const tool = ev.tool ?? \"unknown\";\n appendActivityTrail(activityTrail, {\n label: runningToolLabel(tool),\n tool,\n });\n }\n\n const { action, result, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (result) yield withStreamMetadata(result);\n if (action === \"auto_continue\") {\n throw new AgentAutoContinueSignal(\n autoContinue\n ? { ...autoContinue, activityTrail: [...activityTrail] }\n : { reason: \"stream_ended\", activityTrail: [...activityTrail] },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n return;\n }\n }\n\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // The timeout path cancels the stream before unwinding; some runtimes\n // still consider the pending read active for a tick.\n }\n }\n\n // Stream ended without explicit done event. Even an empty content array is\n // abnormal here: a healthy run emits a terminal `done` event. Treat this as\n // recoverable so the adapter can first reconnect to the run, then continue\n // from durable history if the producer is gone.\n throw new AgentAutoContinueSignal({\n reason: \"stream_ended\",\n activityTrail: [...activityTrail],\n });\n}\n\n/**\n * Read raw SSE events from a ReadableStream and process them into ContentPart[].\n * Unlike readSSEStream, this doesn't yield ChatModelRunResult — it updates the\n * content array in-place and calls onUpdate for each meaningful change.\n * Designed for reconnection scenarios where we render outside assistant-ui's runtime.\n */\nexport async function readSSEStreamRaw(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onUpdate: (content: ContentPart[]) => void,\n): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n // Tracks whether the most recent content state was already pushed via\n // onUpdate inside the loop, so the post-loop flush below doesn't emit the\n // identical content a second time when the stream closes without a terminal\n // event.\n let emittedLatestContent = false;\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n\n let updated = false;\n let sawDataEvent = false;\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n const { action, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (\n action === \"yield\" ||\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n updated = true;\n }\n if (action === \"auto_continue\") {\n onUpdate([...content]);\n throw new AgentAutoContinueSignal(\n autoContinue ?? { reason: \"stream_ended\" },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n onUpdate([...content]);\n return;\n }\n }\n\n if (updated) {\n onUpdate([...content]);\n emittedLatestContent = true;\n }\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // See readSSEStream: cancellation may race lock release in browsers.\n }\n }\n if (content.length > 0 && !emittedLatestContent) onUpdate([...content]);\n throw new AgentAutoContinueSignal({ reason: \"stream_ended\" });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sse-event-processor.js","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAyE5E,MAAM,uBAAuB,GAC3B,iDAAiD,CAAC;AAEpD,MAAM,UAAU,0BAA0B,CACxC,OAAsB,EACtB,MAAM,GAAG,uBAAuB;IAEhC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B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CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB;QAAE,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACxE,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { ChatModelRunResult } from \"@assistant-ui/react\";\nimport type { ActionChatUIConfig } from \"../action-ui.js\";\nimport {\n LLM_MISSING_CREDENTIALS_ERROR_CODE,\n LLM_MISSING_CREDENTIALS_MESSAGE,\n} from \"../agent/engine/credential-errors.js\";\nimport type { AgentMcpAppPayload } from \"../mcp-client/app-result.js\";\nimport { formatChatErrorText, normalizeChatError } from \"./error-format.js\";\nimport { humanizeToolLabelText, runningToolLabel } from \"./tool-display.js\";\n\nexport type ContentPart =\n | { type: \"text\"; text: string }\n | {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n argsText: string;\n args: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n activity?: boolean;\n /**\n * Set when the server emitted an `approval_required` event for this tool\n * call (opt-in `needsApproval` actions). The action did NOT run; the UI\n * renders an Approve/Deny affordance. `approvalKey` is echoed back in\n * `approvedToolCalls` to approve, `dismissed` records a local Deny.\n */\n approval?: { approvalKey: string; dismissed?: boolean };\n /**\n * Structured metadata from the coding-tools executor side-channel.\n * Present only on code-agent tool calls from executors new enough to\n * emit it. The `toolKind` discriminant identifies the shape.\n */\n structuredMeta?: Record<string, unknown>;\n };\n\nexport interface SSEEvent {\n type: string;\n text?: string;\n tool?: string;\n /** Server-assigned call identifier emitted on tool_start / tool_done events. */\n id?: string;\n label?: string;\n input?: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n /** Stable key the client echoes back in `approvedToolCalls` to approve a\n * paused `needsApproval` tool call. Present on `approval_required` events. */\n approvalKey?: string;\n error?: string;\n seq?: number;\n agent?: string;\n status?: string;\n reason?: string;\n // Agent task fields\n taskId?: string;\n threadId?: string;\n description?: string;\n preview?: string;\n currentStep?: string;\n summary?: string;\n // Structured error metadata — Builder gateway sets these on quota/auth/setup\n // failures so the UI can render a CTA alongside the error text.\n errorCode?: string;\n upgradeUrl?: string;\n details?: string;\n recoverable?: boolean;\n maxIterations?: number;\n}\n\nexport type AgentAutoContinueReason =\n | \"run_timeout\"\n | \"loop_limit\"\n | \"no_progress\"\n | \"stream_ended\"\n | \"stale_run\";\n\nexport type AgentActivityTrailEntry = { label: string; tool?: string };\n\nconst INTERRUPTED_TOOL_RESULT =\n \"Interrupted before this tool returned a result.\";\n\nexport function settleInterruptedToolCalls(\n content: ContentPart[],\n result = INTERRUPTED_TOOL_RESULT,\n): boolean {\n let changed = false;\n for (const part of content) {\n if (\n part.type === \"tool-call\" &&\n part.result === undefined &&\n part.activity !== true\n ) {\n part.result = result;\n changed = true;\n }\n }\n return changed;\n}\n\nexport class AgentAutoContinueSignal extends Error {\n readonly reason: AgentAutoContinueReason;\n readonly maxIterations?: number;\n readonly activityTrail: AgentActivityTrailEntry[];\n\n constructor(options: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n activityTrail?: AgentActivityTrailEntry[];\n }) {\n super(`Agent run needs automatic continuation: ${options.reason}`);\n this.name = \"AgentAutoContinueSignal\";\n this.reason = options.reason;\n this.maxIterations = options.maxIterations;\n this.activityTrail = options.activityTrail ?? [];\n }\n}\n\nexport const SSE_NO_PROGRESS_TIMEOUT_MS = 75_000;\n\ntype ActivityTrailEntry = AgentActivityTrailEntry;\n\nfunction findPendingToolCallIndex(\n content: ContentPart[],\n toolName: string,\n toolCallId?: string,\n): number {\n // Prefer id-based match when the event carries an id: parallel same-name\n // calls can be in flight simultaneously, and name-only matching would\n // attach a result to the wrong call.\n if (toolCallId) {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolCallId === toolCallId &&\n part.result === undefined\n ) {\n return i;\n }\n }\n // Fall through to name-matching: the start event may have arrived before\n // the server started emitting ids (e.g. older server build), so the\n // stored toolCallId is the locally-generated \"tc_N\" value rather than the\n // server-assigned one. In that case match by name as a fallback.\n }\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === toolName &&\n part.result === undefined\n ) {\n return i;\n }\n }\n return -1;\n}\n\nfunction appendActivityTrail(\n trail: ActivityTrailEntry[],\n next: ActivityTrailEntry,\n) {\n const label = next.label.trim();\n if (!label) return;\n const tool = next.tool?.trim();\n const last = trail[trail.length - 1];\n if (last?.label === label && last.tool === tool) return;\n trail.push({ label, ...(tool ? { tool } : {}) });\n if (trail.length > 8) {\n trail.splice(0, trail.length - 8);\n }\n}\n\nasync function readChunkWithProgressTimeout(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n lastMeaningfulEventAt: number,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n const elapsed = Date.now() - lastMeaningfulEventAt;\n const timeoutMs = Math.max(0, SSE_NO_PROGRESS_TIMEOUT_MS - elapsed);\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const readPromise = reader.read();\n // If the timeout wins and cancellation causes the pending read to reject,\n // swallow that rejection because the generator is already recovering.\n void readPromise.catch(() => {});\n\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timeoutId = setTimeout(() => resolve(\"timeout\"), timeoutMs);\n });\n const result = await Promise.race([readPromise, timeoutPromise]);\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (result === \"timeout\") {\n await reader.cancel(\"no_progress\").catch(() => {});\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n return result;\n}\n\nfunction isAutoRecoverableError(ev: SSEEvent, errMsg: string): boolean {\n const code = String(ev.errorCode ?? \"\").toLowerCase();\n const msg = errMsg.toLowerCase();\n\n if (\n code === \"context_length_exceeded\" ||\n code === \"input_too_long\" ||\n code.startsWith(\"credits-limit\") ||\n code === \"billing_error\" ||\n code === \"unauthorized\" ||\n code === \"authentication_error\" ||\n code === \"permission_error\" ||\n code === \"http_401\" ||\n code === \"http_403\" ||\n code === \"rate_limit_exceeded\" ||\n code === \"gateway_not_enabled\" ||\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n code === \"invalid_request_error\" ||\n code === \"request_too_large\" ||\n code === \"not_found_error\" ||\n code === \"model_not_found\" ||\n code === \"provider_rate_limited\" ||\n // `builder_gateway_error` is the no-detail fallback the Builder engine\n // emits when the gateway returns `{type:\"stop\",reason:\"error\"}` with no\n // explanation — almost always the upstream provider giving up (model\n // quota hit, account misconfiguration, opaque downstream failure). The\n // production-agent already retries this synchronously up to MAX_RETRIES\n // before the error escapes to the SSE stream, so by the time the client\n // sees it, retrying again with another POST /agent-chat will hit the\n // same wall. This used to send the chat into a 32-continuation runaway\n // (each turn cleared+regenerated visible content) for users hitting a\n // misbehaving Builder route. Surface the error instead.\n code === \"builder_gateway_error\"\n ) {\n return false;\n }\n\n if (\n code === \"builder_gateway_network_error\" ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\"\n ) {\n return true;\n }\n\n if (ev.recoverable === true) return true;\n\n if (msg.includes(\"daily gateway request cap\")) return false;\n\n // \"gateway error\" intentionally absent — that's the no-detail Builder\n // gateway fallback and the production-agent already retries it\n // synchronously up to MAX_RETRIES before the error escapes here. Treating\n // it as auto-recoverable on top of that produced a 32-continuation\n // runaway in production for users hitting a misbehaving Builder route.\n // (See `code === \"builder_gateway_error\"` in the not-recoverable list.)\n return (\n msg.includes(\"overloaded\") ||\n msg.includes(\"rate_limit\") ||\n msg.includes(\"too many requests\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"connection reset\") ||\n msg.includes(\"connection\") ||\n msg.includes(\"network\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\nfunction isMissingCredentialText(message: string, errorCode?: string): boolean {\n const code = String(errorCode ?? \"\").toLowerCase();\n const msg = message.toLowerCase();\n return (\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n msg.includes(\"apikey\") ||\n msg.includes(\"authtoken\") ||\n msg.includes(\"anthropic_api_key\") ||\n msg.includes(\"missing_api_key\") ||\n msg.includes(\"missing api key\") ||\n msg.includes(\"missing credentials\") ||\n msg.includes(\"no llm provider\") ||\n msg.includes(\"llm provider is connected\")\n );\n}\n\nfunction dispatchActivityClear(tabId: string | undefined) {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity-clear\", {\n detail: { tabId },\n }),\n );\n}\n\n/**\n * Process a single SSE event and update the content accumulator.\n * Returns: \"continue\" to keep going, \"done\" to stop, or a yield-ready result.\n */\nexport function processEvent(\n ev: SSEEvent,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n): {\n action:\n | \"continue\"\n | \"done\"\n | \"yield\"\n | \"error\"\n | \"missing_api_key\"\n | \"auto_continue\";\n result?: ChatModelRunResult;\n autoContinue?: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n };\n} {\n if (ev.type === \"clear\") {\n // Server is retrying — discard partial text/tool output from the failed attempt\n content.length = 0;\n dispatchActivityClear(tabId);\n return { action: \"continue\" };\n }\n\n if (ev.type === \"text\") {\n const lastPart = content[content.length - 1];\n if (lastPart && lastPart.type === \"text\") {\n lastPart.text += ev.text ?? \"\";\n } else {\n content.push({ type: \"text\", text: ev.text ?? \"\" });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n const label = humanizeToolLabelText(ev.label ?? \"Working\", tool);\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label,\n ...(tool ? { tool } : {}),\n tabId,\n },\n }),\n );\n }\n if (!tool) return { action: \"continue\" };\n\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool);\n if (pendingToolCallIndex === -1) {\n content.push({\n type: \"tool-call\",\n toolCallId: `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: \"\",\n args: {},\n activity: true,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_start\") {\n const args = (ev.input ?? {}) as Record<string, string>;\n const tool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-start\", {\n detail: { tool, input: args },\n }),\n );\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label: runningToolLabel(tool),\n tool,\n tabId,\n },\n }),\n );\n }\n // Pass the server-assigned id so we upgrade the pending activity card\n // using id-match when available (parallel same-name calls stay separate).\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool, ev.id);\n const pendingToolCall =\n pendingToolCallIndex >= 0 ? content[pendingToolCallIndex] : undefined;\n if (\n pendingToolCall &&\n pendingToolCall.type === \"tool-call\" &&\n pendingToolCall.activity === true &&\n pendingToolCall.argsText === \"\" &&\n Object.keys(pendingToolCall.args).length === 0\n ) {\n // Upgrade the pending activity card in place. Prefer the server-assigned\n // id so the subsequent tool_done can match it precisely (parallel\n // same-name calls each carry their own id). Fall back to the\n // locally-generated id already on the card.\n content[pendingToolCallIndex] = {\n type: \"tool-call\",\n toolCallId: ev.id ?? pendingToolCall.toolCallId,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n };\n } else {\n content.push({\n type: \"tool-call\",\n toolCallId: ev.id ?? `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"approval_required\") {\n // Opt-in `needsApproval` gate: the server emitted `tool_start` immediately\n // before this, so the matching tool-call part already exists. Mark it as\n // awaiting approval so the UI can render the Approve/Deny affordance. The\n // action did NOT execute; a paused `tool_done` follows.\n const approvalTool = ev.tool ?? \"unknown\";\n const approvalKey = ev.approvalKey;\n if (approvalKey) {\n const idx = findPendingToolCallIndex(content, approvalTool, ev.id);\n if (idx >= 0) {\n const part = content[idx];\n if (part.type === \"tool-call\") {\n part.approval = { approvalKey };\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_done\") {\n // Normalize identically to tool_start (which stores `ev.tool ?? \"unknown\"`)\n // so a tool_done frame with an undefined tool name still matches its\n // pending tool-call entry instead of leaving it forever unresolved.\n const doneTool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-done\", {\n detail: { tool: doneTool, result: ev.result },\n }),\n );\n }\n // Use id-based lookup when available so parallel same-name tool calls\n // get their results correctly assigned; fall back to name-matching.\n const doneIdx = findPendingToolCallIndex(content, doneTool, ev.id);\n if (doneIdx >= 0) {\n const part = content[doneIdx];\n if (part.type === \"tool-call\") {\n part.result = ev.result ?? \"\";\n if (ev.mcpApp) part.mcpApp = ev.mcpApp;\n if (ev.chatUI) part.chatUI = ev.chatUI;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call\") {\n const agentName = ev.agent ?? \"agent\";\n if (ev.status === \"start\") {\n const toolCallId = `tc_${++toolCallCounter.value}`;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: `agent:${agentName}`,\n argsText: \"\",\n args: {},\n });\n } else if (ev.status === \"done\" || ev.status === \"error\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.result = ev.status === \"error\" ? \"Error calling agent\" : \"Done\";\n break;\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call_text\") {\n const agentName = ev.agent ?? \"agent\";\n // Find the in-progress agent tool-call and append streaming text to argsText\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.argsText += ev.text ?? \"\";\n break;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n // ─── Agent task events (sub-agent chips) ─────────────────────────\n // These events are dispatched as CustomEvents so AgentTaskCard components\n // can listen for updates to their specific taskId.\n if (\n ev.type === \"agent_task\" ||\n ev.type === \"agent_task_update\" ||\n ev.type === \"agent_task_complete\"\n ) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new CustomEvent(\"agent-task-event\", { detail: ev }));\n }\n // Don't add to content — the agent-teams tool call handles rendering\n return { action: \"continue\" };\n }\n\n if (ev.type === \"missing_api_key\") {\n const errMsg = LLM_MISSING_CREDENTIALS_MESSAGE;\n const errorCode = LLM_MISSING_CREDENTIALS_ERROR_CODE;\n const runError = {\n message: normalizeChatError(errMsg, errorCode).message,\n errorCode,\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, undefined, errorCode),\n });\n return {\n action: \"missing_api_key\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"loop_limit\") {\n const maxIterations =\n typeof ev.maxIterations === \"number\" ? ev.maxIterations : undefined;\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason: \"loop_limit\",\n ...(maxIterations ? { maxIterations } : {}),\n },\n };\n }\n\n if (ev.type === \"auto_continue\") {\n const reason =\n ev.reason === \"stream_ended\" ||\n ev.reason === \"loop_limit\" ||\n ev.reason === \"no_progress\" ||\n ev.reason === \"run_timeout\"\n ? ev.reason\n : ev.errorCode === \"stream_ended\" ||\n ev.errorCode === \"loop_limit\" ||\n ev.errorCode === \"no_progress\" ||\n ev.errorCode === \"run_timeout\"\n ? ev.errorCode\n : ev.error === \"stream_ended\" ||\n ev.error === \"loop_limit\" ||\n ev.error === \"no_progress\" ||\n ev.error === \"run_timeout\"\n ? ev.error\n : ev.status === \"stream_ended\" ||\n ev.status === \"loop_limit\" ||\n ev.status === \"no_progress\" ||\n ev.status === \"run_timeout\"\n ? ev.status\n : \"run_timeout\";\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason,\n ...(typeof ev.maxIterations === \"number\"\n ? { maxIterations: ev.maxIterations }\n : {}),\n },\n };\n }\n\n if (ev.type === \"error\") {\n const errMsg = ev.error ?? \"Unknown error\";\n if (\n (ev.errorCode === \"run_timeout\" && ev.recoverable) ||\n isAutoRecoverableError(ev, errMsg)\n ) {\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason:\n ev.errorCode === \"stale_run\"\n ? \"stale_run\"\n : ev.errorCode === \"builder_gateway_timeout\" ||\n ev.errorCode === \"run_timeout\" ||\n errMsg.toLowerCase().includes(\"timeout\")\n ? \"run_timeout\"\n : \"stream_ended\",\n },\n };\n }\n const normalized = normalizeChatError(errMsg, ev.errorCode);\n if (isMissingCredentialText(errMsg, ev.errorCode)) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n }\n }\n const runError = {\n message: normalized.message,\n ...(normalized.details || ev.details\n ? { details: ev.details ?? normalized.details }\n : {}),\n ...(ev.errorCode ? { errorCode: ev.errorCode } : {}),\n ...(ev.recoverable ? { recoverable: ev.recoverable } : {}),\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, ev.upgradeUrl, ev.errorCode),\n });\n return {\n action: \"error\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"done\") {\n return {\n action: \"done\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n return { action: \"continue\" };\n}\n\n/**\n * Read and process SSE events from a ReadableStream response body.\n * Yields ChatModelRunResult for each meaningful event.\n *\n * When `runId` is provided, every yielded result carries\n * `metadata.custom.runId` so the UI can expose the trace ID via\n * \"Copy Request ID\" — including mid-stream, so users can grab it before\n * the run completes (or if the run hangs / ends prematurely).\n */\nexport async function* readSSEStream(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onSeq?: (seq: number) => void,\n runId?: string | null,\n): AsyncGenerator<ChatModelRunResult> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n const activityTrail: ActivityTrailEntry[] = [];\n\n const withStreamMetadata = (r: ChatModelRunResult): ChatModelRunResult => {\n if (!runId && activityTrail.length === 0) return r;\n const metadata = (r.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n const runError =\n runId && custom.runError && typeof custom.runError === \"object\"\n ? {\n ...(custom.runError as Record<string, unknown>),\n runId,\n }\n : custom.runError;\n return {\n ...r,\n metadata: {\n ...metadata,\n custom: {\n ...custom,\n ...(runId ? { runId } : {}),\n ...(runError ? { runError } : {}),\n ...(activityTrail.length > 0\n ? { activityTrail: [...activityTrail] }\n : {}),\n },\n },\n };\n };\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n let sawDataEvent = false;\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n // Track sequence number for reconnection\n if (ev.seq !== undefined && onSeq) {\n onSeq(ev.seq);\n }\n\n if (ev.type === \"clear\") {\n activityTrail.length = 0;\n } else if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n appendActivityTrail(activityTrail, {\n label: humanizeToolLabelText(ev.label ?? \"Working\", tool),\n ...(tool ? { tool } : {}),\n });\n } else if (ev.type === \"tool_start\") {\n const tool = ev.tool ?? \"unknown\";\n appendActivityTrail(activityTrail, {\n label: runningToolLabel(tool),\n tool,\n });\n }\n\n const { action, result, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (result) yield withStreamMetadata(result);\n if (action === \"auto_continue\") {\n throw new AgentAutoContinueSignal(\n autoContinue\n ? { ...autoContinue, activityTrail: [...activityTrail] }\n : { reason: \"stream_ended\", activityTrail: [...activityTrail] },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n return;\n }\n }\n\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // The timeout path cancels the stream before unwinding; some runtimes\n // still consider the pending read active for a tick.\n }\n }\n\n // Stream ended without explicit done event. Even an empty content array is\n // abnormal here: a healthy run emits a terminal `done` event. Treat this as\n // recoverable so the adapter can first reconnect to the run, then continue\n // from durable history if the producer is gone.\n throw new AgentAutoContinueSignal({\n reason: \"stream_ended\",\n activityTrail: [...activityTrail],\n });\n}\n\n/**\n * Read raw SSE events from a ReadableStream and process them into ContentPart[].\n * Unlike readSSEStream, this doesn't yield ChatModelRunResult — it updates the\n * content array in-place and calls onUpdate for each meaningful change.\n * Designed for reconnection scenarios where we render outside assistant-ui's runtime.\n */\nexport async function readSSEStreamRaw(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onUpdate: (content: ContentPart[]) => void,\n): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n // Tracks whether the most recent content state was already pushed via\n // onUpdate inside the loop, so the post-loop flush below doesn't emit the\n // identical content a second time when the stream closes without a terminal\n // event.\n let emittedLatestContent = false;\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n\n let updated = false;\n let sawDataEvent = false;\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n const { action, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (\n action === \"yield\" ||\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n updated = true;\n }\n if (action === \"auto_continue\") {\n onUpdate([...content]);\n throw new AgentAutoContinueSignal(\n autoContinue ?? { reason: \"stream_ended\" },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n onUpdate([...content]);\n return;\n }\n }\n\n if (updated) {\n onUpdate([...content]);\n emittedLatestContent = true;\n }\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // See readSSEStream: cancellation may race lock release in browsers.\n }\n }\n if (content.length > 0 && !emittedLatestContent) onUpdate([...content]);\n throw new AgentAutoContinueSignal({ reason: \"stream_ended\" });\n}\n"]}
|
|
@@ -213,6 +213,17 @@ The adapter is **only** responsible for:
|
|
|
213
213
|
It does **not** know about the queue, the processor, retries, or the agent
|
|
214
214
|
loop. Those are handled by the shared webhook handler.
|
|
215
215
|
|
|
216
|
+
### Slack non-message events
|
|
217
|
+
|
|
218
|
+
Slack's Events API also sends events that are not agent messages, such as
|
|
219
|
+
`link_shared` for app unfurls. Do not map those into `IncomingMessage` unless
|
|
220
|
+
they should actually run the agent. Handle them as short, provider-specific
|
|
221
|
+
webhook work: verify the Slack signature, return `200 OK` quickly, and call the
|
|
222
|
+
provider API needed for the event (`chat.unfurl` for link previews). If a single
|
|
223
|
+
Slack app must handle both agent chat and app unfurls, put a dispatcher in front
|
|
224
|
+
of the one Slack Events Request URL and route message events to the integration
|
|
225
|
+
webhook flow while routing `link_shared` to the app-specific unfurl handler.
|
|
226
|
+
|
|
216
227
|
## Long-Running Agent Work
|
|
217
228
|
|
|
218
229
|
The processor endpoint runs in a fresh function execution with its own full
|
|
@@ -58,6 +58,30 @@ Connect your agent to Slack, email, Telegram, or WhatsApp so you can chat with i
|
|
|
58
58
|
|
|
59
59
|
7. Send your bot a DM in Slack. It should reply.
|
|
60
60
|
|
|
61
|
+
### Optional: app unfurls
|
|
62
|
+
|
|
63
|
+
Slack app unfurls let an app replace Slack's normal link preview with a richer
|
|
64
|
+
preview. Clips uses this for Loom-style playable video previews.
|
|
65
|
+
|
|
66
|
+
Add these extra bot scopes when your app needs unfurls:
|
|
67
|
+
|
|
68
|
+
- `links:read` — lets Slack notify the app when registered domains are posted
|
|
69
|
+
- `links:write` — lets the app replace Slack's default preview
|
|
70
|
+
- `links.embed:write` — lets the app embed approved media/player URLs
|
|
71
|
+
|
|
72
|
+
Then subscribe to the `link_shared` event and register your public app domains
|
|
73
|
+
under **App Unfurl Domains**. For Clips-only playable previews, set the Slack
|
|
74
|
+
Event Subscriptions Request URL to:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
https://your-clips.example.com/api/slack/unfurl
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
A Slack app has one Events API Request URL. If the same Slack app should handle
|
|
81
|
+
both agent chat events and Clips unfurls, route Slack events through a small
|
|
82
|
+
dispatcher that sends message events to `/_agent-native/integrations/slack/webhook`
|
|
83
|
+
and `link_shared` events to the Clips unfurl handler.
|
|
84
|
+
|
|
61
85
|
### Tips
|
|
62
86
|
|
|
63
87
|
- **Channel mentions** — the bot only responds in channels when it's @-mentioned, to avoid noise.
|
|
@@ -31,6 +31,8 @@ Think along the lines of Loom + Granola + Wispr Flow rolled into one app — but
|
|
|
31
31
|
- **Get an auto-generated title, summary, and chapter markers** for every recording — the agent fills them in and keeps them current.
|
|
32
32
|
- **Search across every transcript** — screen recordings, meetings, and dictations all in one library. "Find the clip where we discussed the rollout plan."
|
|
33
33
|
- **Share clips** with per-clip permissions (public, team, private). Link tracking and threaded comments work too.
|
|
34
|
+
- **Preview public clips in Slack** with a Loom-style playable unfurl after the
|
|
35
|
+
workspace installs your Clips Slack app.
|
|
34
36
|
- **Paste Clips links into agents** so they can discover the agent-readable context: metadata, transcript segments, recommended frames, and timestamped frame images without receiving the raw video file.
|
|
35
37
|
- **Smart library views.** Group by project, filter by speaker, auto-tag based on content.
|
|
36
38
|
- **Edit the transcript through chat.** "Fix the mis-transcribed word at 1:42." "Pull three quotes for a blog post." The agent edits the transcript and the UI updates live.
|
|
@@ -53,6 +55,11 @@ Password-protected clips require the password once; successful responses return
|
|
|
53
55
|
short-lived tokenized links so downstream agents do not need the plaintext
|
|
54
56
|
password.
|
|
55
57
|
|
|
58
|
+
Slack previews use the same sharing boundary. The `/api/slack/unfurl` webhook
|
|
59
|
+
only returns a playable Slack `video` block for ready, public clips without a
|
|
60
|
+
password, expiry hit, archive marker, or trash marker. Other clips still get the
|
|
61
|
+
normal share-page title/thumbnail metadata and require opening Clips.
|
|
62
|
+
|
|
56
63
|
```an-api title="Agent context entry point"
|
|
57
64
|
{
|
|
58
65
|
"method": "GET",
|
|
@@ -137,6 +144,7 @@ Clips is a larger template with a native recorder (it ships a desktop companion
|
|
|
137
144
|
1. **Video storage (required).** Connect a storage backend through the onboarding wizard. The easiest path is Builder.io (free during beta, one-click). For self-hosted storage, set `S3_ENDPOINT`, `S3_BUCKET`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, and optionally `S3_REGION` and `S3_PUBLIC_BASE_URL`. Cloudflare R2 and DigitalOcean Spaces use the same env vars with the `R2_*` prefix.
|
|
138
145
|
2. **Google Calendar (optional).** To sync upcoming meetings, connect a Google Calendar account from Settings. The OAuth callback URL in dev is `http://localhost:8094/_agent-native/google/callback`. Set up a Google OAuth client in [Google Cloud Console](https://console.cloud.google.com/) with the Gmail and Google Calendar APIs enabled.
|
|
139
146
|
3. **Screen-capture permissions.** On macOS, grant Screen Recording permission to the browser (or the desktop companion app) in System Settings → Privacy & Security → Screen Recording.
|
|
147
|
+
4. **Slack previews (optional).** Create a Slack app with `chat:write`, `links:read`, `links:write`, and `links.embed:write`; subscribe to `link_shared`; add your Clips share domain under **App Unfurl Domains**; and set the Request URL to `https://your-clips.example.com/api/slack/unfurl`. Configure `SLACK_BOT_TOKEN` and `SLACK_SIGNING_SECRET` in the Clips deployment.
|
|
140
148
|
|
|
141
149
|
### Key features
|
|
142
150
|
|
|
@@ -148,6 +156,11 @@ Clips is a larger template with a native recorder (it ships a desktop companion
|
|
|
148
156
|
|
|
149
157
|
**Agent-readable share links.** Public share links expose transcript and frame APIs so agents can understand recordings without ingesting raw video.
|
|
150
158
|
|
|
159
|
+
**Slack playable unfurls.** Public share links can render a Slack `video` block
|
|
160
|
+
that points at the existing `/embed/:id` player. This is a workspace Slack app
|
|
161
|
+
install, not a global crawler behavior: normal Open Graph/Twitter metadata is
|
|
162
|
+
the fallback when the app is not installed.
|
|
163
|
+
|
|
151
164
|
### Data model
|
|
152
165
|
|
|
153
166
|
All data lives in SQL via Drizzle ORM. Schema: `templates/clips/server/db/schema.ts`. Recordings, meetings, dictations, calendar accounts, and vocabulary all carry the standard `ownableColumns` and have a matching framework shares table, so they slot into the per-user / per-org sharing model.
|
package/package.json
CHANGED
|
@@ -213,6 +213,17 @@ The adapter is **only** responsible for:
|
|
|
213
213
|
It does **not** know about the queue, the processor, retries, or the agent
|
|
214
214
|
loop. Those are handled by the shared webhook handler.
|
|
215
215
|
|
|
216
|
+
### Slack non-message events
|
|
217
|
+
|
|
218
|
+
Slack's Events API also sends events that are not agent messages, such as
|
|
219
|
+
`link_shared` for app unfurls. Do not map those into `IncomingMessage` unless
|
|
220
|
+
they should actually run the agent. Handle them as short, provider-specific
|
|
221
|
+
webhook work: verify the Slack signature, return `200 OK` quickly, and call the
|
|
222
|
+
provider API needed for the event (`chat.unfurl` for link previews). If a single
|
|
223
|
+
Slack app must handle both agent chat and app unfurls, put a dispatcher in front
|
|
224
|
+
of the one Slack Events Request URL and route message events to the integration
|
|
225
|
+
webhook flow while routing `link_shared` to the app-specific unfurl handler.
|
|
226
|
+
|
|
216
227
|
## Long-Running Agent Work
|
|
217
228
|
|
|
218
229
|
The processor endpoint runs in a fresh function execution with its own full
|