@paymanai/payman-ask-sdk 4.0.18 → 4.0.19

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":["../../payman-sdk-typescript/src/utils/generateId.ts","../../payman-sdk-typescript/src/utils/chatStore.ts","../../payman-sdk-typescript/src/utils/activeStreamStore.ts","../../payman-sdk-typescript/src/utils/streamingClient.ts","../../payman-sdk-typescript/src/utils/stageLabels.ts","../../payman-sdk-typescript/src/utils/v2EventProcessor.ts","../../payman-sdk-typescript/src/utils/requestBuilder.ts","../../payman-sdk-typescript/src/utils/ragImageResolver.ts","../../payman-sdk-typescript/src/hooks/useStreamManagerV2.ts","../../payman-sdk-typescript/src/utils/messageStateManager.ts","../../payman-sdk-typescript/src/utils/userActionClient.ts","../../payman-sdk-typescript/src/hooks/useChatV2.ts","../../payman-sdk-typescript/src/hooks/useVoice.ts","../../payman-sdk-typescript/src/utils/jsonSchemaForm.ts","../src/contexts/PaymanChatContext.tsx","../src/components/PaymanChat/index.native.tsx","../src/utils/cn.ts","../src/utils/formatDate.ts","../src/utils/sentryContext.ts"],"names":["events","s","useRef","useCallback","useState","useMemo","submitUserAction","cancelUserAction","resendUserAction","useEffect","createContext","useContext","Platform","UIManager","memo","VoiceWaveformBar","Animated","Easing","jsx","Keyboard","LayoutAnimation","jsxs","View","TextInput","Pressable","X","Text","Check","Mic","Send","StyleSheet","Markdown","ScrollView","Switch","Dimensions","PanResponder","ShieldCheck","Pencil","ChevronRight","Info","forwardRef","PaymanChat","useColorScheme","useImperativeHandle","isEmpty","KeyboardAvoidingView","twMerge","clsx","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,UAAA,GAAqB;AAEpC,EAAA,OAAO,sCAAA,CAAuC,OAAA,CAAQ,OAAA,EAAS,CAAC,CAAA,KAAM;AACrE,IAAA,MAAM,CAAA,GAAK,IAAA,CAAK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,EAAU;AAC9B,IAAOA,iCAAe,KAAA,EAAO,EAAE,OAAO,OAAA,EAAS,IAAA,EAAM,UAAU,CAAA;AAAA,EAChE,CAAA,MAAO;AACN,IAAOA,iBAAA,CAAA,gBAAA,CAAiB,KAAA,EAAO,EAAE,IAAA,EAAM,UAAU,CAAA;AAAA,EAClD;AACD","file":"index.native.js","sourcesContent":["/**\n * Cross-platform UUID v4 generator\n * Works in both browser and React Native environments\n */\nexport function generateId(): string {\n\t// Simple UUID v4 implementation that doesn't rely on crypto API\n\treturn \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n\t\tconst r = (Math.random() * 16) | 0;\n\t\tconst v = c === \"x\" ? r : (r & 0x3) | 0x8;\n\t\treturn v.toString(16);\n\t});\n}\n","import type { MessageDisplay } from \"../types\";\n\nconst memoryStore = new Map<string, MessageDisplay[]>();\n\nexport const chatStore = {\n\tget(key: string): MessageDisplay[] {\n\t\treturn memoryStore.get(key) ?? [];\n\t},\n\tset(key: string, messages: MessageDisplay[]): void {\n\t\tmemoryStore.set(key, messages);\n\t},\n\tdelete(key: string): void {\n\t\tmemoryStore.delete(key);\n\t},\n};\n","import type { MessageDisplay } from \"../types\";\nimport { chatStore } from \"./chatStore\";\n\ntype Listener = (messages: MessageDisplay[], isWaiting: boolean) => void;\n\ntype StreamEntry = {\n\tmessages: MessageDisplay[];\n\tisWaiting: boolean;\n\tabortController: AbortController;\n\tlisteners: Set<Listener>;\n};\n\n// Keyed by userId — lives at module scope so it survives component unmount/remount\nconst streams = new Map<string, StreamEntry>();\n\nexport const activeStreamStore = {\n\thas(key: string): boolean {\n\t\treturn streams.has(key);\n\t},\n\n\tget(key: string): { messages: MessageDisplay[]; isWaiting: boolean } | null {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return null;\n\t\treturn { messages: entry.messages, isWaiting: entry.isWaiting };\n\t},\n\n\t// Called before startStream — registers the controller and initial messages\n\tstart(key: string, abortController: AbortController, initialMessages: MessageDisplay[]): void {\n\t\tconst existing = streams.get(key);\n\t\tstreams.set(key, {\n\t\t\tmessages: initialMessages,\n\t\t\tisWaiting: true,\n\t\t\tabortController,\n\t\t\tlisteners: existing?.listeners ?? new Set(),\n\t\t});\n\t},\n\n\t// Called by the stream on every event — applies the same updater pattern React uses\n\tapplyMessages(\n\t\tkey: string,\n\t\tupdater: MessageDisplay[] | ((prev: MessageDisplay[]) => MessageDisplay[])\n\t): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tconst next = typeof updater === \"function\" ? updater(entry.messages) : updater;\n\t\tentry.messages = next;\n\t\tentry.listeners.forEach((l) => l(next, entry.isWaiting));\n\t},\n\n\tsetWaiting(key: string, waiting: boolean): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.isWaiting = waiting;\n\t\tentry.listeners.forEach((l) => l(entry.messages, waiting));\n\t},\n\n\t// Called when stream completes — persists to chatStore and cleans up\n\tcomplete(key: string): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.isWaiting = false;\n\t\tentry.listeners.forEach((l) => l(entry.messages, false));\n\t\tconst toSave = entry.messages.filter((m) => !m.isStreaming);\n\t\tif (toSave.length > 0) chatStore.set(key, toSave);\n\t\tstreams.delete(key);\n\t},\n\n\t// Subscribe — returns unsubscribe fn. Component calls this on mount, cleanup on unmount.\n\tsubscribe(key: string, listener: Listener): () => void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return () => {};\n\t\tentry.listeners.add(listener);\n\t\treturn () => {\n\t\t\tstreams.get(key)?.listeners.delete(listener);\n\t\t};\n\t},\n\n\t// Rename an entry — used when the server assigns a new session ID mid-stream\n\trename(oldKey: string, newKey: string): void {\n\t\tconst entry = streams.get(oldKey);\n\t\tif (!entry) return;\n\t\tstreams.set(newKey, entry);\n\t\tstreams.delete(oldKey);\n\t},\n\n\t// Explicit user cancel — aborts the controller and removes the entry\n\tabort(key: string): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.abortController.abort();\n\t\tstreams.delete(key);\n\t},\n};\n","/**\n * Streaming client for handling SSE (Server-Sent Events) from the API\n */\n\nexport type StreamEvent = {\n\teventType: string;\n\tworkerName?: string;\n\tmessage?: string;\n\terrorMessage?: string;\n\tresponse?: unknown;\n\texecutionId?: string;\n\tsessionId?: string;\n\tinputTokens?: number;\n\toutputTokens?: number;\n\telapsedMs?: number;\n\t/**\n\t * Server-computed wall-clock duration from RunStarted to RunCompleted.\n\t * Carried on RUN_COMPLETED only — prefer this over client-side\n\t * step-span heuristics when present.\n\t */\n\ttotalTimeMs?: number;\n\t/**\n\t * User-facing progress label. Attached to:\n\t * - TOOL_CALL_STARTED / TOOL_CALL_COMPLETED — derived from the tool\n\t * name and (on completion) the row-count of the result, e.g.\n\t * \"Pulling your transactions\" / \"Got 437 transactions\".\n\t * - LLM_CALL_STARTED — an in-voice \"what's about to happen\" line.\n\t * - KEEP_ALIVE — a rotating phrase the server sends during silent-\n\t * think gaps so the chat-bubble status changes every few seconds\n\t * instead of staying frozen on \"Thinking…\".\n\t *\n\t * Clients should prefer this over raw type identifiers when\n\t * rendering a progress row.\n\t */\n\tdescription?: string;\n\t/**\n\t * Carried on `THINKING_DELTA` events — Anthropic extended-thinking\n\t * content streamed live from the upstream model. Distinct from\n\t * `partialText` (the user-facing answer); routes into a separate\n\t * \"Thinking…\" panel rather than the chat bubble.\n\t */\n\ttext?: string;\n\t/**\n\t * User-action / elicitation fields, carried at the TOP LEVEL of a\n\t * `USER_ACTION_REQUIRED` event (and `userActionId`/`message` on\n\t * `USER_NOTIFICATION`). The MCP `_meta.action` kind is forwarded\n\t * here as `action`; `requestedSchema` is standard JSON Schema.\n\t */\n\tuserActionId?: string;\n\taction?: string;\n\tsubAction?: string;\n\tverificationType?: string;\n\texpirySeconds?: number;\n\trequestedSchema?: Record<string, unknown>;\n\tmetadata?: Record<string, string>;\n\ttoolCallId?: string;\n\t[key: string]: unknown;\n};\n\nexport type StreamOptions = {\n\tsignal?: AbortSignal;\n\tonEvent?: (event: StreamEvent) => void;\n\tonError?: (error: Error) => void;\n\tonComplete?: () => void;\n};\n\n/**\n * Yield to the macrotask queue after a streaming-text delta so React can\n * commit a render before the next delta lands. No-op for non-delta events\n * (STAGE_*, TOOL_CALL_*) which don't drive the typing animation.\n *\n * Uses setTimeout(0) rather than queueMicrotask: microtasks execute before\n * React's render commit, so they don't break the batch.\n */\nfunction yieldAfterProgressEvent(event: StreamEvent): Promise<void> {\n\tconst t = event.eventType;\n\tif (\n\t\tt === \"RUN_IN_PROGRESS\" ||\n\t\tt === \"INTENT_PROGRESS\" ||\n\t\tt === \"THINKING_DELTA\"\n\t) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, 0));\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Parse buffer for complete JSON objects (raw JSON streaming, not SSE format)\n * Handles concatenated JSON objects without newlines between them\n */\nfunction parseJSONBuffer(buffer: string): {\n\tevents: StreamEvent[];\n\tremaining: string;\n} {\n\tconst events: StreamEvent[] = [];\n\tlet braceCount = 0;\n\tlet startIndex = 0;\n\tlet inString = false;\n\tlet escapeNext = false;\n\tlet lastParsedIndex = -1;\n\n\t// Find complete JSON objects in the buffer\n\tfor (let i = 0; i < buffer.length; i++) {\n\t\tconst char = buffer[i];\n\n\t\tif (escapeNext) {\n\t\t\tescapeNext = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tescapeNext = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' && !escapeNext) {\n\t\t\tinString = !inString;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tif (braceCount === 0) {\n\t\t\t\tstartIndex = i;\n\t\t\t}\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t\tif (braceCount === 0) {\n\t\t\t\t// Found a complete JSON object\n\t\t\t\tconst jsonStr = buffer.substring(startIndex, i + 1);\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = JSON.parse(jsonStr);\n\t\t\t\t\tconst event = parsed as StreamEvent;\n\t\t\t\t\tevents.push(event);\n\t\t\t\t\tlastParsedIndex = i;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"Failed to parse JSON event:\", jsonStr, err);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return parsed events and remaining buffer\n\tconst remaining =\n\t\tlastParsedIndex >= 0 ? buffer.substring(lastParsedIndex + 1) : buffer;\n\treturn { events, remaining };\n}\n\n/**\n * Stream workflow events from the API\n */\nexport async function streamWorkflowEvents(\n\turl: string,\n\tbody: Record<string, unknown>,\n\theaders: Record<string, string>,\n\toptions: StreamOptions = {}\n): Promise<void> {\n\tconst { signal, onEvent, onError, onComplete } = options;\n\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tsignal,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text();\n\t\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t\t}\n\n\t\tconst reader = response.body?.getReader();\n\t\tif (!reader) {\n\t\t\tthrow new Error(\"No response body\");\n\t\t}\n\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\n\t\tif (done) {\n\t\t\t// Process any remaining buffer\n\t\t\tif (buffer.trim()) {\n\t\t\t\tconst { events } = parseJSONBuffer(buffer);\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tonEvent?.(event);\n\t\t\t\t\tawait yieldAfterProgressEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t// Decode the chunk and add to buffer\n\t\tbuffer += decoder.decode(value, { stream: true });\n\n\t\t// Try to parse complete JSON objects from buffer\n\t\tconst { events, remaining } = parseJSONBuffer(buffer);\n\t\tfor (const event of events) {\n\t\t\tonEvent?.(event);\n\t\t\t// Yield after progress deltas so React commits a render between\n\t\t\t// them. Without this, multiple deltas batched into one TCP chunk\n\t\t\t// dispatch all setState calls in the same microtask, React 18\n\t\t\t// batches them, and the user sees the response appear at once\n\t\t\t// instead of streaming in.\n\t\t\tawait yieldAfterProgressEvent(event);\n\t\t}\n\t\t// Keep only the remaining unparsed portion\n\t\tbuffer = remaining;\n\t}\n\n\t\tonComplete?.();\n\t} catch (error) {\n\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t// Stream was cancelled\n\t\t\treturn;\n\t\t}\n\t\tonError?.(error as Error);\n\t}\n}\n","/**\n * User-facing labels for the K2 pipeline stages, used by the event\n * processor to turn machine `stage` keys on STAGE_* events into the\n * text the UI shows in its \"Thought\" / streaming-step list.\n *\n * One label per stage — no completed / failed variants. The previous\n * version had three strings per stage (\"Checking your request\" →\n * \"Request OK\" → \"Couldn't process that request\") and flashed the\n * completed label for a few milliseconds between stages, which read\n * as noise rather than signal (\"Request OK\" and \"Got it\" don't\n * inspire trust in a banking product). The simpler model:\n *\n * - When a stage starts, the cursor shows the stage label.\n * - When the stage completes, the cursor moves on to the NEXT\n * stage's label (via a new STAGE_STARTED event). There is no\n * in-between \"completed\" flash.\n * - When the stage fails, the step is marked status=error but the\n * label stays — the expanded Thought view renders failed steps\n * differently via CSS, not by rewriting the text.\n *\n * The mapping lives in the SDK (not on the server) so copy changes\n * don't require a k2-server deploy. Future i18n replaces this table\n * with a lookup by key + locale without touching the server.\n *\n * Stage keys come from k2-server's `Pipeline.toStepKey()`:\n * sanitizer | analyzer | prefetcher | planner | execution | formatter\n */\n\nconst STAGE_LABELS: Record<string, string> = {\n\tsanitizer: \"Checking your request\",\n\tanalyzer: \"Understanding what you're asking\",\n\tprefetcher: \"Gathering context\",\n\tplanner: \"Planning how to handle this\",\n\texecution: \"Working on it\",\n\tformatter: \"Writing the response\",\n};\n\n/**\n * Map a pipeline stage key to a user-facing label. Returns a\n * sensible generic fallback (\"Running <stage>\") if the stage key is\n * unknown — a future k2-server stage that the SDK doesn't know\n * about yet still renders something in the UI instead of breaking\n * the stream.\n */\nexport function stageLabel(stage: string): string {\n\tconst label = STAGE_LABELS[stage];\n\tif (label) return label;\n\tconst pretty = stage.replace(/[_-]/g, \" \");\n\treturn `Running ${pretty}`;\n}\n","import type { StreamEvent } from \"./streamingClient\";\nimport type {\n\tStreamingStep,\n\tUserActionRequest,\n\tUserActionKind,\n\tActiveUserAction,\n\tUserNotification,\n\tRequestedSchema,\n} from \"../types\";\nimport { stageLabel } from \"./stageLabels\";\n\n// ============================================================\n// Shared stream-event utilities\n// ============================================================\n//\n// These used to live in a separate `eventProcessor.ts` (the legacy\n// v1 processor file). The v1 processor + its stream manager + its\n// useChat hook have all been deleted — the v2 processor below is\n// the only one the SDK ships now — so the utilities moved here\n// rather than into a standalone shared file. They're exported\n// because `useStreamManagerV2` also imports `getEventMessage`.\n\n/**\n * Bland default-start labels every pipeline stage emits as\n * `defaultStartMessage` on the server when nothing more specific\n * has happened yet — `\"Executing…\"`, `\"Working on it…\"`, etc. The\n * stream manager filters these out of the chat-bubble status so\n * they don't replace useful messages (Analyzer's dynamic\n * \"Pulling those up for you now.\", a tool call's \"Got 437\n * transactions\") with a generic placeholder for the brief moment\n * between a stage starting and its first interesting event.\n *\n * Comparison is case-insensitive and trailing punctuation\n * (ellipsis `…` / `...` / period) is stripped so the same label\n * matches whether the server emits it with or without the\n * trailing dots.\n */\nexport function isBlandStatus(message: string | undefined | null): boolean {\n\tif (!message) return true;\n\tconst normalized = message\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[…\\.]+$/, \"\")\n\t\t.trim();\n\treturn BLAND_STATUS_LABELS.has(normalized);\n}\n\nconst BLAND_STATUS_LABELS: Set<string> = new Set([\n\t\"executing\",\n\t\"working on it\",\n\t\"thinking\",\n\t\"processing\",\n\t\"reviewing your request\",\n\t\"composing response\",\n\t\"checking your request\",\n\t\"polishing the response\",\n]);\n\n/**\n * Extract a user-friendly message string from a raw stream event.\n * Used by `useStreamManagerV2` when the streaming client needs a\n * label to attach to an intermediate event (e.g. for logging).\n */\nexport function getEventMessage(event: StreamEvent): string {\n\tif (event.message?.trim()) {\n\t\treturn event.message.trim();\n\t}\n\n\tif (event.errorMessage?.trim()) {\n\t\treturn event.errorMessage.trim();\n\t}\n\n\tconst eventType = event.eventType;\n\tswitch (eventType) {\n\t\tcase \"RUN_STARTED\":\n\t\t\treturn \"Starting agent run...\";\n\t\tcase \"TOOL_CALL_STARTED\": {\n\t\t\t// Prefer the server's human-readable `description` (e.g.\n\t\t\t// \"Pulling your transactions\") over the raw snake_case\n\t\t\t// tool identifier. Older k2-server builds don't populate\n\t\t\t// it, so we fall back to the tool name.\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\tif (description) return description;\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : \"\";\n\t\t\treturn toolName ? `Calling ${toolName}...` : \"Calling tool...\";\n\t\t}\n\t\tcase \"TOOL_CALL_COMPLETED\": {\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\tif (description) return description;\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : \"\";\n\t\t\treturn toolName ? `${toolName} completed` : \"Tool call completed\";\n\t\t}\n\t\tcase \"RUN_IN_PROGRESS\":\n\t\t\treturn (event.partialText as string) || \"Thinking...\";\n\t\tcase \"RUN_COMPLETED\":\n\t\t\treturn \"Agent run completed\";\n\t\tcase \"RUN_FAILED\":\n\t\t\treturn (event.errorMessage as string) || \"Agent run failed\";\n\t\tcase \"KEEP_ALIVE\":\n\t\t\t// k2-server attaches a rotating K2-voice phrase as `description`\n\t\t\t// during silent-think gaps so the chat-bubble status line has\n\t\t\t// something visibly changing instead of a frozen \"Thinking\".\n\t\t\t// Empty when the heartbeat is generic (legacy server builds).\n\t\t\treturn (event.description as string) || \"\";\n\t\tcase \"THINKING_DELTA\":\n\t\t\t// Anthropic extended-thinking content. Routed into the thinking\n\t\t\t// panel via processStreamEventV2; here we just contribute the\n\t\t\t// text to the bubble fallback in case the host UI doesn't\n\t\t\t// render the dedicated panel yet.\n\t\t\treturn (event.text as string) || \"\";\n\t\tdefault:\n\t\t\treturn eventType;\n\t}\n}\n\n/**\n * Pull the final assistant reply out of whatever shape the server\n * decided to send it in. Handles the common cases (direct string,\n * nested object with `text`/`content`/`message`/`answer`) and falls\n * back to a JSON stringification for anything else.\n */\nexport function extractResponseContent(response: unknown): string {\n\t// Handle direct string response (most common from API)\n\tif (typeof response === \"string\") {\n\t\treturn response;\n\t}\n\n\t// Handle object responses with nested content\n\tif (typeof response === \"object\" && response !== null) {\n\t\tconst resp = response as Record<string, unknown>;\n\n\t\t// Try common field names\n\t\tif (\"text\" in resp && typeof resp.text === \"string\") {\n\t\t\treturn resp.text;\n\t\t}\n\t\tif (\"content\" in resp && typeof resp.content === \"string\") {\n\t\t\treturn resp.content;\n\t\t}\n\t\tif (\"message\" in resp && typeof resp.message === \"string\") {\n\t\t\treturn resp.message;\n\t\t}\n\t\tif (\"answer\" in resp && typeof resp.answer === \"string\") {\n\t\t\treturn resp.answer;\n\t\t}\n\n\t\t// Fallback to JSON string\n\t\treturn JSON.stringify(response);\n\t}\n\n\treturn \"\";\n}\n\n/**\n * Translate the clean K2 playground event types (RUN_STARTED,\n * TOOL_CALL_*, RUN_IN_PROGRESS, RUN_COMPLETED, RUN_FAILED) to the\n * internal event names the state machine below handles\n * (WORKFLOW_STARTED, INTENT_STARTED, INTENT_COMPLETED,\n * INTENT_PROGRESS, WORKFLOW_COMPLETED, WORKFLOW_ERROR).\n *\n * STAGE_* events pass through unchanged — they're handled directly\n * by the processor as K2 pipeline stage lifecycle events.\n *\n * Unknown event types pass through unchanged so the state machine\n * can ignore them safely.\n */\nexport function normalizeEvent(event: StreamEvent): StreamEvent {\n\tconst type = event.eventType;\n\tswitch (type) {\n\t\tcase \"RUN_STARTED\":\n\t\t\treturn { ...event, eventType: \"WORKFLOW_STARTED\" };\n\t\tcase \"TOOL_CALL_STARTED\": {\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : undefined;\n\t\t\t// The server now ships a human-readable `description`\n\t\t\t// (\"Pulling your transactions\") on tool events. Surface it\n\t\t\t// as the normalized `message` so the INTENT_STARTED\n\t\t\t// handler below renders it in the thinking-block label\n\t\t\t// instead of the raw tool identifier. Falls back to the\n\t\t\t// existing `message` field when description is absent\n\t\t\t// (older k2-server builds).\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_STARTED\",\n\t\t\t\tworkerName: toolName ?? event.workerName,\n\t\t\t\tmessage: description || (event.message as string | undefined),\n\t\t\t};\n\t\t}\n\t\tcase \"TOOL_CALL_COMPLETED\": {\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : undefined;\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_COMPLETED\",\n\t\t\t\tworkerName: toolName ?? event.workerName,\n\t\t\t\tmessage: description || (event.message as string | undefined),\n\t\t\t};\n\t\t}\n\t\tcase \"RUN_IN_PROGRESS\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_PROGRESS\",\n\t\t\t\tmessage: (event.partialText as string | undefined) ?? event.message,\n\t\t\t};\n\t\tcase \"RUN_COMPLETED\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"WORKFLOW_COMPLETED\",\n\t\t\t\t// state machine reads event.response for the final content\n\t\t\t\tresponse: event.response ?? event.message,\n\t\t\t};\n\t\tcase \"RUN_FAILED\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"WORKFLOW_ERROR\",\n\t\t\t\terrorMessage: (event.errorMessage as string | undefined) ?? (event.message as string | undefined),\n\t\t\t};\n\t\tdefault:\n\t\t\treturn event;\n\t}\n}\n\n/**\n * A `requestedSchema` whose only field is `verificationCode` is the MCP\n * verification (one-time-code) shape, regardless of the declared\n * `action`. Used to refine classification.\n */\nfunction isVerificationSchema(schema: RequestedSchema | undefined): boolean {\n\tconst props = schema?.properties;\n\tif (!props) return false;\n\tconst keys = Object.keys(props);\n\treturn keys.length === 1 && keys[0] === \"verificationCode\";\n}\n\n/**\n * Classify a `USER_ACTION_REQUIRED` event into a render kind. Primary\n * discriminator is the MCP elicitation `action`; we fall back to the\n * schema shape so unknown/legacy `action` tags still route correctly.\n */\nexport function classifyUserActionKind(\n\taction: string | undefined,\n\tschema: RequestedSchema | undefined,\n): UserActionKind {\n\tswitch ((action || \"\").toLowerCase()) {\n\t\tcase \"userverificationrequest\":\n\t\t\treturn \"verification\";\n\t\tcase \"usernotificationrequest\":\n\t\t\treturn \"notification\";\n\t\tcase \"userformrequest\":\n\t\t\treturn isVerificationSchema(schema) ? \"verification\" : \"form\";\n\t\tdefault:\n\t\t\treturn isVerificationSchema(schema) ? \"verification\" : \"form\";\n\t}\n}\n\nexport type V2EventProcessorState = {\n\tfinalResponse: string;\n\tlastEventType: string;\n\tsessionId?: string;\n\texecutionId?: string;\n\thasError: boolean;\n\terrorMessage: string;\n\t/**\n\t * Active user-action prompts, an ordered collection keyed by\n\t * `toolCallId` (fallback `userActionId`). Usually 0–1 for serial\n\t * runs; multiple when parallel tool calls each elicit.\n\t */\n\tuserActions: ActiveUserAction[];\n\t/** One-way notifications surfaced this run (`USER_NOTIFICATION`). */\n\tnotifications: UserNotification[];\n\t/**\n\t * Transient: the prompt upserted by the most recent\n\t * `USER_ACTION_REQUIRED` event, so the stream manager can fire\n\t * `onUserActionRequired` for exactly that prompt. Reset each event.\n\t */\n\tlastUserAction?: UserActionRequest;\n\t/** Transient: the notification pushed by the most recent event. */\n\tlastNotification?: UserNotification;\n\tfinalData?: unknown;\n\tsteps: StreamingStep[];\n\tstepCounter: number;\n\tcurrentExecutingStepId?: string;\n\t/** Server-computed wall-clock duration captured from RUN_COMPLETED's `totalTimeMs`. */\n\ttotalElapsedMs?: number;\n};\n\nfunction getEventText(event: StreamEvent, field: string): string {\n\tconst value = event[field];\n\treturn typeof value === \"string\" ? value.trim() : \"\";\n}\n\n/**\n * Mirror the current tool-call START label onto the enclosing\n * in-progress STAGE_STARTED(\"execution\") step.\n *\n * Called on INTENT_STARTED only (not INTENT_COMPLETED). AGENTIC runs\n * fire many back-to-back tools (especially long query_engine chains),\n * so alternating start→end labels on every call produced a rapid\n * flicker of \"Crunching the numbers\" → \"Got 20 rows\" → \"Crunching\n * the numbers\" → \"Got 16 rows\" during a 60-120s run. Mirroring only\n * the start label means back-to-back same-type calls read as one\n * stable label (\"Crunching the numbers\" throughout the chain), with\n * transitions only when the tool *kind* actually changes.\n *\n * Why the mirror is needed at all: the chat-bubble label picker\n * walks steps in reverse and returns the most recent in-progress\n * step's message. Between tool calls the tool-level INTENT_STARTED\n * step is completed, so the picker falls back to the still-in-progress\n * execution-stage step — whose message is the static \"Executing…\"\n * default from the server. Mirroring the tool label onto that stage\n * step keeps the fallback dynamic and meaningful.\n *\n * No-op when `msg` is empty (older k2-server builds without\n * descriptions) or when no execution-stage step is in progress (run\n * hasn't reached the execution stage yet).\n */\nfunction updateExecutionStageMessage(state: V2EventProcessorState, msg: string): void {\n\tif (!msg) return;\n\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\tconst s = state.steps[i];\n\t\t// Match BOTH \"executor\" (current k2-server) and \"execution\"\n\t\t// (legacy ExecutionEngine). Without the \"executor\" match, the\n\t\t// tool-label mirror never landed on modern server builds and\n\t\t// the chat bubble was stuck on bland \"Executing…\" while the\n\t\t// pipeline panel showed live \"Crunching the numbers\"-style\n\t\t// labels — visible chat/pipeline desync.\n\t\tif (\n\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t(s.stage === \"executor\" || s.stage === \"execution\") &&\n\t\t\ts.status === \"in_progress\"\n\t\t) {\n\t\t\ts.message = msg;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nfunction completeLastInProgressStep(steps: StreamingStep[]): void {\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tif (steps[i].status === \"in_progress\") {\n\t\t\tsteps[i].status = \"completed\";\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nexport function createInitialV2State(): V2EventProcessorState {\n\treturn {\n\t\tfinalResponse: \"\",\n\t\tlastEventType: \"\",\n\t\tsessionId: undefined,\n\t\texecutionId: undefined,\n\t\thasError: false,\n\t\terrorMessage: \"\",\n\t\tuserActions: [],\n\t\tnotifications: [],\n\t\tlastUserAction: undefined,\n\t\tlastNotification: undefined,\n\t\tfinalData: undefined,\n\t\tsteps: [],\n\t\tstepCounter: 0,\n\t\tcurrentExecutingStepId: undefined,\n\t};\n}\n\n/**\n * Upsert a prompt into `state.userActions`, applying the supersede rule:\n * a new event with a matching `toolCallId` (a `SubmissionInvalid` retry\n * or `RequestResent`, even with a new `userActionId`) REPLACES that slot\n * in place; otherwise it's appended as a new (parallel) prompt.\n */\nfunction upsertUserAction(state: V2EventProcessorState, req: UserActionRequest): void {\n\tconst active: ActiveUserAction = { ...req, status: \"pending\" };\n\tconst matchIdx = state.userActions.findIndex((p) =>\n\t\treq.toolCallId\n\t\t\t? p.toolCallId === req.toolCallId\n\t\t\t: p.userActionId === req.userActionId,\n\t);\n\tif (matchIdx >= 0) {\n\t\tstate.userActions[matchIdx] = active;\n\t} else {\n\t\tstate.userActions.push(active);\n\t}\n}\n\nexport function processStreamEventV2(\n\trawEvent: StreamEvent,\n\tstate: V2EventProcessorState,\n): V2EventProcessorState {\n\tconst event = normalizeEvent(rawEvent);\n\tconst eventType = event.eventType;\n\n\t// Transient per-event dispatch signals — cleared every call so the\n\t// stream manager only fires callbacks for the current event.\n\tstate.lastUserAction = undefined;\n\tstate.lastNotification = undefined;\n\n\tif (typeof eventType === \"string\" && eventType.toUpperCase() === \"KEEP_ALIVE\") {\n\t\tif (event.executionId) state.executionId = event.executionId;\n\t\tif (event.sessionId) state.sessionId = event.sessionId;\n\t\t// k2-server attaches a rotating K2-voice phrase as `description` so\n\t\t// the chat-bubble status line changes during silent-think gaps\n\t\t// instead of staying pinned to \"Thinking\" for tens of seconds.\n\t\t// Mirror it onto the most-recent in-progress step's message so the\n\t\t// stream manager's `currentMessage` picker (which walks\n\t\t// state.steps for the latest substantive label) surfaces it.\n\t\tconst description = typeof event.description === \"string\" ? event.description : \"\";\n\t\tif (description) {\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tif (state.steps[i].status === \"in_progress\") {\n\t\t\t\t\tstate.steps[i].message = description;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn state;\n\t}\n\n\tif (typeof eventType === \"string\" && eventType.toUpperCase() === \"THINKING_DELTA\") {\n\t\tif (event.executionId) state.executionId = event.executionId;\n\t\tif (event.sessionId) state.sessionId = event.sessionId;\n\t\tstate.lastEventType = \"THINKING_DELTA\";\n\t\treturn state;\n\t}\n\n\tif (event.executionId) state.executionId = event.executionId;\n\tif (event.sessionId) state.sessionId = event.sessionId;\n\n\tconst message = getEventMessage(event);\n\n\tswitch (eventType) {\n\t\tcase \"WORKFLOW_STARTED\":\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\n\t\tcase \"INTENT_PROGRESS\": {\n\t\t\t// Streaming delta from the Formatter stage — each event\n\t\t\t// carries `partialText` (the new chunk) which normalizeEvent\n\t\t\t// surfaces as `event.message`. Accumulate into\n\t\t\t// state.finalResponse so the stream manager can mirror it\n\t\t\t// into streamingContent in real time. The WORKFLOW_COMPLETED\n\t\t\t// event at the end still lands with the authoritative full\n\t\t\t// text; this just lets us show the answer building up.\n\t\t\t//\n\t\t\t// IMPORTANT: read raw values, do NOT `getEventText()` here.\n\t\t\t// getEventText() calls .trim(), which strips the leading\n\t\t\t// and trailing whitespace that providers include in each\n\t\t\t// token delta (\" bank\", \"accounts \", \"with\"). Trimming at\n\t\t\t// this layer destroys inter-word spacing and produces\n\t\t\t// \"Hereareallyourbankaccounts\" once deltas are concatenated.\n\t\t\tconst rawMessage = typeof event.message === \"string\" ? event.message : \"\";\n\t\t\tconst rawPartial = typeof event.partialText === \"string\" ? event.partialText : \"\";\n\t\t\tconst delta = rawMessage || rawPartial;\n\t\t\tif (delta.length > 0) {\n\t\t\t\tstate.finalResponse += delta;\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"INTENT_STARTED\": {\n\t\t\tconst stepId = `step-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage,\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\telapsedMs: event.elapsedMs,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\t// Keep the enclosing execution stage step in sync with the\n\t\t\t// current tool label so the UI never flashes back to\n\t\t\t// \"Executing…\" between tool calls. See helper docs.\n\t\t\tupdateExecutionStageMessage(state, message);\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"INTENT_COMPLETED\": {\n\t\t\tconst intentStep = state.steps.find(s => s.eventType === \"INTENT_STARTED\" && s.status === \"in_progress\");\n\t\t\tif (intentStep) {\n\t\t\t\tintentStep.status = \"completed\";\n\t\t\t\tif (event.elapsedMs) intentStep.elapsedMs = event.elapsedMs;\n\t\t\t\tif (intentStep.id === state.currentExecutingStepId) state.currentExecutingStepId = undefined;\n\t\t\t}\n\t\t\t// DO NOT update the enclosing execution-stage message\n\t\t\t// here. AGENTIC runs fire many back-to-back tools\n\t\t\t// (especially query_engine chains) and surfacing the\n\t\t\t// per-tool completion label (\"Got 20 rows\" → \"Got 16\n\t\t\t// rows\" → …) caused a rapid flicker between start/end\n\t\t\t// labels during the 60-120s loop. Keeping the stage step\n\t\t\t// pinned to the CURRENT tool's start description means\n\t\t\t// back-to-back same-type tool calls all read as the same\n\t\t\t// stable label (\"Crunching the numbers\" throughout the\n\t\t\t// query_engine chain). The detail per tool still lives\n\t\t\t// on the tool's own step for expanded / trace views.\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"WORKFLOW_COMPLETED\": {\n\t\t\t// Capture server-computed wall-clock duration. Authoritative.\n\t\t\tconst totalTime = Number(event.totalTimeMs);\n\t\t\tif (Number.isFinite(totalTime) && totalTime > 0) {\n\t\t\t\tstate.totalElapsedMs = totalTime;\n\t\t\t}\n\n\t\t\tconst content = extractResponseContent(event.response);\n\n\t\t\tif (content) {\n\t\t\t\tstate.finalResponse = content;\n\t\t\t\t// K2 playground runs emit the answer on `event.response`.\n\t\t\t\t// The full execution trace is fetched on demand via\n\t\t\t\t// GET /api/playground/executions/{id}/trace using\n\t\t\t\t// `executionId` on the final message.\n\t\t\t\tif (event.trace && typeof event.trace === \"object\") {\n\t\t\t\t\tstate.finalData = event.trace;\n\t\t\t\t}\n\t\t\t\tstate.hasError = false;\n\t\t\t\tstate.errorMessage = \"\";\n\t\t\t} else {\n\t\t\t\tstate.hasError = true;\n\t\t\t\tstate.errorMessage = \"WORKFLOW_FAILED\";\n\t\t\t}\n\n\t\t\tstate.steps.forEach(step => {\n\t\t\t\tif (step.status === \"in_progress\") {\n\t\t\t\t\tstep.status = \"completed\";\n\t\t\t\t}\n\t\t\t});\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"USER_ACTION_REQUIRED\": {\n\t\t\tconst rawAction = typeof event.action === \"string\" ? event.action : undefined;\n\t\t\tconst schema = event.requestedSchema as RequestedSchema | undefined;\n\t\t\tconst kind = classifyUserActionKind(rawAction, schema);\n\t\t\tconst promptMessage =\n\t\t\t\t(typeof event.message === \"string\" && event.message.trim()) || message || \"\";\n\t\t\tconst userActionId =\n\t\t\t\ttypeof event.userActionId === \"string\" ? event.userActionId : \"\";\n\n\t\t\t// A UserNotificationRequest is display-only — surface it as a\n\t\t\t// notification, not an interactive prompt.\n\t\t\tif (kind === \"notification\") {\n\t\t\t\tconst notification: UserNotification = {\n\t\t\t\t\tid: userActionId || `note-${state.stepCounter++}`,\n\t\t\t\t\tmessage: promptMessage,\n\t\t\t\t};\n\t\t\t\tstate.notifications.push(notification);\n\t\t\t\tstate.lastNotification = notification;\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Without an id we can't route a resolution back — skip.\n\t\t\tif (!userActionId) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcompleteLastInProgressStep(state.steps);\n\n\t\t\tconst verificationType =\n\t\t\t\tevent.verificationType === \"ALPHANUMERIC_CODE\" ||\n\t\t\t\tevent.verificationType === \"NUMERIC_CODE\"\n\t\t\t\t\t? event.verificationType\n\t\t\t\t\t: undefined;\n\n\t\t\tconst request: UserActionRequest = {\n\t\t\t\tuserActionId,\n\t\t\t\tkind,\n\t\t\t\trawAction,\n\t\t\t\tsubAction: typeof event.subAction === \"string\" ? event.subAction : undefined,\n\t\t\t\tverificationType,\n\t\t\t\texpirySeconds:\n\t\t\t\t\ttypeof event.expirySeconds === \"number\" ? event.expirySeconds : undefined,\n\t\t\t\tmessage: promptMessage || undefined,\n\t\t\t\trequestedSchema: schema,\n\t\t\t\tmetadata: event.metadata as Record<string, string> | undefined,\n\t\t\t\ttoolCallId: typeof event.toolCallId === \"string\" ? event.toolCallId : undefined,\n\t\t\t\texecutionId: state.executionId,\n\t\t\t\tsessionId: state.sessionId,\n\t\t\t};\n\n\t\t\tupsertUserAction(state, request);\n\t\t\tstate.lastUserAction = request;\n\n\t\t\tconst stepId = `step-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage:\n\t\t\t\t\tpromptMessage ||\n\t\t\t\t\t(kind === \"verification\"\n\t\t\t\t\t\t? \"Waiting for verification...\"\n\t\t\t\t\t\t: \"Waiting for your input...\"),\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\telapsedMs: event.elapsedMs,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"USER_NOTIFICATION\": {\n\t\t\tconst noteMessage =\n\t\t\t\t(typeof event.message === \"string\" && event.message.trim()) || message || \"\";\n\t\t\tconst userActionId =\n\t\t\t\ttypeof event.userActionId === \"string\" ? event.userActionId : \"\";\n\t\t\tif (noteMessage || userActionId) {\n\t\t\t\tconst notification: UserNotification = {\n\t\t\t\t\tid: userActionId || `note-${state.stepCounter++}`,\n\t\t\t\t\tmessage: noteMessage,\n\t\t\t\t};\n\t\t\t\tstate.notifications.push(notification);\n\t\t\t\tstate.lastNotification = notification;\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"WORKFLOW_ERROR\":\n\t\t\tstate.hasError = true;\n\t\t\tstate.errorMessage = (event.errorMessage as string) || (event.message as string) || \"Workflow error\";\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\n\t\t// ---- K2 pipeline stage lifecycle events ----\n\t\t//\n\t\t// The k2-server playground streaming API emits\n\t\t// STAGE_STARTED / STAGE_COMPLETED / STAGE_FAILED /\n\t\t// STAGE_SKIPPED around each pipeline stage so the UI can\n\t\t// show real progress (sanitizer → analyzer → planner → …)\n\t\t// instead of a static placeholder. Each STAGE_STARTED\n\t\t// pushes an in-progress step with a user-facing label; the\n\t\t// matching STAGE_COMPLETED/FAILED closes it WITHOUT\n\t\t// rewriting the label — a terse \"completed\" flash between\n\t\t// stages was more noise than signal. STAGE_SKIPPED removes\n\t\t// the just-opened step entirely (skipping is expected on\n\t\t// DIRECT_RESPONSE short-circuits).\n\t\t//\n\t\t// Finding the matching step uses `stepId` directly rather\n\t\t// than comparing labels — the processor remembers which id\n\t\t// it minted for the latest open STAGE_STARTED and the\n\t\t// closing events look it up from state.currentExecutingStepId.\n\n\t\tcase \"STAGE_STARTED\": {\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Prefer the server-provided `message` — each K2 pipeline\n\t\t\t// stage now ships its own user-facing label on StageStarted\n\t\t\t// (Analyzer: \"Thinking…\", Prefetcher: \"Gathering context…\",\n\t\t\t// etc.). Fall back to the SDK's static stageLabel() table\n\t\t\t// only if the server didn't send one, which keeps this\n\t\t\t// processor compatible with older k2-server builds.\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tlet initialMessage = serverMessage || stageLabel(stage);\n\n\t\t\t// Execution-stage special case: the server's default label\n\t\t\t// is a bare \"Executing…\" which would show for the 5-10s\n\t\t\t// between STAGE_STARTED(\"executor\") and the first\n\t\t\t// TOOL_CALL_STARTED in an AGENTIC run. Prefer the\n\t\t\t// Analyzer's LLM-generated status (\"Pulling those up for\n\t\t\t// you now.\") — it's request-specific and bridges the gap\n\t\t\t// to the first tool event. Tool events subsequently mutate\n\t\t\t// this step's message via updateExecutionStageMessage().\n\t\t\t//\n\t\t\t// Match BOTH \"executor\" (current k2-server stage key) and\n\t\t\t// \"execution\" (legacy ExecutionEngine stage). Without the\n\t\t\t// \"executor\" match, the special case never fired against\n\t\t\t// modern server builds — observed in production: the chat\n\t\t\t// bubble showed bland \"Executing…\" for the entire agentic\n\t\t\t// run despite the analyzer having shipped a useful narrative\n\t\t\t// status that should have been inherited.\n\t\t\tif (stage === \"executor\" || stage === \"execution\") {\n\t\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst s = state.steps[i];\n\t\t\t\t\tif (\n\t\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\t\ts.stage === \"analyzer\" &&\n\t\t\t\t\t\ts.status === \"completed\" &&\n\t\t\t\t\t\ts.message\n\t\t\t\t\t) {\n\t\t\t\t\t\tinitialMessage = s.message;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst stepId = `stage-${stage}-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage: initialMessage,\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tstage,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_COMPLETED\": {\n\t\t\t// Close the most recent in-progress step for this stage.\n\t\t\t// If the server provides a new `message` (the Analyzer's\n\t\t\t// LLM-generated \"Pulling those up for you now.\"), OVERWRITE\n\t\t\t// the step's label before marking completed — the UI's\n\t\t\t// currentStepLabel fallback shows the most recent step's\n\t\t\t// label during the gap between stages, so updating here\n\t\t\t// means the user sees the dynamic status instead of the\n\t\t\t// generic start-label until the next STAGE_STARTED lands.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (serverMessage) s.message = serverMessage;\n\t\t\t\t\ts.status = \"completed\";\n\t\t\t\t\tconst durationMs = Number(event.durationMs);\n\t\t\t\t\tif (Number.isFinite(durationMs)) s.elapsedMs = durationMs;\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_FAILED\": {\n\t\t\t// Same as STAGE_COMPLETED but the step's status becomes\n\t\t\t// \"error\". If the server provides a specific failure\n\t\t\t// message we surface it; otherwise the label stays so the\n\t\t\t// user at least sees which stage was running. Expanded\n\t\t\t// Thought view renders errored steps differently via CSS.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (serverMessage) s.message = serverMessage;\n\t\t\t\t\ts.status = \"error\";\n\t\t\t\t\tconst durationMs = Number(event.durationMs);\n\t\t\t\t\tif (Number.isFinite(durationMs)) s.elapsedMs = durationMs;\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_SKIPPED\": {\n\t\t\t// Mark the matching in-progress step as \"skipped\" rather\n\t\t\t// than removing it. The chat-bubble thinking animation\n\t\t\t// only reads in-progress steps so marking skipped doesn't\n\t\t\t// affect it. But pipeline-sidebar UIs need the step\n\t\t\t// retained (with the \"skipped\" status) so they can render\n\t\t\t// a visual indicator (e.g. a MinusCircle icon) for stages\n\t\t\t// the pipeline intentionally bypassed.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\ts.status = \"skipped\" as typeof s.status;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t}\n\n\treturn state;\n}\n","import type { ChatConfig } from \"../types\";\n\nconst DEFAULT_STREAM_ENDPOINT = \"/api/playground/ask/stream\";\n\n/**\n * Latency-vs-precision toggle surfaced in the chat widget. \"fast\"\n * (default) lets the server cap list-tool fetches and answer\n * quickly; \"deep\" runs a full analytical pass. The value is\n * forwarded verbatim to the server, which normalizes it — any\n * other string collapses to \"fast\" server-side. See\n * `ExecutionRequest.analysisMode` on the k2 backend for the\n * authoritative semantics.\n */\nexport type AnalysisMode = \"fast\" | \"deep\";\n\n/**\n * Build request body for the k2 playground ask endpoint.\n *\n * Shape matches PlaygroundAskRequest on the server:\n * { agentId, userInput, sessionId?, sessionOwnerId, sessionOwnerLabel?,\n * sessionAttributes?, analysisMode?, locale, timezone? }\n *\n * `analysisMode` is omitted from the body when undefined so older\n * SDK versions that don't pass it produce the exact same wire\n * shape they did before — the server defaults missing values to\n * \"fast\" anyway, so including the field is purely informational\n * when the caller hasn't opted in.\n *\n * `locale` is REQUIRED by the server's PlaygroundAskRequest. We resolve\n * it from `config.locale` first, then `navigator.language` (browser),\n * then fall back to \"en-US\". Without this the server returns 400 with\n * a serialization error.\n */\nexport function buildRequestBody(\n\tconfig: ChatConfig,\n\tuserMessage: string,\n\tsessionId?: string,\n\toptions?: { analysisMode?: AnalysisMode },\n): Record<string, unknown> {\n\tconst sessionOwner = config.sessionParams;\n\tconst sessionOwnerId = sessionOwner?.id?.trim();\n\tif (!sessionOwnerId) {\n\t\tthrow new Error(\"ChatConfig.sessionParams.id is required to send ask requests.\");\n\t}\n\tconst sessionAttributes =\n\t\tsessionOwner?.attributes && Object.keys(sessionOwner.attributes).length > 0\n\t\t\t? sessionOwner.attributes\n\t\t\t: undefined;\n\n\treturn {\n\t\tagentId: config.agentId,\n\t\tuserInput: userMessage,\n\t\tsessionId,\n\t\tsessionOwnerId,\n\t\tsessionOwnerLabel: sessionOwner?.name || undefined,\n\t\tsessionAttributes,\n\t\tanalysisMode: options?.analysisMode,\n\t\tlocale: resolveLocale(config.locale),\n\t\ttimezone: resolveTimezone(config.timezone),\n\t};\n}\n\n/**\n * Resolve the BCP-47 locale to send with ask requests. Tries explicit\n * config first, then the browser's `navigator.language`, then a safe\n * \"en-US\" fallback. The server requires this field on the playground\n * endpoint — never returns undefined.\n */\nfunction resolveLocale(configured?: string): string {\n\tif (configured && configured.trim().length > 0) return configured.trim();\n\tif (typeof navigator !== \"undefined\") {\n\t\tconst navLocale = (navigator as { language?: string }).language;\n\t\tif (navLocale && navLocale.length > 0) return navLocale;\n\t}\n\treturn \"en-US\";\n}\n\n/**\n * Resolve the IANA timezone to send with ask requests. Tries explicit\n * config first, then `Intl.DateTimeFormat().resolvedOptions().timeZone`,\n * then \"UTC\" as a last resort. Optional on the server, but sending\n * something useful means agents can localize date prose without a\n * follow-up clarification.\n */\nfunction resolveTimezone(configured?: string): string {\n\tif (configured && configured.trim().length > 0) return configured.trim();\n\ttry {\n\t\tconst zone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n\t\tif (zone && zone.length > 0) return zone;\n\t} catch {\n\t\t// Intl missing or unhappy — fall through to the UTC default.\n\t}\n\treturn \"UTC\";\n}\n\n/**\n * Build streaming URL. Defaults to the k2 playground stream endpoint.\n */\nexport function buildStreamingUrl(config: ChatConfig): string {\n\tconst endpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst stage = config.stage || \"DEV\";\n\tconst stageParamName = config.stageQueryParam ?? \"stage\";\n\tconst queryParams = new URLSearchParams({ [stageParamName]: stage });\n\n\treturn `${config.api.baseUrl}${endpoint}?${queryParams.toString()}`;\n}\n\n/**\n * Build user action URL (submit / cancel / resend)\n * Derives base path from the stream endpoint by stripping the \"/stream\" suffix.\n */\nexport function buildUserActionUrl(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\taction: \"submit\" | \"cancel\" | \"resend\",\n): string {\n\tconst endpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst [endpointPath] = endpoint.split(\"?\");\n\tconst normalizedEndpointPath = endpointPath.replace(/\\/+$/, \"\");\n\tconst basePath = normalizedEndpointPath.endsWith(\"/stream\")\n\t\t? normalizedEndpointPath.slice(0, -\"/stream\".length)\n\t\t: normalizedEndpointPath;\n\tconst encodedUserActionId = encodeURIComponent(userActionId);\n\treturn `${config.api.baseUrl}${basePath}/user-action/${encodedUserActionId}/${action}`;\n}\n\n/**\n * Build resolve-image-urls endpoint URL.\n * Derives the base path from the stream endpoint (same pattern as buildUserActionUrl)\n * so that playground URLs stay on the playground path and workflow URLs stay on the\n * workflows path. An explicit resolveImagesEndpoint in config always wins.\n */\nexport function buildResolveImagesUrl(config: ChatConfig): string {\n\tif (config.api.resolveImagesEndpoint) {\n\t\treturn `${config.api.baseUrl}${config.api.resolveImagesEndpoint}`;\n\t}\n\tconst streamEndpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst [endpointPath] = streamEndpoint.split(\"?\");\n\tconst normalizedEndpointPath = endpointPath.replace(/\\/+$/, \"\");\n\tconst basePath = normalizedEndpointPath.endsWith(\"/stream\")\n\t\t? normalizedEndpointPath.slice(0, -\"/stream\".length)\n\t\t: normalizedEndpointPath;\n\treturn `${config.api.baseUrl}${basePath}/resolve-image-urls`;\n}\n\n/**\n * Build request headers\n */\nexport function buildRequestHeaders(config: ChatConfig): Record<string, string> {\n\tconst headers: Record<string, string> = {\n\t\t...config.api.headers,\n\t};\n\tif (config.api.authToken) {\n\t\theaders.Authorization = `Bearer ${config.api.authToken}`;\n\t}\n\treturn headers;\n}\n","import type { ChatConfig } from \"../types\";\nimport { buildResolveImagesUrl, buildRequestHeaders } from \"./requestBuilder\";\n\n/** Matches the RAG image path pattern: /api/rag/chunks/<id>/<version>/<chunk>/image */\nconst RAG_IMAGE_REGEX = /\\/api\\/rag\\/chunks\\/[^\"'\\s]+\\/image/;\n\n/**\n * Returns true if the content contains any unresolved RAG image URLs.\n */\nexport function hasRagImages(content: string): boolean {\n\treturn RAG_IMAGE_REGEX.test(content);\n}\n\n/**\n * Wait one paint before starting the resolve request so the final response\n * can render first and image placeholders can appear in the UI.\n */\nexport async function waitForNextPaint(signal?: AbortSignal): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tlet isSettled = false;\n\n\t\tconst finish = () => {\n\t\t\tif (isSettled) return;\n\t\t\tisSettled = true;\n\t\t\tsignal?.removeEventListener(\"abort\", finish);\n\t\t\tresolve();\n\t\t};\n\n\t\tsignal?.addEventListener(\"abort\", finish, { once: true });\n\n\t\tif (typeof requestAnimationFrame === \"function\") {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tsetTimeout(finish, 0);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tsetTimeout(finish, 0);\n\t});\n}\n\n/**\n * Calls the resolve-image-urls API to replace RAG image paths with\n * real signed Azure Blob Storage URLs.\n *\n * @throws on non-2xx HTTP status\n */\nexport async function resolveRagImageUrls(\n\tconfig: ChatConfig,\n\tcontent: string,\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tconst url = buildResolveImagesUrl(config);\n\tconst baseHeaders = buildRequestHeaders(config);\n\tconst headers = { \"Content-Type\": \"application/json\", ...baseHeaders };\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: JSON.stringify({ input: content }),\n\t\tsignal,\n\t});\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t}\n\n\tconst text = await response.text();\n\n\t// Handle both plain-text and JSON-wrapped responses\n\ttry {\n\t\tconst parsed = JSON.parse(text);\n\t\tif (typeof parsed === \"string\") return parsed;\n\t\tif (typeof parsed.output === \"string\") return parsed.output;\n\t\tif (typeof parsed.result === \"string\") return parsed.result;\n\t} catch {\n\t\t// Not JSON — treat as plain text\n\t}\n\n\treturn text;\n}\n","import { useCallback, useRef } from \"react\";\nimport type { ChatConfig, ChatCallbacks, MessageDisplay } from \"../types\";\nimport { streamWorkflowEvents, type StreamEvent } from \"../utils/streamingClient\";\nimport {\n\tprocessStreamEventV2,\n\tcreateInitialV2State,\n\tgetEventMessage,\n\tisBlandStatus,\n} from \"../utils/v2EventProcessor\";\nimport {\n\tbuildRequestBody,\n\tbuildStreamingUrl,\n\tbuildRequestHeaders,\n\ttype AnalysisMode,\n} from \"../utils/requestBuilder\";\nimport {\n\thasRagImages,\n\tresolveRagImageUrls,\n\twaitForNextPaint,\n} from \"../utils/ragImageResolver\";\n\nconst FRIENDLY_ERROR_MESSAGE = \"Oops, something went wrong. Please try again.\";\n\n/**\n * K2 stream manager:\n * - Mirrors answer tokens into `streamingContent` during RUN_IN_PROGRESS\n * - Buffers the final response until RUN_COMPLETED / WORKFLOW_COMPLETED\n * - No throttle interval — UI-side `useTypingEffect` handles animation\n */\nexport function useStreamManagerV2(\n\tconfig: ChatConfig,\n\tcallbacks: ChatCallbacks,\n\tsetMessages: React.Dispatch<React.SetStateAction<MessageDisplay[]>>,\n\tsetIsWaitingForResponse: (waiting: boolean) => void,\n) {\n\tconst abortControllerRef = useRef<AbortController | null>(null);\n\n\tconst configRef = useRef(config);\n\tconfigRef.current = config;\n\tconst callbacksRef = useRef(callbacks);\n\tcallbacksRef.current = callbacks;\n\n\tconst startStream = useCallback(\n\t\tasync (\n\t\t\tuserMessage: string,\n\t\t\tstreamingId: string,\n\t\t\tsessionId?: string,\n\t\t\texternalAbortController?: AbortController,\n\t\t\toptions?: { analysisMode?: AnalysisMode },\n\t\t): Promise<string | undefined> => {\n\t\t\tabortControllerRef.current?.abort();\n\t\t\tconst abortController = externalAbortController ?? new AbortController();\n\t\t\tabortControllerRef.current = abortController;\n\n\t\t\tconst state = createInitialV2State();\n\n\t\t\tconst updateMessage = (update: Partial<MessageDisplay>) => {\n\t\t\t\tif (abortController.signal.aborted) return;\n\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\tmsg.id === streamingId ? { ...msg, ...update } : msg,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst currentConfig = configRef.current;\n\t\t\t\tconst requestBody = buildRequestBody(\n\t\t\t\t\tcurrentConfig,\n\t\t\t\t\tuserMessage,\n\t\t\t\t\tsessionId,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tconst url = buildStreamingUrl(currentConfig);\n\t\t\t\tconst headers = buildRequestHeaders(currentConfig);\n\n\t\t\t\tawait streamWorkflowEvents(url, requestBody, headers, {\n\t\t\t\t\tsignal: abortController.signal,\n\t\t\t\t\tonEvent: (event: StreamEvent) => {\n\t\t\t\t\t\tif (abortController.signal.aborted) return;\n\n\t\t\t\t\t\t// ── DIAGNOSTIC: print every streaming event ──────────────\n\t\t\t\t\t\t// Token deltas are noisy, so collapse RUN_IN_PROGRESS to a\n\t\t\t\t\t\t// length; everything else prints in full.\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst et = (event as any)?.eventType;\n\t\t\t\t\t\t\tif (et === \"RUN_IN_PROGRESS\" || et === \"INTENT_PROGRESS\" || et === \"THINKING_DELTA\") {\n\t\t\t\t\t\t\t\tconst len = ((event as any).partialText ?? (event as any).text ?? \"\").length;\n\t\t\t\t\t\t\t\tconsole.log(`[stream] ${et} (+${len} chars)`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsole.log(`[stream] ${et ?? \"?\"}:`, JSON.stringify(event));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tconsole.log(\"[stream] (unserializable event)\", (event as any)?.eventType);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// KEEP_ALIVE used to early-return here as a no-op\n\t\t\t\t\t\t// liveness tick. Server now attaches a rotating\n\t\t\t\t\t\t// `description` phrase during silent-think gaps so\n\t\t\t\t\t\t// the chat bubble status line changes instead of\n\t\t\t\t\t\t// freezing on \"Thinking…\". processStreamEventV2 owns\n\t\t\t\t\t\t// that mirroring; we fall through to updateMessage\n\t\t\t\t\t\t// so the new phrase actually reaches the UI.\n\t\t\t\t\t\tprocessStreamEventV2(event, state);\n\n\t\t\t\t\t\t// Dispatch user-action callbacks from the transient\n\t\t\t\t\t\t// signals the processor set for THIS event. A\n\t\t\t\t\t\t// `USER_ACTION_REQUIRED` whose action is a notification\n\t\t\t\t\t\t// surfaces via `lastNotification` instead of\n\t\t\t\t\t\t// `lastUserAction`.\n\t\t\t\t\t\tif (state.lastUserAction) {\n\t\t\t\t\t\t\tcallbacksRef.current.onUserActionRequired?.(state.lastUserAction);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (state.lastNotification) {\n\t\t\t\t\t\t\tcallbacksRef.current.onUserNotification?.(state.lastNotification);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst activeStep = state.steps.find((s) => s.id === state.currentExecutingStepId);\n\t\t\t\t\t\tconst lastInProgressStep = [...state.steps].reverse().find((s) => s.status === \"in_progress\");\n\t\t\t\t\t\t// Bland default-start labels like \"Executing…\" / \"Working\n\t\t\t\t\t\t// on it…\" come from each pipeline stage's\n\t\t\t\t\t\t// defaultStartMessage on the server. They flicker into the\n\t\t\t\t\t\t// chat bubble for the moment between an analyzer's dynamic\n\t\t\t\t\t\t// \"Pulling those up…\" status and the first tool call's\n\t\t\t\t\t\t// real \"Got 437 transactions\" — replacing useful info\n\t\t\t\t\t\t// with placeholder noise. Filter them out so the user\n\t\t\t\t\t\t// sees the most-recent SUBSTANTIVE message instead.\n\t\t\t\t\t\tconst useful = (m: string | undefined): string | undefined =>\n\t\t\t\t\t\t\tm && !isBlandStatus(m) ? m : undefined;\n\t\t\t\t\t\t// Walk backwards for the most recent USEFUL step message.\n\t\t\t\t\t\t// If executor just started with bland \"Executing…\" and\n\t\t\t\t\t\t// analyzer is done with \"Pulling those up for you now\",\n\t\t\t\t\t\t// we want analyzer's — bland on the latest step must\n\t\t\t\t\t\t// NOT shadow useful older ones. Previously latestWithMessage\n\t\t\t\t\t\t// returned the bland top-of-stack step and the candidate\n\t\t\t\t\t\t// chain fell through to the last-resort bland fallback even\n\t\t\t\t\t\t// though useful messages existed deeper in the stack.\n\t\t\t\t\t\tconst latestUsefulStep = [...state.steps].reverse().find(\n\t\t\t\t\t\t\t(s) => s.message && !isBlandStatus(s.message),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst currentMessage =\n\t\t\t\t\t\t\tuseful(activeStep?.message) ??\n\t\t\t\t\t\t\tuseful(lastInProgressStep?.message) ??\n\t\t\t\t\t\t\tlatestUsefulStep?.message ??\n\t\t\t\t\t\t\tuseful(getEventMessage(event)) ??\n\t\t\t\t\t\t\t// Last-resort: every candidate is bland (very first event,\n\t\t\t\t\t\t\t// nothing useful seen yet). Render the bland label so the\n\t\t\t\t\t\t\t// bubble isn't blank.\n\t\t\t\t\t\t\tactiveStep?.message ??\n\t\t\t\t\t\t\tlastInProgressStep?.message ??\n\t\t\t\t\t\t\tgetEventMessage(event);\n\t\t\t\t\t\t// Notify consumers of every status-message change so a\n\t\t\t\t\t\t// surface outside the chat bubble (pipeline sidebar,\n\t\t\t\t\t\t// agent-avatar label) can mirror it without re-parsing\n\t\t\t\t\t\t// the event stream. Debounced implicitly by React\n\t\t\t\t\t\t// reconciliation — the callback fires every event but\n\t\t\t\t\t\t// consumers typically setState against it and React\n\t\t\t\t\t\t// dedups.\n\t\t\t\t\t\tif (currentMessage) {\n\t\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(currentMessage);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Give the host app the full steps snapshot so\n\t\t\t\t\t\t// pipeline-sidebar UIs can derive per-stage status\n\t\t\t\t\t\t// without reverse-mapping labels. Only fire when\n\t\t\t\t\t\t// steps actually changed (every STAGE_* event).\n\t\t\t\t\t\tcallbacksRef.current.onStepsUpdate?.([...state.steps]);\n\n\t\t\t\t\t\tif (state.hasError) {\n\t\t\t\t\t\t\tupdateMessage({\n\t\t\t\t\t\t\t\tstreamingContent: FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\tcontent: FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\tstreamProgress: \"error\",\n\t\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\t\terrorDetails: state.errorMessage,\n\t\t\t\t\t\t\t\tsteps: [...state.steps],\n\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t\tsessionId: state.sessionId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Mirror state.finalResponse into streamingContent\n\t\t\t\t\t\t\t// as it builds up from INTENT_PROGRESS deltas.\n\t\t\t\t\t\t\t// The k2 Formatter streams its LLM output chunk-\n\t\t\t\t\t\t\t// by-chunk; this is how the user sees the answer\n\t\t\t\t\t\t\t// build in real time instead of staring at a\n\t\t\t\t\t\t\t// blank screen for the ~2-3s the LLM takes.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Pre-streaming servers never emit partial text,\n\t\t\t\t\t\t\t// so state.finalResponse stays \"\" until\n\t\t\t\t\t\t\t// WORKFLOW_COMPLETED — rendering \"\" here matches\n\t\t\t\t\t\t\t// the old behavior exactly for that case.\n\t\t\t\t\t\t\tupdateMessage({\n\t\t\t\t\t\t\t\tstreamingContent: state.finalResponse,\n\t\t\t\t\t\t\t\tcontent: \"\",\n\t\t\t\t\t\t\t\tcurrentMessage,\n\t\t\t\t\t\t\t\tstreamProgress: \"processing\",\n\t\t\t\t\t\t\t\tisError: false,\n\t\t\t\t\t\t\t\tsteps: [...state.steps],\n\t\t\t\t\t\t\t\tcurrentExecutingStepId: state.currentExecutingStepId,\n\t\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t\tsessionId: state.sessionId,\n\t\t\t\t\t\t\t\tisCancelled: false,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonError: (error: Error) => {\n\t\t\t\t\t\tsetIsWaitingForResponse(false);\n\t\t\t\t\t\t// Clear any status-message consumers are mirroring —\n\t\t\t\t\t\t// the run is over, whatever was last showing is\n\t\t\t\t\t\t// stale now.\n\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(null);\n\n\t\t\t\t\t\tif (error.name !== \"AbortError\") {\n\t\t\t\t\t\t\tcallbacksRef.current.onError?.(error);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst isAborted = error.name === \"AbortError\";\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\t\t\t\t\tstreamProgress: isAborted ? (\"processing\" as const) : (\"error\" as const),\n\t\t\t\t\t\t\t\t\t\t\tisError: !isAborted,\n\t\t\t\t\t\t\t\t\t\t\tisCancelled: isAborted,\n\t\t\t\t\t\t\t\t\t\t\terrorDetails: isAborted ? undefined : error.message,\n\t\t\t\t\t\t\t\t\t\t\tcontent: isAborted\n\t\t\t\t\t\t\t\t\t\t\t\t? state.finalResponse || \"\"\n\t\t\t\t\t\t\t\t\t\t\t\t: state.finalResponse || FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\t\t\t\tcurrentMessage: isAborted ? \"Thinking...\" : undefined,\n\t\t\t\t\t\t\t\t\t\t\tsteps: [...state.steps].map((step) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (step.status === \"in_progress\" && isAborted) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn step;\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tonComplete: () => {\n\t\t\t\t\t\tsetIsWaitingForResponse(false);\n\t\t\t\t\t\t// Run is over — consumers tracking the status\n\t\t\t\t\t\t// message should clear their label / revert to\n\t\t\t\t\t\t// whatever default (agent name, blank).\n\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(null);\n\t\t\t\t\t\t// Reset the steps snapshot so pipeline-sidebar\n\t\t\t\t\t\t// UIs can revert all stages back to idle.\n\t\t\t\t\t\tcallbacksRef.current.onStepsUpdate?.([]);\n\n\t\t\t\t\t\tif (state.sessionId && state.sessionId !== sessionId) {\n\t\t\t\t\t\t\tcallbacksRef.current.onSessionIdChange?.(state.sessionId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst needsImageResolve =\n\t\t\t\t\t\t\t!state.hasError &&\n\t\t\t\t\t\t\t!abortController.signal.aborted &&\n\t\t\t\t\t\t\thasRagImages(state.finalResponse);\n\n\t\t\t\t\t\tconst finalMessage: MessageDisplay = {\n\t\t\t\t\t\t\tid: streamingId,\n\t\t\t\t\t\t\tsessionId: state.sessionId || sessionId,\n\t\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\t\tcontent: state.hasError ? FRIENDLY_ERROR_MESSAGE : state.finalResponse || \"\",\n\t\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\tstreamProgress: state.hasError ? \"error\" : \"completed\",\n\t\t\t\t\t\t\tisError: state.hasError,\n\t\t\t\t\t\t\terrorDetails: state.hasError ? state.errorMessage : undefined,\n\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t// Defensive: tracingData must be an object (or undefined)\n\t\t\t\t\t\t\t// so the JSON viewer doesn't char-iterate a string. The\n\t\t\t\t\t\t\t// event processor already drops bare strings; this is\n\t\t\t\t\t\t\t// the last stop before the message leaves the SDK.\n\t\t\t\t\t\t\ttracingData:\n\t\t\t\t\t\t\t\tstate.finalData != null && typeof state.finalData === \"object\"\n\t\t\t\t\t\t\t\t\t? state.finalData\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsteps: state.hasError ? [] : [...state.steps],\n\t\t\t\t\t\t\tisCancelled: false,\n\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\tisResolvingImages: needsImageResolve,\n\t\t\t\t\t\t\ttotalElapsedMs: state.hasError ? undefined : state.totalElapsedMs,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId ? finalMessage : msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcallbacksRef.current.onStreamComplete?.(finalMessage);\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tconst shouldResolveImages =\n\t\t\t\t\t!abortController.signal.aborted &&\n\t\t\t\t\t!state.hasError &&\n\t\t\t\t\thasRagImages(state.finalResponse);\n\n\t\t\t\tif (shouldResolveImages) {\n\t\t\t\t\tawait waitForNextPaint(abortController.signal);\n\t\t\t\t}\n\n\t\t\t\tif (shouldResolveImages && !abortController.signal.aborted) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst resolvedContent = await resolveRagImageUrls(\n\t\t\t\t\t\t\tcurrentConfig,\n\t\t\t\t\t\t\tstate.finalResponse,\n\t\t\t\t\t\t\tabortController.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t\t\t? { ...msg, content: resolvedContent, isResolvingImages: false }\n\t\t\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId ? { ...msg, isResolvingImages: false } : msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn state.sessionId;\n\t\t\t} catch (error) {\n\t\t\t\tsetIsWaitingForResponse(false);\n\n\t\t\t\tif ((error as Error).name !== \"AbortError\") {\n\t\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\t}\n\n\t\t\t\tconst isAborted = (error as Error).name === \"AbortError\";\n\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\t\t\tstreamProgress: isAborted ? (\"processing\" as const) : (\"error\" as const),\n\t\t\t\t\t\t\t\t\tisError: !isAborted,\n\t\t\t\t\t\t\t\t\tisCancelled: isAborted,\n\t\t\t\t\t\t\t\t\terrorDetails: isAborted ? undefined : (error as Error).message,\n\t\t\t\t\t\t\t\t\tcontent: isAborted\n\t\t\t\t\t\t\t\t\t\t? state.finalResponse || \"\"\n\t\t\t\t\t\t\t\t\t\t: state.finalResponse || FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\t\tsteps: [...state.steps].map((step) => {\n\t\t\t\t\t\t\t\t\t\tif (step.status === \"in_progress\" && isAborted) {\n\t\t\t\t\t\t\t\t\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn step;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn state.sessionId;\n\t\t\t}\n\t\t},\n\t\t[setMessages, setIsWaitingForResponse],\n\t);\n\n\tconst cancelStream = useCallback(() => {\n\t\tabortControllerRef.current?.abort();\n\t}, []);\n\n\treturn {\n\t\tstartStream,\n\t\tcancelStream,\n\t\tabortControllerRef,\n\t};\n}\n","import type { MessageDisplay, StreamingStep } from \"../types\";\n\n/**\n * Create cancelled message update\n */\nexport function createCancelledMessageUpdate(\n\tsteps: StreamingStep[],\n\tcurrentMessage?: string\n): Partial<MessageDisplay> {\n\tconst updatedSteps = steps.map((step) => {\n\t\tif (step.status === \"in_progress\") {\n\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t}\n\t\treturn step;\n\t});\n\n\treturn {\n\t\tisStreaming: false,\n\t\tisCancelled: true,\n\t\tsteps: updatedSteps,\n\t\tcurrentExecutingStepId: undefined,\n\t\tcurrentMessage: currentMessage || \"Thinking...\",\n\t};\n}\n","import type { ChatConfig } from \"../types\";\nimport { buildUserActionUrl, buildRequestHeaders } from \"./requestBuilder\";\n\ntype UserActionResponse = {\n\tsuccess: boolean;\n\tmessage: string;\n};\n\n/**\n * Thrown when a resolution endpoint returns `404`\n * (`user_action_not_found`): the prompt already resolved, expired, or\n * the id is unknown. Callers should treat the prompt as no longer\n * actionable — stop any countdown and clear the form — rather than\n * surfacing this as a hard error.\n */\nexport class UserActionStaleError extends Error {\n\treadonly userActionId: string;\n\tconstructor(userActionId: string, message = \"User action is no longer actionable\") {\n\t\tsuper(message);\n\t\tthis.name = \"UserActionStaleError\";\n\t\tthis.userActionId = userActionId;\n\t}\n}\n\n/**\n * Internal helper — sends a POST to a user-action endpoint and returns the\n * parsed JSON response. Throws `UserActionStaleError` on 404 and a\n * generic error on other non-2xx status / JSON parse failure.\n */\nasync function sendUserActionRequest(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\taction: \"submit\" | \"cancel\" | \"resend\",\n\tdata?: Record<string, unknown>,\n): Promise<UserActionResponse> {\n\tconst url = buildUserActionUrl(config, userActionId, action);\n\tconst baseHeaders = buildRequestHeaders(config);\n\tconst hasBody = data !== undefined;\n\tconst headers = hasBody\n\t\t? { \"Content-Type\": \"application/json\", ...baseHeaders }\n\t\t: baseHeaders;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: hasBody ? JSON.stringify(data) : undefined,\n\t});\n\n\tif (response.status === 404) {\n\t\tthrow new UserActionStaleError(userActionId);\n\t}\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t}\n\n\treturn await response.json();\n}\n\n/**\n * Submit a user action. `content` is the schema-typed form payload sent\n * straight through to the agent (its keys should match the prompt's\n * `requestedSchema.properties`) — e.g. `{ otp: \"123456\" }` for a\n * verification prompt or `{ amount: 50, confirm: true }` for a form.\n */\nexport async function submitUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\tcontent?: Record<string, unknown>,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"submit\", content ?? {});\n}\n\n/**\n * Cancel / reject a user action\n */\nexport async function cancelUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"cancel\");\n}\n\n/**\n * Resend a user action (e.g. request a new OTP)\n */\nexport async function resendUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"resend\");\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n\tActiveUserAction,\n\tChatCallbacks,\n\tChatConfig,\n\tMessageDisplay,\n\tUserActionRequest,\n\tUserActionState,\n} from \"../types\";\nimport { generateId } from \"../utils/generateId\";\nimport { chatStore } from \"../utils/chatStore\";\nimport { activeStreamStore } from \"../utils/activeStreamStore\";\nimport { useStreamManagerV2 } from \"./useStreamManagerV2\";\nimport type { AnalysisMode } from \"../utils/requestBuilder\";\nimport { createCancelledMessageUpdate } from \"../utils/messageStateManager\";\nimport {\n\tsubmitUserAction as submitUserActionApi,\n\tcancelUserAction as cancelUserActionApi,\n\tresendUserAction as resendUserActionApi,\n\tUserActionStaleError,\n} from \"../utils/userActionClient\";\n\nconst EMPTY_USER_ACTION_STATE: UserActionState = { prompts: [], notifications: [] };\n\n/**\n * Upsert a prompt applying the supersede rule: a request matching an\n * existing slot's `toolCallId` (a retry/resend, possibly with a new\n * `userActionId`) REPLACES that slot in place; otherwise it's appended\n * as a new (parallel) prompt.\n */\nfunction upsertPrompt(\n\tprompts: ActiveUserAction[],\n\treq: UserActionRequest,\n): ActiveUserAction[] {\n\tconst active: ActiveUserAction = { ...req, status: \"pending\" };\n\tconst idx = prompts.findIndex((p) =>\n\t\treq.toolCallId\n\t\t\t? p.toolCallId === req.toolCallId\n\t\t\t: p.userActionId === req.userActionId,\n\t);\n\tif (idx >= 0) {\n\t\tconst next = prompts.slice();\n\t\tnext[idx] = active;\n\t\treturn next;\n\t}\n\treturn [...prompts, active];\n}\n\nexport type SendMessageOptions = {\n\t/**\n\t * Latency-vs-precision toggle surfaced in the chat widget.\n\t * `\"fast\"` (default) — the server caps list-tool fetches and\n\t * returns a quick, directionally correct answer with a sampling\n\t * caveat. `\"deep\"` — the server runs a full analytical pass,\n\t * no row caps, full rankings.\n\t *\n\t * Undefined / omitted means \"don't set — let the server use its\n\t * default\", which is `\"fast\"` today. Callers that want explicit\n\t * control should always pass this; callers that don't care can\n\t * skip it and inherit the server default.\n\t */\n\tanalysisMode?: AnalysisMode;\n};\n\nexport type UseChatV2Return = {\n\tmessages: MessageDisplay[];\n\tsendMessage: (userMessage: string, options?: SendMessageOptions) => Promise<void>;\n\tclearMessages: () => void;\n\tprependMessages: (messages: MessageDisplay[]) => void;\n\tcancelStream: () => void;\n\tresetSession: () => void;\n\tgetSessionId: () => string | undefined;\n\tgetMessages: () => MessageDisplay[];\n\tisWaitingForResponse: boolean;\n\tsessionId: string | undefined;\n\t/** Active user-action prompts + one-way notifications for this chat. */\n\tuserActionState: UserActionState;\n\t/**\n\t * Submit a prompt's form payload. `content` keys should match the\n\t * prompt's `requestedSchema.properties` (e.g. `{ otp: \"123456\" }`).\n\t */\n\tsubmitUserAction: (userActionId: string, content: Record<string, unknown>) => Promise<void>;\n\t/** Cancel / decline a prompt. */\n\tcancelUserAction: (userActionId: string) => Promise<void>;\n\t/** Ask the agent to re-send a prompt (e.g. resend a verification code). */\n\tresendUserAction: (userActionId: string) => Promise<void>;\n\t/** Dismiss a one-way notification from local state. */\n\tdismissNotification: (id: string) => void;\n};\n\nfunction getStoredOrInitialMessages(config: ChatConfig): MessageDisplay[] {\n\tif (!config.userId) return config.initialMessages ?? [];\n\n\t// Active stream takes highest priority — avoids flash when restoring a streaming session\n\tconst activeStream = activeStreamStore.get(config.userId);\n\tif (activeStream) return activeStream.messages;\n\n\tconst stored = chatStore.get(config.userId);\n\tif (stored.length > 0) return stored;\n\n\tif (config.initialMessages?.length) {\n\t\tchatStore.set(config.userId, config.initialMessages);\n\t\treturn config.initialMessages;\n\t}\n\n\treturn [];\n}\n\nfunction getSessionIdFromMessages(messages: MessageDisplay[]): string | undefined {\n\treturn messages.find((message) => message.sessionId)?.sessionId;\n}\n\nexport function useChatV2(config: ChatConfig, callbacks: ChatCallbacks = {}): UseChatV2Return {\n\tconst [messages, setMessages] = useState<MessageDisplay[]>(() => getStoredOrInitialMessages(config));\n\tconst [isWaitingForResponse, setIsWaitingForResponse] = useState(() => {\n\t\tif (!config.userId) return false;\n\t\treturn activeStreamStore.get(config.userId)?.isWaiting ?? false;\n\t});\n\tconst sessionIdRef = useRef<string | undefined>(\n\t\tgetSessionIdFromMessages(getStoredOrInitialMessages(config)) ?? config.initialSessionId ?? undefined,\n\t);\n\tconst prevUserIdRef = useRef<string | undefined>(config.userId);\n\t// Tracks the userId that was active when sendMessage was called — locked for the stream's lifetime\n\tconst streamUserIdRef = useRef<string | undefined>(undefined);\n\t// Tracks the previous userId seen by the subscription effect — used to detect renames\n\tconst subscriptionPrevUserIdRef = useRef<string | undefined>(config.userId);\n\n\tconst callbacksRef = useRef(callbacks);\n\tcallbacksRef.current = callbacks;\n\tconst configRef = useRef(config);\n\tconfigRef.current = config;\n\tconst messagesRef = useRef(messages);\n\tmessagesRef.current = messages;\n\n\tconst storeAwareSetMessages = useCallback<React.Dispatch<React.SetStateAction<MessageDisplay[]>>>(\n\t\t(updater) => {\n\t\t\t// Use the locked stream userId (set at sendMessage time) so background stream\n\t\t\t// updates go to the right store key even if the user switches sessions.\n\t\t\tconst streamUserId = streamUserIdRef.current;\n\t\t\tconst currentUserId = configRef.current.userId;\n\t\t\tconst storeKey = streamUserId ?? currentUserId;\n\t\t\tif (storeKey && activeStreamStore.has(storeKey)) {\n\t\t\t\tactiveStreamStore.applyMessages(storeKey, updater as MessageDisplay[] | ((prev: MessageDisplay[]) => MessageDisplay[]));\n\t\t\t}\n\t\t\t// Only update React state when on the same session as the running stream\n\t\t\tif (!streamUserId || streamUserId === currentUserId) {\n\t\t\t\tsetMessages(updater);\n\t\t\t}\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[],\n\t);\n\n\tconst storeAwareSetIsWaiting = useCallback(\n\t\t(waiting: boolean) => {\n\t\t\tconst streamUserId = streamUserIdRef.current;\n\t\t\tconst currentUserId = configRef.current.userId;\n\t\t\tconst storeKey = streamUserId ?? currentUserId;\n\t\t\tif (storeKey && activeStreamStore.has(storeKey)) {\n\t\t\t\tactiveStreamStore.setWaiting(storeKey, waiting);\n\t\t\t}\n\t\t\tif (!streamUserId || streamUserId === currentUserId) {\n\t\t\t\tsetIsWaitingForResponse(waiting);\n\t\t\t}\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[],\n\t);\n\n\tconst [userActionState, setUserActionState] = useState<UserActionState>(EMPTY_USER_ACTION_STATE);\n\n\tconst wrappedCallbacks = useMemo<ChatCallbacks>(() => ({\n\t\t...callbacksRef.current,\n\t\tonMessageSent: (message) => callbacksRef.current.onMessageSent?.(message),\n\t\tonStreamStart: () => callbacksRef.current.onStreamStart?.(),\n\t\tonStreamComplete: (message) => callbacksRef.current.onStreamComplete?.(message),\n\t\tonError: (error) => callbacksRef.current.onError?.(error),\n\t\tonExecutionTraceClick: (data) => callbacksRef.current.onExecutionTraceClick?.(data),\n\t\tonSessionIdChange: (sessionId) => callbacksRef.current.onSessionIdChange?.(sessionId),\n\t\tonUserActionRequired: (request) => {\n\t\t\tsetUserActionState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\tprompts: upsertPrompt(prev.prompts, request),\n\t\t\t}));\n\t\t\tcallbacksRef.current.onUserActionRequired?.(request);\n\t\t},\n\t\tonUserNotification: (notification) => {\n\t\t\tsetUserActionState((prev) =>\n\t\t\t\tprev.notifications.some((n) => n.id === notification.id)\n\t\t\t\t\t? prev\n\t\t\t\t\t: { ...prev, notifications: [...prev.notifications, notification] },\n\t\t\t);\n\t\t\tcallbacksRef.current.onUserNotification?.(notification);\n\t\t},\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}), []);\n\n\tconst { startStream, cancelStream: cancelStreamManager, abortControllerRef } = useStreamManagerV2(\n\t\tconfig,\n\t\twrappedCallbacks,\n\t\tstoreAwareSetMessages,\n\t\tstoreAwareSetIsWaiting,\n\t);\n\n\tconst sendMessage = useCallback(\n\t\tasync (userMessage: string, options?: SendMessageOptions) => {\n\t\t\tif (!userMessage.trim()) return;\n\n\t\t\tif (!sessionIdRef.current && configRef.current.autoGenerateSessionId !== false) {\n\t\t\t\tsessionIdRef.current = generateId();\n\t\t\t\tcallbacksRef.current.onSessionIdChange?.(sessionIdRef.current);\n\t\t\t}\n\n\t\t\tconst userMessageId = `user-${Date.now()}`;\n\t\t\tconst userMsg: MessageDisplay = {\n\t\t\t\tid: userMessageId,\n\t\t\t\tsessionId: sessionIdRef.current,\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: userMessage,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t};\n\n\t\t\tsetMessages((prev) => [...prev, userMsg]);\n\t\t\tcallbacksRef.current.onMessageSent?.(userMessage);\n\t\t\tsetIsWaitingForResponse(true);\n\t\t\tcallbacksRef.current.onStreamStart?.();\n\n\t\t\tconst streamingId = `assistant-${Date.now()}`;\n\t\t\tconst streamingMsg: MessageDisplay = {\n\t\t\t\tid: streamingId,\n\t\t\t\tsessionId: sessionIdRef.current,\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: \"\",\n\t\t\t\tstreamingContent: \"\",\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tisStreaming: true,\n\t\t\t\tstreamProgress: \"started\",\n\t\t\t\tsteps: [],\n\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\tisCancelled: false,\n\t\t\t\tcurrentMessage: undefined,\n\t\t\t};\n\n\t\t\tsetMessages((prev) => [...prev, streamingMsg]);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst { userId } = configRef.current;\n\t\t\tif (userId) {\n\t\t\t\tstreamUserIdRef.current = userId;\n\t\t\t\tconst initialMessages = [...messagesRef.current, userMsg, streamingMsg];\n\t\t\t\tactiveStreamStore.start(userId, abortController, initialMessages);\n\t\t\t}\n\n\t\t\tconst newSessionId = await startStream(\n\t\t\t\tuserMessage,\n\t\t\t\tstreamingId,\n\t\t\t\tsessionIdRef.current,\n\t\t\t\tabortController,\n\t\t\t\toptions,\n\t\t\t);\n\n\t\t\t// Use streamUserIdRef in case it was updated by a rename (onSessionIdChange)\n\t\t\tconst finalStreamUserId = streamUserIdRef.current ?? userId;\n\t\t\tif (finalStreamUserId) {\n\t\t\t\tactiveStreamStore.complete(finalStreamUserId);\n\t\t\t}\n\t\t\tstreamUserIdRef.current = undefined;\n\n\t\t\tif (!abortController.signal.aborted && newSessionId && newSessionId !== sessionIdRef.current) {\n\t\t\t\tsessionIdRef.current = newSessionId;\n\t\t\t}\n\t\t},\n\t\t[startStream],\n\t);\n\n\tconst clearMessages = useCallback(() => {\n\t\tif (configRef.current.userId) {\n\t\t\tchatStore.delete(configRef.current.userId);\n\t\t}\n\t\tsetMessages([]);\n\t}, []);\n\n\tconst prependMessages = useCallback((msgs: MessageDisplay[]) => {\n\t\tsetMessages((prev) => [...msgs, ...prev]);\n\t}, []);\n\n\tconst cancelStream = useCallback(() => {\n\t\tconst streamUserId = streamUserIdRef.current ?? configRef.current.userId;\n\t\tif (streamUserId) {\n\t\t\tactiveStreamStore.abort(streamUserId);\n\t\t}\n\t\tstreamUserIdRef.current = undefined;\n\t\tcancelStreamManager();\n\t\tsetIsWaitingForResponse(false);\n\t\tsetUserActionState((prev) => ({ ...prev, prompts: [] }));\n\n\t\tsetMessages((prev) =>\n\t\t\tprev.map((msg) => {\n\t\t\t\tif (msg.isStreaming) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t...createCancelledMessageUpdate(\n\t\t\t\t\t\t\tmsg.steps || [],\n\t\t\t\t\t\t\tmsg.currentMessage,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn msg;\n\t\t\t}),\n\t\t);\n\t}, [cancelStreamManager]);\n\n\tconst resetSession = useCallback(() => {\n\t\tconst streamUserId = streamUserIdRef.current ?? configRef.current.userId;\n\t\tif (streamUserId) {\n\t\t\tactiveStreamStore.abort(streamUserId);\n\t\t}\n\t\tif (configRef.current.userId) {\n\t\t\tchatStore.delete(configRef.current.userId);\n\t\t}\n\t\tstreamUserIdRef.current = undefined;\n\t\tsetMessages([]);\n\t\tsessionIdRef.current = undefined;\n\t\tabortControllerRef.current?.abort();\n\t\tsetIsWaitingForResponse(false);\n\t\tsetUserActionState(EMPTY_USER_ACTION_STATE);\n\t}, []);\n\n\tconst getSessionId = useCallback(() => {\n\t\treturn sessionIdRef.current;\n\t}, []);\n\n\tconst getMessages = useCallback(() => {\n\t\treturn messages;\n\t}, [messages]);\n\n\tconst setPromptStatus = useCallback(\n\t\t(userActionId: string, status: ActiveUserAction[\"status\"]) => {\n\t\t\tsetUserActionState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\tprompts: prev.prompts.map((p) =>\n\t\t\t\t\tp.userActionId === userActionId ? { ...p, status } : p,\n\t\t\t\t),\n\t\t\t}));\n\t\t},\n\t\t[],\n\t);\n\n\tconst removePrompt = useCallback((userActionId: string) => {\n\t\tsetUserActionState((prev) => ({\n\t\t\t...prev,\n\t\t\tprompts: prev.prompts.filter((p) => p.userActionId !== userActionId),\n\t\t}));\n\t}, []);\n\n\tconst submitUserAction = useCallback(\n\t\tasync (userActionId: string, content: Record<string, unknown>) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait submitUserActionApi(configRef.current, userActionId, content);\n\t\t\t\t// Endpoint accepted the resolution: the run resumes on the\n\t\t\t\t// open stream. Drop the slot — if the input was invalid the\n\t\t\t\t// server emits a fresh USER_ACTION_REQUIRED (subAction\n\t\t\t\t// \"SubmissionInvalid\") that re-adds it.\n\t\t\t\tremovePrompt(userActionId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tsetPromptStatus(userActionId, \"stale\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Recoverable failure — let the user retry the same prompt.\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[removePrompt, setPromptStatus],\n\t);\n\n\tconst cancelUserAction = useCallback(\n\t\tasync (userActionId: string) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait cancelUserActionApi(configRef.current, userActionId);\n\t\t\t\tremovePrompt(userActionId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tremovePrompt(userActionId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[removePrompt, setPromptStatus],\n\t);\n\n\tconst resendUserAction = useCallback(\n\t\tasync (userActionId: string) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait resendUserActionApi(configRef.current, userActionId);\n\t\t\t\t// Keep the slot open; the server pushes a new\n\t\t\t\t// USER_ACTION_REQUIRED (\"RequestResent\") that supersedes it.\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tsetPromptStatus(userActionId, \"stale\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[setPromptStatus],\n\t);\n\n\tconst dismissNotification = useCallback((id: string) => {\n\t\tsetUserActionState((prev) => ({\n\t\t\t...prev,\n\t\t\tnotifications: prev.notifications.filter((n) => n.id !== id),\n\t\t}));\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst prevSubscriptionUserId = subscriptionPrevUserIdRef.current;\n\t\tsubscriptionPrevUserIdRef.current = config.userId;\n\t\tconst { userId } = config;\n\t\tif (!userId) return;\n\n\t\t// Detect when the stream was renamed (e.g. server assigned a new session ID via\n\t\t// migrateActiveStream in the app): old key is gone, new key has the stream,\n\t\t// and streamUserIdRef still points to the old key.\n\t\tif (\n\t\t\tprevSubscriptionUserId &&\n\t\t\tprevSubscriptionUserId !== userId &&\n\t\t\tstreamUserIdRef.current === prevSubscriptionUserId &&\n\t\t\t!activeStreamStore.has(prevSubscriptionUserId) &&\n\t\t\tactiveStreamStore.has(userId)\n\t\t) {\n\t\t\tstreamUserIdRef.current = userId;\n\t\t}\n\n\t\tconst unsubscribe = activeStreamStore.subscribe(userId, (msgs, isWaiting) => {\n\t\t\tsetMessages(msgs);\n\t\t\tsetIsWaitingForResponse(isWaiting);\n\t\t});\n\t\tconst active = activeStreamStore.get(userId);\n\t\tif (active) {\n\t\t\tsetMessages(active.messages);\n\t\t\tsetIsWaitingForResponse(active.isWaiting);\n\t\t}\n\t\treturn unsubscribe;\n\t}, [config.userId]);\n\n\tuseEffect(() => {\n\t\tif (!config.userId) return;\n\t\t// prevUserIdRef is updated in the userId-change effect which runs *after* this one.\n\t\t// If they differ here, userId just changed and messages still belong to the previous\n\t\t// session — skip so we don't corrupt the new session's chatStore entry.\n\t\tif (prevUserIdRef.current !== config.userId) return;\n\t\tconst toSave = messages.filter((m) => !m.isStreaming);\n\t\tif (toSave.length > 0) {\n\t\t\tchatStore.set(config.userId, toSave);\n\t\t}\n\t}, [messages, config.userId]);\n\n\tuseEffect(() => {\n\t\tif (!config.userId || activeStreamStore.has(config.userId)) return;\n\t\tif (!config.initialMessages?.length || messagesRef.current.length > 0) return;\n\n\t\tchatStore.set(config.userId, config.initialMessages);\n\t\tsetMessages(config.initialMessages);\n\t\tsessionIdRef.current = getSessionIdFromMessages(config.initialMessages) ?? config.initialSessionId;\n\t}, [config.initialMessages, config.initialSessionId, config.userId]);\n\n\tuseEffect(() => {\n\t\tconst prevUserId = prevUserIdRef.current;\n\t\tprevUserIdRef.current = config.userId;\n\n\t\tif (prevUserId === config.userId) return;\n\n\t\tif (prevUserId && !config.userId) {\n\t\t\tchatStore.delete(prevUserId);\n\t\t\tsetMessages([]);\n\t\t\tsessionIdRef.current = undefined;\n\t\t\tsetIsWaitingForResponse(false);\n\t\t\tsetUserActionState(EMPTY_USER_ACTION_STATE);\n\t\t} else if (config.userId) {\n\t\t\tconst active = activeStreamStore.get(config.userId);\n\t\t\tif (active) {\n\t\t\t\tsetMessages(active.messages);\n\t\t\t\tsetIsWaitingForResponse(active.isWaiting);\n\t\t\t\tsessionIdRef.current = getSessionIdFromMessages(active.messages) ?? config.initialSessionId;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextMessages = getStoredOrInitialMessages(config);\n\t\t\tsetMessages(nextMessages);\n\t\t\tsessionIdRef.current = getSessionIdFromMessages(nextMessages) ?? config.initialSessionId;\n\t\t\tsetIsWaitingForResponse(false);\n\t\t}\n\t}, [config]);\n\n\treturn {\n\t\tmessages,\n\t\tsendMessage,\n\t\tclearMessages,\n\t\tprependMessages,\n\t\tcancelStream,\n\t\tresetSession,\n\t\tgetSessionId,\n\t\tgetMessages,\n\t\tisWaitingForResponse,\n\t\tsessionId: sessionIdRef.current,\n\t\tuserActionState,\n\t\tsubmitUserAction,\n\t\tcancelUserAction,\n\t\tresendUserAction,\n\t\tdismissNotification,\n\t};\n}\n","// ============================================\n// Voice Hook - Web Implementation\n// Uses Web Speech API (SpeechRecognition)\n// ============================================\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n\tVoiceCallbacks,\n\tVoiceConfig,\n\tVoicePermissions,\n\tVoiceState,\n\tUseVoiceReturn,\n} from \"../types/voice\";\n\n// ============================================\n// Web Speech API Types\n// ============================================\n\ninterface SpeechRecognitionEvent extends Event {\n\tresults: SpeechRecognitionResultList;\n\tresultIndex: number;\n}\n\ninterface SpeechRecognitionErrorEvent extends Event {\n\terror: string;\n\tmessage?: string;\n}\n\ninterface SpeechRecognition extends EventTarget {\n\tcontinuous: boolean;\n\tinterimResults: boolean;\n\tlang: string;\n\tmaxAlternatives: number;\n\tstart(): void;\n\tstop(): void;\n\tabort(): void;\n\tonstart: ((this: SpeechRecognition, ev: Event) => any) | null;\n\tonend: ((this: SpeechRecognition, ev: Event) => any) | null;\n\tonresult:\n\t\t| ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any)\n\t\t| null;\n\tonerror:\n\t\t| ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any)\n\t\t| null;\n}\n\ninterface SpeechRecognitionConstructor {\n\tnew (): SpeechRecognition;\n}\n\ndeclare global {\n\tinterface Window {\n\t\tSpeechRecognition?: SpeechRecognitionConstructor;\n\t\twebkitSpeechRecognition?: SpeechRecognitionConstructor;\n\t}\n}\n\n// ============================================\n// Helper Functions\n// ============================================\n\nfunction getSpeechRecognition(): SpeechRecognitionConstructor | null {\n\tif (typeof window === \"undefined\") return null;\n\treturn window.SpeechRecognition || window.webkitSpeechRecognition || null;\n}\n\n// ============================================\n// Hook Implementation\n// ============================================\n\nexport function useVoice(\n\tconfig: VoiceConfig = {},\n\tcallbacks: VoiceCallbacks = {}\n): UseVoiceReturn {\n\tconst [voiceState, setVoiceState] = useState<VoiceState>(\"idle\");\n\tconst [transcribedText, setTranscribedText] = useState(\"\");\n\tconst [isAvailable, setIsAvailable] = useState(false);\n\tconst [isRecording, setIsRecording] = useState(false);\n\n\tconst recognitionRef = useRef<SpeechRecognition | null>(null);\n\tconst autoStopTimerRef = useRef<NodeJS.Timeout | null>(null);\n\n\tconst {\n\t\tlang = \"en-US\",\n\t\tinterimResults = true,\n\t\tcontinuous = true,\n\t\tmaxAlternatives = 1,\n\t\tautoStopAfterSilence,\n\t} = config;\n\n\tconst { onStart, onEnd, onResult, onError, onStateChange } = callbacks;\n\n\t// Check speech recognition availability\n\tuseEffect(() => {\n\t\tconst SpeechRecognitionAPI = getSpeechRecognition();\n\t\tsetIsAvailable(SpeechRecognitionAPI !== null);\n\t}, []);\n\n\t// Notify state changes\n\tuseEffect(() => {\n\t\tonStateChange?.(voiceState);\n\t}, [voiceState, onStateChange]);\n\n\t// Request permissions (web prompts automatically on start)\n\tconst requestPermissions = useCallback(async (): Promise<VoicePermissions> => {\n\t\ttry {\n\t\t\tconst result = await navigator.mediaDevices.getUserMedia({\n\t\t\t\taudio: true,\n\t\t\t});\n\t\t\t// Stop the stream immediately, we just wanted to check permissions\n\t\t\tresult.getTracks().forEach((track) => track.stop());\n\n\t\t\treturn {\n\t\t\t\tgranted: true,\n\t\t\t\tstatus: \"granted\",\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"denied\",\n\t\t\t};\n\t\t}\n\t}, []);\n\n\t// Get permissions\n\tconst getPermissions = useCallback(async (): Promise<VoicePermissions> => {\n\t\tif (typeof navigator === \"undefined\" || !navigator.permissions) {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"undetermined\",\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await navigator.permissions.query({\n\t\t\t\tname: \"microphone\" as PermissionName,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tgranted: result.state === \"granted\",\n\t\t\t\tstatus:\n\t\t\t\t\tresult.state === \"granted\"\n\t\t\t\t\t\t? \"granted\"\n\t\t\t\t\t\t: result.state === \"denied\"\n\t\t\t\t\t\t? \"denied\"\n\t\t\t\t\t\t: \"undetermined\",\n\t\t\t};\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"undetermined\",\n\t\t\t};\n\t\t}\n\t}, []);\n\n\t// Clear auto-stop timer\n\tconst clearAutoStopTimer = useCallback(() => {\n\t\tif (autoStopTimerRef.current) {\n\t\t\tclearTimeout(autoStopTimerRef.current);\n\t\t\tautoStopTimerRef.current = null;\n\t\t}\n\t}, []);\n\n\t// Reset auto-stop timer\n\tconst resetAutoStopTimer = useCallback(() => {\n\t\tclearAutoStopTimer();\n\n\t\tif (autoStopAfterSilence && autoStopAfterSilence > 0) {\n\t\t\tautoStopTimerRef.current = setTimeout(() => {\n\t\t\t\tif (recognitionRef.current && isRecording) {\n\t\t\t\t\trecognitionRef.current.stop();\n\t\t\t\t}\n\t\t\t}, autoStopAfterSilence);\n\t\t}\n\t}, [autoStopAfterSilence, clearAutoStopTimer, isRecording]);\n\n\t// Stop recording\n\tconst stopRecording = useCallback(() => {\n\t\tif (recognitionRef.current) {\n\t\t\ttry {\n\t\t\t\trecognitionRef.current.stop();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"Error stopping speech recognition:\", error);\n\t\t\t}\n\t\t}\n\t\tclearAutoStopTimer();\n\t\tsetIsRecording(false);\n\t\tsetVoiceState(\"idle\");\n\t}, [clearAutoStopTimer]);\n\n\t// Start recording\n\tconst startRecording = useCallback(async () => {\n\t\tconst SpeechRecognitionAPI = getSpeechRecognition();\n\n\t\tif (!SpeechRecognitionAPI) {\n\t\t\tonError?.(\"Speech recognition not supported in this browser\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Request microphone permission first\n\t\t\ttry {\n\t\t\t\tawait navigator.mediaDevices.getUserMedia({ audio: true });\n\t\t\t} catch (permError) {\n\t\t\t\tonError?.(\"Microphone access denied. Please allow microphone access in your browser settings.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Create new recognition instance\n\t\t\tconst recognition = new SpeechRecognitionAPI();\n\t\t\trecognition.continuous = continuous;\n\t\t\trecognition.interimResults = interimResults;\n\t\t\trecognition.lang = lang;\n\t\t\trecognition.maxAlternatives = maxAlternatives;\n\n\t\t\t// Event handlers\n\t\t\trecognition.onstart = () => {\n\t\t\t\tsetVoiceState(\"listening\");\n\t\t\t\tsetIsRecording(true);\n\t\t\t\tonStart?.();\n\t\t\t\tresetAutoStopTimer();\n\t\t\t};\n\n\t\t\trecognition.onend = () => {\n\t\t\t\tsetVoiceState(\"idle\");\n\t\t\t\tsetIsRecording(false);\n\t\t\t\tclearAutoStopTimer();\n\t\t\t\tonEnd?.();\n\t\t\t};\n\n\t\t\trecognition.onresult = (event: SpeechRecognitionEvent) => {\n\t\t\t\tconst results = event.results;\n\t\t\t\tlet transcript = \"\";\n\n\t\t\t\t// Combine ALL results from the beginning (not just from resultIndex)\n\t\t\t\t// This ensures continuous speech is properly accumulated\n\t\t\t\tfor (let i = 0; i < results.length; i++) {\n\t\t\t\t\tconst result = results[i];\n\t\t\t\t\tif (result && result[0]) {\n\t\t\t\t\t\tconst text = result[0].transcript;\n\t\t\t\t\t\tif (transcript && !transcript.endsWith(\" \") && !text.startsWith(\" \")) {\n\t\t\t\t\t\t\ttranscript += \" \" + text;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttranscript += text;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttranscript = transcript.trim();\n\t\t\t\t\n\t\t\t\tif (transcript) {\n\t\t\t\t\tsetTranscribedText(transcript);\n\t\t\t\t\tonResult?.(transcript);\n\t\t\t\t\tresetAutoStopTimer();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\trecognition.onerror = (event: SpeechRecognitionErrorEvent) => {\n\t\t\t\tsetVoiceState(\"error\");\n\t\t\t\tsetIsRecording(false);\n\t\t\t\tclearAutoStopTimer();\n\n\t\t\t\t// Provide more user-friendly error messages\n\t\t\t\tlet errorMessage = event.error;\n\t\t\t\tif (event.error === \"not-allowed\") {\n\t\t\t\t\terrorMessage = \"Microphone access denied. Please allow microphone access in your browser settings.\";\n\t\t\t\t} else if (event.error === \"no-speech\") {\n\t\t\t\t\terrorMessage = \"No speech detected. Please try again.\";\n\t\t\t\t} else if (event.error === \"audio-capture\") {\n\t\t\t\t\terrorMessage = \"No microphone found or microphone is in use.\";\n\t\t\t\t} else if (event.error === \"network\") {\n\t\t\t\t\terrorMessage = \"Network error occurred. Please check your connection.\";\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tonError?.(errorMessage);\n\t\t\t};\n\n\t\t\trecognitionRef.current = recognition;\n\t\t\tsetTranscribedText(\"\");\n\n\t\t\t// Start recognition\n\t\t\trecognition.start();\n\t\t} catch (error) {\n\t\t\tsetVoiceState(\"error\");\n\t\t\tsetIsRecording(false);\n\t\t\tonError?.(\n\t\t\t\terror instanceof Error ? error.message : \"Failed to start recording\"\n\t\t\t);\n\t\t}\n\t}, [\n\t\tlang,\n\t\tinterimResults,\n\t\tcontinuous,\n\t\tmaxAlternatives,\n\t\tonStart,\n\t\tonEnd,\n\t\tonResult,\n\t\tonError,\n\t\tgetPermissions,\n\t\tresetAutoStopTimer,\n\t\tclearAutoStopTimer,\n\t]);\n\n\t// Clear transcript\n\tconst clearTranscript = useCallback(() => {\n\t\tsetTranscribedText(\"\");\n\t}, []);\n\n\t// Reset\n\tconst reset = useCallback(() => {\n\t\tstopRecording();\n\t\tsetTranscribedText(\"\");\n\t\tsetVoiceState(\"idle\");\n\t}, [stopRecording]);\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (recognitionRef.current) {\n\t\t\t\ttry {\n\t\t\t\t\trecognitionRef.current.stop();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tclearAutoStopTimer();\n\t\t};\n\t}, [clearAutoStopTimer]);\n\n\treturn {\n\t\tvoiceState,\n\t\ttranscribedText,\n\t\tisAvailable,\n\t\tisRecording,\n\t\tstartRecording,\n\t\tstopRecording,\n\t\trequestPermissions,\n\t\tgetPermissions,\n\t\tclearTranscript,\n\t\treset,\n\t};\n}\n","// ============================================================\n// JSON Schema form helper (zero-dependency, platform-agnostic)\n// ============================================================\n//\n// MCP elicitation uses standard JSON Schema to describe the form a\n// prompt wants filled. The server emits a small, flat subset today\n// (a `properties` map of primitives + `oneOf` single-selects). These\n// pure helpers classify fields, coerce submitted values to the right\n// JSON type, and validate against the declared constraints.\n//\n// Design rules:\n// - No React, no DOM, no deps — usable by web and React Native UIs.\n// - Forward-compatible: unknown `type`s fall back to text, unknown\n// keywords are ignored, and nested objects/arrays are flagged as\n// unsupported (so the UI can skip them) rather than crashing.\n\nimport type {\n\tJsonSchemaField,\n\tJsonSchemaOption,\n\tRequestedSchema,\n} from \"../types\";\n\n/** The widget kinds the renderer knows how to draw. */\nexport type FieldWidget = \"text\" | \"integer\" | \"decimal\" | \"boolean\" | \"select\";\n\n/**\n * Classify a schema field into a widget kind. `oneOf` always wins\n * (titled single-select), then `type`. Anything unrecognized — or a\n * missing type — degrades to a plain text input.\n */\nexport function classifyField(field: JsonSchemaField | undefined): FieldWidget {\n\tif (!field) return \"text\";\n\tif (Array.isArray(field.oneOf) && field.oneOf.length > 0) return \"select\";\n\tswitch (field.type) {\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\t\tcase \"integer\":\n\t\t\treturn \"integer\";\n\t\tcase \"number\":\n\t\t\treturn \"decimal\";\n\t\tcase \"string\":\n\t\t\treturn \"text\";\n\t\tdefault:\n\t\t\treturn \"text\";\n\t}\n}\n\n/**\n * Fields we can't render as a flat primitive (nested objects, arrays,\n * tuple/composite schemas). The renderer should skip these rather than\n * attempt a best-effort input. `oneOf` is NOT considered unsupported —\n * it's our single-select shape.\n */\nexport function isNestedOrUnsupported(field: JsonSchemaField | undefined): boolean {\n\tif (!field) return false;\n\tif (field.type === \"object\" || field.type === \"array\") return true;\n\tif (\"properties\" in field && field.properties != null) return true;\n\tif (\"items\" in field && field.items != null) return true;\n\treturn false;\n}\n\n/** Normalize a field's `oneOf` into a clean option list (drops malformed entries). */\nexport function getOptions(field: JsonSchemaField | undefined): JsonSchemaOption[] {\n\tif (!field || !Array.isArray(field.oneOf)) return [];\n\treturn field.oneOf.filter(\n\t\t(o): o is JsonSchemaOption =>\n\t\t\t!!o && typeof o === \"object\" && typeof o.const === \"string\",\n\t);\n}\n\n/** Is `key` required per the schema's `required` array? */\nexport function isRequired(schema: RequestedSchema | undefined, key: string): boolean {\n\treturn Array.isArray(schema?.required) && schema!.required!.includes(key);\n}\n\n/**\n * Coerce a raw widget value into the JSON type the schema declares, so\n * the submitted `content` round-trips cleanly. Empty/blank values become\n * `undefined` (the field is simply omitted from the payload). The server\n * is tolerant of strings, but matching types keeps things clean.\n */\nexport function coerceValue(field: JsonSchemaField | undefined, raw: unknown): unknown {\n\tconst widget = classifyField(field);\n\n\tif (widget === \"boolean\") {\n\t\tif (typeof raw === \"boolean\") return raw;\n\t\tif (raw === \"true\") return true;\n\t\tif (raw === \"false\") return false;\n\t\treturn Boolean(raw);\n\t}\n\n\tif (widget === \"integer\" || widget === \"decimal\") {\n\t\tif (raw === \"\" || raw == null) return undefined;\n\t\tconst num = typeof raw === \"number\" ? raw : Number(String(raw).trim());\n\t\tif (Number.isNaN(num)) return undefined;\n\t\treturn widget === \"integer\" ? Math.trunc(num) : num;\n\t}\n\n\t// text + select → string\n\tif (raw == null) return undefined;\n\tconst str = String(raw);\n\treturn str === \"\" ? undefined : str;\n}\n\n/** Pre-fill value for a field's widget, from `default` (typed loosely for inputs). */\nexport function defaultValueFor(field: JsonSchemaField | undefined): unknown {\n\tif (!field || field.default === undefined) {\n\t\treturn classifyField(field) === \"boolean\" ? false : \"\";\n\t}\n\treturn field.default;\n}\n\n/**\n * Validate a single field's coerced value. Returns an error string or\n * `null` when valid. Only the documented keywords are enforced; unknown\n * keywords are ignored.\n */\nexport function validateField(\n\tfield: JsonSchemaField | undefined,\n\tvalue: unknown,\n\trequired: boolean,\n): string | null {\n\tconst widget = classifyField(field);\n\tconst label = field?.title || \"This field\";\n\n\tconst isEmpty =\n\t\tvalue === undefined ||\n\t\tvalue === null ||\n\t\t(typeof value === \"string\" && value.trim() === \"\");\n\n\tif (isEmpty) {\n\t\t// Booleans are never \"empty\" in a way that fails required.\n\t\tif (required && widget !== \"boolean\") return `${label} is required.`;\n\t\treturn null;\n\t}\n\n\tif (widget === \"integer\" || widget === \"decimal\") {\n\t\tconst num = typeof value === \"number\" ? value : Number(value);\n\t\tif (Number.isNaN(num)) return `${label} must be a number.`;\n\t\tif (widget === \"integer\" && !Number.isInteger(num)) {\n\t\t\treturn `${label} must be a whole number.`;\n\t\t}\n\t\tif (typeof field?.minimum === \"number\" && num < field.minimum) {\n\t\t\treturn `${label} must be at least ${field.minimum}.`;\n\t\t}\n\t\tif (typeof field?.maximum === \"number\" && num > field.maximum) {\n\t\t\treturn `${label} must be at most ${field.maximum}.`;\n\t\t}\n\t\treturn null;\n\t}\n\n\tif (widget === \"select\") {\n\t\tconst allowed = getOptions(field).map((o) => o.const);\n\t\tif (allowed.length > 0 && !allowed.includes(String(value))) {\n\t\t\treturn `${label} has an invalid selection.`;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// text\n\tconst str = String(value);\n\tif (typeof field?.minLength === \"number\" && str.length < field.minLength) {\n\t\treturn `${label} must be at least ${field.minLength} characters.`;\n\t}\n\tif (typeof field?.maxLength === \"number\" && str.length > field.maxLength) {\n\t\treturn `${label} must be at most ${field.maxLength} characters.`;\n\t}\n\treturn null;\n}\n\n/** Ordered list of renderable [key, field] pairs (skips unsupported fields). */\nexport function renderableFields(\n\tschema: RequestedSchema | undefined,\n): Array<[string, JsonSchemaField]> {\n\tconst props = schema?.properties;\n\tif (!props) return [];\n\treturn Object.entries(props).filter(([, field]) => !isNestedOrUnsupported(field));\n}\n\n/**\n * Validate a full form. `values` is the raw widget-value map (pre-coercion).\n * Returns a `{ key: error }` map (empty when the form is valid).\n */\nexport function validateForm(\n\tschema: RequestedSchema | undefined,\n\tvalues: Record<string, unknown>,\n): Record<string, string> {\n\tconst errors: Record<string, string> = {};\n\tfor (const [key, field] of renderableFields(schema)) {\n\t\tconst coerced = coerceValue(field, values[key]);\n\t\tconst err = validateField(field, coerced, isRequired(schema, key));\n\t\tif (err) errors[key] = err;\n\t}\n\treturn errors;\n}\n\n/**\n * Build the schema-typed `content` object to POST on submit. Only fields\n * present in the schema are included; blank/undefined values are omitted.\n */\nexport function buildContent(\n\tschema: RequestedSchema | undefined,\n\tvalues: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst content: Record<string, unknown> = {};\n\tfor (const [key, field] of renderableFields(schema)) {\n\t\tconst coerced = coerceValue(field, values[key]);\n\t\tif (coerced !== undefined) content[key] = coerced;\n\t}\n\treturn content;\n}\n","import { createContext, useContext } from \"react\";\nimport type { MessageDisplay } from \"../types\";\n\nexport interface PaymanChatContextValue {\n\t/**\n\t * Clear all messages and reset the chat\n\t */\n\tresetSession: () => void;\n\n\t/**\n\t * Clear all messages without resetting session ID\n\t */\n\tclearMessages: () => void;\n\n\t/**\n\t * Prepend older messages to the top of the list (e.g. from history pagination)\n\t */\n\tprependMessages: (messages: MessageDisplay[]) => void;\n\n\t/**\n\t * Cancel current streaming operation\n\t */\n\tcancelStream: () => void;\n\n\t/**\n\t * Get current session ID\n\t */\n\tgetSessionId: () => string | undefined;\n\n\t/**\n\t * Get all messages\n\t */\n\tgetMessages: () => MessageDisplay[];\n\n\t/**\n\t * Check if currently waiting for response\n\t */\n\tisWaitingForResponse: boolean;\n}\n\nexport const PaymanChatContext = createContext<\n\tPaymanChatContextValue | undefined\n>(undefined);\n\n/**\n * Hook to access PaymanChat controls from parent components\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const chat = usePaymanChat();\n * \n * return (\n * <>\n * <button onClick={chat.resetSession}>Reset</button>\n * <button onClick={chat.clearMessages}>Clear</button>\n * </>\n * );\n * }\n * ```\n */\nexport function usePaymanChat(): PaymanChatContextValue {\n\tconst context = useContext(PaymanChatContext);\n\tif (!context) {\n\t\tthrow new Error(\"usePaymanChat must be used within a PaymanChat component\");\n\t}\n\treturn context;\n}\n","import { Check, ChevronRight, Info, Mic, Pencil, Send, ShieldCheck, X } from \"lucide-react-native\";\nimport {\n\tforwardRef,\n\tmemo,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport {\n\tAnimated,\n\tDimensions,\n\tEasing,\n\tKeyboard,\n\tKeyboardAvoidingView,\n\tLayoutAnimation,\n\tPanResponder,\n\tPlatform,\n\tPressable,\n\tScrollView,\n\tStyleSheet,\n\tSwitch,\n\tText,\n\tTextInput,\n\tUIManager,\n\tuseColorScheme,\n\tView,\n} from \"react-native\";\nimport Markdown from \"react-native-markdown-display\";\nimport {\n\tuseChatV2,\n\tuseVoice,\n\tbuildContent,\n\tclassifyField,\n\tdefaultValueFor,\n\tgetOptions,\n\tisRequired,\n\trenderableFields,\n\tvalidateForm,\n} from \"@paymanai/payman-typescript-ask-sdk\";\nimport type {\n\tActiveUserAction,\n\tMessageDisplay,\n\tStreamingStep,\n\tUserNotification,\n} from \"@paymanai/payman-typescript-ask-sdk\";\nimport { PaymanChatContext } from \"../../contexts\";\nimport type { PaymanChatProps, PaymanChatRef } from \"../../types\";\n\nif (Platform.OS === \"android\" && UIManager.setLayoutAnimationEnabledExperimental) {\n\tUIManager.setLayoutAnimationEnabledExperimental(true);\n}\n\n// ─── Constants ────────────────────────────────────────────────────────────────\n\nconst DEFAULT_ACCENT = \"#00858d\";\nconst VOICE_DOT_COUNT = 24;\nconst VOICE_DOT_MIN_H = 5;\nconst VOICE_DOT_MAX_H = 14;\nconst SPEECH_ACTIVITY_MS = 1400;\nconst VOICE_BAR_BG = \"#f0f9f9\";\nconst AI_DISCLAIMER = \"AI can make mistakes. Please double-check responses.\";\n\n// ─── Voice waveform bar ───────────────────────────────────────────────────────\n\nconst VoiceWaveformBar = memo(function VoiceWaveformBar({\n\tindex,\n\tisActive,\n\taccent,\n}: {\n\tindex: number;\n\tisActive: boolean;\n\taccent: string;\n}) {\n\tconst height = useRef(new Animated.Value(VOICE_DOT_MIN_H)).current;\n\n\tuseEffect(() => {\n\t\tif (isActive) {\n\t\t\tconst anim = Animated.loop(\n\t\t\t\tAnimated.sequence([\n\t\t\t\t\tAnimated.timing(height, {\n\t\t\t\t\t\ttoValue: VOICE_DOT_MAX_H,\n\t\t\t\t\t\tduration: 180 + (index % 3) * 40,\n\t\t\t\t\t\tdelay: index * 25,\n\t\t\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t\t\tuseNativeDriver: false,\n\t\t\t\t\t}),\n\t\t\t\t\tAnimated.timing(height, {\n\t\t\t\t\t\ttoValue: VOICE_DOT_MIN_H,\n\t\t\t\t\t\tduration: 180 + (index % 3) * 40,\n\t\t\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t\t\tuseNativeDriver: false,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t\tanim.start();\n\t\t\treturn () => anim.stop();\n\t\t}\n\t\tAnimated.timing(height, { toValue: VOICE_DOT_MIN_H, duration: 200, useNativeDriver: false }).start();\n\t}, [isActive, index, height]);\n\n\treturn (\n\t\t<Animated.View\n\t\t\tstyle={[s.voiceDot, { height, backgroundColor: accent + \"99\" }]}\n\t\t/>\n\t);\n});\n\nfunction formatDuration(sec: number): string {\n\tconst m = Math.floor(sec / 60);\n\tconst s = sec % 60;\n\treturn `${m}:${s.toString().padStart(2, \"0\")}`;\n}\n\n// ─── Input bar ────────────────────────────────────────────────────────────────\n\ntype InputBarProps = {\n\tvalue: string;\n\tonChange: (v: string) => void;\n\tonSend: () => void;\n\tonCancel: () => void;\n\tdisabled: boolean;\n\tplaceholder: string;\n\tisStreaming: boolean;\n\taccent: string;\n\tenableVoice: boolean;\n\tvoiceAvailable: boolean;\n\tisRecording: boolean;\n\trecordingSeconds: number;\n\ttranscribedText: string;\n\tonVoicePress: () => void;\n\tonConfirmRecording: () => void;\n\tonCancelRecording: () => void;\n\tonFocus: () => void;\n\tinsetBottom: number;\n};\n\nfunction InputBar({\n\tvalue,\n\tonChange,\n\tonSend,\n\tonCancel,\n\tdisabled,\n\tplaceholder,\n\tisStreaming,\n\taccent,\n\tenableVoice,\n\tvoiceAvailable,\n\tisRecording,\n\trecordingSeconds,\n\ttranscribedText,\n\tonVoicePress,\n\tonConfirmRecording,\n\tonCancelRecording,\n\tonFocus,\n\tinsetBottom,\n}: InputBarProps) {\n\t// While a response is streaming the user can keep typing, but sending and\n\t// voice are disabled (no cancel) — the buttons appear greyed out.\n\tconst canSend = !disabled && !isStreaming && value.trim().length > 0;\n\tconst voiceDisabled = !voiceAvailable || disabled || isStreaming;\n\tconst showVoiceBar = enableVoice && isRecording;\n\tconst showVoiceBtn = enableVoice && !isRecording;\n\n\tconst [keyboardOpen, setKeyboardOpen] = useState(false);\n\tuseEffect(() => {\n\t\tconst show = Keyboard.addListener(\"keyboardWillShow\", () => setKeyboardOpen(true));\n\t\tconst hide = Keyboard.addListener(\"keyboardWillHide\", () => setKeyboardOpen(false));\n\t\treturn () => { show.remove(); hide.remove(); };\n\t}, []);\n\n\t// Detect speech activity for waveform animation\n\tconst [isSpeaking, setIsSpeaking] = useState(false);\n\tconst prevTranscript = useRef(\"\");\n\tconst speechTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tuseEffect(() => {\n\t\tif (!showVoiceBar) {\n\t\t\tsetIsSpeaking(false);\n\t\t\tprevTranscript.current = \"\";\n\t\t\tif (speechTimeout.current) clearTimeout(speechTimeout.current);\n\t\t\treturn;\n\t\t}\n\t\tconst changed = transcribedText !== prevTranscript.current;\n\t\tprevTranscript.current = transcribedText;\n\t\tif (changed) {\n\t\t\tsetIsSpeaking(true);\n\t\t\tif (speechTimeout.current) clearTimeout(speechTimeout.current);\n\t\t\tspeechTimeout.current = setTimeout(() => setIsSpeaking(false), SPEECH_ACTIVITY_MS);\n\t\t}\n\t\treturn () => { if (speechTimeout.current) clearTimeout(speechTimeout.current); };\n\t}, [showVoiceBar, transcribedText]);\n\n\t// Animate voice bar in/out\n\tconst animOpacity = useRef(new Animated.Value(1)).current;\n\tconst animScale = useRef(new Animated.Value(1)).current;\n\tuseEffect(() => {\n\t\tLayoutAnimation.configureNext(LayoutAnimation.create(200, \"easeInEaseOut\", \"opacity\"));\n\t\tif (showVoiceBar) {\n\t\t\tanimOpacity.setValue(0.92);\n\t\t\tanimScale.setValue(0.98);\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.timing(animOpacity, { toValue: 1, duration: 200, useNativeDriver: true }),\n\t\t\t\tAnimated.spring(animScale, { toValue: 1, useNativeDriver: true, speed: 12, bounciness: 4 }),\n\t\t\t]).start();\n\t\t} else {\n\t\t\tanimOpacity.setValue(1);\n\t\t\tanimScale.setValue(1);\n\t\t}\n\t}, [showVoiceBar, animOpacity, animScale]);\n\n\tconst accentLight = accent + \"33\";\n\tconst barBorderColor = accent + \"59\";\n\n\t// When the keyboard is up it covers the home indicator, so a small pad is\n\t// enough; otherwise clear the device's bottom safe-area inset.\n\tconst bottomPad = keyboardOpen ? 8 : Math.max(insetBottom, 10);\n\n\treturn (\n\t\t<View style={[s.outerBar, showVoiceBar && s.outerBarVoice, { paddingBottom: bottomPad }]}>\n\t\t\t<View style={s.column}>\n\t\t\t\t{/* TextInput + optional voice bar overlay */}\n\t\t\t\t<View style={[s.inputWrap, showVoiceBar && s.inputWrapRelative]}>\n\t\t\t\t\t<TextInput\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tonChangeText={onChange}\n\t\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\t\teditable={!disabled}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tplaceholderTextColor=\"#9CA3AF\"\n\t\t\t\t\t\tmultiline\n\t\t\t\t\t\tstyle={[s.input, disabled && s.inputDisabled, showVoiceBar && s.inputHidden]}\n\t\t\t\t\t\treturnKeyType=\"default\"\n\t\t\t\t\t\tblurOnSubmit={false}\n\t\t\t\t\t\tonSubmitEditing={onSend}\n\t\t\t\t\t/>\n\t\t\t\t\t{showVoiceBar && (\n\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\t\t\t\tstyle={[s.voiceBarContainer, { opacity: animOpacity, transform: [{ scale: animScale }] }]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={[s.voiceBar, { backgroundColor: VOICE_BAR_BG, borderColor: barBorderColor }]}>\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onCancelRecording}\n\t\t\t\t\t\t\t\t\tstyle={({ pressed }) => [s.voiceBarCircle, { backgroundColor: accentLight }, pressed && s.pressed]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Cancel recording\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<X size={20} color={accent} strokeWidth={2.5} />\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t\t<View style={s.voiceBarCenter}>\n\t\t\t\t\t\t\t\t\t<View style={s.voiceDots}>\n\t\t\t\t\t\t\t\t\t\t{Array.from({ length: VOICE_DOT_COUNT }).map((_, i) => (\n\t\t\t\t\t\t\t\t\t\t\t<VoiceWaveformBar key={i} index={i} isActive={isSpeaking} accent={accent} />\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t<Text style={[s.voiceTimer, { color: accent }]}>\n\t\t\t\t\t\t\t\t\t\t{formatDuration(recordingSeconds)}\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onConfirmRecording}\n\t\t\t\t\t\t\t\t\tstyle={({ pressed }) => [s.voiceBarCircle, s.voiceConfirm, { borderColor: accent }, pressed && s.pressed]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Send recording\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Check size={22} color={accent} strokeWidth={2.5} />\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</Animated.View>\n\t\t\t\t\t)}\n\t\t\t\t</View>\n\n\t\t\t\t{/* Actions row: voice + send */}\n\t\t\t\t{!showVoiceBar && (\n\t\t\t\t\t<View style={s.actionsRow}>\n\t\t\t\t\t\t<View style={s.rightActions}>\n\t\t\t\t\t\t\t{showVoiceBtn && (\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onVoicePress}\n\t\t\t\t\t\t\t\t\tdisabled={voiceDisabled}\n\t\t\t\t\t\t\t\t\tstyle={[s.iconBtn, voiceDisabled && s.btnDisabled]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Voice input\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<View style={s.iconBtnInner}>\n\t\t\t\t\t\t\t\t\t\t<Mic size={16} color=\"#6B7280\" strokeWidth={2} />\n\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\tonPress={onSend}\n\t\t\t\t\t\t\t\tdisabled={!canSend}\n\t\t\t\t\t\t\t\tstyle={[s.sendBtn, !canSend && s.btnDisabled]}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<View style={[s.sendBtnInner, { backgroundColor: accent }]}>\n\t\t\t\t\t\t\t\t\t<Send size={14} color=\"#FFFFFF\" />\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t)}\n\t\t\t</View>\n\n\t\t\t<View style={s.disclaimerWrap}>\n\t\t\t\t<Text style={s.disclaimerText}>{AI_DISCLAIMER}</Text>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n\n\n// ─── Typing effect (ported from web useTypingEffect, pure React) ─────────────\n\ntype SpeedProfile = {\n\tnormal: [number, number];\n\tfast: number;\n\tpunctuation: [number, number];\n\tnewline: [number, number];\n\tidle: number;\n};\n\nconst RESPONSE_SPEED: SpeedProfile = {\n\tnormal: [2, 4],\n\tfast: 1,\n\tpunctuation: [8, 12],\n\tnewline: [4, 6],\n\tidle: 15,\n};\n\nfunction charDelay(char: string, speed: SpeedProfile, multiplier: number): number {\n\tconst raw = (() => {\n\t\tif (char === \"*\") return speed.fast;\n\t\tif (char === \"\\n\") return speed.newline[0] + Math.random() * speed.newline[1];\n\t\tif (\".!?,;:\".includes(char)) return speed.punctuation[0] + Math.random() * speed.punctuation[1];\n\t\treturn speed.normal[0] + Math.random() * speed.normal[1];\n\t})();\n\treturn raw / multiplier;\n}\n\n// Characters revealed per tick. Chunking is the real speed lever — it cuts the\n// number of React re-renders (the bottleneck) rather than the per-char delay,\n// which is already clamped by the JS timer minimum.\nconst TYPE_CHUNK = 2;\n\n// If `remaining` (which must start at a line boundary) begins a structural\n// markdown block — a fenced code block or a table — return the length to reveal\n// instantly so we never \"type through\" pipes/backticks. Returns 0 when there's\n// no block, or when the block is still incomplete (so we wait instead of\n// flashing a half-built table while streaming).\nfunction blockJumpLength(remaining: string, isStreaming: boolean): number {\n\t// Fenced code block ```...```\n\tif (remaining.startsWith(\"```\")) {\n\t\tconst closeIdx = remaining.indexOf(\"\\n```\", 3);\n\t\tif (closeIdx === -1) return 0; // closing fence not here yet — wait\n\t\tconst afterFence = remaining.indexOf(\"\\n\", closeIdx + 1);\n\t\treturn afterFence === -1 ? remaining.length : afterFence + 1;\n\t}\n\n\t// Markdown table — consecutive lines beginning with optional spaces then '|'\n\tconst lines = remaining.split(\"\\n\");\n\tif (!/^\\s*\\|/.test(lines[0])) return 0;\n\tlet consumed = 0;\n\tlet tableLines = 0;\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tif (/^\\s*\\|/.test(lines[i])) {\n\t\t\ttableLines++;\n\t\t\tconsumed += lines[i].length + 1; // include the trailing newline\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (tableLines < 2) return 0; // need at least header + separator\n\t// Table runs to the end of what's arrived and we're still streaming → it may\n\t// still be growing; wait for more (or stream end) before revealing it.\n\tif (consumed >= remaining.length && isStreaming) return 0;\n\treturn Math.min(consumed, remaining.length);\n}\n\nfunction useTypingEffect(\n\ttargetText: string,\n\tenabled: boolean,\n\tisStreaming: boolean,\n\tspeedMultiplier: number = 6,\n): { displayedText: string; isTyping: boolean } {\n\tconst instant = speedMultiplier === 0;\n\tconst multiplier = instant ? 1 : Math.max(speedMultiplier, 0.1);\n\n\tconst [displayedText, setDisplayedText] = useState(\"\");\n\tconst displayedRef = useRef(\"\");\n\tconst targetRef = useRef(targetText);\n\tconst enabledRef = useRef(enabled);\n\tconst streamingRef = useRef(isStreaming);\n\tconst timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst runningRef = useRef(false);\n\n\ttargetRef.current = targetText;\n\tenabledRef.current = enabled;\n\tstreamingRef.current = isStreaming;\n\n\tuseEffect(() => {\n\t\tif (!enabled || instant) {\n\t\t\tif (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n\t\t\trunningRef.current = false;\n\t\t\tdisplayedRef.current = targetText;\n\t\t\tsetDisplayedText(targetText);\n\t\t\treturn;\n\t\t}\n\n\t\t// Flush instantly if target changed incompatibly (displayed no longer a prefix)\n\t\tif (displayedRef.current && !targetRef.current.startsWith(displayedRef.current)) {\n\t\t\tdisplayedRef.current = targetRef.current;\n\t\t\tsetDisplayedText(targetRef.current);\n\t\t}\n\n\t\tif (runningRef.current) return;\n\t\trunningRef.current = true;\n\n\t\tconst tick = () => {\n\t\t\tif (!enabledRef.current) { runningRef.current = false; return; }\n\n\t\t\tif (displayedRef.current && !targetRef.current.startsWith(displayedRef.current)) {\n\t\t\t\tdisplayedRef.current = targetRef.current;\n\t\t\t\tsetDisplayedText(targetRef.current);\n\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (displayedRef.current.length < targetRef.current.length) {\n\t\t\t\tconst remaining = targetRef.current.slice(displayedRef.current.length);\n\t\t\t\tconst atLineStart =\n\t\t\t\t\tdisplayedRef.current.length === 0 ||\n\t\t\t\t\ttargetRef.current[displayedRef.current.length - 1] === \"\\n\";\n\n\t\t\t\tif (atLineStart) {\n\t\t\t\t\t// Reveal complete tables / code blocks in one shot.\n\t\t\t\t\tconst jump = blockJumpLength(remaining, streamingRef.current);\n\t\t\t\t\tif (jump > 0) {\n\t\t\t\t\t\tdisplayedRef.current += remaining.slice(0, jump);\n\t\t\t\t\t\tsetDisplayedText(displayedRef.current);\n\t\t\t\t\t\ttimerRef.current = setTimeout(tick, 0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// A structural block is starting but isn't complete yet — don't\n\t\t\t\t\t// type its half-built pipes/backticks; wait for the rest.\n\t\t\t\t\tif (streamingRef.current && /^(```|\\s*\\|)/.test(remaining)) {\n\t\t\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Reveal a chunk, but never cross a newline so the next line is\n\t\t\t\t// re-evaluated for a structural jump at its start.\n\t\t\t\tlet chunk = remaining.slice(0, TYPE_CHUNK);\n\t\t\t\tconst nl = chunk.indexOf(\"\\n\");\n\t\t\t\tif (nl !== -1) chunk = chunk.slice(0, nl + 1);\n\t\t\t\tdisplayedRef.current += chunk;\n\t\t\t\tsetDisplayedText(displayedRef.current);\n\t\t\t\tconst lastChar = chunk[chunk.length - 1];\n\t\t\t\ttimerRef.current = setTimeout(tick, charDelay(lastChar, RESPONSE_SPEED, multiplier));\n\t\t\t} else {\n\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t}\n\t\t};\n\n\t\ttick();\n\n\t\treturn () => {\n\t\t\tif (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n\t\t\trunningRef.current = false;\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [enabled, instant]);\n\n\tconst isTyping = enabled && !instant && displayedRef.current.length < targetRef.current.length;\n\treturn { displayedText: enabled || instant ? displayedText : targetText, isTyping };\n}\n\n// ─── Thinking block (exact port of web ThinkingBlockV2) ──────────────────────\n//\n// Two-line live-progress model computed from `message.steps`:\n// • stickyLabel — the Analyzer's plan narrative; fades in, then stays\n// • currentStepLabel — the live tactical label; shimmers + flips as steps land\n//\n// The shimmer is the web's `payman-v2-thinking-shimmer`: a bright band sweeping\n// horizontally across the text (dim → bright → dim). Web does it with a\n// background-clip:text gradient; RN has no equivalent, so we animate each\n// character's color from a single shared progress value with a moving peak —\n// nested <Text> keeps native word-wrapping intact.\n\nconst PENDING_LABEL = \"Thinking\";\n\n// 2.8s sweep, matching the web's `payman-v2-thinking-shimmer` animation.\nconst SHIMMER_DURATION = 2800;\n// Half-width of the bright band, in normalized [0,1] text-position units.\nconst SHIMMER_BAND = 0.55;\n\n// Shimmer stops per theme (matches web text-4 → text-1).\nconst SHIMMER_LIGHT = { dim: \"#b4b4b4\", bright: \"#1f2937\" };\nconst SHIMMER_DARK = { dim: \"#5b6b6e\", bright: \"#eaf2f3\" };\n\n// One character with an animated color. As the shared `progress` (0→1) sweeps,\n// a bright \"peak\" travels across the label; each char lights up as the peak\n// passes its normalized position — reproducing the web's background-clip:text\n// gradient sweep, with native word-wrapping preserved via nested <Text>.\nfunction ShimmerChar({\n\tch,\n\tpos,\n\tprogress,\n\tdim,\n\tbright,\n}: {\n\tch: string;\n\tpos: number;\n\tprogress: Animated.Value;\n\tdim: string;\n\tbright: string;\n}) {\n\t// progress where the peak coincides with this char: -0.4 + p*1.8 = pos\n\tconst center = (pos + 0.4) / 1.8;\n\tconst half = SHIMMER_BAND / 1.8;\n\tconst color = progress.interpolate({\n\t\tinputRange: [center - half, center, center + half],\n\t\toutputRange: [dim, bright, dim],\n\t\textrapolate: \"clamp\",\n\t});\n\treturn <Animated.Text style={[ts.cursorLabel, { color }]}>{ch}</Animated.Text>;\n}\n\nfunction ShimmerText({ text, isDark }: { text: string; isDark: boolean }) {\n\tconst progress = useRef(new Animated.Value(0)).current;\n\tconst { dim, bright } = isDark ? SHIMMER_DARK : SHIMMER_LIGHT;\n\tuseEffect(() => {\n\t\tconst loop = Animated.loop(\n\t\t\tAnimated.timing(progress, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: SHIMMER_DURATION,\n\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t// color interpolation isn't supported by the native driver\n\t\t\t\tuseNativeDriver: false,\n\t\t\t}),\n\t\t);\n\t\tloop.start();\n\t\treturn () => loop.stop();\n\t}, [progress]);\n\n\tconst chars = Array.from(text);\n\tconst n = Math.max(chars.length - 1, 1);\n\treturn (\n\t\t<Text style={[ts.cursorLabel, { color: dim }]}>\n\t\t\t{chars.map((ch, i) => (\n\t\t\t\t<ShimmerChar key={i} ch={ch} pos={i / n} progress={progress} dim={dim} bright={bright} />\n\t\t\t))}\n\t\t</Text>\n\t);\n}\n\n// Current-step label that re-animates (slide up + fade in) whenever the text\n// changes — the web's \"digital-clock flip\" between stages.\nfunction FlipLabel({ label, isDark }: { label: string; isDark: boolean }) {\n\tconst opacity = useRef(new Animated.Value(0)).current;\n\tconst translateY = useRef(new Animated.Value(6)).current;\n\tuseEffect(() => {\n\t\topacity.setValue(0);\n\t\ttranslateY.setValue(6);\n\t\tAnimated.parallel([\n\t\t\tAnimated.timing(opacity, { toValue: 1, duration: 300, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t\tAnimated.timing(translateY, { toValue: 0, duration: 320, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t]).start();\n\t}, [label, opacity, translateY]);\n\treturn (\n\t\t<Animated.View style={{ opacity, transform: [{ translateY }] }}>\n\t\t\t<ShimmerText text={label} isDark={isDark} />\n\t\t</Animated.View>\n\t);\n}\n\n// Sticky plan narrative — fades in once when it arrives, then stays put.\nfunction StickyLabel({ label, isDark }: { label: string; isDark: boolean }) {\n\tconst opacity = useRef(new Animated.Value(0)).current;\n\tconst translateY = useRef(new Animated.Value(4)).current;\n\tuseEffect(() => {\n\t\tAnimated.parallel([\n\t\t\tAnimated.timing(opacity, { toValue: 1, duration: 400, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t\tAnimated.timing(translateY, { toValue: 0, duration: 400, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t]).start();\n\t}, [opacity, translateY]);\n\treturn (\n\t\t<Animated.Text\n\t\t\tstyle={[\n\t\t\t\tts.stickyLabel,\n\t\t\t\t{ color: isDark ? \"rgba(255,255,255,0.62)\" : \"#4b5563\", opacity, transform: [{ translateY }] },\n\t\t\t]}\n\t\t>\n\t\t\t{label}\n\t\t</Animated.Text>\n\t);\n}\n\nfunction ThinkingBlock({\n\tstickyLabel,\n\tcurrentStepLabel,\n\tisDark,\n}: {\n\tstickyLabel?: string;\n\tcurrentStepLabel?: string;\n\tisDark: boolean;\n}) {\n\tconst label = currentStepLabel || PENDING_LABEL;\n\treturn (\n\t\t<View style={ts.container}>\n\t\t\t{stickyLabel ? <StickyLabel key={stickyLabel} label={stickyLabel} isDark={isDark} /> : null}\n\t\t\t<View style={ts.cursorRow}>\n\t\t\t\t{/* key forces remount on label change → re-runs the flip animation */}\n\t\t\t\t<FlipLabel key={label} label={label} isDark={isDark} />\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Derive the sticky plan-narrative label from the steps array (web parity).\nfunction deriveStickyLabel(steps?: StreamingStep[]): string | undefined {\n\tif (!steps || steps.length === 0) return undefined;\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (\n\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\ts.stage === \"analyzer\" &&\n\t\t\ts.status === \"completed\" &&\n\t\t\ts.message\n\t\t) {\n\t\t\treturn s.message;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n// Derive the live current-step label from the steps array (web parity).\nfunction deriveCurrentStepLabel(\n\tsteps: StreamingStep[] | undefined,\n\tstickyLabel: string | undefined,\n): string | undefined {\n\tif (!steps || steps.length === 0) return undefined;\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (s.status === \"in_progress\" && s.message) {\n\t\t\tif (s.stage === \"analyzer\" && s.message === stickyLabel) continue;\n\t\t\tif (s.message === stickyLabel) continue;\n\t\t\treturn s.message;\n\t\t}\n\t}\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (s.message && s.message !== stickyLabel) return s.message;\n\t}\n\treturn undefined;\n}\n\nconst ts = StyleSheet.create({\n\tcontainer: { paddingVertical: 2 },\n\tstickyLabel: {\n\t\tfontSize: 14,\n\t\tlineHeight: 21,\n\t\tcolor: \"#4b5563\",\n\t\tmarginBottom: 6,\n\t},\n\tcursorRow: { overflow: \"hidden\" },\n\tcursorLabel: {\n\t\tfontSize: 14,\n\t\tlineHeight: 21,\n\t\tfontWeight: \"500\",\n\t},\n});\n\n// ─── User bubble ──────────────────────────────────────────────────────────────\n\nfunction UserBubble({ message, accent }: { message: MessageDisplay; accent: string }) {\n\tconst text = message.content ?? \"\";\n\tif (!text) return null;\n\treturn (\n\t\t<View style={[sd.bubbleRow, sd.rowUser]}>\n\t\t\t<View style={[sd.bubble, sd.bubbleUser, { backgroundColor: accent }]}>\n\t\t\t\t<Text style={[sd.bubbleText, sd.textUser]}>{text}</Text>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// ─── Assistant bubble ─────────────────────────────────────────────────────────\n\n// Strips a trailing incomplete markdown image token from streaming content so\n// the markdown renderer doesn't flash the raw URL as plain text (web parity).\nfunction stripIncompleteImageToken(text: string): string {\n\tconst lastBang = text.lastIndexOf(\"![\");\n\tif (lastBang === -1) return text;\n\tconst after = text.slice(lastBang);\n\tif (/^!\\[[^\\]]*\\]\\([^)]*\\)/.test(after)) return text;\n\treturn text.slice(0, lastBang);\n}\n\n// Removes a user-action prompt's body from the assistant message text so the\n// summary/options aren't rendered twice (once in the bubble, once in the sheet).\n// Matches on the normalized prompt text; tolerant of a trailing partial match\n// while the prompt body is still streaming in.\nfunction stripDuplicatePromptText(text: string, promptText?: string): string {\n\tif (!promptText) return text;\n\tconst pm = promptText.replace(/\\\\n/g, \"\\n\").trim();\n\tif (!pm) return text;\n\tconst idx = text.indexOf(pm);\n\tif (idx !== -1) {\n\t\treturn (text.slice(0, idx) + text.slice(idx + pm.length)).trim();\n\t}\n\t// Streaming: the bubble may hold only a prefix of the prompt body so far.\n\t// Drop from the point where the (still-growing) duplicate begins.\n\tfor (let cut = Math.min(text.length, pm.length); cut >= 24; cut--) {\n\t\tif (text.endsWith(pm.slice(0, cut))) {\n\t\t\treturn text.slice(0, text.length - cut).trim();\n\t\t}\n\t}\n\treturn text;\n}\n\nfunction AssistantBubble({\n\tmessage,\n\tshouldType,\n\tisDark,\n\taccent,\n\tsuppressText,\n}: {\n\tmessage: MessageDisplay;\n\tshouldType: boolean;\n\tisDark: boolean;\n\taccent: string;\n\t// When the same execution raised a user-action prompt, the agent's textual\n\t// answer often duplicates the prompt body (the confirmation summary). We\n\t// strip that duplicate here so it lives only in the action sheet.\n\tsuppressText?: string;\n}) {\n\tconst isCurrentlyStreaming = !!message.isStreaming && !message.isCancelled;\n\tconst mdStyles = isDark ? MD_STYLES_DARK : MD_STYLES_LIGHT;\n\tconst mdRules = useMemo(() => makeMdRules(isDark, accent), [isDark, accent]);\n\tconst bubbleBg = isDark ? \"rgba(255,255,255,0.07)\" : \"#f3f4f6\";\n\tconst errorBg = isDark ? \"rgba(220,38,38,0.14)\" : \"#fef2f2\";\n\n\t// Web's `rawResponseContent`: while streaming prefer the live streamingContent\n\t// (SDK mirrors token deltas into it), else the final content. Normalize \\n and\n\t// strip any trailing incomplete image token while streaming.\n\tconst rawResponseContent = (() => {\n\t\tconst raw = message.isStreaming\n\t\t\t? message.streamingContent || message.content\n\t\t\t: message.content;\n\t\tif (!raw) return \"\";\n\t\tconst normalized = raw.replace(/\\\\n/g, \"\\n\");\n\t\tconst cleaned = message.isStreaming ? stripIncompleteImageToken(normalized) : normalized;\n\t\treturn stripDuplicatePromptText(cleaned, suppressText);\n\t})();\n\n\t// Web's `isThinkingStreaming`: streaming, no response text yet, no error.\n\tconst isThinkingStreaming =\n\t\tisCurrentlyStreaming && !rawResponseContent && !message.isError;\n\n\t// Typing reveal — runs while streaming text lands AND on the just-completed\n\t// message, mirroring web (`responseTypingEnabled`). History renders instantly.\n\tconst hasEverStreamed = useRef(!!message.isStreaming);\n\tif (message.isStreaming) hasEverStreamed.current = true;\n\tconst typingEnabled =\n\t\tshouldType && hasEverStreamed.current && Boolean(rawResponseContent) && !message.isError;\n\tconst { displayedText, isTyping } = useTypingEffect(\n\t\trawResponseContent,\n\t\ttypingEnabled,\n\t\tisCurrentlyStreaming,\n\t\t3,\n\t);\n\n\t// Sticky + current-step labels from the steps array (web parity).\n\tconst stickyLabel = deriveStickyLabel(message.steps);\n\tconst currentStepLabel = deriveCurrentStepLabel(message.steps, stickyLabel);\n\n\t// Error with no content\n\tif (message.isError && !rawResponseContent && !displayedText) {\n\t\tconst detail = message.errorDetails || \"Something went wrong. Please try again.\";\n\t\treturn (\n\t\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, { backgroundColor: errorBg }]}>\n\t\t\t\t\t<Text style={sd.errorText}>{detail}</Text>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Thinking phase — shimmering sticky + current step label.\n\tif (isThinkingStreaming) {\n\t\treturn (\n\t\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, { backgroundColor: bubbleBg }]}>\n\t\t\t\t\t<ThinkingBlock stickyLabel={stickyLabel} currentStepLabel={currentStepLabel} isDark={isDark} />\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Content present (streaming or done) — typed reveal + blinking cursor.\n\tconst showCursor = (isCurrentlyStreaming || isTyping) && !message.isCancelled;\n\tconst markdownContent = showCursor ? displayedText + \"▋\" : displayedText;\n\n\tif (!markdownContent) return null;\n\n\treturn (\n\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, sd.bubbleAssistantWide, { backgroundColor: bubbleBg }]}>\n\t\t\t\t<Markdown style={mdStyles} rules={mdRules}>\n\t\t\t\t\t{markdownContent}\n\t\t\t\t</Markdown>\n\t\t\t\t{message.isCancelled && (\n\t\t\t\t\t<Text style={sd.cancelledText}>Response stopped</Text>\n\t\t\t\t)}\n\t\t\t\t{message.isError && displayedText && (\n\t\t\t\t\t<Text style={sd.partialErrorText}>\n\t\t\t\t\t\t{message.errorDetails || \"The response was interrupted.\"}\n\t\t\t\t\t</Text>\n\t\t\t\t)}\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// ─── Message bubble router ─────────────────────────────────────────────────────\n\nfunction MessageBubble({ message, accent, shouldType, isDark, suppressText }: { message: MessageDisplay; accent: string; shouldType: boolean; isDark: boolean; suppressText?: string }) {\n\tif (message.role === \"user\") return <UserBubble message={message} accent={accent} />;\n\treturn <AssistantBubble message={message} shouldType={shouldType} isDark={isDark} accent={accent} suppressText={suppressText} />;\n}\n\n// ─── User action blocks (full-screen animated sheet) ─────────────────────────\n//\n// When the agent raises a USER_ACTION_REQUIRED prompt mid-run, we present it as\n// an animated bottom sheet over the chat: the user fills the question(s), taps\n// the primary button, the sheet animates away and the run continues. Verification\n// prompts auto-submit a complete numeric code. Expiry + resend timers are honored.\n\nconst RESEND_COOLDOWN_S = 30;\nconst DEFAULT_CODE_LEN = 6;\n\ntype UAPalette = {\n\tsheetBg: string;\n\ttext: string;\n\tmuted: string;\n\tborder: string;\n\tfieldBg: string;\n\tfieldBorder: string;\n\toverlay: string;\n\tgrabber: string;\n};\n\nfunction uaPalette(isDark: boolean): UAPalette {\n\treturn isDark\n\t\t? {\n\t\t\t\tsheetBg: \"#13201f\",\n\t\t\t\ttext: \"rgba(255,255,255,0.95)\",\n\t\t\t\tmuted: \"rgba(255,255,255,0.55)\",\n\t\t\t\tborder: \"rgba(255,255,255,0.10)\",\n\t\t\t\tfieldBg: \"rgba(255,255,255,0.06)\",\n\t\t\t\tfieldBorder: \"rgba(255,255,255,0.18)\",\n\t\t\t\toverlay: \"rgba(0,0,0,0.62)\",\n\t\t\t\tgrabber: \"rgba(255,255,255,0.22)\",\n\t\t }\n\t\t: {\n\t\t\t\tsheetBg: \"#ffffff\",\n\t\t\t\ttext: \"#111827\",\n\t\t\t\tmuted: \"#6b7280\",\n\t\t\t\tborder: \"#eceef1\",\n\t\t\t\tfieldBg: \"#f9fafb\",\n\t\t\t\tfieldBorder: \"#d1d5db\",\n\t\t\t\toverlay: \"rgba(15,23,42,0.45)\",\n\t\t\t\tgrabber: \"rgba(15,23,42,0.18)\",\n\t\t };\n}\n\nfunction promptInitialSeconds(prompt?: ActiveUserAction): number | undefined {\n\treturn prompt && typeof prompt.expirySeconds === \"number\" && prompt.expirySeconds > 0\n\t\t? Math.floor(prompt.expirySeconds)\n\t\t: undefined;\n}\n\n// Key that changes when a fresh / superseded prompt arrives (restarts timers).\nfunction promptTimerKey(prompt?: ActiveUserAction): string {\n\treturn prompt ? `${prompt.userActionId}|${prompt.subAction ?? \"\"}` : \"\";\n}\n\n// Expiry as a single boolean, driven by ONE setTimeout at the deadline. Unlike a\n// per-second interval at the chat level, this re-renders the host only once (on\n// expiry) instead of every second — which is what kept the whole chat tree from\n// repainting each tick.\nfunction useExpiredFlag(prompt?: ActiveUserAction): boolean {\n\tconst initial = promptInitialSeconds(prompt);\n\tconst key = promptTimerKey(prompt);\n\tconst [expired, setExpired] = useState(false);\n\tuseEffect(() => {\n\t\tsetExpired(false);\n\t\tif (initial === undefined) return;\n\t\tconst t = setTimeout(() => setExpired(true), initial * 1000);\n\t\treturn () => clearTimeout(t);\n\t}, [key, initial]);\n\treturn expired;\n}\n\n// Self-contained per-second tick used only by the small timer pills, so the\n// countdown display updates without re-rendering the chat or the form.\nfunction useSecondsLeft(expirySeconds?: number, restartKey?: string): number | undefined {\n\tconst initial =\n\t\ttypeof expirySeconds === \"number\" && expirySeconds > 0 ? Math.floor(expirySeconds) : undefined;\n\tconst [left, setLeft] = useState<number | undefined>(initial);\n\tuseEffect(() => {\n\t\tsetLeft(initial);\n\t\tif (initial === undefined) return;\n\t\tconst id = setInterval(() => {\n\t\t\tsetLeft((s) => (s === undefined ? s : s <= 1 ? 0 : s - 1));\n\t\t}, 1000);\n\t\treturn () => clearInterval(id);\n\t}, [restartKey, initial]);\n\treturn left;\n}\n\n// Timer pill for the sheet header (ticks internally).\nfunction SheetTimerPill({\n\tprompt,\n\taccent,\n\tisDark,\n}: {\n\tprompt: ActiveUserAction;\n\taccent: string;\n\tisDark: boolean;\n}) {\n\tconst left = useSecondsLeft(prompt.expirySeconds, promptTimerKey(prompt));\n\tif (left === undefined || prompt.status === \"stale\") return null;\n\tconst expired = left <= 0;\n\treturn (\n\t\t<View\n\t\t\tstyle={[\n\t\t\t\tsht.timer,\n\t\t\t\t{\n\t\t\t\t\tborderColor: expired ? \"#ef4444\" : accent + \"40\",\n\t\t\t\t\tbackgroundColor: expired ? \"rgba(239,68,68,0.10)\" : accent + (isDark ? \"1F\" : \"12\"),\n\t\t\t\t},\n\t\t\t]}\n\t\t>\n\t\t\t<Text style={{ color: expired ? \"#ef4444\" : accent, fontSize: 12.5, fontWeight: \"700\", letterSpacing: 0.2 }}>\n\t\t\t\t{expired ? \"Expired\" : `${left}s`}\n\t\t\t</Text>\n\t\t</View>\n\t);\n}\n\n// Timer pill for the inline resume card (ticks internally).\nfunction CardTimerPill({\n\tprompt,\n\taccent,\n\tisDark,\n}: {\n\tprompt: ActiveUserAction;\n\taccent: string;\n\tisDark: boolean;\n}) {\n\tconst left = useSecondsLeft(prompt.expirySeconds, promptTimerKey(prompt));\n\tif (left === undefined || left <= 0) return null;\n\treturn (\n\t\t<View style={[rc.timer, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t<Text style={{ color: accent, fontSize: 12, fontWeight: \"700\" }}>{left}s</Text>\n\t\t</View>\n\t);\n}\n\n// Segmented OTP boxes backed by a single hidden numeric input.\nfunction CodeInput({\n\tvalue,\n\tonChange,\n\tlength,\n\tdisabled,\n\terror,\n\taccent,\n\tpal,\n}: {\n\tvalue: string;\n\tonChange: (v: string) => void;\n\tlength: number;\n\tdisabled: boolean;\n\terror: boolean;\n\taccent: string;\n\tpal: UAPalette;\n}) {\n\tconst ref = useRef<TextInput>(null);\n\tuseEffect(() => {\n\t\tconst t = setTimeout(() => ref.current?.focus(), 380);\n\t\treturn () => clearTimeout(t);\n\t}, []);\n\treturn (\n\t\t<Pressable onPress={() => ref.current?.focus()} style={ub.codeRow}>\n\t\t\t{Array.from({ length }).map((_, i) => {\n\t\t\t\tconst ch = value[i] ?? \"\";\n\t\t\t\tconst isCursor = i === value.length && !disabled;\n\t\t\t\tconst bc = error ? \"#ef4444\" : isCursor ? accent : pal.fieldBorder;\n\t\t\t\treturn (\n\t\t\t\t\t<View key={i} style={[ub.codeBox, { borderColor: bc, backgroundColor: pal.fieldBg }]}>\n\t\t\t\t\t\t<Text style={[ub.codeChar, { color: pal.text }]}>{ch}</Text>\n\t\t\t\t\t</View>\n\t\t\t\t);\n\t\t\t})}\n\t\t\t<TextInput\n\t\t\t\tref={ref}\n\t\t\t\tvalue={value}\n\t\t\t\tonChangeText={(t) => onChange(t.replace(/[^0-9]/g, \"\").slice(0, length))}\n\t\t\t\tkeyboardType=\"number-pad\"\n\t\t\t\tmaxLength={length}\n\t\t\t\teditable={!disabled}\n\t\t\t\tcaretHidden\n\t\t\t\tstyle={ub.codeHidden}\n\t\t\t/>\n\t\t</Pressable>\n\t);\n}\n\nfunction PrimaryButton({\n\tlabel,\n\tonPress,\n\tdisabled,\n\taccent,\n}: {\n\tlabel: string;\n\tonPress: () => void;\n\tdisabled?: boolean;\n\taccent: string;\n}) {\n\tconst bg = accent || DEFAULT_ACCENT;\n\treturn (\n\t\t<Pressable\n\t\t\tonPress={onPress}\n\t\t\tdisabled={disabled}\n\t\t\tandroid_ripple={{ color: \"rgba(255,255,255,0.22)\" }}\n\t\t\tstyle={[ub.primaryBtn, { backgroundColor: bg, borderColor: bg, opacity: disabled ? 0.5 : 1 }]}\n\t\t>\n\t\t\t<Text style={ub.primaryBtnText}>{label}</Text>\n\t\t</Pressable>\n\t);\n}\n\n// Verification (one-time-code) body.\nfunction VerificationBody({\n\tprompt,\n\texpired,\n\tpal,\n\taccent,\n\tonSubmit,\n\tonCancel,\n\tonResend,\n}: {\n\tprompt: ActiveUserAction;\n\texpired: boolean;\n\tpal: UAPalette;\n\taccent: string;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n\tonResend: (id: string) => Promise<void>;\n}) {\n\tconst isNumeric = prompt.verificationType !== \"ALPHANUMERIC_CODE\";\n\tconst field = prompt.requestedSchema?.properties?.verificationCode;\n\tconst codeLen =\n\t\t(typeof field?.maxLength === \"number\" ? field.maxLength : undefined) ??\n\t\t(typeof field?.minLength === \"number\" ? field.minLength : undefined) ??\n\t\tDEFAULT_CODE_LEN;\n\n\tconst [code, setCode] = useState(\"\");\n\tconst [errored, setErrored] = useState(false);\n\tconst [resendSec, setResendSec] = useState(0);\n\tconst lastSubmitted = useRef<string | null>(null);\n\tconst resendTimer = useRef<ReturnType<typeof setInterval> | null>(null);\n\n\tconst busy = prompt.status === \"submitting\";\n\tconst stale = prompt.status === \"stale\";\n\tconst locked = busy || stale || expired;\n\n\tuseEffect(() => {\n\t\tif (prompt.subAction === \"SubmissionInvalid\") {\n\t\t\tsetErrored(true);\n\t\t\tsetCode(\"\");\n\t\t\tlastSubmitted.current = null;\n\t\t}\n\t}, [prompt.subAction, prompt.userActionId]);\n\n\tconst doSubmit = useCallback(\n\t\t(value: string) => {\n\t\t\tif (locked || !value) return;\n\t\t\tif (lastSubmitted.current === value) return;\n\t\t\tlastSubmitted.current = value;\n\t\t\tvoid onSubmit(prompt.userActionId, { verificationCode: value }).catch(() => {\n\t\t\t\tlastSubmitted.current = null;\n\t\t\t\tsetErrored(true);\n\t\t\t});\n\t\t},\n\t\t[locked, onSubmit, prompt.userActionId],\n\t);\n\n\t// Auto-submit a full numeric code.\n\tuseEffect(() => {\n\t\tif (!isNumeric || locked) return;\n\t\tif (code.length === codeLen && /^\\d+$/.test(code)) doSubmit(code);\n\t}, [code, codeLen, doSubmit, isNumeric, locked]);\n\n\tuseEffect(() => () => { if (resendTimer.current) clearInterval(resendTimer.current); }, []);\n\n\tconst handleResend = useCallback(async () => {\n\t\tif (locked || resendSec > 0) return;\n\t\tsetErrored(false);\n\t\tsetCode(\"\");\n\t\tlastSubmitted.current = null;\n\t\ttry {\n\t\t\tawait onResend(prompt.userActionId);\n\t\t\tsetResendSec(RESEND_COOLDOWN_S);\n\t\t\tif (resendTimer.current) clearInterval(resendTimer.current);\n\t\t\tresendTimer.current = setInterval(() => {\n\t\t\t\tsetResendSec((s) => {\n\t\t\t\t\tif (s <= 1) {\n\t\t\t\t\t\tif (resendTimer.current) clearInterval(resendTimer.current);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn s - 1;\n\t\t\t\t});\n\t\t\t}, 1000);\n\t\t} catch {\n\t\t\t/* hook surfaces the error */\n\t\t}\n\t}, [locked, onResend, prompt.userActionId, resendSec]);\n\n\tconst description =\n\t\tprompt.message?.trim() ||\n\t\t(isNumeric ? `Enter the ${codeLen}-digit code to continue` : \"Enter the verification code to continue\");\n\n\treturn (\n\t\t<View style={ub.bodyWrap}>\n\t\t\t<ScrollView\n\t\t\t\tstyle={ub.fieldsScroll}\n\t\t\t\tcontentContainerStyle={ub.fieldsContent}\n\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\tshowsVerticalScrollIndicator={false}\n\t\t\t>\n\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>{description}</Text>\n\n\t\t\t{isNumeric ? (\n\t\t\t\t<CodeInput\n\t\t\t\t\tvalue={code}\n\t\t\t\t\tonChange={(v) => { setErrored(false); setCode(v); }}\n\t\t\t\t\tlength={codeLen}\n\t\t\t\t\tdisabled={locked}\n\t\t\t\t\terror={errored}\n\t\t\t\t\taccent={accent}\n\t\t\t\t\tpal={pal}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<TextInput\n\t\t\t\t\tvalue={code}\n\t\t\t\t\tonChangeText={(t) => { setErrored(false); setCode(t); }}\n\t\t\t\t\teditable={!locked}\n\t\t\t\t\tplaceholder=\"Verification code\"\n\t\t\t\t\tplaceholderTextColor={pal.muted}\n\t\t\t\t\tautoComplete=\"one-time-code\"\n\t\t\t\t\tstyle={[\n\t\t\t\t\t\tub.input,\n\t\t\t\t\t\t{ color: pal.text, backgroundColor: pal.fieldBg, borderColor: errored ? \"#ef4444\" : pal.fieldBorder },\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t</ScrollView>\n\n\t\t\t<View style={ub.actions}>\n\t\t\t\t{!isNumeric && (\n\t\t\t\t\t<PrimaryButton\n\t\t\t\t\t\tlabel={busy ? \"Verifying…\" : \"Verify\"}\n\t\t\t\t\t\tonPress={() => doSubmit(code.trim())}\n\t\t\t\t\t\tdisabled={locked || !code.trim()}\n\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<View style={ub.linkRow}>\n\t\t\t\t\t<Pressable disabled={locked || resendSec > 0} onPress={() => void handleResend()}>\n\t\t\t\t\t\t<Text style={[ub.link, { color: accent, opacity: locked || resendSec > 0 ? 0.4 : 1 }]}>\n\t\t\t\t\t\t\t{resendSec > 0 ? `Resend (${resendSec}s)` : \"Resend\"}\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t\t<Pressable disabled={busy} onPress={() => void onCancel(prompt.userActionId)}>\n\t\t\t\t\t\t<Text style={[ub.link, ub.linkDanger, { opacity: busy ? 0.4 : 1 }]}>Cancel</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Schema-driven form body.\nfunction FormBody({\n\tprompt,\n\tpal,\n\taccent,\n\tisDark,\n\tonSubmit,\n\tonCancel,\n}: {\n\tprompt: ActiveUserAction;\n\tpal: UAPalette;\n\taccent: string;\n\tisDark: boolean;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n}) {\n\tconst schema = prompt.requestedSchema;\n\tconst fields = useMemo(() => renderableFields(schema), [schema]);\n\tconst [values, setValues] = useState<Record<string, unknown>>(() => {\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const [key, field] of fields) init[key] = defaultValueFor(field);\n\t\treturn init;\n\t});\n\tconst [errors, setErrors] = useState<Record<string, string>>({});\n\n\tconst busy = prompt.status === \"submitting\";\n\tconst stale = prompt.status === \"stale\";\n\tconst locked = busy || stale;\n\tconst isConfirm = prompt.subAction === \"UserConfirmation\";\n\n\tconst setValue = (key: string, v: unknown) => {\n\t\tsetValues((prev) => ({ ...prev, [key]: v }));\n\t\tsetErrors((prev) => {\n\t\t\tif (!prev[key]) return prev;\n\t\t\tconst next = { ...prev };\n\t\t\tdelete next[key];\n\t\t\treturn next;\n\t\t});\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (locked) return;\n\t\tconst validation = validateForm(schema, values);\n\t\tif (Object.keys(validation).length > 0) {\n\t\t\tsetErrors(validation);\n\t\t\treturn;\n\t\t}\n\t\tvoid onSubmit(prompt.userActionId, buildContent(schema, values)).catch(() => {});\n\t};\n\n\tconst mdStyles = isDark ? MD_STYLES_DARK : MD_STYLES_LIGHT;\n\tconst mdRules = useMemo(() => makeMdRules(isDark, accent), [isDark, accent]);\n\n\treturn (\n\t\t<View style={ub.bodyWrap}>\n\t\t\t<ScrollView\n\t\t\t\tstyle={ub.fieldsScroll}\n\t\t\t\tcontentContainerStyle={ub.fieldsContent}\n\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\tshowsVerticalScrollIndicator\n\t\t\t>\n\t\t\t{prompt.message?.trim() ? (\n\t\t\t\t<View style={ub.messageBlock}>\n\t\t\t\t\t<Markdown style={mdStyles} rules={mdRules}>\n\t\t\t\t\t\t{prompt.message.replace(/\\\\n/g, \"\\n\")}\n\t\t\t\t\t</Markdown>\n\t\t\t\t</View>\n\t\t\t) : null}\n\n\t\t\t<View style={ub.form}>\n\t\t\t\t{fields.map(([key, field]) => {\n\t\t\t\t\tconst widget = classifyField(field);\n\t\t\t\t\tconst label = field.title || key;\n\t\t\t\t\tconst required = isRequired(schema, key);\n\t\t\t\t\tconst err = errors[key];\n\n\t\t\t\t\tif (widget === \"boolean\") {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<View key={key} style={ub.switchRow}>\n\t\t\t\t\t\t\t\t<Text style={[ub.label, { color: pal.text, flex: 1 }]}>\n\t\t\t\t\t\t\t\t\t{label}{required ? <Text style={{ color: \"#ef4444\" }}> *</Text> : null}\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t<Switch\n\t\t\t\t\t\t\t\t\tvalue={Boolean(values[key])}\n\t\t\t\t\t\t\t\t\tdisabled={locked}\n\t\t\t\t\t\t\t\t\tonValueChange={(v) => setValue(key, v)}\n\t\t\t\t\t\t\t\t\ttrackColor={{ true: accent }}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={key} style={ub.field}>\n\t\t\t\t\t\t\t<Text style={[ub.label, { color: pal.text }]}>\n\t\t\t\t\t\t\t\t{label}{required ? <Text style={{ color: \"#ef4444\" }}> *</Text> : null}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t{field.description ? <Text style={[ub.hint, { color: pal.muted }]}>{field.description}</Text> : null}\n\n\t\t\t\t\t\t\t{widget === \"select\" ? (\n\t\t\t\t\t\t\t\t<View style={ub.optionList}>\n\t\t\t\t\t\t\t\t\t{getOptions(field).map((opt) => {\n\t\t\t\t\t\t\t\t\t\tconst selected = String(values[key] ?? \"\") === opt.const;\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\t\t\t\tkey={opt.const}\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={locked}\n\t\t\t\t\t\t\t\t\t\t\t\tonPress={() => setValue(key, opt.const)}\n\t\t\t\t\t\t\t\t\t\t\t\tandroid_ripple={{ color: accent + \"22\" }}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\tub.optionRow,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tborderColor: selected ? accent : pal.fieldBorder,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: selected ? accent + (isDark ? \"26\" : \"14\") : pal.fieldBg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tub.radio,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ borderColor: selected ? accent : pal.fieldBorder },\n\t\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<View style={[ub.radioDot, { backgroundColor: accent }]} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tub.optionLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ color: pal.text, fontWeight: selected ? \"600\" : \"500\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{opt.title || opt.const}\n\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\tvalue={String(values[key] ?? \"\")}\n\t\t\t\t\t\t\t\t\teditable={!locked}\n\t\t\t\t\t\t\t\t\tonChangeText={(t) => setValue(key, t)}\n\t\t\t\t\t\t\t\t\tplaceholder={field.description ? undefined : label}\n\t\t\t\t\t\t\t\t\tplaceholderTextColor={pal.muted}\n\t\t\t\t\t\t\t\t\tkeyboardType={widget === \"integer\" ? \"number-pad\" : widget === \"decimal\" ? \"decimal-pad\" : \"default\"}\n\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\tub.input,\n\t\t\t\t\t\t\t\t\t\t{ color: pal.text, backgroundColor: pal.fieldBg, borderColor: err ? \"#ef4444\" : pal.fieldBorder },\n\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{err ? <Text style={ub.error}>{err}</Text> : null}\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</View>\n\t\t\t</ScrollView>\n\n\t\t\t<View style={ub.actions}>\n\t\t\t\t<PrimaryButton\n\t\t\t\t\tlabel={busy ? \"Submitting…\" : isConfirm ? \"Confirm\" : \"Next\"}\n\t\t\t\t\tonPress={handleSubmit}\n\t\t\t\t\tdisabled={locked}\n\t\t\t\t\taccent={accent}\n\t\t\t\t/>\n\t\t\t\t<View style={ub.linkRow}>\n\t\t\t\t\t<Pressable disabled={busy} onPress={() => void onCancel(prompt.userActionId)}>\n\t\t\t\t\t\t<Text style={[ub.link, ub.linkDanger, { opacity: busy ? 0.4 : 1 }]}>Cancel</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// The animated, swipe-to-dismiss bottom sheet. Presents the active prompt as a\n// tall, polished sheet. Dismissing it (backdrop tap / swipe-down / the close\n// button) is a *minimize* — the run stays alive and the inline resume card takes\n// over. Only the explicit \"Cancel\" action cancels the prompt.\n//\n// It is rendered as an always-mounted, in-tree overlay (NOT a React Native\n// `Modal`). A `Modal` must unmount to let the user reach the chat behind it,\n// and re-presenting a native modal is visibly laggy. Keeping the layer mounted\n// and animating `translateY` on the native driver makes open/close instant and\n// preserves the user's in-progress input across minimize/reopen.\nfunction UserActionSheet({\n\topen,\n\tactive,\n\texpired,\n\tisDark,\n\taccent,\n\tinsetBottom,\n\tonSubmit,\n\tonCancel,\n\tonResend,\n\tonMinimize,\n}: {\n\topen: boolean;\n\tactive?: ActiveUserAction;\n\texpired: boolean;\n\tisDark: boolean;\n\taccent: string;\n\tinsetBottom: number;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n\tonResend: (id: string) => Promise<void>;\n\tonMinimize: () => void;\n}) {\n\tconst pal = uaPalette(isDark);\n\tconst screenH = Dimensions.get(\"window\").height;\n\n\t// Keep the last prompt rendered during the slide-out so content doesn't blank.\n\tconst [shown, setShown] = useState<ActiveUserAction | undefined>(active);\n\tuseEffect(() => {\n\t\tif (active) setShown(active);\n\t}, [active]);\n\n\tconst translateY = useRef(new Animated.Value(screenH)).current;\n\tconst backdrop = useRef(new Animated.Value(0)).current;\n\tconst minimizeRef = useRef(onMinimize);\n\tuseEffect(() => {\n\t\tminimizeRef.current = onMinimize;\n\t});\n\n\t// Keyboard avoidance: the sheet is an absolutely-positioned overlay, so the\n\t// chat's KeyboardAvoidingView doesn't lift it. Track the keyboard height and\n\t// raise the sheet ourselves so inputs (e.g. the OTP field) stay visible.\n\tconst [kbHeight, setKbHeight] = useState(0);\n\tuseEffect(() => {\n\t\tconst showEvt = Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\";\n\t\tconst hideEvt = Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\";\n\t\tconst s1 = Keyboard.addListener(showEvt, (e) => setKbHeight(e?.endCoordinates?.height ?? 0));\n\t\tconst s2 = Keyboard.addListener(hideEvt, () => setKbHeight(0));\n\t\treturn () => {\n\t\t\ts1.remove();\n\t\t\ts2.remove();\n\t\t};\n\t}, []);\n\n\t// Entrance / exit is driven purely by `open` — no mount/unmount churn.\n\tuseEffect(() => {\n\t\tif (open) {\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.spring(translateY, { toValue: 0, useNativeDriver: true, damping: 30, stiffness: 360, mass: 0.85 }),\n\t\t\t\tAnimated.timing(backdrop, { toValue: 1, duration: 190, useNativeDriver: true }),\n\t\t\t]).start();\n\t\t} else {\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.timing(translateY, { toValue: screenH, duration: 210, easing: Easing.in(Easing.cubic), useNativeDriver: true }),\n\t\t\t\tAnimated.timing(backdrop, { toValue: 0, duration: 170, useNativeDriver: true }),\n\t\t\t]).start();\n\t\t}\n\t}, [open, translateY, backdrop, screenH]);\n\n\t// Swipe-down-to-dismiss, anchored to the grabber / header zone. Releasing past\n\t// the threshold calls `onMinimize`; the `open` effect then slides it the rest\n\t// of the way out.\n\tconst pan = useRef(\n\t\tPanResponder.create({\n\t\t\tonMoveShouldSetPanResponder: (_evt, g) => g.dy > 6 && Math.abs(g.dy) > Math.abs(g.dx) * 1.4,\n\t\t\tonPanResponderMove: (_evt, g) => {\n\t\t\t\tif (g.dy > 0) translateY.setValue(g.dy);\n\t\t\t},\n\t\t\tonPanResponderRelease: (_evt, g) => {\n\t\t\t\tif (g.dy > 110 || g.vy > 0.8) {\n\t\t\t\t\tminimizeRef.current();\n\t\t\t\t} else {\n\t\t\t\t\tAnimated.spring(translateY, { toValue: 0, useNativeDriver: true, damping: 30, stiffness: 360 }).start();\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t).current;\n\n\tconst a = active ?? shown;\n\tif (!a) return <View pointerEvents=\"none\" />;\n\n\tconst isVerification = a.kind === \"verification\";\n\tconst title = isVerification ? \"Verification required\" : \"Action required\";\n\tconst subtitle = isVerification\n\t\t? \"Confirm the one-time code to continue\"\n\t\t: \"Review the details and confirm to continue\";\n\n\treturn (\n\t\t<View style={[StyleSheet.absoluteFill, sht.overlay]} pointerEvents={open ? \"auto\" : \"none\"}>\n\t\t\t<Animated.View\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t\tstyle={[sht.backdrop, { backgroundColor: pal.overlay, opacity: backdrop }]}\n\t\t\t/>\n\t\t\t{open ? (\n\t\t\t\t<Pressable style={StyleSheet.absoluteFill} onPress={() => minimizeRef.current()} accessibilityLabel=\"Dismiss\" />\n\t\t\t) : null}\n\n\t\t\t<View style={[sht.kav, { paddingBottom: kbHeight }]} pointerEvents=\"box-none\">\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={[\n\t\t\t\t\t\tsht.sheet,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbackgroundColor: pal.sheetBg,\n\t\t\t\t\t\t\tborderColor: pal.border,\n\t\t\t\t\t\t\t// Cap to the space above the keyboard (and a top margin) so the\n\t\t\t\t\t\t\t// header stays visible and the footer sits above the keyboard;\n\t\t\t\t\t\t\t// the field area scrolls within whatever's left.\n\t\t\t\t\t\t\tmaxHeight: Math.min(screenH * 0.9, screenH - kbHeight - 72),\n\t\t\t\t\t\t\tpaddingBottom: kbHeight > 0 ? 16 : Math.max(insetBottom, 16) + 6,\n\t\t\t\t\t\t\ttransform: [{ translateY }],\n\t\t\t\t\t\t},\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{/* Grab zone — owns the swipe-to-dismiss gesture. */}\n\t\t\t\t\t<View {...pan.panHandlers} style={sht.handleZone}>\n\t\t\t\t\t\t<View style={[sht.grabber, { backgroundColor: pal.grabber }]} />\n\t\t\t\t\t</View>\n\n\t\t\t\t\t<View style={sht.header}>\n\t\t\t\t\t\t<View style={[sht.iconCircle, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t\t\t\t\t{isVerification ? (\n\t\t\t\t\t\t\t\t<ShieldCheck size={20} color={accent} strokeWidth={2} />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Pencil size={18} color={accent} strokeWidth={2} />\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<View style={sht.headerText}>\n\t\t\t\t\t\t\t<Text style={[sht.title, { color: pal.text }]}>{title}</Text>\n\t\t\t\t\t\t\t<Text style={[sht.subtitle, { color: pal.muted }]} numberOfLines={1}>\n\t\t\t\t\t\t\t\t{subtitle}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<SheetTimerPill prompt={a} accent={accent} isDark={isDark} />\n\t\t\t\t\t\t<Pressable onPress={() => minimizeRef.current()} hitSlop={10} style={[sht.closeBtn, { backgroundColor: pal.fieldBg }]}>\n\t\t\t\t\t\t\t<X size={16} color={pal.muted} strokeWidth={2.2} />\n\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{a.status === \"stale\" ? (\n\t\t\t\t\t\t<View style={sht.simpleBody}>\n\t\t\t\t\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>This request is no longer available.</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t) : expired ? (\n\t\t\t\t\t\t<View style={sht.simpleBody}>\n\t\t\t\t\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>\n\t\t\t\t\t\t\t\t{isVerification ? \"This verification request expired.\" : \"This request expired.\"}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<View style={ub.actions}>\n\t\t\t\t\t\t\t\t<PrimaryButton label=\"Close\" onPress={() => void onCancel(a.userActionId)} accent={accent} />\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t) : isVerification ? (\n\t\t\t\t\t\t<VerificationBody\n\t\t\t\t\t\t\tkey={a.userActionId}\n\t\t\t\t\t\t\tprompt={a}\n\t\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\t\tpal={pal}\n\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\tonSubmit={onSubmit}\n\t\t\t\t\t\t\tonCancel={onCancel}\n\t\t\t\t\t\t\tonResend={onResend}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<FormBody key={a.userActionId} prompt={a} pal={pal} accent={accent} isDark={isDark} onSubmit={onSubmit} onCancel={onCancel} />\n\t\t\t\t\t)}\n\t\t\t\t</Animated.View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Inline \"resume\" card shown in the message stream while a prompt is minimized.\n// Carries the live countdown; tapping it re-opens the sheet. Rendered only while\n// the prompt is live (not expired / stale), so it vanishes on expiry and the\n// stream continues.\nfunction UserActionReopenCard({\n\tactive,\n\texpired,\n\tisDark,\n\taccent,\n\tonReopen,\n}: {\n\tactive: ActiveUserAction;\n\texpired: boolean;\n\tisDark: boolean;\n\taccent: string;\n\tonReopen: () => void;\n}) {\n\tif (expired || active.status === \"stale\") return null;\n\tconst pal = uaPalette(isDark);\n\tconst isVerification = active.kind === \"verification\";\n\tconst title = isVerification ? \"Verification required\" : \"Action required\";\n\n\treturn (\n\t\t<Pressable\n\t\t\tonPress={onReopen}\n\t\t\taccessibilityRole=\"button\"\n\t\t\taccessibilityLabel={`${title}. Tap to respond.`}\n\t\t\tandroid_ripple={{ color: accent + \"22\" }}\n\t\t\tstyle={[\n\t\t\t\trc.card,\n\t\t\t\t{\n\t\t\t\t\tbackgroundColor: pal.sheetBg,\n\t\t\t\t\tborderColor: accent + (isDark ? \"59\" : \"40\"),\n\t\t\t\t},\n\t\t\t]}\n\t\t>\n\t\t\t<View style={[rc.iconCircle, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t\t{isVerification ? (\n\t\t\t\t\t<ShieldCheck size={18} color={accent} strokeWidth={2} />\n\t\t\t\t) : (\n\t\t\t\t\t<Pencil size={16} color={accent} strokeWidth={2} />\n\t\t\t\t)}\n\t\t\t</View>\n\t\t\t<View style={rc.textWrap}>\n\t\t\t\t<Text style={[rc.title, { color: pal.text }]} numberOfLines={1}>\n\t\t\t\t\t{title}\n\t\t\t\t</Text>\n\t\t\t\t<Text style={[rc.subtitle, { color: pal.muted }]} numberOfLines={1}>\n\t\t\t\t\tTap to respond and continue\n\t\t\t\t</Text>\n\t\t\t</View>\n\t\t\t<CardTimerPill prompt={active} accent={accent} isDark={isDark} />\n\t\t\t<ChevronRight size={18} color={pal.muted} strokeWidth={2} />\n\t\t</Pressable>\n\t);\n}\n\n// Lightweight dismissible notification stack (one-way messages).\nfunction NotificationStack({\n\tnotifications,\n\tisDark,\n\tonDismiss,\n}: {\n\tnotifications: UserNotification[];\n\tisDark: boolean;\n\tonDismiss: (id: string) => void;\n}) {\n\tif (notifications.length === 0) return null;\n\tconst pal = uaPalette(isDark);\n\treturn (\n\t\t<View style={ub.noteStack}>\n\t\t\t{notifications.map((n) => (\n\t\t\t\t<View key={n.id} style={[ub.note, { backgroundColor: pal.fieldBg, borderColor: pal.border }]}>\n\t\t\t\t\t<Info size={14} color={pal.muted} strokeWidth={1.9} />\n\t\t\t\t\t<Text style={[ub.noteText, { color: pal.text }]}>{n.message}</Text>\n\t\t\t\t\t<Pressable onPress={() => onDismiss(n.id)} hitSlop={8}>\n\t\t\t\t\t\t<X size={14} color={pal.muted} strokeWidth={2} />\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t))}\n\t\t</View>\n\t);\n}\n\nconst ub = StyleSheet.create({\n\t// Body wrapper can shrink within the sheet's (bounded) maxHeight so the inner\n\t// field scroll takes over for tall forms while the footer stays pinned.\n\tbodyWrap: { flexShrink: 1 },\n\t// Field scroll region. flexShrink:1 + no flexGrow → hugs content for short\n\t// forms (no scroll), shrinks and scrolls only when the form exceeds the sheet.\n\tfieldsScroll: { flexShrink: 1 },\n\tfieldsContent: { paddingBottom: 6 },\n\tmessageBlock: { marginBottom: 18, marginTop: 2 },\n\tdesc: { fontSize: 14.5, lineHeight: 21, marginBottom: 16 },\n\tform: { gap: 18 },\n\tfield: { gap: 7 },\n\tlabel: { fontSize: 14, fontWeight: \"600\" },\n\thint: { fontSize: 12.5, lineHeight: 17 },\n\tinput: {\n\t\tborderWidth: 1,\n\t\tborderRadius: 12,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 13,\n\t\tfontSize: 16,\n\t},\n\terror: { color: \"#ef4444\", fontSize: 12.5, marginTop: 2 },\n\tswitchRow: { flexDirection: \"row\", alignItems: \"center\", gap: 12 },\n\t// Selectable option \"boxes\" for oneOf / enum single-select fields.\n\toptionList: { gap: 10 },\n\toptionRow: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 12,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 14,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 14,\n\t},\n\tradio: {\n\t\twidth: 20,\n\t\theight: 20,\n\t\tborderRadius: 10,\n\t\tborderWidth: 2,\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t},\n\tradioDot: { width: 10, height: 10, borderRadius: 5 },\n\toptionLabel: { flex: 1, fontSize: 15, letterSpacing: -0.1 },\n\t// Pinned footer (outside the fields scroll) — always visible.\n\tactions: { paddingTop: 16, gap: 14 },\n\tprimaryBtn: { minHeight: 52, borderRadius: 14, borderWidth: 1, paddingVertical: 15, alignItems: \"center\", justifyContent: \"center\" },\n\tprimaryBtnText: { color: \"#fff\", fontSize: 15.5, fontWeight: \"600\", letterSpacing: -0.1 },\n\tlinkRow: { flexDirection: \"row\", justifyContent: \"center\", gap: 24 },\n\tlink: { fontSize: 14, fontWeight: \"500\" },\n\tlinkDanger: { color: \"#dc2626\" },\n\tcodeRow: { flexDirection: \"row\", justifyContent: \"center\", gap: 9, position: \"relative\" },\n\tcodeBox: {\n\t\twidth: 46,\n\t\theight: 56,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 12,\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t},\n\tcodeChar: { fontSize: 24, fontWeight: \"600\" },\n\tcodeHidden: { ...StyleSheet.absoluteFillObject, opacity: 0 },\n\tnoteStack: { paddingHorizontal: 16, paddingBottom: 6, gap: 6 },\n\tnote: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 8,\n\t\tborderWidth: 1,\n\t\tborderRadius: 12,\n\t\tpaddingHorizontal: 12,\n\t\tpaddingVertical: 10,\n\t},\n\tnoteText: { flex: 1, fontSize: 13.5, lineHeight: 19 },\n});\n\n// Bottom-sheet shell styles.\nconst sht = StyleSheet.create({\n\t// High stacking so the sheet sits above the chat input bar (which carries its\n\t// own zIndex/elevation) and everything else in the chat.\n\toverlay: { zIndex: 100, ...Platform.select({ android: { elevation: 100 }, default: {} }) },\n\tbackdrop: { ...StyleSheet.absoluteFillObject },\n\tkav: { flex: 1, justifyContent: \"flex-end\" },\n\tsheet: {\n\t\tborderTopLeftRadius: 28,\n\t\tborderTopRightRadius: 28,\n\t\tborderWidth: StyleSheet.hairlineWidth,\n\t\tborderBottomWidth: 0,\n\t\tpaddingHorizontal: 22,\n\t\tpaddingTop: 6,\n\t\tmaxWidth: 640,\n\t\twidth: \"100%\",\n\t\talignSelf: \"center\",\n\t\t...Platform.select({\n\t\t\tios: {\n\t\t\t\tshadowColor: \"#000\",\n\t\t\t\tshadowOffset: { width: 0, height: -6 },\n\t\t\t\tshadowOpacity: 0.18,\n\t\t\t\tshadowRadius: 24,\n\t\t\t},\n\t\t\tandroid: { elevation: 24 },\n\t\t}),\n\t},\n\thandleZone: { alignItems: \"center\", paddingVertical: 10 },\n\tgrabber: { width: 40, height: 5, borderRadius: 3 },\n\theader: { flexDirection: \"row\", alignItems: \"center\", gap: 12, marginTop: 2, marginBottom: 18 },\n\ticonCircle: { width: 40, height: 40, borderRadius: 20, alignItems: \"center\", justifyContent: \"center\" },\n\theaderText: { flex: 1, gap: 2 },\n\ttitle: { fontSize: 18, fontWeight: \"700\", letterSpacing: -0.3 },\n\tsubtitle: { fontSize: 13, letterSpacing: -0.1 },\n\ttimer: { borderWidth: 1, borderRadius: 999, paddingHorizontal: 11, paddingVertical: 5, minWidth: 46, alignItems: \"center\" },\n\tcloseBtn: { width: 30, height: 30, borderRadius: 15, alignItems: \"center\", justifyContent: \"center\" },\n\t// Short, non-scrolling bodies (stale / expired notices).\n\tsimpleBody: { paddingBottom: 8 },\n});\n\n// Inline \"resume\" card styles (shown in the chat stream while minimized).\n// Rendered as a direct child of the message-list content, so it stretches to the\n// full row width on its own — no flex needed (flex:1 here would grow vertically).\nconst rc = StyleSheet.create({\n\tcard: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 12,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 18,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 13,\n\t\tmarginVertical: 6,\n\t},\n\ticonCircle: { width: 34, height: 34, borderRadius: 17, alignItems: \"center\", justifyContent: \"center\" },\n\ttextWrap: { flex: 1, gap: 1 },\n\ttitle: { fontSize: 14.5, fontWeight: \"700\", letterSpacing: -0.2 },\n\tsubtitle: { fontSize: 12.5, letterSpacing: -0.1 },\n\ttimer: { borderRadius: 999, paddingHorizontal: 9, paddingVertical: 4, minWidth: 40, alignItems: \"center\" },\n});\n\n// ─── PaymanChat (native) ──────────────────────────────────────────────────────\n\nexport const PaymanChat = forwardRef<PaymanChatRef, PaymanChatProps>(\n\tfunction PaymanChat({ config, callbacks, children, onLoadMoreMessages, isLoadingMoreMessages = false, hasMoreMessages = false }, ref) {\n\t\tconst accent = config.accent ?? DEFAULT_ACCENT;\n\n\t\t// Theme: explicit config override wins, else follow the device scheme.\n\t\tconst systemScheme = useColorScheme();\n\t\tconst isDark = (config.colorScheme ?? systemScheme) === \"dark\";\n\t\tconst ui = isDark\n\t\t\t? {\n\t\t\t\t\tlistBg: \"#0d1719\",\n\t\t\t\t\tinputText: \"rgba(255,255,255,0.92)\",\n\t\t\t\t\temptyText: \"rgba(255,255,255,0.55)\",\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tlistBg: \"#ffffff\",\n\t\t\t\t\tinputText: \"#1F2937\",\n\t\t\t\t\temptyText: \"#6b7280\",\n\t\t\t };\n\n\t\tconst callbacksRef = useRef(callbacks);\n\t\tuseEffect(() => { callbacksRef.current = callbacks; });\n\t\tconst stableCallbacks = useMemo(() => ({\n\t\t\tonSessionIdChange: (id: string | null) => callbacksRef.current?.onSessionIdChange?.(id),\n\t\t\tonStreamStart: () => callbacksRef.current?.onStreamStart?.(),\n\t\t\tonStreamEnd: () => callbacksRef.current?.onStreamEnd?.(),\n\t\t\tonError: (e: Error) => {\n\t\t\t\tconsole.error(\"[PaymanChat] stream error:\", e.message, e);\n\t\t\t\tcallbacksRef.current?.onError?.(e);\n\t\t\t},\n\t\t\tonStatusMessage: (m: string) => callbacksRef.current?.onStatusMessage?.(m),\n\t\t\tonStepsUpdate: (steps: any[]) => callbacksRef.current?.onStepsUpdate?.(steps),\n\t\t\tonUserActionRequired: (r: any) => {\n\t\t\t\tconsole.log(\"[PaymanChat] USER_ACTION_REQUIRED:\", JSON.stringify({ kind: r?.kind, rawAction: r?.rawAction, userActionId: r?.userActionId, hasSchema: !!r?.requestedSchema }));\n\t\t\t\tcallbacksRef.current?.onUserActionRequired?.(r);\n\t\t\t},\n\t\t\tonUserNotification: (n: any) => {\n\t\t\t\tconsole.log(\"[PaymanChat] USER_NOTIFICATION:\", JSON.stringify({ id: n?.id, message: n?.message }));\n\t\t\t\tcallbacksRef.current?.onUserNotification?.(n);\n\t\t\t},\n\t\t}), []);\n\n\t\tconst {\n\t\t\tmessages, sendMessage, isWaitingForResponse,\n\t\t\tresetSession, clearMessages, prependMessages,\n\t\t\tcancelStream, getSessionId, getMessages,\n\t\t\tuserActionState, submitUserAction, cancelUserAction,\n\t\t\tresendUserAction, dismissNotification,\n\t\t} = useChatV2(config, stableCallbacks);\n\n\t\t// Diagnostic: surface active prompt/notification counts as they change.\n\t\tuseEffect(() => {\n\t\t\tconsole.log(\n\t\t\t\t\"[PaymanChat] userActionState ->\",\n\t\t\t\t\"prompts:\", userActionState.prompts.length,\n\t\t\t\tuserActionState.prompts.map((p) => `${p.kind}:${p.status}`).join(\",\"),\n\t\t\t\t\"| notifications:\", userActionState.notifications.length,\n\t\t\t);\n\t\t}, [userActionState]);\n\n\t\t// ── Active user-action prompt presentation ──\n\t\t// The first non-notification prompt drives the sheet. Expiry is tracked as a\n\t\t// single boolean (one timeout, re-renders once) — the live per-second display\n\t\t// lives in the small timer pills so the chat tree doesn't repaint each tick.\n\t\tconst activePrompt = useMemo(\n\t\t\t() => userActionState.prompts.find((p) => p.kind !== \"notification\"),\n\t\t\t[userActionState.prompts],\n\t\t);\n\t\tconst expired = useExpiredFlag(activePrompt);\n\t\tconst [dismissedActionId, setDismissedActionId] = useState<string | null>(null);\n\t\t// A fresh / superseded prompt always (re)opens the sheet.\n\t\tuseEffect(() => {\n\t\t\tif (activePrompt) setDismissedActionId(null);\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, [activePrompt?.userActionId, activePrompt?.subAction]);\n\t\tconst sheetOpen = !!activePrompt && dismissedActionId !== activePrompt.userActionId;\n\t\tconst showReopenCard =\n\t\t\t!!activePrompt && !sheetOpen && !expired && activePrompt.status !== \"stale\";\n\t\tconst minimizeActivePrompt = useCallback(() => {\n\t\t\tsetDismissedActionId((prev) => activePrompt?.userActionId ?? prev);\n\t\t}, [activePrompt?.userActionId]);\n\n\t\tconst {\n\t\t\ttranscribedText, isAvailable: voiceAvailable,\n\t\t\tisRecording, startRecording, stopRecording, clearTranscript,\n\t\t} = useVoice(\n\t\t\t{ lang: \"en-US\", interimResults: true, continuous: true },\n\t\t\t{ onError: (e) => console.error(\"Voice error:\", e) },\n\t\t);\n\n\t\tconst [inputValue, setInputValue] = useState(\"\");\n\t\tconst [recordingSeconds, setRecordingSeconds] = useState(0);\n\t\tconst recordingStartRef = useRef<number | null>(null);\n\t\tconst recordingTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n\t\tuseImperativeHandle(ref, () => ({ resetSession, clearMessages, cancelStream, getSessionId, getMessages }));\n\n\t\tconst contextValue = useMemo(() => ({\n\t\t\tresetSession, clearMessages, prependMessages,\n\t\t\tcancelStream, getSessionId, getMessages, isWaitingForResponse,\n\t\t}), [resetSession, clearMessages, prependMessages, cancelStream, getSessionId, getMessages, isWaitingForResponse]);\n\n\t\tuseEffect(() => {\n\t\t\tif (isRecording) {\n\t\t\t\trecordingStartRef.current = Date.now();\n\t\t\t\tsetRecordingSeconds(0);\n\t\t\t\trecordingTimerRef.current = setInterval(() => {\n\t\t\t\t\tif (recordingStartRef.current != null)\n\t\t\t\t\t\tsetRecordingSeconds(Math.floor((Date.now() - recordingStartRef.current) / 1000));\n\t\t\t\t}, 1000);\n\t\t\t} else {\n\t\t\t\trecordingStartRef.current = null;\n\t\t\t\tif (recordingTimerRef.current) { clearInterval(recordingTimerRef.current); recordingTimerRef.current = null; }\n\t\t\t\tsetRecordingSeconds(0);\n\t\t\t}\n\t\t\treturn () => { if (recordingTimerRef.current) clearInterval(recordingTimerRef.current); };\n\t\t}, [isRecording]);\n\n\t\tconst prevInput = useRef(inputValue);\n\t\tuseEffect(() => {\n\t\t\tconst wasEmpty = prevInput.current.trim() === \"\";\n\t\t\tconst isEmpty = inputValue.trim() === \"\";\n\t\t\tprevInput.current = inputValue;\n\t\t\tif (!wasEmpty && isEmpty) { clearTranscript(); if (isRecording) stopRecording(); }\n\t\t}, [inputValue, clearTranscript, isRecording, stopRecording]);\n\n\t\tconst handleSend = useCallback(() => {\n\t\t\tif (isRecording) stopRecording();\n\t\t\tconst text = inputValue.trim();\n\t\t\tif (!text || isWaitingForResponse) return;\n\t\t\tconsole.log(\"[PaymanChat] sending. baseUrl:\", config.api?.baseUrl, \"agentId:\", config.agentId, \"stage:\", config.stage, \"sessionOwnerId:\", config.sessionParams?.id);\n\t\t\tsetInputValue(\"\");\n\t\t\tvoid sendMessage(text);\n\t\t}, [inputValue, isWaitingForResponse, sendMessage, isRecording, stopRecording, config]);\n\n\t\tconst handleVoicePress = useCallback(async () => {\n\t\t\tif (!voiceAvailable) return;\n\t\t\tclearTranscript();\n\t\t\tawait startRecording();\n\t\t}, [voiceAvailable, startRecording, clearTranscript]);\n\n\t\tconst handleConfirmRecording = useCallback(() => {\n\t\t\tstopRecording();\n\t\t\tif (transcribedText.trim()) setInputValue(transcribedText);\n\t\t}, [stopRecording, transcribedText]);\n\n\t\tconst handleCancelRecording = useCallback(() => { stopRecording(); clearTranscript(); }, [stopRecording, clearTranscript]);\n\n\t\t// The text field stays editable while a response streams (the user can draft\n\t\t// their next message); only a missing session disables typing. Send/voice are\n\t\t// gated on `isStreaming` inside InputBar instead.\n\t\tconst isInputDisabled = !(config.sessionParams?.id?.trim());\n\t\tconst enableVoice = config.enableVoice !== false;\n\t\tconst isEmpty = messages.length === 0;\n\n\t\t// Track which assistant message IDs should use the typing effect.\n\t\t// Initialized with the current message count so history messages are excluded.\n\t\t// Any assistant message added after mount gets the typing animation.\n\t\tconst prevMessageCountRef = useRef(messages.length);\n\t\tconst typingMessageIds = useRef(new Set<string>());\n\t\tuseEffect(() => {\n\t\t\tif (messages.length > prevMessageCountRef.current) {\n\t\t\t\tconst newMsgs = messages.slice(prevMessageCountRef.current);\n\t\t\t\tnewMsgs.forEach((m) => {\n\t\t\t\t\tif (m.role === \"assistant\") typingMessageIds.current.add(m.id);\n\t\t\t\t});\n\t\t\t}\n\t\t\tprevMessageCountRef.current = messages.length;\n\t\t}, [messages]);\n\n\n\t\tconst scrollRef = useRef<ScrollView>(null);\n\t\tconst scrollToBottom = useCallback((animated = true) => {\n\t\t\tscrollRef.current?.scrollToEnd({ animated });\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tconst t = setTimeout(() => scrollToBottom(true), 60);\n\t\t\treturn () => clearTimeout(t);\n\t\t}, [messages, scrollToBottom]);\n\n\t\treturn (\n\t\t\t<PaymanChatContext.Provider value={contextValue}>\n\t\t\t\t<KeyboardAvoidingView\n\t\t\t\t\tstyle={s.container}\n\t\t\t\t\tbehavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n\t\t\t\t\tkeyboardVerticalOffset={0}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\n\t\t\t\t\t{/* Message list / empty state */}\n\t\t\t\t\t<View style={[s.messageListWrap, { backgroundColor: ui.listBg }]}>\n\t\t\t\t\t\t{isEmpty && !isWaitingForResponse ? (\n\t\t\t\t\t\t\t<View style={s.emptyState}>\n\t\t\t\t\t\t\t\t{config.emptyStateComponent}\n\t\t\t\t\t\t\t\t{config.emptyStateComponent != null && <View style={{ height: 16 }} />}\n\t\t\t\t\t\t\t\t<Text style={[s.emptyText, { color: ui.emptyText }]}>\n\t\t\t\t\t\t\t\t\t{config.emptyStateText ?? \"How can I help you today?\"}\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\tref={scrollRef}\n\t\t\t\t\t\t\t\tstyle={s.scrollList}\n\t\t\t\t\t\t\t\tcontentContainerStyle={s.listContent}\n\t\t\t\t\t\t\t\tshowsVerticalScrollIndicator={false}\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\t\t\t\t\tonContentSizeChange={() => scrollToBottom(false)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{messages.map((msg) => (\n\t\t\t\t\t\t\t\t\t<MessageBubble\n\t\t\t\t\t\t\t\t\t\tkey={msg.id}\n\t\t\t\t\t\t\t\t\t\tmessage={msg}\n\t\t\t\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\t\t\t\tshouldType={typingMessageIds.current.has(msg.id)}\n\t\t\t\t\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\t\t\t\t\tsuppressText={\n\t\t\t\t\t\t\t\t\t\t\tactivePrompt?.message &&\n\t\t\t\t\t\t\t\t\t\t\tmsg.role === \"assistant\" &&\n\t\t\t\t\t\t\t\t\t\t\tmsg.id === messages[messages.length - 1]?.id\n\t\t\t\t\t\t\t\t\t\t\t\t? activePrompt.message\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t{/* Inline resume card while the action sheet is minimized */}\n\t\t\t\t\t\t\t\t{showReopenCard && activePrompt ? (\n\t\t\t\t\t\t\t\t\t<UserActionReopenCard\n\t\t\t\t\t\t\t\t\t\tactive={activePrompt}\n\t\t\t\t\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\t\t\t\tonReopen={() => setDismissedActionId(null)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t<View style={{ height: 4 }} />\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{/* One-way notifications, just above the input */}\n\t\t\t\t\t<NotificationStack\n\t\t\t\t\t\tnotifications={userActionState.notifications}\n\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\tonDismiss={dismissNotification}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Input bar */}\n\t\t\t\t\t<View style={s.inputBarWrap}>\n\t\t\t\t\t\t<InputBar\n\t\t\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t\t\tonChange={setInputValue}\n\t\t\t\t\t\t\tonSend={handleSend}\n\t\t\t\t\t\t\tonCancel={cancelStream}\n\t\t\t\t\t\t\tdisabled={isInputDisabled}\n\t\t\t\t\t\t\tplaceholder={config.placeholder ?? \"Type your message...\"}\n\t\t\t\t\t\t\tisStreaming={isWaitingForResponse}\n\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\tenableVoice={enableVoice}\n\t\t\t\t\t\t\tvoiceAvailable={enableVoice && voiceAvailable}\n\t\t\t\t\t\t\tisRecording={enableVoice && isRecording}\n\t\t\t\t\t\t\trecordingSeconds={recordingSeconds}\n\t\t\t\t\t\t\ttranscribedText={transcribedText}\n\t\t\t\t\t\t\tonVoicePress={handleVoicePress}\n\t\t\t\t\t\t\tonConfirmRecording={handleConfirmRecording}\n\t\t\t\t\t\t\tonCancelRecording={handleCancelRecording}\n\t\t\t\t\t\t\tonFocus={() => {}}\n\t\t\t\t\t\t\tinsetBottom={config.contentInsetBottom ?? (Platform.OS === \"ios\" ? 20 : 8)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{/* Animated, swipe-to-dismiss sheet for form / verification prompts.\n\t\t\t\t\t Rendered inside the chat KAV (same parent as the input bar) with a\n\t\t\t\t\t high zIndex so it reliably sits above the input and message list. */}\n\t\t\t\t\t<UserActionSheet\n\t\t\t\t\t\topen={sheetOpen}\n\t\t\t\t\t\tactive={activePrompt}\n\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\tinsetBottom={config.contentInsetBottom ?? (Platform.OS === \"ios\" ? 20 : 8)}\n\t\t\t\t\t\tonSubmit={submitUserAction}\n\t\t\t\t\t\tonCancel={cancelUserAction}\n\t\t\t\t\t\tonResend={resendUserAction}\n\t\t\t\t\t\tonMinimize={minimizeActivePrompt}\n\t\t\t\t\t/>\n\t\t\t\t</KeyboardAvoidingView>\n\t\t\t</PaymanChatContext.Provider>\n\t\t);\n\t},\n);\n\n// ─── Styles ───────────────────────────────────────────────────────────────────\n\nconst s = StyleSheet.create({\n\tcontainer: { flex: 1, backgroundColor: \"#f1f5f9\" },\n\tmessageListWrap: { flex: 1, minHeight: 0, backgroundColor: \"#ffffff\" },\n\tinputBarWrap: {\n\t\twidth: \"100%\",\n\t\tzIndex: 2,\n\t\tbackgroundColor: \"#ffffff\",\n\t\t...Platform.select({ android: { elevation: 8 }, default: {} }),\n\t},\n\n\t// ── Input bar ──\n\touterBar: {\n\t\twidth: \"100%\",\n\t\tbackgroundColor: \"#f1f5f9\",\n\t\tborderTopWidth: 1,\n\t\tborderTopColor: \"rgba(0,0,0,0.08)\",\n\t\tpaddingTop: 6,\n\t\tpaddingHorizontal: 12,\n\t\tborderTopLeftRadius: 20,\n\t\tborderTopRightRadius: 20,\n\t},\n\touterBarVoice: {},\n\tcolumn: { maxWidth: 672, width: \"100%\", alignSelf: \"center\", gap: 2 },\n\tinputWrap: { width: \"100%\", justifyContent: \"center\", paddingHorizontal: 4 },\n\tinputWrapRelative: { position: \"relative\" },\n\tinput: {\n\t\tminHeight: 36,\n\t\tmaxHeight: 110,\n\t\tpaddingVertical: 8,\n\t\tpaddingHorizontal: 16,\n\t\tfontSize: 16,\n\t\tcolor: \"#1F2937\",\n\t\tlineHeight: 22,\n\t},\n\tinputDisabled: { opacity: 0.5 },\n\tinputHidden: { position: \"absolute\", left: 0, right: 0, top: 0, opacity: 0, zIndex: 0 },\n\tactionsRow: { flexDirection: \"row\", justifyContent: \"flex-end\", alignItems: \"center\", marginBottom: 2 },\n\trightActions: { flexDirection: \"row\", alignItems: \"center\", gap: 6 },\n\ticonBtn: { width: 28, height: 28, justifyContent: \"center\", alignItems: \"center\", borderRadius: 14, overflow: \"hidden\" },\n\ticonBtnInner: { width: 28, height: 28, justifyContent: \"center\", alignItems: \"center\", backgroundColor: \"rgba(0,0,0,0.1)\", borderRadius: 14 },\n\tsendBtn: { width: 28, height: 28, borderRadius: 14, overflow: \"hidden\", justifyContent: \"center\", alignItems: \"center\" },\n\tsendBtnInner: { width: 28, height: 28, borderRadius: 14, justifyContent: \"center\", alignItems: \"center\" },\n\tbtnDisabled: { opacity: 0.35 },\n\tpressed: { opacity: 0.7 },\n\tdisclaimerWrap: { maxWidth: 672, width: \"100%\", alignSelf: \"center\", paddingHorizontal: 12, marginTop: 2 },\n\tdisclaimerText: { fontSize: 10, lineHeight: 13, color: \"#9CA3AF\", textAlign: \"center\" },\n\n\t// ── Voice bar ──\n\tvoiceBarContainer: { position: \"absolute\", left: 0, right: 0, top: 0, bottom: 0, justifyContent: \"center\", zIndex: 1 },\n\tvoiceBar: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", borderWidth: 1, borderRadius: 28, minHeight: 56, paddingHorizontal: 12, paddingVertical: 10, gap: 12 },\n\tvoiceBarCircle: { width: 40, height: 40, borderRadius: 20, alignItems: \"center\", justifyContent: \"center\" },\n\tvoiceConfirm: { backgroundColor: \"#FFFFFF\", borderWidth: 1 },\n\tvoiceBarCenter: { flex: 1, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", gap: 10, marginLeft: 8 },\n\tvoiceDots: { flex: 1, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", gap: 4 },\n\tvoiceDot: { width: 4, borderRadius: 2 },\n\tvoiceTimer: { fontSize: 15, fontWeight: \"600\", minWidth: 36, textAlign: \"right\" },\n\n\t// ── Messages ──\n\tscrollList: { flex: 1 },\n\tlistContent: { paddingHorizontal: 16, paddingTop: 8, paddingBottom: 4, flexGrow: 1 },\n\temptyState: { flex: 1, alignItems: \"center\", justifyContent: \"center\", paddingHorizontal: 32, paddingBottom: 60 },\n\temptyText: { fontSize: 16, color: \"#6b7280\", textAlign: \"center\" },\n});\n\nconst sd = StyleSheet.create({\n\tbubbleRow: { flexDirection: \"row\", marginVertical: 3 },\n\trowUser: { justifyContent: \"flex-end\" },\n\trowAssistant: { justifyContent: \"flex-start\" },\n\tbubble: { maxWidth: \"82%\", paddingHorizontal: 14, paddingVertical: 10, borderRadius: 18 },\n\tbubbleUser: { borderBottomRightRadius: 4 },\n\tbubbleAssistant: { backgroundColor: \"#f3f4f6\", borderBottomLeftRadius: 4 },\n\t// Assistant bubbles stretch wider so tables and code blocks have room\n\tbubbleAssistantWide: { maxWidth: \"97%\" },\n\tbubbleError: { backgroundColor: \"#fef2f2\" },\n\tbubbleText: { fontSize: 15, lineHeight: 22 },\n\ttextUser: { color: \"#ffffff\" },\n\ttextAssistant: { color: \"#111827\" },\n\terrorText: { fontSize: 14, lineHeight: 20, color: \"#dc2626\" },\n\tpartialErrorText: { fontSize: 12, color: \"#dc2626\", marginTop: 4 },\n\tcancelledText: { fontSize: 12, color: \"#9ca3af\", marginTop: 4, fontStyle: \"italic\" },\n\tthinkingRow: { flexDirection: \"row\", alignItems: \"flex-start\", gap: 6, marginBottom: 3 },\n\tthinkingIcon: { fontSize: 12, lineHeight: 20, width: 14 },\n\tthinkingStepText: { flex: 1, fontSize: 14, lineHeight: 20, color: \"#374151\", fontStyle: \"italic\" },\n\tthinkingStepDone: { color: \"#9ca3af\" },\n});\n\n// Theme palette for markdown rendering (light/dark parity with the host app).\nfunction mdPalette(isDark: boolean) {\n\treturn isDark\n\t\t? {\n\t\t\t\ttext: \"rgba(255,255,255,0.92)\",\n\t\t\t\theading: \"#ffffff\",\n\t\t\t\tmuted: \"rgba(255,255,255,0.55)\",\n\t\t\t\tborder: \"rgba(255,255,255,0.16)\",\n\t\t\t\tborderSoft: \"rgba(255,255,255,0.10)\",\n\t\t\t\theaderBg: \"rgba(255,255,255,0.07)\",\n\t\t\t\tcodeInlineBg: \"rgba(255,255,255,0.12)\",\n\t\t\t\tcodeInlineText: \"#e8eaed\",\n\t\t\t\tcodeBlockBg: \"#0b1416\",\n\t\t\t\tcodeBlockText: \"#f3f4f6\",\n\t\t\t\tblockquoteBar: \"rgba(255,255,255,0.22)\",\n\t\t\t\thr: \"rgba(255,255,255,0.14)\",\n\t\t\t\tlink: \"#34c3cc\",\n\t\t }\n\t\t: {\n\t\t\t\ttext: \"#1f2937\",\n\t\t\t\theading: \"#111827\",\n\t\t\t\tmuted: \"#4b5563\",\n\t\t\t\tborder: \"#d1d5db\",\n\t\t\t\tborderSoft: \"#e5e7eb\",\n\t\t\t\theaderBg: \"#f3f4f6\",\n\t\t\t\tcodeInlineBg: \"#e5e7eb\",\n\t\t\t\tcodeInlineText: \"#1f2937\",\n\t\t\t\tcodeBlockBg: \"#1f2937\",\n\t\t\t\tcodeBlockText: \"#f9fafb\",\n\t\t\t\tblockquoteBar: \"#d1d5db\",\n\t\t\t\thr: \"#e5e7eb\",\n\t\t\t\tlink: \"#00858d\",\n\t\t };\n}\n\n// Per-column content sizing. react-native-markdown-display renders each row\n// independently with no shared column model, so neither auto-width nor cross-row\n// alignment work out of the box. We render the table ourselves: pull the cell\n// text out of the AST, size each column to its widest cell (clamped), and lay\n// out an aligned grid. Short columns (#, Type) stay narrow; long names get room.\nconst TABLE_CHAR_W = 7.6; // approx px per char at fontSize 13\nconst TABLE_CELL_PAD = 26; // horizontal padding budget per cell\nconst TABLE_MIN_W = 44;\nconst TABLE_MAX_W = 220;\n\n// Recursively collect the visible text of a markdown AST node.\nfunction nodeText(node: any): string {\n\tif (!node) return \"\";\n\tif (Array.isArray(node.children) && node.children.length) {\n\t\treturn node.children.map(nodeText).join(\"\");\n\t}\n\treturn typeof node.content === \"string\" ? node.content : \"\";\n}\n\n// Flatten a `table` AST node into a matrix of cell strings (first row = header).\nfunction tableMatrix(tableNode: any): string[][] {\n\tconst rows: string[][] = [];\n\tconst walk = (n: any) => {\n\t\tif (!n) return;\n\t\tif (n.type === \"tr\") {\n\t\t\trows.push((n.children || []).map(nodeText));\n\t\t\treturn;\n\t\t}\n\t\t(n.children || []).forEach(walk);\n\t};\n\twalk(tableNode);\n\treturn rows;\n}\n\n// Markdown render rules — fully custom, content-sized, themed table.\nfunction makeMdRules(isDark: boolean, accent: string) {\n\tconst c = mdPalette(isDark);\n\t// 8-digit hex alpha: brand-tinted header so the theme is clearly visible.\n\tconst headerBg = isDark ? accent + \"2E\" : accent + \"14\";\n\tconst headerText = isDark ? \"#8fe3e9\" : accent;\n\n\treturn {\n\t\ttable: (node: any) => {\n\t\t\tconst rows = tableMatrix(node);\n\t\t\tif (rows.length === 0) return null;\n\t\t\tconst ncols = Math.max(...rows.map((r) => r.length));\n\n\t\t\tconst colW: number[] = [];\n\t\t\tfor (let ci = 0; ci < ncols; ci++) {\n\t\t\t\tlet maxLen = 0;\n\t\t\t\tfor (const r of rows) maxLen = Math.max(maxLen, (r[ci] || \"\").length);\n\t\t\t\tcolW[ci] = Math.min(\n\t\t\t\t\tTABLE_MAX_W,\n\t\t\t\t\tMath.max(TABLE_MIN_W, Math.round(maxLen * TABLE_CHAR_W) + TABLE_CELL_PAD),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<ScrollView\n\t\t\t\t\tkey={node.key}\n\t\t\t\t\thorizontal\n\t\t\t\t\tshowsHorizontalScrollIndicator={true}\n\t\t\t\t\tstyle={{ marginVertical: 8 }}\n\t\t\t\t>\n\t\t\t\t\t<View style={{ borderWidth: 1, borderColor: c.border, borderRadius: 8, overflow: \"hidden\" }}>\n\t\t\t\t\t\t{rows.map((cells, ri) => {\n\t\t\t\t\t\t\tconst isHeader = ri === 0;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tkey={ri}\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tflexDirection: \"row\",\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: isHeader ? headerBg : \"transparent\",\n\t\t\t\t\t\t\t\t\t\tborderTopWidth: ri === 0 ? 0 : 1,\n\t\t\t\t\t\t\t\t\t\tborderTopColor: c.borderSoft,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{Array.from({ length: ncols }).map((_, ci) => (\n\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\tkey={ci}\n\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\twidth: colW[ci],\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingHorizontal: 12,\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingVertical: 9,\n\t\t\t\t\t\t\t\t\t\t\t\tborderRightWidth: ci === ncols - 1 ? 0 : 1,\n\t\t\t\t\t\t\t\t\t\t\t\tborderRightColor: c.borderSoft,\n\t\t\t\t\t\t\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tfontSize: 13,\n\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight: 18,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcolor: isHeader ? headerText : c.text,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfontWeight: isHeader ? \"700\" : \"400\",\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{cells[ci] ?? \"\"}\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</View>\n\t\t\t\t</ScrollView>\n\t\t\t);\n\t\t},\n\t};\n}\n\n// Markdown styles for react-native-markdown-display, themed light/dark.\nfunction makeMdStyles(isDark: boolean) {\n\tconst c = mdPalette(isDark);\n\tconst mono = Platform.OS === \"ios\" ? \"Menlo\" : \"monospace\";\n\treturn {\n\t\t// Body\n\t\tbody: { color: c.text, fontSize: 14, lineHeight: 21 },\n\t\tparagraph: { marginTop: 0, marginBottom: 4 },\n\n\t\t// Emphasis\n\t\tstrong: { fontWeight: \"700\" as const, color: c.text },\n\t\tem: { fontStyle: \"italic\" as const, color: c.text },\n\n\t\t// Links\n\t\tlink: { color: c.link, textDecorationLine: \"underline\" as const },\n\n\t\t// Inline code\n\t\tcode_inline: {\n\t\t\tbackgroundColor: c.codeInlineBg,\n\t\t\tcolor: c.codeInlineText,\n\t\t\tfontFamily: mono,\n\t\t\tfontSize: 12,\n\t\t\tpaddingHorizontal: 4,\n\t\t\tborderRadius: 4,\n\t\t},\n\t\tcode_inline_container: { borderRadius: 4 },\n\n\t\t// Code blocks\n\t\tfence: { backgroundColor: c.codeBlockBg, borderRadius: 8, padding: 12, marginVertical: 6 },\n\t\tcode_block: { backgroundColor: c.codeBlockBg, borderRadius: 8, padding: 12, marginVertical: 6 },\n\t\tfence_code: { color: c.codeBlockText, fontFamily: mono, fontSize: 12 },\n\n\t\t// Lists\n\t\tbullet_list: { marginVertical: 4 },\n\t\tordered_list: { marginVertical: 4 },\n\t\tlist_item: { marginVertical: 1 },\n\t\tbullet_list_icon: { color: c.muted, marginTop: 6 },\n\t\tordered_list_icon: { color: c.muted },\n\t\tlist_item_text: { fontSize: 14, color: c.text },\n\n\t\t// Headings\n\t\theading1: { fontSize: 18, fontWeight: \"700\" as const, color: c.heading, marginBottom: 6, marginTop: 8 },\n\t\theading2: { fontSize: 16, fontWeight: \"700\" as const, color: c.heading, marginBottom: 4, marginTop: 6 },\n\t\theading3: { fontSize: 15, fontWeight: \"600\" as const, color: c.heading, marginBottom: 4, marginTop: 4 },\n\n\t\t// Blockquote / HR\n\t\tblockquote: { borderLeftWidth: 3, borderLeftColor: c.blockquoteBar, paddingLeft: 10, marginVertical: 4 },\n\t\thr: { backgroundColor: c.hr, height: 1, marginVertical: 8 },\n\n\t\t// Tables are rendered by a fully custom `table` rule (see makeMdRules) —\n\t\t// no per-cell styles needed here.\n\t};\n}\n\n// Precompute both style themes once (cheap). Rules depend on `accent` too, so\n// they're built per-message via useMemo in AssistantBubble.\nconst MD_STYLES_LIGHT = makeMdStyles(false);\nconst MD_STYLES_DARK = makeMdStyles(true);\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Utility function to merge Tailwind CSS classes\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","/**\n * Format a timestamp to a readable date/time string\n */\nexport function formatDate(timestamp: string | Date): string {\n\tconst date = typeof timestamp === \"string\" ? new Date(timestamp) : timestamp;\n\n\tconst now = new Date();\n\tconst diffMs = now.getTime() - date.getTime();\n\tconst diffMins = Math.floor(diffMs / 60000);\n\tconst diffHours = Math.floor(diffMs / 3600000);\n\tconst diffDays = Math.floor(diffMs / 86400000);\n\n\t// Less than a minute\n\tif (diffMins < 1) {\n\t\treturn \"Just now\";\n\t}\n\n\t// Less than an hour\n\tif (diffMins < 60) {\n\t\treturn `${diffMins}m ago`;\n\t}\n\n\t// Less than a day\n\tif (diffHours < 24) {\n\t\treturn `${diffHours}h ago`;\n\t}\n\n\t// Less than a week\n\tif (diffDays < 7) {\n\t\treturn `${diffDays}d ago`;\n\t}\n\n\t// Format as date\n\treturn date.toLocaleDateString(\"en-US\", {\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t\tyear: date.getFullYear() !== now.getFullYear() ? \"numeric\" : undefined,\n\t});\n}\n\nexport function formatElapsedTime(ms?: number): string {\n\tif (!ms) return \"\";\n\tif (ms < 1000) return `${ms}ms`;\n\treturn `${(ms / 1000).toFixed(1)}s`;\n}\n","import * as Sentry from \"@sentry/react\";\n\nexport interface ChatSessionContext {\n\tsessionId?: string;\n\tsessionOwnerId?: string;\n\tagentId?: string;\n\texecutionId?: string;\n\tcfRay?: string;\n\troute?: string;\n\tcustomerId?: string;\n\tcustomerEmail?: string;\n}\n\n/**\n * Reports an error to Sentry enriched with chat session context.\n * Tags and context are scoped to this event so they don't leak\n * to unrelated errors.\n *\n * No-op when Sentry is not initialised.\n */\nexport function captureSentryError(\n\terror: Error | string,\n\tcontext: ChatSessionContext\n): void {\n\tif (!Sentry.getClient()) return;\n\n\tconst tags: Record<string, string> = {};\n\tif (context.executionId) tags.executionId = context.executionId;\n\tif (context.sessionId) tags.sessionId = context.sessionId;\n\tif (context.route) tags.route = context.route;\n\tif (context.cfRay) tags.cfRay = context.cfRay;\n\n\tif (context.customerId) tags.customerId = context.customerId;\n\tif (context.customerEmail) tags.customerEmail = context.customerEmail;\n\n\tconst contexts = {\n\t\tchat_session: {\n\t\t\tsessionId: context.sessionId ?? null,\n\t\t\tsessionOwnerId: context.sessionOwnerId ?? null,\n\t\t\texecutionId: context.executionId ?? null,\n\t\t\tagentId: context.agentId ?? null,\n\t\t\tcfRay: context.cfRay ?? null,\n\t\t\tcustomerId: context.customerId ?? null,\n\t\t\tcustomerEmail: context.customerEmail ?? null,\n\t\t},\n\t};\n\n\tif (typeof error === \"string\") {\n\t\tSentry.captureMessage(error, { level: \"error\", tags, contexts });\n\t} else {\n\t\tSentry.captureException(error, { tags, contexts });\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Targeted fetch interceptor for capturing cf-ray headers\n// ---------------------------------------------------------------------------\n\ntype CfRayListener = (cfRay: string) => void;\n\ninterface InterceptorEntry {\n\turlPattern: string;\n\tlistener: CfRayListener;\n}\n\nconst interceptors: Set<InterceptorEntry> = new Set();\nlet originalFetch: typeof globalThis.fetch | null = null;\n\nfunction patchFetch(): void {\n\tif (originalFetch !== null) return;\n\tif (typeof globalThis === \"undefined\" || typeof globalThis.fetch !== \"function\")\n\t\treturn;\n\n\toriginalFetch = globalThis.fetch;\n\n\tglobalThis.fetch = async function (\n\t\tthis: typeof globalThis,\n\t\tinput: RequestInfo | URL,\n\t\tinit?: RequestInit\n\t): Promise<Response> {\n\t\tconst response = await originalFetch!.call(this, input, init);\n\n\t\tif (interceptors.size > 0) {\n\t\t\tconst url =\n\t\t\t\ttypeof input === \"string\"\n\t\t\t\t\t? input\n\t\t\t\t\t: input instanceof URL\n\t\t\t\t\t\t? input.href\n\t\t\t\t\t\t: (input as Request).url;\n\n\t\t\ttry {\n\t\t\t\tconst cfRay = response.headers.get(\"cf-ray\");\n\t\t\t\tif (cfRay) {\n\t\t\t\t\tfor (const entry of interceptors) {\n\t\t\t\t\t\tif (url.includes(entry.urlPattern)) {\n\t\t\t\t\t\t\tentry.listener(cfRay);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// headers may be inaccessible on opaque responses\n\t\t\t}\n\t\t}\n\n\t\treturn response;\n\t};\n}\n\nfunction maybeUnpatchFetch(): void {\n\tif (interceptors.size > 0 || originalFetch === null) return;\n\tglobalThis.fetch = originalFetch;\n\toriginalFetch = null;\n}\n\n/**\n * Registers a listener that receives the `cf-ray` header value whenever a\n * fetch response URL contains `urlPattern`.\n *\n * Returns an unsubscribe function (call on unmount).\n */\nexport function subscribeToCfRay(\n\turlPattern: string,\n\tlistener: CfRayListener\n): () => void {\n\tconst entry: InterceptorEntry = { urlPattern, listener };\n\tpatchFetch();\n\tinterceptors.add(entry);\n\treturn () => {\n\t\tinterceptors.delete(entry);\n\t\tmaybeUnpatchFetch();\n\t};\n}\n"]}
1
+ {"version":3,"sources":["../../payman-sdk-typescript/src/utils/generateId.ts","../../payman-sdk-typescript/src/utils/chatStore.ts","../../payman-sdk-typescript/src/utils/activeStreamStore.ts","../../payman-sdk-typescript/src/utils/streamingClient.ts","../../payman-sdk-typescript/src/utils/stageLabels.ts","../../payman-sdk-typescript/src/utils/v2EventProcessor.ts","../../payman-sdk-typescript/src/utils/requestBuilder.ts","../../payman-sdk-typescript/src/utils/ragImageResolver.ts","../../payman-sdk-typescript/src/hooks/useStreamManagerV2.ts","../../payman-sdk-typescript/src/utils/messageStateManager.ts","../../payman-sdk-typescript/src/utils/userActionClient.ts","../../payman-sdk-typescript/src/hooks/useChatV2.ts","../../payman-sdk-typescript/src/hooks/useVoice.ts","../../payman-sdk-typescript/src/utils/jsonSchemaForm.ts","../src/contexts/PaymanChatContext.tsx","../src/components/PaymanChat/index.native.tsx","../src/utils/cn.ts","../src/utils/formatDate.ts","../src/utils/sentryContext.ts"],"names":["events","s","useRef","useCallback","useState","useMemo","submitUserAction","cancelUserAction","resendUserAction","expireUserAction","useEffect","createContext","useContext","Platform","UIManager","memo","VoiceWaveformBar","Animated","Easing","jsx","Keyboard","LayoutAnimation","jsxs","View","TextInput","Pressable","X","Text","Check","Mic","Send","StyleSheet","Markdown","ScrollView","Switch","Dimensions","PanResponder","ShieldCheck","Pencil","ChevronRight","Info","forwardRef","PaymanChat","useColorScheme","useImperativeHandle","isEmpty","KeyboardAvoidingView","twMerge","clsx","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,UAAA,GAAqB;AAEpC,EAAA,OAAO,sCAAA,CAAuC,OAAA,CAAQ,OAAA,EAAS,CAAC,CAAA,KAAM;AACrE,IAAA,MAAM,CAAA,GAAK,IAAA,CAAK,MAAA,EAAA,GAAW,EAAA,GAAM,CAAA;AACjC,IAAA,MAAM,CAAA,GAAI,CAAA,KAAM,GAAA,GAAM,CAAA,GAAK,IAAI,CAAA,GAAO,CAAA;AACtC,IAAA,OAAO,CAAA,CAAE,SAAS,EAAE,CAAA;EACrB,CAAC,CAAA;AACF;ACTA,IAAM,WAAA,uBAAkB,GAAA,EAAA;AAEjB,IAAM,SAAA,GAAY;AACxB,EAAA,GAAA,CAAI,GAAA,EAA+B;AAClC,IAAA,OAAO,WAAA,CAAY,GAAA,CAAI,GAAG,CAAA,IAAK,EAAA;AAChC,EAAA,CAAA;AACA,EAAA,GAAA,CAAI,KAAa,QAAA,EAAkC;AAClD,IAAA,WAAA,CAAY,GAAA,CAAI,KAAK,QAAQ,CAAA;AAC9B,EAAA,CAAA;AACA,EAAA,MAAA,CAAO,GAAA,EAAmB;AACzB,IAAA,WAAA,CAAY,OAAO,GAAG,CAAA;AACvB,EAAA;AACD,CAAA;ACDA,IAAM,OAAA,uBAAc,GAAA,EAAA;AAEb,IAAM,iBAAA,GAAoB;AAChC,EAAA,GAAA,CAAI,GAAA,EAAsB;AACzB,IAAA,OAAO,OAAA,CAAQ,IAAI,GAAG,CAAA;AACvB,EAAA,CAAA;AAEA,EAAA,GAAA,CAAI,GAAA,EAAwE;AAC3E,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,GAAG,CA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AA,MAChC,cAAA,EAAgB,QAAQ,cAAA,IAAkB,IAAA;AAAA,MAC1C,WAAA,EAAa,QAAQ,WAAA,IAAe,IAAA;AAAA,MACpC,OAAA,EAAS,QAAQ,OAAA,IAAW,IAAA;AAAA,MAC5B,KAAA,EAAO,QAAQ,KAAA,IAAS,IAAA;AAAA,MACxB,UAAA,EAAY,QAAQ,UAAA,IAAc,IAAA;AAAA,MAClC,aAAA,EAAe,QAAQ,aAAA,IAAiB;AAAA;AACzC,GACD;AAEA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC9B,IAAOA,iCAAe,KAAA,EAAO,EAAE,OAAO,OAAA,EAAS,IAAA,EAAM,UAAU,CAAA;AAAA,EAChE,CAAA,MAAO;AACN,IAAOA,iBAAA,CAAA,gBAAA,CAAiB,KAAA,EAAO,EAAE,IAAA,EAAM,UAAU,CAAA;AAAA,EAClD;AACD","file":"index.native.js","sourcesContent":["/**\n * Cross-platform UUID v4 generator\n * Works in both browser and React Native environments\n */\nexport function generateId(): string {\n\t// Simple UUID v4 implementation that doesn't rely on crypto API\n\treturn \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n\t\tconst r = (Math.random() * 16) | 0;\n\t\tconst v = c === \"x\" ? r : (r & 0x3) | 0x8;\n\t\treturn v.toString(16);\n\t});\n}\n","import type { MessageDisplay } from \"../types\";\n\nconst memoryStore = new Map<string, MessageDisplay[]>();\n\nexport const chatStore = {\n\tget(key: string): MessageDisplay[] {\n\t\treturn memoryStore.get(key) ?? [];\n\t},\n\tset(key: string, messages: MessageDisplay[]): void {\n\t\tmemoryStore.set(key, messages);\n\t},\n\tdelete(key: string): void {\n\t\tmemoryStore.delete(key);\n\t},\n};\n","import type { MessageDisplay } from \"../types\";\nimport { chatStore } from \"./chatStore\";\n\ntype Listener = (messages: MessageDisplay[], isWaiting: boolean) => void;\n\ntype StreamEntry = {\n\tmessages: MessageDisplay[];\n\tisWaiting: boolean;\n\tabortController: AbortController;\n\tlisteners: Set<Listener>;\n};\n\n// Keyed by userId — lives at module scope so it survives component unmount/remount\nconst streams = new Map<string, StreamEntry>();\n\nexport const activeStreamStore = {\n\thas(key: string): boolean {\n\t\treturn streams.has(key);\n\t},\n\n\tget(key: string): { messages: MessageDisplay[]; isWaiting: boolean } | null {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return null;\n\t\treturn { messages: entry.messages, isWaiting: entry.isWaiting };\n\t},\n\n\t// Called before startStream — registers the controller and initial messages\n\tstart(key: string, abortController: AbortController, initialMessages: MessageDisplay[]): void {\n\t\tconst existing = streams.get(key);\n\t\tstreams.set(key, {\n\t\t\tmessages: initialMessages,\n\t\t\tisWaiting: true,\n\t\t\tabortController,\n\t\t\tlisteners: existing?.listeners ?? new Set(),\n\t\t});\n\t},\n\n\t// Called by the stream on every event — applies the same updater pattern React uses\n\tapplyMessages(\n\t\tkey: string,\n\t\tupdater: MessageDisplay[] | ((prev: MessageDisplay[]) => MessageDisplay[])\n\t): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tconst next = typeof updater === \"function\" ? updater(entry.messages) : updater;\n\t\tentry.messages = next;\n\t\tentry.listeners.forEach((l) => l(next, entry.isWaiting));\n\t},\n\n\tsetWaiting(key: string, waiting: boolean): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.isWaiting = waiting;\n\t\tentry.listeners.forEach((l) => l(entry.messages, waiting));\n\t},\n\n\t// Called when stream completes — persists to chatStore and cleans up\n\tcomplete(key: string): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.isWaiting = false;\n\t\tentry.listeners.forEach((l) => l(entry.messages, false));\n\t\tconst toSave = entry.messages.filter((m) => !m.isStreaming);\n\t\tif (toSave.length > 0) chatStore.set(key, toSave);\n\t\tstreams.delete(key);\n\t},\n\n\t// Subscribe — returns unsubscribe fn. Component calls this on mount, cleanup on unmount.\n\tsubscribe(key: string, listener: Listener): () => void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return () => {};\n\t\tentry.listeners.add(listener);\n\t\treturn () => {\n\t\t\tstreams.get(key)?.listeners.delete(listener);\n\t\t};\n\t},\n\n\t// Rename an entry — used when the server assigns a new session ID mid-stream\n\trename(oldKey: string, newKey: string): void {\n\t\tconst entry = streams.get(oldKey);\n\t\tif (!entry) return;\n\t\tstreams.set(newKey, entry);\n\t\tstreams.delete(oldKey);\n\t},\n\n\t// Explicit user cancel — aborts the controller and removes the entry\n\tabort(key: string): void {\n\t\tconst entry = streams.get(key);\n\t\tif (!entry) return;\n\t\tentry.abortController.abort();\n\t\tstreams.delete(key);\n\t},\n};\n","/**\n * Streaming client for handling SSE (Server-Sent Events) from the API\n */\n\nexport type StreamEvent = {\n\teventType: string;\n\tworkerName?: string;\n\tmessage?: string;\n\terrorMessage?: string;\n\tresponse?: unknown;\n\texecutionId?: string;\n\tsessionId?: string;\n\tinputTokens?: number;\n\toutputTokens?: number;\n\telapsedMs?: number;\n\t/**\n\t * Server-computed wall-clock duration from RunStarted to RunCompleted.\n\t * Carried on RUN_COMPLETED only — prefer this over client-side\n\t * step-span heuristics when present.\n\t */\n\ttotalTimeMs?: number;\n\t/**\n\t * User-facing progress label. Attached to:\n\t * - TOOL_CALL_STARTED / TOOL_CALL_COMPLETED — derived from the tool\n\t * name and (on completion) the row-count of the result, e.g.\n\t * \"Pulling your transactions\" / \"Got 437 transactions\".\n\t * - LLM_CALL_STARTED — an in-voice \"what's about to happen\" line.\n\t * - KEEP_ALIVE — a rotating phrase the server sends during silent-\n\t * think gaps so the chat-bubble status changes every few seconds\n\t * instead of staying frozen on \"Thinking…\".\n\t *\n\t * Clients should prefer this over raw type identifiers when\n\t * rendering a progress row.\n\t */\n\tdescription?: string;\n\t/**\n\t * Carried on `THINKING_DELTA` events — Anthropic extended-thinking\n\t * content streamed live from the upstream model. Distinct from\n\t * `partialText` (the user-facing answer); routes into a separate\n\t * \"Thinking…\" panel rather than the chat bubble.\n\t */\n\ttext?: string;\n\t/**\n\t * User-action / elicitation fields, carried at the TOP LEVEL of a\n\t * `USER_ACTION_REQUIRED` event (and `userActionId`/`message` on\n\t * `USER_NOTIFICATION`). The MCP `_meta.action` kind is forwarded\n\t * here as `action`; `requestedSchema` is standard JSON Schema.\n\t */\n\tuserActionId?: string;\n\taction?: string;\n\tsubAction?: string;\n\tverificationType?: string;\n\texpirySeconds?: number;\n\trequestedSchema?: Record<string, unknown>;\n\tmetadata?: Record<string, string>;\n\ttoolCallId?: string;\n\t[key: string]: unknown;\n};\n\nexport type StreamOptions = {\n\tsignal?: AbortSignal;\n\tonEvent?: (event: StreamEvent) => void;\n\tonError?: (error: Error) => void;\n\tonComplete?: () => void;\n};\n\n/**\n * Yield to the macrotask queue after a streaming-text delta so React can\n * commit a render before the next delta lands. No-op for non-delta events\n * (STAGE_*, TOOL_CALL_*) which don't drive the typing animation.\n *\n * Uses setTimeout(0) rather than queueMicrotask: microtasks execute before\n * React's render commit, so they don't break the batch.\n */\nfunction yieldAfterProgressEvent(event: StreamEvent): Promise<void> {\n\tconst t = event.eventType;\n\tif (\n\t\tt === \"RUN_IN_PROGRESS\" ||\n\t\tt === \"INTENT_PROGRESS\" ||\n\t\tt === \"THINKING_DELTA\"\n\t) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, 0));\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Parse buffer for complete JSON objects (raw JSON streaming, not SSE format)\n * Handles concatenated JSON objects without newlines between them\n */\nfunction parseJSONBuffer(buffer: string): {\n\tevents: StreamEvent[];\n\tremaining: string;\n} {\n\tconst events: StreamEvent[] = [];\n\tlet braceCount = 0;\n\tlet startIndex = 0;\n\tlet inString = false;\n\tlet escapeNext = false;\n\tlet lastParsedIndex = -1;\n\n\t// Find complete JSON objects in the buffer\n\tfor (let i = 0; i < buffer.length; i++) {\n\t\tconst char = buffer[i];\n\n\t\tif (escapeNext) {\n\t\t\tescapeNext = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tescapeNext = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' && !escapeNext) {\n\t\t\tinString = !inString;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tif (braceCount === 0) {\n\t\t\t\tstartIndex = i;\n\t\t\t}\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t\tif (braceCount === 0) {\n\t\t\t\t// Found a complete JSON object\n\t\t\t\tconst jsonStr = buffer.substring(startIndex, i + 1);\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = JSON.parse(jsonStr);\n\t\t\t\t\tconst event = parsed as StreamEvent;\n\t\t\t\t\tevents.push(event);\n\t\t\t\t\tlastParsedIndex = i;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(\"Failed to parse JSON event:\", jsonStr, err);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return parsed events and remaining buffer\n\tconst remaining =\n\t\tlastParsedIndex >= 0 ? buffer.substring(lastParsedIndex + 1) : buffer;\n\treturn { events, remaining };\n}\n\n/**\n * Stream workflow events from the API\n */\nexport async function streamWorkflowEvents(\n\turl: string,\n\tbody: Record<string, unknown>,\n\theaders: Record<string, string>,\n\toptions: StreamOptions = {}\n): Promise<void> {\n\tconst { signal, onEvent, onError, onComplete } = options;\n\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t...headers,\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tsignal,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text();\n\t\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t\t}\n\n\t\tconst reader = response.body?.getReader();\n\t\tif (!reader) {\n\t\t\tthrow new Error(\"No response body\");\n\t\t}\n\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\n\twhile (true) {\n\t\tconst { done, value } = await reader.read();\n\n\t\tif (done) {\n\t\t\t// Process any remaining buffer\n\t\t\tif (buffer.trim()) {\n\t\t\t\tconst { events } = parseJSONBuffer(buffer);\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tonEvent?.(event);\n\t\t\t\t\tawait yieldAfterProgressEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\t// Decode the chunk and add to buffer\n\t\tbuffer += decoder.decode(value, { stream: true });\n\n\t\t// Try to parse complete JSON objects from buffer\n\t\tconst { events, remaining } = parseJSONBuffer(buffer);\n\t\tfor (const event of events) {\n\t\t\tonEvent?.(event);\n\t\t\t// Yield after progress deltas so React commits a render between\n\t\t\t// them. Without this, multiple deltas batched into one TCP chunk\n\t\t\t// dispatch all setState calls in the same microtask, React 18\n\t\t\t// batches them, and the user sees the response appear at once\n\t\t\t// instead of streaming in.\n\t\t\tawait yieldAfterProgressEvent(event);\n\t\t}\n\t\t// Keep only the remaining unparsed portion\n\t\tbuffer = remaining;\n\t}\n\n\t\tonComplete?.();\n\t} catch (error) {\n\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t// Stream was cancelled\n\t\t\treturn;\n\t\t}\n\t\tonError?.(error as Error);\n\t}\n}\n","/**\n * User-facing labels for the K2 pipeline stages, used by the event\n * processor to turn machine `stage` keys on STAGE_* events into the\n * text the UI shows in its \"Thought\" / streaming-step list.\n *\n * One label per stage — no completed / failed variants. The previous\n * version had three strings per stage (\"Checking your request\" →\n * \"Request OK\" → \"Couldn't process that request\") and flashed the\n * completed label for a few milliseconds between stages, which read\n * as noise rather than signal (\"Request OK\" and \"Got it\" don't\n * inspire trust in a banking product). The simpler model:\n *\n * - When a stage starts, the cursor shows the stage label.\n * - When the stage completes, the cursor moves on to the NEXT\n * stage's label (via a new STAGE_STARTED event). There is no\n * in-between \"completed\" flash.\n * - When the stage fails, the step is marked status=error but the\n * label stays — the expanded Thought view renders failed steps\n * differently via CSS, not by rewriting the text.\n *\n * The mapping lives in the SDK (not on the server) so copy changes\n * don't require a k2-server deploy. Future i18n replaces this table\n * with a lookup by key + locale without touching the server.\n *\n * Stage keys come from k2-server's `Pipeline.toStepKey()`:\n * sanitizer | analyzer | prefetcher | planner | execution | formatter\n */\n\nconst STAGE_LABELS: Record<string, string> = {\n\tsanitizer: \"Checking your request\",\n\tanalyzer: \"Understanding what you're asking\",\n\tprefetcher: \"Gathering context\",\n\tplanner: \"Planning how to handle this\",\n\texecution: \"Working on it\",\n\tformatter: \"Writing the response\",\n};\n\n/**\n * Map a pipeline stage key to a user-facing label. Returns a\n * sensible generic fallback (\"Running <stage>\") if the stage key is\n * unknown — a future k2-server stage that the SDK doesn't know\n * about yet still renders something in the UI instead of breaking\n * the stream.\n */\nexport function stageLabel(stage: string): string {\n\tconst label = STAGE_LABELS[stage];\n\tif (label) return label;\n\tconst pretty = stage.replace(/[_-]/g, \" \");\n\treturn `Running ${pretty}`;\n}\n","import type { StreamEvent } from \"./streamingClient\";\nimport type {\n\tStreamingStep,\n\tUserActionRequest,\n\tUserActionKind,\n\tActiveUserAction,\n\tUserNotification,\n\tRequestedSchema,\n} from \"../types\";\nimport { stageLabel } from \"./stageLabels\";\n\n// ============================================================\n// Shared stream-event utilities\n// ============================================================\n//\n// These used to live in a separate `eventProcessor.ts` (the legacy\n// v1 processor file). The v1 processor + its stream manager + its\n// useChat hook have all been deleted — the v2 processor below is\n// the only one the SDK ships now — so the utilities moved here\n// rather than into a standalone shared file. They're exported\n// because `useStreamManagerV2` also imports `getEventMessage`.\n\n/**\n * Bland default-start labels every pipeline stage emits as\n * `defaultStartMessage` on the server when nothing more specific\n * has happened yet — `\"Executing…\"`, `\"Working on it…\"`, etc. The\n * stream manager filters these out of the chat-bubble status so\n * they don't replace useful messages (Analyzer's dynamic\n * \"Pulling those up for you now.\", a tool call's \"Got 437\n * transactions\") with a generic placeholder for the brief moment\n * between a stage starting and its first interesting event.\n *\n * Comparison is case-insensitive and trailing punctuation\n * (ellipsis `…` / `...` / period) is stripped so the same label\n * matches whether the server emits it with or without the\n * trailing dots.\n */\nexport function isBlandStatus(message: string | undefined | null): boolean {\n\tif (!message) return true;\n\tconst normalized = message\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[…\\.]+$/, \"\")\n\t\t.trim();\n\treturn BLAND_STATUS_LABELS.has(normalized);\n}\n\nconst BLAND_STATUS_LABELS: Set<string> = new Set([\n\t\"executing\",\n\t\"working on it\",\n\t\"thinking\",\n\t\"processing\",\n\t\"reviewing your request\",\n\t\"composing response\",\n\t\"checking your request\",\n\t\"polishing the response\",\n]);\n\n/**\n * Extract a user-friendly message string from a raw stream event.\n * Used by `useStreamManagerV2` when the streaming client needs a\n * label to attach to an intermediate event (e.g. for logging).\n */\nexport function getEventMessage(event: StreamEvent): string {\n\tif (event.message?.trim()) {\n\t\treturn event.message.trim();\n\t}\n\n\tif (event.errorMessage?.trim()) {\n\t\treturn event.errorMessage.trim();\n\t}\n\n\tconst eventType = event.eventType;\n\tswitch (eventType) {\n\t\tcase \"RUN_STARTED\":\n\t\t\treturn \"Starting agent run...\";\n\t\tcase \"TOOL_CALL_STARTED\": {\n\t\t\t// Prefer the server's human-readable `description` (e.g.\n\t\t\t// \"Pulling your transactions\") over the raw snake_case\n\t\t\t// tool identifier. Older k2-server builds don't populate\n\t\t\t// it, so we fall back to the tool name.\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\tif (description) return description;\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : \"\";\n\t\t\treturn toolName ? `Calling ${toolName}...` : \"Calling tool...\";\n\t\t}\n\t\tcase \"TOOL_CALL_COMPLETED\": {\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\tif (description) return description;\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : \"\";\n\t\t\treturn toolName ? `${toolName} completed` : \"Tool call completed\";\n\t\t}\n\t\tcase \"RUN_IN_PROGRESS\":\n\t\t\treturn (event.partialText as string) || \"Thinking...\";\n\t\tcase \"RUN_COMPLETED\":\n\t\t\treturn \"Agent run completed\";\n\t\tcase \"RUN_FAILED\":\n\t\t\treturn (event.errorMessage as string) || \"Agent run failed\";\n\t\tcase \"KEEP_ALIVE\":\n\t\t\t// k2-server attaches a rotating K2-voice phrase as `description`\n\t\t\t// during silent-think gaps so the chat-bubble status line has\n\t\t\t// something visibly changing instead of a frozen \"Thinking\".\n\t\t\t// Empty when the heartbeat is generic (legacy server builds).\n\t\t\treturn (event.description as string) || \"\";\n\t\tcase \"THINKING_DELTA\":\n\t\t\t// Anthropic extended-thinking content. Routed into the thinking\n\t\t\t// panel via processStreamEventV2; here we just contribute the\n\t\t\t// text to the bubble fallback in case the host UI doesn't\n\t\t\t// render the dedicated panel yet.\n\t\t\treturn (event.text as string) || \"\";\n\t\tdefault:\n\t\t\treturn eventType;\n\t}\n}\n\n/**\n * Pull the final assistant reply out of whatever shape the server\n * decided to send it in. Handles the common cases (direct string,\n * nested object with `text`/`content`/`message`/`answer`) and falls\n * back to a JSON stringification for anything else.\n */\nexport function extractResponseContent(response: unknown): string {\n\t// Handle direct string response (most common from API)\n\tif (typeof response === \"string\") {\n\t\treturn response;\n\t}\n\n\t// Handle object responses with nested content\n\tif (typeof response === \"object\" && response !== null) {\n\t\tconst resp = response as Record<string, unknown>;\n\n\t\t// Try common field names\n\t\tif (\"text\" in resp && typeof resp.text === \"string\") {\n\t\t\treturn resp.text;\n\t\t}\n\t\tif (\"content\" in resp && typeof resp.content === \"string\") {\n\t\t\treturn resp.content;\n\t\t}\n\t\tif (\"message\" in resp && typeof resp.message === \"string\") {\n\t\t\treturn resp.message;\n\t\t}\n\t\tif (\"answer\" in resp && typeof resp.answer === \"string\") {\n\t\t\treturn resp.answer;\n\t\t}\n\n\t\t// Fallback to JSON string\n\t\treturn JSON.stringify(response);\n\t}\n\n\treturn \"\";\n}\n\n/**\n * Translate the clean K2 playground event types (RUN_STARTED,\n * TOOL_CALL_*, RUN_IN_PROGRESS, RUN_COMPLETED, RUN_FAILED) to the\n * internal event names the state machine below handles\n * (WORKFLOW_STARTED, INTENT_STARTED, INTENT_COMPLETED,\n * INTENT_PROGRESS, WORKFLOW_COMPLETED, WORKFLOW_ERROR).\n *\n * STAGE_* events pass through unchanged — they're handled directly\n * by the processor as K2 pipeline stage lifecycle events.\n *\n * Unknown event types pass through unchanged so the state machine\n * can ignore them safely.\n */\nexport function normalizeEvent(event: StreamEvent): StreamEvent {\n\tconst type = event.eventType;\n\tswitch (type) {\n\t\tcase \"RUN_STARTED\":\n\t\t\treturn { ...event, eventType: \"WORKFLOW_STARTED\" };\n\t\tcase \"TOOL_CALL_STARTED\": {\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : undefined;\n\t\t\t// The server now ships a human-readable `description`\n\t\t\t// (\"Pulling your transactions\") on tool events. Surface it\n\t\t\t// as the normalized `message` so the INTENT_STARTED\n\t\t\t// handler below renders it in the thinking-block label\n\t\t\t// instead of the raw tool identifier. Falls back to the\n\t\t\t// existing `message` field when description is absent\n\t\t\t// (older k2-server builds).\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_STARTED\",\n\t\t\t\tworkerName: toolName ?? event.workerName,\n\t\t\t\tmessage: description || (event.message as string | undefined),\n\t\t\t};\n\t\t}\n\t\tcase \"TOOL_CALL_COMPLETED\": {\n\t\t\tconst toolName = typeof event.toolName === \"string\" ? event.toolName : undefined;\n\t\t\tconst description = typeof event.description === \"string\" ? event.description.trim() : \"\";\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_COMPLETED\",\n\t\t\t\tworkerName: toolName ?? event.workerName,\n\t\t\t\tmessage: description || (event.message as string | undefined),\n\t\t\t};\n\t\t}\n\t\tcase \"RUN_IN_PROGRESS\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"INTENT_PROGRESS\",\n\t\t\t\tmessage: (event.partialText as string | undefined) ?? event.message,\n\t\t\t};\n\t\tcase \"RUN_COMPLETED\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"WORKFLOW_COMPLETED\",\n\t\t\t\t// state machine reads event.response for the final content\n\t\t\t\tresponse: event.response ?? event.message,\n\t\t\t};\n\t\tcase \"RUN_FAILED\":\n\t\t\treturn {\n\t\t\t\t...event,\n\t\t\t\teventType: \"WORKFLOW_ERROR\",\n\t\t\t\terrorMessage: (event.errorMessage as string | undefined) ?? (event.message as string | undefined),\n\t\t\t};\n\t\tdefault:\n\t\t\treturn event;\n\t}\n}\n\n/**\n * A `requestedSchema` whose only field is `verificationCode` is the MCP\n * verification (one-time-code) shape, regardless of the declared\n * `action`. Used to refine classification.\n */\nfunction isVerificationSchema(schema: RequestedSchema | undefined): boolean {\n\tconst props = schema?.properties;\n\tif (!props) return false;\n\tconst keys = Object.keys(props);\n\treturn keys.length === 1 && keys[0] === \"verificationCode\";\n}\n\n/**\n * Classify a `USER_ACTION_REQUIRED` event into a render kind. Primary\n * discriminator is the MCP elicitation `action`; we fall back to the\n * schema shape so unknown/legacy `action` tags still route correctly.\n */\nexport function classifyUserActionKind(\n\taction: string | undefined,\n\tschema: RequestedSchema | undefined,\n): UserActionKind {\n\tswitch ((action || \"\").toLowerCase()) {\n\t\tcase \"userverificationrequest\":\n\t\t\treturn \"verification\";\n\t\tcase \"usernotificationrequest\":\n\t\t\treturn \"notification\";\n\t\tcase \"userformrequest\":\n\t\t\treturn isVerificationSchema(schema) ? \"verification\" : \"form\";\n\t\tdefault:\n\t\t\treturn isVerificationSchema(schema) ? \"verification\" : \"form\";\n\t}\n}\n\nexport type V2EventProcessorState = {\n\tfinalResponse: string;\n\tlastEventType: string;\n\tsessionId?: string;\n\texecutionId?: string;\n\thasError: boolean;\n\terrorMessage: string;\n\t/**\n\t * Active user-action prompts, an ordered collection keyed by\n\t * `toolCallId` (fallback `userActionId`). Usually 0–1 for serial\n\t * runs; multiple when parallel tool calls each elicit.\n\t */\n\tuserActions: ActiveUserAction[];\n\t/** One-way notifications surfaced this run (`USER_NOTIFICATION`). */\n\tnotifications: UserNotification[];\n\t/**\n\t * Transient: the prompt upserted by the most recent\n\t * `USER_ACTION_REQUIRED` event, so the stream manager can fire\n\t * `onUserActionRequired` for exactly that prompt. Reset each event.\n\t */\n\tlastUserAction?: UserActionRequest;\n\t/** Transient: the notification pushed by the most recent event. */\n\tlastNotification?: UserNotification;\n\tfinalData?: unknown;\n\tsteps: StreamingStep[];\n\tstepCounter: number;\n\tcurrentExecutingStepId?: string;\n\t/** Server-computed wall-clock duration captured from RUN_COMPLETED's `totalTimeMs`. */\n\ttotalElapsedMs?: number;\n};\n\nfunction getEventText(event: StreamEvent, field: string): string {\n\tconst value = event[field];\n\treturn typeof value === \"string\" ? value.trim() : \"\";\n}\n\n/**\n * Mirror the current tool-call START label onto the enclosing\n * in-progress STAGE_STARTED(\"execution\") step.\n *\n * Called on INTENT_STARTED only (not INTENT_COMPLETED). AGENTIC runs\n * fire many back-to-back tools (especially long query_engine chains),\n * so alternating start→end labels on every call produced a rapid\n * flicker of \"Crunching the numbers\" → \"Got 20 rows\" → \"Crunching\n * the numbers\" → \"Got 16 rows\" during a 60-120s run. Mirroring only\n * the start label means back-to-back same-type calls read as one\n * stable label (\"Crunching the numbers\" throughout the chain), with\n * transitions only when the tool *kind* actually changes.\n *\n * Why the mirror is needed at all: the chat-bubble label picker\n * walks steps in reverse and returns the most recent in-progress\n * step's message. Between tool calls the tool-level INTENT_STARTED\n * step is completed, so the picker falls back to the still-in-progress\n * execution-stage step — whose message is the static \"Executing…\"\n * default from the server. Mirroring the tool label onto that stage\n * step keeps the fallback dynamic and meaningful.\n *\n * No-op when `msg` is empty (older k2-server builds without\n * descriptions) or when no execution-stage step is in progress (run\n * hasn't reached the execution stage yet).\n */\nfunction updateExecutionStageMessage(state: V2EventProcessorState, msg: string): void {\n\tif (!msg) return;\n\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\tconst s = state.steps[i];\n\t\t// Match BOTH \"executor\" (current k2-server) and \"execution\"\n\t\t// (legacy ExecutionEngine). Without the \"executor\" match, the\n\t\t// tool-label mirror never landed on modern server builds and\n\t\t// the chat bubble was stuck on bland \"Executing…\" while the\n\t\t// pipeline panel showed live \"Crunching the numbers\"-style\n\t\t// labels — visible chat/pipeline desync.\n\t\tif (\n\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t(s.stage === \"executor\" || s.stage === \"execution\") &&\n\t\t\ts.status === \"in_progress\"\n\t\t) {\n\t\t\ts.message = msg;\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nfunction completeLastInProgressStep(steps: StreamingStep[]): void {\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tif (steps[i].status === \"in_progress\") {\n\t\t\tsteps[i].status = \"completed\";\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nexport function createInitialV2State(): V2EventProcessorState {\n\treturn {\n\t\tfinalResponse: \"\",\n\t\tlastEventType: \"\",\n\t\tsessionId: undefined,\n\t\texecutionId: undefined,\n\t\thasError: false,\n\t\terrorMessage: \"\",\n\t\tuserActions: [],\n\t\tnotifications: [],\n\t\tlastUserAction: undefined,\n\t\tlastNotification: undefined,\n\t\tfinalData: undefined,\n\t\tsteps: [],\n\t\tstepCounter: 0,\n\t\tcurrentExecutingStepId: undefined,\n\t};\n}\n\n/**\n * Upsert a prompt into `state.userActions`, applying the supersede rule:\n * a new event with a matching `toolCallId` (a `SubmissionInvalid` retry\n * or `RequestResent`, even with a new `userActionId`) REPLACES that slot\n * in place; otherwise it's appended as a new (parallel) prompt.\n */\nfunction upsertUserAction(state: V2EventProcessorState, req: UserActionRequest): void {\n\tconst active: ActiveUserAction = { ...req, status: \"pending\" };\n\tconst matchIdx = state.userActions.findIndex((p) =>\n\t\treq.toolCallId\n\t\t\t? p.toolCallId === req.toolCallId\n\t\t\t: p.userActionId === req.userActionId,\n\t);\n\tif (matchIdx >= 0) {\n\t\tstate.userActions[matchIdx] = active;\n\t} else {\n\t\tstate.userActions.push(active);\n\t}\n}\n\nexport function processStreamEventV2(\n\trawEvent: StreamEvent,\n\tstate: V2EventProcessorState,\n): V2EventProcessorState {\n\tconst event = normalizeEvent(rawEvent);\n\tconst eventType = event.eventType;\n\n\t// Transient per-event dispatch signals — cleared every call so the\n\t// stream manager only fires callbacks for the current event.\n\tstate.lastUserAction = undefined;\n\tstate.lastNotification = undefined;\n\n\tif (typeof eventType === \"string\" && eventType.toUpperCase() === \"KEEP_ALIVE\") {\n\t\tif (event.executionId) state.executionId = event.executionId;\n\t\tif (event.sessionId) state.sessionId = event.sessionId;\n\t\t// k2-server attaches a rotating K2-voice phrase as `description` so\n\t\t// the chat-bubble status line changes during silent-think gaps\n\t\t// instead of staying pinned to \"Thinking\" for tens of seconds.\n\t\t// Mirror it onto the most-recent in-progress step's message so the\n\t\t// stream manager's `currentMessage` picker (which walks\n\t\t// state.steps for the latest substantive label) surfaces it.\n\t\tconst description = typeof event.description === \"string\" ? event.description : \"\";\n\t\tif (description) {\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tif (state.steps[i].status === \"in_progress\") {\n\t\t\t\t\tstate.steps[i].message = description;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn state;\n\t}\n\n\tif (typeof eventType === \"string\" && eventType.toUpperCase() === \"THINKING_DELTA\") {\n\t\tif (event.executionId) state.executionId = event.executionId;\n\t\tif (event.sessionId) state.sessionId = event.sessionId;\n\t\tstate.lastEventType = \"THINKING_DELTA\";\n\t\treturn state;\n\t}\n\n\tif (event.executionId) state.executionId = event.executionId;\n\tif (event.sessionId) state.sessionId = event.sessionId;\n\n\tconst message = getEventMessage(event);\n\n\tswitch (eventType) {\n\t\tcase \"WORKFLOW_STARTED\":\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\n\t\tcase \"INTENT_PROGRESS\": {\n\t\t\t// Streaming delta from the Formatter stage — each event\n\t\t\t// carries `partialText` (the new chunk) which normalizeEvent\n\t\t\t// surfaces as `event.message`. Accumulate into\n\t\t\t// state.finalResponse so the stream manager can mirror it\n\t\t\t// into streamingContent in real time. The WORKFLOW_COMPLETED\n\t\t\t// event at the end still lands with the authoritative full\n\t\t\t// text; this just lets us show the answer building up.\n\t\t\t//\n\t\t\t// IMPORTANT: read raw values, do NOT `getEventText()` here.\n\t\t\t// getEventText() calls .trim(), which strips the leading\n\t\t\t// and trailing whitespace that providers include in each\n\t\t\t// token delta (\" bank\", \"accounts \", \"with\"). Trimming at\n\t\t\t// this layer destroys inter-word spacing and produces\n\t\t\t// \"Hereareallyourbankaccounts\" once deltas are concatenated.\n\t\t\tconst rawMessage = typeof event.message === \"string\" ? event.message : \"\";\n\t\t\tconst rawPartial = typeof event.partialText === \"string\" ? event.partialText : \"\";\n\t\t\tconst delta = rawMessage || rawPartial;\n\t\t\tif (delta.length > 0) {\n\t\t\t\tstate.finalResponse += delta;\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"INTENT_STARTED\": {\n\t\t\tconst stepId = `step-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage,\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\telapsedMs: event.elapsedMs,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\t// Keep the enclosing execution stage step in sync with the\n\t\t\t// current tool label so the UI never flashes back to\n\t\t\t// \"Executing…\" between tool calls. See helper docs.\n\t\t\tupdateExecutionStageMessage(state, message);\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"INTENT_COMPLETED\": {\n\t\t\tconst intentStep = state.steps.find(s => s.eventType === \"INTENT_STARTED\" && s.status === \"in_progress\");\n\t\t\tif (intentStep) {\n\t\t\t\tintentStep.status = \"completed\";\n\t\t\t\tif (event.elapsedMs) intentStep.elapsedMs = event.elapsedMs;\n\t\t\t\tif (intentStep.id === state.currentExecutingStepId) state.currentExecutingStepId = undefined;\n\t\t\t}\n\t\t\t// DO NOT update the enclosing execution-stage message\n\t\t\t// here. AGENTIC runs fire many back-to-back tools\n\t\t\t// (especially query_engine chains) and surfacing the\n\t\t\t// per-tool completion label (\"Got 20 rows\" → \"Got 16\n\t\t\t// rows\" → …) caused a rapid flicker between start/end\n\t\t\t// labels during the 60-120s loop. Keeping the stage step\n\t\t\t// pinned to the CURRENT tool's start description means\n\t\t\t// back-to-back same-type tool calls all read as the same\n\t\t\t// stable label (\"Crunching the numbers\" throughout the\n\t\t\t// query_engine chain). The detail per tool still lives\n\t\t\t// on the tool's own step for expanded / trace views.\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"WORKFLOW_COMPLETED\": {\n\t\t\t// Capture server-computed wall-clock duration. Authoritative.\n\t\t\tconst totalTime = Number(event.totalTimeMs);\n\t\t\tif (Number.isFinite(totalTime) && totalTime > 0) {\n\t\t\t\tstate.totalElapsedMs = totalTime;\n\t\t\t}\n\n\t\t\tconst content = extractResponseContent(event.response);\n\n\t\t\tif (content) {\n\t\t\t\tstate.finalResponse = content;\n\t\t\t\t// K2 playground runs emit the answer on `event.response`.\n\t\t\t\t// The full execution trace is fetched on demand via\n\t\t\t\t// GET /api/playground/executions/{id}/trace using\n\t\t\t\t// `executionId` on the final message.\n\t\t\t\tif (event.trace && typeof event.trace === \"object\") {\n\t\t\t\t\tstate.finalData = event.trace;\n\t\t\t\t}\n\t\t\t\tstate.hasError = false;\n\t\t\t\tstate.errorMessage = \"\";\n\t\t\t} else {\n\t\t\t\tstate.hasError = true;\n\t\t\t\tstate.errorMessage = \"WORKFLOW_FAILED\";\n\t\t\t}\n\n\t\t\tstate.steps.forEach(step => {\n\t\t\t\tif (step.status === \"in_progress\") {\n\t\t\t\t\tstep.status = \"completed\";\n\t\t\t\t}\n\t\t\t});\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"USER_ACTION_REQUIRED\": {\n\t\t\tconst rawAction = typeof event.action === \"string\" ? event.action : undefined;\n\t\t\tconst schema = event.requestedSchema as RequestedSchema | undefined;\n\t\t\tconst kind = classifyUserActionKind(rawAction, schema);\n\t\t\tconst promptMessage =\n\t\t\t\t(typeof event.message === \"string\" && event.message.trim()) || message || \"\";\n\t\t\tconst userActionId =\n\t\t\t\ttypeof event.userActionId === \"string\" ? event.userActionId : \"\";\n\n\t\t\t// A UserNotificationRequest is display-only — surface it as a\n\t\t\t// notification, not an interactive prompt.\n\t\t\tif (kind === \"notification\") {\n\t\t\t\tconst notification: UserNotification = {\n\t\t\t\t\tid: userActionId || `note-${state.stepCounter++}`,\n\t\t\t\t\tmessage: promptMessage,\n\t\t\t\t};\n\t\t\t\tstate.notifications.push(notification);\n\t\t\t\tstate.lastNotification = notification;\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Without an id we can't route a resolution back — skip.\n\t\t\tif (!userActionId) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcompleteLastInProgressStep(state.steps);\n\n\t\t\tconst verificationType =\n\t\t\t\tevent.verificationType === \"ALPHANUMERIC_CODE\" ||\n\t\t\t\tevent.verificationType === \"NUMERIC_CODE\"\n\t\t\t\t\t? event.verificationType\n\t\t\t\t\t: undefined;\n\n\t\t\tconst request: UserActionRequest = {\n\t\t\t\tuserActionId,\n\t\t\t\tkind,\n\t\t\t\trawAction,\n\t\t\t\tsubAction: typeof event.subAction === \"string\" ? event.subAction : undefined,\n\t\t\t\tverificationType,\n\t\t\t\texpirySeconds:\n\t\t\t\t\ttypeof event.expirySeconds === \"number\" ? event.expirySeconds : undefined,\n\t\t\t\tmessage: promptMessage || undefined,\n\t\t\t\trequestedSchema: schema,\n\t\t\t\tmetadata: event.metadata as Record<string, string> | undefined,\n\t\t\t\ttoolCallId: typeof event.toolCallId === \"string\" ? event.toolCallId : undefined,\n\t\t\t\texecutionId: state.executionId,\n\t\t\t\tsessionId: state.sessionId,\n\t\t\t};\n\n\t\t\tupsertUserAction(state, request);\n\t\t\tstate.lastUserAction = request;\n\n\t\t\tconst stepId = `step-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage:\n\t\t\t\t\tpromptMessage ||\n\t\t\t\t\t(kind === \"verification\"\n\t\t\t\t\t\t? \"Waiting for verification...\"\n\t\t\t\t\t\t: \"Waiting for your input...\"),\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\telapsedMs: event.elapsedMs,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"USER_NOTIFICATION\": {\n\t\t\tconst noteMessage =\n\t\t\t\t(typeof event.message === \"string\" && event.message.trim()) || message || \"\";\n\t\t\tconst userActionId =\n\t\t\t\ttypeof event.userActionId === \"string\" ? event.userActionId : \"\";\n\t\t\tif (noteMessage || userActionId) {\n\t\t\t\tconst notification: UserNotification = {\n\t\t\t\t\tid: userActionId || `note-${state.stepCounter++}`,\n\t\t\t\t\tmessage: noteMessage,\n\t\t\t\t};\n\t\t\t\tstate.notifications.push(notification);\n\t\t\t\tstate.lastNotification = notification;\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"WORKFLOW_ERROR\":\n\t\t\tstate.hasError = true;\n\t\t\tstate.errorMessage = (event.errorMessage as string) || (event.message as string) || \"Workflow error\";\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\n\t\t// ---- K2 pipeline stage lifecycle events ----\n\t\t//\n\t\t// The k2-server playground streaming API emits\n\t\t// STAGE_STARTED / STAGE_COMPLETED / STAGE_FAILED /\n\t\t// STAGE_SKIPPED around each pipeline stage so the UI can\n\t\t// show real progress (sanitizer → analyzer → planner → …)\n\t\t// instead of a static placeholder. Each STAGE_STARTED\n\t\t// pushes an in-progress step with a user-facing label; the\n\t\t// matching STAGE_COMPLETED/FAILED closes it WITHOUT\n\t\t// rewriting the label — a terse \"completed\" flash between\n\t\t// stages was more noise than signal. STAGE_SKIPPED removes\n\t\t// the just-opened step entirely (skipping is expected on\n\t\t// DIRECT_RESPONSE short-circuits).\n\t\t//\n\t\t// Finding the matching step uses `stepId` directly rather\n\t\t// than comparing labels — the processor remembers which id\n\t\t// it minted for the latest open STAGE_STARTED and the\n\t\t// closing events look it up from state.currentExecutingStepId.\n\n\t\tcase \"STAGE_STARTED\": {\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Prefer the server-provided `message` — each K2 pipeline\n\t\t\t// stage now ships its own user-facing label on StageStarted\n\t\t\t// (Analyzer: \"Thinking…\", Prefetcher: \"Gathering context…\",\n\t\t\t// etc.). Fall back to the SDK's static stageLabel() table\n\t\t\t// only if the server didn't send one, which keeps this\n\t\t\t// processor compatible with older k2-server builds.\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tlet initialMessage = serverMessage || stageLabel(stage);\n\n\t\t\t// Execution-stage special case: the server's default label\n\t\t\t// is a bare \"Executing…\" which would show for the 5-10s\n\t\t\t// between STAGE_STARTED(\"executor\") and the first\n\t\t\t// TOOL_CALL_STARTED in an AGENTIC run. Prefer the\n\t\t\t// Analyzer's LLM-generated status (\"Pulling those up for\n\t\t\t// you now.\") — it's request-specific and bridges the gap\n\t\t\t// to the first tool event. Tool events subsequently mutate\n\t\t\t// this step's message via updateExecutionStageMessage().\n\t\t\t//\n\t\t\t// Match BOTH \"executor\" (current k2-server stage key) and\n\t\t\t// \"execution\" (legacy ExecutionEngine stage). Without the\n\t\t\t// \"executor\" match, the special case never fired against\n\t\t\t// modern server builds — observed in production: the chat\n\t\t\t// bubble showed bland \"Executing…\" for the entire agentic\n\t\t\t// run despite the analyzer having shipped a useful narrative\n\t\t\t// status that should have been inherited.\n\t\t\tif (stage === \"executor\" || stage === \"execution\") {\n\t\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst s = state.steps[i];\n\t\t\t\t\tif (\n\t\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\t\ts.stage === \"analyzer\" &&\n\t\t\t\t\t\ts.status === \"completed\" &&\n\t\t\t\t\t\ts.message\n\t\t\t\t\t) {\n\t\t\t\t\t\tinitialMessage = s.message;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst stepId = `stage-${stage}-${state.stepCounter++}`;\n\t\t\tstate.steps.push({\n\t\t\t\tid: stepId,\n\t\t\t\teventType,\n\t\t\t\tmessage: initialMessage,\n\t\t\t\tstatus: \"in_progress\",\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tstage,\n\t\t\t});\n\t\t\tstate.currentExecutingStepId = stepId;\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_COMPLETED\": {\n\t\t\t// Close the most recent in-progress step for this stage.\n\t\t\t// If the server provides a new `message` (the Analyzer's\n\t\t\t// LLM-generated \"Pulling those up for you now.\"), OVERWRITE\n\t\t\t// the step's label before marking completed — the UI's\n\t\t\t// currentStepLabel fallback shows the most recent step's\n\t\t\t// label during the gap between stages, so updating here\n\t\t\t// means the user sees the dynamic status instead of the\n\t\t\t// generic start-label until the next STAGE_STARTED lands.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (serverMessage) s.message = serverMessage;\n\t\t\t\t\ts.status = \"completed\";\n\t\t\t\t\tconst durationMs = Number(event.durationMs);\n\t\t\t\t\tif (Number.isFinite(durationMs)) s.elapsedMs = durationMs;\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_FAILED\": {\n\t\t\t// Same as STAGE_COMPLETED but the step's status becomes\n\t\t\t// \"error\". If the server provides a specific failure\n\t\t\t// message we surface it; otherwise the label stays so the\n\t\t\t// user at least sees which stage was running. Expanded\n\t\t\t// Thought view renders errored steps differently via CSS.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst serverMessage = getEventText(event, \"message\");\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (serverMessage) s.message = serverMessage;\n\t\t\t\t\ts.status = \"error\";\n\t\t\t\t\tconst durationMs = Number(event.durationMs);\n\t\t\t\t\tif (Number.isFinite(durationMs)) s.elapsedMs = durationMs;\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"STAGE_SKIPPED\": {\n\t\t\t// Mark the matching in-progress step as \"skipped\" rather\n\t\t\t// than removing it. The chat-bubble thinking animation\n\t\t\t// only reads in-progress steps so marking skipped doesn't\n\t\t\t// affect it. But pipeline-sidebar UIs need the step\n\t\t\t// retained (with the \"skipped\" status) so they can render\n\t\t\t// a visual indicator (e.g. a MinusCircle icon) for stages\n\t\t\t// the pipeline intentionally bypassed.\n\t\t\tconst stage = getEventText(event, \"stage\");\n\t\t\tif (!stage) {\n\t\t\t\tstate.lastEventType = eventType;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (let i = state.steps.length - 1; i >= 0; i--) {\n\t\t\t\tconst s = state.steps[i];\n\t\t\t\tif (\n\t\t\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\t\t\ts.stage === stage &&\n\t\t\t\t\ts.status === \"in_progress\"\n\t\t\t\t) {\n\t\t\t\t\tif (s.id === state.currentExecutingStepId) {\n\t\t\t\t\t\tstate.currentExecutingStepId = undefined;\n\t\t\t\t\t}\n\t\t\t\t\ts.status = \"skipped\" as typeof s.status;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tstate.lastEventType = eventType;\n\t\t\tbreak;\n\t}\n\n\treturn state;\n}\n","import type { ChatConfig } from \"../types\";\n\nconst DEFAULT_STREAM_ENDPOINT = \"/api/playground/ask/stream\";\n\n/**\n * Latency-vs-precision toggle surfaced in the chat widget. \"fast\"\n * (default) lets the server cap list-tool fetches and answer\n * quickly; \"deep\" runs a full analytical pass. The value is\n * forwarded verbatim to the server, which normalizes it — any\n * other string collapses to \"fast\" server-side. See\n * `ExecutionRequest.analysisMode` on the k2 backend for the\n * authoritative semantics.\n */\nexport type AnalysisMode = \"fast\" | \"deep\";\n\n/**\n * Build request body for the k2 playground ask endpoint.\n *\n * Shape matches PlaygroundAskRequest on the server:\n * { agentId, userInput, sessionId?, sessionOwnerId, sessionOwnerLabel?,\n * sessionAttributes?, analysisMode?, locale, timezone? }\n *\n * `analysisMode` is omitted from the body when undefined so older\n * SDK versions that don't pass it produce the exact same wire\n * shape they did before — the server defaults missing values to\n * \"fast\" anyway, so including the field is purely informational\n * when the caller hasn't opted in.\n *\n * `locale` is REQUIRED by the server's PlaygroundAskRequest. We resolve\n * it from `config.locale` first, then `navigator.language` (browser),\n * then fall back to \"en-US\". Without this the server returns 400 with\n * a serialization error.\n */\nexport function buildRequestBody(\n\tconfig: ChatConfig,\n\tuserMessage: string,\n\tsessionId?: string,\n\toptions?: { analysisMode?: AnalysisMode },\n): Record<string, unknown> {\n\tconst sessionOwner = config.sessionParams;\n\tconst sessionOwnerId = sessionOwner?.id?.trim();\n\tif (!sessionOwnerId) {\n\t\tthrow new Error(\"ChatConfig.sessionParams.id is required to send ask requests.\");\n\t}\n\tconst sessionAttributes =\n\t\tsessionOwner?.attributes && Object.keys(sessionOwner.attributes).length > 0\n\t\t\t? sessionOwner.attributes\n\t\t\t: undefined;\n\n\treturn {\n\t\tagentId: config.agentId,\n\t\tuserInput: userMessage,\n\t\tsessionId,\n\t\tsessionOwnerId,\n\t\tsessionOwnerLabel: sessionOwner?.name || undefined,\n\t\tsessionAttributes,\n\t\tanalysisMode: options?.analysisMode,\n\t\tlocale: resolveLocale(config.locale),\n\t\ttimezone: resolveTimezone(config.timezone),\n\t};\n}\n\n/**\n * Resolve the BCP-47 locale to send with ask requests. Tries explicit\n * config first, then the browser's `navigator.language`, then a safe\n * \"en-US\" fallback. The server requires this field on the playground\n * endpoint — never returns undefined.\n */\nfunction resolveLocale(configured?: string): string {\n\tif (configured && configured.trim().length > 0) return configured.trim();\n\tif (typeof navigator !== \"undefined\") {\n\t\tconst navLocale = (navigator as { language?: string }).language;\n\t\tif (navLocale && navLocale.length > 0) return navLocale;\n\t}\n\treturn \"en-US\";\n}\n\n/**\n * Resolve the IANA timezone to send with ask requests. Tries explicit\n * config first, then `Intl.DateTimeFormat().resolvedOptions().timeZone`,\n * then \"UTC\" as a last resort. Optional on the server, but sending\n * something useful means agents can localize date prose without a\n * follow-up clarification.\n */\nfunction resolveTimezone(configured?: string): string {\n\tif (configured && configured.trim().length > 0) return configured.trim();\n\ttry {\n\t\tconst zone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n\t\tif (zone && zone.length > 0) return zone;\n\t} catch {\n\t\t// Intl missing or unhappy — fall through to the UTC default.\n\t}\n\treturn \"UTC\";\n}\n\n/**\n * Build streaming URL. Defaults to the k2 playground stream endpoint.\n */\nexport function buildStreamingUrl(config: ChatConfig): string {\n\tconst endpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst stage = config.stage || \"DEV\";\n\tconst stageParamName = config.stageQueryParam ?? \"stage\";\n\tconst queryParams = new URLSearchParams({ [stageParamName]: stage });\n\n\treturn `${config.api.baseUrl}${endpoint}?${queryParams.toString()}`;\n}\n\n/**\n * Build user action URL (submit / cancel / resend)\n * Derives base path from the stream endpoint by stripping the \"/stream\" suffix.\n */\nexport function buildUserActionUrl(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\taction: \"submit\" | \"cancel\" | \"resend\" | \"expired\",\n): string {\n\tconst endpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst [endpointPath] = endpoint.split(\"?\");\n\tconst normalizedEndpointPath = endpointPath.replace(/\\/+$/, \"\");\n\tconst basePath = normalizedEndpointPath.endsWith(\"/stream\")\n\t\t? normalizedEndpointPath.slice(0, -\"/stream\".length)\n\t\t: normalizedEndpointPath;\n\tconst encodedUserActionId = encodeURIComponent(userActionId);\n\treturn `${config.api.baseUrl}${basePath}/user-action/${encodedUserActionId}/${action}`;\n}\n\n/**\n * Build resolve-image-urls endpoint URL.\n * Derives the base path from the stream endpoint (same pattern as buildUserActionUrl)\n * so that playground URLs stay on the playground path and workflow URLs stay on the\n * workflows path. An explicit resolveImagesEndpoint in config always wins.\n */\nexport function buildResolveImagesUrl(config: ChatConfig): string {\n\tif (config.api.resolveImagesEndpoint) {\n\t\treturn `${config.api.baseUrl}${config.api.resolveImagesEndpoint}`;\n\t}\n\tconst streamEndpoint = config.api.streamEndpoint || DEFAULT_STREAM_ENDPOINT;\n\tconst [endpointPath] = streamEndpoint.split(\"?\");\n\tconst normalizedEndpointPath = endpointPath.replace(/\\/+$/, \"\");\n\tconst basePath = normalizedEndpointPath.endsWith(\"/stream\")\n\t\t? normalizedEndpointPath.slice(0, -\"/stream\".length)\n\t\t: normalizedEndpointPath;\n\treturn `${config.api.baseUrl}${basePath}/resolve-image-urls`;\n}\n\n/**\n * Build request headers\n */\nexport function buildRequestHeaders(config: ChatConfig): Record<string, string> {\n\tconst headers: Record<string, string> = {\n\t\t...config.api.headers,\n\t};\n\tif (config.api.authToken) {\n\t\theaders.Authorization = `Bearer ${config.api.authToken}`;\n\t}\n\treturn headers;\n}\n","import type { ChatConfig } from \"../types\";\nimport { buildResolveImagesUrl, buildRequestHeaders } from \"./requestBuilder\";\n\n/** Matches the RAG image path pattern: /api/rag/chunks/<id>/<version>/<chunk>/image */\nconst RAG_IMAGE_REGEX = /\\/api\\/rag\\/chunks\\/[^\"'\\s]+\\/image/;\n\n/**\n * Returns true if the content contains any unresolved RAG image URLs.\n */\nexport function hasRagImages(content: string): boolean {\n\treturn RAG_IMAGE_REGEX.test(content);\n}\n\n/**\n * Wait one paint before starting the resolve request so the final response\n * can render first and image placeholders can appear in the UI.\n */\nexport async function waitForNextPaint(signal?: AbortSignal): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tlet isSettled = false;\n\n\t\tconst finish = () => {\n\t\t\tif (isSettled) return;\n\t\t\tisSettled = true;\n\t\t\tsignal?.removeEventListener(\"abort\", finish);\n\t\t\tresolve();\n\t\t};\n\n\t\tsignal?.addEventListener(\"abort\", finish, { once: true });\n\n\t\tif (typeof requestAnimationFrame === \"function\") {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tsetTimeout(finish, 0);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tsetTimeout(finish, 0);\n\t});\n}\n\n/**\n * Calls the resolve-image-urls API to replace RAG image paths with\n * real signed Azure Blob Storage URLs.\n *\n * @throws on non-2xx HTTP status\n */\nexport async function resolveRagImageUrls(\n\tconfig: ChatConfig,\n\tcontent: string,\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tconst url = buildResolveImagesUrl(config);\n\tconst baseHeaders = buildRequestHeaders(config);\n\tconst headers = { \"Content-Type\": \"application/json\", ...baseHeaders };\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: JSON.stringify({ input: content }),\n\t\tsignal,\n\t});\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t}\n\n\tconst text = await response.text();\n\n\t// Handle both plain-text and JSON-wrapped responses\n\ttry {\n\t\tconst parsed = JSON.parse(text);\n\t\tif (typeof parsed === \"string\") return parsed;\n\t\tif (typeof parsed.output === \"string\") return parsed.output;\n\t\tif (typeof parsed.result === \"string\") return parsed.result;\n\t} catch {\n\t\t// Not JSON — treat as plain text\n\t}\n\n\treturn text;\n}\n","import { useCallback, useRef } from \"react\";\nimport type { ChatConfig, ChatCallbacks, MessageDisplay } from \"../types\";\nimport { streamWorkflowEvents, type StreamEvent } from \"../utils/streamingClient\";\nimport {\n\tprocessStreamEventV2,\n\tcreateInitialV2State,\n\tgetEventMessage,\n\tisBlandStatus,\n} from \"../utils/v2EventProcessor\";\nimport {\n\tbuildRequestBody,\n\tbuildStreamingUrl,\n\tbuildRequestHeaders,\n\ttype AnalysisMode,\n} from \"../utils/requestBuilder\";\nimport {\n\thasRagImages,\n\tresolveRagImageUrls,\n\twaitForNextPaint,\n} from \"../utils/ragImageResolver\";\n\nconst FRIENDLY_ERROR_MESSAGE = \"Oops, something went wrong. Please try again.\";\n\n/**\n * K2 stream manager:\n * - Mirrors answer tokens into `streamingContent` during RUN_IN_PROGRESS\n * - Buffers the final response until RUN_COMPLETED / WORKFLOW_COMPLETED\n * - No throttle interval — UI-side `useTypingEffect` handles animation\n */\nexport function useStreamManagerV2(\n\tconfig: ChatConfig,\n\tcallbacks: ChatCallbacks,\n\tsetMessages: React.Dispatch<React.SetStateAction<MessageDisplay[]>>,\n\tsetIsWaitingForResponse: (waiting: boolean) => void,\n) {\n\tconst abortControllerRef = useRef<AbortController | null>(null);\n\n\tconst configRef = useRef(config);\n\tconfigRef.current = config;\n\tconst callbacksRef = useRef(callbacks);\n\tcallbacksRef.current = callbacks;\n\n\tconst startStream = useCallback(\n\t\tasync (\n\t\t\tuserMessage: string,\n\t\t\tstreamingId: string,\n\t\t\tsessionId?: string,\n\t\t\texternalAbortController?: AbortController,\n\t\t\toptions?: { analysisMode?: AnalysisMode },\n\t\t): Promise<string | undefined> => {\n\t\t\tabortControllerRef.current?.abort();\n\t\t\tconst abortController = externalAbortController ?? new AbortController();\n\t\t\tabortControllerRef.current = abortController;\n\n\t\t\tconst state = createInitialV2State();\n\n\t\t\tconst updateMessage = (update: Partial<MessageDisplay>) => {\n\t\t\t\tif (abortController.signal.aborted) return;\n\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\tmsg.id === streamingId ? { ...msg, ...update } : msg,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst currentConfig = configRef.current;\n\t\t\t\tconst requestBody = buildRequestBody(\n\t\t\t\t\tcurrentConfig,\n\t\t\t\t\tuserMessage,\n\t\t\t\t\tsessionId,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tconst url = buildStreamingUrl(currentConfig);\n\t\t\t\tconst headers = buildRequestHeaders(currentConfig);\n\n\t\t\t\tawait streamWorkflowEvents(url, requestBody, headers, {\n\t\t\t\t\tsignal: abortController.signal,\n\t\t\t\t\tonEvent: (event: StreamEvent) => {\n\t\t\t\t\t\tif (abortController.signal.aborted) return;\n\n\t\t\t\t\t\t// KEEP_ALIVE used to early-return here as a no-op\n\t\t\t\t\t\t// liveness tick. Server now attaches a rotating\n\t\t\t\t\t\t// `description` phrase during silent-think gaps so\n\t\t\t\t\t\t// the chat bubble status line changes instead of\n\t\t\t\t\t\t// freezing on \"Thinking…\". processStreamEventV2 owns\n\t\t\t\t\t\t// that mirroring; we fall through to updateMessage\n\t\t\t\t\t\t// so the new phrase actually reaches the UI.\n\t\t\t\t\t\tprocessStreamEventV2(event, state);\n\n\t\t\t\t\t\t// Dispatch user-action callbacks from the transient\n\t\t\t\t\t\t// signals the processor set for THIS event. A\n\t\t\t\t\t\t// `USER_ACTION_REQUIRED` whose action is a notification\n\t\t\t\t\t\t// surfaces via `lastNotification` instead of\n\t\t\t\t\t\t// `lastUserAction`.\n\t\t\t\t\t\tif (state.lastUserAction) {\n\t\t\t\t\t\t\tcallbacksRef.current.onUserActionRequired?.(state.lastUserAction);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (state.lastNotification) {\n\t\t\t\t\t\t\tcallbacksRef.current.onUserNotification?.(state.lastNotification);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst activeStep = state.steps.find((s) => s.id === state.currentExecutingStepId);\n\t\t\t\t\t\tconst lastInProgressStep = [...state.steps].reverse().find((s) => s.status === \"in_progress\");\n\t\t\t\t\t\t// Bland default-start labels like \"Executing…\" / \"Working\n\t\t\t\t\t\t// on it…\" come from each pipeline stage's\n\t\t\t\t\t\t// defaultStartMessage on the server. They flicker into the\n\t\t\t\t\t\t// chat bubble for the moment between an analyzer's dynamic\n\t\t\t\t\t\t// \"Pulling those up…\" status and the first tool call's\n\t\t\t\t\t\t// real \"Got 437 transactions\" — replacing useful info\n\t\t\t\t\t\t// with placeholder noise. Filter them out so the user\n\t\t\t\t\t\t// sees the most-recent SUBSTANTIVE message instead.\n\t\t\t\t\t\tconst useful = (m: string | undefined): string | undefined =>\n\t\t\t\t\t\t\tm && !isBlandStatus(m) ? m : undefined;\n\t\t\t\t\t\t// Walk backwards for the most recent USEFUL step message.\n\t\t\t\t\t\t// If executor just started with bland \"Executing…\" and\n\t\t\t\t\t\t// analyzer is done with \"Pulling those up for you now\",\n\t\t\t\t\t\t// we want analyzer's — bland on the latest step must\n\t\t\t\t\t\t// NOT shadow useful older ones. Previously latestWithMessage\n\t\t\t\t\t\t// returned the bland top-of-stack step and the candidate\n\t\t\t\t\t\t// chain fell through to the last-resort bland fallback even\n\t\t\t\t\t\t// though useful messages existed deeper in the stack.\n\t\t\t\t\t\tconst latestUsefulStep = [...state.steps].reverse().find(\n\t\t\t\t\t\t\t(s) => s.message && !isBlandStatus(s.message),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst currentMessage =\n\t\t\t\t\t\t\tuseful(activeStep?.message) ??\n\t\t\t\t\t\t\tuseful(lastInProgressStep?.message) ??\n\t\t\t\t\t\t\tlatestUsefulStep?.message ??\n\t\t\t\t\t\t\tuseful(getEventMessage(event)) ??\n\t\t\t\t\t\t\t// Last-resort: every candidate is bland (very first event,\n\t\t\t\t\t\t\t// nothing useful seen yet). Render the bland label so the\n\t\t\t\t\t\t\t// bubble isn't blank.\n\t\t\t\t\t\t\tactiveStep?.message ??\n\t\t\t\t\t\t\tlastInProgressStep?.message ??\n\t\t\t\t\t\t\tgetEventMessage(event);\n\t\t\t\t\t\t// Notify consumers of every status-message change so a\n\t\t\t\t\t\t// surface outside the chat bubble (pipeline sidebar,\n\t\t\t\t\t\t// agent-avatar label) can mirror it without re-parsing\n\t\t\t\t\t\t// the event stream. Debounced implicitly by React\n\t\t\t\t\t\t// reconciliation — the callback fires every event but\n\t\t\t\t\t\t// consumers typically setState against it and React\n\t\t\t\t\t\t// dedups.\n\t\t\t\t\t\tif (currentMessage) {\n\t\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(currentMessage);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Give the host app the full steps snapshot so\n\t\t\t\t\t\t// pipeline-sidebar UIs can derive per-stage status\n\t\t\t\t\t\t// without reverse-mapping labels. Only fire when\n\t\t\t\t\t\t// steps actually changed (every STAGE_* event).\n\t\t\t\t\t\tcallbacksRef.current.onStepsUpdate?.([...state.steps]);\n\n\t\t\t\t\t\tif (state.hasError) {\n\t\t\t\t\t\t\tupdateMessage({\n\t\t\t\t\t\t\t\tstreamingContent: FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\tcontent: FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\tstreamProgress: \"error\",\n\t\t\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\t\t\terrorDetails: state.errorMessage,\n\t\t\t\t\t\t\t\tsteps: [...state.steps],\n\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t\tsessionId: state.sessionId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Mirror state.finalResponse into streamingContent\n\t\t\t\t\t\t\t// as it builds up from INTENT_PROGRESS deltas.\n\t\t\t\t\t\t\t// The k2 Formatter streams its LLM output chunk-\n\t\t\t\t\t\t\t// by-chunk; this is how the user sees the answer\n\t\t\t\t\t\t\t// build in real time instead of staring at a\n\t\t\t\t\t\t\t// blank screen for the ~2-3s the LLM takes.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Pre-streaming servers never emit partial text,\n\t\t\t\t\t\t\t// so state.finalResponse stays \"\" until\n\t\t\t\t\t\t\t// WORKFLOW_COMPLETED — rendering \"\" here matches\n\t\t\t\t\t\t\t// the old behavior exactly for that case.\n\t\t\t\t\t\t\tupdateMessage({\n\t\t\t\t\t\t\t\tstreamingContent: state.finalResponse,\n\t\t\t\t\t\t\t\tcontent: \"\",\n\t\t\t\t\t\t\t\tcurrentMessage,\n\t\t\t\t\t\t\t\tstreamProgress: \"processing\",\n\t\t\t\t\t\t\t\tisError: false,\n\t\t\t\t\t\t\t\tsteps: [...state.steps],\n\t\t\t\t\t\t\t\tcurrentExecutingStepId: state.currentExecutingStepId,\n\t\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t\tsessionId: state.sessionId,\n\t\t\t\t\t\t\t\tisCancelled: false,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonError: (error: Error) => {\n\t\t\t\t\t\tsetIsWaitingForResponse(false);\n\t\t\t\t\t\t// Clear any status-message consumers are mirroring —\n\t\t\t\t\t\t// the run is over, whatever was last showing is\n\t\t\t\t\t\t// stale now.\n\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(null);\n\n\t\t\t\t\t\tif (error.name !== \"AbortError\") {\n\t\t\t\t\t\t\tcallbacksRef.current.onError?.(error);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst isAborted = error.name === \"AbortError\";\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\t\t\t\t\tstreamProgress: isAborted ? (\"processing\" as const) : (\"error\" as const),\n\t\t\t\t\t\t\t\t\t\t\tisError: !isAborted,\n\t\t\t\t\t\t\t\t\t\t\tisCancelled: isAborted,\n\t\t\t\t\t\t\t\t\t\t\terrorDetails: isAborted ? undefined : error.message,\n\t\t\t\t\t\t\t\t\t\t\tcontent: isAborted\n\t\t\t\t\t\t\t\t\t\t\t\t? state.finalResponse || \"\"\n\t\t\t\t\t\t\t\t\t\t\t\t: state.finalResponse || FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\t\t\t\tcurrentMessage: isAborted ? \"Thinking...\" : undefined,\n\t\t\t\t\t\t\t\t\t\t\tsteps: [...state.steps].map((step) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (step.status === \"in_progress\" && isAborted) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn step;\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tonComplete: () => {\n\t\t\t\t\t\tsetIsWaitingForResponse(false);\n\t\t\t\t\t\t// Run is over — consumers tracking the status\n\t\t\t\t\t\t// message should clear their label / revert to\n\t\t\t\t\t\t// whatever default (agent name, blank).\n\t\t\t\t\t\tcallbacksRef.current.onStatusMessage?.(null);\n\t\t\t\t\t\t// Reset the steps snapshot so pipeline-sidebar\n\t\t\t\t\t\t// UIs can revert all stages back to idle.\n\t\t\t\t\t\tcallbacksRef.current.onStepsUpdate?.([]);\n\n\t\t\t\t\t\tif (state.sessionId && state.sessionId !== sessionId) {\n\t\t\t\t\t\t\tcallbacksRef.current.onSessionIdChange?.(state.sessionId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst needsImageResolve =\n\t\t\t\t\t\t\t!state.hasError &&\n\t\t\t\t\t\t\t!abortController.signal.aborted &&\n\t\t\t\t\t\t\thasRagImages(state.finalResponse);\n\n\t\t\t\t\t\tconst finalMessage: MessageDisplay = {\n\t\t\t\t\t\t\tid: streamingId,\n\t\t\t\t\t\t\tsessionId: state.sessionId || sessionId,\n\t\t\t\t\t\t\trole: \"assistant\",\n\t\t\t\t\t\t\tcontent: state.hasError ? FRIENDLY_ERROR_MESSAGE : state.finalResponse || \"\",\n\t\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\tstreamProgress: state.hasError ? \"error\" : \"completed\",\n\t\t\t\t\t\t\tisError: state.hasError,\n\t\t\t\t\t\t\terrorDetails: state.hasError ? state.errorMessage : undefined,\n\t\t\t\t\t\t\texecutionId: state.executionId,\n\t\t\t\t\t\t\t// Defensive: tracingData must be an object (or undefined)\n\t\t\t\t\t\t\t// so the JSON viewer doesn't char-iterate a string. The\n\t\t\t\t\t\t\t// event processor already drops bare strings; this is\n\t\t\t\t\t\t\t// the last stop before the message leaves the SDK.\n\t\t\t\t\t\t\ttracingData:\n\t\t\t\t\t\t\t\tstate.finalData != null && typeof state.finalData === \"object\"\n\t\t\t\t\t\t\t\t\t? state.finalData\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tsteps: state.hasError ? [] : [...state.steps],\n\t\t\t\t\t\t\tisCancelled: false,\n\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\tisResolvingImages: needsImageResolve,\n\t\t\t\t\t\t\ttotalElapsedMs: state.hasError ? undefined : state.totalElapsedMs,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId ? finalMessage : msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcallbacksRef.current.onStreamComplete?.(finalMessage);\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tconst shouldResolveImages =\n\t\t\t\t\t!abortController.signal.aborted &&\n\t\t\t\t\t!state.hasError &&\n\t\t\t\t\thasRagImages(state.finalResponse);\n\n\t\t\t\tif (shouldResolveImages) {\n\t\t\t\t\tawait waitForNextPaint(abortController.signal);\n\t\t\t\t}\n\n\t\t\t\tif (shouldResolveImages && !abortController.signal.aborted) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst resolvedContent = await resolveRagImageUrls(\n\t\t\t\t\t\t\tcurrentConfig,\n\t\t\t\t\t\t\tstate.finalResponse,\n\t\t\t\t\t\t\tabortController.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t\t\t? { ...msg, content: resolvedContent, isResolvingImages: false }\n\t\t\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\t\t\tmsg.id === streamingId ? { ...msg, isResolvingImages: false } : msg,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn state.sessionId;\n\t\t\t} catch (error) {\n\t\t\t\tsetIsWaitingForResponse(false);\n\n\t\t\t\tif ((error as Error).name !== \"AbortError\") {\n\t\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\t}\n\n\t\t\t\tconst isAborted = (error as Error).name === \"AbortError\";\n\t\t\t\tsetMessages((prev) =>\n\t\t\t\t\tprev.map((msg) =>\n\t\t\t\t\t\tmsg.id === streamingId\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t\t\t\tisStreaming: false,\n\t\t\t\t\t\t\t\t\tstreamProgress: isAborted ? (\"processing\" as const) : (\"error\" as const),\n\t\t\t\t\t\t\t\t\tisError: !isAborted,\n\t\t\t\t\t\t\t\t\tisCancelled: isAborted,\n\t\t\t\t\t\t\t\t\terrorDetails: isAborted ? undefined : (error as Error).message,\n\t\t\t\t\t\t\t\t\tcontent: isAborted\n\t\t\t\t\t\t\t\t\t\t? state.finalResponse || \"\"\n\t\t\t\t\t\t\t\t\t\t: state.finalResponse || FRIENDLY_ERROR_MESSAGE,\n\t\t\t\t\t\t\t\t\tsteps: [...state.steps].map((step) => {\n\t\t\t\t\t\t\t\t\t\tif (step.status === \"in_progress\" && isAborted) {\n\t\t\t\t\t\t\t\t\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn step;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: msg,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn state.sessionId;\n\t\t\t}\n\t\t},\n\t\t[setMessages, setIsWaitingForResponse],\n\t);\n\n\tconst cancelStream = useCallback(() => {\n\t\tabortControllerRef.current?.abort();\n\t}, []);\n\n\treturn {\n\t\tstartStream,\n\t\tcancelStream,\n\t\tabortControllerRef,\n\t};\n}\n","import type { MessageDisplay, StreamingStep } from \"../types\";\n\n/**\n * Create cancelled message update\n */\nexport function createCancelledMessageUpdate(\n\tsteps: StreamingStep[],\n\tcurrentMessage?: string\n): Partial<MessageDisplay> {\n\tconst updatedSteps = steps.map((step) => {\n\t\tif (step.status === \"in_progress\") {\n\t\t\treturn { ...step, status: \"pending\" as const };\n\t\t}\n\t\treturn step;\n\t});\n\n\treturn {\n\t\tisStreaming: false,\n\t\tisCancelled: true,\n\t\tsteps: updatedSteps,\n\t\tcurrentExecutingStepId: undefined,\n\t\tcurrentMessage: currentMessage || \"Thinking...\",\n\t};\n}\n","import type { ChatConfig } from \"../types\";\nimport { buildUserActionUrl, buildRequestHeaders } from \"./requestBuilder\";\n\ntype UserActionResponse = {\n\tsuccess: boolean;\n\tmessage: string;\n};\n\n/**\n * Thrown when a resolution endpoint returns `404`\n * (`user_action_not_found`): the prompt already resolved, expired, or\n * the id is unknown. Callers should treat the prompt as no longer\n * actionable — stop any countdown and clear the form — rather than\n * surfacing this as a hard error.\n */\nexport class UserActionStaleError extends Error {\n\treadonly userActionId: string;\n\tconstructor(userActionId: string, message = \"User action is no longer actionable\") {\n\t\tsuper(message);\n\t\tthis.name = \"UserActionStaleError\";\n\t\tthis.userActionId = userActionId;\n\t}\n}\n\n/**\n * Internal helper — sends a POST to a user-action endpoint and returns the\n * parsed JSON response. Throws `UserActionStaleError` on 404 and a\n * generic error on other non-2xx status / JSON parse failure.\n */\nasync function sendUserActionRequest(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\taction: \"submit\" | \"cancel\" | \"resend\" | \"expired\",\n\tdata?: Record<string, unknown>,\n): Promise<UserActionResponse> {\n\tconst url = buildUserActionUrl(config, userActionId, action);\n\tconst baseHeaders = buildRequestHeaders(config);\n\tconst hasBody = data !== undefined;\n\tconst headers = hasBody\n\t\t? { \"Content-Type\": \"application/json\", ...baseHeaders }\n\t\t: baseHeaders;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: hasBody ? JSON.stringify(data) : undefined,\n\t});\n\n\tif (response.status === 404) {\n\t\tthrow new UserActionStaleError(userActionId);\n\t}\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`HTTP ${response.status}: ${errorText}`);\n\t}\n\n\treturn await response.json();\n}\n\n/**\n * Submit a user action. `content` is the schema-typed form payload sent\n * straight through to the agent (its keys should match the prompt's\n * `requestedSchema.properties`) — e.g. `{ otp: \"123456\" }` for a\n * verification prompt or `{ amount: 50, confirm: true }` for a form.\n */\nexport async function submitUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n\tcontent?: Record<string, unknown>,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"submit\", content ?? {});\n}\n\n/**\n * Cancel / reject a user action\n */\nexport async function cancelUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"cancel\");\n}\n\n/**\n * Resend a user action (e.g. request a new OTP)\n */\nexport async function resendUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"resend\");\n}\n\nexport async function expireUserAction(\n\tconfig: ChatConfig,\n\tuserActionId: string,\n): Promise<UserActionResponse> {\n\treturn sendUserActionRequest(config, userActionId, \"expired\");\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n\tActiveUserAction,\n\tChatCallbacks,\n\tChatConfig,\n\tMessageDisplay,\n\tUserActionRequest,\n\tUserActionState,\n} from \"../types\";\nimport { generateId } from \"../utils/generateId\";\nimport { chatStore } from \"../utils/chatStore\";\nimport { activeStreamStore } from \"../utils/activeStreamStore\";\nimport { useStreamManagerV2 } from \"./useStreamManagerV2\";\nimport type { AnalysisMode } from \"../utils/requestBuilder\";\nimport { createCancelledMessageUpdate } from \"../utils/messageStateManager\";\nimport {\n\tsubmitUserAction as submitUserActionApi,\n\tcancelUserAction as cancelUserActionApi,\n\tresendUserAction as resendUserActionApi,\n\texpireUserAction as expireUserActionApi,\n\tUserActionStaleError,\n} from \"../utils/userActionClient\";\n\nconst EMPTY_USER_ACTION_STATE: UserActionState = { prompts: [], notifications: [] };\n\n/**\n * Upsert a prompt applying the supersede rule: a request matching an\n * existing slot's `toolCallId` (a retry/resend, possibly with a new\n * `userActionId`) REPLACES that slot in place; otherwise it's appended\n * as a new (parallel) prompt.\n */\nfunction upsertPrompt(\n\tprompts: ActiveUserAction[],\n\treq: UserActionRequest,\n): ActiveUserAction[] {\n\tconst active: ActiveUserAction = { ...req, status: \"pending\" };\n\tconst idx = prompts.findIndex((p) =>\n\t\treq.toolCallId\n\t\t\t? p.toolCallId === req.toolCallId\n\t\t\t: p.userActionId === req.userActionId,\n\t);\n\tif (idx >= 0) {\n\t\tconst next = prompts.slice();\n\t\tnext[idx] = active;\n\t\treturn next;\n\t}\n\treturn [...prompts, active];\n}\n\nexport type SendMessageOptions = {\n\t/**\n\t * Latency-vs-precision toggle surfaced in the chat widget.\n\t * `\"fast\"` (default) — the server caps list-tool fetches and\n\t * returns a quick, directionally correct answer with a sampling\n\t * caveat. `\"deep\"` — the server runs a full analytical pass,\n\t * no row caps, full rankings.\n\t *\n\t * Undefined / omitted means \"don't set — let the server use its\n\t * default\", which is `\"fast\"` today. Callers that want explicit\n\t * control should always pass this; callers that don't care can\n\t * skip it and inherit the server default.\n\t */\n\tanalysisMode?: AnalysisMode;\n};\n\nexport type UseChatV2Return = {\n\tmessages: MessageDisplay[];\n\tsendMessage: (userMessage: string, options?: SendMessageOptions) => Promise<void>;\n\tclearMessages: () => void;\n\tprependMessages: (messages: MessageDisplay[]) => void;\n\tcancelStream: () => void;\n\tresetSession: () => void;\n\tgetSessionId: () => string | undefined;\n\tgetMessages: () => MessageDisplay[];\n\tisWaitingForResponse: boolean;\n\tsessionId: string | undefined;\n\t/** Active user-action prompts + one-way notifications for this chat. */\n\tuserActionState: UserActionState;\n\t/**\n\t * Submit a prompt's form payload. `content` keys should match the\n\t * prompt's `requestedSchema.properties` (e.g. `{ otp: \"123456\" }`).\n\t */\n\tsubmitUserAction: (userActionId: string, content: Record<string, unknown>) => Promise<void>;\n\t/** Cancel / decline a prompt. */\n\tcancelUserAction: (userActionId: string) => Promise<void>;\n\t/** Ask the agent to re-send a prompt (e.g. resend a verification code). */\n\tresendUserAction: (userActionId: string) => Promise<void>;\n\texpireUserAction: (userActionId: string) => Promise<void>;\n\t/** Dismiss a one-way notification from local state. */\n\tdismissNotification: (id: string) => void;\n};\n\nfunction getStoredOrInitialMessages(config: ChatConfig): MessageDisplay[] {\n\tif (!config.userId) return config.initialMessages ?? [];\n\n\t// Active stream takes highest priority — avoids flash when restoring a streaming session\n\tconst activeStream = activeStreamStore.get(config.userId);\n\tif (activeStream) return activeStream.messages;\n\n\tconst stored = chatStore.get(config.userId);\n\tif (stored.length > 0) return stored;\n\n\tif (config.initialMessages?.length) {\n\t\tchatStore.set(config.userId, config.initialMessages);\n\t\treturn config.initialMessages;\n\t}\n\n\treturn [];\n}\n\nfunction getSessionIdFromMessages(messages: MessageDisplay[]): string | undefined {\n\treturn messages.find((message) => message.sessionId)?.sessionId;\n}\n\nexport function useChatV2(config: ChatConfig, callbacks: ChatCallbacks = {}): UseChatV2Return {\n\tconst [messages, setMessages] = useState<MessageDisplay[]>(() => getStoredOrInitialMessages(config));\n\tconst [isWaitingForResponse, setIsWaitingForResponse] = useState(() => {\n\t\tif (!config.userId) return false;\n\t\treturn activeStreamStore.get(config.userId)?.isWaiting ?? false;\n\t});\n\tconst sessionIdRef = useRef<string | undefined>(\n\t\tgetSessionIdFromMessages(getStoredOrInitialMessages(config)) ?? config.initialSessionId ?? undefined,\n\t);\n\tconst prevUserIdRef = useRef<string | undefined>(config.userId);\n\t// Tracks the userId that was active when sendMessage was called — locked for the stream's lifetime\n\tconst streamUserIdRef = useRef<string | undefined>(undefined);\n\t// Tracks the previous userId seen by the subscription effect — used to detect renames\n\tconst subscriptionPrevUserIdRef = useRef<string | undefined>(config.userId);\n\n\tconst callbacksRef = useRef(callbacks);\n\tcallbacksRef.current = callbacks;\n\tconst configRef = useRef(config);\n\tconfigRef.current = config;\n\tconst messagesRef = useRef(messages);\n\tmessagesRef.current = messages;\n\n\tconst storeAwareSetMessages = useCallback<React.Dispatch<React.SetStateAction<MessageDisplay[]>>>(\n\t\t(updater) => {\n\t\t\t// Use the locked stream userId (set at sendMessage time) so background stream\n\t\t\t// updates go to the right store key even if the user switches sessions.\n\t\t\tconst streamUserId = streamUserIdRef.current;\n\t\t\tconst currentUserId = configRef.current.userId;\n\t\t\tconst storeKey = streamUserId ?? currentUserId;\n\t\t\tif (storeKey && activeStreamStore.has(storeKey)) {\n\t\t\t\tactiveStreamStore.applyMessages(storeKey, updater as MessageDisplay[] | ((prev: MessageDisplay[]) => MessageDisplay[]));\n\t\t\t}\n\t\t\t// Only update React state when on the same session as the running stream\n\t\t\tif (!streamUserId || streamUserId === currentUserId) {\n\t\t\t\tsetMessages(updater);\n\t\t\t}\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[],\n\t);\n\n\tconst storeAwareSetIsWaiting = useCallback(\n\t\t(waiting: boolean) => {\n\t\t\tconst streamUserId = streamUserIdRef.current;\n\t\t\tconst currentUserId = configRef.current.userId;\n\t\t\tconst storeKey = streamUserId ?? currentUserId;\n\t\t\tif (storeKey && activeStreamStore.has(storeKey)) {\n\t\t\t\tactiveStreamStore.setWaiting(storeKey, waiting);\n\t\t\t}\n\t\t\tif (!streamUserId || streamUserId === currentUserId) {\n\t\t\t\tsetIsWaitingForResponse(waiting);\n\t\t\t}\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[],\n\t);\n\n\tconst [userActionState, setUserActionState] = useState<UserActionState>(EMPTY_USER_ACTION_STATE);\n\n\tconst wrappedCallbacks = useMemo<ChatCallbacks>(() => ({\n\t\t...callbacksRef.current,\n\t\tonMessageSent: (message) => callbacksRef.current.onMessageSent?.(message),\n\t\tonStreamStart: () => callbacksRef.current.onStreamStart?.(),\n\t\tonStreamComplete: (message) => callbacksRef.current.onStreamComplete?.(message),\n\t\tonError: (error) => callbacksRef.current.onError?.(error),\n\t\tonExecutionTraceClick: (data) => callbacksRef.current.onExecutionTraceClick?.(data),\n\t\tonSessionIdChange: (sessionId) => callbacksRef.current.onSessionIdChange?.(sessionId),\n\t\tonUserActionRequired: (request) => {\n\t\t\tsetUserActionState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\tprompts: upsertPrompt(prev.prompts, request),\n\t\t\t}));\n\t\t\tcallbacksRef.current.onUserActionRequired?.(request);\n\t\t},\n\t\tonUserNotification: (notification) => {\n\t\t\tsetUserActionState((prev) =>\n\t\t\t\tprev.notifications.some((n) => n.id === notification.id)\n\t\t\t\t\t? prev\n\t\t\t\t\t: { ...prev, notifications: [...prev.notifications, notification] },\n\t\t\t);\n\t\t\tcallbacksRef.current.onUserNotification?.(notification);\n\t\t},\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}), []);\n\n\tconst { startStream, cancelStream: cancelStreamManager, abortControllerRef } = useStreamManagerV2(\n\t\tconfig,\n\t\twrappedCallbacks,\n\t\tstoreAwareSetMessages,\n\t\tstoreAwareSetIsWaiting,\n\t);\n\n\tconst sendMessage = useCallback(\n\t\tasync (userMessage: string, options?: SendMessageOptions) => {\n\t\t\tif (!userMessage.trim()) return;\n\n\t\t\tif (!sessionIdRef.current && configRef.current.autoGenerateSessionId !== false) {\n\t\t\t\tsessionIdRef.current = generateId();\n\t\t\t\tcallbacksRef.current.onSessionIdChange?.(sessionIdRef.current);\n\t\t\t}\n\n\t\t\tconst userMessageId = `user-${Date.now()}`;\n\t\t\tconst userMsg: MessageDisplay = {\n\t\t\t\tid: userMessageId,\n\t\t\t\tsessionId: sessionIdRef.current,\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: userMessage,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t};\n\n\t\t\tsetMessages((prev) => [...prev, userMsg]);\n\t\t\tcallbacksRef.current.onMessageSent?.(userMessage);\n\t\t\tsetIsWaitingForResponse(true);\n\t\t\tcallbacksRef.current.onStreamStart?.();\n\n\t\t\tconst streamingId = `assistant-${Date.now()}`;\n\t\t\tconst streamingMsg: MessageDisplay = {\n\t\t\t\tid: streamingId,\n\t\t\t\tsessionId: sessionIdRef.current,\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: \"\",\n\t\t\t\tstreamingContent: \"\",\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tisStreaming: true,\n\t\t\t\tstreamProgress: \"started\",\n\t\t\t\tsteps: [],\n\t\t\t\tcurrentExecutingStepId: undefined,\n\t\t\t\tisCancelled: false,\n\t\t\t\tcurrentMessage: undefined,\n\t\t\t};\n\n\t\t\tsetMessages((prev) => [...prev, streamingMsg]);\n\n\t\t\tconst abortController = new AbortController();\n\t\t\tconst { userId } = configRef.current;\n\t\t\tif (userId) {\n\t\t\t\tstreamUserIdRef.current = userId;\n\t\t\t\tconst initialMessages = [...messagesRef.current, userMsg, streamingMsg];\n\t\t\t\tactiveStreamStore.start(userId, abortController, initialMessages);\n\t\t\t}\n\n\t\t\tconst newSessionId = await startStream(\n\t\t\t\tuserMessage,\n\t\t\t\tstreamingId,\n\t\t\t\tsessionIdRef.current,\n\t\t\t\tabortController,\n\t\t\t\toptions,\n\t\t\t);\n\n\t\t\t// Use streamUserIdRef in case it was updated by a rename (onSessionIdChange)\n\t\t\tconst finalStreamUserId = streamUserIdRef.current ?? userId;\n\t\t\tif (finalStreamUserId) {\n\t\t\t\tactiveStreamStore.complete(finalStreamUserId);\n\t\t\t}\n\t\t\tstreamUserIdRef.current = undefined;\n\n\t\t\tif (!abortController.signal.aborted && newSessionId && newSessionId !== sessionIdRef.current) {\n\t\t\t\tsessionIdRef.current = newSessionId;\n\t\t\t}\n\t\t},\n\t\t[startStream],\n\t);\n\n\tconst clearMessages = useCallback(() => {\n\t\tif (configRef.current.userId) {\n\t\t\tchatStore.delete(configRef.current.userId);\n\t\t}\n\t\tsetMessages([]);\n\t}, []);\n\n\tconst prependMessages = useCallback((msgs: MessageDisplay[]) => {\n\t\tsetMessages((prev) => [...msgs, ...prev]);\n\t}, []);\n\n\tconst cancelStream = useCallback(() => {\n\t\tconst streamUserId = streamUserIdRef.current ?? configRef.current.userId;\n\t\tif (streamUserId) {\n\t\t\tactiveStreamStore.abort(streamUserId);\n\t\t}\n\t\tstreamUserIdRef.current = undefined;\n\t\tcancelStreamManager();\n\t\tsetIsWaitingForResponse(false);\n\t\tsetUserActionState((prev) => ({ ...prev, prompts: [] }));\n\n\t\tsetMessages((prev) =>\n\t\t\tprev.map((msg) => {\n\t\t\t\tif (msg.isStreaming) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...msg,\n\t\t\t\t\t\t...createCancelledMessageUpdate(\n\t\t\t\t\t\t\tmsg.steps || [],\n\t\t\t\t\t\t\tmsg.currentMessage,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn msg;\n\t\t\t}),\n\t\t);\n\t}, [cancelStreamManager]);\n\n\tconst resetSession = useCallback(() => {\n\t\tconst streamUserId = streamUserIdRef.current ?? configRef.current.userId;\n\t\tif (streamUserId) {\n\t\t\tactiveStreamStore.abort(streamUserId);\n\t\t}\n\t\tif (configRef.current.userId) {\n\t\t\tchatStore.delete(configRef.current.userId);\n\t\t}\n\t\tstreamUserIdRef.current = undefined;\n\t\tsetMessages([]);\n\t\tsessionIdRef.current = undefined;\n\t\tabortControllerRef.current?.abort();\n\t\tsetIsWaitingForResponse(false);\n\t\tsetUserActionState(EMPTY_USER_ACTION_STATE);\n\t}, []);\n\n\tconst getSessionId = useCallback(() => {\n\t\treturn sessionIdRef.current;\n\t}, []);\n\n\tconst getMessages = useCallback(() => {\n\t\treturn messages;\n\t}, [messages]);\n\n\tconst setPromptStatus = useCallback(\n\t\t(userActionId: string, status: ActiveUserAction[\"status\"]) => {\n\t\t\tsetUserActionState((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\tprompts: prev.prompts.map((p) =>\n\t\t\t\t\tp.userActionId === userActionId ? { ...p, status } : p,\n\t\t\t\t),\n\t\t\t}));\n\t\t},\n\t\t[],\n\t);\n\n\tconst removePrompt = useCallback((userActionId: string) => {\n\t\tsetUserActionState((prev) => ({\n\t\t\t...prev,\n\t\t\tprompts: prev.prompts.filter((p) => p.userActionId !== userActionId),\n\t\t}));\n\t}, []);\n\n\tconst submitUserAction = useCallback(\n\t\tasync (userActionId: string, content: Record<string, unknown>) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait submitUserActionApi(configRef.current, userActionId, content);\n\t\t\t\t// Endpoint accepted the resolution: the run resumes on the\n\t\t\t\t// open stream. Drop the slot — if the input was invalid the\n\t\t\t\t// server emits a fresh USER_ACTION_REQUIRED (subAction\n\t\t\t\t// \"SubmissionInvalid\") that re-adds it.\n\t\t\t\tremovePrompt(userActionId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tsetPromptStatus(userActionId, \"stale\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Recoverable failure — let the user retry the same prompt.\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[removePrompt, setPromptStatus],\n\t);\n\n\tconst cancelUserAction = useCallback(\n\t\tasync (userActionId: string) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait cancelUserActionApi(configRef.current, userActionId);\n\t\t\t\tremovePrompt(userActionId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tremovePrompt(userActionId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[removePrompt, setPromptStatus],\n\t);\n\n\tconst resendUserAction = useCallback(\n\t\tasync (userActionId: string) => {\n\t\t\tsetPromptStatus(userActionId, \"submitting\");\n\t\t\ttry {\n\t\t\t\tawait resendUserActionApi(configRef.current, userActionId);\n\t\t\t\t// Keep the slot open; the server pushes a new\n\t\t\t\t// USER_ACTION_REQUIRED (\"RequestResent\") that supersedes it.\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) {\n\t\t\t\t\tsetPromptStatus(userActionId, \"stale\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetPromptStatus(userActionId, \"pending\");\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[setPromptStatus],\n\t);\n\n\tconst expireUserAction = useCallback(\n\t\tasync (userActionId: string) => {\n\t\t\tsetPromptStatus(userActionId, \"expired\");\n\t\t\ttry {\n\t\t\t\tawait expireUserActionApi(configRef.current, userActionId);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof UserActionStaleError) return;\n\t\t\t\tcallbacksRef.current.onError?.(error as Error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\t[setPromptStatus],\n\t);\n\n\tconst dismissNotification = useCallback((id: string) => {\n\t\tsetUserActionState((prev) => ({\n\t\t\t...prev,\n\t\t\tnotifications: prev.notifications.filter((n) => n.id !== id),\n\t\t}));\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst prevSubscriptionUserId = subscriptionPrevUserIdRef.current;\n\t\tsubscriptionPrevUserIdRef.current = config.userId;\n\t\tconst { userId } = config;\n\t\tif (!userId) return;\n\n\t\t// Detect when the stream was renamed (e.g. server assigned a new session ID via\n\t\t// migrateActiveStream in the app): old key is gone, new key has the stream,\n\t\t// and streamUserIdRef still points to the old key.\n\t\tif (\n\t\t\tprevSubscriptionUserId &&\n\t\t\tprevSubscriptionUserId !== userId &&\n\t\t\tstreamUserIdRef.current === prevSubscriptionUserId &&\n\t\t\t!activeStreamStore.has(prevSubscriptionUserId) &&\n\t\t\tactiveStreamStore.has(userId)\n\t\t) {\n\t\t\tstreamUserIdRef.current = userId;\n\t\t}\n\n\t\tconst unsubscribe = activeStreamStore.subscribe(userId, (msgs, isWaiting) => {\n\t\t\tsetMessages(msgs);\n\t\t\tsetIsWaitingForResponse(isWaiting);\n\t\t});\n\t\tconst active = activeStreamStore.get(userId);\n\t\tif (active) {\n\t\t\tsetMessages(active.messages);\n\t\t\tsetIsWaitingForResponse(active.isWaiting);\n\t\t}\n\t\treturn unsubscribe;\n\t}, [config.userId]);\n\n\tuseEffect(() => {\n\t\tif (!config.userId) return;\n\t\t// prevUserIdRef is updated in the userId-change effect which runs *after* this one.\n\t\t// If they differ here, userId just changed and messages still belong to the previous\n\t\t// session — skip so we don't corrupt the new session's chatStore entry.\n\t\tif (prevUserIdRef.current !== config.userId) return;\n\t\tconst toSave = messages.filter((m) => !m.isStreaming);\n\t\tif (toSave.length > 0) {\n\t\t\tchatStore.set(config.userId, toSave);\n\t\t}\n\t}, [messages, config.userId]);\n\n\tuseEffect(() => {\n\t\tif (!config.userId || activeStreamStore.has(config.userId)) return;\n\t\tif (!config.initialMessages?.length || messagesRef.current.length > 0) return;\n\n\t\tchatStore.set(config.userId, config.initialMessages);\n\t\tsetMessages(config.initialMessages);\n\t\tsessionIdRef.current = getSessionIdFromMessages(config.initialMessages) ?? config.initialSessionId;\n\t}, [config.initialMessages, config.initialSessionId, config.userId]);\n\n\tuseEffect(() => {\n\t\tconst prevUserId = prevUserIdRef.current;\n\t\tprevUserIdRef.current = config.userId;\n\n\t\tif (prevUserId === config.userId) return;\n\n\t\tif (prevUserId && !config.userId) {\n\t\t\tchatStore.delete(prevUserId);\n\t\t\tsetMessages([]);\n\t\t\tsessionIdRef.current = undefined;\n\t\t\tsetIsWaitingForResponse(false);\n\t\t\tsetUserActionState(EMPTY_USER_ACTION_STATE);\n\t\t} else if (config.userId) {\n\t\t\tconst active = activeStreamStore.get(config.userId);\n\t\t\tif (active) {\n\t\t\t\tsetMessages(active.messages);\n\t\t\t\tsetIsWaitingForResponse(active.isWaiting);\n\t\t\t\tsessionIdRef.current = getSessionIdFromMessages(active.messages) ?? config.initialSessionId;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextMessages = getStoredOrInitialMessages(config);\n\t\t\tsetMessages(nextMessages);\n\t\t\tsessionIdRef.current = getSessionIdFromMessages(nextMessages) ?? config.initialSessionId;\n\t\t\tsetIsWaitingForResponse(false);\n\t\t}\n\t}, [config]);\n\n\treturn {\n\t\tmessages,\n\t\tsendMessage,\n\t\tclearMessages,\n\t\tprependMessages,\n\t\tcancelStream,\n\t\tresetSession,\n\t\tgetSessionId,\n\t\tgetMessages,\n\t\tisWaitingForResponse,\n\t\tsessionId: sessionIdRef.current,\n\t\tuserActionState,\n\t\tsubmitUserAction,\n\t\tcancelUserAction,\n\t\tresendUserAction,\n\t\texpireUserAction,\n\t\tdismissNotification,\n\t};\n}\n","// ============================================\n// Voice Hook - Web Implementation\n// Uses Web Speech API (SpeechRecognition)\n// ============================================\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n\tVoiceCallbacks,\n\tVoiceConfig,\n\tVoicePermissions,\n\tVoiceState,\n\tUseVoiceReturn,\n} from \"../types/voice\";\n\n// ============================================\n// Web Speech API Types\n// ============================================\n\ninterface SpeechRecognitionEvent extends Event {\n\tresults: SpeechRecognitionResultList;\n\tresultIndex: number;\n}\n\ninterface SpeechRecognitionErrorEvent extends Event {\n\terror: string;\n\tmessage?: string;\n}\n\ninterface SpeechRecognition extends EventTarget {\n\tcontinuous: boolean;\n\tinterimResults: boolean;\n\tlang: string;\n\tmaxAlternatives: number;\n\tstart(): void;\n\tstop(): void;\n\tabort(): void;\n\tonstart: ((this: SpeechRecognition, ev: Event) => any) | null;\n\tonend: ((this: SpeechRecognition, ev: Event) => any) | null;\n\tonresult:\n\t\t| ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any)\n\t\t| null;\n\tonerror:\n\t\t| ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any)\n\t\t| null;\n}\n\ninterface SpeechRecognitionConstructor {\n\tnew (): SpeechRecognition;\n}\n\ndeclare global {\n\tinterface Window {\n\t\tSpeechRecognition?: SpeechRecognitionConstructor;\n\t\twebkitSpeechRecognition?: SpeechRecognitionConstructor;\n\t}\n}\n\n// ============================================\n// Helper Functions\n// ============================================\n\nfunction getSpeechRecognition(): SpeechRecognitionConstructor | null {\n\tif (typeof window === \"undefined\") return null;\n\treturn window.SpeechRecognition || window.webkitSpeechRecognition || null;\n}\n\n// ============================================\n// Hook Implementation\n// ============================================\n\nexport function useVoice(\n\tconfig: VoiceConfig = {},\n\tcallbacks: VoiceCallbacks = {}\n): UseVoiceReturn {\n\tconst [voiceState, setVoiceState] = useState<VoiceState>(\"idle\");\n\tconst [transcribedText, setTranscribedText] = useState(\"\");\n\tconst [isAvailable, setIsAvailable] = useState(false);\n\tconst [isRecording, setIsRecording] = useState(false);\n\n\tconst recognitionRef = useRef<SpeechRecognition | null>(null);\n\tconst autoStopTimerRef = useRef<NodeJS.Timeout | null>(null);\n\n\tconst {\n\t\tlang = \"en-US\",\n\t\tinterimResults = true,\n\t\tcontinuous = true,\n\t\tmaxAlternatives = 1,\n\t\tautoStopAfterSilence,\n\t} = config;\n\n\tconst { onStart, onEnd, onResult, onError, onStateChange } = callbacks;\n\n\t// Check speech recognition availability\n\tuseEffect(() => {\n\t\tconst SpeechRecognitionAPI = getSpeechRecognition();\n\t\tsetIsAvailable(SpeechRecognitionAPI !== null);\n\t}, []);\n\n\t// Notify state changes\n\tuseEffect(() => {\n\t\tonStateChange?.(voiceState);\n\t}, [voiceState, onStateChange]);\n\n\t// Request permissions (web prompts automatically on start)\n\tconst requestPermissions = useCallback(async (): Promise<VoicePermissions> => {\n\t\ttry {\n\t\t\tconst result = await navigator.mediaDevices.getUserMedia({\n\t\t\t\taudio: true,\n\t\t\t});\n\t\t\t// Stop the stream immediately, we just wanted to check permissions\n\t\t\tresult.getTracks().forEach((track) => track.stop());\n\n\t\t\treturn {\n\t\t\t\tgranted: true,\n\t\t\t\tstatus: \"granted\",\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"denied\",\n\t\t\t};\n\t\t}\n\t}, []);\n\n\t// Get permissions\n\tconst getPermissions = useCallback(async (): Promise<VoicePermissions> => {\n\t\tif (typeof navigator === \"undefined\" || !navigator.permissions) {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"undetermined\",\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await navigator.permissions.query({\n\t\t\t\tname: \"microphone\" as PermissionName,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tgranted: result.state === \"granted\",\n\t\t\t\tstatus:\n\t\t\t\t\tresult.state === \"granted\"\n\t\t\t\t\t\t? \"granted\"\n\t\t\t\t\t\t: result.state === \"denied\"\n\t\t\t\t\t\t? \"denied\"\n\t\t\t\t\t\t: \"undetermined\",\n\t\t\t};\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tgranted: false,\n\t\t\t\tstatus: \"undetermined\",\n\t\t\t};\n\t\t}\n\t}, []);\n\n\t// Clear auto-stop timer\n\tconst clearAutoStopTimer = useCallback(() => {\n\t\tif (autoStopTimerRef.current) {\n\t\t\tclearTimeout(autoStopTimerRef.current);\n\t\t\tautoStopTimerRef.current = null;\n\t\t}\n\t}, []);\n\n\t// Reset auto-stop timer\n\tconst resetAutoStopTimer = useCallback(() => {\n\t\tclearAutoStopTimer();\n\n\t\tif (autoStopAfterSilence && autoStopAfterSilence > 0) {\n\t\t\tautoStopTimerRef.current = setTimeout(() => {\n\t\t\t\tif (recognitionRef.current && isRecording) {\n\t\t\t\t\trecognitionRef.current.stop();\n\t\t\t\t}\n\t\t\t}, autoStopAfterSilence);\n\t\t}\n\t}, [autoStopAfterSilence, clearAutoStopTimer, isRecording]);\n\n\t// Stop recording\n\tconst stopRecording = useCallback(() => {\n\t\tif (recognitionRef.current) {\n\t\t\ttry {\n\t\t\t\trecognitionRef.current.stop();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"Error stopping speech recognition:\", error);\n\t\t\t}\n\t\t}\n\t\tclearAutoStopTimer();\n\t\tsetIsRecording(false);\n\t\tsetVoiceState(\"idle\");\n\t}, [clearAutoStopTimer]);\n\n\t// Start recording\n\tconst startRecording = useCallback(async () => {\n\t\tconst SpeechRecognitionAPI = getSpeechRecognition();\n\n\t\tif (!SpeechRecognitionAPI) {\n\t\t\tonError?.(\"Speech recognition not supported in this browser\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Request microphone permission first\n\t\t\ttry {\n\t\t\t\tawait navigator.mediaDevices.getUserMedia({ audio: true });\n\t\t\t} catch (permError) {\n\t\t\t\tonError?.(\"Microphone access denied. Please allow microphone access in your browser settings.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Create new recognition instance\n\t\t\tconst recognition = new SpeechRecognitionAPI();\n\t\t\trecognition.continuous = continuous;\n\t\t\trecognition.interimResults = interimResults;\n\t\t\trecognition.lang = lang;\n\t\t\trecognition.maxAlternatives = maxAlternatives;\n\n\t\t\t// Event handlers\n\t\t\trecognition.onstart = () => {\n\t\t\t\tsetVoiceState(\"listening\");\n\t\t\t\tsetIsRecording(true);\n\t\t\t\tonStart?.();\n\t\t\t\tresetAutoStopTimer();\n\t\t\t};\n\n\t\t\trecognition.onend = () => {\n\t\t\t\tsetVoiceState(\"idle\");\n\t\t\t\tsetIsRecording(false);\n\t\t\t\tclearAutoStopTimer();\n\t\t\t\tonEnd?.();\n\t\t\t};\n\n\t\t\trecognition.onresult = (event: SpeechRecognitionEvent) => {\n\t\t\t\tconst results = event.results;\n\t\t\t\tlet transcript = \"\";\n\n\t\t\t\t// Combine ALL results from the beginning (not just from resultIndex)\n\t\t\t\t// This ensures continuous speech is properly accumulated\n\t\t\t\tfor (let i = 0; i < results.length; i++) {\n\t\t\t\t\tconst result = results[i];\n\t\t\t\t\tif (result && result[0]) {\n\t\t\t\t\t\tconst text = result[0].transcript;\n\t\t\t\t\t\tif (transcript && !transcript.endsWith(\" \") && !text.startsWith(\" \")) {\n\t\t\t\t\t\t\ttranscript += \" \" + text;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttranscript += text;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttranscript = transcript.trim();\n\t\t\t\t\n\t\t\t\tif (transcript) {\n\t\t\t\t\tsetTranscribedText(transcript);\n\t\t\t\t\tonResult?.(transcript);\n\t\t\t\t\tresetAutoStopTimer();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\trecognition.onerror = (event: SpeechRecognitionErrorEvent) => {\n\t\t\t\tsetVoiceState(\"error\");\n\t\t\t\tsetIsRecording(false);\n\t\t\t\tclearAutoStopTimer();\n\n\t\t\t\t// Provide more user-friendly error messages\n\t\t\t\tlet errorMessage = event.error;\n\t\t\t\tif (event.error === \"not-allowed\") {\n\t\t\t\t\terrorMessage = \"Microphone access denied. Please allow microphone access in your browser settings.\";\n\t\t\t\t} else if (event.error === \"no-speech\") {\n\t\t\t\t\terrorMessage = \"No speech detected. Please try again.\";\n\t\t\t\t} else if (event.error === \"audio-capture\") {\n\t\t\t\t\terrorMessage = \"No microphone found or microphone is in use.\";\n\t\t\t\t} else if (event.error === \"network\") {\n\t\t\t\t\terrorMessage = \"Network error occurred. Please check your connection.\";\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tonError?.(errorMessage);\n\t\t\t};\n\n\t\t\trecognitionRef.current = recognition;\n\t\t\tsetTranscribedText(\"\");\n\n\t\t\t// Start recognition\n\t\t\trecognition.start();\n\t\t} catch (error) {\n\t\t\tsetVoiceState(\"error\");\n\t\t\tsetIsRecording(false);\n\t\t\tonError?.(\n\t\t\t\terror instanceof Error ? error.message : \"Failed to start recording\"\n\t\t\t);\n\t\t}\n\t}, [\n\t\tlang,\n\t\tinterimResults,\n\t\tcontinuous,\n\t\tmaxAlternatives,\n\t\tonStart,\n\t\tonEnd,\n\t\tonResult,\n\t\tonError,\n\t\tgetPermissions,\n\t\tresetAutoStopTimer,\n\t\tclearAutoStopTimer,\n\t]);\n\n\t// Clear transcript\n\tconst clearTranscript = useCallback(() => {\n\t\tsetTranscribedText(\"\");\n\t}, []);\n\n\t// Reset\n\tconst reset = useCallback(() => {\n\t\tstopRecording();\n\t\tsetTranscribedText(\"\");\n\t\tsetVoiceState(\"idle\");\n\t}, [stopRecording]);\n\n\t// Cleanup on unmount\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (recognitionRef.current) {\n\t\t\t\ttry {\n\t\t\t\t\trecognitionRef.current.stop();\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tclearAutoStopTimer();\n\t\t};\n\t}, [clearAutoStopTimer]);\n\n\treturn {\n\t\tvoiceState,\n\t\ttranscribedText,\n\t\tisAvailable,\n\t\tisRecording,\n\t\tstartRecording,\n\t\tstopRecording,\n\t\trequestPermissions,\n\t\tgetPermissions,\n\t\tclearTranscript,\n\t\treset,\n\t};\n}\n","// ============================================================\n// JSON Schema form helper (zero-dependency, platform-agnostic)\n// ============================================================\n//\n// MCP elicitation uses standard JSON Schema to describe the form a\n// prompt wants filled. The server emits a small, flat subset today\n// (a `properties` map of primitives + `oneOf` single-selects). These\n// pure helpers classify fields, coerce submitted values to the right\n// JSON type, and validate against the declared constraints.\n//\n// Design rules:\n// - No React, no DOM, no deps — usable by web and React Native UIs.\n// - Forward-compatible: unknown `type`s fall back to text, unknown\n// keywords are ignored, and nested objects/arrays are flagged as\n// unsupported (so the UI can skip them) rather than crashing.\n\nimport type {\n\tJsonSchemaField,\n\tJsonSchemaOption,\n\tRequestedSchema,\n} from \"../types\";\n\n/** The widget kinds the renderer knows how to draw. */\nexport type FieldWidget = \"text\" | \"integer\" | \"decimal\" | \"boolean\" | \"select\";\n\n/**\n * Classify a schema field into a widget kind. `oneOf` always wins\n * (titled single-select), then `type`. Anything unrecognized — or a\n * missing type — degrades to a plain text input.\n */\nexport function classifyField(field: JsonSchemaField | undefined): FieldWidget {\n\tif (!field) return \"text\";\n\tif (Array.isArray(field.oneOf) && field.oneOf.length > 0) return \"select\";\n\tswitch (field.type) {\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\t\tcase \"integer\":\n\t\t\treturn \"integer\";\n\t\tcase \"number\":\n\t\t\treturn \"decimal\";\n\t\tcase \"string\":\n\t\t\treturn \"text\";\n\t\tdefault:\n\t\t\treturn \"text\";\n\t}\n}\n\n/**\n * Fields we can't render as a flat primitive (nested objects, arrays,\n * tuple/composite schemas). The renderer should skip these rather than\n * attempt a best-effort input. `oneOf` is NOT considered unsupported —\n * it's our single-select shape.\n */\nexport function isNestedOrUnsupported(field: JsonSchemaField | undefined): boolean {\n\tif (!field) return false;\n\tif (field.type === \"object\" || field.type === \"array\") return true;\n\tif (\"properties\" in field && field.properties != null) return true;\n\tif (\"items\" in field && field.items != null) return true;\n\treturn false;\n}\n\n/** Normalize a field's `oneOf` into a clean option list (drops malformed entries). */\nexport function getOptions(field: JsonSchemaField | undefined): JsonSchemaOption[] {\n\tif (!field || !Array.isArray(field.oneOf)) return [];\n\treturn field.oneOf.filter(\n\t\t(o): o is JsonSchemaOption =>\n\t\t\t!!o && typeof o === \"object\" && typeof o.const === \"string\",\n\t);\n}\n\n/** Is `key` required per the schema's `required` array? */\nexport function isRequired(schema: RequestedSchema | undefined, key: string): boolean {\n\treturn Array.isArray(schema?.required) && schema!.required!.includes(key);\n}\n\n/**\n * Coerce a raw widget value into the JSON type the schema declares, so\n * the submitted `content` round-trips cleanly. Empty/blank values become\n * `undefined` (the field is simply omitted from the payload). The server\n * is tolerant of strings, but matching types keeps things clean.\n */\nexport function coerceValue(field: JsonSchemaField | undefined, raw: unknown): unknown {\n\tconst widget = classifyField(field);\n\n\tif (widget === \"boolean\") {\n\t\tif (typeof raw === \"boolean\") return raw;\n\t\tif (raw === \"true\") return true;\n\t\tif (raw === \"false\") return false;\n\t\treturn Boolean(raw);\n\t}\n\n\tif (widget === \"integer\" || widget === \"decimal\") {\n\t\tif (raw === \"\" || raw == null) return undefined;\n\t\tconst num = typeof raw === \"number\" ? raw : Number(String(raw).trim());\n\t\tif (Number.isNaN(num)) return undefined;\n\t\treturn widget === \"integer\" ? Math.trunc(num) : num;\n\t}\n\n\t// text + select → string\n\tif (raw == null) return undefined;\n\tconst str = String(raw);\n\treturn str === \"\" ? undefined : str;\n}\n\n/** Pre-fill value for a field's widget, from `default` (typed loosely for inputs). */\nexport function defaultValueFor(field: JsonSchemaField | undefined): unknown {\n\tif (!field || field.default === undefined) {\n\t\treturn classifyField(field) === \"boolean\" ? false : \"\";\n\t}\n\treturn field.default;\n}\n\n/**\n * Validate a single field's coerced value. Returns an error string or\n * `null` when valid. Only the documented keywords are enforced; unknown\n * keywords are ignored.\n */\nexport function validateField(\n\tfield: JsonSchemaField | undefined,\n\tvalue: unknown,\n\trequired: boolean,\n): string | null {\n\tconst widget = classifyField(field);\n\tconst label = field?.title || \"This field\";\n\n\tconst isEmpty =\n\t\tvalue === undefined ||\n\t\tvalue === null ||\n\t\t(typeof value === \"string\" && value.trim() === \"\");\n\n\tif (isEmpty) {\n\t\t// Booleans are never \"empty\" in a way that fails required.\n\t\tif (required && widget !== \"boolean\") return `${label} is required.`;\n\t\treturn null;\n\t}\n\n\tif (widget === \"integer\" || widget === \"decimal\") {\n\t\tconst num = typeof value === \"number\" ? value : Number(value);\n\t\tif (Number.isNaN(num)) return `${label} must be a number.`;\n\t\tif (widget === \"integer\" && !Number.isInteger(num)) {\n\t\t\treturn `${label} must be a whole number.`;\n\t\t}\n\t\tif (typeof field?.minimum === \"number\" && num < field.minimum) {\n\t\t\treturn `${label} must be at least ${field.minimum}.`;\n\t\t}\n\t\tif (typeof field?.maximum === \"number\" && num > field.maximum) {\n\t\t\treturn `${label} must be at most ${field.maximum}.`;\n\t\t}\n\t\treturn null;\n\t}\n\n\tif (widget === \"select\") {\n\t\tconst allowed = getOptions(field).map((o) => o.const);\n\t\tif (allowed.length > 0 && !allowed.includes(String(value))) {\n\t\t\treturn `${label} has an invalid selection.`;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// text\n\tconst str = String(value);\n\tif (typeof field?.minLength === \"number\" && str.length < field.minLength) {\n\t\treturn `${label} must be at least ${field.minLength} characters.`;\n\t}\n\tif (typeof field?.maxLength === \"number\" && str.length > field.maxLength) {\n\t\treturn `${label} must be at most ${field.maxLength} characters.`;\n\t}\n\treturn null;\n}\n\n/** Ordered list of renderable [key, field] pairs (skips unsupported fields). */\nexport function renderableFields(\n\tschema: RequestedSchema | undefined,\n): Array<[string, JsonSchemaField]> {\n\tconst props = schema?.properties;\n\tif (!props) return [];\n\treturn Object.entries(props).filter(([, field]) => !isNestedOrUnsupported(field));\n}\n\n/**\n * Validate a full form. `values` is the raw widget-value map (pre-coercion).\n * Returns a `{ key: error }` map (empty when the form is valid).\n */\nexport function validateForm(\n\tschema: RequestedSchema | undefined,\n\tvalues: Record<string, unknown>,\n): Record<string, string> {\n\tconst errors: Record<string, string> = {};\n\tfor (const [key, field] of renderableFields(schema)) {\n\t\tconst coerced = coerceValue(field, values[key]);\n\t\tconst err = validateField(field, coerced, isRequired(schema, key));\n\t\tif (err) errors[key] = err;\n\t}\n\treturn errors;\n}\n\n/**\n * Build the schema-typed `content` object to POST on submit. Only fields\n * present in the schema are included; blank/undefined values are omitted.\n */\nexport function buildContent(\n\tschema: RequestedSchema | undefined,\n\tvalues: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst content: Record<string, unknown> = {};\n\tfor (const [key, field] of renderableFields(schema)) {\n\t\tconst coerced = coerceValue(field, values[key]);\n\t\tif (coerced !== undefined) content[key] = coerced;\n\t}\n\treturn content;\n}\n","import { createContext, useContext } from \"react\";\nimport type { MessageDisplay } from \"../types\";\n\nexport interface PaymanChatContextValue {\n\t/**\n\t * Clear all messages and reset the chat\n\t */\n\tresetSession: () => void;\n\n\t/**\n\t * Clear all messages without resetting session ID\n\t */\n\tclearMessages: () => void;\n\n\t/**\n\t * Prepend older messages to the top of the list (e.g. from history pagination)\n\t */\n\tprependMessages: (messages: MessageDisplay[]) => void;\n\n\t/**\n\t * Cancel current streaming operation\n\t */\n\tcancelStream: () => void;\n\n\t/**\n\t * Get current session ID\n\t */\n\tgetSessionId: () => string | undefined;\n\n\t/**\n\t * Get all messages\n\t */\n\tgetMessages: () => MessageDisplay[];\n\n\t/**\n\t * Check if currently waiting for response\n\t */\n\tisWaitingForResponse: boolean;\n}\n\nexport const PaymanChatContext = createContext<\n\tPaymanChatContextValue | undefined\n>(undefined);\n\n/**\n * Hook to access PaymanChat controls from parent components\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const chat = usePaymanChat();\n * \n * return (\n * <>\n * <button onClick={chat.resetSession}>Reset</button>\n * <button onClick={chat.clearMessages}>Clear</button>\n * </>\n * );\n * }\n * ```\n */\nexport function usePaymanChat(): PaymanChatContextValue {\n\tconst context = useContext(PaymanChatContext);\n\tif (!context) {\n\t\tthrow new Error(\"usePaymanChat must be used within a PaymanChat component\");\n\t}\n\treturn context;\n}\n","import { Check, ChevronRight, Info, Mic, Pencil, Send, ShieldCheck, X } from \"lucide-react-native\";\nimport {\n\tforwardRef,\n\tmemo,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport {\n\tAnimated,\n\tDimensions,\n\tEasing,\n\tKeyboard,\n\tKeyboardAvoidingView,\n\tLayoutAnimation,\n\tPanResponder,\n\tPlatform,\n\tPressable,\n\tScrollView,\n\tStyleSheet,\n\tSwitch,\n\tText,\n\tTextInput,\n\tUIManager,\n\tuseColorScheme,\n\tView,\n} from \"react-native\";\nimport Markdown from \"react-native-markdown-display\";\nimport {\n\tuseChatV2,\n\tuseVoice,\n\tbuildContent,\n\tclassifyField,\n\tdefaultValueFor,\n\tgetOptions,\n\tisRequired,\n\trenderableFields,\n\tvalidateForm,\n} from \"@paymanai/payman-typescript-ask-sdk\";\nimport type {\n\tActiveUserAction,\n\tMessageDisplay,\n\tStreamingStep,\n\tUserNotification,\n} from \"@paymanai/payman-typescript-ask-sdk\";\nimport { PaymanChatContext } from \"../../contexts\";\nimport type { PaymanChatProps, PaymanChatRef } from \"../../types\";\n\nif (Platform.OS === \"android\" && UIManager.setLayoutAnimationEnabledExperimental) {\n\tUIManager.setLayoutAnimationEnabledExperimental(true);\n}\n\n// ─── Constants ────────────────────────────────────────────────────────────────\n\nconst DEFAULT_ACCENT = \"#00858d\";\nconst VOICE_DOT_COUNT = 24;\nconst VOICE_DOT_MIN_H = 5;\nconst VOICE_DOT_MAX_H = 14;\nconst SPEECH_ACTIVITY_MS = 1400;\nconst VOICE_BAR_BG = \"#f0f9f9\";\nconst AI_DISCLAIMER = \"AI can make mistakes. Please double-check responses.\";\n\n// ─── Voice waveform bar ───────────────────────────────────────────────────────\n\nconst VoiceWaveformBar = memo(function VoiceWaveformBar({\n\tindex,\n\tisActive,\n\taccent,\n}: {\n\tindex: number;\n\tisActive: boolean;\n\taccent: string;\n}) {\n\tconst height = useRef(new Animated.Value(VOICE_DOT_MIN_H)).current;\n\n\tuseEffect(() => {\n\t\tif (isActive) {\n\t\t\tconst anim = Animated.loop(\n\t\t\t\tAnimated.sequence([\n\t\t\t\t\tAnimated.timing(height, {\n\t\t\t\t\t\ttoValue: VOICE_DOT_MAX_H,\n\t\t\t\t\t\tduration: 180 + (index % 3) * 40,\n\t\t\t\t\t\tdelay: index * 25,\n\t\t\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t\t\tuseNativeDriver: false,\n\t\t\t\t\t}),\n\t\t\t\t\tAnimated.timing(height, {\n\t\t\t\t\t\ttoValue: VOICE_DOT_MIN_H,\n\t\t\t\t\t\tduration: 180 + (index % 3) * 40,\n\t\t\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t\t\tuseNativeDriver: false,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t\tanim.start();\n\t\t\treturn () => anim.stop();\n\t\t}\n\t\tAnimated.timing(height, { toValue: VOICE_DOT_MIN_H, duration: 200, useNativeDriver: false }).start();\n\t}, [isActive, index, height]);\n\n\treturn (\n\t\t<Animated.View\n\t\t\tstyle={[s.voiceDot, { height, backgroundColor: accent + \"99\" }]}\n\t\t/>\n\t);\n});\n\nfunction formatDuration(sec: number): string {\n\tconst m = Math.floor(sec / 60);\n\tconst s = sec % 60;\n\treturn `${m}:${s.toString().padStart(2, \"0\")}`;\n}\n\n// ─── Input bar ────────────────────────────────────────────────────────────────\n\ntype InputBarProps = {\n\tvalue: string;\n\tonChange: (v: string) => void;\n\tonSend: () => void;\n\tonCancel: () => void;\n\tdisabled: boolean;\n\tplaceholder: string;\n\tisStreaming: boolean;\n\taccent: string;\n\tenableVoice: boolean;\n\tvoiceAvailable: boolean;\n\tisRecording: boolean;\n\trecordingSeconds: number;\n\ttranscribedText: string;\n\tonVoicePress: () => void;\n\tonConfirmRecording: () => void;\n\tonCancelRecording: () => void;\n\tonFocus: () => void;\n\tinsetBottom: number;\n};\n\nfunction InputBar({\n\tvalue,\n\tonChange,\n\tonSend,\n\tonCancel,\n\tdisabled,\n\tplaceholder,\n\tisStreaming,\n\taccent,\n\tenableVoice,\n\tvoiceAvailable,\n\tisRecording,\n\trecordingSeconds,\n\ttranscribedText,\n\tonVoicePress,\n\tonConfirmRecording,\n\tonCancelRecording,\n\tonFocus,\n\tinsetBottom,\n}: InputBarProps) {\n\t// While a response is streaming the user can keep typing, but sending and\n\t// voice are disabled (no cancel) — the buttons appear greyed out.\n\tconst canSend = !disabled && !isStreaming && value.trim().length > 0;\n\tconst voiceDisabled = !voiceAvailable || disabled || isStreaming;\n\tconst showVoiceBar = enableVoice && isRecording;\n\tconst showVoiceBtn = enableVoice && !isRecording;\n\n\tconst [keyboardOpen, setKeyboardOpen] = useState(false);\n\tuseEffect(() => {\n\t\tconst show = Keyboard.addListener(\"keyboardWillShow\", () => setKeyboardOpen(true));\n\t\tconst hide = Keyboard.addListener(\"keyboardWillHide\", () => setKeyboardOpen(false));\n\t\treturn () => { show.remove(); hide.remove(); };\n\t}, []);\n\n\t// Detect speech activity for waveform animation\n\tconst [isSpeaking, setIsSpeaking] = useState(false);\n\tconst prevTranscript = useRef(\"\");\n\tconst speechTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tuseEffect(() => {\n\t\tif (!showVoiceBar) {\n\t\t\tsetIsSpeaking(false);\n\t\t\tprevTranscript.current = \"\";\n\t\t\tif (speechTimeout.current) clearTimeout(speechTimeout.current);\n\t\t\treturn;\n\t\t}\n\t\tconst changed = transcribedText !== prevTranscript.current;\n\t\tprevTranscript.current = transcribedText;\n\t\tif (changed) {\n\t\t\tsetIsSpeaking(true);\n\t\t\tif (speechTimeout.current) clearTimeout(speechTimeout.current);\n\t\t\tspeechTimeout.current = setTimeout(() => setIsSpeaking(false), SPEECH_ACTIVITY_MS);\n\t\t}\n\t\treturn () => { if (speechTimeout.current) clearTimeout(speechTimeout.current); };\n\t}, [showVoiceBar, transcribedText]);\n\n\t// Animate voice bar in/out\n\tconst animOpacity = useRef(new Animated.Value(1)).current;\n\tconst animScale = useRef(new Animated.Value(1)).current;\n\tuseEffect(() => {\n\t\tLayoutAnimation.configureNext(LayoutAnimation.create(200, \"easeInEaseOut\", \"opacity\"));\n\t\tif (showVoiceBar) {\n\t\t\tanimOpacity.setValue(0.92);\n\t\t\tanimScale.setValue(0.98);\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.timing(animOpacity, { toValue: 1, duration: 200, useNativeDriver: true }),\n\t\t\t\tAnimated.spring(animScale, { toValue: 1, useNativeDriver: true, speed: 12, bounciness: 4 }),\n\t\t\t]).start();\n\t\t} else {\n\t\t\tanimOpacity.setValue(1);\n\t\t\tanimScale.setValue(1);\n\t\t}\n\t}, [showVoiceBar, animOpacity, animScale]);\n\n\tconst accentLight = accent + \"33\";\n\tconst barBorderColor = accent + \"59\";\n\n\t// When the keyboard is up it covers the home indicator, so a small pad is\n\t// enough; otherwise clear the device's bottom safe-area inset.\n\tconst bottomPad = keyboardOpen ? 8 : Math.max(insetBottom, 10);\n\n\treturn (\n\t\t<View style={[s.outerBar, showVoiceBar && s.outerBarVoice, { paddingBottom: bottomPad }]}>\n\t\t\t<View style={s.column}>\n\t\t\t\t{/* TextInput + optional voice bar overlay */}\n\t\t\t\t<View style={[s.inputWrap, showVoiceBar && s.inputWrapRelative]}>\n\t\t\t\t\t<TextInput\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tonChangeText={onChange}\n\t\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\t\teditable={!disabled}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tplaceholderTextColor=\"#9CA3AF\"\n\t\t\t\t\t\tmultiline\n\t\t\t\t\t\tstyle={[s.input, disabled && s.inputDisabled, showVoiceBar && s.inputHidden]}\n\t\t\t\t\t\treturnKeyType=\"default\"\n\t\t\t\t\t\tblurOnSubmit={false}\n\t\t\t\t\t\tonSubmitEditing={onSend}\n\t\t\t\t\t/>\n\t\t\t\t\t{showVoiceBar && (\n\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\t\t\t\tstyle={[s.voiceBarContainer, { opacity: animOpacity, transform: [{ scale: animScale }] }]}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={[s.voiceBar, { backgroundColor: VOICE_BAR_BG, borderColor: barBorderColor }]}>\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onCancelRecording}\n\t\t\t\t\t\t\t\t\tstyle={({ pressed }) => [s.voiceBarCircle, { backgroundColor: accentLight }, pressed && s.pressed]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Cancel recording\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<X size={20} color={accent} strokeWidth={2.5} />\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t\t<View style={s.voiceBarCenter}>\n\t\t\t\t\t\t\t\t\t<View style={s.voiceDots}>\n\t\t\t\t\t\t\t\t\t\t{Array.from({ length: VOICE_DOT_COUNT }).map((_, i) => (\n\t\t\t\t\t\t\t\t\t\t\t<VoiceWaveformBar key={i} index={i} isActive={isSpeaking} accent={accent} />\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t<Text style={[s.voiceTimer, { color: accent }]}>\n\t\t\t\t\t\t\t\t\t\t{formatDuration(recordingSeconds)}\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onConfirmRecording}\n\t\t\t\t\t\t\t\t\tstyle={({ pressed }) => [s.voiceBarCircle, s.voiceConfirm, { borderColor: accent }, pressed && s.pressed]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Send recording\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Check size={22} color={accent} strokeWidth={2.5} />\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</Animated.View>\n\t\t\t\t\t)}\n\t\t\t\t</View>\n\n\t\t\t\t{/* Actions row: voice + send */}\n\t\t\t\t{!showVoiceBar && (\n\t\t\t\t\t<View style={s.actionsRow}>\n\t\t\t\t\t\t<View style={s.rightActions}>\n\t\t\t\t\t\t\t{showVoiceBtn && (\n\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\tonPress={onVoicePress}\n\t\t\t\t\t\t\t\t\tdisabled={voiceDisabled}\n\t\t\t\t\t\t\t\t\tstyle={[s.iconBtn, voiceDisabled && s.btnDisabled]}\n\t\t\t\t\t\t\t\t\taccessibilityLabel=\"Voice input\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<View style={s.iconBtnInner}>\n\t\t\t\t\t\t\t\t\t\t<Mic size={16} color=\"#6B7280\" strokeWidth={2} />\n\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\tonPress={onSend}\n\t\t\t\t\t\t\t\tdisabled={!canSend}\n\t\t\t\t\t\t\t\tstyle={[s.sendBtn, !canSend && s.btnDisabled]}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<View style={[s.sendBtnInner, { backgroundColor: accent }]}>\n\t\t\t\t\t\t\t\t\t<Send size={14} color=\"#FFFFFF\" />\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t)}\n\t\t\t</View>\n\n\t\t\t<View style={s.disclaimerWrap}>\n\t\t\t\t<Text style={s.disclaimerText}>{AI_DISCLAIMER}</Text>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n\n\n// ─── Typing effect (ported from web useTypingEffect, pure React) ─────────────\n\ntype SpeedProfile = {\n\tnormal: [number, number];\n\tfast: number;\n\tpunctuation: [number, number];\n\tnewline: [number, number];\n\tidle: number;\n};\n\nconst RESPONSE_SPEED: SpeedProfile = {\n\tnormal: [2, 4],\n\tfast: 1,\n\tpunctuation: [8, 12],\n\tnewline: [4, 6],\n\tidle: 15,\n};\n\nfunction charDelay(char: string, speed: SpeedProfile, multiplier: number): number {\n\tconst raw = (() => {\n\t\tif (char === \"*\") return speed.fast;\n\t\tif (char === \"\\n\") return speed.newline[0] + Math.random() * speed.newline[1];\n\t\tif (\".!?,;:\".includes(char)) return speed.punctuation[0] + Math.random() * speed.punctuation[1];\n\t\treturn speed.normal[0] + Math.random() * speed.normal[1];\n\t})();\n\treturn raw / multiplier;\n}\n\n// Characters revealed per tick. Chunking is the real speed lever — it cuts the\n// number of React re-renders (the bottleneck) rather than the per-char delay,\n// which is already clamped by the JS timer minimum.\nconst TYPE_CHUNK = 2;\n\n// If `remaining` (which must start at a line boundary) begins a structural\n// markdown block — a fenced code block or a table — return the length to reveal\n// instantly so we never \"type through\" pipes/backticks. Returns 0 when there's\n// no block, or when the block is still incomplete (so we wait instead of\n// flashing a half-built table while streaming).\nfunction blockJumpLength(remaining: string, isStreaming: boolean): number {\n\t// Fenced code block ```...```\n\tif (remaining.startsWith(\"```\")) {\n\t\tconst closeIdx = remaining.indexOf(\"\\n```\", 3);\n\t\tif (closeIdx === -1) return 0; // closing fence not here yet — wait\n\t\tconst afterFence = remaining.indexOf(\"\\n\", closeIdx + 1);\n\t\treturn afterFence === -1 ? remaining.length : afterFence + 1;\n\t}\n\n\t// Markdown table — consecutive lines beginning with optional spaces then '|'\n\tconst lines = remaining.split(\"\\n\");\n\tif (!/^\\s*\\|/.test(lines[0])) return 0;\n\tlet consumed = 0;\n\tlet tableLines = 0;\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tif (/^\\s*\\|/.test(lines[i])) {\n\t\t\ttableLines++;\n\t\t\tconsumed += lines[i].length + 1; // include the trailing newline\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (tableLines < 2) return 0; // need at least header + separator\n\t// Table runs to the end of what's arrived and we're still streaming → it may\n\t// still be growing; wait for more (or stream end) before revealing it.\n\tif (consumed >= remaining.length && isStreaming) return 0;\n\treturn Math.min(consumed, remaining.length);\n}\n\nfunction useTypingEffect(\n\ttargetText: string,\n\tenabled: boolean,\n\tisStreaming: boolean,\n\tspeedMultiplier: number = 6,\n): { displayedText: string; isTyping: boolean } {\n\tconst instant = speedMultiplier === 0;\n\tconst multiplier = instant ? 1 : Math.max(speedMultiplier, 0.1);\n\n\tconst [displayedText, setDisplayedText] = useState(\"\");\n\tconst displayedRef = useRef(\"\");\n\tconst targetRef = useRef(targetText);\n\tconst enabledRef = useRef(enabled);\n\tconst streamingRef = useRef(isStreaming);\n\tconst timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst runningRef = useRef(false);\n\n\ttargetRef.current = targetText;\n\tenabledRef.current = enabled;\n\tstreamingRef.current = isStreaming;\n\n\tuseEffect(() => {\n\t\tif (!enabled || instant) {\n\t\t\tif (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n\t\t\trunningRef.current = false;\n\t\t\tdisplayedRef.current = targetText;\n\t\t\tsetDisplayedText(targetText);\n\t\t\treturn;\n\t\t}\n\n\t\t// Flush instantly if target changed incompatibly (displayed no longer a prefix)\n\t\tif (displayedRef.current && !targetRef.current.startsWith(displayedRef.current)) {\n\t\t\tdisplayedRef.current = targetRef.current;\n\t\t\tsetDisplayedText(targetRef.current);\n\t\t}\n\n\t\tif (runningRef.current) return;\n\t\trunningRef.current = true;\n\n\t\tconst tick = () => {\n\t\t\tif (!enabledRef.current) { runningRef.current = false; return; }\n\n\t\t\tif (displayedRef.current && !targetRef.current.startsWith(displayedRef.current)) {\n\t\t\t\tdisplayedRef.current = targetRef.current;\n\t\t\t\tsetDisplayedText(targetRef.current);\n\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (displayedRef.current.length < targetRef.current.length) {\n\t\t\t\tconst remaining = targetRef.current.slice(displayedRef.current.length);\n\t\t\t\tconst atLineStart =\n\t\t\t\t\tdisplayedRef.current.length === 0 ||\n\t\t\t\t\ttargetRef.current[displayedRef.current.length - 1] === \"\\n\";\n\n\t\t\t\tif (atLineStart) {\n\t\t\t\t\t// Reveal complete tables / code blocks in one shot.\n\t\t\t\t\tconst jump = blockJumpLength(remaining, streamingRef.current);\n\t\t\t\t\tif (jump > 0) {\n\t\t\t\t\t\tdisplayedRef.current += remaining.slice(0, jump);\n\t\t\t\t\t\tsetDisplayedText(displayedRef.current);\n\t\t\t\t\t\ttimerRef.current = setTimeout(tick, 0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// A structural block is starting but isn't complete yet — don't\n\t\t\t\t\t// type its half-built pipes/backticks; wait for the rest.\n\t\t\t\t\tif (streamingRef.current && /^(```|\\s*\\|)/.test(remaining)) {\n\t\t\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Reveal a chunk, but never cross a newline so the next line is\n\t\t\t\t// re-evaluated for a structural jump at its start.\n\t\t\t\tlet chunk = remaining.slice(0, TYPE_CHUNK);\n\t\t\t\tconst nl = chunk.indexOf(\"\\n\");\n\t\t\t\tif (nl !== -1) chunk = chunk.slice(0, nl + 1);\n\t\t\t\tdisplayedRef.current += chunk;\n\t\t\t\tsetDisplayedText(displayedRef.current);\n\t\t\t\tconst lastChar = chunk[chunk.length - 1];\n\t\t\t\ttimerRef.current = setTimeout(tick, charDelay(lastChar, RESPONSE_SPEED, multiplier));\n\t\t\t} else {\n\t\t\t\ttimerRef.current = setTimeout(tick, RESPONSE_SPEED.idle / multiplier);\n\t\t\t}\n\t\t};\n\n\t\ttick();\n\n\t\treturn () => {\n\t\t\tif (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n\t\t\trunningRef.current = false;\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [enabled, instant]);\n\n\tconst isTyping = enabled && !instant && displayedRef.current.length < targetRef.current.length;\n\treturn { displayedText: enabled || instant ? displayedText : targetText, isTyping };\n}\n\n// ─── Thinking block (exact port of web ThinkingBlockV2) ──────────────────────\n//\n// Two-line live-progress model computed from `message.steps`:\n// • stickyLabel — the Analyzer's plan narrative; fades in, then stays\n// • currentStepLabel — the live tactical label; shimmers + flips as steps land\n//\n// The shimmer is the web's `payman-v2-thinking-shimmer`: a bright band sweeping\n// horizontally across the text (dim → bright → dim). Web does it with a\n// background-clip:text gradient; RN has no equivalent, so we animate each\n// character's color from a single shared progress value with a moving peak —\n// nested <Text> keeps native word-wrapping intact.\n\nconst PENDING_LABEL = \"Thinking\";\n\n// 2.8s sweep, matching the web's `payman-v2-thinking-shimmer` animation.\nconst SHIMMER_DURATION = 2800;\n// Half-width of the bright band, in normalized [0,1] text-position units.\nconst SHIMMER_BAND = 0.55;\n\n// Shimmer stops per theme (matches web text-4 → text-1).\nconst SHIMMER_LIGHT = { dim: \"#b4b4b4\", bright: \"#1f2937\" };\nconst SHIMMER_DARK = { dim: \"#5b6b6e\", bright: \"#eaf2f3\" };\n\n// One character with an animated color. As the shared `progress` (0→1) sweeps,\n// a bright \"peak\" travels across the label; each char lights up as the peak\n// passes its normalized position — reproducing the web's background-clip:text\n// gradient sweep, with native word-wrapping preserved via nested <Text>.\nfunction ShimmerChar({\n\tch,\n\tpos,\n\tprogress,\n\tdim,\n\tbright,\n}: {\n\tch: string;\n\tpos: number;\n\tprogress: Animated.Value;\n\tdim: string;\n\tbright: string;\n}) {\n\t// progress where the peak coincides with this char: -0.4 + p*1.8 = pos\n\tconst center = (pos + 0.4) / 1.8;\n\tconst half = SHIMMER_BAND / 1.8;\n\tconst color = progress.interpolate({\n\t\tinputRange: [center - half, center, center + half],\n\t\toutputRange: [dim, bright, dim],\n\t\textrapolate: \"clamp\",\n\t});\n\treturn <Animated.Text style={[ts.cursorLabel, { color }]}>{ch}</Animated.Text>;\n}\n\nfunction ShimmerText({ text, isDark }: { text: string; isDark: boolean }) {\n\tconst progress = useRef(new Animated.Value(0)).current;\n\tconst { dim, bright } = isDark ? SHIMMER_DARK : SHIMMER_LIGHT;\n\tuseEffect(() => {\n\t\tconst loop = Animated.loop(\n\t\t\tAnimated.timing(progress, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: SHIMMER_DURATION,\n\t\t\t\teasing: Easing.inOut(Easing.ease),\n\t\t\t\t// color interpolation isn't supported by the native driver\n\t\t\t\tuseNativeDriver: false,\n\t\t\t}),\n\t\t);\n\t\tloop.start();\n\t\treturn () => loop.stop();\n\t}, [progress]);\n\n\tconst chars = Array.from(text);\n\tconst n = Math.max(chars.length - 1, 1);\n\treturn (\n\t\t<Text style={[ts.cursorLabel, { color: dim }]}>\n\t\t\t{chars.map((ch, i) => (\n\t\t\t\t<ShimmerChar key={i} ch={ch} pos={i / n} progress={progress} dim={dim} bright={bright} />\n\t\t\t))}\n\t\t</Text>\n\t);\n}\n\n// Current-step label that re-animates (slide up + fade in) whenever the text\n// changes — the web's \"digital-clock flip\" between stages.\nfunction FlipLabel({ label, isDark }: { label: string; isDark: boolean }) {\n\tconst opacity = useRef(new Animated.Value(0)).current;\n\tconst translateY = useRef(new Animated.Value(6)).current;\n\tuseEffect(() => {\n\t\topacity.setValue(0);\n\t\ttranslateY.setValue(6);\n\t\tAnimated.parallel([\n\t\t\tAnimated.timing(opacity, { toValue: 1, duration: 300, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t\tAnimated.timing(translateY, { toValue: 0, duration: 320, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t]).start();\n\t}, [label, opacity, translateY]);\n\treturn (\n\t\t<Animated.View style={{ opacity, transform: [{ translateY }] }}>\n\t\t\t<ShimmerText text={label} isDark={isDark} />\n\t\t</Animated.View>\n\t);\n}\n\n// Sticky plan narrative — fades in once when it arrives, then stays put.\nfunction StickyLabel({ label, isDark }: { label: string; isDark: boolean }) {\n\tconst opacity = useRef(new Animated.Value(0)).current;\n\tconst translateY = useRef(new Animated.Value(4)).current;\n\tuseEffect(() => {\n\t\tAnimated.parallel([\n\t\t\tAnimated.timing(opacity, { toValue: 1, duration: 400, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t\tAnimated.timing(translateY, { toValue: 0, duration: 400, easing: Easing.out(Easing.ease), useNativeDriver: true }),\n\t\t]).start();\n\t}, [opacity, translateY]);\n\treturn (\n\t\t<Animated.Text\n\t\t\tstyle={[\n\t\t\t\tts.stickyLabel,\n\t\t\t\t{ color: isDark ? \"rgba(255,255,255,0.62)\" : \"#4b5563\", opacity, transform: [{ translateY }] },\n\t\t\t]}\n\t\t>\n\t\t\t{label}\n\t\t</Animated.Text>\n\t);\n}\n\nfunction ThinkingBlock({\n\tstickyLabel,\n\tcurrentStepLabel,\n\tisDark,\n}: {\n\tstickyLabel?: string;\n\tcurrentStepLabel?: string;\n\tisDark: boolean;\n}) {\n\tconst label = currentStepLabel || PENDING_LABEL;\n\treturn (\n\t\t<View style={ts.container}>\n\t\t\t{stickyLabel ? <StickyLabel key={stickyLabel} label={stickyLabel} isDark={isDark} /> : null}\n\t\t\t<View style={ts.cursorRow}>\n\t\t\t\t{/* key forces remount on label change → re-runs the flip animation */}\n\t\t\t\t<FlipLabel key={label} label={label} isDark={isDark} />\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Derive the sticky plan-narrative label from the steps array (web parity).\nfunction deriveStickyLabel(steps?: StreamingStep[]): string | undefined {\n\tif (!steps || steps.length === 0) return undefined;\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (\n\t\t\ts.eventType === \"STAGE_STARTED\" &&\n\t\t\ts.stage === \"analyzer\" &&\n\t\t\ts.status === \"completed\" &&\n\t\t\ts.message\n\t\t) {\n\t\t\treturn s.message;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n// Derive the live current-step label from the steps array (web parity).\nfunction deriveCurrentStepLabel(\n\tsteps: StreamingStep[] | undefined,\n\tstickyLabel: string | undefined,\n): string | undefined {\n\tif (!steps || steps.length === 0) return undefined;\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (s.status === \"in_progress\" && s.message) {\n\t\t\tif (s.stage === \"analyzer\" && s.message === stickyLabel) continue;\n\t\t\tif (s.message === stickyLabel) continue;\n\t\t\treturn s.message;\n\t\t}\n\t}\n\tfor (let i = steps.length - 1; i >= 0; i--) {\n\t\tconst s = steps[i];\n\t\tif (s.message && s.message !== stickyLabel) return s.message;\n\t}\n\treturn undefined;\n}\n\nconst ts = StyleSheet.create({\n\tcontainer: { paddingVertical: 2 },\n\tstickyLabel: {\n\t\tfontSize: 14,\n\t\tlineHeight: 21,\n\t\tcolor: \"#4b5563\",\n\t\tmarginBottom: 6,\n\t},\n\tcursorRow: { overflow: \"hidden\" },\n\tcursorLabel: {\n\t\tfontSize: 14,\n\t\tlineHeight: 21,\n\t\tfontWeight: \"500\",\n\t},\n});\n\n// ─── User bubble ──────────────────────────────────────────────────────────────\n\nfunction UserBubble({ message, accent }: { message: MessageDisplay; accent: string }) {\n\tconst text = message.content ?? \"\";\n\tif (!text) return null;\n\treturn (\n\t\t<View style={[sd.bubbleRow, sd.rowUser]}>\n\t\t\t<View style={[sd.bubble, sd.bubbleUser, { backgroundColor: accent }]}>\n\t\t\t\t<Text style={[sd.bubbleText, sd.textUser]}>{text}</Text>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// ─── Assistant bubble ─────────────────────────────────────────────────────────\n\n// Strips a trailing incomplete markdown image token from streaming content so\n// the markdown renderer doesn't flash the raw URL as plain text (web parity).\nfunction stripIncompleteImageToken(text: string): string {\n\tconst lastBang = text.lastIndexOf(\"![\");\n\tif (lastBang === -1) return text;\n\tconst after = text.slice(lastBang);\n\tif (/^!\\[[^\\]]*\\]\\([^)]*\\)/.test(after)) return text;\n\treturn text.slice(0, lastBang);\n}\n\n// Removes a user-action prompt's body from the assistant message text so the\n// summary/options aren't rendered twice (once in the bubble, once in the sheet).\n// Matches on the normalized prompt text; tolerant of a trailing partial match\n// while the prompt body is still streaming in.\nfunction stripDuplicatePromptText(text: string, promptText?: string): string {\n\tif (!promptText) return text;\n\tconst pm = promptText.replace(/\\\\n/g, \"\\n\").trim();\n\tif (!pm) return text;\n\tconst idx = text.indexOf(pm);\n\tif (idx !== -1) {\n\t\treturn (text.slice(0, idx) + text.slice(idx + pm.length)).trim();\n\t}\n\t// Streaming: the bubble may hold only a prefix of the prompt body so far.\n\t// Drop from the point where the (still-growing) duplicate begins.\n\tfor (let cut = Math.min(text.length, pm.length); cut >= 24; cut--) {\n\t\tif (text.endsWith(pm.slice(0, cut))) {\n\t\t\treturn text.slice(0, text.length - cut).trim();\n\t\t}\n\t}\n\treturn text;\n}\n\nfunction AssistantBubble({\n\tmessage,\n\tshouldType,\n\tisDark,\n\taccent,\n\tsuppressText,\n}: {\n\tmessage: MessageDisplay;\n\tshouldType: boolean;\n\tisDark: boolean;\n\taccent: string;\n\t// When the same execution raised a user-action prompt, the agent's textual\n\t// answer often duplicates the prompt body (the confirmation summary). We\n\t// strip that duplicate here so it lives only in the action sheet.\n\tsuppressText?: string;\n}) {\n\tconst isCurrentlyStreaming = !!message.isStreaming && !message.isCancelled;\n\tconst mdStyles = isDark ? MD_STYLES_DARK : MD_STYLES_LIGHT;\n\tconst mdRules = useMemo(() => makeMdRules(isDark, accent), [isDark, accent]);\n\tconst bubbleBg = isDark ? \"rgba(255,255,255,0.07)\" : \"#f3f4f6\";\n\tconst errorBg = isDark ? \"rgba(220,38,38,0.14)\" : \"#fef2f2\";\n\n\t// Web's `rawResponseContent`: while streaming prefer the live streamingContent\n\t// (SDK mirrors token deltas into it), else the final content. Normalize \\n and\n\t// strip any trailing incomplete image token while streaming.\n\tconst rawResponseContent = (() => {\n\t\tconst raw = message.isStreaming\n\t\t\t? message.streamingContent || message.content\n\t\t\t: message.content;\n\t\tif (!raw) return \"\";\n\t\tconst normalized = raw.replace(/\\\\n/g, \"\\n\");\n\t\tconst cleaned = message.isStreaming ? stripIncompleteImageToken(normalized) : normalized;\n\t\treturn stripDuplicatePromptText(cleaned, suppressText);\n\t})();\n\n\t// Web's `isThinkingStreaming`: streaming, no response text yet, no error.\n\tconst isThinkingStreaming =\n\t\tisCurrentlyStreaming && !rawResponseContent && !message.isError;\n\n\t// Typing reveal — runs while streaming text lands AND on the just-completed\n\t// message, mirroring web (`responseTypingEnabled`). History renders instantly.\n\tconst hasEverStreamed = useRef(!!message.isStreaming);\n\tif (message.isStreaming) hasEverStreamed.current = true;\n\tconst typingEnabled =\n\t\tshouldType && hasEverStreamed.current && Boolean(rawResponseContent) && !message.isError;\n\tconst { displayedText, isTyping } = useTypingEffect(\n\t\trawResponseContent,\n\t\ttypingEnabled,\n\t\tisCurrentlyStreaming,\n\t\t3,\n\t);\n\n\t// Sticky + current-step labels from the steps array (web parity).\n\tconst stickyLabel = deriveStickyLabel(message.steps);\n\tconst currentStepLabel = deriveCurrentStepLabel(message.steps, stickyLabel);\n\n\t// Error with no content\n\tif (message.isError && !rawResponseContent && !displayedText) {\n\t\tconst detail = message.errorDetails || \"Something went wrong. Please try again.\";\n\t\treturn (\n\t\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, { backgroundColor: errorBg }]}>\n\t\t\t\t\t<Text style={sd.errorText}>{detail}</Text>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Thinking phase — shimmering sticky + current step label.\n\tif (isThinkingStreaming) {\n\t\treturn (\n\t\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, { backgroundColor: bubbleBg }]}>\n\t\t\t\t\t<ThinkingBlock stickyLabel={stickyLabel} currentStepLabel={currentStepLabel} isDark={isDark} />\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Content present (streaming or done) — typed reveal + blinking cursor.\n\tconst showCursor = (isCurrentlyStreaming || isTyping) && !message.isCancelled;\n\tconst markdownContent = showCursor ? displayedText + \"▋\" : displayedText;\n\n\tif (!markdownContent) return null;\n\n\treturn (\n\t\t<View style={[sd.bubbleRow, sd.rowAssistant]}>\n\t\t\t<View style={[sd.bubble, sd.bubbleAssistant, sd.bubbleAssistantWide, { backgroundColor: bubbleBg }]}>\n\t\t\t\t<Markdown style={mdStyles} rules={mdRules}>\n\t\t\t\t\t{markdownContent}\n\t\t\t\t</Markdown>\n\t\t\t\t{message.isCancelled && (\n\t\t\t\t\t<Text style={sd.cancelledText}>Response stopped</Text>\n\t\t\t\t)}\n\t\t\t\t{message.isError && displayedText && (\n\t\t\t\t\t<Text style={sd.partialErrorText}>\n\t\t\t\t\t\t{message.errorDetails || \"The response was interrupted.\"}\n\t\t\t\t\t</Text>\n\t\t\t\t)}\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// ─── Message bubble router ─────────────────────────────────────────────────────\n\nfunction MessageBubble({ message, accent, shouldType, isDark, suppressText }: { message: MessageDisplay; accent: string; shouldType: boolean; isDark: boolean; suppressText?: string }) {\n\tif (message.role === \"user\") return <UserBubble message={message} accent={accent} />;\n\treturn <AssistantBubble message={message} shouldType={shouldType} isDark={isDark} accent={accent} suppressText={suppressText} />;\n}\n\n// ─── User action blocks (full-screen animated sheet) ─────────────────────────\n//\n// When the agent raises a USER_ACTION_REQUIRED prompt mid-run, we present it as\n// an animated bottom sheet over the chat: the user fills the question(s), taps\n// the primary button, the sheet animates away and the run continues. Verification\n// prompts auto-submit a complete numeric code. Expiry + resend timers are honored.\n\nconst RESEND_COOLDOWN_S = 30;\nconst DEFAULT_CODE_LEN = 6;\n\ntype UAPalette = {\n\tsheetBg: string;\n\ttext: string;\n\tmuted: string;\n\tborder: string;\n\tfieldBg: string;\n\tfieldBorder: string;\n\toverlay: string;\n\tgrabber: string;\n};\n\nfunction uaPalette(isDark: boolean): UAPalette {\n\treturn isDark\n\t\t? {\n\t\t\t\tsheetBg: \"#13201f\",\n\t\t\t\ttext: \"rgba(255,255,255,0.95)\",\n\t\t\t\tmuted: \"rgba(255,255,255,0.55)\",\n\t\t\t\tborder: \"rgba(255,255,255,0.10)\",\n\t\t\t\tfieldBg: \"rgba(255,255,255,0.06)\",\n\t\t\t\tfieldBorder: \"rgba(255,255,255,0.18)\",\n\t\t\t\toverlay: \"rgba(0,0,0,0.62)\",\n\t\t\t\tgrabber: \"rgba(255,255,255,0.22)\",\n\t\t }\n\t\t: {\n\t\t\t\tsheetBg: \"#ffffff\",\n\t\t\t\ttext: \"#111827\",\n\t\t\t\tmuted: \"#6b7280\",\n\t\t\t\tborder: \"#eceef1\",\n\t\t\t\tfieldBg: \"#f9fafb\",\n\t\t\t\tfieldBorder: \"#d1d5db\",\n\t\t\t\toverlay: \"rgba(15,23,42,0.45)\",\n\t\t\t\tgrabber: \"rgba(15,23,42,0.18)\",\n\t\t };\n}\n\nfunction promptInitialSeconds(prompt?: ActiveUserAction): number | undefined {\n\treturn prompt && typeof prompt.expirySeconds === \"number\" && prompt.expirySeconds > 0\n\t\t? Math.floor(prompt.expirySeconds)\n\t\t: undefined;\n}\n\n// Key that changes when a fresh / superseded prompt arrives (restarts timers).\nfunction promptTimerKey(prompt?: ActiveUserAction): string {\n\treturn prompt ? `${prompt.userActionId}|${prompt.subAction ?? \"\"}` : \"\";\n}\n\n// Expiry as a single boolean, driven by ONE setTimeout at the deadline. Unlike a\n// per-second interval at the chat level, this re-renders the host only once (on\n// expiry) instead of every second — which is what kept the whole chat tree from\n// repainting each tick.\nfunction useExpiredFlag(prompt?: ActiveUserAction): boolean {\n\tconst initial = promptInitialSeconds(prompt);\n\tconst key = promptTimerKey(prompt);\n\tconst [expired, setExpired] = useState(false);\n\tuseEffect(() => {\n\t\tsetExpired(false);\n\t\tif (initial === undefined) return;\n\t\tconst t = setTimeout(() => setExpired(true), initial * 1000);\n\t\treturn () => clearTimeout(t);\n\t}, [key, initial]);\n\treturn expired;\n}\n\n// Self-contained per-second tick used only by the small timer pills, so the\n// countdown display updates without re-rendering the chat or the form.\nfunction useSecondsLeft(expirySeconds?: number, restartKey?: string): number | undefined {\n\tconst initial =\n\t\ttypeof expirySeconds === \"number\" && expirySeconds > 0 ? Math.floor(expirySeconds) : undefined;\n\tconst [left, setLeft] = useState<number | undefined>(initial);\n\tuseEffect(() => {\n\t\tsetLeft(initial);\n\t\tif (initial === undefined) return;\n\t\tconst id = setInterval(() => {\n\t\t\tsetLeft((s) => (s === undefined ? s : s <= 1 ? 0 : s - 1));\n\t\t}, 1000);\n\t\treturn () => clearInterval(id);\n\t}, [restartKey, initial]);\n\treturn left;\n}\n\n// Timer pill for the sheet header (ticks internally).\nfunction SheetTimerPill({\n\tprompt,\n\taccent,\n\tisDark,\n}: {\n\tprompt: ActiveUserAction;\n\taccent: string;\n\tisDark: boolean;\n}) {\n\tconst left = useSecondsLeft(prompt.expirySeconds, promptTimerKey(prompt));\n\tif (left === undefined || prompt.status === \"stale\") return null;\n\tconst expired = left <= 0;\n\treturn (\n\t\t<View\n\t\t\tstyle={[\n\t\t\t\tsht.timer,\n\t\t\t\t{\n\t\t\t\t\tborderColor: expired ? \"#ef4444\" : accent + \"40\",\n\t\t\t\t\tbackgroundColor: expired ? \"rgba(239,68,68,0.10)\" : accent + (isDark ? \"1F\" : \"12\"),\n\t\t\t\t},\n\t\t\t]}\n\t\t>\n\t\t\t<Text style={{ color: expired ? \"#ef4444\" : accent, fontSize: 12.5, fontWeight: \"700\", letterSpacing: 0.2 }}>\n\t\t\t\t{expired ? \"Expired\" : `${left}s`}\n\t\t\t</Text>\n\t\t</View>\n\t);\n}\n\n// Timer pill for the inline resume card (ticks internally).\nfunction CardTimerPill({\n\tprompt,\n\taccent,\n\tisDark,\n}: {\n\tprompt: ActiveUserAction;\n\taccent: string;\n\tisDark: boolean;\n}) {\n\tconst left = useSecondsLeft(prompt.expirySeconds, promptTimerKey(prompt));\n\tif (left === undefined || left <= 0) return null;\n\treturn (\n\t\t<View style={[rc.timer, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t<Text style={{ color: accent, fontSize: 12, fontWeight: \"700\" }}>{left}s</Text>\n\t\t</View>\n\t);\n}\n\n// Segmented OTP boxes backed by a single hidden numeric input.\nfunction CodeInput({\n\tvalue,\n\tonChange,\n\tlength,\n\tdisabled,\n\terror,\n\taccent,\n\tpal,\n}: {\n\tvalue: string;\n\tonChange: (v: string) => void;\n\tlength: number;\n\tdisabled: boolean;\n\terror: boolean;\n\taccent: string;\n\tpal: UAPalette;\n}) {\n\tconst ref = useRef<TextInput>(null);\n\tuseEffect(() => {\n\t\tconst t = setTimeout(() => ref.current?.focus(), 380);\n\t\treturn () => clearTimeout(t);\n\t}, []);\n\treturn (\n\t\t<Pressable onPress={() => ref.current?.focus()} style={ub.codeRow}>\n\t\t\t{Array.from({ length }).map((_, i) => {\n\t\t\t\tconst ch = value[i] ?? \"\";\n\t\t\t\tconst isCursor = i === value.length && !disabled;\n\t\t\t\tconst bc = error ? \"#ef4444\" : isCursor ? accent : pal.fieldBorder;\n\t\t\t\treturn (\n\t\t\t\t\t<View key={i} style={[ub.codeBox, { borderColor: bc, backgroundColor: pal.fieldBg }]}>\n\t\t\t\t\t\t<Text style={[ub.codeChar, { color: pal.text }]}>{ch}</Text>\n\t\t\t\t\t</View>\n\t\t\t\t);\n\t\t\t})}\n\t\t\t<TextInput\n\t\t\t\tref={ref}\n\t\t\t\tvalue={value}\n\t\t\t\tonChangeText={(t) => onChange(t.replace(/[^0-9]/g, \"\").slice(0, length))}\n\t\t\t\tkeyboardType=\"number-pad\"\n\t\t\t\tmaxLength={length}\n\t\t\t\teditable={!disabled}\n\t\t\t\tcaretHidden\n\t\t\t\tstyle={ub.codeHidden}\n\t\t\t/>\n\t\t</Pressable>\n\t);\n}\n\nfunction PrimaryButton({\n\tlabel,\n\tonPress,\n\tdisabled,\n\taccent,\n}: {\n\tlabel: string;\n\tonPress: () => void;\n\tdisabled?: boolean;\n\taccent: string;\n}) {\n\tconst bg = accent || DEFAULT_ACCENT;\n\treturn (\n\t\t<Pressable\n\t\t\tonPress={onPress}\n\t\t\tdisabled={disabled}\n\t\t\tandroid_ripple={{ color: \"rgba(255,255,255,0.22)\" }}\n\t\t\tstyle={[ub.primaryBtn, { backgroundColor: bg, borderColor: bg, opacity: disabled ? 0.5 : 1 }]}\n\t\t>\n\t\t\t<Text style={ub.primaryBtnText}>{label}</Text>\n\t\t</Pressable>\n\t);\n}\n\n// Verification (one-time-code) body.\nfunction VerificationBody({\n\tprompt,\n\texpired,\n\tpal,\n\taccent,\n\tonSubmit,\n\tonCancel,\n\tonResend,\n}: {\n\tprompt: ActiveUserAction;\n\texpired: boolean;\n\tpal: UAPalette;\n\taccent: string;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n\tonResend: (id: string) => Promise<void>;\n}) {\n\tconst isNumeric = prompt.verificationType !== \"ALPHANUMERIC_CODE\";\n\tconst field = prompt.requestedSchema?.properties?.verificationCode;\n\tconst codeLen =\n\t\t(typeof field?.maxLength === \"number\" ? field.maxLength : undefined) ??\n\t\t(typeof field?.minLength === \"number\" ? field.minLength : undefined) ??\n\t\tDEFAULT_CODE_LEN;\n\n\tconst [code, setCode] = useState(\"\");\n\tconst [errored, setErrored] = useState(false);\n\tconst [resendSec, setResendSec] = useState(0);\n\tconst lastSubmitted = useRef<string | null>(null);\n\tconst resendTimer = useRef<ReturnType<typeof setInterval> | null>(null);\n\n\tconst busy = prompt.status === \"submitting\";\n\tconst stale = prompt.status === \"stale\";\n\tconst locked = busy || stale || expired;\n\n\tuseEffect(() => {\n\t\tif (prompt.subAction === \"SubmissionInvalid\") {\n\t\t\tsetErrored(true);\n\t\t\tsetCode(\"\");\n\t\t\tlastSubmitted.current = null;\n\t\t}\n\t}, [prompt.subAction, prompt.userActionId]);\n\n\tconst doSubmit = useCallback(\n\t\t(value: string) => {\n\t\t\tif (locked || !value) return;\n\t\t\tif (lastSubmitted.current === value) return;\n\t\t\tlastSubmitted.current = value;\n\t\t\tvoid onSubmit(prompt.userActionId, { verificationCode: value }).catch(() => {\n\t\t\t\tlastSubmitted.current = null;\n\t\t\t\tsetErrored(true);\n\t\t\t});\n\t\t},\n\t\t[locked, onSubmit, prompt.userActionId],\n\t);\n\n\t// Auto-submit a full numeric code.\n\tuseEffect(() => {\n\t\tif (!isNumeric || locked) return;\n\t\tif (code.length === codeLen && /^\\d+$/.test(code)) doSubmit(code);\n\t}, [code, codeLen, doSubmit, isNumeric, locked]);\n\n\tuseEffect(() => () => { if (resendTimer.current) clearInterval(resendTimer.current); }, []);\n\n\tconst handleResend = useCallback(async () => {\n\t\tif (locked || resendSec > 0) return;\n\t\tsetErrored(false);\n\t\tsetCode(\"\");\n\t\tlastSubmitted.current = null;\n\t\ttry {\n\t\t\tawait onResend(prompt.userActionId);\n\t\t\tsetResendSec(RESEND_COOLDOWN_S);\n\t\t\tif (resendTimer.current) clearInterval(resendTimer.current);\n\t\t\tresendTimer.current = setInterval(() => {\n\t\t\t\tsetResendSec((s) => {\n\t\t\t\t\tif (s <= 1) {\n\t\t\t\t\t\tif (resendTimer.current) clearInterval(resendTimer.current);\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn s - 1;\n\t\t\t\t});\n\t\t\t}, 1000);\n\t\t} catch {\n\t\t\t/* hook surfaces the error */\n\t\t}\n\t}, [locked, onResend, prompt.userActionId, resendSec]);\n\n\tconst description =\n\t\tprompt.message?.trim() ||\n\t\t(isNumeric ? `Enter the ${codeLen}-digit code to continue` : \"Enter the verification code to continue\");\n\n\treturn (\n\t\t<View style={ub.bodyWrap}>\n\t\t\t<ScrollView\n\t\t\t\tstyle={ub.fieldsScroll}\n\t\t\t\tcontentContainerStyle={ub.fieldsContent}\n\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\tshowsVerticalScrollIndicator={false}\n\t\t\t>\n\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>{description}</Text>\n\n\t\t\t{isNumeric ? (\n\t\t\t\t<CodeInput\n\t\t\t\t\tvalue={code}\n\t\t\t\t\tonChange={(v) => { setErrored(false); setCode(v); }}\n\t\t\t\t\tlength={codeLen}\n\t\t\t\t\tdisabled={locked}\n\t\t\t\t\terror={errored}\n\t\t\t\t\taccent={accent}\n\t\t\t\t\tpal={pal}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<TextInput\n\t\t\t\t\tvalue={code}\n\t\t\t\t\tonChangeText={(t) => { setErrored(false); setCode(t); }}\n\t\t\t\t\teditable={!locked}\n\t\t\t\t\tplaceholder=\"Verification code\"\n\t\t\t\t\tplaceholderTextColor={pal.muted}\n\t\t\t\t\tautoComplete=\"one-time-code\"\n\t\t\t\t\tstyle={[\n\t\t\t\t\t\tub.input,\n\t\t\t\t\t\t{ color: pal.text, backgroundColor: pal.fieldBg, borderColor: errored ? \"#ef4444\" : pal.fieldBorder },\n\t\t\t\t\t]}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t</ScrollView>\n\n\t\t\t<View style={ub.actions}>\n\t\t\t\t{!isNumeric && (\n\t\t\t\t\t<PrimaryButton\n\t\t\t\t\t\tlabel={busy ? \"Verifying…\" : \"Verify\"}\n\t\t\t\t\t\tonPress={() => doSubmit(code.trim())}\n\t\t\t\t\t\tdisabled={locked || !code.trim()}\n\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<View style={ub.linkRow}>\n\t\t\t\t\t<Pressable disabled={locked || resendSec > 0} onPress={() => void handleResend()}>\n\t\t\t\t\t\t<Text style={[ub.link, { color: accent, opacity: locked || resendSec > 0 ? 0.4 : 1 }]}>\n\t\t\t\t\t\t\t{resendSec > 0 ? `Resend (${resendSec}s)` : \"Resend\"}\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t\t<Pressable disabled={busy} onPress={() => void onCancel(prompt.userActionId)}>\n\t\t\t\t\t\t<Text style={[ub.link, ub.linkDanger, { opacity: busy ? 0.4 : 1 }]}>Cancel</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Schema-driven form body.\nfunction FormBody({\n\tprompt,\n\tpal,\n\taccent,\n\tisDark,\n\tonSubmit,\n\tonCancel,\n}: {\n\tprompt: ActiveUserAction;\n\tpal: UAPalette;\n\taccent: string;\n\tisDark: boolean;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n}) {\n\tconst schema = prompt.requestedSchema;\n\tconst fields = useMemo(() => renderableFields(schema), [schema]);\n\tconst [values, setValues] = useState<Record<string, unknown>>(() => {\n\t\tconst init: Record<string, unknown> = {};\n\t\tfor (const [key, field] of fields) init[key] = defaultValueFor(field);\n\t\treturn init;\n\t});\n\tconst [errors, setErrors] = useState<Record<string, string>>({});\n\n\tconst busy = prompt.status === \"submitting\";\n\tconst stale = prompt.status === \"stale\";\n\tconst locked = busy || stale;\n\tconst isConfirm = prompt.subAction === \"UserConfirmation\";\n\n\tconst setValue = (key: string, v: unknown) => {\n\t\tsetValues((prev) => ({ ...prev, [key]: v }));\n\t\tsetErrors((prev) => {\n\t\t\tif (!prev[key]) return prev;\n\t\t\tconst next = { ...prev };\n\t\t\tdelete next[key];\n\t\t\treturn next;\n\t\t});\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (locked) return;\n\t\tconst validation = validateForm(schema, values);\n\t\tif (Object.keys(validation).length > 0) {\n\t\t\tsetErrors(validation);\n\t\t\treturn;\n\t\t}\n\t\tvoid onSubmit(prompt.userActionId, buildContent(schema, values)).catch(() => {});\n\t};\n\n\tconst mdStyles = isDark ? MD_STYLES_DARK : MD_STYLES_LIGHT;\n\tconst mdRules = useMemo(() => makeMdRules(isDark, accent), [isDark, accent]);\n\n\treturn (\n\t\t<View style={ub.bodyWrap}>\n\t\t\t<ScrollView\n\t\t\t\tstyle={ub.fieldsScroll}\n\t\t\t\tcontentContainerStyle={ub.fieldsContent}\n\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\tshowsVerticalScrollIndicator\n\t\t\t>\n\t\t\t{prompt.message?.trim() ? (\n\t\t\t\t<View style={ub.messageBlock}>\n\t\t\t\t\t<Markdown style={mdStyles} rules={mdRules}>\n\t\t\t\t\t\t{prompt.message.replace(/\\\\n/g, \"\\n\")}\n\t\t\t\t\t</Markdown>\n\t\t\t\t</View>\n\t\t\t) : null}\n\n\t\t\t<View style={ub.form}>\n\t\t\t\t{fields.map(([key, field]) => {\n\t\t\t\t\tconst widget = classifyField(field);\n\t\t\t\t\tconst label = field.title || key;\n\t\t\t\t\tconst required = isRequired(schema, key);\n\t\t\t\t\tconst err = errors[key];\n\n\t\t\t\t\tif (widget === \"boolean\") {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<View key={key} style={ub.switchRow}>\n\t\t\t\t\t\t\t\t<Text style={[ub.label, { color: pal.text, flex: 1 }]}>\n\t\t\t\t\t\t\t\t\t{label}{required ? <Text style={{ color: \"#ef4444\" }}> *</Text> : null}\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t<Switch\n\t\t\t\t\t\t\t\t\tvalue={Boolean(values[key])}\n\t\t\t\t\t\t\t\t\tdisabled={locked}\n\t\t\t\t\t\t\t\t\tonValueChange={(v) => setValue(key, v)}\n\t\t\t\t\t\t\t\t\ttrackColor={{ true: accent }}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={key} style={ub.field}>\n\t\t\t\t\t\t\t<Text style={[ub.label, { color: pal.text }]}>\n\t\t\t\t\t\t\t\t{label}{required ? <Text style={{ color: \"#ef4444\" }}> *</Text> : null}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t{field.description ? <Text style={[ub.hint, { color: pal.muted }]}>{field.description}</Text> : null}\n\n\t\t\t\t\t\t\t{widget === \"select\" ? (\n\t\t\t\t\t\t\t\t<View style={ub.optionList}>\n\t\t\t\t\t\t\t\t\t{getOptions(field).map((opt) => {\n\t\t\t\t\t\t\t\t\t\tconst selected = String(values[key] ?? \"\") === opt.const;\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<Pressable\n\t\t\t\t\t\t\t\t\t\t\t\tkey={opt.const}\n\t\t\t\t\t\t\t\t\t\t\t\tdisabled={locked}\n\t\t\t\t\t\t\t\t\t\t\t\tonPress={() => setValue(key, opt.const)}\n\t\t\t\t\t\t\t\t\t\t\t\tandroid_ripple={{ color: accent + \"22\" }}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\tub.optionRow,\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tborderColor: selected ? accent : pal.fieldBorder,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: selected ? accent + (isDark ? \"26\" : \"14\") : pal.fieldBg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tub.radio,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ borderColor: selected ? accent : pal.fieldBorder },\n\t\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<View style={[ub.radioDot, { backgroundColor: accent }]} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tub.optionLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ color: pal.text, fontWeight: selected ? \"600\" : \"500\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{opt.title || opt.const}\n\t\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\tvalue={String(values[key] ?? \"\")}\n\t\t\t\t\t\t\t\t\teditable={!locked}\n\t\t\t\t\t\t\t\t\tonChangeText={(t) => setValue(key, t)}\n\t\t\t\t\t\t\t\t\tplaceholder={field.description ? undefined : label}\n\t\t\t\t\t\t\t\t\tplaceholderTextColor={pal.muted}\n\t\t\t\t\t\t\t\t\tkeyboardType={widget === \"integer\" ? \"number-pad\" : widget === \"decimal\" ? \"decimal-pad\" : \"default\"}\n\t\t\t\t\t\t\t\t\tstyle={[\n\t\t\t\t\t\t\t\t\t\tub.input,\n\t\t\t\t\t\t\t\t\t\t{ color: pal.text, backgroundColor: pal.fieldBg, borderColor: err ? \"#ef4444\" : pal.fieldBorder },\n\t\t\t\t\t\t\t\t\t]}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{err ? <Text style={ub.error}>{err}</Text> : null}\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</View>\n\t\t\t</ScrollView>\n\n\t\t\t<View style={ub.actions}>\n\t\t\t\t<PrimaryButton\n\t\t\t\t\tlabel={busy ? \"Submitting…\" : isConfirm ? \"Confirm\" : \"Next\"}\n\t\t\t\t\tonPress={handleSubmit}\n\t\t\t\t\tdisabled={locked}\n\t\t\t\t\taccent={accent}\n\t\t\t\t/>\n\t\t\t\t<View style={ub.linkRow}>\n\t\t\t\t\t<Pressable disabled={busy} onPress={() => void onCancel(prompt.userActionId)}>\n\t\t\t\t\t\t<Text style={[ub.link, ub.linkDanger, { opacity: busy ? 0.4 : 1 }]}>Cancel</Text>\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// The animated, swipe-to-dismiss bottom sheet. Presents the active prompt as a\n// tall, polished sheet. Dismissing it (backdrop tap / swipe-down / the close\n// button) is a *minimize* — the run stays alive and the inline resume card takes\n// over. Only the explicit \"Cancel\" action cancels the prompt.\n//\n// It is rendered as an always-mounted, in-tree overlay (NOT a React Native\n// `Modal`). A `Modal` must unmount to let the user reach the chat behind it,\n// and re-presenting a native modal is visibly laggy. Keeping the layer mounted\n// and animating `translateY` on the native driver makes open/close instant and\n// preserves the user's in-progress input across minimize/reopen.\nfunction UserActionSheet({\n\topen,\n\tactive,\n\texpired,\n\tisDark,\n\taccent,\n\tinsetBottom,\n\tonSubmit,\n\tonCancel,\n\tonResend,\n\tonMinimize,\n}: {\n\topen: boolean;\n\tactive?: ActiveUserAction;\n\texpired: boolean;\n\tisDark: boolean;\n\taccent: string;\n\tinsetBottom: number;\n\tonSubmit: (id: string, content: Record<string, unknown>) => Promise<void>;\n\tonCancel: (id: string) => Promise<void>;\n\tonResend: (id: string) => Promise<void>;\n\tonMinimize: () => void;\n}) {\n\tconst pal = uaPalette(isDark);\n\tconst screenH = Dimensions.get(\"window\").height;\n\n\t// Keep the last prompt rendered during the slide-out so content doesn't blank.\n\tconst [shown, setShown] = useState<ActiveUserAction | undefined>(active);\n\tuseEffect(() => {\n\t\tif (active) setShown(active);\n\t}, [active]);\n\n\tconst translateY = useRef(new Animated.Value(screenH)).current;\n\tconst backdrop = useRef(new Animated.Value(0)).current;\n\tconst minimizeRef = useRef(onMinimize);\n\tuseEffect(() => {\n\t\tminimizeRef.current = onMinimize;\n\t});\n\n\t// Keyboard avoidance: the sheet is an absolutely-positioned overlay, so the\n\t// chat's KeyboardAvoidingView doesn't lift it. Track the keyboard height and\n\t// raise the sheet ourselves so inputs (e.g. the OTP field) stay visible.\n\tconst [kbHeight, setKbHeight] = useState(0);\n\tuseEffect(() => {\n\t\tconst showEvt = Platform.OS === \"ios\" ? \"keyboardWillShow\" : \"keyboardDidShow\";\n\t\tconst hideEvt = Platform.OS === \"ios\" ? \"keyboardWillHide\" : \"keyboardDidHide\";\n\t\tconst s1 = Keyboard.addListener(showEvt, (e) => setKbHeight(e?.endCoordinates?.height ?? 0));\n\t\tconst s2 = Keyboard.addListener(hideEvt, () => setKbHeight(0));\n\t\treturn () => {\n\t\t\ts1.remove();\n\t\t\ts2.remove();\n\t\t};\n\t}, []);\n\n\t// Entrance / exit is driven purely by `open` — no mount/unmount churn.\n\tuseEffect(() => {\n\t\tif (open) {\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.spring(translateY, { toValue: 0, useNativeDriver: true, damping: 30, stiffness: 360, mass: 0.85 }),\n\t\t\t\tAnimated.timing(backdrop, { toValue: 1, duration: 190, useNativeDriver: true }),\n\t\t\t]).start();\n\t\t} else {\n\t\t\tAnimated.parallel([\n\t\t\t\tAnimated.timing(translateY, { toValue: screenH, duration: 210, easing: Easing.in(Easing.cubic), useNativeDriver: true }),\n\t\t\t\tAnimated.timing(backdrop, { toValue: 0, duration: 170, useNativeDriver: true }),\n\t\t\t]).start();\n\t\t}\n\t}, [open, translateY, backdrop, screenH]);\n\n\t// Swipe-down-to-dismiss, anchored to the grabber / header zone. Releasing past\n\t// the threshold calls `onMinimize`; the `open` effect then slides it the rest\n\t// of the way out.\n\tconst pan = useRef(\n\t\tPanResponder.create({\n\t\t\tonMoveShouldSetPanResponder: (_evt, g) => g.dy > 6 && Math.abs(g.dy) > Math.abs(g.dx) * 1.4,\n\t\t\tonPanResponderMove: (_evt, g) => {\n\t\t\t\tif (g.dy > 0) translateY.setValue(g.dy);\n\t\t\t},\n\t\t\tonPanResponderRelease: (_evt, g) => {\n\t\t\t\tif (g.dy > 110 || g.vy > 0.8) {\n\t\t\t\t\tminimizeRef.current();\n\t\t\t\t} else {\n\t\t\t\t\tAnimated.spring(translateY, { toValue: 0, useNativeDriver: true, damping: 30, stiffness: 360 }).start();\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t).current;\n\n\tconst a = active ?? shown;\n\tif (!a) return <View pointerEvents=\"none\" />;\n\n\tconst isVerification = a.kind === \"verification\";\n\tconst title = isVerification ? \"Verification required\" : \"Action required\";\n\tconst subtitle = isVerification\n\t\t? \"Confirm the one-time code to continue\"\n\t\t: \"Review the details and confirm to continue\";\n\n\treturn (\n\t\t<View style={[StyleSheet.absoluteFill, sht.overlay]} pointerEvents={open ? \"auto\" : \"none\"}>\n\t\t\t<Animated.View\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t\tstyle={[sht.backdrop, { backgroundColor: pal.overlay, opacity: backdrop }]}\n\t\t\t/>\n\t\t\t{open ? (\n\t\t\t\t<Pressable style={StyleSheet.absoluteFill} onPress={() => minimizeRef.current()} accessibilityLabel=\"Dismiss\" />\n\t\t\t) : null}\n\n\t\t\t<View style={[sht.kav, { paddingBottom: kbHeight }]} pointerEvents=\"box-none\">\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={[\n\t\t\t\t\t\tsht.sheet,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbackgroundColor: pal.sheetBg,\n\t\t\t\t\t\t\tborderColor: pal.border,\n\t\t\t\t\t\t\t// Cap to the space above the keyboard (and a top margin) so the\n\t\t\t\t\t\t\t// header stays visible and the footer sits above the keyboard;\n\t\t\t\t\t\t\t// the field area scrolls within whatever's left.\n\t\t\t\t\t\t\tmaxHeight: Math.min(screenH * 0.9, screenH - kbHeight - 72),\n\t\t\t\t\t\t\tpaddingBottom: kbHeight > 0 ? 16 : Math.max(insetBottom, 16) + 6,\n\t\t\t\t\t\t\ttransform: [{ translateY }],\n\t\t\t\t\t\t},\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{/* Grab zone — owns the swipe-to-dismiss gesture. */}\n\t\t\t\t\t<View {...pan.panHandlers} style={sht.handleZone}>\n\t\t\t\t\t\t<View style={[sht.grabber, { backgroundColor: pal.grabber }]} />\n\t\t\t\t\t</View>\n\n\t\t\t\t\t<View style={sht.header}>\n\t\t\t\t\t\t<View style={[sht.iconCircle, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t\t\t\t\t{isVerification ? (\n\t\t\t\t\t\t\t\t<ShieldCheck size={20} color={accent} strokeWidth={2} />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Pencil size={18} color={accent} strokeWidth={2} />\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<View style={sht.headerText}>\n\t\t\t\t\t\t\t<Text style={[sht.title, { color: pal.text }]}>{title}</Text>\n\t\t\t\t\t\t\t<Text style={[sht.subtitle, { color: pal.muted }]} numberOfLines={1}>\n\t\t\t\t\t\t\t\t{subtitle}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<SheetTimerPill prompt={a} accent={accent} isDark={isDark} />\n\t\t\t\t\t\t<Pressable onPress={() => minimizeRef.current()} hitSlop={10} style={[sht.closeBtn, { backgroundColor: pal.fieldBg }]}>\n\t\t\t\t\t\t\t<X size={16} color={pal.muted} strokeWidth={2.2} />\n\t\t\t\t\t\t</Pressable>\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{a.status === \"stale\" ? (\n\t\t\t\t\t\t<View style={sht.simpleBody}>\n\t\t\t\t\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>This request is no longer available.</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t) : expired ? (\n\t\t\t\t\t\t<View style={sht.simpleBody}>\n\t\t\t\t\t\t\t<Text style={[ub.desc, { color: pal.muted }]}>\n\t\t\t\t\t\t\t\t{isVerification ? \"This verification request expired.\" : \"This request expired.\"}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<View style={ub.actions}>\n\t\t\t\t\t\t\t\t<PrimaryButton label=\"Close\" onPress={() => void onCancel(a.userActionId)} accent={accent} />\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t) : isVerification ? (\n\t\t\t\t\t\t<VerificationBody\n\t\t\t\t\t\t\tkey={a.userActionId}\n\t\t\t\t\t\t\tprompt={a}\n\t\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\t\tpal={pal}\n\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\tonSubmit={onSubmit}\n\t\t\t\t\t\t\tonCancel={onCancel}\n\t\t\t\t\t\t\tonResend={onResend}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<FormBody key={a.userActionId} prompt={a} pal={pal} accent={accent} isDark={isDark} onSubmit={onSubmit} onCancel={onCancel} />\n\t\t\t\t\t)}\n\t\t\t\t</Animated.View>\n\t\t\t</View>\n\t\t</View>\n\t);\n}\n\n// Inline \"resume\" card shown in the message stream while a prompt is minimized.\n// Carries the live countdown; tapping it re-opens the sheet. Rendered only while\n// the prompt is live (not expired / stale), so it vanishes on expiry and the\n// stream continues.\nfunction UserActionReopenCard({\n\tactive,\n\texpired,\n\tisDark,\n\taccent,\n\tonReopen,\n}: {\n\tactive: ActiveUserAction;\n\texpired: boolean;\n\tisDark: boolean;\n\taccent: string;\n\tonReopen: () => void;\n}) {\n\tif (expired || active.status === \"stale\") return null;\n\tconst pal = uaPalette(isDark);\n\tconst isVerification = active.kind === \"verification\";\n\tconst title = isVerification ? \"Verification required\" : \"Action required\";\n\n\treturn (\n\t\t<Pressable\n\t\t\tonPress={onReopen}\n\t\t\taccessibilityRole=\"button\"\n\t\t\taccessibilityLabel={`${title}. Tap to respond.`}\n\t\t\tandroid_ripple={{ color: accent + \"22\" }}\n\t\t\tstyle={[\n\t\t\t\trc.card,\n\t\t\t\t{\n\t\t\t\t\tbackgroundColor: pal.sheetBg,\n\t\t\t\t\tborderColor: accent + (isDark ? \"59\" : \"40\"),\n\t\t\t\t},\n\t\t\t]}\n\t\t>\n\t\t\t<View style={[rc.iconCircle, { backgroundColor: accent + (isDark ? \"26\" : \"14\") }]}>\n\t\t\t\t{isVerification ? (\n\t\t\t\t\t<ShieldCheck size={18} color={accent} strokeWidth={2} />\n\t\t\t\t) : (\n\t\t\t\t\t<Pencil size={16} color={accent} strokeWidth={2} />\n\t\t\t\t)}\n\t\t\t</View>\n\t\t\t<View style={rc.textWrap}>\n\t\t\t\t<Text style={[rc.title, { color: pal.text }]} numberOfLines={1}>\n\t\t\t\t\t{title}\n\t\t\t\t</Text>\n\t\t\t\t<Text style={[rc.subtitle, { color: pal.muted }]} numberOfLines={1}>\n\t\t\t\t\tTap to respond and continue\n\t\t\t\t</Text>\n\t\t\t</View>\n\t\t\t<CardTimerPill prompt={active} accent={accent} isDark={isDark} />\n\t\t\t<ChevronRight size={18} color={pal.muted} strokeWidth={2} />\n\t\t</Pressable>\n\t);\n}\n\n// Lightweight dismissible notification stack (one-way messages).\nfunction NotificationStack({\n\tnotifications,\n\tisDark,\n\tonDismiss,\n}: {\n\tnotifications: UserNotification[];\n\tisDark: boolean;\n\tonDismiss: (id: string) => void;\n}) {\n\tif (notifications.length === 0) return null;\n\tconst pal = uaPalette(isDark);\n\treturn (\n\t\t<View style={ub.noteStack}>\n\t\t\t{notifications.map((n) => (\n\t\t\t\t<View key={n.id} style={[ub.note, { backgroundColor: pal.fieldBg, borderColor: pal.border }]}>\n\t\t\t\t\t<Info size={14} color={pal.muted} strokeWidth={1.9} />\n\t\t\t\t\t<Text style={[ub.noteText, { color: pal.text }]}>{n.message}</Text>\n\t\t\t\t\t<Pressable onPress={() => onDismiss(n.id)} hitSlop={8}>\n\t\t\t\t\t\t<X size={14} color={pal.muted} strokeWidth={2} />\n\t\t\t\t\t</Pressable>\n\t\t\t\t</View>\n\t\t\t))}\n\t\t</View>\n\t);\n}\n\nconst ub = StyleSheet.create({\n\t// Body wrapper can shrink within the sheet's (bounded) maxHeight so the inner\n\t// field scroll takes over for tall forms while the footer stays pinned.\n\tbodyWrap: { flexShrink: 1 },\n\t// Field scroll region. flexShrink:1 + no flexGrow → hugs content for short\n\t// forms (no scroll), shrinks and scrolls only when the form exceeds the sheet.\n\tfieldsScroll: { flexShrink: 1 },\n\tfieldsContent: { paddingBottom: 6 },\n\tmessageBlock: { marginBottom: 18, marginTop: 2 },\n\tdesc: { fontSize: 14.5, lineHeight: 21, marginBottom: 16 },\n\tform: { gap: 18 },\n\tfield: { gap: 7 },\n\tlabel: { fontSize: 14, fontWeight: \"600\" },\n\thint: { fontSize: 12.5, lineHeight: 17 },\n\tinput: {\n\t\tborderWidth: 1,\n\t\tborderRadius: 12,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 13,\n\t\tfontSize: 16,\n\t},\n\terror: { color: \"#ef4444\", fontSize: 12.5, marginTop: 2 },\n\tswitchRow: { flexDirection: \"row\", alignItems: \"center\", gap: 12 },\n\t// Selectable option \"boxes\" for oneOf / enum single-select fields.\n\toptionList: { gap: 10 },\n\toptionRow: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 12,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 14,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 14,\n\t},\n\tradio: {\n\t\twidth: 20,\n\t\theight: 20,\n\t\tborderRadius: 10,\n\t\tborderWidth: 2,\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t},\n\tradioDot: { width: 10, height: 10, borderRadius: 5 },\n\toptionLabel: { flex: 1, fontSize: 15, letterSpacing: -0.1 },\n\t// Pinned footer (outside the fields scroll) — always visible.\n\tactions: { paddingTop: 16, gap: 14 },\n\tprimaryBtn: { minHeight: 52, borderRadius: 14, borderWidth: 1, paddingVertical: 15, alignItems: \"center\", justifyContent: \"center\" },\n\tprimaryBtnText: { color: \"#fff\", fontSize: 15.5, fontWeight: \"600\", letterSpacing: -0.1 },\n\tlinkRow: { flexDirection: \"row\", justifyContent: \"center\", gap: 24 },\n\tlink: { fontSize: 14, fontWeight: \"500\" },\n\tlinkDanger: { color: \"#dc2626\" },\n\tcodeRow: { flexDirection: \"row\", justifyContent: \"center\", gap: 9, position: \"relative\" },\n\tcodeBox: {\n\t\twidth: 46,\n\t\theight: 56,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 12,\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t},\n\tcodeChar: { fontSize: 24, fontWeight: \"600\" },\n\tcodeHidden: { ...StyleSheet.absoluteFillObject, opacity: 0 },\n\tnoteStack: { paddingHorizontal: 16, paddingBottom: 6, gap: 6 },\n\tnote: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 8,\n\t\tborderWidth: 1,\n\t\tborderRadius: 12,\n\t\tpaddingHorizontal: 12,\n\t\tpaddingVertical: 10,\n\t},\n\tnoteText: { flex: 1, fontSize: 13.5, lineHeight: 19 },\n});\n\n// Bottom-sheet shell styles.\nconst sht = StyleSheet.create({\n\t// High stacking so the sheet sits above the chat input bar (which carries its\n\t// own zIndex/elevation) and everything else in the chat.\n\toverlay: { zIndex: 100, ...Platform.select({ android: { elevation: 100 }, default: {} }) },\n\tbackdrop: { ...StyleSheet.absoluteFillObject },\n\tkav: { flex: 1, justifyContent: \"flex-end\" },\n\tsheet: {\n\t\tborderTopLeftRadius: 28,\n\t\tborderTopRightRadius: 28,\n\t\tborderWidth: StyleSheet.hairlineWidth,\n\t\tborderBottomWidth: 0,\n\t\tpaddingHorizontal: 22,\n\t\tpaddingTop: 6,\n\t\tmaxWidth: 640,\n\t\twidth: \"100%\",\n\t\talignSelf: \"center\",\n\t\t...Platform.select({\n\t\t\tios: {\n\t\t\t\tshadowColor: \"#000\",\n\t\t\t\tshadowOffset: { width: 0, height: -6 },\n\t\t\t\tshadowOpacity: 0.18,\n\t\t\t\tshadowRadius: 24,\n\t\t\t},\n\t\t\tandroid: { elevation: 24 },\n\t\t}),\n\t},\n\thandleZone: { alignItems: \"center\", paddingVertical: 10 },\n\tgrabber: { width: 40, height: 5, borderRadius: 3 },\n\theader: { flexDirection: \"row\", alignItems: \"center\", gap: 12, marginTop: 2, marginBottom: 18 },\n\ticonCircle: { width: 40, height: 40, borderRadius: 20, alignItems: \"center\", justifyContent: \"center\" },\n\theaderText: { flex: 1, gap: 2 },\n\ttitle: { fontSize: 18, fontWeight: \"700\", letterSpacing: -0.3 },\n\tsubtitle: { fontSize: 13, letterSpacing: -0.1 },\n\ttimer: { borderWidth: 1, borderRadius: 999, paddingHorizontal: 11, paddingVertical: 5, minWidth: 46, alignItems: \"center\" },\n\tcloseBtn: { width: 30, height: 30, borderRadius: 15, alignItems: \"center\", justifyContent: \"center\" },\n\t// Short, non-scrolling bodies (stale / expired notices).\n\tsimpleBody: { paddingBottom: 8 },\n});\n\n// Inline \"resume\" card styles (shown in the chat stream while minimized).\n// Rendered as a direct child of the message-list content, so it stretches to the\n// full row width on its own — no flex needed (flex:1 here would grow vertically).\nconst rc = StyleSheet.create({\n\tcard: {\n\t\tflexDirection: \"row\",\n\t\talignItems: \"center\",\n\t\tgap: 12,\n\t\tborderWidth: 1.5,\n\t\tborderRadius: 18,\n\t\tpaddingHorizontal: 14,\n\t\tpaddingVertical: 13,\n\t\tmarginVertical: 6,\n\t},\n\ticonCircle: { width: 34, height: 34, borderRadius: 17, alignItems: \"center\", justifyContent: \"center\" },\n\ttextWrap: { flex: 1, gap: 1 },\n\ttitle: { fontSize: 14.5, fontWeight: \"700\", letterSpacing: -0.2 },\n\tsubtitle: { fontSize: 12.5, letterSpacing: -0.1 },\n\ttimer: { borderRadius: 999, paddingHorizontal: 9, paddingVertical: 4, minWidth: 40, alignItems: \"center\" },\n});\n\n// ─── PaymanChat (native) ──────────────────────────────────────────────────────\n\nexport const PaymanChat = forwardRef<PaymanChatRef, PaymanChatProps>(\n\tfunction PaymanChat({ config, callbacks, children, onLoadMoreMessages, isLoadingMoreMessages = false, hasMoreMessages = false }, ref) {\n\t\tconst accent = config.accent ?? DEFAULT_ACCENT;\n\n\t\t// Theme: explicit config override wins, else follow the device scheme.\n\t\tconst systemScheme = useColorScheme();\n\t\tconst isDark = (config.colorScheme ?? systemScheme) === \"dark\";\n\t\tconst ui = isDark\n\t\t\t? {\n\t\t\t\t\tlistBg: \"#0d1719\",\n\t\t\t\t\tinputText: \"rgba(255,255,255,0.92)\",\n\t\t\t\t\temptyText: \"rgba(255,255,255,0.55)\",\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tlistBg: \"#ffffff\",\n\t\t\t\t\tinputText: \"#1F2937\",\n\t\t\t\t\temptyText: \"#6b7280\",\n\t\t\t };\n\n\t\tconst callbacksRef = useRef(callbacks);\n\t\tuseEffect(() => { callbacksRef.current = callbacks; });\n\t\tconst stableCallbacks = useMemo(() => ({\n\t\t\tonSessionIdChange: (id: string | null) => callbacksRef.current?.onSessionIdChange?.(id),\n\t\t\tonStreamStart: () => callbacksRef.current?.onStreamStart?.(),\n\t\t\tonStreamEnd: () => callbacksRef.current?.onStreamEnd?.(),\n\t\t\tonError: (e: Error) => {\n\t\t\t\tconsole.error(\"[PaymanChat] stream error:\", e.message, e);\n\t\t\t\tcallbacksRef.current?.onError?.(e);\n\t\t\t},\n\t\t\tonStatusMessage: (m: string) => callbacksRef.current?.onStatusMessage?.(m),\n\t\t\tonStepsUpdate: (steps: any[]) => callbacksRef.current?.onStepsUpdate?.(steps),\n\t\t\tonUserActionRequired: (r: any) => {\n\t\t\t\tconsole.log(\"[PaymanChat] USER_ACTION_REQUIRED:\", JSON.stringify({ kind: r?.kind, rawAction: r?.rawAction, userActionId: r?.userActionId, hasSchema: !!r?.requestedSchema }));\n\t\t\t\tcallbacksRef.current?.onUserActionRequired?.(r);\n\t\t\t},\n\t\t\tonUserNotification: (n: any) => {\n\t\t\t\tconsole.log(\"[PaymanChat] USER_NOTIFICATION:\", JSON.stringify({ id: n?.id, message: n?.message }));\n\t\t\t\tcallbacksRef.current?.onUserNotification?.(n);\n\t\t\t},\n\t\t}), []);\n\n\t\tconst {\n\t\t\tmessages, sendMessage, isWaitingForResponse,\n\t\t\tresetSession, clearMessages, prependMessages,\n\t\t\tcancelStream, getSessionId, getMessages,\n\t\t\tuserActionState, submitUserAction, cancelUserAction,\n\t\t\tresendUserAction, dismissNotification,\n\t\t} = useChatV2(config, stableCallbacks);\n\n\t\t// Diagnostic: surface active prompt/notification counts as they change.\n\t\tuseEffect(() => {\n\t\t\tconsole.log(\n\t\t\t\t\"[PaymanChat] userActionState ->\",\n\t\t\t\t\"prompts:\", userActionState.prompts.length,\n\t\t\t\tuserActionState.prompts.map((p) => `${p.kind}:${p.status}`).join(\",\"),\n\t\t\t\t\"| notifications:\", userActionState.notifications.length,\n\t\t\t);\n\t\t}, [userActionState]);\n\n\t\t// ── Active user-action prompt presentation ──\n\t\t// The first non-notification prompt drives the sheet. Expiry is tracked as a\n\t\t// single boolean (one timeout, re-renders once) — the live per-second display\n\t\t// lives in the small timer pills so the chat tree doesn't repaint each tick.\n\t\tconst activePrompt = useMemo(\n\t\t\t() => userActionState.prompts.find((p) => p.kind !== \"notification\"),\n\t\t\t[userActionState.prompts],\n\t\t);\n\t\tconst expired = useExpiredFlag(activePrompt);\n\t\tconst [dismissedActionId, setDismissedActionId] = useState<string | null>(null);\n\t\t// A fresh / superseded prompt always (re)opens the sheet.\n\t\tuseEffect(() => {\n\t\t\tif (activePrompt) setDismissedActionId(null);\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, [activePrompt?.userActionId, activePrompt?.subAction]);\n\t\tconst sheetOpen = !!activePrompt && dismissedActionId !== activePrompt.userActionId;\n\t\tconst showReopenCard =\n\t\t\t!!activePrompt && !sheetOpen && !expired && activePrompt.status !== \"stale\";\n\t\tconst minimizeActivePrompt = useCallback(() => {\n\t\t\tsetDismissedActionId((prev) => activePrompt?.userActionId ?? prev);\n\t\t}, [activePrompt?.userActionId]);\n\n\t\tconst {\n\t\t\ttranscribedText, isAvailable: voiceAvailable,\n\t\t\tisRecording, startRecording, stopRecording, clearTranscript,\n\t\t} = useVoice(\n\t\t\t{ lang: \"en-US\", interimResults: true, continuous: true },\n\t\t\t{ onError: (e) => console.error(\"Voice error:\", e) },\n\t\t);\n\n\t\tconst [inputValue, setInputValue] = useState(\"\");\n\t\tconst [recordingSeconds, setRecordingSeconds] = useState(0);\n\t\tconst recordingStartRef = useRef<number | null>(null);\n\t\tconst recordingTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n\t\tuseImperativeHandle(ref, () => ({ resetSession, clearMessages, cancelStream, getSessionId, getMessages }));\n\n\t\tconst contextValue = useMemo(() => ({\n\t\t\tresetSession, clearMessages, prependMessages,\n\t\t\tcancelStream, getSessionId, getMessages, isWaitingForResponse,\n\t\t}), [resetSession, clearMessages, prependMessages, cancelStream, getSessionId, getMessages, isWaitingForResponse]);\n\n\t\tuseEffect(() => {\n\t\t\tif (isRecording) {\n\t\t\t\trecordingStartRef.current = Date.now();\n\t\t\t\tsetRecordingSeconds(0);\n\t\t\t\trecordingTimerRef.current = setInterval(() => {\n\t\t\t\t\tif (recordingStartRef.current != null)\n\t\t\t\t\t\tsetRecordingSeconds(Math.floor((Date.now() - recordingStartRef.current) / 1000));\n\t\t\t\t}, 1000);\n\t\t\t} else {\n\t\t\t\trecordingStartRef.current = null;\n\t\t\t\tif (recordingTimerRef.current) { clearInterval(recordingTimerRef.current); recordingTimerRef.current = null; }\n\t\t\t\tsetRecordingSeconds(0);\n\t\t\t}\n\t\t\treturn () => { if (recordingTimerRef.current) clearInterval(recordingTimerRef.current); };\n\t\t}, [isRecording]);\n\n\t\tconst prevInput = useRef(inputValue);\n\t\tuseEffect(() => {\n\t\t\tconst wasEmpty = prevInput.current.trim() === \"\";\n\t\t\tconst isEmpty = inputValue.trim() === \"\";\n\t\t\tprevInput.current = inputValue;\n\t\t\tif (!wasEmpty && isEmpty) { clearTranscript(); if (isRecording) stopRecording(); }\n\t\t}, [inputValue, clearTranscript, isRecording, stopRecording]);\n\n\t\tconst handleSend = useCallback(() => {\n\t\t\tif (isRecording) stopRecording();\n\t\t\tconst text = inputValue.trim();\n\t\t\tif (!text || isWaitingForResponse) return;\n\t\t\tconsole.log(\"[PaymanChat] sending. baseUrl:\", config.api?.baseUrl, \"agentId:\", config.agentId, \"stage:\", config.stage, \"sessionOwnerId:\", config.sessionParams?.id);\n\t\t\tsetInputValue(\"\");\n\t\t\tvoid sendMessage(text);\n\t\t}, [inputValue, isWaitingForResponse, sendMessage, isRecording, stopRecording, config]);\n\n\t\tconst handleVoicePress = useCallback(async () => {\n\t\t\tif (!voiceAvailable) return;\n\t\t\tclearTranscript();\n\t\t\tawait startRecording();\n\t\t}, [voiceAvailable, startRecording, clearTranscript]);\n\n\t\tconst handleConfirmRecording = useCallback(() => {\n\t\t\tstopRecording();\n\t\t\tif (transcribedText.trim()) setInputValue(transcribedText);\n\t\t}, [stopRecording, transcribedText]);\n\n\t\tconst handleCancelRecording = useCallback(() => { stopRecording(); clearTranscript(); }, [stopRecording, clearTranscript]);\n\n\t\t// The text field stays editable while a response streams (the user can draft\n\t\t// their next message); only a missing session disables typing. Send/voice are\n\t\t// gated on `isStreaming` inside InputBar instead.\n\t\tconst isInputDisabled = !(config.sessionParams?.id?.trim());\n\t\tconst enableVoice = config.enableVoice !== false;\n\t\tconst isEmpty = messages.length === 0;\n\n\t\t// Track which assistant message IDs should use the typing effect.\n\t\t// Initialized with the current message count so history messages are excluded.\n\t\t// Any assistant message added after mount gets the typing animation.\n\t\tconst prevMessageCountRef = useRef(messages.length);\n\t\tconst typingMessageIds = useRef(new Set<string>());\n\t\tuseEffect(() => {\n\t\t\tif (messages.length > prevMessageCountRef.current) {\n\t\t\t\tconst newMsgs = messages.slice(prevMessageCountRef.current);\n\t\t\t\tnewMsgs.forEach((m) => {\n\t\t\t\t\tif (m.role === \"assistant\") typingMessageIds.current.add(m.id);\n\t\t\t\t});\n\t\t\t}\n\t\t\tprevMessageCountRef.current = messages.length;\n\t\t}, [messages]);\n\n\n\t\tconst scrollRef = useRef<ScrollView>(null);\n\t\tconst scrollToBottom = useCallback((animated = true) => {\n\t\t\tscrollRef.current?.scrollToEnd({ animated });\n\t\t}, []);\n\n\t\tuseEffect(() => {\n\t\t\tconst t = setTimeout(() => scrollToBottom(true), 60);\n\t\t\treturn () => clearTimeout(t);\n\t\t}, [messages, scrollToBottom]);\n\n\t\treturn (\n\t\t\t<PaymanChatContext.Provider value={contextValue}>\n\t\t\t\t<KeyboardAvoidingView\n\t\t\t\t\tstyle={s.container}\n\t\t\t\t\tbehavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n\t\t\t\t\tkeyboardVerticalOffset={0}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\n\t\t\t\t\t{/* Message list / empty state */}\n\t\t\t\t\t<View style={[s.messageListWrap, { backgroundColor: ui.listBg }]}>\n\t\t\t\t\t\t{isEmpty && !isWaitingForResponse ? (\n\t\t\t\t\t\t\t<View style={s.emptyState}>\n\t\t\t\t\t\t\t\t{config.emptyStateComponent}\n\t\t\t\t\t\t\t\t{config.emptyStateComponent != null && <View style={{ height: 16 }} />}\n\t\t\t\t\t\t\t\t<Text style={[s.emptyText, { color: ui.emptyText }]}>\n\t\t\t\t\t\t\t\t\t{config.emptyStateText ?? \"How can I help you today?\"}\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\tref={scrollRef}\n\t\t\t\t\t\t\t\tstyle={s.scrollList}\n\t\t\t\t\t\t\t\tcontentContainerStyle={s.listContent}\n\t\t\t\t\t\t\t\tshowsVerticalScrollIndicator={false}\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"handled\"\n\t\t\t\t\t\t\t\tonContentSizeChange={() => scrollToBottom(false)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{messages.map((msg) => (\n\t\t\t\t\t\t\t\t\t<MessageBubble\n\t\t\t\t\t\t\t\t\t\tkey={msg.id}\n\t\t\t\t\t\t\t\t\t\tmessage={msg}\n\t\t\t\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\t\t\t\tshouldType={typingMessageIds.current.has(msg.id)}\n\t\t\t\t\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\t\t\t\t\tsuppressText={\n\t\t\t\t\t\t\t\t\t\t\tactivePrompt?.message &&\n\t\t\t\t\t\t\t\t\t\t\tmsg.role === \"assistant\" &&\n\t\t\t\t\t\t\t\t\t\t\tmsg.id === messages[messages.length - 1]?.id\n\t\t\t\t\t\t\t\t\t\t\t\t? activePrompt.message\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t{/* Inline resume card while the action sheet is minimized */}\n\t\t\t\t\t\t\t\t{showReopenCard && activePrompt ? (\n\t\t\t\t\t\t\t\t\t<UserActionReopenCard\n\t\t\t\t\t\t\t\t\t\tactive={activePrompt}\n\t\t\t\t\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\t\t\t\tonReopen={() => setDismissedActionId(null)}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t<View style={{ height: 4 }} />\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{/* One-way notifications, just above the input */}\n\t\t\t\t\t<NotificationStack\n\t\t\t\t\t\tnotifications={userActionState.notifications}\n\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\tonDismiss={dismissNotification}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Input bar */}\n\t\t\t\t\t<View style={s.inputBarWrap}>\n\t\t\t\t\t\t<InputBar\n\t\t\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t\t\tonChange={setInputValue}\n\t\t\t\t\t\t\tonSend={handleSend}\n\t\t\t\t\t\t\tonCancel={cancelStream}\n\t\t\t\t\t\t\tdisabled={isInputDisabled}\n\t\t\t\t\t\t\tplaceholder={config.placeholder ?? \"Type your message...\"}\n\t\t\t\t\t\t\tisStreaming={isWaitingForResponse}\n\t\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\t\tenableVoice={enableVoice}\n\t\t\t\t\t\t\tvoiceAvailable={enableVoice && voiceAvailable}\n\t\t\t\t\t\t\tisRecording={enableVoice && isRecording}\n\t\t\t\t\t\t\trecordingSeconds={recordingSeconds}\n\t\t\t\t\t\t\ttranscribedText={transcribedText}\n\t\t\t\t\t\t\tonVoicePress={handleVoicePress}\n\t\t\t\t\t\t\tonConfirmRecording={handleConfirmRecording}\n\t\t\t\t\t\t\tonCancelRecording={handleCancelRecording}\n\t\t\t\t\t\t\tonFocus={() => {}}\n\t\t\t\t\t\t\tinsetBottom={config.contentInsetBottom ?? (Platform.OS === \"ios\" ? 20 : 8)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\n\t\t\t\t\t{/* Animated, swipe-to-dismiss sheet for form / verification prompts.\n\t\t\t\t\t Rendered inside the chat KAV (same parent as the input bar) with a\n\t\t\t\t\t high zIndex so it reliably sits above the input and message list. */}\n\t\t\t\t\t<UserActionSheet\n\t\t\t\t\t\topen={sheetOpen}\n\t\t\t\t\t\tactive={activePrompt}\n\t\t\t\t\t\texpired={expired}\n\t\t\t\t\t\tisDark={isDark}\n\t\t\t\t\t\taccent={accent}\n\t\t\t\t\t\tinsetBottom={config.contentInsetBottom ?? (Platform.OS === \"ios\" ? 20 : 8)}\n\t\t\t\t\t\tonSubmit={submitUserAction}\n\t\t\t\t\t\tonCancel={cancelUserAction}\n\t\t\t\t\t\tonResend={resendUserAction}\n\t\t\t\t\t\tonMinimize={minimizeActivePrompt}\n\t\t\t\t\t/>\n\t\t\t\t</KeyboardAvoidingView>\n\t\t\t</PaymanChatContext.Provider>\n\t\t);\n\t},\n);\n\n// ─── Styles ───────────────────────────────────────────────────────────────────\n\nconst s = StyleSheet.create({\n\tcontainer: { flex: 1, backgroundColor: \"#f1f5f9\" },\n\tmessageListWrap: { flex: 1, minHeight: 0, backgroundColor: \"#ffffff\" },\n\tinputBarWrap: {\n\t\twidth: \"100%\",\n\t\tzIndex: 2,\n\t\tbackgroundColor: \"#ffffff\",\n\t\t...Platform.select({ android: { elevation: 8 }, default: {} }),\n\t},\n\n\t// ── Input bar ──\n\touterBar: {\n\t\twidth: \"100%\",\n\t\tbackgroundColor: \"#f1f5f9\",\n\t\tborderTopWidth: 1,\n\t\tborderTopColor: \"rgba(0,0,0,0.08)\",\n\t\tpaddingTop: 6,\n\t\tpaddingHorizontal: 12,\n\t\tborderTopLeftRadius: 20,\n\t\tborderTopRightRadius: 20,\n\t},\n\touterBarVoice: {},\n\tcolumn: { maxWidth: 672, width: \"100%\", alignSelf: \"center\", gap: 2 },\n\tinputWrap: { width: \"100%\", justifyContent: \"center\", paddingHorizontal: 4 },\n\tinputWrapRelative: { position: \"relative\" },\n\tinput: {\n\t\tminHeight: 36,\n\t\tmaxHeight: 110,\n\t\tpaddingVertical: 8,\n\t\tpaddingHorizontal: 16,\n\t\tfontSize: 16,\n\t\tcolor: \"#1F2937\",\n\t\tlineHeight: 22,\n\t},\n\tinputDisabled: { opacity: 0.5 },\n\tinputHidden: { position: \"absolute\", left: 0, right: 0, top: 0, opacity: 0, zIndex: 0 },\n\tactionsRow: { flexDirection: \"row\", justifyContent: \"flex-end\", alignItems: \"center\", marginBottom: 2 },\n\trightActions: { flexDirection: \"row\", alignItems: \"center\", gap: 6 },\n\ticonBtn: { width: 28, height: 28, justifyContent: \"center\", alignItems: \"center\", borderRadius: 14, overflow: \"hidden\" },\n\ticonBtnInner: { width: 28, height: 28, justifyContent: \"center\", alignItems: \"center\", backgroundColor: \"rgba(0,0,0,0.1)\", borderRadius: 14 },\n\tsendBtn: { width: 28, height: 28, borderRadius: 14, overflow: \"hidden\", justifyContent: \"center\", alignItems: \"center\" },\n\tsendBtnInner: { width: 28, height: 28, borderRadius: 14, justifyContent: \"center\", alignItems: \"center\" },\n\tbtnDisabled: { opacity: 0.35 },\n\tpressed: { opacity: 0.7 },\n\tdisclaimerWrap: { maxWidth: 672, width: \"100%\", alignSelf: \"center\", paddingHorizontal: 12, marginTop: 2 },\n\tdisclaimerText: { fontSize: 10, lineHeight: 13, color: \"#9CA3AF\", textAlign: \"center\" },\n\n\t// ── Voice bar ──\n\tvoiceBarContainer: { position: \"absolute\", left: 0, right: 0, top: 0, bottom: 0, justifyContent: \"center\", zIndex: 1 },\n\tvoiceBar: { flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", borderWidth: 1, borderRadius: 28, minHeight: 56, paddingHorizontal: 12, paddingVertical: 10, gap: 12 },\n\tvoiceBarCircle: { width: 40, height: 40, borderRadius: 20, alignItems: \"center\", justifyContent: \"center\" },\n\tvoiceConfirm: { backgroundColor: \"#FFFFFF\", borderWidth: 1 },\n\tvoiceBarCenter: { flex: 1, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", gap: 10, marginLeft: 8 },\n\tvoiceDots: { flex: 1, flexDirection: \"row\", alignItems: \"center\", justifyContent: \"space-between\", gap: 4 },\n\tvoiceDot: { width: 4, borderRadius: 2 },\n\tvoiceTimer: { fontSize: 15, fontWeight: \"600\", minWidth: 36, textAlign: \"right\" },\n\n\t// ── Messages ──\n\tscrollList: { flex: 1 },\n\tlistContent: { paddingHorizontal: 16, paddingTop: 8, paddingBottom: 4, flexGrow: 1 },\n\temptyState: { flex: 1, alignItems: \"center\", justifyContent: \"center\", paddingHorizontal: 32, paddingBottom: 60 },\n\temptyText: { fontSize: 16, color: \"#6b7280\", textAlign: \"center\" },\n});\n\nconst sd = StyleSheet.create({\n\tbubbleRow: { flexDirection: \"row\", marginVertical: 3 },\n\trowUser: { justifyContent: \"flex-end\" },\n\trowAssistant: { justifyContent: \"flex-start\" },\n\tbubble: { maxWidth: \"82%\", paddingHorizontal: 14, paddingVertical: 10, borderRadius: 18 },\n\tbubbleUser: { borderBottomRightRadius: 4 },\n\tbubbleAssistant: { backgroundColor: \"#f3f4f6\", borderBottomLeftRadius: 4 },\n\t// Assistant bubbles stretch wider so tables and code blocks have room\n\tbubbleAssistantWide: { maxWidth: \"97%\" },\n\tbubbleError: { backgroundColor: \"#fef2f2\" },\n\tbubbleText: { fontSize: 15, lineHeight: 22 },\n\ttextUser: { color: \"#ffffff\" },\n\ttextAssistant: { color: \"#111827\" },\n\terrorText: { fontSize: 14, lineHeight: 20, color: \"#dc2626\" },\n\tpartialErrorText: { fontSize: 12, color: \"#dc2626\", marginTop: 4 },\n\tcancelledText: { fontSize: 12, color: \"#9ca3af\", marginTop: 4, fontStyle: \"italic\" },\n\tthinkingRow: { flexDirection: \"row\", alignItems: \"flex-start\", gap: 6, marginBottom: 3 },\n\tthinkingIcon: { fontSize: 12, lineHeight: 20, width: 14 },\n\tthinkingStepText: { flex: 1, fontSize: 14, lineHeight: 20, color: \"#374151\", fontStyle: \"italic\" },\n\tthinkingStepDone: { color: \"#9ca3af\" },\n});\n\n// Theme palette for markdown rendering (light/dark parity with the host app).\nfunction mdPalette(isDark: boolean) {\n\treturn isDark\n\t\t? {\n\t\t\t\ttext: \"rgba(255,255,255,0.92)\",\n\t\t\t\theading: \"#ffffff\",\n\t\t\t\tmuted: \"rgba(255,255,255,0.55)\",\n\t\t\t\tborder: \"rgba(255,255,255,0.16)\",\n\t\t\t\tborderSoft: \"rgba(255,255,255,0.10)\",\n\t\t\t\theaderBg: \"rgba(255,255,255,0.07)\",\n\t\t\t\tcodeInlineBg: \"rgba(255,255,255,0.12)\",\n\t\t\t\tcodeInlineText: \"#e8eaed\",\n\t\t\t\tcodeBlockBg: \"#0b1416\",\n\t\t\t\tcodeBlockText: \"#f3f4f6\",\n\t\t\t\tblockquoteBar: \"rgba(255,255,255,0.22)\",\n\t\t\t\thr: \"rgba(255,255,255,0.14)\",\n\t\t\t\tlink: \"#34c3cc\",\n\t\t }\n\t\t: {\n\t\t\t\ttext: \"#1f2937\",\n\t\t\t\theading: \"#111827\",\n\t\t\t\tmuted: \"#4b5563\",\n\t\t\t\tborder: \"#d1d5db\",\n\t\t\t\tborderSoft: \"#e5e7eb\",\n\t\t\t\theaderBg: \"#f3f4f6\",\n\t\t\t\tcodeInlineBg: \"#e5e7eb\",\n\t\t\t\tcodeInlineText: \"#1f2937\",\n\t\t\t\tcodeBlockBg: \"#1f2937\",\n\t\t\t\tcodeBlockText: \"#f9fafb\",\n\t\t\t\tblockquoteBar: \"#d1d5db\",\n\t\t\t\thr: \"#e5e7eb\",\n\t\t\t\tlink: \"#00858d\",\n\t\t };\n}\n\n// Per-column content sizing. react-native-markdown-display renders each row\n// independently with no shared column model, so neither auto-width nor cross-row\n// alignment work out of the box. We render the table ourselves: pull the cell\n// text out of the AST, size each column to its widest cell (clamped), and lay\n// out an aligned grid. Short columns (#, Type) stay narrow; long names get room.\nconst TABLE_CHAR_W = 7.6; // approx px per char at fontSize 13\nconst TABLE_CELL_PAD = 26; // horizontal padding budget per cell\nconst TABLE_MIN_W = 44;\nconst TABLE_MAX_W = 220;\n\n// Recursively collect the visible text of a markdown AST node.\nfunction nodeText(node: any): string {\n\tif (!node) return \"\";\n\tif (Array.isArray(node.children) && node.children.length) {\n\t\treturn node.children.map(nodeText).join(\"\");\n\t}\n\treturn typeof node.content === \"string\" ? node.content : \"\";\n}\n\n// Flatten a `table` AST node into a matrix of cell strings (first row = header).\nfunction tableMatrix(tableNode: any): string[][] {\n\tconst rows: string[][] = [];\n\tconst walk = (n: any) => {\n\t\tif (!n) return;\n\t\tif (n.type === \"tr\") {\n\t\t\trows.push((n.children || []).map(nodeText));\n\t\t\treturn;\n\t\t}\n\t\t(n.children || []).forEach(walk);\n\t};\n\twalk(tableNode);\n\treturn rows;\n}\n\n// Markdown render rules — fully custom, content-sized, themed table.\nfunction makeMdRules(isDark: boolean, accent: string) {\n\tconst c = mdPalette(isDark);\n\t// 8-digit hex alpha: brand-tinted header so the theme is clearly visible.\n\tconst headerBg = isDark ? accent + \"2E\" : accent + \"14\";\n\tconst headerText = isDark ? \"#8fe3e9\" : accent;\n\n\treturn {\n\t\ttable: (node: any) => {\n\t\t\tconst rows = tableMatrix(node);\n\t\t\tif (rows.length === 0) return null;\n\t\t\tconst ncols = Math.max(...rows.map((r) => r.length));\n\n\t\t\tconst colW: number[] = [];\n\t\t\tfor (let ci = 0; ci < ncols; ci++) {\n\t\t\t\tlet maxLen = 0;\n\t\t\t\tfor (const r of rows) maxLen = Math.max(maxLen, (r[ci] || \"\").length);\n\t\t\t\tcolW[ci] = Math.min(\n\t\t\t\t\tTABLE_MAX_W,\n\t\t\t\t\tMath.max(TABLE_MIN_W, Math.round(maxLen * TABLE_CHAR_W) + TABLE_CELL_PAD),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<ScrollView\n\t\t\t\t\tkey={node.key}\n\t\t\t\t\thorizontal\n\t\t\t\t\tshowsHorizontalScrollIndicator={true}\n\t\t\t\t\tstyle={{ marginVertical: 8 }}\n\t\t\t\t>\n\t\t\t\t\t<View style={{ borderWidth: 1, borderColor: c.border, borderRadius: 8, overflow: \"hidden\" }}>\n\t\t\t\t\t\t{rows.map((cells, ri) => {\n\t\t\t\t\t\t\tconst isHeader = ri === 0;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tkey={ri}\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tflexDirection: \"row\",\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: isHeader ? headerBg : \"transparent\",\n\t\t\t\t\t\t\t\t\t\tborderTopWidth: ri === 0 ? 0 : 1,\n\t\t\t\t\t\t\t\t\t\tborderTopColor: c.borderSoft,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{Array.from({ length: ncols }).map((_, ci) => (\n\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\tkey={ci}\n\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\twidth: colW[ci],\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingHorizontal: 12,\n\t\t\t\t\t\t\t\t\t\t\t\tpaddingVertical: 9,\n\t\t\t\t\t\t\t\t\t\t\t\tborderRightWidth: ci === ncols - 1 ? 0 : 1,\n\t\t\t\t\t\t\t\t\t\t\t\tborderRightColor: c.borderSoft,\n\t\t\t\t\t\t\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tfontSize: 13,\n\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight: 18,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcolor: isHeader ? headerText : c.text,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfontWeight: isHeader ? \"700\" : \"400\",\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{cells[ci] ?? \"\"}\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</View>\n\t\t\t\t</ScrollView>\n\t\t\t);\n\t\t},\n\t};\n}\n\n// Markdown styles for react-native-markdown-display, themed light/dark.\nfunction makeMdStyles(isDark: boolean) {\n\tconst c = mdPalette(isDark);\n\tconst mono = Platform.OS === \"ios\" ? \"Menlo\" : \"monospace\";\n\treturn {\n\t\t// Body\n\t\tbody: { color: c.text, fontSize: 14, lineHeight: 21 },\n\t\tparagraph: { marginTop: 0, marginBottom: 4 },\n\n\t\t// Emphasis\n\t\tstrong: { fontWeight: \"700\" as const, color: c.text },\n\t\tem: { fontStyle: \"italic\" as const, color: c.text },\n\n\t\t// Links\n\t\tlink: { color: c.link, textDecorationLine: \"underline\" as const },\n\n\t\t// Inline code\n\t\tcode_inline: {\n\t\t\tbackgroundColor: c.codeInlineBg,\n\t\t\tcolor: c.codeInlineText,\n\t\t\tfontFamily: mono,\n\t\t\tfontSize: 12,\n\t\t\tpaddingHorizontal: 4,\n\t\t\tborderRadius: 4,\n\t\t},\n\t\tcode_inline_container: { borderRadius: 4 },\n\n\t\t// Code blocks\n\t\tfence: { backgroundColor: c.codeBlockBg, borderRadius: 8, padding: 12, marginVertical: 6 },\n\t\tcode_block: { backgroundColor: c.codeBlockBg, borderRadius: 8, padding: 12, marginVertical: 6 },\n\t\tfence_code: { color: c.codeBlockText, fontFamily: mono, fontSize: 12 },\n\n\t\t// Lists\n\t\tbullet_list: { marginVertical: 4 },\n\t\tordered_list: { marginVertical: 4 },\n\t\tlist_item: { marginVertical: 1 },\n\t\tbullet_list_icon: { color: c.muted, marginTop: 6 },\n\t\tordered_list_icon: { color: c.muted },\n\t\tlist_item_text: { fontSize: 14, color: c.text },\n\n\t\t// Headings\n\t\theading1: { fontSize: 18, fontWeight: \"700\" as const, color: c.heading, marginBottom: 6, marginTop: 8 },\n\t\theading2: { fontSize: 16, fontWeight: \"700\" as const, color: c.heading, marginBottom: 4, marginTop: 6 },\n\t\theading3: { fontSize: 15, fontWeight: \"600\" as const, color: c.heading, marginBottom: 4, marginTop: 4 },\n\n\t\t// Blockquote / HR\n\t\tblockquote: { borderLeftWidth: 3, borderLeftColor: c.blockquoteBar, paddingLeft: 10, marginVertical: 4 },\n\t\thr: { backgroundColor: c.hr, height: 1, marginVertical: 8 },\n\n\t\t// Tables are rendered by a fully custom `table` rule (see makeMdRules) —\n\t\t// no per-cell styles needed here.\n\t};\n}\n\n// Precompute both style themes once (cheap). Rules depend on `accent` too, so\n// they're built per-message via useMemo in AssistantBubble.\nconst MD_STYLES_LIGHT = makeMdStyles(false);\nconst MD_STYLES_DARK = makeMdStyles(true);\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Utility function to merge Tailwind CSS classes\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","/**\n * Format a timestamp to a readable date/time string\n */\nexport function formatDate(timestamp: string | Date): string {\n\tconst date = typeof timestamp === \"string\" ? new Date(timestamp) : timestamp;\n\n\tconst now = new Date();\n\tconst diffMs = now.getTime() - date.getTime();\n\tconst diffMins = Math.floor(diffMs / 60000);\n\tconst diffHours = Math.floor(diffMs / 3600000);\n\tconst diffDays = Math.floor(diffMs / 86400000);\n\n\t// Less than a minute\n\tif (diffMins < 1) {\n\t\treturn \"Just now\";\n\t}\n\n\t// Less than an hour\n\tif (diffMins < 60) {\n\t\treturn `${diffMins}m ago`;\n\t}\n\n\t// Less than a day\n\tif (diffHours < 24) {\n\t\treturn `${diffHours}h ago`;\n\t}\n\n\t// Less than a week\n\tif (diffDays < 7) {\n\t\treturn `${diffDays}d ago`;\n\t}\n\n\t// Format as date\n\treturn date.toLocaleDateString(\"en-US\", {\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t\tyear: date.getFullYear() !== now.getFullYear() ? \"numeric\" : undefined,\n\t});\n}\n\nexport function formatElapsedTime(ms?: number): string {\n\tif (!ms) return \"\";\n\tif (ms < 1000) return `${ms}ms`;\n\treturn `${(ms / 1000).toFixed(1)}s`;\n}\n","import * as Sentry from \"@sentry/react\";\n\nexport interface ChatSessionContext {\n\tsessionId?: string;\n\tsessionOwnerId?: string;\n\tagentId?: string;\n\texecutionId?: string;\n\tcfRay?: string;\n\troute?: string;\n\tcustomerId?: string;\n\tcustomerEmail?: string;\n}\n\n/**\n * Reports an error to Sentry enriched with chat session context.\n * Tags and context are scoped to this event so they don't leak\n * to unrelated errors.\n *\n * No-op when Sentry is not initialised.\n */\nexport function captureSentryError(\n\terror: Error | string,\n\tcontext: ChatSessionContext\n): void {\n\tif (!Sentry.getClient()) return;\n\n\tconst tags: Record<string, string> = {};\n\tif (context.executionId) tags.executionId = context.executionId;\n\tif (context.sessionId) tags.sessionId = context.sessionId;\n\tif (context.route) tags.route = context.route;\n\tif (context.cfRay) tags.cfRay = context.cfRay;\n\n\tif (context.customerId) tags.customerId = context.customerId;\n\tif (context.customerEmail) tags.customerEmail = context.customerEmail;\n\n\tconst contexts = {\n\t\tchat_session: {\n\t\t\tsessionId: context.sessionId ?? null,\n\t\t\tsessionOwnerId: context.sessionOwnerId ?? null,\n\t\t\texecutionId: context.executionId ?? null,\n\t\t\tagentId: context.agentId ?? null,\n\t\t\tcfRay: context.cfRay ?? null,\n\t\t\tcustomerId: context.customerId ?? null,\n\t\t\tcustomerEmail: context.customerEmail ?? null,\n\t\t},\n\t};\n\n\tif (typeof error === \"string\") {\n\t\tSentry.captureMessage(error, { level: \"error\", tags, contexts });\n\t} else {\n\t\tSentry.captureException(error, { tags, contexts });\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Targeted fetch interceptor for capturing cf-ray headers\n// ---------------------------------------------------------------------------\n\ntype CfRayListener = (cfRay: string) => void;\n\ninterface InterceptorEntry {\n\turlPattern: string;\n\tlistener: CfRayListener;\n}\n\nconst interceptors: Set<InterceptorEntry> = new Set();\nlet originalFetch: typeof globalThis.fetch | null = null;\n\nfunction patchFetch(): void {\n\tif (originalFetch !== null) return;\n\tif (typeof globalThis === \"undefined\" || typeof globalThis.fetch !== \"function\")\n\t\treturn;\n\n\toriginalFetch = globalThis.fetch;\n\n\tglobalThis.fetch = async function (\n\t\tthis: typeof globalThis,\n\t\tinput: RequestInfo | URL,\n\t\tinit?: RequestInit\n\t): Promise<Response> {\n\t\tconst response = await originalFetch!.call(this, input, init);\n\n\t\tif (interceptors.size > 0) {\n\t\t\tconst url =\n\t\t\t\ttypeof input === \"string\"\n\t\t\t\t\t? input\n\t\t\t\t\t: input instanceof URL\n\t\t\t\t\t\t? input.href\n\t\t\t\t\t\t: (input as Request).url;\n\n\t\t\ttry {\n\t\t\t\tconst cfRay = response.headers.get(\"cf-ray\");\n\t\t\t\tif (cfRay) {\n\t\t\t\t\tfor (const entry of interceptors) {\n\t\t\t\t\t\tif (url.includes(entry.urlPattern)) {\n\t\t\t\t\t\t\tentry.listener(cfRay);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// headers may be inaccessible on opaque responses\n\t\t\t}\n\t\t}\n\n\t\treturn response;\n\t};\n}\n\nfunction maybeUnpatchFetch(): void {\n\tif (interceptors.size > 0 || originalFetch === null) return;\n\tglobalThis.fetch = originalFetch;\n\toriginalFetch = null;\n}\n\n/**\n * Registers a listener that receives the `cf-ray` header value whenever a\n * fetch response URL contains `urlPattern`.\n *\n * Returns an unsubscribe function (call on unmount).\n */\nexport function subscribeToCfRay(\n\turlPattern: string,\n\tlistener: CfRayListener\n): () => void {\n\tconst entry: InterceptorEntry = { urlPattern, listener };\n\tpatchFetch();\n\tinterceptors.add(entry);\n\treturn () => {\n\t\tinterceptors.delete(entry);\n\t\tmaybeUnpatchFetch();\n\t};\n}\n"]}