@mgamadeus/ddd-agents 0.11.13 → 0.12.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.
Files changed (226) hide show
  1. package/README.md +138 -6
  2. package/boundary.json +5 -0
  3. package/dist/admin.js +13712 -0
  4. package/dist/admin.js.map +1 -0
  5. package/dist/chat.js +1627 -109
  6. package/dist/chat.js.map +1 -1
  7. package/dist/chunks/{AgentsConversationClientContext-C4T7g_Qk.js → AgentsConversationClientContext-B_UJSLXU.js} +2 -2
  8. package/dist/chunks/{AgentsConversationClientContext-C4T7g_Qk.js.map → AgentsConversationClientContext-B_UJSLXU.js.map} +1 -1
  9. package/dist/chunks/{ConversationMarkdown-D-aP3Ssl.js → ConversationMarkdown-DlvwT3Qk.js} +5 -4
  10. package/dist/chunks/{ConversationMarkdown-D-aP3Ssl.js.map → ConversationMarkdown-DlvwT3Qk.js.map} +1 -1
  11. package/dist/chunks/{ConversationMessageInputComposerWidgets-7HNAmZE1.js → ConversationMessageInputComposerWidgets-TchR1lPj.js} +6 -6
  12. package/dist/chunks/{ConversationMessageInputComposerWidgets-7HNAmZE1.js.map → ConversationMessageInputComposerWidgets-TchR1lPj.js.map} +1 -1
  13. package/dist/chunks/{VoiceBarsIcon-FhLAcgLG.js → VoiceBarsIcon-y3mgSqbn.js} +4 -4
  14. package/dist/chunks/{VoiceBarsIcon-FhLAcgLG.js.map → VoiceBarsIcon-y3mgSqbn.js.map} +1 -1
  15. package/dist/chunks/{WebSearchResultsConversationWidget-dEq19U7k.js → WebSearchResultsConversationWidget-l9Aek_lG.js} +3 -2
  16. package/dist/chunks/WebSearchResultsConversationWidget-l9Aek_lG.js.map +1 -0
  17. package/dist/chunks/agents-http-trace-mappers-LWNi-3a4.js +759 -0
  18. package/dist/chunks/agents-http-trace-mappers-LWNi-3a4.js.map +1 -0
  19. package/dist/chunks/{browser-request-interception-ydNOzeUL.js → browser-request-interception-D678IemW.js} +2 -2
  20. package/dist/chunks/{browser-request-interception-ydNOzeUL.js.map → browser-request-interception-D678IemW.js.map} +1 -1
  21. package/dist/chunks/{canvas-reducers-BInd3xNz.js → canvas-reducers-BYArW_Ji.js} +2 -2
  22. package/dist/chunks/{canvas-reducers-BInd3xNz.js.map → canvas-reducers-BYArW_Ji.js.map} +1 -1
  23. package/dist/chunks/{canvas-title-slot-context-BI1PLnPn.js → canvas-title-slot-context-BRGnFzYP.js} +3 -3
  24. package/dist/chunks/{canvas-title-slot-context-BI1PLnPn.js.map → canvas-title-slot-context-BRGnFzYP.js.map} +1 -1
  25. package/dist/chunks/{canvasBodies-CRVh8pCw.js → canvasBodies-BjXypuHf.js} +4 -4
  26. package/dist/chunks/{canvasBodies-CRVh8pCw.js.map → canvasBodies-BjXypuHf.js.map} +1 -1
  27. package/dist/chunks/{canvasStorage-Cr3omZeI.js → canvasStorage-DSspwRMg.js} +2 -2
  28. package/dist/chunks/{canvasStorage-Cr3omZeI.js.map → canvasStorage-DSspwRMg.js.map} +1 -1
  29. package/dist/chunks/content-from-unified-diff-CovnmG2Q.js +2927 -0
  30. package/dist/chunks/content-from-unified-diff-CovnmG2Q.js.map +1 -0
  31. package/dist/chunks/{contract-C18owGKs.js → contract-886XjdID.js} +2 -2
  32. package/dist/chunks/{contract-C18owGKs.js.map → contract-886XjdID.js.map} +1 -1
  33. package/dist/chunks/{conversation-CbWEHPbL.js → conversation-B7-evdj_.js} +4 -4
  34. package/dist/chunks/{conversation-CbWEHPbL.js.map → conversation-B7-evdj_.js.map} +1 -1
  35. package/dist/chunks/{icon-names-Di6c4zLo.js → icon-names-C5PeVvkJ.js} +32 -1
  36. package/dist/chunks/icon-names-C5PeVvkJ.js.map +1 -0
  37. package/dist/chunks/{link-navigation-DRHt6g7U.js → index-DZovGMpG.js} +65 -106
  38. package/dist/chunks/index-DZovGMpG.js.map +1 -0
  39. package/dist/chunks/link-navigation-a_sRfmsj.js +49 -0
  40. package/dist/chunks/link-navigation-a_sRfmsj.js.map +1 -0
  41. package/dist/chunks/{widget-name-resolver-Dq6Ejo7d.js → widget-name-resolver-DS3zH_5W.js} +5 -4
  42. package/dist/chunks/{widget-name-resolver-Dq6Ejo7d.js.map → widget-name-resolver-DS3zH_5W.js.map} +1 -1
  43. package/dist/chunks/{withPollingChangeSubscription-ClyOABgu.js → withPollingChangeSubscription-XvCpjGmd.js} +13 -2
  44. package/dist/chunks/{withPollingChangeSubscription-ClyOABgu.js.map → withPollingChangeSubscription-XvCpjGmd.js.map} +1 -1
  45. package/dist/client-testing.js +5 -5
  46. package/dist/client.js +50 -231
  47. package/dist/client.js.map +1 -1
  48. package/dist/contract.js +5 -5
  49. package/dist/files/i18n-keys.json +18091 -1287
  50. package/dist/files/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.md +3 -3
  51. package/dist/image-render.js +7 -7
  52. package/dist/index.js +62 -61
  53. package/dist/index.js.map +1 -1
  54. package/dist/kit.js +2 -2
  55. package/dist/preview.js +7 -7
  56. package/dist/provider.js +57 -56
  57. package/dist/provider.js.map +1 -1
  58. package/dist/renderer.js +15 -15
  59. package/dist/styles.css +2962 -15
  60. package/dist/types/admin/blocks/CodeBlock.d.ts +28 -0
  61. package/dist/types/admin/blocks/DetailModal.d.ts +34 -0
  62. package/dist/types/admin/blocks/Disclosure.d.ts +25 -0
  63. package/dist/types/admin/blocks/JsonTree.d.ts +18 -0
  64. package/dist/types/admin/blocks/LineDiffView.d.ts +18 -0
  65. package/dist/types/admin/blocks/ProportionBar.d.ts +43 -0
  66. package/dist/types/admin/blocks/TokenFigure.d.ts +14 -0
  67. package/dist/types/admin/blocks/json-tree.d.ts +40 -0
  68. package/dist/types/admin/blocks/line-diff.d.ts +46 -0
  69. package/dist/types/admin/blocks/proportion-bar.d.ts +34 -0
  70. package/dist/types/admin/blocks/series-fill-classes.d.ts +13 -0
  71. package/dist/types/admin/blocks/token-figure.d.ts +8 -0
  72. package/dist/types/admin/connections/AgentConnectionCard.d.ts +21 -0
  73. package/dist/types/admin/connections/AgentConnectionDriveRootSpaces.d.ts +25 -0
  74. package/dist/types/admin/connections/AgentConnectionDriveScopeDialog.d.ts +20 -0
  75. package/dist/types/admin/connections/AgentConnectionDriveSearchFilters.d.ts +34 -0
  76. package/dist/types/admin/connections/AgentConnectionDrivesDrawer.d.ts +39 -0
  77. package/dist/types/admin/connections/AgentConnectionLevelsDrawer.d.ts +27 -0
  78. package/dist/types/admin/connections/AgentConnectionSharingDialog.d.ts +12 -0
  79. package/dist/types/admin/connections/AgentConnectionsPanel.d.ts +97 -0
  80. package/dist/types/admin/connections/AgentConnectionsScreen.d.ts +18 -0
  81. package/dist/types/admin/connections/ConnectDialogs.d.ts +22 -0
  82. package/dist/types/admin/connections/agent-connection-drive-scope.d.ts +112 -0
  83. package/dist/types/admin/connections/agent-connection-drives.d.ts +107 -0
  84. package/dist/types/admin/connections/agent-connection-format.d.ts +82 -0
  85. package/dist/types/admin/connections/agent-connection-oauth.d.ts +122 -0
  86. package/dist/types/admin/connections/agent-connections-api.d.ts +420 -0
  87. package/dist/types/admin/connections/agent-connections-context.d.ts +60 -0
  88. package/dist/types/admin/connections/agent-connections-types.d.ts +447 -0
  89. package/dist/types/admin/connections/connection-logos.d.ts +53 -0
  90. package/dist/types/admin/connections/connection-parts.d.ts +84 -0
  91. package/dist/types/admin/connections/use-agent-connect.d.ts +25 -0
  92. package/dist/types/admin/context/CompactionThresholdBanner.d.ts +13 -0
  93. package/dist/types/admin/context/ContextCompositionPanel.d.ts +27 -0
  94. package/dist/types/admin/context/ContextSegmentList.d.ts +20 -0
  95. package/dist/types/admin/context/SentPayloadPanel.d.ts +37 -0
  96. package/dist/types/admin/context/agent-inspect-context-api.d.ts +53 -0
  97. package/dist/types/admin/context/agent-inspect-context-types.d.ts +98 -0
  98. package/dist/types/admin/context/context-composition-grouping.d.ts +78 -0
  99. package/dist/types/admin/context/context-segment-families.d.ts +18 -0
  100. package/dist/types/admin/context/context-segment-label-texts.d.ts +19 -0
  101. package/dist/types/admin/context/context-segment-labels.d.ts +18 -0
  102. package/dist/types/admin/control-panel/AgentControlPanelScreen.d.ts +71 -0
  103. package/dist/types/admin/control-panel/BudgetsTab.d.ts +13 -0
  104. package/dist/types/admin/control-panel/SettingsTab.d.ts +22 -0
  105. package/dist/types/admin/control-panel/SpacesTab.d.ts +24 -0
  106. package/dist/types/admin/control-panel/StatisticsTab.d.ts +26 -0
  107. package/dist/types/admin/control-panel/TimeSeriesChartCard.d.ts +37 -0
  108. package/dist/types/admin/control-panel/ToolResponseSamplesDrawer.d.ts +22 -0
  109. package/dist/types/admin/control-panel/agent-control-panel-api.d.ts +104 -0
  110. package/dist/types/admin/control-panel/agent-control-panel-types.d.ts +241 -0
  111. package/dist/types/admin/control-panel/budget-meters.d.ts +35 -0
  112. package/dist/types/admin/control-panel/control-panel-statistics.d.ts +49 -0
  113. package/dist/types/admin/control-panel/runtime-settings-form.d.ts +44 -0
  114. package/dist/types/admin/control-panel/time-series-chart.d.ts +54 -0
  115. package/dist/types/admin/conversations/AgentConversationDetailScreen.d.ts +128 -0
  116. package/dist/types/admin/conversations/AgentConversationsScreen.d.ts +60 -0
  117. package/dist/types/admin/conversations/ContextPanel.d.ts +9 -0
  118. package/dist/types/admin/conversations/ConversationActions.d.ts +32 -0
  119. package/dist/types/admin/conversations/ConversationTurns.d.ts +56 -0
  120. package/dist/types/admin/conversations/DebugSwitchBar.d.ts +23 -0
  121. package/dist/types/admin/conversations/DelegationPanel.d.ts +6 -0
  122. package/dist/types/admin/conversations/ModelContextDialog.d.ts +31 -0
  123. package/dist/types/admin/conversations/RequestCompositionRows.d.ts +14 -0
  124. package/dist/types/admin/conversations/RequestsPanel.d.ts +21 -0
  125. package/dist/types/admin/conversations/SandboxPanel.d.ts +42 -0
  126. package/dist/types/admin/conversations/StepDetailDialog.d.ts +19 -0
  127. package/dist/types/admin/conversations/agent-inspect-api.d.ts +259 -0
  128. package/dist/types/admin/conversations/agent-inspect-mappers.d.ts +23 -0
  129. package/dist/types/admin/conversations/agent-inspect-types.d.ts +517 -0
  130. package/dist/types/admin/conversations/conversation-list-export.d.ts +64 -0
  131. package/dist/types/admin/conversations/conversation-list-filters.d.ts +59 -0
  132. package/dist/types/admin/conversations/debug-switches.d.ts +27 -0
  133. package/dist/types/admin/conversations/delegation-swimlanes.d.ts +78 -0
  134. package/dist/types/admin/conversations/header-facts.d.ts +23 -0
  135. package/dist/types/admin/conversations/inspect-format.d.ts +44 -0
  136. package/dist/types/admin/conversations/inspect-parts.d.ts +42 -0
  137. package/dist/types/admin/conversations/inspect-scope.d.ts +92 -0
  138. package/dist/types/admin/conversations/model-call-rows.d.ts +78 -0
  139. package/dist/types/admin/conversations/step-descriptions.d.ts +43 -0
  140. package/dist/types/admin/conversations/touched-files-tree.d.ts +47 -0
  141. package/dist/types/admin/conversations/turn-paging.d.ts +56 -0
  142. package/dist/types/admin/conversations/turn-segments.d.ts +36 -0
  143. package/dist/types/admin/conversations/turn-timeline.d.ts +22 -0
  144. package/dist/types/admin/conversations/use-query-loader.d.ts +8 -0
  145. package/dist/types/admin/period/AdminPeriodControl.d.ts +15 -0
  146. package/dist/types/admin/period/admin-period.d.ts +51 -0
  147. package/dist/types/admin/quality/AgentQualityEvalRunScreen.d.ts +30 -0
  148. package/dist/types/admin/quality/AgentQualityScreen.d.ts +38 -0
  149. package/dist/types/admin/quality/SaveAsEvalCaseDialog.d.ts +27 -0
  150. package/dist/types/admin/quality/agent-quality-api.d.ts +86 -0
  151. package/dist/types/admin/quality/agent-quality-format.d.ts +52 -0
  152. package/dist/types/admin/quality/agent-quality-types.d.ts +161 -0
  153. package/dist/types/admin/schedules/AgentSchedulesPanel.d.ts +43 -0
  154. package/dist/types/admin/schedules/agent-schedules-api.d.ts +116 -0
  155. package/dist/types/admin/schedules/agent-schedules-format.d.ts +25 -0
  156. package/dist/types/admin/schedules/agent-schedules-types.d.ts +113 -0
  157. package/dist/types/admin/shared/AdminHrefLink.d.ts +13 -0
  158. package/dist/types/admin/skills/AgentSkillCatalogScreen.d.ts +51 -0
  159. package/dist/types/admin/skills/SharedBlocksPanel.d.ts +14 -0
  160. package/dist/types/admin/skills/SkillPurposesPanel.d.ts +16 -0
  161. package/dist/types/admin/skills/SkillTreeRowView.d.ts +31 -0
  162. package/dist/types/admin/skills/ToolSchemaDrawer.d.ts +21 -0
  163. package/dist/types/admin/skills/agent-skill-catalog-api.d.ts +89 -0
  164. package/dist/types/admin/skills/agent-skill-catalog-types.d.ts +223 -0
  165. package/dist/types/admin/skills/skill-catalog-colors.d.ts +10 -0
  166. package/dist/types/admin/skills/skill-catalog-tree.d.ts +159 -0
  167. package/dist/types/admin/skills/skill-purpose-texts.d.ts +11 -0
  168. package/dist/types/admin/wire/admin-wire.d.ts +21 -0
  169. package/dist/types/chat/controller/AgentChatController.d.ts +22 -0
  170. package/dist/types/chat/controller/turn-initiators.d.ts +21 -0
  171. package/dist/types/chat/trace/BackgroundTasksList.d.ts +35 -0
  172. package/dist/types/chat/trace/ChangeSetCard.d.ts +34 -0
  173. package/dist/types/chat/trace/ChangedFilesPane.d.ts +33 -0
  174. package/dist/types/chat/trace/ChangedRecordsList.d.ts +34 -0
  175. package/dist/types/chat/trace/ConsentRequestCard.d.ts +23 -0
  176. package/dist/types/chat/trace/ContextRing.d.ts +19 -0
  177. package/dist/types/chat/trace/ConversationChildTrace.d.ts +18 -0
  178. package/dist/types/chat/trace/ConversationTurnTrace.d.ts +48 -0
  179. package/dist/types/chat/trace/EntityChip.d.ts +23 -0
  180. package/dist/types/chat/trace/FileChangesSummary.d.ts +14 -0
  181. package/dist/types/chat/trace/FileEditBlock.d.ts +42 -0
  182. package/dist/types/chat/trace/LoadedSkillsDisclosure.d.ts +16 -0
  183. package/dist/types/chat/trace/QueuedMessageChip.d.ts +17 -0
  184. package/dist/types/chat/trace/RunStatusLine.d.ts +27 -0
  185. package/dist/types/chat/trace/StepKindDetails.d.ts +59 -0
  186. package/dist/types/chat/trace/SubAgentStepGroup.d.ts +53 -0
  187. package/dist/types/chat/trace/TaskPlanPane.d.ts +31 -0
  188. package/dist/types/chat/trace/TaskPlanRow.d.ts +28 -0
  189. package/dist/types/chat/trace/TerminalBlock.d.ts +16 -0
  190. package/dist/types/chat/trace/ThinkingBlock.d.ts +19 -0
  191. package/dist/types/chat/trace/ToolStepDetail.d.ts +49 -0
  192. package/dist/types/chat/trace/ToolStepGroup.d.ts +58 -0
  193. package/dist/types/chat/trace/ToolStepRow.d.ts +52 -0
  194. package/dist/types/chat/trace/TraceViewModeSwitch.d.ts +14 -0
  195. package/dist/types/chat/trace/TurnMetaLine.d.ts +27 -0
  196. package/dist/types/chat/trace/content-from-unified-diff.d.ts +25 -0
  197. package/dist/types/chat/trace/conversation-trace-loader.d.ts +133 -0
  198. package/dist/types/chat/trace/index.d.ts +34 -0
  199. package/dist/types/chat/trace/parse-unified-diff.d.ts +51 -0
  200. package/dist/types/chat/trace/task-plan-counts.d.ts +41 -0
  201. package/dist/types/chat/trace/trace-collect.d.ts +91 -0
  202. package/dist/types/chat/trace/trace-counts.d.ts +21 -0
  203. package/dist/types/chat/trace/trace-format.d.ts +73 -0
  204. package/dist/types/chat/trace/trace-labels.d.ts +60 -0
  205. package/dist/types/chat/trace/trace-parts.d.ts +63 -0
  206. package/dist/types/chat/trace/trace-step-focus.d.ts +12 -0
  207. package/dist/types/chat/trace/trace-types.d.ts +370 -0
  208. package/dist/types/chat/trace/use-conversation-trace.d.ts +47 -0
  209. package/dist/types/client/AgentsConversationClient.d.ts +20 -0
  210. package/dist/types/client/http/agents-http-trace-mappers.d.ts +31 -0
  211. package/dist/types/client/http/agents-http-trace-wire.d.ts +433 -0
  212. package/dist/types/contract/conversation-trace.d.ts +594 -0
  213. package/dist/types/entries/admin.d.ts +85 -0
  214. package/dist/types/entries/chat.d.ts +3 -1
  215. package/dist/types/entries/client.d.ts +2 -0
  216. package/dist/types/entries/contract.d.ts +1 -0
  217. package/dist/types/provider/components/icon-names.d.ts +4 -2
  218. package/dist/types/provider/components/types.d.ts +3 -1
  219. package/dist/types/widgets/DriveFilesConversationWidget/shared/drive-files.d.ts +1 -1
  220. package/dist/voice.js +3 -3
  221. package/dist/widgets.js +6 -6
  222. package/package.json +7 -3
  223. package/public-api.json +1036 -3
  224. package/dist/chunks/WebSearchResultsConversationWidget-dEq19U7k.js.map +0 -1
  225. package/dist/chunks/icon-names-Di6c4zLo.js.map +0 -1
  226. package/dist/chunks/link-navigation-DRHt6g7U.js.map +0 -1
package/dist/chat.js CHANGED
@@ -1,39 +1,40 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
3
- import { useRef, useEffect, useMemo, useState, useImperativeHandle, useLayoutEffect, memo, useCallback, Fragment, useReducer } from "react";
4
- import { u as useAgentsConversationClient, a as useOptionalAgentsConversationClient, A as AgentsConversationClientProvider } from "./chunks/AgentsConversationClientContext-C4T7g_Qk.js";
5
- import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-ClyOABgu.js";
6
- import { s as Text, F as classNames, I as Icon, ab as useAgentsTexts, G as GlowFrame, v as Tooltip, B as Button, n as Skeleton, j as Markdown, K as getAgentDisplayName, a3 as useAgentsBudgetLimit, a5 as useAgentsEnvironment, h as InteractiveSurface, L as LoadingSpinner, a1 as translateText, p as SplitView, _ as reportRunningTurn, a2 as useAgentsActiveAgentSpaceKey, P as ProgressBar } from "./chunks/link-navigation-DRHt6g7U.js";
7
- import { i as isAgentsClientError, a as AgentsClientError } from "./chunks/conversation-CbWEHPbL.js";
8
- import { n as normalizeServerMessageToMarkdown, V as VoiceBarsIcon, b as ConversationMessageHeader, a as ConversationMessageUser, C as ConversationMessageWidgets } from "./chunks/VoiceBarsIcon-FhLAcgLG.js";
9
- import { a1 as useConversationWidgetContext, j as canvasBehaviourOf, J as canvasKindOpenerWidgetNamesOf, p as payloadHashOfInstanceId, A as buildWidgetAgentSpaceKeyProps, t as CHAT_COLUMN_MIN_WIDTH_PX, q as CANVAS_MIN_WIDTH_PX, bg as useCanvasViable, D as DEFAULT_CANVAS_WIDTH_PERCENT, K as canvasWidthPercentOf, C as CANVAS_BOXED_INSET_PX, aq as ElementWidthCanvasViability, ae as CanvasViabilityContext } from "./chunks/WebSearchResultsConversationWidget-dEq19U7k.js";
10
- import { j as conversationWidgetRegistry, n as findWidgetFencesInMarkdown, o as ConversationWidgetErrorBoundary, p as ConversationWidgetFeatureGate, T as parseWidgetJsonObject, F as resolveCanonicalWidgetName, W as WIDGET_FENCE_LANG, y as getConversationWidgetRegistryRevision, U as BARE_WIDGET_LINE_GLOBAL, G as resolveWidgetName, t as closestWidgetNames } from "./chunks/widget-name-resolver-Dq6Ejo7d.js";
11
- import { r as readStoredCanvas, c as clearStoredCanvas } from "./chunks/canvasStorage-Cr3omZeI.js";
12
- import { r as resolveDeepLinkableWidget, i as isWidgetClickSignalSource, C as CanvasTitleSlotContext } from "./chunks/canvas-title-slot-context-BI1PLnPn.js";
13
- import { b as ConversationErrorType, a as ConversationMessageInputComposerWidgets, C as ConversationWidgetProvider, c as createAgentsChatStore } from "./chunks/ConversationMessageInputComposerWidgets-7HNAmZE1.js";
14
- import { A, E, I, r, d } from "./chunks/ConversationMessageInputComposerWidgets-7HNAmZE1.js";
15
- import { c as buildMessageTextWithComposerWidgets, e as WidgetWindowRootContext, f as findBalancedJsonObjectEnd, d as buildWidgetRenderReportSignal, W as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, g as createWidgetRenderReportCollector, h as WidgetRenderReportCollectorContext } from "./chunks/ConversationMarkdown-D-aP3Ssl.js";
16
- import { l as lastWireMessageIsUnansweredUserMessage, P as PHONE_CALL_LIFECYCLE_SIGNAL_SOURCES, b as buildChangedMessagesRequest, d as deriveAgentActivity } from "./chunks/contract-C18owGKs.js";
17
- import { S } from "./chunks/contract-C18owGKs.js";
3
+ import { useRef, useEffect, useMemo, useState, useImperativeHandle, useLayoutEffect, memo, useCallback, Fragment, useReducer, useSyncExternalStore } from "react";
4
+ import { u as useAgentsConversationClient, a as useOptionalAgentsConversationClient, A as AgentsConversationClientProvider } from "./chunks/AgentsConversationClientContext-B_UJSLXU.js";
5
+ import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-XvCpjGmd.js";
6
+ import { r as Text, E as classNames, I as Icon, a9 as useAgentsTexts, G as GlowFrame, u as Tooltip, B as Button, m as Skeleton, i as Markdown, J as getAgentDisplayName, a2 as useAgentsBudgetLimit, a4 as useAgentsEnvironment, g as InteractiveSurface, L as LoadingSpinner, a0 as translateText, o as SplitView, Z as reportRunningTurn, a1 as useAgentsActiveAgentSpaceKey, P as ProgressBar } from "./chunks/index-DZovGMpG.js";
7
+ import { i as isAgentsClientError, A as AgentsClientError } from "./chunks/conversation-B7-evdj_.js";
8
+ import { n as normalizeServerMessageToMarkdown, V as VoiceBarsIcon, b as ConversationMessageHeader, a as ConversationMessageUser, C as ConversationMessageWidgets } from "./chunks/VoiceBarsIcon-y3mgSqbn.js";
9
+ import { a1 as useConversationWidgetContext, j as canvasBehaviourOf, J as canvasKindOpenerWidgetNamesOf, p as payloadHashOfInstanceId, A as buildWidgetAgentSpaceKeyProps, t as CHAT_COLUMN_MIN_WIDTH_PX, q as CANVAS_MIN_WIDTH_PX, bg as useCanvasViable, D as DEFAULT_CANVAS_WIDTH_PERCENT, K as canvasWidthPercentOf, C as CANVAS_BOXED_INSET_PX, aq as ElementWidthCanvasViability, ae as CanvasViabilityContext } from "./chunks/WebSearchResultsConversationWidget-l9Aek_lG.js";
10
+ import { j as conversationWidgetRegistry, n as findWidgetFencesInMarkdown, o as ConversationWidgetErrorBoundary, p as ConversationWidgetFeatureGate, T as parseWidgetJsonObject, F as resolveCanonicalWidgetName, W as WIDGET_FENCE_LANG, y as getConversationWidgetRegistryRevision, U as BARE_WIDGET_LINE_GLOBAL, G as resolveWidgetName, t as closestWidgetNames } from "./chunks/widget-name-resolver-DS3zH_5W.js";
11
+ import { r as readStoredCanvas, c as clearStoredCanvas } from "./chunks/canvasStorage-DSspwRMg.js";
12
+ import { r as resolveDeepLinkableWidget, i as isWidgetClickSignalSource, C as CanvasTitleSlotContext } from "./chunks/canvas-title-slot-context-BRGnFzYP.js";
13
+ import { b as ConversationErrorType, a as ConversationMessageInputComposerWidgets, C as ConversationWidgetProvider, c as createAgentsChatStore } from "./chunks/ConversationMessageInputComposerWidgets-TchR1lPj.js";
14
+ import { A, E, I, r, d } from "./chunks/ConversationMessageInputComposerWidgets-TchR1lPj.js";
15
+ import { c as buildMessageTextWithComposerWidgets, e as WidgetWindowRootContext, f as findBalancedJsonObjectEnd, d as buildWidgetRenderReportSignal, W as WIDGET_RENDER_REPORT_SIGNAL_SOURCE, g as createWidgetRenderReportCollector, h as WidgetRenderReportCollectorContext } from "./chunks/ConversationMarkdown-DlvwT3Qk.js";
16
+ import { l as lastWireMessageIsUnansweredUserMessage, P as PHONE_CALL_LIFECYCLE_SIGNAL_SOURCES, b as buildChangedMessagesRequest, S as SIGNAL_SOURCES_THAT_OWE_NO_WORK, d as deriveAgentActivity } from "./chunks/contract-886XjdID.js";
18
17
  import { t as textKey } from "./chunks/text-key-DnoZ4lAk.js";
19
- import { c as canvasBodies } from "./chunks/canvasBodies-CRVh8pCw.js";
18
+ import { c as canvasBodies } from "./chunks/canvasBodies-BjXypuHf.js";
20
19
  import { a as canvasFeatureFlagOf } from "./chunks/canvas-feature-flags-Cn8xBliA.js";
21
20
  import { flushSync } from "react-dom";
22
- import { u as useAgentsChatSelector } from "./chunks/use-agents-chat-store-CuIkCz9v.js";
23
- import { A as A2, b, c, a } from "./chunks/use-agents-chat-store-CuIkCz9v.js";
21
+ import { u as useAgentsChatSelector, a as useOptionalAgentsChatStore } from "./chunks/use-agents-chat-store-CuIkCz9v.js";
22
+ import { A as A2, b, c } from "./chunks/use-agents-chat-store-CuIkCz9v.js";
23
+ import { s as styles$l, u as useTraceFormat, a as useTraceNow, b as agentStyles, T as TraceStateIcon, r as readTraceMoment, f as formatTraceClock, c as readTraceStateLabel, d as styles$m, F as FileChangesSummary, e as readTraceFileChangeLetter, g as readTraceFileChangeWord, h as TracePath, i as TraceMountChip, j as TraceLink, k as FileEditBlock, E as EntityChip, l as selectVisibleTraceSteps, m as TraceStepRow, n as TaskPlanRow, o as readTaskPlanCountsOfStep, p as buildTaskPlanItems, q as describeStepCount, t as TurnMetaLine, v as ToolStepGroup, w as readTaskPlanCounts, x as describeTaskPlanProgress, y as isTraceBackgroundJobLabel, z as readTraceSubAgentState, A as describeTraceBackgroundJob, B as readTraceStepState } from "./chunks/content-from-unified-diff-CovnmG2Q.js";
24
+ import { C, D, L, S, G, H, I as I2, J, K, M, N, O, P, Q, R, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak } from "./chunks/content-from-unified-diff-CovnmG2Q.js";
24
25
  const history = "agents_history_BIbikt";
25
- const styles$j = {
26
+ const styles$k = {
26
27
  history
27
28
  };
28
29
  const AgentChatActivityHistory = (props) => {
29
30
  const { turn } = props;
30
31
  if (turn === null || turn.lines.length === 0) return null;
31
- return /* @__PURE__ */ jsx("div", { className: styles$j.history, "data-testid": "agent-chat-activity-history", children: turn.lines.map((line2) => /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", translate: false, children: line2.line }, `${line2.toolCallMessageId}-${line2.state}`)) });
32
+ return /* @__PURE__ */ jsx("div", { className: styles$k.history, "data-testid": "agent-chat-activity-history", children: turn.lines.map((line2) => /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", translate: false, children: line2.line }, `${line2.toolCallMessageId}-${line2.state}`)) });
32
33
  };
33
34
  const dots = "agents_dots_ndE4a-";
34
35
  const bounce = "agents_bounce_rAVWhT";
35
36
  const pulse = "agents_pulse_r0EheQ";
36
- const styles$i = {
37
+ const styles$j = {
37
38
  dots,
38
39
  bounce,
39
40
  pulse
@@ -41,7 +42,7 @@ const styles$i = {
41
42
  const AgentChatActivityDots = ({ variant = "bounce" }) => /* @__PURE__ */ jsxs(
42
43
  "div",
43
44
  {
44
- className: classNames(styles$i.dots, variant === "pulse" ? styles$i.pulse : styles$i.bounce),
45
+ className: classNames(styles$j.dots, variant === "pulse" ? styles$j.pulse : styles$j.bounce),
45
46
  "aria-hidden": "true",
46
47
  "data-agents-activity-dots": variant,
47
48
  children: [
@@ -52,7 +53,7 @@ const AgentChatActivityDots = ({ variant = "bounce" }) => /* @__PURE__ */ jsxs(
52
53
  }
53
54
  );
54
55
  const activity = "agents_activity_Gv-0ee";
55
- const styles$h = {
56
+ const styles$i = {
56
57
  activity
57
58
  };
58
59
  const AgentChatActivityIndicator = (props) => {
@@ -61,18 +62,18 @@ const AgentChatActivityIndicator = (props) => {
61
62
  if (!isWorking) return null;
62
63
  const currentLines = activityTicker.currentTurn?.lines ?? [];
63
64
  const currentLine = currentLines.length > 0 ? currentLines[currentLines.length - 1].line : null;
64
- return /* @__PURE__ */ jsxs("div", { className: styles$h.activity, role: "status", "aria-live": "polite", "data-testid": "agent-chat-activity", children: [
65
+ return /* @__PURE__ */ jsxs("div", { className: styles$i.activity, role: "status", "aria-live": "polite", "data-testid": "agent-chat-activity", children: [
65
66
  /* @__PURE__ */ jsx(AgentChatActivityDots, { variant: dotsVariant }),
66
67
  currentLine !== null ? /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", translate: false, children: currentLine }) : /* @__PURE__ */ jsx(Text, { role: "help", color: "--agents-fg-light", children: "Working on it…" })
67
68
  ] });
68
69
  };
69
70
  const bar = "agents_bar_DAkgRp";
70
- const styles$g = {
71
+ const styles$h = {
71
72
  bar
72
73
  };
73
74
  const ConversationClosedBar = (props) => {
74
75
  const { text = "This conversation is closed." } = props;
75
- return /* @__PURE__ */ jsxs("div", { className: styles$g.bar, "data-testid": "agent-chat-closed-bar", children: [
76
+ return /* @__PURE__ */ jsxs("div", { className: styles$h.bar, "data-testid": "agent-chat-closed-bar", children: [
76
77
  /* @__PURE__ */ jsx(Icon, { name: "check", color: "--agents-success-500" }),
77
78
  /* @__PURE__ */ jsx(Text, { children: text })
78
79
  ] });
@@ -156,7 +157,7 @@ const input = "agents_input_GCtiXU";
156
157
  const inputReplacement = "agents_inputReplacement_EAhjsv";
157
158
  const inputInCategory = "agents_inputInCategory_RDuOYA";
158
159
  const olderLoading = "agents_olderLoading_5X7nMg";
159
- const styles$f = {
160
+ const styles$g = {
160
161
  chat,
161
162
  genericChat,
162
163
  customBg,
@@ -191,7 +192,7 @@ const compactTopSlot = "agents_compactTopSlot_x57yOL";
191
192
  const compactActionsStart = "agents_compactActionsStart_3SeY5C";
192
193
  const collapsed = "agents_collapsed_v3Ekqz";
193
194
  const collapsedPillSizer = "agents_collapsedPillSizer_aqw7WI";
194
- const styles$e = {
195
+ const styles$f = {
195
196
  inputContainer,
196
197
  aiGlow,
197
198
  editableInput,
@@ -377,7 +378,7 @@ const ConversationMessageInput = (props) => {
377
378
  /* @__PURE__ */ jsx(
378
379
  GlowFrame,
379
380
  {
380
- className: classNames(styles$e.aiGlow),
381
+ className: classNames(styles$f.aiGlow),
381
382
  color: isMessageTooLong ? "var(--agents-danger-500)" : void 0,
382
383
  borderRadius: compact2 ? COMPACT_INPUT_RADIUS_PX : void 0,
383
384
  borderWidth: 2,
@@ -386,20 +387,20 @@ const ConversationMessageInput = (props) => {
386
387
  "div",
387
388
  {
388
389
  className: classNames(
389
- styles$e.inputContainer,
390
+ styles$f.inputContainer,
390
391
  {
391
- [styles$e.compact]: compact2,
392
- [styles$e.compactStacked]: isCompactStacked,
393
- [styles$e.compactWithActionsStart]: isCompactStacked && !!actionsSlotStart,
394
- [styles$e.collapsed]: compact2 && collapsed2
392
+ [styles$f.compact]: compact2,
393
+ [styles$f.compactStacked]: isCompactStacked,
394
+ [styles$f.compactWithActionsStart]: isCompactStacked && !!actionsSlotStart,
395
+ [styles$f.collapsed]: compact2 && collapsed2
395
396
  },
396
397
  inputContainerClassName
397
398
  ),
398
399
  onMouseDown: handleContainerMouseDown,
399
400
  children: [
400
- isCompactStacked && !!topSlot && /* @__PURE__ */ jsx("div", { className: styles$e.compactTopSlot, children: topSlot }),
401
+ isCompactStacked && !!topSlot && /* @__PURE__ */ jsx("div", { className: styles$f.compactTopSlot, children: topSlot }),
401
402
  !isCompactStacked && topSlot,
402
- isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$e.compactActionsStart, children: actionsSlotStart }),
403
+ isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$f.compactActionsStart, children: actionsSlotStart }),
403
404
  /* @__PURE__ */ jsx(
404
405
  "span",
405
406
  {
@@ -409,26 +410,26 @@ const ConversationMessageInput = (props) => {
409
410
  onCompositionStart: handleCompositionStart,
410
411
  onCompositionEnd: handleCompositionEnd,
411
412
  onKeyDown: handleKeyPress,
412
- className: `${styles$e.editableInput} ${!inputValue ? styles$e.showPlaceholder : ""}`,
413
+ className: `${styles$f.editableInput} ${!inputValue ? styles$f.showPlaceholder : ""}`,
413
414
  "data-placeholder": translatedPlaceholder,
414
415
  "data-testid": `${testId}-textarea`
415
416
  }
416
417
  ),
417
- inputValue.length >= CHARACTER_COUNTER_SHOWN_FROM_LENGTH && /* @__PURE__ */ jsx("div", { className: styles$e.statusRow, children: /* @__PURE__ */ jsx(
418
+ inputValue.length >= CHARACTER_COUNTER_SHOWN_FROM_LENGTH && /* @__PURE__ */ jsx("div", { className: styles$f.statusRow, children: /* @__PURE__ */ jsx(
418
419
  Text,
419
420
  {
420
421
  role: "caption",
421
422
  translate: false,
422
423
  color: isMessageTooLong ? "var(--agents-danger-500)" : "var(--agents-fg-lightest)",
423
- className: styles$e.characterCounter,
424
+ className: styles$f.characterCounter,
424
425
  testId: `${testId}-character-counter`,
425
426
  children: `${inputValue.length.toLocaleString()} / ${MAX_MESSAGE_LENGTH.toLocaleString()}`
426
427
  }
427
428
  ) }),
428
- /* @__PURE__ */ jsxs("div", { className: styles$e.actions, children: [
429
- !isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$e.actionsStart, children: actionsSlotStart }),
429
+ /* @__PURE__ */ jsxs("div", { className: styles$f.actions, children: [
430
+ !isCompactStacked && !!actionsSlotStart && /* @__PURE__ */ jsx("div", { className: styles$f.actionsStart, children: actionsSlotStart }),
430
431
  actionsSlot,
431
- sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames(styles$e.ownAction, { [styles$e.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
432
+ sendReplacementWhenEmpty && !hasSendableContent ? sendReplacementWhenEmpty : /* @__PURE__ */ jsx("div", { className: classNames(styles$f.ownAction, { [styles$f.sendBlocked]: isMessageTooLong }), children: /* @__PURE__ */ jsx(
432
433
  Tooltip,
433
434
  {
434
435
  text: isMessageTooLong ? "Your message is over the %maxLength% character limit" : void 0,
@@ -455,7 +456,7 @@ const ConversationMessageInput = (props) => {
455
456
  )
456
457
  }
457
458
  ),
458
- measuresCollapsedPillWidth && /* @__PURE__ */ jsx("span", { ref: collapsedPillSizerRef, className: styles$e.collapsedPillSizer, "aria-hidden": "true", children: translatedPlaceholder })
459
+ measuresCollapsedPillWidth && /* @__PURE__ */ jsx("span", { ref: collapsedPillSizerRef, className: styles$f.collapsedPillSizer, "aria-hidden": "true", children: translatedPlaceholder })
459
460
  ] });
460
461
  };
461
462
  const canvasReopenControl = "agents_canvasReopenControl_7vGS8F";
@@ -487,7 +488,7 @@ const classes$1 = {
487
488
  assistantMessageBesideAvatar
488
489
  };
489
490
  const avatar = "agents_avatar_Vlh0Vn";
490
- const title = "agents_title_j4BUnD";
491
+ const title$1 = "agents_title_j4BUnD";
491
492
  const subtitle = "agents_subtitle_IyTssG";
492
493
  const suggestionCard$1 = "agents_suggestionCard_62jhTV";
493
494
  const userBubble = "agents_userBubble_-P9Wwm";
@@ -497,7 +498,7 @@ const messageAuthor = "agents_messageAuthor_2HTGU1";
497
498
  const messageBody = "agents_messageBody_orq0Pr";
498
499
  const loadingStyles = {
499
500
  avatar,
500
- title,
501
+ title: title$1,
501
502
  subtitle,
502
503
  suggestionCard: suggestionCard$1,
503
504
  userBubble,
@@ -512,7 +513,7 @@ const NoConversationLoading = () => {
512
513
  /* @__PURE__ */ jsx(Skeleton, { className: loadingStyles.avatar, borderRadius: SKEL_RADIUS }),
513
514
  /* @__PURE__ */ jsx(Skeleton, { className: loadingStyles.title }),
514
515
  /* @__PURE__ */ jsx(Skeleton, { className: loadingStyles.subtitle }),
515
- /* @__PURE__ */ jsx("div", { className: classes$1.suggestions, children: Array.from({ length: 3 }, (_, index) => /* @__PURE__ */ jsx(Skeleton, { className: loadingStyles.suggestionCard, borderRadius: SKEL_RADIUS }, index)) })
516
+ /* @__PURE__ */ jsx("div", { className: classes$1.suggestions, children: Array.from({ length: 3 }, (_2, index) => /* @__PURE__ */ jsx(Skeleton, { className: loadingStyles.suggestionCard, borderRadius: SKEL_RADIUS }, index)) })
516
517
  ] });
517
518
  };
518
519
  const ConversationLoading = () => {
@@ -578,22 +579,22 @@ const assistantMessageHasRenderableMarkdown = (message) => {
578
579
  return markdown !== "" && !isBareUnknownTypeJson(markdown);
579
580
  };
580
581
  const responseContainer$1 = "agents_responseContainer_LFzKoO";
581
- const styles$d = {
582
+ const styles$e = {
582
583
  responseContainer: responseContainer$1
583
584
  };
584
585
  const responseHeaderLayout = "agents_responseHeaderLayout_WuoaNs";
585
586
  const iconContainer = "agents_iconContainer_C1c9yQ";
586
587
  const responseHeader = "agents_responseHeader_-CQw8U";
587
- const styles$c = {
588
+ const styles$d = {
588
589
  responseHeaderLayout,
589
590
  iconContainer,
590
591
  responseHeader
591
592
  };
592
593
  const ConversationMessageSystemHeader = memo((props) => {
593
594
  const { aiPromptExtensionCategory, aiPromptExtension, isContentExpanded, onExpandContentClick } = props;
594
- return /* @__PURE__ */ jsxs("div", { className: styles$c.responseHeaderLayout, children: [
595
- /* @__PURE__ */ jsxs("div", { className: styles$c.responseHeader, children: [
596
- /* @__PURE__ */ jsx("span", { className: styles$c.iconContainer, children: /* @__PURE__ */ jsx(Icon, { color: "var(--agents-fg-on-accent)", name: "wizard" }) }),
595
+ return /* @__PURE__ */ jsxs("div", { className: styles$d.responseHeaderLayout, children: [
596
+ /* @__PURE__ */ jsxs("div", { className: styles$d.responseHeader, children: [
597
+ /* @__PURE__ */ jsx("span", { className: styles$d.iconContainer, children: /* @__PURE__ */ jsx(Icon, { color: "var(--agents-fg-on-accent)", name: "wizard" }) }),
597
598
  /* @__PURE__ */ jsxs("div", { children: [
598
599
  /* @__PURE__ */ jsx(Text, { role: "help", weight: "bold", children: aiPromptExtension?.name ?? "AI Extensions" }),
599
600
  aiPromptExtensionCategory !== void 0 ? /* @__PURE__ */ jsxs(Text, { role: "caption", children: [
@@ -603,7 +604,7 @@ const ConversationMessageSystemHeader = memo((props) => {
603
604
  aiPromptExtensionCategory === void 0 ? /* @__PURE__ */ jsx(Text, { role: "caption", children: "System" }) : null
604
605
  ] })
605
606
  ] }),
606
- /* @__PURE__ */ jsx("div", { className: styles$c.responseHeaderAction, children: /* @__PURE__ */ jsx(
607
+ /* @__PURE__ */ jsx("div", { className: styles$d.responseHeaderAction, children: /* @__PURE__ */ jsx(
607
608
  Button,
608
609
  {
609
610
  variant: "muted",
@@ -616,7 +617,7 @@ const ConversationMessageSystemHeader = memo((props) => {
616
617
  const ConversationMessageSystem = memo((props) => {
617
618
  const { aiPromptExtensionCategory, aiPromptExtension, message } = props;
618
619
  const [isContentExpanded, setIsContentExpanded] = useState(false);
619
- return /* @__PURE__ */ jsxs("div", { className: styles$d.responseContainer, children: [
620
+ return /* @__PURE__ */ jsxs("div", { className: styles$e.responseContainer, children: [
620
621
  /* @__PURE__ */ jsx(
621
622
  ConversationMessageSystemHeader,
622
623
  {
@@ -626,14 +627,14 @@ const ConversationMessageSystem = memo((props) => {
626
627
  isContentExpanded
627
628
  }
628
629
  ),
629
- /* @__PURE__ */ jsx("div", { style: { display: isContentExpanded ? void 0 : "none" }, children: /* @__PURE__ */ jsx("div", { className: styles$d.responseMessage, children: /* @__PURE__ */ jsx(Markdown, { markdown: message }) }) })
630
+ /* @__PURE__ */ jsx("div", { style: { display: isContentExpanded ? void 0 : "none" }, children: /* @__PURE__ */ jsx("div", { className: styles$e.responseMessage, children: /* @__PURE__ */ jsx(Markdown, { markdown: message }) }) })
630
631
  ] });
631
632
  });
632
633
  const markerRow = "agents_markerRow_zl8Pcg";
633
634
  const markerChip = "agents_markerChip_u9Z-aO";
634
635
  const markerIcon = "agents_markerIcon_En-miz";
635
636
  const markerDuration = "agents_markerDuration_Nbff92";
636
- const styles$b = {
637
+ const styles$c = {
637
638
  markerRow,
638
639
  markerChip,
639
640
  markerIcon,
@@ -666,15 +667,15 @@ const ConversationCallMarkerChip = memo(({ signalSource, signalText }) => {
666
667
  const durationSeconds = /(\d+)s\b/.exec(signalText)?.[1];
667
668
  const markerState = callMarkerStateOf(isCallEnd, endReason);
668
669
  const markerLabel = isInAppCall ? MARKER_LABELS[markerState].inApp : MARKER_LABELS[markerState].phoneLine;
669
- return /* @__PURE__ */ jsx("div", { className: styles$b.markerRow, "data-testid": "conversation-call-marker", children: /* @__PURE__ */ jsxs("span", { className: styles$b.markerChip, "data-state": markerState, children: [
670
- /* @__PURE__ */ jsx("span", { className: styles$b.markerIcon, children: isInAppCall ? /* @__PURE__ */ jsx(VoiceBarsIcon, { size: 16 }) : /* @__PURE__ */ jsx(Icon, { name: "phone" }) }),
670
+ return /* @__PURE__ */ jsx("div", { className: styles$c.markerRow, "data-testid": "conversation-call-marker", children: /* @__PURE__ */ jsxs("span", { className: styles$c.markerChip, "data-state": markerState, children: [
671
+ /* @__PURE__ */ jsx("span", { className: styles$c.markerIcon, children: isInAppCall ? /* @__PURE__ */ jsx(VoiceBarsIcon, { size: 16 }) : /* @__PURE__ */ jsx(Icon, { name: "phone" }) }),
671
672
  /* @__PURE__ */ jsx(Text, { role: "caption", replacements: { agentName: getAgentDisplayName() }, children: markerLabel }),
672
- markerState === "ended" && durationSeconds != null && /* @__PURE__ */ jsx("span", { className: styles$b.markerDuration, children: /* @__PURE__ */ jsx(Text, { role: "caption", translate: false, children: formatCallDuration(Number(durationSeconds)) }) })
673
+ markerState === "ended" && durationSeconds != null && /* @__PURE__ */ jsx("span", { className: styles$c.markerDuration, children: /* @__PURE__ */ jsx(Text, { role: "caption", translate: false, children: formatCallDuration(Number(durationSeconds)) }) })
673
674
  ] }) });
674
675
  });
675
676
  const disclosure = "agents_disclosure_rVPB-y";
676
677
  const instructionPanel = "agents_instructionPanel_G2fM1K";
677
- const styles$a = {
678
+ const styles$b = {
678
679
  disclosure,
679
680
  instructionPanel
680
681
  };
@@ -682,15 +683,15 @@ const ConversationTaskInstructionDisclosure = ({
682
683
  instructionText
683
684
  }) => {
684
685
  const [expanded, setExpanded] = useState(false);
685
- return /* @__PURE__ */ jsxs("div", { className: styles$a.disclosure, children: [
686
- expanded ? /* @__PURE__ */ jsx("div", { className: styles$a.instructionPanel, children: /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", allowNewLines: true, translate: false, children: instructionText }) }) : null,
686
+ return /* @__PURE__ */ jsxs("div", { className: styles$b.disclosure, children: [
687
+ expanded ? /* @__PURE__ */ jsx("div", { className: styles$b.instructionPanel, children: /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", allowNewLines: true, translate: false, children: instructionText }) }) : null,
687
688
  /* @__PURE__ */ jsx(Button, { variant: "muted", onClick: () => setExpanded((wasExpanded) => !wasExpanded), children: expanded ? "Hide task instruction" : "Show task instruction" })
688
689
  ] });
689
690
  };
690
691
  const responseContainer = "agents_responseContainer_DP5-nh";
691
692
  const thinkingMessage = "agents_thinkingMessage_8Z3pN0";
692
693
  const thinkingDots = "agents_thinkingDots_9rZMzX";
693
- const styles$9 = {
694
+ const styles$a = {
694
695
  responseContainer,
695
696
  thinkingMessage,
696
697
  thinkingDots
@@ -712,7 +713,7 @@ const ConversationMessageThinking = memo((props) => {
712
713
  }, 2500);
713
714
  return () => clearInterval(interval);
714
715
  }, []);
715
- return /* @__PURE__ */ jsxs("div", { className: styles$9.responseContainer, children: [
716
+ return /* @__PURE__ */ jsxs("div", { className: styles$a.responseContainer, children: [
716
717
  /* @__PURE__ */ jsx(
717
718
  ConversationMessageHeader,
718
719
  {
@@ -720,8 +721,8 @@ const ConversationMessageThinking = memo((props) => {
720
721
  aiPromptExtension
721
722
  }
722
723
  ),
723
- /* @__PURE__ */ jsxs("div", { className: styles$9.thinkingMessage, children: [
724
- /* @__PURE__ */ jsxs("div", { className: styles$9.thinkingDots, children: [
724
+ /* @__PURE__ */ jsxs("div", { className: styles$a.thinkingMessage, children: [
725
+ /* @__PURE__ */ jsxs("div", { className: styles$a.thinkingDots, children: [
725
726
  /* @__PURE__ */ jsx("span", {}),
726
727
  /* @__PURE__ */ jsx("span", {}),
727
728
  /* @__PURE__ */ jsx("span", {})
@@ -732,7 +733,7 @@ const ConversationMessageThinking = memo((props) => {
732
733
  });
733
734
  const errorMessageContainer = "agents_errorMessageContainer_SW0BKU";
734
735
  const errorMessageTitle = "agents_errorMessageTitle_c--G2K";
735
- const styles$8 = {
736
+ const styles$9 = {
736
737
  errorMessageContainer,
737
738
  errorMessageTitle
738
739
  };
@@ -803,9 +804,9 @@ const ConversationErrorWidget = (props) => {
803
804
  replacements: replacements2
804
805
  };
805
806
  }, [errorType, isUpSellPossible, rateLimitRetryAfterSeconds, showFairUsageMessage, canRetry]);
806
- return /* @__PURE__ */ jsxs("div", { className: styles$8.errorMessageContainer, children: [
807
+ return /* @__PURE__ */ jsxs("div", { className: styles$9.errorMessageContainer, children: [
807
808
  /* @__PURE__ */ jsxs("div", { children: [
808
- /* @__PURE__ */ jsxs("div", { className: styles$8.errorMessageTitle, children: [
809
+ /* @__PURE__ */ jsxs("div", { className: styles$9.errorMessageTitle, children: [
809
810
  /* @__PURE__ */ jsx(Icon, { name: icon }),
810
811
  /* @__PURE__ */ jsx(Text, { weight: "bold", children: title2 })
811
812
  ] }),
@@ -967,7 +968,7 @@ const ConversationMessageList = ({
967
968
  const suggestionCard = "agents_suggestionCard_mrCOnL";
968
969
  const suggestionCardButton = "agents_suggestionCardButton_Vs0fh3";
969
970
  const arrowIcon = "agents_arrowIcon_KmN-nZ";
970
- const styles$7 = {
971
+ const styles$8 = {
971
972
  suggestionCard,
972
973
  suggestionCardButton,
973
974
  arrowIcon
@@ -975,7 +976,7 @@ const styles$7 = {
975
976
  const ConversationSuggestionWidget = (props) => {
976
977
  const { suggestion, onClick, testId } = props;
977
978
  const { AssistantIconBadge } = useAgentsEnvironment();
978
- return /* @__PURE__ */ jsx(InteractiveSurface, { hoverable: true, className: classNames(styles$7.suggestionCard), testId, children: /* @__PURE__ */ jsxs("button", { type: "button", className: styles$7.suggestionCardButton, onClick, children: [
979
+ return /* @__PURE__ */ jsx(InteractiveSurface, { hoverable: true, className: classNames(styles$8.suggestionCard), testId, children: /* @__PURE__ */ jsxs("button", { type: "button", className: styles$8.suggestionCardButton, onClick, children: [
979
980
  AssistantIconBadge ? /* @__PURE__ */ jsx(
980
981
  AssistantIconBadge,
981
982
  {
@@ -988,7 +989,7 @@ const ConversationSuggestionWidget = (props) => {
988
989
  /* @__PURE__ */ jsx(Text, { role: "help", weight: "bold", color: "var(--agents-fg-on-accent)", children: suggestion.name }),
989
990
  /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-on-accent)", children: suggestion.description })
990
991
  ] }),
991
- /* @__PURE__ */ jsx(Icon, { color: "var(--agents-fg-on-accent)", className: styles$7.arrowIcon, name: "arrowRight" })
992
+ /* @__PURE__ */ jsx(Icon, { color: "var(--agents-fg-on-accent)", className: styles$8.arrowIcon, name: "arrowRight" })
992
993
  ] }) });
993
994
  };
994
995
  const ConversationIntroWidget = ({
@@ -1040,14 +1041,14 @@ const ConversationIntroWidget = ({
1040
1041
  };
1041
1042
  const scrollToLatest = "agents_scrollToLatest_j2xJO9";
1042
1043
  const visible = "agents_visible_bwj0Gp";
1043
- const styles$6 = {
1044
+ const styles$7 = {
1044
1045
  scrollToLatest,
1045
1046
  visible
1046
1047
  };
1047
1048
  const ConversationScrollToLatestMessageButton = (props) => {
1048
1049
  const { visible: visible2, onClick } = props;
1049
1050
  const texts = useAgentsTexts();
1050
- return /* @__PURE__ */ jsx("div", { className: classNames(styles$6.scrollToLatest, visible2 ? styles$6.visible : void 0), children: /* @__PURE__ */ jsx(
1051
+ return /* @__PURE__ */ jsx("div", { className: classNames(styles$7.scrollToLatest, visible2 ? styles$7.visible : void 0), children: /* @__PURE__ */ jsx(
1051
1052
  Button,
1052
1053
  {
1053
1054
  variant: "muted",
@@ -1217,7 +1218,7 @@ const ConversationViewBody = (props) => {
1217
1218
  );
1218
1219
  const { readAssistantThemeClassName, AssistantBackground } = useAgentsEnvironment();
1219
1220
  const colorPalette = useMemo(
1220
- () => currentCategory?.alias ? readAssistantThemeClassName?.(currentCategory.alias) ?? styles$f.genericChat : styles$f.genericChat,
1221
+ () => currentCategory?.alias ? readAssistantThemeClassName?.(currentCategory.alias) ?? styles$g.genericChat : styles$g.genericChat,
1221
1222
  [currentCategory, readAssistantThemeClassName]
1222
1223
  );
1223
1224
  const isMessageListVisible = !!messages && (!!conversationId || !!showMessagesWithoutConversation) || startingNewConversation || !!error && error !== ConversationErrorType.CONVERSATION_NOT_FOUND;
@@ -1422,7 +1423,7 @@ const ConversationViewBody = (props) => {
1422
1423
  const messageColumn = /* @__PURE__ */ jsxs(
1423
1424
  "div",
1424
1425
  {
1425
- className: styles$f.contentWrapper,
1426
+ className: styles$g.contentWrapper,
1426
1427
  "data-agents-chat-scroll": "",
1427
1428
  "data-testid": "chat-messages-scroll",
1428
1429
  ref: handleContentWrapperRef,
@@ -1440,11 +1441,11 @@ const ConversationViewBody = (props) => {
1440
1441
  onSuggestionClick
1441
1442
  }
1442
1443
  ) : null,
1443
- !!loadingOlder ? /* @__PURE__ */ jsx("span", { className: styles$f.olderLoading, children: /* @__PURE__ */ jsx(Text, { children: "Loading older messages…" }) }) : null,
1444
+ !!loadingOlder ? /* @__PURE__ */ jsx("span", { className: styles$g.olderLoading, children: /* @__PURE__ */ jsx(Text, { children: "Loading older messages…" }) }) : null,
1444
1445
  isMessageListVisible ? /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(WidgetWindowRootContext.Provider, { value: scrollContainer, children: /* @__PURE__ */ jsx(
1445
1446
  ConversationMessageList,
1446
1447
  {
1447
- className: enablePinQuestionAndRevealAnswer && (conversationId || startingNewConversation || aiThinking || error) ? styles$f.topAlignedMessages : void 0,
1448
+ className: enablePinQuestionAndRevealAnswer && (conversationId || startingNewConversation || aiThinking || error) ? styles$g.topAlignedMessages : void 0,
1448
1449
  messages,
1449
1450
  currentCategory,
1450
1451
  aiPromptExtension,
@@ -1472,41 +1473,41 @@ const ConversationViewBody = (props) => {
1472
1473
  "div",
1473
1474
  {
1474
1475
  className: classNames(
1475
- styles$f.chat,
1476
- background || backgroundPaintedByHost2 ? styles$f.customBg : colorPalette,
1477
- backgroundPaintedByHost2 ? styles$f.backgroundPaintedByHost : void 0,
1478
- isCompact ? styles$f.chatCompact : void 0,
1479
- confineTopBlurBandToChatPane2 ? styles$f.confineTopBlurBandToChatPane : void 0
1476
+ styles$g.chat,
1477
+ background || backgroundPaintedByHost2 ? styles$g.customBg : colorPalette,
1478
+ backgroundPaintedByHost2 ? styles$g.backgroundPaintedByHost : void 0,
1479
+ isCompact ? styles$g.chatCompact : void 0,
1480
+ confineTopBlurBandToChatPane2 ? styles$g.confineTopBlurBandToChatPane : void 0
1480
1481
  ),
1481
1482
  children: [
1482
- background ? /* @__PURE__ */ jsx("div", { className: styles$f.backgroundLayer, children: background }) : backgroundPaintedByHost2 ? null : AssistantBackground ? /* @__PURE__ */ jsx(AssistantBackground, { category: currentCategory, categoryAlias: currentCategory?.alias ?? void 0 }) : null,
1483
+ background ? /* @__PURE__ */ jsx("div", { className: styles$g.backgroundLayer, children: background }) : backgroundPaintedByHost2 ? null : AssistantBackground ? /* @__PURE__ */ jsx(AssistantBackground, { category: currentCategory, categoryAlias: currentCategory?.alias ?? void 0 }) : null,
1483
1484
  progressStepperSlot,
1484
1485
  fileDropHintSlot,
1485
- contentOverlaySlot !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$f.contentLayers, "data-overlay-shown": isContentOverlayShown || void 0, children: [
1486
+ contentOverlaySlot !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$g.contentLayers, "data-overlay-shown": isContentOverlayShown || void 0, children: [
1486
1487
  messageColumn,
1487
1488
  /* @__PURE__ */ jsx(
1488
1489
  "div",
1489
1490
  {
1490
- className: styles$f.contentOverlay,
1491
+ className: styles$g.contentOverlay,
1491
1492
  "aria-hidden": !isContentOverlayShown || void 0,
1492
1493
  inert: !isContentOverlayShown || void 0,
1493
1494
  children: contentOverlaySlot
1494
1495
  }
1495
1496
  )
1496
1497
  ] }) : messageColumn,
1497
- enablePinQuestionAndRevealAnswer && /* @__PURE__ */ jsx("div", { className: styles$f.scrollToLatestAnchor, children: /* @__PURE__ */ jsx(
1498
+ enablePinQuestionAndRevealAnswer && /* @__PURE__ */ jsx("div", { className: styles$g.scrollToLatestAnchor, children: /* @__PURE__ */ jsx(
1498
1499
  ConversationScrollToLatestMessageButton,
1499
1500
  {
1500
1501
  visible: isMessagesBottomOutOfView,
1501
1502
  onClick: scrollToLatestMessage
1502
1503
  }
1503
1504
  ) }),
1504
- inputReplacementSlot ? /* @__PURE__ */ jsx("div", { className: styles$f.inputReplacement, children: inputReplacementSlot }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
1505
+ inputReplacementSlot ? /* @__PURE__ */ jsx("div", { className: styles$g.inputReplacement, children: inputReplacementSlot }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
1505
1506
  inputBandSlot,
1506
1507
  /* @__PURE__ */ jsx(
1507
1508
  ConversationMessageInput,
1508
1509
  {
1509
- className: classNames(styles$f.input, currentCategory?.alias ? styles$f.inputInCategory : void 0),
1510
+ className: classNames(styles$g.input, currentCategory?.alias ? styles$g.inputInCategory : void 0),
1510
1511
  isProcessing: allowSendWhileAiThinking ? !!startingNewConversation : aiThinking,
1511
1512
  onSendMessage,
1512
1513
  actionsSlot: inputActionsSlot,
@@ -1827,7 +1828,7 @@ const tab = "agents_tab_XzVXlj";
1827
1828
  const tabTop = "agents_tabTop_mAtOHf";
1828
1829
  const tabBottom = "agents_tabBottom_JLQcsf";
1829
1830
  const tabCircle = "agents_tabCircle_J5jxeo";
1830
- const styles$5 = {
1831
+ const styles$6 = {
1831
1832
  handle,
1832
1833
  tab,
1833
1834
  tabTop,
@@ -1841,13 +1842,13 @@ const CanvasResizeHandle = (props) => {
1841
1842
  "div",
1842
1843
  {
1843
1844
  ...handleProps,
1844
- className: styles$5.handle,
1845
+ className: styles$6.handle,
1845
1846
  "data-tab": tab2,
1846
1847
  "aria-label": translateText("Resize canvas"),
1847
- children: /* @__PURE__ */ jsxs("span", { className: styles$5.tab, style: { "--agents-resize-tab-x": `${tabX}px` }, "aria-hidden": "true", children: [
1848
- /* @__PURE__ */ jsx("span", { className: styles$5.tabCircle }),
1849
- /* @__PURE__ */ jsx("span", { className: styles$5.tabTop }),
1850
- /* @__PURE__ */ jsx("span", { className: styles$5.tabBottom })
1848
+ children: /* @__PURE__ */ jsxs("span", { className: styles$6.tab, style: { "--agents-resize-tab-x": `${tabX}px` }, "aria-hidden": "true", children: [
1849
+ /* @__PURE__ */ jsx("span", { className: styles$6.tabCircle }),
1850
+ /* @__PURE__ */ jsx("span", { className: styles$6.tabTop }),
1851
+ /* @__PURE__ */ jsx("span", { className: styles$6.tabBottom })
1851
1852
  ] })
1852
1853
  }
1853
1854
  );
@@ -1927,7 +1928,9 @@ const ConversationView = (props) => {
1927
1928
  // Centered vertically on the divider.
1928
1929
  verticalPositionPercent: 50,
1929
1930
  // The chat's own re-open control is shown: the split view adds no second one while it covers.
1930
- mainPaneShowsReopen: showsNarrowReopenControl
1931
+ mainPaneShowsReopen: showsNarrowReopenControl,
1932
+ // The canvas pane carries its own close button: no floating toggle over it while it covers the chat.
1933
+ sidePaneShowsClose: true
1931
1934
  } : void 0,
1932
1935
  main: {
1933
1936
  width: "100%",
@@ -2716,6 +2719,78 @@ const useConversationMessagePages = (chatStore, client, pageSize = CONVERSATION_
2716
2719
  [readConversationMetadata, fetchOpeningPage, refetchChangedTail, loadOlder, loadingOlder]
2717
2720
  );
2718
2721
  };
2722
+ const isTurnInitiatorMessage = (message) => {
2723
+ if (message.messageType === "ERROR" || message.messageType === "CHECKPOINT" || message.messageType === "TOOL_MESSAGE") {
2724
+ return false;
2725
+ }
2726
+ if (message.messageType === "SIGNAL") return !SIGNAL_SOURCES_THAT_OWE_NO_WORK.includes(message.signalSource ?? "");
2727
+ if (message.role !== "USER") return false;
2728
+ if (message.messageType === "TOOL_CALL") return false;
2729
+ return !(message.message ?? "").startsWith("/toolresult ");
2730
+ };
2731
+ const isAssistantAnswer = (message) => message.role === "ASSISTANT" && (message.messageType === "TEXT" || message.messageType == null) && assistantMessageHasRenderableMarkdown(message.message);
2732
+ const NO_TURN_IN_FLIGHT = { liveTurnMessageId: null, queuedMessages: [] };
2733
+ const findTurnsInFlight = (messages, isTurnRunning, namedTurnMessageId) => {
2734
+ if (!isTurnRunning || !messages?.length) return NO_TURN_IN_FLIGHT;
2735
+ let firstIndexAfterNewestAnswer = 0;
2736
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
2737
+ if (isAssistantAnswer(messages[index])) {
2738
+ firstIndexAfterNewestAnswer = index + 1;
2739
+ break;
2740
+ }
2741
+ }
2742
+ const candidates = messages.slice(firstIndexAfterNewestAnswer).filter(isTurnInitiatorMessage);
2743
+ if (candidates.length === 0 && namedTurnMessageId === null) {
2744
+ const newestInitiator = messages.slice(0, firstIndexAfterNewestAnswer).filter(isTurnInitiatorMessage).at(-1);
2745
+ return { liveTurnMessageId: typeof newestInitiator?.id === "number" ? newestInitiator.id : null, queuedMessages: [] };
2746
+ }
2747
+ const namedPosition = namedTurnMessageId === null ? -1 : candidates.findIndex((candidate) => candidate.id === namedTurnMessageId);
2748
+ const isNamedBeforeCandidates = namedTurnMessageId !== null && namedPosition === -1;
2749
+ const livePosition = isNamedBeforeCandidates ? -1 : Math.max(namedPosition, 0);
2750
+ const liveCandidate = isNamedBeforeCandidates ? void 0 : candidates[livePosition];
2751
+ const liveTurnMessageId = isNamedBeforeCandidates ? namedTurnMessageId : typeof liveCandidate?.id === "number" ? liveCandidate.id : null;
2752
+ return {
2753
+ liveTurnMessageId,
2754
+ // Only the owner's own words show as queued; a signal behind the running turn has no bubble.
2755
+ queuedMessages: candidates.slice(livePosition + 1).filter((candidate) => candidate.role === "USER" && candidate.messageType !== "SIGNAL")
2756
+ };
2757
+ };
2758
+ const QueuedMessageChip = (props) => {
2759
+ const { text, isCompact = false, wasTakenUp = false, className } = props;
2760
+ if (wasTakenUp) {
2761
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$l.queued, styles$l.queuedTakenUp, className), "data-testid": "trace-queued-message-taken-up", "data-compact": isCompact || void 0, title: text ?? void 0, children: [
2762
+ /* @__PURE__ */ jsx(Icon, { name: "stepDone", pixelSize: 12 }),
2763
+ /* @__PURE__ */ jsxs("span", { className: styles$l.queuedText, children: [
2764
+ translateText("Sent during the run"),
2765
+ isCompact ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [
2766
+ " · ",
2767
+ translateText("taken up in this turn")
2768
+ ] })
2769
+ ] })
2770
+ ] });
2771
+ }
2772
+ return /* @__PURE__ */ jsxs(
2773
+ "div",
2774
+ {
2775
+ className: classNames(styles$l.queued, !text && styles$l.queuedInThread, className),
2776
+ role: "status",
2777
+ "data-testid": "trace-queued-message",
2778
+ "data-compact": isCompact || void 0,
2779
+ children: [
2780
+ /* @__PURE__ */ jsx(Icon, { name: "stepWaiting", pixelSize: 13 }),
2781
+ /* @__PURE__ */ jsx("span", { className: styles$l.queuedText, children: text ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2782
+ translateText("Queued:"),
2783
+ " ",
2784
+ /* @__PURE__ */ jsx("span", { className: styles$l.queuedQuote, children: text }),
2785
+ isCompact ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [
2786
+ " · ",
2787
+ translateText("read at the next step")
2788
+ ] })
2789
+ ] }) : translateText("Queued · read at the next step") })
2790
+ ]
2791
+ }
2792
+ );
2793
+ };
2719
2794
  const useConversationScrollJump = (inputs) => {
2720
2795
  const {
2721
2796
  scrollTarget,
@@ -3065,6 +3140,8 @@ const AgentChatController = (props) => {
3065
3140
  AssistantAvatar,
3066
3141
  ContentOverlay,
3067
3142
  ActivityHistory,
3143
+ TurnTrace,
3144
+ showsQueuedMessages = false,
3068
3145
  children,
3069
3146
  disableSplitView = false,
3070
3147
  hostHasCanvasSurface = !disableSplitView,
@@ -3389,15 +3466,46 @@ const AgentChatController = (props) => {
3389
3466
  const startingIdeasMessage = { id: -1, role: "ASSISTANT", message: startingIdeasMarkdown, fresh: true };
3390
3467
  return [startingIdeasMessage];
3391
3468
  }, [showsStartingIdeas, startingIdeasMarkdown, messages]);
3392
- const renderActivityHistoryAfterMessage = useCallback(
3393
- (message) => ActivityHistory ? /* @__PURE__ */ jsx(
3469
+ const namedLiveTurnMessageId = activityRunning ? activityTurnMessageId ?? null : null;
3470
+ const turnsInFlight = useMemo(
3471
+ () => findTurnsInFlight(messages, isTurnRunning, namedLiveTurnMessageId),
3472
+ [messages, isTurnRunning, namedLiveTurnMessageId]
3473
+ );
3474
+ const hasTurnTraceSlot = TurnTrace !== void 0 && liveConversationId !== void 0;
3475
+ const showsKeptActivityHistory = keepActivityHistoryAfterAnswer && ActivityHistory !== void 0 && TurnTrace === void 0;
3476
+ const renderAfterMessage = useCallback(
3477
+ (message) => {
3478
+ const isQueued = turnsInFlight.queuedMessages.includes(message);
3479
+ const turnTrace = TurnTrace && liveConversationId !== void 0 && message.id != null && !isQueued && isTurnInitiatorMessage(message) ? /* @__PURE__ */ jsx(
3480
+ TurnTrace,
3481
+ {
3482
+ conversationId: liveConversationId,
3483
+ turnMessageId: message.id,
3484
+ phase: message.id === turnsInFlight.liveTurnMessageId ? "live" : "done",
3485
+ isCompact
3486
+ }
3487
+ ) : null;
3488
+ const activityHistory = showsKeptActivityHistory && ActivityHistory ? /* @__PURE__ */ jsx(
3489
+ ActivityHistory,
3490
+ {
3491
+ turn: typeof message.id === "number" ? activityHistoryByTurnMessageId.get(message.id) ?? null : null
3492
+ }
3493
+ ) : null;
3494
+ if (!isQueued) return turnTrace ?? activityHistory;
3495
+ return showsQueuedMessages ? /* @__PURE__ */ jsx(QueuedMessageChip, { isCompact }) : null;
3496
+ },
3497
+ [
3394
3498
  ActivityHistory,
3395
- {
3396
- turn: typeof message.id === "number" ? activityHistoryByTurnMessageId.get(message.id) ?? null : null
3397
- }
3398
- ) : null,
3399
- [ActivityHistory, activityHistoryByTurnMessageId]
3499
+ TurnTrace,
3500
+ activityHistoryByTurnMessageId,
3501
+ isCompact,
3502
+ liveConversationId,
3503
+ showsKeptActivityHistory,
3504
+ showsQueuedMessages,
3505
+ turnsInFlight
3506
+ ]
3400
3507
  );
3508
+ const rendersAfterMessages = hasTurnTraceSlot || showsKeptActivityHistory || showsQueuedMessages;
3401
3509
  const unansweredWidgetMessageId = useMemo(() => findUnansweredWidgetMessageId(messages ?? []), [messages]);
3402
3510
  const renderAssistantAvatar = useCallback(
3403
3511
  (message) => AssistantAvatar ? /* @__PURE__ */ jsx(AssistantAvatar, { message }) : null,
@@ -3453,7 +3561,7 @@ const AgentChatController = (props) => {
3453
3561
  aiThinking: agentActivity.active,
3454
3562
  allowSendWhileAiThinking: true,
3455
3563
  thinkingIndicator: /* @__PURE__ */ jsx(ThinkingIndicator, { ...activityProps }),
3456
- renderAfterMessage: keepActivityHistoryAfterAnswer ? renderActivityHistoryAfterMessage : void 0,
3564
+ renderAfterMessage: rendersAfterMessages ? renderAfterMessage : void 0,
3457
3565
  renderAssistantAvatar: AssistantAvatar ? renderAssistantAvatar : void 0,
3458
3566
  hideAssistantMeta: true,
3459
3567
  userMessageTheme: "dark",
@@ -3498,7 +3606,7 @@ const AgentChatController = (props) => {
3498
3606
  const chatArea = "agents_chatArea_4XiCda";
3499
3607
  const chatAreaWithTopBlurBand = "agents_chatAreaWithTopBlurBand_W-AdU0";
3500
3608
  const chatWrap = "agents_chatWrap_yS-zs5";
3501
- const styles$4 = {
3609
+ const styles$5 = {
3502
3610
  chatArea,
3503
3611
  chatAreaWithTopBlurBand,
3504
3612
  chatWrap
@@ -3517,7 +3625,7 @@ const AgentChat = (props) => {
3517
3625
  onNewConversation,
3518
3626
  inputReplacementSlot,
3519
3627
  chatAreaClassName,
3520
- chatWrapClassName = styles$4.chatWrap,
3628
+ chatWrapClassName = styles$5.chatWrap,
3521
3629
  showsTopBlurBand = false,
3522
3630
  confineTopBlurBandToChatPane: confineTopBlurBandToChatPane2 = showsTopBlurBand,
3523
3631
  ...controllerProps
@@ -3567,11 +3675,1327 @@ const AgentChat = (props) => {
3567
3675
  ThinkingIndicator,
3568
3676
  ActivityHistory,
3569
3677
  inputReplacementSlot: inputReplacementSlot ?? (isConversationRunEnded ? /* @__PURE__ */ jsx(ConversationClosedBar, {}) : void 0),
3570
- chatAreaClassName: chatAreaClassName ?? classNames(styles$4.chatArea, showsTopBlurBand ? styles$4.chatAreaWithTopBlurBand : void 0),
3678
+ chatAreaClassName: chatAreaClassName ?? classNames(styles$5.chatArea, showsTopBlurBand ? styles$5.chatAreaWithTopBlurBand : void 0),
3571
3679
  chatWrapClassName
3572
3680
  }
3573
3681
  ) });
3574
3682
  };
3683
+ const TYPE_LABELS = {
3684
+ subAgent: () => translateText("Sub-agent"),
3685
+ // The noun; the bare key is the verb of a host's button.
3686
+ schedule: () => translateText("Schedule", void 0, "task-type"),
3687
+ command: () => translateText("Command"),
3688
+ call: () => translateText("Call")
3689
+ };
3690
+ const BackgroundTasksList = (props) => {
3691
+ const { tasks, title: title2, onOpenTask, headerActions, className } = props;
3692
+ const format = useTraceFormat();
3693
+ const runningCount = tasks.filter((task) => task.state === "running").length;
3694
+ const now = useTraceNow(runningCount > 0);
3695
+ const describeTime = (task) => {
3696
+ const startedAt = readTraceMoment(task.startedAt);
3697
+ if (task.state === "running" && startedAt !== null) return formatTraceClock(now - startedAt);
3698
+ if (task.durationMs != null) return format.duration(task.durationMs);
3699
+ return readTraceStateLabel(task.state);
3700
+ };
3701
+ return /* @__PURE__ */ jsxs("div", { className: classNames(agentStyles.tasks, className), "data-testid": "trace-background-tasks", children: [
3702
+ /* @__PURE__ */ jsxs("div", { className: agentStyles.tasksHead, children: [
3703
+ /* @__PURE__ */ jsx("span", { className: agentStyles.tasksTitle, children: title2 || translateText("Background tasks") }),
3704
+ runningCount > 0 ? /* @__PURE__ */ jsx("span", { className: agentStyles.quiet, children: translateText("%count% running", { count: format.number(runningCount) }) }) : null,
3705
+ headerActions
3706
+ ] }),
3707
+ tasks.length === 0 ? /* @__PURE__ */ jsx("div", { className: agentStyles.tasksEmpty, children: translateText("Nothing runs in the background.") }) : /* @__PURE__ */ jsx("ul", { className: agentStyles.tasksList, children: tasks.map((task) => {
3708
+ const content2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
3709
+ /* @__PURE__ */ jsx("span", { className: agentStyles.taskState, children: /* @__PURE__ */ jsx(TraceStateIcon, { state: task.state }) }),
3710
+ /* @__PURE__ */ jsxs("span", { className: agentStyles.taskTexts, children: [
3711
+ /* @__PURE__ */ jsx("span", { className: agentStyles.taskTitle, title: task.title, children: task.title }),
3712
+ task.detail ? /* @__PURE__ */ jsx("span", { className: agentStyles.taskDetail, title: task.detail, children: task.detail }) : null
3713
+ ] }),
3714
+ /* @__PURE__ */ jsx("span", { className: agentStyles.weight, children: describeTime(task) }),
3715
+ /* @__PURE__ */ jsx("span", { className: agentStyles.taskType, children: task.typeLabel || TYPE_LABELS[task.type]() })
3716
+ ] });
3717
+ return /* @__PURE__ */ jsx("li", { "data-task-state": task.state, "data-task-type": task.type, children: onOpenTask ? /* @__PURE__ */ jsx("button", { type: "button", className: classNames(agentStyles.task, agentStyles.taskInteractive), onClick: () => onOpenTask(task), children: content2 }) : /* @__PURE__ */ jsx("div", { className: agentStyles.task, children: content2 }) }, task.key);
3718
+ }) })
3719
+ ] });
3720
+ };
3721
+ const OPERATION_CLASS_NAMES = {
3722
+ ADDED: styles$m.operationAdded,
3723
+ MODIFIED: styles$m.operationModified,
3724
+ DELETED: styles$m.operationDeleted,
3725
+ RENAMED: styles$m.operationRenamed
3726
+ };
3727
+ const ChangedFilesPane = (props) => {
3728
+ const {
3729
+ fileChanges,
3730
+ selectedIndex,
3731
+ onSelectedIndexChange,
3732
+ defaultSelectedIndex = 0,
3733
+ title: title2,
3734
+ headerActions,
3735
+ renderThumbnail,
3736
+ canOpenInViewer,
3737
+ buildSandboxHref,
3738
+ linkComponent,
3739
+ className,
3740
+ describeMount,
3741
+ onOpenInViewer,
3742
+ ...fileEditProps
3743
+ } = props;
3744
+ const format = useTraceFormat();
3745
+ const [ownSelectedIndex, setOwnSelectedIndex] = useState(defaultSelectedIndex);
3746
+ const fileCount = new Set(fileChanges.map((fileChange) => `${fileChange.mountKind ?? ""}:${fileChange.mountName ?? ""}:${fileChange.path}`)).size;
3747
+ const shownSelectedIndex = Math.min(Math.max(selectedIndex ?? ownSelectedIndex, 0), Math.max(fileChanges.length - 1, 0));
3748
+ const selectedFileChange = fileChanges[shownSelectedIndex];
3749
+ const linesAdded = fileChanges.reduce((sum, fileChange) => sum + (fileChange.linesAdded ?? 0), 0);
3750
+ const linesRemoved = fileChanges.reduce((sum, fileChange) => sum + (fileChange.linesRemoved ?? 0), 0);
3751
+ const select = (index) => {
3752
+ setOwnSelectedIndex(index);
3753
+ onSelectedIndexChange?.(index);
3754
+ };
3755
+ const describeExtra = (fileChange) => {
3756
+ if (fileChange.linesAdded != null || fileChange.linesRemoved != null) {
3757
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3758
+ /* @__PURE__ */ jsxs("span", { className: styles$m.added, children: [
3759
+ "+",
3760
+ format.number(fileChange.linesAdded ?? 0)
3761
+ ] }),
3762
+ " ",
3763
+ /* @__PURE__ */ jsxs("span", { className: styles$m.removed, children: [
3764
+ "−",
3765
+ format.number(fileChange.linesRemoved ?? 0)
3766
+ ] })
3767
+ ] });
3768
+ }
3769
+ if (fileChange.changeType === "RENAMED" && fileChange.previousPath) return `← ${fileChange.previousPath.split("/").pop() ?? ""}`;
3770
+ if (fileChange.sizeAfter != null) return format.bytes(fileChange.sizeAfter);
3771
+ return null;
3772
+ };
3773
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$m.pane, className), "data-testid": "trace-changed-files", children: [
3774
+ /* @__PURE__ */ jsxs("div", { className: styles$m.paneHead, children: [
3775
+ title2 !== void 0 && title2 !== null ? /* @__PURE__ */ jsx("span", { className: styles$m.paneTitle, children: title2 }) : null,
3776
+ /* @__PURE__ */ jsx(FileChangesSummary, { fileCount, linesAdded, linesRemoved }),
3777
+ /* @__PURE__ */ jsx("span", { className: styles$m.grow }),
3778
+ headerActions
3779
+ ] }),
3780
+ fileChanges.length === 0 ? /* @__PURE__ */ jsx("div", { className: styles$m.paneEmpty, children: translateText("No files were changed.") }) : /* @__PURE__ */ jsx("ul", { className: styles$m.paneList, children: fileChanges.map((fileChange, index) => {
3781
+ const changeType = fileChange.changeType ?? "MODIFIED";
3782
+ const extra = describeExtra(fileChange);
3783
+ const sandboxHref = buildSandboxHref?.(fileChange) ?? null;
3784
+ return /* @__PURE__ */ jsxs("li", { className: sandboxHref !== null ? styles$m.paneFileRow : void 0, children: [
3785
+ /* @__PURE__ */ jsxs(
3786
+ "button",
3787
+ {
3788
+ type: "button",
3789
+ className: classNames(styles$m.paneFile, index === shownSelectedIndex && styles$m.paneFileOn),
3790
+ "aria-current": index === shownSelectedIndex ? "true" : void 0,
3791
+ onClick: () => select(index),
3792
+ children: [
3793
+ /* @__PURE__ */ jsx(
3794
+ "span",
3795
+ {
3796
+ className: classNames(styles$m.operation, styles$m.operationLetter, OPERATION_CLASS_NAMES[changeType]),
3797
+ title: readTraceFileChangeWord(changeType),
3798
+ "aria-label": readTraceFileChangeWord(changeType),
3799
+ children: readTraceFileChangeLetter(changeType)
3800
+ }
3801
+ ),
3802
+ /* @__PURE__ */ jsx(TracePath, { path: fileChange.path, isMonospaced: true, isRemoved: changeType === "DELETED" }),
3803
+ /* @__PURE__ */ jsx("span", { className: styles$m.grow }),
3804
+ /* @__PURE__ */ jsx(
3805
+ TraceMountChip,
3806
+ {
3807
+ mountKind: fileChange.mountKind,
3808
+ mountName: fileChange.mountName,
3809
+ driveSpaceId: fileChange.driveSpaceId,
3810
+ describeMount
3811
+ }
3812
+ ),
3813
+ extra !== null ? /* @__PURE__ */ jsx("span", { className: styles$m.paneFileExtra, children: extra }) : null
3814
+ ]
3815
+ }
3816
+ ),
3817
+ sandboxHref !== null ? (
3818
+ // Beside the row's button, never inside it: a link in a button is no valid markup.
3819
+ /* @__PURE__ */ jsx(TraceLink, { href: sandboxHref, linkComponent, className: styles$m.paneFileLink, title: translateText("Show this file in the sandbox"), children: /* @__PURE__ */ jsx(Icon, { name: "terminal", pixelSize: 13 }) })
3820
+ ) : null
3821
+ ] }, `${fileChange.id ?? index}:${fileChange.path}`);
3822
+ }) }),
3823
+ selectedFileChange ? /* @__PURE__ */ jsx("div", { className: styles$m.paneDetail, children: /* @__PURE__ */ jsx(
3824
+ FileEditBlock,
3825
+ {
3826
+ ...fileEditProps,
3827
+ fileChange: selectedFileChange,
3828
+ describeMount,
3829
+ onOpenInViewer: canOpenInViewer?.(selectedFileChange) ?? true ? onOpenInViewer : void 0,
3830
+ sandboxHref: buildSandboxHref?.(selectedFileChange) ?? null,
3831
+ linkComponent,
3832
+ thumbnail: renderThumbnail?.(selectedFileChange)
3833
+ }
3834
+ ) }) : null
3835
+ ] });
3836
+ };
3837
+ const ChangeSetCard = (props) => {
3838
+ const { title: title2, icon = "toolWrite", entity, changes, note: note2, onUndo, isUndone = false, actions: actions2, className } = props;
3839
+ const [isUndoPending, setIsUndoPending] = useState(false);
3840
+ const handleUndo = async () => {
3841
+ if (!onUndo) return;
3842
+ setIsUndoPending(true);
3843
+ try {
3844
+ await onUndo();
3845
+ } finally {
3846
+ setIsUndoPending(false);
3847
+ }
3848
+ };
3849
+ return /* @__PURE__ */ jsxs("div", { className: classNames(agentStyles.changeSet, isUndone && agentStyles.changeSetPending, className), "data-testid": "trace-change-set", "data-undone": isUndone || void 0, children: [
3850
+ /* @__PURE__ */ jsxs("div", { className: agentStyles.changeSetHead, children: [
3851
+ /* @__PURE__ */ jsx(Icon, { name: icon, pixelSize: 15, className: styles$l.rowIcon }),
3852
+ /* @__PURE__ */ jsx("span", { className: agentStyles.changeSetTitle, children: title2 }),
3853
+ entity,
3854
+ /* @__PURE__ */ jsx("span", { className: agentStyles.changeSetGrow }),
3855
+ isUndone ? /* @__PURE__ */ jsx("span", { className: styles$l.badge, children: translateText("Undone") }) : null
3856
+ ] }),
3857
+ /* @__PURE__ */ jsx("dl", { className: agentStyles.changes, children: changes.map((change, index) => {
3858
+ const hasBefore = change.before != null && change.before !== "";
3859
+ const hasAfter = change.after != null && change.after !== "";
3860
+ return /* @__PURE__ */ jsxs("div", { style: { display: "contents" }, "data-testid": "trace-change", children: [
3861
+ /* @__PURE__ */ jsx("dt", { className: agentStyles.changeName, children: change.label }),
3862
+ /* @__PURE__ */ jsx("dd", { className: classNames(agentStyles.changeValue, hasBefore ? agentStyles.changeOld : agentStyles.changeUnchanged), children: hasBefore ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
3863
+ /* @__PURE__ */ jsxs("span", { className: styles$l.visuallyHidden, children: [
3864
+ translateText("Before:"),
3865
+ " "
3866
+ ] }),
3867
+ change.before
3868
+ ] }) : "—" }),
3869
+ /* @__PURE__ */ jsx("dd", { className: classNames(agentStyles.changeValue, agentStyles.changeArrow), "aria-hidden": true, children: "→" }),
3870
+ /* @__PURE__ */ jsx("dd", { className: classNames(agentStyles.changeValue, hasAfter ? agentStyles.changeNew : agentStyles.changeUnchanged), children: hasAfter ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
3871
+ /* @__PURE__ */ jsxs("span", { className: styles$l.visuallyHidden, children: [
3872
+ translateText("After:"),
3873
+ " "
3874
+ ] }),
3875
+ change.after
3876
+ ] }) : "—" })
3877
+ ] }, change.key ?? index);
3878
+ }) }),
3879
+ note2 || onUndo || actions2 ? /* @__PURE__ */ jsxs("div", { className: agentStyles.changeSetFoot, children: [
3880
+ note2 ? /* @__PURE__ */ jsx("span", { className: agentStyles.changeSetNote, children: note2 }) : null,
3881
+ /* @__PURE__ */ jsx("span", { className: agentStyles.changeSetGrow }),
3882
+ actions2,
3883
+ onUndo && !isUndone ? /* @__PURE__ */ jsxs("button", { type: "button", className: styles$l.stopButton, disabled: isUndoPending, onClick: () => void handleUndo(), children: [
3884
+ /* @__PURE__ */ jsx(Icon, { name: "undo", pixelSize: 13 }),
3885
+ translateText("Undo")
3886
+ ] }) : null
3887
+ ] }) : null
3888
+ ] });
3889
+ };
3890
+ const plan = "agents_plan_fUk0Cn";
3891
+ const head = "agents_head_ei8NJQ";
3892
+ const title = "agents_title_5Puazk";
3893
+ const titleClamped = "agents_titleClamped_aVu5aw";
3894
+ const quiet = "agents_quiet_-57i6u";
3895
+ const grow = "agents_grow_-Ny7Qu";
3896
+ const meter = "agents_meter_GbJSox";
3897
+ const meterFill = "agents_meterFill_crRsRr";
3898
+ const items = "agents_items_5iP2dV";
3899
+ const item = "agents_item_hMmGsa";
3900
+ const itemDone = "agents_itemDone_Zx6jhT";
3901
+ const itemNext = "agents_itemNext_d9RLRd";
3902
+ const box = "agents_box_uNFF6C";
3903
+ const itemSkipped = "agents_itemSkipped_1TqmwX";
3904
+ const itemBlocked = "agents_itemBlocked_tGu3mM";
3905
+ const number = "agents_number_sa8-dA";
3906
+ const itemText = "agents_itemText_o93Of0";
3907
+ const itemLink = "agents_itemLink_sVVPi-";
3908
+ const mark = "agents_mark_6Xg7Dz";
3909
+ const markWarning = "agents_markWarning_OkUqju";
3910
+ const markDanger = "agents_markDanger_A9kQOI";
3911
+ const markDelete = "agents_markDelete_K9mc-B";
3912
+ const records = "agents_records_rAqP86";
3913
+ const recordsList = "agents_recordsList_sQDD-m";
3914
+ const record = "agents_record_vUQ52J";
3915
+ const recordQuiet = "agents_recordQuiet_z0IeDj";
3916
+ const recordHead = "agents_recordHead_cfPttG";
3917
+ const recordIcon = "agents_recordIcon_sYtEbT";
3918
+ const recordTitle = "agents_recordTitle_v7XRIp";
3919
+ const recordTime = "agents_recordTime_IGmwoU";
3920
+ const recordFoot = "agents_recordFoot_XJnrh5";
3921
+ const recordLine = "agents_recordLine_PNcw9U";
3922
+ const markCreated = "agents_markCreated_h3npcj";
3923
+ const recordChangeSets = "agents_recordChangeSets_DULh2V";
3924
+ const recordLink = "agents_recordLink_a4Fnwz";
3925
+ const note = "agents_note_1xkyAQ";
3926
+ const styles$4 = {
3927
+ plan,
3928
+ head,
3929
+ title,
3930
+ titleClamped,
3931
+ quiet,
3932
+ grow,
3933
+ meter,
3934
+ meterFill,
3935
+ items,
3936
+ item,
3937
+ itemDone,
3938
+ itemNext,
3939
+ box,
3940
+ itemSkipped,
3941
+ itemBlocked,
3942
+ number,
3943
+ itemText,
3944
+ itemLink,
3945
+ mark,
3946
+ markWarning,
3947
+ markDanger,
3948
+ markDelete,
3949
+ records,
3950
+ recordsList,
3951
+ record,
3952
+ recordQuiet,
3953
+ recordHead,
3954
+ recordIcon,
3955
+ recordTitle,
3956
+ recordTime,
3957
+ recordFoot,
3958
+ recordLine,
3959
+ markCreated,
3960
+ recordChangeSets,
3961
+ recordLink,
3962
+ note
3963
+ };
3964
+ const describeChangedFieldName = (fieldName) => fieldName.replace(/_/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").toLowerCase().trim();
3965
+ const describeChangedRecord = (tableName, recordId) => {
3966
+ const words = describeChangedFieldName(tableName);
3967
+ const label = words.charAt(0).toUpperCase() + words.slice(1);
3968
+ return recordId === null ? label : `${label} ${recordId}`;
3969
+ };
3970
+ const readRecordOperationLabel = (operation) => {
3971
+ if (operation === "CREATED") return translateText("created", void 0, "record-change");
3972
+ if (operation === "DELETED") return translateText("deleted", void 0, "record-change");
3973
+ return translateText("changed", void 0, "record-change");
3974
+ };
3975
+ const ChangedRecordsList = (props) => {
3976
+ const { records: records2, title: title2, describeEntity, buildEntityHref, buildStepHref, linkComponent, note: note2, describeRecord, className } = props;
3977
+ const format = useTraceFormat();
3978
+ if (records2.length === 0) return null;
3979
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$4.records, className), "data-testid": "trace-changed-records", children: [
3980
+ /* @__PURE__ */ jsxs("div", { className: styles$4.head, children: [
3981
+ /* @__PURE__ */ jsx("span", { className: styles$4.title, children: title2 || translateText("Records changed") }),
3982
+ /* @__PURE__ */ jsx("span", { className: styles$4.grow }),
3983
+ /* @__PURE__ */ jsx("span", { className: styles$4.quiet, children: format.number(records2.length) })
3984
+ ] }),
3985
+ /* @__PURE__ */ jsx("ul", { className: styles$4.recordsList, children: records2.map((record2) => {
3986
+ const startedAt = readTraceMoment(record2.startedAt);
3987
+ const words = record2.toolNameInWords || record2.toolName || translateText("Used a tool");
3988
+ const stepHref = buildStepHref?.(record2) ?? null;
3989
+ const chips = record2.entityReferences.map((reference) => {
3990
+ const description = describeEntity?.(reference) ?? null;
3991
+ if (description === null) return null;
3992
+ return /* @__PURE__ */ jsx(
3993
+ EntityChip,
3994
+ {
3995
+ label: description.label,
3996
+ icon: description.icon,
3997
+ href: description.href,
3998
+ argumentName: reference.argumentName,
3999
+ id: reference.id,
4000
+ buildEntityHref,
4001
+ linkComponent
4002
+ },
4003
+ `${reference.argumentName}:${reference.id}`
4004
+ );
4005
+ }).filter((chip) => chip !== null);
4006
+ const isQuiet = record2.state === "failed" || record2.state === "waiting" || record2.state === "cancelled";
4007
+ return /* @__PURE__ */ jsxs(
4008
+ "li",
4009
+ {
4010
+ className: classNames(styles$4.record, isQuiet && styles$4.recordQuiet),
4011
+ "data-record-effect": record2.effect,
4012
+ "data-record-state": record2.state,
4013
+ children: [
4014
+ /* @__PURE__ */ jsxs("div", { className: styles$4.recordHead, children: [
4015
+ /* @__PURE__ */ jsx(Icon, { name: record2.effect === "DELETE" ? "trash" : "toolWrite", pixelSize: 14, className: styles$4.recordIcon }),
4016
+ /* @__PURE__ */ jsx("span", { className: styles$4.recordTitle, title: record2.toolName ?? void 0, children: words }),
4017
+ record2.effect === "DELETE" ? /* @__PURE__ */ jsx("span", { className: classNames(styles$4.mark, styles$4.markDelete), children: translateText("deletes data", void 0, "tool-effect") }) : null,
4018
+ record2.state === "waiting" ? /* @__PURE__ */ jsx("span", { className: classNames(styles$4.mark, styles$4.markWarning), children: translateText("waits for approval") }) : null,
4019
+ record2.state === "failed" ? /* @__PURE__ */ jsx("span", { className: classNames(styles$4.mark, styles$4.markDanger), children: readTraceStateLabel("failed") }) : null,
4020
+ record2.state === "running" || record2.state === "cancelled" ? /* @__PURE__ */ jsx("span", { className: styles$4.mark, children: readTraceStateLabel(record2.state) }) : null,
4021
+ /* @__PURE__ */ jsx("span", { className: styles$4.grow }),
4022
+ startedAt !== null ? /* @__PURE__ */ jsx("span", { className: styles$4.recordTime, children: format.time(startedAt) }) : null
4023
+ ] }),
4024
+ record2.line && record2.line !== words ? /* @__PURE__ */ jsx("div", { className: styles$4.recordLine, children: record2.line }) : null,
4025
+ record2.recordChanges.length > 0 || record2.omittedRecordChangeCount > 0 ? /* @__PURE__ */ jsxs("div", { className: styles$4.recordChangeSets, children: [
4026
+ record2.recordChanges.map((recordChange, recordIndex) => /* @__PURE__ */ jsx(
4027
+ ChangeSetCard,
4028
+ {
4029
+ title: describeRecord?.(recordChange.tableName, recordChange.recordId) ?? describeChangedRecord(recordChange.tableName, recordChange.recordId),
4030
+ icon: recordChange.operation === "DELETED" ? "trash" : "toolWrite",
4031
+ entity: /* @__PURE__ */ jsx(
4032
+ "span",
4033
+ {
4034
+ className: classNames(
4035
+ styles$4.mark,
4036
+ recordChange.operation === "CREATED" && styles$4.markCreated,
4037
+ recordChange.operation === "DELETED" && styles$4.markDelete
4038
+ ),
4039
+ children: readRecordOperationLabel(recordChange.operation)
4040
+ }
4041
+ ),
4042
+ changes: recordChange.fieldChanges.map((fieldChange) => ({
4043
+ key: fieldChange.fieldName,
4044
+ label: describeChangedFieldName(fieldChange.fieldName),
4045
+ before: fieldChange.before,
4046
+ after: fieldChange.after
4047
+ })),
4048
+ note: recordChange.omittedFieldCount > 0 ? translateText("%count% more fields", { count: format.number(recordChange.omittedFieldCount) }) : void 0
4049
+ },
4050
+ `${recordChange.tableName}:${recordChange.recordId ?? `new-${recordIndex}`}`
4051
+ )),
4052
+ record2.omittedRecordChangeCount > 0 ? /* @__PURE__ */ jsx("span", { className: styles$4.recordLine, children: translateText("%count% more records", { count: format.number(record2.omittedRecordChangeCount) }) }) : null
4053
+ ] }) : null,
4054
+ chips.length > 0 || stepHref !== null ? /* @__PURE__ */ jsxs("div", { className: styles$4.recordFoot, children: [
4055
+ chips,
4056
+ stepHref !== null ? /* @__PURE__ */ jsxs(TraceLink, { href: stepHref, linkComponent, className: styles$4.recordLink, title: translateText("Open this step in the analysis"), children: [
4057
+ /* @__PURE__ */ jsx(Icon, { name: "external", pixelSize: 12 }),
4058
+ translateText("Open in analysis")
4059
+ ] }) : null
4060
+ ] }) : null
4061
+ ]
4062
+ },
4063
+ record2.key
4064
+ );
4065
+ }) }),
4066
+ note2 ? /* @__PURE__ */ jsx("p", { className: styles$4.note, children: note2 }) : null
4067
+ ] });
4068
+ };
4069
+ const ContextRing = (props) => {
4070
+ const { percent, usedTokens, contextWindowTokens, showsPercent = true, size = 26, onClick, className } = props;
4071
+ const format = useTraceFormat();
4072
+ const shownPercent = Math.round(Math.min(100, Math.max(0, Number.isFinite(percent) ? percent : 0)));
4073
+ const strokeWidth = Math.max(3, Math.round(size / 7));
4074
+ const radius = (size - strokeWidth) / 2;
4075
+ const circumference = 2 * Math.PI * radius;
4076
+ const label = usedTokens != null && contextWindowTokens != null ? translateText("Context %percent% % full (%used% of %total% tokens)", {
4077
+ percent: shownPercent,
4078
+ used: format.count(usedTokens),
4079
+ total: format.count(contextWindowTokens)
4080
+ }) : translateText("Context %percent% % full", { percent: shownPercent });
4081
+ const content2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
4082
+ /* @__PURE__ */ jsxs("svg", { className: styles$l.ringSvg, width: size, height: size, viewBox: `0 0 ${size} ${size}`, "aria-hidden": true, children: [
4083
+ /* @__PURE__ */ jsx("circle", { className: styles$l.ringTrack, cx: size / 2, cy: size / 2, r: radius, strokeWidth }),
4084
+ /* @__PURE__ */ jsx(
4085
+ "circle",
4086
+ {
4087
+ className: classNames(styles$l.ringArc, shownPercent >= 95 ? styles$l.ringArcFull : shownPercent >= 80 && styles$l.ringArcHigh),
4088
+ cx: size / 2,
4089
+ cy: size / 2,
4090
+ r: radius,
4091
+ strokeWidth,
4092
+ strokeDasharray: `${circumference * shownPercent / 100} ${circumference}`
4093
+ }
4094
+ )
4095
+ ] }),
4096
+ showsPercent ? /* @__PURE__ */ jsxs("span", { "aria-hidden": true, children: [
4097
+ shownPercent,
4098
+ " %"
4099
+ ] }) : null
4100
+ ] });
4101
+ if (onClick) {
4102
+ return /* @__PURE__ */ jsx(
4103
+ "button",
4104
+ {
4105
+ type: "button",
4106
+ className: classNames(styles$l.ring, styles$l.ringInteractive, className),
4107
+ "aria-label": label,
4108
+ title: label,
4109
+ onClick,
4110
+ "data-testid": "trace-context-ring",
4111
+ children: content2
4112
+ }
4113
+ );
4114
+ }
4115
+ return /* @__PURE__ */ jsx("span", { className: classNames(styles$l.ring, className), role: "img", "aria-label": label, title: label, "data-testid": "trace-context-ring", children: content2 });
4116
+ };
4117
+ const DEFAULT_PAGE_SIZE = 20;
4118
+ const DEFAULT_POLL_INTERVAL_MS = 1500;
4119
+ const EMPTY_STATE = { turns: [], status: "idle", level: null, isRunLive: false, hasOlderTurns: false, totalTurnCount: null };
4120
+ class ConversationTraceLoader {
4121
+ constructor(client, conversationId, options = {}) {
4122
+ this.client = client;
4123
+ this.conversationId = conversationId;
4124
+ this.turnsByNumber = /* @__PURE__ */ new Map();
4125
+ this.listeners = /* @__PURE__ */ new Set();
4126
+ this.wantedTurnMessageIds = /* @__PURE__ */ new Map();
4127
+ this.liveTurnMessageIds = /* @__PURE__ */ new Map();
4128
+ this.endedTurnMessageIds = /* @__PURE__ */ new Set();
4129
+ this.lookedForAtRevision = /* @__PURE__ */ new Map();
4130
+ this.state = EMPTY_STATE;
4131
+ this.newestMessageIndex = null;
4132
+ this.hasReadNewest = false;
4133
+ this.wantsNewest = false;
4134
+ this.needsFollowRead = false;
4135
+ this.isReading = false;
4136
+ this.isPumpScheduled = false;
4137
+ this.revision = 0;
4138
+ this.failedAtRevision = null;
4139
+ this.conversationRevision = null;
4140
+ this.followerCount = 0;
4141
+ this.pollTimer = null;
4142
+ this.pollIntervalMs = DEFAULT_POLL_INTERVAL_MS;
4143
+ this.subscribe = (listener) => {
4144
+ this.listeners.add(listener);
4145
+ return () => {
4146
+ this.listeners.delete(listener);
4147
+ };
4148
+ };
4149
+ this.getState = () => this.state;
4150
+ this.level = options.level ?? "STEPS";
4151
+ this.pageSize = Math.max(1, options.pageSize ?? DEFAULT_PAGE_SIZE);
4152
+ }
4153
+ /** The turn a message started, when it was read. */
4154
+ findTurn(turnMessageId) {
4155
+ for (const turn of this.turnsByNumber.values()) {
4156
+ if (turn.turnMessageId === turnMessageId) return turn;
4157
+ }
4158
+ return null;
4159
+ }
4160
+ /**
4161
+ * A component shows the turn of this message: the loader reads until it holds the turn or knows the message started
4162
+ * none. Returns the release (the component is gone).
4163
+ */
4164
+ requestTurn(turnMessageId) {
4165
+ this.wantedTurnMessageIds.set(turnMessageId, (this.wantedTurnMessageIds.get(turnMessageId) ?? 0) + 1);
4166
+ this.schedulePump();
4167
+ return () => {
4168
+ const remaining = (this.wantedTurnMessageIds.get(turnMessageId) ?? 1) - 1;
4169
+ if (remaining > 0) this.wantedTurnMessageIds.set(turnMessageId, remaining);
4170
+ else {
4171
+ this.wantedTurnMessageIds.delete(turnMessageId);
4172
+ this.lookedForAtRevision.delete(turnMessageId);
4173
+ }
4174
+ };
4175
+ }
4176
+ /** A component shows the conversation's newest turns (a pane, a sub-agent's trace): the newest window is read. */
4177
+ requestNewestTurns() {
4178
+ this.wantsNewest = true;
4179
+ this.schedulePump();
4180
+ }
4181
+ /**
4182
+ * The turn of this message runs: the loader follows it with a read of the changed turns every `pollIntervalMs` until
4183
+ * the returned function is called (the turn ended), then reads it once more for its final figures.
4184
+ */
4185
+ followLiveTurn(turnMessageId, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS) {
4186
+ this.liveTurnMessageIds.set(turnMessageId, (this.liveTurnMessageIds.get(turnMessageId) ?? 0) + 1);
4187
+ const stopFollowing = this.followChanges(pollIntervalMs);
4188
+ return () => {
4189
+ const remaining = (this.liveTurnMessageIds.get(turnMessageId) ?? 1) - 1;
4190
+ if (remaining > 0) this.liveTurnMessageIds.set(turnMessageId, remaining);
4191
+ else {
4192
+ this.liveTurnMessageIds.delete(turnMessageId);
4193
+ this.endedTurnMessageIds.add(turnMessageId);
4194
+ }
4195
+ stopFollowing();
4196
+ };
4197
+ }
4198
+ /**
4199
+ * Reads the changed turns every `pollIntervalMs` until the returned function is called, then once more: for a
4200
+ * component that shows a conversation while it runs without naming a turn (a sub-agent's trace).
4201
+ */
4202
+ followChanges(pollIntervalMs = DEFAULT_POLL_INTERVAL_MS) {
4203
+ this.followerCount += 1;
4204
+ this.pollIntervalMs = Math.max(250, pollIntervalMs);
4205
+ this.startPolling();
4206
+ this.noteChange();
4207
+ let isReleased = false;
4208
+ return () => {
4209
+ if (isReleased) return;
4210
+ isReleased = true;
4211
+ this.followerCount -= 1;
4212
+ if (this.followerCount <= 0) this.stopPolling();
4213
+ this.noteChange();
4214
+ };
4215
+ }
4216
+ /**
4217
+ * Tells the loader where the conversation stands (a value that changes with every new message, e.g. its message
4218
+ * count and newest id). A changed value makes the loader read the changed turns.
4219
+ */
4220
+ noteConversationRevision(conversationRevision) {
4221
+ if (this.conversationRevision === conversationRevision) return;
4222
+ const isFirst = this.conversationRevision === null;
4223
+ this.conversationRevision = conversationRevision;
4224
+ if (!isFirst) this.noteChange();
4225
+ }
4226
+ /** Reads the changed turns now (the stop of a turn was accepted, a diff was stored). */
4227
+ refresh() {
4228
+ this.noteChange();
4229
+ }
4230
+ /** Stops the loader's timer; the turns it holds stay readable. */
4231
+ dispose() {
4232
+ this.stopPolling();
4233
+ this.listeners.clear();
4234
+ }
4235
+ noteChange() {
4236
+ this.revision += 1;
4237
+ if (this.hasReadNewest) this.needsFollowRead = true;
4238
+ this.schedulePump();
4239
+ }
4240
+ startPolling() {
4241
+ this.stopPolling();
4242
+ this.pollTimer = setInterval(() => this.noteChange(), this.pollIntervalMs);
4243
+ }
4244
+ stopPolling() {
4245
+ if (this.pollTimer !== null) clearInterval(this.pollTimer);
4246
+ this.pollTimer = null;
4247
+ }
4248
+ /** Every request of one tick becomes one decision: the components of a thread mount together. */
4249
+ schedulePump() {
4250
+ if (this.isPumpScheduled) return;
4251
+ this.isPumpScheduled = true;
4252
+ queueMicrotask(() => {
4253
+ this.isPumpScheduled = false;
4254
+ this.pump();
4255
+ });
4256
+ }
4257
+ pump() {
4258
+ if (this.isReading) return;
4259
+ const read = this.chooseNextRead();
4260
+ if (read === null) return;
4261
+ this.isReading = true;
4262
+ if (!this.hasReadNewest) this.publish({ status: "loading" });
4263
+ const revisionAtStart = this.revision;
4264
+ void this.runRead(read).then(
4265
+ (traces) => {
4266
+ this.failedAtRevision = null;
4267
+ this.acceptRead(read, traces);
4268
+ },
4269
+ () => {
4270
+ this.failedAtRevision = revisionAtStart;
4271
+ if (read.kind === "follow") this.needsFollowRead = false;
4272
+ if (!this.hasReadNewest) this.publish({ status: "failed" });
4273
+ }
4274
+ ).finally(() => {
4275
+ this.isReading = false;
4276
+ this.pump();
4277
+ });
4278
+ }
4279
+ runRead(read) {
4280
+ const getTurnTraces = this.client.getTurnTraces;
4281
+ if (!getTurnTraces) return Promise.reject(new Error("The conversation client reads no turn traces."));
4282
+ if (read.kind === "newest") return getTurnTraces(this.conversationId, { level: this.level, limit: this.pageSize });
4283
+ if (read.kind === "follow") return getTurnTraces(this.conversationId, { level: this.level, afterMessageIndex: read.afterMessageIndex });
4284
+ return getTurnTraces(this.conversationId, { level: this.level, fromTurnNumber: read.fromTurnNumber, limit: read.limit });
4285
+ }
4286
+ /** The one read to run next, or null when the loader holds everything that is wanted. */
4287
+ chooseNextRead() {
4288
+ if (this.failedAtRevision !== null && this.failedAtRevision === this.revision) return null;
4289
+ const hasWishes = this.wantedTurnMessageIds.size > 0 || this.wantsNewest || this.followerCount > 0;
4290
+ if (!this.hasReadNewest) return hasWishes ? { kind: "newest" } : null;
4291
+ const sortedTurns = this.state.turns;
4292
+ const initiatorIds = sortedTurns.map((turn) => turn.turnMessageId).filter((id) => id !== null);
4293
+ const newestInitiatorId = initiatorIds.length > 0 ? initiatorIds[initiatorIds.length - 1] : null;
4294
+ const oldestInitiatorId = initiatorIds.length > 0 ? initiatorIds[0] : null;
4295
+ const oldestTurnNumber = sortedTurns.length > 0 ? sortedTurns[0].turnNumber : null;
4296
+ let smallestMissingOlderId = null;
4297
+ for (const turnMessageId of this.wantedTurnMessageIds.keys()) {
4298
+ if (this.findTurn(turnMessageId) !== null) continue;
4299
+ if (newestInitiatorId === null || turnMessageId > newestInitiatorId) {
4300
+ if (this.lookedForAtRevision.get(turnMessageId) !== this.revision) {
4301
+ this.lookedForAtRevision.set(turnMessageId, this.revision);
4302
+ this.needsFollowRead = true;
4303
+ }
4304
+ } else if (oldestInitiatorId !== null && turnMessageId < oldestInitiatorId && this.state.hasOlderTurns) {
4305
+ smallestMissingOlderId = smallestMissingOlderId === null ? turnMessageId : Math.min(smallestMissingOlderId, turnMessageId);
4306
+ }
4307
+ }
4308
+ if (this.needsFollowRead) {
4309
+ const afterMessageIndex = this.readFollowPosition();
4310
+ return afterMessageIndex === null ? { kind: "newest" } : { kind: "follow", afterMessageIndex };
4311
+ }
4312
+ if (smallestMissingOlderId !== null && oldestTurnNumber !== null && oldestTurnNumber > 1) {
4313
+ const fromTurnNumber = Math.max(1, oldestTurnNumber - this.pageSize);
4314
+ return { kind: "older", fromTurnNumber, limit: oldestTurnNumber - fromTurnNumber };
4315
+ }
4316
+ return null;
4317
+ }
4318
+ /**
4319
+ * The position a follow read asks after: the newest row read, moved back before the first row of every turn that
4320
+ * runs or just ended, so those turns come back whole (a step's status changes without a new row).
4321
+ */
4322
+ readFollowPosition() {
4323
+ if (this.newestMessageIndex === null) return null;
4324
+ let position = this.newestMessageIndex;
4325
+ for (const turn of this.turnsByNumber.values()) {
4326
+ const isFollowed = turn.isRunning || turn.turnMessageId !== null && (this.liveTurnMessageIds.has(turn.turnMessageId) || this.endedTurnMessageIds.has(turn.turnMessageId));
4327
+ if (isFollowed && turn.turnMessageIndex !== null) position = Math.min(position, turn.turnMessageIndex - 1);
4328
+ }
4329
+ return position;
4330
+ }
4331
+ /**
4332
+ * Whether turns older than the held ones exist after `traces` was read. Only a page read knows (the newest page, a
4333
+ * page of older turns), and only the page that reaches back at least as far as the oldest held turn decides; a
4334
+ * follow-up read is no page and leaves the fact as it is.
4335
+ */
4336
+ readHasOlderTurns(read, traces) {
4337
+ if (read.kind === "follow") return this.state.hasOlderTurns;
4338
+ const oldestHeldTurnNumber = this.state.turns.length > 0 ? this.state.turns[0].turnNumber : null;
4339
+ const firstTurnNumberOfPage = traces.firstTurnNumber ?? (traces.turns.length > 0 ? traces.turns[0].turnNumber : null);
4340
+ if (oldestHeldTurnNumber === null) return traces.hasOlderTurns;
4341
+ if (firstTurnNumberOfPage === null) return this.state.hasOlderTurns;
4342
+ return firstTurnNumberOfPage <= oldestHeldTurnNumber ? traces.hasOlderTurns : this.state.hasOlderTurns;
4343
+ }
4344
+ acceptRead(read, traces) {
4345
+ let hasChanged = !this.hasReadNewest;
4346
+ const hasOlderTurns = this.readHasOlderTurns(read, traces);
4347
+ const totalTurnCount = traces.totalTurnCount ?? this.state.totalTurnCount;
4348
+ if (read.kind !== "older") {
4349
+ this.hasReadNewest = true;
4350
+ this.needsFollowRead = false;
4351
+ this.endedTurnMessageIds.clear();
4352
+ if (traces.newestMessageIndex !== null) this.newestMessageIndex = traces.newestMessageIndex;
4353
+ }
4354
+ for (const turn of traces.turns) {
4355
+ const heldTurn = this.turnsByNumber.get(turn.turnNumber);
4356
+ if (heldTurn !== void 0 && JSON.stringify(heldTurn) === JSON.stringify(turn)) continue;
4357
+ this.turnsByNumber.set(turn.turnNumber, turn);
4358
+ hasChanged = true;
4359
+ }
4360
+ const isRunLive = read.kind === "older" ? this.state.isRunLive : traces.isRunLive;
4361
+ const level = traces.level;
4362
+ if (!hasChanged && isRunLive === this.state.isRunLive && level === this.state.level && hasOlderTurns === this.state.hasOlderTurns && totalTurnCount === this.state.totalTurnCount && this.state.status === "ready") {
4363
+ return;
4364
+ }
4365
+ const turns = [...this.turnsByNumber.values()].sort((first, second) => first.turnNumber - second.turnNumber);
4366
+ this.publish({ turns, status: "ready", level, isRunLive, hasOlderTurns, totalTurnCount });
4367
+ }
4368
+ publish(change) {
4369
+ this.state = { ...this.state, ...change };
4370
+ for (const listener of [...this.listeners]) listener();
4371
+ }
4372
+ }
4373
+ const loadersByClient = /* @__PURE__ */ new WeakMap();
4374
+ const getConversationTraceLoader = (client, conversationId, options = {}) => {
4375
+ let loaders = loadersByClient.get(client);
4376
+ if (loaders === void 0) {
4377
+ loaders = /* @__PURE__ */ new Map();
4378
+ loadersByClient.set(client, loaders);
4379
+ }
4380
+ const key = `${conversationId}:${options.level ?? "STEPS"}:${options.pageSize ?? DEFAULT_PAGE_SIZE}`;
4381
+ let loader = loaders.get(key);
4382
+ if (loader === void 0) {
4383
+ loader = new ConversationTraceLoader(client, conversationId, options);
4384
+ loaders.set(key, loader);
4385
+ }
4386
+ return loader;
4387
+ };
4388
+ const releaseConversationTraceLoaders = (client) => {
4389
+ const loaders = loadersByClient.get(client);
4390
+ if (loaders === void 0) return;
4391
+ for (const loader of loaders.values()) loader.dispose();
4392
+ loadersByClient.delete(client);
4393
+ };
4394
+ const selectConversationRevision = (state) => {
4395
+ const messages = state.messages ?? [];
4396
+ return `${messages.length}:${messages[messages.length - 1]?.id ?? ""}`;
4397
+ };
4398
+ const useConversationTraceRevision = (conversationRevision) => {
4399
+ const chatStore = useOptionalAgentsChatStore();
4400
+ const storeRevision = useAgentsChatSelector(chatStore, selectConversationRevision, "");
4401
+ if (conversationRevision !== void 0 && conversationRevision !== null) return conversationRevision;
4402
+ return chatStore === null ? null : storeRevision;
4403
+ };
4404
+ const useConversationTurnTrace = (options) => {
4405
+ const { client, conversationId, turnMessageId, level, isLive, pollIntervalMs } = options;
4406
+ const loader = useMemo(() => getConversationTraceLoader(client, conversationId, { level }), [client, conversationId, level]);
4407
+ const state = useSyncExternalStore(loader.subscribe, loader.getState, loader.getState);
4408
+ const conversationRevision = useConversationTraceRevision(options.conversationRevision);
4409
+ useEffect(() => {
4410
+ if (conversationRevision !== null) loader.noteConversationRevision(conversationRevision);
4411
+ }, [loader, conversationRevision]);
4412
+ useEffect(() => turnMessageId === null ? void 0 : loader.requestTurn(turnMessageId), [loader, turnMessageId]);
4413
+ useEffect(
4414
+ () => turnMessageId === null || !isLive ? void 0 : loader.followLiveTurn(turnMessageId, pollIntervalMs),
4415
+ [loader, turnMessageId, isLive, pollIntervalMs]
4416
+ );
4417
+ const turn = useMemo(() => turnMessageId === null ? null : loader.findTurn(turnMessageId), [loader, turnMessageId, state]);
4418
+ return { turn, state, refresh: () => loader.refresh() };
4419
+ };
4420
+ const NO_TRACE_STATE = { turns: [], status: "idle", level: null, isRunLive: false, hasOlderTurns: false, totalTurnCount: null };
4421
+ const subscribeToNothing = () => () => void 0;
4422
+ const readNoTraceState = () => NO_TRACE_STATE;
4423
+ const useConversationTraces = (options) => {
4424
+ const { client, conversationId, level, followsWhileLive = false, pollIntervalMs } = options;
4425
+ const loader = useMemo(
4426
+ () => conversationId === null ? null : getConversationTraceLoader(client, conversationId, { level }),
4427
+ [client, conversationId, level]
4428
+ );
4429
+ const state = useSyncExternalStore(loader?.subscribe ?? subscribeToNothing, loader?.getState ?? readNoTraceState, loader?.getState ?? readNoTraceState);
4430
+ const conversationRevision = useConversationTraceRevision(options.conversationRevision);
4431
+ useEffect(() => loader?.requestNewestTurns(), [loader]);
4432
+ useEffect(() => {
4433
+ if (loader !== null && conversationRevision !== null) loader.noteConversationRevision(conversationRevision);
4434
+ }, [loader, conversationRevision]);
4435
+ const isFollowing = followsWhileLive && state.isRunLive;
4436
+ useEffect(() => loader !== null && isFollowing ? loader.followChanges(pollIntervalMs) : void 0, [loader, isFollowing, pollIntervalMs]);
4437
+ return state;
4438
+ };
4439
+ const ConversationChildTrace = (props) => {
4440
+ const { client, conversationId, viewMode = "normal", host, isCompact = false, pollIntervalMs } = props;
4441
+ const state = useConversationTraces({
4442
+ client,
4443
+ conversationId,
4444
+ level: viewMode === "verbose" ? "DEBUG" : "STEPS",
4445
+ followsWhileLive: true,
4446
+ pollIntervalMs
4447
+ });
4448
+ if (state.status === "idle" || state.status === "loading") {
4449
+ return /* @__PURE__ */ jsx("div", { className: agentStyles.quiet, children: translateText("Loading the steps…") });
4450
+ }
4451
+ if (state.status === "failed") return null;
4452
+ const rows = state.turns.flatMap(
4453
+ (turn) => selectVisibleTraceSteps(turn.steps, viewMode === "summary" ? "normal" : viewMode).map((step) => ({ key: `${turn.turnNumber}:${step.key}`, step }))
4454
+ );
4455
+ if (rows.length === 0) {
4456
+ return /* @__PURE__ */ jsx("div", { className: agentStyles.quiet, children: state.isRunLive ? translateText("No steps so far.") : translateText("This run recorded no steps.") });
4457
+ }
4458
+ return /* @__PURE__ */ jsx("div", { className: classNames(styles$l.steps, isCompact && styles$l.compact), "data-testid": "trace-child-steps", children: rows.map((row) => /* @__PURE__ */ jsx(
4459
+ TraceStepRow,
4460
+ {
4461
+ step: row.step,
4462
+ viewMode: viewMode === "summary" ? "normal" : viewMode,
4463
+ host,
4464
+ conversationId,
4465
+ isCompact
4466
+ },
4467
+ row.key
4468
+ )) });
4469
+ };
4470
+ const ConsentRequestCard = (props) => {
4471
+ const { conversationId, turnMessageId, calls, isCompact = false } = props;
4472
+ const widgetContext = useConversationWidgetContext();
4473
+ const [sentAnswer, setSentAnswer] = useState(null);
4474
+ if (calls.length === 0 || widgetContext.conversationId !== conversationId) return null;
4475
+ const messages = widgetContext.messages ?? [];
4476
+ const turnPosition = messages.findIndex((message) => message.id === turnMessageId);
4477
+ const isAnswered = turnPosition >= 0 && messages.slice(turnPosition + 1).some((message) => message.role === "USER" && message.messageType !== "SIGNAL");
4478
+ if (isAnswered && sentAnswer === null) return null;
4479
+ const answer = (choice) => {
4480
+ if (sentAnswer !== null) return;
4481
+ setSentAnswer(choice);
4482
+ void widgetContext.sendMessageToChat(
4483
+ choice === "yes" ? translateText("Yes, I explicitly approve this step, exactly as you described it.") : translateText("No, please don't run this step.")
4484
+ );
4485
+ };
4486
+ const heading = calls.length === 1 ? translateText("Approve: %action%?", { action: calls[0].title }) : translateText("Approve %count% actions?", { count: calls.length });
4487
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$l.consentCard, isCompact && styles$l.consentCardCompact), "data-testid": "trace-consent-request", children: [
4488
+ /* @__PURE__ */ jsxs("div", { className: styles$l.consentHead, children: [
4489
+ /* @__PURE__ */ jsx(Icon, { name: "stepWaiting", pixelSize: 14 }),
4490
+ /* @__PURE__ */ jsx("span", { className: styles$l.consentTitle, children: heading }),
4491
+ /* @__PURE__ */ jsx("span", { className: classNames(styles$l.badge, styles$l.badgeWarning), children: translateText("waits for you") })
4492
+ ] }),
4493
+ calls.some((call) => call.line) ? /* @__PURE__ */ jsx("ul", { className: styles$l.consentCalls, children: calls.map((call, position) => (
4494
+ // biome-ignore lint/suspicious/noArrayIndexKey: the calls of one turn keep their order
4495
+ /* @__PURE__ */ jsxs("li", { children: [
4496
+ calls.length > 1 ? /* @__PURE__ */ jsxs("b", { children: [
4497
+ call.title,
4498
+ ": "
4499
+ ] }) : null,
4500
+ call.line
4501
+ ] }, position)
4502
+ )) }) : null,
4503
+ /* @__PURE__ */ jsxs("div", { className: styles$l.consentActions, children: [
4504
+ /* @__PURE__ */ jsx("button", { type: "button", className: styles$l.consentApprove, disabled: sentAnswer !== null, onClick: () => answer("yes"), children: translateText("Approve") }),
4505
+ /* @__PURE__ */ jsx("button", { type: "button", className: styles$l.consentDecline, disabled: sentAnswer !== null, onClick: () => answer("no"), children: translateText("Don't run it") }),
4506
+ /* @__PURE__ */ jsx("span", { className: styles$l.consentNote, children: sentAnswer === null ? translateText("Runs only after your approval.") : translateText("Your answer was sent.") })
4507
+ ] })
4508
+ ] });
4509
+ };
4510
+ const RunStatusLine = (props) => {
4511
+ const { startedAt, statusText, viewMode = "normal", tokens, costInUsd, formatCost, onStop, isStopping = false, children, className } = props;
4512
+ const format = useTraceFormat();
4513
+ const now = useTraceNow(true);
4514
+ const [isStopPending, setIsStopPending] = useState(false);
4515
+ const startedAtMoment = typeof startedAt === "number" ? startedAt : readTraceMoment(startedAt);
4516
+ const showsStopping = isStopping || isStopPending;
4517
+ const figures = [
4518
+ startedAtMoment !== null ? formatTraceClock(now - startedAtMoment) : null,
4519
+ // before the first model call answers there is nothing to count: "0 tokens · $0.00" would read as a fault
4520
+ viewMode === "verbose" && tokens != null && tokens > 0 ? translateText("%count% tokens", { count: format.count(tokens) }) : null,
4521
+ viewMode === "verbose" && costInUsd != null && costInUsd > 0 ? (formatCost ?? format.cost)(costInUsd) : null
4522
+ ].filter((figure) => figure !== null);
4523
+ const handleStop = async () => {
4524
+ if (!onStop) return;
4525
+ setIsStopPending(true);
4526
+ try {
4527
+ await onStop();
4528
+ } finally {
4529
+ setIsStopPending(false);
4530
+ }
4531
+ };
4532
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$l.statusLine, className), role: "status", "data-testid": "trace-run-status", children: [
4533
+ /* @__PURE__ */ jsx("span", { className: styles$l.spinner, "aria-hidden": true }),
4534
+ /* @__PURE__ */ jsxs("span", { className: styles$l.statusText, children: [
4535
+ /* @__PURE__ */ jsx("span", { className: styles$l.statusWord, children: showsStopping ? translateText("Stopping…") : statusText ?? translateText("Working") }),
4536
+ figures.length > 0 ? ` · ${figures.join(" · ")}` : null
4537
+ ] }),
4538
+ /* @__PURE__ */ jsx("span", { className: styles$l.metaGrow }),
4539
+ children,
4540
+ onStop ? /* @__PURE__ */ jsxs("button", { type: "button", className: styles$l.stopButton, disabled: showsStopping, onClick: () => void handleStop(), children: [
4541
+ /* @__PURE__ */ jsx("span", { className: styles$l.stopSquare, "aria-hidden": true }),
4542
+ translateText("Stop")
4543
+ ] }) : null
4544
+ ] });
4545
+ };
4546
+ const findNewestModelCallMessageId = (steps) => {
4547
+ for (let position = steps.length - 1; position >= 0; position -= 1) {
4548
+ const step = steps[position];
4549
+ if ((step.kind === "MODEL_CALL" || step.modelCall !== null) && step.messageId !== null) return step.messageId;
4550
+ }
4551
+ return null;
4552
+ };
4553
+ const findTurnModelLabel = (steps, modelName) => {
4554
+ if (!modelName) return null;
4555
+ for (let position = steps.length - 1; position >= 0; position -= 1) {
4556
+ const step = steps[position];
4557
+ if (step.modelCall?.modelName === modelName && step.modelLabel) return step.modelLabel;
4558
+ }
4559
+ return null;
4560
+ };
4561
+ const findNewestTaskPlanStep = (steps) => {
4562
+ for (let position = steps.length - 1; position >= 0; position -= 1) {
4563
+ if (steps[position].kind === "TASK_PLAN" && steps[position].taskPlanItemCount !== null) return steps[position];
4564
+ }
4565
+ return null;
4566
+ };
4567
+ const sumModelCalls = (turn) => {
4568
+ let tokens = turn.totals.inputTokens !== null || turn.totals.outputTokens !== null ? (turn.totals.inputTokens ?? 0) + (turn.totals.outputTokens ?? 0) : null;
4569
+ let costInUsd = turn.totals.costInUsd;
4570
+ if (tokens === null || costInUsd === null) {
4571
+ let summedTokens = 0;
4572
+ let summedCost = 0;
4573
+ let hasTokens = false;
4574
+ let hasCost = false;
4575
+ for (const step of turn.steps) {
4576
+ if (step.kind !== "MODEL_CALL" || step.modelCall === null) continue;
4577
+ if (step.modelCall.inputTokens !== null || step.modelCall.outputTokens !== null) {
4578
+ summedTokens += (step.modelCall.inputTokens ?? 0) + (step.modelCall.outputTokens ?? 0);
4579
+ hasTokens = true;
4580
+ }
4581
+ if (step.modelCall.costInUsd !== null) {
4582
+ summedCost += step.modelCall.costInUsd;
4583
+ hasCost = true;
4584
+ }
4585
+ }
4586
+ if (tokens === null && hasTokens) tokens = summedTokens;
4587
+ if (costInUsd === null && hasCost) costInUsd = summedCost;
4588
+ }
4589
+ return { tokens, costInUsd };
4590
+ };
4591
+ const ConversationTurnTrace = (props) => {
4592
+ const {
4593
+ conversationId,
4594
+ turnMessageId,
4595
+ phase,
4596
+ isCompact,
4597
+ client,
4598
+ viewMode,
4599
+ host,
4600
+ isDebugAllowed = false,
4601
+ pollIntervalMs,
4602
+ onOpenContext,
4603
+ buildAnalysisHref,
4604
+ taskPlan,
4605
+ conversationRevision,
4606
+ className
4607
+ } = props;
4608
+ const format = useTraceFormat();
4609
+ const isLive = phase === "live";
4610
+ const shownViewMode = viewMode === "verbose" && !isDebugAllowed ? "normal" : viewMode;
4611
+ const isVerbose = shownViewMode === "verbose";
4612
+ const numericTurnMessageId = typeof turnMessageId === "number" && Number.isFinite(turnMessageId) ? turnMessageId : null;
4613
+ const { turn, refresh } = useConversationTurnTrace({
4614
+ client,
4615
+ conversationId,
4616
+ turnMessageId: numericTurnMessageId,
4617
+ level: isVerbose ? "DEBUG" : "STEPS",
4618
+ isLive,
4619
+ pollIntervalMs,
4620
+ conversationRevision
4621
+ });
4622
+ const [isSummaryOpened, setIsSummaryOpened] = useState(false);
4623
+ useEffect(() => setIsSummaryOpened(false), [viewMode, numericTurnMessageId]);
4624
+ const firstSeenLiveAt = useRef(null);
4625
+ if (isLive && firstSeenLiveAt.current === null) firstSeenLiveAt.current = Date.now();
4626
+ if (!isLive) firstSeenLiveAt.current = null;
4627
+ const [isStopping, setIsStopping] = useState(false);
4628
+ useEffect(() => {
4629
+ if (!isLive) setIsStopping(false);
4630
+ }, [isLive]);
4631
+ const { getFileChangeDiff, getTurnTraces, stopTurn } = client;
4632
+ const boundHost = useMemo(() => {
4633
+ const loadFullDiffOfClient = getFileChangeDiff ? async (fileChange) => {
4634
+ if (fileChange.id == null) return fileChange.diffPreview ?? "";
4635
+ return (await getFileChangeDiff(fileChange.id)).diff;
4636
+ } : void 0;
4637
+ return {
4638
+ ...host,
4639
+ openModelCallContext: host?.openModelCallContext ?? onOpenContext,
4640
+ loadFullDiff: host?.loadFullDiff ?? loadFullDiffOfClient,
4641
+ renderChildTrace: host?.renderChildTrace ?? ((childConversationId) => /* @__PURE__ */ jsx(
4642
+ ConversationChildTrace,
4643
+ {
4644
+ client: { getTurnTraces },
4645
+ conversationId: childConversationId,
4646
+ viewMode: shownViewMode,
4647
+ host,
4648
+ isCompact,
4649
+ pollIntervalMs
4650
+ }
4651
+ ))
4652
+ };
4653
+ }, [host, onOpenContext, getFileChangeDiff, getTurnTraces, shownViewMode, isCompact, pollIntervalMs]);
4654
+ if (turn === null && !isLive) return null;
4655
+ const steps = turn?.steps ?? [];
4656
+ const totals = turn?.totals ?? null;
4657
+ const readerSteps = selectVisibleTraceSteps(steps, "normal");
4658
+ const handleStop = stopTurn ? async () => {
4659
+ try {
4660
+ const turnStop = await stopTurn(conversationId);
4661
+ setIsStopping(turnStop.isStopped);
4662
+ refresh();
4663
+ } catch {
4664
+ setIsStopping(false);
4665
+ }
4666
+ } : void 0;
4667
+ const spent = turn !== null && isVerbose ? sumModelCalls(turn) : { tokens: null, costInUsd: null };
4668
+ const statusLine = isLive ? /* @__PURE__ */ jsx(
4669
+ RunStatusLine,
4670
+ {
4671
+ startedAt: turn?.startedAt ?? firstSeenLiveAt.current,
4672
+ viewMode: shownViewMode,
4673
+ tokens: spent.tokens,
4674
+ costInUsd: spent.costInUsd,
4675
+ formatCost: boundHost.formatCost,
4676
+ onStop: handleStop,
4677
+ isStopping
4678
+ }
4679
+ ) : null;
4680
+ const newestPlanStep = isLive ? findNewestTaskPlanStep(steps) : null;
4681
+ const planRow = !isLive ? null : taskPlan && taskPlan.items.length > 0 ? /* @__PURE__ */ jsx(TaskPlanRow, { title: taskPlan.title, items: taskPlan.items, defaultOpen: !isCompact }) : newestPlanStep !== null ? /* @__PURE__ */ jsx(
4682
+ TaskPlanRow,
4683
+ {
4684
+ title: newestPlanStep.taskPlanTitle,
4685
+ items: buildTaskPlanItems(newestPlanStep.taskPlanItems),
4686
+ defaultOpen: !isCompact,
4687
+ totalCount: newestPlanStep.taskPlanItemCount,
4688
+ doneCount: readTaskPlanCountsOfStep(newestPlanStep).done
4689
+ }
4690
+ ) : null;
4691
+ const consentCalls = !isLive ? steps.filter((step) => step.isHeldForConsent).map((step) => ({ title: step.toolNameInWords || step.toolName || translateText("Action"), line: step.line ?? null })) : [];
4692
+ const consentCard = consentCalls.length > 0 && numericTurnMessageId !== null ? /* @__PURE__ */ jsx(ConsentRequestCard, { conversationId, turnMessageId: numericTurnMessageId, calls: consentCalls, isCompact }) : null;
4693
+ if (shownViewMode === "summary" && !isSummaryOpened) {
4694
+ if (isLive) {
4695
+ return /* @__PURE__ */ jsx("div", { className: classNames(styles$l.turnTrace, isCompact && styles$l.turnTraceCompact, className), "data-testid": "conversation-turn-trace", "data-view-mode": "summary", "data-phase": phase, children: statusLine });
4696
+ }
4697
+ if (readerSteps.length === 0) return null;
4698
+ const summaryParts = [
4699
+ describeStepCount(readerSteps.length, format),
4700
+ totals?.durationMs != null ? format.duration(totals.durationMs) : null
4701
+ ].filter((part) => part !== null);
4702
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$l.turnTrace, isCompact && styles$l.turnTraceCompact, className), "data-testid": "conversation-turn-trace", "data-view-mode": "summary", "data-phase": phase, children: [
4703
+ /* @__PURE__ */ jsxs(
4704
+ "button",
4705
+ {
4706
+ type: "button",
4707
+ className: styles$l.summaryChip,
4708
+ "aria-expanded": false,
4709
+ title: translateText("Show the steps"),
4710
+ onClick: () => setIsSummaryOpened(true),
4711
+ "data-testid": "trace-summary-chip",
4712
+ children: [
4713
+ /* @__PURE__ */ jsx(Icon, { name: "steps", pixelSize: 13 }),
4714
+ summaryParts.join(" · ")
4715
+ ]
4716
+ }
4717
+ ),
4718
+ consentCard
4719
+ ] });
4720
+ }
4721
+ const groupViewMode = shownViewMode === "summary" ? "normal" : shownViewMode;
4722
+ const newestModelCallMessageId = isVerbose ? findNewestModelCallMessageId(steps) : null;
4723
+ const analysisHref = isVerbose && numericTurnMessageId !== null ? buildAnalysisHref?.(conversationId, numericTurnMessageId) ?? null : null;
4724
+ const metaLine = isVerbose && totals !== null && !isLive ? /* @__PURE__ */ jsx(
4725
+ TurnMetaLine,
4726
+ {
4727
+ ...totals,
4728
+ modelLabel: findTurnModelLabel(steps, totals.modelName),
4729
+ onOpenContext: onOpenContext && newestModelCallMessageId !== null ? () => onOpenContext(newestModelCallMessageId) : void 0,
4730
+ analysisHref,
4731
+ linkComponent: boundHost.linkComponent,
4732
+ formatCost: boundHost.formatCost,
4733
+ isCompact
4734
+ }
4735
+ ) : null;
4736
+ const queuedMessagesTakenUp = !isLive && turn !== null && shownViewMode !== "summary" ? (turn.queuedMessages ?? []).filter((message) => message.handledInTurnNumber == null || message.handledInTurnNumber === turn.turnNumber) : [];
4737
+ const hasGroup = selectVisibleTraceSteps(steps, groupViewMode).length > 0 || isLive || metaLine !== null;
4738
+ if (!hasGroup) return consentCard;
4739
+ return /* @__PURE__ */ jsxs(
4740
+ "div",
4741
+ {
4742
+ className: classNames(styles$l.turnTrace, styles$l.anchor, isCompact && styles$l.turnTraceCompact, className),
4743
+ "data-testid": "conversation-turn-trace",
4744
+ "data-view-mode": shownViewMode,
4745
+ "data-phase": phase,
4746
+ "data-trace-turn-number": turn?.turnNumber ?? void 0,
4747
+ children: [
4748
+ planRow,
4749
+ /* @__PURE__ */ jsx(
4750
+ ToolStepGroup,
4751
+ {
4752
+ steps,
4753
+ viewMode: groupViewMode,
4754
+ durationMs: isLive ? null : totals?.durationMs,
4755
+ defaultOpen: isLive || shownViewMode === "summary" ? true : void 0,
4756
+ summary: totals !== null && (totals.commandCount > 0 || totals.fileCount > 0 || totals.linesAdded > 0 || totals.linesRemoved > 0) ? /* @__PURE__ */ jsx(FileChangesSummary, { commandCount: totals.commandCount, fileCount: totals.fileCount, linesAdded: totals.linesAdded, linesRemoved: totals.linesRemoved }) : void 0,
4757
+ metaLine,
4758
+ host: boundHost,
4759
+ conversationId,
4760
+ isCompact
4761
+ },
4762
+ isLive ? "live" : "done"
4763
+ ),
4764
+ queuedMessagesTakenUp.map((message) => /* @__PURE__ */ jsx(QueuedMessageChip, { text: message.text, wasTakenUp: true, isCompact }, message.messageId ?? message.text)),
4765
+ consentCard,
4766
+ statusLine
4767
+ ]
4768
+ }
4769
+ );
4770
+ };
4771
+ const readItemState = (status, isFirstOpen) => {
4772
+ if (status === "done") return "done";
4773
+ if (status === "not_applicable") return "skipped";
4774
+ if (status === "blocked") return "blocked";
4775
+ return isFirstOpen ? "next" : "open";
4776
+ };
4777
+ const ITEM_STATE_LABELS = {
4778
+ done: () => translateText("Done"),
4779
+ skipped: () => translateText("Does not apply", void 0, "plan-item-state"),
4780
+ blocked: () => translateText("Blocked", void 0, "plan-item-state"),
4781
+ next: () => translateText("Up next", void 0, "plan-item-state"),
4782
+ open: () => translateText("Not started")
4783
+ };
4784
+ const ITEM_CLASS_NAMES = {
4785
+ done: styles$4.itemDone,
4786
+ skipped: classNames(styles$4.itemDone, styles$4.itemSkipped),
4787
+ blocked: styles$4.itemBlocked,
4788
+ next: styles$4.itemNext,
4789
+ open: void 0
4790
+ };
4791
+ const TaskPlanPane = (props) => {
4792
+ const { title: title2, items: items2, note: note2, itemSources, onSelectItem, className } = props;
4793
+ const format = useTraceFormat();
4794
+ const counts = readTaskPlanCounts({ itemCount: props.itemCount, doneItemCount: props.doneCount, blockedItemCount: props.blockedCount, items: items2 });
4795
+ const itemCount = counts.total;
4796
+ const doneCount = counts.done;
4797
+ const progressText = describeTaskPlanProgress(counts, format);
4798
+ const firstOpenIndex = items2.findIndex((item2) => item2.status !== "done" && item2.status !== "not_applicable" && item2.status !== "blocked");
4799
+ return /* @__PURE__ */ jsxs("div", { className: classNames(styles$4.plan, className), "data-testid": "trace-task-plan-pane", children: [
4800
+ /* @__PURE__ */ jsxs("div", { className: styles$4.head, children: [
4801
+ /* @__PURE__ */ jsx("span", { className: classNames(styles$4.title, styles$4.titleClamped), title: title2 ?? void 0, children: title2 ? `${translateText("Plan")} · ${title2}` : translateText("Plan") }),
4802
+ /* @__PURE__ */ jsx("span", { className: styles$4.grow }),
4803
+ itemCount > 0 ? /* @__PURE__ */ jsx("span", { className: styles$4.quiet, children: progressText }) : null
4804
+ ] }),
4805
+ itemCount > 0 ? /* @__PURE__ */ jsx(
4806
+ "div",
4807
+ {
4808
+ className: styles$4.meter,
4809
+ role: "progressbar",
4810
+ "aria-valuemin": 0,
4811
+ "aria-valuemax": itemCount,
4812
+ "aria-valuenow": doneCount,
4813
+ "aria-label": progressText,
4814
+ children: /* @__PURE__ */ jsx("span", { className: styles$4.meterFill, style: { width: `${doneCount / itemCount * 100}%` } })
4815
+ }
4816
+ ) : null,
4817
+ note2 ? /* @__PURE__ */ jsx("div", { className: styles$4.quiet, children: note2 }) : null,
4818
+ items2.length > 0 ? /* @__PURE__ */ jsx("ol", { className: styles$4.items, children: items2.map((item2, index) => {
4819
+ const state = readItemState(item2.status, index === firstOpenIndex);
4820
+ const source = item2.key ? itemSources?.[item2.key] : void 0;
4821
+ return /* @__PURE__ */ jsxs(
4822
+ "li",
4823
+ {
4824
+ className: classNames(styles$4.item, ITEM_CLASS_NAMES[state]),
4825
+ style: { paddingLeft: `${Math.max(0, item2.depth ?? 0) * 18}px` },
4826
+ "data-plan-item-state": state,
4827
+ "aria-current": state === "next" ? "step" : void 0,
4828
+ children: [
4829
+ /* @__PURE__ */ jsxs("span", { className: styles$4.box, role: "img", "aria-label": ITEM_STATE_LABELS[state](), children: [
4830
+ state === "done" ? /* @__PURE__ */ jsx(Icon, { name: "stepDone", pixelSize: 11 }) : null,
4831
+ state === "skipped" ? /* @__PURE__ */ jsx(Icon, { name: "dash", pixelSize: 11 }) : null,
4832
+ state === "blocked" ? /* @__PURE__ */ jsx(Icon, { name: "exclamation", pixelSize: 11 }) : null
4833
+ ] }),
4834
+ item2.numberPath ? /* @__PURE__ */ jsx("span", { className: styles$4.number, children: item2.numberPath }) : null,
4835
+ source !== void 0 && onSelectItem !== void 0 ? /* @__PURE__ */ jsx(
4836
+ "button",
4837
+ {
4838
+ type: "button",
4839
+ className: classNames(styles$4.itemText, styles$4.itemLink),
4840
+ title: translateText("Show the step that last changed this item"),
4841
+ "data-testid": "trace-task-plan-item-link",
4842
+ onClick: () => onSelectItem(item2, source),
4843
+ children: item2.title
4844
+ }
4845
+ ) : /* @__PURE__ */ jsx("span", { className: styles$4.itemText, children: item2.title }),
4846
+ state === "blocked" ? /* @__PURE__ */ jsx("span", { className: classNames(styles$4.mark, styles$4.markWarning), children: ITEM_STATE_LABELS.blocked() }) : null,
4847
+ state === "skipped" ? /* @__PURE__ */ jsx("span", { className: styles$4.mark, children: ITEM_STATE_LABELS.skipped() }) : null
4848
+ ]
4849
+ },
4850
+ item2.key || index
4851
+ );
4852
+ }) }) : null
4853
+ ] });
4854
+ };
4855
+ const TRACE_STEP_ANCHOR_ATTRIBUTE = "data-trace-step-anchor";
4856
+ const TRACE_TURN_ANCHOR_ATTRIBUTE = "data-trace-turn-number";
4857
+ const TRACE_HIGHLIGHT_ATTRIBUTE = "data-trace-highlighted";
4858
+ const HIGHLIGHT_DURATION_MS = 2e3;
4859
+ const escapeAttributeValue = (value) => value.replace(/["\\]/g, "\\$&");
4860
+ const focusTraceStep = (root2, source) => {
4861
+ const stepElement = source.stepId !== null ? root2.querySelector(`[${TRACE_STEP_ANCHOR_ATTRIBUTE}="${escapeAttributeValue(source.stepId)}"]`) : null;
4862
+ const element = stepElement ?? root2.querySelector(`[${TRACE_TURN_ANCHOR_ATTRIBUTE}="${source.turnNumber}"]`);
4863
+ if (element === null) return false;
4864
+ element.scrollIntoView?.({ block: "center", behavior: "smooth" });
4865
+ element.setAttribute(TRACE_HIGHLIGHT_ATTRIBUTE, "true");
4866
+ setTimeout(() => element.removeAttribute(TRACE_HIGHLIGHT_ATTRIBUTE), HIGHLIGHT_DURATION_MS);
4867
+ return true;
4868
+ };
4869
+ const collectTraceFileChangesByTurn = (turns) => turns.flatMap((turn) => {
4870
+ const fileChanges = turn.steps.flatMap((step) => step.fileChanges);
4871
+ if (fileChanges.length === 0) return [];
4872
+ return [
4873
+ {
4874
+ turnNumber: turn.turnNumber,
4875
+ turnMessageId: turn.turnMessageId,
4876
+ startedAt: turn.startedAt,
4877
+ fileChanges,
4878
+ fileCount: new Set(fileChanges.map((fileChange) => `${fileChange.mountKind ?? ""}:${fileChange.mountName ?? ""}:${fileChange.path}`)).size,
4879
+ linesAdded: fileChanges.reduce((sum, fileChange) => sum + (fileChange.linesAdded ?? 0), 0),
4880
+ linesRemoved: fileChanges.reduce((sum, fileChange) => sum + (fileChange.linesRemoved ?? 0), 0)
4881
+ }
4882
+ ];
4883
+ });
4884
+ const collectTraceBackgroundTasks = (turns) => {
4885
+ const tasksByKey = /* @__PURE__ */ new Map();
4886
+ for (const turn of turns) {
4887
+ for (const step of turn.steps) {
4888
+ if (step.kind === "SUB_AGENT" && step.subAgent !== null) {
4889
+ const subAgent = step.subAgent;
4890
+ const newestRun = subAgent.runs[subAgent.runs.length - 1];
4891
+ const startedAt = readTraceMoment(newestRun?.startedAt);
4892
+ const finishedAt = readTraceMoment(newestRun?.finishedAt);
4893
+ const key2 = `subAgent:${subAgent.childConversationId ?? `${turn.turnNumber}:${step.key}`}`;
4894
+ tasksByKey.delete(key2);
4895
+ const isBackgroundJob = subAgent.taskKind === "toolRun" || isTraceBackgroundJobLabel(subAgent.taskText);
4896
+ const durationMs = startedAt !== null && finishedAt !== null ? Math.max(0, finishedAt - startedAt) : null;
4897
+ tasksByKey.set(key2, {
4898
+ key: key2,
4899
+ type: "subAgent",
4900
+ title: subAgent.number !== null ? `#${subAgent.number} ${subAgent.label}` : subAgent.label,
4901
+ detail: isBackgroundJob ? describeTraceBackgroundJob(subAgent.toolName ?? subAgent.taskText) : subAgent.taskText,
4902
+ state: readTraceSubAgentState(subAgent),
4903
+ startedAt: newestRun?.startedAt ?? step.startedAt,
4904
+ durationMs: durationMs === 0 ? null : durationMs,
4905
+ typeLabel: isBackgroundJob ? translateText("Background job") : null,
4906
+ childConversationId: subAgent.childConversationId
4907
+ });
4908
+ continue;
4909
+ }
4910
+ if (step.terminal === null) continue;
4911
+ const state = readTraceStepState(step);
4912
+ if (!step.terminal.isBackground && state !== "running") continue;
4913
+ const key = `command:${turn.turnNumber}:${step.key}`;
4914
+ tasksByKey.set(key, {
4915
+ key,
4916
+ type: "command",
4917
+ title: step.terminal.command ?? step.line ?? step.toolNameInWords ?? "",
4918
+ detail: step.terminal.cwd,
4919
+ state,
4920
+ startedAt: step.startedAt,
4921
+ durationMs: step.terminal.durationMs ?? step.durationMs
4922
+ });
4923
+ }
4924
+ }
4925
+ return [...tasksByKey.values()].reverse();
4926
+ };
4927
+ const collectTaskPlanItemSources = (turns) => {
4928
+ const sources = {};
4929
+ const previousStateByKey = /* @__PURE__ */ new Map();
4930
+ for (const turn of turns) {
4931
+ for (const step of turn.steps) {
4932
+ if (step.kind !== "TASK_PLAN") continue;
4933
+ for (const item2 of step.taskPlanItems) {
4934
+ const state = `${item2.status ?? ""}\0${item2.title}`;
4935
+ if (previousStateByKey.get(item2.key) === state) continue;
4936
+ previousStateByKey.set(item2.key, state);
4937
+ sources[item2.key] = { turnNumber: turn.turnNumber, turnMessageId: turn.turnMessageId, stepKey: step.key, stepId: step.stepId ?? null };
4938
+ }
4939
+ }
4940
+ }
4941
+ return sources;
4942
+ };
4943
+ const collectTraceTaskPlan = (turns) => {
4944
+ for (let turnPosition = turns.length - 1; turnPosition >= 0; turnPosition -= 1) {
4945
+ const turn = turns[turnPosition];
4946
+ for (let stepPosition = turn.steps.length - 1; stepPosition >= 0; stepPosition -= 1) {
4947
+ const step = turn.steps[stepPosition];
4948
+ if (step.kind !== "TASK_PLAN") continue;
4949
+ const items2 = step.taskPlanItems;
4950
+ if (items2.length === 0 && (step.taskPlanItemCount === null || step.taskPlanItemCount <= 0)) continue;
4951
+ const counts = readTaskPlanCounts({
4952
+ itemCount: step.taskPlanItemCount,
4953
+ openItemCount: step.taskPlanOpenItemCount,
4954
+ doneItemCount: step.taskPlanDoneItemCount,
4955
+ blockedItemCount: step.taskPlanBlockedItemCount,
4956
+ items: items2
4957
+ });
4958
+ return {
4959
+ turnNumber: turn.turnNumber,
4960
+ turnMessageId: turn.turnMessageId,
4961
+ stepKey: step.key,
4962
+ title: step.taskPlanTitle,
4963
+ items: items2,
4964
+ itemCount: counts.total,
4965
+ doneCount: counts.done,
4966
+ blockedCount: counts.blocked,
4967
+ updatedAt: step.startedAt,
4968
+ itemSources: collectTaskPlanItemSources(turns)
4969
+ };
4970
+ }
4971
+ }
4972
+ return null;
4973
+ };
4974
+ const collectTraceChangedRecords = (turns) => {
4975
+ const records2 = [];
4976
+ for (const turn of turns) {
4977
+ for (const step of turn.steps) {
4978
+ if (step.kind !== "TOOL_CALL" || step.effect !== "WRITE" && step.effect !== "DELETE" || step.isRefused) continue;
4979
+ records2.push({
4980
+ key: `${turn.turnNumber}:${step.key}`,
4981
+ turnNumber: turn.turnNumber,
4982
+ turnMessageId: turn.turnMessageId,
4983
+ stepId: step.stepId,
4984
+ messageId: step.messageId,
4985
+ toolName: step.toolName,
4986
+ toolNameInWords: step.toolNameInWords,
4987
+ line: step.line,
4988
+ effect: step.effect,
4989
+ state: readTraceStepState(step),
4990
+ startedAt: step.startedAt,
4991
+ entityReferences: step.entityReferences,
4992
+ recordChanges: step.recordChanges ?? [],
4993
+ omittedRecordChangeCount: step.omittedRecordChangeCount ?? 0
4994
+ });
4995
+ }
4996
+ }
4997
+ return records2.reverse();
4998
+ };
3575
4999
  const stack = "agents_stack_qYED72";
3576
5000
  const visual = "agents_visual_44ItL8";
3577
5001
  const waiting = "agents_waiting_jFvZ9-";
@@ -3910,8 +5334,15 @@ export {
3910
5334
  AgentChatController,
3911
5335
  A as AgentsChatStateContainer,
3912
5336
  A2 as AgentsChatStoreProvider,
5337
+ BackgroundTasksList,
3913
5338
  CanvasPane,
3914
5339
  CanvasRestoreOnMount,
5340
+ ChangeSetCard,
5341
+ ChangedFilesPane,
5342
+ ChangedRecordsList,
5343
+ C as CompactionDetail,
5344
+ ContextRing,
5345
+ ConversationChildTrace,
3915
5346
  ConversationClosedBar,
3916
5347
  ConversationDeepLinkedWidget,
3917
5348
  ConversationErrorWidget as ConversationErrorCard,
@@ -3925,24 +5356,107 @@ export {
3925
5356
  ConversationMessageSystem,
3926
5357
  ConversationMessageUser,
3927
5358
  ConversationMessageWidgets,
5359
+ ConversationTraceLoader,
5360
+ ConversationTurnTrace,
3928
5361
  ConversationView,
3929
5362
  ConversationWidgetProvider,
3930
5363
  DEFAULT_AGENT_CHAT_ACTIVITY_TIMING,
5364
+ D as DecisionDetail,
3931
5365
  E as EMPTY_AGENTS_CHAT_OPENING_REQUEST,
5366
+ EntityChip,
5367
+ FileChangesSummary,
5368
+ FileEditBlock,
3932
5369
  I as INITIAL_AGENTS_CHAT_STATE,
5370
+ L as LoadedSkillsDisclosure,
3933
5371
  MAX_MESSAGE_LENGTH,
3934
5372
  PHONE_CALL_LIFECYCLE_SIGNAL_SOURCES,
3935
- S as SIGNAL_SOURCES_THAT_OWE_NO_WORK,
5373
+ QueuedMessageChip,
5374
+ RunStatusLine,
5375
+ SIGNAL_SOURCES_THAT_OWE_NO_WORK,
3936
5376
  SUCCESS_BEAT_MS,
5377
+ S as SignalDetail,
5378
+ G as SkillLoadDetail,
5379
+ H as StepFactsLine,
5380
+ I2 as SubAgentStepGroup,
5381
+ J as SubAgentStepRow,
5382
+ K as TRACE_CONTEXT_SEGMENT_LABELS,
5383
+ M as TRACE_DECISION_SITE_LABELS,
5384
+ TRACE_HIGHLIGHT_ATTRIBUTE,
5385
+ N as TRACE_SIGNAL_SOURCE_LABELS,
5386
+ O as TRACE_SIGNAL_TAG_LABELS,
5387
+ TRACE_STEP_ANCHOR_ATTRIBUTE,
5388
+ TRACE_TURN_ANCHOR_ATTRIBUTE,
5389
+ P as TRACE_WAKE_CONDITION_LABELS,
5390
+ TaskPlanPane,
5391
+ TaskPlanRow,
5392
+ Q as TaskPlanStepDetail,
5393
+ R as TerminalBlock,
5394
+ U as ThinkingBlock,
5395
+ V as ToolStepDetail,
5396
+ ToolStepGroup,
5397
+ W as ToolStepRow,
5398
+ X as TraceCodePanel,
5399
+ Y as TraceCopyButton,
5400
+ TraceMountChip,
5401
+ TracePath,
5402
+ TraceStateIcon,
5403
+ TraceStepRow,
5404
+ Z as TraceViewModeSwitch,
5405
+ TurnMetaLine,
5406
+ _ as WidgetDetail,
5407
+ $ as buildSideBySideDiffRows,
5408
+ buildTaskPlanItems,
5409
+ collectTraceBackgroundTasks,
5410
+ collectTraceChangedRecords,
5411
+ collectTraceFileChangesByTurn,
5412
+ collectTraceTaskPlan,
3937
5413
  createAgentsChatStore,
5414
+ a0 as createTraceFormat,
3938
5415
  deriveAgentActivity,
5416
+ describeChangedFieldName,
5417
+ describeChangedRecord,
5418
+ a1 as describeSubAgentCounts,
5419
+ describeTraceBackgroundJob,
5420
+ a2 as describeTraceCompaction,
5421
+ a3 as describeTraceContextSegment,
5422
+ a4 as describeTraceDecision,
5423
+ a5 as describeTraceDecisionSite,
5424
+ a6 as describeTraceDecisionStatus,
5425
+ a7 as describeTraceModelName,
5426
+ a8 as describeTraceMount,
5427
+ a9 as describeTraceSignal,
5428
+ aa as describeTraceSkillCause,
5429
+ ab as describeTraceWakeCondition,
5430
+ findTurnsInFlight,
3939
5431
  findUnansweredWidgetMessageId,
5432
+ focusTraceStep,
3940
5433
  formatElapsedClock,
5434
+ ac as formatShortSha256,
5435
+ formatTraceClock,
5436
+ getConversationTraceLoader,
3941
5437
  isStepStillRunning,
5438
+ isTraceBackgroundJobLabel,
5439
+ isTurnInitiatorMessage,
3942
5440
  normalizeServerMessageToMarkdown,
5441
+ ad as parseUnifiedDiff,
5442
+ ae as prettyPrintTraceJson,
5443
+ af as readContentFromUnifiedDiff,
3943
5444
  r as readConversationErrorTypeOfRefusedSend,
5445
+ ag as readTraceFileChangeIcon,
5446
+ readTraceFileChangeLetter,
5447
+ readTraceFileChangeWord,
5448
+ ah as readTraceIdInWords,
5449
+ readTraceMoment,
5450
+ ai as readTraceRunResultText,
5451
+ readTraceStateLabel,
5452
+ aj as readTraceStateOfStatus,
5453
+ ak as readTraceStepIcon,
5454
+ readTraceStepState,
5455
+ readTraceSubAgentState,
3944
5456
  d as reduceAgentsChatState,
5457
+ releaseConversationTraceLoaders,
3945
5458
  resolveAgentChatActivityTiming,
5459
+ selectVisibleTraceSteps,
3946
5460
  useActivityTicker,
3947
5461
  useAgentsChatSelector,
3948
5462
  b as useAgentsChatState,
@@ -3950,8 +5464,12 @@ export {
3950
5464
  useAgentsConversationClient,
3951
5465
  useAgentsConversationRunStatus,
3952
5466
  useConversationMessageSearch,
5467
+ useConversationTraceRevision,
5468
+ useConversationTraces,
5469
+ useConversationTurnTrace,
3953
5470
  useConversationsSearch,
3954
- a as useOptionalAgentsChatStore,
3955
- useOptionalAgentsConversationClient
5471
+ useOptionalAgentsChatStore,
5472
+ useOptionalAgentsConversationClient,
5473
+ useTraceFormat
3956
5474
  };
3957
5475
  //# sourceMappingURL=chat.js.map