@assistant-ui/core 0.3.19 → 0.3.21
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/dist/adapters/attachment.d.ts +50 -43
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +52 -21
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +2 -5
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +7 -8
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +14 -9
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/speech.d.ts +63 -65
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +16 -2
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/suggestion.d.ts +19 -22
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +60 -58
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +8 -11
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +50 -45
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +17 -3
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +70 -56
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.d.ts +1 -4
- package/dist/internal/duplicate-detection.d.ts.map +1 -1
- package/dist/internal.d.ts +27 -58
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +8 -6
- package/dist/model-context/frame/host.d.ts +20 -23
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +3 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +28 -30
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +6 -0
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.d.ts +24 -27
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/frame/validate.d.ts +3 -0
- package/dist/model-context/frame/validate.d.ts.map +1 -0
- package/dist/model-context/frame/validate.js +26 -0
- package/dist/model-context/frame/validate.js.map +1 -0
- package/dist/model-context/interactable-composer-metadata.d.ts +51 -39
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +30 -6
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry-handles.d.ts +9 -12
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +15 -18
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +15 -17
- package/dist/model-context/tool-call-text.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +12 -14
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +40 -43
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +9 -12
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +23 -26
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +4 -8
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +28 -23
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +77 -58
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +4 -7
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +6 -9
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +2 -5
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts +9 -12
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +3 -6
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +306 -101
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +34 -37
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +2 -1
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/Tools.d.ts +10 -12
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +4 -8
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts +9 -11
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +32 -22
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/index.d.ts +160 -122
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +5 -5
- package/dist/react/interactables-legacy/Interactables.d.ts +2 -5
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +15 -8
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts +6 -9
- package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.js +13 -14
- package/dist/react/interactables-legacy/interactable-model-context.js.map +1 -1
- package/dist/react/interactables-legacy/scopes.d.ts +42 -46
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +8 -11
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useInteractableState.d.ts +7 -9
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -14
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +54 -25
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.d.ts +15 -18
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +13 -6
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts +1 -4
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts +3 -6
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +26 -29
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +6 -9
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +6 -9
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +6 -9
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +5 -7
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts +1 -4
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +44 -32
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +3 -6
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +7 -10
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +3 -6
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +9 -13
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +13 -16
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +3 -5
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +3 -6
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +40 -40
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableState.d.ts +10 -9
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +4 -7
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +7 -9
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +7 -10
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +6 -9
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +3 -6
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +3 -6
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +4 -7
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts +3 -6
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +3 -6
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +4 -7
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +2 -5
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts +3 -6
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts +5 -8
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts +1 -4
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts +3 -6
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +7 -10
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +4 -4
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +3 -6
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +8 -11
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -29
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +26 -28
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +13 -13
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +13 -17
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +30 -33
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +42 -33
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +30 -28
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +14 -15
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +122 -120
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +208 -194
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +124 -82
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +8 -11
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +4 -7
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +16 -19
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +61 -64
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +25 -27
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +24 -5
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +26 -28
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +6 -9
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +5 -8
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +4 -7
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +3 -6
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +3 -6
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +3 -6
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +3 -6
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +4 -7
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +7 -10
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +4 -7
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +4 -7
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +5 -1
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +4 -7
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +4 -8
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +210 -219
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +70 -46
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +186 -198
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +13 -4
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +17 -23
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +3 -1
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +10 -11
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +11 -14
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +6 -8
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js +9 -2
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts +9 -12
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.js +4 -1
- package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/types.d.ts +123 -118
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +7 -10
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +17 -6
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +3 -6
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +2 -5
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +7 -10
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +426 -216
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +15 -18
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +8 -4
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +146 -125
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +120 -8
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +13 -15
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +5 -7
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +2 -5
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.js +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +3 -6
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +9 -11
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +15 -19
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +14 -17
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +17 -21
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-store-history-copy.d.ts +25 -0
- package/dist/react/runtimes/external-store-history-copy.d.ts.map +1 -0
- package/dist/react/runtimes/external-store-history-copy.js +148 -0
- package/dist/react/runtimes/external-store-history-copy.js.map +1 -0
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts +3 -6
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +72 -35
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +2 -5
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +29 -41
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +142 -34
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +3 -6
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +2 -2
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +5 -7
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +4 -6
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +72 -70
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +11 -15
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +60 -60
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +21 -24
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/react/types/store-augmentation.d.ts +10 -11
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +6 -8
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +35 -37
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +3 -6
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +3 -6
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +28 -31
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +51 -49
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +35 -35
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +215 -201
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +4 -0
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +31 -30
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +25 -2
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +87 -82
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +4 -3
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts +54 -57
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +70 -72
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +77 -81
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +306 -308
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +2 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +9 -12
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +150 -101
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +400 -122
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +121 -104
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +174 -62
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +30 -31
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +21 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +28 -31
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +23 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +15 -18
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +8 -11
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +98 -83
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +67 -70
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +225 -211
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +25 -20
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +37 -40
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +32 -33
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +10 -2
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/queue/queue-item.d.ts +7 -10
- package/dist/runtime/queue/queue-item.d.ts.map +1 -1
- package/dist/runtime/utils/abortable-thread-load.d.ts +9 -11
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.d.ts +16 -15
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.js +24 -2
- package/dist/runtime/utils/attachment-add-operations.js.map +1 -1
- package/dist/runtime/utils/attachment-send-operations.d.ts +12 -0
- package/dist/runtime/utils/attachment-send-operations.d.ts.map +1 -0
- package/dist/runtime/utils/attachment-send-operations.js +34 -0
- package/dist/runtime/utils/attachment-send-operations.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +11 -13
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +3 -5
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +31 -33
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +47 -48
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +6 -5
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +6 -9
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +24 -27
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +52 -54
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +8 -7
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +12 -14
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +7 -10
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +6 -9
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
- package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
- package/dist/runtime/utils/stored-message-parts.js +103 -0
- package/dist/runtime/utils/stored-message-parts.js.map +1 -0
- package/dist/runtime/utils/streaming-timing.d.ts +23 -26
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +38 -34
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +16 -6
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +5 -7
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.js +31 -4
- package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -1
- package/dist/runtime/utils/tool-call-tree.d.ts +10 -13
- package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
- package/dist/runtime/utils/tool-interactions.d.ts +10 -0
- package/dist/runtime/utils/tool-interactions.d.ts.map +1 -0
- package/dist/runtime/utils/tool-interactions.js +92 -0
- package/dist/runtime/utils/tool-interactions.js.map +1 -0
- package/dist/runtimes/assistant-transport/utils.d.ts +1 -4
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +220 -200
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +6 -8
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js +4 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.d.ts +3 -6
- package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +40 -43
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +2 -2
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +119 -125
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +71 -18
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +5 -8
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +96 -98
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.js +3 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/internal.d.ts +20 -16
- package/dist/runtimes/internal.d.ts.map +1 -0
- package/dist/runtimes/local/local-runtime-core.d.ts +7 -10
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +41 -44
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +42 -45
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +94 -93
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +220 -29
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +2 -5
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +77 -55
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +28 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +12 -15
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +3 -6
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +2 -5
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +34 -31
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +8 -3
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +60 -63
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -1
- package/dist/runtimes/remote-thread-list/title-generation.d.ts +31 -33
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +5 -8
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +119 -121
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +147 -149
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +22 -7
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +8 -11
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/external-thread.d.ts +56 -58
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +1270 -741
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +2 -5
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +3 -6
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +3 -1
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +2 -5
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts +4 -6
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/submission-message.d.ts +8 -0
- package/dist/store/clients/submission-message.d.ts.map +1 -0
- package/dist/store/clients/submission-message.js +22 -0
- package/dist/store/clients/submission-message.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +8 -11
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +12 -12
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +81 -82
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/clients/thread-selection-events.d.ts +1 -4
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +7 -10
- package/dist/store/clients/thread-tasks.d.ts.map +1 -1
- package/dist/store/env.d.ts +1 -4
- package/dist/store/env.d.ts.map +1 -1
- package/dist/store/index.d.ts +33 -36
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +5 -5
- package/dist/store/internal.d.ts +12 -12
- package/dist/store/internal.d.ts.map +1 -0
- package/dist/store/internal.js +2 -2
- package/dist/store/primitive-predicates.d.ts +14 -16
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +10 -5
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +11 -14
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +65 -62
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -4
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -4
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +2 -5
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +26 -16
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +10 -11
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +121 -113
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +5 -8
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +6 -9
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +221 -158
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +3 -6
- package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
- package/dist/store/scope-registration.d.ts +28 -29
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/attachment.d.ts +19 -22
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +33 -35
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +147 -135
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +119 -112
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +10 -13
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +53 -50
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +21 -23
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts +14 -17
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +18 -21
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +27 -30
- package/dist/store/scopes/task.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +68 -71
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +197 -200
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +49 -52
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +73 -69
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +35 -7
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/attachment.d.ts +35 -37
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/augmentations.d.ts +7 -8
- package/dist/types/augmentations.d.ts.map +1 -1
- package/dist/types/directive.d.ts +13 -16
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +15 -17
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/message.d.ts +358 -318
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts +3 -6
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +10 -13
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts +1 -4
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +2 -5
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +9 -13
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +16 -19
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +19 -21
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/id.d.ts +3 -6
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/image-media-type.d.ts +1 -4
- package/dist/utils/image-media-type.d.ts.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +1 -4
- package/dist/utils/invoke-user-callback.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +1 -4
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +5 -8
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +3 -6
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.d.ts +6 -8
- package/dist/utils/normalizePartStatus.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.js +3 -2
- package/dist/utils/normalizePartStatus.js.map +1 -1
- package/dist/utils/notify-event-listeners.d.ts +2 -4
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/record.d.ts +1 -4
- package/dist/utils/record.d.ts.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +2 -5
- package/dist/utils/silent-runtime-action.d.ts.map +1 -1
- package/dist/utils/text.d.ts +2 -5
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/wire-media.d.ts +3 -6
- package/dist/utils/wire-media.d.ts.map +1 -1
- package/package.json +15 -13
- package/src/adapters/attachment.test.ts +98 -1
- package/src/adapters/attachment.ts +77 -20
- package/src/adapters/feedback.ts +1 -0
- package/src/adapters/speech.test.ts +94 -0
- package/src/adapters/speech.ts +16 -2
- package/src/adapters/thread-history.ts +16 -5
- package/src/adapters/voice.test.ts +169 -0
- package/src/adapters/voice.ts +25 -4
- package/src/index.ts +14 -2
- package/src/internal.ts +7 -0
- package/src/model-context/frame/host.test.ts +51 -1
- package/src/model-context/frame/host.ts +3 -1
- package/src/model-context/frame/provider.test.ts +106 -20
- package/src/model-context/frame/provider.ts +8 -1
- package/src/model-context/frame/validate.ts +57 -0
- package/src/model-context/interactable-composer-metadata.test.ts +82 -0
- package/src/model-context/interactable-composer-metadata.ts +45 -2
- package/src/react/RuntimeAdapter.test.ts +4 -1
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +711 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +125 -109
- package/src/react/client/Interactables.test.ts +865 -8
- package/src/react/client/Interactables.ts +325 -45
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
- package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
- package/src/react/client/RemoteThreadList.test.ts +5 -6
- package/src/react/client/RemoteThreadList.ts +6 -0
- package/src/react/client/Tools.ts +2 -3
- package/src/react/client/interactable-model-context.test.ts +56 -13
- package/src/react/client/interactable-model-context.ts +48 -23
- package/src/react/index.ts +2 -2
- package/src/react/interactables-legacy/Interactables.test.ts +221 -4
- package/src/react/interactables-legacy/Interactables.ts +25 -14
- package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +40 -22
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
- package/src/react/model-context/useInteractable.test.tsx +56 -29
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -5
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +33 -0
- package/src/react/primitive-hooks/useSuggestionTrigger.ts +7 -4
- package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +170 -0
- package/src/react/primitives/generativeUI/GenerativeUI.tsx +43 -28
- package/src/react/primitives/message/MessageAttachments.test.tsx +2 -6
- package/src/react/primitives/message/MessageAttachments.tsx +14 -8
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +155 -8
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -6
- package/src/react/primitives/message/MessageParts.test.tsx +84 -0
- package/src/react/primitives/message/MessageParts.tool-interaction.test.tsx +69 -0
- package/src/react/primitives/message/MessageParts.tsx +29 -8
- package/src/react/primitives/thread/ThreadMessages.test.tsx +25 -7
- package/src/react/primitives/thread/ThreadSuggestions.test.tsx +97 -0
- package/src/react/primitives/thread/ThreadSuggestions.tsx +29 -6
- package/src/react/providers/ReadonlyThreadProvider.tsx +2 -2
- package/src/react/providers/TextMessagePartProvider.tsx +3 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +93 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +181 -21
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +62 -17
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +112 -77
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -3
- package/src/react/runtimes/RemoteThreadResource.ts +5 -2
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +3 -1
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +10 -2
- package/src/react/runtimes/assistant-transport/runManager.ts +3 -0
- package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +57 -0
- package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
- package/src/react/runtimes/assistant-transport/transport-thread-id.test.tsx +571 -0
- package/src/react/runtimes/assistant-transport/types.ts +9 -1
- package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +10 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +108 -1
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +33 -9
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.integration.test.tsx +289 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.test.tsx +471 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.engagement.test.tsx +330 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +78 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +463 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +595 -227
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +33 -4
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
- package/src/react/runtimes/cloud/auiV0.ts +275 -6
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +873 -0
- package/src/react/runtimes/createMessageConverter.ts +9 -3
- package/src/react/runtimes/external-message-converter.test.ts +7 -3
- package/src/react/runtimes/external-store-history-copy.ts +223 -0
- package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
- package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +84 -3
- package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
- package/src/react/runtimes/useExternalStoreRuntime.ts +25 -5
- package/src/react/runtimes/useLocalRuntime.test.tsx +145 -1
- package/src/react/runtimes/useLocalRuntime.ts +8 -5
- package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +5 -1
- package/src/react/types/MessagePartComponentTypes.ts +10 -0
- package/src/react/types/scopes/interactables.ts +3 -0
- package/src/runtime/api/attachment-runtime.ts +10 -5
- package/src/runtime/api/bindings.ts +6 -1
- package/src/runtime/api/composer-runtime.ts +29 -6
- package/src/runtime/api/message-part-runtime.test.ts +215 -0
- package/src/runtime/api/message-part-runtime.ts +44 -1
- package/src/runtime/api/message-runtime.test.ts +112 -2
- package/src/runtime/api/message-runtime.ts +25 -7
- package/src/runtime/api/thread-list-item-runtime.ts +5 -5
- package/src/runtime/api/thread-list-runtime.ts +3 -3
- package/src/runtime/api/thread-runtime.test.ts +59 -0
- package/src/runtime/api/thread-runtime.ts +21 -11
- package/src/runtime/base/base-composer-runtime-core.ts +548 -153
- package/src/runtime/base/base-thread-runtime-core.test.ts +1614 -136
- package/src/runtime/base/base-thread-runtime-core.ts +236 -46
- package/src/runtime/base/default-edit-composer-runtime-core.ts +24 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +33 -3
- package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +24 -1
- package/src/runtime/queue/message-queue.ts +11 -1
- package/src/runtime/utils/attachment-add-operations.ts +45 -2
- package/src/runtime/utils/attachment-send-operations.ts +54 -0
- package/src/runtime/utils/auto-status.test.ts +54 -0
- package/src/runtime/utils/auto-status.ts +3 -10
- package/src/runtime/utils/external-message-conversion.test.ts +91 -0
- package/src/runtime/utils/external-message-conversion.ts +9 -6
- package/src/runtime/utils/message-repository.test.ts +69 -1
- package/src/runtime/utils/message-repository.ts +14 -7
- package/src/runtime/utils/stored-message-parts.ts +216 -0
- package/src/runtime/utils/thread-message-like.test.ts +58 -0
- package/src/runtime/utils/thread-message-like.ts +79 -48
- package/src/runtime/utils/thread-runtime-lifecycle.test.ts +67 -0
- package/src/runtime/utils/thread-runtime-lifecycle.ts +42 -8
- package/src/runtime/utils/tool-interactions.test.ts +193 -0
- package/src/runtime/utils/tool-interactions.ts +147 -0
- package/src/runtimes/external-store/external-store-adapter.ts +25 -0
- package/src/runtimes/external-store/external-store-runtime-core.ts +10 -2
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +2 -2
- package/src/runtimes/external-store/external-store-thread-runtime-core.test.ts +49 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +114 -32
- package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +127 -56
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +10 -1
- package/src/runtimes/local/local-thread-runtime-core.edit-cancellation.test.ts +70 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +1866 -169
- package/src/runtimes/local/local-thread-runtime-core.ts +365 -40
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +53 -1
- package/src/runtimes/remote-thread-list/optimistic-state.ts +8 -3
- package/src/runtimes/tool-invocations/EDGE_CASES.md +19 -4
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +392 -39
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +31 -8
- package/src/store/clients/external-thread.test.ts +145 -0
- package/src/store/clients/external-thread.ts +669 -144
- package/src/store/clients/model-context-client.test.ts +8 -8
- package/src/store/clients/no-op-composer-client.ts +2 -0
- package/src/store/clients/submission-message.ts +27 -0
- package/src/store/clients/thread-message-client.test.ts +39 -0
- package/src/store/clients/thread-message-client.ts +13 -6
- package/src/store/index.ts +2 -2
- package/src/store/internal.ts +1 -0
- package/src/store/primitive-predicates.test.ts +119 -0
- package/src/store/primitive-predicates.ts +19 -4
- package/src/store/runtime-clients/composer-runtime-client.ts +4 -3
- package/src/store/runtime-clients/message-part-runtime-client.test.ts +42 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +4 -0
- package/src/store/runtime-clients/message-runtime-client.ts +5 -0
- package/src/store/runtime-clients/thread-runtime-client.test.tsx +243 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +46 -9
- package/src/store/scopes/composer.ts +22 -4
- package/src/store/scopes/message.ts +12 -1
- package/src/store/scopes/part.ts +8 -0
- package/src/subscribable/subscribable.test.ts +205 -3
- package/src/subscribable/subscribable.ts +49 -7
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
- package/src/tests/attachment-adapters.test.ts +16 -1
- package/src/tests/auiV0Encode.test.ts +412 -1
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
- package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
- package/src/tests/base-composer-runtime-core.test.ts +212 -5
- package/src/tests/composer-can-cancel.test.ts +35 -6
- package/src/tests/composer-can-send.test.ts +120 -1
- package/src/tests/composer-submission.test.tsx +796 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +149 -2
- package/src/tests/external-store-thread-list-runtime-core.test.ts +111 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +810 -28
- package/src/tests/external-store-thread-runtime-core.test.ts +217 -0
- package/src/tests/external-thread-attachments.test.tsx +763 -26
- package/src/tests/external-thread-feedback.test.tsx +20 -7
- package/src/tests/external-thread-isLast.test.tsx +69 -0
- package/src/tests/external-thread-parity.test.tsx +1 -1
- package/src/tests/get-thread-state-isRunning.test.ts +2 -2
- package/src/tests/message-queue.test.ts +45 -10
- package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
- package/src/tests/thread-switch-events.test.tsx +11 -7
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +2 -1
- package/src/types/message.test.ts +19 -0
- package/src/types/message.ts +65 -10
- package/src/utils/normalizePartStatus.ts +14 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -16
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
- package/dist/tests/remote-thread-list-test-helpers.js +0 -59
- package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import type {
|
|
20
20
|
AttachmentAddErrorReason,
|
|
21
21
|
ComposerRuntimeCore,
|
|
22
|
+
ComposerSubmission,
|
|
22
23
|
ComposerRuntimeEventCallback,
|
|
23
24
|
ComposerRuntimeEventPayload,
|
|
24
25
|
ComposerRuntimeEventType,
|
|
@@ -34,6 +35,12 @@ import {
|
|
|
34
35
|
AttachmentAddOperations,
|
|
35
36
|
drainAttachmentAdd,
|
|
36
37
|
} from "../utils/attachment-add-operations";
|
|
38
|
+
import { AttachmentSendOperations } from "../utils/attachment-send-operations";
|
|
39
|
+
|
|
40
|
+
type InTransit = {
|
|
41
|
+
readonly submission: ComposerSubmission;
|
|
42
|
+
readonly known: ReadonlySet<string>;
|
|
43
|
+
};
|
|
37
44
|
|
|
38
45
|
export abstract class BaseComposerRuntimeCore
|
|
39
46
|
extends BaseSubscribable
|
|
@@ -143,10 +150,89 @@ export abstract class BaseComposerRuntimeCore
|
|
|
143
150
|
this._notifySubscribers();
|
|
144
151
|
}
|
|
145
152
|
|
|
146
|
-
|
|
147
|
-
private
|
|
153
|
+
private _submission: ComposerSubmission | undefined;
|
|
154
|
+
private _submissionSend:
|
|
155
|
+
| {
|
|
156
|
+
readonly options: SendOptions | undefined;
|
|
157
|
+
readonly runConfig: RunConfig;
|
|
158
|
+
readonly controller: AbortController;
|
|
159
|
+
}
|
|
160
|
+
| undefined;
|
|
161
|
+
private _inTransit: readonly InTransit[] = [];
|
|
162
|
+
private _inTransitSubmissions: readonly ComposerSubmission[] = [];
|
|
148
163
|
private _sendGeneration = 0;
|
|
149
164
|
private _attachmentAddOperations = new AttachmentAddOperations();
|
|
165
|
+
private _attachmentSends = new AttachmentSendOperations();
|
|
166
|
+
|
|
167
|
+
public get submission() {
|
|
168
|
+
return this._submission;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public get inTransit() {
|
|
172
|
+
return this._inTransitSubmissions;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Whether a send is still being prepared, which holds the composer. */
|
|
176
|
+
protected get isSubmitting() {
|
|
177
|
+
return this._submission !== undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Whether a send takes the draft with it, leaving the composer free. */
|
|
181
|
+
protected get detachesDraftOnSend(): boolean {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The ids of the thread's messages of a role, or undefined when this
|
|
187
|
+
* composer's sends do not render in the thread. A dispatched submission
|
|
188
|
+
* stays in transit until a message of its role that was not there at
|
|
189
|
+
* dispatch shows up.
|
|
190
|
+
*/
|
|
191
|
+
protected threadMessageIds(
|
|
192
|
+
_role: MessageRole,
|
|
193
|
+
): readonly string[] | undefined {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Releases the messages in transit that the thread now shows. Each new
|
|
199
|
+
* message stands in for the oldest send still waiting for one, and only
|
|
200
|
+
* once, so sends made in quick succession hand over in order.
|
|
201
|
+
*/
|
|
202
|
+
protected settleInTransit() {
|
|
203
|
+
if (this._inTransit.length === 0) return;
|
|
204
|
+
const claimed = new Set<string>();
|
|
205
|
+
const pending = this._inTransit.filter(({ submission, known }) => {
|
|
206
|
+
const shown = this.threadMessageIds(submission.role)?.find(
|
|
207
|
+
(id) => !known.has(id) && !claimed.has(id),
|
|
208
|
+
);
|
|
209
|
+
if (shown === undefined) return true;
|
|
210
|
+
claimed.add(shown);
|
|
211
|
+
return false;
|
|
212
|
+
});
|
|
213
|
+
if (pending.length === this._inTransit.length) return;
|
|
214
|
+
this._setInTransit(
|
|
215
|
+
pending.map((entry) => ({
|
|
216
|
+
...entry,
|
|
217
|
+
known: new Set([...entry.known, ...claimed]),
|
|
218
|
+
})),
|
|
219
|
+
);
|
|
220
|
+
this._notifySubscribers();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private _setInTransit(entries: readonly InTransit[]) {
|
|
224
|
+
this._inTransit = entries;
|
|
225
|
+
this._inTransitSubmissions = entries.map((entry) => entry.submission);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private _leaveTransit(submission: ComposerSubmission) {
|
|
229
|
+
const remaining = this._inTransit.filter(
|
|
230
|
+
(entry) => entry.submission !== submission,
|
|
231
|
+
);
|
|
232
|
+
if (remaining.length === this._inTransit.length) return false;
|
|
233
|
+
this._setInTransit(remaining);
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
150
236
|
|
|
151
237
|
private _cancelAttachmentAdd(attachmentId: string) {
|
|
152
238
|
this._attachmentAddOperations.cancel(attachmentId);
|
|
@@ -179,8 +265,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
179
265
|
// invalidates that send entirely so a late-settling upload can neither
|
|
180
266
|
// append the discarded draft nor touch a newer send's lock.
|
|
181
267
|
this._sendGeneration++;
|
|
182
|
-
|
|
183
|
-
this._removedDuringSend.clear();
|
|
268
|
+
const discarded = this._discardSubmission();
|
|
184
269
|
|
|
185
270
|
if (
|
|
186
271
|
this._attachments.length === 0 &&
|
|
@@ -189,6 +274,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
189
274
|
Object.keys(this._runConfig).length === 0 &&
|
|
190
275
|
this._quote === undefined
|
|
191
276
|
) {
|
|
277
|
+
await discarded;
|
|
192
278
|
return;
|
|
193
279
|
}
|
|
194
280
|
|
|
@@ -198,14 +284,14 @@ export abstract class BaseComposerRuntimeCore
|
|
|
198
284
|
|
|
199
285
|
const task = this._onClearAttachments();
|
|
200
286
|
this._emptyTextAndAttachments();
|
|
201
|
-
await task;
|
|
287
|
+
await Promise.all([task, discarded]);
|
|
202
288
|
}
|
|
203
289
|
|
|
204
290
|
public async clearAttachments() {
|
|
205
291
|
this._cancelAllAttachmentAdds();
|
|
206
|
-
if (this.
|
|
292
|
+
if (this.isSubmitting) {
|
|
207
293
|
for (const attachment of this._attachments)
|
|
208
|
-
this.
|
|
294
|
+
this._attachmentSends.markRemoved(attachment);
|
|
209
295
|
}
|
|
210
296
|
const task = this._onClearAttachments();
|
|
211
297
|
this.setAttachments([]);
|
|
@@ -214,105 +300,301 @@ export abstract class BaseComposerRuntimeCore
|
|
|
214
300
|
}
|
|
215
301
|
|
|
216
302
|
public async send(options?: SendOptions) {
|
|
217
|
-
if (!this.canSend || this.
|
|
303
|
+
if (!this.canSend || this.isSubmitting) return;
|
|
218
304
|
|
|
219
305
|
if (this._dictationSession) {
|
|
306
|
+
const sessionId = this._activeDictationSessionId;
|
|
220
307
|
try {
|
|
221
308
|
this._dictationSession.cancel();
|
|
222
309
|
} catch (error) {
|
|
223
310
|
console.error("[assistant-ui] Dictation session cancel threw", error);
|
|
224
311
|
} finally {
|
|
225
|
-
this._cleanupDictation();
|
|
312
|
+
this._cleanupDictation({ sessionId });
|
|
226
313
|
}
|
|
227
314
|
}
|
|
228
315
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
316
|
+
// An attachment whose removal is still awaiting the adapter is excluded
|
|
317
|
+
// up front, or a send started mid-removal would upload and dispatch it.
|
|
318
|
+
const attachments = this.attachments.filter(
|
|
319
|
+
(attachment) => !this._attachmentSends.isRemoved(attachment),
|
|
320
|
+
);
|
|
321
|
+
// canSend counted an attachment whose removal is still in flight, so the
|
|
322
|
+
// draft can be empty by the time the filter above has run.
|
|
323
|
+
if (!this.text.trim() && attachments.length === 0) return;
|
|
324
|
+
|
|
325
|
+
const draft: ComposerSubmission = {
|
|
326
|
+
id: generateId(),
|
|
327
|
+
role: this.role,
|
|
328
|
+
text: this.text,
|
|
329
|
+
quote: this._quote,
|
|
330
|
+
attachments,
|
|
331
|
+
};
|
|
332
|
+
const context = { options, runConfig: this.runConfig };
|
|
333
|
+
// Only a send whose attachments still need the adapter becomes a
|
|
334
|
+
// submission; one with nothing left to prepare goes out right away, as it
|
|
335
|
+
// always has, and never shows up as a row of its own.
|
|
336
|
+
const complete = attachments.filter(isAttachmentComplete);
|
|
337
|
+
const ready = complete.length === attachments.length;
|
|
338
|
+
if (!ready) {
|
|
339
|
+
this._submission = draft;
|
|
340
|
+
this._submissionSend = { ...context, controller: new AbortController() };
|
|
341
|
+
}
|
|
342
|
+
if (this.detachesDraftOnSend) {
|
|
343
|
+
const detached = new Set(attachments);
|
|
344
|
+
this._attachments = this._attachments.filter((a) => !detached.has(a));
|
|
345
|
+
this._text = "";
|
|
346
|
+
this._rebaseDictation("");
|
|
347
|
+
this._quote = undefined;
|
|
348
|
+
}
|
|
245
349
|
const generation = ++this._sendGeneration;
|
|
246
350
|
this._notifySubscribers();
|
|
247
351
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
352
|
+
if (ready) {
|
|
353
|
+
this._dispatch(generation, draft, complete, context, false);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
await this._prepareSubmission(generation);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private async _prepareSubmission(generation: number) {
|
|
360
|
+
const adapter = this.getAttachmentAdapter();
|
|
361
|
+
const uploads = (this._submission?.attachments ?? []).flatMap(
|
|
362
|
+
(attachment) => {
|
|
363
|
+
const upload = this._attachmentAddOperations.whenSendable(
|
|
364
|
+
attachment.id,
|
|
365
|
+
);
|
|
366
|
+
return upload ? [upload] : [];
|
|
367
|
+
},
|
|
368
|
+
);
|
|
369
|
+
if (uploads.length > 0) {
|
|
370
|
+
// An attachment still uploading in `add()` cannot be finalized yet, so
|
|
371
|
+
// the submission waits for its latest state.
|
|
372
|
+
await Promise.all(uploads);
|
|
373
|
+
if (generation !== this._sendGeneration) return;
|
|
374
|
+
this._refreshSubmissionAttachments();
|
|
271
375
|
}
|
|
272
376
|
|
|
273
|
-
|
|
274
|
-
|
|
377
|
+
const submission = this._submission;
|
|
378
|
+
const context = this._submissionSend;
|
|
379
|
+
if (!submission || !context) return;
|
|
380
|
+
|
|
381
|
+
const sent = submission.attachments.filter(
|
|
382
|
+
(attachment) => !this._attachmentSends.isRemoved(attachment),
|
|
383
|
+
);
|
|
384
|
+
for (const attachment of sent) this._cancelAttachmentAdd(attachment.id);
|
|
385
|
+
|
|
386
|
+
const settled = await Promise.allSettled(
|
|
387
|
+
sent.map((attachment) =>
|
|
388
|
+
this._attachmentSends.send(
|
|
389
|
+
attachment,
|
|
390
|
+
adapter,
|
|
391
|
+
context.controller.signal,
|
|
392
|
+
),
|
|
393
|
+
),
|
|
394
|
+
);
|
|
275
395
|
if (generation !== this._sendGeneration) return;
|
|
276
396
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
this._notifySubscribers();
|
|
397
|
+
const rejection = settled.find((result) => result.status === "rejected");
|
|
398
|
+
if (rejection) {
|
|
399
|
+
this._returnSubmissionToDraft(sent, settled, rejection.reason);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
283
402
|
|
|
284
403
|
// An attachment removed mid-upload can't be cancelled, but it can still be
|
|
285
404
|
// dropped from the outgoing message instead of silently being sent anyway.
|
|
286
|
-
const finalAttachments =
|
|
287
|
-
|
|
405
|
+
const finalAttachments = settled.flatMap((result, index) =>
|
|
406
|
+
this._attachmentSends.isRemoved(sent[index]!) ||
|
|
407
|
+
result.status === "rejected"
|
|
408
|
+
? []
|
|
409
|
+
: [result.value],
|
|
288
410
|
);
|
|
289
|
-
this.
|
|
411
|
+
this._dispatch(generation, submission, finalAttachments, context, true);
|
|
412
|
+
}
|
|
290
413
|
|
|
414
|
+
private _dispatch(
|
|
415
|
+
generation: number,
|
|
416
|
+
draft: ComposerSubmission,
|
|
417
|
+
attachments: readonly CompleteAttachment[],
|
|
418
|
+
context: { options: SendOptions | undefined; runConfig: RunConfig },
|
|
419
|
+
isSubmission: boolean,
|
|
420
|
+
) {
|
|
291
421
|
const message: Omit<AppendMessage, "parentId" | "sourceId"> = {
|
|
292
422
|
createdAt: new Date(),
|
|
293
|
-
role,
|
|
294
|
-
content: text ? [{ type: "text", text }] : [],
|
|
295
|
-
attachments
|
|
296
|
-
runConfig,
|
|
297
|
-
metadata: {
|
|
423
|
+
role: draft.role,
|
|
424
|
+
content: draft.text ? [{ type: "text", text: draft.text }] : [],
|
|
425
|
+
attachments,
|
|
426
|
+
runConfig: context.runConfig,
|
|
427
|
+
metadata: {
|
|
428
|
+
custom: { ...(draft.quote ? { quote: draft.quote } : {}) },
|
|
429
|
+
},
|
|
298
430
|
};
|
|
299
431
|
|
|
300
|
-
const
|
|
432
|
+
const sent: ComposerSubmission = { ...draft, attachments };
|
|
433
|
+
const queued = this.queue.length;
|
|
434
|
+
if (isSubmission) {
|
|
435
|
+
// The runtime owns the message from here, so neither a reset nor the
|
|
436
|
+
// next send can reach it, and the thread shows it until the runtime does.
|
|
437
|
+
this._submission = undefined;
|
|
438
|
+
this._submissionSend = undefined;
|
|
439
|
+
// A composer that kept its draft holds the same attachments, which are
|
|
440
|
+
// the delivered ones now, so clearing that draft (an edit ending) must
|
|
441
|
+
// not remove their uploads.
|
|
442
|
+
if (!this.detachesDraftOnSend) {
|
|
443
|
+
const delivered = new Map(
|
|
444
|
+
attachments.map((attachment) => [attachment.id, attachment]),
|
|
445
|
+
);
|
|
446
|
+
this._attachments = this._attachments.map(
|
|
447
|
+
(attachment) => delivered.get(attachment.id) ?? attachment,
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
const known = this.threadMessageIds(draft.role);
|
|
451
|
+
if (known)
|
|
452
|
+
this._setInTransit([
|
|
453
|
+
...this._inTransit,
|
|
454
|
+
{ submission: sent, known: new Set(known) },
|
|
455
|
+
]);
|
|
456
|
+
}
|
|
457
|
+
|
|
301
458
|
let sendTask: void | Promise<void>;
|
|
302
459
|
try {
|
|
303
|
-
sendTask = this.handleSend(message, options);
|
|
460
|
+
sendTask = this.handleSend(message, context.options);
|
|
304
461
|
} catch (error) {
|
|
305
|
-
|
|
306
|
-
|
|
462
|
+
console.error("[assistant-ui] Failed to send the message", error);
|
|
463
|
+
this._leaveTransit(sent);
|
|
464
|
+
if (generation === this._sendGeneration) this._returnToDraft(sent);
|
|
465
|
+
else this._notifySubscribers();
|
|
466
|
+
return;
|
|
307
467
|
}
|
|
308
468
|
if (sendTask)
|
|
309
469
|
void sendTask.catch((error) => {
|
|
310
|
-
this.
|
|
470
|
+
const wasInTransit = this._leaveTransit(sent);
|
|
471
|
+
if (generation === this._sendGeneration && isMessageNotSentError(error))
|
|
472
|
+
this._returnToDraft(sent);
|
|
473
|
+
else if (wasInTransit) this._notifySubscribers();
|
|
311
474
|
});
|
|
475
|
+
|
|
312
476
|
this._notifyEventSubscribers("send", {
|
|
313
|
-
chars: text.length,
|
|
314
|
-
attachments:
|
|
477
|
+
chars: draft.text.length,
|
|
478
|
+
attachments: attachments.length,
|
|
315
479
|
});
|
|
480
|
+
|
|
481
|
+
if (!isSubmission) return;
|
|
482
|
+
// A queued message has its own place in the UI.
|
|
483
|
+
if (this.queue.length > queued) this._leaveTransit(sent);
|
|
484
|
+
this._notifySubscribers();
|
|
485
|
+
this.settleInTransit();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
private _refreshSubmissionAttachments() {
|
|
489
|
+
const submission = this._submission;
|
|
490
|
+
if (!submission) return;
|
|
491
|
+
const attachments = submission.attachments.filter(
|
|
492
|
+
(attachment) => !this._attachmentSends.isRemoved(attachment),
|
|
493
|
+
);
|
|
494
|
+
if (attachments.length === submission.attachments.length) return;
|
|
495
|
+
this._submission = { ...submission, attachments };
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
private _returnSubmissionToDraft(
|
|
499
|
+
sent: readonly Attachment[],
|
|
500
|
+
settled: readonly PromiseSettledResult<CompleteAttachment>[],
|
|
501
|
+
reason: unknown,
|
|
502
|
+
) {
|
|
503
|
+
const submission = this._submission;
|
|
504
|
+
if (!submission) return;
|
|
505
|
+
|
|
506
|
+
const failures = new Map<string, unknown>();
|
|
507
|
+
settled.forEach((result, index) => {
|
|
508
|
+
if (result.status === "rejected")
|
|
509
|
+
failures.set(sent[index]!.id, result.reason);
|
|
510
|
+
});
|
|
511
|
+
// Each attachment that could not be prepared carries its own reason, so
|
|
512
|
+
// the draft it returns to shows which file needs another try.
|
|
513
|
+
const attachments = submission.attachments.map((attachment) => {
|
|
514
|
+
if (!failures.has(attachment.id) || isAttachmentComplete(attachment))
|
|
515
|
+
return attachment;
|
|
516
|
+
const failure = failures.get(attachment.id);
|
|
517
|
+
return this._attachmentSends.transfer(attachment, {
|
|
518
|
+
...attachment,
|
|
519
|
+
status: {
|
|
520
|
+
type: "incomplete",
|
|
521
|
+
reason: "error",
|
|
522
|
+
message: failure instanceof Error ? failure.message : String(failure),
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
this._endSubmission();
|
|
527
|
+
this._returnToDraft({ ...submission, attachments });
|
|
528
|
+
console.error("[assistant-ui] Failed to send attachments", reason);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Ends the send being prepared, so nothing it started can dispatch it. */
|
|
532
|
+
private _endSubmission() {
|
|
533
|
+
this._sendGeneration++;
|
|
534
|
+
this._submission = undefined;
|
|
535
|
+
this._submissionSend = undefined;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Stops the submission and takes its content back into the draft, merging it
|
|
540
|
+
* ahead of anything written since, so a send is never dropped.
|
|
541
|
+
*/
|
|
542
|
+
protected cancelSubmission() {
|
|
543
|
+
const submission = this._submission;
|
|
544
|
+
if (!submission) return;
|
|
545
|
+
this._submissionSend?.controller.abort();
|
|
546
|
+
this._endSubmission();
|
|
547
|
+
this._returnToDraft(submission);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Takes a send's content back into the draft, ahead of anything written
|
|
552
|
+
* since. A composer that kept its draft only takes back the state the
|
|
553
|
+
* attachments came back in, such as the reason one failed.
|
|
554
|
+
*/
|
|
555
|
+
private _returnToDraft(submission: ComposerSubmission) {
|
|
556
|
+
if (this.detachesDraftOnSend) {
|
|
557
|
+
const kept = submission.attachments.filter(
|
|
558
|
+
(attachment) => !this._attachmentSends.isRemoved(attachment),
|
|
559
|
+
);
|
|
560
|
+
this._attachments = [...kept, ...this._attachments];
|
|
561
|
+
const text = [submission.text, this._text].filter(Boolean).join("\n");
|
|
562
|
+
this._text = text;
|
|
563
|
+
this._rebaseDictation(text);
|
|
564
|
+
this._quote = this._quote ?? submission.quote;
|
|
565
|
+
} else {
|
|
566
|
+
const returned = new Map(
|
|
567
|
+
submission.attachments.map((attachment) => [attachment.id, attachment]),
|
|
568
|
+
);
|
|
569
|
+
this._attachments = this._attachments.map(
|
|
570
|
+
(attachment) => returned.get(attachment.id) ?? attachment,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
this._notifySubscribers();
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
private async _discardSubmission() {
|
|
577
|
+
const submission = this._submission;
|
|
578
|
+
if (!submission) return;
|
|
579
|
+
|
|
580
|
+
this._submissionSend?.controller.abort();
|
|
581
|
+
this._endSubmission();
|
|
582
|
+
this._notifySubscribers();
|
|
583
|
+
|
|
584
|
+
const adapter = this.getAttachmentAdapter();
|
|
585
|
+
if (!adapter) return;
|
|
586
|
+
// An attachment the draft still holds is removed along with the draft.
|
|
587
|
+
const drafted = new Set(
|
|
588
|
+
this._attachments.map((attachment) => attachment.id),
|
|
589
|
+
);
|
|
590
|
+
await Promise.all(
|
|
591
|
+
submission.attachments
|
|
592
|
+
.filter(
|
|
593
|
+
(attachment) =>
|
|
594
|
+
!isAttachmentComplete(attachment) && !drafted.has(attachment.id),
|
|
595
|
+
)
|
|
596
|
+
.map(async (attachment) => adapter.remove(attachment)),
|
|
597
|
+
);
|
|
316
598
|
}
|
|
317
599
|
|
|
318
600
|
/**
|
|
@@ -371,24 +653,14 @@ export abstract class BaseComposerRuntimeCore
|
|
|
371
653
|
this._notifySubscribers();
|
|
372
654
|
}
|
|
373
655
|
|
|
374
|
-
// The generation check is what a reset and a later send use to invalidate a
|
|
375
|
-
// draft, so of several queued drafts only the most recent one is still
|
|
376
|
-
// restorable.
|
|
377
|
-
private _restoreUnsentDraft(
|
|
378
|
-
error: unknown,
|
|
379
|
-
generation: number,
|
|
380
|
-
draft: {
|
|
381
|
-
text: string;
|
|
382
|
-
quote: QuoteInfo | undefined;
|
|
383
|
-
attachments: readonly CompleteAttachment[];
|
|
384
|
-
},
|
|
385
|
-
) {
|
|
386
|
-
if (!isMessageNotSentError(error)) return;
|
|
387
|
-
if (generation !== this._sendGeneration) return;
|
|
388
|
-
this.restoreDraft(draft);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
656
|
public cancel() {
|
|
657
|
+
// A composer that keeps its draft while sending (an edit session) ends
|
|
658
|
+
// that session here, so its submission must not dispatch afterwards.
|
|
659
|
+
if (this.isSubmitting && !this.detachesDraftOnSend) {
|
|
660
|
+
this._submissionSend?.controller.abort();
|
|
661
|
+
this._endSubmission();
|
|
662
|
+
this._notifySubscribers();
|
|
663
|
+
}
|
|
392
664
|
this.handleCancel();
|
|
393
665
|
}
|
|
394
666
|
|
|
@@ -483,7 +755,25 @@ export abstract class BaseComposerRuntimeCore
|
|
|
483
755
|
|
|
484
756
|
const operation = this._attachmentAddOperations.start();
|
|
485
757
|
const upsertAttachment = (a: PendingAttachment) => {
|
|
486
|
-
if (!this._attachmentAddOperations.accept(operation, a
|
|
758
|
+
if (!this._attachmentAddOperations.accept(operation, a)) return false;
|
|
759
|
+
|
|
760
|
+
// An attachment the composer sent lives on the submission, so its
|
|
761
|
+
// remaining upload updates follow it there instead of coming back as a
|
|
762
|
+
// new draft entry.
|
|
763
|
+
const submission = this._submission;
|
|
764
|
+
const submitted =
|
|
765
|
+
submission?.attachments.some((attachment) => attachment.id === a.id) ??
|
|
766
|
+
false;
|
|
767
|
+
if (submission && submitted) {
|
|
768
|
+
this._submission = {
|
|
769
|
+
...submission,
|
|
770
|
+
attachments: submission.attachments.map((attachment) =>
|
|
771
|
+
attachment.id === a.id
|
|
772
|
+
? this._attachmentSends.transfer(attachment, a)
|
|
773
|
+
: attachment,
|
|
774
|
+
),
|
|
775
|
+
};
|
|
776
|
+
}
|
|
487
777
|
|
|
488
778
|
const idx = this._attachments.findIndex(
|
|
489
779
|
(attachment) => attachment.id === a.id,
|
|
@@ -494,7 +784,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
494
784
|
a,
|
|
495
785
|
...this._attachments.slice(idx + 1),
|
|
496
786
|
];
|
|
497
|
-
else {
|
|
787
|
+
else if (!submitted) {
|
|
498
788
|
this._attachments = [...this._attachments, a];
|
|
499
789
|
}
|
|
500
790
|
|
|
@@ -583,15 +873,18 @@ export abstract class BaseComposerRuntimeCore
|
|
|
583
873
|
|
|
584
874
|
async removeAttachment(attachmentId: string) {
|
|
585
875
|
const index = this._attachments.findIndex((a) => a.id === attachmentId);
|
|
586
|
-
if (index === -1)
|
|
876
|
+
if (index === -1) {
|
|
877
|
+
await this._removeSubmittedAttachment(attachmentId);
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
587
880
|
const attachment = this._attachments[index]!;
|
|
588
881
|
|
|
589
882
|
this._cancelAttachmentAdd(attachmentId);
|
|
590
883
|
|
|
591
|
-
//
|
|
592
|
-
//
|
|
593
|
-
//
|
|
594
|
-
|
|
884
|
+
// The mark must precede any await: an in-flight send drops the attachment
|
|
885
|
+
// from its outgoing message, and a send that starts while the adapter
|
|
886
|
+
// removal is still pending excludes it from the batch entirely.
|
|
887
|
+
this._attachmentSends.markRemoved(attachment);
|
|
595
888
|
|
|
596
889
|
if (!isAttachmentComplete(attachment)) {
|
|
597
890
|
const adapter = this.getAttachmentAdapter();
|
|
@@ -602,10 +895,10 @@ export abstract class BaseComposerRuntimeCore
|
|
|
602
895
|
const message = error instanceof Error ? error.message : String(error);
|
|
603
896
|
this._attachments = this._attachments.map((candidate) =>
|
|
604
897
|
candidate.id === attachmentId && !isAttachmentComplete(candidate)
|
|
605
|
-
? {
|
|
898
|
+
? this._attachmentSends.transfer(candidate, {
|
|
606
899
|
...candidate,
|
|
607
900
|
status: { type: "incomplete", reason: "error", message },
|
|
608
|
-
}
|
|
901
|
+
})
|
|
609
902
|
: candidate,
|
|
610
903
|
);
|
|
611
904
|
this._notifySubscribers();
|
|
@@ -616,6 +909,61 @@ export abstract class BaseComposerRuntimeCore
|
|
|
616
909
|
this._notifySubscribers();
|
|
617
910
|
}
|
|
618
911
|
|
|
912
|
+
/**
|
|
913
|
+
* A submission is not delivered yet, so an attachment can still be taken out
|
|
914
|
+
* of it, which the draft no longer holds once the send detached it.
|
|
915
|
+
*/
|
|
916
|
+
private async _removeSubmittedAttachment(attachmentId: string) {
|
|
917
|
+
const submitted = this._submission?.attachments.find(
|
|
918
|
+
(a) => a.id === attachmentId,
|
|
919
|
+
);
|
|
920
|
+
if (!submitted) throw new Error("Attachment not found");
|
|
921
|
+
|
|
922
|
+
this._cancelAttachmentAdd(attachmentId);
|
|
923
|
+
this._attachmentSends.markRemoved(submitted);
|
|
924
|
+
if (!isAttachmentComplete(submitted)) {
|
|
925
|
+
const adapter = this.getAttachmentAdapter();
|
|
926
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
|
927
|
+
try {
|
|
928
|
+
await adapter.remove(submitted);
|
|
929
|
+
} catch (error) {
|
|
930
|
+
this._failSubmittedRemoval(attachmentId, error);
|
|
931
|
+
throw error;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
const submission = this._submission;
|
|
935
|
+
if (!submission) return;
|
|
936
|
+
this._submission = {
|
|
937
|
+
...submission,
|
|
938
|
+
attachments: submission.attachments.filter((a) => a.id !== attachmentId),
|
|
939
|
+
};
|
|
940
|
+
this._notifySubscribers();
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* An attachment whose removal failed stays out of the message it was taken
|
|
945
|
+
* from and shows why, so the removal can be tried again.
|
|
946
|
+
*/
|
|
947
|
+
private _failSubmittedRemoval(attachmentId: string, error: unknown) {
|
|
948
|
+
const submission = this._submission;
|
|
949
|
+
if (!submission) return;
|
|
950
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
951
|
+
this._submission = {
|
|
952
|
+
...submission,
|
|
953
|
+
attachments: submission.attachments.map((attachment) => {
|
|
954
|
+
if (attachment.id !== attachmentId || isAttachmentComplete(attachment))
|
|
955
|
+
return attachment;
|
|
956
|
+
const failed = this._attachmentSends.transfer(attachment, {
|
|
957
|
+
...attachment,
|
|
958
|
+
status: { type: "incomplete", reason: "error", message },
|
|
959
|
+
});
|
|
960
|
+
this._attachmentSends.markRemoved(failed);
|
|
961
|
+
return failed;
|
|
962
|
+
}),
|
|
963
|
+
};
|
|
964
|
+
this._notifySubscribers();
|
|
965
|
+
}
|
|
966
|
+
|
|
619
967
|
private _dictation: DictationState | undefined;
|
|
620
968
|
private _dictationSession: DictationAdapter.Session | undefined;
|
|
621
969
|
private _dictationUnsubscribes: Unsubscribe[] = [];
|
|
@@ -677,71 +1025,118 @@ export abstract class BaseComposerRuntimeCore
|
|
|
677
1025
|
const sessionId = ++this._dictationSessionIdCounter;
|
|
678
1026
|
this._activeDictationSessionId = sessionId;
|
|
679
1027
|
this._dictation = { status: session.status, inputDisabled };
|
|
680
|
-
|
|
1028
|
+
try {
|
|
1029
|
+
this._notifySubscribers();
|
|
1030
|
+
} catch (notifyError) {
|
|
1031
|
+
console.error(
|
|
1032
|
+
"[assistant-ui] Dictation start notification threw",
|
|
1033
|
+
notifyError,
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
681
1036
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
this._dictationBaseText =
|
|
694
|
-
this._dictationBaseText + separator + result.transcript;
|
|
695
|
-
this._currentInterimText = "";
|
|
696
|
-
this._text = this._dictationBaseText;
|
|
697
|
-
|
|
698
|
-
if (this._dictation) {
|
|
699
|
-
const { transcript: _, ...rest } = this._dictation;
|
|
700
|
-
this._dictation = rest;
|
|
701
|
-
}
|
|
702
|
-
this._notifySubscribers();
|
|
703
|
-
} else {
|
|
704
|
-
this._currentInterimText = separator + result.transcript;
|
|
705
|
-
this._text = this._dictationBaseText + this._currentInterimText;
|
|
706
|
-
|
|
707
|
-
if (this._dictation) {
|
|
708
|
-
this._dictation = {
|
|
709
|
-
...this._dictation,
|
|
710
|
-
transcript: result.transcript,
|
|
711
|
-
};
|
|
1037
|
+
if (!this._isActiveSession(sessionId, session)) return;
|
|
1038
|
+
|
|
1039
|
+
// Handles stay local because cleanup can run synchronously during setup
|
|
1040
|
+
// and would drain the shared list before the remaining handles exist.
|
|
1041
|
+
const setupUnsubscribes: Unsubscribe[] = [];
|
|
1042
|
+
const releaseSetup = () => {
|
|
1043
|
+
for (const unsubscribe of setupUnsubscribes.splice(0)) {
|
|
1044
|
+
try {
|
|
1045
|
+
unsubscribe();
|
|
1046
|
+
} catch (cleanupError) {
|
|
1047
|
+
console.error("[assistant-ui] Dictation cleanup threw", cleanupError);
|
|
712
1048
|
}
|
|
713
|
-
this._notifySubscribers();
|
|
714
1049
|
}
|
|
715
|
-
}
|
|
716
|
-
|
|
1050
|
+
};
|
|
1051
|
+
const keepUnsubscribe = (unsubscribe: Unsubscribe) => {
|
|
1052
|
+
setupUnsubscribes.push(unsubscribe);
|
|
1053
|
+
if (this._isActiveSession(sessionId, session)) return true;
|
|
1054
|
+
releaseSetup();
|
|
1055
|
+
return false;
|
|
1056
|
+
};
|
|
717
1057
|
|
|
718
|
-
|
|
719
|
-
|
|
1058
|
+
try {
|
|
1059
|
+
const unsubSpeech = session.onSpeech((result) => {
|
|
1060
|
+
if (!this._isActiveSession(sessionId, session)) return;
|
|
1061
|
+
const isFinal = result.isFinal !== false;
|
|
1062
|
+
|
|
1063
|
+
const needsSeparator =
|
|
1064
|
+
this._dictationBaseText &&
|
|
1065
|
+
!this._dictationBaseText.endsWith(" ") &&
|
|
1066
|
+
result.transcript;
|
|
1067
|
+
const separator = needsSeparator ? " " : "";
|
|
1068
|
+
|
|
1069
|
+
if (isFinal) {
|
|
1070
|
+
this._dictationBaseText =
|
|
1071
|
+
this._dictationBaseText + separator + result.transcript;
|
|
1072
|
+
this._currentInterimText = "";
|
|
1073
|
+
this._text = this._dictationBaseText;
|
|
1074
|
+
|
|
1075
|
+
if (this._dictation) {
|
|
1076
|
+
const { transcript: _, ...rest } = this._dictation;
|
|
1077
|
+
this._dictation = rest;
|
|
1078
|
+
}
|
|
1079
|
+
this._notifySubscribers();
|
|
1080
|
+
} else {
|
|
1081
|
+
this._currentInterimText = separator + result.transcript;
|
|
1082
|
+
this._text = this._dictationBaseText + this._currentInterimText;
|
|
1083
|
+
|
|
1084
|
+
if (this._dictation) {
|
|
1085
|
+
this._dictation = {
|
|
1086
|
+
...this._dictation,
|
|
1087
|
+
transcript: result.transcript,
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
this._notifySubscribers();
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
if (!keepUnsubscribe(unsubSpeech)) return;
|
|
1094
|
+
|
|
1095
|
+
const unsubStart = session.onSpeechStart(() => {
|
|
1096
|
+
if (!this._isActiveSession(sessionId, session)) return;
|
|
1097
|
+
|
|
1098
|
+
this._dictation = {
|
|
1099
|
+
status: { type: "running" },
|
|
1100
|
+
inputDisabled,
|
|
1101
|
+
...(this._dictation?.transcript && {
|
|
1102
|
+
transcript: this._dictation.transcript,
|
|
1103
|
+
}),
|
|
1104
|
+
};
|
|
1105
|
+
this._notifySubscribers();
|
|
1106
|
+
});
|
|
1107
|
+
if (!keepUnsubscribe(unsubStart)) return;
|
|
720
1108
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
transcript: this._dictation.transcript,
|
|
726
|
-
}),
|
|
727
|
-
};
|
|
728
|
-
this._notifySubscribers();
|
|
729
|
-
});
|
|
730
|
-
this._dictationUnsubscribes.push(unsubStart);
|
|
1109
|
+
const unsubEnd = session.onSpeechEnd(() => {
|
|
1110
|
+
this._cleanupDictation({ sessionId });
|
|
1111
|
+
});
|
|
1112
|
+
if (!keepUnsubscribe(unsubEnd)) return;
|
|
731
1113
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
});
|
|
735
|
-
this._dictationUnsubscribes.push(unsubEnd);
|
|
1114
|
+
const statusInterval = setInterval(() => {
|
|
1115
|
+
if (!this._isActiveSession(sessionId, session)) return;
|
|
736
1116
|
|
|
737
|
-
|
|
738
|
-
|
|
1117
|
+
if (session.status.type === "ended") {
|
|
1118
|
+
this._cleanupDictation({ sessionId });
|
|
1119
|
+
}
|
|
1120
|
+
}, 100);
|
|
1121
|
+
if (!keepUnsubscribe(() => clearInterval(statusInterval))) return;
|
|
739
1122
|
|
|
740
|
-
|
|
741
|
-
|
|
1123
|
+
this._dictationUnsubscribes.push(...setupUnsubscribes.splice(0));
|
|
1124
|
+
} catch (error) {
|
|
1125
|
+
releaseSetup();
|
|
1126
|
+
if (this._isActiveSession(sessionId, session)) {
|
|
1127
|
+
try {
|
|
1128
|
+
session.cancel();
|
|
1129
|
+
} catch (cancelError) {
|
|
1130
|
+
console.error(
|
|
1131
|
+
"[assistant-ui] Dictation session cancel threw",
|
|
1132
|
+
cancelError,
|
|
1133
|
+
);
|
|
1134
|
+
} finally {
|
|
1135
|
+
this._cleanupDictation({ sessionId });
|
|
1136
|
+
}
|
|
742
1137
|
}
|
|
743
|
-
|
|
744
|
-
|
|
1138
|
+
throw error;
|
|
1139
|
+
}
|
|
745
1140
|
}
|
|
746
1141
|
|
|
747
1142
|
public stopDictation(): void {
|