@athenaintel/react 0.57.2 → 0.60.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 +795 -12
- package/dist/agent-runtime/src/addressed-agents.cjs +16 -0
- package/dist/agent-runtime/src/addressed-agents.cjs.map +1 -0
- package/dist/agent-runtime/src/addressed-agents.d.ts +30 -0
- package/dist/agent-runtime/src/addressed-agents.js +16 -0
- package/dist/agent-runtime/src/addressed-agents.js.map +1 -0
- package/dist/agent-runtime/src/answer-label.cjs +4 -3
- package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
- package/dist/agent-runtime/src/answer-label.d.ts +13 -6
- package/dist/agent-runtime/src/answer-label.js +4 -3
- package/dist/agent-runtime/src/answer-label.js.map +1 -1
- package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -1
- package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +1 -1
- package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -1
- package/dist/agent-runtime/src/chat-outbox-entry.cjs +101 -0
- package/dist/agent-runtime/src/chat-outbox-entry.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-entry.d.ts +99 -0
- package/dist/agent-runtime/src/chat-outbox-entry.js +101 -0
- package/dist/agent-runtime/src/chat-outbox-entry.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-legacy.cjs +252 -0
- package/dist/agent-runtime/src/chat-outbox-legacy.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-legacy.d.ts +96 -0
- package/dist/agent-runtime/src/chat-outbox-legacy.js +252 -0
- package/dist/agent-runtime/src/chat-outbox-legacy.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-policy.cjs +30 -0
- package/dist/agent-runtime/src/chat-outbox-policy.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-policy.d.ts +42 -0
- package/dist/agent-runtime/src/chat-outbox-policy.js +30 -0
- package/dist/agent-runtime/src/chat-outbox-policy.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-storage.cjs +306 -0
- package/dist/agent-runtime/src/chat-outbox-storage.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-storage.d.ts +194 -0
- package/dist/agent-runtime/src/chat-outbox-storage.js +306 -0
- package/dist/agent-runtime/src/chat-outbox-storage.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-thread.cjs +21 -94
- package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/chat-outbox-thread.d.ts +22 -18
- package/dist/agent-runtime/src/chat-outbox-thread.js +21 -94
- package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -1
- package/dist/agent-runtime/src/chat-outbox.cjs +492 -547
- package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -1
- package/dist/agent-runtime/src/chat-outbox.d.ts +110 -142
- package/dist/agent-runtime/src/chat-outbox.js +492 -547
- package/dist/agent-runtime/src/chat-outbox.js.map +1 -1
- package/dist/agent-runtime/src/composer-markdown.cjs +0 -16
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
- package/dist/agent-runtime/src/composer-markdown.d.ts +1 -1
- package/dist/agent-runtime/src/composer-markdown.js +1 -17
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +8 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/agent-runtime/src/dictation-preferences.d.ts +356 -0
- package/dist/agent-runtime/src/dictation-record.d.ts +279 -0
- package/dist/agent-runtime/src/dictation-session.d.ts +106 -7
- package/dist/agent-runtime/src/dictation-snippets.d.ts +9 -0
- package/dist/agent-runtime/src/dictation-transfer.d.ts +142 -0
- package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/agent-runtime/src/edit-command.d.ts +1 -1
- package/dist/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/agent-runtime/src/errors.cjs +1 -0
- package/dist/agent-runtime/src/errors.cjs.map +1 -1
- package/dist/agent-runtime/src/errors.js +1 -0
- package/dist/agent-runtime/src/errors.js.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs +24 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +3 -3
- package/dist/agent-runtime/src/generated/runconfig-contract.js +24 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/agent-runtime/src/index.d.ts +14 -8
- package/dist/agent-runtime/src/lane-follow.cjs +289 -0
- package/dist/agent-runtime/src/lane-follow.cjs.map +1 -0
- package/dist/agent-runtime/src/lane-follow.js +289 -0
- package/dist/agent-runtime/src/lane-follow.js.map +1 -0
- package/dist/agent-runtime/src/lane-images.cjs +387 -0
- package/dist/agent-runtime/src/lane-images.cjs.map +1 -0
- package/dist/agent-runtime/src/lane-images.js +387 -0
- package/dist/agent-runtime/src/lane-images.js.map +1 -0
- package/dist/agent-runtime/src/message-window.js +1 -1
- package/dist/agent-runtime/src/messages.cjs +19 -1
- package/dist/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.d.ts +8 -0
- package/dist/agent-runtime/src/messages.js +21 -3
- package/dist/agent-runtime/src/messages.js.map +1 -1
- package/dist/agent-runtime/src/named-agents.cjs +301 -0
- package/dist/agent-runtime/src/named-agents.cjs.map +1 -0
- package/dist/agent-runtime/src/named-agents.d.ts +246 -0
- package/dist/agent-runtime/src/named-agents.js +301 -0
- package/dist/agent-runtime/src/named-agents.js.map +1 -0
- package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
- package/dist/agent-runtime/src/offline-status.d.ts +93 -2
- package/dist/agent-runtime/src/offline-status.js.map +1 -1
- package/dist/agent-runtime/src/ptc-subcalls.cjs +41 -0
- package/dist/agent-runtime/src/ptc-subcalls.cjs.map +1 -0
- package/dist/agent-runtime/src/ptc-subcalls.js +41 -0
- package/dist/agent-runtime/src/ptc-subcalls.js.map +1 -0
- package/dist/agent-runtime/src/queue.cjs +2 -2
- package/dist/agent-runtime/src/queue.cjs.map +1 -1
- package/dist/agent-runtime/src/queue.d.ts +20 -25
- package/dist/agent-runtime/src/queue.js +2 -2
- package/dist/agent-runtime/src/queue.js.map +1 -1
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +314 -84
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +137 -40
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js +318 -88
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/agent-runtime/src/run-send.cjs +54 -0
- package/dist/agent-runtime/src/run-send.cjs.map +1 -0
- package/dist/agent-runtime/src/run-send.d.ts +51 -0
- package/dist/agent-runtime/src/run-send.js +54 -0
- package/dist/agent-runtime/src/run-send.js.map +1 -0
- package/dist/agent-runtime/src/running-tool-placeholder.cjs +6 -0
- package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -1
- package/dist/agent-runtime/src/running-tool-placeholder.js +6 -0
- package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -1
- package/dist/agent-runtime/src/runtime.d.ts +9 -5
- package/dist/agent-runtime/src/sealed-idb.cjs +64 -0
- package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -1
- package/dist/agent-runtime/src/sealed-idb.d.ts +16 -0
- package/dist/agent-runtime/src/sealed-idb.js +64 -0
- package/dist/agent-runtime/src/sealed-idb.js.map +1 -1
- package/dist/agent-runtime/src/send-recovery.cjs +90 -118
- package/dist/agent-runtime/src/send-recovery.cjs.map +1 -1
- package/dist/agent-runtime/src/send-recovery.d.ts +25 -29
- package/dist/agent-runtime/src/send-recovery.js +90 -118
- package/dist/agent-runtime/src/send-recovery.js.map +1 -1
- package/dist/agent-runtime/src/statewire-diagnostics.d.ts +4 -1
- package/dist/agent-runtime/src/statewire-held-sends.cjs +191 -0
- package/dist/agent-runtime/src/statewire-held-sends.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-held-sends.d.ts +119 -0
- package/dist/agent-runtime/src/statewire-held-sends.js +191 -0
- package/dist/agent-runtime/src/statewire-held-sends.js.map +1 -0
- package/dist/agent-runtime/src/statewire-state.cjs +4 -0
- package/dist/agent-runtime/src/statewire-state.cjs.map +1 -1
- package/dist/agent-runtime/src/statewire-state.js +4 -0
- package/dist/agent-runtime/src/statewire-state.js.map +1 -1
- package/dist/agent-runtime/src/statewire-transport.cjs +8 -2
- package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
- package/dist/agent-runtime/src/statewire-transport.d.ts +14 -5
- package/dist/agent-runtime/src/statewire-transport.js +8 -2
- package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
- package/dist/agent-runtime/src/subagent-transcripts.cjs +1 -23
- package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
- package/dist/agent-runtime/src/subagent-transcripts.js +3 -25
- package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
- package/dist/agent-runtime/src/subagents.cjs +22 -29
- package/dist/agent-runtime/src/subagents.cjs.map +1 -1
- package/dist/agent-runtime/src/subagents.js +23 -30
- package/dist/agent-runtime/src/subagents.js.map +1 -1
- package/dist/agent-runtime/src/thread-extras.cjs +27 -19
- package/dist/agent-runtime/src/thread-extras.cjs.map +1 -1
- package/dist/agent-runtime/src/thread-extras.d.ts +19 -6
- package/dist/agent-runtime/src/thread-extras.js +27 -19
- package/dist/agent-runtime/src/thread-extras.js.map +1 -1
- package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
- package/dist/agent-runtime/src/tool-metadata.cjs +19 -0
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-metadata.js +19 -0
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/agent-runtime/src/tool-names.cjs +21 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-names.d.ts +8 -0
- package/dist/agent-runtime/src/tool-names.js +21 -0
- package/dist/agent-runtime/src/tool-names.js.map +1 -1
- package/dist/agent-runtime/src/typed-interrupt-kinds.cjs +247 -0
- package/dist/agent-runtime/src/typed-interrupt-kinds.cjs.map +1 -0
- package/dist/agent-runtime/src/typed-interrupt-kinds.d.ts +173 -0
- package/dist/agent-runtime/src/typed-interrupt-kinds.js +247 -0
- package/dist/agent-runtime/src/typed-interrupt-kinds.js.map +1 -0
- package/dist/agent-runtime/src/typed-interrupts.cjs +48 -0
- package/dist/agent-runtime/src/typed-interrupts.cjs.map +1 -0
- package/dist/agent-runtime/src/typed-interrupts.d.ts +75 -0
- package/dist/agent-runtime/src/typed-interrupts.js +48 -0
- package/dist/agent-runtime/src/typed-interrupts.js.map +1 -0
- package/dist/agent-runtime/src/types.d.ts +1 -1
- package/dist/agent-runtime/src/use-conversation-list.cjs +1 -0
- package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -1
- package/dist/agent-runtime/src/use-conversation-list.d.ts +7 -0
- package/dist/agent-runtime/src/use-conversation-list.js +1 -0
- package/dist/agent-runtime/src/use-conversation-list.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +46 -29
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +14 -22
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +46 -29
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +78 -14
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +34 -7
- package/dist/agent-runtime/src/use-deep-agent-runtime.js +79 -15
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +16 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +7 -2
- package/dist/agent-runtime/src/use-deep-agent-thread.js +16 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs +30 -4
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +22 -4
- package/dist/agent-runtime/src/use-deep-agent-voice.js +30 -4
- package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
- package/dist/agent-runtime/src/withdrawn-turns.d.ts +5 -4
- package/dist/agent-runtime/src/word-device-fit.d.ts +174 -0
- package/dist/agent-runtime/src/work-in.d.ts +127 -0
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +6 -1
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/asset-panel-store.cjs +13 -5
- package/dist/assets/asset-panel-store.cjs.map +1 -1
- package/dist/assets/asset-panel-store.d.ts +33 -2
- package/dist/assets/asset-panel-store.js +13 -5
- package/dist/assets/asset-panel-store.js.map +1 -1
- package/dist/auth/AthenaCredentialSourceContext.cjs +11 -0
- package/dist/auth/AthenaCredentialSourceContext.cjs.map +1 -1
- package/dist/auth/AthenaCredentialSourceContext.d.ts +6 -0
- package/dist/auth/AthenaCredentialSourceContext.js +11 -0
- package/dist/auth/AthenaCredentialSourceContext.js.map +1 -1
- package/dist/auth/account-identity.cjs +13 -2
- package/dist/auth/account-identity.cjs.map +1 -1
- package/dist/auth/account-identity.d.ts +9 -0
- package/dist/auth/account-identity.js +13 -2
- package/dist/auth/account-identity.js.map +1 -1
- package/dist/auth/credential-source.cjs +20 -4
- package/dist/auth/credential-source.cjs.map +1 -1
- package/dist/auth/credential-source.d.ts +9 -0
- package/dist/auth/credential-source.js +20 -4
- package/dist/auth/credential-source.js.map +1 -1
- package/dist/catalog/chat-pickers.cjs +31 -0
- package/dist/catalog/chat-pickers.cjs.map +1 -1
- package/dist/catalog/chat-pickers.d.ts +17 -0
- package/dist/catalog/chat-pickers.js +33 -2
- package/dist/catalog/chat-pickers.js.map +1 -1
- package/dist/catalog/runtime-catalog.cjs +63 -3
- package/dist/catalog/runtime-catalog.cjs.map +1 -1
- package/dist/catalog/runtime-catalog.d.ts +63 -3
- package/dist/catalog/runtime-catalog.js +64 -4
- package/dist/catalog/runtime-catalog.js.map +1 -1
- package/dist/chat/AthenaChat.cjs +301 -98
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +80 -4
- package/dist/chat/AthenaChat.js +302 -99
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +35 -5
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +55 -2
- package/dist/chat/StatewireApprovalCard.js +37 -7
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +17 -2
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +8 -45
- package/dist/chat/StatewireQueuedMessages.js +18 -3
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/chat-agent-mentions.cjs +70 -0
- package/dist/chat/chat-agent-mentions.cjs.map +1 -0
- package/dist/chat/chat-agent-mentions.d.ts +13 -0
- package/dist/chat/chat-agent-mentions.js +70 -0
- package/dist/chat/chat-agent-mentions.js.map +1 -0
- package/dist/chat/composer-actions.cjs +12 -0
- package/dist/chat/composer-actions.cjs.map +1 -0
- package/dist/chat/composer-actions.d.ts +22 -0
- package/dist/chat/composer-actions.js +12 -0
- package/dist/chat/composer-actions.js.map +1 -0
- package/dist/chat/follow-up-suggestions.cjs +185 -0
- package/dist/chat/follow-up-suggestions.cjs.map +1 -0
- package/dist/chat/follow-up-suggestions.d.ts +64 -0
- package/dist/chat/follow-up-suggestions.js +185 -0
- package/dist/chat/follow-up-suggestions.js.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs +4 -3
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.d.ts +7 -3
- package/dist/chat/super-grouping/ToolTimeline.js +4 -3
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
- package/dist/chat/turn-changes.cjs +284 -0
- package/dist/chat/turn-changes.cjs.map +1 -0
- package/dist/chat/turn-changes.d.ts +130 -0
- package/dist/chat/turn-changes.js +284 -0
- package/dist/chat/turn-changes.js.map +1 -0
- package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs +31 -0
- package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.cjs.map +1 -0
- package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.d.ts +31 -0
- package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js +31 -0
- package/dist/chat/typed-interrupts/StatewireTypedInterruptCard.js.map +1 -0
- package/dist/chat/typed-interrupts/approval-cards.cjs +250 -0
- package/dist/chat/typed-interrupts/approval-cards.cjs.map +1 -0
- package/dist/chat/typed-interrupts/approval-cards.d.ts +22 -0
- package/dist/chat/typed-interrupts/approval-cards.js +250 -0
- package/dist/chat/typed-interrupts/approval-cards.js.map +1 -0
- package/dist/chat/typed-interrupts/form-cards.cjs +289 -0
- package/dist/chat/typed-interrupts/form-cards.cjs.map +1 -0
- package/dist/chat/typed-interrupts/form-cards.d.ts +6 -0
- package/dist/chat/typed-interrupts/form-cards.js +289 -0
- package/dist/chat/typed-interrupts/form-cards.js.map +1 -0
- package/dist/chat/typed-interrupts/interrupt-card-shell.cjs +182 -0
- package/dist/chat/typed-interrupts/interrupt-card-shell.cjs.map +1 -0
- package/dist/chat/typed-interrupts/interrupt-card-shell.d.ts +47 -0
- package/dist/chat/typed-interrupts/interrupt-card-shell.js +182 -0
- package/dist/chat/typed-interrupts/interrupt-card-shell.js.map +1 -0
- package/dist/chat/typed-interrupts/json-schema-form.cjs +388 -0
- package/dist/chat/typed-interrupts/json-schema-form.cjs.map +1 -0
- package/dist/chat/typed-interrupts/json-schema-form.d.ts +33 -0
- package/dist/chat/typed-interrupts/json-schema-form.js +388 -0
- package/dist/chat/typed-interrupts/json-schema-form.js.map +1 -0
- package/dist/chat/typed-interrupts/questionnaire-card.cjs +449 -0
- package/dist/chat/typed-interrupts/questionnaire-card.cjs.map +1 -0
- package/dist/chat/typed-interrupts/questionnaire-card.d.ts +20 -0
- package/dist/chat/typed-interrupts/questionnaire-card.js +449 -0
- package/dist/chat/typed-interrupts/questionnaire-card.js.map +1 -0
- package/dist/chat/typed-interrupts/request-file-card.cjs +159 -0
- package/dist/chat/typed-interrupts/request-file-card.cjs.map +1 -0
- package/dist/chat/typed-interrupts/request-file-card.d.ts +2 -0
- package/dist/chat/typed-interrupts/request-file-card.js +159 -0
- package/dist/chat/typed-interrupts/request-file-card.js.map +1 -0
- package/dist/chat/typed-interrupts/toolkit-selection-card.cjs +189 -0
- package/dist/chat/typed-interrupts/toolkit-selection-card.cjs.map +1 -0
- package/dist/chat/typed-interrupts/toolkit-selection-card.d.ts +23 -0
- package/dist/chat/typed-interrupts/toolkit-selection-card.js +189 -0
- package/dist/chat/typed-interrupts/toolkit-selection-card.js.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-body.cjs +26 -0
- package/dist/chat/typed-interrupts/typed-interrupt-body.cjs.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-body.d.ts +3 -0
- package/dist/chat/typed-interrupts/typed-interrupt-body.js +26 -0
- package/dist/chat/typed-interrupts/typed-interrupt-body.js.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs +105 -0
- package/dist/chat/typed-interrupts/typed-interrupt-graphql.cjs.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-graphql.d.ts +29 -0
- package/dist/chat/typed-interrupts/typed-interrupt-graphql.js +105 -0
- package/dist/chat/typed-interrupts/typed-interrupt-graphql.js.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs +70 -0
- package/dist/chat/typed-interrupts/typed-interrupt-notice.cjs.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-notice.d.ts +45 -0
- package/dist/chat/typed-interrupts/typed-interrupt-notice.js +70 -0
- package/dist/chat/typed-interrupts/typed-interrupt-notice.js.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs +76 -0
- package/dist/chat/typed-interrupts/typed-interrupt-panel.cjs.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-panel.d.ts +11 -0
- package/dist/chat/typed-interrupts/typed-interrupt-panel.js +76 -0
- package/dist/chat/typed-interrupts/typed-interrupt-panel.js.map +1 -0
- package/dist/chat/typed-interrupts/typed-interrupt-types.d.ts +46 -0
- package/dist/chat/typed-interrupts/use-interrupt-draft.cjs +106 -0
- package/dist/chat/typed-interrupts/use-interrupt-draft.cjs.map +1 -0
- package/dist/chat/typed-interrupts/use-interrupt-draft.d.ts +29 -0
- package/dist/chat/typed-interrupts/use-interrupt-draft.js +106 -0
- package/dist/chat/typed-interrupts/use-interrupt-draft.js.map +1 -0
- package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs +231 -0
- package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.cjs.map +1 -0
- package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.d.ts +66 -0
- package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js +231 -0
- package/dist/chat/typed-interrupts/use-statewire-typed-interrupt.js.map +1 -0
- package/dist/chat-ui/composer/composer-named-agents.cjs +13 -0
- package/dist/chat-ui/composer/composer-named-agents.cjs.map +1 -0
- package/dist/chat-ui/composer/composer-named-agents.d.ts +20 -0
- package/dist/chat-ui/composer/composer-named-agents.js +13 -0
- package/dist/chat-ui/composer/composer-named-agents.js.map +1 -0
- package/dist/chat-ui/composer/slash-command-menu.cjs +143 -0
- package/dist/chat-ui/composer/slash-command-menu.cjs.map +1 -0
- package/dist/chat-ui/composer/slash-command-menu.d.ts +19 -0
- package/dist/chat-ui/composer/slash-command-menu.js +143 -0
- package/dist/chat-ui/composer/slash-command-menu.js.map +1 -0
- package/dist/chat-ui/composer/slash-commands-extension.cjs +51 -0
- package/dist/chat-ui/composer/slash-commands-extension.cjs.map +1 -0
- package/dist/chat-ui/composer/slash-commands-extension.d.ts +39 -0
- package/dist/chat-ui/composer/slash-commands-extension.js +51 -0
- package/dist/chat-ui/composer/slash-commands-extension.js.map +1 -0
- package/dist/chat-ui/composer/slash-commands.cjs +74 -0
- package/dist/chat-ui/composer/slash-commands.cjs.map +1 -0
- package/dist/chat-ui/composer/slash-commands.d.ts +82 -0
- package/dist/chat-ui/composer/slash-commands.js +74 -0
- package/dist/chat-ui/composer/slash-commands.js.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs +135 -9
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +61 -2
- package/dist/chat-ui/composer/tiptap-composer.js +135 -9
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +5 -0
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +4 -2
- package/dist/chat-ui/index.js +5 -0
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +10 -4
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.js +11 -5
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +8 -1
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.js +8 -1
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs +1 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js +1 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs +20 -2
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.js +22 -4
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +45 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +48 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.js +45 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs +89 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.cjs.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.d.ts +8 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js +89 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icon-names.generated.js.map +1 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +140 -116
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +46 -12
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +141 -117
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +272 -25
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +88 -10
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +274 -27
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/types.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/types.d.ts +27 -1
- package/dist/chat-ui/mentions/suggestions/data/types.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +56 -5
- 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 +26 -6
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +57 -6
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs +34 -17
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +19 -1
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js +35 -18
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.js.map +1 -1
- package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs +12 -0
- package/dist/chat-ui/mentions/use-asset-icon-app-url.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-asset-icon-app-url.d.ts +8 -0
- package/dist/chat-ui/mentions/use-asset-icon-app-url.js +12 -0
- package/dist/chat-ui/mentions/use-asset-icon-app-url.js.map +1 -0
- package/dist/chat-ui/statewire.d.ts +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +15 -0
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +4 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +15 -0
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/collab/client.cjs +41 -6
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +38 -7
- package/dist/collab/client.js +41 -6
- package/dist/collab/client.js.map +1 -1
- package/dist/composer/ComposerAttachedReferences.cjs +119 -0
- package/dist/composer/ComposerAttachedReferences.cjs.map +1 -0
- package/dist/composer/ComposerAttachedReferences.d.ts +26 -0
- package/dist/composer/ComposerAttachedReferences.js +119 -0
- package/dist/composer/ComposerAttachedReferences.js.map +1 -0
- package/dist/composer/ComposerNamedAgents.cjs +63 -0
- package/dist/composer/ComposerNamedAgents.cjs.map +1 -0
- package/dist/composer/ComposerNamedAgents.d.ts +16 -0
- package/dist/composer/ComposerNamedAgents.js +63 -0
- package/dist/composer/ComposerNamedAgents.js.map +1 -0
- package/dist/composer/attached-references.cjs +159 -0
- package/dist/composer/attached-references.cjs.map +1 -0
- package/dist/composer/attached-references.d.ts +86 -0
- package/dist/composer/attached-references.js +159 -0
- package/dist/composer/attached-references.js.map +1 -0
- package/dist/composer/build-composed-message.cjs +14 -7
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +6 -1
- package/dist/composer/build-composed-message.js +14 -7
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +6 -2
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +7 -1
- package/dist/composer/composer-handoff.js +6 -2
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/folder-upload.cjs +149 -0
- package/dist/composer/folder-upload.cjs.map +1 -0
- package/dist/composer/folder-upload.d.ts +79 -0
- package/dist/composer/folder-upload.js +149 -0
- package/dist/composer/folder-upload.js.map +1 -0
- package/dist/composer/index.d.ts +1 -1
- package/dist/composer/staged-message-metadata.cjs +12 -0
- package/dist/composer/staged-message-metadata.cjs.map +1 -0
- package/dist/composer/staged-message-metadata.d.ts +15 -0
- package/dist/composer/staged-message-metadata.js +12 -0
- package/dist/composer/staged-message-metadata.js.map +1 -0
- package/dist/composer/useAttachToChat.cjs +35 -0
- package/dist/composer/useAttachToChat.cjs.map +1 -0
- package/dist/composer/useAttachToChat.d.ts +54 -0
- package/dist/composer/useAttachToChat.js +35 -0
- package/dist/composer/useAttachToChat.js.map +1 -0
- package/dist/composer/useAttachedReferencesComposerProps.cjs +19 -0
- package/dist/composer/useAttachedReferencesComposerProps.cjs.map +1 -0
- package/dist/composer/useAttachedReferencesComposerProps.d.ts +12 -0
- package/dist/composer/useAttachedReferencesComposerProps.js +19 -0
- package/dist/composer/useAttachedReferencesComposerProps.js.map +1 -0
- package/dist/composer/useFileUpload.cjs +95 -7
- package/dist/composer/useFileUpload.cjs.map +1 -1
- package/dist/composer/useFileUpload.d.ts +21 -2
- package/dist/composer/useFileUpload.js +95 -7
- package/dist/composer/useFileUpload.js.map +1 -1
- package/dist/data/athena-api-error.cjs +125 -0
- package/dist/data/athena-api-error.cjs.map +1 -0
- package/dist/data/athena-api-error.d.ts +96 -0
- package/dist/data/athena-api-error.js +125 -0
- package/dist/data/athena-api-error.js.map +1 -0
- package/dist/data/athena-data-client.cjs +106 -0
- package/dist/data/athena-data-client.cjs.map +1 -0
- package/dist/data/athena-data-client.d.ts +74 -0
- package/dist/data/athena-data-client.js +106 -0
- package/dist/data/athena-data-client.js.map +1 -0
- package/dist/data/athena-member.cjs +93 -0
- package/dist/data/athena-member.cjs.map +1 -0
- package/dist/data/athena-member.d.ts +125 -0
- package/dist/data/athena-member.js +93 -0
- package/dist/data/athena-member.js.map +1 -0
- package/dist/data/athena-request.cjs +460 -0
- package/dist/data/athena-request.cjs.map +1 -0
- package/dist/data/athena-request.d.ts +120 -0
- package/dist/data/athena-request.js +460 -0
- package/dist/data/athena-request.js.map +1 -0
- package/dist/data/use-athena-fetch.cjs +14 -0
- package/dist/data/use-athena-fetch.cjs.map +1 -0
- package/dist/data/use-athena-fetch.d.ts +19 -0
- package/dist/data/use-athena-fetch.js +14 -0
- package/dist/data/use-athena-fetch.js.map +1 -0
- package/dist/data/use-athena-graphql.cjs +66 -0
- package/dist/data/use-athena-graphql.cjs.map +1 -0
- package/dist/data/use-athena-graphql.d.ts +56 -0
- package/dist/data/use-athena-graphql.js +66 -0
- package/dist/data/use-athena-graphql.js.map +1 -0
- package/dist/data/use-athena-rest.cjs +33 -0
- package/dist/data/use-athena-rest.cjs.map +1 -0
- package/dist/data/use-athena-rest.d.ts +21 -0
- package/dist/data/use-athena-rest.js +33 -0
- package/dist/data/use-athena-rest.js.map +1 -0
- package/dist/data/use-semantic-query.cjs +44 -0
- package/dist/data/use-semantic-query.cjs.map +1 -0
- package/dist/data/use-semantic-query.d.ts +92 -0
- package/dist/data/use-semantic-query.js +44 -0
- package/dist/data/use-semantic-query.js.map +1 -0
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +5 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/diagnostics/errors.cjs +7 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +7 -0
- package/dist/diagnostics/errors.js +7 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +155 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +72 -13
- package/dist/index.js +148 -4
- package/dist/index.js.map +1 -1
- package/dist/keryx-http/src/initial-sync.cjs +64 -16
- package/dist/keryx-http/src/initial-sync.cjs.map +1 -1
- package/dist/keryx-http/src/initial-sync.d.ts +31 -1
- package/dist/keryx-http/src/initial-sync.js +64 -16
- package/dist/keryx-http/src/initial-sync.js.map +1 -1
- package/dist/keryx-http/src/own-awareness.cjs +20 -0
- package/dist/keryx-http/src/own-awareness.cjs.map +1 -0
- package/dist/keryx-http/src/own-awareness.d.ts +50 -0
- package/dist/keryx-http/src/own-awareness.js +20 -0
- package/dist/keryx-http/src/own-awareness.js.map +1 -0
- package/dist/keryx-http/src/update-attributions.cjs +26 -1
- package/dist/keryx-http/src/update-attributions.cjs.map +1 -1
- package/dist/keryx-http/src/update-attributions.d.ts +10 -1
- package/dist/keryx-http/src/update-attributions.js +26 -1
- package/dist/keryx-http/src/update-attributions.js.map +1 -1
- package/dist/offline/chat-outbox.cjs +262 -26
- package/dist/offline/chat-outbox.cjs.map +1 -1
- package/dist/offline/chat-outbox.d.ts +90 -12
- package/dist/offline/chat-outbox.js +263 -27
- package/dist/offline/chat-outbox.js.map +1 -1
- package/dist/provider/AthenaProvider.cjs +60 -22
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +24 -8
- package/dist/provider/AthenaProvider.js +61 -23
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/references/src/anchors/parse.cjs +11 -1
- package/dist/references/src/anchors/parse.cjs.map +1 -1
- package/dist/references/src/anchors/parse.js +11 -1
- package/dist/references/src/anchors/parse.js.map +1 -1
- package/dist/references/src/anchors/schemas.d.ts +1 -0
- package/dist/references/src/anchors/serialize.cjs +1 -0
- package/dist/references/src/anchors/serialize.cjs.map +1 -1
- package/dist/references/src/anchors/serialize.js +1 -0
- package/dist/references/src/anchors/serialize.js.map +1 -1
- package/dist/references/src/anchors/types.cjs +5 -0
- package/dist/references/src/anchors/types.cjs.map +1 -1
- package/dist/references/src/anchors/types.d.ts +9 -0
- package/dist/references/src/anchors/types.js +5 -0
- package/dist/references/src/anchors/types.js.map +1 -1
- package/dist/references/src/attachable.cjs +149 -0
- package/dist/references/src/attachable.cjs.map +1 -0
- package/dist/references/src/attachable.d.ts +87 -0
- package/dist/references/src/attachable.js +149 -0
- package/dist/references/src/attachable.js.map +1 -0
- package/dist/references/src/schemas.d.ts +2 -0
- package/dist/runtime/StatewirePlanModeLaneSync.cjs +93 -0
- package/dist/runtime/StatewirePlanModeLaneSync.cjs.map +1 -0
- package/dist/runtime/StatewirePlanModeLaneSync.d.ts +34 -0
- package/dist/runtime/StatewirePlanModeLaneSync.js +93 -0
- package/dist/runtime/StatewirePlanModeLaneSync.js.map +1 -0
- package/dist/runtime/StatewireThreadConfigLaneSync.cjs +2 -0
- package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -1
- package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +4 -0
- package/dist/runtime/StatewireThreadConfigLaneSync.js +2 -0
- package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -1
- package/dist/runtime/statewire-plan-mode.cjs +71 -0
- package/dist/runtime/statewire-plan-mode.cjs.map +1 -0
- package/dist/runtime/statewire-plan-mode.d.ts +88 -0
- package/dist/runtime/statewire-plan-mode.js +71 -0
- package/dist/runtime/statewire-plan-mode.js.map +1 -0
- package/dist/runtime/statewire-run-config.cjs +3 -1
- package/dist/runtime/statewire-run-config.cjs.map +1 -1
- package/dist/runtime/statewire-run-config.d.ts +7 -0
- package/dist/runtime/statewire-run-config.js +3 -1
- package/dist/runtime/statewire-run-config.js.map +1 -1
- package/dist/runtime/statewire-session-key.cjs +11 -5
- package/dist/runtime/statewire-session-key.cjs.map +1 -1
- package/dist/runtime/statewire-session-key.d.ts +22 -10
- package/dist/runtime/statewire-session-key.js +11 -5
- package/dist/runtime/statewire-session-key.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +64 -9
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +26 -10
- package/dist/runtime/useAthenaStatewireRuntime.js +66 -11
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaAssets.cjs +394 -0
- package/dist/search/useAthenaAssets.cjs.map +1 -0
- package/dist/search/useAthenaAssets.d.ts +186 -0
- package/dist/search/useAthenaAssets.js +394 -0
- package/dist/search/useAthenaAssets.js.map +1 -0
- package/dist/sheet-range/index.cjs +4 -0
- package/dist/sheet-range/index.cjs.map +1 -1
- package/dist/sheet-range/index.d.ts +4 -2
- package/dist/sheet-range/index.js +4 -0
- package/dist/sheet-range/index.js.map +1 -1
- package/dist/sheet-range/query-range.cjs +102 -0
- package/dist/sheet-range/query-range.cjs.map +1 -0
- package/dist/sheet-range/query-range.d.ts +46 -0
- package/dist/sheet-range/query-range.js +102 -0
- package/dist/sheet-range/query-range.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/subagents/index.cjs +49 -0
- package/dist/subagents/index.cjs.map +1 -0
- package/dist/subagents/index.d.ts +16 -0
- package/dist/subagents/index.js +49 -0
- package/dist/subagents/index.js.map +1 -0
- package/dist/subagents/lane-follow.cjs +19 -0
- package/dist/subagents/lane-follow.cjs.map +1 -0
- package/dist/subagents/lane-follow.d.ts +9 -0
- package/dist/subagents/lane-follow.js +19 -0
- package/dist/subagents/lane-follow.js.map +1 -0
- package/dist/subagents/lane-model.cjs +178 -0
- package/dist/subagents/lane-model.cjs.map +1 -0
- package/dist/subagents/lane-model.d.ts +140 -0
- package/dist/subagents/lane-model.js +178 -0
- package/dist/subagents/lane-model.js.map +1 -0
- package/dist/subagents/lane-parts.cjs +517 -0
- package/dist/subagents/lane-parts.cjs.map +1 -0
- package/dist/subagents/lane-parts.d.ts +130 -0
- package/dist/subagents/lane-parts.js +517 -0
- package/dist/subagents/lane-parts.js.map +1 -0
- package/dist/subagents/subagent-lane-group.cjs +215 -0
- package/dist/subagents/subagent-lane-group.cjs.map +1 -0
- package/dist/subagents/subagent-lane-group.d.ts +67 -0
- package/dist/subagents/subagent-lane-group.js +215 -0
- package/dist/subagents/subagent-lane-group.js.map +1 -0
- package/dist/subagents/subagent-transcript-drawer.cjs +431 -0
- package/dist/subagents/subagent-transcript-drawer.cjs.map +1 -0
- package/dist/subagents/subagent-transcript-drawer.d.ts +78 -0
- package/dist/subagents/subagent-transcript-drawer.js +431 -0
- package/dist/subagents/subagent-transcript-drawer.js.map +1 -0
- package/dist/subagents/task-subagent-group.cjs +115 -0
- package/dist/subagents/task-subagent-group.cjs.map +1 -0
- package/dist/subagents/task-subagent-group.d.ts +36 -0
- package/dist/subagents/task-subagent-group.js +115 -0
- package/dist/subagents/task-subagent-group.js.map +1 -0
- package/dist/subagents/use-omitted-images-in-view.cjs +68 -0
- package/dist/subagents/use-omitted-images-in-view.cjs.map +1 -0
- package/dist/subagents/use-omitted-images-in-view.d.ts +21 -0
- package/dist/subagents/use-omitted-images-in-view.js +68 -0
- package/dist/subagents/use-omitted-images-in-view.js.map +1 -0
- package/dist/threads/Inbox.cjs +2 -2
- package/dist/threads/Inbox.cjs.map +1 -1
- package/dist/threads/SessionList.cjs +6 -6
- package/dist/threads/SessionList.cjs.map +1 -1
- package/dist/threads/SessionsPage.cjs +13 -7
- package/dist/threads/SessionsPage.cjs.map +1 -1
- package/dist/threads/SessionsPage.d.ts +10 -1
- package/dist/threads/SessionsPage.js +9 -3
- package/dist/threads/SessionsPage.js.map +1 -1
- package/dist/threads/session-list-model.cjs.map +1 -1
- package/dist/threads/session-list-model.d.ts +2 -1
- package/dist/threads/session-list-model.js.map +1 -1
- package/dist/threads/session-row-parts.cjs +3 -3
- package/dist/threads/session-row-parts.cjs.map +1 -1
- package/dist/threads/sessions-page-model.cjs +13 -5
- package/dist/threads/sessions-page-model.cjs.map +1 -1
- package/dist/threads/sessions-page-model.d.ts +7 -0
- package/dist/threads/sessions-page-model.js +11 -3
- package/dist/threads/sessions-page-model.js.map +1 -1
- package/dist/threads/sessions-page-storage.cjs +8 -8
- package/dist/threads/sessions-page-storage.cjs.map +1 -1
- package/dist/threads/sessions-page-storage.d.ts +5 -1
- package/dist/threads/sessions-page-storage.js +8 -8
- package/dist/threads/sessions-page-storage.js.map +1 -1
- package/dist/threads/statewire-thread-list.cjs +14 -2
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +11 -2
- package/dist/threads/statewire-thread-list.js +14 -2
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-athena-sessions.cjs +1 -0
- package/dist/threads/use-athena-sessions.cjs.map +1 -1
- package/dist/threads/use-athena-sessions.d.ts +7 -0
- package/dist/threads/use-athena-sessions.js +1 -0
- package/dist/threads/use-athena-sessions.js.map +1 -1
- package/dist/threads/use-athena-thread-agent.cjs +31 -0
- package/dist/threads/use-athena-thread-agent.cjs.map +1 -0
- package/dist/threads/use-athena-thread-agent.d.ts +38 -0
- package/dist/threads/use-athena-thread-agent.js +31 -0
- package/dist/threads/use-athena-thread-agent.js.map +1 -0
- package/dist/threads/use-athena-thread-plan-mode.cjs +18 -0
- package/dist/threads/use-athena-thread-plan-mode.cjs.map +1 -0
- package/dist/threads/use-athena-thread-plan-mode.d.ts +18 -0
- package/dist/threads/use-athena-thread-plan-mode.js +18 -0
- package/dist/threads/use-athena-thread-plan-mode.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.d.ts +1 -0
- package/dist/tools/agent-creations.cjs +97 -0
- package/dist/tools/agent-creations.cjs.map +1 -0
- package/dist/tools/agent-creations.d.ts +38 -0
- package/dist/tools/agent-creations.js +97 -0
- package/dist/tools/agent-creations.js.map +1 -0
- package/dist/tools/agent-highlights.cjs +100 -0
- package/dist/tools/agent-highlights.cjs.map +1 -0
- package/dist/tools/agent-highlights.d.ts +57 -0
- package/dist/tools/agent-highlights.js +100 -0
- package/dist/tools/agent-highlights.js.map +1 -0
- package/dist/tools/append-document-tool-ui.cjs +1 -0
- package/dist/tools/append-document-tool-ui.cjs.map +1 -1
- package/dist/tools/append-document-tool-ui.d.ts +7 -0
- package/dist/tools/append-document-tool-ui.js +2 -1
- package/dist/tools/append-document-tool-ui.js.map +1 -1
- package/dist/tools/auto-open-tools.cjs +144 -71
- package/dist/tools/auto-open-tools.cjs.map +1 -1
- package/dist/tools/auto-open-tools.d.ts +131 -1
- package/dist/tools/auto-open-tools.js +145 -72
- package/dist/tools/auto-open-tools.js.map +1 -1
- package/dist/tools/browser-tool-uis.cjs +594 -0
- package/dist/tools/browser-tool-uis.cjs.map +1 -0
- package/dist/tools/browser-tool-uis.d.ts +8 -0
- package/dist/tools/browser-tool-uis.js +594 -0
- package/dist/tools/browser-tool-uis.js.map +1 -0
- package/dist/tools/computer-asset-tool-uis.cjs +313 -0
- package/dist/tools/computer-asset-tool-uis.cjs.map +1 -0
- package/dist/tools/computer-asset-tool-uis.d.ts +5 -0
- package/dist/tools/computer-asset-tool-uis.js +313 -0
- package/dist/tools/computer-asset-tool-uis.js.map +1 -0
- package/dist/tools/document-edit-tool-uis.cjs +218 -0
- package/dist/tools/document-edit-tool-uis.cjs.map +1 -0
- package/dist/tools/document-edit-tool-uis.d.ts +40 -0
- package/dist/tools/document-edit-tool-uis.js +218 -0
- package/dist/tools/document-edit-tool-uis.js.map +1 -0
- package/dist/tools/drive-tool-uis.cjs +429 -0
- package/dist/tools/drive-tool-uis.cjs.map +1 -0
- package/dist/tools/drive-tool-uis.d.ts +121 -0
- package/dist/tools/drive-tool-uis.js +429 -0
- package/dist/tools/drive-tool-uis.js.map +1 -0
- package/dist/tools/email-calendar-tool-uis.cjs +789 -0
- package/dist/tools/email-calendar-tool-uis.cjs.map +1 -0
- package/dist/tools/email-calendar-tool-uis.d.ts +129 -0
- package/dist/tools/email-calendar-tool-uis.js +789 -0
- package/dist/tools/email-calendar-tool-uis.js.map +1 -0
- package/dist/tools/ontology-tool-uis.cjs +83 -0
- package/dist/tools/ontology-tool-uis.cjs.map +1 -0
- package/dist/tools/ontology-tool-uis.d.ts +9 -0
- package/dist/tools/ontology-tool-uis.js +83 -0
- package/dist/tools/ontology-tool-uis.js.map +1 -0
- package/dist/tools/orchestration-tool-uis.cjs +586 -0
- package/dist/tools/orchestration-tool-uis.cjs.map +1 -0
- package/dist/tools/orchestration-tool-uis.d.ts +141 -0
- package/dist/tools/orchestration-tool-uis.js +586 -0
- package/dist/tools/orchestration-tool-uis.js.map +1 -0
- package/dist/tools/presentation-edit-tool-uis.cjs +516 -0
- package/dist/tools/presentation-edit-tool-uis.cjs.map +1 -0
- package/dist/tools/presentation-edit-tool-uis.d.ts +73 -0
- package/dist/tools/presentation-edit-tool-uis.js +516 -0
- package/dist/tools/presentation-edit-tool-uis.js.map +1 -0
- package/dist/tools/project-tool-uis.cjs +213 -0
- package/dist/tools/project-tool-uis.cjs.map +1 -0
- package/dist/tools/project-tool-uis.d.ts +14 -0
- package/dist/tools/project-tool-uis.js +213 -0
- package/dist/tools/project-tool-uis.js.map +1 -0
- package/dist/tools/sandbox-tool-uis.cjs +491 -0
- package/dist/tools/sandbox-tool-uis.cjs.map +1 -0
- package/dist/tools/sandbox-tool-uis.d.ts +116 -0
- package/dist/tools/sandbox-tool-uis.js +491 -0
- package/dist/tools/sandbox-tool-uis.js.map +1 -0
- package/dist/tools/sheet-query-tool-ui.cjs +138 -0
- package/dist/tools/sheet-query-tool-ui.cjs.map +1 -0
- package/dist/tools/sheet-query-tool-ui.d.ts +15 -0
- package/dist/tools/sheet-query-tool-ui.js +138 -0
- package/dist/tools/sheet-query-tool-ui.js.map +1 -0
- package/dist/tools/studio-screenshot-tool-uis.cjs +262 -0
- package/dist/tools/studio-screenshot-tool-uis.cjs.map +1 -0
- package/dist/tools/studio-screenshot-tool-uis.d.ts +52 -0
- package/dist/tools/studio-screenshot-tool-uis.js +262 -0
- package/dist/tools/studio-screenshot-tool-uis.js.map +1 -0
- package/dist/tools/subagent-task-tool-ui.cjs +24 -475
- package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
- package/dist/tools/subagent-task-tool-ui.d.ts +19 -103
- package/dist/tools/subagent-task-tool-ui.js +28 -479
- package/dist/tools/subagent-task-tool-ui.js.map +1 -1
- package/dist/tools/tool-summary.cjs +36 -0
- package/dist/tools/tool-summary.cjs.map +1 -1
- package/dist/tools/tool-summary.js +36 -0
- package/dist/tools/tool-summary.js.map +1 -1
- package/dist/tools/tool-uis.cjs +181 -53
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.d.ts +40 -0
- package/dist/tools/tool-uis.js +183 -55
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/typed-interrupts/index.cjs +15 -0
- package/dist/typed-interrupts/index.cjs.map +1 -0
- package/dist/typed-interrupts/index.d.ts +20 -0
- package/dist/typed-interrupts/index.js +15 -0
- package/dist/typed-interrupts/index.js.map +1 -0
- package/dist/version.cjs +4 -0
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.ts +9 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -1
- package/dist/workbench/live-desktop-api.cjs +2 -1
- package/dist/workbench/live-desktop-api.cjs.map +1 -1
- package/dist/workbench/live-desktop-api.js +2 -1
- package/dist/workbench/live-desktop-api.js.map +1 -1
- package/dist/workbench/session-workbench-panes.cjs +6 -6
- package/dist/workbench/session-workbench-panes.cjs.map +1 -1
- package/dist/workbench/session-workspace-api.cjs +7 -2
- package/dist/workbench/session-workspace-api.cjs.map +1 -1
- package/dist/workbench/session-workspace-api.d.ts +10 -0
- package/dist/workbench/session-workspace-api.js +7 -2
- package/dist/workbench/session-workspace-api.js.map +1 -1
- package/package.json +28 -6
- package/dist/agent-runtime/src/chat-outbox-store.cjs +0 -510
- package/dist/agent-runtime/src/chat-outbox-store.cjs.map +0 -1
- package/dist/agent-runtime/src/chat-outbox-store.d.ts +0 -210
- package/dist/agent-runtime/src/chat-outbox-store.js +0 -510
- package/dist/agent-runtime/src/chat-outbox-store.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachToChat.cjs","sources":["../../src/composer/useAttachToChat.ts"],"sourcesContent":["import type { AttachableReference } from '@athenaintel/references/attachable';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { AthenaStatewireThreadIdContext } from '../threads/thread-id-context';\nimport {\n type AttachReferenceResult,\n attachReferenceToThread,\n clearAttachedReferences,\n detachReferenceFromThread,\n usePendingAttachedReferences,\n} from './attached-references';\nimport { useFocusComposer } from './composer-handoff';\nimport { useAppendToComposer } from './useAppendToComposer';\n\n/**\n * Something an app can attach to the next chat message: an Athena asset (optionally narrowed to a\n * place inside it with an `anchor`, as the reference standard writes it), an ontology object, or a\n * web page. `meta.title` is what the chip shows; the agent is told it is the app's label, never the\n * object's content.\n *\n * ```ts\n * { referenced: 'asset', id: 'asset_…', anchor?: { type: 'page', page: 5 }, meta?: { title: 'Q4 deck' } }\n * { referenced: 'ontology_object', id: 'asset_…', meta?: { title: 'Sequoia Capital', objectType: 'Investor' } }\n * { referenced: 'external_url', url: 'https://…', meta?: { title: 'Blog post' } }\n * ```\n */\nexport type AthenaReference = AttachableReference;\n\nexport interface AttachToChatOptions {\n /**\n * Text put in the composer after what the person has typed, for them to finish and send. Nothing\n * is sent.\n */\n prompt?: string;\n /** Focus the composer, caret at the end of the draft, so the person can type and send. */\n open?: boolean;\n}\n\nexport interface UseAttachToChatResult {\n /**\n * Attach `reference` to the next message: the composer shows it as a removable chip, and it\n * travels with that message as structured data, never as text. Athena resolves it on the server\n * with the signed-in person's own permission; the agent is told about anything it can't open\n * instead of seeing it. Returns why it was not attached when it was not.\n */\n attach: (reference: AthenaReference, options?: AttachToChatOptions) => AttachReferenceResult;\n /** Take `reference` (matched by kind and id, an asset's anchor included) off the next message. */\n detach: (reference: AthenaReference) => void;\n /** Take every reference off the next message. */\n clear: () => void;\n /** What the next message carries, in the order attached. */\n references: readonly AthenaReference[];\n}\n\n/**\n * Attach objects on screen to the conversation's next message (\"Discuss this with the agent\").\n * Use it anywhere under `<AthenaProvider>`: it attaches to the chat's active conversation, whose\n * composer (`AthenaChat`) shows the chips. A message carries at most\n * `MAX_ATTACHED_REFERENCES` (10).\n *\n * ```tsx\n * const { attach } = useAttachToChat();\n * <button onClick={() => attach(\n * { referenced: 'ontology_object', id: investor.id, meta: { title: investor.name } },\n * { prompt: 'Draft an intro email to ', open: true },\n * )}>Discuss</button>\n * ```\n */\nexport function useAttachToChat(): UseAttachToChatResult {\n const threadId = useContext(AthenaStatewireThreadIdContext);\n const references = usePendingAttachedReferences(threadId);\n const appendToComposer = useAppendToComposer();\n const focusComposer = useFocusComposer();\n\n const attach = useCallback(\n (reference: AthenaReference, options?: AttachToChatOptions): AttachReferenceResult => {\n const result = attachReferenceToThread({ threadId, reference });\n if (!result.attached) return result;\n const prompt = options?.prompt;\n if (prompt) appendToComposer(prompt, { focus: options?.open ?? false });\n else if (options?.open) focusComposer();\n return result;\n },\n [appendToComposer, focusComposer, threadId],\n );\n const detach = useCallback(\n (reference: AthenaReference) => detachReferenceFromThread({ threadId, reference }),\n [threadId],\n );\n const clear = useCallback(() => clearAttachedReferences(threadId), [threadId]);\n\n return useMemo(\n () => ({ attach, detach, clear, references }),\n [attach, clear, detach, references],\n );\n}\n"],"names":["useContext","AthenaStatewireThreadIdContext","usePendingAttachedReferences","useAppendToComposer","useFocusComposer","useCallback","attachReferenceToThread","detachReferenceFromThread","clearAttachedReferences","useMemo"],"mappings":";;;;;;;AAmEO,SAAS,kBAAyC;AACvD,QAAM,WAAWA,WAAAA,WAAWC,8CAA8B;AAC1D,QAAM,aAAaC,mBAAAA,6BAA6B,QAAQ;AACxD,QAAM,mBAAmBC,oBAAAA,oBAAA;AACzB,QAAM,gBAAgBC,gBAAAA,iBAAA;AAEtB,QAAM,SAASC,WAAAA;AAAAA,IACb,CAAC,WAA4B,YAAyD;AACpF,YAAM,SAASC,mBAAAA,wBAAwB,EAAE,UAAU,WAAW;AAC9D,UAAI,CAAC,OAAO,SAAU,QAAO;AAC7B,YAAM,SAAS,mCAAS;AACxB,UAAI,yBAAyB,QAAQ,EAAE,QAAO,mCAAS,SAAQ,OAAO;AAAA,eAC7D,mCAAS,KAAM,eAAA;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,eAAe,QAAQ;AAAA,EAAA;AAE5C,QAAM,SAASD,WAAAA;AAAAA,IACb,CAAC,cAA+BE,mBAAAA,0BAA0B,EAAE,UAAU,WAAW;AAAA,IACjF,CAAC,QAAQ;AAAA,EAAA;AAEX,QAAM,QAAQF,WAAAA,YAAY,MAAMG,mBAAAA,wBAAwB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAE7E,SAAOC,WAAAA;AAAAA,IACL,OAAO,EAAE,QAAQ,QAAQ,OAAO,WAAA;AAAA,IAChC,CAAC,QAAQ,OAAO,QAAQ,UAAU;AAAA,EAAA;AAEtC;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AttachableReference } from '../references/src/attachable';
|
|
2
|
+
import { type AttachReferenceResult } from './attached-references';
|
|
3
|
+
/**
|
|
4
|
+
* Something an app can attach to the next chat message: an Athena asset (optionally narrowed to a
|
|
5
|
+
* place inside it with an `anchor`, as the reference standard writes it), an ontology object, or a
|
|
6
|
+
* web page. `meta.title` is what the chip shows; the agent is told it is the app's label, never the
|
|
7
|
+
* object's content.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* { referenced: 'asset', id: 'asset_…', anchor?: { type: 'page', page: 5 }, meta?: { title: 'Q4 deck' } }
|
|
11
|
+
* { referenced: 'ontology_object', id: 'asset_…', meta?: { title: 'Sequoia Capital', objectType: 'Investor' } }
|
|
12
|
+
* { referenced: 'external_url', url: 'https://…', meta?: { title: 'Blog post' } }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type AthenaReference = AttachableReference;
|
|
16
|
+
export interface AttachToChatOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Text put in the composer after what the person has typed, for them to finish and send. Nothing
|
|
19
|
+
* is sent.
|
|
20
|
+
*/
|
|
21
|
+
prompt?: string;
|
|
22
|
+
/** Focus the composer, caret at the end of the draft, so the person can type and send. */
|
|
23
|
+
open?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface UseAttachToChatResult {
|
|
26
|
+
/**
|
|
27
|
+
* Attach `reference` to the next message: the composer shows it as a removable chip, and it
|
|
28
|
+
* travels with that message as structured data, never as text. Athena resolves it on the server
|
|
29
|
+
* with the signed-in person's own permission; the agent is told about anything it can't open
|
|
30
|
+
* instead of seeing it. Returns why it was not attached when it was not.
|
|
31
|
+
*/
|
|
32
|
+
attach: (reference: AthenaReference, options?: AttachToChatOptions) => AttachReferenceResult;
|
|
33
|
+
/** Take `reference` (matched by kind and id, an asset's anchor included) off the next message. */
|
|
34
|
+
detach: (reference: AthenaReference) => void;
|
|
35
|
+
/** Take every reference off the next message. */
|
|
36
|
+
clear: () => void;
|
|
37
|
+
/** What the next message carries, in the order attached. */
|
|
38
|
+
references: readonly AthenaReference[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Attach objects on screen to the conversation's next message ("Discuss this with the agent").
|
|
42
|
+
* Use it anywhere under `<AthenaProvider>`: it attaches to the chat's active conversation, whose
|
|
43
|
+
* composer (`AthenaChat`) shows the chips. A message carries at most
|
|
44
|
+
* `MAX_ATTACHED_REFERENCES` (10).
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const { attach } = useAttachToChat();
|
|
48
|
+
* <button onClick={() => attach(
|
|
49
|
+
* { referenced: 'ontology_object', id: investor.id, meta: { title: investor.name } },
|
|
50
|
+
* { prompt: 'Draft an intro email to ', open: true },
|
|
51
|
+
* )}>Discuss</button>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function useAttachToChat(): UseAttachToChatResult;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useContext, useCallback, useMemo } from "react";
|
|
2
|
+
import { AthenaStatewireThreadIdContext } from "../threads/thread-id-context.js";
|
|
3
|
+
import { usePendingAttachedReferences, attachReferenceToThread, detachReferenceFromThread, clearAttachedReferences } from "./attached-references.js";
|
|
4
|
+
import { useFocusComposer } from "./composer-handoff.js";
|
|
5
|
+
import { useAppendToComposer } from "./useAppendToComposer.js";
|
|
6
|
+
function useAttachToChat() {
|
|
7
|
+
const threadId = useContext(AthenaStatewireThreadIdContext);
|
|
8
|
+
const references = usePendingAttachedReferences(threadId);
|
|
9
|
+
const appendToComposer = useAppendToComposer();
|
|
10
|
+
const focusComposer = useFocusComposer();
|
|
11
|
+
const attach = useCallback(
|
|
12
|
+
(reference, options) => {
|
|
13
|
+
const result = attachReferenceToThread({ threadId, reference });
|
|
14
|
+
if (!result.attached) return result;
|
|
15
|
+
const prompt = options == null ? void 0 : options.prompt;
|
|
16
|
+
if (prompt) appendToComposer(prompt, { focus: (options == null ? void 0 : options.open) ?? false });
|
|
17
|
+
else if (options == null ? void 0 : options.open) focusComposer();
|
|
18
|
+
return result;
|
|
19
|
+
},
|
|
20
|
+
[appendToComposer, focusComposer, threadId]
|
|
21
|
+
);
|
|
22
|
+
const detach = useCallback(
|
|
23
|
+
(reference) => detachReferenceFromThread({ threadId, reference }),
|
|
24
|
+
[threadId]
|
|
25
|
+
);
|
|
26
|
+
const clear = useCallback(() => clearAttachedReferences(threadId), [threadId]);
|
|
27
|
+
return useMemo(
|
|
28
|
+
() => ({ attach, detach, clear, references }),
|
|
29
|
+
[attach, clear, detach, references]
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
useAttachToChat
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=useAttachToChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachToChat.js","sources":["../../src/composer/useAttachToChat.ts"],"sourcesContent":["import type { AttachableReference } from '@athenaintel/references/attachable';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { AthenaStatewireThreadIdContext } from '../threads/thread-id-context';\nimport {\n type AttachReferenceResult,\n attachReferenceToThread,\n clearAttachedReferences,\n detachReferenceFromThread,\n usePendingAttachedReferences,\n} from './attached-references';\nimport { useFocusComposer } from './composer-handoff';\nimport { useAppendToComposer } from './useAppendToComposer';\n\n/**\n * Something an app can attach to the next chat message: an Athena asset (optionally narrowed to a\n * place inside it with an `anchor`, as the reference standard writes it), an ontology object, or a\n * web page. `meta.title` is what the chip shows; the agent is told it is the app's label, never the\n * object's content.\n *\n * ```ts\n * { referenced: 'asset', id: 'asset_…', anchor?: { type: 'page', page: 5 }, meta?: { title: 'Q4 deck' } }\n * { referenced: 'ontology_object', id: 'asset_…', meta?: { title: 'Sequoia Capital', objectType: 'Investor' } }\n * { referenced: 'external_url', url: 'https://…', meta?: { title: 'Blog post' } }\n * ```\n */\nexport type AthenaReference = AttachableReference;\n\nexport interface AttachToChatOptions {\n /**\n * Text put in the composer after what the person has typed, for them to finish and send. Nothing\n * is sent.\n */\n prompt?: string;\n /** Focus the composer, caret at the end of the draft, so the person can type and send. */\n open?: boolean;\n}\n\nexport interface UseAttachToChatResult {\n /**\n * Attach `reference` to the next message: the composer shows it as a removable chip, and it\n * travels with that message as structured data, never as text. Athena resolves it on the server\n * with the signed-in person's own permission; the agent is told about anything it can't open\n * instead of seeing it. Returns why it was not attached when it was not.\n */\n attach: (reference: AthenaReference, options?: AttachToChatOptions) => AttachReferenceResult;\n /** Take `reference` (matched by kind and id, an asset's anchor included) off the next message. */\n detach: (reference: AthenaReference) => void;\n /** Take every reference off the next message. */\n clear: () => void;\n /** What the next message carries, in the order attached. */\n references: readonly AthenaReference[];\n}\n\n/**\n * Attach objects on screen to the conversation's next message (\"Discuss this with the agent\").\n * Use it anywhere under `<AthenaProvider>`: it attaches to the chat's active conversation, whose\n * composer (`AthenaChat`) shows the chips. A message carries at most\n * `MAX_ATTACHED_REFERENCES` (10).\n *\n * ```tsx\n * const { attach } = useAttachToChat();\n * <button onClick={() => attach(\n * { referenced: 'ontology_object', id: investor.id, meta: { title: investor.name } },\n * { prompt: 'Draft an intro email to ', open: true },\n * )}>Discuss</button>\n * ```\n */\nexport function useAttachToChat(): UseAttachToChatResult {\n const threadId = useContext(AthenaStatewireThreadIdContext);\n const references = usePendingAttachedReferences(threadId);\n const appendToComposer = useAppendToComposer();\n const focusComposer = useFocusComposer();\n\n const attach = useCallback(\n (reference: AthenaReference, options?: AttachToChatOptions): AttachReferenceResult => {\n const result = attachReferenceToThread({ threadId, reference });\n if (!result.attached) return result;\n const prompt = options?.prompt;\n if (prompt) appendToComposer(prompt, { focus: options?.open ?? false });\n else if (options?.open) focusComposer();\n return result;\n },\n [appendToComposer, focusComposer, threadId],\n );\n const detach = useCallback(\n (reference: AthenaReference) => detachReferenceFromThread({ threadId, reference }),\n [threadId],\n );\n const clear = useCallback(() => clearAttachedReferences(threadId), [threadId]);\n\n return useMemo(\n () => ({ attach, detach, clear, references }),\n [attach, clear, detach, references],\n );\n}\n"],"names":[],"mappings":";;;;;AAmEO,SAAS,kBAAyC;AACvD,QAAM,WAAW,WAAW,8BAA8B;AAC1D,QAAM,aAAa,6BAA6B,QAAQ;AACxD,QAAM,mBAAmB,oBAAA;AACzB,QAAM,gBAAgB,iBAAA;AAEtB,QAAM,SAAS;AAAA,IACb,CAAC,WAA4B,YAAyD;AACpF,YAAM,SAAS,wBAAwB,EAAE,UAAU,WAAW;AAC9D,UAAI,CAAC,OAAO,SAAU,QAAO;AAC7B,YAAM,SAAS,mCAAS;AACxB,UAAI,yBAAyB,QAAQ,EAAE,QAAO,mCAAS,SAAQ,OAAO;AAAA,eAC7D,mCAAS,KAAM,eAAA;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,kBAAkB,eAAe,QAAQ;AAAA,EAAA;AAE5C,QAAM,SAAS;AAAA,IACb,CAAC,cAA+B,0BAA0B,EAAE,UAAU,WAAW;AAAA,IACjF,CAAC,QAAQ;AAAA,EAAA;AAEX,QAAM,QAAQ,YAAY,MAAM,wBAAwB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAE7E,SAAO;AAAA,IACL,OAAO,EAAE,QAAQ,QAAQ,OAAO,WAAA;AAAA,IAChC,CAAC,QAAQ,OAAO,QAAQ,UAAU;AAAA,EAAA;AAEtC;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const attachedReferences = require("./attached-references.cjs");
|
|
5
|
+
function useAttachedReferencesComposerProps(threadId) {
|
|
6
|
+
const prepareSend = require$$0.useCallback(
|
|
7
|
+
({ text }) => ({
|
|
8
|
+
queue: attachedReferences.stageThreadAttachedReferencesForSend({ threadId, text }).length > 0
|
|
9
|
+
}),
|
|
10
|
+
[threadId]
|
|
11
|
+
);
|
|
12
|
+
const onSendReturned = require$$0.useCallback(
|
|
13
|
+
({ text }) => attachedReferences.restoreSentAttachedReferences({ threadId, text }),
|
|
14
|
+
[threadId]
|
|
15
|
+
);
|
|
16
|
+
return require$$0.useMemo(() => ({ prepareSend, onSendReturned }), [onSendReturned, prepareSend]);
|
|
17
|
+
}
|
|
18
|
+
exports.useAttachedReferencesComposerProps = useAttachedReferencesComposerProps;
|
|
19
|
+
//# sourceMappingURL=useAttachedReferencesComposerProps.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachedReferencesComposerProps.cjs","sources":["../../src/composer/useAttachedReferencesComposerProps.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { TiptapComposerProps } from '../chat-ui/composer/tiptap-composer';\nimport {\n restoreSentAttachedReferences,\n stageThreadAttachedReferencesForSend,\n} from './attached-references';\n\n/** The `TiptapComposer` props that send what an app attached to the message. */\nexport type AttachedReferencesComposerProps = Required<\n Pick<TiptapComposerProps, 'prepareSend' | 'onSendReturned'>\n>;\n\n/**\n * Wire a `TiptapComposer` to the references an app attached to `threadId`'s next message\n * (`useAttachToChat`): spread the result on the composer. Each send the composer makes itself\n * carries them in its metadata (and waits for its own run rather than joining a live one), and a\n * send statewire hands back brings their chips back. `AthenaChat` does this for its own composer;\n * a host mounting `TiptapComposer` directly (with `ComposerAttachedReferences` above it) opts in\n * here, and one that doesn't never sends attachments or loads this code.\n */\nexport function useAttachedReferencesComposerProps(\n threadId: string,\n): AttachedReferencesComposerProps {\n const prepareSend = useCallback(\n ({ text }: { text: string }) => ({\n queue: stageThreadAttachedReferencesForSend({ threadId, text }).length > 0,\n }),\n [threadId],\n );\n const onSendReturned = useCallback(\n ({ text }: { text: string }) => restoreSentAttachedReferences({ threadId, text }),\n [threadId],\n );\n return useMemo(() => ({ prepareSend, onSendReturned }), [onSendReturned, prepareSend]);\n}\n"],"names":["useCallback","stageThreadAttachedReferencesForSend","restoreSentAttachedReferences","useMemo"],"mappings":";;;;AAoBO,SAAS,mCACd,UACiC;AACjC,QAAM,cAAcA,WAAAA;AAAAA,IAClB,CAAC,EAAE,KAAA,OAA8B;AAAA,MAC/B,OAAOC,mBAAAA,qCAAqC,EAAE,UAAU,KAAA,CAAM,EAAE,SAAS;AAAA,IAAA;AAAA,IAE3E,CAAC,QAAQ;AAAA,EAAA;AAEX,QAAM,iBAAiBD,WAAAA;AAAAA,IACrB,CAAC,EAAE,KAAA,MAA6BE,mBAAAA,8BAA8B,EAAE,UAAU,MAAM;AAAA,IAChF,CAAC,QAAQ;AAAA,EAAA;AAEX,SAAOC,WAAAA,QAAQ,OAAO,EAAE,aAAa,mBAAmB,CAAC,gBAAgB,WAAW,CAAC;AACvF;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TiptapComposerProps } from '../chat-ui/composer/tiptap-composer';
|
|
2
|
+
/** The `TiptapComposer` props that send what an app attached to the message. */
|
|
3
|
+
export type AttachedReferencesComposerProps = Required<Pick<TiptapComposerProps, 'prepareSend' | 'onSendReturned'>>;
|
|
4
|
+
/**
|
|
5
|
+
* Wire a `TiptapComposer` to the references an app attached to `threadId`'s next message
|
|
6
|
+
* (`useAttachToChat`): spread the result on the composer. Each send the composer makes itself
|
|
7
|
+
* carries them in its metadata (and waits for its own run rather than joining a live one), and a
|
|
8
|
+
* send statewire hands back brings their chips back. `AthenaChat` does this for its own composer;
|
|
9
|
+
* a host mounting `TiptapComposer` directly (with `ComposerAttachedReferences` above it) opts in
|
|
10
|
+
* here, and one that doesn't never sends attachments or loads this code.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAttachedReferencesComposerProps(threadId: string): AttachedReferencesComposerProps;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { stageThreadAttachedReferencesForSend, restoreSentAttachedReferences } from "./attached-references.js";
|
|
3
|
+
function useAttachedReferencesComposerProps(threadId) {
|
|
4
|
+
const prepareSend = useCallback(
|
|
5
|
+
({ text }) => ({
|
|
6
|
+
queue: stageThreadAttachedReferencesForSend({ threadId, text }).length > 0
|
|
7
|
+
}),
|
|
8
|
+
[threadId]
|
|
9
|
+
);
|
|
10
|
+
const onSendReturned = useCallback(
|
|
11
|
+
({ text }) => restoreSentAttachedReferences({ threadId, text }),
|
|
12
|
+
[threadId]
|
|
13
|
+
);
|
|
14
|
+
return useMemo(() => ({ prepareSend, onSendReturned }), [onSendReturned, prepareSend]);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
useAttachedReferencesComposerProps
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useAttachedReferencesComposerProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachedReferencesComposerProps.js","sources":["../../src/composer/useAttachedReferencesComposerProps.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { TiptapComposerProps } from '../chat-ui/composer/tiptap-composer';\nimport {\n restoreSentAttachedReferences,\n stageThreadAttachedReferencesForSend,\n} from './attached-references';\n\n/** The `TiptapComposer` props that send what an app attached to the message. */\nexport type AttachedReferencesComposerProps = Required<\n Pick<TiptapComposerProps, 'prepareSend' | 'onSendReturned'>\n>;\n\n/**\n * Wire a `TiptapComposer` to the references an app attached to `threadId`'s next message\n * (`useAttachToChat`): spread the result on the composer. Each send the composer makes itself\n * carries them in its metadata (and waits for its own run rather than joining a live one), and a\n * send statewire hands back brings their chips back. `AthenaChat` does this for its own composer;\n * a host mounting `TiptapComposer` directly (with `ComposerAttachedReferences` above it) opts in\n * here, and one that doesn't never sends attachments or loads this code.\n */\nexport function useAttachedReferencesComposerProps(\n threadId: string,\n): AttachedReferencesComposerProps {\n const prepareSend = useCallback(\n ({ text }: { text: string }) => ({\n queue: stageThreadAttachedReferencesForSend({ threadId, text }).length > 0,\n }),\n [threadId],\n );\n const onSendReturned = useCallback(\n ({ text }: { text: string }) => restoreSentAttachedReferences({ threadId, text }),\n [threadId],\n );\n return useMemo(() => ({ prepareSend, onSendReturned }), [onSendReturned, prepareSend]);\n}\n"],"names":[],"mappings":";;AAoBO,SAAS,mCACd,UACiC;AACjC,QAAM,cAAc;AAAA,IAClB,CAAC,EAAE,KAAA,OAA8B;AAAA,MAC/B,OAAO,qCAAqC,EAAE,UAAU,KAAA,CAAM,EAAE,SAAS;AAAA,IAAA;AAAA,IAE3E,CAAC,QAAQ;AAAA,EAAA;AAEX,QAAM,iBAAiB;AAAA,IACrB,CAAC,EAAE,KAAA,MAA6B,8BAA8B,EAAE,UAAU,MAAM;AAAA,IAChF,CAAC,QAAQ;AAAA,EAAA;AAEX,SAAO,QAAQ,OAAO,EAAE,aAAa,mBAAmB,CAAC,gBAAgB,WAAW,CAAC;AACvF;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require$$0 = require("react");
|
|
4
4
|
const AthenaContext = require("../provider/AthenaContext.cjs");
|
|
5
|
+
const folderUpload = require("./folder-upload.cjs");
|
|
5
6
|
const MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024;
|
|
6
7
|
function useFileUpload() {
|
|
7
8
|
const config = AthenaContext.useAthenaConfig();
|
|
@@ -12,15 +13,87 @@ function useFileUpload() {
|
|
|
12
13
|
const [progress, setProgress] = require$$0.useState(null);
|
|
13
14
|
const [error, setError] = require$$0.useState(null);
|
|
14
15
|
const xhrRef = require$$0.useRef(null);
|
|
16
|
+
const taskWaitRef = require$$0.useRef(null);
|
|
15
17
|
require$$0.useEffect(() => {
|
|
16
18
|
return () => {
|
|
17
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
18
20
|
(_a = xhrRef.current) == null ? void 0 : _a.abort();
|
|
21
|
+
(_b = taskWaitRef.current) == null ? void 0 : _b.abort();
|
|
19
22
|
};
|
|
20
23
|
}, []);
|
|
21
24
|
const clearError = require$$0.useCallback(() => setError(null), []);
|
|
25
|
+
const uploadIntoFolder = require$$0.useCallback(
|
|
26
|
+
async ({
|
|
27
|
+
files,
|
|
28
|
+
parentFolderId,
|
|
29
|
+
baseUrl,
|
|
30
|
+
headers,
|
|
31
|
+
currentToken
|
|
32
|
+
}) => {
|
|
33
|
+
const send = (form) => new Promise((resolve, reject) => {
|
|
34
|
+
const xhr = new XMLHttpRequest();
|
|
35
|
+
xhrRef.current = xhr;
|
|
36
|
+
xhr.upload.addEventListener("progress", (e) => {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!e.lengthComputable) return;
|
|
39
|
+
const percent = e.loaded / e.total;
|
|
40
|
+
const fileIndex = Math.min(Math.floor(percent * files.length), files.length - 1);
|
|
41
|
+
setProgress({
|
|
42
|
+
current: fileIndex + 1,
|
|
43
|
+
total: files.length,
|
|
44
|
+
fileName: ((_a = files[fileIndex]) == null ? void 0 : _a.name) ?? "",
|
|
45
|
+
percent
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
xhr.addEventListener(
|
|
49
|
+
"load",
|
|
50
|
+
() => resolve(new Response(xhr.responseText, { status: xhr.status }))
|
|
51
|
+
);
|
|
52
|
+
xhr.addEventListener("error", () => reject(new Error("Network error during upload")));
|
|
53
|
+
xhr.addEventListener("abort", () => reject(new Error("Upload was cancelled")));
|
|
54
|
+
xhr.open("POST", `${baseUrl}${folderUpload.FOLDER_UPLOAD_PATH}`);
|
|
55
|
+
for (const [key, value] of Object.entries(headers)) xhr.setRequestHeader(key, value);
|
|
56
|
+
xhr.withCredentials = !currentToken && !configRef.current.apiKey;
|
|
57
|
+
xhr.send(form);
|
|
58
|
+
});
|
|
59
|
+
const taskId = await folderUpload.startFolderUpload({ send, files, parentFolderId });
|
|
60
|
+
const config2 = configRef.current;
|
|
61
|
+
const auth = {
|
|
62
|
+
backendUrl: baseUrl,
|
|
63
|
+
appUrl: config2.appUrl,
|
|
64
|
+
apiKey: config2.apiKey,
|
|
65
|
+
credentials: "include",
|
|
66
|
+
get accessToken() {
|
|
67
|
+
return configRef.current.token ?? void 0;
|
|
68
|
+
},
|
|
69
|
+
getAccessToken: async () => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
return await ((_b = (_a = configRef.current).getToken) == null ? void 0 : _b.call(_a)) ?? void 0;
|
|
72
|
+
},
|
|
73
|
+
renewAccessToken: async () => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return await ((_b = (_a = configRef.current).getToken) == null ? void 0 : _b.call(_a, { force: true })) ?? void 0;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const waiting = new AbortController();
|
|
79
|
+
taskWaitRef.current = waiting;
|
|
80
|
+
try {
|
|
81
|
+
const task = await folderUpload.waitForFolderUploadTask({ auth, taskId, signal: waiting.signal });
|
|
82
|
+
const { uploaded, failed } = folderUpload.folderUploadResultOf({ task, files });
|
|
83
|
+
if (failed.length > 0) {
|
|
84
|
+
const errMsg = failed.map((entry) => `${entry.fileName}: ${entry.error}`).join("; ");
|
|
85
|
+
setError(errMsg);
|
|
86
|
+
if (uploaded.length === 0) throw new Error(errMsg);
|
|
87
|
+
}
|
|
88
|
+
return { uploaded, refused: failed };
|
|
89
|
+
} finally {
|
|
90
|
+
if (taskWaitRef.current === waiting) taskWaitRef.current = null;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
[]
|
|
94
|
+
);
|
|
22
95
|
const upload = require$$0.useCallback(
|
|
23
|
-
async (files) => {
|
|
96
|
+
async (files, options = {}) => {
|
|
24
97
|
var _a;
|
|
25
98
|
if (files.length === 0) return [];
|
|
26
99
|
for (const file of files) {
|
|
@@ -34,10 +107,6 @@ function useFileUpload() {
|
|
|
34
107
|
setError(null);
|
|
35
108
|
setProgress({ current: 0, total: files.length, fileName: ((_a = files[0]) == null ? void 0 : _a.name) ?? "", percent: 0 });
|
|
36
109
|
try {
|
|
37
|
-
const formData = new FormData();
|
|
38
|
-
for (const file of files) {
|
|
39
|
-
formData.append("files", file, file.name);
|
|
40
|
-
}
|
|
41
110
|
const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
42
111
|
const uploadUrl = `${baseUrl}/api/upload/`;
|
|
43
112
|
const currentToken = configRef.current.token;
|
|
@@ -47,6 +116,22 @@ function useFileUpload() {
|
|
|
47
116
|
} else if (apiKey) {
|
|
48
117
|
headers["X-API-KEY"] = apiKey;
|
|
49
118
|
}
|
|
119
|
+
const { parentFolderId, onFilesRefused } = options;
|
|
120
|
+
if (parentFolderId) {
|
|
121
|
+
const { uploaded, refused } = await uploadIntoFolder({
|
|
122
|
+
files,
|
|
123
|
+
parentFolderId,
|
|
124
|
+
baseUrl,
|
|
125
|
+
headers,
|
|
126
|
+
currentToken
|
|
127
|
+
});
|
|
128
|
+
if (refused.length > 0) onFilesRefused == null ? void 0 : onFilesRefused(refused);
|
|
129
|
+
return uploaded;
|
|
130
|
+
}
|
|
131
|
+
const formData = new FormData();
|
|
132
|
+
for (const file of files) {
|
|
133
|
+
formData.append("files", file, file.name);
|
|
134
|
+
}
|
|
50
135
|
const xhr = new XMLHttpRequest();
|
|
51
136
|
xhrRef.current = xhr;
|
|
52
137
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -108,6 +193,9 @@ function useFileUpload() {
|
|
|
108
193
|
throw new Error(errMsg);
|
|
109
194
|
}
|
|
110
195
|
setError(errMsg);
|
|
196
|
+
onFilesRefused == null ? void 0 : onFilesRefused(
|
|
197
|
+
result.errors.map((e) => ({ fileName: e.file.filename, error: e.error }))
|
|
198
|
+
);
|
|
111
199
|
}
|
|
112
200
|
return result.success;
|
|
113
201
|
} catch (err) {
|
|
@@ -120,7 +208,7 @@ function useFileUpload() {
|
|
|
120
208
|
setProgress(null);
|
|
121
209
|
}
|
|
122
210
|
},
|
|
123
|
-
[backendUrl, apiKey]
|
|
211
|
+
[backendUrl, apiKey, uploadIntoFolder]
|
|
124
212
|
);
|
|
125
213
|
return { upload, isUploading, progress, error, clearError };
|
|
126
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileUpload.cjs","sources":["../../src/composer/useFileUpload.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useAthenaConfig } from '../provider/AthenaContext';\n\nexport interface UploadedAsset {\n id: string;\n title: string;\n fileName: string;\n fileSize: number;\n mediaType: string;\n /**\n * The position, in the batch `upload` was given, of the file this asset was\n * uploaded from (the upload's `success_file_indexes`; absent from a server\n * that does not send them).\n */\n fileIndex?: number;\n /**\n * A local `blob:` URL of the picture this attachment was uploaded from, for\n * the composer's thumbnail and full-screen viewer. Set by the composer's\n * intake for image files, and revoked when the draft lets the attachment go.\n */\n previewUrl?: string;\n}\n\nexport interface UploadProgress {\n current: number;\n total: number;\n fileName: string;\n /** 0–1 normalized progress for the current file */\n percent: number;\n}\n\nexport interface UseFileUploadReturn {\n /** Upload one or more files to Athena. Returns the created asset(s). */\n upload: (files: File[]) => Promise<UploadedAsset[]>;\n /** Whether an upload is currently in progress. */\n isUploading: boolean;\n /** Upload progress info (null when idle). */\n progress: UploadProgress | null;\n /** Last upload error (null when no error). */\n error: string | null;\n /** Clear the error state. */\n clearError: () => void;\n}\n\nconst MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024; // 5 GB\n\n/**\n * Hook for uploading files to the Athena platform via the Athena upload endpoint.\n * Files become Athena assets (documents, spreadsheets, PDFs, images, etc.).\n *\n * Usage:\n * const { upload, isUploading, progress, error } = useFileUpload();\n * const assets = await upload(fileList);\n */\nexport function useFileUpload(): UseFileUploadReturn {\n const config = useAthenaConfig();\n // Keep config in a ref so upload() always reads the latest token at call\n // time. AthenaConfig's token is a getter that returns the current value\n // from PropelAuth, and reading via the ref avoids capturing stale\n // destructured values in the useCallback closure.\n const configRef = useRef(config);\n configRef.current = config;\n const { backendUrl, apiKey } = config;\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState<UploadProgress | null>(null);\n const [error, setError] = useState<string | null>(null);\n const xhrRef = useRef<XMLHttpRequest | null>(null);\n\n // Abort any in-flight upload when the component unmounts\n useEffect(() => {\n return () => {\n xhrRef.current?.abort();\n };\n }, []);\n\n const clearError = useCallback(() => setError(null), []);\n\n const upload = useCallback(\n async (files: File[]): Promise<UploadedAsset[]> => {\n if (files.length === 0) return [];\n\n // Validate file sizes\n for (const file of files) {\n if (file.size > MAX_FILE_SIZE) {\n const msg = `File \"${file.name}\" exceeds the maximum size of 5 GB.`;\n setError(msg);\n throw new Error(msg);\n }\n }\n\n setIsUploading(true);\n setError(null);\n setProgress({ current: 0, total: files.length, fileName: files[0]?.name ?? '', percent: 0 });\n\n try {\n const formData = new FormData();\n for (const file of files) {\n formData.append('files', file, file.name);\n }\n\n // Derive the upload URL from the configured Athena backend URL.\n // If backendUrl points at a nested Athena endpoint, trim it back to the API base first.\n const baseUrl = backendUrl.replace(/\\/api\\/assistant-ui\\/?$/, '');\n const uploadUrl = `${baseUrl}/api/upload/`;\n\n // Read the current token at call time so rotated tokens are picked up.\n const currentToken = configRef.current.token;\n const headers: Record<string, string> = {};\n if (currentToken) {\n headers['Authorization'] = `Bearer ${currentToken}`;\n } else if (apiKey) {\n headers['X-API-KEY'] = apiKey;\n }\n\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n\n const result = await new Promise<{ success: UploadedAsset[]; errors: Array<{ file: { filename: string }; error: string }> }>((resolve, reject) => {\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n const percent = e.loaded / e.total;\n // Estimate which file we're on based on progress\n const fileIndex = Math.min(\n Math.floor(percent * files.length),\n files.length - 1,\n );\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n const data = JSON.parse(xhr.responseText);\n const fileIndexes: unknown = data.success_file_indexes;\n const assets: UploadedAsset[] = (data.success ?? []).map((a: Record<string, unknown>, at: number) => {\n const fileIndex = Array.isArray(fileIndexes) ? fileIndexes[at] : undefined;\n return {\n id: a.id as string,\n title: (a.title ?? a.file_name) as string,\n fileName: a.file_name as string,\n fileSize: a.file_size as number,\n mediaType: a.media_type as string,\n ...(typeof fileIndex === 'number' && { fileIndex }),\n };\n });\n resolve({ success: assets, errors: data.errors ?? [] });\n } catch {\n reject(new Error('Failed to parse upload response'));\n }\n } else if (xhr.status === 401 || xhr.status === 403) {\n reject(new Error('Authentication failed. Check your API key or token.'));\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n\n xhr.open('POST', uploadUrl);\n for (const [key, value] of Object.entries(headers)) {\n xhr.setRequestHeader(key, value);\n }\n xhr.withCredentials = !currentToken && !apiKey;\n xhr.send(formData);\n });\n\n if (result.errors.length > 0) {\n const errMsg = result.errors.map((e) => `${e.file.filename}: ${e.error}`).join('; ');\n if (result.success.length === 0) {\n setError(errMsg);\n throw new Error(errMsg);\n }\n // Partial success — set error but still return successful uploads\n setError(errMsg);\n }\n\n return result.success;\n } catch (err) {\n const msg = err instanceof Error ? err.message : 'Upload failed';\n setError(msg);\n throw err;\n } finally {\n xhrRef.current = null;\n setIsUploading(false);\n setProgress(null);\n }\n },\n [backendUrl, apiKey],\n );\n\n return { upload, isUploading, progress, error, clearError };\n}\n"],"names":["useAthenaConfig","useRef","useState","useEffect","useCallback","_a"],"mappings":";;;;AA4CA,MAAM,gBAAgB,IAAI,OAAO,OAAO;AAUjC,SAAS,gBAAqC;AACnD,QAAM,SAASA,cAAAA,gBAAA;AAKf,QAAM,YAAYC,WAAAA,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,EAAE,YAAY,OAAA,IAAW;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAIC,WAAAA,SAAS,KAAK;AACpD,QAAM,CAAC,UAAU,WAAW,IAAIA,WAAAA,SAAgC,IAAI;AACpE,QAAM,CAAC,OAAO,QAAQ,IAAIA,WAAAA,SAAwB,IAAI;AACtD,QAAM,SAASD,WAAAA,OAA8B,IAAI;AAGjDE,aAAAA,UAAU,MAAM;AACd,WAAO,MAAM;;AACX,mBAAO,YAAP,mBAAgB;AAAA,IAClB;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,QAAM,aAAaC,WAAAA,YAAY,MAAM,SAAS,IAAI,GAAG,CAAA,CAAE;AAEvD,QAAM,SAASA,WAAAA;AAAAA,IACb,OAAO,UAA4C;;AACjD,UAAI,MAAM,WAAW,EAAG,QAAO,CAAA;AAG/B,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,OAAO,eAAe;AAC7B,gBAAM,MAAM,SAAS,KAAK,IAAI;AAC9B,mBAAS,GAAG;AACZ,gBAAM,IAAI,MAAM,GAAG;AAAA,QACrB;AAAA,MACF;AAEA,qBAAe,IAAI;AACnB,eAAS,IAAI;AACb,kBAAY,EAAE,SAAS,GAAG,OAAO,MAAM,QAAQ,YAAU,WAAM,CAAC,MAAP,mBAAU,SAAQ,IAAI,SAAS,GAAG;AAE3F,UAAI;AACF,cAAM,WAAW,IAAI,SAAA;AACrB,mBAAW,QAAQ,OAAO;AACxB,mBAAS,OAAO,SAAS,MAAM,KAAK,IAAI;AAAA,QA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AI;AAAA,MAClB;AAAA,IACF;AAAA,IACA,CAAC,YAAY,MAAM;AAAA,EAAA;AAGrB,SAAO,EAAE,QAAQ,aAAa,UAAU,OAAO,WAAA;AACjD;;"}
|
|
1
|
+
{"version":3,"file":"useFileUpload.cjs","sources":["../../src/composer/useFileUpload.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { MentionAuthContext } from '../chat-ui/mentions/suggestions/data/api-client';\nimport { useAthenaConfig } from '../provider/AthenaContext';\nimport {\n FOLDER_UPLOAD_PATH,\n folderUploadResultOf,\n startFolderUpload,\n waitForFolderUploadTask,\n} from './folder-upload';\n\nexport interface UploadedAsset {\n id: string;\n title: string;\n fileName: string;\n fileSize: number;\n mediaType: string;\n /**\n * The position, in the batch `upload` was given, of the file this asset was\n * uploaded from (the upload's `success_file_indexes`; absent from a server\n * that does not send them).\n */\n fileIndex?: number;\n /**\n * A local `blob:` URL of the picture this attachment was uploaded from, for\n * the composer's thumbnail and full-screen viewer. Set by the composer's\n * intake for image files, and revoked when the draft lets the attachment go.\n */\n previewUrl?: string;\n}\n\nexport interface UploadProgress {\n current: number;\n total: number;\n fileName: string;\n /** 0–1 normalized progress for the current file */\n percent: number;\n}\n\n/** A file Athena refused while it took others from the same upload, with its reason. */\nexport interface UploadRefusal {\n fileName: string;\n error: string;\n}\n\nexport interface UploadOptions {\n /**\n * The folder the files go into. agora's async upload takes them there, and refuses the whole\n * upload, before it takes any file, unless the person may edit that folder. Without one they are\n * filed at the workspace's root, as before.\n */\n parentFolderId?: string | null;\n /**\n * Hears the files Athena refused when it took others from the same upload, before `upload`\n * resolves with the ones it took (the hook's `error` says the same, as one line). An upload that\n * took none rejects instead.\n */\n onFilesRefused?: (refused: readonly UploadRefusal[]) => void;\n}\n\nexport interface UseFileUploadReturn {\n /** Upload one or more files to Athena (into a folder, `parentFolderId`). Returns the created asset(s). */\n upload: (files: File[], options?: UploadOptions) => Promise<UploadedAsset[]>;\n /** Whether an upload is currently in progress. */\n isUploading: boolean;\n /** Upload progress info (null when idle). */\n progress: UploadProgress | null;\n /** Last upload error (null when no error). */\n error: string | null;\n /** Clear the error state. */\n clearError: () => void;\n}\n\nconst MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024; // 5 GB\n\n/**\n * Hook for uploading files to the Athena platform via the Athena upload endpoint.\n * Files become Athena assets (documents, spreadsheets, PDFs, images, etc.).\n *\n * Usage:\n * const { upload, isUploading, progress, error } = useFileUpload();\n * const assets = await upload(fileList);\n */\nexport function useFileUpload(): UseFileUploadReturn {\n const config = useAthenaConfig();\n // Keep config in a ref so upload() always reads the latest token at call\n // time. AthenaConfig's token is a getter that returns the current value\n // from PropelAuth, and reading via the ref avoids capturing stale\n // destructured values in the useCallback closure.\n const configRef = useRef(config);\n configRef.current = config;\n const { backendUrl, apiKey } = config;\n const [isUploading, setIsUploading] = useState(false);\n const [progress, setProgress] = useState<UploadProgress | null>(null);\n const [error, setError] = useState<string | null>(null);\n const xhrRef = useRef<XMLHttpRequest | null>(null);\n // An upload into a folder reads its task until it ends: let go of it when the component goes.\n const taskWaitRef = useRef<AbortController | null>(null);\n\n // Abort any in-flight upload when the component unmounts\n useEffect(() => {\n return () => {\n xhrRef.current?.abort();\n taskWaitRef.current?.abort();\n };\n }, []);\n\n const clearError = useCallback(() => setError(null), []);\n\n /**\n * Into a folder: agora's async upload (`POST /api/upload/async` with `parent_folder_id`, which\n * authorizes EDIT on the folder before it takes a file), its bytes' progress reported as the\n * quick upload's is, then its task read until it ends (`folder-upload.ts`).\n */\n const uploadIntoFolder = useCallback(\n async ({\n files,\n parentFolderId,\n baseUrl,\n headers,\n currentToken,\n }: {\n files: File[];\n parentFolderId: string;\n baseUrl: string;\n headers: Record<string, string>;\n currentToken: string | null | undefined;\n }): Promise<{ uploaded: UploadedAsset[]; refused: UploadRefusal[] }> => {\n const send = (form: FormData) =>\n new Promise<Response>((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n xhr.upload.addEventListener('progress', (e) => {\n if (!e.lengthComputable) return;\n const percent = e.loaded / e.total;\n const fileIndex = Math.min(Math.floor(percent * files.length), files.length - 1);\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n });\n xhr.addEventListener('load', () =>\n resolve(new Response(xhr.responseText, { status: xhr.status })),\n );\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n xhr.open('POST', `${baseUrl}${FOLDER_UPLOAD_PATH}`);\n for (const [key, value] of Object.entries(headers)) xhr.setRequestHeader(key, value);\n xhr.withCredentials = !currentToken && !configRef.current.apiKey;\n xhr.send(form);\n });\n const taskId = await startFolderUpload({ send, files, parentFolderId });\n const config = configRef.current;\n const auth: MentionAuthContext = {\n backendUrl: baseUrl,\n appUrl: config.appUrl,\n apiKey: config.apiKey,\n credentials: 'include',\n get accessToken() {\n return configRef.current.token ?? undefined;\n },\n getAccessToken: async () => (await configRef.current.getToken?.()) ?? undefined,\n renewAccessToken: async () =>\n (await configRef.current.getToken?.({ force: true })) ?? undefined,\n };\n const waiting = new AbortController();\n taskWaitRef.current = waiting;\n try {\n const task = await waitForFolderUploadTask({ auth, taskId, signal: waiting.signal });\n const { uploaded, failed } = folderUploadResultOf({ task, files });\n if (failed.length > 0) {\n const errMsg = failed.map((entry) => `${entry.fileName}: ${entry.error}`).join('; ');\n setError(errMsg);\n if (uploaded.length === 0) throw new Error(errMsg);\n }\n return { uploaded, refused: failed };\n } finally {\n if (taskWaitRef.current === waiting) taskWaitRef.current = null;\n }\n },\n [],\n );\n\n const upload = useCallback(\n async (files: File[], options: UploadOptions = {}): Promise<UploadedAsset[]> => {\n if (files.length === 0) return [];\n\n // Validate file sizes\n for (const file of files) {\n if (file.size > MAX_FILE_SIZE) {\n const msg = `File \"${file.name}\" exceeds the maximum size of 5 GB.`;\n setError(msg);\n throw new Error(msg);\n }\n }\n\n setIsUploading(true);\n setError(null);\n setProgress({ current: 0, total: files.length, fileName: files[0]?.name ?? '', percent: 0 });\n\n try {\n // Derive the upload URL from the configured Athena backend URL.\n // If backendUrl points at a nested Athena endpoint, trim it back to the API base first.\n const baseUrl = backendUrl.replace(/\\/api\\/assistant-ui\\/?$/, '');\n const uploadUrl = `${baseUrl}/api/upload/`;\n\n // Read the current token at call time so rotated tokens are picked up.\n const currentToken = configRef.current.token;\n const headers: Record<string, string> = {};\n if (currentToken) {\n headers['Authorization'] = `Bearer ${currentToken}`;\n } else if (apiKey) {\n headers['X-API-KEY'] = apiKey;\n }\n\n const { parentFolderId, onFilesRefused } = options;\n if (parentFolderId) {\n const { uploaded, refused } = await uploadIntoFolder({\n files,\n parentFolderId,\n baseUrl,\n headers,\n currentToken,\n });\n if (refused.length > 0) onFilesRefused?.(refused);\n return uploaded;\n }\n\n const formData = new FormData();\n for (const file of files) {\n formData.append('files', file, file.name);\n }\n\n const xhr = new XMLHttpRequest();\n xhrRef.current = xhr;\n\n const result = await new Promise<{ success: UploadedAsset[]; errors: Array<{ file: { filename: string }; error: string }> }>((resolve, reject) => {\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n const percent = e.loaded / e.total;\n // Estimate which file we're on based on progress\n const fileIndex = Math.min(\n Math.floor(percent * files.length),\n files.length - 1,\n );\n setProgress({\n current: fileIndex + 1,\n total: files.length,\n fileName: files[fileIndex]?.name ?? '',\n percent,\n });\n }\n });\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n const data = JSON.parse(xhr.responseText);\n const fileIndexes: unknown = data.success_file_indexes;\n const assets: UploadedAsset[] = (data.success ?? []).map((a: Record<string, unknown>, at: number) => {\n const fileIndex = Array.isArray(fileIndexes) ? fileIndexes[at] : undefined;\n return {\n id: a.id as string,\n title: (a.title ?? a.file_name) as string,\n fileName: a.file_name as string,\n fileSize: a.file_size as number,\n mediaType: a.media_type as string,\n ...(typeof fileIndex === 'number' && { fileIndex }),\n };\n });\n resolve({ success: assets, errors: data.errors ?? [] });\n } catch {\n reject(new Error('Failed to parse upload response'));\n }\n } else if (xhr.status === 401 || xhr.status === 403) {\n reject(new Error('Authentication failed. Check your API key or token.'));\n } else {\n reject(new Error(`Upload failed with status ${xhr.status}`));\n }\n });\n\n xhr.addEventListener('error', () => reject(new Error('Network error during upload')));\n xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')));\n\n xhr.open('POST', uploadUrl);\n for (const [key, value] of Object.entries(headers)) {\n xhr.setRequestHeader(key, value);\n }\n xhr.withCredentials = !currentToken && !apiKey;\n xhr.send(formData);\n });\n\n if (result.errors.length > 0) {\n const errMsg = result.errors.map((e) => `${e.file.filename}: ${e.error}`).join('; ');\n if (result.success.length === 0) {\n setError(errMsg);\n throw new Error(errMsg);\n }\n // Partial success — set error but still return successful uploads\n setError(errMsg);\n onFilesRefused?.(\n result.errors.map((e) => ({ fileName: e.file.filename, error: e.error })),\n );\n }\n\n return result.success;\n } catch (err) {\n const msg = err instanceof Error ? err.message : 'Upload failed';\n setError(msg);\n throw err;\n } finally {\n xhrRef.current = null;\n setIsUploading(false);\n setProgress(null);\n }\n },\n [backendUrl, apiKey, uploadIntoFolder],\n );\n\n return { upload, isUploading, progress, error, clearError };\n}\n"],"names":["useAthenaConfig","useRef","useState","useEffect","useCallback","FOLDER_UPLOAD_PATH","startFolderUpload","config","waitForFolderUploadTask","folderUploadResultOf","_a"],"mappings":";;;;;AAwEA,MAAM,gBAAgB,IAAI,OAAO,OAAO;AAUjC,SAAS,gBAAqC;AACnD,QAAM,SAASA,cAAAA,gBAAA;AAKf,QAAM,YAAYC,WAAAA,OAAO,MAAM;AAC/B,YAAU,UAAU;AACpB,QAAM,EAAE,YAAY,OAAA,IAAW;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAIC,WAAAA,SAAS,KAAK;AACpD,QAAM,CAAC,UAAU,WAAW,IAAIA,WAAAA,SAAgC,IAAI;AACpE,QAAM,CAAC,OAAO,Q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I,MAAM,6BAA6B,CAAC,CAAC;AACpF,cAAI,iBAAiB,SAAS,MAAM,OAAO,IAAI,MAAM,sBAAsB,CAAC,CAAC;AAE7E,cAAI,KAAK,QAAQ,SAAS;AAC1B,qBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,gBAAI,iBAAiB,KAAK,KAAK;AAAA,UACjC;AACA,cAAI,kBAAkB,CAAC,gBAAgB,CAAC;AACxC,cAAI,KAAK,QAAQ;AAAA,QACnB,CAAC;AAED,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,gBAAM,SAAS,OAAO,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,QAAQ,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,IAAI;AACnF,cAAI,OAAO,QAAQ,WAAW,GAAG;AAC/B,qBAAS,MAAM;AACf,kBAAM,IAAI,MAAM,MAAM;AAAA,UACxB;AAEA,mBAAS,MAAM;AACf;AAAA,YACE,OAAO,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,OAAO,EAAE,QAAQ;AAAA;AAAA,QAE5E;AAEA,eAAO,OAAO;AAAA,MAChB,SAAS,KAAK;AACZ,cAAM,MAAM,eAAe,QAAQ,IAAI,UAAU;AACjD,iBAAS,GAAG;AACZ,cAAM;AAAA,MACR,UAAA;AACE,eAAO,UAAU;AACjB,uBAAe,KAAK;AACpB,oBAAY,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,IACA,CAAC,YAAY,QAAQ,gBAAgB;AAAA,EAAA;AAGvC,SAAO,EAAE,QAAQ,aAAa,UAAU,OAAO,WAAA;AACjD;;"}
|
|
@@ -24,9 +24,28 @@ export interface UploadProgress {
|
|
|
24
24
|
/** 0–1 normalized progress for the current file */
|
|
25
25
|
percent: number;
|
|
26
26
|
}
|
|
27
|
+
/** A file Athena refused while it took others from the same upload, with its reason. */
|
|
28
|
+
export interface UploadRefusal {
|
|
29
|
+
fileName: string;
|
|
30
|
+
error: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UploadOptions {
|
|
33
|
+
/**
|
|
34
|
+
* The folder the files go into. agora's async upload takes them there, and refuses the whole
|
|
35
|
+
* upload, before it takes any file, unless the person may edit that folder. Without one they are
|
|
36
|
+
* filed at the workspace's root, as before.
|
|
37
|
+
*/
|
|
38
|
+
parentFolderId?: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Hears the files Athena refused when it took others from the same upload, before `upload`
|
|
41
|
+
* resolves with the ones it took (the hook's `error` says the same, as one line). An upload that
|
|
42
|
+
* took none rejects instead.
|
|
43
|
+
*/
|
|
44
|
+
onFilesRefused?: (refused: readonly UploadRefusal[]) => void;
|
|
45
|
+
}
|
|
27
46
|
export interface UseFileUploadReturn {
|
|
28
|
-
/** Upload one or more files to Athena. Returns the created asset(s). */
|
|
29
|
-
upload: (files: File[]) => Promise<UploadedAsset[]>;
|
|
47
|
+
/** Upload one or more files to Athena (into a folder, `parentFolderId`). Returns the created asset(s). */
|
|
48
|
+
upload: (files: File[], options?: UploadOptions) => Promise<UploadedAsset[]>;
|
|
30
49
|
/** Whether an upload is currently in progress. */
|
|
31
50
|
isUploading: boolean;
|
|
32
51
|
/** Upload progress info (null when idle). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRef, useState, useEffect, useCallback } from "react";
|
|
2
2
|
import { useAthenaConfig } from "../provider/AthenaContext.js";
|
|
3
|
+
import { startFolderUpload, waitForFolderUploadTask, folderUploadResultOf, FOLDER_UPLOAD_PATH } from "./folder-upload.js";
|
|
3
4
|
const MAX_FILE_SIZE = 5 * 1024 * 1024 * 1024;
|
|
4
5
|
function useFileUpload() {
|
|
5
6
|
const config = useAthenaConfig();
|
|
@@ -10,15 +11,87 @@ function useFileUpload() {
|
|
|
10
11
|
const [progress, setProgress] = useState(null);
|
|
11
12
|
const [error, setError] = useState(null);
|
|
12
13
|
const xhrRef = useRef(null);
|
|
14
|
+
const taskWaitRef = useRef(null);
|
|
13
15
|
useEffect(() => {
|
|
14
16
|
return () => {
|
|
15
|
-
var _a;
|
|
17
|
+
var _a, _b;
|
|
16
18
|
(_a = xhrRef.current) == null ? void 0 : _a.abort();
|
|
19
|
+
(_b = taskWaitRef.current) == null ? void 0 : _b.abort();
|
|
17
20
|
};
|
|
18
21
|
}, []);
|
|
19
22
|
const clearError = useCallback(() => setError(null), []);
|
|
23
|
+
const uploadIntoFolder = useCallback(
|
|
24
|
+
async ({
|
|
25
|
+
files,
|
|
26
|
+
parentFolderId,
|
|
27
|
+
baseUrl,
|
|
28
|
+
headers,
|
|
29
|
+
currentToken
|
|
30
|
+
}) => {
|
|
31
|
+
const send = (form) => new Promise((resolve, reject) => {
|
|
32
|
+
const xhr = new XMLHttpRequest();
|
|
33
|
+
xhrRef.current = xhr;
|
|
34
|
+
xhr.upload.addEventListener("progress", (e) => {
|
|
35
|
+
var _a;
|
|
36
|
+
if (!e.lengthComputable) return;
|
|
37
|
+
const percent = e.loaded / e.total;
|
|
38
|
+
const fileIndex = Math.min(Math.floor(percent * files.length), files.length - 1);
|
|
39
|
+
setProgress({
|
|
40
|
+
current: fileIndex + 1,
|
|
41
|
+
total: files.length,
|
|
42
|
+
fileName: ((_a = files[fileIndex]) == null ? void 0 : _a.name) ?? "",
|
|
43
|
+
percent
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
xhr.addEventListener(
|
|
47
|
+
"load",
|
|
48
|
+
() => resolve(new Response(xhr.responseText, { status: xhr.status }))
|
|
49
|
+
);
|
|
50
|
+
xhr.addEventListener("error", () => reject(new Error("Network error during upload")));
|
|
51
|
+
xhr.addEventListener("abort", () => reject(new Error("Upload was cancelled")));
|
|
52
|
+
xhr.open("POST", `${baseUrl}${FOLDER_UPLOAD_PATH}`);
|
|
53
|
+
for (const [key, value] of Object.entries(headers)) xhr.setRequestHeader(key, value);
|
|
54
|
+
xhr.withCredentials = !currentToken && !configRef.current.apiKey;
|
|
55
|
+
xhr.send(form);
|
|
56
|
+
});
|
|
57
|
+
const taskId = await startFolderUpload({ send, files, parentFolderId });
|
|
58
|
+
const config2 = configRef.current;
|
|
59
|
+
const auth = {
|
|
60
|
+
backendUrl: baseUrl,
|
|
61
|
+
appUrl: config2.appUrl,
|
|
62
|
+
apiKey: config2.apiKey,
|
|
63
|
+
credentials: "include",
|
|
64
|
+
get accessToken() {
|
|
65
|
+
return configRef.current.token ?? void 0;
|
|
66
|
+
},
|
|
67
|
+
getAccessToken: async () => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
return await ((_b = (_a = configRef.current).getToken) == null ? void 0 : _b.call(_a)) ?? void 0;
|
|
70
|
+
},
|
|
71
|
+
renewAccessToken: async () => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return await ((_b = (_a = configRef.current).getToken) == null ? void 0 : _b.call(_a, { force: true })) ?? void 0;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const waiting = new AbortController();
|
|
77
|
+
taskWaitRef.current = waiting;
|
|
78
|
+
try {
|
|
79
|
+
const task = await waitForFolderUploadTask({ auth, taskId, signal: waiting.signal });
|
|
80
|
+
const { uploaded, failed } = folderUploadResultOf({ task, files });
|
|
81
|
+
if (failed.length > 0) {
|
|
82
|
+
const errMsg = failed.map((entry) => `${entry.fileName}: ${entry.error}`).join("; ");
|
|
83
|
+
setError(errMsg);
|
|
84
|
+
if (uploaded.length === 0) throw new Error(errMsg);
|
|
85
|
+
}
|
|
86
|
+
return { uploaded, refused: failed };
|
|
87
|
+
} finally {
|
|
88
|
+
if (taskWaitRef.current === waiting) taskWaitRef.current = null;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
[]
|
|
92
|
+
);
|
|
20
93
|
const upload = useCallback(
|
|
21
|
-
async (files) => {
|
|
94
|
+
async (files, options = {}) => {
|
|
22
95
|
var _a;
|
|
23
96
|
if (files.length === 0) return [];
|
|
24
97
|
for (const file of files) {
|
|
@@ -32,10 +105,6 @@ function useFileUpload() {
|
|
|
32
105
|
setError(null);
|
|
33
106
|
setProgress({ current: 0, total: files.length, fileName: ((_a = files[0]) == null ? void 0 : _a.name) ?? "", percent: 0 });
|
|
34
107
|
try {
|
|
35
|
-
const formData = new FormData();
|
|
36
|
-
for (const file of files) {
|
|
37
|
-
formData.append("files", file, file.name);
|
|
38
|
-
}
|
|
39
108
|
const baseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
40
109
|
const uploadUrl = `${baseUrl}/api/upload/`;
|
|
41
110
|
const currentToken = configRef.current.token;
|
|
@@ -45,6 +114,22 @@ function useFileUpload() {
|
|
|
45
114
|
} else if (apiKey) {
|
|
46
115
|
headers["X-API-KEY"] = apiKey;
|
|
47
116
|
}
|
|
117
|
+
const { parentFolderId, onFilesRefused } = options;
|
|
118
|
+
if (parentFolderId) {
|
|
119
|
+
const { uploaded, refused } = await uploadIntoFolder({
|
|
120
|
+
files,
|
|
121
|
+
parentFolderId,
|
|
122
|
+
baseUrl,
|
|
123
|
+
headers,
|
|
124
|
+
currentToken
|
|
125
|
+
});
|
|
126
|
+
if (refused.length > 0) onFilesRefused == null ? void 0 : onFilesRefused(refused);
|
|
127
|
+
return uploaded;
|
|
128
|
+
}
|
|
129
|
+
const formData = new FormData();
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
formData.append("files", file, file.name);
|
|
132
|
+
}
|
|
48
133
|
const xhr = new XMLHttpRequest();
|
|
49
134
|
xhrRef.current = xhr;
|
|
50
135
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -106,6 +191,9 @@ function useFileUpload() {
|
|
|
106
191
|
throw new Error(errMsg);
|
|
107
192
|
}
|
|
108
193
|
setError(errMsg);
|
|
194
|
+
onFilesRefused == null ? void 0 : onFilesRefused(
|
|
195
|
+
result.errors.map((e) => ({ fileName: e.file.filename, error: e.error }))
|
|
196
|
+
);
|
|
109
197
|
}
|
|
110
198
|
return result.success;
|
|
111
199
|
} catch (err) {
|
|
@@ -118,7 +206,7 @@ function useFileUpload() {
|
|
|
118
206
|
setProgress(null);
|
|
119
207
|
}
|
|
120
208
|
},
|
|
121
|
-
[backendUrl, apiKey]
|
|
209
|
+
[backendUrl, apiKey, uploadIntoFolder]
|
|
122
210
|
);
|
|
123
211
|
return { upload, isUploading, progress, error, clearError };
|
|
124
212
|
}
|