@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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Unsubscribe } from "../types/unsubscribe.js";
|
|
2
2
|
import { AssistantInstructionsConfig, AssistantToolProps, ModelContext, ModelContextProvider } from "./types.js";
|
|
3
3
|
import { ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle } from "./registry-handles.js";
|
|
4
|
-
|
|
5
4
|
//#region src/model-context/registry.d.ts
|
|
6
5
|
declare class ModelContextRegistry implements ModelContextProvider {
|
|
7
6
|
private _tools;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","names":[],"sources":["../../src/model-context/registry.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","names":[],"sources":["../../src/model-context/registry.ts"],"mappings":";;;;cAea,gCAAgC;UACnC;UACA;UACA;UACA;UACA;EAER,mBAAmB;EAiDnB,UAAU,uBAAuB;UAKzB;EAMR,QAAQ,cAAc,yBAAyB,SAC7C,MAAM,mBAAmB,OAAO,WAC/B,+BAA+B,OAAO;EAoBzC,eACE,iBAAiB,8BAChB;EAiCH,YACE,UAAU,uBACT"}
|
|
@@ -1,31 +1,45 @@
|
|
|
1
1
|
import { Tool } from "assistant-stream";
|
|
2
|
-
|
|
3
2
|
//#region src/model-context/tool.d.ts
|
|
3
|
+
type StandardSchemaInput<TSchema> = TSchema extends {
|
|
4
|
+
readonly "~standard": {
|
|
5
|
+
readonly types?: {
|
|
6
|
+
readonly input: infer TInput;
|
|
7
|
+
} | undefined;
|
|
8
|
+
};
|
|
9
|
+
} ? TInput extends Record<string, unknown> ? TInput : Record<string, unknown> : Record<string, unknown>;
|
|
10
|
+
type StandardSchemaParameters = Extract<NonNullable<Extract<Tool<any>, {
|
|
11
|
+
parameters: unknown;
|
|
12
|
+
}>["parameters"]>, {
|
|
13
|
+
readonly "~standard": unknown;
|
|
14
|
+
}>;
|
|
4
15
|
/**
|
|
5
16
|
* Defines a model tool with its argument schema, execution behavior, and
|
|
6
17
|
* optional model-output conversion.
|
|
7
18
|
*
|
|
8
19
|
* This helper keeps reusable tool definitions type-checked and convenient to
|
|
9
20
|
* export for a {@link Toolkit} registered with {@link Tools}.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
21
|
+
* When `parameters` is a Standard Schema (for example Zod v4), its input type
|
|
22
|
+
* is inferred for `execute`, `streamCall`, and model-output callbacks. Plain
|
|
23
|
+
* JSON Schema objects do not carry TypeScript input types, so provide generic
|
|
24
|
+
* arguments or annotate callbacks when you need precise args for JSON Schema.
|
|
12
25
|
*
|
|
13
26
|
* @param tool - Tool definition to expose to the assistant model.
|
|
14
27
|
*
|
|
15
28
|
* @example
|
|
16
29
|
* ```ts
|
|
17
|
-
*
|
|
30
|
+
* import { z } from "zod";
|
|
31
|
+
*
|
|
32
|
+
* const getWeather = tool({
|
|
18
33
|
* type: "frontend",
|
|
19
34
|
* description: "Get the weather for a city.",
|
|
20
|
-
* parameters: {
|
|
21
|
-
* type: "object",
|
|
22
|
-
* properties: { city: { type: "string" } },
|
|
23
|
-
* required: ["city"],
|
|
24
|
-
* },
|
|
35
|
+
* parameters: z.object({ city: z.string() }),
|
|
25
36
|
* execute: async ({ city }) => `Sunny in ${city}`,
|
|
26
37
|
* });
|
|
27
38
|
* ```
|
|
28
39
|
*/
|
|
40
|
+
declare function tool<const TSchema extends StandardSchemaParameters, TResult = any>(tool: Tool<StandardSchemaInput<TSchema>, TResult> & {
|
|
41
|
+
parameters: TSchema;
|
|
42
|
+
}): Tool<StandardSchemaInput<TSchema>, TResult>;
|
|
29
43
|
declare function tool<TArgs extends Record<string, unknown>, TResult = any>(tool: Tool<TArgs, TResult>): Tool<TArgs, TResult>;
|
|
30
44
|
//#endregion
|
|
31
45
|
export { tool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","names":[],"sources":["../../src/model-context/tool.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool.d.ts","names":[],"sources":["../../src/model-context/tool.ts"],"mappings":";;KAEK,oBAAoB,WAAW;WACzB;aACE;eAAmB,aAAa;;;IAGzC,eAAe,0BACb,SACA,0BACF;KAEC,2BAA2B,QAC9B,YAAY,QAAQ;EAAa;;WACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BG,WACR,gBAAgB,0BACtB,eAEA,MAAM,KAAK,oBAAoB,UAAU;EAAa,YAAY;IACjE,KAAK,oBAAoB,UAAU;iBACtB,KAAK,cAAc,yBAAyB,eAC1D,MAAM,KAAK,OAAO,WACjB,KAAK,OAAO"}
|
|
@@ -1,29 +1,4 @@
|
|
|
1
1
|
//#region src/model-context/tool.ts
|
|
2
|
-
/**
|
|
3
|
-
* Defines a model tool with its argument schema, execution behavior, and
|
|
4
|
-
* optional model-output conversion.
|
|
5
|
-
*
|
|
6
|
-
* This helper keeps reusable tool definitions type-checked and convenient to
|
|
7
|
-
* export for a {@link Toolkit} registered with {@link Tools}.
|
|
8
|
-
* Inference from parameter schemas is currently limited, so provide generic
|
|
9
|
-
* arguments when you need precise args or result types.
|
|
10
|
-
*
|
|
11
|
-
* @param tool - Tool definition to expose to the assistant model.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const getWeather = tool<{ city: string }, string>({
|
|
16
|
-
* type: "frontend",
|
|
17
|
-
* description: "Get the weather for a city.",
|
|
18
|
-
* parameters: {
|
|
19
|
-
* type: "object",
|
|
20
|
-
* properties: { city: { type: "string" } },
|
|
21
|
-
* required: ["city"],
|
|
22
|
-
* },
|
|
23
|
-
* execute: async ({ city }) => `Sunny in ${city}`,
|
|
24
|
-
* });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
2
|
function tool(tool) {
|
|
28
3
|
return tool;
|
|
29
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","names":["Tool","
|
|
1
|
+
{"version":3,"file":"tool.js","names":["Tool","StandardSchemaInput","TSchema","types","input","TInput","Record","StandardSchemaParameters","Extract","NonNullable","parameters","tool","TResult","TArgs"],"sources":["../../src/model-context/tool.ts"],"sourcesContent":["import type { Tool } from \"assistant-stream\";\n\ntype StandardSchemaInput<TSchema> = TSchema extends {\n readonly \"~standard\": {\n readonly types?: { readonly input: infer TInput } | undefined;\n };\n}\n ? TInput extends Record<string, unknown>\n ? TInput\n : Record<string, unknown>\n : Record<string, unknown>;\n\ntype StandardSchemaParameters = Extract<\n NonNullable<Extract<Tool<any>, { parameters: unknown }>[\"parameters\"]>,\n { readonly \"~standard\": unknown }\n>;\n\n/**\n * Defines a model tool with its argument schema, execution behavior, and\n * optional model-output conversion.\n *\n * This helper keeps reusable tool definitions type-checked and convenient to\n * export for a {@link Toolkit} registered with {@link Tools}.\n * When `parameters` is a Standard Schema (for example Zod v4), its input type\n * is inferred for `execute`, `streamCall`, and model-output callbacks. Plain\n * JSON Schema objects do not carry TypeScript input types, so provide generic\n * arguments or annotate callbacks when you need precise args for JSON Schema.\n *\n * @param tool - Tool definition to expose to the assistant model.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n *\n * const getWeather = tool({\n * type: \"frontend\",\n * description: \"Get the weather for a city.\",\n * parameters: z.object({ city: z.string() }),\n * execute: async ({ city }) => `Sunny in ${city}`,\n * });\n * ```\n */\nexport function tool<\n const TSchema extends StandardSchemaParameters,\n TResult = any,\n>(\n tool: Tool<StandardSchemaInput<TSchema>, TResult> & { parameters: TSchema },\n): Tool<StandardSchemaInput<TSchema>, TResult>;\nexport function tool<TArgs extends Record<string, unknown>, TResult = any>(\n tool: Tool<TArgs, TResult>,\n): Tool<TArgs, TResult>;\nexport function tool<TArgs extends Record<string, unknown>, TResult = any>(\n tool: Tool<TArgs, TResult>,\n): Tool<TArgs, TResult> {\n return tool;\n}\n"],"mappings":";AAmDA,SAAgBW,KACdA,MACsB;CACtB,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/model-context/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/model-context/types.ts"],"mappings":";;;KAGY;EACV;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;KAGA;EACV;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,QAAQ,eAAe;EACvB,eAAe;EACf,SAAS;;;;;;EAMT,4BAA4B;;KAGlB;EACV,uBAAuB;EACvB,aAAa,yBAAyB;;KAG5B,mBACV,cAAc,yBACd,WACE,KAAK,OAAO;EACd;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;;cAGW,qBACX,WAAW,IAAI,0BACd"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AssistantRuntime } from "../runtime/api/assistant-runtime.js";
|
|
2
2
|
import { AssistantClient } from "@assistant-ui/store";
|
|
3
3
|
import { ComponentType, FC, PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/react/AssistantProvider.d.ts
|
|
6
5
|
declare const getRenderComponent: (runtime: AssistantRuntime) => ComponentType | undefined;
|
|
7
6
|
type AssistantProviderBaseProps = PropsWithChildren<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantProvider.d.ts","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssistantProvider.d.ts","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"mappings":";;;;cAWa,qBAAsB,SAAS,qBAEnB;KAGb,6BAA6B;EACvC,SAAS;EACT,MAAM;;cAGK,uBAAuB,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantProvider.js","names":["memo","ComponentType","FC","PropsWithChildren","useAui","AuiProvider","AssistantClient","AssistantRuntime","AssistantRuntimeCore","RuntimeAdapter","getRenderComponent","runtime","_core","RenderComponent","AssistantProviderBaseProps","aui","AssistantProviderBase","parent","children","threads","inner"],"sources":["../../src/react/AssistantProvider.tsx"],"sourcesContent":["import {\n memo,\n type ComponentType,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { useAui, AuiProvider, type AssistantClient } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/api/assistant-runtime\";\nimport type { AssistantRuntimeCore } from \"../runtime/interfaces/assistant-runtime-core\";\nimport { RuntimeAdapter } from \"./RuntimeAdapter\";\n\nexport const getRenderComponent = (runtime: AssistantRuntime) => {\n return (runtime as { _core?: AssistantRuntimeCore })._core\n ?.RenderComponent as ComponentType | undefined;\n};\n\nexport type AssistantProviderBaseProps = PropsWithChildren<{\n runtime: AssistantRuntime;\n aui?: AssistantClient | null;\n}>;\n\nexport const AssistantProviderBase: FC<AssistantProviderBaseProps> = memo(\n ({ runtime, aui: parent = null, children }) => {\n // The runtime has a stable identity but mutates in place: its options are\n // pushed in by an unconditional effect inside <RenderComponent />, so that\n // element must be re-created every commit for React to re-render it and\n // re-run the effect. React Compiler caches <RenderComponent /> on the\n // stable RenderComponent type, which silences the effect and stops option\n // changes (e.g. unstable_enableMessageQueue) from reaching the runtime.\n \"use no memo\";\n const aui = useAui({ threads: RuntimeAdapter(runtime) }, { parent });\n const RenderComponent = getRenderComponent(runtime);\n const inner = (\n <AuiProvider value={aui}>\n {RenderComponent && <RenderComponent />}\n {children}\n </AuiProvider>\n );\n if (!parent) return inner;\n return <AuiProvider value={parent}>{inner}</AuiProvider>;\n },\n);\n"],"mappings":";;;;;AAWA,MAAaU,sBAAsBC,YAA8B;CAC/D,OAAQA,QAA6CC,OACjDC;AACN;AAOA,MAAaG,wBAAwDhB,MAClE,EAAEW,SAASI,KAAKE,SAAS,MAAMC,eAAe;CAO7C;CACA,MAAMH,MAAMX,OAAO,EAAEe,SAASV,eAAeE,OAAO,EAAE,GAAG,EAAEM,OAAO,CAAC;CACnE,MAAMJ,kBAAkBH,mBAAmBC,OAAO;CAClD,MAAMS,QACJ,qBAAC,aAAD;EAAa,OAAOL;
|
|
1
|
+
{"version":3,"file":"AssistantProvider.js","names":["memo","ComponentType","FC","PropsWithChildren","useAui","AuiProvider","AssistantClient","AssistantRuntime","AssistantRuntimeCore","RuntimeAdapter","getRenderComponent","runtime","_core","RenderComponent","AssistantProviderBaseProps","aui","AssistantProviderBase","parent","children","threads","inner"],"sources":["../../src/react/AssistantProvider.tsx"],"sourcesContent":["import {\n memo,\n type ComponentType,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { useAui, AuiProvider, type AssistantClient } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/api/assistant-runtime\";\nimport type { AssistantRuntimeCore } from \"../runtime/interfaces/assistant-runtime-core\";\nimport { RuntimeAdapter } from \"./RuntimeAdapter\";\n\nexport const getRenderComponent = (runtime: AssistantRuntime) => {\n return (runtime as { _core?: AssistantRuntimeCore })._core\n ?.RenderComponent as ComponentType | undefined;\n};\n\nexport type AssistantProviderBaseProps = PropsWithChildren<{\n runtime: AssistantRuntime;\n aui?: AssistantClient | null;\n}>;\n\nexport const AssistantProviderBase: FC<AssistantProviderBaseProps> = memo(\n ({ runtime, aui: parent = null, children }) => {\n // The runtime has a stable identity but mutates in place: its options are\n // pushed in by an unconditional effect inside <RenderComponent />, so that\n // element must be re-created every commit for React to re-render it and\n // re-run the effect. React Compiler caches <RenderComponent /> on the\n // stable RenderComponent type, which silences the effect and stops option\n // changes (e.g. unstable_enableMessageQueue) from reaching the runtime.\n \"use no memo\";\n const aui = useAui({ threads: RuntimeAdapter(runtime) }, { parent });\n const RenderComponent = getRenderComponent(runtime);\n const inner = (\n <AuiProvider value={aui}>\n {RenderComponent && <RenderComponent />}\n {children}\n </AuiProvider>\n );\n if (!parent) return inner;\n return <AuiProvider value={parent}>{inner}</AuiProvider>;\n },\n);\n"],"mappings":";;;;;AAWA,MAAaU,sBAAsBC,YAA8B;CAC/D,OAAQA,QAA6CC,OACjDC;AACN;AAOA,MAAaG,wBAAwDhB,MAClE,EAAEW,SAASI,KAAKE,SAAS,MAAMC,eAAe;CAO7C;CACA,MAAMH,MAAMX,OAAO,EAAEe,SAASV,eAAeE,OAAO,EAAE,GAAG,EAAEM,OAAO,CAAC;CACnE,MAAMJ,kBAAkBH,mBAAmBC,OAAO;CAClD,MAAMS,QACJ,qBAAC,aAAD;EAAa,OAAOL;EAApB,UAAA,CACGF,mBAAmB,oBAAC,iBAAD,CAAgB,CAAA,GACnCK,QACU;;CAEf,IAAI,CAACD,QAAQ,OAAOG;CACpB,OAAO,oBAAC,aAAD;EAAa,OAAOH;EAASG,UAAAA;CAAmB,CAAA;AACzD,CACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AssistantRuntime } from "../runtime/api/assistant-runtime.js";
|
|
2
2
|
import { AssistantClient } from "@assistant-ui/store";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/react/AssistantRuntimeProvider.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Mounts an `AssistantRuntime` into the React tree.
|
|
@@ -25,11 +24,7 @@ import { ReactNode } from "react";
|
|
|
25
24
|
* }
|
|
26
25
|
* ```
|
|
27
26
|
*/
|
|
28
|
-
declare const AssistantRuntimeProvider: import("react").MemoExoticComponent<({
|
|
29
|
-
runtime,
|
|
30
|
-
aui,
|
|
31
|
-
children
|
|
32
|
-
}: {
|
|
27
|
+
declare const AssistantRuntimeProvider: import("react").MemoExoticComponent<({ runtime, aui, children }: {
|
|
33
28
|
/**
|
|
34
29
|
* The assistant runtime to expose to descendants. Build one with
|
|
35
30
|
* `useLocalRuntime`, `useExternalStoreRuntime`, or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantRuntimeProvider.d.ts","names":[],"sources":["../../src/react/AssistantRuntimeProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssistantRuntimeProvider.d.ts","names":[],"sources":["../../src/react/AssistantRuntimeProvider.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;cA2Ba,0CAAwB,uBAAA,SAAA,KAAA;;;;;;EAWjC,SAAS;;;;;;;EAOT,MAAM;EACN,UAAU;sBACX,IAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AssistantRuntime } from "../runtime/api/assistant-runtime.js";
|
|
2
|
+
import "../index.js";
|
|
2
3
|
//#region src/react/RuntimeAdapter.d.ts
|
|
3
4
|
declare const RuntimeAdapter: import("@assistant-ui/tap").Resource<import("@assistant-ui/store").ClientOutput<"threads">, [runtime: AssistantRuntime]>;
|
|
4
5
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeAdapter.d.ts","names":[],"sources":["../../src/react/RuntimeAdapter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RuntimeAdapter.d.ts","names":[],"sources":["../../src/react/RuntimeAdapter.ts"],"mappings":";;;cA+Ba,4CAAc,uCAAA,0BAAA,SAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ExportedMessageRepository } from "../../runtime/utils/message-repository.js";
|
|
1
2
|
import { RemoteThreadListAdapter } from "../../runtimes/remote-thread-list/types.js";
|
|
3
|
+
import "../../internal.js";
|
|
4
|
+
import "../../index.js";
|
|
2
5
|
import { TitleGenerationAdapter } from "./TitleGenerationAdapter.js";
|
|
3
|
-
|
|
4
6
|
//#region src/react/adapters/LocalStorageThreadListAdapter.d.ts
|
|
5
7
|
type AsyncStorageLike = {
|
|
6
8
|
getItem(key: string): Promise<string | null>;
|
|
@@ -12,7 +14,16 @@ type LocalStorageAdapterOptions = {
|
|
|
12
14
|
prefix?: string | undefined;
|
|
13
15
|
titleGenerator?: TitleGenerationAdapter | undefined;
|
|
14
16
|
};
|
|
17
|
+
type StoredThreadMetadata = {
|
|
18
|
+
remoteId: string;
|
|
19
|
+
externalId?: string;
|
|
20
|
+
status: "regular" | "archived";
|
|
21
|
+
title?: string;
|
|
22
|
+
custom?: Record<string, unknown> | undefined;
|
|
23
|
+
};
|
|
24
|
+
declare const parseStoredThreadMetadata: (raw: string | null) => StoredThreadMetadata[];
|
|
25
|
+
declare const parseStoredMessageRepository: (raw: string | null) => ExportedMessageRepository;
|
|
15
26
|
declare const createLocalStorageAdapter: (options: LocalStorageAdapterOptions) => RemoteThreadListAdapter;
|
|
16
27
|
//#endregion
|
|
17
|
-
export { AsyncStorageLike, createLocalStorageAdapter };
|
|
28
|
+
export { AsyncStorageLike, createLocalStorageAdapter, parseStoredMessageRepository, parseStoredThreadMetadata };
|
|
18
29
|
//# sourceMappingURL=LocalStorageThreadListAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalStorageThreadListAdapter.d.ts","names":[],"sources":["../../../src/react/adapters/LocalStorageThreadListAdapter.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"LocalStorageThreadListAdapter.d.ts","names":[],"sources":["../../../src/react/adapters/LocalStorageThreadListAdapter.tsx"],"mappings":";;;;;;KAmBY;EACV,QAAQ,cAAc;EACtB,QAAQ,aAAa,gBAAgB;EACrC,WAAW,cAAc;;KAkCtB;EACH,SAAS;EACT;EACA,iBAAiB;;KAGd;EACH;EACA;EACA;EACA;EACA,SAAS;;cAwIE,4BACX,uBACC;cAoCU,+BACX,uBACC;cAkGU,4BACX,SAAS,+BACR"}
|
|
@@ -4,14 +4,153 @@ import { useAui } from "@assistant-ui/store";
|
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/adapters/LocalStorageThreadListAdapter.tsx
|
|
7
|
+
var KeyedMutationQueue = class {
|
|
8
|
+
tails = /* @__PURE__ */ new Map();
|
|
9
|
+
run(key, mutation) {
|
|
10
|
+
const previous = this.tails.get(key);
|
|
11
|
+
const result = previous ? previous.then(mutation) : mutation();
|
|
12
|
+
const tail = result.then(() => void 0, () => void 0);
|
|
13
|
+
this.tails.set(key, tail);
|
|
14
|
+
tail.then(() => {
|
|
15
|
+
if (this.tails.get(key) === tail) this.tails.delete(key);
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const mutationQueues = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
const getMutationQueue = (storage) => {
|
|
22
|
+
let queue = mutationQueues.get(storage);
|
|
23
|
+
if (!queue) {
|
|
24
|
+
queue = new KeyedMutationQueue();
|
|
25
|
+
mutationQueues.set(storage, queue);
|
|
26
|
+
}
|
|
27
|
+
return queue;
|
|
28
|
+
};
|
|
29
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
const parseJSON = (raw) => {
|
|
31
|
+
if (!raw) return void 0;
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(raw);
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const parseStoredThread = (value) => {
|
|
39
|
+
if (!isRecord(value) || typeof value.remoteId !== "string") return null;
|
|
40
|
+
const status = value.status ?? "regular";
|
|
41
|
+
if (status !== "regular" && status !== "archived") return null;
|
|
42
|
+
return {
|
|
43
|
+
remoteId: value.remoteId,
|
|
44
|
+
status,
|
|
45
|
+
...typeof value.externalId === "string" ? { externalId: value.externalId } : void 0,
|
|
46
|
+
...typeof value.title === "string" ? { title: value.title } : void 0,
|
|
47
|
+
...isRecord(value.custom) ? { custom: value.custom } : void 0
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const parseDate = (value) => {
|
|
51
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value;
|
|
52
|
+
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
53
|
+
const date = new Date(value);
|
|
54
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
55
|
+
};
|
|
56
|
+
const isMessageRole = (value) => value === "system" || value === "user" || value === "assistant";
|
|
57
|
+
const parseStoredThreadMessage = (value) => {
|
|
58
|
+
if (!isRecord(value) || typeof value.id !== "string") return null;
|
|
59
|
+
if (!isMessageRole(value.role)) return null;
|
|
60
|
+
if (!Array.isArray(value.content)) return null;
|
|
61
|
+
const createdAt = parseDate(value.createdAt);
|
|
62
|
+
if (!createdAt) return null;
|
|
63
|
+
const metadata = value.metadata;
|
|
64
|
+
if (!isRecord(metadata) || !isRecord(metadata.custom)) return null;
|
|
65
|
+
if (value.role === "assistant") {
|
|
66
|
+
const status = value.status;
|
|
67
|
+
if (!isRecord(status) || typeof status.type !== "string") return null;
|
|
68
|
+
const submittedFeedbackType = (isRecord(metadata.submittedFeedback) ? metadata.submittedFeedback : void 0)?.type;
|
|
69
|
+
return {
|
|
70
|
+
id: value.id,
|
|
71
|
+
role: "assistant",
|
|
72
|
+
content: value.content,
|
|
73
|
+
status,
|
|
74
|
+
createdAt,
|
|
75
|
+
metadata: {
|
|
76
|
+
unstable_state: metadata.unstable_state ?? null,
|
|
77
|
+
unstable_annotations: Array.isArray(metadata.unstable_annotations) ? metadata.unstable_annotations : [],
|
|
78
|
+
unstable_data: Array.isArray(metadata.unstable_data) ? metadata.unstable_data : [],
|
|
79
|
+
steps: Array.isArray(metadata.steps) ? metadata.steps : [],
|
|
80
|
+
...submittedFeedbackType === "positive" || submittedFeedbackType === "negative" ? { submittedFeedback: { type: submittedFeedbackType } } : void 0,
|
|
81
|
+
...metadata.timing !== void 0 ? { timing: metadata.timing } : void 0,
|
|
82
|
+
...metadata.isOptimistic === true ? { isOptimistic: true } : void 0,
|
|
83
|
+
custom: metadata.custom
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (value.role === "user") return {
|
|
88
|
+
id: value.id,
|
|
89
|
+
role: "user",
|
|
90
|
+
content: value.content,
|
|
91
|
+
attachments: Array.isArray(value.attachments) ? value.attachments : [],
|
|
92
|
+
createdAt,
|
|
93
|
+
metadata: { custom: metadata.custom }
|
|
94
|
+
};
|
|
95
|
+
if (value.content.length !== 1) return null;
|
|
96
|
+
return {
|
|
97
|
+
id: value.id,
|
|
98
|
+
role: "system",
|
|
99
|
+
content: [value.content[0]],
|
|
100
|
+
createdAt,
|
|
101
|
+
metadata: { custom: metadata.custom }
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
const parseStoredThreadMetadata = (raw) => {
|
|
105
|
+
const parsed = parseJSON(raw);
|
|
106
|
+
if (!Array.isArray(parsed)) return [];
|
|
107
|
+
return parsed.flatMap((item) => {
|
|
108
|
+
const thread = parseStoredThread(item);
|
|
109
|
+
return thread ? [thread] : [];
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const parseStoredMessageRepositoryItem = (value) => {
|
|
113
|
+
if (!isRecord(value)) return null;
|
|
114
|
+
const message = parseStoredThreadMessage(value.message);
|
|
115
|
+
if (!message) return null;
|
|
116
|
+
const parentId = value.parentId;
|
|
117
|
+
if (parentId !== void 0 && parentId !== null && typeof parentId !== "string") return null;
|
|
118
|
+
return {
|
|
119
|
+
message,
|
|
120
|
+
parentId: parentId ?? null,
|
|
121
|
+
...isRecord(value.runConfig) ? { runConfig: value.runConfig } : void 0
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
const parseStoredMessageRepository = (raw) => {
|
|
125
|
+
const parsed = parseJSON(raw);
|
|
126
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.messages)) return { messages: [] };
|
|
127
|
+
const candidateMessages = parsed.messages.flatMap((item) => {
|
|
128
|
+
const parsedItem = parseStoredMessageRepositoryItem(item);
|
|
129
|
+
return parsedItem ? [parsedItem] : [];
|
|
130
|
+
});
|
|
131
|
+
const acceptedIds = /* @__PURE__ */ new Set();
|
|
132
|
+
const messages = candidateMessages.flatMap((item) => {
|
|
133
|
+
if (acceptedIds.has(item.message.id)) return [];
|
|
134
|
+
if (item.parentId !== null && !acceptedIds.has(item.parentId)) return [];
|
|
135
|
+
acceptedIds.add(item.message.id);
|
|
136
|
+
return [item];
|
|
137
|
+
});
|
|
138
|
+
const headId = parsed.headId === null || typeof parsed.headId === "string" && messages.some((item) => item.message.id === parsed.headId) ? parsed.headId : void 0;
|
|
139
|
+
return {
|
|
140
|
+
...headId !== void 0 ? { headId } : void 0,
|
|
141
|
+
messages
|
|
142
|
+
};
|
|
143
|
+
};
|
|
7
144
|
var AsyncStorageHistoryAdapter = class {
|
|
8
145
|
storage;
|
|
9
146
|
aui;
|
|
10
147
|
prefix;
|
|
11
|
-
|
|
148
|
+
mutationQueue;
|
|
149
|
+
constructor(storage, aui, prefix, mutationQueue) {
|
|
12
150
|
this.storage = storage;
|
|
13
151
|
this.aui = aui;
|
|
14
152
|
this.prefix = prefix;
|
|
153
|
+
this.mutationQueue = mutationQueue;
|
|
15
154
|
}
|
|
16
155
|
_messagesKey(remoteId) {
|
|
17
156
|
return `${this.prefix}messages:${remoteId}`;
|
|
@@ -20,29 +159,30 @@ var AsyncStorageHistoryAdapter = class {
|
|
|
20
159
|
const remoteId = this.aui.threadListItem().getState().remoteId;
|
|
21
160
|
if (!remoteId) return { messages: [] };
|
|
22
161
|
const raw = await this.storage.getItem(this._messagesKey(remoteId));
|
|
23
|
-
|
|
24
|
-
return JSON.parse(raw);
|
|
162
|
+
return parseStoredMessageRepository(raw);
|
|
25
163
|
}
|
|
26
164
|
async append(item) {
|
|
27
165
|
const { remoteId } = await this.aui.threadListItem().initialize();
|
|
28
166
|
const key = this._messagesKey(remoteId);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
167
|
+
await this.mutationQueue.run(key, async () => {
|
|
168
|
+
const raw = await this.storage.getItem(key);
|
|
169
|
+
const repo = parseStoredMessageRepository(raw);
|
|
170
|
+
const idx = repo.messages.findIndex((m) => m.message.id === item.message.id);
|
|
171
|
+
if (idx >= 0) repo.messages[idx] = item;
|
|
172
|
+
else repo.messages.push(item);
|
|
173
|
+
repo.headId = item.message.id;
|
|
174
|
+
await this.storage.setItem(key, JSON.stringify(repo));
|
|
175
|
+
});
|
|
36
176
|
}
|
|
37
177
|
};
|
|
38
|
-
const createHistoryProvider = (storage, prefix) => {
|
|
178
|
+
const createHistoryProvider = (storage, prefix, mutationQueue) => {
|
|
39
179
|
const Provider = (t0) => {
|
|
40
180
|
const $ = c(7);
|
|
41
181
|
const { children } = t0;
|
|
42
182
|
const aui = useAui();
|
|
43
183
|
let t1;
|
|
44
184
|
if ($[0] !== aui) {
|
|
45
|
-
t1 = new AsyncStorageHistoryAdapter(storage, aui, prefix);
|
|
185
|
+
t1 = new AsyncStorageHistoryAdapter(storage, aui, prefix, mutationQueue);
|
|
46
186
|
$[0] = aui;
|
|
47
187
|
$[1] = t1;
|
|
48
188
|
} else t1 = $[1];
|
|
@@ -72,15 +212,26 @@ const createLocalStorageAdapter = (options) => {
|
|
|
72
212
|
const { storage, prefix = "@assistant-ui:", titleGenerator } = options;
|
|
73
213
|
const threadsKey = `${prefix}threads`;
|
|
74
214
|
const messagesKey = (threadId) => `${prefix}messages:${threadId}`;
|
|
215
|
+
const mutationQueue = getMutationQueue(storage);
|
|
75
216
|
const loadThreadMetadata = async () => {
|
|
76
217
|
const raw = await storage.getItem(threadsKey);
|
|
77
|
-
return
|
|
218
|
+
return parseStoredThreadMetadata(raw);
|
|
78
219
|
};
|
|
79
220
|
const saveThreadMetadata = async (threads) => {
|
|
80
221
|
await storage.setItem(threadsKey, JSON.stringify(threads));
|
|
81
222
|
};
|
|
223
|
+
const updateThreadMetadata = async (remoteId, update) => {
|
|
224
|
+
await mutationQueue.run(threadsKey, async () => {
|
|
225
|
+
const threads = await loadThreadMetadata();
|
|
226
|
+
const thread = threads.find((item) => item.remoteId === remoteId);
|
|
227
|
+
if (thread) {
|
|
228
|
+
update(thread);
|
|
229
|
+
await saveThreadMetadata(threads);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
};
|
|
82
233
|
return {
|
|
83
|
-
unstable_Provider: createHistoryProvider(storage, prefix),
|
|
234
|
+
unstable_Provider: createHistoryProvider(storage, prefix, mutationQueue),
|
|
84
235
|
async list() {
|
|
85
236
|
return { threads: (await loadThreadMetadata()).map((t) => ({
|
|
86
237
|
remoteId: t.remoteId,
|
|
@@ -92,58 +243,52 @@ const createLocalStorageAdapter = (options) => {
|
|
|
92
243
|
},
|
|
93
244
|
async initialize(threadId) {
|
|
94
245
|
const remoteId = threadId;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
threads.
|
|
246
|
+
return mutationQueue.run(threadsKey, async () => {
|
|
247
|
+
const threads = await loadThreadMetadata();
|
|
248
|
+
if (!threads.some((t) => t.remoteId === remoteId)) {
|
|
249
|
+
threads.unshift({
|
|
250
|
+
remoteId,
|
|
251
|
+
status: "regular"
|
|
252
|
+
});
|
|
253
|
+
await saveThreadMetadata(threads);
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
98
256
|
remoteId,
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
remoteId,
|
|
105
|
-
externalId: void 0
|
|
106
|
-
};
|
|
257
|
+
externalId: void 0
|
|
258
|
+
};
|
|
259
|
+
});
|
|
107
260
|
},
|
|
108
261
|
async rename(remoteId, newTitle) {
|
|
109
|
-
|
|
110
|
-
const thread = threads.find((t) => t.remoteId === remoteId);
|
|
111
|
-
if (thread) {
|
|
262
|
+
await updateThreadMetadata(remoteId, (thread) => {
|
|
112
263
|
thread.title = newTitle;
|
|
113
|
-
|
|
114
|
-
}
|
|
264
|
+
});
|
|
115
265
|
},
|
|
116
266
|
async updateCustom(remoteId, custom) {
|
|
117
|
-
|
|
118
|
-
const thread = threads.find((t) => t.remoteId === remoteId);
|
|
119
|
-
if (thread) {
|
|
267
|
+
await updateThreadMetadata(remoteId, (thread) => {
|
|
120
268
|
thread.custom = custom;
|
|
121
|
-
|
|
122
|
-
}
|
|
269
|
+
});
|
|
123
270
|
},
|
|
124
271
|
async archive(remoteId) {
|
|
125
|
-
|
|
126
|
-
const thread = threads.find((t) => t.remoteId === remoteId);
|
|
127
|
-
if (thread) {
|
|
272
|
+
await updateThreadMetadata(remoteId, (thread) => {
|
|
128
273
|
thread.status = "archived";
|
|
129
|
-
|
|
130
|
-
}
|
|
274
|
+
});
|
|
131
275
|
},
|
|
132
276
|
async unarchive(remoteId) {
|
|
133
|
-
|
|
134
|
-
const thread = threads.find((t) => t.remoteId === remoteId);
|
|
135
|
-
if (thread) {
|
|
277
|
+
await updateThreadMetadata(remoteId, (thread) => {
|
|
136
278
|
thread.status = "regular";
|
|
137
|
-
|
|
138
|
-
}
|
|
279
|
+
});
|
|
139
280
|
},
|
|
140
281
|
async delete(remoteId) {
|
|
141
|
-
await
|
|
142
|
-
|
|
282
|
+
await mutationQueue.run(threadsKey, async () => {
|
|
283
|
+
const filtered = (await loadThreadMetadata()).filter((t) => t.remoteId !== remoteId);
|
|
284
|
+
await saveThreadMetadata(filtered);
|
|
285
|
+
});
|
|
286
|
+
const key = messagesKey(remoteId);
|
|
287
|
+
await mutationQueue.run(key, () => storage.removeItem(key));
|
|
143
288
|
},
|
|
144
289
|
async fetch(threadId) {
|
|
145
290
|
const thread = (await loadThreadMetadata()).find((t) => t.remoteId === threadId);
|
|
146
|
-
if (!thread) throw new Error("
|
|
291
|
+
if (!thread) throw new Error(`Stored thread "${threadId}" not found while fetching thread metadata.`);
|
|
147
292
|
return {
|
|
148
293
|
remoteId: thread.remoteId,
|
|
149
294
|
externalId: thread.externalId,
|
|
@@ -155,12 +300,9 @@ const createLocalStorageAdapter = (options) => {
|
|
|
155
300
|
async generateTitle(remoteId, messages) {
|
|
156
301
|
if (titleGenerator) {
|
|
157
302
|
const title = await titleGenerator.generateTitle(messages);
|
|
158
|
-
|
|
159
|
-
const thread = threads.find((t) => t.remoteId === remoteId);
|
|
160
|
-
if (thread) {
|
|
303
|
+
await updateThreadMetadata(remoteId, (thread) => {
|
|
161
304
|
thread.title = title;
|
|
162
|
-
|
|
163
|
-
}
|
|
305
|
+
});
|
|
164
306
|
return createAssistantStream((controller) => {
|
|
165
307
|
controller.appendText(title);
|
|
166
308
|
});
|
|
@@ -170,6 +312,6 @@ const createLocalStorageAdapter = (options) => {
|
|
|
170
312
|
};
|
|
171
313
|
};
|
|
172
314
|
//#endregion
|
|
173
|
-
export { createLocalStorageAdapter };
|
|
315
|
+
export { createLocalStorageAdapter, parseStoredMessageRepository, parseStoredThreadMetadata };
|
|
174
316
|
|
|
175
317
|
//# sourceMappingURL=LocalStorageThreadListAdapter.js.map
|