@mgamadeus/ddd-agents 0.1.0-alpha.22 → 0.1.0-alpha.24

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.
Files changed (164) hide show
  1. package/README.md +3 -2
  2. package/dist/chat.js +87 -893
  3. package/dist/chat.js.map +1 -1
  4. package/dist/chunks/ConversationMessageInputComposerWidgets-BxyaFBA6.js +631 -0
  5. package/dist/chunks/ConversationMessageInputComposerWidgets-BxyaFBA6.js.map +1 -0
  6. package/dist/chunks/{WebSearchResultsConversationWidget-BvnLWHyi.js → WebSearchResultsConversationWidget-as3p5bHw.js} +147 -1125
  7. package/dist/chunks/WebSearchResultsConversationWidget-as3p5bHw.js.map +1 -0
  8. package/dist/chunks/{canvas-behaviours-BRFR1ALE.js → canvas-behaviours-AvzKSYyv.js} +4 -4
  9. package/dist/chunks/{canvas-behaviours-BRFR1ALE.js.map → canvas-behaviours-AvzKSYyv.js.map} +1 -1
  10. package/dist/chunks/canvas-reducers-Bfp_i7lc.js +88 -0
  11. package/dist/chunks/canvas-reducers-Bfp_i7lc.js.map +1 -0
  12. package/dist/chunks/{canvasBodies-9SuF6NAB.js → canvasBodies-Cvu3l38p.js} +12 -6
  13. package/dist/chunks/canvasBodies-Cvu3l38p.js.map +1 -0
  14. package/dist/chunks/canvasStorage-EvQsGdto.js +65 -0
  15. package/dist/chunks/canvasStorage-EvQsGdto.js.map +1 -0
  16. package/dist/chunks/contract-BxmMxYPF.js +96 -0
  17. package/dist/chunks/contract-BxmMxYPF.js.map +1 -0
  18. package/dist/chunks/conversation-BEF0aesf.js +31 -0
  19. package/dist/chunks/conversation-BEF0aesf.js.map +1 -0
  20. package/dist/chunks/entity-detail-name-3A82gDAp.js +15 -0
  21. package/dist/chunks/entity-detail-name-3A82gDAp.js.map +1 -0
  22. package/dist/chunks/icon-names-Di6c4zLo.js +86 -0
  23. package/dist/chunks/icon-names-Di6c4zLo.js.map +1 -0
  24. package/dist/chunks/index-7Qc_3GbG.js +1046 -0
  25. package/dist/chunks/index-7Qc_3GbG.js.map +1 -0
  26. package/dist/chunks/{ConversationMarkdown-W7NHglmL.js → widget-click-signal-sources-DulRkNvZ.js} +54 -7
  27. package/dist/chunks/widget-click-signal-sources-DulRkNvZ.js.map +1 -0
  28. package/dist/chunks/{widget-image-readiness-signal-DeOuL89j.js → widget-image-readiness-signal-D3ci53xr.js} +2 -2
  29. package/dist/chunks/{widget-image-readiness-signal-DeOuL89j.js.map → widget-image-readiness-signal-D3ci53xr.js.map} +1 -1
  30. package/dist/chunks/{widget-name-resolver-DyIY6Zu4.js → widget-name-resolver-BGN3HpoG.js} +80 -117
  31. package/dist/chunks/widget-name-resolver-BGN3HpoG.js.map +1 -0
  32. package/dist/chunks/{withPollingChangeSubscription-BLDAWF-o.js → withPollingChangeSubscription-B16htQGd.js} +2 -2
  33. package/dist/chunks/{withPollingChangeSubscription-BLDAWF-o.js.map → withPollingChangeSubscription-B16htQGd.js.map} +1 -1
  34. package/dist/client-testing.js +91 -2
  35. package/dist/client-testing.js.map +1 -1
  36. package/dist/client.js +1 -1
  37. package/dist/contract.js +8 -27
  38. package/dist/contract.js.map +1 -1
  39. package/dist/files/chat/Conversation.module.scss +268 -0
  40. package/dist/files/chat/ConversationViewBody/ConversationViewBody.module.scss +336 -0
  41. package/dist/files/chat/_conversation-tokens.scss +37 -0
  42. package/dist/files/image-render/WidgetImageRender.module.scss +22 -0
  43. package/dist/files/kit/ComposedViewConversationWidget.md +59 -0
  44. package/dist/files/kit/components/data/data.preview-fixtures.json +3298 -0
  45. package/dist/files/kit/components/embedding/widget.preview-fixtures.json +147 -0
  46. package/dist/files/kit/components/entity/entity-link.preview-fixtures.json +340 -0
  47. package/dist/files/kit/components/form/form.preview-fixtures.json +319 -0
  48. package/dist/files/kit/components/inputs/button.preview-fixtures.json +301 -0
  49. package/dist/files/kit/components/inputs/checkbox.preview-fixtures.json +35 -0
  50. package/dist/files/kit/components/inputs/date-picker.preview-fixtures.json +36 -0
  51. package/dist/files/kit/components/inputs/input.preview-fixtures.json +55 -0
  52. package/dist/files/kit/components/inputs/radio-group.preview-fixtures.json +76 -0
  53. package/dist/files/kit/components/inputs/select.preview-fixtures.json +314 -0
  54. package/dist/files/kit/components/inputs/slider.preview-fixtures.json +178 -0
  55. package/dist/files/kit/components/inputs/tabs.preview-fixtures.json +304 -0
  56. package/dist/files/kit/components/inputs/textarea.preview-fixtures.json +37 -0
  57. package/dist/files/kit/components/layout/layout.preview-fixtures.json +892 -0
  58. package/dist/files/kit/components/map/map.preview-fixtures.json +339 -0
  59. package/dist/files/kit/components/media/image-group.preview-fixtures.json +228 -0
  60. package/dist/files/kit/components/media/image.preview-fixtures.json +61 -0
  61. package/dist/files/kit/components/media/video-card/video-card.preview-fixtures.json +121 -0
  62. package/dist/files/kit/components/media/video.preview-fixtures.json +68 -0
  63. package/dist/files/kit/components/rich/code.preview-fixtures.json +105 -0
  64. package/dist/files/kit/components/rich/diagram.preview-fixtures.json +89 -0
  65. package/dist/files/kit/components/rich/math.preview-fixtures.json +152 -0
  66. package/dist/files/kit/components/rich/svg.preview-fixtures.json +243 -0
  67. package/dist/files/kit/components/text/badge.preview-fixtures.json +44 -0
  68. package/dist/files/kit/components/text/caption.preview-fixtures.json +31 -0
  69. package/dist/files/kit/components/text/favicon.preview-fixtures.json +69 -0
  70. package/dist/files/kit/components/text/label.preview-fixtures.json +48 -0
  71. package/dist/files/kit/components/text/link.preview-fixtures.json +103 -0
  72. package/dist/files/kit/components/text/markdown.preview-fixtures.json +29 -0
  73. package/dist/files/kit/components/text/source-ref.preview-fixtures.json +51 -0
  74. package/dist/files/kit/components/text/text.preview-fixtures.json +106 -0
  75. package/dist/files/kit/components/text/title.preview-fixtures.json +172 -0
  76. package/dist/files/kit/composed-view-widget-contract.json +88 -0
  77. package/dist/files/kit/composed-view.preview-fixtures.json +376 -0
  78. package/dist/files/renderer/conversation-widget-layout.module.scss +47 -0
  79. package/dist/files/renderer/widget-tree/composed-node-schema.json +3428 -0
  80. package/dist/files/styles/_conversation-widget-container.scss +6 -0
  81. package/dist/files/styles/_media.scss +50 -0
  82. package/dist/files/styles/_spacings.scss +23 -0
  83. package/dist/files/styles/_surfaces.scss +28 -0
  84. package/dist/files/widgets/ClockConversationWidget/ClockConversationWidget.md +53 -0
  85. package/dist/files/widgets/ClockConversationWidget/clock.preview-fixtures.json +76 -0
  86. package/dist/files/widgets/ConceptExplainerConversationWidget/ConceptExplainerConversationWidget.md +86 -0
  87. package/dist/files/widgets/ConceptExplainerConversationWidget/concept-explainer.preview-fixtures.json +23 -0
  88. package/dist/files/widgets/ConversationSearchResultsConversationWidget/ConversationSearchResultsConversationWidget.md +59 -0
  89. package/dist/files/widgets/ConversationSearchResultsConversationWidget/conversation-search-results.preview-fixtures.json +85 -0
  90. package/dist/files/widgets/CurrencyConverterConversationWidget/CurrencyConverterConversationWidget.md +51 -0
  91. package/dist/files/widgets/CurrencyConverterConversationWidget/currency-converter.preview-fixtures.json +73 -0
  92. package/dist/files/widgets/CustomVisualizationConversationWidget/CustomVisualizationConversationWidget.md +83 -0
  93. package/dist/files/widgets/CustomVisualizationConversationWidget/custom-visualization.preview-fixtures.json +227 -0
  94. package/dist/files/widgets/CustomVisualizationConversationWidget/sandbox-frame/custom-visualization-frame.html +188 -0
  95. package/dist/files/widgets/EntityMentionConversationWidget/EntityMentionConversationWidget.md +55 -0
  96. package/dist/files/widgets/EntityMentionConversationWidget/entity-mention.preview-fixtures.json +55 -0
  97. package/dist/files/widgets/MultiChoiceConversationWidget/MultiChoiceConversationWidget.md +61 -0
  98. package/dist/files/widgets/MultiChoiceConversationWidget/multi-choice-widget-contract.json +43 -0
  99. package/dist/files/widgets/MultiChoiceConversationWidget/multi-choice.preview-fixtures.json +103 -0
  100. package/dist/files/widgets/QuickRepliesConversationWidget/QuickRepliesConversationWidget.md +65 -0
  101. package/dist/files/widgets/QuickRepliesConversationWidget/quick-replies-widget-contract.json +43 -0
  102. package/dist/files/widgets/QuickRepliesConversationWidget/quick-replies.preview-fixtures.json +45 -0
  103. package/dist/files/widgets/SuggestedActions/SuggestedActions.md +60 -0
  104. package/dist/files/widgets/SuggestedActions/suggested-actions.preview-fixtures.json +19 -0
  105. package/dist/files/widgets/ToolTraceConversationWidget/ToolTraceConversationWidget.md +48 -0
  106. package/dist/files/widgets/ToolTraceConversationWidget/tool-trace.preview-fixtures.json +32 -0
  107. package/dist/files/widgets/WebSearchResultsConversationWidget/WebSearchResultsConversationWidget.md +49 -0
  108. package/dist/files/widgets/WebSearchResultsConversationWidget/web-search-results.preview-fixtures.json +57 -0
  109. package/dist/files/widgets/WritingDraftConversationWidget/WritingDraftConversationWidget.md +66 -0
  110. package/dist/files/widgets/WritingDraftConversationWidget/writing-draft.preview-fixtures.json +129 -0
  111. package/dist/image-render.js +11 -10
  112. package/dist/image-render.js.map +1 -1
  113. package/dist/index.js +32 -27
  114. package/dist/index.js.map +1 -1
  115. package/dist/kit.js +11 -2
  116. package/dist/kit.js.map +1 -1
  117. package/dist/preview.js +47 -18
  118. package/dist/preview.js.map +1 -1
  119. package/dist/provider.js +71 -0
  120. package/dist/provider.js.map +1 -0
  121. package/dist/renderer.js +142 -62
  122. package/dist/renderer.js.map +1 -1
  123. package/dist/styles.css +86 -38
  124. package/dist/types/client/testing/test-conversation-widgets.d.ts +25 -0
  125. package/dist/types/client/testing/widget-hydration-stand-ins.d.ts +42 -0
  126. package/dist/types/entries/chat.d.ts +12 -0
  127. package/dist/types/entries/client-testing.d.ts +4 -0
  128. package/dist/types/entries/contract.d.ts +1 -0
  129. package/dist/types/entries/index.d.ts +4 -3
  130. package/dist/types/entries/kit.d.ts +7 -0
  131. package/dist/types/entries/preview.d.ts +2 -0
  132. package/dist/types/entries/provider.d.ts +1 -0
  133. package/dist/types/entries/renderer.d.ts +19 -1
  134. package/dist/types/entries/widgets.d.ts +13 -0
  135. package/dist/types/kit/components/data/apex-chart-component.d.ts +3 -0
  136. package/dist/types/kit/components/data/chart-model.d.ts +164 -0
  137. package/dist/types/kit/components/data/data-value-format.d.ts +44 -0
  138. package/dist/types/kit/components/data/use-chart-palette.d.ts +9 -0
  139. package/dist/types/kit/components/data/use-number-locale.d.ts +5 -0
  140. package/dist/types/kit/components/map/use-google-maps-auth-failure.d.ts +18 -0
  141. package/dist/types/kit/entity-detail/entity-detail-bodies.d.ts +2 -0
  142. package/dist/types/provider/index.d.ts +1 -0
  143. package/dist/types/renderer/_access/ConversationWidgetGateSkeleton.d.ts +6 -0
  144. package/dist/types/renderer/_agent-space/use-conversation-widget-agent-space-fallback.d.ts +16 -0
  145. package/dist/types/renderer/canvas/entity-detail-instance.d.ts +5 -3
  146. package/dist/types/renderer/canvas/use-anchor-widget-agent-space-key.d.ts +17 -0
  147. package/dist/types/renderer/conversationWidgetRegistry.d.ts +6 -0
  148. package/dist/types/renderer/read-conversation-widget-variant.d.ts +22 -0
  149. package/dist/types/renderer/widget-hydration/use-widget-hydration.d.ts +5 -0
  150. package/dist/types/widgets/EntityMentionConversationWidget/stories/EntityMentionAskFlowStory.d.ts +8 -0
  151. package/dist/types/widgets/_shared/CardFooter.d.ts +6 -0
  152. package/dist/types/widgets/_shared/WidgetLabel.d.ts +8 -0
  153. package/dist/types/widgets/_shared/entity-update-channel.d.ts +17 -0
  154. package/dist/types/widgets/_shared/use-element-visible.d.ts +6 -0
  155. package/dist/widgets.js +120 -27
  156. package/dist/widgets.js.map +1 -1
  157. package/package.json +74 -1
  158. package/public-api.json +779 -0
  159. package/dist/chunks/ConversationMarkdown-W7NHglmL.js.map +0 -1
  160. package/dist/chunks/WebSearchResultsConversationWidget-BvnLWHyi.js.map +0 -1
  161. package/dist/chunks/canvasBodies-9SuF6NAB.js.map +0 -1
  162. package/dist/chunks/decide-canvas-open-Ct-wnNEJ.js +0 -20
  163. package/dist/chunks/decide-canvas-open-Ct-wnNEJ.js.map +0 -1
  164. package/dist/chunks/widget-name-resolver-DyIY6Zu4.js.map +0 -1
package/dist/chat.js CHANGED
@@ -1,29 +1,33 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
- import { useRef, useEffect, useMemo, useCallback, useSyncExternalStore, useContext, createContext, useState, useImperativeHandle, useLayoutEffect, memo, Fragment as Fragment$1, useReducer } from "react";
3
+ import { useRef, useEffect, useMemo, useState, useImperativeHandle, useLayoutEffect, useCallback, useContext, memo, Fragment as Fragment$1, useReducer } from "react";
4
4
  import { u as useAgentsConversationClient, a as useOptionalAgentsConversationClient } from "./chunks/AgentsConversationClientContext-C4T7g_Qk.js";
5
- import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-BLDAWF-o.js";
6
- import { q as Text, I as Icon, aA as useConversationWidgetContext, ax as payloadHashOfInstanceId, b0 as buildWidgetAgentSpaceKeyProps, ab as sameCanvasIdentity, a5 as useAgentsEnvironment, a8 as useAgentsStateDispatch, a9 as useAgentsStateSelector, bh as CANVAS_VIABLE_MIN_WIDTH, ad as ConversationWidgetContext, a1 as translateText, G as GlowFrame, t as Tooltip, B as Button, z as classNames, l as Skeleton, N as getFurtherWidgetClickSignalSources, h as Markdown, F as getAgentDisplayName, a3 as useAgentsBudgetLimit, f as InteractiveSurface, L as LoadingSpinner, bk as useCanvasViable, n as SplitView, _ as reportRunningTurn, a2 as useAgentsActiveAgentSpaceKey, P as ProgressBar } from "./chunks/WebSearchResultsConversationWidget-BvnLWHyi.js";
7
- import { isAgentsClientError, AgentsClientError } from "./contract.js";
8
- import { W as WIDGET_FENCE_LANG, v as resolveWidgetName, o as conversationWidgetRegistry, B as findWidgetFencesInMarkdown, j as ConversationWidgetErrorBoundary, k as ConversationWidgetFeatureGate, N as parseWidgetJsonObject, u as resolveCanonicalWidgetName, q as getConversationWidgetRegistryRevision, O as BARE_WIDGET_LINE_GLOBAL, m as closestWidgetNames } from "./chunks/widget-name-resolver-DyIY6Zu4.js";
9
- import { i as isCanvasId, d as canvasBehaviourOf, c as CHAT_COLUMN_MIN_WIDTH_PX, b as CANVAS_MIN_WIDTH_PX, D as DEFAULT_CANVAS_WIDTH_PERCENT, e as canvasWidthPercentOf, C as CANVAS_BOXED_INSET_PX } from "./chunks/canvas-behaviours-BRFR1ALE.js";
10
- import { d as decideCanvasOpen } from "./chunks/decide-canvas-open-Ct-wnNEJ.js";
11
- import { W as WidgetWindowRootContext, C as ConversationMarkdown, b as buildWidgetRenderReportSignal, c as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, d as createWidgetRenderReportCollector, e as WidgetRenderReportCollectorContext } from "./chunks/ConversationMarkdown-W7NHglmL.js";
12
- import { c as canvasBodies } from "./chunks/canvasBodies-9SuF6NAB.js";
5
+ import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-B16htQGd.js";
6
+ import { q as Text, I as Icon, $ as translateText, G as GlowFrame, t as Tooltip, B as Button, z as classNames, l as Skeleton, a3 as useAgentsEnvironment, h as Markdown, F as getAgentDisplayName, a1 as useAgentsBudgetLimit, f as InteractiveSurface, L as LoadingSpinner, n as SplitView, Y as reportRunningTurn, a0 as useAgentsActiveAgentSpaceKey, P as ProgressBar } from "./chunks/index-7Qc_3GbG.js";
7
+ import { i as isAgentsClientError, A as AgentsClientError } from "./chunks/conversation-BEF0aesf.js";
8
+ import { W as WIDGET_FENCE_LANG, G as resolveWidgetName, j as conversationWidgetRegistry, n as findWidgetFencesInMarkdown, o as ConversationWidgetErrorBoundary, p as ConversationWidgetFeatureGate, T as parseWidgetJsonObject, F as resolveCanonicalWidgetName, y as getConversationWidgetRegistryRevision, U as BARE_WIDGET_LINE_GLOBAL, t as closestWidgetNames } from "./chunks/widget-name-resolver-BGN3HpoG.js";
9
+ import { E as useConversationWidgetContext, p as payloadHashOfInstanceId, j as buildWidgetAgentSpaceKeyProps, ap as useCanvasViable } from "./chunks/WebSearchResultsConversationWidget-as3p5bHw.js";
10
+ import { c as canvasBehaviourOf, d as CHAT_COLUMN_MIN_WIDTH_PX, b as CANVAS_MIN_WIDTH_PX, D as DEFAULT_CANVAS_WIDTH_PERCENT, e as canvasWidthPercentOf, C as CANVAS_BOXED_INSET_PX } from "./chunks/canvas-behaviours-AvzKSYyv.js";
11
+ import { r as readStoredCanvas, c as clearStoredCanvas } from "./chunks/canvasStorage-EvQsGdto.js";
12
+ import { r as resolveDeepLinkableWidget, c as WidgetWindowRootContext, C as ConversationMarkdown, i as isWidgetClickSignalSource, b as buildWidgetRenderReportSignal, W as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, e as createWidgetRenderReportCollector, f as WidgetRenderReportCollectorContext } from "./chunks/widget-click-signal-sources-DulRkNvZ.js";
13
+ import { b as ConversationErrorType, a as ConversationMessageInputComposerWidgets, u as useAgentsChatSelector, C as ConversationWidgetProvider, c as createAgentsChatStore } from "./chunks/ConversationMessageInputComposerWidgets-BxyaFBA6.js";
14
+ import { A, d, E, I, r, e, f, g, h } from "./chunks/ConversationMessageInputComposerWidgets-BxyaFBA6.js";
15
+ import { c as canvasBodies } from "./chunks/canvasBodies-Cvu3l38p.js";
13
16
  import { c as canvasFeatureFlagOf } from "./chunks/canvas-feature-flags-BmmxC3bz.js";
14
17
  import { flushSync } from "react-dom";
18
+ import { b as buildChangedMessagesRequest, d as deriveAgentActivity } from "./chunks/contract-BxmMxYPF.js";
15
19
  const history = "agents_history_BIbikt";
16
- const styles$m = {
20
+ const styles$l = {
17
21
  history
18
22
  };
19
23
  const AgentChatActivityHistory = (props) => {
20
24
  const { turn } = props;
21
25
  if (turn === null || turn.lines.length === 0) return null;
22
- return /* @__PURE__ */ jsx("div", { className: styles$m.history, "data-testid": "agent-chat-activity-history", children: turn.lines.map((line) => /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", translate: false, children: line.line }, `${line.toolCallMessageId}-${line.state}`)) });
26
+ return /* @__PURE__ */ jsx("div", { className: styles$l.history, "data-testid": "agent-chat-activity-history", children: turn.lines.map((line) => /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", translate: false, children: line.line }, `${line.toolCallMessageId}-${line.state}`)) });
23
27
  };
24
28
  const activity = "agents_activity_Gv-0ee";
25
29
  const dots = "agents_dots_Qvm8gN";
26
- const styles$l = {
30
+ const styles$k = {
27
31
  activity,
28
32
  dots
29
33
  };
@@ -33,8 +37,8 @@ const AgentChatActivityIndicator = (props) => {
33
37
  if (!isWorking) return null;
34
38
  const currentLines = activityTicker.currentTurn?.lines ?? [];
35
39
  const currentLine = currentLines.length > 0 ? currentLines[currentLines.length - 1].line : null;
36
- return /* @__PURE__ */ jsxs("div", { className: styles$l.activity, role: "status", "aria-live": "polite", "data-testid": "agent-chat-activity", children: [
37
- /* @__PURE__ */ jsxs("div", { className: styles$l.dots, "aria-hidden": "true", children: [
40
+ return /* @__PURE__ */ jsxs("div", { className: styles$k.activity, role: "status", "aria-live": "polite", "data-testid": "agent-chat-activity", children: [
41
+ /* @__PURE__ */ jsxs("div", { className: styles$k.dots, "aria-hidden": "true", children: [
38
42
  /* @__PURE__ */ jsx("span", {}),
39
43
  /* @__PURE__ */ jsx("span", {}),
40
44
  /* @__PURE__ */ jsx("span", {})
@@ -43,12 +47,12 @@ const AgentChatActivityIndicator = (props) => {
43
47
  ] });
44
48
  };
45
49
  const bar = "agents_bar_DAkgRp";
46
- const styles$k = {
50
+ const styles$j = {
47
51
  bar
48
52
  };
49
53
  const ConversationClosedBar = (props) => {
50
54
  const { text = "This conversation is closed." } = props;
51
- return /* @__PURE__ */ jsxs("div", { className: styles$k.bar, "data-testid": "agent-chat-closed-bar", children: [
55
+ return /* @__PURE__ */ jsxs("div", { className: styles$j.bar, "data-testid": "agent-chat-closed-bar", children: [
52
56
  /* @__PURE__ */ jsx(Icon, { name: "check", color: "--agents-success-500" }),
53
57
  /* @__PURE__ */ jsx(Text, { children: text })
54
58
  ] });
@@ -318,63 +322,6 @@ const normalizeServerMessageToMarkdown = (message2) => {
318
322
  }
319
323
  return referenceNakedWidgetJson(repairMalformedWidgetFences(stripPreCallMessageMarker(result)));
320
324
  };
321
- const CANVAS_STORAGE_KEY_PREFIX = "agent.canvas.";
322
- const canvasStorageKey = (conversationId) => `${CANVAS_STORAGE_KEY_PREFIX}${conversationId}`;
323
- const isPositiveInteger = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
324
- const parseAnchor = (value) => {
325
- if (typeof value !== "object" || value === null) return null;
326
- const candidate = value;
327
- if (candidate.kind === "message" && isPositiveInteger(candidate.messageId)) {
328
- return { kind: "message", messageId: candidate.messageId };
329
- }
330
- if (candidate.kind === "page" && isPositiveInteger(candidate.agentSpaceKey)) {
331
- return { kind: "page", agentSpaceKey: candidate.agentSpaceKey };
332
- }
333
- return null;
334
- };
335
- const parseStoredCanvasPointer = (value) => {
336
- if (typeof value !== "object" || value === null) return null;
337
- const candidate = value;
338
- const anchor = parseAnchor(candidate.anchor);
339
- if (!isCanvasId(candidate.canvasId) || anchor === null) return null;
340
- if (typeof candidate.instanceId !== "string" || candidate.instanceId.length === 0) return null;
341
- return {
342
- canvasId: candidate.canvasId,
343
- anchor,
344
- instanceId: candidate.instanceId,
345
- ...isPositiveInteger(candidate.createdEntityId) ? { createdEntityId: candidate.createdEntityId } : {}
346
- };
347
- };
348
- const storeOpenCanvas = (conversationId, canvas) => {
349
- if (conversationId === void 0) return;
350
- const pointer = {
351
- canvasId: canvas.canvasId,
352
- anchor: canvas.anchor,
353
- instanceId: canvas.instanceId,
354
- ...canvas.createdEntityId !== void 0 ? { createdEntityId: canvas.createdEntityId } : {}
355
- };
356
- try {
357
- window.sessionStorage.setItem(canvasStorageKey(conversationId), JSON.stringify(pointer));
358
- } catch {
359
- }
360
- };
361
- const readStoredCanvas = (conversationId) => {
362
- if (conversationId === void 0) return null;
363
- try {
364
- const raw = window.sessionStorage.getItem(canvasStorageKey(conversationId));
365
- if (raw === null) return null;
366
- return parseStoredCanvasPointer(JSON.parse(raw));
367
- } catch {
368
- return null;
369
- }
370
- };
371
- const clearStoredCanvas = (conversationId) => {
372
- if (conversationId === void 0) return;
373
- try {
374
- window.sessionStorage.removeItem(canvasStorageKey(conversationId));
375
- } catch {
376
- }
377
- };
378
325
  const anchorMessageCarriesCanvasWidget = (pointer, anchorMessage) => {
379
326
  const openers = new Set(
380
327
  conversationWidgetRegistry.widgets.filter((entry) => entry.opensCanvases?.includes(pointer.canvasId)).map((entry) => entry.name)
@@ -422,10 +369,6 @@ const CanvasRestoreOnMount = ({ conversationId, messages }) => {
422
369
  }, [conversationId, messages, openCanvas]);
423
370
  return null;
424
371
  };
425
- const resolveDeepLinkableWidget = (widgetName) => {
426
- if (!widgetName) return null;
427
- return conversationWidgetRegistry.widgets.find((entry) => entry.name === widgetName && entry.deepLinkable === true) ?? null;
428
- };
429
372
  const ConversationDeepLinkedWidget = ({ widgetName, agentSpaceKey }) => {
430
373
  const entry = useMemo(() => resolveDeepLinkableWidget(widgetName), [widgetName]);
431
374
  if (!entry) return null;
@@ -441,638 +384,6 @@ const ConversationDeepLinkedWidget = ({ widgetName, agentSpaceKey }) => {
441
384
  }
442
385
  ) : widget });
443
386
  };
444
- const EMPTY_AGENTS_CHAT_OPENING_REQUEST = {
445
- userMessage: null,
446
- startSignalText: null,
447
- entryPointKey: null,
448
- deepLinkedWidgetName: null
449
- };
450
- const INITIAL_AGENTS_CHAT_STATE = {
451
- conversation: null,
452
- messages: null,
453
- conversationLoading: false,
454
- conversationLoaded: false,
455
- hasMoreOlder: false,
456
- aiThinking: false,
457
- error: null,
458
- rateLimitRetryAfterSeconds: null,
459
- requestedConversationId: null,
460
- startingNewConversation: false,
461
- pendingStartToken: null,
462
- startTokenCount: 0,
463
- openingRequest: EMPTY_AGENTS_CHAT_OPENING_REQUEST,
464
- canvas: null,
465
- lastClosedCanvas: null,
466
- canvasMountCount: 0
467
- };
468
- const toLastClosed = (canvas, closedByCustomer) => ({
469
- canvasId: canvas.canvasId,
470
- instanceId: canvas.instanceId,
471
- anchor: canvas.anchor,
472
- mountGeneration: canvas.mountGeneration,
473
- closedByCustomer,
474
- ...canvas.createdEntityId !== void 0 ? { createdEntityId: canvas.createdEntityId } : {}
475
- });
476
- const nextMountGeneration = (state) => {
477
- state.canvasMountCount += 1;
478
- return state.canvasMountCount;
479
- };
480
- const applyOpenCanvas = (state, request) => {
481
- const decision = decideCanvasOpen(canvasBehaviourOf(request.canvasId), state.canvas, state.lastClosedCanvas, request);
482
- if (decision.kind === "ignore") return decision;
483
- const previous = state.canvas;
484
- const mountGeneration = nextMountGeneration(state);
485
- const carriedCreatedEntityId = request.createdEntityId ?? (previous !== null && sameCanvasIdentity(previous, request) ? previous.createdEntityId : void 0) ?? (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request) ? state.lastClosedCanvas.createdEntityId : void 0);
486
- if (previous !== null && !sameCanvasIdentity(previous, request)) {
487
- state.lastClosedCanvas = toLastClosed(previous, false);
488
- } else if (state.lastClosedCanvas !== null && sameCanvasIdentity(state.lastClosedCanvas, request)) {
489
- state.lastClosedCanvas = null;
490
- }
491
- state.canvas = {
492
- canvasId: request.canvasId,
493
- instanceId: request.instanceId,
494
- anchor: request.anchor,
495
- origin: request.origin,
496
- mountGeneration,
497
- ...carriedCreatedEntityId !== void 0 ? { createdEntityId: carriedCreatedEntityId } : {}
498
- };
499
- return decision;
500
- };
501
- const applyCloseCanvas = (state, byCustomer) => {
502
- if (state.canvas === null) return;
503
- state.lastClosedCanvas = toLastClosed(state.canvas, byCustomer);
504
- state.canvas = null;
505
- };
506
- const applyResetCanvasForNewTurn = (state) => {
507
- if (state.canvas !== null && canvasBehaviourOf(state.canvas.canvasId)?.lifetime === "turn") {
508
- state.canvas = null;
509
- }
510
- if (state.lastClosedCanvas !== null) {
511
- if (canvasBehaviourOf(state.lastClosedCanvas.canvasId)?.lifetime === "turn") {
512
- state.lastClosedCanvas = null;
513
- } else if (state.lastClosedCanvas.closedByCustomer) {
514
- state.lastClosedCanvas = { ...state.lastClosedCanvas, closedByCustomer: false };
515
- }
516
- }
517
- };
518
- const applyClearCanvas = (state) => {
519
- state.canvas = null;
520
- state.lastClosedCanvas = null;
521
- };
522
- const applySetCanvasCreatedEntityId = (state, created) => {
523
- const canvas = state.canvas;
524
- if (canvas === null || !sameCanvasIdentity(canvas, created) || canvas.mountGeneration !== created.mountGeneration) {
525
- return false;
526
- }
527
- state.canvas = { ...canvas, createdEntityId: created.createdEntityId };
528
- return true;
529
- };
530
- const ConversationErrorType = {
531
- AI_BUDGET: "AI_BUDGET",
532
- /**
533
- * HTTP 429 from an AI endpoint — a per-minute/hour/day usage quota was hit. Distinct from AI_BUDGET (monthly budget):
534
- * this one clears on its own after the Retry-After window.
535
- */
536
- RATE_LIMIT: "RATE_LIMIT",
537
- NETWORK_ERROR: "NETWORK_ERROR",
538
- CONVERSATION_NOT_FOUND: "CONVERSATION_NOT_FOUND",
539
- /**
540
- * The backend run FAILED (e.g. the model provider returned an error). The raw provider error is admin-only (never
541
- * shown here); the owner gets a generic "something went wrong" card.
542
- */
543
- AGENT_ERROR: "AGENT_ERROR",
544
- /**
545
- * The conversation is COMPLETED/CANCELLED and refuses further owner input. Set from the server's stable error code
546
- * `CONVERSATION_CLOSED` or by the chat's own pre-send guard; the error card owns the copy.
547
- */
548
- CONVERSATION_CLOSED: "CONVERSATION_CLOSED"
549
- };
550
- const readConversationErrorTypeOfRefusedSend = (error) => {
551
- if (error.kind === "budget") return ConversationErrorType.AI_BUDGET;
552
- if (error.kind === "rateLimit") return ConversationErrorType.RATE_LIMIT;
553
- if (error.kind === "closed") return ConversationErrorType.CONVERSATION_CLOSED;
554
- return ConversationErrorType.NETWORK_ERROR;
555
- };
556
- const mergeChatMessagesByIndex = (existing, incoming) => {
557
- const messagesByIndex = /* @__PURE__ */ new Map();
558
- const messagesWithoutIndex = [];
559
- const collectMessage = (message2) => {
560
- if (message2.indexInConversation != null) {
561
- messagesByIndex.set(message2.indexInConversation, message2);
562
- } else {
563
- messagesWithoutIndex.push(message2);
564
- }
565
- };
566
- existing.forEach(collectMessage);
567
- incoming.forEach(collectMessage);
568
- const indexedMessages = Array.from(messagesByIndex.values()).sort(
569
- (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0)
570
- );
571
- return [...indexedMessages, ...messagesWithoutIndex];
572
- };
573
- const tagFreshChatMessages = (incoming, previousMessages) => {
574
- const previousIds = new Set(previousMessages.map((message2) => message2.id).filter((id) => id != null));
575
- return incoming.map((message2) => ({ ...message2, fresh: message2.id != null && !previousIds.has(message2.id) }));
576
- };
577
- const mergeMessagesPage = (loadedMessages, page, requestedConversationId) => {
578
- const shownConversationId = loadedMessages?.find((message2) => message2.conversationId != null)?.conversationId;
579
- const replacesShownConversation = shownConversationId != null && shownConversationId !== requestedConversationId;
580
- const existingMessages = replacesShownConversation ? [] : loadedMessages ?? [];
581
- const messagesByIndex = /* @__PURE__ */ new Map();
582
- for (const existingMessage of existingMessages) {
583
- if (existingMessage.indexInConversation != null) {
584
- messagesByIndex.set(existingMessage.indexInConversation, existingMessage);
585
- }
586
- }
587
- const hadMessagesBeforeMerge = existingMessages.length > 0;
588
- const highestShownIndex = Math.max(-1, ...existingMessages.map((message2) => message2.indexInConversation ?? -1));
589
- for (const incomingMessage of page) {
590
- if (incomingMessage.indexInConversation == null) continue;
591
- const previousMessage = messagesByIndex.get(incomingMessage.indexInConversation);
592
- const isLiveArrival = hadMessagesBeforeMerge && previousMessage == null && incomingMessage.indexInConversation > highestShownIndex;
593
- messagesByIndex.set(incomingMessage.indexInConversation, {
594
- ...incomingMessage,
595
- fresh: previousMessage?.fresh ?? isLiveArrival
596
- });
597
- }
598
- return Array.from(messagesByIndex.values()).sort(
599
- (first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0)
600
- );
601
- };
602
- const withRefusedSendError = (state, error) => {
603
- const conversationErrorType = readConversationErrorTypeOfRefusedSend(error);
604
- return {
605
- ...state,
606
- error: conversationErrorType,
607
- rateLimitRetryAfterSeconds: conversationErrorType === ConversationErrorType.RATE_LIMIT ? error.retryAfterSeconds ?? null : null
608
- };
609
- };
610
- const mergeSendAnswer = (loadedMessages, answerMessages) => {
611
- const messagesWithoutOptimisticMessage = loadedMessages ? loadedMessages.slice(0, loadedMessages.length - 1) : [];
612
- return mergeChatMessagesByIndex(
613
- messagesWithoutOptimisticMessage,
614
- tagFreshChatMessages(answerMessages, messagesWithoutOptimisticMessage)
615
- );
616
- };
617
- const withCanvasTransition = (state, applyCanvasTransition) => {
618
- const nextState = { ...state };
619
- applyCanvasTransition(nextState);
620
- const changed = nextState.canvas !== state.canvas || nextState.lastClosedCanvas !== state.lastClosedCanvas || nextState.canvasMountCount !== state.canvasMountCount;
621
- return changed ? nextState : state;
622
- };
623
- const reduceAgentsChatState = (state, event) => {
624
- switch (event.type) {
625
- case "reset":
626
- return {
627
- ...INITIAL_AGENTS_CHAT_STATE,
628
- openingRequest: state.openingRequest,
629
- canvasMountCount: state.canvasMountCount,
630
- startTokenCount: state.startTokenCount
631
- };
632
- case "conversationMetadataRequested":
633
- case "messagesPageRequested":
634
- return state.requestedConversationId === event.conversationId ? state : { ...state, requestedConversationId: event.conversationId };
635
- case "conversationMetadataReceived":
636
- if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {
637
- return state;
638
- }
639
- return { ...state, conversation: event.conversation, conversationLoaded: true };
640
- case "conversationMetadataFailed":
641
- return { ...state, conversationLoaded: true };
642
- case "messagesPageReceived": {
643
- if (state.requestedConversationId === null || state.requestedConversationId !== event.conversationId) {
644
- return state;
645
- }
646
- if (state.conversation !== null && state.conversation.id !== event.conversationId) {
647
- return state;
648
- }
649
- return {
650
- ...state,
651
- messages: mergeMessagesPage(state.messages, event.messages, event.conversationId),
652
- hasMoreOlder: event.hasMoreOlder ?? state.hasMoreOlder,
653
- conversationLoaded: true
654
- };
655
- }
656
- case "messagePostRequested":
657
- return {
658
- ...state,
659
- conversationLoading: true,
660
- conversationLoaded: false,
661
- aiThinking: true,
662
- error: null,
663
- rateLimitRetryAfterSeconds: null,
664
- messages: [...state.messages ?? [], event.message]
665
- };
666
- case "messagePostReceived":
667
- if (event.conversationId !== state.conversation?.id) {
668
- return state;
669
- }
670
- return {
671
- ...state,
672
- messages: mergeSendAnswer(state.messages, event.posted.messages),
673
- conversationLoading: false,
674
- conversationLoaded: true,
675
- error: null
676
- };
677
- case "messagePostFailed":
678
- return withRefusedSendError(
679
- { ...state, conversationLoading: false, conversationLoaded: true, aiThinking: false },
680
- event.error
681
- );
682
- case "startRequested":
683
- return {
684
- ...state,
685
- conversation: null,
686
- conversationLoading: true,
687
- conversationLoaded: false,
688
- aiThinking: true,
689
- error: null,
690
- rateLimitRetryAfterSeconds: null,
691
- startingNewConversation: true,
692
- startTokenCount: state.startTokenCount + 1,
693
- pendingStartToken: state.startTokenCount + 1,
694
- // A signal-only start (an empty visible message carries the start signal) seeds no empty bubble.
695
- messages: event.message.message ? [event.message] : []
696
- };
697
- case "startReceived": {
698
- if (event.startToken !== state.pendingStartToken) {
699
- return state;
700
- }
701
- const { started } = event;
702
- if (started.reopenedExisting) {
703
- return {
704
- ...state,
705
- conversation: started.conversation,
706
- messages: [],
707
- conversationLoading: false,
708
- conversationLoaded: true,
709
- aiThinking: false,
710
- startingNewConversation: false,
711
- pendingStartToken: null
712
- };
713
- }
714
- return {
715
- ...state,
716
- conversation: started.conversation,
717
- messages: mergeSendAnswer(state.messages, started.messages),
718
- conversationLoading: false,
719
- conversationLoaded: true,
720
- startingNewConversation: false,
721
- pendingStartToken: null
722
- };
723
- }
724
- case "startFailed":
725
- return withRefusedSendError(
726
- {
727
- ...state,
728
- conversation: null,
729
- conversationLoading: false,
730
- conversationLoaded: true,
731
- aiThinking: false,
732
- startingNewConversation: false,
733
- pendingStartToken: null
734
- },
735
- event.error
736
- );
737
- case "errorSet":
738
- return state.error === event.error ? state : { ...state, error: event.error };
739
- case "aiThinkingSet":
740
- return state.aiThinking === event.aiThinking ? state : { ...state, aiThinking: event.aiThinking };
741
- case "openingRequestSet":
742
- return { ...state, openingRequest: { ...state.openingRequest, ...event.openingRequest } };
743
- case "canvasOpened":
744
- return withCanvasTransition(state, (nextState) => {
745
- applyOpenCanvas(nextState, event.request);
746
- });
747
- case "canvasClosed":
748
- return withCanvasTransition(state, (nextState) => applyCloseCanvas(nextState, event.byCustomer));
749
- case "canvasResetForNewTurn":
750
- return withCanvasTransition(state, applyResetCanvasForNewTurn);
751
- case "canvasCleared":
752
- return withCanvasTransition(state, applyClearCanvas);
753
- case "canvasCreatedEntityIdSet":
754
- return withCanvasTransition(state, (nextState) => {
755
- applySetCanvasCreatedEntityId(nextState, event.created);
756
- });
757
- }
758
- };
759
- class AgentsChatStateContainer {
760
- constructor(initialState = INITIAL_AGENTS_CHAT_STATE) {
761
- this.listeners = /* @__PURE__ */ new Set();
762
- this.getState = () => this.state;
763
- this.subscribe = (listener) => {
764
- this.listeners.add(listener);
765
- return () => {
766
- this.listeners.delete(listener);
767
- };
768
- };
769
- this.dispatch = (event) => {
770
- const nextState = reduceAgentsChatState(this.state, event);
771
- if (nextState === this.state) return;
772
- this.state = nextState;
773
- for (const notifyListener of [...this.listeners]) notifyListener();
774
- };
775
- this.state = initialState;
776
- }
777
- }
778
- const createAgentsChatStore = (initialState) => new AgentsChatStateContainer(initialState);
779
- const AgentsChatStoreContext = createContext(null);
780
- const AgentsChatStoreProvider = (props) => {
781
- const { chatStore, children } = props;
782
- return /* @__PURE__ */ jsx(AgentsChatStoreContext.Provider, { value: chatStore, children });
783
- };
784
- const useAgentsChatStore = () => {
785
- const chatStore = useContext(AgentsChatStoreContext);
786
- if (chatStore === null) {
787
- throw new Error("A chat component rendered outside AgentsChatStoreProvider: the app has to mount its chat store.");
788
- }
789
- return chatStore;
790
- };
791
- const useOptionalAgentsChatStore = () => useContext(AgentsChatStoreContext);
792
- const subscribeToNothing = () => () => void 0;
793
- const useAgentsChatSelector = (chatStore, selector, valueWithoutStore) => {
794
- const subscribe = chatStore ? chatStore.subscribe : subscribeToNothing;
795
- const readSelectedValue = useCallback(
796
- () => chatStore ? selector(chatStore.getState()) : valueWithoutStore,
797
- [chatStore, selector, valueWithoutStore]
798
- );
799
- return useSyncExternalStore(subscribe, readSelectedValue, readSelectedValue);
800
- };
801
- const useAgentsChatState = (selector) => useAgentsChatSelector(useAgentsChatStore(), selector);
802
- let agenticChatMountCount = 0;
803
- const selectCanvas$1 = (state) => state.canvas;
804
- const selectLastClosedCanvas = (state) => state.lastClosedCanvas;
805
- const selectAiThinking = (state) => state.aiThinking;
806
- const selectRunState = (state) => state.conversation?.runState;
807
- const selectMessages$1 = (state) => state.messages;
808
- const ChatStoreConversationWidgetProvider = (props) => {
809
- const { chatStore, ...bodyProps } = props;
810
- const canvas = useAgentsChatSelector(chatStore, selectCanvas$1);
811
- const lastClosedCanvas = useAgentsChatSelector(chatStore, selectLastClosedCanvas);
812
- const isConversationRunning = useAgentsChatSelector(chatStore, selectAiThinking);
813
- const runState = useAgentsChatSelector(chatStore, selectRunState);
814
- const messages = useAgentsChatSelector(chatStore, selectMessages$1);
815
- const chatState = useMemo(
816
- () => ({
817
- canvas,
818
- lastClosedCanvas,
819
- isConversationRunning,
820
- runState,
821
- messages,
822
- dispatchCanvasEvent: chatStore.dispatch
823
- }),
824
- [canvas, lastClosedCanvas, isConversationRunning, runState, messages, chatStore]
825
- );
826
- return /* @__PURE__ */ jsx(ConversationWidgetProviderBody, { ...bodyProps, chatState });
827
- };
828
- const SliceConversationWidgetProvider = (props) => {
829
- const { sliceInstance, ...bodyProps } = props;
830
- const dispatch = useAgentsStateDispatch();
831
- const canvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).canvas);
832
- const lastClosedCanvas = useAgentsStateSelector((state) => sliceInstance.selectState(state).lastClosedCanvas);
833
- const isConversationRunning = useAgentsStateSelector((state) => sliceInstance.selectState(state).aiThinking);
834
- const runState = useAgentsStateSelector((state) => sliceInstance.selectState(state).conversation?.runState);
835
- const messages = useAgentsStateSelector((state) => sliceInstance.selectState(state).messages);
836
- const dispatchCanvasEvent = useCallback(
837
- (event) => {
838
- const { actions: actions2 } = sliceInstance;
839
- if (event.type === "canvasOpened") dispatch(actions2.openCanvas(event.request));
840
- else if (event.type === "canvasClosed") dispatch(actions2.closeCanvas({ byCustomer: event.byCustomer }));
841
- else if (event.type === "canvasResetForNewTurn") dispatch(actions2.resetCanvasForNewTurn());
842
- else if (event.type === "canvasCleared") dispatch(actions2.clearCanvas());
843
- else dispatch(actions2.setCanvasCreatedEntityId(event.created));
844
- },
845
- [dispatch, sliceInstance]
846
- );
847
- const chatState = useMemo(
848
- () => ({ canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent }),
849
- [canvas, lastClosedCanvas, isConversationRunning, runState, messages, dispatchCanvasEvent]
850
- );
851
- return /* @__PURE__ */ jsx(ConversationWidgetProviderBody, { ...bodyProps, chatState });
852
- };
853
- const OwnChatStoreConversationWidgetProvider = (props) => {
854
- const [ownChatStore] = useState(createAgentsChatStore);
855
- return /* @__PURE__ */ jsx(ChatStoreConversationWidgetProvider, { ...props, chatStore: ownChatStore });
856
- };
857
- const ConversationWidgetProvider = (props) => {
858
- const { sliceInstance, chatStore, ...bodyProps } = props;
859
- const { defaultChatStatePartition } = useAgentsEnvironment();
860
- const statePartition = sliceInstance ?? defaultChatStatePartition;
861
- if (chatStore) return /* @__PURE__ */ jsx(ChatStoreConversationWidgetProvider, { ...bodyProps, chatStore });
862
- if (statePartition) return /* @__PURE__ */ jsx(SliceConversationWidgetProvider, { ...bodyProps, sliceInstance: statePartition });
863
- return /* @__PURE__ */ jsx(OwnChatStoreConversationWidgetProvider, { ...bodyProps });
864
- };
865
- const ConversationWidgetProviderBody = ({
866
- children,
867
- callbacks,
868
- hostHasCanvasSurface = true,
869
- chatState
870
- }) => {
871
- const dispatch = useAgentsStateDispatch();
872
- const { buildChatSurfaceOpenChangedAction } = useAgentsEnvironment();
873
- const { canvas, lastClosedCanvas, isConversationRunning, runState, messages } = chatState;
874
- const isConversationClosed = runState === "COMPLETED" || runState === "CANCELLED";
875
- const dispatchCanvasEventRef = useRef(chatState.dispatchCanvasEvent);
876
- dispatchCanvasEventRef.current = chatState.dispatchCanvasEvent;
877
- const hostHasCanvasSurfaceRef = useRef(hostHasCanvasSurface);
878
- hostHasCanvasSurfaceRef.current = hostHasCanvasSurface;
879
- const buildChatSurfaceOpenChangedActionRef = useRef(buildChatSurfaceOpenChangedAction);
880
- buildChatSurfaceOpenChangedActionRef.current = buildChatSurfaceOpenChangedAction;
881
- useEffect(() => {
882
- agenticChatMountCount += 1;
883
- if (agenticChatMountCount === 1 && buildChatSurfaceOpenChangedActionRef.current) {
884
- dispatch(buildChatSurfaceOpenChangedActionRef.current(true));
885
- }
886
- return () => {
887
- agenticChatMountCount -= 1;
888
- if (agenticChatMountCount === 0 && buildChatSurfaceOpenChangedActionRef.current) {
889
- dispatch(buildChatSurfaceOpenChangedActionRef.current(false));
890
- }
891
- };
892
- }, [dispatch]);
893
- const callbacksRef = useRef(callbacks);
894
- callbacksRef.current = callbacks;
895
- const isComposerWidgetsControlled = callbacks.composerWidgets !== void 0;
896
- const [internalComposerWidgets, setInternalComposerWidgets] = useState([]);
897
- const composerWidgets = isComposerWidgetsControlled ? callbacks.composerWidgets : internalComposerWidgets;
898
- const composerWidgetsStateRef = useRef({ composerWidgets, isComposerWidgetsControlled });
899
- composerWidgetsStateRef.current = { composerWidgets, isComposerWidgetsControlled };
900
- const publishComposerWidgets = useCallback((next) => {
901
- if (composerWidgetsStateRef.current.isComposerWidgetsControlled) {
902
- callbacksRef.current.onComposerWidgetsChange?.(next);
903
- } else {
904
- setInternalComposerWidgets(next);
905
- }
906
- }, []);
907
- const addComposerWidget = useCallback(
908
- (widgetName, fields) => {
909
- const composerWidgetId = crypto.randomUUID();
910
- publishComposerWidgets([
911
- ...composerWidgetsStateRef.current.composerWidgets,
912
- { composerWidgetId, widgetName, fields }
913
- ]);
914
- return composerWidgetId;
915
- },
916
- [publishComposerWidgets]
917
- );
918
- const replaceComposerWidgetFields = useCallback(
919
- (composerWidgetId, fields) => {
920
- publishComposerWidgets(
921
- composerWidgetsStateRef.current.composerWidgets.map(
922
- (widget) => widget.composerWidgetId === composerWidgetId ? { ...widget, fields } : widget
923
- )
924
- );
925
- },
926
- [publishComposerWidgets]
927
- );
928
- const removeComposerWidget = useCallback(
929
- (composerWidgetId) => {
930
- publishComposerWidgets(
931
- composerWidgetsStateRef.current.composerWidgets.filter(
932
- (widget) => widget.composerWidgetId !== composerWidgetId
933
- )
934
- );
935
- },
936
- [publishComposerWidgets]
937
- );
938
- const clearComposerWidgets = useCallback(() => {
939
- publishComposerWidgets([]);
940
- }, [publishComposerWidgets]);
941
- const openCanvas = useCallback(
942
- (request) => {
943
- dispatchCanvasEventRef.current({
944
- type: "canvasOpened",
945
- request: {
946
- ...request,
947
- viewportViable: window.innerWidth >= CANVAS_VIABLE_MIN_WIDTH,
948
- hostHasCanvasSurface: hostHasCanvasSurfaceRef.current
949
- }
950
- });
951
- },
952
- []
953
- );
954
- const closeCanvas = useCallback(
955
- (byCustomer) => {
956
- dispatchCanvasEventRef.current({ type: "canvasClosed", byCustomer });
957
- },
958
- []
959
- );
960
- const lastClosedCanvasRef = useRef(lastClosedCanvas);
961
- lastClosedCanvasRef.current = lastClosedCanvas;
962
- const reopenLastClosedCanvas = useCallback(() => {
963
- const last = lastClosedCanvasRef.current;
964
- if (last === null) return;
965
- dispatchCanvasEventRef.current({
966
- type: "canvasOpened",
967
- request: {
968
- canvasId: last.canvasId,
969
- instanceId: last.instanceId,
970
- anchor: last.anchor,
971
- origin: "cardClick",
972
- justDelivered: false,
973
- viewportViable: window.innerWidth >= CANVAS_VIABLE_MIN_WIDTH,
974
- hostHasCanvasSurface: hostHasCanvasSurfaceRef.current,
975
- ...last.createdEntityId !== void 0 ? { createdEntityId: last.createdEntityId } : {}
976
- }
977
- });
978
- }, []);
979
- const setCanvasCreatedEntityId = useCallback(
980
- (created) => {
981
- dispatchCanvasEventRef.current({ type: "canvasCreatedEntityIdSet", created });
982
- },
983
- []
984
- );
985
- const storedCanvasConversationIdRef = useRef(void 0);
986
- const conversationIdForStorage = callbacks.conversationId;
987
- useEffect(() => {
988
- if (canvas !== null) {
989
- storeOpenCanvas(conversationIdForStorage, canvas);
990
- storedCanvasConversationIdRef.current = conversationIdForStorage;
991
- return;
992
- }
993
- if (storedCanvasConversationIdRef.current !== void 0 && storedCanvasConversationIdRef.current === conversationIdForStorage) {
994
- clearStoredCanvas(conversationIdForStorage);
995
- }
996
- storedCanvasConversationIdRef.current = void 0;
997
- }, [canvas, conversationIdForStorage]);
998
- const resetCanvas = useCallback(() => {
999
- dispatchCanvasEventRef.current({ type: "canvasCleared" });
1000
- }, []);
1001
- const resetCanvasForNewTurn = useCallback(() => {
1002
- dispatchCanvasEventRef.current({ type: "canvasResetForNewTurn" });
1003
- }, []);
1004
- const sendMessageToChat = useCallback((message2) => {
1005
- return callbacksRef.current.sendMessageToChat?.(message2);
1006
- }, []);
1007
- const prefillComposer = useCallback((text) => {
1008
- callbacksRef.current.prefillComposer?.(text);
1009
- }, []);
1010
- const injectSignal = useCallback((signalText, options) => {
1011
- return callbacksRef.current.injectSignal?.(signalText, options);
1012
- }, []);
1013
- const minimizeChatHost = useCallback(() => {
1014
- callbacksRef.current.minimizeChatHost?.();
1015
- }, []);
1016
- const contextValue = useMemo(
1017
- () => ({
1018
- canvas,
1019
- hostHasCanvasSurface,
1020
- lastClosedCanvas,
1021
- openCanvas,
1022
- closeCanvas,
1023
- reopenLastClosedCanvas,
1024
- setCanvasCreatedEntityId,
1025
- resetCanvas,
1026
- resetCanvasForNewTurn,
1027
- sendMessageToChat,
1028
- prefillComposer,
1029
- injectSignal,
1030
- minimizeChatHost,
1031
- chatAgentSpaceKey: callbacks.chatAgentSpaceKey,
1032
- isConversationRunning,
1033
- isConversationClosed,
1034
- conversationId: callbacks.conversationId,
1035
- composerWidgets,
1036
- addComposerWidget,
1037
- replaceComposerWidgetFields,
1038
- removeComposerWidget,
1039
- clearComposerWidgets,
1040
- onOpenConversation: callbacks.onOpenConversation,
1041
- onSwitchConversation: callbacks.onSwitchConversation,
1042
- isOnboardingSetupConversation: callbacks.isOnboardingSetupConversation ?? false,
1043
- messages
1044
- }),
1045
- [
1046
- canvas,
1047
- hostHasCanvasSurface,
1048
- lastClosedCanvas,
1049
- openCanvas,
1050
- closeCanvas,
1051
- reopenLastClosedCanvas,
1052
- setCanvasCreatedEntityId,
1053
- resetCanvas,
1054
- resetCanvasForNewTurn,
1055
- sendMessageToChat,
1056
- prefillComposer,
1057
- injectSignal,
1058
- minimizeChatHost,
1059
- callbacks.chatAgentSpaceKey,
1060
- isConversationRunning,
1061
- isConversationClosed,
1062
- callbacks.conversationId,
1063
- composerWidgets,
1064
- addComposerWidget,
1065
- replaceComposerWidgetFields,
1066
- removeComposerWidget,
1067
- clearComposerWidgets,
1068
- callbacks.onOpenConversation,
1069
- callbacks.onSwitchConversation,
1070
- callbacks.isOnboardingSetupConversation,
1071
- messages
1072
- ]
1073
- );
1074
- return /* @__PURE__ */ jsx(ConversationWidgetContext.Provider, { value: contextValue, children });
1075
- };
1076
387
  const chat = "agents_chat_fuWV-c";
1077
388
  const genericChat = "agents_genericChat_AyTt-f";
1078
389
  const customBg = "agents_customBg_RtIJtP";
@@ -1089,7 +400,7 @@ const input = "agents_input_GCtiXU";
1089
400
  const inputReplacement = "agents_inputReplacement_EAhjsv";
1090
401
  const inputInCategory = "agents_inputInCategory_RDuOYA";
1091
402
  const olderLoading = "agents_olderLoading_5X7nMg";
1092
- const styles$j = {
403
+ const styles$i = {
1093
404
  chat,
1094
405
  genericChat,
1095
406
  customBg,
@@ -1119,7 +430,7 @@ const sendBlocked = "agents_sendBlocked_rNqOKm";
1119
430
  const compact = "agents_compact_ZBtAbD";
1120
431
  const collapsed = "agents_collapsed_v3Ekqz";
1121
432
  const collapsedPillSizer = "agents_collapsedPillSizer_aqw7WI";
1122
- const styles$i = {
433
+ const styles$h = {
1123
434
  inputContainer,
1124
435
  aiGlow,
1125
436
  editableInput,
@@ -1268,15 +579,15 @@ const ConversationMessageInput = (props) => {
1268
579
  replaceComposerWidgetFields(lastWidget.composerWidgetId, nextFields);
1269
580
  }
1270
581
  };
1271
- const handleKeyPress = (e) => {
1272
- if (e.key === "Enter" && !e.shiftKey) {
582
+ const handleKeyPress = (e2) => {
583
+ if (e2.key === "Enter" && !e2.shiftKey) {
1273
584
  if (isComposingRef.current) return;
1274
- e.preventDefault();
585
+ e2.preventDefault();
1275
586
  handleSendMessage();
1276
587
  return;
1277
588
  }
1278
- if (e.key === "Backspace" && inputValue === "" && (outgoingComposerWidgets?.length ?? 0) > 0) {
1279
- e.preventDefault();
589
+ if (e2.key === "Backspace" && inputValue === "" && (outgoingComposerWidgets?.length ?? 0) > 0) {
590
+ e2.preventDefault();
1280
591
  handleBackspaceOnEmptyInput();
1281
592
  }
1282
593
  };
@@ -1298,12 +609,12 @@ const ConversationMessageInput = (props) => {
1298
609
  const handleBlur = () => {
1299
610
  setIsFocused(false);
1300
611
  };
1301
- const handleContainerMouseDown = (e) => {
1302
- const target = e.target;
612
+ const handleContainerMouseDown = (e2) => {
613
+ const target = e2.target;
1303
614
  if (target === inputRef.current || inputRef.current?.contains(target)) return;
1304
615
  if (target.closest("button")) return;
1305
616
  if (disabled || isProcessing) return;
1306
- e.preventDefault();
617
+ e2.preventDefault();
1307
618
  focusInputAtEnd();
1308
619
  };
1309
620
  useLayoutEffect(() => {
@@ -1323,9 +634,9 @@ const ConversationMessageInput = (props) => {
1323
634
  wasProcessingRef.current = isProcessing;
1324
635
  }, [isProcessing, disabled]);
1325
636
  useEffect(() => {
1326
- const handlePasteEvent = (e) => {
1327
- e.preventDefault();
1328
- const text = e.clipboardData?.getData("text/plain");
637
+ const handlePasteEvent = (e2) => {
638
+ e2.preventDefault();
639
+ const text = e2.clipboardData?.getData("text/plain");
1329
640
  if (!text) {
1330
641
  return;
1331
642
  }
@@ -1351,7 +662,7 @@ const ConversationMessageInput = (props) => {
1351
662
  /* @__PURE__ */ jsx(
1352
663
  GlowFrame,
1353
664
  {
1354
- className: classNames(styles$i.aiGlow),
665
+ className: classNames(styles$h.aiGlow),
1355
666
  color: isMessageTooLong ? "var(--agents-danger-500)" : void 0,
1356
667
  borderRadius: compact2 ? COMPACT_INPUT_RADIUS_PX : void 0,
1357
668
  borderWidth: 2,
@@ -1359,9 +670,9 @@ const ConversationMessageInput = (props) => {
1359
670
  children: /* @__PURE__ */ jsxs(
1360
671
  "div",
1361
672
  {
1362
- className: classNames(styles$i.inputContainer, {
1363
- [styles$i.compact]: compact2,
1364
- [styles$i.collapsed]: compact2 && collapsed2
673
+ className: classNames(styles$h.inputContainer, {
674
+ [styles$h.compact]: compact2,
675
+ [styles$h.collapsed]: compact2 && collapsed2
1365
676
  }),
1366
677
  onMouseDown: handleContainerMouseDown,
1367
678
  children: [
@@ -1377,26 +688,26 @@ const ConversationMessageInput = (props) => {
1377
688
  onKeyDown: handleKeyPress,
1378
689
  onFocus: handleFocus,
1379
690
  onBlur: handleBlur,
1380
- className: `${styles$i.editableInput} ${!inputValue && !isFocused ? styles$i.showPlaceholder : ""}`,
691
+ className: `${styles$h.editableInput} ${!inputValue && !isFocused ? styles$h.showPlaceholder : ""}`,
1381
692
  "data-placeholder": translatedPlaceholder,
1382
693
  "data-testid": `${testId}-textarea`
1383
694
  }
1384
695
  ),
1385
- inputValue.length >= CHARACTER_COUNTER_SHOWN_FROM_LENGTH && /* @__PURE__ */ jsx("div", { className: styles$i.statusRow, children: /* @__PURE__ */ jsx(
696
+ inputValue.length >= CHARACTER_COUNTER_SHOWN_FROM_LENGTH && /* @__PURE__ */ jsx("div", { className: styles$h.statusRow, children: /* @__PURE__ */ jsx(
1386
697
  Text,
1387
698
  {
1388
699
  role: "caption",
1389
700
  translate: false,
1390
701
  color: isMessageTooLong ? "var(--agents-danger-500)" : "var(--agents-fg-lightest)",
1391
- className: styles$i.characterCounter,
702
+ className: styles$h.characterCounter,
1392
703
  testId: `${testId}-character-counter`,
1393
704
  children: `${inputValue.length.toLocaleString()} / ${MAX_MESSAGE_LENGTH.toLocaleString()}`
1394
705
  }
1395
706
  ) }),
1396
- /* @__PURE__ */ jsxs("div", { className: styles$i.actions, children: [
1397
- actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$i.actionsStart, children: actionsSlotStart }),
707
+ /* @__PURE__ */ jsxs("div", { className: styles$h.actions, children: [
708
+ actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$h.actionsStart, children: actionsSlotStart }),
1398
709
  actionsSlot,
1399
- sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames({ [styles$i.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
710
+ sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames({ [styles$h.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
1400
711
  Tooltip,
1401
712
  {
1402
713
  text: isMessageTooLong ? "Your message is over the %maxLength% character limit" : void 0,
@@ -1422,45 +733,9 @@ const ConversationMessageInput = (props) => {
1422
733
  )
1423
734
  }
1424
735
  ),
1425
- measuresCollapsedPillWidth && /* @__PURE__ */ jsx("span", { ref: collapsedPillSizerRef, className: styles$i.collapsedPillSizer, "aria-hidden": "true", children: translatedPlaceholder })
736
+ measuresCollapsedPillWidth && /* @__PURE__ */ jsx("span", { ref: collapsedPillSizerRef, className: styles$h.collapsedPillSizer, "aria-hidden": "true", children: translatedPlaceholder })
1426
737
  ] });
1427
738
  };
1428
- const stripReveal$1 = "agents_stripReveal_6XAjCM";
1429
- const stripRevealOpen$1 = "agents_stripRevealOpen_sWkJwh";
1430
- const stripRevealInner$1 = "agents_stripRevealInner_C2VlV7";
1431
- const strip$1 = "agents_strip_rKQFvx";
1432
- const styles$h = {
1433
- stripReveal: stripReveal$1,
1434
- stripRevealOpen: stripRevealOpen$1,
1435
- stripRevealInner: stripRevealInner$1,
1436
- strip: strip$1
1437
- };
1438
- const ConversationMessageInputComposerWidgets = (props) => {
1439
- const { testId = "chat-input" } = props;
1440
- const { composerWidgets, replaceComposerWidgetFields, removeComposerWidget } = useConversationWidgetContext();
1441
- const renderableWidgets = composerWidgets.flatMap((widget) => {
1442
- const entry = conversationWidgetRegistry.widgets.find((candidate) => candidate.name === widget.widgetName);
1443
- return entry?.composerComponent ? [{ widget, Component: entry.composerComponent }] : [];
1444
- });
1445
- return /* @__PURE__ */ jsx(
1446
- "div",
1447
- {
1448
- className: classNames(styles$h.stripReveal, { [styles$h.stripRevealOpen]: renderableWidgets.length > 0 }),
1449
- "data-testid": `${testId}-composer-widgets-strip`,
1450
- children: /* @__PURE__ */ jsx("div", { className: styles$h.stripRevealInner, children: /* @__PURE__ */ jsx("div", { className: styles$h.strip, children: renderableWidgets.map(({ widget, Component }) => /* @__PURE__ */ jsx(
1451
- Component,
1452
- {
1453
- composerWidgetId: widget.composerWidgetId,
1454
- fields: widget.fields,
1455
- replaceFields: (nextFields) => replaceComposerWidgetFields(widget.composerWidgetId, nextFields),
1456
- remove: () => removeComposerWidget(widget.composerWidgetId),
1457
- testId: `${testId}-composer-widget-${widget.composerWidgetId}`
1458
- },
1459
- widget.composerWidgetId
1460
- )) }) })
1461
- }
1462
- );
1463
- };
1464
739
  const canvasReopenControl = "agents_canvasReopenControl_7vGS8F";
1465
740
  const splitViewRoot = "agents_splitViewRoot_OfrSES";
1466
741
  const splitViewPane = "agents_splitViewPane_YSX5Rp";
@@ -1931,17 +1206,6 @@ const widgetNamesInMarkdown = (markdown) => {
1931
1206
  }
1932
1207
  return names;
1933
1208
  };
1934
- const FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE = "FRONTEND_WIDGET_CLICK";
1935
- const OWNER_ACTION_CONFIRM_SIGNAL_SOURCE = "OWNER_ACTION_CONFIRM";
1936
- const PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES = [
1937
- FRONTEND_WIDGET_CLICK_SIGNAL_SOURCE,
1938
- OWNER_ACTION_CONFIRM_SIGNAL_SOURCE
1939
- ];
1940
- const getWidgetClickSignalSources = () => [
1941
- ...PACKAGE_WIDGET_CLICK_SIGNAL_SOURCES,
1942
- ...getFurtherWidgetClickSignalSources()
1943
- ];
1944
- const isWidgetClickSignalSource = (signalSource) => signalSource != null && getWidgetClickSignalSources().includes(signalSource);
1945
1209
  const isBareUnknownTypeJson = (markdown) => {
1946
1210
  if (!markdown.startsWith("{")) return false;
1947
1211
  let parsed;
@@ -2624,7 +1888,7 @@ const ConversationViewBody = (props) => {
2624
1888
  );
2625
1889
  const { readAssistantThemeClassName, AssistantBackground } = useAgentsEnvironment();
2626
1890
  const colorPalette = useMemo(
2627
- () => currentCategory?.alias ? readAssistantThemeClassName?.(currentCategory.alias) ?? styles$j.genericChat : styles$j.genericChat,
1891
+ () => currentCategory?.alias ? readAssistantThemeClassName?.(currentCategory.alias) ?? styles$i.genericChat : styles$i.genericChat,
2628
1892
  [currentCategory, readAssistantThemeClassName]
2629
1893
  );
2630
1894
  const isMessageListVisible = !!messages && (!!conversationId || !!showMessagesWithoutConversation) || startingNewConversation || !!error && error !== ConversationErrorType.CONVERSATION_NOT_FOUND;
@@ -2829,7 +2093,7 @@ const ConversationViewBody = (props) => {
2829
2093
  const messageColumn = /* @__PURE__ */ jsxs(
2830
2094
  "div",
2831
2095
  {
2832
- className: styles$j.contentWrapper,
2096
+ className: styles$i.contentWrapper,
2833
2097
  "data-agents-chat-scroll": "",
2834
2098
  "data-testid": "chat-messages-scroll",
2835
2099
  ref: handleContentWrapperRef,
@@ -2847,11 +2111,11 @@ const ConversationViewBody = (props) => {
2847
2111
  onSuggestionClick
2848
2112
  }
2849
2113
  ) : null,
2850
- !!loadingOlder ? /* @__PURE__ */ jsx("span", { className: styles$j.olderLoading, children: /* @__PURE__ */ jsx(Text, { children: "Loading older messages…" }) }) : null,
2114
+ !!loadingOlder ? /* @__PURE__ */ jsx("span", { className: styles$i.olderLoading, children: /* @__PURE__ */ jsx(Text, { children: "Loading older messages…" }) }) : null,
2851
2115
  isMessageListVisible ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(WidgetWindowRootContext.Provider, { value: scrollContainer, children: /* @__PURE__ */ jsx(
2852
2116
  ConversationMessageList,
2853
2117
  {
2854
- className: enablePinQuestionAndRevealAnswer && (conversationId || startingNewConversation || aiThinking || error) ? styles$j.topAlignedMessages : void 0,
2118
+ className: enablePinQuestionAndRevealAnswer && (conversationId || startingNewConversation || aiThinking || error) ? styles$i.topAlignedMessages : void 0,
2855
2119
  messages,
2856
2120
  currentCategory,
2857
2121
  aiPromptExtension,
@@ -2878,40 +2142,40 @@ const ConversationViewBody = (props) => {
2878
2142
  "div",
2879
2143
  {
2880
2144
  className: classNames(
2881
- styles$j.chat,
2882
- background || backgroundPaintedByHost2 ? styles$j.customBg : colorPalette,
2883
- backgroundPaintedByHost2 ? styles$j.backgroundPaintedByHost : void 0,
2884
- isCompact ? styles$j.chatCompact : void 0,
2885
- confineTopBlurBandToChatPane2 ? styles$j.confineTopBlurBandToChatPane : void 0
2145
+ styles$i.chat,
2146
+ background || backgroundPaintedByHost2 ? styles$i.customBg : colorPalette,
2147
+ backgroundPaintedByHost2 ? styles$i.backgroundPaintedByHost : void 0,
2148
+ isCompact ? styles$i.chatCompact : void 0,
2149
+ confineTopBlurBandToChatPane2 ? styles$i.confineTopBlurBandToChatPane : void 0
2886
2150
  ),
2887
2151
  children: [
2888
- background ? /* @__PURE__ */ jsx("div", { className: styles$j.backgroundLayer, children: background }) : backgroundPaintedByHost2 ? null : AssistantBackground ? /* @__PURE__ */ jsx(AssistantBackground, { category: currentCategory, categoryAlias: currentCategory?.alias ?? void 0 }) : null,
2152
+ background ? /* @__PURE__ */ jsx("div", { className: styles$i.backgroundLayer, children: background }) : backgroundPaintedByHost2 ? null : AssistantBackground ? /* @__PURE__ */ jsx(AssistantBackground, { category: currentCategory, categoryAlias: currentCategory?.alias ?? void 0 }) : null,
2889
2153
  progressStepperSlot,
2890
- contentOverlaySlot !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$j.contentLayers, "data-overlay-shown": isContentOverlayShown || void 0, children: [
2154
+ contentOverlaySlot !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$i.contentLayers, "data-overlay-shown": isContentOverlayShown || void 0, children: [
2891
2155
  messageColumn,
2892
2156
  /* @__PURE__ */ jsx(
2893
2157
  "div",
2894
2158
  {
2895
- className: styles$j.contentOverlay,
2159
+ className: styles$i.contentOverlay,
2896
2160
  "aria-hidden": !isContentOverlayShown || void 0,
2897
2161
  inert: !isContentOverlayShown || void 0,
2898
2162
  children: contentOverlaySlot
2899
2163
  }
2900
2164
  )
2901
2165
  ] }) : messageColumn,
2902
- enablePinQuestionAndRevealAnswer && /* @__PURE__ */ jsx("div", { className: styles$j.scrollToLatestAnchor, children: /* @__PURE__ */ jsx(
2166
+ enablePinQuestionAndRevealAnswer && /* @__PURE__ */ jsx("div", { className: styles$i.scrollToLatestAnchor, children: /* @__PURE__ */ jsx(
2903
2167
  ConversationScrollToLatestMessageButton,
2904
2168
  {
2905
2169
  visible: isMessagesBottomOutOfView,
2906
2170
  onClick: scrollToLatestMessage
2907
2171
  }
2908
2172
  ) }),
2909
- inputReplacementSlot ? /* @__PURE__ */ jsx("div", { className: styles$j.inputReplacement, children: inputReplacementSlot }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2173
+ inputReplacementSlot ? /* @__PURE__ */ jsx("div", { className: styles$i.inputReplacement, children: inputReplacementSlot }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2910
2174
  inputBandSlot,
2911
2175
  /* @__PURE__ */ jsx(
2912
2176
  ConversationMessageInput,
2913
2177
  {
2914
- className: classNames(styles$j.input, currentCategory?.alias ? styles$j.inputInCategory : void 0),
2178
+ className: classNames(styles$i.input, currentCategory?.alias ? styles$i.inputInCategory : void 0),
2915
2179
  isProcessing: allowSendWhileAiThinking ? !!startingNewConversation : aiThinking,
2916
2180
  onSendMessage,
2917
2181
  actionsSlot: inputActionsSlot,
@@ -3354,78 +2618,6 @@ const ConversationView = (props) => {
3354
2618
  ) : null
3355
2619
  ] });
3356
2620
  };
3357
- const DELEGATE_TOOL_NAME = "delegate";
3358
- const RESOLVED_STATUSES = ["COMPLETED", "FAILED", "CANCELLED"];
3359
- const isResolved = (status) => status != null && RESOLVED_STATUSES.includes(status);
3360
- const TERMINAL_RUN_STATES = ["COMPLETED", "FAILED", "CANCELLED"];
3361
- const UNRESOLVED_RUN_STATUSES = ["QUEUED", "RUNNING"];
3362
- const isEffectivelyResolved = (message2) => {
3363
- if (message2 == null) return false;
3364
- if (isResolved(message2.toolCall?.status)) return true;
3365
- if (message2.toolCall?.name !== DELEGATE_TOOL_NAME) return false;
3366
- const children = message2.delegatedConversations ?? [];
3367
- if (children.length === 0) return false;
3368
- const declaredTasks = message2.toolCall?.arguments?.tasks;
3369
- if (Array.isArray(declaredTasks) && declaredTasks.length > children.length) return false;
3370
- return children.every((child) => TERMINAL_RUN_STATES.includes(child.runState ?? ""));
3371
- };
3372
- const countOutstandingChildren = (message2) => {
3373
- const children = message2.delegatedConversations ?? [];
3374
- if (children.length > 0) {
3375
- return children.filter((child) => !TERMINAL_RUN_STATES.includes(child.runState ?? "")).length;
3376
- }
3377
- if (message2.toolCall?.name !== DELEGATE_TOOL_NAME) {
3378
- return 0;
3379
- }
3380
- const subAgent = message2.subAgent;
3381
- if (subAgent != null) {
3382
- const currentRun = (subAgent.runs ?? []).find((run) => run.runNumber === subAgent.currentRunNumber);
3383
- return currentRun != null && UNRESOLVED_RUN_STATUSES.includes(currentRun.status ?? "") ? 1 : 0;
3384
- }
3385
- if (isResolved(message2.toolCall?.status)) {
3386
- return 0;
3387
- }
3388
- const declaredTasks = message2.toolCall?.arguments?.tasks;
3389
- return Array.isArray(declaredTasks) && declaredTasks.length > 0 ? declaredTasks.length : 1;
3390
- };
3391
- const hasUnresolvedToolCall = (message2) => message2.toolCall != null && !isEffectivelyResolved(message2);
3392
- const hasDelegationInFlight = (message2) => countOutstandingChildren(message2) > 0 || message2.toolCall?.name === DELEGATE_TOOL_NAME && !isEffectivelyResolved(message2);
3393
- const deriveAgentActivity = (messages, runStatus) => {
3394
- if (runStatus === "failed") {
3395
- return { active: false, label: "" };
3396
- }
3397
- const sorted = [...messages ?? []].sort(
3398
- (a, b) => (a.indexInConversation ?? Number.POSITIVE_INFINITY) - (b.indexInConversation ?? Number.POSITIVE_INFINITY)
3399
- );
3400
- const lastMessage = sorted[sorted.length - 1];
3401
- if (lastMessage?.role === "USER") {
3402
- return { active: true, label: "" };
3403
- }
3404
- const unresolvedDelegateCount = sorted.reduce((count, message2) => count + countOutstandingChildren(message2), 0);
3405
- if (runStatus === "idle" && unresolvedDelegateCount === 0) {
3406
- return { active: false, label: "" };
3407
- }
3408
- if (unresolvedDelegateCount > 0) {
3409
- return {
3410
- active: true,
3411
- label: "Waiting for %count% delegations...",
3412
- replacements: { count: unresolvedDelegateCount },
3413
- context: unresolvedDelegateCount === 1 ? "one" : "other"
3414
- };
3415
- }
3416
- if (lastMessage?.messageType === "TOOL_CALL" && !isEffectivelyResolved(lastMessage)) {
3417
- return {
3418
- active: true,
3419
- label: "Running: %tool%...",
3420
- replacements: { tool: lastMessage.toolCall?.name ?? "Tool" },
3421
- toolRunning: true
3422
- };
3423
- }
3424
- if (runStatus === "running") {
3425
- return { active: true, label: "" };
3426
- }
3427
- return { active: false, label: "" };
3428
- };
3429
2621
  const pickPendingStartRequest = (pendingStartUserMessage, pendingStartSignalText) => {
3430
2622
  if (pendingStartUserMessage) {
3431
2623
  return { kind: "message", text: pendingStartUserMessage };
@@ -3486,6 +2678,7 @@ const LINE_PACE_MS = 2200;
3486
2678
  const BACKLOG_LINE_PACE_MS = 1400;
3487
2679
  const BACKLOG_THRESHOLD = 2;
3488
2680
  const MAX_WAITING_LINES = 4;
2681
+ const isStepStillRunning = (line) => line.state === "queued" || line.state === "running";
3489
2682
  const EMPTY_ACTIVITY_TICKER_QUEUE = {
3490
2683
  shownLines: {},
3491
2684
  trailIds: [],
@@ -3579,6 +2772,10 @@ const countWorkingHelpers = (elements) => {
3579
2772
  });
3580
2773
  return workingHelperKeys.size;
3581
2774
  };
2775
+ const formatElapsedClock = (elapsedMs) => {
2776
+ const elapsedSeconds = Math.max(0, Math.floor(elapsedMs / 1e3));
2777
+ return `${Math.floor(elapsedSeconds / 60)}:${String(elapsedSeconds % 60).padStart(2, "0")}`;
2778
+ };
3582
2779
  const INITIAL_ACTIVITY_TICKER_STATE = {
3583
2780
  queue: EMPTY_ACTIVITY_TICKER_QUEUE,
3584
2781
  phase: "idle",
@@ -4038,23 +3235,6 @@ const useAgentsConversationRunStatus = (client, conversationId) => {
4038
3235
  }, [client, conversationId]);
4039
3236
  return runStatus;
4040
3237
  };
4041
- const CHANGING_STATUSES = ["PENDING", "RUNNING", "CANCEL_REQUESTED"];
4042
- const canStillChange = (message2) => CHANGING_STATUSES.includes(message2.status ?? "") || hasUnresolvedToolCall(message2) || hasDelegationInFlight(message2);
4043
- const buildChangedMessagesRequest = (messages, pageSize) => {
4044
- const loaded = (messages ?? []).filter((message2) => message2.indexInConversation != null);
4045
- if (loaded.length === 0) {
4046
- return null;
4047
- }
4048
- const indexes = (list) => list.map((message2) => message2.indexInConversation);
4049
- const highestIndex = Math.max(...indexes(loaded));
4050
- const changing = loaded.filter(canStillChange);
4051
- const fromIndex = Math.max(
4052
- changing.length > 0 ? Math.min(...indexes(changing)) : highestIndex + 1,
4053
- highestIndex - pageSize + 1
4054
- );
4055
- const highestKnownId = Math.max(...loaded.map((message2) => message2.id ?? 0));
4056
- return { highestKnownId, fromIndex, pageSize };
4057
- };
4058
3238
  const CONVERSATION_MESSAGE_PAGE_SIZE = 50;
4059
3239
  const useConversationMessagePages = (chatStore, client, pageSize = CONVERSATION_MESSAGE_PAGE_SIZE) => {
4060
3240
  const openingPageRef = useRef(null);
@@ -5235,29 +4415,43 @@ export {
5235
4415
  AgentChatActivityHistory,
5236
4416
  AgentChatActivityIndicator,
5237
4417
  AgentChatController,
5238
- AgentsChatStateContainer,
5239
- AgentsChatStoreProvider,
4418
+ A as AgentsChatStateContainer,
4419
+ d as AgentsChatStoreProvider,
4420
+ CanvasPane,
5240
4421
  CanvasRestoreOnMount,
5241
4422
  ConversationClosedBar,
4423
+ ConversationDeepLinkedWidget,
5242
4424
  ConversationErrorCard,
5243
4425
  ConversationErrorType,
4426
+ ConversationMessageInput,
5244
4427
  ConversationMessageInputAttachmentsErrorBox,
5245
4428
  ConversationMessageInputAttachmentsPreviewStrip,
4429
+ ConversationMessageList,
4430
+ ConversationMessageSystem,
4431
+ ConversationMessageUser,
4432
+ ConversationMessageWidgets,
5246
4433
  ConversationView,
5247
4434
  ConversationWidgetProvider,
5248
- EMPTY_AGENTS_CHAT_OPENING_REQUEST,
5249
- INITIAL_AGENTS_CHAT_STATE,
4435
+ E as EMPTY_AGENTS_CHAT_OPENING_REQUEST,
4436
+ I as INITIAL_AGENTS_CHAT_STATE,
4437
+ MAX_MESSAGE_LENGTH,
4438
+ PHONE_CALL_LIFECYCLE_SIGNAL_SOURCES,
4439
+ SIGNAL_SOURCES_THAT_OWE_NO_WORK,
4440
+ SUCCESS_BEAT_MS,
5250
4441
  createAgentsChatStore,
5251
4442
  deriveAgentActivity,
4443
+ formatElapsedClock,
4444
+ isStepStillRunning,
5252
4445
  normalizeServerMessageToMarkdown,
5253
- readConversationErrorTypeOfRefusedSend,
5254
- reduceAgentsChatState,
4446
+ r as readConversationErrorTypeOfRefusedSend,
4447
+ e as reduceAgentsChatState,
4448
+ useActivityTicker,
5255
4449
  useAgentsChatSelector,
5256
- useAgentsChatState,
5257
- useAgentsChatStore,
4450
+ f as useAgentsChatState,
4451
+ g as useAgentsChatStore,
5258
4452
  useAgentsConversationRunStatus,
5259
4453
  useConversationMessageSearch,
5260
4454
  useConversationsSearch,
5261
- useOptionalAgentsChatStore
4455
+ h as useOptionalAgentsChatStore
5262
4456
  };
5263
4457
  //# sourceMappingURL=chat.js.map