@assistant-ui/core 0.2.20 → 0.2.22
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 +2 -2
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +14 -7
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +0 -1
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +0 -1
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.js +2 -1
- package/dist/adapters/speech.d.ts +0 -1
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +9 -2
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/suggestion.d.ts +16 -2
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/suggestion.js +36 -0
- package/dist/adapters/suggestion.js.map +1 -0
- package/dist/adapters/thread-history.d.ts +2 -2
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +5 -3
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +0 -1
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +13 -5
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.d.ts.map +1 -1
- package/dist/internal.d.ts +9 -1
- package/dist/internal.js +8 -2
- package/dist/model-context/frame/host.d.ts +1 -1
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +5 -0
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +0 -1
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +1 -0
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.d.ts +4 -2
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry-handles.d.ts +0 -1
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +0 -1
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +23 -9
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/tool.js +0 -25
- package/dist/model-context/tool.js.map +1 -1
- package/dist/model-context/types.d.ts +0 -1
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +0 -1
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +1 -6
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +1 -0
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +13 -2
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +196 -54
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +0 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +0 -1
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +0 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +3 -2
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts +0 -1
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/interactables-legacy/Interactables.d.ts +0 -1
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts +0 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
- package/dist/react/interactables-legacy/scopes.d.ts +4 -2
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +0 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.d.ts +19 -4
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.js +17 -5
- package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +1 -2
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +2 -2
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +2 -2
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +2 -2
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +2 -2
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +0 -1
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +5 -5
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +1 -0
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +3 -2
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +1 -0
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +4 -2
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +3 -2
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +0 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +0 -1
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +7 -4
- package/dist/react/model-context/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.js.map +1 -1
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +0 -1
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +3 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +1 -4
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +13 -13
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +0 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +0 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.js +5 -1
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +1 -5
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +0 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +0 -1
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +7 -4
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +4 -3
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +4 -3
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -2
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +2 -2
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +4 -3
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +1 -6
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +44 -25
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +48 -37
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +2 -2
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +0 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +2 -2
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +35 -17
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +6 -4
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +4 -3
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +0 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +0 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +0 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +0 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +18 -30
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +0 -1
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +0 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +0 -1
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +18 -30
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +0 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +0 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +0 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +0 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +0 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +2 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +12 -3
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +70 -27
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +0 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +0 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -4
- 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 +12 -2
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +30 -1
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +0 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +1 -7
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +0 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +1 -8
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +43 -45
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts +0 -1
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +0 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +3 -5
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +9 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +0 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +0 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +6 -3
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +4 -2
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +5 -3
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/react/types/store-augmentation.d.ts +1 -2
- package/dist/react/types/store-augmentation.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +0 -1
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +2 -2
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +0 -1
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +0 -1
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/bindings.d.ts +0 -1
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +6 -4
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +0 -1
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +6 -16
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +5 -5
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +0 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js +2 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +0 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +3 -1
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +0 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +51 -10
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -4
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +3 -2
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -5
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +4 -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 +1 -0
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +2 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +0 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +2 -2
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +0 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +2 -2
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +0 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +6 -4
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +1 -1
- package/dist/runtime/utils/auto-status.d.ts +0 -1
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +0 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +0 -1
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +1 -5
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +3 -1
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +0 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/streaming-timing.d.ts +5 -3
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +2 -2
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +4 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +2 -2
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +0 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.d.ts +0 -1
- 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 +0 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +2 -0
- 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 +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +0 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-core.d.ts +0 -1
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +0 -1
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +0 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +5 -21
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +29 -17
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +0 -1
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/local/should-continue.js +2 -2
- package/dist/runtimes/local/should-continue.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +0 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js +5 -3
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +0 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +10 -8
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +22 -9
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +0 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +2 -2
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +1 -2
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +0 -1
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +0 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +0 -1
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +0 -1
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/suggestions.d.ts +0 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +0 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +0 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +0 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +0 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +0 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +0 -1
- 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 +0 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +0 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +0 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
- package/dist/store/scope-registration.d.ts +1 -2
- package/dist/store/scope-registration.d.ts.map +1 -1
- package/dist/store/scopes/attachment.d.ts +0 -1
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +0 -1
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +0 -1
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +6 -4
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +0 -1
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +0 -1
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +0 -1
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +0 -1
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +4 -3
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +0 -1
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +1 -2
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +11 -3
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +2 -2
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js +5 -2
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/types/attachment.d.ts +3 -2
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/attachment.js +6 -0
- package/dist/types/attachment.js.map +1 -0
- package/dist/types/directive.d.ts +3 -2
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +15 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +46 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/message.d.ts +71 -33
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +0 -1
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +1 -0
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +9 -0
- package/dist/utils/data-url.d.ts.map +1 -0
- package/dist/utils/data-url.js +14 -0
- package/dist/utils/data-url.js.map +1 -0
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +0 -1
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/is-json.js +1 -1
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +7 -0
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -0
- package/dist/utils/json/stable-stringify-tool-args.js +32 -0
- package/dist/utils/json/stable-stringify-tool-args.js.map +1 -0
- package/dist/utils/notify-event-listeners.d.ts +6 -0
- package/dist/utils/notify-event-listeners.d.ts.map +1 -0
- package/dist/utils/notify-event-listeners.js +16 -0
- package/dist/utils/notify-event-listeners.js.map +1 -0
- package/dist/utils/text.d.ts +0 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/package.json +14 -10
- package/src/adapters/attachment.test.ts +107 -0
- package/src/adapters/attachment.ts +20 -10
- package/src/adapters/index.ts +6 -1
- package/src/adapters/speech.test.ts +88 -0
- package/src/adapters/speech.ts +17 -2
- package/src/adapters/suggestion.test.ts +187 -0
- package/src/adapters/suggestion.ts +75 -1
- package/src/adapters/voice.test.ts +130 -0
- package/src/adapters/voice.ts +26 -6
- package/src/index.ts +15 -1
- package/src/internal.ts +21 -0
- package/src/model-context/frame/host.test.ts +100 -0
- package/src/model-context/frame/host.ts +10 -0
- package/src/model-context/frame/provider.test.ts +83 -0
- package/src/model-context/frame/provider.ts +1 -0
- package/src/model-context/tool.test.ts +110 -0
- package/src/model-context/tool.ts +31 -9
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +304 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +307 -60
- package/src/react/index.ts +2 -0
- package/src/react/model-context/define-mcp-toolkit.ts +39 -6
- package/src/react/model-context/define-toolkit.test.ts +107 -0
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +79 -0
- package/src/react/primitive-hooks/useActionBarCopy.ts +4 -3
- package/src/react/primitive-hooks/useMessageError.test.ts +64 -0
- package/src/react/primitive-hooks/useMessageError.ts +19 -6
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -3
- package/src/react/primitives/message/MessageParts.tsx +48 -35
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +19 -2
- package/src/react/providers/PartByIndexProvider.tsx +16 -2
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +18 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +4 -1
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +96 -26
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +69 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +1 -1
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +127 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +15 -4
- package/src/react/runtimes/cloud/auiV0.ts +71 -2
- package/src/react/runtimes/external-message-converter.test.tsx +123 -0
- package/src/react/runtimes/external-message-converter.ts +36 -11
- package/src/react/runtimes/useLocalRuntime.test.tsx +56 -0
- package/src/react/runtimes/useLocalRuntime.ts +13 -1
- package/src/runtime/api/message-runtime.test.ts +81 -0
- package/src/runtime/api/message-runtime.ts +4 -6
- package/src/runtime/api/thread-list-item-runtime.ts +6 -1
- package/src/runtime/base/base-composer-runtime-core.ts +95 -30
- package/src/runtime/base/base-thread-runtime-core.ts +2 -1
- package/src/runtime/base/default-edit-composer-runtime-core.ts +4 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +2 -2
- package/src/runtime/utils/message-repository.ts +8 -3
- package/src/runtime/utils/thread-message-like.ts +3 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +276 -3
- package/src/runtimes/local/local-thread-runtime-core.ts +29 -25
- package/src/runtimes/local/should-continue.ts +5 -2
- package/src/runtimes/remote-thread-list/adapter/in-memory.test.ts +14 -0
- package/src/runtimes/remote-thread-list/adapter/in-memory.ts +13 -5
- package/src/runtimes/remote-thread-list/optimistic-state.test.ts +63 -0
- package/src/runtimes/remote-thread-list/optimistic-state.ts +49 -17
- package/src/runtimes/remote-thread-list/types.ts +1 -1
- package/src/runtimes/tool-invocations/EDGE_CASES.md +13 -19
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +127 -6
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +4 -2
- package/src/subscribable/subscribable.test.ts +58 -0
- package/src/subscribable/subscribable.ts +13 -3
- package/src/tests/MessageRepository.test.ts +26 -0
- package/src/tests/OptimisticState-list-race.test.ts +33 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +42 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-order.test.ts +223 -0
- package/src/tests/attachment-adapters.test.ts +14 -2
- package/src/tests/auiV0Encode.test.ts +134 -1
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +123 -5
- package/src/tests/base-composer-runtime-core-send.test.ts +573 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +43 -5
- package/src/tests/event-subscription-listener-errors.test.ts +205 -0
- package/src/tests/remote-thread-list-test-helpers.ts +14 -7
- package/src/tests/thread-message-like.test.ts +97 -0
- package/src/types/attachment.ts +6 -0
- package/src/types/error.test.ts +122 -0
- package/src/types/error.ts +74 -0
- package/src/types/index.ts +1 -0
- package/src/types/message.ts +12 -3
- package/src/utils/data-url.test.ts +50 -0
- package/src/utils/data-url.ts +9 -0
- package/src/utils/json/is-json-equal.test.ts +84 -0
- package/src/utils/json/is-json.test.ts +123 -0
- package/src/utils/json/is-json.ts +1 -1
- package/src/utils/json/stable-stringify-tool-args.test.ts +105 -0
- package/src/utils/json/stable-stringify-tool-args.ts +70 -0
- package/src/utils/notify-event-listeners.ts +30 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { CompleteAttachment } from "../../types/attachment";
|
|
3
|
+
import type { ThreadRuntimeCoreBinding } from "./thread-runtime";
|
|
4
|
+
import {
|
|
5
|
+
MessageRuntimeImpl,
|
|
6
|
+
type MessageState,
|
|
7
|
+
type MessageStateBinding,
|
|
8
|
+
} from "./message-runtime";
|
|
9
|
+
|
|
10
|
+
const messagePath = {
|
|
11
|
+
ref: "threads.main.messages[0]",
|
|
12
|
+
threadSelector: { type: "main" as const },
|
|
13
|
+
messageSelector: { type: "index" as const, index: 0 },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const attachment: CompleteAttachment = {
|
|
17
|
+
id: "attachment-1",
|
|
18
|
+
type: "file",
|
|
19
|
+
name: "notes.txt",
|
|
20
|
+
contentType: "text/plain",
|
|
21
|
+
content: [{ type: "text", text: "notes" }],
|
|
22
|
+
status: { type: "complete" },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const message: MessageState = {
|
|
26
|
+
id: "message-1",
|
|
27
|
+
role: "assistant",
|
|
28
|
+
createdAt: new Date(0),
|
|
29
|
+
content: [
|
|
30
|
+
{ type: "text", text: "Hello" },
|
|
31
|
+
{
|
|
32
|
+
type: "tool-call",
|
|
33
|
+
toolCallId: "call-1",
|
|
34
|
+
toolName: "weather",
|
|
35
|
+
args: {},
|
|
36
|
+
argsText: "{}",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
attachments: [attachment],
|
|
40
|
+
status: { type: "complete", reason: "stop" },
|
|
41
|
+
metadata: {
|
|
42
|
+
unstable_state: null,
|
|
43
|
+
unstable_annotations: [],
|
|
44
|
+
unstable_data: [],
|
|
45
|
+
steps: [],
|
|
46
|
+
custom: {},
|
|
47
|
+
},
|
|
48
|
+
parentId: null,
|
|
49
|
+
index: 0,
|
|
50
|
+
isLast: true,
|
|
51
|
+
branchNumber: 1,
|
|
52
|
+
branchCount: 1,
|
|
53
|
+
speech: undefined,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const messageBinding: MessageStateBinding = {
|
|
57
|
+
path: messagePath,
|
|
58
|
+
getState: () => message,
|
|
59
|
+
subscribe: () => () => {},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const threadBinding = {
|
|
63
|
+
subscribe: () => () => {},
|
|
64
|
+
} as unknown as ThreadRuntimeCoreBinding;
|
|
65
|
+
|
|
66
|
+
describe("MessageRuntimeImpl paths", () => {
|
|
67
|
+
it("appends nested selectors to the message path", () => {
|
|
68
|
+
const runtime = new MessageRuntimeImpl(messageBinding, threadBinding);
|
|
69
|
+
|
|
70
|
+
expect(runtime.composer.path.ref).toBe("threads.main.messages[0].composer");
|
|
71
|
+
expect(runtime.getMessagePartByIndex(0).path.ref).toBe(
|
|
72
|
+
"threads.main.messages[0].content[0]",
|
|
73
|
+
);
|
|
74
|
+
expect(runtime.getMessagePartByToolCallId("call-1").path.ref).toBe(
|
|
75
|
+
'threads.main.messages[0].content[toolCallId="call-1"]',
|
|
76
|
+
);
|
|
77
|
+
expect(runtime.getAttachmentByIndex(0).path.ref).toBe(
|
|
78
|
+
"threads.main.messages[0].attachments[0]",
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -142,7 +142,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
|
|
|
142
142
|
new NestedSubscriptionSubject({
|
|
143
143
|
path: {
|
|
144
144
|
...this.path,
|
|
145
|
-
ref: `${this.path.ref}
|
|
145
|
+
ref: `${this.path.ref}.composer`,
|
|
146
146
|
composerSource: "edit",
|
|
147
147
|
},
|
|
148
148
|
getState: this._getEditComposerRuntimeCore,
|
|
@@ -269,7 +269,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
|
|
|
269
269
|
new ShallowMemoizeSubject({
|
|
270
270
|
path: {
|
|
271
271
|
...this.path,
|
|
272
|
-
ref: `${this.path.ref}
|
|
272
|
+
ref: `${this.path.ref}.content[${idx}]`,
|
|
273
273
|
messagePartSelector: { type: "index", index: idx },
|
|
274
274
|
},
|
|
275
275
|
getState: () => {
|
|
@@ -287,9 +287,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
|
|
|
287
287
|
new ShallowMemoizeSubject({
|
|
288
288
|
path: {
|
|
289
289
|
...this.path,
|
|
290
|
-
ref:
|
|
291
|
-
this.path.ref +
|
|
292
|
-
`${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,
|
|
290
|
+
ref: `${this.path.ref}.content[toolCallId=${JSON.stringify(toolCallId)}]`,
|
|
293
291
|
messagePartSelector: { type: "toolCallId", toolCallId },
|
|
294
292
|
},
|
|
295
293
|
getState: () => {
|
|
@@ -313,7 +311,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
|
|
|
313
311
|
new ShallowMemoizeSubject({
|
|
314
312
|
path: {
|
|
315
313
|
...this.path,
|
|
316
|
-
ref: `${this.path.ref}
|
|
314
|
+
ref: `${this.path.ref}.attachments[${idx}]`,
|
|
317
315
|
attachmentSource: "message",
|
|
318
316
|
attachmentSelector: { type: "index", index: idx },
|
|
319
317
|
},
|
|
@@ -2,6 +2,7 @@ import type { Unsubscribe } from "../../types/unsubscribe";
|
|
|
2
2
|
import type { SubscribableWithState } from "../../subscribable/subscribable";
|
|
3
3
|
import type { ThreadListItemRuntimePath } from "./paths";
|
|
4
4
|
import type { ThreadListRuntimeCoreBinding } from "./thread-list-runtime";
|
|
5
|
+
import { notifyEventListeners } from "../../utils/notify-event-listeners";
|
|
5
6
|
|
|
6
7
|
export type ThreadListItemEventPayload = {
|
|
7
8
|
/**
|
|
@@ -162,7 +163,11 @@ export class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {
|
|
|
162
163
|
|
|
163
164
|
if (event === "switchedTo" && !newIsMain) return;
|
|
164
165
|
if (event === "switchedAway" && newIsMain) return;
|
|
165
|
-
(
|
|
166
|
+
notifyEventListeners(
|
|
167
|
+
[callback as (payload?: unknown) => void],
|
|
168
|
+
{},
|
|
169
|
+
`Thread list item "${event}"`,
|
|
170
|
+
);
|
|
166
171
|
});
|
|
167
172
|
}
|
|
168
173
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
isCreateAttachment,
|
|
3
|
+
type Attachment,
|
|
4
|
+
type CompleteAttachment,
|
|
5
|
+
type CreateAttachment,
|
|
6
|
+
type PendingAttachment,
|
|
6
7
|
} from "../../types/attachment";
|
|
7
8
|
import type { MessageRole, AppendMessage } from "../../types/message";
|
|
8
9
|
import type { QuoteInfo } from "../../types/quote";
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
type QueueItemState,
|
|
29
30
|
} from "../../store/scopes/queue-item";
|
|
30
31
|
import { generateId } from "../../utils/id";
|
|
32
|
+
import { notifyEventListeners } from "../../utils/notify-event-listeners";
|
|
31
33
|
|
|
32
34
|
const isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>
|
|
33
35
|
a.status.type === "complete";
|
|
@@ -133,6 +135,10 @@ export abstract class BaseComposerRuntimeCore
|
|
|
133
135
|
this._notifySubscribers();
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
protected _isSending = false;
|
|
139
|
+
private _removedDuringSend = new Set<string>();
|
|
140
|
+
private _sendGeneration = 0;
|
|
141
|
+
|
|
136
142
|
private _emptyTextAndAttachments() {
|
|
137
143
|
this._attachments = [];
|
|
138
144
|
this._text = "";
|
|
@@ -148,6 +154,14 @@ export abstract class BaseComposerRuntimeCore
|
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
public async reset() {
|
|
157
|
+
// A send whose adapter never settles must not brick the composer; reset is
|
|
158
|
+
// the escape hatch that releases the in-flight lock. Bumping the generation
|
|
159
|
+
// invalidates that send entirely so a late-settling upload can neither
|
|
160
|
+
// append the discarded draft nor touch a newer send's lock.
|
|
161
|
+
this._sendGeneration++;
|
|
162
|
+
this._isSending = false;
|
|
163
|
+
this._removedDuringSend.clear();
|
|
164
|
+
|
|
151
165
|
if (
|
|
152
166
|
this._attachments.length === 0 &&
|
|
153
167
|
this._text === "" &&
|
|
@@ -175,7 +189,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
175
189
|
}
|
|
176
190
|
|
|
177
191
|
public async send(options?: SendOptions) {
|
|
178
|
-
if (!this.canSend) return;
|
|
192
|
+
if (!this.canSend || this._isSending) return;
|
|
179
193
|
|
|
180
194
|
if (this._dictationSession) {
|
|
181
195
|
this._dictationSession.cancel();
|
|
@@ -183,33 +197,75 @@ export abstract class BaseComposerRuntimeCore
|
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
const adapter = this.getAttachmentAdapter();
|
|
186
|
-
const attachments
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const result = await adapter.send(a);
|
|
193
|
-
return result as CompleteAttachment;
|
|
194
|
-
}),
|
|
195
|
-
)
|
|
196
|
-
: [];
|
|
200
|
+
const attachmentTasks = this.attachments.map(async (a) => {
|
|
201
|
+
if (isAttachmentComplete(a)) return a;
|
|
202
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
|
203
|
+
const result = await adapter.send(a);
|
|
204
|
+
return result as CompleteAttachment;
|
|
205
|
+
});
|
|
197
206
|
|
|
207
|
+
const originalAttachments = this.attachments;
|
|
198
208
|
const text = this.text;
|
|
199
209
|
const quote = this._quote;
|
|
200
210
|
this._quote = undefined;
|
|
201
|
-
this.
|
|
211
|
+
this._text = "";
|
|
212
|
+
this._isSending = true;
|
|
213
|
+
const generation = ++this._sendGeneration;
|
|
214
|
+
this._notifySubscribers();
|
|
215
|
+
|
|
216
|
+
let resolvedAttachments: CompleteAttachment[];
|
|
217
|
+
try {
|
|
218
|
+
resolvedAttachments = await Promise.all(attachmentTasks);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
if (generation === this._sendGeneration) {
|
|
221
|
+
if (!this.text.trim() && this._quote === undefined) {
|
|
222
|
+
this._text = text;
|
|
223
|
+
this._quote = quote;
|
|
224
|
+
this._notifySubscribers();
|
|
225
|
+
}
|
|
226
|
+
// Promise.all rejects on the first failure, but sibling uploads from
|
|
227
|
+
// this batch keep running; the send rejects immediately while the
|
|
228
|
+
// retry lock is held until they settle, or a retry could re-send
|
|
229
|
+
// attachments that are still in flight.
|
|
230
|
+
void Promise.allSettled(attachmentTasks).then(() => {
|
|
231
|
+
if (generation !== this._sendGeneration) return;
|
|
232
|
+
this._removedDuringSend.clear();
|
|
233
|
+
this._isSending = false;
|
|
234
|
+
this._notifySubscribers();
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
throw e;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// A reset during the upload discarded this send's draft; the settled
|
|
241
|
+
// uploads must not append it or touch the lock a newer send may own.
|
|
242
|
+
if (generation !== this._sendGeneration) return;
|
|
243
|
+
|
|
244
|
+
// Drop by id, not wholesale: the user may have added or removed chips while
|
|
245
|
+
// the upload was in flight.
|
|
246
|
+
const sentIds = new Set(originalAttachments.map((a) => a.id));
|
|
247
|
+
this._attachments = this._attachments.filter((a) => !sentIds.has(a.id));
|
|
248
|
+
this._isSending = false;
|
|
249
|
+
this._notifySubscribers();
|
|
250
|
+
|
|
251
|
+
// An attachment removed mid-upload can't be cancelled, but it can still be
|
|
252
|
+
// dropped from the outgoing message instead of silently being sent anyway.
|
|
253
|
+
const finalAttachments = resolvedAttachments.filter(
|
|
254
|
+
(a) => !this._removedDuringSend.has(a.id),
|
|
255
|
+
);
|
|
256
|
+
this._removedDuringSend.clear();
|
|
202
257
|
|
|
203
258
|
const message: Omit<AppendMessage, "parentId" | "sourceId"> = {
|
|
204
259
|
createdAt: new Date(),
|
|
205
260
|
role: this.role,
|
|
206
261
|
content: text ? [{ type: "text", text }] : [],
|
|
207
|
-
attachments:
|
|
262
|
+
attachments: finalAttachments,
|
|
208
263
|
runConfig: this.runConfig,
|
|
209
264
|
metadata: { custom: { ...(quote ? { quote } : {}) } },
|
|
210
265
|
};
|
|
211
266
|
|
|
212
|
-
this.handleSend(message, options);
|
|
267
|
+
const sendTask = this.handleSend(message, options);
|
|
268
|
+
if (sendTask) void sendTask.catch(() => {});
|
|
213
269
|
this._notifyEventSubscribers("send", {});
|
|
214
270
|
}
|
|
215
271
|
|
|
@@ -227,11 +283,11 @@ export abstract class BaseComposerRuntimeCore
|
|
|
227
283
|
protected abstract handleSend(
|
|
228
284
|
message: Omit<AppendMessage, "parentId" | "sourceId">,
|
|
229
285
|
options?: SendOptions,
|
|
230
|
-
): void
|
|
286
|
+
): void | Promise<void>;
|
|
231
287
|
protected abstract handleCancel(): void;
|
|
232
288
|
|
|
233
289
|
async addAttachment(fileOrAttachment: File | CreateAttachment) {
|
|
234
|
-
if (
|
|
290
|
+
if (isCreateAttachment(fileOrAttachment)) {
|
|
235
291
|
const adapter = this.getAttachmentAdapter();
|
|
236
292
|
if (
|
|
237
293
|
adapter &&
|
|
@@ -321,7 +377,11 @@ export abstract class BaseComposerRuntimeCore
|
|
|
321
377
|
if (lastAttachment) {
|
|
322
378
|
upsertAttachment({
|
|
323
379
|
...lastAttachment,
|
|
324
|
-
status: {
|
|
380
|
+
status: {
|
|
381
|
+
type: "incomplete",
|
|
382
|
+
reason: "error",
|
|
383
|
+
message: e instanceof Error ? e.message : String(e),
|
|
384
|
+
},
|
|
325
385
|
});
|
|
326
386
|
}
|
|
327
387
|
this._safeEmitAttachmentAddError(
|
|
@@ -333,14 +393,15 @@ export abstract class BaseComposerRuntimeCore
|
|
|
333
393
|
throw e;
|
|
334
394
|
}
|
|
335
395
|
|
|
336
|
-
|
|
396
|
+
if (
|
|
337
397
|
lastAttachment?.status.type === "incomplete" &&
|
|
338
|
-
lastAttachment.status.reason === "error"
|
|
339
|
-
|
|
398
|
+
lastAttachment.status.reason === "error"
|
|
399
|
+
) {
|
|
340
400
|
this._safeEmitAttachmentAddError(
|
|
341
401
|
"adapter-error",
|
|
342
|
-
|
|
343
|
-
|
|
402
|
+
lastAttachment.status.message ??
|
|
403
|
+
"Attachment upload did not complete successfully.",
|
|
404
|
+
lastAttachment.id,
|
|
344
405
|
);
|
|
345
406
|
} else {
|
|
346
407
|
this._notifyEventSubscribers("attachmentAdd", {});
|
|
@@ -373,12 +434,16 @@ export abstract class BaseComposerRuntimeCore
|
|
|
373
434
|
if (index === -1) throw new Error("Attachment not found");
|
|
374
435
|
const attachment = this._attachments[index]!;
|
|
375
436
|
|
|
437
|
+
// A send in flight may already be uploading this attachment; the upload
|
|
438
|
+
// can't be cancelled, so mark it to be dropped from the outgoing message
|
|
439
|
+
// before any await gives the upload a chance to settle first.
|
|
440
|
+
if (this._isSending) this._removedDuringSend.add(attachmentId);
|
|
441
|
+
|
|
376
442
|
if (!isAttachmentComplete(attachment)) {
|
|
377
443
|
const adapter = this.getAttachmentAdapter();
|
|
378
444
|
if (!adapter) throw new Error("Attachments are not supported");
|
|
379
445
|
await adapter.remove(attachment);
|
|
380
446
|
}
|
|
381
|
-
|
|
382
447
|
this._attachments = this._attachments.filter((a) => a.id !== attachmentId);
|
|
383
448
|
this._notifySubscribers();
|
|
384
449
|
}
|
|
@@ -544,7 +609,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
544
609
|
const subscribers = this._eventSubscribers.get(event);
|
|
545
610
|
if (!subscribers) return;
|
|
546
611
|
|
|
547
|
-
|
|
612
|
+
notifyEventListeners(subscribers, payload, `Composer runtime "${event}"`);
|
|
548
613
|
}
|
|
549
614
|
|
|
550
615
|
public unstable_on<E extends ComposerRuntimeEventType>(
|
|
@@ -34,6 +34,7 @@ import type { FeedbackAdapter } from "../../adapters/feedback";
|
|
|
34
34
|
import type { AttachmentAdapter } from "../../adapters/attachment";
|
|
35
35
|
import type { RealtimeVoiceAdapter } from "../../adapters/voice";
|
|
36
36
|
import type { ThreadMessageLike } from "../utils/thread-message-like";
|
|
37
|
+
import { notifyEventListeners } from "../../utils/notify-event-listeners";
|
|
37
38
|
|
|
38
39
|
type BaseThreadAdapters = {
|
|
39
40
|
speech?: SpeechSynthesisAdapter | undefined;
|
|
@@ -182,7 +183,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
|
|
182
183
|
const subscribers = this._eventSubscribers.get(event);
|
|
183
184
|
if (!subscribers) return;
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
notifyEventListeners(subscribers, payload, `Thread runtime "${event}"`);
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
public subscribe(callback: () => void): Unsubscribe {
|
|
@@ -15,7 +15,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
public get canSend() {
|
|
18
|
-
return !this.isEmpty;
|
|
18
|
+
return !this.isEmpty && !this._isSending;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
protected getAttachmentAdapter() {
|
|
@@ -80,6 +80,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
80
80
|
message: Omit<AppendMessage, "parentId" | "sourceId">,
|
|
81
81
|
options?: SendOptions,
|
|
82
82
|
) {
|
|
83
|
+
let appendTask: void | Promise<void> = undefined;
|
|
83
84
|
const text = getThreadMessageText(message as AppendMessage);
|
|
84
85
|
const attachmentsChanged = !attachmentsEqual(
|
|
85
86
|
message.attachments ?? [],
|
|
@@ -114,7 +115,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
114
115
|
message,
|
|
115
116
|
composerMetadata,
|
|
116
117
|
);
|
|
117
|
-
this.runtime.append({
|
|
118
|
+
appendTask = this.runtime.append({
|
|
118
119
|
...enriched,
|
|
119
120
|
content,
|
|
120
121
|
parentId: this._parentId,
|
|
@@ -124,6 +125,7 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
this.handleCancel();
|
|
128
|
+
return appendTask;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
public handleCancel() {
|
|
@@ -23,7 +23,7 @@ export class DefaultThreadComposerRuntimeCore
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public get canSend() {
|
|
26
|
-
return !this.isEmpty && !this.runtime.isSendDisabled;
|
|
26
|
+
return !this.isEmpty && !this.runtime.isSendDisabled && !this._isSending;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public override get queue(): readonly QueueItemState[] {
|
|
@@ -94,7 +94,7 @@ export class DefaultThreadComposerRuntimeCore
|
|
|
94
94
|
);
|
|
95
95
|
const enriched = this.enrichWithComposerMetadata(message, composerMetadata);
|
|
96
96
|
|
|
97
|
-
this.runtime.append({
|
|
97
|
+
return this.runtime.append({
|
|
98
98
|
...(enriched as AppendMessage),
|
|
99
99
|
parentId: this.runtime.messages.at(-1)?.id ?? null,
|
|
100
100
|
sourceId: null,
|
|
@@ -436,13 +436,18 @@ export class MessageRepository {
|
|
|
436
436
|
export(): ExportedMessageRepository {
|
|
437
437
|
const exportItems: ExportedMessageRepository["messages"] = [];
|
|
438
438
|
|
|
439
|
-
// Optimistic messages are ephemeral and never persisted.
|
|
440
|
-
//
|
|
439
|
+
// Optimistic messages are ephemeral and never persisted. A persisted child
|
|
440
|
+
// of an optimistic node is re-parented onto its nearest persisted ancestor
|
|
441
|
+
// so the exported tree never references a skipped id.
|
|
441
442
|
for (const [, message] of this.messages) {
|
|
442
443
|
if (message.current.metadata?.isOptimistic) continue;
|
|
444
|
+
let prev = message.prev;
|
|
445
|
+
while (prev && prev.current.metadata?.isOptimistic) {
|
|
446
|
+
prev = prev.prev;
|
|
447
|
+
}
|
|
443
448
|
exportItems.push({
|
|
444
449
|
message: message.current,
|
|
445
|
-
parentId:
|
|
450
|
+
parentId: prev?.current.id ?? null,
|
|
446
451
|
});
|
|
447
452
|
}
|
|
448
453
|
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
import type { CompleteAttachment } from "../../types/attachment";
|
|
21
21
|
import type {
|
|
22
22
|
MessageTiming,
|
|
23
|
+
PartProviderMetadata,
|
|
23
24
|
TextMessagePart,
|
|
24
25
|
ToolApprovalOption,
|
|
25
26
|
ToolCallTiming,
|
|
@@ -61,6 +62,7 @@ export type ThreadMessageLike = {
|
|
|
61
62
|
readonly messages?: readonly ThreadMessage[] | undefined;
|
|
62
63
|
readonly interrupt?: { type: "human"; payload: unknown };
|
|
63
64
|
readonly timing?: ToolCallTiming;
|
|
65
|
+
readonly providerMetadata?: PartProviderMetadata;
|
|
64
66
|
readonly approval?: {
|
|
65
67
|
readonly id: string;
|
|
66
68
|
readonly approved?: boolean;
|
|
@@ -264,6 +266,7 @@ export const fromThreadMessageLike = (
|
|
|
264
266
|
})),
|
|
265
267
|
metadata: {
|
|
266
268
|
custom: metadata?.custom ?? {},
|
|
269
|
+
...(metadata?.isOptimistic && { isOptimistic: true }),
|
|
267
270
|
},
|
|
268
271
|
} satisfies ThreadUserMessage;
|
|
269
272
|
|