@athenaintel/react 0.41.3 → 0.42.2
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 +132 -10
- package/dist/agent-runtime/src/asset-attachment.d.ts +98 -0
- package/dist/agent-runtime/src/athena-asset-drag.d.ts +32 -0
- package/dist/agent-runtime/src/auth-denial.d.ts +29 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.cjs +41 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +38 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.js +41 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-signals.cjs +63 -0
- package/dist/agent-runtime/src/chat-outbox-signals.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-signals.d.ts +12 -0
- package/dist/agent-runtime/src/chat-outbox-signals.js +63 -0
- package/dist/agent-runtime/src/chat-outbox-signals.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-store.cjs +509 -0
- package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-store.d.ts +203 -0
- package/dist/agent-runtime/src/chat-outbox-store.js +509 -0
- package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-thread.cjs +136 -0
- package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-thread.d.ts +118 -0
- package/dist/agent-runtime/src/chat-outbox-thread.js +136 -0
- package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox.cjs +696 -0
- package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox.d.ts +285 -0
- package/dist/agent-runtime/src/chat-outbox.js +696 -0
- package/dist/agent-runtime/src/chat-outbox.js.map +1 -0
- package/dist/agent-runtime/src/chat-socket-reachability.d.ts +45 -0
- package/dist/agent-runtime/src/client-tool-bridge.d.ts +152 -0
- package/dist/agent-runtime/src/client-tools.d.ts +133 -0
- package/dist/agent-runtime/src/composer-markdown.cjs +10 -0
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
- package/dist/agent-runtime/src/composer-markdown.d.ts +108 -0
- package/dist/agent-runtime/src/composer-markdown.js +10 -0
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
- package/dist/agent-runtime/src/config-mutations.d.ts +51 -0
- package/dist/agent-runtime/src/conversation-index.d.ts +110 -0
- package/dist/agent-runtime/src/conversation-list.d.ts +343 -0
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -2
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +166 -0
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -2
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/agent-runtime/src/desktop-handoff.d.ts +139 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
- package/dist/agent-runtime/src/edit-command.d.ts +156 -0
- package/dist/agent-runtime/src/errors.d.ts +174 -0
- package/dist/agent-runtime/src/execute-output.d.ts +31 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
- package/dist/agent-runtime/src/index.d.ts +74 -0
- package/dist/agent-runtime/src/interrupts.cjs +17 -0
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/agent-runtime/src/interrupts.d.ts +348 -0
- package/dist/agent-runtime/src/interrupts.js +17 -0
- package/dist/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
- package/dist/agent-runtime/src/lane-history.cjs +209 -0
- package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
- package/dist/agent-runtime/src/lane-history.d.ts +175 -0
- package/dist/agent-runtime/src/lane-history.js +209 -0
- package/dist/agent-runtime/src/lane-history.js.map +1 -0
- package/dist/agent-runtime/src/lane-images.d.ts +184 -0
- package/dist/agent-runtime/src/message-author.d.ts +43 -0
- package/dist/agent-runtime/src/message-text.cjs +15 -0
- package/dist/agent-runtime/src/message-text.cjs.map +1 -0
- package/dist/agent-runtime/src/message-text.d.ts +47 -0
- package/dist/agent-runtime/src/message-text.js +15 -0
- package/dist/agent-runtime/src/message-text.js.map +1 -0
- package/dist/agent-runtime/src/message-window.cjs +15 -1
- package/dist/agent-runtime/src/message-window.cjs.map +1 -1
- package/dist/agent-runtime/src/message-window.d.ts +159 -0
- package/dist/agent-runtime/src/message-window.js +16 -2
- package/dist/agent-runtime/src/message-window.js.map +1 -1
- package/dist/agent-runtime/src/messages.cjs +123 -8
- package/dist/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.d.ts +621 -0
- package/dist/agent-runtime/src/messages.js +123 -8
- package/dist/agent-runtime/src/messages.js.map +1 -1
- package/dist/agent-runtime/src/model-context.d.ts +22 -0
- package/dist/agent-runtime/src/offline-status.d.ts +157 -0
- package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
- package/dist/agent-runtime/src/protocol.cjs +12 -4
- package/dist/agent-runtime/src/protocol.cjs.map +1 -1
- package/dist/agent-runtime/src/protocol.d.ts +119 -0
- package/dist/agent-runtime/src/protocol.js +13 -5
- package/dist/agent-runtime/src/protocol.js.map +1 -1
- package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
- package/dist/agent-runtime/src/queue.d.ts +138 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +10 -0
- 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 +161 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js +10 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
- package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
- package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
- package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
- package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
- package/dist/agent-runtime/src/screen-point.d.ts +151 -0
- package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
- package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
- package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
- package/dist/agent-runtime/src/sealed-idb.js +112 -0
- package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
- package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
- package/dist/agent-runtime/src/session-lane-scope.cjs +25 -0
- package/dist/agent-runtime/src/session-lane-scope.cjs.map +1 -0
- package/dist/agent-runtime/src/session-lane-scope.d.ts +59 -0
- package/dist/agent-runtime/src/session-lane-scope.js +25 -0
- package/dist/agent-runtime/src/session-lane-scope.js.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
- package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
- package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
- package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
- package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
- package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
- package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
- package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
- package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
- package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
- package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
- package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
- package/dist/agent-runtime/src/subagents.cjs +253 -0
- package/dist/agent-runtime/src/subagents.cjs.map +1 -0
- package/dist/agent-runtime/src/subagents.d.ts +311 -0
- package/dist/agent-runtime/src/subagents.js +253 -0
- package/dist/agent-runtime/src/subagents.js.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
- package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
- package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
- package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
- package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +46 -117
- package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -1
- package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.js +17 -88
- package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -1
- package/dist/agent-runtime/src/thread-status.d.ts +53 -0
- package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
- package/dist/agent-runtime/src/tool-names.cjs +71 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-names.d.ts +67 -0
- package/dist/agent-runtime/src/tool-names.js +72 -1
- package/dist/agent-runtime/src/tool-names.js.map +1 -1
- package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
- package/dist/agent-runtime/src/tool-result.cjs +1 -0
- package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-result.d.ts +126 -0
- package/dist/agent-runtime/src/tool-result.js +1 -0
- package/dist/agent-runtime/src/tool-result.js.map +1 -1
- package/dist/agent-runtime/src/types.d.ts +159 -0
- package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +37 -2
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +177 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js +38 -3
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +39 -13
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +352 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.js +39 -13
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs +1019 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.js +1019 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
- package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
- package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
- package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
- package/dist/agent-runtime/src/voice-presentation.js +2 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
- package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
- package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
- package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
- package/dist/catalog/runtime-catalog.js +1 -1
- package/dist/chat/AthenaChat.cjs +192 -103
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +9 -0
- package/dist/chat/AthenaChat.js +194 -105
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +1 -1
- package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +11 -4
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
- package/dist/chat/StatewireQueuedMessages.js +11 -4
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/chat-outbox-rows.cjs +223 -0
- package/dist/chat/chat-outbox-rows.cjs.map +1 -0
- package/dist/chat/chat-outbox-rows.d.ts +29 -0
- package/dist/chat/chat-outbox-rows.js +223 -0
- package/dist/chat/chat-outbox-rows.js.map +1 -0
- package/dist/chat/chat-voice-controls.cjs +128 -0
- package/dist/chat/chat-voice-controls.cjs.map +1 -0
- package/dist/chat/chat-voice-controls.d.ts +19 -0
- package/dist/chat/chat-voice-controls.js +128 -0
- package/dist/chat/chat-voice-controls.js.map +1 -0
- package/dist/chat/statewire-approval.d.ts +1 -1
- package/dist/chat/statewire-client-tools.d.ts +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
- package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +15 -8
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +18 -8
- package/dist/chat/super-grouping/activity-timeline.js +15 -8
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +36 -0
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +49 -1
- package/dist/chat/use-statewire-approval-request.js +39 -3
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +133 -14
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +33 -1
- package/dist/chat-ui/composer/tiptap-composer.js +135 -16
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
- package/dist/chat-ui/index.d.ts +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +29 -51
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +2 -2
- package/dist/chat-ui/mentions/use-account-workspace-id.js +30 -52
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +15 -0
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.js +15 -0
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
- package/dist/chat-ui/messages/user-edit-composer.js +15 -2
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +1 -0
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +2 -2
- package/dist/chat-ui/statewire.js +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.cjs +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
- package/dist/chat-ui/thread/composer-send-or-stop.d.ts +2 -0
- package/dist/chat-ui/thread/composer-send-or-stop.js +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
- package/dist/composer/AttachmentContext.cjs +8 -4
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.d.ts +7 -0
- package/dist/composer/AttachmentContext.js +8 -4
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/build-composed-message.cjs +34 -0
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +20 -0
- package/dist/composer/build-composed-message.js +35 -1
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +39 -2
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +28 -3
- package/dist/composer/composer-handoff.js +39 -2
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/useAttachFiles.cjs +15 -2
- package/dist/composer/useAttachFiles.cjs.map +1 -1
- package/dist/composer/useAttachFiles.d.ts +11 -0
- package/dist/composer/useAttachFiles.js +15 -2
- package/dist/composer/useAttachFiles.js.map +1 -1
- package/dist/composer/useSendMessage.cjs.map +1 -1
- package/dist/composer/useSendMessage.d.ts +4 -3
- package/dist/composer/useSendMessage.js.map +1 -1
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/offline/chat-outbox.cjs +57 -0
- package/dist/offline/chat-outbox.cjs.map +1 -0
- package/dist/offline/chat-outbox.d.ts +80 -0
- package/dist/offline/chat-outbox.js +57 -0
- package/dist/offline/chat-outbox.js.map +1 -0
- package/dist/offline/offline-history.d.ts +1 -1
- package/dist/provider/AthenaProvider.cjs +162 -8
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +15 -1
- package/dist/provider/AthenaProvider.js +163 -9
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/statewire-window-context.d.ts +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/references/src/anchors/file-line-range.d.ts +58 -0
- package/dist/references/src/anchors/format.d.ts +21 -0
- package/dist/references/src/anchors/message-anchors.d.ts +71 -0
- package/dist/references/src/anchors/parse.d.ts +8 -0
- package/dist/references/src/anchors/registry-contract.d.ts +24 -0
- package/dist/references/src/anchors/registry.d.ts +19 -0
- package/dist/references/src/anchors/schemas.d.ts +194 -0
- package/dist/references/src/anchors/serialize.d.ts +8 -0
- package/dist/references/src/anchors/time.d.ts +78 -0
- package/dist/references/src/anchors/types.d.ts +474 -0
- package/dist/references/src/asset-bounds.d.ts +27 -0
- package/dist/references/src/asset-links.d.ts +23 -0
- package/dist/references/src/asset-reference.d.ts +16 -0
- package/dist/references/src/formats/format-catalog.d.ts +79 -0
- package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
- package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
- package/dist/references/src/formats/object/asset-object.d.ts +9 -0
- package/dist/references/src/formats/object/callable-object.d.ts +6 -0
- package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
- package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
- package/dist/references/src/formats/object/group-object.d.ts +9 -0
- package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
- package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
- package/dist/references/src/formats/object/person-object.d.ts +9 -0
- package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
- package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
- package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
- package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
- package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
- package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
- package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
- package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
- package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
- package/dist/references/src/index.d.ts +47 -0
- package/dist/references/src/legacy/index.d.ts +14 -0
- package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
- package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
- package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
- package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
- package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
- package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
- package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
- package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
- package/dist/references/src/legacy.d.ts +2 -0
- package/dist/references/src/mention-href-patterns.d.ts +19 -0
- package/dist/references/src/mention-node/index.d.ts +5 -0
- package/dist/references/src/mention-node/mention-node.d.ts +31 -0
- package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
- package/dist/references/src/parse-reference.d.ts +23 -0
- package/dist/references/src/schemas.d.ts +463 -0
- package/dist/references/src/serialize-reference.d.ts +50 -0
- package/dist/references/src/sheet-name.d.ts +10 -0
- package/dist/references/src/tool-option-schemas.d.ts +597 -0
- package/dist/references/src/types.d.ts +125 -0
- package/dist/references/src/version-ref.d.ts +30 -0
- package/dist/runtime/statewire-lifecycle.d.ts +1 -1
- package/dist/runtime/statewire-model-lane.d.ts +1 -1
- package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
- package/dist/runtime/statewire-session-key.cjs +7 -0
- package/dist/runtime/statewire-session-key.cjs.map +1 -1
- package/dist/runtime/statewire-session-key.d.ts +19 -0
- package/dist/runtime/statewire-session-key.js +8 -1
- package/dist/runtime/statewire-session-key.js.map +1 -1
- package/dist/runtime/statewire-session-lane.cjs +48 -0
- package/dist/runtime/statewire-session-lane.cjs.map +1 -0
- package/dist/runtime/statewire-session-lane.d.ts +29 -0
- package/dist/runtime/statewire-session-lane.js +48 -0
- package/dist/runtime/statewire-session-lane.js.map +1 -0
- package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +19 -5
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +20 -6
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/api.d.ts +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +1 -1
- package/dist/threads/index-triggered-refresh.cjs +164 -0
- package/dist/threads/index-triggered-refresh.cjs.map +1 -0
- package/dist/threads/index-triggered-refresh.d.ts +70 -0
- package/dist/threads/index-triggered-refresh.js +164 -0
- package/dist/threads/index-triggered-refresh.js.map +1 -0
- package/dist/threads/offline-session-list.d.ts +1 -1
- package/dist/threads/pull-request-display.d.ts +1 -1
- package/dist/threads/session-list-model.d.ts +1 -1
- package/dist/threads/session-list-tab-share.cjs +150 -0
- package/dist/threads/session-list-tab-share.cjs.map +1 -0
- package/dist/threads/session-list-tab-share.d.ts +73 -0
- package/dist/threads/session-list-tab-share.js +150 -0
- package/dist/threads/session-list-tab-share.js.map +1 -0
- package/dist/threads/session-row-parts.d.ts +1 -1
- package/dist/threads/sessions-query.d.ts +1 -1
- package/dist/threads/statewire-thread-list.cjs +42 -16
- 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 +43 -17
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/thread-prefetcher.d.ts +1 -1
- package/dist/threads/use-athena-session-attention.d.ts +1 -1
- package/dist/threads/use-athena-sessions.cjs +32 -22
- package/dist/threads/use-athena-sessions.cjs.map +1 -1
- package/dist/threads/use-athena-sessions.js +33 -23
- package/dist/threads/use-athena-sessions.js.map +1 -1
- package/dist/threads/use-rest-conversation-history.d.ts +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
- package/dist/tools/NestedPtcMessages.cjs +14 -9
- package/dist/tools/NestedPtcMessages.cjs.map +1 -1
- package/dist/tools/NestedPtcMessages.d.ts +9 -0
- package/dist/tools/NestedPtcMessages.js +6 -1
- package/dist/tools/NestedPtcMessages.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/primitives.d.ts +1 -1
- package/dist/tools/subagent-task-tool-ui.cjs +494 -0
- package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
- package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
- package/dist/tools/subagent-task-tool-ui.js +494 -0
- package/dist/tools/subagent-task-tool-ui.js.map +1 -0
- package/dist/tools/tool-fallback.d.ts +1 -1
- package/dist/tools/tool-icons.d.ts +1 -1
- package/dist/tools/tool-summary.d.ts +1 -1
- package/dist/tools/tool-uis.cjs +4 -0
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.js +4 -0
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/voice/chat.cjs +6 -0
- package/dist/voice/chat.cjs.map +1 -0
- package/dist/voice/chat.d.ts +2 -0
- package/dist/voice/chat.js +6 -0
- package/dist/voice/chat.js.map +1 -0
- package/dist/voice/livekit-join.cjs +119 -0
- package/dist/voice/livekit-join.cjs.map +1 -0
- package/dist/voice/livekit-join.d.ts +8 -0
- package/dist/voice/livekit-join.js +119 -0
- package/dist/voice/livekit-join.js.map +1 -0
- package/dist/voice/livekit.cjs +32 -0
- package/dist/voice/livekit.cjs.map +1 -0
- package/dist/voice/livekit.d.ts +80 -0
- package/dist/voice/livekit.js +32 -0
- package/dist/voice/livekit.js.map +1 -0
- package/dist/voice/use-chat-voice-enabled.cjs +43 -0
- package/dist/voice/use-chat-voice-enabled.cjs.map +1 -0
- package/dist/voice/use-chat-voice-enabled.d.ts +9 -0
- package/dist/voice/use-chat-voice-enabled.js +43 -0
- package/dist/voice/use-chat-voice-enabled.js.map +1 -0
- package/package.json +22 -16
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function extrasOf(state) {
|
|
4
|
+
const extras = state.extras;
|
|
5
|
+
return extras && typeof extras === "object" ? extras : null;
|
|
6
|
+
}
|
|
7
|
+
function idsOf(list, into) {
|
|
8
|
+
if (!Array.isArray(list)) return;
|
|
9
|
+
for (const item of list) {
|
|
10
|
+
const id = item == null ? void 0 : item.id;
|
|
11
|
+
if (typeof id === "string") into.add(id);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function chatOutboxHeldIds(state) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const held = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const message of state.messages ?? []) held.add(message.id);
|
|
18
|
+
const runs = (_a = extrasOf(state)) == null ? void 0 : _a.runs;
|
|
19
|
+
if (runs) {
|
|
20
|
+
idsOf(runs.queue, held);
|
|
21
|
+
idsOf(runs.steerQueue, held);
|
|
22
|
+
idsOf(runs.failed, held);
|
|
23
|
+
idsOf((_b = runs.dispatching) == null ? void 0 : _b.messages, held);
|
|
24
|
+
}
|
|
25
|
+
return held;
|
|
26
|
+
}
|
|
27
|
+
function chatOutboxReadiness(connection) {
|
|
28
|
+
if (!connection) return "connecting";
|
|
29
|
+
switch (connection.status) {
|
|
30
|
+
case "connected":
|
|
31
|
+
return "ready";
|
|
32
|
+
case "standby":
|
|
33
|
+
return connection.reason === "deferred" && typeof connection.message === "string" ? "refused" : "ready";
|
|
34
|
+
case "stopped":
|
|
35
|
+
return "refused";
|
|
36
|
+
default:
|
|
37
|
+
return "connecting";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function chatOutboxWireAnchorId(wireMessages) {
|
|
41
|
+
let fallback = null;
|
|
42
|
+
for (let index = wireMessages.length - 1; index >= 0; index -= 1) {
|
|
43
|
+
const message = wireMessages[index];
|
|
44
|
+
if (!message || typeof message.id !== "string" || message.id.length === 0) continue;
|
|
45
|
+
fallback ?? (fallback = message.id);
|
|
46
|
+
if (!message.ephemeral) return message.id;
|
|
47
|
+
}
|
|
48
|
+
return fallback;
|
|
49
|
+
}
|
|
50
|
+
function viewedLeafId(messages) {
|
|
51
|
+
var _a;
|
|
52
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
53
|
+
const message = messages[index];
|
|
54
|
+
if (message && ((_a = message.status) == null ? void 0 : _a.type) !== "running") return message.id;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function newRunId() {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const host = globalThis;
|
|
61
|
+
return ((_b = (_a = host.crypto) == null ? void 0 : _a.randomUUID) == null ? void 0 : _b.call(_a)) ?? `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
62
|
+
}
|
|
63
|
+
function chatOutboxWireMessage(entry) {
|
|
64
|
+
const files = (entry.files ?? []).map((file) => ({
|
|
65
|
+
type: "file",
|
|
66
|
+
mediaType: file.mediaType,
|
|
67
|
+
url: file.url,
|
|
68
|
+
...file.filename !== void 0 && { filename: file.filename }
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
id: entry.id,
|
|
72
|
+
role: "user",
|
|
73
|
+
parts: [...files, ...entry.text.length > 0 ? [{ type: "text", text: entry.text }] : []]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function buildChatOutboxSendCommand({
|
|
77
|
+
entry,
|
|
78
|
+
messages,
|
|
79
|
+
wireMessages,
|
|
80
|
+
runId,
|
|
81
|
+
isRunning
|
|
82
|
+
}) {
|
|
83
|
+
const message = chatOutboxWireMessage(entry);
|
|
84
|
+
if (isRunning && runId !== null) return { type: "run/enqueue", runId, message };
|
|
85
|
+
if (runId !== null) return { type: "run/steer", runId, message };
|
|
86
|
+
const runAnchorMessageId = wireMessages && wireMessages.length > 0 ? chatOutboxWireAnchorId(wireMessages) : viewedLeafId(messages);
|
|
87
|
+
return { type: "run/steer", runId: newRunId(), message, runAnchorMessageId };
|
|
88
|
+
}
|
|
89
|
+
function createStatewireChatOutboxPort({
|
|
90
|
+
client
|
|
91
|
+
}) {
|
|
92
|
+
const state = () => {
|
|
93
|
+
var _a;
|
|
94
|
+
return ((_a = client()) == null ? void 0 : _a.thread().getState()) ?? null;
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
readiness() {
|
|
98
|
+
var _a;
|
|
99
|
+
const current = state();
|
|
100
|
+
return current ? chatOutboxReadiness((_a = extrasOf(current)) == null ? void 0 : _a.connection) : "connecting";
|
|
101
|
+
},
|
|
102
|
+
heldIds() {
|
|
103
|
+
const current = state();
|
|
104
|
+
return current ? chatOutboxHeldIds(current) : /* @__PURE__ */ new Set();
|
|
105
|
+
},
|
|
106
|
+
send(entry) {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
const current = state();
|
|
109
|
+
const extras = current ? extrasOf(current) : null;
|
|
110
|
+
if (!current || typeof (extras == null ? void 0 : extras.sendCommand) !== "function") {
|
|
111
|
+
return Promise.reject(new Error("The conversation is not ready to send."));
|
|
112
|
+
}
|
|
113
|
+
const runId = typeof ((_a = extras.runs) == null ? void 0 : _a.runId) === "string" ? extras.runs.runId : null;
|
|
114
|
+
const wireMessages = (_b = extras.state) == null ? void 0 : _b.messages;
|
|
115
|
+
const command = buildChatOutboxSendCommand({
|
|
116
|
+
entry,
|
|
117
|
+
messages: current.messages ?? [],
|
|
118
|
+
wireMessages: Array.isArray(wireMessages) ? wireMessages : null,
|
|
119
|
+
runId,
|
|
120
|
+
isRunning: extras.status === "running"
|
|
121
|
+
});
|
|
122
|
+
return extras.sendCommand(command, { preparedMetadata: Promise.resolve(entry.metadata) });
|
|
123
|
+
},
|
|
124
|
+
subscribe(listener) {
|
|
125
|
+
const current = client();
|
|
126
|
+
return current ? current.subscribe(listener) : () => void 0;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
exports.buildChatOutboxSendCommand = buildChatOutboxSendCommand;
|
|
131
|
+
exports.chatOutboxHeldIds = chatOutboxHeldIds;
|
|
132
|
+
exports.chatOutboxReadiness = chatOutboxReadiness;
|
|
133
|
+
exports.chatOutboxWireAnchorId = chatOutboxWireAnchorId;
|
|
134
|
+
exports.chatOutboxWireMessage = chatOutboxWireMessage;
|
|
135
|
+
exports.createStatewireChatOutboxPort = createStatewireChatOutboxPort;
|
|
136
|
+
//# sourceMappingURL=chat-outbox-thread.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-outbox-thread.cjs","sources":["../../../../agent-runtime/src/chat-outbox-thread.ts"],"sourcesContent":["import type { ChatOutboxEntry } from \"./chat-outbox-store\";\nimport type { ChatOutboxThreadPort, ChatOutboxThreadReadiness } from \"./chat-outbox\";\n\n/**\n * The chat outbox's view of a statewire deep-agent thread (`chat-outbox.ts`): which message ids it\n * holds, whether a hand-off reaches it now, and the hand-off itself — the same `run/*` statement\n * the composer's own send makes, under the id the message was minted with when it was typed.\n */\n\n/** The imperative slice of an assistant-ui client the port reads (web and native `useAui` alike). */\nexport interface ChatOutboxClientHost {\n thread: () => {\n getState: () => {\n extras?: unknown;\n messages?: readonly { id: string; status?: { type: string } }[];\n };\n };\n subscribe: (listener: () => void) => () => void;\n}\n\ntype WireFilePart = { type: \"file\"; mediaType: string; url: string; filename?: string };\ntype WireTextPart = { type: \"text\"; text: string };\n\n/** The wire message an outbox entry is sent as (react-statewire's `UserMessage`, structurally). */\nexport interface ChatOutboxWireMessage {\n id: string;\n role: \"user\";\n parts: (WireFilePart | WireTextPart)[];\n metadata?: Record<string, unknown>;\n}\n\nexport type ChatOutboxSendCommand =\n | { type: \"run/enqueue\"; runId: string; message: ChatOutboxWireMessage }\n | {\n type: \"run/steer\";\n runId: string;\n message: ChatOutboxWireMessage;\n runAnchorMessageId?: string | null;\n };\n\ninterface RunsView {\n runId?: unknown;\n queue?: unknown;\n steerQueue?: unknown;\n failed?: unknown;\n dispatching?: { messages?: unknown } | null;\n}\n\ninterface StatewireExtrasView {\n runs?: RunsView;\n /** The composed thread state: its `messages` are the raw wire messages of the loaded window. */\n state?: { messages?: unknown } | null;\n status?: unknown;\n connection?: { status?: unknown; reason?: unknown; message?: unknown } | null;\n sendCommand?: (command: unknown, options?: { preparedMetadata?: Promise<unknown> }) => Promise<unknown>;\n}\n\nfunction extrasOf(state: { extras?: unknown }): StatewireExtrasView | null {\n const extras = state.extras;\n return extras && typeof extras === \"object\" ? (extras as StatewireExtrasView) : null;\n}\n\nfunction idsOf(list: unknown, into: Set<string>): void {\n if (!Array.isArray(list)) return;\n for (const item of list) {\n const id = (item as { id?: unknown } | null)?.id;\n if (typeof id === \"string\") into.add(id);\n }\n}\n\n/** The ids a statewire thread shows: transcript, lanes, the run being dispatched, failed sends. */\nexport function chatOutboxHeldIds(state: {\n extras?: unknown;\n messages?: readonly { id: string }[];\n}): Set<string> {\n const held = new Set<string>();\n for (const message of state.messages ?? []) held.add(message.id);\n const runs = extrasOf(state)?.runs;\n if (runs) {\n idsOf(runs.queue, held);\n idsOf(runs.steerQueue, held);\n idsOf(runs.failed, held);\n idsOf(runs.dispatching?.messages, held);\n }\n return held;\n}\n\n/** Whether a hand-off reaches the thread now, from its statewire connection. */\nexport function chatOutboxReadiness(connection: StatewireExtrasView[\"connection\"]): ChatOutboxThreadReadiness {\n if (!connection) return \"connecting\";\n switch (connection.status) {\n case \"connected\":\n return \"ready\";\n case \"standby\":\n // A never-started chat parks until its first send, and an idle channel reattaches on\n // demand; a park with a stated reason is the suspended transport (an authorization denial,\n // a host suspension), which never dials.\n return connection.reason === \"deferred\" && typeof connection.message === \"string\"\n ? \"refused\"\n : \"ready\";\n case \"stopped\":\n return \"refused\";\n default:\n return \"connecting\";\n }\n}\n\n/**\n * The anchor of a run a send mints, read from the raw wire messages the way the host computes its\n * own (`run_anchor_message_id`): the last durable message, else the trailing ephemeral one, else\n * none (an empty thread). The rendered messages do not line up with the host's transcript (an\n * assistant turn and its tool messages render as one message under the turn's first id, hidden\n * entries are dropped), so the raw list is what names the host's tail.\n */\nexport function chatOutboxWireAnchorId(wireMessages: readonly unknown[]): string | null {\n let fallback: string | null = null;\n for (let index = wireMessages.length - 1; index >= 0; index -= 1) {\n const message = wireMessages[index] as { id?: unknown; ephemeral?: unknown } | null | undefined;\n if (!message || typeof message.id !== \"string\" || message.id.length === 0) continue;\n fallback ??= message.id;\n if (!message.ephemeral) return message.id;\n }\n return fallback;\n}\n\n/** The last rendered message that is committed history (not a streaming answer). */\nfunction viewedLeafId(messages: readonly { id: string; status?: { type: string } }[]): string | null {\n for (let index = messages.length - 1; index >= 0; index -= 1) {\n const message = messages[index];\n if (message && message.status?.type !== \"running\") return message.id;\n }\n return null;\n}\n\nfunction newRunId(): string {\n const host = globalThis as { crypto?: { randomUUID?: () => string } };\n return host.crypto?.randomUUID?.() ?? `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** The wire message for an outbox entry: its files first, then one text part (react-statewire's shape). */\nexport function chatOutboxWireMessage(entry: ChatOutboxEntry): ChatOutboxWireMessage {\n const files: WireFilePart[] = (entry.files ?? []).map((file) => ({\n type: \"file\",\n mediaType: file.mediaType,\n url: file.url,\n ...(file.filename !== undefined && { filename: file.filename }),\n }));\n return {\n id: entry.id,\n role: \"user\",\n parts: [...files, ...(entry.text.length > 0 ? [{ type: \"text\" as const, text: entry.text }] : [])],\n };\n}\n\n/**\n * The statement the composer's own send would make now (`composer.send({ steer: false })`): a\n * queued follow-up behind a live run, otherwise a send that starts a run, anchored at the host's\n * tail as the raw wire messages name it ({@link chatOutboxWireAnchorId}); without them (a surface\n * whose state is not replicated yet), at the last rendered message, as the composer anchors.\n */\nexport function buildChatOutboxSendCommand({\n entry,\n messages,\n wireMessages,\n runId,\n isRunning,\n}: {\n entry: ChatOutboxEntry;\n messages: readonly { id: string; status?: { type: string } }[];\n /** The raw wire messages of the loaded window (`extras.state.messages`), when replicated. */\n wireMessages?: readonly unknown[] | null;\n runId: string | null;\n isRunning: boolean;\n}): ChatOutboxSendCommand {\n const message = chatOutboxWireMessage(entry);\n if (isRunning && runId !== null) return { type: \"run/enqueue\", runId, message };\n if (runId !== null) return { type: \"run/steer\", runId, message };\n const runAnchorMessageId =\n wireMessages && wireMessages.length > 0 ? chatOutboxWireAnchorId(wireMessages) : viewedLeafId(messages);\n return { type: \"run/steer\", runId: newRunId(), message, runAnchorMessageId };\n}\n\n/** A statewire thread, as the chat outbox's port. */\nexport function createStatewireChatOutboxPort({\n client,\n}: {\n /** Read on every call, so the port follows the host's current client. */\n client: () => ChatOutboxClientHost | null;\n}): ChatOutboxThreadPort {\n const state = () => client()?.thread().getState() ?? null;\n return {\n readiness() {\n const current = state();\n return current ? chatOutboxReadiness(extrasOf(current)?.connection) : \"connecting\";\n },\n heldIds() {\n const current = state();\n return current ? chatOutboxHeldIds(current) : new Set<string>();\n },\n send(entry) {\n const current = state();\n const extras = current ? extrasOf(current) : null;\n if (!current || typeof extras?.sendCommand !== \"function\") {\n return Promise.reject(new Error(\"The conversation is not ready to send.\"));\n }\n const runId = typeof extras.runs?.runId === \"string\" ? extras.runs.runId : null;\n const wireMessages = extras.state?.messages;\n const command = buildChatOutboxSendCommand({\n entry,\n messages: current.messages ?? [],\n wireMessages: Array.isArray(wireMessages) ? wireMessages : null,\n runId,\n isRunning: extras.status === \"running\",\n });\n // The metadata frozen when the message was typed rides as prepared metadata, so the\n // runtime's own capture (which reads what the composer staged for its next send) is not\n // consumed by a message typed earlier.\n return extras.sendCommand(command, { preparedMetadata: Promise.resolve(entry.metadata) });\n },\n subscribe(listener) {\n const current = client();\n return current ? current.subscribe(listener) : () => undefined;\n },\n };\n}\n"],"names":[],"mappings":";;AAyDA,SAAS,SAAS,OAAyD;AACzE,QAAM,SAAS,MAAM;AACrB,SAAO,UAAU,OAAO,WAAW,WAAY,SAAiC;AAClF;AAEA,SAAS,MAAM,MAAe,MAAyB;AACrD,MAAI,CAAC,MAAM,QAAQ,IAAI,EAAG;AAC1B,aAAW,QAAQ,MAAM;AACvB,UAAM,KAAM,6BAAkC;AAC9C,QAAI,OAAO,OAAO,SAAU,MAAK,IAAI,EAAE;AAAA,EACzC;AACF;AAGO,SAAS,kBAAkB,OAGlB;;AACd,QAAM,2BAAW,IAAA;AACjB,aAAW,WAAW,MAAM,YAAY,CAAA,EAAI,MAAK,IAAI,QAAQ,EAAE;AAC/D,QAAM,QAAO,cAAS,KAAK,MAAd,mBAAiB;AAC9B,MAAI,MAAM;AACR,UAAM,KAAK,OAAO,IAAI;AACtB,UAAM,KAAK,YAAY,IAAI;AAC3B,UAAM,KAAK,QAAQ,IAAI;AACvB,WAAM,UAAK,gBAAL,mBAAkB,UAAU,IAAI;AAAA,EACxC;AACA,SAAO;AACT;AAGO,SAAS,oBAAoB,YAA0E;AAC5G,MAAI,CAAC,WAAY,QAAO;AACxB,UAAQ,WAAW,QAAA;AAAA,IACjB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAIH,aAAO,WAAW,WAAW,cAAc,OAAO,WAAW,YAAY,WACrE,YACA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AASO,SAAS,uBAAuB,cAAiD;AACtF,MAAI,WAA0B;AAC9B,WAAS,QAAQ,aAAa,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;AAChE,UAAM,UAAU,aAAa,KAAK;AAClC,QAAI,CAAC,WAAW,OAAO,QAAQ,OAAO,YAAY,QAAQ,GAAG,WAAW,EAAG;AAC3E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";
|
|
2
|
+
import type { ChatOutboxThreadPort, ChatOutboxThreadReadiness } from "./chat-outbox";
|
|
3
|
+
/**
|
|
4
|
+
* The chat outbox's view of a statewire deep-agent thread (`chat-outbox.ts`): which message ids it
|
|
5
|
+
* holds, whether a hand-off reaches it now, and the hand-off itself — the same `run/*` statement
|
|
6
|
+
* the composer's own send makes, under the id the message was minted with when it was typed.
|
|
7
|
+
*/
|
|
8
|
+
/** The imperative slice of an assistant-ui client the port reads (web and native `useAui` alike). */
|
|
9
|
+
export interface ChatOutboxClientHost {
|
|
10
|
+
thread: () => {
|
|
11
|
+
getState: () => {
|
|
12
|
+
extras?: unknown;
|
|
13
|
+
messages?: readonly {
|
|
14
|
+
id: string;
|
|
15
|
+
status?: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
subscribe: (listener: () => void) => () => void;
|
|
22
|
+
}
|
|
23
|
+
type WireFilePart = {
|
|
24
|
+
type: "file";
|
|
25
|
+
mediaType: string;
|
|
26
|
+
url: string;
|
|
27
|
+
filename?: string;
|
|
28
|
+
};
|
|
29
|
+
type WireTextPart = {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
/** The wire message an outbox entry is sent as (react-statewire's `UserMessage`, structurally). */
|
|
34
|
+
export interface ChatOutboxWireMessage {
|
|
35
|
+
id: string;
|
|
36
|
+
role: "user";
|
|
37
|
+
parts: (WireFilePart | WireTextPart)[];
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export type ChatOutboxSendCommand = {
|
|
41
|
+
type: "run/enqueue";
|
|
42
|
+
runId: string;
|
|
43
|
+
message: ChatOutboxWireMessage;
|
|
44
|
+
} | {
|
|
45
|
+
type: "run/steer";
|
|
46
|
+
runId: string;
|
|
47
|
+
message: ChatOutboxWireMessage;
|
|
48
|
+
runAnchorMessageId?: string | null;
|
|
49
|
+
};
|
|
50
|
+
interface RunsView {
|
|
51
|
+
runId?: unknown;
|
|
52
|
+
queue?: unknown;
|
|
53
|
+
steerQueue?: unknown;
|
|
54
|
+
failed?: unknown;
|
|
55
|
+
dispatching?: {
|
|
56
|
+
messages?: unknown;
|
|
57
|
+
} | null;
|
|
58
|
+
}
|
|
59
|
+
interface StatewireExtrasView {
|
|
60
|
+
runs?: RunsView;
|
|
61
|
+
/** The composed thread state: its `messages` are the raw wire messages of the loaded window. */
|
|
62
|
+
state?: {
|
|
63
|
+
messages?: unknown;
|
|
64
|
+
} | null;
|
|
65
|
+
status?: unknown;
|
|
66
|
+
connection?: {
|
|
67
|
+
status?: unknown;
|
|
68
|
+
reason?: unknown;
|
|
69
|
+
message?: unknown;
|
|
70
|
+
} | null;
|
|
71
|
+
sendCommand?: (command: unknown, options?: {
|
|
72
|
+
preparedMetadata?: Promise<unknown>;
|
|
73
|
+
}) => Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
/** The ids a statewire thread shows: transcript, lanes, the run being dispatched, failed sends. */
|
|
76
|
+
export declare function chatOutboxHeldIds(state: {
|
|
77
|
+
extras?: unknown;
|
|
78
|
+
messages?: readonly {
|
|
79
|
+
id: string;
|
|
80
|
+
}[];
|
|
81
|
+
}): Set<string>;
|
|
82
|
+
/** Whether a hand-off reaches the thread now, from its statewire connection. */
|
|
83
|
+
export declare function chatOutboxReadiness(connection: StatewireExtrasView["connection"]): ChatOutboxThreadReadiness;
|
|
84
|
+
/**
|
|
85
|
+
* The anchor of a run a send mints, read from the raw wire messages the way the host computes its
|
|
86
|
+
* own (`run_anchor_message_id`): the last durable message, else the trailing ephemeral one, else
|
|
87
|
+
* none (an empty thread). The rendered messages do not line up with the host's transcript (an
|
|
88
|
+
* assistant turn and its tool messages render as one message under the turn's first id, hidden
|
|
89
|
+
* entries are dropped), so the raw list is what names the host's tail.
|
|
90
|
+
*/
|
|
91
|
+
export declare function chatOutboxWireAnchorId(wireMessages: readonly unknown[]): string | null;
|
|
92
|
+
/** The wire message for an outbox entry: its files first, then one text part (react-statewire's shape). */
|
|
93
|
+
export declare function chatOutboxWireMessage(entry: ChatOutboxEntry): ChatOutboxWireMessage;
|
|
94
|
+
/**
|
|
95
|
+
* The statement the composer's own send would make now (`composer.send({ steer: false })`): a
|
|
96
|
+
* queued follow-up behind a live run, otherwise a send that starts a run, anchored at the host's
|
|
97
|
+
* tail as the raw wire messages name it ({@link chatOutboxWireAnchorId}); without them (a surface
|
|
98
|
+
* whose state is not replicated yet), at the last rendered message, as the composer anchors.
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildChatOutboxSendCommand({ entry, messages, wireMessages, runId, isRunning, }: {
|
|
101
|
+
entry: ChatOutboxEntry;
|
|
102
|
+
messages: readonly {
|
|
103
|
+
id: string;
|
|
104
|
+
status?: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
}[];
|
|
108
|
+
/** The raw wire messages of the loaded window (`extras.state.messages`), when replicated. */
|
|
109
|
+
wireMessages?: readonly unknown[] | null;
|
|
110
|
+
runId: string | null;
|
|
111
|
+
isRunning: boolean;
|
|
112
|
+
}): ChatOutboxSendCommand;
|
|
113
|
+
/** A statewire thread, as the chat outbox's port. */
|
|
114
|
+
export declare function createStatewireChatOutboxPort({ client, }: {
|
|
115
|
+
/** Read on every call, so the port follows the host's current client. */
|
|
116
|
+
client: () => ChatOutboxClientHost | null;
|
|
117
|
+
}): ChatOutboxThreadPort;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
function extrasOf(state) {
|
|
2
|
+
const extras = state.extras;
|
|
3
|
+
return extras && typeof extras === "object" ? extras : null;
|
|
4
|
+
}
|
|
5
|
+
function idsOf(list, into) {
|
|
6
|
+
if (!Array.isArray(list)) return;
|
|
7
|
+
for (const item of list) {
|
|
8
|
+
const id = item == null ? void 0 : item.id;
|
|
9
|
+
if (typeof id === "string") into.add(id);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function chatOutboxHeldIds(state) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const held = /* @__PURE__ */ new Set();
|
|
15
|
+
for (const message of state.messages ?? []) held.add(message.id);
|
|
16
|
+
const runs = (_a = extrasOf(state)) == null ? void 0 : _a.runs;
|
|
17
|
+
if (runs) {
|
|
18
|
+
idsOf(runs.queue, held);
|
|
19
|
+
idsOf(runs.steerQueue, held);
|
|
20
|
+
idsOf(runs.failed, held);
|
|
21
|
+
idsOf((_b = runs.dispatching) == null ? void 0 : _b.messages, held);
|
|
22
|
+
}
|
|
23
|
+
return held;
|
|
24
|
+
}
|
|
25
|
+
function chatOutboxReadiness(connection) {
|
|
26
|
+
if (!connection) return "connecting";
|
|
27
|
+
switch (connection.status) {
|
|
28
|
+
case "connected":
|
|
29
|
+
return "ready";
|
|
30
|
+
case "standby":
|
|
31
|
+
return connection.reason === "deferred" && typeof connection.message === "string" ? "refused" : "ready";
|
|
32
|
+
case "stopped":
|
|
33
|
+
return "refused";
|
|
34
|
+
default:
|
|
35
|
+
return "connecting";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function chatOutboxWireAnchorId(wireMessages) {
|
|
39
|
+
let fallback = null;
|
|
40
|
+
for (let index = wireMessages.length - 1; index >= 0; index -= 1) {
|
|
41
|
+
const message = wireMessages[index];
|
|
42
|
+
if (!message || typeof message.id !== "string" || message.id.length === 0) continue;
|
|
43
|
+
fallback ?? (fallback = message.id);
|
|
44
|
+
if (!message.ephemeral) return message.id;
|
|
45
|
+
}
|
|
46
|
+
return fallback;
|
|
47
|
+
}
|
|
48
|
+
function viewedLeafId(messages) {
|
|
49
|
+
var _a;
|
|
50
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
51
|
+
const message = messages[index];
|
|
52
|
+
if (message && ((_a = message.status) == null ? void 0 : _a.type) !== "running") return message.id;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function newRunId() {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const host = globalThis;
|
|
59
|
+
return ((_b = (_a = host.crypto) == null ? void 0 : _a.randomUUID) == null ? void 0 : _b.call(_a)) ?? `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
60
|
+
}
|
|
61
|
+
function chatOutboxWireMessage(entry) {
|
|
62
|
+
const files = (entry.files ?? []).map((file) => ({
|
|
63
|
+
type: "file",
|
|
64
|
+
mediaType: file.mediaType,
|
|
65
|
+
url: file.url,
|
|
66
|
+
...file.filename !== void 0 && { filename: file.filename }
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
id: entry.id,
|
|
70
|
+
role: "user",
|
|
71
|
+
parts: [...files, ...entry.text.length > 0 ? [{ type: "text", text: entry.text }] : []]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function buildChatOutboxSendCommand({
|
|
75
|
+
entry,
|
|
76
|
+
messages,
|
|
77
|
+
wireMessages,
|
|
78
|
+
runId,
|
|
79
|
+
isRunning
|
|
80
|
+
}) {
|
|
81
|
+
const message = chatOutboxWireMessage(entry);
|
|
82
|
+
if (isRunning && runId !== null) return { type: "run/enqueue", runId, message };
|
|
83
|
+
if (runId !== null) return { type: "run/steer", runId, message };
|
|
84
|
+
const runAnchorMessageId = wireMessages && wireMessages.length > 0 ? chatOutboxWireAnchorId(wireMessages) : viewedLeafId(messages);
|
|
85
|
+
return { type: "run/steer", runId: newRunId(), message, runAnchorMessageId };
|
|
86
|
+
}
|
|
87
|
+
function createStatewireChatOutboxPort({
|
|
88
|
+
client
|
|
89
|
+
}) {
|
|
90
|
+
const state = () => {
|
|
91
|
+
var _a;
|
|
92
|
+
return ((_a = client()) == null ? void 0 : _a.thread().getState()) ?? null;
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
readiness() {
|
|
96
|
+
var _a;
|
|
97
|
+
const current = state();
|
|
98
|
+
return current ? chatOutboxReadiness((_a = extrasOf(current)) == null ? void 0 : _a.connection) : "connecting";
|
|
99
|
+
},
|
|
100
|
+
heldIds() {
|
|
101
|
+
const current = state();
|
|
102
|
+
return current ? chatOutboxHeldIds(current) : /* @__PURE__ */ new Set();
|
|
103
|
+
},
|
|
104
|
+
send(entry) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const current = state();
|
|
107
|
+
const extras = current ? extrasOf(current) : null;
|
|
108
|
+
if (!current || typeof (extras == null ? void 0 : extras.sendCommand) !== "function") {
|
|
109
|
+
return Promise.reject(new Error("The conversation is not ready to send."));
|
|
110
|
+
}
|
|
111
|
+
const runId = typeof ((_a = extras.runs) == null ? void 0 : _a.runId) === "string" ? extras.runs.runId : null;
|
|
112
|
+
const wireMessages = (_b = extras.state) == null ? void 0 : _b.messages;
|
|
113
|
+
const command = buildChatOutboxSendCommand({
|
|
114
|
+
entry,
|
|
115
|
+
messages: current.messages ?? [],
|
|
116
|
+
wireMessages: Array.isArray(wireMessages) ? wireMessages : null,
|
|
117
|
+
runId,
|
|
118
|
+
isRunning: extras.status === "running"
|
|
119
|
+
});
|
|
120
|
+
return extras.sendCommand(command, { preparedMetadata: Promise.resolve(entry.metadata) });
|
|
121
|
+
},
|
|
122
|
+
subscribe(listener) {
|
|
123
|
+
const current = client();
|
|
124
|
+
return current ? current.subscribe(listener) : () => void 0;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
buildChatOutboxSendCommand,
|
|
130
|
+
chatOutboxHeldIds,
|
|
131
|
+
chatOutboxReadiness,
|
|
132
|
+
chatOutboxWireAnchorId,
|
|
133
|
+
chatOutboxWireMessage,
|
|
134
|
+
createStatewireChatOutboxPort
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=chat-outbox-thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-outbox-thread.js","sources":["../../../../agent-runtime/src/chat-outbox-thread.ts"],"sourcesContent":["import type { ChatOutboxEntry } from \"./chat-outbox-store\";\nimport type { ChatOutboxThreadPort, ChatOutboxThreadReadiness } from \"./chat-outbox\";\n\n/**\n * The chat outbox's view of a statewire deep-agent thread (`chat-outbox.ts`): which message ids it\n * holds, whether a hand-off reaches it now, and the hand-off itself — the same `run/*` statement\n * the composer's own send makes, under the id the message was minted with when it was typed.\n */\n\n/** The imperative slice of an assistant-ui client the port reads (web and native `useAui` alike). */\nexport interface ChatOutboxClientHost {\n thread: () => {\n getState: () => {\n extras?: unknown;\n messages?: readonly { id: string; status?: { type: string } }[];\n };\n };\n subscribe: (listener: () => void) => () => void;\n}\n\ntype WireFilePart = { type: \"file\"; mediaType: string; url: string; filename?: string };\ntype WireTextPart = { type: \"text\"; text: string };\n\n/** The wire message an outbox entry is sent as (react-statewire's `UserMessage`, structurally). */\nexport interface ChatOutboxWireMessage {\n id: string;\n role: \"user\";\n parts: (WireFilePart | WireTextPart)[];\n metadata?: Record<string, unknown>;\n}\n\nexport type ChatOutboxSendCommand =\n | { type: \"run/enqueue\"; runId: string; message: ChatOutboxWireMessage }\n | {\n type: \"run/steer\";\n runId: string;\n message: ChatOutboxWireMessage;\n runAnchorMessageId?: string | null;\n };\n\ninterface RunsView {\n runId?: unknown;\n queue?: unknown;\n steerQueue?: unknown;\n failed?: unknown;\n dispatching?: { messages?: unknown } | null;\n}\n\ninterface StatewireExtrasView {\n runs?: RunsView;\n /** The composed thread state: its `messages` are the raw wire messages of the loaded window. */\n state?: { messages?: unknown } | null;\n status?: unknown;\n connection?: { status?: unknown; reason?: unknown; message?: unknown } | null;\n sendCommand?: (command: unknown, options?: { preparedMetadata?: Promise<unknown> }) => Promise<unknown>;\n}\n\nfunction extrasOf(state: { extras?: unknown }): StatewireExtrasView | null {\n const extras = state.extras;\n return extras && typeof extras === \"object\" ? (extras as StatewireExtrasView) : null;\n}\n\nfunction idsOf(list: unknown, into: Set<string>): void {\n if (!Array.isArray(list)) return;\n for (const item of list) {\n const id = (item as { id?: unknown } | null)?.id;\n if (typeof id === \"string\") into.add(id);\n }\n}\n\n/** The ids a statewire thread shows: transcript, lanes, the run being dispatched, failed sends. */\nexport function chatOutboxHeldIds(state: {\n extras?: unknown;\n messages?: readonly { id: string }[];\n}): Set<string> {\n const held = new Set<string>();\n for (const message of state.messages ?? []) held.add(message.id);\n const runs = extrasOf(state)?.runs;\n if (runs) {\n idsOf(runs.queue, held);\n idsOf(runs.steerQueue, held);\n idsOf(runs.failed, held);\n idsOf(runs.dispatching?.messages, held);\n }\n return held;\n}\n\n/** Whether a hand-off reaches the thread now, from its statewire connection. */\nexport function chatOutboxReadiness(connection: StatewireExtrasView[\"connection\"]): ChatOutboxThreadReadiness {\n if (!connection) return \"connecting\";\n switch (connection.status) {\n case \"connected\":\n return \"ready\";\n case \"standby\":\n // A never-started chat parks until its first send, and an idle channel reattaches on\n // demand; a park with a stated reason is the suspended transport (an authorization denial,\n // a host suspension), which never dials.\n return connection.reason === \"deferred\" && typeof connection.message === \"string\"\n ? \"refused\"\n : \"ready\";\n case \"stopped\":\n return \"refused\";\n default:\n return \"connecting\";\n }\n}\n\n/**\n * The anchor of a run a send mints, read from the raw wire messages the way the host computes its\n * own (`run_anchor_message_id`): the last durable message, else the trailing ephemeral one, else\n * none (an empty thread). The rendered messages do not line up with the host's transcript (an\n * assistant turn and its tool messages render as one message under the turn's first id, hidden\n * entries are dropped), so the raw list is what names the host's tail.\n */\nexport function chatOutboxWireAnchorId(wireMessages: readonly unknown[]): string | null {\n let fallback: string | null = null;\n for (let index = wireMessages.length - 1; index >= 0; index -= 1) {\n const message = wireMessages[index] as { id?: unknown; ephemeral?: unknown } | null | undefined;\n if (!message || typeof message.id !== \"string\" || message.id.length === 0) continue;\n fallback ??= message.id;\n if (!message.ephemeral) return message.id;\n }\n return fallback;\n}\n\n/** The last rendered message that is committed history (not a streaming answer). */\nfunction viewedLeafId(messages: readonly { id: string; status?: { type: string } }[]): string | null {\n for (let index = messages.length - 1; index >= 0; index -= 1) {\n const message = messages[index];\n if (message && message.status?.type !== \"running\") return message.id;\n }\n return null;\n}\n\nfunction newRunId(): string {\n const host = globalThis as { crypto?: { randomUUID?: () => string } };\n return host.crypto?.randomUUID?.() ?? `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** The wire message for an outbox entry: its files first, then one text part (react-statewire's shape). */\nexport function chatOutboxWireMessage(entry: ChatOutboxEntry): ChatOutboxWireMessage {\n const files: WireFilePart[] = (entry.files ?? []).map((file) => ({\n type: \"file\",\n mediaType: file.mediaType,\n url: file.url,\n ...(file.filename !== undefined && { filename: file.filename }),\n }));\n return {\n id: entry.id,\n role: \"user\",\n parts: [...files, ...(entry.text.length > 0 ? [{ type: \"text\" as const, text: entry.text }] : [])],\n };\n}\n\n/**\n * The statement the composer's own send would make now (`composer.send({ steer: false })`): a\n * queued follow-up behind a live run, otherwise a send that starts a run, anchored at the host's\n * tail as the raw wire messages name it ({@link chatOutboxWireAnchorId}); without them (a surface\n * whose state is not replicated yet), at the last rendered message, as the composer anchors.\n */\nexport function buildChatOutboxSendCommand({\n entry,\n messages,\n wireMessages,\n runId,\n isRunning,\n}: {\n entry: ChatOutboxEntry;\n messages: readonly { id: string; status?: { type: string } }[];\n /** The raw wire messages of the loaded window (`extras.state.messages`), when replicated. */\n wireMessages?: readonly unknown[] | null;\n runId: string | null;\n isRunning: boolean;\n}): ChatOutboxSendCommand {\n const message = chatOutboxWireMessage(entry);\n if (isRunning && runId !== null) return { type: \"run/enqueue\", runId, message };\n if (runId !== null) return { type: \"run/steer\", runId, message };\n const runAnchorMessageId =\n wireMessages && wireMessages.length > 0 ? chatOutboxWireAnchorId(wireMessages) : viewedLeafId(messages);\n return { type: \"run/steer\", runId: newRunId(), message, runAnchorMessageId };\n}\n\n/** A statewire thread, as the chat outbox's port. */\nexport function createStatewireChatOutboxPort({\n client,\n}: {\n /** Read on every call, so the port follows the host's current client. */\n client: () => ChatOutboxClientHost | null;\n}): ChatOutboxThreadPort {\n const state = () => client()?.thread().getState() ?? null;\n return {\n readiness() {\n const current = state();\n return current ? chatOutboxReadiness(extrasOf(current)?.connection) : \"connecting\";\n },\n heldIds() {\n const current = state();\n return current ? chatOutboxHeldIds(current) : new Set<string>();\n },\n send(entry) {\n const current = state();\n const extras = current ? extrasOf(current) : null;\n if (!current || typeof extras?.sendCommand !== \"function\") {\n return Promise.reject(new Error(\"The conversation is not ready to send.\"));\n }\n const runId = typeof extras.runs?.runId === \"string\" ? extras.runs.runId : null;\n const wireMessages = extras.state?.messages;\n const command = buildChatOutboxSendCommand({\n entry,\n messages: current.messages ?? [],\n wireMessages: Array.isArray(wireMessages) ? wireMessages : null,\n runId,\n isRunning: extras.status === \"running\",\n });\n // The metadata frozen when the message was typed rides as prepared metadata, so the\n // runtime's own capture (which reads what the composer staged for its next send) is not\n // consumed by a message typed earlier.\n return extras.sendCommand(command, { preparedMetadata: Promise.resolve(entry.metadata) });\n },\n subscribe(listener) {\n const current = client();\n return current ? current.subscribe(listener) : () => undefined;\n },\n };\n}\n"],"names":[],"mappings":"AAyDA,SAAS,SAAS,OAAyD;AACzE,QAAM,SAAS,MAAM;AACrB,SAAO,UAAU,OAAO,WAAW,WAAY,SAAiC;AAClF;AAEA,SAAS,MAAM,MAAe,MAAyB;AACrD,MAAI,CAAC,MAAM,QAAQ,IAAI,EAAG;AAC1B,aAAW,QAAQ,MAAM;AACvB,UAAM,KAAM,6BAAkC;AAC9C,QAAI,OAAO,OAAO,SAAU,MAAK,IAAI,EAAE;AAAA,EACzC;AACF;AAGO,SAAS,kBAAkB,OAGlB;AAjBhB;AAkBE,QAAM,2BAAW,IAAA;AACjB,aAAW,WAAW,MAAM,YAAY,CAAA,EAAI,MAAK,IAAI,QAAQ,EAAE;AAC/D,QAAM,QAAO,cAAS,KAAK,MAAd,mBAAiB;AAC9B,MAAI,MAAM;AACR,UAAM,KAAK,OAAO,IAAI;AACtB,UAAM,KAAK,YAAY,IAAI;AAC3B,UAAM,KAAK,QAAQ,IAAI;AACvB,WAAM,UAAK,gBAAL,mBAAkB,UAA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