@assistant-ui/core 0.3.20 → 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 +42 -34
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +51 -21
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +1 -3
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +6 -7
- 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 +57 -58
- 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 +14 -16
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +54 -51
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +7 -9
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +46 -40
- 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 +0 -2
- 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 +19 -21
- 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 +27 -28
- 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 +19 -21
- 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 +42 -29
- 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 +6 -8
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +14 -16
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +13 -14
- package/dist/model-context/tool-call-text.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +10 -11
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +32 -34
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +6 -8
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +23 -25
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +2 -5
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +24 -18
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +58 -25
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -4
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +5 -7
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -3
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts +6 -8
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +2 -4
- 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 +32 -34
- 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 +9 -11
- 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 -10
- 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 +1 -3
- 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 -8
- 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 +33 -36
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +6 -8
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useInteractableState.d.ts +6 -7
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -13
- 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 +11 -13
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +12 -4
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts +0 -2
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts +0 -2
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +23 -25
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +4 -6
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +4 -6
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +4 -6
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +3 -4
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts +0 -2
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +37 -24
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +2 -5
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +5 -7
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +2 -5
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +8 -11
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +11 -13
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +2 -3
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +2 -4
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +37 -36
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableState.d.ts +10 -8
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +3 -5
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +5 -6
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +6 -8
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +4 -6
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +2 -4
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +2 -4
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +3 -5
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts +2 -4
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +2 -4
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +3 -5
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -3
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts +2 -4
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts +4 -6
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts +0 -2
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts +2 -4
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +6 -8
- 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 +0 -2
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +0 -2
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +2 -4
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +0 -2
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +5 -7
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +25 -26
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +22 -23
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +10 -9
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +11 -14
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +26 -28
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +16 -6
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +26 -23
- 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 +120 -117
- 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 +199 -185
- 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 +6 -8
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -4
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +13 -15
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +54 -56
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +20 -21
- 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 +22 -23
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +4 -6
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +3 -5
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +3 -5
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +2 -4
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +2 -4
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +2 -4
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +2 -4
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -4
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +5 -7
- 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 +2 -4
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +3 -5
- 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 +3 -5
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +3 -6
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +209 -219
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +53 -39
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +185 -196
- 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 +14 -19
- 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 +8 -9
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +9 -11
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +4 -5
- 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 +7 -9
- 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 +106 -100
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +3 -5
- 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 +2 -4
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -3
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +5 -7
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +410 -213
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +14 -16
- 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 +136 -123
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +60 -9
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +9 -10
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +4 -5
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +1 -3
- 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 +2 -4
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +8 -9
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +14 -17
- 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 +11 -13
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +14 -18
- 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 +2 -4
- 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 +1 -3
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +26 -37
- 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 +2 -4
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +1 -3
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +3 -5
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +46 -43
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +8 -11
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +50 -49
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +17 -19
- 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 +5 -6
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +28 -29
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +1 -3
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +2 -4
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +26 -28
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +46 -43
- 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 +31 -30
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +207 -193
- 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 +28 -26
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +22 -0
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +87 -84
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +1 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts +48 -50
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +64 -66
- 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 +73 -76
- 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 +299 -300
- 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 +8 -10
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +149 -99
- 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 +120 -108
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +109 -41
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +29 -29
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +10 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +27 -29
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +21 -6
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +14 -16
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +7 -9
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +88 -72
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +63 -65
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +210 -197
- 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 +35 -37
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +29 -31
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +1 -1
- package/dist/runtime/queue/queue-item.d.ts +5 -7
- package/dist/runtime/queue/queue-item.d.ts.map +1 -1
- package/dist/runtime/utils/abortable-thread-load.d.ts +7 -8
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.d.ts +13 -11
- 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 +4 -5
- 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 +26 -27
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +32 -32
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +3 -3
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +2 -4
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +21 -23
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +50 -51
- 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 +10 -11
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +6 -8
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +4 -6
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.d.ts +5 -5
- package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.js +22 -2
- package/dist/runtime/utils/stored-message-parts.js.map +1 -1
- package/dist/runtime/utils/streaming-timing.d.ts +19 -21
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +36 -32
- 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 +4 -5
- 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 +6 -8
- 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 +0 -2
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +215 -198
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +5 -6
- 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 +1 -3
- 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 +38 -40
- 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 +117 -124
- 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 +44 -14
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +3 -5
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +94 -95
- 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 +6 -8
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +40 -42
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +40 -42
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +93 -97
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +178 -31
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +1 -3
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +76 -53
- 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 +11 -13
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +2 -4
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -3
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +33 -29
- 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 +44 -46
- 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 +25 -26
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +3 -5
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +111 -112
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +144 -145
- 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 +7 -9
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/external-thread.d.ts +53 -54
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +1256 -731
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -3
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +2 -4
- 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 +1 -3
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts +3 -4
- 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 +5 -7
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +10 -9
- 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 +0 -2
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +4 -6
- package/dist/store/clients/thread-tasks.d.ts.map +1 -1
- package/dist/store/env.d.ts +0 -2
- 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 +3 -4
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +9 -4
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +3 -5
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +10 -12
- 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 +0 -2
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +0 -2
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +1 -3
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +3 -5
- 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 +9 -9
- 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 +4 -6
- 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 +5 -7
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +3 -5
- 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 +2 -4
- 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 +15 -17
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +28 -29
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +141 -128
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +114 -107
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +7 -9
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +49 -45
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +18 -20
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts +10 -12
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +13 -15
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +23 -25
- package/dist/store/scopes/task.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +63 -65
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +192 -194
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +45 -47
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +58 -53
- 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 +26 -27
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/augmentations.d.ts +4 -4
- package/dist/types/augmentations.d.ts.map +1 -1
- package/dist/types/directive.d.ts +11 -13
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +7 -8
- 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 +322 -284
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts +2 -4
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +8 -10
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts +0 -2
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +0 -2
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +8 -11
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +10 -12
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +17 -18
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/id.d.ts +0 -2
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/image-media-type.d.ts +0 -2
- package/dist/utils/image-media-type.d.ts.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +0 -2
- package/dist/utils/invoke-user-callback.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +0 -2
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +1 -3
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +1 -3
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.d.ts +2 -3
- 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 +1 -2
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/record.d.ts +0 -2
- package/dist/utils/record.d.ts.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +0 -2
- package/dist/utils/silent-runtime-action.d.ts.map +1 -1
- package/dist/utils/text.d.ts +1 -3
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/wire-media.d.ts +0 -2
- package/dist/utils/wire-media.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/adapters/attachment.test.ts +98 -1
- package/src/adapters/attachment.ts +70 -20
- 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 +61 -0
- 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/adapters/LocalStorageThreadListAdapter.test.ts +594 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +98 -35
- package/src/react/client/Interactables.test.ts +853 -1
- package/src/react/client/Interactables.ts +325 -45
- package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
- 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 +212 -1
- package/src/react/interactables-legacy/Interactables.ts +25 -14
- package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
- 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 +124 -8
- package/src/react/primitives/generativeUI/GenerativeUI.tsx +35 -15
- 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 +151 -7
- 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/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.running.test.tsx +93 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +160 -3
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +38 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +73 -53
- 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-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 +42 -0
- 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 +361 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +571 -216
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +25 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
- package/src/react/runtimes/cloud/auiV0.ts +158 -9
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +352 -1
- package/src/react/runtimes/createMessageConverter.ts +9 -3
- package/src/react/runtimes/external-store-history-copy.ts +223 -0
- package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +76 -1
- 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/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 +40 -0
- package/src/runtime/api/message-runtime.test.ts +112 -2
- package/src/runtime/api/message-runtime.ts +10 -5
- 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 +744 -9
- package/src/runtime/base/base-thread-runtime-core.ts +154 -27
- package/src/runtime/base/default-edit-composer-runtime-core.ts +13 -1
- package/src/runtime/base/default-thread-composer-runtime-core.ts +29 -10
- package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +22 -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 +48 -0
- package/src/runtime/utils/external-message-conversion.ts +3 -4
- 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 +43 -1
- package/src/runtime/utils/thread-message-like.test.ts +58 -0
- package/src/runtime/utils/thread-message-like.ts +72 -46
- 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 +22 -1
- 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 +76 -29
- 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 +1649 -108
- package/src/runtimes/local/local-thread-runtime-core.ts +301 -47
- 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 +635 -131
- 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 +103 -0
- package/src/store/primitive-predicates.ts +15 -3
- 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 +138 -5
- 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 +8 -0
- package/src/store/scopes/part.ts +8 -0
- package/src/subscribable/subscribable.test.ts +198 -1
- package/src/subscribable/subscribable.ts +49 -7
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
- package/src/tests/auiV0Encode.test.ts +408 -1
- package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
- package/src/tests/base-composer-runtime-core.test.ts +196 -0
- package/src/tests/composer-can-send.test.ts +98 -1
- package/src/tests/composer-submission.test.tsx +796 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +102 -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 +581 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +186 -0
- package/src/tests/external-thread-attachments.test.tsx +741 -3
- package/src/tests/external-thread-isLast.test.tsx +69 -0
- package/src/tests/get-thread-state-isRunning.test.ts +2 -2
- package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
- package/src/types/message.ts +49 -2
- package/src/utils/normalizePartStatus.ts +14 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -15
- 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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { AssistantCloud } from "assistant-cloud";
|
|
3
|
+
import { CloudFileAttachmentAdapter } from "../react/runtimes/cloud/CloudFileAttachmentAdapter";
|
|
2
4
|
import { DefaultThreadComposerRuntimeCore } from "../runtime/base/default-thread-composer-runtime-core";
|
|
3
5
|
import type { AttachmentAdapter } from "../adapters/attachment";
|
|
4
6
|
import type { ThreadRuntimeCore } from "../runtime/interfaces/thread-runtime-core";
|
|
@@ -42,30 +44,59 @@ const makeComposer = (adapter?: AttachmentAdapter, append = vi.fn()) => {
|
|
|
42
44
|
|
|
43
45
|
const textFile = () => new File(["content"], "f.txt", { type: "text/plain" });
|
|
44
46
|
|
|
47
|
+
const deferred = () => {
|
|
48
|
+
let resolve!: () => void;
|
|
49
|
+
let reject!: (reason: unknown) => void;
|
|
50
|
+
const promise = new Promise<void>((res, rej) => {
|
|
51
|
+
resolve = res;
|
|
52
|
+
reject = rej;
|
|
53
|
+
});
|
|
54
|
+
return { promise, resolve, reject };
|
|
55
|
+
};
|
|
56
|
+
|
|
45
57
|
describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
46
|
-
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
vi.restoreAllMocks();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("takes text, attachments, and quote back when an upload fails", async () => {
|
|
47
63
|
const adapter = makeAdapter({
|
|
48
64
|
send: async () => {
|
|
49
65
|
throw new Error("upload failed");
|
|
50
66
|
},
|
|
51
67
|
});
|
|
52
68
|
const { composer, append } = makeComposer(adapter);
|
|
69
|
+
const consoleError = vi
|
|
70
|
+
.spyOn(console, "error")
|
|
71
|
+
.mockImplementation(() => {});
|
|
53
72
|
|
|
54
73
|
composer.setText("hello");
|
|
55
74
|
await composer.addAttachment(textFile());
|
|
56
75
|
composer.setQuote({ text: "quoted", messageId: "m-1" });
|
|
57
76
|
const originalAttachments = composer.attachments;
|
|
58
77
|
|
|
59
|
-
await expect(composer.send()).
|
|
78
|
+
await expect(composer.send()).resolves.toBeUndefined();
|
|
60
79
|
|
|
80
|
+
expect(composer.submission).toBeUndefined();
|
|
61
81
|
expect(composer.text).toBe("hello");
|
|
62
|
-
expect(composer.attachments).toEqual(originalAttachments);
|
|
63
82
|
expect(composer.attachments).toHaveLength(1);
|
|
83
|
+
expect(composer.attachments[0]).toMatchObject({
|
|
84
|
+
...originalAttachments[0],
|
|
85
|
+
status: {
|
|
86
|
+
type: "incomplete",
|
|
87
|
+
reason: "error",
|
|
88
|
+
message: "upload failed",
|
|
89
|
+
},
|
|
90
|
+
});
|
|
64
91
|
expect(composer.quote).toEqual({ text: "quoted", messageId: "m-1" });
|
|
65
92
|
expect(append).not.toHaveBeenCalled();
|
|
93
|
+
expect(consoleError).toHaveBeenCalledWith(
|
|
94
|
+
"[assistant-ui] Failed to send attachments",
|
|
95
|
+
expect.objectContaining({ message: "upload failed" }),
|
|
96
|
+
);
|
|
66
97
|
});
|
|
67
98
|
|
|
68
|
-
it("
|
|
99
|
+
it("merges text typed while a failed upload was in flight", async () => {
|
|
69
100
|
let rejectSend!: (e: Error) => void;
|
|
70
101
|
const adapter = makeAdapter({
|
|
71
102
|
send: () =>
|
|
@@ -82,14 +113,19 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
82
113
|
composer.setText("new draft");
|
|
83
114
|
rejectSend(new Error("upload failed"));
|
|
84
115
|
|
|
85
|
-
await expect(sendPromise).
|
|
116
|
+
await expect(sendPromise).resolves.toBeUndefined();
|
|
86
117
|
|
|
87
|
-
expect(composer.text).toBe("
|
|
118
|
+
expect(composer.text).toBe("hello\nnew draft");
|
|
88
119
|
expect(composer.attachments).toHaveLength(1);
|
|
120
|
+
expect(composer.attachments[0]?.status).toEqual({
|
|
121
|
+
type: "incomplete",
|
|
122
|
+
reason: "error",
|
|
123
|
+
message: "upload failed",
|
|
124
|
+
});
|
|
89
125
|
expect(append).not.toHaveBeenCalled();
|
|
90
126
|
});
|
|
91
127
|
|
|
92
|
-
it("
|
|
128
|
+
it("keeps a quote set while a failed upload returns to the draft", async () => {
|
|
93
129
|
let rejectSend!: (e: Error) => void;
|
|
94
130
|
const adapter = makeAdapter({
|
|
95
131
|
send: () =>
|
|
@@ -106,11 +142,16 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
106
142
|
composer.setQuote({ text: "new quote", messageId: "m-2" });
|
|
107
143
|
rejectSend(new Error("upload failed"));
|
|
108
144
|
|
|
109
|
-
await expect(sendPromise).
|
|
145
|
+
await expect(sendPromise).resolves.toBeUndefined();
|
|
110
146
|
|
|
111
147
|
expect(composer.quote).toEqual({ text: "new quote", messageId: "m-2" });
|
|
112
|
-
expect(composer.text).toBe("");
|
|
148
|
+
expect(composer.text).toBe("hello");
|
|
113
149
|
expect(composer.attachments).toHaveLength(1);
|
|
150
|
+
expect(composer.attachments[0]?.status).toEqual({
|
|
151
|
+
type: "incomplete",
|
|
152
|
+
reason: "error",
|
|
153
|
+
message: "upload failed",
|
|
154
|
+
});
|
|
114
155
|
expect(append).not.toHaveBeenCalled();
|
|
115
156
|
});
|
|
116
157
|
|
|
@@ -131,7 +172,7 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
131
172
|
expect(message.attachments[0].status).toEqual({ type: "complete" });
|
|
132
173
|
});
|
|
133
174
|
|
|
134
|
-
it("keeps
|
|
175
|
+
it("keeps sent attachments on the submission until the upload resolves", async () => {
|
|
135
176
|
let resolveSend!: () => void;
|
|
136
177
|
const adapter = makeAdapter({
|
|
137
178
|
send: (a) =>
|
|
@@ -149,7 +190,12 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
149
190
|
await Promise.resolve();
|
|
150
191
|
|
|
151
192
|
expect(composer.text).toBe("");
|
|
152
|
-
expect(composer.attachments).toHaveLength(
|
|
193
|
+
expect(composer.attachments).toHaveLength(0);
|
|
194
|
+
expect(composer.submission).toMatchObject({
|
|
195
|
+
role: "user",
|
|
196
|
+
text: "hello",
|
|
197
|
+
attachments: [expect.objectContaining({ id: "att-1" })],
|
|
198
|
+
});
|
|
153
199
|
expect(append).not.toHaveBeenCalled();
|
|
154
200
|
|
|
155
201
|
resolveSend();
|
|
@@ -296,23 +342,248 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
296
342
|
await composer.addAttachment(new File(["b"], "b.txt"));
|
|
297
343
|
|
|
298
344
|
const sendPromise = composer.send();
|
|
299
|
-
const caught = sendPromise.catch(() => {});
|
|
300
345
|
|
|
301
|
-
// b's rejection has already surfaced from Promise.all, but a's upload is
|
|
302
|
-
// still running — sending must stay blocked so a retry can't fire a second
|
|
303
|
-
// adapter.send for the attachment that's still in flight.
|
|
304
346
|
await Promise.resolve();
|
|
305
347
|
await Promise.resolve();
|
|
306
348
|
await Promise.resolve();
|
|
307
349
|
expect(composer.canSend).toBe(false);
|
|
308
350
|
|
|
309
351
|
resolveA();
|
|
310
|
-
await
|
|
352
|
+
await sendPromise;
|
|
311
353
|
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
312
354
|
expect(sendCallsForA).toBe(1);
|
|
313
355
|
});
|
|
314
356
|
|
|
315
|
-
it("
|
|
357
|
+
it.each(["before", "after"])(
|
|
358
|
+
"reuses completed attachments when a sibling fails %s they finish",
|
|
359
|
+
async (failureOrder) => {
|
|
360
|
+
const successfulUpload = deferred();
|
|
361
|
+
const failedUpload = deferred();
|
|
362
|
+
const error = new Error("temporary upload failure");
|
|
363
|
+
const send = vi.fn(async (attachment: PendingAttachment) => {
|
|
364
|
+
if (attachment.name === "a.txt") {
|
|
365
|
+
await successfulUpload.promise;
|
|
366
|
+
} else {
|
|
367
|
+
await failedUpload.promise;
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
...attachment,
|
|
371
|
+
status: { type: "complete" as const },
|
|
372
|
+
content: [{ type: "image" as const, image: "https://example.com/a" }],
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
const adapter = makeAdapter({
|
|
376
|
+
add: async ({ file }) => ({
|
|
377
|
+
id: file.name,
|
|
378
|
+
type: "image",
|
|
379
|
+
name: file.name,
|
|
380
|
+
contentType: file.type,
|
|
381
|
+
file,
|
|
382
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
383
|
+
}),
|
|
384
|
+
send,
|
|
385
|
+
});
|
|
386
|
+
const { composer, append } = makeComposer(adapter);
|
|
387
|
+
await composer.addAttachment(new File(["a"], "a.txt"));
|
|
388
|
+
await composer.addAttachment(new File(["b"], "b.txt"));
|
|
389
|
+
const original = composer.attachments;
|
|
390
|
+
composer.setText("hello");
|
|
391
|
+
|
|
392
|
+
const sending = composer.send();
|
|
393
|
+
if (failureOrder === "after") {
|
|
394
|
+
successfulUpload.resolve();
|
|
395
|
+
await successfulUpload.promise;
|
|
396
|
+
}
|
|
397
|
+
failedUpload.reject(error);
|
|
398
|
+
if (failureOrder === "before") {
|
|
399
|
+
expect(composer.canSend).toBe(false);
|
|
400
|
+
expect(composer.submission?.attachments).toEqual(original);
|
|
401
|
+
successfulUpload.resolve();
|
|
402
|
+
}
|
|
403
|
+
await expect(sending).resolves.toBeUndefined();
|
|
404
|
+
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
405
|
+
|
|
406
|
+
expect(composer.attachments[0]).toBe(original[0]);
|
|
407
|
+
expect(composer.attachments[1]).toMatchObject({
|
|
408
|
+
id: "b.txt",
|
|
409
|
+
status: {
|
|
410
|
+
type: "incomplete",
|
|
411
|
+
reason: "error",
|
|
412
|
+
message: "temporary upload failure",
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
send.mockImplementation(async (attachment) => {
|
|
416
|
+
if (attachment.name === "a.txt") throw new Error("Already consumed");
|
|
417
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
418
|
+
});
|
|
419
|
+
await composer.send();
|
|
420
|
+
|
|
421
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
422
|
+
"a.txt",
|
|
423
|
+
"b.txt",
|
|
424
|
+
"b.txt",
|
|
425
|
+
]);
|
|
426
|
+
expect(append).toHaveBeenCalledOnce();
|
|
427
|
+
expect(append.mock.calls[0]![0]).toMatchObject({
|
|
428
|
+
content: [{ type: "text", text: "hello" }],
|
|
429
|
+
attachments: [
|
|
430
|
+
{
|
|
431
|
+
id: "a.txt",
|
|
432
|
+
content: [{ type: "image", image: "https://example.com/a" }],
|
|
433
|
+
},
|
|
434
|
+
{ id: "b.txt", status: { type: "complete" } },
|
|
435
|
+
],
|
|
436
|
+
});
|
|
437
|
+
expect(composer.isEmpty).toBe(true);
|
|
438
|
+
},
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
it.each(["remove", "clear", "reset"])(
|
|
442
|
+
"cleans up retained uploads when a failed draft is discarded with %s",
|
|
443
|
+
async (action) => {
|
|
444
|
+
const remove = vi.fn(async () => {});
|
|
445
|
+
const adapter = makeAdapter({
|
|
446
|
+
add: async ({ file }) => ({
|
|
447
|
+
id: file.name,
|
|
448
|
+
type: "file",
|
|
449
|
+
name: file.name,
|
|
450
|
+
file,
|
|
451
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
452
|
+
}),
|
|
453
|
+
remove,
|
|
454
|
+
send: async (attachment) => {
|
|
455
|
+
if (attachment.id === "b") throw new Error("upload failed");
|
|
456
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
const { composer, append } = makeComposer(adapter);
|
|
460
|
+
await composer.addAttachment(new File(["a"], "a"));
|
|
461
|
+
await composer.addAttachment(new File(["b"], "b"));
|
|
462
|
+
const original = composer.attachments[0];
|
|
463
|
+
await expect(composer.send()).resolves.toBeUndefined();
|
|
464
|
+
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
465
|
+
|
|
466
|
+
if (action === "remove") await composer.removeAttachment("a");
|
|
467
|
+
else if (action === "clear") await composer.clearAttachments();
|
|
468
|
+
else await composer.reset();
|
|
469
|
+
|
|
470
|
+
expect(remove).toHaveBeenCalledWith(original);
|
|
471
|
+
expect(append).not.toHaveBeenCalled();
|
|
472
|
+
},
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
it.each(["before", "after"])(
|
|
476
|
+
"reuses an upload when removal fails %s it settles",
|
|
477
|
+
async (order) => {
|
|
478
|
+
const upload = deferred();
|
|
479
|
+
const send = vi.fn(async (attachment: PendingAttachment) => {
|
|
480
|
+
if (attachment.name === "b") throw new Error("upload failed");
|
|
481
|
+
await upload.promise;
|
|
482
|
+
return {
|
|
483
|
+
...attachment,
|
|
484
|
+
status: { type: "complete" as const },
|
|
485
|
+
content: [],
|
|
486
|
+
};
|
|
487
|
+
});
|
|
488
|
+
const { composer, append } = makeComposer(
|
|
489
|
+
makeAdapter({
|
|
490
|
+
add: async ({ file }) => ({
|
|
491
|
+
id: file.name,
|
|
492
|
+
type: "file",
|
|
493
|
+
name: file.name,
|
|
494
|
+
file,
|
|
495
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
496
|
+
}),
|
|
497
|
+
remove: async () => {
|
|
498
|
+
throw new Error("remove failed");
|
|
499
|
+
},
|
|
500
|
+
send,
|
|
501
|
+
}),
|
|
502
|
+
);
|
|
503
|
+
await composer.addAttachment(new File(["a"], "a"));
|
|
504
|
+
await composer.addAttachment(new File(["b"], "b"));
|
|
505
|
+
const sending = composer.send();
|
|
506
|
+
if (order === "before") {
|
|
507
|
+
await expect(composer.removeAttachment("a")).rejects.toThrow(
|
|
508
|
+
"remove failed",
|
|
509
|
+
);
|
|
510
|
+
upload.resolve();
|
|
511
|
+
} else {
|
|
512
|
+
upload.resolve();
|
|
513
|
+
await sending;
|
|
514
|
+
await expect(composer.removeAttachment("a")).rejects.toThrow(
|
|
515
|
+
"remove failed",
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
if (order === "after") {
|
|
519
|
+
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
520
|
+
}
|
|
521
|
+
await sending;
|
|
522
|
+
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
523
|
+
send.mockImplementation(async (attachment) => {
|
|
524
|
+
if (attachment.name === "a") throw new Error("Already consumed");
|
|
525
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
526
|
+
});
|
|
527
|
+
await composer.send();
|
|
528
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
529
|
+
"a",
|
|
530
|
+
"b",
|
|
531
|
+
"b",
|
|
532
|
+
]);
|
|
533
|
+
expect(append).toHaveBeenCalledOnce();
|
|
534
|
+
},
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
it.each(["remove", "clear", "reset"])(
|
|
538
|
+
"keeps the right attachments when %s interrupts a failed send",
|
|
539
|
+
async (action) => {
|
|
540
|
+
const upload = deferred();
|
|
541
|
+
const removal = deferred();
|
|
542
|
+
const adapter = makeAdapter({
|
|
543
|
+
add: async ({ file }) => ({
|
|
544
|
+
id: file.name,
|
|
545
|
+
type: "image",
|
|
546
|
+
name: file.name,
|
|
547
|
+
contentType: file.type,
|
|
548
|
+
file,
|
|
549
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
550
|
+
}),
|
|
551
|
+
remove: () => removal.promise,
|
|
552
|
+
send: async (attachment) => {
|
|
553
|
+
if (attachment.name === "b.txt") throw new Error("upload failed");
|
|
554
|
+
await upload.promise;
|
|
555
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
556
|
+
},
|
|
557
|
+
});
|
|
558
|
+
const { composer, append } = makeComposer(adapter);
|
|
559
|
+
await composer.addAttachment(new File(["a"], "a.txt"));
|
|
560
|
+
await composer.addAttachment(new File(["b"], "b.txt"));
|
|
561
|
+
const sending = composer.send();
|
|
562
|
+
const cleanup =
|
|
563
|
+
action === "remove"
|
|
564
|
+
? composer.removeAttachment("a.txt")
|
|
565
|
+
: action === "clear"
|
|
566
|
+
? composer.clearAttachments()
|
|
567
|
+
: composer.reset();
|
|
568
|
+
const newId = action === "remove" ? "later" : "a.txt";
|
|
569
|
+
await composer.addAttachment({ id: newId, name: "later", content: [] });
|
|
570
|
+
upload.resolve();
|
|
571
|
+
await sending;
|
|
572
|
+
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
573
|
+
removal.resolve();
|
|
574
|
+
await cleanup;
|
|
575
|
+
expect(composer.attachments.map((attachment) => attachment.id)).toEqual(
|
|
576
|
+
action === "clear"
|
|
577
|
+
? ["a.txt", "b.txt", newId]
|
|
578
|
+
: action === "remove"
|
|
579
|
+
? ["b.txt", newId]
|
|
580
|
+
: [newId],
|
|
581
|
+
);
|
|
582
|
+
expect(append).not.toHaveBeenCalled();
|
|
583
|
+
},
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
it("keeps the submission until a failed batch's stragglers settle", async () => {
|
|
316
587
|
let resolveA!: () => void;
|
|
317
588
|
const adapter = makeAdapter({
|
|
318
589
|
add: async ({ file }: { file: File }): Promise<PendingAttachment> => ({
|
|
@@ -340,13 +611,16 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
340
611
|
await composer.addAttachment(new File(["b"], "b.txt"));
|
|
341
612
|
|
|
342
613
|
const sendPromise = composer.send();
|
|
343
|
-
await expect(sendPromise).rejects.toThrow("b failed");
|
|
344
614
|
|
|
345
|
-
|
|
615
|
+
await Promise.resolve();
|
|
616
|
+
expect(composer.submission).toMatchObject({ text: "hello" });
|
|
617
|
+
expect(composer.text).toBe("");
|
|
346
618
|
expect(composer.canSend).toBe(false);
|
|
347
619
|
|
|
348
620
|
resolveA();
|
|
621
|
+
await sendPromise;
|
|
349
622
|
await vi.waitFor(() => expect(composer.canSend).toBe(true));
|
|
623
|
+
expect(composer.text).toBe("hello");
|
|
350
624
|
});
|
|
351
625
|
|
|
352
626
|
it("excludes a removed attachment even when the upload settles before the adapter remove", async () => {
|
|
@@ -380,15 +654,15 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
380
654
|
await removePromise;
|
|
381
655
|
});
|
|
382
656
|
|
|
383
|
-
it("
|
|
657
|
+
it("keeps in-flight attachments when clearing the draft", async () => {
|
|
384
658
|
const upload = Promise.withResolvers<void>();
|
|
385
|
-
const
|
|
659
|
+
const remove = vi.fn(async () => {});
|
|
386
660
|
const adapter = makeAdapter({
|
|
387
661
|
send: async (attachment) => {
|
|
388
662
|
await upload.promise;
|
|
389
663
|
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
390
664
|
},
|
|
391
|
-
remove
|
|
665
|
+
remove,
|
|
392
666
|
});
|
|
393
667
|
const core = new LocalRuntimeCore(
|
|
394
668
|
{
|
|
@@ -412,6 +686,7 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
412
686
|
const sendPromise = composer.send({ startRun: false });
|
|
413
687
|
const clearPromise = composer.clearAttachments();
|
|
414
688
|
expect(composer.attachments).toEqual([]);
|
|
689
|
+
expect(composer.submission?.attachments).toHaveLength(2);
|
|
415
690
|
await composer.addAttachment({
|
|
416
691
|
id: "later",
|
|
417
692
|
name: "later.txt",
|
|
@@ -421,13 +696,16 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
421
696
|
await sendPromise;
|
|
422
697
|
|
|
423
698
|
expect(thread.messages).toMatchObject([
|
|
424
|
-
{
|
|
699
|
+
{
|
|
700
|
+
content: [{ type: "text", text: "hello" }],
|
|
701
|
+
attachments: [{ id: "att-1" }, { id: "ready" }],
|
|
702
|
+
},
|
|
425
703
|
]);
|
|
426
704
|
expect(composer.attachments.map((attachment) => attachment.id)).toEqual([
|
|
427
705
|
"later",
|
|
428
706
|
]);
|
|
429
|
-
removal.resolve();
|
|
430
707
|
await clearPromise;
|
|
708
|
+
expect(remove).not.toHaveBeenCalled();
|
|
431
709
|
});
|
|
432
710
|
|
|
433
711
|
it("releases the in-flight lock on reset so a stalled send cannot brick the composer", async () => {
|
|
@@ -503,6 +781,78 @@ describe("BaseComposerRuntimeCore.send restore-on-failure", () => {
|
|
|
503
781
|
expect(message.attachments).toHaveLength(0);
|
|
504
782
|
});
|
|
505
783
|
|
|
784
|
+
it("keeps an attachment re-added under a removed id during an in-flight send", async () => {
|
|
785
|
+
let resolveSend!: () => void;
|
|
786
|
+
const adapter = makeAdapter({
|
|
787
|
+
send: (a) =>
|
|
788
|
+
new Promise((resolve) => {
|
|
789
|
+
resolveSend = () =>
|
|
790
|
+
resolve({ ...a, status: { type: "complete" }, content: [] });
|
|
791
|
+
}),
|
|
792
|
+
});
|
|
793
|
+
const { composer, append } = makeComposer(adapter);
|
|
794
|
+
|
|
795
|
+
composer.setText("hello");
|
|
796
|
+
await composer.addAttachment(textFile());
|
|
797
|
+
|
|
798
|
+
const sendPromise = composer.send();
|
|
799
|
+
await composer.removeAttachment("att-1");
|
|
800
|
+
await composer.addAttachment({ id: "att-1", name: "again", content: [] });
|
|
801
|
+
resolveSend();
|
|
802
|
+
await sendPromise;
|
|
803
|
+
|
|
804
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
805
|
+
expect(append.mock.calls[0]![0].attachments).toHaveLength(0);
|
|
806
|
+
expect(composer.attachments.map((a) => a.name)).toEqual(["again"]);
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
it("does not send an attachment whose removal was pending when the send started", async () => {
|
|
810
|
+
const removal = deferred();
|
|
811
|
+
const send = vi.fn(async (a: PendingAttachment) => ({
|
|
812
|
+
...a,
|
|
813
|
+
status: { type: "complete" as const },
|
|
814
|
+
content: [],
|
|
815
|
+
}));
|
|
816
|
+
const adapter = makeAdapter({ remove: () => removal.promise, send });
|
|
817
|
+
const { composer, append } = makeComposer(adapter);
|
|
818
|
+
|
|
819
|
+
composer.setText("hello");
|
|
820
|
+
await composer.addAttachment(textFile());
|
|
821
|
+
|
|
822
|
+
const removePromise = composer.removeAttachment("att-1");
|
|
823
|
+
await composer.send();
|
|
824
|
+
|
|
825
|
+
expect(send).not.toHaveBeenCalled();
|
|
826
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
827
|
+
expect(append.mock.calls[0]![0].attachments).toHaveLength(0);
|
|
828
|
+
|
|
829
|
+
removal.resolve();
|
|
830
|
+
await removePromise;
|
|
831
|
+
expect(composer.attachments).toEqual([]);
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
it("does not dispatch an empty message when the only attachment is being removed", async () => {
|
|
835
|
+
const removal = deferred();
|
|
836
|
+
const send = vi.fn(async (a: PendingAttachment) => ({
|
|
837
|
+
...a,
|
|
838
|
+
status: { type: "complete" as const },
|
|
839
|
+
content: [],
|
|
840
|
+
}));
|
|
841
|
+
const adapter = makeAdapter({ remove: () => removal.promise, send });
|
|
842
|
+
const { composer, append } = makeComposer(adapter);
|
|
843
|
+
|
|
844
|
+
await composer.addAttachment(textFile());
|
|
845
|
+
|
|
846
|
+
const removePromise = composer.removeAttachment("att-1");
|
|
847
|
+
await composer.send();
|
|
848
|
+
|
|
849
|
+
expect(send).not.toHaveBeenCalled();
|
|
850
|
+
expect(append).not.toHaveBeenCalled();
|
|
851
|
+
|
|
852
|
+
removal.resolve();
|
|
853
|
+
await removePromise;
|
|
854
|
+
});
|
|
855
|
+
|
|
506
856
|
it("sends a text-only message with no attachment adapter", async () => {
|
|
507
857
|
const { composer, append } = makeComposer();
|
|
508
858
|
|
|
@@ -700,7 +1050,7 @@ describe("BaseComposerRuntimeCore.send restore-on-undispatched", () => {
|
|
|
700
1050
|
expect(composer.text).toBe("");
|
|
701
1051
|
});
|
|
702
1052
|
|
|
703
|
-
it("
|
|
1053
|
+
it("returns the message ahead of a draft written after the send", async () => {
|
|
704
1054
|
const { append, reject } = rejectableAppend();
|
|
705
1055
|
const { composer } = makeComposer(makeAdapter(), append);
|
|
706
1056
|
|
|
@@ -709,8 +1059,8 @@ describe("BaseComposerRuntimeCore.send restore-on-undispatched", () => {
|
|
|
709
1059
|
composer.setText("new draft");
|
|
710
1060
|
reject(new MessageNotSentError());
|
|
711
1061
|
|
|
712
|
-
await vi.waitFor(() => expect(
|
|
713
|
-
expect(
|
|
1062
|
+
await vi.waitFor(() => expect(composer.text).toBe("hello\nnew draft"));
|
|
1063
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
714
1064
|
});
|
|
715
1065
|
|
|
716
1066
|
it("does not restore a draft a reset discarded", async () => {
|
|
@@ -748,11 +1098,11 @@ describe("BaseComposerRuntimeCore.send restore-on-undispatched edge cases", () =
|
|
|
748
1098
|
protected handleCancel(): void {}
|
|
749
1099
|
}
|
|
750
1100
|
|
|
751
|
-
it("restores the draft when handleSend throws synchronously", async () => {
|
|
1101
|
+
it("restores the draft when handleSend throws synchronously and resolves", async () => {
|
|
752
1102
|
const composer = new SyncThrowComposerCore();
|
|
753
1103
|
composer.setText("hello");
|
|
754
1104
|
|
|
755
|
-
await expect(composer.send()).
|
|
1105
|
+
await expect(composer.send()).resolves.toBeUndefined();
|
|
756
1106
|
|
|
757
1107
|
expect(composer.text).toBe("hello");
|
|
758
1108
|
});
|
|
@@ -772,9 +1122,352 @@ describe("BaseComposerRuntimeCore.send restore-on-undispatched edge cases", () =
|
|
|
772
1122
|
composer.setText("two");
|
|
773
1123
|
await composer.send();
|
|
774
1124
|
|
|
1125
|
+
expect(composer.submission).toBeUndefined();
|
|
1126
|
+
expect(rejects).toHaveLength(2);
|
|
775
1127
|
rejects[0]!(new MessageNotSentError());
|
|
776
1128
|
rejects[1]!(new MessageNotSentError());
|
|
777
1129
|
|
|
778
1130
|
await vi.waitFor(() => expect(composer.text).toBe("two"));
|
|
779
1131
|
});
|
|
780
1132
|
});
|
|
1133
|
+
|
|
1134
|
+
describe("BaseComposerRuntimeCore.send with an upload still running in add()", () => {
|
|
1135
|
+
afterEach(() => {
|
|
1136
|
+
vi.unstubAllGlobals();
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
const completeSend = () =>
|
|
1140
|
+
vi.fn(async (attachment: PendingAttachment) => ({
|
|
1141
|
+
...attachment,
|
|
1142
|
+
status: { type: "complete" as const },
|
|
1143
|
+
content: [],
|
|
1144
|
+
}));
|
|
1145
|
+
|
|
1146
|
+
const uploadingAdapter = (
|
|
1147
|
+
upload: Promise<void>,
|
|
1148
|
+
overrides: Partial<AttachmentAdapter> = {},
|
|
1149
|
+
) =>
|
|
1150
|
+
makeAdapter({
|
|
1151
|
+
async *add({ file }) {
|
|
1152
|
+
const attachment = {
|
|
1153
|
+
id: "att-1",
|
|
1154
|
+
type: "file",
|
|
1155
|
+
name: file.name,
|
|
1156
|
+
contentType: file.type,
|
|
1157
|
+
file,
|
|
1158
|
+
};
|
|
1159
|
+
yield {
|
|
1160
|
+
...attachment,
|
|
1161
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1162
|
+
} satisfies PendingAttachment;
|
|
1163
|
+
await upload;
|
|
1164
|
+
yield {
|
|
1165
|
+
...attachment,
|
|
1166
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1167
|
+
} satisfies PendingAttachment;
|
|
1168
|
+
},
|
|
1169
|
+
...overrides,
|
|
1170
|
+
});
|
|
1171
|
+
|
|
1172
|
+
it("waits for the upload before handing the attachment to the adapter", async () => {
|
|
1173
|
+
const upload = deferred();
|
|
1174
|
+
const send = completeSend();
|
|
1175
|
+
const { composer, append } = makeComposer(
|
|
1176
|
+
uploadingAdapter(upload.promise, { send }),
|
|
1177
|
+
);
|
|
1178
|
+
|
|
1179
|
+
composer.setText("hello");
|
|
1180
|
+
const adding = composer.addAttachment(textFile());
|
|
1181
|
+
await vi.waitFor(() =>
|
|
1182
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1183
|
+
);
|
|
1184
|
+
|
|
1185
|
+
const sendPromise = composer.send();
|
|
1186
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1187
|
+
expect(send).not.toHaveBeenCalled();
|
|
1188
|
+
expect(append).not.toHaveBeenCalled();
|
|
1189
|
+
|
|
1190
|
+
upload.resolve();
|
|
1191
|
+
await adding;
|
|
1192
|
+
await sendPromise;
|
|
1193
|
+
|
|
1194
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
1195
|
+
expect(send.mock.calls[0]![0].status).toEqual({
|
|
1196
|
+
type: "requires-action",
|
|
1197
|
+
reason: "composer-send",
|
|
1198
|
+
});
|
|
1199
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1200
|
+
expect(append.mock.calls[0]![0]).toMatchObject({
|
|
1201
|
+
content: [{ type: "text", text: "hello" }],
|
|
1202
|
+
attachments: [{ id: "att-1", status: { type: "complete" } }],
|
|
1203
|
+
});
|
|
1204
|
+
expect(composer.attachments).toEqual([]);
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
it("sends through the cloud adapter while its upload is still running", async () => {
|
|
1208
|
+
const put = Promise.withResolvers<{ ok: boolean }>();
|
|
1209
|
+
const fetchMock = vi.fn(() => put.promise);
|
|
1210
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
1211
|
+
const cloud = {
|
|
1212
|
+
files: {
|
|
1213
|
+
generatePresignedUploadUrl: vi.fn().mockResolvedValue({
|
|
1214
|
+
signedUrl: "https://storage.example/upload",
|
|
1215
|
+
publicUrl: "https://cdn.example/image.png",
|
|
1216
|
+
}),
|
|
1217
|
+
},
|
|
1218
|
+
} as unknown as AssistantCloud;
|
|
1219
|
+
const core = new LocalRuntimeCore(
|
|
1220
|
+
{
|
|
1221
|
+
adapters: {
|
|
1222
|
+
chatModel: { run: async () => ({ content: [] }) },
|
|
1223
|
+
attachments: new CloudFileAttachmentAdapter(cloud),
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
undefined,
|
|
1227
|
+
);
|
|
1228
|
+
const thread = core.threads.getMainThreadRuntimeCore();
|
|
1229
|
+
|
|
1230
|
+
thread.composer.setText("look at this");
|
|
1231
|
+
const adding = thread.composer.addAttachment(
|
|
1232
|
+
new File([new Uint8Array([1, 2, 3])], "image.png", { type: "image/png" }),
|
|
1233
|
+
);
|
|
1234
|
+
await vi.waitFor(() => expect(fetchMock).toHaveBeenCalled());
|
|
1235
|
+
|
|
1236
|
+
const sendPromise = thread.composer.send({ startRun: false });
|
|
1237
|
+
put.resolve({ ok: true });
|
|
1238
|
+
await adding;
|
|
1239
|
+
await sendPromise;
|
|
1240
|
+
|
|
1241
|
+
expect(thread.messages).toMatchObject([
|
|
1242
|
+
{
|
|
1243
|
+
content: [{ type: "text", text: "look at this" }],
|
|
1244
|
+
attachments: [
|
|
1245
|
+
{
|
|
1246
|
+
status: { type: "complete" },
|
|
1247
|
+
content: [
|
|
1248
|
+
{ type: "image", image: "https://cdn.example/image.png" },
|
|
1249
|
+
],
|
|
1250
|
+
},
|
|
1251
|
+
],
|
|
1252
|
+
},
|
|
1253
|
+
]);
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
it("drops the send when a reset lands while the upload is still running", async () => {
|
|
1257
|
+
const upload = deferred();
|
|
1258
|
+
const send = completeSend();
|
|
1259
|
+
const { composer, append } = makeComposer(
|
|
1260
|
+
uploadingAdapter(upload.promise, { send }),
|
|
1261
|
+
);
|
|
1262
|
+
|
|
1263
|
+
composer.setText("hello");
|
|
1264
|
+
const adding = composer.addAttachment(textFile());
|
|
1265
|
+
await vi.waitFor(() =>
|
|
1266
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
const sendPromise = composer.send();
|
|
1270
|
+
await composer.reset();
|
|
1271
|
+
await sendPromise;
|
|
1272
|
+
upload.resolve();
|
|
1273
|
+
await adding;
|
|
1274
|
+
|
|
1275
|
+
expect(send).not.toHaveBeenCalled();
|
|
1276
|
+
expect(append).not.toHaveBeenCalled();
|
|
1277
|
+
expect(composer.attachments).toEqual([]);
|
|
1278
|
+
expect(composer.text).toBe("");
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
it("leaves out an attachment removed while it was still uploading", async () => {
|
|
1282
|
+
const upload = deferred();
|
|
1283
|
+
const send = completeSend();
|
|
1284
|
+
const { composer, append } = makeComposer(
|
|
1285
|
+
uploadingAdapter(upload.promise, { send }),
|
|
1286
|
+
);
|
|
1287
|
+
|
|
1288
|
+
composer.setText("hello");
|
|
1289
|
+
const adding = composer.addAttachment(textFile());
|
|
1290
|
+
await vi.waitFor(() =>
|
|
1291
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1292
|
+
);
|
|
1293
|
+
|
|
1294
|
+
const sendPromise = composer.send();
|
|
1295
|
+
await composer.removeAttachment("att-1");
|
|
1296
|
+
await sendPromise;
|
|
1297
|
+
upload.resolve();
|
|
1298
|
+
await adding;
|
|
1299
|
+
|
|
1300
|
+
expect(send).not.toHaveBeenCalled();
|
|
1301
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1302
|
+
expect(append.mock.calls[0]![0]).toMatchObject({
|
|
1303
|
+
content: [{ type: "text", text: "hello" }],
|
|
1304
|
+
attachments: [],
|
|
1305
|
+
});
|
|
1306
|
+
expect(composer.attachments).toEqual([]);
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
it("keeps an attachment re-added under a removed id out of the send", async () => {
|
|
1310
|
+
const upload = deferred();
|
|
1311
|
+
const send = completeSend();
|
|
1312
|
+
const { composer, append } = makeComposer(
|
|
1313
|
+
uploadingAdapter(upload.promise, { send }),
|
|
1314
|
+
);
|
|
1315
|
+
|
|
1316
|
+
composer.setText("hello");
|
|
1317
|
+
const adding = composer.addAttachment(textFile());
|
|
1318
|
+
await vi.waitFor(() =>
|
|
1319
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1320
|
+
);
|
|
1321
|
+
|
|
1322
|
+
const sendPromise = composer.send();
|
|
1323
|
+
await composer.removeAttachment("att-1");
|
|
1324
|
+
await composer.addAttachment({ id: "att-1", name: "again", content: [] });
|
|
1325
|
+
await sendPromise;
|
|
1326
|
+
upload.resolve();
|
|
1327
|
+
await adding;
|
|
1328
|
+
|
|
1329
|
+
expect(send).not.toHaveBeenCalled();
|
|
1330
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1331
|
+
expect(append.mock.calls[0]![0]).toMatchObject({
|
|
1332
|
+
content: [{ type: "text", text: "hello" }],
|
|
1333
|
+
attachments: [],
|
|
1334
|
+
});
|
|
1335
|
+
expect(composer.attachments.map((a) => a.name)).toEqual(["again"]);
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
it("waits for the upload that took over an attachment id", async () => {
|
|
1339
|
+
const uploads = [deferred(), deferred()];
|
|
1340
|
+
let addCount = 0;
|
|
1341
|
+
const send = completeSend();
|
|
1342
|
+
const adapter = makeAdapter({
|
|
1343
|
+
async *add({ file }) {
|
|
1344
|
+
const upload = uploads[addCount++]!;
|
|
1345
|
+
const attachment = {
|
|
1346
|
+
id: file.name,
|
|
1347
|
+
type: "file",
|
|
1348
|
+
name: file.name,
|
|
1349
|
+
contentType: file.type,
|
|
1350
|
+
file,
|
|
1351
|
+
};
|
|
1352
|
+
yield {
|
|
1353
|
+
...attachment,
|
|
1354
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1355
|
+
} satisfies PendingAttachment;
|
|
1356
|
+
await upload.promise;
|
|
1357
|
+
yield {
|
|
1358
|
+
...attachment,
|
|
1359
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1360
|
+
} satisfies PendingAttachment;
|
|
1361
|
+
},
|
|
1362
|
+
send,
|
|
1363
|
+
});
|
|
1364
|
+
const { composer, append } = makeComposer(adapter);
|
|
1365
|
+
|
|
1366
|
+
const first = composer.addAttachment(textFile());
|
|
1367
|
+
await vi.waitFor(() =>
|
|
1368
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1369
|
+
);
|
|
1370
|
+
await composer.removeAttachment("f.txt");
|
|
1371
|
+
const second = composer.addAttachment(textFile());
|
|
1372
|
+
await vi.waitFor(() =>
|
|
1373
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1374
|
+
);
|
|
1375
|
+
|
|
1376
|
+
const sendPromise = composer.send();
|
|
1377
|
+
uploads[0]!.resolve();
|
|
1378
|
+
await first;
|
|
1379
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1380
|
+
expect(send).not.toHaveBeenCalled();
|
|
1381
|
+
|
|
1382
|
+
uploads[1]!.resolve();
|
|
1383
|
+
await second;
|
|
1384
|
+
await sendPromise;
|
|
1385
|
+
|
|
1386
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
1387
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1388
|
+
expect(append.mock.calls[0]![0].attachments).toHaveLength(1);
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
it("sends once the upload that took over an attachment id is ready", async () => {
|
|
1392
|
+
const stalled = deferred();
|
|
1393
|
+
let addCount = 0;
|
|
1394
|
+
const send = completeSend();
|
|
1395
|
+
const adapter = makeAdapter({
|
|
1396
|
+
async *add({ file }) {
|
|
1397
|
+
const attachment = {
|
|
1398
|
+
id: file.name,
|
|
1399
|
+
type: "file",
|
|
1400
|
+
name: file.name,
|
|
1401
|
+
contentType: file.type,
|
|
1402
|
+
file,
|
|
1403
|
+
};
|
|
1404
|
+
if (addCount++ === 0) {
|
|
1405
|
+
yield {
|
|
1406
|
+
...attachment,
|
|
1407
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1408
|
+
} satisfies PendingAttachment;
|
|
1409
|
+
await stalled.promise;
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
yield {
|
|
1413
|
+
...attachment,
|
|
1414
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1415
|
+
} satisfies PendingAttachment;
|
|
1416
|
+
},
|
|
1417
|
+
send,
|
|
1418
|
+
});
|
|
1419
|
+
const { composer, append } = makeComposer(adapter);
|
|
1420
|
+
|
|
1421
|
+
void composer.addAttachment(textFile());
|
|
1422
|
+
await vi.waitFor(() =>
|
|
1423
|
+
expect(composer.attachments[0]?.status.type).toBe("running"),
|
|
1424
|
+
);
|
|
1425
|
+
await composer.addAttachment(textFile());
|
|
1426
|
+
expect(composer.attachments[0]?.status.type).toBe("requires-action");
|
|
1427
|
+
|
|
1428
|
+
await composer.send();
|
|
1429
|
+
|
|
1430
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
1431
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1432
|
+
stalled.resolve();
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
it("ignores add updates for an attachment after it was sent", async () => {
|
|
1436
|
+
const resume = deferred();
|
|
1437
|
+
const drainedAfterSend = vi.fn();
|
|
1438
|
+
const adapter = makeAdapter({
|
|
1439
|
+
async *add({ file }) {
|
|
1440
|
+
const attachment = {
|
|
1441
|
+
id: "att-1",
|
|
1442
|
+
type: "file",
|
|
1443
|
+
name: file.name,
|
|
1444
|
+
contentType: file.type,
|
|
1445
|
+
file,
|
|
1446
|
+
};
|
|
1447
|
+
yield {
|
|
1448
|
+
...attachment,
|
|
1449
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1450
|
+
} satisfies PendingAttachment;
|
|
1451
|
+
await resume.promise;
|
|
1452
|
+
yield {
|
|
1453
|
+
...attachment,
|
|
1454
|
+
status: { type: "running", reason: "uploading", progress: 1 },
|
|
1455
|
+
} satisfies PendingAttachment;
|
|
1456
|
+
drainedAfterSend();
|
|
1457
|
+
},
|
|
1458
|
+
});
|
|
1459
|
+
const { composer, append } = makeComposer(adapter);
|
|
1460
|
+
|
|
1461
|
+
composer.setText("hello");
|
|
1462
|
+
const adding = composer.addAttachment(textFile());
|
|
1463
|
+
await vi.waitFor(() => expect(composer.attachments).toHaveLength(1));
|
|
1464
|
+
|
|
1465
|
+
await composer.send();
|
|
1466
|
+
resume.resolve();
|
|
1467
|
+
await adding;
|
|
1468
|
+
|
|
1469
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
1470
|
+
expect(composer.attachments).toEqual([]);
|
|
1471
|
+
expect(drainedAfterSend).not.toHaveBeenCalled();
|
|
1472
|
+
});
|
|
1473
|
+
});
|