@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
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, render, waitFor } from "@testing-library/react";
|
|
3
|
+
import type { FC } from "react";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
6
|
+
import { DefaultThreadComposerRuntimeCore } from "../runtime/base/default-thread-composer-runtime-core";
|
|
7
|
+
import type { AttachmentAdapter } from "../adapters/attachment";
|
|
8
|
+
import type { ThreadRuntimeCore } from "../runtime/interfaces/thread-runtime-core";
|
|
9
|
+
import { MessageNotSentError } from "../types/error";
|
|
10
|
+
import type {
|
|
11
|
+
CompleteAttachment,
|
|
12
|
+
PendingAttachment,
|
|
13
|
+
} from "../types/attachment";
|
|
14
|
+
import type {
|
|
15
|
+
ExternalThreadMessage,
|
|
16
|
+
ExternalThreadProps,
|
|
17
|
+
} from "../store/clients/external-thread";
|
|
18
|
+
import { ExternalThread } from "../store/clients/external-thread";
|
|
19
|
+
import { submissionThreadMessage } from "../store/clients/submission-message";
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.restoreAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const deferred = () => Promise.withResolvers<void>();
|
|
26
|
+
const settledUpload = Promise.resolve();
|
|
27
|
+
|
|
28
|
+
const textFile = (name = "f.txt") =>
|
|
29
|
+
new File(["content"], name, { type: "text/plain" });
|
|
30
|
+
|
|
31
|
+
const uploadAdapter = (
|
|
32
|
+
upload: Promise<void>,
|
|
33
|
+
overrides: Partial<AttachmentAdapter> = {},
|
|
34
|
+
): AttachmentAdapter => ({
|
|
35
|
+
accept: "*",
|
|
36
|
+
add: async ({ file }: { file: File }): Promise<PendingAttachment> => ({
|
|
37
|
+
id: file.name,
|
|
38
|
+
type: "file",
|
|
39
|
+
name: file.name,
|
|
40
|
+
contentType: file.type,
|
|
41
|
+
file,
|
|
42
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
43
|
+
}),
|
|
44
|
+
remove: async () => {},
|
|
45
|
+
send: async (attachment) => {
|
|
46
|
+
await upload;
|
|
47
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
48
|
+
},
|
|
49
|
+
...overrides,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const makeComposer = (adapter: AttachmentAdapter, messages: unknown[] = []) => {
|
|
53
|
+
const append = vi.fn();
|
|
54
|
+
const runtime = {
|
|
55
|
+
append,
|
|
56
|
+
cancelRun: vi.fn(),
|
|
57
|
+
subscribe: vi.fn(() => () => {}),
|
|
58
|
+
capabilities: { cancel: false },
|
|
59
|
+
messages,
|
|
60
|
+
getModelContext: () => ({ unstable_composerMetadata: undefined }),
|
|
61
|
+
adapters: { attachments: adapter },
|
|
62
|
+
} as unknown as Omit<ThreadRuntimeCore, "composer">;
|
|
63
|
+
return { composer: new DefaultThreadComposerRuntimeCore(runtime), append };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const makeThread = (
|
|
67
|
+
adapter: AttachmentAdapter,
|
|
68
|
+
{ isRunning = false }: { isRunning?: boolean } = {},
|
|
69
|
+
) => {
|
|
70
|
+
const listeners = new Set<() => void>();
|
|
71
|
+
const runtime = {
|
|
72
|
+
append: vi.fn(),
|
|
73
|
+
cancelRun: vi.fn(),
|
|
74
|
+
subscribe: (listener: () => void) => {
|
|
75
|
+
listeners.add(listener);
|
|
76
|
+
return () => {
|
|
77
|
+
listeners.delete(listener);
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
capabilities: { cancel: true },
|
|
81
|
+
isRunning,
|
|
82
|
+
messages: [] as { id: string; role: string }[],
|
|
83
|
+
getModelContext: () => ({ unstable_composerMetadata: undefined }),
|
|
84
|
+
adapters: { attachments: adapter },
|
|
85
|
+
};
|
|
86
|
+
const composer = new DefaultThreadComposerRuntimeCore(
|
|
87
|
+
runtime as unknown as Omit<ThreadRuntimeCore, "composer">,
|
|
88
|
+
);
|
|
89
|
+
return {
|
|
90
|
+
composer,
|
|
91
|
+
append: runtime.append,
|
|
92
|
+
cancelRun: runtime.cancelRun,
|
|
93
|
+
show: (id: string, role = "user") => {
|
|
94
|
+
runtime.messages = [...runtime.messages, { id, role }];
|
|
95
|
+
for (const listener of listeners) listener();
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
describe("composer submission", () => {
|
|
101
|
+
it("holds the sent message while its attachments are prepared", async () => {
|
|
102
|
+
const upload = deferred();
|
|
103
|
+
const { composer, append } = makeComposer(uploadAdapter(upload.promise));
|
|
104
|
+
|
|
105
|
+
composer.setText("hello");
|
|
106
|
+
await composer.addAttachment(textFile());
|
|
107
|
+
|
|
108
|
+
const sending = composer.send();
|
|
109
|
+
await Promise.resolve();
|
|
110
|
+
|
|
111
|
+
expect(composer.text).toBe("");
|
|
112
|
+
expect(composer.attachments).toEqual([]);
|
|
113
|
+
expect(composer.canSend).toBe(false);
|
|
114
|
+
expect(composer.submission).toMatchObject({
|
|
115
|
+
text: "hello",
|
|
116
|
+
role: "user",
|
|
117
|
+
attachments: [{ id: "f.txt" }],
|
|
118
|
+
});
|
|
119
|
+
expect(append).not.toHaveBeenCalled();
|
|
120
|
+
|
|
121
|
+
upload.resolve();
|
|
122
|
+
await sending;
|
|
123
|
+
|
|
124
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
125
|
+
expect(append.mock.calls[0]![0]).toMatchObject({
|
|
126
|
+
content: [{ type: "text", text: "hello" }],
|
|
127
|
+
attachments: [{ id: "f.txt", status: { type: "complete" } }],
|
|
128
|
+
});
|
|
129
|
+
// The runtime here never shows the message, and a submission it already
|
|
130
|
+
// took must not hold the composer.
|
|
131
|
+
composer.setText("next");
|
|
132
|
+
expect(composer.canSend).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("takes the message back into the draft when it is cancelled", async () => {
|
|
136
|
+
const upload = deferred();
|
|
137
|
+
const { composer, append } = makeComposer(uploadAdapter(upload.promise));
|
|
138
|
+
|
|
139
|
+
composer.setText("hello");
|
|
140
|
+
await composer.addAttachment(textFile());
|
|
141
|
+
const sending = composer.send();
|
|
142
|
+
await Promise.resolve();
|
|
143
|
+
|
|
144
|
+
composer.setText("typed while sending");
|
|
145
|
+
composer.cancel();
|
|
146
|
+
|
|
147
|
+
expect(composer.submission).toBeUndefined();
|
|
148
|
+
expect(composer.text).toBe("hello\ntyped while sending");
|
|
149
|
+
expect(composer.attachments).toMatchObject([
|
|
150
|
+
{ id: "f.txt", status: { type: "requires-action" } },
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
upload.resolve();
|
|
154
|
+
await sending;
|
|
155
|
+
expect(append).not.toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("takes the message back with the reason when an upload fails", async () => {
|
|
159
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
160
|
+
const upload = deferred();
|
|
161
|
+
const send = vi.fn(async (): Promise<CompleteAttachment> => {
|
|
162
|
+
await upload.promise;
|
|
163
|
+
throw new Error("upload failed");
|
|
164
|
+
});
|
|
165
|
+
const { composer, append } = makeComposer(
|
|
166
|
+
uploadAdapter(upload.promise, { send }),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
composer.setText("hello");
|
|
170
|
+
await composer.addAttachment(textFile());
|
|
171
|
+
const sending = composer.send();
|
|
172
|
+
upload.resolve();
|
|
173
|
+
await sending;
|
|
174
|
+
|
|
175
|
+
expect(append).not.toHaveBeenCalled();
|
|
176
|
+
expect(composer.submission).toBeUndefined();
|
|
177
|
+
expect(composer.text).toBe("hello");
|
|
178
|
+
expect(composer.attachments[0]?.status).toEqual({
|
|
179
|
+
type: "incomplete",
|
|
180
|
+
reason: "error",
|
|
181
|
+
message: "upload failed",
|
|
182
|
+
});
|
|
183
|
+
expect(composer.canSend).toBe(true);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("reuses an upload that finished when the message is sent again", async () => {
|
|
187
|
+
const send = vi.fn(
|
|
188
|
+
async (attachment: PendingAttachment): Promise<CompleteAttachment> => ({
|
|
189
|
+
...attachment,
|
|
190
|
+
status: { type: "complete" },
|
|
191
|
+
content: [],
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
const upload = deferred();
|
|
195
|
+
upload.resolve();
|
|
196
|
+
const { composer, append } = makeComposer(
|
|
197
|
+
uploadAdapter(upload.promise, { send }),
|
|
198
|
+
);
|
|
199
|
+
append.mockImplementation(() => Promise.reject(new MessageNotSentError()));
|
|
200
|
+
|
|
201
|
+
composer.setText("hello");
|
|
202
|
+
await composer.addAttachment(textFile());
|
|
203
|
+
await composer.send();
|
|
204
|
+
await vi.waitFor(() => expect(composer.text).toBe("hello"));
|
|
205
|
+
|
|
206
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
207
|
+
expect(composer.attachments).toHaveLength(1);
|
|
208
|
+
|
|
209
|
+
await composer.send();
|
|
210
|
+
|
|
211
|
+
expect(append).toHaveBeenCalledTimes(2);
|
|
212
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe("a message in transit", () => {
|
|
217
|
+
it("stays in the thread until the runtime shows it, even after the next send", async () => {
|
|
218
|
+
const { composer, show } = makeThread(uploadAdapter(settledUpload));
|
|
219
|
+
|
|
220
|
+
composer.setText("one");
|
|
221
|
+
await composer.addAttachment(textFile("a.txt"));
|
|
222
|
+
await composer.send();
|
|
223
|
+
|
|
224
|
+
expect(composer.submission).toBeUndefined();
|
|
225
|
+
expect(composer.inTransit).toMatchObject([
|
|
226
|
+
{
|
|
227
|
+
text: "one",
|
|
228
|
+
attachments: [{ id: "a.txt", status: { type: "complete" } }],
|
|
229
|
+
},
|
|
230
|
+
]);
|
|
231
|
+
|
|
232
|
+
composer.setText("two");
|
|
233
|
+
await composer.addAttachment(textFile("b.txt"));
|
|
234
|
+
await composer.send();
|
|
235
|
+
expect(composer.inTransit.map((message) => message.text)).toEqual([
|
|
236
|
+
"one",
|
|
237
|
+
"two",
|
|
238
|
+
]);
|
|
239
|
+
|
|
240
|
+
show("m1");
|
|
241
|
+
expect(composer.inTransit.map((message) => message.text)).toEqual(["two"]);
|
|
242
|
+
show("a1", "assistant");
|
|
243
|
+
expect(composer.inTransit.map((message) => message.text)).toEqual(["two"]);
|
|
244
|
+
show("m2");
|
|
245
|
+
expect(composer.inTransit).toEqual([]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("leaves the thread when the runtime rejects it", async () => {
|
|
249
|
+
const { composer, append } = makeThread(uploadAdapter(settledUpload));
|
|
250
|
+
append.mockImplementation(() => Promise.reject(new Error("offline")));
|
|
251
|
+
|
|
252
|
+
composer.setText("hello");
|
|
253
|
+
await composer.addAttachment(textFile());
|
|
254
|
+
await composer.send();
|
|
255
|
+
|
|
256
|
+
await vi.waitFor(() => expect(composer.inTransit).toEqual([]));
|
|
257
|
+
expect(composer.text).toBe("");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("keeps its attachments when the composer resets", async () => {
|
|
261
|
+
const remove = vi.fn(async () => {});
|
|
262
|
+
const { composer } = makeThread(uploadAdapter(settledUpload, { remove }));
|
|
263
|
+
|
|
264
|
+
composer.setText("hello");
|
|
265
|
+
await composer.addAttachment(textFile());
|
|
266
|
+
await composer.send();
|
|
267
|
+
await composer.reset();
|
|
268
|
+
|
|
269
|
+
expect(remove).not.toHaveBeenCalled();
|
|
270
|
+
expect(composer.inTransit).toHaveLength(1);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("belongs to the runtime even when handing it over resets the composer", async () => {
|
|
274
|
+
const remove = vi.fn(async () => {});
|
|
275
|
+
const { composer, append } = makeThread(
|
|
276
|
+
uploadAdapter(settledUpload, { remove }),
|
|
277
|
+
);
|
|
278
|
+
append.mockImplementation(() => {
|
|
279
|
+
void composer.reset();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
composer.setText("hello");
|
|
283
|
+
await composer.addAttachment(textFile());
|
|
284
|
+
await composer.send();
|
|
285
|
+
|
|
286
|
+
expect(append).toHaveBeenCalledTimes(1);
|
|
287
|
+
expect(remove).not.toHaveBeenCalled();
|
|
288
|
+
expect(composer.submission).toBeUndefined();
|
|
289
|
+
expect(composer.inTransit).toHaveLength(1);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe("taking a send back", () => {
|
|
294
|
+
it("also stops a run that is going when the send is cancelled", async () => {
|
|
295
|
+
const upload = deferred();
|
|
296
|
+
const { composer, append, cancelRun } = makeThread(
|
|
297
|
+
uploadAdapter(upload.promise),
|
|
298
|
+
{ isRunning: true },
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
composer.setText("hello");
|
|
302
|
+
await composer.addAttachment(textFile());
|
|
303
|
+
const sending = composer.send();
|
|
304
|
+
expect(composer.canCancel).toBe(true);
|
|
305
|
+
composer.cancel();
|
|
306
|
+
|
|
307
|
+
expect(cancelRun).toHaveBeenCalledTimes(1);
|
|
308
|
+
expect(composer.submission).toBeUndefined();
|
|
309
|
+
expect(composer.text).toBe("hello");
|
|
310
|
+
upload.resolve();
|
|
311
|
+
await sending;
|
|
312
|
+
expect(append).not.toHaveBeenCalled();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("leaves the runtime alone when no run is going", async () => {
|
|
316
|
+
const upload = deferred();
|
|
317
|
+
const { composer, cancelRun } = makeThread(uploadAdapter(upload.promise));
|
|
318
|
+
|
|
319
|
+
await composer.addAttachment(textFile());
|
|
320
|
+
const sending = composer.send();
|
|
321
|
+
composer.cancel();
|
|
322
|
+
|
|
323
|
+
expect(cancelRun).not.toHaveBeenCalled();
|
|
324
|
+
upload.resolve();
|
|
325
|
+
await sending;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it("does not start the draft with a blank line when the message had no text", async () => {
|
|
329
|
+
const upload = deferred();
|
|
330
|
+
const { composer } = makeThread(uploadAdapter(upload.promise));
|
|
331
|
+
|
|
332
|
+
await composer.addAttachment(textFile());
|
|
333
|
+
const sending = composer.send();
|
|
334
|
+
composer.setText("typed while sending");
|
|
335
|
+
composer.cancel();
|
|
336
|
+
|
|
337
|
+
expect(composer.text).toBe("typed while sending");
|
|
338
|
+
upload.resolve();
|
|
339
|
+
await sending;
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it("gives each attachment that failed its own reason", async () => {
|
|
343
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
344
|
+
const send = vi.fn(
|
|
345
|
+
async (attachment: PendingAttachment): Promise<CompleteAttachment> => {
|
|
346
|
+
throw new Error(`${attachment.name} failed`);
|
|
347
|
+
},
|
|
348
|
+
);
|
|
349
|
+
const { composer } = makeThread(uploadAdapter(settledUpload, { send }));
|
|
350
|
+
|
|
351
|
+
await composer.addAttachment(textFile("a.txt"));
|
|
352
|
+
await composer.addAttachment(textFile("b.txt"));
|
|
353
|
+
await composer.send();
|
|
354
|
+
|
|
355
|
+
expect(composer.attachments.map((attachment) => attachment.status)).toEqual(
|
|
356
|
+
[
|
|
357
|
+
{ type: "incomplete", reason: "error", message: "a.txt failed" },
|
|
358
|
+
{ type: "incomplete", reason: "error", message: "b.txt failed" },
|
|
359
|
+
],
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it("keeps an attachment it could not remove out of the message, with the reason", async () => {
|
|
364
|
+
const upload = deferred();
|
|
365
|
+
const remove = vi.fn(async () => {
|
|
366
|
+
throw new Error("remove failed");
|
|
367
|
+
});
|
|
368
|
+
const { composer, append } = makeThread(
|
|
369
|
+
uploadAdapter(upload.promise, { remove }),
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
composer.setText("hello");
|
|
373
|
+
await composer.addAttachment(textFile());
|
|
374
|
+
const sending = composer.send();
|
|
375
|
+
|
|
376
|
+
await expect(composer.removeAttachment("f.txt")).rejects.toThrow(
|
|
377
|
+
"remove failed",
|
|
378
|
+
);
|
|
379
|
+
expect(composer.submission?.attachments[0]?.status).toEqual({
|
|
380
|
+
type: "incomplete",
|
|
381
|
+
reason: "error",
|
|
382
|
+
message: "remove failed",
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
upload.resolve();
|
|
386
|
+
await sending;
|
|
387
|
+
expect(append.mock.calls[0]![0]).toMatchObject({ attachments: [] });
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
describe("submissionThreadMessage", () => {
|
|
392
|
+
it("gives a system message without text its one text part", () => {
|
|
393
|
+
expect(
|
|
394
|
+
submissionThreadMessage({
|
|
395
|
+
id: "s1",
|
|
396
|
+
role: "system",
|
|
397
|
+
text: "",
|
|
398
|
+
quote: undefined,
|
|
399
|
+
attachments: [],
|
|
400
|
+
}).content,
|
|
401
|
+
).toEqual([{ type: "text", text: "" }]);
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const renderThread = (props: Partial<ExternalThreadProps>) => {
|
|
406
|
+
const captured: { aui?: ReturnType<typeof useAui> } = {};
|
|
407
|
+
const Capture: FC = () => {
|
|
408
|
+
captured.aui = useAui();
|
|
409
|
+
return null;
|
|
410
|
+
};
|
|
411
|
+
const App: FC<{ messages: readonly ExternalThreadMessage[] }> = ({
|
|
412
|
+
messages,
|
|
413
|
+
}) => {
|
|
414
|
+
const aui = useAui({
|
|
415
|
+
thread: ExternalThread({ isRunning: false, ...props, messages }),
|
|
416
|
+
});
|
|
417
|
+
return (
|
|
418
|
+
<AuiProvider value={aui}>
|
|
419
|
+
<Capture />
|
|
420
|
+
</AuiProvider>
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
const view = render(<App messages={[]} />);
|
|
424
|
+
return {
|
|
425
|
+
aui: () => captured.aui!,
|
|
426
|
+
setMessages: (messages: readonly ExternalThreadMessage[]) =>
|
|
427
|
+
view.rerender(<App messages={messages} />),
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
describe("the thread's submission row", () => {
|
|
432
|
+
it("renders the message being sent and gives way to the runtime's own", async () => {
|
|
433
|
+
const upload = deferred();
|
|
434
|
+
const onNew = vi.fn();
|
|
435
|
+
const { aui, setMessages } = renderThread({
|
|
436
|
+
onNew,
|
|
437
|
+
attachmentAdapter: uploadAdapter(upload.promise),
|
|
438
|
+
});
|
|
439
|
+
const composer = () => aui().thread.composer();
|
|
440
|
+
|
|
441
|
+
await act(async () => {
|
|
442
|
+
await composer().addAttachment(textFile());
|
|
443
|
+
composer().setText("hello");
|
|
444
|
+
});
|
|
445
|
+
await act(async () => {
|
|
446
|
+
composer().send();
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
const thread = () => aui().thread.getState();
|
|
450
|
+
expect(thread().messages).toHaveLength(1);
|
|
451
|
+
const row = thread().messages[0]!;
|
|
452
|
+
expect(row.role).toBe("user");
|
|
453
|
+
expect(row.submission).toMatchObject({ text: "hello" });
|
|
454
|
+
expect(row.attachments).toEqual([]);
|
|
455
|
+
expect(
|
|
456
|
+
aui().thread.message({ index: 0 }).attachment({ index: 0 }).getState(),
|
|
457
|
+
).toMatchObject({ id: "f.txt", status: { type: "requires-action" } });
|
|
458
|
+
expect(thread().isEmpty).toBe(false);
|
|
459
|
+
|
|
460
|
+
await act(async () => {
|
|
461
|
+
upload.resolve();
|
|
462
|
+
await upload.promise;
|
|
463
|
+
});
|
|
464
|
+
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(1));
|
|
465
|
+
|
|
466
|
+
// The row stays until the host shows the message it was dispatched as.
|
|
467
|
+
expect(thread().messages).toHaveLength(1);
|
|
468
|
+
expect(thread().messages[0]!.submission).toBeDefined();
|
|
469
|
+
|
|
470
|
+
await act(async () => {
|
|
471
|
+
setMessages([
|
|
472
|
+
{
|
|
473
|
+
id: "m1",
|
|
474
|
+
role: "user",
|
|
475
|
+
content: [{ type: "text", text: "hello" }],
|
|
476
|
+
attachments: [],
|
|
477
|
+
createdAt: new Date(0),
|
|
478
|
+
metadata: { custom: {} },
|
|
479
|
+
},
|
|
480
|
+
]);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
await waitFor(() => expect(thread().messages).toHaveLength(1));
|
|
484
|
+
expect(thread().messages[0]!.id).toBe("m1");
|
|
485
|
+
expect(thread().messages[0]!.submission).toBeUndefined();
|
|
486
|
+
expect(composer().getState().submission).toBeUndefined();
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
describe("the thread's rows for messages in transit", () => {
|
|
491
|
+
const hostMessage = (id: string, text: string): ExternalThreadMessage => ({
|
|
492
|
+
id,
|
|
493
|
+
role: "user",
|
|
494
|
+
content: [{ type: "text", text }],
|
|
495
|
+
attachments: [],
|
|
496
|
+
createdAt: new Date(0),
|
|
497
|
+
metadata: { custom: {} },
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("keeps each sent message until the host shows it, in order", async () => {
|
|
501
|
+
const onNew = vi.fn();
|
|
502
|
+
const { aui, setMessages } = renderThread({
|
|
503
|
+
onNew,
|
|
504
|
+
attachmentAdapter: uploadAdapter(settledUpload),
|
|
505
|
+
});
|
|
506
|
+
const composer = () => aui().thread.composer();
|
|
507
|
+
const rows = () =>
|
|
508
|
+
aui()
|
|
509
|
+
.thread.getState()
|
|
510
|
+
.messages.map((message) => message.submission?.text ?? message.id);
|
|
511
|
+
|
|
512
|
+
for (const [text, name] of [
|
|
513
|
+
["one", "a.txt"],
|
|
514
|
+
["two", "b.txt"],
|
|
515
|
+
] as const) {
|
|
516
|
+
await act(async () => {
|
|
517
|
+
await composer().addAttachment(textFile(name));
|
|
518
|
+
composer().setText(text);
|
|
519
|
+
});
|
|
520
|
+
await act(async () => {
|
|
521
|
+
composer().send();
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(2));
|
|
525
|
+
expect(rows()).toEqual(["one", "two"]);
|
|
526
|
+
|
|
527
|
+
await act(async () => {
|
|
528
|
+
setMessages([hostMessage("m1", "one")]);
|
|
529
|
+
});
|
|
530
|
+
expect(rows()).toEqual(["m1", "two"]);
|
|
531
|
+
|
|
532
|
+
await act(async () => {
|
|
533
|
+
setMessages([hostMessage("m1", "one"), hostMessage("m2", "two")]);
|
|
534
|
+
});
|
|
535
|
+
expect(rows()).toEqual(["m1", "m2"]);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it("marks only the last row as the thread's last message", async () => {
|
|
539
|
+
const upload = deferred();
|
|
540
|
+
const onNew = vi.fn();
|
|
541
|
+
const { aui, setMessages } = renderThread({
|
|
542
|
+
onNew,
|
|
543
|
+
attachmentAdapter: uploadAdapter(upload.promise),
|
|
544
|
+
});
|
|
545
|
+
const composer = () => aui().thread.composer();
|
|
546
|
+
const lastFlags = () =>
|
|
547
|
+
aui()
|
|
548
|
+
.thread.getState()
|
|
549
|
+
.messages.map(({ isLast }) => isLast);
|
|
550
|
+
await act(async () => {
|
|
551
|
+
setMessages([hostMessage("m0", "earlier")]);
|
|
552
|
+
});
|
|
553
|
+
await act(async () => {
|
|
554
|
+
await composer().addAttachment(textFile());
|
|
555
|
+
composer().setText("hello");
|
|
556
|
+
});
|
|
557
|
+
await act(async () => {
|
|
558
|
+
composer().send();
|
|
559
|
+
});
|
|
560
|
+
expect(lastFlags()).toEqual([false, true]);
|
|
561
|
+
|
|
562
|
+
await act(async () => {
|
|
563
|
+
upload.resolve();
|
|
564
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
565
|
+
});
|
|
566
|
+
expect(onNew).toHaveBeenCalledTimes(1);
|
|
567
|
+
expect(lastFlags()).toEqual([false, true]);
|
|
568
|
+
|
|
569
|
+
await act(async () => {
|
|
570
|
+
setMessages([hostMessage("m0", "earlier"), hostMessage("m1", "hello")]);
|
|
571
|
+
});
|
|
572
|
+
expect(
|
|
573
|
+
aui()
|
|
574
|
+
.thread.getState()
|
|
575
|
+
.messages.map(({ id }) => id),
|
|
576
|
+
).toEqual(["m0", "m1"]);
|
|
577
|
+
expect(lastFlags()).toEqual([false, true]);
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it("keeps a second send cancellable while the first is still in transit", async () => {
|
|
581
|
+
const slow = deferred();
|
|
582
|
+
const send = vi.fn(async (attachment: PendingAttachment) => {
|
|
583
|
+
if (attachment.name === "b.txt") await slow.promise;
|
|
584
|
+
return {
|
|
585
|
+
...attachment,
|
|
586
|
+
status: { type: "complete" as const },
|
|
587
|
+
content: [],
|
|
588
|
+
};
|
|
589
|
+
});
|
|
590
|
+
const onNew = vi.fn();
|
|
591
|
+
const { aui, setMessages } = renderThread({
|
|
592
|
+
onNew,
|
|
593
|
+
attachmentAdapter: uploadAdapter(settledUpload, { send }),
|
|
594
|
+
});
|
|
595
|
+
const composer = () => aui().thread.composer();
|
|
596
|
+
|
|
597
|
+
await act(async () => {
|
|
598
|
+
await composer().addAttachment(textFile("a.txt"));
|
|
599
|
+
composer().setText("one");
|
|
600
|
+
});
|
|
601
|
+
await act(async () => {
|
|
602
|
+
composer().send();
|
|
603
|
+
});
|
|
604
|
+
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(1));
|
|
605
|
+
await act(async () => {
|
|
606
|
+
await composer().addAttachment(textFile("b.txt"));
|
|
607
|
+
composer().setText("two");
|
|
608
|
+
});
|
|
609
|
+
await act(async () => {
|
|
610
|
+
composer().send();
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
await act(async () => {
|
|
614
|
+
setMessages([hostMessage("m1", "one")]);
|
|
615
|
+
});
|
|
616
|
+
expect(composer().getState().submission).toMatchObject({ text: "two" });
|
|
617
|
+
|
|
618
|
+
await act(async () => {
|
|
619
|
+
composer().cancel();
|
|
620
|
+
});
|
|
621
|
+
expect(composer().getState().submission).toBeUndefined();
|
|
622
|
+
expect(composer().getState().text).toBe("two");
|
|
623
|
+
|
|
624
|
+
await act(async () => {
|
|
625
|
+
slow.resolve();
|
|
626
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
627
|
+
});
|
|
628
|
+
expect(onNew).toHaveBeenCalledTimes(1);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
it("stops a run that is going when a send being prepared is cancelled", async () => {
|
|
632
|
+
const upload = deferred();
|
|
633
|
+
const onCancel = vi.fn();
|
|
634
|
+
const onNew = vi.fn();
|
|
635
|
+
const { aui } = renderThread({
|
|
636
|
+
isRunning: true,
|
|
637
|
+
onCancel,
|
|
638
|
+
onNew,
|
|
639
|
+
attachmentAdapter: uploadAdapter(upload.promise),
|
|
640
|
+
});
|
|
641
|
+
const composer = () => aui().thread.composer();
|
|
642
|
+
|
|
643
|
+
await act(async () => {
|
|
644
|
+
await composer().addAttachment(textFile());
|
|
645
|
+
composer().setText("hello");
|
|
646
|
+
});
|
|
647
|
+
await act(async () => {
|
|
648
|
+
composer().send();
|
|
649
|
+
});
|
|
650
|
+
await act(async () => {
|
|
651
|
+
composer().cancel();
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
655
|
+
expect(composer().getState().text).toBe("hello");
|
|
656
|
+
expect(aui().thread.getState().messages).toEqual([]);
|
|
657
|
+
|
|
658
|
+
await act(async () => {
|
|
659
|
+
upload.resolve();
|
|
660
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
661
|
+
});
|
|
662
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
it("keeps the upload an edit was sent with when the edit is cancelled afterwards", async () => {
|
|
666
|
+
const remove = vi.fn(async () => {});
|
|
667
|
+
const onEdit = vi.fn();
|
|
668
|
+
const { aui, setMessages } = renderThread({
|
|
669
|
+
onEdit,
|
|
670
|
+
attachmentAdapter: uploadAdapter(settledUpload, { remove }),
|
|
671
|
+
});
|
|
672
|
+
await act(async () => {
|
|
673
|
+
setMessages([hostMessage("m1", "hello")]);
|
|
674
|
+
});
|
|
675
|
+
const edit = () => aui().thread.message({ index: 0 }).composer();
|
|
676
|
+
|
|
677
|
+
await act(async () => {
|
|
678
|
+
edit().beginEdit();
|
|
679
|
+
});
|
|
680
|
+
await act(async () => {
|
|
681
|
+
await edit().addAttachment(textFile());
|
|
682
|
+
});
|
|
683
|
+
await act(async () => {
|
|
684
|
+
edit().send();
|
|
685
|
+
});
|
|
686
|
+
await waitFor(() => expect(onEdit).toHaveBeenCalledTimes(1));
|
|
687
|
+
await act(async () => {
|
|
688
|
+
edit().cancel();
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
expect(remove).not.toHaveBeenCalled();
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
it("returns the message to the draft when the host throws", async () => {
|
|
695
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
696
|
+
const onNew = vi.fn(() => {
|
|
697
|
+
throw new Error("offline");
|
|
698
|
+
});
|
|
699
|
+
const { aui } = renderThread({
|
|
700
|
+
onNew,
|
|
701
|
+
attachmentAdapter: uploadAdapter(settledUpload),
|
|
702
|
+
});
|
|
703
|
+
const composer = () => aui().thread.composer();
|
|
704
|
+
|
|
705
|
+
await act(async () => {
|
|
706
|
+
composer().setText("plain");
|
|
707
|
+
});
|
|
708
|
+
await act(async () => {
|
|
709
|
+
composer().send();
|
|
710
|
+
});
|
|
711
|
+
expect(composer().getState().text).toBe("plain");
|
|
712
|
+
|
|
713
|
+
await act(async () => {
|
|
714
|
+
composer().setText("");
|
|
715
|
+
await composer().addAttachment(textFile());
|
|
716
|
+
composer().setText("with a file");
|
|
717
|
+
});
|
|
718
|
+
await act(async () => {
|
|
719
|
+
composer().send();
|
|
720
|
+
});
|
|
721
|
+
await waitFor(() => expect(composer().getState().text).toBe("with a file"));
|
|
722
|
+
expect(composer().getState().attachments).toHaveLength(1);
|
|
723
|
+
expect(aui().thread.getState().messages).toEqual([]);
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
it("gives each attachment that failed its own reason", async () => {
|
|
727
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
728
|
+
const send = vi.fn(
|
|
729
|
+
async (attachment: PendingAttachment): Promise<CompleteAttachment> => {
|
|
730
|
+
throw new Error(`${attachment.name} failed`);
|
|
731
|
+
},
|
|
732
|
+
);
|
|
733
|
+
const { aui } = renderThread({
|
|
734
|
+
onNew: vi.fn(),
|
|
735
|
+
attachmentAdapter: uploadAdapter(settledUpload, { send }),
|
|
736
|
+
});
|
|
737
|
+
const composer = () => aui().thread.composer();
|
|
738
|
+
|
|
739
|
+
await act(async () => {
|
|
740
|
+
await composer().addAttachment(textFile("a.txt"));
|
|
741
|
+
await composer().addAttachment(textFile("b.txt"));
|
|
742
|
+
});
|
|
743
|
+
await act(async () => {
|
|
744
|
+
composer().send();
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
await waitFor(() =>
|
|
748
|
+
expect(
|
|
749
|
+
composer()
|
|
750
|
+
.getState()
|
|
751
|
+
.attachments.map((attachment) => attachment.status),
|
|
752
|
+
).toEqual([
|
|
753
|
+
{ type: "incomplete", reason: "error", message: "a.txt failed" },
|
|
754
|
+
{ type: "incomplete", reason: "error", message: "b.txt failed" },
|
|
755
|
+
]),
|
|
756
|
+
);
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
it("keeps an attachment it could not remove out of the message, with the reason", async () => {
|
|
760
|
+
const upload = deferred();
|
|
761
|
+
const remove = vi.fn(async () => {
|
|
762
|
+
throw new Error("remove failed");
|
|
763
|
+
});
|
|
764
|
+
const onNew = vi.fn();
|
|
765
|
+
const { aui } = renderThread({
|
|
766
|
+
onNew,
|
|
767
|
+
attachmentAdapter: uploadAdapter(upload.promise, { remove }),
|
|
768
|
+
});
|
|
769
|
+
const composer = () => aui().thread.composer();
|
|
770
|
+
|
|
771
|
+
await act(async () => {
|
|
772
|
+
await composer().addAttachment(textFile());
|
|
773
|
+
composer().setText("hello");
|
|
774
|
+
});
|
|
775
|
+
await act(async () => {
|
|
776
|
+
composer().send();
|
|
777
|
+
});
|
|
778
|
+
await act(async () => {
|
|
779
|
+
await expect(
|
|
780
|
+
composer().attachment({ id: "f.txt" }).remove(),
|
|
781
|
+
).rejects.toThrow("remove failed");
|
|
782
|
+
});
|
|
783
|
+
expect(composer().getState().submission?.attachments[0]?.status).toEqual({
|
|
784
|
+
type: "incomplete",
|
|
785
|
+
reason: "error",
|
|
786
|
+
message: "remove failed",
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
await act(async () => {
|
|
790
|
+
upload.resolve();
|
|
791
|
+
await upload.promise;
|
|
792
|
+
});
|
|
793
|
+
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(1));
|
|
794
|
+
expect(onNew.mock.calls[0]![0]).toMatchObject({ attachments: [] });
|
|
795
|
+
});
|
|
796
|
+
});
|