@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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const CONVERSATION_LIST_QUERY_KEY_ROOT = "athena-conversation-list";
|
|
4
|
+
const CONVERSATION_LIST_DEFAULT_SCOPE_KEY = "default";
|
|
5
|
+
function normalizeConversationListFilter(filter) {
|
|
6
|
+
const normalized = {};
|
|
7
|
+
if (filter.appId) normalized.appId = filter.appId;
|
|
8
|
+
if (filter.assetTypes && filter.assetTypes.length > 0) {
|
|
9
|
+
normalized.assetTypes = [...filter.assetTypes].sort();
|
|
10
|
+
}
|
|
11
|
+
if (filter.search) normalized.search = filter.search;
|
|
12
|
+
if (filter.excludeTriggered !== void 0) normalized.excludeTriggered = filter.excludeTriggered;
|
|
13
|
+
if (filter.sourceChannels && filter.sourceChannels.length > 0) {
|
|
14
|
+
normalized.sourceChannels = [...filter.sourceChannels].sort();
|
|
15
|
+
}
|
|
16
|
+
if (filter.excludeSourceChannels && filter.excludeSourceChannels.length > 0) {
|
|
17
|
+
normalized.excludeSourceChannels = [...filter.excludeSourceChannels].sort();
|
|
18
|
+
}
|
|
19
|
+
if (filter.computerAssetId) normalized.computerAssetId = filter.computerAssetId;
|
|
20
|
+
if (filter.states && filter.states.length > 0) {
|
|
21
|
+
normalized.states = [...filter.states].sort();
|
|
22
|
+
}
|
|
23
|
+
if (filter.agentIds && filter.agentIds.length > 0) {
|
|
24
|
+
normalized.agentIds = [...filter.agentIds].sort();
|
|
25
|
+
}
|
|
26
|
+
if (filter.includeSubSessions) normalized.includeSubSessions = true;
|
|
27
|
+
return normalized;
|
|
28
|
+
}
|
|
29
|
+
function conversationListFilterKey(filter) {
|
|
30
|
+
const normalized = normalizeConversationListFilter(filter);
|
|
31
|
+
return JSON.stringify(
|
|
32
|
+
Object.keys(normalized).sort().map((key) => [key, normalized[key]])
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const conversationListQueryKeys = {
|
|
36
|
+
root: [CONVERSATION_LIST_QUERY_KEY_ROOT],
|
|
37
|
+
scope: (scopeKey) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey],
|
|
38
|
+
firstPage: (scopeKey, filterKey, pageSize) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, "first-page"],
|
|
39
|
+
history: (scopeKey, filterKey, pageSize) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, "history"]
|
|
40
|
+
};
|
|
41
|
+
function mergeConversationPages(pages) {
|
|
42
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43
|
+
const items = [];
|
|
44
|
+
for (const page of pages) {
|
|
45
|
+
for (const item of page.items) {
|
|
46
|
+
if (seen.has(item.threadId)) continue;
|
|
47
|
+
seen.add(item.threadId);
|
|
48
|
+
items.push(item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return items;
|
|
52
|
+
}
|
|
53
|
+
function prependConversationToPage(page, item) {
|
|
54
|
+
if (page.items.some((existing) => existing.threadId === item.threadId)) return page;
|
|
55
|
+
return {
|
|
56
|
+
...page,
|
|
57
|
+
items: [item, ...page.items],
|
|
58
|
+
totalCount: page.totalCount === null ? null : page.totalCount + 1
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function removeConversationFromPage(page, threadId) {
|
|
62
|
+
if (!page.items.some((item) => item.threadId === threadId)) return page;
|
|
63
|
+
return { ...page, items: page.items.filter((item) => item.threadId !== threadId) };
|
|
64
|
+
}
|
|
65
|
+
function patchConversationsInPage(page, match, patch) {
|
|
66
|
+
let changed = false;
|
|
67
|
+
const items = page.items.map((item) => {
|
|
68
|
+
if (!match(item)) return item;
|
|
69
|
+
changed = true;
|
|
70
|
+
return { ...item, ...patch };
|
|
71
|
+
});
|
|
72
|
+
return changed ? { ...page, items } : page;
|
|
73
|
+
}
|
|
74
|
+
function scopedKey(options) {
|
|
75
|
+
return (options == null ? void 0 : options.scopeKey) !== void 0 ? conversationListQueryKeys.scope(options.scopeKey) : conversationListQueryKeys.root;
|
|
76
|
+
}
|
|
77
|
+
function invalidateConversationListCaches(queryClient, options) {
|
|
78
|
+
return queryClient.invalidateQueries({ queryKey: scopedKey(options) });
|
|
79
|
+
}
|
|
80
|
+
exports.CONVERSATION_LIST_DEFAULT_SCOPE_KEY = CONVERSATION_LIST_DEFAULT_SCOPE_KEY;
|
|
81
|
+
exports.CONVERSATION_LIST_QUERY_KEY_ROOT = CONVERSATION_LIST_QUERY_KEY_ROOT;
|
|
82
|
+
exports.conversationListFilterKey = conversationListFilterKey;
|
|
83
|
+
exports.conversationListQueryKeys = conversationListQueryKeys;
|
|
84
|
+
exports.invalidateConversationListCaches = invalidateConversationListCaches;
|
|
85
|
+
exports.mergeConversationPages = mergeConversationPages;
|
|
86
|
+
exports.normalizeConversationListFilter = normalizeConversationListFilter;
|
|
87
|
+
exports.patchConversationsInPage = patchConversationsInPage;
|
|
88
|
+
exports.prependConversationToPage = prependConversationToPage;
|
|
89
|
+
exports.removeConversationFromPage = removeConversationFromPage;
|
|
90
|
+
//# sourceMappingURL=conversation-list.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-list.cjs","sources":["../../../../../agent-runtime/src/conversation-list.ts"],"sourcesContent":["import type { InfiniteData, QueryClient } from '@tanstack/react-query';\nimport type { ConversationIndexEntry } from './conversation-index';\n\n/**\n * Shared conversation/thread LIST contract (chat-stack unification —\n * thread-list-contract-convergence).\n *\n * Every chat surface lists \"my conversations\" against the same underlying\n * session assets, but historically each declared its own row shape, paging\n * model, and filter set (Olympus GraphQL `listConversations`, the SDK/Chrome\n * REST `/api/conversations/threads/list`, mobile's `/api/v0/sessions`). This\n * module is the ONE contract those surfaces converge on:\n *\n * - **Row shape**: {@link ConversationSummary} — the canonical camelCase\n * superset. Fields a transport cannot supply are `null`, never invented.\n * - **Ordering**: newest first by `updatedAt`, always. Ordering is part of the\n * contract, not a parameter — no surface sorts any other way.\n * - **Paging**: offset/limit with a LIVE newest page and explicitly-fetched\n * frozen history pages (see `useConversationList`). `hasMore` continues the\n * scan; `totalCount` is advisory and may be `null` for transports that do\n * not count.\n * - **Filtering**: {@link ConversationListFilter}. `appId` follows\n * `docs/SESSION_APP_ID_GUIDE.md`: exact match when set (legacy `null`\n * sessions excluded), no filter when unset. A fetcher that cannot express a\n * requested filter field MUST throw rather than silently ignore it — a\n * dropped filter returns wrong rows under a cache key that claims otherwise.\n * - **Freshness**: the per-user conversation-index statewire\n * (`conversation-index.ts`) is the push signal; these queries are the data\n * source. Push handlers call {@link invalidateConversationListCaches}.\n */\nexport interface ConversationSummary {\n /** LangGraph thread id — the cross-surface conversation identity. */\n threadId: string;\n title: string;\n /** ISO 8601 timestamp of last update (the contract's sort key). */\n updatedAt: string;\n /** ISO 8601 creation timestamp, when the transport reports it. */\n createdAt: string | null;\n /** Session lifecycle state from athena_metadata (e.g. running, completed). */\n state: string | null;\n /** Agent runtime marker (e.g. 'athena_deep_agent'), when reported. */\n runtime: string | null;\n /** Channel the session was started from (e.g. agent_email, web). */\n sourceChannel: string | null;\n /** Asset type (session, video_session, desktop_session, mobile_session). */\n assetType: string | null;\n /** Session asset id (`asset_<uuid>`), when the transport reports it. */\n assetId: string | null;\n /** Client app that created the session (SESSION_APP_ID_GUIDE). */\n appId: string | null;\n /** Computer asset whose sandbox started the session (`sourceChannel` 'computer'); omitted by surfaces that don't carry it. */\n computerAssetId?: string | null;\n /** Trigger marker (`manual` remains user-initiated; other values are automated). */\n triggerType: string | null;\n /** Last-message preview used when a legacy session has no useful title. */\n preview: string | null;\n messageCount: number | null;\n /** Per-user unread flag derived server-side from the read receipt. */\n isUnread: boolean;\n /**\n * Canonical session status (status_v2: idle | active | needs_input | error),\n * or null when the transport does not report it.\n */\n sessionStatus: string | null;\n /**\n * Canonical status of the session's current run (status_v2: scheduled |\n * queued | running | needs_input | completed | failed | canceled). Null when\n * the transport does not report it — {@link isConversationRunning} then\n * falls back to the legacy `state`. Running badges on every surface derive\n * from this one helper so they cannot disagree.\n */\n runStatus: string | null;\n}\n\n/**\n * The canonical filter set. Semantics are defined here once; each fetcher\n * translates the fields its transport supports and throws on the rest.\n */\nexport interface ConversationListFilter {\n /** Exact-match client app filter; unset = all apps (SESSION_APP_ID_GUIDE). */\n appId?: string;\n /** Asset types to include (e.g. ['session']); unset = all session types. */\n assetTypes?: readonly string[];\n /** Case-insensitive title search. */\n search?: string;\n /** Hide triggered/background sessions (REST thread list only today). */\n excludeTriggered?: boolean;\n /** Start-channel filter (v0 sessions / REST thread list only today). */\n sourceChannels?: readonly string[];\n /** Start channels to hide (e.g. ['api']); GraphQL `listConversations` only today. */\n excludeSourceChannels?: readonly string[];\n /** Exact computer asset whose sandbox started the session; GraphQL `listConversations` only today. */\n computerAssetId?: string;\n /**\n * Lifecycle-state filter (e.g. ['running'], ['completed']). Transports match\n * it with the shared status_v2 rule (running carries a 12-hour recency cutoff).\n */\n states?: readonly string[];\n /** Restrict to sessions run by any of these agents (athena_metadata.agent). */\n agentIds?: readonly string[];\n /**\n * Include branched sub-sessions and orchestration children, which every list\n * hides by default because they belong under their parent thread.\n */\n includeSubSessions?: boolean;\n}\n\nexport interface ConversationListPage {\n /** Rows in contract order (updatedAt desc). */\n items: ConversationSummary[];\n /** Whether another `offset + limit` scan would return more rows. */\n hasMore: boolean;\n /** Total matching rows, or null when the transport does not count. */\n totalCount: number | null;\n}\n\nexport interface ConversationListFetchParams {\n limit: number;\n offset: number;\n filter: ConversationListFilter;\n signal?: AbortSignal;\n}\n\n/**\n * One page fetch against some transport (GraphQL `listConversations`, the\n * REST thread list, …). Must reject on filter fields it cannot express.\n */\nexport type ConversationListFetcher = (\n params: ConversationListFetchParams\n) => Promise<ConversationListPage>;\n\n/** Root of every conversation-list query key (all surfaces, all filters). */\nexport const CONVERSATION_LIST_QUERY_KEY_ROOT = 'athena-conversation-list';\n\n/**\n * Scope used by `useConversationList` when the caller passes no `scopeKey`.\n * Exported so cache seeders (e.g. Olympus's spacesBootstrap adoption) can\n * address the exact keys default-scoped hooks read from.\n */\nexport const CONVERSATION_LIST_DEFAULT_SCOPE_KEY = 'default';\n\n/**\n * Normalize a filter to its semantic content: unset/empty fields are dropped\n * (so `{}` and `{ appId: undefined }` are the same filter) and array order is\n * canonicalized. Fetchers receive the normalized form, so what a cache entry\n * claims to hold is exactly what was fetched.\n */\nexport function normalizeConversationListFilter(\n filter: ConversationListFilter\n): ConversationListFilter {\n const normalized: ConversationListFilter = {};\n if (filter.appId) normalized.appId = filter.appId;\n if (filter.assetTypes && filter.assetTypes.length > 0) {\n normalized.assetTypes = [...filter.assetTypes].sort();\n }\n if (filter.search) normalized.search = filter.search;\n if (filter.excludeTriggered !== undefined) normalized.excludeTriggered = filter.excludeTriggered;\n if (filter.sourceChannels && filter.sourceChannels.length > 0) {\n normalized.sourceChannels = [...filter.sourceChannels].sort();\n }\n if (filter.excludeSourceChannels && filter.excludeSourceChannels.length > 0) {\n normalized.excludeSourceChannels = [...filter.excludeSourceChannels].sort();\n }\n if (filter.computerAssetId) normalized.computerAssetId = filter.computerAssetId;\n if (filter.states && filter.states.length > 0) {\n normalized.states = [...filter.states].sort();\n }\n if (filter.agentIds && filter.agentIds.length > 0) {\n normalized.agentIds = [...filter.agentIds].sort();\n }\n if (filter.includeSubSessions) normalized.includeSubSessions = true;\n return normalized;\n}\n\n/** status_v2 run statuses during which a session is actively working. */\nconst RUNNING_RUN_STATUSES: ReadonlySet<string> = new Set(['queued', 'running']);\n\n/**\n * THE running rule for every conversation-list surface (sidebar pane, recent\n * dropdown, workspace section, pushed index rows): the canonical status_v2 run\n * status when the transport reports one, else the legacy `state`. A session\n * paused on a human gate (`needs_input`) is not running.\n */\nexport function isConversationRunning(summary: {\n runStatus?: string | null;\n state?: string | null;\n}): boolean {\n if (summary.runStatus !== null && summary.runStatus !== undefined) {\n return RUNNING_RUN_STATUSES.has(summary.runStatus);\n }\n return summary.state === 'running';\n}\n\n/**\n * Stable cache identity for a filter: the normalized fields serialized in\n * sorted key order, so semantically equal filters share one cache entry.\n */\nexport function conversationListFilterKey(filter: ConversationListFilter): string {\n const normalized = normalizeConversationListFilter(filter) as Record<string, unknown>;\n return JSON.stringify(\n Object.keys(normalized)\n .sort()\n .map((key) => [key, normalized[key]])\n );\n}\n\n/**\n * Query keys for the two-tier pager. `scopeKey` isolates caches beyond the\n * filter — surfaces MUST include everything that changes whose list this is\n * (principal/user id, backend base URL) so a credential swap can never read\n * another identity's rows out of the cache.\n *\n * `pageSize` is part of the key because it is baked into every cached page's\n * offset boundaries: two hooks sharing a scope and filter but paging by\n * different sizes would otherwise reuse each other's incompatible boundaries\n * and skip or duplicate rows.\n */\nexport const conversationListQueryKeys = {\n root: [CONVERSATION_LIST_QUERY_KEY_ROOT] as const,\n scope: (scopeKey: string) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey] as const,\n firstPage: (scopeKey: string, filterKey: string, pageSize: number) =>\n [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, 'first-page'] as const,\n history: (scopeKey: string, filterKey: string, pageSize: number) =>\n [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, 'history'] as const,\n};\n\n/**\n * Flatten pages into one newest-first list, deduplicating by `threadId`.\n * The live first page wins over retained history copies of the same thread.\n */\nexport function mergeConversationPages(\n pages: readonly ConversationListPage[]\n): ConversationSummary[] {\n const seen = new Set<string>();\n const items: ConversationSummary[] = [];\n for (const page of pages) {\n for (const item of page.items) {\n if (seen.has(item.threadId)) continue;\n seen.add(item.threadId);\n items.push(item);\n }\n }\n return items;\n}\n\n/**\n * Prepend a conversation to a page unless its thread is already present\n * (optimistic \"new thread appears at the top\" write). Identity-preserving\n * no-op when present, so equal writes never notify subscribers.\n */\nexport function prependConversationToPage(\n page: ConversationListPage,\n item: ConversationSummary\n): ConversationListPage {\n if (page.items.some((existing) => existing.threadId === item.threadId)) return page;\n return {\n ...page,\n items: [item, ...page.items],\n totalCount: page.totalCount === null ? null : page.totalCount + 1,\n };\n}\n\n/** Remove a thread's row from a page; identity-preserving when absent. */\nexport function removeConversationFromPage(\n page: ConversationListPage,\n threadId: string\n): ConversationListPage {\n if (!page.items.some((item) => item.threadId === threadId)) return page;\n return { ...page, items: page.items.filter((item) => item.threadId !== threadId) };\n}\n\n/**\n * Patch every row matching `match`; identity-preserving when nothing matches\n * so cache writes cannot cause spurious re-renders.\n */\nexport function patchConversationsInPage(\n page: ConversationListPage,\n match: (item: ConversationSummary) => boolean,\n patch: Partial<ConversationSummary>\n): ConversationListPage {\n let changed = false;\n const items = page.items.map((item) => {\n if (!match(item)) return item;\n changed = true;\n return { ...item, ...patch };\n });\n return changed ? { ...page, items } : page;\n}\n\ntype CachedConversationList =\n | ConversationListPage\n | InfiniteData<ConversationListPage, number>\n | undefined;\n\nfunction isInfinitePages(\n data: ConversationListPage | InfiniteData<ConversationListPage, number>\n): data is InfiniteData<ConversationListPage, number> {\n return 'pages' in data;\n}\n\nfunction mapCachedPages(\n data: CachedConversationList,\n transform: (page: ConversationListPage) => ConversationListPage\n): CachedConversationList {\n if (!data) return data;\n if (isInfinitePages(data)) {\n let changed = false;\n const pages = data.pages.map((page) => {\n const next = transform(page);\n if (next !== page) changed = true;\n return next;\n });\n return changed ? { ...data, pages } : data;\n }\n return transform(data);\n}\n\ninterface ConversationListCacheScope {\n /** Restrict to one scope; omitted = every conversation-list cache. */\n scopeKey?: string;\n}\n\nfunction scopedKey(options?: ConversationListCacheScope): readonly string[] {\n return options?.scopeKey !== undefined\n ? conversationListQueryKeys.scope(options.scopeKey)\n : conversationListQueryKeys.root;\n}\n\n/**\n * Invalidate conversation-list caches (all filters, first page + history).\n * This is the hook for push signals — the conversation-index statewire, a\n * finished run, an archive/restore — anything that changed the server list.\n */\nexport function invalidateConversationListCaches(\n queryClient: QueryClient,\n options?: ConversationListCacheScope\n): Promise<void> {\n return queryClient.invalidateQueries({ queryKey: scopedKey(options) });\n}\n\n/** Cancel in-flight list fetches so an optimistic write cannot be overwritten. */\nexport function cancelConversationListCaches(\n queryClient: QueryClient,\n options?: ConversationListCacheScope\n): Promise<void> {\n return queryClient.cancelQueries({ queryKey: scopedKey(options) });\n}\n\n/**\n * Patch matching rows in every cached conversation list (first pages, history\n * pages, searches) so per-row state (read receipts, titles) flips in the same\n * frame as the interaction instead of after the next refetch.\n */\nexport function patchConversationListCaches(\n queryClient: QueryClient,\n options: ConversationListCacheScope & {\n match: (item: ConversationSummary) => boolean;\n patch: Partial<ConversationSummary>;\n }\n): void {\n queryClient.setQueriesData<CachedConversationList>({ queryKey: scopedKey(options) }, (data) =>\n mapCachedPages(data, (page) => patchConversationsInPage(page, options.match, options.patch))\n );\n}\n\n/** Remove a thread's row from every cached conversation list in scope. */\nexport function removeConversationFromListCaches(\n queryClient: QueryClient,\n options: ConversationListCacheScope & { threadId: string }\n): void {\n queryClient.setQueriesData<CachedConversationList>({ queryKey: scopedKey(options) }, (data) =>\n mapCachedPages(data, (page) => removeConversationFromPage(page, options.threadId))\n );\n}\n\nfunction timestampMs(value: string): number {\n const parsed = Date.parse(value);\n return Number.isNaN(parsed) ? 0 : parsed;\n}\n\nfunction sameSummary(a: ConversationSummary, b: ConversationSummary): boolean {\n return (\n a.threadId === b.threadId &&\n a.title === b.title &&\n a.updatedAt === b.updatedAt &&\n a.createdAt === b.createdAt &&\n a.state === b.state &&\n a.runtime === b.runtime &&\n a.sourceChannel === b.sourceChannel &&\n a.assetType === b.assetType &&\n a.assetId === b.assetId &&\n a.appId === b.appId &&\n a.triggerType === b.triggerType &&\n a.preview === b.preview &&\n a.messageCount === b.messageCount &&\n a.isUnread === b.isUnread &&\n a.sessionStatus === b.sessionStatus &&\n a.runStatus === b.runStatus\n );\n}\n\n/**\n * Project one replicated conversation-index row onto the shared summary shape.\n * Fields the index never carries (`createdAt`) and viewer-specific fields a\n * lifecycle publish cannot know (`is_unread: null`) keep the row's previous\n * value. Canonical status is taken from the entry when the publishing pod\n * reports it; a snapshot from a pod that predates the fields falls back to the\n * legacy `state` (null status) rather than keeping a stale run status.\n */\nexport function summaryFromConversationIndexEntry(\n entry: ConversationIndexEntry,\n previous?: ConversationSummary\n): ConversationSummary {\n const carriesStatus = entry.run_status !== undefined || entry.session_status !== undefined;\n return {\n threadId: entry.thread_id,\n title: entry.title,\n updatedAt: entry.updated_at,\n createdAt: previous?.createdAt ?? null,\n state: entry.state,\n runtime: entry.runtime,\n sourceChannel: entry.start_channel,\n assetType: entry.asset_type,\n assetId: entry.asset_id ?? previous?.assetId ?? null,\n computerAssetId: previous?.computerAssetId ?? null,\n appId: entry.app_id,\n triggerType: entry.trigger_type,\n preview: entry.last_message_preview,\n messageCount: entry.message_count,\n isUnread: entry.is_unread ?? previous?.isUnread ?? false,\n sessionStatus: carriesStatus ? (entry.session_status ?? null) : null,\n runStatus: carriesStatus ? (entry.run_status ?? null) : null,\n };\n}\n\n/**\n * Fold the user's replicated conversation index (the newest-page window the\n * per-user statewire pushes) into a cached live first page, so a thread\n * created, renamed, finished, or read anywhere updates every list surface in\n * the same frame — without refetching the page.\n *\n * - Rows in the window are upserted (new threads appear, existing rows take\n * the pushed fields, see {@link summaryFromConversationIndexEntry}).\n * - Rows NOT in the window but at least as new as the window's oldest row\n * should have been in it, so they left the list (archived, hidden, shared\n * away) and are dropped. Older rows are beyond the window and are kept.\n * - When the index reports no further rows (`indexHasMore === false`) the\n * window IS the whole list, so every row outside it is dropped.\n *\n * Newest-first ordering is restored and the page identity is preserved when\n * nothing changed, so an equal push never notifies subscribers.\n */\nexport function mergeConversationIndexIntoPage(\n page: ConversationListPage,\n entries: readonly ConversationIndexEntry[],\n options: { indexHasMore: boolean }\n): ConversationListPage {\n const previousByThread = new Map(page.items.map((item) => [item.threadId, item]));\n const inWindow = new Set(entries.map((entry) => entry.thread_id));\n const windowTailMs =\n entries.length > 0 ? Math.min(...entries.map((entry) => timestampMs(entry.updated_at))) : null;\n\n const merged: ConversationSummary[] = entries.map((entry) => {\n const previous = previousByThread.get(entry.thread_id);\n const next = summaryFromConversationIndexEntry(entry, previous);\n return previous && sameSummary(previous, next) ? previous : next;\n });\n\n for (const item of page.items) {\n if (inWindow.has(item.threadId)) continue;\n if (!options.indexHasMore) continue;\n if (windowTailMs !== null && timestampMs(item.updatedAt) >= windowTailMs) continue;\n merged.push(item);\n }\n\n merged.sort((a, b) => timestampMs(b.updatedAt) - timestampMs(a.updatedAt));\n\n const unchanged =\n merged.length === page.items.length &&\n merged.every((item, index) => item === page.items[index]);\n if (unchanged) return page;\n\n return { ...page, items: merged };\n}\n"],"names":[],"mappings":";;AAoIO,MAAM,mCAAmC;AAOzC,MAAM,sCAAsC;AAQ5C,SAAS,gCACd,QACwB;AACxB,QAAM,aAAqC,CAAA;AAC3C,MAAI,OAAO,MAAO,YAAW,QAAQ,OAAO;AAC5C,MAAI,OAAO,cAAc,OAAO,WAAW,SAAS,GAAG;AACrD,eAAW,aAAa,CAAC,GAAG,OAAO,UAAU,EAAE,KAAA;AAAA,EACjD;AACA,MAAI,OAAO,OAAQ,YAAW,SAAS,OAAO;AAC9C,MAAI,OAAO,qBAAqB,OAAW,YAAW,mBAAmB,OAAO;AAChF,MAAI,OAAO,kBAAkB,OAAO,eAAe,SAAS,GAAG;AAC7D,eAAW,iBAAiB,CAAC,GAAG,OAAO,cAAc,EAAE,KAAA;AAAA,EACzD;AACA,MAAI,OAAO,yBAAyB,OAAO,sBAAsB,SAAS,GAAG;AAC3E,eAAW,wBAAwB,CAAC,GAAG,OAAO,qBAAqB,EAAE,KAAA;AAAA,EACvE;AACA,MAAI,OAAO,gBAAiB,YAAW,kBAAkB,OAAO;AAChE,MAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAAG;AAC7C,eAAW,SAAS,CAAC,GAAG,OAAO,MAAM,EAAE,KAAA;AAAA,EACzC;AACA,MAAI,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AACjD,eAAW,WAAW,CAAC,GAAG,OAAO,QAAQ,EAAE,KAAA;AAAA,EAC7C;AACA,MAAI,OAAO,mBAAoB,YAAW,qBAAqB;AAC/D,SAAO;AACT;AAyBO,SAAS,0BAA0B,QAAwC;AAChF,QAAM,aAAa,gCAAgC,MAAM;AACzD,SAAO,KAAK;AAAA,IACV,OAAO,KAAK,UAAU,EACnB,OACA,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC;AAAA,EAAA;AAE1C;AAaO,MAAM,4BAA4B;AAAA,EACvC,MAAM,CAAC,gCAAgC;AAAA,EACvC,OAAO,CAAC,aAAqB,CAAC,kCAAkC,QAAQ;AAAA,EACxE,WAAW,CAAC,UAAkB,WAAmB,aAC/C,CAAC,kCAAkC,UAAU,WAAW,UAAU,YAAY;AAAA,EAChF,SAAS,CAAC,UAAkB,WAAmB,aAC7C,CAAC,kCAAkC,UAAU,WAAW,UAAU,SAAS;AAC/E;AAMO,SAAS,uBACd,OACuB;AACvB,QAAM,2BAAW,IAAA;AACjB,QAAM,QAA+B,CAAA;AACrC,aAAW,QAAQ,OAAO;AACxB,eAAW,QAAQ,KAAK,OAAO;AAC7B,UAAI,KAAK,IAAI,KAAK,QAAQ,EAAG;AAC7B,WAAK,IAAI,KAAK,QAAQ;AACtB,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,0BACd,MACA,MACsB;AACtB,MAAI,KAAK,MAAM,KAAK,CAAC,aAAa,SAAS,aAAa,KAAK,QAAQ,EAAG,QAAO;AAC/E,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,CAAC,MAAM,GAAG,KAAK,KAAK;AAAA,IAC3B,YAAY,KAAK,eAAe,OAAO,OAAO,KAAK,aAAa;AAAA,EAAA;AAEpE;AAGO,SAAS,2BACd,MACA,UACsB;AACtB,MAAI,CAAC,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,aAAa,QAAQ,EAAG,QAAO;AACnE,SAAO,EAAE,GAAG,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,KAAK,aAAa,QAAQ,EAAA;AACjF;AAMO,SAAS,yBACd,MACA,OACA,OACsB;AACtB,MAAI,UAAU;AACd,QAAM,QAAQ,KAAK,MAAM,IAAI,CAAC,SAAS;AACrC,QAAI,CAAC,MAAM,IAAI,EAAG,QAAO;AACzB,cAAU;AACV,WAAO,EAAE,GAAG,MAAM,GAAG,MAAA;AAAA,EACvB,CAAC;AACD,SAAO,UAAU,EAAE,GAAG,MAAM,UAAU;AACxC;AAmCA,SAAS,UAAU,SAAyD;AAC1E,UAAO,mCAAS,cAAa,SACzB,0BAA0B,MAAM,QAAQ,QAAQ,IAChD,0BAA0B;AAChC;AAOO,SAAS,iCACd,aACA,SACe;AACf,SAAO,YAAY,kBAAkB,EAAE,UAAU,UAAU,OAAO,GAAG;AACvE;;;;;;;;;;;"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const CONVERSATION_LIST_QUERY_KEY_ROOT = "athena-conversation-list";
|
|
2
|
+
const CONVERSATION_LIST_DEFAULT_SCOPE_KEY = "default";
|
|
3
|
+
function normalizeConversationListFilter(filter) {
|
|
4
|
+
const normalized = {};
|
|
5
|
+
if (filter.appId) normalized.appId = filter.appId;
|
|
6
|
+
if (filter.assetTypes && filter.assetTypes.length > 0) {
|
|
7
|
+
normalized.assetTypes = [...filter.assetTypes].sort();
|
|
8
|
+
}
|
|
9
|
+
if (filter.search) normalized.search = filter.search;
|
|
10
|
+
if (filter.excludeTriggered !== void 0) normalized.excludeTriggered = filter.excludeTriggered;
|
|
11
|
+
if (filter.sourceChannels && filter.sourceChannels.length > 0) {
|
|
12
|
+
normalized.sourceChannels = [...filter.sourceChannels].sort();
|
|
13
|
+
}
|
|
14
|
+
if (filter.excludeSourceChannels && filter.excludeSourceChannels.length > 0) {
|
|
15
|
+
normalized.excludeSourceChannels = [...filter.excludeSourceChannels].sort();
|
|
16
|
+
}
|
|
17
|
+
if (filter.computerAssetId) normalized.computerAssetId = filter.computerAssetId;
|
|
18
|
+
if (filter.states && filter.states.length > 0) {
|
|
19
|
+
normalized.states = [...filter.states].sort();
|
|
20
|
+
}
|
|
21
|
+
if (filter.agentIds && filter.agentIds.length > 0) {
|
|
22
|
+
normalized.agentIds = [...filter.agentIds].sort();
|
|
23
|
+
}
|
|
24
|
+
if (filter.includeSubSessions) normalized.includeSubSessions = true;
|
|
25
|
+
return normalized;
|
|
26
|
+
}
|
|
27
|
+
function conversationListFilterKey(filter) {
|
|
28
|
+
const normalized = normalizeConversationListFilter(filter);
|
|
29
|
+
return JSON.stringify(
|
|
30
|
+
Object.keys(normalized).sort().map((key) => [key, normalized[key]])
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const conversationListQueryKeys = {
|
|
34
|
+
root: [CONVERSATION_LIST_QUERY_KEY_ROOT],
|
|
35
|
+
scope: (scopeKey) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey],
|
|
36
|
+
firstPage: (scopeKey, filterKey, pageSize) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, "first-page"],
|
|
37
|
+
history: (scopeKey, filterKey, pageSize) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, "history"]
|
|
38
|
+
};
|
|
39
|
+
function mergeConversationPages(pages) {
|
|
40
|
+
const seen = /* @__PURE__ */ new Set();
|
|
41
|
+
const items = [];
|
|
42
|
+
for (const page of pages) {
|
|
43
|
+
for (const item of page.items) {
|
|
44
|
+
if (seen.has(item.threadId)) continue;
|
|
45
|
+
seen.add(item.threadId);
|
|
46
|
+
items.push(item);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return items;
|
|
50
|
+
}
|
|
51
|
+
function prependConversationToPage(page, item) {
|
|
52
|
+
if (page.items.some((existing) => existing.threadId === item.threadId)) return page;
|
|
53
|
+
return {
|
|
54
|
+
...page,
|
|
55
|
+
items: [item, ...page.items],
|
|
56
|
+
totalCount: page.totalCount === null ? null : page.totalCount + 1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function removeConversationFromPage(page, threadId) {
|
|
60
|
+
if (!page.items.some((item) => item.threadId === threadId)) return page;
|
|
61
|
+
return { ...page, items: page.items.filter((item) => item.threadId !== threadId) };
|
|
62
|
+
}
|
|
63
|
+
function patchConversationsInPage(page, match, patch) {
|
|
64
|
+
let changed = false;
|
|
65
|
+
const items = page.items.map((item) => {
|
|
66
|
+
if (!match(item)) return item;
|
|
67
|
+
changed = true;
|
|
68
|
+
return { ...item, ...patch };
|
|
69
|
+
});
|
|
70
|
+
return changed ? { ...page, items } : page;
|
|
71
|
+
}
|
|
72
|
+
function scopedKey(options) {
|
|
73
|
+
return (options == null ? void 0 : options.scopeKey) !== void 0 ? conversationListQueryKeys.scope(options.scopeKey) : conversationListQueryKeys.root;
|
|
74
|
+
}
|
|
75
|
+
function invalidateConversationListCaches(queryClient, options) {
|
|
76
|
+
return queryClient.invalidateQueries({ queryKey: scopedKey(options) });
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
CONVERSATION_LIST_DEFAULT_SCOPE_KEY,
|
|
80
|
+
CONVERSATION_LIST_QUERY_KEY_ROOT,
|
|
81
|
+
conversationListFilterKey,
|
|
82
|
+
conversationListQueryKeys,
|
|
83
|
+
invalidateConversationListCaches,
|
|
84
|
+
mergeConversationPages,
|
|
85
|
+
normalizeConversationListFilter,
|
|
86
|
+
patchConversationsInPage,
|
|
87
|
+
prependConversationToPage,
|
|
88
|
+
removeConversationFromPage
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=conversation-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-list.js","sources":["../../../../../agent-runtime/src/conversation-list.ts"],"sourcesContent":["import type { InfiniteData, QueryClient } from '@tanstack/react-query';\nimport type { ConversationIndexEntry } from './conversation-index';\n\n/**\n * Shared conversation/thread LIST contract (chat-stack unification —\n * thread-list-contract-convergence).\n *\n * Every chat surface lists \"my conversations\" against the same underlying\n * session assets, but historically each declared its own row shape, paging\n * model, and filter set (Olympus GraphQL `listConversations`, the SDK/Chrome\n * REST `/api/conversations/threads/list`, mobile's `/api/v0/sessions`). This\n * module is the ONE contract those surfaces converge on:\n *\n * - **Row shape**: {@link ConversationSummary} — the canonical camelCase\n * superset. Fields a transport cannot supply are `null`, never invented.\n * - **Ordering**: newest first by `updatedAt`, always. Ordering is part of the\n * contract, not a parameter — no surface sorts any other way.\n * - **Paging**: offset/limit with a LIVE newest page and explicitly-fetched\n * frozen history pages (see `useConversationList`). `hasMore` continues the\n * scan; `totalCount` is advisory and may be `null` for transports that do\n * not count.\n * - **Filtering**: {@link ConversationListFilter}. `appId` follows\n * `docs/SESSION_APP_ID_GUIDE.md`: exact match when set (legacy `null`\n * sessions excluded), no filter when unset. A fetcher that cannot express a\n * requested filter field MUST throw rather than silently ignore it — a\n * dropped filter returns wrong rows under a cache key that claims otherwise.\n * - **Freshness**: the per-user conversation-index statewire\n * (`conversation-index.ts`) is the push signal; these queries are the data\n * source. Push handlers call {@link invalidateConversationListCaches}.\n */\nexport interface ConversationSummary {\n /** LangGraph thread id — the cross-surface conversation identity. */\n threadId: string;\n title: string;\n /** ISO 8601 timestamp of last update (the contract's sort key). */\n updatedAt: string;\n /** ISO 8601 creation timestamp, when the transport reports it. */\n createdAt: string | null;\n /** Session lifecycle state from athena_metadata (e.g. running, completed). */\n state: string | null;\n /** Agent runtime marker (e.g. 'athena_deep_agent'), when reported. */\n runtime: string | null;\n /** Channel the session was started from (e.g. agent_email, web). */\n sourceChannel: string | null;\n /** Asset type (session, video_session, desktop_session, mobile_session). */\n assetType: string | null;\n /** Session asset id (`asset_<uuid>`), when the transport reports it. */\n assetId: string | null;\n /** Client app that created the session (SESSION_APP_ID_GUIDE). */\n appId: string | null;\n /** Computer asset whose sandbox started the session (`sourceChannel` 'computer'); omitted by surfaces that don't carry it. */\n computerAssetId?: string | null;\n /** Trigger marker (`manual` remains user-initiated; other values are automated). */\n triggerType: string | null;\n /** Last-message preview used when a legacy session has no useful title. */\n preview: string | null;\n messageCount: number | null;\n /** Per-user unread flag derived server-side from the read receipt. */\n isUnread: boolean;\n /**\n * Canonical session status (status_v2: idle | active | needs_input | error),\n * or null when the transport does not report it.\n */\n sessionStatus: string | null;\n /**\n * Canonical status of the session's current run (status_v2: scheduled |\n * queued | running | needs_input | completed | failed | canceled). Null when\n * the transport does not report it — {@link isConversationRunning} then\n * falls back to the legacy `state`. Running badges on every surface derive\n * from this one helper so they cannot disagree.\n */\n runStatus: string | null;\n}\n\n/**\n * The canonical filter set. Semantics are defined here once; each fetcher\n * translates the fields its transport supports and throws on the rest.\n */\nexport interface ConversationListFilter {\n /** Exact-match client app filter; unset = all apps (SESSION_APP_ID_GUIDE). */\n appId?: string;\n /** Asset types to include (e.g. ['session']); unset = all session types. */\n assetTypes?: readonly string[];\n /** Case-insensitive title search. */\n search?: string;\n /** Hide triggered/background sessions (REST thread list only today). */\n excludeTriggered?: boolean;\n /** Start-channel filter (v0 sessions / REST thread list only today). */\n sourceChannels?: readonly string[];\n /** Start channels to hide (e.g. ['api']); GraphQL `listConversations` only today. */\n excludeSourceChannels?: readonly string[];\n /** Exact computer asset whose sandbox started the session; GraphQL `listConversations` only today. */\n computerAssetId?: string;\n /**\n * Lifecycle-state filter (e.g. ['running'], ['completed']). Transports match\n * it with the shared status_v2 rule (running carries a 12-hour recency cutoff).\n */\n states?: readonly string[];\n /** Restrict to sessions run by any of these agents (athena_metadata.agent). */\n agentIds?: readonly string[];\n /**\n * Include branched sub-sessions and orchestration children, which every list\n * hides by default because they belong under their parent thread.\n */\n includeSubSessions?: boolean;\n}\n\nexport interface ConversationListPage {\n /** Rows in contract order (updatedAt desc). */\n items: ConversationSummary[];\n /** Whether another `offset + limit` scan would return more rows. */\n hasMore: boolean;\n /** Total matching rows, or null when the transport does not count. */\n totalCount: number | null;\n}\n\nexport interface ConversationListFetchParams {\n limit: number;\n offset: number;\n filter: ConversationListFilter;\n signal?: AbortSignal;\n}\n\n/**\n * One page fetch against some transport (GraphQL `listConversations`, the\n * REST thread list, …). Must reject on filter fields it cannot express.\n */\nexport type ConversationListFetcher = (\n params: ConversationListFetchParams\n) => Promise<ConversationListPage>;\n\n/** Root of every conversation-list query key (all surfaces, all filters). */\nexport const CONVERSATION_LIST_QUERY_KEY_ROOT = 'athena-conversation-list';\n\n/**\n * Scope used by `useConversationList` when the caller passes no `scopeKey`.\n * Exported so cache seeders (e.g. Olympus's spacesBootstrap adoption) can\n * address the exact keys default-scoped hooks read from.\n */\nexport const CONVERSATION_LIST_DEFAULT_SCOPE_KEY = 'default';\n\n/**\n * Normalize a filter to its semantic content: unset/empty fields are dropped\n * (so `{}` and `{ appId: undefined }` are the same filter) and array order is\n * canonicalized. Fetchers receive the normalized form, so what a cache entry\n * claims to hold is exactly what was fetched.\n */\nexport function normalizeConversationListFilter(\n filter: ConversationListFilter\n): ConversationListFilter {\n const normalized: ConversationListFilter = {};\n if (filter.appId) normalized.appId = filter.appId;\n if (filter.assetTypes && filter.assetTypes.length > 0) {\n normalized.assetTypes = [...filter.assetTypes].sort();\n }\n if (filter.search) normalized.search = filter.search;\n if (filter.excludeTriggered !== undefined) normalized.excludeTriggered = filter.excludeTriggered;\n if (filter.sourceChannels && filter.sourceChannels.length > 0) {\n normalized.sourceChannels = [...filter.sourceChannels].sort();\n }\n if (filter.excludeSourceChannels && filter.excludeSourceChannels.length > 0) {\n normalized.excludeSourceChannels = [...filter.excludeSourceChannels].sort();\n }\n if (filter.computerAssetId) normalized.computerAssetId = filter.computerAssetId;\n if (filter.states && filter.states.length > 0) {\n normalized.states = [...filter.states].sort();\n }\n if (filter.agentIds && filter.agentIds.length > 0) {\n normalized.agentIds = [...filter.agentIds].sort();\n }\n if (filter.includeSubSessions) normalized.includeSubSessions = true;\n return normalized;\n}\n\n/** status_v2 run statuses during which a session is actively working. */\nconst RUNNING_RUN_STATUSES: ReadonlySet<string> = new Set(['queued', 'running']);\n\n/**\n * THE running rule for every conversation-list surface (sidebar pane, recent\n * dropdown, workspace section, pushed index rows): the canonical status_v2 run\n * status when the transport reports one, else the legacy `state`. A session\n * paused on a human gate (`needs_input`) is not running.\n */\nexport function isConversationRunning(summary: {\n runStatus?: string | null;\n state?: string | null;\n}): boolean {\n if (summary.runStatus !== null && summary.runStatus !== undefined) {\n return RUNNING_RUN_STATUSES.has(summary.runStatus);\n }\n return summary.state === 'running';\n}\n\n/**\n * Stable cache identity for a filter: the normalized fields serialized in\n * sorted key order, so semantically equal filters share one cache entry.\n */\nexport function conversationListFilterKey(filter: ConversationListFilter): string {\n const normalized = normalizeConversationListFilter(filter) as Record<string, unknown>;\n return JSON.stringify(\n Object.keys(normalized)\n .sort()\n .map((key) => [key, normalized[key]])\n );\n}\n\n/**\n * Query keys for the two-tier pager. `scopeKey` isolates caches beyond the\n * filter — surfaces MUST include everything that changes whose list this is\n * (principal/user id, backend base URL) so a credential swap can never read\n * another identity's rows out of the cache.\n *\n * `pageSize` is part of the key because it is baked into every cached page's\n * offset boundaries: two hooks sharing a scope and filter but paging by\n * different sizes would otherwise reuse each other's incompatible boundaries\n * and skip or duplicate rows.\n */\nexport const conversationListQueryKeys = {\n root: [CONVERSATION_LIST_QUERY_KEY_ROOT] as const,\n scope: (scopeKey: string) => [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey] as const,\n firstPage: (scopeKey: string, filterKey: string, pageSize: number) =>\n [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, 'first-page'] as const,\n history: (scopeKey: string, filterKey: string, pageSize: number) =>\n [CONVERSATION_LIST_QUERY_KEY_ROOT, scopeKey, filterKey, pageSize, 'history'] as const,\n};\n\n/**\n * Flatten pages into one newest-first list, deduplicating by `threadId`.\n * The live first page wins over retained history copies of the same thread.\n */\nexport function mergeConversationPages(\n pages: readonly ConversationListPage[]\n): ConversationSummary[] {\n const seen = new Set<string>();\n const items: ConversationSummary[] = [];\n for (const page of pages) {\n for (const item of page.items) {\n if (seen.has(item.threadId)) continue;\n seen.add(item.threadId);\n items.push(item);\n }\n }\n return items;\n}\n\n/**\n * Prepend a conversation to a page unless its thread is already present\n * (optimistic \"new thread appears at the top\" write). Identity-preserving\n * no-op when present, so equal writes never notify subscribers.\n */\nexport function prependConversationToPage(\n page: ConversationListPage,\n item: ConversationSummary\n): ConversationListPage {\n if (page.items.some((existing) => existing.threadId === item.threadId)) return page;\n return {\n ...page,\n items: [item, ...page.items],\n totalCount: page.totalCount === null ? null : page.totalCount + 1,\n };\n}\n\n/** Remove a thread's row from a page; identity-preserving when absent. */\nexport function removeConversationFromPage(\n page: ConversationListPage,\n threadId: string\n): ConversationListPage {\n if (!page.items.some((item) => item.threadId === threadId)) return page;\n return { ...page, items: page.items.filter((item) => item.threadId !== threadId) };\n}\n\n/**\n * Patch every row matching `match`; identity-preserving when nothing matches\n * so cache writes cannot cause spurious re-renders.\n */\nexport function patchConversationsInPage(\n page: ConversationListPage,\n match: (item: ConversationSummary) => boolean,\n patch: Partial<ConversationSummary>\n): ConversationListPage {\n let changed = false;\n const items = page.items.map((item) => {\n if (!match(item)) return item;\n changed = true;\n return { ...item, ...patch };\n });\n return changed ? { ...page, items } : page;\n}\n\ntype CachedConversationList =\n | ConversationListPage\n | InfiniteData<ConversationListPage, number>\n | undefined;\n\nfunction isInfinitePages(\n data: ConversationListPage | InfiniteData<ConversationListPage, number>\n): data is InfiniteData<ConversationListPage, number> {\n return 'pages' in data;\n}\n\nfunction mapCachedPages(\n data: CachedConversationList,\n transform: (page: ConversationListPage) => ConversationListPage\n): CachedConversationList {\n if (!data) return data;\n if (isInfinitePages(data)) {\n let changed = false;\n const pages = data.pages.map((page) => {\n const next = transform(page);\n if (next !== page) changed = true;\n return next;\n });\n return changed ? { ...data, pages } : data;\n }\n return transform(data);\n}\n\ninterface ConversationListCacheScope {\n /** Restrict to one scope; omitted = every conversation-list cache. */\n scopeKey?: string;\n}\n\nfunction scopedKey(options?: ConversationListCacheScope): readonly string[] {\n return options?.scopeKey !== undefined\n ? conversationListQueryKeys.scope(options.scopeKey)\n : conversationListQueryKeys.root;\n}\n\n/**\n * Invalidate conversation-list caches (all filters, first page + history).\n * This is the hook for push signals — the conversation-index statewire, a\n * finished run, an archive/restore — anything that changed the server list.\n */\nexport function invalidateConversationListCaches(\n queryClient: QueryClient,\n options?: ConversationListCacheScope\n): Promise<void> {\n return queryClient.invalidateQueries({ queryKey: scopedKey(options) });\n}\n\n/** Cancel in-flight list fetches so an optimistic write cannot be overwritten. */\nexport function cancelConversationListCaches(\n queryClient: QueryClient,\n options?: ConversationListCacheScope\n): Promise<void> {\n return queryClient.cancelQueries({ queryKey: scopedKey(options) });\n}\n\n/**\n * Patch matching rows in every cached conversation list (first pages, history\n * pages, searches) so per-row state (read receipts, titles) flips in the same\n * frame as the interaction instead of after the next refetch.\n */\nexport function patchConversationListCaches(\n queryClient: QueryClient,\n options: ConversationListCacheScope & {\n match: (item: ConversationSummary) => boolean;\n patch: Partial<ConversationSummary>;\n }\n): void {\n queryClient.setQueriesData<CachedConversationList>({ queryKey: scopedKey(options) }, (data) =>\n mapCachedPages(data, (page) => patchConversationsInPage(page, options.match, options.patch))\n );\n}\n\n/** Remove a thread's row from every cached conversation list in scope. */\nexport function removeConversationFromListCaches(\n queryClient: QueryClient,\n options: ConversationListCacheScope & { threadId: string }\n): void {\n queryClient.setQueriesData<CachedConversationList>({ queryKey: scopedKey(options) }, (data) =>\n mapCachedPages(data, (page) => removeConversationFromPage(page, options.threadId))\n );\n}\n\nfunction timestampMs(value: string): number {\n const parsed = Date.parse(value);\n return Number.isNaN(parsed) ? 0 : parsed;\n}\n\nfunction sameSummary(a: ConversationSummary, b: ConversationSummary): boolean {\n return (\n a.threadId === b.threadId &&\n a.title === b.title &&\n a.updatedAt === b.updatedAt &&\n a.createdAt === b.createdAt &&\n a.state === b.state &&\n a.runtime === b.runtime &&\n a.sourceChannel === b.sourceChannel &&\n a.assetType === b.assetType &&\n a.assetId === b.assetId &&\n a.appId === b.appId &&\n a.triggerType === b.triggerType &&\n a.preview === b.preview &&\n a.messageCount === b.messageCount &&\n a.isUnread === b.isUnread &&\n a.sessionStatus === b.sessionStatus &&\n a.runStatus === b.runStatus\n );\n}\n\n/**\n * Project one replicated conversation-index row onto the shared summary shape.\n * Fields the index never carries (`createdAt`) and viewer-specific fields a\n * lifecycle publish cannot know (`is_unread: null`) keep the row's previous\n * value. Canonical status is taken from the entry when the publishing pod\n * reports it; a snapshot from a pod that predates the fields falls back to the\n * legacy `state` (null status) rather than keeping a stale run status.\n */\nexport function summaryFromConversationIndexEntry(\n entry: ConversationIndexEntry,\n previous?: ConversationSummary\n): ConversationSummary {\n const carriesStatus = entry.run_status !== undefined || entry.session_status !== undefined;\n return {\n threadId: entry.thread_id,\n title: entry.title,\n updatedAt: entry.updated_at,\n createdAt: previous?.createdAt ?? null,\n state: entry.state,\n runtime: entry.runtime,\n sourceChannel: entry.start_channel,\n assetType: entry.asset_type,\n assetId: entry.asset_id ?? previous?.assetId ?? null,\n computerAssetId: previous?.computerAssetId ?? null,\n appId: entry.app_id,\n triggerType: entry.trigger_type,\n preview: entry.last_message_preview,\n messageCount: entry.message_count,\n isUnread: entry.is_unread ?? previous?.isUnread ?? false,\n sessionStatus: carriesStatus ? (entry.session_status ?? null) : null,\n runStatus: carriesStatus ? (entry.run_status ?? null) : null,\n };\n}\n\n/**\n * Fold the user's replicated conversation index (the newest-page window the\n * per-user statewire pushes) into a cached live first page, so a thread\n * created, renamed, finished, or read anywhere updates every list surface in\n * the same frame — without refetching the page.\n *\n * - Rows in the window are upserted (new threads appear, existing rows take\n * the pushed fields, see {@link summaryFromConversationIndexEntry}).\n * - Rows NOT in the window but at least as new as the window's oldest row\n * should have been in it, so they left the list (archived, hidden, shared\n * away) and are dropped. Older rows are beyond the window and are kept.\n * - When the index reports no further rows (`indexHasMore === false`) the\n * window IS the whole list, so every row outside it is dropped.\n *\n * Newest-first ordering is restored and the page identity is preserved when\n * nothing changed, so an equal push never notifies subscribers.\n */\nexport function mergeConversationIndexIntoPage(\n page: ConversationListPage,\n entries: readonly ConversationIndexEntry[],\n options: { indexHasMore: boolean }\n): ConversationListPage {\n const previousByThread = new Map(page.items.map((item) => [item.threadId, item]));\n const inWindow = new Set(entries.map((entry) => entry.thread_id));\n const windowTailMs =\n entries.length > 0 ? Math.min(...entries.map((entry) => timestampMs(entry.updated_at))) : null;\n\n const merged: ConversationSummary[] = entries.map((entry) => {\n const previous = previousByThread.get(entry.thread_id);\n const next = summaryFromConversationIndexEntry(entry, previous);\n return previous && sameSummary(previous, next) ? previous : next;\n });\n\n for (const item of page.items) {\n if (inWindow.has(item.threadId)) continue;\n if (!options.indexHasMore) continue;\n if (windowTailMs !== null && timestampMs(item.updatedAt) >= windowTailMs) continue;\n merged.push(item);\n }\n\n merged.sort((a, b) => timestampMs(b.updatedAt) - timestampMs(a.updatedAt));\n\n const unchanged =\n merged.length === page.items.length &&\n merged.every((item, index) => item === page.items[index]);\n if (unchanged) return page;\n\n return { ...page, items: merged };\n}\n"],"names":[],"mappings":"AAoIO,MAAM,mCAAmC;AAOzC,MAAM,sCAAsC;AAQ5C,SAAS,gCACd,QACwB;AACxB,QAAM,aAAqC,CAAA;AAC3C,MAAI,OAAO,MAAO,YAAW,QAAQ,OAAO;AAC5C,MAAI,OAAO,cAAc,OAAO,WAAW,SAAS,GAAG;AACrD,eAAW,aAAa,CAAC,GAAG,OAAO,UAAU,EAAE,KAAA;AAAA,EACjD;AACA,MAAI,OAAO,OAAQ,YAAW,SAAS,OAAO;AAC9C,MAAI,OAAO,qBAAqB,OAAW,YAAW,mBAAmB,OAAO;AAChF,MAAI,OAAO,kBAAkB,OAAO,eAAe,SAAS,GAAG;AAC7D,eAAW,iBAAiB,CAAC,GAAG,OAAO,cAAc,EAAE,KAAA;AAAA,EACzD;AACA,MAAI,OAAO,yBAAyB,OAAO,sBAAsB,SAAS,GAAG;AAC3E,eAAW,wBAAwB,CAAC,GAAG,OAAO,qBAAqB,EAAE,KAAA;AAAA,EACvE;AACA,MAAI,OAAO,gBAAiB,YAAW,kBAAkB,OAAO;AAChE,MAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAAG;AAC7C,eAAW,SAAS,CAAC,GAAG,OAAO,MAAM,EAAE,KAAA;AAAA,EACzC;AACA,MAAI,OAAO,YAAY,OAAO,SAAS,SAAS,GAAG;AACjD,eAAW,WAAW,CAAC,GAAG,OAAO,QAAQ,EAAE,KAAA;AAAA,EAC7C;AACA,MAAI,OAAO,mBAAoB,YAAW,qBAAqB;AAC/D,SAAO;AACT;AAyBO,SAAS,0BAA0B,QAAwC;AAChF,QAAM,aAAa,gCAAgC,MAAM;AACzD,SAAO,KAAK;AAAA,IACV,OAAO,KAAK,UAAU,EACnB,OACA,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC;AAAA,EAAA;AAE1C;AAaO,MAAM,4BAA4B;AAAA,EACvC,MAAM,CAAC,gCAAgC;AAAA,EACvC,OAAO,CAAC,aAAqB,CAAC,kCAAkC,QAAQ;AAAA,EACxE,WAAW,CAAC,UAAkB,WAAmB,aAC/C,CAAC,kCAAkC,UAAU,WAAW,UAAU,YAAY;AAAA,EAChF,SAAS,CAAC,UAAkB,WAAmB,aAC7C,CAAC,kCAAkC,UAAU,WAAW,UAAU,SAAS;AAC/E;AAMO,SAAS,uBACd,OACuB;AACvB,QAAM,2BAAW,IAAA;AACjB,QAAM,QAA+B,CAAA;AACrC,aAAW,QAAQ,OAAO;AACxB,eAAW,QAAQ,KAAK,OAAO;AAC7B,UAAI,KAAK,IAAI,KAAK,QAAQ,EAAG;AAC7B,WAAK,IAAI,KAAK,QAAQ;AACtB,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,0BACd,MACA,MACsB;AACtB,MAAI,KAAK,MAAM,KAAK,CAAC,aAAa,SAAS,aAAa,KAAK,QAAQ,EAAG,QAAO;AAC/E,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,CAAC,MAAM,GAAG,KAAK,KAAK;AAAA,IAC3B,YAAY,KAAK,eAAe,OAAO,OAAO,KAAK,aAAa;AAAA,EAAA;AAEpE;AAGO,SAAS,2BACd,MACA,UACsB;AACtB,MAAI,CAAC,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,aAAa,QAAQ,EAAG,QAAO;AACnE,SAAO,EAAE,GAAG,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,KAAK,aAAa,QAAQ,EAAA;AACjF;AAMO,SAAS,yBACd,MACA,OACA,OACsB;AACtB,MAAI,UAAU;AACd,QAAM,QAAQ,KAAK,MAAM,IAAI,CAAC,SAAS;AACrC,QAAI,CAAC,MAAM,IAAI,EAAG,QAAO;AACzB,cAAU;AACV,WAAO,EAAE,GAAG,MAAM,GAAG,MAAA;AAAA,EACvB,CAAC;AACD,SAAO,UAAU,EAAE,GAAG,MAAM,UAAU;AACxC;AAmCA,SAAS,UAAU,SAAyD;AAC1E,UAAO,mCAAS,cAAa,SACzB,0BAA0B,MAAM,QAAQ,QAAQ,IAChD,0BAA0B;AAChC;AAOO,SAAS,iCACd,aACA,SACe;AACf,SAAO,YAAY,kBAAkB,EAAE,UAAU,UAAU,OAAO,GAAG;AACvE;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const messageWindow = require("./message-window.cjs");
|
|
4
|
+
const protocol = require("./protocol.cjs");
|
|
5
|
+
const statewireAttachObserver = require("./statewire-attach-observer.cjs");
|
|
6
|
+
const statewireTransport = require("./statewire-transport.cjs");
|
|
7
|
+
function deepAgentThreadUrl({
|
|
8
|
+
baseUrl,
|
|
9
|
+
threadId
|
|
10
|
+
}) {
|
|
11
|
+
return `${baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(threadId)}`;
|
|
12
|
+
}
|
|
13
|
+
function createDeepAgentAttachTransport({
|
|
14
|
+
baseUrl,
|
|
15
|
+
threadId,
|
|
16
|
+
headers,
|
|
17
|
+
sse = false,
|
|
18
|
+
isNew = false,
|
|
19
|
+
sessionStore,
|
|
20
|
+
onAuthResolve,
|
|
21
|
+
onAttachTiming,
|
|
22
|
+
retryGate = statewireAttachObserver.attachRetryGate,
|
|
23
|
+
messageWindow: messageWindow$1 = false
|
|
24
|
+
}) {
|
|
25
|
+
const url = deepAgentThreadUrl({ baseUrl, threadId });
|
|
26
|
+
const instrumentation = statewireAttachObserver.createAttachInstrumentation({
|
|
27
|
+
url,
|
|
28
|
+
sse,
|
|
29
|
+
onEvent: onAttachTiming,
|
|
30
|
+
retryGate
|
|
31
|
+
});
|
|
32
|
+
const options = {
|
|
33
|
+
url,
|
|
34
|
+
...isNew && { isNew: true },
|
|
35
|
+
headers: async (ctx) => {
|
|
36
|
+
await retryGate.waitForDial(url);
|
|
37
|
+
onAuthResolve == null ? void 0 : onAuthResolve(ctx);
|
|
38
|
+
const declared = protocol.withDeclaredProtocolVersion(await headers(ctx));
|
|
39
|
+
return messageWindow$1 === false ? declared : messageWindow.withDeclaredMessageWindow(declared, messageWindow$1);
|
|
40
|
+
},
|
|
41
|
+
...sessionStore && { sessionStore },
|
|
42
|
+
// Structural types: this package compiles without the DOM lib, while
|
|
43
|
+
// statewire's option types name the browser `WebSocket`/`fetch`.
|
|
44
|
+
...instrumentation.webSocket && {
|
|
45
|
+
webSocket: instrumentation.webSocket
|
|
46
|
+
},
|
|
47
|
+
...instrumentation.fetch && {
|
|
48
|
+
fetch: instrumentation.fetch
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return statewireTransport.statewireTransport(options, { sse });
|
|
52
|
+
}
|
|
53
|
+
exports.createDeepAgentAttachTransport = createDeepAgentAttachTransport;
|
|
54
|
+
exports.deepAgentThreadUrl = deepAgentThreadUrl;
|
|
55
|
+
//# sourceMappingURL=deep-agent-transport-recipe.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-agent-transport-recipe.cjs","sources":["../../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise. */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * Declare a message window on the attach (`x-athena-deep-agent-window`, see\n * `message-window.ts`): the hello carries the transcript's tail plus the\n * `messagesWindow` lane instead of every message, and older ranges load\n * through `history/load`. Part of the recipe so a pooled dial asks for the\n * same shape as the thread's own attach — a pooled hello then seeds the very\n * state the attach will reconcile. `false` / omitted keeps the full\n * snapshot; the surfaces that have not adopted the window are untouched.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | false | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares this build's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow = false,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n const instrumentation = createAttachInstrumentation({\n url,\n sse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n const declared = withDeclaredProtocolVersion(await headers(ctx));\n return messageWindow === false\n ? declared\n : withDeclaredMessageWindow(declared, messageWindow);\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":["attachRetryGate","messageWindow","createAttachInstrumentation","withDeclaredProtocolVersion","withDeclaredMessageWindow","statewireTransport"],"mappings":";;;;;;AA2BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AA6CO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAYA,wBAAAA;AAAAA,EAAA,eACZC,kBAAgB;AAClB,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AACpD,QAAM,kBAAkBC,wBAAAA,4BAA4B;AAAA,IAClD;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,YAAM,WAAWC,SAAAA,4BAA4B,MAAM,QAAQ,GAAG,CAAC;AAC/D,aAAOF,oBAAkB,QACrB,WACAG,cAAAA,0BAA0B,UAAUH,eAAa;AAAA,IACvD;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAOI,sCAA2B,SAAS,EAAE,KAAK;AACpD;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { withDeclaredMessageWindow } from "./message-window.js";
|
|
2
|
+
import { withDeclaredProtocolVersion } from "./protocol.js";
|
|
3
|
+
import { createAttachInstrumentation, attachRetryGate } from "./statewire-attach-observer.js";
|
|
4
|
+
import { statewireTransport } from "./statewire-transport.js";
|
|
5
|
+
function deepAgentThreadUrl({
|
|
6
|
+
baseUrl,
|
|
7
|
+
threadId
|
|
8
|
+
}) {
|
|
9
|
+
return `${baseUrl.replace(/\/+$/, "")}/${encodeURIComponent(threadId)}`;
|
|
10
|
+
}
|
|
11
|
+
function createDeepAgentAttachTransport({
|
|
12
|
+
baseUrl,
|
|
13
|
+
threadId,
|
|
14
|
+
headers,
|
|
15
|
+
sse = false,
|
|
16
|
+
isNew = false,
|
|
17
|
+
sessionStore,
|
|
18
|
+
onAuthResolve,
|
|
19
|
+
onAttachTiming,
|
|
20
|
+
retryGate = attachRetryGate,
|
|
21
|
+
messageWindow = false
|
|
22
|
+
}) {
|
|
23
|
+
const url = deepAgentThreadUrl({ baseUrl, threadId });
|
|
24
|
+
const instrumentation = createAttachInstrumentation({
|
|
25
|
+
url,
|
|
26
|
+
sse,
|
|
27
|
+
onEvent: onAttachTiming,
|
|
28
|
+
retryGate
|
|
29
|
+
});
|
|
30
|
+
const options = {
|
|
31
|
+
url,
|
|
32
|
+
...isNew && { isNew: true },
|
|
33
|
+
headers: async (ctx) => {
|
|
34
|
+
await retryGate.waitForDial(url);
|
|
35
|
+
onAuthResolve == null ? void 0 : onAuthResolve(ctx);
|
|
36
|
+
const declared = withDeclaredProtocolVersion(await headers(ctx));
|
|
37
|
+
return messageWindow === false ? declared : withDeclaredMessageWindow(declared, messageWindow);
|
|
38
|
+
},
|
|
39
|
+
...sessionStore && { sessionStore },
|
|
40
|
+
// Structural types: this package compiles without the DOM lib, while
|
|
41
|
+
// statewire's option types name the browser `WebSocket`/`fetch`.
|
|
42
|
+
...instrumentation.webSocket && {
|
|
43
|
+
webSocket: instrumentation.webSocket
|
|
44
|
+
},
|
|
45
|
+
...instrumentation.fetch && {
|
|
46
|
+
fetch: instrumentation.fetch
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return statewireTransport(options, { sse });
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
createDeepAgentAttachTransport,
|
|
53
|
+
deepAgentThreadUrl
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=deep-agent-transport-recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-agent-transport-recipe.js","sources":["../../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise. */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * Declare a message window on the attach (`x-athena-deep-agent-window`, see\n * `message-window.ts`): the hello carries the transcript's tail plus the\n * `messagesWindow` lane instead of every message, and older ranges load\n * through `history/load`. Part of the recipe so a pooled dial asks for the\n * same shape as the thread's own attach — a pooled hello then seeds the very\n * state the attach will reconcile. `false` / omitted keeps the full\n * snapshot; the surfaces that have not adopted the window are untouched.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | false | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares this build's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow = false,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n const instrumentation = createAttachInstrumentation({\n url,\n sse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n const declared = withDeclaredProtocolVersion(await headers(ctx));\n return messageWindow === false\n ? declared\n : withDeclaredMessageWindow(declared, messageWindow);\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":[],"mappings":";;;;AA2BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AA6CO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,gBAAgB;AAClB,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AACpD,QAAM,kBAAkB,4BAA4B;AAAA,IAClD;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,YAAM,WAAW,4BAA4B,MAAM,QAAQ,GAAG,CAAC;AAC/D,aAAO,kBAAkB,QACrB,WACA,0BAA0B,UAAU,aAAa;AAAA,IACvD;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAO,mBAA2B,SAAS,EAAE,KAAK;AACpD;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const messageWindow = require("./message-window.cjs");
|
|
4
|
+
const threadExtras = require("./thread-extras.cjs");
|
|
5
|
+
function readDeepAgentStatewireExtras(extras) {
|
|
6
|
+
if (!threadExtras.hasStatewireThreadExtras(extras)) return null;
|
|
7
|
+
return extras;
|
|
8
|
+
}
|
|
9
|
+
function resolveWireAnchorMessageId({
|
|
10
|
+
wireMessages,
|
|
11
|
+
sourceId,
|
|
12
|
+
window = null
|
|
13
|
+
}) {
|
|
14
|
+
var _a;
|
|
15
|
+
if (!wireMessages) return void 0;
|
|
16
|
+
const index = wireMessages.findIndex((message) => (message == null ? void 0 : message.id) === sourceId);
|
|
17
|
+
if (index < 0) return void 0;
|
|
18
|
+
if (index === 0) {
|
|
19
|
+
if (window === null || window.start === 0) return null;
|
|
20
|
+
return window.anchorBefore ?? void 0;
|
|
21
|
+
}
|
|
22
|
+
const parentId = (_a = wireMessages[index - 1]) == null ? void 0 : _a.id;
|
|
23
|
+
return typeof parentId === "string" ? parentId : void 0;
|
|
24
|
+
}
|
|
25
|
+
function isSourceBelowLoadedWindow({
|
|
26
|
+
wireMessages,
|
|
27
|
+
sourceId,
|
|
28
|
+
window
|
|
29
|
+
}) {
|
|
30
|
+
if (!wireMessages || window === null || window.start === 0) return false;
|
|
31
|
+
return !wireMessages.some((message) => (message == null ? void 0 : message.id) === sourceId);
|
|
32
|
+
}
|
|
33
|
+
function mintCommandId() {
|
|
34
|
+
const webcrypto = globalThis.crypto;
|
|
35
|
+
if (typeof (webcrypto == null ? void 0 : webcrypto.randomUUID) === "function") return webcrypto.randomUUID();
|
|
36
|
+
const hex = () => Math.floor(Math.random() * 65536).toString(16).padStart(4, "0");
|
|
37
|
+
return `${hex()}${hex()}-${hex()}-4${hex().slice(1)}-${hex()}-${hex()}${hex()}${hex()}`;
|
|
38
|
+
}
|
|
39
|
+
function buildDeepAgentEditCommand({
|
|
40
|
+
extras,
|
|
41
|
+
sourceId,
|
|
42
|
+
text
|
|
43
|
+
}) {
|
|
44
|
+
var _a;
|
|
45
|
+
const runAnchorMessageId = resolveWireAnchorMessageId({
|
|
46
|
+
wireMessages: (_a = extras.state) == null ? void 0 : _a.messages,
|
|
47
|
+
sourceId,
|
|
48
|
+
window: messageWindow.readDeepAgentMessagesWindow(extras.state)
|
|
49
|
+
});
|
|
50
|
+
if (runAnchorMessageId === void 0) return null;
|
|
51
|
+
return {
|
|
52
|
+
type: "run/edit",
|
|
53
|
+
runId: extras.runs.runId ?? mintCommandId(),
|
|
54
|
+
message: { id: mintCommandId(), role: "user", parts: [{ type: "text", text }] },
|
|
55
|
+
sourceId,
|
|
56
|
+
runAnchorMessageId
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const MAX_EDIT_ANCHOR_HISTORY_LOADS = 5;
|
|
60
|
+
async function resolveDeepAgentEditCommand({
|
|
61
|
+
readExtras,
|
|
62
|
+
sourceId,
|
|
63
|
+
text,
|
|
64
|
+
maxHistoryLoads = MAX_EDIT_ANCHOR_HISTORY_LOADS
|
|
65
|
+
}) {
|
|
66
|
+
var _a;
|
|
67
|
+
for (let page = 0; page <= maxHistoryLoads; page += 1) {
|
|
68
|
+
const extras = readExtras();
|
|
69
|
+
if (!extras) return null;
|
|
70
|
+
const command = buildDeepAgentEditCommand({ extras, sourceId, text });
|
|
71
|
+
if (command) return command;
|
|
72
|
+
if (page === maxHistoryLoads) return null;
|
|
73
|
+
const wireMessages = (_a = extras.state) == null ? void 0 : _a.messages;
|
|
74
|
+
const window = messageWindow.readDeepAgentMessagesWindow(extras.state);
|
|
75
|
+
if (!isSourceBelowLoadedWindow({ wireMessages, sourceId, window })) return null;
|
|
76
|
+
const load = window === null ? null : messageWindow.buildHistoryLoadCommand({ window });
|
|
77
|
+
if (load === null) return null;
|
|
78
|
+
const result = messageWindow.readHistoryLoadResult(await extras.sendCommand(load));
|
|
79
|
+
if (result === null || result.loaded === 0 && !result.stale) return null;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
exports.MAX_EDIT_ANCHOR_HISTORY_LOADS = MAX_EDIT_ANCHOR_HISTORY_LOADS;
|
|
84
|
+
exports.buildDeepAgentEditCommand = buildDeepAgentEditCommand;
|
|
85
|
+
exports.isSourceBelowLoadedWindow = isSourceBelowLoadedWindow;
|
|
86
|
+
exports.readDeepAgentStatewireExtras = readDeepAgentStatewireExtras;
|
|
87
|
+
exports.resolveDeepAgentEditCommand = resolveDeepAgentEditCommand;
|
|
88
|
+
exports.resolveWireAnchorMessageId = resolveWireAnchorMessageId;
|
|
89
|
+
//# sourceMappingURL=edit-command.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-command.cjs","sources":["../../../../../agent-runtime/src/edit-command.ts"],"sourcesContent":["import type { StatewireThread } from '@assistant-ui/react-statewire';\nimport {\n buildHistoryLoadCommand,\n type DeepAgentMessagesWindow,\n readDeepAgentMessagesWindow,\n readHistoryLoadResult,\n} from './message-window';\nimport { hasStatewireThreadExtras } from './thread-extras';\n\n/**\n * Wire-accurate `run/edit` construction for deep-agent retry/edit, shared by\n * every surface that resubmits a user message.\n *\n * assistant-ui builds the command's `runAnchorMessageId` from the CONVERTED\n * thread messages (`resolveEditCommand`: `messages[index - 1].id`), but the\n * deep-agent host validates that anchor against the edited message's parent in\n * its RAW message list (`harness_sdk.linear_thread`: the entry before it in\n * `state[\"messages\"]`). Those two lists do not line up:\n *\n * - the converter chunks an assistant turn and its tool messages into ONE\n * thread message carrying only the FIRST wire id, so the anchor names the\n * head of the previous turn instead of its last tool message;\n * - `sanitizeLangChainMessages` drops hidden-from-frontend and unconvertible\n * entries, so a dropped tail message is invisible to the anchor too.\n *\n * Either way the host rejects the command with `wrong-anchor`\n * (`runAnchorMessageId … is not the source's parent`) AFTER the composer's\n * synchronous `send()` returned, so the retry/edit silently does nothing.\n *\n * Building the command here off the replicated raw state makes the anchor the\n * same value the host computes.\n *\n * On a windowed wire the raw list is the tail of the transcript, so the first\n * loaded message's parent is not in it: the host publishes that id as the\n * `messagesWindow` lane's `anchorBefore`, and an edit at the window edge\n * anchors there — never on `null`, which would assert the root and be\n * rejected `wrong-anchor`. A message below the loaded range has no parent on\n * this client at all; {@link resolveDeepAgentEditCommand} loads older pages\n * until it does.\n */\n\n/** The pieces of the statewire thread extras the edit path reads. */\nexport interface DeepAgentStatewireExtras {\n /** The library's dispatch; it resolves with the host's reply to the command. */\n sendCommand: (\n command: StatewireThread.Command,\n options?: StatewireThread.SendOptions,\n ) => Promise<unknown> | void;\n /** Optional on older hosts; capture before loading an edit's history anchor. */\n prepareMessageMetadata?: StatewireThread.Extras['prepareMessageMetadata'];\n discardPreparedMessageMetadata?: StatewireThread.Extras['discardPreparedMessageMetadata'];\n sendPreparedEdit?: StatewireThread.Extras['sendPreparedEdit'];\n isPreparingSubmission?: boolean;\n /** The replicated host state — its `messages` are the raw wire messages. */\n state: { messages?: readonly { id?: unknown }[] } | null;\n /** The live run, when one is in flight; `epoch` advances on each dispatch. */\n runs: { runId?: string | null; epoch?: number };\n /** The host's replicated run status; absent on a surface that predates it. */\n status?: StatewireThread.ThreadStatus;\n}\n\n/**\n * The statewire extras of the nearest aui thread, or `null` when the thread is\n * not a statewire thread (e.g. a read-only subagent transcript runtime).\n * Gated on {@link hasStatewireThreadExtras} for the same reason the approval\n * card is: the library's own hooks throw on a non-statewire thread.\n */\nexport function readDeepAgentStatewireExtras(extras: unknown): DeepAgentStatewireExtras | null {\n if (!hasStatewireThreadExtras(extras)) return null;\n return extras as DeepAgentStatewireExtras;\n}\n\n/**\n * The host's parent of `sourceId`: the raw wire message directly before it\n * (`null` when it is the first of the whole transcript). Returns `undefined`\n * when `sourceId` is not in the raw list at all — an optimistic bubble the\n * host has not settled yet, a message below a windowed wire's loaded range, or\n * a surface whose state this module cannot read — so the caller can fall back\n * to the library's own path instead of asserting a wrong anchor.\n *\n * On a windowed wire (`window`), the first loaded message's parent is the\n * lane's `anchorBefore`; a truncated window that carries no anchor resolves\n * `undefined` rather than `null` (the root), which the host would reject.\n */\nexport function resolveWireAnchorMessageId({\n wireMessages,\n sourceId,\n window = null,\n}: {\n wireMessages: readonly { id?: unknown }[] | undefined;\n sourceId: string;\n window?: DeepAgentMessagesWindow | null;\n}): string | null | undefined {\n if (!wireMessages) return undefined;\n const index = wireMessages.findIndex((message) => message?.id === sourceId);\n if (index < 0) return undefined;\n if (index === 0) {\n if (window === null || window.start === 0) return null;\n return window.anchorBefore ?? undefined;\n }\n const parentId = wireMessages[index - 1]?.id;\n return typeof parentId === 'string' ? parentId : undefined;\n}\n\n/**\n * Whether `sourceId` lies below a windowed wire's loaded range: not in the raw\n * list while the lane says older messages exist. The caller loads older\n * history before an edit can be anchored.\n */\nexport function isSourceBelowLoadedWindow({\n wireMessages,\n sourceId,\n window,\n}: {\n wireMessages: readonly { id?: unknown }[] | undefined;\n sourceId: string;\n window: DeepAgentMessagesWindow | null;\n}): boolean {\n if (!wireMessages || window === null || window.start === 0) return false;\n return !wireMessages.some((message) => message?.id === sourceId);\n}\n\n/**\n * A fresh command / message id (uniqueness, not secrecy). `crypto.randomUUID`\n * where the host runtime has it — every browser, Bun, Node and Hermes with\n * webcrypto — and a v4-shaped fallback elsewhere, so the shared path never\n * throws on a runtime without full webcrypto.\n */\nfunction mintCommandId(): string {\n const webcrypto = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (typeof webcrypto?.randomUUID === 'function') return webcrypto.randomUUID();\n const hex = (): string => Math.floor(Math.random() * 0x10000).toString(16).padStart(4, '0');\n return `${hex()}${hex()}-${hex()}-4${hex().slice(1)}-${hex()}-${hex()}${hex()}${hex()}`;\n}\n\n/**\n * The `run/edit` command for resubmitting `sourceId` with `text`, anchored on\n * the host's own parent. `null` when the anchor cannot be resolved from the\n * replicated state.\n */\nexport function buildDeepAgentEditCommand({\n extras,\n sourceId,\n text,\n}: {\n extras: DeepAgentStatewireExtras;\n sourceId: string;\n text: string;\n}): StatewireThread.RunEditCommand | null {\n const runAnchorMessageId = resolveWireAnchorMessageId({\n wireMessages: extras.state?.messages,\n sourceId,\n window: readDeepAgentMessagesWindow(extras.state),\n });\n if (runAnchorMessageId === undefined) return null;\n return {\n type: 'run/edit',\n runId: extras.runs.runId ?? mintCommandId(),\n message: { id: mintCommandId(), role: 'user', parts: [{ type: 'text', text }] },\n sourceId,\n runAnchorMessageId,\n };\n}\n\n/**\n * Pages of older history loaded while looking for an edited message's host\n * parent. Each page is up to a window's worth of messages, so an edit reaches\n * this many windows below what was loaded before it gives up.\n */\nexport const MAX_EDIT_ANCHOR_HISTORY_LOADS = 5;\n\n/**\n * The anchored `run/edit` for `sourceId`, loading older history a page at a\n * time when the message lies below a windowed wire's loaded range. Every page\n * is read back from the live thread state (`readExtras` — the host prepends\n * it as ops before it answers the command), so the anchor is always the host's\n * own parent id.\n *\n * Resolves `null` — the caller's cue for the library's composer path, whose\n * failure it reports — when the thread is not a statewire thread, the host has\n * not settled the message, the history is exhausted without it, or the page\n * budget ({@link MAX_EDIT_ANCHOR_HISTORY_LOADS}) is spent. A synchronous\n * resolution never awaits: the first read either anchors at once or decides\n * that pages are needed.\n */\nexport async function resolveDeepAgentEditCommand({\n readExtras,\n sourceId,\n text,\n maxHistoryLoads = MAX_EDIT_ANCHOR_HISTORY_LOADS,\n}: {\n /** The live thread extras — re-read per page so each anchor attempt sees the prepended range. */\n readExtras: () => DeepAgentStatewireExtras | null;\n sourceId: string;\n text: string;\n maxHistoryLoads?: number;\n}): Promise<StatewireThread.RunEditCommand | null> {\n for (let page = 0; page <= maxHistoryLoads; page += 1) {\n const extras = readExtras();\n if (!extras) return null;\n const command = buildDeepAgentEditCommand({ extras, sourceId, text });\n if (command) return command;\n if (page === maxHistoryLoads) return null;\n const wireMessages = extras.state?.messages;\n const window = readDeepAgentMessagesWindow(extras.state);\n if (!isSourceBelowLoadedWindow({ wireMessages, sourceId, window })) return null;\n const load = window === null ? null : buildHistoryLoadCommand({ window });\n if (load === null) return null;\n const result = readHistoryLoadResult(await extras.sendCommand(load));\n // A current view that yielded nothing older: the message is not in this\n // thread's history at all. (A stale view is retried with the fresh lane.)\n if (result === null || (result.loaded === 0 && !result.stale)) return null;\n }\n return null;\n}\n"],"names":["hasStatewireThreadExtras","readDeepAgentMessagesWindow","buildHistoryLoadCommand","readHistoryLoadResult"],"mappings":";;;;AAmEO,SAAS,6BAA6B,QAAkD;AAC7F,MAAI,CAACA,aAAAA,yBAAyB,MAAM,EAAG,QAAO;AAC9C,SAAO;AACT;AAcO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AAAA,EACA,SAAS;AACX,GAI8B;;AAC5B,MAAI,CAAC,aAAc,QAAO;AAC1B,QAAM,QAAQ,aAAa,UAAU,CAAC,aAAY,mCAAS,QAAO,QAAQ;AAC1E,MAAI,QAAQ,EAAG,QAAO;AACtB,MAAI,UAAU,GAAG;AACf,QAAI,WAAW,QAAQ,OAAO,UAAU,EAAG,QAAO;AAClD,WAAO,OAAO,gBAAgB;AAAA,EAChC;AACA,QAAM,YAAW,kBAAa,QAAQ,CAAC,MAAtB,mBAAyB;AAC1C,SAAO,OAAO,aAAa,WAAW,WAAW;AACnD;AAOO,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACF,GAIY;AACV,MAAI,CAAC,gBAAgB,WAAW,QAAQ,OAAO,UAAU,EAAG,QAAO;AACnE,SAAO,CAAC,aAAa,KAAK,CAAC,aAAY,mCAAS,QAAO,QAAQ;AACjE;AAQA,SAAS,gBAAwB;AAC/B,QAAM,YAAa,WAA0D;AAC7E,MAAI,QAAO,uCAAW,gBAAe,WAAY,QAAO,UAAU,WAAA;AAClE,QAAM,MAAM,MAAc,KAAK,MAAM,KAAK,OAAA,IAAW,KAAO,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC1F,SAAO,GAAG,IAAA,CAAK,GAAG,IAAA,CAAK,IAAI,IAAA,CAAK,KAAK,MAAM,MAAM,CAAC,CAAC,IAAI,IAAA,CAAK,IAAI,KAAK,GAAG,IAAA,CAAK,GAAG,IAAA,CAAK;AACvF;AAOO,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACF,GAI0C;;AACxC,QAAM,qBAAqB,2BAA2B;AAAA,IACpD,eAAc,YAAO,UAAP,mBAAc;AAAA,IAC5B;AAAA,IACA,QAAQC,cAAAA,4BAA4B,OAAO,KAAK;AAAA,EAAA,CACjD;AACD,MAAI,uBAAuB,OAAW,QAAO;AAC7C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO,OAAO,KAAK,SAAS,cAAA;AAAA,IAC5B,SAAS,EAAE,IAAI,cAAA,GAAiB,MAAM,QAAQ,OAAO,CAAC,EAAE,MAAM,QAAQ,KAAA,CAAM,EAAA;AAAA,IAC5E;AAAA,IACA;AAAA,EAAA;AAEJ;AAOO,MAAM,gCAAgC;AAgB7C,eAAsB,4BAA4B;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AACpB,GAMmD;;AACjD,WAAS,OAAO,GAAG,QAAQ,iBAAiB,QAAQ,GAAG;AACrD,UAAM,SAAS,WAAA;AACf,QAAI,CAAC,OAAQ,QAAO;AACpB,UAAM,UAAU,0BAA0B,EAAE,QAAQ,UAAU,MAAM;AACpE,QAAI,QAAS,QAAO;AACpB,QAAI,SAAS,gBAAiB,QAAO;AACrC,UAAM,gBAAe,YAAO,UAAP,mBAAc;AACnC,UAAM,SAASA,cAAAA,4BAA4B,OAAO,KAAK;AACvD,QAAI,CAAC,0BAA0B,EAAE,cAAc,UAAU,OAAA,CAAQ,EAAG,QAAO;AAC3E,UAAM,OAAO,WAAW,OAAO,OAAOC,cAAAA,wBAAwB,EAAE,QAAQ;AACxE,QAAI,SAAS,KAAM,QAAO;AAC1B,UAAM,SAASC,cAAAA,sBAAsB,MAAM,OAAO,YAAY,IAAI,CAAC;AAGnE,QAAI,WAAW,QAAS,OAAO,WAAW,KAAK,CAAC,OAAO,MAAQ,QAAO;AAAA,EACxE;AACA,SAAO;AACT;;;;;;;"}
|