@athenaintel/react 0.41.2 → 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 +108 -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.cjs +158 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.cjs.map +1 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.js +158 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.js.map +1 -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 +329 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.js +329 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -0
- 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 +77 -6
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.js +78 -7
- 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 +19 -11
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +25 -9
- package/dist/chat/super-grouping/activity-timeline.js +19 -11
- 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 +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -6
- package/dist/index.js +19 -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.cjs +77 -0
- package/dist/offline/offline-history.cjs.map +1 -0
- package/dist/offline/offline-history.d.ts +60 -0
- package/dist/offline/offline-history.js +77 -0
- package/dist/offline/offline-history.js.map +1 -0
- package/dist/provider/AthenaProvider.cjs +206 -9
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +22 -1
- package/dist/provider/AthenaProvider.js +207 -10
- 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.cjs +75 -0
- package/dist/threads/offline-session-list.cjs.map +1 -0
- package/dist/threads/offline-session-list.d.ts +27 -0
- package/dist/threads/offline-session-list.js +75 -0
- package/dist/threads/offline-session-list.js.map +1 -0
- 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 +105 -20
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +31 -3
- package/dist/threads/statewire-thread-list.js +107 -22
- 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":"interrupts.js","sources":["../../../../agent-runtime/src/interrupts.ts"],"sourcesContent":["/**\n * Human-in-the-loop interrupt primitives shared by every statewire chat\n * surface (Olympus, the React SDK, the Office add-in, the Chrome extension,\n * mobile).\n *\n * The agora deep-agent runtime parks a gated run on an `interrupt` input\n * request whose payload carries the Athena `hitl_approval` shape\n * (`athena_deep_agent/hitl_bridge.py`). A surface answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. This module holds the\n * payload contract (narrowing, resume values) and the shared resume-lock state\n * machine; rendering stays with each surface.\n *\n * Deliberately parameterized rather than self-wiring: these helpers never call\n * `useStatewireRuns`/`useAuiState` themselves. Each surface reads its own\n * statewire hooks (which its tests already mock) and passes the values in, so\n * the shared semantics cannot drift while per-surface wiring stays testable.\n */\n\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { hasClientToolInterruptSource } from './client-tools';\nimport { statewireTransportOutcome } from './errors';\nimport { readDeepAgentStreamValues } from './statewire-state';\n\n/** Human-in-the-loop approval payload the agora deep-agent runtime parks a run\n * on (shaped by `athena_deep_agent/hitl_bridge.py`). */\nexport interface HitlApprovalPayload {\n source: string;\n type: string;\n message: string;\n /** Risk headline/facts/warnings, when the host includes them. */\n approval_context?: unknown;\n context?: {\n tool_name?: string;\n tool_id?: string;\n tool_call_id?: string;\n tool_args?: Record<string, unknown>;\n pending_action_count?: number;\n approval_context?: unknown;\n /**\n * Every pending gated call (name + args), in decision order. Absent on\n * older backends — fall back to the single `tool_name`/`tool_args` pair.\n * Per-dispatch payloads also carry each lane's `tool_call_id` (the lane\n * card key) and `interrupt_id` (the lane resume key).\n */\n action_requests?: {\n name?: string;\n args?: Record<string, unknown>;\n tool_call_id?: string;\n interrupt_id?: string;\n /**\n * True when \"approve all for this session\" would take effect for this\n * tool (the workspace allows overriding its approval). Absent on older\n * backends and on non-overridable tools: the option is not offered.\n */\n session_approval_allowed?: boolean;\n /**\n * The decision types the parked gate accepts for this call (`approve`,\n * `reject`, `edit`). Absent on older backends: only approve / reject\n * are known to be accepted.\n */\n allowed_decisions?: string[];\n /** What the backend resolved about this call before asking (display-only). */\n approval_context?: unknown;\n }[];\n /**\n * True when each dispatch parked on its own interrupt: decisions submit\n * per lane via `lane_decisions` and each approved lane starts immediately,\n * instead of the legacy batch where one resume must answer every lane.\n */\n per_dispatch?: boolean;\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A pending `interrupt` input request; a present `response` key marks it answered. */\nexport function isPendingInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n return request.type === 'interrupt' && !('response' in request);\n}\n\n/**\n * Interrupt sources that were system pauses before the host stamped\n * `requires_user_action: false` on them (a background deep-research wait). Kept\n * only for the deploy skew between an older agora and a newer client; delete\n * once every deployment's raiser stamps the flag.\n */\nconst LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES: ReadonlySet<string> = new Set(['deep_research_pending']);\n\n/**\n * A park nobody answers: the agent is still working (a background research\n * wait) and the backend resumes it itself. The raiser stamps\n * `requires_user_action: false`; older raisers are recognised by source.\n */\nexport function isSystemPauseInterrupt(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (payload.requires_user_action === false) return true;\n return (\n typeof payload.source === 'string' && LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES.has(payload.source)\n );\n}\n\n/**\n * A pending interrupt an approval card may answer. Two kinds are excluded —\n * client-tool parks (the client-tool bridge owns those, and a generic resume\n * would corrupt the parked tool call) and system pauses (nothing to answer; the\n * backend resumes them). The source checks are deliberately loose so a skewed\n * deploy can never route one here.\n */\nexport function isApprovalCardInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n if (!isPendingInterrupt(request)) return false;\n const payload = (request as { payload?: unknown }).payload;\n return !hasClientToolInterruptSource(payload) && !isSystemPauseInterrupt(payload);\n}\n\n/** Narrow an interrupt payload to the Athena HITL approval shape. */\nexport function asHitlApproval(value: unknown): HitlApprovalPayload | null {\n if (!isRecord(value)) return null;\n return value.type === 'hitl' &&\n value.source === 'hitl_approval' &&\n typeof value.message === 'string'\n ? (value as unknown as HitlApprovalPayload)\n : null;\n}\n\n/** Default paused-run copy when an interrupt payload carries no message. */\nexport const DEFAULT_INTERRUPT_PAUSED_MESSAGE =\n 'The agent is paused and waiting for input.';\n\n/** Best-effort human-readable message from any interrupt payload. */\nexport function readInterruptMessage(\n value: unknown,\n fallback: string = DEFAULT_INTERRUPT_PAUSED_MESSAGE,\n): string {\n if (isRecord(value) && typeof value.message === 'string' && value.message.length > 0) {\n return value.message;\n }\n return fallback;\n}\n\n/** One label/value row of a call's resolved approval facts. */\nexport interface PendingApprovalFact {\n label: string;\n value: string;\n}\n\n/** One caution of a call's resolved approval facts. */\nexport interface PendingApprovalWarning {\n severity: 'info' | 'warning' | 'critical';\n message: string;\n}\n\nexport interface PendingApprovalSlackTarget {\n catalog_id: string;\n conversation_id: string | null;\n thread_ts: string | null;\n team_url: string | null;\n people: string[];\n}\n\n/**\n * What the backend resolved about a gated call before asking — e.g. where a\n * Slack write goes and as whom (agora `services/interrupts/approval_context.py`).\n * Display-only; the decision still answers the parked call.\n */\nexport interface PendingApprovalContext {\n facts: PendingApprovalFact[];\n warnings: PendingApprovalWarning[];\n slack_target?: PendingApprovalSlackTarget;\n}\n\nconst APPROVAL_WARNING_SEVERITIES = new Set(['info', 'warning', 'critical']);\n\nfunction isNullableString(value: unknown): value is string | null {\n return value === null || typeof value === 'string';\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\nfunction parsePendingApprovalSlackTarget(value: unknown): PendingApprovalSlackTarget | undefined {\n if (!isRecord(value) || typeof value.catalog_id !== 'string') return undefined;\n const conversationId = value.conversation_id;\n const threadTs = value.thread_ts;\n const teamUrl = value.team_url;\n const people = value.people === undefined ? [] : value.people;\n if (\n !isNullableString(conversationId) ||\n !isNullableString(threadTs) ||\n !isNullableString(teamUrl) ||\n !isStringArray(people)\n )\n return undefined;\n return {\n catalog_id: value.catalog_id,\n conversation_id: conversationId,\n thread_ts: threadTs,\n team_url: teamUrl,\n people,\n };\n}\n\n/** A call's `approval_context`, or `undefined` when absent or empty. */\nexport function parsePendingApprovalContext(value: unknown): PendingApprovalContext | undefined {\n if (!isRecord(value)) return undefined;\n const facts: PendingApprovalFact[] = Array.isArray(value.facts)\n ? value.facts.flatMap((fact) =>\n isRecord(fact) && typeof fact.label === 'string' && typeof fact.value === 'string'\n ? [{ label: fact.label, value: fact.value }]\n : [],\n )\n : [];\n const warnings: PendingApprovalWarning[] = Array.isArray(value.warnings)\n ? value.warnings.flatMap((warning) => {\n if (!isRecord(warning) || typeof warning.message !== 'string') return [];\n const severity =\n typeof warning.severity === 'string' && APPROVAL_WARNING_SEVERITIES.has(warning.severity)\n ? (warning.severity as PendingApprovalWarning['severity'])\n : 'info';\n return [{ severity, message: warning.message }];\n })\n : [];\n const slackTarget = parsePendingApprovalSlackTarget(value.slack_target);\n return facts.length > 0 || warnings.length > 0 || slackTarget\n ? { facts, warnings, ...(slackTarget ? { slack_target: slackTarget } : {}) }\n : undefined;\n}\n\nexport interface PendingActionRequest {\n name: string;\n args: Record<string, unknown>;\n /** The lane's `task` tool-call id (present on per-dispatch payloads). */\n toolCallId?: string;\n /** The lane's langgraph interrupt id — the `lane_decisions` resume key. */\n interruptId?: string;\n /** Present (true) when a session-wide approval would cover later calls of this tool. */\n sessionApprovalAllowed?: true;\n /** Present (true) when the gate accepts an `edit` decision for this call. */\n editAllowed?: true;\n /** Present when the backend resolved facts about this call before asking. */\n approvalContext?: PendingApprovalContext;\n}\n\n/**\n * Every gated call this approval covers, in decision order. One resume answers\n * ALL of them, so every entry must stay reviewable somewhere. Falls back to\n * the single first-call fields on older backends without `action_requests`.\n */\nexport function pendingActionRequests(hitl: HitlApprovalPayload | null): PendingActionRequest[] {\n const context = hitl?.context;\n if (!context) return [];\n // The payload crosses the wire with only its top-level shape narrowed\n // (`asHitlApproval`), so the nested collection must be validated before any\n // array/property access: a malformed host value must degrade to \"no\n // reviewable entries\", never crash the approval surface.\n const requests: Record<string, unknown>[] = Array.isArray(context.action_requests)\n ? context.action_requests.filter(isRecord)\n : context.tool_name && context.tool_args\n ? [{ name: context.tool_name, args: context.tool_args, tool_call_id: context.tool_call_id }]\n : [];\n return requests.map((request) => {\n const approvalContext = parsePendingApprovalContext(request.approval_context);\n return {\n name: typeof request.name === 'string' ? request.name : 'tool',\n args: isRecord(request.args) ? request.args : {},\n ...(typeof request.tool_call_id === 'string' && { toolCallId: request.tool_call_id }),\n ...(typeof request.interrupt_id === 'string' && { interruptId: request.interrupt_id }),\n ...(request.session_approval_allowed === true && { sessionApprovalAllowed: true }),\n ...(Array.isArray(request.allowed_decisions) &&\n request.allowed_decisions.includes('edit') && { editAllowed: true }),\n ...(approvalContext && { approvalContext }),\n };\n });\n}\n\n/**\n * Whether the card may offer \"approve all for this session\": every pending\n * call must be one the backend stamped as session-approvable, so a batch that\n * mixes in a tool the workspace pinned as always-prompt only offers the\n * one-time answer.\n */\nexport function canApproveForSession(actionRequests: readonly PendingActionRequest[]): boolean {\n return (\n actionRequests.length > 0 &&\n actionRequests.every((request) => request.sessionApprovalAllowed === true)\n );\n}\n\n/** An interrupt a non-resume dispatch dropped, published by the host. */\nexport interface AbandonedInputRequest {\n id: string;\n type: string;\n}\n\n/**\n * `useStatewireState` selector body for the host-published abandoned input\n * requests. Reads through {@link readDeepAgentStreamValues} so the selector is\n * safe on the pre-attach (`undefined`) wire state, and returns the raw array\n * reference so the subscription stays shallow-stable — derive (`.find`) on the\n * result, never inside the selector.\n */\nexport function readAbandonedInputRequests(\n state: unknown,\n): readonly AbandonedInputRequest[] | undefined {\n const abandoned = readDeepAgentStreamValues(state).abandonedInputRequests;\n // Wire value: anything non-array (including a malformed host publication)\n // reads as \"none\" rather than crashing the consuming surface. Identity-\n // preserving for the valid case, so it stays selector-safe.\n return Array.isArray(abandoned)\n ? (abandoned as readonly AbandonedInputRequest[])\n : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the host's mirrored interrupt\n * (`__interrupt__`, the LangGraph `{value, resumable}` wrapper). The mirror\n * is published the moment a lane parks on its gate — while sibling lanes are\n * still streaming and the run manager has NOT yet published an answerable\n * input request. Raw reference, selector-safe; unwrap with\n * {@link interruptMirrorPayload}.\n */\nexport function readInterruptMirror(state: unknown): unknown {\n return readDeepAgentStreamValues(state).__interrupt__;\n}\n\n/** The payload of a mirrored interrupt wrapper, or `undefined` for anything else. */\nexport function interruptMirrorPayload(mirror: unknown): unknown {\n return isRecord(mirror) ? mirror.value : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the per-dispatch lane decisions the\n * host accepted through `run/lane-input` while the run was still streaming\n * (`queuedLaneDecisions`, keyed by langgraph interrupt id). Held until the\n * run parks, then answered as a native `lane_decisions` resume; every attached\n * client reads a queued lane as decided. Raw reference, selector-safe.\n */\nexport function readQueuedLaneDecisions(\n state: unknown,\n): Readonly<Record<string, unknown>> | undefined {\n const queued = readDeepAgentStreamValues(state).queuedLaneDecisions;\n return isRecord(queued) ? queued : undefined;\n}\n\n/**\n * The distinct langgraph interrupt ids a `lane_decisions` resume answers for\n * these gated calls, in first-seen order — or `null` when any call lacks its\n * stamp (a legacy batch payload only a positional resume can answer). A\n * nested HITL request gating several calls contributes one id: the lane is\n * the interrupt, and one decision fans across its calls server-side.\n */\nexport function laneInterruptIds(actionRequests: readonly PendingActionRequest[]): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.interruptId === undefined) return null;\n if (!ids.includes(request.interruptId)) ids.push(request.interruptId);\n }\n return ids;\n}\n\n/** One decision for every lane — the `lane_decisions` map a run-wide approve or reject sends. */\nexport function fanLaneDecision<T>({\n interruptIds,\n decision,\n}: {\n interruptIds: readonly string[];\n decision: T;\n}): Record<string, T> {\n return Object.fromEntries(interruptIds.map((id) => [id, decision]));\n}\n\n/** The abandoned `interrupt` entry, if any — the \"approval was cancelled\" notice. */\nexport function findAbandonedInterrupt(\n abandoned: readonly AbandonedInputRequest[] | undefined,\n): AbandonedInputRequest | undefined {\n return abandoned?.find(\n (request) => isRecord(request) && request.type === 'interrupt' && typeof request.id === 'string',\n );\n}\n\n/** Canonical reason string carried by a user rejection. */\nexport const HITL_REJECT_REASON = 'User rejected the action.';\n\n/**\n * Default {@link UseApprovalResumeLockOptions.pendingResumeGraceMs} for every\n * approval surface: how long a clicked decision waits for its resume run to\n * start before the actions unlock again. Covers a `run/input` the host\n * rejected or a disconnected transport swallowed before any run began — the\n * one failure neither identity-change nor observed-run recovery can detect.\n */\nexport const HITL_PENDING_RESUME_GRACE_MS = 15_000;\n\n/**\n * Default {@link UseApprovalResumeLockOptions.maxTransportRetries}: how many\n * times a decision the transport lost (the websocket dropped or the statewire\n * session reset while the `run/input` was in flight) is re-sent on its own\n * before the user is asked to click again.\n */\nexport const HITL_RESUME_TRANSPORT_RETRIES = 3;\n\n/**\n * The dispatch died client-side without the host ever seeing it — a proven\n * session loss or a gone stream. Safe to re-send the same decision for the\n * same still-parked request. The complement (a server verdict, or the surface\n * unmounting) is not.\n */\nexport function isResumeTransportLoss(error: unknown): boolean {\n const outcome = statewireTransportOutcome(error);\n return outcome === 'session-lost' || outcome === 'stream-gone';\n}\n\n/** `run/input` resume value approving the gated call(s). */\nexport function hitlResumeApprove(): Record<string, string> {\n return { action: 'approve' };\n}\n\n/**\n * `run/input` resume value approving the gated call(s) AND every later call of\n * the same tool(s) on this thread. The backend records the tools from its own\n * parked interrupt (never from this payload), so the value carries no names.\n */\nexport function hitlResumeApproveForSession(): Record<string, string> {\n return { action: 'approve', scope: 'session' };\n}\n\n/** `run/input` resume value rejecting the gated call(s). */\nexport function hitlResumeReject(reason: string = HITL_REJECT_REASON): Record<string, string> {\n return { action: 'reject', reason };\n}\n\n/** One gated call's own answer inside a per-action resume ({@link hitlResumeActionDecisions}). */\nexport type HitlActionDecision =\n | { action: 'approve' }\n | { action: 'reject'; reason: string }\n | { action: 'edit'; edited_args: Record<string, unknown> };\n\n/**\n * The `tool_call_id` of every gated call, in decision order — or `null` when\n * any call lacks one or two calls share one, in which case no per-action\n * resume can be bound to the batch and only the batch answers above apply.\n */\nexport function actionRequestToolCallIds(\n actionRequests: readonly PendingActionRequest[],\n): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.toolCallId === undefined || ids.includes(request.toolCallId)) return null;\n ids.push(request.toolCallId);\n }\n return ids;\n}\n\n/**\n * `run/input` resume value deciding each gated call by its `tool_call_id` —\n * the only channel that carries an edited call. The backend binds every entry\n * to the parked request with that id, takes the tool NAME from its own\n * request (an edit can change a call's arguments, never which tool runs), and\n * refuses the whole answer — nothing runs — unless the map names exactly the\n * parked calls. `edited_args` is the complete argument set the call runs\n * with, not a patch. The envelope `action` mirrors the first entry for hosts\n * that only read the envelope; `action_decisions` is authoritative.\n */\nexport function hitlResumeActionDecisions(\n decisions: Readonly<Record<string, HitlActionDecision>>,\n): Record<string, unknown> {\n const [anchorId, anchor] = Object.entries(decisions)[0] ?? [];\n return {\n action: anchor?.action === 'reject' ? 'reject' : 'approve',\n ...(anchorId !== undefined && { tool_call_id: anchorId }),\n action_decisions: decisions,\n };\n}\n\n/** Canonical reason string carried by a user declining a non-HITL park. */\nexport const INTERRUPT_DECLINE_REASON = 'User declined the request.';\n\n/**\n * `run/input` resume value declining a non-HITL park. `{ action: 'reject' }`\n * is the one value every typed raiser treats as a clean user decline\n * (`FormCancelledError` / `ToolRejectedError`); a generic `continue` would be\n * rejected by their resume schemas and surface as a tool error the agent then\n * improvises around.\n */\nexport function interruptResumeDecline(\n reason: string = INTERRUPT_DECLINE_REASON,\n): Record<string, string> {\n return { action: 'reject', reason };\n}\n\nexport interface UseApprovalResumeLockOptions<TValue> {\n /** The pending interrupt's request id (`undefined` when nothing is parked). */\n requestId: string | undefined;\n /** The surface's thread `isRunning` read (mockable per surface). */\n isRunning: boolean;\n /**\n * Dispatch the `run/input` resume for `requestId` on the surface's transport.\n * Return the dispatch promise so a refused or lost command releases the lock\n * at once and reaches `onResumeRejected`; a `void` return leaves the\n * recovery paths below as the only release.\n */\n sendResume: (requestId: string, value: TValue) => void | Promise<unknown>;\n /**\n * The dispatch `sendResume` returned rejected — the host refused the\n * `run/input` or the transport lost it. The lock is already released when\n * this fires; the surface tells the user, since the request is back on\n * screen with nothing else saying why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * A dispatch the transport lost is being re-sent for the still-parked\n * request; `attempt` counts the retries so far (1-based). Diagnostics only —\n * the lock stays held across the retry.\n */\n onResumeRetry?: (error: unknown, requestId: string, attempt: number) => void;\n /**\n * Automatic re-sends of a decision the transport lost\n * ({@link isResumeTransportLoss}) while the request is still parked. `0`\n * disables retries. Defaults to {@link HITL_RESUME_TRANSPORT_RETRIES}.\n */\n maxTransportRetries?: number;\n /**\n * Re-enable the actions when no resume run started within this window —\n * covers a `run/input` that was rejected or lost before any run began, so\n * neither reset path below can fire. Omit to keep the pre-existing surface\n * behavior of staying locked until a resume run is observed.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface ApprovalResumeLock<TValue> {\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Send the resume value, locking the actions. No-op (returns `undefined`)\n * while pending or unparked. Returns the dispatch promise when `sendResume`\n * produced one, so a surface can hold its own state until the host settles.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * Optimistic action lock shared by every approval surface: disable the\n * decision buttons the moment one is clicked, until the request identity\n * changes (it clears after the resume, or a fresh interrupt arrives). This\n * closes the double-click → duplicate-resume window.\n *\n * Recovery paths, in order of specificity:\n * 0. The dispatch itself rejected (a `sendResume` that returned a promise) —\n * released at once, and reported through `onResumeRejected`. A rejection\n * that is a transport loss (the socket dropped mid-flight) is re-sent up to\n * `maxTransportRetries` times first, the lock held throughout, so a flaky\n * connection does not hand the card back to the user for another click.\n * The returned promise settles with the final attempt.\n * 1. Identity change — the resume landed (or a new interrupt replaced the\n * request). Reset during render via React's \"previous value\" pattern.\n * 2. A resume run was observed starting and then settling with the request\n * still pending (failed/cancelled resume) — clear the lock so the user can\n * answer again.\n * 3. Optional grace window ({@link UseApprovalResumeLockOptions.pendingResumeGraceMs})\n * for a `run/input` that never started a run at all.\n */\nexport function useApprovalResumeLock<TValue = Record<string, string>>(\n options: UseApprovalResumeLockOptions<TValue>,\n): ApprovalResumeLock<TValue> {\n const {\n requestId,\n isRunning,\n sendResume,\n pendingResumeGraceMs,\n onResumeRejected,\n onResumeRetry,\n maxTransportRetries = HITL_RESUME_TRANSPORT_RETRIES,\n } = options;\n\n const [pending, setPending] = useState(false);\n // Bumped per re-send so the grace window restarts with each attempt.\n const [attempt, setAttempt] = useState(0);\n const prevRequestIdRef = useRef(requestId);\n if (prevRequestIdRef.current !== requestId) {\n prevRequestIdRef.current = requestId;\n if (pending) setPending(false);\n }\n\n // Track the resume run we kicked off (isRunning observed true→false while\n // pending) and clear `pending` when it ends with the request unresolved.\n const sawResumeRunRef = useRef(false);\n useEffect(() => {\n if (!pending) {\n sawResumeRunRef.current = false;\n return;\n }\n if (isRunning) {\n sawResumeRunRef.current = true;\n return;\n }\n if (sawResumeRunRef.current) {\n sawResumeRunRef.current = false;\n setPending(false);\n }\n }, [pending, isRunning]);\n\n // Pre-start failure recovery: re-enable after the grace window when no\n // resume run began; answering the still-parked request again is exactly\n // what the user needs to be able to do.\n useEffect(() => {\n if (!pending || pendingResumeGraceMs === undefined) return;\n const timer = setTimeout(() => {\n if (!sawResumeRunRef.current) setPending(false);\n }, pendingResumeGraceMs);\n return () => clearTimeout(timer);\n }, [pending, requestId, pendingResumeGraceMs, attempt]);\n\n const sendResumeRef = useRef(sendResume);\n sendResumeRef.current = sendResume;\n const onResumeRejectedRef = useRef(onResumeRejected);\n onResumeRejectedRef.current = onResumeRejected;\n const onResumeRetryRef = useRef(onResumeRetry);\n onResumeRetryRef.current = onResumeRetry;\n const maxTransportRetriesRef = useRef(maxTransportRetries);\n maxTransportRetriesRef.current = maxTransportRetries;\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const pendingRef = useRef(pending);\n pendingRef.current = pending;\n // One token per `resume` call: a settle from an earlier submission must not\n // retry over, or release, a newer one for the same request.\n const submissionRef = useRef(0);\n\n const resume = useCallback(\n (value: TValue): Promise<unknown> | undefined => {\n if (requestId === undefined || pendingRef.current) return undefined;\n const submission = ++submissionRef.current;\n setPending(true);\n pendingRef.current = true;\n setAttempt(0);\n const first: unknown = sendResumeRef.current(requestId, value);\n if (!(first instanceof Promise)) return undefined;\n // The final failure is already reported through `onResumeRejected`;\n // callers that drop the promise must not get an unhandled rejection.\n const outcome = new Promise<unknown>((resolve, reject) => {\n const settle = (dispatched: Promise<unknown>, retries: number) => {\n dispatched.then(resolve, (error: unknown) => {\n // A late refusal for a request the lock has since moved past (the\n // park was re-keyed, or a newer answer is in flight) must neither\n // release that answer's lock nor be reported as a failure of it.\n // The optimistic fold hides the answered request until the fold\n // rolls back, so `undefined` here is not a departure.\n const current = currentRequestIdRef.current;\n if (\n submission !== submissionRef.current ||\n (current !== undefined && current !== requestId)\n ) {\n reject(error);\n return;\n }\n if (retries < maxTransportRetriesRef.current && isResumeTransportLoss(error)) {\n const next = retries + 1;\n onResumeRetryRef.current?.(error, requestId, next);\n setPending(true);\n pendingRef.current = true;\n setAttempt(next);\n const resent: unknown = sendResumeRef.current(requestId, value);\n if (resent instanceof Promise) {\n settle(resent, next);\n return;\n }\n resolve(undefined);\n return;\n }\n setPending(false);\n pendingRef.current = false;\n onResumeRejectedRef.current?.(error, requestId);\n reject(error);\n });\n };\n settle(first, 0);\n });\n outcome.catch(() => {});\n return outcome;\n },\n [requestId],\n );\n\n return { pending, resume };\n}\n"],"names":[],"mappings":";;;;AA2EA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAGO,SAAS,mBACd,SAC+C;AAC/C,SAAO,QAAQ,SAAS,eAAe,EAAE,cAAc;AACzD;AAQA,MAAM,wCAA6D,oBAAI,IAAI,CAAC,uBAAuB,CAAC;AAO7F,SAAS,uBAAuB,SAA2B;AAChE,MAAI,CAAC,SAAS,OAAO,EAAG,QAAO;AAC/B,MAAI,QAAQ,yBAAyB,MAAO,QAAO;AACnD,SACE,OAAO,QAAQ,WAAW,YAAY,sCAAsC,IAAI,QAAQ,MAAM;AAElG;AASO,SAAS,wBACd,SAC+C;AAC/C,MAAI,CAAC,mBAAmB,OAAO,EAAG,QAAO;AACzC,QAAM,UAAW,QAAkC;AACnD,SAAO,CAAC,6BAA6B,OAAO,KAAK,CAAC,uBAAuB,OAAO;AAClF;AAGO,SAAS,eAAe,OAA4C;AACzE,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,SAAO,MAAM,SAAS,UACpB,MAAM,WAAW,mBACjB,OAAO,MAAM,YAAY,WACtB,QACD;AACN;AAGO,MAAM,mCACX;AAGK,SAAS,qBACd,OACA,WAAmB,kCACX;AACR,MAAI,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY,YAAY,MAAM,QAAQ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,YAAY,UAAa,YAAY,WACtC;AACA,qBAAO,KAAK;AACZ;AAAA,YACF;AACA,gBAAI,UAAU,uBAAuB,WAAW,sBAAsB,KAAK,GAAG;AAC5E,oBAAM,OAAO,UAAU;AACvB,qCAAiB,YAAjB,0CAA2B,OAAO,WAAW;AAC7C,yBAAW,IAAI;AACf,yBAAW,UAAU;AACrB,yBAAW,IAAI;AACf,oBAAM,SAAkB,cAAc,QAAQ,WAAW,KAAK;AAC9D,kBAAI,kBAAkB,SAAS;AAC7B,uBAAO,QAAQ,IAAI;AACnB;AAAA,cACF;AACA,sBAAQ,MAAS;AACjB;AAAA,YACF;AACA,uBAAW,KAAK;AAChB,uBAAW,UAAU;AACrB,sCAAoB,YAApB,6CAA8B,OAAO;AACrC,mBAAO,KAAK;AAAA,UACd,CAAC;AAAA,QACH;AACA,eAAO,OAAO,CAAC;AAAA,MACjB,CAAC;AACD,cAAQ,MAAM,MAAM;AAAA,MAAC,CAAC;AACtB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,SAAS;AAAA,EAAA;AAGZ,SAAO,EAAE,SAAS,OAAA;AACpB;"}
|
|
1
|
+
{"version":3,"file":"interrupts.js","sources":["../../../../agent-runtime/src/interrupts.ts"],"sourcesContent":["/**\n * Human-in-the-loop interrupt primitives shared by every statewire chat\n * surface (Olympus, the React SDK, the Office add-in, the Chrome extension,\n * mobile).\n *\n * The agora deep-agent runtime parks a gated run on an `interrupt` input\n * request whose payload carries the Athena `hitl_approval` shape\n * (`athena_deep_agent/hitl_bridge.py`). A surface answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. This module holds the\n * payload contract (narrowing, resume values) and the shared resume-lock state\n * machine; rendering stays with each surface.\n *\n * Deliberately parameterized rather than self-wiring: these helpers never call\n * `useStatewireRuns`/`useAuiState` themselves. Each surface reads its own\n * statewire hooks (which its tests already mock) and passes the values in, so\n * the shared semantics cannot drift while per-surface wiring stays testable.\n */\n\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { hasClientToolInterruptSource } from './client-tools';\nimport { statewireTransportOutcome } from './errors';\nimport { readDeepAgentStreamValues } from './statewire-state';\n\n/** Human-in-the-loop approval payload the agora deep-agent runtime parks a run\n * on (shaped by `athena_deep_agent/hitl_bridge.py`). */\nexport interface HitlApprovalPayload {\n source: string;\n type: string;\n message: string;\n /** Risk headline/facts/warnings, when the host includes them. */\n approval_context?: unknown;\n context?: {\n tool_name?: string;\n tool_id?: string;\n tool_call_id?: string;\n tool_args?: Record<string, unknown>;\n pending_action_count?: number;\n approval_context?: unknown;\n /**\n * Every pending gated call (name + args), in decision order. Absent on\n * older backends — fall back to the single `tool_name`/`tool_args` pair.\n * Per-dispatch payloads also carry each lane's `tool_call_id` (the lane\n * card key) and `interrupt_id` (the lane resume key).\n */\n action_requests?: {\n name?: string;\n args?: Record<string, unknown>;\n tool_call_id?: string;\n interrupt_id?: string;\n /**\n * True when \"approve all for this session\" would take effect for this\n * tool (the workspace allows overriding its approval). Absent on older\n * backends and on non-overridable tools: the option is not offered.\n */\n session_approval_allowed?: boolean;\n /**\n * The decision types the parked gate accepts for this call (`approve`,\n * `reject`, `edit`). Absent on older backends: only approve / reject\n * are known to be accepted.\n */\n allowed_decisions?: string[];\n /** What the backend resolved about this call before asking (display-only). */\n approval_context?: unknown;\n }[];\n /**\n * True when each dispatch parked on its own interrupt: decisions submit\n * per lane via `lane_decisions` and each approved lane starts immediately,\n * instead of the legacy batch where one resume must answer every lane.\n */\n per_dispatch?: boolean;\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A pending `interrupt` input request; a present `response` key marks it answered. */\nexport function isPendingInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n return request.type === 'interrupt' && !('response' in request);\n}\n\n/**\n * Interrupt sources that were system pauses before the host stamped\n * `requires_user_action: false` on them (a background deep-research wait). Kept\n * only for the deploy skew between an older agora and a newer client; delete\n * once every deployment's raiser stamps the flag.\n */\nconst LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES: ReadonlySet<string> = new Set(['deep_research_pending']);\n\n/**\n * A park nobody answers: the agent is still working (a background research\n * wait) and the backend resumes it itself. The raiser stamps\n * `requires_user_action: false`; older raisers are recognised by source.\n */\nexport function isSystemPauseInterrupt(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (payload.requires_user_action === false) return true;\n return (\n typeof payload.source === 'string' && LEGACY_SYSTEM_PAUSE_INTERRUPT_SOURCES.has(payload.source)\n );\n}\n\n/**\n * A pending interrupt an approval card may answer. Two kinds are excluded —\n * client-tool parks (the client-tool bridge owns those, and a generic resume\n * would corrupt the parked tool call) and system pauses (nothing to answer; the\n * backend resumes them). The source checks are deliberately loose so a skewed\n * deploy can never route one here.\n */\nexport function isApprovalCardInterrupt(\n request: StatewireThread.InputRequestState,\n): request is StatewireThread.CustomInputRequest {\n if (!isPendingInterrupt(request)) return false;\n const payload = (request as { payload?: unknown }).payload;\n return !hasClientToolInterruptSource(payload) && !isSystemPauseInterrupt(payload);\n}\n\n/** Narrow an interrupt payload to the Athena HITL approval shape. */\nexport function asHitlApproval(value: unknown): HitlApprovalPayload | null {\n if (!isRecord(value)) return null;\n return value.type === 'hitl' &&\n value.source === 'hitl_approval' &&\n typeof value.message === 'string'\n ? (value as unknown as HitlApprovalPayload)\n : null;\n}\n\n/** Default paused-run copy when an interrupt payload carries no message. */\nexport const DEFAULT_INTERRUPT_PAUSED_MESSAGE =\n 'The agent is paused and waiting for input.';\n\n/** Best-effort human-readable message from any interrupt payload. */\nexport function readInterruptMessage(\n value: unknown,\n fallback: string = DEFAULT_INTERRUPT_PAUSED_MESSAGE,\n): string {\n if (isRecord(value) && typeof value.message === 'string' && value.message.length > 0) {\n return value.message;\n }\n return fallback;\n}\n\n/** One label/value row of a call's resolved approval facts. */\nexport interface PendingApprovalFact {\n label: string;\n value: string;\n}\n\n/** One caution of a call's resolved approval facts. */\nexport interface PendingApprovalWarning {\n severity: 'info' | 'warning' | 'critical';\n message: string;\n}\n\nexport interface PendingApprovalSlackTarget {\n catalog_id: string;\n conversation_id: string | null;\n thread_ts: string | null;\n team_url: string | null;\n people: string[];\n}\n\n/**\n * What the backend resolved about a gated call before asking — e.g. where a\n * Slack write goes and as whom (agora `services/interrupts/approval_context.py`).\n * Display-only; the decision still answers the parked call.\n */\nexport interface PendingApprovalContext {\n facts: PendingApprovalFact[];\n warnings: PendingApprovalWarning[];\n slack_target?: PendingApprovalSlackTarget;\n}\n\nconst APPROVAL_WARNING_SEVERITIES = new Set(['info', 'warning', 'critical']);\n\nfunction isNullableString(value: unknown): value is string | null {\n return value === null || typeof value === 'string';\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\nfunction parsePendingApprovalSlackTarget(value: unknown): PendingApprovalSlackTarget | undefined {\n if (!isRecord(value) || typeof value.catalog_id !== 'string') return undefined;\n const conversationId = value.conversation_id;\n const threadTs = value.thread_ts;\n const teamUrl = value.team_url;\n const people = value.people === undefined ? [] : value.people;\n if (\n !isNullableString(conversationId) ||\n !isNullableString(threadTs) ||\n !isNullableString(teamUrl) ||\n !isStringArray(people)\n )\n return undefined;\n return {\n catalog_id: value.catalog_id,\n conversation_id: conversationId,\n thread_ts: threadTs,\n team_url: teamUrl,\n people,\n };\n}\n\n/** A call's `approval_context`, or `undefined` when absent or empty. */\nexport function parsePendingApprovalContext(value: unknown): PendingApprovalContext | undefined {\n if (!isRecord(value)) return undefined;\n const facts: PendingApprovalFact[] = Array.isArray(value.facts)\n ? value.facts.flatMap((fact) =>\n isRecord(fact) && typeof fact.label === 'string' && typeof fact.value === 'string'\n ? [{ label: fact.label, value: fact.value }]\n : [],\n )\n : [];\n const warnings: PendingApprovalWarning[] = Array.isArray(value.warnings)\n ? value.warnings.flatMap((warning) => {\n if (!isRecord(warning) || typeof warning.message !== 'string') return [];\n const severity =\n typeof warning.severity === 'string' && APPROVAL_WARNING_SEVERITIES.has(warning.severity)\n ? (warning.severity as PendingApprovalWarning['severity'])\n : 'info';\n return [{ severity, message: warning.message }];\n })\n : [];\n const slackTarget = parsePendingApprovalSlackTarget(value.slack_target);\n return facts.length > 0 || warnings.length > 0 || slackTarget\n ? { facts, warnings, ...(slackTarget ? { slack_target: slackTarget } : {}) }\n : undefined;\n}\n\nexport interface PendingActionRequest {\n name: string;\n args: Record<string, unknown>;\n /** The lane's `task` tool-call id (present on per-dispatch payloads). */\n toolCallId?: string;\n /** The lane's langgraph interrupt id — the `lane_decisions` resume key. */\n interruptId?: string;\n /** Present (true) when a session-wide approval would cover later calls of this tool. */\n sessionApprovalAllowed?: true;\n /** Present (true) when the gate accepts an `edit` decision for this call. */\n editAllowed?: true;\n /** Present when the backend resolved facts about this call before asking. */\n approvalContext?: PendingApprovalContext;\n}\n\n/**\n * Every gated call this approval covers, in decision order. One resume answers\n * ALL of them, so every entry must stay reviewable somewhere. Falls back to\n * the single first-call fields on older backends without `action_requests`.\n */\nexport function pendingActionRequests(hitl: HitlApprovalPayload | null): PendingActionRequest[] {\n const context = hitl?.context;\n if (!context) return [];\n // The payload crosses the wire with only its top-level shape narrowed\n // (`asHitlApproval`), so the nested collection must be validated before any\n // array/property access: a malformed host value must degrade to \"no\n // reviewable entries\", never crash the approval surface.\n const requests: Record<string, unknown>[] = Array.isArray(context.action_requests)\n ? context.action_requests.filter(isRecord)\n : context.tool_name && context.tool_args\n ? [{ name: context.tool_name, args: context.tool_args, tool_call_id: context.tool_call_id }]\n : [];\n return requests.map((request) => {\n const approvalContext = parsePendingApprovalContext(request.approval_context);\n return {\n name: typeof request.name === 'string' ? request.name : 'tool',\n args: isRecord(request.args) ? request.args : {},\n ...(typeof request.tool_call_id === 'string' && { toolCallId: request.tool_call_id }),\n ...(typeof request.interrupt_id === 'string' && { interruptId: request.interrupt_id }),\n ...(request.session_approval_allowed === true && { sessionApprovalAllowed: true }),\n ...(Array.isArray(request.allowed_decisions) &&\n request.allowed_decisions.includes('edit') && { editAllowed: true }),\n ...(approvalContext && { approvalContext }),\n };\n });\n}\n\n/**\n * Whether the card may offer \"approve all for this session\": every pending\n * call must be one the backend stamped as session-approvable, so a batch that\n * mixes in a tool the workspace pinned as always-prompt only offers the\n * one-time answer.\n */\nexport function canApproveForSession(actionRequests: readonly PendingActionRequest[]): boolean {\n return (\n actionRequests.length > 0 &&\n actionRequests.every((request) => request.sessionApprovalAllowed === true)\n );\n}\n\n/** An interrupt a non-resume dispatch dropped, published by the host. */\nexport interface AbandonedInputRequest {\n id: string;\n type: string;\n}\n\n/**\n * `useStatewireState` selector body for the host-published abandoned input\n * requests. Reads through {@link readDeepAgentStreamValues} so the selector is\n * safe on the pre-attach (`undefined`) wire state, and returns the raw array\n * reference so the subscription stays shallow-stable — derive (`.find`) on the\n * result, never inside the selector.\n */\nexport function readAbandonedInputRequests(\n state: unknown,\n): readonly AbandonedInputRequest[] | undefined {\n const abandoned = readDeepAgentStreamValues(state).abandonedInputRequests;\n // Wire value: anything non-array (including a malformed host publication)\n // reads as \"none\" rather than crashing the consuming surface. Identity-\n // preserving for the valid case, so it stays selector-safe.\n return Array.isArray(abandoned)\n ? (abandoned as readonly AbandonedInputRequest[])\n : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the host's mirrored interrupt\n * (`__interrupt__`, the LangGraph `{value, resumable}` wrapper). The mirror\n * is published the moment a lane parks on its gate — while sibling lanes are\n * still streaming and the run manager has NOT yet published an answerable\n * input request. Raw reference, selector-safe; unwrap with\n * {@link interruptMirrorPayload}.\n */\nexport function readInterruptMirror(state: unknown): unknown {\n return readDeepAgentStreamValues(state).__interrupt__;\n}\n\n/** The payload of a mirrored interrupt wrapper, or `undefined` for anything else. */\nexport function interruptMirrorPayload(mirror: unknown): unknown {\n return isRecord(mirror) ? mirror.value : undefined;\n}\n\n/**\n * `useStatewireState` selector body for the per-dispatch lane decisions the\n * host accepted through `run/lane-input` while the run was still streaming\n * (`queuedLaneDecisions`, keyed by langgraph interrupt id). Held until the\n * run parks, then answered as a native `lane_decisions` resume; every attached\n * client reads a queued lane as decided. Raw reference, selector-safe.\n */\nexport function readQueuedLaneDecisions(\n state: unknown,\n): Readonly<Record<string, unknown>> | undefined {\n const queued = readDeepAgentStreamValues(state).queuedLaneDecisions;\n return isRecord(queued) ? queued : undefined;\n}\n\n/**\n * The distinct langgraph interrupt ids a `lane_decisions` resume answers for\n * these gated calls, in first-seen order — or `null` when any call lacks its\n * stamp (a legacy batch payload only a positional resume can answer). A\n * nested HITL request gating several calls contributes one id: the lane is\n * the interrupt, and one decision fans across its calls server-side.\n */\nexport function laneInterruptIds(actionRequests: readonly PendingActionRequest[]): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.interruptId === undefined) return null;\n if (!ids.includes(request.interruptId)) ids.push(request.interruptId);\n }\n return ids;\n}\n\nconst NO_TOOL_CALL_IDS: ReadonlySet<string> = new Set();\n\n/**\n * The gated calls still waiting on a person, by `tool_call_id`: every call of\n * the approval on screen (the parked request's, or the host's mirror while\n * sibling lanes still stream), less the lanes whose decision the host already\n * holds (`queuedLaneDecisions`, keyed by interrupt id): a lane decided live\n * waits for the run to park, not for anyone. The id is the one join between an\n * approval and the call it gates (a payload names no lane), so a call without\n * one counts for nothing.\n */\nexport function toolCallIdsAwaitingApproval({\n actionRequests,\n queuedLaneDecisions,\n}: {\n actionRequests: readonly PendingActionRequest[];\n queuedLaneDecisions?: Readonly<Record<string, unknown>>;\n}): ReadonlySet<string> {\n let ids: Set<string> | undefined;\n for (const request of actionRequests) {\n if (request.toolCallId === undefined) continue;\n if (\n request.interruptId !== undefined &&\n queuedLaneDecisions !== undefined &&\n request.interruptId in queuedLaneDecisions\n ) {\n continue;\n }\n ids ??= new Set();\n ids.add(request.toolCallId);\n }\n return ids ?? NO_TOOL_CALL_IDS;\n}\n\n/** One decision for every lane — the `lane_decisions` map a run-wide approve or reject sends. */\nexport function fanLaneDecision<T>({\n interruptIds,\n decision,\n}: {\n interruptIds: readonly string[];\n decision: T;\n}): Record<string, T> {\n return Object.fromEntries(interruptIds.map((id) => [id, decision]));\n}\n\n/** The abandoned `interrupt` entry, if any — the \"approval was cancelled\" notice. */\nexport function findAbandonedInterrupt(\n abandoned: readonly AbandonedInputRequest[] | undefined,\n): AbandonedInputRequest | undefined {\n return abandoned?.find(\n (request) => isRecord(request) && request.type === 'interrupt' && typeof request.id === 'string',\n );\n}\n\n/** Canonical reason string carried by a user rejection. */\nexport const HITL_REJECT_REASON = 'User rejected the action.';\n\n/**\n * Default {@link UseApprovalResumeLockOptions.pendingResumeGraceMs} for every\n * approval surface: how long a clicked decision waits for its resume run to\n * start before the actions unlock again. Covers a `run/input` the host\n * rejected or a disconnected transport swallowed before any run began — the\n * one failure neither identity-change nor observed-run recovery can detect.\n */\nexport const HITL_PENDING_RESUME_GRACE_MS = 15_000;\n\n/**\n * Default {@link UseApprovalResumeLockOptions.maxTransportRetries}: how many\n * times a decision the transport lost (the websocket dropped or the statewire\n * session reset while the `run/input` was in flight) is re-sent on its own\n * before the user is asked to click again.\n */\nexport const HITL_RESUME_TRANSPORT_RETRIES = 3;\n\n/**\n * The dispatch died client-side without the host ever seeing it — a proven\n * session loss or a gone stream. Safe to re-send the same decision for the\n * same still-parked request. The complement (a server verdict, or the surface\n * unmounting) is not.\n */\nexport function isResumeTransportLoss(error: unknown): boolean {\n const outcome = statewireTransportOutcome(error);\n return outcome === 'session-lost' || outcome === 'stream-gone';\n}\n\n/** `run/input` resume value approving the gated call(s). */\nexport function hitlResumeApprove(): Record<string, string> {\n return { action: 'approve' };\n}\n\n/**\n * `run/input` resume value approving the gated call(s) AND every later call of\n * the same tool(s) on this thread. The backend records the tools from its own\n * parked interrupt (never from this payload), so the value carries no names.\n */\nexport function hitlResumeApproveForSession(): Record<string, string> {\n return { action: 'approve', scope: 'session' };\n}\n\n/** `run/input` resume value rejecting the gated call(s). */\nexport function hitlResumeReject(reason: string = HITL_REJECT_REASON): Record<string, string> {\n return { action: 'reject', reason };\n}\n\n/** One gated call's own answer inside a per-action resume ({@link hitlResumeActionDecisions}). */\nexport type HitlActionDecision =\n | { action: 'approve' }\n | { action: 'reject'; reason: string }\n | { action: 'edit'; edited_args: Record<string, unknown> };\n\n/**\n * The `tool_call_id` of every gated call, in decision order — or `null` when\n * any call lacks one or two calls share one, in which case no per-action\n * resume can be bound to the batch and only the batch answers above apply.\n */\nexport function actionRequestToolCallIds(\n actionRequests: readonly PendingActionRequest[],\n): string[] | null {\n if (actionRequests.length === 0) return null;\n const ids: string[] = [];\n for (const request of actionRequests) {\n if (request.toolCallId === undefined || ids.includes(request.toolCallId)) return null;\n ids.push(request.toolCallId);\n }\n return ids;\n}\n\n/**\n * `run/input` resume value deciding each gated call by its `tool_call_id` —\n * the only channel that carries an edited call. The backend binds every entry\n * to the parked request with that id, takes the tool NAME from its own\n * request (an edit can change a call's arguments, never which tool runs), and\n * refuses the whole answer — nothing runs — unless the map names exactly the\n * parked calls. `edited_args` is the complete argument set the call runs\n * with, not a patch. The envelope `action` mirrors the first entry for hosts\n * that only read the envelope; `action_decisions` is authoritative.\n */\nexport function hitlResumeActionDecisions(\n decisions: Readonly<Record<string, HitlActionDecision>>,\n): Record<string, unknown> {\n const [anchorId, anchor] = Object.entries(decisions)[0] ?? [];\n return {\n action: anchor?.action === 'reject' ? 'reject' : 'approve',\n ...(anchorId !== undefined && { tool_call_id: anchorId }),\n action_decisions: decisions,\n };\n}\n\n/** Canonical reason string carried by a user declining a non-HITL park. */\nexport const INTERRUPT_DECLINE_REASON = 'User declined the request.';\n\n/**\n * `run/input` resume value declining a non-HITL park. `{ action: 'reject' }`\n * is the one value every typed raiser treats as a clean user decline\n * (`FormCancelledError` / `ToolRejectedError`); a generic `continue` would be\n * rejected by their resume schemas and surface as a tool error the agent then\n * improvises around.\n */\nexport function interruptResumeDecline(\n reason: string = INTERRUPT_DECLINE_REASON,\n): Record<string, string> {\n return { action: 'reject', reason };\n}\n\nexport interface UseApprovalResumeLockOptions<TValue> {\n /** The pending interrupt's request id (`undefined` when nothing is parked). */\n requestId: string | undefined;\n /** The surface's thread `isRunning` read (mockable per surface). */\n isRunning: boolean;\n /**\n * Dispatch the `run/input` resume for `requestId` on the surface's transport.\n * Return the dispatch promise so a refused or lost command releases the lock\n * at once and reaches `onResumeRejected`; a `void` return leaves the\n * recovery paths below as the only release.\n */\n sendResume: (requestId: string, value: TValue) => void | Promise<unknown>;\n /**\n * The dispatch `sendResume` returned rejected — the host refused the\n * `run/input` or the transport lost it. The lock is already released when\n * this fires; the surface tells the user, since the request is back on\n * screen with nothing else saying why.\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * A dispatch the transport lost is being re-sent for the still-parked\n * request; `attempt` counts the retries so far (1-based). Diagnostics only —\n * the lock stays held across the retry.\n */\n onResumeRetry?: (error: unknown, requestId: string, attempt: number) => void;\n /**\n * Automatic re-sends of a decision the transport lost\n * ({@link isResumeTransportLoss}) while the request is still parked. `0`\n * disables retries. Defaults to {@link HITL_RESUME_TRANSPORT_RETRIES}.\n */\n maxTransportRetries?: number;\n /**\n * Re-enable the actions when no resume run started within this window —\n * covers a `run/input` that was rejected or lost before any run began, so\n * neither reset path below can fire. Omit to keep the pre-existing surface\n * behavior of staying locked until a resume run is observed.\n */\n pendingResumeGraceMs?: number;\n}\n\nexport interface ApprovalResumeLock<TValue> {\n /** True after a resume until the request identity changes (or recovery fires). */\n pending: boolean;\n /**\n * Send the resume value, locking the actions. No-op (returns `undefined`)\n * while pending or unparked. Returns the dispatch promise when `sendResume`\n * produced one, so a surface can hold its own state until the host settles.\n */\n resume: (value: TValue) => Promise<unknown> | undefined;\n}\n\n/**\n * Optimistic action lock shared by every approval surface: disable the\n * decision buttons the moment one is clicked, until the request identity\n * changes (it clears after the resume, or a fresh interrupt arrives). This\n * closes the double-click → duplicate-resume window.\n *\n * Recovery paths, in order of specificity:\n * 0. The dispatch itself rejected (a `sendResume` that returned a promise) —\n * released at once, and reported through `onResumeRejected`. A rejection\n * that is a transport loss (the socket dropped mid-flight) is re-sent up to\n * `maxTransportRetries` times first, the lock held throughout, so a flaky\n * connection does not hand the card back to the user for another click.\n * The returned promise settles with the final attempt.\n * 1. Identity change — the resume landed (or a new interrupt replaced the\n * request). Reset during render via React's \"previous value\" pattern.\n * 2. A resume run was observed starting and then settling with the request\n * still pending (failed/cancelled resume) — clear the lock so the user can\n * answer again.\n * 3. Optional grace window ({@link UseApprovalResumeLockOptions.pendingResumeGraceMs})\n * for a `run/input` that never started a run at all.\n */\nexport function useApprovalResumeLock<TValue = Record<string, string>>(\n options: UseApprovalResumeLockOptions<TValue>,\n): ApprovalResumeLock<TValue> {\n const {\n requestId,\n isRunning,\n sendResume,\n pendingResumeGraceMs,\n onResumeRejected,\n onResumeRetry,\n maxTransportRetries = HITL_RESUME_TRANSPORT_RETRIES,\n } = options;\n\n const [pending, setPending] = useState(false);\n // Bumped per re-send so the grace window restarts with each attempt.\n const [attempt, setAttempt] = useState(0);\n const prevRequestIdRef = useRef(requestId);\n if (prevRequestIdRef.current !== requestId) {\n prevRequestIdRef.current = requestId;\n if (pending) setPending(false);\n }\n\n // Track the resume run we kicked off (isRunning observed true→false while\n // pending) and clear `pending` when it ends with the request unresolved.\n const sawResumeRunRef = useRef(false);\n useEffect(() => {\n if (!pending) {\n sawResumeRunRef.current = false;\n return;\n }\n if (isRunning) {\n sawResumeRunRef.current = true;\n return;\n }\n if (sawResumeRunRef.current) {\n sawResumeRunRef.current = false;\n setPending(false);\n }\n }, [pending, isRunning]);\n\n // Pre-start failure recovery: re-enable after the grace window when no\n // resume run began; answering the still-parked request again is exactly\n // what the user needs to be able to do.\n useEffect(() => {\n if (!pending || pendingResumeGraceMs === undefined) return;\n const timer = setTimeout(() => {\n if (!sawResumeRunRef.current) setPending(false);\n }, pendingResumeGraceMs);\n return () => clearTimeout(timer);\n }, [pending, requestId, pendingResumeGraceMs, attempt]);\n\n const sendResumeRef = useRef(sendResume);\n sendResumeRef.current = sendResume;\n const onResumeRejectedRef = useRef(onResumeRejected);\n onResumeRejectedRef.current = onResumeRejected;\n const onResumeRetryRef = useRef(onResumeRetry);\n onResumeRetryRef.current = onResumeRetry;\n const maxTransportRetriesRef = useRef(maxTransportRetries);\n maxTransportRetriesRef.current = maxTransportRetries;\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const pendingRef = useRef(pending);\n pendingRef.current = pending;\n // One token per `resume` call: a settle from an earlier submission must not\n // retry over, or release, a newer one for the same request.\n const submissionRef = useRef(0);\n\n const resume = useCallback(\n (value: TValue): Promise<unknown> | undefined => {\n if (requestId === undefined || pendingRef.current) return undefined;\n const submission = ++submissionRef.current;\n setPending(true);\n pendingRef.current = true;\n setAttempt(0);\n const first: unknown = sendResumeRef.current(requestId, value);\n if (!(first instanceof Promise)) return undefined;\n // The final failure is already reported through `onResumeRejected`;\n // callers that drop the promise must not get an unhandled rejection.\n const outcome = new Promise<unknown>((resolve, reject) => {\n const settle = (dispatched: Promise<unknown>, retries: number) => {\n dispatched.then(resolve, (error: unknown) => {\n // A late refusal for a request the lock has since moved past (the\n // park was re-keyed, or a newer answer is in flight) must neither\n // release that answer's lock nor be reported as a failure of it.\n // The optimistic fold hides the answered request until the fold\n // rolls back, so `undefined` here is not a departure.\n const current = currentRequestIdRef.current;\n if (\n submission !== submissionRef.current ||\n (current !== undefined && current !== requestId)\n ) {\n reject(error);\n return;\n }\n if (retries < maxTransportRetriesRef.current && isResumeTransportLoss(error)) {\n const next = retries + 1;\n onResumeRetryRef.current?.(error, requestId, next);\n setPending(true);\n pendingRef.current = true;\n setAttempt(next);\n const resent: unknown = sendResumeRef.current(requestId, value);\n if (resent instanceof Promise) {\n settle(resent, next);\n return;\n }\n resolve(undefined);\n return;\n }\n setPending(false);\n pendingRef.current = false;\n onResumeRejectedRef.current?.(error, requestId);\n reject(error);\n });\n };\n settle(first, 0);\n });\n outcome.catch(() => {});\n return outcome;\n },\n [requestId],\n );\n\n return { pending, resume };\n}\n"],"names":[],"mappings":";;;;AA2EA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAGO,SAAS,mBACd,SAC+C;AAC/C,SAAO,QAAQ,SAAS,eAAe,EAAE,cAAc;AACzD;AAQA,MAAM,wCAA6D,oBAAI,IAAI,CAAC,uBAAuB,CAAC;AAO7F,SAAS,uBAAuB,SAA2B;AAChE,MAAI,CAAC,SAAS,OAAO,EAAG,QAAO;AAC/B,MAAI,QAAQ,yBAAyB,MAAO,QAAO;AACnD,SACE,OAAO,QAAQ,WAAW,YAAY,sCAAsC,IAAI,QAAQ,MAAM;AAElG;AASO,SAAS,wBACd,SAC+C;AAC/C,MAAI,CAAC,mBAAmB,OAAO,EAAG,QAAO;AACzC,QAAM,UAAW,QAAkC;AACnD,SAAO,CAAC,6BAA6B,OAAO,KAAK,CAAC,uBAAuB,OAAO;AAClF;AAGO,SAAS,eAAe,OAA4C;AACzE,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,SAAO,MAAM,SAAS,UACpB,MAAM,WAAW,mBACjB,OAAO,MAAM,YAAY,WACtB,QACD;AACN;AAGO,MAAM,mCACX;AAGK,SAAS,qBACd,OACA,WAAmB,kCACX;AACR,MAAI,SAAS,KAAK,KAAK,OAAO,MAAM,YAAY,YAAY,MAAM,QAAQ,SAAS,GAAG;AACpF,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAiCA,MAAM,8BAA8B,oBAAI,IAAI,CAAC,QAAQ,WAAW,UAAU,CAAC;AAE3E,SAAS,iBAAiB,OAAwC;AAChE,SAAO,UAAU,QAAQ,OAAO,UAAU;AAC5C;AAEA,SAAS,cAAc,OAAmC;AACxD,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,CAAC,UAAU,OAA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AoB;AACpC,gBACE,eAAe,cAAc,WAC5B,YAAY,UAAa,YAAY,WACtC;AACA,qBAAO,KAAK;AACZ;AAAA,YACF;AACA,gBAAI,UAAU,uBAAuB,WAAW,sBAAsB,KAAK,GAAG;AAC5E,oBAAM,OAAO,UAAU;AACvB,qCAAiB,YAAjB,0CAA2B,OAAO,WAAW;AAC7C,yBAAW,IAAI;AACf,yBAAW,UAAU;AACrB,yBAAW,IAAI;AACf,oBAAM,SAAkB,cAAc,QAAQ,WAAW,KAAK;AAC9D,kBAAI,kBAAkB,SAAS;AAC7B,uBAAO,QAAQ,IAAI;AACnB;AAAA,cACF;AACA,sBAAQ,MAAS;AACjB;AAAA,YACF;AACA,uBAAW,KAAK;AAChB,uBAAW,UAAU;AACrB,sCAAoB,YAApB,6CAA8B,OAAO;AACrC,mBAAO,KAAK;AAAA,UACd,CAAC;AAAA,QACH;AACA,eAAO,OAAO,CAAC;AAAA,MACjB,CAAC;AACD,cAAQ,MAAM,MAAM;AAAA,MAAC,CAAC;AACtB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,SAAS;AAAA,EAAA;AAGZ,SAAO,EAAE,SAAS,OAAA;AACpB;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Followed subagent lanes — the client half of agora's `follow` interest
|
|
3
|
+
* (`message_window.follow_windows`).
|
|
4
|
+
*
|
|
5
|
+
* A running `task` card carries only its lane's newest steps (eight, with
|
|
6
|
+
* `athena_lane_truncated` counting the rest). A request that adds
|
|
7
|
+
* `follow: {before}` also covers the newest `before` steps of every lane a card
|
|
8
|
+
* in its window names: the resolution gains `follows`
|
|
9
|
+
* (`{ns: {chain, more, toolCallId}}`) and each step is its own `athena`
|
|
10
|
+
* document, keyed `[threadId, ns, stepId]`.
|
|
11
|
+
*
|
|
12
|
+
* A lane is followed through a request anchored at its card alone
|
|
13
|
+
* ({@link laneFollowRequest}), so following one lane pulls in no other and has
|
|
14
|
+
* the attach's whole step allowance. {@link readDeepAgentFollowedWindow} reads
|
|
15
|
+
* the followed steps back onto the card, so the card's tool-call part carries
|
|
16
|
+
* the whole live lane as its nested thread; {@link useDeepAgentLaneFollowSync}
|
|
17
|
+
* keeps the attach's follow requests to the running lanes a surface shows
|
|
18
|
+
* ({@link createDeepAgentLaneFollowRegistry}). It follows only on a host whose
|
|
19
|
+
* `protocol` lane advertises `DEEP_AGENT_LANE_FOLLOW_PROTOCOL_VERSION`; a host
|
|
20
|
+
* that refuses `follow` anyway (`invalid-interest`, one predating it) keeps the
|
|
21
|
+
* attach's windows, and the cards keep the steps their own documents carry.
|
|
22
|
+
*
|
|
23
|
+
* Surfaces opt in. A surface that follows nothing ships none of this and sees
|
|
24
|
+
* the wire it saw before.
|
|
25
|
+
*/
|
|
26
|
+
import type { LangChainMessage } from '@assistant-ui/react-langgraph';
|
|
27
|
+
import { type DeepAgentInterestRequest, type DeepAgentMessageWindow, readDeepAgentMessageWindow } from './message-window';
|
|
28
|
+
type MountedDocuments = Parameters<typeof readDeepAgentMessageWindow>[0];
|
|
29
|
+
/** A request following the lane one `task` card holds. */
|
|
30
|
+
export interface DeepAgentLaneFollowRequest extends DeepAgentInterestRequest {
|
|
31
|
+
readonly at: string;
|
|
32
|
+
readonly follow: {
|
|
33
|
+
readonly before: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The request following the lane of the running `task` card `cardId`: the card
|
|
38
|
+
* alone (`before: 1`), so its window names no other card's lane, with as many
|
|
39
|
+
* of its lane's newest steps as one attach follows.
|
|
40
|
+
*/
|
|
41
|
+
export declare function laneFollowRequest(cardId: string): DeepAgentLaneFollowRequest;
|
|
42
|
+
export declare function isLaneFollowRequest(request: DeepAgentInterestRequest): request is DeepAgentLaneFollowRequest;
|
|
43
|
+
/** What an attach follows, read off its mounted documents. */
|
|
44
|
+
export interface DeepAgentLaneFollows {
|
|
45
|
+
/** The follow requests the attach holds whose card is still in the transcript. */
|
|
46
|
+
readonly requests: readonly DeepAgentLaneFollowRequest[];
|
|
47
|
+
/** Each followed lane's mounted steps, oldest first, by the `task` call whose card holds it. */
|
|
48
|
+
readonly lanes: ReadonlyMap<string, readonly LangChainMessage[]>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The attach's follow requests and followed lanes. A step whose document is
|
|
52
|
+
* not mounted is left out; a lane two windows follow is read from the deeper
|
|
53
|
+
* one. A malformed window or step reads as absent.
|
|
54
|
+
*/
|
|
55
|
+
export declare function readDeepAgentLaneFollows(mounted: MountedDocuments): DeepAgentLaneFollows;
|
|
56
|
+
/**
|
|
57
|
+
* A running card's transcript with its followed lane read in. A cut card
|
|
58
|
+
* carries its lane's newest steps whole, led by its first `cutTurns` entries:
|
|
59
|
+
* the older assistant turns that requested results among them, cut to those
|
|
60
|
+
* calls. The merge is the followed steps older than the card's newest, then
|
|
61
|
+
* the card's newest steps, then any followed step newer than all of them. The
|
|
62
|
+
* card's newest copies are the fuller ones (a lane step's document leaves every
|
|
63
|
+
* inline image a placeholder), and only the card carries a step without an id,
|
|
64
|
+
* which no follow addresses; the follow holds the cut turns whole, with the
|
|
65
|
+
* steps between them and the newest, and a cut turn it does not hold leads.
|
|
66
|
+
*/
|
|
67
|
+
export declare function mergeFollowedLane(carried: readonly unknown[], followed: readonly LangChainMessage[], cutTurns?: number): readonly unknown[];
|
|
68
|
+
/**
|
|
69
|
+
* {@link readDeepAgentMessageWindow} with the attach's followed lanes read in.
|
|
70
|
+
* The follow requests ride at the end of `requests`, so a restatement built
|
|
71
|
+
* from this window (the thread's head widening, a page of older history) keeps
|
|
72
|
+
* them: the joined view never counts them as pages. Each running card a follow
|
|
73
|
+
* covers carries its lane's followed steps as its transcript, kept as the same
|
|
74
|
+
* object while its steps stand. Without follows, the window is
|
|
75
|
+
* {@link readDeepAgentMessageWindow}'s own.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readDeepAgentFollowedWindow(mounted: MountedDocuments): DeepAgentMessageWindow | null;
|
|
78
|
+
/**
|
|
79
|
+
* The lanes a surface shows (an open transcript drawer's), by the `task` call
|
|
80
|
+
* whose card holds each: what {@link useDeepAgentLaneFollowSync} follows.
|
|
81
|
+
*/
|
|
82
|
+
export interface DeepAgentLaneFollowRegistry {
|
|
83
|
+
/** Follow the lane of the `task` call `toolCallId` until the returned release is called. */
|
|
84
|
+
follow(toolCallId: string): () => void;
|
|
85
|
+
subscribe(listener: () => void): () => void;
|
|
86
|
+
/** The `task` calls whose lanes are followed; a new set on every change. */
|
|
87
|
+
getSnapshot(): ReadonlySet<string>;
|
|
88
|
+
}
|
|
89
|
+
export declare function createDeepAgentLaneFollowRegistry(): DeepAgentLaneFollowRegistry;
|
|
90
|
+
/** Follows the lane of `toolCallId` while `active` (a drawer open on a running lane). */
|
|
91
|
+
export declare function useDeepAgentLaneFollow(registry: DeepAgentLaneFollowRegistry | null, toolCallId: string, active: boolean): void;
|
|
92
|
+
export interface UseDeepAgentLaneFollowSyncOptions {
|
|
93
|
+
/** The lanes the surface shows. */
|
|
94
|
+
registry: DeepAgentLaneFollowRegistry;
|
|
95
|
+
/**
|
|
96
|
+
* Another statement on the interest lane is in flight (a page of older
|
|
97
|
+
* history): wait for it, so neither statement drops what the other adds.
|
|
98
|
+
*/
|
|
99
|
+
paused?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A follow statement failed. A host that does not serve `follow` is not a
|
|
102
|
+
* failure: the cards keep the lanes their own documents carry.
|
|
103
|
+
*/
|
|
104
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Keeps the attach's follow requests to the running lanes the registry holds,
|
|
108
|
+
* once per change, on a host whose `protocol` lane advertises at least
|
|
109
|
+
* `DEEP_AGENT_LANE_FOLLOW_PROTOCOL_VERSION`. A statement restates the
|
|
110
|
+
* attach's other requests as the window holds them, with the follows after
|
|
111
|
+
* them, inside the host's interest cap; a statement elsewhere that left a
|
|
112
|
+
* follow out (a page of older history) is answered by stating it again.
|
|
113
|
+
*
|
|
114
|
+
* Never a retry loop: a statement is not sent again unchanged on the same
|
|
115
|
+
* connection. A host that refuses `follow` (`invalid-interest`, one that
|
|
116
|
+
* predates it) keeps the attach's windows, and nothing is followed on that
|
|
117
|
+
* connection again; a card that left the transcript first (`unknown-message`)
|
|
118
|
+
* is not followed until the transcript moves.
|
|
119
|
+
*/
|
|
120
|
+
export declare function useDeepAgentLaneFollowSync({ registry, paused, onError, }: UseDeepAgentLaneFollowSyncOptions): void;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const store = require("@assistant-ui/store");
|
|
4
|
+
const reactQuery = require("@tanstack/react-query");
|
|
5
|
+
const react = require("react");
|
|
6
|
+
const runconfigContract = require("./generated/runconfig-contract.cjs");
|
|
7
|
+
const messageWindow = require("./message-window.cjs");
|
|
8
|
+
const protocol = require("./protocol.cjs");
|
|
9
|
+
const subagents = require("./subagents.cjs");
|
|
10
|
+
const threadExtras = require("./thread-extras.cjs");
|
|
11
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
13
|
+
const entryId = (entry) => {
|
|
14
|
+
const id = isRecord(entry) ? entry.id : void 0;
|
|
15
|
+
return typeof id === "string" ? id : void 0;
|
|
16
|
+
};
|
|
17
|
+
function buildHistoryLaneCommand({
|
|
18
|
+
target,
|
|
19
|
+
at
|
|
20
|
+
}) {
|
|
21
|
+
return {
|
|
22
|
+
type: runconfigContract.DEEP_AGENT_HISTORY_LANE_COMMAND,
|
|
23
|
+
...target.lane !== void 0 ? { lane: target.lane } : { messageId: target.messageId },
|
|
24
|
+
before: runconfigContract.DEEP_AGENT_MAX_LANE_PAGE,
|
|
25
|
+
...at !== void 0 && { at }
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const nonEmpty = (value) => typeof value === "string" && value ? value : null;
|
|
29
|
+
function readHistoryLanePage(payload) {
|
|
30
|
+
if (!isRecord(payload)) return null;
|
|
31
|
+
const { steps, more, total } = payload;
|
|
32
|
+
const messageId = nonEmpty(payload.messageId);
|
|
33
|
+
const lane = nonEmpty(payload.lane);
|
|
34
|
+
if (messageId === null === (lane === null) || !Array.isArray(steps)) return null;
|
|
35
|
+
if (!isRecord(more) || typeof more.before !== "boolean" || !isCount(total)) return null;
|
|
36
|
+
return {
|
|
37
|
+
messageId,
|
|
38
|
+
lane,
|
|
39
|
+
steps: steps.filter((step) => entryId(step) !== void 0),
|
|
40
|
+
hasEarlier: more.before,
|
|
41
|
+
total
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const answers = (page, target) => target.lane !== void 0 ? page.lane === target.lane : page.messageId === target.messageId;
|
|
45
|
+
function isWholeCardRefusal(error) {
|
|
46
|
+
const failure = isRecord(error) ? error.failure : void 0;
|
|
47
|
+
return isRecord(failure) && failure.fate === "rejected" && typeof failure.message === "string" && failure.message.includes(runconfigContract.DEEP_AGENT_HISTORY_MESSAGE_COMMAND);
|
|
48
|
+
}
|
|
49
|
+
const callCount = (entry) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return entry.type === "ai" ? ((_a = entry.tool_calls) == null ? void 0 : _a.length) ?? 0 : 0;
|
|
52
|
+
};
|
|
53
|
+
function mergeLaneHistory({
|
|
54
|
+
history,
|
|
55
|
+
carried,
|
|
56
|
+
whole = false
|
|
57
|
+
}) {
|
|
58
|
+
if (history.length === 0) return carried;
|
|
59
|
+
const held = /* @__PURE__ */ new Set();
|
|
60
|
+
for (const entry of history) {
|
|
61
|
+
const id = entryId(entry);
|
|
62
|
+
if (id !== void 0) held.add(id);
|
|
63
|
+
}
|
|
64
|
+
let anchor = -1;
|
|
65
|
+
for (let index = carried.length - 1; index >= 0; index -= 1) {
|
|
66
|
+
const id = entryId(carried[index]);
|
|
67
|
+
if (id !== void 0 && held.has(id)) {
|
|
68
|
+
anchor = index;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (anchor < 0) return whole ? history : [...history, ...carried];
|
|
73
|
+
const own = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const entry of carried) {
|
|
75
|
+
const id = entryId(entry);
|
|
76
|
+
if (id !== void 0) own.set(id, entry);
|
|
77
|
+
}
|
|
78
|
+
const read = history.map((entry) => {
|
|
79
|
+
const id = entryId(entry);
|
|
80
|
+
const mine = id === void 0 ? void 0 : own.get(id);
|
|
81
|
+
return mine !== void 0 && callCount(mine) >= callCount(entry) ? mine : entry;
|
|
82
|
+
});
|
|
83
|
+
const older = carried.slice(0, anchor).filter((entry) => {
|
|
84
|
+
const id = entryId(entry);
|
|
85
|
+
return id !== void 0 && !held.has(id);
|
|
86
|
+
});
|
|
87
|
+
return [...older, ...read, ...carried.slice(anchor + 1)];
|
|
88
|
+
}
|
|
89
|
+
const laneTargetKey = (target) => target.lane !== void 0 ? `lane:${target.lane}` : `card:${target.messageId}`;
|
|
90
|
+
const deepAgentLaneHistoryQueryKey = ({
|
|
91
|
+
target,
|
|
92
|
+
mount
|
|
93
|
+
}) => ["athena-deep-agent", "history-lane", target, ...mount === void 0 ? [] : [mount]];
|
|
94
|
+
let mountCount = 0;
|
|
95
|
+
const nextMount = () => {
|
|
96
|
+
mountCount += 1;
|
|
97
|
+
return mountCount;
|
|
98
|
+
};
|
|
99
|
+
async function readLanePage({
|
|
100
|
+
sendCommand,
|
|
101
|
+
target,
|
|
102
|
+
at
|
|
103
|
+
}) {
|
|
104
|
+
try {
|
|
105
|
+
const page = readHistoryLanePage(await sendCommand(buildHistoryLaneCommand({ target, at })));
|
|
106
|
+
if (page === null || !answers(page, target)) {
|
|
107
|
+
throw new Error("history/lane answered another card or lane");
|
|
108
|
+
}
|
|
109
|
+
return { steps: page.steps, hasEarlier: page.hasEarlier, total: page.total, whole: false };
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (target.messageId === void 0 || !isWholeCardRefusal(error)) throw error;
|
|
112
|
+
const result = messageWindow.readHistoryMessageResult(
|
|
113
|
+
await sendCommand(messageWindow.buildHistoryMessageCommand({ messageId: target.messageId }))
|
|
114
|
+
);
|
|
115
|
+
if (result === null || result.messageId !== target.messageId) {
|
|
116
|
+
throw new Error("history/message answered another message");
|
|
117
|
+
}
|
|
118
|
+
const card = result.message;
|
|
119
|
+
const steps = subagents.nestedMessagesFromArtifact(isRecord(card) ? card.artifact : void 0);
|
|
120
|
+
return { steps, hasEarlier: false, total: steps.length, whole: true };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function useDeepAgentLaneHistory({
|
|
124
|
+
messageId,
|
|
125
|
+
lane,
|
|
126
|
+
carried,
|
|
127
|
+
total,
|
|
128
|
+
finished = false,
|
|
129
|
+
checkpointed = false,
|
|
130
|
+
auto = false
|
|
131
|
+
}) {
|
|
132
|
+
var _a;
|
|
133
|
+
const sendCommand = store.useAuiState(
|
|
134
|
+
(s) => threadExtras.hasStatewireThreadExtras(s.thread.extras) ? s.thread.extras.sendCommand : void 0
|
|
135
|
+
);
|
|
136
|
+
const hostVersion = store.useAuiState((s) => {
|
|
137
|
+
var _a2;
|
|
138
|
+
const extras = s.thread.extras;
|
|
139
|
+
return ((_a2 = protocol.readDeepAgentProtocol(extras == null ? void 0 : extras.state)) == null ? void 0 : _a2.version) ?? 0;
|
|
140
|
+
});
|
|
141
|
+
const sendRef = react.useRef(sendCommand);
|
|
142
|
+
sendRef.current = sendCommand;
|
|
143
|
+
const [mount] = react.useState(nextMount);
|
|
144
|
+
const [asked, setAsked] = react.useState(false);
|
|
145
|
+
const target = react.useMemo(
|
|
146
|
+
() => lane !== void 0 ? { lane } : messageId !== void 0 ? { messageId } : void 0,
|
|
147
|
+
[lane, messageId]
|
|
148
|
+
);
|
|
149
|
+
const settled = finished || checkpointed;
|
|
150
|
+
const askable = (total !== void 0 || checkpointed) && target !== void 0 && sendCommand !== void 0 && (target.lane !== void 0 || settled || hostVersion >= runconfigContract.DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION);
|
|
151
|
+
const query = reactQuery.useInfiniteQuery({
|
|
152
|
+
queryKey: deepAgentLaneHistoryQueryKey({
|
|
153
|
+
target: target === void 0 ? "" : laneTargetKey(target),
|
|
154
|
+
mount: settled ? void 0 : mount
|
|
155
|
+
}),
|
|
156
|
+
queryFn: ({ pageParam }) => {
|
|
157
|
+
const send = sendRef.current;
|
|
158
|
+
if (target === void 0 || send === void 0) {
|
|
159
|
+
return Promise.reject(new Error("no statewire thread to read the lane from"));
|
|
160
|
+
}
|
|
161
|
+
return readLanePage({ sendCommand: send, target, at: pageParam });
|
|
162
|
+
},
|
|
163
|
+
initialPageParam: void 0,
|
|
164
|
+
getNextPageParam: (last) => last.hasEarlier ? entryId(last.steps[0]) : void 0,
|
|
165
|
+
enabled: askable && (auto || asked),
|
|
166
|
+
retry: false,
|
|
167
|
+
retryOnMount: false,
|
|
168
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
169
|
+
refetchOnMount: false,
|
|
170
|
+
refetchOnWindowFocus: false,
|
|
171
|
+
refetchOnReconnect: false
|
|
172
|
+
});
|
|
173
|
+
const pages = (_a = query.data) == null ? void 0 : _a.pages;
|
|
174
|
+
const history = react.useMemo(() => {
|
|
175
|
+
var _a2, _b;
|
|
176
|
+
if (pages === void 0 || pages.length === 0) return null;
|
|
177
|
+
const entries = [...pages].reverse().flatMap((page) => page.steps);
|
|
178
|
+
return { entries, whole: ((_a2 = pages[0]) == null ? void 0 : _a2.whole) === true, total: ((_b = pages[0]) == null ? void 0 : _b.total) ?? 0 };
|
|
179
|
+
}, [pages]);
|
|
180
|
+
const available = askable && !query.isError;
|
|
181
|
+
const steps = react.useMemo(
|
|
182
|
+
() => history === null ? carried : mergeLaneHistory({ history: history.entries, carried, whole: history.whole }),
|
|
183
|
+
[history, carried]
|
|
184
|
+
);
|
|
185
|
+
const hasEarlier = available && (history === null ? checkpointed || steps.length < (total ?? 0) : query.hasNextPage);
|
|
186
|
+
const loading = query.isFetching;
|
|
187
|
+
const { fetchNextPage } = query;
|
|
188
|
+
const loadEarlier = react.useCallback(() => {
|
|
189
|
+
if (!hasEarlier || loading) return;
|
|
190
|
+
if (history === null) setAsked(true);
|
|
191
|
+
else void fetchNextPage();
|
|
192
|
+
}, [fetchNextPage, hasEarlier, history, loading]);
|
|
193
|
+
return {
|
|
194
|
+
steps,
|
|
195
|
+
// A lane read without a marker (a checkpointed one) counts what its pages say.
|
|
196
|
+
total: total === void 0 ? history == null ? void 0 : history.total : Math.max(total, (history == null ? void 0 : history.total) ?? 0),
|
|
197
|
+
available,
|
|
198
|
+
hasEarlier,
|
|
199
|
+
loading,
|
|
200
|
+
loadEarlier
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
exports.buildHistoryLaneCommand = buildHistoryLaneCommand;
|
|
204
|
+
exports.deepAgentLaneHistoryQueryKey = deepAgentLaneHistoryQueryKey;
|
|
205
|
+
exports.isWholeCardRefusal = isWholeCardRefusal;
|
|
206
|
+
exports.mergeLaneHistory = mergeLaneHistory;
|
|
207
|
+
exports.readHistoryLanePage = readHistoryLanePage;
|
|
208
|
+
exports.useDeepAgentLaneHistory = useDeepAgentLaneHistory;
|
|
209
|
+
//# sourceMappingURL=lane-history.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lane-history.cjs","sources":["../../../../agent-runtime/src/lane-history.ts"],"sourcesContent":["/**\n * A card's whole nested transcript on demand — the client half of agora's\n * `history/lane` read command.\n *\n * A card's own document carries its nested transcript (a `task` subagent's\n * lane) cut to its newest entries whenever older ones are left off — a running\n * card always, and on a version-2 view a finished one too — counting the whole\n * stored transcript under `athena_lane_truncated`. `history/lane`\n * `{messageId, before, at?}` answers a page of it: the newest `before` entries,\n * or those strictly older than `at`, oldest first, each projected like a\n * followed lane step (every inline image a placeholder), with\n * `{more: {before}, total}`. {@link useDeepAgentLaneHistory} pages one card's\n * transcript for a surface that shows it whole, and {@link mergeLaneHistory}\n * reads the pages in under the card's own live entries.\n *\n * An in-eval dispatch's lane (`task()` inside `eval`) streams the same way on\n * its `ptc_subagents` registry entry: its newest steps, the marker counting the\n * lane, running or finished. `history/lane` `{lane, before, at?}` pages it by\n * the dispatch id (the registry key, never with `messageId`), and answers the\n * same page with `lane` set and `messageId` null. A lane whose steps no longer\n * ride pages the same way from its subagent checkpoint once agora recorded its\n * namespace (`ns`), `checkpointed`: a previous run's lane in this activation\n * (a later run left its registry entry only its summary and `ns`), or a\n * reopened session's (the registry died with the activation that streamed it,\n * and the summary its eval persisted records `ns`). It carries no steps, and\n * the first page names the total.\n *\n * Only a cut card or lane is paged. A finished card is cut only by a host that\n * serves `history/lane`, so it is always asked, and so is a cut in-eval lane\n * (a client that never sends `lane` needs no gate); a running card is asked\n * only when the host's `protocol` lane advertises\n * `DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION`. A card whose entries carry no ids\n * cannot be paged: the host says to read the card whole with\n * `history/message`, and that one read stands for the lane. Any other refusal\n * (an older pod answers `history/lane` as an unknown command, or wants a\n * `messageId`; a lane with no recorded checkpoint) leaves the surface on the\n * entries it carries: no error, and that mount never asks again.\n *\n * Surfaces opt in. A surface that pages nothing ships none of this.\n */\nimport type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useAuiState } from '@assistant-ui/store';\nimport { type InfiniteData, useInfiniteQuery } from '@tanstack/react-query';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport {\n DEEP_AGENT_HISTORY_LANE_COMMAND,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION,\n DEEP_AGENT_MAX_LANE_PAGE,\n} from './generated/runconfig-contract';\nimport { buildHistoryMessageCommand, readHistoryMessageResult } from './message-window';\nimport { readDeepAgentProtocol } from './protocol';\nimport { nestedMessagesFromArtifact } from './subagents';\nimport { hasStatewireThreadExtras } from './thread-extras';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isCount = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\nconst entryId = (entry: unknown): string | undefined => {\n const id = isRecord(entry) ? entry.id : undefined;\n return typeof id === 'string' ? id : undefined;\n};\n\n/**\n * The `history/lane` read command on the statewire command union, so\n * `sendCommand({ type: 'history/lane', … })` typechecks wherever the deep-agent\n * host is driven (an attach-ACL read, like `history/message`).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A page of one card's nested transcript. */\n historyLane: HistoryLaneCommand;\n }\n }\n}\n\n/**\n * What one `history/lane` read pages: a card's nested transcript, by the card's\n * message id (a finished card or a running placeholder), or an in-eval\n * dispatch's lane, by its dispatch id.\n */\nexport type DeepAgentLaneTarget =\n | { readonly messageId: string; readonly lane?: undefined }\n | { readonly lane: string; readonly messageId?: undefined };\n\n/** The `history/lane` command: a page of one card's or lane's steps, oldest first. */\nexport type HistoryLaneCommand = {\n readonly type: typeof DEEP_AGENT_HISTORY_LANE_COMMAND;\n /** Entries in the page (`1..DEEP_AGENT_MAX_LANE_PAGE`). */\n readonly before: number;\n /** An entry id: the page holds the entries strictly older than it. Without it, the newest. */\n readonly at?: string;\n} & ({ readonly messageId: string } | { readonly lane: string });\n\nexport function buildHistoryLaneCommand({\n target,\n at,\n}: {\n target: DeepAgentLaneTarget;\n at?: string | undefined;\n}): HistoryLaneCommand {\n return {\n type: DEEP_AGENT_HISTORY_LANE_COMMAND,\n ...(target.lane !== undefined ? { lane: target.lane } : { messageId: target.messageId }),\n before: DEEP_AGENT_MAX_LANE_PAGE,\n ...(at !== undefined && { at }),\n };\n}\n\n/** One page `history/lane` answered. */\nexport interface HistoryLanePage {\n /** The card it pages; `null` for a lane. */\n readonly messageId: string | null;\n /** The in-eval lane it pages; `null` for a card (a host that predates lanes leaves it out). */\n readonly lane: string | null;\n /** The page's entries, oldest first; an entry without a string id is never in one. */\n readonly steps: readonly LangChainMessage[];\n /** Whether entries older than the page remain. */\n readonly hasEarlier: boolean;\n /** Entries the card's transcript, or the lane's checkpoint, stores. */\n readonly total: number;\n}\n\nconst nonEmpty = (value: unknown): string | null =>\n typeof value === 'string' && value ? value : null;\n\nexport function readHistoryLanePage(payload: unknown): HistoryLanePage | null {\n if (!isRecord(payload)) return null;\n const { steps, more, total } = payload;\n const messageId = nonEmpty(payload.messageId);\n const lane = nonEmpty(payload.lane);\n if ((messageId === null) === (lane === null) || !Array.isArray(steps)) return null;\n if (!isRecord(more) || typeof more.before !== 'boolean' || !isCount(total)) return null;\n return {\n messageId,\n lane,\n steps: steps.filter((step): step is LangChainMessage => entryId(step) !== undefined),\n hasEarlier: more.before,\n total,\n };\n}\n\n/** Whether a page answers a read of `target`. */\nconst answers = (page: HistoryLanePage, target: DeepAgentLaneTarget): boolean =>\n target.lane !== undefined ? page.lane === target.lane : page.messageId === target.messageId;\n\n/**\n * Whether `history/lane` was refused because the lane's entries carry no ids\n * to page by: the host names `history/message` as the way to read the card.\n */\nexport function isWholeCardRefusal(error: unknown): boolean {\n const failure = isRecord(error) ? error.failure : undefined;\n return (\n isRecord(failure) &&\n failure.fate === 'rejected' &&\n typeof failure.message === 'string' &&\n failure.message.includes(DEEP_AGENT_HISTORY_MESSAGE_COMMAND)\n );\n}\n\n/** The tool calls an assistant entry makes. */\nconst callCount = (entry: LangChainMessage): number =>\n entry.type === 'ai' ? (entry.tool_calls?.length ?? 0) : 0;\n\n/**\n * A card's transcript with its paged history read in: the history (whole,\n * oldest first), then the card's own entries newer than the last one the\n * history holds — what the lane did since the history was read. The card's\n * entries older than that one and not in the history yet (a page cut short by\n * its size, or a turn the card keeps for a result it holds) come first, so the\n * view never shows less than the card. An entry the card also carries is the\n * card's copy, which is the newer one: a page is a snapshot, which can catch a\n * step mid-stream, and leaves every inline image a placeholder. The exception\n * is a turn the card keeps cut to the calls it holds results for, which\n * carries fewer calls than the page's copy. Without history, the card's own\n * entries. `whole` history is the card's entire transcript as it was read;\n * when none of its entries can be matched to the card's (they carry no ids),\n * it stands alone.\n */\nexport function mergeLaneHistory({\n history,\n carried,\n whole = false,\n}: {\n history: readonly LangChainMessage[];\n carried: readonly LangChainMessage[];\n whole?: boolean;\n}): readonly LangChainMessage[] {\n if (history.length === 0) return carried;\n const held = new Set<string>();\n for (const entry of history) {\n const id = entryId(entry);\n if (id !== undefined) held.add(id);\n }\n let anchor = -1;\n for (let index = carried.length - 1; index >= 0; index -= 1) {\n const id = entryId(carried[index]);\n if (id !== undefined && held.has(id)) {\n anchor = index;\n break;\n }\n }\n if (anchor < 0) return whole ? history : [...history, ...carried];\n const own = new Map<string, LangChainMessage>();\n for (const entry of carried) {\n const id = entryId(entry);\n if (id !== undefined) own.set(id, entry);\n }\n const read = history.map((entry) => {\n const id = entryId(entry);\n const mine = id === undefined ? undefined : own.get(id);\n return mine !== undefined && callCount(mine) >= callCount(entry) ? mine : entry;\n });\n const older = carried.slice(0, anchor).filter((entry) => {\n const id = entryId(entry);\n return id !== undefined && !held.has(id);\n });\n return [...older, ...read, ...carried.slice(anchor + 1)];\n}\n\n/** What a surface shows of one card's or lane's steps. */\nexport interface DeepAgentLaneHistoryState {\n /** The steps with the history read so far; the steps it carries before any. */\n readonly steps: readonly LangChainMessage[];\n /** Entries the transcript stores, when it is cut (a checkpointed lane's, once a page counted them). */\n readonly total: number | undefined;\n /** The host answers `history/lane` for this card or lane, and has not refused it. */\n readonly available: boolean;\n /** Entries older than the ones read remain, and can be asked for. */\n readonly hasEarlier: boolean;\n readonly loading: boolean;\n /** Read the page before the earliest entry read so far (the newest page first). */\n readonly loadEarlier: () => void;\n}\n\n/** One `history/lane` page as the pager holds it. */\ninterface LanePageData {\n /** The page's entries, oldest first. */\n readonly steps: readonly LangChainMessage[];\n readonly hasEarlier: boolean;\n readonly total: number;\n /** The card's whole transcript, read with `history/message`. */\n readonly whole: boolean;\n}\n\n/** One key per card or lane, so a card and a lane never share history or a refusal. */\nconst laneTargetKey = (target: DeepAgentLaneTarget): string =>\n target.lane !== undefined ? `lane:${target.lane}` : `card:${target.messageId}`;\n\n/**\n * The query key one card's or lane's pages are cached under. A finished card or\n * lane never changes, so its pages are kept while it is cached; a running one\n * is read afresh by each surface that mounts it (`mount`), since an old page of\n * a lane that kept running could leave a gap before the steps it carries now.\n */\nexport const deepAgentLaneHistoryQueryKey = ({\n target,\n mount,\n}: {\n target: string;\n mount?: number | undefined;\n}) => ['athena-deep-agent', 'history-lane', target, ...(mount === undefined ? [] : [mount])];\n\nlet mountCount = 0;\nconst nextMount = (): number => {\n mountCount += 1;\n return mountCount;\n};\n\ntype SendCommand = StatewireThread.Extras['sendCommand'];\n\n/** One page of `target`: `history/lane`, or the card whole when its entries carry no ids. */\nasync function readLanePage({\n sendCommand,\n target,\n at,\n}: {\n sendCommand: SendCommand;\n target: DeepAgentLaneTarget;\n at: string | undefined;\n}): Promise<LanePageData> {\n try {\n const page = readHistoryLanePage(await sendCommand(buildHistoryLaneCommand({ target, at })));\n if (page === null || !answers(page, target)) {\n throw new Error('history/lane answered another card or lane');\n }\n return { steps: page.steps, hasEarlier: page.hasEarlier, total: page.total, whole: false };\n } catch (error) {\n if (target.messageId === undefined || !isWholeCardRefusal(error)) throw error;\n const result = readHistoryMessageResult(\n await sendCommand(buildHistoryMessageCommand({ messageId: target.messageId }))\n );\n if (result === null || result.messageId !== target.messageId) {\n throw new Error('history/message answered another message');\n }\n const card: unknown = result.message;\n const steps = nestedMessagesFromArtifact(isRecord(card) ? card.artifact : undefined);\n return { steps, hasEarlier: false, total: steps.length, whole: true };\n }\n}\n\n/**\n * Pages one card's transcript, or one in-eval lane, through `history/lane` for\n * a surface that shows it whole, as a TanStack infinite query. `auto` reads\n * the newest page as soon as it is cut (an open transcript drawer); otherwise\n * nothing is read until `loadEarlier`. A card whose message id changes (its\n * result replaced the running placeholder) is a new query. A refusal is the\n * query's error: never retried or refetched, so it costs one command, and the\n * surface stays on the steps it carries with no error.\n */\nexport function useDeepAgentLaneHistory({\n messageId,\n lane,\n carried,\n total,\n finished = false,\n checkpointed = false,\n auto = false,\n}: {\n /** The card's message id, for a `task` lane. */\n messageId?: string | undefined;\n /** The dispatch id, for an in-eval lane; wins over `messageId`. Neither: nothing to page. */\n lane?: string | undefined;\n /** The steps the card or the lane's registry entry carries. */\n carried: readonly LangChainMessage[];\n /** The cut marker's `messages`; `undefined` while every step rides. */\n total: number | undefined;\n /** The cut marker says the lane finished (only a host serving `history/lane` cuts a card then). */\n finished?: boolean;\n /**\n * No steps ride: an in-eval lane a later run or a reopen left only its\n * summary and namespace. It carries no steps and no marker, `history/lane`\n * pages its subagent's own steps from its checkpoint, and the first page\n * names their total.\n */\n checkpointed?: boolean;\n auto?: boolean;\n}): DeepAgentLaneHistoryState {\n const sendCommand = useAuiState((s) =>\n hasStatewireThreadExtras(s.thread.extras)\n ? (s.thread.extras as StatewireThread.Extras).sendCommand\n : undefined\n );\n const hostVersion = useAuiState((s) => {\n const extras = s.thread.extras as Partial<StatewireThread.Extras> | undefined;\n return readDeepAgentProtocol(extras?.state)?.version ?? 0;\n });\n const sendRef = useRef(sendCommand);\n sendRef.current = sendCommand;\n const [mount] = useState(nextMount);\n const [asked, setAsked] = useState(false);\n\n const target = useMemo<DeepAgentLaneTarget | undefined>(\n () =>\n lane !== undefined ? { lane } : messageId !== undefined ? { messageId } : undefined,\n [lane, messageId]\n );\n // A checkpointed lane's steps were left off once its run had ended.\n const settled = finished || checkpointed;\n const askable =\n (total !== undefined || checkpointed) &&\n target !== undefined &&\n sendCommand !== undefined &&\n (target.lane !== undefined || settled || hostVersion >= DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION);\n\n const query = useInfiniteQuery<\n LanePageData,\n Error,\n InfiniteData<LanePageData, string | undefined>,\n readonly unknown[],\n string | undefined\n >({\n queryKey: deepAgentLaneHistoryQueryKey({\n target: target === undefined ? '' : laneTargetKey(target),\n mount: settled ? undefined : mount,\n }),\n queryFn: ({ pageParam }) => {\n const send = sendRef.current;\n if (target === undefined || send === undefined) {\n return Promise.reject(new Error('no statewire thread to read the lane from'));\n }\n return readLanePage({ sendCommand: send, target, at: pageParam });\n },\n initialPageParam: undefined,\n getNextPageParam: (last) => (last.hasEarlier ? entryId(last.steps[0]) : undefined),\n enabled: askable && (auto || asked),\n retry: false,\n retryOnMount: false,\n staleTime: Number.POSITIVE_INFINITY,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n });\n\n const pages = query.data?.pages;\n const history = useMemo(() => {\n if (pages === undefined || pages.length === 0) return null;\n // Pages arrive newest first; each is strictly older than the one before.\n const entries = [...pages].reverse().flatMap((page) => page.steps);\n return { entries, whole: pages[0]?.whole === true, total: pages[0]?.total ?? 0 };\n }, [pages]);\n const available = askable && !query.isError;\n const steps = useMemo(\n () =>\n history === null\n ? carried\n : mergeLaneHistory({ history: history.entries, carried, whole: history.whole }),\n [history, carried]\n );\n // Before its first page, a checkpointed lane has every step still to read.\n const hasEarlier =\n available &&\n (history === null ? checkpointed || steps.length < (total ?? 0) : query.hasNextPage);\n const loading = query.isFetching;\n const { fetchNextPage } = query;\n const loadEarlier = useCallback(() => {\n if (!hasEarlier || loading) return;\n if (history === null) setAsked(true);\n else void fetchNextPage();\n }, [fetchNextPage, hasEarlier, history, loading]);\n\n return {\n steps,\n // A lane read without a marker (a checkpointed one) counts what its pages say.\n total: total === undefined ? history?.total : Math.max(total, history?.total ?? 0),\n available,\n hasEarlier,\n loading,\n loadEarlier,\n };\n}\n"],"names":["DEEP_AGENT_HISTORY_LANE_COMMAND","DEEP_AGENT_MAX_LANE_PAGE","DEEP_AGENT_HISTORY_MESSAGE_COMMAND","readHistoryMessageResult","buildHistoryMessageCommand","nestedMessagesFromArtifact","useAuiState","hasStatewireThreadExtras","readDeepAgentProtocol","useRef","useState","useMemo","DEEP_AGENT_LANE_CUT_PROTOCOL_V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