@assistant-ui/core 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/attachment.d.ts +50 -43
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +52 -21
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +2 -5
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +7 -8
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +14 -9
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/speech.d.ts +63 -65
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +16 -2
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/suggestion.d.ts +19 -22
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +60 -58
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +8 -11
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +50 -45
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +17 -3
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +70 -56
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.d.ts +1 -4
- package/dist/internal/duplicate-detection.d.ts.map +1 -1
- package/dist/internal.d.ts +27 -58
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +8 -6
- package/dist/model-context/frame/host.d.ts +20 -23
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +3 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +28 -30
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +6 -0
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.d.ts +24 -27
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/frame/validate.d.ts +3 -0
- package/dist/model-context/frame/validate.d.ts.map +1 -0
- package/dist/model-context/frame/validate.js +26 -0
- package/dist/model-context/frame/validate.js.map +1 -0
- package/dist/model-context/interactable-composer-metadata.d.ts +51 -39
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +30 -6
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry-handles.d.ts +9 -12
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +15 -18
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +15 -17
- package/dist/model-context/tool-call-text.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +12 -14
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +40 -43
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +9 -12
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +23 -26
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +4 -8
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +28 -23
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +77 -58
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +4 -7
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +6 -9
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +2 -5
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts +9 -12
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +3 -6
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +306 -101
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +34 -37
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +2 -1
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/Tools.d.ts +10 -12
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +4 -8
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts +9 -11
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +32 -22
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/index.d.ts +160 -122
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +5 -5
- package/dist/react/interactables-legacy/Interactables.d.ts +2 -5
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +15 -8
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts +6 -9
- package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.js +13 -14
- package/dist/react/interactables-legacy/interactable-model-context.js.map +1 -1
- package/dist/react/interactables-legacy/scopes.d.ts +42 -46
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +8 -11
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useInteractableState.d.ts +7 -9
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -14
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +54 -25
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.d.ts +15 -18
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +13 -6
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts +1 -4
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts +3 -6
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +26 -29
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +6 -9
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +6 -9
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +6 -9
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +5 -7
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts +1 -4
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +44 -32
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +3 -6
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +7 -10
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +3 -6
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +9 -13
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +13 -16
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +3 -5
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +3 -6
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +40 -40
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableState.d.ts +10 -9
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +4 -7
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +7 -9
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +7 -10
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +6 -9
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +3 -6
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +3 -6
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +3 -6
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +4 -7
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts +3 -6
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +3 -6
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +4 -7
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +2 -5
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts +3 -6
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts +5 -8
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts +1 -4
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts +3 -6
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +7 -10
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +4 -4
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +3 -6
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -4
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +2 -5
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +8 -11
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -29
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +26 -28
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +13 -13
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +13 -17
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +30 -33
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +42 -33
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +30 -28
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +14 -15
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +122 -120
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +208 -194
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +124 -82
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +8 -11
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +4 -7
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +16 -19
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +61 -64
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +25 -27
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +24 -5
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +26 -28
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +6 -9
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +5 -8
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +4 -7
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +3 -6
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +3 -6
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +3 -6
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +3 -6
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +4 -7
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +7 -10
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +4 -7
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +4 -7
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +5 -1
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +4 -7
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +4 -8
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +210 -219
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +70 -46
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +186 -198
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +13 -4
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +17 -23
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +3 -1
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +10 -11
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +11 -14
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +6 -8
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js +9 -2
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts +9 -12
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.js +4 -1
- package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/types.d.ts +123 -118
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +7 -10
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +17 -6
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +3 -6
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +2 -5
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +7 -10
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +426 -216
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +15 -18
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +8 -4
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +146 -125
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +120 -8
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +13 -15
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +5 -7
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +2 -5
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.js +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +3 -6
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +9 -11
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +15 -19
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +14 -17
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +17 -21
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-store-history-copy.d.ts +25 -0
- package/dist/react/runtimes/external-store-history-copy.d.ts.map +1 -0
- package/dist/react/runtimes/external-store-history-copy.js +148 -0
- package/dist/react/runtimes/external-store-history-copy.js.map +1 -0
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts +3 -6
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +72 -35
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +2 -5
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +29 -41
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +142 -34
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +3 -6
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +2 -2
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +5 -7
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +4 -6
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +72 -70
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +11 -15
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +60 -60
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +21 -24
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/react/types/store-augmentation.d.ts +10 -11
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +6 -8
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +35 -37
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +3 -6
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +3 -6
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +28 -31
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +51 -49
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +35 -35
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +215 -201
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +4 -0
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +31 -30
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +25 -2
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +87 -82
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +4 -3
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts +54 -57
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +70 -72
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +77 -81
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +306 -308
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +2 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +9 -12
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +150 -101
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +400 -122
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +121 -104
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +174 -62
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +30 -31
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +21 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +28 -31
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +23 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +15 -18
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +8 -11
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +98 -83
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +67 -70
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +225 -211
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +25 -20
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +37 -40
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +32 -33
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +10 -2
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/queue/queue-item.d.ts +7 -10
- package/dist/runtime/queue/queue-item.d.ts.map +1 -1
- package/dist/runtime/utils/abortable-thread-load.d.ts +9 -11
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.d.ts +16 -15
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.js +24 -2
- package/dist/runtime/utils/attachment-add-operations.js.map +1 -1
- package/dist/runtime/utils/attachment-send-operations.d.ts +12 -0
- package/dist/runtime/utils/attachment-send-operations.d.ts.map +1 -0
- package/dist/runtime/utils/attachment-send-operations.js +34 -0
- package/dist/runtime/utils/attachment-send-operations.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +11 -13
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +3 -5
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +31 -33
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +47 -48
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +6 -5
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +6 -9
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +24 -27
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +52 -54
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +8 -7
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +12 -14
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +7 -10
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +6 -9
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
- package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
- package/dist/runtime/utils/stored-message-parts.js +103 -0
- package/dist/runtime/utils/stored-message-parts.js.map +1 -0
- package/dist/runtime/utils/streaming-timing.d.ts +23 -26
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +38 -34
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +16 -6
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +5 -7
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.js +31 -4
- package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -1
- package/dist/runtime/utils/tool-call-tree.d.ts +10 -13
- package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
- package/dist/runtime/utils/tool-interactions.d.ts +10 -0
- package/dist/runtime/utils/tool-interactions.d.ts.map +1 -0
- package/dist/runtime/utils/tool-interactions.js +92 -0
- package/dist/runtime/utils/tool-interactions.js.map +1 -0
- package/dist/runtimes/assistant-transport/utils.d.ts +1 -4
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +220 -200
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +6 -8
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js +4 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.d.ts +3 -6
- package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +40 -43
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +2 -2
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +119 -125
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +71 -18
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +5 -8
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +96 -98
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.js +3 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/internal.d.ts +20 -16
- package/dist/runtimes/internal.d.ts.map +1 -0
- package/dist/runtimes/local/local-runtime-core.d.ts +7 -10
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +41 -44
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +42 -45
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +94 -93
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +220 -29
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +2 -5
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +77 -55
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +28 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +12 -15
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +3 -6
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +2 -5
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +34 -31
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +8 -3
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +60 -63
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -1
- package/dist/runtimes/remote-thread-list/title-generation.d.ts +31 -33
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +5 -8
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +119 -121
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +147 -149
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +22 -7
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +8 -11
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/external-thread.d.ts +56 -58
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +1270 -741
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +2 -5
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +3 -6
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +3 -1
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +2 -5
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts +4 -6
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/submission-message.d.ts +8 -0
- package/dist/store/clients/submission-message.d.ts.map +1 -0
- package/dist/store/clients/submission-message.js +22 -0
- package/dist/store/clients/submission-message.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +8 -11
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +12 -12
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +81 -82
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/clients/thread-selection-events.d.ts +1 -4
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +7 -10
- package/dist/store/clients/thread-tasks.d.ts.map +1 -1
- package/dist/store/env.d.ts +1 -4
- package/dist/store/env.d.ts.map +1 -1
- package/dist/store/index.d.ts +33 -36
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +5 -5
- package/dist/store/internal.d.ts +12 -12
- package/dist/store/internal.d.ts.map +1 -0
- package/dist/store/internal.js +2 -2
- package/dist/store/primitive-predicates.d.ts +14 -16
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +10 -5
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +11 -14
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +65 -62
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -4
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -4
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +2 -5
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +26 -16
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +10 -11
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +121 -113
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +5 -8
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +6 -9
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +4 -7
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +221 -158
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +3 -6
- package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
- package/dist/store/scope-registration.d.ts +28 -29
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/attachment.d.ts +19 -22
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +33 -35
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +147 -135
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +119 -112
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +10 -13
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +53 -50
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +21 -23
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts +14 -17
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +18 -21
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +27 -30
- package/dist/store/scopes/task.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +68 -71
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +197 -200
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +49 -52
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +73 -69
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +35 -7
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/attachment.d.ts +35 -37
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/augmentations.d.ts +7 -8
- package/dist/types/augmentations.d.ts.map +1 -1
- package/dist/types/directive.d.ts +13 -16
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +15 -17
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/message.d.ts +358 -318
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts +3 -6
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +10 -13
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts +1 -4
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +2 -5
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +9 -13
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +16 -19
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +19 -21
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/id.d.ts +3 -6
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/image-media-type.d.ts +1 -4
- package/dist/utils/image-media-type.d.ts.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +1 -4
- package/dist/utils/invoke-user-callback.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +1 -4
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +5 -8
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +3 -6
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.d.ts +6 -8
- package/dist/utils/normalizePartStatus.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.js +3 -2
- package/dist/utils/normalizePartStatus.js.map +1 -1
- package/dist/utils/notify-event-listeners.d.ts +2 -4
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/record.d.ts +1 -4
- package/dist/utils/record.d.ts.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +2 -5
- package/dist/utils/silent-runtime-action.d.ts.map +1 -1
- package/dist/utils/text.d.ts +2 -5
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/wire-media.d.ts +3 -6
- package/dist/utils/wire-media.d.ts.map +1 -1
- package/package.json +15 -13
- package/src/adapters/attachment.test.ts +98 -1
- package/src/adapters/attachment.ts +77 -20
- package/src/adapters/feedback.ts +1 -0
- package/src/adapters/speech.test.ts +94 -0
- package/src/adapters/speech.ts +16 -2
- package/src/adapters/thread-history.ts +16 -5
- package/src/adapters/voice.test.ts +169 -0
- package/src/adapters/voice.ts +25 -4
- package/src/index.ts +14 -2
- package/src/internal.ts +7 -0
- package/src/model-context/frame/host.test.ts +51 -1
- package/src/model-context/frame/host.ts +3 -1
- package/src/model-context/frame/provider.test.ts +106 -20
- package/src/model-context/frame/provider.ts +8 -1
- package/src/model-context/frame/validate.ts +57 -0
- package/src/model-context/interactable-composer-metadata.test.ts +82 -0
- package/src/model-context/interactable-composer-metadata.ts +45 -2
- package/src/react/RuntimeAdapter.test.ts +4 -1
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +711 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +125 -109
- package/src/react/client/Interactables.test.ts +865 -8
- package/src/react/client/Interactables.ts +325 -45
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
- package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
- package/src/react/client/RemoteThreadList.test.ts +5 -6
- package/src/react/client/RemoteThreadList.ts +6 -0
- package/src/react/client/Tools.ts +2 -3
- package/src/react/client/interactable-model-context.test.ts +56 -13
- package/src/react/client/interactable-model-context.ts +48 -23
- package/src/react/index.ts +2 -2
- package/src/react/interactables-legacy/Interactables.test.ts +221 -4
- package/src/react/interactables-legacy/Interactables.ts +25 -14
- package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +40 -22
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
- package/src/react/model-context/useInteractable.test.tsx +56 -29
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -5
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +33 -0
- package/src/react/primitive-hooks/useSuggestionTrigger.ts +7 -4
- package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +170 -0
- package/src/react/primitives/generativeUI/GenerativeUI.tsx +43 -28
- package/src/react/primitives/message/MessageAttachments.test.tsx +2 -6
- package/src/react/primitives/message/MessageAttachments.tsx +14 -8
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +155 -8
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -6
- package/src/react/primitives/message/MessageParts.test.tsx +84 -0
- package/src/react/primitives/message/MessageParts.tool-interaction.test.tsx +69 -0
- package/src/react/primitives/message/MessageParts.tsx +29 -8
- package/src/react/primitives/thread/ThreadMessages.test.tsx +25 -7
- package/src/react/primitives/thread/ThreadSuggestions.test.tsx +97 -0
- package/src/react/primitives/thread/ThreadSuggestions.tsx +29 -6
- package/src/react/providers/ReadonlyThreadProvider.tsx +2 -2
- package/src/react/providers/TextMessagePartProvider.tsx +3 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +93 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +181 -21
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +62 -17
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +112 -77
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -3
- package/src/react/runtimes/RemoteThreadResource.ts +5 -2
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +3 -1
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +10 -2
- package/src/react/runtimes/assistant-transport/runManager.ts +3 -0
- package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +57 -0
- package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
- package/src/react/runtimes/assistant-transport/transport-thread-id.test.tsx +571 -0
- package/src/react/runtimes/assistant-transport/types.ts +9 -1
- package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +10 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +108 -1
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +33 -9
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.integration.test.tsx +289 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.test.tsx +471 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.engagement.test.tsx +330 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +78 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +463 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +595 -227
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +33 -4
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
- package/src/react/runtimes/cloud/auiV0.ts +275 -6
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +873 -0
- package/src/react/runtimes/createMessageConverter.ts +9 -3
- package/src/react/runtimes/external-message-converter.test.ts +7 -3
- package/src/react/runtimes/external-store-history-copy.ts +223 -0
- package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
- package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +84 -3
- package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
- package/src/react/runtimes/useExternalStoreRuntime.ts +25 -5
- package/src/react/runtimes/useLocalRuntime.test.tsx +145 -1
- package/src/react/runtimes/useLocalRuntime.ts +8 -5
- package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +5 -1
- package/src/react/types/MessagePartComponentTypes.ts +10 -0
- package/src/react/types/scopes/interactables.ts +3 -0
- package/src/runtime/api/attachment-runtime.ts +10 -5
- package/src/runtime/api/bindings.ts +6 -1
- package/src/runtime/api/composer-runtime.ts +29 -6
- package/src/runtime/api/message-part-runtime.test.ts +215 -0
- package/src/runtime/api/message-part-runtime.ts +44 -1
- package/src/runtime/api/message-runtime.test.ts +112 -2
- package/src/runtime/api/message-runtime.ts +25 -7
- package/src/runtime/api/thread-list-item-runtime.ts +5 -5
- package/src/runtime/api/thread-list-runtime.ts +3 -3
- package/src/runtime/api/thread-runtime.test.ts +59 -0
- package/src/runtime/api/thread-runtime.ts +21 -11
- package/src/runtime/base/base-composer-runtime-core.ts +548 -153
- package/src/runtime/base/base-thread-runtime-core.test.ts +1614 -136
- package/src/runtime/base/base-thread-runtime-core.ts +236 -46
- package/src/runtime/base/default-edit-composer-runtime-core.ts +24 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +33 -3
- package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +24 -1
- package/src/runtime/queue/message-queue.ts +11 -1
- package/src/runtime/utils/attachment-add-operations.ts +45 -2
- package/src/runtime/utils/attachment-send-operations.ts +54 -0
- package/src/runtime/utils/auto-status.test.ts +54 -0
- package/src/runtime/utils/auto-status.ts +3 -10
- package/src/runtime/utils/external-message-conversion.test.ts +91 -0
- package/src/runtime/utils/external-message-conversion.ts +9 -6
- package/src/runtime/utils/message-repository.test.ts +69 -1
- package/src/runtime/utils/message-repository.ts +14 -7
- package/src/runtime/utils/stored-message-parts.ts +216 -0
- package/src/runtime/utils/thread-message-like.test.ts +58 -0
- package/src/runtime/utils/thread-message-like.ts +79 -48
- package/src/runtime/utils/thread-runtime-lifecycle.test.ts +67 -0
- package/src/runtime/utils/thread-runtime-lifecycle.ts +42 -8
- package/src/runtime/utils/tool-interactions.test.ts +193 -0
- package/src/runtime/utils/tool-interactions.ts +147 -0
- package/src/runtimes/external-store/external-store-adapter.ts +25 -0
- package/src/runtimes/external-store/external-store-runtime-core.ts +10 -2
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +2 -2
- package/src/runtimes/external-store/external-store-thread-runtime-core.test.ts +49 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +114 -32
- package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +127 -56
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +10 -1
- package/src/runtimes/local/local-thread-runtime-core.edit-cancellation.test.ts +70 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +1866 -169
- package/src/runtimes/local/local-thread-runtime-core.ts +365 -40
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +53 -1
- package/src/runtimes/remote-thread-list/optimistic-state.ts +8 -3
- package/src/runtimes/tool-invocations/EDGE_CASES.md +19 -4
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +392 -39
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +31 -8
- package/src/store/clients/external-thread.test.ts +145 -0
- package/src/store/clients/external-thread.ts +669 -144
- package/src/store/clients/model-context-client.test.ts +8 -8
- package/src/store/clients/no-op-composer-client.ts +2 -0
- package/src/store/clients/submission-message.ts +27 -0
- package/src/store/clients/thread-message-client.test.ts +39 -0
- package/src/store/clients/thread-message-client.ts +13 -6
- package/src/store/index.ts +2 -2
- package/src/store/internal.ts +1 -0
- package/src/store/primitive-predicates.test.ts +119 -0
- package/src/store/primitive-predicates.ts +19 -4
- package/src/store/runtime-clients/composer-runtime-client.ts +4 -3
- package/src/store/runtime-clients/message-part-runtime-client.test.ts +42 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +4 -0
- package/src/store/runtime-clients/message-runtime-client.ts +5 -0
- package/src/store/runtime-clients/thread-runtime-client.test.tsx +243 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +46 -9
- package/src/store/scopes/composer.ts +22 -4
- package/src/store/scopes/message.ts +12 -1
- package/src/store/scopes/part.ts +8 -0
- package/src/subscribable/subscribable.test.ts +205 -3
- package/src/subscribable/subscribable.ts +49 -7
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
- package/src/tests/attachment-adapters.test.ts +16 -1
- package/src/tests/auiV0Encode.test.ts +412 -1
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
- package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
- package/src/tests/base-composer-runtime-core.test.ts +212 -5
- package/src/tests/composer-can-cancel.test.ts +35 -6
- package/src/tests/composer-can-send.test.ts +120 -1
- package/src/tests/composer-submission.test.tsx +796 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +149 -2
- package/src/tests/external-store-thread-list-runtime-core.test.ts +111 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +810 -28
- package/src/tests/external-store-thread-runtime-core.test.ts +217 -0
- package/src/tests/external-thread-attachments.test.tsx +763 -26
- package/src/tests/external-thread-feedback.test.tsx +20 -7
- package/src/tests/external-thread-isLast.test.tsx +69 -0
- package/src/tests/external-thread-parity.test.tsx +1 -1
- package/src/tests/get-thread-state-isRunning.test.ts +2 -2
- package/src/tests/message-queue.test.ts +45 -10
- package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
- package/src/tests/thread-switch-events.test.tsx +11 -7
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +2 -1
- package/src/types/message.test.ts +19 -0
- package/src/types/message.ts +65 -10
- package/src/utils/normalizePartStatus.ts +14 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -16
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
- package/dist/tests/remote-thread-list-test-helpers.js +0 -59
- package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
|
+
import { getEventListeners } from "node:events";
|
|
3
4
|
import { act, render, waitFor } from "@testing-library/react";
|
|
4
|
-
import type
|
|
5
|
+
import { Activity, type FC } from "react";
|
|
5
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import { AuiProvider, useAui } from "@assistant-ui/store";
|
|
7
|
-
import {
|
|
7
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/store";
|
|
8
|
+
import { useAssistantClientDestroySignal } from "@assistant-ui/store/internal";
|
|
9
|
+
import {
|
|
10
|
+
type AttachmentAdapter,
|
|
11
|
+
CompositeAttachmentAdapter,
|
|
12
|
+
} from "../adapters/attachment";
|
|
8
13
|
import type {
|
|
9
14
|
ExternalThreadMessage,
|
|
10
15
|
ExternalThreadProps,
|
|
@@ -75,7 +80,343 @@ const renderThread = () => {
|
|
|
75
80
|
return () => captured.aui!;
|
|
76
81
|
};
|
|
77
82
|
|
|
83
|
+
const deferred = () => Promise.withResolvers<void>();
|
|
84
|
+
|
|
85
|
+
const setupPartialSend = (type: "thread" | "edit" = "thread") => {
|
|
86
|
+
const successfulUpload = deferred();
|
|
87
|
+
const failedUpload = deferred();
|
|
88
|
+
const remove = vi.fn(async () => {});
|
|
89
|
+
const onNew = vi.fn();
|
|
90
|
+
const send = vi.fn(async (attachment: PendingAttachment) => {
|
|
91
|
+
await (attachment.name === "a" ? successfulUpload : failedUpload).promise;
|
|
92
|
+
return {
|
|
93
|
+
...attachment,
|
|
94
|
+
status: { type: "complete" as const },
|
|
95
|
+
content: [{ type: "text" as const, text: attachment.name }],
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
const aui = renderThreadWithProps({
|
|
99
|
+
onNew,
|
|
100
|
+
onEdit: onNew,
|
|
101
|
+
messages:
|
|
102
|
+
type === "edit"
|
|
103
|
+
? [
|
|
104
|
+
{
|
|
105
|
+
id: "u1",
|
|
106
|
+
role: "user",
|
|
107
|
+
content: [{ type: "text", text: "original" }],
|
|
108
|
+
attachments: [],
|
|
109
|
+
createdAt: new Date(0),
|
|
110
|
+
metadata: { custom: {} },
|
|
111
|
+
},
|
|
112
|
+
]
|
|
113
|
+
: [],
|
|
114
|
+
attachmentAdapter: {
|
|
115
|
+
accept: "*",
|
|
116
|
+
add: async ({ file }) => ({
|
|
117
|
+
id: file.name,
|
|
118
|
+
type: "file",
|
|
119
|
+
name: file.name,
|
|
120
|
+
file,
|
|
121
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
122
|
+
}),
|
|
123
|
+
remove,
|
|
124
|
+
send,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
aui,
|
|
129
|
+
composer: () =>
|
|
130
|
+
type === "edit"
|
|
131
|
+
? aui().thread.message({ id: "u1" }).composer()
|
|
132
|
+
: aui().thread.composer(),
|
|
133
|
+
successfulUpload,
|
|
134
|
+
failedUpload,
|
|
135
|
+
send,
|
|
136
|
+
remove,
|
|
137
|
+
onNew,
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
78
141
|
describe("ExternalThread attachments", () => {
|
|
142
|
+
it.each([
|
|
143
|
+
["thread", "before"],
|
|
144
|
+
["thread", "after"],
|
|
145
|
+
["edit", "before"],
|
|
146
|
+
["edit", "after"],
|
|
147
|
+
] as const)(
|
|
148
|
+
"%s reuses successful uploads when a sibling fails %s they finish",
|
|
149
|
+
async (type, order) => {
|
|
150
|
+
const consoleError = vi
|
|
151
|
+
.spyOn(console, "error")
|
|
152
|
+
.mockImplementation(() => {});
|
|
153
|
+
const { composer, successfulUpload, failedUpload, send, remove, onNew } =
|
|
154
|
+
setupPartialSend(type);
|
|
155
|
+
await act(async () => {
|
|
156
|
+
if (type === "edit") composer().beginEdit();
|
|
157
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
158
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
159
|
+
composer().setText("hello");
|
|
160
|
+
composer().send();
|
|
161
|
+
});
|
|
162
|
+
if (order === "after") await act(async () => successfulUpload.resolve());
|
|
163
|
+
await act(async () => failedUpload.reject(new Error("upload failed")));
|
|
164
|
+
expect(composer().getState().text).toBe(
|
|
165
|
+
type === "edit" || order === "after" ? "hello" : "",
|
|
166
|
+
);
|
|
167
|
+
if (order === "before") {
|
|
168
|
+
expect(composer().getState().canSend).toBe(false);
|
|
169
|
+
act(() => composer().send());
|
|
170
|
+
expect(send).toHaveBeenCalledTimes(2);
|
|
171
|
+
await act(async () => successfulUpload.resolve());
|
|
172
|
+
}
|
|
173
|
+
await waitFor(() => expect(composer().getState().canSend).toBe(true));
|
|
174
|
+
expect(consoleError).toHaveBeenCalled();
|
|
175
|
+
send.mockImplementation(async (attachment) => {
|
|
176
|
+
if (attachment.name === "a") throw new Error("Already consumed");
|
|
177
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
178
|
+
});
|
|
179
|
+
await act(async () => composer().send());
|
|
180
|
+
|
|
181
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
182
|
+
"a",
|
|
183
|
+
"b",
|
|
184
|
+
"b",
|
|
185
|
+
]);
|
|
186
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
187
|
+
expect(onNew.mock.calls[0]![0]).toMatchObject({
|
|
188
|
+
content: [{ type: "text", text: "hello" }],
|
|
189
|
+
attachments: [
|
|
190
|
+
{
|
|
191
|
+
id: "a",
|
|
192
|
+
status: { type: "complete" },
|
|
193
|
+
content: [{ type: "text", text: "a" }],
|
|
194
|
+
},
|
|
195
|
+
{ id: "b", status: { type: "complete" } },
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
expect(composer().getState().attachments).toEqual(
|
|
199
|
+
type === "thread"
|
|
200
|
+
? []
|
|
201
|
+
: expect.arrayContaining([
|
|
202
|
+
expect.objectContaining({ id: "a" }),
|
|
203
|
+
expect.objectContaining({ id: "b" }),
|
|
204
|
+
]),
|
|
205
|
+
);
|
|
206
|
+
expect(remove).not.toHaveBeenCalled();
|
|
207
|
+
},
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
it.each(["remove", "clearAttachments", "reset"] as const)(
|
|
211
|
+
"keeps retained uploads removable after failure with %s",
|
|
212
|
+
async (action) => {
|
|
213
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
214
|
+
const { composer, successfulUpload, failedUpload, remove, onNew } =
|
|
215
|
+
setupPartialSend();
|
|
216
|
+
await act(async () => {
|
|
217
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
218
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
219
|
+
composer().send();
|
|
220
|
+
successfulUpload.resolve();
|
|
221
|
+
failedUpload.reject(new Error("upload failed"));
|
|
222
|
+
});
|
|
223
|
+
await waitFor(() => expect(composer().getState().canSend).toBe(true));
|
|
224
|
+
await act(async () => {
|
|
225
|
+
if (action === "remove")
|
|
226
|
+
await composer().attachment({ id: "a" }).remove();
|
|
227
|
+
else await composer()[action]();
|
|
228
|
+
});
|
|
229
|
+
expect(remove).toHaveBeenCalledWith(expect.objectContaining({ id: "a" }));
|
|
230
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
231
|
+
},
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
it.each(["before", "after"])(
|
|
235
|
+
"reuses a retained upload when a sibling fails %s it finishes and removal fails",
|
|
236
|
+
async (order) => {
|
|
237
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
238
|
+
const { composer, successfulUpload, failedUpload, send, remove, onNew } =
|
|
239
|
+
setupPartialSend();
|
|
240
|
+
remove.mockRejectedValue(new Error("remove failed"));
|
|
241
|
+
await act(async () => {
|
|
242
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
243
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
244
|
+
composer().send();
|
|
245
|
+
if (order === "after") successfulUpload.resolve();
|
|
246
|
+
failedUpload.reject(new Error("upload failed"));
|
|
247
|
+
});
|
|
248
|
+
if (order === "before") {
|
|
249
|
+
await act(async () => successfulUpload.resolve());
|
|
250
|
+
}
|
|
251
|
+
await waitFor(() => expect(composer().getState().canSend).toBe(true));
|
|
252
|
+
await act(async () => {
|
|
253
|
+
await expect(
|
|
254
|
+
composer().attachment({ id: "a" }).remove(),
|
|
255
|
+
).rejects.toThrow("remove failed");
|
|
256
|
+
});
|
|
257
|
+
send.mockImplementation(async (attachment) => {
|
|
258
|
+
if (attachment.name === "a") throw new Error("Already consumed");
|
|
259
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
260
|
+
});
|
|
261
|
+
await act(async () => composer().send());
|
|
262
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
263
|
+
"a",
|
|
264
|
+
"b",
|
|
265
|
+
"b",
|
|
266
|
+
]);
|
|
267
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
268
|
+
expect(onNew.mock.calls[0]![0].attachments).toHaveLength(2);
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
it("does not dispatch an attachment whose removal is still pending", async () => {
|
|
273
|
+
const removal = deferred();
|
|
274
|
+
const { composer, successfulUpload, failedUpload, remove, onNew } =
|
|
275
|
+
setupPartialSend();
|
|
276
|
+
remove.mockReturnValue(removal.promise);
|
|
277
|
+
await act(async () => {
|
|
278
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
279
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
280
|
+
composer().send();
|
|
281
|
+
});
|
|
282
|
+
let removing!: Promise<void>;
|
|
283
|
+
await act(async () => {
|
|
284
|
+
removing = composer().attachment({ id: "a" }).remove();
|
|
285
|
+
successfulUpload.resolve();
|
|
286
|
+
failedUpload.resolve();
|
|
287
|
+
});
|
|
288
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
289
|
+
expect(onNew.mock.calls[0]![0].attachments).toMatchObject([{ id: "b" }]);
|
|
290
|
+
await act(async () => {
|
|
291
|
+
removal.resolve();
|
|
292
|
+
await removing;
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("renders in-flight submission attachments as a thread message", async () => {
|
|
297
|
+
const { aui, composer, successfulUpload, failedUpload, onNew } =
|
|
298
|
+
setupPartialSend();
|
|
299
|
+
await act(async () => {
|
|
300
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
301
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
302
|
+
composer().setText("hello");
|
|
303
|
+
composer().send();
|
|
304
|
+
});
|
|
305
|
+
expect(aui().thread().getState().messages).toMatchObject([
|
|
306
|
+
{
|
|
307
|
+
attachments: [],
|
|
308
|
+
content: [{ type: "text", text: "hello" }],
|
|
309
|
+
submission: {
|
|
310
|
+
text: "hello",
|
|
311
|
+
attachments: [{ id: "a" }, { id: "b" }],
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
]);
|
|
315
|
+
expect(
|
|
316
|
+
aui().thread().message({ index: 0 }).attachment({ id: "a" }).getState(),
|
|
317
|
+
).toMatchObject({ id: "a" });
|
|
318
|
+
await act(async () => {
|
|
319
|
+
successfulUpload.resolve();
|
|
320
|
+
failedUpload.resolve();
|
|
321
|
+
});
|
|
322
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
323
|
+
expect(onNew.mock.calls[0]![0].attachments).toMatchObject([
|
|
324
|
+
{ id: "a" },
|
|
325
|
+
{ id: "b" },
|
|
326
|
+
]);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("does not dispatch an attachment whose removal was pending when send started", async () => {
|
|
330
|
+
const removal = deferred();
|
|
331
|
+
const { composer, successfulUpload, failedUpload, send, remove, onNew } =
|
|
332
|
+
setupPartialSend();
|
|
333
|
+
remove.mockReturnValue(removal.promise);
|
|
334
|
+
await act(async () => {
|
|
335
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
336
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
337
|
+
});
|
|
338
|
+
let removing!: Promise<void>;
|
|
339
|
+
await act(async () => {
|
|
340
|
+
removing = composer().attachment({ id: "a" }).remove();
|
|
341
|
+
});
|
|
342
|
+
await act(async () => {
|
|
343
|
+
composer().send();
|
|
344
|
+
successfulUpload.resolve();
|
|
345
|
+
failedUpload.resolve();
|
|
346
|
+
});
|
|
347
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
348
|
+
"b",
|
|
349
|
+
]);
|
|
350
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
351
|
+
expect(onNew.mock.calls[0]![0].attachments).toMatchObject([{ id: "b" }]);
|
|
352
|
+
await act(async () => {
|
|
353
|
+
removal.resolve();
|
|
354
|
+
await removing;
|
|
355
|
+
});
|
|
356
|
+
expect(composer().getState().attachments).toEqual([]);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it.each(["reset", "cancel"] as const)(
|
|
360
|
+
"does not dispatch an old edit or unlock a newer send after %s",
|
|
361
|
+
async (action) => {
|
|
362
|
+
const { composer, successfulUpload, failedUpload, send, onNew } =
|
|
363
|
+
setupPartialSend("edit");
|
|
364
|
+
await act(async () => {
|
|
365
|
+
composer().beginEdit();
|
|
366
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
367
|
+
composer().send();
|
|
368
|
+
await composer()[action]();
|
|
369
|
+
if (action === "cancel") composer().beginEdit();
|
|
370
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
371
|
+
composer().send();
|
|
372
|
+
successfulUpload.resolve();
|
|
373
|
+
});
|
|
374
|
+
expect(composer().getState().canSend).toBe(false);
|
|
375
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
376
|
+
expect(send).toHaveBeenCalledTimes(2);
|
|
377
|
+
await act(async () => failedUpload.resolve());
|
|
378
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
379
|
+
expect(onNew.mock.calls[0]![0].attachments).toMatchObject([{ id: "b" }]);
|
|
380
|
+
},
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
it.each(["clearAttachments", "reset"] as const)(
|
|
384
|
+
"handles an attachment replaced with the same ID after %s",
|
|
385
|
+
async (action) => {
|
|
386
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
387
|
+
const { composer, successfulUpload, failedUpload, send, onNew } =
|
|
388
|
+
setupPartialSend();
|
|
389
|
+
await act(async () => {
|
|
390
|
+
await composer().addAttachment(new File(["old"], "a"));
|
|
391
|
+
await composer().addAttachment(new File(["b"], "b"));
|
|
392
|
+
composer().send();
|
|
393
|
+
failedUpload.reject(new Error("upload failed"));
|
|
394
|
+
});
|
|
395
|
+
await act(async () => {
|
|
396
|
+
await composer()[action]();
|
|
397
|
+
await composer().addAttachment(new File(["replacement"], "a"));
|
|
398
|
+
successfulUpload.resolve();
|
|
399
|
+
});
|
|
400
|
+
await waitFor(() => expect(composer().getState().canSend).toBe(true));
|
|
401
|
+
if (action === "clearAttachments") {
|
|
402
|
+
send.mockImplementation(async (attachment) => {
|
|
403
|
+
if (attachment.name === "a") throw new Error("Already consumed");
|
|
404
|
+
return { ...attachment, status: { type: "complete" }, content: [] };
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
await act(async () => composer().send());
|
|
408
|
+
expect(send.mock.calls.map(([attachment]) => attachment.name)).toEqual([
|
|
409
|
+
"a",
|
|
410
|
+
"b",
|
|
411
|
+
action === "clearAttachments" ? "b" : "a",
|
|
412
|
+
]);
|
|
413
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
414
|
+
expect(onNew.mock.calls[0]![0].attachments).toHaveLength(
|
|
415
|
+
action === "clearAttachments" ? 2 : 1,
|
|
416
|
+
);
|
|
417
|
+
},
|
|
418
|
+
);
|
|
419
|
+
|
|
79
420
|
describe.each(["clearAttachments", "reset"] as const)(
|
|
80
421
|
"%s cleanup",
|
|
81
422
|
(method) => {
|
|
@@ -243,12 +584,12 @@ describe("ExternalThread attachments", () => {
|
|
|
243
584
|
|
|
244
585
|
it("preserves foreign files that expose content", async () => {
|
|
245
586
|
const aui = renderThread();
|
|
246
|
-
const foreignFile =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
587
|
+
const foreignFile = Object.assign(
|
|
588
|
+
new File([""], "photo.png", { type: "image/png" }),
|
|
589
|
+
{
|
|
590
|
+
content: [{ type: "text", text: "implementation detail" }],
|
|
591
|
+
},
|
|
592
|
+
);
|
|
252
593
|
|
|
253
594
|
await act(() => aui().thread.composer().addAttachment(foreignFile));
|
|
254
595
|
|
|
@@ -375,7 +716,7 @@ describe("ExternalThread attachments", () => {
|
|
|
375
716
|
|
|
376
717
|
it("preserves composer state while attachments are prepared for send", async () => {
|
|
377
718
|
let resolveSend!: (attachment: CompleteAttachment) => void;
|
|
378
|
-
const onNew = vi.fn();
|
|
719
|
+
const onNew = vi.fn<NonNullable<ExternalThreadProps["onNew"]>>();
|
|
379
720
|
const file = new File(["data"], "notes.txt", { type: "text/plain" });
|
|
380
721
|
const adapter = {
|
|
381
722
|
accept: "*",
|
|
@@ -403,10 +744,10 @@ describe("ExternalThread attachments", () => {
|
|
|
403
744
|
act(() => {
|
|
404
745
|
composer().setText("first message");
|
|
405
746
|
composer().setRole("assistant");
|
|
406
|
-
composer().setRunConfig({ model: "model-a" });
|
|
747
|
+
composer().setRunConfig({ custom: { model: "model-a" } });
|
|
407
748
|
composer().send();
|
|
408
749
|
composer().setRole("system");
|
|
409
|
-
composer().setRunConfig({ model: "model-b" });
|
|
750
|
+
composer().setRunConfig({ custom: { model: "model-b" } });
|
|
410
751
|
});
|
|
411
752
|
await act(async () => {
|
|
412
753
|
resolveSend({
|
|
@@ -422,7 +763,7 @@ describe("ExternalThread attachments", () => {
|
|
|
422
763
|
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(1));
|
|
423
764
|
expect(onNew.mock.calls[0]![0]).toMatchObject({
|
|
424
765
|
role: "assistant",
|
|
425
|
-
runConfig: { model: "model-a" },
|
|
766
|
+
runConfig: { custom: { model: "model-a" } },
|
|
426
767
|
});
|
|
427
768
|
});
|
|
428
769
|
|
|
@@ -678,6 +1019,77 @@ describe("ExternalThread attachments", () => {
|
|
|
678
1019
|
expect(drainedAfterSend).not.toHaveBeenCalled();
|
|
679
1020
|
});
|
|
680
1021
|
|
|
1022
|
+
it("waits for an attachment still uploading in add() before sending it", async () => {
|
|
1023
|
+
let finishUpload!: () => void;
|
|
1024
|
+
const onNew = vi.fn();
|
|
1025
|
+
const file = new File(["data"], "notes.txt", { type: "text/plain" });
|
|
1026
|
+
const attachment = {
|
|
1027
|
+
id: "att-1",
|
|
1028
|
+
type: "file",
|
|
1029
|
+
name: file.name,
|
|
1030
|
+
contentType: file.type,
|
|
1031
|
+
file,
|
|
1032
|
+
};
|
|
1033
|
+
const send = vi.fn(async (pending: PendingAttachment) => ({
|
|
1034
|
+
...pending,
|
|
1035
|
+
status: { type: "complete" as const },
|
|
1036
|
+
content: [],
|
|
1037
|
+
}));
|
|
1038
|
+
const aui = renderThreadWithProps({
|
|
1039
|
+
attachmentAdapter: {
|
|
1040
|
+
accept: "*",
|
|
1041
|
+
async *add() {
|
|
1042
|
+
yield {
|
|
1043
|
+
...attachment,
|
|
1044
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1045
|
+
} satisfies PendingAttachment;
|
|
1046
|
+
await new Promise<void>((resolve) => {
|
|
1047
|
+
finishUpload = resolve;
|
|
1048
|
+
});
|
|
1049
|
+
yield {
|
|
1050
|
+
...attachment,
|
|
1051
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1052
|
+
} satisfies PendingAttachment;
|
|
1053
|
+
},
|
|
1054
|
+
send,
|
|
1055
|
+
remove: async () => {},
|
|
1056
|
+
},
|
|
1057
|
+
onNew,
|
|
1058
|
+
});
|
|
1059
|
+
const composer = () => aui().thread.composer();
|
|
1060
|
+
|
|
1061
|
+
let adding!: Promise<void>;
|
|
1062
|
+
act(() => {
|
|
1063
|
+
adding = composer().addAttachment(file);
|
|
1064
|
+
});
|
|
1065
|
+
await waitFor(() =>
|
|
1066
|
+
expect(composer().getState().attachments[0]?.status.type).toBe("running"),
|
|
1067
|
+
);
|
|
1068
|
+
|
|
1069
|
+
await act(async () => {
|
|
1070
|
+
composer().setText("hello");
|
|
1071
|
+
composer().send();
|
|
1072
|
+
});
|
|
1073
|
+
expect(send).not.toHaveBeenCalled();
|
|
1074
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
1075
|
+
|
|
1076
|
+
await act(async () => {
|
|
1077
|
+
finishUpload();
|
|
1078
|
+
await adding;
|
|
1079
|
+
});
|
|
1080
|
+
await waitFor(() => expect(onNew).toHaveBeenCalledTimes(1));
|
|
1081
|
+
|
|
1082
|
+
expect(send.mock.calls[0]![0].status).toEqual({
|
|
1083
|
+
type: "requires-action",
|
|
1084
|
+
reason: "composer-send",
|
|
1085
|
+
});
|
|
1086
|
+
expect(onNew.mock.calls[0]![0]).toMatchObject({
|
|
1087
|
+
content: [{ type: "text", text: "hello" }],
|
|
1088
|
+
attachments: [{ id: "att-1", status: { type: "complete" } }],
|
|
1089
|
+
});
|
|
1090
|
+
expect(composer().getState().attachments).toHaveLength(0);
|
|
1091
|
+
});
|
|
1092
|
+
|
|
681
1093
|
it("routes edit-composer attachments through the adapter", async () => {
|
|
682
1094
|
const add = vi.fn(async ({ file }: { file: File }) => ({
|
|
683
1095
|
id: "att-edit",
|
|
@@ -876,6 +1288,45 @@ describe("ExternalThread attachments", () => {
|
|
|
876
1288
|
});
|
|
877
1289
|
|
|
878
1290
|
describe("cancelled edit sessions", () => {
|
|
1291
|
+
it("sends a prefilled attachment again after cancelling its removal in an earlier edit", async () => {
|
|
1292
|
+
const attachment: CompleteAttachment = {
|
|
1293
|
+
id: "saved",
|
|
1294
|
+
type: "file",
|
|
1295
|
+
name: "saved.txt",
|
|
1296
|
+
content: [],
|
|
1297
|
+
status: { type: "complete" },
|
|
1298
|
+
};
|
|
1299
|
+
const onEdit = vi.fn();
|
|
1300
|
+
const send = vi.fn();
|
|
1301
|
+
const aui = renderThreadWithProps({
|
|
1302
|
+
messages: [
|
|
1303
|
+
{
|
|
1304
|
+
id: "u1",
|
|
1305
|
+
role: "user",
|
|
1306
|
+
createdAt: new Date(0),
|
|
1307
|
+
content: [{ type: "text", text: "hello" }],
|
|
1308
|
+
attachments: [attachment],
|
|
1309
|
+
metadata: { custom: {} },
|
|
1310
|
+
},
|
|
1311
|
+
],
|
|
1312
|
+
onEdit,
|
|
1313
|
+
attachmentAdapter: { accept: "*", add: vi.fn(), send, remove: vi.fn() },
|
|
1314
|
+
});
|
|
1315
|
+
const composer = () => aui().thread.message({ id: "u1" }).composer();
|
|
1316
|
+
await act(async () => {
|
|
1317
|
+
composer().beginEdit();
|
|
1318
|
+
});
|
|
1319
|
+
await act(async () => {
|
|
1320
|
+
await composer().attachment({ id: "saved" }).remove();
|
|
1321
|
+
composer().cancel();
|
|
1322
|
+
composer().beginEdit();
|
|
1323
|
+
composer().send();
|
|
1324
|
+
});
|
|
1325
|
+
expect(onEdit).toHaveBeenCalledOnce();
|
|
1326
|
+
expect(onEdit.mock.calls[0]![0].attachments).toEqual([attachment]);
|
|
1327
|
+
expect(send).not.toHaveBeenCalled();
|
|
1328
|
+
});
|
|
1329
|
+
|
|
879
1330
|
const editSetup = (
|
|
880
1331
|
add: (arg: { file: File }) => Promise<PendingAttachment>,
|
|
881
1332
|
) =>
|
|
@@ -931,8 +1382,8 @@ describe("cancelled edit sessions", () => {
|
|
|
931
1382
|
name: "notes.txt",
|
|
932
1383
|
contentType: "text/plain",
|
|
933
1384
|
file: new File(["data"], "notes.txt", { type: "text/plain" }),
|
|
934
|
-
status: { type: "
|
|
935
|
-
}
|
|
1385
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1386
|
+
});
|
|
936
1387
|
await addPromise.catch(() => {});
|
|
937
1388
|
});
|
|
938
1389
|
|
|
@@ -964,15 +1415,14 @@ describe("cancelled edit sessions", () => {
|
|
|
964
1415
|
onEdit: () => {},
|
|
965
1416
|
attachmentAdapter: {
|
|
966
1417
|
accept: "*",
|
|
967
|
-
add: async ({ file }: { file: File }) =>
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
}) as PendingAttachment,
|
|
1418
|
+
add: async ({ file }: { file: File }) => ({
|
|
1419
|
+
id: "pending-1",
|
|
1420
|
+
type: "document",
|
|
1421
|
+
name: file.name,
|
|
1422
|
+
contentType: file.type,
|
|
1423
|
+
file,
|
|
1424
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1425
|
+
}),
|
|
976
1426
|
send: async () => ({}) as never,
|
|
977
1427
|
remove,
|
|
978
1428
|
},
|
|
@@ -1037,8 +1487,8 @@ describe("cancelled edit sessions", () => {
|
|
|
1037
1487
|
name: "notes.txt",
|
|
1038
1488
|
contentType: "text/plain",
|
|
1039
1489
|
file: new File(["data"], "notes.txt", { type: "text/plain" }),
|
|
1040
|
-
status: { type: "
|
|
1041
|
-
}
|
|
1490
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1491
|
+
});
|
|
1042
1492
|
await addPromise;
|
|
1043
1493
|
});
|
|
1044
1494
|
|
|
@@ -1047,3 +1497,290 @@ describe("cancelled edit sessions", () => {
|
|
|
1047
1497
|
]);
|
|
1048
1498
|
});
|
|
1049
1499
|
});
|
|
1500
|
+
|
|
1501
|
+
describe("attachment sends and the client lifetime", () => {
|
|
1502
|
+
afterEach(() => {
|
|
1503
|
+
vi.restoreAllMocks();
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
const userMessage: ExternalThreadMessage = {
|
|
1507
|
+
id: "u1",
|
|
1508
|
+
role: "user",
|
|
1509
|
+
content: [{ type: "text", text: "original" }],
|
|
1510
|
+
attachments: [],
|
|
1511
|
+
createdAt: new Date(0),
|
|
1512
|
+
metadata: { custom: {} },
|
|
1513
|
+
};
|
|
1514
|
+
|
|
1515
|
+
const renderOwnedThread = (props: Partial<ExternalThreadProps>) => {
|
|
1516
|
+
const captured: {
|
|
1517
|
+
aui?: ReturnType<typeof useAui>;
|
|
1518
|
+
destroySignal?: AbortSignal | undefined;
|
|
1519
|
+
} = {};
|
|
1520
|
+
const Capture: FC = () => {
|
|
1521
|
+
captured.aui = useAui();
|
|
1522
|
+
captured.destroySignal = useAssistantClientDestroySignal();
|
|
1523
|
+
return null;
|
|
1524
|
+
};
|
|
1525
|
+
const Chat: FC = () => (
|
|
1526
|
+
<AuiProvider
|
|
1527
|
+
config={AuiConfig({
|
|
1528
|
+
thread: ExternalThread({ messages: [], isRunning: false, ...props }),
|
|
1529
|
+
})}
|
|
1530
|
+
>
|
|
1531
|
+
<Capture />
|
|
1532
|
+
</AuiProvider>
|
|
1533
|
+
);
|
|
1534
|
+
const App: FC<{ hidden: boolean }> = ({ hidden }) => (
|
|
1535
|
+
<Activity mode={hidden ? "hidden" : "visible"}>
|
|
1536
|
+
<Chat />
|
|
1537
|
+
</Activity>
|
|
1538
|
+
);
|
|
1539
|
+
const view = render(<App hidden={false} />);
|
|
1540
|
+
return {
|
|
1541
|
+
aui: () => captured.aui!,
|
|
1542
|
+
destroyListeners: () =>
|
|
1543
|
+
getEventListeners(captured.destroySignal!, "abort").length,
|
|
1544
|
+
hide: () => act(async () => view.rerender(<App hidden />)),
|
|
1545
|
+
reveal: () => act(async () => view.rerender(<App hidden={false} />)),
|
|
1546
|
+
destroy: async () => {
|
|
1547
|
+
view.unmount();
|
|
1548
|
+
// The owner's destroy signal aborts in a microtask after the unmount.
|
|
1549
|
+
await act(async () => {});
|
|
1550
|
+
},
|
|
1551
|
+
};
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
const slowAdapter = ({ honorsAbort = false } = {}) => {
|
|
1555
|
+
const upload = deferred();
|
|
1556
|
+
const signals: (AbortSignal | undefined)[] = [];
|
|
1557
|
+
const send = vi.fn(
|
|
1558
|
+
(attachment: PendingAttachment, options?: { signal?: AbortSignal }) =>
|
|
1559
|
+
new Promise<CompleteAttachment>((resolve, reject) => {
|
|
1560
|
+
const signal = options?.signal;
|
|
1561
|
+
signals.push(signal);
|
|
1562
|
+
if (honorsAbort)
|
|
1563
|
+
signal?.addEventListener("abort", () => reject(signal.reason));
|
|
1564
|
+
void upload.promise.then(() =>
|
|
1565
|
+
resolve({
|
|
1566
|
+
...attachment,
|
|
1567
|
+
status: { type: "complete" },
|
|
1568
|
+
content: [],
|
|
1569
|
+
}),
|
|
1570
|
+
);
|
|
1571
|
+
}),
|
|
1572
|
+
);
|
|
1573
|
+
const adapter: AttachmentAdapter = {
|
|
1574
|
+
accept: "*",
|
|
1575
|
+
add: async ({ file }) => ({
|
|
1576
|
+
id: file.name,
|
|
1577
|
+
type: "file",
|
|
1578
|
+
name: file.name,
|
|
1579
|
+
file,
|
|
1580
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1581
|
+
}),
|
|
1582
|
+
remove: async () => {},
|
|
1583
|
+
send,
|
|
1584
|
+
};
|
|
1585
|
+
return { adapter, upload, send, signals };
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
it.each([
|
|
1589
|
+
["thread", "rejects on abort"],
|
|
1590
|
+
["thread", "ignores the abort"],
|
|
1591
|
+
["edit", "rejects on abort"],
|
|
1592
|
+
["edit", "ignores the abort"],
|
|
1593
|
+
] as const)(
|
|
1594
|
+
"aborts the %s composer's send and never dispatches it once the client is destroyed, when the adapter %s",
|
|
1595
|
+
async (type, behavior) => {
|
|
1596
|
+
const consoleError = vi
|
|
1597
|
+
.spyOn(console, "error")
|
|
1598
|
+
.mockImplementation(() => {});
|
|
1599
|
+
const { adapter, upload, send, signals } = slowAdapter({
|
|
1600
|
+
honorsAbort: behavior === "rejects on abort",
|
|
1601
|
+
});
|
|
1602
|
+
const onNew = vi.fn();
|
|
1603
|
+
const onEdit = vi.fn();
|
|
1604
|
+
const thread = renderOwnedThread({
|
|
1605
|
+
messages: type === "edit" ? [userMessage] : [],
|
|
1606
|
+
onNew,
|
|
1607
|
+
onEdit,
|
|
1608
|
+
attachmentAdapter: adapter,
|
|
1609
|
+
});
|
|
1610
|
+
const composer = () =>
|
|
1611
|
+
type === "edit"
|
|
1612
|
+
? thread.aui().thread.message({ id: "u1" }).composer()
|
|
1613
|
+
: thread.aui().thread.composer();
|
|
1614
|
+
await act(async () => {
|
|
1615
|
+
if (type === "edit") composer().beginEdit();
|
|
1616
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
1617
|
+
composer().setText("hello");
|
|
1618
|
+
composer().send();
|
|
1619
|
+
});
|
|
1620
|
+
expect(send).toHaveBeenCalledOnce();
|
|
1621
|
+
expect(signals[0]?.aborted).toBe(false);
|
|
1622
|
+
|
|
1623
|
+
await thread.destroy();
|
|
1624
|
+
expect(signals[0]?.aborted).toBe(true);
|
|
1625
|
+
await act(async () => upload.resolve());
|
|
1626
|
+
|
|
1627
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
1628
|
+
expect(onEdit).not.toHaveBeenCalled();
|
|
1629
|
+
expect(consoleError).not.toHaveBeenCalled();
|
|
1630
|
+
},
|
|
1631
|
+
);
|
|
1632
|
+
|
|
1633
|
+
it("finishes a send while the client is hidden", async () => {
|
|
1634
|
+
const { adapter, upload, signals } = slowAdapter();
|
|
1635
|
+
const onNew = vi.fn();
|
|
1636
|
+
const thread = renderOwnedThread({ onNew, attachmentAdapter: adapter });
|
|
1637
|
+
const composer = () => thread.aui().thread.composer();
|
|
1638
|
+
await act(async () => {
|
|
1639
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
1640
|
+
composer().setText("hello");
|
|
1641
|
+
composer().send();
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
await thread.hide();
|
|
1645
|
+
await act(async () => upload.resolve());
|
|
1646
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
1647
|
+
expect(signals[0]?.aborted).toBe(false);
|
|
1648
|
+
|
|
1649
|
+
await thread.reveal();
|
|
1650
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
1651
|
+
expect(composer().getState().submission).toBeUndefined();
|
|
1652
|
+
});
|
|
1653
|
+
|
|
1654
|
+
it("never calls send for an upload that finishes after the client is destroyed", async () => {
|
|
1655
|
+
const finishUpload = deferred();
|
|
1656
|
+
const onNew = vi.fn();
|
|
1657
|
+
const send = vi.fn();
|
|
1658
|
+
const file = new File(["data"], "notes.txt", { type: "text/plain" });
|
|
1659
|
+
const attachment = { id: "att-1", type: "file", name: file.name, file };
|
|
1660
|
+
const thread = renderOwnedThread({
|
|
1661
|
+
onNew,
|
|
1662
|
+
attachmentAdapter: {
|
|
1663
|
+
accept: "*",
|
|
1664
|
+
async *add() {
|
|
1665
|
+
yield {
|
|
1666
|
+
...attachment,
|
|
1667
|
+
status: { type: "running", reason: "uploading", progress: 0 },
|
|
1668
|
+
} satisfies PendingAttachment;
|
|
1669
|
+
await finishUpload.promise;
|
|
1670
|
+
yield {
|
|
1671
|
+
...attachment,
|
|
1672
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
1673
|
+
} satisfies PendingAttachment;
|
|
1674
|
+
},
|
|
1675
|
+
send,
|
|
1676
|
+
remove: async () => {},
|
|
1677
|
+
},
|
|
1678
|
+
});
|
|
1679
|
+
const composer = () => thread.aui().thread.composer();
|
|
1680
|
+
let adding!: Promise<void>;
|
|
1681
|
+
act(() => {
|
|
1682
|
+
adding = composer().addAttachment(file);
|
|
1683
|
+
});
|
|
1684
|
+
await waitFor(() =>
|
|
1685
|
+
expect(composer().getState().attachments[0]?.status.type).toBe("running"),
|
|
1686
|
+
);
|
|
1687
|
+
await act(async () => {
|
|
1688
|
+
composer().send();
|
|
1689
|
+
});
|
|
1690
|
+
|
|
1691
|
+
await thread.destroy();
|
|
1692
|
+
await act(async () => {
|
|
1693
|
+
finishUpload.resolve();
|
|
1694
|
+
await adding;
|
|
1695
|
+
});
|
|
1696
|
+
|
|
1697
|
+
expect(send).not.toHaveBeenCalled();
|
|
1698
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
1699
|
+
});
|
|
1700
|
+
|
|
1701
|
+
it("leaves a finished send's signal alone when the client is destroyed later", async () => {
|
|
1702
|
+
const { adapter, upload, signals } = slowAdapter();
|
|
1703
|
+
const onNew = vi.fn();
|
|
1704
|
+
const thread = renderOwnedThread({ onNew, attachmentAdapter: adapter });
|
|
1705
|
+
const composer = () => thread.aui().thread.composer();
|
|
1706
|
+
const listeners = thread.destroyListeners();
|
|
1707
|
+
await act(async () => {
|
|
1708
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
1709
|
+
composer().send();
|
|
1710
|
+
});
|
|
1711
|
+
await act(async () => upload.resolve());
|
|
1712
|
+
expect(onNew).toHaveBeenCalledOnce();
|
|
1713
|
+
expect(thread.destroyListeners()).toBe(listeners);
|
|
1714
|
+
|
|
1715
|
+
await thread.destroy();
|
|
1716
|
+
expect(signals[0]?.aborted).toBe(false);
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1719
|
+
it("never calls the adapter for a send made after the client is destroyed", async () => {
|
|
1720
|
+
const { adapter, send } = slowAdapter();
|
|
1721
|
+
const onNew = vi.fn();
|
|
1722
|
+
const thread = renderOwnedThread({ onNew, attachmentAdapter: adapter });
|
|
1723
|
+
const composer = () => thread.aui().thread.composer();
|
|
1724
|
+
await act(async () => {
|
|
1725
|
+
await composer().addAttachment(new File(["a"], "a"));
|
|
1726
|
+
composer().setText("hello");
|
|
1727
|
+
});
|
|
1728
|
+
|
|
1729
|
+
await thread.destroy();
|
|
1730
|
+
await act(async () => composer().send());
|
|
1731
|
+
|
|
1732
|
+
expect(send).not.toHaveBeenCalled();
|
|
1733
|
+
expect(onNew).not.toHaveBeenCalled();
|
|
1734
|
+
});
|
|
1735
|
+
|
|
1736
|
+
it.each(["the adapter's send", "an upload in add()"] as const)(
|
|
1737
|
+
"releases the destroy signal when a send stalled on %s is cancelled",
|
|
1738
|
+
async (stall) => {
|
|
1739
|
+
const { adapter } = slowAdapter();
|
|
1740
|
+
const file = new File(["a"], "a");
|
|
1741
|
+
const thread = renderOwnedThread({
|
|
1742
|
+
attachmentAdapter:
|
|
1743
|
+
stall === "the adapter's send"
|
|
1744
|
+
? adapter
|
|
1745
|
+
: {
|
|
1746
|
+
...adapter,
|
|
1747
|
+
async *add() {
|
|
1748
|
+
yield {
|
|
1749
|
+
id: file.name,
|
|
1750
|
+
type: "file",
|
|
1751
|
+
name: file.name,
|
|
1752
|
+
file,
|
|
1753
|
+
status: {
|
|
1754
|
+
type: "running",
|
|
1755
|
+
reason: "uploading",
|
|
1756
|
+
progress: 0,
|
|
1757
|
+
},
|
|
1758
|
+
} satisfies PendingAttachment;
|
|
1759
|
+
await new Promise<never>(() => {});
|
|
1760
|
+
},
|
|
1761
|
+
},
|
|
1762
|
+
});
|
|
1763
|
+
const composer = () => thread.aui().thread.composer();
|
|
1764
|
+
const listeners = thread.destroyListeners();
|
|
1765
|
+
act(() => {
|
|
1766
|
+
void composer().addAttachment(file);
|
|
1767
|
+
});
|
|
1768
|
+
await waitFor(() =>
|
|
1769
|
+
expect(composer().getState().attachments).toHaveLength(1),
|
|
1770
|
+
);
|
|
1771
|
+
|
|
1772
|
+
for (let round = 0; round < 3; round++) {
|
|
1773
|
+
await act(async () => {
|
|
1774
|
+
composer().setText("hello");
|
|
1775
|
+
composer().send();
|
|
1776
|
+
});
|
|
1777
|
+
expect(composer().getState().submission).toBeDefined();
|
|
1778
|
+
expect(thread.destroyListeners()).toBe(listeners + 1);
|
|
1779
|
+
await act(async () => composer().cancel());
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
expect(composer().getState().submission).toBeUndefined();
|
|
1783
|
+
expect(thread.destroyListeners()).toBe(listeners);
|
|
1784
|
+
},
|
|
1785
|
+
);
|
|
1786
|
+
});
|