@athenaintel/react 0.28.1 → 0.32.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 +479 -10
- package/dist/agent-runtime/src/asset-attachment.cjs.map +1 -0
- package/dist/agent-runtime/src/asset-attachment.js.map +1 -0
- package/dist/agent-runtime/src/athena-asset-drag.cjs +44 -0
- package/dist/agent-runtime/src/athena-asset-drag.cjs.map +1 -0
- package/dist/agent-runtime/src/athena-asset-drag.js +44 -0
- package/dist/agent-runtime/src/athena-asset-drag.js.map +1 -0
- package/dist/agent-runtime/src/auth-denial.cjs.map +1 -0
- package/dist/agent-runtime/src/auth-denial.js.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tool-bridge.js.map +1 -0
- package/dist/agent-runtime/src/client-tools.cjs.map +1 -0
- package/dist/agent-runtime/src/client-tools.js.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.cjs +124 -0
- package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/composer-markdown.js +124 -0
- package/dist/agent-runtime/src/composer-markdown.js.map +1 -0
- package/dist/agent-runtime/src/config-mutations.cjs +59 -0
- package/dist/agent-runtime/src/config-mutations.cjs.map +1 -0
- package/dist/agent-runtime/src/config-mutations.js +59 -0
- package/dist/agent-runtime/src/config-mutations.js.map +1 -0
- package/dist/agent-runtime/src/conversation-index.cjs.map +1 -0
- package/dist/agent-runtime/src/conversation-index.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.cjs +36 -0
- package/dist/agent-runtime/src/conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-list.js +36 -0
- package/dist/agent-runtime/src/conversation-list.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.cjs +5 -3
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/deep-agent-transport-recipe.js +6 -4
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -0
- package/dist/agent-runtime/src/edit-command.cjs.map +1 -0
- package/dist/agent-runtime/src/edit-command.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.cjs +23 -0
- package/dist/agent-runtime/src/errors.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/errors.js +23 -0
- package/dist/agent-runtime/src/errors.js.map +1 -0
- package/dist/agent-runtime/src/execute-output.cjs +41 -0
- package/dist/agent-runtime/src/execute-output.cjs.map +1 -0
- package/dist/agent-runtime/src/execute-output.js +41 -0
- package/dist/agent-runtime/src/execute-output.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.cjs +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/generated/runconfig-contract.js +16 -2
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/github-wake-event.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.cjs +24 -1
- package/dist/agent-runtime/src/interrupts.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/interrupts.js +24 -1
- package/dist/agent-runtime/src/interrupts.js.map +1 -0
- package/dist/agent-runtime/src/message-author.cjs.map +1 -0
- package/dist/agent-runtime/src/message-author.js.map +1 -0
- package/dist/agent-runtime/src/message-window.cjs.map +1 -0
- package/dist/agent-runtime/src/message-window.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.cjs +8 -4
- package/dist/agent-runtime/src/messages.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/messages.js +6 -2
- package/dist/agent-runtime/src/messages.js.map +1 -0
- package/dist/agent-runtime/src/model-context.cjs.map +1 -0
- package/dist/agent-runtime/src/model-context.js.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.cjs.map +1 -0
- package/dist/agent-runtime/src/optimistic-content.js.map +1 -0
- package/dist/agent-runtime/src/protocol.cjs.map +1 -0
- package/dist/agent-runtime/src/protocol.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.cjs +23 -2
- package/dist/agent-runtime/src/queue.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/queue.js +23 -2
- package/dist/agent-runtime/src/queue.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.cjs +71 -13
- package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/quota-safe-local-storage-session.js +73 -15
- package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.cjs.map +1 -0
- package/dist/agent-runtime/src/runtime-messages.js.map +1 -0
- package/dist/agent-runtime/src/screen-point.cjs.map +1 -0
- package/dist/agent-runtime/src/screen-point.js.map +1 -0
- package/dist/agent-runtime/src/send-recovery.cjs.map +1 -0
- package/dist/agent-runtime/src/send-recovery.js.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-attach-observer.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.cjs +8 -0
- package/dist/agent-runtime/src/statewire-state.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-state.js +8 -0
- package/dist/agent-runtime/src/statewire-state.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.cjs +4 -0
- package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-suspended.js +4 -0
- package/dist/agent-runtime/src/statewire-suspended.js.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.cjs +43 -0
- package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -0
- package/dist/agent-runtime/src/statewire-transport.js +43 -0
- package/dist/agent-runtime/src/statewire-transport.js.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.cjs.map +1 -0
- package/dist/agent-runtime/src/streaming-markdown.js.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.cjs.map +1 -0
- package/dist/agent-runtime/src/subscription-wake-event.js +252 -0
- package/dist/agent-runtime/src/subscription-wake-event.js.map +1 -0
- package/dist/agent-runtime/src/thread-extras.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-extras.js.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-snapshot-cache.js.map +1 -0
- package/dist/agent-runtime/src/thread-status.cjs.map +1 -0
- package/dist/agent-runtime/src/thread-status.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.cjs +304 -9
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/tool-metadata.js +304 -9
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -0
- package/dist/agent-runtime/src/tool-names.cjs +5 -0
- package/dist/agent-runtime/src/tool-names.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-names.js +5 -0
- package/dist/agent-runtime/src/tool-names.js.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-outputs.js.map +1 -0
- package/dist/agent-runtime/src/tool-result.cjs.map +1 -0
- package/dist/agent-runtime/src/tool-result.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.cjs +33 -22
- package/dist/agent-runtime/src/use-conversation-list.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-conversation-list.js +34 -23
- package/dist/agent-runtime/src/use-conversation-list.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.cjs +129 -0
- package/dist/agent-runtime/src/use-deep-agent-config.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-config.js +129 -0
- package/dist/agent-runtime/src/use-deep-agent-config.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.cjs +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-edit-submit.js +2 -0
- package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.cjs +1 -0
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-thread.js +2 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -0
- package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.cjs.map +1 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js +52 -0
- package/dist/agent-runtime/src/use-historical-edit-attachments.js.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.cjs +14 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -0
- package/dist/{packages/agent-runtime → agent-runtime}/src/voice-presentation.js +14 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.cjs.map +1 -0
- package/dist/agent-runtime/src/voice-turn-grouping.js.map +1 -0
- package/dist/assets/AthenaAssetEmbed.cjs +13 -2
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +10 -0
- package/dist/assets/AthenaAssetEmbed.js +14 -3
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/AthenaLayout.cjs +97 -31
- package/dist/assets/AthenaLayout.cjs.map +1 -1
- package/dist/assets/AthenaLayout.d.ts +13 -0
- package/dist/assets/AthenaLayout.js +98 -32
- package/dist/assets/AthenaLayout.js.map +1 -1
- package/dist/assets/asset-embed-messages.cjs +6 -0
- package/dist/assets/asset-embed-messages.cjs.map +1 -1
- package/dist/assets/asset-embed-messages.d.ts +13 -0
- package/dist/assets/asset-embed-messages.js +6 -0
- package/dist/assets/asset-embed-messages.js.map +1 -1
- package/dist/assets/asset-panel-store.cjs +68 -32
- package/dist/assets/asset-panel-store.cjs.map +1 -1
- package/dist/assets/asset-panel-store.d.ts +47 -1
- package/dist/assets/asset-panel-store.js +68 -32
- package/dist/assets/asset-panel-store.js.map +1 -1
- package/dist/assets/use-asset-embed.cjs +29 -8
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.d.ts +7 -0
- package/dist/assets/use-asset-embed.js +29 -8
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/catalog/chat-pickers.cjs +152 -0
- package/dist/catalog/chat-pickers.cjs.map +1 -0
- package/dist/catalog/chat-pickers.d.ts +22 -0
- package/dist/catalog/chat-pickers.js +152 -0
- package/dist/catalog/chat-pickers.js.map +1 -0
- package/dist/catalog/runtime-catalog.cjs +181 -0
- package/dist/catalog/runtime-catalog.cjs.map +1 -0
- package/dist/catalog/runtime-catalog.d.ts +100 -0
- package/dist/catalog/runtime-catalog.js +181 -0
- package/dist/catalog/runtime-catalog.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +122 -67
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +21 -4
- package/dist/chat/AthenaChat.js +124 -69
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +38 -37
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.d.ts +2 -0
- package/dist/chat/StatewireApprovalCard.js +39 -38
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -2
- package/dist/chat/StatewireClientToolBridge.js +2 -2
- package/dist/chat/StatewireQueuedMessages.cjs +15 -12
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.d.ts +22 -2
- package/dist/chat/StatewireQueuedMessages.js +15 -12
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/StatewireRunRefusalNotice.cjs +48 -0
- package/dist/chat/StatewireRunRefusalNotice.cjs.map +1 -0
- package/dist/chat/StatewireRunRefusalNotice.d.ts +25 -0
- package/dist/chat/StatewireRunRefusalNotice.js +48 -0
- package/dist/chat/StatewireRunRefusalNotice.js.map +1 -0
- package/dist/chat/WaitingOnYouBanner.cjs +2 -2
- package/dist/chat/WaitingOnYouBanner.js +2 -2
- package/dist/chat/athena-citation-links.cjs +19 -15
- package/dist/chat/athena-citation-links.cjs.map +1 -1
- package/dist/chat/athena-citation-links.js +19 -15
- package/dist/chat/athena-citation-links.js.map +1 -1
- package/dist/chat/run-activity.cjs +9 -1
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.d.ts +6 -0
- package/dist/chat/run-activity.js +10 -2
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-banners.cjs +30 -1
- package/dist/chat/statewire-banners.cjs.map +1 -1
- package/dist/chat/statewire-banners.d.ts +20 -1
- package/dist/chat/statewire-banners.js +32 -3
- package/dist/chat/statewire-banners.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +1 -1
- package/dist/chat/statewire-client-tools.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
- package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +38 -16
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +21 -4
- package/dist/chat/super-grouping/SuperGroupingCard.js +39 -17
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +377 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +31 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +377 -0
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -0
- package/dist/chat/super-grouping/ToolTimeline.cjs +13 -2
- package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
- package/dist/chat/super-grouping/ToolTimeline.d.ts +10 -3
- package/dist/chat/super-grouping/ToolTimeline.js +13 -2
- package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +69 -29
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +60 -9
- package/dist/chat/super-grouping/activity-timeline.js +70 -30
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/index.cjs +14 -0
- package/dist/chat/super-grouping/index.cjs.map +1 -1
- package/dist/chat/super-grouping/index.d.ts +7 -2
- package/dist/chat/super-grouping/index.js +16 -2
- package/dist/chat/super-grouping/index.js.map +1 -1
- package/dist/chat/super-grouping/timeline-step.cjs +14 -5
- package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
- package/dist/chat/super-grouping/timeline-step.d.ts +10 -1
- package/dist/chat/super-grouping/timeline-step.js +15 -6
- package/dist/chat/super-grouping/timeline-step.js.map +1 -1
- package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
- package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
- package/dist/chat/super-grouping/toolkit-map.js +1 -0
- package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
- package/dist/chat/super-grouping/turn-segments.cjs +82 -0
- package/dist/chat/super-grouping/turn-segments.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-segments.d.ts +69 -0
- package/dist/chat/super-grouping/turn-segments.js +82 -0
- package/dist/chat/super-grouping/turn-segments.js.map +1 -0
- package/dist/chat/super-grouping/turn-timing.cjs +110 -0
- package/dist/chat/super-grouping/turn-timing.cjs.map +1 -0
- package/dist/chat/super-grouping/turn-timing.d.ts +52 -0
- package/dist/chat/super-grouping/turn-timing.js +110 -0
- package/dist/chat/super-grouping/turn-timing.js.map +1 -0
- package/dist/chat/tiptap-text.cjs +1 -1
- package/dist/chat/tiptap-text.js +1 -1
- package/dist/chat/use-athena-run-live.cjs +1 -1
- package/dist/chat/use-athena-run-live.js +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +73 -4
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.js +74 -5
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/composer-message.cjs +284 -0
- package/dist/chat-ui/composer/composer-message.cjs.map +1 -0
- package/dist/chat-ui/composer/composer-message.d.ts +152 -0
- package/dist/chat-ui/composer/composer-message.js +284 -0
- package/dist/chat-ui/composer/composer-message.js.map +1 -0
- package/dist/chat-ui/composer/tiptap-composer.cjs +97 -15
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.d.ts +34 -6
- package/dist/chat-ui/composer/tiptap-composer.js +97 -15
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +4 -1
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.d.ts +3 -2
- package/dist/chat-ui/index.js +5 -2
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +31 -3
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.d.ts +2 -5
- package/dist/chat-ui/mentions/mention-chip.js +33 -5
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.cjs +9 -3
- package/dist/chat-ui/mentions/mention-extension.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-extension.js +9 -3
- package/dist/chat-ui/mentions/mention-extension.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js +3 -1
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +65 -19
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +15 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +67 -21
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs +4 -2
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +2 -1
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js +5 -3
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +61 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +3 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.js +61 -0
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -0
- package/dist/chat-ui/mentions/use-member-avatar.cjs +75 -0
- package/dist/chat-ui/mentions/use-member-avatar.cjs.map +1 -0
- package/dist/chat-ui/mentions/use-member-avatar.d.ts +2 -0
- package/dist/chat-ui/mentions/use-member-avatar.js +75 -0
- package/dist/chat-ui/mentions/use-member-avatar.js.map +1 -0
- package/dist/chat-ui/messages/message-components.cjs +30 -10
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.d.ts +21 -1
- package/dist/chat-ui/messages/message-components.js +30 -10
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +1 -1
- package/dist/chat-ui/messages/runtime-message.js +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +5 -5
- package/dist/chat-ui/messages/statewire-continue-run.js +5 -5
- package/dist/chat-ui/messages/user-edit-composer.cjs +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +39 -4
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
- package/dist/chat-ui/messages/wake-marker.d.ts +16 -5
- package/dist/chat-ui/messages/wake-marker.js +40 -5
- package/dist/chat-ui/messages/wake-marker.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.cjs +12 -8
- package/dist/chat-ui/rich-text/chat-message-body.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-message-body.d.ts +6 -1
- package/dist/chat-ui/rich-text/chat-message-body.js +13 -9
- package/dist/chat-ui/rich-text/chat-message-body.js.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.cjs +64 -6
- package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
- package/dist/chat-ui/rich-text/chat-text-schema.d.ts +5 -0
- package/dist/chat-ui/rich-text/chat-text-schema.js +66 -8
- package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +1 -1
- package/dist/chat-ui/statewire.d.ts +1 -1
- package/dist/chat-ui/statewire.js +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -2
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -2
- package/dist/collab/client.cjs +282 -16
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +127 -2
- package/dist/collab/client.js +285 -20
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.cjs +2 -0
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.ts +1 -1
- package/dist/collab/index.js +3 -1
- package/dist/composer/AttachmentContext.cjs +38 -12
- package/dist/composer/AttachmentContext.cjs.map +1 -1
- package/dist/composer/AttachmentContext.d.ts +22 -1
- package/dist/composer/AttachmentContext.js +40 -14
- package/dist/composer/AttachmentContext.js.map +1 -1
- package/dist/composer/QuoteContext.cjs +80 -28
- package/dist/composer/QuoteContext.cjs.map +1 -1
- package/dist/composer/QuoteContext.d.ts +35 -6
- package/dist/composer/QuoteContext.js +82 -30
- package/dist/composer/QuoteContext.js.map +1 -1
- package/dist/composer/build-composed-message.cjs +27 -0
- package/dist/composer/build-composed-message.cjs.map +1 -1
- package/dist/composer/build-composed-message.d.ts +21 -0
- package/dist/composer/build-composed-message.js +28 -1
- package/dist/composer/build-composed-message.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +13 -1
- package/dist/composer/composer-handoff.cjs.map +1 -1
- package/dist/composer/composer-handoff.d.ts +12 -0
- package/dist/composer/composer-handoff.js +15 -3
- package/dist/composer/composer-handoff.js.map +1 -1
- package/dist/composer/index.d.ts +6 -3
- package/dist/composer/useReadComposerDraft.cjs +16 -0
- package/dist/composer/useReadComposerDraft.cjs.map +1 -0
- package/dist/composer/useReadComposerDraft.d.ts +6 -0
- package/dist/composer/useReadComposerDraft.js +16 -0
- package/dist/composer/useReadComposerDraft.js.map +1 -0
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/diagnostics/errors.cjs +6 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +6 -0
- package/dist/diagnostics/errors.js +6 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/index.cjs +163 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +55 -12
- package/dist/index.js +170 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/owner-document.cjs +32 -0
- package/dist/lib/owner-document.cjs.map +1 -0
- package/dist/lib/owner-document.d.ts +17 -0
- package/dist/lib/owner-document.js +32 -0
- package/dist/lib/owner-document.js.map +1 -0
- package/dist/lib/portal-surface.cjs +55 -0
- package/dist/lib/portal-surface.cjs.map +1 -0
- package/dist/lib/portal-surface.d.ts +37 -0
- package/dist/lib/portal-surface.js +55 -0
- package/dist/lib/portal-surface.js.map +1 -0
- package/dist/lib/use-athena-rest-query.cjs +34 -0
- package/dist/lib/use-athena-rest-query.cjs.map +1 -0
- package/dist/lib/use-athena-rest-query.d.ts +31 -0
- package/dist/lib/use-athena-rest-query.js +34 -0
- package/dist/lib/use-athena-rest-query.js.map +1 -0
- package/dist/provider/AthenaProvider.cjs +70 -10
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +27 -2
- package/dist/provider/AthenaProvider.js +74 -14
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/citation-links.d.ts +10 -2
- package/dist/{packages/react → react}/package.json.cjs +1 -1
- package/dist/{packages/react → react}/package.json.js +1 -1
- package/dist/runtime/StatewireModelLaneSync.cjs +96 -0
- package/dist/runtime/StatewireModelLaneSync.cjs.map +1 -0
- package/dist/runtime/StatewireModelLaneSync.d.ts +45 -0
- package/dist/runtime/StatewireModelLaneSync.js +96 -0
- package/dist/runtime/StatewireModelLaneSync.js.map +1 -0
- package/dist/runtime/statewire-lifecycle.cjs +20 -5
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.d.ts +11 -0
- package/dist/runtime/statewire-lifecycle.js +20 -5
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/statewire-model-lane.cjs +28 -0
- package/dist/runtime/statewire-model-lane.cjs.map +1 -0
- package/dist/runtime/statewire-model-lane.d.ts +64 -0
- package/dist/runtime/statewire-model-lane.js +28 -0
- package/dist/runtime/statewire-model-lane.js.map +1 -0
- package/dist/runtime/statewire-run-config.cjs +16 -2
- package/dist/runtime/statewire-run-config.cjs.map +1 -1
- package/dist/runtime/statewire-run-config.d.ts +10 -0
- package/dist/runtime/statewire-run-config.js +16 -2
- package/dist/runtime/statewire-run-config.js.map +1 -1
- package/dist/runtime/statewire-server-lane-context.cjs +24 -0
- package/dist/runtime/statewire-server-lane-context.cjs.map +1 -0
- package/dist/runtime/statewire-server-lane-context.d.ts +30 -0
- package/dist/runtime/statewire-server-lane-context.js +24 -0
- package/dist/runtime/statewire-server-lane-context.js.map +1 -0
- package/dist/runtime/useAthenaStatewireRuntime.cjs +47 -23
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +8 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +48 -24
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/search/useAthenaRepoSearch.cjs +5 -13
- package/dist/search/useAthenaRepoSearch.cjs.map +1 -1
- package/dist/search/useAthenaRepoSearch.d.ts +3 -3
- package/dist/search/useAthenaRepoSearch.js +6 -14
- package/dist/search/useAthenaRepoSearch.js.map +1 -1
- package/dist/sheet-range/a1.cjs +162 -0
- package/dist/sheet-range/a1.cjs.map +1 -0
- package/dist/sheet-range/a1.d.ts +91 -0
- package/dist/sheet-range/a1.js +162 -0
- package/dist/sheet-range/a1.js.map +1 -0
- package/dist/sheet-range/index.cjs +22 -0
- package/dist/sheet-range/index.cjs.map +1 -0
- package/dist/sheet-range/index.d.ts +12 -0
- package/dist/sheet-range/index.js +22 -0
- package/dist/sheet-range/index.js.map +1 -0
- package/dist/sheet-range/range-preview-table.cjs +75 -0
- package/dist/sheet-range/range-preview-table.cjs.map +1 -0
- package/dist/sheet-range/range-preview-table.d.ts +20 -0
- package/dist/sheet-range/range-preview-table.js +75 -0
- package/dist/sheet-range/range-preview-table.js.map +1 -0
- package/dist/sheet-range/range-preview.cjs +116 -0
- package/dist/sheet-range/range-preview.cjs.map +1 -0
- package/dist/sheet-range/range-preview.d.ts +67 -0
- package/dist/sheet-range/range-preview.js +116 -0
- package/dist/sheet-range/range-preview.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/threads/Inbox.cjs +289 -0
- package/dist/threads/Inbox.cjs.map +1 -0
- package/dist/threads/Inbox.d.ts +46 -0
- package/dist/threads/Inbox.js +289 -0
- package/dist/threads/Inbox.js.map +1 -0
- package/dist/threads/SessionList.cjs +51 -126
- package/dist/threads/SessionList.cjs.map +1 -1
- package/dist/threads/SessionList.d.ts +26 -1
- package/dist/threads/SessionList.js +45 -120
- package/dist/threads/SessionList.js.map +1 -1
- package/dist/threads/SessionsPage.cjs +753 -0
- package/dist/threads/SessionsPage.cjs.map +1 -0
- package/dist/threads/SessionsPage.d.ts +35 -0
- package/dist/threads/SessionsPage.js +753 -0
- package/dist/threads/SessionsPage.js.map +1 -0
- package/dist/threads/api.cjs +23 -2
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +60 -0
- package/dist/threads/api.js +23 -2
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/conversation-list-fetcher.cjs +9 -2
- package/dist/threads/conversation-list-fetcher.cjs.map +1 -1
- package/dist/threads/conversation-list-fetcher.d.ts +14 -1
- package/dist/threads/conversation-list-fetcher.js +9 -2
- package/dist/threads/conversation-list-fetcher.js.map +1 -1
- package/dist/threads/index.d.ts +2 -1
- package/dist/threads/pull-request-display.cjs +25 -0
- package/dist/threads/pull-request-display.cjs.map +1 -0
- package/dist/threads/pull-request-display.d.ts +15 -0
- package/dist/threads/pull-request-display.js +25 -0
- package/dist/threads/pull-request-display.js.map +1 -0
- package/dist/threads/session-list-model.cjs +16 -2
- package/dist/threads/session-list-model.cjs.map +1 -1
- package/dist/threads/session-list-model.d.ts +10 -0
- package/dist/threads/session-list-model.js +16 -2
- package/dist/threads/session-list-model.js.map +1 -1
- package/dist/threads/session-row-parts.cjs +152 -0
- package/dist/threads/session-row-parts.cjs.map +1 -0
- package/dist/threads/session-row-parts.d.ts +50 -0
- package/dist/threads/session-row-parts.js +152 -0
- package/dist/threads/session-row-parts.js.map +1 -0
- package/dist/threads/sessions-page-model.cjs +305 -0
- package/dist/threads/sessions-page-model.cjs.map +1 -0
- package/dist/threads/sessions-page-model.d.ts +86 -0
- package/dist/threads/sessions-page-model.js +305 -0
- package/dist/threads/sessions-page-model.js.map +1 -0
- package/dist/threads/sessions-page-storage.cjs +93 -0
- package/dist/threads/sessions-page-storage.cjs.map +1 -0
- package/dist/threads/sessions-page-storage.d.ts +23 -0
- package/dist/threads/sessions-page-storage.js +93 -0
- package/dist/threads/sessions-page-storage.js.map +1 -0
- package/dist/threads/sessions-query.cjs +235 -0
- package/dist/threads/sessions-query.cjs.map +1 -0
- package/dist/threads/sessions-query.d.ts +119 -0
- package/dist/threads/sessions-query.js +235 -0
- package/dist/threads/sessions-query.js.map +1 -0
- package/dist/threads/statewire-thread-list.cjs +133 -40
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.d.ts +83 -2
- package/dist/threads/statewire-thread-list.js +134 -41
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-athena-sessions.cjs +198 -0
- package/dist/threads/use-athena-sessions.cjs.map +1 -0
- package/dist/threads/use-athena-sessions.d.ts +81 -0
- package/dist/threads/use-athena-sessions.js +198 -0
- package/dist/threads/use-athena-sessions.js.map +1 -0
- package/dist/threads/use-athena-thread-model.cjs +14 -0
- package/dist/threads/use-athena-thread-model.cjs.map +1 -0
- package/dist/threads/use-athena-thread-model.d.ts +22 -0
- package/dist/threads/use-athena-thread-model.js +14 -0
- package/dist/threads/use-athena-thread-model.js.map +1 -0
- package/dist/threads/use-rest-conversation-history.cjs +1 -1
- package/dist/threads/use-rest-conversation-history.js +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +1 -1
- package/dist/threads/use-statewire-conversation-history.d.ts +3 -0
- package/dist/threads/use-statewire-conversation-history.js +1 -1
- package/dist/threads/use-thread-read-state.cjs +73 -0
- package/dist/threads/use-thread-read-state.cjs.map +1 -0
- package/dist/threads/use-thread-read-state.d.ts +51 -0
- package/dist/threads/use-thread-read-state.js +73 -0
- package/dist/threads/use-thread-read-state.js.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +1 -0
- package/dist/tiptap-markdown-table/src/markdown-table-serializer.js.map +1 -0
- package/dist/tools/auto-open-tools.cjs +2 -0
- package/dist/tools/auto-open-tools.cjs.map +1 -1
- package/dist/tools/auto-open-tools.js +2 -0
- package/dist/tools/auto-open-tools.js.map +1 -1
- package/dist/tools/file-tool-uis.cjs +18 -43
- package/dist/tools/file-tool-uis.cjs.map +1 -1
- package/dist/tools/file-tool-uis.d.ts +1 -2
- package/dist/tools/file-tool-uis.js +18 -42
- package/dist/tools/file-tool-uis.js.map +1 -1
- package/dist/tools/index.cjs +6 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +6 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -2
- package/dist/tools/misc-tool-uis.js +2 -2
- package/dist/tools/primitives.cjs +1 -1
- package/dist/tools/primitives.js +1 -1
- package/dist/tools/read-asset-tool-ui.cjs +21 -70
- package/dist/tools/read-asset-tool-ui.cjs.map +1 -1
- package/dist/tools/read-asset-tool-ui.js +21 -70
- package/dist/tools/read-asset-tool-ui.js.map +1 -1
- package/dist/tools/step-text.cjs +21 -0
- package/dist/tools/step-text.cjs.map +1 -0
- package/dist/tools/step-text.d.ts +10 -0
- package/dist/tools/step-text.js +21 -0
- package/dist/tools/step-text.js.map +1 -0
- package/dist/tools/tool-fallback.cjs +24 -5
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.d.ts +3 -1
- package/dist/tools/tool-fallback.js +24 -5
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/tool-summary.cjs +661 -0
- package/dist/tools/tool-summary.cjs.map +1 -0
- package/dist/tools/tool-summary.d.ts +99 -0
- package/dist/tools/tool-summary.js +661 -0
- package/dist/tools/tool-summary.js.map +1 -0
- package/dist/tools/tool-uis.cjs +37 -95
- package/dist/tools/tool-uis.cjs.map +1 -1
- package/dist/tools/tool-uis.js +37 -95
- package/dist/tools/tool-uis.js.map +1 -1
- package/dist/tools/voice-update-tool-ui.cjs +1 -1
- package/dist/tools/voice-update-tool-ui.js +1 -1
- package/dist/tools/write-todos-tool-ui.cjs +3 -2
- package/dist/tools/write-todos-tool-ui.cjs.map +1 -1
- package/dist/tools/write-todos-tool-ui.d.ts +5 -0
- package/dist/tools/write-todos-tool-ui.js +5 -4
- package/dist/tools/write-todos-tool-ui.js.map +1 -1
- package/dist/ui/popover.cjs +6 -6
- package/dist/ui/popover.cjs.map +1 -1
- package/dist/ui/popover.js +6 -6
- package/dist/ui/popover.js.map +1 -1
- package/dist/ui/tooltip.cjs +16 -2
- package/dist/ui/tooltip.cjs.map +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/dist/ui/tooltip.js +16 -2
- package/dist/ui/tooltip.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/voice/use-athena-voice-session.cjs.map +1 -1
- package/dist/voice/use-athena-voice-session.d.ts +3 -3
- package/dist/voice/use-athena-voice-session.js.map +1 -1
- package/dist/workbench/SessionWorkbench.cjs +378 -0
- package/dist/workbench/SessionWorkbench.cjs.map +1 -0
- package/dist/workbench/SessionWorkbench.d.ts +30 -0
- package/dist/workbench/SessionWorkbench.js +378 -0
- package/dist/workbench/SessionWorkbench.js.map +1 -0
- package/dist/workbench/session-workbench-context.cjs +26 -0
- package/dist/workbench/session-workbench-context.cjs.map +1 -0
- package/dist/workbench/session-workbench-context.d.ts +55 -0
- package/dist/workbench/session-workbench-context.js +26 -0
- package/dist/workbench/session-workbench-context.js.map +1 -0
- package/dist/workbench/session-workbench-model.cjs +288 -0
- package/dist/workbench/session-workbench-model.cjs.map +1 -0
- package/dist/workbench/session-workbench-model.d.ts +168 -0
- package/dist/workbench/session-workbench-model.js +288 -0
- package/dist/workbench/session-workbench-model.js.map +1 -0
- package/dist/workbench/session-workbench-panes.cjs +580 -0
- package/dist/workbench/session-workbench-panes.cjs.map +1 -0
- package/dist/workbench/session-workbench-panes.d.ts +16 -0
- package/dist/workbench/session-workbench-panes.js +580 -0
- package/dist/workbench/session-workbench-panes.js.map +1 -0
- package/dist/workbench/session-workspace-api.cjs +157 -0
- package/dist/workbench/session-workspace-api.cjs.map +1 -0
- package/dist/workbench/session-workspace-api.d.ts +70 -0
- package/dist/workbench/session-workspace-api.js +157 -0
- package/dist/workbench/session-workspace-api.js.map +1 -0
- package/dist/workbench/use-session-workspace.cjs +100 -0
- package/dist/workbench/use-session-workspace.cjs.map +1 -0
- package/dist/workbench/use-session-workspace.d.ts +45 -0
- package/dist/workbench/use-session-workspace.js +100 -0
- package/dist/workbench/use-session-workspace.js.map +1 -0
- package/dist/workbench/workbench-layout-context.cjs +10 -0
- package/dist/workbench/workbench-layout-context.cjs.map +1 -0
- package/dist/workbench/workbench-layout-context.d.ts +17 -0
- package/dist/workbench/workbench-layout-context.js +10 -0
- package/dist/workbench/workbench-layout-context.js.map +1 -0
- package/package.json +21 -10
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js +0 -77
- package/dist/node_modules/@assistant-ui/react-langchain/dist/converter.js.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.cjs.map +0 -1
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js +0 -181
- package/dist/node_modules/@assistant-ui/react-langgraph/dist/convertLangChainMessages.js.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/asset-attachment.js.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/auth-denial.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tool-bridge.js.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/client-tools.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-index.js.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/deep-agent-transport-recipe.js.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +0 -1
- package/dist/packages/agent-runtime/src/errors.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/errors.js.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/github-wake-event.js.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/interrupts.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-author.js.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/message-window.js.map +0 -1
- package/dist/packages/agent-runtime/src/messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/model-context.js.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/optimistic-content.js.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/protocol.js.map +0 -1
- package/dist/packages/agent-runtime/src/queue.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/queue.js.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/runtime-messages.js.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/screen-point.js.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/send-recovery.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-attach-observer.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-state.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-suspended.js.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.cjs +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/statewire-transport.js +0 -11
- package/dist/packages/agent-runtime/src/statewire-transport.js.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/streaming-markdown.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-extras.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-snapshot-cache.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-status.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-outputs.js.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/tool-result.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-conversation-list.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -13
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -13
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-edit-submit.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-runtime.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-window-sync.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-presentation.js.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/voice-turn-grouping.js.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.cjs.map +0 -1
- package/dist/packages/tiptap-markdown-table/src/markdown-table-serializer.js.map +0 -1
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/asset-attachment.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/auth-denial.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tool-bridge.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/client-tools.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/conversation-index.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/edit-command.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/github-wake-event.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-author.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/message-window.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/model-context.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/optimistic-content.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/protocol.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/runtime-messages.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/screen-point.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/send-recovery.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/statewire-attach-observer.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/streaming-markdown.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-extras.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-snapshot-cache.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/thread-status.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-outputs.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/tool-result.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-runtime.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/use-deep-agent-window-sync.js +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.cjs +0 -0
- /package/dist/{packages/agent-runtime → agent-runtime}/src/voice-turn-grouping.js +0 -0
- /package/dist/{packages/react → react}/package.json.cjs.map +0 -0
- /package/dist/{packages/react → react}/package.json.js.map +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.cjs +0 -0
- /package/dist/{packages/tiptap-markdown-table → tiptap-markdown-table}/src/markdown-table-serializer.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQueryClient, useQuery, useInfiniteQuery } from "@tanstack/react-query";
|
|
2
2
|
import { useRef, useMemo, useCallback } from "react";
|
|
3
|
-
import { normalizeConversationListFilter, conversationListFilterKey, conversationListQueryKeys,
|
|
3
|
+
import { CONVERSATION_LIST_DEFAULT_SCOPE_KEY, normalizeConversationListFilter, conversationListFilterKey, conversationListQueryKeys, mergeConversationPages, invalidateConversationListCaches, prependConversationToPage, removeConversationFromPage, patchConversationsInPage } from "./conversation-list.js";
|
|
4
4
|
const DEFAULT_PAGE_SIZE = 20;
|
|
5
5
|
const DEFAULT_STALE_TIME_MS = 3e4;
|
|
6
6
|
const DEFAULT_GC_TIME_MS = 10 * 60 * 1e3;
|
|
@@ -18,7 +18,7 @@ function useConversationList(options) {
|
|
|
18
18
|
refetchInterval = false,
|
|
19
19
|
retry
|
|
20
20
|
} = options;
|
|
21
|
-
const queryClient = useQueryClient();
|
|
21
|
+
const queryClient = useQueryClient(options.queryClient);
|
|
22
22
|
const fetchPageRef = useRef(options.fetchPage);
|
|
23
23
|
fetchPageRef.current = options.fetchPage;
|
|
24
24
|
const normalizedFilter = normalizeConversationListFilter(filter ?? {});
|
|
@@ -37,27 +37,38 @@ function useConversationList(options) {
|
|
|
37
37
|
...refetchOnWindowFocus !== void 0 ? { refetchOnWindowFocus } : {},
|
|
38
38
|
...retry !== void 0 ? { retry } : {}
|
|
39
39
|
};
|
|
40
|
-
const firstPage = useQuery(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
const firstPage = useQuery(
|
|
41
|
+
{
|
|
42
|
+
queryKey: firstPageKey,
|
|
43
|
+
queryFn: ({ signal }) => fetchPageRef.current({ limit: pageSize, offset: 0, filter: normalizedFilter, signal }),
|
|
44
|
+
staleTime,
|
|
45
|
+
gcTime,
|
|
46
|
+
refetchInterval,
|
|
47
|
+
...passthrough
|
|
48
|
+
},
|
|
49
|
+
queryClient
|
|
50
|
+
);
|
|
51
|
+
const history = useInfiniteQuery(
|
|
52
|
+
{
|
|
53
|
+
queryKey: historyKey,
|
|
54
|
+
initialPageParam: pageSize,
|
|
55
|
+
gcTime,
|
|
56
|
+
queryFn: ({ pageParam, signal }) => fetchPageRef.current({
|
|
57
|
+
limit: pageSize,
|
|
58
|
+
offset: pageParam,
|
|
59
|
+
filter: normalizedFilter,
|
|
60
|
+
signal
|
|
61
|
+
}),
|
|
62
|
+
getNextPageParam: (lastPage, _allPages, lastOffset) => lastPage.hasMore ? lastOffset + pageSize : void 0,
|
|
63
|
+
...passthrough,
|
|
64
|
+
// fetchNextPage/refetch still perform explicit fetches for disabled
|
|
65
|
+
// queries. Keeping this observer disabled prevents focus, invalidation,
|
|
66
|
+
// and polling from replaying every retained historical page. This must
|
|
67
|
+
// win over `passthrough.enabled`, so it is spread last.
|
|
68
|
+
enabled: false
|
|
69
|
+
},
|
|
70
|
+
queryClient
|
|
71
|
+
);
|
|
61
72
|
const historyPages = (_a = history.data) == null ? void 0 : _a.pages;
|
|
62
73
|
const hasLoadedHistory = ((historyPages == null ? void 0 : historyPages.length) ?? 0) > 0;
|
|
63
74
|
const conversations = useMemo(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-conversation-list.js","sources":["../../../../agent-runtime/src/use-conversation-list.ts"],"sourcesContent":["import {\n type InfiniteData,\n type QueryClient,\n useInfiniteQuery,\n useQuery,\n useQueryClient,\n} from '@tanstack/react-query';\nimport { useCallback, useMemo, useRef } from 'react';\nimport {\n CONVERSATION_LIST_DEFAULT_SCOPE_KEY,\n type ConversationListFetcher,\n type ConversationListFilter,\n type ConversationListPage,\n type ConversationSummary,\n conversationListFilterKey,\n conversationListQueryKeys,\n invalidateConversationListCaches,\n mergeConversationPages,\n normalizeConversationListFilter,\n patchConversationsInPage,\n prependConversationToPage,\n removeConversationFromPage,\n} from './conversation-list';\n\nconst DEFAULT_PAGE_SIZE = 20;\nconst DEFAULT_STALE_TIME_MS = 30_000;\nconst DEFAULT_GC_TIME_MS = 10 * 60 * 1000;\n\nexport interface UseConversationListOptions {\n /**\n * Transport adapter for one page (GraphQL `listConversations`, the REST\n * thread list, …). Captured in a ref — identity changes do not re-key the\n * cache, so pair a changing fetcher with a changing `scopeKey`.\n */\n fetchPage: ConversationListFetcher;\n filter?: ConversationListFilter;\n pageSize?: number;\n /**\n * Cache identity beyond the filter. MUST include everything that changes\n * whose list this is — principal/user id, backend base URL — so a\n * credential swap can never serve another identity's rows from the cache.\n */\n scopeKey?: string;\n enabled?: boolean;\n staleTime?: number;\n gcTime?: number;\n refetchOnMount?: boolean | 'always';\n refetchOnWindowFocus?: boolean;\n /**\n * Newest-page freshness is push-based by default (the conversation-index\n * statewire invalidates these caches), so no timer runs unless asked.\n */\n refetchInterval?: number | false;\n retry?: boolean | number | ((failureCount: number, error: Error) => boolean);\n /**\n * The client to cache in. Defaults to the one in context; a hook that may\n * render outside any `QueryClientProvider` (and stays disabled there)\n * passes its own.\n */\n queryClient?: QueryClient;\n}\n\nexport interface ConversationListController {\n /** Merged newest-first rows: live first page + retained history pages. */\n conversations: ConversationSummary[];\n /** Advisory total from the live first page, when the transport counts. */\n totalCount: number | null;\n isLoading: boolean;\n isFetching: boolean;\n /** True once the live first page has resolved at least once. */\n hasResolvedFirstPage: boolean;\n hasNextPage: boolean;\n isFetchingNextPage: boolean;\n /** True while the last next-page request failed (cleared by a successful one). */\n isFetchNextPageError: boolean;\n fetchNextPage: () => Promise<unknown>;\n /** Refetch the live first page (history pages stay frozen). */\n refresh: () => Promise<unknown>;\n /** Invalidate every conversation-list cache in this scope (all filters). */\n invalidate: () => Promise<void>;\n /** Optimistically show a new conversation at the top of THIS filter view. */\n prependConversation: (item: ConversationSummary) => void;\n /** Optimistically drop a conversation from THIS filter view. */\n removeConversation: (threadId: string) => void;\n /** Optimistically patch a conversation's row in THIS filter view. */\n patchConversation: (threadId: string, patch: Partial<ConversationSummary>) => void;\n}\n\n/**\n * The shared headless conversation-list pager (chat-stack unification —\n * thread-list-contract-convergence).\n *\n * Implements, once, the two-tier TanStack Query pattern Olympus and mobile\n * each hand-rolled:\n *\n * - a LIVE first-page query — the only observer that refetches on\n * invalidation/focus, so push-driven freshness costs one page, and\n * - a permanently-disabled infinite \"history\" query whose pages are fetched\n * only by explicit `fetchNextPage()` calls and retained without replay\n * (invalidation/polling never refetches every loaded page).\n *\n * Rows merge newest-first with the live page winning duplicate threads.\n */\nexport function useConversationList(options: UseConversationListOptions): ConversationListController {\n const {\n filter,\n pageSize = DEFAULT_PAGE_SIZE,\n scopeKey = CONVERSATION_LIST_DEFAULT_SCOPE_KEY,\n enabled,\n staleTime = DEFAULT_STALE_TIME_MS,\n gcTime = DEFAULT_GC_TIME_MS,\n refetchOnMount,\n refetchOnWindowFocus,\n refetchInterval = false,\n retry,\n } = options;\n const queryClient = useQueryClient(options.queryClient);\n\n const fetchPageRef = useRef(options.fetchPage);\n fetchPageRef.current = options.fetchPage;\n\n // The normalized filter is both the cache identity (via the key) and what\n // queryFn closures fetch, so a cache entry holds exactly what it claims —\n // fresh-but-equal filter objects from the caller never re-key or refetch.\n // (Plain per-render values: only the serialized key participates in\n // identity, so object freshness here is irrelevant.)\n const normalizedFilter = normalizeConversationListFilter(filter ?? {});\n const filterKey = conversationListFilterKey(normalizedFilter);\n\n const firstPageKey = useMemo(\n () => conversationListQueryKeys.firstPage(scopeKey, filterKey, pageSize),\n [scopeKey, filterKey, pageSize]\n );\n const historyKey = useMemo(\n () => conversationListQueryKeys.history(scopeKey, filterKey, pageSize),\n [scopeKey, filterKey, pageSize]\n );\n\n // React Query merges per-query options OVER the client's defaultOptions with\n // Object.assign, which copies explicitly-`undefined` keys — so passing\n // `refetchOnWindowFocus: undefined` CLOBBERS a consumer's\n // `refetchOnWindowFocus: false` default and silently re-enables focus\n // refetching. Options the caller did not set must therefore be omitted, not\n // forwarded as undefined, so they fall through to the consuming app's client.\n const passthrough = {\n ...(enabled !== undefined ? { enabled } : {}),\n ...(refetchOnMount !== undefined ? { refetchOnMount } : {}),\n ...(refetchOnWindowFocus !== undefined ? { refetchOnWindowFocus } : {}),\n ...(retry !== undefined ? { retry } : {}),\n };\n\n const firstPage = useQuery(\n {\n queryKey: firstPageKey,\n queryFn: ({ signal }) =>\n fetchPageRef.current({ limit: pageSize, offset: 0, filter: normalizedFilter, signal }),\n staleTime,\n gcTime,\n refetchInterval,\n ...passthrough,\n },\n queryClient\n );\n\n const history = useInfiniteQuery(\n {\n queryKey: historyKey,\n initialPageParam: pageSize,\n gcTime,\n queryFn: ({ pageParam, signal }) =>\n fetchPageRef.current({\n limit: pageSize,\n offset: pageParam,\n filter: normalizedFilter,\n signal,\n }),\n getNextPageParam: (lastPage, _allPages, lastOffset) =>\n lastPage.hasMore ? lastOffset + pageSize : undefined,\n ...passthrough,\n // fetchNextPage/refetch still perform explicit fetches for disabled\n // queries. Keeping this observer disabled prevents focus, invalidation,\n // and polling from replaying every retained historical page. This must\n // win over `passthrough.enabled`, so it is spread last.\n enabled: false,\n },\n queryClient\n );\n\n const historyPages = history.data?.pages;\n const hasLoadedHistory = (historyPages?.length ?? 0) > 0;\n\n const conversations = useMemo(\n () =>\n mergeConversationPages([\n ...(firstPage.data ? [firstPage.data] : []),\n ...(historyPages ?? []),\n ]),\n [firstPage.data, historyPages]\n );\n\n const fetchNextHistoryPage = history.fetchNextPage;\n const refetchHistoryFirstPage = history.refetch;\n const fetchNextPage = useCallback(\n () => (hasLoadedHistory ? fetchNextHistoryPage() : refetchHistoryFirstPage()),\n [hasLoadedHistory, fetchNextHistoryPage, refetchHistoryFirstPage]\n );\n\n const refresh = useCallback(() => firstPage.refetch(), [firstPage.refetch]);\n\n const invalidate = useCallback(\n () => invalidateConversationListCaches(queryClient, { scopeKey }),\n [queryClient, scopeKey]\n );\n\n const prependConversation = useCallback(\n (item: ConversationSummary) => {\n queryClient.setQueryData<ConversationListPage>(firstPageKey, (page) =>\n page ? prependConversationToPage(page, item) : page\n );\n },\n [queryClient, firstPageKey]\n );\n\n const removeConversation = useCallback(\n (threadId: string) => {\n queryClient.setQueryData<ConversationListPage>(firstPageKey, (page) =>\n page ? removeConversationFromPage(page, threadId) : page\n );\n queryClient.setQueryData<InfiniteData<ConversationListPage, number>>(historyKey, (data) =>\n data\n ? { ...data, pages: data.pages.map((page) => removeConversationFromPage(page, threadId)) }\n : data\n );\n },\n [queryClient, firstPageKey, historyKey]\n );\n\n const patchConversation = useCallback(\n (threadId: string, patch: Partial<ConversationSummary>) => {\n const match = (item: ConversationSummary) => item.threadId === threadId;\n queryClient.setQueryData<ConversationListPage>(firstPageKey, (page) =>\n page ? patchConversationsInPage(page, match, patch) : page\n );\n queryClient.setQueryData<InfiniteData<ConversationListPage, number>>(historyKey, (data) =>\n data\n ? {\n ...data,\n pages: data.pages.map((page) => patchConversationsInPage(page, match, patch)),\n }\n : data\n );\n },\n [queryClient, firstPageKey, historyKey]\n );\n\n return {\n conversations,\n totalCount: firstPage.data?.totalCount ?? null,\n isLoading: firstPage.isLoading,\n isFetching: firstPage.isFetching || history.isFetching,\n hasResolvedFirstPage: firstPage.data !== undefined,\n hasNextPage: hasLoadedHistory\n ? (history.hasNextPage ?? false)\n : (firstPage.data?.hasMore ?? false),\n isFetchingNextPage: history.isFetchingNextPage || (!hasLoadedHistory && history.isFetching),\n isFetchNextPageError: history.isError,\n fetchNextPage,\n refresh,\n invalidate,\n prependConversation,\n removeConversation,\n patchConversation,\n };\n}\n"],"names":[],"mappings":";;;AAwBA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB,KAAK,KAAK;AA6E9B,SAAS,oBAAoB,SAAiE;;AACnG,QAAM;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,IACA,YAAY;AAAA,IACZ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,EAAA,IACE;AACJ,QAAM,cAAc,eAAe,QAAQ,WAAW;AAEtD,QAAM,eAAe,OAAO,QAAQ,SAAS;AAC7C,eAAa,UAAU,QAAQ;AAO/B,QAAM,mBAAmB,gCAAgC,UAAU,EAAE;AACrE,QAAM,YAAY,0BAA0B,gBAAgB;AAE5D,QAAM,eAAe;AAAA,IACnB,MAAM,0BAA0B,UA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AAA;AAExD,kBAAY;AAAA,QAAyD;AAAA,QAAY,CAAC,SAChF,OACI;AAAA,UACE,GAAG;AAAA,UACH,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,yBAAyB,MAAM,OAAO,KAAK,CAAC;AAAA,QAAA,IAE9E;AAAA,MAAA;AAAA,IAER;AAAA,IACA,CAAC,aAAa,cAAc,UAAU;AAAA,EAAA;AAGxC,SAAO;AAAA,IACL;AAAA,IACA,cAAY,eAAU,SAAV,mBAAgB,eAAc;AAAA,IAC1C,WAAW,UAAU;AAAA,IACrB,YAAY,UAAU,cAAc,QAAQ;AAAA,IAC5C,sBAAsB,UAAU,SAAS;AAAA,IACzC,aAAa,mBACR,QAAQ,eAAe,UACvB,eAAU,SAAV,mBAAgB,YAAW;AAAA,IAChC,oBAAoB,QAAQ,sBAAuB,CAAC,oBAAoB,QAAQ;AAAA,IAChF,sBAAsB,QAAQ;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("@assistant-ui/react-statewire");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const configMutations = require("./config-mutations.cjs");
|
|
6
|
+
const errors = require("./errors.cjs");
|
|
7
|
+
const runconfigContract = require("./generated/runconfig-contract.cjs");
|
|
8
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
function readServerConfig(state) {
|
|
10
|
+
const config = state == null ? void 0 : state.config;
|
|
11
|
+
if (!isRecord(config)) return null;
|
|
12
|
+
const version = config.version;
|
|
13
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version <= 0) return null;
|
|
14
|
+
if (!isRecord(config.custom)) return null;
|
|
15
|
+
return config;
|
|
16
|
+
}
|
|
17
|
+
const CONFIG_WRITE_FORBIDDEN_CODES = /* @__PURE__ */ new Set([
|
|
18
|
+
"config_write_forbidden",
|
|
19
|
+
"thread_write_forbidden"
|
|
20
|
+
]);
|
|
21
|
+
function isConfigWriteForbiddenRejection(error) {
|
|
22
|
+
const payload = errors.statewireRejectionPayload(error);
|
|
23
|
+
if ((payload == null ? void 0 : payload.status) !== 403) return false;
|
|
24
|
+
const detail = payload.detail;
|
|
25
|
+
return typeof (detail == null ? void 0 : detail.code) === "string" && CONFIG_WRITE_FORBIDDEN_CODES.has(detail.code);
|
|
26
|
+
}
|
|
27
|
+
function isConfigSyncUnavailableRejection(error) {
|
|
28
|
+
const payload = errors.statewireRejectionPayload(error);
|
|
29
|
+
if ((payload == null ? void 0 : payload.status) !== 400) return false;
|
|
30
|
+
const detail = payload.detail;
|
|
31
|
+
return (detail == null ? void 0 : detail.code) === "config_sync_unavailable";
|
|
32
|
+
}
|
|
33
|
+
function foldPendingConfigOps(serverConfig, ops) {
|
|
34
|
+
const version = (serverConfig == null ? void 0 : serverConfig.version) ?? 0;
|
|
35
|
+
let custom = (serverConfig == null ? void 0 : serverConfig.custom) ?? {};
|
|
36
|
+
for (const op of ops) {
|
|
37
|
+
if (op.settledVersion !== null && op.settledVersion <= version) continue;
|
|
38
|
+
custom = op.apply(custom);
|
|
39
|
+
}
|
|
40
|
+
return custom;
|
|
41
|
+
}
|
|
42
|
+
function useDeepAgentConfigController({
|
|
43
|
+
serverConfig,
|
|
44
|
+
sendCommand,
|
|
45
|
+
onServerConfig
|
|
46
|
+
}) {
|
|
47
|
+
const [ops, setOps] = react.useState([]);
|
|
48
|
+
const nextOpIdRef = react.useRef(1);
|
|
49
|
+
const sendCommandRef = react.useRef(sendCommand);
|
|
50
|
+
sendCommandRef.current = sendCommand;
|
|
51
|
+
const onServerConfigRef = react.useRef(onServerConfig);
|
|
52
|
+
onServerConfigRef.current = onServerConfig;
|
|
53
|
+
const custom = react.useMemo(() => foldPendingConfigOps(serverConfig, ops), [serverConfig, ops]);
|
|
54
|
+
const serverVersion = (serverConfig == null ? void 0 : serverConfig.version) ?? 0;
|
|
55
|
+
const serverVersionRef = react.useRef(serverVersion);
|
|
56
|
+
serverVersionRef.current = serverVersion;
|
|
57
|
+
react.useEffect(() => {
|
|
58
|
+
setOps((current) => {
|
|
59
|
+
const kept = current.filter(
|
|
60
|
+
(op) => op.settledVersion === null || op.settledVersion > serverVersion
|
|
61
|
+
);
|
|
62
|
+
return kept.length === current.length ? current : kept;
|
|
63
|
+
});
|
|
64
|
+
}, [serverVersion]);
|
|
65
|
+
const lastNotifiedRef = react.useRef(null);
|
|
66
|
+
react.useEffect(() => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (serverConfig === null || serverConfig === lastNotifiedRef.current) return;
|
|
69
|
+
lastNotifiedRef.current = serverConfig;
|
|
70
|
+
(_a = onServerConfigRef.current) == null ? void 0 : _a.call(onServerConfigRef, { version: serverConfig.version, custom });
|
|
71
|
+
}, [serverConfig, custom]);
|
|
72
|
+
const run = react.useCallback(
|
|
73
|
+
async (command, apply) => {
|
|
74
|
+
const id = nextOpIdRef.current++;
|
|
75
|
+
setOps((current) => [...current, { id, apply, settledVersion: null }]);
|
|
76
|
+
try {
|
|
77
|
+
const raw = await sendCommandRef.current(command);
|
|
78
|
+
const version = typeof (raw == null ? void 0 : raw.version) === "number" ? raw.version : Number.POSITIVE_INFINITY;
|
|
79
|
+
setOps(
|
|
80
|
+
(current) => version <= serverVersionRef.current ? current.filter((op) => op.id !== id) : current.map((op) => op.id === id ? { ...op, settledVersion: version } : op)
|
|
81
|
+
);
|
|
82
|
+
return {
|
|
83
|
+
version: Number.isFinite(version) ? version : 0,
|
|
84
|
+
custom: isRecord(raw == null ? void 0 : raw.custom) ? raw.custom : apply({})
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
setOps((current) => current.filter((op) => op.id !== id));
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
[]
|
|
92
|
+
);
|
|
93
|
+
const patchConfig = react.useCallback(
|
|
94
|
+
(patch) => run(
|
|
95
|
+
{ type: runconfigContract.DEEP_AGENT_CONFIG_COMMANDS.patch, patch },
|
|
96
|
+
(base) => configMutations.applyConfigPatch(base, patch)
|
|
97
|
+
),
|
|
98
|
+
[run]
|
|
99
|
+
);
|
|
100
|
+
const enableTools = react.useCallback(
|
|
101
|
+
(toolIds) => run(
|
|
102
|
+
{ type: runconfigContract.DEEP_AGENT_CONFIG_COMMANDS.toolsEnable, toolIds: [...toolIds] },
|
|
103
|
+
(base) => configMutations.applyToolsEnable(base, toolIds)
|
|
104
|
+
),
|
|
105
|
+
[run]
|
|
106
|
+
);
|
|
107
|
+
const disableTools = react.useCallback(
|
|
108
|
+
(toolIds) => run(
|
|
109
|
+
{ type: runconfigContract.DEEP_AGENT_CONFIG_COMMANDS.toolsDisable, toolIds: [...toolIds] },
|
|
110
|
+
(base) => configMutations.applyToolsDisable(base, toolIds)
|
|
111
|
+
),
|
|
112
|
+
[run]
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
configVersion: serverVersion,
|
|
116
|
+
serverConfig,
|
|
117
|
+
custom,
|
|
118
|
+
hasPendingWrites: ops.some((op) => op.settledVersion === null),
|
|
119
|
+
patchConfig,
|
|
120
|
+
enableTools,
|
|
121
|
+
disableTools
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
exports.foldPendingConfigOps = foldPendingConfigOps;
|
|
125
|
+
exports.isConfigSyncUnavailableRejection = isConfigSyncUnavailableRejection;
|
|
126
|
+
exports.isConfigWriteForbiddenRejection = isConfigWriteForbiddenRejection;
|
|
127
|
+
exports.readServerConfig = readServerConfig;
|
|
128
|
+
exports.useDeepAgentConfigController = useDeepAgentConfigController;
|
|
129
|
+
//# sourceMappingURL=use-deep-agent-config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-config.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-config.ts"],"sourcesContent":["import { useStatewireSendCommand, useStatewireState } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n applyConfigPatch,\n applyToolsDisable,\n applyToolsEnable,\n type ThreadConfigCustom,\n type ThreadConfigPatch,\n} from './config-mutations';\nimport { statewireRejectionPayload } from './errors';\nimport { DEEP_AGENT_CONFIG_COMMANDS } from './generated/runconfig-contract';\nimport { readDeepAgentStateThreadId } from './statewire-state';\n\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** Set / unset top-level keys of the thread's server config (`null` unsets). */\n configPatch: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.patch;\n patch: Record<string, unknown>;\n };\n /** Append ids to the thread's `enabled_tools`. */\n configToolsEnable: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsEnable;\n toolIds: string[];\n };\n /** Remove ids from the thread's `enabled_tools`. */\n configToolsDisable: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsDisable;\n toolIds: string[];\n };\n }\n }\n}\n\n/**\n * The replicated `state.config` lane of a thread with server-authoritative\n * run config. Absent — and `readServerConfig` returns `null` — while the\n * thread has never been configured (version 0: a brand-new thread, or one\n * created by a client predating the lane).\n */\nexport interface DeepAgentServerConfig {\n /** Monotonic server-incremented version; always >= 1 when the lane exists. */\n version: number;\n /** The thread-config keys every run on this thread uses as its base. */\n custom: ThreadConfigCustom;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Read the server-config lane off a raw statewire state.\n *\n * Identity-preserving (returns the raw `state.config` reference), so it is\n * safe as a `useStatewireState` selector: the reference only changes when the\n * server writes the lane.\n */\nexport function readServerConfig(state: unknown): DeepAgentServerConfig | null {\n const config = (state as { config?: unknown } | null | undefined)?.config;\n if (!isRecord(config)) return null;\n const version = config.version;\n if (typeof version !== 'number' || !Number.isInteger(version) || version <= 0) return null;\n if (!isRecord(config.custom)) return null;\n return config as unknown as DeepAgentServerConfig;\n}\n\n/** The thread's server config version: 0 while the thread has never been configured. */\nexport function readConfigVersion(state: unknown): number {\n return readServerConfig(state)?.version ?? 0;\n}\n\n/**\n * {@link readServerConfig}, but only from a state `threadId`'s own attach\n * produced (`readDeepAgentStateThreadId`); any other state reads as\n * unconfigured. With no `threadId` it is {@link readServerConfig} unchanged.\n *\n * Identity-preserving like {@link readServerConfig}, so it is safe as a\n * `useStatewireState` selector.\n */\nexport function readThreadServerConfig({\n state,\n threadId,\n}: {\n state: unknown;\n threadId: string | undefined;\n}): DeepAgentServerConfig | null {\n if (threadId !== undefined && readDeepAgentStateThreadId(state) !== threadId) return null;\n return readServerConfig(state);\n}\n\n/**\n * The 403 rejection codes a view-only collaborator's `config/*` write can\n * come back with: `config_write_forbidden` from the config host's own gate,\n * or `thread_write_forbidden` from the host-wide mutation gate that runs\n * ahead of it and refuses every thread-mutating command on a view grant.\n */\nconst CONFIG_WRITE_FORBIDDEN_CODES: ReadonlySet<string> = new Set([\n 'config_write_forbidden',\n 'thread_write_forbidden',\n]);\n\n/**\n * Whether a rejected `config/*` command was refused because the submitter\n * only has view access to the session. The write is not retriable by that\n * user; hosts disable their config controls.\n */\nexport function isConfigWriteForbiddenRejection(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n if (payload?.status !== 403) return false;\n const detail = payload.detail as { code?: unknown } | undefined;\n return typeof detail?.code === 'string' && CONFIG_WRITE_FORBIDDEN_CODES.has(detail.code);\n}\n\n/**\n * Whether a rejected `config/*` command was refused because the thread's\n * workspace cannot hold server config at all (`config_sync_unavailable`, a\n * regionally-pinned workspace). No write will ever succeed on the thread;\n * hosts stop issuing them and send their full config per run instead.\n */\nexport function isConfigSyncUnavailableRejection(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n if (payload?.status !== 400) return false;\n const detail = payload.detail as { code?: unknown } | undefined;\n return detail?.code === 'config_sync_unavailable';\n}\n\n/** The settled result of a `config/*` command: the new server config. */\nexport interface DeepAgentConfigWriteResult {\n version: number;\n custom: ThreadConfigCustom;\n}\n\n/** An observed server-config version, delivered to the host callback. */\nexport interface DeepAgentServerConfigEvent {\n version: number;\n /** The server config with this client's still-pending writes folded over. */\n custom: ThreadConfigCustom;\n}\n\ninterface PendingOp {\n id: number;\n apply: (custom: ThreadConfigCustom) => ThreadConfigCustom;\n /** The version the server assigned this op; retired once the lane reaches it. */\n settledVersion: number | null;\n}\n\n/**\n * Fold the pending optimistic ops over the server config — the effective\n * config a client shows and sends against. Pure, for the tests.\n */\nexport function foldPendingConfigOps(\n serverConfig: DeepAgentServerConfig | null,\n ops: readonly Pick<PendingOp, 'apply' | 'settledVersion'>[]\n): ThreadConfigCustom {\n const version = serverConfig?.version ?? 0;\n let custom: ThreadConfigCustom = serverConfig?.custom ?? {};\n for (const op of ops) {\n if (op.settledVersion !== null && op.settledVersion <= version) continue;\n custom = op.apply(custom);\n }\n return custom;\n}\n\nexport interface UseDeepAgentConfigOptions {\n /**\n * Fired whenever the server writes a new version of the lane (another\n * device, the seed, or the echo of our own command), with this client's\n * still-pending writes folded over — hosts mirror it into their local\n * store; nothing is ever clobbered because pending edits stay on top.\n */\n onServerConfig?: (event: DeepAgentServerConfigEvent) => void;\n /**\n * The thread this binding serves. When set, the lane is read only from a\n * state that thread's own attach produced ({@link readThreadServerConfig}):\n * for the first render after a thread switch the client still projects the\n * previous thread's state, and adopting its lane would report the previous\n * thread's config and version as this thread's.\n */\n threadId?: string;\n}\n\nexport interface UseDeepAgentConfigResult {\n /** Reactive server config version (0 while the thread has never been configured). */\n configVersion: number;\n /** Reactive server-config lane, or `null` at version 0. */\n serverConfig: DeepAgentServerConfig | null;\n /**\n * The effective thread config: the server lane with this client's pending\n * writes folded over. `{}` at version 0 with nothing pending.\n */\n custom: ThreadConfigCustom;\n /** `true` while at least one `config/*` command is unacknowledged by the server. */\n hasPendingWrites: boolean;\n /** `config/patch` — set / unset top-level keys; `null` unsets. */\n patchConfig: (patch: ThreadConfigPatch) => Promise<DeepAgentConfigWriteResult>;\n /** `config/tools/enable`. */\n enableTools: (toolIds: readonly string[]) => Promise<DeepAgentConfigWriteResult>;\n /** `config/tools/disable`. */\n disableTools: (toolIds: readonly string[]) => Promise<DeepAgentConfigWriteResult>;\n}\n\ntype ConfigCommand =\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.patch; patch: Record<string, unknown> }\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsEnable; toolIds: string[] }\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsDisable; toolIds: string[] };\n\n/**\n * The server-authoritative thread config of a deep-agent thread.\n *\n * Every capability a run depends on — model, agent binding, enabled tools,\n * sandbox, environment, … — lives on the thread's server config lane and is\n * changed only through the `config/*` commands. Sends carry per-send keys\n * only (`pickPerSendCustom`). The commands are applied optimistically: each\n * one folds its transform over the server config the moment it is issued\n * (`custom`), and retires once the lane reaches the version the server\n * assigned it; a rejection drops it, so the UI snaps back to the truth.\n *\n * Must be mounted under the thread's statewire context (an `AuiProvider`\n * holding `useDeepAgentThread`'s element), keyed by the thread identity so a\n * thread switch remounts it with an empty pending set. A binding that persists\n * what it reads per thread passes `threadId`, so the render that still sees\n * the previous thread's state after a switch reads no lane at all.\n */\nexport function useDeepAgentConfig({\n threadId,\n ...options\n}: UseDeepAgentConfigOptions = {}): UseDeepAgentConfigResult {\n const sendCommand = useStatewireSendCommand();\n const selectServerConfig = useCallback(\n (state: unknown) => readThreadServerConfig({ state, threadId }),\n [threadId]\n );\n const serverConfig = useStatewireState(selectServerConfig);\n return useDeepAgentConfigController({\n serverConfig,\n sendCommand: (command) => Promise.resolve(sendCommand(command as never)),\n ...options,\n });\n}\n\nexport interface DeepAgentConfigControllerInputs extends UseDeepAgentConfigOptions {\n serverConfig: DeepAgentServerConfig | null;\n sendCommand: (command: ConfigCommand) => Promise<unknown>;\n}\n\n/**\n * The transport-agnostic body of {@link useDeepAgentConfig}, with the reactive\n * inputs injected — so the optimistic-overlay behavior is testable without a\n * statewire session.\n */\nexport function useDeepAgentConfigController({\n serverConfig,\n sendCommand,\n onServerConfig,\n}: DeepAgentConfigControllerInputs): UseDeepAgentConfigResult {\n const [ops, setOps] = useState<readonly PendingOp[]>([]);\n const nextOpIdRef = useRef(1);\n const sendCommandRef = useRef(sendCommand);\n sendCommandRef.current = sendCommand;\n const onServerConfigRef = useRef(onServerConfig);\n onServerConfigRef.current = onServerConfig;\n\n const custom = useMemo(() => foldPendingConfigOps(serverConfig, ops), [serverConfig, ops]);\n\n // Retire ops the lane has caught up with (their transform is now part of\n // the server config itself).\n const serverVersion = serverConfig?.version ?? 0;\n const serverVersionRef = useRef(serverVersion);\n serverVersionRef.current = serverVersion;\n useEffect(() => {\n setOps((current) => {\n const kept = current.filter(\n (op) => op.settledVersion === null || op.settledVersion > serverVersion\n );\n return kept.length === current.length ? current : kept;\n });\n }, [serverVersion]);\n\n const lastNotifiedRef = useRef<DeepAgentServerConfig | null>(null);\n useEffect(() => {\n if (serverConfig === null || serverConfig === lastNotifiedRef.current) return;\n lastNotifiedRef.current = serverConfig;\n onServerConfigRef.current?.({ version: serverConfig.version, custom });\n }, [serverConfig, custom]);\n\n const run = useCallback(\n async (\n command: ConfigCommand,\n apply: PendingOp['apply']\n ): Promise<DeepAgentConfigWriteResult> => {\n const id = nextOpIdRef.current++;\n setOps((current) => [...current, { id, apply, settledVersion: null }]);\n try {\n const raw = (await sendCommandRef.current(command)) as\n | { version?: unknown; custom?: unknown }\n | null\n | undefined;\n const version = typeof raw?.version === 'number' ? raw.version : Number.POSITIVE_INFINITY;\n // The lane echo may have landed before the acknowledgement: retire\n // now if so, otherwise stamp the version for the retire effect.\n setOps((current) =>\n version <= serverVersionRef.current\n ? current.filter((op) => op.id !== id)\n : current.map((op) => (op.id === id ? { ...op, settledVersion: version } : op))\n );\n return {\n version: Number.isFinite(version) ? version : 0,\n custom: isRecord(raw?.custom) ? raw.custom : apply({}),\n };\n } catch (error) {\n setOps((current) => current.filter((op) => op.id !== id));\n throw error;\n }\n },\n []\n );\n\n const patchConfig = useCallback(\n (patch: ThreadConfigPatch) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.patch, patch }, (base) =>\n applyConfigPatch(base, patch)\n ),\n [run]\n );\n const enableTools = useCallback(\n (toolIds: readonly string[]) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.toolsEnable, toolIds: [...toolIds] }, (base) =>\n applyToolsEnable(base, toolIds)\n ),\n [run]\n );\n const disableTools = useCallback(\n (toolIds: readonly string[]) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.toolsDisable, toolIds: [...toolIds] }, (base) =>\n applyToolsDisable(base, toolIds)\n ),\n [run]\n );\n\n return {\n configVersion: serverVersion,\n serverConfig,\n custom,\n hasPendingWrites: ops.some((op) => op.settledVersion === null),\n patchConfig,\n enableTools,\n disableTools,\n };\n}\n"],"names":["statewireRejectionPayload","useState","useRef","useMemo","useEffect","useCallback","DEEP_AGENT_CONFIG_COMMANDS","applyConfigPatch","applyToolsEnable","applyToolsDisable"],"mappings":";;;;;;;AAgDA,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAS9D,SAAS,iBAAiB,OAA8C;AAC7E,QAAM,SAAU,+BAAmD;AACnE,MAAI,CAAC,SAAS,MAAM,EAAG,QAAO;AAC9B,QAAM,UAAU,OAAO;AACvB,MAAI,OAAO,YAAY,YAAY,CAAC,OAAO,UAAU,OAAO,KAAK,WAAW,EAAG,QAAO;AACtF,MAAI,CAAC,SAAS,OAAO,MAAM,EAAG,QAAO;AACrC,SAAO;AACT;AAgCA,MAAM,mDAAwD,IAAI;AAAA,EAChE;AAAA,EACA;AACF,CAAC;AAOM,SAAS,gCAAgC,OAAyB;AACvE,QAAM,UAAUA,OAAAA,0BAA0B,KAAK;AAC/C,OAAI,mCAAS,YAAW,IAAK,QAAO;AACpC,QAAM,SAAS,QAAQ;AACvB,S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AAA,MAAI,EAAE,MAAMC,kBAAAA,2BAA2B,aAAa,SAAS,CAAC,GAAG,OAAO,EAAA;AAAA,MAAK,CAAC,SAC5EE,iCAAiB,MAAM,OAAO;AAAA,IAAA;AAAA,IAElC,CAAC,GAAG;AAAA,EAAA;AAEN,QAAM,eAAeH,MAAAA;AAAAA,IACnB,CAAC,YACC;AAAA,MAAI,EAAE,MAAMC,kBAAAA,2BAA2B,cAAc,SAAS,CAAC,GAAG,OAAO,EAAA;AAAA,MAAK,CAAC,SAC7EG,kCAAkB,MAAM,OAAO;AAAA,IAAA;AAAA,IAEnC,CAAC,GAAG;AAAA,EAAA;AAGN,SAAO;AAAA,IACL,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA,kBAAkB,IAAI,KAAK,CAAC,OAAO,GAAG,mBAAmB,IAAI;AAAA,IAC7D;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;;"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import "@assistant-ui/react-statewire";
|
|
2
|
+
import { useState, useRef, useMemo, useEffect, useCallback } from "react";
|
|
3
|
+
import { applyConfigPatch, applyToolsEnable, applyToolsDisable } from "./config-mutations.js";
|
|
4
|
+
import { statewireRejectionPayload } from "./errors.js";
|
|
5
|
+
import { DEEP_AGENT_CONFIG_COMMANDS } from "./generated/runconfig-contract.js";
|
|
6
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
function readServerConfig(state) {
|
|
8
|
+
const config = state == null ? void 0 : state.config;
|
|
9
|
+
if (!isRecord(config)) return null;
|
|
10
|
+
const version = config.version;
|
|
11
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version <= 0) return null;
|
|
12
|
+
if (!isRecord(config.custom)) return null;
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
const CONFIG_WRITE_FORBIDDEN_CODES = /* @__PURE__ */ new Set([
|
|
16
|
+
"config_write_forbidden",
|
|
17
|
+
"thread_write_forbidden"
|
|
18
|
+
]);
|
|
19
|
+
function isConfigWriteForbiddenRejection(error) {
|
|
20
|
+
const payload = statewireRejectionPayload(error);
|
|
21
|
+
if ((payload == null ? void 0 : payload.status) !== 403) return false;
|
|
22
|
+
const detail = payload.detail;
|
|
23
|
+
return typeof (detail == null ? void 0 : detail.code) === "string" && CONFIG_WRITE_FORBIDDEN_CODES.has(detail.code);
|
|
24
|
+
}
|
|
25
|
+
function isConfigSyncUnavailableRejection(error) {
|
|
26
|
+
const payload = statewireRejectionPayload(error);
|
|
27
|
+
if ((payload == null ? void 0 : payload.status) !== 400) return false;
|
|
28
|
+
const detail = payload.detail;
|
|
29
|
+
return (detail == null ? void 0 : detail.code) === "config_sync_unavailable";
|
|
30
|
+
}
|
|
31
|
+
function foldPendingConfigOps(serverConfig, ops) {
|
|
32
|
+
const version = (serverConfig == null ? void 0 : serverConfig.version) ?? 0;
|
|
33
|
+
let custom = (serverConfig == null ? void 0 : serverConfig.custom) ?? {};
|
|
34
|
+
for (const op of ops) {
|
|
35
|
+
if (op.settledVersion !== null && op.settledVersion <= version) continue;
|
|
36
|
+
custom = op.apply(custom);
|
|
37
|
+
}
|
|
38
|
+
return custom;
|
|
39
|
+
}
|
|
40
|
+
function useDeepAgentConfigController({
|
|
41
|
+
serverConfig,
|
|
42
|
+
sendCommand,
|
|
43
|
+
onServerConfig
|
|
44
|
+
}) {
|
|
45
|
+
const [ops, setOps] = useState([]);
|
|
46
|
+
const nextOpIdRef = useRef(1);
|
|
47
|
+
const sendCommandRef = useRef(sendCommand);
|
|
48
|
+
sendCommandRef.current = sendCommand;
|
|
49
|
+
const onServerConfigRef = useRef(onServerConfig);
|
|
50
|
+
onServerConfigRef.current = onServerConfig;
|
|
51
|
+
const custom = useMemo(() => foldPendingConfigOps(serverConfig, ops), [serverConfig, ops]);
|
|
52
|
+
const serverVersion = (serverConfig == null ? void 0 : serverConfig.version) ?? 0;
|
|
53
|
+
const serverVersionRef = useRef(serverVersion);
|
|
54
|
+
serverVersionRef.current = serverVersion;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
setOps((current) => {
|
|
57
|
+
const kept = current.filter(
|
|
58
|
+
(op) => op.settledVersion === null || op.settledVersion > serverVersion
|
|
59
|
+
);
|
|
60
|
+
return kept.length === current.length ? current : kept;
|
|
61
|
+
});
|
|
62
|
+
}, [serverVersion]);
|
|
63
|
+
const lastNotifiedRef = useRef(null);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
var _a;
|
|
66
|
+
if (serverConfig === null || serverConfig === lastNotifiedRef.current) return;
|
|
67
|
+
lastNotifiedRef.current = serverConfig;
|
|
68
|
+
(_a = onServerConfigRef.current) == null ? void 0 : _a.call(onServerConfigRef, { version: serverConfig.version, custom });
|
|
69
|
+
}, [serverConfig, custom]);
|
|
70
|
+
const run = useCallback(
|
|
71
|
+
async (command, apply) => {
|
|
72
|
+
const id = nextOpIdRef.current++;
|
|
73
|
+
setOps((current) => [...current, { id, apply, settledVersion: null }]);
|
|
74
|
+
try {
|
|
75
|
+
const raw = await sendCommandRef.current(command);
|
|
76
|
+
const version = typeof (raw == null ? void 0 : raw.version) === "number" ? raw.version : Number.POSITIVE_INFINITY;
|
|
77
|
+
setOps(
|
|
78
|
+
(current) => version <= serverVersionRef.current ? current.filter((op) => op.id !== id) : current.map((op) => op.id === id ? { ...op, settledVersion: version } : op)
|
|
79
|
+
);
|
|
80
|
+
return {
|
|
81
|
+
version: Number.isFinite(version) ? version : 0,
|
|
82
|
+
custom: isRecord(raw == null ? void 0 : raw.custom) ? raw.custom : apply({})
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
setOps((current) => current.filter((op) => op.id !== id));
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[]
|
|
90
|
+
);
|
|
91
|
+
const patchConfig = useCallback(
|
|
92
|
+
(patch) => run(
|
|
93
|
+
{ type: DEEP_AGENT_CONFIG_COMMANDS.patch, patch },
|
|
94
|
+
(base) => applyConfigPatch(base, patch)
|
|
95
|
+
),
|
|
96
|
+
[run]
|
|
97
|
+
);
|
|
98
|
+
const enableTools = useCallback(
|
|
99
|
+
(toolIds) => run(
|
|
100
|
+
{ type: DEEP_AGENT_CONFIG_COMMANDS.toolsEnable, toolIds: [...toolIds] },
|
|
101
|
+
(base) => applyToolsEnable(base, toolIds)
|
|
102
|
+
),
|
|
103
|
+
[run]
|
|
104
|
+
);
|
|
105
|
+
const disableTools = useCallback(
|
|
106
|
+
(toolIds) => run(
|
|
107
|
+
{ type: DEEP_AGENT_CONFIG_COMMANDS.toolsDisable, toolIds: [...toolIds] },
|
|
108
|
+
(base) => applyToolsDisable(base, toolIds)
|
|
109
|
+
),
|
|
110
|
+
[run]
|
|
111
|
+
);
|
|
112
|
+
return {
|
|
113
|
+
configVersion: serverVersion,
|
|
114
|
+
serverConfig,
|
|
115
|
+
custom,
|
|
116
|
+
hasPendingWrites: ops.some((op) => op.settledVersion === null),
|
|
117
|
+
patchConfig,
|
|
118
|
+
enableTools,
|
|
119
|
+
disableTools
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
foldPendingConfigOps,
|
|
124
|
+
isConfigSyncUnavailableRejection,
|
|
125
|
+
isConfigWriteForbiddenRejection,
|
|
126
|
+
readServerConfig,
|
|
127
|
+
useDeepAgentConfigController
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=use-deep-agent-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-config.js","sources":["../../../../agent-runtime/src/use-deep-agent-config.ts"],"sourcesContent":["import { useStatewireSendCommand, useStatewireState } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n applyConfigPatch,\n applyToolsDisable,\n applyToolsEnable,\n type ThreadConfigCustom,\n type ThreadConfigPatch,\n} from './config-mutations';\nimport { statewireRejectionPayload } from './errors';\nimport { DEEP_AGENT_CONFIG_COMMANDS } from './generated/runconfig-contract';\nimport { readDeepAgentStateThreadId } from './statewire-state';\n\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** Set / unset top-level keys of the thread's server config (`null` unsets). */\n configPatch: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.patch;\n patch: Record<string, unknown>;\n };\n /** Append ids to the thread's `enabled_tools`. */\n configToolsEnable: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsEnable;\n toolIds: string[];\n };\n /** Remove ids from the thread's `enabled_tools`. */\n configToolsDisable: {\n type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsDisable;\n toolIds: string[];\n };\n }\n }\n}\n\n/**\n * The replicated `state.config` lane of a thread with server-authoritative\n * run config. Absent — and `readServerConfig` returns `null` — while the\n * thread has never been configured (version 0: a brand-new thread, or one\n * created by a client predating the lane).\n */\nexport interface DeepAgentServerConfig {\n /** Monotonic server-incremented version; always >= 1 when the lane exists. */\n version: number;\n /** The thread-config keys every run on this thread uses as its base. */\n custom: ThreadConfigCustom;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Read the server-config lane off a raw statewire state.\n *\n * Identity-preserving (returns the raw `state.config` reference), so it is\n * safe as a `useStatewireState` selector: the reference only changes when the\n * server writes the lane.\n */\nexport function readServerConfig(state: unknown): DeepAgentServerConfig | null {\n const config = (state as { config?: unknown } | null | undefined)?.config;\n if (!isRecord(config)) return null;\n const version = config.version;\n if (typeof version !== 'number' || !Number.isInteger(version) || version <= 0) return null;\n if (!isRecord(config.custom)) return null;\n return config as unknown as DeepAgentServerConfig;\n}\n\n/** The thread's server config version: 0 while the thread has never been configured. */\nexport function readConfigVersion(state: unknown): number {\n return readServerConfig(state)?.version ?? 0;\n}\n\n/**\n * {@link readServerConfig}, but only from a state `threadId`'s own attach\n * produced (`readDeepAgentStateThreadId`); any other state reads as\n * unconfigured. With no `threadId` it is {@link readServerConfig} unchanged.\n *\n * Identity-preserving like {@link readServerConfig}, so it is safe as a\n * `useStatewireState` selector.\n */\nexport function readThreadServerConfig({\n state,\n threadId,\n}: {\n state: unknown;\n threadId: string | undefined;\n}): DeepAgentServerConfig | null {\n if (threadId !== undefined && readDeepAgentStateThreadId(state) !== threadId) return null;\n return readServerConfig(state);\n}\n\n/**\n * The 403 rejection codes a view-only collaborator's `config/*` write can\n * come back with: `config_write_forbidden` from the config host's own gate,\n * or `thread_write_forbidden` from the host-wide mutation gate that runs\n * ahead of it and refuses every thread-mutating command on a view grant.\n */\nconst CONFIG_WRITE_FORBIDDEN_CODES: ReadonlySet<string> = new Set([\n 'config_write_forbidden',\n 'thread_write_forbidden',\n]);\n\n/**\n * Whether a rejected `config/*` command was refused because the submitter\n * only has view access to the session. The write is not retriable by that\n * user; hosts disable their config controls.\n */\nexport function isConfigWriteForbiddenRejection(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n if (payload?.status !== 403) return false;\n const detail = payload.detail as { code?: unknown } | undefined;\n return typeof detail?.code === 'string' && CONFIG_WRITE_FORBIDDEN_CODES.has(detail.code);\n}\n\n/**\n * Whether a rejected `config/*` command was refused because the thread's\n * workspace cannot hold server config at all (`config_sync_unavailable`, a\n * regionally-pinned workspace). No write will ever succeed on the thread;\n * hosts stop issuing them and send their full config per run instead.\n */\nexport function isConfigSyncUnavailableRejection(error: unknown): boolean {\n const payload = statewireRejectionPayload(error);\n if (payload?.status !== 400) return false;\n const detail = payload.detail as { code?: unknown } | undefined;\n return detail?.code === 'config_sync_unavailable';\n}\n\n/** The settled result of a `config/*` command: the new server config. */\nexport interface DeepAgentConfigWriteResult {\n version: number;\n custom: ThreadConfigCustom;\n}\n\n/** An observed server-config version, delivered to the host callback. */\nexport interface DeepAgentServerConfigEvent {\n version: number;\n /** The server config with this client's still-pending writes folded over. */\n custom: ThreadConfigCustom;\n}\n\ninterface PendingOp {\n id: number;\n apply: (custom: ThreadConfigCustom) => ThreadConfigCustom;\n /** The version the server assigned this op; retired once the lane reaches it. */\n settledVersion: number | null;\n}\n\n/**\n * Fold the pending optimistic ops over the server config — the effective\n * config a client shows and sends against. Pure, for the tests.\n */\nexport function foldPendingConfigOps(\n serverConfig: DeepAgentServerConfig | null,\n ops: readonly Pick<PendingOp, 'apply' | 'settledVersion'>[]\n): ThreadConfigCustom {\n const version = serverConfig?.version ?? 0;\n let custom: ThreadConfigCustom = serverConfig?.custom ?? {};\n for (const op of ops) {\n if (op.settledVersion !== null && op.settledVersion <= version) continue;\n custom = op.apply(custom);\n }\n return custom;\n}\n\nexport interface UseDeepAgentConfigOptions {\n /**\n * Fired whenever the server writes a new version of the lane (another\n * device, the seed, or the echo of our own command), with this client's\n * still-pending writes folded over — hosts mirror it into their local\n * store; nothing is ever clobbered because pending edits stay on top.\n */\n onServerConfig?: (event: DeepAgentServerConfigEvent) => void;\n /**\n * The thread this binding serves. When set, the lane is read only from a\n * state that thread's own attach produced ({@link readThreadServerConfig}):\n * for the first render after a thread switch the client still projects the\n * previous thread's state, and adopting its lane would report the previous\n * thread's config and version as this thread's.\n */\n threadId?: string;\n}\n\nexport interface UseDeepAgentConfigResult {\n /** Reactive server config version (0 while the thread has never been configured). */\n configVersion: number;\n /** Reactive server-config lane, or `null` at version 0. */\n serverConfig: DeepAgentServerConfig | null;\n /**\n * The effective thread config: the server lane with this client's pending\n * writes folded over. `{}` at version 0 with nothing pending.\n */\n custom: ThreadConfigCustom;\n /** `true` while at least one `config/*` command is unacknowledged by the server. */\n hasPendingWrites: boolean;\n /** `config/patch` — set / unset top-level keys; `null` unsets. */\n patchConfig: (patch: ThreadConfigPatch) => Promise<DeepAgentConfigWriteResult>;\n /** `config/tools/enable`. */\n enableTools: (toolIds: readonly string[]) => Promise<DeepAgentConfigWriteResult>;\n /** `config/tools/disable`. */\n disableTools: (toolIds: readonly string[]) => Promise<DeepAgentConfigWriteResult>;\n}\n\ntype ConfigCommand =\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.patch; patch: Record<string, unknown> }\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsEnable; toolIds: string[] }\n | { type: typeof DEEP_AGENT_CONFIG_COMMANDS.toolsDisable; toolIds: string[] };\n\n/**\n * The server-authoritative thread config of a deep-agent thread.\n *\n * Every capability a run depends on — model, agent binding, enabled tools,\n * sandbox, environment, … — lives on the thread's server config lane and is\n * changed only through the `config/*` commands. Sends carry per-send keys\n * only (`pickPerSendCustom`). The commands are applied optimistically: each\n * one folds its transform over the server config the moment it is issued\n * (`custom`), and retires once the lane reaches the version the server\n * assigned it; a rejection drops it, so the UI snaps back to the truth.\n *\n * Must be mounted under the thread's statewire context (an `AuiProvider`\n * holding `useDeepAgentThread`'s element), keyed by the thread identity so a\n * thread switch remounts it with an empty pending set. A binding that persists\n * what it reads per thread passes `threadId`, so the render that still sees\n * the previous thread's state after a switch reads no lane at all.\n */\nexport function useDeepAgentConfig({\n threadId,\n ...options\n}: UseDeepAgentConfigOptions = {}): UseDeepAgentConfigResult {\n const sendCommand = useStatewireSendCommand();\n const selectServerConfig = useCallback(\n (state: unknown) => readThreadServerConfig({ state, threadId }),\n [threadId]\n );\n const serverConfig = useStatewireState(selectServerConfig);\n return useDeepAgentConfigController({\n serverConfig,\n sendCommand: (command) => Promise.resolve(sendCommand(command as never)),\n ...options,\n });\n}\n\nexport interface DeepAgentConfigControllerInputs extends UseDeepAgentConfigOptions {\n serverConfig: DeepAgentServerConfig | null;\n sendCommand: (command: ConfigCommand) => Promise<unknown>;\n}\n\n/**\n * The transport-agnostic body of {@link useDeepAgentConfig}, with the reactive\n * inputs injected — so the optimistic-overlay behavior is testable without a\n * statewire session.\n */\nexport function useDeepAgentConfigController({\n serverConfig,\n sendCommand,\n onServerConfig,\n}: DeepAgentConfigControllerInputs): UseDeepAgentConfigResult {\n const [ops, setOps] = useState<readonly PendingOp[]>([]);\n const nextOpIdRef = useRef(1);\n const sendCommandRef = useRef(sendCommand);\n sendCommandRef.current = sendCommand;\n const onServerConfigRef = useRef(onServerConfig);\n onServerConfigRef.current = onServerConfig;\n\n const custom = useMemo(() => foldPendingConfigOps(serverConfig, ops), [serverConfig, ops]);\n\n // Retire ops the lane has caught up with (their transform is now part of\n // the server config itself).\n const serverVersion = serverConfig?.version ?? 0;\n const serverVersionRef = useRef(serverVersion);\n serverVersionRef.current = serverVersion;\n useEffect(() => {\n setOps((current) => {\n const kept = current.filter(\n (op) => op.settledVersion === null || op.settledVersion > serverVersion\n );\n return kept.length === current.length ? current : kept;\n });\n }, [serverVersion]);\n\n const lastNotifiedRef = useRef<DeepAgentServerConfig | null>(null);\n useEffect(() => {\n if (serverConfig === null || serverConfig === lastNotifiedRef.current) return;\n lastNotifiedRef.current = serverConfig;\n onServerConfigRef.current?.({ version: serverConfig.version, custom });\n }, [serverConfig, custom]);\n\n const run = useCallback(\n async (\n command: ConfigCommand,\n apply: PendingOp['apply']\n ): Promise<DeepAgentConfigWriteResult> => {\n const id = nextOpIdRef.current++;\n setOps((current) => [...current, { id, apply, settledVersion: null }]);\n try {\n const raw = (await sendCommandRef.current(command)) as\n | { version?: unknown; custom?: unknown }\n | null\n | undefined;\n const version = typeof raw?.version === 'number' ? raw.version : Number.POSITIVE_INFINITY;\n // The lane echo may have landed before the acknowledgement: retire\n // now if so, otherwise stamp the version for the retire effect.\n setOps((current) =>\n version <= serverVersionRef.current\n ? current.filter((op) => op.id !== id)\n : current.map((op) => (op.id === id ? { ...op, settledVersion: version } : op))\n );\n return {\n version: Number.isFinite(version) ? version : 0,\n custom: isRecord(raw?.custom) ? raw.custom : apply({}),\n };\n } catch (error) {\n setOps((current) => current.filter((op) => op.id !== id));\n throw error;\n }\n },\n []\n );\n\n const patchConfig = useCallback(\n (patch: ThreadConfigPatch) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.patch, patch }, (base) =>\n applyConfigPatch(base, patch)\n ),\n [run]\n );\n const enableTools = useCallback(\n (toolIds: readonly string[]) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.toolsEnable, toolIds: [...toolIds] }, (base) =>\n applyToolsEnable(base, toolIds)\n ),\n [run]\n );\n const disableTools = useCallback(\n (toolIds: readonly string[]) =>\n run({ type: DEEP_AGENT_CONFIG_COMMANDS.toolsDisable, toolIds: [...toolIds] }, (base) =>\n applyToolsDisable(base, toolIds)\n ),\n [run]\n );\n\n return {\n configVersion: serverVersion,\n serverConfig,\n custom,\n hasPendingWrites: ops.some((op) => op.settledVersion === null),\n patchConfig,\n enableTools,\n disableTools,\n };\n}\n"],"names":[],"mappings":";;;;;AAgDA,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAS9D,SAAS,iBAAiB,OAA8C;AAC7E,QAAM,SAAU,+BAAmD;AACnE,MAAI,CAAC,SAAS,MAAM,EAAG,QAAO;AAC9B,QAAM,UAAU,OAAO;AACvB,MAAI,OAAO,YAAY,YAAY,CAAC,OAAO,UAAU,OAAO,KAAK,WAAW,EAAG,QAAO;AACtF,MAAI,CAAC,SAAS,OAAO,MAAM,EAAG,QAAO;AACrC,SAAO;AACT;AAgCA,MAAM,mDAAwD,IAAI;AAAA,EAChE;AAAA,EACA;AACF,CAAC;AAOM,SAAS,gCAAgC,OAAyB;AACvE,QAAM,UAAU,0BAA0B,KAAK;AAC/C,OAAI,mCAAS,YAAW,IAAK,QAAO;AACpC,QAAM,SAAS,QAAQ;AACvB,SAAO,QAAO,iCAAQ,UAAS,YAAY,6BAA6B,IAAI,OAAO,IAAI;AACzF;AAQO,SAAS,iCAAiC,OAAyB;AACxE,QAAM,UAAU,0BAA0B,KAAK;AAC/C,OAAI,mCAAS,YAAW,IAAK,QAAO;AACpC,QAAM,SAAS,QAAQ;AACvB,UAAO,iCAAQ,UAAS;AAC1B;AA0BO,SAAS,qBACd,cACA,KACoB;AACpB,QAAM,WAAU,6CAAc,YAAW;AACzC,MAAI,UAA6B,6CAAc,WAAU,CAAA;AACzD,aAAW,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AAC,OAAO,GAAG,mBAAmB,IAAI;AAAA,IAC7D;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const store = require("@assistant-ui/store");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const editCommand = require("./edit-command.cjs");
|
|
6
|
+
const useHistoricalEditAttachments = require("./use-historical-edit-attachments.cjs");
|
|
6
7
|
function useDeepAgentMessageEditSubmit() {
|
|
8
|
+
useHistoricalEditAttachments.useHistoricalEditAttachments();
|
|
7
9
|
const aui = store.useAui();
|
|
8
10
|
const alive = react.useRef(true);
|
|
9
11
|
const submitting = react.useRef(false);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-edit-submit.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-edit-submit.ts"],"sourcesContent":["import { useAui } from '@assistant-ui/store';\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { readDeepAgentStatewireExtras, resolveDeepAgentEditCommand } from './edit-command';\nimport { useHistoricalEditAttachments } from './use-historical-edit-attachments';\n\n/**\n * The submit handler of a message's edit composer on a deep-agent thread: the\n * edited text leaves as a `run/edit` anchored on the host's own parent of the\n * message (see `edit-command.ts`) — older pages stated first for a message at\n * or below the loaded window's edge — instead of the library's\n * converted-message anchor, which the host rejects `wrong-anchor` after a\n * chunked assistant turn and at the window edge.\n *\n * Read inside the message scope (`aui.message()`): the library's optimistic\n * fold shows the edited bubble and rewinds the visible history the moment the\n * command is dispatched, so the edit composer closes right away. Falls back\n * to the composer's own `send()` when the thread is not a statewire thread or\n * the host has not settled the message yet. Resolves `false` for an empty\n * draft, a duplicate submission, or an edit cancelled during preparation.\n */\nexport function useDeepAgentMessageEditSubmit(): () => Promise<boolean> {\n useHistoricalEditAttachments();\n const aui = useAui();\n const alive = useRef(true);\n const submitting = useRef(false);\n useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n };\n }, []);\n return useCallback(async () => {\n if (submitting.current) return false;\n const composer = aui.message().composer();\n const draft = composer.getState();\n const text = draft.text.trim();\n if (!text && draft.attachments.length === 0) return false;\n const files: StatewireThread.FilePart[] = [];\n const texts = text ? [text] : [];\n // beginEdit lifts original inline images/files into completed composer\n // attachments. The anchored command must carry those too: a text-only\n // reconstruction silently deleted them when editing a cross-device turn.\n for (const attachment of draft.attachments) {\n if (attachment.status.type !== 'complete')\n throw new Error('Wait for attachments to finish before sending your edit.');\n for (const part of attachment.content ?? []) {\n if (part.type === 'text') texts.push(part.text);\n else if (part.type === 'image')\n files.push({ type: 'file', mediaType: 'image/*', url: part.image });\n else if (part.type === 'file')\n files.push({\n type: 'file',\n mediaType: part.mimeType,\n url: part.data,\n ...(part.filename && { filename: part.filename }),\n });\n else throw new Error('This attachment cannot be edited here.');\n }\n }\n submitting.current = true;\n try {\n const sourceId = aui.message().getState().id;\n const readExtras = () =>\n alive.current ? readDeepAgentStatewireExtras(aui.thread().getState().extras) : null;\n const extras = readExtras();\n if (extras) {\n const preparedMetadata = extras.prepareMessageMetadata?.();\n try {\n const command = await resolveDeepAgentEditCommand({\n readExtras,\n sourceId,\n text,\n });\n if (!alive.current || !composer.getState().isEditing) {\n if (preparedMetadata) extras.discardPreparedMessageMetadata?.(preparedMetadata);\n return false;\n }\n if (command) {\n void Promise.resolve(\n extras.sendCommand(\n {\n ...command,\n message: {\n ...command.message,\n parts: [\n ...files,\n ...(texts.length\n ? [{ type: 'text' as const, text: texts.join('\\n\\n') }]\n : []),\n ],\n },\n },\n preparedMetadata === undefined ? undefined : { preparedMetadata },\n ),\n ).catch(() => undefined);\n composer.cancel();\n return true;\n }\n if (preparedMetadata && extras.sendPreparedEdit) {\n extras.sendPreparedEdit(sourceId, preparedMetadata);\n return true;\n }\n } catch (error) {\n if (preparedMetadata) extras.discardPreparedMessageMetadata?.(preparedMetadata);\n throw error;\n }\n }\n composer.send();\n return true;\n } finally {\n submitting.current = false;\n }\n }, [aui]);\n}\n"],"names":["useHistoricalEditAttachments","useAui","useRef","useEffect","useCallback","readDeepAgentStatewireExtras","resolveDeepAgentEditCommand"],"mappings":";;;;;;AAqBO,SAAS,gCAAwD;AACtEA,4DAAA;AACA,QAAM,MAAMC,MAAAA,OAAA;AACZ,QAAM,QAAQC,MAAAA,OAAO,IAAI;AACzB,QAAM,aAAaA,MAAAA,OAAO,KAAK;AAC/BC,QAAAA,UAAU,MAAM;AACd,UAAM,UAAU;AAChB,WAAO,MAAM;AACX,YAAM,UAAU;AAAA,IAClB;AAAA,EACF,GAAG,CAAA,CAAE;AACL,SAAOC,MAAAA,YAAY,YAAY;;AAC7B,QAAI,WAAW,QAAS,QAAO;AAC/B,UAAM,WAAW,IAAI,QAAA,EAAU,SAAA;AAC/B,UAAM,QAAQ,SAAS,SAAA;AACvB,UAAM,OAAO,MAAM,KAAK,KAAA;AACxB,QAAI,CAAC,QAAQ,MAAM,YAAY,WAAW,EAAG,QAAO;AACpD,UAAM,QAAoC,CAAA;AAC1C,UAAM,QAAQ,OAAO,CAAC,IAAI,IAAI,CAAA;AAI9B,eAAW,cAAc,MAAM,aAAa;AAC1C,UAAI,WAAW,OAAO,SAAS;AAC7B,cAAM,IAAI,MAAM,0DAA0D;AAC5E,iBAAW,QAAQ,WAAW,WAAW,CAAA,GAAI;AAC3C,YAAI,KAAK,SAAS,OAAQ,OAAM,KAAK,KAAK,IAAI;AAAA,iBACrC,KAAK,SAAS;AACrB,gBAAM,KAAK,EAAE,MAAM,QAAQ,WAAW,WAAW,KAAK,KAAK,OAAO;AAAA,iBAC3D,KAAK,SAAS;AACrB,gBAAM,KAAK;AAAA,YACT,MAAM;AAAA,YACN,WAAW,KAAK;AAAA,YAChB,KAAK,KAAK;AAAA,YACV,GAAI,KAAK,YAAY,EAAE,UAAU,KAAK,SAAA;AAAA,UAAS,CAChD;AAAA,YACE,OAAM,IAAI,MAAM,wCAAw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|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useAui } from "@assistant-ui/store";
|
|
2
2
|
import { useRef, useEffect, useCallback } from "react";
|
|
3
3
|
import { readDeepAgentStatewireExtras, resolveDeepAgentEditCommand } from "./edit-command.js";
|
|
4
|
+
import { useHistoricalEditAttachments } from "./use-historical-edit-attachments.js";
|
|
4
5
|
function useDeepAgentMessageEditSubmit() {
|
|
6
|
+
useHistoricalEditAttachments();
|
|
5
7
|
const aui = useAui();
|
|
6
8
|
const alive = useRef(true);
|
|
7
9
|
const submitting = useRef(false);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-edit-submit.js","sources":["../../../../agent-runtime/src/use-deep-agent-edit-submit.ts"],"sourcesContent":["import { useAui } from '@assistant-ui/store';\nimport type { StatewireThread } from '@assistant-ui/react-statewire';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { readDeepAgentStatewireExtras, resolveDeepAgentEditCommand } from './edit-command';\nimport { useHistoricalEditAttachments } from './use-historical-edit-attachments';\n\n/**\n * The submit handler of a message's edit composer on a deep-agent thread: the\n * edited text leaves as a `run/edit` anchored on the host's own parent of the\n * message (see `edit-command.ts`) — older pages stated first for a message at\n * or below the loaded window's edge — instead of the library's\n * converted-message anchor, which the host rejects `wrong-anchor` after a\n * chunked assistant turn and at the window edge.\n *\n * Read inside the message scope (`aui.message()`): the library's optimistic\n * fold shows the edited bubble and rewinds the visible history the moment the\n * command is dispatched, so the edit composer closes right away. Falls back\n * to the composer's own `send()` when the thread is not a statewire thread or\n * the host has not settled the message yet. Resolves `false` for an empty\n * draft, a duplicate submission, or an edit cancelled during preparation.\n */\nexport function useDeepAgentMessageEditSubmit(): () => Promise<boolean> {\n useHistoricalEditAttachments();\n const aui = useAui();\n const alive = useRef(true);\n const submitting = useRef(false);\n useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n };\n }, []);\n return useCallback(async () => {\n if (submitting.current) return false;\n const composer = aui.message().composer();\n const draft = composer.getState();\n const text = draft.text.trim();\n if (!text && draft.attachments.length === 0) return false;\n const files: StatewireThread.FilePart[] = [];\n const texts = text ? [text] : [];\n // beginEdit lifts original inline images/files into completed composer\n // attachments. The anchored command must carry those too: a text-only\n // reconstruction silently deleted them when editing a cross-device turn.\n for (const attachment of draft.attachments) {\n if (attachment.status.type !== 'complete')\n throw new Error('Wait for attachments to finish before sending your edit.');\n for (const part of attachment.content ?? []) {\n if (part.type === 'text') texts.push(part.text);\n else if (part.type === 'image')\n files.push({ type: 'file', mediaType: 'image/*', url: part.image });\n else if (part.type === 'file')\n files.push({\n type: 'file',\n mediaType: part.mimeType,\n url: part.data,\n ...(part.filename && { filename: part.filename }),\n });\n else throw new Error('This attachment cannot be edited here.');\n }\n }\n submitting.current = true;\n try {\n const sourceId = aui.message().getState().id;\n const readExtras = () =>\n alive.current ? readDeepAgentStatewireExtras(aui.thread().getState().extras) : null;\n const extras = readExtras();\n if (extras) {\n const preparedMetadata = extras.prepareMessageMetadata?.();\n try {\n const command = await resolveDeepAgentEditCommand({\n readExtras,\n sourceId,\n text,\n });\n if (!alive.current || !composer.getState().isEditing) {\n if (preparedMetadata) extras.discardPreparedMessageMetadata?.(preparedMetadata);\n return false;\n }\n if (command) {\n void Promise.resolve(\n extras.sendCommand(\n {\n ...command,\n message: {\n ...command.message,\n parts: [\n ...files,\n ...(texts.length\n ? [{ type: 'text' as const, text: texts.join('\\n\\n') }]\n : []),\n ],\n },\n },\n preparedMetadata === undefined ? undefined : { preparedMetadata },\n ),\n ).catch(() => undefined);\n composer.cancel();\n return true;\n }\n if (preparedMetadata && extras.sendPreparedEdit) {\n extras.sendPreparedEdit(sourceId, preparedMetadata);\n return true;\n }\n } catch (error) {\n if (preparedMetadata) extras.discardPreparedMessageMetadata?.(preparedMetadata);\n throw error;\n }\n }\n composer.send();\n return true;\n } finally {\n submitting.current = false;\n }\n }, [aui]);\n}\n"],"names":[],"mappings":";;;;AAqBO,SAAS,gCAAwD;AACtE,+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,oBAAmB,YAAO,2BAAP;AACzB,YAAI;AACF,gBAAM,UAAU,MAAM,4BAA4B;AAAA,YAChD;AAAA,YACA;AAAA,YACA;AAAA,UAAA,CACD;AACD,cAAI,CAAC,MAAM,WAAW,CAAC,SAAS,SAAA,EAAW,WAAW;AACpD,gBAAI,iBAAkB,cAAO,mCAAP,gCAAwC;AAC9D,mBAAO;AAAA,UACT;AACA,cAAI,SAAS;AACX,iBAAK,QAAQ;AAAA,cACX,OAAO;AAAA,gBACL;AAAA,kBACE,GAAG;AAAA,kBACH,SAAS;AAAA,oBACP,GAAG,QAAQ;AAAA,oBACX,OAAO;AAAA,sBACL,GAAG;AAAA,sBACH,GAAI,MAAM,SACN,CAAC,EAAE,MAAM,QAAiB,MAAM,MAAM,KAAK,MAAM,EAAA,CAAG,IACpD,CAAA;AAAA,oBAAC;AAAA,kBACP;AAAA,gBACF;AAAA,gBAEF,qBAAqB,SAAY,SAAY,EAAE,iBAAA;AAAA,cAAiB;AAAA,YAClE,EACA,MAAM,MAAM,MAAS;AACvB,qBAAS,OAAA;AACT,mBAAO;AAAA,UACT;AACA,cAAI,oBAAoB,OAAO,kBAAkB;AAC/C,mBAAO,iBAAiB,UAAU,gBAAgB;AAClD,mBAAO;AAAA,UACT;AAAA,QACF,SAAS,OAAO;AACd,cAAI,iBAAkB,cAAO,mCAAP,gCAAwC;AAC9D,gBAAM;AAAA,QACR;AAAA,MACF;AACA,eAAS,KAAA;AACT,aAAO;AAAA,IACT,UAAA;AACE,iBAAW,UAAU;AAAA,IACvB;AAAA,EACF,GAAG,CAAC,GAAG,CAAC;AACV;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-runtime.cjs","sources":["../../../../agent-runtime/src/use-deep-agent-runtime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { isStatewireChannelTeardown } from './errors';\nimport { type DeepAgentModelContextHost, registerDeepAgentRunConfig } from './model-context';\nimport {\n isStorageQuotaError,\n QuotaSafeLocalStorageSession,\n readFailedSendStampsFromRecord,\n readPersistedFailedSendStamps,\n type SessionStorageDegradation,\n} from './quota-safe-local-storage-session';\nimport { createDeepAgentSendRecovery } from './send-recovery';\nimport type { StatewireTransportOptions } from './statewire-transport';\nimport { readStatewireFailedSendLane } from './thread-extras';\nimport { isConfigSyncUnavailableRejection } from './use-deep-agent-config';\nimport { useDeepAgentThread, type UseDeepAgentThreadOptions } from './use-deep-agent-thread';\n\n/** The thread element `useDeepAgentThread` produces — what the host's `useAui`\n * consumes (`useAui({ thread })`). */\nexport type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;\n\n/**\n * Durable command-lane persistence for the thread — where the lane identity and\n * the commands still awaiting a durable verdict live, so a reload resumes the\n * lane instead of minting a new client.\n *\n * - `local-storage`: browser hosts. Backed by {@link QuotaSafeLocalStorageSession}\n * (the upstream `LocalStorageSession` contract with Athena keys, legacy\n * metadata, and retention). A storage failure after mounting — the origin\n * out of quota after statewire's own sweep, a lockdown-mode write refusal —\n * degrades the session to memory-only persistence and is reported through\n * `onStorageDegraded` (default: one console warning); it never stops the\n * connection. Guarded by a shared availability probe: SSR, storage-blocked\n * iframes, and locked-down browsers keep the session process-local, exactly\n * as before the seam existed, while an origin that is merely full mounts the\n * session and lets it degrade. `key` scopes the stored lane — a thread id is\n * only meaningful against the backend (and, where relevant, principal) that\n * minted it, so include the sync-host URL.\n * - `session-store`: React Native hosts pass a hydrated library store backed\n * by AsyncStorage. Its synchronous `load()` is\n * also the send-recovery freshness gate's view of the persisted failed lane,\n * so a store that persists `failed` gets the same 24 h staleness rule as the\n * browser hosts.\n * - `false`: process-local session (a reload mints a new client).\n */\nexport type DeepAgentSessionPersistence =\n | {\n kind: 'local-storage';\n key: (threadId: string) => string;\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n }\n | { kind: 'session-store'; store: NonNullable<StatewireTransportOptions['sessionStore']> }\n | false;\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageGlobals = {\n localStorage?: {\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n };\n navigator?: { locks?: unknown };\n};\n\n/**\n * Whether a localStorage-backed session can persist here. A write probe, not a\n * `typeof` check: storage-blocked iframes (SDK embeds under third-party-storage\n * blocking) throw from the `localStorage` accessor itself, and lockdown-mode\n * origins throw from `setItem` — each of those must mean \"stay process-local\",\n * never a crash at mount. An origin that is merely out of quota still reads\n * and takes locks, so it mounts the session: {@link QuotaSafeLocalStorageSession}\n * degrades that to memory-only persistence and recovers when room frees,\n * where staying process-local would give up cross-tab sharing for the whole\n * page load over a condition that clears.\n *\n * The Web Locks API is probed too: the session storage serializes the shared\n * record across tabs through `navigator.locks` and refuses to mount without it\n * (the same precondition as the vendor `LocalStorageSession`), so an origin\n * with localStorage but no Web Locks — older WebViews, Safari before 15.4 —\n * must also stay process-local instead of throwing at mount.\n */\nexport function canPersistDeepAgentSession(): boolean {\n try {\n const globals = globalThis as StorageGlobals;\n if (!globals.navigator?.locks) return false;\n const storage = globals.localStorage;\n if (!storage) return false;\n const probeKey = '__athena_statewire_session_probe__';\n try {\n storage.setItem(probeKey, probeKey);\n storage.removeItem(probeKey);\n } catch (error) {\n return isStorageQuotaError(error);\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/** A host session store's current record, or `null` when the read throws —\n * the recovery gate must never take the runtime down over a storage fault. */\nfunction loadSessionRecord(\n store: NonNullable<StatewireTransportOptions['sessionStore']>\n): ReturnType<NonNullable<StatewireTransportOptions['sessionStore']>['load']> | null {\n try {\n return store.load();\n } catch {\n return null;\n }\n}\n\n/**\n * The shared tail of every surface's transport error policy: channel teardown\n * is lifecycle noise (logged at debug), as is `config_sync_unavailable` — only\n * `config/*` writes emit it, and the host's config sync already handles it\n * through its own command promise (regionally-pinned workspaces run on\n * local-only config); everything else is a real transport error. Hosts with their own error chain\n * (paywall, telemetry, send-failure stores) end it with this so the fallback\n * logging stays uniform per surface.\n */\nexport function logUnhandledStatewireError(surface: string, error: Error): void {\n if (isStatewireChannelTeardown(error)) {\n console.debug(`[${surface}] statewire channel teardown:`, error);\n return;\n }\n if (isConfigSyncUnavailableRejection(error)) {\n console.debug(`[${surface}] config sync unavailable (handled by config sync):`, error);\n return;\n }\n console.error(`[${surface}] statewire transport error:`, error);\n}\n\n/**\n * The imperative thread-state slice of an assistant-ui client — structural so\n * web and native `useAui` results both satisfy it. The send-recovery layer\n * reads the statewire thread extras through it (the sanctioned imperative\n * pattern: `aui.thread().getState()` inside callbacks/effects, never render).\n */\nexport interface DeepAgentThreadStateClientHost {\n thread: () => { getState: () => { extras?: unknown } };\n subscribe: (listener: () => void) => () => void;\n}\n\n/** Deep-agent runConfig registration on the ambient model context (see\n * {@link registerDeepAgentRunConfig}). */\nexport interface DeepAgentRunConfigRegistration {\n /**\n * Builds the `runConfig` that drives the run. The core pulls it when the\n * model context notifies (mount and each key change); the server reads that\n * synced value at command admission. The per-render ref makes each pull use\n * the latest closure but does not trigger a pull itself.\n */\n get: () => Record<string, unknown>;\n /**\n * Re-registers the provider and notifies model-context sync when this value\n * changes (reference equality). Include getter inputs that can change while\n * mounted; they reach the server only after a key change triggers a pull.\n */\n key?: unknown;\n}\n\nexport interface UseDeepAgentRuntimeOptions<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n> extends Omit<UseDeepAgentThreadOptions, 'storage' | 'sessionStore'> {\n /** Host surface tag for the shared fallback error logging (e.g.\n * `'AthenaDeepAgent'`, `'AthenaSDK'`, `'ChromeStatewire'`). */\n surface: string;\n /** Durable command-lane persistence; defaults to process-local. */\n session?: DeepAgentSessionPersistence;\n /**\n * Builds the host's assistant-ui client from the thread element — pass the\n * platform `useAui` (web hosts from `@assistant-ui/react`, React Native\n * hosts from `@assistant-ui/react-native`; this package imports neither).\n * Called unconditionally on every render, so it MUST be (or call) a hook\n * following the rules of hooks — define it at module scope with a `use*`\n * name: `const useHostClient = (thread: DeepAgentThreadElement) =>\n * useAui({ thread })`.\n */\n useClient: (thread: DeepAgentThreadElement) => TClient;\n /** Registers the deep-agent runConfig on the client's model context. Hosts\n * that register elsewhere (e.g. a bridge component mounted under the\n * provider) omit it. */\n runConfig?: DeepAgentRunConfigRegistration;\n}\n\n/**\n * The configurable deep-agent statewire runtime — the one hook every Athena\n * chat surface (Olympus, `@athenaintel/react` SDK, Chrome extension, Office\n * add-in, mobile) mounts its assistant-ui client through.\n *\n * Composes the pieces every surface previously wired by hand:\n * `useDeepAgentThread` (attach lifecycle, auth parking, lane projection,\n * connection/running observers), durable session persistence with the shared\n * availability guard, transport-level send recovery (failed sends the server\n * never judged auto-retry under their original message id — `send-recovery.ts`),\n * the platform client via `useClient`, and the\n * runConfig model-context registration on provider notifications. Everything\n * host-specific — auth headers, run-config building, error policy, adapters,\n * diagnostics recorders — stays an option, so per-surface behavior is\n * configuration, not a fork.\n */\nexport function useDeepAgentRuntime<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n>(options: UseDeepAgentRuntimeOptions<TClient>): TClient {\n const {\n surface,\n session = false,\n useClient,\n runConfig,\n onError,\n onStateChange,\n onCommandChange,\n ...threadOptions\n } = options;\n\n // Probed once per mount, like every browser host did individually: an origin\n // that cannot persist stays process-local for the mount's lifetime.\n const [canPersistLocalSession] = useState(canPersistDeepAgentSession);\n\n // Per-render refs so the transport never remounts on a new closure identity\n // and always reads the latest policy.\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const surfaceRef = useRef(surface);\n surfaceRef.current = surface;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const diagnosticsRef = useRef(threadOptions.diagnostics);\n diagnosticsRef.current = threadOptions.diagnostics;\n const clientRef = useRef<TClient | null>(null);\n\n // Where the persisted session record lives, for the recovery freshness gate\n // (read per sweep — undefined means \"no persistence, everything is fresh\").\n const failureStampsRef = useRef<(() => ReadonlyMap<string, number> | null) | undefined>(\n undefined\n );\n failureStampsRef.current =\n session === false\n ? undefined\n : session.kind === 'local-storage'\n ? canPersistLocalSession\n ? () => readPersistedFailedSendStamps(session.key(threadOptions.threadId))\n : undefined\n : () => readFailedSendStampsFromRecord(loadSessionRecord(session.store));\n\n // Send recovery, keyed by attach identity exactly like the thread's session\n // (a switch or re-attach gets fresh hydration gating and retry budgets). The\n // controller re-dispatches failed sends the server never judged; see\n // `send-recovery.ts` for the contract.\n const attachId =\n threadOptions.attachKey === undefined\n ? threadOptions.threadId\n : `${threadOptions.threadId}:${threadOptions.attachKey}`;\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by attach identity on purpose; every other input is read through a per-render ref.\n const sendRecovery = useMemo(\n () =>\n createDeepAgentSendRecovery({\n lane: () => {\n const client = clientRef.current;\n if (!client) return null;\n return readStatewireFailedSendLane(client.thread().getState().extras);\n },\n failureStamps: () => failureStampsRef.current?.() ?? null,\n diagnostics: () => diagnosticsRef.current,\n }),\n [attachId]\n );\n useEffect(() => () => sendRecovery.dispose(), [sendRecovery]);\n const sendRecoveryRef = useRef(sendRecovery);\n sendRecoveryRef.current = sendRecovery;\n\n const thread = useDeepAgentThread({\n ...threadOptions,\n ...(session !== false &&\n session.kind === 'local-storage' &&\n canPersistLocalSession && {\n storage: {\n session: QuotaSafeLocalStorageSession({\n threadId: threadOptions.threadId,\n key: session.key,\n ...(session.onStorageDegraded === undefined\n ? {}\n : { onStorageDegraded: session.onStorageDegraded }),\n }),\n },\n }),\n ...(session !== false && session.kind === 'session-store' && { sessionStore: session.store }),\n onStateChange: (state, ctx) => {\n sendRecoveryRef.current.observeStateChange(state);\n onStateChangeRef.current?.(state, ctx);\n },\n onCommandChange: (update, ctx) => {\n sendRecoveryRef.current.observeCommand(update);\n onCommandChangeRef.current?.(update, ctx);\n },\n onError: (error) => {\n const handler = onErrorRef.current;\n if (handler) {\n handler(error);\n return;\n }\n logUnhandledStatewireError(surfaceRef.current, error);\n },\n });\n\n const client = useClient(thread);\n clientRef.current = client;\n\n // A locked shared journal can publish failed history after onCommandChange,\n // with no canonical state change to wake recovery. Observe the client that\n // owns the visible failed lane; the controller guards in-flight retries.\n useEffect(() => {\n const unsubscribe = client.subscribe(() => sendRecovery.observeFailedLaneChange());\n sendRecovery.observeFailedLaneChange();\n return unsubscribe;\n }, [client, sendRecovery]);\n\n // Commands travel bare, so the runConfig that drives the run rides the\n // ambient model context: `contextSync: 'command-send'` mirrors it to the\n // server, which reads `config.runConfig` at command admission. The core pulls\n // on model-context notifications; the per-render ref ensures each pull uses\n // the latest closure but does not trigger a pull itself.\n const getRunConfigRef = useRef(runConfig?.get);\n getRunConfigRef.current = runConfig?.get;\n const hasRunConfig = runConfig !== undefined;\n const runConfigKey = runConfig?.key;\n useEffect(() => {\n if (!hasRunConfig) return undefined;\n return registerDeepAgentRunConfig(client, () => getRunConfigRef.current?.() ?? {});\n }, [client, hasRunConfig, runConfigKey]);\n\n return client;\n}\n\n"],"names":["isStorageQuotaError","isStatewireChannelTeardown","isConfigSyncUnavailableRejection","useState","useRef","readPersistedFailedSendStamps","readFailedSendStampsFromRecord","sendRecovery","useMemo","createDeepAgentSendRecovery","client","readStatewireFailedSendLane","useEffect","useDeepAgentThread","QuotaSafeLocalStorageSession","registerDeepAgentRunConfig"],"mappings":";;;;;;;;;;AAgFO,SAAS,6BAAsC;;AACpD,MAAI;AACF,UAAM,UAAU;AAChB,QAAI,GAAC,aAAQ,cAAR,mBAAmB,OAAO,QAAO;AACtC,UAAM,UAAU,QAAQ;AACxB,QAAI,CAAC,QAAS,QAAO;AACrB,UAAM,WAAW;AACjB,QAAI;AACF,cAAQ,QAAQ,UAAU,QAAQ;AAClC,cAAQ,WAAW,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,aAAOA,6BAAAA,oBAAoB,KAAK;AAAA,IAClC;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,kBACP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,WAAW;AAC3B,UAAI,SAAS;AACX,gBAAQ,KAAK;AACb;AAAA,MACF;AACA,iCAA2B,WAAW,SAAS,KAAK;AAAA,IACtD;AAAA,EAAA,CACD;AAED,QAAM,SAAS,UAAU,MAAM;AAC/B,YAAU,UAAU;AAKpBF,QAAAA,UAAU,MAAM;AACd,UAAM,cAAc,OAAO,UAAU,MAAML,eAAa,yBAAyB;AACjFA,mBAAa,wBAAA;AACb,WAAO;AAAA,EACT,GAAG,CAAC,QAAQA,cAAY,CAAC;AAOzB,QAAM,kBAAkBH,MAAAA,OAAO,uCAAW,GAAG;AAC7C,kBAAgB,UAAU,uCAAW;AACrC,QAAM,eAAe,cAAc;AACnC,QAAM,eAAe,uCAAW;AAChCQ,QAAAA,UAAU,MAAM;AACd,QAAI,CAAC,aAAc,QAAO;AAC1B,WAAOG,aAAAA,2BAA2B,QAAQ,MAAA;;AAAM,oCAAgB,YAAhB,6CAA+B,CAAA;AAAA,KAAE;AAAA,EACnF,GAAG,CAAC,QAAQ,cAAc,YAAY,CAAC;AAEvC,SAAO;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-deep-agent-runtime.js","sources":["../../../../agent-runtime/src/use-deep-agent-runtime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { isStatewireChannelTeardown } from './errors';\nimport { type DeepAgentModelContextHost, registerDeepAgentRunConfig } from './model-context';\nimport {\n isStorageQuotaError,\n QuotaSafeLocalStorageSession,\n readFailedSendStampsFromRecord,\n readPersistedFailedSendStamps,\n type SessionStorageDegradation,\n} from './quota-safe-local-storage-session';\nimport { createDeepAgentSendRecovery } from './send-recovery';\nimport type { StatewireTransportOptions } from './statewire-transport';\nimport { readStatewireFailedSendLane } from './thread-extras';\nimport { isConfigSyncUnavailableRejection } from './use-deep-agent-config';\nimport { useDeepAgentThread, type UseDeepAgentThreadOptions } from './use-deep-agent-thread';\n\n/** The thread element `useDeepAgentThread` produces — what the host's `useAui`\n * consumes (`useAui({ thread })`). */\nexport type DeepAgentThreadElement = ReturnType<typeof useDeepAgentThread>;\n\n/**\n * Durable command-lane persistence for the thread — where the lane identity and\n * the commands still awaiting a durable verdict live, so a reload resumes the\n * lane instead of minting a new client.\n *\n * - `local-storage`: browser hosts. Backed by {@link QuotaSafeLocalStorageSession}\n * (the upstream `LocalStorageSession` contract with Athena keys, legacy\n * metadata, and retention). A storage failure after mounting — the origin\n * out of quota after statewire's own sweep, a lockdown-mode write refusal —\n * degrades the session to memory-only persistence and is reported through\n * `onStorageDegraded` (default: one console warning); it never stops the\n * connection. Guarded by a shared availability probe: SSR, storage-blocked\n * iframes, and locked-down browsers keep the session process-local, exactly\n * as before the seam existed, while an origin that is merely full mounts the\n * session and lets it degrade. `key` scopes the stored lane — a thread id is\n * only meaningful against the backend (and, where relevant, principal) that\n * minted it, so include the sync-host URL.\n * - `session-store`: React Native hosts pass a hydrated library store backed\n * by AsyncStorage. Its synchronous `load()` is\n * also the send-recovery freshness gate's view of the persisted failed lane,\n * so a store that persists `failed` gets the same 24 h staleness rule as the\n * browser hosts.\n * - `false`: process-local session (a reload mints a new client).\n */\nexport type DeepAgentSessionPersistence =\n | {\n kind: 'local-storage';\n key: (threadId: string) => string;\n onStorageDegraded?: (degradation: SessionStorageDegradation) => void;\n }\n | { kind: 'session-store'; store: NonNullable<StatewireTransportOptions['sessionStore']> }\n | false;\n\n/** Structural view of the browser storage global — this package compiles\n * without the DOM lib (React Native honesty; see `globals.d.ts`). */\ntype StorageGlobals = {\n localStorage?: {\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n };\n navigator?: { locks?: unknown };\n};\n\n/**\n * Whether a localStorage-backed session can persist here. A write probe, not a\n * `typeof` check: storage-blocked iframes (SDK embeds under third-party-storage\n * blocking) throw from the `localStorage` accessor itself, and lockdown-mode\n * origins throw from `setItem` — each of those must mean \"stay process-local\",\n * never a crash at mount. An origin that is merely out of quota still reads\n * and takes locks, so it mounts the session: {@link QuotaSafeLocalStorageSession}\n * degrades that to memory-only persistence and recovers when room frees,\n * where staying process-local would give up cross-tab sharing for the whole\n * page load over a condition that clears.\n *\n * The Web Locks API is probed too: the session storage serializes the shared\n * record across tabs through `navigator.locks` and refuses to mount without it\n * (the same precondition as the vendor `LocalStorageSession`), so an origin\n * with localStorage but no Web Locks — older WebViews, Safari before 15.4 —\n * must also stay process-local instead of throwing at mount.\n */\nexport function canPersistDeepAgentSession(): boolean {\n try {\n const globals = globalThis as StorageGlobals;\n if (!globals.navigator?.locks) return false;\n const storage = globals.localStorage;\n if (!storage) return false;\n const probeKey = '__athena_statewire_session_probe__';\n try {\n storage.setItem(probeKey, probeKey);\n storage.removeItem(probeKey);\n } catch (error) {\n return isStorageQuotaError(error);\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/** A host session store's current record, or `null` when the read throws —\n * the recovery gate must never take the runtime down over a storage fault. */\nfunction loadSessionRecord(\n store: NonNullable<StatewireTransportOptions['sessionStore']>\n): ReturnType<NonNullable<StatewireTransportOptions['sessionStore']>['load']> | null {\n try {\n return store.load();\n } catch {\n return null;\n }\n}\n\n/**\n * The shared tail of every surface's transport error policy: channel teardown\n * is lifecycle noise (logged at debug), as is `config_sync_unavailable` — only\n * `config/*` writes emit it, and the host's config sync already handles it\n * through its own command promise (regionally-pinned workspaces run on\n * local-only config); everything else is a real transport error. Hosts with their own error chain\n * (paywall, telemetry, send-failure stores) end it with this so the fallback\n * logging stays uniform per surface.\n */\nexport function logUnhandledStatewireError(surface: string, error: Error): void {\n if (isStatewireChannelTeardown(error)) {\n console.debug(`[${surface}] statewire channel teardown:`, error);\n return;\n }\n if (isConfigSyncUnavailableRejection(error)) {\n console.debug(`[${surface}] config sync unavailable (handled by config sync):`, error);\n return;\n }\n console.error(`[${surface}] statewire transport error:`, error);\n}\n\n/**\n * The imperative thread-state slice of an assistant-ui client — structural so\n * web and native `useAui` results both satisfy it. The send-recovery layer\n * reads the statewire thread extras through it (the sanctioned imperative\n * pattern: `aui.thread().getState()` inside callbacks/effects, never render).\n */\nexport interface DeepAgentThreadStateClientHost {\n thread: () => { getState: () => { extras?: unknown } };\n subscribe: (listener: () => void) => () => void;\n}\n\n/** Deep-agent runConfig registration on the ambient model context (see\n * {@link registerDeepAgentRunConfig}). */\nexport interface DeepAgentRunConfigRegistration {\n /**\n * Builds the `runConfig` that drives the run. The core pulls it when the\n * model context notifies (mount and each key change); the server reads that\n * synced value at command admission. The per-render ref makes each pull use\n * the latest closure but does not trigger a pull itself.\n */\n get: () => Record<string, unknown>;\n /**\n * Re-registers the provider and notifies model-context sync when this value\n * changes (reference equality). Include getter inputs that can change while\n * mounted; they reach the server only after a key change triggers a pull.\n */\n key?: unknown;\n}\n\nexport interface UseDeepAgentRuntimeOptions<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n> extends Omit<UseDeepAgentThreadOptions, 'storage' | 'sessionStore'> {\n /** Host surface tag for the shared fallback error logging (e.g.\n * `'AthenaDeepAgent'`, `'AthenaSDK'`, `'ChromeStatewire'`). */\n surface: string;\n /** Durable command-lane persistence; defaults to process-local. */\n session?: DeepAgentSessionPersistence;\n /**\n * Builds the host's assistant-ui client from the thread element — pass the\n * platform `useAui` (web hosts from `@assistant-ui/react`, React Native\n * hosts from `@assistant-ui/react-native`; this package imports neither).\n * Called unconditionally on every render, so it MUST be (or call) a hook\n * following the rules of hooks — define it at module scope with a `use*`\n * name: `const useHostClient = (thread: DeepAgentThreadElement) =>\n * useAui({ thread })`.\n */\n useClient: (thread: DeepAgentThreadElement) => TClient;\n /** Registers the deep-agent runConfig on the client's model context. Hosts\n * that register elsewhere (e.g. a bridge component mounted under the\n * provider) omit it. */\n runConfig?: DeepAgentRunConfigRegistration;\n}\n\n/**\n * The configurable deep-agent statewire runtime — the one hook every Athena\n * chat surface (Olympus, `@athenaintel/react` SDK, Chrome extension, Office\n * add-in, mobile) mounts its assistant-ui client through.\n *\n * Composes the pieces every surface previously wired by hand:\n * `useDeepAgentThread` (attach lifecycle, auth parking, lane projection,\n * connection/running observers), durable session persistence with the shared\n * availability guard, transport-level send recovery (failed sends the server\n * never judged auto-retry under their original message id — `send-recovery.ts`),\n * the platform client via `useClient`, and the\n * runConfig model-context registration on provider notifications. Everything\n * host-specific — auth headers, run-config building, error policy, adapters,\n * diagnostics recorders — stays an option, so per-surface behavior is\n * configuration, not a fork.\n */\nexport function useDeepAgentRuntime<\n TClient extends DeepAgentModelContextHost & DeepAgentThreadStateClientHost,\n>(options: UseDeepAgentRuntimeOptions<TClient>): TClient {\n const {\n surface,\n session = false,\n useClient,\n runConfig,\n onError,\n onStateChange,\n onCommandChange,\n ...threadOptions\n } = options;\n\n // Probed once per mount, like every browser host did individually: an origin\n // that cannot persist stays process-local for the mount's lifetime.\n const [canPersistLocalSession] = useState(canPersistDeepAgentSession);\n\n // Per-render refs so the transport never remounts on a new closure identity\n // and always reads the latest policy.\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const surfaceRef = useRef(surface);\n surfaceRef.current = surface;\n const onStateChangeRef = useRef(onStateChange);\n onStateChangeRef.current = onStateChange;\n const onCommandChangeRef = useRef(onCommandChange);\n onCommandChangeRef.current = onCommandChange;\n const diagnosticsRef = useRef(threadOptions.diagnostics);\n diagnosticsRef.current = threadOptions.diagnostics;\n const clientRef = useRef<TClient | null>(null);\n\n // Where the persisted session record lives, for the recovery freshness gate\n // (read per sweep — undefined means \"no persistence, everything is fresh\").\n const failureStampsRef = useRef<(() => ReadonlyMap<string, number> | null) | undefined>(\n undefined\n );\n failureStampsRef.current =\n session === false\n ? undefined\n : session.kind === 'local-storage'\n ? canPersistLocalSession\n ? () => readPersistedFailedSendStamps(session.key(threadOptions.threadId))\n : undefined\n : () => readFailedSendStampsFromRecord(loadSessionRecord(session.store));\n\n // Send recovery, keyed by attach identity exactly like the thread's session\n // (a switch or re-attach gets fresh hydration gating and retry budgets). The\n // controller re-dispatches failed sends the server never judged; see\n // `send-recovery.ts` for the contract.\n const attachId =\n threadOptions.attachKey === undefined\n ? threadOptions.threadId\n : `${threadOptions.threadId}:${threadOptions.attachKey}`;\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by attach identity on purpose; every other input is read through a per-render ref.\n const sendRecovery = useMemo(\n () =>\n createDeepAgentSendRecovery({\n lane: () => {\n const client = clientRef.current;\n if (!client) return null;\n return readStatewireFailedSendLane(client.thread().getState().extras);\n },\n failureStamps: () => failureStampsRef.current?.() ?? null,\n diagnostics: () => diagnosticsRef.current,\n }),\n [attachId]\n );\n useEffect(() => () => sendRecovery.dispose(), [sendRecovery]);\n const sendRecoveryRef = useRef(sendRecovery);\n sendRecoveryRef.current = sendRecovery;\n\n const thread = useDeepAgentThread({\n ...threadOptions,\n ...(session !== false &&\n session.kind === 'local-storage' &&\n canPersistLocalSession && {\n storage: {\n session: QuotaSafeLocalStorageSession({\n threadId: threadOptions.threadId,\n key: session.key,\n ...(session.onStorageDegraded === undefined\n ? {}\n : { onStorageDegraded: session.onStorageDegraded }),\n }),\n },\n }),\n ...(session !== false && session.kind === 'session-store' && { sessionStore: session.store }),\n onStateChange: (state, ctx) => {\n sendRecoveryRef.current.observeStateChange(state);\n onStateChangeRef.current?.(state, ctx);\n },\n onCommandChange: (update, ctx) => {\n sendRecoveryRef.current.observeCommand(update);\n onCommandChangeRef.current?.(update, ctx);\n },\n onError: (error) => {\n const handler = onErrorRef.current;\n if (handler) {\n handler(error);\n return;\n }\n logUnhandledStatewireError(surfaceRef.current, error);\n },\n });\n\n const client = useClient(thread);\n clientRef.current = client;\n\n // A locked shared journal can publish failed history after onCommandChange,\n // with no canonical state change to wake recovery. Observe the client that\n // owns the visible failed lane; the controller guards in-flight retries.\n useEffect(() => {\n const unsubscribe = client.subscribe(() => sendRecovery.observeFailedLaneChange());\n sendRecovery.observeFailedLaneChange();\n return unsubscribe;\n }, [client, sendRecovery]);\n\n // Commands travel bare, so the runConfig that drives the run rides the\n // ambient model context: `contextSync: 'command-send'` mirrors it to the\n // server, which reads `config.runConfig` at command admission. The core pulls\n // on model-context notifications; the per-render ref ensures each pull uses\n // the latest closure but does not trigger a pull itself.\n const getRunConfigRef = useRef(runConfig?.get);\n getRunConfigRef.current = runConfig?.get;\n const hasRunConfig = runConfig !== undefined;\n const runConfigKey = runConfig?.key;\n useEffect(() => {\n if (!hasRunConfig) return undefined;\n return registerDeepAgentRunConfig(client, () => getRunConfigRef.current?.() ?? {});\n }, [client, hasRunConfig, runConfigKey]);\n\n return client;\n}\n\n"],"names":["client"],"mappings":";;;;;;;;AAgFO,SAAS,6BAAsC;;AACpD,MAAI;AACF,UAAM,UAAU;AAChB,QAAI,GAAC,aAAQ,cAAR,mBAAmB,OAAO,QAAO;AACtC,UAAM,UAAU,QAAQ;AACxB,QAAI,CAAC,QAAS,QAAO;AACrB,UAAM,WAAW;AACjB,QAAI;AACF,cAAQ,QAAQ,UAAU,QAAQ;AAClC,cAAQ,WAAW,QAAQ;AAAA,IAC7B,SAAS,OAAO;AACd,aAAO,oBAAoB,KAAK;AAAA,IAClC;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,kBACP,OACmF;AACnF,MAAI;AACF,WAAO,MAAM,KAAA;AAAA,EACf,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAWO,SAAS,2BAA2B,SAAiB,OAAoB;AAC9E,MAAI,2BAA2B,KAAK,GAAG;AACrC,YAAQ,MAAM,IAAI,OAAO,iCAAiC,KAAK;AAC/D;AAAA,EACF;AACA,MAAI,iCAAiC,KAAK,GAAG;AAC3C,YAAQ,MAAM,IAAI,OAAO,uDAAuD,KAAK;AACrF;AAAA,EACF;AACA,UAAQ,MAAM,IAAI,OAAO,gCAAgC,KAAK;AAChE;AAuEO,SAAS,oBAEd,SAAuD;AACvD,QAAM;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAIJ,QA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window == null ? void 0 : window.messages) ?? values.messages ?? held ?? [];
|
|
252
252
|
if (window !== null || messages2.length > 0) lastMessagesRef.current = { attachId, messages: messages2 };
|
|
253
253
|
const state = { ...values, messages: [...messages2] };
|
|
254
|
+
statewireState.pairDeepAgentStateWithThread({ state, threadId });
|
|
254
255
|
materialize(state);
|
|
255
256
|
const joined = state.messages ?? [];
|
|
256
257
|
const previousJoined = lastStateMessagesRef.current;
|