@mgamadeus/ddd-agents 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -8
- package/boundary.json +15 -1
- package/dist/admin-chat-widgets.js +158 -0
- package/dist/admin-chat-widgets.js.map +1 -0
- package/dist/admin.js +90 -63
- package/dist/admin.js.map +1 -1
- package/dist/chat.js +16 -16
- package/dist/chat.js.map +1 -1
- package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js +304 -0
- package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js.map +1 -0
- package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js → ConversationMarkdown-W8NzeAT1.js} +5 -5
- package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js.map → ConversationMarkdown-W8NzeAT1.js.map} +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js → ConversationMessageInputComposerWidgets-BH7axorv.js} +6 -6
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js.map → ConversationMessageInputComposerWidgets-BH7axorv.js.map} +1 -1
- package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js → VoiceBarsIcon-CT2HQSBH.js} +4 -4
- package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js.map → VoiceBarsIcon-CT2HQSBH.js.map} +1 -1
- package/dist/chunks/{WebSearchResultsConversationWidget-l9Aek_lG.js → WebSearchResultsConversationWidget-BM624Fcx.js} +71 -62
- package/dist/chunks/WebSearchResultsConversationWidget-BM624Fcx.js.map +1 -0
- package/dist/chunks/{agents-http-trace-mappers-rsbGAf2_.js → agents-http-trace-mappers-CuGZOFu-.js} +53 -14
- package/dist/chunks/agents-http-trace-mappers-CuGZOFu-.js.map +1 -0
- package/dist/chunks/{browser-request-interception-D678IemW.js → browser-request-interception-BnOQWLaJ.js} +2 -2
- package/dist/chunks/{browser-request-interception-D678IemW.js.map → browser-request-interception-BnOQWLaJ.js.map} +1 -1
- package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js → canvas-label-context-BKRsrpye.js} +3 -3
- package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js.map → canvas-label-context-BKRsrpye.js.map} +1 -1
- package/dist/chunks/{canvas-reducers-BYArW_Ji.js → canvas-reducers-CZaOPvdt.js} +2 -2
- package/dist/chunks/{canvas-reducers-BYArW_Ji.js.map → canvas-reducers-CZaOPvdt.js.map} +1 -1
- package/dist/chunks/{canvasBodies-BpLPp-S8.js → canvasBodies-CMqo5eHg.js} +4 -4
- package/dist/chunks/{canvasBodies-BpLPp-S8.js.map → canvasBodies-CMqo5eHg.js.map} +1 -1
- package/dist/chunks/{canvasStorage-DSspwRMg.js → canvasStorage-ceJ7yaBd.js} +2 -2
- package/dist/chunks/{canvasStorage-DSspwRMg.js.map → canvasStorage-ceJ7yaBd.js.map} +1 -1
- package/dist/chunks/{content-from-unified-diff-DWyBHRSy.js → content-from-unified-diff-BKdgop63.js} +39 -5
- package/dist/chunks/content-from-unified-diff-BKdgop63.js.map +1 -0
- package/dist/chunks/{contract-DtFmOk91.js → contract-CQ6PO_e8.js} +2 -2
- package/dist/chunks/{contract-DtFmOk91.js.map → contract-CQ6PO_e8.js.map} +1 -1
- package/dist/chunks/{conversation-Cbrqtx-_.js → conversation-VosmRbsr.js} +4 -2
- package/dist/chunks/{conversation-Cbrqtx-_.js.map → conversation-VosmRbsr.js.map} +1 -1
- package/dist/chunks/conversation-trace-fVeh6Lg6.js.map +1 -1
- package/dist/chunks/{widget-name-resolver-DXIE9JUr.js → conversationWidgetRegistry-BW-U_RvC.js} +810 -530
- package/dist/chunks/conversationWidgetRegistry-BW-U_RvC.js.map +1 -0
- package/dist/chunks/{index-DZovGMpG.js → index-DAEGct6X.js} +61 -61
- package/dist/chunks/index-DAEGct6X.js.map +1 -0
- package/dist/chunks/{link-navigation-a_sRfmsj.js → link-navigation-DQWyeNkx.js} +2 -2
- package/dist/chunks/{link-navigation-a_sRfmsj.js.map → link-navigation-DQWyeNkx.js.map} +1 -1
- package/dist/chunks/{withPollingChangeSubscription-Cz3Diolr.js → withPollingChangeSubscription-Ct8kjmlL.js} +19 -2
- package/dist/chunks/withPollingChangeSubscription-Ct8kjmlL.js.map +1 -0
- package/dist/client-testing.js +39 -5
- package/dist/client-testing.js.map +1 -1
- package/dist/client.js +43 -14
- package/dist/client.js.map +1 -1
- package/dist/contract.js +4 -3
- package/dist/files/i18n-keys.json +619 -15
- package/dist/files/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.md +4 -2
- package/dist/files/widgets/OwnerStepConfirmationConversationWidget/OwnerStepConfirmationConversationWidget.md +54 -0
- package/dist/files/widgets/OwnerStepConfirmationConversationWidget/owner-step-confirmation.preview-fixtures.json +16 -0
- package/dist/image-render.js +8 -8
- package/dist/index.js +16 -16
- package/dist/kit.js +2 -2
- package/dist/preview.js +124 -117
- package/dist/preview.js.map +1 -1
- package/dist/provider.js +2 -2
- package/dist/renderer.js +53 -52
- package/dist/styles.css +46 -0
- package/dist/types/admin/schedules/AgentScheduleOrderDraftPanel.d.ts +45 -0
- package/dist/types/admin/schedules/AgentSchedulesPanel.d.ts +11 -3
- package/dist/types/admin/schedules/agent-schedules-api.d.ts +38 -2
- package/dist/types/admin/schedules/agent-schedules-format.d.ts +22 -1
- package/dist/types/admin/schedules/agent-schedules-types.d.ts +91 -1
- package/dist/types/admin-chat-widgets/ScheduleOrderApprovalConversationWidget.d.ts +37 -0
- package/dist/types/admin-chat-widgets/registerScheduleOrderApprovalWidget.d.ts +11 -0
- package/dist/types/chat/trace/TurnMetaLine.d.ts +5 -3
- package/dist/types/chat/trace/trace-counts.d.ts +2 -0
- package/dist/types/chat/trace/trace-types.d.ts +4 -0
- package/dist/types/client/AgentsConversationClient.d.ts +17 -1
- package/dist/types/client/http/agents-http-mappers.d.ts +4 -2
- package/dist/types/client/http/agents-http-trace-wire.d.ts +2 -0
- package/dist/types/client/http/agents-http-wire.d.ts +24 -0
- package/dist/types/client/testing/createInMemoryAgentsConversationClient.d.ts +13 -1
- package/dist/types/contract/conversation-trace.d.ts +4 -0
- package/dist/types/contract/conversation.d.ts +43 -0
- package/dist/types/entries/admin-chat-widgets.d.ts +2 -0
- package/dist/types/entries/admin.d.ts +4 -2
- package/dist/types/entries/renderer.d.ts +1 -1
- package/dist/types/renderer/widget-tree/composed-node-schema.d.ts +20 -3
- package/dist/types/widgets/DriveFilesConversationWidget/shared/drive-files.d.ts +3 -1
- package/dist/voice.js +2 -2
- package/dist/widgets.js +4 -4
- package/package.json +7 -1
- package/public-api.json +39 -0
- package/dist/chunks/WebSearchResultsConversationWidget-l9Aek_lG.js.map +0 -1
- package/dist/chunks/agents-http-trace-mappers-rsbGAf2_.js.map +0 -1
- package/dist/chunks/content-from-unified-diff-DWyBHRSy.js.map +0 -1
- package/dist/chunks/index-DZovGMpG.js.map +0 -1
- package/dist/chunks/widget-name-resolver-DXIE9JUr.js.map +0 -1
- package/dist/chunks/withPollingChangeSubscription-Cz3Diolr.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { r as Text, F as escapePlainTextForText, E as classNames, I as Icon, a4 as useAgentsEnvironment, B as Button } from "./index-
|
|
3
|
+
import { r as Text, F as escapePlainTextForText, E as classNames, I as Icon, a4 as useAgentsEnvironment, B as Button } from "./index-DAEGct6X.js";
|
|
4
4
|
import { useMemo, useState, useRef, useCallback, useEffect, useContext, useLayoutEffect, memo } from "react";
|
|
5
|
-
import { f as findBalancedJsonObjectEnd, s as splitComposerWidgetFencesFromMessageText, e as WidgetWindowRootContext, C as ConversationMarkdown } from "./ConversationMarkdown-
|
|
6
|
-
import { W as WIDGET_FENCE_LANG,
|
|
5
|
+
import { f as findBalancedJsonObjectEnd, s as splitComposerWidgetFencesFromMessageText, e as WidgetWindowRootContext, C as ConversationMarkdown } from "./ConversationMarkdown-W8NzeAT1.js";
|
|
6
|
+
import { W as WIDGET_FENCE_LANG, H as resolveWidgetName, j as conversationWidgetRegistry, o as ConversationWidgetErrorBoundary } from "./conversationWidgetRegistry-BW-U_RvC.js";
|
|
7
7
|
const ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
8
8
|
const parseFenceDelimiterLine = (line) => {
|
|
9
9
|
const match = ANY_FENCE_DELIM_LINE.exec(line);
|
|
@@ -640,4 +640,4 @@ export {
|
|
|
640
640
|
ConversationMessageHeader as b,
|
|
641
641
|
normalizeServerMessageToMarkdown as n
|
|
642
642
|
};
|
|
643
|
-
//# sourceMappingURL=VoiceBarsIcon-
|
|
643
|
+
//# sourceMappingURL=VoiceBarsIcon-CT2HQSBH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceBarsIcon-eODB_UTI.js","sources":["../../src/renderer/repair-malformed-widget-fences.ts","../../src/renderer/reference-naked-widget-json.ts","../../src/chat/strip-pre-call-message-marker.ts","../../src/chat/normalize-server-message-to-markdown.ts","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUserWidgets.tsx","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUser.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useTypewriter.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useStreamingText.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useFreshMessageBlockReveal.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageHeader/ConversationMessageHeader.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/copyRichToClipboard.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageWidgets.tsx","../../src/chat/ConversationMessage/ConversationCallMarkerChip/VoiceBarsIcon/VoiceBarsIcon.tsx"],"sourcesContent":["import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { WIDGET_FENCE_LANG } from \"./widget-fence-syntax\";\n\n/**\n * Repair the ```widget fence defects a model produces when it switches into a function call mid-text, or drops a\n * closing fence, or opens a second widget before closing the first (text + fence + tool call\n * in ONE response). A LINE-AWARE pass: CommonMark opens a fence on a line that (after up to 3 spaces of indent)\n * starts with ``` , and closes it only on a line whose sole content — same indent rule — is ``` . Content inside\n * ANY open fence (widget, json, or anything else) is data and is never scanned or touched, so a ``` mentioned\n * inside a JSON string value never gets mistaken for a delimiter.\n *\n * Two repairs, both scoped to the ```widget lang only:\n * 1. A glued opener (```widget stuck to the end of a prose line, so Markdown never recognized it as starting a\n * line) is relocated onto its own line ONLY when a JSON object begins right after it — otherwise the text is\n * left completely untouched (a prose sentence that merely mentions ```widget must not be mangled).\n * 2. An open widget fence with no proper closing-fence LINE before either end-of-text or the next fence-opener\n * line gets a ``` closer spliced in right after its balanced JSON object (string-aware, so a ``` inside a JSON\n * string is never treated as the closer). A widget fence whose body isn't a JSON object at all is left\n * untouched — nothing could safely render there either way, and deleting text is not this function's job.\n *\n * The backend stores the model text as emitted, so this is the ONE place the shape is corrected — for stored\n * history and for every new message alike. Runs before `referenceNakedWidgetJson` so the re-fenced JSON is not\n * wrapped a second time. Pure; well-formed text is returned unchanged.\n */\n\n/** A fence delimiter LINE per CommonMark, either character: up to 3 spaces indent, then a run of 3+ of the same\n * fence character (`` ` `` or `~`), then the rest of the line. Used by {@link findFencedBlockRanges} — the GENERAL\n * \"is this real fence syntax\" question, as opposed to the WIDGET-fence-only scanning above. */\nconst ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;\n\n/** One real fence delimiter: its character, marker length and (trimmed) info string. */\ninterface FenceDelimiter {\n char: \"`\" | \"~\";\n length: number;\n info: string;\n}\n\n/**\n * Parse one line as a CommonMark fence delimiter, or null when it isn't one. A backtick run's info string may not\n * itself contain a backtick — CommonMark's own rule disambiguating a fence opener from an inline code span — so a\n * line such as \"```js `x`\" is not a fence delimiter at all (it never opens or closes anything).\n */\nconst parseFenceDelimiterLine = (line: string): FenceDelimiter | null => {\n const match = ANY_FENCE_DELIM_LINE.exec(line);\n if (!match) return null;\n const marker = match[1];\n const char = marker[0] as \"`\" | \"~\";\n const info = match[2].trim();\n if (char === \"`\" && info.includes(\"`\")) return null;\n return { char, length: marker.length, info };\n};\n\nconst isWidgetFenceInfo = (info: string): boolean => new RegExp(`^${WIDGET_FENCE_LANG}\\\\b`).test(info.trim());\n\n/** A ```widget opener anywhere in the text, glued or not — built from the shared lang constant. */\nconst widgetOpenerPattern = (): RegExp => new RegExp(\"```[ \\\\t]*\" + WIDGET_FENCE_LANG + \"\\\\b\");\n\n/** One line of `text` starting at `lineStart`: its content (terminator excluded — a trailing `\\r` of a CRLF\n * line ending is stripped too, so a delimiter regex's `.` never has to account for it) and the index right after\n * the line INCLUDING its terminator (or `text.length` at end-of-text). */\nconst readLine = (text: string, lineStart: number): { content: string; afterLine: number } => {\n const newlineIndex = text.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? text.length : newlineIndex;\n const afterLine = newlineIndex === -1 ? text.length : newlineIndex + 1;\n const rawContent = text.slice(lineStart, lineEnd);\n return { content: rawContent.endsWith(\"\\r\") ? rawContent.slice(0, -1) : rawContent, afterLine };\n};\n\n/**\n * Scan forward from `bodyStart` for a line that CLOSES the given opener: same fence character, a marker run at\n * least as long as the opener's, and nothing but whitespace after it (CommonMark's closing-fence rule). Unclosed →\n * end-of-text.\n */\nconst findClosingFenceEnd = (text: string, bodyStart: number, opener: FenceDelimiter): number => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === opener.char && delimiter.length >= opener.length && delimiter.info === \"\") {\n return afterLine;\n }\n cursor = afterLine;\n }\n return text.length;\n};\n\n/**\n * The `[start, end)` ranges of every REAL fenced code block in `text` — ``` or ~~~, CommonMark's own rules (up to\n * 3 spaces of indent, a closer using the same character with a run at least as long as the opener's, a backtick\n * opener's info string never containing a backtick). An unclosed opener runs to end-of-text. The GENERAL-PURPOSE\n * counterpart of this file's widget-fence-only scanning, built on the same {@link readLine} line walk — used by\n * `referenceNakedWidgetJson` to skip content genuinely inside a fence: a `~~~widget` fence (no tilde support\n * existed before), and content that follows a line which LOOKS like a backtick fence opener but isn't one per the\n * info-string rule above (that line never opens anything, so it can no longer swallow the real fence after it).\n */\nexport const findFencedBlockRanges = (text: string): Array<[number, number]> => {\n const ranges: Array<[number, number]> = [];\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const opener = parseFenceDelimiterLine(content);\n if (opener) {\n const end = findClosingFenceEnd(text, afterLine, opener);\n ranges.push([cursor, end]);\n cursor = end;\n continue;\n }\n cursor = afterLine;\n }\n return ranges;\n};\n\n/**\n * Scan forward from `bodyStart` (right after a fence opener line) for the next LINE-anchored BACKTICK fence\n * delimiter (via {@link parseFenceDelimiterLine} — the same CommonMark rules `findFencedBlockRanges` uses, so a\n * line like \"```js `x`\" — an invalid info string, not a fence delimiter at all — is correctly skipped as plain\n * content rather than mistaken for one): a proper closing line (empty info) closes the fence normally; any other\n * delimiter line (another opener, any lang) is the boundary where this fence gave up without closing. Neither\n * found before end-of-text → unclosed at EOF.\n */\nconst findFenceEnd = (text: string, bodyStart: number): { closesAt: number } | { unclosedBoundary: number } => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n return delimiter.info === \"\" ? { closesAt: afterLine } : { unclosedBoundary: cursor };\n }\n cursor = afterLine;\n }\n return { unclosedBoundary: text.length };\n};\n\n/**\n * Resolve an OPEN widget fence's body starting at `bodyStart`: verbatim through a real closing-fence line when one\n * exists before end-of-text or the next fence-opener line; otherwise a ``` closer spliced in right after the\n * balanced JSON object; or, when the body isn't a JSON object at all, everything to end-of-text left untouched.\n */\nconst closeWidgetFenceBody = (text: string, bodyStart: number): { appended: string; resumeAt: number } => {\n const end = findFenceEnd(text, bodyStart);\n if (\"closesAt\" in end) {\n return { appended: text.slice(bodyStart, end.closesAt), resumeAt: end.closesAt };\n }\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, bodyStart);\n if (jsonObjectEnd === null) {\n return { appended: text.slice(bodyStart), resumeAt: text.length };\n }\n return { appended: text.slice(bodyStart, jsonObjectEnd + 1) + \"\\n```\", resumeAt: jsonObjectEnd + 1 };\n};\n\nexport const repairMalformedWidgetFences = (text: string): string => {\n if (!widgetOpenerPattern().test(text)) return text;\n\n let result = \"\";\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n\n // Backtick fences only here (tilde ```widget``` has no repair path, same as before): a line whose backtick\n // run's info string itself contains a backtick (e.g. \"```js `x`\") is not a fence delimiter at all per\n // CommonMark, so it falls through to the glued-opener check / plain-text copy below, never swallowing a real\n // ```widget fence that follows it as a bogus \"other fence\".\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n const info = delimiter.info;\n if (info !== \"\" && isWidgetFenceInfo(info)) {\n result += content + text.slice(cursor + content.length, afterLine); // the opener line, verbatim\n const { appended, resumeAt } = closeWidgetFenceBody(text, afterLine);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n if (info !== \"\") {\n // Some other fenced language: copy its whole body through untouched — never scanned for a widget opener,\n // so a widget-fence mention inside a JSON string value in THIS fence's content is never touched (a widget\n // fence itself can't legally start inside an already-open fence either way).\n const otherFenceEnd = findFenceEnd(text, afterLine);\n const bodyEnd = \"closesAt\" in otherFenceEnd ? otherFenceEnd.closesAt : text.length;\n result += text.slice(cursor, bodyEnd);\n cursor = bodyEnd;\n continue;\n }\n }\n\n // Not a fence-delimiter line: a glued opener (the fence's backticks stuck to the end of prose). Relocate onto\n // its own line ONLY when a JSON object begins right after it; a prose line that merely mentions ```widget with\n // nothing to render is left completely untouched.\n const gluedMatch = widgetOpenerPattern().exec(content);\n if (gluedMatch && gluedMatch.index > 0 && content.slice(0, gluedMatch.index).trim() !== \"\") {\n const bodyStart = afterLine;\n if (findBalancedJsonObjectEnd(text, bodyStart) !== null) {\n const openerLine = content.slice(gluedMatch.index) + text.slice(cursor + content.length, afterLine);\n result += content.slice(0, gluedMatch.index) + \"\\n\" + openerLine;\n const { appended, resumeAt } = closeWidgetFenceBody(text, bodyStart);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n }\n\n result += text.slice(cursor, afterLine);\n cursor = afterLine;\n }\n return result;\n};\n","import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { findFencedBlockRanges } from \"./repair-malformed-widget-fences\";\nimport { resolveWidgetName } from \"./widget-name-resolver\";\n\n/**\n * Weak models (Gemini-3.5-Flash) intermittently emit a widget as a NAKED JSON line —\n * `{ \"type\": \"ExampleWidget\" }` — without the ```widget fence the skills instruct. Such a line is not rendered\n * by remarkWidgetFencePlugin (no fence) and not by the bare-line path (no `widget` prefix), so the customer sees raw\n * JSON. `detectUnrenderedWidgets` only DETECTS this (to corrective-signal the model); here we RENDER it: wrap a naked\n * line-starting JSON object whose `type` resolves to a REGISTERED widget in a ```widget fence, so the plugin renders\n * it — no model round-trip, the customer never sees JSON. UNKNOWN types are left untouched (the corrective-signal\n * path still handles `type: \"example\"` → suggest `ExampleWidget`).\n *\n * Fence-aware: JSON already inside any REAL fenced block (``` or ~~~, CommonMark rules — see\n * `findFencedBlockRanges`) is skipped (never double-fenced). Uses the SAME resolveWidgetName as the render plugin +\n * the detector, so \"would render\" is decided in one place.\n */\n\n/** A line-starting balanced { … } JSON object and its [start, end) span in the source text. */\ninterface JsonSpan {\n json: string;\n start: number;\n end: number;\n}\n\n/**\n * Scan line-starting balanced `{ … }` JSON objects (string-aware brace walk), returning each with its span. Mirrors\n * detect-unrendered-widgets' `extractNakedJsonCandidates`, but keeps offsets so the object can be replaced in place.\n */\nconst scanLineStartingJsonSpans = (text: string): JsonSpan[] => {\n const spans: JsonSpan[] = [];\n const lines = text.split(\"\\n\");\n let offset = 0;\n for (const line of lines) {\n const lineStart = offset;\n offset += line.length + 1;\n if (!line.trimStart().startsWith(\"{\")) continue;\n const openIndex = lineStart + line.indexOf(\"{\");\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, openIndex);\n if (jsonObjectEnd !== null) {\n spans.push({ json: text.slice(openIndex, jsonObjectEnd + 1), start: openIndex, end: jsonObjectEnd + 1 });\n }\n }\n return spans;\n};\n\n/** The string `type` of a JSON object, or null when it is not an object with a non-empty string `type`. */\nconst widgetTypeOf = (jsonCandidate: string): string | null => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(jsonCandidate);\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null) return null;\n const type = (parsed as Record<string, unknown>).type;\n return typeof type === \"string\" && type !== \"\" ? type : null;\n};\n\nexport const referenceNakedWidgetJson = (text: string): string => {\n if (!text.includes('\"type\"')) return text;\n\n const fencedRanges = findFencedBlockRanges(text);\n const isInsideFence = (position: number) => fencedRanges.some(([start, end]) => position >= start && position < end);\n\n // Right-to-left so each replacement leaves the earlier spans' offsets valid.\n const spans = scanLineStartingJsonSpans(text)\n .filter((span) => !isInsideFence(span.start))\n .reverse();\n\n let result = text;\n for (const span of spans) {\n const type = widgetTypeOf(span.json);\n if (type === null || resolveWidgetName(type) === undefined) continue; // unknown → leave for the corrective signal\n const fencedBlock = \"```widget\\n\" + span.json + \"\\n```\";\n result = result.slice(0, span.start) + fencedBlock + result.slice(span.end);\n }\n return result;\n};\n","/**\n * Mirrors `AIConversationMessage::PRE_CALL_MESSAGE_MARKER` (PHP). The model prefixes a short \"I'm about to do X\"\n * status line with this sentinel; the BACKEND only detects/signals on it and stores it RAW (it never strips). Every\n * render layer — this is the customer chat one — strips it before showing the text to the user.\n */\nexport const PRE_CALL_MESSAGE_MARKER = \"{preCallMessage}\";\n\n/**\n * The MANGLED JSON form some models emit instead of the sentinel (Gemini 3.5 Flash): the status line\n * arrives as `{ \"preCallMessage\": \"…\" }<` — optionally with extra fields and/or a trailing `<|im_call:…` pseudo call\n * marker — fused into the assistant text. Normalized to the inner status text so the user never sees raw JSON.\n * Mirrors the PHP normalization in `AIConversationMessage::stripPreCallMessageMarker`.\n */\nconst MANGLED_PRE_CALL_RE = /\\{\\s*\"preCallMessage\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*,?\\s*[^}]*\\}\\s*(?:<\\S*)?/g;\n\n/**\n * Remove the {preCallMessage} sentinel from assistant text before display, and normalize the mangled JSON form to\n * its inner status line. Also holds back a leading PARTIAL of either shape while it is still streaming in (so the\n * user never sees a \"{preCa…\" or `{ \"preCallMessage\": \"Einen Mo` flash before the full form arrives).\n */\nexport const stripPreCallMessageMarker = (text: string): string => {\n if (!text) return text;\n const leading = text.replace(/^\\s+/, \"\");\n // The sentinel itself is still streaming (nothing after it yet) → render nothing until real content arrives.\n if (leading.length < PRE_CALL_MESSAGE_MARKER.length && PRE_CALL_MESSAGE_MARKER.startsWith(leading)) return \"\";\n // The mangled JSON form is still streaming (opened but not yet closed) → hold it back the same way.\n const mangledPrefix = '{ \"preCallMessage\"';\n const normalizedLeading = leading.replace(/\\s+/g, \" \");\n if (\n (normalizedLeading.length < mangledPrefix.length && mangledPrefix.startsWith(normalizedLeading)) ||\n (normalizedLeading.startsWith(mangledPrefix) && !normalizedLeading.includes(\"}\"))\n ) {\n return \"\";\n }\n const withMangledNormalized = text.replace(MANGLED_PRE_CALL_RE, (_match, escapedStatusLine: string) => {\n try {\n return JSON.parse(`\"${escapedStatusLine}\"`) as string;\n } catch {\n return escapedStatusLine;\n }\n });\n const withMarkerRemoved = withMangledNormalized.split(PRE_CALL_MESSAGE_MARKER).join(\"\");\n // The marker (or its mangled form) sits at the very start, after only whitespace → that whitespace was there\n // only to separate it from the rest of the text and is removed along with it. Anything else — a message that\n // never carried the marker there at all — keeps its OWN leading whitespace untouched, so a four-space-indented\n // code block at the start of a message stays indented (plain CommonMark code) instead of sliding to column 0\n // and becoming a widget fence.\n const markerWasLeading = leading.startsWith(PRE_CALL_MESSAGE_MARKER) || normalizedLeading.startsWith(mangledPrefix);\n return markerWasLeading ? withMarkerRemoved.replace(/^\\s+/, \"\") : withMarkerRemoved;\n};\n","import { referenceNakedWidgetJson } from \"../renderer/reference-naked-widget-json\";\nimport { repairMalformedWidgetFences } from \"../renderer/repair-malformed-widget-fences\";\n\nimport { stripPreCallMessageMarker } from \"./strip-pre-call-message-marker\";\n\ntype ServerTextPart = { type: \"text\"; text?: string };\n\ntype ServerComponentPart = {\n type: \"component\";\n name?: string;\n props?: Record<string, unknown>;\n};\n\ntype ServerToolUsePart = {\n type: \"tool_use\";\n name?: string;\n input?: unknown;\n};\n\ntype ServerMessagePart = ServerTextPart | ServerComponentPart | ServerToolUsePart;\n\nexport type AssistantServerMessagePayload = {\n role?: string;\n content?: ServerMessagePart[];\n parts?: ServerMessagePart[];\n messageId?: string;\n};\n\nconst WIDGET_ATTR_KEY = /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst isTextPart = (part: unknown): part is ServerTextPart => isRecord(part) && part.type === \"text\";\n\nconst isComponentPart = (part: unknown): part is ServerComponentPart =>\n isRecord(part) && part.type === \"component\" && typeof part.name === \"string\" && part.name.length > 0;\n\nconst isToolUsePart = (part: unknown): part is ServerToolUsePart => isRecord(part) && part.type === \"tool_use\";\n\nconst isMessagePart = (part: unknown): part is ServerMessagePart =>\n isTextPart(part) || isComponentPart(part) || isToolUsePart(part);\n\nconst isPayload = (value: unknown): value is AssistantServerMessagePayload => {\n if (!isRecord(value)) return false;\n const parts = value.content ?? value.parts;\n return Array.isArray(parts) && parts.every(isMessagePart);\n};\n\n/**\n * The model occasionally emits a single part object instead of an array\n * ({\"content\":{\"type\":\"text\",...}}). Coerce it so the message still renders.\n */\nconst coerceSinglePartPayload = (value: unknown): AssistantServerMessagePayload | null => {\n if (!isRecord(value)) return null;\n const part = value.content ?? value.parts;\n if (!isMessagePart(part)) return null;\n const rest = { ...value };\n delete rest.parts;\n return { ...rest, content: [part] };\n};\n\nconst encodeAttrValue = (value: unknown) => JSON.stringify(value).replace(/'/g, \"\\\\u0027\");\n\nconst propsToAttrs = (props: Record<string, unknown>) =>\n Object.entries(props)\n .filter(([key, value]) => value !== undefined && WIDGET_ATTR_KEY.test(key))\n .map(([key, value]) => `${key}='${encodeAttrValue(value)}'`)\n .join(\" \");\n\nconst componentPartToWidget = (part: ServerComponentPart) => {\n const attrs = propsToAttrs(part.props ?? {});\n return attrs ? `::${part.name}{${attrs}}` : `::${part.name}`;\n};\n\nconst toolUsePartToWidget = (part: ServerToolUsePart) => {\n const payload = encodeAttrValue({ name: part.name, input: part.input });\n return `::ToolTrace{payload='${payload}'}`;\n};\n\nconst partToMarkdown = (part: ServerMessagePart) => {\n if (isTextPart(part)) return part.text?.trim() ?? \"\";\n if (isToolUsePart(part)) return toolUsePartToWidget(part);\n return componentPartToWidget(part);\n};\n\nconst payloadToMarkdown = (payload: AssistantServerMessagePayload) => {\n return (payload.content ?? payload.parts ?? []).map(partToMarkdown).filter(Boolean).join(\"\\n\\n\");\n};\n\nconst tryParsePayload = (value: string): AssistantServerMessagePayload | null => {\n try {\n const parsed = JSON.parse(value) as unknown;\n return isPayload(parsed) ? parsed : coerceSinglePartPayload(parsed);\n } catch {\n return null;\n }\n};\n\nexport const normalizeServerMessageToMarkdown = (message: unknown): string => {\n let result: string;\n if (typeof message === \"string\") {\n const parsed = tryParsePayload(message);\n result = parsed ? payloadToMarkdown(parsed) : message;\n } else if (isPayload(message)) {\n result = payloadToMarkdown(message);\n } else {\n const coerced = coerceSinglePartPayload(message);\n if (coerced) {\n result = payloadToMarkdown(coerced);\n } else {\n console.warn(\"[AIExtensions] normalizeServerMessageToMarkdown: unrecognized message shape\", message);\n result = \"\";\n }\n }\n // The backend stores the {preCallMessage} status-line sentinel raw (it only detects/signals on it) — strip it here.\n // Then repair a ```widget fence the model broke mid-text (opener glued to the prose line / never closed — the model\n // switched into a tool call), then re-fence any naked widget JSON (a weak model emitted\n // `{ \"type\": \"ExampleWidget\" }` without a ```widget fence): wrapping a known widget type lets\n // remarkWidgetFencePlugin render it, so the customer never sees raw JSON.\n return referenceNakedWidgetJson(repairMalformedWidgetFences(stripPreCallMessageMarker(result)));\n};\n","import React from \"react\";\nimport { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationWidgetErrorBoundary } from \"../../../renderer/ConversationWidgetErrorBoundary\";\n\nexport interface ConversationMessageUserWidgetsProps {\n /** Composer-widget fences extracted from the customer's own message text (see `splitComposerWidgetFencesFromMessageText`). */\n widgets: ConversationComposerWidget[];\n}\n\n/**\n * Read-only echo of the composer widgets the customer sent inside their OWN message — rendered above the prose. Reuses each widget's registered message `component` (the same one an\n * assistant reply would mount via the remark pipeline) directly with the fence's fields as `payload` — NOT the\n * remark/markdown pipeline itself, which never runs for user text (interpreting the customer's own prose as\n * Markdown would change every user bubble). `fresh={false}`: this is always a replay of content already sent, never\n * a live delivery. Each widget renders inside its own `ConversationWidgetErrorBoundary` so a malformed fence never\n * blanks the whole bubble.\n */\nexport const ConversationMessageUserWidgets = (props: ConversationMessageUserWidgetsProps) => {\n const { widgets } = props;\n\n if (widgets.length === 0) return null;\n\n return (\n <>\n {widgets.map((widget) => {\n const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);\n if (!entry) return null;\n const Component = entry.component;\n return (\n <ConversationWidgetErrorBoundary key={widget.composerWidgetId} widgetName={entry.name}>\n <Component payload={JSON.stringify(widget.fields)} fresh={false} />\n </ConversationWidgetErrorBoundary>\n );\n })}\n </>\n );\n};\n","import { Text } from \"../../../provider/components\";\nimport React, { useMemo } from \"react\";\nimport { classNames } from \"../../../provider/class-names\";\nimport { escapePlainTextForText } from \"../../../provider/environment\";\nimport styles from \"./ConversationMessageUser.module.scss\";\nimport { splitComposerWidgetFencesFromMessageText } from \"../../../renderer/composer-widget-fence\";\nimport type { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationMessageUserWidgets } from \"./ConversationMessageUserWidgets\";\n\nexport type ConversationMessageUserTheme = \"default\" | \"light\" | \"dark\" | \"primary\";\n\nexport interface ConversationMessageUserProps {\n text: string;\n theme?: ConversationMessageUserTheme;\n /** @deprecated Never read: a customer message looks the same in every chat. Kept so existing callers compile. */\n isGenericChat?: boolean;\n}\n\n/** True when the widget's registry entry shows its echo on its own above the bubble (e.g. attached images). */\nconst isShownAboveBubble = (widget: ConversationComposerWidget): boolean =>\n conversationWidgetRegistry.widgets.find((entry) => entry.name === widget.widgetName)?.customerMessagePlacement ===\n \"aboveBubble\";\n\nexport const ConversationMessageUser = (props: ConversationMessageUserProps) => {\n const { text, theme = \"default\" } = props;\n\n // Pull any registered composer-widget fences out of the customer's own message text so they render as\n // read-only widgets above the prose, exactly like the assistant-side remark pipeline renders them in a reply —\n // but WITHOUT running that pipeline over user text (never treat the customer's own prose as Markdown).\n // The prose is the customer's own text: it reaches the text component as plain text (`escapePlainTextForText`), so\n // an app's text component that reads a string as markup shows it as written.\n const { text: proseText, widgets } = useMemo(() => splitComposerWidgetFencesFromMessageText(text), [text]);\n const widgetsAboveBubble = useMemo(() => widgets.filter(isShownAboveBubble), [widgets]);\n const widgetsInsideBubble = useMemo(() => widgets.filter((widget) => !isShownAboveBubble(widget)), [widgets]);\n\n const bubbleClass =\n theme === \"light\"\n ? styles.whiteBubble\n : theme === \"dark\"\n ? styles.darkBubble\n : theme === \"primary\"\n ? styles.primaryBubble\n : undefined;\n\n const textColor =\n theme === \"light\"\n ? \"var(--agents-fg)\"\n : theme === \"dark\"\n ? \"var(--agents-chat-user-bubble-text)\"\n : \"var(--agents-fg-on-accent)\";\n\n const bubble = (\n <div className={classNames(styles.message, bubbleClass)} data-testid=\"chat-message-user\">\n <ConversationMessageUserWidgets widgets={widgetsInsideBubble} />\n {/* A widget-only message (e.g. images sent without text) has no prose line to render. */}\n {proseText !== \"\" && (\n <Text testId=\"conversation-message-user-text\" allowNewLines translate={false} color={textColor}>\n {escapePlainTextForText(proseText)}\n </Text>\n )}\n </div>\n );\n\n if (widgetsAboveBubble.length === 0) return bubble;\n\n // Widgets placed above the bubble (e.g. attached images) stand on their own, right-aligned; a message that is nothing\n // but such widgets shows no bubble at all.\n return (\n <div className={styles.messageWithWidgetsAboveBubble}>\n <ConversationMessageUserWidgets widgets={widgetsAboveBubble} />\n {(proseText !== \"\" || widgetsInsideBubble.length > 0) && bubble}\n </div>\n );\n};\n","import { useRef, useState, useCallback } from \"react\";\n\ninterface UseTypewriterOptions {\n // Characters per second to reveal\n speed?: number;\n // Minimum interval between UI commits (ms) to reduce re-renders\n commitIntervalMs?: number;\n}\n\nexport const useTypewriter = (options: UseTypewriterOptions = {}) => {\n const { speed = 200, commitIntervalMs = 50 } = options;\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [isFinished, setIsFinished] = useState<boolean>(false);\n\n const fullTextRef = useRef<string>(\"\");\n const typeRAFRef = useRef<number | null>(null);\n const lastTimestampRef = useRef<number | null>(null);\n const renderedLengthRef = useRef<number>(0);\n const speedRef = useRef<number>(speed);\n const commitIntervalRef = useRef<number>(commitIntervalMs);\n const lastCommitTsRef = useRef<number>(0);\n\n const startTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) return; // already running\n if (renderedLengthRef.current >= fullTextRef.current.length) return; // nothing to render\n\n const animate = (timestamp: number) => {\n if (lastTimestampRef.current === null) {\n lastTimestampRef.current = timestamp;\n }\n\n const elapsedSeconds = (timestamp - lastTimestampRef.current) / 1000;\n lastTimestampRef.current = timestamp;\n\n const charactersToAdd = Math.max(1, Math.floor(elapsedSeconds * speedRef.current));\n const nextLength = Math.min(fullTextRef.current.length, renderedLengthRef.current + charactersToAdd);\n\n renderedLengthRef.current = nextLength;\n\n // Only commit to React state at most every commitIntervalMs or when finished\n if (\n timestamp - lastCommitTsRef.current >= commitIntervalRef.current ||\n nextLength === fullTextRef.current.length\n ) {\n const nextText = fullTextRef.current.slice(0, nextLength);\n setDisplayedText(nextText);\n lastCommitTsRef.current = timestamp;\n }\n\n if (nextLength < fullTextRef.current.length) {\n typeRAFRef.current = requestAnimationFrame(animate);\n } else {\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n setIsFinished(true);\n }\n };\n\n typeRAFRef.current = requestAnimationFrame(animate);\n }, []);\n\n const appendText = useCallback(\n (text: string) => {\n if (!text) return;\n fullTextRef.current += text;\n setIsFinished(false);\n startTypewriter();\n },\n [startTypewriter],\n );\n\n const stopTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) {\n cancelAnimationFrame(typeRAFRef.current);\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n }\n }, []);\n\n const finishTypewriter = useCallback(() => {\n stopTypewriter();\n setDisplayedText(fullTextRef.current);\n renderedLengthRef.current = fullTextRef.current.length;\n setIsFinished(true);\n }, [stopTypewriter]);\n\n return {\n displayedText,\n appendText,\n stopTypewriter,\n finishTypewriter,\n isFinished,\n };\n};\n","import { useEffect, useRef, useCallback } from \"react\";\n\ninterface UseStreamingTextOptions {\n eventSource?: EventSource;\n onTextChunk?: (chunk: string) => void;\n onError?: () => void;\n onDone?: () => void;\n}\n\nexport const useStreamingText = ({ eventSource, onTextChunk, onError, onDone }: UseStreamingTextOptions) => {\n const bufferRef = useRef<string>(\"\");\n const flushRAFRef = useRef<number | null>(null);\n\n const onTextChunkRef = useRef<typeof onTextChunk>(null);\n const onErrorRef = useRef<typeof onError>(null);\n const onDoneRef = useRef<typeof onDone>(null);\n onTextChunkRef.current = onTextChunk;\n onErrorRef.current = onError;\n onDoneRef.current = onDone;\n\n const flushBuffer = useCallback(() => {\n flushRAFRef.current = null;\n if (!bufferRef.current) return;\n\n const chunk = bufferRef.current;\n bufferRef.current = \"\";\n onTextChunkRef.current?.(chunk);\n }, []);\n\n const finish = useCallback(() => {\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n flushBuffer();\n onDoneRef.current?.();\n }, [flushBuffer]);\n\n const handleMessage = useCallback(\n (event: MessageEvent) => {\n // OpenAI Chat Completions terminator\n if (event.data === \"[DONE]\") {\n finish();\n return;\n }\n\n try {\n const parsed = JSON.parse(event.data);\n\n // Chat Completions streaming delta\n const piece =\n parsed?.choices?.[0]?.delta?.content ??\n // fallback: support simple formats too\n (typeof parsed === \"string\" ? parsed : (parsed?.text ?? \"\"));\n\n // Some servers send a final frame with finish_reason\n const finishReason = parsed?.choices?.[0]?.finish_reason;\n\n if (piece) {\n bufferRef.current += piece;\n if (flushRAFRef.current === null) {\n flushRAFRef.current = requestAnimationFrame(flushBuffer);\n }\n }\n\n if (finishReason === \"stop\") {\n finish();\n }\n } catch (error) {\n console.error(\"Error parsing SSE message:\", error, event.data);\n onErrorRef.current?.();\n }\n },\n [flushBuffer, finish],\n );\n\n const handleError = useCallback(() => {\n onErrorRef.current?.();\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n }, [flushBuffer]);\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !eventSource) return;\n\n eventSource.addEventListener(\"message\", handleMessage);\n eventSource.addEventListener(\"error\", handleError);\n\n return () => {\n eventSource.removeEventListener(\"message\", handleMessage);\n eventSource.removeEventListener(\"error\", handleError);\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n };\n }, [eventSource, handleMessage, handleError, flushBuffer]);\n};\n","import { RefObject, useContext, useLayoutEffect } from \"react\";\nimport { WidgetWindowRootContext } from \"../../../../renderer/widget-windowing\";\n\n/**\n * Fade a freshly-delivered assistant reply's rendered block elements in, one after another, instead of\n * popping the whole wall of text in at once. The reveal operates on the DOM blocks the markdown renderer\n * already produces (the direct children of the `[data-markdown-blocks-root]` div that is containerRef's\n * DIRECT child — nested Markdown instances rendered by widgets stamp the same attribute deeper\n * down and must not be picked up) — the markdown string is never split, so code fences, tables, nested\n * lists, and widgets are handled uniformly.\n *\n * - Blocks in view on arrival (tested against the FULL viewport, edge to edge): a quick staggered fade-in\n * (STAGGER_STEP_MS apart, capped at STAGGER_CAP_MS; each block fades over the faster INITIAL_FADE_MS set\n * inline) — the visible screen fills with text down to the bottom edge fast, no hidden band at the bottom.\n * - Blocks below the fold: a single, calmer fade at the CSS default duration the FIRST time any pixel of\n * them enters the scroll root — never replayed, never reversed on scroll-up.\n * - VISIBILITY DEADLINE: whatever the observers did or did not see, every block still hidden\n * VISIBILITY_DEADLINE_MS after the reply arrived becomes plainly visible (no fade) and the observers are\n * dropped. Delivered text must never depend on a scroll event to become readable.\n *\n * Invariants:\n * - Opacity + transform only, never display/visibility/height — hidden blocks keep their final layout space\n * from the first frame, so the pin/reserve machinery in ConversationViewBody sees stable heights and Cmd+F /\n * selection / a11y still find the pending text.\n * - Only fresh static replies animate (the caller gates via `enabled`); streaming is excluded upstream.\n * - Once per message id: a re-render / windowing pass / navigate-away-and-back never replays it.\n * - A block can never be stuck hidden: hiding happens in the same synchronous useLayoutEffect that creates\n * the observer; the deadline and the cleanup both finalize every still-hidden block to visible. (A\n * \"-15% into the viewport\" trigger left the reply's closing question invisible while the pinned-question\n * policy never scrolled — the owner saw the question only after their next send. Hence zero margin AND the\n * deadline.)\n */\n\nconst STAGGER_STEP_MS = 90;\nconst STAGGER_CAP_MS = 720;\n// The initial screen-fill batch fades each block faster than the CSS default (900ms) so the first screen\n// populates snappily; blocks scrolled into view later keep the calmer default fade untouched.\nconst INITIAL_FADE_MS = 550;\n// Scroll-reveal trigger — below-the-fold blocks ONLY (the initial batch tests against the full viewport).\n// Zero margin: a block reveals the moment any pixel of it is inside the scroll root. (A negative bottom\n// margin — \"reveal once the top is 15% up into the viewport\" — left a block whose top sat in that bottom band\n// hidden for good when nothing scrolled; a percentage margin is even measured against the root's WIDTH.)\nconst SCROLL_REVEAL_ROOT_MARGIN = \"0px\";\n// Hard upper bound on hiding: after this, every still-hidden block is made visible without animation.\nexport const VISIBILITY_DEADLINE_MS = 2500;\n\n// Module-scoped so the guard survives unmount/remount of ConversationMessageWidgets (Redux re-render, widget\n// windowing, navigate-away-and-back within the session) — the same one-shot pattern as\n// reloadReopenMessageIdRef in ConversationMessageList.\nconst alreadyRevealedMessageIds = new Set<string | number>();\n\nexport const useFreshMessageBlockReveal = (options: {\n /**\n * The rendered-message container — ConversationMessageWidgets's existing renderedRef. Its DIRECT child must be\n * the reply's own `[data-markdown-blocks-root]` div (ConversationMarkdown renders exactly one Markdown,\n * whose context provider adds no DOM node); the hook queries only that direct child.\n */\n containerRef: RefObject<HTMLDivElement | null>;\n /** fresh && message != null — static fresh assistant replies only. */\n enabled: boolean;\n /** Once-only guard key; when null/undefined the reply animates but is not recorded. */\n messageId?: string | number | null;\n}): void => {\n const { containerRef, enabled, messageId } = options;\n const scrollRoot = useContext(WidgetWindowRootContext);\n\n useLayoutEffect(() => {\n if (!enabled) return;\n if (messageId != null && alreadyRevealedMessageIds.has(messageId)) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n // Markdown rendered outside the chat scroll container (drawer/canvas hosts render their own Markdown\n // instances) has no scroll root and must never inherit the reveal.\n if (scrollRoot == null) return;\n\n // Direct child ONLY (`:scope >`): the shared Markdown component stamps `data-markdown-blocks-root` on\n // every instance, and a widget inside the reply can render its own nested Markdown (e.g.\n // WebSearchAnswer). The reply's own blocks root is always renderedRef's direct child — ConversationMarkdown\n // renders a context provider (no DOM node) around exactly one Markdown — so a descendant query could\n // conflate roots, while the direct-child query can only match the outer one.\n const blocksRoot = containerRef.current?.querySelector(\":scope > [data-markdown-blocks-root]\");\n if (blocksRoot == null) return;\n\n const blocks = Array.from(blocksRoot.children) as HTMLElement[];\n if (blocks.length === 0) return;\n\n for (const block of blocks) block.dataset.blockReveal = \"hidden\";\n if (messageId != null) alreadyRevealedMessageIds.add(messageId);\n\n // The one idempotent end state: observers gone, every still-hidden block plainly visible (the hook's\n // attribute and inline overrides removed — assigning \"revealed\" would start another 900ms fade), blocks\n // already revealed keep their finished state. Reached by the deadline, by cleanup, or by an observer\n // setup failure; queued observer callbacks after it are no-ops.\n let finalized = false;\n let scrollRevealObserver: IntersectionObserver | null = null;\n let initialViewportObserver: IntersectionObserver | null = null;\n const finalize = () => {\n if (finalized) return;\n finalized = true;\n initialViewportObserver?.disconnect();\n scrollRevealObserver?.disconnect();\n for (const block of blocks) {\n if (block.dataset.blockReveal === \"hidden\") {\n delete block.dataset.blockReveal;\n block.style.animationDelay = \"\";\n block.style.animationDuration = \"\";\n }\n }\n };\n const deadline = window.setTimeout(finalize, VISIBILITY_DEADLINE_MS);\n\n // Below-the-fold blocks reveal the first time any pixel of them enters the scroll root — single fade, no delay.\n scrollRevealObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n for (const entry of entries) {\n if (!entry.isIntersecting) continue;\n (entry.target as HTMLElement).dataset.blockReveal = \"revealed\";\n observer.unobserve(entry.target);\n }\n },\n { root: scrollRoot, rootMargin: SCROLL_REVEAL_ROOT_MARGIN, threshold: 0 },\n );\n\n // The initial pass fires exactly once, right after observe(), with every block's intersection state\n // against the FULL viewport (no trigger margin): everything visible — under the pinned question, down\n // to the bottom edge — reveals staggered, so the first screen is completely filled with text. The\n // blocks below the fold are handed to scrollRevealObserver.\n initialViewportObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n let staggerIndex = 0;\n for (const entry of entries) {\n const block = entry.target as HTMLElement;\n if (entry.isIntersecting) {\n block.style.animationDelay = `${Math.min(staggerIndex * STAGGER_STEP_MS, STAGGER_CAP_MS)}ms`;\n block.style.animationDuration = `${INITIAL_FADE_MS}ms`;\n staggerIndex++;\n block.dataset.blockReveal = \"revealed\";\n } else {\n scrollRevealObserver?.observe(block);\n }\n }\n observer.disconnect();\n },\n { root: scrollRoot, threshold: 0 },\n );\n\n for (const block of blocks) initialViewportObserver.observe(block);\n\n return () => {\n window.clearTimeout(deadline);\n finalize();\n };\n }, [enabled, messageId, scrollRoot, containerRef]);\n};\n","import { Icon, Text } from \"../../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../../chat-assistant-identity\";\nimport React, { memo } from \"react\";\nimport styles from \"./ConversationMessageHeader.module.scss\";\n\nexport interface ConversationMessageHeaderProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n}\n\nexport const ConversationMessageHeader = memo((props: ConversationMessageHeaderProps) => {\n const { aiPromptExtensionCategory, aiPromptExtension } = props;\n\n // The extension's icon class is an icon of the app's icon set.\n const iconName = aiPromptExtension?.iconClass ?? \"ai\";\n\n return (\n <div className={styles.responseHeader}>\n <span className={styles.iconContainer}>\n <Icon color=\"var(--agents-fg-on-accent)\" hostIconName={iconName} />\n </span>\n <div>\n <Text role=\"help\" weight=\"bold\">\n {aiPromptExtension?.name ?? \"AI Extensions\"}\n </Text>\n {aiPromptExtensionCategory !== undefined ? (\n <Text role=\"caption\" replacements={{ productName: aiPromptExtensionCategory?.name }}>\n %productName% Assistant\n </Text>\n ) : null}\n {aiPromptExtensionCategory === undefined ? (\n <Text role=\"caption\">Assistant</Text>\n ) : null}\n </div>\n </div>\n );\n});\n","export async function copyRichToClipboard(plainText: string, html: string) {\n if (!plainText) {\n console.warn(\"No text to copy\");\n return;\n }\n\n if (!navigator.clipboard) {\n console.warn(\"Clipboard API not available\");\n return;\n }\n\n if (!(html && typeof ClipboardItem !== \"undefined\" && navigator.clipboard.write)) {\n console.warn(\"Clipboard does not support rich text, copying plain text only\");\n return navigator.clipboard.writeText(plainText);\n }\n try {\n const item = new ClipboardItem({\n \"text/plain\": new Blob([plainText], { type: \"text/plain\" }),\n \"text/html\": new Blob([html], { type: \"text/html\" }),\n });\n return navigator.clipboard.write([item]);\n } catch (error) {\n console.error(\"Failed to copy rich text to clipboard:\", error);\n return navigator.clipboard.writeText(plainText);\n }\n}\n","import { Button } from \"../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../chat-assistant-identity\";\nimport React, { memo, useCallback, useEffect, useRef, useState } from \"react\";\nimport styles from \"./ConversationMessageWidgets.module.scss\";\nimport { useTypewriter } from \"./hooks/useTypewriter\";\nimport { useStreamingText } from \"./hooks/useStreamingText\";\nimport { useFreshMessageBlockReveal } from \"./hooks/useFreshMessageBlockReveal\";\nimport { ConversationMessageHeader } from \"./ConversationMessageHeader/ConversationMessageHeader\";\nimport { ConversationMarkdown } from \"../../../renderer/ConversationMarkdown\";\nimport { copyRichToClipboard } from \"./copyRichToClipboard\";\nimport { normalizeServerMessageToMarkdown } from \"../../normalize-server-message-to-markdown\";\nimport { stripPreCallMessageMarker } from \"../../strip-pre-call-message-marker\";\nimport { useAgentsEnvironment } from \"../../../provider/AgentsProvider\";\n\nexport interface ConversationMessageWidgetsProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n eventSource?: EventSource;\n message?: unknown;\n /**\n * The reply's widgets may be used (buttons, forms, hydration refresh): a live-delivered reply, and the newest reply\n * after a reload. Forwarded to every widget as `interactive` (+ the deprecated alias `fresh`).\n */\n interactive?: boolean;\n /**\n * The reply was delivered live right now — never after a reload. Forwarded to every widget as `justDelivered`, the\n * only gate for one-shot side effects (canvas open, draft creation), and the gate of the block reveal.\n */\n justDelivered?: boolean;\n hideWidgets?: boolean;\n /** Id of the host message: once-only guard of the block reveal, and the identity of a canvas opened from it. */\n messageId?: string | number | null;\n /**\n * Hide the assistant header (icon + name + \"Assistant\") and the copy button.\n * Used by a host, which renders bare assistant messages.\n */\n hideAssistantMeta?: boolean;\n /** Opt-in staggered fade-in of this fresh reply's markdown blocks (see useFreshMessageBlockReveal). Default off. */\n enableFreshMessageBlockReveal?: boolean;\n}\n\nexport const ConversationMessageWidgets = memo((props: ConversationMessageWidgetsProps) => {\n const {\n aiPromptExtensionCategory,\n aiPromptExtension,\n eventSource,\n message,\n interactive = false,\n justDelivered = false,\n hideWidgets = false,\n hideAssistantMeta = false,\n enableFreshMessageBlockReveal = false,\n messageId,\n } = props;\n const { MessageFooter } = useAgentsEnvironment();\n\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<number | null>(null);\n const renderedRef = useRef<HTMLDivElement | null>(null);\n\n const { displayedText, appendText, finishTypewriter } = useTypewriter({\n speed: 200,\n commitIntervalMs: 100,\n });\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n // Only stream when no static message is provided\n useStreamingText({\n eventSource: message != null ? undefined : eventSource,\n onTextChunk: appendText,\n onError: finishTypewriter,\n onDone: finishTypewriter,\n });\n\n // If a message is provided, render it directly; otherwise render streamed text\n // Static message → normalize (already strips the {preCallMessage} sentinel); live stream → strip it here too.\n const textToRender =\n message != null ? normalizeServerMessageToMarkdown(message) : stripPreCallMessageMarker(displayedText);\n\n // (The former \"a fresh widget message closes the open canvas\" layout effect is gone: a canvas is superseded only\n // by another canvas being opened — and a pinned canvas survives a widget reply.)\n\n // Fade the just-delivered reply's rendered blocks in (staggered in view, once on scroll below the fold). Static\n // live-delivered assistant replies only — never after a reload, and the streaming path (message == null) renders\n // progressively already.\n useFreshMessageBlockReveal({\n containerRef: renderedRef,\n enabled: enableFreshMessageBlockReveal && justDelivered && message != null,\n messageId,\n });\n\n const onCopy = useCallback(async () => {\n const fallbackText = textToRender || \"\";\n const plain = renderedRef.current?.innerText?.trim() || fallbackText;\n const html = renderedRef.current?.innerHTML || \"\";\n\n await copyRichToClipboard(plain, html);\n\n setCopied(true);\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n timeoutRef.current = window.setTimeout(() => setCopied(false), 2000);\n }, [textToRender]);\n\n return (\n <div className={styles.responseContainer}>\n {!hideAssistantMeta ? (\n <ConversationMessageHeader\n aiPromptExtensionCategory={aiPromptExtensionCategory}\n aiPromptExtension={aiPromptExtension}\n />\n ) : null}\n <div className={styles.responseMessage}>\n <div ref={renderedRef}>\n {/* TODO: move the markdown component into the component library */}\n <ConversationMarkdown\n markdown={textToRender}\n interactive={interactive}\n justDelivered={justDelivered}\n messageId={messageId ?? undefined}\n hideWidgets={hideWidgets}\n />\n </div>\n\n {!hideAssistantMeta ? (\n <Button\n variant=\"muted\"\n icon={copied ? \"check\" : \"duplicate\"}\n onClick={onCopy}\n size=\"small\"\n />\n ) : null}\n </div>\n\n {/* The app's footer under the message (for example an admin-only trace footer that gates itself). */}\n {MessageFooter ? <MessageFooter message={message} /> : null}\n </div>\n );\n});\n","import styles from \"./VoiceBarsIcon.module.scss\";\n\nexport interface VoiceBarsIconProps {\n /** Edge length in px; the bars take the current text colour. */\n size?: number;\n}\n\n/**\n * Five sound bars, the tallest in the middle — the mark of an in-app voice call with the agent.\n */\nexport const VoiceBarsIcon = (props: VoiceBarsIconProps) => {\n const { size = 18 } = props;\n return (\n <svg className={styles.icon} width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden focusable=\"false\">\n <path d=\"M3.5 10.5v3M7.75 8v8M12 4.5v15M16.25 8v8M20.5 10.5v3\" />\n </svg>\n );\n};\n"],"names":["message","styles"],"mappings":";;;;;;AA4BA,MAAM,uBAAuB;AAc7B,MAAM,0BAA0B,CAAC,SAAwC;AACvE,QAAM,QAAQ,qBAAqB,KAAK,IAAI;AAC5C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,MAAM,CAAC;AACtB,QAAM,OAAO,OAAO,CAAC;AACrB,QAAM,OAAO,MAAM,CAAC,EAAE,KAAA;AACtB,MAAI,SAAS,OAAO,KAAK,SAAS,GAAG,EAAG,QAAO;AAC/C,SAAO,EAAE,MAAM,QAAQ,OAAO,QAAQ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,EAAK,GAAE,wDAAuD,EAAA,CACjE;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"VoiceBarsIcon-CT2HQSBH.js","sources":["../../src/renderer/repair-malformed-widget-fences.ts","../../src/renderer/reference-naked-widget-json.ts","../../src/chat/strip-pre-call-message-marker.ts","../../src/chat/normalize-server-message-to-markdown.ts","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUserWidgets.tsx","../../src/chat/ConversationMessage/ConversationMessageUser/ConversationMessageUser.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useTypewriter.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useStreamingText.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/hooks/useFreshMessageBlockReveal.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageHeader/ConversationMessageHeader.tsx","../../src/chat/ConversationMessage/ConversationMessageWidgets/copyRichToClipboard.ts","../../src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageWidgets.tsx","../../src/chat/ConversationMessage/ConversationCallMarkerChip/VoiceBarsIcon/VoiceBarsIcon.tsx"],"sourcesContent":["import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { WIDGET_FENCE_LANG } from \"./widget-fence-syntax\";\n\n/**\n * Repair the ```widget fence defects a model produces when it switches into a function call mid-text, or drops a\n * closing fence, or opens a second widget before closing the first (text + fence + tool call\n * in ONE response). A LINE-AWARE pass: CommonMark opens a fence on a line that (after up to 3 spaces of indent)\n * starts with ``` , and closes it only on a line whose sole content — same indent rule — is ``` . Content inside\n * ANY open fence (widget, json, or anything else) is data and is never scanned or touched, so a ``` mentioned\n * inside a JSON string value never gets mistaken for a delimiter.\n *\n * Two repairs, both scoped to the ```widget lang only:\n * 1. A glued opener (```widget stuck to the end of a prose line, so Markdown never recognized it as starting a\n * line) is relocated onto its own line ONLY when a JSON object begins right after it — otherwise the text is\n * left completely untouched (a prose sentence that merely mentions ```widget must not be mangled).\n * 2. An open widget fence with no proper closing-fence LINE before either end-of-text or the next fence-opener\n * line gets a ``` closer spliced in right after its balanced JSON object (string-aware, so a ``` inside a JSON\n * string is never treated as the closer). A widget fence whose body isn't a JSON object at all is left\n * untouched — nothing could safely render there either way, and deleting text is not this function's job.\n *\n * The backend stores the model text as emitted, so this is the ONE place the shape is corrected — for stored\n * history and for every new message alike. Runs before `referenceNakedWidgetJson` so the re-fenced JSON is not\n * wrapped a second time. Pure; well-formed text is returned unchanged.\n */\n\n/** A fence delimiter LINE per CommonMark, either character: up to 3 spaces indent, then a run of 3+ of the same\n * fence character (`` ` `` or `~`), then the rest of the line. Used by {@link findFencedBlockRanges} — the GENERAL\n * \"is this real fence syntax\" question, as opposed to the WIDGET-fence-only scanning above. */\nconst ANY_FENCE_DELIM_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;\n\n/** One real fence delimiter: its character, marker length and (trimmed) info string. */\ninterface FenceDelimiter {\n char: \"`\" | \"~\";\n length: number;\n info: string;\n}\n\n/**\n * Parse one line as a CommonMark fence delimiter, or null when it isn't one. A backtick run's info string may not\n * itself contain a backtick — CommonMark's own rule disambiguating a fence opener from an inline code span — so a\n * line such as \"```js `x`\" is not a fence delimiter at all (it never opens or closes anything).\n */\nconst parseFenceDelimiterLine = (line: string): FenceDelimiter | null => {\n const match = ANY_FENCE_DELIM_LINE.exec(line);\n if (!match) return null;\n const marker = match[1];\n const char = marker[0] as \"`\" | \"~\";\n const info = match[2].trim();\n if (char === \"`\" && info.includes(\"`\")) return null;\n return { char, length: marker.length, info };\n};\n\nconst isWidgetFenceInfo = (info: string): boolean => new RegExp(`^${WIDGET_FENCE_LANG}\\\\b`).test(info.trim());\n\n/** A ```widget opener anywhere in the text, glued or not — built from the shared lang constant. */\nconst widgetOpenerPattern = (): RegExp => new RegExp(\"```[ \\\\t]*\" + WIDGET_FENCE_LANG + \"\\\\b\");\n\n/** One line of `text` starting at `lineStart`: its content (terminator excluded — a trailing `\\r` of a CRLF\n * line ending is stripped too, so a delimiter regex's `.` never has to account for it) and the index right after\n * the line INCLUDING its terminator (or `text.length` at end-of-text). */\nconst readLine = (text: string, lineStart: number): { content: string; afterLine: number } => {\n const newlineIndex = text.indexOf(\"\\n\", lineStart);\n const lineEnd = newlineIndex === -1 ? text.length : newlineIndex;\n const afterLine = newlineIndex === -1 ? text.length : newlineIndex + 1;\n const rawContent = text.slice(lineStart, lineEnd);\n return { content: rawContent.endsWith(\"\\r\") ? rawContent.slice(0, -1) : rawContent, afterLine };\n};\n\n/**\n * Scan forward from `bodyStart` for a line that CLOSES the given opener: same fence character, a marker run at\n * least as long as the opener's, and nothing but whitespace after it (CommonMark's closing-fence rule). Unclosed →\n * end-of-text.\n */\nconst findClosingFenceEnd = (text: string, bodyStart: number, opener: FenceDelimiter): number => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === opener.char && delimiter.length >= opener.length && delimiter.info === \"\") {\n return afterLine;\n }\n cursor = afterLine;\n }\n return text.length;\n};\n\n/**\n * The `[start, end)` ranges of every REAL fenced code block in `text` — ``` or ~~~, CommonMark's own rules (up to\n * 3 spaces of indent, a closer using the same character with a run at least as long as the opener's, a backtick\n * opener's info string never containing a backtick). An unclosed opener runs to end-of-text. The GENERAL-PURPOSE\n * counterpart of this file's widget-fence-only scanning, built on the same {@link readLine} line walk — used by\n * `referenceNakedWidgetJson` to skip content genuinely inside a fence: a `~~~widget` fence (no tilde support\n * existed before), and content that follows a line which LOOKS like a backtick fence opener but isn't one per the\n * info-string rule above (that line never opens anything, so it can no longer swallow the real fence after it).\n */\nexport const findFencedBlockRanges = (text: string): Array<[number, number]> => {\n const ranges: Array<[number, number]> = [];\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const opener = parseFenceDelimiterLine(content);\n if (opener) {\n const end = findClosingFenceEnd(text, afterLine, opener);\n ranges.push([cursor, end]);\n cursor = end;\n continue;\n }\n cursor = afterLine;\n }\n return ranges;\n};\n\n/**\n * Scan forward from `bodyStart` (right after a fence opener line) for the next LINE-anchored BACKTICK fence\n * delimiter (via {@link parseFenceDelimiterLine} — the same CommonMark rules `findFencedBlockRanges` uses, so a\n * line like \"```js `x`\" — an invalid info string, not a fence delimiter at all — is correctly skipped as plain\n * content rather than mistaken for one): a proper closing line (empty info) closes the fence normally; any other\n * delimiter line (another opener, any lang) is the boundary where this fence gave up without closing. Neither\n * found before end-of-text → unclosed at EOF.\n */\nconst findFenceEnd = (text: string, bodyStart: number): { closesAt: number } | { unclosedBoundary: number } => {\n let cursor = bodyStart;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n return delimiter.info === \"\" ? { closesAt: afterLine } : { unclosedBoundary: cursor };\n }\n cursor = afterLine;\n }\n return { unclosedBoundary: text.length };\n};\n\n/**\n * Resolve an OPEN widget fence's body starting at `bodyStart`: verbatim through a real closing-fence line when one\n * exists before end-of-text or the next fence-opener line; otherwise a ``` closer spliced in right after the\n * balanced JSON object; or, when the body isn't a JSON object at all, everything to end-of-text left untouched.\n */\nconst closeWidgetFenceBody = (text: string, bodyStart: number): { appended: string; resumeAt: number } => {\n const end = findFenceEnd(text, bodyStart);\n if (\"closesAt\" in end) {\n return { appended: text.slice(bodyStart, end.closesAt), resumeAt: end.closesAt };\n }\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, bodyStart);\n if (jsonObjectEnd === null) {\n return { appended: text.slice(bodyStart), resumeAt: text.length };\n }\n return { appended: text.slice(bodyStart, jsonObjectEnd + 1) + \"\\n```\", resumeAt: jsonObjectEnd + 1 };\n};\n\nexport const repairMalformedWidgetFences = (text: string): string => {\n if (!widgetOpenerPattern().test(text)) return text;\n\n let result = \"\";\n let cursor = 0;\n while (cursor < text.length) {\n const { content, afterLine } = readLine(text, cursor);\n\n // Backtick fences only here (tilde ```widget``` has no repair path, same as before): a line whose backtick\n // run's info string itself contains a backtick (e.g. \"```js `x`\") is not a fence delimiter at all per\n // CommonMark, so it falls through to the glued-opener check / plain-text copy below, never swallowing a real\n // ```widget fence that follows it as a bogus \"other fence\".\n const delimiter = parseFenceDelimiterLine(content);\n if (delimiter && delimiter.char === \"`\") {\n const info = delimiter.info;\n if (info !== \"\" && isWidgetFenceInfo(info)) {\n result += content + text.slice(cursor + content.length, afterLine); // the opener line, verbatim\n const { appended, resumeAt } = closeWidgetFenceBody(text, afterLine);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n if (info !== \"\") {\n // Some other fenced language: copy its whole body through untouched — never scanned for a widget opener,\n // so a widget-fence mention inside a JSON string value in THIS fence's content is never touched (a widget\n // fence itself can't legally start inside an already-open fence either way).\n const otherFenceEnd = findFenceEnd(text, afterLine);\n const bodyEnd = \"closesAt\" in otherFenceEnd ? otherFenceEnd.closesAt : text.length;\n result += text.slice(cursor, bodyEnd);\n cursor = bodyEnd;\n continue;\n }\n }\n\n // Not a fence-delimiter line: a glued opener (the fence's backticks stuck to the end of prose). Relocate onto\n // its own line ONLY when a JSON object begins right after it; a prose line that merely mentions ```widget with\n // nothing to render is left completely untouched.\n const gluedMatch = widgetOpenerPattern().exec(content);\n if (gluedMatch && gluedMatch.index > 0 && content.slice(0, gluedMatch.index).trim() !== \"\") {\n const bodyStart = afterLine;\n if (findBalancedJsonObjectEnd(text, bodyStart) !== null) {\n const openerLine = content.slice(gluedMatch.index) + text.slice(cursor + content.length, afterLine);\n result += content.slice(0, gluedMatch.index) + \"\\n\" + openerLine;\n const { appended, resumeAt } = closeWidgetFenceBody(text, bodyStart);\n result += appended;\n cursor = resumeAt;\n continue;\n }\n }\n\n result += text.slice(cursor, afterLine);\n cursor = afterLine;\n }\n return result;\n};\n","import { findBalancedJsonObjectEnd } from \"./balanced-json-object\";\nimport { findFencedBlockRanges } from \"./repair-malformed-widget-fences\";\nimport { resolveWidgetName } from \"./widget-name-resolver\";\n\n/**\n * Weak models (Gemini-3.5-Flash) intermittently emit a widget as a NAKED JSON line —\n * `{ \"type\": \"ExampleWidget\" }` — without the ```widget fence the skills instruct. Such a line is not rendered\n * by remarkWidgetFencePlugin (no fence) and not by the bare-line path (no `widget` prefix), so the customer sees raw\n * JSON. `detectUnrenderedWidgets` only DETECTS this (to corrective-signal the model); here we RENDER it: wrap a naked\n * line-starting JSON object whose `type` resolves to a REGISTERED widget in a ```widget fence, so the plugin renders\n * it — no model round-trip, the customer never sees JSON. UNKNOWN types are left untouched (the corrective-signal\n * path still handles `type: \"example\"` → suggest `ExampleWidget`).\n *\n * Fence-aware: JSON already inside any REAL fenced block (``` or ~~~, CommonMark rules — see\n * `findFencedBlockRanges`) is skipped (never double-fenced). Uses the SAME resolveWidgetName as the render plugin +\n * the detector, so \"would render\" is decided in one place.\n */\n\n/** A line-starting balanced { … } JSON object and its [start, end) span in the source text. */\ninterface JsonSpan {\n json: string;\n start: number;\n end: number;\n}\n\n/**\n * Scan line-starting balanced `{ … }` JSON objects (string-aware brace walk), returning each with its span. Mirrors\n * detect-unrendered-widgets' `extractNakedJsonCandidates`, but keeps offsets so the object can be replaced in place.\n */\nconst scanLineStartingJsonSpans = (text: string): JsonSpan[] => {\n const spans: JsonSpan[] = [];\n const lines = text.split(\"\\n\");\n let offset = 0;\n for (const line of lines) {\n const lineStart = offset;\n offset += line.length + 1;\n if (!line.trimStart().startsWith(\"{\")) continue;\n const openIndex = lineStart + line.indexOf(\"{\");\n const jsonObjectEnd = findBalancedJsonObjectEnd(text, openIndex);\n if (jsonObjectEnd !== null) {\n spans.push({ json: text.slice(openIndex, jsonObjectEnd + 1), start: openIndex, end: jsonObjectEnd + 1 });\n }\n }\n return spans;\n};\n\n/** The string `type` of a JSON object, or null when it is not an object with a non-empty string `type`. */\nconst widgetTypeOf = (jsonCandidate: string): string | null => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(jsonCandidate);\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null) return null;\n const type = (parsed as Record<string, unknown>).type;\n return typeof type === \"string\" && type !== \"\" ? type : null;\n};\n\nexport const referenceNakedWidgetJson = (text: string): string => {\n if (!text.includes('\"type\"')) return text;\n\n const fencedRanges = findFencedBlockRanges(text);\n const isInsideFence = (position: number) => fencedRanges.some(([start, end]) => position >= start && position < end);\n\n // Right-to-left so each replacement leaves the earlier spans' offsets valid.\n const spans = scanLineStartingJsonSpans(text)\n .filter((span) => !isInsideFence(span.start))\n .reverse();\n\n let result = text;\n for (const span of spans) {\n const type = widgetTypeOf(span.json);\n if (type === null || resolveWidgetName(type) === undefined) continue; // unknown → leave for the corrective signal\n const fencedBlock = \"```widget\\n\" + span.json + \"\\n```\";\n result = result.slice(0, span.start) + fencedBlock + result.slice(span.end);\n }\n return result;\n};\n","/**\n * Mirrors `AIConversationMessage::PRE_CALL_MESSAGE_MARKER` (PHP). The model prefixes a short \"I'm about to do X\"\n * status line with this sentinel; the BACKEND only detects/signals on it and stores it RAW (it never strips). Every\n * render layer — this is the customer chat one — strips it before showing the text to the user.\n */\nexport const PRE_CALL_MESSAGE_MARKER = \"{preCallMessage}\";\n\n/**\n * The MANGLED JSON form some models emit instead of the sentinel (Gemini 3.5 Flash): the status line\n * arrives as `{ \"preCallMessage\": \"…\" }<` — optionally with extra fields and/or a trailing `<|im_call:…` pseudo call\n * marker — fused into the assistant text. Normalized to the inner status text so the user never sees raw JSON.\n * Mirrors the PHP normalization in `AIConversationMessage::stripPreCallMessageMarker`.\n */\nconst MANGLED_PRE_CALL_RE = /\\{\\s*\"preCallMessage\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*,?\\s*[^}]*\\}\\s*(?:<\\S*)?/g;\n\n/**\n * Remove the {preCallMessage} sentinel from assistant text before display, and normalize the mangled JSON form to\n * its inner status line. Also holds back a leading PARTIAL of either shape while it is still streaming in (so the\n * user never sees a \"{preCa…\" or `{ \"preCallMessage\": \"Einen Mo` flash before the full form arrives).\n */\nexport const stripPreCallMessageMarker = (text: string): string => {\n if (!text) return text;\n const leading = text.replace(/^\\s+/, \"\");\n // The sentinel itself is still streaming (nothing after it yet) → render nothing until real content arrives.\n if (leading.length < PRE_CALL_MESSAGE_MARKER.length && PRE_CALL_MESSAGE_MARKER.startsWith(leading)) return \"\";\n // The mangled JSON form is still streaming (opened but not yet closed) → hold it back the same way.\n const mangledPrefix = '{ \"preCallMessage\"';\n const normalizedLeading = leading.replace(/\\s+/g, \" \");\n if (\n (normalizedLeading.length < mangledPrefix.length && mangledPrefix.startsWith(normalizedLeading)) ||\n (normalizedLeading.startsWith(mangledPrefix) && !normalizedLeading.includes(\"}\"))\n ) {\n return \"\";\n }\n const withMangledNormalized = text.replace(MANGLED_PRE_CALL_RE, (_match, escapedStatusLine: string) => {\n try {\n return JSON.parse(`\"${escapedStatusLine}\"`) as string;\n } catch {\n return escapedStatusLine;\n }\n });\n const withMarkerRemoved = withMangledNormalized.split(PRE_CALL_MESSAGE_MARKER).join(\"\");\n // The marker (or its mangled form) sits at the very start, after only whitespace → that whitespace was there\n // only to separate it from the rest of the text and is removed along with it. Anything else — a message that\n // never carried the marker there at all — keeps its OWN leading whitespace untouched, so a four-space-indented\n // code block at the start of a message stays indented (plain CommonMark code) instead of sliding to column 0\n // and becoming a widget fence.\n const markerWasLeading = leading.startsWith(PRE_CALL_MESSAGE_MARKER) || normalizedLeading.startsWith(mangledPrefix);\n return markerWasLeading ? withMarkerRemoved.replace(/^\\s+/, \"\") : withMarkerRemoved;\n};\n","import { referenceNakedWidgetJson } from \"../renderer/reference-naked-widget-json\";\nimport { repairMalformedWidgetFences } from \"../renderer/repair-malformed-widget-fences\";\n\nimport { stripPreCallMessageMarker } from \"./strip-pre-call-message-marker\";\n\ntype ServerTextPart = { type: \"text\"; text?: string };\n\ntype ServerComponentPart = {\n type: \"component\";\n name?: string;\n props?: Record<string, unknown>;\n};\n\ntype ServerToolUsePart = {\n type: \"tool_use\";\n name?: string;\n input?: unknown;\n};\n\ntype ServerMessagePart = ServerTextPart | ServerComponentPart | ServerToolUsePart;\n\nexport type AssistantServerMessagePayload = {\n role?: string;\n content?: ServerMessagePart[];\n parts?: ServerMessagePart[];\n messageId?: string;\n};\n\nconst WIDGET_ATTR_KEY = /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst isTextPart = (part: unknown): part is ServerTextPart => isRecord(part) && part.type === \"text\";\n\nconst isComponentPart = (part: unknown): part is ServerComponentPart =>\n isRecord(part) && part.type === \"component\" && typeof part.name === \"string\" && part.name.length > 0;\n\nconst isToolUsePart = (part: unknown): part is ServerToolUsePart => isRecord(part) && part.type === \"tool_use\";\n\nconst isMessagePart = (part: unknown): part is ServerMessagePart =>\n isTextPart(part) || isComponentPart(part) || isToolUsePart(part);\n\nconst isPayload = (value: unknown): value is AssistantServerMessagePayload => {\n if (!isRecord(value)) return false;\n const parts = value.content ?? value.parts;\n return Array.isArray(parts) && parts.every(isMessagePart);\n};\n\n/**\n * The model occasionally emits a single part object instead of an array\n * ({\"content\":{\"type\":\"text\",...}}). Coerce it so the message still renders.\n */\nconst coerceSinglePartPayload = (value: unknown): AssistantServerMessagePayload | null => {\n if (!isRecord(value)) return null;\n const part = value.content ?? value.parts;\n if (!isMessagePart(part)) return null;\n const rest = { ...value };\n delete rest.parts;\n return { ...rest, content: [part] };\n};\n\nconst encodeAttrValue = (value: unknown) => JSON.stringify(value).replace(/'/g, \"\\\\u0027\");\n\nconst propsToAttrs = (props: Record<string, unknown>) =>\n Object.entries(props)\n .filter(([key, value]) => value !== undefined && WIDGET_ATTR_KEY.test(key))\n .map(([key, value]) => `${key}='${encodeAttrValue(value)}'`)\n .join(\" \");\n\nconst componentPartToWidget = (part: ServerComponentPart) => {\n const attrs = propsToAttrs(part.props ?? {});\n return attrs ? `::${part.name}{${attrs}}` : `::${part.name}`;\n};\n\nconst toolUsePartToWidget = (part: ServerToolUsePart) => {\n const payload = encodeAttrValue({ name: part.name, input: part.input });\n return `::ToolTrace{payload='${payload}'}`;\n};\n\nconst partToMarkdown = (part: ServerMessagePart) => {\n if (isTextPart(part)) return part.text?.trim() ?? \"\";\n if (isToolUsePart(part)) return toolUsePartToWidget(part);\n return componentPartToWidget(part);\n};\n\nconst payloadToMarkdown = (payload: AssistantServerMessagePayload) => {\n return (payload.content ?? payload.parts ?? []).map(partToMarkdown).filter(Boolean).join(\"\\n\\n\");\n};\n\nconst tryParsePayload = (value: string): AssistantServerMessagePayload | null => {\n try {\n const parsed = JSON.parse(value) as unknown;\n return isPayload(parsed) ? parsed : coerceSinglePartPayload(parsed);\n } catch {\n return null;\n }\n};\n\nexport const normalizeServerMessageToMarkdown = (message: unknown): string => {\n let result: string;\n if (typeof message === \"string\") {\n const parsed = tryParsePayload(message);\n result = parsed ? payloadToMarkdown(parsed) : message;\n } else if (isPayload(message)) {\n result = payloadToMarkdown(message);\n } else {\n const coerced = coerceSinglePartPayload(message);\n if (coerced) {\n result = payloadToMarkdown(coerced);\n } else {\n console.warn(\"[AIExtensions] normalizeServerMessageToMarkdown: unrecognized message shape\", message);\n result = \"\";\n }\n }\n // The backend stores the {preCallMessage} status-line sentinel raw (it only detects/signals on it) — strip it here.\n // Then repair a ```widget fence the model broke mid-text (opener glued to the prose line / never closed — the model\n // switched into a tool call), then re-fence any naked widget JSON (a weak model emitted\n // `{ \"type\": \"ExampleWidget\" }` without a ```widget fence): wrapping a known widget type lets\n // remarkWidgetFencePlugin render it, so the customer never sees raw JSON.\n return referenceNakedWidgetJson(repairMalformedWidgetFences(stripPreCallMessageMarker(result)));\n};\n","import React from \"react\";\nimport { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationWidgetErrorBoundary } from \"../../../renderer/ConversationWidgetErrorBoundary\";\n\nexport interface ConversationMessageUserWidgetsProps {\n /** Composer-widget fences extracted from the customer's own message text (see `splitComposerWidgetFencesFromMessageText`). */\n widgets: ConversationComposerWidget[];\n}\n\n/**\n * Read-only echo of the composer widgets the customer sent inside their OWN message — rendered above the prose. Reuses each widget's registered message `component` (the same one an\n * assistant reply would mount via the remark pipeline) directly with the fence's fields as `payload` — NOT the\n * remark/markdown pipeline itself, which never runs for user text (interpreting the customer's own prose as\n * Markdown would change every user bubble). `fresh={false}`: this is always a replay of content already sent, never\n * a live delivery. Each widget renders inside its own `ConversationWidgetErrorBoundary` so a malformed fence never\n * blanks the whole bubble.\n */\nexport const ConversationMessageUserWidgets = (props: ConversationMessageUserWidgetsProps) => {\n const { widgets } = props;\n\n if (widgets.length === 0) return null;\n\n return (\n <>\n {widgets.map((widget) => {\n const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);\n if (!entry) return null;\n const Component = entry.component;\n return (\n <ConversationWidgetErrorBoundary key={widget.composerWidgetId} widgetName={entry.name}>\n <Component payload={JSON.stringify(widget.fields)} fresh={false} />\n </ConversationWidgetErrorBoundary>\n );\n })}\n </>\n );\n};\n","import { Text } from \"../../../provider/components\";\nimport React, { useMemo } from \"react\";\nimport { classNames } from \"../../../provider/class-names\";\nimport { escapePlainTextForText } from \"../../../provider/environment\";\nimport styles from \"./ConversationMessageUser.module.scss\";\nimport { splitComposerWidgetFencesFromMessageText } from \"../../../renderer/composer-widget-fence\";\nimport type { ConversationComposerWidget } from \"../../../renderer/conversation-composer-widget\";\nimport { conversationWidgetRegistry } from \"../../../renderer/conversationWidgetRegistry\";\nimport { ConversationMessageUserWidgets } from \"./ConversationMessageUserWidgets\";\n\nexport type ConversationMessageUserTheme = \"default\" | \"light\" | \"dark\" | \"primary\";\n\nexport interface ConversationMessageUserProps {\n text: string;\n theme?: ConversationMessageUserTheme;\n /** @deprecated Never read: a customer message looks the same in every chat. Kept so existing callers compile. */\n isGenericChat?: boolean;\n}\n\n/** True when the widget's registry entry shows its echo on its own above the bubble (e.g. attached images). */\nconst isShownAboveBubble = (widget: ConversationComposerWidget): boolean =>\n conversationWidgetRegistry.widgets.find((entry) => entry.name === widget.widgetName)?.customerMessagePlacement ===\n \"aboveBubble\";\n\nexport const ConversationMessageUser = (props: ConversationMessageUserProps) => {\n const { text, theme = \"default\" } = props;\n\n // Pull any registered composer-widget fences out of the customer's own message text so they render as\n // read-only widgets above the prose, exactly like the assistant-side remark pipeline renders them in a reply —\n // but WITHOUT running that pipeline over user text (never treat the customer's own prose as Markdown).\n // The prose is the customer's own text: it reaches the text component as plain text (`escapePlainTextForText`), so\n // an app's text component that reads a string as markup shows it as written.\n const { text: proseText, widgets } = useMemo(() => splitComposerWidgetFencesFromMessageText(text), [text]);\n const widgetsAboveBubble = useMemo(() => widgets.filter(isShownAboveBubble), [widgets]);\n const widgetsInsideBubble = useMemo(() => widgets.filter((widget) => !isShownAboveBubble(widget)), [widgets]);\n\n const bubbleClass =\n theme === \"light\"\n ? styles.whiteBubble\n : theme === \"dark\"\n ? styles.darkBubble\n : theme === \"primary\"\n ? styles.primaryBubble\n : undefined;\n\n const textColor =\n theme === \"light\"\n ? \"var(--agents-fg)\"\n : theme === \"dark\"\n ? \"var(--agents-chat-user-bubble-text)\"\n : \"var(--agents-fg-on-accent)\";\n\n const bubble = (\n <div className={classNames(styles.message, bubbleClass)} data-testid=\"chat-message-user\">\n <ConversationMessageUserWidgets widgets={widgetsInsideBubble} />\n {/* A widget-only message (e.g. images sent without text) has no prose line to render. */}\n {proseText !== \"\" && (\n <Text testId=\"conversation-message-user-text\" allowNewLines translate={false} color={textColor}>\n {escapePlainTextForText(proseText)}\n </Text>\n )}\n </div>\n );\n\n if (widgetsAboveBubble.length === 0) return bubble;\n\n // Widgets placed above the bubble (e.g. attached images) stand on their own, right-aligned; a message that is nothing\n // but such widgets shows no bubble at all.\n return (\n <div className={styles.messageWithWidgetsAboveBubble}>\n <ConversationMessageUserWidgets widgets={widgetsAboveBubble} />\n {(proseText !== \"\" || widgetsInsideBubble.length > 0) && bubble}\n </div>\n );\n};\n","import { useRef, useState, useCallback } from \"react\";\n\ninterface UseTypewriterOptions {\n // Characters per second to reveal\n speed?: number;\n // Minimum interval between UI commits (ms) to reduce re-renders\n commitIntervalMs?: number;\n}\n\nexport const useTypewriter = (options: UseTypewriterOptions = {}) => {\n const { speed = 200, commitIntervalMs = 50 } = options;\n\n const [displayedText, setDisplayedText] = useState<string>(\"\");\n const [isFinished, setIsFinished] = useState<boolean>(false);\n\n const fullTextRef = useRef<string>(\"\");\n const typeRAFRef = useRef<number | null>(null);\n const lastTimestampRef = useRef<number | null>(null);\n const renderedLengthRef = useRef<number>(0);\n const speedRef = useRef<number>(speed);\n const commitIntervalRef = useRef<number>(commitIntervalMs);\n const lastCommitTsRef = useRef<number>(0);\n\n const startTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) return; // already running\n if (renderedLengthRef.current >= fullTextRef.current.length) return; // nothing to render\n\n const animate = (timestamp: number) => {\n if (lastTimestampRef.current === null) {\n lastTimestampRef.current = timestamp;\n }\n\n const elapsedSeconds = (timestamp - lastTimestampRef.current) / 1000;\n lastTimestampRef.current = timestamp;\n\n const charactersToAdd = Math.max(1, Math.floor(elapsedSeconds * speedRef.current));\n const nextLength = Math.min(fullTextRef.current.length, renderedLengthRef.current + charactersToAdd);\n\n renderedLengthRef.current = nextLength;\n\n // Only commit to React state at most every commitIntervalMs or when finished\n if (\n timestamp - lastCommitTsRef.current >= commitIntervalRef.current ||\n nextLength === fullTextRef.current.length\n ) {\n const nextText = fullTextRef.current.slice(0, nextLength);\n setDisplayedText(nextText);\n lastCommitTsRef.current = timestamp;\n }\n\n if (nextLength < fullTextRef.current.length) {\n typeRAFRef.current = requestAnimationFrame(animate);\n } else {\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n setIsFinished(true);\n }\n };\n\n typeRAFRef.current = requestAnimationFrame(animate);\n }, []);\n\n const appendText = useCallback(\n (text: string) => {\n if (!text) return;\n fullTextRef.current += text;\n setIsFinished(false);\n startTypewriter();\n },\n [startTypewriter],\n );\n\n const stopTypewriter = useCallback(() => {\n if (typeRAFRef.current !== null) {\n cancelAnimationFrame(typeRAFRef.current);\n typeRAFRef.current = null;\n lastTimestampRef.current = null;\n }\n }, []);\n\n const finishTypewriter = useCallback(() => {\n stopTypewriter();\n setDisplayedText(fullTextRef.current);\n renderedLengthRef.current = fullTextRef.current.length;\n setIsFinished(true);\n }, [stopTypewriter]);\n\n return {\n displayedText,\n appendText,\n stopTypewriter,\n finishTypewriter,\n isFinished,\n };\n};\n","import { useEffect, useRef, useCallback } from \"react\";\n\ninterface UseStreamingTextOptions {\n eventSource?: EventSource;\n onTextChunk?: (chunk: string) => void;\n onError?: () => void;\n onDone?: () => void;\n}\n\nexport const useStreamingText = ({ eventSource, onTextChunk, onError, onDone }: UseStreamingTextOptions) => {\n const bufferRef = useRef<string>(\"\");\n const flushRAFRef = useRef<number | null>(null);\n\n const onTextChunkRef = useRef<typeof onTextChunk>(null);\n const onErrorRef = useRef<typeof onError>(null);\n const onDoneRef = useRef<typeof onDone>(null);\n onTextChunkRef.current = onTextChunk;\n onErrorRef.current = onError;\n onDoneRef.current = onDone;\n\n const flushBuffer = useCallback(() => {\n flushRAFRef.current = null;\n if (!bufferRef.current) return;\n\n const chunk = bufferRef.current;\n bufferRef.current = \"\";\n onTextChunkRef.current?.(chunk);\n }, []);\n\n const finish = useCallback(() => {\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n flushBuffer();\n onDoneRef.current?.();\n }, [flushBuffer]);\n\n const handleMessage = useCallback(\n (event: MessageEvent) => {\n // OpenAI Chat Completions terminator\n if (event.data === \"[DONE]\") {\n finish();\n return;\n }\n\n try {\n const parsed = JSON.parse(event.data);\n\n // Chat Completions streaming delta\n const piece =\n parsed?.choices?.[0]?.delta?.content ??\n // fallback: support simple formats too\n (typeof parsed === \"string\" ? parsed : (parsed?.text ?? \"\"));\n\n // Some servers send a final frame with finish_reason\n const finishReason = parsed?.choices?.[0]?.finish_reason;\n\n if (piece) {\n bufferRef.current += piece;\n if (flushRAFRef.current === null) {\n flushRAFRef.current = requestAnimationFrame(flushBuffer);\n }\n }\n\n if (finishReason === \"stop\") {\n finish();\n }\n } catch (error) {\n console.error(\"Error parsing SSE message:\", error, event.data);\n onErrorRef.current?.();\n }\n },\n [flushBuffer, finish],\n );\n\n const handleError = useCallback(() => {\n onErrorRef.current?.();\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n }, [flushBuffer]);\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !eventSource) return;\n\n eventSource.addEventListener(\"message\", handleMessage);\n eventSource.addEventListener(\"error\", handleError);\n\n return () => {\n eventSource.removeEventListener(\"message\", handleMessage);\n eventSource.removeEventListener(\"error\", handleError);\n\n if (flushRAFRef.current !== null) {\n cancelAnimationFrame(flushRAFRef.current);\n flushRAFRef.current = null;\n }\n\n flushBuffer();\n };\n }, [eventSource, handleMessage, handleError, flushBuffer]);\n};\n","import { RefObject, useContext, useLayoutEffect } from \"react\";\nimport { WidgetWindowRootContext } from \"../../../../renderer/widget-windowing\";\n\n/**\n * Fade a freshly-delivered assistant reply's rendered block elements in, one after another, instead of\n * popping the whole wall of text in at once. The reveal operates on the DOM blocks the markdown renderer\n * already produces (the direct children of the `[data-markdown-blocks-root]` div that is containerRef's\n * DIRECT child — nested Markdown instances rendered by widgets stamp the same attribute deeper\n * down and must not be picked up) — the markdown string is never split, so code fences, tables, nested\n * lists, and widgets are handled uniformly.\n *\n * - Blocks in view on arrival (tested against the FULL viewport, edge to edge): a quick staggered fade-in\n * (STAGGER_STEP_MS apart, capped at STAGGER_CAP_MS; each block fades over the faster INITIAL_FADE_MS set\n * inline) — the visible screen fills with text down to the bottom edge fast, no hidden band at the bottom.\n * - Blocks below the fold: a single, calmer fade at the CSS default duration the FIRST time any pixel of\n * them enters the scroll root — never replayed, never reversed on scroll-up.\n * - VISIBILITY DEADLINE: whatever the observers did or did not see, every block still hidden\n * VISIBILITY_DEADLINE_MS after the reply arrived becomes plainly visible (no fade) and the observers are\n * dropped. Delivered text must never depend on a scroll event to become readable.\n *\n * Invariants:\n * - Opacity + transform only, never display/visibility/height — hidden blocks keep their final layout space\n * from the first frame, so the pin/reserve machinery in ConversationViewBody sees stable heights and Cmd+F /\n * selection / a11y still find the pending text.\n * - Only fresh static replies animate (the caller gates via `enabled`); streaming is excluded upstream.\n * - Once per message id: a re-render / windowing pass / navigate-away-and-back never replays it.\n * - A block can never be stuck hidden: hiding happens in the same synchronous useLayoutEffect that creates\n * the observer; the deadline and the cleanup both finalize every still-hidden block to visible. (A\n * \"-15% into the viewport\" trigger left the reply's closing question invisible while the pinned-question\n * policy never scrolled — the owner saw the question only after their next send. Hence zero margin AND the\n * deadline.)\n */\n\nconst STAGGER_STEP_MS = 90;\nconst STAGGER_CAP_MS = 720;\n// The initial screen-fill batch fades each block faster than the CSS default (900ms) so the first screen\n// populates snappily; blocks scrolled into view later keep the calmer default fade untouched.\nconst INITIAL_FADE_MS = 550;\n// Scroll-reveal trigger — below-the-fold blocks ONLY (the initial batch tests against the full viewport).\n// Zero margin: a block reveals the moment any pixel of it is inside the scroll root. (A negative bottom\n// margin — \"reveal once the top is 15% up into the viewport\" — left a block whose top sat in that bottom band\n// hidden for good when nothing scrolled; a percentage margin is even measured against the root's WIDTH.)\nconst SCROLL_REVEAL_ROOT_MARGIN = \"0px\";\n// Hard upper bound on hiding: after this, every still-hidden block is made visible without animation.\nexport const VISIBILITY_DEADLINE_MS = 2500;\n\n// Module-scoped so the guard survives unmount/remount of ConversationMessageWidgets (Redux re-render, widget\n// windowing, navigate-away-and-back within the session) — the same one-shot pattern as\n// reloadReopenMessageIdRef in ConversationMessageList.\nconst alreadyRevealedMessageIds = new Set<string | number>();\n\nexport const useFreshMessageBlockReveal = (options: {\n /**\n * The rendered-message container — ConversationMessageWidgets's existing renderedRef. Its DIRECT child must be\n * the reply's own `[data-markdown-blocks-root]` div (ConversationMarkdown renders exactly one Markdown,\n * whose context provider adds no DOM node); the hook queries only that direct child.\n */\n containerRef: RefObject<HTMLDivElement | null>;\n /** fresh && message != null — static fresh assistant replies only. */\n enabled: boolean;\n /** Once-only guard key; when null/undefined the reply animates but is not recorded. */\n messageId?: string | number | null;\n}): void => {\n const { containerRef, enabled, messageId } = options;\n const scrollRoot = useContext(WidgetWindowRootContext);\n\n useLayoutEffect(() => {\n if (!enabled) return;\n if (messageId != null && alreadyRevealedMessageIds.has(messageId)) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n // Markdown rendered outside the chat scroll container (drawer/canvas hosts render their own Markdown\n // instances) has no scroll root and must never inherit the reveal.\n if (scrollRoot == null) return;\n\n // Direct child ONLY (`:scope >`): the shared Markdown component stamps `data-markdown-blocks-root` on\n // every instance, and a widget inside the reply can render its own nested Markdown (e.g.\n // WebSearchAnswer). The reply's own blocks root is always renderedRef's direct child — ConversationMarkdown\n // renders a context provider (no DOM node) around exactly one Markdown — so a descendant query could\n // conflate roots, while the direct-child query can only match the outer one.\n const blocksRoot = containerRef.current?.querySelector(\":scope > [data-markdown-blocks-root]\");\n if (blocksRoot == null) return;\n\n const blocks = Array.from(blocksRoot.children) as HTMLElement[];\n if (blocks.length === 0) return;\n\n for (const block of blocks) block.dataset.blockReveal = \"hidden\";\n if (messageId != null) alreadyRevealedMessageIds.add(messageId);\n\n // The one idempotent end state: observers gone, every still-hidden block plainly visible (the hook's\n // attribute and inline overrides removed — assigning \"revealed\" would start another 900ms fade), blocks\n // already revealed keep their finished state. Reached by the deadline, by cleanup, or by an observer\n // setup failure; queued observer callbacks after it are no-ops.\n let finalized = false;\n let scrollRevealObserver: IntersectionObserver | null = null;\n let initialViewportObserver: IntersectionObserver | null = null;\n const finalize = () => {\n if (finalized) return;\n finalized = true;\n initialViewportObserver?.disconnect();\n scrollRevealObserver?.disconnect();\n for (const block of blocks) {\n if (block.dataset.blockReveal === \"hidden\") {\n delete block.dataset.blockReveal;\n block.style.animationDelay = \"\";\n block.style.animationDuration = \"\";\n }\n }\n };\n const deadline = window.setTimeout(finalize, VISIBILITY_DEADLINE_MS);\n\n // Below-the-fold blocks reveal the first time any pixel of them enters the scroll root — single fade, no delay.\n scrollRevealObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n for (const entry of entries) {\n if (!entry.isIntersecting) continue;\n (entry.target as HTMLElement).dataset.blockReveal = \"revealed\";\n observer.unobserve(entry.target);\n }\n },\n { root: scrollRoot, rootMargin: SCROLL_REVEAL_ROOT_MARGIN, threshold: 0 },\n );\n\n // The initial pass fires exactly once, right after observe(), with every block's intersection state\n // against the FULL viewport (no trigger margin): everything visible — under the pinned question, down\n // to the bottom edge — reveals staggered, so the first screen is completely filled with text. The\n // blocks below the fold are handed to scrollRevealObserver.\n initialViewportObserver = new IntersectionObserver(\n (entries, observer) => {\n if (finalized) return;\n let staggerIndex = 0;\n for (const entry of entries) {\n const block = entry.target as HTMLElement;\n if (entry.isIntersecting) {\n block.style.animationDelay = `${Math.min(staggerIndex * STAGGER_STEP_MS, STAGGER_CAP_MS)}ms`;\n block.style.animationDuration = `${INITIAL_FADE_MS}ms`;\n staggerIndex++;\n block.dataset.blockReveal = \"revealed\";\n } else {\n scrollRevealObserver?.observe(block);\n }\n }\n observer.disconnect();\n },\n { root: scrollRoot, threshold: 0 },\n );\n\n for (const block of blocks) initialViewportObserver.observe(block);\n\n return () => {\n window.clearTimeout(deadline);\n finalize();\n };\n }, [enabled, messageId, scrollRoot, containerRef]);\n};\n","import { Icon, Text } from \"../../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../../chat-assistant-identity\";\nimport React, { memo } from \"react\";\nimport styles from \"./ConversationMessageHeader.module.scss\";\n\nexport interface ConversationMessageHeaderProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n}\n\nexport const ConversationMessageHeader = memo((props: ConversationMessageHeaderProps) => {\n const { aiPromptExtensionCategory, aiPromptExtension } = props;\n\n // The extension's icon class is an icon of the app's icon set.\n const iconName = aiPromptExtension?.iconClass ?? \"ai\";\n\n return (\n <div className={styles.responseHeader}>\n <span className={styles.iconContainer}>\n <Icon color=\"var(--agents-fg-on-accent)\" hostIconName={iconName} />\n </span>\n <div>\n <Text role=\"help\" weight=\"bold\">\n {aiPromptExtension?.name ?? \"AI Extensions\"}\n </Text>\n {aiPromptExtensionCategory !== undefined ? (\n <Text role=\"caption\" replacements={{ productName: aiPromptExtensionCategory?.name }}>\n %productName% Assistant\n </Text>\n ) : null}\n {aiPromptExtensionCategory === undefined ? (\n <Text role=\"caption\">Assistant</Text>\n ) : null}\n </div>\n </div>\n );\n});\n","export async function copyRichToClipboard(plainText: string, html: string) {\n if (!plainText) {\n console.warn(\"No text to copy\");\n return;\n }\n\n if (!navigator.clipboard) {\n console.warn(\"Clipboard API not available\");\n return;\n }\n\n if (!(html && typeof ClipboardItem !== \"undefined\" && navigator.clipboard.write)) {\n console.warn(\"Clipboard does not support rich text, copying plain text only\");\n return navigator.clipboard.writeText(plainText);\n }\n try {\n const item = new ClipboardItem({\n \"text/plain\": new Blob([plainText], { type: \"text/plain\" }),\n \"text/html\": new Blob([html], { type: \"text/html\" }),\n });\n return navigator.clipboard.write([item]);\n } catch (error) {\n console.error(\"Failed to copy rich text to clipboard:\", error);\n return navigator.clipboard.writeText(plainText);\n }\n}\n","import { Button } from \"../../../provider/components\";\nimport type { ChatAssistantCategory, ChatAssistantIdentity } from \"../../chat-assistant-identity\";\nimport React, { memo, useCallback, useEffect, useRef, useState } from \"react\";\nimport styles from \"./ConversationMessageWidgets.module.scss\";\nimport { useTypewriter } from \"./hooks/useTypewriter\";\nimport { useStreamingText } from \"./hooks/useStreamingText\";\nimport { useFreshMessageBlockReveal } from \"./hooks/useFreshMessageBlockReveal\";\nimport { ConversationMessageHeader } from \"./ConversationMessageHeader/ConversationMessageHeader\";\nimport { ConversationMarkdown } from \"../../../renderer/ConversationMarkdown\";\nimport { copyRichToClipboard } from \"./copyRichToClipboard\";\nimport { normalizeServerMessageToMarkdown } from \"../../normalize-server-message-to-markdown\";\nimport { stripPreCallMessageMarker } from \"../../strip-pre-call-message-marker\";\nimport { useAgentsEnvironment } from \"../../../provider/AgentsProvider\";\n\nexport interface ConversationMessageWidgetsProps {\n aiPromptExtensionCategory?: ChatAssistantCategory;\n aiPromptExtension?: ChatAssistantIdentity;\n eventSource?: EventSource;\n message?: unknown;\n /**\n * The reply's widgets may be used (buttons, forms, hydration refresh): a live-delivered reply, and the newest reply\n * after a reload. Forwarded to every widget as `interactive` (+ the deprecated alias `fresh`).\n */\n interactive?: boolean;\n /**\n * The reply was delivered live right now — never after a reload. Forwarded to every widget as `justDelivered`, the\n * only gate for one-shot side effects (canvas open, draft creation), and the gate of the block reveal.\n */\n justDelivered?: boolean;\n hideWidgets?: boolean;\n /** Id of the host message: once-only guard of the block reveal, and the identity of a canvas opened from it. */\n messageId?: string | number | null;\n /**\n * Hide the assistant header (icon + name + \"Assistant\") and the copy button.\n * Used by a host, which renders bare assistant messages.\n */\n hideAssistantMeta?: boolean;\n /** Opt-in staggered fade-in of this fresh reply's markdown blocks (see useFreshMessageBlockReveal). Default off. */\n enableFreshMessageBlockReveal?: boolean;\n}\n\nexport const ConversationMessageWidgets = memo((props: ConversationMessageWidgetsProps) => {\n const {\n aiPromptExtensionCategory,\n aiPromptExtension,\n eventSource,\n message,\n interactive = false,\n justDelivered = false,\n hideWidgets = false,\n hideAssistantMeta = false,\n enableFreshMessageBlockReveal = false,\n messageId,\n } = props;\n const { MessageFooter } = useAgentsEnvironment();\n\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<number | null>(null);\n const renderedRef = useRef<HTMLDivElement | null>(null);\n\n const { displayedText, appendText, finishTypewriter } = useTypewriter({\n speed: 200,\n commitIntervalMs: 100,\n });\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n // Only stream when no static message is provided\n useStreamingText({\n eventSource: message != null ? undefined : eventSource,\n onTextChunk: appendText,\n onError: finishTypewriter,\n onDone: finishTypewriter,\n });\n\n // If a message is provided, render it directly; otherwise render streamed text\n // Static message → normalize (already strips the {preCallMessage} sentinel); live stream → strip it here too.\n const textToRender =\n message != null ? normalizeServerMessageToMarkdown(message) : stripPreCallMessageMarker(displayedText);\n\n // (The former \"a fresh widget message closes the open canvas\" layout effect is gone: a canvas is superseded only\n // by another canvas being opened — and a pinned canvas survives a widget reply.)\n\n // Fade the just-delivered reply's rendered blocks in (staggered in view, once on scroll below the fold). Static\n // live-delivered assistant replies only — never after a reload, and the streaming path (message == null) renders\n // progressively already.\n useFreshMessageBlockReveal({\n containerRef: renderedRef,\n enabled: enableFreshMessageBlockReveal && justDelivered && message != null,\n messageId,\n });\n\n const onCopy = useCallback(async () => {\n const fallbackText = textToRender || \"\";\n const plain = renderedRef.current?.innerText?.trim() || fallbackText;\n const html = renderedRef.current?.innerHTML || \"\";\n\n await copyRichToClipboard(plain, html);\n\n setCopied(true);\n if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);\n timeoutRef.current = window.setTimeout(() => setCopied(false), 2000);\n }, [textToRender]);\n\n return (\n <div className={styles.responseContainer}>\n {!hideAssistantMeta ? (\n <ConversationMessageHeader\n aiPromptExtensionCategory={aiPromptExtensionCategory}\n aiPromptExtension={aiPromptExtension}\n />\n ) : null}\n <div className={styles.responseMessage}>\n <div ref={renderedRef}>\n {/* TODO: move the markdown component into the component library */}\n <ConversationMarkdown\n markdown={textToRender}\n interactive={interactive}\n justDelivered={justDelivered}\n messageId={messageId ?? undefined}\n hideWidgets={hideWidgets}\n />\n </div>\n\n {!hideAssistantMeta ? (\n <Button\n variant=\"muted\"\n icon={copied ? \"check\" : \"duplicate\"}\n onClick={onCopy}\n size=\"small\"\n />\n ) : null}\n </div>\n\n {/* The app's footer under the message (for example an admin-only trace footer that gates itself). */}\n {MessageFooter ? <MessageFooter message={message} /> : null}\n </div>\n );\n});\n","import styles from \"./VoiceBarsIcon.module.scss\";\n\nexport interface VoiceBarsIconProps {\n /** Edge length in px; the bars take the current text colour. */\n size?: number;\n}\n\n/**\n * Five sound bars, the tallest in the middle — the mark of an in-app voice call with the agent.\n */\nexport const VoiceBarsIcon = (props: VoiceBarsIconProps) => {\n const { size = 18 } = props;\n return (\n <svg className={styles.icon} width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden focusable=\"false\">\n <path d=\"M3.5 10.5v3M7.75 8v8M12 4.5v15M16.25 8v8M20.5 10.5v3\" />\n </svg>\n );\n};\n"],"names":["message","styles"],"mappings":";;;;;;AA4BA,MAAM,uBAAuB;AAc7B,MAAM,0BAA0B,CAAC,SAAwC;AACvE,QAAM,QAAQ,qBAAqB,KAAK,IAAI;AAC5C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,MAAM,CAAC;AACtB,QAAM,OAAO,OAAO,CAAC;AACrB,QAAM,OAAO,MAAM,CAAC,EAAE,KAAA;AACtB,MAAI,SAAS,OAAO,KAAK,SAAS,GAAG,EAAG,QAAO;AAC/C,SAAO,EAAE,MAAM,QAAQ,OAAO,QAAQ,KAAA;AACxC;AAEA,MAAM,oBAAoB,CAAC,SAA0B,IAAI,OAAO,IAAI,iBAAiB,KAAK,EAAE,KAAK,KAAK,KAAA,CAAM;AAG5G,MAAM,sBAAsB,MAAc,IAAI,OAAO,eAAe,oBAAoB,KAAK;AAK7F,MAAM,WAAW,CAAC,MAAc,cAA8D;AAC5F,QAAM,eAAe,KAAK,QAAQ,MAAM,SAAS;AACjD,QAAM,UAAU,iBAAiB,KAAK,KAAK,SAAS;AACpD,QAAM,YAAY,iBAAiB,KAAK,KAAK,SAAS,eAAe;AACrE,QAAM,aAAa,KAAK,MAAM,WAAW,OAAO;AAChD,SAAO,EAAE,SAAS,WAAW,SAAS,IAAI,IAAI,WAAW,MAAM,GAAG,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AA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,MAAA;AAAA,IAAA,IAEA;AAAA,IACJ,qBAAC,OAAA,EAAI,WAAWA,SAAO,iBACrB,UAAA;AAAA,MAAA,oBAAC,OAAA,EAAI,KAAK,aAER,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,WAAW,aAAa;AAAA,UACxB;AAAA,QAAA;AAAA,MAAA,GAEJ;AAAA,MAEC,CAAC,oBACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SAAQ;AAAA,UACR,MAAM,SAAS,UAAU;AAAA,UACzB,SAAS;AAAA,UACT,MAAK;AAAA,QAAA;AAAA,MAAA,IAEL;AAAA,IAAA,GACN;AAAA,IAGC,gBAAgB,oBAAC,eAAA,EAAc,SAAAD,SAAA,CAAkB,IAAK;AAAA,EAAA,GACzD;AAEJ,CAAC;;;;;ACpIM,MAAM,gBAAgB,CAAC,UAA8B;AAC1D,QAAM,EAAE,OAAO,GAAA,IAAO;AACtB,6BACG,OAAA,EAAI,WAAW,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,SAAQ,aAAY,eAAW,MAAC,WAAU,SAChG,8BAAC,QAAA,EAAK,GAAE,wDAAuD,EAAA,CACjE;AAEJ;"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { X as getWidgetSelfHydrationKeyFieldName, a8 as useAgentsStateSelector, a7 as useAgentsStateDispatch, ac as WidgetHydrationSlice, m as Skeleton, E as classNames, n as SkeletonText, w as WidgetText, H as HeroRow, f as HeroValue, r as Text, q as StatusChip, B as Button, I as Icon, F as escapePlainTextForText, a0 as translateText, a6 as useAgentsOwnerSettings, k as RangeSlider, U as getSandboxLegacyAliases, N as getFurtherCanvasBehaviours, u as Tooltip, K as getAgentsEnvironment, y as buildUnnamedAgentSpaceLabel, z as buildWidgetOfAnotherAgentSpaceExplanation, g as InteractiveSurface, i as Markdown, t as TextInput, s as TextArea, a1 as useAgentsActiveAgentSpaceKey, C as Checkbox, x as appendAnotherAgentSpaceToOwnerText, a as ConversationSearchResultsList } from "./index-
|
|
4
|
-
import { createContext,
|
|
3
|
+
import { X as getWidgetSelfHydrationKeyFieldName, a8 as useAgentsStateSelector, a7 as useAgentsStateDispatch, ac as WidgetHydrationSlice, m as Skeleton, E as classNames, n as SkeletonText, w as WidgetText, H as HeroRow, f as HeroValue, r as Text, q as StatusChip, B as Button, I as Icon, F as escapePlainTextForText, a0 as translateText, a6 as useAgentsOwnerSettings, k as RangeSlider, U as getSandboxLegacyAliases, N as getFurtherCanvasBehaviours, u as Tooltip, K as getAgentsEnvironment, y as buildUnnamedAgentSpaceLabel, z as buildWidgetOfAnotherAgentSpaceExplanation, g as InteractiveSurface, i as Markdown, t as TextInput, s as TextArea, a1 as useAgentsActiveAgentSpaceKey, C as Checkbox, x as appendAnotherAgentSpaceToOwnerText, a as ConversationSearchResultsList } from "./index-DAEGct6X.js";
|
|
4
|
+
import { createContext, useMemo, useContext, useEffect, useId, useRef, useCallback, useState, useSyncExternalStore, useLayoutEffect } from "react";
|
|
5
5
|
import { t as textKey } from "./text-key-DnoZ4lAk.js";
|
|
6
|
-
import { u as useAgentsLinkNavigation, A as AgentsLink } from "./link-navigation-
|
|
6
|
+
import { u as useAgentsLinkNavigation, A as AgentsLink } from "./link-navigation-DQWyeNkx.js";
|
|
7
7
|
import { createPortal } from "react-dom";
|
|
8
8
|
import { visit } from "unist-util-visit";
|
|
9
|
-
const ConversationWidgetRenderContext = createContext("conversation");
|
|
10
|
-
const useIsEmailWidgetRender = () => useContext(ConversationWidgetRenderContext) === "email";
|
|
11
9
|
const defaultConversationWidgetCallbacks = {
|
|
12
10
|
canvas: null,
|
|
13
11
|
hostHasCanvasSurface: false,
|
|
@@ -58,6 +56,16 @@ const StandaloneConversationWidgetProvider = (props) => {
|
|
|
58
56
|
return /* @__PURE__ */ jsx(ConversationWidgetContext.Provider, { value, children });
|
|
59
57
|
};
|
|
60
58
|
const useConversationWidgetContext = () => useContext(ConversationWidgetContext);
|
|
59
|
+
const WidgetRenderReportContext = createContext(null);
|
|
60
|
+
const useReportWidgetRenderStatus = (status, code, detail) => {
|
|
61
|
+
const reporter = useContext(WidgetRenderReportContext);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
reporter?.report({ status, ...code ? { code } : {}, ...detail ? { detail } : {} });
|
|
64
|
+
}, [reporter, status, code, detail]);
|
|
65
|
+
};
|
|
66
|
+
const useWidgetRenderReporter = () => useContext(WidgetRenderReportContext);
|
|
67
|
+
const ConversationWidgetRenderContext = createContext("conversation");
|
|
68
|
+
const useIsEmailWidgetRender = () => useContext(ConversationWidgetRenderContext) === "email";
|
|
61
69
|
const readWidgetAgentSpaceKeyAttribute = (propsOrFields) => {
|
|
62
70
|
const attribute = propsOrFields[getWidgetSelfHydrationKeyFieldName()];
|
|
63
71
|
return typeof attribute === "string" || typeof attribute === "number" ? attribute : void 0;
|
|
@@ -99,14 +107,6 @@ const referenceOfCanvasInstanceId = (instanceId) => {
|
|
|
99
107
|
return match && isCanvasReference(match[1]) ? match[1] : void 0;
|
|
100
108
|
};
|
|
101
109
|
const isCanvasAnchorLoaded = (anchor2, loadedMessageIds) => anchor2.kind === "page" || loadedMessageIds.includes(anchor2.messageId);
|
|
102
|
-
const WidgetRenderReportContext = createContext(null);
|
|
103
|
-
const useReportWidgetRenderStatus = (status, code, detail) => {
|
|
104
|
-
const reporter = useContext(WidgetRenderReportContext);
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
reporter?.report({ status, ...code ? { code } : {}, ...detail ? { detail } : {} });
|
|
107
|
-
}, [reporter, status, code, detail]);
|
|
108
|
-
};
|
|
109
|
-
const useWidgetRenderReporter = () => useContext(WidgetRenderReportContext);
|
|
110
110
|
const useWidgetMemory = (key) => {
|
|
111
111
|
return useAgentsStateSelector((state2) => {
|
|
112
112
|
return state2.AIExtensionsWidgetHydration?.widgets[key];
|
|
@@ -2497,10 +2497,19 @@ const nodeIdOfReference = (reference) => {
|
|
|
2497
2497
|
const match = /^[\w-]+\/([\w-]+)$/.exec(reference.trim());
|
|
2498
2498
|
return match?.[1] ?? null;
|
|
2499
2499
|
};
|
|
2500
|
+
const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/;
|
|
2500
2501
|
const safeDriveFileOpenLink = (link, origin) => {
|
|
2501
2502
|
const trimmed = (link ?? "").trim();
|
|
2502
|
-
if (trimmed === "") return null;
|
|
2503
|
-
if (trimmed.startsWith("/"))
|
|
2503
|
+
if (trimmed === "" || CONTROL_CHARACTER.test(trimmed)) return null;
|
|
2504
|
+
if (trimmed.startsWith("/")) {
|
|
2505
|
+
if (trimmed.startsWith("//") || trimmed.includes("\\")) return null;
|
|
2506
|
+
if (origin === null) return trimmed;
|
|
2507
|
+
try {
|
|
2508
|
+
return new URL(trimmed, origin).origin === origin ? trimmed : null;
|
|
2509
|
+
} catch {
|
|
2510
|
+
return null;
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2504
2513
|
if (origin === null) return null;
|
|
2505
2514
|
try {
|
|
2506
2515
|
const url = new URL(trimmed);
|
|
@@ -5115,40 +5124,40 @@ const WebSearchResultsConversationWidget = (props) => {
|
|
|
5115
5124
|
);
|
|
5116
5125
|
};
|
|
5117
5126
|
export {
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5127
|
+
readWidgetAgentSpaceKeyAttribute as $,
|
|
5128
|
+
ConversationWidgetContext as A,
|
|
5129
|
+
ConversationWidgetRenderContext as B,
|
|
5121
5130
|
CANVAS_BOXED_INSET_PX as C,
|
|
5122
5131
|
DEFAULT_CANVAS_WIDTH_PERCENT as D,
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5132
|
+
buildWidgetAgentSpaceKeyProps as E,
|
|
5133
|
+
canvasInstanceIdForActiveAgentSpace as F,
|
|
5134
|
+
canvasInstanceIdForAgentSpace as G,
|
|
5135
|
+
canvasInstanceIdForEntity as H,
|
|
5136
|
+
canvasInstanceIdForMessage as I,
|
|
5137
|
+
canvasInstanceIdForMessagePayload as J,
|
|
5138
|
+
canvasInstanceIdForReference as K,
|
|
5130
5139
|
LEGACY_CARD_CLICK_ORIGIN as L,
|
|
5131
5140
|
ModelText as M,
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5141
|
+
canvasKindOpenerWidgetNamesOf as N,
|
|
5142
|
+
canvasWidthPercentOf as O,
|
|
5143
|
+
defaultConversationWidgetCallbacks as P,
|
|
5144
|
+
entityIdOfInstanceId as Q,
|
|
5136
5145
|
ReadOnlyConversationWidgetProvider as R,
|
|
5137
5146
|
StandaloneConversationWidgetProvider as S,
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5147
|
+
getDeclaredCanvasIds as T,
|
|
5148
|
+
hasWidgetHydrator as U,
|
|
5149
|
+
isCanvasAnchorLoaded as V,
|
|
5141
5150
|
WidgetRenderReportContext as W,
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5151
|
+
isCanvasReference as X,
|
|
5152
|
+
messageAnchor as Y,
|
|
5153
|
+
packageCanvasBehaviours as Z,
|
|
5154
|
+
pageAnchor as _,
|
|
5155
|
+
useConversationWidgetContext as a,
|
|
5147
5156
|
pickAllowedValue as a$,
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5157
|
+
referenceOfCanvasInstanceId as a0,
|
|
5158
|
+
sameCanvasAnchor as a1,
|
|
5159
|
+
shortStringHash as a2,
|
|
5160
|
+
useIsEmailWidgetRender as a3,
|
|
5152
5161
|
useWidgetHydration as a4,
|
|
5153
5162
|
useWidgetMemory as a5,
|
|
5154
5163
|
useWidgetRenderReporter as a6,
|
|
@@ -5208,7 +5217,7 @@ export {
|
|
|
5208
5217
|
QuickRepliesConversationWidget as ax,
|
|
5209
5218
|
SkeletonCircle as ay,
|
|
5210
5219
|
SkeletonLine as az,
|
|
5211
|
-
|
|
5220
|
+
isPackageCanvasId as b,
|
|
5212
5221
|
pickReviewExternalId as b0,
|
|
5213
5222
|
pickSafeAlias as b1,
|
|
5214
5223
|
pickSafeAliases as b2,
|
|
@@ -5254,29 +5263,29 @@ export {
|
|
|
5254
5263
|
toEntityMentionWireFields as bx,
|
|
5255
5264
|
ConversationWidgetButton as by,
|
|
5256
5265
|
ImageGallery as bz,
|
|
5257
|
-
|
|
5266
|
+
registerConceptExplainerTypes as c,
|
|
5258
5267
|
declareCanvasKind as d,
|
|
5259
|
-
|
|
5268
|
+
registerDriveFileCanvasOpener as e,
|
|
5260
5269
|
forgetCanvasKind as f,
|
|
5261
|
-
|
|
5262
|
-
|
|
5270
|
+
registerDriveFileCardsSource as g,
|
|
5271
|
+
registerFilePreviewSource as h,
|
|
5263
5272
|
isCanvasId as i,
|
|
5264
|
-
|
|
5265
|
-
|
|
5273
|
+
registerWidgetHydrator as j,
|
|
5274
|
+
canvasBehaviourOf as k,
|
|
5266
5275
|
listWidgetHydratorTypes as l,
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5276
|
+
getWidgetHydrator as m,
|
|
5277
|
+
abandonWidgetHydrationReads as n,
|
|
5278
|
+
unregisterWidgetHydrator as o,
|
|
5279
|
+
useResolvedConversationWidgetAgentSpaceKey as p,
|
|
5280
|
+
payloadHashOfInstanceId as q,
|
|
5272
5281
|
readConceptExplainerTypeDefinitions as r,
|
|
5273
5282
|
sameCanvasIdentity as s,
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
};
|
|
5282
|
-
//# sourceMappingURL=WebSearchResultsConversationWidget-
|
|
5283
|
+
CANVAS_FILLS_SCREEN_WIDTH_PERCENT as t,
|
|
5284
|
+
useReportWidgetRenderStatus as u,
|
|
5285
|
+
CANVAS_MIN_WIDTH_PX as v,
|
|
5286
|
+
CHAT_COLUMN_MIN_WIDTH_PX as w,
|
|
5287
|
+
ConversationWidgetActions as x,
|
|
5288
|
+
ConversationWidgetAgentSpaceFrame as y,
|
|
5289
|
+
ConversationWidgetAgentSpaceHeader as z
|
|
5290
|
+
};
|
|
5291
|
+
//# sourceMappingURL=WebSearchResultsConversationWidget-BM624Fcx.js.map
|