@assistant-ui/core 0.3.20 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/attachment.d.ts +42 -34
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +51 -21
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +1 -3
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +6 -7
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +14 -9
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/speech.d.ts +57 -58
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +16 -2
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/suggestion.d.ts +14 -16
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +54 -51
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +7 -9
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +46 -40
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +17 -3
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +70 -56
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.d.ts +0 -2
- package/dist/internal/duplicate-detection.d.ts.map +1 -1
- package/dist/internal.d.ts +27 -58
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +8 -6
- package/dist/model-context/frame/host.d.ts +19 -21
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +3 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +27 -28
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +6 -0
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.d.ts +19 -21
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/frame/validate.d.ts +3 -0
- package/dist/model-context/frame/validate.d.ts.map +1 -0
- package/dist/model-context/frame/validate.js +26 -0
- package/dist/model-context/frame/validate.js.map +1 -0
- package/dist/model-context/interactable-composer-metadata.d.ts +42 -29
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +30 -6
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry-handles.d.ts +6 -8
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +14 -16
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +13 -14
- package/dist/model-context/tool-call-text.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +10 -11
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +32 -34
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +6 -8
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +23 -25
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +2 -5
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +24 -18
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +58 -25
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -4
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +5 -7
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -3
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts +6 -8
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +2 -4
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +306 -101
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +32 -34
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +2 -1
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/Tools.d.ts +9 -11
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +4 -8
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts +9 -10
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +32 -22
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/index.d.ts +160 -122
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +5 -5
- package/dist/react/interactables-legacy/Interactables.d.ts +1 -3
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +15 -8
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts +6 -8
- package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.js +13 -14
- package/dist/react/interactables-legacy/interactable-model-context.js.map +1 -1
- package/dist/react/interactables-legacy/scopes.d.ts +33 -36
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +6 -8
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useInteractableState.d.ts +6 -7
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -13
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +54 -25
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.d.ts +11 -13
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +12 -4
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts +0 -2
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts +0 -2
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +23 -25
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +4 -6
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +4 -6
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +4 -6
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +3 -4
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts +0 -2
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +37 -24
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +2 -5
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +5 -7
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +2 -5
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +8 -11
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +11 -13
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +2 -3
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +2 -4
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +37 -36
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableState.d.ts +10 -8
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +3 -5
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +5 -6
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +6 -8
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +4 -6
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +2 -4
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +2 -4
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +2 -4
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +3 -5
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts +2 -4
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +2 -4
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +3 -5
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -3
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts +2 -4
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts +4 -6
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts +0 -2
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts +2 -4
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +6 -8
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +4 -4
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +0 -2
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +0 -2
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +2 -4
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +0 -2
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -3
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +5 -7
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +25 -26
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +22 -23
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +10 -9
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +11 -14
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +26 -28
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +16 -6
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +26 -23
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +14 -15
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +120 -117
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +199 -185
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +124 -82
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +6 -8
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -4
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +13 -15
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +54 -56
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +20 -21
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +24 -5
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +22 -23
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +4 -6
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +3 -5
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +3 -5
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +2 -4
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +2 -4
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +2 -4
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +2 -4
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -4
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +5 -7
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +2 -4
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +3 -5
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +5 -1
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +3 -5
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +3 -6
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +209 -219
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +53 -39
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +185 -196
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +13 -4
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +14 -19
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +3 -1
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +8 -9
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +9 -11
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +4 -5
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js +9 -2
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts +7 -9
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.js +4 -1
- package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/types.d.ts +106 -100
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +3 -5
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +17 -6
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +2 -4
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -3
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +5 -7
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +410 -213
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +14 -16
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +8 -4
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +136 -123
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +60 -9
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +9 -10
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +4 -5
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +1 -3
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.js +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +2 -4
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +8 -9
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +14 -17
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +11 -13
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +14 -18
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-store-history-copy.d.ts +25 -0
- package/dist/react/runtimes/external-store-history-copy.d.ts.map +1 -0
- package/dist/react/runtimes/external-store-history-copy.js +148 -0
- package/dist/react/runtimes/external-store-history-copy.js.map +1 -0
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts +2 -4
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +72 -35
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +1 -3
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +26 -37
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +142 -34
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +2 -4
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +1 -3
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +3 -5
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +46 -43
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +8 -11
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +50 -49
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +17 -19
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/react/types/store-augmentation.d.ts +10 -11
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +5 -6
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +28 -29
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +1 -3
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +2 -4
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +26 -28
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +46 -43
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +31 -30
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +207 -193
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +4 -0
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +28 -26
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +22 -0
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +87 -84
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +1 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts +48 -50
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +64 -66
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +73 -76
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +299 -300
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +2 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +8 -10
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +149 -99
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +400 -122
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +120 -108
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +109 -41
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +29 -29
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +10 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +27 -29
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +21 -6
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +14 -16
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +7 -9
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +88 -72
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +63 -65
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +210 -197
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +25 -20
- package/dist/runtime/internal.d.ts.map +1 -0
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +35 -37
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +29 -31
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +1 -1
- package/dist/runtime/queue/queue-item.d.ts +5 -7
- package/dist/runtime/queue/queue-item.d.ts.map +1 -1
- package/dist/runtime/utils/abortable-thread-load.d.ts +7 -8
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.d.ts +13 -11
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.js +24 -2
- package/dist/runtime/utils/attachment-add-operations.js.map +1 -1
- package/dist/runtime/utils/attachment-send-operations.d.ts +12 -0
- package/dist/runtime/utils/attachment-send-operations.d.ts.map +1 -0
- package/dist/runtime/utils/attachment-send-operations.js +34 -0
- package/dist/runtime/utils/attachment-send-operations.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +4 -5
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +3 -5
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +26 -27
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +32 -32
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +3 -3
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +2 -4
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +21 -23
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +50 -51
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +8 -7
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +10 -11
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +6 -8
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +4 -6
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.d.ts +5 -5
- package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.js +22 -2
- package/dist/runtime/utils/stored-message-parts.js.map +1 -1
- package/dist/runtime/utils/streaming-timing.d.ts +19 -21
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +36 -32
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +16 -6
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +4 -5
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.js +31 -4
- package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -1
- package/dist/runtime/utils/tool-call-tree.d.ts +6 -8
- package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
- package/dist/runtime/utils/tool-interactions.d.ts +10 -0
- package/dist/runtime/utils/tool-interactions.d.ts.map +1 -0
- package/dist/runtime/utils/tool-interactions.js +92 -0
- package/dist/runtime/utils/tool-interactions.js.map +1 -0
- package/dist/runtimes/assistant-transport/utils.d.ts +0 -2
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +215 -198
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +5 -6
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js +4 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.d.ts +1 -3
- package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +38 -40
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +2 -2
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +117 -124
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +44 -14
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +3 -5
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +94 -95
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.js +3 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/internal.d.ts +20 -16
- package/dist/runtimes/internal.d.ts.map +1 -0
- package/dist/runtimes/local/local-runtime-core.d.ts +6 -8
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +40 -42
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +40 -42
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +93 -97
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +178 -31
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +1 -3
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +76 -53
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +28 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +11 -13
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +2 -4
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -3
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +33 -29
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +8 -3
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +44 -46
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -1
- package/dist/runtimes/remote-thread-list/title-generation.d.ts +25 -26
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +3 -5
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +111 -112
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +144 -145
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +22 -7
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +7 -9
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/external-thread.d.ts +53 -54
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +1256 -731
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -3
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +2 -4
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +3 -1
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -3
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts +3 -4
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/submission-message.d.ts +8 -0
- package/dist/store/clients/submission-message.d.ts.map +1 -0
- package/dist/store/clients/submission-message.js +22 -0
- package/dist/store/clients/submission-message.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +5 -7
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +10 -9
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +81 -82
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/clients/thread-selection-events.d.ts +0 -2
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +4 -6
- package/dist/store/clients/thread-tasks.d.ts.map +1 -1
- package/dist/store/env.d.ts +0 -2
- package/dist/store/env.d.ts.map +1 -1
- package/dist/store/index.d.ts +33 -36
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +5 -5
- package/dist/store/internal.d.ts +12 -12
- package/dist/store/internal.d.ts.map +1 -0
- package/dist/store/internal.js +2 -2
- package/dist/store/primitive-predicates.d.ts +3 -4
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +9 -4
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +3 -5
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +10 -12
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +65 -62
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.d.ts +0 -2
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +0 -2
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +1 -3
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +3 -5
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +26 -16
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +9 -9
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +121 -113
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +4 -6
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +5 -7
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +3 -5
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +221 -158
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +2 -4
- package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
- package/dist/store/scope-registration.d.ts +28 -29
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/attachment.d.ts +15 -17
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +28 -29
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +141 -128
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +114 -107
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +7 -9
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +49 -45
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +18 -20
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts +10 -12
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +13 -15
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +23 -25
- package/dist/store/scopes/task.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +63 -65
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +192 -194
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +45 -47
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +58 -53
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +35 -7
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/attachment.d.ts +26 -27
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/augmentations.d.ts +4 -4
- package/dist/types/augmentations.d.ts.map +1 -1
- package/dist/types/directive.d.ts +11 -13
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +7 -8
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/message.d.ts +322 -284
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts +2 -4
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +8 -10
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts +0 -2
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +0 -2
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +8 -11
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +10 -12
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +17 -18
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/id.d.ts +0 -2
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/image-media-type.d.ts +0 -2
- package/dist/utils/image-media-type.d.ts.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +0 -2
- package/dist/utils/invoke-user-callback.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +0 -2
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +1 -3
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +1 -3
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.d.ts +2 -3
- package/dist/utils/normalizePartStatus.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.js +3 -2
- package/dist/utils/normalizePartStatus.js.map +1 -1
- package/dist/utils/notify-event-listeners.d.ts +1 -2
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/record.d.ts +0 -2
- package/dist/utils/record.d.ts.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +0 -2
- package/dist/utils/silent-runtime-action.d.ts.map +1 -1
- package/dist/utils/text.d.ts +1 -3
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/wire-media.d.ts +0 -2
- package/dist/utils/wire-media.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/adapters/attachment.test.ts +98 -1
- package/src/adapters/attachment.ts +70 -20
- package/src/adapters/speech.test.ts +94 -0
- package/src/adapters/speech.ts +16 -2
- package/src/adapters/thread-history.ts +16 -5
- package/src/adapters/voice.test.ts +169 -0
- package/src/adapters/voice.ts +25 -4
- package/src/index.ts +14 -2
- package/src/internal.ts +7 -0
- package/src/model-context/frame/host.test.ts +51 -1
- package/src/model-context/frame/host.ts +3 -1
- package/src/model-context/frame/provider.test.ts +61 -0
- package/src/model-context/frame/provider.ts +8 -1
- package/src/model-context/frame/validate.ts +57 -0
- package/src/model-context/interactable-composer-metadata.test.ts +82 -0
- package/src/model-context/interactable-composer-metadata.ts +45 -2
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +594 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +98 -35
- package/src/react/client/Interactables.test.ts +853 -1
- package/src/react/client/Interactables.ts +325 -45
- package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
- package/src/react/client/RemoteThreadList.ts +6 -0
- package/src/react/client/Tools.ts +2 -3
- package/src/react/client/interactable-model-context.test.ts +56 -13
- package/src/react/client/interactable-model-context.ts +48 -23
- package/src/react/index.ts +2 -2
- package/src/react/interactables-legacy/Interactables.test.ts +212 -1
- package/src/react/interactables-legacy/Interactables.ts +25 -14
- package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +33 -0
- package/src/react/primitive-hooks/useSuggestionTrigger.ts +7 -4
- package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +124 -8
- package/src/react/primitives/generativeUI/GenerativeUI.tsx +35 -15
- package/src/react/primitives/message/MessageAttachments.test.tsx +2 -6
- package/src/react/primitives/message/MessageAttachments.tsx +14 -8
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +151 -7
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -6
- package/src/react/primitives/message/MessageParts.test.tsx +84 -0
- package/src/react/primitives/message/MessageParts.tool-interaction.test.tsx +69 -0
- package/src/react/primitives/message/MessageParts.tsx +29 -8
- package/src/react/primitives/thread/ThreadSuggestions.test.tsx +97 -0
- package/src/react/primitives/thread/ThreadSuggestions.tsx +29 -6
- package/src/react/providers/ReadonlyThreadProvider.tsx +2 -2
- package/src/react/providers/TextMessagePartProvider.tsx +3 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +93 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +160 -3
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +38 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +73 -53
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -3
- package/src/react/runtimes/RemoteThreadResource.ts +5 -2
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +3 -1
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +10 -2
- package/src/react/runtimes/assistant-transport/runManager.ts +3 -0
- package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +57 -0
- package/src/react/runtimes/assistant-transport/transport-thread-id.test.tsx +571 -0
- package/src/react/runtimes/assistant-transport/types.ts +9 -1
- package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +10 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +42 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +33 -9
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.integration.test.tsx +289 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.test.tsx +471 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.engagement.test.tsx +330 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +78 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +361 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +571 -216
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +25 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
- package/src/react/runtimes/cloud/auiV0.ts +158 -9
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +352 -1
- package/src/react/runtimes/createMessageConverter.ts +9 -3
- package/src/react/runtimes/external-store-history-copy.ts +223 -0
- package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +76 -1
- package/src/react/runtimes/useExternalStoreRuntime.ts +25 -5
- package/src/react/runtimes/useLocalRuntime.test.tsx +145 -1
- package/src/react/runtimes/useLocalRuntime.ts +8 -5
- package/src/react/types/MessagePartComponentTypes.ts +10 -0
- package/src/react/types/scopes/interactables.ts +3 -0
- package/src/runtime/api/attachment-runtime.ts +10 -5
- package/src/runtime/api/bindings.ts +6 -1
- package/src/runtime/api/composer-runtime.ts +29 -6
- package/src/runtime/api/message-part-runtime.test.ts +215 -0
- package/src/runtime/api/message-part-runtime.ts +40 -0
- package/src/runtime/api/message-runtime.test.ts +112 -2
- package/src/runtime/api/message-runtime.ts +10 -5
- package/src/runtime/api/thread-list-item-runtime.ts +5 -5
- package/src/runtime/api/thread-list-runtime.ts +3 -3
- package/src/runtime/api/thread-runtime.test.ts +59 -0
- package/src/runtime/api/thread-runtime.ts +21 -11
- package/src/runtime/base/base-composer-runtime-core.ts +548 -153
- package/src/runtime/base/base-thread-runtime-core.test.ts +744 -9
- package/src/runtime/base/base-thread-runtime-core.ts +154 -27
- package/src/runtime/base/default-edit-composer-runtime-core.ts +13 -1
- package/src/runtime/base/default-thread-composer-runtime-core.ts +29 -10
- package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +22 -1
- package/src/runtime/utils/attachment-add-operations.ts +45 -2
- package/src/runtime/utils/attachment-send-operations.ts +54 -0
- package/src/runtime/utils/auto-status.test.ts +54 -0
- package/src/runtime/utils/auto-status.ts +3 -10
- package/src/runtime/utils/external-message-conversion.test.ts +48 -0
- package/src/runtime/utils/external-message-conversion.ts +3 -4
- package/src/runtime/utils/message-repository.test.ts +69 -1
- package/src/runtime/utils/message-repository.ts +14 -7
- package/src/runtime/utils/stored-message-parts.ts +43 -1
- package/src/runtime/utils/thread-message-like.test.ts +58 -0
- package/src/runtime/utils/thread-message-like.ts +72 -46
- package/src/runtime/utils/thread-runtime-lifecycle.test.ts +67 -0
- package/src/runtime/utils/thread-runtime-lifecycle.ts +42 -8
- package/src/runtime/utils/tool-interactions.test.ts +193 -0
- package/src/runtime/utils/tool-interactions.ts +147 -0
- package/src/runtimes/external-store/external-store-adapter.ts +22 -1
- package/src/runtimes/external-store/external-store-runtime-core.ts +10 -2
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +2 -2
- package/src/runtimes/external-store/external-store-thread-runtime-core.test.ts +49 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +76 -29
- package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +127 -56
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +10 -1
- package/src/runtimes/local/local-thread-runtime-core.edit-cancellation.test.ts +70 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +1649 -108
- package/src/runtimes/local/local-thread-runtime-core.ts +301 -47
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +53 -1
- package/src/runtimes/remote-thread-list/optimistic-state.ts +8 -3
- package/src/runtimes/tool-invocations/EDGE_CASES.md +19 -4
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +392 -39
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +31 -8
- package/src/store/clients/external-thread.test.ts +145 -0
- package/src/store/clients/external-thread.ts +635 -131
- package/src/store/clients/model-context-client.test.ts +8 -8
- package/src/store/clients/no-op-composer-client.ts +2 -0
- package/src/store/clients/submission-message.ts +27 -0
- package/src/store/clients/thread-message-client.test.ts +39 -0
- package/src/store/clients/thread-message-client.ts +13 -6
- package/src/store/index.ts +2 -2
- package/src/store/internal.ts +1 -0
- package/src/store/primitive-predicates.test.ts +103 -0
- package/src/store/primitive-predicates.ts +15 -3
- package/src/store/runtime-clients/composer-runtime-client.ts +4 -3
- package/src/store/runtime-clients/message-part-runtime-client.test.ts +42 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +4 -0
- package/src/store/runtime-clients/message-runtime-client.ts +5 -0
- package/src/store/runtime-clients/thread-runtime-client.test.tsx +138 -5
- package/src/store/runtime-clients/thread-runtime-client.ts +46 -9
- package/src/store/scopes/composer.ts +22 -4
- package/src/store/scopes/message.ts +8 -0
- package/src/store/scopes/part.ts +8 -0
- package/src/subscribable/subscribable.test.ts +198 -1
- package/src/subscribable/subscribable.ts +49 -7
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
- package/src/tests/auiV0Encode.test.ts +408 -1
- package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
- package/src/tests/base-composer-runtime-core.test.ts +196 -0
- package/src/tests/composer-can-send.test.ts +98 -1
- package/src/tests/composer-submission.test.tsx +796 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +102 -2
- package/src/tests/external-store-thread-list-runtime-core.test.ts +111 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +581 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +186 -0
- package/src/tests/external-thread-attachments.test.tsx +741 -3
- package/src/tests/external-thread-isLast.test.tsx +69 -0
- package/src/tests/get-thread-state-isRunning.test.ts +2 -2
- package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
- package/src/types/message.ts +49 -2
- package/src/utils/normalizePartStatus.ts +14 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -15
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
- package/dist/tests/remote-thread-list-test-helpers.js +0 -59
- package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
3
|
import { act, render, waitFor } from "@testing-library/react";
|
|
4
|
-
import { type FC, StrictMode } from "react";
|
|
4
|
+
import { Activity, type FC, StrictMode, useEffect } from "react";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
import type { AssistantCloud } from "assistant-cloud";
|
|
7
7
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
8
8
|
import type { ChatModelAdapter } from "../../runtime/utils/chat-model-adapter";
|
|
9
9
|
import { AssistantRuntimeProvider } from "../AssistantRuntimeProvider";
|
|
10
10
|
import { useLocalRuntime } from "./useLocalRuntime";
|
|
11
|
+
import type { RealtimeVoiceAdapter } from "../../adapters/voice";
|
|
12
|
+
import type { AssistantRuntime } from "../../runtime/api/assistant-runtime";
|
|
11
13
|
|
|
12
14
|
const chatModel: ChatModelAdapter = {
|
|
13
15
|
run: async () => ({ content: [] }),
|
|
@@ -32,6 +34,148 @@ afterEach(() => {
|
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
describe("useLocalRuntime", () => {
|
|
37
|
+
const createVoiceApp = () => {
|
|
38
|
+
const disconnect = vi.fn();
|
|
39
|
+
let emitTranscript!: (item: RealtimeVoiceAdapter.TranscriptItem) => void;
|
|
40
|
+
const session: RealtimeVoiceAdapter.Session = {
|
|
41
|
+
status: { type: "running" },
|
|
42
|
+
isMuted: false,
|
|
43
|
+
disconnect,
|
|
44
|
+
mute: vi.fn(),
|
|
45
|
+
unmute: vi.fn(),
|
|
46
|
+
onStatusChange: () => () => {},
|
|
47
|
+
onTranscript: (callback) => {
|
|
48
|
+
emitTranscript = callback;
|
|
49
|
+
return () => {};
|
|
50
|
+
},
|
|
51
|
+
onModeChange: () => () => {},
|
|
52
|
+
onVolumeChange: () => () => {},
|
|
53
|
+
};
|
|
54
|
+
const capture: { runtime: AssistantRuntime | null } = { runtime: null };
|
|
55
|
+
let connected = false;
|
|
56
|
+
const App = () => {
|
|
57
|
+
const runtime = useLocalRuntime(chatModel, {
|
|
58
|
+
adapters: { voice: { connect: () => session } },
|
|
59
|
+
});
|
|
60
|
+
capture.runtime = runtime;
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (connected) return;
|
|
63
|
+
connected = true;
|
|
64
|
+
runtime.thread.connectVoice();
|
|
65
|
+
}, [runtime]);
|
|
66
|
+
return (
|
|
67
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
68
|
+
<div />
|
|
69
|
+
</AssistantRuntimeProvider>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
App,
|
|
74
|
+
capture,
|
|
75
|
+
disconnect,
|
|
76
|
+
emitTranscript: (item: RealtimeVoiceAdapter.TranscriptItem) =>
|
|
77
|
+
emitTranscript(item),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
it("keeps voice connected through StrictMode replay and disconnects on unmount", async () => {
|
|
82
|
+
const { App, disconnect } = createVoiceApp();
|
|
83
|
+
|
|
84
|
+
const view = render(
|
|
85
|
+
<StrictMode>
|
|
86
|
+
<App />
|
|
87
|
+
</StrictMode>,
|
|
88
|
+
);
|
|
89
|
+
await act(async () => Promise.resolve());
|
|
90
|
+
expect(disconnect).not.toHaveBeenCalled();
|
|
91
|
+
|
|
92
|
+
view.unmount();
|
|
93
|
+
await act(async () => Promise.resolve());
|
|
94
|
+
expect(disconnect).toHaveBeenCalledOnce();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("keeps voice and the thread through Activity hide and reveal", async () => {
|
|
98
|
+
const { App, capture, disconnect, emitTranscript } = createVoiceApp();
|
|
99
|
+
const renderApp = (mode: "visible" | "hidden") => (
|
|
100
|
+
<Activity mode={mode}>
|
|
101
|
+
<App />
|
|
102
|
+
</Activity>
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const view = render(renderApp("visible"));
|
|
106
|
+
await act(async () => Promise.resolve());
|
|
107
|
+
view.rerender(renderApp("hidden"));
|
|
108
|
+
await act(async () => Promise.resolve());
|
|
109
|
+
view.rerender(renderApp("visible"));
|
|
110
|
+
await act(async () => Promise.resolve());
|
|
111
|
+
|
|
112
|
+
expect(disconnect).not.toHaveBeenCalled();
|
|
113
|
+
expect(capture.runtime!.thread.getState().voice).toBeDefined();
|
|
114
|
+
|
|
115
|
+
act(() =>
|
|
116
|
+
emitTranscript({ role: "user", text: "after reveal", isFinal: true }),
|
|
117
|
+
);
|
|
118
|
+
expect(capture.runtime!.thread.getState().messages).toHaveLength(1);
|
|
119
|
+
|
|
120
|
+
view.unmount();
|
|
121
|
+
await act(async () => Promise.resolve());
|
|
122
|
+
expect(disconnect).toHaveBeenCalledOnce();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("passes the remote id of a fresh Cloud thread to its first run", async () => {
|
|
126
|
+
const cloud = {
|
|
127
|
+
registerSdk: vi.fn(),
|
|
128
|
+
telemetry: { enabled: false },
|
|
129
|
+
threads: {
|
|
130
|
+
list: vi.fn().mockResolvedValue({ threads: [] }),
|
|
131
|
+
create: vi.fn().mockResolvedValue({ thread_id: "remote-thread" }),
|
|
132
|
+
messages: {
|
|
133
|
+
list: vi.fn().mockResolvedValue({ messages: [] }),
|
|
134
|
+
create: vi.fn().mockResolvedValue({ message_id: "message-1" }),
|
|
135
|
+
update: vi.fn().mockResolvedValue(undefined),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
runs: {
|
|
139
|
+
stream: vi.fn().mockResolvedValue(
|
|
140
|
+
new ReadableStream({
|
|
141
|
+
start(controller) {
|
|
142
|
+
controller.close();
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
),
|
|
146
|
+
},
|
|
147
|
+
} as unknown as AssistantCloud;
|
|
148
|
+
const threadIds: (string | undefined)[] = [];
|
|
149
|
+
const run: ChatModelAdapter = {
|
|
150
|
+
run: async ({ unstable_threadId }) => {
|
|
151
|
+
threadIds.push(unstable_threadId);
|
|
152
|
+
return { content: [] };
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
let runtime: ReturnType<typeof useLocalRuntime> | null = null;
|
|
156
|
+
const App = () => {
|
|
157
|
+
runtime = useLocalRuntime(run, { cloud });
|
|
158
|
+
return (
|
|
159
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
160
|
+
<div />
|
|
161
|
+
</AssistantRuntimeProvider>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
render(<App />);
|
|
166
|
+
await waitFor(() => {
|
|
167
|
+
expect(runtime!.threads.mainItem.getState().id).toBeDefined();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
await runtime!.thread.append("hello");
|
|
171
|
+
|
|
172
|
+
await waitFor(() => {
|
|
173
|
+
expect(threadIds).toHaveLength(1);
|
|
174
|
+
});
|
|
175
|
+
expect(cloud.threads.create).toHaveBeenCalledTimes(1);
|
|
176
|
+
expect(threadIds).toEqual(["remote-thread"]);
|
|
177
|
+
});
|
|
178
|
+
|
|
35
179
|
it("enables feedback for Cloud threads", async () => {
|
|
36
180
|
const cloud = makeCloud();
|
|
37
181
|
let runtime: ReturnType<typeof useLocalRuntime> | null = null;
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
} from "../../index";
|
|
7
7
|
import type { LocalRuntimeOptionsBase } from "../../runtimes/local/local-runtime-options";
|
|
8
8
|
import { AssistantRuntimeImpl, LocalRuntimeCore } from "../../internal";
|
|
9
|
-
import {
|
|
9
|
+
import { useAui } from "@assistant-ui/store";
|
|
10
10
|
import { useRemoteThreadListRuntime } from "./useRemoteThreadListRuntime";
|
|
11
11
|
import { useCloudThreadListAdapter } from "./cloud/useCloudThreadListAdapter";
|
|
12
12
|
import { useRuntimeAdapters } from "./RuntimeAdapterProvider";
|
|
@@ -34,15 +34,18 @@ const useLocalThreadRuntime = (
|
|
|
34
34
|
|
|
35
35
|
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const aui = useAui();
|
|
38
38
|
const historyLoadPromiseRef = useRef<Promise<void> | undefined>(undefined);
|
|
39
|
-
threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);
|
|
40
39
|
|
|
40
|
+
// A run reads the id in the microtask after the initialization barrier,
|
|
41
|
+
// before the store has flushed the remote id into React state.
|
|
41
42
|
useEffect(() => {
|
|
42
43
|
runtime.threads
|
|
43
44
|
.getMainThreadRuntimeCore()
|
|
44
|
-
.__internal_setGetThreadId(
|
|
45
|
-
|
|
45
|
+
.__internal_setGetThreadId(
|
|
46
|
+
() => aui.threadListItem.__internal_getRuntime?.().getState().remoteId,
|
|
47
|
+
);
|
|
48
|
+
}, [aui, runtime]);
|
|
46
49
|
|
|
47
50
|
useEffect(() => {
|
|
48
51
|
return () => {
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
ToolApprovalResponse,
|
|
13
13
|
ToolCallMessagePart,
|
|
14
14
|
Unstable_AudioMessagePart,
|
|
15
|
+
Unstable_ToolInteractionInput,
|
|
15
16
|
QuoteInfo,
|
|
16
17
|
} from "../..";
|
|
17
18
|
import type { MessagePartState } from "../..";
|
|
@@ -91,6 +92,15 @@ export type ToolCallMessagePartProps<
|
|
|
91
92
|
* it could not be recorded, so the controls can stay retryable.
|
|
92
93
|
*/
|
|
93
94
|
respondToApproval: (response: ToolApprovalResponse) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Records what the user did in this call's UI on the part, so a stored
|
|
97
|
+
* conversation keeps it. Resolves once recorded, and rejects when the
|
|
98
|
+
* payload is not plain JSON, is over the size limit, or the runtime
|
|
99
|
+
* cannot record interactions; the user's action itself is unaffected.
|
|
100
|
+
*/
|
|
101
|
+
unstable_recordInteraction?:
|
|
102
|
+
| ((input: Unstable_ToolInteractionInput) => Promise<void>)
|
|
103
|
+
| undefined;
|
|
94
104
|
};
|
|
95
105
|
|
|
96
106
|
/** Component used to render a tool-call message part. */
|
|
@@ -59,6 +59,9 @@ export type Unstable_InteractablePersistenceAdapter = {
|
|
|
59
59
|
* Restores previously saved state. Called when the adapter is attached;
|
|
60
60
|
* loaded state seeds app-scoped interactables that have not been locally
|
|
61
61
|
* edited yet (a local edit always wins over a slow load).
|
|
62
|
+
*
|
|
63
|
+
* A different adapter instance represents a different persistence scope.
|
|
64
|
+
* Switching adapters resets app-scoped state before loading the replacement.
|
|
62
65
|
*/
|
|
63
66
|
load?():
|
|
64
67
|
| Unstable_InteractablePersistedState
|
|
@@ -17,25 +17,30 @@ type EditComposerAttachmentState = Attachment & {
|
|
|
17
17
|
readonly source: "edit-composer";
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type
|
|
20
|
+
export type AttachmentRuntimeState =
|
|
21
21
|
| ThreadComposerAttachmentState
|
|
22
22
|
| EditComposerAttachmentState
|
|
23
23
|
| MessageAttachmentState;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use `AttachmentRuntimeState`. From `@assistant-ui/react` 0.16, `AttachmentState` names the attachment state read through `useAuiState`.
|
|
27
|
+
*/
|
|
28
|
+
export type AttachmentState = AttachmentRuntimeState;
|
|
29
|
+
|
|
25
30
|
type AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =
|
|
26
31
|
SubscribableWithState<
|
|
27
|
-
|
|
32
|
+
AttachmentRuntimeState & { source: Source },
|
|
28
33
|
AttachmentRuntimePath & { attachmentSource: Source }
|
|
29
34
|
>;
|
|
30
35
|
|
|
31
|
-
type AttachmentRuntimeSource =
|
|
36
|
+
type AttachmentRuntimeSource = AttachmentRuntimeState["source"];
|
|
32
37
|
|
|
33
38
|
export type AttachmentRuntime<
|
|
34
39
|
TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,
|
|
35
40
|
> = {
|
|
36
41
|
readonly path: AttachmentRuntimePath & { attachmentSource: TSource };
|
|
37
42
|
readonly source: TSource;
|
|
38
|
-
getState():
|
|
43
|
+
getState(): AttachmentRuntimeState & { source: TSource };
|
|
39
44
|
remove(): Promise<void>;
|
|
40
45
|
subscribe(callback: () => void): Unsubscribe;
|
|
41
46
|
};
|
|
@@ -62,7 +67,7 @@ export abstract class AttachmentRuntimeImpl<
|
|
|
62
67
|
this.subscribe = this.subscribe.bind(this);
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
public getState():
|
|
70
|
+
public getState(): AttachmentRuntimeState & { source: Source } {
|
|
66
71
|
return this._core.getState();
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -35,7 +35,7 @@ export type MessageStateBinding = SubscribableWithState<
|
|
|
35
35
|
MessageRuntimePath
|
|
36
36
|
>;
|
|
37
37
|
|
|
38
|
-
export type
|
|
38
|
+
export type ThreadListItemRuntimeState = {
|
|
39
39
|
readonly isMain: boolean;
|
|
40
40
|
/**
|
|
41
41
|
* Whether this thread has a run in progress, including a run that continues
|
|
@@ -50,3 +50,8 @@ export type ThreadListItemState = {
|
|
|
50
50
|
readonly lastMessageAt?: Date | undefined;
|
|
51
51
|
readonly custom?: Record<string, unknown> | undefined;
|
|
52
52
|
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `ThreadListItemRuntimeState`. From `@assistant-ui/react` 0.16, `ThreadListItemState` names the thread list item state read through `useAuiState`.
|
|
56
|
+
*/
|
|
57
|
+
export type ThreadListItemState = ThreadListItemRuntimeState;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import type {
|
|
17
17
|
ComposerRuntimeEventCallback,
|
|
18
18
|
ComposerRuntimeEventType,
|
|
19
|
+
ComposerSubmission,
|
|
19
20
|
DictationState,
|
|
20
21
|
EditComposerRuntimeCore,
|
|
21
22
|
SendOptions,
|
|
@@ -30,7 +31,7 @@ import type { ComposerRuntimePath } from "./paths";
|
|
|
30
31
|
|
|
31
32
|
import {
|
|
32
33
|
type AttachmentRuntime,
|
|
33
|
-
type
|
|
34
|
+
type AttachmentRuntimeState,
|
|
34
35
|
EditComposerAttachmentRuntimeImpl,
|
|
35
36
|
ThreadComposerAttachmentRuntimeImpl,
|
|
36
37
|
} from "./attachment-runtime";
|
|
@@ -73,6 +74,19 @@ type BaseComposerState = {
|
|
|
73
74
|
|
|
74
75
|
/** Messages waiting to be processed. Empty unless the `queue` capability is set. */
|
|
75
76
|
readonly queue: readonly QueueItemState[];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The message this composer sent while its attachments are prepared.
|
|
80
|
+
* Undefined once the runtime has taken it.
|
|
81
|
+
*/
|
|
82
|
+
readonly submission?: ComposerSubmission | undefined;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Messages this composer handed to the runtime that the thread does not
|
|
86
|
+
* show yet, oldest first. The thread keeps rendering each one until the
|
|
87
|
+
* runtime shows the message it became.
|
|
88
|
+
*/
|
|
89
|
+
readonly inTransit?: readonly ComposerSubmission[] | undefined;
|
|
76
90
|
};
|
|
77
91
|
|
|
78
92
|
export type ThreadComposerState = BaseComposerState & {
|
|
@@ -85,7 +99,12 @@ export type EditComposerState = BaseComposerState & {
|
|
|
85
99
|
readonly sourceId: string | null;
|
|
86
100
|
};
|
|
87
101
|
|
|
88
|
-
export type
|
|
102
|
+
export type ComposerRuntimeState = ThreadComposerState | EditComposerState;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use `ComposerRuntimeState`. From `@assistant-ui/react` 0.16, `ComposerState` names the composer state read through `useAuiState`.
|
|
106
|
+
*/
|
|
107
|
+
export type ComposerState = ComposerRuntimeState;
|
|
89
108
|
|
|
90
109
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
91
110
|
const EMPTY_OBJECT = Object.freeze({});
|
|
@@ -108,6 +127,8 @@ const getThreadComposerState = (
|
|
|
108
127
|
dictation: runtime?.dictation,
|
|
109
128
|
quote: runtime?.quote,
|
|
110
129
|
queue: runtime?.queue ?? EMPTY_ARRAY,
|
|
130
|
+
submission: runtime?.submission,
|
|
131
|
+
inTransit: runtime?.inTransit ?? EMPTY_ARRAY,
|
|
111
132
|
|
|
112
133
|
value: runtime?.text ?? "",
|
|
113
134
|
});
|
|
@@ -132,6 +153,8 @@ const getEditComposerState = (
|
|
|
132
153
|
dictation: runtime?.dictation,
|
|
133
154
|
quote: runtime?.quote,
|
|
134
155
|
queue: runtime?.queue ?? EMPTY_ARRAY,
|
|
156
|
+
submission: runtime?.submission,
|
|
157
|
+
inTransit: runtime?.inTransit ?? EMPTY_ARRAY,
|
|
135
158
|
|
|
136
159
|
parentId: runtime?.parentId ?? null,
|
|
137
160
|
sourceId: runtime?.sourceId ?? null,
|
|
@@ -147,7 +170,7 @@ export type ComposerRuntime = {
|
|
|
147
170
|
/**
|
|
148
171
|
* Get the current state of the composer. Includes any data that has been added to the composer.
|
|
149
172
|
*/
|
|
150
|
-
getState():
|
|
173
|
+
getState(): ComposerRuntimeState;
|
|
151
174
|
|
|
152
175
|
/**
|
|
153
176
|
* Add an attachment to the composer. Accepts either a standard File object
|
|
@@ -287,7 +310,7 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
287
310
|
this.unstable_on = this.unstable_on.bind(this);
|
|
288
311
|
}
|
|
289
312
|
|
|
290
|
-
public abstract getState():
|
|
313
|
+
public abstract getState(): ComposerRuntimeState;
|
|
291
314
|
|
|
292
315
|
public setText(text: string) {
|
|
293
316
|
const core = this._core.getState();
|
|
@@ -464,7 +487,7 @@ export class ThreadComposerRuntimeImpl
|
|
|
464
487
|
return {
|
|
465
488
|
...attachment,
|
|
466
489
|
source: "thread-composer",
|
|
467
|
-
} satisfies
|
|
490
|
+
} satisfies AttachmentRuntimeState & { source: "thread-composer" };
|
|
468
491
|
},
|
|
469
492
|
subscribe: (callback) => this._core.subscribe(callback),
|
|
470
493
|
}),
|
|
@@ -552,7 +575,7 @@ export class EditComposerRuntimeImpl
|
|
|
552
575
|
return {
|
|
553
576
|
...attachment,
|
|
554
577
|
source: "edit-composer",
|
|
555
|
-
} satisfies
|
|
578
|
+
} satisfies AttachmentRuntimeState & { source: "edit-composer" };
|
|
556
579
|
},
|
|
557
580
|
subscribe: (callback) => this._core.subscribe(callback),
|
|
558
581
|
}),
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { ThreadRuntimeCore } from "../interfaces/thread-runtime-core";
|
|
3
|
+
import type { MessageStateBinding } from "./bindings";
|
|
4
|
+
import type { MessagePartState } from "./message-part-runtime";
|
|
5
|
+
import { MessagePartRuntimeImpl } from "./message-part-runtime";
|
|
6
|
+
import type { ThreadRuntimeCoreBinding } from "./thread-runtime";
|
|
7
|
+
|
|
8
|
+
const threadPath = {
|
|
9
|
+
ref: "threads.main",
|
|
10
|
+
threadSelector: { type: "main" as const },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const messagePath = {
|
|
14
|
+
...threadPath,
|
|
15
|
+
ref: "threads.main.messages[0]",
|
|
16
|
+
messageSelector: { type: "index" as const, index: 0 },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const partPath = {
|
|
20
|
+
...messagePath,
|
|
21
|
+
ref: "threads.main.messages[0].content[0]",
|
|
22
|
+
messagePartSelector: { type: "index" as const, index: 0 },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const toolPart: MessagePartState = {
|
|
26
|
+
type: "tool-call",
|
|
27
|
+
toolCallId: "call-1",
|
|
28
|
+
toolName: "weather",
|
|
29
|
+
args: {},
|
|
30
|
+
argsText: "{}",
|
|
31
|
+
status: { type: "requires-action", reason: "tool-calls" },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const textPart: MessagePartState = {
|
|
35
|
+
type: "text",
|
|
36
|
+
text: "hello",
|
|
37
|
+
status: { type: "complete" },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const message = {
|
|
41
|
+
id: "message-1",
|
|
42
|
+
role: "assistant" as const,
|
|
43
|
+
createdAt: new Date(0),
|
|
44
|
+
content: [toolPart],
|
|
45
|
+
status: { type: "requires-action" as const, reason: "tool-calls" as const },
|
|
46
|
+
metadata: {
|
|
47
|
+
unstable_state: null,
|
|
48
|
+
unstable_annotations: [],
|
|
49
|
+
unstable_data: [],
|
|
50
|
+
steps: [],
|
|
51
|
+
custom: {},
|
|
52
|
+
},
|
|
53
|
+
parentId: null,
|
|
54
|
+
index: 0,
|
|
55
|
+
isLast: true,
|
|
56
|
+
branchNumber: 1,
|
|
57
|
+
branchCount: 1,
|
|
58
|
+
speech: undefined,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const createRuntime = ({
|
|
62
|
+
part = toolPart,
|
|
63
|
+
core,
|
|
64
|
+
}: {
|
|
65
|
+
part?: MessagePartState;
|
|
66
|
+
core: ThreadRuntimeCore;
|
|
67
|
+
}) => {
|
|
68
|
+
const contentBinding = {
|
|
69
|
+
path: partPath,
|
|
70
|
+
getState: () => part,
|
|
71
|
+
subscribe: () => () => {},
|
|
72
|
+
};
|
|
73
|
+
const messageBinding: MessageStateBinding = {
|
|
74
|
+
path: messagePath,
|
|
75
|
+
getState: () => message,
|
|
76
|
+
subscribe: () => () => {},
|
|
77
|
+
};
|
|
78
|
+
const threadBinding: ThreadRuntimeCoreBinding = {
|
|
79
|
+
path: threadPath,
|
|
80
|
+
getState: () => core,
|
|
81
|
+
subscribe: () => () => {},
|
|
82
|
+
outerSubscribe: () => () => {},
|
|
83
|
+
};
|
|
84
|
+
return new MessagePartRuntimeImpl(
|
|
85
|
+
contentBinding,
|
|
86
|
+
messageBinding,
|
|
87
|
+
threadBinding,
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
describe("MessagePartRuntime interaction recording", () => {
|
|
92
|
+
it("rejects invalid inputs without throwing synchronously", async () => {
|
|
93
|
+
const core = {
|
|
94
|
+
unstable_recordToolInteraction: vi.fn(),
|
|
95
|
+
} as unknown as ThreadRuntimeCore;
|
|
96
|
+
const runtime = createRuntime({ core });
|
|
97
|
+
|
|
98
|
+
const recording = runtime.unstable_recordInteraction({
|
|
99
|
+
type: "action",
|
|
100
|
+
payload: "not an object",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await expect(recording).rejects.toThrow(
|
|
104
|
+
"An action interaction payload must be a JSON object.",
|
|
105
|
+
);
|
|
106
|
+
expect(core.unstable_recordToolInteraction).not.toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("rejects recording on non-tool parts", async () => {
|
|
110
|
+
const core = {
|
|
111
|
+
unstable_recordToolInteraction: vi.fn(),
|
|
112
|
+
} as unknown as ThreadRuntimeCore;
|
|
113
|
+
const runtime = createRuntime({ core, part: textPart });
|
|
114
|
+
|
|
115
|
+
await expect(
|
|
116
|
+
runtime.unstable_recordInteraction({ type: "action", payload: {} }),
|
|
117
|
+
).rejects.toThrow("Tried to record interaction on non-tool message part");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("rejects when the core cannot record tool interactions", async () => {
|
|
121
|
+
const runtime = createRuntime({ core: {} as ThreadRuntimeCore });
|
|
122
|
+
|
|
123
|
+
await expect(
|
|
124
|
+
runtime.unstable_recordInteraction({ type: "action", payload: {} }),
|
|
125
|
+
).rejects.toThrow("Runtime does not support recording tool interactions.");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("delegates stamped interactions with the message and tool call ids", async () => {
|
|
129
|
+
const recordInteraction = vi.fn(async () => {});
|
|
130
|
+
const core = {
|
|
131
|
+
unstable_recordToolInteraction: recordInteraction,
|
|
132
|
+
} as unknown as ThreadRuntimeCore;
|
|
133
|
+
const runtime = createRuntime({ core });
|
|
134
|
+
|
|
135
|
+
await runtime.unstable_recordInteraction({
|
|
136
|
+
type: "action",
|
|
137
|
+
payload: { action: "toggle" },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
expect(recordInteraction).toHaveBeenCalledExactlyOnceWith({
|
|
141
|
+
messageId: "message-1",
|
|
142
|
+
toolCallId: "call-1",
|
|
143
|
+
interaction: {
|
|
144
|
+
type: "action",
|
|
145
|
+
payload: { action: "toggle" },
|
|
146
|
+
occurredAt: expect.any(Number),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("MessagePartRuntime resumeToolCall", () => {
|
|
153
|
+
it("records the accepted human response", () => {
|
|
154
|
+
const resumeToolCall = vi.fn();
|
|
155
|
+
const recordInteraction = vi.fn(async () => {});
|
|
156
|
+
const runtime = createRuntime({
|
|
157
|
+
core: {
|
|
158
|
+
resumeToolCall,
|
|
159
|
+
unstable_recordToolInteraction: recordInteraction,
|
|
160
|
+
} as unknown as ThreadRuntimeCore,
|
|
161
|
+
});
|
|
162
|
+
const payload = { answer: "yes" };
|
|
163
|
+
|
|
164
|
+
runtime.resumeToolCall(payload);
|
|
165
|
+
|
|
166
|
+
expect(resumeToolCall).toHaveBeenCalledExactlyOnceWith({
|
|
167
|
+
toolCallId: "call-1",
|
|
168
|
+
payload,
|
|
169
|
+
});
|
|
170
|
+
expect(recordInteraction).toHaveBeenCalledExactlyOnceWith({
|
|
171
|
+
messageId: "message-1",
|
|
172
|
+
toolCallId: "call-1",
|
|
173
|
+
interaction: {
|
|
174
|
+
type: "human-response",
|
|
175
|
+
payload,
|
|
176
|
+
occurredAt: expect.any(Number),
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
expect(resumeToolCall.mock.invocationCallOrder[0]).toBeLessThan(
|
|
180
|
+
recordInteraction.mock.invocationCallOrder[0]!,
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("does not record a human response when resuming throws", () => {
|
|
185
|
+
const error = new Error("resume failed");
|
|
186
|
+
const recordInteraction = vi.fn(async () => {});
|
|
187
|
+
const runtime = createRuntime({
|
|
188
|
+
core: {
|
|
189
|
+
resumeToolCall: () => {
|
|
190
|
+
throw error;
|
|
191
|
+
},
|
|
192
|
+
unstable_recordToolInteraction: recordInteraction,
|
|
193
|
+
} as unknown as ThreadRuntimeCore,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(() => runtime.resumeToolCall({ answer: "yes" })).toThrow(error);
|
|
197
|
+
expect(recordInteraction).not.toHaveBeenCalled();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("keeps an accepted resume successful when recording fails", async () => {
|
|
201
|
+
const resumeToolCall = vi.fn();
|
|
202
|
+
const runtime = createRuntime({
|
|
203
|
+
core: {
|
|
204
|
+
resumeToolCall,
|
|
205
|
+
unstable_recordToolInteraction: vi.fn(async () => {
|
|
206
|
+
throw new Error("recording failed");
|
|
207
|
+
}),
|
|
208
|
+
} as unknown as ThreadRuntimeCore,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(() => runtime.resumeToolCall({ answer: "yes" })).not.toThrow();
|
|
212
|
+
await Promise.resolve();
|
|
213
|
+
expect(resumeToolCall).toHaveBeenCalledOnce();
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -3,8 +3,10 @@ import type {
|
|
|
3
3
|
ThreadUserMessagePart,
|
|
4
4
|
ToolApprovalResponse,
|
|
5
5
|
ToolCallMessagePartStatus,
|
|
6
|
+
Unstable_ToolInteractionInput,
|
|
6
7
|
} from "../../types/message";
|
|
7
8
|
import { resolveToolApprovalResponse } from "../utils/resolveToolApprovalResponse";
|
|
9
|
+
import { createToolInteraction } from "../utils/tool-interactions";
|
|
8
10
|
import type { Unsubscribe } from "../../types/unsubscribe";
|
|
9
11
|
import type { MessagePartStatus } from "../../types/message";
|
|
10
12
|
import type { SubscribableWithState } from "../../subscribable/subscribable";
|
|
@@ -29,6 +31,9 @@ export type MessagePartRuntime = {
|
|
|
29
31
|
addToolResult(result: any | ToolResponse<any>): void;
|
|
30
32
|
resumeToolCall(payload: unknown): void;
|
|
31
33
|
respondToToolApproval(response: ToolApprovalResponse): Promise<void>;
|
|
34
|
+
unstable_recordInteraction?: (
|
|
35
|
+
input: Unstable_ToolInteractionInput,
|
|
36
|
+
) => Promise<void>;
|
|
32
37
|
|
|
33
38
|
readonly path: MessagePartRuntimePath;
|
|
34
39
|
getState(): MessagePartState;
|
|
@@ -59,6 +64,8 @@ export class MessagePartRuntimeImpl implements MessagePartRuntime {
|
|
|
59
64
|
this.addToolResult = this.addToolResult.bind(this);
|
|
60
65
|
this.resumeToolCall = this.resumeToolCall.bind(this);
|
|
61
66
|
this.respondToToolApproval = this.respondToToolApproval.bind(this);
|
|
67
|
+
this.unstable_recordInteraction =
|
|
68
|
+
this.unstable_recordInteraction.bind(this);
|
|
62
69
|
this.getState = this.getState.bind(this);
|
|
63
70
|
this.subscribe = this.subscribe.bind(this);
|
|
64
71
|
}
|
|
@@ -114,6 +121,10 @@ export class MessagePartRuntimeImpl implements MessagePartRuntime {
|
|
|
114
121
|
toolCallId,
|
|
115
122
|
payload,
|
|
116
123
|
});
|
|
124
|
+
void this.unstable_recordInteraction({
|
|
125
|
+
type: "human-response",
|
|
126
|
+
payload,
|
|
127
|
+
}).catch(() => {});
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
public respondToToolApproval(response: ToolApprovalResponse): Promise<void> {
|
|
@@ -141,6 +152,35 @@ export class MessagePartRuntimeImpl implements MessagePartRuntime {
|
|
|
141
152
|
);
|
|
142
153
|
}
|
|
143
154
|
|
|
155
|
+
public async unstable_recordInteraction(
|
|
156
|
+
input: Unstable_ToolInteractionInput,
|
|
157
|
+
): Promise<void> {
|
|
158
|
+
const state = this.contentBinding.getState();
|
|
159
|
+
if (!state) throw new Error("Message part is not available");
|
|
160
|
+
|
|
161
|
+
if (state.type !== "tool-call")
|
|
162
|
+
throw new Error("Tried to record interaction on non-tool message part");
|
|
163
|
+
|
|
164
|
+
if (!this.messageApi)
|
|
165
|
+
throw new Error(
|
|
166
|
+
"Message API is not available. This is likely a bug in assistant-ui.",
|
|
167
|
+
);
|
|
168
|
+
if (!this.threadApi) throw new Error("Thread API is not available");
|
|
169
|
+
|
|
170
|
+
const message = this.messageApi.getState();
|
|
171
|
+
if (!message) throw new Error("Message is not available");
|
|
172
|
+
|
|
173
|
+
const core = this.threadApi.getState();
|
|
174
|
+
if (!core.unstable_recordToolInteraction)
|
|
175
|
+
throw new Error("Runtime does not support recording tool interactions.");
|
|
176
|
+
|
|
177
|
+
await core.unstable_recordToolInteraction({
|
|
178
|
+
messageId: message.id,
|
|
179
|
+
toolCallId: state.toolCallId,
|
|
180
|
+
interaction: createToolInteraction(input),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
144
184
|
public subscribe(callback: () => void) {
|
|
145
185
|
return this.contentBinding.subscribe(callback);
|
|
146
186
|
}
|