@athenaintel/react 0.22.4 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +394 -4
- package/dist/chat/AthenaChat.cjs +346 -244
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +19 -8
- package/dist/chat/AthenaChat.js +350 -248
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +2 -1
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.js +2 -1
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +1 -0
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireClientToolBridge.js +1 -0
- package/dist/chat/StatewireClientToolBridge.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +1 -0
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.js +1 -0
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/WaitingOnYouBanner.cjs +100 -0
- package/dist/chat/WaitingOnYouBanner.cjs.map +1 -0
- package/dist/chat/WaitingOnYouBanner.d.ts +29 -0
- package/dist/chat/WaitingOnYouBanner.js +100 -0
- package/dist/chat/WaitingOnYouBanner.js.map +1 -0
- package/dist/chat/athena-chat-welcome.cjs +148 -0
- package/dist/chat/athena-chat-welcome.cjs.map +1 -0
- package/dist/chat/athena-chat-welcome.d.ts +54 -0
- package/dist/chat/athena-chat-welcome.js +148 -0
- package/dist/chat/athena-chat-welcome.js.map +1 -0
- package/dist/chat/athena-composer-controls.cjs +76 -0
- package/dist/chat/athena-composer-controls.cjs.map +1 -0
- package/dist/chat/athena-composer-controls.d.ts +21 -0
- package/dist/chat/athena-composer-controls.js +76 -0
- package/dist/chat/athena-composer-controls.js.map +1 -0
- package/dist/chat/composer-keyboard-hint.cjs +61 -0
- package/dist/chat/composer-keyboard-hint.cjs.map +1 -0
- package/dist/chat/composer-keyboard-hint.d.ts +33 -0
- package/dist/chat/composer-keyboard-hint.js +61 -0
- package/dist/chat/composer-keyboard-hint.js.map +1 -0
- package/dist/chat/message-time.cjs +64 -0
- package/dist/chat/message-time.cjs.map +1 -0
- package/dist/chat/message-time.d.ts +45 -0
- package/dist/chat/message-time.js +64 -0
- package/dist/chat/message-time.js.map +1 -0
- package/dist/chat/run-activity.cjs +38 -7
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.d.ts +14 -3
- package/dist/chat/run-activity.js +39 -8
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +2 -1
- package/dist/chat/statewire-client-tools.cjs.map +1 -1
- package/dist/chat/statewire-client-tools.js +2 -1
- package/dist/chat/statewire-client-tools.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +2 -1
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.js +2 -1
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/thread-scroll-to-bottom.cjs +24 -0
- package/dist/chat/thread-scroll-to-bottom.cjs.map +1 -0
- package/dist/chat/thread-scroll-to-bottom.d.ts +11 -0
- package/dist/chat/thread-scroll-to-bottom.js +24 -0
- package/dist/chat/thread-scroll-to-bottom.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +26 -95
- package/dist/chat/tiptap-text.cjs.map +1 -1
- package/dist/chat/tiptap-text.d.ts +13 -0
- package/dist/chat/tiptap-text.js +26 -95
- package/dist/chat/tiptap-text.js.map +1 -1
- package/dist/chat/use-athena-run-live.cjs +2 -1
- package/dist/chat/use-athena-run-live.cjs.map +1 -1
- package/dist/chat/use-athena-run-live.js +2 -1
- package/dist/chat/use-athena-run-live.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +1 -0
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.js +1 -0
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +39 -4
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +21 -0
- package/dist/chat-ui/composer/tiptap-composer.js +39 -4
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +15 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +6 -3
- package/dist/chat-ui/index.js +16 -2
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +31 -4
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.js +31 -4
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +19 -1
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +13 -0
- package/dist/chat-ui/messages/message-components.js +19 -1
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +2 -1
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
- package/dist/chat-ui/messages/runtime-message.js +2 -1
- package/dist/chat-ui/messages/runtime-message.js.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +1 -0
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.js +1 -0
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +3 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +3 -1
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +84 -0
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -0
- package/dist/chat-ui/messages/wake-marker.d.ts +16 -0
- package/dist/chat-ui/messages/wake-marker.js +84 -0
- package/dist/chat-ui/messages/wake-marker.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-blocks.cjs +177 -0
- package/dist/chat-ui/rich-text/chat-blocks.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-blocks.d.ts +58 -0
- package/dist/chat-ui/rich-text/chat-blocks.js +177 -0
- package/dist/chat-ui/rich-text/chat-blocks.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-link.cjs +69 -0
- package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-link.d.ts +24 -0
- package/dist/chat-ui/rich-text/chat-link.js +69 -0
- package/dist/chat-ui/rich-text/chat-link.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs +144 -18
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +10 -1
- package/dist/chat-ui/rich-text/chat-message-body.js +149 -23
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.cjs +38 -5
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-node-views.d.ts +11 -0
- package/dist/chat-ui/rich-text/chat-node-views.js +39 -6
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +20 -3
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +15 -2
- package/dist/chat-ui/rich-text/chat-text-schema.js +20 -3
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/rich-text/citation-anchors.cjs +139 -0
- package/dist/chat-ui/rich-text/citation-anchors.cjs.map +1 -0
- package/dist/chat-ui/rich-text/citation-anchors.d.ts +74 -0
- package/dist/chat-ui/rich-text/citation-anchors.js +139 -0
- package/dist/chat-ui/rich-text/citation-anchors.js.map +1 -0
- package/dist/chat-ui/statewire.cjs +8 -1
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +2 -0
- package/dist/chat-ui/statewire.js +8 -1
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/chat-composer-dock.cjs +27 -6
- package/dist/chat-ui/thread/chat-composer-dock.cjs.map +1 -1
- package/dist/chat-ui/thread/chat-composer-dock.d.ts +21 -1
- package/dist/chat-ui/thread/chat-composer-dock.js +28 -7
- package/dist/chat-ui/thread/chat-composer-dock.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +12 -13
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +11 -10
- package/dist/chat-ui/thread/statewire-history-edge.js +13 -14
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/chat-ui/thread/thread-loading-overlay.cjs +31 -0
- package/dist/chat-ui/thread/thread-loading-overlay.cjs.map +1 -0
- package/dist/chat-ui/thread/thread-loading-overlay.d.ts +14 -0
- package/dist/chat-ui/thread/thread-loading-overlay.js +31 -0
- package/dist/chat-ui/thread/thread-loading-overlay.js.map +1 -0
- package/dist/composer/ComposerDropZone.cjs +8 -1
- package/dist/composer/ComposerDropZone.cjs.map +1 -1
- package/dist/composer/ComposerDropZone.d.ts +6 -0
- package/dist/composer/ComposerDropZone.js +9 -2
- package/dist/composer/ComposerDropZone.js.map +1 -1
- package/dist/diagnostics/errors.cjs +20 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +20 -0
- package/dist/diagnostics/errors.js +20 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +47 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -7
- package/dist/index.js +51 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/use-prefers-reduced-motion.cjs +29 -0
- package/dist/lib/use-prefers-reduced-motion.cjs.map +1 -0
- package/dist/lib/use-prefers-reduced-motion.d.ts +6 -0
- package/dist/lib/use-prefers-reduced-motion.js +29 -0
- package/dist/lib/use-prefers-reduced-motion.js.map +1 -0
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-index.js.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs +59 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.js +60 -1
- package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs +5 -3
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js +5 -3
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs +21 -17
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.js +22 -18
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +9 -11
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +9 -11
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/packages/agent-runtime/src/github-wake-event.cjs +86 -0
- package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/github-wake-event.js +86 -0
- package/dist/packages/agent-runtime/src/github-wake-event.js.map +1 -0
- package/dist/packages/agent-runtime/src/message-window.cjs +150 -42
- package/dist/packages/agent-runtime/src/message-window.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/message-window.js +151 -43
- package/dist/packages/agent-runtime/src/message-window.js.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +13 -9
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +13 -9
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs +1 -3
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.js +1 -3
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +61 -30
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js +59 -28
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs +56 -36
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js +59 -39
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/dist/provider/AthenaContext.cjs.map +1 -1
- package/dist/provider/AthenaContext.d.ts +3 -0
- package/dist/provider/AthenaContext.js.map +1 -1
- package/dist/provider/AthenaProvider.cjs +93 -45
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +6 -1
- package/dist/provider/AthenaProvider.js +97 -49
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +2 -1
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.js +2 -1
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +3 -2
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -12
- package/dist/runtime/useAthenaStatewireRuntime.js +3 -2
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaRepoSearch.cjs +94 -0
- package/dist/search/useAthenaRepoSearch.cjs.map +1 -0
- package/dist/search/useAthenaRepoSearch.d.ts +95 -0
- package/dist/search/useAthenaRepoSearch.js +94 -0
- package/dist/search/useAthenaRepoSearch.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/threads/SessionList.cjs +486 -0
- package/dist/threads/SessionList.cjs.map +1 -0
- package/dist/threads/SessionList.d.ts +60 -0
- package/dist/threads/SessionList.js +486 -0
- package/dist/threads/SessionList.js.map +1 -0
- package/dist/threads/api.cjs +112 -4
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +128 -1
- package/dist/threads/api.js +113 -5
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +27 -3
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +16 -3
- package/dist/threads/conversation-list-fetcher.js +27 -3
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/index.d.ts +5 -1
- package/dist/threads/session-list-model.cjs +130 -0
- package/dist/threads/session-list-model.cjs.map +1 -0
- package/dist/threads/session-list-model.d.ts +62 -0
- package/dist/threads/session-list-model.js +130 -0
- package/dist/threads/session-list-model.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +220 -38
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +152 -2
- package/dist/threads/statewire-thread-list.js +222 -40
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/thread-prefetcher.cjs +63 -0
- package/dist/threads/thread-prefetcher.cjs.map +1 -0
- package/dist/threads/thread-prefetcher.d.ts +54 -0
- package/dist/threads/thread-prefetcher.js +63 -0
- package/dist/threads/thread-prefetcher.js.map +1 -0
- package/dist/threads/use-athena-session-attention.cjs +22 -0
- package/dist/threads/use-athena-session-attention.cjs.map +1 -0
- package/dist/threads/use-athena-session-attention.d.ts +24 -0
- package/dist/threads/use-athena-session-attention.js +22 -0
- package/dist/threads/use-athena-session-attention.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +25 -2
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.d.ts +8 -1
- package/dist/threads/use-rest-conversation-history.js +25 -2
- package/dist/threads/use-rest-conversation-history.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +40 -16
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +13 -0
- package/dist/threads/use-statewire-conversation-history.js +40 -16
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/threads/use-thread-archive.cjs +128 -0
- package/dist/threads/use-thread-archive.cjs.map +1 -0
- package/dist/threads/use-thread-archive.d.ts +26 -0
- package/dist/threads/use-thread-archive.js +128 -0
- package/dist/threads/use-thread-archive.js.map +1 -0
- package/dist/threads/use-thread-favorite.cjs +53 -0
- package/dist/threads/use-thread-favorite.cjs.map +1 -0
- package/dist/threads/use-thread-favorite.d.ts +49 -0
- package/dist/threads/use-thread-favorite.js +53 -0
- package/dist/threads/use-thread-favorite.js.map +1 -0
- package/dist/threads/use-thread-field-override.cjs +184 -0
- package/dist/threads/use-thread-field-override.cjs.map +1 -0
- package/dist/threads/use-thread-field-override.d.ts +55 -0
- package/dist/threads/use-thread-field-override.js +184 -0
- package/dist/threads/use-thread-field-override.js.map +1 -0
- package/dist/threads/use-thread-rename.cjs +53 -0
- package/dist/threads/use-thread-rename.cjs.map +1 -0
- package/dist/threads/use-thread-rename.d.ts +48 -0
- package/dist/threads/use-thread-rename.js +53 -0
- package/dist/threads/use-thread-rename.js.map +1 -0
- package/dist/tools/index.cjs +5 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +7 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -1
- package/dist/tools/misc-tool-uis.cjs.map +1 -1
- package/dist/tools/misc-tool-uis.js +2 -1
- package/dist/tools/misc-tool-uis.js.map +1 -1
- package/dist/tools/primitives.cjs +25 -2
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/primitives.d.ts +9 -2
- package/dist/tools/primitives.js +26 -3
- package/dist/tools/primitives.js.map +1 -1
- package/dist/tools/tool-appearance.cjs +11 -0
- package/dist/tools/tool-appearance.cjs.map +1 -0
- package/dist/tools/tool-appearance.d.ts +29 -0
- package/dist/tools/tool-appearance.js +11 -0
- package/dist/tools/tool-appearance.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +211 -13
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.d.ts +31 -4
- package/dist/tools/tool-fallback.js +214 -16
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/use-elapsed-seconds.cjs +24 -0
- package/dist/tools/use-elapsed-seconds.cjs.map +1 -0
- package/dist/tools/use-elapsed-seconds.d.ts +10 -0
- package/dist/tools/use-elapsed-seconds.js +24 -0
- package/dist/tools/use-elapsed-seconds.js.map +1 -0
- package/dist/tools/voice-update-tool-ui.cjs +2 -1
- package/dist/tools/voice-update-tool-ui.cjs.map +1 -1
- package/dist/tools/voice-update-tool-ui.js +2 -1
- package/dist/tools/voice-update-tool-ui.js.map +1 -1
- package/package.json +3 -3
- package/src/chat-ui/tailwind-preset.js +14 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const GITHUB_EVENT_SOURCE_KEY = "github_event_source";
|
|
2
|
+
const REPO_FULL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9._-]+$/;
|
|
3
|
+
const GITHUB_HOSTS = /* @__PURE__ */ new Set(["github.com", "www.github.com"]);
|
|
4
|
+
function readString(record, key) {
|
|
5
|
+
const value = record[key];
|
|
6
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
7
|
+
}
|
|
8
|
+
function readNumber(record, key) {
|
|
9
|
+
const value = record[key];
|
|
10
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
11
|
+
if (typeof value === "string" && /^\d+$/.test(value.trim())) return Number(value.trim());
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
function githubWakeEventUrl(repo, url) {
|
|
15
|
+
if (url === null) return null;
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = new URL(url);
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (parsed.protocol !== "https:" || !GITHUB_HOSTS.has(parsed.hostname.toLowerCase())) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const path = parsed.pathname.toLowerCase();
|
|
26
|
+
const prefix = `/${repo.toLowerCase()}`;
|
|
27
|
+
return path === prefix || path.startsWith(`${prefix}/`) ? parsed.toString() : null;
|
|
28
|
+
}
|
|
29
|
+
function readGithubWakeEvent(custom) {
|
|
30
|
+
const raw = custom == null ? void 0 : custom[GITHUB_EVENT_SOURCE_KEY];
|
|
31
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
|
|
32
|
+
const record = raw;
|
|
33
|
+
const repo = readString(record, "repo");
|
|
34
|
+
if (repo === null || !REPO_FULL_NAME.test(repo)) return void 0;
|
|
35
|
+
return {
|
|
36
|
+
repo,
|
|
37
|
+
number: readNumber(record, "number"),
|
|
38
|
+
githubEvent: readString(record, "github_event"),
|
|
39
|
+
action: readString(record, "action"),
|
|
40
|
+
sender: readString(record, "sender"),
|
|
41
|
+
title: readString(record, "title"),
|
|
42
|
+
url: githubWakeEventUrl(repo, readString(record, "url")),
|
|
43
|
+
reviewState: readString(record, "review_state"),
|
|
44
|
+
checkName: readString(record, "check_name"),
|
|
45
|
+
checkConclusion: readString(record, "check_conclusion"),
|
|
46
|
+
bodyExcerpt: readString(record, "body_excerpt"),
|
|
47
|
+
receivedAt: readString(record, "received_at")
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function isGithubWakeMessage(custom) {
|
|
51
|
+
return readGithubWakeEvent(custom) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
function humanize(value) {
|
|
54
|
+
return value.replace(/[._]/g, " ").trim();
|
|
55
|
+
}
|
|
56
|
+
function githubWakeEventLabel(event) {
|
|
57
|
+
const name = event.githubEvent ?? "";
|
|
58
|
+
if (name.includes("review_comment")) return "review comment";
|
|
59
|
+
if (name.includes("review")) {
|
|
60
|
+
return event.reviewState ? `review: ${humanize(event.reviewState)}` : "review";
|
|
61
|
+
}
|
|
62
|
+
if (name.includes("comment")) return "comment";
|
|
63
|
+
if (name.includes("check")) {
|
|
64
|
+
const check = event.checkName ? `check ${event.checkName}` : "check";
|
|
65
|
+
return event.checkConclusion ? `${check}: ${humanize(event.checkConclusion)}` : check;
|
|
66
|
+
}
|
|
67
|
+
if (event.action) return `${humanize(name) || "event"} ${humanize(event.action)}`.trim();
|
|
68
|
+
return humanize(name) || "GitHub event";
|
|
69
|
+
}
|
|
70
|
+
function githubWakeReference(event) {
|
|
71
|
+
return event.number !== null ? `${event.repo}#${event.number}` : event.repo;
|
|
72
|
+
}
|
|
73
|
+
function githubWakeMarkerText(event) {
|
|
74
|
+
const target = event.number !== null ? `#${event.number}` : event.repo;
|
|
75
|
+
return `Woke: ${githubWakeEventLabel(event)} on ${target}`;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
GITHUB_EVENT_SOURCE_KEY,
|
|
79
|
+
githubWakeEventLabel,
|
|
80
|
+
githubWakeEventUrl,
|
|
81
|
+
githubWakeMarkerText,
|
|
82
|
+
githubWakeReference,
|
|
83
|
+
isGithubWakeMessage,
|
|
84
|
+
readGithubWakeEvent
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=github-wake-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-wake-event.js","sources":["../../../../../agent-runtime/src/github-wake-event.ts"],"sourcesContent":["/**\n * The GitHub event that woke a resting session, read from the user turn the\n * wake injected.\n *\n * When a GitHub webhook wakes a linked session (agora\n * `trigger_engine/actions/handlers/github_thread_wake.py`), the injected user\n * turn carries a provenance envelope under `github_event_source` in its\n * message metadata (`services/channels/github_event_source.py`). The shipped\n * converter exposes that metadata as the thread message's `metadata.custom`,\n * so every surface reads the envelope from there and renders the turn as a\n * compact runtime marker (\"Woke: review comment on #36337\") instead of a user\n * bubble quoting the whole wake text. The envelope is provenance for RENDERING\n * only: the model still receives the full composed text, so a surface that\n * ignores it degrades to a plain bubble, never to a lost instruction.\n */\n\n/** `metadata.custom` key the wake handler stamps on the injected user turn. */\nexport const GITHUB_EVENT_SOURCE_KEY = 'github_event_source';\n\n/**\n * `owner/name`, the only repository shape the wake handler stamps. The\n * envelope is message metadata, which a collaborator with write access to\n * the thread can also author, so a marker is only rendered for an envelope\n * of the real shape and only links back into the named repository on\n * github.com (see {@link githubWakeEventUrl}) — a forged envelope can at\n * most point at its own repository, never at an arbitrary host.\n */\nconst REPO_FULL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*\\/[A-Za-z0-9._-]+$/;\n\nconst GITHUB_HOSTS: ReadonlySet<string> = new Set(['github.com', 'www.github.com']);\n\nexport interface GithubWakeEvent {\n /** `owner/repo` the event came from. */\n repo: string;\n /** The pull request number, when the event names one. */\n number: number | null;\n /** The webhook event name (`pull_request_review_comment`, `check_run`, …). */\n githubEvent: string | null;\n /** The event's `action` (`created`, `submitted`, `completed`, …). */\n action: string | null;\n /** GitHub login of who caused the event. */\n sender: string | null;\n /** The pull request title, when the payload carried one. */\n title: string | null;\n /**\n * Link to the pull request (or the repository for repo-level events),\n * kept only when it points into `repo` on github.com\n * ({@link githubWakeEventUrl}); any other value reads as `null`.\n */\n url: string | null;\n /** A review's state (`approved`, `changes_requested`, `commented`). */\n reviewState: string | null;\n /** A check's name and conclusion, for check events. */\n checkName: string | null;\n checkConclusion: string | null;\n /** The comment or review body, cut to the card budget by the backend. */\n bodyExcerpt: string | null;\n /** ISO 8601 receipt time stamped by the backend. */\n receivedAt: string | null;\n}\n\nfunction readString(record: Record<string, unknown>, key: string): string | null {\n const value = record[key];\n return typeof value === 'string' && value.trim().length > 0 ? value : null;\n}\n\nfunction readNumber(record: Record<string, unknown>, key: string): number | null {\n const value = record[key];\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (typeof value === 'string' && /^\\d+$/.test(value.trim())) return Number(value.trim());\n return null;\n}\n\n/**\n * The envelope's link when it is an `https://github.com/<repo>/…` URL for the\n * envelope's own repository, else `null`. The marker never renders a link\n * that could lead anywhere else, whatever the metadata claims.\n */\nexport function githubWakeEventUrl(repo: string, url: string | null): string | null {\n if (url === null) return null;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'https:' || !GITHUB_HOSTS.has(parsed.hostname.toLowerCase())) {\n return null;\n }\n const path = parsed.pathname.toLowerCase();\n const prefix = `/${repo.toLowerCase()}`;\n return path === prefix || path.startsWith(`${prefix}/`) ? parsed.toString() : null;\n}\n\n/**\n * The wake envelope behind a thread message's `metadata.custom`, or\n * `undefined` when the message is an ordinary user turn (or the envelope is\n * not of the shape the wake handler stamps — a missing or malformed\n * repository is not a wake worth rendering).\n */\nexport function readGithubWakeEvent(\n custom: Record<string, unknown> | null | undefined\n): GithubWakeEvent | undefined {\n const raw = custom?.[GITHUB_EVENT_SOURCE_KEY];\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return undefined;\n const record = raw as Record<string, unknown>;\n const repo = readString(record, 'repo');\n if (repo === null || !REPO_FULL_NAME.test(repo)) return undefined;\n return {\n repo,\n number: readNumber(record, 'number'),\n githubEvent: readString(record, 'github_event'),\n action: readString(record, 'action'),\n sender: readString(record, 'sender'),\n title: readString(record, 'title'),\n url: githubWakeEventUrl(repo, readString(record, 'url')),\n reviewState: readString(record, 'review_state'),\n checkName: readString(record, 'check_name'),\n checkConclusion: readString(record, 'check_conclusion'),\n bodyExcerpt: readString(record, 'body_excerpt'),\n receivedAt: readString(record, 'received_at'),\n };\n}\n\n/**\n * Whether a thread message is a GitHub wake turn. Returns a primitive, so it\n * is safe as a `useAuiState` selector (the reader above builds a fresh object\n * per call; an object snapshot would loop the render under `Object.is`).\n */\nexport function isGithubWakeMessage(custom: Record<string, unknown> | null | undefined): boolean {\n return readGithubWakeEvent(custom) !== undefined;\n}\n\nfunction humanize(value: string): string {\n return value.replace(/[._]/g, ' ').trim();\n}\n\n/**\n * The event in a few words, in sentence position (\"review comment\",\n * \"review: changes requested\", \"check CI: failure\", \"pull request opened\").\n */\nexport function githubWakeEventLabel(event: GithubWakeEvent): string {\n const name = event.githubEvent ?? '';\n if (name.includes('review_comment')) return 'review comment';\n if (name.includes('review')) {\n return event.reviewState ? `review: ${humanize(event.reviewState)}` : 'review';\n }\n if (name.includes('comment')) return 'comment';\n if (name.includes('check')) {\n const check = event.checkName ? `check ${event.checkName}` : 'check';\n return event.checkConclusion ? `${check}: ${humanize(event.checkConclusion)}` : check;\n }\n if (event.action) return `${humanize(name) || 'event'} ${humanize(event.action)}`.trim();\n return humanize(name) || 'GitHub event';\n}\n\n/** `owner/repo#123`, or `owner/repo` for a repository-level event. */\nexport function githubWakeReference(event: GithubWakeEvent): string {\n return event.number !== null ? `${event.repo}#${event.number}` : event.repo;\n}\n\n/**\n * The marker line every surface renders for a wake turn:\n * \"Woke: review comment on #36337\" (the repository when there is no number).\n */\nexport function githubWakeMarkerText(event: GithubWakeEvent): string {\n const target = event.number !== null ? `#${event.number}` : event.repo;\n return `Woke: ${githubWakeEventLabel(event)} on ${target}`;\n}\n"],"names":[],"mappings":"AAiBO,MAAM,0BAA0B;AAUvC,MAAM,iBAAiB;AAEvB,MAAM,eAAoC,oBAAI,IAAI,CAAC,cAAc,gBAAgB,CAAC;AAgClF,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,SAAO,OAAO,UAAU,YAAY,MAAM,OAAO,SAAS,IAAI,QAAQ;AACxE;AAEA,SAAS,WAAW,QAAiC,KAA4B;AAC/E,QAAM,QAAQ,OAAO,GAAG;AACxB,MAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,EAAG,QAAO;AAChE,MAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,MAAM,KAAA,CAAM,EAAG,QAAO,OAAO,MAAM,MAAM;AACvF,SAAO;AACT;AAOO,SAAS,mBAAmB,MAAc,KAAmC;AAClF,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,aAAa,YAAY,CAAC,aAAa,IAAI,OAAO,SAAS,YAAA,CAAa,GAAG;AACpF,WAAO;AAAA,EACT;AACA,QAAM,OAAO,OAAO,SAAS,YAAA;AAC7B,QAAM,SAAS,IAAI,KAAK,YAAA,CAAa;AACrC,SAAO,SAAS,UAAU,KAAK,WAAW,GAAG,MAAM,GAAG,IAAI,OAAO,SAAA,IAAa;AAChF;AAQO,SAAS,oBACd,QAC6B;AAC7B,QAAM,MAAM,iCAAS;AACrB,MAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,GAAG,EAAG,QAAO;AAC1E,QAAM,SAAS;AACf,QAAM,OAAO,WAAW,QAAQ,MAAM;AACtC,MAAI,SAAS,QAAQ,CAAC,eA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AAC3B;AAGO,SAAS,oBAAoB,OAAgC;AAClE,SAAO,MAAM,WAAW,OAAO,GAAG,MAAM,IAAI,IAAI,MAAM,MAAM,KAAK,MAAM;AACzE;AAMO,SAAS,qBAAqB,OAAgC;AACnE,QAAM,SAAS,MAAM,WAAW,OAAO,IAAI,MAAM,MAAM,KAAK,MAAM;AAClE,SAAO,SAAS,qBAAqB,KAAK,CAAC,OAAO,MAAM;AAC1D;"}
|
|
@@ -1,52 +1,155 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const runconfigContract = require("./generated/runconfig-contract.cjs");
|
|
4
|
+
const statewireTransport = require("./statewire-transport.cjs");
|
|
4
5
|
const isIndex = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
function clampMessageWindowSize(size) {
|
|
7
|
+
if (size === void 0 || !Number.isFinite(size)) return runconfigContract.DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;
|
|
8
|
+
return Math.max(
|
|
9
|
+
runconfigContract.DEEP_AGENT_MIN_MESSAGE_WINDOW,
|
|
10
|
+
Math.min(runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function headInterestRequest(size) {
|
|
14
|
+
return { ns: runconfigContract.DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };
|
|
15
|
+
}
|
|
16
|
+
function pageInterestRequest(at, size) {
|
|
17
|
+
return { ns: runconfigContract.DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };
|
|
15
18
|
}
|
|
16
|
-
const clampWindowSize = (size) => Math.max(
|
|
17
|
-
runconfigContract.DEEP_AGENT_MIN_MESSAGE_WINDOW,
|
|
18
|
-
Math.min(runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))
|
|
19
|
-
);
|
|
20
19
|
function withDeclaredMessageWindow(headers, declaration = {}) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
if (declaration.provenance === "full" && !(runconfigContract.DEEP_AGENT_PROVENANCE_HEADER in declared)) {
|
|
29
|
-
declared[runconfigContract.DEEP_AGENT_PROVENANCE_HEADER] = runconfigContract.DEEP_AGENT_PROVENANCE_FULL;
|
|
30
|
-
}
|
|
31
|
-
return declared;
|
|
20
|
+
if (runconfigContract.DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;
|
|
21
|
+
return {
|
|
22
|
+
...headers,
|
|
23
|
+
[runconfigContract.DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size))
|
|
24
|
+
};
|
|
32
25
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
26
|
+
function readDeepAgentInterestResolution(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null) return null;
|
|
28
|
+
const { ns, before, at, after, chain, more } = value;
|
|
29
|
+
if (ns !== runconfigContract.DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;
|
|
30
|
+
if (at !== void 0 && typeof at !== "string") return null;
|
|
31
|
+
if (after !== void 0 && !isIndex(after)) return null;
|
|
32
|
+
if (typeof more !== "object" || more === null) return null;
|
|
33
|
+
const { before: moreBefore, after: moreAfter } = more;
|
|
34
|
+
if (typeof moreBefore !== "boolean" || typeof moreAfter !== "boolean") return null;
|
|
35
|
+
const entries = [];
|
|
36
|
+
for (const entry of chain) {
|
|
37
|
+
const { id, siblings } = entry ?? {};
|
|
38
|
+
if (typeof id !== "string") return null;
|
|
39
|
+
entries.push({
|
|
40
|
+
id,
|
|
41
|
+
siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === "string") : [id]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
39
44
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
ns: runconfigContract.DEEP_AGENT_MAIN_NS,
|
|
46
|
+
before,
|
|
47
|
+
...at !== void 0 && { at },
|
|
48
|
+
...after !== void 0 && { after },
|
|
49
|
+
chain: entries,
|
|
50
|
+
more: { before: moreBefore, after: moreAfter }
|
|
43
51
|
};
|
|
44
52
|
}
|
|
45
|
-
function
|
|
46
|
-
if (typeof
|
|
47
|
-
const {
|
|
48
|
-
if (!
|
|
49
|
-
|
|
53
|
+
function readDeepAgentInterestDocument(value) {
|
|
54
|
+
if (typeof value !== "object" || value === null) return null;
|
|
55
|
+
const { windows } = value;
|
|
56
|
+
if (!Array.isArray(windows)) return null;
|
|
57
|
+
const resolutions = [];
|
|
58
|
+
for (const window of windows) {
|
|
59
|
+
const resolution = readDeepAgentInterestResolution(window);
|
|
60
|
+
if (resolution === null) return null;
|
|
61
|
+
resolutions.push(resolution);
|
|
62
|
+
}
|
|
63
|
+
return { windows: resolutions };
|
|
64
|
+
}
|
|
65
|
+
const interestRequest = ({ ns, before, at, after }) => ({
|
|
66
|
+
ns,
|
|
67
|
+
before,
|
|
68
|
+
...at !== void 0 && { at },
|
|
69
|
+
...after !== void 0 && { after }
|
|
70
|
+
});
|
|
71
|
+
function coalescedInterestRequests(chain, grow) {
|
|
72
|
+
const loaded = chain.length;
|
|
73
|
+
const requests = [
|
|
74
|
+
{ ns: runconfigContract.DEEP_AGENT_MAIN_NS, before: Math.min(runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) }
|
|
75
|
+
];
|
|
76
|
+
let low = loaded - requests[0].before;
|
|
77
|
+
while (low > 0) {
|
|
78
|
+
const before = Math.min(runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);
|
|
79
|
+
requests.push({
|
|
80
|
+
ns: runconfigContract.DEEP_AGENT_MAIN_NS,
|
|
81
|
+
before,
|
|
82
|
+
at: chain[low].id
|
|
83
|
+
});
|
|
84
|
+
low = low + 1 - before;
|
|
85
|
+
}
|
|
86
|
+
const last = requests[requests.length - 1];
|
|
87
|
+
if (last.before + grow <= runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW) {
|
|
88
|
+
requests[requests.length - 1] = { ...last, before: last.before + grow };
|
|
89
|
+
} else {
|
|
90
|
+
requests.push({
|
|
91
|
+
ns: runconfigContract.DEEP_AGENT_MAIN_NS,
|
|
92
|
+
before: grow + 1,
|
|
93
|
+
at: chain[0].id
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return requests.length > runconfigContract.DEEP_AGENT_MAX_INTERESTS ? null : requests;
|
|
97
|
+
}
|
|
98
|
+
function pageInterestRequests(window, size) {
|
|
99
|
+
var _a;
|
|
100
|
+
const anchor = (_a = window.chain[0]) == null ? void 0 : _a.id;
|
|
101
|
+
if (anchor === void 0 || !window.hasOlder) return null;
|
|
102
|
+
const page = pageInterestRequest(anchor, size);
|
|
103
|
+
const appended = [...window.requests, page];
|
|
104
|
+
if (appended.length <= runconfigContract.DEEP_AGENT_MAX_INTERESTS) return appended;
|
|
105
|
+
return coalescedInterestRequests(window.chain, page.before - 1);
|
|
106
|
+
}
|
|
107
|
+
function interestsCovered(carried, stated) {
|
|
108
|
+
return stated.every(
|
|
109
|
+
(request) => carried.some((have) => have.at === request.at && have.before >= request.before)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function readDeepAgentMessageWindow(mounted) {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
if (mounted === void 0) return null;
|
|
115
|
+
let windows;
|
|
116
|
+
const documents = /* @__PURE__ */ new Map();
|
|
117
|
+
for (const document of mounted.values()) {
|
|
118
|
+
const key = document.key;
|
|
119
|
+
if (document.protocol === runconfigContract.DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {
|
|
120
|
+
windows = (_a = readDeepAgentInterestDocument(document.value)) == null ? void 0 : _a.windows;
|
|
121
|
+
} else if (document.protocol === statewireTransport.DEEP_AGENT_STATEWIRE_PROTOCOL && key !== null && key.length === 3 && key[1] === runconfigContract.DEEP_AGENT_MAIN_NS) {
|
|
122
|
+
documents.set(key[2], document.value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const head = windows == null ? void 0 : windows[0];
|
|
126
|
+
if (windows === void 0 || head === void 0) return null;
|
|
127
|
+
let chain = head.chain;
|
|
128
|
+
let hasOlder = head.more.before;
|
|
129
|
+
const requests = [interestRequest(head)];
|
|
130
|
+
const loaded = new Set(chain.map((entry) => entry.id));
|
|
131
|
+
let pages = 0;
|
|
132
|
+
for (const page of windows.slice(1)) {
|
|
133
|
+
if (page.at === void 0 || !loaded.has(page.at)) continue;
|
|
134
|
+
const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);
|
|
135
|
+
if (anchorAt < 0) continue;
|
|
136
|
+
const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));
|
|
137
|
+
if (fresh.length === 0) {
|
|
138
|
+
if (((_b = page.chain[0]) == null ? void 0 : _b.id) === ((_c = chain[0]) == null ? void 0 : _c.id)) hasOlder = page.more.before;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
chain = [...fresh, ...chain];
|
|
142
|
+
for (const entry of fresh) loaded.add(entry.id);
|
|
143
|
+
hasOlder = page.more.before;
|
|
144
|
+
requests.push(interestRequest(page));
|
|
145
|
+
pages += 1;
|
|
146
|
+
}
|
|
147
|
+
const messages = [];
|
|
148
|
+
for (const entry of chain) {
|
|
149
|
+
const message = documents.get(entry.id);
|
|
150
|
+
if (message !== void 0) messages.push(message);
|
|
151
|
+
}
|
|
152
|
+
return { requests, chain, messages, hasOlder, pages };
|
|
50
153
|
}
|
|
51
154
|
function buildToolOutputCommand({ messageId }) {
|
|
52
155
|
return { type: runconfigContract.DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };
|
|
@@ -74,10 +177,15 @@ function readTruncatedToolOutputArtifact(artifact) {
|
|
|
74
177
|
return { chars, messageId };
|
|
75
178
|
}
|
|
76
179
|
exports.ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY;
|
|
77
|
-
exports.buildHistoryLoadCommand = buildHistoryLoadCommand;
|
|
78
180
|
exports.buildToolOutputCommand = buildToolOutputCommand;
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
181
|
+
exports.clampMessageWindowSize = clampMessageWindowSize;
|
|
182
|
+
exports.headInterestRequest = headInterestRequest;
|
|
183
|
+
exports.interestsCovered = interestsCovered;
|
|
184
|
+
exports.pageInterestRequest = pageInterestRequest;
|
|
185
|
+
exports.pageInterestRequests = pageInterestRequests;
|
|
186
|
+
exports.readDeepAgentInterestDocument = readDeepAgentInterestDocument;
|
|
187
|
+
exports.readDeepAgentInterestResolution = readDeepAgentInterestResolution;
|
|
188
|
+
exports.readDeepAgentMessageWindow = readDeepAgentMessageWindow;
|
|
81
189
|
exports.readToolOutputResult = readToolOutputResult;
|
|
82
190
|
exports.readTruncatedToolContent = readTruncatedToolContent;
|
|
83
191
|
exports.readTruncatedToolOutputArtifact = readTruncatedToolOutputArtifact;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-window.cjs","sources":["../../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_LOAD_COMMAND,\n DEEP_AGENT_HISTORY_LOAD_MAX_LIMIT,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MESSAGES_WINDOW_STATE_KEY,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_PROVENANCE_FULL,\n DEEP_AGENT_PROVENANCE_HEADER,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\n\n/**\n * The windowed hello — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * A surface that declares a message window on its attach headers\n * ({@link withDeclaredMessageWindow}) receives a hello carrying only the last\n * N messages plus the `messagesWindow` lane, and its op stream re-addressed\n * to that window by the host — so `state.messages` is always exactly\n * `server.messages[start:]` and the ordinary converter renders it unchanged.\n * Older ranges arrive through `history/load` ({@link buildHistoryLoadCommand})\n * as ops for this client alone; a truncated tool output comes back whole\n * through `history/tool_output` ({@link buildToolOutputCommand}).\n *\n * Undeclared surfaces (no header) are untouched: full snapshot, no lane.\n * Skew-tolerant both ways — an old server ignores the header and advertises\n * no lane (read as \"everything is loaded\"), a malformed lane reads as absent.\n */\nexport interface DeepAgentMessagesWindow {\n /** Index in the server transcript of the client's first loaded message. */\n start: number;\n /** Server transcript length. */\n total: number;\n /** Whether older messages exist that the client has not loaded (`start > 0`). */\n truncated: boolean;\n /** The window size the host clamped the declaration to. */\n size: number;\n /**\n * Id of the message just before the window (`null` at the beginning): the\n * host parent of the first loaded message, so an edit or reload at the\n * window edge can assert its `runAnchorMessageId` without loading first.\n */\n anchorBefore: string | null;\n}\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/**\n * The window lane off a raw statewire state, or `null` when the wire is not\n * windowed (an undeclared attach, a pre-window server, pre-attach) or the lane\n * is malformed (tolerated as absent — never thrown on).\n */\nexport function readDeepAgentMessagesWindow(state: unknown): DeepAgentMessagesWindow | null {\n if (typeof state !== 'object' || state === null) return null;\n const lane = (state as Record<string, unknown>)[DEEP_AGENT_MESSAGES_WINDOW_STATE_KEY];\n if (typeof lane !== 'object' || lane === null) return null;\n const { start, total, truncated, size, anchorBefore } = lane as Record<string, unknown>;\n if (!isIndex(start) || !isIndex(total) || !isIndex(size) || typeof truncated !== 'boolean') {\n return null;\n }\n if (anchorBefore !== null && typeof anchorBefore !== 'string') return null;\n return { start, total, truncated, size, anchorBefore };\n}\n\n/** How many messages older than the loaded window the server still holds. */\nexport function olderMessageCount(window: DeepAgentMessagesWindow | null): number {\n return window === null ? 0 : window.start;\n}\n\n/** What a surface declares on its attach: a window size and the provenance mode. */\nexport interface DeepAgentMessageWindowDeclaration {\n /** Messages the hello should carry (the host clamps to its bounds). */\n size?: number;\n /** `'full'` keeps the model-provenance blobs on the wire; default strips them. */\n provenance?: 'full' | 'compact';\n}\n\nconst clampWindowSize = (size: number): number =>\n Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n\n/**\n * Attach headers with a message window declared. Applied by\n * `useDeepAgentThread` when a surface passes `messageWindow`; an explicit\n * entry (tests, forced overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n const declared: Record<string, string> = { ...headers };\n if (!(DEEP_AGENT_MESSAGE_WINDOW_HEADER in declared)) {\n const size = declaration.size ?? DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n declared[DEEP_AGENT_MESSAGE_WINDOW_HEADER] = String(\n Number.isFinite(size) ? clampWindowSize(size) : DEEP_AGENT_DEFAULT_MESSAGE_WINDOW\n );\n }\n if (declaration.provenance === 'full' && !(DEEP_AGENT_PROVENANCE_HEADER in declared)) {\n declared[DEEP_AGENT_PROVENANCE_HEADER] = DEEP_AGENT_PROVENANCE_FULL;\n }\n return declared;\n}\n\n/**\n * The windowed wire's read commands on the statewire command union, so\n * `sendCommand({ type: 'history/load', … })` typechecks wherever the deep-agent\n * host is driven (`DeepAgentThread.history_load` / `history_tool_output`, both\n * attach-ACL reads). The augmentation is part of this module so every surface\n * that imports the builders gets the typed commands with them.\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** Prepend older messages to this client's windowed view. */\n historyLoad: HistoryLoadCommand;\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n }\n }\n}\n\n/** The `history/load` command: older messages prepended to this client's view. */\nexport interface HistoryLoadCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_LOAD_COMMAND;\n /** The `start` this load extends — the host answers `stale` for any other. */\n readonly beforeIndex: number;\n readonly limit: number;\n}\n\n/**\n * The next page of older history for `window`, or `null` when the beginning of\n * the transcript is already loaded. `limit` defaults to the window size and is\n * capped at the host's bound.\n */\nexport function buildHistoryLoadCommand({\n window,\n limit,\n}: {\n window: DeepAgentMessagesWindow;\n limit?: number;\n}): HistoryLoadCommand | null {\n if (window.start <= 0) return null;\n const requested = limit ?? window.size;\n return {\n type: DEEP_AGENT_HISTORY_LOAD_COMMAND,\n beforeIndex: window.start,\n limit: Math.max(1, Math.min(DEEP_AGENT_HISTORY_LOAD_MAX_LIMIT, Math.trunc(requested))),\n };\n}\n\n/** The host's answer to `history/load`. */\nexport interface HistoryLoadResult {\n start: number;\n total: number;\n loaded: number;\n /** The load named a `start` the client no longer held; nothing was loaded. */\n stale: boolean;\n}\n\nexport function readHistoryLoadResult(payload: unknown): HistoryLoadResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { start, total, loaded, stale } = payload as Record<string, unknown>;\n if (!isIndex(start) || !isIndex(total) || !isIndex(loaded)) return null;\n return { start, total, loaded, stale: stale === true };\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":["DEEP_AGENT_MESSAGES_WINDOW_STATE_KEY","DEEP_AGENT_MIN_MESSAGE_WINDOW","DEEP_AGENT_MAX_MESSAGE_WINDOW","DEEP_AGENT_MESSAGE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AAUlD,SAAS,gCACd,UACoC;AACpC,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,SAAU,SAAqC,yCAAyC;AAC9F,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,OAAO,UAAA,IAAc;AAC7B,MAAI,CAAC,QAAQ,KAAK,KAAK,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AAC3E,SAAO,EAAE,OAAO,UAAA;AAClB;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"message-window.cjs","sources":["../../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireDocuments } from 'statewire';\nimport {\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_INTEREST_PROTOCOL,\n DEEP_AGENT_MAIN_NS,\n DEEP_AGENT_MAX_INTERESTS,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from './statewire-transport';\n\n/**\n * The interest window — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * The wire main document carries no `messages`. A client states its interests\n * on the `athena/interest` lane as one array (`set(requests)`): the first is\n * the head (the newest `before` messages of the `main` namespace), the rest\n * are pages anchored `at` the first message of the window they extend. The\n * host holds one ephemeral main document per attach, `{ windows }`, one\n * resolution per request in order (the request echoed plus the covered\n * `chain` and `more` flags; an anchor that vanished leaves an empty window in\n * place), and one shared `athena` document per covered message, keyed\n * `[threadId, \"main\", messageId]`. {@link readDeepAgentMessageWindow} joins\n * them into the transcript the converter renders.\n *\n * Two host rules shape the client half. The head window never drops below\n * the oldest message it has carried on an attach (a run's appends grow the\n * view, nothing loaded slides out), so a page stays anchored at the head's\n * first message while the transcript grows; and the host remembers a client\n * id's interests across its attaches, so a reconnect's hello carries the\n * view the client held. A fresh client's hello carries the head it declared\n * on the attach headers ({@link withDeclaredMessageWindow}) — a statement\n * cannot ride the first attach, the hello negotiates the lanes.\n *\n * Pages are appended one per load until the host's interest cap, then the\n * loaded range is restated in as few maximal requests as it takes\n * ({@link pageInterestRequests}); the whole transcript stays reachable up to\n * `MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages. A truncated tool output\n * comes back whole through `history/tool_output` ({@link buildToolOutputCommand});\n * a message's stored form — provenance blobs and all — through\n * `history/message` ({@link buildHistoryMessageCommand}).\n */\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/** What a surface declares for its window: the interest size (the host clamps to its bounds). */\nexport interface DeepAgentMessageWindowDeclaration {\n size?: number;\n}\n\nexport function clampMessageWindowSize(size?: number): number {\n if (size === undefined || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n return Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n}\n\n/** An `athena/interest` request over the linear transcript. */\nexport interface DeepAgentInterestRequest {\n readonly ns: typeof DEEP_AGENT_MAIN_NS;\n /** Messages ending at the anchor (the tail without `at`). */\n readonly before: number;\n /** Anchor message id; a page's is the first message of the window it extends. */\n readonly at?: string;\n /** Messages past the anchor (requires `at`). */\n readonly after?: number;\n}\n\nexport function headInterestRequest(size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };\n}\n\nexport function pageInterestRequest(at: string, size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };\n}\n\n/**\n * Attach headers with the head window declared (`x-athena-deep-agent-window`):\n * the hello of a client the host does not remember carries the newest `size`\n * messages. Part of the one attach recipe, so a pooled dial asks for the shape\n * the thread's own attach would. An explicit entry (tests, overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;\n return {\n ...headers,\n [DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size)),\n };\n}\n\nexport interface DeepAgentInterestChainEntry {\n id: string;\n siblings: string[];\n}\n\n/** The host's resolution document of one interest: the request echoed plus its coverage. */\nexport interface DeepAgentInterestResolution extends DeepAgentInterestRequest {\n /** Covered message ids, oldest first (a page ends at its anchor). */\n chain: DeepAgentInterestChainEntry[];\n more: { before: boolean; after: boolean };\n}\n\nexport function readDeepAgentInterestResolution(value: unknown): DeepAgentInterestResolution | null {\n if (typeof value !== 'object' || value === null) return null;\n const { ns, before, at, after, chain, more } = value as Record<string, unknown>;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n if (typeof more !== 'object' || more === null) return null;\n const { before: moreBefore, after: moreAfter } = more as Record<string, unknown>;\n if (typeof moreBefore !== 'boolean' || typeof moreAfter !== 'boolean') return null;\n const entries: DeepAgentInterestChainEntry[] = [];\n for (const entry of chain) {\n const { id, siblings } = (entry ?? {}) as Record<string, unknown>;\n if (typeof id !== 'string') return null;\n entries.push({\n id,\n siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === 'string') : [id],\n });\n }\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n chain: entries,\n more: { before: moreBefore, after: moreAfter },\n };\n}\n\n/** The attach's interest document: one resolution per stated request, in order. */\nexport interface DeepAgentInterestDocument {\n windows: DeepAgentInterestResolution[];\n}\n\nexport function readDeepAgentInterestDocument(value: unknown): DeepAgentInterestDocument | null {\n if (typeof value !== 'object' || value === null) return null;\n const { windows } = value as Record<string, unknown>;\n if (!Array.isArray(windows)) return null;\n const resolutions: DeepAgentInterestResolution[] = [];\n for (const window of windows) {\n const resolution = readDeepAgentInterestResolution(window);\n if (resolution === null) return null;\n resolutions.push(resolution);\n }\n return { windows: resolutions };\n}\n\nconst interestRequest = ({ ns, before, at, after }: DeepAgentInterestRequest): DeepAgentInterestRequest => ({\n ns,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n});\n\n/** The loaded transcript window, joined from the head interest and its anchored pages. */\nexport interface DeepAgentMessageWindow {\n /** The requests the joined view stands on, in order (the head first): what a `set` restates. A stale page (its anchor gone) or one the head already covers is left out. */\n requests: DeepAgentInterestRequest[];\n /** Covered chain, oldest first. */\n chain: DeepAgentInterestChainEntry[];\n /** The chain's message documents, in chain order (an unmounted one is skipped). */\n messages: LangChainMessage[];\n /** Whether the host holds messages older than the window. */\n hasOlder: boolean;\n /** Pages joined onto the head. */\n pages: number;\n}\n\n/**\n * The loaded chain plus `grow` older messages, restated in as few requests as\n * it takes: a maximal head, then maximal pages each anchored at the first\n * message of the window above it. `null` once even that exceeds the host's\n * interest cap — the reachable depth is `MAX_INTERESTS × MAX_MESSAGE_WINDOW`.\n */\nfunction coalescedInterestRequests(\n chain: readonly DeepAgentInterestChainEntry[],\n grow: number\n): DeepAgentInterestRequest[] | null {\n const loaded = chain.length;\n const requests: DeepAgentInterestRequest[] = [\n { ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) },\n ];\n // `low` is the chain index of the lowest message the plan covers so far.\n let low = loaded - (requests[0] as DeepAgentInterestRequest).before;\n while (low > 0) {\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before,\n at: (chain[low] as DeepAgentInterestChainEntry).id,\n });\n low = low + 1 - before;\n }\n // The plan covers the chain; the new messages extend its lowest request\n // when that stays within one window, else they are a page of their own.\n const last = requests[requests.length - 1] as DeepAgentInterestRequest;\n if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n requests[requests.length - 1] = { ...last, before: last.before + grow };\n } else {\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before: grow + 1,\n at: (chain[0] as DeepAgentInterestChainEntry).id,\n });\n }\n return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;\n}\n\n/**\n * The requests to state for one more page of older history, or `null` when\n * there is nothing to load (no anchor, the beginning reached) or the host's\n * interest cap is spent. One page is appended, anchored at the window's first\n * message, while the cap allows; at the cap the loaded range is coalesced\n * into maximal requests first (see {@link coalescedInterestRequests}).\n */\nexport function pageInterestRequests(\n window: DeepAgentMessageWindow,\n size?: number\n): DeepAgentInterestRequest[] | null {\n const anchor = window.chain[0]?.id;\n if (anchor === undefined || !window.hasOlder) return null;\n const page = pageInterestRequest(anchor, size);\n const appended = [...window.requests, page];\n if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;\n // A page's `before` counts its anchor: it adds `before - 1` older messages.\n return coalescedInterestRequests(window.chain, page.before - 1);\n}\n\n/**\n * Whether every `stated` request is carried by `carried` (the same anchor, at\n * least as wide): a reconnect's hello that carries what the client last\n * stated — the host remembers a client id's interests — needs no restatement.\n */\nexport function interestsCovered(\n carried: readonly DeepAgentInterestRequest[],\n stated: readonly DeepAgentInterestRequest[]\n): boolean {\n return stated.every((request) =>\n carried.some((have) => have.at === request.at && have.before >= request.before)\n );\n}\n\n/**\n * The window off the mounted documents, or `null` while the head interest has\n * not resolved (pre-attach, before the first `set` answer, a wire without\n * documents). A page joins wherever its anchor sits in the chain so far — at\n * the first message it extends the view, inside the head (the head widened\n * past it) it adds nothing and is left out of `requests`; a page whose anchor\n * left the transcript (a rewind emptied it in place) is left out too. A\n * malformed document reads as absent.\n */\nexport function readDeepAgentMessageWindow(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentMessageWindow | null {\n if (mounted === undefined) return null;\n let windows: DeepAgentInterestResolution[] | undefined;\n const documents = new Map<string, LangChainMessage>();\n for (const document of mounted.values()) {\n const key = document.key;\n if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {\n windows = readDeepAgentInterestDocument(document.value)?.windows;\n } else if (\n document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL &&\n key !== null &&\n key.length === 3 &&\n key[1] === DEEP_AGENT_MAIN_NS\n ) {\n documents.set(key[2] as string, document.value as LangChainMessage);\n }\n }\n const head = windows?.[0];\n if (windows === undefined || head === undefined) return null;\n let chain = head.chain;\n let hasOlder = head.more.before;\n const requests = [interestRequest(head)];\n const loaded = new Set(chain.map((entry) => entry.id));\n let pages = 0;\n for (const page of windows.slice(1)) {\n if (page.at === undefined || !loaded.has(page.at)) continue;\n const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);\n if (anchorAt < 0) continue;\n // Both windows are ranges of one linear transcript sharing the anchor:\n // what the page holds below it and the chain does not is a prefix.\n const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));\n if (fresh.length === 0) {\n // Nothing new, but a page that starts where the loaded chain starts\n // has looked below it: its `more.before` is the answer for the edge.\n if (page.chain[0]?.id === chain[0]?.id) hasOlder = page.more.before;\n continue;\n }\n chain = [...fresh, ...chain];\n for (const entry of fresh) loaded.add(entry.id);\n hasOlder = page.more.before;\n requests.push(interestRequest(page));\n pages += 1;\n }\n const messages: LangChainMessage[] = [];\n for (const entry of chain) {\n const message = documents.get(entry.id);\n if (message !== undefined) messages.push(message);\n }\n return { requests, chain, messages, hasOlder, pages };\n}\n\n/**\n * The windowed wire's read command on the statewire command union, so\n * `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the\n * deep-agent host is driven (`DeepAgentThread.history_tool_output`, an\n * attach-ACL read).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n /** One stored message whole — the per-client shape, by command. */\n historyMessage: HistoryMessageCommand;\n }\n }\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/**\n * The `history/message` command: a message as the host stores it — the\n * model-provenance blobs the wire strips and an untruncated tool output\n * included. Every client receives one projected wire form; this is the one\n * per-client shape, fetched on demand like `history/tool_output`.\n */\nexport interface HistoryMessageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_MESSAGE_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildHistoryMessageCommand({\n messageId,\n}: {\n messageId: string;\n}): HistoryMessageCommand {\n return { type: DEEP_AGENT_HISTORY_MESSAGE_COMMAND, messageId };\n}\n\nexport interface HistoryMessageResult {\n messageId: string;\n message: LangChainMessage;\n}\n\nexport function readHistoryMessageResult(payload: unknown): HistoryMessageResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, message } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n if (typeof message !== 'object' || message === null) return null;\n return { messageId, message: message as LangChainMessage };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","DEEP_AGENT_MIN_MESSAGE_WINDOW","DEEP_AGENT_MAX_MESSAGE_WINDOW","DEEP_AGENT_MAIN_NS","DEEP_AGENT_MESSAGE_WINDOW_HEADER","DEEP_AGENT_MAX_INTERESTS","DEEP_AGENT_INTEREST_PROTOCOL","DEEP_AGENT_STATEWIRE_PROTOCOL","DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND","DEEP_AGENT_TRUNCATED_CONTENT_KEY"],"mappings":";;;;AAiD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AGENT_DEFAULT_MESSAGE_WINDOW, DEEP_AGENT_MIN_MESSAGE_WINDOW, DEEP_AGENT_MESSAGE_WINDOW_HEADER, DEEP_AGENT_TRUNCATED_CONTENT_KEY } from "./generated/runconfig-contract.js";
|
|
2
|
+
import { DEEP_AGENT_STATEWIRE_PROTOCOL } from "./statewire-transport.js";
|
|
2
3
|
const isIndex = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
function clampMessageWindowSize(size) {
|
|
5
|
+
if (size === void 0 || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;
|
|
6
|
+
return Math.max(
|
|
7
|
+
DEEP_AGENT_MIN_MESSAGE_WINDOW,
|
|
8
|
+
Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function headInterestRequest(size) {
|
|
12
|
+
return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };
|
|
13
|
+
}
|
|
14
|
+
function pageInterestRequest(at, size) {
|
|
15
|
+
return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };
|
|
13
16
|
}
|
|
14
|
-
const clampWindowSize = (size) => Math.max(
|
|
15
|
-
DEEP_AGENT_MIN_MESSAGE_WINDOW,
|
|
16
|
-
Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))
|
|
17
|
-
);
|
|
18
17
|
function withDeclaredMessageWindow(headers, declaration = {}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
if (declaration.provenance === "full" && !(DEEP_AGENT_PROVENANCE_HEADER in declared)) {
|
|
27
|
-
declared[DEEP_AGENT_PROVENANCE_HEADER] = DEEP_AGENT_PROVENANCE_FULL;
|
|
28
|
-
}
|
|
29
|
-
return declared;
|
|
18
|
+
if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;
|
|
19
|
+
return {
|
|
20
|
+
...headers,
|
|
21
|
+
[DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size))
|
|
22
|
+
};
|
|
30
23
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
24
|
+
function readDeepAgentInterestResolution(value) {
|
|
25
|
+
if (typeof value !== "object" || value === null) return null;
|
|
26
|
+
const { ns, before, at, after, chain, more } = value;
|
|
27
|
+
if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;
|
|
28
|
+
if (at !== void 0 && typeof at !== "string") return null;
|
|
29
|
+
if (after !== void 0 && !isIndex(after)) return null;
|
|
30
|
+
if (typeof more !== "object" || more === null) return null;
|
|
31
|
+
const { before: moreBefore, after: moreAfter } = more;
|
|
32
|
+
if (typeof moreBefore !== "boolean" || typeof moreAfter !== "boolean") return null;
|
|
33
|
+
const entries = [];
|
|
34
|
+
for (const entry of chain) {
|
|
35
|
+
const { id, siblings } = entry ?? {};
|
|
36
|
+
if (typeof id !== "string") return null;
|
|
37
|
+
entries.push({
|
|
38
|
+
id,
|
|
39
|
+
siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === "string") : [id]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
37
42
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
ns: DEEP_AGENT_MAIN_NS,
|
|
44
|
+
before,
|
|
45
|
+
...at !== void 0 && { at },
|
|
46
|
+
...after !== void 0 && { after },
|
|
47
|
+
chain: entries,
|
|
48
|
+
more: { before: moreBefore, after: moreAfter }
|
|
41
49
|
};
|
|
42
50
|
}
|
|
43
|
-
function
|
|
44
|
-
if (typeof
|
|
45
|
-
const {
|
|
46
|
-
if (!
|
|
47
|
-
|
|
51
|
+
function readDeepAgentInterestDocument(value) {
|
|
52
|
+
if (typeof value !== "object" || value === null) return null;
|
|
53
|
+
const { windows } = value;
|
|
54
|
+
if (!Array.isArray(windows)) return null;
|
|
55
|
+
const resolutions = [];
|
|
56
|
+
for (const window of windows) {
|
|
57
|
+
const resolution = readDeepAgentInterestResolution(window);
|
|
58
|
+
if (resolution === null) return null;
|
|
59
|
+
resolutions.push(resolution);
|
|
60
|
+
}
|
|
61
|
+
return { windows: resolutions };
|
|
62
|
+
}
|
|
63
|
+
const interestRequest = ({ ns, before, at, after }) => ({
|
|
64
|
+
ns,
|
|
65
|
+
before,
|
|
66
|
+
...at !== void 0 && { at },
|
|
67
|
+
...after !== void 0 && { after }
|
|
68
|
+
});
|
|
69
|
+
function coalescedInterestRequests(chain, grow) {
|
|
70
|
+
const loaded = chain.length;
|
|
71
|
+
const requests = [
|
|
72
|
+
{ ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) }
|
|
73
|
+
];
|
|
74
|
+
let low = loaded - requests[0].before;
|
|
75
|
+
while (low > 0) {
|
|
76
|
+
const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);
|
|
77
|
+
requests.push({
|
|
78
|
+
ns: DEEP_AGENT_MAIN_NS,
|
|
79
|
+
before,
|
|
80
|
+
at: chain[low].id
|
|
81
|
+
});
|
|
82
|
+
low = low + 1 - before;
|
|
83
|
+
}
|
|
84
|
+
const last = requests[requests.length - 1];
|
|
85
|
+
if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {
|
|
86
|
+
requests[requests.length - 1] = { ...last, before: last.before + grow };
|
|
87
|
+
} else {
|
|
88
|
+
requests.push({
|
|
89
|
+
ns: DEEP_AGENT_MAIN_NS,
|
|
90
|
+
before: grow + 1,
|
|
91
|
+
at: chain[0].id
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;
|
|
95
|
+
}
|
|
96
|
+
function pageInterestRequests(window, size) {
|
|
97
|
+
var _a;
|
|
98
|
+
const anchor = (_a = window.chain[0]) == null ? void 0 : _a.id;
|
|
99
|
+
if (anchor === void 0 || !window.hasOlder) return null;
|
|
100
|
+
const page = pageInterestRequest(anchor, size);
|
|
101
|
+
const appended = [...window.requests, page];
|
|
102
|
+
if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;
|
|
103
|
+
return coalescedInterestRequests(window.chain, page.before - 1);
|
|
104
|
+
}
|
|
105
|
+
function interestsCovered(carried, stated) {
|
|
106
|
+
return stated.every(
|
|
107
|
+
(request) => carried.some((have) => have.at === request.at && have.before >= request.before)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function readDeepAgentMessageWindow(mounted) {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
if (mounted === void 0) return null;
|
|
113
|
+
let windows;
|
|
114
|
+
const documents = /* @__PURE__ */ new Map();
|
|
115
|
+
for (const document of mounted.values()) {
|
|
116
|
+
const key = document.key;
|
|
117
|
+
if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {
|
|
118
|
+
windows = (_a = readDeepAgentInterestDocument(document.value)) == null ? void 0 : _a.windows;
|
|
119
|
+
} else if (document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL && key !== null && key.length === 3 && key[1] === DEEP_AGENT_MAIN_NS) {
|
|
120
|
+
documents.set(key[2], document.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const head = windows == null ? void 0 : windows[0];
|
|
124
|
+
if (windows === void 0 || head === void 0) return null;
|
|
125
|
+
let chain = head.chain;
|
|
126
|
+
let hasOlder = head.more.before;
|
|
127
|
+
const requests = [interestRequest(head)];
|
|
128
|
+
const loaded = new Set(chain.map((entry) => entry.id));
|
|
129
|
+
let pages = 0;
|
|
130
|
+
for (const page of windows.slice(1)) {
|
|
131
|
+
if (page.at === void 0 || !loaded.has(page.at)) continue;
|
|
132
|
+
const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);
|
|
133
|
+
if (anchorAt < 0) continue;
|
|
134
|
+
const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));
|
|
135
|
+
if (fresh.length === 0) {
|
|
136
|
+
if (((_b = page.chain[0]) == null ? void 0 : _b.id) === ((_c = chain[0]) == null ? void 0 : _c.id)) hasOlder = page.more.before;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
chain = [...fresh, ...chain];
|
|
140
|
+
for (const entry of fresh) loaded.add(entry.id);
|
|
141
|
+
hasOlder = page.more.before;
|
|
142
|
+
requests.push(interestRequest(page));
|
|
143
|
+
pages += 1;
|
|
144
|
+
}
|
|
145
|
+
const messages = [];
|
|
146
|
+
for (const entry of chain) {
|
|
147
|
+
const message = documents.get(entry.id);
|
|
148
|
+
if (message !== void 0) messages.push(message);
|
|
149
|
+
}
|
|
150
|
+
return { requests, chain, messages, hasOlder, pages };
|
|
48
151
|
}
|
|
49
152
|
function buildToolOutputCommand({ messageId }) {
|
|
50
153
|
return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };
|
|
@@ -73,10 +176,15 @@ function readTruncatedToolOutputArtifact(artifact) {
|
|
|
73
176
|
}
|
|
74
177
|
export {
|
|
75
178
|
ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY,
|
|
76
|
-
buildHistoryLoadCommand,
|
|
77
179
|
buildToolOutputCommand,
|
|
78
|
-
|
|
79
|
-
|
|
180
|
+
clampMessageWindowSize,
|
|
181
|
+
headInterestRequest,
|
|
182
|
+
interestsCovered,
|
|
183
|
+
pageInterestRequest,
|
|
184
|
+
pageInterestRequests,
|
|
185
|
+
readDeepAgentInterestDocument,
|
|
186
|
+
readDeepAgentInterestResolution,
|
|
187
|
+
readDeepAgentMessageWindow,
|
|
80
188
|
readToolOutputResult,
|
|
81
189
|
readTruncatedToolContent,
|
|
82
190
|
readTruncatedToolOutputArtifact,
|