@athenaintel/react 0.42.2 → 0.48.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 +225 -3
- package/dist/agent-runtime/src/answer-label.cjs +137 -0
- package/dist/agent-runtime/src/answer-label.cjs.map +1 -0
- package/dist/agent-runtime/src/answer-label.d.ts +104 -0
- package/dist/agent-runtime/src/answer-label.js +137 -0
- package/dist/agent-runtime/src/answer-label.js.map +1 -0
- package/dist/agent-runtime/src/answer-rows.cjs +180 -0
- package/dist/agent-runtime/src/answer-rows.cjs.map +1 -0
- package/dist/agent-runtime/src/answer-rows.d.ts +86 -0
- package/dist/agent-runtime/src/answer-rows.js +180 -0
- package/dist/agent-runtime/src/answer-rows.js.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.cjs +15 -15
- package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
- package/dist/agent-runtime/src/conversation-index.cjs +8 -8
- package/dist/agent-runtime/src/conversation-index.cjs.map +1 -1
- package/dist/agent-runtime/src/conversation-list-groups.d.ts +74 -0
- package/dist/agent-runtime/src/decision-checks.cjs +207 -0
- package/dist/agent-runtime/src/decision-checks.cjs.map +1 -0
- package/dist/agent-runtime/src/decision-checks.d.ts +142 -0
- package/dist/agent-runtime/src/decision-checks.js +207 -0
- package/dist/agent-runtime/src/decision-checks.js.map +1 -0
- package/dist/agent-runtime/src/desktop-handoff.d.ts +12 -0
- package/dist/agent-runtime/src/errors.cjs +18 -0
- package/dist/agent-runtime/src/errors.cjs.map +1 -1
- package/dist/agent-runtime/src/errors.d.ts +7 -0
- package/dist/agent-runtime/src/errors.js +18 -0
- package/dist/agent-runtime/src/errors.js.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs +12 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +6 -6
- package/dist/agent-runtime/src/generated/runconfig-contract.js +12 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/agent-runtime/src/handoff-arrival.cjs +60 -0
- package/dist/agent-runtime/src/handoff-arrival.cjs.map +1 -0
- package/dist/agent-runtime/src/handoff-arrival.d.ts +46 -0
- package/dist/agent-runtime/src/handoff-arrival.js +60 -0
- package/dist/agent-runtime/src/handoff-arrival.js.map +1 -0
- package/dist/agent-runtime/src/index.d.ts +15 -8
- package/dist/agent-runtime/src/interrupts.cjs +43 -18
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/agent-runtime/src/interrupts.d.ts +19 -2
- package/dist/agent-runtime/src/interrupts.js +28 -3
- package/dist/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/agent-runtime/src/lane-history.cjs +8 -8
- package/dist/agent-runtime/src/lane-history.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.cjs +43 -8
- package/dist/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.d.ts +25 -3
- package/dist/agent-runtime/src/messages.js +43 -8
- package/dist/agent-runtime/src/messages.js.map +1 -1
- package/dist/agent-runtime/src/offline-status.cjs +36 -0
- package/dist/agent-runtime/src/offline-status.cjs.map +1 -0
- package/dist/agent-runtime/src/offline-status.d.ts +118 -3
- package/dist/agent-runtime/src/offline-status.js +36 -0
- package/dist/agent-runtime/src/offline-status.js.map +1 -0
- package/dist/agent-runtime/src/queue.cjs +0 -9
- package/dist/agent-runtime/src/queue.cjs.map +1 -1
- package/dist/agent-runtime/src/queue.js +0 -9
- package/dist/agent-runtime/src/queue.js.map +1 -1
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +9 -9
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/agent-runtime/src/runtime-catalog.cjs +42 -0
- package/dist/agent-runtime/src/runtime-catalog.cjs.map +1 -0
- package/dist/agent-runtime/src/runtime-catalog.d.ts +35 -0
- package/dist/agent-runtime/src/runtime-catalog.js +42 -0
- package/dist/agent-runtime/src/runtime-catalog.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -1
- package/dist/agent-runtime/src/runtime-messages.d.ts +1 -1
- package/dist/agent-runtime/src/runtime-messages.js.map +1 -1
- package/dist/agent-runtime/src/runtime.d.ts +40 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs +3 -3
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
- package/dist/agent-runtime/src/subagents.cjs +32 -2
- package/dist/agent-runtime/src/subagents.cjs.map +1 -1
- package/dist/agent-runtime/src/subagents.d.ts +9 -0
- package/dist/agent-runtime/src/subagents.js +30 -0
- package/dist/agent-runtime/src/subagents.js.map +1 -1
- package/dist/agent-runtime/src/thread-driver.cjs +67 -0
- package/dist/agent-runtime/src/thread-driver.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-driver.d.ts +49 -0
- package/dist/agent-runtime/src/thread-driver.js +67 -0
- package/dist/agent-runtime/src/thread-driver.js.map +1 -0
- package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +172 -0
- package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +756 -0
- package/dist/agent-runtime/src/thread-handoff-qr.d.ts +11 -0
- package/dist/agent-runtime/src/thread-handoff.d.ts +3 -364
- package/dist/agent-runtime/src/thread-status.cjs +3 -3
- package/dist/agent-runtime/src/thread-status.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-metadata.cjs +210 -33
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-metadata.d.ts +12 -0
- package/dist/agent-runtime/src/tool-metadata.js +210 -33
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/agent-runtime/src/tool-names.cjs +2 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-names.d.ts +2 -0
- package/dist/agent-runtime/src/tool-names.js +2 -0
- package/dist/agent-runtime/src/tool-names.js.map +1 -1
- package/dist/agent-runtime/src/types.d.ts +10 -2
- package/dist/agent-runtime/src/use-conversation-list.cjs +11 -11
- package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +24 -19
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +2 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +6 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-config.cjs +14 -14
- package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +6 -6
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +16 -16
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +45 -45
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs +572 -134
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +137 -10
- package/dist/agent-runtime/src/use-deep-agent-voice.js +514 -76
- package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +26 -26
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +4 -4
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -1
- package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +28 -26
- package/dist/agent-runtime/src/voice-media.cjs +117 -0
- package/dist/agent-runtime/src/voice-media.cjs.map +1 -0
- package/dist/agent-runtime/src/voice-media.d.ts +49 -0
- package/dist/agent-runtime/src/voice-media.js +117 -0
- package/dist/agent-runtime/src/voice-media.js.map +1 -0
- package/dist/agent-runtime/src/voice-wire-types.d.ts +32 -0
- package/dist/assets/AssetPanel.cjs +11 -11
- package/dist/assets/AssetPanel.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.cjs +11 -9
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +7 -0
- package/dist/assets/AthenaAssetEmbed.js +4 -2
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/AthenaLayout.cjs +16 -16
- package/dist/assets/AthenaLayout.cjs.map +1 -1
- package/dist/assets/use-asset-content.cjs +4 -4
- package/dist/assets/use-asset-content.cjs.map +1 -1
- package/dist/assets/use-asset-embed.cjs +14 -7
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.d.ts +11 -1
- package/dist/assets/use-asset-embed.js +10 -3
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/auth/AthenaAuthContext.cjs +3 -3
- package/dist/auth/AthenaAuthContext.cjs.map +1 -1
- package/dist/auth/AthenaAuthProvider.cjs +8 -8
- package/dist/auth/AthenaAuthProvider.cjs.map +1 -1
- package/dist/auth/AthenaCredentialSourceContext.cjs +5 -5
- package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
- package/dist/auth/AthenaSSOProvider.cjs +14 -14
- package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
- package/dist/auth/credential-source.cjs +26 -13
- package/dist/auth/credential-source.cjs.map +1 -1
- package/dist/auth/credential-source.d.ts +8 -0
- package/dist/auth/credential-source.js +26 -13
- package/dist/auth/credential-source.js.map +1 -1
- package/dist/catalog/agent-model-options.cjs +25 -17
- package/dist/catalog/agent-model-options.cjs.map +1 -1
- package/dist/catalog/agent-model-options.d.ts +38 -5
- package/dist/catalog/agent-model-options.js +25 -17
- package/dist/catalog/agent-model-options.js.map +1 -1
- package/dist/catalog/channel-refusal.cjs +36 -0
- package/dist/catalog/channel-refusal.cjs.map +1 -0
- package/dist/catalog/channel-refusal.d.ts +29 -0
- package/dist/catalog/channel-refusal.js +36 -0
- package/dist/catalog/channel-refusal.js.map +1 -0
- package/dist/catalog/chat-pickers.cjs +60 -24
- package/dist/catalog/chat-pickers.cjs.map +1 -1
- package/dist/catalog/chat-pickers.d.ts +12 -2
- package/dist/catalog/chat-pickers.js +56 -20
- package/dist/catalog/chat-pickers.js.map +1 -1
- package/dist/catalog/runtime-catalog.cjs +89 -23
- package/dist/catalog/runtime-catalog.cjs.map +1 -1
- package/dist/catalog/runtime-catalog.d.ts +8 -2
- package/dist/catalog/runtime-catalog.js +83 -17
- package/dist/catalog/runtime-catalog.js.map +1 -1
- package/dist/catalog/use-athena-chat-mode.cjs +12 -12
- package/dist/catalog/use-athena-chat-mode.cjs.map +1 -1
- package/dist/chat/AthenaChat.cjs +155 -67
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +42 -2
- package/dist/chat/AthenaChat.js +106 -18
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/AthenaChatErrorBoundary.cjs +3 -3
- package/dist/chat/AthenaChatErrorBoundary.cjs.map +1 -1
- package/dist/chat/DrivingOnChip.cjs +23 -0
- package/dist/chat/DrivingOnChip.cjs.map +1 -0
- package/dist/chat/DrivingOnChip.d.ts +17 -0
- package/dist/chat/DrivingOnChip.js +23 -0
- package/dist/chat/DrivingOnChip.js.map +1 -0
- package/dist/chat/StatewireApprovalCard.cjs +125 -31
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +73 -1
- package/dist/chat/StatewireApprovalCard.js +115 -21
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -2
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +25 -63
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +11 -13
- package/dist/chat/StatewireQueuedMessages.js +16 -54
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/WaitingOnYouBanner.cjs +3 -3
- package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
- package/dist/chat/athena-chat-welcome.cjs +2 -2
- package/dist/chat/athena-chat-welcome.cjs.map +1 -1
- package/dist/chat/athena-citation-links.cjs +5 -5
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-composer-controls.cjs +26 -16
- package/dist/chat/athena-composer-controls.cjs.map +1 -1
- package/dist/chat/athena-composer-controls.d.ts +6 -0
- package/dist/chat/athena-composer-controls.js +26 -16
- package/dist/chat/athena-composer-controls.js.map +1 -1
- package/dist/chat/athena-turn-end-status.cjs +42 -0
- package/dist/chat/athena-turn-end-status.cjs.map +1 -0
- package/dist/chat/athena-turn-end-status.d.ts +24 -0
- package/dist/chat/athena-turn-end-status.js +42 -0
- package/dist/chat/athena-turn-end-status.js.map +1 -0
- package/dist/chat/browser-decision-check.cjs +131 -0
- package/dist/chat/browser-decision-check.cjs.map +1 -0
- package/dist/chat/browser-decision-check.d.ts +61 -0
- package/dist/chat/browser-decision-check.js +131 -0
- package/dist/chat/browser-decision-check.js.map +1 -0
- package/dist/chat/chat-outbox-rows.cjs +3 -3
- package/dist/chat/chat-outbox-rows.cjs.map +1 -1
- package/dist/chat/chat-voice-controls.cjs +93 -28
- package/dist/chat/chat-voice-controls.cjs.map +1 -1
- package/dist/chat/chat-voice-controls.d.ts +36 -2
- package/dist/chat/chat-voice-controls.js +89 -24
- package/dist/chat/chat-voice-controls.js.map +1 -1
- package/dist/chat/composer-keyboard-hint.cjs +5 -5
- package/dist/chat/composer-keyboard-hint.cjs.map +1 -1
- package/dist/chat/device-operation.cjs +29 -0
- package/dist/chat/device-operation.cjs.map +1 -0
- package/dist/chat/device-operation.d.ts +34 -0
- package/dist/chat/device-operation.js +29 -0
- package/dist/chat/device-operation.js.map +1 -0
- package/dist/chat/super-grouping/CollapsibleGroup.cjs +14 -14
- package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
- package/dist/chat/super-grouping/GroupedMessageParts.cjs +4 -4
- package/dist/chat/super-grouping/GroupedMessageParts.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +60 -38
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +24 -4
- package/dist/chat/super-grouping/SuperGroupingCard.js +37 -15
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +32 -32
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +3 -3
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.cjs +97 -37
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.d.ts +14 -2
- package/dist/chat/super-grouping/ToolTimeline.js +94 -34
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +47 -12
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +21 -0
- package/dist/chat/super-grouping/activity-timeline.js +47 -12
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/grouping-function.cjs +4 -0
- package/dist/chat/super-grouping/grouping-function.cjs.map +1 -1
- package/dist/chat/super-grouping/grouping-function.d.ts +7 -0
- package/dist/chat/super-grouping/grouping-function.js +5 -1
- package/dist/chat/super-grouping/grouping-function.js.map +1 -1
- package/dist/chat/super-grouping/index.cjs +6 -0
- package/dist/chat/super-grouping/index.cjs.map +1 -1
- package/dist/chat/super-grouping/index.d.ts +6 -2
- package/dist/chat/super-grouping/index.js +7 -1
- package/dist/chat/super-grouping/index.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +61 -2
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
- package/dist/chat/super-grouping/timeline-step.d.ts +13 -1
- package/dist/chat/super-grouping/timeline-step.js +61 -2
- package/dist/chat/super-grouping/timeline-step.js.map +1 -1
- package/dist/chat/super-grouping/tool-part-placement.cjs +17 -0
- package/dist/chat/super-grouping/tool-part-placement.cjs.map +1 -0
- package/dist/chat/super-grouping/tool-part-placement.d.ts +22 -0
- package/dist/chat/super-grouping/tool-part-placement.js +17 -0
- package/dist/chat/super-grouping/tool-part-placement.js.map +1 -0
- package/dist/chat/thread-scroll-to-bottom.cjs +2 -2
- package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -1
- package/dist/chat/thread-scroll-to-bottom.d.ts +10 -7
- package/dist/chat/thread-scroll-to-bottom.js +2 -2
- package/dist/chat/thread-scroll-to-bottom.js.map +1 -1
- package/dist/chat/tooltip-icon-button.cjs +2 -2
- package/dist/chat/tooltip-icon-button.cjs.map +1 -1
- package/dist/chat/use-athena-voice-live.cjs +11 -0
- package/dist/chat/use-athena-voice-live.cjs.map +1 -0
- package/dist/chat/use-athena-voice-live.d.ts +11 -0
- package/dist/chat/use-athena-voice-live.js +11 -0
- package/dist/chat/use-athena-voice-live.js.map +1 -0
- package/dist/chat/use-statewire-approval-request.cjs +56 -24
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +33 -4
- package/dist/chat/use-statewire-approval-request.js +41 -9
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/auth/sign-in-card.cjs +2 -2
- package/dist/chat-ui/auth/sign-in-card.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +138 -107
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +20 -4
- package/dist/chat-ui/composer/tiptap-composer.js +85 -54
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/header/conversation-history-panel.cjs +49 -23
- package/dist/chat-ui/header/conversation-history-panel.cjs.map +1 -1
- package/dist/chat-ui/header/conversation-history-panel.d.ts +12 -1
- package/dist/chat-ui/header/conversation-history-panel.js +38 -12
- package/dist/chat-ui/header/conversation-history-panel.js.map +1 -1
- package/dist/chat-ui/index.cjs +18 -0
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +7 -1
- package/dist/chat-ui/index.js +18 -0
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +147 -38
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.d.ts +17 -1
- package/dist/chat-ui/mentions/mention-chip.js +146 -37
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +10 -9
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +3 -2
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +2 -2
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +29 -6
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +7 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js +25 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs +2 -2
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs +2 -2
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +3 -3
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs +56 -2
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +12 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.js +56 -2
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +24 -3
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +7 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +24 -3
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +35 -13
- 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 +15 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +28 -6
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs +9 -6
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +3 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js +5 -2
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +45 -10
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +24 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.js +46 -11
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
- package/dist/chat-ui/mentions/use-member-avatar.cjs +4 -4
- package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -1
- package/dist/chat-ui/mentions/use-mention-asset.cjs +140 -0
- package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-mention-asset.d.ts +16 -0
- package/dist/chat-ui/mentions/use-mention-asset.js +140 -0
- package/dist/chat-ui/mentions/use-mention-asset.js.map +1 -0
- package/dist/chat-ui/messages/answer-label.cjs +42 -0
- package/dist/chat-ui/messages/answer-label.cjs.map +1 -0
- package/dist/chat-ui/messages/answer-label.d.ts +33 -0
- package/dist/chat-ui/messages/answer-label.js +42 -0
- package/dist/chat-ui/messages/answer-label.js.map +1 -0
- package/dist/chat-ui/messages/arrival-animation.cjs +13 -0
- package/dist/chat-ui/messages/arrival-animation.cjs.map +1 -0
- package/dist/chat-ui/messages/arrival-animation.d.ts +14 -0
- package/dist/chat-ui/messages/arrival-animation.js +13 -0
- package/dist/chat-ui/messages/arrival-animation.js.map +1 -0
- package/dist/chat-ui/messages/continue-pill.cjs +5 -5
- package/dist/chat-ui/messages/continue-pill.cjs.map +1 -1
- package/dist/chat-ui/messages/handoff-arrival-divider.cjs +44 -0
- package/dist/chat-ui/messages/handoff-arrival-divider.cjs.map +1 -0
- package/dist/chat-ui/messages/handoff-arrival-divider.d.ts +17 -0
- package/dist/chat-ui/messages/handoff-arrival-divider.js +44 -0
- package/dist/chat-ui/messages/handoff-arrival-divider.js.map +1 -0
- package/dist/chat-ui/messages/message-actions-config.cjs +3 -3
- package/dist/chat-ui/messages/message-actions-config.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +8 -4
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.js +5 -1
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/message-images.cjs +66 -0
- package/dist/chat-ui/messages/message-images.cjs.map +1 -0
- package/dist/chat-ui/messages/message-images.d.ts +16 -0
- package/dist/chat-ui/messages/message-images.js +66 -0
- package/dist/chat-ui/messages/message-images.js.map +1 -0
- package/dist/chat-ui/messages/user-edit-composer.cjs +2 -2
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +3 -3
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-link.cjs +7 -6
- package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-link.d.ts +2 -3
- package/dist/chat-ui/rich-text/chat-link.js +6 -5
- package/dist/chat-ui/rich-text/chat-link.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +8 -8
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.cjs +7 -6
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.js +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
- package/dist/chat-ui/rich-text/dom-output-spec.cjs +2 -2
- package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -1
- package/dist/chat-ui/statewire.cjs +3 -0
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +2 -1
- package/dist/chat-ui/statewire.js +3 -0
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/chat-thread-shell.cjs +43 -14
- package/dist/chat-ui/thread/chat-thread-shell.cjs.map +1 -1
- package/dist/chat-ui/thread/chat-thread-shell.d.ts +16 -2
- package/dist/chat-ui/thread/chat-thread-shell.js +35 -6
- package/dist/chat-ui/thread/chat-thread-shell.js.map +1 -1
- package/dist/chat-ui/thread/composer-send-or-stop.cjs +30 -20
- package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
- package/dist/chat-ui/thread/composer-send-or-stop.d.ts +8 -0
- package/dist/chat-ui/thread/composer-send-or-stop.js +29 -19
- package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +20 -21
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +3 -4
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/chat-ui/thread/thread-loading-overlay.cjs +5 -5
- package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -1
- package/dist/collab/client.cjs +40 -3
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +25 -0
- package/dist/collab/client.js +40 -3
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/document-status.cjs +150 -0
- package/dist/collab/document-status.cjs.map +1 -0
- package/dist/collab/document-status.d.ts +68 -0
- package/dist/collab/document-status.js +150 -0
- package/dist/collab/document-status.js.map +1 -0
- package/dist/collab/index.cjs +7 -0
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.ts +6 -1
- package/dist/collab/index.js +7 -0
- package/dist/collab/index.js.map +1 -1
- package/dist/collab/presence-react.cjs +11 -11
- package/dist/collab/presence-react.cjs.map +1 -1
- package/dist/collab/react.cjs +6 -6
- package/dist/collab/react.cjs.map +1 -1
- package/dist/composer/AttachmentContext.cjs +24 -11
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.js +18 -5
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/ComposerAttachmentPreview.cjs +78 -23
- package/dist/composer/ComposerAttachmentPreview.cjs.map +1 -1
- package/dist/composer/ComposerAttachmentPreview.d.ts +5 -3
- package/dist/composer/ComposerAttachmentPreview.js +79 -24
- package/dist/composer/ComposerAttachmentPreview.js.map +1 -1
- package/dist/composer/ComposerDropZone.cjs +7 -7
- package/dist/composer/ComposerDropZone.cjs.map +1 -1
- package/dist/composer/FileUploadButton.cjs +37 -22
- package/dist/composer/FileUploadButton.cjs.map +1 -1
- package/dist/composer/FileUploadButton.d.ts +6 -0
- package/dist/composer/FileUploadButton.js +34 -19
- package/dist/composer/FileUploadButton.js.map +1 -1
- package/dist/composer/QuoteContext.cjs +8 -8
- package/dist/composer/QuoteContext.cjs.map +1 -1
- package/dist/composer/composer-handoff.cjs +4 -4
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/useAppendToComposer.cjs +4 -4
- package/dist/composer/useAppendToComposer.cjs.map +1 -1
- package/dist/composer/useAttachFiles.cjs +23 -6
- package/dist/composer/useAttachFiles.cjs.map +1 -1
- package/dist/composer/useAttachFiles.d.ts +15 -7
- package/dist/composer/useAttachFiles.js +22 -5
- package/dist/composer/useAttachFiles.js.map +1 -1
- package/dist/composer/useComposerAttachment.cjs +4 -4
- package/dist/composer/useComposerAttachment.cjs.map +1 -1
- package/dist/composer/useFileUpload.cjs +21 -16
- package/dist/composer/useFileUpload.cjs.map +1 -1
- package/dist/composer/useFileUpload.d.ts +12 -0
- package/dist/composer/useFileUpload.js +12 -7
- package/dist/composer/useFileUpload.js.map +1 -1
- package/dist/composer/useReadComposerDraft.cjs +2 -2
- package/dist/composer/useReadComposerDraft.cjs.map +1 -1
- package/dist/composer/useSendMessage.cjs +4 -4
- package/dist/composer/useSendMessage.cjs.map +1 -1
- package/dist/diagnostics/useAthenaDiagnostics.cjs +4 -4
- package/dist/diagnostics/useAthenaDiagnostics.cjs.map +1 -1
- package/dist/dictation/audio-level-history.cjs +3 -3
- package/dist/dictation/audio-level-history.cjs.map +1 -1
- package/dist/dictation/dictation-controls.cjs +24 -20
- package/dist/dictation/dictation-controls.cjs.map +1 -1
- package/dist/dictation/dictation-controls.d.ts +6 -1
- package/dist/dictation/dictation-controls.js +24 -20
- package/dist/dictation/dictation-controls.js.map +1 -1
- package/dist/dictation/use-athena-dictation-engine.cjs +3 -3
- package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -1
- package/dist/dictation/use-dictation.cjs +22 -22
- package/dist/dictation/use-dictation.cjs.map +1 -1
- package/dist/index.cjs +26 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/keryx-http/src/receive-only-socket.cjs +40 -0
- package/dist/keryx-http/src/receive-only-socket.cjs.map +1 -0
- package/dist/keryx-http/src/receive-only-socket.d.ts +27 -0
- package/dist/keryx-http/src/receive-only-socket.js +40 -0
- package/dist/keryx-http/src/receive-only-socket.js.map +1 -0
- package/dist/keryx-http/src/update-attributions.cjs +111 -0
- package/dist/keryx-http/src/update-attributions.cjs.map +1 -0
- package/dist/keryx-http/src/update-attributions.d.ts +75 -0
- package/dist/keryx-http/src/update-attributions.js +111 -0
- package/dist/keryx-http/src/update-attributions.js.map +1 -0
- package/dist/lib/owner-document.cjs +6 -6
- package/dist/lib/owner-document.cjs.map +1 -1
- package/dist/lib/use-athena-rest-query.cjs +4 -4
- package/dist/lib/use-athena-rest-query.cjs.map +1 -1
- package/dist/lib/use-document-active.cjs +4 -4
- package/dist/lib/use-document-active.cjs.map +1 -1
- package/dist/lib/use-prefers-reduced-motion.cjs +2 -2
- package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -1
- package/dist/offline/offline-history.cjs +7 -7
- package/dist/offline/offline-history.cjs.map +1 -1
- package/dist/provider/AthenaContext.cjs +3 -3
- package/dist/provider/AthenaContext.cjs.map +1 -1
- package/dist/provider/AthenaProvider.cjs +116 -79
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.js +40 -3
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/PostHogProvider.cjs +2 -2
- package/dist/provider/PostHogProvider.cjs.map +1 -1
- package/dist/provider/agent-selection-context.cjs +2 -2
- package/dist/provider/agent-selection-context.cjs.map +1 -1
- package/dist/provider/chat-mode-context.cjs +2 -2
- package/dist/provider/chat-mode-context.cjs.map +1 -1
- package/dist/provider/session-persistence-context.cjs +10 -0
- package/dist/provider/session-persistence-context.cjs.map +1 -0
- package/dist/provider/session-persistence-context.d.ts +15 -0
- package/dist/provider/session-persistence-context.js +10 -0
- package/dist/provider/session-persistence-context.js.map +1 -0
- package/dist/provider/statewire-history-context.cjs +4 -4
- package/dist/provider/statewire-history-context.cjs.map +1 -1
- package/dist/provider/statewire-lifecycle-context.cjs +3 -3
- package/dist/provider/statewire-lifecycle-context.cjs.map +1 -1
- package/dist/provider/statewire-window-context.cjs +3 -3
- package/dist/provider/statewire-window-context.cjs.map +1 -1
- package/dist/provider/theme-style-context.cjs +3 -3
- package/dist/provider/theme-style-context.cjs.map +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/references/src/tool-option-schemas.d.ts +0 -34
- package/dist/runtime/StatewireThreadConfigLaneSync.cjs +10 -10
- package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
- package/dist/runtime/auth-refusal-restart.cjs +7 -7
- package/dist/runtime/auth-refusal-restart.cjs.map +1 -1
- package/dist/runtime/auth.cjs +13 -13
- package/dist/runtime/auth.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +1 -0
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.d.ts +3 -1
- package/dist/runtime/statewire-lifecycle.js +2 -1
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/statewire-server-lane-context.cjs +2 -2
- package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
- package/dist/runtime/statewire-session-lane.cjs +4 -4
- package/dist/runtime/statewire-session-lane.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +10 -8
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
- package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/Inbox.cjs +8 -8
- package/dist/threads/Inbox.cjs.map +1 -1
- package/dist/threads/SessionList.cjs +9 -9
- package/dist/threads/SessionList.cjs.map +1 -1
- package/dist/threads/SessionsPage.cjs +11 -11
- package/dist/threads/SessionsPage.cjs.map +1 -1
- package/dist/threads/index-triggered-refresh.cjs +10 -10
- package/dist/threads/index-triggered-refresh.cjs.map +1 -1
- package/dist/threads/mark-viewed-thread-read.cjs +12 -12
- package/dist/threads/mark-viewed-thread-read.cjs.map +1 -1
- package/dist/threads/offline-session-list.cjs +3 -3
- package/dist/threads/offline-session-list.cjs.map +1 -1
- package/dist/threads/session-list-tab-share.cjs +5 -5
- package/dist/threads/session-list-tab-share.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.cjs +55 -51
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +6 -2
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/thread-id-context.cjs +5 -5
- package/dist/threads/thread-id-context.cjs.map +1 -1
- package/dist/threads/use-athena-session-attention.cjs +2 -2
- package/dist/threads/use-athena-session-attention.cjs.map +1 -1
- package/dist/threads/use-athena-sessions.cjs +10 -10
- package/dist/threads/use-athena-sessions.cjs.map +1 -1
- package/dist/threads/use-athena-thread-model.cjs +3 -3
- package/dist/threads/use-athena-thread-model.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.cjs +3 -3
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +8 -8
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-thread-archive.cjs +9 -9
- package/dist/threads/use-thread-archive.cjs.map +1 -1
- package/dist/threads/use-thread-favorite.cjs +2 -2
- package/dist/threads/use-thread-favorite.cjs.map +1 -1
- package/dist/threads/use-thread-field-override.cjs +20 -20
- package/dist/threads/use-thread-field-override.cjs.map +1 -1
- package/dist/threads/use-thread-read-state.cjs +4 -4
- package/dist/threads/use-thread-read-state.cjs.map +1 -1
- package/dist/threads/use-thread-rename.cjs +2 -2
- package/dist/threads/use-thread-rename.cjs.map +1 -1
- package/dist/threads/useAthenaThreadManager.cjs +2 -2
- package/dist/threads/useAthenaThreadManager.cjs.map +1 -1
- package/dist/tools/NestedPtcMessages.cjs +6 -6
- package/dist/tools/NestedPtcMessages.cjs.map +1 -1
- package/dist/tools/append-document-tool-ui.cjs +7 -7
- package/dist/tools/append-document-tool-ui.cjs.map +1 -1
- package/dist/tools/file-tool-uis.cjs +2 -2
- package/dist/tools/file-tool-uis.cjs.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -2
- package/dist/tools/misc-tool-uis.cjs.map +1 -1
- package/dist/tools/primitives.cjs +6 -6
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/read-asset-tool-ui.cjs +6 -6
- package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
- package/dist/tools/subagent-task-tool-ui.cjs +21 -21
- package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
- package/dist/tools/test-recording-tool-uis.cjs +16 -16
- package/dist/tools/test-recording-tool-uis.cjs.map +1 -1
- package/dist/tools/todo-plan-store.cjs +4 -4
- package/dist/tools/todo-plan-store.cjs.map +1 -1
- package/dist/tools/tool-appearance.cjs +3 -3
- package/dist/tools/tool-appearance.cjs.map +1 -1
- package/dist/tools/tool-fallback.cjs +14 -14
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-summary.cjs +0 -2
- package/dist/tools/tool-summary.cjs.map +1 -1
- package/dist/tools/tool-summary.js +0 -2
- package/dist/tools/tool-summary.js.map +1 -1
- package/dist/tools/tool-uis.cjs +74 -74
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/use-elapsed-seconds.cjs +3 -3
- package/dist/tools/use-elapsed-seconds.cjs.map +1 -1
- package/dist/tools/write-todos-tool-ui.cjs +9 -9
- package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
- package/dist/ui/image-viewer.cjs +382 -0
- package/dist/ui/image-viewer.cjs.map +1 -0
- package/dist/ui/image-viewer.d.ts +50 -0
- package/dist/ui/image-viewer.js +382 -0
- package/dist/ui/image-viewer.js.map +1 -0
- package/dist/voice/chat.cjs +6 -0
- package/dist/voice/chat.cjs.map +1 -1
- package/dist/voice/chat.d.ts +1 -1
- package/dist/voice/chat.js +8 -2
- package/dist/voice/livekit-join.cjs +52 -101
- package/dist/voice/livekit-join.cjs.map +1 -1
- package/dist/voice/livekit-join.d.ts +1 -6
- package/dist/voice/livekit-join.js +52 -101
- package/dist/voice/livekit-join.js.map +1 -1
- package/dist/voice/livekit.cjs.map +1 -1
- package/dist/voice/livekit.d.ts +11 -1
- package/dist/voice/livekit.js.map +1 -1
- package/dist/voice/use-athena-voice-session.cjs +34 -34
- package/dist/voice/use-athena-voice-session.cjs.map +1 -1
- package/dist/workbench/ComputerLiveDesktop.cjs +13 -13
- package/dist/workbench/ComputerLiveDesktop.cjs.map +1 -1
- package/dist/workbench/SessionWorkbench.cjs +22 -22
- package/dist/workbench/SessionWorkbench.cjs.map +1 -1
- package/dist/workbench/session-workbench-context.cjs +3 -3
- package/dist/workbench/session-workbench-context.cjs.map +1 -1
- package/dist/workbench/session-workbench-panes.cjs +8 -8
- package/dist/workbench/session-workbench-panes.cjs.map +1 -1
- package/dist/workbench/workbench-layout-context.cjs +3 -3
- package/dist/workbench/workbench-layout-context.cjs.map +1 -1
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LabelCopy } from '../../../../agent-runtime/src/offline-status';
|
|
1
2
|
import type { MenuItem, MenuScope } from './types';
|
|
2
3
|
import type { MentionSuggestionsStore } from './use-mention-suggestions';
|
|
3
4
|
/**
|
|
@@ -28,6 +29,8 @@ export interface UseMenuItemsResult {
|
|
|
28
29
|
items: MenuItem[];
|
|
29
30
|
isFetching: boolean;
|
|
30
31
|
hasMore: boolean;
|
|
32
|
+
/** Why this scope can't load from Athena right now (`null` while it can, or for local items). */
|
|
33
|
+
unavailable: LabelCopy | null;
|
|
31
34
|
loadMore: () => void;
|
|
32
35
|
targetCount: number;
|
|
33
36
|
}
|
|
@@ -11,8 +11,9 @@ function useMenuItems(store, options) {
|
|
|
11
11
|
store,
|
|
12
12
|
() => selectItems(store, scope, query, targetCount, parentScope)
|
|
13
13
|
);
|
|
14
|
+
const waitsOnAthena = snapshot.unavailable !== null;
|
|
14
15
|
useEffect(() => {
|
|
15
|
-
if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
|
|
16
|
+
if (!waitsOnAthena && snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
|
|
16
17
|
triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);
|
|
17
18
|
}
|
|
18
19
|
}, [
|
|
@@ -21,12 +22,13 @@ function useMenuItems(store, options) {
|
|
|
21
22
|
query,
|
|
22
23
|
targetCount,
|
|
23
24
|
parentScope,
|
|
25
|
+
waitsOnAthena,
|
|
24
26
|
snapshot.items.length,
|
|
25
27
|
snapshot.hasMore,
|
|
26
28
|
snapshot.isFetching
|
|
27
29
|
]);
|
|
28
30
|
const loadMore = () => {
|
|
29
|
-
if (snapshot.hasMore && !snapshot.isFetching) {
|
|
31
|
+
if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {
|
|
30
32
|
setTargetCount((prev) => prev + 50);
|
|
31
33
|
}
|
|
32
34
|
};
|
|
@@ -34,6 +36,7 @@ function useMenuItems(store, options) {
|
|
|
34
36
|
items: snapshot.items,
|
|
35
37
|
isFetching: snapshot.isFetching,
|
|
36
38
|
hasMore: snapshot.hasMore,
|
|
39
|
+
unavailable: snapshot.unavailable,
|
|
37
40
|
loadMore,
|
|
38
41
|
targetCount
|
|
39
42
|
// Expose for debugging
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-menu-items.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching\n useEffect(() => {\n if (snapshot.items.length < targetCount
|
|
1
|
+
{"version":3,"file":"use-menu-items.js","sources":["../../../../../src/chat-ui/mentions/suggestions/data/use-menu-items.ts"],"sourcesContent":["import type { LabelCopy } from '@athenaintel/agent-runtime/offline-status';\nimport { useStore } from '@tanstack/react-store';\nimport { useEffect, useState } from 'react';\nimport { selectItems, triggerFetchIfNeeded } from './orchestrator';\nimport type { MenuItem, MenuScope } from './types';\nimport type { MentionSuggestionsStore } from './use-mention-suggestions';\n\n/**\n * useMenuItems - Like React Query, but for menu items\n *\n * Clean, automatic hook that:\n * - Reads items from store (reactive!)\n * - Auto-fetches if needed (in useEffect)\n * - Returns clean interface { items, isFetching, hasMore }\n *\n * Usage:\n * ```typescript\n * const { items, isFetching, hasMore } = useMenuItems(store, {\n * scope: 'athena_folders',\n * query: 'doc',\n * minItems: 10,\n * parentScope: 'root'\n * });\n * ```\n */\nexport interface UseMenuItemsOptions {\n scope: MenuScope;\n query?: string;\n minItems?: number;\n parentScope?: MenuScope;\n}\n\nexport interface UseMenuItemsResult {\n items: MenuItem[];\n isFetching: boolean;\n hasMore: boolean;\n /** Why this scope can't load from Athena right now (`null` while it can, or for local items). */\n unavailable: LabelCopy | null;\n loadMore: () => void; // Explicit load more (not automatic!)\n targetCount: number; // Current target for debugging\n}\n\nexport function useMenuItems(\n store: MentionSuggestionsStore,\n options: UseMenuItemsOptions\n): UseMenuItemsResult {\n const { scope, query = '', minItems = 50, parentScope } = options;\n\n // Target item count (increases when user clicks \"Load More\")\n const [targetCount, setTargetCount] = useState(minItems);\n\n // Reset target when scope/query changes\n // biome-ignore lint/correctness/useExhaustiveDependencies: We intentionally reset on scope/query change\n useEffect(() => {\n setTargetCount(minItems);\n }, [scope, query, minItems]);\n\n // Read from store (pure, reactive)\n const snapshot = useStore(store, () =>\n selectItems(store, scope, query, targetCount, parentScope)\n );\n\n // Auto-fetch when: cached < target AND hasMore AND !fetching (and Athena can be asked)\n const waitsOnAthena = snapshot.unavailable !== null;\n useEffect(() => {\n if (\n !waitsOnAthena &&\n snapshot.items.length < targetCount &&\n snapshot.hasMore &&\n !snapshot.isFetching\n ) {\n triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);\n }\n }, [\n store,\n scope,\n query,\n targetCount,\n parentScope,\n waitsOnAthena,\n snapshot.items.length,\n snapshot.hasMore,\n snapshot.isFetching,\n ]);\n\n // Explicit load more: Increase target by 50\n const loadMore = () => {\n if (!waitsOnAthena && snapshot.hasMore && !snapshot.isFetching) {\n setTargetCount((prev) => prev + 50);\n }\n };\n\n return {\n items: snapshot.items,\n isFetching: snapshot.isFetching,\n hasMore: snapshot.hasMore,\n unavailable: snapshot.unavailable,\n loadMore,\n targetCount, // Expose for debugging\n };\n}\n"],"names":[],"mappings":";;;AA0CO,SAAS,aACd,OACA,SACoB;AACpB,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW,IAAI,gBAAgB;AAG1D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,QAAQ;AAIvD,YAAU,MAAM;AACd,mBAAe,QAAQ;AAAA,EACzB,GAAG,CAAC,OAAO,OAAO,QAAQ,CAAC;AAG3B,QAAM,WAAW;AAAA,IAAS;AAAA,IAAO,MAC/B,YAAY,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,EAAA;AAI3D,QAAM,gBAAgB,SAAS,gBAAgB;AAC/C,YAAU,MAAM;AACd,QACE,CAAC,iBACD,SAAS,MAAM,SAAS,eACxB,SAAS,WACT,CAAC,SAAS,YACV;AACA,2BAAqB,OAAO,OAAO,OAAO,aAAa,WAAW;AAAA,IACpE;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV;AAGD,QAAM,WAAW,MAAM;AACrB,QAAI,CAAC,iBAAiB,SAAS,WAAW,CAAC,SAAS,YAAY;AAC9D,qBAAe,CAAC,SAAS,OAAO,EAAE;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,SAAS;AAAA,IAChB,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB,aAAa,SAAS;AAAA,IACtB;AAAA,IACA;AAAA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const reactQuery = require("@tanstack/react-query");
|
|
4
|
-
const
|
|
4
|
+
const AthenaCredentialSourceContext = require("../../auth/AthenaCredentialSourceContext.cjs");
|
|
5
|
+
const credentialSource = require("../../auth/credential-source.cjs");
|
|
5
6
|
const runtimeCatalog = require("../../catalog/runtime-catalog.cjs");
|
|
7
|
+
const useAthenaRestQuery = require("../../lib/use-athena-rest-query.cjs");
|
|
6
8
|
const credentialRenewal = require("../../runtime/credential-renewal.cjs");
|
|
7
9
|
const api = require("../../threads/api.cjs");
|
|
8
|
-
|
|
10
|
+
const tokenGetterIds = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
let lastTokenGetterId = 0;
|
|
12
|
+
function tokenGetterId(getToken) {
|
|
13
|
+
if (getToken === void 0) return "";
|
|
14
|
+
let id = tokenGetterIds.get(getToken);
|
|
15
|
+
if (id === void 0) {
|
|
16
|
+
lastTokenGetterId += 1;
|
|
17
|
+
id = lastTokenGetterId;
|
|
18
|
+
tokenGetterIds.set(getToken, id);
|
|
19
|
+
}
|
|
20
|
+
return `getter:${id}`;
|
|
21
|
+
}
|
|
22
|
+
function heldTokenIdentity(token) {
|
|
23
|
+
if (!token) return "";
|
|
24
|
+
const subject = credentialSource.jwtSubject(token);
|
|
25
|
+
if (subject === null) return `token:${useAthenaRestQuery.keyPartFingerprint(token)}`;
|
|
26
|
+
const scope = credentialSource.jwtScope(token);
|
|
27
|
+
return scope === null ? `sub:${useAthenaRestQuery.keyPartFingerprint(subject)}` : `sub:${useAthenaRestQuery.keyPartFingerprint(subject)}|scope:${useAthenaRestQuery.keyPartFingerprint(scope)}`;
|
|
28
|
+
}
|
|
29
|
+
function useAccountIdentityRead(auth, { enabled, tokenGetter }) {
|
|
9
30
|
const queryClient = runtimeCatalog.useCatalogQueryClient();
|
|
10
|
-
const
|
|
11
|
-
const principal = (auth == null ? void 0 : auth.apiKey) ? `key:${runtimeCatalog.credentialFingerprint({ credential: auth.apiKey })}` : (auth == null ? void 0 : auth.userId) ?? ((auth == null ? void 0 : auth.accessToken) ? `token:${runtimeCatalog.credentialFingerprint({ credential: auth.accessToken })}` : anonymousScope);
|
|
31
|
+
const identityEpoch = AthenaCredentialSourceContext.useAthenaCredentialIdentityEpoch();
|
|
12
32
|
const query = reactQuery.useQuery(
|
|
13
33
|
{
|
|
14
|
-
queryKey: [
|
|
34
|
+
queryKey: [
|
|
35
|
+
"athena-sdk",
|
|
36
|
+
"account",
|
|
37
|
+
(auth == null ? void 0 : auth.backendUrl) ?? "",
|
|
38
|
+
(auth == null ? void 0 : auth.userId) ?? "",
|
|
39
|
+
(auth == null ? void 0 : auth.apiKey) ? useAthenaRestQuery.keyPartFingerprint(auth.apiKey) : "",
|
|
40
|
+
tokenGetterId(tokenGetter),
|
|
41
|
+
heldTokenIdentity(auth == null ? void 0 : auth.accessToken),
|
|
42
|
+
identityEpoch
|
|
43
|
+
],
|
|
15
44
|
queryFn: async ({ signal }) => {
|
|
16
45
|
if (!auth) return null;
|
|
17
|
-
|
|
46
|
+
return credentialRenewal.withCredentialRenewal(
|
|
18
47
|
async ({ force } = {}) => {
|
|
19
48
|
var _a, _b;
|
|
20
49
|
return {
|
|
@@ -25,15 +54,21 @@ function useAccountWorkspaceId(auth) {
|
|
|
25
54
|
},
|
|
26
55
|
(resolved) => api.fetchAccountIdentity(auth.backendUrl, resolved, { signal })
|
|
27
56
|
);
|
|
28
|
-
return identity.workspaceId ?? null;
|
|
29
57
|
},
|
|
30
|
-
enabled: auth !== null &&
|
|
58
|
+
enabled: auth !== null && enabled,
|
|
31
59
|
retry: false,
|
|
32
60
|
staleTime: 6e4
|
|
33
61
|
},
|
|
34
62
|
queryClient
|
|
35
63
|
);
|
|
36
|
-
return
|
|
64
|
+
return query.data;
|
|
65
|
+
}
|
|
66
|
+
function useAccountIdentity(auth, options = {}) {
|
|
67
|
+
const identity = useAccountIdentityRead(auth, { enabled: true, ...options });
|
|
68
|
+
return {
|
|
69
|
+
userId: identity == null ? void 0 : identity.userId,
|
|
70
|
+
workspaceId: (auth == null ? void 0 : auth.workspaceId) ?? (identity == null ? void 0 : identity.workspaceId) ?? void 0
|
|
71
|
+
};
|
|
37
72
|
}
|
|
38
|
-
exports.
|
|
73
|
+
exports.useAccountIdentity = useAccountIdentity;
|
|
39
74
|
//# sourceMappingURL=use-account-workspace-id.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-account-workspace-id.cjs","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport {
|
|
1
|
+
{"version":3,"file":"use-account-workspace-id.cjs","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { useAthenaCredentialIdentityEpoch } from '../../auth/AthenaCredentialSourceContext';\nimport { jwtScope, jwtSubject } from '../../auth/credential-source';\nimport { useCatalogQueryClient } from '../../catalog/runtime-catalog';\nimport { keyPartFingerprint } from '../../lib/use-athena-rest-query';\nimport { withCredentialRenewal } from '../../runtime/credential-renewal';\nimport type { AthenaStatewireTokenGetter } from '../../runtime/statewire-auth-headers';\nimport { type AccountIdentity, fetchAccountIdentity } from '../../threads/api';\nimport type { MentionAuthContext } from './suggestions/data/api-client';\n\n/** The credential's agora identity, as far as it is known yet. */\nexport interface AccountIdentityState {\n /** Agora's user id (`user_…`) for the credential; unknown until `/me` answers. */\n userId: string | undefined;\n /** The host's workspace when it names one, else the credential's current workspace. */\n workspaceId: string | undefined;\n}\n\nexport interface AccountIdentityOptions {\n /**\n * The provider's token getter, which `auth.getAccessToken` wraps (`AthenaChat`\n * passes `useAthenaConfig().getToken`). Its identity keeps two providers\n * apart when only their getters know who they sign in.\n */\n tokenGetter?: AthenaStatewireTokenGetter;\n}\n\n/** One id per token getter, so the key can name a getter without holding it. */\nconst tokenGetterIds = new WeakMap<AthenaStatewireTokenGetter, number>();\nlet lastTokenGetterId = 0;\n\nfunction tokenGetterId(getToken: AthenaStatewireTokenGetter | undefined): string {\n if (getToken === undefined) return '';\n let id = tokenGetterIds.get(getToken);\n if (id === undefined) {\n lastTokenGetterId += 1;\n id = lastTokenGetterId;\n tokenGetterIds.set(getToken, id);\n }\n return `getter:${id}`;\n}\n\n/**\n * Who a held token acts as, and where, without the token: its JWT subject and\n * the claims scoping it to a workspace or org (`jwtScope`), or the token\n * itself when it is opaque, fingerprinted. A renewal for the same person and\n * scope keeps it, so a rotation is not a new identity; the same person's token\n * scoped to another workspace is.\n */\nfunction heldTokenIdentity(token: string | null | undefined): string {\n if (!token) return '';\n const subject = jwtSubject(token);\n if (subject === null) return `token:${keyPartFingerprint(token)}`;\n const scope = jwtScope(token);\n return scope === null\n ? `sub:${keyPartFingerprint(subject)}`\n : `sub:${keyPartFingerprint(subject)}|scope:${keyPartFingerprint(scope)}`;\n}\n\n/**\n * One `/me` read per credential, through the host's query cache (never a\n * process-wide user-id map), keyed by the credential the read is sent with and\n * never by the secret: the backend, the signed-in person, the API key's\n * fingerprint, the provider's token getter, who the held token acts as and\n * which workspace it is scoped to, and the provider's credential identity\n * epoch (`useAthenaCredentialIdentityEpoch`), which moves once the getter has\n * handed out a token that acts as someone else. A renewal for the same person\n * and scope keeps the key, so the answer stays put; an API-key switch, a held\n * token scoped to another workspace, or a getter now signing in someone else,\n * reads `/me` again under a new key, never a cached answer for the previous\n * credential. The epoch follows the person, not the scope: a host getter that\n * alone hands out the same person's token for another workspace is read again\n * once the answer goes stale. `enabled` is the caller's: a reader that only\n * needs the workspace skips the read when the host names one.\n */\nfunction useAccountIdentityRead(\n auth: MentionAuthContext | null,\n { enabled, tokenGetter }: { enabled: boolean } & AccountIdentityOptions\n): AccountIdentity | null | undefined {\n const queryClient = useCatalogQueryClient();\n const identityEpoch = useAthenaCredentialIdentityEpoch();\n const query = useQuery(\n {\n queryKey: [\n 'athena-sdk',\n 'account',\n auth?.backendUrl ?? '',\n auth?.userId ?? '',\n auth?.apiKey ? keyPartFingerprint(auth.apiKey) : '',\n tokenGetterId(tokenGetter),\n heldTokenIdentity(auth?.accessToken),\n identityEpoch,\n ],\n queryFn: async ({ signal }) => {\n if (!auth) return null;\n return withCredentialRenewal(\n async ({ force }: { force?: boolean } = {}) => ({\n token:\n (force ? await auth.renewAccessToken?.() : await auth.getAccessToken?.()) ??\n auth.accessToken ??\n null,\n apiKey: auth.apiKey,\n credentials: auth.credentials,\n }),\n (resolved) => fetchAccountIdentity(auth.backendUrl, resolved, { signal })\n );\n },\n enabled: auth !== null && enabled,\n retry: false,\n staleTime: 60_000,\n },\n queryClient\n );\n return query.data;\n}\n\n/** The workspace mentions search: the host's when it names one, else the credential's own. */\nexport function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined {\n const identity = useAccountIdentityRead(auth, { enabled: !auth?.workspaceId });\n return auth?.workspaceId ?? identity?.workspaceId ?? undefined;\n}\n\n/**\n * The credential's agora user id and workspace from the same read. The auth\n * context carries the identity provider's user id, not agora's, so \"who is\n * the viewer\" (an answer label's \"for you\") needs this one, and it reads\n * `/me` even when the host names a workspace.\n */\nexport function useAccountIdentity(\n auth: MentionAuthContext | null,\n options: AccountIdentityOptions = {}\n): AccountIdentityState {\n const identity = useAccountIdentityRead(auth, { enabled: true, ...options });\n return {\n userId: identity?.userId,\n workspaceId: auth?.workspaceId ?? identity?.workspaceId ?? undefined,\n };\n}\n"],"names":["jwtSubject","keyPartFingerprint","jwtScope","useCatalogQueryClient","useAthenaCredentialIdentityEpoch","useQuery","withCredentialRenewal","fetchAccountIdentity"],"mappings":";;;;;;;;;AA4BA,MAAM,qCAAqB,QAAA;AAC3B,IAAI,oBAAoB;AAExB,SAAS,cAAc,UAA0D;AAC/E,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,KAAK,eAAe,IAAI,QAAQ;AACpC,MAAI,OAAO,QAAW;AACpB,yBAAqB;AACrB,SAAK;AACL,mBAAe,IAAI,UAAU,EAAE;AAAA,EACjC;AACA,SAAO,UAAU,EAAE;AACrB;AASA,SAAS,kBAAkB,OAA0C;AACnE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,UAAUA,iBAAAA,WAAW,KAAK;AAChC,MAAI,YAAY,KAAM,QAAO,SAASC,mBAAAA,mBAAmB,KAAK,CAAC;AAC/D,QAAM,QAAQC,iBAAAA,SAAS,KAAK;AAC5B,SAAO,UAAU,OACb,OAAOD,mBAAAA,mBAAmB,OAAO,CAAC,KAClC,OAAOA,mBAAAA,mBAAmB,OAAO,CAAC,UAAUA,mBAAAA,mBAAmB,KAAK,CAAC;AAC3E;AAkBA,SAAS,uBACP,MACA,EAAE,SAAS,eACyB;AACpC,QAAM,cAAcE,eAAAA,sBAAA;AACpB,QAAM,gBAAgBC,8BAAAA,iCAAA;AACtB,QAAM,QAAQC,WAAAA;AAAAA,IACZ;AAAA,MACE,UAAU;AAAA,QACR;AAAA,QACA;AAAA,SACA,6BAAM,eAAc;AAAA,SACpB,6BAAM,WAAU;AAAA,SAChB,6BAAM,UAASJ,mBAAAA,mBAAmB,KAAK,MAAM,IAAI;AAAA,QACjD,cAAc,WAAW;AAAA,QACzB,kBAAkB,6BAAM,WAAW;AAAA,QACnC;AAAA,MAAA;AAAA,MAEF,SAAS,OAAO,EAAE,aAAa;AAC7B,YAAI,CAAC,KAAM,QAAO;AAClB,eAAOK,kBAAAA;AAAAA,UACL,OAAO,EAAE,MAAA,IAA+B,OAAC;;AAAO;AAAA,cAC9C,QACG,QAAQ,QAAM,UAAK,qBAAL,iCAA4B,QAAM,UAAK,mBAAL,mCACjD,KAAK,eACL;AAAA,cACF,QAAQ,KAAK;AAAA,cACb,aAAa,KAAK;AAAA,YAAA;AAAA;AAAA,UAEpB,CAAC,aAAaC,IAAAA,qBAAqB,KAAK,YAAY,UAAU,EAAE,QAAQ;AAAA,QAAA;AAAA,MAE5E;AAAA,MACA,SAAS,SAAS,QAAQ;AAAA,MAC1B,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,EAAA;AAEF,SAAO,MAAM;AACf;AAcO,SAAS,mBACd,MACA,UAAkC,IACZ;AACtB,QAAM,WAAW,uBAAuB,MAAM,EAAE,SAAS,MAAM,GAAG,SAAS;AAC3E,SAAO;AAAA,IACL,QAAQ,qCAAU;AAAA,IAClB,cAAa,6BAAM,iBAAe,qCAAU,gBAAe;AAAA,EAAA;AAE/D;;"}
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
import type { AthenaStatewireTokenGetter } from '../../runtime/statewire-auth-headers';
|
|
1
2
|
import type { MentionAuthContext } from './suggestions/data/api-client';
|
|
2
|
-
/**
|
|
3
|
+
/** The credential's agora identity, as far as it is known yet. */
|
|
4
|
+
export interface AccountIdentityState {
|
|
5
|
+
/** Agora's user id (`user_…`) for the credential; unknown until `/me` answers. */
|
|
6
|
+
userId: string | undefined;
|
|
7
|
+
/** The host's workspace when it names one, else the credential's current workspace. */
|
|
8
|
+
workspaceId: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface AccountIdentityOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The provider's token getter, which `auth.getAccessToken` wraps (`AthenaChat`
|
|
13
|
+
* passes `useAthenaConfig().getToken`). Its identity keeps two providers
|
|
14
|
+
* apart when only their getters know who they sign in.
|
|
15
|
+
*/
|
|
16
|
+
tokenGetter?: AthenaStatewireTokenGetter;
|
|
17
|
+
}
|
|
18
|
+
/** The workspace mentions search: the host's when it names one, else the credential's own. */
|
|
3
19
|
export declare function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The credential's agora user id and workspace from the same read. The auth
|
|
22
|
+
* context carries the identity provider's user id, not agora's, so "who is
|
|
23
|
+
* the viewer" (an answer label's "for you") needs this one, and it reads
|
|
24
|
+
* `/me` even when the host names a workspace.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAccountIdentity(auth: MentionAuthContext | null, options?: AccountIdentityOptions): AccountIdentityState;
|
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useAthenaCredentialIdentityEpoch } from "../../auth/AthenaCredentialSourceContext.js";
|
|
3
|
+
import { jwtSubject, jwtScope } from "../../auth/credential-source.js";
|
|
4
|
+
import { useCatalogQueryClient } from "../../catalog/runtime-catalog.js";
|
|
5
|
+
import { keyPartFingerprint } from "../../lib/use-athena-rest-query.js";
|
|
4
6
|
import { withCredentialRenewal } from "../../runtime/credential-renewal.js";
|
|
5
7
|
import { fetchAccountIdentity } from "../../threads/api.js";
|
|
6
|
-
|
|
8
|
+
const tokenGetterIds = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
let lastTokenGetterId = 0;
|
|
10
|
+
function tokenGetterId(getToken) {
|
|
11
|
+
if (getToken === void 0) return "";
|
|
12
|
+
let id = tokenGetterIds.get(getToken);
|
|
13
|
+
if (id === void 0) {
|
|
14
|
+
lastTokenGetterId += 1;
|
|
15
|
+
id = lastTokenGetterId;
|
|
16
|
+
tokenGetterIds.set(getToken, id);
|
|
17
|
+
}
|
|
18
|
+
return `getter:${id}`;
|
|
19
|
+
}
|
|
20
|
+
function heldTokenIdentity(token) {
|
|
21
|
+
if (!token) return "";
|
|
22
|
+
const subject = jwtSubject(token);
|
|
23
|
+
if (subject === null) return `token:${keyPartFingerprint(token)}`;
|
|
24
|
+
const scope = jwtScope(token);
|
|
25
|
+
return scope === null ? `sub:${keyPartFingerprint(subject)}` : `sub:${keyPartFingerprint(subject)}|scope:${keyPartFingerprint(scope)}`;
|
|
26
|
+
}
|
|
27
|
+
function useAccountIdentityRead(auth, { enabled, tokenGetter }) {
|
|
7
28
|
const queryClient = useCatalogQueryClient();
|
|
8
|
-
const
|
|
9
|
-
const principal = (auth == null ? void 0 : auth.apiKey) ? `key:${credentialFingerprint({ credential: auth.apiKey })}` : (auth == null ? void 0 : auth.userId) ?? ((auth == null ? void 0 : auth.accessToken) ? `token:${credentialFingerprint({ credential: auth.accessToken })}` : anonymousScope);
|
|
29
|
+
const identityEpoch = useAthenaCredentialIdentityEpoch();
|
|
10
30
|
const query = useQuery(
|
|
11
31
|
{
|
|
12
|
-
queryKey: [
|
|
32
|
+
queryKey: [
|
|
33
|
+
"athena-sdk",
|
|
34
|
+
"account",
|
|
35
|
+
(auth == null ? void 0 : auth.backendUrl) ?? "",
|
|
36
|
+
(auth == null ? void 0 : auth.userId) ?? "",
|
|
37
|
+
(auth == null ? void 0 : auth.apiKey) ? keyPartFingerprint(auth.apiKey) : "",
|
|
38
|
+
tokenGetterId(tokenGetter),
|
|
39
|
+
heldTokenIdentity(auth == null ? void 0 : auth.accessToken),
|
|
40
|
+
identityEpoch
|
|
41
|
+
],
|
|
13
42
|
queryFn: async ({ signal }) => {
|
|
14
43
|
if (!auth) return null;
|
|
15
|
-
|
|
44
|
+
return withCredentialRenewal(
|
|
16
45
|
async ({ force } = {}) => {
|
|
17
46
|
var _a, _b;
|
|
18
47
|
return {
|
|
@@ -23,17 +52,23 @@ function useAccountWorkspaceId(auth) {
|
|
|
23
52
|
},
|
|
24
53
|
(resolved) => fetchAccountIdentity(auth.backendUrl, resolved, { signal })
|
|
25
54
|
);
|
|
26
|
-
return identity.workspaceId ?? null;
|
|
27
55
|
},
|
|
28
|
-
enabled: auth !== null &&
|
|
56
|
+
enabled: auth !== null && enabled,
|
|
29
57
|
retry: false,
|
|
30
58
|
staleTime: 6e4
|
|
31
59
|
},
|
|
32
60
|
queryClient
|
|
33
61
|
);
|
|
34
|
-
return
|
|
62
|
+
return query.data;
|
|
63
|
+
}
|
|
64
|
+
function useAccountIdentity(auth, options = {}) {
|
|
65
|
+
const identity = useAccountIdentityRead(auth, { enabled: true, ...options });
|
|
66
|
+
return {
|
|
67
|
+
userId: identity == null ? void 0 : identity.userId,
|
|
68
|
+
workspaceId: (auth == null ? void 0 : auth.workspaceId) ?? (identity == null ? void 0 : identity.workspaceId) ?? void 0
|
|
69
|
+
};
|
|
35
70
|
}
|
|
36
71
|
export {
|
|
37
|
-
|
|
72
|
+
useAccountIdentity
|
|
38
73
|
};
|
|
39
74
|
//# sourceMappingURL=use-account-workspace-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-account-workspace-id.js","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport {
|
|
1
|
+
{"version":3,"file":"use-account-workspace-id.js","sources":["../../../src/chat-ui/mentions/use-account-workspace-id.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { useAthenaCredentialIdentityEpoch } from '../../auth/AthenaCredentialSourceContext';\nimport { jwtScope, jwtSubject } from '../../auth/credential-source';\nimport { useCatalogQueryClient } from '../../catalog/runtime-catalog';\nimport { keyPartFingerprint } from '../../lib/use-athena-rest-query';\nimport { withCredentialRenewal } from '../../runtime/credential-renewal';\nimport type { AthenaStatewireTokenGetter } from '../../runtime/statewire-auth-headers';\nimport { type AccountIdentity, fetchAccountIdentity } from '../../threads/api';\nimport type { MentionAuthContext } from './suggestions/data/api-client';\n\n/** The credential's agora identity, as far as it is known yet. */\nexport interface AccountIdentityState {\n /** Agora's user id (`user_…`) for the credential; unknown until `/me` answers. */\n userId: string | undefined;\n /** The host's workspace when it names one, else the credential's current workspace. */\n workspaceId: string | undefined;\n}\n\nexport interface AccountIdentityOptions {\n /**\n * The provider's token getter, which `auth.getAccessToken` wraps (`AthenaChat`\n * passes `useAthenaConfig().getToken`). Its identity keeps two providers\n * apart when only their getters know who they sign in.\n */\n tokenGetter?: AthenaStatewireTokenGetter;\n}\n\n/** One id per token getter, so the key can name a getter without holding it. */\nconst tokenGetterIds = new WeakMap<AthenaStatewireTokenGetter, number>();\nlet lastTokenGetterId = 0;\n\nfunction tokenGetterId(getToken: AthenaStatewireTokenGetter | undefined): string {\n if (getToken === undefined) return '';\n let id = tokenGetterIds.get(getToken);\n if (id === undefined) {\n lastTokenGetterId += 1;\n id = lastTokenGetterId;\n tokenGetterIds.set(getToken, id);\n }\n return `getter:${id}`;\n}\n\n/**\n * Who a held token acts as, and where, without the token: its JWT subject and\n * the claims scoping it to a workspace or org (`jwtScope`), or the token\n * itself when it is opaque, fingerprinted. A renewal for the same person and\n * scope keeps it, so a rotation is not a new identity; the same person's token\n * scoped to another workspace is.\n */\nfunction heldTokenIdentity(token: string | null | undefined): string {\n if (!token) return '';\n const subject = jwtSubject(token);\n if (subject === null) return `token:${keyPartFingerprint(token)}`;\n const scope = jwtScope(token);\n return scope === null\n ? `sub:${keyPartFingerprint(subject)}`\n : `sub:${keyPartFingerprint(subject)}|scope:${keyPartFingerprint(scope)}`;\n}\n\n/**\n * One `/me` read per credential, through the host's query cache (never a\n * process-wide user-id map), keyed by the credential the read is sent with and\n * never by the secret: the backend, the signed-in person, the API key's\n * fingerprint, the provider's token getter, who the held token acts as and\n * which workspace it is scoped to, and the provider's credential identity\n * epoch (`useAthenaCredentialIdentityEpoch`), which moves once the getter has\n * handed out a token that acts as someone else. A renewal for the same person\n * and scope keeps the key, so the answer stays put; an API-key switch, a held\n * token scoped to another workspace, or a getter now signing in someone else,\n * reads `/me` again under a new key, never a cached answer for the previous\n * credential. The epoch follows the person, not the scope: a host getter that\n * alone hands out the same person's token for another workspace is read again\n * once the answer goes stale. `enabled` is the caller's: a reader that only\n * needs the workspace skips the read when the host names one.\n */\nfunction useAccountIdentityRead(\n auth: MentionAuthContext | null,\n { enabled, tokenGetter }: { enabled: boolean } & AccountIdentityOptions\n): AccountIdentity | null | undefined {\n const queryClient = useCatalogQueryClient();\n const identityEpoch = useAthenaCredentialIdentityEpoch();\n const query = useQuery(\n {\n queryKey: [\n 'athena-sdk',\n 'account',\n auth?.backendUrl ?? '',\n auth?.userId ?? '',\n auth?.apiKey ? keyPartFingerprint(auth.apiKey) : '',\n tokenGetterId(tokenGetter),\n heldTokenIdentity(auth?.accessToken),\n identityEpoch,\n ],\n queryFn: async ({ signal }) => {\n if (!auth) return null;\n return withCredentialRenewal(\n async ({ force }: { force?: boolean } = {}) => ({\n token:\n (force ? await auth.renewAccessToken?.() : await auth.getAccessToken?.()) ??\n auth.accessToken ??\n null,\n apiKey: auth.apiKey,\n credentials: auth.credentials,\n }),\n (resolved) => fetchAccountIdentity(auth.backendUrl, resolved, { signal })\n );\n },\n enabled: auth !== null && enabled,\n retry: false,\n staleTime: 60_000,\n },\n queryClient\n );\n return query.data;\n}\n\n/** The workspace mentions search: the host's when it names one, else the credential's own. */\nexport function useAccountWorkspaceId(auth: MentionAuthContext | null): string | undefined {\n const identity = useAccountIdentityRead(auth, { enabled: !auth?.workspaceId });\n return auth?.workspaceId ?? identity?.workspaceId ?? undefined;\n}\n\n/**\n * The credential's agora user id and workspace from the same read. The auth\n * context carries the identity provider's user id, not agora's, so \"who is\n * the viewer\" (an answer label's \"for you\") needs this one, and it reads\n * `/me` even when the host names a workspace.\n */\nexport function useAccountIdentity(\n auth: MentionAuthContext | null,\n options: AccountIdentityOptions = {}\n): AccountIdentityState {\n const identity = useAccountIdentityRead(auth, { enabled: true, ...options });\n return {\n userId: identity?.userId,\n workspaceId: auth?.workspaceId ?? identity?.workspaceId ?? undefined,\n };\n}\n"],"names":[],"mappings":";;;;;;;AA4BA,MAAM,qCAAqB,QAAA;AAC3B,IAAI,oBAAoB;AAExB,SAAS,cAAc,UAA0D;AAC/E,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,KAAK,eAAe,IAAI,QAAQ;AACpC,MAAI,OAAO,QAAW;AACpB,yBAAqB;AACrB,SAAK;AACL,mBAAe,IAAI,UAAU,EAAE;AAAA,EACjC;AACA,SAAO,UAAU,EAAE;AACrB;AASA,SAAS,kBAAkB,OAA0C;AACnE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,UAAU,WAAW,KAAK;AAChC,MAAI,YAAY,KAAM,QAAO,SAAS,mBAAmB,KAAK,CAAC;AAC/D,QAAM,QAAQ,SAAS,KAAK;AAC5B,SAAO,UAAU,OACb,OAAO,mBAAmB,OAAO,CAAC,KAClC,OAAO,mBAAmB,OAAO,CAAC,UAAU,mBAAmB,KAAK,CAAC;AAC3E;AAkBA,SAAS,uBACP,MACA,EAAE,SAAS,eACyB;AACpC,QAAM,cAAc,sBAAA;AACpB,QAAM,gBAAgB,iCAAA;AACtB,QAAM,QAAQ;AAAA,IACZ;AAAA,MACE,UAAU;AAAA,QACR;AAAA,QACA;AAAA,SACA,6BAAM,eAAc;AAAA,SACpB,6BAAM,WAAU;AAAA,SAChB,6BAAM,UAAS,mBAAmB,KAAK,MAAM,IAAI;AAAA,QACjD,cAAc,WAAW;AAAA,QACzB,kBAAkB,6BAAM,WAAW;AAAA,QACnC;AAAA,MAAA;AAAA,MAEF,SAAS,OAAO,EAAE,aAAa;AAC7B,YAAI,CAAC,KAAM,QAAO;AAClB,eAAO;AAAA,UACL,OAAO,EAAE,MAAA,IAA+B,OAAC;;AAAO;AAAA,cAC9C,QACG,QAAQ,QAAM,UAAK,qBAAL,iCAA4B,QAAM,UAAK,mBAAL,mCACjD,KAAK,eACL;AAAA,cACF,QAAQ,KAAK;AAAA,cACb,aAAa,KAAK;AAAA,YAAA;AAAA;AAAA,UAEpB,CAAC,aAAa,qBAAqB,KAAK,YAAY,UAAU,EAAE,QAAQ;AAAA,QAAA;AAAA,MAE5E;AAAA,MACA,SAAS,SAAS,QAAQ;AAAA,MAC1B,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,IAEb;AAAA,EAAA;AAEF,SAAO,MAAM;AACf;AAcO,SAAS,mBACd,MACA,UAAkC,IACZ;AACtB,QAAM,WAAW,uBAAuB,MAAM,EAAE,SAAS,MAAM,GAAG,SAAS;AAC3E,SAAO;AAAA,IACL,QAAQ,qCAAU;AAAA,IAClB,cAAa,6BAAM,iBAAe,qCAAU,gBAAe;AAAA,EAAA;AAE/D;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const require$$0 = require("react");
|
|
4
4
|
const apiClient = require("./suggestions/data/api-client.cjs");
|
|
5
5
|
const MEMBER_AVATAR_TTL_MS = 5 * 60 * 1e3;
|
|
6
6
|
const memberAvatarRequests = /* @__PURE__ */ new Map();
|
|
@@ -42,11 +42,11 @@ function loadMemberAvatars(auth) {
|
|
|
42
42
|
return request;
|
|
43
43
|
}
|
|
44
44
|
function useMemberAvatarUrl(email) {
|
|
45
|
-
const auth =
|
|
45
|
+
const auth = require$$0.useContext(apiClient.MentionAuthCtx);
|
|
46
46
|
const normalizedEmail = email == null ? void 0 : email.trim().toLowerCase();
|
|
47
47
|
const cacheKey = (auth == null ? void 0 : auth.workspaceId) && `${auth.backendUrl}|${auth.workspaceId}`;
|
|
48
|
-
const [resolvedAvatar, setResolvedAvatar] =
|
|
49
|
-
|
|
48
|
+
const [resolvedAvatar, setResolvedAvatar] = require$$0.useState();
|
|
49
|
+
require$$0.useEffect(() => {
|
|
50
50
|
if (!auth || !cacheKey || !normalizedEmail) {
|
|
51
51
|
setResolvedAvatar(void 0);
|
|
52
52
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-member-avatar.cjs","sources":["../../../src/chat-ui/mentions/use-member-avatar.ts"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\";\nimport {\n fetchGraphQL,\n MentionAuthCtx,\n WORKSPACE_MEMBERS_QUERY,\n} from \"./suggestions/data/api-client\";\nimport type { MentionAuthContext } from \"./suggestions/data/api-client\";\n\ntype WorkspaceMemberAvatar = {\n email?: string | null;\n avatarUrl?: string | null;\n};\n\ntype WorkspaceMembersResponse = {\n getUsersInWorkspace?: WorkspaceMemberAvatar[] | null;\n};\n\nconst MEMBER_AVATAR_TTL_MS = 5 * 60 * 1000;\n\ntype MemberAvatarCacheEntry = {\n request: Promise<Map<string, string>>;\n fetchedAt: number | null;\n};\n\nconst memberAvatarRequests = new Map<string, MemberAvatarCacheEntry>();\n\nfunction loadMemberAvatars(\n auth: MentionAuthContext,\n): Promise<Map<string, string>> {\n const workspaceId = auth.workspaceId;\n if (!workspaceId) return Promise.resolve(new Map());\n\n const cacheKey = `${auth.backendUrl}|${workspaceId}`;\n const cached = memberAvatarRequests.get(cacheKey);\n if (cached && (cached.fetchedAt === null || Date.now() - cached.fetchedAt < MEMBER_AVATAR_TTL_MS)) {\n return cached.request;\n }\n\n const entry: MemberAvatarCacheEntry = {\n request: Promise.resolve(new Map<string, string>()),\n fetchedAt: null,\n };\n const request = fetchGraphQL<WorkspaceMembersResponse>(\n auth,\n WORKSPACE_MEMBERS_QUERY,\n { workspaceId },\n )\n .then((data) => {\n const avatars = new Map<string, string>();\n for (const member of data.getUsersInWorkspace ?? []) {\n const email = member.email?.trim().toLowerCase();\n if (email && member.avatarUrl != null) {\n avatars.set(email, member.avatarUrl);\n }\n }\n entry.fetchedAt = Date.now();\n return avatars;\n })\n .catch((error: unknown) => {\n if (memberAvatarRequests.get(cacheKey) === entry) {\n memberAvatarRequests.delete(cacheKey);\n }\n throw error;\n });\n\n entry.request = request;\n memberAvatarRequests.set(cacheKey, entry);\n return request;\n}\n\nexport function useMemberAvatarUrl(\n email: string | undefined,\n): string | undefined {\n const auth = useContext(MentionAuthCtx);\n const normalizedEmail = email?.trim().toLowerCase();\n const cacheKey =\n auth?.workspaceId && `${auth.backendUrl}|${auth.workspaceId}`;\n const [resolvedAvatar, setResolvedAvatar] = useState<{\n cacheKey: string;\n url: string | undefined;\n }>();\n\n useEffect(() => {\n if (!auth || !cacheKey || !normalizedEmail) {\n setResolvedAvatar(undefined);\n return;\n }\n\n let cancelled = false;\n loadMemberAvatars(auth).then(\n (avatars) => {\n if (!cancelled) {\n setResolvedAvatar({ cacheKey, url: avatars.get(normalizedEmail) });\n }\n },\n () => {\n if (!cancelled) setResolvedAvatar({ cacheKey, url: undefined });\n },\n );\n\n return () => {\n cancelled = true;\n };\n }, [auth, cacheKey, normalizedEmail]);\n\n if (!cacheKey || !resolvedAvatar || resolvedAvatar.cacheKey !== cacheKey) {\n return undefined;\n }\n return resolvedAvatar.url;\n}\n\nexport function resetMemberAvatarsForTests(): void {\n memberAvatarRequests.clear();\n}\n"],"names":["fetchGraphQL","WORKSPACE_MEMBERS_QUERY","useContext","MentionAuthCtx","useState","useEffect"],"mappings":";;;;AAiBA,MAAM,uBAAuB,IAAI,KAAK;AAOtC,MAAM,2CAA2B,IAAA;AAEjC,SAAS,kBACP,MAC8B;AAC9B,QAAM,cAAc,KAAK;AACzB,MAAI,CAAC,YAAa,QAAO,QAAQ,QAAQ,oBAAI,KAAK;AAElD,QAAM,WAAW,GAAG,KAAK,UAAU,IAAI,WAAW;AAClD,QAAM,SAAS,qBAAqB,IAAI,QAAQ;AAChD,MAAI,WAAW,OAAO,cAAc,QAAQ,KAAK,IAAA,IAAQ,OAAO,YAAY,uBAAuB;AACjG,WAAO,OAAO;AAAA,EAChB;AAEA,QAAM,QAAgC;AAAA,IACpC,SAAS,QAAQ,QAAQ,oBAAI,KAAqB;AAAA,IAClD,WAAW;AAAA,EAAA;AAEb,QAAM,UAAUA,UAAAA;AAAAA,IACd;AAAA,IACAC,UAAAA;AAAAA,IACA,EAAE,YAAA;AAAA,EAAY,EAEb,KAAK,CAAC,SAAS;;AACd,UAAM,8BAAc,IAAA;AACpB,eAAW,UAAU,KAAK,uBAAuB,CAAA,GAAI;AACnD,YAAM,SAAQ,YAAO,UAAP,mBAAc,OAAO;AACnC,UAAI,SAAS,OAAO,aAAa,MAAM;AACrC,gBAAQ,IAAI,OAAO,OAAO,SAAS;AAAA,MACrC;AAAA,IACF;AACA,UAAM,YAAY,KAAK,IAAA;AACvB,WAAO;AAAA,EACT,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,QAAI,qBAAqB,IAAI,QAAQ,MAAM,OAAO;AAChD,2BAAqB,OAAO,QAAQ;AAAA,IACtC;AACA,UAAM;AAAA,EACR,CAAC;AAEH,QAAM,UAAU;AAChB,uBAAqB,IAAI,UAAU,KAAK;AACxC,SAAO;AACT;AAEO,SAAS,mBACd,OACoB;AACpB,QAAM,OAAOC,
|
|
1
|
+
{"version":3,"file":"use-member-avatar.cjs","sources":["../../../src/chat-ui/mentions/use-member-avatar.ts"],"sourcesContent":["import { useContext, useEffect, useState } from \"react\";\nimport {\n fetchGraphQL,\n MentionAuthCtx,\n WORKSPACE_MEMBERS_QUERY,\n} from \"./suggestions/data/api-client\";\nimport type { MentionAuthContext } from \"./suggestions/data/api-client\";\n\ntype WorkspaceMemberAvatar = {\n email?: string | null;\n avatarUrl?: string | null;\n};\n\ntype WorkspaceMembersResponse = {\n getUsersInWorkspace?: WorkspaceMemberAvatar[] | null;\n};\n\nconst MEMBER_AVATAR_TTL_MS = 5 * 60 * 1000;\n\ntype MemberAvatarCacheEntry = {\n request: Promise<Map<string, string>>;\n fetchedAt: number | null;\n};\n\nconst memberAvatarRequests = new Map<string, MemberAvatarCacheEntry>();\n\nfunction loadMemberAvatars(\n auth: MentionAuthContext,\n): Promise<Map<string, string>> {\n const workspaceId = auth.workspaceId;\n if (!workspaceId) return Promise.resolve(new Map());\n\n const cacheKey = `${auth.backendUrl}|${workspaceId}`;\n const cached = memberAvatarRequests.get(cacheKey);\n if (cached && (cached.fetchedAt === null || Date.now() - cached.fetchedAt < MEMBER_AVATAR_TTL_MS)) {\n return cached.request;\n }\n\n const entry: MemberAvatarCacheEntry = {\n request: Promise.resolve(new Map<string, string>()),\n fetchedAt: null,\n };\n const request = fetchGraphQL<WorkspaceMembersResponse>(\n auth,\n WORKSPACE_MEMBERS_QUERY,\n { workspaceId },\n )\n .then((data) => {\n const avatars = new Map<string, string>();\n for (const member of data.getUsersInWorkspace ?? []) {\n const email = member.email?.trim().toLowerCase();\n if (email && member.avatarUrl != null) {\n avatars.set(email, member.avatarUrl);\n }\n }\n entry.fetchedAt = Date.now();\n return avatars;\n })\n .catch((error: unknown) => {\n if (memberAvatarRequests.get(cacheKey) === entry) {\n memberAvatarRequests.delete(cacheKey);\n }\n throw error;\n });\n\n entry.request = request;\n memberAvatarRequests.set(cacheKey, entry);\n return request;\n}\n\nexport function useMemberAvatarUrl(\n email: string | undefined,\n): string | undefined {\n const auth = useContext(MentionAuthCtx);\n const normalizedEmail = email?.trim().toLowerCase();\n const cacheKey =\n auth?.workspaceId && `${auth.backendUrl}|${auth.workspaceId}`;\n const [resolvedAvatar, setResolvedAvatar] = useState<{\n cacheKey: string;\n url: string | undefined;\n }>();\n\n useEffect(() => {\n if (!auth || !cacheKey || !normalizedEmail) {\n setResolvedAvatar(undefined);\n return;\n }\n\n let cancelled = false;\n loadMemberAvatars(auth).then(\n (avatars) => {\n if (!cancelled) {\n setResolvedAvatar({ cacheKey, url: avatars.get(normalizedEmail) });\n }\n },\n () => {\n if (!cancelled) setResolvedAvatar({ cacheKey, url: undefined });\n },\n );\n\n return () => {\n cancelled = true;\n };\n }, [auth, cacheKey, normalizedEmail]);\n\n if (!cacheKey || !resolvedAvatar || resolvedAvatar.cacheKey !== cacheKey) {\n return undefined;\n }\n return resolvedAvatar.url;\n}\n\nexport function resetMemberAvatarsForTests(): void {\n memberAvatarRequests.clear();\n}\n"],"names":["fetchGraphQL","WORKSPACE_MEMBERS_QUERY","useContext","MentionAuthCtx","useState","useEffect"],"mappings":";;;;AAiBA,MAAM,uBAAuB,IAAI,KAAK;AAOtC,MAAM,2CAA2B,IAAA;AAEjC,SAAS,kBACP,MAC8B;AAC9B,QAAM,cAAc,KAAK;AACzB,MAAI,CAAC,YAAa,QAAO,QAAQ,QAAQ,oBAAI,KAAK;AAElD,QAAM,WAAW,GAAG,KAAK,UAAU,IAAI,WAAW;AAClD,QAAM,SAAS,qBAAqB,IAAI,QAAQ;AAChD,MAAI,WAAW,OAAO,cAAc,QAAQ,KAAK,IAAA,IAAQ,OAAO,YAAY,uBAAuB;AACjG,WAAO,OAAO;AAAA,EAChB;AAEA,QAAM,QAAgC;AAAA,IACpC,SAAS,QAAQ,QAAQ,oBAAI,KAAqB;AAAA,IAClD,WAAW;AAAA,EAAA;AAEb,QAAM,UAAUA,UAAAA;AAAAA,IACd;AAAA,IACAC,UAAAA;AAAAA,IACA,EAAE,YAAA;AAAA,EAAY,EAEb,KAAK,CAAC,SAAS;;AACd,UAAM,8BAAc,IAAA;AACpB,eAAW,UAAU,KAAK,uBAAuB,CAAA,GAAI;AACnD,YAAM,SAAQ,YAAO,UAAP,mBAAc,OAAO;AACnC,UAAI,SAAS,OAAO,aAAa,MAAM;AACrC,gBAAQ,IAAI,OAAO,OAAO,SAAS;AAAA,MACrC;AAAA,IACF;AACA,UAAM,YAAY,KAAK,IAAA;AACvB,WAAO;AAAA,EACT,CAAC,EACA,MAAM,CAAC,UAAmB;AACzB,QAAI,qBAAqB,IAAI,QAAQ,MAAM,OAAO;AAChD,2BAAqB,OAAO,QAAQ;AAAA,IACtC;AACA,UAAM;AAAA,EACR,CAAC;AAEH,QAAM,UAAU;AAChB,uBAAqB,IAAI,UAAU,KAAK;AACxC,SAAO;AACT;AAEO,SAAS,mBACd,OACoB;AACpB,QAAM,OAAOC,WAAAA,WAAWC,wBAAc;AACtC,QAAM,kBAAkB,+BAAO,OAAO;AACtC,QAAM,YACJ,6BAAM,gBAAe,GAAG,KAAK,UAAU,IAAI,KAAK,WAAW;AAC7D,QAAM,CAAC,gBAAgB,iBAAiB,IAAIC,oBAAA;AAK5CC,aAAAA,UAAU,MAAM;AACd,QAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,iBAAiB;AAC1C,wBAAkB,MAAS;AAC3B;AAAA,IACF;AAEA,QAAI,YAAY;AAChB,sBAAkB,IAAI,EAAE;AAAA,MACtB,CAAC,YAAY;AACX,YAAI,CAAC,WAAW;AACd,4BAAkB,EAAE,UAAU,KAAK,QAAQ,IAAI,eAAe,GAAG;AAAA,QACnE;AAAA,MACF;AAAA,MACA,MAAM;AACJ,YAAI,CAAC,UAAW,mBAAkB,EAAE,UAAU,KAAK,QAAW;AAAA,MAChE;AAAA,IAAA;AAGF,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,MAAM,UAAU,eAAe,CAAC;AAEpC,MAAI,CAAC,YAAY,CAAC,kBAAkB,eAAe,aAAa,UAAU;AACxE,WAAO;AAAA,EACT;AACA,SAAO,eAAe;AACxB;;"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactQuery = require("@tanstack/react-query");
|
|
4
|
+
const require$$0 = require("react");
|
|
5
|
+
const apiClient = require("./suggestions/data/api-client.cjs");
|
|
6
|
+
const MENTION_ASSET_BATCH_SIZE = 50;
|
|
7
|
+
const MENTION_ASSET_BATCH_WINDOW_MS = 16;
|
|
8
|
+
const MENTION_ASSET_STALE_TIME_MS = 6e4;
|
|
9
|
+
const MENTION_ASSETS_QUERY = `
|
|
10
|
+
query MentionChipAssets($assetIds: [String!]!) {
|
|
11
|
+
getAssetsByIds(assetIds: $assetIds) {
|
|
12
|
+
id
|
|
13
|
+
title
|
|
14
|
+
athenaOriginalType
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const LOOKUP_ID = /^asset_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
19
|
+
function mentionAssetLookupId(assetId) {
|
|
20
|
+
const baseId = (assetId == null ? void 0 : assetId.trim().split("@")[0]) ?? "";
|
|
21
|
+
return LOOKUP_ID.test(baseId) ? baseId : null;
|
|
22
|
+
}
|
|
23
|
+
function canAuthenticate(auth) {
|
|
24
|
+
return Boolean(auth.accessToken || auth.apiKey || auth.credentials || auth.getAccessToken);
|
|
25
|
+
}
|
|
26
|
+
function fingerprint(credential) {
|
|
27
|
+
let hash = 2166136261;
|
|
28
|
+
for (let index = 0; index < credential.length; index += 1) {
|
|
29
|
+
hash ^= credential.charCodeAt(index);
|
|
30
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
31
|
+
}
|
|
32
|
+
return hash.toString(16).padStart(8, "0");
|
|
33
|
+
}
|
|
34
|
+
const authScopes = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
let authScopeCount = 0;
|
|
36
|
+
function principalOf(auth) {
|
|
37
|
+
const scope = [];
|
|
38
|
+
if (auth.userId) scope.push(`user:${auth.userId}`);
|
|
39
|
+
if (auth.apiKey) scope.push(`key:${fingerprint(auth.apiKey)}`);
|
|
40
|
+
if (scope.length) return scope.join("|");
|
|
41
|
+
let own = authScopes.get(auth);
|
|
42
|
+
if (!own) {
|
|
43
|
+
authScopeCount += 1;
|
|
44
|
+
own = `auth:${authScopeCount}`;
|
|
45
|
+
authScopes.set(auth, own);
|
|
46
|
+
}
|
|
47
|
+
const token = auth.accessToken;
|
|
48
|
+
return token ? `${own}|token:${fingerprint(token)}` : own;
|
|
49
|
+
}
|
|
50
|
+
const pendingBatches = /* @__PURE__ */ new Map();
|
|
51
|
+
function settle(waiters, asset) {
|
|
52
|
+
for (const waiter of waiters ?? []) waiter.resolve(asset);
|
|
53
|
+
}
|
|
54
|
+
function fail(waiters, error) {
|
|
55
|
+
for (const waiter of waiters ?? []) waiter.reject(error);
|
|
56
|
+
}
|
|
57
|
+
function sendBatch(batchKey) {
|
|
58
|
+
const batch = pendingBatches.get(batchKey);
|
|
59
|
+
if (!batch) return;
|
|
60
|
+
pendingBatches.delete(batchKey);
|
|
61
|
+
const ids = [...batch.waiters.keys()];
|
|
62
|
+
for (let start = 0; start < ids.length; start += MENTION_ASSET_BATCH_SIZE) {
|
|
63
|
+
const chunk = ids.slice(start, start + MENTION_ASSET_BATCH_SIZE);
|
|
64
|
+
apiClient.fetchGraphQL(batch.auth, MENTION_ASSETS_QUERY, {
|
|
65
|
+
assetIds: chunk
|
|
66
|
+
}).then(
|
|
67
|
+
(data) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const found = new Map((data.getAssetsByIds ?? []).map((asset) => [asset.id, asset]));
|
|
70
|
+
for (const id of chunk) {
|
|
71
|
+
const asset = found.get(id);
|
|
72
|
+
settle(
|
|
73
|
+
batch.waiters.get(id),
|
|
74
|
+
asset ? {
|
|
75
|
+
id,
|
|
76
|
+
title: ((_a = asset.title) == null ? void 0 : _a.trim()) ?? "",
|
|
77
|
+
assetType: ((_b = asset.athenaOriginalType) == null ? void 0 : _b.trim()) ?? ""
|
|
78
|
+
} : null
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
(error) => {
|
|
83
|
+
for (const id of chunk) fail(batch.waiters.get(id), error);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function loadMentionAsset({
|
|
89
|
+
auth,
|
|
90
|
+
batchKey,
|
|
91
|
+
assetId
|
|
92
|
+
}) {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
let batch = pendingBatches.get(batchKey);
|
|
95
|
+
if (!batch) {
|
|
96
|
+
batch = { auth, waiters: /* @__PURE__ */ new Map() };
|
|
97
|
+
pendingBatches.set(batchKey, batch);
|
|
98
|
+
setTimeout(() => sendBatch(batchKey), MENTION_ASSET_BATCH_WINDOW_MS);
|
|
99
|
+
}
|
|
100
|
+
const waiters = batch.waiters.get(assetId) ?? [];
|
|
101
|
+
waiters.push({ resolve, reject });
|
|
102
|
+
batch.waiters.set(assetId, waiters);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const chipQueryClient = new reactQuery.QueryClient();
|
|
106
|
+
function useMentionAsset(assetId) {
|
|
107
|
+
const auth = require$$0.useContext(apiClient.MentionAuthCtx);
|
|
108
|
+
const hostQueryClient = require$$0.useContext(reactQuery.QueryClientContext);
|
|
109
|
+
const lookupId = mentionAssetLookupId(assetId);
|
|
110
|
+
const enabled = Boolean(auth && lookupId && canAuthenticate(auth));
|
|
111
|
+
const backendUrl = (auth == null ? void 0 : auth.backendUrl) ?? "";
|
|
112
|
+
const principal = auth ? principalOf(auth) : "";
|
|
113
|
+
const { data } = reactQuery.useQuery(
|
|
114
|
+
{
|
|
115
|
+
queryKey: ["athena-sdk", "mention-asset", backendUrl, principal, lookupId ?? ""],
|
|
116
|
+
queryFn: () => {
|
|
117
|
+
if (!auth || !lookupId) return null;
|
|
118
|
+
return loadMentionAsset({
|
|
119
|
+
auth,
|
|
120
|
+
batchKey: `${backendUrl}|${principal}`,
|
|
121
|
+
assetId: lookupId
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
enabled,
|
|
125
|
+
staleTime: MENTION_ASSET_STALE_TIME_MS,
|
|
126
|
+
// Kept no longer than it is fresh: a title is shown again only after
|
|
127
|
+
// agora answers again, never from a cache a minute past its check.
|
|
128
|
+
gcTime: MENTION_ASSET_STALE_TIME_MS,
|
|
129
|
+
retry: false,
|
|
130
|
+
refetchOnWindowFocus: false
|
|
131
|
+
},
|
|
132
|
+
hostQueryClient ?? chipQueryClient
|
|
133
|
+
);
|
|
134
|
+
return enabled ? data : void 0;
|
|
135
|
+
}
|
|
136
|
+
exports.MENTION_ASSET_BATCH_SIZE = MENTION_ASSET_BATCH_SIZE;
|
|
137
|
+
exports.MENTION_ASSET_BATCH_WINDOW_MS = MENTION_ASSET_BATCH_WINDOW_MS;
|
|
138
|
+
exports.mentionAssetLookupId = mentionAssetLookupId;
|
|
139
|
+
exports.useMentionAsset = useMentionAsset;
|
|
140
|
+
//# sourceMappingURL=use-mention-asset.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mention-asset.cjs","sources":["../../../src/chat-ui/mentions/use-mention-asset.ts"],"sourcesContent":["/**\n * The asset an asset chip names, read the way Olympus's chips read it: its\n * title and type from agora's `getAssetsByIds`, which returns only the assets\n * the caller may read (an id they cannot read is left out of the answer, as is\n * another workspace's). A chip then shows the asset's own name and icon\n * instead of whatever label and `type=` its link carried.\n *\n * Chips that mount together ask together: one GraphQL request per batch of up\n * to {@link MENTION_ASSET_BATCH_SIZE} ids, gathered over\n * {@link MENTION_ASSET_BATCH_WINDOW_MS}. Each answer is a TanStack query keyed\n * by backend, the person asking and the id, fresh for a minute, so a\n * transcript full of citations to one repository asks for it once.\n */\nimport { QueryClient, QueryClientContext, useQuery } from \"@tanstack/react-query\";\nimport { useContext } from \"react\";\nimport {\n fetchGraphQL,\n type MentionAuthContext,\n MentionAuthCtx,\n} from \"./suggestions/data/api-client\";\n\n/** What a chip draws from the asset: its current title and its type. */\nexport interface MentionAsset {\n id: string;\n title: string;\n assetType: string;\n}\n\nexport const MENTION_ASSET_BATCH_SIZE = 50;\nexport const MENTION_ASSET_BATCH_WINDOW_MS = 16;\nconst MENTION_ASSET_STALE_TIME_MS = 60_000;\n\n/** No metadata: a session's carries its token ledgers, and a chip needs a name and a type. */\nconst MENTION_ASSETS_QUERY = `\n query MentionChipAssets($assetIds: [String!]!) {\n getAssetsByIds(assetIds: $assetIds) {\n id\n title\n athenaOriginalType\n }\n }\n`;\n\ninterface MentionAssetsResponse {\n getAssetsByIds?: Array<{\n id: string;\n title: string | null;\n athenaOriginalType: string | null;\n }> | null;\n}\n\n/**\n * The ids a lookup asks about: a stored asset. A versioned id (`asset_x@3`)\n * asks about its asset. A live provider file (`asset_<catalog>_<file>`) is not\n * a row `getAssetsByIds` holds, and a session (`asset_thread_<uuid>`) is never\n * asked about: agora reads the whole row, and a session's metadata carries\n * its transcript's ledgers (megabytes on a long session) — too much for a name.\n */\nconst LOOKUP_ID = /^asset_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport function mentionAssetLookupId(assetId: string | undefined): string | null {\n const baseId = assetId?.trim().split(\"@\")[0] ?? \"\";\n return LOOKUP_ID.test(baseId) ? baseId : null;\n}\n\n/** Whether a request can carry a credential (`mentionRequestInit` refuses one that cannot). */\nfunction canAuthenticate(auth: MentionAuthContext): boolean {\n return Boolean(auth.accessToken || auth.apiKey || auth.credentials || auth.getAccessToken);\n}\n\n/** A short, stable stand-in for a credential in a cache key; never the credential itself. */\nfunction fingerprint(credential: string): string {\n let hash = 0x811c9dc5;\n for (let index = 0; index < credential.length; index += 1) {\n hash ^= credential.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, \"0\");\n}\n\n/** The scope each credential with no stable identity of its own gets: its own auth object. */\nconst authScopes = new WeakMap<MentionAuthContext, string>();\nlet authScopeCount = 0;\n\n/**\n * Who is asking, as narrowly as the credential says: what `getAssetsByIds`\n * answers differs per person and per API key, and an answer (or a batch's\n * request) is only ever shared within one scope. A person's id and an API key\n * scope the cache across token rotations. A credential that names neither (a\n * session cookie, a token callback) shares nothing beyond its own auth object\n * and its current token, so a token swapped on the same object asks again.\n */\nfunction principalOf(auth: MentionAuthContext): string {\n const scope: string[] = [];\n if (auth.userId) scope.push(`user:${auth.userId}`);\n if (auth.apiKey) scope.push(`key:${fingerprint(auth.apiKey)}`);\n if (scope.length) return scope.join(\"|\");\n let own = authScopes.get(auth);\n if (!own) {\n authScopeCount += 1;\n own = `auth:${authScopeCount}`;\n authScopes.set(auth, own);\n }\n const token = auth.accessToken;\n return token ? `${own}|token:${fingerprint(token)}` : own;\n}\n\ninterface Waiter {\n resolve: (asset: MentionAsset | null) => void;\n reject: (error: unknown) => void;\n}\n\ninterface PendingBatch {\n auth: MentionAuthContext;\n waiters: Map<string, Waiter[]>;\n}\n\n/** The batch each backend and principal is gathering, until its window closes. */\nconst pendingBatches = new Map<string, PendingBatch>();\n\nfunction settle(waiters: Waiter[] | undefined, asset: MentionAsset | null): void {\n for (const waiter of waiters ?? []) waiter.resolve(asset);\n}\n\nfunction fail(waiters: Waiter[] | undefined, error: unknown): void {\n for (const waiter of waiters ?? []) waiter.reject(error);\n}\n\nfunction sendBatch(batchKey: string): void {\n const batch = pendingBatches.get(batchKey);\n if (!batch) return;\n pendingBatches.delete(batchKey);\n const ids = [...batch.waiters.keys()];\n for (let start = 0; start < ids.length; start += MENTION_ASSET_BATCH_SIZE) {\n const chunk = ids.slice(start, start + MENTION_ASSET_BATCH_SIZE);\n fetchGraphQL<MentionAssetsResponse>(batch.auth, MENTION_ASSETS_QUERY, {\n assetIds: chunk,\n }).then(\n (data) => {\n const found = new Map((data.getAssetsByIds ?? []).map((asset) => [asset.id, asset]));\n for (const id of chunk) {\n const asset = found.get(id);\n settle(\n batch.waiters.get(id),\n asset\n ? {\n id,\n title: asset.title?.trim() ?? \"\",\n assetType: asset.athenaOriginalType?.trim() ?? \"\",\n }\n : null,\n );\n }\n },\n (error: unknown) => {\n for (const id of chunk) fail(batch.waiters.get(id), error);\n },\n );\n }\n}\n\nfunction loadMentionAsset({\n auth,\n batchKey,\n assetId,\n}: {\n auth: MentionAuthContext;\n batchKey: string;\n assetId: string;\n}): Promise<MentionAsset | null> {\n return new Promise((resolve, reject) => {\n let batch = pendingBatches.get(batchKey);\n if (!batch) {\n batch = { auth, waiters: new Map() };\n pendingBatches.set(batchKey, batch);\n setTimeout(() => sendBatch(batchKey), MENTION_ASSET_BATCH_WINDOW_MS);\n }\n const waiters = batch.waiters.get(assetId) ?? [];\n waiters.push({ resolve, reject });\n batch.waiters.set(assetId, waiters);\n });\n}\n\n/** Chips rendered outside any query client (a host's own tray) still share one cache. */\nconst chipQueryClient = new QueryClient();\n\n/**\n * The asset an asset chip names: `undefined` while unknown (no lookup, still\n * loading, or the lookup failed), `null` when agora returned no asset the\n * viewer may read under that id, else its title and type.\n */\nexport function useMentionAsset(assetId: string | undefined): MentionAsset | null | undefined {\n const auth = useContext(MentionAuthCtx);\n const hostQueryClient = useContext(QueryClientContext);\n const lookupId = mentionAssetLookupId(assetId);\n const enabled = Boolean(auth && lookupId && canAuthenticate(auth));\n const backendUrl = auth?.backendUrl ?? \"\";\n const principal = auth ? principalOf(auth) : \"\";\n const { data } = useQuery(\n {\n queryKey: [\"athena-sdk\", \"mention-asset\", backendUrl, principal, lookupId ?? \"\"],\n queryFn: () => {\n if (!auth || !lookupId) return null;\n return loadMentionAsset({\n auth,\n batchKey: `${backendUrl}|${principal}`,\n assetId: lookupId,\n });\n },\n enabled,\n staleTime: MENTION_ASSET_STALE_TIME_MS,\n // Kept no longer than it is fresh: a title is shown again only after\n // agora answers again, never from a cache a minute past its check.\n gcTime: MENTION_ASSET_STALE_TIME_MS,\n retry: false,\n refetchOnWindowFocus: false,\n },\n hostQueryClient ?? chipQueryClient,\n );\n return enabled ? data : undefined;\n}\n\nexport function resetMentionAssetsForTests(): void {\n pendingBatches.clear();\n chipQueryClient.clear();\n}\n"],"names":["fetchGraphQL","QueryClient","useContext","MentionAuthCtx","QueryClientContext","useQuery"],"mappings":";;;;;AA4BO,MAAM,2BAA2B;AACjC,MAAM,gCAAgC;AAC7C,MAAM,8BAA8B;AAGpC,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyB7B,MAAM,YAAY;AAEX,SAAS,qBAAqB,SAA4C;AAC/E,QAAM,UAAS,mCAAS,OAAO,MAAM,KAAK,OAAM;AAChD,SAAO,UAAU,KAAK,MAAM,IAAI,SAAS;AAC3C;AAGA,SAAS,gBAAgB,MAAmC;AAC1D,SAAO,QAAQ,KAAK,eAAe,KAAK,UAAU,KAAK,eAAe,KAAK,cAAc;AAC3F;AAGA,SAAS,YAAY,YAA4B;AAC/C,MAAI,OAAO;AACX,WAAS,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS,GAAG;AACzD,YAAQ,WAAW,WAAW,KAAK;AACnC,WAAO,KAAK,KAAK,MAAM,QAAU,MAAM;AAAA,EACzC;AACA,SAAO,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC1C;AAGA,MAAM,iCAAiB,QAAA;AACvB,IAAI,iBAAiB;AAUrB,SAAS,YAAY,MAAkC;AACrD,QAAM,QAAkB,CAAA;AACxB,MAAI,KAAK,OAAQ,OAAM,KAAK,QAAQ,KAAK,MAAM,EAAE;AACjD,MAAI,KAAK,OAAQ,OAAM,KAAK,OAAO,YAAY,KAAK,MAAM,CAAC,EAAE;AAC7D,MAAI,MAAM,OAAQ,QAAO,MAAM,KAAK,GAAG;AACvC,MAAI,MAAM,WAAW,IAAI,IAAI;AAC7B,MAAI,CAAC,KAAK;AACR,sBAAkB;AAClB,UAAM,QAAQ,cAAc;AAC5B,eAAW,IAAI,MAAM,GAAG;AAAA,EAC1B;AACA,QAAM,QAAQ,KAAK;AACnB,SAAO,QAAQ,GAAG,GAAG,UAAU,YAAY,KAAK,CAAC,KAAK;AACxD;AAaA,MAAM,qCAAqB,IAAA;AAE3B,SAAS,OAAO,SAA+B,OAAkC;AAC/E,aAAW,UAAU,WAAW,CAAA,EAAI,QAAO,QAAQ,KAAK;AAC1D;AAEA,SAAS,KAAK,SAA+B,OAAsB;AACjE,aAAW,UAAU,WAAW,CAAA,EAAI,QAAO,OAAO,KAAK;AACzD;AAEA,SAAS,UAAU,UAAwB;AACzC,QAAM,QAAQ,eAAe,IAAI,QAAQ;AACzC,MAAI,CAAC,MAAO;AACZ,iBAAe,OAAO,QAAQ;AAC9B,QAAM,MAAM,CAAC,GAAG,MAAM,QAAQ,MAAM;AACpC,WAAS,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS,0BAA0B;AACzE,UAAM,QAAQ,IAAI,MAAM,OAAO,QAAQ,wBAAwB;AAC/DA,2BAAoC,MAAM,MAAM,sBAAsB;AAAA,MACpE,UAAU;AAAA,IAAA,CACX,EAAE;AAAA,MACD,CAAC,SAAS;;AACR,cAAM,QAAQ,IAAI,KAAK,KAAK,kBAAkB,CAAA,GAAI,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;AACnF,mBAAW,MAAM,OAAO;AACtB,gBAAM,QAAQ,MAAM,IAAI,EAAE;AAC1B;AAAA,YACE,MAAM,QAAQ,IAAI,EAAE;AAAA,YACpB,QACI;AAAA,cACE;AAAA,cACA,SAAO,WAAM,UAAN,mBAAa,WAAU;AAAA,cAC9B,aAAW,WAAM,uBAAN,mBAA0B,WAAU;AAAA,YAAA,IAEjD;AAAA,UAAA;AAAA,QAER;AAAA,MACF;AAAA,MACA,CAAC,UAAmB;AAClB,mBAAW,MAAM,MAAO,MAAK,MAAM,QAAQ,IAAI,EAAE,GAAG,KAAK;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AACF;AAEA,SAAS,iBAAiB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF,GAIiC;AAC/B,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,QAAQ,eAAe,IAAI,QAAQ;AACvC,QAAI,CAAC,OAAO;AACV,cAAQ,EAAE,MAAM,SAAS,oBAAI,MAAI;AACjC,qBAAe,IAAI,UAAU,KAAK;AAClC,iBAAW,MAAM,UAAU,QAAQ,GAAG,6BAA6B;AAAA,IACrE;AACA,UAAM,UAAU,MAAM,QAAQ,IAAI,OAAO,KAAK,CAAA;AAC9C,YAAQ,KAAK,EAAE,SAAS,OAAA,CAAQ;AAChC,UAAM,QAAQ,IAAI,SAAS,OAAO;AAAA,EACpC,CAAC;AACH;AAGA,MAAM,kBAAkB,IAAIC,WAAAA,YAAA;AAOrB,SAAS,gBAAgB,SAA8D;AAC5F,QAAM,OAAOC,WAAAA,WAAWC,wBAAc;AACtC,QAAM,kBAAkBD,WAAAA,WAAWE,6BAAkB;AACrD,QAAM,WAAW,qBAAqB,OAAO;AAC7C,QAAM,UAAU,QAAQ,QAAQ,YAAY,gBAAgB,IAAI,CAAC;AACjE,QAAM,cAAa,6BAAM,eAAc;AACvC,QAAM,YAAY,OAAO,YAAY,IAAI,IAAI;AAC7C,QAAM,EAAE,SAASC,WAAAA;AAAAA,IACf;AAAA,MACE,UAAU,CAAC,cAAc,iBAAiB,YAAY,WAAW,YAAY,EAAE;AAAA,MAC/E,SAAS,MAAM;AACb,YAAI,CAAC,QAAQ,CAAC,SAAU,QAAO;AAC/B,eAAO,iBAAiB;AAAA,UACtB;AAAA,UACA,UAAU,GAAG,UAAU,IAAI,SAAS;AAAA,UACpC,SAAS;AAAA,QAAA,CACV;AAAA,MACH;AAAA,MACA;AAAA,MACA,WAAW;AAAA;AAAA;AAAA,MAGX,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,sBAAsB;AAAA,IAAA;AAAA,IAExB,mBAAmB;AAAA,EAAA;AAErB,SAAO,UAAU,OAAO;AAC1B;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** What a chip draws from the asset: its current title and its type. */
|
|
2
|
+
export interface MentionAsset {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
assetType: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const MENTION_ASSET_BATCH_SIZE = 50;
|
|
8
|
+
export declare const MENTION_ASSET_BATCH_WINDOW_MS = 16;
|
|
9
|
+
export declare function mentionAssetLookupId(assetId: string | undefined): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The asset an asset chip names: `undefined` while unknown (no lookup, still
|
|
12
|
+
* loading, or the lookup failed), `null` when agora returned no asset the
|
|
13
|
+
* viewer may read under that id, else its title and type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMentionAsset(assetId: string | undefined): MentionAsset | null | undefined;
|
|
16
|
+
export declare function resetMentionAssetsForTests(): void;
|