@athenaintel/react 0.22.4 → 0.23.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 +390 -4
- package/dist/chat/AthenaChat.cjs +346 -244
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +19 -8
- package/dist/chat/AthenaChat.js +350 -248
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +2 -1
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.js +2 -1
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +1 -0
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireClientToolBridge.js +1 -0
- package/dist/chat/StatewireClientToolBridge.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +1 -0
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.js +1 -0
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/WaitingOnYouBanner.cjs +100 -0
- package/dist/chat/WaitingOnYouBanner.cjs.map +1 -0
- package/dist/chat/WaitingOnYouBanner.d.ts +29 -0
- package/dist/chat/WaitingOnYouBanner.js +100 -0
- package/dist/chat/WaitingOnYouBanner.js.map +1 -0
- package/dist/chat/athena-chat-welcome.cjs +148 -0
- package/dist/chat/athena-chat-welcome.cjs.map +1 -0
- package/dist/chat/athena-chat-welcome.d.ts +54 -0
- package/dist/chat/athena-chat-welcome.js +148 -0
- package/dist/chat/athena-chat-welcome.js.map +1 -0
- package/dist/chat/athena-composer-controls.cjs +76 -0
- package/dist/chat/athena-composer-controls.cjs.map +1 -0
- package/dist/chat/athena-composer-controls.d.ts +21 -0
- package/dist/chat/athena-composer-controls.js +76 -0
- package/dist/chat/athena-composer-controls.js.map +1 -0
- package/dist/chat/composer-keyboard-hint.cjs +61 -0
- package/dist/chat/composer-keyboard-hint.cjs.map +1 -0
- package/dist/chat/composer-keyboard-hint.d.ts +33 -0
- package/dist/chat/composer-keyboard-hint.js +61 -0
- package/dist/chat/composer-keyboard-hint.js.map +1 -0
- package/dist/chat/message-time.cjs +64 -0
- package/dist/chat/message-time.cjs.map +1 -0
- package/dist/chat/message-time.d.ts +45 -0
- package/dist/chat/message-time.js +64 -0
- package/dist/chat/message-time.js.map +1 -0
- package/dist/chat/run-activity.cjs +38 -7
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.d.ts +14 -3
- package/dist/chat/run-activity.js +39 -8
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +2 -1
- package/dist/chat/statewire-client-tools.cjs.map +1 -1
- package/dist/chat/statewire-client-tools.js +2 -1
- package/dist/chat/statewire-client-tools.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +2 -1
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.js +2 -1
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/thread-scroll-to-bottom.cjs +24 -0
- package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -0
- package/dist/chat/thread-scroll-to-bottom.d.ts +11 -0
- package/dist/chat/thread-scroll-to-bottom.js +24 -0
- package/dist/chat/thread-scroll-to-bottom.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +26 -95
- package/dist/chat/tiptap-text.cjs.map +1 -1
- package/dist/chat/tiptap-text.d.ts +13 -0
- package/dist/chat/tiptap-text.js +26 -95
- package/dist/chat/tiptap-text.js.map +1 -1
- package/dist/chat/use-athena-run-live.cjs +2 -1
- package/dist/chat/use-athena-run-live.cjs.map +1 -1
- package/dist/chat/use-athena-run-live.js +2 -1
- package/dist/chat/use-athena-run-live.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +1 -0
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.js +1 -0
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +39 -4
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +21 -0
- package/dist/chat-ui/composer/tiptap-composer.js +39 -4
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +15 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +6 -3
- package/dist/chat-ui/index.js +16 -2
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +31 -4
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.js +31 -4
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +19 -1
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +13 -0
- package/dist/chat-ui/messages/message-components.js +19 -1
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +2 -1
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
- package/dist/chat-ui/messages/runtime-message.js +2 -1
- package/dist/chat-ui/messages/runtime-message.js.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +1 -0
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.js +1 -0
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +3 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +3 -1
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +84 -0
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -0
- package/dist/chat-ui/messages/wake-marker.d.ts +16 -0
- package/dist/chat-ui/messages/wake-marker.js +84 -0
- package/dist/chat-ui/messages/wake-marker.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-blocks.cjs +177 -0
- package/dist/chat-ui/rich-text/chat-blocks.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-blocks.d.ts +58 -0
- package/dist/chat-ui/rich-text/chat-blocks.js +177 -0
- package/dist/chat-ui/rich-text/chat-blocks.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-link.cjs +69 -0
- package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-link.d.ts +24 -0
- package/dist/chat-ui/rich-text/chat-link.js +69 -0
- package/dist/chat-ui/rich-text/chat-link.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs +144 -18
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +10 -1
- package/dist/chat-ui/rich-text/chat-message-body.js +149 -23
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.cjs +38 -5
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.d.ts +11 -0
- package/dist/chat-ui/rich-text/chat-node-views.js +39 -6
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +20 -3
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +15 -2
- package/dist/chat-ui/rich-text/chat-text-schema.js +20 -3
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/rich-text/citation-anchors.cjs +139 -0
- package/dist/chat-ui/rich-text/citation-anchors.cjs.map +1 -0
- package/dist/chat-ui/rich-text/citation-anchors.d.ts +74 -0
- package/dist/chat-ui/rich-text/citation-anchors.js +139 -0
- package/dist/chat-ui/rich-text/citation-anchors.js.map +1 -0
- package/dist/chat-ui/statewire.cjs +8 -1
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +2 -0
- package/dist/chat-ui/statewire.js +8 -1
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/chat-composer-dock.cjs +27 -6
- package/dist/chat-ui/thread/chat-composer-dock.cjs.map +1 -1
- package/dist/chat-ui/thread/chat-composer-dock.d.ts +21 -1
- package/dist/chat-ui/thread/chat-composer-dock.js +28 -7
- package/dist/chat-ui/thread/chat-composer-dock.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +12 -13
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +11 -10
- package/dist/chat-ui/thread/statewire-history-edge.js +13 -14
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/chat-ui/thread/thread-loading-overlay.cjs +31 -0
- package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -0
- package/dist/chat-ui/thread/thread-loading-overlay.d.ts +14 -0
- package/dist/chat-ui/thread/thread-loading-overlay.js +31 -0
- package/dist/chat-ui/thread/thread-loading-overlay.js.map +1 -0
- package/dist/composer/ComposerDropZone.cjs +8 -1
- package/dist/composer/ComposerDropZone.cjs.map +1 -1
- package/dist/composer/ComposerDropZone.d.ts +6 -0
- package/dist/composer/ComposerDropZone.js +9 -2
- package/dist/composer/ComposerDropZone.js.map +1 -1
- package/dist/diagnostics/errors.cjs +20 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +20 -0
- package/dist/diagnostics/errors.js +20 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +47 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -7
- package/dist/index.js +51 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/use-prefers-reduced-motion.cjs +29 -0
- package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -0
- package/dist/lib/use-prefers-reduced-motion.d.ts +6 -0
- package/dist/lib/use-prefers-reduced-motion.js +29 -0
- package/dist/lib/use-prefers-reduced-motion.js.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-index.js.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs +59 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.js +60 -1
- package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs +5 -3
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js +5 -3
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs +21 -17
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.js +22 -18
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +9 -11
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +9 -11
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/packages/agent-runtime/src/github-wake-event.cjs +86 -0
- package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/github-wake-event.js +86 -0
- package/dist/packages/agent-runtime/src/github-wake-event.js.map +1 -0
- package/dist/packages/agent-runtime/src/message-window.cjs +150 -42
- package/dist/packages/agent-runtime/src/message-window.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/message-window.js +151 -43
- package/dist/packages/agent-runtime/src/message-window.js.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +13 -9
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +13 -9
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs +1 -3
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.js +1 -3
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +61 -30
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js +59 -28
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs +56 -36
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js +59 -39
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/dist/provider/AthenaContext.cjs.map +1 -1
- package/dist/provider/AthenaContext.d.ts +3 -0
- package/dist/provider/AthenaContext.js.map +1 -1
- package/dist/provider/AthenaProvider.cjs +93 -45
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +6 -1
- package/dist/provider/AthenaProvider.js +97 -49
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +2 -1
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.js +2 -1
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +3 -2
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -12
- package/dist/runtime/useAthenaStatewireRuntime.js +3 -2
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaRepoSearch.cjs +94 -0
- package/dist/search/useAthenaRepoSearch.cjs.map +1 -0
- package/dist/search/useAthenaRepoSearch.d.ts +95 -0
- package/dist/search/useAthenaRepoSearch.js +94 -0
- package/dist/search/useAthenaRepoSearch.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/threads/SessionList.cjs +486 -0
- package/dist/threads/SessionList.cjs.map +1 -0
- package/dist/threads/SessionList.d.ts +60 -0
- package/dist/threads/SessionList.js +486 -0
- package/dist/threads/SessionList.js.map +1 -0
- package/dist/threads/api.cjs +112 -4
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +128 -1
- package/dist/threads/api.js +113 -5
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +27 -3
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +16 -3
- package/dist/threads/conversation-list-fetcher.js +27 -3
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/index.d.ts +5 -1
- package/dist/threads/session-list-model.cjs +130 -0
- package/dist/threads/session-list-model.cjs.map +1 -0
- package/dist/threads/session-list-model.d.ts +62 -0
- package/dist/threads/session-list-model.js +130 -0
- package/dist/threads/session-list-model.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +220 -38
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +152 -2
- package/dist/threads/statewire-thread-list.js +222 -40
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/thread-prefetcher.cjs +63 -0
- package/dist/threads/thread-prefetcher.cjs.map +1 -0
- package/dist/threads/thread-prefetcher.d.ts +54 -0
- package/dist/threads/thread-prefetcher.js +63 -0
- package/dist/threads/thread-prefetcher.js.map +1 -0
- package/dist/threads/use-athena-session-attention.cjs +22 -0
- package/dist/threads/use-athena-session-attention.cjs.map +1 -0
- package/dist/threads/use-athena-session-attention.d.ts +24 -0
- package/dist/threads/use-athena-session-attention.js +22 -0
- package/dist/threads/use-athena-session-attention.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +25 -2
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.d.ts +8 -1
- package/dist/threads/use-rest-conversation-history.js +25 -2
- package/dist/threads/use-rest-conversation-history.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +40 -16
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +13 -0
- package/dist/threads/use-statewire-conversation-history.js +40 -16
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/threads/use-thread-archive.cjs +128 -0
- package/dist/threads/use-thread-archive.cjs.map +1 -0
- package/dist/threads/use-thread-archive.d.ts +26 -0
- package/dist/threads/use-thread-archive.js +128 -0
- package/dist/threads/use-thread-archive.js.map +1 -0
- package/dist/threads/use-thread-favorite.cjs +53 -0
- package/dist/threads/use-thread-favorite.cjs.map +1 -0
- package/dist/threads/use-thread-favorite.d.ts +49 -0
- package/dist/threads/use-thread-favorite.js +53 -0
- package/dist/threads/use-thread-favorite.js.map +1 -0
- package/dist/threads/use-thread-field-override.cjs +184 -0
- package/dist/threads/use-thread-field-override.cjs.map +1 -0
- package/dist/threads/use-thread-field-override.d.ts +55 -0
- package/dist/threads/use-thread-field-override.js +184 -0
- package/dist/threads/use-thread-field-override.js.map +1 -0
- package/dist/threads/use-thread-rename.cjs +53 -0
- package/dist/threads/use-thread-rename.cjs.map +1 -0
- package/dist/threads/use-thread-rename.d.ts +48 -0
- package/dist/threads/use-thread-rename.js +53 -0
- package/dist/threads/use-thread-rename.js.map +1 -0
- package/dist/tools/index.cjs +5 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +7 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -1
- package/dist/tools/misc-tool-uis.cjs.map +1 -1
- package/dist/tools/misc-tool-uis.js +2 -1
- package/dist/tools/misc-tool-uis.js.map +1 -1
- package/dist/tools/primitives.cjs +25 -2
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/primitives.d.ts +9 -2
- package/dist/tools/primitives.js +26 -3
- package/dist/tools/primitives.js.map +1 -1
- package/dist/tools/tool-appearance.cjs +11 -0
- package/dist/tools/tool-appearance.cjs.map +1 -0
- package/dist/tools/tool-appearance.d.ts +29 -0
- package/dist/tools/tool-appearance.js +11 -0
- package/dist/tools/tool-appearance.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +211 -13
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.d.ts +31 -4
- package/dist/tools/tool-fallback.js +214 -16
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/use-elapsed-seconds.cjs +24 -0
- package/dist/tools/use-elapsed-seconds.cjs.map +1 -0
- package/dist/tools/use-elapsed-seconds.d.ts +10 -0
- package/dist/tools/use-elapsed-seconds.js +24 -0
- package/dist/tools/use-elapsed-seconds.js.map +1 -0
- package/dist/tools/voice-update-tool-ui.cjs +2 -1
- package/dist/tools/voice-update-tool-ui.cjs.map +1 -1
- package/dist/tools/voice-update-tool-ui.js +2 -1
- package/dist/tools/voice-update-tool-ui.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-ui/tailwind-preset.js +14 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactQuery = require("@tanstack/react-query");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const mint = require("../collab/mint.cjs");
|
|
6
|
+
const errors = require("../diagnostics/errors.cjs");
|
|
7
|
+
const AthenaContext = require("../provider/AthenaContext.cjs");
|
|
8
|
+
const statewireAuthHeaders = require("../runtime/statewire-auth-headers.cjs");
|
|
9
|
+
const credentialShape = require("../threads/credential-shape.cjs");
|
|
10
|
+
const ATHENA_REPO_SEARCH_PATH = "/api/search/repositories";
|
|
11
|
+
function repoSearchRequestBody(params) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const body = { query: params.query.trim() };
|
|
14
|
+
if (params.limit !== void 0) body.limit = params.limit;
|
|
15
|
+
if (params.mode !== void 0) body.mode = params.mode;
|
|
16
|
+
if ((_a = params.repositoryAssetIds) == null ? void 0 : _a.length) body.repository_asset_ids = params.repositoryAssetIds;
|
|
17
|
+
if ((_b = params.paths) == null ? void 0 : _b.length) body.paths = params.paths;
|
|
18
|
+
if ((_c = params.languages) == null ? void 0 : _c.length) body.languages = params.languages;
|
|
19
|
+
return body;
|
|
20
|
+
}
|
|
21
|
+
function isAbortError(error) {
|
|
22
|
+
return (error instanceof DOMException || error instanceof Error) && error.name === "AbortError";
|
|
23
|
+
}
|
|
24
|
+
async function fetchRepoSearch(backendUrl, auth, params, opts = {}) {
|
|
25
|
+
const url = `${mint.getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;
|
|
26
|
+
const body = JSON.stringify(repoSearchRequestBody(params));
|
|
27
|
+
const post = async (staleAuth) => {
|
|
28
|
+
const headers = await statewireAuthHeaders.resolveStatewireAuthHeaders(auth, { staleAuth });
|
|
29
|
+
try {
|
|
30
|
+
return await fetch(url, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
33
|
+
body,
|
|
34
|
+
signal: opts.signal ?? null
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (isAbortError(error)) throw error;
|
|
38
|
+
throw new errors.AthenaSdkError({
|
|
39
|
+
code: "repo_search_failed",
|
|
40
|
+
message: "Repository search could not reach the Agora API.",
|
|
41
|
+
cause: error,
|
|
42
|
+
hint: "Check the network and that backendUrl points at the Agora API base."
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
let res = await post(false);
|
|
47
|
+
if (res.status === 401 && auth.getToken) res = await post(true);
|
|
48
|
+
if (!res.ok) {
|
|
49
|
+
const refused = res.status === 401 || res.status === 403;
|
|
50
|
+
throw new errors.AthenaSdkError({
|
|
51
|
+
code: refused ? "auth_rejected" : "repo_search_failed",
|
|
52
|
+
message: `Repository search failed: ${res.status}`,
|
|
53
|
+
status: res.status,
|
|
54
|
+
detail: await res.json().catch(() => void 0),
|
|
55
|
+
hint: refused ? "Repository search is limited to Athena platform staff on the managed cloud; check the credential." : res.status === 404 ? "Repository search is not offered on this deployment (managed cloud only)." : "Check backendUrl points at the Agora API base and that Clio is available."
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return await res.json();
|
|
59
|
+
}
|
|
60
|
+
function useAthenaRepoSearch({
|
|
61
|
+
enabled = true,
|
|
62
|
+
...params
|
|
63
|
+
}) {
|
|
64
|
+
const config = AthenaContext.useAthenaConfig();
|
|
65
|
+
const { backendUrl, apiKey, getToken } = config;
|
|
66
|
+
const credentialsRef = react.useRef(credentialShape.credentialShape({ apiKey, token: config.token, getToken }));
|
|
67
|
+
const generationRef = react.useRef(0);
|
|
68
|
+
const currentCredentials = credentialShape.credentialShape({ apiKey, token: config.token, getToken });
|
|
69
|
+
if (!credentialShape.sameCredentialShape(credentialsRef.current, currentCredentials)) {
|
|
70
|
+
credentialsRef.current = currentCredentials;
|
|
71
|
+
generationRef.current += 1;
|
|
72
|
+
}
|
|
73
|
+
const body = repoSearchRequestBody(params);
|
|
74
|
+
const contextClient = react.useContext(reactQuery.QueryClientContext);
|
|
75
|
+
const [fallbackClient] = react.useState(() => contextClient ? void 0 : new reactQuery.QueryClient());
|
|
76
|
+
return reactQuery.useQuery(
|
|
77
|
+
{
|
|
78
|
+
queryKey: ["athena-sdk", "repo-search", backendUrl, generationRef.current, body],
|
|
79
|
+
// `config.token` is read at fetch time: the provider serves the latest
|
|
80
|
+
// token through a getter, so rotations reach the request.
|
|
81
|
+
queryFn: ({ signal }) => fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),
|
|
82
|
+
enabled: enabled && body.query.length > 0 && backendUrl.length > 0,
|
|
83
|
+
staleTime: 3e4,
|
|
84
|
+
placeholderData: reactQuery.keepPreviousData,
|
|
85
|
+
refetchOnWindowFocus: false
|
|
86
|
+
},
|
|
87
|
+
contextClient ?? fallbackClient
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
exports.ATHENA_REPO_SEARCH_PATH = ATHENA_REPO_SEARCH_PATH;
|
|
91
|
+
exports.fetchRepoSearch = fetchRepoSearch;
|
|
92
|
+
exports.repoSearchRequestBody = repoSearchRequestBody;
|
|
93
|
+
exports.useAthenaRepoSearch = useAthenaRepoSearch;
|
|
94
|
+
//# sourceMappingURL=useAthenaRepoSearch.cjs.map
|
|
@@ -0,0 +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 {\n resolveStatewireAuthHeaders,\n type StatewireAuthSource,\n} 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 `401` gets one\n * forced re-mint through `getToken` (`force: true`, the statewire\n * transport's `staleAuth` contract) — a getter that caches until forced would\n * otherwise resend the same expired token on every retry. Every failure is an\n * `AthenaSdkError`, transport rejections included; only an abort keeps its\n * 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 (staleAuth: boolean): Promise<Response> => {\n const headers = await resolveStatewireAuthHeaders(auth, { staleAuth });\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 let res = await post(false);\n if (res.status === 401 && auth.getToken) res = await post(true);\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","resolveStatewireAuthHeaders","AthenaSdkError","useAthenaConfig","useRef","credentialShape","sameCredentialShape","useContext","QueryClientContext","useState","QueryClient","useQuery","keepPreviousData"],"mappings":";;;;;;;;;AA2FO,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,sBAAsB,MAAM,CAAC;AACzD,QAAM,OAAO,OAAO,cAA0C;AAC5D,UAAM,UAAU,MAAMC,qBAAAA,4BAA4B,MAAM,EAAE,WAAW;AACrE,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,IAAIC,OAAAA,eAAe;AAAA,QACvB,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,MAAM;AAAA,MAAA,CACP;AAAA,IACH;AAAA,EACF;AACA,MAAI,MAAM,MAAM,KAAK,KAAK;AAC1B,MAAI,IAAI,WAAW,OAAO,KAAK,SAAU,OAAM,MAAM,KAAK,IAAI;AAC9D,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,UAAU,IAAI,WAAW,OAAO,IAAI,WAAW;AACrD,UAAM,IAAIA,OAAAA,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,SAASC,cAAAA,gBAAA;AACf,QAAM,EAAE,YAAY,QAAQ,SAAA,IAAa;AACzC,QAAM,iBAAiBC,aAAOC,gBAAAA,gBAAgB,EAAE,QAAQ,OAAO,OAAO,OAAO,SAAA,CAAU,CAAC;AACxF,QAAM,gBAAgBD,MAAAA,OAAO,CAAC;AAC9B,QAAM,qBAAqBC,gBAAAA,gBAAgB,EAAE,QAAQ,OAAO,OAAO,OAAO,UAAU;AACpF,MAAI,CAACC,gBAAAA,oBAAoB,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;;;;;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code search over the workspace's indexed repositories —
|
|
3
|
+
* `POST /api/search/repositories` (agora `web/api/search/repositories.py`),
|
|
4
|
+
* the HTTP face of Clio's repository source for a Devin-style "Ask" surface
|
|
5
|
+
* that searches the monorepo without an agent turn. Athena platform staff
|
|
6
|
+
* only (the account-level `is_admin`, not a workspace role) on the managed
|
|
7
|
+
* cloud today: a non-staff caller reads `403`, a private deployment `404`.
|
|
8
|
+
*/
|
|
9
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
10
|
+
import { type StatewireAuthSource } from '../runtime/statewire-auth-headers';
|
|
11
|
+
export type AthenaRepoSearchMode = 'hybrid' | 'lexical';
|
|
12
|
+
/** One file range of one indexed repository, as the route serves it. */
|
|
13
|
+
export interface AthenaRepoSearchHit {
|
|
14
|
+
/** The GitHub catalog asset the repository is connected through. */
|
|
15
|
+
catalogAssetId: string;
|
|
16
|
+
/** `owner/repo`; `null` when the catalog names no repository. */
|
|
17
|
+
repoFullName: string | null;
|
|
18
|
+
/** Repo-relative, `/`-separated. */
|
|
19
|
+
path: string;
|
|
20
|
+
/** 1-based, inclusive. */
|
|
21
|
+
startLine: number;
|
|
22
|
+
endLine: number;
|
|
23
|
+
/** The enclosing declaration (`Class.method`) when the chunk's header named one. */
|
|
24
|
+
symbol: string | null;
|
|
25
|
+
/** Clio's language name for the file (`python`, `typescript`, …). */
|
|
26
|
+
language: string | null;
|
|
27
|
+
/** `code` (an AST chunk) or `window` (a Markdown heading window). */
|
|
28
|
+
unitType: string;
|
|
29
|
+
score: number;
|
|
30
|
+
/** The indexed commit the hit was read at. */
|
|
31
|
+
commitSha: string | null;
|
|
32
|
+
/** `{origin}/{owner}/{repo}/blob/{sha}/{path}#L{a}-L{b}`, GHES-aware. */
|
|
33
|
+
githubUrl: string | null;
|
|
34
|
+
/** The chunk's lines, header line removed, line breaks preserved. */
|
|
35
|
+
snippet: string;
|
|
36
|
+
/** `asset_<catalog>?anchor=file_line_range&…` — what `read_asset` and a citation take. */
|
|
37
|
+
readAssetReference: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AthenaRepoSearchResponse {
|
|
40
|
+
/** Best first, at most `limit`. */
|
|
41
|
+
hits: AthenaRepoSearchHit[];
|
|
42
|
+
tookMs: number;
|
|
43
|
+
mode: AthenaRepoSearchMode;
|
|
44
|
+
}
|
|
45
|
+
export interface AthenaRepoSearchParams {
|
|
46
|
+
query: string;
|
|
47
|
+
/** 1–25; the route's default is 10. */
|
|
48
|
+
limit?: number;
|
|
49
|
+
/** `hybrid` (default) or `lexical`. */
|
|
50
|
+
mode?: AthenaRepoSearchMode;
|
|
51
|
+
/** Search these GitHub catalog assets only; empty means every indexed repository. */
|
|
52
|
+
repositoryAssetIds?: string[];
|
|
53
|
+
/** gitignore-style globs a hit's path must match (`agora/**\/*.py`, `docs/`). */
|
|
54
|
+
paths?: string[];
|
|
55
|
+
/** Clio language names a hit's file must be indexed as. */
|
|
56
|
+
languages?: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface UseAthenaRepoSearchOptions extends AthenaRepoSearchParams {
|
|
59
|
+
/** `false` holds the query idle (a blank `query` does too). Default `true`. */
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** The route's JSON body — snake_case, unset filters omitted. */
|
|
63
|
+
export interface AthenaRepoSearchRequestBody {
|
|
64
|
+
query: string;
|
|
65
|
+
limit?: number;
|
|
66
|
+
mode?: AthenaRepoSearchMode;
|
|
67
|
+
repository_asset_ids?: string[];
|
|
68
|
+
paths?: string[];
|
|
69
|
+
languages?: string[];
|
|
70
|
+
}
|
|
71
|
+
export declare const ATHENA_REPO_SEARCH_PATH = "/api/search/repositories";
|
|
72
|
+
export declare function repoSearchRequestBody(params: AthenaRepoSearchParams): AthenaRepoSearchRequestBody;
|
|
73
|
+
/**
|
|
74
|
+
* One search request. The credential rides `Authorization: Bearer` (a token,
|
|
75
|
+
* resolved live through `getToken` when the host provided one) or
|
|
76
|
+
* `X-API-KEY`; with neither, a same-origin host's session cookie rides
|
|
77
|
+
* automatically, as the SDK's other REST helpers allow. A `401` gets one
|
|
78
|
+
* forced re-mint through `getToken` (`force: true`, the statewire
|
|
79
|
+
* transport's `staleAuth` contract) — a getter that caches until forced would
|
|
80
|
+
* otherwise resend the same expired token on every retry. Every failure is an
|
|
81
|
+
* `AthenaSdkError`, transport rejections included; only an abort keeps its
|
|
82
|
+
* own identity.
|
|
83
|
+
*/
|
|
84
|
+
export declare function fetchRepoSearch(backendUrl: string, auth: StatewireAuthSource, params: AthenaRepoSearchParams, opts?: {
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
}): Promise<AthenaRepoSearchResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Search the indexed repositories through TanStack Query with the provider's
|
|
89
|
+
* `backendUrl` and credentials. Keyed by the non-secret request and a
|
|
90
|
+
* credential generation (a counter that advances when the host's credentials
|
|
91
|
+
* change), never by the credential itself. Uses the host's `QueryClient` when
|
|
92
|
+
* one is in context (`enableThreadList` mounts the SDK's own) and a
|
|
93
|
+
* hook-scoped client otherwise, so it works under any `<AthenaProvider>`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function useAthenaRepoSearch({ enabled, ...params }: UseAthenaRepoSearchOptions): UseQueryResult<AthenaRepoSearchResponse, Error>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { QueryClientContext, QueryClient, useQuery, keepPreviousData } from "@tanstack/react-query";
|
|
2
|
+
import { useRef, useContext, useState } from "react";
|
|
3
|
+
import { getAthenaApiBaseUrl } from "../collab/mint.js";
|
|
4
|
+
import { AthenaSdkError } from "../diagnostics/errors.js";
|
|
5
|
+
import { useAthenaConfig } from "../provider/AthenaContext.js";
|
|
6
|
+
import { resolveStatewireAuthHeaders } from "../runtime/statewire-auth-headers.js";
|
|
7
|
+
import { credentialShape, sameCredentialShape } from "../threads/credential-shape.js";
|
|
8
|
+
const ATHENA_REPO_SEARCH_PATH = "/api/search/repositories";
|
|
9
|
+
function repoSearchRequestBody(params) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const body = { query: params.query.trim() };
|
|
12
|
+
if (params.limit !== void 0) body.limit = params.limit;
|
|
13
|
+
if (params.mode !== void 0) body.mode = params.mode;
|
|
14
|
+
if ((_a = params.repositoryAssetIds) == null ? void 0 : _a.length) body.repository_asset_ids = params.repositoryAssetIds;
|
|
15
|
+
if ((_b = params.paths) == null ? void 0 : _b.length) body.paths = params.paths;
|
|
16
|
+
if ((_c = params.languages) == null ? void 0 : _c.length) body.languages = params.languages;
|
|
17
|
+
return body;
|
|
18
|
+
}
|
|
19
|
+
function isAbortError(error) {
|
|
20
|
+
return (error instanceof DOMException || error instanceof Error) && error.name === "AbortError";
|
|
21
|
+
}
|
|
22
|
+
async function fetchRepoSearch(backendUrl, auth, params, opts = {}) {
|
|
23
|
+
const url = `${getAthenaApiBaseUrl(backendUrl)}${ATHENA_REPO_SEARCH_PATH}`;
|
|
24
|
+
const body = JSON.stringify(repoSearchRequestBody(params));
|
|
25
|
+
const post = async (staleAuth) => {
|
|
26
|
+
const headers = await resolveStatewireAuthHeaders(auth, { staleAuth });
|
|
27
|
+
try {
|
|
28
|
+
return await fetch(url, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
31
|
+
body,
|
|
32
|
+
signal: opts.signal ?? null
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (isAbortError(error)) throw error;
|
|
36
|
+
throw new AthenaSdkError({
|
|
37
|
+
code: "repo_search_failed",
|
|
38
|
+
message: "Repository search could not reach the Agora API.",
|
|
39
|
+
cause: error,
|
|
40
|
+
hint: "Check the network and that backendUrl points at the Agora API base."
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let res = await post(false);
|
|
45
|
+
if (res.status === 401 && auth.getToken) res = await post(true);
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
const refused = res.status === 401 || res.status === 403;
|
|
48
|
+
throw new AthenaSdkError({
|
|
49
|
+
code: refused ? "auth_rejected" : "repo_search_failed",
|
|
50
|
+
message: `Repository search failed: ${res.status}`,
|
|
51
|
+
status: res.status,
|
|
52
|
+
detail: await res.json().catch(() => void 0),
|
|
53
|
+
hint: refused ? "Repository search is limited to Athena platform staff on the managed cloud; check the credential." : res.status === 404 ? "Repository search is not offered on this deployment (managed cloud only)." : "Check backendUrl points at the Agora API base and that Clio is available."
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return await res.json();
|
|
57
|
+
}
|
|
58
|
+
function useAthenaRepoSearch({
|
|
59
|
+
enabled = true,
|
|
60
|
+
...params
|
|
61
|
+
}) {
|
|
62
|
+
const config = useAthenaConfig();
|
|
63
|
+
const { backendUrl, apiKey, getToken } = config;
|
|
64
|
+
const credentialsRef = useRef(credentialShape({ apiKey, token: config.token, getToken }));
|
|
65
|
+
const generationRef = useRef(0);
|
|
66
|
+
const currentCredentials = credentialShape({ apiKey, token: config.token, getToken });
|
|
67
|
+
if (!sameCredentialShape(credentialsRef.current, currentCredentials)) {
|
|
68
|
+
credentialsRef.current = currentCredentials;
|
|
69
|
+
generationRef.current += 1;
|
|
70
|
+
}
|
|
71
|
+
const body = repoSearchRequestBody(params);
|
|
72
|
+
const contextClient = useContext(QueryClientContext);
|
|
73
|
+
const [fallbackClient] = useState(() => contextClient ? void 0 : new QueryClient());
|
|
74
|
+
return useQuery(
|
|
75
|
+
{
|
|
76
|
+
queryKey: ["athena-sdk", "repo-search", backendUrl, generationRef.current, body],
|
|
77
|
+
// `config.token` is read at fetch time: the provider serves the latest
|
|
78
|
+
// token through a getter, so rotations reach the request.
|
|
79
|
+
queryFn: ({ signal }) => fetchRepoSearch(backendUrl, { apiKey, token: config.token, getToken }, params, { signal }),
|
|
80
|
+
enabled: enabled && body.query.length > 0 && backendUrl.length > 0,
|
|
81
|
+
staleTime: 3e4,
|
|
82
|
+
placeholderData: keepPreviousData,
|
|
83
|
+
refetchOnWindowFocus: false
|
|
84
|
+
},
|
|
85
|
+
contextClient ?? fallbackClient
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
ATHENA_REPO_SEARCH_PATH,
|
|
90
|
+
fetchRepoSearch,
|
|
91
|
+
repoSearchRequestBody,
|
|
92
|
+
useAthenaRepoSearch
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=useAthenaRepoSearch.js.map
|
|
@@ -0,0 +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 {\n resolveStatewireAuthHeaders,\n type StatewireAuthSource,\n} 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 `401` gets one\n * forced re-mint through `getToken` (`force: true`, the statewire\n * transport's `staleAuth` contract) — a getter that caches until forced would\n * otherwise resend the same expired token on every retry. Every failure is an\n * `AthenaSdkError`, transport rejections included; only an abort keeps its\n * 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 (staleAuth: boolean): Promise<Response> => {\n const headers = await resolveStatewireAuthHeaders(auth, { staleAuth });\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 let res = await post(false);\n if (res.status === 401 && auth.getToken) res = await post(true);\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":"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"}
|