@athenaintel/react 0.41.3 → 0.42.1
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 +102 -9
- 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 +88 -4
- package/dist/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.d.ts +603 -0
- package/dist/agent-runtime/src/messages.js +88 -4
- 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.d.ts +154 -0
- 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/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 +67 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-names.d.ts +60 -0
- package/dist/agent-runtime/src/tool-names.js +68 -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 +20 -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 +168 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js +20 -2
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +12 -4
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +320 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.js +12 -4
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs +999 -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 +999 -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.d.ts +80 -0
- 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/chat/AthenaChat.cjs +72 -5
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.js +73 -6
- 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/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 +102 -3
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +32 -1
- package/dist/chat-ui/composer/tiptap-composer.js +103 -4
- 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/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/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 +13 -6
- 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 +16 -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 +16 -5
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +17 -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/package.json +20 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-agent-transport-recipe.js","sources":["../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n resolveStatewireTransportKind,\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise (`resolveStatewireTransportKind`). */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * The head window declared on the attach (`x-athena-deep-agent-window`,\n * see `message-window.ts`): the hello of a client the host does not\n * remember carries the newest `size` messages. Part of the recipe so a\n * pooled dial asks for the same shape as the thread's own attach — a pooled\n * hello then seeds the very state the attach will reconcile. Omitted, the\n * shared default is declared.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares this build's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n // The instrumentation wraps the transport actually built: SSE needs the\n // fetch wrapper that reads a refused attach's `Retry-After`.\n const useSse = resolveStatewireTransportKind({ sse }) === \"sse\";\n const instrumentation = createAttachInstrumentation({\n url,\n sse: useSse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n return withDeclaredMessageWindow(\n withDeclaredProtocolVersion(await headers(ctx)),\n messageWindow,\n );\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse: useSse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":[],"mappings":";;;;AA4BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AA4CO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AACF,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AAGpD,QAAM,SAAS,8BAA8B,EAAE,IAAA,CAAK,MAAM;AAC1D,QAAM,kBAAkB,4BAA4B;AAAA,IAClD;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,aAAO;AAAA,QACL,4BAA4B,MAAM,QAAQ,GAAG,CAAC;AAAA,QAC9C;AAAA,MAAA;AAAA,IAEJ;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAO,mBAA2B,SAAS,EAAE,KAAK,QAAQ;AAC5D;"}
|
|
1
|
+
{"version":3,"file":"deep-agent-transport-recipe.js","sources":["../../../../agent-runtime/src/deep-agent-transport-recipe.ts"],"sourcesContent":["import type { ResourceElement } from \"@assistant-ui/tap\";\nimport type { Statewire, StatewireClient } from \"statewire\";\nimport {\n type DeepAgentMessageWindowDeclaration,\n withDeclaredMessageWindow,\n} from \"./message-window\";\nimport { withDeclaredProtocolVersion } from \"./protocol\";\nimport {\n attachRetryGate,\n type AttachRetryGate,\n createAttachInstrumentation,\n type DeepAgentAttachTimingEvent,\n type DeepAgentWakeRefusal,\n parseRetryAfterHeaderMs,\n} from \"./statewire-attach-observer\";\nimport {\n resolveStatewireTransportKind,\n statewireTransport,\n type StatewireTransportOptions,\n} from \"./statewire-transport\";\n\n/** Auth-header resolver for the transport; `staleAuth` is true right after an\n * auth rejection, so resolvers that can force-renew should honor it. */\nexport type DeepAgentHeadersResolver = (ctx: {\n staleAuth: boolean;\n}) => Record<string, string> | Promise<Record<string, string>>;\n\n/** The statewire attach URL for a thread: the host's `…/v2/threads` mount plus the id. */\nexport function deepAgentThreadUrl({\n baseUrl,\n threadId,\n}: {\n baseUrl: string;\n threadId: string;\n}): string {\n return `${baseUrl.replace(/\\/+$/, \"\")}/${encodeURIComponent(threadId)}`;\n}\n\nexport interface DeepAgentAttachTransportOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n /** SSE when true, WebSocket otherwise (`resolveStatewireTransportKind`). */\n sse?: boolean;\n /** A never-started chat: the transport makes no network calls until the first command send. */\n isNew?: boolean;\n /** Host session store (mobile); browser hosts mount `storage.session` on the thread instead. */\n sessionStore?: StatewireClient.SessionStorage | undefined;\n /** Observes every headers resolve (the diagnostics recorder's stale-auth seam). */\n onAuthResolve?: ((ctx: { staleAuth: boolean }) => void) | undefined;\n /** Attach timing + retry hints (see `statewire-attach-observer`). */\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n /**\n * The head window declared on the attach (`x-athena-deep-agent-window`,\n * see `message-window.ts`): the hello of a client the host does not\n * remember carries the newest `size` messages. Part of the recipe so a\n * pooled dial asks for the same shape as the thread's own attach — a pooled\n * hello then seeds the very state the attach will reconcile. Omitted, the\n * shared default is declared.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | undefined;\n /**\n * The surface pages cut lanes (see `DeepAgentProtocolDeclaration`), so its\n * attach declares the lane-cut contract version. Part of the recipe so a\n * pooled dial declares what the thread's own attach would; omitted, the\n * default version is declared.\n */\n laneHistory?: boolean | undefined;\n}\n\n/**\n * The ONE recipe for a deep-agent thread transport — shared by the mounted\n * thread (`useDeepAgentThread`) and the prewarm pool, so a pre-dialed\n * connection is byte-for-byte the connection the thread would have opened\n * itself: same URL, same auth + wire-contract headers, same session lane, same\n * instrumentation.\n *\n * Every attach declares the surface's wire-contract version alongside the\n * host's auth headers (first WS frame / SSE request headers) — the server\n * half of version negotiation reads it in `authorize`. The headers resolve\n * also waits out any server `Retry-After` floor for the thread: both statewire\n * attach paths resolve headers before they dial, so this is the seam where a\n * hint can hold the next dial without touching the library's backoff.\n */\nexport function createDeepAgentAttachTransport<TState = unknown>({\n baseUrl,\n threadId,\n headers,\n sse = false,\n isNew = false,\n sessionStore,\n onAuthResolve,\n onAttachTiming,\n retryGate = attachRetryGate,\n messageWindow,\n laneHistory = false,\n}: DeepAgentAttachTransportOptions): ResourceElement<\n Statewire<TState | undefined>\n> {\n const url = deepAgentThreadUrl({ baseUrl, threadId });\n // The instrumentation wraps the transport actually built: SSE needs the\n // fetch wrapper that reads a refused attach's `Retry-After`.\n const useSse = resolveStatewireTransportKind({ sse }) === \"sse\";\n const instrumentation = createAttachInstrumentation({\n url,\n sse: useSse,\n onEvent: onAttachTiming,\n retryGate,\n });\n const options: StatewireTransportOptions = {\n url,\n ...(isNew && { isNew: true }),\n headers: async (ctx: { staleAuth: boolean }) => {\n await retryGate.waitForDial(url);\n onAuthResolve?.(ctx);\n return withDeclaredMessageWindow(\n withDeclaredProtocolVersion(await headers(ctx), { laneHistory }),\n messageWindow,\n );\n },\n ...(sessionStore && { sessionStore }),\n // Structural types: this package compiles without the DOM lib, while\n // statewire's option types name the browser `WebSocket`/`fetch`.\n ...(instrumentation.webSocket && {\n webSocket:\n instrumentation.webSocket as unknown as StatewireTransportOptions[\"webSocket\"],\n }),\n ...(instrumentation.fetch && {\n fetch:\n instrumentation.fetch as unknown as StatewireTransportOptions[\"fetch\"],\n }),\n };\n return statewireTransport<TState>(options, { sse: useSse });\n}\n\n/** What `POST …/prewarm` answered. */\nexport interface DeepAgentWakeResult {\n status: number;\n /** The host activated the thread and its history is resident. */\n warm: boolean;\n /**\n * `'warm'` when the history was already memoized, `'fresh_load'` when this\n * call loaded it; `null` when the host did not say (a refusal, or a host\n * without the route).\n */\n history: \"fresh_load\" | \"warm\" | null;\n /**\n * The dial floor recorded for the thread off a 503/429 `Retry-After` — the\n * header's value, except a 503 `\"worker\"` refusal, capped at\n * {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\n retryAfterMs: number | null;\n /** Who refused a 503/429 (see {@link DeepAgentWakeRefusal}); `null` for any other answer. */\n refusal: DeepAgentWakeRefusal;\n durationMs: number;\n}\n\n/**\n * Dial floor for a 503 the pinned worker produced about one instance's\n * lifecycle. Pinned answers every retriable 503 with a blanket\n * `Retry-After: 1`, but what those name — an instance record mid-teardown\n * (\"instance closing; retry\": fence release + placement release, ≈100 ms), a\n * full activation queue — clears far sooner than that, and the thread's own\n * attach is the request that carries the next activation. Holding it a full\n * second traded a ≈100 ms gap for a ≈1 s stall on every refused wake. A 429\n * is rate limiting and keeps its hint whatever the body says.\n */\nexport const WAKE_WORKER_REFUSAL_FLOOR_MS = 250;\n\n/**\n * The pinboard's own placement-refusal vocabulary — the `error` strings of\n * `@assistant-ui/pinboard` (`src/refusals.ts` plus the two inline refusals in\n * `src/server.ts`). Mirrors `PINBOARD_PLACEMENT_REFUSAL_ERRORS` in\n * `iris/scaler/src/v2AccessLog.ts`, whose test pins it to the installed\n * library; keep the two lists identical. A body with any other `error`\n * string is `\"unknown\"`, never `\"placement\"`.\n */\nexport const PINBOARD_PLACEMENT_REFUSAL_ERRORS: ReadonlySet<string> = new Set([\n \"no live backends for namespace\",\n \"registry cold start, retry\",\n \"not the serving fleet\",\n \"no live workers for hostname\",\n \"hostname binding displaced, retry\",\n \"hostname bindings inconsistent, retry\",\n \"takeover in progress, retry\",\n \"placement held by another hostname\",\n \"worker inflight cap exceeded, retry\",\n \"worker refused activation, retry\",\n]);\n\n/**\n * Pinned's instance-lifecycle refusals (`pinned/hosting/directory.py`,\n * `pinned/hosting/_records.py`): each names one instance on the worker the\n * thread is already placed on and clears in the time a teardown or an\n * activation slot takes. Anything else the worker answers 503 with — \"Thread\n * history load failed\", \"The regional conversation store is temporarily\n * unavailable\", a lease that expired — is not about one instance and keeps\n * the full hint.\n */\nexport const PINNED_TRANSIENT_WORKER_REFUSALS: ReadonlySet<string> = new Set([\n \"instance closing; retry\",\n \"instance aborted\",\n \"activation queue full; retry\",\n \"host draining; retry\",\n \"instance capacity reached; retry\",\n \"instance past its wind-down deadline; retry\",\n]);\n\n/**\n * Classify a 503/429 body (see {@link DeepAgentWakeRefusal}): a known pinboard\n * `error` is `\"placement\"`, a known pinned `detail` is `\"worker\"`, everything\n * else — including unfamiliar strings in either field — is `\"unknown\"`.\n */\nexport function classifyWakeRefusal(\n body: unknown,\n): Exclude<DeepAgentWakeRefusal, null> {\n if (typeof body === \"object\" && body !== null) {\n const record = body as Record<string, unknown>;\n if (\n typeof record.error === \"string\" &&\n PINBOARD_PLACEMENT_REFUSAL_ERRORS.has(record.error)\n ) {\n return \"placement\";\n }\n if (\n typeof record.detail === \"string\" &&\n PINNED_TRANSIENT_WORKER_REFUSALS.has(record.detail)\n ) {\n return \"worker\";\n }\n }\n return \"unknown\";\n}\n\n/** Structural `fetch` for the wake call — this package compiles without the DOM lib. */\nexport type DeepAgentWakeFetch = (\n input: string,\n init?: {\n method?: string;\n headers?: Record<string, string>;\n keepalive?: boolean;\n },\n) => Promise<{\n ok: boolean;\n status: number;\n headers: { get(name: string): string | null };\n json(): Promise<unknown>;\n}>;\n\nexport interface DeepAgentWakeOptions {\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n threadId: string;\n headers: DeepAgentHeadersResolver;\n fetch?: DeepAgentWakeFetch | undefined;\n /** Dial floors from server retry hints; the process-wide gate by default. */\n retryGate?: AttachRetryGate;\n onAttachTiming?: ((event: DeepAgentAttachTimingEvent) => void) | undefined;\n now?: () => number;\n /** The surface pages cut lanes: declare what its attach declares (see `DeepAgentAttachTransportOptions`). */\n laneHistory?: boolean | undefined;\n}\n\n/**\n * Wake a thread's server instance ahead of its attach. `POST …/prewarm` runs\n * the host's `authorize` and history load — the fence adopt, graph compile and\n * checkpoint read that make a cold attach's hello take ≈1 s — and answers with\n * no thread content, only whether the history was already resident. Fire it\n * on hover intent, before a pooled attach or the click's own dial, so the\n * activation overlaps the handshake and the attach that follows finds the\n * instance warm.\n *\n * Fire-and-forget by contract: every failure resolves `null`, and a host\n * without the route (404) is reported like any other non-OK answer. A 503/429\n * `Retry-After` is recorded as a dial floor for the thread, so the attach that\n * follows waits it out instead of bouncing — in full, except a 503 that names\n * one of pinned's instance-lifecycle refusals (one instance mid-teardown on\n * the worker the thread already has; see {@link DeepAgentWakeRefusal}), whose\n * floor is capped at {@link WAKE_WORKER_REFUSAL_FLOOR_MS}.\n */\nexport async function wakeDeepAgentThread({\n baseUrl,\n threadId,\n headers,\n fetch: fetchOverride,\n retryGate = attachRetryGate,\n onAttachTiming,\n now = () => Date.now(),\n laneHistory = false,\n}: DeepAgentWakeOptions): Promise<DeepAgentWakeResult | null> {\n const fetchImpl =\n fetchOverride ?? (globalThis as { fetch?: DeepAgentWakeFetch }).fetch;\n if (typeof fetchImpl !== \"function\") return null;\n const threadUrl = deepAgentThreadUrl({ baseUrl, threadId });\n const emit = (event: DeepAgentAttachTimingEvent): void => {\n try {\n onAttachTiming?.(event);\n } catch {\n // Observers are best-effort.\n }\n };\n const startedAt = now();\n try {\n const resolved = withDeclaredProtocolVersion(\n await headers({ staleAuth: false }),\n { laneHistory },\n );\n const response = await fetchImpl(`${threadUrl}/prewarm`, {\n method: \"POST\",\n headers: resolved,\n keepalive: true,\n });\n const durationMs = now() - startedAt;\n let retryAfterMs: number | null = null;\n let refusal: DeepAgentWakeRefusal = null;\n if (response.status === 503 || response.status === 429) {\n let body: unknown = null;\n try {\n body = await response.json();\n } catch {\n // A refusal without a readable body is classified by nothing.\n }\n refusal = classifyWakeRefusal(body);\n const hinted = parseRetryAfterHeaderMs(\n response.headers.get(\"retry-after\"),\n now,\n );\n if (hinted !== null) {\n retryAfterMs =\n response.status === 503 && refusal === \"worker\"\n ? Math.min(hinted, WAKE_WORKER_REFUSAL_FLOOR_MS)\n : hinted;\n if (retryAfterMs > 0) {\n retryGate.noteRetryAfter(threadUrl, retryAfterMs);\n emit({\n type: \"retry-after\",\n url: threadUrl,\n delayMs: retryAfterMs,\n source: \"http-header\",\n });\n }\n }\n }\n let warm = false;\n let history: DeepAgentWakeResult[\"history\"] = null;\n if (response.ok) {\n try {\n const body = (await response.json()) as {\n warm?: unknown;\n history?: unknown;\n } | null;\n warm = body?.warm === true;\n history =\n body?.history === \"warm\" || body?.history === \"fresh_load\"\n ? body.history\n : null;\n } catch {\n // A 200 without a JSON body still means the instance is up.\n warm = true;\n }\n }\n emit({\n type: \"wake\",\n url: threadUrl,\n status: response.status,\n durationMs,\n history,\n refusal,\n });\n return {\n status: response.status,\n warm,\n history,\n retryAfterMs,\n refusal,\n durationMs,\n };\n } catch {\n return null;\n }\n}\n"],"names":[],"mappings":";;;;AA4BO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGW;AACT,SAAO,GAAG,QAAQ,QAAQ,QAAQ,EAAE,CAAC,IAAI,mBAAmB,QAAQ,CAAC;AACvE;AAmDO,SAAS,+BAAiD;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,cAAc;AAChB,GAEE;AACA,QAAM,MAAM,mBAAmB,EAAE,SAAS,UAAU;AAGpD,QAAM,SAAS,8BAA8B,EAAE,IAAA,CAAK,MAAM;AAC1D,QAAM,kBAAkB,4BAA4B;AAAA,IAClD;AAAA,IACA,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,EAAA,CACD;AACD,QAAM,UAAqC;AAAA,IACzC;AAAA,IACA,GAAI,SAAS,EAAE,OAAO,KAAA;AAAA,IACtB,SAAS,OAAO,QAAgC;AAC9C,YAAM,UAAU,YAAY,GAAG;AAC/B,qDAAgB;AAChB,aAAO;AAAA,QACL,4BAA4B,MAAM,QAAQ,GAAG,GAAG,EAAE,aAAa;AAAA,QAC/D;AAAA,MAAA;AAAA,IAEJ;AAAA,IACA,GAAI,gBAAgB,EAAE,aAAA;AAAA;AAAA;AAAA,IAGtB,GAAI,gBAAgB,aAAa;AAAA,MAC/B,WACE,gBAAgB;AAAA,IAAA;AAAA,IAEpB,GAAI,gBAAgB,SAAS;AAAA,MAC3B,OACE,gBAAgB;AAAA,IAAA;AAAA,EACpB;AAEF,SAAO,mBAA2B,SAAS,EAAE,KAAK,QAAQ;AAC5D;"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Authenticated desktop handoffs carry references, never document/chat contents or credentials. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const DESKTOP_HANDOFF_PROTOCOL_VERSION: 1;
|
|
4
|
+
export declare const DESKTOP_HANDOFF_MAX_ASSETS = 50;
|
|
5
|
+
export declare const desktopHandoffAssetSchema: z.ZodObject<{
|
|
6
|
+
asset_id: z.ZodString;
|
|
7
|
+
reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type DesktopHandoffAsset = z.infer<typeof desktopHandoffAssetSchema>;
|
|
10
|
+
export declare const desktopHandoffResultSchema: z.ZodObject<{
|
|
11
|
+
desktop_version: z.ZodString;
|
|
12
|
+
protocol_version: z.ZodLiteral<1>;
|
|
13
|
+
thread_opened: z.ZodBoolean;
|
|
14
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
15
|
+
asset_id: z.ZodString;
|
|
16
|
+
status: z.ZodEnum<{
|
|
17
|
+
failed: "failed";
|
|
18
|
+
opened: "opened";
|
|
19
|
+
web_fallback: "web_fallback";
|
|
20
|
+
}>;
|
|
21
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type DesktopHandoffResult = z.infer<typeof desktopHandoffResultSchema>;
|
|
25
|
+
export declare const desktopHandoffViewSchema: z.ZodObject<{
|
|
26
|
+
handoff_id: z.ZodString;
|
|
27
|
+
thread_id: z.ZodNullable<z.ZodString>;
|
|
28
|
+
session_asset_id: z.ZodNullable<z.ZodString>;
|
|
29
|
+
source: z.ZodLiteral<"spaces">;
|
|
30
|
+
destination: z.ZodLiteral<"desktop">;
|
|
31
|
+
environment: z.ZodEnum<{
|
|
32
|
+
localhost: "localhost";
|
|
33
|
+
production: "production";
|
|
34
|
+
staging: "staging";
|
|
35
|
+
}>;
|
|
36
|
+
state: z.ZodEnum<{
|
|
37
|
+
acknowledged: "acknowledged";
|
|
38
|
+
claimed: "claimed";
|
|
39
|
+
failed: "failed";
|
|
40
|
+
issued: "issued";
|
|
41
|
+
launched: "launched";
|
|
42
|
+
}>;
|
|
43
|
+
issued_at: z.ZodISODateTime;
|
|
44
|
+
expires_at: z.ZodISODateTime;
|
|
45
|
+
claimed_at: z.ZodNullable<z.ZodISODateTime>;
|
|
46
|
+
acknowledged_at: z.ZodNullable<z.ZodISODateTime>;
|
|
47
|
+
failure_reason: z.ZodNullable<z.ZodString>;
|
|
48
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
49
|
+
asset_id: z.ZodString;
|
|
50
|
+
reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
active_asset_id: z.ZodNullable<z.ZodString>;
|
|
53
|
+
result: z.ZodNullable<z.ZodObject<{
|
|
54
|
+
desktop_version: z.ZodString;
|
|
55
|
+
protocol_version: z.ZodLiteral<1>;
|
|
56
|
+
thread_opened: z.ZodBoolean;
|
|
57
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
58
|
+
asset_id: z.ZodString;
|
|
59
|
+
status: z.ZodEnum<{
|
|
60
|
+
failed: "failed";
|
|
61
|
+
opened: "opened";
|
|
62
|
+
web_fallback: "web_fallback";
|
|
63
|
+
}>;
|
|
64
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type DesktopHandoffView = z.infer<typeof desktopHandoffViewSchema>;
|
|
69
|
+
export declare const desktopHandoffLaunchSchema: z.ZodObject<{
|
|
70
|
+
kind: z.ZodLiteral<"desktop">;
|
|
71
|
+
scheme_url: z.ZodString;
|
|
72
|
+
download_url: z.ZodURL;
|
|
73
|
+
deployment_url: z.ZodURL;
|
|
74
|
+
protocol_version: z.ZodLiteral<1>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type DesktopHandoffLaunch = z.infer<typeof desktopHandoffLaunchSchema>;
|
|
77
|
+
export declare const createDesktopHandoffResponseSchema: z.ZodObject<{
|
|
78
|
+
handoff: z.ZodObject<{
|
|
79
|
+
handoff_id: z.ZodString;
|
|
80
|
+
thread_id: z.ZodNullable<z.ZodString>;
|
|
81
|
+
session_asset_id: z.ZodNullable<z.ZodString>;
|
|
82
|
+
source: z.ZodLiteral<"spaces">;
|
|
83
|
+
destination: z.ZodLiteral<"desktop">;
|
|
84
|
+
environment: z.ZodEnum<{
|
|
85
|
+
localhost: "localhost";
|
|
86
|
+
production: "production";
|
|
87
|
+
staging: "staging";
|
|
88
|
+
}>;
|
|
89
|
+
state: z.ZodEnum<{
|
|
90
|
+
acknowledged: "acknowledged";
|
|
91
|
+
claimed: "claimed";
|
|
92
|
+
failed: "failed";
|
|
93
|
+
issued: "issued";
|
|
94
|
+
launched: "launched";
|
|
95
|
+
}>;
|
|
96
|
+
issued_at: z.ZodISODateTime;
|
|
97
|
+
expires_at: z.ZodISODateTime;
|
|
98
|
+
claimed_at: z.ZodNullable<z.ZodISODateTime>;
|
|
99
|
+
acknowledged_at: z.ZodNullable<z.ZodISODateTime>;
|
|
100
|
+
failure_reason: z.ZodNullable<z.ZodString>;
|
|
101
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
102
|
+
asset_id: z.ZodString;
|
|
103
|
+
reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
active_asset_id: z.ZodNullable<z.ZodString>;
|
|
106
|
+
result: z.ZodNullable<z.ZodObject<{
|
|
107
|
+
desktop_version: z.ZodString;
|
|
108
|
+
protocol_version: z.ZodLiteral<1>;
|
|
109
|
+
thread_opened: z.ZodBoolean;
|
|
110
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
111
|
+
asset_id: z.ZodString;
|
|
112
|
+
status: z.ZodEnum<{
|
|
113
|
+
failed: "failed";
|
|
114
|
+
opened: "opened";
|
|
115
|
+
web_fallback: "web_fallback";
|
|
116
|
+
}>;
|
|
117
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
launch: z.ZodObject<{
|
|
122
|
+
kind: z.ZodLiteral<"desktop">;
|
|
123
|
+
scheme_url: z.ZodString;
|
|
124
|
+
download_url: z.ZodURL;
|
|
125
|
+
deployment_url: z.ZodURL;
|
|
126
|
+
protocol_version: z.ZodLiteral<1>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type CreateDesktopHandoffResponse = z.infer<typeof createDesktopHandoffResponseSchema>;
|
|
130
|
+
export interface CreateDesktopHandoffInput {
|
|
131
|
+
thread_id?: string | null;
|
|
132
|
+
assets: DesktopHandoffAsset[];
|
|
133
|
+
active_asset_id?: string | null;
|
|
134
|
+
source: "spaces";
|
|
135
|
+
}
|
|
136
|
+
/** Only a destination acknowledgement proves a launch. Timeouts prove no installation state. */
|
|
137
|
+
export declare function desktopHandoffSummary({ handoff, }: {
|
|
138
|
+
handoff: DesktopHandoffView;
|
|
139
|
+
}): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type DeepAgentThreadSnapshotCache } from "./thread-snapshot-cache";
|
|
2
|
+
import { type ThreadSnapshotMirror } from "./thread-snapshot-mirror";
|
|
3
|
+
/**
|
|
4
|
+
* The thread snapshot cache with a durable, encrypted mirror behind it (`thread-snapshot-mirror.ts`):
|
|
5
|
+
* a reload seeds a recently visited thread from what it last showed, and a thread can be read while
|
|
6
|
+
* the transport cannot connect at all.
|
|
7
|
+
*
|
|
8
|
+
* - **Online, nothing changes.** `take` serves the in-memory entry within its age bound (one hour by
|
|
9
|
+
* default), exactly as the plain cache does, and the attach snapshot replaces the seed.
|
|
10
|
+
* - **Offline** (`isOffline()`: the host's own word that Athena can't be reached), `take` serves the
|
|
11
|
+
* thread's last resting transcript this page holds (what it read, or what the mirror kept), up to
|
|
12
|
+
* `offlineMaxAgeMs` old and past the online bound, so a person can read their recent
|
|
13
|
+
* conversations on a plane. Never a mid-stream state: a run the connection dropped is a partial
|
|
14
|
+
* transcript, and the resting one before it is what shows. Every offline seed, however recent, is
|
|
15
|
+
* recorded with its capture time (`offlineSeedAt`) so the host can say the transcript is "as of"
|
|
16
|
+
* then; only the next state the wire delivers for the thread (its attach) clears it.
|
|
17
|
+
* - **Owned.** Entries belong to one owner (`setOwner`): a change drops every entry, deletes the
|
|
18
|
+
* previous owner's mirrored records and reads the new owner's. A snapshot captured under one
|
|
19
|
+
* account never seeds a mount under another. `wipe` drops everything (a sign-out).
|
|
20
|
+
*/
|
|
21
|
+
export interface DurableThreadSnapshotCache extends DeepAgentThreadSnapshotCache {
|
|
22
|
+
peek(threadId: string): boolean;
|
|
23
|
+
/** Bind the cache to the acting owner (`null`: nobody signed in; nothing is mirrored). */
|
|
24
|
+
setOwner(ownerId: string | null): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Start reading an owner's mirrored snapshots before the owner is known for sure (a host's
|
|
27
|
+
* last-owner hint at boot): `setOwner` adopts the read if that owner is the one bound, and it
|
|
28
|
+
* is discarded otherwise. Binds nothing and deletes nothing.
|
|
29
|
+
*/
|
|
30
|
+
prime(ownerId: string): void;
|
|
31
|
+
/** The owner the cache is bound to. */
|
|
32
|
+
owner(): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* When the seed `take` last served for `threadId` was captured, if it was served while Athena
|
|
35
|
+
* could not be reached; `null` otherwise, and again once the wire delivers the thread.
|
|
36
|
+
*/
|
|
37
|
+
offlineSeedAt(threadId: string): number | null;
|
|
38
|
+
/** Calls `listener` whenever an offline seed is served or cleared; returns what stops it. */
|
|
39
|
+
subscribeOfflineSeeds(listener: () => void): () => void;
|
|
40
|
+
/** Whether the entry `take` would serve for `threadId` came back from the mirror. */
|
|
41
|
+
isRestored(threadId: string): boolean;
|
|
42
|
+
/** Resolves once the current owner's mirrored snapshots have been read (tests, telemetry). */
|
|
43
|
+
whenHydrated(): Promise<void>;
|
|
44
|
+
/** Drop every entry, in memory and in the mirror (a sign-out, a workspace switch). */
|
|
45
|
+
wipe(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface DurableThreadSnapshotCacheOptions {
|
|
48
|
+
mirror: ThreadSnapshotMirror;
|
|
49
|
+
/** Whether Athena can't be reached right now (the host's reachability, or the browser's). */
|
|
50
|
+
isOffline?: () => boolean;
|
|
51
|
+
maxThreads?: number;
|
|
52
|
+
/** The online age bound (the plain cache's). */
|
|
53
|
+
maxAgeMs?: number;
|
|
54
|
+
/** How old a mirrored snapshot may be and still be read offline. */
|
|
55
|
+
offlineMaxAgeMs?: number;
|
|
56
|
+
now?: () => number;
|
|
57
|
+
}
|
|
58
|
+
/** What a device keeps for reading offline: the offline plan's 30 days. */
|
|
59
|
+
export declare const OFFLINE_SNAPSHOT_MAX_AGE_MS: number;
|
|
60
|
+
export declare function createDurableThreadSnapshotCache({ mirror, isOffline, maxThreads, maxAgeMs, offlineMaxAgeMs, now, }: DurableThreadSnapshotCacheOptions): DurableThreadSnapshotCache;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { StatewireThread } from '@assistant-ui/react-statewire';
|
|
2
|
+
import { type DeepAgentMessageWindow } from './message-window';
|
|
3
|
+
/**
|
|
4
|
+
* Wire-accurate `run/edit` construction for deep-agent retry/edit, shared by
|
|
5
|
+
* every surface that resubmits a user message.
|
|
6
|
+
*
|
|
7
|
+
* assistant-ui builds the command's `runAnchorMessageId` from the CONVERTED
|
|
8
|
+
* thread messages (`resolveEditCommand`: `messages[index - 1].id`), but the
|
|
9
|
+
* deep-agent host validates that anchor against the edited message's parent in
|
|
10
|
+
* its RAW message list (`harness_sdk.linear_thread`: the entry before it in
|
|
11
|
+
* `state["messages"]`). Those two lists do not line up:
|
|
12
|
+
*
|
|
13
|
+
* - the converter chunks an assistant turn and its tool messages into ONE
|
|
14
|
+
* thread message carrying only the FIRST wire id, so the anchor names the
|
|
15
|
+
* head of the previous turn instead of its last tool message;
|
|
16
|
+
* - `sanitizeLangChainMessages` drops hidden-from-frontend and unconvertible
|
|
17
|
+
* entries, so a dropped tail message is invisible to the anchor too.
|
|
18
|
+
*
|
|
19
|
+
* Either way the host rejects the command with `wrong-anchor`
|
|
20
|
+
* (`runAnchorMessageId … is not the source's parent`) AFTER the composer's
|
|
21
|
+
* synchronous `send()` returned, so the retry/edit silently does nothing.
|
|
22
|
+
*
|
|
23
|
+
* Building the command here off the replicated raw state makes the anchor the
|
|
24
|
+
* same value the host computes.
|
|
25
|
+
*
|
|
26
|
+
* The raw list is the loaded interest window, so the first loaded message's
|
|
27
|
+
* parent is not in it while older messages exist — an edit there must not
|
|
28
|
+
* anchor on `null` (the root, rejected `wrong-anchor`); a message below the
|
|
29
|
+
* window has no parent on this client at all. {@link resolveDeepAgentEditCommand}
|
|
30
|
+
* states older page interests until the parent is loaded.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Host metadata frozen at submission, settling once the async capture does.
|
|
34
|
+
* The message-metadata preparation surface — `prepareMessageMetadata`,
|
|
35
|
+
* `discardPreparedMessageMetadata`, `sendPreparedEdit` and `sendCommand`'s
|
|
36
|
+
* `preparedMetadata` option — is what the monorepo patches into
|
|
37
|
+
* `@assistant-ui/react-statewire@0.31.0` (`patches/`). It is declared
|
|
38
|
+
* structurally here rather than as `StatewireThread.Extras[...]` so that the
|
|
39
|
+
* published sources also compile against the unpatched upstream typings, where
|
|
40
|
+
* those members are absent and the edit path's optional calls never run.
|
|
41
|
+
*/
|
|
42
|
+
export type DeepAgentPreparedMessageMetadata = Promise<Record<string, unknown> | undefined>;
|
|
43
|
+
/** The pieces of the statewire thread extras the edit path reads. */
|
|
44
|
+
export interface DeepAgentStatewireExtras {
|
|
45
|
+
/** The library's dispatch; it resolves with the host's reply to the command. */
|
|
46
|
+
sendCommand: (command: StatewireThread.Command, options?: {
|
|
47
|
+
preparedMetadata?: DeepAgentPreparedMessageMetadata | undefined;
|
|
48
|
+
}) => Promise<unknown> | void;
|
|
49
|
+
/** Optional on older hosts; capture before loading an edit's history anchor. */
|
|
50
|
+
prepareMessageMetadata?: (() => DeepAgentPreparedMessageMetadata) | undefined;
|
|
51
|
+
discardPreparedMessageMetadata?: ((prepared: DeepAgentPreparedMessageMetadata) => void) | undefined;
|
|
52
|
+
sendPreparedEdit?: ((sourceId: string, prepared: DeepAgentPreparedMessageMetadata) => void) | undefined;
|
|
53
|
+
isPreparingSubmission?: boolean;
|
|
54
|
+
/** The composed thread state — its `messages` are the raw wire messages of the loaded window. */
|
|
55
|
+
state: {
|
|
56
|
+
messages?: readonly {
|
|
57
|
+
id?: unknown;
|
|
58
|
+
}[];
|
|
59
|
+
} | null;
|
|
60
|
+
/** The mounted documents (the interest window), absent on a wire without documents. */
|
|
61
|
+
documents?: StatewireThread.Extras['documents'];
|
|
62
|
+
invoke?: StatewireThread.Extras['invoke'];
|
|
63
|
+
/** The live run, when one is in flight; `epoch` advances on each dispatch. */
|
|
64
|
+
runs: {
|
|
65
|
+
runId?: string | null;
|
|
66
|
+
epoch?: number;
|
|
67
|
+
};
|
|
68
|
+
/** The host's replicated run status; absent on a surface that predates it. */
|
|
69
|
+
status?: StatewireThread.ThreadStatus;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The statewire extras of the nearest aui thread, or `null` when the thread is
|
|
73
|
+
* not a statewire thread (e.g. a read-only subagent transcript runtime).
|
|
74
|
+
* Gated on {@link hasStatewireThreadExtras} for the same reason the approval
|
|
75
|
+
* card is: the library's own hooks throw on a non-statewire thread.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readDeepAgentStatewireExtras(extras: unknown): DeepAgentStatewireExtras | null;
|
|
78
|
+
/**
|
|
79
|
+
* The host's parent of `sourceId`: the raw wire message directly before it
|
|
80
|
+
* (`null` when it is the first of the whole transcript). Returns `undefined`
|
|
81
|
+
* when `sourceId` is not in the raw list at all — an optimistic bubble the
|
|
82
|
+
* host has not settled yet, a message below the loaded window, or a surface
|
|
83
|
+
* whose state this module cannot read — or when it is the first loaded
|
|
84
|
+
* message while older ones exist (`hasOlder`), so the caller can load more or
|
|
85
|
+
* fall back to the library's own path instead of asserting a wrong anchor.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveWireAnchorMessageId({ wireMessages, sourceId, hasOlder, }: {
|
|
88
|
+
wireMessages: readonly {
|
|
89
|
+
id?: unknown;
|
|
90
|
+
}[] | undefined;
|
|
91
|
+
sourceId: string;
|
|
92
|
+
hasOlder?: boolean;
|
|
93
|
+
}): string | null | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Whether `sourceId`'s parent lies below the loaded window: the message is
|
|
96
|
+
* absent from the raw list, or its first entry, while older messages exist.
|
|
97
|
+
* The caller loads older history before an edit can be anchored.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isSourceBelowLoadedWindow({ wireMessages, sourceId, window, }: {
|
|
100
|
+
wireMessages: readonly {
|
|
101
|
+
id?: unknown;
|
|
102
|
+
}[] | undefined;
|
|
103
|
+
sourceId: string;
|
|
104
|
+
window: DeepAgentMessageWindow | null;
|
|
105
|
+
}): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The `run/edit` command for resubmitting `sourceId` with `text`, anchored on
|
|
108
|
+
* the host's own parent. `null` when the anchor cannot be resolved from the
|
|
109
|
+
* replicated state.
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildDeepAgentEditCommand({ extras, sourceId, text, }: {
|
|
112
|
+
extras: DeepAgentStatewireExtras;
|
|
113
|
+
sourceId: string;
|
|
114
|
+
text: string;
|
|
115
|
+
}): StatewireThread.RunEditCommand | null;
|
|
116
|
+
/**
|
|
117
|
+
* State one more page of older history for a windowed thread: the next page
|
|
118
|
+
* past the loaded window's oldest message. Resolves `true` once the host has
|
|
119
|
+
* mounted it (it answers the statement after mounting), `false` when there is
|
|
120
|
+
* nothing older, the thread is not a windowed statewire thread, or no page can
|
|
121
|
+
* be stated. For a reader that needs a message below the loaded window — a
|
|
122
|
+
* search result revealing an older turn of a long conversation — and pages
|
|
123
|
+
* until it renders.
|
|
124
|
+
*/
|
|
125
|
+
export declare function loadOlderDeepAgentHistoryPage({ readExtras, pageSize, }: {
|
|
126
|
+
readExtras: () => DeepAgentStatewireExtras | null;
|
|
127
|
+
pageSize?: number;
|
|
128
|
+
}): Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Pages of older history stated while looking for an edited message's host
|
|
131
|
+
* parent. Each page is up to a window's worth of messages, so an edit reaches
|
|
132
|
+
* this many windows below what was loaded before it gives up.
|
|
133
|
+
*/
|
|
134
|
+
export declare const MAX_EDIT_ANCHOR_HISTORY_LOADS = 5;
|
|
135
|
+
/**
|
|
136
|
+
* The anchored `run/edit` for `sourceId`, stating older page interests one at
|
|
137
|
+
* a time when the message's parent lies below the loaded window. Every page
|
|
138
|
+
* is read back from the live documents (`readExtras` — the host mounts them
|
|
139
|
+
* before it answers the statement), so the anchor is always the host's own
|
|
140
|
+
* parent id.
|
|
141
|
+
*
|
|
142
|
+
* Resolves `null` — the caller's cue for the library's composer path, whose
|
|
143
|
+
* failure it reports — when the thread is not a statewire thread, the host has
|
|
144
|
+
* not settled the message, the history is exhausted without it, or the page
|
|
145
|
+
* budget ({@link MAX_EDIT_ANCHOR_HISTORY_LOADS}) is spent. A synchronous
|
|
146
|
+
* resolution never awaits: the first read either anchors at once or decides
|
|
147
|
+
* that pages are needed.
|
|
148
|
+
*/
|
|
149
|
+
export declare function resolveDeepAgentEditCommand({ readExtras, sourceId, text, pageSize, maxHistoryLoads, }: {
|
|
150
|
+
/** The live thread extras — re-read per page so each anchor attempt sees the widened window. */
|
|
151
|
+
readExtras: () => DeepAgentStatewireExtras | null;
|
|
152
|
+
sourceId: string;
|
|
153
|
+
text: string;
|
|
154
|
+
pageSize?: number;
|
|
155
|
+
maxHistoryLoads?: number;
|
|
156
|
+
}): Promise<StatewireThread.RunEditCommand | null>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { StatewireClient } from 'statewire';
|
|
2
|
+
import type { DeepAgentConnectionState } from './types';
|
|
3
|
+
/** Structured payload attached to a server-rejected Statewire command. */
|
|
4
|
+
export interface StatewireRejectionPayload {
|
|
5
|
+
status: number;
|
|
6
|
+
detail: unknown;
|
|
7
|
+
}
|
|
8
|
+
/** Return a rejected command's structured `{ status, detail }` payload. */
|
|
9
|
+
export declare function statewireRejectionPayload(error: unknown): StatewireRejectionPayload | null;
|
|
10
|
+
/**
|
|
11
|
+
* The server's human-readable reason for a rejected command — `detail.message`
|
|
12
|
+
* (or a plain-string `detail`) — else `null`. Hosts surface it as send
|
|
13
|
+
* feedback so the user sees the actionable cause instead of the generic
|
|
14
|
+
* client-side `command rejected (<status>)`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function statewireRejectionDetailMessage(error: unknown): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* A structured, retryable refusal the host recorded as the run error
|
|
19
|
+
* (`runs.error`): the dispatch never started — the pod or instance was
|
|
20
|
+
* closing (`pod_draining`) — and the entries stayed in their lanes for the
|
|
21
|
+
* thread's next placement. Distinct from a rejected COMMAND
|
|
22
|
+
* ({@link statewireRejectionPayload}): this is the shape harness-sdk writes
|
|
23
|
+
* when the run executor raises the rejection, so it lives on the replicated
|
|
24
|
+
* run entry, not on a command settle.
|
|
25
|
+
*/
|
|
26
|
+
export interface RetryableRunRefusal {
|
|
27
|
+
/** The structured `detail.code` (`pod_draining`). */
|
|
28
|
+
code: string;
|
|
29
|
+
/** The server's human-readable reason, when it sent one. */
|
|
30
|
+
message: string | null;
|
|
31
|
+
}
|
|
32
|
+
export declare function readRetryableRunRefusal(error: unknown): RetryableRunRefusal | null;
|
|
33
|
+
/**
|
|
34
|
+
* The `detail.code` agora answers when a send names another channel of the
|
|
35
|
+
* collab agent a session started on (`collab_agent_bridge.py`): a session
|
|
36
|
+
* keeps its channel — the SDK app's Agent / Ask mode — for its lifetime, and
|
|
37
|
+
* the way to the other mode is a new session. Wire-frozen.
|
|
38
|
+
*/
|
|
39
|
+
export declare const COLLAB_AGENT_CHANNEL_SESSION_MISMATCH = "collab_agent_channel_session_mismatch";
|
|
40
|
+
/**
|
|
41
|
+
* A structured refusal the host recorded as the run error when the run could
|
|
42
|
+
* not START: the run executor raised the gate's `{status, detail: {code,
|
|
43
|
+
* message}}` envelope (agora's `_status_reject`) before it accepted the
|
|
44
|
+
* dispatched input, so the message went back to its lane and the thread rests
|
|
45
|
+
* `error` with it still queued. Unlike a retryable refusal
|
|
46
|
+
* ({@link readRetryableRunRefusal}) nothing will dispatch it later: resending
|
|
47
|
+
* the same input is refused the same way, so the server's message is the only
|
|
48
|
+
* explanation the person gets.
|
|
49
|
+
*/
|
|
50
|
+
export interface RunStartRefusal {
|
|
51
|
+
/** The structured `detail.code` (`collab_agent_channel_session_mismatch`, …). */
|
|
52
|
+
code: string;
|
|
53
|
+
/** The server's human-readable reason, when it sent one. */
|
|
54
|
+
message: string | null;
|
|
55
|
+
/** The HTTP-style status the gate raised with, when recorded. */
|
|
56
|
+
status: number | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The non-retryable structured refusal off a replicated run error
|
|
60
|
+
* (`runs.error`), or `null` — for a run that failed while it was running (a
|
|
61
|
+
* plain `{message}`), a retryable refusal, or no error at all.
|
|
62
|
+
*/
|
|
63
|
+
export declare function readRunStartRefusal(error: unknown): RunStartRefusal | null;
|
|
64
|
+
/** The structured `detail.code` of a rejected command, or `null`. */
|
|
65
|
+
export declare function statewireRejectionCode(error: unknown): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* A structured, retryable refusal of a COMMAND, read off its rejection
|
|
68
|
+
* ({@link statewireRejectionPayload}): the host's `_structured_reject(...,
|
|
69
|
+
* retryable=True)` envelope — `command_auth_context_expired` when a pod
|
|
70
|
+
* replacement dropped the socket-scoped auth a replayed command needed,
|
|
71
|
+
* `pod_draining` when the host was closing. The command never ran, and the
|
|
72
|
+
* host itself says a resend after the reconnect will; `detail.code` is the
|
|
73
|
+
* wire-frozen contract clients classify on. Same shape as
|
|
74
|
+
* {@link readRetryableRunRefusal}, which reads it off a replicated run entry.
|
|
75
|
+
*/
|
|
76
|
+
export interface RetryableCommandRejection {
|
|
77
|
+
/** The structured `detail.code`. */
|
|
78
|
+
code: string;
|
|
79
|
+
/** The server's human-readable reason, when it sent one. */
|
|
80
|
+
message: string | null;
|
|
81
|
+
}
|
|
82
|
+
export declare function readRetryableCommandRejection(error: unknown): RetryableCommandRejection | null;
|
|
83
|
+
/** The host's `detail.code` for a command replayed onto a pod that could not restore its auth context. */
|
|
84
|
+
export declare const STATEWIRE_COMMAND_AUTH_CONTEXT_EXPIRED = "command_auth_context_expired";
|
|
85
|
+
/**
|
|
86
|
+
* Whether a rejected command hit the host's fail-closed auth recovery: the
|
|
87
|
+
* command was replayed onto a replacement pod that could not restore the
|
|
88
|
+
* attach's auth context, so it was refused unrun (503, retryable). The
|
|
89
|
+
* reconnect already under way restores the context; a single resend after it
|
|
90
|
+
* is the recovery, not a failure to report.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isStatewireCommandAuthContextExpired(error: unknown): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The `detail.code` agora answers for a write to an archived (trashed)
|
|
95
|
+
* conversation (`host_rejects._conversation_archived_reject`, a 409): it
|
|
96
|
+
* takes no new turns, config writes or approval answers until it is
|
|
97
|
+
* restored, and stopping still works. Wire-frozen.
|
|
98
|
+
*/
|
|
99
|
+
export declare const CONVERSATION_ARCHIVED = "conversation_archived";
|
|
100
|
+
/** What a person is told when that refusal comes back (the server says the same). */
|
|
101
|
+
export declare const CONVERSATION_ARCHIVED_MESSAGE = "This conversation is archived. Restore it to continue.";
|
|
102
|
+
/**
|
|
103
|
+
* Whether a rejected command was refused because the conversation is archived
|
|
104
|
+
* ({@link CONVERSATION_ARCHIVED}). Not retriable: nothing changes until a
|
|
105
|
+
* restore, so callers show {@link CONVERSATION_ARCHIVED_MESSAGE} rather than a
|
|
106
|
+
* "try again".
|
|
107
|
+
*/
|
|
108
|
+
export declare function isConversationArchivedRejection(error: unknown): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether a rejected command hit the legacy-thread dispatch fence: the
|
|
111
|
+
* structured 409 the server answers when an out-of-band run is writing a
|
|
112
|
+
* pre-cutover thread (or its adoption failed). A per-send failure — the
|
|
113
|
+
* snapshot never carries a standing read-only flag.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isLegacyThreadReadOnlyRejection(error: unknown): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Whether a rejected command was refused because its rewind anchor no longer
|
|
118
|
+
* matches the host's parent for the edited message (`wrong-anchor`).
|
|
119
|
+
*
|
|
120
|
+
* A retry/edit resubmit is dispatched optimistically, so this rejection lands
|
|
121
|
+
* after the UI already cleared its edit affordances: the turn simply never
|
|
122
|
+
* re-runs. Callers use this to tell the user the resubmit was dropped instead
|
|
123
|
+
* of leaving a console-only failure.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isStatewireRewindAnchorRejection(error: unknown): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Whether a statewire send failure is the host's `expired` verdict
|
|
128
|
+
* (`result-unavailable`): the command's seq was at or below the host's
|
|
129
|
+
* admitted watermark and no retained result was left for it. Either the
|
|
130
|
+
* command ran and settled but the client re-asked for the answer (a resend
|
|
131
|
+
* after the stream came back) only after the host had let the retained result
|
|
132
|
+
* go, or the seq was already admitted and the command was absorbed as a
|
|
133
|
+
* duplicate without ever running — a client whose shared session record fell
|
|
134
|
+
* behind the watermark stays there until a reconnect re-syncs it. The library
|
|
135
|
+
* never reruns the command on replay, so for an idempotent read the answer is
|
|
136
|
+
* simply gone — asking again is the correct reaction, not reporting a failure;
|
|
137
|
+
* a write cannot assume it was applied.
|
|
138
|
+
*/
|
|
139
|
+
export declare function isStatewireExpiredVerdict(error: unknown): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Whether a statewire send failure is a local channel death rather than a
|
|
142
|
+
* command error.
|
|
143
|
+
*
|
|
144
|
+
* The library's contract for `SendFailure.cause`: `"server"` is the server's
|
|
145
|
+
* own answer; every other cause is "a channel death the client settled
|
|
146
|
+
* locally" — `unmount`, `stream-gone`, and `session-lost`. A thread switch
|
|
147
|
+
* settles every in-flight command that way, so logging these at error level
|
|
148
|
+
* reports two failures for an ordinary switch and buries the ones that mean
|
|
149
|
+
* something.
|
|
150
|
+
*
|
|
151
|
+
* Channel health is already surfaced where it belongs: the connection
|
|
152
|
+
* indicator renders the connection state. This
|
|
153
|
+
* predicate only decides the log level.
|
|
154
|
+
*/
|
|
155
|
+
export declare function isStatewireChannelTeardown(error: unknown): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* The low-cardinality reason a statewire send settled as transport weather
|
|
158
|
+
* rather than a defect, or `null` when the failure is a real error.
|
|
159
|
+
*
|
|
160
|
+
* Three families qualify: a channel death the client settled locally
|
|
161
|
+
* ({@link isStatewireChannelTeardown} — the cause: `unmount`, `stream-gone`,
|
|
162
|
+
* `session-lost`), the host's `expired` verdict
|
|
163
|
+
* ({@link isStatewireExpiredVerdict} — the answer outlived the host's
|
|
164
|
+
* retention before the post-reconnect resend collected it), and a retryable
|
|
165
|
+
* structured rejection ({@link readRetryableCommandRejection} — its code: the
|
|
166
|
+
* host asked for a resend). In every case the sender's own retry or poll is
|
|
167
|
+
* the recovery and the connection indicator already shows the channel, so
|
|
168
|
+
* error reporting counts the outcome instead of paging on it. Handler
|
|
169
|
+
* failures, crashes, and non-retryable rejections stay `null`: those are
|
|
170
|
+
* defects to page on.
|
|
171
|
+
*/
|
|
172
|
+
export declare function statewireTransportOutcome(error: unknown): string | null;
|
|
173
|
+
/** Preserve the Statewire lifecycle and sanitize host detail for display. */
|
|
174
|
+
export declare function projectDeepAgentConnection(connection: StatewireClient.ConnectionState): DeepAgentConnectionState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the deepagents `execute` (shell) tool: the command's headline and
|
|
3
|
+
* the status notes the backend appends to its output. Pure, so every surface
|
|
4
|
+
* that lists shell commands (a tool card, a session's Shell pane) agrees on
|
|
5
|
+
* what succeeded.
|
|
6
|
+
*/
|
|
7
|
+
export interface ShellCommandSummary {
|
|
8
|
+
/** The first non-blank line of the command, trimmed. */
|
|
9
|
+
firstLine: string;
|
|
10
|
+
/** How many lines follow it. */
|
|
11
|
+
extraLines: number;
|
|
12
|
+
}
|
|
13
|
+
/** A shell command's first non-blank line plus how many lines follow it. */
|
|
14
|
+
export declare function summarizeShellCommand(command: string): ShellCommandSummary;
|
|
15
|
+
export interface ParsedExecuteOutput {
|
|
16
|
+
/** The command's output with the trailing status notes removed. */
|
|
17
|
+
body: string;
|
|
18
|
+
/** The exit code from the status note, or `null` when the output carries none. */
|
|
19
|
+
exitCode: number | null;
|
|
20
|
+
/** Whether the backend cut the output (`[Output was truncated due to size limits]`). */
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Split an `execute` result into its output and the notes agora's execute
|
|
25
|
+
* router appends (`_format_execute_output` in `asset_execute.py`, mirroring
|
|
26
|
+
* the SDK tool): `[Command succeeded with exit code 0]`, `[Command failed with
|
|
27
|
+
* exit code 1]` and `[Output was truncated due to size limits]`. A result
|
|
28
|
+
* without an exit note (an `Error: …` refusal before the command ran, an
|
|
29
|
+
* output the live window cut) reports `exitCode: null`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseExecuteOutput(raw: string): ParsedExecuteOutput;
|