@athenaintel/react 0.20.0 → 0.21.0
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 +74 -0
- package/dist/assets/use-asset-embed.cjs +8 -0
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.js +8 -0
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +22 -4
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +14 -0
- package/dist/chat/StatewireApprovalCard.js +23 -5
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -1
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireClientToolBridge.js +2 -1
- package/dist/chat/StatewireClientToolBridge.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +2 -1
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.js +2 -1
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/athena-citation-links.cjs +17 -1
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-citation-links.js +17 -1
- package/dist/chat/athena-citation-links.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/SuperGroupingCard.cjs +69 -187
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +10 -6
- package/dist/chat/super-grouping/SuperGroupingCard.js +73 -191
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.cjs +131 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.d.ts +16 -0
- package/dist/chat/super-grouping/ToolTimeline.js +131 -0
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -0
- package/dist/chat/super-grouping/activity-timeline.cjs +14 -8
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +3 -0
- package/dist/chat/super-grouping/activity-timeline.js +14 -8
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +65 -0
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -0
- package/dist/chat/super-grouping/timeline-step.d.ts +17 -0
- package/dist/chat/super-grouping/timeline-step.js +65 -0
- package/dist/chat/super-grouping/timeline-step.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +8 -8
- package/dist/chat/tiptap-text.cjs.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 +7 -2
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +12 -2
- package/dist/chat/use-statewire-approval-request.js +8 -3
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +24 -65
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.js +24 -65
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +2 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.js +2 -1
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +49 -4
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.d.ts +11 -0
- package/dist/chat-ui/mentions/mention-chip.js +50 -5
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +18 -6
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.d.ts +2 -0
- package/dist/chat-ui/mentions/mention-extension.js +18 -6
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs +9 -6
- package/dist/chat-ui/mentions/suggestions/components/menu-item.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-item.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js +10 -7
- package/dist/chat-ui/mentions/suggestions/components/menu-item.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js +2 -2
- package/dist/chat-ui/mentions/suggestions/components/menu-list.js.map +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 -2
- 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/messages/message-components.cjs +6 -29
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +1 -13
- package/dist/chat-ui/messages/message-components.js +8 -31
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +3 -2
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
- package/dist/chat-ui/messages/runtime-message.js +3 -2
- package/dist/chat-ui/messages/runtime-message.js.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +23 -8
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.d.ts +14 -4
- package/dist/chat-ui/messages/statewire-continue-run.js +23 -8
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +2 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +2 -1
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-message-body.js +76 -0
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-node-views.d.ts +13 -0
- package/dist/chat-ui/rich-text/chat-node-views.js +51 -0
- package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -0
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +7 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +70 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.cjs.map +1 -0
- package/dist/chat-ui/rich-text/dom-output-spec.d.ts +11 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js +83 -0
- package/dist/chat-ui/rich-text/dom-output-spec.js.map +1 -0
- package/dist/chat-ui/statewire.cjs +2 -1
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.js +2 -1
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -1
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs +32 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs.map +1 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js +31 -0
- package/dist/node_modules/qrcode-generator/dist/qrcode.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +44 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +43 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +29 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +29 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +871 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.cjs +570 -0
- package/dist/node_modules/zod/v4/core/api.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +570 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +411 -0
- package/dist/node_modules/zod/v4/core/checks.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +411 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.cjs +77 -0
- package/dist/node_modules/zod/v4/core/core.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +77 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +38 -0
- package/dist/node_modules/zod/v4/core/doc.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +76 -0
- package/dist/node_modules/zod/v4/core/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +76 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +312 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +96 -0
- package/dist/node_modules/zod/v4/core/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +96 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +86 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +86 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
- package/dist/node_modules/zod/v4/core/registries.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +1412 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1413 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +370 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.cjs +444 -0
- package/dist/node_modules/zod/v4/core/util.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +444 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +9 -0
- package/dist/node_modules/zod/v4/core/versions.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +9 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs +7 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js +7 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs +4 -0
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/conversation-list.js +4 -0
- package/dist/packages/agent-runtime/src/conversation-list.js.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +2 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +2 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs +31 -7
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.js +31 -7
- package/dist/packages/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/packages/agent-runtime/src/messages.cjs +35 -5
- package/dist/packages/agent-runtime/src/messages.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/messages.js +35 -5
- package/dist/packages/agent-runtime/src/messages.js.map +1 -1
- package/dist/packages/agent-runtime/src/protocol.cjs +4 -6
- package/dist/packages/agent-runtime/src/protocol.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/protocol.js +4 -6
- package/dist/packages/agent-runtime/src/protocol.js.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +296 -14
- 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 +293 -11
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/packages/agent-runtime/src/screen-point.cjs +68 -0
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/screen-point.js +68 -0
- package/dist/packages/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +6 -1
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js +6 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +1 -1
- package/dist/packages/agent-runtime/src/thread-handoff.cjs +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js +85 -0
- package/dist/packages/agent-runtime/src/thread-handoff.js.map +1 -0
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js +1 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs +0 -8
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js +0 -8
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +14 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs +21 -5
- 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 +21 -5
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs +13 -3
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js +14 -4
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs +35 -15
- 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 +35 -15
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/voice-presentation.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/AthenaProvider.cjs +2 -1
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.js +2 -1
- 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 +2 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +2 -1
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +4 -0
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.js +4 -0
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/statewire-thread-list.cjs +2 -1
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +2 -1
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-rest-conversation-history.cjs +2 -1
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.js +2 -1
- package/dist/threads/use-rest-conversation-history.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +2 -1
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +1 -0
- package/dist/threads/use-statewire-conversation-history.js +2 -1
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/tools/index.cjs +2 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +2 -1
- 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 +2 -1
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/primitives.js +2 -1
- package/dist/tools/primitives.js.map +1 -1
- package/dist/tools/tool-fallback.cjs +2 -1
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.js +2 -1
- package/dist/tools/tool-fallback.js.map +1 -1
- 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/dist/voice/index.cjs +6 -0
- package/dist/voice/index.cjs.map +1 -0
- package/dist/voice/index.d.ts +2 -0
- package/dist/voice/index.js +6 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/use-athena-voice-session.cjs +315 -0
- package/dist/voice/use-athena-voice-session.cjs.map +1 -0
- package/dist/voice/use-athena-voice-session.d.ts +145 -0
- package/dist/voice/use-athena-voice-session.js +315 -0
- package/dist/voice/use-athena-voice-session.js.map +1 -0
- package/package.json +17 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-deep-agent-thread.js","sources":["../../../../../agent-runtime/src/use-deep-agent-thread.ts"],"sourcesContent":["import { StatewireThread } from '@assistant-ui/react-statewire';\nimport { withKey } from '@assistant-ui/tap';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n type AuthDenialTrackerState,\n initialAuthDenialTrackerState,\n observeAuthDenial,\n} from './auth-denial';\nimport {\n createDeepAgentAttachTransport,\n type DeepAgentHeadersResolver,\n} from './deep-agent-transport-recipe';\nimport { projectDeepAgentConnection } from './errors';\nimport { type DeepAgentMessageAuthor, isSameMessageAuthor } from './message-author';\nimport type { DeepAgentMessageWindowDeclaration } from './message-window';\nimport { convertDeepAgentState, createDeepAgentMaterialize } from './messages';\nimport { type DeepAgentProtocolStatus, projectDeepAgentProtocol } from './protocol';\nimport type { DeepAgentAttachTimingEvent } from './statewire-attach-observer';\nimport type { StatewireDiagnosticsRecorder } from './statewire-diagnostics';\nimport { isDeepAgentStateHydrated, readDeepAgentStreamValues } from './statewire-state';\nimport { StatewireSuspended } from './statewire-suspended';\nimport type { StatewireTransportOptions } from './statewire-transport';\nimport type { DeepAgentThreadPrewarmPool } from './thread-prewarm';\nimport { type DeepAgentThreadSnapshotCache, toThreadSnapshotSeed } from './thread-snapshot-cache';\nimport type { DeepAgentToolOutputStore } from './tool-outputs';\nimport type {\n DeepAgentConnectionState,\n DeepAgentLaneProjection,\n DeepAgentStreamValues,\n} from './types';\n\ntype ThreadOptions = StatewireThread.Options<DeepAgentStreamValues>;\n\nexport type { DeepAgentHeadersResolver } from './deep-agent-transport-recipe';\n\n/**\n * How an attach's FIRST frame is sourced, decided once per attach at mount: the\n * hello a pooled pre-dialed attach already replicated (`prewarm`), a remembered\n * snapshot seed (`snapshot`), or nothing (`none` — the thread loads until its\n * hello).\n */\nexport type DeepAgentAttachSource = 'prewarm' | 'snapshot' | 'none';\n\nexport interface UseDeepAgentThreadOptions {\n threadId: string;\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n /** Transport selection: SSE when true, WebSocket otherwise. */\n sse?: boolean;\n /**\n * Auth headers for the transport. Statewire passes `{ staleAuth: true }`\n * when the previous credential was refused, so resolvers that can\n * force-renew should honor it.\n */\n headers: DeepAgentHeadersResolver;\n /**\n * Statewire session store for reconnect command-session recovery (e.g. the\n * mobile AsyncStorage-backed store). Host-resolved; omitted, sessions are\n * process-local.\n */\n sessionStore?: StatewireTransportOptions['sessionStore'];\n /**\n * Mounted storage seams for the thread: `session` holds the lane identity and\n * the commands still awaiting a durable verdict, so a reload resumes the lane\n * instead of minting a new client (browser hosts pass `LocalStorageSession`\n * from `@assistant-ui/react-statewire/local-storage`); `composer` persists the\n * draft. Mutually exclusive with `sessionStore` — statewire refuses a session\n * mounted twice.\n */\n storage?: ThreadOptions['storage'];\n /** True only for a never-started local chat; existing empty threads still load until their snapshot. */\n isNewChat?: boolean;\n /**\n * Extra transport-key discriminator for the SAME thread. The session is keyed\n * by `threadId` alone by default; hosts that must re-read the server snapshot\n * without a thread switch (a run dispatched outside this client, e.g. a\n * backgrounded AOP run writing the thread's first messages) bump this to\n * remount the session against the same URL.\n */\n attachKey?: string | number;\n /**\n * Host gate: park the transport instead of attaching — no socket, no retry\n * loop. The thread element stays mounted so assistant-ui consumers keep\n * rendering. Pass it when the host already knows every attach would be denied (e.g.\n * the signed-in user has no workspace yet), so a locked-out tab does not\n * hammer the attach endpoint on every backoff interval.\n */\n suspended?: { reason: string } | false;\n /**\n * Adapter capabilities the host UI exposes. Defaults preserve each client's\n * pre-extraction surface — pass what the product mounts.\n */\n capabilities?: {\n edit?: boolean;\n continue?: boolean;\n reload?: boolean;\n unstable_switchBranch?: boolean;\n };\n /** Which run lanes project into the message tail; see {@link DeepAgentLaneProjection}. */\n laneProjection?: DeepAgentLaneProjection;\n /**\n * The viewer, as the backend would stamp them (`metadata.custom.author`).\n * Stamped onto this client's own optimistic bubbles — a send still in flight\n * has no host `meta` yet — so a just-sent turn is attributed, and the\n * multi-author avatar gate flips for a second poster, without waiting for\n * the acknowledgment. Replicated entries carry the host's own stamp instead.\n * Compared field-wise, so callers need not memoize the object.\n */\n selfAuthor?: DeepAgentMessageAuthor | null;\n /** Host-owned adapters: attachments (upload/mention choreography), speech, feedback. */\n adapters?: ThreadOptions['adapters'];\n /**\n * Transport lifecycle recorder (attach latency, reconnect loops, command\n * settle fates, stale-auth renewals) fed from the hook's own seams. Pass one\n * only when the host's diagnostics channel is enabled — the recorder is\n * observed on hot paths, and an absent recorder costs a single optional call.\n */\n diagnostics?: StatewireDiagnosticsRecorder;\n /**\n * Per-tab LRU of the last wire state seen per thread. When set, every\n * hydrated state the transport publishes is remembered, and a mount of a\n * remembered thread seeds `initialState` from the cache (through\n * {@link toThreadSnapshotSeed}) — the thread renders its last-known\n * messages on the first frame instead of holding a loading treatment for\n * the attach round-trip, and projects \"running\" when the run was live at\n * capture (else \"ready\"). The attach snapshot then\n * REPLACES the seeded state (statewire's `initialState` contract), so a\n * thread that advanced elsewhere reconciles in one round-trip. New chats\n * keep their preload and never read the cache.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /**\n * Declare a message window on the attach (`x-athena-deep-agent-window`):\n * the hello carries the last `size` messages plus the `messagesWindow`\n * lane and the host re-addresses the op stream to that window; older\n * ranges load through `history/load` (see `message-window.ts`). Read once\n * per attach. `false` / omitted keeps the full snapshot — the surfaces\n * that have not adopted the window are untouched.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | false;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages\n * (`history/tool_output`); the thread re-converts when one lands. Only\n * meaningful together with `messageWindow`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /**\n * Pre-dialed attaches (see `thread-prewarm.ts`). When the pool holds a root\n * for this thread at mount, the thread takes the hello it replicated as its\n * seed — the transcript is the first frame — and dials its own attach\n * against the instance the pool warmed; the pooled root is disposed in the\n * same step, so one socket is live per thread after mount. Never seeded for\n * a preloaded new chat or a suspended attach; such a root is discarded.\n */\n prewarmPool?: DeepAgentThreadPrewarmPool<DeepAgentStreamValues>;\n /**\n * Attach-path timing: socket open, hello size + handler cost, server retry\n * hints — attributed to the attach's own thread, since a late event from the\n * thread being left can land after the host has moved on.\n */\n onAttachTiming?: (info: { threadId: string; event: DeepAgentAttachTimingEvent }) => void;\n /** Where this attach's first frame comes from; once per attach, at mount. */\n onAttachSource?: (info: { threadId: string; source: DeepAgentAttachSource }) => void;\n /** Full transport error policy (paywall, toast, telemetry) — client-owned. */\n onError?: ThreadOptions['onError'];\n /**\n * Raw statewire state observer (first-attach latches, telemetry). The state\n * argument is never `undefined`/`null`: passes where the wire has no\n * snapshot yet (pre-attach, replay boundaries) deliver the typed\n * `DEEP_AGENT_PRE_STREAM_STATE` default — `isDeepAgentStateHydrated`\n * distinguishes them from a real (possibly empty) snapshot.\n */\n onStateChange?: ThreadOptions['onStateChange'];\n /** Raw command-lifecycle observer (send-failure salvage, telemetry). */\n onCommandChange?: ThreadOptions['onCommandChange'];\n /** Raw connection observer (reconnect handles, telemetry). */\n onRawConnectionChange?: ThreadOptions['onConnectionChange'];\n /**\n * Projected connection status changes, deduped per thread, with `null` on\n * unmount so an indicator never shows a stale status.\n */\n onConnectionChange?: (connection: DeepAgentConnectionState | null) => void;\n /** Notified when a run starts/stops so the page can reflect the running thread. */\n onRunningChange?: (isRunning: boolean) => void;\n /**\n * Notified once per thread with the `runConfig` carried by the statewire\n * snapshot (the backend's persisted panel config, seeded in `_load_history`),\n * so the host can hydrate its config store from the thread. Notified with\n * `null` (at most once per attach) when a server snapshot arrives WITHOUT a\n * persisted config, so a host waiting on hydration can stop waiting; a\n * config appearing on a later snapshot of the same attach (mirrored at run\n * start) still delivers the config notification.\n */\n onServerRunConfig?: (config: Record<string, unknown> | null) => void;\n /**\n * Notified when the snapshot's `legacyRunActive` flag changes: the host set\n * it while a run executing OUTSIDE this surface (an AOP / HTTP-route run)\n * is actively writing the thread's bare-namespace history, which the host\n * live-refreshes onto the wire. Lets the page show run-in-progress\n * treatment instead of an empty conversation, and stand down its own\n * re-attach polling. Change-notified per attach (an initial `false` before\n * the snapshot stays silent), mirroring `onRunningChange`.\n */\n onLegacyRunActive?: (legacyRunActive: boolean) => void;\n /**\n * Notified with the state's session-asset lifecycle flag\n * ({@link readSessionPersisted}) PAIRED with the thread it describes: `false`\n * while the thread's `session` asset provably does not exist yet (a\n * never-started chat's preload, a first run before the mint), `true` once\n * minted, `null` when the state carries no flag (a host that predates it).\n *\n * Fired from the converter pass, so the pair is read from the state of the\n * thread this attach was mounted for. A component reading the flag off the\n * client store instead lags the mounted thread id by one render on a switch\n * and can pair the new id with the previous thread's flag — releasing a\n * session-scoped read for a row the backend has not minted. Change-notified\n * per attach; the first pass of every attach notifies, so a host holding a\n * read back until it hears from the mounted thread always does.\n */\n onSessionPersistedChange?: (event: {\n threadId: string;\n sessionPersisted: boolean | null;\n }) => void;\n /**\n * Notified with the wire-contract negotiation status once the attach\n * snapshot advertises the `protocol` lane, and again whenever it changes\n * (a re-attach after a server roll can raise `minClientVersion`\n * mid-session). `serverRequiresUpgrade` is the render signal: the server\n * will refuse this build's commands with `client_version_unsupported`, so\n * the host should show an \"update required\" affordance. Never called for\n * pre-negotiation servers (their snapshots carry no lane) — absence of a\n * call means \"no known constraint\", not \"compatible\".\n */\n onProtocolChange?: (status: DeepAgentProtocolStatus) => void;\n}\n\n/** One thread's replicated running state, keyed so a switch between two\n * threads with the same status still re-notifies (the host page clears its\n * per-thread state on selection, mirroring the connection dedupe below). */\nexport interface RunningSnapshot {\n threadId: string;\n isRunning: boolean;\n}\n\n/** Whether the thread's `session` asset exists, read off a statewire state, or\n * `null` when the state does not carry the flag.\n *\n * Absence is not absence of the asset: a snapshot from a host that predates\n * the flag has no such key, and reading that as \"the asset does not exist\"\n * would gate a read the client is entitled to make, with nothing left to\n * un-gate it. A new thread's preload seeds `false` (see `initialState`), so\n * the pre-attach pass of a chat that cannot have an asset yet still gates.\n *\n * Hosts pass this to `useStatewireState` so the flag and the thread it belongs\n * to are read in one component — a thread switch then cannot pair one thread's\n * id with the other's flag. */\nexport function readSessionPersisted(state: unknown): boolean | null {\n const flag = (state as { sessionPersisted?: unknown } | null)?.sessionPersisted;\n return typeof flag === 'boolean' ? flag : null;\n}\n\n/** Whether a converter pass must notify `onRunningChange`.\n *\n * The mount's very first status notifies only when it is `true` (a snapshot\n * carrying a live run) — an initial `false` before the snapshot must stay\n * silent so it cannot clear a still-valid indicator. After that, every\n * transition notifies, and so does the first status after a thread switch\n * (the host page clears its per-thread state on selection, so a switch\n * between two threads with the same status must still re-notify). */\nexport function shouldNotifyRunningChange(\n previous: RunningSnapshot | null,\n next: RunningSnapshot\n): boolean {\n if (previous === null) return next.isRunning;\n return previous.threadId !== next.threadId || previous.isRunning !== next.isRunning;\n}\n\n/**\n * The shared deep-agent Statewire thread.\n *\n * `StatewireThread` (from `@assistant-ui/react-statewire`) attaches to the\n * agora-hosted thread at `${baseUrl}/${threadId}` (WebSocket by default,\n * with SSE retained only as a host-selected compatibility switch): the backend\n * hosts the thread state and this client\n * replicates it live, so the server snapshot is the single source of history\n * (no local import, no `/status` resume probing) and run scheduling — queueing,\n * steering, stop, edit rewinds — rides the built-in `run/*` commands.\n *\n * The thread element is keyed by `threadId`, so a thread switch remounts the\n * session against the new URL instead of importing history in place.\n *\n * Returns the thread element for the host's own `useAui({ thread })` — web\n * hosts take `useAui` from `@assistant-ui/react`, React Native hosts from\n * `@assistant-ui/react-native`; this package imports neither.\n */\nexport function useDeepAgentThread({\n threadId,\n baseUrl,\n sse = false,\n headers,\n sessionStore,\n storage,\n isNewChat = false,\n attachKey,\n suspended = false,\n capabilities,\n laneProjection = 'both',\n selfAuthor = null,\n adapters,\n diagnostics,\n snapshotCache,\n messageWindow = false,\n toolOutputs,\n prewarmPool,\n onAttachTiming,\n onAttachSource,\n onError,\n onStateChange,\n onCommandChange,\n onRawConnectionChange,\n onConnectionChange,\n onRunningChange,\n onServerRunConfig,\n onLegacyRunActive,\n onSessionPersistedChange,\n onProtocolChange,\n}: UseDeepAgentThreadOptions) {\n const onRunningChangeRef = useRef(onRunningChange);\n onRunningChangeRef.current = onRunningChange;\n const onSessionPersistedChangeRef = useRef(onSessionPersistedChange);\n onSessionPersistedChangeRef.current = onSessionPersistedChange;\n const onConnectionChangeRef = useRef(onConnectionChange);\n onConnectionChangeRef.current = onConnectionChange;\n const onServerRunConfigRef = useRef(onServerRunConfig);\n onServerRunConfigRef.current = onServerRunConfig;\n const onLegacyRunActiveRef = useRef(onLegacyRunActive);\n onLegacyRunActiveRef.current = onLegacyRunActive;\n const onProtocolChangeRef = useRef(onProtocolChange);\n onProtocolChangeRef.current = onProtocolChange;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const onRawConnectionChangeRef = useRef(onRawConnectionChange);\n onRawConnectionChangeRef.current = onRawConnectionChange;\n const headersRef = useRef(headers);\n headersRef.current = headers;\n const messageWindowRef = useRef(messageWindow);\n messageWindowRef.current = messageWindow;\n // A fetched tool output must re-run the converter (the store is read inside\n // it); the version is the memo's signal that the store's contents moved.\n const [toolOutputsVersion, setToolOutputsVersion] = useState(0);\n useEffect(() => {\n if (!toolOutputs) return undefined;\n return toolOutputs.subscribe(() => setToolOutputsVersion((version) => version + 1));\n }, [toolOutputs]);\n const diagnosticsRef = useRef(diagnostics);\n diagnosticsRef.current = diagnostics;\n const onAttachTimingRef = useRef(onAttachTiming);\n onAttachTimingRef.current = onAttachTiming;\n const onAttachSourceRef = useRef(onAttachSource);\n onAttachSourceRef.current = onAttachSource;\n\n const lastRunningRef = useRef<RunningSnapshot | null>(null);\n // Out-of-band run activity (`legacyRunActive`), change-notified with the\n // same semantics as the running flag above.\n const lastLegacyRunActiveRef = useRef<RunningSnapshot | null>(null);\n // The session-asset lifecycle flag last notified, keyed by attach so every\n // attach's first pass notifies (a host holding a read back until it hears\n // from the mounted thread must always hear from it).\n const lastSessionPersistedRef = useRef<{\n attachId: string;\n threadId: string;\n sessionPersisted: boolean | null;\n } | null>(null);\n // The last wire-contract negotiation status notified, keyed by attach so a\n // re-attach re-notifies (the new snapshot may advertise a different\n // minimum). `status: null` = nothing advertised yet on this attach.\n const lastProtocolRef = useRef<{\n attachId: string;\n status: DeepAgentProtocolStatus | null;\n } | null>(null);\n // The thread whose statewire-carried runConfig has been surfaced to the host\n // (once per thread; later snapshots must not clobber edits).\n const appliedStateRunConfigThreadRef = useRef<string | null>(null);\n // The attach that already notified `onServerRunConfig(null)` (snapshot\n // arrived carrying no persisted config) — at most once per attach.\n const absentStateRunConfigAttachRef = useRef<string | null>(null);\n // Live thread id for the callbacks: they are created per render but may\n // settle after a switch, so they compare against the current id.\n const threadIdRef = useRef(threadId);\n threadIdRef.current = threadId;\n // Identity of the current attach. Every per-thread latch keys off this, so a\n // re-attach of the same thread (a bumped `attachKey`) re-notifies the host\n // exactly like a switch would — the host clears its per-thread state on\n // re-attach, so a snapshot that repeats the previous status must not dedupe.\n const attachId: string = attachKey === undefined ? threadId : `${threadId}:${attachKey}`;\n const attachIdRef = useRef(attachId);\n attachIdRef.current = attachId;\n\n // Auth-denial park: the server fins every denied attach `unauthorized` and\n // the reconnect loop would otherwise retry it every 30s forever (prod tabs\n // looped for hours against revoked/workspace-less credentials). After a\n // streak of denials the live transport is swapped for a parked one; a new\n // attach (thread switch, bumped attachKey) or the parked connection's\n // `reconnect()` re-arms it.\n const [authParked, setAuthParked] = useState<{\n attachId: string;\n message: string | undefined;\n } | null>(null);\n const authDenialRef = useRef<{ attachId: string; state: AuthDenialTrackerState }>({\n attachId,\n state: initialAuthDenialTrackerState(),\n });\n useEffect(() => {\n setAuthParked((prev) => (prev !== null && prev.attachId !== attachId ? null : prev));\n }, [attachId]);\n\n // Field-wise stable identity for the viewer stamp, so a host that rebuilds\n // the author object per render does not rebuild the converter (and with it\n // every message) per render. Adjusting state during render is React's\n // sanctioned derived-state pattern: it re-renders once with the new value.\n const [stableSelfAuthor, setStableSelfAuthor] = useState(selfAuthor);\n if (!isSameMessageAuthor(stableSelfAuthor, selfAuthor)) setStableSelfAuthor(selfAuthor);\n\n const converter = useMemo(\n () => (state: unknown, isRunning: boolean) => {\n // Statewire snapshots carry the thread's persisted panel config (the\n // backend seeds `runConfig` in `_load_history` and mirrors it on run\n // start). Surface it once per thread so the host can hydrate its config\n // store.\n const stateRunConfig = (state as { runConfig?: unknown } | null)?.runConfig;\n if (\n stateRunConfig &&\n typeof stateRunConfig === 'object' &&\n !Array.isArray(stateRunConfig) &&\n appliedStateRunConfigThreadRef.current !== attachIdRef.current\n ) {\n appliedStateRunConfigThreadRef.current = attachIdRef.current;\n const notifyRunConfig = onServerRunConfigRef.current;\n if (notifyRunConfig) {\n queueMicrotask(() => notifyRunConfig(stateRunConfig as Record<string, unknown>));\n }\n } else if (\n !stateRunConfig &&\n appliedStateRunConfigThreadRef.current !== attachIdRef.current &&\n absentStateRunConfigAttachRef.current !== attachIdRef.current &&\n projectDeepAgentProtocol(state) !== null\n ) {\n // No persisted config on a SERVER state: the protocol lane rides every\n // attach snapshot, so its presence distinguishes \"the server answered\n // without a config\" from the pre-attach `initialState` (which must not\n // end the host's hydration wait).\n absentStateRunConfigAttachRef.current = attachIdRef.current;\n const notifyRunConfig = onServerRunConfigRef.current;\n if (notifyRunConfig) {\n queueMicrotask(() => notifyRunConfig(null));\n }\n }\n // Out-of-band run activity: the host live-refreshes a bare-namespace\n // (AOP / HTTP-route) thread's transcript while its run is active and\n // flags the wire state so the page can reflect it.\n const stateLegacyRunActive =\n (state as { legacyRunActive?: unknown } | null)?.legacyRunActive === true;\n const legacyRunActiveSnapshot = {\n threadId: attachIdRef.current,\n isRunning: stateLegacyRunActive,\n };\n if (shouldNotifyRunningChange(lastLegacyRunActiveRef.current, legacyRunActiveSnapshot)) {\n lastLegacyRunActiveRef.current = legacyRunActiveSnapshot;\n const observedAttachId = attachIdRef.current;\n queueMicrotask(() => {\n // A re-attach or newer snapshot between the converter pass and this\n // microtask owns the channel now — a stale flag must not leak into\n // the new attach's per-thread state.\n if (\n attachIdRef.current !== observedAttachId ||\n lastLegacyRunActiveRef.current !== legacyRunActiveSnapshot\n ) {\n return;\n }\n onLegacyRunActiveRef.current?.(stateLegacyRunActive);\n });\n }\n // Wire-contract negotiation: the host advertises the `protocol` lane in\n // every attach snapshot. Notify on first advertisement and on change\n // (dedupe by value, re-keyed per attach), with the same stale-guard\n // microtask as the other observers.\n const protocolStatus = projectDeepAgentProtocol(state);\n if (protocolStatus !== null) {\n const previous =\n lastProtocolRef.current?.attachId === attachIdRef.current\n ? lastProtocolRef.current.status\n : null;\n if (\n previous === null ||\n previous.protocolVersion !== protocolStatus.protocolVersion ||\n previous.minClientVersion !== protocolStatus.minClientVersion\n ) {\n const update = { attachId: attachIdRef.current, status: protocolStatus };\n lastProtocolRef.current = update;\n queueMicrotask(() => {\n if (lastProtocolRef.current !== update || attachIdRef.current !== update.attachId) {\n return;\n }\n onProtocolChangeRef.current?.(protocolStatus);\n });\n }\n }\n const runningSnapshot = { threadId: attachIdRef.current, isRunning };\n if (shouldNotifyRunningChange(lastRunningRef.current, runningSnapshot)) {\n lastRunningRef.current = runningSnapshot;\n const notify = onRunningChangeRef.current;\n if (notify) queueMicrotask(() => notify(isRunning));\n }\n return convertDeepAgentState(state, {\n laneProjection,\n selfAuthor: stableSelfAuthor,\n toolOutputs,\n });\n },\n // biome-ignore lint/correctness/useExhaustiveDependencies: toolOutputsVersion is the store's change signal — the converter reads the store's contents, not the counter.\n [laneProjection, stableSelfAuthor, toolOutputs, toolOutputsVersion]\n );\n const materialize = useMemo(\n () => createDeepAgentMaterialize({ selfAuthor: stableSelfAuthor }),\n [stableSelfAuthor]\n );\n\n // Surface the statewire connection status through `onConnectionChange` (the\n // converter re-runs on connection changes), and clear it when the runtime\n // unmounts so an indicator never shows a stale status. Dedup is keyed by\n // thread: the runtime stays mounted across idle thread switches, so the new\n // thread's first status must notify even when it equals the previous\n // thread's last one.\n const lastConnectionRef = useRef<{\n threadId: string;\n connection: DeepAgentConnectionState;\n } | null>(null);\n useEffect(\n () => () => {\n lastConnectionRef.current = null;\n onConnectionChangeRef.current?.(null);\n },\n []\n );\n\n // The preload decision pins at thread entry: `isNewChat` flips once the\n // thread persists, but the mount that began as a new thread stays preloaded.\n const preloadRef = useRef({ threadId, preload: isNewChat });\n if (preloadRef.current.threadId !== threadId)\n preloadRef.current = { threadId, preload: isNewChat };\n\n const snapshotCacheRef = useRef(snapshotCache);\n snapshotCacheRef.current = snapshotCache;\n // The snapshot seed pins at attach identity, like the preload decision: the\n // cache is read once per mount, so a mid-session cache write (this thread's\n // own states being remembered) never changes what `initialState` was.\n //\n // A suspended attach never seeds: the suspended transport never dials, so a\n // seed would be served indefinitely — under a view-as lens that would paint\n // thread content the parked transport exists to withhold (the lens must\n // show what the LENSED identity is authorized to see, and only the server\n // can decide that).\n //\n // The pooled hello is taken the same way: exactly once, at the attach's\n // first render (the pool disposes its root in that step).\n const snapshotSeedRef = useRef<{\n attachId: string;\n seed: DeepAgentStreamValues | undefined;\n } | null>(null);\n if (snapshotSeedRef.current === null || snapshotSeedRef.current.attachId !== attachId) {\n const preload = preloadRef.current.preload;\n let pooledState: DeepAgentStreamValues | undefined;\n if (prewarmPool?.has(threadId)) {\n if (preload || suspended) {\n // This mount attaches on its own terms (or not at all): the pooled\n // dial must not linger as a second socket to the same session.\n prewarmPool.discard(threadId);\n } else {\n pooledState = prewarmPool.take(threadId)?.state;\n }\n }\n // The pooled hello outranks a remembered snapshot (it is newer by\n // construction); a pooled dial that had not landed seeds like a plain\n // attach and reconciles when this attach's own hello lands.\n const remembered =\n preload || suspended ? undefined : (pooledState ?? snapshotCache?.take(threadId));\n const seed = remembered ? toThreadSnapshotSeed(remembered) : undefined;\n snapshotSeedRef.current = { attachId, seed };\n const source: DeepAgentAttachSource =\n pooledState !== undefined ? 'prewarm' : seed ? 'snapshot' : 'none';\n const notifySource = onAttachSourceRef.current;\n if (notifySource) queueMicrotask(() => notifySource({ threadId, source }));\n }\n\n // react-statewire memoizes the converted thread on this function's\n // identity, so an inline closure would re-run `convertDeepAgentState` over\n // the whole transcript on every host render. Keyed on the attach identity (a\n // re-attach re-keys its per-thread latches); everything else the body needs\n // is read through the per-render refs above.\n const threadConverter = useCallback<ThreadOptions['converter']>(\n (state, meta) => {\n // Projected once per pass through the single seam; every fold below\n // consumes the projection (the recorder projects the raw connection\n // itself, so any host observer can feed it).\n const connection = projectDeepAgentConnection(meta.connection);\n // Transition-deduped inside the recorder, so this per-pass observation\n // is free while the connection is unchanged.\n diagnosticsRef.current?.observeConnection(meta.connection);\n // Fold this pass's connection into the denial streak (the converter\n // re-runs on every reconnect-attempt bump). Parking is deferred to a\n // microtask like every other notification here.\n if (authDenialRef.current.attachId !== attachIdRef.current) {\n authDenialRef.current = {\n attachId: attachIdRef.current,\n state: initialAuthDenialTrackerState(),\n };\n }\n const denial = observeAuthDenial(authDenialRef.current.state, connection);\n authDenialRef.current.state = denial.state;\n if (denial.park) {\n const parkAttachId = attachIdRef.current;\n const parkMessage = denial.state.message;\n // The server refused authorization for this thread: any remembered\n // snapshot must not warm-paint it on a later mount (permissions may\n // have been revoked since the state was captured).\n snapshotCacheRef.current?.forget(threadId);\n queueMicrotask(() => {\n if (attachIdRef.current !== parkAttachId) return;\n setAuthParked((prev) =>\n prev?.attachId === parkAttachId\n ? prev\n : { attachId: parkAttachId, message: parkMessage }\n );\n });\n }\n const previous = lastConnectionRef.current;\n if (\n previous?.threadId !== attachId ||\n !Object.keys({ ...previous.connection, ...connection }).every(\n (key) => Reflect.get(previous.connection, key) === Reflect.get(connection, key)\n )\n ) {\n const update = { threadId: attachId, connection };\n lastConnectionRef.current = update;\n queueMicrotask(() => {\n // A newer projection, a thread switch, or the unmount cleanup owns\n // the channel now.\n if (lastConnectionRef.current !== update || attachIdRef.current !== attachId) return;\n onConnectionChangeRef.current?.(connection);\n });\n }\n // Session-asset lifecycle, paired with THIS attach's thread by closure:\n // the state converted here is the state of the thread the element was\n // built for, so the pair can never straddle a switch (a client-store\n // read would). Deduped by value per attach. A pass from an attach the\n // host has already replaced never touches the latch — it could otherwise\n // cancel the current attach's still-queued verdict — and the microtask\n // guard drops a pass whose attach is replaced before it settles.\n if (attachIdRef.current === attachId) {\n const sessionPersisted = readSessionPersisted(state);\n const lastSession = lastSessionPersistedRef.current;\n if (\n lastSession?.attachId !== attachId ||\n lastSession.sessionPersisted !== sessionPersisted\n ) {\n const sessionUpdate = { attachId, threadId, sessionPersisted };\n lastSessionPersistedRef.current = sessionUpdate;\n queueMicrotask(() => {\n if (\n lastSessionPersistedRef.current !== sessionUpdate ||\n attachIdRef.current !== attachId\n ) {\n return;\n }\n onSessionPersistedChangeRef.current?.({ threadId, sessionPersisted });\n });\n }\n }\n // The replicated run status IS the running signal: the lib's run-dialect\n // fold flips it to \"running\" on the send, before the app converter runs,\n // so the optimistic window needs no hand-tracked flag.\n return converter(state, state?.runs?.[0]?.status === 'running');\n },\n [attachId, converter, threadId]\n );\n\n return StatewireThread<DeepAgentStreamValues>({\n // New threads preload an empty runs mount and report `deferred` — the\n // composer is interactive before the stream attaches and pre-attach sends\n // render through the optimistic folds. Existing threads omit the runs\n // mount and project \"loading\" until the attach snapshot: the server seeds\n // messages/todos/runConfig in `_load_history`.\n //\n // The preload also seeds `sessionPersisted: false`: a never-started chat\n // provably has no `session` asset until its first run mints one, so the\n // wire carries that from the first render and a host reading the flag off\n // the state needs no separate \"is this a new chat\" knowledge. An existing\n // thread leaves it absent (unknown) so its asset read is never gated.\n initialState:\n snapshotSeedRef.current.seed ??\n ({\n messages: [],\n todos: [],\n ...(preloadRef.current.preload && { runs: [], sessionPersisted: false }),\n } satisfies DeepAgentStreamValues),\n // Keyed by thread: a switch unmounts the previous thread's session and\n // remounts against the new URL, so the converter never sees the previous\n // thread's snapshot (a new thread serves its preload again, an existing\n // one loads until its snapshot). A host-suspended or auth-parked attach\n // swaps in the never-dialing transport instead.\n transport: withKey(\n attachId,\n (() => {\n if (suspended) return StatewireSuspended({ message: suspended.reason });\n if (authParked !== null && authParked.attachId === attachId) {\n return StatewireSuspended({\n message: authParked.message ?? 'Session authorization was refused.',\n onReconnectRequested: () => {\n authDenialRef.current = {\n attachId: attachIdRef.current,\n state: initialAuthDenialTrackerState(),\n };\n setAuthParked(null);\n },\n });\n }\n // The shared recipe (URL, auth + wire-contract headers, session lane,\n // attach instrumentation, retry-hint floor) — the same one the prewarm\n // pool dials with, so the instance a pooled attach warmed is the one\n // this dial reaches. A never-started chat dials nothing until its\n // first send.\n return createDeepAgentAttachTransport<DeepAgentStreamValues>({\n baseUrl,\n threadId,\n sse,\n isNew: preloadRef.current.preload,\n headers: (ctx) => headersRef.current(ctx),\n sessionStore,\n onAuthResolve: (ctx) => diagnosticsRef.current?.observeAuthResolve(ctx),\n onAttachTiming: (event) => onAttachTimingRef.current?.({ threadId, event }),\n // Read once per attach: a declaration change applies to the next\n // attach, never to a reconnect of this one (the view would be\n // re-shaped under the client).\n messageWindow: messageWindowRef.current,\n });\n })()\n ),\n // Survives the transport remounts above: a bumped attachKey re-attaches the\n // same lane, and a persistent session storage carries it across reloads.\n ...(storage && { storage }),\n // The run subsystem (status, lanes, input requests, runId) is mounted on\n // the state root and always replicated by react-statewire >= 0.14 (the\n // former `runs: true` opt-in is gone) — the converter only maps app-owned\n // keys, including the `run/stop` runId stamp the lib projects itself.\n converter: threadConverter,\n // Makes the server's dispatch record concrete in state (after the\n // optimistic folds); the lib's post-converter dispatch merge turns off.\n materialize,\n // Native message editing: an edited turn is resubmitted as a `run/edit`\n // command, and the deep-agent backend rewinds the checkpointed thread to\n // the edited message's parent before appending (route `plan_rewind`).\n capabilities: capabilities ?? { edit: true },\n ...(adapters && { adapters }),\n contextSync: 'command-send',\n // The Stop control is the only `cancelRun()` caller — teardown paths\n // unmount the keyed transport instead — so every `run/stop` is a\n // deliberate user stop.\n stopPayload: () => ({ reason: 'user_stop' }),\n onError: (error) => {\n diagnosticsRef.current?.observeError(error);\n onErrorRef.current?.(error);\n },\n ...((onStateChange || snapshotCache) && {\n // The lib types the observed state `NonNullable`, but the runtime\n // delivers `undefined` where the wire has no snapshot (pre-attach and\n // replay boundaries republish it) — normalize so the type is true and\n // host observers never crash on a field read.\n onStateChange: ((state, ctx) => {\n const values = readDeepAgentStreamValues(state);\n // Remember under the closure's thread id, not a ref: a late delivery\n // from a previous thread's session must file under THAT thread.\n if (isDeepAgentStateHydrated(values)) {\n snapshotCacheRef.current?.remember(threadId, values);\n }\n onStateChangeRef.current?.(values, ctx);\n }) satisfies ThreadOptions['onStateChange'],\n }),\n ...((onCommandChange || diagnostics) && {\n onCommandChange: ((update, ctx) => {\n diagnosticsRef.current?.observeCommand(update);\n onCommandChangeRef.current?.(update, ctx);\n }) satisfies ThreadOptions['onCommandChange'],\n }),\n ...(onRawConnectionChange && {\n onConnectionChange: ((connection) =>\n onRawConnectionChangeRef.current?.(\n connection\n )) satisfies ThreadOptions['onConnectionChange'],\n }),\n });\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;AAgQO,SAAS,qBAAqB,OAAgC;AACnE,QAAM,OAAQ,+BAAiD;AAC/D,SAAO,OAAO,SAAS,YAAY,OAAO;AAC5C;AAUO,SAAS,0BACd,UACA,MACS;AACT,MAAI,aAAa,KAAM,QAAO,KAAK;AACnC,SAAO,SAAS,aAAa,KAAK,YAAY,SAAS,cAAc,KAAK;AAC5E;AAoBO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;;AAC5B,QAAM,qBAAqB,OAAO,eAAe;AACjD,qBAAmB,UAAU;AAC7B,QAAM,8BAA8B,OAAO,wBAAwB;AACnE,8BAA4B,UAAU;AACtC,QAAM,wBAAwB,OAAO,kBAAkB;AACvD,wBAAsB,UAAU;AAChC,QAAM,uBAAuB,OAAO,iBAAiB;AACrD,uBAAqB,UAAU;AAC/B,QAAM,uBAAuB,OAAO,iBAAiB;AACrD,uBAAqB,UAAU;AAC/B,QAAM,sBAAsB,OAAO,gBA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,MAAA,eAAe,YAAf,gBAAAA,IAAwB,aAAa;AACrC,uBAAW,YAAX,oCAAqB;AAAA,IACvB;AAAA,IACA,IAAK,iBAAiB,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,MAKtC,gBAAgB,CAAC,OAAO,QAAQ;;AAC9B,cAAM,SAAS,0BAA0B,KAAK;AAG9C,YAAI,yBAAyB,MAAM,GAAG;AACpC,WAAAA,MAAA,iBAAiB,YAAjB,gBAAAA,IAA0B,SAAS,UAAU;AAAA,QAC/C;AACA,+BAAiB,YAAjB,0CAA2B,QAAQ;AAAA,MACrC;AAAA,IAAA;AAAA,IAEF,IAAK,mBAAmB,gBAAgB;AAAA,MACtC,kBAAkB,CAAC,QAAQ,QAAQ;;AACjC,SAAAA,MAAA,eAAe,YAAf,gBAAAA,IAAwB,eAAe;AACvC,iCAAmB,YAAnB,4CAA6B,QAAQ;AAAA,MACvC;AAAA,IAAA;AAAA,IAEF,GAAI,yBAAyB;AAAA,MAC3B,qBAAqB,CAAC,eAAA;;AACpB,gBAAAA,MAAA,yBAAyB,YAAzB,gBAAAA,IAAA;AAAA;AAAA,UACE;AAAA;AAAA;AAAA,IACF;AAAA,EACJ,CACD;AACH;"}
|
|
1
|
+
{"version":3,"file":"use-deep-agent-thread.js","sources":["../../../../../agent-runtime/src/use-deep-agent-thread.ts"],"sourcesContent":["import { StatewireThread } from '@assistant-ui/react-statewire';\nimport { withKey } from '@assistant-ui/tap';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n type AuthDenialTrackerState,\n initialAuthDenialTrackerState,\n observeAuthDenial,\n} from './auth-denial';\nimport {\n createDeepAgentAttachTransport,\n type DeepAgentHeadersResolver,\n} from './deep-agent-transport-recipe';\nimport { projectDeepAgentConnection } from './errors';\nimport { type DeepAgentMessageAuthor, isSameMessageAuthor } from './message-author';\nimport type { DeepAgentMessageWindowDeclaration } from './message-window';\nimport { convertDeepAgentState, createDeepAgentMaterialize } from './messages';\nimport { type DeepAgentProtocolStatus, projectDeepAgentProtocol } from './protocol';\nimport type { DeepAgentAttachTimingEvent } from './statewire-attach-observer';\nimport type { StatewireDiagnosticsRecorder } from './statewire-diagnostics';\nimport { isDeepAgentStateHydrated, readDeepAgentStreamValues } from './statewire-state';\nimport { StatewireSuspended } from './statewire-suspended';\nimport {\n DEEP_AGENT_STATEWIRE_PROTOCOL,\n type StatewireTransportOptions,\n} from './statewire-transport';\nimport type { DeepAgentThreadPrewarmPool } from './thread-prewarm';\nimport { type DeepAgentThreadSnapshotCache, toThreadSnapshotSeed } from './thread-snapshot-cache';\nimport type { DeepAgentToolOutputStore } from './tool-outputs';\nimport type { DeepAgentWithdrawnTurns } from './withdrawn-turns';\nimport type {\n DeepAgentConnectionState,\n DeepAgentLaneProjection,\n DeepAgentStreamValues,\n} from './types';\n\ntype ThreadOptions = StatewireThread.Options<DeepAgentStreamValues>;\n\nexport type { DeepAgentHeadersResolver } from './deep-agent-transport-recipe';\n\n/**\n * How an attach's FIRST frame is sourced, decided once per attach at mount: the\n * hello a pooled pre-dialed attach already replicated (`prewarm`), a remembered\n * snapshot seed (`snapshot`), or nothing (`none` — the thread loads until its\n * hello).\n */\nexport type DeepAgentAttachSource = 'prewarm' | 'snapshot' | 'none';\n\nexport interface UseDeepAgentThreadOptions {\n threadId: string;\n /** Base URL of the deep-agent statewire host (the `…/v2/threads` mount). */\n baseUrl: string;\n /** Transport selection: SSE when true, WebSocket otherwise. */\n sse?: boolean;\n /**\n * Auth headers for the transport. Statewire passes `{ staleAuth: true }`\n * when the previous credential was refused, so resolvers that can\n * force-renew should honor it.\n */\n headers: DeepAgentHeadersResolver;\n /**\n * Statewire session store for reconnect command-session recovery (e.g. the\n * mobile AsyncStorage-backed store). Host-resolved; omitted, sessions are\n * process-local.\n */\n sessionStore?: StatewireTransportOptions['sessionStore'];\n /**\n * Mounted storage seams for the thread: `session` holds the lane identity and\n * the commands still awaiting a durable verdict, so a reload resumes the lane\n * instead of minting a new client (browser hosts pass `LocalStorageSession`\n * from `@assistant-ui/react-statewire/local-storage`); `composer` persists the\n * draft. Mutually exclusive with `sessionStore` — statewire refuses a session\n * mounted twice.\n */\n storage?: ThreadOptions['storage'];\n /** True only for a never-started local chat; existing empty threads still load until their snapshot. */\n isNewChat?: boolean;\n /**\n * Extra transport-key discriminator for the SAME thread. The session is keyed\n * by `threadId` alone by default; hosts that must re-read the server snapshot\n * without a thread switch (a run dispatched outside this client, e.g. a\n * backgrounded AOP run writing the thread's first messages) bump this to\n * remount the session against the same URL.\n */\n attachKey?: string | number;\n /**\n * Host gate: park the transport instead of attaching — no socket, no retry\n * loop. The thread element stays mounted so assistant-ui consumers keep\n * rendering. Pass it when the host already knows every attach would be denied (e.g.\n * the signed-in user has no workspace yet), so a locked-out tab does not\n * hammer the attach endpoint on every backoff interval.\n */\n suspended?: { reason: string } | false;\n /**\n * Adapter capabilities the host UI exposes. Defaults preserve each client's\n * pre-extraction surface — pass what the product mounts.\n */\n capabilities?: {\n edit?: boolean;\n continue?: boolean;\n reload?: boolean;\n unstable_switchBranch?: boolean;\n };\n /** Which run lanes project into the message tail; see {@link DeepAgentLaneProjection}. */\n laneProjection?: DeepAgentLaneProjection;\n /**\n * The viewer, as the backend would stamp them (`metadata.custom.author`).\n * Stamped onto this client's own optimistic bubbles — a send still in flight\n * has no host `meta` yet — so a just-sent turn is attributed, and the\n * multi-author avatar gate flips for a second poster, without waiting for\n * the acknowledgment. Replicated entries carry the host's own stamp instead.\n * Compared field-wise, so callers need not memoize the object.\n */\n selfAuthor?: DeepAgentMessageAuthor | null;\n /**\n * Snapshot host context when each user message is submitted, before it is\n * journaled. Includes programmatic appends, keyboard sends, queued messages,\n * steering, and edits. The async getter starts immediately at submission;\n * sends retain their order while it resolves. Retries, queue text edits,\n * lane moves, reload, and continue preserve the original association.\n * Return JSON-serializable metadata; optional capture failures can\n * return an explicit null field rather than blocking the message.\n */\n getMessageMetadata?: ThreadOptions['getMessageMetadata'];\n /** Host-owned adapters: attachments (upload/mention choreography), speech, feedback. */\n adapters?: ThreadOptions['adapters'];\n /**\n * Transport lifecycle recorder (attach latency, reconnect loops, command\n * settle fates, stale-auth renewals) fed from the hook's own seams. Pass one\n * only when the host's diagnostics channel is enabled — the recorder is\n * observed on hot paths, and an absent recorder costs a single optional call.\n */\n diagnostics?: StatewireDiagnosticsRecorder;\n /**\n * Per-tab LRU of the last wire state seen per thread. When set, every\n * hydrated state the transport publishes is remembered, and a mount of a\n * remembered thread seeds `initialState` from the cache (through\n * {@link toThreadSnapshotSeed}) — the thread renders its last-known\n * messages on the first frame instead of holding a loading treatment for\n * the attach round-trip, and projects \"running\" when the run was live at\n * capture (else \"ready\"). The attach snapshot then\n * REPLACES the seeded state (statewire's `initialState` contract), so a\n * thread that advanced elsewhere reconciles in one round-trip. New chats\n * keep their preload and never read the cache.\n */\n snapshotCache?: DeepAgentThreadSnapshotCache;\n /**\n * Declare a message window on the attach (`x-athena-deep-agent-window`):\n * the hello carries the last `size` messages plus the `messagesWindow`\n * lane and the host re-addresses the op stream to that window; older\n * ranges load through `history/load` (see `message-window.ts`). Read once\n * per attach. `false` / omitted keeps the full snapshot — the surfaces\n * that have not adopted the window are untouched.\n */\n messageWindow?: DeepAgentMessageWindowDeclaration | false;\n /**\n * Full tool outputs fetched back for a windowed wire's cut tool messages\n * (`history/tool_output`); the thread re-converts when one lands. Only\n * meaningful together with `messageWindow`.\n */\n toolOutputs?: DeepAgentToolOutputStore;\n /**\n * User turns this client took back ahead of the wire (a user stop before\n * any assistant output); the thread re-converts when one opens or closes.\n */\n withdrawnTurns?: DeepAgentWithdrawnTurns;\n /**\n * Pre-dialed attaches (see `thread-prewarm.ts`). When the pool holds a root\n * for this thread at mount, the thread takes the hello it replicated as its\n * seed — the transcript is the first frame — and dials its own attach\n * against the instance the pool warmed; the pooled root is disposed in the\n * same step, so one socket is live per thread after mount. Never seeded for\n * a preloaded new chat or a suspended attach; such a root is discarded.\n */\n prewarmPool?: DeepAgentThreadPrewarmPool<DeepAgentStreamValues>;\n /**\n * Attach-path timing: socket open, hello size + handler cost, server retry\n * hints — attributed to the attach's own thread, since a late event from the\n * thread being left can land after the host has moved on.\n */\n onAttachTiming?: (info: { threadId: string; event: DeepAgentAttachTimingEvent }) => void;\n /** Where this attach's first frame comes from; once per attach, at mount. */\n onAttachSource?: (info: { threadId: string; source: DeepAgentAttachSource }) => void;\n /** Full transport error policy (paywall, toast, telemetry) — client-owned. */\n onError?: ThreadOptions['onError'];\n /**\n * Raw statewire state observer (first-attach latches, telemetry). The state\n * argument is never `undefined`/`null`: passes where the wire has no\n * snapshot yet (pre-attach, replay boundaries) deliver the typed\n * `DEEP_AGENT_PRE_STREAM_STATE` default — `isDeepAgentStateHydrated`\n * distinguishes them from a real (possibly empty) snapshot.\n */\n onStateChange?: ThreadOptions['onStateChange'];\n /** Raw command-lifecycle observer (send-failure salvage, telemetry). */\n onCommandChange?: ThreadOptions['onCommandChange'];\n /** Raw connection observer (reconnect handles, telemetry). */\n onRawConnectionChange?: ThreadOptions['onConnectionChange'];\n /**\n * Projected connection status changes, deduped per thread, with `null` on\n * unmount so an indicator never shows a stale status.\n */\n onConnectionChange?: (connection: DeepAgentConnectionState | null) => void;\n /** Notified when a run starts/stops so the page can reflect the running thread. */\n onRunningChange?: (isRunning: boolean) => void;\n /**\n * Notified once per thread with the `runConfig` carried by the statewire\n * snapshot (the backend's persisted panel config, seeded in `_load_history`),\n * so the host can hydrate its config store from the thread. Notified with\n * `null` (at most once per attach) when a server snapshot arrives WITHOUT a\n * persisted config, so a host waiting on hydration can stop waiting; a\n * config appearing on a later snapshot of the same attach (mirrored at run\n * start) still delivers the config notification.\n */\n onServerRunConfig?: (config: Record<string, unknown> | null) => void;\n /**\n * Notified when the snapshot's `outOfBandRunActive` flag changes: the host set\n * it while a run executing OUTSIDE this surface (an AOP / HTTP-route run)\n * is actively writing the thread's bare-namespace history, which the host\n * live-refreshes onto the wire. Lets the page show run-in-progress\n * treatment instead of an empty conversation, and stand down its own\n * re-attach polling. Change-notified per attach (an initial `false` before\n * the snapshot stays silent), mirroring `onRunningChange`.\n */\n onOutOfBandRunActive?: (outOfBandRunActive: boolean) => void;\n /**\n * Notified with the state's session-asset lifecycle flag\n * ({@link readSessionPersisted}) PAIRED with the thread it describes: `false`\n * while the thread's `session` asset provably does not exist yet (a\n * never-started chat's preload, a first run before the mint), `true` once\n * minted, `null` when the state carries no flag (a host that predates it).\n *\n * Fired from the converter pass, so the pair is read from the state of the\n * thread this attach was mounted for. A component reading the flag off the\n * client store instead lags the mounted thread id by one render on a switch\n * and can pair the new id with the previous thread's flag — releasing a\n * session-scoped read for a row the backend has not minted. Change-notified\n * per attach; the first pass of every attach notifies, so a host holding a\n * read back until it hears from the mounted thread always does.\n */\n onSessionPersistedChange?: (event: {\n threadId: string;\n sessionPersisted: boolean | null;\n }) => void;\n /**\n * Notified with the wire-contract status once the attach snapshot\n * advertises the `protocol` lane, and again whenever it changes (a\n * re-attach after a server roll can advertise a new `version`). Telemetry\n * and per-version behaviour only: the host has no minimum client version,\n * so nothing about the status gates a send. Never called for\n * pre-declaration servers (their snapshots carry no lane) — absence of a\n * call means \"no advertisement\", not \"compatible\".\n */\n onProtocolChange?: (status: DeepAgentProtocolStatus) => void;\n}\n\n/** One thread's replicated running state, keyed so a switch between two\n * threads with the same status still re-notifies (the host page clears its\n * per-thread state on selection, mirroring the connection dedupe below). */\nexport interface RunningSnapshot {\n threadId: string;\n isRunning: boolean;\n}\n\n/** Whether the thread's `session` asset exists, read off a statewire state, or\n * `null` when the state does not carry the flag.\n *\n * Absence is not absence of the asset: a snapshot from a host that predates\n * the flag has no such key, and reading that as \"the asset does not exist\"\n * would gate a read the client is entitled to make, with nothing left to\n * un-gate it. A new thread's preload seeds `false` (see `initialState`), so\n * the pre-attach pass of a chat that cannot have an asset yet still gates.\n *\n * Hosts pass this to `useStatewireState` so the flag and the thread it belongs\n * to are read in one component — a thread switch then cannot pair one thread's\n * id with the other's flag. */\nexport function readSessionPersisted(state: unknown): boolean | null {\n const flag = (state as { sessionPersisted?: unknown } | null)?.sessionPersisted;\n return typeof flag === 'boolean' ? flag : null;\n}\n\n/** Whether a converter pass must notify `onRunningChange`.\n *\n * The mount's very first status notifies only when it is `true` (a snapshot\n * carrying a live run) — an initial `false` before the snapshot must stay\n * silent so it cannot clear a still-valid indicator. After that, every\n * transition notifies, and so does the first status after a thread switch\n * (the host page clears its per-thread state on selection, so a switch\n * between two threads with the same status must still re-notify). */\nexport function shouldNotifyRunningChange(\n previous: RunningSnapshot | null,\n next: RunningSnapshot\n): boolean {\n if (previous === null) return next.isRunning;\n return previous.threadId !== next.threadId || previous.isRunning !== next.isRunning;\n}\n\n/**\n * The shared deep-agent Statewire thread.\n *\n * `StatewireThread` (from `@assistant-ui/react-statewire`) attaches to the\n * agora-hosted thread at `${baseUrl}/${threadId}` (WebSocket by default,\n * with SSE retained only as a host-selected compatibility switch): the backend\n * hosts the thread state and this client\n * replicates it live, so the server snapshot is the single source of history\n * (no local import, no `/status` resume probing) and run scheduling — queueing,\n * steering, stop, edit rewinds — rides the built-in `run/*` commands.\n *\n * The thread element is keyed by `threadId`, so a thread switch remounts the\n * session against the new URL instead of importing history in place.\n *\n * Returns the thread element for the host's own `useAui({ thread })` — web\n * hosts take `useAui` from `@assistant-ui/react`, React Native hosts from\n * `@assistant-ui/react-native`; this package imports neither.\n */\nexport function useDeepAgentThread({\n threadId,\n baseUrl,\n sse = false,\n headers,\n sessionStore,\n storage,\n isNewChat = false,\n attachKey,\n suspended = false,\n capabilities,\n laneProjection = 'both',\n selfAuthor = null,\n getMessageMetadata,\n adapters,\n diagnostics,\n snapshotCache,\n messageWindow = false,\n toolOutputs,\n withdrawnTurns,\n prewarmPool,\n onAttachTiming,\n onAttachSource,\n onError,\n onStateChange,\n onCommandChange,\n onRawConnectionChange,\n onConnectionChange,\n onRunningChange,\n onServerRunConfig,\n onOutOfBandRunActive,\n onSessionPersistedChange,\n onProtocolChange,\n}: UseDeepAgentThreadOptions) {\n const onRunningChangeRef = useRef(onRunningChange);\n onRunningChangeRef.current = onRunningChange;\n const onSessionPersistedChangeRef = useRef(onSessionPersistedChange);\n onSessionPersistedChangeRef.current = onSessionPersistedChange;\n const onConnectionChangeRef = useRef(onConnectionChange);\n onConnectionChangeRef.current = onConnectionChange;\n const onServerRunConfigRef = useRef(onServerRunConfig);\n onServerRunConfigRef.current = onServerRunConfig;\n const onOutOfBandRunActiveRef = useRef(onOutOfBandRunActive);\n onOutOfBandRunActiveRef.current = onOutOfBandRunActive;\n const onProtocolChangeRef = useRef(onProtocolChange);\n onProtocolChangeRef.current = onProtocolChange;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const onRawConnectionChangeRef = useRef(onRawConnectionChange);\n onRawConnectionChangeRef.current = onRawConnectionChange;\n const headersRef = useRef(headers);\n headersRef.current = headers;\n const messageWindowRef = useRef(messageWindow);\n messageWindowRef.current = messageWindow;\n // A fetched tool output must re-run the converter (the store is read inside\n // it); the version is the memo's signal that the store's contents moved.\n const [toolOutputsVersion, setToolOutputsVersion] = useState(0);\n useEffect(() => {\n if (!toolOutputs) return undefined;\n return toolOutputs.subscribe(() => setToolOutputsVersion((version) => version + 1));\n }, [toolOutputs]);\n const [withdrawnTurnsVersion, setWithdrawnTurnsVersion] = useState(0);\n useEffect(() => {\n if (!withdrawnTurns) return undefined;\n return withdrawnTurns.subscribe(() => setWithdrawnTurnsVersion((version) => version + 1));\n }, [withdrawnTurns]);\n const diagnosticsRef = useRef(diagnostics);\n diagnosticsRef.current = diagnostics;\n const onAttachTimingRef = useRef(onAttachTiming);\n onAttachTimingRef.current = onAttachTiming;\n const onAttachSourceRef = useRef(onAttachSource);\n onAttachSourceRef.current = onAttachSource;\n\n const lastRunningRef = useRef<RunningSnapshot | null>(null);\n // Out-of-band run activity (`outOfBandRunActive`), change-notified with the\n // same semantics as the running flag above.\n const lastOutOfBandRunActiveRef = useRef<RunningSnapshot | null>(null);\n // The session-asset lifecycle flag last notified, keyed by attach so every\n // attach's first pass notifies (a host holding a read back until it hears\n // from the mounted thread must always hear from it).\n const lastSessionPersistedRef = useRef<{\n attachId: string;\n threadId: string;\n sessionPersisted: boolean | null;\n } | null>(null);\n // The last wire-contract status notified, keyed by attach so a re-attach\n // re-notifies (the new snapshot may advertise a different version).\n // `status: null` = nothing advertised yet on this attach.\n const lastProtocolRef = useRef<{\n attachId: string;\n status: DeepAgentProtocolStatus | null;\n } | null>(null);\n // The thread whose statewire-carried runConfig has been surfaced to the host\n // (once per thread; later snapshots must not clobber edits).\n const appliedStateRunConfigThreadRef = useRef<string | null>(null);\n // The attach that already notified `onServerRunConfig(null)` (snapshot\n // arrived carrying no persisted config) — at most once per attach.\n const absentStateRunConfigAttachRef = useRef<string | null>(null);\n // Live thread id for the callbacks: they are created per render but may\n // settle after a switch, so they compare against the current id.\n const threadIdRef = useRef(threadId);\n threadIdRef.current = threadId;\n // Identity of the current attach. Every per-thread latch keys off this, so a\n // re-attach of the same thread (a bumped `attachKey`) re-notifies the host\n // exactly like a switch would — the host clears its per-thread state on\n // re-attach, so a snapshot that repeats the previous status must not dedupe.\n const attachId: string = attachKey === undefined ? threadId : `${threadId}:${attachKey}`;\n const attachIdRef = useRef(attachId);\n attachIdRef.current = attachId;\n\n // Auth-denial park: the server fins every denied attach `unauthorized` and\n // the reconnect loop would otherwise retry it every 30s forever (prod tabs\n // looped for hours against revoked/workspace-less credentials). After a\n // streak of denials the live transport is swapped for a parked one; a new\n // attach (thread switch, bumped attachKey) or the parked connection's\n // `reconnect()` re-arms it.\n const [authParked, setAuthParked] = useState<{\n attachId: string;\n message: string | undefined;\n } | null>(null);\n const authDenialRef = useRef<{ attachId: string; state: AuthDenialTrackerState }>({\n attachId,\n state: initialAuthDenialTrackerState(),\n });\n useEffect(() => {\n setAuthParked((prev) => (prev !== null && prev.attachId !== attachId ? null : prev));\n }, [attachId]);\n\n // Field-wise stable identity for the viewer stamp, so a host that rebuilds\n // the author object per render does not rebuild the converter (and with it\n // every message) per render. Adjusting state during render is React's\n // sanctioned derived-state pattern: it re-renders once with the new value.\n const [stableSelfAuthor, setStableSelfAuthor] = useState(selfAuthor);\n if (!isSameMessageAuthor(stableSelfAuthor, selfAuthor)) setStableSelfAuthor(selfAuthor);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: toolOutputsVersion / withdrawnTurnsVersion are the stores' change signals — the converter reads the stores' contents, not the counters.\n const converter = useMemo(\n () => (state: unknown, isRunning: boolean) => {\n // Statewire snapshots carry the thread's persisted panel config (the\n // backend seeds `runConfig` in `_load_history` and mirrors it on run\n // start). Surface it once per thread so the host can hydrate its config\n // store.\n const stateRunConfig = (state as { runConfig?: unknown } | null)?.runConfig;\n if (\n stateRunConfig &&\n typeof stateRunConfig === 'object' &&\n !Array.isArray(stateRunConfig) &&\n appliedStateRunConfigThreadRef.current !== attachIdRef.current\n ) {\n appliedStateRunConfigThreadRef.current = attachIdRef.current;\n const notifyRunConfig = onServerRunConfigRef.current;\n if (notifyRunConfig) {\n queueMicrotask(() => notifyRunConfig(stateRunConfig as Record<string, unknown>));\n }\n } else if (\n !stateRunConfig &&\n appliedStateRunConfigThreadRef.current !== attachIdRef.current &&\n absentStateRunConfigAttachRef.current !== attachIdRef.current &&\n projectDeepAgentProtocol(state) !== null\n ) {\n // No persisted config on a SERVER state: the protocol lane rides every\n // attach snapshot, so its presence distinguishes \"the server answered\n // without a config\" from the pre-attach `initialState` (which must not\n // end the host's hydration wait).\n absentStateRunConfigAttachRef.current = attachIdRef.current;\n const notifyRunConfig = onServerRunConfigRef.current;\n if (notifyRunConfig) {\n queueMicrotask(() => notifyRunConfig(null));\n }\n }\n // Out-of-band run activity: the host live-refreshes a bare-namespace\n // (AOP / HTTP-route) thread's transcript while its run is active and\n // flags the wire state so the page can reflect it.\n const stateOutOfBandRunActive =\n (state as { outOfBandRunActive?: unknown } | null)?.outOfBandRunActive === true;\n const outOfBandRunActiveSnapshot = {\n threadId: attachIdRef.current,\n isRunning: stateOutOfBandRunActive,\n };\n if (shouldNotifyRunningChange(lastOutOfBandRunActiveRef.current, outOfBandRunActiveSnapshot)) {\n lastOutOfBandRunActiveRef.current = outOfBandRunActiveSnapshot;\n const observedAttachId = attachIdRef.current;\n queueMicrotask(() => {\n // A re-attach or newer snapshot between the converter pass and this\n // microtask owns the channel now — a stale flag must not leak into\n // the new attach's per-thread state.\n if (\n attachIdRef.current !== observedAttachId ||\n lastOutOfBandRunActiveRef.current !== outOfBandRunActiveSnapshot\n ) {\n return;\n }\n onOutOfBandRunActiveRef.current?.(stateOutOfBandRunActive);\n });\n }\n // Wire-contract advertisement: the host publishes the `protocol` lane in\n // every attach snapshot. Notify on first advertisement and on change\n // (dedupe by value, re-keyed per attach), with the same stale-guard\n // microtask as the other observers.\n const protocolStatus = projectDeepAgentProtocol(state);\n if (protocolStatus !== null) {\n const previous =\n lastProtocolRef.current?.attachId === attachIdRef.current\n ? lastProtocolRef.current.status\n : null;\n if (previous === null || previous.protocolVersion !== protocolStatus.protocolVersion) {\n const update = { attachId: attachIdRef.current, status: protocolStatus };\n lastProtocolRef.current = update;\n queueMicrotask(() => {\n if (lastProtocolRef.current !== update || attachIdRef.current !== update.attachId) {\n return;\n }\n onProtocolChangeRef.current?.(protocolStatus);\n });\n }\n }\n const runningSnapshot = { threadId: attachIdRef.current, isRunning };\n if (shouldNotifyRunningChange(lastRunningRef.current, runningSnapshot)) {\n lastRunningRef.current = runningSnapshot;\n const notify = onRunningChangeRef.current;\n if (notify) queueMicrotask(() => notify(isRunning));\n }\n return convertDeepAgentState(state, {\n laneProjection,\n selfAuthor: stableSelfAuthor,\n toolOutputs,\n withdrawnTurns,\n });\n },\n [\n laneProjection,\n stableSelfAuthor,\n toolOutputs,\n toolOutputsVersion,\n withdrawnTurns,\n withdrawnTurnsVersion,\n ]\n );\n const materialize = useMemo(\n () => createDeepAgentMaterialize({ selfAuthor: stableSelfAuthor }),\n [stableSelfAuthor]\n );\n\n // Surface the statewire connection status through `onConnectionChange` (the\n // converter re-runs on connection changes), and clear it when the runtime\n // unmounts so an indicator never shows a stale status. Dedup is keyed by\n // thread: the runtime stays mounted across idle thread switches, so the new\n // thread's first status must notify even when it equals the previous\n // thread's last one.\n const lastConnectionRef = useRef<{\n threadId: string;\n connection: DeepAgentConnectionState;\n } | null>(null);\n useEffect(\n () => () => {\n lastConnectionRef.current = null;\n onConnectionChangeRef.current?.(null);\n },\n []\n );\n\n // The preload decision pins at thread entry: `isNewChat` flips once the\n // thread persists, but the mount that began as a new thread stays preloaded.\n const preloadRef = useRef({ threadId, preload: isNewChat });\n if (preloadRef.current.threadId !== threadId)\n preloadRef.current = { threadId, preload: isNewChat };\n\n const snapshotCacheRef = useRef(snapshotCache);\n snapshotCacheRef.current = snapshotCache;\n // The snapshot seed pins at attach identity, like the preload decision: the\n // cache is read once per mount, so a mid-session cache write (this thread's\n // own states being remembered) never changes what `initialState` was.\n //\n // A suspended attach never seeds: the suspended transport never dials, so a\n // seed would be served indefinitely — under a view-as lens that would paint\n // thread content the parked transport exists to withhold (the lens must\n // show what the LENSED identity is authorized to see, and only the server\n // can decide that).\n //\n // The pooled hello is taken the same way: exactly once, at the attach's\n // first render (the pool disposes its root in that step).\n const snapshotSeedRef = useRef<{\n attachId: string;\n seed: DeepAgentStreamValues | undefined;\n } | null>(null);\n if (snapshotSeedRef.current === null || snapshotSeedRef.current.attachId !== attachId) {\n const preload = preloadRef.current.preload;\n let pooledState: DeepAgentStreamValues | undefined;\n if (prewarmPool?.has(threadId)) {\n if (preload || suspended) {\n // This mount attaches on its own terms (or not at all): the pooled\n // dial must not linger as a second socket to the same session.\n prewarmPool.discard(threadId);\n } else {\n pooledState = prewarmPool.take(threadId)?.state;\n }\n }\n // The pooled hello outranks a remembered snapshot (it is newer by\n // construction); a pooled dial that had not landed seeds like a plain\n // attach and reconciles when this attach's own hello lands.\n const remembered =\n preload || suspended ? undefined : (pooledState ?? snapshotCache?.take(threadId));\n const seed = remembered ? toThreadSnapshotSeed(remembered) : undefined;\n snapshotSeedRef.current = { attachId, seed };\n const source: DeepAgentAttachSource =\n pooledState !== undefined ? 'prewarm' : seed ? 'snapshot' : 'none';\n const notifySource = onAttachSourceRef.current;\n if (notifySource) queueMicrotask(() => notifySource({ threadId, source }));\n }\n\n // react-statewire memoizes the converted thread on this function's\n // identity, so an inline closure would re-run `convertDeepAgentState` over\n // the whole transcript on every host render. Keyed on the attach identity (a\n // re-attach re-keys its per-thread latches); everything else the body needs\n // is read through the per-render refs above.\n const threadConverter = useCallback<ThreadOptions['converter']>(\n (state, meta) => {\n // Projected once per pass through the single seam; every fold below\n // consumes the projection (the recorder projects the raw connection\n // itself, so any host observer can feed it).\n const connection = projectDeepAgentConnection(meta.connection);\n // Transition-deduped inside the recorder, so this per-pass observation\n // is free while the connection is unchanged.\n diagnosticsRef.current?.observeConnection(meta.connection);\n // Fold this pass's connection into the denial streak (the converter\n // re-runs on every reconnect-attempt bump). Parking is deferred to a\n // microtask like every other notification here.\n if (authDenialRef.current.attachId !== attachIdRef.current) {\n authDenialRef.current = {\n attachId: attachIdRef.current,\n state: initialAuthDenialTrackerState(),\n };\n }\n const denial = observeAuthDenial(authDenialRef.current.state, connection);\n authDenialRef.current.state = denial.state;\n if (denial.park) {\n const parkAttachId = attachIdRef.current;\n const parkMessage = denial.state.message;\n // The server refused authorization for this thread: any remembered\n // snapshot must not warm-paint it on a later mount (permissions may\n // have been revoked since the state was captured).\n snapshotCacheRef.current?.forget(threadId);\n queueMicrotask(() => {\n if (attachIdRef.current !== parkAttachId) return;\n setAuthParked((prev) =>\n prev?.attachId === parkAttachId\n ? prev\n : { attachId: parkAttachId, message: parkMessage }\n );\n });\n }\n const previous = lastConnectionRef.current;\n if (\n previous?.threadId !== attachId ||\n !Object.keys({ ...previous.connection, ...connection }).every(\n (key) => Reflect.get(previous.connection, key) === Reflect.get(connection, key)\n )\n ) {\n const update = { threadId: attachId, connection };\n lastConnectionRef.current = update;\n queueMicrotask(() => {\n // A newer projection, a thread switch, or the unmount cleanup owns\n // the channel now.\n if (lastConnectionRef.current !== update || attachIdRef.current !== attachId) return;\n onConnectionChangeRef.current?.(connection);\n });\n }\n // Session-asset lifecycle, paired with THIS attach's thread by closure:\n // the state converted here is the state of the thread the element was\n // built for, so the pair can never straddle a switch (a client-store\n // read would). Deduped by value per attach. A pass from an attach the\n // host has already replaced never touches the latch — it could otherwise\n // cancel the current attach's still-queued verdict — and the microtask\n // guard drops a pass whose attach is replaced before it settles.\n if (attachIdRef.current === attachId) {\n const sessionPersisted = readSessionPersisted(state);\n const lastSession = lastSessionPersistedRef.current;\n if (\n lastSession?.attachId !== attachId ||\n lastSession.sessionPersisted !== sessionPersisted\n ) {\n const sessionUpdate = { attachId, threadId, sessionPersisted };\n lastSessionPersistedRef.current = sessionUpdate;\n queueMicrotask(() => {\n if (\n lastSessionPersistedRef.current !== sessionUpdate ||\n attachIdRef.current !== attachId\n ) {\n return;\n }\n onSessionPersistedChangeRef.current?.({ threadId, sessionPersisted });\n });\n }\n }\n // The replicated run status IS the running signal: the lib's run-dialect\n // fold flips it to \"running\" on the send, before the app converter runs,\n // so the optimistic window needs no hand-tracked flag.\n return converter(state, state?.runs?.[0]?.status === 'running');\n },\n [attachId, converter, threadId]\n );\n\n return StatewireThread<DeepAgentStreamValues>({\n // The transport stamps this protocol on every command; the thread client\n // must declare it too or the core skips the optimistic folds and a send\n // stays invisible until the server frame lands.\n protocol: DEEP_AGENT_STATEWIRE_PROTOCOL,\n // New threads preload an empty runs mount and report `deferred` — the\n // composer is interactive before the stream attaches and pre-attach sends\n // render through the optimistic folds. Existing threads omit the runs\n // mount and project \"loading\" until the attach snapshot: the server seeds\n // messages/todos/runConfig in `_load_history`.\n //\n // The preload also seeds `sessionPersisted: false`: a never-started chat\n // provably has no `session` asset until its first run mints one, so the\n // wire carries that from the first render and a host reading the flag off\n // the state needs no separate \"is this a new chat\" knowledge. An existing\n // thread leaves it absent (unknown) so its asset read is never gated.\n initialState:\n snapshotSeedRef.current.seed ??\n ({\n messages: [],\n todos: [],\n ...(preloadRef.current.preload && { runs: [], sessionPersisted: false }),\n } satisfies DeepAgentStreamValues),\n // Keyed by thread: a switch unmounts the previous thread's session and\n // remounts against the new URL, so the converter never sees the previous\n // thread's snapshot (a new thread serves its preload again, an existing\n // one loads until its snapshot). A host-suspended or auth-parked attach\n // swaps in the never-dialing transport instead.\n transport: withKey(\n attachId,\n (() => {\n if (suspended) return StatewireSuspended({ message: suspended.reason });\n if (authParked !== null && authParked.attachId === attachId) {\n return StatewireSuspended({\n message: authParked.message ?? 'Session authorization was refused.',\n onReconnectRequested: () => {\n authDenialRef.current = {\n attachId: attachIdRef.current,\n state: initialAuthDenialTrackerState(),\n };\n setAuthParked(null);\n },\n });\n }\n // The shared recipe (URL, auth + wire-contract headers, session lane,\n // attach instrumentation, retry-hint floor) — the same one the prewarm\n // pool dials with, so the instance a pooled attach warmed is the one\n // this dial reaches. A never-started chat dials nothing until its\n // first send.\n return createDeepAgentAttachTransport<DeepAgentStreamValues>({\n baseUrl,\n threadId,\n sse,\n isNew: preloadRef.current.preload,\n headers: (ctx) => headersRef.current(ctx),\n sessionStore,\n onAuthResolve: (ctx) => diagnosticsRef.current?.observeAuthResolve(ctx),\n onAttachTiming: (event) => onAttachTimingRef.current?.({ threadId, event }),\n // Read once per attach: a declaration change applies to the next\n // attach, never to a reconnect of this one (the view would be\n // re-shaped under the client).\n messageWindow: messageWindowRef.current,\n });\n })()\n ),\n // Survives the transport remounts above: a bumped attachKey re-attaches the\n // same lane, and a persistent session storage carries it across reloads.\n ...(storage && { storage }),\n // The run subsystem (status, lanes, input requests, runId) is mounted on\n // the state root and always replicated by react-statewire >= 0.14 (the\n // former `runs: true` opt-in is gone) — the converter only maps app-owned\n // keys, including the `run/stop` runId stamp the lib projects itself.\n converter: threadConverter,\n // Makes the server's dispatch record concrete in state (after the\n // optimistic folds); the lib's post-converter dispatch merge turns off.\n materialize,\n // Native message editing: an edited turn is resubmitted as a `run/edit`\n // command, and the deep-agent backend rewinds the checkpointed thread to\n // the edited message's parent before appending (route `plan_rewind`).\n capabilities: capabilities ?? { edit: true },\n ...(getMessageMetadata && { getMessageMetadata }),\n ...(adapters && { adapters }),\n contextSync: 'command-send',\n // The Stop control is the only `cancelRun()` caller — teardown paths\n // unmount the keyed transport instead — so every `run/stop` is a\n // deliberate user stop.\n stopPayload: () => ({ reason: 'user_stop' }),\n onError: (error) => {\n diagnosticsRef.current?.observeError(error);\n onErrorRef.current?.(error);\n },\n ...((onStateChange || snapshotCache) && {\n // The lib types the observed state `NonNullable`, but the runtime\n // delivers `undefined` where the wire has no snapshot (pre-attach and\n // replay boundaries republish it) — normalize so the type is true and\n // host observers never crash on a field read.\n onStateChange: ((state, ctx) => {\n const values = readDeepAgentStreamValues(state);\n // Remember under the closure's thread id, not a ref: a late delivery\n // from a previous thread's session must file under THAT thread.\n if (isDeepAgentStateHydrated(values)) {\n snapshotCacheRef.current?.remember(threadId, values);\n }\n onStateChangeRef.current?.(values, ctx);\n }) satisfies ThreadOptions['onStateChange'],\n }),\n ...((onCommandChange || diagnostics) && {\n onCommandChange: ((update, ctx) => {\n diagnosticsRef.current?.observeCommand(update);\n onCommandChangeRef.current?.(update, ctx);\n }) satisfies ThreadOptions['onCommandChange'],\n }),\n ...(onRawConnectionChange && {\n onConnectionChange: ((connection) =>\n onRawConnectionChangeRef.current?.(\n connection\n )) satisfies ThreadOptions['onConnectionChange'],\n }),\n });\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;AAkRO,SAAS,qBAAqB,OAAgC;AACnE,QAAM,OAAQ,+BAAiD;AAC/D,SAAO,OAAO,SAAS,YAAY,OAAO;AAC5C;AAUO,SAAS,0BACd,UACA,MACS;AACT,MAAI,aAAa,KAAM,QAAO,KAAK;AACnC,SAAO,SAAS,aAAa,KAAK,YAAY,SAAS,cAAc,KAAK;AA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B,cAAM,SAAS,0BAA0B,KAAK;AAG9C,YAAI,yBAAyB,MAAM,GAAG;AACpC,WAAAA,MAAA,iBAAiB,YAAjB,gBAAAA,IAA0B,SAAS,UAAU;AAAA,QAC/C;AACA,+BAAiB,YAAjB,0CAA2B,QAAQ;AAAA,MACrC;AAAA,IAAA;AAAA,IAEF,IAAK,mBAAmB,gBAAgB;AAAA,MACtC,kBAAkB,CAAC,QAAQ,QAAQ;;AACjC,SAAAA,MAAA,eAAe,YAAf,gBAAAA,IAAwB,eAAe;AACvC,iCAAmB,YAAnB,4CAA6B,QAAQ;AAAA,MACvC;AAAA,IAAA;AAAA,IAEF,GAAI,yBAAyB;AAAA,MAC3B,qBAAqB,CAAC,eAAA;;AACpB,gBAAAA,MAAA,yBAAyB,YAAzB,gBAAAA,IAAA;AAAA;AAAA,UACE;AAAA;AAAA;AAAA,IACF;AAAA,EACJ,CACD;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice-presentation.cjs","sources":["../../../../../agent-runtime/src/voice-presentation.ts"],"sourcesContent":["/**\n * How voice-mode transcript entries present, shared by every chat surface\n * (Olympus, the Chrome side panel, the mobile app) so a spoken turn, a\n * delegation the live voice model handed off, and an interim spoken update\n * read the same everywhere. The wire contract is the deep-agent host's\n * `additional_kwargs.metadata` (exposed as `message.metadata.custom`):\n *\n * - `source: \"voice\"` — a spoken turn; `voice_live: true` while it is still\n * being heard or spoken (the ephemeral entry the durable row replaces);\n * - `source: \"text\"` — a message typed into the live conversation;\n * - `source: \"voice_delegation\"` (id prefix `voicetask_`) — the unit of work\n * the live voice model delegated to the thread.\n */\n\n/** `metadata.custom.source` of a spoken turn. */\nexport const VOICE_SOURCE_SPOKEN = 'voice';\n/** `metadata.custom.source` of a message typed into the live conversation. */\nexport const VOICE_SOURCE_TYPED = 'text';\n/** `metadata.custom.source` of a voice delegation's anchor message. */\nexport const VOICE_SOURCE_DELEGATION = 'voice_delegation';\n/** Id prefix of a voice delegation's anchor message (the working signal on\n * hosts that drop the command's metadata). */\nexport const VOICE_DELEGATION_ID_PREFIX = 'voicetask_';\n/** `metadata.custom` flag on a spoken turn still in flight. */\nexport const VOICE_LIVE_KEY = 'voice_live';\n\n/** The delegated run's interim-update tool (agora `send_voice_update`). */\nexport const VOICE_UPDATE_TOOL_NAME = 'send_voice_update';\n\n/** Trailing hint on the live-session strip, worded once for every surface. */\nexport const VOICE_LIVE_TYPED_HINT = 'typed messages go to the voice conversation';\n\
|
|
1
|
+
{"version":3,"file":"voice-presentation.cjs","sources":["../../../../../agent-runtime/src/voice-presentation.ts"],"sourcesContent":["/**\n * How voice-mode transcript entries present, shared by every chat surface\n * (Olympus, the Chrome side panel, the mobile app) so a spoken turn, a\n * delegation the live voice model handed off, and an interim spoken update\n * read the same everywhere. The wire contract is the deep-agent host's\n * `additional_kwargs.metadata` (exposed as `message.metadata.custom`):\n *\n * - `source: \"voice\"` — a spoken turn; `voice_live: true` while it is still\n * being heard or spoken (the ephemeral entry the durable row replaces);\n * - `source: \"text\"` — a message typed into the live conversation;\n * - `source: \"voice_delegation\"` (id prefix `voicetask_`) — the unit of work\n * the live voice model delegated to the thread.\n */\n\n/** `metadata.custom.source` of a spoken turn. */\nexport const VOICE_SOURCE_SPOKEN = 'voice';\n/** `metadata.custom.source` of a message typed into the live conversation. */\nexport const VOICE_SOURCE_TYPED = 'text';\n/** `metadata.custom.source` of a voice delegation's anchor message. */\nexport const VOICE_SOURCE_DELEGATION = 'voice_delegation';\n/** Id prefix of a voice delegation's anchor message (the working signal on\n * hosts that drop the command's metadata). */\nexport const VOICE_DELEGATION_ID_PREFIX = 'voicetask_';\n/** `metadata.custom` flag on a spoken turn still in flight. */\nexport const VOICE_LIVE_KEY = 'voice_live';\n\n/** The delegated run's interim-update tool (agora `send_voice_update`). */\nexport const VOICE_UPDATE_TOOL_NAME = 'send_voice_update';\n\n/** Trailing hint on the live-session strip, worded once for every surface. */\nexport const VOICE_LIVE_TYPED_HINT = 'typed messages go to the voice conversation';\n\nexport interface VoiceMessageMarker {\n /** The thread message id; a host may not have assigned one yet. */\n messageId: string | undefined;\n /** The thread message's `metadata.custom`, when any. */\n custom: Record<string, unknown> | undefined;\n}\n\n/** Whether a thread message is a voice delegation's anchor (the ask the live\n * voice model handed to the thread), by source or by id prefix. */\nexport function isVoiceDelegationMessage({ messageId, custom }: VoiceMessageMarker): boolean {\n return (\n custom?.source === VOICE_SOURCE_DELEGATION ||\n (typeof messageId === 'string' && messageId.startsWith(VOICE_DELEGATION_ID_PREFIX))\n );\n}\n\nexport interface VoiceProvenance {\n /** Chip copy: \"Listening\", \"Speaking\", \"Spoken\", or \"Delegated from voice\". */\n readonly label: string;\n /** True while the turn is still being heard or spoken. */\n readonly live: boolean;\n}\n\n// These values are read directly by useAuiState/useSyncExternalStore selectors.\n// Equal presentation must retain its identity, even when a transport replaces\n// the message metadata. Fresh objects here cause React's update-depth crash.\nconst SPOKEN_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Spoken',\n live: false,\n});\nconst LISTENING_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Listening',\n live: true,\n});\nconst SPEAKING_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Speaking',\n live: true,\n});\nconst DELEGATED_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Delegated from voice',\n live: false,\n});\n\n/**\n * The provenance chip for a message, or `null` for ordinary chat messages so\n * the chip is free to mount on every row. A spoken turn still in flight reads\n * as what is happening (\"Listening\" for the user, \"Speaking\" for the\n * assistant) rather than as a finished \"Spoken\" turn; a typed-in-voice turn\n * is a normal message and gets no chip. Results are immutable and stable for\n * equal presentation, so all surfaces can use this function as a selector.\n */\nexport function voiceProvenanceLabel({\n messageId,\n custom,\n role,\n}: VoiceMessageMarker & { role: 'user' | 'assistant' | string }): VoiceProvenance | null {\n const source = custom?.source;\n if (source === VOICE_SOURCE_SPOKEN) {\n if (custom?.[VOICE_LIVE_KEY] === true) {\n return role === 'user' ? LISTENING_PROVENANCE : SPEAKING_PROVENANCE;\n }\n return SPOKEN_PROVENANCE;\n }\n if (isVoiceDelegationMessage({ messageId, custom })) {\n return DELEGATED_PROVENANCE;\n }\n return null;\n}\n\nexport interface VoiceUpdateToolCall {\n /** `mode: \"speak\"` — read aloud to the user; otherwise a silent progress note. */\n spoken: boolean;\n /** The update's words. */\n text: string;\n /** Whether the live session took it; `null` while the call is still running. */\n delivered: boolean | null;\n}\n\n/**\n * What a `send_voice_update` tool call did, from its arguments and the tool's\n * teaching-text result (agora returns prose, not JSON, so the run can read it).\n */\nexport function describeVoiceUpdateToolCall({\n args,\n result,\n}: {\n args: Record<string, unknown> | undefined;\n result: unknown;\n}): VoiceUpdateToolCall {\n const text = typeof args?.text === 'string' ? args.text.trim() : '';\n const spoken = args?.mode === 'speak';\n if (typeof result !== 'string' || result.trim() === '') {\n return { spoken, text, delivered: null };\n }\n const outcome = result.toLowerCase();\n const failed =\n outcome.includes('could not be delivered') ||\n outcome.includes('was not delivered') ||\n outcome.includes('rejected the update') ||\n outcome.includes('has ended') ||\n outcome.includes('not configured') ||\n outcome.includes('no voice session');\n return { spoken, text, delivered: !failed };\n}\n\n/** The card's status line for a voice update in a given tool-call state. */\nexport function voiceUpdateStatusLabel(\n call: VoiceUpdateToolCall,\n status: 'running' | 'complete' | 'incomplete' | 'requires-action' | undefined\n): string {\n if (status === 'running' || (call.delivered === null && status !== 'incomplete')) {\n return call.spoken ? 'Saying to you…' : 'Noting progress…';\n }\n if (call.delivered === false || status === 'incomplete') {\n return call.spoken ? 'Could not say this to you' : 'Progress note not delivered';\n }\n return call.spoken ? 'Said aloud' : 'Progress noted silently';\n}\n"],"names":[],"mappings":";;AAmBO,MAAM,0BAA0B;AAGhC,MAAM,6BAA6B;AAKnC,MAAM,yBAAyB;AAc/B,SAAS,yBAAyB,EAAE,WAAW,UAAuC;AAC3F,UACE,iCAAQ,YAAW,2BAClB,OAAO,cAAc,YAAY,UAAU,WAAW,0BAA0B;AAErF;AAoEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGwB;AACtB,QAAM,OAAO,QAAO,6BAAM,UAAS,WAAW,KAAK,KAAK,SAAS;AACjE,QAAM,UAAS,6BAAM,UAAS;AAC9B,MAAI,OAAO,WAAW,YAAY,OAAO,KAAA,MAAW,IAAI;AACtD,WAAO,EAAE,QAAQ,MAAM,WAAW,KAAA;AAAA,EACpC;AACA,QAAM,UAAU,OAAO,YAAA;AACvB,QAAM,SACJ,QAAQ,SAAS,wBAAwB,KACzC,QAAQ,SAAS,mBAAmB,KACpC,QAAQ,SAAS,qBAAqB,KACtC,QAAQ,SAAS,WAAW,KAC5B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,kBAAkB;AACrC,SAAO,EAAE,QAAQ,MAAM,WAAW,CAAC,OAAA;AACrC;AAGO,SAAS,uBACd,MACA,QACQ;AACR,MAAI,WAAW,aAAc,KAAK,cAAc,QAAQ,WAAW,cAAe;AAChF,WAAO,KAAK,SAAS,mBAAmB;AAAA,EAC1C;AACA,MAAI,KAAK,cAAc,SAAS,WAAW,cAAc;AACvD,WAAO,KAAK,SAAS,8BAA8B;AAAA,EACrD;AACA,SAAO,KAAK,SAAS,eAAe;AACtC;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice-presentation.js","sources":["../../../../../agent-runtime/src/voice-presentation.ts"],"sourcesContent":["/**\n * How voice-mode transcript entries present, shared by every chat surface\n * (Olympus, the Chrome side panel, the mobile app) so a spoken turn, a\n * delegation the live voice model handed off, and an interim spoken update\n * read the same everywhere. The wire contract is the deep-agent host's\n * `additional_kwargs.metadata` (exposed as `message.metadata.custom`):\n *\n * - `source: \"voice\"` — a spoken turn; `voice_live: true` while it is still\n * being heard or spoken (the ephemeral entry the durable row replaces);\n * - `source: \"text\"` — a message typed into the live conversation;\n * - `source: \"voice_delegation\"` (id prefix `voicetask_`) — the unit of work\n * the live voice model delegated to the thread.\n */\n\n/** `metadata.custom.source` of a spoken turn. */\nexport const VOICE_SOURCE_SPOKEN = 'voice';\n/** `metadata.custom.source` of a message typed into the live conversation. */\nexport const VOICE_SOURCE_TYPED = 'text';\n/** `metadata.custom.source` of a voice delegation's anchor message. */\nexport const VOICE_SOURCE_DELEGATION = 'voice_delegation';\n/** Id prefix of a voice delegation's anchor message (the working signal on\n * hosts that drop the command's metadata). */\nexport const VOICE_DELEGATION_ID_PREFIX = 'voicetask_';\n/** `metadata.custom` flag on a spoken turn still in flight. */\nexport const VOICE_LIVE_KEY = 'voice_live';\n\n/** The delegated run's interim-update tool (agora `send_voice_update`). */\nexport const VOICE_UPDATE_TOOL_NAME = 'send_voice_update';\n\n/** Trailing hint on the live-session strip, worded once for every surface. */\nexport const VOICE_LIVE_TYPED_HINT = 'typed messages go to the voice conversation';\n\
|
|
1
|
+
{"version":3,"file":"voice-presentation.js","sources":["../../../../../agent-runtime/src/voice-presentation.ts"],"sourcesContent":["/**\n * How voice-mode transcript entries present, shared by every chat surface\n * (Olympus, the Chrome side panel, the mobile app) so a spoken turn, a\n * delegation the live voice model handed off, and an interim spoken update\n * read the same everywhere. The wire contract is the deep-agent host's\n * `additional_kwargs.metadata` (exposed as `message.metadata.custom`):\n *\n * - `source: \"voice\"` — a spoken turn; `voice_live: true` while it is still\n * being heard or spoken (the ephemeral entry the durable row replaces);\n * - `source: \"text\"` — a message typed into the live conversation;\n * - `source: \"voice_delegation\"` (id prefix `voicetask_`) — the unit of work\n * the live voice model delegated to the thread.\n */\n\n/** `metadata.custom.source` of a spoken turn. */\nexport const VOICE_SOURCE_SPOKEN = 'voice';\n/** `metadata.custom.source` of a message typed into the live conversation. */\nexport const VOICE_SOURCE_TYPED = 'text';\n/** `metadata.custom.source` of a voice delegation's anchor message. */\nexport const VOICE_SOURCE_DELEGATION = 'voice_delegation';\n/** Id prefix of a voice delegation's anchor message (the working signal on\n * hosts that drop the command's metadata). */\nexport const VOICE_DELEGATION_ID_PREFIX = 'voicetask_';\n/** `metadata.custom` flag on a spoken turn still in flight. */\nexport const VOICE_LIVE_KEY = 'voice_live';\n\n/** The delegated run's interim-update tool (agora `send_voice_update`). */\nexport const VOICE_UPDATE_TOOL_NAME = 'send_voice_update';\n\n/** Trailing hint on the live-session strip, worded once for every surface. */\nexport const VOICE_LIVE_TYPED_HINT = 'typed messages go to the voice conversation';\n\nexport interface VoiceMessageMarker {\n /** The thread message id; a host may not have assigned one yet. */\n messageId: string | undefined;\n /** The thread message's `metadata.custom`, when any. */\n custom: Record<string, unknown> | undefined;\n}\n\n/** Whether a thread message is a voice delegation's anchor (the ask the live\n * voice model handed to the thread), by source or by id prefix. */\nexport function isVoiceDelegationMessage({ messageId, custom }: VoiceMessageMarker): boolean {\n return (\n custom?.source === VOICE_SOURCE_DELEGATION ||\n (typeof messageId === 'string' && messageId.startsWith(VOICE_DELEGATION_ID_PREFIX))\n );\n}\n\nexport interface VoiceProvenance {\n /** Chip copy: \"Listening\", \"Speaking\", \"Spoken\", or \"Delegated from voice\". */\n readonly label: string;\n /** True while the turn is still being heard or spoken. */\n readonly live: boolean;\n}\n\n// These values are read directly by useAuiState/useSyncExternalStore selectors.\n// Equal presentation must retain its identity, even when a transport replaces\n// the message metadata. Fresh objects here cause React's update-depth crash.\nconst SPOKEN_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Spoken',\n live: false,\n});\nconst LISTENING_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Listening',\n live: true,\n});\nconst SPEAKING_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Speaking',\n live: true,\n});\nconst DELEGATED_PROVENANCE: VoiceProvenance = Object.freeze({\n label: 'Delegated from voice',\n live: false,\n});\n\n/**\n * The provenance chip for a message, or `null` for ordinary chat messages so\n * the chip is free to mount on every row. A spoken turn still in flight reads\n * as what is happening (\"Listening\" for the user, \"Speaking\" for the\n * assistant) rather than as a finished \"Spoken\" turn; a typed-in-voice turn\n * is a normal message and gets no chip. Results are immutable and stable for\n * equal presentation, so all surfaces can use this function as a selector.\n */\nexport function voiceProvenanceLabel({\n messageId,\n custom,\n role,\n}: VoiceMessageMarker & { role: 'user' | 'assistant' | string }): VoiceProvenance | null {\n const source = custom?.source;\n if (source === VOICE_SOURCE_SPOKEN) {\n if (custom?.[VOICE_LIVE_KEY] === true) {\n return role === 'user' ? LISTENING_PROVENANCE : SPEAKING_PROVENANCE;\n }\n return SPOKEN_PROVENANCE;\n }\n if (isVoiceDelegationMessage({ messageId, custom })) {\n return DELEGATED_PROVENANCE;\n }\n return null;\n}\n\nexport interface VoiceUpdateToolCall {\n /** `mode: \"speak\"` — read aloud to the user; otherwise a silent progress note. */\n spoken: boolean;\n /** The update's words. */\n text: string;\n /** Whether the live session took it; `null` while the call is still running. */\n delivered: boolean | null;\n}\n\n/**\n * What a `send_voice_update` tool call did, from its arguments and the tool's\n * teaching-text result (agora returns prose, not JSON, so the run can read it).\n */\nexport function describeVoiceUpdateToolCall({\n args,\n result,\n}: {\n args: Record<string, unknown> | undefined;\n result: unknown;\n}): VoiceUpdateToolCall {\n const text = typeof args?.text === 'string' ? args.text.trim() : '';\n const spoken = args?.mode === 'speak';\n if (typeof result !== 'string' || result.trim() === '') {\n return { spoken, text, delivered: null };\n }\n const outcome = result.toLowerCase();\n const failed =\n outcome.includes('could not be delivered') ||\n outcome.includes('was not delivered') ||\n outcome.includes('rejected the update') ||\n outcome.includes('has ended') ||\n outcome.includes('not configured') ||\n outcome.includes('no voice session');\n return { spoken, text, delivered: !failed };\n}\n\n/** The card's status line for a voice update in a given tool-call state. */\nexport function voiceUpdateStatusLabel(\n call: VoiceUpdateToolCall,\n status: 'running' | 'complete' | 'incomplete' | 'requires-action' | undefined\n): string {\n if (status === 'running' || (call.delivered === null && status !== 'incomplete')) {\n return call.spoken ? 'Saying to you…' : 'Noting progress…';\n }\n if (call.delivered === false || status === 'incomplete') {\n return call.spoken ? 'Could not say this to you' : 'Progress note not delivered';\n }\n return call.spoken ? 'Said aloud' : 'Progress noted silently';\n}\n"],"names":[],"mappings":"AAmBO,MAAM,0BAA0B;AAGhC,MAAM,6BAA6B;AAKnC,MAAM,yBAAyB;AAc/B,SAAS,yBAAyB,EAAE,WAAW,UAAuC;AAC3F,UACE,iCAAQ,YAAW,2BAClB,OAAO,cAAc,YAAY,UAAU,WAAW,0BAA0B;AAErF;AAoEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGwB;AACtB,QAAM,OAAO,QAAO,6BAAM,UAAS,WAAW,KAAK,KAAK,SAAS;AACjE,QAAM,UAAS,6BAAM,UAAS;AAC9B,MAAI,OAAO,WAAW,YAAY,OAAO,KAAA,MAAW,IAAI;AACtD,WAAO,EAAE,QAAQ,MAAM,WAAW,KAAA;AAAA,EACpC;AACA,QAAM,UAAU,OAAO,YAAA;AACvB,QAAM,SACJ,QAAQ,SAAS,wBAAwB,KACzC,QAAQ,SAAS,mBAAmB,KACpC,QAAQ,SAAS,qBAAqB,KACtC,QAAQ,SAAS,WAAW,KAC5B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,kBAAkB;AACrC,SAAO,EAAE,QAAQ,MAAM,WAAW,CAAC,OAAA;AACrC;AAGO,SAAS,uBACd,MACA,QACQ;AACR,MAAI,WAAW,aAAc,KAAK,cAAc,QAAQ,WAAW,cAAe;AAChF,WAAO,KAAK,SAAS,mBAAmB;AAAA,EAC1C;AACA,MAAI,KAAK,cAAc,SAAS,WAAW,cAAc;AACvD,WAAO,KAAK,SAAS,8BAA8B;AAAA,EACrD;AACA,SAAO,KAAK,SAAS,eAAe;AACtC;"}
|
|
@@ -13,11 +13,12 @@ require("../packages/agent-runtime/src/messages.cjs");
|
|
|
13
13
|
require("@assistant-ui/react-statewire");
|
|
14
14
|
require("@assistant-ui/store");
|
|
15
15
|
const toolOutputs = require("../packages/agent-runtime/src/tool-outputs.cjs");
|
|
16
|
-
require("
|
|
16
|
+
require("../packages/agent-runtime/src/quota-safe-local-storage-session.cjs");
|
|
17
17
|
const threadSnapshotCache = require("../packages/agent-runtime/src/thread-snapshot-cache.cjs");
|
|
18
18
|
require("../packages/agent-runtime/src/statewire-attach-observer.cjs");
|
|
19
19
|
const threadStatus = require("../packages/agent-runtime/src/thread-status.cjs");
|
|
20
20
|
require("@assistant-ui/core");
|
|
21
|
+
require("../packages/agent-runtime/src/thread-handoff.cjs");
|
|
21
22
|
const athenaUrls = require("../lib/athena-urls.cjs");
|
|
22
23
|
const mint = require("../collab/mint.cjs");
|
|
23
24
|
const auth = require("../runtime/auth.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AthenaProvider.cjs","sources":["../../src/provider/AthenaProvider.tsx"],"sourcesContent":["import { AuiProvider } from '@assistant-ui/react';\nimport {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport type { Toolkit } from '@assistant-ui/react';\nimport {\n createDeepAgentThreadSnapshotCache,\n createDeepAgentToolOutputStore,\n DeepAgentConnectionContext,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n} from '@athenaintel/agent-runtime';\nimport {\n assertHostMintedStatewireMount,\n deriveAthenaAppUrl,\n getAthenaEnvironmentUrls,\n resolveStatewireSyncUrl,\n type AthenaEnvironment,\n} from '../lib/athena-urls';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { useParentBridge } from '../runtime/auth';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n useAthenaStatewireRuntime,\n useStatewireClientTools,\n} from '../runtime/useAthenaStatewireRuntime';\nimport {\n athenaStatewireErrorNotice,\n type AthenaStatewireLifecycleState,\n initialStatewireLifecycle,\n statewireLifecycleReducer,\n} from '../runtime/statewire-lifecycle';\nimport type { AthenaStatewireTokenGetter } from '../runtime/statewire-auth-headers';\nimport { resolveAgentProp } from '../runtime/statewire-run-config';\nimport { mintThreadId } from '../threads/mint-thread-id';\nimport { AthenaStatewireLifecycleContext } from './statewire-lifecycle-context';\nimport { StatewireToolOutputsContext } from './statewire-window-context';\nimport { StatewireClientToolBridge } from '../chat/StatewireClientToolBridge';\nimport {\n athenaDiagnostics,\n debugPropToDiagnosticsConfig,\n installAthenaDiagnosticsGlobal,\n type AthenaDiagnosticEvent,\n type AthenaDiagnosticLevel,\n type AthenaDiagnosticsConfig,\n} from '../diagnostics/athena-diagnostics';\nimport type { AthenaSdkError } from '../diagnostics/errors';\nimport { TooltipProvider } from '../ui/tooltip';\nimport { DEFAULT_AUTO_OPEN_TOOLS } from '../tools/auto-open-tools';\nimport { AthenaContext, type AthenaConfig } from './AthenaContext';\nimport type { AthenaProviderConfig } from './config';\nimport type {\n AthenaCitationLinkOptions,\n AthenaLinkClickOptions,\n} from './citation-links';\nimport {\n AthenaStatewireThreadIdContext,\n AthenaThreadIdContext,\n} from '../threads/thread-id-context';\nimport {\n AthenaStatewireThreadListProvider,\n StatewireThreadTitlePoller,\n useAthenaStatewireThreadList,\n} from '../threads/statewire-thread-list';\nimport { useAssetPanelStore } from '../assets/asset-panel-store';\nimport { themeToStyleVars, type AthenaTheme } from '../theme';\nimport { PostHogProvider, type PostHogConfig } from './PostHogProvider';\n\nexport interface AthenaProviderProps {\n children: ReactNode;\n\n /** Preferred structured config for auth and Athena endpoint settings. */\n config?: AthenaProviderConfig;\n\n /** @deprecated Prefer `config.apiKey`. API key for authentication in standalone mode. */\n apiKey?: string;\n\n /** @deprecated Prefer `config.token`. PropelAuth token. If provided, takes priority over apiKey. If omitted, the SDK\n * will automatically listen for a token from the parent window via PostMessage. */\n token?: string | null;\n\n /** Run the thread AS a published collab agent. The only accepted shape is\n * `collab_agent:<asset_id>`: the thread then uses that agent's prompt,\n * tools, and model default, and the caller must have view access to the\n * agent asset. Omit it (or pass a blank string) to run the Athena deep agent.\n *\n * Any other non-blank value throws at render — the statewire host cannot\n * honour named agents, and a selector that is silently dropped would let a\n * misconfigured deployment answer as the wrong agent. */\n agent?: string;\n\n /** Collab-agent channel id — a built-in channel (`email`, `sms`, …) or a\n * user-defined custom channel id from the agent's Channels tab. Selects\n * that channel's configuration overrides and stamps the session's origin.\n * Only meaningful together with a `collab_agent:<asset_id>` `agent`; sent\n * as `collab_channel_id`. An unknown or disabled channel rejects the run\n * with a structured, teaching error. */\n channel?: string;\n\n /** LLM model identifier. Defaults to the deep-agent default model\n * (`DEFAULT_STATEWIRE_MODEL`) — or, when a collab agent is selected, to\n * the model its author configured. */\n model?: string;\n\n /** Backend toolkit IDs to enable (e.g. 'document_toolkit', 'web_search_browse_toolkit'). */\n tools?: string[];\n\n /** Frontend tools that execute in the browser. The agent can invoke these.\n * Merged on top of the SDK's default auto-open tools; entries here take\n * precedence over defaults with the same name. Tools with a local\n * `execute` are declared to the backend as `client_tools` and run through\n * the statewire client-tool bridge. */\n frontendTools?: Toolkit;\n\n /** Disable the SDK's default auto-open behavior for created/touched assets. */\n disableAutoOpen?: boolean;\n\n /** @deprecated Prefer `config.apiUrl`. URL on the Iris host fronting the\n * deployment; its origin derives the statewire sync mount when\n * `statewireSyncUrl` is not set. */\n apiUrl?: string;\n\n /** @deprecated Prefer `config.backendUrl`. URL for the Athena backend API. */\n backendUrl?: string;\n\n /** @deprecated Prefer `config.appUrl`. URL for the Athena frontend app origin. */\n appUrl?: string;\n\n /** @deprecated Prefer `config.environment`. Athena environment preset used when URLs are not explicitly provided. */\n environment?: AthenaEnvironment;\n\n /** Resolve the latest auth token immediately before a request (for\n * expiring clients). Takes priority over `token` when it resolves.\n * Prefer `config.getToken` (see its `force` contract for refused\n * credentials). */\n getToken?: AthenaStatewireTokenGetter;\n\n /** Additional fields merged into runConfig.custom. Prefer\n * `config.extraRunConfig`. */\n extraRunConfig?: Record<string, unknown>;\n\n /** Statewire sync base URL override (the `…/v2/threads` mount). Defaults to\n * the mount a Marathon host mints, then the effective `apiUrl` host +\n * `/v2/threads`. Prefer `config.statewireSyncUrl`. */\n statewireSyncUrl?: string;\n\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n\n /** System prompt override. */\n systemPrompt?: string;\n\n /** Client app identifier for session filtering.\n * Sessions created with this ID can be filtered in the thread list.\n * E.g. \"olympus\", \"athena-app\", or a computer asset ID like \"asset_<uuid>\". */\n appId?: string;\n\n /** Thread ID override. Auto-generated if not provided. */\n threadId?: string;\n\n /** Enable thread list management (sidebar thread switching). */\n enableThreadList?: boolean;\n\n /** Theme configuration. Pass a preset from `themes` or a custom `AthenaTheme` object.\n * Injects CSS variables on a wrapper element — no CSS files needed.\n *\n * @example\n * import { themes } from '@athenaintel/react';\n * <AthenaProvider theme={themes.dark}>\n *\n * @example\n * <AthenaProvider theme={{ primary: '#8b5cf6', radius: '1rem' }}>\n *\n * @example\n * <AthenaProvider theme={{ ...themes.dark, primary: '#22c55e' }}>\n */\n theme?: AthenaTheme;\n\n /** Customize how rendered chat links behave. */\n linkClicks?: AthenaLinkClickOptions;\n\n /** @deprecated Prefer `linkClicks`. Customize how Athena citation links rendered in chat messages behave. */\n citationLinks?: AthenaCitationLinkOptions;\n\n /** PostHog analytics configuration. When omitted or keys are missing, PostHog is silently disabled.\n * Prefer `config.posthog` for structured configuration. */\n posthog?: PostHogConfig;\n\n /** SDK diagnostics.\n *\n * - `true` / a level: echo structured `[AthenaSDK]` events to the console\n * at that level (`true` = 'debug').\n * - An object: full diagnostics config (console level, PostHog timing\n * forwarding, buffer size).\n *\n * Independent of the prop, `localStorage.setItem('athena:debug','debug')`\n * (or `window.__ATHENA_SDK__.diagnostics.enableConsole()`) turns console\n * echo on at runtime without a rebuild. Errors log once even when off. */\n debug?: boolean | AthenaDiagnosticLevel | Partial<AthenaDiagnosticsConfig>;\n\n /** Receives every diagnostics event (timings, warnings, errors) — the hook\n * for shipping SDK telemetry to the host app's own pipeline. */\n onDiagnostic?: (event: AthenaDiagnosticEvent) => void;\n\n /** Receives every SDK error as a typed `AthenaSdkError` (stable `code`,\n * `hint`, structured server `detail`). Fires in addition to the UI's own\n * error handling, so integrations never fail silently. */\n onError?: (error: AthenaSdkError, event: AthenaDiagnosticEvent) => void;\n}\n\nconst resolveTokenOverride = ({\n config,\n token,\n}: {\n config?: AthenaProviderConfig;\n token?: string | null;\n}): string | null | undefined => {\n if (config?.token !== undefined) {\n return config.token;\n }\n return token;\n};\n\nconst useAthenaConfigValue = ({\n backendUrl,\n appUrl,\n apiKey,\n token,\n enabledToolkits,\n linkClicks,\n citationLinks,\n}: {\n backendUrl: string;\n appUrl: string;\n apiKey?: string;\n token?: string | null;\n enabledToolkits: string[];\n linkClicks?: AthenaLinkClickOptions;\n citationLinks?: AthenaCitationLinkOptions;\n}): AthenaConfig => {\n const linkClicksRef = useRef(linkClicks);\n linkClicksRef.current = linkClicks;\n const citationLinksRef = useRef(citationLinks);\n citationLinksRef.current = citationLinks;\n // Keep token in a ref so its value can update without invalidating the\n // config object identity. PropelAuth rotates tokens on window focus —\n // if token were a memo dep, every rotation would publish a new config\n // object to context and force every consumer (e.g. AssetIframe) to\n // re-render, causing asset panel flicker.\n const tokenRef = useRef(token);\n tokenRef.current = token;\n\n return useMemo(\n () => ({\n backendUrl,\n appUrl,\n apiKey,\n enabledToolkits,\n get token() {\n return tokenRef.current;\n },\n get linkClicks() {\n return linkClicksRef.current;\n },\n get citationLinks() {\n return citationLinksRef.current;\n },\n }),\n [backendUrl, appUrl, apiKey, enabledToolkits],\n );\n};\n\n// ─── Standalone Mode ──────────────────────────────────────────────────\n\nfunction AthenaStatewireStandalone({\n children,\n syncUrl,\n backendUrl,\n appUrl,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n frontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n threadId: threadIdProp,\n isNewChatOverride,\n snapshotCache,\n toolOutputs,\n linkClicks,\n citationLinks,\n}: {\n children: ReactNode;\n syncUrl: string;\n backendUrl: string;\n appUrl: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n model?: string;\n agent?: string;\n channel?: string;\n tools: string[];\n frontendToolIds: string[];\n frontendTools: Toolkit;\n workbench?: string[];\n knowledgeBase?: string[];\n systemPrompt?: string;\n appId?: string;\n extraRunConfig?: Record<string, unknown>;\n threadId?: string;\n /** Overrides the \"new chat\" derivation (thread-list mode mints ids for\n * brand-new chats, which must still load as new). */\n isNewChatOverride?: boolean;\n /** The provider-owned snapshot cache (see `AthenaProvider`). */\n snapshotCache: DeepAgentThreadSnapshotCache;\n /** The provider-owned store of fetched-back cut tool outputs (see `AthenaProvider`). */\n toolOutputs: DeepAgentToolOutputStore;\n linkClicks?: AthenaLinkClickOptions;\n citationLinks?: AthenaCitationLinkOptions;\n}) {\n // Statewire attaches to `${syncUrl}/${threadId}`, so a thread ID must exist\n // up front. An auto-generated ID is by definition a never-started local chat.\n const generatedIdRef = useRef<string | null>(null);\n if (generatedIdRef.current === null) {\n generatedIdRef.current = mintThreadId();\n }\n const threadId = threadIdProp ?? generatedIdRef.current;\n\n const [lifecycle, dispatchLifecycle] = useReducer(\n statewireLifecycleReducer,\n initialStatewireLifecycle,\n );\n\n const aui = useAthenaStatewireRuntime({\n syncUrl,\n threadId,\n isNewChat: isNewChatOverride ?? !threadIdProp,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n frontendToolkit: frontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n toolOutputs,\n // The runtime already records every transport error on the diagnostics\n // bus (with the channel-teardown split), so this layer only maps it to\n // the banner notice.\n onError: (error) => {\n const notice = athenaStatewireErrorNotice(error);\n if (notice) dispatchLifecycle({ type: 'error', error: notice });\n },\n onConnectionChange: (connection) => {\n dispatchLifecycle({ type: 'connection', connection });\n },\n onRawConnectionChange: (connection) => {\n dispatchLifecycle({ type: 'raw-connection', reconnect: connection.reconnect });\n },\n });\n\n const clientTools = useStatewireClientTools(frontendTools);\n\n const dismissError = useCallback(\n () => dispatchLifecycle({ type: 'error', error: null }),\n [],\n );\n const lifecycleValue = useMemo<AthenaStatewireLifecycleState>(\n () => ({\n connection: lifecycle.connection,\n error: lifecycle.error,\n reconnect: lifecycle.reconnect,\n dismissError,\n }),\n [lifecycle, dismissError],\n );\n\n const athenaConfig = useAthenaConfigValue({\n backendUrl,\n appUrl,\n apiKey,\n token,\n enabledToolkits: tools,\n linkClicks,\n citationLinks,\n });\n\n return (\n <AuiProvider value={aui}>\n <AthenaContext.Provider value={athenaConfig}>\n <AthenaStatewireThreadIdContext.Provider value={threadId}>\n <AthenaStatewireLifecycleContext.Provider value={lifecycleValue}>\n <DeepAgentConnectionContext.Provider value={lifecycleValue.connection}>\n <StatewireToolOutputsContext.Provider value={toolOutputs}>\n <TooltipProvider>\n <StatewireClientToolBridge tools={clientTools} threadId={threadId} />\n {children}\n </TooltipProvider>\n </StatewireToolOutputsContext.Provider>\n </DeepAgentConnectionContext.Provider>\n </AthenaStatewireLifecycleContext.Provider>\n </AthenaStatewireThreadIdContext.Provider>\n </AthenaContext.Provider>\n </AuiProvider>\n );\n}\n\n// ─── Thread List Mode ─────────────────────────────────────────────────\n\nfunction AthenaStatewireWithThreadList({\n children,\n backendUrl,\n syncUrl,\n appId,\n apiKey,\n token,\n getToken,\n initialThreadId,\n ...standaloneProps\n}: Omit<\n Parameters<typeof AthenaStatewireStandalone>[0],\n 'threadId' | 'isNewChatOverride'\n> & {\n initialThreadId?: string;\n}) {\n return (\n <AthenaStatewireThreadListProvider\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n appId={appId}\n initialThreadId={initialThreadId}\n >\n <AthenaStatewireActiveThreadHost\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n appId={appId}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n {...standaloneProps}\n >\n {children}\n </AthenaStatewireActiveThreadHost>\n </AthenaStatewireThreadListProvider>\n );\n}\n\nfunction AthenaStatewireActiveThreadHost({\n children,\n ...standaloneProps\n}: Omit<\n Parameters<typeof AthenaStatewireStandalone>[0],\n 'threadId' | 'isNewChatOverride'\n>) {\n const list = useAthenaStatewireThreadList();\n if (!list) return null;\n\n // Keyed by thread id: a switch remounts the statewire session against the\n // new `…/v2/threads/{id}` URL instead of importing history in place. The\n // thread-id context is undefined for a never-started chat, so\n // history-gated UI (e.g. the loading overlay) does not treat an\n // intentionally-empty new chat as pending history.\n return (\n <AthenaThreadIdContext.Provider\n value={list.isNewChat ? undefined : list.activeThreadId}\n >\n <AthenaStatewireStandalone\n key={list.activeThreadId}\n threadId={list.activeThreadId}\n isNewChatOverride={list.isNewChat}\n {...standaloneProps}\n >\n <StatewireThreadTitlePoller />\n <AssetPanelThreadSync />\n {children}\n </AthenaStatewireStandalone>\n </AthenaThreadIdContext.Provider>\n );\n}\n\n/**\n * Syncs the active thread ID into the asset panel store so that open asset\n * tabs are scoped per-thread automatically.\n *\n * Scoped by the thread list's minted id from creation onward — NOT by\n * `useAthenaThreadManager().activeThreadId`, which is deliberately `null`\n * while a new chat is unpersisted (so URL sync never names it). The minted id\n * is the id the thread persists under, so tabs opened in a brand-new chat\n * stay put when the backend first lists it instead of being left behind in a\n * `null` scope the store never restores.\n */\nfunction AssetPanelThreadSync() {\n const list = useAthenaStatewireThreadList();\n const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);\n const activeThreadId = list?.activeThreadId ?? null;\n\n useEffect(() => {\n setCurrentThread(activeThreadId);\n }, [activeThreadId, setCurrentThread]);\n\n return null;\n}\n\n// ─── Main Provider ────────────────────────────────────────────────────\n\nexport function AthenaProvider({\n children,\n config,\n apiKey,\n token: tokenProp,\n agent,\n channel,\n model,\n tools = [],\n frontendTools = {},\n disableAutoOpen = false,\n apiUrl,\n backendUrl,\n appUrl,\n environment,\n statewireSyncUrl,\n getToken,\n extraRunConfig,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n threadId: threadIdProp,\n enableThreadList = false,\n theme,\n linkClicks,\n citationLinks,\n posthog: posthogProp,\n debug,\n onDiagnostic,\n onError,\n}: AthenaProviderProps) {\n // Fail loud before any effect, bridge wait, or network call: an `agent`\n // outside the collab_agent namespace can never apply, so a misconfigured\n // deployment must die at first render rather than answer as the wrong agent.\n resolveAgentProp({ agent });\n\n // Diagnostics wiring first, so everything below is observable. Callbacks\n // ride refs: a per-render closure must not re-register the consumer. Each\n // provider registers its OWN consumer (additive, cleaned up on unmount), so\n // two mounted providers never clobber each other's onDiagnostic/onError —\n // only the console/PostHog/buffer settings are global (last writer wins).\n const onDiagnosticRef = useRef(onDiagnostic);\n onDiagnosticRef.current = onDiagnostic;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n useEffect(() => {\n installAthenaDiagnosticsGlobal();\n return athenaDiagnostics.addConsumer({\n onEvent: (event) => onDiagnosticRef.current?.(event),\n onError: (error, event) => onErrorRef.current?.(error, event),\n });\n }, []);\n const debugKey = JSON.stringify(debugPropToDiagnosticsConfig(debug));\n useEffect(() => {\n athenaDiagnostics.configure(debugPropToDiagnosticsConfig(debug));\n // debugKey is the value-stable form of `debug` (consumers pass literals).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debugKey]);\n const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);\n // Merge SDK auto-open defaults under the consumer's frontendTools. Consumer\n // entries win on name collision; auto-open tool names are NOT added to\n // frontendToolIds (they are already backend-advertised by their toolkits).\n const effectiveFrontendTools = useMemo<Toolkit>(\n () => (disableAutoOpen ? frontendTools : { ...DEFAULT_AUTO_OPEN_TOOLS, ...frontendTools }),\n [disableAutoOpen, frontendTools],\n );\n const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : undefined, [theme]);\n const configuredEnvironment = config?.environment ?? environment;\n const environmentUrls = useMemo(\n () => getAthenaEnvironmentUrls({ environment: configuredEnvironment }),\n [configuredEnvironment],\n );\n const configuredApiKey = config?.apiKey ?? apiKey;\n const configuredToken = resolveTokenOverride({ config, token: tokenProp });\n const configuredApiUrl = config?.apiUrl ?? apiUrl;\n const configuredBackendUrl = config?.backendUrl ?? backendUrl;\n const configuredAppUrl = config?.appUrl ?? appUrl;\n const configuredStatewireSyncUrl = config?.statewireSyncUrl ?? statewireSyncUrl;\n const configuredGetToken = config?.getToken ?? getToken;\n const configuredExtraRunConfig = config?.extraRunConfig ?? extraRunConfig;\n const configuredTrustedParentOrigins = config?.trustedParentOrigins;\n const posthogConfig: PostHogConfig | undefined = config?.posthog ?? posthogProp;\n\n // Statewire is the SDK's only chat transport; the gauge/event stay on the\n // diagnostics contract so dashboards keyed on them keep reading a value.\n useEffect(() => {\n athenaDiagnostics.gauge('sdk.transport', 'statewire');\n athenaDiagnostics.emit('sdk.transport', {\n level: 'debug',\n data: { transport: 'statewire', thread_list: enableThreadList },\n });\n }, [enableThreadList]);\n\n const bridge = useParentBridge({\n trustedOrigins: configuredTrustedParentOrigins,\n });\n\n // If an AthenaAuthProvider is present above us, use its access token automatically.\n const authContext = useContext(AthenaAuthContext);\n const authProviderToken = authContext?.accessToken ?? null;\n\n // Per-provider snapshot cache: a switch back to a recently-visited thread\n // mounts with its last-known snapshot instead of a loading spinner. Owned\n // here, above the per-thread keyed mount, so it survives switches; cleared\n // when the acting identity changes so a snapshot captured under one account\n // never seeds a mount under another.\n const [snapshotCache] = useState(() => createDeepAgentThreadSnapshotCache());\n // The windowed wire's fetched-back tool outputs, owned alongside the cache\n // for the same reasons: shared across the provider's thread switches (a\n // tool message id is unique across threads), dropped with the identity.\n const [toolOutputs] = useState(() => createDeepAgentToolOutputStore());\n const principal = authContext?.user?.userId ?? '';\n useEffect(() => {\n snapshotCache.clear();\n toolOutputs.clear();\n }, [snapshotCache, toolOutputs, principal, configuredApiKey]);\n\n const effectiveToken = configuredToken !== undefined\n ? configuredToken\n : authProviderToken ?? bridge.token;\n // Explicit config wins. A Marathon host mints the statewire mount, the bare\n // Agora base and the app origin outright (`/_athena/auth`, or a trusted\n // parent's `athena-config`); the environment preset is the last resort, and\n // the sync mount derives from the `apiUrl` host when no host minted one.\n const effectiveApiUrl = configuredApiUrl ?? environmentUrls.apiUrl;\n // Published as the bare Agora base: a historical `…/api/assistant-ui` value\n // is trimmed here once rather than by each REST helper.\n const effectiveBackendUrl = getAthenaApiBaseUrl(\n configuredBackendUrl ?? bridge.backendBaseUrl ?? environmentUrls.backendUrl,\n );\n const hostStatewireSyncUrl = configuredStatewireSyncUrl ?? bridge.statewireSyncUrl ?? undefined;\n const effectiveAppUrl = configuredAppUrl\n ?? bridge.appUrl\n ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl })\n ?? environmentUrls.appUrl;\n\n // Wait for the parent bridge to deliver config/auth before rendering.\n // This prevents the thread list from fetching with wrong URLs or no token.\n // Falls back after a short timeout (2s) if no bridge responds.\n if (!bridge.ready) {\n return null;\n }\n\n // Both throw on an unresolvable configuration instead of falling back to an\n // Athena default — a custom deployment's credentials must never be sent to\n // a host the consumer didn't configure. A host that answered the bridge\n // without minting the statewire mount is that case: its token would\n // otherwise ride the environment preset.\n assertHostMintedStatewireMount({\n hostAnswered: bridge.hostAnswered,\n hostStatewireSyncUrl: bridge.statewireSyncUrl,\n statewireSyncUrl: configuredStatewireSyncUrl,\n apiUrl: configuredApiUrl,\n });\n const effectiveStatewireSyncUrl = resolveStatewireSyncUrl({\n statewireSyncUrl: hostStatewireSyncUrl,\n apiUrl: effectiveApiUrl,\n });\n\n const statewireProps = {\n syncUrl: effectiveStatewireSyncUrl,\n backendUrl: effectiveBackendUrl,\n appUrl: effectiveAppUrl,\n apiKey: configuredApiKey,\n token: effectiveToken,\n getToken: configuredGetToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds: frontendToolNames,\n frontendTools: effectiveFrontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig: configuredExtraRunConfig,\n snapshotCache,\n toolOutputs,\n linkClicks,\n citationLinks,\n };\n\n const inner: ReactNode = enableThreadList ? (\n <AthenaStatewireWithThreadList {...statewireProps} initialThreadId={threadIdProp}>\n {children}\n </AthenaStatewireWithThreadList>\n ) : (\n <AthenaStatewireStandalone {...statewireProps} threadId={threadIdProp}>\n {children}\n </AthenaStatewireStandalone>\n );\n\n // The .athena-sdk wrapper (display: contents) anchors the SDK's design\n // tokens and scoped preflight from styles.css, so the stylesheet works\n // in hosts without their own Tailwind build. PostHog gracefully no-ops\n // when its config is missing.\n return (\n <div\n className={themeStyleVars ? \"athena-sdk athena-themed\" : \"athena-sdk\"}\n style={themeStyleVars as React.CSSProperties | undefined}\n >\n <PostHogProvider config={posthogConfig}>\n {inner}\n </PostHogProvider>\n </div>\n );\n}\n"],"names":["useRef","useMemo","toolOutputs","mintThreadId","useReducer","statewireLifecycleReducer","initialStatewireLifecycle","useAthenaStatewireRuntime","athenaStatewireErrorNotice","useStatewireClientTools","useCallback","AuiProvider","jsx","AthenaContext","AthenaStatewireThreadIdContext","AthenaStatewireLifecycleContext","DeepAgentConnectionContext","StatewireToolOutputsContext","TooltipProvider","StatewireClientToolBridge","AthenaStatewireThreadListProvider","useAthenaStatewireThreadList","AthenaThreadIdContext","jsxs","StatewireThreadTitlePoller","useAssetPanelStore","useEffect","resolveAgentProp","installAthenaDiagnosticsGlobal","athenaDiagnostics","_a","debugPropToDiagnosticsConfig","DEFAULT_AUTO_OPEN_TOOLS","themeToStyleVars","getAthenaEnvironmentUrls","useParentBridge","useContext","AthenaAuthContext","useState","createDeepAgentThreadSnapshotCache","createDeepAgentToolOutputStore","getAthenaApiBaseUrl","deriveAthenaAppUrl","assertHostMintedStatewireMount","resolveStatewireSyncUrl","PostHogProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4NA,MAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGiC;AAC/B,OAAI,iCAAQ,WAAU,QAAW;AAC/B,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;AAEA,MAAM,uBAA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AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IAAA,aACA1C;AAAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,QAAmB,mBACvBU,2BAAAA,IAAC,+BAAA,EAA+B,GAAG,gBAAgB,iBAAiB,cACjE,SAAA,CACH,mCAEC,2BAAA,EAA2B,GAAG,gBAAgB,UAAU,cACtD,UACH;AAOF,SACEA,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,iBAAiB,6BAA6B;AAAA,MACzD,OAAO;AAAA,MAEP,UAAAA,2BAAAA,IAACiC,iCAAA,EAAgB,QAAQ,eACtB,UAAA,MAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
|
1
|
+
{"version":3,"file":"AthenaProvider.cjs","sources":["../../src/provider/AthenaProvider.tsx"],"sourcesContent":["import { AuiProvider } from '@assistant-ui/react';\nimport {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport type { Toolkit } from '@assistant-ui/react';\nimport {\n createDeepAgentThreadSnapshotCache,\n createDeepAgentToolOutputStore,\n DeepAgentConnectionContext,\n type DeepAgentThreadSnapshotCache,\n type DeepAgentToolOutputStore,\n} from '@athenaintel/agent-runtime';\nimport {\n assertHostMintedStatewireMount,\n deriveAthenaAppUrl,\n getAthenaEnvironmentUrls,\n resolveStatewireSyncUrl,\n type AthenaEnvironment,\n} from '../lib/athena-urls';\nimport { getAthenaApiBaseUrl } from '../collab/mint';\nimport { useParentBridge } from '../runtime/auth';\nimport { AthenaAuthContext } from '../auth/AthenaAuthContext';\nimport {\n useAthenaStatewireRuntime,\n useStatewireClientTools,\n} from '../runtime/useAthenaStatewireRuntime';\nimport {\n athenaStatewireErrorNotice,\n type AthenaStatewireLifecycleState,\n initialStatewireLifecycle,\n statewireLifecycleReducer,\n} from '../runtime/statewire-lifecycle';\nimport type { AthenaStatewireTokenGetter } from '../runtime/statewire-auth-headers';\nimport { resolveAgentProp } from '../runtime/statewire-run-config';\nimport { mintThreadId } from '../threads/mint-thread-id';\nimport { AthenaStatewireLifecycleContext } from './statewire-lifecycle-context';\nimport { StatewireToolOutputsContext } from './statewire-window-context';\nimport { StatewireClientToolBridge } from '../chat/StatewireClientToolBridge';\nimport {\n athenaDiagnostics,\n debugPropToDiagnosticsConfig,\n installAthenaDiagnosticsGlobal,\n type AthenaDiagnosticEvent,\n type AthenaDiagnosticLevel,\n type AthenaDiagnosticsConfig,\n} from '../diagnostics/athena-diagnostics';\nimport type { AthenaSdkError } from '../diagnostics/errors';\nimport { TooltipProvider } from '../ui/tooltip';\nimport { DEFAULT_AUTO_OPEN_TOOLS } from '../tools/auto-open-tools';\nimport { AthenaContext, type AthenaConfig } from './AthenaContext';\nimport type { AthenaProviderConfig } from './config';\nimport type {\n AthenaCitationLinkOptions,\n AthenaLinkClickOptions,\n} from './citation-links';\nimport {\n AthenaStatewireThreadIdContext,\n AthenaThreadIdContext,\n} from '../threads/thread-id-context';\nimport {\n AthenaStatewireThreadListProvider,\n StatewireThreadTitlePoller,\n useAthenaStatewireThreadList,\n} from '../threads/statewire-thread-list';\nimport { useAssetPanelStore } from '../assets/asset-panel-store';\nimport { themeToStyleVars, type AthenaTheme } from '../theme';\nimport { PostHogProvider, type PostHogConfig } from './PostHogProvider';\n\nexport interface AthenaProviderProps {\n children: ReactNode;\n\n /** Preferred structured config for auth and Athena endpoint settings. */\n config?: AthenaProviderConfig;\n\n /** @deprecated Prefer `config.apiKey`. API key for authentication in standalone mode. */\n apiKey?: string;\n\n /** @deprecated Prefer `config.token`. PropelAuth token. If provided, takes priority over apiKey. If omitted, the SDK\n * will automatically listen for a token from the parent window via PostMessage. */\n token?: string | null;\n\n /** Run the thread AS a published collab agent. The only accepted shape is\n * `collab_agent:<asset_id>`: the thread then uses that agent's prompt,\n * tools, and model default, and the caller must have view access to the\n * agent asset. Omit it (or pass a blank string) to run the Athena deep agent.\n *\n * Any other non-blank value throws at render — the statewire host cannot\n * honour named agents, and a selector that is silently dropped would let a\n * misconfigured deployment answer as the wrong agent. */\n agent?: string;\n\n /** Collab-agent channel id — a built-in channel (`email`, `sms`, …) or a\n * user-defined custom channel id from the agent's Channels tab. Selects\n * that channel's configuration overrides and stamps the session's origin.\n * Only meaningful together with a `collab_agent:<asset_id>` `agent`; sent\n * as `collab_channel_id`. An unknown or disabled channel rejects the run\n * with a structured, teaching error. */\n channel?: string;\n\n /** LLM model identifier. Defaults to the deep-agent default model\n * (`DEFAULT_STATEWIRE_MODEL`) — or, when a collab agent is selected, to\n * the model its author configured. */\n model?: string;\n\n /** Backend toolkit IDs to enable (e.g. 'document_toolkit', 'web_search_browse_toolkit'). */\n tools?: string[];\n\n /** Frontend tools that execute in the browser. The agent can invoke these.\n * Merged on top of the SDK's default auto-open tools; entries here take\n * precedence over defaults with the same name. Tools with a local\n * `execute` are declared to the backend as `client_tools` and run through\n * the statewire client-tool bridge. */\n frontendTools?: Toolkit;\n\n /** Disable the SDK's default auto-open behavior for created/touched assets. */\n disableAutoOpen?: boolean;\n\n /** @deprecated Prefer `config.apiUrl`. URL on the Iris host fronting the\n * deployment; its origin derives the statewire sync mount when\n * `statewireSyncUrl` is not set. */\n apiUrl?: string;\n\n /** @deprecated Prefer `config.backendUrl`. URL for the Athena backend API. */\n backendUrl?: string;\n\n /** @deprecated Prefer `config.appUrl`. URL for the Athena frontend app origin. */\n appUrl?: string;\n\n /** @deprecated Prefer `config.environment`. Athena environment preset used when URLs are not explicitly provided. */\n environment?: AthenaEnvironment;\n\n /** Resolve the latest auth token immediately before a request (for\n * expiring clients). Takes priority over `token` when it resolves.\n * Prefer `config.getToken` (see its `force` contract for refused\n * credentials). */\n getToken?: AthenaStatewireTokenGetter;\n\n /** Additional fields merged into runConfig.custom. Prefer\n * `config.extraRunConfig`. */\n extraRunConfig?: Record<string, unknown>;\n\n /** Statewire sync base URL override (the `…/v2/threads` mount). Defaults to\n * the mount a Marathon host mints, then the effective `apiUrl` host +\n * `/v2/threads`. Prefer `config.statewireSyncUrl`. */\n statewireSyncUrl?: string;\n\n /** Asset IDs to include in the workbench. */\n workbench?: string[];\n\n /** Knowledge base IDs for RAG context. */\n knowledgeBase?: string[];\n\n /** System prompt override. */\n systemPrompt?: string;\n\n /** Client app identifier for session filtering.\n * Sessions created with this ID can be filtered in the thread list.\n * E.g. \"olympus\", \"athena-app\", or a computer asset ID like \"asset_<uuid>\". */\n appId?: string;\n\n /** Thread ID override. Auto-generated if not provided. */\n threadId?: string;\n\n /** Enable thread list management (sidebar thread switching). */\n enableThreadList?: boolean;\n\n /** Theme configuration. Pass a preset from `themes` or a custom `AthenaTheme` object.\n * Injects CSS variables on a wrapper element — no CSS files needed.\n *\n * @example\n * import { themes } from '@athenaintel/react';\n * <AthenaProvider theme={themes.dark}>\n *\n * @example\n * <AthenaProvider theme={{ primary: '#8b5cf6', radius: '1rem' }}>\n *\n * @example\n * <AthenaProvider theme={{ ...themes.dark, primary: '#22c55e' }}>\n */\n theme?: AthenaTheme;\n\n /** Customize how rendered chat links behave. */\n linkClicks?: AthenaLinkClickOptions;\n\n /** @deprecated Prefer `linkClicks`. Customize how Athena citation links rendered in chat messages behave. */\n citationLinks?: AthenaCitationLinkOptions;\n\n /** PostHog analytics configuration. When omitted or keys are missing, PostHog is silently disabled.\n * Prefer `config.posthog` for structured configuration. */\n posthog?: PostHogConfig;\n\n /** SDK diagnostics.\n *\n * - `true` / a level: echo structured `[AthenaSDK]` events to the console\n * at that level (`true` = 'debug').\n * - An object: full diagnostics config (console level, PostHog timing\n * forwarding, buffer size).\n *\n * Independent of the prop, `localStorage.setItem('athena:debug','debug')`\n * (or `window.__ATHENA_SDK__.diagnostics.enableConsole()`) turns console\n * echo on at runtime without a rebuild. Errors log once even when off. */\n debug?: boolean | AthenaDiagnosticLevel | Partial<AthenaDiagnosticsConfig>;\n\n /** Receives every diagnostics event (timings, warnings, errors) — the hook\n * for shipping SDK telemetry to the host app's own pipeline. */\n onDiagnostic?: (event: AthenaDiagnosticEvent) => void;\n\n /** Receives every SDK error as a typed `AthenaSdkError` (stable `code`,\n * `hint`, structured server `detail`). Fires in addition to the UI's own\n * error handling, so integrations never fail silently. */\n onError?: (error: AthenaSdkError, event: AthenaDiagnosticEvent) => void;\n}\n\nconst resolveTokenOverride = ({\n config,\n token,\n}: {\n config?: AthenaProviderConfig;\n token?: string | null;\n}): string | null | undefined => {\n if (config?.token !== undefined) {\n return config.token;\n }\n return token;\n};\n\nconst useAthenaConfigValue = ({\n backendUrl,\n appUrl,\n apiKey,\n token,\n enabledToolkits,\n linkClicks,\n citationLinks,\n}: {\n backendUrl: string;\n appUrl: string;\n apiKey?: string;\n token?: string | null;\n enabledToolkits: string[];\n linkClicks?: AthenaLinkClickOptions;\n citationLinks?: AthenaCitationLinkOptions;\n}): AthenaConfig => {\n const linkClicksRef = useRef(linkClicks);\n linkClicksRef.current = linkClicks;\n const citationLinksRef = useRef(citationLinks);\n citationLinksRef.current = citationLinks;\n // Keep token in a ref so its value can update without invalidating the\n // config object identity. PropelAuth rotates tokens on window focus —\n // if token were a memo dep, every rotation would publish a new config\n // object to context and force every consumer (e.g. AssetIframe) to\n // re-render, causing asset panel flicker.\n const tokenRef = useRef(token);\n tokenRef.current = token;\n\n return useMemo(\n () => ({\n backendUrl,\n appUrl,\n apiKey,\n enabledToolkits,\n get token() {\n return tokenRef.current;\n },\n get linkClicks() {\n return linkClicksRef.current;\n },\n get citationLinks() {\n return citationLinksRef.current;\n },\n }),\n [backendUrl, appUrl, apiKey, enabledToolkits],\n );\n};\n\n// ─── Standalone Mode ──────────────────────────────────────────────────\n\nfunction AthenaStatewireStandalone({\n children,\n syncUrl,\n backendUrl,\n appUrl,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n frontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n threadId: threadIdProp,\n isNewChatOverride,\n snapshotCache,\n toolOutputs,\n linkClicks,\n citationLinks,\n}: {\n children: ReactNode;\n syncUrl: string;\n backendUrl: string;\n appUrl: string;\n apiKey?: string;\n token?: string | null;\n getToken?: AthenaStatewireTokenGetter;\n model?: string;\n agent?: string;\n channel?: string;\n tools: string[];\n frontendToolIds: string[];\n frontendTools: Toolkit;\n workbench?: string[];\n knowledgeBase?: string[];\n systemPrompt?: string;\n appId?: string;\n extraRunConfig?: Record<string, unknown>;\n threadId?: string;\n /** Overrides the \"new chat\" derivation (thread-list mode mints ids for\n * brand-new chats, which must still load as new). */\n isNewChatOverride?: boolean;\n /** The provider-owned snapshot cache (see `AthenaProvider`). */\n snapshotCache: DeepAgentThreadSnapshotCache;\n /** The provider-owned store of fetched-back cut tool outputs (see `AthenaProvider`). */\n toolOutputs: DeepAgentToolOutputStore;\n linkClicks?: AthenaLinkClickOptions;\n citationLinks?: AthenaCitationLinkOptions;\n}) {\n // Statewire attaches to `${syncUrl}/${threadId}`, so a thread ID must exist\n // up front. An auto-generated ID is by definition a never-started local chat.\n const generatedIdRef = useRef<string | null>(null);\n if (generatedIdRef.current === null) {\n generatedIdRef.current = mintThreadId();\n }\n const threadId = threadIdProp ?? generatedIdRef.current;\n\n const [lifecycle, dispatchLifecycle] = useReducer(\n statewireLifecycleReducer,\n initialStatewireLifecycle,\n );\n\n const aui = useAthenaStatewireRuntime({\n syncUrl,\n threadId,\n isNewChat: isNewChatOverride ?? !threadIdProp,\n apiKey,\n token,\n getToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds,\n frontendToolkit: frontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig,\n snapshotCache,\n toolOutputs,\n // The runtime already records every transport error on the diagnostics\n // bus (with the channel-teardown split), so this layer only maps it to\n // the banner notice.\n onError: (error) => {\n const notice = athenaStatewireErrorNotice(error);\n if (notice) dispatchLifecycle({ type: 'error', error: notice });\n },\n onConnectionChange: (connection) => {\n dispatchLifecycle({ type: 'connection', connection });\n },\n onRawConnectionChange: (connection) => {\n dispatchLifecycle({ type: 'raw-connection', reconnect: connection.reconnect });\n },\n });\n\n const clientTools = useStatewireClientTools(frontendTools);\n\n const dismissError = useCallback(\n () => dispatchLifecycle({ type: 'error', error: null }),\n [],\n );\n const lifecycleValue = useMemo<AthenaStatewireLifecycleState>(\n () => ({\n connection: lifecycle.connection,\n error: lifecycle.error,\n reconnect: lifecycle.reconnect,\n dismissError,\n }),\n [lifecycle, dismissError],\n );\n\n const athenaConfig = useAthenaConfigValue({\n backendUrl,\n appUrl,\n apiKey,\n token,\n enabledToolkits: tools,\n linkClicks,\n citationLinks,\n });\n\n return (\n <AuiProvider value={aui}>\n <AthenaContext.Provider value={athenaConfig}>\n <AthenaStatewireThreadIdContext.Provider value={threadId}>\n <AthenaStatewireLifecycleContext.Provider value={lifecycleValue}>\n <DeepAgentConnectionContext.Provider value={lifecycleValue.connection}>\n <StatewireToolOutputsContext.Provider value={toolOutputs}>\n <TooltipProvider>\n <StatewireClientToolBridge tools={clientTools} threadId={threadId} />\n {children}\n </TooltipProvider>\n </StatewireToolOutputsContext.Provider>\n </DeepAgentConnectionContext.Provider>\n </AthenaStatewireLifecycleContext.Provider>\n </AthenaStatewireThreadIdContext.Provider>\n </AthenaContext.Provider>\n </AuiProvider>\n );\n}\n\n// ─── Thread List Mode ─────────────────────────────────────────────────\n\nfunction AthenaStatewireWithThreadList({\n children,\n backendUrl,\n syncUrl,\n appId,\n apiKey,\n token,\n getToken,\n initialThreadId,\n ...standaloneProps\n}: Omit<\n Parameters<typeof AthenaStatewireStandalone>[0],\n 'threadId' | 'isNewChatOverride'\n> & {\n initialThreadId?: string;\n}) {\n return (\n <AthenaStatewireThreadListProvider\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n appId={appId}\n initialThreadId={initialThreadId}\n >\n <AthenaStatewireActiveThreadHost\n backendUrl={backendUrl}\n syncUrl={syncUrl}\n appId={appId}\n apiKey={apiKey}\n token={token}\n getToken={getToken}\n {...standaloneProps}\n >\n {children}\n </AthenaStatewireActiveThreadHost>\n </AthenaStatewireThreadListProvider>\n );\n}\n\nfunction AthenaStatewireActiveThreadHost({\n children,\n ...standaloneProps\n}: Omit<\n Parameters<typeof AthenaStatewireStandalone>[0],\n 'threadId' | 'isNewChatOverride'\n>) {\n const list = useAthenaStatewireThreadList();\n if (!list) return null;\n\n // Keyed by thread id: a switch remounts the statewire session against the\n // new `…/v2/threads/{id}` URL instead of importing history in place. The\n // thread-id context is undefined for a never-started chat, so\n // history-gated UI (e.g. the loading overlay) does not treat an\n // intentionally-empty new chat as pending history.\n return (\n <AthenaThreadIdContext.Provider\n value={list.isNewChat ? undefined : list.activeThreadId}\n >\n <AthenaStatewireStandalone\n key={list.activeThreadId}\n threadId={list.activeThreadId}\n isNewChatOverride={list.isNewChat}\n {...standaloneProps}\n >\n <StatewireThreadTitlePoller />\n <AssetPanelThreadSync />\n {children}\n </AthenaStatewireStandalone>\n </AthenaThreadIdContext.Provider>\n );\n}\n\n/**\n * Syncs the active thread ID into the asset panel store so that open asset\n * tabs are scoped per-thread automatically.\n *\n * Scoped by the thread list's minted id from creation onward — NOT by\n * `useAthenaThreadManager().activeThreadId`, which is deliberately `null`\n * while a new chat is unpersisted (so URL sync never names it). The minted id\n * is the id the thread persists under, so tabs opened in a brand-new chat\n * stay put when the backend first lists it instead of being left behind in a\n * `null` scope the store never restores.\n */\nfunction AssetPanelThreadSync() {\n const list = useAthenaStatewireThreadList();\n const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);\n const activeThreadId = list?.activeThreadId ?? null;\n\n useEffect(() => {\n setCurrentThread(activeThreadId);\n }, [activeThreadId, setCurrentThread]);\n\n return null;\n}\n\n// ─── Main Provider ────────────────────────────────────────────────────\n\nexport function AthenaProvider({\n children,\n config,\n apiKey,\n token: tokenProp,\n agent,\n channel,\n model,\n tools = [],\n frontendTools = {},\n disableAutoOpen = false,\n apiUrl,\n backendUrl,\n appUrl,\n environment,\n statewireSyncUrl,\n getToken,\n extraRunConfig,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n threadId: threadIdProp,\n enableThreadList = false,\n theme,\n linkClicks,\n citationLinks,\n posthog: posthogProp,\n debug,\n onDiagnostic,\n onError,\n}: AthenaProviderProps) {\n // Fail loud before any effect, bridge wait, or network call: an `agent`\n // outside the collab_agent namespace can never apply, so a misconfigured\n // deployment must die at first render rather than answer as the wrong agent.\n resolveAgentProp({ agent });\n\n // Diagnostics wiring first, so everything below is observable. Callbacks\n // ride refs: a per-render closure must not re-register the consumer. Each\n // provider registers its OWN consumer (additive, cleaned up on unmount), so\n // two mounted providers never clobber each other's onDiagnostic/onError —\n // only the console/PostHog/buffer settings are global (last writer wins).\n const onDiagnosticRef = useRef(onDiagnostic);\n onDiagnosticRef.current = onDiagnostic;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n useEffect(() => {\n installAthenaDiagnosticsGlobal();\n return athenaDiagnostics.addConsumer({\n onEvent: (event) => onDiagnosticRef.current?.(event),\n onError: (error, event) => onErrorRef.current?.(error, event),\n });\n }, []);\n const debugKey = JSON.stringify(debugPropToDiagnosticsConfig(debug));\n useEffect(() => {\n athenaDiagnostics.configure(debugPropToDiagnosticsConfig(debug));\n // debugKey is the value-stable form of `debug` (consumers pass literals).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debugKey]);\n const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);\n // Merge SDK auto-open defaults under the consumer's frontendTools. Consumer\n // entries win on name collision; auto-open tool names are NOT added to\n // frontendToolIds (they are already backend-advertised by their toolkits).\n const effectiveFrontendTools = useMemo<Toolkit>(\n () => (disableAutoOpen ? frontendTools : { ...DEFAULT_AUTO_OPEN_TOOLS, ...frontendTools }),\n [disableAutoOpen, frontendTools],\n );\n const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : undefined, [theme]);\n const configuredEnvironment = config?.environment ?? environment;\n const environmentUrls = useMemo(\n () => getAthenaEnvironmentUrls({ environment: configuredEnvironment }),\n [configuredEnvironment],\n );\n const configuredApiKey = config?.apiKey ?? apiKey;\n const configuredToken = resolveTokenOverride({ config, token: tokenProp });\n const configuredApiUrl = config?.apiUrl ?? apiUrl;\n const configuredBackendUrl = config?.backendUrl ?? backendUrl;\n const configuredAppUrl = config?.appUrl ?? appUrl;\n const configuredStatewireSyncUrl = config?.statewireSyncUrl ?? statewireSyncUrl;\n const configuredGetToken = config?.getToken ?? getToken;\n const configuredExtraRunConfig = config?.extraRunConfig ?? extraRunConfig;\n const configuredTrustedParentOrigins = config?.trustedParentOrigins;\n const posthogConfig: PostHogConfig | undefined = config?.posthog ?? posthogProp;\n\n // Statewire is the SDK's only chat transport; the gauge/event stay on the\n // diagnostics contract so dashboards keyed on them keep reading a value.\n useEffect(() => {\n athenaDiagnostics.gauge('sdk.transport', 'statewire');\n athenaDiagnostics.emit('sdk.transport', {\n level: 'debug',\n data: { transport: 'statewire', thread_list: enableThreadList },\n });\n }, [enableThreadList]);\n\n const bridge = useParentBridge({\n trustedOrigins: configuredTrustedParentOrigins,\n });\n\n // If an AthenaAuthProvider is present above us, use its access token automatically.\n const authContext = useContext(AthenaAuthContext);\n const authProviderToken = authContext?.accessToken ?? null;\n\n // Per-provider snapshot cache: a switch back to a recently-visited thread\n // mounts with its last-known snapshot instead of a loading spinner. Owned\n // here, above the per-thread keyed mount, so it survives switches; cleared\n // when the acting identity changes so a snapshot captured under one account\n // never seeds a mount under another.\n const [snapshotCache] = useState(() => createDeepAgentThreadSnapshotCache());\n // The windowed wire's fetched-back tool outputs, owned alongside the cache\n // for the same reasons: shared across the provider's thread switches (a\n // tool message id is unique across threads), dropped with the identity.\n const [toolOutputs] = useState(() => createDeepAgentToolOutputStore());\n const principal = authContext?.user?.userId ?? '';\n useEffect(() => {\n snapshotCache.clear();\n toolOutputs.clear();\n }, [snapshotCache, toolOutputs, principal, configuredApiKey]);\n\n const effectiveToken = configuredToken !== undefined\n ? configuredToken\n : authProviderToken ?? bridge.token;\n // Explicit config wins. A Marathon host mints the statewire mount, the bare\n // Agora base and the app origin outright (`/_athena/auth`, or a trusted\n // parent's `athena-config`); the environment preset is the last resort, and\n // the sync mount derives from the `apiUrl` host when no host minted one.\n const effectiveApiUrl = configuredApiUrl ?? environmentUrls.apiUrl;\n // Published as the bare Agora base: a historical `…/api/assistant-ui` value\n // is trimmed here once rather than by each REST helper.\n const effectiveBackendUrl = getAthenaApiBaseUrl(\n configuredBackendUrl ?? bridge.backendBaseUrl ?? environmentUrls.backendUrl,\n );\n const hostStatewireSyncUrl = configuredStatewireSyncUrl ?? bridge.statewireSyncUrl ?? undefined;\n const effectiveAppUrl = configuredAppUrl\n ?? bridge.appUrl\n ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl })\n ?? environmentUrls.appUrl;\n\n // Wait for the parent bridge to deliver config/auth before rendering.\n // This prevents the thread list from fetching with wrong URLs or no token.\n // Falls back after a short timeout (2s) if no bridge responds.\n if (!bridge.ready) {\n return null;\n }\n\n // Both throw on an unresolvable configuration instead of falling back to an\n // Athena default — a custom deployment's credentials must never be sent to\n // a host the consumer didn't configure. A host that answered the bridge\n // without minting the statewire mount is that case: its token would\n // otherwise ride the environment preset.\n assertHostMintedStatewireMount({\n hostAnswered: bridge.hostAnswered,\n hostStatewireSyncUrl: bridge.statewireSyncUrl,\n statewireSyncUrl: configuredStatewireSyncUrl,\n apiUrl: configuredApiUrl,\n });\n const effectiveStatewireSyncUrl = resolveStatewireSyncUrl({\n statewireSyncUrl: hostStatewireSyncUrl,\n apiUrl: effectiveApiUrl,\n });\n\n const statewireProps = {\n syncUrl: effectiveStatewireSyncUrl,\n backendUrl: effectiveBackendUrl,\n appUrl: effectiveAppUrl,\n apiKey: configuredApiKey,\n token: effectiveToken,\n getToken: configuredGetToken,\n model,\n agent,\n channel,\n tools,\n frontendToolIds: frontendToolNames,\n frontendTools: effectiveFrontendTools,\n workbench,\n knowledgeBase,\n systemPrompt,\n appId,\n extraRunConfig: configuredExtraRunConfig,\n snapshotCache,\n toolOutputs,\n linkClicks,\n citationLinks,\n };\n\n const inner: ReactNode = enableThreadList ? (\n <AthenaStatewireWithThreadList {...statewireProps} initialThreadId={threadIdProp}>\n {children}\n </AthenaStatewireWithThreadList>\n ) : (\n <AthenaStatewireStandalone {...statewireProps} threadId={threadIdProp}>\n {children}\n </AthenaStatewireStandalone>\n );\n\n // The .athena-sdk wrapper (display: contents) anchors the SDK's design\n // tokens and scoped preflight from styles.css, so the stylesheet works\n // in hosts without their own Tailwind build. PostHog gracefully no-ops\n // when its config is missing.\n return (\n <div\n className={themeStyleVars ? \"athena-sdk athena-themed\" : \"athena-sdk\"}\n style={themeStyleVars as React.CSSProperties | undefined}\n >\n <PostHogProvider config={posthogConfig}>\n {inner}\n </PostHogProvider>\n </div>\n );\n}\n"],"names":["useRef","useMemo","toolOutputs","mintThreadId","useReducer","statewireLifecycleReducer","initialStatewireLifecycle","useAthenaStatewireRuntime","athenaStatewireErrorNotice","useStatewireClientTools","useCallback","AuiProvider","jsx","AthenaContext","AthenaStatewireThreadIdContext","AthenaStatewireLifecycleContext","DeepAgentConnectionContext","StatewireToolOutputsContext","TooltipProvider","StatewireClientToolBridge","AthenaStatewireThreadListProvider","useAthenaStatewireThreadList","AthenaThreadIdContext","jsxs","StatewireThreadTitlePoller","useAssetPanelStore","useEffect","resolveAgentProp","installAthenaDiagnosticsGlobal","athenaDiagnostics","_a","debugPropToDiagnosticsConfig","DEFAULT_AUTO_OPEN_TOOLS","themeToStyleVars","getAthenaEnvironmentUrls","useParentBridge","useContext","AthenaAuthContext","useState","createDeepAgentThreadSnapshotCache","createDeepAgentToolOutputStore","getAthenaApiBaseUrl","deriveAthenaAppUrl","assertHostMintedStatewireMount","resolveStatewireSyncUrl","PostHogProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4NA,MAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGiC;AAC/B,OAAI,iCAAQ,WAAU,QAAW;AAC/B,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAQoB;AAClB,QAAM,gBAAgBA,MAAAA,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,mBAAmBA,MAAAA,OAAO,aAAa;AAC7C,mBAAiB,UAAU;AAM3B,QAAM,WAAWA,MAAAA,OAAO,KAAK;AAC7B,WAAS,UAAU;AAEnB,SAAOC,MAAAA;AAAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,IAAI,QAAQ;AACV,eAAO,SAAS;AAAA,MAClB;AAAA,MACA,IAAI,aAAa;AACf,eAAO,cAAc;AAAA,MACvB;AAAA,MACA,IAAI,gBAAgB;AAClB,eAAO,iBAAiB;AAAA,MAC1B;AAAA,IAAA;AAAA,IAEF,CAAC,YAAY,QAAQ,QAAQ,eAAe;AAAA,EAAA;AAEhD;AAIA,SAAS,0BAA0B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA;AACF,GA6BG;AAGD,QAAM,iBAAiBF,MAAAA,OAAsB,IAAI;AAC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;AAAA,IAC7B,cAAc,OAAO;AAAA,IACrB,sBAAsB,OAAO;AAAA,IAC7B,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EAAA,CACT;AACD,QAAM,4BAA4BC,WAAAA,wBAAwB;AAAA,IACxD,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EAAA,CACT;AAED,QAAM,iBAAiB;AAAA,IACrB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IAAA,aACA1C;AAAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,QAAmB,mBACvBU,2BAAAA,IAAC,+BAAA,EAA+B,GAAG,gBAAgB,iBAAiB,cACjE,SAAA,CACH,mCAEC,2BAAA,EAA2B,GAAG,gBAAgB,UAAU,cACtD,UACH;AAOF,SACEA,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,iBAAiB,6BAA6B;AAAA,MACzD,OAAO;AAAA,MAEP,UAAAA,2BAAAA,IAACiC,iCAAA,EAAgB,QAAQ,eACtB,UAAA,MAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAGN;;"}
|
|
@@ -11,11 +11,12 @@ import "../packages/agent-runtime/src/messages.js";
|
|
|
11
11
|
import "@assistant-ui/react-statewire";
|
|
12
12
|
import "@assistant-ui/store";
|
|
13
13
|
import { createDeepAgentToolOutputStore } from "../packages/agent-runtime/src/tool-outputs.js";
|
|
14
|
-
import "
|
|
14
|
+
import "../packages/agent-runtime/src/quota-safe-local-storage-session.js";
|
|
15
15
|
import { createDeepAgentThreadSnapshotCache } from "../packages/agent-runtime/src/thread-snapshot-cache.js";
|
|
16
16
|
import "../packages/agent-runtime/src/statewire-attach-observer.js";
|
|
17
17
|
import { DeepAgentConnectionContext } from "../packages/agent-runtime/src/thread-status.js";
|
|
18
18
|
import "@assistant-ui/core";
|
|
19
|
+
import "../packages/agent-runtime/src/thread-handoff.js";
|
|
19
20
|
import { getAthenaEnvironmentUrls, deriveAthenaAppUrl, assertHostMintedStatewireMount, resolveStatewireSyncUrl } from "../lib/athena-urls.js";
|
|
20
21
|
import { getAthenaApiBaseUrl } from "../collab/mint.js";
|
|
21
22
|
import { useParentBridge } from "../runtime/auth.js";
|