@athenaintel/react 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -11
- package/dist/assets/AssetPanel.cjs +277 -0
- package/dist/assets/AssetPanel.cjs.map +1 -0
- package/dist/assets/AssetPanel.js +277 -0
- package/dist/assets/AssetPanel.js.map +1 -0
- package/dist/assets/AthenaAssetEmbed.cjs +151 -0
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -0
- package/dist/assets/AthenaAssetEmbed.js +151 -0
- package/dist/assets/AthenaAssetEmbed.js.map +1 -0
- package/dist/assets/AthenaLayout.cjs +69 -0
- package/dist/assets/AthenaLayout.cjs.map +1 -0
- package/dist/assets/AthenaLayout.js +69 -0
- package/dist/assets/AthenaLayout.js.map +1 -0
- package/dist/assets/asset-embed-messages.cjs +39 -0
- package/dist/assets/asset-embed-messages.cjs.map +1 -0
- package/dist/assets/asset-embed-messages.js +39 -0
- package/dist/assets/asset-embed-messages.js.map +1 -0
- package/dist/assets/asset-panel-store.cjs +124 -0
- package/dist/assets/asset-panel-store.cjs.map +1 -0
- package/dist/assets/asset-panel-store.js +124 -0
- package/dist/assets/asset-panel-store.js.map +1 -0
- package/dist/assets/asset-panel-url.cjs +40 -0
- package/dist/assets/asset-panel-url.cjs.map +1 -0
- package/dist/assets/asset-panel-url.js +40 -0
- package/dist/assets/asset-panel-url.js.map +1 -0
- package/dist/assets/use-asset-embed.cjs +370 -0
- package/dist/assets/use-asset-embed.cjs.map +1 -0
- package/dist/assets/use-asset-embed.js +370 -0
- package/dist/assets/use-asset-embed.js.map +1 -0
- package/dist/{AthenaAuthContext-B3AwLA5Z.cjs → auth/AthenaAuthContext.cjs} +5 -4
- package/dist/auth/AthenaAuthContext.cjs.map +1 -0
- package/dist/{AthenaAuthContext-DQsdayH2.js → auth/AthenaAuthContext.js} +3 -3
- package/dist/auth/AthenaAuthContext.js.map +1 -0
- package/dist/auth/AthenaAuthProvider.cjs +141 -0
- package/dist/auth/AthenaAuthProvider.cjs.map +1 -0
- package/dist/auth/AthenaAuthProvider.js +141 -0
- package/dist/auth/AthenaAuthProvider.js.map +1 -0
- package/dist/{auth.cjs → auth/AthenaSSOProvider.cjs} +14 -151
- package/dist/auth/AthenaSSOProvider.cjs.map +1 -0
- package/dist/{auth.js → auth/AthenaSSOProvider.js} +4 -142
- package/dist/auth/AthenaSSOProvider.js.map +1 -0
- package/dist/auth/index.cjs +10 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +753 -0
- package/dist/chat/AthenaChat.cjs.map +1 -0
- package/dist/chat/AthenaChat.d.ts +3 -2
- package/dist/chat/AthenaChat.js +753 -0
- package/dist/chat/AthenaChat.js.map +1 -0
- package/dist/chat/AthenaChatErrorBoundary.cjs +53 -0
- package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -0
- package/dist/chat/AthenaChatErrorBoundary.js +53 -0
- package/dist/chat/AthenaChatErrorBoundary.js.map +1 -0
- package/dist/chat/StatewireApprovalCard.cjs +189 -0
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -0
- package/dist/chat/StatewireApprovalCard.d.ts +14 -0
- package/dist/chat/StatewireApprovalCard.js +189 -0
- package/dist/chat/StatewireApprovalCard.js.map +1 -0
- package/dist/chat/StatewireClientToolBridge.cjs +51 -0
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -0
- package/dist/chat/StatewireClientToolBridge.js +51 -0
- package/dist/chat/StatewireClientToolBridge.js.map +1 -0
- package/dist/chat/StatewireQueuedMessages.cjs +433 -0
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -0
- package/dist/chat/StatewireQueuedMessages.d.ts +3 -4
- package/dist/chat/StatewireQueuedMessages.js +433 -0
- package/dist/chat/StatewireQueuedMessages.js.map +1 -0
- package/dist/chat/athena-citation-links.cjs +342 -0
- package/dist/chat/athena-citation-links.cjs.map +1 -0
- package/dist/chat/athena-citation-links.js +342 -0
- package/dist/chat/athena-citation-links.js.map +1 -0
- package/dist/chat/run-activity.cjs +28 -0
- package/dist/chat/run-activity.cjs.map +1 -0
- package/dist/chat/run-activity.js +28 -0
- package/dist/chat/run-activity.js.map +1 -0
- package/dist/chat/statewire-banners.cjs +83 -0
- package/dist/chat/statewire-banners.cjs.map +1 -0
- package/dist/chat/statewire-banners.js +83 -0
- package/dist/chat/statewire-banners.js.map +1 -0
- package/dist/chat/statewire-client-tools.cjs +74 -0
- package/dist/chat/statewire-client-tools.cjs.map +1 -0
- package/dist/chat/statewire-client-tools.js +74 -0
- package/dist/chat/statewire-client-tools.js.map +1 -0
- package/dist/chat/super-grouping/CollapsibleGroup.cjs +158 -0
- package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -0
- package/dist/chat/super-grouping/CollapsibleGroup.js +158 -0
- package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -0
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +243 -0
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -0
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +14 -7
- package/dist/chat/super-grouping/SuperGroupingCard.js +243 -0
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs +131 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.d.ts +16 -0
- package/dist/chat/super-grouping/ToolTimeline.js +131 -0
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -0
- package/dist/chat/super-grouping/activity-timeline.cjs +157 -0
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -0
- package/dist/chat/super-grouping/activity-timeline.d.ts +6 -3
- package/dist/chat/super-grouping/activity-timeline.js +157 -0
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -0
- package/dist/chat/super-grouping/grouping-function.cjs +55 -0
- package/dist/chat/super-grouping/grouping-function.cjs.map +1 -0
- package/dist/chat/super-grouping/grouping-function.js +55 -0
- package/dist/chat/super-grouping/grouping-function.js.map +1 -0
- package/dist/chat/super-grouping/index.cjs +26 -0
- package/dist/chat/super-grouping/index.cjs.map +1 -0
- package/dist/chat/super-grouping/index.js +26 -0
- package/dist/chat/super-grouping/index.js.map +1 -0
- package/dist/chat/super-grouping/timeline-step.cjs +65 -0
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -0
- package/dist/chat/super-grouping/timeline-step.d.ts +17 -0
- package/dist/chat/super-grouping/timeline-step.js +65 -0
- package/dist/chat/super-grouping/timeline-step.js.map +1 -0
- package/dist/chat/super-grouping/toolkit-map.cjs +96 -0
- package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -0
- package/dist/chat/super-grouping/toolkit-map.js +96 -0
- package/dist/chat/super-grouping/toolkit-map.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +101 -0
- package/dist/chat/tiptap-text.cjs.map +1 -0
- package/dist/chat/tiptap-text.js +101 -0
- package/dist/chat/tiptap-text.js.map +1 -0
- package/dist/chat/tooltip-icon-button.cjs +32 -0
- package/dist/chat/tooltip-icon-button.cjs.map +1 -0
- package/dist/chat/tooltip-icon-button.js +32 -0
- package/dist/chat/tooltip-icon-button.js.map +1 -0
- package/dist/chat/use-athena-run-live.cjs +24 -0
- package/dist/chat/use-athena-run-live.cjs.map +1 -0
- package/dist/chat/use-athena-run-live.d.ts +10 -0
- package/dist/chat/use-athena-run-live.js +24 -0
- package/dist/chat/use-athena-run-live.js.map +1 -0
- package/dist/chat/use-statewire-approval-request.cjs +51 -0
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -0
- package/dist/chat/use-statewire-approval-request.d.ts +12 -2
- package/dist/chat/use-statewire-approval-request.js +51 -0
- package/dist/chat/use-statewire-approval-request.js.map +1 -0
- package/dist/chat-ui/auth/sign-in-card.cjs +128 -0
- package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -0
- package/dist/chat-ui/auth/sign-in-card.js +128 -0
- package/dist/chat-ui/auth/sign-in-card.js.map +1 -0
- package/dist/chat-ui/composer/composer-action.cjs +11 -0
- package/dist/chat-ui/composer/composer-action.cjs.map +1 -0
- package/dist/chat-ui/composer/composer-action.d.ts +5 -8
- package/dist/chat-ui/composer/composer-action.js +11 -0
- package/dist/chat-ui/composer/composer-action.js.map +1 -0
- package/dist/chat-ui/composer/pending-attachment-uploads.cjs +25 -0
- package/dist/chat-ui/composer/pending-attachment-uploads.cjs.map +1 -0
- package/dist/chat-ui/composer/pending-attachment-uploads.js +25 -0
- package/dist/chat-ui/composer/pending-attachment-uploads.js.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs +549 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.d.ts +44 -7
- package/dist/chat-ui/composer/tiptap-composer.js +549 -0
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -0
- package/dist/chat-ui/header/chat-header.cjs +33 -0
- package/dist/chat-ui/header/chat-header.cjs.map +1 -0
- package/dist/chat-ui/header/chat-header.js +33 -0
- package/dist/chat-ui/header/chat-header.js.map +1 -0
- package/dist/chat-ui/header/conversation-history-panel.cjs +369 -0
- package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -0
- package/dist/chat-ui/header/conversation-history-panel.js +369 -0
- package/dist/chat-ui/header/conversation-history-panel.js.map +1 -0
- package/dist/chat-ui/index.cjs +140 -0
- package/dist/chat-ui/index.cjs.map +1 -0
- package/dist/chat-ui/index.d.ts +4 -3
- package/dist/chat-ui/index.js +140 -0
- package/dist/chat-ui/index.js.map +1 -0
- package/dist/chat-ui/lib/asset-urls.cjs +18 -0
- package/dist/chat-ui/lib/asset-urls.cjs.map +1 -0
- package/dist/chat-ui/lib/asset-urls.js +18 -0
- package/dist/chat-ui/lib/asset-urls.js.map +1 -0
- package/dist/chat-ui/mentions/mention-chip.cjs +253 -0
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -0
- package/dist/chat-ui/mentions/mention-chip.d.ts +11 -0
- package/dist/chat-ui/mentions/mention-chip.js +253 -0
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -0
- package/dist/chat-ui/mentions/mention-extension.cjs +196 -0
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -0
- package/dist/chat-ui/mentions/mention-extension.d.ts +26 -2
- package/dist/chat-ui/mentions/mention-extension.js +196 -0
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +35 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +35 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +95 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +5 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +95 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +116 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +116 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +31 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +31 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-breadcrumbs.cjs +27 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-breadcrumbs.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-breadcrumbs.js +27 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-breadcrumbs.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +65 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-item.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js +65 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +63 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js +63 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-skeleton.cjs +11 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-skeleton.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-skeleton.js +11 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-skeleton.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-summary.cjs +33 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-summary.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-summary.js +33 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-summary.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +58 -0
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.js +58 -0
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +81 -0
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.js +81 -0
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/utils.cjs +18 -0
- package/dist/chat-ui/mentions/suggestions/components/utils.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/components/utils.js +18 -0
- package/dist/chat-ui/mentions/suggestions/components/utils.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +124 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +13 -2
- package/dist/chat-ui/mentions/suggestions/data/api-client.js +124 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/item-cache.cjs +37 -0
- package/dist/chat-ui/mentions/suggestions/data/item-cache.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/item-cache.js +37 -0
- package/dist/chat-ui/mentions/suggestions/data/item-cache.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +134 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +134 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/scope-registry.cjs +91 -0
- package/dist/chat-ui/mentions/suggestions/data/scope-registry.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/scope-registry.js +91 -0
- package/dist/chat-ui/mentions/suggestions/data/scope-registry.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +137 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +137 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +375 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +16 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +375 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/types.cjs +9 -0
- package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/types.d.ts +14 -0
- package/dist/chat-ui/mentions/suggestions/data/types.js +9 -0
- package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +173 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +14 -4
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +173 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +45 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +45 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/filter-items.cjs +43 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/filter-items.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/filter-items.js +43 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/filter-items.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/match-query.cjs +14 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/match-query.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/match-query.js +14 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/match-query.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/score-match.cjs +48 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/score-match.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/score-match.js +48 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/score-match.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +71 -0
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +71 -0
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -0
- package/dist/chat-ui/messages/continue-pill.cjs +54 -0
- package/dist/chat-ui/messages/continue-pill.cjs.map +1 -0
- package/dist/chat-ui/messages/continue-pill.js +54 -0
- package/dist/chat-ui/messages/continue-pill.js.map +1 -0
- package/dist/chat-ui/messages/message-actions-config.cjs +12 -0
- package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -0
- package/dist/chat-ui/messages/message-actions-config.js +12 -0
- package/dist/chat-ui/messages/message-actions-config.js.map +1 -0
- package/dist/chat-ui/messages/message-components.cjs +320 -0
- package/dist/chat-ui/messages/message-components.cjs.map +1 -0
- package/dist/chat-ui/messages/message-components.d.ts +1 -1
- package/dist/chat-ui/messages/message-components.js +320 -0
- package/dist/chat-ui/messages/message-components.js.map +1 -0
- package/dist/chat-ui/messages/running-indicator.cjs +49 -0
- package/dist/chat-ui/messages/running-indicator.cjs.map +1 -0
- package/dist/chat-ui/messages/running-indicator.js +49 -0
- package/dist/chat-ui/messages/running-indicator.js.map +1 -0
- package/dist/chat-ui/messages/runtime-message.cjs +66 -0
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -0
- package/dist/chat-ui/messages/runtime-message.js +66 -0
- package/dist/chat-ui/messages/runtime-message.js.map +1 -0
- package/dist/{statewire-continue-run-nE9VCKUh.cjs → chat-ui/messages/statewire-continue-run.cjs} +61 -23
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -0
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +19 -5
- package/dist/{statewire-continue-run-D34gS7_1.js → chat-ui/messages/statewire-continue-run.js} +51 -14
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -0
- package/dist/chat-ui/messages/user-edit-composer.cjs +62 -0
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -0
- package/dist/chat-ui/messages/user-edit-composer.js +62 -0
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -0
- package/dist/chat-ui/messages/voice-delegation-card.cjs +51 -0
- package/dist/chat-ui/messages/voice-delegation-card.cjs.map +1 -0
- package/dist/chat-ui/messages/voice-delegation-card.d.ts +26 -0
- package/dist/chat-ui/messages/voice-delegation-card.js +51 -0
- package/dist/chat-ui/messages/voice-delegation-card.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-message-body.js +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.d.ts +13 -0
- package/dist/chat-ui/rich-text/chat-node-views.js +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +7 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.d.ts +11 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js.map +1 -0
- package/dist/chat-ui/statewire.cjs +40 -0
- package/dist/chat-ui/statewire.cjs.map +1 -0
- package/dist/chat-ui/statewire.js +40 -0
- package/dist/chat-ui/statewire.js.map +1 -0
- package/dist/chat-ui/thread/chat-composer-dock.cjs +37 -0
- package/dist/chat-ui/thread/chat-composer-dock.cjs.map +1 -0
- package/dist/chat-ui/thread/chat-composer-dock.js +37 -0
- package/dist/chat-ui/thread/chat-composer-dock.js.map +1 -0
- package/dist/chat-ui/thread/chat-thread-shell.cjs +102 -0
- package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -0
- package/dist/chat-ui/thread/chat-thread-shell.js +102 -0
- package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -0
- package/dist/chat-ui/thread/composer-send-or-stop.cjs +75 -0
- package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -0
- package/dist/chat-ui/thread/composer-send-or-stop.d.ts +0 -6
- package/dist/chat-ui/thread/composer-send-or-stop.js +75 -0
- package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -0
- package/dist/chat-ui/thread/statewire-history-edge.cjs +135 -0
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -0
- package/dist/chat-ui/thread/statewire-history-edge.js +135 -0
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -0
- package/dist/{collab.cjs → collab/client.cjs} +6 -166
- package/dist/collab/client.cjs.map +1 -0
- package/dist/{collab.js → collab/client.js} +5 -164
- package/dist/collab/client.js.map +1 -0
- package/dist/collab/close-policy.cjs +14 -0
- package/dist/collab/close-policy.cjs.map +1 -0
- package/dist/collab/close-policy.js +14 -0
- package/dist/collab/close-policy.js.map +1 -0
- package/dist/collab/index.cjs +17 -0
- package/dist/collab/index.cjs.map +1 -0
- package/dist/collab/index.js +17 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/collab/mint.cjs +59 -0
- package/dist/collab/mint.cjs.map +1 -0
- package/dist/collab/mint.js +59 -0
- package/dist/collab/mint.js.map +1 -0
- package/dist/collab/react.cjs +58 -0
- package/dist/collab/react.cjs.map +1 -0
- package/dist/collab/react.js +58 -0
- package/dist/collab/react.js.map +1 -0
- package/dist/collab/shape.cjs +45 -0
- package/dist/collab/shape.cjs.map +1 -0
- package/dist/collab/shape.js +45 -0
- package/dist/collab/shape.js.map +1 -0
- package/dist/composer/AttachmentContext.cjs +40 -0
- package/dist/composer/AttachmentContext.cjs.map +1 -0
- package/dist/composer/AttachmentContext.js +40 -0
- package/dist/composer/AttachmentContext.js.map +1 -0
- package/dist/composer/ComposerAttachmentPreview.cjs +39 -0
- package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -0
- package/dist/composer/ComposerAttachmentPreview.js +39 -0
- package/dist/composer/ComposerAttachmentPreview.js.map +1 -0
- package/dist/composer/ComposerDropZone.cjs +61 -0
- package/dist/composer/ComposerDropZone.cjs.map +1 -0
- package/dist/composer/ComposerDropZone.d.ts +1 -1
- package/dist/composer/ComposerDropZone.js +61 -0
- package/dist/composer/ComposerDropZone.js.map +1 -0
- package/dist/composer/ComposerQuotePreview.cjs +42 -0
- package/dist/composer/ComposerQuotePreview.cjs.map +1 -0
- package/dist/composer/ComposerQuotePreview.js +42 -0
- package/dist/composer/ComposerQuotePreview.js.map +1 -0
- package/dist/composer/FileUploadButton.cjs +65 -0
- package/dist/composer/FileUploadButton.cjs.map +1 -0
- package/dist/composer/FileUploadButton.d.ts +1 -1
- package/dist/composer/FileUploadButton.js +65 -0
- package/dist/composer/FileUploadButton.js.map +1 -0
- package/dist/composer/QuoteContext.cjs +68 -0
- package/dist/composer/QuoteContext.cjs.map +1 -0
- package/dist/composer/QuoteContext.js +68 -0
- package/dist/composer/QuoteContext.js.map +1 -0
- package/dist/composer/build-composed-message.cjs +25 -0
- package/dist/composer/build-composed-message.cjs.map +1 -0
- package/dist/composer/build-composed-message.js +25 -0
- package/dist/composer/build-composed-message.js.map +1 -0
- package/dist/composer/clipboard.cjs +62 -0
- package/dist/composer/clipboard.cjs.map +1 -0
- package/dist/composer/clipboard.d.ts +27 -3
- package/dist/composer/clipboard.js +62 -0
- package/dist/composer/clipboard.js.map +1 -0
- package/dist/composer/useAppendToComposer.cjs +21 -0
- package/dist/composer/useAppendToComposer.cjs.map +1 -0
- package/dist/composer/useAppendToComposer.js +21 -0
- package/dist/composer/useAppendToComposer.js.map +1 -0
- package/dist/composer/useAttachFiles.cjs +40 -0
- package/dist/composer/useAttachFiles.cjs.map +1 -0
- package/dist/composer/useAttachFiles.d.ts +24 -0
- package/dist/composer/useAttachFiles.js +40 -0
- package/dist/composer/useAttachFiles.js.map +1 -0
- package/dist/composer/useComposerAttachment.cjs +25 -0
- package/dist/composer/useComposerAttachment.cjs.map +1 -0
- package/dist/composer/useComposerAttachment.js +25 -0
- package/dist/composer/useComposerAttachment.js.map +1 -0
- package/dist/composer/useFileUpload.cjs +123 -0
- package/dist/composer/useFileUpload.cjs.map +1 -0
- package/dist/composer/useFileUpload.js +123 -0
- package/dist/composer/useFileUpload.js.map +1 -0
- package/dist/composer/useSendMessage.cjs +22 -0
- package/dist/composer/useSendMessage.cjs.map +1 -0
- package/dist/composer/useSendMessage.js +22 -0
- package/dist/composer/useSendMessage.js.map +1 -0
- package/dist/diagnostics/athena-diagnostics.cjs +329 -0
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -0
- package/dist/diagnostics/athena-diagnostics.js +329 -0
- package/dist/diagnostics/athena-diagnostics.js.map +1 -0
- package/dist/diagnostics/errors.cjs +89 -0
- package/dist/diagnostics/errors.cjs.map +1 -0
- package/dist/diagnostics/errors.js +89 -0
- package/dist/diagnostics/errors.js.map +1 -0
- package/dist/diagnostics/useAthenaDiagnostics.cjs +16 -0
- package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -0
- package/dist/diagnostics/useAthenaDiagnostics.js +16 -0
- package/dist/diagnostics/useAthenaDiagnostics.js.map +1 -0
- package/dist/index.cjs +275 -27882
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +162 -27759
- package/dist/index.js.map +1 -1
- package/dist/lib/athena-urls.cjs +194 -0
- package/dist/lib/athena-urls.cjs.map +1 -0
- package/dist/lib/athena-urls.d.ts +20 -5
- package/dist/lib/athena-urls.js +194 -0
- package/dist/lib/athena-urls.js.map +1 -0
- package/dist/lib/posthog/before-send.cjs +58 -0
- package/dist/lib/posthog/before-send.cjs.map +1 -0
- package/dist/lib/posthog/before-send.js +58 -0
- package/dist/lib/posthog/before-send.js.map +1 -0
- package/dist/lib/posthog/capture-gate.cjs +322 -0
- package/dist/lib/posthog/capture-gate.cjs.map +1 -0
- package/dist/lib/posthog/capture-gate.js +322 -0
- package/dist/lib/posthog/capture-gate.js.map +1 -0
- package/dist/lib/posthog/wrap-posthog-client.cjs +163 -0
- package/dist/lib/posthog/wrap-posthog-client.cjs.map +1 -0
- package/dist/lib/posthog/wrap-posthog-client.js +163 -0
- package/dist/lib/posthog/wrap-posthog-client.js.map +1 -0
- package/dist/lib/utils.cjs +12 -0
- package/dist/lib/utils.cjs.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +77 -0
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +1 -0
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +77 -0
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +1 -0
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +181 -0
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +1 -0
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +181 -0
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +1 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs +32 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs.map +1 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js +31 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +44 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +43 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +29 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +29 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.cjs +570 -0
- package/dist/node_modules/zod/v4/core/api.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +570 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +411 -0
- package/dist/node_modules/zod/v4/core/checks.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +411 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.cjs +77 -0
- package/dist/node_modules/zod/v4/core/core.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +77 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +38 -0
- package/dist/node_modules/zod/v4/core/doc.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +76 -0
- package/dist/node_modules/zod/v4/core/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +76 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +96 -0
- package/dist/node_modules/zod/v4/core/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +96 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +86 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +86 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
- package/dist/node_modules/zod/v4/core/registries.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +1412 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1413 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.cjs +444 -0
- package/dist/node_modules/zod/v4/core/util.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +444 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +9 -0
- package/dist/node_modules/zod/v4/core/versions.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/packages/agent-runtime/src/asset-attachment.cjs +19 -0
- package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/asset-attachment.js +19 -0
- package/dist/packages/agent-runtime/src/asset-attachment.js.map +1 -0
- package/dist/packages/agent-runtime/src/auth-denial.cjs +28 -0
- package/dist/packages/agent-runtime/src/auth-denial.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/auth-denial.js +28 -0
- package/dist/packages/agent-runtime/src/auth-denial.js.map +1 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs +276 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.js +276 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +1 -0
- package/dist/packages/agent-runtime/src/client-tools.cjs +137 -0
- package/dist/packages/agent-runtime/src/client-tools.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/client-tools.js +137 -0
- package/dist/packages/agent-runtime/src/client-tools.js.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-index.cjs +80 -0
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-index.js +80 -0
- package/dist/packages/agent-runtime/src/conversation-index.js.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs +90 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-list.js +90 -0
- package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -0
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs +55 -0
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js +55 -0
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
- package/dist/packages/agent-runtime/src/edit-command.cjs +89 -0
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/edit-command.js +89 -0
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -0
- package/dist/packages/agent-runtime/src/errors.cjs +95 -0
- package/dist/packages/agent-runtime/src/errors.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/errors.js +95 -0
- package/dist/packages/agent-runtime/src/errors.js.map +1 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +238 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +238 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
- package/dist/packages/agent-runtime/src/interrupts.cjs +141 -0
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/interrupts.js +141 -0
- package/dist/packages/agent-runtime/src/interrupts.js.map +1 -0
- package/dist/packages/agent-runtime/src/message-author.cjs +31 -0
- package/dist/packages/agent-runtime/src/message-author.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/message-author.js +31 -0
- package/dist/packages/agent-runtime/src/message-author.js.map +1 -0
- package/dist/packages/agent-runtime/src/message-window.cjs +85 -0
- package/dist/packages/agent-runtime/src/message-window.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/message-window.js +85 -0
- package/dist/packages/agent-runtime/src/message-window.js.map +1 -0
- package/dist/packages/agent-runtime/src/messages.cjs +463 -0
- package/dist/packages/agent-runtime/src/messages.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/messages.js +463 -0
- package/dist/packages/agent-runtime/src/messages.js.map +1 -0
- package/dist/packages/agent-runtime/src/model-context.cjs +13 -0
- package/dist/packages/agent-runtime/src/model-context.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/model-context.js +13 -0
- package/dist/packages/agent-runtime/src/model-context.js.map +1 -0
- package/dist/packages/agent-runtime/src/optimistic-content.cjs +17 -0
- package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/optimistic-content.js +17 -0
- package/dist/packages/agent-runtime/src/optimistic-content.js.map +1 -0
- package/dist/packages/agent-runtime/src/protocol.cjs +31 -0
- package/dist/packages/agent-runtime/src/protocol.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/protocol.js +31 -0
- package/dist/packages/agent-runtime/src/protocol.js.map +1 -0
- package/dist/packages/agent-runtime/src/queue.cjs +67 -0
- package/dist/packages/agent-runtime/src/queue.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/queue.js +67 -0
- package/dist/packages/agent-runtime/src/queue.js.map +1 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +329 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +329 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
- package/dist/packages/agent-runtime/src/runtime-messages.cjs +187 -0
- package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/runtime-messages.js +187 -0
- package/dist/packages/agent-runtime/src/runtime-messages.js.map +1 -0
- package/dist/packages/agent-runtime/src/screen-point.cjs +68 -0
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/screen-point.js +68 -0
- package/dist/packages/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/packages/agent-runtime/src/send-recovery.cjs +128 -0
- package/dist/packages/agent-runtime/src/send-recovery.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/send-recovery.js +128 -0
- package/dist/packages/agent-runtime/src/send-recovery.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs +249 -0
- package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-attach-observer.js +249 -0
- package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-state.cjs +16 -0
- package/dist/packages/agent-runtime/src/statewire-state.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-state.js +16 -0
- package/dist/packages/agent-runtime/src/statewire-state.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs +41 -0
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-suspended.js +41 -0
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +11 -0
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-transport.js +11 -0
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +1 -0
- package/dist/packages/agent-runtime/src/streaming-markdown.cjs +214 -0
- package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/streaming-markdown.js +214 -0
- package/dist/packages/agent-runtime/src/streaming-markdown.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-extras.cjs +38 -0
- package/dist/packages/agent-runtime/src/thread-extras.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-extras.js +38 -0
- package/dist/packages/agent-runtime/src/thread-extras.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-handoff.cjs +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs +90 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js +90 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-status.cjs +49 -0
- package/dist/packages/agent-runtime/src/thread-status.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-status.js +49 -0
- package/dist/packages/agent-runtime/src/thread-status.js.map +1 -0
- package/dist/packages/agent-runtime/src/tool-metadata.cjs +1794 -0
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/tool-metadata.js +1794 -0
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +1 -0
- package/dist/packages/agent-runtime/src/tool-outputs.cjs +46 -0
- package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/tool-outputs.js +46 -0
- package/dist/packages/agent-runtime/src/tool-outputs.js.map +1 -0
- package/dist/packages/agent-runtime/src/tool-result.cjs +151 -0
- package/dist/packages/agent-runtime/src/tool-result.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/tool-result.js +151 -0
- package/dist/packages/agent-runtime/src/tool-result.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-conversation-list.cjs +139 -0
- package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-conversation-list.js +139 -0
- package/dist/packages/agent-runtime/src/use-conversation-list.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs +44 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js +44 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs +148 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js +148 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +407 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js +407 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs +133 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js +133 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
- package/dist/packages/agent-runtime/src/voice-presentation.cjs +37 -0
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/voice-presentation.js +37 -0
- package/dist/packages/agent-runtime/src/voice-presentation.js.map +1 -0
- package/dist/packages/react/package.json.cjs +9 -0
- package/dist/packages/react/package.json.cjs.map +1 -0
- package/dist/packages/react/package.json.js +9 -0
- package/dist/packages/react/package.json.js.map +1 -0
- package/dist/{AthenaContext-B1QMhIP-.cjs → provider/AthenaContext.cjs} +5 -4
- package/dist/provider/AthenaContext.cjs.map +1 -0
- package/dist/{AthenaContext-MOslgOmE.js → provider/AthenaContext.js} +3 -3
- package/dist/provider/AthenaContext.js.map +1 -0
- package/dist/provider/AthenaProvider.cjs +404 -0
- package/dist/provider/AthenaProvider.cjs.map +1 -0
- package/dist/provider/AthenaProvider.js +404 -0
- package/dist/provider/AthenaProvider.js.map +1 -0
- package/dist/provider/PostHogProvider.cjs +81 -0
- package/dist/provider/PostHogProvider.cjs.map +1 -0
- package/dist/provider/PostHogProvider.js +59 -0
- package/dist/provider/PostHogProvider.js.map +1 -0
- package/dist/provider/config.d.ts +8 -7
- package/dist/provider/statewire-lifecycle-context.cjs +10 -0
- package/dist/provider/statewire-lifecycle-context.cjs.map +1 -0
- package/dist/provider/statewire-lifecycle-context.js +10 -0
- package/dist/provider/statewire-lifecycle-context.js.map +1 -0
- package/dist/provider/statewire-window-context.cjs +10 -0
- package/dist/provider/statewire-window-context.cjs.map +1 -0
- package/dist/provider/statewire-window-context.js +10 -0
- package/dist/provider/statewire-window-context.js.map +1 -0
- package/dist/runtime/auth.cjs +309 -0
- package/dist/runtime/auth.cjs.map +1 -0
- package/dist/runtime/auth.d.ts +19 -18
- package/dist/runtime/auth.js +309 -0
- package/dist/runtime/auth.js.map +1 -0
- package/dist/runtime/statewire-auth-headers.cjs +18 -0
- package/dist/runtime/statewire-auth-headers.cjs.map +1 -0
- package/dist/runtime/statewire-auth-headers.js +18 -0
- package/dist/runtime/statewire-auth-headers.js.map +1 -0
- package/dist/runtime/statewire-lifecycle.cjs +68 -0
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -0
- package/dist/runtime/statewire-lifecycle.js +68 -0
- package/dist/runtime/statewire-lifecycle.js.map +1 -0
- package/dist/runtime/statewire-run-config.cjs +68 -0
- package/dist/runtime/statewire-run-config.cjs.map +1 -0
- package/dist/runtime/statewire-run-config.js +68 -0
- package/dist/runtime/statewire-run-config.js.map +1 -0
- package/dist/runtime/statewire-session-key.cjs +11 -0
- package/dist/runtime/statewire-session-key.cjs.map +1 -0
- package/dist/runtime/statewire-session-key.js +11 -0
- package/dist/runtime/statewire-session-key.js.map +1 -0
- package/dist/runtime/useAthenaStatewireRuntime.cjs +180 -0
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -0
- package/dist/runtime/useAthenaStatewireRuntime.js +181 -0
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme/index.cjs +182 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.js +182 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/threads/ThreadList.cjs +55 -0
- package/dist/threads/ThreadList.cjs.map +1 -0
- package/dist/threads/ThreadList.js +55 -0
- package/dist/threads/ThreadList.js.map +1 -0
- package/dist/threads/api.cjs +208 -0
- package/dist/threads/api.cjs.map +1 -0
- package/dist/threads/api.js +208 -0
- package/dist/threads/api.js.map +1 -0
- package/dist/threads/conversation-list-fetcher.cjs +74 -0
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -0
- package/dist/threads/conversation-list-fetcher.js +74 -0
- package/dist/threads/conversation-list-fetcher.js.map +1 -0
- package/dist/threads/mint-thread-id.cjs +7 -0
- package/dist/threads/mint-thread-id.cjs.map +1 -0
- package/dist/threads/mint-thread-id.js +7 -0
- package/dist/threads/mint-thread-id.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +232 -0
- package/dist/threads/statewire-thread-list.cjs.map +1 -0
- package/dist/threads/statewire-thread-list.js +232 -0
- package/dist/threads/statewire-thread-list.js.map +1 -0
- package/dist/threads/thread-id-context.cjs +22 -0
- package/dist/threads/thread-id-context.cjs.map +1 -0
- package/dist/threads/thread-id-context.d.ts +9 -0
- package/dist/threads/thread-id-context.js +22 -0
- package/dist/threads/thread-id-context.js.map +1 -0
- package/dist/threads/title.cjs +95 -0
- package/dist/threads/title.cjs.map +1 -0
- package/dist/threads/title.js +95 -0
- package/dist/threads/title.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +80 -0
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -0
- package/dist/threads/use-rest-conversation-history.js +80 -0
- package/dist/threads/use-rest-conversation-history.js.map +1 -0
- package/dist/threads/use-statewire-conversation-history.cjs +244 -0
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -0
- package/dist/threads/use-statewire-conversation-history.d.ts +1 -0
- package/dist/threads/use-statewire-conversation-history.js +244 -0
- package/dist/threads/use-statewire-conversation-history.js.map +1 -0
- package/dist/threads/useAthenaThreadManager.cjs +24 -0
- package/dist/threads/useAthenaThreadManager.cjs.map +1 -0
- package/dist/threads/useAthenaThreadManager.js +24 -0
- package/dist/threads/useAthenaThreadManager.js.map +1 -0
- package/dist/toolkits/index.cjs +279 -0
- package/dist/toolkits/index.cjs.map +1 -0
- package/dist/toolkits/index.js +279 -0
- package/dist/toolkits/index.js.map +1 -0
- package/dist/tools/NestedPtcMessages.cjs +46 -0
- package/dist/tools/NestedPtcMessages.cjs.map +1 -0
- package/dist/tools/NestedPtcMessages.js +46 -0
- package/dist/tools/NestedPtcMessages.js.map +1 -0
- package/dist/tools/append-document-tool-ui.cjs +145 -0
- package/dist/tools/append-document-tool-ui.cjs.map +1 -0
- package/dist/tools/append-document-tool-ui.js +145 -0
- package/dist/tools/append-document-tool-ui.js.map +1 -0
- package/dist/tools/asset-utils.cjs +16 -0
- package/dist/tools/asset-utils.cjs.map +1 -0
- package/dist/tools/asset-utils.js +16 -0
- package/dist/tools/asset-utils.js.map +1 -0
- package/dist/tools/auto-open-tools.cjs +121 -0
- package/dist/tools/auto-open-tools.cjs.map +1 -0
- package/dist/tools/auto-open-tools.js +121 -0
- package/dist/tools/auto-open-tools.js.map +1 -0
- package/dist/tools/file-tool-uis.cjs +108 -0
- package/dist/tools/file-tool-uis.cjs.map +1 -0
- package/dist/tools/file-tool-uis.js +108 -0
- package/dist/tools/file-tool-uis.js.map +1 -0
- package/dist/tools/index.cjs +57 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +57 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/misc-tool-uis.cjs +55 -0
- package/dist/tools/misc-tool-uis.cjs.map +1 -0
- package/dist/{misc-tool-uis-gAiQw0Yl.js → tools/misc-tool-uis.js} +18 -7
- package/dist/tools/misc-tool-uis.js.map +1 -0
- package/dist/tools/primitives.cjs +167 -0
- package/dist/tools/primitives.cjs.map +1 -0
- package/dist/tools/primitives.js +167 -0
- package/dist/tools/primitives.js.map +1 -0
- package/dist/tools/read-asset-tool-ui.cjs +284 -0
- package/dist/tools/read-asset-tool-ui.cjs.map +1 -0
- package/dist/tools/read-asset-tool-ui.js +284 -0
- package/dist/tools/read-asset-tool-ui.js.map +1 -0
- package/dist/tools/todo-plan-store.cjs +88 -0
- package/dist/tools/todo-plan-store.cjs.map +1 -0
- package/dist/tools/todo-plan-store.js +88 -0
- package/dist/tools/todo-plan-store.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +668 -0
- package/dist/tools/tool-fallback.cjs.map +1 -0
- package/dist/tools/tool-fallback.js +668 -0
- package/dist/tools/tool-fallback.js.map +1 -0
- package/dist/tools/tool-icons.cjs +61 -0
- package/dist/tools/tool-icons.cjs.map +1 -0
- package/dist/tools/tool-icons.js +61 -0
- package/dist/tools/tool-icons.js.map +1 -0
- package/dist/tools/tool-uis.cjs +3049 -0
- package/dist/tools/tool-uis.cjs.map +1 -0
- package/dist/tools/tool-uis.js +3049 -0
- package/dist/tools/tool-uis.js.map +1 -0
- package/dist/tools/voice-update-tool-ui.cjs +90 -0
- package/dist/tools/voice-update-tool-ui.cjs.map +1 -0
- package/dist/tools/voice-update-tool-ui.d.ts +27 -0
- package/dist/tools/voice-update-tool-ui.js +90 -0
- package/dist/tools/voice-update-tool-ui.js.map +1 -0
- package/dist/tools/write-todos-tool-ui.cjs +270 -0
- package/dist/tools/write-todos-tool-ui.cjs.map +1 -0
- package/dist/tools/write-todos-tool-ui.js +270 -0
- package/dist/tools/write-todos-tool-ui.js.map +1 -0
- package/dist/ui/button.cjs +57 -0
- package/dist/ui/button.cjs.map +1 -0
- package/dist/ui/button.js +57 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/collapsible.cjs +17 -0
- package/dist/ui/collapsible.cjs.map +1 -0
- package/dist/ui/collapsible.js +17 -0
- package/dist/ui/collapsible.js.map +1 -0
- package/dist/ui/tooltip.cjs +48 -0
- package/dist/ui/tooltip.cjs.map +1 -0
- package/dist/ui/tooltip.js +48 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/version.cjs +6 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/voice/index.cjs +6 -0
- package/dist/voice/index.cjs.map +1 -0
- package/dist/voice/index.d.ts +2 -0
- package/dist/voice/index.js +6 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/use-athena-voice-session.cjs +315 -0
- package/dist/voice/use-athena-voice-session.cjs.map +1 -0
- package/dist/voice/use-athena-voice-session.d.ts +145 -0
- package/dist/voice/use-athena-voice-session.js +315 -0
- package/dist/voice/use-athena-voice-session.js.map +1 -0
- package/package.json +32 -20
- package/dist/AthenaAuthContext-B3AwLA5Z.cjs.map +0 -1
- package/dist/AthenaAuthContext-DQsdayH2.js.map +0 -1
- package/dist/AthenaContext-B1QMhIP-.cjs.map +0 -1
- package/dist/AthenaContext-MOslgOmE.js.map +0 -1
- package/dist/SuperGroupingCard-BsWbHyV_.js +0 -795
- package/dist/SuperGroupingCard-BsWbHyV_.js.map +0 -1
- package/dist/SuperGroupingCard-CRRFUgjN.cjs +0 -794
- package/dist/SuperGroupingCard-CRRFUgjN.cjs.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/chat/ComposerEditorContext.d.ts +0 -36
- package/dist/chat/tiptap-composer.d.ts +0 -7
- package/dist/chat-ui-statewire.cjs +0 -25
- package/dist/chat-ui-statewire.cjs.map +0 -1
- package/dist/chat-ui-statewire.js +0 -25
- package/dist/chat-ui-statewire.js.map +0 -1
- package/dist/chat-ui.cjs +0 -2484
- package/dist/chat-ui.cjs.map +0 -1
- package/dist/chat-ui.js +0 -2486
- package/dist/chat-ui.js.map +0 -1
- package/dist/collab.cjs.map +0 -1
- package/dist/collab.js.map +0 -1
- package/dist/mentions/composer-keybinds.d.ts +0 -5
- package/dist/mentions/mention-extension.d.ts +0 -6
- package/dist/mentions/mention-icons.d.ts +0 -4
- package/dist/mentions/mention-node-view.d.ts +0 -2
- package/dist/mentions/mention-suggestion-list.d.ts +0 -14
- package/dist/mentions/mention-suggestion-popup.d.ts +0 -15
- package/dist/mentions/mention-suggestions-extension.d.ts +0 -11
- package/dist/mentions/mention-types.d.ts +0 -21
- package/dist/mentions/mention-utils.d.ts +0 -23
- package/dist/mentions/use-mention-suggestions.d.ts +0 -29
- package/dist/misc-tool-uis-B2e0Okkn.cjs +0 -43
- package/dist/misc-tool-uis-B2e0Okkn.cjs.map +0 -1
- package/dist/misc-tool-uis-gAiQw0Yl.js.map +0 -1
- package/dist/statewire-continue-run-D34gS7_1.js.map +0 -1
- package/dist/statewire-continue-run-nE9VCKUh.cjs.map +0 -1
- package/dist/statewire-history-edge-C8uyTEjX.cjs +0 -1711
- package/dist/statewire-history-edge-C8uyTEjX.cjs.map +0 -1
- package/dist/statewire-history-edge-CPohUKMt.js +0 -1712
- package/dist/statewire-history-edge-CPohUKMt.js.map +0 -1
- package/dist/super-grouping.cjs +0 -22
- package/dist/super-grouping.cjs.map +0 -1
- package/dist/super-grouping.js +0 -22
- package/dist/super-grouping.js.map +0 -1
- package/dist/tool-fallback-DkQ3DLkn.js +0 -4281
- package/dist/tool-fallback-DkQ3DLkn.js.map +0 -1
- package/dist/tool-fallback-kfhpJQZa.cjs +0 -4297
- package/dist/tool-fallback-kfhpJQZa.cjs.map +0 -1
- package/dist/tools.cjs +0 -41
- package/dist/tools.cjs.map +0 -1
- package/dist/tools.js +0 -41
- package/dist/tools.js.map +0 -1
- package/dist/trash-2-B5OaNAL7.cjs +0 -5096
- package/dist/trash-2-B5OaNAL7.cjs.map +0 -1
- package/dist/trash-2-CCwSURL-.js +0 -5081
- package/dist/trash-2-CCwSURL-.js.map +0 -1
- package/dist/use-rest-conversation-history-Cm8qMRxp.cjs +0 -32397
- package/dist/use-rest-conversation-history-Cm8qMRxp.cjs.map +0 -1
- package/dist/use-rest-conversation-history-veDZS-oL.js +0 -32361
- package/dist/use-rest-conversation-history-veDZS-oL.js.map +0 -1
- package/dist/wrench-BEf72cyP.cjs +0 -417
- package/dist/wrench-BEf72cyP.cjs.map +0 -1
- package/dist/wrench-CbrOlVYm.js +0 -418
- package/dist/wrench-CbrOlVYm.js.map +0 -1
- package/dist/x-Dfd2NzK0.cjs +0 -42
- package/dist/x-Dfd2NzK0.cjs.map +0 -1
- package/dist/x-_DntAa_a.js +0 -43
- package/dist/x-_DntAa_a.js.map +0 -1
|
@@ -0,0 +1,3049 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { athenaDiagnostics } from "../diagnostics/athena-diagnostics.js";
|
|
3
|
+
import { memo, useMemo, useCallback, useEffect, useState, useRef } from "react";
|
|
4
|
+
import { GlobeIcon, FilePlusIcon, MailIcon, BookOpenIcon, PresentationIcon, BarChart3Icon, DatabaseIcon, TablePropertiesIcon, TableIcon, FolderOpenIcon, ExternalLinkIcon, AlertTriangleIcon, CodeIcon, TerminalIcon, ImageIcon, PlayIcon, SheetIcon, CameraIcon, ScissorsIcon, SearchIcon, Maximize2Icon, XIcon, FileTextIcon } from "lucide-react";
|
|
5
|
+
import { normalizeResult, truncate, ToolCard, ExpandableSection } from "./primitives.js";
|
|
6
|
+
import { SearchFilesToolUI, EditFileToolUI, WriteFileToolUI, ListFilesToolUI, ReadFileToolUI } from "./file-tool-uis.js";
|
|
7
|
+
import { WriteTodosToolUI } from "./write-todos-tool-ui.js";
|
|
8
|
+
import { InstallPackageToolUI } from "./misc-tool-uis.js";
|
|
9
|
+
import { useAssetPanelStore } from "../assets/asset-panel-store.js";
|
|
10
|
+
import { useAthenaConfig } from "../provider/AthenaContext.js";
|
|
11
|
+
import { cn } from "cnfast";
|
|
12
|
+
function isSdkToolDebugEnabled() {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
try {
|
|
15
|
+
const hostname = (_a = globalThis.location) == null ? void 0 : _a.hostname;
|
|
16
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return ((_b = globalThis.localStorage) == null ? void 0 : _b.getItem("athena:sdk:debug")) === "1";
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function stringifyDebugPayload(payload) {
|
|
25
|
+
return JSON.stringify(payload, (_key, value) => {
|
|
26
|
+
if (typeof value === "string" && value.length > 800) {
|
|
27
|
+
return `${value.slice(0, 800)}... [truncated ${value.length - 800} chars]`;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function logDebugPayload(label, payload) {
|
|
33
|
+
if (!isSdkToolDebugEnabled()) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
athenaDiagnostics.emit("tools.debug", {
|
|
37
|
+
level: "debug",
|
|
38
|
+
data: { label, payload: stringifyDebugPayload(payload) }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function parseSearchResults(data) {
|
|
42
|
+
const results = data.results ?? data.search_results ?? data.items ?? data.limited_results;
|
|
43
|
+
if (!Array.isArray(results)) return [];
|
|
44
|
+
return results.slice(0, 8).map((r) => {
|
|
45
|
+
const item = r;
|
|
46
|
+
return {
|
|
47
|
+
title: item.title ?? item.name,
|
|
48
|
+
url: item.url ?? item.link ?? item.href,
|
|
49
|
+
content: item.content ?? item.snippet ?? item.description
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const WebSearchToolUIImpl = ({
|
|
54
|
+
toolName,
|
|
55
|
+
args,
|
|
56
|
+
result,
|
|
57
|
+
status
|
|
58
|
+
}) => {
|
|
59
|
+
const typedArgs = args;
|
|
60
|
+
const query = (typedArgs == null ? void 0 : typedArgs.query) ?? (typedArgs == null ? void 0 : typedArgs.search_query) ?? "";
|
|
61
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
62
|
+
const results = useMemo(() => data ? parseSearchResults(data) : [], [data]);
|
|
63
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
64
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
65
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
ToolCard,
|
|
68
|
+
{
|
|
69
|
+
icon: SearchIcon,
|
|
70
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
71
|
+
title: isRunning ? "Searching the web..." : "Web search",
|
|
72
|
+
subtitle: query ? truncate(query, 80) : void 0,
|
|
73
|
+
toolName,
|
|
74
|
+
args: typedArgs,
|
|
75
|
+
result,
|
|
76
|
+
badge: isComplete && results.length > 0 ? `${results.length} results` : void 0,
|
|
77
|
+
error: errorMsg,
|
|
78
|
+
children: isComplete && results.length > 0 && /* @__PURE__ */ jsx(ExpandableSection, { label: "Show search results", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2.5", children: results.map((r, i) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
80
|
+
r.url && /^https?:\/\//i.test(r.url) ? /* @__PURE__ */ jsx(
|
|
81
|
+
"a",
|
|
82
|
+
{
|
|
83
|
+
href: r.url,
|
|
84
|
+
target: "_blank",
|
|
85
|
+
rel: "noopener noreferrer",
|
|
86
|
+
className: "text-[12px] font-medium text-blue-600 hover:underline",
|
|
87
|
+
children: r.title || r.url
|
|
88
|
+
}
|
|
89
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-[12px] font-medium text-foreground", children: r.title || r.url || "Result" }),
|
|
90
|
+
r.url && /* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3 shrink-0 text-muted-foreground" })
|
|
91
|
+
] }),
|
|
92
|
+
r.url && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", children: truncate(r.url, 60) }),
|
|
93
|
+
r.content && /* @__PURE__ */ jsx("p", { className: "text-[11px] leading-relaxed text-muted-foreground", children: truncate(r.content, 200) })
|
|
94
|
+
] }, i)) }) })
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
const WebSearchToolUI = memo(
|
|
99
|
+
WebSearchToolUIImpl
|
|
100
|
+
);
|
|
101
|
+
WebSearchToolUI.displayName = "WebSearchToolUI";
|
|
102
|
+
const BrowseToolUIImpl = ({
|
|
103
|
+
toolName,
|
|
104
|
+
args,
|
|
105
|
+
result,
|
|
106
|
+
status
|
|
107
|
+
}) => {
|
|
108
|
+
const typedArgs = args;
|
|
109
|
+
const url = (typedArgs == null ? void 0 : typedArgs.url) ?? (typedArgs == null ? void 0 : typedArgs.page_url) ?? "";
|
|
110
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
111
|
+
const pageTitle = (data == null ? void 0 : data.title) ?? (data == null ? void 0 : data.page_title);
|
|
112
|
+
const pageContent = (data == null ? void 0 : data.content) ?? (data == null ? void 0 : data.text) ?? (data == null ? void 0 : data.page_text);
|
|
113
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
114
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
115
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
116
|
+
const displayUrl = useMemo(() => {
|
|
117
|
+
if (!url) return void 0;
|
|
118
|
+
try {
|
|
119
|
+
const parsed = new URL(url);
|
|
120
|
+
return parsed.hostname + (parsed.pathname !== "/" ? parsed.pathname : "");
|
|
121
|
+
} catch {
|
|
122
|
+
return truncate(url, 60);
|
|
123
|
+
}
|
|
124
|
+
}, [url]);
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
ToolCard,
|
|
127
|
+
{
|
|
128
|
+
icon: GlobeIcon,
|
|
129
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
130
|
+
title: isRunning ? "Browsing page..." : pageTitle ? truncate(pageTitle, 50) : "Browsed page",
|
|
131
|
+
subtitle: displayUrl,
|
|
132
|
+
toolName,
|
|
133
|
+
args: typedArgs,
|
|
134
|
+
result,
|
|
135
|
+
error: errorMsg,
|
|
136
|
+
children: isComplete && pageContent && /* @__PURE__ */ jsx(ExpandableSection, { label: "Show page content", children: /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed text-muted-foreground", children: truncate(pageContent, 3e3) }) })
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
const BrowseToolUI = memo(
|
|
141
|
+
BrowseToolUIImpl
|
|
142
|
+
);
|
|
143
|
+
BrowseToolUI.displayName = "BrowseToolUI";
|
|
144
|
+
function parseEmailResults(data) {
|
|
145
|
+
const results = data.limited_results ?? data.results ?? data.emails ?? data.messages;
|
|
146
|
+
if (!Array.isArray(results)) return [];
|
|
147
|
+
return results.slice(0, 50).flatMap((r) => {
|
|
148
|
+
const item = asRecord(r);
|
|
149
|
+
if (!item) return [];
|
|
150
|
+
return [
|
|
151
|
+
{
|
|
152
|
+
subject: asString(item.subject) ?? asString(item.title),
|
|
153
|
+
from: asString(item.from) ?? asString(item.sender) ?? asString(item.from_email),
|
|
154
|
+
date: asString(item.date) ?? asString(item.received_at) ?? asString(item.sent_at),
|
|
155
|
+
snippet: asString(item.snippet) ?? asString(item.preview) ?? asString(item.body_preview),
|
|
156
|
+
isDraft: item.is_draft === true
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function formatEmailDate(raw) {
|
|
162
|
+
if (!raw) return void 0;
|
|
163
|
+
const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw.trim());
|
|
164
|
+
const date = dateOnly ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3])) : new Date(raw);
|
|
165
|
+
if (Number.isNaN(date.getTime())) return raw;
|
|
166
|
+
const now = /* @__PURE__ */ new Date();
|
|
167
|
+
if (!dateOnly && date.toDateString() === now.toDateString()) {
|
|
168
|
+
return date.toLocaleTimeString(void 0, {
|
|
169
|
+
hour: "numeric",
|
|
170
|
+
minute: "2-digit"
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const sameYear = date.getFullYear() === now.getFullYear();
|
|
174
|
+
return date.toLocaleDateString(void 0, {
|
|
175
|
+
month: "short",
|
|
176
|
+
day: "numeric",
|
|
177
|
+
...sameYear ? {} : { year: "numeric" }
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const EMAIL_QUERY_OPERATOR = /(?:^|\s)(received|after|before|from|to|subject|has|in|is):(?:"([^"]+)"|(\S+))/gi;
|
|
181
|
+
function humanEmailDate(raw) {
|
|
182
|
+
return formatEmailDate(raw.replace(/\//g, "-")) ?? raw;
|
|
183
|
+
}
|
|
184
|
+
function humanizeEmailQuery(query) {
|
|
185
|
+
if (!query.trim()) return "";
|
|
186
|
+
const phrases = [];
|
|
187
|
+
let freeText = query;
|
|
188
|
+
for (const match of query.matchAll(EMAIL_QUERY_OPERATOR)) {
|
|
189
|
+
const [token, op, quoted, bare] = match;
|
|
190
|
+
const value = quoted ?? bare ?? "";
|
|
191
|
+
freeText = freeText.replace(token, " ");
|
|
192
|
+
switch (op.toLowerCase()) {
|
|
193
|
+
case "received": {
|
|
194
|
+
const [start, end] = value.split("..");
|
|
195
|
+
phrases.push(
|
|
196
|
+
end ? `${humanEmailDate(start)} – ${humanEmailDate(end)}` : humanEmailDate(start)
|
|
197
|
+
);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "after":
|
|
201
|
+
phrases.push(`after ${humanEmailDate(value)}`);
|
|
202
|
+
break;
|
|
203
|
+
case "before":
|
|
204
|
+
phrases.push(`before ${humanEmailDate(value)}`);
|
|
205
|
+
break;
|
|
206
|
+
case "from":
|
|
207
|
+
phrases.push(`from ${value}`);
|
|
208
|
+
break;
|
|
209
|
+
case "to":
|
|
210
|
+
phrases.push(`to ${value}`);
|
|
211
|
+
break;
|
|
212
|
+
case "subject":
|
|
213
|
+
phrases.push(`subject “${value}”`);
|
|
214
|
+
break;
|
|
215
|
+
case "has":
|
|
216
|
+
phrases.push(value === "attachment" ? "with attachments" : `has ${value}`);
|
|
217
|
+
break;
|
|
218
|
+
case "in":
|
|
219
|
+
phrases.push(value === "drafts" ? "drafts only" : `in ${value}`);
|
|
220
|
+
break;
|
|
221
|
+
case "is":
|
|
222
|
+
phrases.push(value);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const remainder = freeText.trim().replace(/\s+/g, " ");
|
|
227
|
+
if (remainder) phrases.push(`“${remainder}”`);
|
|
228
|
+
return phrases.join(" · ");
|
|
229
|
+
}
|
|
230
|
+
const INLINE_EMAIL_ROWS = 3;
|
|
231
|
+
function EmailResultRow({ email }) {
|
|
232
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 py-2 first:pt-0 last:pb-0", children: [
|
|
233
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
234
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-baseline gap-1.5 text-[12px] font-medium text-foreground", children: [
|
|
235
|
+
email.isDraft && /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded bg-amber-100 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-amber-700", children: "Draft" }),
|
|
236
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: email.subject || "No subject" })
|
|
237
|
+
] }),
|
|
238
|
+
email.date && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[10px] text-muted-foreground", children: formatEmailDate(email.date) })
|
|
239
|
+
] }),
|
|
240
|
+
email.from && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-muted-foreground", children: email.from }),
|
|
241
|
+
email.snippet && /* @__PURE__ */ jsx("p", { className: "text-[11px] leading-relaxed text-muted-foreground/80", children: truncate(email.snippet, 150) })
|
|
242
|
+
] });
|
|
243
|
+
}
|
|
244
|
+
const EmailSearchToolUIImpl = ({
|
|
245
|
+
toolName,
|
|
246
|
+
args,
|
|
247
|
+
result,
|
|
248
|
+
status
|
|
249
|
+
}) => {
|
|
250
|
+
const typedArgs = args;
|
|
251
|
+
const query = (typedArgs == null ? void 0 : typedArgs.query) ?? (typedArgs == null ? void 0 : typedArgs.search_query) ?? "";
|
|
252
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
253
|
+
const emails = useMemo(() => data ? parseEmailResults(data) : [], [data]);
|
|
254
|
+
const provider = typeof (data == null ? void 0 : data.provider) === "string" ? data.provider : void 0;
|
|
255
|
+
const totalCount = typeof (data == null ? void 0 : data.count) === "number" ? data.count : emails.length;
|
|
256
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
257
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
258
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
259
|
+
const readableQuery = useMemo(() => humanizeEmailQuery(query), [query]);
|
|
260
|
+
const inlineEmails = emails.slice(0, INLINE_EMAIL_ROWS);
|
|
261
|
+
const overflowEmails = emails.slice(INLINE_EMAIL_ROWS);
|
|
262
|
+
const countLabel = emails.length > 0 && totalCount > emails.length ? `${emails.length} of ${totalCount}` : `${totalCount}`;
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
ToolCard,
|
|
265
|
+
{
|
|
266
|
+
icon: MailIcon,
|
|
267
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
268
|
+
title: isRunning ? "Searching email…" : "Email search",
|
|
269
|
+
subtitle: readableQuery ? truncate(readableQuery, 90) : void 0,
|
|
270
|
+
toolName,
|
|
271
|
+
args: typedArgs,
|
|
272
|
+
result,
|
|
273
|
+
badge: isComplete ? totalCount > 0 ? `${countLabel} email${totalCount === 1 ? "" : "s"}${provider ? ` · ${provider}` : ""}` : "No matches" : void 0,
|
|
274
|
+
error: errorMsg,
|
|
275
|
+
children: isComplete && emails.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
276
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col divide-y divide-border/30", children: inlineEmails.map((email, i) => /* @__PURE__ */ jsx(EmailResultRow, { email }, i)) }),
|
|
277
|
+
overflowEmails.length > 0 && /* @__PURE__ */ jsx(
|
|
278
|
+
ExpandableSection,
|
|
279
|
+
{
|
|
280
|
+
label: `Show ${overflowEmails.length} more`,
|
|
281
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex flex-col divide-y divide-border/30", children: overflowEmails.map((email, i) => /* @__PURE__ */ jsx(EmailResultRow, { email }, i)) })
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] })
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
};
|
|
288
|
+
const EmailSearchToolUI = memo(
|
|
289
|
+
EmailSearchToolUIImpl
|
|
290
|
+
);
|
|
291
|
+
EmailSearchToolUI.displayName = "EmailSearchToolUI";
|
|
292
|
+
function parseEmailAccounts(data) {
|
|
293
|
+
const accounts = data.accounts ?? data.results;
|
|
294
|
+
if (!Array.isArray(accounts)) return [];
|
|
295
|
+
return accounts.slice(0, 10).flatMap((raw) => {
|
|
296
|
+
const item = asRecord(raw);
|
|
297
|
+
if (!item) return [];
|
|
298
|
+
const defaultFlag = typeof item.is_default === "boolean" ? item.is_default : item.default;
|
|
299
|
+
return [
|
|
300
|
+
{
|
|
301
|
+
address: asString(item.email_address) ?? asString(item.email) ?? asString(item.address),
|
|
302
|
+
provider: asString(item.provider) ?? asString(item.provider_name),
|
|
303
|
+
name: asString(item.account_name) ?? asString(item.name),
|
|
304
|
+
isDefault: defaultFlag === true
|
|
305
|
+
}
|
|
306
|
+
];
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const EmailAccountsToolUIImpl = ({
|
|
310
|
+
toolName,
|
|
311
|
+
args,
|
|
312
|
+
result,
|
|
313
|
+
status
|
|
314
|
+
}) => {
|
|
315
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
316
|
+
const accounts = useMemo(
|
|
317
|
+
() => data ? parseEmailAccounts(data) : [],
|
|
318
|
+
[data]
|
|
319
|
+
);
|
|
320
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
321
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
322
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
323
|
+
return /* @__PURE__ */ jsx(
|
|
324
|
+
ToolCard,
|
|
325
|
+
{
|
|
326
|
+
icon: MailIcon,
|
|
327
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
328
|
+
title: isRunning ? "Checking connected email accounts…" : "Email accounts",
|
|
329
|
+
toolName,
|
|
330
|
+
args,
|
|
331
|
+
result,
|
|
332
|
+
badge: isComplete && accounts.length > 0 ? `${accounts.length} connected` : void 0,
|
|
333
|
+
error: errorMsg,
|
|
334
|
+
children: isComplete && accounts.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2.5", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col divide-y divide-border/30", children: accounts.map((account, i) => /* @__PURE__ */ jsxs(
|
|
335
|
+
"div",
|
|
336
|
+
{
|
|
337
|
+
className: "flex items-center justify-between gap-2 py-1.5 first:pt-0 last:pb-0",
|
|
338
|
+
children: [
|
|
339
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-[12px] text-foreground", children: account.address || account.name || "Unknown account" }),
|
|
340
|
+
/* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
341
|
+
account.isDefault && /* @__PURE__ */ jsx("span", { className: "rounded-full bg-emerald-50 px-1.5 py-px text-[9px] font-semibold uppercase tracking-wide text-emerald-700", children: "Default" }),
|
|
342
|
+
account.provider && /* @__PURE__ */ jsx("span", { className: "rounded-md bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground", children: account.provider })
|
|
343
|
+
] })
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
i
|
|
347
|
+
)) }) })
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
const EmailAccountsToolUI = memo(
|
|
352
|
+
EmailAccountsToolUIImpl
|
|
353
|
+
);
|
|
354
|
+
EmailAccountsToolUI.displayName = "EmailAccountsToolUI";
|
|
355
|
+
function extractAssetId(result) {
|
|
356
|
+
const data = normalizeResult(result);
|
|
357
|
+
if (!data) return null;
|
|
358
|
+
const id = data.asset_id ?? data.assetId ?? data.id;
|
|
359
|
+
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
function resetAssetAutoOpen() {
|
|
363
|
+
useAssetPanelStore.getState().resetAutoOpen();
|
|
364
|
+
}
|
|
365
|
+
function getStringField(source, keys) {
|
|
366
|
+
if (!source) return null;
|
|
367
|
+
for (const key of keys) {
|
|
368
|
+
const value = source[key];
|
|
369
|
+
if (typeof value === "string" && value.trim()) {
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
function getNumberField(source, keys) {
|
|
376
|
+
if (!source) return null;
|
|
377
|
+
for (const key of keys) {
|
|
378
|
+
const value = source[key];
|
|
379
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
380
|
+
return value;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
function asRecord(value) {
|
|
386
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
return value;
|
|
390
|
+
}
|
|
391
|
+
function asString(value) {
|
|
392
|
+
return typeof value === "string" ? value : void 0;
|
|
393
|
+
}
|
|
394
|
+
const PRESENTATION_CODE_SLIDE_NUMBER_KEYS = [
|
|
395
|
+
"slideNumber",
|
|
396
|
+
"slide_number",
|
|
397
|
+
"targetSlideNumber",
|
|
398
|
+
"target_slide_number",
|
|
399
|
+
"targetSlide",
|
|
400
|
+
"target_slide"
|
|
401
|
+
];
|
|
402
|
+
const PRESENTATION_CODE_SLIDE_INDEX_KEYS = [
|
|
403
|
+
"slideIndex",
|
|
404
|
+
"slide_index",
|
|
405
|
+
"targetSlideIndex",
|
|
406
|
+
"target_slide_index"
|
|
407
|
+
];
|
|
408
|
+
function getStudioAssetId({
|
|
409
|
+
args,
|
|
410
|
+
result
|
|
411
|
+
}) {
|
|
412
|
+
const id = getStringField(result, ["asset_id", "assetId", "id"]) ?? getStringField(args, ["asset_id", "assetId", "id"]);
|
|
413
|
+
return (id == null ? void 0 : id.startsWith("asset_")) ? id : null;
|
|
414
|
+
}
|
|
415
|
+
function getPresentationCodeDeckId(code) {
|
|
416
|
+
const match = code.match(/\bdeck_id\s*=\s*["']([^"']+)["']/);
|
|
417
|
+
const deckId = match == null ? void 0 : match[1];
|
|
418
|
+
return (deckId == null ? void 0 : deckId.startsWith("asset_")) ? deckId : null;
|
|
419
|
+
}
|
|
420
|
+
function getPresentationCodeSlideNumberFromFields(source) {
|
|
421
|
+
const explicit = getNumberField(source, PRESENTATION_CODE_SLIDE_NUMBER_KEYS);
|
|
422
|
+
if (explicit != null && Number.isInteger(explicit) && explicit >= 1) {
|
|
423
|
+
return explicit;
|
|
424
|
+
}
|
|
425
|
+
const zeroBasedIndex = getNumberField(source, PRESENTATION_CODE_SLIDE_INDEX_KEYS);
|
|
426
|
+
if (zeroBasedIndex != null && Number.isInteger(zeroBasedIndex) && zeroBasedIndex >= 0) {
|
|
427
|
+
return zeroBasedIndex + 1;
|
|
428
|
+
}
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
function getPresentationCodeSlideNumberFromText(text) {
|
|
432
|
+
const match = text == null ? void 0 : text.match(/\bslide\s*(?:#|number\s*)?(\d+)\b/i);
|
|
433
|
+
if (!match) {
|
|
434
|
+
return void 0;
|
|
435
|
+
}
|
|
436
|
+
const slideNumber = Number.parseInt(match[1] ?? "", 10);
|
|
437
|
+
return Number.isInteger(slideNumber) && slideNumber >= 1 ? slideNumber : void 0;
|
|
438
|
+
}
|
|
439
|
+
function getPresentationCodeSlideNumber({
|
|
440
|
+
args,
|
|
441
|
+
result
|
|
442
|
+
}) {
|
|
443
|
+
return getPresentationCodeSlideNumberFromFields(args) ?? getPresentationCodeSlideNumberFromFields(result) ?? getPresentationCodeSlideNumberFromText(
|
|
444
|
+
getStringField(args, ["summary", "title", "description"])
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
function getAddSlideNumber(args) {
|
|
448
|
+
const index = getNumberField(args, ["index"]);
|
|
449
|
+
return index != null && Number.isInteger(index) && index >= 0 ? index + 1 : void 0;
|
|
450
|
+
}
|
|
451
|
+
function CreateAssetToolUIImpl({
|
|
452
|
+
icon: Icon,
|
|
453
|
+
assetType,
|
|
454
|
+
runningLabel,
|
|
455
|
+
doneLabel,
|
|
456
|
+
toolName,
|
|
457
|
+
args,
|
|
458
|
+
result,
|
|
459
|
+
status
|
|
460
|
+
}) {
|
|
461
|
+
const typedArgs = args;
|
|
462
|
+
const name = (typedArgs == null ? void 0 : typedArgs.name) ?? (typedArgs == null ? void 0 : typedArgs.title) ?? (typedArgs == null ? void 0 : typedArgs.document_name) ?? (typedArgs == null ? void 0 : typedArgs.sheet_name) ?? "";
|
|
463
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
464
|
+
const createdName = (data == null ? void 0 : data.name) ?? (data == null ? void 0 : data.title) ?? (data == null ? void 0 : data.asset_name);
|
|
465
|
+
const assetId = extractAssetId(result);
|
|
466
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
467
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
468
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
469
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
470
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
471
|
+
const handleOpen = () => {
|
|
472
|
+
if (assetId) {
|
|
473
|
+
openAsset(assetId, {
|
|
474
|
+
name: createdName || name || void 0,
|
|
475
|
+
type: assetType
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
return /* @__PURE__ */ jsx(
|
|
480
|
+
ToolCard,
|
|
481
|
+
{
|
|
482
|
+
icon: Icon,
|
|
483
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
484
|
+
title: isRunning ? runningLabel : doneLabel,
|
|
485
|
+
subtitle: createdName || name || void 0,
|
|
486
|
+
toolName,
|
|
487
|
+
args: typedArgs,
|
|
488
|
+
result,
|
|
489
|
+
error: errorMsg,
|
|
490
|
+
children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2.5", children: /* @__PURE__ */ jsxs(
|
|
491
|
+
"button",
|
|
492
|
+
{
|
|
493
|
+
type: "button",
|
|
494
|
+
onClick: handleOpen,
|
|
495
|
+
className: "group flex w-full items-center gap-3 rounded-lg border border-border/60 bg-muted/20 px-3 py-2.5 text-left transition-colors hover:border-border hover:bg-muted/40",
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ jsx(
|
|
498
|
+
"div",
|
|
499
|
+
{
|
|
500
|
+
className: cn(
|
|
501
|
+
"flex size-10 shrink-0 items-center justify-center rounded-lg",
|
|
502
|
+
ASSET_TILE_STYLE[assetType] ?? ASSET_TILE_STYLE.unknown
|
|
503
|
+
),
|
|
504
|
+
children: /* @__PURE__ */ jsx(Icon, { className: "size-5" })
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
508
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-[13px] font-medium text-foreground", children: createdName || name || "Untitled" }),
|
|
509
|
+
/* @__PURE__ */ jsxs("div", { className: "text-[11px] text-muted-foreground", children: [
|
|
510
|
+
ASSET_TILE_LABEL[assetType] ?? "Asset",
|
|
511
|
+
" · Click to open"
|
|
512
|
+
] })
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" })
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
) })
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
const ASSET_TILE_STYLE = {
|
|
522
|
+
document: "bg-blue-500/10 text-blue-600",
|
|
523
|
+
spreadsheet: "bg-emerald-500/10 text-emerald-600",
|
|
524
|
+
presentation: "bg-orange-500/10 text-orange-600",
|
|
525
|
+
notebook: "bg-violet-500/10 text-violet-600",
|
|
526
|
+
unknown: "bg-muted text-muted-foreground"
|
|
527
|
+
};
|
|
528
|
+
const ASSET_TILE_LABEL = {
|
|
529
|
+
document: "Document",
|
|
530
|
+
spreadsheet: "Spreadsheet",
|
|
531
|
+
presentation: "Presentation",
|
|
532
|
+
notebook: "Notebook",
|
|
533
|
+
unknown: "Asset"
|
|
534
|
+
};
|
|
535
|
+
const CreateDocumentToolUIImpl = (props) => /* @__PURE__ */ jsx(
|
|
536
|
+
CreateAssetToolUIImpl,
|
|
537
|
+
{
|
|
538
|
+
icon: FilePlusIcon,
|
|
539
|
+
assetType: "document",
|
|
540
|
+
runningLabel: "Creating document...",
|
|
541
|
+
doneLabel: "Created document",
|
|
542
|
+
...props
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
const CreateDocumentToolUI = memo(
|
|
546
|
+
CreateDocumentToolUIImpl
|
|
547
|
+
);
|
|
548
|
+
CreateDocumentToolUI.displayName = "CreateDocumentToolUI";
|
|
549
|
+
const CreateSheetToolUIImpl = (props) => /* @__PURE__ */ jsx(
|
|
550
|
+
CreateAssetToolUIImpl,
|
|
551
|
+
{
|
|
552
|
+
icon: BarChart3Icon,
|
|
553
|
+
assetType: "spreadsheet",
|
|
554
|
+
runningLabel: "Creating spreadsheet...",
|
|
555
|
+
doneLabel: "Created spreadsheet",
|
|
556
|
+
...props
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
const CreateSheetToolUI = memo(
|
|
560
|
+
CreateSheetToolUIImpl
|
|
561
|
+
);
|
|
562
|
+
CreateSheetToolUI.displayName = "CreateSheetToolUI";
|
|
563
|
+
const CreatePresentationToolUIImpl = (props) => /* @__PURE__ */ jsx(
|
|
564
|
+
CreateAssetToolUIImpl,
|
|
565
|
+
{
|
|
566
|
+
icon: PresentationIcon,
|
|
567
|
+
assetType: "presentation",
|
|
568
|
+
runningLabel: "Creating presentation...",
|
|
569
|
+
doneLabel: "Created presentation",
|
|
570
|
+
...props
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
const CreatePresentationToolUI = memo(
|
|
574
|
+
CreatePresentationToolUIImpl
|
|
575
|
+
);
|
|
576
|
+
CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
|
|
577
|
+
function openStudioAsset({
|
|
578
|
+
assetId,
|
|
579
|
+
assetType,
|
|
580
|
+
slideNumber,
|
|
581
|
+
preserveExistingSlide
|
|
582
|
+
}) {
|
|
583
|
+
const store = useAssetPanelStore.getState();
|
|
584
|
+
const existing = store.tabs.find((tab) => tab.id === assetId);
|
|
585
|
+
const shouldKeepCurrentSlide = preserveExistingSlide && existing;
|
|
586
|
+
store.openAsset(assetId, {
|
|
587
|
+
type: assetType,
|
|
588
|
+
...!shouldKeepCurrentSlide && slideNumber !== void 0 ? { slideNumber } : {}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
function StudioPtcToolUI({
|
|
592
|
+
config,
|
|
593
|
+
toolName,
|
|
594
|
+
args,
|
|
595
|
+
result,
|
|
596
|
+
status
|
|
597
|
+
}) {
|
|
598
|
+
var _a, _b;
|
|
599
|
+
const typedArgs = args;
|
|
600
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
601
|
+
const slideNumber = (_a = config.getSlideNumber) == null ? void 0 : _a.call(config, typedArgs);
|
|
602
|
+
const assetId = getStudioAssetId({ args: typedArgs, result: data });
|
|
603
|
+
const subtitle = (_b = config.getSubtitle) == null ? void 0 : _b.call(config, typedArgs, data, slideNumber);
|
|
604
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
605
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
606
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
607
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? String(status.error ?? status.reason ?? "Tool failed") : null;
|
|
608
|
+
const handleOpen = useCallback(() => {
|
|
609
|
+
if (!assetId) return;
|
|
610
|
+
if (toolName === "AddSlide") {
|
|
611
|
+
logDebugPayload("[Athena SDK AddSlide] manual open", {
|
|
612
|
+
args: typedArgs,
|
|
613
|
+
parsedResult: data,
|
|
614
|
+
rawResult: result,
|
|
615
|
+
assetId,
|
|
616
|
+
slideNumber
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
openStudioAsset({
|
|
620
|
+
assetId,
|
|
621
|
+
assetType: config.assetType,
|
|
622
|
+
slideNumber,
|
|
623
|
+
preserveExistingSlide: config.preserveExistingSlide
|
|
624
|
+
});
|
|
625
|
+
}, [
|
|
626
|
+
assetId,
|
|
627
|
+
config.assetType,
|
|
628
|
+
config.preserveExistingSlide,
|
|
629
|
+
data,
|
|
630
|
+
result,
|
|
631
|
+
slideNumber,
|
|
632
|
+
toolName,
|
|
633
|
+
typedArgs
|
|
634
|
+
]);
|
|
635
|
+
useEffect(() => {
|
|
636
|
+
if (toolName !== "AddSlide") {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
logDebugPayload("[Athena SDK AddSlide] tool state", {
|
|
640
|
+
args: typedArgs,
|
|
641
|
+
parsedResult: data,
|
|
642
|
+
rawResult: result,
|
|
643
|
+
status,
|
|
644
|
+
assetId,
|
|
645
|
+
slideNumber,
|
|
646
|
+
isComplete,
|
|
647
|
+
isCancelled
|
|
648
|
+
});
|
|
649
|
+
}, [
|
|
650
|
+
assetId,
|
|
651
|
+
data,
|
|
652
|
+
isCancelled,
|
|
653
|
+
isComplete,
|
|
654
|
+
result,
|
|
655
|
+
slideNumber,
|
|
656
|
+
status,
|
|
657
|
+
toolName,
|
|
658
|
+
typedArgs
|
|
659
|
+
]);
|
|
660
|
+
return /* @__PURE__ */ jsx(
|
|
661
|
+
ToolCard,
|
|
662
|
+
{
|
|
663
|
+
icon: config.icon,
|
|
664
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
665
|
+
title: isRunning ? config.runningLabel(typedArgs) : config.doneLabel(typedArgs, slideNumber),
|
|
666
|
+
subtitle,
|
|
667
|
+
badge: config.badge,
|
|
668
|
+
toolName,
|
|
669
|
+
args: typedArgs,
|
|
670
|
+
result,
|
|
671
|
+
error: errorMsg,
|
|
672
|
+
children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
673
|
+
"button",
|
|
674
|
+
{
|
|
675
|
+
type: "button",
|
|
676
|
+
onClick: handleOpen,
|
|
677
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
680
|
+
config.openLabel(slideNumber)
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
) })
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
function createStudioPtcToolUI(displayName, config) {
|
|
688
|
+
const Component = (props) => /* @__PURE__ */ jsx(StudioPtcToolUI, { config, ...props });
|
|
689
|
+
const Memoized = memo(Component);
|
|
690
|
+
Memoized.displayName = displayName;
|
|
691
|
+
return Memoized;
|
|
692
|
+
}
|
|
693
|
+
const getNameSubtitle = (args, result) => getStringField(result, ["title", "name", "asset_name"]) ?? getStringField(args, ["title", "name"]) ?? void 0;
|
|
694
|
+
const getParagraphSubtitle = (args) => {
|
|
695
|
+
const text = getStringField(args, ["text"]);
|
|
696
|
+
return text ? truncate(text, 80) : void 0;
|
|
697
|
+
};
|
|
698
|
+
const getSlideSubtitle = (args, _result, slideNumber) => {
|
|
699
|
+
const layout = getStringField(args, ["layoutName", "layout_name"]) ?? getStringField(args, ["layoutPath", "layout_path"]);
|
|
700
|
+
const slideLabel = slideNumber ? `Slide ${slideNumber}` : null;
|
|
701
|
+
if (slideLabel && layout) return `${slideLabel} - ${truncate(layout, 48)}`;
|
|
702
|
+
return slideLabel ?? (layout ? truncate(layout, 64) : void 0);
|
|
703
|
+
};
|
|
704
|
+
const StudioCreateWorkbookToolUI = createStudioPtcToolUI(
|
|
705
|
+
"StudioCreateWorkbookToolUI",
|
|
706
|
+
{
|
|
707
|
+
icon: BarChart3Icon,
|
|
708
|
+
assetType: "spreadsheet",
|
|
709
|
+
badge: "Sheet",
|
|
710
|
+
runningLabel: (args) => {
|
|
711
|
+
const title = getStringField(args, ["title", "name"]);
|
|
712
|
+
return title ? `Creating workbook "${title}"...` : "Creating workbook...";
|
|
713
|
+
},
|
|
714
|
+
doneLabel: () => "Workbook created",
|
|
715
|
+
getSubtitle: getNameSubtitle,
|
|
716
|
+
openLabel: () => "Open workbook"
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
const StudioAddSheetToolUI = createStudioPtcToolUI(
|
|
720
|
+
"StudioAddSheetToolUI",
|
|
721
|
+
{
|
|
722
|
+
icon: BarChart3Icon,
|
|
723
|
+
assetType: "spreadsheet",
|
|
724
|
+
badge: "Sheet",
|
|
725
|
+
runningLabel: (args) => {
|
|
726
|
+
const name = getStringField(args, ["name", "sheetName", "sheet_name"]);
|
|
727
|
+
return name ? `Adding sheet "${name}"...` : "Adding sheet...";
|
|
728
|
+
},
|
|
729
|
+
doneLabel: (args) => {
|
|
730
|
+
const name = getStringField(args, ["name", "sheetName", "sheet_name"]);
|
|
731
|
+
return name ? `Sheet added: ${name}` : "Sheet added";
|
|
732
|
+
},
|
|
733
|
+
getSubtitle: (args) => getStringField(args, ["name", "sheetName", "sheet_name"]) ?? void 0,
|
|
734
|
+
openLabel: () => "Open workbook"
|
|
735
|
+
}
|
|
736
|
+
);
|
|
737
|
+
const StudioOpenWorkbookToolUI = createStudioPtcToolUI(
|
|
738
|
+
"StudioOpenWorkbookToolUI",
|
|
739
|
+
{
|
|
740
|
+
icon: BarChart3Icon,
|
|
741
|
+
assetType: "spreadsheet",
|
|
742
|
+
badge: "Sheet",
|
|
743
|
+
runningLabel: () => "Opening workbook...",
|
|
744
|
+
doneLabel: () => "Workbook opened",
|
|
745
|
+
openLabel: () => "Open workbook"
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
const StudioCreatePresentationToolUI = createStudioPtcToolUI(
|
|
749
|
+
"StudioCreatePresentationToolUI",
|
|
750
|
+
{
|
|
751
|
+
icon: PresentationIcon,
|
|
752
|
+
assetType: "presentation",
|
|
753
|
+
badge: "Deck",
|
|
754
|
+
runningLabel: (args) => {
|
|
755
|
+
const title = getStringField(args, ["title", "name"]);
|
|
756
|
+
return title ? `Creating presentation "${title}"...` : "Creating presentation...";
|
|
757
|
+
},
|
|
758
|
+
doneLabel: () => "Presentation created",
|
|
759
|
+
getSubtitle: getNameSubtitle,
|
|
760
|
+
getSlideNumber: () => 1,
|
|
761
|
+
openLabel: () => "Open presentation"
|
|
762
|
+
}
|
|
763
|
+
);
|
|
764
|
+
const StudioOpenPresentationToolUI = createStudioPtcToolUI(
|
|
765
|
+
"StudioOpenPresentationToolUI",
|
|
766
|
+
{
|
|
767
|
+
icon: PresentationIcon,
|
|
768
|
+
assetType: "presentation",
|
|
769
|
+
badge: "Deck",
|
|
770
|
+
runningLabel: () => "Opening presentation...",
|
|
771
|
+
doneLabel: () => "Presentation opened",
|
|
772
|
+
getSlideNumber: () => 1,
|
|
773
|
+
getSubtitle: (_args, _result, slideNumber) => slideNumber ? `Slide ${slideNumber}` : void 0,
|
|
774
|
+
openLabel: () => "Open presentation",
|
|
775
|
+
preserveExistingSlide: true
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
const StudioAddSlideToolUI = createStudioPtcToolUI(
|
|
779
|
+
"StudioAddSlideToolUI",
|
|
780
|
+
{
|
|
781
|
+
icon: PresentationIcon,
|
|
782
|
+
assetType: "presentation",
|
|
783
|
+
badge: "Deck",
|
|
784
|
+
runningLabel: () => "Adding slide...",
|
|
785
|
+
doneLabel: (_args, slideNumber) => slideNumber ? `Slide ${slideNumber} added` : "Slide added",
|
|
786
|
+
getSubtitle: getSlideSubtitle,
|
|
787
|
+
getSlideNumber: (args) => getAddSlideNumber(args) ?? 1,
|
|
788
|
+
openLabel: (slideNumber) => slideNumber ? `Open slide ${slideNumber}` : "Open presentation"
|
|
789
|
+
}
|
|
790
|
+
);
|
|
791
|
+
const StudioCreateDocumentToolUI = createStudioPtcToolUI(
|
|
792
|
+
"StudioCreateDocumentToolUI",
|
|
793
|
+
{
|
|
794
|
+
icon: FileTextIcon,
|
|
795
|
+
assetType: "document",
|
|
796
|
+
badge: "Doc",
|
|
797
|
+
runningLabel: (args) => {
|
|
798
|
+
const title = getStringField(args, ["title", "name"]);
|
|
799
|
+
return title ? `Creating document "${title}"...` : "Creating document...";
|
|
800
|
+
},
|
|
801
|
+
doneLabel: () => "Document created",
|
|
802
|
+
getSubtitle: getNameSubtitle,
|
|
803
|
+
openLabel: () => "Open document"
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
const StudioCreateParagraphToolUI = createStudioPtcToolUI(
|
|
807
|
+
"StudioCreateParagraphToolUI",
|
|
808
|
+
{
|
|
809
|
+
icon: FileTextIcon,
|
|
810
|
+
assetType: "document",
|
|
811
|
+
badge: "Doc",
|
|
812
|
+
runningLabel: () => "Adding paragraph...",
|
|
813
|
+
doneLabel: () => "Paragraph added",
|
|
814
|
+
getSubtitle: getParagraphSubtitle,
|
|
815
|
+
openLabel: () => "Open document"
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
const StudioOpenDocumentToolUI = createStudioPtcToolUI(
|
|
819
|
+
"StudioOpenDocumentToolUI",
|
|
820
|
+
{
|
|
821
|
+
icon: FileTextIcon,
|
|
822
|
+
assetType: "document",
|
|
823
|
+
badge: "Doc",
|
|
824
|
+
runningLabel: () => "Opening document...",
|
|
825
|
+
doneLabel: () => "Document opened",
|
|
826
|
+
openLabel: () => "Open document"
|
|
827
|
+
}
|
|
828
|
+
);
|
|
829
|
+
const CreateEmailDraftToolUIImpl = ({
|
|
830
|
+
toolName,
|
|
831
|
+
args,
|
|
832
|
+
result,
|
|
833
|
+
status
|
|
834
|
+
}) => {
|
|
835
|
+
const typedArgs = args;
|
|
836
|
+
const to = (typedArgs == null ? void 0 : typedArgs.to) ?? (typedArgs == null ? void 0 : typedArgs.recipient) ?? "";
|
|
837
|
+
const subject = (typedArgs == null ? void 0 : typedArgs.subject) ?? "";
|
|
838
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
839
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
840
|
+
return /* @__PURE__ */ jsx(
|
|
841
|
+
ToolCard,
|
|
842
|
+
{
|
|
843
|
+
icon: MailIcon,
|
|
844
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
845
|
+
title: isRunning ? "Creating email draft..." : "Email draft created",
|
|
846
|
+
toolName,
|
|
847
|
+
args: typedArgs,
|
|
848
|
+
result,
|
|
849
|
+
subtitle: subject ? truncate(subject, 60) : to ? `To: ${truncate(to, 40)}` : void 0,
|
|
850
|
+
error: errorMsg
|
|
851
|
+
}
|
|
852
|
+
);
|
|
853
|
+
};
|
|
854
|
+
const CreateEmailDraftToolUI = memo(
|
|
855
|
+
CreateEmailDraftToolUIImpl
|
|
856
|
+
);
|
|
857
|
+
CreateEmailDraftToolUI.displayName = "CreateEmailDraftToolUI";
|
|
858
|
+
const CreateNotebookToolUIImpl = (props) => /* @__PURE__ */ jsx(
|
|
859
|
+
CreateAssetToolUIImpl,
|
|
860
|
+
{
|
|
861
|
+
icon: BookOpenIcon,
|
|
862
|
+
assetType: "notebook",
|
|
863
|
+
runningLabel: "Creating notebook...",
|
|
864
|
+
doneLabel: "Created notebook",
|
|
865
|
+
...props
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
const CreateNotebookToolUI = memo(
|
|
869
|
+
CreateNotebookToolUIImpl
|
|
870
|
+
);
|
|
871
|
+
CreateNotebookToolUI.displayName = "CreateNotebookToolUI";
|
|
872
|
+
function parsePythonResult(result) {
|
|
873
|
+
const data = normalizeResult(result);
|
|
874
|
+
if (!data)
|
|
875
|
+
return {
|
|
876
|
+
outputs: [],
|
|
877
|
+
stdout: null,
|
|
878
|
+
stderr: null,
|
|
879
|
+
value: null,
|
|
880
|
+
error: null,
|
|
881
|
+
exception: null,
|
|
882
|
+
imagePng: null,
|
|
883
|
+
plotlyJson: null,
|
|
884
|
+
createdAssets: [],
|
|
885
|
+
assetId: null,
|
|
886
|
+
deckId: null
|
|
887
|
+
};
|
|
888
|
+
const inner = typeof data.result === "object" && data.result !== null ? data.result : data;
|
|
889
|
+
const stdout = inner.stdout ?? null;
|
|
890
|
+
const stderr = inner.stderr ?? null;
|
|
891
|
+
const value = inner.value ?? null;
|
|
892
|
+
const error = inner.error ?? null;
|
|
893
|
+
let exception = null;
|
|
894
|
+
if (inner.exception && typeof inner.exception === "object") {
|
|
895
|
+
const exc = inner.exception;
|
|
896
|
+
exception = {
|
|
897
|
+
name: exc.name ?? "Error",
|
|
898
|
+
value: exc.value ?? "",
|
|
899
|
+
traceback: exc.traceback ?? ""
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
let imagePng = null;
|
|
903
|
+
let plotlyJson = null;
|
|
904
|
+
const outputs = [];
|
|
905
|
+
if (inner.data && typeof inner.data === "object") {
|
|
906
|
+
imagePng = inner.data.png ?? null;
|
|
907
|
+
}
|
|
908
|
+
if (Array.isArray(data.outputs)) {
|
|
909
|
+
for (const output of data.outputs) {
|
|
910
|
+
if (output && typeof output === "object") {
|
|
911
|
+
const outputRecord = output;
|
|
912
|
+
const mimeBundle = output.mime_bundle;
|
|
913
|
+
let outputImagePng = null;
|
|
914
|
+
let outputPlotlyJson = null;
|
|
915
|
+
let outputTextPlain = null;
|
|
916
|
+
if (mimeBundle && typeof mimeBundle === "object") {
|
|
917
|
+
const mb = mimeBundle;
|
|
918
|
+
if (!plotlyJson && typeof mb["plotly+json"] === "string") {
|
|
919
|
+
plotlyJson = mb["plotly+json"];
|
|
920
|
+
}
|
|
921
|
+
if (!imagePng && typeof mb["image/png"] === "string") {
|
|
922
|
+
imagePng = mb["image/png"];
|
|
923
|
+
}
|
|
924
|
+
outputPlotlyJson = typeof mb["plotly+json"] === "string" ? mb["plotly+json"] : null;
|
|
925
|
+
outputImagePng = typeof mb["image/png"] === "string" ? mb["image/png"] : null;
|
|
926
|
+
outputTextPlain = typeof mb["text/plain"] === "string" ? mb["text/plain"] : null;
|
|
927
|
+
}
|
|
928
|
+
outputs.push({
|
|
929
|
+
objectId: typeof outputRecord.object_id === "string" ? outputRecord.object_id : null,
|
|
930
|
+
title: typeof outputRecord.title === "string" ? outputRecord.title : null,
|
|
931
|
+
textPlain: outputTextPlain,
|
|
932
|
+
imagePng: outputImagePng,
|
|
933
|
+
plotlyJson: outputPlotlyJson,
|
|
934
|
+
assetId: typeof outputRecord.asset_id === "string" ? outputRecord.asset_id : null
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const createdAssets = Array.isArray(data.created_assets) ? data.created_assets : [];
|
|
940
|
+
const assetId = typeof data.asset_id === "string" ? data.asset_id : null;
|
|
941
|
+
const deckId = typeof data.deck_id === "string" ? data.deck_id : null;
|
|
942
|
+
return {
|
|
943
|
+
outputs,
|
|
944
|
+
stdout,
|
|
945
|
+
stderr,
|
|
946
|
+
value,
|
|
947
|
+
error,
|
|
948
|
+
exception,
|
|
949
|
+
imagePng,
|
|
950
|
+
plotlyJson,
|
|
951
|
+
createdAssets,
|
|
952
|
+
assetId,
|
|
953
|
+
deckId
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function getExecutionTextOutput(parsed) {
|
|
957
|
+
const output = [
|
|
958
|
+
parsed.value,
|
|
959
|
+
parsed.stdout,
|
|
960
|
+
parsed.stderr,
|
|
961
|
+
...parsed.outputs.map((entry) => {
|
|
962
|
+
if (!entry.textPlain) {
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
return entry.title ? `${entry.title}
|
|
966
|
+
${entry.textPlain}` : entry.textPlain;
|
|
967
|
+
})
|
|
968
|
+
].filter((chunk) => Boolean(chunk && chunk.trim())).join("\n\n");
|
|
969
|
+
return output || null;
|
|
970
|
+
}
|
|
971
|
+
function getPlotly() {
|
|
972
|
+
return window.Plotly;
|
|
973
|
+
}
|
|
974
|
+
let plotlyLoadPromise = null;
|
|
975
|
+
function ensurePlotlyLoaded() {
|
|
976
|
+
if (getPlotly()) return Promise.resolve();
|
|
977
|
+
if (plotlyLoadPromise) return plotlyLoadPromise;
|
|
978
|
+
plotlyLoadPromise = new Promise((resolve, reject) => {
|
|
979
|
+
const script = document.createElement("script");
|
|
980
|
+
script.src = "https://cdn.plot.ly/plotly-2.35.2.min.js";
|
|
981
|
+
script.crossOrigin = "anonymous";
|
|
982
|
+
script.onload = () => resolve();
|
|
983
|
+
script.onerror = () => {
|
|
984
|
+
plotlyLoadPromise = null;
|
|
985
|
+
document.head.removeChild(script);
|
|
986
|
+
reject(new Error("Failed to load Plotly"));
|
|
987
|
+
};
|
|
988
|
+
document.head.appendChild(script);
|
|
989
|
+
});
|
|
990
|
+
return plotlyLoadPromise;
|
|
991
|
+
}
|
|
992
|
+
const PlotlyChart = ({ json, height = 500 }) => {
|
|
993
|
+
const chartRef = useRef(null);
|
|
994
|
+
const [error, setError] = useState(null);
|
|
995
|
+
useEffect(() => {
|
|
996
|
+
let cancelled = false;
|
|
997
|
+
ensurePlotlyLoaded().then(() => {
|
|
998
|
+
if (cancelled || !chartRef.current) return;
|
|
999
|
+
const parsed = JSON.parse(json);
|
|
1000
|
+
const Plotly = getPlotly();
|
|
1001
|
+
if (!Plotly) return;
|
|
1002
|
+
Plotly.newPlot(
|
|
1003
|
+
chartRef.current,
|
|
1004
|
+
parsed.data || [],
|
|
1005
|
+
{ ...parsed.layout || {}, autosize: true, width: void 0, height: void 0 },
|
|
1006
|
+
{ responsive: true, displayModeBar: true, displaylogo: false, showLink: false }
|
|
1007
|
+
);
|
|
1008
|
+
}).catch((err) => {
|
|
1009
|
+
if (!cancelled) setError(err.message);
|
|
1010
|
+
});
|
|
1011
|
+
return () => {
|
|
1012
|
+
cancelled = true;
|
|
1013
|
+
if (chartRef.current) {
|
|
1014
|
+
const Plotly = getPlotly();
|
|
1015
|
+
if (Plotly) Plotly.purge(chartRef.current);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
}, [json]);
|
|
1019
|
+
if (error) {
|
|
1020
|
+
return /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: error });
|
|
1021
|
+
}
|
|
1022
|
+
return /* @__PURE__ */ jsx("div", { ref: chartRef, className: "w-full overflow-hidden", style: { height } });
|
|
1023
|
+
};
|
|
1024
|
+
const PlotlyChartSection = ({ json }) => {
|
|
1025
|
+
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
1026
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1027
|
+
/* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
1028
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-1.5", children: [
|
|
1029
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1030
|
+
/* @__PURE__ */ jsx(BarChart3Icon, { className: "size-3 text-muted-foreground" }),
|
|
1031
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Interactive chart" })
|
|
1032
|
+
] }),
|
|
1033
|
+
/* @__PURE__ */ jsx(
|
|
1034
|
+
"button",
|
|
1035
|
+
{
|
|
1036
|
+
type: "button",
|
|
1037
|
+
onClick: () => setIsFullscreen(true),
|
|
1038
|
+
className: "flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1039
|
+
title: "View full screen",
|
|
1040
|
+
children: /* @__PURE__ */ jsx(Maximize2Icon, { className: "size-3.5" })
|
|
1041
|
+
}
|
|
1042
|
+
)
|
|
1043
|
+
] }),
|
|
1044
|
+
/* @__PURE__ */ jsx(PlotlyChart, { json })
|
|
1045
|
+
] }),
|
|
1046
|
+
isFullscreen && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-[9999] flex flex-col bg-background", children: [
|
|
1047
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-3 border-b border-border", children: [
|
|
1048
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1049
|
+
/* @__PURE__ */ jsx(BarChart3Icon, { className: "size-4 text-muted-foreground" }),
|
|
1050
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Interactive chart" })
|
|
1051
|
+
] }),
|
|
1052
|
+
/* @__PURE__ */ jsx(
|
|
1053
|
+
"button",
|
|
1054
|
+
{
|
|
1055
|
+
type: "button",
|
|
1056
|
+
onClick: () => setIsFullscreen(false),
|
|
1057
|
+
className: "flex items-center justify-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1058
|
+
title: "Close full screen",
|
|
1059
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-5" })
|
|
1060
|
+
}
|
|
1061
|
+
)
|
|
1062
|
+
] }),
|
|
1063
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 p-4", children: /* @__PURE__ */ jsx(PlotlyChart, { json, height: "100%" }) })
|
|
1064
|
+
] })
|
|
1065
|
+
] });
|
|
1066
|
+
};
|
|
1067
|
+
const SyntaxHighlightedCode = memo(({ code }) => {
|
|
1068
|
+
const highlighted = useMemo(() => highlightPython(code), [code]);
|
|
1069
|
+
return /* @__PURE__ */ jsx(
|
|
1070
|
+
"pre",
|
|
1071
|
+
{
|
|
1072
|
+
className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed font-mono",
|
|
1073
|
+
dangerouslySetInnerHTML: { __html: highlighted }
|
|
1074
|
+
}
|
|
1075
|
+
);
|
|
1076
|
+
});
|
|
1077
|
+
SyntaxHighlightedCode.displayName = "SyntaxHighlightedCode";
|
|
1078
|
+
const PY_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1079
|
+
"False",
|
|
1080
|
+
"None",
|
|
1081
|
+
"True",
|
|
1082
|
+
"and",
|
|
1083
|
+
"as",
|
|
1084
|
+
"assert",
|
|
1085
|
+
"async",
|
|
1086
|
+
"await",
|
|
1087
|
+
"break",
|
|
1088
|
+
"class",
|
|
1089
|
+
"continue",
|
|
1090
|
+
"def",
|
|
1091
|
+
"del",
|
|
1092
|
+
"elif",
|
|
1093
|
+
"else",
|
|
1094
|
+
"except",
|
|
1095
|
+
"finally",
|
|
1096
|
+
"for",
|
|
1097
|
+
"from",
|
|
1098
|
+
"global",
|
|
1099
|
+
"if",
|
|
1100
|
+
"import",
|
|
1101
|
+
"in",
|
|
1102
|
+
"is",
|
|
1103
|
+
"lambda",
|
|
1104
|
+
"nonlocal",
|
|
1105
|
+
"not",
|
|
1106
|
+
"or",
|
|
1107
|
+
"pass",
|
|
1108
|
+
"raise",
|
|
1109
|
+
"return",
|
|
1110
|
+
"try",
|
|
1111
|
+
"while",
|
|
1112
|
+
"with",
|
|
1113
|
+
"yield"
|
|
1114
|
+
]);
|
|
1115
|
+
const PY_BUILTINS = /* @__PURE__ */ new Set([
|
|
1116
|
+
"print",
|
|
1117
|
+
"len",
|
|
1118
|
+
"range",
|
|
1119
|
+
"int",
|
|
1120
|
+
"str",
|
|
1121
|
+
"float",
|
|
1122
|
+
"list",
|
|
1123
|
+
"dict",
|
|
1124
|
+
"set",
|
|
1125
|
+
"tuple",
|
|
1126
|
+
"bool",
|
|
1127
|
+
"type",
|
|
1128
|
+
"isinstance",
|
|
1129
|
+
"enumerate",
|
|
1130
|
+
"zip",
|
|
1131
|
+
"map",
|
|
1132
|
+
"filter",
|
|
1133
|
+
"sorted",
|
|
1134
|
+
"reversed",
|
|
1135
|
+
"sum",
|
|
1136
|
+
"min",
|
|
1137
|
+
"max",
|
|
1138
|
+
"abs",
|
|
1139
|
+
"round",
|
|
1140
|
+
"open",
|
|
1141
|
+
"super",
|
|
1142
|
+
"property",
|
|
1143
|
+
"staticmethod",
|
|
1144
|
+
"classmethod",
|
|
1145
|
+
"display",
|
|
1146
|
+
"input",
|
|
1147
|
+
"format",
|
|
1148
|
+
"getattr",
|
|
1149
|
+
"setattr",
|
|
1150
|
+
"hasattr",
|
|
1151
|
+
"vars",
|
|
1152
|
+
"dir"
|
|
1153
|
+
]);
|
|
1154
|
+
function escapeHtml(s) {
|
|
1155
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1156
|
+
}
|
|
1157
|
+
function highlightPython(code) {
|
|
1158
|
+
const lines = code.split("\n");
|
|
1159
|
+
return lines.map((line) => {
|
|
1160
|
+
const commentMatch = line.match(/^(\s*)(#.*)$/);
|
|
1161
|
+
if (commentMatch) {
|
|
1162
|
+
return `${escapeHtml(commentMatch[1])}<span style="color:var(--aui-syn-comment, #6a9955)">${escapeHtml(commentMatch[2])}</span>`;
|
|
1163
|
+
}
|
|
1164
|
+
let result = "";
|
|
1165
|
+
let i = 0;
|
|
1166
|
+
while (i < line.length) {
|
|
1167
|
+
if (line[i] === "#") {
|
|
1168
|
+
result += `<span style="color:var(--aui-syn-comment, #6a9955)">${escapeHtml(line.slice(i))}</span>`;
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
if (line.slice(i, i + 3) === '"""' || line.slice(i, i + 3) === "'''") {
|
|
1172
|
+
const quote = line.slice(i, i + 3);
|
|
1173
|
+
const end = line.indexOf(quote, i + 3);
|
|
1174
|
+
const str = end >= 0 ? line.slice(i, end + 3) : line.slice(i);
|
|
1175
|
+
result += `<span style="color:var(--aui-syn-string, #ce9178)">${escapeHtml(str)}</span>`;
|
|
1176
|
+
i += str.length;
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
if (line[i] === '"' || line[i] === "'") {
|
|
1180
|
+
const q = line[i];
|
|
1181
|
+
let j = i + 1;
|
|
1182
|
+
while (j < line.length && line[j] !== q) {
|
|
1183
|
+
if (line[j] === "\\") j++;
|
|
1184
|
+
j++;
|
|
1185
|
+
}
|
|
1186
|
+
const str = line.slice(i, j + 1);
|
|
1187
|
+
result += `<span style="color:var(--aui-syn-string, #ce9178)">${escapeHtml(str)}</span>`;
|
|
1188
|
+
i = j + 1;
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
if (/\d/.test(line[i]) && (i === 0 || /[\s(,=[\-+*/:!<>]/.test(line[i - 1]))) {
|
|
1192
|
+
const numMatch = line.slice(i).match(/^(\d+\.?\d*(?:[eE][+-]?\d+)?)/);
|
|
1193
|
+
if (numMatch) {
|
|
1194
|
+
result += `<span style="color:var(--aui-syn-number, #b5cea8)">${escapeHtml(numMatch[1])}</span>`;
|
|
1195
|
+
i += numMatch[1].length;
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
if (/[a-zA-Z_]/.test(line[i])) {
|
|
1200
|
+
const wordMatch = line.slice(i).match(/^[a-zA-Z_]\w*/);
|
|
1201
|
+
if (wordMatch) {
|
|
1202
|
+
const word = wordMatch[0];
|
|
1203
|
+
if (PY_KEYWORDS.has(word)) {
|
|
1204
|
+
result += `<span style="color:var(--aui-syn-keyword, #569cd6)">${escapeHtml(word)}</span>`;
|
|
1205
|
+
} else if (PY_BUILTINS.has(word)) {
|
|
1206
|
+
result += `<span style="color:var(--aui-syn-builtin, #dcdcaa)">${escapeHtml(word)}</span>`;
|
|
1207
|
+
} else if (line[i + word.length] === "(") {
|
|
1208
|
+
result += `<span style="color:var(--aui-syn-func, #dcdcaa)">${escapeHtml(word)}</span>`;
|
|
1209
|
+
} else {
|
|
1210
|
+
result += escapeHtml(word);
|
|
1211
|
+
}
|
|
1212
|
+
i += word.length;
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (line[i] === "@" && (i === 0 || /\s/.test(line[i - 1]))) {
|
|
1217
|
+
const decMatch = line.slice(i).match(/^@[\w.]+/);
|
|
1218
|
+
if (decMatch) {
|
|
1219
|
+
result += `<span style="color:var(--aui-syn-decorator, #569cd6)">${escapeHtml(decMatch[0])}</span>`;
|
|
1220
|
+
i += decMatch[0].length;
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
if (/[+\-*/%=<>!&|^~]/.test(line[i])) {
|
|
1225
|
+
result += `<span style="color:var(--aui-syn-op, #d4d4d4)">${escapeHtml(line[i])}</span>`;
|
|
1226
|
+
i++;
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
result += escapeHtml(line[i]);
|
|
1230
|
+
i++;
|
|
1231
|
+
}
|
|
1232
|
+
return result;
|
|
1233
|
+
}).join("\n");
|
|
1234
|
+
}
|
|
1235
|
+
const RunPythonCodeToolUIImpl = ({
|
|
1236
|
+
toolName,
|
|
1237
|
+
args,
|
|
1238
|
+
result,
|
|
1239
|
+
status
|
|
1240
|
+
}) => {
|
|
1241
|
+
var _a;
|
|
1242
|
+
const typedArgs = args;
|
|
1243
|
+
const code = (typedArgs == null ? void 0 : typedArgs.code) ?? "";
|
|
1244
|
+
const summary = (typedArgs == null ? void 0 : typedArgs.summary) ?? null;
|
|
1245
|
+
const lines = code ? code.split("\n").length : 0;
|
|
1246
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1247
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1248
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1249
|
+
const parsed = useMemo(
|
|
1250
|
+
() => isComplete ? parsePythonResult(result) : null,
|
|
1251
|
+
[result, isComplete]
|
|
1252
|
+
);
|
|
1253
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
1254
|
+
const outputText = parsed ? getExecutionTextOutput(parsed) : null;
|
|
1255
|
+
const hasOutput = Boolean(outputText);
|
|
1256
|
+
const hasError = parsed && (parsed.error || parsed.exception);
|
|
1257
|
+
const hasImage = parsed == null ? void 0 : parsed.imagePng;
|
|
1258
|
+
const hasPlotly = parsed == null ? void 0 : parsed.plotlyJson;
|
|
1259
|
+
return /* @__PURE__ */ jsxs(
|
|
1260
|
+
ToolCard,
|
|
1261
|
+
{
|
|
1262
|
+
icon: CodeIcon,
|
|
1263
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1264
|
+
title: isRunning ? "Running code..." : summary || `Executed ${lines} ${lines !== 1 ? "lines" : "line"}`,
|
|
1265
|
+
toolName,
|
|
1266
|
+
args: typedArgs,
|
|
1267
|
+
result,
|
|
1268
|
+
error: errorMsg,
|
|
1269
|
+
children: [
|
|
1270
|
+
code && /* @__PURE__ */ jsx(ExpandableSection, { label: "Show code", children: /* @__PURE__ */ jsx(SyntaxHighlightedCode, { code }) }),
|
|
1271
|
+
isComplete && hasOutput && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
1272
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
|
|
1273
|
+
/* @__PURE__ */ jsx(TerminalIcon, { className: "size-3 text-muted-foreground" }),
|
|
1274
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Output" })
|
|
1275
|
+
] }),
|
|
1276
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/30 p-2 text-[11px] leading-relaxed font-mono text-foreground/80", children: outputText })
|
|
1277
|
+
] }),
|
|
1278
|
+
isComplete && hasError && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: [
|
|
1279
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx(AlertTriangleIcon, { className: "size-3 text-destructive" }),
|
|
1281
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-destructive", children: parsed.exception ? `${parsed.exception.name}: ${parsed.exception.value}` : "Error" })
|
|
1282
|
+
] }),
|
|
1283
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-destructive/5 p-2 text-[11px] leading-relaxed font-mono text-destructive/80", children: ((_a = parsed.exception) == null ? void 0 : _a.traceback) ?? parsed.error })
|
|
1284
|
+
] }),
|
|
1285
|
+
isComplete && hasPlotly && /* @__PURE__ */ jsx(PlotlyChartSection, { json: parsed.plotlyJson }),
|
|
1286
|
+
isComplete && hasImage && !hasPlotly && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
1287
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1.5", children: [
|
|
1288
|
+
/* @__PURE__ */ jsx(ImageIcon, { className: "size-3 text-muted-foreground" }),
|
|
1289
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Generated image" })
|
|
1290
|
+
] }),
|
|
1291
|
+
/* @__PURE__ */ jsx(
|
|
1292
|
+
"img",
|
|
1293
|
+
{
|
|
1294
|
+
src: `data:image/png;base64,${parsed.imagePng}`,
|
|
1295
|
+
alt: "Python output",
|
|
1296
|
+
className: "max-w-full rounded-md border border-border/40"
|
|
1297
|
+
}
|
|
1298
|
+
)
|
|
1299
|
+
] }),
|
|
1300
|
+
isComplete && parsed && parsed.createdAssets.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2", children: [
|
|
1301
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Created assets" }),
|
|
1302
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-wrap gap-1.5", children: parsed.createdAssets.map((a) => /* @__PURE__ */ jsxs(
|
|
1303
|
+
"button",
|
|
1304
|
+
{
|
|
1305
|
+
type: "button",
|
|
1306
|
+
onClick: () => openAsset(a.asset_id),
|
|
1307
|
+
className: "flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1308
|
+
children: [
|
|
1309
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-2.5" }),
|
|
1310
|
+
truncate(a.asset_id, 20)
|
|
1311
|
+
]
|
|
1312
|
+
},
|
|
1313
|
+
a.asset_id
|
|
1314
|
+
)) })
|
|
1315
|
+
] })
|
|
1316
|
+
]
|
|
1317
|
+
}
|
|
1318
|
+
);
|
|
1319
|
+
};
|
|
1320
|
+
const RunPythonCodeToolUI = memo(
|
|
1321
|
+
RunPythonCodeToolUIImpl
|
|
1322
|
+
);
|
|
1323
|
+
RunPythonCodeToolUI.displayName = "RunPythonCodeToolUI";
|
|
1324
|
+
const ExecutePresentationCodeToolUIImpl = ({
|
|
1325
|
+
toolName,
|
|
1326
|
+
args,
|
|
1327
|
+
result,
|
|
1328
|
+
status
|
|
1329
|
+
}) => {
|
|
1330
|
+
var _a;
|
|
1331
|
+
const typedArgs = args;
|
|
1332
|
+
const code = (typedArgs == null ? void 0 : typedArgs.code) ?? "";
|
|
1333
|
+
const summary = (typedArgs == null ? void 0 : typedArgs.summary) ?? null;
|
|
1334
|
+
const deckIdFromArgs = getStringField(typedArgs, ["deck_id", "deckId", "asset_id", "assetId"]) ?? getPresentationCodeDeckId(code);
|
|
1335
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1336
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1337
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1338
|
+
const parsed = useMemo(
|
|
1339
|
+
() => isComplete ? parsePythonResult(result) : null,
|
|
1340
|
+
[result, isComplete]
|
|
1341
|
+
);
|
|
1342
|
+
const resultData = useMemo(() => normalizeResult(result), [result]);
|
|
1343
|
+
const outputText = parsed ? getExecutionTextOutput(parsed) : null;
|
|
1344
|
+
const targetSlideNumber = getPresentationCodeSlideNumber({
|
|
1345
|
+
args: typedArgs,
|
|
1346
|
+
result: resultData
|
|
1347
|
+
});
|
|
1348
|
+
const deckId = (parsed == null ? void 0 : parsed.deckId) ?? deckIdFromArgs;
|
|
1349
|
+
const assetId = (parsed == null ? void 0 : parsed.assetId) ?? ((deckId == null ? void 0 : deckId.startsWith("asset_")) ? deckId : null);
|
|
1350
|
+
const hasError = parsed && (parsed.error || parsed.exception);
|
|
1351
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
1352
|
+
useEffect(() => {
|
|
1353
|
+
if (!isComplete) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
logDebugPayload("[Athena SDK execute_presentation_code] tool state", {
|
|
1357
|
+
args: typedArgs,
|
|
1358
|
+
parsedResult: resultData,
|
|
1359
|
+
status,
|
|
1360
|
+
assetId,
|
|
1361
|
+
deckId,
|
|
1362
|
+
targetSlideNumber,
|
|
1363
|
+
outputText
|
|
1364
|
+
});
|
|
1365
|
+
}, [
|
|
1366
|
+
assetId,
|
|
1367
|
+
deckId,
|
|
1368
|
+
isComplete,
|
|
1369
|
+
outputText,
|
|
1370
|
+
resultData,
|
|
1371
|
+
status,
|
|
1372
|
+
targetSlideNumber,
|
|
1373
|
+
typedArgs
|
|
1374
|
+
]);
|
|
1375
|
+
const openPresentation = useCallback(() => {
|
|
1376
|
+
if (!assetId) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
logDebugPayload("[Athena SDK execute_presentation_code] open deck", {
|
|
1380
|
+
args: typedArgs,
|
|
1381
|
+
parsedResult: resultData,
|
|
1382
|
+
assetId,
|
|
1383
|
+
deckId,
|
|
1384
|
+
targetSlideNumber
|
|
1385
|
+
});
|
|
1386
|
+
openAsset(assetId, {
|
|
1387
|
+
type: "presentation",
|
|
1388
|
+
...targetSlideNumber !== void 0 ? { slideNumber: targetSlideNumber } : {}
|
|
1389
|
+
});
|
|
1390
|
+
}, [assetId, deckId, openAsset, resultData, targetSlideNumber, typedArgs]);
|
|
1391
|
+
return /* @__PURE__ */ jsxs(
|
|
1392
|
+
ToolCard,
|
|
1393
|
+
{
|
|
1394
|
+
icon: PresentationIcon,
|
|
1395
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1396
|
+
title: isRunning ? summary || "Executing presentation code..." : summary || "Presentation updated",
|
|
1397
|
+
subtitle: deckId ? `Deck ${truncate(deckId, 24)}` : assetId ? `Asset ${truncate(assetId, 24)}` : void 0,
|
|
1398
|
+
badge: "Deck",
|
|
1399
|
+
toolName,
|
|
1400
|
+
args: typedArgs,
|
|
1401
|
+
result,
|
|
1402
|
+
error: errorMsg,
|
|
1403
|
+
children: [
|
|
1404
|
+
assetId && isComplete && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1405
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
1406
|
+
/* @__PURE__ */ jsx("div", { className: "text-[11px] font-medium text-muted-foreground", children: "Open the updated deck in the asset panel" }),
|
|
1407
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-[11px] text-foreground/80", children: truncate(assetId, 32) })
|
|
1408
|
+
] }),
|
|
1409
|
+
/* @__PURE__ */ jsxs(
|
|
1410
|
+
"button",
|
|
1411
|
+
{
|
|
1412
|
+
type: "button",
|
|
1413
|
+
onClick: openPresentation,
|
|
1414
|
+
className: "flex shrink-0 items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1415
|
+
children: [
|
|
1416
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
1417
|
+
targetSlideNumber ? `Open slide ${targetSlideNumber}` : "Open deck"
|
|
1418
|
+
]
|
|
1419
|
+
}
|
|
1420
|
+
)
|
|
1421
|
+
] }) }),
|
|
1422
|
+
code && /* @__PURE__ */ jsx(ExpandableSection, { label: "Show code", children: /* @__PURE__ */ jsx(SyntaxHighlightedCode, { code }) }),
|
|
1423
|
+
isComplete && outputText && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
1424
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center gap-1.5", children: [
|
|
1425
|
+
/* @__PURE__ */ jsx(TerminalIcon, { className: "size-3 text-muted-foreground" }),
|
|
1426
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Execution log" })
|
|
1427
|
+
] }),
|
|
1428
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/30 p-2 text-[11px] leading-relaxed font-mono text-foreground/80", children: outputText })
|
|
1429
|
+
] }),
|
|
1430
|
+
isComplete && hasError && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: [
|
|
1431
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center gap-1.5", children: [
|
|
1432
|
+
/* @__PURE__ */ jsx(AlertTriangleIcon, { className: "size-3 text-destructive" }),
|
|
1433
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-destructive", children: parsed.exception ? `${parsed.exception.name}: ${parsed.exception.value}` : "Execution error" })
|
|
1434
|
+
] }),
|
|
1435
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-destructive/5 p-2 text-[11px] leading-relaxed font-mono text-destructive/80", children: ((_a = parsed.exception) == null ? void 0 : _a.traceback) ?? parsed.error })
|
|
1436
|
+
] }),
|
|
1437
|
+
isComplete && parsed && parsed.createdAssets.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2", children: [
|
|
1438
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Created assets" }),
|
|
1439
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-wrap gap-1.5", children: parsed.createdAssets.map((entry) => /* @__PURE__ */ jsxs(
|
|
1440
|
+
"button",
|
|
1441
|
+
{
|
|
1442
|
+
type: "button",
|
|
1443
|
+
onClick: () => openAsset(entry.asset_id),
|
|
1444
|
+
className: "flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1445
|
+
children: [
|
|
1446
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-2.5" }),
|
|
1447
|
+
truncate(entry.asset_id, 20)
|
|
1448
|
+
]
|
|
1449
|
+
},
|
|
1450
|
+
entry.asset_id
|
|
1451
|
+
)) })
|
|
1452
|
+
] })
|
|
1453
|
+
]
|
|
1454
|
+
}
|
|
1455
|
+
);
|
|
1456
|
+
};
|
|
1457
|
+
const ExecutePresentationCodeToolUI = memo(
|
|
1458
|
+
ExecutePresentationCodeToolUIImpl
|
|
1459
|
+
);
|
|
1460
|
+
ExecutePresentationCodeToolUI.displayName = "ExecutePresentationCodeToolUI";
|
|
1461
|
+
const OpenAssetToolUIImpl = ({
|
|
1462
|
+
toolName,
|
|
1463
|
+
args,
|
|
1464
|
+
result,
|
|
1465
|
+
status
|
|
1466
|
+
}) => {
|
|
1467
|
+
const typedArgs = args;
|
|
1468
|
+
const argsAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
|
|
1469
|
+
const resultAssetId = extractAssetId(result);
|
|
1470
|
+
const assetId = resultAssetId ?? (argsAssetId.startsWith("asset_") ? argsAssetId : null);
|
|
1471
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1472
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
1473
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
1474
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1475
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
1476
|
+
return /* @__PURE__ */ jsx(
|
|
1477
|
+
ToolCard,
|
|
1478
|
+
{
|
|
1479
|
+
icon: FolderOpenIcon,
|
|
1480
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1481
|
+
title: isRunning ? "Opening asset..." : "Asset opened",
|
|
1482
|
+
subtitle: assetId ? truncate(assetId, 30) : void 0,
|
|
1483
|
+
toolName,
|
|
1484
|
+
args: typedArgs,
|
|
1485
|
+
result,
|
|
1486
|
+
error: errorMsg,
|
|
1487
|
+
children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
1488
|
+
"button",
|
|
1489
|
+
{
|
|
1490
|
+
type: "button",
|
|
1491
|
+
onClick: () => openAsset(assetId),
|
|
1492
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
1495
|
+
"Open asset"
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
) })
|
|
1499
|
+
}
|
|
1500
|
+
);
|
|
1501
|
+
};
|
|
1502
|
+
const OpenAssetToolUI = memo(
|
|
1503
|
+
OpenAssetToolUIImpl
|
|
1504
|
+
);
|
|
1505
|
+
OpenAssetToolUI.displayName = "OpenAssetToolUI";
|
|
1506
|
+
const DescribeDatabaseToolUIImpl = ({
|
|
1507
|
+
toolName,
|
|
1508
|
+
args,
|
|
1509
|
+
result,
|
|
1510
|
+
status
|
|
1511
|
+
}) => {
|
|
1512
|
+
const typedArgs = args;
|
|
1513
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
1514
|
+
const title = typeof (data == null ? void 0 : data.title) === "string" ? data.title : null;
|
|
1515
|
+
const provider = typeof (data == null ? void 0 : data.provider) === "string" ? data.provider : null;
|
|
1516
|
+
const databaseName = typeof (data == null ? void 0 : data.database_name) === "string" ? data.database_name : null;
|
|
1517
|
+
const tableCount = typeof (data == null ? void 0 : data.table_count) === "number" ? data.table_count : null;
|
|
1518
|
+
const dbStatus = typeof (data == null ? void 0 : data.status) === "string" ? data.status : null;
|
|
1519
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1520
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1521
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1522
|
+
return /* @__PURE__ */ jsx(
|
|
1523
|
+
ToolCard,
|
|
1524
|
+
{
|
|
1525
|
+
icon: DatabaseIcon,
|
|
1526
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1527
|
+
title: isRunning ? "Inspecting database..." : title ? `Database: ${title}` : "Database overview",
|
|
1528
|
+
subtitle: databaseName ?? void 0,
|
|
1529
|
+
toolName,
|
|
1530
|
+
args: typedArgs,
|
|
1531
|
+
result,
|
|
1532
|
+
badge: isComplete && tableCount !== null ? `${tableCount} ${tableCount === 1 ? "table" : "tables"}` : void 0,
|
|
1533
|
+
error: errorMsg,
|
|
1534
|
+
children: isComplete && (title || provider || databaseName || dbStatus) && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-4 gap-y-2 text-[11px]", children: [
|
|
1535
|
+
title && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 min-w-0", children: [
|
|
1536
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Name" }),
|
|
1537
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-foreground/80", children: title })
|
|
1538
|
+
] }),
|
|
1539
|
+
provider && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 min-w-0", children: [
|
|
1540
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Provider" }),
|
|
1541
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-foreground/80 capitalize", children: provider })
|
|
1542
|
+
] }),
|
|
1543
|
+
databaseName && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 min-w-0", children: [
|
|
1544
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Database" }),
|
|
1545
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-mono text-foreground/80", children: databaseName })
|
|
1546
|
+
] }),
|
|
1547
|
+
dbStatus && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 min-w-0", children: [
|
|
1548
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Status" }),
|
|
1549
|
+
/* @__PURE__ */ jsxs(
|
|
1550
|
+
"span",
|
|
1551
|
+
{
|
|
1552
|
+
className: cn(
|
|
1553
|
+
"inline-flex w-fit items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium capitalize",
|
|
1554
|
+
dbStatus === "active" ? "bg-emerald-50 text-emerald-700" : "bg-muted text-muted-foreground"
|
|
1555
|
+
),
|
|
1556
|
+
children: [
|
|
1557
|
+
/* @__PURE__ */ jsx(
|
|
1558
|
+
"span",
|
|
1559
|
+
{
|
|
1560
|
+
className: cn(
|
|
1561
|
+
"size-1.5 rounded-full",
|
|
1562
|
+
dbStatus === "active" ? "bg-emerald-500" : "bg-muted-foreground"
|
|
1563
|
+
)
|
|
1564
|
+
}
|
|
1565
|
+
),
|
|
1566
|
+
dbStatus
|
|
1567
|
+
]
|
|
1568
|
+
}
|
|
1569
|
+
)
|
|
1570
|
+
] })
|
|
1571
|
+
] }) })
|
|
1572
|
+
}
|
|
1573
|
+
);
|
|
1574
|
+
};
|
|
1575
|
+
const DescribeDatabaseToolUI = memo(
|
|
1576
|
+
DescribeDatabaseToolUIImpl
|
|
1577
|
+
);
|
|
1578
|
+
DescribeDatabaseToolUI.displayName = "DescribeDatabaseToolUI";
|
|
1579
|
+
const ListDatabaseTablesToolUIImpl = ({
|
|
1580
|
+
toolName,
|
|
1581
|
+
args,
|
|
1582
|
+
result,
|
|
1583
|
+
status
|
|
1584
|
+
}) => {
|
|
1585
|
+
const typedArgs = args;
|
|
1586
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
1587
|
+
const tables = useMemo(() => {
|
|
1588
|
+
if (!data || !Array.isArray(data.tables)) return [];
|
|
1589
|
+
return data.tables.map((t) => {
|
|
1590
|
+
const item = t ?? {};
|
|
1591
|
+
return {
|
|
1592
|
+
table_name: typeof item.table_name === "string" ? item.table_name : "",
|
|
1593
|
+
schema_name: typeof item.schema_name === "string" ? item.schema_name : void 0,
|
|
1594
|
+
row_count: typeof item.row_count === "number" ? item.row_count : void 0
|
|
1595
|
+
};
|
|
1596
|
+
});
|
|
1597
|
+
}, [data]);
|
|
1598
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1599
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1600
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1601
|
+
return /* @__PURE__ */ jsx(
|
|
1602
|
+
ToolCard,
|
|
1603
|
+
{
|
|
1604
|
+
icon: TableIcon,
|
|
1605
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1606
|
+
title: isRunning ? "Listing database tables..." : "Database tables",
|
|
1607
|
+
toolName,
|
|
1608
|
+
args: typedArgs,
|
|
1609
|
+
result,
|
|
1610
|
+
badge: isComplete && tables.length > 0 ? `${tables.length} ${tables.length === 1 ? "table" : "tables"}` : void 0,
|
|
1611
|
+
error: errorMsg,
|
|
1612
|
+
children: isComplete && tables.length > 0 && /* @__PURE__ */ jsx(
|
|
1613
|
+
ExpandableSection,
|
|
1614
|
+
{
|
|
1615
|
+
label: "Show tables",
|
|
1616
|
+
defaultOpen: tables.length <= 10,
|
|
1617
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: tables.map((t) => {
|
|
1618
|
+
const qualified = t.schema_name ? `${t.schema_name}.${t.table_name}` : t.table_name;
|
|
1619
|
+
return /* @__PURE__ */ jsxs(
|
|
1620
|
+
"div",
|
|
1621
|
+
{
|
|
1622
|
+
className: "flex items-center justify-between gap-3 rounded-md px-2 py-1 hover:bg-muted/40",
|
|
1623
|
+
children: [
|
|
1624
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
1625
|
+
/* @__PURE__ */ jsx(TableIcon, { className: "size-3 shrink-0 text-muted-foreground/60" }),
|
|
1626
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-mono text-[12px] text-foreground/90", children: qualified })
|
|
1627
|
+
] }),
|
|
1628
|
+
t.row_count !== void 0 && /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-[10px] tabular-nums text-muted-foreground", children: [
|
|
1629
|
+
t.row_count.toLocaleString(),
|
|
1630
|
+
" ",
|
|
1631
|
+
t.row_count === 1 ? "row" : "rows"
|
|
1632
|
+
] })
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1635
|
+
qualified
|
|
1636
|
+
);
|
|
1637
|
+
}) })
|
|
1638
|
+
}
|
|
1639
|
+
)
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1642
|
+
};
|
|
1643
|
+
const ListDatabaseTablesToolUI = memo(
|
|
1644
|
+
ListDatabaseTablesToolUIImpl
|
|
1645
|
+
);
|
|
1646
|
+
ListDatabaseTablesToolUI.displayName = "ListDatabaseTablesToolUI";
|
|
1647
|
+
const GetDatabaseTableSchemaToolUIImpl = ({
|
|
1648
|
+
toolName,
|
|
1649
|
+
args,
|
|
1650
|
+
result,
|
|
1651
|
+
status
|
|
1652
|
+
}) => {
|
|
1653
|
+
const typedArgs = args;
|
|
1654
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
1655
|
+
const tableName = (typeof (data == null ? void 0 : data.table_name) === "string" ? data.table_name : null) ?? (typeof (typedArgs == null ? void 0 : typedArgs.table_name) === "string" ? typedArgs.table_name : null);
|
|
1656
|
+
const schemaName = typeof (data == null ? void 0 : data.schema_name) === "string" ? data.schema_name : null;
|
|
1657
|
+
const columns = useMemo(() => {
|
|
1658
|
+
if (!data || !Array.isArray(data.columns)) return [];
|
|
1659
|
+
return data.columns.map((c) => {
|
|
1660
|
+
const item = c ?? {};
|
|
1661
|
+
return {
|
|
1662
|
+
name: typeof item.name === "string" ? item.name : "",
|
|
1663
|
+
data_type: typeof item.data_type === "string" ? item.data_type : "",
|
|
1664
|
+
is_nullable: typeof item.is_nullable === "boolean" ? item.is_nullable : void 0,
|
|
1665
|
+
default_value: typeof item.default_value === "string" ? item.default_value : null,
|
|
1666
|
+
max_length: typeof item.max_length === "number" ? item.max_length : null
|
|
1667
|
+
};
|
|
1668
|
+
});
|
|
1669
|
+
}, [data]);
|
|
1670
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1671
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1672
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1673
|
+
const displayName = tableName ? schemaName ? `${schemaName}.${tableName}` : tableName : null;
|
|
1674
|
+
return /* @__PURE__ */ jsx(
|
|
1675
|
+
ToolCard,
|
|
1676
|
+
{
|
|
1677
|
+
icon: TablePropertiesIcon,
|
|
1678
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1679
|
+
title: isRunning ? "Reading table schema..." : displayName ? `Schema: ${displayName}` : "Table schema",
|
|
1680
|
+
toolName,
|
|
1681
|
+
args: typedArgs,
|
|
1682
|
+
result,
|
|
1683
|
+
badge: isComplete && columns.length > 0 ? `${columns.length} ${columns.length === 1 ? "column" : "columns"}` : void 0,
|
|
1684
|
+
error: errorMsg,
|
|
1685
|
+
children: isComplete && columns.length > 0 && /* @__PURE__ */ jsx(
|
|
1686
|
+
ExpandableSection,
|
|
1687
|
+
{
|
|
1688
|
+
label: "Show columns",
|
|
1689
|
+
defaultOpen: columns.length <= 12,
|
|
1690
|
+
children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-md border border-border/40", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[11px]", children: [
|
|
1691
|
+
/* @__PURE__ */ jsx("thead", { className: "bg-muted/50", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1692
|
+
/* @__PURE__ */ jsx("th", { className: "px-2 py-1.5 text-left font-medium text-muted-foreground", children: "Column" }),
|
|
1693
|
+
/* @__PURE__ */ jsx("th", { className: "px-2 py-1.5 text-left font-medium text-muted-foreground", children: "Type" }),
|
|
1694
|
+
/* @__PURE__ */ jsx("th", { className: "px-2 py-1.5 text-right font-medium text-muted-foreground", children: "Nullable" })
|
|
1695
|
+
] }) }),
|
|
1696
|
+
/* @__PURE__ */ jsx("tbody", { children: columns.map((col) => {
|
|
1697
|
+
const typeLabel = col.max_length != null ? `${col.data_type}(${col.max_length})` : col.data_type;
|
|
1698
|
+
return /* @__PURE__ */ jsxs(
|
|
1699
|
+
"tr",
|
|
1700
|
+
{
|
|
1701
|
+
className: "border-t border-border/30",
|
|
1702
|
+
title: col.default_value ? `default: ${col.default_value}` : void 0,
|
|
1703
|
+
children: [
|
|
1704
|
+
/* @__PURE__ */ jsx("td", { className: "whitespace-nowrap px-2 py-1 font-mono text-foreground/90", children: col.name }),
|
|
1705
|
+
/* @__PURE__ */ jsx("td", { className: "whitespace-nowrap px-2 py-1 text-muted-foreground", children: typeLabel }),
|
|
1706
|
+
/* @__PURE__ */ jsx("td", { className: "whitespace-nowrap px-2 py-1 text-right", children: col.is_nullable === false ? /* @__PURE__ */ jsx("span", { className: "rounded bg-amber-50 px-1 py-0.5 text-[10px] font-medium text-amber-700", children: "NOT NULL" }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50", children: "—" }) })
|
|
1707
|
+
]
|
|
1708
|
+
},
|
|
1709
|
+
col.name
|
|
1710
|
+
);
|
|
1711
|
+
}) })
|
|
1712
|
+
] }) })
|
|
1713
|
+
}
|
|
1714
|
+
)
|
|
1715
|
+
}
|
|
1716
|
+
);
|
|
1717
|
+
};
|
|
1718
|
+
const GetDatabaseTableSchemaToolUI = memo(
|
|
1719
|
+
GetDatabaseTableSchemaToolUIImpl
|
|
1720
|
+
);
|
|
1721
|
+
GetDatabaseTableSchemaToolUI.displayName = "GetDatabaseTableSchemaToolUI";
|
|
1722
|
+
const SQL_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1723
|
+
"SELECT",
|
|
1724
|
+
"FROM",
|
|
1725
|
+
"WHERE",
|
|
1726
|
+
"JOIN",
|
|
1727
|
+
"LEFT",
|
|
1728
|
+
"RIGHT",
|
|
1729
|
+
"INNER",
|
|
1730
|
+
"OUTER",
|
|
1731
|
+
"FULL",
|
|
1732
|
+
"CROSS",
|
|
1733
|
+
"ON",
|
|
1734
|
+
"USING",
|
|
1735
|
+
"AND",
|
|
1736
|
+
"OR",
|
|
1737
|
+
"NOT",
|
|
1738
|
+
"IN",
|
|
1739
|
+
"IS",
|
|
1740
|
+
"NULL",
|
|
1741
|
+
"AS",
|
|
1742
|
+
"ORDER",
|
|
1743
|
+
"BY",
|
|
1744
|
+
"GROUP",
|
|
1745
|
+
"HAVING",
|
|
1746
|
+
"LIMIT",
|
|
1747
|
+
"OFFSET",
|
|
1748
|
+
"UNION",
|
|
1749
|
+
"ALL",
|
|
1750
|
+
"DISTINCT",
|
|
1751
|
+
"INSERT",
|
|
1752
|
+
"INTO",
|
|
1753
|
+
"VALUES",
|
|
1754
|
+
"UPDATE",
|
|
1755
|
+
"SET",
|
|
1756
|
+
"DELETE",
|
|
1757
|
+
"CREATE",
|
|
1758
|
+
"TABLE",
|
|
1759
|
+
"DROP",
|
|
1760
|
+
"ALTER",
|
|
1761
|
+
"ADD",
|
|
1762
|
+
"COLUMN",
|
|
1763
|
+
"INDEX",
|
|
1764
|
+
"PRIMARY",
|
|
1765
|
+
"KEY",
|
|
1766
|
+
"FOREIGN",
|
|
1767
|
+
"REFERENCES",
|
|
1768
|
+
"CONSTRAINT",
|
|
1769
|
+
"CASCADE",
|
|
1770
|
+
"CASE",
|
|
1771
|
+
"WHEN",
|
|
1772
|
+
"THEN",
|
|
1773
|
+
"ELSE",
|
|
1774
|
+
"END",
|
|
1775
|
+
"WITH",
|
|
1776
|
+
"RECURSIVE",
|
|
1777
|
+
"ASC",
|
|
1778
|
+
"DESC",
|
|
1779
|
+
"BETWEEN",
|
|
1780
|
+
"LIKE",
|
|
1781
|
+
"ILIKE",
|
|
1782
|
+
"EXISTS",
|
|
1783
|
+
"ANY",
|
|
1784
|
+
"SOME",
|
|
1785
|
+
"RETURNING",
|
|
1786
|
+
"OVER",
|
|
1787
|
+
"PARTITION",
|
|
1788
|
+
"WINDOW"
|
|
1789
|
+
]);
|
|
1790
|
+
const SQL_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
1791
|
+
"COUNT",
|
|
1792
|
+
"SUM",
|
|
1793
|
+
"AVG",
|
|
1794
|
+
"MIN",
|
|
1795
|
+
"MAX",
|
|
1796
|
+
"ROUND",
|
|
1797
|
+
"CAST",
|
|
1798
|
+
"COALESCE",
|
|
1799
|
+
"NULLIF",
|
|
1800
|
+
"UPPER",
|
|
1801
|
+
"LOWER",
|
|
1802
|
+
"LENGTH",
|
|
1803
|
+
"SUBSTRING",
|
|
1804
|
+
"TRIM",
|
|
1805
|
+
"CONCAT",
|
|
1806
|
+
"DATE",
|
|
1807
|
+
"NOW",
|
|
1808
|
+
"CURRENT_DATE",
|
|
1809
|
+
"CURRENT_TIMESTAMP",
|
|
1810
|
+
"EXTRACT",
|
|
1811
|
+
"DATE_TRUNC",
|
|
1812
|
+
"ROW_NUMBER",
|
|
1813
|
+
"RANK",
|
|
1814
|
+
"DENSE_RANK",
|
|
1815
|
+
"LAG",
|
|
1816
|
+
"LEAD"
|
|
1817
|
+
]);
|
|
1818
|
+
function highlightSql(code) {
|
|
1819
|
+
let result = "";
|
|
1820
|
+
let i = 0;
|
|
1821
|
+
while (i < code.length) {
|
|
1822
|
+
if (code.slice(i, i + 2) === "--") {
|
|
1823
|
+
const end = code.indexOf("\n", i);
|
|
1824
|
+
const str = end >= 0 ? code.slice(i, end) : code.slice(i);
|
|
1825
|
+
result += `<span style="color:var(--aui-syn-comment, #6a9955)">${escapeHtml(str)}</span>`;
|
|
1826
|
+
i += str.length;
|
|
1827
|
+
continue;
|
|
1828
|
+
}
|
|
1829
|
+
if (code.slice(i, i + 2) === "/*") {
|
|
1830
|
+
const end = code.indexOf("*/", i + 2);
|
|
1831
|
+
const str = end >= 0 ? code.slice(i, end + 2) : code.slice(i);
|
|
1832
|
+
result += `<span style="color:var(--aui-syn-comment, #6a9955)">${escapeHtml(str)}</span>`;
|
|
1833
|
+
i += str.length;
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
if (code[i] === "'" || code[i] === '"') {
|
|
1837
|
+
const q = code[i];
|
|
1838
|
+
let j = i + 1;
|
|
1839
|
+
while (j < code.length) {
|
|
1840
|
+
if (code[j] === q) {
|
|
1841
|
+
if (j + 1 < code.length && code[j + 1] === q) {
|
|
1842
|
+
j += 2;
|
|
1843
|
+
continue;
|
|
1844
|
+
}
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1847
|
+
j++;
|
|
1848
|
+
}
|
|
1849
|
+
const str = code.slice(i, j + 1);
|
|
1850
|
+
result += `<span style="color:var(--aui-syn-string, #ce9178)">${escapeHtml(str)}</span>`;
|
|
1851
|
+
i = j + 1;
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
if (/\d/.test(code[i]) && (i === 0 || /[\s(,=[\-+*/:!<>]/.test(code[i - 1]))) {
|
|
1855
|
+
const m = code.slice(i).match(/^(\d+\.?\d*)/);
|
|
1856
|
+
if (m) {
|
|
1857
|
+
result += `<span style="color:var(--aui-syn-number, #b5cea8)">${escapeHtml(m[1])}</span>`;
|
|
1858
|
+
i += m[1].length;
|
|
1859
|
+
continue;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
if (/[a-zA-Z_]/.test(code[i])) {
|
|
1863
|
+
const m = code.slice(i).match(/^[a-zA-Z_]\w*/);
|
|
1864
|
+
if (m) {
|
|
1865
|
+
const word = m[0];
|
|
1866
|
+
const upper = word.toUpperCase();
|
|
1867
|
+
if (SQL_KEYWORDS.has(upper)) {
|
|
1868
|
+
result += `<span style="color:var(--aui-syn-keyword, #569cd6)">${escapeHtml(word)}</span>`;
|
|
1869
|
+
} else if (SQL_FUNCTIONS.has(upper)) {
|
|
1870
|
+
result += `<span style="color:var(--aui-syn-func, #dcdcaa)">${escapeHtml(word)}</span>`;
|
|
1871
|
+
} else {
|
|
1872
|
+
result += escapeHtml(word);
|
|
1873
|
+
}
|
|
1874
|
+
i += word.length;
|
|
1875
|
+
continue;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
result += escapeHtml(code[i]);
|
|
1879
|
+
i++;
|
|
1880
|
+
}
|
|
1881
|
+
return result;
|
|
1882
|
+
}
|
|
1883
|
+
const SyntaxHighlightedSql = memo(({ code }) => {
|
|
1884
|
+
const highlighted = useMemo(() => highlightSql(code), [code]);
|
|
1885
|
+
return /* @__PURE__ */ jsx(
|
|
1886
|
+
"pre",
|
|
1887
|
+
{
|
|
1888
|
+
className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed font-mono",
|
|
1889
|
+
dangerouslySetInnerHTML: { __html: highlighted }
|
|
1890
|
+
}
|
|
1891
|
+
);
|
|
1892
|
+
});
|
|
1893
|
+
SyntaxHighlightedSql.displayName = "SyntaxHighlightedSql";
|
|
1894
|
+
function parseSqlResult(result) {
|
|
1895
|
+
const empty = { columns: [], rows: [], rowCount: null };
|
|
1896
|
+
const data = normalizeResult(result);
|
|
1897
|
+
if (!data) return empty;
|
|
1898
|
+
const inner = data.result && typeof data.result === "object" && !Array.isArray(data.result) ? data.result : data;
|
|
1899
|
+
const rawRows = inner.rows ?? inner.data ?? inner.records;
|
|
1900
|
+
if (!Array.isArray(rawRows)) return empty;
|
|
1901
|
+
const rows = rawRows.filter(
|
|
1902
|
+
(r) => typeof r === "object" && r !== null && !Array.isArray(r)
|
|
1903
|
+
);
|
|
1904
|
+
let columns = [];
|
|
1905
|
+
if (Array.isArray(inner.columns)) {
|
|
1906
|
+
columns = inner.columns.map((c) => {
|
|
1907
|
+
if (typeof c === "string") return c;
|
|
1908
|
+
if (c && typeof c === "object") {
|
|
1909
|
+
const name = c.name;
|
|
1910
|
+
return typeof name === "string" ? name : null;
|
|
1911
|
+
}
|
|
1912
|
+
return null;
|
|
1913
|
+
}).filter((c) => c !== null);
|
|
1914
|
+
}
|
|
1915
|
+
if (columns.length === 0 && rows.length > 0) {
|
|
1916
|
+
columns = Object.keys(rows[0]);
|
|
1917
|
+
}
|
|
1918
|
+
const rowCount = typeof inner.row_count === "number" ? inner.row_count : typeof inner.rowCount === "number" ? inner.rowCount : rows.length;
|
|
1919
|
+
return { columns, rows, rowCount };
|
|
1920
|
+
}
|
|
1921
|
+
const RunSqlToolUIImpl = ({
|
|
1922
|
+
toolName,
|
|
1923
|
+
args,
|
|
1924
|
+
result,
|
|
1925
|
+
status
|
|
1926
|
+
}) => {
|
|
1927
|
+
const typedArgs = args;
|
|
1928
|
+
const sqlQuery = (typedArgs == null ? void 0 : typedArgs.sql_query) ?? (typedArgs == null ? void 0 : typedArgs.query) ?? (typedArgs == null ? void 0 : typedArgs.sql) ?? "";
|
|
1929
|
+
const trimmedQuery = sqlQuery.trim();
|
|
1930
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
1931
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
1932
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
1933
|
+
const parsed = useMemo(
|
|
1934
|
+
() => isComplete ? parseSqlResult(result) : null,
|
|
1935
|
+
[result, isComplete]
|
|
1936
|
+
);
|
|
1937
|
+
const querySubtitle = useMemo(() => {
|
|
1938
|
+
if (!trimmedQuery) return void 0;
|
|
1939
|
+
const oneLine = trimmedQuery.replace(/\s+/g, " ");
|
|
1940
|
+
return truncate(oneLine, 80);
|
|
1941
|
+
}, [trimmedQuery]);
|
|
1942
|
+
return /* @__PURE__ */ jsxs(
|
|
1943
|
+
ToolCard,
|
|
1944
|
+
{
|
|
1945
|
+
icon: PlayIcon,
|
|
1946
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
1947
|
+
title: isRunning ? "Running SQL query..." : "SQL query",
|
|
1948
|
+
subtitle: querySubtitle,
|
|
1949
|
+
toolName,
|
|
1950
|
+
args: typedArgs,
|
|
1951
|
+
result,
|
|
1952
|
+
badge: isComplete && parsed && parsed.rowCount !== null ? `${parsed.rowCount} ${parsed.rowCount === 1 ? "row" : "rows"}` : void 0,
|
|
1953
|
+
error: errorMsg,
|
|
1954
|
+
children: [
|
|
1955
|
+
trimmedQuery && /* @__PURE__ */ jsx(
|
|
1956
|
+
ExpandableSection,
|
|
1957
|
+
{
|
|
1958
|
+
label: "Show query",
|
|
1959
|
+
defaultOpen: isComplete && (!parsed || parsed.rows.length === 0),
|
|
1960
|
+
children: /* @__PURE__ */ jsx(SyntaxHighlightedSql, { code: trimmedQuery })
|
|
1961
|
+
}
|
|
1962
|
+
),
|
|
1963
|
+
isComplete && parsed && parsed.rows.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40", children: [
|
|
1964
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-72 overflow-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[11px]", children: [
|
|
1965
|
+
/* @__PURE__ */ jsx("thead", { className: "sticky top-0 bg-muted/60 backdrop-blur", children: /* @__PURE__ */ jsx("tr", { children: parsed.columns.map((col) => /* @__PURE__ */ jsx(
|
|
1966
|
+
"th",
|
|
1967
|
+
{
|
|
1968
|
+
className: "whitespace-nowrap px-2 py-1.5 text-left font-medium text-muted-foreground",
|
|
1969
|
+
children: col
|
|
1970
|
+
},
|
|
1971
|
+
col
|
|
1972
|
+
)) }) }),
|
|
1973
|
+
/* @__PURE__ */ jsx("tbody", { children: parsed.rows.slice(0, 50).map((row, i) => /* @__PURE__ */ jsx(
|
|
1974
|
+
"tr",
|
|
1975
|
+
{
|
|
1976
|
+
className: "border-t border-border/30 hover:bg-muted/20",
|
|
1977
|
+
children: parsed.columns.map((col) => {
|
|
1978
|
+
const value = row[col];
|
|
1979
|
+
const isNull = value === null || value === void 0;
|
|
1980
|
+
const str = isNull ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
1981
|
+
return /* @__PURE__ */ jsx(
|
|
1982
|
+
"td",
|
|
1983
|
+
{
|
|
1984
|
+
className: "max-w-[240px] truncate whitespace-nowrap px-2 py-1 text-foreground/80",
|
|
1985
|
+
title: isNull ? "null" : str,
|
|
1986
|
+
children: isNull ? /* @__PURE__ */ jsx("span", { className: "italic text-muted-foreground/60", children: "null" }) : str
|
|
1987
|
+
},
|
|
1988
|
+
col
|
|
1989
|
+
);
|
|
1990
|
+
})
|
|
1991
|
+
},
|
|
1992
|
+
i
|
|
1993
|
+
)) })
|
|
1994
|
+
] }) }),
|
|
1995
|
+
(parsed.rows.length > 50 || parsed.rowCount !== null && parsed.rowCount > parsed.rows.length) && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/30 px-4 py-1.5 text-[10px] text-muted-foreground", children: [
|
|
1996
|
+
"Showing first ",
|
|
1997
|
+
Math.min(50, parsed.rows.length),
|
|
1998
|
+
" of ",
|
|
1999
|
+
parsed.rowCount ?? parsed.rows.length,
|
|
2000
|
+
" rows"
|
|
2001
|
+
] })
|
|
2002
|
+
] }),
|
|
2003
|
+
isComplete && parsed && parsed.rows.length === 0 && parsed.rowCount === 0 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2.5", children: /* @__PURE__ */ jsx("span", { className: "text-[11px] italic text-muted-foreground", children: "Query returned no rows" }) })
|
|
2004
|
+
]
|
|
2005
|
+
}
|
|
2006
|
+
);
|
|
2007
|
+
};
|
|
2008
|
+
const RunSqlToolUI = memo(
|
|
2009
|
+
RunSqlToolUIImpl
|
|
2010
|
+
);
|
|
2011
|
+
RunSqlToolUI.displayName = "RunSqlToolUI";
|
|
2012
|
+
function parseA1Range(range) {
|
|
2013
|
+
const stripped = range.replace(/^(?:'[^']+'|[^'!]+)!/, "");
|
|
2014
|
+
const match = stripped.match(/^([A-Z]+)(\d+)/i);
|
|
2015
|
+
if (!match) return null;
|
|
2016
|
+
return { startCol: match[1].toUpperCase(), startRow: parseInt(match[2], 10) };
|
|
2017
|
+
}
|
|
2018
|
+
function colNumToLetter(n) {
|
|
2019
|
+
let result = "";
|
|
2020
|
+
let num = n;
|
|
2021
|
+
while (num > 0) {
|
|
2022
|
+
num--;
|
|
2023
|
+
result = String.fromCharCode(65 + num % 26) + result;
|
|
2024
|
+
num = Math.floor(num / 26);
|
|
2025
|
+
}
|
|
2026
|
+
return result;
|
|
2027
|
+
}
|
|
2028
|
+
function parseCellsToGrid(cells) {
|
|
2029
|
+
let parsed = null;
|
|
2030
|
+
if (typeof cells === "string") {
|
|
2031
|
+
try {
|
|
2032
|
+
parsed = JSON.parse(cells);
|
|
2033
|
+
} catch {
|
|
2034
|
+
return null;
|
|
2035
|
+
}
|
|
2036
|
+
} else if (Array.isArray(cells)) {
|
|
2037
|
+
parsed = cells;
|
|
2038
|
+
}
|
|
2039
|
+
if (!parsed || !Array.isArray(parsed)) return null;
|
|
2040
|
+
return parsed.map((row) => {
|
|
2041
|
+
if (!Array.isArray(row)) return [];
|
|
2042
|
+
return row.map((cell) => {
|
|
2043
|
+
if (cell == null) return "";
|
|
2044
|
+
if (typeof cell === "object" && cell !== null) {
|
|
2045
|
+
const c = cell;
|
|
2046
|
+
if (c.formula) return c.formula;
|
|
2047
|
+
if (c.value !== void 0 && c.value !== null) return String(c.value);
|
|
2048
|
+
return "";
|
|
2049
|
+
}
|
|
2050
|
+
return String(cell);
|
|
2051
|
+
});
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
const MAX_SHEET_DISPLAY_ROWS = 30;
|
|
2055
|
+
const MAX_LISTED_DV_VIOLATIONS = 3;
|
|
2056
|
+
function buildSheetUpdateFailureMessage(data, range) {
|
|
2057
|
+
const rawViolations = data == null ? void 0 : data.dataValidationViolations;
|
|
2058
|
+
const violations = Array.isArray(rawViolations) ? rawViolations : [];
|
|
2059
|
+
if (violations.length > 0) {
|
|
2060
|
+
const listed = violations.slice(0, MAX_LISTED_DV_VIOLATIONS).map((v) => {
|
|
2061
|
+
const expectation = v.allowed && v.allowed.length > 0 ? `only allows ${v.allowed.join(", ")}` : `rejected the value${v.constraint ? ` (${v.constraint})` : ""}`;
|
|
2062
|
+
return `${v.address ?? "cell"} ${expectation}`;
|
|
2063
|
+
});
|
|
2064
|
+
const more = violations.length > MAX_LISTED_DV_VIOLATIONS ? ` (+${violations.length - MAX_LISTED_DV_VIOLATIONS} more)` : "";
|
|
2065
|
+
return `Data validation blocked this update — nothing was written: ${listed.join("; ")}${more}`;
|
|
2066
|
+
}
|
|
2067
|
+
const errorStr = typeof (data == null ? void 0 : data.error) === "string" ? data.error : null;
|
|
2068
|
+
if (errorStr) return errorStr;
|
|
2069
|
+
return `Update to ${range || "the sheet"} was rejected — nothing was written`;
|
|
2070
|
+
}
|
|
2071
|
+
const UpdateSheetRangeToolUIImpl = ({
|
|
2072
|
+
toolName,
|
|
2073
|
+
args,
|
|
2074
|
+
result,
|
|
2075
|
+
status
|
|
2076
|
+
}) => {
|
|
2077
|
+
const typedArgs = args;
|
|
2078
|
+
const range = (typedArgs == null ? void 0 : typedArgs.range) ?? "";
|
|
2079
|
+
const explanation = (typedArgs == null ? void 0 : typedArgs.explanation) ?? "";
|
|
2080
|
+
const assetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
|
|
2081
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
2082
|
+
const success = (data == null ? void 0 : data.success) === true;
|
|
2083
|
+
const resultAssetId = extractAssetId(result);
|
|
2084
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2085
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
2086
|
+
const isFailure = isComplete && (data == null ? void 0 : data.success) === false;
|
|
2087
|
+
const errorMsg = isFailure ? buildSheetUpdateFailureMessage(data, range) : (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
2088
|
+
const grid = useMemo(
|
|
2089
|
+
() => parseCellsToGrid(typedArgs == null ? void 0 : typedArgs.cells),
|
|
2090
|
+
[typedArgs == null ? void 0 : typedArgs.cells]
|
|
2091
|
+
);
|
|
2092
|
+
const rangeInfo = useMemo(() => parseA1Range(range), [range]);
|
|
2093
|
+
const { headers, displayRows, totalRows } = useMemo(() => {
|
|
2094
|
+
if (!grid || grid.length === 0) {
|
|
2095
|
+
return { headers: [], displayRows: [], totalRows: 0 };
|
|
2096
|
+
}
|
|
2097
|
+
const maxCols = Math.max(...grid.map((r) => r.length));
|
|
2098
|
+
const startColNum = rangeInfo ? rangeInfo.startCol.split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - 64, 0) : 1;
|
|
2099
|
+
const hdrs = Array.from(
|
|
2100
|
+
{ length: maxCols },
|
|
2101
|
+
(_, i) => colNumToLetter(startColNum + i)
|
|
2102
|
+
);
|
|
2103
|
+
const capped = grid.slice(0, MAX_SHEET_DISPLAY_ROWS);
|
|
2104
|
+
return { headers: hdrs, displayRows: capped, totalRows: grid.length };
|
|
2105
|
+
}, [grid, rangeInfo]);
|
|
2106
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2107
|
+
const effectiveAssetId = resultAssetId ?? (assetId.startsWith("asset_") ? assetId : null);
|
|
2108
|
+
const title = isRunning ? explanation ? `Updating ${range}: ${explanation}` : `Updating sheet range ${range}...` : isFailure ? `Update to ${range || "sheet"} rejected` : explanation ? `Updated ${range}: ${explanation}` : `Updated sheet range ${range}`;
|
|
2109
|
+
return /* @__PURE__ */ jsxs(
|
|
2110
|
+
ToolCard,
|
|
2111
|
+
{
|
|
2112
|
+
icon: SheetIcon,
|
|
2113
|
+
status: isFailure ? "incomplete" : (status == null ? void 0 : status.type) ?? "complete",
|
|
2114
|
+
title: truncate(title, 80),
|
|
2115
|
+
subtitle: !explanation && range ? `Range: ${range}` : void 0,
|
|
2116
|
+
toolName,
|
|
2117
|
+
args: typedArgs,
|
|
2118
|
+
result,
|
|
2119
|
+
badge: isComplete && success && grid ? `${totalRows} ${totalRows === 1 ? "row" : "rows"}` : void 0,
|
|
2120
|
+
error: errorMsg,
|
|
2121
|
+
children: [
|
|
2122
|
+
headers.length > 0 && displayRows.length > 0 && /* @__PURE__ */ jsxs(
|
|
2123
|
+
ExpandableSection,
|
|
2124
|
+
{
|
|
2125
|
+
label: `Show data (${totalRows} ${totalRows === 1 ? "row" : "rows"})`,
|
|
2126
|
+
defaultOpen: totalRows <= 10,
|
|
2127
|
+
children: [
|
|
2128
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-auto max-h-72", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[11px]", children: [
|
|
2129
|
+
/* @__PURE__ */ jsx("thead", { className: "sticky top-0 bg-muted/60 backdrop-blur", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2130
|
+
/* @__PURE__ */ jsx("th", { className: "w-8 px-1.5 py-1 text-right font-medium text-muted-foreground/60", children: "#" }),
|
|
2131
|
+
headers.map((h) => /* @__PURE__ */ jsx(
|
|
2132
|
+
"th",
|
|
2133
|
+
{
|
|
2134
|
+
className: "whitespace-nowrap px-2 py-1 text-center font-medium text-muted-foreground",
|
|
2135
|
+
children: h
|
|
2136
|
+
},
|
|
2137
|
+
h
|
|
2138
|
+
))
|
|
2139
|
+
] }) }),
|
|
2140
|
+
/* @__PURE__ */ jsx("tbody", { children: displayRows.map((row, i) => {
|
|
2141
|
+
const rowNum = ((rangeInfo == null ? void 0 : rangeInfo.startRow) ?? 1) + i;
|
|
2142
|
+
return /* @__PURE__ */ jsxs("tr", { className: "border-t border-border/30 hover:bg-muted/20", children: [
|
|
2143
|
+
/* @__PURE__ */ jsx("td", { className: "w-8 px-1.5 py-0.5 text-right tabular-nums text-muted-foreground/60", children: rowNum }),
|
|
2144
|
+
headers.map((h, j) => {
|
|
2145
|
+
const val = row[j] ?? "";
|
|
2146
|
+
const isFormula = typeof val === "string" && val.startsWith("=");
|
|
2147
|
+
return /* @__PURE__ */ jsx(
|
|
2148
|
+
"td",
|
|
2149
|
+
{
|
|
2150
|
+
className: cn(
|
|
2151
|
+
"max-w-[180px] truncate whitespace-nowrap px-2 py-0.5 text-foreground/80",
|
|
2152
|
+
isFormula && "font-mono text-blue-600"
|
|
2153
|
+
),
|
|
2154
|
+
title: val,
|
|
2155
|
+
children: val || /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/30", children: "—" })
|
|
2156
|
+
},
|
|
2157
|
+
h
|
|
2158
|
+
);
|
|
2159
|
+
})
|
|
2160
|
+
] }, i);
|
|
2161
|
+
}) })
|
|
2162
|
+
] }) }),
|
|
2163
|
+
totalRows > MAX_SHEET_DISPLAY_ROWS && /* @__PURE__ */ jsxs("div", { className: "px-2 py-1 text-[10px] text-muted-foreground", children: [
|
|
2164
|
+
"Showing first ",
|
|
2165
|
+
MAX_SHEET_DISPLAY_ROWS,
|
|
2166
|
+
" of ",
|
|
2167
|
+
totalRows,
|
|
2168
|
+
" rows"
|
|
2169
|
+
] })
|
|
2170
|
+
]
|
|
2171
|
+
}
|
|
2172
|
+
),
|
|
2173
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
2174
|
+
"button",
|
|
2175
|
+
{
|
|
2176
|
+
type: "button",
|
|
2177
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
2178
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2179
|
+
children: [
|
|
2180
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2181
|
+
"Open spreadsheet"
|
|
2182
|
+
]
|
|
2183
|
+
}
|
|
2184
|
+
) })
|
|
2185
|
+
]
|
|
2186
|
+
}
|
|
2187
|
+
);
|
|
2188
|
+
};
|
|
2189
|
+
const UpdateSheetRangeToolUI = memo(
|
|
2190
|
+
UpdateSheetRangeToolUIImpl
|
|
2191
|
+
);
|
|
2192
|
+
UpdateSheetRangeToolUI.displayName = "UpdateSheetRangeToolUI";
|
|
2193
|
+
function parseJsonArray(text) {
|
|
2194
|
+
try {
|
|
2195
|
+
const parsed = JSON.parse(text);
|
|
2196
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
2197
|
+
} catch {
|
|
2198
|
+
return null;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
function getFirstSheetCellStyle(operation) {
|
|
2202
|
+
const cells = operation.cells;
|
|
2203
|
+
const rows = typeof cells === "string" ? parseJsonArray(cells) : cells;
|
|
2204
|
+
if (!Array.isArray(rows)) {
|
|
2205
|
+
return null;
|
|
2206
|
+
}
|
|
2207
|
+
for (const row of rows) {
|
|
2208
|
+
if (!Array.isArray(row)) {
|
|
2209
|
+
continue;
|
|
2210
|
+
}
|
|
2211
|
+
for (const cell of row) {
|
|
2212
|
+
const cellRecord = asRecord(cell);
|
|
2213
|
+
const style = asRecord(
|
|
2214
|
+
(cellRecord == null ? void 0 : cellRecord.cellStyles) ?? (cellRecord == null ? void 0 : cellRecord.cell_styles) ?? (cellRecord == null ? void 0 : cellRecord.style)
|
|
2215
|
+
);
|
|
2216
|
+
if (style) {
|
|
2217
|
+
return style;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
return null;
|
|
2222
|
+
}
|
|
2223
|
+
function summarizeSheetCellStyle(style) {
|
|
2224
|
+
if (!style) {
|
|
2225
|
+
return "Cell formatting";
|
|
2226
|
+
}
|
|
2227
|
+
const parts = [];
|
|
2228
|
+
const textFormat = asRecord(style.textFormat ?? style.text_format);
|
|
2229
|
+
if ((textFormat == null ? void 0 : textFormat.bold) === true) {
|
|
2230
|
+
parts.push("bold");
|
|
2231
|
+
}
|
|
2232
|
+
if ((textFormat == null ? void 0 : textFormat.italic) === true) {
|
|
2233
|
+
parts.push("italic");
|
|
2234
|
+
}
|
|
2235
|
+
if ((textFormat == null ? void 0 : textFormat.underline) === true) {
|
|
2236
|
+
parts.push("underline");
|
|
2237
|
+
}
|
|
2238
|
+
const fontSize = getNumberField(textFormat, ["fontSize", "font_size"]);
|
|
2239
|
+
if (fontSize != null) {
|
|
2240
|
+
parts.push(`${fontSize} pt`);
|
|
2241
|
+
}
|
|
2242
|
+
const textColor = getStringField(textFormat, [
|
|
2243
|
+
"color_hex",
|
|
2244
|
+
"colorHex",
|
|
2245
|
+
"foregroundColor_hex",
|
|
2246
|
+
"foregroundColorHex"
|
|
2247
|
+
]);
|
|
2248
|
+
if (textColor) {
|
|
2249
|
+
parts.push(`text ${textColor}`);
|
|
2250
|
+
}
|
|
2251
|
+
const fillColor = getStringField(style, [
|
|
2252
|
+
"backgroundColor_hex",
|
|
2253
|
+
"backgroundColorHex",
|
|
2254
|
+
"background_color_hex"
|
|
2255
|
+
]);
|
|
2256
|
+
if (fillColor) {
|
|
2257
|
+
parts.push(`fill ${fillColor}`);
|
|
2258
|
+
}
|
|
2259
|
+
const numberFormat = asRecord(style.numberFormat ?? style.number_format);
|
|
2260
|
+
const numberPattern = getStringField(numberFormat, ["pattern"]);
|
|
2261
|
+
const numberType = getStringField(numberFormat, ["type"]);
|
|
2262
|
+
if (numberPattern) {
|
|
2263
|
+
parts.push(numberPattern);
|
|
2264
|
+
} else if (numberType) {
|
|
2265
|
+
parts.push(numberType.toLowerCase());
|
|
2266
|
+
}
|
|
2267
|
+
const horizontalAlignment = getStringField(style, [
|
|
2268
|
+
"horizontalAlignment",
|
|
2269
|
+
"horizontal_alignment"
|
|
2270
|
+
]);
|
|
2271
|
+
if (horizontalAlignment) {
|
|
2272
|
+
parts.push(`${horizontalAlignment.toLowerCase()} align`);
|
|
2273
|
+
}
|
|
2274
|
+
return parts.length > 0 ? parts.slice(0, 5).join(", ") : "Cell formatting";
|
|
2275
|
+
}
|
|
2276
|
+
function parseSheetFormatOperations(operationsValue) {
|
|
2277
|
+
const operations = typeof operationsValue === "string" ? parseJsonArray(operationsValue) : operationsValue;
|
|
2278
|
+
if (!Array.isArray(operations)) {
|
|
2279
|
+
return [];
|
|
2280
|
+
}
|
|
2281
|
+
return operations.flatMap((operation) => {
|
|
2282
|
+
const record = asRecord(operation);
|
|
2283
|
+
if (!record) {
|
|
2284
|
+
return [];
|
|
2285
|
+
}
|
|
2286
|
+
const range = getStringField(record, ["range"]) ?? "";
|
|
2287
|
+
if (!range) {
|
|
2288
|
+
return [];
|
|
2289
|
+
}
|
|
2290
|
+
const assetId = getStringField(record, ["asset_id", "assetId", "id"]);
|
|
2291
|
+
return [
|
|
2292
|
+
{
|
|
2293
|
+
assetId: (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null,
|
|
2294
|
+
explanation: getStringField(record, ["explanation", "summary"]),
|
|
2295
|
+
range,
|
|
2296
|
+
styleSummary: summarizeSheetCellStyle(getFirstSheetCellStyle(record))
|
|
2297
|
+
}
|
|
2298
|
+
];
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
function getSpreadsheetAssetIdFromOperations(operations) {
|
|
2302
|
+
var _a;
|
|
2303
|
+
return ((_a = operations.find((operation) => operation.assetId)) == null ? void 0 : _a.assetId) ?? null;
|
|
2304
|
+
}
|
|
2305
|
+
function getSpreadsheetAssetIdFromArgs(args) {
|
|
2306
|
+
const assetId = getStringField(args, ["asset_id", "assetId", "id"]);
|
|
2307
|
+
return (assetId == null ? void 0 : assetId.startsWith("asset_")) ? assetId : null;
|
|
2308
|
+
}
|
|
2309
|
+
function summarizeSheetRanges(ranges) {
|
|
2310
|
+
if (ranges.length === 0) {
|
|
2311
|
+
return void 0;
|
|
2312
|
+
}
|
|
2313
|
+
const visible = ranges.slice(0, 4);
|
|
2314
|
+
const remaining = ranges.length - visible.length;
|
|
2315
|
+
return remaining > 0 ? `${visible.join(", ")} +${remaining} more` : visible.join(", ");
|
|
2316
|
+
}
|
|
2317
|
+
const BulkFormatSheetRangeToolUIImpl = ({
|
|
2318
|
+
toolName,
|
|
2319
|
+
args,
|
|
2320
|
+
result,
|
|
2321
|
+
status
|
|
2322
|
+
}) => {
|
|
2323
|
+
const typedArgs = args;
|
|
2324
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
2325
|
+
const operations = useMemo(
|
|
2326
|
+
() => parseSheetFormatOperations(typedArgs == null ? void 0 : typedArgs.operations),
|
|
2327
|
+
[typedArgs == null ? void 0 : typedArgs.operations]
|
|
2328
|
+
);
|
|
2329
|
+
const resultAssetId = extractAssetId(result);
|
|
2330
|
+
const argsAssetId = getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
2331
|
+
const operationsAssetId = getSpreadsheetAssetIdFromOperations(operations);
|
|
2332
|
+
const effectiveAssetId = resultAssetId ?? argsAssetId ?? operationsAssetId;
|
|
2333
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2334
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
2335
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
2336
|
+
const totalCount = getNumberField(data, ["total"]) ?? operations.length;
|
|
2337
|
+
const succeededCount = getNumberField(data, ["succeeded", "success_count", "successCount"]) ?? (isComplete && totalCount > 0 ? Math.max(totalCount - (getNumberField(data, ["failed"]) ?? 0), 0) : null);
|
|
2338
|
+
const failedCount = getNumberField(data, [
|
|
2339
|
+
"failed",
|
|
2340
|
+
"failure_count",
|
|
2341
|
+
"failureCount"
|
|
2342
|
+
]);
|
|
2343
|
+
const rangesSummary = summarizeSheetRanges(
|
|
2344
|
+
operations.map((operation) => operation.range)
|
|
2345
|
+
);
|
|
2346
|
+
const visibleOperations = operations.slice(0, 24);
|
|
2347
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2348
|
+
const title = isRunning ? totalCount > 0 ? `Formatting ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}...` : "Formatting spreadsheet ranges..." : failedCount && failedCount > 0 ? `Formatted ${succeededCount ?? 0} of ${totalCount} sheet ranges` : totalCount > 0 ? `Formatted ${totalCount} sheet ${totalCount === 1 ? "range" : "ranges"}` : "Formatted spreadsheet ranges";
|
|
2349
|
+
return /* @__PURE__ */ jsxs(
|
|
2350
|
+
ToolCard,
|
|
2351
|
+
{
|
|
2352
|
+
icon: TablePropertiesIcon,
|
|
2353
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
2354
|
+
title: truncate(title, 80),
|
|
2355
|
+
subtitle: rangesSummary,
|
|
2356
|
+
toolName,
|
|
2357
|
+
args: typedArgs,
|
|
2358
|
+
result,
|
|
2359
|
+
badge: failedCount && failedCount > 0 ? `${failedCount} failed` : totalCount > 0 ? `${totalCount} ops` : void 0,
|
|
2360
|
+
error: errorMsg,
|
|
2361
|
+
children: [
|
|
2362
|
+
operations.length > 0 && /* @__PURE__ */ jsxs(
|
|
2363
|
+
ExpandableSection,
|
|
2364
|
+
{
|
|
2365
|
+
label: `Show formatting operations (${operations.length})`,
|
|
2366
|
+
defaultOpen: operations.length <= 6,
|
|
2367
|
+
children: [
|
|
2368
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-[11px]", children: [
|
|
2369
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b border-border/40 text-left text-muted-foreground", children: [
|
|
2370
|
+
/* @__PURE__ */ jsx("th", { className: "w-20 pb-1.5 pr-3 font-medium", children: "Range" }),
|
|
2371
|
+
/* @__PURE__ */ jsx("th", { className: "pb-1.5 pr-3 font-medium", children: "Purpose" }),
|
|
2372
|
+
/* @__PURE__ */ jsx("th", { className: "pb-1.5 font-medium", children: "Style" })
|
|
2373
|
+
] }) }),
|
|
2374
|
+
/* @__PURE__ */ jsx("tbody", { children: visibleOperations.map((operation, index) => /* @__PURE__ */ jsxs(
|
|
2375
|
+
"tr",
|
|
2376
|
+
{
|
|
2377
|
+
className: "border-t border-border/25 first:border-t-0",
|
|
2378
|
+
children: [
|
|
2379
|
+
/* @__PURE__ */ jsx("td", { className: "whitespace-nowrap py-1.5 pr-3 font-mono text-foreground/80", children: operation.range }),
|
|
2380
|
+
/* @__PURE__ */ jsx("td", { className: "max-w-[220px] py-1.5 pr-3 text-foreground/75", children: operation.explanation ? truncate(operation.explanation, 72) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "-" }) }),
|
|
2381
|
+
/* @__PURE__ */ jsx("td", { className: "max-w-[260px] py-1.5 text-muted-foreground", children: truncate(operation.styleSummary, 80) })
|
|
2382
|
+
]
|
|
2383
|
+
},
|
|
2384
|
+
`${operation.range}-${index}`
|
|
2385
|
+
)) })
|
|
2386
|
+
] }) }),
|
|
2387
|
+
operations.length > visibleOperations.length && /* @__PURE__ */ jsxs("div", { className: "pt-2 text-[10px] text-muted-foreground", children: [
|
|
2388
|
+
"Showing first ",
|
|
2389
|
+
visibleOperations.length,
|
|
2390
|
+
" of ",
|
|
2391
|
+
operations.length,
|
|
2392
|
+
" operations"
|
|
2393
|
+
] })
|
|
2394
|
+
]
|
|
2395
|
+
}
|
|
2396
|
+
),
|
|
2397
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
2398
|
+
"button",
|
|
2399
|
+
{
|
|
2400
|
+
type: "button",
|
|
2401
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
2402
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2403
|
+
children: [
|
|
2404
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2405
|
+
"Open spreadsheet"
|
|
2406
|
+
]
|
|
2407
|
+
}
|
|
2408
|
+
) })
|
|
2409
|
+
]
|
|
2410
|
+
}
|
|
2411
|
+
);
|
|
2412
|
+
};
|
|
2413
|
+
const BulkFormatSheetRangeToolUI = memo(
|
|
2414
|
+
BulkFormatSheetRangeToolUIImpl
|
|
2415
|
+
);
|
|
2416
|
+
BulkFormatSheetRangeToolUI.displayName = "BulkFormatSheetRangeToolUI";
|
|
2417
|
+
function formatDimensionUnit(unit) {
|
|
2418
|
+
if (!unit) {
|
|
2419
|
+
return "";
|
|
2420
|
+
}
|
|
2421
|
+
const normalized = unit.toLowerCase();
|
|
2422
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
2423
|
+
return "pixels";
|
|
2424
|
+
}
|
|
2425
|
+
if (normalized === "points" || normalized === "point") {
|
|
2426
|
+
return "points";
|
|
2427
|
+
}
|
|
2428
|
+
return unit;
|
|
2429
|
+
}
|
|
2430
|
+
function formatShortDimensionUnit(unit) {
|
|
2431
|
+
const normalized = unit == null ? void 0 : unit.toLowerCase();
|
|
2432
|
+
if (normalized === "pixels" || normalized === "pixel") {
|
|
2433
|
+
return "px";
|
|
2434
|
+
}
|
|
2435
|
+
if (normalized === "points" || normalized === "point") {
|
|
2436
|
+
return "pt";
|
|
2437
|
+
}
|
|
2438
|
+
return unit ?? "";
|
|
2439
|
+
}
|
|
2440
|
+
function parseDimensionMeasurement(value) {
|
|
2441
|
+
const record = asRecord(value);
|
|
2442
|
+
if (record) {
|
|
2443
|
+
const numericValue = getNumberField(record, ["value"]);
|
|
2444
|
+
const stringValue = getStringField(record, ["value"]);
|
|
2445
|
+
const rawValue = numericValue != null ? String(numericValue) : stringValue ? stringValue : null;
|
|
2446
|
+
if (!rawValue) {
|
|
2447
|
+
return null;
|
|
2448
|
+
}
|
|
2449
|
+
const unit = getStringField(record, ["type", "unit"]);
|
|
2450
|
+
const formattedUnit = formatDimensionUnit(unit);
|
|
2451
|
+
const shortUnit = formatShortDimensionUnit(unit);
|
|
2452
|
+
return {
|
|
2453
|
+
value: formattedUnit ? `${rawValue} ${formattedUnit}` : rawValue,
|
|
2454
|
+
shortValue: shortUnit ? `${rawValue} ${shortUnit}` : rawValue
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
2458
|
+
return { value: String(value), shortValue: String(value) };
|
|
2459
|
+
}
|
|
2460
|
+
if (typeof value === "string" && value.trim()) {
|
|
2461
|
+
return { value, shortValue: value };
|
|
2462
|
+
}
|
|
2463
|
+
return null;
|
|
2464
|
+
}
|
|
2465
|
+
function getSheetDimensionSummary(args) {
|
|
2466
|
+
const width = parseDimensionMeasurement(args == null ? void 0 : args.width);
|
|
2467
|
+
if (width) {
|
|
2468
|
+
return {
|
|
2469
|
+
kind: "column width",
|
|
2470
|
+
shortValue: width.shortValue,
|
|
2471
|
+
value: width.value
|
|
2472
|
+
};
|
|
2473
|
+
}
|
|
2474
|
+
const height = parseDimensionMeasurement(args == null ? void 0 : args.height);
|
|
2475
|
+
if (height) {
|
|
2476
|
+
return {
|
|
2477
|
+
kind: "row height",
|
|
2478
|
+
shortValue: height.shortValue,
|
|
2479
|
+
value: height.value
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
return {
|
|
2483
|
+
kind: "row and column dimensions",
|
|
2484
|
+
shortValue: null,
|
|
2485
|
+
value: null
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
function getToolResultText(result, data) {
|
|
2489
|
+
if (typeof result === "string" && result.trim()) {
|
|
2490
|
+
return result;
|
|
2491
|
+
}
|
|
2492
|
+
return getStringField(data, ["message", "result", "summary"]);
|
|
2493
|
+
}
|
|
2494
|
+
const SetRowColumnDimensionsToolUIImpl = ({
|
|
2495
|
+
toolName,
|
|
2496
|
+
args,
|
|
2497
|
+
result,
|
|
2498
|
+
status
|
|
2499
|
+
}) => {
|
|
2500
|
+
const typedArgs = args;
|
|
2501
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
2502
|
+
const range = getStringField(typedArgs, ["range"]) ?? "";
|
|
2503
|
+
const dimension = getSheetDimensionSummary(typedArgs);
|
|
2504
|
+
const effectiveAssetId = extractAssetId(result) ?? getSpreadsheetAssetIdFromArgs(typedArgs);
|
|
2505
|
+
const resultText = getToolResultText(result, data);
|
|
2506
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2507
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2508
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
2509
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
2510
|
+
const title = isRunning ? `Setting ${dimension.kind}...` : range ? `Set ${dimension.kind} for ${range}` : `Set ${dimension.kind}`;
|
|
2511
|
+
return /* @__PURE__ */ jsxs(
|
|
2512
|
+
ToolCard,
|
|
2513
|
+
{
|
|
2514
|
+
icon: TablePropertiesIcon,
|
|
2515
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
2516
|
+
title: truncate(title, 80),
|
|
2517
|
+
subtitle: dimension.value ? `Value: ${dimension.value}` : void 0,
|
|
2518
|
+
toolName,
|
|
2519
|
+
args: typedArgs,
|
|
2520
|
+
result,
|
|
2521
|
+
badge: dimension.shortValue ?? void 0,
|
|
2522
|
+
error: errorMsg,
|
|
2523
|
+
children: [
|
|
2524
|
+
(range || dimension.value || resultText) && isComplete && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
|
|
2525
|
+
/* @__PURE__ */ jsxs("dl", { className: "grid gap-2 text-[11px] sm:grid-cols-3", children: [
|
|
2526
|
+
range && /* @__PURE__ */ jsxs("div", { children: [
|
|
2527
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Range" }),
|
|
2528
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 font-mono text-foreground/80", children: range })
|
|
2529
|
+
] }),
|
|
2530
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2531
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Dimension" }),
|
|
2532
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.kind })
|
|
2533
|
+
] }),
|
|
2534
|
+
dimension.value && /* @__PURE__ */ jsxs("div", { children: [
|
|
2535
|
+
/* @__PURE__ */ jsx("dt", { className: "font-medium text-muted-foreground", children: "Value" }),
|
|
2536
|
+
/* @__PURE__ */ jsx("dd", { className: "mt-0.5 text-foreground/80", children: dimension.value })
|
|
2537
|
+
] })
|
|
2538
|
+
] }),
|
|
2539
|
+
resultText && /* @__PURE__ */ jsx("p", { className: "mt-2 text-[11px] leading-relaxed text-muted-foreground", children: truncate(resultText, 160) })
|
|
2540
|
+
] }),
|
|
2541
|
+
effectiveAssetId && isComplete && !errorMsg && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
2542
|
+
"button",
|
|
2543
|
+
{
|
|
2544
|
+
type: "button",
|
|
2545
|
+
onClick: () => openAsset(effectiveAssetId, { type: "spreadsheet" }),
|
|
2546
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2547
|
+
children: [
|
|
2548
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2549
|
+
"Open spreadsheet"
|
|
2550
|
+
]
|
|
2551
|
+
}
|
|
2552
|
+
) })
|
|
2553
|
+
]
|
|
2554
|
+
}
|
|
2555
|
+
);
|
|
2556
|
+
};
|
|
2557
|
+
const SetRowColumnDimensionsToolUI = memo(
|
|
2558
|
+
SetRowColumnDimensionsToolUIImpl
|
|
2559
|
+
);
|
|
2560
|
+
SetRowColumnDimensionsToolUI.displayName = "SetRowColumnDimensionsToolUI";
|
|
2561
|
+
function createAssetToolUI(config) {
|
|
2562
|
+
const Component = (props) => /* @__PURE__ */ jsx(
|
|
2563
|
+
CreateAssetToolUIImpl,
|
|
2564
|
+
{
|
|
2565
|
+
icon: config.icon,
|
|
2566
|
+
assetType: config.assetType,
|
|
2567
|
+
runningLabel: config.runningLabel,
|
|
2568
|
+
doneLabel: config.doneLabel,
|
|
2569
|
+
...props
|
|
2570
|
+
}
|
|
2571
|
+
);
|
|
2572
|
+
const Memoized = memo(Component);
|
|
2573
|
+
Memoized.displayName = `CreateAssetToolUI(${config.assetType})`;
|
|
2574
|
+
return Memoized;
|
|
2575
|
+
}
|
|
2576
|
+
const CaptureMomentToolUIImpl = ({
|
|
2577
|
+
toolName,
|
|
2578
|
+
args,
|
|
2579
|
+
result,
|
|
2580
|
+
status
|
|
2581
|
+
}) => {
|
|
2582
|
+
const typedArgs = args;
|
|
2583
|
+
const timestamp = typedArgs == null ? void 0 : typedArgs.timestamp;
|
|
2584
|
+
const startTime = typedArgs == null ? void 0 : typedArgs.start_time;
|
|
2585
|
+
const endTime = typedArgs == null ? void 0 : typedArgs.end_time;
|
|
2586
|
+
const sourceAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? "";
|
|
2587
|
+
const isClipMode = startTime != null && endTime != null;
|
|
2588
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
2589
|
+
const success = data == null ? void 0 : data.success;
|
|
2590
|
+
const createdAssetId = extractAssetId(result);
|
|
2591
|
+
const resultType = (data == null ? void 0 : data.type) ?? (isClipMode ? "video" : "image");
|
|
2592
|
+
const resultTimestamp = (data == null ? void 0 : data.timestamp) ?? timestamp;
|
|
2593
|
+
const timeRange = data == null ? void 0 : data.time_range;
|
|
2594
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : data && !success ? data.error : null;
|
|
2595
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2596
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
2597
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
2598
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2599
|
+
const handleOpen = () => {
|
|
2600
|
+
if (createdAssetId) {
|
|
2601
|
+
openAsset(createdAssetId, {
|
|
2602
|
+
name: void 0,
|
|
2603
|
+
type: "unknown"
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
};
|
|
2607
|
+
let subtitle;
|
|
2608
|
+
if (isClipMode) {
|
|
2609
|
+
const rangeLabel = timeRange ? `${timeRange.start} → ${timeRange.end}` : `${startTime} → ${endTime}`;
|
|
2610
|
+
subtitle = `Clip: ${rangeLabel}`;
|
|
2611
|
+
} else if (resultTimestamp || timestamp) {
|
|
2612
|
+
subtitle = `Screenshot at ${resultTimestamp ?? timestamp}`;
|
|
2613
|
+
}
|
|
2614
|
+
if (sourceAssetId) {
|
|
2615
|
+
subtitle = subtitle ? `${subtitle} · ${truncate(sourceAssetId, 30)}` : truncate(sourceAssetId, 40);
|
|
2616
|
+
}
|
|
2617
|
+
const Icon = isClipMode ? ScissorsIcon : CameraIcon;
|
|
2618
|
+
let title;
|
|
2619
|
+
if (isRunning) {
|
|
2620
|
+
title = isClipMode ? "Extracting video clip…" : "Capturing screenshot…";
|
|
2621
|
+
} else if (errorMsg) {
|
|
2622
|
+
title = "Capture failed";
|
|
2623
|
+
} else {
|
|
2624
|
+
title = isClipMode ? "Video clip captured" : "Screenshot captured";
|
|
2625
|
+
}
|
|
2626
|
+
return /* @__PURE__ */ jsx(
|
|
2627
|
+
ToolCard,
|
|
2628
|
+
{
|
|
2629
|
+
icon: Icon,
|
|
2630
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
2631
|
+
title,
|
|
2632
|
+
subtitle,
|
|
2633
|
+
toolName,
|
|
2634
|
+
badge: isComplete && success ? resultType : void 0,
|
|
2635
|
+
args: typedArgs,
|
|
2636
|
+
result,
|
|
2637
|
+
error: errorMsg,
|
|
2638
|
+
children: createdAssetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
|
|
2639
|
+
"button",
|
|
2640
|
+
{
|
|
2641
|
+
type: "button",
|
|
2642
|
+
onClick: handleOpen,
|
|
2643
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2644
|
+
children: [
|
|
2645
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2646
|
+
"Open ",
|
|
2647
|
+
resultType === "video" ? "clip" : "screenshot"
|
|
2648
|
+
]
|
|
2649
|
+
}
|
|
2650
|
+
) })
|
|
2651
|
+
}
|
|
2652
|
+
);
|
|
2653
|
+
};
|
|
2654
|
+
const CaptureMomentToolUI = memo(
|
|
2655
|
+
CaptureMomentToolUIImpl
|
|
2656
|
+
);
|
|
2657
|
+
CaptureMomentToolUI.displayName = "CaptureMomentToolUI";
|
|
2658
|
+
function normalizeContentResult(result) {
|
|
2659
|
+
if (Array.isArray(result)) {
|
|
2660
|
+
return result;
|
|
2661
|
+
}
|
|
2662
|
+
if (typeof result === "string") {
|
|
2663
|
+
try {
|
|
2664
|
+
const parsed = JSON.parse(result);
|
|
2665
|
+
return normalizeContentResult(parsed);
|
|
2666
|
+
} catch {
|
|
2667
|
+
return [];
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
if (result && typeof result === "object") {
|
|
2671
|
+
const obj = result;
|
|
2672
|
+
if (Array.isArray(obj.result)) {
|
|
2673
|
+
return obj.result;
|
|
2674
|
+
}
|
|
2675
|
+
if (typeof obj.result === "string") {
|
|
2676
|
+
return normalizeContentResult(obj.result);
|
|
2677
|
+
}
|
|
2678
|
+
if (Array.isArray(obj.content)) {
|
|
2679
|
+
return obj.content;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return [];
|
|
2683
|
+
}
|
|
2684
|
+
function useFreshPresignedUrl({
|
|
2685
|
+
s3Key,
|
|
2686
|
+
fallbackUrl
|
|
2687
|
+
}) {
|
|
2688
|
+
const [freshUrl, setFreshUrl] = useState(null);
|
|
2689
|
+
const config = useAthenaConfig();
|
|
2690
|
+
const configRef = useRef(config);
|
|
2691
|
+
configRef.current = config;
|
|
2692
|
+
useEffect(() => {
|
|
2693
|
+
setFreshUrl(null);
|
|
2694
|
+
if (!s3Key) return;
|
|
2695
|
+
let cancelled = false;
|
|
2696
|
+
(async () => {
|
|
2697
|
+
try {
|
|
2698
|
+
const { backendUrl, token, apiKey } = configRef.current;
|
|
2699
|
+
const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
2700
|
+
const url = `${baseUrl}/api/asset/fetch-attachment-presigned-url`;
|
|
2701
|
+
const headers = {
|
|
2702
|
+
"Content-Type": "application/json"
|
|
2703
|
+
};
|
|
2704
|
+
if (token) {
|
|
2705
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
2706
|
+
} else if (apiKey) {
|
|
2707
|
+
headers["X-API-KEY"] = apiKey;
|
|
2708
|
+
}
|
|
2709
|
+
const resp = await fetch(url, {
|
|
2710
|
+
method: "POST",
|
|
2711
|
+
headers,
|
|
2712
|
+
body: JSON.stringify({ s3_key: s3Key })
|
|
2713
|
+
});
|
|
2714
|
+
if (!cancelled && resp.ok) {
|
|
2715
|
+
const data = await resp.json();
|
|
2716
|
+
if (!cancelled && data.presigned_url) {
|
|
2717
|
+
setFreshUrl(data.presigned_url);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
} catch {
|
|
2721
|
+
}
|
|
2722
|
+
})();
|
|
2723
|
+
return () => {
|
|
2724
|
+
cancelled = true;
|
|
2725
|
+
};
|
|
2726
|
+
}, [s3Key]);
|
|
2727
|
+
return freshUrl ?? fallbackUrl;
|
|
2728
|
+
}
|
|
2729
|
+
function getSlideScreenshotResult(result) {
|
|
2730
|
+
let text = null;
|
|
2731
|
+
let imageUrl = null;
|
|
2732
|
+
let mediaType = null;
|
|
2733
|
+
let s3Key = null;
|
|
2734
|
+
for (const item of normalizeContentResult(result)) {
|
|
2735
|
+
if (!item || typeof item !== "object") {
|
|
2736
|
+
continue;
|
|
2737
|
+
}
|
|
2738
|
+
const part = item;
|
|
2739
|
+
if (!text && part.type === "text" && typeof part.text === "string") {
|
|
2740
|
+
text = part.text;
|
|
2741
|
+
continue;
|
|
2742
|
+
}
|
|
2743
|
+
if (part.type !== "image") {
|
|
2744
|
+
continue;
|
|
2745
|
+
}
|
|
2746
|
+
const source = part.source && typeof part.source === "object" ? part.source : {};
|
|
2747
|
+
if (!imageUrl) {
|
|
2748
|
+
imageUrl = getStringField(source, ["presigned_url", "url"]) ?? getStringField(part, ["url", "image_url"]);
|
|
2749
|
+
}
|
|
2750
|
+
if (!mediaType) {
|
|
2751
|
+
mediaType = getStringField(source, ["media_type", "mime_type"]) ?? getStringField(part, ["media_type", "mime_type"]);
|
|
2752
|
+
}
|
|
2753
|
+
if (!s3Key) {
|
|
2754
|
+
s3Key = getStringField(source, ["data", "s3_key"]);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
return { text, imageUrl, mediaType, s3Key };
|
|
2758
|
+
}
|
|
2759
|
+
const CaptureSlideScreenshotToolUIImpl = ({
|
|
2760
|
+
toolName,
|
|
2761
|
+
args,
|
|
2762
|
+
result,
|
|
2763
|
+
status
|
|
2764
|
+
}) => {
|
|
2765
|
+
const typedArgs = args;
|
|
2766
|
+
const assetId = getStringField(typedArgs, ["asset_id", "assetId"]);
|
|
2767
|
+
const slideNumber = getNumberField(typedArgs, ["slide_number", "slideNumber"]) ?? void 0;
|
|
2768
|
+
const { text, imageUrl, mediaType, s3Key } = useMemo(
|
|
2769
|
+
() => getSlideScreenshotResult(result),
|
|
2770
|
+
[result]
|
|
2771
|
+
);
|
|
2772
|
+
const freshImageUrl = useFreshPresignedUrl({ s3Key, fallbackUrl: imageUrl });
|
|
2773
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2774
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
2775
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
2776
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? String(status.error ?? status.reason ?? "Capture failed") : null;
|
|
2777
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2778
|
+
const handleOpenSlide = useCallback(() => {
|
|
2779
|
+
if (!assetId) {
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
openAsset(assetId, {
|
|
2783
|
+
type: "presentation",
|
|
2784
|
+
...slideNumber ? { slideNumber } : {}
|
|
2785
|
+
});
|
|
2786
|
+
}, [assetId, openAsset, slideNumber]);
|
|
2787
|
+
const subtitle = [
|
|
2788
|
+
slideNumber ? `Slide ${slideNumber}` : null,
|
|
2789
|
+
assetId ? truncate(assetId, 34) : null
|
|
2790
|
+
].filter((value) => Boolean(value)).join(" · ");
|
|
2791
|
+
return /* @__PURE__ */ jsxs(
|
|
2792
|
+
ToolCard,
|
|
2793
|
+
{
|
|
2794
|
+
icon: CameraIcon,
|
|
2795
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
2796
|
+
title: isRunning ? "Capturing slide screenshot..." : errorMsg ? "Slide screenshot failed" : "Slide screenshot captured",
|
|
2797
|
+
subtitle: subtitle || void 0,
|
|
2798
|
+
badge: slideNumber ? `Slide ${slideNumber}` : mediaType ?? void 0,
|
|
2799
|
+
toolName,
|
|
2800
|
+
args: typedArgs,
|
|
2801
|
+
result,
|
|
2802
|
+
error: errorMsg,
|
|
2803
|
+
children: [
|
|
2804
|
+
isComplete && !isCancelled && freshImageUrl && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 p-3", children: [
|
|
2805
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-lg border border-border/50 bg-muted/20", children: /* @__PURE__ */ jsx(
|
|
2806
|
+
"img",
|
|
2807
|
+
{
|
|
2808
|
+
src: freshImageUrl,
|
|
2809
|
+
alt: slideNumber ? `Slide ${slideNumber} screenshot` : "Slide screenshot",
|
|
2810
|
+
className: "aspect-video w-full object-contain",
|
|
2811
|
+
loading: "lazy"
|
|
2812
|
+
}
|
|
2813
|
+
) }),
|
|
2814
|
+
text && /* @__PURE__ */ jsx("p", { className: "mt-2 text-[11px] leading-relaxed text-muted-foreground", children: truncate(text, 160) })
|
|
2815
|
+
] }),
|
|
2816
|
+
isComplete && !isCancelled && assetId && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border/40 px-4 py-2", children: [
|
|
2817
|
+
/* @__PURE__ */ jsxs(
|
|
2818
|
+
"button",
|
|
2819
|
+
{
|
|
2820
|
+
type: "button",
|
|
2821
|
+
onClick: handleOpenSlide,
|
|
2822
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2823
|
+
children: [
|
|
2824
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2825
|
+
slideNumber ? `Open slide ${slideNumber}` : "Open presentation"
|
|
2826
|
+
]
|
|
2827
|
+
}
|
|
2828
|
+
),
|
|
2829
|
+
freshImageUrl && /* @__PURE__ */ jsxs(
|
|
2830
|
+
"a",
|
|
2831
|
+
{
|
|
2832
|
+
href: freshImageUrl,
|
|
2833
|
+
target: "_blank",
|
|
2834
|
+
rel: "noreferrer",
|
|
2835
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2836
|
+
children: [
|
|
2837
|
+
/* @__PURE__ */ jsx(ImageIcon, { className: "size-3" }),
|
|
2838
|
+
"Open image"
|
|
2839
|
+
]
|
|
2840
|
+
}
|
|
2841
|
+
)
|
|
2842
|
+
] })
|
|
2843
|
+
]
|
|
2844
|
+
}
|
|
2845
|
+
);
|
|
2846
|
+
};
|
|
2847
|
+
const CaptureSlideScreenshotToolUI = memo(
|
|
2848
|
+
CaptureSlideScreenshotToolUIImpl
|
|
2849
|
+
);
|
|
2850
|
+
CaptureSlideScreenshotToolUI.displayName = "CaptureSlideScreenshotToolUI";
|
|
2851
|
+
const OpenBrowserToolUIImpl = ({
|
|
2852
|
+
toolName,
|
|
2853
|
+
args,
|
|
2854
|
+
result,
|
|
2855
|
+
status
|
|
2856
|
+
}) => {
|
|
2857
|
+
const typedArgs = args;
|
|
2858
|
+
const url = (typedArgs == null ? void 0 : typedArgs.url) ?? "";
|
|
2859
|
+
const argsTitle = typedArgs == null ? void 0 : typedArgs.title;
|
|
2860
|
+
const data = useMemo(() => normalizeResult(result), [result]);
|
|
2861
|
+
const pageTitle = (data == null ? void 0 : data.page_title) ?? (data == null ? void 0 : data.title);
|
|
2862
|
+
const landedUrl = (data == null ? void 0 : data.landed_url) ?? url;
|
|
2863
|
+
const warning = data == null ? void 0 : data.warning;
|
|
2864
|
+
const redirectWarning = useMemo(() => {
|
|
2865
|
+
if (!url || !landedUrl) return null;
|
|
2866
|
+
try {
|
|
2867
|
+
const requested = new URL(url);
|
|
2868
|
+
const landed = new URL(landedUrl);
|
|
2869
|
+
const sameTarget = requested.origin === landed.origin && requested.pathname.replace(/\/+$/, "") === landed.pathname.replace(/\/+$/, "") && requested.search === landed.search;
|
|
2870
|
+
return sameTarget ? null : `Redirected to ${landed.href}`;
|
|
2871
|
+
} catch {
|
|
2872
|
+
return url === landedUrl ? null : `Redirected to ${landedUrl}`;
|
|
2873
|
+
}
|
|
2874
|
+
}, [url, landedUrl]);
|
|
2875
|
+
const warningText = warning ?? redirectWarning;
|
|
2876
|
+
const assetId = extractAssetId(result);
|
|
2877
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
2878
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
2879
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
2880
|
+
const displayUrl = useMemo(() => {
|
|
2881
|
+
const raw = landedUrl || url;
|
|
2882
|
+
if (!raw) return void 0;
|
|
2883
|
+
try {
|
|
2884
|
+
const parsed = new URL(raw);
|
|
2885
|
+
return parsed.hostname + (parsed.pathname !== "/" ? parsed.pathname : "");
|
|
2886
|
+
} catch {
|
|
2887
|
+
return truncate(raw, 60);
|
|
2888
|
+
}
|
|
2889
|
+
}, [landedUrl, url]);
|
|
2890
|
+
const displayTitle = useMemo(() => {
|
|
2891
|
+
if (isRunning) return "Opening browser...";
|
|
2892
|
+
if (pageTitle) return truncate(pageTitle, 50);
|
|
2893
|
+
if (argsTitle) return truncate(argsTitle, 50);
|
|
2894
|
+
return "Browser session opened";
|
|
2895
|
+
}, [isRunning, pageTitle, argsTitle]);
|
|
2896
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
2897
|
+
return /* @__PURE__ */ jsxs(
|
|
2898
|
+
ToolCard,
|
|
2899
|
+
{
|
|
2900
|
+
icon: GlobeIcon,
|
|
2901
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
2902
|
+
title: displayTitle,
|
|
2903
|
+
subtitle: displayUrl,
|
|
2904
|
+
toolName,
|
|
2905
|
+
args: typedArgs,
|
|
2906
|
+
result,
|
|
2907
|
+
error: errorMsg,
|
|
2908
|
+
children: [
|
|
2909
|
+
warningText && isComplete && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 bg-amber-50 px-4 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2910
|
+
/* @__PURE__ */ jsx(AlertTriangleIcon, { className: "mt-0.5 size-3 shrink-0 text-amber-600" }),
|
|
2911
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] leading-relaxed text-amber-700", children: warningText })
|
|
2912
|
+
] }) }),
|
|
2913
|
+
isComplete && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-t border-border/40 px-4 py-2", children: [
|
|
2914
|
+
assetId && /* @__PURE__ */ jsxs(
|
|
2915
|
+
"button",
|
|
2916
|
+
{
|
|
2917
|
+
type: "button",
|
|
2918
|
+
onClick: () => openAsset(assetId, {
|
|
2919
|
+
name: pageTitle ?? argsTitle,
|
|
2920
|
+
type: "unknown"
|
|
2921
|
+
}),
|
|
2922
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2923
|
+
children: [
|
|
2924
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "size-3" }),
|
|
2925
|
+
"Open session"
|
|
2926
|
+
]
|
|
2927
|
+
}
|
|
2928
|
+
),
|
|
2929
|
+
landedUrl && /^https?:\/\//i.test(landedUrl) && /* @__PURE__ */ jsxs(
|
|
2930
|
+
"a",
|
|
2931
|
+
{
|
|
2932
|
+
href: landedUrl,
|
|
2933
|
+
target: "_blank",
|
|
2934
|
+
rel: "noopener noreferrer",
|
|
2935
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
2936
|
+
children: [
|
|
2937
|
+
/* @__PURE__ */ jsx(GlobeIcon, { className: "size-3" }),
|
|
2938
|
+
"Visit URL"
|
|
2939
|
+
]
|
|
2940
|
+
}
|
|
2941
|
+
)
|
|
2942
|
+
] })
|
|
2943
|
+
]
|
|
2944
|
+
}
|
|
2945
|
+
);
|
|
2946
|
+
};
|
|
2947
|
+
const OpenBrowserToolUI = memo(
|
|
2948
|
+
OpenBrowserToolUIImpl
|
|
2949
|
+
);
|
|
2950
|
+
OpenBrowserToolUI.displayName = "OpenBrowserToolUI";
|
|
2951
|
+
const TOOL_UI_REGISTRY = {
|
|
2952
|
+
search: WebSearchToolUI,
|
|
2953
|
+
browse: BrowseToolUI,
|
|
2954
|
+
open_browser: OpenBrowserToolUI,
|
|
2955
|
+
search_email: EmailSearchToolUI,
|
|
2956
|
+
unified_email_search: EmailSearchToolUI,
|
|
2957
|
+
unified_email_list_accounts: EmailAccountsToolUI,
|
|
2958
|
+
email_list_accounts: EmailAccountsToolUI,
|
|
2959
|
+
create_email_draft: CreateEmailDraftToolUI,
|
|
2960
|
+
unified_email_create_draft: CreateEmailDraftToolUI,
|
|
2961
|
+
create_new_document: CreateDocumentToolUI,
|
|
2962
|
+
create_document_from_markdown: CreateDocumentToolUI,
|
|
2963
|
+
create_new_sheet: CreateSheetToolUI,
|
|
2964
|
+
create_powerpoint_deck: CreatePresentationToolUI,
|
|
2965
|
+
create_presentation_pptx_studio: CreatePresentationToolUI,
|
|
2966
|
+
create_new_notebook: CreateNotebookToolUI,
|
|
2967
|
+
// Studio SDK nested PTC tools
|
|
2968
|
+
CreateWorkbook: StudioCreateWorkbookToolUI,
|
|
2969
|
+
AddSheet: StudioAddSheetToolUI,
|
|
2970
|
+
OpenWorkbook: StudioOpenWorkbookToolUI,
|
|
2971
|
+
CreatePresentation: StudioCreatePresentationToolUI,
|
|
2972
|
+
OpenPresentation: StudioOpenPresentationToolUI,
|
|
2973
|
+
AddSlide: StudioAddSlideToolUI,
|
|
2974
|
+
CreateDocument: StudioCreateDocumentToolUI,
|
|
2975
|
+
OpenDocument: StudioOpenDocumentToolUI,
|
|
2976
|
+
CreateParagraph: StudioCreateParagraphToolUI,
|
|
2977
|
+
execute_presentation_code: ExecutePresentationCodeToolUI,
|
|
2978
|
+
run_python_code: RunPythonCodeToolUI,
|
|
2979
|
+
open_asset_in_workspace: OpenAssetToolUI,
|
|
2980
|
+
// Media capture
|
|
2981
|
+
capture_moment: CaptureMomentToolUI,
|
|
2982
|
+
capture_slide_screenshot: CaptureSlideScreenshotToolUI,
|
|
2983
|
+
// Spreadsheet toolkit
|
|
2984
|
+
bulk_format_sheet_range: BulkFormatSheetRangeToolUI,
|
|
2985
|
+
set_row_column_dimensions: SetRowColumnDimensionsToolUI,
|
|
2986
|
+
update_sheet_range: UpdateSheetRangeToolUI,
|
|
2987
|
+
// Database toolkit
|
|
2988
|
+
describe_database: DescribeDatabaseToolUI,
|
|
2989
|
+
list_database_tables: ListDatabaseTablesToolUI,
|
|
2990
|
+
get_database_table_schema: GetDatabaseTableSchemaToolUI,
|
|
2991
|
+
run_sql: RunSqlToolUI,
|
|
2992
|
+
run_database_sql: RunSqlToolUI,
|
|
2993
|
+
run_sql_query_tool: RunSqlToolUI,
|
|
2994
|
+
install_pip_package: InstallPackageToolUI,
|
|
2995
|
+
write_todos: WriteTodosToolUI,
|
|
2996
|
+
// Deep-agent workspace-file tools — quiet plain-English cards; the generic
|
|
2997
|
+
// fallback dumped raw scratch-space JSON (see file-tool-uis.tsx).
|
|
2998
|
+
read_file: ReadFileToolUI,
|
|
2999
|
+
ls: ListFilesToolUI,
|
|
3000
|
+
write_file: WriteFileToolUI,
|
|
3001
|
+
edit_file: EditFileToolUI,
|
|
3002
|
+
glob: SearchFilesToolUI,
|
|
3003
|
+
grep: SearchFilesToolUI
|
|
3004
|
+
};
|
|
3005
|
+
export {
|
|
3006
|
+
BrowseToolUI,
|
|
3007
|
+
BulkFormatSheetRangeToolUI,
|
|
3008
|
+
CaptureMomentToolUI,
|
|
3009
|
+
CaptureSlideScreenshotToolUI,
|
|
3010
|
+
CreateDocumentToolUI,
|
|
3011
|
+
CreateEmailDraftToolUI,
|
|
3012
|
+
CreateNotebookToolUI,
|
|
3013
|
+
CreatePresentationToolUI,
|
|
3014
|
+
CreateSheetToolUI,
|
|
3015
|
+
DescribeDatabaseToolUI,
|
|
3016
|
+
EmailAccountsToolUI,
|
|
3017
|
+
EmailSearchToolUI,
|
|
3018
|
+
ExecutePresentationCodeToolUI,
|
|
3019
|
+
ExpandableSection,
|
|
3020
|
+
GetDatabaseTableSchemaToolUI,
|
|
3021
|
+
ListDatabaseTablesToolUI,
|
|
3022
|
+
OpenAssetToolUI,
|
|
3023
|
+
OpenBrowserToolUI,
|
|
3024
|
+
RunPythonCodeToolUI,
|
|
3025
|
+
RunSqlToolUI,
|
|
3026
|
+
SetRowColumnDimensionsToolUI,
|
|
3027
|
+
StudioAddSheetToolUI,
|
|
3028
|
+
StudioAddSlideToolUI,
|
|
3029
|
+
StudioCreateDocumentToolUI,
|
|
3030
|
+
StudioCreateParagraphToolUI,
|
|
3031
|
+
StudioCreatePresentationToolUI,
|
|
3032
|
+
StudioCreateWorkbookToolUI,
|
|
3033
|
+
StudioOpenDocumentToolUI,
|
|
3034
|
+
StudioOpenPresentationToolUI,
|
|
3035
|
+
StudioOpenWorkbookToolUI,
|
|
3036
|
+
TOOL_UI_REGISTRY,
|
|
3037
|
+
ToolCard,
|
|
3038
|
+
UpdateSheetRangeToolUI,
|
|
3039
|
+
WebSearchToolUI,
|
|
3040
|
+
buildSheetUpdateFailureMessage,
|
|
3041
|
+
createAssetToolUI,
|
|
3042
|
+
formatEmailDate,
|
|
3043
|
+
humanizeEmailQuery,
|
|
3044
|
+
normalizeResult,
|
|
3045
|
+
parseEmailAccounts,
|
|
3046
|
+
resetAssetAutoOpen,
|
|
3047
|
+
truncate
|
|
3048
|
+
};
|
|
3049
|
+
//# sourceMappingURL=tool-uis.js.map
|