@athenaintel/react 0.30.0 → 0.32.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 (147) hide show
  1. package/README.md +61 -0
  2. package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
  3. package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
  4. package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
  5. package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
  6. package/dist/agent-runtime/src/config-mutations.cjs +59 -0
  7. package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
  8. package/dist/agent-runtime/src/config-mutations.js +59 -0
  9. package/dist/agent-runtime/src/config-mutations.js.map +1 -0
  10. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +6 -0
  11. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  12. package/dist/agent-runtime/src/generated/runconfig-contract.js +6 -0
  13. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  14. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +48 -0
  15. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  16. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +49 -1
  17. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  18. package/dist/agent-runtime/src/tool-metadata.cjs +25 -6
  19. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  20. package/dist/agent-runtime/src/tool-metadata.js +25 -6
  21. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  22. package/dist/agent-runtime/src/use-deep-agent-config.cjs +117 -1
  23. package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
  24. package/dist/agent-runtime/src/use-deep-agent-config.js +118 -2
  25. package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -1
  26. package/dist/assets/AthenaAssetEmbed.cjs +6 -1
  27. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  28. package/dist/assets/AthenaAssetEmbed.d.ts +2 -0
  29. package/dist/assets/AthenaAssetEmbed.js +7 -2
  30. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  31. package/dist/assets/asset-embed-messages.cjs +6 -0
  32. package/dist/assets/asset-embed-messages.cjs.map +1 -1
  33. package/dist/assets/asset-embed-messages.d.ts +7 -0
  34. package/dist/assets/asset-embed-messages.js +6 -0
  35. package/dist/assets/asset-embed-messages.js.map +1 -1
  36. package/dist/chat/AthenaChat.cjs +41 -26
  37. package/dist/chat/AthenaChat.cjs.map +1 -1
  38. package/dist/chat/AthenaChat.js +41 -26
  39. package/dist/chat/AthenaChat.js.map +1 -1
  40. package/dist/chat/super-grouping/SuperGroupingCard.cjs +31 -11
  41. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  42. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +14 -3
  43. package/dist/chat/super-grouping/SuperGroupingCard.js +32 -12
  44. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  45. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +80 -53
  46. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  47. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  48. package/dist/chat/super-grouping/SuperGroupingTranscript.js +81 -54
  49. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  50. package/dist/chat/super-grouping/activity-timeline.cjs +19 -4
  51. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  52. package/dist/chat/super-grouping/activity-timeline.d.ts +20 -1
  53. package/dist/chat/super-grouping/activity-timeline.js +19 -4
  54. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  55. package/dist/chat/super-grouping/index.cjs +2 -0
  56. package/dist/chat/super-grouping/index.cjs.map +1 -1
  57. package/dist/chat/super-grouping/index.d.ts +1 -1
  58. package/dist/chat/super-grouping/index.js +3 -1
  59. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  60. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  61. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  62. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  63. package/dist/chat-ui/composer/tiptap-composer.cjs +40 -4
  64. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  65. package/dist/chat-ui/composer/tiptap-composer.js +40 -4
  66. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  67. package/dist/chat-ui/mentions/mention-chip.cjs +29 -2
  68. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  69. package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
  70. package/dist/chat-ui/mentions/mention-chip.js +30 -3
  71. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  72. package/dist/chat-ui/mentions/mention-extension.cjs +1 -1
  73. package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
  74. package/dist/chat-ui/mentions/mention-extension.js +1 -1
  75. package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
  76. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
  77. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
  78. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
  79. package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
  80. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
  81. package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
  82. package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
  83. package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
  84. package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
  85. package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
  86. package/dist/collab/client.cjs +80 -19
  87. package/dist/collab/client.cjs.map +1 -1
  88. package/dist/collab/client.d.ts +22 -0
  89. package/dist/collab/client.js +80 -19
  90. package/dist/collab/client.js.map +1 -1
  91. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  92. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  93. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  94. package/dist/index.cjs +4 -0
  95. package/dist/index.cjs.map +1 -1
  96. package/dist/index.d.ts +3 -1
  97. package/dist/index.js +5 -1
  98. package/dist/index.js.map +1 -1
  99. package/dist/provider/AthenaProvider.cjs +34 -4
  100. package/dist/provider/AthenaProvider.cjs.map +1 -1
  101. package/dist/provider/AthenaProvider.d.ts +7 -1
  102. package/dist/provider/AthenaProvider.js +36 -6
  103. package/dist/provider/AthenaProvider.js.map +1 -1
  104. package/dist/react/package.json.cjs +1 -1
  105. package/dist/react/package.json.js +1 -1
  106. package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
  107. package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
  108. package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
  109. package/dist/runtime/StatewireModelLaneSync.js +96 -0
  110. package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
  111. package/dist/runtime/statewire-lifecycle.cjs +5 -2
  112. package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
  113. package/dist/runtime/statewire-lifecycle.d.ts +5 -0
  114. package/dist/runtime/statewire-lifecycle.js +5 -2
  115. package/dist/runtime/statewire-lifecycle.js.map +1 -1
  116. package/dist/runtime/statewire-model-lane.cjs +28 -0
  117. package/dist/runtime/statewire-model-lane.cjs.map +1 -0
  118. package/dist/runtime/statewire-model-lane.d.ts +64 -0
  119. package/dist/runtime/statewire-model-lane.js +28 -0
  120. package/dist/runtime/statewire-model-lane.js.map +1 -0
  121. package/dist/runtime/statewire-run-config.cjs +16 -2
  122. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  123. package/dist/runtime/statewire-run-config.d.ts +10 -0
  124. package/dist/runtime/statewire-run-config.js +16 -2
  125. package/dist/runtime/statewire-run-config.js.map +1 -1
  126. package/dist/runtime/statewire-server-lane-context.cjs +24 -0
  127. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
  128. package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
  129. package/dist/runtime/statewire-server-lane-context.js +24 -0
  130. package/dist/runtime/statewire-server-lane-context.js.map +1 -0
  131. package/dist/runtime/useAthenaStatewireRuntime.cjs +38 -18
  132. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  133. package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
  134. package/dist/runtime/useAthenaStatewireRuntime.js +39 -19
  135. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  136. package/dist/styles.css +1 -1
  137. package/dist/threads/api.cjs +2 -1
  138. package/dist/threads/api.cjs.map +1 -1
  139. package/dist/threads/api.d.ts +1 -0
  140. package/dist/threads/api.js +2 -1
  141. package/dist/threads/api.js.map +1 -1
  142. package/dist/threads/use-athena-thread-model.cjs +14 -0
  143. package/dist/threads/use-athena-thread-model.cjs.map +1 -0
  144. package/dist/threads/use-athena-thread-model.d.ts +22 -0
  145. package/dist/threads/use-athena-thread-model.js +14 -0
  146. package/dist/threads/use-athena-thread-model.js.map +1 -0
  147. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"activity-timeline.cjs","sources":["../../../src/chat/super-grouping/activity-timeline.ts"],"sourcesContent":["/**\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 * summary registry (`summarizeToolCall`), itself built on the display\n * registry.\n */\nimport type {\n MessageStatus,\n ThreadAssistantMessagePart,\n ToolCallMessagePartStatus,\n} from '@assistant-ui/react';\nimport {\n classifyToolResult,\n isSpokenTurnTextPart,\n readRejectedToolResult,\n type ToolStatusLabelState,\n} from '@athenaintel/agent-runtime';\nimport { summarizeToolCall, type ToolCallSummary } from '../../tools/tool-summary';\nimport type { GroupingFunction } from './grouping-function';\n\nexport type ActivityToolState = ToolStatusLabelState;\n\nexport type ActivityItem =\n | {\n kind: 'reasoning';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n text: string;\n state: 'running' | 'complete';\n }\n | {\n kind: 'tool';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n toolName: string;\n args?: ToolCallPart['args'];\n /** The tool's real result; absent while it runs or holds only the streaming placeholder. */\n result?: unknown;\n state: ActivityToolState;\n };\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\n/**\n * Whether a tool-call part still holds the backend's streaming placeholder\n * result rather than the tool's real output. Long-running tools (task\n * subagents, studio and Python execution, deep research) append a ToolMessage\n * the moment they start so their card can fill in live; it carries\n * `additional_kwargs.streaming`, which the runtime converter lifts into\n * `artifact._tool_message_metadata`. The real ToolMessage that replaces it\n * has no such flag, so a defined `result` alone does not mean the tool is done.\n */\nexport function isStreamingToolPlaceholder(part: Pick<ToolCallPart, 'artifact'>): boolean {\n const artifact: unknown = part.artifact;\n if (typeof artifact !== 'object' || artifact === null) return false;\n const metadata: unknown = (artifact as { _tool_message_metadata?: unknown })\n ._tool_message_metadata;\n if (typeof metadata !== 'object' || metadata === null) return false;\n return (metadata as { streaming?: unknown }).streaming === true;\n}\n\n/** The tool's real result: undefined while it has none or only the streaming placeholder. */\nfunction finalResult(part: ToolCallPart): unknown {\n return isStreamingToolPlaceholder(part) ? undefined : part.result;\n}\n\nfunction toolCallStatus(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n): ToolCallMessagePartStatus | undefined {\n if (finalResult(part) !== 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 result = finalResult(part);\n const unresolved = 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,\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 const result = finalResult(part);\n timeline.push({\n kind: 'tool',\n id: part.toolCallId,\n partIndex: index,\n args: part.args,\n ...(result !== undefined ? { result } : {}),\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({\n kind: 'reasoning',\n id: `reasoning-${index}`,\n partIndex: index,\n text,\n state: stillStreaming ? 'running' : 'complete',\n });\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\n * `requires-action` status, a waiting tool, or a host's own `waitingForInput`\n * assertion (no in-repo host passes one) — then the 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 * A settled thought's row: the heading a reasoning summary opens with\n * (\"**Checking the workstation**\" → \"Checking the workstation\"), else the\n * generic wording. The thought itself stays in the run's details.\n */\nexport function getReasoningLabel(text: string, state: 'running' | 'complete'): string {\n if (state === 'running') return 'Thinking';\n const heading = /^\\s*\\*\\*([^*\\n]{3,80}?)\\*\\*/.exec(text)?.[1]?.trim();\n return heading ? heading.replace(/[.:]+$/, '') : 'Thought through the next step';\n}\n\n/**\n * The status-row copy for one step: the call's own summary from the shared\n * summary registry (`summarizeToolCall`: \"Ran git status\", \"Read config.ts\").\n * `resolveToolDisplayName` lets a host with a richer tool catalog name tools\n * neither registry has an entry for; `assetTitles` names the machine or\n * document a call targeted by id when an earlier result in the turn did.\n */\nexport function getActivityItemLabel(\n item: ActivityItem,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): string {\n if (item.kind === 'reasoning') return getReasoningLabel(item.text, item.state);\n return summarizeActivityTool(item, resolveToolDisplayName, assetTitles).label;\n}\n\n/** The summary of one tool step (see {@link getActivityItemLabel}). */\nexport function summarizeActivityTool(\n item: Extract<ActivityItem, { kind: 'tool' }>,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): ToolCallSummary {\n return summarizeToolCall({\n toolName: item.toolName,\n args: item.args,\n result: item.result,\n status: item.state,\n ...(assetTitles ? { assetTitles } : {}),\n ...(resolveToolDisplayName ? { displayName: resolveToolDisplayName(item.toolName) } : {}),\n });\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 * Whether a text part shows below the card instead of in the details panel:\n * it comes after the final tool call, or it holds a spoken voice turn's words\n * (a live turn heard during a delegated run lands between the run's tool\n * calls, see `isSpokenTurnTextPart`; it is the conversation, not narration).\n */\nfunction isAnswerTextPart(\n part: { readonly type: string } | undefined,\n index: number,\n lastToolIndex: number,\n): boolean {\n return part?.type === 'text' && (index > lastToolIndex || isSpokenTurnTextPart(part));\n}\n\n/**\n * The visible answer of a grouped turn: the text after the final tool call\n * (all of it when the turn never called a tool), plus the words of every\n * spoken voice turn in the message, in order. Other 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 const lastToolIndex = content.findLastIndex((part) => part?.type === 'tool-call');\n const texts: string[] = [];\n content.forEach((part, index) => {\n if (part.text && isAnswerTextPart(part, index, lastToolIndex)) texts.push(part.text);\n });\n return texts.length > 0 ? texts.join('\\n\\n') : null;\n}\n\n/**\n * Keep the answer out of the details panel: it renders below the card\n * (`SuperGroupingFinalText`), so the details grouping drops every text part\n * `getFinalText` shows 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((index) => !isAnswerTextPart(parts[index], index, lastToolIndex)),\n }))\n .filter((group) => group.indices.length > 0);\n };\n}\n"],"names":["readRejectedToolResult","classifyToolResult","summarizeToolCall","isSpokenTurnTextPart"],"mappings":";;;;;AAuEA,MAAM,+BAAoC,IAAA;AAWnC,SAAS,2BAA2B,MAA+C;AACxF,QAAM,WAAo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AS,KAAK,CAAC,SAAS,KAAK,SAAS,UAAU,KAAK,UAAU,WAAW,GAAG;AAC/E,WAAO;AAAA,EACT;AACA,MAAI,SAAS,KAAK,CAAC,SAAS,KAAK,SAAS,UAAU,KAAK,UAAU,QAAQ,GAAG;AAC5E,WAAO;AAAA,EACT;AACA,MAAI,YAAY,EAAG,QAAO,QAAQ,SAAS,IAAI,cAAc,IAAI,SAAS,OAAO;AACjF,SAAO;AACT;AAWA,SAAS,iBACP,MACA,OACA,eACS;AACT,UAAO,6BAAM,UAAS,WAAW,QAAQ,iBAAiBC,kBAAAA,qBAAqB,IAAI;AACrF;AAQO,SAAS,aAAa,SAA8D;AACzF,MAAI,EAAC,mCAAS,QAAQ,QAAO;AAE7B,QAAM,gBAAgB,QAAQ,cAAc,CAAC,UAAS,6BAAM,UAAS,WAAW;AAChF,QAAM,QAAkB,CAAA;AACxB,UAAQ,QAAQ,CAAC,MAAM,UAAU;AAC/B,QAAI,KAAK,QAAQ,iBAAiB,MAAM,OAAO,aAAa,EAAG,OAAM,KAAK,KAAK,IAAI;AAAA,EACrF,CAAC;AACD,SAAO,MAAM,SAAS,IAAI,MAAM,KAAK,MAAM,IAAI;AACjD;AAOO,SAAS,2BAA2B,UAA8C;AACvF,SAAO,CAAC,UAAU;AAChB,UAAM,gBAAgB,MAAM,cAAc,CAAC,UAAS,6BAAM,UAAS,WAAW;AAC9E,WAAO,SAAS,KAAK,EAClB,IAAI,CAAC,WAAW;AAAA,MACf,GAAG;AAAA,MACH,SAAS,MAAM,QAAQ,OAAO,CAAC,UAAU,CAAC,iBAAiB,MAAM,KAAK,GAAG,OAAO,aAAa,CAAC;AAAA,IAAA,EAC9F,EACD,OAAO,CAAC,UAAU,MAAM,QAAQ,SAAS,CAAC;AAAA,EAC/C;AACF;;;;;;;;;;;;"}
1
+ {"version":3,"file":"activity-timeline.cjs","sources":["../../../src/chat/super-grouping/activity-timeline.ts"],"sourcesContent":["/**\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 * summary registry (`summarizeToolCall`), itself built on the display\n * registry.\n */\nimport type {\n MessageStatus,\n ThreadAssistantMessagePart,\n ToolCallMessagePartStatus,\n} from '@assistant-ui/react';\nimport {\n classifyToolResult,\n isSpokenTurnTextPart,\n readRejectedToolResult,\n type ToolStatusLabelState,\n} from '@athenaintel/agent-runtime';\nimport { summarizeToolCall, type ToolCallSummary } from '../../tools/tool-summary';\nimport type { GroupablePart, GroupingFunction } from './grouping-function';\n\nexport type ActivityToolState = ToolStatusLabelState;\n\nexport type ActivityItem =\n | {\n kind: 'reasoning';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n text: string;\n state: 'running' | 'complete';\n }\n | {\n kind: 'tool';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n toolName: string;\n args?: ToolCallPart['args'];\n /** The tool's real result; absent while it runs or holds only the streaming placeholder. */\n result?: unknown;\n state: ActivityToolState;\n };\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\n/**\n * Whether a tool-call part still holds the backend's streaming placeholder\n * result rather than the tool's real output. Long-running tools (task\n * subagents, studio and Python execution, deep research) append a ToolMessage\n * the moment they start so their card can fill in live; it carries\n * `additional_kwargs.streaming`, which the runtime converter lifts into\n * `artifact._tool_message_metadata`. The real ToolMessage that replaces it\n * has no such flag, so a defined `result` alone does not mean the tool is done.\n */\nexport function isStreamingToolPlaceholder(part: Pick<ToolCallPart, 'artifact'>): boolean {\n const artifact: unknown = part.artifact;\n if (typeof artifact !== 'object' || artifact === null) return false;\n const metadata: unknown = (artifact as { _tool_message_metadata?: unknown })\n ._tool_message_metadata;\n if (typeof metadata !== 'object' || metadata === null) return false;\n return (metadata as { streaming?: unknown }).streaming === true;\n}\n\n/** The tool's real result: undefined while it has none or only the streaming placeholder. */\nfunction finalResult(part: ToolCallPart): unknown {\n return isStreamingToolPlaceholder(part) ? undefined : part.result;\n}\n\nfunction toolCallStatus(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n): ToolCallMessagePartStatus | undefined {\n if (finalResult(part) !== 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 result = finalResult(part);\n const unresolved = 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,\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 const result = finalResult(part);\n timeline.push({\n kind: 'tool',\n id: part.toolCallId,\n partIndex: index,\n args: part.args,\n ...(result !== undefined ? { result } : {}),\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({\n kind: 'reasoning',\n id: `reasoning-${index}`,\n partIndex: index,\n text,\n state: stillStreaming ? 'running' : 'complete',\n });\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\n * `requires-action` status, a waiting tool, or a host's own `waitingForInput`\n * assertion (no in-repo host passes one) — then the 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 * A settled thought's row: the heading a reasoning summary opens with\n * (\"**Checking the workstation**\" → \"Checking the workstation\"), else the\n * generic wording. The thought itself stays in the run's details.\n */\nexport function getReasoningLabel(text: string, state: 'running' | 'complete'): string {\n if (state === 'running') return 'Thinking';\n const heading = /^\\s*\\*\\*([^*\\n]{3,80}?)\\*\\*/.exec(text)?.[1]?.trim();\n return heading ? heading.replace(/[.:]+$/, '') : 'Thought through the next step';\n}\n\n/**\n * The status-row copy for one step: the call's own summary from the shared\n * summary registry (`summarizeToolCall`: \"Ran git status\", \"Read config.ts\").\n * `resolveToolDisplayName` lets a host with a richer tool catalog name tools\n * neither registry has an entry for; `assetTitles` names the machine or\n * document a call targeted by id when an earlier result in the turn did.\n */\nexport function getActivityItemLabel(\n item: ActivityItem,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): string {\n if (item.kind === 'reasoning') return getReasoningLabel(item.text, item.state);\n return summarizeActivityTool(item, resolveToolDisplayName, assetTitles).label;\n}\n\n/** The summary of one tool step (see {@link getActivityItemLabel}). */\nexport function summarizeActivityTool(\n item: Extract<ActivityItem, { kind: 'tool' }>,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): ToolCallSummary {\n return summarizeToolCall({\n toolName: item.toolName,\n args: item.args,\n result: item.result,\n status: item.state,\n ...(assetTitles ? { assetTitles } : {}),\n ...(resolveToolDisplayName ? { displayName: resolveToolDisplayName(item.toolName) } : {}),\n });\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 * Whether a text part shows below the card instead of in the details panel:\n * it comes after the final tool call, or it holds a spoken voice turn's words\n * (a live turn heard during a delegated run lands between the run's tool\n * calls, see `isSpokenTurnTextPart`; it is the conversation, not narration).\n */\nfunction isAnswerTextPart(\n part: { readonly type: string } | undefined,\n index: number,\n lastToolIndex: number,\n): boolean {\n return part?.type === 'text' && (index > lastToolIndex || isSpokenTurnTextPart(part));\n}\n\n/**\n * The visible answer of a grouped turn: the text after the final tool call\n * (all of it when the turn never called a tool), plus the words of every\n * spoken voice turn in the message, in order. Other 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 const parts = getFinalTextParts(content);\n return parts.length > 0 ? parts.map((part) => part.text).join('\\n\\n') : null;\n}\n\n/** One text part of the visible answer, with its index in the message content. */\nexport interface FinalTextSegment {\n index: number;\n text: string;\n}\n\n/**\n * The parts `getFinalText` joins, each kept separate with its content index.\n * A spoken turn and the run's own reply can stream at the same time, so the\n * earlier part may grow while a later one exists: rendered as one joined\n * string, that text changes in the middle rather than at its end, and the\n * streaming reveal restarts from an empty bubble on every word.\n */\nexport function getFinalTextParts(content: readonly FinalTextPart[] | undefined): FinalTextSegment[] {\n if (!content?.length) return [];\n\n const lastToolIndex = content.findLastIndex((part) => part?.type === 'tool-call');\n const parts: FinalTextSegment[] = [];\n content.forEach((part, index) => {\n if (part.text && isAnswerTextPart(part, index, lastToolIndex)) parts.push({ index, text: part.text });\n });\n return parts;\n}\n\n/**\n * Keep the answer out of the details panel: it renders below the card\n * (`SuperGroupingFinalText`), so the details grouping drops every text part\n * `getFinalText` shows 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((index) => !isAnswerTextPart(parts[index], index, lastToolIndex)),\n }))\n .filter((group) => group.indices.length > 0);\n };\n}\n\n/**\n * Drop the parts `exclude` matches from every group, and any group left\n * empty: `SuperGroupingCard` renders inline tool calls outside the details,\n * so they must not render a second time inside it.\n */\nexport function excludePartsFromGroups(\n grouping: GroupingFunction,\n exclude: (part: GroupablePart) => boolean,\n): GroupingFunction {\n return (parts) =>\n grouping(parts)\n .map((group) => ({\n ...group,\n indices: group.indices.filter((index) => {\n const part = parts[index];\n return part === undefined || !exclude(part);\n }),\n }))\n .filter((group) => group.indices.length > 0);\n}\n"],"names":["readRejectedToolResult","classifyToolResult","summarizeToolCall","isSpokenTurnTextPart"],"mappings":";;;;;AAuEA,MAAM,+BAAoC,IAAA;AAWnC,SAAS,2BAA2B,MAA+C;AACxF,QAAM,WAAoB,KAAK;AAC/B,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,WAAqB,SACxB;AACH,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,SAAQ,SAAqC,cAAc;AAC7D;AAGA,SAAS,YAAY,MAA6B;AAChD,SAAO,2BAA2B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AS,UAAa,CAAC,QAAQ,IAAI;AAAA,IAC5C,CAAC;AAAA,EAAA,EACD,EACD,OAAO,CAAC,UAAU,MAAM,QAAQ,SAAS,CAAC;AACjD;;;;;;;;;;;;;;"}
@@ -15,7 +15,7 @@
15
15
  import type { MessageStatus, ThreadAssistantMessagePart } from '@assistant-ui/react';
16
16
  import { type ToolStatusLabelState } from '@athenaintel/agent-runtime';
17
17
  import { type ToolCallSummary } from '../../tools/tool-summary';
18
- import type { GroupingFunction } from './grouping-function';
18
+ import type { GroupablePart, GroupingFunction } from './grouping-function';
19
19
  export type ActivityToolState = ToolStatusLabelState;
20
20
  export type ActivityItem = {
21
21
  kind: 'reasoning';
@@ -117,10 +117,29 @@ export type FinalTextPart = {
117
117
  * or between tool calls) stays available in the details panel.
118
118
  */
119
119
  export declare function getFinalText(content: readonly FinalTextPart[] | undefined): string | null;
120
+ /** One text part of the visible answer, with its index in the message content. */
121
+ export interface FinalTextSegment {
122
+ index: number;
123
+ text: string;
124
+ }
125
+ /**
126
+ * The parts `getFinalText` joins, each kept separate with its content index.
127
+ * A spoken turn and the run's own reply can stream at the same time, so the
128
+ * earlier part may grow while a later one exists: rendered as one joined
129
+ * string, that text changes in the middle rather than at its end, and the
130
+ * streaming reveal restarts from an empty bubble on every word.
131
+ */
132
+ export declare function getFinalTextParts(content: readonly FinalTextPart[] | undefined): FinalTextSegment[];
120
133
  /**
121
134
  * Keep the answer out of the details panel: it renders below the card
122
135
  * (`SuperGroupingFinalText`), so the details grouping drops every text part
123
136
  * `getFinalText` shows and any group that becomes empty.
124
137
  */
125
138
  export declare function excludeFinalTextFromGroups(grouping: GroupingFunction): GroupingFunction;
139
+ /**
140
+ * Drop the parts `exclude` matches from every group, and any group left
141
+ * empty: `SuperGroupingCard` renders inline tool calls outside the details,
142
+ * so they must not render a second time inside it.
143
+ */
144
+ export declare function excludePartsFromGroups(grouping: GroupingFunction, exclude: (part: GroupablePart) => boolean): GroupingFunction;
126
145
  export {};
@@ -134,13 +134,17 @@ function isAnswerTextPart(part, index, lastToolIndex) {
134
134
  return (part == null ? void 0 : part.type) === "text" && (index > lastToolIndex || isSpokenTurnTextPart(part));
135
135
  }
136
136
  function getFinalText(content) {
137
- if (!(content == null ? void 0 : content.length)) return null;
137
+ const parts = getFinalTextParts(content);
138
+ return parts.length > 0 ? parts.map((part) => part.text).join("\n\n") : null;
139
+ }
140
+ function getFinalTextParts(content) {
141
+ if (!(content == null ? void 0 : content.length)) return [];
138
142
  const lastToolIndex = content.findLastIndex((part) => (part == null ? void 0 : part.type) === "tool-call");
139
- const texts = [];
143
+ const parts = [];
140
144
  content.forEach((part, index) => {
141
- if (part.text && isAnswerTextPart(part, index, lastToolIndex)) texts.push(part.text);
145
+ if (part.text && isAnswerTextPart(part, index, lastToolIndex)) parts.push({ index, text: part.text });
142
146
  });
143
- return texts.length > 0 ? texts.join("\n\n") : null;
147
+ return parts;
144
148
  }
145
149
  function excludeFinalTextFromGroups(grouping) {
146
150
  return (parts) => {
@@ -151,14 +155,25 @@ function excludeFinalTextFromGroups(grouping) {
151
155
  })).filter((group) => group.indices.length > 0);
152
156
  };
153
157
  }
158
+ function excludePartsFromGroups(grouping, exclude) {
159
+ return (parts) => grouping(parts).map((group) => ({
160
+ ...group,
161
+ indices: group.indices.filter((index) => {
162
+ const part = parts[index];
163
+ return part === void 0 || !exclude(part);
164
+ })
165
+ })).filter((group) => group.indices.length > 0);
166
+ }
154
167
  export {
155
168
  buildActivityTimeline,
156
169
  countActivityTools,
157
170
  excludeFinalTextFromGroups,
171
+ excludePartsFromGroups,
158
172
  getActivityItemLabel,
159
173
  getActivitySummary,
160
174
  getActivityToolState,
161
175
  getFinalText,
176
+ getFinalTextParts,
162
177
  getReasoningLabel,
163
178
  isStreamingToolPlaceholder,
164
179
  resolveActivityPhase,
@@ -1 +1 @@
1
- {"version":3,"file":"activity-timeline.js","sources":["../../../src/chat/super-grouping/activity-timeline.ts"],"sourcesContent":["/**\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 * summary registry (`summarizeToolCall`), itself built on the display\n * registry.\n */\nimport type {\n MessageStatus,\n ThreadAssistantMessagePart,\n ToolCallMessagePartStatus,\n} from '@assistant-ui/react';\nimport {\n classifyToolResult,\n isSpokenTurnTextPart,\n readRejectedToolResult,\n type ToolStatusLabelState,\n} from '@athenaintel/agent-runtime';\nimport { summarizeToolCall, type ToolCallSummary } from '../../tools/tool-summary';\nimport type { GroupingFunction } from './grouping-function';\n\nexport type ActivityToolState = ToolStatusLabelState;\n\nexport type ActivityItem =\n | {\n kind: 'reasoning';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n text: string;\n state: 'running' | 'complete';\n }\n | {\n kind: 'tool';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n toolName: string;\n args?: ToolCallPart['args'];\n /** The tool's real result; absent while it runs or holds only the streaming placeholder. */\n result?: unknown;\n state: ActivityToolState;\n };\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\n/**\n * Whether a tool-call part still holds the backend's streaming placeholder\n * result rather than the tool's real output. Long-running tools (task\n * subagents, studio and Python execution, deep research) append a ToolMessage\n * the moment they start so their card can fill in live; it carries\n * `additional_kwargs.streaming`, which the runtime converter lifts into\n * `artifact._tool_message_metadata`. The real ToolMessage that replaces it\n * has no such flag, so a defined `result` alone does not mean the tool is done.\n */\nexport function isStreamingToolPlaceholder(part: Pick<ToolCallPart, 'artifact'>): boolean {\n const artifact: unknown = part.artifact;\n if (typeof artifact !== 'object' || artifact === null) return false;\n const metadata: unknown = (artifact as { _tool_message_metadata?: unknown })\n ._tool_message_metadata;\n if (typeof metadata !== 'object' || metadata === null) return false;\n return (metadata as { streaming?: unknown }).streaming === true;\n}\n\n/** The tool's real result: undefined while it has none or only the streaming placeholder. */\nfunction finalResult(part: ToolCallPart): unknown {\n return isStreamingToolPlaceholder(part) ? undefined : part.result;\n}\n\nfunction toolCallStatus(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n): ToolCallMessagePartStatus | undefined {\n if (finalResult(part) !== 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 result = finalResult(part);\n const unresolved = 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,\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 const result = finalResult(part);\n timeline.push({\n kind: 'tool',\n id: part.toolCallId,\n partIndex: index,\n args: part.args,\n ...(result !== undefined ? { result } : {}),\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({\n kind: 'reasoning',\n id: `reasoning-${index}`,\n partIndex: index,\n text,\n state: stillStreaming ? 'running' : 'complete',\n });\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\n * `requires-action` status, a waiting tool, or a host's own `waitingForInput`\n * assertion (no in-repo host passes one) — then the 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 * A settled thought's row: the heading a reasoning summary opens with\n * (\"**Checking the workstation**\" → \"Checking the workstation\"), else the\n * generic wording. The thought itself stays in the run's details.\n */\nexport function getReasoningLabel(text: string, state: 'running' | 'complete'): string {\n if (state === 'running') return 'Thinking';\n const heading = /^\\s*\\*\\*([^*\\n]{3,80}?)\\*\\*/.exec(text)?.[1]?.trim();\n return heading ? heading.replace(/[.:]+$/, '') : 'Thought through the next step';\n}\n\n/**\n * The status-row copy for one step: the call's own summary from the shared\n * summary registry (`summarizeToolCall`: \"Ran git status\", \"Read config.ts\").\n * `resolveToolDisplayName` lets a host with a richer tool catalog name tools\n * neither registry has an entry for; `assetTitles` names the machine or\n * document a call targeted by id when an earlier result in the turn did.\n */\nexport function getActivityItemLabel(\n item: ActivityItem,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): string {\n if (item.kind === 'reasoning') return getReasoningLabel(item.text, item.state);\n return summarizeActivityTool(item, resolveToolDisplayName, assetTitles).label;\n}\n\n/** The summary of one tool step (see {@link getActivityItemLabel}). */\nexport function summarizeActivityTool(\n item: Extract<ActivityItem, { kind: 'tool' }>,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): ToolCallSummary {\n return summarizeToolCall({\n toolName: item.toolName,\n args: item.args,\n result: item.result,\n status: item.state,\n ...(assetTitles ? { assetTitles } : {}),\n ...(resolveToolDisplayName ? { displayName: resolveToolDisplayName(item.toolName) } : {}),\n });\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 * Whether a text part shows below the card instead of in the details panel:\n * it comes after the final tool call, or it holds a spoken voice turn's words\n * (a live turn heard during a delegated run lands between the run's tool\n * calls, see `isSpokenTurnTextPart`; it is the conversation, not narration).\n */\nfunction isAnswerTextPart(\n part: { readonly type: string } | undefined,\n index: number,\n lastToolIndex: number,\n): boolean {\n return part?.type === 'text' && (index > lastToolIndex || isSpokenTurnTextPart(part));\n}\n\n/**\n * The visible answer of a grouped turn: the text after the final tool call\n * (all of it when the turn never called a tool), plus the words of every\n * spoken voice turn in the message, in order. Other 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 const lastToolIndex = content.findLastIndex((part) => part?.type === 'tool-call');\n const texts: string[] = [];\n content.forEach((part, index) => {\n if (part.text && isAnswerTextPart(part, index, lastToolIndex)) texts.push(part.text);\n });\n return texts.length > 0 ? texts.join('\\n\\n') : null;\n}\n\n/**\n * Keep the answer out of the details panel: it renders below the card\n * (`SuperGroupingFinalText`), so the details grouping drops every text part\n * `getFinalText` shows 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((index) => !isAnswerTextPart(parts[index], index, lastToolIndex)),\n }))\n .filter((group) => group.indices.length > 0);\n };\n}\n"],"names":[],"mappings":";;;AAuEA,MAAM,+BAAoC,IAAA;AAWnC,SAAS,2BAA2B,MAA+C;AACxF,QAAM,WAAoB,KAAK;AAC/B,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,WAAqB,SACxB;AACH,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,SAAQ,SAAqC,cAAc;AAC7D;AAGA,SAAS,YAAY,MAA6B;AAChD,SAAO,2BAA2B,IAAI,IAAI,SAAY,KAAK;AAC7D;AAEA,SAAS,eACP,MACA,eACuC;AACvC,MAAI,YAAY,IAAI,MAAM,OAAW,QAAO,EAAE,MAAM,WAAA;AACpD,OAAI,+CAAe,UAAS,cAAc;AACxC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,cAAc,WAAW,eAAe,UAAU,cAAc;AAAA,MACxE,OAAO,cAAc;AAAA,IAAA;AAAA,EAEzB;AACA,OAAI,+CAAe,UAAS,WAAY,QAAO,EAAE,MAAM,WAAA;AACvD,OAAI,+CAAe,UAAS,mBAAmB;AAC7C,WAAO,EAAE,MAAM,mBAAmB,QAAQ,cAAc,OAAA;AAAA,EAC1D;AACA,OAAI,+CAAe,UAAS,UAAW,QAAO,EAAE,MAAM,UAAA;AACtD,SAAO;AACT;AAGO,SAAS,qBACd,MACA,eACA,EAAE,eAAe,UAAU,mBAAmB,SAAA,IAAsC,IACjE;;AACnB,QAAI,UAAK,aAAL,mBAAe,cAAa,SAAS,uBAAuB,KAAK,MAAM,MAAM,MAAM;AACrF,WAAO;AAAA,EACT;AACA,QA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G;AAAA,MACH,SAAS,MAAM,QAAQ,OAAO,CAAC,UAAU,CAAC,iBAAiB,MAAM,KAAK,GAAG,OAAO,aAAa,CAAC;AAAA,IAAA,EAC9F,EACD,OAAO,CAAC,UAAU,MAAM,QAAQ,SAAS,CAAC;AAAA,EAC/C;AACF;"}
1
+ {"version":3,"file":"activity-timeline.js","sources":["../../../src/chat/super-grouping/activity-timeline.ts"],"sourcesContent":["/**\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 * summary registry (`summarizeToolCall`), itself built on the display\n * registry.\n */\nimport type {\n MessageStatus,\n ThreadAssistantMessagePart,\n ToolCallMessagePartStatus,\n} from '@assistant-ui/react';\nimport {\n classifyToolResult,\n isSpokenTurnTextPart,\n readRejectedToolResult,\n type ToolStatusLabelState,\n} from '@athenaintel/agent-runtime';\nimport { summarizeToolCall, type ToolCallSummary } from '../../tools/tool-summary';\nimport type { GroupablePart, GroupingFunction } from './grouping-function';\n\nexport type ActivityToolState = ToolStatusLabelState;\n\nexport type ActivityItem =\n | {\n kind: 'reasoning';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n text: string;\n state: 'running' | 'complete';\n }\n | {\n kind: 'tool';\n id?: string;\n /** Position of the part in the message's content. */\n partIndex?: number;\n toolName: string;\n args?: ToolCallPart['args'];\n /** The tool's real result; absent while it runs or holds only the streaming placeholder. */\n result?: unknown;\n state: ActivityToolState;\n };\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\n/**\n * Whether a tool-call part still holds the backend's streaming placeholder\n * result rather than the tool's real output. Long-running tools (task\n * subagents, studio and Python execution, deep research) append a ToolMessage\n * the moment they start so their card can fill in live; it carries\n * `additional_kwargs.streaming`, which the runtime converter lifts into\n * `artifact._tool_message_metadata`. The real ToolMessage that replaces it\n * has no such flag, so a defined `result` alone does not mean the tool is done.\n */\nexport function isStreamingToolPlaceholder(part: Pick<ToolCallPart, 'artifact'>): boolean {\n const artifact: unknown = part.artifact;\n if (typeof artifact !== 'object' || artifact === null) return false;\n const metadata: unknown = (artifact as { _tool_message_metadata?: unknown })\n ._tool_message_metadata;\n if (typeof metadata !== 'object' || metadata === null) return false;\n return (metadata as { streaming?: unknown }).streaming === true;\n}\n\n/** The tool's real result: undefined while it has none or only the streaming placeholder. */\nfunction finalResult(part: ToolCallPart): unknown {\n return isStreamingToolPlaceholder(part) ? undefined : part.result;\n}\n\nfunction toolCallStatus(\n part: ToolCallPart,\n messageStatus: MessageStatus | undefined,\n): ToolCallMessagePartStatus | undefined {\n if (finalResult(part) !== 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 result = finalResult(part);\n const unresolved = 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,\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 const result = finalResult(part);\n timeline.push({\n kind: 'tool',\n id: part.toolCallId,\n partIndex: index,\n args: part.args,\n ...(result !== undefined ? { result } : {}),\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({\n kind: 'reasoning',\n id: `reasoning-${index}`,\n partIndex: index,\n text,\n state: stillStreaming ? 'running' : 'complete',\n });\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\n * `requires-action` status, a waiting tool, or a host's own `waitingForInput`\n * assertion (no in-repo host passes one) — then the 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 * A settled thought's row: the heading a reasoning summary opens with\n * (\"**Checking the workstation**\" → \"Checking the workstation\"), else the\n * generic wording. The thought itself stays in the run's details.\n */\nexport function getReasoningLabel(text: string, state: 'running' | 'complete'): string {\n if (state === 'running') return 'Thinking';\n const heading = /^\\s*\\*\\*([^*\\n]{3,80}?)\\*\\*/.exec(text)?.[1]?.trim();\n return heading ? heading.replace(/[.:]+$/, '') : 'Thought through the next step';\n}\n\n/**\n * The status-row copy for one step: the call's own summary from the shared\n * summary registry (`summarizeToolCall`: \"Ran git status\", \"Read config.ts\").\n * `resolveToolDisplayName` lets a host with a richer tool catalog name tools\n * neither registry has an entry for; `assetTitles` names the machine or\n * document a call targeted by id when an earlier result in the turn did.\n */\nexport function getActivityItemLabel(\n item: ActivityItem,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): string {\n if (item.kind === 'reasoning') return getReasoningLabel(item.text, item.state);\n return summarizeActivityTool(item, resolveToolDisplayName, assetTitles).label;\n}\n\n/** The summary of one tool step (see {@link getActivityItemLabel}). */\nexport function summarizeActivityTool(\n item: Extract<ActivityItem, { kind: 'tool' }>,\n resolveToolDisplayName?: (toolName: string) => string | undefined,\n assetTitles?: ReadonlyMap<string, string>,\n): ToolCallSummary {\n return summarizeToolCall({\n toolName: item.toolName,\n args: item.args,\n result: item.result,\n status: item.state,\n ...(assetTitles ? { assetTitles } : {}),\n ...(resolveToolDisplayName ? { displayName: resolveToolDisplayName(item.toolName) } : {}),\n });\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 * Whether a text part shows below the card instead of in the details panel:\n * it comes after the final tool call, or it holds a spoken voice turn's words\n * (a live turn heard during a delegated run lands between the run's tool\n * calls, see `isSpokenTurnTextPart`; it is the conversation, not narration).\n */\nfunction isAnswerTextPart(\n part: { readonly type: string } | undefined,\n index: number,\n lastToolIndex: number,\n): boolean {\n return part?.type === 'text' && (index > lastToolIndex || isSpokenTurnTextPart(part));\n}\n\n/**\n * The visible answer of a grouped turn: the text after the final tool call\n * (all of it when the turn never called a tool), plus the words of every\n * spoken voice turn in the message, in order. Other 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 const parts = getFinalTextParts(content);\n return parts.length > 0 ? parts.map((part) => part.text).join('\\n\\n') : null;\n}\n\n/** One text part of the visible answer, with its index in the message content. */\nexport interface FinalTextSegment {\n index: number;\n text: string;\n}\n\n/**\n * The parts `getFinalText` joins, each kept separate with its content index.\n * A spoken turn and the run's own reply can stream at the same time, so the\n * earlier part may grow while a later one exists: rendered as one joined\n * string, that text changes in the middle rather than at its end, and the\n * streaming reveal restarts from an empty bubble on every word.\n */\nexport function getFinalTextParts(content: readonly FinalTextPart[] | undefined): FinalTextSegment[] {\n if (!content?.length) return [];\n\n const lastToolIndex = content.findLastIndex((part) => part?.type === 'tool-call');\n const parts: FinalTextSegment[] = [];\n content.forEach((part, index) => {\n if (part.text && isAnswerTextPart(part, index, lastToolIndex)) parts.push({ index, text: part.text });\n });\n return parts;\n}\n\n/**\n * Keep the answer out of the details panel: it renders below the card\n * (`SuperGroupingFinalText`), so the details grouping drops every text part\n * `getFinalText` shows 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((index) => !isAnswerTextPart(parts[index], index, lastToolIndex)),\n }))\n .filter((group) => group.indices.length > 0);\n };\n}\n\n/**\n * Drop the parts `exclude` matches from every group, and any group left\n * empty: `SuperGroupingCard` renders inline tool calls outside the details,\n * so they must not render a second time inside it.\n */\nexport function excludePartsFromGroups(\n grouping: GroupingFunction,\n exclude: (part: GroupablePart) => boolean,\n): GroupingFunction {\n return (parts) =>\n grouping(parts)\n .map((group) => ({\n ...group,\n indices: group.indices.filter((index) => {\n const part = parts[index];\n return part === undefined || !exclude(part);\n }),\n }))\n .filter((group) => group.indices.length > 0);\n}\n"],"names":[],"mappings":";;;AAuEA,MAAM,+BAAoC,IAAA;AAWnC,SAA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AAC;AAAA,EAC/C;AACF;AAOO,SAAS,uBACd,UACA,SACkB;AAClB,SAAO,CAAC,UACN,SAAS,KAAK,EACX,IAAI,CAAC,WAAW;AAAA,IACf,GAAG;AAAA,IACH,SAAS,MAAM,QAAQ,OAAO,CAAC,UAAU;AACvC,YAAM,OAAO,MAAM,KAAK;AACxB,aAAO,SAAS,UAAa,CAAC,QAAQ,IAAI;AAAA,IAC5C,CAAC;AAAA,EAAA,EACD,EACD,OAAO,CAAC,UAAU,MAAM,QAAQ,SAAS,CAAC;AACjD;"}
@@ -11,10 +11,12 @@ const toolkitMap = require("./toolkit-map.cjs");
11
11
  exports.buildActivityTimeline = activityTimeline.buildActivityTimeline;
12
12
  exports.countActivityTools = activityTimeline.countActivityTools;
13
13
  exports.excludeFinalTextFromGroups = activityTimeline.excludeFinalTextFromGroups;
14
+ exports.excludePartsFromGroups = activityTimeline.excludePartsFromGroups;
14
15
  exports.getActivityItemLabel = activityTimeline.getActivityItemLabel;
15
16
  exports.getActivitySummary = activityTimeline.getActivitySummary;
16
17
  exports.getActivityToolState = activityTimeline.getActivityToolState;
17
18
  exports.getFinalText = activityTimeline.getFinalText;
19
+ exports.getFinalTextParts = activityTimeline.getFinalTextParts;
18
20
  exports.getReasoningLabel = activityTimeline.getReasoningLabel;
19
21
  exports.isStreamingToolPlaceholder = activityTimeline.isStreamingToolPlaceholder;
20
22
  exports.resolveActivityPhase = activityTimeline.resolveActivityPhase;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -7,7 +7,7 @@
7
7
  * A lean entry so hosts with their own thread (Olympus, the Chrome extension)
8
8
  * mount it from source without the SDK's composer stack.
9
9
  */
10
- export { type ActivityItem, type ActivityPhase, type ActivityTimelineOptions, type ActivityToolState, buildActivityTimeline, countActivityTools, excludeFinalTextFromGroups, type FinalTextPart, getActivityItemLabel, getActivitySummary, getReasoningLabel, getActivityToolState, isStreamingToolPlaceholder, getFinalText, resolveActivityPhase, } from './activity-timeline';
10
+ export { type ActivityItem, type ActivityPhase, type ActivityTimelineOptions, type ActivityToolState, buildActivityTimeline, countActivityTools, excludeFinalTextFromGroups, excludePartsFromGroups, type FinalTextPart, type FinalTextSegment, getActivityItemLabel, getActivitySummary, getReasoningLabel, getActivityToolState, isStreamingToolPlaceholder, getFinalText, getFinalTextParts, resolveActivityPhase, } from './activity-timeline';
11
11
  export { CollapsibleGroup, type CollapsibleGroupProps, DEFAULT_TOOLKIT_THEME, SuperGroupingProvider, TOOLKIT_THEMES, type ToolkitTheme, } from './CollapsibleGroup';
12
12
  export { createToolBasedGroupingFunction, type GroupablePart, type GroupingFunction, type MessagePartGroup, } from './grouping-function';
13
13
  export { resetRememberedExpansionsForTests, SuperGroupingCard, type SuperGroupingCardProps, SuperGroupingFinalText, useActivityExpansion, } from './SuperGroupingCard';
@@ -1,4 +1,4 @@
1
- import { buildActivityTimeline, countActivityTools, excludeFinalTextFromGroups, getActivityItemLabel, getActivitySummary, getActivityToolState, getFinalText, getReasoningLabel, isStreamingToolPlaceholder, resolveActivityPhase } from "./activity-timeline.js";
1
+ import { buildActivityTimeline, countActivityTools, excludeFinalTextFromGroups, excludePartsFromGroups, getActivityItemLabel, getActivitySummary, getActivityToolState, getFinalText, getFinalTextParts, getReasoningLabel, isStreamingToolPlaceholder, resolveActivityPhase } from "./activity-timeline.js";
2
2
  import { CollapsibleGroup, DEFAULT_TOOLKIT_THEME, SuperGroupingProvider, TOOLKIT_THEMES } from "./CollapsibleGroup.js";
3
3
  import { createToolBasedGroupingFunction } from "./grouping-function.js";
4
4
  import { SuperGroupingCard, SuperGroupingFinalText, resetRememberedExpansionsForTests, useActivityExpansion } from "./SuperGroupingCard.js";
@@ -19,11 +19,13 @@ export {
19
19
  createToolBasedGroupingFunction,
20
20
  defaultGetToolGroupKey,
21
21
  excludeFinalTextFromGroups,
22
+ excludePartsFromGroups,
22
23
  formatWorkDuration,
23
24
  getActivityItemLabel,
24
25
  getActivitySummary,
25
26
  getActivityToolState,
26
27
  getFinalText,
28
+ getFinalTextParts,
27
29
  getReasoningLabel,
28
30
  isStreamingToolPlaceholder,
29
31
  readTurnTiming,
@@ -40,6 +40,7 @@ const DEFAULT_TOOL_TO_TOOLKIT = {
40
40
  create_presentation_pptx_studio: "Presentation",
41
41
  execute_presentation_code: "Presentation",
42
42
  capture_slide_screenshot: "Presentation",
43
+ capture_slide_screenshots: "Presentation",
43
44
  // Studio presentation PTC
44
45
  CreatePresentation: "Presentation",
45
46
  OpenPresentation: "Presentation",
@@ -1 +1 @@
1
- {"version":3,"file":"toolkit-map.cjs","sources":["../../../src/chat/super-grouping/toolkit-map.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":";;AAWA,MAAM,0BAAkD;AAAA;AAAA,EAEtD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA;AAAA,EAGZ,qBAAqB;AAAA,EACrB,+BAA+B;AAAA,EAC/B,oCAAoC;AAAA,EACpC,qCAAqC;AAAA,EACrC,oCAAoC;AAAA,EACpC,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA;AAAA,EAGhB,gB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,YAAY;AAAA,EAC/E;AACA,SAAO,wBAAwB,QAAQ;AACzC;;"}
1
+ {"version":3,"file":"toolkit-map.cjs","sources":["../../../src/chat/super-grouping/toolkit-map.ts"],"sourcesContent":["/**\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 capture_slide_screenshots: '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"],"names":[],"mappings":";;AAWA,MAAM,0BAAkD;AAAA;AAAA,EAEtD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA;AAAA,EAGZ,qBAAqB;AAAA,EACrB,+BAA+B;AAAA,EAC/B,oCAAoC;AAAA,EACpC,qCAAqC;AAAA,EACrC,oCAAoC;AAAA,EACpC,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA;AAAA,EAGhB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,0BAA0B;AAAA;AAAA,EAG1B,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,EACzB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA;AAAA,EAEd,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,cAAc;AAAA;AAAA,EAGd,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC,2BAA2B;AAAA,EAC3B,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA;AAAA,EAE3B,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,UAAU;AAAA;AAAA,EAGV,qBAAqB;AAAA,EACrB,mBAAmB;AAAA;AAAA,EAGnB,iBAAiB;AAAA,EACjB,YAAY;AAAA;AAAA,EAGZ,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAG3B,cAAc;AAAA,EACd,sBAAsB;AAAA;AAAA,EAGtB,gBAAgB;AAClB;AAMA,MAAM,kBAAqC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQA,MAAM,qBAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOA,MAAM,yBAA4C,CAAC,YAAY,YAAY,iBAAiB;AAsBrF,MAAM,yBAAyB,CACpC,UACA,YACuB;AACvB,MAAI,gBAAgB,SAAS,QAAQ,EAAG,QAAO;AAC/C,MAAI,mBAAmB,SAAS,QAAQ,GAAG;AACzC,UAAM,YAAY,mCAAS;AAC3B,WAAO,aAAa,uBAAuB,SAAS,SAAS,IAAI,YAAY;AAAA,EAC/E;AACA,SAAO,wBAAwB,QAAQ;AACzC;;"}
@@ -38,6 +38,7 @@ const DEFAULT_TOOL_TO_TOOLKIT = {
38
38
  create_presentation_pptx_studio: "Presentation",
39
39
  execute_presentation_code: "Presentation",
40
40
  capture_slide_screenshot: "Presentation",
41
+ capture_slide_screenshots: "Presentation",
41
42
  // Studio presentation PTC
42
43
  CreatePresentation: "Presentation",
43
44
  OpenPresentation: "Presentation",
@@ -1 +1 @@
1
- {"version":3,"file":"toolkit-map.js","sources":["../../../src/chat/super-grouping/toolkit-map.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":"AAWA,MAAM,0BAAkD;AAAA;AAAA,EAEtD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA;AAAA,EAGZ,qBAAqB;AAAA,EACrB,+BAA+B;AAAA,EAC/B,oCAAoC;AAAA,EACpC,qCAAqC;AAAA,EACrC,oCAAoC;AAAA,EACpC,2BAA2B;AAAA,EAC3B,gBAAgB;AAAA;AAAA,EAGhB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,0BAA0B;AAAA;AAAA,EAG1B,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,EACzB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA;AAAA,EAEd,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,cAAc;AAAA;AAAA,EAGd,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC,2BAA2B;AAAA,EAC3B,0BAA0B;AAAA;AAAA,EAE1B,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,UAAU;AAAA;AAAA,EAGV,qBAAqB;AAAA,EACrB,mBAAmB;AAAA;AAAA,EAGnB,iBAAiB;AAAA,EACjB,YAAY;AAAA;AAAA,EAGZ,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAG3B,cAAc;AAAA,EACd,sBAAsB;AAAA;AAAA,EAGtB,gBAAgB;AAClB;AAMA,MAAM,kBAAqC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQA,MAAM,qBAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOA,MAAM,yBAA4C,CAAC,YAAY,YAAY,iBAAiB;AAsBrF,MAAM,yBAAyB,CACpC,UACA,YACuB;AACvB,MAAI,gBAAgB,SAAS,QAAQ,EAAG,QAAO;AAC/C,MAAI,mBAAmB,SAAS,QAAQ,GAAG;AACzC,UAAM,YAAY,mCAAS;AAC3B,WAAO,aAAa,uBAAuB,SAAS,SAAS,IAAI,YAAY;AAAA,EAC/E;AACA,SAAO,wBAAwB,QAAQ;AACzC;"}
1
+ {"version":3,"file":"toolkit-map.js","sources":["../../../src/chat/super-grouping/toolkit-map.ts"],"sourcesContent":["/**\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 capture_slide_screenshots: '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"],"names":[],"mappings":"AAWA,MAAM,0BAAkD;AAAA;AAAA,EAEtD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,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AC,YAAY,YAAY,iBAAiB;AAsBrF,MAAM,yBAAyB,CACpC,UACA,YACuB;AACvB,MAAI,gBAAgB,SAAS,QAAQ,EAAG,QAAO;AAC/C,MAAI,mBAAmB,SAAS,QAAQ,GAAG;AACzC,UAAM,YAAY,mCAAS;AAC3B,WAAO,aAAa,uBAAuB,SAAS,SAAS,IAAI,YAAY;AAAA,EAC/E;AACA,SAAO,wBAAwB,QAAQ;AACzC;"}
@@ -19,6 +19,7 @@ const state = require("@tiptap/pm/state");
19
19
  const composerMessage = require("./composer-message.cjs");
20
20
  const pendingAttachmentUploads = require("./pending-attachment-uploads.cjs");
21
21
  const runInputRulesOnEnter = require("./run-input-rules-on-enter.cjs");
22
+ const athenaAssetDrag = require("../../agent-runtime/src/athena-asset-drag.cjs");
22
23
  const assetAttachment = require("../../agent-runtime/src/asset-attachment.cjs");
23
24
  const cnfast = require("cnfast");
24
25
  const SubmitKeybind = core.Extension.create({
@@ -357,23 +358,56 @@ const TiptapComposer = react.forwardRef(
357
358
  },
358
359
  [addAttachment, fileIntake, onAttachmentError]
359
360
  );
361
+ const disabledRef = react.useRef(disabled);
362
+ disabledRef.current = disabled;
363
+ const insertAssetMentionRef = react.useRef(
364
+ () => {
365
+ }
366
+ );
367
+ const handleAssetDrop = react.useCallback(
368
+ (event, view) => {
369
+ if (disabledRef.current || !event.dataTransfer) return false;
370
+ const dropped = athenaAssetDrag.readAthenaAssetDrop(event.dataTransfer);
371
+ if (!dropped) return false;
372
+ event.preventDefault();
373
+ if (dropped.kind !== "asset") return true;
374
+ const position = view == null ? void 0 : view.posAtCoords({
375
+ left: event.clientX,
376
+ top: event.clientY
377
+ });
378
+ if (view) {
379
+ const { state: state$1 } = view;
380
+ view.dispatch(
381
+ state$1.tr.setSelection(
382
+ position ? state.Selection.near(state$1.doc.resolve(position.pos)) : state.Selection.atEnd(state$1.doc)
383
+ )
384
+ );
385
+ }
386
+ insertAssetMentionRef.current(dropped.asset);
387
+ return true;
388
+ },
389
+ []
390
+ );
360
391
  const handleDrop = react.useCallback(
361
- (_view, event) => {
392
+ (view, event) => {
362
393
  var _a;
394
+ if (handleAssetDrop(event, view)) return true;
363
395
  const files = (_a = event.dataTransfer) == null ? void 0 : _a.files;
364
396
  if (!(files == null ? void 0 : files.length)) return false;
365
397
  const handled = addDroppedImages(files);
366
398
  if (handled) event.preventDefault();
367
399
  return handled;
368
400
  },
369
- [addDroppedImages]
401
+ [addDroppedImages, handleAssetDrop]
370
402
  );
371
403
  const handleComposerDrop = react.useCallback(
372
404
  (event) => {
405
+ var _a;
373
406
  if (event.defaultPrevented) return;
407
+ if (handleAssetDrop(event.nativeEvent, (_a = editorRef.current) == null ? void 0 : _a.view)) return;
374
408
  if (addDroppedImages(event.dataTransfer.files)) event.preventDefault();
375
409
  },
376
- [addDroppedImages]
410
+ [addDroppedImages, handleAssetDrop]
377
411
  );
378
412
  const placeholderRef = react.useRef(placeholder);
379
413
  placeholderRef.current = placeholder;
@@ -514,6 +548,7 @@ const TiptapComposer = react.forwardRef(
514
548
  },
515
549
  [replaceImagePreviews, showImagePreviews]
516
550
  );
551
+ insertAssetMentionRef.current = insertAssetMention;
517
552
  const removeImagePreview = react.useCallback(
518
553
  (preview) => {
519
554
  if (!preview.assetId) return;
@@ -592,7 +627,8 @@ const TiptapComposer = react.forwardRef(
592
627
  "aria-label": "Message composer",
593
628
  "aria-disabled": disabled,
594
629
  onDragOver: (event) => {
595
- if (Array.from(event.dataTransfer.types).includes("Files")) {
630
+ const types = Array.from(event.dataTransfer.types);
631
+ if (types.includes("Files") || !disabled && athenaAssetDrag.isAthenaAssetDrag(types)) {
596
632
  event.preventDefault();
597
633
  event.dataTransfer.dropEffect = "copy";
598
634
  }