@athenaintel/react 0.28.1 → 0.30.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 +418 -10
- package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
- package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
- package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
- package/dist/agent-runtime/src/auth-denial.js.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
- package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tools.js.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.js +124 -0
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
- package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
- package/dist/agent-runtime/src/conversation-index.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
- package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
- package/dist/agent-runtime/src/conversation-list.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
- package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
- package/dist/agent-runtime/src/edit-command.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
- package/dist/agent-runtime/src/errors.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
- package/dist/agent-runtime/src/errors.js.map +1 -0
- package/dist/agent-runtime/src/execute-output.cjs +41 -0
- package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
- package/dist/agent-runtime/src/execute-output.js +41 -0
- package/dist/agent-runtime/src/execute-output.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +10 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +10 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
- package/dist/agent-runtime/src/interrupts.js.map +1 -0
- package/dist/agent-runtime/src/message-author.cjs.map +1 -0
- package/dist/agent-runtime/src/message-author.js.map +1 -0
- package/dist/agent-runtime/src/message-window.cjs.map +1 -0
- package/dist/agent-runtime/src/message-window.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
- package/dist/agent-runtime/src/messages.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
- package/dist/agent-runtime/src/messages.js.map +1 -0
- package/dist/agent-runtime/src/model-context.cjs.map +1 -0
- package/dist/agent-runtime/src/model-context.js.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
- package/dist/agent-runtime/src/protocol.cjs.map +1 -0
- package/dist/agent-runtime/src/protocol.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
- package/dist/agent-runtime/src/queue.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
- package/dist/agent-runtime/src/queue.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +23 -13
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +24 -14
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
- package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
- package/dist/agent-runtime/src/send-recovery.js.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
- package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
- package/dist/agent-runtime/src/statewire-state.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
- package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
- package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.js +43 -0
- package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
- package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-extras.js.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
- package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-status.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +279 -3
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +279 -3
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
- package/dist/agent-runtime/src/tool-names.cjs +5 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-names.js +5 -0
- package/dist/agent-runtime/src/tool-names.js.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
- package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-result.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
- package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
- package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
- package/dist/assets/AthenaAssetEmbed.cjs +8 -2
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +8 -0
- package/dist/assets/AthenaAssetEmbed.js +8 -2
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/AthenaLayout.cjs +97 -31
- package/dist/assets/AthenaLayout.cjs.map +1 -1
- package/dist/assets/AthenaLayout.d.ts +13 -0
- package/dist/assets/AthenaLayout.js +98 -32
- package/dist/assets/AthenaLayout.js.map +1 -1
- package/dist/assets/asset-embed-messages.cjs.map +1 -1
- package/dist/assets/asset-embed-messages.d.ts +6 -0
- package/dist/assets/asset-embed-messages.js.map +1 -1
- package/dist/assets/asset-panel-store.cjs +68 -32
- package/dist/assets/asset-panel-store.cjs.map +1 -1
- package/dist/assets/asset-panel-store.d.ts +47 -1
- package/dist/assets/asset-panel-store.js +68 -32
- package/dist/assets/asset-panel-store.js.map +1 -1
- package/dist/assets/use-asset-embed.cjs +29 -8
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.d.ts +7 -0
- package/dist/assets/use-asset-embed.js +29 -8
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/catalog/chat-pickers.cjs +152 -0
- package/dist/catalog/chat-pickers.cjs.map +1 -0
- package/dist/catalog/chat-pickers.d.ts +22 -0
- package/dist/catalog/chat-pickers.js +152 -0
- package/dist/catalog/chat-pickers.js.map +1 -0
- package/dist/catalog/runtime-catalog.cjs +181 -0
- package/dist/catalog/runtime-catalog.cjs.map +1 -0
- package/dist/catalog/runtime-catalog.d.ts +100 -0
- package/dist/catalog/runtime-catalog.js +181 -0
- package/dist/catalog/runtime-catalog.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +86 -46
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +21 -4
- package/dist/chat/AthenaChat.js +88 -48
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +38 -37
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +2 -0
- package/dist/chat/StatewireApprovalCard.js +39 -38
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -2
- package/dist/chat/StatewireClientToolBridge.js +2 -2
- package/dist/chat/StatewireQueuedMessages.cjs +15 -12
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
- package/dist/chat/StatewireQueuedMessages.js +15 -12
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
- package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
- package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
- package/dist/chat/StatewireRunRefusalNotice.js +48 -0
- package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
- package/dist/chat/WaitingOnYouBanner.cjs +2 -2
- package/dist/chat/WaitingOnYouBanner.js +2 -2
- package/dist/chat/athena-citation-links.cjs +19 -15
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-citation-links.js +19 -15
- package/dist/chat/athena-citation-links.js.map +1 -1
- package/dist/chat/run-activity.cjs +9 -1
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.d.ts +6 -0
- package/dist/chat/run-activity.js +10 -2
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-banners.cjs +30 -1
- package/dist/chat/statewire-banners.cjs.map +1 -1
- package/dist/chat/statewire-banners.d.ts +20 -1
- package/dist/chat/statewire-banners.js +32 -3
- package/dist/chat/statewire-banners.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +1 -1
- package/dist/chat/statewire-client-tools.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +7 -5
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +8 -2
- package/dist/chat/super-grouping/SuperGroupingCard.js +7 -5
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +350 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +350 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
- package/dist/chat/super-grouping/ToolTimeline.js +13 -2
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +51 -26
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +40 -8
- package/dist/chat/super-grouping/activity-timeline.js +52 -27
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/index.cjs +12 -0
- package/dist/chat/super-grouping/index.cjs.map +1 -1
- package/dist/chat/super-grouping/index.d.ts +7 -2
- package/dist/chat/super-grouping/index.js +14 -2
- package/dist/chat/super-grouping/index.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +14 -5
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
- package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
- package/dist/chat/super-grouping/timeline-step.js +15 -6
- package/dist/chat/super-grouping/timeline-step.js.map +1 -1
- package/dist/chat/super-grouping/turn-segments.cjs +82 -0
- package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
- package/dist/chat/super-grouping/turn-segments.js +82 -0
- package/dist/chat/super-grouping/turn-segments.js.map +1 -0
- package/dist/chat/super-grouping/turn-timing.cjs +110 -0
- package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
- package/dist/chat/super-grouping/turn-timing.js +110 -0
- package/dist/chat/super-grouping/turn-timing.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +1 -1
- package/dist/chat/tiptap-text.js +1 -1
- package/dist/chat/use-athena-run-live.cjs +1 -1
- package/dist/chat/use-athena-run-live.js +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +73 -4
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.js +74 -5
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/composer-message.cjs +284 -0
- package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
- package/dist/chat-ui/composer/composer-message.d.ts +152 -0
- package/dist/chat-ui/composer/composer-message.js +284 -0
- package/dist/chat-ui/composer/composer-message.js.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs +57 -11
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
- package/dist/chat-ui/composer/tiptap-composer.js +57 -11
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +4 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +3 -2
- package/dist/chat-ui/index.js +5 -2
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +3 -2
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.js +4 -3
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +8 -2
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.js +8 -2
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +30 -10
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +21 -1
- package/dist/chat-ui/messages/message-components.js +30 -10
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +1 -1
- package/dist/chat-ui/messages/runtime-message.js +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
- package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
- package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +39 -4
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
- package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
- package/dist/chat-ui/messages/wake-marker.js +40 -5
- package/dist/chat-ui/messages/wake-marker.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
- package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +1 -1
- package/dist/chat-ui/statewire.d.ts +1 -1
- package/dist/chat-ui/statewire.js +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
- package/dist/collab/client.cjs +218 -13
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +105 -2
- package/dist/collab/client.js +221 -17
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.cjs +2 -0
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.ts +1 -1
- package/dist/collab/index.js +3 -1
- package/dist/composer/AttachmentContext.cjs +38 -12
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.d.ts +22 -1
- package/dist/composer/AttachmentContext.js +40 -14
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/QuoteContext.cjs +80 -28
- package/dist/composer/QuoteContext.cjs.map +1 -1
- package/dist/composer/QuoteContext.d.ts +35 -6
- package/dist/composer/QuoteContext.js +82 -30
- package/dist/composer/QuoteContext.js.map +1 -1
- package/dist/composer/build-composed-message.cjs +27 -0
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +21 -0
- package/dist/composer/build-composed-message.js +28 -1
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +13 -1
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +12 -0
- package/dist/composer/composer-handoff.js +15 -3
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/index.d.ts +6 -3
- package/dist/composer/useReadComposerDraft.cjs +16 -0
- package/dist/composer/useReadComposerDraft.cjs.map +1 -0
- package/dist/composer/useReadComposerDraft.d.ts +6 -0
- package/dist/composer/useReadComposerDraft.js +16 -0
- package/dist/composer/useReadComposerDraft.js.map +1 -0
- package/dist/diagnostics/errors.cjs +6 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +6 -0
- package/dist/diagnostics/errors.js +6 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +159 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +53 -12
- package/dist/index.js +166 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/owner-document.cjs +32 -0
- package/dist/lib/owner-document.cjs.map +1 -0
- package/dist/lib/owner-document.d.ts +17 -0
- package/dist/lib/owner-document.js +32 -0
- package/dist/lib/owner-document.js.map +1 -0
- package/dist/lib/portal-surface.cjs +55 -0
- package/dist/lib/portal-surface.cjs.map +1 -0
- package/dist/lib/portal-surface.d.ts +37 -0
- package/dist/lib/portal-surface.js +55 -0
- package/dist/lib/portal-surface.js.map +1 -0
- package/dist/lib/use-athena-rest-query.cjs +34 -0
- package/dist/lib/use-athena-rest-query.cjs.map +1 -0
- package/dist/lib/use-athena-rest-query.d.ts +31 -0
- package/dist/lib/use-athena-rest-query.js +34 -0
- package/dist/lib/use-athena-rest-query.js.map +1 -0
- package/dist/provider/AthenaProvider.cjs +36 -6
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +20 -1
- package/dist/provider/AthenaProvider.js +38 -8
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/citation-links.d.ts +10 -2
- package/dist/{packages/react → react}/package.json.cjs +1 -1
- package/dist/{packages/react → react}/package.json.js +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +15 -3
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.d.ts +6 -0
- package/dist/runtime/statewire-lifecycle.js +15 -3
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +11 -7
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +11 -7
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaRepoSearch.cjs +5 -13
- package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
- package/dist/search/useAthenaRepoSearch.d.ts +3 -3
- package/dist/search/useAthenaRepoSearch.js +6 -14
- package/dist/search/useAthenaRepoSearch.js.map +1 -1
- package/dist/sheet-range/a1.cjs +162 -0
- package/dist/sheet-range/a1.cjs.map +1 -0
- package/dist/sheet-range/a1.d.ts +91 -0
- package/dist/sheet-range/a1.js +162 -0
- package/dist/sheet-range/a1.js.map +1 -0
- package/dist/sheet-range/index.cjs +22 -0
- package/dist/sheet-range/index.cjs.map +1 -0
- package/dist/sheet-range/index.d.ts +12 -0
- package/dist/sheet-range/index.js +22 -0
- package/dist/sheet-range/index.js.map +1 -0
- package/dist/sheet-range/range-preview-table.cjs +75 -0
- package/dist/sheet-range/range-preview-table.cjs.map +1 -0
- package/dist/sheet-range/range-preview-table.d.ts +20 -0
- package/dist/sheet-range/range-preview-table.js +75 -0
- package/dist/sheet-range/range-preview-table.js.map +1 -0
- package/dist/sheet-range/range-preview.cjs +116 -0
- package/dist/sheet-range/range-preview.cjs.map +1 -0
- package/dist/sheet-range/range-preview.d.ts +67 -0
- package/dist/sheet-range/range-preview.js +116 -0
- package/dist/sheet-range/range-preview.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/threads/Inbox.cjs +289 -0
- package/dist/threads/Inbox.cjs.map +1 -0
- package/dist/threads/Inbox.d.ts +46 -0
- package/dist/threads/Inbox.js +289 -0
- package/dist/threads/Inbox.js.map +1 -0
- package/dist/threads/SessionList.cjs +51 -126
- package/dist/threads/SessionList.cjs.map +1 -1
- package/dist/threads/SessionList.d.ts +26 -1
- package/dist/threads/SessionList.js +45 -120
- package/dist/threads/SessionList.js.map +1 -1
- package/dist/threads/SessionsPage.cjs +753 -0
- package/dist/threads/SessionsPage.cjs.map +1 -0
- package/dist/threads/SessionsPage.d.ts +35 -0
- package/dist/threads/SessionsPage.js +753 -0
- package/dist/threads/SessionsPage.js.map +1 -0
- package/dist/threads/api.cjs +21 -1
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +59 -0
- package/dist/threads/api.js +21 -1
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +9 -2
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +14 -1
- package/dist/threads/conversation-list-fetcher.js +9 -2
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/index.d.ts +2 -1
- package/dist/threads/pull-request-display.cjs +25 -0
- package/dist/threads/pull-request-display.cjs.map +1 -0
- package/dist/threads/pull-request-display.d.ts +15 -0
- package/dist/threads/pull-request-display.js +25 -0
- package/dist/threads/pull-request-display.js.map +1 -0
- package/dist/threads/session-list-model.cjs +16 -2
- package/dist/threads/session-list-model.cjs.map +1 -1
- package/dist/threads/session-list-model.d.ts +10 -0
- package/dist/threads/session-list-model.js +16 -2
- package/dist/threads/session-list-model.js.map +1 -1
- package/dist/threads/session-row-parts.cjs +152 -0
- package/dist/threads/session-row-parts.cjs.map +1 -0
- package/dist/threads/session-row-parts.d.ts +50 -0
- package/dist/threads/session-row-parts.js +152 -0
- package/dist/threads/session-row-parts.js.map +1 -0
- package/dist/threads/sessions-page-model.cjs +305 -0
- package/dist/threads/sessions-page-model.cjs.map +1 -0
- package/dist/threads/sessions-page-model.d.ts +86 -0
- package/dist/threads/sessions-page-model.js +305 -0
- package/dist/threads/sessions-page-model.js.map +1 -0
- package/dist/threads/sessions-page-storage.cjs +93 -0
- package/dist/threads/sessions-page-storage.cjs.map +1 -0
- package/dist/threads/sessions-page-storage.d.ts +23 -0
- package/dist/threads/sessions-page-storage.js +93 -0
- package/dist/threads/sessions-page-storage.js.map +1 -0
- package/dist/threads/sessions-query.cjs +235 -0
- package/dist/threads/sessions-query.cjs.map +1 -0
- package/dist/threads/sessions-query.d.ts +119 -0
- package/dist/threads/sessions-query.js +235 -0
- package/dist/threads/sessions-query.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +133 -40
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +83 -2
- package/dist/threads/statewire-thread-list.js +134 -41
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-athena-sessions.cjs +198 -0
- package/dist/threads/use-athena-sessions.cjs.map +1 -0
- package/dist/threads/use-athena-sessions.d.ts +81 -0
- package/dist/threads/use-athena-sessions.js +198 -0
- package/dist/threads/use-athena-sessions.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +1 -1
- package/dist/threads/use-rest-conversation-history.js +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
- package/dist/threads/use-statewire-conversation-history.js +1 -1
- package/dist/threads/use-thread-read-state.cjs +73 -0
- package/dist/threads/use-thread-read-state.cjs.map +1 -0
- package/dist/threads/use-thread-read-state.d.ts +51 -0
- package/dist/threads/use-thread-read-state.js +73 -0
- package/dist/threads/use-thread-read-state.js.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
- package/dist/tools/auto-open-tools.cjs +2 -0
- package/dist/tools/auto-open-tools.cjs.map +1 -1
- package/dist/tools/auto-open-tools.js +2 -0
- package/dist/tools/auto-open-tools.js.map +1 -1
- package/dist/tools/file-tool-uis.cjs +18 -43
- package/dist/tools/file-tool-uis.cjs.map +1 -1
- package/dist/tools/file-tool-uis.d.ts +1 -2
- package/dist/tools/file-tool-uis.js +18 -42
- package/dist/tools/file-tool-uis.js.map +1 -1
- package/dist/tools/index.cjs +6 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +6 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -2
- package/dist/tools/misc-tool-uis.js +2 -2
- package/dist/tools/primitives.cjs +1 -1
- package/dist/tools/primitives.js +1 -1
- package/dist/tools/read-asset-tool-ui.cjs +21 -70
- package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
- package/dist/tools/read-asset-tool-ui.js +21 -70
- package/dist/tools/read-asset-tool-ui.js.map +1 -1
- package/dist/tools/step-text.cjs +21 -0
- package/dist/tools/step-text.cjs.map +1 -0
- package/dist/tools/step-text.d.ts +10 -0
- package/dist/tools/step-text.js +21 -0
- package/dist/tools/step-text.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +24 -5
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.d.ts +3 -1
- package/dist/tools/tool-fallback.js +24 -5
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/tool-summary.cjs +661 -0
- package/dist/tools/tool-summary.cjs.map +1 -0
- package/dist/tools/tool-summary.d.ts +99 -0
- package/dist/tools/tool-summary.js +661 -0
- package/dist/tools/tool-summary.js.map +1 -0
- package/dist/tools/tool-uis.cjs +37 -95
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.js +37 -95
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/tools/voice-update-tool-ui.cjs +1 -1
- package/dist/tools/voice-update-tool-ui.js +1 -1
- package/dist/tools/write-todos-tool-ui.cjs +3 -2
- package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
- package/dist/tools/write-todos-tool-ui.d.ts +5 -0
- package/dist/tools/write-todos-tool-ui.js +5 -4
- package/dist/tools/write-todos-tool-ui.js.map +1 -1
- package/dist/ui/popover.cjs +6 -6
- package/dist/ui/popover.cjs.map +1 -1
- package/dist/ui/popover.js +6 -6
- package/dist/ui/popover.js.map +1 -1
- package/dist/ui/tooltip.cjs +16 -2
- package/dist/ui/tooltip.cjs.map +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/dist/ui/tooltip.js +16 -2
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/voice/use-athena-voice-session.cjs.map +1 -1
- package/dist/voice/use-athena-voice-session.d.ts +3 -3
- package/dist/voice/use-athena-voice-session.js.map +1 -1
- package/dist/workbench/SessionWorkbench.cjs +378 -0
- package/dist/workbench/SessionWorkbench.cjs.map +1 -0
- package/dist/workbench/SessionWorkbench.d.ts +30 -0
- package/dist/workbench/SessionWorkbench.js +378 -0
- package/dist/workbench/SessionWorkbench.js.map +1 -0
- package/dist/workbench/session-workbench-context.cjs +26 -0
- package/dist/workbench/session-workbench-context.cjs.map +1 -0
- package/dist/workbench/session-workbench-context.d.ts +55 -0
- package/dist/workbench/session-workbench-context.js +26 -0
- package/dist/workbench/session-workbench-context.js.map +1 -0
- package/dist/workbench/session-workbench-model.cjs +288 -0
- package/dist/workbench/session-workbench-model.cjs.map +1 -0
- package/dist/workbench/session-workbench-model.d.ts +168 -0
- package/dist/workbench/session-workbench-model.js +288 -0
- package/dist/workbench/session-workbench-model.js.map +1 -0
- package/dist/workbench/session-workbench-panes.cjs +580 -0
- package/dist/workbench/session-workbench-panes.cjs.map +1 -0
- package/dist/workbench/session-workbench-panes.d.ts +16 -0
- package/dist/workbench/session-workbench-panes.js +580 -0
- package/dist/workbench/session-workbench-panes.js.map +1 -0
- package/dist/workbench/session-workspace-api.cjs +157 -0
- package/dist/workbench/session-workspace-api.cjs.map +1 -0
- package/dist/workbench/session-workspace-api.d.ts +70 -0
- package/dist/workbench/session-workspace-api.js +157 -0
- package/dist/workbench/session-workspace-api.js.map +1 -0
- package/dist/workbench/use-session-workspace.cjs +100 -0
- package/dist/workbench/use-session-workspace.cjs.map +1 -0
- package/dist/workbench/use-session-workspace.d.ts +45 -0
- package/dist/workbench/use-session-workspace.js +100 -0
- package/dist/workbench/use-session-workspace.js.map +1 -0
- package/dist/workbench/workbench-layout-context.cjs +10 -0
- package/dist/workbench/workbench-layout-context.cjs.map +1 -0
- package/dist/workbench/workbench-layout-context.d.ts +17 -0
- package/dist/workbench/workbench-layout-context.js +10 -0
- package/dist/workbench/workbench-layout-context.js.map +1 -0
- package/package.json +20 -9
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
- package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/errors.js.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
- package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
- package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/queue.js.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-config.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-config.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
- /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
- /package/dist/{packages/react → react}/package.json.js.map +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
|
@@ -7,9 +7,10 @@ import { resolveStatewireAuthHeaders } from "./statewire-auth-headers.js";
|
|
|
7
7
|
import { statewireSessionKey } from "./statewire-session-key.js";
|
|
8
8
|
import { resolveAgentProp, buildStatewireRunConfig } from "./statewire-run-config.js";
|
|
9
9
|
import { DEFAULT_STATEWIRE_MODEL } from "./statewire-run-config.js";
|
|
10
|
-
import { DEEP_AGENT_DEFAULT_MESSAGE_WINDOW } from "../
|
|
11
|
-
import { useDeepAgentRuntime, logUnhandledStatewireError } from "../
|
|
12
|
-
import { isStatewireChannelTeardown } from "../
|
|
10
|
+
import { DEEP_AGENT_DEFAULT_MESSAGE_WINDOW } from "../agent-runtime/src/generated/runconfig-contract.js";
|
|
11
|
+
import { useDeepAgentRuntime, logUnhandledStatewireError } from "../agent-runtime/src/use-deep-agent-runtime.js";
|
|
12
|
+
import { isStatewireChannelTeardown } from "../agent-runtime/src/errors.js";
|
|
13
|
+
import { withStagedComposerMarkdown } from "../agent-runtime/src/composer-markdown.js";
|
|
13
14
|
const ATHENA_SDK_MESSAGE_WINDOW = {
|
|
14
15
|
size: DEEP_AGENT_DEFAULT_MESSAGE_WINDOW
|
|
15
16
|
};
|
|
@@ -95,6 +96,10 @@ function useAthenaStatewireRuntime(config) {
|
|
|
95
96
|
messageWindow,
|
|
96
97
|
toolOutputs,
|
|
97
98
|
capabilities: { edit: true, reload: true, continue: true },
|
|
99
|
+
// The composer stages the draft each send came from right before it
|
|
100
|
+
// sends; the message carries it as its composer markdown, so its bubble
|
|
101
|
+
// shows the text exactly as typed (`UserMessageText`).
|
|
102
|
+
getMessageMetadata: withStagedComposerMarkdown({ threadId }),
|
|
98
103
|
useClient: useSdkClient,
|
|
99
104
|
onStateChange: () => {
|
|
100
105
|
const endSpan = attachSpanRef.current;
|
|
@@ -119,10 +124,9 @@ function useAthenaStatewireRuntime(config) {
|
|
|
119
124
|
},
|
|
120
125
|
onRawConnectionChange,
|
|
121
126
|
onRunningChange,
|
|
122
|
-
//
|
|
123
|
-
// per-render ref
|
|
124
|
-
//
|
|
125
|
-
// (no `key`: the provider registers once per client).
|
|
127
|
+
// Each model-context notification pulls the latest getter through the
|
|
128
|
+
// core's per-render ref. Consumers commonly pass fresh array literals per
|
|
129
|
+
// render, which must not thrash registration (no `key`: once per client).
|
|
126
130
|
runConfig: {
|
|
127
131
|
get: () => buildStatewireRunConfig({
|
|
128
132
|
model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAthenaStatewireRuntime.js","sources":["../../src/runtime/useAthenaStatewireRuntime.ts"],"sourcesContent":["import type { AssistantClient, Toolkit } from '@assistant-ui/react';\nimport { Tools, useAui } from '@assistant-ui/react';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n type DeepAgentMessageWindowDeclaration,\n type DeepAgentThreadElement,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n isStatewireChannelTeardown,\n logUnhandledStatewireError,\n type RegisteredClientTool,\n useDeepAgentRuntime,\n type UseDeepAgentThreadOptions,\n} from '@athenaintel/agent-runtime';\nimport { useContext, useMemo, useRef } from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n collectStatewireClientTools,\n statewireClientToolWireEntries,\n} from '../chat/statewire-client-tools';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n} from './statewire-auth-headers';\nimport { statewireSessionKey } from './statewire-session-key';\n\ntype AthenaDiagnosticsSpanStarter = typeof athenaDiagnostics.span;\nimport {\n buildStatewireRunConfig,\n DEFAULT_STATEWIRE_MODEL,\n resolveAgentProp,\n} from './statewire-run-config';\n\nexport { DEFAULT_STATEWIRE_MODEL };\n\n/**\n * The head interest every SDK attach states (`athena/interest`): the host\n * mounts the transcript's tail as message documents instead of every message\n * — megabytes on long threads, over the 1 MiB frame limit of stock websocket\n * clients. Older pages load from the `StatewireHistoryEdge` row the chat UI\n * mounts above the messages, and cut tool outputs are fetched back for the\n * cards that show them.\n */\nexport const ATHENA_SDK_MESSAGE_WINDOW: DeepAgentMessageWindowDeclaration = {\n size: DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n};\n\nexport interface AthenaStatewireRuntimeConfig {\n /** Base URL of the statewire sync host (the `…/v2/threads` mount). */\n syncUrl: string;\n /** Thread ID the statewire session attaches to. */\n threadId: string;\n /** True only for a never-started local chat. Existing (or pre-assigned)\n * threads load until their server snapshot arrives. */\n isNewChat?: boolean;\n /** API key for authentication. Used when no auth token is provided. */\n apiKey?: string;\n /** Auth token. Takes priority over apiKey. */\n token?: string | null;\n /** Resolve the latest token immediately before a request (for expiring\n * clients). Called with `{ force: true }` right after the host refused the\n * previous credential (the transport's `staleAuth`), so a caching getter\n * mints a fresh token instead of returning the refused one. */\n getToken?: AthenaStatewireTokenGetter;\n /**\n * Per-provider LRU of each thread's last wire state. A switch back to a\n * remembered thread mounts with that snapshot and projects ready on the\n * first frame instead of a loading treatment; the attach snapshot then\n * replaces it. Owned above the per-thread mount so it survives switches.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /** The head interest stated on the attach (see {@link ATHENA_SDK_MESSAGE_WINDOW}, the default). */\n messageWindow?: DeepAgentMessageWindowDeclaration;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages;\n * the thread re-converts when one lands. `AthenaProvider` owns one per\n * provider and hands the same store to `StatewireHistoryEdge`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /** LLM model identifier. Defaults to the deep-agent default model. */\n model?: string;\n /** Agent selector: only `collab_agent:<asset_id>` refs are accepted (the run\n * executes AS that published collab agent). Any other non-empty value\n * throws — see `resolveAgentProp`. */\n agent?: string;\n /** Collab-agent channel id selecting that channel's overrides. */\n channel?: string;\n /** Backend toolkit IDs to enable. */\n tools?: string[];\n /** Frontend tool IDs to include in enabled_tools. */\n frontendToolIds?: string[];\n /** Frontend tools registered on the assistant client. Tools with a local\n * `execute` are also declared as `client_tools` and executed through the\n * statewire client-tool bridge. */\n frontendToolkit?: Toolkit;\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n /** System prompt override. */\n systemPrompt?: string;\n /** Client app identifier for session filtering. Sent as app_id in runConfig.custom. */\n appId?: string;\n /** Additional fields merged into runConfig.custom. */\n extraRunConfig?: Record<string, unknown>;\n /** Called on statewire transport errors (send rejections, stream failures). */\n onError?: (error: Error) => void;\n /** Projected connection status changes (deduped; null on unmount). */\n onConnectionChange?: UseDeepAgentThreadOptions['onConnectionChange'];\n /** Raw connection observer — carries the transport's reconnect handle. */\n onRawConnectionChange?: UseDeepAgentThreadOptions['onRawConnectionChange'];\n /** Notified when a run starts/stops. */\n onRunningChange?: UseDeepAgentThreadOptions['onRunningChange'];\n}\n\nconst EMPTY_TOOLKIT: Toolkit = {};\nconst EMPTY_TOOL_IDS: string[] = [];\n\n/** The client tools derived from the runtime's frontend toolkit — exposed so\n * the provider can mount the client-tool bridge with the same set. */\nexport function useStatewireClientTools(\n frontendToolkit: Toolkit | undefined,\n): RegisteredClientTool[] {\n return useMemo(\n () => collectStatewireClientTools(frontendToolkit ?? EMPTY_TOOLKIT),\n [frontendToolkit],\n );\n}\n\n/**\n * Statewire runtime for the Athena SDK — a thin shim over the shared\n * `@athenaintel/agent-runtime` `useDeepAgentRuntime`: it attaches to the\n * agora-hosted deep-agent thread at `${syncUrl}/${threadId}` and returns the\n * `AssistantClient` to mount via `AuiProvider` — the same integration shape as\n * the Olympus, Chrome extension, Office, and mobile statewire hosts.\n *\n * Auth: a token (resolved live through `getToken` when provided) rides\n * `Authorization: Bearer`, and an API key falls back to `X-API-KEY` — both\n * accepted by the statewire host.\n */\nexport function useAthenaStatewireRuntime(\n config: AthenaStatewireRuntimeConfig,\n): AssistantClient {\n const {\n syncUrl,\n threadId,\n isNewChat = false,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools = EMPTY_TOOL_IDS,\n frontendToolIds = EMPTY_TOOL_IDS,\n frontendToolkit = EMPTY_TOOLKIT,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n messageWindow = ATHENA_SDK_MESSAGE_WINDOW,\n toolOutputs,\n onError,\n onConnectionChange,\n onRawConnectionChange,\n onRunningChange,\n } = config;\n\n // Fail loud at mount, not at first send: the statewire host always runs the\n // Athena deep agent, so an `agent` outside the collab_agent namespace can\n // never apply. Throwing here (render time) is what makes a misconfigured\n // integration visible instead of quietly answering as the wrong agent.\n resolveAgentProp({ agent });\n\n const clientTools = useStatewireClientTools(frontendToolkit);\n\n // The persisted command lane is keyed by WHO is signed in as well as by host\n // and thread (see `statewireSessionKey`).\n const authContext = useContext(AthenaAuthContext);\n const principal = authContext?.user?.userId ?? '';\n\n // Attach → first server snapshot span, keyed per thread attach.\n const attachSpanRef = useRef<ReturnType<AthenaDiagnosticsSpanStarter> | null>(null);\n const attachThreadRef = useRef<string | null>(null);\n if (attachThreadRef.current !== threadId) {\n attachThreadRef.current = threadId;\n attachSpanRef.current = athenaDiagnostics.span(\n `statewire.attach:${threadId}`,\n 'statewire.attach.start',\n { thread_id: threadId, is_new_chat: isNewChat },\n );\n }\n\n const auiTools = useMemo(() => Tools({ toolkit: frontendToolkit }), [frontendToolkit]);\n // Web client for the shared runtime core (a `use*` name so the\n // rules-of-hooks lint sees the `useAui` call inside a custom hook; the core\n // invokes it unconditionally every render).\n const useSdkClient = (thread: DeepAgentThreadElement) => useAui({ thread, tools: auiTools });\n\n return useDeepAgentRuntime({\n surface: 'AthenaSDK',\n threadId,\n baseUrl: syncUrl,\n // Option closures are re-read per render by the core, so credential\n // rotation (new `token`/`getToken`/`apiKey` props) reaches the next\n // request without remounting the thread. The transport's `staleAuth`\n // (true right after a refused credential) is forwarded as `force`.\n headers: (ctx) => resolveStatewireAuthHeaders({ apiKey, token, getToken }, ctx),\n isNewChat,\n // Queued entries render in the SDK's queue panel, so only the steer lane\n // projects into the message tail.\n laneProjection: 'steer-only',\n // Durable session: a reload resumes the lane and resends whatever the\n // server has not marked durable. Scoped by host AND principal — a thread\n // id is only meaningful against the backend that minted it, and a stored\n // lane must never resend against another signed-in user. (Consumers\n // server-render this SDK; the core's availability probe keeps those\n // sessions process-local, as before the seam existed.)\n session: {\n kind: 'local-storage',\n key: (id) => statewireSessionKey({ syncUrl, principal, threadId: id }),\n },\n snapshotCache,\n // Head interest (see `ATHENA_SDK_MESSAGE_WINDOW`): the tail of the\n // transcript instead of every message; the chat UI's history edge pages\n // older ranges in and fetches cut tool outputs into `toolOutputs`.\n messageWindow,\n toolOutputs,\n capabilities: { edit: true, reload: true, continue: true },\n useClient: useSdkClient,\n onStateChange: () => {\n // First snapshot for this attach ends the attach span (time-to-history).\n const endSpan = attachSpanRef.current;\n if (endSpan) {\n attachSpanRef.current = null;\n endSpan('statewire.snapshot', { data: { thread_id: threadId } });\n }\n },\n onConnectionChange: (connection) => {\n athenaDiagnostics.gauge('statewire.connection', connection?.status ?? null);\n if (connection?.status === 'stopped') {\n athenaDiagnostics.emit('statewire.connection', {\n level: 'warn',\n data: {\n status: connection.status,\n reason: connection.reason,\n message: connection.message,\n },\n });\n }\n onConnectionChange?.(connection);\n },\n onRawConnectionChange,\n onRunningChange,\n // The runConfig getter is pulled at command-send time through the core's\n // per-render ref, so it reads the latest props — consumers commonly pass\n // fresh array literals per render, which must not thrash the registration\n // (no `key`: the provider registers once per client).\n runConfig: {\n get: () =>\n buildStatewireRunConfig({\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n clientTools: statewireClientToolWireEntries(clientTools),\n }),\n },\n onError: (error) => {\n if (!isStatewireChannelTeardown(error)) {\n athenaDiagnostics.error(\n 'statewire.error',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host rejected a command',\n hint: 'Inspect error.detail — agora rejections carry a structured {code, message}.',\n },\n { thread_id: threadId },\n );\n }\n if (onError) {\n onError(error);\n return;\n }\n logUnhandledStatewireError('AthenaSDK', error);\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA4CO,MAAM,4BAA+D;AAAA,EAC1E,MAAM;AACR;AAsEA,MAAM,gBAAyB,CAAA;AAC/B,MAAM,iBAA2B,CAAA;AAI1B,SAAS,wBACd,iBACwB;AACxB,SAAO;AAAA,IACL,MAAM,4BAA4B,mBAAmB,aAAa;AAAA,IAClE,CAAC,eAAe;AAAA,EAAA;AAEpB;AAaO,SAAS,0BACd,QACiB;;AACjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAMJ,mBAAiB,EAAE,OAAO;AAE1B,QAAM,cAAc,wBAAwB,eAAe;AAI3D,QAAM,cAAc,WAAW,iBAAiB;AAChD,QAAM,cAAY,gDAAa,SAAb,mBAAmB,WAAU;AAG/C,QAAM,gBAAgB,OAAwD,IAAI;AAClF,QAAM,kBAAkB,OAAsB,IAAI;AAClD,MAAI,gBAAgB,YAAY,UAAU;AACxC,oBAAgB,UAAU;AAC1B,kBAAc,UAAU,kBAAkB;AAAA,MACxC,oBAAoB,QAAQ;AAAA,MAC5B;AAAA,MACA,EAAE,WAAW,UAAU,aAAa,UAAA;AAAA,IAAU;AAAA,EAElD;AAEA,QAAM,WAAW,QAAQ,MAAM,MAAM,EAAE,SAAS,gBAAA,CAAiB,GAAG,CAAC,eAAe,CAAC;AAIrF,QAAM,eAAe,CAAC,WAAmC,OAAO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a,+BAA+B,WAAW;AAAA,MAAA,CACxD;AAAA,IAAA;AAAA,IAEL,SAAS,CAAC,UAAU;AAClB,UAAI,CAAC,2BAA2B,KAAK,GAAG;AACtC,0BAAkB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,YACT,MAAM;AAAA,UAAA;AAAA,UAER,EAAE,WAAW,SAAA;AAAA,QAAS;AAAA,MAE1B;AACA,UAAI,SAAS;AACX,gBAAQ,KAAK;AACb;AAAA,MACF;AACA,iCAA2B,aAAa,KAAK;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;"}
|
|
1
|
+
{"version":3,"file":"useAthenaStatewireRuntime.js","sources":["../../src/runtime/useAthenaStatewireRuntime.ts"],"sourcesContent":["import type { AssistantClient, Toolkit } from '@assistant-ui/react';\nimport { Tools, useAui } from '@assistant-ui/react';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n type DeepAgentMessageWindowDeclaration,\n type DeepAgentThreadElement,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n isStatewireChannelTeardown,\n logUnhandledStatewireError,\n type RegisteredClientTool,\n useDeepAgentRuntime,\n type UseDeepAgentThreadOptions,\n withStagedComposerMarkdown,\n} from '@athenaintel/agent-runtime';\nimport { useContext, useMemo, useRef } from 'react';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n collectStatewireClientTools,\n statewireClientToolWireEntries,\n} from '../chat/statewire-client-tools';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n type AthenaStatewireTokenGetter,\n resolveStatewireAuthHeaders,\n} from './statewire-auth-headers';\nimport { statewireSessionKey } from './statewire-session-key';\n\ntype AthenaDiagnosticsSpanStarter = typeof athenaDiagnostics.span;\nimport {\n buildStatewireRunConfig,\n DEFAULT_STATEWIRE_MODEL,\n resolveAgentProp,\n} from './statewire-run-config';\n\nexport { DEFAULT_STATEWIRE_MODEL };\n\n/**\n * The head interest every SDK attach states (`athena/interest`): the host\n * mounts the transcript's tail as message documents instead of every message\n * — megabytes on long threads, over the 1 MiB frame limit of stock websocket\n * clients. Older pages load from the `StatewireHistoryEdge` row the chat UI\n * mounts above the messages, and cut tool outputs are fetched back for the\n * cards that show them.\n */\nexport const ATHENA_SDK_MESSAGE_WINDOW: DeepAgentMessageWindowDeclaration = {\n size: DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n};\n\nexport interface AthenaStatewireRuntimeConfig {\n /** Base URL of the statewire sync host (the `…/v2/threads` mount). */\n syncUrl: string;\n /** Thread ID the statewire session attaches to. */\n threadId: string;\n /** True only for a never-started local chat. Existing (or pre-assigned)\n * threads load until their server snapshot arrives. */\n isNewChat?: boolean;\n /** API key for authentication. Used when no auth token is provided. */\n apiKey?: string;\n /** Auth token. Takes priority over apiKey. */\n token?: string | null;\n /** Resolve the latest token immediately before a request (for expiring\n * clients). Called with `{ force: true }` right after the host refused the\n * previous credential (the transport's `staleAuth`), so a caching getter\n * mints a fresh token instead of returning the refused one. */\n getToken?: AthenaStatewireTokenGetter;\n /**\n * Per-provider LRU of each thread's last wire state. A switch back to a\n * remembered thread mounts with that snapshot and projects ready on the\n * first frame instead of a loading treatment; the attach snapshot then\n * replaces it. Owned above the per-thread mount so it survives switches.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /** The head interest stated on the attach (see {@link ATHENA_SDK_MESSAGE_WINDOW}, the default). */\n messageWindow?: DeepAgentMessageWindowDeclaration;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages;\n * the thread re-converts when one lands. `AthenaProvider` owns one per\n * provider and hands the same store to `StatewireHistoryEdge`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /** LLM model identifier. Defaults to the deep-agent default model. */\n model?: string;\n /** Agent selector: only `collab_agent:<asset_id>` refs are accepted (the run\n * executes AS that published collab agent). Any other non-empty value\n * throws — see `resolveAgentProp`. */\n agent?: string;\n /** Collab-agent channel id selecting that channel's overrides. */\n channel?: string;\n /** Backend toolkit IDs to enable. */\n tools?: string[];\n /** Frontend tool IDs to include in enabled_tools. */\n frontendToolIds?: string[];\n /** Frontend tools registered on the assistant client. Tools with a local\n * `execute` are also declared as `client_tools` and executed through the\n * statewire client-tool bridge. */\n frontendToolkit?: Toolkit;\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n /** System prompt override. */\n systemPrompt?: string;\n /** Client app identifier for session filtering. Sent as app_id in runConfig.custom. */\n appId?: string;\n /** Additional fields merged into runConfig.custom. */\n extraRunConfig?: Record<string, unknown>;\n /** Called on statewire transport errors (send rejections, stream failures). */\n onError?: (error: Error) => void;\n /** Projected connection status changes (deduped; null on unmount). */\n onConnectionChange?: UseDeepAgentThreadOptions['onConnectionChange'];\n /** Raw connection observer — carries the transport's reconnect handle. */\n onRawConnectionChange?: UseDeepAgentThreadOptions['onRawConnectionChange'];\n /** Notified when a run starts/stops. */\n onRunningChange?: UseDeepAgentThreadOptions['onRunningChange'];\n}\n\nconst EMPTY_TOOLKIT: Toolkit = {};\nconst EMPTY_TOOL_IDS: string[] = [];\n\n/** The client tools derived from the runtime's frontend toolkit — exposed so\n * the provider can mount the client-tool bridge with the same set. */\nexport function useStatewireClientTools(\n frontendToolkit: Toolkit | undefined,\n): RegisteredClientTool[] {\n return useMemo(\n () => collectStatewireClientTools(frontendToolkit ?? EMPTY_TOOLKIT),\n [frontendToolkit],\n );\n}\n\n/**\n * Statewire runtime for the Athena SDK — a thin shim over the shared\n * `@athenaintel/agent-runtime` `useDeepAgentRuntime`: it attaches to the\n * agora-hosted deep-agent thread at `${syncUrl}/${threadId}` and returns the\n * `AssistantClient` to mount via `AuiProvider` — the same integration shape as\n * the Olympus, Chrome extension, Office, and mobile statewire hosts.\n *\n * Auth: a token (resolved live through `getToken` when provided) rides\n * `Authorization: Bearer`, and an API key falls back to `X-API-KEY` — both\n * accepted by the statewire host.\n */\nexport function useAthenaStatewireRuntime(\n config: AthenaStatewireRuntimeConfig,\n): AssistantClient {\n const {\n syncUrl,\n threadId,\n isNewChat = false,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools = EMPTY_TOOL_IDS,\n frontendToolIds = EMPTY_TOOL_IDS,\n frontendToolkit = EMPTY_TOOLKIT,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n messageWindow = ATHENA_SDK_MESSAGE_WINDOW,\n toolOutputs,\n onError,\n onConnectionChange,\n onRawConnectionChange,\n onRunningChange,\n } = config;\n\n // Fail loud at mount, not at first send: the statewire host always runs the\n // Athena deep agent, so an `agent` outside the collab_agent namespace can\n // never apply. Throwing here (render time) is what makes a misconfigured\n // integration visible instead of quietly answering as the wrong agent.\n resolveAgentProp({ agent });\n\n const clientTools = useStatewireClientTools(frontendToolkit);\n\n // The persisted command lane is keyed by WHO is signed in as well as by host\n // and thread (see `statewireSessionKey`).\n const authContext = useContext(AthenaAuthContext);\n const principal = authContext?.user?.userId ?? '';\n\n // Attach → first server snapshot span, keyed per thread attach.\n const attachSpanRef = useRef<ReturnType<AthenaDiagnosticsSpanStarter> | null>(null);\n const attachThreadRef = useRef<string | null>(null);\n if (attachThreadRef.current !== threadId) {\n attachThreadRef.current = threadId;\n attachSpanRef.current = athenaDiagnostics.span(\n `statewire.attach:${threadId}`,\n 'statewire.attach.start',\n { thread_id: threadId, is_new_chat: isNewChat },\n );\n }\n\n const auiTools = useMemo(() => Tools({ toolkit: frontendToolkit }), [frontendToolkit]);\n // Web client for the shared runtime core (a `use*` name so the\n // rules-of-hooks lint sees the `useAui` call inside a custom hook; the core\n // invokes it unconditionally every render).\n const useSdkClient = (thread: DeepAgentThreadElement) => useAui({ thread, tools: auiTools });\n\n return useDeepAgentRuntime({\n surface: 'AthenaSDK',\n threadId,\n baseUrl: syncUrl,\n // Option closures are re-read per render by the core, so credential\n // rotation (new `token`/`getToken`/`apiKey` props) reaches the next\n // request without remounting the thread. The transport's `staleAuth`\n // (true right after a refused credential) is forwarded as `force`.\n headers: (ctx) => resolveStatewireAuthHeaders({ apiKey, token, getToken }, ctx),\n isNewChat,\n // Queued entries render in the SDK's queue panel, so only the steer lane\n // projects into the message tail.\n laneProjection: 'steer-only',\n // Durable session: a reload resumes the lane and resends whatever the\n // server has not marked durable. Scoped by host AND principal — a thread\n // id is only meaningful against the backend that minted it, and a stored\n // lane must never resend against another signed-in user. (Consumers\n // server-render this SDK; the core's availability probe keeps those\n // sessions process-local, as before the seam existed.)\n session: {\n kind: 'local-storage',\n key: (id) => statewireSessionKey({ syncUrl, principal, threadId: id }),\n },\n snapshotCache,\n // Head interest (see `ATHENA_SDK_MESSAGE_WINDOW`): the tail of the\n // transcript instead of every message; the chat UI's history edge pages\n // older ranges in and fetches cut tool outputs into `toolOutputs`.\n messageWindow,\n toolOutputs,\n capabilities: { edit: true, reload: true, continue: true },\n // The composer stages the draft each send came from right before it\n // sends; the message carries it as its composer markdown, so its bubble\n // shows the text exactly as typed (`UserMessageText`).\n getMessageMetadata: withStagedComposerMarkdown({ threadId }),\n useClient: useSdkClient,\n onStateChange: () => {\n // First snapshot for this attach ends the attach span (time-to-history).\n const endSpan = attachSpanRef.current;\n if (endSpan) {\n attachSpanRef.current = null;\n endSpan('statewire.snapshot', { data: { thread_id: threadId } });\n }\n },\n onConnectionChange: (connection) => {\n athenaDiagnostics.gauge('statewire.connection', connection?.status ?? null);\n if (connection?.status === 'stopped') {\n athenaDiagnostics.emit('statewire.connection', {\n level: 'warn',\n data: {\n status: connection.status,\n reason: connection.reason,\n message: connection.message,\n },\n });\n }\n onConnectionChange?.(connection);\n },\n onRawConnectionChange,\n onRunningChange,\n // Each model-context notification pulls the latest getter through the\n // core's per-render ref. Consumers commonly pass fresh array literals per\n // render, which must not thrash registration (no `key`: once per client).\n runConfig: {\n get: () =>\n buildStatewireRunConfig({\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n clientTools: statewireClientToolWireEntries(clientTools),\n }),\n },\n onError: (error) => {\n if (!isStatewireChannelTeardown(error)) {\n athenaDiagnostics.error(\n 'statewire.error',\n error,\n {\n code: 'statewire_rejected',\n message: 'The statewire host rejected a command',\n hint: 'Inspect error.detail — agora rejections carry a structured {code, message}.',\n },\n { thread_id: threadId },\n );\n }\n if (onError) {\n onError(error);\n return;\n }\n logUnhandledStatewireError('AthenaSDK', error);\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA6CO,MAAM,4BAA+D;AAAA,EAC1E,MAAM;AACR;AAsEA,MAAM,gBAAyB,CAAA;AAC/B,MAAM,iBAA2B,CAAA;AAI1B,SAAS,wBACd,iBACwB;AACxB,SAAO;AAAA,IACL,MAAM,4BAA4B,mBAAmB,aAAa;AAAA,IAClE,CAAC,eAAe;AAAA,EAAA;AAEpB;AAaO,SAAS,0BACd,QACiB;;AACjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAMJ,mBAAiB,EAAE,OAAO;AAE1B,QAAM,cAAc,wBAAwB,eAAe;AAI3D,QAAM,cAAc,WAAW,iBAAiB;AAChD,QAAM,cAAY,gDAAa,SAAb,mBAAmB,WAAU;AAG/C,QAAM,gBAAgB,OAAwD,IAAI;AAClF,QAAM,kBAAkB,OAAsB,IAAI;AAClD,MAAI,gBAAgB,YAAY,UAAU;AACxC,oBAAgB,UAAU;AAC1B,kBAAc,UAAU,kBAAkB;AAAA,MACxC,oBAAoB,Q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AAAA,QACtB,CACD;AAAA,MACH;AACA,+DAAqB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,WAAW;AAAA,MACT,KAAK,MACH,wBAAwB;AAAA,QACtB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAa,+BAA+B,WAAW;AAAA,MAAA,CACxD;AAAA,IAAA;AAAA,IAEL,SAAS,CAAC,UAAU;AAClB,UAAI,CAAC,2BAA2B,KAAK,GAAG;AACtC,0BAAkB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,YACT,MAAM;AAAA,UAAA;AAAA,UAER,EAAE,WAAW,SAAA;AAAA,QAAS;AAAA,MAE1B;AACA,UAAI,SAAS;AACX,gBAAQ,KAAK;AACb;AAAA,MACF;AACA,iCAA2B,aAAa,KAAK;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const reactQuery = require("@tanstack/react-query");
|
|
4
|
-
const react = require("react");
|
|
5
4
|
const mint = require("../collab/mint.cjs");
|
|
6
5
|
const errors = require("../diagnostics/errors.cjs");
|
|
6
|
+
const useAthenaRestQuery = require("../lib/use-athena-rest-query.cjs");
|
|
7
7
|
const AthenaContext = require("../provider/AthenaContext.cjs");
|
|
8
8
|
const credentialRenewal = require("../runtime/credential-renewal.cjs");
|
|
9
|
-
const credentialShape = require("../threads/credential-shape.cjs");
|
|
10
9
|
const ATHENA_REPO_SEARCH_PATH = "/api/search/repositories";
|
|
11
10
|
function repoSearchRequestBody(params) {
|
|
12
11
|
var _a, _b, _c;
|
|
@@ -61,19 +60,12 @@ function useAthenaRepoSearch({
|
|
|
61
60
|
}) {
|
|
62
61
|
const config = AthenaContext.useAthenaConfig();
|
|
63
62
|
const { backendUrl, apiKey, getToken } = config;
|
|
64
|
-
const
|
|
65
|
-
const generationRef = react.useRef(0);
|
|
66
|
-
const currentCredentials = credentialShape.credentialShape({ apiKey, token: config.token, getToken });
|
|
67
|
-
if (!credentialShape.sameCredentialShape(credentialsRef.current, currentCredentials)) {
|
|
68
|
-
credentialsRef.current = currentCredentials;
|
|
69
|
-
generationRef.current += 1;
|
|
70
|
-
}
|
|
63
|
+
const identity = useAthenaRestQuery.useAthenaQueryIdentity({ apiKey, token: config.token, getToken });
|
|
71
64
|
const body = repoSearchRequestBody(params);
|
|
72
|
-
const
|
|
73
|
-
const [fallbackClient] = react.useState(() => contextClient ? void 0 : new reactQuery.QueryClient());
|
|
65
|
+
const queryClient = useAthenaRestQuery.useAthenaQueryClient();
|
|
74
66
|
return reactQuery.useQuery(
|
|
75
67
|
{
|
|
76
|
-
queryKey: ["athena-sdk", "repo-search", backendUrl,
|
|
68
|
+
queryKey: ["athena-sdk", "repo-search", backendUrl, ...identity, body],
|
|
77
69
|
// `config.token` is read at fetch time: the provider serves the latest
|
|
78
70
|
// token through a getter, so rotations reach the request.
|
|
79
71
|
queryFn: ({ signal }) => fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),
|
|
@@ -82,7 +74,7 @@ function useAthenaRepoSearch({
|
|
|
82
74
|
placeholderData: reactQuery.keepPreviousData,
|
|
83
75
|
refetchOnWindowFocus: false
|
|
84
76
|
},
|
|
85
|
-
|
|
77
|
+
queryClient
|
|
86
78
|
);
|
|
87
79
|
}
|
|
88
80
|
exports.ATHENA_REPO_SEARCH_PATH = ATHENA_REPO_SEARCH_PATH;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAthenaRepoSearch.cjs","sources":["../../src/search/useAthenaRepoSearch.ts"],"sourcesContent":["/**\n * Code search over the workspace's indexed repositories —\n * `POST /api/search/repositories` (agora `web/api/search/repositories.py`),\n * the HTTP face of Clio's repository source for a Devin-style \"Ask\" surface\n * that searches the monorepo without an agent turn. Athena platform staff\n * only (the account-level `is_admin`, not a workspace role) on the managed\n * cloud today: a non-staff caller reads `403`, a private deployment `404`.\n */\nimport {\n keepPreviousData,\n QueryClient,\n QueryClientContext,\n useQuery,\n type UseQueryResult,\n} from '@tanstack/react-query';\nimport { useContext, useRef, useState } from 'react';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport { sendWithCredentialRenewal } from '../runtime/credential-renewal';\nimport type { StatewireAuthSource } from '../runtime/statewire-auth-headers';\nimport { credentialShape, sameCredentialShape } from '../threads/credential-shape';\n\nexport type AthenaRepoSearchMode = 'hybrid' | 'lexical';\n\n/** One file range of one indexed repository, as the route serves it. */\nexport interface AthenaRepoSearchHit {\n /** The GitHub catalog asset the repository is connected through. */\n catalogAssetId: string;\n /** `owner/repo`; `null` when the catalog names no repository. */\n repoFullName: string | null;\n /** Repo-relative, `/`-separated. */\n path: string;\n /** 1-based, inclusive. */\n startLine: number;\n endLine: number;\n /** The enclosing declaration (`Class.method`) when the chunk's header named one. */\n symbol: string | null;\n /** Clio's language name for the file (`python`, `typescript`, …). */\n language: string | null;\n /** `code` (an AST chunk) or `window` (a Markdown heading window). */\n unitType: string;\n score: number;\n /** The indexed commit the hit was read at. */\n commitSha: string | null;\n /** `{origin}/{owner}/{repo}/blob/{sha}/{path}#L{a}-L{b}`, GHES-aware. */\n githubUrl: string | null;\n /** The chunk's lines, header line removed, line breaks preserved. */\n snippet: string;\n /** `asset_<catalog>?anchor=file_line_range&…` — what `read_asset` and a citation take. */\n readAssetReference: string;\n}\n\nexport interface AthenaRepoSearchResponse {\n /** Best first, at most `limit`. */\n hits: AthenaRepoSearchHit[];\n tookMs: number;\n mode: AthenaRepoSearchMode;\n}\n\nexport interface AthenaRepoSearchParams {\n query: string;\n /** 1–25; the route's default is 10. */\n limit?: number;\n /** `hybrid` (default) or `lexical`. */\n mode?: AthenaRepoSearchMode;\n /** Search these GitHub catalog assets only; empty means every indexed repository. */\n repositoryAssetIds?: string[];\n /** gitignore-style globs a hit's path must match (`agora/**\\/*.py`, `docs/`). */\n paths?: string[];\n /** Clio language names a hit's file must be indexed as. */\n languages?: string[];\n}\n\nexport interface UseAthenaRepoSearchOptions extends AthenaRepoSearchParams {\n /** `false` holds the query idle (a blank `query` does too). Default `true`. */\n enabled?: boolean;\n}\n\n/** The route's JSON body — snake_case, unset filters omitted. */\nexport interface AthenaRepoSearchRequestBody {\n query: string;\n limit?: number;\n mode?: AthenaRepoSearchMode;\n repository_asset_ids?: string[];\n paths?: string[];\n languages?: string[];\n}\n\nexport const ATHENA_REPO_SEARCH_PATH = '/api/search/repositories';\n\nexport function repoSearchRequestBody(params: AthenaRepoSearchParams): AthenaRepoSearchRequestBody {\n const body: AthenaRepoSearchRequestBody = { query: params.query.trim() };\n if (params.limit !== undefined) body.limit = params.limit;\n if (params.mode !== undefined) body.mode = params.mode;\n if (params.repositoryAssetIds?.length) body.repository_asset_ids = params.repositoryAssetIds;\n if (params.paths?.length) body.paths = params.paths;\n if (params.languages?.length) body.languages = params.languages;\n return body;\n}\n\n/** A `fetch` the caller cancelled (unmount, a newer query): lifecycle, not failure. */\nfunction isAbortError(error: unknown): boolean {\n return (error instanceof DOMException || error instanceof Error) && error.name === 'AbortError';\n}\n\n/**\n * One search request. The credential rides `Authorization: Bearer` (a token,\n * resolved live through `getToken` when the host provided one) or\n * `X-API-KEY`; with neither, a same-origin host's session cookie rides\n * automatically, as the SDK's other REST helpers allow. A refused bearer\n * (`401`) gets one forced re-mint through `getToken` (`force: true`, the\n * statewire transport's `staleAuth` contract; `sendWithCredentialRenewal`) — a\n * getter that caches until forced would otherwise resend the same expired\n * token on every retry. Every failure is an `AthenaSdkError`, transport\n * rejections included; only an abort keeps its own identity.\n */\nexport async function fetchRepoSearch(\n backendUrl: string,\n auth: StatewireAuthSource,\n params: AthenaRepoSearchParams,\n opts: { signal?: AbortSignal } = {},\n): Promise<AthenaRepoSearchResponse> {\n const url = `${getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;\n const body = JSON.stringify(repoSearchRequestBody(params));\n const post = async (headers: Record<string, string>): Promise<Response> => {\n try {\n return await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body,\n signal: opts.signal ?? null,\n });\n } catch (error) {\n if (isAbortError(error)) throw error;\n throw new AthenaSdkError({\n code: 'repo_search_failed',\n message: 'Repository search could not reach the Agora API.',\n cause: error,\n hint: 'Check the network and that backendUrl points at the Agora API base.',\n });\n }\n };\n const res = await sendWithCredentialRenewal(auth, post);\n if (!res.ok) {\n const refused = res.status === 401 || res.status === 403;\n throw new AthenaSdkError({\n code: refused ? 'auth_rejected' : 'repo_search_failed',\n message: `Repository search failed: ${res.status}`,\n status: res.status,\n detail: await res.json().catch(() => undefined),\n hint: refused\n ? 'Repository search is limited to Athena platform staff on the managed cloud; check the credential.'\n : res.status === 404\n ? 'Repository search is not offered on this deployment (managed cloud only).'\n : 'Check backendUrl points at the Agora API base and that Clio is available.',\n });\n }\n return (await res.json()) as AthenaRepoSearchResponse;\n}\n\n/**\n * Search the indexed repositories through TanStack Query with the provider's\n * `backendUrl` and credentials. Keyed by the non-secret request and a\n * credential generation (a counter that advances when the host's credentials\n * change), never by the credential itself. Uses the host's `QueryClient` when\n * one is in context (`enableThreadList` mounts the SDK's own) and a\n * hook-scoped client otherwise, so it works under any `<AthenaProvider>`.\n */\nexport function useAthenaRepoSearch({\n enabled = true,\n ...params\n}: UseAthenaRepoSearchOptions): UseQueryResult<AthenaRepoSearchResponse, Error> {\n const config = useAthenaConfig();\n const { backendUrl, apiKey, getToken } = config;\n const credentialsRef = useRef(credentialShape({ apiKey, token: config.token, getToken }));\n const generationRef = useRef(0);\n const currentCredentials = credentialShape({ apiKey, token: config.token, getToken });\n if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {\n credentialsRef.current = currentCredentials;\n generationRef.current += 1;\n }\n const body = repoSearchRequestBody(params);\n const contextClient = useContext(QueryClientContext);\n const [fallbackClient] = useState(() => (contextClient ? undefined : new QueryClient()));\n return useQuery(\n {\n queryKey: ['athena-sdk', 'repo-search', backendUrl, generationRef.current, body],\n // `config.token` is read at fetch time: the provider serves the latest\n // token through a getter, so rotations reach the request.\n queryFn: ({ signal }) =>\n fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),\n enabled: enabled && body.query.length > 0 && backendUrl.length > 0,\n staleTime: 30_000,\n placeholderData: keepPreviousData,\n refetchOnWindowFocus: false,\n },\n contextClient ?? fallbackClient,\n );\n}\n"],"names":["getAthenaApiBaseUrl","AthenaSdkError","sendWithCredentialRenewal","useAthenaConfig","useRef","credentialShape","sameCredentialShape","useContext","QueryClientContext","useState","QueryClient","useQuery","keepPreviousData"],"mappings":";;;;;;;;;AAyFO,MAAM,0BAA0B;AAEhC,SAAS,sBAAsB,QAA6D;;AACjG,QAAM,OAAoC,EAAE,OAAO,OAAO,MAAM,OAAK;AACrE,MAAI,OAAO,UAAU,OAAW,MAAK,QAAQ,OAAO;AACpD,MAAI,OAAO,SAAS,OAAW,MAAK,OAAO,OAAO;AAClD,OAAI,YAAO,uBAAP,mBAA2B,OAAQ,MAAK,uBAAuB,OAAO;AAC1E,OAAI,YAAO,UAAP,mBAAc,OAAQ,MAAK,QAAQ,OAAO;AAC9C,OAAI,YAAO,cAAP,mBAAkB,OAAQ,MAAK,YAAY,OAAO;AACtD,SAAO;AACT;AAGA,SAAS,aAAa,OAAyB;AAC7C,UAAQ,iBAAiB,gBAAgB,iBAAiB,UAAU,MAAM,SAAS;AACrF;AAaA,eAAsB,gBACpB,YACA,MACA,QACA,OAAiC,CAAA,GACE;AACnC,QAAM,MAAM,GAAGA,KAAAA,oBAAoB,UAAU,CAAC,GAAG,uBAAuB;AACxE,QAAM,OAAO,KAAK,UAAU,sB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eAAe,SAAS,kBAAkB,GAAG;AACpE,mBAAe,UAAU;AACzB,kBAAc,WAAW;AAAA,EAC3B;AACA,QAAM,OAAO,sBAAsB,MAAM;AACzC,QAAM,gBAAgBC,MAAAA,WAAWC,6BAAkB;AACnD,QAAM,CAAC,cAAc,IAAIC,MAAAA,SAAS,MAAO,gBAAgB,SAAY,IAAIC,WAAAA,aAAc;AACvF,SAAOC,WAAAA;AAAAA,IACL;AAAA,MACE,UAAU,CAAC,cAAc,eAAe,YAAY,cAAc,SAAS,IAAI;AAAA;AAAA;AAAA,MAG/E,SAAS,CAAC,EAAE,OAAA,MACV,gBAAgB,YAAY,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,GAAY,QAAQ,EAAE,QAAQ;AAAA,MAC3F,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,WAAW,SAAS;AAAA,MACjE,WAAW;AAAA,MACX,iBAAiBC,WAAAA;AAAAA,MACjB,sBAAsB;AAAA,IAAA;AAAA,IAExB,iBAAiB;AAAA,EAAA;AAErB;;;;;"}
|
|
1
|
+
{"version":3,"file":"useAthenaRepoSearch.cjs","sources":["../../src/search/useAthenaRepoSearch.ts"],"sourcesContent":["/**\n * Code search over the workspace's indexed repositories —\n * `POST /api/search/repositories` (agora `web/api/search/repositories.py`),\n * the HTTP face of Clio's repository source for a Devin-style \"Ask\" surface\n * that searches the monorepo without an agent turn. Athena platform staff\n * only (the account-level `is_admin`, not a workspace role) on the managed\n * cloud today: a non-staff caller reads `403`, a private deployment `404`.\n */\nimport { keepPreviousData, useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaQueryClient, useAthenaQueryIdentity } from '../lib/use-athena-rest-query';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport { sendWithCredentialRenewal } from '../runtime/credential-renewal';\nimport type { StatewireAuthSource } from '../runtime/statewire-auth-headers';\n\nexport type AthenaRepoSearchMode = 'hybrid' | 'lexical';\n\n/** One file range of one indexed repository, as the route serves it. */\nexport interface AthenaRepoSearchHit {\n /** The GitHub catalog asset the repository is connected through. */\n catalogAssetId: string;\n /** `owner/repo`; `null` when the catalog names no repository. */\n repoFullName: string | null;\n /** Repo-relative, `/`-separated. */\n path: string;\n /** 1-based, inclusive. */\n startLine: number;\n endLine: number;\n /** The enclosing declaration (`Class.method`) when the chunk's header named one. */\n symbol: string | null;\n /** Clio's language name for the file (`python`, `typescript`, …). */\n language: string | null;\n /** `code` (an AST chunk) or `window` (a Markdown heading window). */\n unitType: string;\n score: number;\n /** The indexed commit the hit was read at. */\n commitSha: string | null;\n /** `{origin}/{owner}/{repo}/blob/{sha}/{path}#L{a}-L{b}`, GHES-aware. */\n githubUrl: string | null;\n /** The chunk's lines, header line removed, line breaks preserved. */\n snippet: string;\n /** `asset_<catalog>?anchor=file_line_range&…` — what `read_asset` and a citation take. */\n readAssetReference: string;\n}\n\nexport interface AthenaRepoSearchResponse {\n /** Best first, at most `limit`. */\n hits: AthenaRepoSearchHit[];\n tookMs: number;\n mode: AthenaRepoSearchMode;\n}\n\nexport interface AthenaRepoSearchParams {\n query: string;\n /** 1–25; the route's default is 10. */\n limit?: number;\n /** `hybrid` (default) or `lexical`. */\n mode?: AthenaRepoSearchMode;\n /** Search these GitHub catalog assets only; empty means every indexed repository. */\n repositoryAssetIds?: string[];\n /** gitignore-style globs a hit's path must match (`agora/**\\/*.py`, `docs/`). */\n paths?: string[];\n /** Clio language names a hit's file must be indexed as. */\n languages?: string[];\n}\n\nexport interface UseAthenaRepoSearchOptions extends AthenaRepoSearchParams {\n /** `false` holds the query idle (a blank `query` does too). Default `true`. */\n enabled?: boolean;\n}\n\n/** The route's JSON body — snake_case, unset filters omitted. */\nexport interface AthenaRepoSearchRequestBody {\n query: string;\n limit?: number;\n mode?: AthenaRepoSearchMode;\n repository_asset_ids?: string[];\n paths?: string[];\n languages?: string[];\n}\n\nexport const ATHENA_REPO_SEARCH_PATH = '/api/search/repositories';\n\nexport function repoSearchRequestBody(params: AthenaRepoSearchParams): AthenaRepoSearchRequestBody {\n const body: AthenaRepoSearchRequestBody = { query: params.query.trim() };\n if (params.limit !== undefined) body.limit = params.limit;\n if (params.mode !== undefined) body.mode = params.mode;\n if (params.repositoryAssetIds?.length) body.repository_asset_ids = params.repositoryAssetIds;\n if (params.paths?.length) body.paths = params.paths;\n if (params.languages?.length) body.languages = params.languages;\n return body;\n}\n\n/** A `fetch` the caller cancelled (unmount, a newer query): lifecycle, not failure. */\nfunction isAbortError(error: unknown): boolean {\n return (error instanceof DOMException || error instanceof Error) && error.name === 'AbortError';\n}\n\n/**\n * One search request. The credential rides `Authorization: Bearer` (a token,\n * resolved live through `getToken` when the host provided one) or\n * `X-API-KEY`; with neither, a same-origin host's session cookie rides\n * automatically, as the SDK's other REST helpers allow. A refused bearer\n * (`401`) gets one forced re-mint through `getToken` (`force: true`, the\n * statewire transport's `staleAuth` contract; `sendWithCredentialRenewal`) — a\n * getter that caches until forced would otherwise resend the same expired\n * token on every retry. Every failure is an `AthenaSdkError`, transport\n * rejections included; only an abort keeps its own identity.\n */\nexport async function fetchRepoSearch(\n backendUrl: string,\n auth: StatewireAuthSource,\n params: AthenaRepoSearchParams,\n opts: { signal?: AbortSignal } = {},\n): Promise<AthenaRepoSearchResponse> {\n const url = `${getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;\n const body = JSON.stringify(repoSearchRequestBody(params));\n const post = async (headers: Record<string, string>): Promise<Response> => {\n try {\n return await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body,\n signal: opts.signal ?? null,\n });\n } catch (error) {\n if (isAbortError(error)) throw error;\n throw new AthenaSdkError({\n code: 'repo_search_failed',\n message: 'Repository search could not reach the Agora API.',\n cause: error,\n hint: 'Check the network and that backendUrl points at the Agora API base.',\n });\n }\n };\n const res = await sendWithCredentialRenewal(auth, post);\n if (!res.ok) {\n const refused = res.status === 401 || res.status === 403;\n throw new AthenaSdkError({\n code: refused ? 'auth_rejected' : 'repo_search_failed',\n message: `Repository search failed: ${res.status}`,\n status: res.status,\n detail: await res.json().catch(() => undefined),\n hint: refused\n ? 'Repository search is limited to Athena platform staff on the managed cloud; check the credential.'\n : res.status === 404\n ? 'Repository search is not offered on this deployment (managed cloud only).'\n : 'Check backendUrl points at the Agora API base and that Clio is available.',\n });\n }\n return (await res.json()) as AthenaRepoSearchResponse;\n}\n\n/**\n * Search the indexed repositories through TanStack Query with the provider's\n * `backendUrl` and credentials. Keyed by the non-secret request, the signed-in\n * principal and a credential generation (a counter that advances when the\n * host's credentials change), never by the credential itself. Uses the host's `QueryClient` when\n * one is in context (`enableThreadList` mounts the SDK's own) and a\n * hook-scoped client otherwise, so it works under any `<AthenaProvider>`.\n */\nexport function useAthenaRepoSearch({\n enabled = true,\n ...params\n}: UseAthenaRepoSearchOptions): UseQueryResult<AthenaRepoSearchResponse, Error> {\n const config = useAthenaConfig();\n const { backendUrl, apiKey, getToken } = config;\n const identity = useAthenaQueryIdentity({ apiKey, token: config.token, getToken });\n const body = repoSearchRequestBody(params);\n const queryClient = useAthenaQueryClient();\n return useQuery(\n {\n queryKey: ['athena-sdk', 'repo-search', backendUrl, ...identity, body],\n // `config.token` is read at fetch time: the provider serves the latest\n // token through a getter, so rotations reach the request.\n queryFn: ({ signal }) =>\n fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),\n enabled: enabled && body.query.length > 0 && backendUrl.length > 0,\n staleTime: 30_000,\n placeholderData: keepPreviousData,\n refetchOnWindowFocus: false,\n },\n queryClient,\n );\n}\n"],"names":["getAthenaApiBaseUrl","AthenaSdkError","sendWithCredentialRenewal","useAthenaConfig","useAthenaQueryIdentity","useAthenaQueryClient","useQuery","keepPreviousData"],"mappings":";;;;;;;;AAkFO,MAAM,0BAA0B;AAEhC,SAAS,sBAAsB,QAA6D;;AACjG,QAAM,OAAoC,EAAE,OAAO,OAA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AAQ,MAAM,IAAI,OAAO,MAAM,MAAM,MAAS;AAAA,MAC9C,MAAM,UACF,sGACA,IAAI,WAAW,MACb,8EACA;AAAA,IAAA,CACP;AAAA,EACH;AACA,SAAQ,MAAM,IAAI,KAAA;AACpB;AAUO,SAAS,oBAAoB;AAAA,EAClC,UAAU;AAAA,EACV,GAAG;AACL,GAAgF;AAC9E,QAAM,SAASE,cAAAA,gBAAA;AACf,QAAM,EAAE,YAAY,QAAQ,SAAA,IAAa;AACzC,QAAM,WAAWC,mBAAAA,uBAAuB,EAAE,QAAQ,OAAO,OAAO,OAAO,UAAU;AACjF,QAAM,OAAO,sBAAsB,MAAM;AACzC,QAAM,cAAcC,mBAAAA,qBAAA;AACpB,SAAOC,WAAAA;AAAAA,IACL;AAAA,MACE,UAAU,CAAC,cAAc,eAAe,YAAY,GAAG,UAAU,IAAI;AAAA;AAAA;AAAA,MAGrE,SAAS,CAAC,EAAE,OAAA,MACV,gBAAgB,YAAY,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,GAAY,QAAQ,EAAE,QAAQ;AAAA,MAC3F,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,WAAW,SAAS;AAAA,MACjE,WAAW;AAAA,MACX,iBAAiBC,WAAAA;AAAAA,MACjB,sBAAsB;AAAA,IAAA;AAAA,IAExB;AAAA,EAAA;AAEJ;;;;;"}
|
|
@@ -86,9 +86,9 @@ export declare function fetchRepoSearch(backendUrl: string, auth: StatewireAuthS
|
|
|
86
86
|
}): Promise<AthenaRepoSearchResponse>;
|
|
87
87
|
/**
|
|
88
88
|
* Search the indexed repositories through TanStack Query with the provider's
|
|
89
|
-
* `backendUrl` and credentials. Keyed by the non-secret request
|
|
90
|
-
* credential generation (a counter that advances when the
|
|
91
|
-
* change), never by the credential itself. Uses the host's `QueryClient` when
|
|
89
|
+
* `backendUrl` and credentials. Keyed by the non-secret request, the signed-in
|
|
90
|
+
* principal and a credential generation (a counter that advances when the
|
|
91
|
+
* host's credentials change), never by the credential itself. Uses the host's `QueryClient` when
|
|
92
92
|
* one is in context (`enableThreadList` mounts the SDK's own) and a
|
|
93
93
|
* hook-scoped client otherwise, so it works under any `<AthenaProvider>`.
|
|
94
94
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef, useContext, useState } from "react";
|
|
1
|
+
import { useQuery, keepPreviousData } from "@tanstack/react-query";
|
|
3
2
|
import { getAthenaApiBaseUrl } from "../collab/mint.js";
|
|
4
3
|
import { AthenaSdkError } from "../diagnostics/errors.js";
|
|
4
|
+
import { useAthenaQueryIdentity, useAthenaQueryClient } from "../lib/use-athena-rest-query.js";
|
|
5
5
|
import { useAthenaConfig } from "../provider/AthenaContext.js";
|
|
6
6
|
import { sendWithCredentialRenewal } from "../runtime/credential-renewal.js";
|
|
7
|
-
import { credentialShape, sameCredentialShape } from "../threads/credential-shape.js";
|
|
8
7
|
const ATHENA_REPO_SEARCH_PATH = "/api/search/repositories";
|
|
9
8
|
function repoSearchRequestBody(params) {
|
|
10
9
|
var _a, _b, _c;
|
|
@@ -59,19 +58,12 @@ function useAthenaRepoSearch({
|
|
|
59
58
|
}) {
|
|
60
59
|
const config = useAthenaConfig();
|
|
61
60
|
const { backendUrl, apiKey, getToken } = config;
|
|
62
|
-
const
|
|
63
|
-
const generationRef = useRef(0);
|
|
64
|
-
const currentCredentials = credentialShape({ apiKey, token: config.token, getToken });
|
|
65
|
-
if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {
|
|
66
|
-
credentialsRef.current = currentCredentials;
|
|
67
|
-
generationRef.current += 1;
|
|
68
|
-
}
|
|
61
|
+
const identity = useAthenaQueryIdentity({ apiKey, token: config.token, getToken });
|
|
69
62
|
const body = repoSearchRequestBody(params);
|
|
70
|
-
const
|
|
71
|
-
const [fallbackClient] = useState(() => contextClient ? void 0 : new QueryClient());
|
|
63
|
+
const queryClient = useAthenaQueryClient();
|
|
72
64
|
return useQuery(
|
|
73
65
|
{
|
|
74
|
-
queryKey: ["athena-sdk", "repo-search", backendUrl,
|
|
66
|
+
queryKey: ["athena-sdk", "repo-search", backendUrl, ...identity, body],
|
|
75
67
|
// `config.token` is read at fetch time: the provider serves the latest
|
|
76
68
|
// token through a getter, so rotations reach the request.
|
|
77
69
|
queryFn: ({ signal }) => fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),
|
|
@@ -80,7 +72,7 @@ function useAthenaRepoSearch({
|
|
|
80
72
|
placeholderData: keepPreviousData,
|
|
81
73
|
refetchOnWindowFocus: false
|
|
82
74
|
},
|
|
83
|
-
|
|
75
|
+
queryClient
|
|
84
76
|
);
|
|
85
77
|
}
|
|
86
78
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAthenaRepoSearch.js","sources":["../../src/search/useAthenaRepoSearch.ts"],"sourcesContent":["/**\n * Code search over the workspace's indexed repositories —\n * `POST /api/search/repositories` (agora `web/api/search/repositories.py`),\n * the HTTP face of Clio's repository source for a Devin-style \"Ask\" surface\n * that searches the monorepo without an agent turn. Athena platform staff\n * only (the account-level `is_admin`, not a workspace role) on the managed\n * cloud today: a non-staff caller reads `403`, a private deployment `404`.\n */\nimport {\n keepPreviousData,\n QueryClient,\n QueryClientContext,\n useQuery,\n type UseQueryResult,\n} from '@tanstack/react-query';\nimport { useContext, useRef, useState } from 'react';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport { sendWithCredentialRenewal } from '../runtime/credential-renewal';\nimport type { StatewireAuthSource } from '../runtime/statewire-auth-headers';\nimport { credentialShape, sameCredentialShape } from '../threads/credential-shape';\n\nexport type AthenaRepoSearchMode = 'hybrid' | 'lexical';\n\n/** One file range of one indexed repository, as the route serves it. */\nexport interface AthenaRepoSearchHit {\n /** The GitHub catalog asset the repository is connected through. */\n catalogAssetId: string;\n /** `owner/repo`; `null` when the catalog names no repository. */\n repoFullName: string | null;\n /** Repo-relative, `/`-separated. */\n path: string;\n /** 1-based, inclusive. */\n startLine: number;\n endLine: number;\n /** The enclosing declaration (`Class.method`) when the chunk's header named one. */\n symbol: string | null;\n /** Clio's language name for the file (`python`, `typescript`, …). */\n language: string | null;\n /** `code` (an AST chunk) or `window` (a Markdown heading window). */\n unitType: string;\n score: number;\n /** The indexed commit the hit was read at. */\n commitSha: string | null;\n /** `{origin}/{owner}/{repo}/blob/{sha}/{path}#L{a}-L{b}`, GHES-aware. */\n githubUrl: string | null;\n /** The chunk's lines, header line removed, line breaks preserved. */\n snippet: string;\n /** `asset_<catalog>?anchor=file_line_range&…` — what `read_asset` and a citation take. */\n readAssetReference: string;\n}\n\nexport interface AthenaRepoSearchResponse {\n /** Best first, at most `limit`. */\n hits: AthenaRepoSearchHit[];\n tookMs: number;\n mode: AthenaRepoSearchMode;\n}\n\nexport interface AthenaRepoSearchParams {\n query: string;\n /** 1–25; the route's default is 10. */\n limit?: number;\n /** `hybrid` (default) or `lexical`. */\n mode?: AthenaRepoSearchMode;\n /** Search these GitHub catalog assets only; empty means every indexed repository. */\n repositoryAssetIds?: string[];\n /** gitignore-style globs a hit's path must match (`agora/**\\/*.py`, `docs/`). */\n paths?: string[];\n /** Clio language names a hit's file must be indexed as. */\n languages?: string[];\n}\n\nexport interface UseAthenaRepoSearchOptions extends AthenaRepoSearchParams {\n /** `false` holds the query idle (a blank `query` does too). Default `true`. */\n enabled?: boolean;\n}\n\n/** The route's JSON body — snake_case, unset filters omitted. */\nexport interface AthenaRepoSearchRequestBody {\n query: string;\n limit?: number;\n mode?: AthenaRepoSearchMode;\n repository_asset_ids?: string[];\n paths?: string[];\n languages?: string[];\n}\n\nexport const ATHENA_REPO_SEARCH_PATH = '/api/search/repositories';\n\nexport function repoSearchRequestBody(params: AthenaRepoSearchParams): AthenaRepoSearchRequestBody {\n const body: AthenaRepoSearchRequestBody = { query: params.query.trim() };\n if (params.limit !== undefined) body.limit = params.limit;\n if (params.mode !== undefined) body.mode = params.mode;\n if (params.repositoryAssetIds?.length) body.repository_asset_ids = params.repositoryAssetIds;\n if (params.paths?.length) body.paths = params.paths;\n if (params.languages?.length) body.languages = params.languages;\n return body;\n}\n\n/** A `fetch` the caller cancelled (unmount, a newer query): lifecycle, not failure. */\nfunction isAbortError(error: unknown): boolean {\n return (error instanceof DOMException || error instanceof Error) && error.name === 'AbortError';\n}\n\n/**\n * One search request. The credential rides `Authorization: Bearer` (a token,\n * resolved live through `getToken` when the host provided one) or\n * `X-API-KEY`; with neither, a same-origin host's session cookie rides\n * automatically, as the SDK's other REST helpers allow. A refused bearer\n * (`401`) gets one forced re-mint through `getToken` (`force: true`, the\n * statewire transport's `staleAuth` contract; `sendWithCredentialRenewal`) — a\n * getter that caches until forced would otherwise resend the same expired\n * token on every retry. Every failure is an `AthenaSdkError`, transport\n * rejections included; only an abort keeps its own identity.\n */\nexport async function fetchRepoSearch(\n backendUrl: string,\n auth: StatewireAuthSource,\n params: AthenaRepoSearchParams,\n opts: { signal?: AbortSignal } = {},\n): Promise<AthenaRepoSearchResponse> {\n const url = `${getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;\n const body = JSON.stringify(repoSearchRequestBody(params));\n const post = async (headers: Record<string, string>): Promise<Response> => {\n try {\n return await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body,\n signal: opts.signal ?? null,\n });\n } catch (error) {\n if (isAbortError(error)) throw error;\n throw new AthenaSdkError({\n code: 'repo_search_failed',\n message: 'Repository search could not reach the Agora API.',\n cause: error,\n hint: 'Check the network and that backendUrl points at the Agora API base.',\n });\n }\n };\n const res = await sendWithCredentialRenewal(auth, post);\n if (!res.ok) {\n const refused = res.status === 401 || res.status === 403;\n throw new AthenaSdkError({\n code: refused ? 'auth_rejected' : 'repo_search_failed',\n message: `Repository search failed: ${res.status}`,\n status: res.status,\n detail: await res.json().catch(() => undefined),\n hint: refused\n ? 'Repository search is limited to Athena platform staff on the managed cloud; check the credential.'\n : res.status === 404\n ? 'Repository search is not offered on this deployment (managed cloud only).'\n : 'Check backendUrl points at the Agora API base and that Clio is available.',\n });\n }\n return (await res.json()) as AthenaRepoSearchResponse;\n}\n\n/**\n * Search the indexed repositories through TanStack Query with the provider's\n * `backendUrl` and credentials. Keyed by the non-secret request and a\n * credential generation (a counter that advances when the host's credentials\n * change), never by the credential itself. Uses the host's `QueryClient` when\n * one is in context (`enableThreadList` mounts the SDK's own) and a\n * hook-scoped client otherwise, so it works under any `<AthenaProvider>`.\n */\nexport function useAthenaRepoSearch({\n enabled = true,\n ...params\n}: UseAthenaRepoSearchOptions): UseQueryResult<AthenaRepoSearchResponse, Error> {\n const config = useAthenaConfig();\n const { backendUrl, apiKey, getToken } = config;\n const credentialsRef = useRef(credentialShape({ apiKey, token: config.token, getToken }));\n const generationRef = useRef(0);\n const currentCredentials = credentialShape({ apiKey, token: config.token, getToken });\n if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {\n credentialsRef.current = currentCredentials;\n generationRef.current += 1;\n }\n const body = repoSearchRequestBody(params);\n const contextClient = useContext(QueryClientContext);\n const [fallbackClient] = useState(() => (contextClient ? undefined : new QueryClient()));\n return useQuery(\n {\n queryKey: ['athena-sdk', 'repo-search', backendUrl, generationRef.current, body],\n // `config.token` is read at fetch time: the provider serves the latest\n // token through a getter, so rotations reach the request.\n queryFn: ({ signal }) =>\n fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),\n enabled: enabled && body.query.length > 0 && backendUrl.length > 0,\n staleTime: 30_000,\n placeholderData: keepPreviousData,\n refetchOnWindowFocus: false,\n },\n contextClient ?? fallbackClient,\n );\n}\n"],"names":[],"mappings":";;;;;;;AAyFO,MAAM,0BAA0B;AAEhC,SAAS,sBAAsB,QAA6D;;AACjG,QAAM,OAAoC,EAAE,OAAO,OAAO,MAAM,OAAK;AACrE,MAAI,OAAO,UAAU,OAAW,MAAK,QAAQ,OAAO;AACpD,MAAI,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IAAA,CACP;AAAA,EACH;AACA,SAAQ,MAAM,IAAI,KAAA;AACpB;AAUO,SAAS,oBAAoB;AAAA,EAClC,UAAU;AAAA,EACV,GAAG;AACL,GAAgF;AAC9E,QAAM,SAAS,gBAAA;AACf,QAAM,EAAE,YAAY,QAAQ,SAAA,IAAa;AACzC,QAAM,iBAAiB,OAAO,gBAAgB,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,CAAU,CAAC;AACxF,QAAM,gBAAgB,OAAO,CAAC;AAC9B,QAAM,qBAAqB,gBAAgB,EAAE,QAAQ,OAAO,OAAO,OAAO,UAAU;AACpF,MAAI,CAAC,oBAAoB,eAAe,SAAS,kBAAkB,GAAG;AACpE,mBAAe,UAAU;AACzB,kBAAc,WAAW;AAAA,EAC3B;AACA,QAAM,OAAO,sBAAsB,MAAM;AACzC,QAAM,gBAAgB,WAAW,kBAAkB;AACnD,QAAM,CAAC,cAAc,IAAI,SAAS,MAAO,gBAAgB,SAAY,IAAI,aAAc;AACvF,SAAO;AAAA,IACL;AAAA,MACE,UAAU,CAAC,cAAc,eAAe,YAAY,cAAc,SAAS,IAAI;AAAA;AAAA;AAAA,MAG/E,SAAS,CAAC,EAAE,OAAA,MACV,gBAAgB,YAAY,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,GAAY,QAAQ,EAAE,QAAQ;AAAA,MAC3F,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,WAAW,SAAS;AAAA,MACjE,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,sBAAsB;AAAA,IAAA;AAAA,IAExB,iBAAiB;AAAA,EAAA;AAErB;"}
|
|
1
|
+
{"version":3,"file":"useAthenaRepoSearch.js","sources":["../../src/search/useAthenaRepoSearch.ts"],"sourcesContent":["/**\n * Code search over the workspace's indexed repositories —\n * `POST /api/search/repositories` (agora `web/api/search/repositories.py`),\n * the HTTP face of Clio's repository source for a Devin-style \"Ask\" surface\n * that searches the monorepo without an agent turn. Athena platform staff\n * only (the account-level `is_admin`, not a workspace role) on the managed\n * cloud today: a non-staff caller reads `403`, a private deployment `404`.\n */\nimport { keepPreviousData, useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaQueryClient, useAthenaQueryIdentity } from '../lib/use-athena-rest-query';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport { sendWithCredentialRenewal } from '../runtime/credential-renewal';\nimport type { StatewireAuthSource } from '../runtime/statewire-auth-headers';\n\nexport type AthenaRepoSearchMode = 'hybrid' | 'lexical';\n\n/** One file range of one indexed repository, as the route serves it. */\nexport interface AthenaRepoSearchHit {\n /** The GitHub catalog asset the repository is connected through. */\n catalogAssetId: string;\n /** `owner/repo`; `null` when the catalog names no repository. */\n repoFullName: string | null;\n /** Repo-relative, `/`-separated. */\n path: string;\n /** 1-based, inclusive. */\n startLine: number;\n endLine: number;\n /** The enclosing declaration (`Class.method`) when the chunk's header named one. */\n symbol: string | null;\n /** Clio's language name for the file (`python`, `typescript`, …). */\n language: string | null;\n /** `code` (an AST chunk) or `window` (a Markdown heading window). */\n unitType: string;\n score: number;\n /** The indexed commit the hit was read at. */\n commitSha: string | null;\n /** `{origin}/{owner}/{repo}/blob/{sha}/{path}#L{a}-L{b}`, GHES-aware. */\n githubUrl: string | null;\n /** The chunk's lines, header line removed, line breaks preserved. */\n snippet: string;\n /** `asset_<catalog>?anchor=file_line_range&…` — what `read_asset` and a citation take. */\n readAssetReference: string;\n}\n\nexport interface AthenaRepoSearchResponse {\n /** Best first, at most `limit`. */\n hits: AthenaRepoSearchHit[];\n tookMs: number;\n mode: AthenaRepoSearchMode;\n}\n\nexport interface AthenaRepoSearchParams {\n query: string;\n /** 1–25; the route's default is 10. */\n limit?: number;\n /** `hybrid` (default) or `lexical`. */\n mode?: AthenaRepoSearchMode;\n /** Search these GitHub catalog assets only; empty means every indexed repository. */\n repositoryAssetIds?: string[];\n /** gitignore-style globs a hit's path must match (`agora/**\\/*.py`, `docs/`). */\n paths?: string[];\n /** Clio language names a hit's file must be indexed as. */\n languages?: string[];\n}\n\nexport interface UseAthenaRepoSearchOptions extends AthenaRepoSearchParams {\n /** `false` holds the query idle (a blank `query` does too). Default `true`. */\n enabled?: boolean;\n}\n\n/** The route's JSON body — snake_case, unset filters omitted. */\nexport interface AthenaRepoSearchRequestBody {\n query: string;\n limit?: number;\n mode?: AthenaRepoSearchMode;\n repository_asset_ids?: string[];\n paths?: string[];\n languages?: string[];\n}\n\nexport const ATHENA_REPO_SEARCH_PATH = '/api/search/repositories';\n\nexport function repoSearchRequestBody(params: AthenaRepoSearchParams): AthenaRepoSearchRequestBody {\n const body: AthenaRepoSearchRequestBody = { query: params.query.trim() };\n if (params.limit !== undefined) body.limit = params.limit;\n if (params.mode !== undefined) body.mode = params.mode;\n if (params.repositoryAssetIds?.length) body.repository_asset_ids = params.repositoryAssetIds;\n if (params.paths?.length) body.paths = params.paths;\n if (params.languages?.length) body.languages = params.languages;\n return body;\n}\n\n/** A `fetch` the caller cancelled (unmount, a newer query): lifecycle, not failure. */\nfunction isAbortError(error: unknown): boolean {\n return (error instanceof DOMException || error instanceof Error) && error.name === 'AbortError';\n}\n\n/**\n * One search request. The credential rides `Authorization: Bearer` (a token,\n * resolved live through `getToken` when the host provided one) or\n * `X-API-KEY`; with neither, a same-origin host's session cookie rides\n * automatically, as the SDK's other REST helpers allow. A refused bearer\n * (`401`) gets one forced re-mint through `getToken` (`force: true`, the\n * statewire transport's `staleAuth` contract; `sendWithCredentialRenewal`) — a\n * getter that caches until forced would otherwise resend the same expired\n * token on every retry. Every failure is an `AthenaSdkError`, transport\n * rejections included; only an abort keeps its own identity.\n */\nexport async function fetchRepoSearch(\n backendUrl: string,\n auth: StatewireAuthSource,\n params: AthenaRepoSearchParams,\n opts: { signal?: AbortSignal } = {},\n): Promise<AthenaRepoSearchResponse> {\n const url = `${getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;\n const body = JSON.stringify(repoSearchRequestBody(params));\n const post = async (headers: Record<string, string>): Promise<Response> => {\n try {\n return await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body,\n signal: opts.signal ?? null,\n });\n } catch (error) {\n if (isAbortError(error)) throw error;\n throw new AthenaSdkError({\n code: 'repo_search_failed',\n message: 'Repository search could not reach the Agora API.',\n cause: error,\n hint: 'Check the network and that backendUrl points at the Agora API base.',\n });\n }\n };\n const res = await sendWithCredentialRenewal(auth, post);\n if (!res.ok) {\n const refused = res.status === 401 || res.status === 403;\n throw new AthenaSdkError({\n code: refused ? 'auth_rejected' : 'repo_search_failed',\n message: `Repository search failed: ${res.status}`,\n status: res.status,\n detail: await res.json().catch(() => undefined),\n hint: refused\n ? 'Repository search is limited to Athena platform staff on the managed cloud; check the credential.'\n : res.status === 404\n ? 'Repository search is not offered on this deployment (managed cloud only).'\n : 'Check backendUrl points at the Agora API base and that Clio is available.',\n });\n }\n return (await res.json()) as AthenaRepoSearchResponse;\n}\n\n/**\n * Search the indexed repositories through TanStack Query with the provider's\n * `backendUrl` and credentials. Keyed by the non-secret request, the signed-in\n * principal and a credential generation (a counter that advances when the\n * host's credentials change), never by the credential itself. Uses the host's `QueryClient` when\n * one is in context (`enableThreadList` mounts the SDK's own) and a\n * hook-scoped client otherwise, so it works under any `<AthenaProvider>`.\n */\nexport function useAthenaRepoSearch({\n enabled = true,\n ...params\n}: UseAthenaRepoSearchOptions): UseQueryResult<AthenaRepoSearchResponse, Error> {\n const config = useAthenaConfig();\n const { backendUrl, apiKey, getToken } = config;\n const identity = useAthenaQueryIdentity({ apiKey, token: config.token, getToken });\n const body = repoSearchRequestBody(params);\n const queryClient = useAthenaQueryClient();\n return useQuery(\n {\n queryKey: ['athena-sdk', 'repo-search', backendUrl, ...identity, body],\n // `config.token` is read at fetch time: the provider serves the latest\n // token through a getter, so rotations reach the request.\n queryFn: ({ signal }) =>\n fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),\n enabled: enabled && body.query.length > 0 && backendUrl.length > 0,\n staleTime: 30_000,\n placeholderData: keepPreviousData,\n refetchOnWindowFocus: false,\n },\n queryClient,\n );\n}\n"],"names":[],"mappings":";;;;;;AAkFO,MAAM,0BAA0B;AAEhC,SAAS,sBAAsB,QAA6D;;AACjG,QAAM,OAAoC,EAAE,OAAO,OAAO,MAAM,OAAK;AACrE,MAAI,OAAO,UAAU,OAAW,MAAK,QAAQ,OAAO;AACpD,MAAI,OAAO,SAAS,OAAW,MAAK,OAAO,OAAO;AAClD,OAAI,YAAO,uBAAP,mBAA2B,OAAQ,MAAK,uBAAuB,OAAO;AAC1E,OAAI,YAAO,UAAP,mBAAc,OAAQ,MAAK,QAAQ,OAAO;AAC9C,OAAI,YAAO,cAAP,mBAAkB,OAAQ,MAAK,YAAY,OAAO;AACtD,SAAO;AACT;AAGA,SAAS,aAAa,OAAyB;AAC7C,UAAQ,iBAAiB,gBAAgB,iBAAiB,UAAU,MAAM,SAAS;AACrF;AAaA,eAAsB,gBACpB,YACA,MACA,QACA,OAAiC,CAAA,GACE;AACnC,QAAM,MAAM,GAAG,oBAAoB,UAAU,CAAC,GAAG,uBAAuB;AACxE,QAAM,OAAO,KAAK,UAAU,sBAAsB,MAAM,CAAC;AACzD,QAAM,OAAO,OAAO,YAAuD;AACzE,QAAI;AACF,aAAO,MAAM,MAAM,KAAK;AAAA,QACtB,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,oBAAoB,GAAG,QAAA;AAAA,QAClD;AAAA,QACA,QAAQ,KAAK,UAAU;AAAA,MAAA,CACxB;AAAA,IACH,SAAS,OAAO;AACd,UAAI,aAAa,KAAK,EAAG,OAAM;AAC/B,YAAM,IAAI,eAAe;AAAA,QACvB,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,EACF;AACA,QAAM,MAAM,MAAM,0BAA0B,MAAM,IAAI;AACtD,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,UAAU,IAAI,WAAW,OAAO,IAAI,WAAW;AACrD,UAAM,IAAI,eAAe;AAAA,MACvB,MAAM,UAAU,kBAAkB;AAAA,MAClC,SAAS,6BAA6B,IAAI,MAAM;AAAA,MAChD,QAAQ,IAAI;AAAA,MACZ,QAAQ,MAAM,IAAI,OAAO,MAAM,MAAM,MAAS;AAAA,MAC9C,MAAM,UACF,sGACA,IAAI,WAAW,MACb,8EACA;AAAA,IAAA,CACP;AAAA,EACH;AACA,SAAQ,MAAM,IAAI,KAAA;AACpB;AAUO,SAAS,oBAAoB;AAAA,EAClC,UAAU;AAAA,EACV,GAAG;AACL,GAAgF;AAC9E,QAAM,SAAS,gBAAA;AACf,QAAM,EAAE,YAAY,QAAQ,SAAA,IAAa;AACzC,QAAM,WAAW,uBAAuB,EAAE,QAAQ,OAAO,OAAO,OAAO,UAAU;AACjF,QAAM,OAAO,sBAAsB,MAAM;AACzC,QAAM,cAAc,qBAAA;AACpB,SAAO;AAAA,IACL;AAAA,MACE,UAAU,CAAC,cAAc,eAAe,YAAY,GAAG,UAAU,IAAI;AAAA;AAAA;AAAA,MAGrE,SAAS,CAAC,EAAE,OAAA,MACV,gBAAgB,YAAY,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,GAAY,QAAQ,EAAE,QAAQ;AAAA,MAC3F,SAAS,WAAW,KAAK,MAAM,SAAS,KAAK,WAAW,SAAS;AAAA,MACjE,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,sBAAsB;AAAA,IAAA;AAAA,IAExB;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const SHEET_MAX_ROW = 1048576;
|
|
4
|
+
const SHEET_MAX_COLUMN = 16384;
|
|
5
|
+
const CELL_REFERENCE = /^\$?([A-Za-z]{1,3})\$?(\d{1,7})$/;
|
|
6
|
+
const COLUMN_REFERENCE = /^\$?([A-Za-z]{1,3})$/;
|
|
7
|
+
const ROW_REFERENCE = /^\$?(\d{1,7})$/;
|
|
8
|
+
function columnLettersToNumber(letters) {
|
|
9
|
+
if (!/^[A-Za-z]{1,3}$/.test(letters)) return null;
|
|
10
|
+
let column = 0;
|
|
11
|
+
for (const letter of letters.toUpperCase()) column = column * 26 + (letter.charCodeAt(0) - 64);
|
|
12
|
+
return column <= SHEET_MAX_COLUMN ? column : null;
|
|
13
|
+
}
|
|
14
|
+
function columnNumberToLetters(column) {
|
|
15
|
+
if (!Number.isInteger(column) || column < 1) return "";
|
|
16
|
+
let letters = "";
|
|
17
|
+
for (let rest = column; rest > 0; rest = Math.floor((rest - 1) / 26)) {
|
|
18
|
+
letters = String.fromCharCode(65 + (rest - 1) % 26) + letters;
|
|
19
|
+
}
|
|
20
|
+
return letters;
|
|
21
|
+
}
|
|
22
|
+
function formatA1Cell({ row, column }) {
|
|
23
|
+
return `${columnNumberToLetters(column)}${row}`;
|
|
24
|
+
}
|
|
25
|
+
function formatA1Range({ startRow, endRow, startColumn, endColumn }) {
|
|
26
|
+
const start = formatA1Cell({ row: startRow, column: startColumn });
|
|
27
|
+
if (startRow === endRow && startColumn === endColumn) return start;
|
|
28
|
+
return `${start}:${formatA1Cell({ row: endRow, column: endColumn })}`;
|
|
29
|
+
}
|
|
30
|
+
function splitSheetPrefix(reference) {
|
|
31
|
+
if (reference.startsWith("'")) {
|
|
32
|
+
let name2 = "";
|
|
33
|
+
let index = 1;
|
|
34
|
+
while (index < reference.length) {
|
|
35
|
+
const char = reference[index];
|
|
36
|
+
if (char === "'") {
|
|
37
|
+
if (reference[index + 1] !== "'") break;
|
|
38
|
+
name2 += "'";
|
|
39
|
+
index += 2;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
name2 += char;
|
|
43
|
+
index += 1;
|
|
44
|
+
}
|
|
45
|
+
if (name2 === "" || reference[index] !== "'" || reference[index + 1] !== "!") return null;
|
|
46
|
+
return { sheetName: name2, address: reference.slice(index + 2) };
|
|
47
|
+
}
|
|
48
|
+
const bang = reference.indexOf("!");
|
|
49
|
+
if (bang === -1) return { sheetName: null, address: reference };
|
|
50
|
+
const name = reference.slice(0, bang);
|
|
51
|
+
if (name === "" || name.includes("'")) return null;
|
|
52
|
+
return { sheetName: name, address: reference.slice(bang + 1) };
|
|
53
|
+
}
|
|
54
|
+
function parseRow(digits) {
|
|
55
|
+
const row = Number(digits);
|
|
56
|
+
return Number.isInteger(row) && row >= 1 && row <= SHEET_MAX_ROW ? row : null;
|
|
57
|
+
}
|
|
58
|
+
function parseCell(part) {
|
|
59
|
+
const match = CELL_REFERENCE.exec(part);
|
|
60
|
+
if (!match) return null;
|
|
61
|
+
const column = columnLettersToNumber(match[1]);
|
|
62
|
+
const row = parseRow(match[2]);
|
|
63
|
+
return column === null || row === null ? null : { row, column };
|
|
64
|
+
}
|
|
65
|
+
function parseColumn(part) {
|
|
66
|
+
const match = COLUMN_REFERENCE.exec(part);
|
|
67
|
+
return match ? columnLettersToNumber(match[1]) : null;
|
|
68
|
+
}
|
|
69
|
+
function parseWholeRow(part) {
|
|
70
|
+
const match = ROW_REFERENCE.exec(part);
|
|
71
|
+
return match ? parseRow(match[1]) : null;
|
|
72
|
+
}
|
|
73
|
+
function parseA1Range(reference) {
|
|
74
|
+
if (typeof reference !== "string") return null;
|
|
75
|
+
const qualified = splitSheetPrefix(reference.trim());
|
|
76
|
+
if (!qualified) return null;
|
|
77
|
+
const { sheetName } = qualified;
|
|
78
|
+
const parts = qualified.address.split(":").map((part) => part.trim());
|
|
79
|
+
if (parts.length > 2 || parts.some((part) => part === "")) return null;
|
|
80
|
+
if (parts.length === 1) {
|
|
81
|
+
const cell = parseCell(parts[0]);
|
|
82
|
+
if (!cell) return null;
|
|
83
|
+
return {
|
|
84
|
+
kind: "cell",
|
|
85
|
+
sheetName,
|
|
86
|
+
startRow: cell.row,
|
|
87
|
+
endRow: cell.row,
|
|
88
|
+
startColumn: cell.column,
|
|
89
|
+
endColumn: cell.column
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const [first, second] = parts;
|
|
93
|
+
const startCell = parseCell(first);
|
|
94
|
+
const endCell = parseCell(second);
|
|
95
|
+
if (startCell && endCell) {
|
|
96
|
+
return {
|
|
97
|
+
kind: "range",
|
|
98
|
+
sheetName,
|
|
99
|
+
startRow: Math.min(startCell.row, endCell.row),
|
|
100
|
+
endRow: Math.max(startCell.row, endCell.row),
|
|
101
|
+
startColumn: Math.min(startCell.column, endCell.column),
|
|
102
|
+
endColumn: Math.max(startCell.column, endCell.column)
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const startColumn = parseColumn(first);
|
|
106
|
+
const endColumn = parseColumn(second);
|
|
107
|
+
if (startColumn !== null && endColumn !== null) {
|
|
108
|
+
return {
|
|
109
|
+
kind: "columns",
|
|
110
|
+
sheetName,
|
|
111
|
+
startRow: null,
|
|
112
|
+
endRow: null,
|
|
113
|
+
startColumn: Math.min(startColumn, endColumn),
|
|
114
|
+
endColumn: Math.max(startColumn, endColumn)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const startRow = parseWholeRow(first);
|
|
118
|
+
const endRow = parseWholeRow(second);
|
|
119
|
+
if (startRow !== null && endRow !== null) {
|
|
120
|
+
return {
|
|
121
|
+
kind: "rows",
|
|
122
|
+
sheetName,
|
|
123
|
+
startRow: Math.min(startRow, endRow),
|
|
124
|
+
endRow: Math.max(startRow, endRow),
|
|
125
|
+
startColumn: null,
|
|
126
|
+
endColumn: null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function a1AnchorCell(reference) {
|
|
132
|
+
if (typeof reference !== "string" || !parseA1Range(reference)) return null;
|
|
133
|
+
const qualified = splitSheetPrefix(reference.trim());
|
|
134
|
+
const first = (qualified == null ? void 0 : qualified.address.split(":")[0].trim()) ?? "";
|
|
135
|
+
const cell = parseCell(first);
|
|
136
|
+
if (cell) return cell;
|
|
137
|
+
const column = parseColumn(first);
|
|
138
|
+
if (column !== null) return { row: 1, column };
|
|
139
|
+
const row = parseWholeRow(first);
|
|
140
|
+
return row === null ? null : { row, column: 1 };
|
|
141
|
+
}
|
|
142
|
+
function a1RangeBounds(reference) {
|
|
143
|
+
const range = parseA1Range(reference);
|
|
144
|
+
if (!range || range.kind !== "cell" && range.kind !== "range") return null;
|
|
145
|
+
return {
|
|
146
|
+
startRow: range.startRow,
|
|
147
|
+
endRow: range.endRow,
|
|
148
|
+
startColumn: range.startColumn,
|
|
149
|
+
endColumn: range.endColumn
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
exports.SHEET_MAX_COLUMN = SHEET_MAX_COLUMN;
|
|
153
|
+
exports.SHEET_MAX_ROW = SHEET_MAX_ROW;
|
|
154
|
+
exports.a1AnchorCell = a1AnchorCell;
|
|
155
|
+
exports.a1RangeBounds = a1RangeBounds;
|
|
156
|
+
exports.columnLettersToNumber = columnLettersToNumber;
|
|
157
|
+
exports.columnNumberToLetters = columnNumberToLetters;
|
|
158
|
+
exports.formatA1Cell = formatA1Cell;
|
|
159
|
+
exports.formatA1Range = formatA1Range;
|
|
160
|
+
exports.parseA1Range = parseA1Range;
|
|
161
|
+
exports.splitSheetPrefix = splitSheetPrefix;
|
|
162
|
+
//# sourceMappingURL=a1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a1.cjs","sources":["../../src/sheet-range/a1.ts"],"sourcesContent":["/**\n * A1 references, read and written the way every spreadsheet surface outside\n * the grid reads them: the SDK's sheet tool cards, and Olympus's sheet tool\n * cards, citation previews and citation navigation. Pure: no React, no engine.\n *\n * Rows and columns are 1-based, as the sheets engine counts them: `A1` is row\n * 1, column 1.\n */\n\n/** The last row a sheet addresses (Excel and the sheets engine). */\nexport const SHEET_MAX_ROW = 1_048_576;\n/** The last column a sheet addresses: XFD. */\nexport const SHEET_MAX_COLUMN = 16_384;\n\n/** A rectangle of cells, 1-based and inclusive on both ends. */\nexport interface SheetRangeBounds {\n startRow: number;\n endRow: number;\n startColumn: number;\n endColumn: number;\n}\n\ninterface SheetQualifier {\n /** The sheet a `Sales!` or `'Q1 Plan'!` prefix names (quotes removed, `''` read as `'`); null without one. */\n sheetName: string | null;\n}\n\n/**\n * A parsed A1 reference. A cell or a rectangle carries all four bounds\n * (normalized so start ≤ end, as `C5:A1` means `A1:C5`); whole columns (`A:C`)\n * leave the rows open and whole rows (`3:5`) the columns.\n */\nexport type A1Range =\n | (SheetQualifier & SheetRangeBounds & { kind: 'cell' | 'range' })\n | (SheetQualifier & {\n kind: 'columns';\n startRow: null;\n endRow: null;\n startColumn: number;\n endColumn: number;\n })\n | (SheetQualifier & {\n kind: 'rows';\n startRow: number;\n endRow: number;\n startColumn: null;\n endColumn: null;\n });\n\n/** A cell (`B7`, `$B$7`); the column is 1–3 letters, the row 1–7 digits. */\nconst CELL_REFERENCE = /^\\$?([A-Za-z]{1,3})\\$?(\\d{1,7})$/;\n/** One side of whole columns (`A`, `$A`). */\nconst COLUMN_REFERENCE = /^\\$?([A-Za-z]{1,3})$/;\n/** One side of whole rows (`3`, `$3`). */\nconst ROW_REFERENCE = /^\\$?(\\d{1,7})$/;\n\n/** Column letters to the 1-based column (`A` → 1, `AA` → 27); null past XFD or for anything but letters. */\nexport function columnLettersToNumber(letters: string): number | null {\n if (!/^[A-Za-z]{1,3}$/.test(letters)) return null;\n let column = 0;\n for (const letter of letters.toUpperCase()) column = column * 26 + (letter.charCodeAt(0) - 64);\n return column <= SHEET_MAX_COLUMN ? column : null;\n}\n\n/** A 1-based column to its letters (1 → `A`, 27 → `AA`); empty for anything below 1 or fractional. */\nexport function columnNumberToLetters(column: number): string {\n if (!Number.isInteger(column) || column < 1) return '';\n let letters = '';\n for (let rest = column; rest > 0; rest = Math.floor((rest - 1) / 26)) {\n letters = String.fromCharCode(65 + ((rest - 1) % 26)) + letters;\n }\n return letters;\n}\n\n/** A cell's A1 address: `{ row: 7, column: 2 }` → `B7`. */\nexport function formatA1Cell({ row, column }: { row: number; column: number }): string {\n return `${columnNumberToLetters(column)}${row}`;\n}\n\n/** A rectangle's A1 address: `A1:C5`, or `A1` alone when it is one cell. */\nexport function formatA1Range({ startRow, endRow, startColumn, endColumn }: SheetRangeBounds): string {\n const start = formatA1Cell({ row: startRow, column: startColumn });\n if (startRow === endRow && startColumn === endColumn) return start;\n return `${start}:${formatA1Cell({ row: endRow, column: endColumn })}`;\n}\n\n/**\n * Split the sheet prefix off a reference: `'Q1 Plan'!A1:B2` → `Q1 Plan` and\n * `A1:B2`, `Sales!B7` → `Sales` and `B7`, `B7` → no sheet and `B7`. A quoted\n * name runs to the first quote that is not doubled (`'Bob''s'!A1` names\n * `Bob's`); an unquoted one runs to the first `!` and holds no quote. Null for\n * a prefix that is not one (an empty name, an unclosed quote, a quote without\n * its `!`).\n */\nexport function splitSheetPrefix(reference: string): { sheetName: string | null; address: string } | null {\n if (reference.startsWith(\"'\")) {\n let name = '';\n let index = 1;\n while (index < reference.length) {\n const char = reference[index];\n if (char === \"'\") {\n if (reference[index + 1] !== \"'\") break;\n name += \"'\";\n index += 2;\n continue;\n }\n name += char;\n index += 1;\n }\n if (name === '' || reference[index] !== \"'\" || reference[index + 1] !== '!') return null;\n return { sheetName: name, address: reference.slice(index + 2) };\n }\n const bang = reference.indexOf('!');\n if (bang === -1) return { sheetName: null, address: reference };\n const name = reference.slice(0, bang);\n if (name === '' || name.includes(\"'\")) return null;\n return { sheetName: name, address: reference.slice(bang + 1) };\n}\n\nfunction parseRow(digits: string): number | null {\n const row = Number(digits);\n return Number.isInteger(row) && row >= 1 && row <= SHEET_MAX_ROW ? row : null;\n}\n\nfunction parseCell(part: string): { row: number; column: number } | null {\n const match = CELL_REFERENCE.exec(part);\n if (!match) return null;\n const column = columnLettersToNumber(match[1]);\n const row = parseRow(match[2]);\n return column === null || row === null ? null : { row, column };\n}\n\nfunction parseColumn(part: string): number | null {\n const match = COLUMN_REFERENCE.exec(part);\n return match ? columnLettersToNumber(match[1]) : null;\n}\n\nfunction parseWholeRow(part: string): number | null {\n const match = ROW_REFERENCE.exec(part);\n return match ? parseRow(match[1]) : null;\n}\n\n/**\n * Read an A1 reference: a cell (`B7`), a rectangle (`A1:C5`), whole columns\n * (`A:C`) or whole rows (`3:5`), with an optional sheet prefix (`Sales!`,\n * `'Q1 Plan'!`), `$` absolute markers and any letter case. Whitespace around\n * the reference and around its `:` is ignored. Null for anything else: a named\n * range, a column past XFD, row 0 or a row past 1,048,576, a lone column or\n * row, mixed sides (`A1:C`), three parts.\n */\nexport function parseA1Range(reference: string | null | undefined): A1Range | null {\n if (typeof reference !== 'string') return null;\n const qualified = splitSheetPrefix(reference.trim());\n if (!qualified) return null;\n const { sheetName } = qualified;\n const parts = qualified.address.split(':').map((part) => part.trim());\n if (parts.length > 2 || parts.some((part) => part === '')) return null;\n\n if (parts.length === 1) {\n const cell = parseCell(parts[0]);\n if (!cell) return null;\n return {\n kind: 'cell',\n sheetName,\n startRow: cell.row,\n endRow: cell.row,\n startColumn: cell.column,\n endColumn: cell.column,\n };\n }\n\n const [first, second] = parts;\n const startCell = parseCell(first);\n const endCell = parseCell(second);\n if (startCell && endCell) {\n return {\n kind: 'range',\n sheetName,\n startRow: Math.min(startCell.row, endCell.row),\n endRow: Math.max(startCell.row, endCell.row),\n startColumn: Math.min(startCell.column, endCell.column),\n endColumn: Math.max(startCell.column, endCell.column),\n };\n }\n const startColumn = parseColumn(first);\n const endColumn = parseColumn(second);\n if (startColumn !== null && endColumn !== null) {\n return {\n kind: 'columns',\n sheetName,\n startRow: null,\n endRow: null,\n startColumn: Math.min(startColumn, endColumn),\n endColumn: Math.max(startColumn, endColumn),\n };\n }\n const startRow = parseWholeRow(first);\n const endRow = parseWholeRow(second);\n if (startRow !== null && endRow !== null) {\n return {\n kind: 'rows',\n sheetName,\n startRow: Math.min(startRow, endRow),\n endRow: Math.max(startRow, endRow),\n startColumn: null,\n endColumn: null,\n };\n }\n return null;\n}\n\n/**\n * The cell a reference starts from as written, its first part: `D6` for\n * `D6:C5`, row 1 of column C for `C:A`, column A of row 5 for `5:3`. A write\n * anchored at a range starts there; the backend does not reorder a range\n * written backwards. Null for anything `parseA1Range` cannot read.\n */\nexport function a1AnchorCell(reference: string | null | undefined): { row: number; column: number } | null {\n if (typeof reference !== 'string' || !parseA1Range(reference)) return null;\n const qualified = splitSheetPrefix(reference.trim());\n const first = qualified?.address.split(':')[0].trim() ?? '';\n const cell = parseCell(first);\n if (cell) return cell;\n const column = parseColumn(first);\n if (column !== null) return { row: 1, column };\n const row = parseWholeRow(first);\n return row === null ? null : { row, column: 1 };\n}\n\n/**\n * The rectangle a cell or rectangle reference covers. Null for whole columns\n * or rows, whose extent is open, and for anything `parseA1Range` cannot read.\n */\nexport function a1RangeBounds(reference: string | null | undefined): SheetRangeBounds | null {\n const range = parseA1Range(reference);\n if (!range || (range.kind !== 'cell' && range.kind !== 'range')) return null;\n return {\n startRow: range.startRow,\n endRow: range.endRow,\n startColumn: range.startColumn,\n endColumn: range.endColumn,\n };\n}\n"],"names":["name"],"mappings":";;AAUO,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB;AAsChC,MAAM,iBAAiB;AAEvB,MAAM,mBAAmB;AAEzB,MAAM,gBAAgB;AAGf,SAAS,sBAAsB,SAAgC;AACpE,MAAI,CAAC,kBAAkB,KAAK,OAAO,EAAG,QAAO;AAC7C,MAAI,SAAS;AACb,aAAW,UAAU,QAAQ,YAAA,EAAe,UAAS,SAAS,MAAM,OAAO,WAAW,CAAC,IAAI;AAC3F,SAAO,UAAU,mBAAmB,SAAS;AAC/C;AAGO,SAAS,sBAAsB,QAAwB;AAC5D,MAAI,CAAC,OAAO,UAAU,MAAM,KAAK,SAAS,EAAG,QAAO;AACpD,MAAI,UAAU;AACd,WAAS,OAAO,QAAQ,OAAO,GAAG,OAAO,KAAK,OAAO,OAAO,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K,GAAG,OAAA;AACtC,QAAM,MAAM,cAAc,KAAK;AAC/B,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,QAAQ,EAAA;AAC9C;AAMO,SAAS,cAAc,WAA+D;AAC3F,QAAM,QAAQ,aAAa,SAAS;AACpC,MAAI,CAAC,SAAU,MAAM,SAAS,UAAU,MAAM,SAAS,QAAU,QAAO;AACxE,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM;AAAA,IACd,aAAa,MAAM;AAAA,IACnB,WAAW,MAAM;AAAA,EAAA;AAErB;;;;;;;;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A1 references, read and written the way every spreadsheet surface outside
|
|
3
|
+
* the grid reads them: the SDK's sheet tool cards, and Olympus's sheet tool
|
|
4
|
+
* cards, citation previews and citation navigation. Pure: no React, no engine.
|
|
5
|
+
*
|
|
6
|
+
* Rows and columns are 1-based, as the sheets engine counts them: `A1` is row
|
|
7
|
+
* 1, column 1.
|
|
8
|
+
*/
|
|
9
|
+
/** The last row a sheet addresses (Excel and the sheets engine). */
|
|
10
|
+
export declare const SHEET_MAX_ROW = 1048576;
|
|
11
|
+
/** The last column a sheet addresses: XFD. */
|
|
12
|
+
export declare const SHEET_MAX_COLUMN = 16384;
|
|
13
|
+
/** A rectangle of cells, 1-based and inclusive on both ends. */
|
|
14
|
+
export interface SheetRangeBounds {
|
|
15
|
+
startRow: number;
|
|
16
|
+
endRow: number;
|
|
17
|
+
startColumn: number;
|
|
18
|
+
endColumn: number;
|
|
19
|
+
}
|
|
20
|
+
interface SheetQualifier {
|
|
21
|
+
/** The sheet a `Sales!` or `'Q1 Plan'!` prefix names (quotes removed, `''` read as `'`); null without one. */
|
|
22
|
+
sheetName: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A parsed A1 reference. A cell or a rectangle carries all four bounds
|
|
26
|
+
* (normalized so start ≤ end, as `C5:A1` means `A1:C5`); whole columns (`A:C`)
|
|
27
|
+
* leave the rows open and whole rows (`3:5`) the columns.
|
|
28
|
+
*/
|
|
29
|
+
export type A1Range = (SheetQualifier & SheetRangeBounds & {
|
|
30
|
+
kind: 'cell' | 'range';
|
|
31
|
+
}) | (SheetQualifier & {
|
|
32
|
+
kind: 'columns';
|
|
33
|
+
startRow: null;
|
|
34
|
+
endRow: null;
|
|
35
|
+
startColumn: number;
|
|
36
|
+
endColumn: number;
|
|
37
|
+
}) | (SheetQualifier & {
|
|
38
|
+
kind: 'rows';
|
|
39
|
+
startRow: number;
|
|
40
|
+
endRow: number;
|
|
41
|
+
startColumn: null;
|
|
42
|
+
endColumn: null;
|
|
43
|
+
});
|
|
44
|
+
/** Column letters to the 1-based column (`A` → 1, `AA` → 27); null past XFD or for anything but letters. */
|
|
45
|
+
export declare function columnLettersToNumber(letters: string): number | null;
|
|
46
|
+
/** A 1-based column to its letters (1 → `A`, 27 → `AA`); empty for anything below 1 or fractional. */
|
|
47
|
+
export declare function columnNumberToLetters(column: number): string;
|
|
48
|
+
/** A cell's A1 address: `{ row: 7, column: 2 }` → `B7`. */
|
|
49
|
+
export declare function formatA1Cell({ row, column }: {
|
|
50
|
+
row: number;
|
|
51
|
+
column: number;
|
|
52
|
+
}): string;
|
|
53
|
+
/** A rectangle's A1 address: `A1:C5`, or `A1` alone when it is one cell. */
|
|
54
|
+
export declare function formatA1Range({ startRow, endRow, startColumn, endColumn }: SheetRangeBounds): string;
|
|
55
|
+
/**
|
|
56
|
+
* Split the sheet prefix off a reference: `'Q1 Plan'!A1:B2` → `Q1 Plan` and
|
|
57
|
+
* `A1:B2`, `Sales!B7` → `Sales` and `B7`, `B7` → no sheet and `B7`. A quoted
|
|
58
|
+
* name runs to the first quote that is not doubled (`'Bob''s'!A1` names
|
|
59
|
+
* `Bob's`); an unquoted one runs to the first `!` and holds no quote. Null for
|
|
60
|
+
* a prefix that is not one (an empty name, an unclosed quote, a quote without
|
|
61
|
+
* its `!`).
|
|
62
|
+
*/
|
|
63
|
+
export declare function splitSheetPrefix(reference: string): {
|
|
64
|
+
sheetName: string | null;
|
|
65
|
+
address: string;
|
|
66
|
+
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* Read an A1 reference: a cell (`B7`), a rectangle (`A1:C5`), whole columns
|
|
69
|
+
* (`A:C`) or whole rows (`3:5`), with an optional sheet prefix (`Sales!`,
|
|
70
|
+
* `'Q1 Plan'!`), `$` absolute markers and any letter case. Whitespace around
|
|
71
|
+
* the reference and around its `:` is ignored. Null for anything else: a named
|
|
72
|
+
* range, a column past XFD, row 0 or a row past 1,048,576, a lone column or
|
|
73
|
+
* row, mixed sides (`A1:C`), three parts.
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseA1Range(reference: string | null | undefined): A1Range | null;
|
|
76
|
+
/**
|
|
77
|
+
* The cell a reference starts from as written, its first part: `D6` for
|
|
78
|
+
* `D6:C5`, row 1 of column C for `C:A`, column A of row 5 for `5:3`. A write
|
|
79
|
+
* anchored at a range starts there; the backend does not reorder a range
|
|
80
|
+
* written backwards. Null for anything `parseA1Range` cannot read.
|
|
81
|
+
*/
|
|
82
|
+
export declare function a1AnchorCell(reference: string | null | undefined): {
|
|
83
|
+
row: number;
|
|
84
|
+
column: number;
|
|
85
|
+
} | null;
|
|
86
|
+
/**
|
|
87
|
+
* The rectangle a cell or rectangle reference covers. Null for whole columns
|
|
88
|
+
* or rows, whose extent is open, and for anything `parseA1Range` cannot read.
|
|
89
|
+
*/
|
|
90
|
+
export declare function a1RangeBounds(reference: string | null | undefined): SheetRangeBounds | null;
|
|
91
|
+
export {};
|