@athenaintel/react 0.28.1 → 0.32.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 +479 -10
- package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
- package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
- package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
- package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
- package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
- package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
- package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
- package/dist/agent-runtime/src/auth-denial.js.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
- package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tools.js.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.js +124 -0
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
- package/dist/agent-runtime/src/config-mutations.cjs +59 -0
- package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
- package/dist/agent-runtime/src/config-mutations.js +59 -0
- package/dist/agent-runtime/src/config-mutations.js.map +1 -0
- package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
- package/dist/agent-runtime/src/conversation-index.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
- package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
- package/dist/agent-runtime/src/conversation-list.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
- package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
- package/dist/agent-runtime/src/edit-command.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
- package/dist/agent-runtime/src/errors.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
- package/dist/agent-runtime/src/errors.js.map +1 -0
- package/dist/agent-runtime/src/execute-output.cjs +41 -0
- package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
- package/dist/agent-runtime/src/execute-output.js +41 -0
- package/dist/agent-runtime/src/execute-output.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
- package/dist/agent-runtime/src/interrupts.js.map +1 -0
- package/dist/agent-runtime/src/message-author.cjs.map +1 -0
- package/dist/agent-runtime/src/message-author.js.map +1 -0
- package/dist/agent-runtime/src/message-window.cjs.map +1 -0
- package/dist/agent-runtime/src/message-window.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
- package/dist/agent-runtime/src/messages.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
- package/dist/agent-runtime/src/messages.js.map +1 -0
- package/dist/agent-runtime/src/model-context.cjs.map +1 -0
- package/dist/agent-runtime/src/model-context.js.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
- package/dist/agent-runtime/src/protocol.cjs.map +1 -0
- package/dist/agent-runtime/src/protocol.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
- package/dist/agent-runtime/src/queue.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
- package/dist/agent-runtime/src/queue.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +71 -13
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +73 -15
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
- package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
- package/dist/agent-runtime/src/send-recovery.js.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
- package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
- package/dist/agent-runtime/src/statewire-state.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
- package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
- package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.js +43 -0
- package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
- package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-extras.js.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
- package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-status.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +304 -9
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +304 -9
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
- package/dist/agent-runtime/src/tool-names.cjs +5 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-names.js +5 -0
- package/dist/agent-runtime/src/tool-names.js.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
- package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-result.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
- package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
- package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.cjs +129 -0
- package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.js +129 -0
- package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
- package/dist/assets/AthenaAssetEmbed.cjs +13 -2
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +10 -0
- package/dist/assets/AthenaAssetEmbed.js +14 -3
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/AthenaLayout.cjs +97 -31
- package/dist/assets/AthenaLayout.cjs.map +1 -1
- package/dist/assets/AthenaLayout.d.ts +13 -0
- package/dist/assets/AthenaLayout.js +98 -32
- package/dist/assets/AthenaLayout.js.map +1 -1
- package/dist/assets/asset-embed-messages.cjs +6 -0
- package/dist/assets/asset-embed-messages.cjs.map +1 -1
- package/dist/assets/asset-embed-messages.d.ts +13 -0
- package/dist/assets/asset-embed-messages.js +6 -0
- package/dist/assets/asset-embed-messages.js.map +1 -1
- package/dist/assets/asset-panel-store.cjs +68 -32
- package/dist/assets/asset-panel-store.cjs.map +1 -1
- package/dist/assets/asset-panel-store.d.ts +47 -1
- package/dist/assets/asset-panel-store.js +68 -32
- package/dist/assets/asset-panel-store.js.map +1 -1
- package/dist/assets/use-asset-embed.cjs +29 -8
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.d.ts +7 -0
- package/dist/assets/use-asset-embed.js +29 -8
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/catalog/chat-pickers.cjs +152 -0
- package/dist/catalog/chat-pickers.cjs.map +1 -0
- package/dist/catalog/chat-pickers.d.ts +22 -0
- package/dist/catalog/chat-pickers.js +152 -0
- package/dist/catalog/chat-pickers.js.map +1 -0
- package/dist/catalog/runtime-catalog.cjs +181 -0
- package/dist/catalog/runtime-catalog.cjs.map +1 -0
- package/dist/catalog/runtime-catalog.d.ts +100 -0
- package/dist/catalog/runtime-catalog.js +181 -0
- package/dist/catalog/runtime-catalog.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +122 -67
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +21 -4
- package/dist/chat/AthenaChat.js +124 -69
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +38 -37
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +2 -0
- package/dist/chat/StatewireApprovalCard.js +39 -38
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -2
- package/dist/chat/StatewireClientToolBridge.js +2 -2
- package/dist/chat/StatewireQueuedMessages.cjs +15 -12
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
- package/dist/chat/StatewireQueuedMessages.js +15 -12
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
- package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
- package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
- package/dist/chat/StatewireRunRefusalNotice.js +48 -0
- package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
- package/dist/chat/WaitingOnYouBanner.cjs +2 -2
- package/dist/chat/WaitingOnYouBanner.js +2 -2
- package/dist/chat/athena-citation-links.cjs +19 -15
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-citation-links.js +19 -15
- package/dist/chat/athena-citation-links.js.map +1 -1
- package/dist/chat/run-activity.cjs +9 -1
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.d.ts +6 -0
- package/dist/chat/run-activity.js +10 -2
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-banners.cjs +30 -1
- package/dist/chat/statewire-banners.cjs.map +1 -1
- package/dist/chat/statewire-banners.d.ts +20 -1
- package/dist/chat/statewire-banners.js +32 -3
- package/dist/chat/statewire-banners.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +1 -1
- package/dist/chat/statewire-client-tools.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +38 -16
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +21 -4
- package/dist/chat/super-grouping/SuperGroupingCard.js +39 -17
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +377 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +377 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
- package/dist/chat/super-grouping/ToolTimeline.js +13 -2
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +69 -29
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +60 -9
- package/dist/chat/super-grouping/activity-timeline.js +70 -30
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/index.cjs +14 -0
- package/dist/chat/super-grouping/index.cjs.map +1 -1
- package/dist/chat/super-grouping/index.d.ts +7 -2
- package/dist/chat/super-grouping/index.js +16 -2
- package/dist/chat/super-grouping/index.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +14 -5
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
- package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
- package/dist/chat/super-grouping/timeline-step.js +15 -6
- package/dist/chat/super-grouping/timeline-step.js.map +1 -1
- package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
- package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
- package/dist/chat/super-grouping/toolkit-map.js +1 -0
- package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
- package/dist/chat/super-grouping/turn-segments.cjs +82 -0
- package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
- package/dist/chat/super-grouping/turn-segments.js +82 -0
- package/dist/chat/super-grouping/turn-segments.js.map +1 -0
- package/dist/chat/super-grouping/turn-timing.cjs +110 -0
- package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
- package/dist/chat/super-grouping/turn-timing.js +110 -0
- package/dist/chat/super-grouping/turn-timing.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +1 -1
- package/dist/chat/tiptap-text.js +1 -1
- package/dist/chat/use-athena-run-live.cjs +1 -1
- package/dist/chat/use-athena-run-live.js +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +73 -4
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.js +74 -5
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/composer-message.cjs +284 -0
- package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
- package/dist/chat-ui/composer/composer-message.d.ts +152 -0
- package/dist/chat-ui/composer/composer-message.js +284 -0
- package/dist/chat-ui/composer/composer-message.js.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs +97 -15
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
- package/dist/chat-ui/composer/tiptap-composer.js +97 -15
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +4 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +3 -2
- package/dist/chat-ui/index.js +5 -2
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +31 -3
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
- package/dist/chat-ui/mentions/mention-chip.js +33 -5
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +9 -3
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.js +9 -3
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
- package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
- package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
- package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
- package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
- package/dist/chat-ui/messages/message-components.cjs +30 -10
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +21 -1
- package/dist/chat-ui/messages/message-components.js +30 -10
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +1 -1
- package/dist/chat-ui/messages/runtime-message.js +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
- package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
- package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +39 -4
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
- package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
- package/dist/chat-ui/messages/wake-marker.js +40 -5
- package/dist/chat-ui/messages/wake-marker.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
- package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +1 -1
- package/dist/chat-ui/statewire.d.ts +1 -1
- package/dist/chat-ui/statewire.js +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
- package/dist/collab/client.cjs +282 -16
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +127 -2
- package/dist/collab/client.js +285 -20
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.cjs +2 -0
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.ts +1 -1
- package/dist/collab/index.js +3 -1
- package/dist/composer/AttachmentContext.cjs +38 -12
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.d.ts +22 -1
- package/dist/composer/AttachmentContext.js +40 -14
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/QuoteContext.cjs +80 -28
- package/dist/composer/QuoteContext.cjs.map +1 -1
- package/dist/composer/QuoteContext.d.ts +35 -6
- package/dist/composer/QuoteContext.js +82 -30
- package/dist/composer/QuoteContext.js.map +1 -1
- package/dist/composer/build-composed-message.cjs +27 -0
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +21 -0
- package/dist/composer/build-composed-message.js +28 -1
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +13 -1
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +12 -0
- package/dist/composer/composer-handoff.js +15 -3
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/index.d.ts +6 -3
- package/dist/composer/useReadComposerDraft.cjs +16 -0
- package/dist/composer/useReadComposerDraft.cjs.map +1 -0
- package/dist/composer/useReadComposerDraft.d.ts +6 -0
- package/dist/composer/useReadComposerDraft.js +16 -0
- package/dist/composer/useReadComposerDraft.js.map +1 -0
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/diagnostics/errors.cjs +6 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +6 -0
- package/dist/diagnostics/errors.js +6 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +163 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +55 -12
- package/dist/index.js +170 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/owner-document.cjs +32 -0
- package/dist/lib/owner-document.cjs.map +1 -0
- package/dist/lib/owner-document.d.ts +17 -0
- package/dist/lib/owner-document.js +32 -0
- package/dist/lib/owner-document.js.map +1 -0
- package/dist/lib/portal-surface.cjs +55 -0
- package/dist/lib/portal-surface.cjs.map +1 -0
- package/dist/lib/portal-surface.d.ts +37 -0
- package/dist/lib/portal-surface.js +55 -0
- package/dist/lib/portal-surface.js.map +1 -0
- package/dist/lib/use-athena-rest-query.cjs +34 -0
- package/dist/lib/use-athena-rest-query.cjs.map +1 -0
- package/dist/lib/use-athena-rest-query.d.ts +31 -0
- package/dist/lib/use-athena-rest-query.js +34 -0
- package/dist/lib/use-athena-rest-query.js.map +1 -0
- package/dist/provider/AthenaProvider.cjs +70 -10
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +27 -2
- package/dist/provider/AthenaProvider.js +74 -14
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/citation-links.d.ts +10 -2
- package/dist/{packages/react → react}/package.json.cjs +1 -1
- package/dist/{packages/react → react}/package.json.js +1 -1
- package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
- package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
- package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
- package/dist/runtime/StatewireModelLaneSync.js +96 -0
- package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
- package/dist/runtime/statewire-lifecycle.cjs +20 -5
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.d.ts +11 -0
- package/dist/runtime/statewire-lifecycle.js +20 -5
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/statewire-model-lane.cjs +28 -0
- package/dist/runtime/statewire-model-lane.cjs.map +1 -0
- package/dist/runtime/statewire-model-lane.d.ts +64 -0
- package/dist/runtime/statewire-model-lane.js +28 -0
- package/dist/runtime/statewire-model-lane.js.map +1 -0
- package/dist/runtime/statewire-run-config.cjs +16 -2
- package/dist/runtime/statewire-run-config.cjs.map +1 -1
- package/dist/runtime/statewire-run-config.d.ts +10 -0
- package/dist/runtime/statewire-run-config.js +16 -2
- package/dist/runtime/statewire-run-config.js.map +1 -1
- package/dist/runtime/statewire-server-lane-context.cjs +24 -0
- package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
- package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
- package/dist/runtime/statewire-server-lane-context.js +24 -0
- package/dist/runtime/statewire-server-lane-context.js.map +1 -0
- package/dist/runtime/useAthenaStatewireRuntime.cjs +47 -23
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +48 -24
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaRepoSearch.cjs +5 -13
- package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
- package/dist/search/useAthenaRepoSearch.d.ts +3 -3
- package/dist/search/useAthenaRepoSearch.js +6 -14
- package/dist/search/useAthenaRepoSearch.js.map +1 -1
- package/dist/sheet-range/a1.cjs +162 -0
- package/dist/sheet-range/a1.cjs.map +1 -0
- package/dist/sheet-range/a1.d.ts +91 -0
- package/dist/sheet-range/a1.js +162 -0
- package/dist/sheet-range/a1.js.map +1 -0
- package/dist/sheet-range/index.cjs +22 -0
- package/dist/sheet-range/index.cjs.map +1 -0
- package/dist/sheet-range/index.d.ts +12 -0
- package/dist/sheet-range/index.js +22 -0
- package/dist/sheet-range/index.js.map +1 -0
- package/dist/sheet-range/range-preview-table.cjs +75 -0
- package/dist/sheet-range/range-preview-table.cjs.map +1 -0
- package/dist/sheet-range/range-preview-table.d.ts +20 -0
- package/dist/sheet-range/range-preview-table.js +75 -0
- package/dist/sheet-range/range-preview-table.js.map +1 -0
- package/dist/sheet-range/range-preview.cjs +116 -0
- package/dist/sheet-range/range-preview.cjs.map +1 -0
- package/dist/sheet-range/range-preview.d.ts +67 -0
- package/dist/sheet-range/range-preview.js +116 -0
- package/dist/sheet-range/range-preview.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/threads/Inbox.cjs +289 -0
- package/dist/threads/Inbox.cjs.map +1 -0
- package/dist/threads/Inbox.d.ts +46 -0
- package/dist/threads/Inbox.js +289 -0
- package/dist/threads/Inbox.js.map +1 -0
- package/dist/threads/SessionList.cjs +51 -126
- package/dist/threads/SessionList.cjs.map +1 -1
- package/dist/threads/SessionList.d.ts +26 -1
- package/dist/threads/SessionList.js +45 -120
- package/dist/threads/SessionList.js.map +1 -1
- package/dist/threads/SessionsPage.cjs +753 -0
- package/dist/threads/SessionsPage.cjs.map +1 -0
- package/dist/threads/SessionsPage.d.ts +35 -0
- package/dist/threads/SessionsPage.js +753 -0
- package/dist/threads/SessionsPage.js.map +1 -0
- package/dist/threads/api.cjs +23 -2
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +60 -0
- package/dist/threads/api.js +23 -2
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +9 -2
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +14 -1
- package/dist/threads/conversation-list-fetcher.js +9 -2
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/index.d.ts +2 -1
- package/dist/threads/pull-request-display.cjs +25 -0
- package/dist/threads/pull-request-display.cjs.map +1 -0
- package/dist/threads/pull-request-display.d.ts +15 -0
- package/dist/threads/pull-request-display.js +25 -0
- package/dist/threads/pull-request-display.js.map +1 -0
- package/dist/threads/session-list-model.cjs +16 -2
- package/dist/threads/session-list-model.cjs.map +1 -1
- package/dist/threads/session-list-model.d.ts +10 -0
- package/dist/threads/session-list-model.js +16 -2
- package/dist/threads/session-list-model.js.map +1 -1
- package/dist/threads/session-row-parts.cjs +152 -0
- package/dist/threads/session-row-parts.cjs.map +1 -0
- package/dist/threads/session-row-parts.d.ts +50 -0
- package/dist/threads/session-row-parts.js +152 -0
- package/dist/threads/session-row-parts.js.map +1 -0
- package/dist/threads/sessions-page-model.cjs +305 -0
- package/dist/threads/sessions-page-model.cjs.map +1 -0
- package/dist/threads/sessions-page-model.d.ts +86 -0
- package/dist/threads/sessions-page-model.js +305 -0
- package/dist/threads/sessions-page-model.js.map +1 -0
- package/dist/threads/sessions-page-storage.cjs +93 -0
- package/dist/threads/sessions-page-storage.cjs.map +1 -0
- package/dist/threads/sessions-page-storage.d.ts +23 -0
- package/dist/threads/sessions-page-storage.js +93 -0
- package/dist/threads/sessions-page-storage.js.map +1 -0
- package/dist/threads/sessions-query.cjs +235 -0
- package/dist/threads/sessions-query.cjs.map +1 -0
- package/dist/threads/sessions-query.d.ts +119 -0
- package/dist/threads/sessions-query.js +235 -0
- package/dist/threads/sessions-query.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +133 -40
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +83 -2
- package/dist/threads/statewire-thread-list.js +134 -41
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-athena-sessions.cjs +198 -0
- package/dist/threads/use-athena-sessions.cjs.map +1 -0
- package/dist/threads/use-athena-sessions.d.ts +81 -0
- package/dist/threads/use-athena-sessions.js +198 -0
- package/dist/threads/use-athena-sessions.js.map +1 -0
- package/dist/threads/use-athena-thread-model.cjs +14 -0
- package/dist/threads/use-athena-thread-model.cjs.map +1 -0
- package/dist/threads/use-athena-thread-model.d.ts +22 -0
- package/dist/threads/use-athena-thread-model.js +14 -0
- package/dist/threads/use-athena-thread-model.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +1 -1
- package/dist/threads/use-rest-conversation-history.js +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
- package/dist/threads/use-statewire-conversation-history.js +1 -1
- package/dist/threads/use-thread-read-state.cjs +73 -0
- package/dist/threads/use-thread-read-state.cjs.map +1 -0
- package/dist/threads/use-thread-read-state.d.ts +51 -0
- package/dist/threads/use-thread-read-state.js +73 -0
- package/dist/threads/use-thread-read-state.js.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
- package/dist/tools/auto-open-tools.cjs +2 -0
- package/dist/tools/auto-open-tools.cjs.map +1 -1
- package/dist/tools/auto-open-tools.js +2 -0
- package/dist/tools/auto-open-tools.js.map +1 -1
- package/dist/tools/file-tool-uis.cjs +18 -43
- package/dist/tools/file-tool-uis.cjs.map +1 -1
- package/dist/tools/file-tool-uis.d.ts +1 -2
- package/dist/tools/file-tool-uis.js +18 -42
- package/dist/tools/file-tool-uis.js.map +1 -1
- package/dist/tools/index.cjs +6 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +6 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -2
- package/dist/tools/misc-tool-uis.js +2 -2
- package/dist/tools/primitives.cjs +1 -1
- package/dist/tools/primitives.js +1 -1
- package/dist/tools/read-asset-tool-ui.cjs +21 -70
- package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
- package/dist/tools/read-asset-tool-ui.js +21 -70
- package/dist/tools/read-asset-tool-ui.js.map +1 -1
- package/dist/tools/step-text.cjs +21 -0
- package/dist/tools/step-text.cjs.map +1 -0
- package/dist/tools/step-text.d.ts +10 -0
- package/dist/tools/step-text.js +21 -0
- package/dist/tools/step-text.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +24 -5
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.d.ts +3 -1
- package/dist/tools/tool-fallback.js +24 -5
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/tool-summary.cjs +661 -0
- package/dist/tools/tool-summary.cjs.map +1 -0
- package/dist/tools/tool-summary.d.ts +99 -0
- package/dist/tools/tool-summary.js +661 -0
- package/dist/tools/tool-summary.js.map +1 -0
- package/dist/tools/tool-uis.cjs +37 -95
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.js +37 -95
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/tools/voice-update-tool-ui.cjs +1 -1
- package/dist/tools/voice-update-tool-ui.js +1 -1
- package/dist/tools/write-todos-tool-ui.cjs +3 -2
- package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
- package/dist/tools/write-todos-tool-ui.d.ts +5 -0
- package/dist/tools/write-todos-tool-ui.js +5 -4
- package/dist/tools/write-todos-tool-ui.js.map +1 -1
- package/dist/ui/popover.cjs +6 -6
- package/dist/ui/popover.cjs.map +1 -1
- package/dist/ui/popover.js +6 -6
- package/dist/ui/popover.js.map +1 -1
- package/dist/ui/tooltip.cjs +16 -2
- package/dist/ui/tooltip.cjs.map +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/dist/ui/tooltip.js +16 -2
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/voice/use-athena-voice-session.cjs.map +1 -1
- package/dist/voice/use-athena-voice-session.d.ts +3 -3
- package/dist/voice/use-athena-voice-session.js.map +1 -1
- package/dist/workbench/SessionWorkbench.cjs +378 -0
- package/dist/workbench/SessionWorkbench.cjs.map +1 -0
- package/dist/workbench/SessionWorkbench.d.ts +30 -0
- package/dist/workbench/SessionWorkbench.js +378 -0
- package/dist/workbench/SessionWorkbench.js.map +1 -0
- package/dist/workbench/session-workbench-context.cjs +26 -0
- package/dist/workbench/session-workbench-context.cjs.map +1 -0
- package/dist/workbench/session-workbench-context.d.ts +55 -0
- package/dist/workbench/session-workbench-context.js +26 -0
- package/dist/workbench/session-workbench-context.js.map +1 -0
- package/dist/workbench/session-workbench-model.cjs +288 -0
- package/dist/workbench/session-workbench-model.cjs.map +1 -0
- package/dist/workbench/session-workbench-model.d.ts +168 -0
- package/dist/workbench/session-workbench-model.js +288 -0
- package/dist/workbench/session-workbench-model.js.map +1 -0
- package/dist/workbench/session-workbench-panes.cjs +580 -0
- package/dist/workbench/session-workbench-panes.cjs.map +1 -0
- package/dist/workbench/session-workbench-panes.d.ts +16 -0
- package/dist/workbench/session-workbench-panes.js +580 -0
- package/dist/workbench/session-workbench-panes.js.map +1 -0
- package/dist/workbench/session-workspace-api.cjs +157 -0
- package/dist/workbench/session-workspace-api.cjs.map +1 -0
- package/dist/workbench/session-workspace-api.d.ts +70 -0
- package/dist/workbench/session-workspace-api.js +157 -0
- package/dist/workbench/session-workspace-api.js.map +1 -0
- package/dist/workbench/use-session-workspace.cjs +100 -0
- package/dist/workbench/use-session-workspace.cjs.map +1 -0
- package/dist/workbench/use-session-workspace.d.ts +45 -0
- package/dist/workbench/use-session-workspace.js +100 -0
- package/dist/workbench/use-session-workspace.js.map +1 -0
- package/dist/workbench/workbench-layout-context.cjs +10 -0
- package/dist/workbench/workbench-layout-context.cjs.map +1 -0
- package/dist/workbench/workbench-layout-context.d.ts +17 -0
- package/dist/workbench/workbench-layout-context.js +10 -0
- package/dist/workbench/workbench-layout-context.js.map +1 -0
- package/package.json +21 -10
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
- package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/errors.js.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
- package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
- package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/queue.js.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -13
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -13
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
- /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
- /package/dist/{packages/react → react}/package.json.js.map +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuoteContext.cjs","sources":["../../src/composer/QuoteContext.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';\n\nexport interface QuoteData {\n /** The selected/quoted text. */\n text: string;\n /** Title of the source (e.g., asset title, document name). */\n sourceTitle?: string;\n /** Asset ID of the source (for attribution). */\n sourceAssetId?: string;\n /** Message ID of the source message (when quoting from chat). */\n sourceMessageId?: string;\n /** Role of the source message ('assistant' | 'user'). */\n sourceRole?: string;\n}\n\ninterface QuoteContextValue {\n quote: QuoteData | null;\n setQuote: (quote: QuoteData | null) => void;\n clearQuote: () => void;\n}\n\nconst QuoteCtx = createContext<QuoteContextValue | null>(null);\n\nexport function QuoteProvider({ children }: { children: ReactNode }) {\n const [quote, setQuote] = useState<QuoteData | null>(null);\n const clearQuote = useCallback(() => setQuote(null), []);\n\n const value = useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);\n\n return (\n <QuoteCtx.Provider value={value}>\n {children}\n </QuoteCtx.Provider>\n );\n}\n\nexport function useQuote(): QuoteContextValue {\n const ctx = useContext(QuoteCtx);\n if (!ctx) {\n throw new Error('[AthenaSDK] useQuote must be used within <QuoteProvider>');\n }\n return ctx;\n}\n\n/**\n * Whether a message came from a frame embedded directly in this window, for\n * any origin: the window of one of this document's iframes (an identity\n * comparison, safe cross-origin), or, for a frame inside a shadow root, a\n * window whose `parent` is this window (`parent` is readable on a\n * cross-origin window). A message port, a worker, this window itself, a\n * grandchild frame or an unrelated window is refused.\n */\nexport function isDirectChildFrame(source: MessageEventSource | null): boolean {\n if (!source || source === window) return false;\n for (const frame of document.querySelectorAll('iframe')) {\n if (frame.contentWindow === source) return true;\n }\n try {\n return Reflect.get(source, 'parent') === window;\n } catch {\n return false;\n }\n}\n\n/**\n * Listens for:\n * 1. Cmd+L / Ctrl+L keydown — grabs the current text selection and sets it as a quote.\n * `preventDefault` stops the browser from focusing the URL bar.\n * 2. PostMessage events from child iframes (asset panels, embedded content)\n * with type `athena-add-to-composer`, only from a frame embedded directly\n * in this window ({@link isDirectChildFrame}).\n *\n * Mount this once inside AthenaProvider.\n */\nexport function useQuoteFromPostMessage() {\n const { setQuote } = useQuote();\n\n useEffect(() => {\n // ── Cmd+L / Ctrl+L keyboard handler ──────────────────────────────\n const handleKeydown = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'l') {\n const sel = window.getSelection();\n const selection = sel?.toString()?.trim();\n\n if (selection && selection.length > 0) {\n e.preventDefault();\n\n // Walk up from the selection anchor to find the message container.\n // assistant-ui message roots have data-role=\"assistant\" or data-role=\"user\".\n let messageId: string | undefined;\n let role: string | undefined;\n let node = sel?.anchorNode as HTMLElement | null;\n while (node && node !== document.body) {\n if (node instanceof HTMLElement) {\n const dataRole = node.getAttribute('data-role');\n if (dataRole === 'assistant' || dataRole === 'user') {\n role = dataRole;\n // assistant-ui sets data-message-id on message roots\n messageId = node.getAttribute('data-message-id') ?? undefined;\n break;\n }\n }\n node = node.parentElement;\n }\n\n setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });\n }\n }\n };\n\n // ── PostMessage handler (from iframes) ───────────────────────────\n // Accepts messages from any origin, but only from a frame embedded\n // directly in this window: the SDK consumer controls which iframes are\n // embedded, and that is the trust boundary. A popup, an opener or another\n // tab holding a reference to this window cannot stage composer text.\n const handleMessage = (event: MessageEvent) => {\n const data = event.data;\n if (\n data &&\n typeof data === 'object' &&\n data.type === 'athena-add-to-composer' &&\n typeof data.text === 'string' &&\n data.text.trim().length > 0 &&\n isDirectChildFrame(event.source)\n ) {\n setQuote({\n text: data.text,\n sourceTitle: data.sourceTitle,\n sourceAssetId: data.sourceAssetId,\n });\n }\n };\n\n document.addEventListener('keydown', handleKeydown, true); // capture phase to beat the browser\n window.addEventListener('message', handleMessage);\n\n return () => {\n document.removeEventListener('keydown', handleKeydown, true);\n window.removeEventListener('message', handleMessage);\n };\n }, [setQuote]);\n}\n"],"names":["createContext","useState","useCallback","useMemo","jsx","useContext","useEffect"],"mappings":";;;;AAqBA,MAAM,WAAWA,MAAAA,cAAwC,IAAI;AAEtD,SAAS,cAAc,EAAE,YAAqC;AACnE,QAAM,CAAC,OAAO,QAAQ,IAAIC,MAAAA,SAA2B,IAAI;AACzD,QAAM,aAAaC,MAAAA,YAAY,MAAM,SAAS,IAAI,GAAG,CAAA,CAAE;AAEvD,QAAM,QAAQC,MAAAA,QAAQ,OAAO,EAAE,OAAO,UAAU,WAAA,IAAe,CAAC,OAAO,UAAU,UAAU,CAAC;AAE5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C,YAAM,OAAO,MAAM;AACnB,UACE,QACA,OAAO,SAAS,YAChB,KAAK,SAAS,4BACd,OAAO,KAAK,SAAS,YACrB,KAAK,KAAK,OAAO,SAAS,KAC1B,mBAAmB,MAAM,MAAM,GAC/B;AACA,iBAAS;AAAA,UACP,MAAM,KAAK;AAAA,UACX,aAAa,KAAK;AAAA,UAClB,eAAe,KAAK;AAAA,QAAA,CACrB;AAAA,MACH;AAAA,IACF;AAEA,aAAS,iBAAiB,WAAW,eAAe,IAAI;AACxD,WAAO,iBAAiB,WAAW,aAAa;AAEhD,WAAO,MAAM;AACX,eAAS,oBAAoB,WAAW,eAAe,IAAI;AAC3D,aAAO,oBAAoB,WAAW,aAAa;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACf;;;;;"}
|
|
1
|
+
{"version":3,"file":"QuoteContext.cjs","sources":["../../src/composer/QuoteContext.tsx"],"sourcesContent":["import {\n createContext,\n type RefObject,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\nimport { useStore } from 'zustand';\nimport { createStore, type StoreApi } from 'zustand/vanilla';\n\nexport interface QuoteData {\n /** The selected/quoted text. */\n text: string;\n /** Title of the source (e.g., asset title, document name). */\n sourceTitle?: string;\n /** Asset ID of the source (for attribution). */\n sourceAssetId?: string;\n /** Message ID of the source message (when quoting from chat). */\n sourceMessageId?: string;\n /** Role of the source message ('assistant' | 'user'). */\n sourceRole?: string;\n}\n\ninterface QuoteContextValue {\n quote: QuoteData | null;\n setQuote: (quote: QuoteData | null) => void;\n clearQuote: () => void;\n}\n\nconst QuoteCtx = createContext<QuoteContextValue | null>(null);\n\ninterface QuoteStoreState {\n quote: QuoteData | null;\n}\n\n/**\n * A composer's pending quote, kept outside React (`createQuoteStore`), like\n * `AttachmentStore`: one per chat when a host shows several.\n */\nexport type QuoteStore = StoreApi<QuoteStoreState>;\n\n/** An empty `QuoteStore`, for `<QuoteProvider store>`. */\nexport function createQuoteStore(): QuoteStore {\n return createStore<QuoteStoreState>(() => ({ quote: null }));\n}\n\n/**\n * The composer's pending quote. Like \\`AttachmentProvider\\`, a `store` makes\n * it that store's, and without one it reuses a provider already mounted\n * above, so a host can keep the quote across a remounting \\`AthenaChat\\`.\n */\nexport function QuoteProvider({ children, store }: { children: ReactNode; store?: QuoteStore }) {\n const outer = useContext(QuoteCtx);\n if (store) return <StoreQuoteProvider store={store}>{children}</StoreQuoteProvider>;\n if (outer) return <>{children}</>;\n return <OwnQuoteProvider>{children}</OwnQuoteProvider>;\n}\n\nfunction OwnQuoteProvider({ children }: { children: ReactNode }) {\n const [store] = useState(createQuoteStore);\n return <StoreQuoteProvider store={store}>{children}</StoreQuoteProvider>;\n}\n\nfunction StoreQuoteProvider({ children, store }: { children: ReactNode; store: QuoteStore }) {\n const quote = useStore(store, (state) => state.quote);\n const actions = useMemo(\n () => ({\n setQuote: (next: QuoteData | null) => store.setState({ quote: next }),\n clearQuote: () => store.setState({ quote: null }),\n }),\n [store],\n );\n const value = useMemo(() => ({ quote, ...actions }), [quote, actions]);\n\n return (\n <QuoteCtx.Provider value={value}>\n {children}\n </QuoteCtx.Provider>\n );\n}\n\nexport function useQuote(): QuoteContextValue {\n const ctx = useContext(QuoteCtx);\n if (!ctx) {\n throw new Error('[AthenaSDK] useQuote must be used within <QuoteProvider>');\n }\n return ctx;\n}\n\n/**\n * Whether a message came from a frame embedded directly in this window, for\n * any origin: the window of one of this document's iframes (an identity\n * comparison, safe cross-origin), or, for a frame inside a shadow root, a\n * window whose `parent` is this window (`parent` is readable on a\n * cross-origin window). A message port, a worker, this window itself, a\n * grandchild frame or an unrelated window is refused. `win` is the window the\n * message came to (default: this one), e.g. a popped-out chat's.\n */\nexport function isDirectChildFrame(\n source: MessageEventSource | null,\n win: Window = window,\n): boolean {\n if (!source || source === win) return false;\n for (const frame of win.document.querySelectorAll('iframe')) {\n if (frame.contentWindow === source) return true;\n }\n try {\n return Reflect.get(source, 'parent') === win;\n } catch {\n return false;\n }\n}\n\n/** `AthenaChat`'s thread root: the chats `useQuoteFromPostMessage` tells apart. */\nconst CHAT_ROOT_SELECTOR = '.aui-thread-root';\n\n/**\n * The chat the person last focused in each window, which takes a quote that\n * names no chat (a selection outside every chat, an embedded frame's text)\n * when that window shows several. A focus, not data: no state of the chats\n * themselves.\n */\nconst lastFocusedChatRoots = new WeakMap<Document, Element>();\n\n/** The element a node is, or sits in; duck-typed, since a pop-out window's nodes are another realm's. */\nfunction elementOf(node: Node | null | undefined): Element | null {\n if (!node) return null;\n return node.nodeType === 1 ? (node as Element) : node.parentElement;\n}\n\nexport interface QuoteFromPostMessageOptions {\n /**\n * An element inside the chat this composer belongs to. With several chats in\n * one window, a ⌘L selection goes to the chat it was made in, and one made\n * outside every chat (or an embedded frame's text) to the chat the person\n * last focused; the keys and an embedded frame's messages are heard in this\n * element's own window, a pop-out included. Without it, every quote is this\n * composer's, as before.\n */\n scope?: RefObject<Element | null>;\n}\n\n/**\n * Listens for:\n * 1. Cmd+L / Ctrl+L keydown — grabs the current text selection and sets it as a quote.\n * `preventDefault` stops the browser from focusing the URL bar.\n * 2. PostMessage events from child iframes (asset panels, embedded content)\n * with type `athena-add-to-composer`, only from a frame embedded directly\n * in this window ({@link isDirectChildFrame}).\n *\n * Mount this once per composer inside AthenaProvider (`AthenaChat` does).\n */\nexport function useQuoteFromPostMessage({ scope }: QuoteFromPostMessageOptions = {}) {\n const { setQuote } = useQuote();\n\n useEffect(() => {\n const doc = scope?.current?.ownerDocument ?? document;\n const win = doc.defaultView ?? window;\n const chatRoot = () => scope?.current?.closest(CHAT_ROOT_SELECTOR) ?? null;\n // Whether this composer takes a quote made at `anchor` (null: one that names no chat).\n const takes = (anchor: Node | null) => {\n const mine = chatRoot();\n if (!mine) return true;\n const owner = elementOf(anchor)?.closest(CHAT_ROOT_SELECTOR) ?? null;\n if (owner) return owner === mine;\n const remembered = lastFocusedChatRoots.get(doc);\n const focused = remembered?.isConnected ? remembered : doc.querySelector(CHAT_ROOT_SELECTOR);\n return focused === mine;\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const mine = chatRoot();\n const target = event.target as Node | null;\n if (mine && target && typeof target.nodeType === 'number' && mine.contains(target)) {\n lastFocusedChatRoots.set(doc, mine);\n }\n };\n\n // ── Cmd+L / Ctrl+L keyboard handler ──────────────────────────────\n const handleKeydown = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'l') {\n const sel = doc.getSelection();\n const selection = sel?.toString()?.trim();\n\n if (selection && selection.length > 0 && takes(sel?.anchorNode ?? null)) {\n e.preventDefault();\n\n // Walk up from the selection anchor to find the message container.\n // assistant-ui message roots have data-role=\"assistant\" or data-role=\"user\".\n let messageId: string | undefined;\n let role: string | undefined;\n let node = elementOf(sel?.anchorNode);\n while (node && node !== doc.body) {\n const dataRole = node.getAttribute('data-role');\n if (dataRole === 'assistant' || dataRole === 'user') {\n role = dataRole;\n // assistant-ui sets data-message-id on message roots\n messageId = node.getAttribute('data-message-id') ?? undefined;\n break;\n }\n node = node.parentElement;\n }\n\n setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });\n }\n }\n };\n\n // ── PostMessage handler (from iframes) ───────────────────────────\n // Accepts messages from any origin, but only from a frame embedded\n // directly in this window: the SDK consumer controls which iframes are\n // embedded, and that is the trust boundary. A popup, an opener or another\n // tab holding a reference to this window cannot stage composer text.\n const handleMessage = (event: MessageEvent) => {\n const data = event.data;\n if (\n data &&\n typeof data === 'object' &&\n data.type === 'athena-add-to-composer' &&\n typeof data.text === 'string' &&\n data.text.trim().length > 0 &&\n isDirectChildFrame(event.source, win) &&\n takes(null)\n ) {\n setQuote({\n text: data.text,\n sourceTitle: data.sourceTitle,\n sourceAssetId: data.sourceAssetId,\n });\n }\n };\n\n doc.addEventListener('keydown', handleKeydown, true); // capture phase to beat the browser\n doc.addEventListener('focusin', handleFocusIn, true);\n win.addEventListener('message', handleMessage);\n\n return () => {\n doc.removeEventListener('keydown', handleKeydown, true);\n doc.removeEventListener('focusin', handleFocusIn, true);\n win.removeEventListener('message', handleMessage);\n };\n }, [scope, setQuote]);\n}\n"],"names":["createContext","createStore","useContext","jsx","Fragment","useState","useStore","useMemo","useEffect","_a"],"mappings":";;;;;;AA+BA,MAAM,WAAWA,MAAAA,cAAwC,IAAI;AAatD,SAAS,mBAA+B;AAC7C,SAAOC,QAAAA,YAA6B,OAAO,EAAE,OAAO,OAAO;AAC7D;AAOO,SAAS,cAAc,EAAE,UAAU,SAAsD;AAC9F,QAAM,QAAQC,MAAAA,WAAW,QAAQ;AACjC,MAAI,MAAO,QAAOC,2BAAAA,IAAC,oBAAA,EAAmB,OAAe,UAAS;AAC9D,MAAI,MAAO,QAAOA,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,SAAA,CAAS;AAC9B,SAAOD,+BAAC,oBAAkB,UAAS;AACrC;AAEA,SAAS,iBAAiB,EAAE,YAAqC;AAC/D,QAAM,CAAC,KAAK,IAAIE,MAAAA,SAAS,gBAAgB;AACzC,SAAOF,2BAAAA,IAAC,oBAAA,EAAmB,OAAe,SAAA,CAAS;AACrD;AAEA,SAAS,mBAAmB,EAAE,UAAU,SAAqD;AAC3F,QAAM,QAAQG,QAAAA,SAAS,OAAO,CAAC,UAAU,MAAM,KAAK;AACpD,QAAM,UAAUC,MAAAA;AAAAA,IACd,OAAO;AAAA,MACL,UAAU,CAAC,SAA2B,MAAM,SAAS,EAAE,OAAO,MAAM;AAAA,MACpE,YAAY,MAAM,MAAM,SAAS,EAAE,OAAO,MAAM;AAAA,IAAA;AAAA,IAElD,CAAC,KAAK;AAAA,EAAA;AAER,QAAM,QAAQA,cAAQ,OAAO,EAAE,OAAO,GAAG,QAAA,IAAY,CAAC,OAAO,OAAO,CAAC;AAErE,SACEJ,2BAAAA,IAAC,SAAS,UAAT,EAAkB,OAChB,SAAA,CACH;AAEJ;AAEO,SAAS,WAA8B;AAC5C,QAAM,MAAMD,MAAAA,WAAW,QAAQ;AAC/B,MAAI,CAAC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e,IAAI;AACtD,UAAI,oBAAoB,WAAW,eAAe,IAAI;AACtD,UAAI,oBAAoB,WAAW,aAAa;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,CAAC;AACtB;;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type RefObject, type ReactNode } from 'react';
|
|
2
|
+
import { type StoreApi } from 'zustand/vanilla';
|
|
2
3
|
export interface QuoteData {
|
|
3
4
|
/** The selected/quoted text. */
|
|
4
5
|
text: string;
|
|
@@ -16,8 +17,24 @@ interface QuoteContextValue {
|
|
|
16
17
|
setQuote: (quote: QuoteData | null) => void;
|
|
17
18
|
clearQuote: () => void;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
interface QuoteStoreState {
|
|
21
|
+
quote: QuoteData | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A composer's pending quote, kept outside React (`createQuoteStore`), like
|
|
25
|
+
* `AttachmentStore`: one per chat when a host shows several.
|
|
26
|
+
*/
|
|
27
|
+
export type QuoteStore = StoreApi<QuoteStoreState>;
|
|
28
|
+
/** An empty `QuoteStore`, for `<QuoteProvider store>`. */
|
|
29
|
+
export declare function createQuoteStore(): QuoteStore;
|
|
30
|
+
/**
|
|
31
|
+
* The composer's pending quote. Like \`AttachmentProvider\`, a `store` makes
|
|
32
|
+
* it that store's, and without one it reuses a provider already mounted
|
|
33
|
+
* above, so a host can keep the quote across a remounting \`AthenaChat\`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function QuoteProvider({ children, store }: {
|
|
20
36
|
children: ReactNode;
|
|
37
|
+
store?: QuoteStore;
|
|
21
38
|
}): import("react").JSX.Element;
|
|
22
39
|
export declare function useQuote(): QuoteContextValue;
|
|
23
40
|
/**
|
|
@@ -26,9 +43,21 @@ export declare function useQuote(): QuoteContextValue;
|
|
|
26
43
|
* comparison, safe cross-origin), or, for a frame inside a shadow root, a
|
|
27
44
|
* window whose `parent` is this window (`parent` is readable on a
|
|
28
45
|
* cross-origin window). A message port, a worker, this window itself, a
|
|
29
|
-
* grandchild frame or an unrelated window is refused.
|
|
46
|
+
* grandchild frame or an unrelated window is refused. `win` is the window the
|
|
47
|
+
* message came to (default: this one), e.g. a popped-out chat's.
|
|
30
48
|
*/
|
|
31
|
-
export declare function isDirectChildFrame(source: MessageEventSource | null): boolean;
|
|
49
|
+
export declare function isDirectChildFrame(source: MessageEventSource | null, win?: Window): boolean;
|
|
50
|
+
export interface QuoteFromPostMessageOptions {
|
|
51
|
+
/**
|
|
52
|
+
* An element inside the chat this composer belongs to. With several chats in
|
|
53
|
+
* one window, a ⌘L selection goes to the chat it was made in, and one made
|
|
54
|
+
* outside every chat (or an embedded frame's text) to the chat the person
|
|
55
|
+
* last focused; the keys and an embedded frame's messages are heard in this
|
|
56
|
+
* element's own window, a pop-out included. Without it, every quote is this
|
|
57
|
+
* composer's, as before.
|
|
58
|
+
*/
|
|
59
|
+
scope?: RefObject<Element | null>;
|
|
60
|
+
}
|
|
32
61
|
/**
|
|
33
62
|
* Listens for:
|
|
34
63
|
* 1. Cmd+L / Ctrl+L keydown — grabs the current text selection and sets it as a quote.
|
|
@@ -37,7 +66,7 @@ export declare function isDirectChildFrame(source: MessageEventSource | null): b
|
|
|
37
66
|
* with type `athena-add-to-composer`, only from a frame embedded directly
|
|
38
67
|
* in this window ({@link isDirectChildFrame}).
|
|
39
68
|
*
|
|
40
|
-
* Mount this once inside AthenaProvider.
|
|
69
|
+
* Mount this once per composer inside AthenaProvider (`AthenaChat` does).
|
|
41
70
|
*/
|
|
42
|
-
export declare function useQuoteFromPostMessage(): void;
|
|
71
|
+
export declare function useQuoteFromPostMessage({ scope }?: QuoteFromPostMessageOptions): void;
|
|
43
72
|
export {};
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext,
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, createContext, useMemo, useState, useEffect } from "react";
|
|
3
|
+
import { useStore } from "zustand";
|
|
4
|
+
import { createStore } from "zustand/vanilla";
|
|
3
5
|
const QuoteCtx = createContext(null);
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function createQuoteStore() {
|
|
7
|
+
return createStore(() => ({ quote: null }));
|
|
8
|
+
}
|
|
9
|
+
function QuoteProvider({ children, store }) {
|
|
10
|
+
const outer = useContext(QuoteCtx);
|
|
11
|
+
if (store) return /* @__PURE__ */ jsx(StoreQuoteProvider, { store, children });
|
|
12
|
+
if (outer) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
13
|
+
return /* @__PURE__ */ jsx(OwnQuoteProvider, { children });
|
|
14
|
+
}
|
|
15
|
+
function OwnQuoteProvider({ children }) {
|
|
16
|
+
const [store] = useState(createQuoteStore);
|
|
17
|
+
return /* @__PURE__ */ jsx(StoreQuoteProvider, { store, children });
|
|
18
|
+
}
|
|
19
|
+
function StoreQuoteProvider({ children, store }) {
|
|
20
|
+
const quote = useStore(store, (state) => state.quote);
|
|
21
|
+
const actions = useMemo(
|
|
22
|
+
() => ({
|
|
23
|
+
setQuote: (next) => store.setState({ quote: next }),
|
|
24
|
+
clearQuote: () => store.setState({ quote: null })
|
|
25
|
+
}),
|
|
26
|
+
[store]
|
|
27
|
+
);
|
|
28
|
+
const value = useMemo(() => ({ quote, ...actions }), [quote, actions]);
|
|
8
29
|
return /* @__PURE__ */ jsx(QuoteCtx.Provider, { value, children });
|
|
9
30
|
}
|
|
10
31
|
function useQuote() {
|
|
@@ -14,38 +35,66 @@ function useQuote() {
|
|
|
14
35
|
}
|
|
15
36
|
return ctx;
|
|
16
37
|
}
|
|
17
|
-
function isDirectChildFrame(source) {
|
|
18
|
-
if (!source || source ===
|
|
19
|
-
for (const frame of document.querySelectorAll("iframe")) {
|
|
38
|
+
function isDirectChildFrame(source, win = window) {
|
|
39
|
+
if (!source || source === win) return false;
|
|
40
|
+
for (const frame of win.document.querySelectorAll("iframe")) {
|
|
20
41
|
if (frame.contentWindow === source) return true;
|
|
21
42
|
}
|
|
22
43
|
try {
|
|
23
|
-
return Reflect.get(source, "parent") ===
|
|
44
|
+
return Reflect.get(source, "parent") === win;
|
|
24
45
|
} catch {
|
|
25
46
|
return false;
|
|
26
47
|
}
|
|
27
48
|
}
|
|
28
|
-
|
|
49
|
+
const CHAT_ROOT_SELECTOR = ".aui-thread-root";
|
|
50
|
+
const lastFocusedChatRoots = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function elementOf(node) {
|
|
52
|
+
if (!node) return null;
|
|
53
|
+
return node.nodeType === 1 ? node : node.parentElement;
|
|
54
|
+
}
|
|
55
|
+
function useQuoteFromPostMessage({ scope } = {}) {
|
|
29
56
|
const { setQuote } = useQuote();
|
|
30
57
|
useEffect(() => {
|
|
58
|
+
var _a;
|
|
59
|
+
const doc = ((_a = scope == null ? void 0 : scope.current) == null ? void 0 : _a.ownerDocument) ?? document;
|
|
60
|
+
const win = doc.defaultView ?? window;
|
|
61
|
+
const chatRoot = () => {
|
|
62
|
+
var _a2;
|
|
63
|
+
return ((_a2 = scope == null ? void 0 : scope.current) == null ? void 0 : _a2.closest(CHAT_ROOT_SELECTOR)) ?? null;
|
|
64
|
+
};
|
|
65
|
+
const takes = (anchor) => {
|
|
66
|
+
var _a2;
|
|
67
|
+
const mine = chatRoot();
|
|
68
|
+
if (!mine) return true;
|
|
69
|
+
const owner = ((_a2 = elementOf(anchor)) == null ? void 0 : _a2.closest(CHAT_ROOT_SELECTOR)) ?? null;
|
|
70
|
+
if (owner) return owner === mine;
|
|
71
|
+
const remembered = lastFocusedChatRoots.get(doc);
|
|
72
|
+
const focused = (remembered == null ? void 0 : remembered.isConnected) ? remembered : doc.querySelector(CHAT_ROOT_SELECTOR);
|
|
73
|
+
return focused === mine;
|
|
74
|
+
};
|
|
75
|
+
const handleFocusIn = (event) => {
|
|
76
|
+
const mine = chatRoot();
|
|
77
|
+
const target = event.target;
|
|
78
|
+
if (mine && target && typeof target.nodeType === "number" && mine.contains(target)) {
|
|
79
|
+
lastFocusedChatRoots.set(doc, mine);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
31
82
|
const handleKeydown = (e) => {
|
|
32
|
-
var
|
|
83
|
+
var _a2;
|
|
33
84
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "l") {
|
|
34
|
-
const sel =
|
|
35
|
-
const selection = (
|
|
36
|
-
if (selection && selection.length > 0) {
|
|
85
|
+
const sel = doc.getSelection();
|
|
86
|
+
const selection = (_a2 = sel == null ? void 0 : sel.toString()) == null ? void 0 : _a2.trim();
|
|
87
|
+
if (selection && selection.length > 0 && takes((sel == null ? void 0 : sel.anchorNode) ?? null)) {
|
|
37
88
|
e.preventDefault();
|
|
38
89
|
let messageId;
|
|
39
90
|
let role;
|
|
40
|
-
let node = sel == null ? void 0 : sel.anchorNode;
|
|
41
|
-
while (node && node !==
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
91
|
+
let node = elementOf(sel == null ? void 0 : sel.anchorNode);
|
|
92
|
+
while (node && node !== doc.body) {
|
|
93
|
+
const dataRole = node.getAttribute("data-role");
|
|
94
|
+
if (dataRole === "assistant" || dataRole === "user") {
|
|
95
|
+
role = dataRole;
|
|
96
|
+
messageId = node.getAttribute("data-message-id") ?? void 0;
|
|
97
|
+
break;
|
|
49
98
|
}
|
|
50
99
|
node = node.parentElement;
|
|
51
100
|
}
|
|
@@ -55,7 +104,7 @@ function useQuoteFromPostMessage() {
|
|
|
55
104
|
};
|
|
56
105
|
const handleMessage = (event) => {
|
|
57
106
|
const data = event.data;
|
|
58
|
-
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0 && isDirectChildFrame(event.source)) {
|
|
107
|
+
if (data && typeof data === "object" && data.type === "athena-add-to-composer" && typeof data.text === "string" && data.text.trim().length > 0 && isDirectChildFrame(event.source, win) && takes(null)) {
|
|
59
108
|
setQuote({
|
|
60
109
|
text: data.text,
|
|
61
110
|
sourceTitle: data.sourceTitle,
|
|
@@ -63,16 +112,19 @@ function useQuoteFromPostMessage() {
|
|
|
63
112
|
});
|
|
64
113
|
}
|
|
65
114
|
};
|
|
66
|
-
|
|
67
|
-
|
|
115
|
+
doc.addEventListener("keydown", handleKeydown, true);
|
|
116
|
+
doc.addEventListener("focusin", handleFocusIn, true);
|
|
117
|
+
win.addEventListener("message", handleMessage);
|
|
68
118
|
return () => {
|
|
69
|
-
|
|
70
|
-
|
|
119
|
+
doc.removeEventListener("keydown", handleKeydown, true);
|
|
120
|
+
doc.removeEventListener("focusin", handleFocusIn, true);
|
|
121
|
+
win.removeEventListener("message", handleMessage);
|
|
71
122
|
};
|
|
72
|
-
}, [setQuote]);
|
|
123
|
+
}, [scope, setQuote]);
|
|
73
124
|
}
|
|
74
125
|
export {
|
|
75
126
|
QuoteProvider,
|
|
127
|
+
createQuoteStore,
|
|
76
128
|
isDirectChildFrame,
|
|
77
129
|
useQuote,
|
|
78
130
|
useQuoteFromPostMessage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuoteContext.js","sources":["../../src/composer/QuoteContext.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';\n\nexport interface QuoteData {\n /** The selected/quoted text. */\n text: string;\n /** Title of the source (e.g., asset title, document name). */\n sourceTitle?: string;\n /** Asset ID of the source (for attribution). */\n sourceAssetId?: string;\n /** Message ID of the source message (when quoting from chat). */\n sourceMessageId?: string;\n /** Role of the source message ('assistant' | 'user'). */\n sourceRole?: string;\n}\n\ninterface QuoteContextValue {\n quote: QuoteData | null;\n setQuote: (quote: QuoteData | null) => void;\n clearQuote: () => void;\n}\n\nconst QuoteCtx = createContext<QuoteContextValue | null>(null);\n\nexport function QuoteProvider({ children }: { children: ReactNode }) {\n const [quote, setQuote] = useState<QuoteData | null>(null);\n const clearQuote = useCallback(() => setQuote(null), []);\n\n const value = useMemo(() => ({ quote, setQuote, clearQuote }), [quote, setQuote, clearQuote]);\n\n return (\n <QuoteCtx.Provider value={value}>\n {children}\n </QuoteCtx.Provider>\n );\n}\n\nexport function useQuote(): QuoteContextValue {\n const ctx = useContext(QuoteCtx);\n if (!ctx) {\n throw new Error('[AthenaSDK] useQuote must be used within <QuoteProvider>');\n }\n return ctx;\n}\n\n/**\n * Whether a message came from a frame embedded directly in this window, for\n * any origin: the window of one of this document's iframes (an identity\n * comparison, safe cross-origin), or, for a frame inside a shadow root, a\n * window whose `parent` is this window (`parent` is readable on a\n * cross-origin window). A message port, a worker, this window itself, a\n * grandchild frame or an unrelated window is refused.\n */\nexport function isDirectChildFrame(source: MessageEventSource | null): boolean {\n if (!source || source === window) return false;\n for (const frame of document.querySelectorAll('iframe')) {\n if (frame.contentWindow === source) return true;\n }\n try {\n return Reflect.get(source, 'parent') === window;\n } catch {\n return false;\n }\n}\n\n/**\n * Listens for:\n * 1. Cmd+L / Ctrl+L keydown — grabs the current text selection and sets it as a quote.\n * `preventDefault` stops the browser from focusing the URL bar.\n * 2. PostMessage events from child iframes (asset panels, embedded content)\n * with type `athena-add-to-composer`, only from a frame embedded directly\n * in this window ({@link isDirectChildFrame}).\n *\n * Mount this once inside AthenaProvider.\n */\nexport function useQuoteFromPostMessage() {\n const { setQuote } = useQuote();\n\n useEffect(() => {\n // ── Cmd+L / Ctrl+L keyboard handler ──────────────────────────────\n const handleKeydown = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'l') {\n const sel = window.getSelection();\n const selection = sel?.toString()?.trim();\n\n if (selection && selection.length > 0) {\n e.preventDefault();\n\n // Walk up from the selection anchor to find the message container.\n // assistant-ui message roots have data-role=\"assistant\" or data-role=\"user\".\n let messageId: string | undefined;\n let role: string | undefined;\n let node = sel?.anchorNode as HTMLElement | null;\n while (node && node !== document.body) {\n if (node instanceof HTMLElement) {\n const dataRole = node.getAttribute('data-role');\n if (dataRole === 'assistant' || dataRole === 'user') {\n role = dataRole;\n // assistant-ui sets data-message-id on message roots\n messageId = node.getAttribute('data-message-id') ?? undefined;\n break;\n }\n }\n node = node.parentElement;\n }\n\n setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });\n }\n }\n };\n\n // ── PostMessage handler (from iframes) ───────────────────────────\n // Accepts messages from any origin, but only from a frame embedded\n // directly in this window: the SDK consumer controls which iframes are\n // embedded, and that is the trust boundary. A popup, an opener or another\n // tab holding a reference to this window cannot stage composer text.\n const handleMessage = (event: MessageEvent) => {\n const data = event.data;\n if (\n data &&\n typeof data === 'object' &&\n data.type === 'athena-add-to-composer' &&\n typeof data.text === 'string' &&\n data.text.trim().length > 0 &&\n isDirectChildFrame(event.source)\n ) {\n setQuote({\n text: data.text,\n sourceTitle: data.sourceTitle,\n sourceAssetId: data.sourceAssetId,\n });\n }\n };\n\n document.addEventListener('keydown', handleKeydown, true); // capture phase to beat the browser\n window.addEventListener('message', handleMessage);\n\n return () => {\n document.removeEventListener('keydown', handleKeydown, true);\n window.removeEventListener('message', handleMessage);\n };\n }, [setQuote]);\n}\n"],"names":[],"mappings":";;AAqBA,MAAM,WAAW,cAAwC,IAAI;AAEtD,SAAS,cAAc,EAAE,YAAqC;AACnE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA2B,IAAI;AACzD,QAAM,aAAa,YAAY,MAAM,SAAS,IAAI,GAAG,CAAA,CAAE;AAEvD,QAAM,QAAQ,QAAQ,OAAO,EAAE,OAAO,UAAU,WAAA,IAAe,CAAC,OAAO,UAAU,UAAU,CAAC;AAE5F,SACE,oBAAC,SAAS,UAAT,EAAkB,OAChB,SAAA,CACH;AAEJ;AAEO,SAAS,WAA8B;AAC5C,QAAM,MAAM,WAAW,QAAQ;AAC/B,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5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AAa,KAAK;AAAA,UAClB,eAAe,KAAK;AAAA,QAAA,CACrB;AAAA,MACH;AAAA,IACF;AAEA,aAAS,iBAAiB,WAAW,eAAe,IAAI;AACxD,WAAO,iBAAiB,WAAW,aAAa;AAEhD,WAAO,MAAM;AACX,eAAS,oBAAoB,WAAW,eAAe,IAAI;AAC3D,aAAO,oBAAoB,WAAW,aAAa;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACf;"}
|
|
1
|
+
{"version":3,"file":"QuoteContext.js","sources":["../../src/composer/QuoteContext.tsx"],"sourcesContent":["import {\n createContext,\n type RefObject,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\nimport { useStore } from 'zustand';\nimport { createStore, type StoreApi } from 'zustand/vanilla';\n\nexport interface QuoteData {\n /** The selected/quoted text. */\n text: string;\n /** Title of the source (e.g., asset title, document name). */\n sourceTitle?: string;\n /** Asset ID of the source (for attribution). */\n sourceAssetId?: string;\n /** Message ID of the source message (when quoting from chat). */\n sourceMessageId?: string;\n /** Role of the source message ('assistant' | 'user'). */\n sourceRole?: string;\n}\n\ninterface QuoteContextValue {\n quote: QuoteData | null;\n setQuote: (quote: QuoteData | null) => void;\n clearQuote: () => void;\n}\n\nconst QuoteCtx = createContext<QuoteContextValue | null>(null);\n\ninterface QuoteStoreState {\n quote: QuoteData | null;\n}\n\n/**\n * A composer's pending quote, kept outside React (`createQuoteStore`), like\n * `AttachmentStore`: one per chat when a host shows several.\n */\nexport type QuoteStore = StoreApi<QuoteStoreState>;\n\n/** An empty `QuoteStore`, for `<QuoteProvider store>`. */\nexport function createQuoteStore(): QuoteStore {\n return createStore<QuoteStoreState>(() => ({ quote: null }));\n}\n\n/**\n * The composer's pending quote. Like \\`AttachmentProvider\\`, a `store` makes\n * it that store's, and without one it reuses a provider already mounted\n * above, so a host can keep the quote across a remounting \\`AthenaChat\\`.\n */\nexport function QuoteProvider({ children, store }: { children: ReactNode; store?: QuoteStore }) {\n const outer = useContext(QuoteCtx);\n if (store) return <StoreQuoteProvider store={store}>{children}</StoreQuoteProvider>;\n if (outer) return <>{children}</>;\n return <OwnQuoteProvider>{children}</OwnQuoteProvider>;\n}\n\nfunction OwnQuoteProvider({ children }: { children: ReactNode }) {\n const [store] = useState(createQuoteStore);\n return <StoreQuoteProvider store={store}>{children}</StoreQuoteProvider>;\n}\n\nfunction StoreQuoteProvider({ children, store }: { children: ReactNode; store: QuoteStore }) {\n const quote = useStore(store, (state) => state.quote);\n const actions = useMemo(\n () => ({\n setQuote: (next: QuoteData | null) => store.setState({ quote: next }),\n clearQuote: () => store.setState({ quote: null }),\n }),\n [store],\n );\n const value = useMemo(() => ({ quote, ...actions }), [quote, actions]);\n\n return (\n <QuoteCtx.Provider value={value}>\n {children}\n </QuoteCtx.Provider>\n );\n}\n\nexport function useQuote(): QuoteContextValue {\n const ctx = useContext(QuoteCtx);\n if (!ctx) {\n throw new Error('[AthenaSDK] useQuote must be used within <QuoteProvider>');\n }\n return ctx;\n}\n\n/**\n * Whether a message came from a frame embedded directly in this window, for\n * any origin: the window of one of this document's iframes (an identity\n * comparison, safe cross-origin), or, for a frame inside a shadow root, a\n * window whose `parent` is this window (`parent` is readable on a\n * cross-origin window). A message port, a worker, this window itself, a\n * grandchild frame or an unrelated window is refused. `win` is the window the\n * message came to (default: this one), e.g. a popped-out chat's.\n */\nexport function isDirectChildFrame(\n source: MessageEventSource | null,\n win: Window = window,\n): boolean {\n if (!source || source === win) return false;\n for (const frame of win.document.querySelectorAll('iframe')) {\n if (frame.contentWindow === source) return true;\n }\n try {\n return Reflect.get(source, 'parent') === win;\n } catch {\n return false;\n }\n}\n\n/** `AthenaChat`'s thread root: the chats `useQuoteFromPostMessage` tells apart. */\nconst CHAT_ROOT_SELECTOR = '.aui-thread-root';\n\n/**\n * The chat the person last focused in each window, which takes a quote that\n * names no chat (a selection outside every chat, an embedded frame's text)\n * when that window shows several. A focus, not data: no state of the chats\n * themselves.\n */\nconst lastFocusedChatRoots = new WeakMap<Document, Element>();\n\n/** The element a node is, or sits in; duck-typed, since a pop-out window's nodes are another realm's. */\nfunction elementOf(node: Node | null | undefined): Element | null {\n if (!node) return null;\n return node.nodeType === 1 ? (node as Element) : node.parentElement;\n}\n\nexport interface QuoteFromPostMessageOptions {\n /**\n * An element inside the chat this composer belongs to. With several chats in\n * one window, a ⌘L selection goes to the chat it was made in, and one made\n * outside every chat (or an embedded frame's text) to the chat the person\n * last focused; the keys and an embedded frame's messages are heard in this\n * element's own window, a pop-out included. Without it, every quote is this\n * composer's, as before.\n */\n scope?: RefObject<Element | null>;\n}\n\n/**\n * Listens for:\n * 1. Cmd+L / Ctrl+L keydown — grabs the current text selection and sets it as a quote.\n * `preventDefault` stops the browser from focusing the URL bar.\n * 2. PostMessage events from child iframes (asset panels, embedded content)\n * with type `athena-add-to-composer`, only from a frame embedded directly\n * in this window ({@link isDirectChildFrame}).\n *\n * Mount this once per composer inside AthenaProvider (`AthenaChat` does).\n */\nexport function useQuoteFromPostMessage({ scope }: QuoteFromPostMessageOptions = {}) {\n const { setQuote } = useQuote();\n\n useEffect(() => {\n const doc = scope?.current?.ownerDocument ?? document;\n const win = doc.defaultView ?? window;\n const chatRoot = () => scope?.current?.closest(CHAT_ROOT_SELECTOR) ?? null;\n // Whether this composer takes a quote made at `anchor` (null: one that names no chat).\n const takes = (anchor: Node | null) => {\n const mine = chatRoot();\n if (!mine) return true;\n const owner = elementOf(anchor)?.closest(CHAT_ROOT_SELECTOR) ?? null;\n if (owner) return owner === mine;\n const remembered = lastFocusedChatRoots.get(doc);\n const focused = remembered?.isConnected ? remembered : doc.querySelector(CHAT_ROOT_SELECTOR);\n return focused === mine;\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const mine = chatRoot();\n const target = event.target as Node | null;\n if (mine && target && typeof target.nodeType === 'number' && mine.contains(target)) {\n lastFocusedChatRoots.set(doc, mine);\n }\n };\n\n // ── Cmd+L / Ctrl+L keyboard handler ──────────────────────────────\n const handleKeydown = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'l') {\n const sel = doc.getSelection();\n const selection = sel?.toString()?.trim();\n\n if (selection && selection.length > 0 && takes(sel?.anchorNode ?? null)) {\n e.preventDefault();\n\n // Walk up from the selection anchor to find the message container.\n // assistant-ui message roots have data-role=\"assistant\" or data-role=\"user\".\n let messageId: string | undefined;\n let role: string | undefined;\n let node = elementOf(sel?.anchorNode);\n while (node && node !== doc.body) {\n const dataRole = node.getAttribute('data-role');\n if (dataRole === 'assistant' || dataRole === 'user') {\n role = dataRole;\n // assistant-ui sets data-message-id on message roots\n messageId = node.getAttribute('data-message-id') ?? undefined;\n break;\n }\n node = node.parentElement;\n }\n\n setQuote({ text: selection, sourceRole: role, sourceMessageId: messageId });\n }\n }\n };\n\n // ── PostMessage handler (from iframes) ───────────────────────────\n // Accepts messages from any origin, but only from a frame embedded\n // directly in this window: the SDK consumer controls which iframes are\n // embedded, and that is the trust boundary. A popup, an opener or another\n // tab holding a reference to this window cannot stage composer text.\n const handleMessage = (event: MessageEvent) => {\n const data = event.data;\n if (\n data &&\n typeof data === 'object' &&\n data.type === 'athena-add-to-composer' &&\n typeof data.text === 'string' &&\n data.text.trim().length > 0 &&\n isDirectChildFrame(event.source, win) &&\n takes(null)\n ) {\n setQuote({\n text: data.text,\n sourceTitle: data.sourceTitle,\n sourceAssetId: data.sourceAssetId,\n });\n }\n };\n\n doc.addEventListener('keydown', handleKeydown, true); // capture phase to beat the browser\n doc.addEventListener('focusin', handleFocusIn, true);\n win.addEventListener('message', handleMessage);\n\n return () => {\n doc.removeEventListener('keydown', handleKeydown, true);\n doc.removeEventListener('focusin', handleFocusIn, true);\n win.removeEventListener('message', handleMessage);\n };\n }, [scope, setQuote]);\n}\n"],"names":["_a"],"mappings":";;;;AA+BA,MAAM,WAAW,cAAwC,IAAI;AAatD,SAAS,mBAA+B;AAC7C,SAAO,YAA6B,OAAO,EAAE,OAAO,OAAO;AAC7D;A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cAAI;AACJ,cAAI;AACJ,cAAI,OAAO,UAAU,2BAAK,UAAU;AACpC,iBAAO,QAAQ,SAAS,IAAI,MAAM;AAChC,kBAAM,WAAW,KAAK,aAAa,WAAW;AAC9C,gBAAI,aAAa,eAAe,aAAa,QAAQ;AACnD,qBAAO;AAEP,0BAAY,KAAK,aAAa,iBAAiB,KAAK;AACpD;AAAA,YACF;AACA,mBAAO,KAAK;AAAA,UACd;AAEA,mBAAS,EAAE,MAAM,WAAW,YAAY,MAAM,iBAAiB,WAAW;AAAA,QAC5E;AAAA,MACF;AAAA,IACF;AAOA,UAAM,gBAAgB,CAAC,UAAwB;AAC7C,YAAM,OAAO,MAAM;AACnB,UACE,QACA,OAAO,SAAS,YAChB,KAAK,SAAS,4BACd,OAAO,KAAK,SAAS,YACrB,KAAK,KAAK,KAAA,EAAO,SAAS,KAC1B,mBAAmB,MAAM,QAAQ,GAAG,KACpC,MAAM,IAAI,GACV;AACA,iBAAS;AAAA,UACP,MAAM,KAAK;AAAA,UACX,aAAa,KAAK;AAAA,UAClB,eAAe,KAAK;AAAA,QAAA,CACrB;AAAA,MACH;AAAA,IACF;AAEA,QAAI,iBAAiB,WAAW,eAAe,IAAI;AACnD,QAAI,iBAAiB,WAAW,eAAe,IAAI;AACnD,QAAI,iBAAiB,WAAW,aAAa;AAE7C,WAAO,MAAM;AACX,UAAI,oBAAoB,WAAW,eAAe,IAAI;AACtD,UAAI,oBAAoB,WAAW,eAAe,IAAI;AACtD,UAAI,oBAAoB,WAAW,aAAa;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,OAAO,QAAQ,CAAC;AACtB;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const AttachmentContext = require("./AttachmentContext.cjs");
|
|
4
|
+
const composerMessage = require("../chat-ui/composer/composer-message.cjs");
|
|
4
5
|
function buildComposedMessage(opts) {
|
|
5
6
|
var _a;
|
|
6
7
|
const parts = [];
|
|
@@ -21,5 +22,31 @@ ${quotedLines}`);
|
|
|
21
22
|
if (trimmed) parts.push(trimmed);
|
|
22
23
|
return parts.join("\n\n");
|
|
23
24
|
}
|
|
25
|
+
function buildComposedSend({
|
|
26
|
+
attachments,
|
|
27
|
+
quote,
|
|
28
|
+
send,
|
|
29
|
+
appUrl
|
|
30
|
+
}) {
|
|
31
|
+
const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });
|
|
32
|
+
if (!text) return null;
|
|
33
|
+
const draftMarkdown = buildComposedMessage({
|
|
34
|
+
attachments: attachments == null ? void 0 : attachments.map((attachment) => ({
|
|
35
|
+
...attachment,
|
|
36
|
+
title: composerMessage.escapeCharacterReferences(attachment.title)
|
|
37
|
+
})),
|
|
38
|
+
quote: quote && {
|
|
39
|
+
...quote,
|
|
40
|
+
text: composerMessage.escapeCharacterReferences(quote.text),
|
|
41
|
+
...quote.sourceTitle !== void 0 && {
|
|
42
|
+
sourceTitle: composerMessage.escapeCharacterReferences(quote.sourceTitle)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
userText: send.draftMarkdown,
|
|
46
|
+
appUrl
|
|
47
|
+
});
|
|
48
|
+
return { text, draftMarkdown };
|
|
49
|
+
}
|
|
24
50
|
exports.buildComposedMessage = buildComposedMessage;
|
|
51
|
+
exports.buildComposedSend = buildComposedSend;
|
|
25
52
|
//# sourceMappingURL=build-composed-message.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-composed-message.cjs","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n"],"names":["buildAttachmentMarkdownWithAppUrl"],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-composed-message.cjs","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `<` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n"],"names":["buildAttachmentMarkdownWithAppUrl","escapeCharacterReferences"],"mappings":";;;;AAeO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAeA,kBAAAA,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAAA,EAAM,WAAW,EAAE;AAAA,EAC9C;AAEA,QAAM,WAAU,UAAK,aAAL,mBAAe;AAC/B,MAAI,QAAS,OAAM,KAAK,OAAO;AAE/B,SAAO,MAAM,KAAK,MAAM;AAC1B;AAgBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKwB;AACtB,QAAM,OAAO,qBAAqB,EAAE,aAAa,OAAO,UAAU,KAAK,MAAM,QAAQ;AACrF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,gBAAgB,qBAAqB;AAAA,IACzC,aAAa,2CAAa,IAAI,CAAC,gBAAgB;AAAA,MAC7C,GAAG;AAAA,MACH,OAAOC,gBAAAA,0BAA0B,WAAW,KAAK;AAAA,IAAA;AAAA,IAEnD,OAAO,SAAS;AAAA,MACd,GAAG;AAAA,MACH,MAAMA,gBAAAA,0BAA0B,MAAM,IAAI;AAAA,MAC1C,GAAI,MAAM,gBAAgB,UAAa;AAAA,QACrC,aAAaA,gBAAAA,0BAA0B,MAAM,WAAW;AAAA,MAAA;AAAA,IAC1D;AAAA,IAEF,UAAU,KAAK;AAAA,IACf;AAAA,EAAA,CACD;AACD,SAAO,EAAE,MAAM,cAAA;AACjB;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UploadedAsset } from './useFileUpload';
|
|
2
2
|
import type { QuoteData } from './QuoteContext';
|
|
3
|
+
import { type ComposerSend } from '../chat-ui/composer/composer-message';
|
|
3
4
|
/**
|
|
4
5
|
* Assembles a composed message from attachments, a quote, and user text.
|
|
5
6
|
* Used by both the TipTap Enter-key submit and the send-button click handler
|
|
@@ -13,3 +14,23 @@ export declare function buildComposedMessage(opts: {
|
|
|
13
14
|
userText?: string;
|
|
14
15
|
appUrl?: string;
|
|
15
16
|
}): string;
|
|
17
|
+
/**
|
|
18
|
+
* The composed message a send delivers and the draft it came from: the same
|
|
19
|
+
* attachments and quote around the editor's text as typed in one, and around
|
|
20
|
+
* the editor's draft in the other (`ComposerSend`). `null` when there is
|
|
21
|
+
* nothing to send.
|
|
22
|
+
*
|
|
23
|
+
* The quote and the attachment titles are text the person did not type in
|
|
24
|
+
* the editor, and the message carries them as they are. The draft writes an
|
|
25
|
+
* `&` in them that starts a character reference as `&`, as the composer's
|
|
26
|
+
* draft does for typed text, so it reads back as the message and stays a draft
|
|
27
|
+
* of the message's own text (`isComposerMarkdownOfText`, which agora applies
|
|
28
|
+
* too): a quoted `<` would otherwise read as `<` in the draft and the
|
|
29
|
+
* message would lose its composer markdown.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildComposedSend({ attachments, quote, send, appUrl, }: {
|
|
32
|
+
attachments?: UploadedAsset[];
|
|
33
|
+
quote?: QuoteData | null;
|
|
34
|
+
send: ComposerSend;
|
|
35
|
+
appUrl?: string;
|
|
36
|
+
}): ComposerSend | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildAttachmentMarkdownWithAppUrl } from "./AttachmentContext.js";
|
|
2
|
+
import { escapeCharacterReferences } from "../chat-ui/composer/composer-message.js";
|
|
2
3
|
function buildComposedMessage(opts) {
|
|
3
4
|
var _a;
|
|
4
5
|
const parts = [];
|
|
@@ -19,7 +20,33 @@ ${quotedLines}`);
|
|
|
19
20
|
if (trimmed) parts.push(trimmed);
|
|
20
21
|
return parts.join("\n\n");
|
|
21
22
|
}
|
|
23
|
+
function buildComposedSend({
|
|
24
|
+
attachments,
|
|
25
|
+
quote,
|
|
26
|
+
send,
|
|
27
|
+
appUrl
|
|
28
|
+
}) {
|
|
29
|
+
const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });
|
|
30
|
+
if (!text) return null;
|
|
31
|
+
const draftMarkdown = buildComposedMessage({
|
|
32
|
+
attachments: attachments == null ? void 0 : attachments.map((attachment) => ({
|
|
33
|
+
...attachment,
|
|
34
|
+
title: escapeCharacterReferences(attachment.title)
|
|
35
|
+
})),
|
|
36
|
+
quote: quote && {
|
|
37
|
+
...quote,
|
|
38
|
+
text: escapeCharacterReferences(quote.text),
|
|
39
|
+
...quote.sourceTitle !== void 0 && {
|
|
40
|
+
sourceTitle: escapeCharacterReferences(quote.sourceTitle)
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
userText: send.draftMarkdown,
|
|
44
|
+
appUrl
|
|
45
|
+
});
|
|
46
|
+
return { text, draftMarkdown };
|
|
47
|
+
}
|
|
22
48
|
export {
|
|
23
|
-
buildComposedMessage
|
|
49
|
+
buildComposedMessage,
|
|
50
|
+
buildComposedSend
|
|
24
51
|
};
|
|
25
52
|
//# sourceMappingURL=build-composed-message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-composed-message.js","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-composed-message.js","sources":["../../src/composer/build-composed-message.ts"],"sourcesContent":["import type { UploadedAsset } from './useFileUpload';\nimport type { QuoteData } from './QuoteContext';\nimport { buildAttachmentMarkdownWithAppUrl } from './AttachmentContext';\nimport {\n type ComposerSend,\n escapeCharacterReferences,\n} from '../chat-ui/composer/composer-message';\n\n/**\n * Assembles a composed message from attachments, a quote, and user text.\n * Used by both the TipTap Enter-key submit and the send-button click handler\n * to avoid duplicating the message-assembly logic.\n *\n * Returns an empty string if all inputs are empty.\n */\nexport function buildComposedMessage(opts: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n userText?: string;\n appUrl?: string;\n}): string {\n const parts: string[] = [];\n\n if (opts.attachments && opts.attachments.length > 0) {\n const attachmentMd = buildAttachmentMarkdownWithAppUrl({\n attachments: opts.attachments,\n appUrl: opts.appUrl,\n });\n if (attachmentMd) parts.push(attachmentMd);\n }\n\n if (opts.quote) {\n const quotedLines = opts.quote.text.split('\\n').map((l) => `> ${l}`).join('\\n');\n const sourceLabel = opts.quote.sourceTitle\n ? `From \"${opts.quote.sourceTitle}\"`\n : opts.quote.sourceRole === 'assistant'\n ? 'Quoting assistant'\n : 'Quoting';\n parts.push(`${sourceLabel}:\\n${quotedLines}`);\n }\n\n const trimmed = opts.userText?.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts.join('\\n\\n');\n}\n\n/**\n * The composed message a send delivers and the draft it came from: the same\n * attachments and quote around the editor's text as typed in one, and around\n * the editor's draft in the other (`ComposerSend`). `null` when there is\n * nothing to send.\n *\n * The quote and the attachment titles are text the person did not type in\n * the editor, and the message carries them as they are. The draft writes an\n * `&` in them that starts a character reference as `&`, as the composer's\n * draft does for typed text, so it reads back as the message and stays a draft\n * of the message's own text (`isComposerMarkdownOfText`, which agora applies\n * too): a quoted `<` would otherwise read as `<` in the draft and the\n * message would lose its composer markdown.\n */\nexport function buildComposedSend({\n attachments,\n quote,\n send,\n appUrl,\n}: {\n attachments?: UploadedAsset[];\n quote?: QuoteData | null;\n send: ComposerSend;\n appUrl?: string;\n}): ComposerSend | null {\n const text = buildComposedMessage({ attachments, quote, userText: send.text, appUrl });\n if (!text) return null;\n const draftMarkdown = buildComposedMessage({\n attachments: attachments?.map((attachment) => ({\n ...attachment,\n title: escapeCharacterReferences(attachment.title),\n })),\n quote: quote && {\n ...quote,\n text: escapeCharacterReferences(quote.text),\n ...(quote.sourceTitle !== undefined && {\n sourceTitle: escapeCharacterReferences(quote.sourceTitle),\n }),\n },\n userText: send.draftMarkdown,\n appUrl,\n });\n return { text, draftMarkdown };\n}\n"],"names":[],"mappings":";;AAeO,SAAS,qBAAqB,MAK1B;;AACT,QAAM,QAAkB,CAAA;AAExB,MAAI,KAAK,eAAe,KAAK,YAAY,SAAS,GAAG;AACnD,UAAM,eAAe,kCAAkC;AAAA,MACrD,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,QAAI,aAAc,OAAM,KAAK,YAAY;AAAA,EAC3C;AAEA,MAAI,KAAK,OAAO;AACd,UAAM,cAAc,KAAK,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI;AAC9E,UAAM,cAAc,KAAK,MAAM,cAC3B,SAAS,KAAK,MAAM,WAAW,MAC/B,KAAK,MAAM,eAAe,cACxB,sBACA;AACN,UAAM,KAAK,GAAG,WAAW;AAAA,EAAM,WAAW,EAAE;AAAA,EAC9C;AAEA,QAAM,WAAU,UAAK,aAAL,mBAAe;AAC/B,MAAI,QAAS,OAAM,KAAK,OAAO;AAE/B,SAAO,MAAM,KAAK,MAAM;AAC1B;AAgBO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKwB;AACtB,QAAM,OAAO,qBAAqB,EAAE,aAAa,OAAO,UAAU,KAAK,MAAM,QAAQ;AACrF,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,gBAAgB,qBAAqB;AAAA,IACzC,aAAa,2CAAa,IAAI,CAAC,gBAAgB;AAAA,MAC7C,GAAG;AAAA,MACH,OAAO,0BAA0B,WAAW,KAAK;AAAA,IAAA;AAAA,IAEnD,OAAO,SAAS;AAAA,MACd,GAAG;AAAA,MACH,MAAM,0BAA0B,MAAM,IAAI;AAAA,MAC1C,GAAI,MAAM,gBAAgB,UAAa;AAAA,QACrC,aAAa,0BAA0B,MAAM,WAAW;AAAA,MAAA;AAAA,IAC1D;AAAA,IAEF,UAAU,KAAK;AAAA,IACf;AAAA,EAAA,CACD;AACD,SAAO,EAAE,MAAM,cAAA;AACjB;"}
|
|
@@ -6,12 +6,22 @@ const athenaDiagnostics = require("../diagnostics/athena-diagnostics.cjs");
|
|
|
6
6
|
const errors = require("../diagnostics/errors.cjs");
|
|
7
7
|
const statewireThreadList = require("../threads/statewire-thread-list.cjs");
|
|
8
8
|
function createComposerHandoffStore() {
|
|
9
|
-
return { pending: [], focusOnNextMirror: false, focusEnd: null };
|
|
9
|
+
return { pending: [], focusOnNextMirror: false, focusEnd: null, focusOnMount: false };
|
|
10
10
|
}
|
|
11
11
|
const ComposerHandoffContext = react$1.createContext(null);
|
|
12
12
|
function useComposerHandoffStore() {
|
|
13
13
|
return react$1.useContext(ComposerHandoffContext);
|
|
14
14
|
}
|
|
15
|
+
function useFocusComposer() {
|
|
16
|
+
const store = useComposerHandoffStore();
|
|
17
|
+
return react$1.useCallback(() => {
|
|
18
|
+
if (store) focusComposer({ store });
|
|
19
|
+
}, [store]);
|
|
20
|
+
}
|
|
21
|
+
function focusComposer({ store }) {
|
|
22
|
+
if (store.focusEnd) store.focusEnd();
|
|
23
|
+
else store.focusOnMount = true;
|
|
24
|
+
}
|
|
15
25
|
function useComposerReady() {
|
|
16
26
|
const list = statewireThreadList.useAthenaStatewireThreadList();
|
|
17
27
|
const threadLoading = react.useAuiState((s) => {
|
|
@@ -114,8 +124,10 @@ exports.applyComposerWrite = applyComposerWrite;
|
|
|
114
124
|
exports.clearComposerHandoff = clearComposerHandoff;
|
|
115
125
|
exports.createComposerHandoffStore = createComposerHandoffStore;
|
|
116
126
|
exports.drainComposerHandoff = drainComposerHandoff;
|
|
127
|
+
exports.focusComposer = focusComposer;
|
|
117
128
|
exports.mergeComposerDraft = mergeComposerDraft;
|
|
118
129
|
exports.queueComposerWrite = queueComposerWrite;
|
|
119
130
|
exports.useComposerHandoffStore = useComposerHandoffStore;
|
|
120
131
|
exports.useComposerReady = useComposerReady;
|
|
132
|
+
exports.useFocusComposer = useFocusComposer;
|
|
121
133
|
//# sourceMappingURL=composer-handoff.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-handoff.cjs","sources":["../../src/composer/composer-handoff.ts"],"sourcesContent":["/**\n * Composer handoff: writes to the chat composer from host UI that lives\n * outside `<AthenaChat>` (a sidebar, an agenda card, a workflow button).\n *\n * Two problems it solves for `useAppendToComposer` / `useSendMessage`:\n *\n * 1. A write before the chat is ready is lost. While the thread list is still\n * resolving the active thread, or the thread's history is still loading,\n * the composer the hooks write to belongs to a mount that is about to be\n * replaced (thread-list mode keys the statewire subtree by thread), and\n * the draft goes with it. The store below lives ABOVE that mount, so a\n * write made too early waits here and the ready mount drains it.\n * 2. A prefilled draft should put the caret after the text so the user can\n * keep typing or dictating. The Tiptap editor mirrors runtime text on a\n * later tick; the `focusOnNextMirror` flag asks it to focus at the end\n * right after that mirror lands, instead of the host guessing a delay.\n *\n * Every queued write is bound to the statewire thread it was made for and\n * drains only into that thread's mount; a thread switch, an identity change\n * or a provider unmount drops what waits with a `composer_write_dropped`\n * error, never into another user's or another thread's composer.\n */\nimport { createContext, useContext } from 'react';\nimport { useAuiState } from '@assistant-ui/react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaStatewireThreadList } from '../threads/statewire-thread-list';\n\n/** The slice of the assistant-ui client the handoff writes to. */\nexport interface ComposerTarget {\n composer: {\n getState: () => { text: string };\n setText: (text: string) => void;\n send: (options?: { steer?: boolean }) => unknown;\n };\n}\n\nexport interface ComposerWrite {\n text: string;\n /** Replace the draft instead of appending on a new line. */\n replace: boolean;\n /** Submit right after writing. */\n send: boolean;\n /** Put the caret at the end of the draft once the editor shows it. */\n focus: boolean;\n /** The statewire thread the write was made for; it drains only into that thread's mount. */\n threadId: string | null;\n /** Settled once the write has been applied (and, for `send`, with the send's outcome). */\n resolve?: (outcome: Promise<void> | void) => void;\n /** Settled with `composer_write_dropped` when the write can no longer land. */\n reject?: (error: AthenaSdkError) => void;\n}\n\nexport interface ComposerHandoffStore {\n /** Writes waiting for a ready composer, oldest first. Adjacent plain appends fold together. */\n pending: ComposerWrite[];\n /** Set by a `focus` write; the editor consumes it after mirroring the draft. */\n focusOnNextMirror: boolean;\n /** Registered by the mounted editor: place the caret at the end of the draft. */\n focusEnd: (() => void) | null;\n}\n\nexport function createComposerHandoffStore(): ComposerHandoffStore {\n return { pending: [], focusOnNextMirror: false, focusEnd: null };\n}\n\nexport const ComposerHandoffContext = createContext<ComposerHandoffStore | null>(null);\n\n/** The provider's handoff store, or null outside `AthenaProvider`. */\nexport function useComposerHandoffStore(): ComposerHandoffStore | null {\n return useContext(ComposerHandoffContext);\n}\n\n/**\n * Whether a composer write lands now: in thread-list mode the list has\n * resolved which thread is active, and that thread's history has loaded.\n * Until then the composer the hooks write to is the one of a mount that is\n * about to be replaced, and the draft goes with it.\n *\n * Deliberately not the socket status: a never-started chat sits in\n * `standby` until its first send and must still take a prefill.\n */\nexport function useComposerReady(): boolean {\n const list = useAthenaStatewireThreadList();\n const threadLoading = useAuiState((s) => s.optional.thread?.isLoading ?? false);\n return !(list?.isLoading ?? false) && !threadLoading;\n}\n\n/** The draft after `write`: `replace` (or an empty draft) takes the text as is. */\nexport function mergeComposerDraft({\n current,\n write,\n}: {\n current: string;\n write: Pick<ComposerWrite, 'text' | 'replace'>;\n}): string {\n if (write.replace || !current) return write.text;\n return `${current}\\n${write.text}`;\n}\n\n/**\n * Write into the live composer. Returns the send's outcome for a `send`\n * write so callers can await it.\n */\nexport function applyComposerWrite({\n target,\n store,\n write,\n}: {\n target: ComposerTarget;\n store: ComposerHandoffStore | null;\n write: ComposerWrite;\n}): Promise<void> | void {\n const current = target.composer.getState().text ?? '';\n const next = mergeComposerDraft({ current, write });\n target.composer.setText(next);\n if (write.focus && store) {\n // An unchanged draft never re-mirrors, so focus at once; otherwise the\n // editor focuses itself right after it has shown the new text.\n if (next === current) store.focusEnd?.();\n else store.focusOnNextMirror = true;\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'applied', send: write.send, focus: write.focus, chars: next.length },\n });\n if (write.send) {\n return Promise.resolve(target.composer.send({ steer: false })).then(() => undefined);\n }\n return undefined;\n}\n\n/**\n * Hold a write until the composer is ready. Writes keep their order; a plain\n * append folds into a directly preceding plain append for the same thread\n * (one draft, not two), while a replace or a send is kept as its own step so\n * no message is lost and every send settles on its own.\n */\nexport function queueComposerWrite({\n store,\n write,\n}: {\n store: ComposerHandoffStore;\n write: ComposerWrite;\n}): void {\n const last = store.pending[store.pending.length - 1];\n const foldable =\n last !== undefined &&\n !last.send &&\n !write.send &&\n !write.replace &&\n last.threadId === write.threadId &&\n last.resolve === undefined &&\n write.resolve === undefined;\n if (foldable) {\n last.text = mergeComposerDraft({ current: last.text, write });\n last.focus = last.focus || write.focus;\n } else {\n store.pending.push(write);\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'deferred', send: write.send, focus: write.focus, queued: store.pending.length },\n });\n}\n\nfunction dropWrite({ write, reason }: { write: ComposerWrite; reason: string }): void {\n const error = new AthenaSdkError({\n code: 'composer_write_dropped',\n message: `A composer ${write.send ? 'send' : 'draft'} queued before the chat was ready was dropped: ${reason}.`,\n hint: 'Make the write again from the chat that is active now.',\n context: { threadId: write.threadId, send: write.send },\n });\n athenaDiagnostics.emit('composer.handoff', {\n level: 'warn',\n error,\n data: { phase: 'dropped', send: write.send, reason, threadId: write.threadId },\n });\n write.reject?.(error);\n}\n\n/**\n * Deliver the pending writes, in order, into a now-ready composer. A write\n * made for another thread is dropped (rejected), never applied here.\n */\nexport function drainComposerHandoff({\n store,\n target,\n threadId,\n}: {\n store: ComposerHandoffStore;\n target: ComposerTarget;\n /** The statewire thread of the mount that is draining. */\n threadId: string | null;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) {\n if (write.threadId !== null && threadId !== null && write.threadId !== threadId) {\n dropWrite({ write, reason: `it was made for thread ${write.threadId}, thread ${threadId} is active` });\n continue;\n }\n const outcome = applyComposerWrite({ target, store, write });\n write.resolve?.(outcome);\n }\n}\n\n/** Drop every pending write (identity changed, provider unmounted). */\nexport function clearComposerHandoff({\n store,\n reason,\n}: {\n store: ComposerHandoffStore;\n reason: string;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) dropWrite({ write, reason });\n}\n"],"names":["createContext","useContext","useAthenaStatewireThreadList","useAuiState","athenaDiagnostics","AthenaSdkError"],"mappings":";;;;;;;AA8DO,SAAS,6BAAmD;AACjE,SAAO,EAAE,SAAS,CAAA,GAAI,mBAAmB,OAAO,UAAU,KAAA;AAC5D;AAEO,MAAM,yBAAyBA,QAAAA,cAA2C,IAAI;AAG9E,SAAS,0BAAuD;AACrE,SAAOC,QAAAA,WAAW,sBAAsB;AAC1C;AAWO,SAAS,mBAA4B;AAC1C,QAAM,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AM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,OAAQ,WAAU,EAAE,OAAO,QAAQ;AACzD;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"composer-handoff.cjs","sources":["../../src/composer/composer-handoff.ts"],"sourcesContent":["/**\n * Composer handoff: writes to the chat composer from host UI that lives\n * outside `<AthenaChat>` (a sidebar, an agenda card, a workflow button).\n *\n * Two problems it solves for `useAppendToComposer` / `useSendMessage`:\n *\n * 1. A write before the chat is ready is lost. While the thread list is still\n * resolving the active thread, or the thread's history is still loading,\n * the composer the hooks write to belongs to a mount that is about to be\n * replaced (thread-list mode keys the statewire subtree by thread), and\n * the draft goes with it. The store below lives ABOVE that mount, so a\n * write made too early waits here and the ready mount drains it.\n * 2. A prefilled draft should put the caret after the text so the user can\n * keep typing or dictating. The Tiptap editor mirrors runtime text on a\n * later tick; the `focusOnNextMirror` flag asks it to focus at the end\n * right after that mirror lands, instead of the host guessing a delay.\n *\n * Every queued write is bound to the statewire thread it was made for and\n * drains only into that thread's mount; a thread switch, an identity change\n * or a provider unmount drops what waits with a `composer_write_dropped`\n * error, never into another user's or another thread's composer.\n */\nimport { createContext, useCallback, useContext } from 'react';\nimport { useAuiState } from '@assistant-ui/react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport { AthenaSdkError } from '../diagnostics/errors';\nimport { useAthenaStatewireThreadList } from '../threads/statewire-thread-list';\n\n/** The slice of the assistant-ui client the handoff writes to. */\nexport interface ComposerTarget {\n composer: {\n getState: () => { text: string };\n setText: (text: string) => void;\n send: (options?: { steer?: boolean }) => unknown;\n };\n}\n\nexport interface ComposerWrite {\n text: string;\n /** Replace the draft instead of appending on a new line. */\n replace: boolean;\n /** Submit right after writing. */\n send: boolean;\n /** Put the caret at the end of the draft once the editor shows it. */\n focus: boolean;\n /** The statewire thread the write was made for; it drains only into that thread's mount. */\n threadId: string | null;\n /** Settled once the write has been applied (and, for `send`, with the send's outcome). */\n resolve?: (outcome: Promise<void> | void) => void;\n /** Settled with `composer_write_dropped` when the write can no longer land. */\n reject?: (error: AthenaSdkError) => void;\n}\n\nexport interface ComposerHandoffStore {\n /** Writes waiting for a ready composer, oldest first. Adjacent plain appends fold together. */\n pending: ComposerWrite[];\n /** Set by a `focus` write; the editor consumes it after mirroring the draft. */\n focusOnNextMirror: boolean;\n /** Registered by the mounted editor: place the caret at the end of the draft. */\n focusEnd: (() => void) | null;\n /** Set by `useFocusComposer` before the editor mounted; the editor consumes it when it does. */\n focusOnMount: boolean;\n}\n\nexport function createComposerHandoffStore(): ComposerHandoffStore {\n return { pending: [], focusOnNextMirror: false, focusEnd: null, focusOnMount: false };\n}\n\nexport const ComposerHandoffContext = createContext<ComposerHandoffStore | null>(null);\n\n/** The provider's handoff store, or null outside `AthenaProvider`. */\nexport function useComposerHandoffStore(): ComposerHandoffStore | null {\n return useContext(ComposerHandoffContext);\n}\n\n/**\n * Puts the caret at the end of the composer's draft and leaves the draft as it is; asked before the\n * editor has mounted, it focuses the editor as it mounts. For a host that shows the chat again and\n * wants typing to land in it (a launcher window a shortcut brings back).\n */\nexport function useFocusComposer(): () => void {\n const store = useComposerHandoffStore();\n return useCallback(() => {\n if (store) focusComposer({ store });\n }, [store]);\n}\n\n/** The caret to the end of the draft now, or, with no editor mounted yet, as one mounts. */\nexport function focusComposer({ store }: { store: ComposerHandoffStore }): void {\n if (store.focusEnd) store.focusEnd();\n else store.focusOnMount = true;\n}\n\n/**\n * Whether a composer write lands now: in thread-list mode the list has\n * resolved which thread is active, and that thread's history has loaded.\n * Until then the composer the hooks write to is the one of a mount that is\n * about to be replaced, and the draft goes with it.\n *\n * Deliberately not the socket status: a never-started chat sits in\n * `standby` until its first send and must still take a prefill.\n */\nexport function useComposerReady(): boolean {\n const list = useAthenaStatewireThreadList();\n const threadLoading = useAuiState((s) => s.optional.thread?.isLoading ?? false);\n return !(list?.isLoading ?? false) && !threadLoading;\n}\n\n/** The draft after `write`: `replace` (or an empty draft) takes the text as is. */\nexport function mergeComposerDraft({\n current,\n write,\n}: {\n current: string;\n write: Pick<ComposerWrite, 'text' | 'replace'>;\n}): string {\n if (write.replace || !current) return write.text;\n return `${current}\\n${write.text}`;\n}\n\n/**\n * Write into the live composer. Returns the send's outcome for a `send`\n * write so callers can await it.\n */\nexport function applyComposerWrite({\n target,\n store,\n write,\n}: {\n target: ComposerTarget;\n store: ComposerHandoffStore | null;\n write: ComposerWrite;\n}): Promise<void> | void {\n const current = target.composer.getState().text ?? '';\n const next = mergeComposerDraft({ current, write });\n target.composer.setText(next);\n if (write.focus && store) {\n // An unchanged draft never re-mirrors, so focus at once; otherwise the\n // editor focuses itself right after it has shown the new text.\n if (next === current) store.focusEnd?.();\n else store.focusOnNextMirror = true;\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'applied', send: write.send, focus: write.focus, chars: next.length },\n });\n if (write.send) {\n return Promise.resolve(target.composer.send({ steer: false })).then(() => undefined);\n }\n return undefined;\n}\n\n/**\n * Hold a write until the composer is ready. Writes keep their order; a plain\n * append folds into a directly preceding plain append for the same thread\n * (one draft, not two), while a replace or a send is kept as its own step so\n * no message is lost and every send settles on its own.\n */\nexport function queueComposerWrite({\n store,\n write,\n}: {\n store: ComposerHandoffStore;\n write: ComposerWrite;\n}): void {\n const last = store.pending[store.pending.length - 1];\n const foldable =\n last !== undefined &&\n !last.send &&\n !write.send &&\n !write.replace &&\n last.threadId === write.threadId &&\n last.resolve === undefined &&\n write.resolve === undefined;\n if (foldable) {\n last.text = mergeComposerDraft({ current: last.text, write });\n last.focus = last.focus || write.focus;\n } else {\n store.pending.push(write);\n }\n athenaDiagnostics.emit('composer.handoff', {\n level: 'debug',\n data: { phase: 'deferred', send: write.send, focus: write.focus, queued: store.pending.length },\n });\n}\n\nfunction dropWrite({ write, reason }: { write: ComposerWrite; reason: string }): void {\n const error = new AthenaSdkError({\n code: 'composer_write_dropped',\n message: `A composer ${write.send ? 'send' : 'draft'} queued before the chat was ready was dropped: ${reason}.`,\n hint: 'Make the write again from the chat that is active now.',\n context: { threadId: write.threadId, send: write.send },\n });\n athenaDiagnostics.emit('composer.handoff', {\n level: 'warn',\n error,\n data: { phase: 'dropped', send: write.send, reason, threadId: write.threadId },\n });\n write.reject?.(error);\n}\n\n/**\n * Deliver the pending writes, in order, into a now-ready composer. A write\n * made for another thread is dropped (rejected), never applied here.\n */\nexport function drainComposerHandoff({\n store,\n target,\n threadId,\n}: {\n store: ComposerHandoffStore;\n target: ComposerTarget;\n /** The statewire thread of the mount that is draining. */\n threadId: string | null;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) {\n if (write.threadId !== null && threadId !== null && write.threadId !== threadId) {\n dropWrite({ write, reason: `it was made for thread ${write.threadId}, thread ${threadId} is active` });\n continue;\n }\n const outcome = applyComposerWrite({ target, store, write });\n write.resolve?.(outcome);\n }\n}\n\n/** Drop every pending write (identity changed, provider unmounted). */\nexport function clearComposerHandoff({\n store,\n reason,\n}: {\n store: ComposerHandoffStore;\n reason: string;\n}): void {\n const writes = store.pending;\n if (writes.length === 0) return;\n store.pending = [];\n for (const write of writes) dropWrite({ write, reason });\n}\n"],"names":["createContext","useContext","useCallback","useAthenaStatewireThreadList","useAuiState","athenaDiagnostics","AthenaSdkError"],"mappings":";;;;;;;AAgEO,SAAS,6BAAmD;AACjE,SAAO,EAAE,SAAS,CAAA,GAAI,mBAAmB,OAAO,UAAU,MAAM,cAAc,MAAA;AAChF;AAEO,MAAM,yBAAyBA,QAAAA,cAA2C,IAAI;AAG9E,SAAS,0BAAuD;AACrE,SAAOC,QAAAA,WAAW,sBAAsB;AAC1C;AAOO,SAAS,mBAA+B;AAC7C,QAAM,QAAQ,wBAAA;AACd,SAAOC,QAAAA,YAAY,MAAM;AACvB,QAAI,MAAO,eAAc,EAAE,OAAO;AAAA,EACpC,GAAG,CAAC,KAAK,CAAC;AACZ;AAGO,SAAS,c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,gBAAM,YAAN,+BAAgB;AAAA,EAClB;AACF;AAGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAGS;AACP,QAAM,SAAS,MAAM;AACrB,MAAI,OAAO,WAAW,EAAG;AACzB,QAAM,UAAU,CAAA;AAChB,aAAW,SAAS,OAAQ,WAAU,EAAE,OAAO,QAAQ;AACzD;;;;;;;;;;;;"}
|
|
@@ -33,11 +33,23 @@ export interface ComposerHandoffStore {
|
|
|
33
33
|
focusOnNextMirror: boolean;
|
|
34
34
|
/** Registered by the mounted editor: place the caret at the end of the draft. */
|
|
35
35
|
focusEnd: (() => void) | null;
|
|
36
|
+
/** Set by `useFocusComposer` before the editor mounted; the editor consumes it when it does. */
|
|
37
|
+
focusOnMount: boolean;
|
|
36
38
|
}
|
|
37
39
|
export declare function createComposerHandoffStore(): ComposerHandoffStore;
|
|
38
40
|
export declare const ComposerHandoffContext: import("react").Context<ComposerHandoffStore | null>;
|
|
39
41
|
/** The provider's handoff store, or null outside `AthenaProvider`. */
|
|
40
42
|
export declare function useComposerHandoffStore(): ComposerHandoffStore | null;
|
|
43
|
+
/**
|
|
44
|
+
* Puts the caret at the end of the composer's draft and leaves the draft as it is; asked before the
|
|
45
|
+
* editor has mounted, it focuses the editor as it mounts. For a host that shows the chat again and
|
|
46
|
+
* wants typing to land in it (a launcher window a shortcut brings back).
|
|
47
|
+
*/
|
|
48
|
+
export declare function useFocusComposer(): () => void;
|
|
49
|
+
/** The caret to the end of the draft now, or, with no editor mounted yet, as one mounts. */
|
|
50
|
+
export declare function focusComposer({ store }: {
|
|
51
|
+
store: ComposerHandoffStore;
|
|
52
|
+
}): void;
|
|
41
53
|
/**
|
|
42
54
|
* Whether a composer write lands now: in thread-list mode the list has
|
|
43
55
|
* resolved which thread is active, and that thread's history has loaded.
|