@athenaintel/react 0.41.3 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -10
- package/dist/agent-runtime/src/asset-attachment.d.ts +98 -0
- package/dist/agent-runtime/src/athena-asset-drag.d.ts +32 -0
- package/dist/agent-runtime/src/auth-denial.d.ts +29 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.cjs +41 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +38 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.js +41 -0
- package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-signals.cjs +63 -0
- package/dist/agent-runtime/src/chat-outbox-signals.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-signals.d.ts +12 -0
- package/dist/agent-runtime/src/chat-outbox-signals.js +63 -0
- package/dist/agent-runtime/src/chat-outbox-signals.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-store.cjs +509 -0
- package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-store.d.ts +203 -0
- package/dist/agent-runtime/src/chat-outbox-store.js +509 -0
- package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-thread.cjs +136 -0
- package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox-thread.d.ts +118 -0
- package/dist/agent-runtime/src/chat-outbox-thread.js +136 -0
- package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -0
- package/dist/agent-runtime/src/chat-outbox.cjs +696 -0
- package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -0
- package/dist/agent-runtime/src/chat-outbox.d.ts +285 -0
- package/dist/agent-runtime/src/chat-outbox.js +696 -0
- package/dist/agent-runtime/src/chat-outbox.js.map +1 -0
- package/dist/agent-runtime/src/chat-socket-reachability.d.ts +45 -0
- package/dist/agent-runtime/src/client-tool-bridge.d.ts +152 -0
- package/dist/agent-runtime/src/client-tools.d.ts +133 -0
- package/dist/agent-runtime/src/composer-markdown.cjs +10 -0
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
- package/dist/agent-runtime/src/composer-markdown.d.ts +108 -0
- package/dist/agent-runtime/src/composer-markdown.js +10 -0
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
- package/dist/agent-runtime/src/config-mutations.d.ts +51 -0
- package/dist/agent-runtime/src/conversation-index.d.ts +110 -0
- package/dist/agent-runtime/src/conversation-list.d.ts +343 -0
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -2
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +166 -0
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -2
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/agent-runtime/src/desktop-handoff.d.ts +139 -0
- package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
- package/dist/agent-runtime/src/edit-command.d.ts +156 -0
- package/dist/agent-runtime/src/errors.d.ts +174 -0
- package/dist/agent-runtime/src/execute-output.d.ts +31 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
- package/dist/agent-runtime/src/index.d.ts +74 -0
- package/dist/agent-runtime/src/interrupts.cjs +17 -0
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/agent-runtime/src/interrupts.d.ts +348 -0
- package/dist/agent-runtime/src/interrupts.js +17 -0
- package/dist/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
- package/dist/agent-runtime/src/lane-history.cjs +209 -0
- package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
- package/dist/agent-runtime/src/lane-history.d.ts +175 -0
- package/dist/agent-runtime/src/lane-history.js +209 -0
- package/dist/agent-runtime/src/lane-history.js.map +1 -0
- package/dist/agent-runtime/src/lane-images.d.ts +184 -0
- package/dist/agent-runtime/src/message-author.d.ts +43 -0
- package/dist/agent-runtime/src/message-text.cjs +15 -0
- package/dist/agent-runtime/src/message-text.cjs.map +1 -0
- package/dist/agent-runtime/src/message-text.d.ts +47 -0
- package/dist/agent-runtime/src/message-text.js +15 -0
- package/dist/agent-runtime/src/message-text.js.map +1 -0
- package/dist/agent-runtime/src/message-window.cjs +15 -1
- package/dist/agent-runtime/src/message-window.cjs.map +1 -1
- package/dist/agent-runtime/src/message-window.d.ts +159 -0
- package/dist/agent-runtime/src/message-window.js +16 -2
- package/dist/agent-runtime/src/message-window.js.map +1 -1
- package/dist/agent-runtime/src/messages.cjs +123 -8
- package/dist/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/agent-runtime/src/messages.d.ts +621 -0
- package/dist/agent-runtime/src/messages.js +123 -8
- package/dist/agent-runtime/src/messages.js.map +1 -1
- package/dist/agent-runtime/src/model-context.d.ts +22 -0
- package/dist/agent-runtime/src/offline-status.d.ts +157 -0
- package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
- package/dist/agent-runtime/src/protocol.cjs +12 -4
- package/dist/agent-runtime/src/protocol.cjs.map +1 -1
- package/dist/agent-runtime/src/protocol.d.ts +119 -0
- package/dist/agent-runtime/src/protocol.js +13 -5
- package/dist/agent-runtime/src/protocol.js.map +1 -1
- package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
- package/dist/agent-runtime/src/queue.d.ts +138 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +10 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +161 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js +10 -0
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
- package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
- package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
- package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
- package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
- package/dist/agent-runtime/src/screen-point.d.ts +151 -0
- package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
- package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
- package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
- package/dist/agent-runtime/src/sealed-idb.js +112 -0
- package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
- package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
- package/dist/agent-runtime/src/session-lane-scope.cjs +25 -0
- package/dist/agent-runtime/src/session-lane-scope.cjs.map +1 -0
- package/dist/agent-runtime/src/session-lane-scope.d.ts +59 -0
- package/dist/agent-runtime/src/session-lane-scope.js +25 -0
- package/dist/agent-runtime/src/session-lane-scope.js.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
- package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
- package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
- package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
- package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
- package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
- package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
- package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
- package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
- package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
- package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
- package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
- package/dist/agent-runtime/src/subagents.cjs +253 -0
- package/dist/agent-runtime/src/subagents.cjs.map +1 -0
- package/dist/agent-runtime/src/subagents.d.ts +311 -0
- package/dist/agent-runtime/src/subagents.js +253 -0
- package/dist/agent-runtime/src/subagents.js.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
- package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
- package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
- package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
- package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +46 -117
- package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -1
- package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
- package/dist/agent-runtime/src/thread-snapshot-mirror.js +17 -88
- package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -1
- package/dist/agent-runtime/src/thread-status.d.ts +53 -0
- package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
- package/dist/agent-runtime/src/tool-names.cjs +71 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-names.d.ts +67 -0
- package/dist/agent-runtime/src/tool-names.js +72 -1
- package/dist/agent-runtime/src/tool-names.js.map +1 -1
- package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
- package/dist/agent-runtime/src/tool-result.cjs +1 -0
- package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-result.d.ts +126 -0
- package/dist/agent-runtime/src/tool-result.js +1 -0
- package/dist/agent-runtime/src/tool-result.js.map +1 -1
- package/dist/agent-runtime/src/types.d.ts +159 -0
- package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
- package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +37 -2
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +177 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js +38 -3
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +39 -13
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +352 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.js +39 -13
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs +1019 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.js +1019 -0
- package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
- package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
- package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
- package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
- package/dist/agent-runtime/src/voice-presentation.js +2 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
- package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
- package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
- package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
- package/dist/catalog/runtime-catalog.js +1 -1
- package/dist/chat/AthenaChat.cjs +192 -103
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +9 -0
- package/dist/chat/AthenaChat.js +194 -105
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +1 -1
- package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +11 -4
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
- package/dist/chat/StatewireQueuedMessages.js +11 -4
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/chat-outbox-rows.cjs +223 -0
- package/dist/chat/chat-outbox-rows.cjs.map +1 -0
- package/dist/chat/chat-outbox-rows.d.ts +29 -0
- package/dist/chat/chat-outbox-rows.js +223 -0
- package/dist/chat/chat-outbox-rows.js.map +1 -0
- package/dist/chat/chat-voice-controls.cjs +128 -0
- package/dist/chat/chat-voice-controls.cjs.map +1 -0
- package/dist/chat/chat-voice-controls.d.ts +19 -0
- package/dist/chat/chat-voice-controls.js +128 -0
- package/dist/chat/chat-voice-controls.js.map +1 -0
- package/dist/chat/statewire-approval.d.ts +1 -1
- package/dist/chat/statewire-client-tools.d.ts +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
- package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +15 -8
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +18 -8
- package/dist/chat/super-grouping/activity-timeline.js +15 -8
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +36 -0
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +49 -1
- package/dist/chat/use-statewire-approval-request.js +39 -3
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +133 -14
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +33 -1
- package/dist/chat-ui/composer/tiptap-composer.js +135 -16
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
- package/dist/chat-ui/index.d.ts +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
- package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +29 -51
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +2 -2
- package/dist/chat-ui/mentions/use-account-workspace-id.js +30 -52
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +15 -0
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.js +15 -0
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
- package/dist/chat-ui/messages/user-edit-composer.js +15 -2
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +1 -0
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +2 -2
- package/dist/chat-ui/statewire.js +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.cjs +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
- package/dist/chat-ui/thread/composer-send-or-stop.d.ts +2 -0
- package/dist/chat-ui/thread/composer-send-or-stop.js +2 -1
- package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
- package/dist/composer/AttachmentContext.cjs +8 -4
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.d.ts +7 -0
- package/dist/composer/AttachmentContext.js +8 -4
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/build-composed-message.cjs +34 -0
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +20 -0
- package/dist/composer/build-composed-message.js +35 -1
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +39 -2
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +28 -3
- package/dist/composer/composer-handoff.js +39 -2
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/useAttachFiles.cjs +15 -2
- package/dist/composer/useAttachFiles.cjs.map +1 -1
- package/dist/composer/useAttachFiles.d.ts +11 -0
- package/dist/composer/useAttachFiles.js +15 -2
- package/dist/composer/useAttachFiles.js.map +1 -1
- package/dist/composer/useSendMessage.cjs.map +1 -1
- package/dist/composer/useSendMessage.d.ts +4 -3
- package/dist/composer/useSendMessage.js.map +1 -1
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/offline/chat-outbox.cjs +57 -0
- package/dist/offline/chat-outbox.cjs.map +1 -0
- package/dist/offline/chat-outbox.d.ts +80 -0
- package/dist/offline/chat-outbox.js +57 -0
- package/dist/offline/chat-outbox.js.map +1 -0
- package/dist/offline/offline-history.d.ts +1 -1
- package/dist/provider/AthenaProvider.cjs +162 -8
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +15 -1
- package/dist/provider/AthenaProvider.js +163 -9
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/statewire-window-context.d.ts +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/references/src/anchors/file-line-range.d.ts +58 -0
- package/dist/references/src/anchors/format.d.ts +21 -0
- package/dist/references/src/anchors/message-anchors.d.ts +71 -0
- package/dist/references/src/anchors/parse.d.ts +8 -0
- package/dist/references/src/anchors/registry-contract.d.ts +24 -0
- package/dist/references/src/anchors/registry.d.ts +19 -0
- package/dist/references/src/anchors/schemas.d.ts +194 -0
- package/dist/references/src/anchors/serialize.d.ts +8 -0
- package/dist/references/src/anchors/time.d.ts +78 -0
- package/dist/references/src/anchors/types.d.ts +474 -0
- package/dist/references/src/asset-bounds.d.ts +27 -0
- package/dist/references/src/asset-links.d.ts +23 -0
- package/dist/references/src/asset-reference.d.ts +16 -0
- package/dist/references/src/formats/format-catalog.d.ts +79 -0
- package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
- package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
- package/dist/references/src/formats/object/asset-object.d.ts +9 -0
- package/dist/references/src/formats/object/callable-object.d.ts +6 -0
- package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
- package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
- package/dist/references/src/formats/object/group-object.d.ts +9 -0
- package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
- package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
- package/dist/references/src/formats/object/person-object.d.ts +9 -0
- package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
- package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
- package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
- package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
- package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
- package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
- package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
- package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
- package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
- package/dist/references/src/index.d.ts +47 -0
- package/dist/references/src/legacy/index.d.ts +14 -0
- package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
- package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
- package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
- package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
- package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
- package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
- package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
- package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
- package/dist/references/src/legacy.d.ts +2 -0
- package/dist/references/src/mention-href-patterns.d.ts +19 -0
- package/dist/references/src/mention-node/index.d.ts +5 -0
- package/dist/references/src/mention-node/mention-node.d.ts +31 -0
- package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
- package/dist/references/src/parse-reference.d.ts +23 -0
- package/dist/references/src/schemas.d.ts +463 -0
- package/dist/references/src/serialize-reference.d.ts +50 -0
- package/dist/references/src/sheet-name.d.ts +10 -0
- package/dist/references/src/tool-option-schemas.d.ts +597 -0
- package/dist/references/src/types.d.ts +125 -0
- package/dist/references/src/version-ref.d.ts +30 -0
- package/dist/runtime/statewire-lifecycle.d.ts +1 -1
- package/dist/runtime/statewire-model-lane.d.ts +1 -1
- package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
- package/dist/runtime/statewire-session-key.cjs +7 -0
- package/dist/runtime/statewire-session-key.cjs.map +1 -1
- package/dist/runtime/statewire-session-key.d.ts +19 -0
- package/dist/runtime/statewire-session-key.js +8 -1
- package/dist/runtime/statewire-session-key.js.map +1 -1
- package/dist/runtime/statewire-session-lane.cjs +48 -0
- package/dist/runtime/statewire-session-lane.cjs.map +1 -0
- package/dist/runtime/statewire-session-lane.d.ts +29 -0
- package/dist/runtime/statewire-session-lane.js +48 -0
- package/dist/runtime/statewire-session-lane.js.map +1 -0
- package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +19 -5
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +20 -6
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/api.d.ts +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +1 -1
- package/dist/threads/index-triggered-refresh.cjs +164 -0
- package/dist/threads/index-triggered-refresh.cjs.map +1 -0
- package/dist/threads/index-triggered-refresh.d.ts +70 -0
- package/dist/threads/index-triggered-refresh.js +164 -0
- package/dist/threads/index-triggered-refresh.js.map +1 -0
- package/dist/threads/offline-session-list.d.ts +1 -1
- package/dist/threads/pull-request-display.d.ts +1 -1
- package/dist/threads/session-list-model.d.ts +1 -1
- package/dist/threads/session-list-tab-share.cjs +150 -0
- package/dist/threads/session-list-tab-share.cjs.map +1 -0
- package/dist/threads/session-list-tab-share.d.ts +73 -0
- package/dist/threads/session-list-tab-share.js +150 -0
- package/dist/threads/session-list-tab-share.js.map +1 -0
- package/dist/threads/session-row-parts.d.ts +1 -1
- package/dist/threads/sessions-query.d.ts +1 -1
- package/dist/threads/statewire-thread-list.cjs +42 -16
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +11 -2
- package/dist/threads/statewire-thread-list.js +43 -17
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/thread-prefetcher.d.ts +1 -1
- package/dist/threads/use-athena-session-attention.d.ts +1 -1
- package/dist/threads/use-athena-sessions.cjs +32 -22
- package/dist/threads/use-athena-sessions.cjs.map +1 -1
- package/dist/threads/use-athena-sessions.js +33 -23
- package/dist/threads/use-athena-sessions.js.map +1 -1
- package/dist/threads/use-rest-conversation-history.d.ts +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
- package/dist/tools/NestedPtcMessages.cjs +14 -9
- package/dist/tools/NestedPtcMessages.cjs.map +1 -1
- package/dist/tools/NestedPtcMessages.d.ts +9 -0
- package/dist/tools/NestedPtcMessages.js +6 -1
- package/dist/tools/NestedPtcMessages.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/primitives.d.ts +1 -1
- package/dist/tools/subagent-task-tool-ui.cjs +494 -0
- package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
- package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
- package/dist/tools/subagent-task-tool-ui.js +494 -0
- package/dist/tools/subagent-task-tool-ui.js.map +1 -0
- package/dist/tools/tool-fallback.d.ts +1 -1
- package/dist/tools/tool-icons.d.ts +1 -1
- package/dist/tools/tool-summary.d.ts +1 -1
- package/dist/tools/tool-uis.cjs +4 -0
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.js +4 -0
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/voice/chat.cjs +6 -0
- package/dist/voice/chat.cjs.map +1 -0
- package/dist/voice/chat.d.ts +2 -0
- package/dist/voice/chat.js +6 -0
- package/dist/voice/chat.js.map +1 -0
- package/dist/voice/livekit-join.cjs +119 -0
- package/dist/voice/livekit-join.cjs.map +1 -0
- package/dist/voice/livekit-join.d.ts +8 -0
- package/dist/voice/livekit-join.js +119 -0
- package/dist/voice/livekit-join.js.map +1 -0
- package/dist/voice/livekit.cjs +32 -0
- package/dist/voice/livekit.cjs.map +1 -0
- package/dist/voice/livekit.d.ts +80 -0
- package/dist/voice/livekit.js +32 -0
- package/dist/voice/livekit.js.map +1 -0
- package/dist/voice/use-chat-voice-enabled.cjs +43 -0
- package/dist/voice/use-chat-voice-enabled.cjs.map +1 -0
- package/dist/voice/use-chat-voice-enabled.d.ts +9 -0
- package/dist/voice/use-chat-voice-enabled.js +43 -0
- package/dist/voice/use-chat-voice-enabled.js.map +1 -0
- package/package.json +22 -16
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hide a markdown link the stream has not finished writing.
|
|
3
|
+
*
|
|
4
|
+
* The agent mentions and cites assets as markdown links —
|
|
5
|
+
* `[@Considerations/Notes](https://…/dashboard/spaces/?asset_ids=asset_…&type=document&anchor=pm_node&node_id=…&excerpt=…)`
|
|
6
|
+
* — which every chat surface renders as a mention chip once the link is
|
|
7
|
+
* complete. While it is still arriving, a markdown parser sees a bracketed
|
|
8
|
+
* label followed by a bare URL: the label shows as raw text and the half URL
|
|
9
|
+
* linkifies into a live link whose target changes with every batch, for as
|
|
10
|
+
* long as the destination takes to stream (an `excerpt` parameter can run to
|
|
11
|
+
* hundreds of characters). Then the closing `)` lands and the run is rebuilt
|
|
12
|
+
* as a chip.
|
|
13
|
+
*
|
|
14
|
+
* While a part is streaming, cut the text at the start of a trailing link
|
|
15
|
+
* whose `)` has not arrived; it reappears whole, as a chip, in the batch that
|
|
16
|
+
* closes it. Every link and image destination is held — a web citation
|
|
17
|
+
* flickers the same way — and so is every bracket still undecided on the
|
|
18
|
+
* line: an unfinished `[label`, and a closed `[label]` at the very end of the
|
|
19
|
+
* text, which waits one batch for its `(`. Holding the label too is what
|
|
20
|
+
* makes the visible text only ever grow — a link never shows as a label and
|
|
21
|
+
* then retracts when its destination starts — and that append-only property
|
|
22
|
+
* is what keeps Olympus's incremental streaming apply on its cheap path.
|
|
23
|
+
* Brackets match innermost-first, as CommonMark does, and the hold starts at
|
|
24
|
+
* the outermost undecided bracket the size bound allows, so an unmatched
|
|
25
|
+
* bracket in prose hides at most a phrase, briefly, and never masks a later
|
|
26
|
+
* mention. A construct that crosses a line break or runs past its bound is
|
|
27
|
+
* released so a malformed link cannot hide the rest of the message; fenced
|
|
28
|
+
* code (including fences inside blockquotes), indented code and inline code
|
|
29
|
+
* are left untouched; and settled text is never passed through this
|
|
30
|
+
* function, so a link the model genuinely left open shows raw once the part
|
|
31
|
+
* completes.
|
|
32
|
+
*
|
|
33
|
+
* Shared by every chat surface (Olympus, the React SDK hosts, mobile) so the
|
|
34
|
+
* hold behaves identically wherever a transcript streams. Pure string work,
|
|
35
|
+
* linear in the text.
|
|
36
|
+
*/
|
|
37
|
+
/** An open bracket further back than this is prose, not a label being streamed. */
|
|
38
|
+
export declare const UNTERMINATED_LABEL_HOLD_LIMIT = 200;
|
|
39
|
+
/** A link (label and destination) longer than this is broken, not streaming. */
|
|
40
|
+
export declare const UNTERMINATED_LINK_HOLD_LIMIT = 1500;
|
|
41
|
+
/**
|
|
42
|
+
* The streamed text with a trailing, still-undecided markdown link or image
|
|
43
|
+
* removed. Text without such a construct is returned as is, and the result is
|
|
44
|
+
* always a prefix of `text`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function hideUnterminatedMarkdownLink(text: string): string;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("@assistant-ui/core/react");
|
|
4
|
+
const runconfigContract = require("./generated/runconfig-contract.cjs");
|
|
5
|
+
const messageText = require("./message-text.cjs");
|
|
6
|
+
const messages = require("./messages.cjs");
|
|
7
|
+
const toolNames = require("./tool-names.cjs");
|
|
8
|
+
function laneTranscriptOf(artifact) {
|
|
9
|
+
if (typeof artifact !== "object" || artifact === null) return void 0;
|
|
10
|
+
const state = artifact.subgraph_state;
|
|
11
|
+
if (typeof state !== "object" || state === null) return void 0;
|
|
12
|
+
const messages2 = state.messages;
|
|
13
|
+
return Array.isArray(messages2) ? messages2 : void 0;
|
|
14
|
+
}
|
|
15
|
+
const restoredTranscripts = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function withRepeatedResult(transcript, content) {
|
|
17
|
+
const last = transcript[transcript.length - 1];
|
|
18
|
+
if (last === void 0 || last[runconfigContract.DEEP_AGENT_REPEATS_RESULT_KEY] !== true || typeof content !== "string" && !Array.isArray(content)) {
|
|
19
|
+
return transcript;
|
|
20
|
+
}
|
|
21
|
+
const cached = restoredTranscripts.get(transcript);
|
|
22
|
+
if (cached !== void 0 && cached.content === content) return cached.transcript;
|
|
23
|
+
const restored = [...transcript.slice(0, -1), { ...last, content }];
|
|
24
|
+
restoredTranscripts.set(transcript, { content, transcript: restored });
|
|
25
|
+
return restored;
|
|
26
|
+
}
|
|
27
|
+
const convertibleChunkTurns = /* @__PURE__ */ new WeakMap();
|
|
28
|
+
function asConvertibleTurn(message) {
|
|
29
|
+
const type = message.type;
|
|
30
|
+
if (type !== "AIMessageChunk") return message;
|
|
31
|
+
const cached = convertibleChunkTurns.get(message);
|
|
32
|
+
if (cached !== void 0) return cached;
|
|
33
|
+
const turn = { ...message, type: "ai" };
|
|
34
|
+
convertibleChunkTurns.set(message, turn);
|
|
35
|
+
return turn;
|
|
36
|
+
}
|
|
37
|
+
function answeringTurn(step) {
|
|
38
|
+
var _a;
|
|
39
|
+
const turn = asConvertibleTurn(step);
|
|
40
|
+
return turn.type === "ai" && (((_a = turn.tool_calls) == null ? void 0 : _a.length) ?? 0) === 0 ? turn : null;
|
|
41
|
+
}
|
|
42
|
+
const isTextBlock = (block) => typeof block === "object" && block !== null && "type" in block && block.type === "text";
|
|
43
|
+
function shownText(content) {
|
|
44
|
+
if (typeof content === "string") return content;
|
|
45
|
+
if (!Array.isArray(content)) return "";
|
|
46
|
+
let text = "";
|
|
47
|
+
for (const block of content) {
|
|
48
|
+
if (isTextBlock(block) && typeof block.text === "string") text += block.text;
|
|
49
|
+
}
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
function blankTurn(step) {
|
|
53
|
+
const turn = answeringTurn(step);
|
|
54
|
+
if (turn === null || shownText(turn.content).trim() !== "") return null;
|
|
55
|
+
return typeof turn.content === "string" || turn.content.every(isTextBlock) ? turn : null;
|
|
56
|
+
}
|
|
57
|
+
const reportedLanes = /* @__PURE__ */ new WeakMap();
|
|
58
|
+
function withLaneReport(transcript, report) {
|
|
59
|
+
if (report === void 0 || report.trim() === "" || transcript.length === 0) return transcript;
|
|
60
|
+
let at = transcript.length - 1;
|
|
61
|
+
let closing = transcript[at];
|
|
62
|
+
while (closing !== void 0 && blankTurn(closing) !== null) {
|
|
63
|
+
at -= 1;
|
|
64
|
+
closing = transcript[at];
|
|
65
|
+
}
|
|
66
|
+
const answered = closing !== void 0 && answeringTurn(closing) !== null && shownText(closing.content).trim() !== "";
|
|
67
|
+
if (answered) return transcript;
|
|
68
|
+
const cached = reportedLanes.get(transcript);
|
|
69
|
+
if (cached !== void 0 && cached.report === report) return cached.transcript;
|
|
70
|
+
const last = transcript[transcript.length - 1];
|
|
71
|
+
const blank = last === void 0 ? null : blankTurn(last);
|
|
72
|
+
const closed = blank !== null ? [...transcript.slice(0, -1), { ...blank, content: report }] : [...transcript, { id: `${(last == null ? void 0 : last.id) ?? "lane"}:report`, type: "ai", content: report }];
|
|
73
|
+
reportedLanes.set(transcript, { report, transcript: closed });
|
|
74
|
+
return closed;
|
|
75
|
+
}
|
|
76
|
+
function transcriptSources(transcript) {
|
|
77
|
+
return messages.sanitizeLangChainMessages(transcript.map(asConvertibleTurn));
|
|
78
|
+
}
|
|
79
|
+
const reportedTranscripts = /* @__PURE__ */ new WeakSet();
|
|
80
|
+
function reportUnconvertibleTranscript(transcript, error) {
|
|
81
|
+
if (reportedTranscripts.has(transcript)) return;
|
|
82
|
+
reportedTranscripts.add(transcript);
|
|
83
|
+
console.warn("[agent-runtime] a subagent transcript could not be converted", error);
|
|
84
|
+
}
|
|
85
|
+
function sameJson(a, b) {
|
|
86
|
+
if (Object.is(a, b)) return true;
|
|
87
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
88
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
89
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => sameJson(item, b[index]));
|
|
90
|
+
}
|
|
91
|
+
const left = a;
|
|
92
|
+
const right = b;
|
|
93
|
+
const keys = Object.keys(left);
|
|
94
|
+
return keys.length === Object.keys(right).length && keys.every(
|
|
95
|
+
(key) => Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function steadyStepObjects() {
|
|
99
|
+
let held = /* @__PURE__ */ new Map();
|
|
100
|
+
return (transcript) => {
|
|
101
|
+
const next = /* @__PURE__ */ new Map();
|
|
102
|
+
let kept = false;
|
|
103
|
+
const steadied = transcript.map((entry) => {
|
|
104
|
+
const id = entry.id;
|
|
105
|
+
if (typeof id !== "string") return entry;
|
|
106
|
+
const before = held.get(id);
|
|
107
|
+
const step = before !== void 0 && sameJson(before, entry) ? before : entry;
|
|
108
|
+
next.set(id, step);
|
|
109
|
+
if (step !== entry) kept = true;
|
|
110
|
+
return step;
|
|
111
|
+
});
|
|
112
|
+
held = next;
|
|
113
|
+
return kept ? steadied : transcript;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function createSubagentLaneConversion() {
|
|
117
|
+
const memory = createSubagentTranscriptConversionCache();
|
|
118
|
+
const steady = steadyStepObjects();
|
|
119
|
+
let last = null;
|
|
120
|
+
return (transcript, running) => {
|
|
121
|
+
if (last !== null && last.transcript === transcript && last.running === running) {
|
|
122
|
+
return last.messages;
|
|
123
|
+
}
|
|
124
|
+
let messages2;
|
|
125
|
+
try {
|
|
126
|
+
messages2 = memory.convert(transcriptSources(steady(transcript)), running);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
reportUnconvertibleTranscript(transcript, error);
|
|
129
|
+
}
|
|
130
|
+
last = { transcript, running, messages: messages2 };
|
|
131
|
+
return messages2;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function subagentTranscriptAttacher() {
|
|
135
|
+
const lanes = /* @__PURE__ */ new Map();
|
|
136
|
+
const attachedRows = /* @__PURE__ */ new WeakMap();
|
|
137
|
+
const attachedParts = /* @__PURE__ */ new WeakMap();
|
|
138
|
+
const laneMessages = (toolCallId, transcript, running) => {
|
|
139
|
+
let lane = lanes.get(toolCallId);
|
|
140
|
+
if (lane === void 0) {
|
|
141
|
+
lane = createSubagentLaneConversion();
|
|
142
|
+
lanes.set(toolCallId, lane);
|
|
143
|
+
}
|
|
144
|
+
return lane(transcript, running);
|
|
145
|
+
};
|
|
146
|
+
const attach = (row) => {
|
|
147
|
+
if (row.role !== "assistant") return row;
|
|
148
|
+
const cached = attachedRows.get(row);
|
|
149
|
+
if (cached !== void 0) return cached;
|
|
150
|
+
let content = null;
|
|
151
|
+
for (const [index, part] of row.content.entries()) {
|
|
152
|
+
if (part.type !== "tool-call" || part.toolName !== toolNames.TASK_TOOL_NAME) continue;
|
|
153
|
+
const nested = laneTranscriptOf(part.artifact);
|
|
154
|
+
if (nested === void 0) continue;
|
|
155
|
+
const running = part.isPreliminary === true;
|
|
156
|
+
const restored = withRepeatedResult(nested, part.result);
|
|
157
|
+
const transcript = running || part.isError === true ? restored : withLaneReport(restored, messageText.getMessageText({ content: part.result }));
|
|
158
|
+
const messages2 = laneMessages(part.toolCallId, transcript, running);
|
|
159
|
+
if (messages2 === void 0) continue;
|
|
160
|
+
const kept = attachedParts.get(part);
|
|
161
|
+
const attached = kept !== void 0 && kept.messages === messages2 ? kept.part : { ...part, messages: messages2 };
|
|
162
|
+
attachedParts.set(part, { messages: messages2, part: attached });
|
|
163
|
+
content ?? (content = [...row.content]);
|
|
164
|
+
content[index] = attached;
|
|
165
|
+
}
|
|
166
|
+
const attachedRow = content === null ? row : { ...row, content };
|
|
167
|
+
attachedRows.set(row, attachedRow);
|
|
168
|
+
return attachedRow;
|
|
169
|
+
};
|
|
170
|
+
return (rows) => {
|
|
171
|
+
const attached = rows.map(attach);
|
|
172
|
+
if (lanes.size === 0) return attached;
|
|
173
|
+
const held = /* @__PURE__ */ new Set();
|
|
174
|
+
for (const row of rows) {
|
|
175
|
+
if (row.role !== "assistant") continue;
|
|
176
|
+
for (const part of row.content) {
|
|
177
|
+
if (part.type !== "tool-call" || part.toolName !== toolNames.TASK_TOOL_NAME) continue;
|
|
178
|
+
held.add(part.toolCallId);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (const toolCallId of lanes.keys()) {
|
|
182
|
+
if (!held.has(toolCallId)) lanes.delete(toolCallId);
|
|
183
|
+
}
|
|
184
|
+
return attached;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function createSubagentTranscriptConversionCache(options = {}) {
|
|
188
|
+
const thread = messages.createDeepAgentMessageConversionCache(options);
|
|
189
|
+
const attach = subagentTranscriptAttacher();
|
|
190
|
+
let previousRows = null;
|
|
191
|
+
let previous = [];
|
|
192
|
+
return {
|
|
193
|
+
convert(messages2, isRunning) {
|
|
194
|
+
const rows = thread.convert(messages2, isRunning);
|
|
195
|
+
if (rows === previousRows) return previous;
|
|
196
|
+
previousRows = rows;
|
|
197
|
+
const next = attach(rows);
|
|
198
|
+
const unchanged = next.length === previous.length && next.every((row, index) => row === previous[index]);
|
|
199
|
+
if (!unchanged) previous = next;
|
|
200
|
+
return previous;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
react.createExternalMessageConversionCache();
|
|
205
|
+
exports.createSubagentLaneConversion = createSubagentLaneConversion;
|
|
206
|
+
exports.createSubagentTranscriptConversionCache = createSubagentTranscriptConversionCache;
|
|
207
|
+
exports.withLaneReport = withLaneReport;
|
|
208
|
+
exports.withRepeatedResult = withRepeatedResult;
|
|
209
|
+
//# sourceMappingURL=subagent-transcripts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-transcripts.cjs","sources":["../../../../agent-runtime/src/subagent-transcripts.ts"],"sourcesContent":["/**\n * A subagent's transcript as assistant-ui's native nested thread.\n *\n * The backend nests a `task` subagent's transcript in its card's ToolMessage,\n * at `artifact.subgraph_state.messages`: the newest steps on the running\n * placeholder, the whole transcript on the real result. The conversion cache\n * built here converts that transcript through the thread's own pipeline and\n * sets it as the `task` tool-call part's `messages`, assistant-ui's channel for\n * a tool call's nested conversation. `ReadonlyThreadProvider` (the provider\n * under `MessagePartPrimitive.Messages`) renders it as a read-only thread under\n * the parent's tool UIs, and `thread.tasks` derives child work from it.\n *\n * Hosts opt in (`useDeepAgentThread({ createConversionCache })`). It builds on\n * the shared conversion memory from outside, so the shared converter, which\n * ships in every surface's startup bundle (the Office pane's startup and total\n * budgets have no room to spare), stays as it is, and a surface that draws no\n * subagent transcript pays nothing for it.\n */\nimport type {\n ThreadAssistantMessagePart,\n ThreadMessage,\n ToolCallMessagePart,\n} from '@assistant-ui/core';\nimport {\n convertExternalMessages,\n createExternalMessageConversionCache,\n} from '@assistant-ui/core/react';\nimport type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport { DEEP_AGENT_REPEATS_RESULT_KEY } from './generated/runconfig-contract';\nimport { getMessageText } from './message-text';\nimport {\n convertDeepAgentLangChainMessage,\n createDeepAgentMessageConversionCache,\n type DeepAgentConversionMemory,\n type DeepAgentMessageConversionOptions,\n markPreliminaryToolResults,\n sanitizeLangChainMessages,\n} from './messages';\nimport { TASK_TOOL_NAME } from './tool-names';\n\n/** The transcript nested on a `task` card's artifact, or `undefined` when it carries none. */\nfunction laneTranscriptOf(artifact: unknown): readonly LangChainMessage[] | undefined {\n if (typeof artifact !== 'object' || artifact === null) return undefined;\n const state: unknown = (artifact as { subgraph_state?: unknown }).subgraph_state;\n if (typeof state !== 'object' || state === null) return undefined;\n const messages: unknown = (state as { messages?: unknown }).messages;\n return Array.isArray(messages) ? (messages as LangChainMessage[]) : undefined;\n}\n\nconst restoredTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly content: unknown; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A card's nested transcript with its report restored. On a cut finished card\n * the last step can ride with empty content and `DEEP_AGENT_REPEATS_RESULT_KEY`:\n * its text is the subagent's report, the card's own `content`, which the card\n * carries anyway. The step gets that content back. Any other transcript comes\n * back as it is. Memoized per transcript, so a lane's conversion sees one array.\n */\nexport function withRepeatedResult(\n transcript: readonly LangChainMessage[],\n content: unknown\n): readonly LangChainMessage[] {\n const last = transcript[transcript.length - 1];\n if (\n last === undefined ||\n (last as Record<string, unknown>)[DEEP_AGENT_REPEATS_RESULT_KEY] !== true ||\n (typeof content !== 'string' && !Array.isArray(content))\n ) {\n return transcript;\n }\n const cached = restoredTranscripts.get(transcript);\n if (cached !== undefined && cached.content === content) return cached.transcript;\n const restored = [...transcript.slice(0, -1), { ...last, content } as LangChainMessage];\n restoredTranscripts.set(transcript, { content, transcript: restored });\n return restored;\n}\n\ntype AssistantLangChainMessage = Extract<LangChainMessage, { type: 'ai' }>;\n\nconst convertibleChunkTurns = new WeakMap<LangChainMessage, LangChainMessage>();\n\n/**\n * A nested assistant turn stored under the chunk class name (the legacy\n * assistant-stream fold keeps `AIMessageChunk`) as the `ai` message it is: the\n * shipped converter maps only `ai`, and would drop the turn.\n */\nfunction asConvertibleTurn(message: LangChainMessage): LangChainMessage {\n const type: string = message.type;\n if (type !== 'AIMessageChunk') return message;\n const cached = convertibleChunkTurns.get(message);\n if (cached !== undefined) return cached;\n const turn: LangChainMessage = { ...(message as AssistantLangChainMessage), type: 'ai' };\n convertibleChunkTurns.set(message, turn);\n return turn;\n}\n\n/** A lane step as the assistant turn it is when it calls nothing; `null` for any other step. */\nfunction answeringTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = asConvertibleTurn(step);\n return turn.type === 'ai' && (turn.tool_calls?.length ?? 0) === 0 ? turn : null;\n}\n\nconst isTextBlock = (block: unknown): block is { type: 'text'; text?: unknown } =>\n typeof block === 'object' && block !== null && 'type' in block && block.type === 'text';\n\n/** The text a step's content shows: the string, or its text blocks joined. */\nfunction shownText(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n let text = '';\n for (const block of content) {\n if (isTextBlock(block) && typeof block.text === 'string') text += block.text;\n }\n return text;\n}\n\n/** A turn that calls nothing and shows nothing: no text, and no block of another kind. */\nfunction blankTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = answeringTurn(step);\n if (turn === null || shownText(turn.content).trim() !== '') return null;\n return typeof turn.content === 'string' || turn.content.every(isTextBlock) ? turn : null;\n}\n\nconst reportedLanes = new WeakMap<\n readonly LangChainMessage[],\n { readonly report: string; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A finished lane's transcript, closed by its report. A `task` card's content\n * is its subagent's report, the text of the lane's last turn. A transcript\n * that ends on that turn (an assistant step that calls nothing and says\n * something, which {@link withRepeatedResult} restores when it rides marked)\n * comes back as it is, even when blank steps follow it. A lane stored without\n * it shows the report as its closing answer: a lane whose last step is a blank\n * assistant step (lanes that finished before the host marked a repeated\n * report) gets the report in that step, its id and stamps kept, and a lane\n * that ends on a tool result or a turn that calls tools gets a closing step\n * after its last one. An empty report or transcript changes nothing. For\n * display only: the wire and the stored lane are untouched. Memoized per\n * transcript, so a lane's conversion sees one array.\n */\nexport function withLaneReport(\n transcript: readonly LangChainMessage[],\n report: string | undefined\n): readonly LangChainMessage[] {\n if (report === undefined || report.trim() === '' || transcript.length === 0) return transcript;\n // The lane's closing turn: its last step past any blank ones.\n let at = transcript.length - 1;\n let closing = transcript[at];\n while (closing !== undefined && blankTurn(closing) !== null) {\n at -= 1;\n closing = transcript[at];\n }\n const answered =\n closing !== undefined &&\n answeringTurn(closing) !== null &&\n shownText(closing.content).trim() !== '';\n if (answered) return transcript;\n const cached = reportedLanes.get(transcript);\n if (cached !== undefined && cached.report === report) return cached.transcript;\n const last = transcript[transcript.length - 1];\n const blank = last === undefined ? null : blankTurn(last);\n const closed: readonly LangChainMessage[] =\n blank !== null\n ? [...transcript.slice(0, -1), { ...blank, content: report }]\n : [...transcript, { id: `${last?.id ?? 'lane'}:report`, type: 'ai', content: report }];\n reportedLanes.set(transcript, { report, transcript: closed });\n return closed;\n}\n\n/** A nested transcript as the thread's own pipeline reads it (see {@link sanitizeLangChainMessages}). */\nfunction transcriptSources(transcript: readonly LangChainMessage[]): LangChainMessage[] {\n return sanitizeLangChainMessages(transcript.map(asConvertibleTurn));\n}\n\nconst reportedTranscripts = new WeakSet<readonly LangChainMessage[]>();\n\n/**\n * A nested transcript the shipped converter refused (it throws on, e.g., a\n * result whose tool name differs from its call's): reported once, and its card\n * goes without a nested thread instead of taking the whole thread down.\n */\nfunction reportUnconvertibleTranscript(\n transcript: readonly LangChainMessage[],\n error: unknown\n): void {\n if (reportedTranscripts.has(transcript)) return;\n reportedTranscripts.add(transcript);\n console.warn('[agent-runtime] a subagent transcript could not be converted', error);\n}\n\n/** Whether two values the wire carries (JSON: no functions, no cycles) are equal. */\nfunction sameJson(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => sameJson(item, b[index]))\n );\n }\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = Object.keys(left);\n return (\n keys.length === Object.keys(right).length &&\n keys.every(\n (key) =>\n Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])\n )\n );\n}\n\n/**\n * Keeps a lane's unchanged steps as the objects it already converted. The host\n * replaces a card's whole document whenever the card changes, so every step it\n * carries arrives as a new object, and the conversion memory, which tells the\n * steps a turn continues by object, would see a new turn each time the card's\n * cut drops its oldest step and the turn's first step changes. A step whose id\n * and content are unchanged is the object held for that id. O(the steps' size).\n */\nfunction steadyStepObjects(): (\n transcript: readonly LangChainMessage[]\n) => readonly LangChainMessage[] {\n let held = new Map<string, LangChainMessage>();\n return (transcript) => {\n const next = new Map<string, LangChainMessage>();\n let kept = false;\n const steadied = transcript.map((entry) => {\n const id = entry.id;\n if (typeof id !== 'string') return entry;\n const before = held.get(id);\n const step = before !== undefined && sameJson(before, entry) ? before : entry;\n next.set(id, step);\n if (step !== entry) kept = true;\n return step;\n });\n held = next;\n return kept ? steadied : transcript;\n };\n}\n\n/** One lane's transcript, converted: `undefined` when the converter refused it. */\nexport type SubagentLaneConversion = (\n transcript: readonly LangChainMessage[],\n running: boolean\n) => readonly ThreadMessage[] | undefined;\n\n/**\n * One `task` lane's own conversion memory, for whatever converts that lane:\n * its unchanged steps keep their converted objects while it streams (a step the\n * wire sends again unchanged included, see {@link steadyStepObjects}), and its\n * turn keeps its row key (`deepAgentRowKey`) and part keys when the turn's head\n * moves — the oldest steps of a cut card falling off as the lane runs, or older\n * steps a transcript drawer pages in. A surface that keeps its disclosures under\n * that key keeps them open through both. A transcript array converted last time\n * is not converted again.\n */\nexport function createSubagentLaneConversion(): SubagentLaneConversion {\n const memory = createSubagentTranscriptConversionCache();\n const steady = steadyStepObjects();\n let last: {\n readonly transcript: readonly LangChainMessage[];\n readonly running: boolean;\n readonly messages: readonly ThreadMessage[] | undefined;\n } | null = null;\n return (transcript, running) => {\n if (last !== null && last.transcript === transcript && last.running === running) {\n return last.messages;\n }\n let messages: readonly ThreadMessage[] | undefined;\n try {\n messages = memory.convert(transcriptSources(steady(transcript)), running);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n last = { transcript, running, messages };\n return messages;\n };\n}\n\n/**\n * Sets each `task` part of a pass's converted rows to carry its nested\n * transcript as `messages`, for one attach. Each lane has its own conversion\n * memory, so its unchanged steps keep their converted objects while it\n * streams, as the thread's own messages do, and a lane whose transcript array\n * did not change is not converted again. A row, and a part whose lane did not\n * change, keep their identity: the same row always comes back as the same\n * object. A lane's memory lives only while a row of the pass holds its `task`\n * call: a lane a rewind removes, a branch switch hides or the window leaves\n * behind is let go with its transcript, and converted afresh if it returns.\n */\nfunction subagentTranscriptAttacher(): (rows: readonly ThreadMessage[]) => ThreadMessage[] {\n const lanes = new Map<string, SubagentLaneConversion>();\n const attachedRows = new WeakMap<ThreadMessage, ThreadMessage>();\n const attachedParts = new WeakMap<\n ToolCallMessagePart,\n { readonly messages: readonly ThreadMessage[]; readonly part: ToolCallMessagePart }\n >();\n\n const laneMessages = (\n toolCallId: string,\n transcript: readonly LangChainMessage[],\n running: boolean\n ): readonly ThreadMessage[] | undefined => {\n let lane = lanes.get(toolCallId);\n if (lane === undefined) {\n lane = createSubagentLaneConversion();\n lanes.set(toolCallId, lane);\n }\n return lane(transcript, running);\n };\n\n const attach = (row: ThreadMessage): ThreadMessage => {\n if (row.role !== 'assistant') return row;\n const cached = attachedRows.get(row);\n if (cached !== undefined) return cached;\n let content: ThreadAssistantMessagePart[] | null = null;\n for (const [index, part] of row.content.entries()) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n const nested = laneTranscriptOf(part.artifact);\n if (nested === undefined) continue;\n // A running lane's placeholder is preliminary: its newest nested turn streams.\n const running = part.isPreliminary === true;\n const restored = withRepeatedResult(nested, part.result);\n const transcript =\n running || part.isError === true\n ? restored\n : withLaneReport(restored, getMessageText({ content: part.result }));\n const messages = laneMessages(part.toolCallId, transcript, running);\n if (messages === undefined) continue;\n const kept = attachedParts.get(part);\n const attached =\n kept !== undefined && kept.messages === messages ? kept.part : { ...part, messages };\n attachedParts.set(part, { messages, part: attached });\n content ??= [...row.content];\n content[index] = attached;\n }\n const attachedRow: ThreadMessage = content === null ? row : { ...row, content };\n attachedRows.set(row, attachedRow);\n return attachedRow;\n };\n\n return (rows) => {\n const attached = rows.map(attach);\n if (lanes.size === 0) return attached;\n const held = new Set<string>();\n for (const row of rows) {\n if (row.role !== 'assistant') continue;\n for (const part of row.content) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n held.add(part.toolCallId);\n }\n }\n for (const toolCallId of lanes.keys()) {\n if (!held.has(toolCallId)) lanes.delete(toolCallId);\n }\n return attached;\n };\n}\n\n/**\n * A conversion memory for one attach (see\n * `useDeepAgentThread({ createConversionCache })`): the shared one's rows, with\n * each `task` tool-call part carrying its subagent's converted transcript as\n * `messages`. A pass that changes no row hands back the previous list itself.\n */\nexport function createSubagentTranscriptConversionCache(\n options: DeepAgentMessageConversionOptions = {}\n): DeepAgentConversionMemory {\n const thread = createDeepAgentMessageConversionCache(options);\n const attach = subagentTranscriptAttacher();\n let previousRows: ThreadMessage[] | null = null;\n let previous: ThreadMessage[] = [];\n return {\n convert(messages, isRunning) {\n const rows = thread.convert(messages, isRunning);\n if (rows === previousRows) return previous;\n previousRows = rows;\n const next = attach(rows);\n const unchanged =\n next.length === previous.length && next.every((row, index) => row === previous[index]);\n if (!unchanged) previous = next;\n return previous;\n },\n };\n}\n\n/**\n * Shared by every in-eval transcript: entries are keyed by source message, so\n * none outlives the wire state holding it and threads cannot collide.\n */\nconst inEvalTranscriptCache = createExternalMessageConversionCache();\nconst IN_EVAL_TRANSCRIPT_METADATA = {};\nconst inEvalTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly running: boolean; readonly messages: readonly ThreadMessage[] }\n>();\n\nconst NO_MESSAGES: readonly ThreadMessage[] = [];\n\n/**\n * An in-eval dispatch's live transcript (a `ptc_subagents` entry's `messages`)\n * as a nested thread, converted like a `task` lane's. Memoized per transcript\n * array; a step the lane did not change keeps its converted object. A\n * transcript the converter refuses reads as empty.\n */\nexport function convertSubagentTranscript(\n transcript: readonly LangChainMessage[],\n running: boolean\n): readonly ThreadMessage[] {\n const cached = inEvalTranscripts.get(transcript);\n if (cached !== undefined && cached.running === running) return cached.messages;\n let messages: readonly ThreadMessage[] = NO_MESSAGES;\n try {\n messages = convertExternalMessages(\n transcriptSources(transcript),\n convertDeepAgentLangChainMessage,\n running,\n IN_EVAL_TRANSCRIPT_METADATA,\n inEvalTranscriptCache\n ).map(markPreliminaryToolResults);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n inEvalTranscripts.set(transcript, { running, messages });\n return messages;\n}\n"],"names":["messages","DEEP_AGENT_REPEATS_RESULT_KEY","sanitizeLangChainMessages","TASK_TOOL_NAME","getMessageText","createDeepAgentMessageConversionCache","createExternalMessageConversionCache"],"mappings":";;;;;;;AAyCA,SAAS,iBAAiB,UAA4D;AACpF,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,QAAkB,SAA0C;AAClE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAMA,YAAqB,MAAiC;AAC5D,SAAO,MAAM,QAAQA,SAAQ,IAAKA,YAAkC;AACtE;AAEA,MAAM,0CAA0B,QAAA;AAYzB,SAAS,mBACd,YACA,SAC6B;AAC7B,QAAM,OAAO,WAAW,WAAW,SAAS,CAAC;AAC7C,MACE,SAAS,UACR,KAAiCC,kBAAAA,6BAA6B,MAAM,QACpE,OAAO,YAAY,YAAY,CAAC,MAAM,QAAQ,OAAO,GACtD;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAS,oBAAoB,IAAI,UAAU;AACjD,MAAI,WAAW,UAAa,OAAO,YAAY,gBAAgB,OAAO;AACtE,QAAM,WAAW,CAAC,GAAG,WAAW,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,SAA6B;AACtF,sBAAoB,IAAI,YAAY,EAAE,SAAS,YAAY,UAAU;AACrE,SAAO;AACT;AAIA,MAAM,4CAA4B,QAAA;AAOlC,SAAS,kBAAkB,SAA6C;AACtE,QAAM,OAAe,QAAQ;AAC7B,MAAI,SAAS,iBAAkB,QAAO;AACtC,QAAM,SAAS,sBAAsB,IAAI,OAAO;AAChD,MAAI,WAAW,OAAW,QAAO;AACjC,QAAM,OAAyB,EAAE,GAAI,SAAuC,MAAM,KAAA;AAClF,wBAAsB,IAAI,SAAS,IAAI;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;AACA,eAAW,cAAc,MAAM,QAAQ;AACrC,UAAI,CAAC,KAAK,IAAI,UAAU,EAAG,OAAM,OAAO,UAAU;AAAA,IACpD;AACA,WAAO;AAAA,EACT;AACF;AAQO,SAAS,wCACd,UAA6C,IAClB;AAC3B,QAAM,SAASE,SAAAA,sCAAsC,OAAO;AAC5D,QAAM,SAAS,2BAAA;AACf,MAAI,eAAuC;AAC3C,MAAI,WAA4B,CAAA;AAChC,SAAO;AAAA,IACL,QAAQL,WAAU,WAAW;AAC3B,YAAM,OAAO,OAAO,QAAQA,WAAU,SAAS;AAC/C,UAAI,SAAS,aAAc,QAAO;AAClC,qBAAe;AACf,YAAM,OAAO,OAAO,IAAI;AACxB,YAAM,YACJ,KAAK,WAAW,SAAS,UAAU,KAAK,MAAM,CAAC,KAAK,UAAU,QAAQ,SAAS,KAAK,CAAC;AACvF,UAAI,CAAC,UAAW,YAAW;AAC3B,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;AAM8BM,MAAAA,qCAAA;;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A subagent's transcript as assistant-ui's native nested thread.
|
|
3
|
+
*
|
|
4
|
+
* The backend nests a `task` subagent's transcript in its card's ToolMessage,
|
|
5
|
+
* at `artifact.subgraph_state.messages`: the newest steps on the running
|
|
6
|
+
* placeholder, the whole transcript on the real result. The conversion cache
|
|
7
|
+
* built here converts that transcript through the thread's own pipeline and
|
|
8
|
+
* sets it as the `task` tool-call part's `messages`, assistant-ui's channel for
|
|
9
|
+
* a tool call's nested conversation. `ReadonlyThreadProvider` (the provider
|
|
10
|
+
* under `MessagePartPrimitive.Messages`) renders it as a read-only thread under
|
|
11
|
+
* the parent's tool UIs, and `thread.tasks` derives child work from it.
|
|
12
|
+
*
|
|
13
|
+
* Hosts opt in (`useDeepAgentThread({ createConversionCache })`). It builds on
|
|
14
|
+
* the shared conversion memory from outside, so the shared converter, which
|
|
15
|
+
* ships in every surface's startup bundle (the Office pane's startup and total
|
|
16
|
+
* budgets have no room to spare), stays as it is, and a surface that draws no
|
|
17
|
+
* subagent transcript pays nothing for it.
|
|
18
|
+
*/
|
|
19
|
+
import type { ThreadMessage } from '@assistant-ui/core';
|
|
20
|
+
import type { LangChainMessage } from '@assistant-ui/react-langgraph';
|
|
21
|
+
import { type DeepAgentConversionMemory, type DeepAgentMessageConversionOptions } from './messages';
|
|
22
|
+
/**
|
|
23
|
+
* A card's nested transcript with its report restored. On a cut finished card
|
|
24
|
+
* the last step can ride with empty content and `DEEP_AGENT_REPEATS_RESULT_KEY`:
|
|
25
|
+
* its text is the subagent's report, the card's own `content`, which the card
|
|
26
|
+
* carries anyway. The step gets that content back. Any other transcript comes
|
|
27
|
+
* back as it is. Memoized per transcript, so a lane's conversion sees one array.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withRepeatedResult(transcript: readonly LangChainMessage[], content: unknown): readonly LangChainMessage[];
|
|
30
|
+
/**
|
|
31
|
+
* A finished lane's transcript, closed by its report. A `task` card's content
|
|
32
|
+
* is its subagent's report, the text of the lane's last turn. A transcript
|
|
33
|
+
* that ends on that turn (an assistant step that calls nothing and says
|
|
34
|
+
* something, which {@link withRepeatedResult} restores when it rides marked)
|
|
35
|
+
* comes back as it is, even when blank steps follow it. A lane stored without
|
|
36
|
+
* it shows the report as its closing answer: a lane whose last step is a blank
|
|
37
|
+
* assistant step (lanes that finished before the host marked a repeated
|
|
38
|
+
* report) gets the report in that step, its id and stamps kept, and a lane
|
|
39
|
+
* that ends on a tool result or a turn that calls tools gets a closing step
|
|
40
|
+
* after its last one. An empty report or transcript changes nothing. For
|
|
41
|
+
* display only: the wire and the stored lane are untouched. Memoized per
|
|
42
|
+
* transcript, so a lane's conversion sees one array.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withLaneReport(transcript: readonly LangChainMessage[], report: string | undefined): readonly LangChainMessage[];
|
|
45
|
+
/** One lane's transcript, converted: `undefined` when the converter refused it. */
|
|
46
|
+
export type SubagentLaneConversion = (transcript: readonly LangChainMessage[], running: boolean) => readonly ThreadMessage[] | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* One `task` lane's own conversion memory, for whatever converts that lane:
|
|
49
|
+
* its unchanged steps keep their converted objects while it streams (a step the
|
|
50
|
+
* wire sends again unchanged included, see {@link steadyStepObjects}), and its
|
|
51
|
+
* turn keeps its row key (`deepAgentRowKey`) and part keys when the turn's head
|
|
52
|
+
* moves — the oldest steps of a cut card falling off as the lane runs, or older
|
|
53
|
+
* steps a transcript drawer pages in. A surface that keeps its disclosures under
|
|
54
|
+
* that key keeps them open through both. A transcript array converted last time
|
|
55
|
+
* is not converted again.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSubagentLaneConversion(): SubagentLaneConversion;
|
|
58
|
+
/**
|
|
59
|
+
* A conversion memory for one attach (see
|
|
60
|
+
* `useDeepAgentThread({ createConversionCache })`): the shared one's rows, with
|
|
61
|
+
* each `task` tool-call part carrying its subagent's converted transcript as
|
|
62
|
+
* `messages`. A pass that changes no row hands back the previous list itself.
|
|
63
|
+
*/
|
|
64
|
+
export declare function createSubagentTranscriptConversionCache(options?: DeepAgentMessageConversionOptions): DeepAgentConversionMemory;
|
|
65
|
+
/**
|
|
66
|
+
* An in-eval dispatch's live transcript (a `ptc_subagents` entry's `messages`)
|
|
67
|
+
* as a nested thread, converted like a `task` lane's. Memoized per transcript
|
|
68
|
+
* array; a step the lane did not change keeps its converted object. A
|
|
69
|
+
* transcript the converter refuses reads as empty.
|
|
70
|
+
*/
|
|
71
|
+
export declare function convertSubagentTranscript(transcript: readonly LangChainMessage[], running: boolean): readonly ThreadMessage[];
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createExternalMessageConversionCache } from "@assistant-ui/core/react";
|
|
2
|
+
import { DEEP_AGENT_REPEATS_RESULT_KEY } from "./generated/runconfig-contract.js";
|
|
3
|
+
import { getMessageText } from "./message-text.js";
|
|
4
|
+
import { createDeepAgentMessageConversionCache, sanitizeLangChainMessages } from "./messages.js";
|
|
5
|
+
import { TASK_TOOL_NAME } from "./tool-names.js";
|
|
6
|
+
function laneTranscriptOf(artifact) {
|
|
7
|
+
if (typeof artifact !== "object" || artifact === null) return void 0;
|
|
8
|
+
const state = artifact.subgraph_state;
|
|
9
|
+
if (typeof state !== "object" || state === null) return void 0;
|
|
10
|
+
const messages = state.messages;
|
|
11
|
+
return Array.isArray(messages) ? messages : void 0;
|
|
12
|
+
}
|
|
13
|
+
const restoredTranscripts = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
function withRepeatedResult(transcript, content) {
|
|
15
|
+
const last = transcript[transcript.length - 1];
|
|
16
|
+
if (last === void 0 || last[DEEP_AGENT_REPEATS_RESULT_KEY] !== true || typeof content !== "string" && !Array.isArray(content)) {
|
|
17
|
+
return transcript;
|
|
18
|
+
}
|
|
19
|
+
const cached = restoredTranscripts.get(transcript);
|
|
20
|
+
if (cached !== void 0 && cached.content === content) return cached.transcript;
|
|
21
|
+
const restored = [...transcript.slice(0, -1), { ...last, content }];
|
|
22
|
+
restoredTranscripts.set(transcript, { content, transcript: restored });
|
|
23
|
+
return restored;
|
|
24
|
+
}
|
|
25
|
+
const convertibleChunkTurns = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
function asConvertibleTurn(message) {
|
|
27
|
+
const type = message.type;
|
|
28
|
+
if (type !== "AIMessageChunk") return message;
|
|
29
|
+
const cached = convertibleChunkTurns.get(message);
|
|
30
|
+
if (cached !== void 0) return cached;
|
|
31
|
+
const turn = { ...message, type: "ai" };
|
|
32
|
+
convertibleChunkTurns.set(message, turn);
|
|
33
|
+
return turn;
|
|
34
|
+
}
|
|
35
|
+
function answeringTurn(step) {
|
|
36
|
+
var _a;
|
|
37
|
+
const turn = asConvertibleTurn(step);
|
|
38
|
+
return turn.type === "ai" && (((_a = turn.tool_calls) == null ? void 0 : _a.length) ?? 0) === 0 ? turn : null;
|
|
39
|
+
}
|
|
40
|
+
const isTextBlock = (block) => typeof block === "object" && block !== null && "type" in block && block.type === "text";
|
|
41
|
+
function shownText(content) {
|
|
42
|
+
if (typeof content === "string") return content;
|
|
43
|
+
if (!Array.isArray(content)) return "";
|
|
44
|
+
let text = "";
|
|
45
|
+
for (const block of content) {
|
|
46
|
+
if (isTextBlock(block) && typeof block.text === "string") text += block.text;
|
|
47
|
+
}
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
function blankTurn(step) {
|
|
51
|
+
const turn = answeringTurn(step);
|
|
52
|
+
if (turn === null || shownText(turn.content).trim() !== "") return null;
|
|
53
|
+
return typeof turn.content === "string" || turn.content.every(isTextBlock) ? turn : null;
|
|
54
|
+
}
|
|
55
|
+
const reportedLanes = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
function withLaneReport(transcript, report) {
|
|
57
|
+
if (report === void 0 || report.trim() === "" || transcript.length === 0) return transcript;
|
|
58
|
+
let at = transcript.length - 1;
|
|
59
|
+
let closing = transcript[at];
|
|
60
|
+
while (closing !== void 0 && blankTurn(closing) !== null) {
|
|
61
|
+
at -= 1;
|
|
62
|
+
closing = transcript[at];
|
|
63
|
+
}
|
|
64
|
+
const answered = closing !== void 0 && answeringTurn(closing) !== null && shownText(closing.content).trim() !== "";
|
|
65
|
+
if (answered) return transcript;
|
|
66
|
+
const cached = reportedLanes.get(transcript);
|
|
67
|
+
if (cached !== void 0 && cached.report === report) return cached.transcript;
|
|
68
|
+
const last = transcript[transcript.length - 1];
|
|
69
|
+
const blank = last === void 0 ? null : blankTurn(last);
|
|
70
|
+
const closed = blank !== null ? [...transcript.slice(0, -1), { ...blank, content: report }] : [...transcript, { id: `${(last == null ? void 0 : last.id) ?? "lane"}:report`, type: "ai", content: report }];
|
|
71
|
+
reportedLanes.set(transcript, { report, transcript: closed });
|
|
72
|
+
return closed;
|
|
73
|
+
}
|
|
74
|
+
function transcriptSources(transcript) {
|
|
75
|
+
return sanitizeLangChainMessages(transcript.map(asConvertibleTurn));
|
|
76
|
+
}
|
|
77
|
+
const reportedTranscripts = /* @__PURE__ */ new WeakSet();
|
|
78
|
+
function reportUnconvertibleTranscript(transcript, error) {
|
|
79
|
+
if (reportedTranscripts.has(transcript)) return;
|
|
80
|
+
reportedTranscripts.add(transcript);
|
|
81
|
+
console.warn("[agent-runtime] a subagent transcript could not be converted", error);
|
|
82
|
+
}
|
|
83
|
+
function sameJson(a, b) {
|
|
84
|
+
if (Object.is(a, b)) return true;
|
|
85
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
86
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
87
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => sameJson(item, b[index]));
|
|
88
|
+
}
|
|
89
|
+
const left = a;
|
|
90
|
+
const right = b;
|
|
91
|
+
const keys = Object.keys(left);
|
|
92
|
+
return keys.length === Object.keys(right).length && keys.every(
|
|
93
|
+
(key) => Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function steadyStepObjects() {
|
|
97
|
+
let held = /* @__PURE__ */ new Map();
|
|
98
|
+
return (transcript) => {
|
|
99
|
+
const next = /* @__PURE__ */ new Map();
|
|
100
|
+
let kept = false;
|
|
101
|
+
const steadied = transcript.map((entry) => {
|
|
102
|
+
const id = entry.id;
|
|
103
|
+
if (typeof id !== "string") return entry;
|
|
104
|
+
const before = held.get(id);
|
|
105
|
+
const step = before !== void 0 && sameJson(before, entry) ? before : entry;
|
|
106
|
+
next.set(id, step);
|
|
107
|
+
if (step !== entry) kept = true;
|
|
108
|
+
return step;
|
|
109
|
+
});
|
|
110
|
+
held = next;
|
|
111
|
+
return kept ? steadied : transcript;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function createSubagentLaneConversion() {
|
|
115
|
+
const memory = createSubagentTranscriptConversionCache();
|
|
116
|
+
const steady = steadyStepObjects();
|
|
117
|
+
let last = null;
|
|
118
|
+
return (transcript, running) => {
|
|
119
|
+
if (last !== null && last.transcript === transcript && last.running === running) {
|
|
120
|
+
return last.messages;
|
|
121
|
+
}
|
|
122
|
+
let messages;
|
|
123
|
+
try {
|
|
124
|
+
messages = memory.convert(transcriptSources(steady(transcript)), running);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
reportUnconvertibleTranscript(transcript, error);
|
|
127
|
+
}
|
|
128
|
+
last = { transcript, running, messages };
|
|
129
|
+
return messages;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function subagentTranscriptAttacher() {
|
|
133
|
+
const lanes = /* @__PURE__ */ new Map();
|
|
134
|
+
const attachedRows = /* @__PURE__ */ new WeakMap();
|
|
135
|
+
const attachedParts = /* @__PURE__ */ new WeakMap();
|
|
136
|
+
const laneMessages = (toolCallId, transcript, running) => {
|
|
137
|
+
let lane = lanes.get(toolCallId);
|
|
138
|
+
if (lane === void 0) {
|
|
139
|
+
lane = createSubagentLaneConversion();
|
|
140
|
+
lanes.set(toolCallId, lane);
|
|
141
|
+
}
|
|
142
|
+
return lane(transcript, running);
|
|
143
|
+
};
|
|
144
|
+
const attach = (row) => {
|
|
145
|
+
if (row.role !== "assistant") return row;
|
|
146
|
+
const cached = attachedRows.get(row);
|
|
147
|
+
if (cached !== void 0) return cached;
|
|
148
|
+
let content = null;
|
|
149
|
+
for (const [index, part] of row.content.entries()) {
|
|
150
|
+
if (part.type !== "tool-call" || part.toolName !== TASK_TOOL_NAME) continue;
|
|
151
|
+
const nested = laneTranscriptOf(part.artifact);
|
|
152
|
+
if (nested === void 0) continue;
|
|
153
|
+
const running = part.isPreliminary === true;
|
|
154
|
+
const restored = withRepeatedResult(nested, part.result);
|
|
155
|
+
const transcript = running || part.isError === true ? restored : withLaneReport(restored, getMessageText({ content: part.result }));
|
|
156
|
+
const messages = laneMessages(part.toolCallId, transcript, running);
|
|
157
|
+
if (messages === void 0) continue;
|
|
158
|
+
const kept = attachedParts.get(part);
|
|
159
|
+
const attached = kept !== void 0 && kept.messages === messages ? kept.part : { ...part, messages };
|
|
160
|
+
attachedParts.set(part, { messages, part: attached });
|
|
161
|
+
content ?? (content = [...row.content]);
|
|
162
|
+
content[index] = attached;
|
|
163
|
+
}
|
|
164
|
+
const attachedRow = content === null ? row : { ...row, content };
|
|
165
|
+
attachedRows.set(row, attachedRow);
|
|
166
|
+
return attachedRow;
|
|
167
|
+
};
|
|
168
|
+
return (rows) => {
|
|
169
|
+
const attached = rows.map(attach);
|
|
170
|
+
if (lanes.size === 0) return attached;
|
|
171
|
+
const held = /* @__PURE__ */ new Set();
|
|
172
|
+
for (const row of rows) {
|
|
173
|
+
if (row.role !== "assistant") continue;
|
|
174
|
+
for (const part of row.content) {
|
|
175
|
+
if (part.type !== "tool-call" || part.toolName !== TASK_TOOL_NAME) continue;
|
|
176
|
+
held.add(part.toolCallId);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
for (const toolCallId of lanes.keys()) {
|
|
180
|
+
if (!held.has(toolCallId)) lanes.delete(toolCallId);
|
|
181
|
+
}
|
|
182
|
+
return attached;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function createSubagentTranscriptConversionCache(options = {}) {
|
|
186
|
+
const thread = createDeepAgentMessageConversionCache(options);
|
|
187
|
+
const attach = subagentTranscriptAttacher();
|
|
188
|
+
let previousRows = null;
|
|
189
|
+
let previous = [];
|
|
190
|
+
return {
|
|
191
|
+
convert(messages, isRunning) {
|
|
192
|
+
const rows = thread.convert(messages, isRunning);
|
|
193
|
+
if (rows === previousRows) return previous;
|
|
194
|
+
previousRows = rows;
|
|
195
|
+
const next = attach(rows);
|
|
196
|
+
const unchanged = next.length === previous.length && next.every((row, index) => row === previous[index]);
|
|
197
|
+
if (!unchanged) previous = next;
|
|
198
|
+
return previous;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
createExternalMessageConversionCache();
|
|
203
|
+
export {
|
|
204
|
+
createSubagentLaneConversion,
|
|
205
|
+
createSubagentTranscriptConversionCache,
|
|
206
|
+
withLaneReport,
|
|
207
|
+
withRepeatedResult
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=subagent-transcripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-transcripts.js","sources":["../../../../agent-runtime/src/subagent-transcripts.ts"],"sourcesContent":["/**\n * A subagent's transcript as assistant-ui's native nested thread.\n *\n * The backend nests a `task` subagent's transcript in its card's ToolMessage,\n * at `artifact.subgraph_state.messages`: the newest steps on the running\n * placeholder, the whole transcript on the real result. The conversion cache\n * built here converts that transcript through the thread's own pipeline and\n * sets it as the `task` tool-call part's `messages`, assistant-ui's channel for\n * a tool call's nested conversation. `ReadonlyThreadProvider` (the provider\n * under `MessagePartPrimitive.Messages`) renders it as a read-only thread under\n * the parent's tool UIs, and `thread.tasks` derives child work from it.\n *\n * Hosts opt in (`useDeepAgentThread({ createConversionCache })`). It builds on\n * the shared conversion memory from outside, so the shared converter, which\n * ships in every surface's startup bundle (the Office pane's startup and total\n * budgets have no room to spare), stays as it is, and a surface that draws no\n * subagent transcript pays nothing for it.\n */\nimport type {\n ThreadAssistantMessagePart,\n ThreadMessage,\n ToolCallMessagePart,\n} from '@assistant-ui/core';\nimport {\n convertExternalMessages,\n createExternalMessageConversionCache,\n} from '@assistant-ui/core/react';\nimport type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport { DEEP_AGENT_REPEATS_RESULT_KEY } from './generated/runconfig-contract';\nimport { getMessageText } from './message-text';\nimport {\n convertDeepAgentLangChainMessage,\n createDeepAgentMessageConversionCache,\n type DeepAgentConversionMemory,\n type DeepAgentMessageConversionOptions,\n markPreliminaryToolResults,\n sanitizeLangChainMessages,\n} from './messages';\nimport { TASK_TOOL_NAME } from './tool-names';\n\n/** The transcript nested on a `task` card's artifact, or `undefined` when it carries none. */\nfunction laneTranscriptOf(artifact: unknown): readonly LangChainMessage[] | undefined {\n if (typeof artifact !== 'object' || artifact === null) return undefined;\n const state: unknown = (artifact as { subgraph_state?: unknown }).subgraph_state;\n if (typeof state !== 'object' || state === null) return undefined;\n const messages: unknown = (state as { messages?: unknown }).messages;\n return Array.isArray(messages) ? (messages as LangChainMessage[]) : undefined;\n}\n\nconst restoredTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly content: unknown; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A card's nested transcript with its report restored. On a cut finished card\n * the last step can ride with empty content and `DEEP_AGENT_REPEATS_RESULT_KEY`:\n * its text is the subagent's report, the card's own `content`, which the card\n * carries anyway. The step gets that content back. Any other transcript comes\n * back as it is. Memoized per transcript, so a lane's conversion sees one array.\n */\nexport function withRepeatedResult(\n transcript: readonly LangChainMessage[],\n content: unknown\n): readonly LangChainMessage[] {\n const last = transcript[transcript.length - 1];\n if (\n last === undefined ||\n (last as Record<string, unknown>)[DEEP_AGENT_REPEATS_RESULT_KEY] !== true ||\n (typeof content !== 'string' && !Array.isArray(content))\n ) {\n return transcript;\n }\n const cached = restoredTranscripts.get(transcript);\n if (cached !== undefined && cached.content === content) return cached.transcript;\n const restored = [...transcript.slice(0, -1), { ...last, content } as LangChainMessage];\n restoredTranscripts.set(transcript, { content, transcript: restored });\n return restored;\n}\n\ntype AssistantLangChainMessage = Extract<LangChainMessage, { type: 'ai' }>;\n\nconst convertibleChunkTurns = new WeakMap<LangChainMessage, LangChainMessage>();\n\n/**\n * A nested assistant turn stored under the chunk class name (the legacy\n * assistant-stream fold keeps `AIMessageChunk`) as the `ai` message it is: the\n * shipped converter maps only `ai`, and would drop the turn.\n */\nfunction asConvertibleTurn(message: LangChainMessage): LangChainMessage {\n const type: string = message.type;\n if (type !== 'AIMessageChunk') return message;\n const cached = convertibleChunkTurns.get(message);\n if (cached !== undefined) return cached;\n const turn: LangChainMessage = { ...(message as AssistantLangChainMessage), type: 'ai' };\n convertibleChunkTurns.set(message, turn);\n return turn;\n}\n\n/** A lane step as the assistant turn it is when it calls nothing; `null` for any other step. */\nfunction answeringTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = asConvertibleTurn(step);\n return turn.type === 'ai' && (turn.tool_calls?.length ?? 0) === 0 ? turn : null;\n}\n\nconst isTextBlock = (block: unknown): block is { type: 'text'; text?: unknown } =>\n typeof block === 'object' && block !== null && 'type' in block && block.type === 'text';\n\n/** The text a step's content shows: the string, or its text blocks joined. */\nfunction shownText(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n let text = '';\n for (const block of content) {\n if (isTextBlock(block) && typeof block.text === 'string') text += block.text;\n }\n return text;\n}\n\n/** A turn that calls nothing and shows nothing: no text, and no block of another kind. */\nfunction blankTurn(step: LangChainMessage): AssistantLangChainMessage | null {\n const turn = answeringTurn(step);\n if (turn === null || shownText(turn.content).trim() !== '') return null;\n return typeof turn.content === 'string' || turn.content.every(isTextBlock) ? turn : null;\n}\n\nconst reportedLanes = new WeakMap<\n readonly LangChainMessage[],\n { readonly report: string; readonly transcript: readonly LangChainMessage[] }\n>();\n\n/**\n * A finished lane's transcript, closed by its report. A `task` card's content\n * is its subagent's report, the text of the lane's last turn. A transcript\n * that ends on that turn (an assistant step that calls nothing and says\n * something, which {@link withRepeatedResult} restores when it rides marked)\n * comes back as it is, even when blank steps follow it. A lane stored without\n * it shows the report as its closing answer: a lane whose last step is a blank\n * assistant step (lanes that finished before the host marked a repeated\n * report) gets the report in that step, its id and stamps kept, and a lane\n * that ends on a tool result or a turn that calls tools gets a closing step\n * after its last one. An empty report or transcript changes nothing. For\n * display only: the wire and the stored lane are untouched. Memoized per\n * transcript, so a lane's conversion sees one array.\n */\nexport function withLaneReport(\n transcript: readonly LangChainMessage[],\n report: string | undefined\n): readonly LangChainMessage[] {\n if (report === undefined || report.trim() === '' || transcript.length === 0) return transcript;\n // The lane's closing turn: its last step past any blank ones.\n let at = transcript.length - 1;\n let closing = transcript[at];\n while (closing !== undefined && blankTurn(closing) !== null) {\n at -= 1;\n closing = transcript[at];\n }\n const answered =\n closing !== undefined &&\n answeringTurn(closing) !== null &&\n shownText(closing.content).trim() !== '';\n if (answered) return transcript;\n const cached = reportedLanes.get(transcript);\n if (cached !== undefined && cached.report === report) return cached.transcript;\n const last = transcript[transcript.length - 1];\n const blank = last === undefined ? null : blankTurn(last);\n const closed: readonly LangChainMessage[] =\n blank !== null\n ? [...transcript.slice(0, -1), { ...blank, content: report }]\n : [...transcript, { id: `${last?.id ?? 'lane'}:report`, type: 'ai', content: report }];\n reportedLanes.set(transcript, { report, transcript: closed });\n return closed;\n}\n\n/** A nested transcript as the thread's own pipeline reads it (see {@link sanitizeLangChainMessages}). */\nfunction transcriptSources(transcript: readonly LangChainMessage[]): LangChainMessage[] {\n return sanitizeLangChainMessages(transcript.map(asConvertibleTurn));\n}\n\nconst reportedTranscripts = new WeakSet<readonly LangChainMessage[]>();\n\n/**\n * A nested transcript the shipped converter refused (it throws on, e.g., a\n * result whose tool name differs from its call's): reported once, and its card\n * goes without a nested thread instead of taking the whole thread down.\n */\nfunction reportUnconvertibleTranscript(\n transcript: readonly LangChainMessage[],\n error: unknown\n): void {\n if (reportedTranscripts.has(transcript)) return;\n reportedTranscripts.add(transcript);\n console.warn('[agent-runtime] a subagent transcript could not be converted', error);\n}\n\n/** Whether two values the wire carries (JSON: no functions, no cycles) are equal. */\nfunction sameJson(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => sameJson(item, b[index]))\n );\n }\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = Object.keys(left);\n return (\n keys.length === Object.keys(right).length &&\n keys.every(\n (key) =>\n Object.prototype.hasOwnProperty.call(right, key) && sameJson(left[key], right[key])\n )\n );\n}\n\n/**\n * Keeps a lane's unchanged steps as the objects it already converted. The host\n * replaces a card's whole document whenever the card changes, so every step it\n * carries arrives as a new object, and the conversion memory, which tells the\n * steps a turn continues by object, would see a new turn each time the card's\n * cut drops its oldest step and the turn's first step changes. A step whose id\n * and content are unchanged is the object held for that id. O(the steps' size).\n */\nfunction steadyStepObjects(): (\n transcript: readonly LangChainMessage[]\n) => readonly LangChainMessage[] {\n let held = new Map<string, LangChainMessage>();\n return (transcript) => {\n const next = new Map<string, LangChainMessage>();\n let kept = false;\n const steadied = transcript.map((entry) => {\n const id = entry.id;\n if (typeof id !== 'string') return entry;\n const before = held.get(id);\n const step = before !== undefined && sameJson(before, entry) ? before : entry;\n next.set(id, step);\n if (step !== entry) kept = true;\n return step;\n });\n held = next;\n return kept ? steadied : transcript;\n };\n}\n\n/** One lane's transcript, converted: `undefined` when the converter refused it. */\nexport type SubagentLaneConversion = (\n transcript: readonly LangChainMessage[],\n running: boolean\n) => readonly ThreadMessage[] | undefined;\n\n/**\n * One `task` lane's own conversion memory, for whatever converts that lane:\n * its unchanged steps keep their converted objects while it streams (a step the\n * wire sends again unchanged included, see {@link steadyStepObjects}), and its\n * turn keeps its row key (`deepAgentRowKey`) and part keys when the turn's head\n * moves — the oldest steps of a cut card falling off as the lane runs, or older\n * steps a transcript drawer pages in. A surface that keeps its disclosures under\n * that key keeps them open through both. A transcript array converted last time\n * is not converted again.\n */\nexport function createSubagentLaneConversion(): SubagentLaneConversion {\n const memory = createSubagentTranscriptConversionCache();\n const steady = steadyStepObjects();\n let last: {\n readonly transcript: readonly LangChainMessage[];\n readonly running: boolean;\n readonly messages: readonly ThreadMessage[] | undefined;\n } | null = null;\n return (transcript, running) => {\n if (last !== null && last.transcript === transcript && last.running === running) {\n return last.messages;\n }\n let messages: readonly ThreadMessage[] | undefined;\n try {\n messages = memory.convert(transcriptSources(steady(transcript)), running);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n last = { transcript, running, messages };\n return messages;\n };\n}\n\n/**\n * Sets each `task` part of a pass's converted rows to carry its nested\n * transcript as `messages`, for one attach. Each lane has its own conversion\n * memory, so its unchanged steps keep their converted objects while it\n * streams, as the thread's own messages do, and a lane whose transcript array\n * did not change is not converted again. A row, and a part whose lane did not\n * change, keep their identity: the same row always comes back as the same\n * object. A lane's memory lives only while a row of the pass holds its `task`\n * call: a lane a rewind removes, a branch switch hides or the window leaves\n * behind is let go with its transcript, and converted afresh if it returns.\n */\nfunction subagentTranscriptAttacher(): (rows: readonly ThreadMessage[]) => ThreadMessage[] {\n const lanes = new Map<string, SubagentLaneConversion>();\n const attachedRows = new WeakMap<ThreadMessage, ThreadMessage>();\n const attachedParts = new WeakMap<\n ToolCallMessagePart,\n { readonly messages: readonly ThreadMessage[]; readonly part: ToolCallMessagePart }\n >();\n\n const laneMessages = (\n toolCallId: string,\n transcript: readonly LangChainMessage[],\n running: boolean\n ): readonly ThreadMessage[] | undefined => {\n let lane = lanes.get(toolCallId);\n if (lane === undefined) {\n lane = createSubagentLaneConversion();\n lanes.set(toolCallId, lane);\n }\n return lane(transcript, running);\n };\n\n const attach = (row: ThreadMessage): ThreadMessage => {\n if (row.role !== 'assistant') return row;\n const cached = attachedRows.get(row);\n if (cached !== undefined) return cached;\n let content: ThreadAssistantMessagePart[] | null = null;\n for (const [index, part] of row.content.entries()) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n const nested = laneTranscriptOf(part.artifact);\n if (nested === undefined) continue;\n // A running lane's placeholder is preliminary: its newest nested turn streams.\n const running = part.isPreliminary === true;\n const restored = withRepeatedResult(nested, part.result);\n const transcript =\n running || part.isError === true\n ? restored\n : withLaneReport(restored, getMessageText({ content: part.result }));\n const messages = laneMessages(part.toolCallId, transcript, running);\n if (messages === undefined) continue;\n const kept = attachedParts.get(part);\n const attached =\n kept !== undefined && kept.messages === messages ? kept.part : { ...part, messages };\n attachedParts.set(part, { messages, part: attached });\n content ??= [...row.content];\n content[index] = attached;\n }\n const attachedRow: ThreadMessage = content === null ? row : { ...row, content };\n attachedRows.set(row, attachedRow);\n return attachedRow;\n };\n\n return (rows) => {\n const attached = rows.map(attach);\n if (lanes.size === 0) return attached;\n const held = new Set<string>();\n for (const row of rows) {\n if (row.role !== 'assistant') continue;\n for (const part of row.content) {\n if (part.type !== 'tool-call' || part.toolName !== TASK_TOOL_NAME) continue;\n held.add(part.toolCallId);\n }\n }\n for (const toolCallId of lanes.keys()) {\n if (!held.has(toolCallId)) lanes.delete(toolCallId);\n }\n return attached;\n };\n}\n\n/**\n * A conversion memory for one attach (see\n * `useDeepAgentThread({ createConversionCache })`): the shared one's rows, with\n * each `task` tool-call part carrying its subagent's converted transcript as\n * `messages`. A pass that changes no row hands back the previous list itself.\n */\nexport function createSubagentTranscriptConversionCache(\n options: DeepAgentMessageConversionOptions = {}\n): DeepAgentConversionMemory {\n const thread = createDeepAgentMessageConversionCache(options);\n const attach = subagentTranscriptAttacher();\n let previousRows: ThreadMessage[] | null = null;\n let previous: ThreadMessage[] = [];\n return {\n convert(messages, isRunning) {\n const rows = thread.convert(messages, isRunning);\n if (rows === previousRows) return previous;\n previousRows = rows;\n const next = attach(rows);\n const unchanged =\n next.length === previous.length && next.every((row, index) => row === previous[index]);\n if (!unchanged) previous = next;\n return previous;\n },\n };\n}\n\n/**\n * Shared by every in-eval transcript: entries are keyed by source message, so\n * none outlives the wire state holding it and threads cannot collide.\n */\nconst inEvalTranscriptCache = createExternalMessageConversionCache();\nconst IN_EVAL_TRANSCRIPT_METADATA = {};\nconst inEvalTranscripts = new WeakMap<\n readonly LangChainMessage[],\n { readonly running: boolean; readonly messages: readonly ThreadMessage[] }\n>();\n\nconst NO_MESSAGES: readonly ThreadMessage[] = [];\n\n/**\n * An in-eval dispatch's live transcript (a `ptc_subagents` entry's `messages`)\n * as a nested thread, converted like a `task` lane's. Memoized per transcript\n * array; a step the lane did not change keeps its converted object. A\n * transcript the converter refuses reads as empty.\n */\nexport function convertSubagentTranscript(\n transcript: readonly LangChainMessage[],\n running: boolean\n): readonly ThreadMessage[] {\n const cached = inEvalTranscripts.get(transcript);\n if (cached !== undefined && cached.running === running) return cached.messages;\n let messages: readonly ThreadMessage[] = NO_MESSAGES;\n try {\n messages = convertExternalMessages(\n transcriptSources(transcript),\n convertDeepAgentLangChainMessage,\n running,\n IN_EVAL_TRANSCRIPT_METADATA,\n inEvalTranscriptCache\n ).map(markPreliminaryToolResults);\n } catch (error) {\n reportUnconvertibleTranscript(transcript, error);\n }\n inEvalTranscripts.set(transcript, { running, messages });\n return messages;\n}\n"],"names":[],"mappings":";;;;;AAyCA,SAAS,iBAAiB,UAA4D;AACpF,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,QAAkB,SAA0C;AAClE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,WAAqB,MAAiC;AAC5D,SAAO,MAAM,QAAQ,QAAQ,IAAK,WAAkC;AACtE;AAEA,MAAM,0CAA0B,QAAA;AAYzB,SAAS,mBACd,YACA,SAC6B;AAC7B,QAAM,OAAO,WAAW,WAAW,SAAS,CAAC;AAC7C,MACE,SAAS,UACR,KAAiC,6BAA6B,MAAM,QACpE,OAAO,YAAY,YAAY,CAAC,MAAM,QAAQ,OAAO,GACtD;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAS,oBAAoB,IAAI,UAAU;AACjD,MAAI,WAAW,UAAa,OAAO,YAAY,gBAAgB,OAAO;AACtE,QAAM,WAAW,CAAC,GAAG,WAAW,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,SAA6B;AACtF,sBAAoB,IAAI,YAAY,EAAE,SAAS,YAAY,UAAU;AACrE,SAAO;AACT;AAIA,MAAM,4CAA4B,QAAA;AAOlC,SAAS,kBAAkB,SAA6C;AACtE,QAAM,OAAe,QAAQ;AAC7B,MAAI,SAAS,iBAAkB,QAAO;AACtC,QAAM,SAAS,sBAAsB,IAAI,OAAO;AAChD,MAAI,WAAW,OAAW,QAAO;AACjC,QAAM,OAAyB,EAAE,GAAI,SAAuC,MAAM,KAAA;AAClF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