@athenaintel/react 0.17.0 → 0.19.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 (128) hide show
  1. package/README.md +179 -43
  2. package/dist/AthenaContext-B1QMhIP-.cjs.map +1 -1
  3. package/dist/AthenaContext-MOslgOmE.js.map +1 -1
  4. package/dist/SuperGroupingCard-BsWbHyV_.js +795 -0
  5. package/dist/SuperGroupingCard-BsWbHyV_.js.map +1 -0
  6. package/dist/SuperGroupingCard-CRRFUgjN.cjs +794 -0
  7. package/dist/SuperGroupingCard-CRRFUgjN.cjs.map +1 -0
  8. package/dist/chat/StatewireApprovalCard.d.ts +59 -2
  9. package/dist/chat/StatewireClientToolBridge.d.ts +3 -3
  10. package/dist/chat/StatewireQueuedMessages.d.ts +105 -6
  11. package/dist/chat/statewire-approval.d.ts +1 -1
  12. package/dist/chat/statewire-banners.d.ts +5 -9
  13. package/dist/chat/statewire-client-tools.d.ts +15 -21
  14. package/dist/chat/super-grouping/CollapsibleGroup.d.ts +52 -11
  15. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +78 -21
  16. package/dist/chat/super-grouping/activity-timeline.d.ts +91 -0
  17. package/dist/chat/super-grouping/grouping-function.d.ts +13 -10
  18. package/dist/chat/super-grouping/index.d.ts +12 -0
  19. package/dist/chat/super-grouping/toolkit-map.d.ts +8 -1
  20. package/dist/chat/use-statewire-approval-request.d.ts +44 -0
  21. package/dist/chat-ui/header/conversation-history-panel.d.ts +11 -1
  22. package/dist/chat-ui/index.d.ts +9 -0
  23. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +24 -0
  24. package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +5 -0
  25. package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +1 -1
  26. package/dist/chat-ui/mentions/suggestions/shims.d.ts +0 -4
  27. package/dist/chat-ui/messages/continue-pill.d.ts +13 -0
  28. package/dist/chat-ui/messages/message-components.d.ts +7 -2
  29. package/dist/chat-ui/messages/runtime-message.d.ts +21 -0
  30. package/dist/chat-ui/messages/statewire-continue-run.d.ts +82 -0
  31. package/dist/chat-ui/messages/user-edit-composer.d.ts +5 -2
  32. package/dist/chat-ui/statewire.d.ts +19 -0
  33. package/dist/chat-ui/thread/chat-composer-dock.d.ts +1 -1
  34. package/dist/chat-ui/thread/chat-thread-shell.d.ts +7 -1
  35. package/dist/chat-ui/thread/statewire-history-edge.d.ts +52 -0
  36. package/dist/chat-ui-statewire.cjs +25 -0
  37. package/dist/chat-ui-statewire.cjs.map +1 -0
  38. package/dist/chat-ui-statewire.js +25 -0
  39. package/dist/chat-ui-statewire.js.map +1 -0
  40. package/dist/chat-ui.cjs +292 -252
  41. package/dist/chat-ui.cjs.map +1 -1
  42. package/dist/chat-ui.js +289 -248
  43. package/dist/chat-ui.js.map +1 -1
  44. package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
  45. package/dist/diagnostics/errors.d.ts +4 -4
  46. package/dist/index.cjs +20237 -26233
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +25 -14
  49. package/dist/index.js +18465 -24458
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/athena-urls.d.ts +0 -2
  52. package/dist/lib/posthog/wrap-posthog-client.d.ts +3 -1
  53. package/dist/misc-tool-uis-B2e0Okkn.cjs +43 -0
  54. package/dist/misc-tool-uis-B2e0Okkn.cjs.map +1 -0
  55. package/dist/misc-tool-uis-gAiQw0Yl.js +44 -0
  56. package/dist/misc-tool-uis-gAiQw0Yl.js.map +1 -0
  57. package/dist/provider/AthenaContext.d.ts +0 -7
  58. package/dist/provider/AthenaProvider.d.ts +28 -52
  59. package/dist/provider/config.d.ts +19 -15
  60. package/dist/provider/statewire-lifecycle-context.d.ts +3 -4
  61. package/dist/provider/statewire-window-context.d.ts +12 -0
  62. package/dist/provider/types.d.ts +0 -1
  63. package/dist/runtime/statewire-auth-headers.d.ts +38 -0
  64. package/dist/runtime/statewire-lifecycle.d.ts +25 -1
  65. package/dist/runtime/statewire-run-config.d.ts +18 -5
  66. package/dist/runtime/statewire-session-key.d.ts +13 -0
  67. package/dist/runtime/useAthenaStatewireRuntime.d.ts +42 -16
  68. package/dist/statewire-continue-run-D34gS7_1.js +132 -0
  69. package/dist/statewire-continue-run-D34gS7_1.js.map +1 -0
  70. package/dist/statewire-continue-run-nE9VCKUh.cjs +131 -0
  71. package/dist/statewire-continue-run-nE9VCKUh.cjs.map +1 -0
  72. package/dist/statewire-history-edge-C8uyTEjX.cjs +1711 -0
  73. package/dist/statewire-history-edge-C8uyTEjX.cjs.map +1 -0
  74. package/dist/statewire-history-edge-CPohUKMt.js +1712 -0
  75. package/dist/statewire-history-edge-CPohUKMt.js.map +1 -0
  76. package/dist/styles.css +1 -1
  77. package/dist/super-grouping.cjs +22 -0
  78. package/dist/super-grouping.cjs.map +1 -0
  79. package/dist/super-grouping.js +22 -0
  80. package/dist/super-grouping.js.map +1 -0
  81. package/dist/threads/ThreadList.d.ts +6 -1
  82. package/dist/threads/mint-thread-id.d.ts +8 -0
  83. package/dist/threads/statewire-thread-list.d.ts +26 -9
  84. package/dist/threads/thread-id-context.d.ts +9 -0
  85. package/dist/threads/use-statewire-conversation-history.d.ts +2 -0
  86. package/dist/threads/useAthenaThreadManager.d.ts +24 -12
  87. package/dist/tool-fallback-DkQ3DLkn.js +4281 -0
  88. package/dist/tool-fallback-DkQ3DLkn.js.map +1 -0
  89. package/dist/tool-fallback-kfhpJQZa.cjs +4297 -0
  90. package/dist/tool-fallback-kfhpJQZa.cjs.map +1 -0
  91. package/dist/tools/index.d.ts +14 -0
  92. package/dist/tools/misc-tool-uis.d.ts +2 -0
  93. package/dist/tools/primitives.d.ts +41 -0
  94. package/dist/tools/tool-fallback.d.ts +78 -6
  95. package/dist/tools/tool-icons.d.ts +10 -0
  96. package/dist/tools/tool-uis.d.ts +1 -23
  97. package/dist/tools.cjs +41 -0
  98. package/dist/tools.cjs.map +1 -0
  99. package/dist/tools.js +41 -0
  100. package/dist/tools.js.map +1 -0
  101. package/dist/trash-2-B5OaNAL7.cjs +5096 -0
  102. package/dist/trash-2-B5OaNAL7.cjs.map +1 -0
  103. package/dist/trash-2-CCwSURL-.js +5081 -0
  104. package/dist/trash-2-CCwSURL-.js.map +1 -0
  105. package/dist/{use-rest-conversation-history-BdnG8jEP.cjs → use-rest-conversation-history-Cm8qMRxp.cjs} +985 -5405
  106. package/dist/use-rest-conversation-history-Cm8qMRxp.cjs.map +1 -0
  107. package/dist/{use-rest-conversation-history-DpEswBqQ.js → use-rest-conversation-history-veDZS-oL.js} +1035 -5455
  108. package/dist/use-rest-conversation-history-veDZS-oL.js.map +1 -0
  109. package/dist/wrench-BEf72cyP.cjs +417 -0
  110. package/dist/wrench-BEf72cyP.cjs.map +1 -0
  111. package/dist/wrench-CbrOlVYm.js +418 -0
  112. package/dist/wrench-CbrOlVYm.js.map +1 -0
  113. package/dist/x-Dfd2NzK0.cjs +42 -0
  114. package/dist/x-Dfd2NzK0.cjs.map +1 -0
  115. package/dist/x-_DntAa_a.js +43 -0
  116. package/dist/x-_DntAa_a.js.map +1 -0
  117. package/package.json +29 -11
  118. package/dist/chat/super-grouping/tool-status-labels.d.ts +0 -1
  119. package/dist/runtime/converter.d.ts +0 -5
  120. package/dist/runtime/external-message-converter.d.ts +0 -21
  121. package/dist/runtime/schemas.d.ts +0 -24
  122. package/dist/runtime/transport.d.ts +0 -39
  123. package/dist/runtime/useAthenaRuntime.d.ts +0 -47
  124. package/dist/threads/adapter.d.ts +0 -42
  125. package/dist/threads/useActiveThreadStateHydration.d.ts +0 -12
  126. package/dist/threads/useThreadTitlePolling.d.ts +0 -14
  127. package/dist/use-rest-conversation-history-BdnG8jEP.cjs.map +0 -1
  128. package/dist/use-rest-conversation-history-DpEswBqQ.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SuperGroupingCard-CRRFUgjN.cjs","sources":["../../../node_modules/lucide-react/dist/esm/icons/chevron-up.js","../src/chat/super-grouping/activity-timeline.ts","../src/chat/super-grouping/grouping-function.ts","../src/chat/super-grouping/toolkit-map.ts","../src/chat/super-grouping/CollapsibleGroup.tsx","../src/chat/super-grouping/SuperGroupingCard.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.575.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [[\"path\", { d: \"m18 15-6-6-6 6\", key: \"153udz\" }]];\nconst ChevronUp = createLucideIcon(\"chevron-up\", __iconNode);\n\nexport { __iconNode, ChevronUp as default };\n//# sourceMappingURL=chevron-up.js.map\n","/**\n * The assistant turn's activity timeline — the one derivation of \"what did\n * this turn do, and how did each step end\" behind the grouped\n * (\"conversational\") view on every surface: the SDK's `AthenaChat`, Olympus's\n * Spaces chat, and the Chrome extension. Pure functions over assistant-ui\n * message parts; `SuperGroupingCard` renders them.\n *\n * Step states come from the shared classifier (`classifyToolResult`) plus the\n * approval outcomes a part carries (`approval`, `interrupt`, a rejection\n * result), so a call that reads as failed, paused, or rejected on one surface\n * cannot read as a green check on another. Copy comes from the shared tool\n * display registry (`toolStatusLabel`).\n */\nimport type {\n MessageStatus,\n ThreadAssistantMessagePart,\n ToolCallMessagePartStatus,\n} from '@assistant-ui/react';\nimport {\n classifyToolResult,\n readRejectedToolResult,\n toolStatusLabel,\n type ToolStatusLabelState,\n} from '@athenaintel/agent-runtime';\nimport type { GroupingFunction } from './grouping-function';\n\nexport type ActivityToolState = ToolStatusLabelState;\n\nexport type ActivityItem =\n | { kind: 'reasoning'; text: string; state: 'running' | 'complete' }\n | { kind: 'tool'; toolName: string; state: ActivityToolState };\n\n/** The turn as a whole: still working, parked on the person, ended in error, or done. */\nexport type ActivityPhase = 'running' | 'waiting' | 'complete' | 'error';\n\ntype ToolCallPart = Extract<ThreadAssistantMessagePart, { type: 'tool-call' }>;\n\nexport interface ActivityTimelineOptions {\n /**\n * Tools whose unresolved call means the turn is waiting on the person even\n * without an interrupt or approval on the part (the Chrome extension's\n * device plan approval, which the tool UI itself collects).\n */\n waitingTools?: ReadonlySet<string>;\n /**\n * Tools whose result is an application payload relayed verbatim (the Chrome\n * extension's page JavaScript), so a `success: false` flag counts only with\n * an error detail — see `classifyToolResult`'s `passThroughPayload`.\n */\n passThroughTools?: ReadonlySet<string>;\n}\n\nconst NO_TOOLS: ReadonlySet<string> = new Set();\n\nfunction toolCallStatus(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n): ToolCallMessagePartStatus | undefined {\n if (part.result !== undefined) return { type: 'complete' };\n if (messageStatus?.type === 'incomplete') {\n return {\n type: 'incomplete',\n reason: messageStatus.reason === 'tool-calls' ? 'other' : messageStatus.reason,\n error: messageStatus.error,\n };\n }\n if (messageStatus?.type === 'complete') return { type: 'complete' };\n if (messageStatus?.type === 'requires-action') {\n return { type: 'requires-action', reason: messageStatus.reason };\n }\n if (messageStatus?.type === 'running') return { type: 'running' };\n return undefined;\n}\n\n/** How one tool call ended (or is going), reading the approval fields before the result. */\nexport function getActivityToolState(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n { waitingTools = NO_TOOLS, passThroughTools = NO_TOOLS }: ActivityTimelineOptions = {},\n): ActivityToolState {\n if (part.approval?.approved === false || readRejectedToolResult(part.result) !== null) {\n return 'rejected';\n }\n if (part.approval?.resolution === 'cancelled' || part.approval?.resolution === 'expired') {\n return 'cancelled';\n }\n const unresolved = part.result === undefined;\n const messageIsActive =\n messageStatus === undefined ||\n messageStatus.type === 'running' ||\n messageStatus.type === 'requires-action';\n if (\n unresolved &&\n (part.interrupt?.type === 'human' ||\n (part.approval !== undefined &&\n part.approval.approved === undefined &&\n part.approval.resolution === undefined) ||\n (waitingTools.has(part.toolName) && messageIsActive))\n ) {\n return 'waiting';\n }\n\n const classification = classifyToolResult({\n status: toolCallStatus(part, messageStatus),\n result: part.result,\n isError: part.isError,\n passThroughPayload: passThroughTools.has(part.toolName),\n });\n if (classification.state === 'requires-action') return 'waiting';\n return classification.state;\n}\n\n/**\n * The compact reasoning/tool timeline in the order the parts streamed.\n *\n * A reasoning part is still streaming only while it is the final part of a\n * running message — once any later part appears, the thought has settled.\n * Settled reasoning parts with no text are dropped so the list never shows an\n * empty thinking row.\n */\nexport function buildActivityTimeline(\n content: readonly ThreadAssistantMessagePart[] | undefined,\n messageStatus: MessageStatus | undefined,\n options: ActivityTimelineOptions = {},\n): ActivityItem[] {\n if (!content?.length) return [];\n\n const lastPartIndex = content.length - 1;\n const timeline: ActivityItem[] = [];\n for (let index = 0; index < content.length; index += 1) {\n const part = content[index];\n if (part.type === 'tool-call') {\n timeline.push({\n kind: 'tool',\n toolName: part.toolName,\n state: getActivityToolState(part, messageStatus, options),\n });\n continue;\n }\n if (part.type !== 'reasoning') continue;\n\n const text = typeof part.text === 'string' ? part.text : '';\n const stillStreaming = messageStatus?.type === 'running' && index === lastPartIndex;\n if (!stillStreaming && text.trim() === '') continue;\n timeline.push({ kind: 'reasoning', text, state: stillStreaming ? 'running' : 'complete' });\n }\n return timeline;\n}\n\n/** Number of tool calls in the timeline. */\nexport function countActivityTools(timeline: readonly ActivityItem[]): number {\n return timeline.reduce((count, item) => (item.kind === 'tool' ? count + 1 : count), 0);\n}\n\n/**\n * The turn's phase. Waiting on the person wins over everything (a host can\n * also assert it — Olympus's allotment store knows about `ask`), then the\n * message's own status.\n */\nexport function resolveActivityPhase(\n status: MessageStatus | undefined,\n timeline: readonly ActivityItem[],\n { waitingForInput = false }: { waitingForInput?: boolean } = {},\n): ActivityPhase {\n if (\n waitingForInput ||\n status?.type === 'requires-action' ||\n timeline.some((item) => item.kind === 'tool' && item.state === 'waiting')\n ) {\n return 'waiting';\n }\n if (status?.type === 'running') return 'running';\n if (status?.type === 'incomplete') return 'error';\n return 'complete';\n}\n\n/**\n * The status-row copy for one step. `resolveToolDisplayName` lets a host with\n * a richer tool catalog name tools the shared registry has no entry for.\n */\nexport function getActivityItemLabel(\n item: ActivityItem,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n): string {\n if (item.kind === 'reasoning') {\n return item.state === 'running' ? 'Thinking' : 'Thought through the next step';\n }\n return toolStatusLabel(item.toolName, item.state, resolveToolDisplayName?.(item.toolName));\n}\n\n/** The collapsed-card summary of a finished turn. */\nexport function getActivitySummary(timeline: readonly ActivityItem[]): string {\n const toolCount = countActivityTools(timeline);\n const hasIssue = timeline.some(\n (item) => item.kind === 'tool' && (item.state === 'error' || item.state === 'rejected'),\n );\n if (hasIssue) return 'Completed with issues';\n if (timeline.some((item) => item.kind === 'tool' && item.state === 'cancelled')) {\n return 'Action cancelled';\n }\n if (timeline.some((item) => item.kind === 'tool' && item.state === 'paused')) {\n return 'Paused during tool use';\n }\n if (toolCount > 0) return `Used ${toolCount} ${toolCount === 1 ? 'tool' : 'tools'}`;\n return 'Reasoning complete';\n}\n\n/** The part shape the final-text read needs; any message role's parts satisfy it. */\nexport type FinalTextPart = { readonly type: string; readonly text?: string };\n\n/**\n * The visible answer of a grouped turn: the text after the final tool call,\n * or all of it when the turn never called a tool. Intermediate text (before\n * or between tool calls) stays available in the details panel.\n */\nexport function getFinalText(content: readonly FinalTextPart[] | undefined): string | null {\n if (!content?.length) return null;\n\n let lastToolIndex = -1;\n for (let index = content.length - 1; index >= 0; index -= 1) {\n if (content[index]?.type === 'tool-call') {\n lastToolIndex = index;\n break;\n }\n }\n\n const texts: string[] = [];\n for (let index = lastToolIndex + 1; index < content.length; index += 1) {\n const part = content[index];\n if (part?.type === 'text' && part.text) texts.push(part.text);\n }\n return texts.length > 0 ? texts.join('\\n\\n') : null;\n}\n\n/**\n * Keep the final answer out of the details panel: it renders below the card\n * (`SuperGroupingFinalText`), so the details grouping drops every text part\n * after the last tool call and any group that becomes empty.\n */\nexport function excludeFinalTextFromGroups(grouping: GroupingFunction): GroupingFunction {\n return (parts) => {\n const lastToolIndex = parts.findLastIndex((part) => part?.type === 'tool-call');\n return grouping(parts)\n .map((group) => ({\n ...group,\n indices: group.indices.filter(\n (index) => parts[index]?.type !== 'text' || index <= lastToolIndex,\n ),\n }))\n .filter((group) => group.indices.length > 0);\n };\n}\n","import type { GetToolGroupKey } from './toolkit-map';\n\n/** The part shape grouping needs; assistant-ui's `ThreadAssistantMessagePart` satisfies it. */\nexport type GroupablePart = {\n type: string;\n toolName?: string;\n};\n\n/** One group `MessagePrimitive.Unstable_PartsGrouped` renders through its `Group` component. */\nexport type MessagePartGroup = {\n groupKey: string | undefined;\n indices: number[];\n};\n\n/** The grouping contract `MessagePrimitive.Unstable_PartsGrouped` consumes. */\nexport type GroupingFunction = (parts: readonly GroupablePart[]) => MessagePartGroup[];\n\n/**\n * Groups adjacent parts by their toolkit group key: reasoning parts join the\n * open group, and a text part joins when the tool calls on both sides of it\n * share a key. Every `getToolGroupKey` call sees the open group's key and the\n * set of tools the message called, so a tool shared by several toolkits can\n * resolve to the one actually in play (Olympus attributes shared citation\n * tools to the enabled toolkit that way).\n */\nexport const createToolBasedGroupingFunction =\n (getToolGroupKey: GetToolGroupKey): GroupingFunction =>\n (parts) => {\n const calledToolNames = new Set<string>();\n for (const part of parts) {\n if (part.type === 'tool-call' && part.toolName) calledToolNames.add(part.toolName);\n }\n\n const groups: MessagePartGroup[] = [];\n let currentGroup: MessagePartGroup | null = null;\n\n for (let idx = 0; idx < parts.length; idx++) {\n const part = parts[idx];\n\n // Reasoning parts join the current group (if any).\n if (part?.type === 'reasoning') {\n if (currentGroup) {\n currentGroup.indices.push(idx);\n } else {\n groups.push({ groupKey: undefined, indices: [idx] });\n }\n continue;\n }\n\n let key: string | undefined;\n\n if (part?.type === 'tool-call' && part.toolName) {\n key = getToolGroupKey(part.toolName, {\n preferredGroupKey: currentGroup?.groupKey,\n calledToolNames,\n });\n } else if (part?.type === 'text') {\n const prevKey = currentGroup?.groupKey;\n\n let nextKey: string | undefined;\n for (let lookIdx = idx + 1; lookIdx < parts.length; lookIdx++) {\n const lookPart = parts[lookIdx];\n if (lookPart?.type === 'reasoning' || lookPart?.type === 'text') continue;\n if (lookPart?.type === 'tool-call' && lookPart.toolName) {\n nextKey = getToolGroupKey(lookPart.toolName, {\n preferredGroupKey: currentGroup?.groupKey,\n calledToolNames,\n });\n }\n break;\n }\n\n if (prevKey && nextKey && prevKey === nextKey) {\n key = prevKey;\n }\n }\n\n if (currentGroup && currentGroup.groupKey === key) {\n currentGroup.indices.push(idx);\n } else {\n if (currentGroup) groups.push(currentGroup);\n currentGroup = { groupKey: key, indices: [idx] };\n }\n }\n if (currentGroup) groups.push(currentGroup);\n return groups;\n };\n","/**\n * Static map of tool names → toolkit group display key, mirroring Olympus's\n * runtime `toolDefinitionsStore` output. The SDK doesn't ship a backend-fetched\n * toolkit catalog, so this provides the same grouping behavior using the names\n * the agent typically calls. Consumers can override via the `getToolGroupKey`\n * prop on `<AthenaChat>`.\n *\n * Keys here are toolkit *display* names (what users see in the toolkit\n * selector), not toolkit IDs — they match Olympus's\n * `getToolkitToGroupKeyMap()` output.\n */\nconst DEFAULT_TOOL_TO_TOOLKIT: Record<string, string> = {\n // Web\n search: 'Web',\n browse: 'Web',\n web_search: 'Web',\n search_web: 'Web',\n web_scrape: 'Web',\n scrape_web: 'Web',\n\n // Document\n create_new_document: 'Document',\n create_document_from_markdown: 'Document',\n append_markdown_to_athena_document: 'Document',\n replace_markdown_in_athena_document: 'Document',\n delete_blocks_from_athena_document: 'Document',\n convert_athena_doc_to_pdf: 'Document',\n convert_to_pdf: 'Document',\n\n // Word document (Studio)\n CreateDocument: 'Document (Word)',\n CreateParagraph: 'Document (Word)',\n OpenDocument: 'Document (Word)',\n execute_word_commands: 'Document (Word)',\n create_new_word_document: 'Document (Word)',\n\n // Spreadsheet\n create_new_sheet: 'Spreadsheet',\n update_sheet_range: 'Spreadsheet',\n format_sheet_range: 'Spreadsheet',\n bulk_format_sheet_range: 'Spreadsheet',\n create_table: 'Spreadsheet',\n update_table: 'Spreadsheet',\n create_chart: 'Spreadsheet',\n update_chart: 'Spreadsheet',\n // Studio sheet PTC\n CreateWorkbook: 'Spreadsheet',\n AddSheet: 'Spreadsheet',\n OpenWorkbook: 'Spreadsheet',\n\n // Presentation\n create_powerpoint_deck: 'Presentation',\n create_presentation_pptx_studio: 'Presentation',\n execute_presentation_code: 'Presentation',\n capture_slide_screenshot: 'Presentation',\n // Studio presentation PTC\n CreatePresentation: 'Presentation',\n OpenPresentation: 'Presentation',\n AddSlide: 'Presentation',\n\n // Notebook\n create_new_notebook: 'Notebook',\n run_notebook_cell: 'Notebook',\n\n // Python / code execution\n run_python_code: 'Python',\n run_python: 'Python',\n\n // Database\n run_sql: 'Database',\n run_database_sql: 'Database',\n run_sql_query_tool: 'Database',\n execute_sql: 'Database',\n describe_database: 'Database',\n list_database_tables: 'Database',\n get_database_table_schema: 'Database',\n\n // Email / calendar\n search_email: 'Email',\n unified_email_search: 'Email',\n\n // Media\n capture_moment: 'Computer',\n};\n\n/**\n * Tools that should never participate in grouping — even when surrounded by\n * tools of the same toolkit. Mirrors Olympus's `UNGROUPED_TOOLS`.\n */\nconst UNGROUPED_TOOLS: readonly string[] = [\n 'read_asset',\n 'read_full_asset',\n 'ask',\n 'open_asset_in_workspace',\n 'create_email_draft',\n 'unified_email_create_draft',\n 'unified_email_send',\n 'unified_email_edit_draft',\n];\n\n/**\n * Generic sandbox runtime tools shared across many toolkits (notebook,\n * computer, session sandbox, …). Mirrors Olympus's `CONTEXT_ONLY_TOOLS`:\n * they never start a toolkit group on their own — they only inherit the\n * surrounding group.\n */\nconst CONTEXT_ONLY_TOOLS: readonly string[] = [\n 'execute',\n 'ls',\n 'read_file',\n 'write_file',\n 'edit_file',\n 'glob',\n 'grep',\n];\n\n/**\n * Group display keys for toolkits that target a sandbox and therefore contain\n * the shared runtime tools. Context-only tools may only inherit these groups —\n * an open Web or Email group must not absorb a sandbox call.\n */\nconst SANDBOX_TOOLKIT_GROUPS: readonly string[] = ['Notebook', 'Computer', 'Session Sandbox'];\n\nexport type ToolGroupKeyOptions = {\n /** Display name of the surrounding group, when one is already open. */\n preferredGroupKey?: string;\n /**\n * Distinct tool names the message called. Hosts with a toolkit catalog use\n * it to attribute a tool shared by several toolkits to the one the message\n * leans on; the default map ignores it.\n */\n calledToolNames?: ReadonlySet<string>;\n};\n\n/**\n * Default `getToolGroupKey` implementation used by the SDK's tool grouping.\n * Returns the toolkit display key for a tool name, or `undefined` if the tool\n * is ungrouped or unknown. Context-only tools inherit the surrounding group\n * and are otherwise ungrouped.\n *\n * Override per-app by passing `getToolGroupKey` (or a whole `groupingFunction`) to\n * `SuperGroupingCard`.\n */\nexport const defaultGetToolGroupKey = (\n toolName: string,\n options?: ToolGroupKeyOptions\n): string | undefined => {\n if (UNGROUPED_TOOLS.includes(toolName)) return undefined;\n if (CONTEXT_ONLY_TOOLS.includes(toolName)) {\n const preferred = options?.preferredGroupKey;\n return preferred && SANDBOX_TOOLKIT_GROUPS.includes(preferred) ? preferred : undefined;\n }\n return DEFAULT_TOOL_TO_TOOLKIT[toolName];\n};\n\nexport type GetToolGroupKey = (\n toolName: string,\n options?: ToolGroupKeyOptions\n) => string | undefined;\n","import { useAuiState } from '@assistant-ui/react';\nimport { ChevronDown, ChevronUp } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useId, useMemo, useState } from 'react';\nimport { cn } from '../../lib/utils';\nimport { createToolBasedGroupingFunction, type GroupingFunction } from './grouping-function';\nimport { defaultGetToolGroupKey } from './toolkit-map';\n\n/**\n * Per-toolkit theme: the brand color that tints the group header, and an\n * optional icon URL a host serves (Olympus ships toolkit SVGs; the SDK does\n * not bundle images, so it tints only).\n */\nexport type ToolkitTheme = {\n /** Hex brand color for this toolkit. */\n color: string;\n /** Absolute or root-relative URL of the toolkit icon, when the host has one. */\n icon?: string;\n};\n\n/** Brand colors keyed by toolkit display name — the group keys the grouping function emits. */\nexport const TOOLKIT_THEMES: Record<string, ToolkitTheme> = {\n Web: { color: '#7BCCFA' },\n Document: { color: '#4586F9' },\n 'Document (Word)': { color: '#4586F9' },\n Notebook: { color: '#FFAB00' },\n Python: { color: '#00A76F' },\n Spreadsheet: { color: '#00A76F' },\n Email: { color: '#B584FF' },\n AOP: { color: '#336DFF' },\n App: { color: '#7336F5' },\n Presentation: { color: '#F56B36' },\n 'User Interface': { color: '#7336F5' },\n Canvas: { color: '#002542' },\n Computer: { color: '#3E0042' },\n Database: { color: '#7336F5' },\n 'Chrome Browser': { color: '#4285F4' },\n};\n\nexport const DEFAULT_TOOLKIT_THEME: ToolkitTheme = { color: '#919EAB' };\n\nconst DEFAULT_GROUPING = createToolBasedGroupingFunction(defaultGetToolGroupKey);\n\n/**\n * The grouping in force for the message being rendered. `SuperGroupingCard`\n * provides it so each `CollapsibleGroup` can tell whether it is the last\n * grouped block (the one that opens by default while the run is live) without\n * being handed the function as a prop through `Unstable_PartsGrouped`.\n */\nconst SuperGroupingContext = createContext<{ groupingFunction: GroupingFunction } | null>(null);\n\nexport const SuperGroupingProvider = SuperGroupingContext.Provider;\n\nexport interface CollapsibleGroupProps {\n /** Group key from the grouping function (toolkit display name); `undefined` for ungrouped parts. */\n groupKey: string | undefined;\n /** Indices of the parts belonging to this group. */\n indices: number[];\n children?: ReactNode;\n /** Host toolkit themes (colors, icons), merged over the built-in colors. */\n themes?: Record<string, ToolkitTheme>;\n /**\n * Keep the group open regardless of the run state — a host rule such as\n * \"an unsubmitted email draft stays visible\". The user's own toggle still\n * wins once used.\n */\n forceOpen?: boolean;\n /**\n * Do not open the live group by default (screenshot-heavy browser-control\n * runs hold hundreds of actions); the user can still expand it.\n */\n compactWhileRunning?: boolean;\n /** Extra header controls, rendered as siblings of the toggle (never nested buttons). */\n headerActions?: ReactNode;\n /** The grouping used to find the last grouped block; defaults to the card's, then the SDK's. */\n groupingFunction?: GroupingFunction;\n className?: string;\n}\n\n/**\n * Per-toolkit collapsible block inside the grouped details panel — \"Using\n * Spreadsheet Toolkit · 4 tool calls\" — used by the SDK, Olympus, and the\n * Chrome extension. The last grouped block opens by default while the message\n * is running and settles closed; the user's toggle is remembered for the\n * mounted block.\n *\n * Selector discipline: one raw `s.message.content` read; every per-group\n * derivation (grouping, counts) runs in `useMemo` off it, so the grouping\n * pass happens once per content change instead of once per selector pass.\n */\nexport const CollapsibleGroup = ({\n groupKey,\n indices,\n children,\n themes,\n forceOpen = false,\n compactWhileRunning = false,\n headerActions,\n groupingFunction,\n className,\n}: CollapsibleGroupProps) => {\n const panelId = useId();\n const isMessageRunning = useAuiState((s) => s.message.status?.type === 'running');\n const messageContent = useAuiState((s) =>\n s.message.role === 'assistant' ? s.message.content : undefined,\n );\n const contextGrouping = useContext(SuperGroupingContext)?.groupingFunction;\n const grouping = groupingFunction ?? contextGrouping ?? DEFAULT_GROUPING;\n\n const lastIndex = indices.at(-1);\n const isLastGroup = useMemo(() => {\n if (!messageContent) return false;\n const lastGroup = grouping(messageContent)\n .filter((group) => group.indices.length > 1)\n .at(-1);\n return lastGroup?.indices.at(-1) === lastIndex;\n }, [messageContent, grouping, lastIndex]);\n\n const toolCallCount = useMemo(\n () =>\n messageContent\n ? indices.reduce(\n (count, index) => (messageContent[index]?.type === 'tool-call' ? count + 1 : count),\n 0,\n )\n : 0,\n [messageContent, indices],\n );\n\n const theme = useMemo<ToolkitTheme>(\n () => (groupKey ? { ...TOOLKIT_THEMES, ...themes }[groupKey] ?? DEFAULT_TOOLKIT_THEME : DEFAULT_TOOLKIT_THEME),\n [groupKey, themes],\n );\n\n const [userOpened, setOpen] = useState<boolean>();\n const autoOpen = isLastGroup && isMessageRunning && !compactWhileRunning;\n const open = userOpened ?? (autoOpen || forceOpen);\n\n if (!groupKey || indices.length <= 1) return <>{children}</>;\n\n const toggle = () => setOpen(!open);\n\n return (\n <div\n data-slot=\"collapsible-group\"\n data-group-key={groupKey}\n className={cn('my-4 rounded-2xl border shadow-sm', className)}\n style={{\n borderColor: `${theme.color}33`,\n background: `linear-gradient(to right, ${theme.color}0d, transparent, ${theme.color}0d)`,\n }}\n >\n <div className=\"flex w-full items-center rounded-2xl\">\n <button\n type=\"button\"\n onClick={toggle}\n aria-expanded={open}\n aria-controls={panelId}\n className=\"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-2xl px-5 py-3 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/5\"\n >\n <span className=\"flex min-w-0 items-center gap-3 text-foreground/90\">\n {theme.icon ? (\n <img src={theme.icon} alt=\"\" aria-hidden=\"true\" className=\"size-5 shrink-0\" />\n ) : (\n <span\n className=\"inline-block size-2 shrink-0 rounded-full\"\n style={{ backgroundColor: theme.color }}\n aria-hidden=\"true\"\n />\n )}\n <span className=\"truncate text-sm font-semibold\">\n {isMessageRunning ? 'Using ' : 'Used '}\n {groupKey} Toolkit\n </span>\n </span>\n <span className=\"shrink-0 text-xs font-medium text-muted-foreground\">\n {toolCallCount} tool {toolCallCount === 1 ? 'call' : 'calls'}\n </span>\n </button>\n <div className=\"flex shrink-0 items-center gap-1 pr-3 pl-1\">\n {headerActions}\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={open ? 'Collapse toolkit group' : 'Expand toolkit group'}\n aria-expanded={open}\n aria-controls={panelId}\n className=\"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-black/5 dark:hover:bg-white/5\"\n >\n {open ? <ChevronUp size={16} /> : <ChevronDown size={16} />}\n </button>\n </div>\n </div>\n\n <div\n id={panelId}\n className={cn(\n 'grid overflow-hidden border-t transition-[grid-template-rows] duration-200 ease-in-out motion-reduce:transition-none',\n open ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',\n )}\n style={{ borderColor: `${theme.color}33` }}\n >\n <div className=\"overflow-hidden\">\n <div className=\"space-y-2 px-5 py-4\">{children}</div>\n </div>\n </div>\n </div>\n );\n};\n","'use client';\n\nimport type {\n ReasoningMessagePartComponent,\n TextMessagePartComponent,\n ThreadAssistantMessagePart,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n} from '@assistant-ui/react';\nimport { MessagePrimitive, useAuiState } from '@assistant-ui/react';\nimport {\n AlertCircle,\n Brain,\n Check,\n ChevronDown,\n ChevronRight,\n ChevronUp,\n Circle,\n Pause,\n X,\n} from 'lucide-react';\nimport {\n type ComponentType,\n memo,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../../lib/utils';\nimport { ToolFallback } from '../../tools/tool-fallback';\nimport {\n type ActivityItem,\n type ActivityPhase,\n buildActivityTimeline,\n countActivityTools,\n excludeFinalTextFromGroups,\n getActivityItemLabel,\n getActivitySummary,\n getFinalText,\n resolveActivityPhase,\n} from './activity-timeline';\nimport { CollapsibleGroup, type CollapsibleGroupProps, SuperGroupingProvider } from './CollapsibleGroup';\nimport { createToolBasedGroupingFunction, type GroupingFunction } from './grouping-function';\nimport { defaultGetToolGroupKey, type GetToolGroupKey } from './toolkit-map';\n\nconst DEFAULT_MAX_VISIBLE_STEPS = 3;\nconst MAX_REMEMBERED_EXPANSIONS = 200;\nconst EMPTY_TIMELINE: ActivityItem[] = [];\nconst EMPTY_CONTENT: readonly ThreadAssistantMessagePart[] = [];\n\n// ─── Disclosure memory ─────────────────────────────────────────────────\n\n/**\n * Session-local memory of which cards the user opened, keyed by the host's\n * expansion key (the message id by default; the Chrome extension keys by\n * thread + position so a streaming message keeps its choice when it receives\n * its stable id). Bounded so a long session cannot grow it without limit.\n */\nconst rememberedExpansions = new Map<string, boolean>();\n\nfunction rememberExpansion(key: string, expanded: boolean): void {\n rememberedExpansions.delete(key);\n rememberedExpansions.set(key, expanded);\n while (rememberedExpansions.size > MAX_REMEMBERED_EXPANSIONS) {\n const oldestKey = rememberedExpansions.keys().next().value;\n if (oldestKey === undefined) break;\n rememberedExpansions.delete(oldestKey);\n }\n}\n\nexport function resetRememberedExpansionsForTests(): void {\n rememberedExpansions.clear();\n}\n\n/**\n * The details disclosure: remembered per expansion key, and — when the host\n * opts in — opened once when the turn starts waiting on the person, so the\n * approval controls inside the details are visible without a click.\n */\nexport function useActivityExpansion({\n expansionKey,\n phase,\n expandWhileWaiting = false,\n}: {\n expansionKey: string;\n phase: ActivityPhase;\n expandWhileWaiting?: boolean;\n}) {\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>(() =>\n rememberedExpansions.get(expansionKey),\n );\n const [waitingAutoExpanded, setWaitingAutoExpanded] = useState(false);\n const previousRef = useRef({ expansionKey, phase });\n\n useEffect(() => {\n setUserExpanded(rememberedExpansions.get(expansionKey));\n setWaitingAutoExpanded(false);\n }, [expansionKey]);\n\n useEffect(() => {\n const previous = previousRef.current;\n if (expandWhileWaiting && previous.expansionKey === expansionKey) {\n if (previous.phase !== 'waiting' && phase === 'waiting') {\n setWaitingAutoExpanded(true);\n } else if (previous.phase === 'waiting' && phase !== 'waiting') {\n setWaitingAutoExpanded(false);\n }\n }\n previousRef.current = { expansionKey, phase };\n }, [expansionKey, phase, expandWhileWaiting]);\n\n const expanded =\n waitingAutoExpanded || (userExpanded ?? (expandWhileWaiting && phase === 'waiting'));\n const toggleExpanded = () => {\n const next = !expanded;\n setWaitingAutoExpanded(false);\n rememberExpansion(expansionKey, next);\n setUserExpanded(next);\n };\n\n return { expanded, toggleExpanded };\n}\n\n// ─── Pieces ────────────────────────────────────────────────────────────\n\nfunction PulsingDots() {\n return (\n <span className=\"inline-flex items-center gap-[3px]\" aria-hidden=\"true\">\n <span className=\"size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_infinite]\" />\n <span className=\"size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_0.2s_infinite]\" />\n <span className=\"size-[5px] rounded-full bg-foreground/80 animate-[aui-sg-pulse-dot_1.4s_ease-in-out_0.4s_infinite]\" />\n <style>{`\n @keyframes aui-sg-pulse-dot {\n 0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }\n 40% { opacity: 1; transform: scale(1); }\n }\n @keyframes aui-sg-shimmer-bar {\n 0% { transform: translateX(-100%); }\n 100% { transform: translateX(400%); }\n }\n `}</style>\n </span>\n );\n}\n\nfunction StepIcon({ item }: { item: ActivityItem }) {\n if (item.kind === 'reasoning') {\n return (\n <Brain\n aria-hidden=\"true\"\n className={cn(\n 'mt-[1px] size-3.5 shrink-0',\n item.state === 'running' ? 'text-blue-500 motion-safe:animate-pulse' : 'text-muted-foreground',\n )}\n />\n );\n }\n switch (item.state) {\n case 'complete':\n return <Check aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-emerald-500\" />;\n case 'rejected':\n return <X aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-muted-foreground\" />;\n case 'cancelled':\n return <Circle aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-muted-foreground\" />;\n case 'error':\n return <AlertCircle aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-destructive\" />;\n case 'waiting':\n return <Circle aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-amber-500\" />;\n case 'paused':\n return <Pause aria-hidden=\"true\" className=\"mt-[1px] size-3.5 shrink-0 text-amber-600\" />;\n case 'running':\n return (\n <span className=\"flex size-3.5 shrink-0 items-center justify-center\" aria-hidden=\"true\">\n <span className=\"size-1.5 rounded-full bg-blue-500 motion-safe:animate-pulse\" />\n </span>\n );\n }\n}\n\nfunction SummaryIcon({ timeline }: { timeline: readonly ActivityItem[] }) {\n const tools = timeline.filter((item) => item.kind === 'tool');\n if (tools.some((item) => item.state === 'error' || item.state === 'rejected')) {\n return <X aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-muted-foreground\" />;\n }\n if (tools.some((item) => item.state === 'cancelled')) {\n return <Circle aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-muted-foreground\" />;\n }\n if (tools.some((item) => item.state === 'paused')) {\n return <Pause aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-amber-600\" />;\n }\n return <Check aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-emerald-500\" />;\n}\n\n// ─── Card ──────────────────────────────────────────────────────────────\n\nexport interface SuperGroupingCardProps {\n /** Tool UIs to render inside the details panel, by tool name (registered tool UIs still apply). */\n toolUIs?: Record<string, ToolCallMessagePartComponent>;\n /** Fallback for tools without a UI; the SDK's `ToolFallback` by default. */\n ToolFallback?: ComponentType<ToolCallMessagePartProps>;\n /** Text renderer for the details panel. */\n TextComponent: TextMessagePartComponent;\n /** Reasoning renderer for the details panel. */\n ReasoningComponent?: ReasoningMessagePartComponent;\n /** Per-toolkit block inside the details panel; the SDK's `CollapsibleGroup` by default. */\n GroupComponent?: ComponentType<CollapsibleGroupProps>;\n /** Toolkit lookup driving the per-toolkit sub-grouping; the SDK's static map by default. */\n getToolGroupKey?: GetToolGroupKey;\n /** A complete grouping function, when the host builds its own (overrides `getToolGroupKey`). */\n groupingFunction?: GroupingFunction;\n /** Tools whose unresolved call means the turn is waiting on the person (see `buildActivityTimeline`). */\n waitingTools?: ReadonlySet<string>;\n /** Tools whose result is a relayed application payload (see `buildActivityTimeline`). */\n passThroughTools?: ReadonlySet<string>;\n /** Host assertion that the turn is waiting on the person (Olympus's allotment store). */\n waitingForInput?: boolean;\n /** Names tools the shared registry has no entry for (Olympus's tool catalog). */\n resolveToolDisplayName?: (toolName: string) => string | undefined;\n /** Key the disclosure choice is remembered under; the message id by default. */\n expansionKey?: string;\n /** Open the details once when the turn starts waiting on the person. */\n expandWhileWaiting?: boolean;\n /** How many latest steps the live list shows before folding the rest into \"N earlier steps\". */\n maxVisibleSteps?: number;\n /** Extra segments after the collapsed summary (\"1m 23s\", \"12.4k tokens\"), joined with \" · \". */\n summaryDetails?: readonly string[];\n /** Header controls beside the title (a stop button while running, a changes button once done). */\n renderHeaderActions?: (context: {\n phase: ActivityPhase;\n messageContent: readonly ThreadAssistantMessagePart[];\n }) => ReactNode;\n /** A line under the header while the turn is live (an elapsed timer). */\n renderRunningMeta?: (context: { phase: ActivityPhase }) => ReactNode;\n className?: string;\n classNames?: { root?: string; details?: string };\n}\n\n/**\n * The grouped (\"conversational\") view of an assistant turn: one \"Athena is\n * working\" card while the turn runs, listing its latest steps; a collapsed\n * \"Used N tools\" summary once it ends, with the full tool cards behind a\n * details disclosure. The answer itself renders below the card\n * (`SuperGroupingFinalText`). Shared by the SDK's `AthenaChat`, Olympus, and\n * the Chrome extension, which supply their own text/tool renderers and the\n * host-specific controls through the slots.\n *\n * The details panel stays mounted (visually hidden) while the turn is live so\n * the tool UIs inside run their effects — an asset-streaming card's follow\n * mode must not wait for \"Show details\".\n *\n * Selector discipline: raw reads only (`message.content`, `message.status`,\n * `message.id`); every derivation runs in `useMemo` — a selector that returned\n * a fresh array would tear through `useSyncExternalStore`.\n */\nexport const SuperGroupingCard = memo(function SuperGroupingCard({\n toolUIs,\n ToolFallback: ToolFallbackComponent = ToolFallback,\n TextComponent,\n ReasoningComponent,\n GroupComponent = CollapsibleGroup,\n getToolGroupKey = defaultGetToolGroupKey,\n groupingFunction,\n waitingTools,\n passThroughTools,\n waitingForInput = false,\n resolveToolDisplayName,\n expansionKey: expansionKeyProp,\n expandWhileWaiting = false,\n maxVisibleSteps = DEFAULT_MAX_VISIBLE_STEPS,\n summaryDetails,\n renderHeaderActions,\n renderRunningMeta,\n className,\n classNames,\n}: SuperGroupingCardProps) {\n const messageId = useAuiState((s) => s.message.id);\n const messageContent = useAuiState((s) =>\n s.message.role === 'assistant' ? s.message.content : EMPTY_CONTENT,\n );\n const messageStatus = useAuiState((s) => s.message.status);\n\n const timeline = useMemo(() => {\n const items = buildActivityTimeline(messageContent, messageStatus, {\n waitingTools,\n passThroughTools,\n });\n return items.length > 0 ? items : EMPTY_TIMELINE;\n }, [messageContent, messageStatus, waitingTools, passThroughTools]);\n const phase = useMemo(\n () => resolveActivityPhase(messageStatus, timeline, { waitingForInput }),\n [messageStatus, timeline, waitingForInput],\n );\n const toolCount = countActivityTools(timeline);\n\n const { expanded, toggleExpanded } = useActivityExpansion({\n expansionKey: expansionKeyProp ?? messageId,\n phase,\n expandWhileWaiting,\n });\n const generatedId = useId().replace(/[^A-Za-z0-9_-]/g, '');\n const detailsPanelId = `aui-sg-details-${generatedId}`;\n const statusId = `aui-sg-status-${generatedId}`;\n const primaryDisclosureRef = useRef<HTMLButtonElement>(null);\n\n const grouping = useMemo(\n () => excludeFinalTextFromGroups(groupingFunction ?? createToolBasedGroupingFunction(getToolGroupKey)),\n [groupingFunction, getToolGroupKey],\n );\n const groupingContext = useMemo(() => ({ groupingFunction: grouping }), [grouping]);\n const components = useMemo(\n () => ({\n tools: { ...(toolUIs ? { by_name: toolUIs } : {}), Fallback: ToolFallbackComponent },\n Text: TextComponent,\n ...(ReasoningComponent ? { Reasoning: ReasoningComponent } : {}),\n Group: GroupComponent,\n }),\n [toolUIs, ToolFallbackComponent, TextComponent, ReasoningComponent, GroupComponent],\n );\n\n const isActive = phase === 'running' || phase === 'waiting';\n const hasActivity = timeline.length > 0 || phase !== 'complete';\n if (!hasActivity) return null;\n\n const detailsMounted = isActive || expanded;\n const visibleItems = timeline.slice(-Math.max(1, maxVisibleSteps));\n const hiddenCount = timeline.length - visibleItems.length;\n const latestStatus =\n phase === 'waiting'\n ? 'Waiting for your input'\n : phase === 'error'\n ? 'Something went wrong'\n : timeline.length > 0\n ? getActivityItemLabel(timeline[timeline.length - 1], resolveToolDisplayName)\n : 'Planning approach';\n const summary = [getActivitySummary(timeline), ...(summaryDetails ?? [])].join(' · ');\n const headerActions = renderHeaderActions?.({ phase, messageContent });\n const runningMeta = isActive ? renderRunningMeta?.({ phase }) : null;\n\n const hideDetails = () => {\n toggleExpanded();\n queueMicrotask(() => primaryDisclosureRef.current?.focus());\n };\n\n return (\n <section\n data-slot=\"super-grouping-card\"\n data-phase={phase}\n data-tool-count={toolCount}\n className={cn(\n 'my-3 min-w-0 overflow-hidden rounded-2xl border transition-colors duration-200',\n phase === 'error'\n ? 'border-destructive/30 bg-destructive/5'\n : phase === 'waiting'\n ? 'border-amber-200 bg-amber-50/40 dark:border-amber-500/30 dark:bg-amber-500/10'\n : 'border-border/60 bg-muted/10',\n className,\n classNames?.root,\n )}\n aria-busy={phase === 'running' ? 'true' : 'false'}\n aria-describedby={statusId}\n >\n {phase === 'complete' ? (\n <div className=\"flex w-full items-center\">\n <button\n ref={primaryDisclosureRef}\n type=\"button\"\n onClick={toggleExpanded}\n aria-expanded={expanded}\n aria-controls={detailsPanelId}\n className=\"flex min-w-0 flex-1 items-center gap-2 px-4 py-3 text-left transition-colors hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring\"\n >\n <SummaryIcon timeline={timeline} />\n <span className=\"min-w-0 flex-1 truncate text-[12px] text-muted-foreground\">{summary}</span>\n </button>\n <div className=\"flex shrink-0 items-center gap-1 pr-3 pl-1\">\n {headerActions}\n <button\n type=\"button\"\n onClick={toggleExpanded}\n aria-label={expanded ? 'Hide run details' : 'Show run details'}\n aria-expanded={expanded}\n aria-controls={detailsPanelId}\n className=\"flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground\"\n >\n {expanded ? <ChevronDown className=\"size-3.5\" /> : <ChevronRight className=\"size-3.5\" />}\n </button>\n </div>\n </div>\n ) : (\n <>\n <div className=\"flex min-w-0 items-center justify-between gap-2 px-4 pt-4 pb-2\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <h3 className=\"truncate text-[13px] font-semibold text-foreground\">\n {phase === 'error'\n ? 'Something went wrong'\n : phase === 'waiting'\n ? 'Waiting for you'\n : 'Athena is working'}\n </h3>\n {phase === 'running' ? <PulsingDots /> : null}\n </div>\n {headerActions ? (\n <div className=\"flex shrink-0 items-center gap-1\">{headerActions}</div>\n ) : null}\n </div>\n\n {runningMeta ? <div className=\"px-4 pb-1\">{runningMeta}</div> : null}\n\n {phase === 'running' ? (\n <div className=\"px-4 pb-1\">\n <div className=\"h-[2px] w-full overflow-hidden rounded-full bg-muted/40\">\n <div className=\"h-full w-1/3 rounded-full bg-gradient-to-r from-blue-400 to-indigo-400 animate-[aui-sg-shimmer-bar_1.5s_ease-in-out_infinite] motion-reduce:animate-none\" />\n </div>\n </div>\n ) : null}\n\n {visibleItems.length > 0 ? (\n <ul className=\"space-y-1 px-4 pt-1.5 pb-1\" aria-label=\"Work status updates\">\n {hiddenCount > 0 ? (\n <li className=\"pl-[22px] text-[11px] text-muted-foreground/70\">\n {hiddenCount} earlier {hiddenCount === 1 ? 'step' : 'steps'}\n </li>\n ) : null}\n {visibleItems.map((item, index) => (\n <li\n key={`${item.kind}-${hiddenCount + index}`}\n className=\"flex min-w-0 items-start gap-2 text-[12px]\"\n >\n <StepIcon item={item} />\n {item.kind === 'reasoning' ? (\n item.text.trim() ? (\n <span className=\"line-clamp-2 min-w-0 flex-1 italic leading-relaxed text-muted-foreground\">\n {item.text}\n </span>\n ) : (\n <span className=\"shimmer min-w-0 flex-1 leading-relaxed text-muted-foreground\">\n Thinking…\n </span>\n )\n ) : (\n <span\n className={cn(\n 'min-w-0 flex-1 truncate leading-relaxed',\n item.state === 'complete' ? 'text-muted-foreground/70' : 'text-foreground/80',\n )}\n >\n {getActivityItemLabel(item, resolveToolDisplayName)}\n </span>\n )}\n </li>\n ))}\n </ul>\n ) : (\n <div className=\"px-4 pt-1 pb-2\">\n <span className=\"shimmer text-[12px] text-muted-foreground\">Planning approach...</span>\n </div>\n )}\n\n <div className=\"px-4 pb-3 pt-0.5\">\n <button\n ref={primaryDisclosureRef}\n type=\"button\"\n onClick={toggleExpanded}\n aria-expanded={expanded}\n aria-controls={detailsPanelId}\n className=\"flex items-center gap-1 rounded px-1 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {expanded ? <ChevronDown className=\"size-3\" /> : <ChevronRight className=\"size-3\" />}\n {expanded ? 'Hide details' : 'Show details'}\n </button>\n </div>\n </>\n )}\n\n <output id={statusId} aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {latestStatus}\n </output>\n\n {detailsMounted ? (\n <div\n id={detailsPanelId}\n role=\"region\"\n aria-label=\"Run details\"\n hidden={!expanded}\n className={cn(\n 'space-y-2 overflow-hidden border-t border-border/60 bg-background/80 px-4 py-4',\n classNames?.details,\n )}\n >\n <SuperGroupingProvider value={groupingContext}>\n <MessagePrimitive.Unstable_PartsGrouped groupingFunction={grouping} components={components} />\n </SuperGroupingProvider>\n <button\n type=\"button\"\n onClick={hideDetails}\n aria-controls={detailsPanelId}\n aria-expanded=\"true\"\n className=\"mx-auto mt-3 flex items-center gap-1 rounded-md px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <ChevronUp className=\"size-3\" />\n Hide details\n </button>\n </div>\n ) : null}\n </section>\n );\n});\n\n/**\n * The turn's visible answer, rendered below the card: the text after the last\n * tool call (all of it when the turn called no tools), streaming while the\n * turn is live so the person reads the answer as it arrives.\n */\nexport const SuperGroupingFinalText = memo(function SuperGroupingFinalText({\n TextComponent,\n}: {\n TextComponent: TextMessagePartComponent;\n}) {\n const messageContent = useAuiState((s) =>\n s.message.role === 'assistant' ? s.message.content : EMPTY_CONTENT,\n );\n const statusType = useAuiState((s) => s.message.status?.type);\n const finalText = useMemo(() => getFinalText(messageContent), [messageContent]);\n\n if (!finalText) return null;\n return (\n <TextComponent\n type=\"text\"\n text={finalText}\n status={\n statusType === 'running' || statusType === 'requires-action'\n ? { type: 'running' }\n : { type: 'complete' }\n }\n />\n );\n});\n"],"names":["createLucideIcon","readRejectedToolResult","classifyToolResult","toolStatusLabel","createContext","useId","useAuiState","_a","useContext","useMemo","useState","jsxs","cn","jsx","ChevronDown","useRef","useEffect","Brain","Check","X","Circle","AlertCircle","Pause","memo","SuperGroupingCard","ToolFallback","ChevronRight","Fragment","MessagePrimitive","SuperGroupingFinalText"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,a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,MAAM,yBAAyBU,MAAAA,KAAK,SAASM,wBAAuB;AAAA,EACzE;AACF,GAEG;AACD,QAAM,iBAAiBvB,MAAAA;AAAAA,IAAY,CAAC,MAClC,EAAE,QAAQ,SAAS,cAAc,EAAE,QAAQ,UAAU;AAAA,EAAA;AAEvD,QAAM,aAAaA,MAAAA,YAAY,CAAC;;AAAM,mBAAE,QAAQ,WAAV,mBAAkB;AAAA,GAAI;AAC5D,QAAM,YAAYG,MAAAA,QAAQ,MAAM,aAAa,cAAc,GAAG,CAAC,cAAc,CAAC;AAE9E,MAAI,CAAC,UAAW,QAAO;AACvB,SACEI,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAM;AAAA,MACN,QACE,eAAe,aAAa,eAAe,oBACvC,EAAE,MAAM,UAAA,IACR,EAAE,MAAM,WAAA;AAAA,IAAW;AAAA,EAAA;AAI/B,CAAC;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -1,5 +1,33 @@
1
1
  import type { StatewireThread } from '@assistant-ui/react-statewire';
2
- import type { FC } from 'react';
2
+ import { type HitlApprovalPayload, type PendingActionRequest } from '@athenaintel/agent-runtime';
3
+ import { type FC, type ReactNode } from 'react';
4
+ import { type StatewireInterruptPredicate } from './use-statewire-approval-request';
5
+ /**
6
+ * Human-in-the-loop approval card for the statewire transport — the one
7
+ * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the
8
+ * Chrome side panel, the Office task pane, Olympus).
9
+ *
10
+ * When the deep-agent runtime hits an approval-gated tool call, the backend
11
+ * parks the run on an `interrupt` input request. This card reads that request
12
+ * through `useStatewireApprovalRequest` and answers it with
13
+ * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —
14
+ * the exact command the backend's resume path consumes. Without an answer the
15
+ * run stays parked forever, so this card must be mounted on every statewire
16
+ * chat surface. On legacy (non-statewire) threads it renders nothing.
17
+ *
18
+ * Host-specific review UIs (subagent cards, email summaries) slot in through
19
+ * `renderDetails`; requests another surface answers (typed interrupt
20
+ * families, per-lane subagent approvals) stand down through
21
+ * `isHandledElsewhere`; viewers without edit rights see `readOnlyNotice`.
22
+ */
23
+ /** The pending request a host slot renders or judges. */
24
+ export interface StatewireApprovalRequestContext {
25
+ request: StatewireThread.CustomInputRequest;
26
+ /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */
27
+ hitl: HitlApprovalPayload | null;
28
+ /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */
29
+ actionRequests: PendingActionRequest[];
30
+ }
3
31
  export interface StatewireApprovalCardProps {
4
32
  /** Surface-styling overrides merged onto the default classes. */
5
33
  classNames?: {
@@ -7,6 +35,10 @@ export interface StatewireApprovalCardProps {
7
35
  root?: string;
8
36
  /** The "approval was cancelled" notice container. */
9
37
  abandoned?: string;
38
+ /** The disclosed details block. */
39
+ details?: string;
40
+ /** The decision row. */
41
+ actions?: string;
10
42
  };
11
43
  /** Copy shown when an interrupt payload carries no message. */
12
44
  fallbackMessage?: string;
@@ -15,6 +47,31 @@ export interface StatewireApprovalCardProps {
15
47
  * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way
16
48
  * unless the surface handles those itself).
17
49
  */
18
- interruptPredicate?: (request: StatewireThread.InputRequestState) => request is StatewireThread.CustomInputRequest;
50
+ interruptPredicate?: StatewireInterruptPredicate;
51
+ /**
52
+ * How long a clicked decision keeps the buttons locked when no resume run
53
+ * ever starts (a `run/input` the host rejected before any run began).
54
+ * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.
55
+ */
56
+ pendingResumeGraceMs?: number;
57
+ /**
58
+ * Return true when another surface answers this request (a typed Athena
59
+ * interrupt family, per-lane subagent approval cards). The card renders
60
+ * nothing for it — two surfaces must never answer the same input request.
61
+ */
62
+ isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;
63
+ /**
64
+ * Replace the default argument disclosure (one JSON block per gated call)
65
+ * with a host-specific review UI. Rendered inside the collapsible details
66
+ * region; the decision buttons stay with the card.
67
+ */
68
+ renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;
69
+ /**
70
+ * The viewer may see the request (it explains why the run is parked) but
71
+ * cannot decide it — answering steers the shared run. Renders
72
+ * `readOnlyNotice` in place of the buttons.
73
+ */
74
+ readOnly?: boolean;
75
+ readOnlyNotice?: ReactNode;
19
76
  }
20
77
  export declare const StatewireApprovalCard: FC<StatewireApprovalCardProps>;
@@ -1,4 +1,4 @@
1
- import type { StatewireClientTool } from './statewire-client-tools';
1
+ import { type RegisteredClientTool } from '@athenaintel/agent-runtime';
2
2
  /**
3
3
  * Executes the deep agent's frontend tool calls in statewire mode.
4
4
  *
@@ -10,9 +10,9 @@ import type { StatewireClientTool } from './statewire-client-tools';
10
10
  *
11
11
  * The claim lifecycle, liveness guards, and wire-safety live in
12
12
  * `@athenaintel/agent-runtime`'s `useStatewireClientToolBridge`; this wrapper
13
- * only adapts the SDK's toolkit-derived tool shape and transport.
13
+ * only adapts the shared `RegisteredClientTool` shape and the SDK's transport.
14
14
  */
15
15
  export declare function StatewireClientToolBridge({ tools, threadId, }: {
16
- tools: readonly StatewireClientTool[];
16
+ tools: readonly RegisteredClientTool[];
17
17
  threadId: string;
18
18
  }): null;
@@ -1,8 +1,107 @@
1
- import { type FC } from 'react';
1
+ import type { StatewireThread } from '@assistant-ui/react-statewire';
2
+ import { type DeepAgentThreadStatus } from '@athenaintel/agent-runtime';
3
+ import { type FC, type ReactNode } from 'react';
4
+ declare module '@assistant-ui/core' {
5
+ namespace Assistant {
6
+ interface Commands {
7
+ /**
8
+ * The ⚡ on a queued row (`DeepAgentThread.run_prioritize`). With
9
+ * `priority: true` the host moves the entry to the head of the queue
10
+ * lane (behind entries prioritized before it), records it durably, and
11
+ * the live run ends at its next model-call boundary — after the
12
+ * in-flight tool chain, never mid-tool — so the settle delivers the
13
+ * entry on top of the finished tool results instead of after the whole
14
+ * turn. `priority: false` withdraws the request and leaves the entry
15
+ * where it is.
16
+ */
17
+ runPrioritize: {
18
+ type: 'run/prioritize';
19
+ runId: string;
20
+ messageId: string;
21
+ priority: boolean;
22
+ };
23
+ }
24
+ }
25
+ }
2
26
  /**
3
- * Controls for the server-owned statewire queue and steer lanes: a message
4
- * sent mid-run queues behind the active run; entries can be removed or
5
- * steered in ("Send now"), and a stopped run can continue with its queue.
6
- * Renders nothing on the legacy transport or when the queue is empty.
27
+ * The one queued-messages tray for the server-owned statewire queue and steer
28
+ * lanes, mounted by the SDK's `AthenaChat`, the Chrome side panel, the Office
29
+ * task pane, and Olympus.
30
+ *
31
+ * A message sent mid-run queues behind the active run. Rows offer "Send now"
32
+ * (a steer-lane move — the host stops the run and dispatches it once the run
33
+ * settles; on a stopped/errored thread the same move dispatches immediately),
34
+ * "Prioritize" (`run/prioritize`, the ⚡ — the non-interrupting analog: the
35
+ * live run ends at its next model-call boundary so the entry lands on top of
36
+ * the finished tool results), inline edit (re-sent under the entry's own id
37
+ * on its own lane, which the host folds as an in-place content update), and
38
+ * remove (`run/dequeue`). While the thread rests stopped/errored, stranded
39
+ * steer-lane entries list ahead of the queue (they dispatch first, as one
40
+ * batch, so they carry Remove but no per-row Send now) and a Continue pill
41
+ * steer-promotes the queue head — a steer entry moved onto its own lane is a
42
+ * no-op, so a steer-only rest state gets no dead button.
43
+ *
44
+ * A row whose send has not settled yet (`isQueueEntryUnsettled` — this
45
+ * client's optimistic fold, not a host-admitted lane entry) renders as
46
+ * "Sending…" with no acting affordances: admission is server-side and can
47
+ * still refuse the message. Failed run sends (`runs.failed`) list after the
48
+ * lanes with Retry (`retryFailed`) and Discard (`discardFailed`).
49
+ *
50
+ * With `autoContinue`, a stranded settle (a dispatch that died before its
51
+ * first checkpoint, a pod drain, a failed run) steer-promotes the queue head
52
+ * on its own after `QUEUE_AUTO_CONTINUE_DELAY_MS`, once per entry — except
53
+ * past an acknowledged user stop, where the manual pill stays the only way on.
54
+ *
55
+ * Renders nothing on the legacy transport or when every lane is empty.
7
56
  */
8
- export declare const StatewireQueuedMessages: FC;
57
+ export type StatewireQueueEvent = {
58
+ type: 'auto-continued';
59
+ threadId: string | null;
60
+ status: DeepAgentThreadStatus;
61
+ headEntryId: string;
62
+ } | {
63
+ type: 'failed-send-action-raced';
64
+ threadId: string | null;
65
+ messageId: string;
66
+ action: 'retry' | 'discard';
67
+ error: string;
68
+ };
69
+ export interface StatewireQueueRowContentContext {
70
+ text: string;
71
+ index: number;
72
+ item: StatewireThread.RunsQueueEntry;
73
+ }
74
+ export interface StatewireQueueEditorContext {
75
+ value: string;
76
+ onChange: (value: string) => void;
77
+ /** Save the edit; a blank or unchanged text sends nothing but closes the editor. */
78
+ onSave: (text: string) => void;
79
+ onCancel: () => void;
80
+ }
81
+ export interface StatewireQueuedMessagesProps {
82
+ /** Surface-styling overrides merged onto the default classes. */
83
+ classNames?: {
84
+ /** The tray container. */
85
+ root?: string;
86
+ /** The row list. */
87
+ list?: string;
88
+ };
89
+ /**
90
+ * Steer-promote a stranded queue head automatically after a settle (see the
91
+ * component docs). Off by default: a host opts in to dispatching runs on the
92
+ * user's behalf. Pass `{ delayMs }` to tune the grace before the promotion
93
+ * (defaults to `QUEUE_AUTO_CONTINUE_DELAY_MS`).
94
+ */
95
+ autoContinue?: boolean | {
96
+ delayMs?: number;
97
+ };
98
+ /** Identifies the thread for once-per-entry auto-continue attempts and events. */
99
+ threadId?: string | null;
100
+ /** Telemetry sink for the tray's notable moments. */
101
+ onEvent?: (event: StatewireQueueEvent) => void;
102
+ /** Replace the plain-text row body (e.g. a mention-aware renderer). */
103
+ renderContent?: (context: StatewireQueueRowContentContext) => ReactNode;
104
+ /** Replace the plain textarea inline editor (e.g. the host's composer editor). */
105
+ renderEditor?: (context: StatewireQueueEditorContext) => ReactNode;
106
+ }
107
+ export declare const StatewireQueuedMessages: FC<StatewireQueuedMessagesProps>;
@@ -4,4 +4,4 @@
4
4
  * module so existing `@athenaintel/react` imports (and the package's public
5
5
  * exports) stay stable.
6
6
  */
7
- export { asHitlApproval, hasStatewireThreadExtras, type HitlApprovalPayload, isApprovalCardInterrupt, isPendingInterrupt, readInterruptMessage, } from '@athenaintel/agent-runtime';
7
+ export { asHitlApproval, hasStatewireThreadExtras, HITL_PENDING_RESUME_GRACE_MS, type HitlApprovalPayload, isApprovalCardInterrupt, isPendingInterrupt, readInterruptMessage, } from '@athenaintel/agent-runtime';
@@ -1,17 +1,13 @@
1
1
  import type { FC } from 'react';
2
2
  /**
3
- * Dismissible transport-error banner for statewire mode: send rejections,
4
- * paywall refusals, and command failures that would otherwise vanish into
5
- * the console after the composer already cleared. Renders nothing on the
6
- * legacy transport.
3
+ * Dismissible transport-error banner: send rejections (including the
4
+ * pre-cutover-thread dispatch fence's 409), paywall refusals, and command
5
+ * failures that would otherwise vanish into the console after the composer
6
+ * already cleared. Renders nothing outside `AthenaProvider`.
7
7
  */
8
8
  export declare const StatewireErrorBanner: FC;
9
9
  /**
10
10
  * Degraded-connection strip: shown only while the statewire channel is
11
- * reconnecting or gone, with a manual reconnect affordance when the
12
- * transport exposes one. Healthy states render nothing.
11
+ * degraded, with a manual reconnect affordance when the transport exposes one.
13
12
  */
14
13
  export declare const StatewireConnectionBanner: FC;
15
- /** Read-only notice for pre-cutover threads whose history lives under the
16
- * legacy runtime; the server fences dispatch into them. */
17
- export declare const StatewireLegacyReadOnlyBanner: FC;
@@ -1,22 +1,14 @@
1
1
  import type { Toolkit } from '@assistant-ui/react';
2
- import { toJSONSchema } from 'assistant-stream';
3
- type StatewireToolParameters = ReturnType<typeof toJSONSchema>;
4
- interface StatewireClientToolWireEntry extends Record<string, unknown> {
5
- name: string;
6
- description: string;
7
- parameters: StatewireToolParameters;
8
- requires_write: false;
9
- }
10
- export interface StatewireClientTool {
11
- name: string;
12
- description?: string;
13
- parameters: StatewireToolParameters;
14
- handler: (args: Record<string, unknown>, context: {
15
- toolCallId: string;
16
- }) => Promise<unknown>;
17
- }
2
+ import { type RegisteredClientTool } from '@athenaintel/agent-runtime';
18
3
  /**
19
- * Collect the client-executable tools from a frontend toolkit.
4
+ * @deprecated The SDK's client tools ARE the shared `RegisteredClientTool`
5
+ * shape from `@athenaintel/agent-runtime` (`definition` + `handler`); import
6
+ * that type instead. Retained for one release so existing imports type-check.
7
+ */
8
+ export type StatewireClientTool = RegisteredClientTool;
9
+ /**
10
+ * Collect the client-executable tools from a frontend toolkit, in the shared
11
+ * `RegisteredClientTool` shape every statewire surface declares and executes.
20
12
  *
21
13
  * The deep-agent runtime drops frontend (`ui_*`) tool definitions, so tools
22
14
  * with a local `execute` must instead be declared through
@@ -24,8 +16,10 @@ export interface StatewireClientTool {
24
16
  * bridge. Schema conversion reuses `toJSONSchema` — the same conversion
25
17
  * primitive as the legacy assistant-transport — and a tool whose schema cannot
26
18
  * be converted is skipped with a warning rather than failing the whole set.
19
+ * SDK tools never gate on write consent (`requiresWrite: false`): a toolkit
20
+ * `execute` is the host app's own code.
27
21
  */
28
- export declare function collectStatewireClientTools(toolkit: Toolkit): StatewireClientTool[];
29
- /** Wire entries for `runConfig.custom.client_tools`. */
30
- export declare function statewireClientToolWireEntries(tools: readonly StatewireClientTool[]): StatewireClientToolWireEntry[];
31
- export {};
22
+ export declare function collectStatewireClientTools(toolkit: Toolkit): RegisteredClientTool[];
23
+ /** Wire entries for `runConfig.custom.client_tools` — the shared contract from
24
+ * `@athenaintel/agent-runtime`, so the SDK cannot drift from the other surfaces. */
25
+ export declare function statewireClientToolWireEntries(tools: readonly RegisteredClientTool[]): Record<string, unknown>[];
@@ -1,15 +1,56 @@
1
- import type { PropsWithChildren } from 'react';
2
- export type CollapsibleGroupProps = PropsWithChildren<{
3
- /** Group key from the grouping function (toolkit display name). */
4
- groupKey?: string;
1
+ import type { ReactNode } from 'react';
2
+ import { type GroupingFunction } from './grouping-function';
3
+ /**
4
+ * Per-toolkit theme: the brand color that tints the group header, and an
5
+ * optional icon URL a host serves (Olympus ships toolkit SVGs; the SDK does
6
+ * not bundle images, so it tints only).
7
+ */
8
+ export type ToolkitTheme = {
9
+ /** Hex brand color for this toolkit. */
10
+ color: string;
11
+ /** Absolute or root-relative URL of the toolkit icon, when the host has one. */
12
+ icon?: string;
13
+ };
14
+ /** Brand colors keyed by toolkit display name — the group keys the grouping function emits. */
15
+ export declare const TOOLKIT_THEMES: Record<string, ToolkitTheme>;
16
+ export declare const DEFAULT_TOOLKIT_THEME: ToolkitTheme;
17
+ export declare const SuperGroupingProvider: import("react").Provider<{
18
+ groupingFunction: GroupingFunction;
19
+ } | null>;
20
+ export interface CollapsibleGroupProps {
21
+ /** Group key from the grouping function (toolkit display name); `undefined` for ungrouped parts. */
22
+ groupKey: string | undefined;
5
23
  /** Indices of the parts belonging to this group. */
6
24
  indices: number[];
7
- }>;
25
+ children?: ReactNode;
26
+ /** Host toolkit themes (colors, icons), merged over the built-in colors. */
27
+ themes?: Record<string, ToolkitTheme>;
28
+ /**
29
+ * Keep the group open regardless of the run state — a host rule such as
30
+ * "an unsubmitted email draft stays visible". The user's own toggle still
31
+ * wins once used.
32
+ */
33
+ forceOpen?: boolean;
34
+ /**
35
+ * Do not open the live group by default (screenshot-heavy browser-control
36
+ * runs hold hundreds of actions); the user can still expand it.
37
+ */
38
+ compactWhileRunning?: boolean;
39
+ /** Extra header controls, rendered as siblings of the toggle (never nested buttons). */
40
+ headerActions?: ReactNode;
41
+ /** The grouping used to find the last grouped block; defaults to the card's, then the SDK's. */
42
+ groupingFunction?: GroupingFunction;
43
+ className?: string;
44
+ }
8
45
  /**
9
- * Per-toolkit collapsible block used inside the SuperGroupingCard details
10
- * panel. Ported from `olympus/src/components/CollapsibleGroup.tsx`. The
11
- * Olympus version also gates "auto-stay-open" on unsubmitted email/calendar
12
- * drafts (`useMessageMetadata` + `EMAIL_TOOLKIT_GROUP`); the SDK doesn't have
13
- * those metadata fields, so that branch is dropped.
46
+ * Per-toolkit collapsible block inside the grouped details panel — "Using
47
+ * Spreadsheet Toolkit · 4 tool calls" — used by the SDK, Olympus, and the
48
+ * Chrome extension. The last grouped block opens by default while the message
49
+ * is running and settles closed; the user's toggle is remembered for the
50
+ * mounted block.
51
+ *
52
+ * Selector discipline: one raw `s.message.content` read; every per-group
53
+ * derivation (grouping, counts) runs in `useMemo` off it, so the grouping
54
+ * pass happens once per content change instead of once per selector pass.
14
55
  */
15
- export declare const CollapsibleGroup: ({ groupKey, indices, children }: CollapsibleGroupProps) => import("react/jsx-runtime").JSX.Element;
56
+ export declare const CollapsibleGroup: ({ groupKey, indices, children, themes, forceOpen, compactWhileRunning, headerActions, groupingFunction, className, }: CollapsibleGroupProps) => import("react/jsx-runtime").JSX.Element;