@assistant-ui/core 0.2.12 → 0.2.15
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.js.map +1 -1
- package/dist/adapters/directive-formatter.js.map +1 -1
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +3 -1
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.js.map +1 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +2 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.js.map +1 -1
- package/dist/model-context/registry.js.map +1 -1
- package/dist/model-context/tool.js.map +1 -1
- package/dist/model-context/types.d.ts +1 -0
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/AssistantProvider.js +7 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.js +18 -6
- package/dist/react/AssistantRuntimeProvider.js.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +1 -1
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.js +35 -6
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +29 -7
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -8
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +56 -36
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Interactables.d.ts +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +71 -70
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +2 -13
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +121 -57
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
- package/dist/react/model-context/define-toolkit.js.map +1 -1
- package/dist/react/model-context/external-tool.js.map +1 -1
- package/dist/react/model-context/human-tool.js.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/makeAssistantTool.js.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/provider-tool.js.map +1 -1
- package/dist/react/model-context/stub-tool.js.map +1 -1
- package/dist/react/model-context/toolbox.js.map +1 -1
- package/dist/react/model-context/useAssistantContext.js.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.js +27 -8
- package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.js +33 -10
- package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
- package/dist/react/model-context/useAssistantTool.js +59 -17
- package/dist/react/model-context/useAssistantTool.js.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.js +30 -9
- package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
- package/dist/react/model-context/useInlineRender.js +35 -8
- package/dist/react/model-context/useInlineRender.js.map +1 -1
- package/dist/react/model-context/useInteractableState.js +65 -19
- package/dist/react/model-context/useInteractableState.js.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.js +42 -14
- package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +59 -22
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.js +25 -7
- package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.js +49 -13
- package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.js +25 -7
- package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.js +28 -9
- package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +25 -7
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.js +24 -8
- package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.js +25 -7
- package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.js +25 -7
- package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.js +18 -4
- package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.js +41 -9
- package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.js +4 -1
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.js +25 -7
- package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +31 -13
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +25 -7
- package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.js +18 -4
- package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.js +4 -1
- package/dist/react/primitive-hooks/useThreadMessages.js.map +1 -1
- package/dist/react/primitive-hooks/useVoice.js +63 -13
- package/dist/react/primitive-hooks/useVoice.js.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +42 -7
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +67 -16
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.js +30 -9
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +55 -13
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +68 -16
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +6 -6
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +28 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +665 -163
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.js +18 -2
- package/dist/react/primitives/message/MessageQuote.js.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.js +6 -2
- package/dist/react/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.js +46 -14
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +67 -10
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +50 -10
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +55 -14
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +15 -2
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.js +57 -12
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +33 -11
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +29 -6
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.js +49 -19
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +29 -6
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.js +29 -6
- package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js +83 -28
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.js +29 -6
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +75 -26
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.js +30 -6
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +28 -5
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +19 -4
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js +27 -10
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +16 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +19 -17
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +67 -30
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +44 -10
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.js +17 -12
- package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +34 -6
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +5 -6
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.js.map +1 -1
- package/dist/react/utils/groupParts.d.ts +13 -1
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +17 -5
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/runtime/api/assistant-runtime.js.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +1 -0
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +3 -9
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +3 -6
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +2 -0
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +5 -0
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +1 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +3 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +4 -0
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
- package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +15 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js +35 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.d.ts +5 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/assistant-transport/utils.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -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 +13 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.js.map +1 -1
- package/dist/runtimes/local/local-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +9 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +65 -5
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.js +4 -2
- package/dist/runtimes/local/should-continue.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.js +39 -20
- package/dist/store/clients/chain-of-thought-client.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.js +67 -16
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +2 -4
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +96 -54
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -3
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +2 -15
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts +1 -4
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +63 -23
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +184 -73
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/internal.d.ts +2 -2
- package/dist/store/internal.js +2 -2
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.js +31 -7
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +195 -72
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +7 -0
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -0
- package/dist/store/runtime-clients/liveRef.js +8 -0
- package/dist/store/runtime-clients/liveRef.js.map +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +49 -9
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +220 -54
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +71 -26
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +141 -36
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +196 -72
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.js +2 -9
- package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
- package/dist/store/scopes/message.d.ts +1 -0
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +5 -6
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +1 -0
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +1 -0
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/types/message.d.ts +38 -5
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/json/is-json-equal.js.map +1 -1
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/text.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/thread-history.ts +2 -0
- package/src/index.ts +5 -0
- package/src/internal.ts +1 -0
- package/src/model-context/types.ts +1 -0
- package/src/react/AssistantProvider.tsx +10 -1
- package/src/react/RuntimeAdapter.ts +25 -8
- package/src/react/client/DataRenderers.ts +42 -45
- package/src/react/client/Interactables.ts +261 -261
- package/src/react/client/Tools.ts +9 -9
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
- package/src/react/primitives/message/MessageParts.tsx +64 -13
- package/src/react/providers/TextMessagePartProvider.tsx +5 -3
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
- package/src/react/runtimes/external-message-converter.ts +3 -1
- package/src/react/types/MessagePartComponentTypes.ts +5 -5
- package/src/react/utils/groupParts.ts +27 -0
- package/src/runtime/api/bindings.ts +1 -0
- package/src/runtime/api/message-part-runtime.ts +14 -11
- package/src/runtime/api/message-runtime.ts +7 -0
- package/src/runtime/api/thread-list-runtime.ts +1 -0
- package/src/runtime/api/thread-runtime.ts +7 -0
- package/src/runtime/base/base-thread-runtime-core.ts +1 -0
- package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
- package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +4 -0
- package/src/runtime/utils/resolveToolApprovalResponse.test.ts +91 -0
- package/src/runtime/utils/resolveToolApprovalResponse.ts +55 -0
- package/src/runtime/utils/thread-message-like.ts +10 -1
- package/src/runtimes/external-store/external-store-adapter.ts +1 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
- package/src/runtimes/local/local-runtime-options.ts +1 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +370 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +113 -7
- package/src/runtimes/local/should-continue.ts +24 -13
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
- package/src/runtimes/remote-thread-list/types.ts +1 -0
- package/src/store/clients/chain-of-thought-client.ts +5 -3
- package/src/store/clients/model-context-client.test.ts +5 -4
- package/src/store/clients/model-context-client.ts +21 -21
- package/src/store/clients/no-op-composer-client.ts +5 -3
- package/src/store/clients/runtime-adapter.ts +0 -24
- package/src/store/clients/suggestions.ts +12 -23
- package/src/store/clients/thread-message-client.ts +42 -40
- package/src/store/internal.ts +1 -4
- package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
- package/src/store/runtime-clients/composer-runtime-client.ts +48 -45
- package/src/store/runtime-clients/liveRef.ts +5 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
- package/src/store/runtime-clients/message-runtime-client.ts +42 -40
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
- package/src/store/runtime-clients/thread-list-runtime-client.ts +13 -11
- package/src/store/runtime-clients/thread-runtime-client.ts +20 -16
- package/src/store/runtime-clients/useSubscribable.ts +2 -10
- package/src/store/scopes/message.ts +1 -0
- package/src/store/scopes/part.ts +5 -2
- package/src/store/scopes/thread-list-item.ts +1 -0
- package/src/store/scopes/thread.ts +1 -0
- package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
- package/src/tests/groupMessageParts.test.ts +84 -0
- package/src/tests/groupParts.test.ts +55 -0
- package/src/types/message.ts +45 -3
|
@@ -15,28 +15,30 @@ import type { QueueItemState } from "../scopes/queue-item";
|
|
|
15
15
|
import { AttachmentRuntimeClient } from "./attachment-runtime-client";
|
|
16
16
|
import { useSubscribable } from "./useSubscribable";
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
18
|
+
const useComposerAttachmentClientByIndex = ({
|
|
19
|
+
runtime,
|
|
20
|
+
index,
|
|
21
|
+
}: {
|
|
22
|
+
runtime: ComposerRuntime;
|
|
23
|
+
index: number;
|
|
24
|
+
}) => {
|
|
25
|
+
const attachmentRuntime = useMemo(
|
|
26
|
+
() => runtime.getAttachmentByIndex(index),
|
|
27
|
+
[runtime, index],
|
|
28
|
+
);
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
return useResource(
|
|
31
|
+
AttachmentRuntimeClient({
|
|
32
|
+
runtime: attachmentRuntime,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ComposerAttachmentClientByIndex = resource(
|
|
38
|
+
useComposerAttachmentClientByIndex,
|
|
37
39
|
);
|
|
38
40
|
|
|
39
|
-
const
|
|
41
|
+
const useQueueItemClient = ({
|
|
40
42
|
item,
|
|
41
43
|
onSteer,
|
|
42
44
|
onRemove,
|
|
@@ -44,15 +46,17 @@ const QueueItemClient = resource(function QueueItemClient({
|
|
|
44
46
|
item: QueueItemState;
|
|
45
47
|
onSteer: () => void;
|
|
46
48
|
onRemove: () => void;
|
|
47
|
-
}): ClientOutput<"queueItem"> {
|
|
49
|
+
}): ClientOutput<"queueItem"> => {
|
|
48
50
|
return {
|
|
49
51
|
getState: () => item,
|
|
50
52
|
steer: onSteer,
|
|
51
53
|
remove: onRemove,
|
|
52
54
|
};
|
|
53
|
-
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const QueueItemClient = resource(useQueueItemClient);
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
const useComposerClient = ({
|
|
56
60
|
threadIdRef,
|
|
57
61
|
messageIdRef,
|
|
58
62
|
runtime,
|
|
@@ -60,7 +64,7 @@ export const ComposerClient = resource(function ComposerClient({
|
|
|
60
64
|
threadIdRef: { current: string };
|
|
61
65
|
messageIdRef?: { current: string };
|
|
62
66
|
runtime: ComposerRuntime;
|
|
63
|
-
}): ClientOutput<"composer"> {
|
|
67
|
+
}): ClientOutput<"composer"> => {
|
|
64
68
|
const runtimeState = useSubscribable(runtime);
|
|
65
69
|
const emit = useAssistantEmit();
|
|
66
70
|
|
|
@@ -98,33 +102,30 @@ export const ComposerClient = resource(function ComposerClient({
|
|
|
98
102
|
}, [runtime, emit, threadIdRef, messageIdRef]);
|
|
99
103
|
|
|
100
104
|
const attachments = useClientLookup(
|
|
101
|
-
() =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
),
|
|
105
|
+
runtimeState.attachments.map((attachment, idx) =>
|
|
106
|
+
withKey(
|
|
107
|
+
attachment.id,
|
|
108
|
+
ComposerAttachmentClientByIndex({
|
|
109
|
+
runtime,
|
|
110
|
+
index: idx,
|
|
111
|
+
}),
|
|
112
|
+
[runtime, idx],
|
|
110
113
|
),
|
|
111
|
-
|
|
114
|
+
),
|
|
112
115
|
);
|
|
113
116
|
|
|
114
117
|
const queue = runtimeState.queue;
|
|
115
118
|
const queueItems = useClientLookup(
|
|
116
|
-
() =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}),
|
|
125
|
-
),
|
|
119
|
+
queue.map((item) =>
|
|
120
|
+
withKey(
|
|
121
|
+
item.id,
|
|
122
|
+
QueueItemClient({
|
|
123
|
+
item,
|
|
124
|
+
onSteer: () => runtime.steerQueueItem(item.id),
|
|
125
|
+
onRemove: () => runtime.removeQueueItem(item.id),
|
|
126
|
+
}),
|
|
126
127
|
),
|
|
127
|
-
|
|
128
|
+
),
|
|
128
129
|
);
|
|
129
130
|
|
|
130
131
|
const state = useMemo<ComposerState>(() => {
|
|
@@ -173,4 +174,6 @@ export const ComposerClient = resource(function ComposerClient({
|
|
|
173
174
|
queueItem: (selector) => queueItems.get(selector),
|
|
174
175
|
__internal_getRuntime: () => runtime,
|
|
175
176
|
};
|
|
176
|
-
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const ComposerClient = resource(useComposerClient);
|
|
@@ -3,11 +3,11 @@ import type { ClientOutput } from "@assistant-ui/store";
|
|
|
3
3
|
import type { MessagePartRuntime } from "../../runtime/api/message-part-runtime";
|
|
4
4
|
import { useSubscribable } from "./useSubscribable";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const useMessagePartClient = ({
|
|
7
7
|
runtime,
|
|
8
8
|
}: {
|
|
9
9
|
runtime: MessagePartRuntime;
|
|
10
|
-
}): ClientOutput<"part"> {
|
|
10
|
+
}): ClientOutput<"part"> => {
|
|
11
11
|
const state = useSubscribable(runtime);
|
|
12
12
|
|
|
13
13
|
return {
|
|
@@ -18,4 +18,6 @@ export const MessagePartClient = resource(function MessagePartClient({
|
|
|
18
18
|
runtime.respondToToolApproval(response),
|
|
19
19
|
__internal_getRuntime: () => runtime,
|
|
20
20
|
};
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const MessagePartClient = resource(useMessagePartClient);
|
|
@@ -7,59 +7,60 @@ import {
|
|
|
7
7
|
} from "@assistant-ui/store";
|
|
8
8
|
import type { MessageRuntime } from "../../runtime/api/message-runtime";
|
|
9
9
|
import { useSubscribable } from "./useSubscribable";
|
|
10
|
+
import { liveRef } from "./liveRef";
|
|
10
11
|
import { ComposerClient } from "./composer-runtime-client";
|
|
11
12
|
import { MessagePartClient } from "./message-part-runtime-client";
|
|
12
13
|
import type { MessageState } from "../scopes/message";
|
|
13
14
|
import { AttachmentRuntimeClient } from "./attachment-runtime-client";
|
|
14
15
|
|
|
16
|
+
const useMessageAttachmentClientByIndex = ({
|
|
17
|
+
runtime,
|
|
18
|
+
index,
|
|
19
|
+
}: {
|
|
20
|
+
runtime: MessageRuntime;
|
|
21
|
+
index: number;
|
|
22
|
+
}) => {
|
|
23
|
+
const attachmentRuntime = useMemo(
|
|
24
|
+
() => runtime.getAttachmentByIndex(index),
|
|
25
|
+
[runtime, index],
|
|
26
|
+
);
|
|
27
|
+
return useResource(AttachmentRuntimeClient({ runtime: attachmentRuntime }));
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
const MessageAttachmentClientByIndex = resource(
|
|
16
|
-
|
|
17
|
-
runtime,
|
|
18
|
-
index,
|
|
19
|
-
}: {
|
|
20
|
-
runtime: MessageRuntime;
|
|
21
|
-
index: number;
|
|
22
|
-
}) {
|
|
23
|
-
const attachmentRuntime = useMemo(
|
|
24
|
-
() => runtime.getAttachmentByIndex(index),
|
|
25
|
-
[runtime, index],
|
|
26
|
-
);
|
|
27
|
-
return useResource(AttachmentRuntimeClient({ runtime: attachmentRuntime }));
|
|
28
|
-
},
|
|
31
|
+
useMessageAttachmentClientByIndex,
|
|
29
32
|
);
|
|
30
33
|
|
|
31
|
-
const
|
|
34
|
+
const useMessagePartByIndex = ({
|
|
32
35
|
runtime,
|
|
33
36
|
index,
|
|
34
37
|
}: {
|
|
35
38
|
runtime: MessageRuntime;
|
|
36
39
|
index: number;
|
|
37
|
-
}) {
|
|
40
|
+
}) => {
|
|
38
41
|
const partRuntime = useMemo(
|
|
39
42
|
() => runtime.getMessagePartByIndex(index),
|
|
40
43
|
[runtime, index],
|
|
41
44
|
);
|
|
42
45
|
return useResource(MessagePartClient({ runtime: partRuntime }));
|
|
43
|
-
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const MessagePartByIndex = resource(useMessagePartByIndex);
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
const useMessageClient = ({
|
|
46
51
|
runtime,
|
|
47
52
|
threadIdRef,
|
|
48
53
|
}: {
|
|
49
54
|
runtime: MessageRuntime;
|
|
50
55
|
threadIdRef: { current: string };
|
|
51
|
-
}): ClientOutput<"message"> {
|
|
56
|
+
}): ClientOutput<"message"> => {
|
|
52
57
|
const runtimeState = useSubscribable(runtime);
|
|
53
58
|
|
|
54
59
|
const [isCopiedState, setIsCopied] = useState(false);
|
|
55
60
|
const [isHoveringState, setIsHovering] = useState(false);
|
|
56
61
|
|
|
57
62
|
const messageIdRef = useMemo(
|
|
58
|
-
() => (
|
|
59
|
-
get current() {
|
|
60
|
-
return runtime.getState().id;
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
+
() => liveRef(() => runtime.getState().id),
|
|
63
64
|
[runtime],
|
|
64
65
|
);
|
|
65
66
|
|
|
@@ -71,27 +72,25 @@ export const MessageClient = resource(function MessageClient({
|
|
|
71
72
|
}),
|
|
72
73
|
);
|
|
73
74
|
const parts = useClientLookup(
|
|
74
|
-
() =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
),
|
|
75
|
+
runtimeState.content.map((part, idx) =>
|
|
76
|
+
withKey(
|
|
77
|
+
"toolCallId" in part && part.toolCallId != null
|
|
78
|
+
? `toolCallId-${part.toolCallId}`
|
|
79
|
+
: `index-${idx}`,
|
|
80
|
+
MessagePartByIndex({ runtime, index: idx }),
|
|
81
|
+
[runtime, idx],
|
|
82
82
|
),
|
|
83
|
-
|
|
83
|
+
),
|
|
84
84
|
);
|
|
85
85
|
|
|
86
86
|
const attachments = useClientLookup(
|
|
87
|
-
() =>
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
),
|
|
87
|
+
(runtimeState.attachments ?? []).map((attachment, idx) =>
|
|
88
|
+
withKey(
|
|
89
|
+
attachment.id,
|
|
90
|
+
MessageAttachmentClientByIndex({ runtime, index: idx }),
|
|
91
|
+
[runtime, idx],
|
|
93
92
|
),
|
|
94
|
-
|
|
93
|
+
),
|
|
95
94
|
);
|
|
96
95
|
|
|
97
96
|
const state = useMemo<MessageState>(() => {
|
|
@@ -117,6 +116,7 @@ export const MessageClient = resource(function MessageClient({
|
|
|
117
116
|
|
|
118
117
|
composer: () => composer.methods,
|
|
119
118
|
|
|
119
|
+
delete: () => runtime.delete(),
|
|
120
120
|
reload: (config) => runtime.reload(config),
|
|
121
121
|
speak: () => runtime.speak(),
|
|
122
122
|
stopSpeaking: () => runtime.stopSpeaking(),
|
|
@@ -144,4 +144,6 @@ export const MessageClient = resource(function MessageClient({
|
|
|
144
144
|
|
|
145
145
|
__internal_getRuntime: () => runtime,
|
|
146
146
|
};
|
|
147
|
-
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const MessageClient = resource(useMessageClient);
|
|
@@ -8,11 +8,11 @@ import type {
|
|
|
8
8
|
} from "../../runtime/api/thread-list-item-runtime";
|
|
9
9
|
import { useSubscribable } from "./useSubscribable";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const useThreadListItemClient = ({
|
|
12
12
|
runtime,
|
|
13
13
|
}: {
|
|
14
14
|
runtime: ThreadListItemRuntime;
|
|
15
|
-
}): ClientOutput<"threadListItem"> {
|
|
15
|
+
}): ClientOutput<"threadListItem"> => {
|
|
16
16
|
const state = useSubscribable(runtime);
|
|
17
17
|
const emit = useAssistantEmit();
|
|
18
18
|
|
|
@@ -53,4 +53,6 @@ export const ThreadListItemClient = resource(function ThreadListItemClient({
|
|
|
53
53
|
detach: runtime.detach,
|
|
54
54
|
__internal_getRuntime: () => runtime,
|
|
55
55
|
};
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const ThreadListItemClient = resource(useThreadListItemClient);
|
|
@@ -12,13 +12,13 @@ import { ThreadListItemClient } from "./thread-list-item-runtime-client";
|
|
|
12
12
|
import { ThreadClient } from "./thread-runtime-client";
|
|
13
13
|
import type { ThreadsState } from "../scopes/threads";
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const useThreadListItemClientById = ({
|
|
16
16
|
runtime,
|
|
17
17
|
id,
|
|
18
18
|
}: {
|
|
19
19
|
runtime: ThreadListRuntime;
|
|
20
20
|
id: string;
|
|
21
|
-
}) {
|
|
21
|
+
}) => {
|
|
22
22
|
const threadListItemRuntime = useMemo(
|
|
23
23
|
() => runtime.getItemById(id),
|
|
24
24
|
[runtime, id],
|
|
@@ -28,15 +28,17 @@ const ThreadListItemClientById = resource(function ThreadListItemClientById({
|
|
|
28
28
|
runtime: threadListItemRuntime,
|
|
29
29
|
}),
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const ThreadListItemClientById = resource(useThreadListItemClientById);
|
|
34
|
+
|
|
35
|
+
const useThreadListClient = ({
|
|
34
36
|
runtime,
|
|
35
37
|
__internal_assistantRuntime,
|
|
36
38
|
}: {
|
|
37
39
|
runtime: ThreadListRuntime;
|
|
38
40
|
__internal_assistantRuntime: AssistantRuntime;
|
|
39
|
-
}): ClientOutput<"threads"> {
|
|
41
|
+
}): ClientOutput<"threads"> => {
|
|
40
42
|
const runtimeState = useSubscribable(runtime);
|
|
41
43
|
|
|
42
44
|
const main = useClientResource(
|
|
@@ -45,11 +47,9 @@ export const ThreadListClient = resource(function ThreadListClient({
|
|
|
45
47
|
}),
|
|
46
48
|
);
|
|
47
49
|
const threadItems = useClientLookup(
|
|
48
|
-
() =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
),
|
|
52
|
-
[runtimeState.threadItems, runtime],
|
|
50
|
+
Object.keys(runtimeState.threadItems).map((id) =>
|
|
51
|
+
withKey(id, ThreadListItemClientById({ runtime, id }), [runtime, id]),
|
|
52
|
+
),
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
const state = useMemo<ThreadsState>(() => {
|
|
@@ -96,4 +96,6 @@ export const ThreadListClient = resource(function ThreadListClient({
|
|
|
96
96
|
loadMore: () => runtime.loadMore(),
|
|
97
97
|
__internal_getAssistantRuntime: () => __internal_assistantRuntime,
|
|
98
98
|
};
|
|
99
|
-
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const ThreadListClient = resource(useThreadListClient);
|
|
@@ -3,6 +3,7 @@ import type { ThreadRuntimeEventType } from "../../runtime/interfaces/thread-run
|
|
|
3
3
|
import type { ThreadRuntime } from "../../runtime/api/thread-runtime";
|
|
4
4
|
import { useMemo, useEffect, RefObject } from "react";
|
|
5
5
|
import { useResource, resource, withKey } from "@assistant-ui/tap";
|
|
6
|
+
import { liveRef } from "./liveRef";
|
|
6
7
|
import {
|
|
7
8
|
type ClientOutput,
|
|
8
9
|
useAssistantEmit,
|
|
@@ -14,7 +15,7 @@ import { MessageClient } from "./message-runtime-client";
|
|
|
14
15
|
import { useSubscribable } from "./useSubscribable";
|
|
15
16
|
import type { ThreadState } from "../scopes/thread";
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
+
const useMessageClientById = ({
|
|
18
19
|
runtime,
|
|
19
20
|
id,
|
|
20
21
|
threadIdRef,
|
|
@@ -22,20 +23,22 @@ const MessageClientById = resource(function MessageClientById({
|
|
|
22
23
|
runtime: ThreadRuntime;
|
|
23
24
|
id: string;
|
|
24
25
|
threadIdRef: RefObject<string>;
|
|
25
|
-
}) {
|
|
26
|
+
}) => {
|
|
26
27
|
const messageRuntime = useMemo(
|
|
27
28
|
() => runtime.getMessageById(id),
|
|
28
29
|
[runtime, id],
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
return useResource(MessageClient({ runtime: messageRuntime, threadIdRef }));
|
|
32
|
-
}
|
|
33
|
+
};
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const MessageClientById = resource(useMessageClientById);
|
|
36
|
+
|
|
37
|
+
const useThreadClient = ({
|
|
35
38
|
runtime,
|
|
36
39
|
}: {
|
|
37
40
|
runtime: ThreadRuntime;
|
|
38
|
-
}): ClientOutput<"thread"> {
|
|
41
|
+
}): ClientOutput<"thread"> => {
|
|
39
42
|
const runtimeState = useSubscribable(runtime);
|
|
40
43
|
const emit = useAssistantEmit();
|
|
41
44
|
|
|
@@ -65,11 +68,7 @@ export const ThreadClient = resource(function ThreadClient({
|
|
|
65
68
|
}, [runtime, emit]);
|
|
66
69
|
|
|
67
70
|
const threadIdRef = useMemo(
|
|
68
|
-
() => (
|
|
69
|
-
get current() {
|
|
70
|
-
return runtime.getState()!.threadId;
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
71
|
+
() => liveRef(() => runtime.getState()!.threadId),
|
|
73
72
|
[runtime],
|
|
74
73
|
);
|
|
75
74
|
|
|
@@ -80,11 +79,13 @@ export const ThreadClient = resource(function ThreadClient({
|
|
|
80
79
|
}),
|
|
81
80
|
);
|
|
82
81
|
const messages = useClientLookup(
|
|
83
|
-
() =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
runtimeState.messages.map((m) =>
|
|
83
|
+
withKey(m.id, MessageClientById({ runtime, id: m.id, threadIdRef }), [
|
|
84
|
+
runtime,
|
|
85
|
+
m.id,
|
|
86
|
+
threadIdRef,
|
|
87
|
+
]),
|
|
88
|
+
),
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
const state = useMemo<ThreadState>(() => {
|
|
@@ -109,6 +110,7 @@ export const ThreadClient = resource(function ThreadClient({
|
|
|
109
110
|
getState: () => state,
|
|
110
111
|
composer: () => composer.methods,
|
|
111
112
|
append: runtime.append,
|
|
113
|
+
deleteMessage: runtime.deleteMessage,
|
|
112
114
|
startRun: runtime.startRun,
|
|
113
115
|
resumeRun: runtime.resumeRun,
|
|
114
116
|
cancelRun: runtime.cancelRun,
|
|
@@ -132,4 +134,6 @@ export const ThreadClient = resource(function ThreadClient({
|
|
|
132
134
|
},
|
|
133
135
|
__internal_getRuntime: () => runtime,
|
|
134
136
|
};
|
|
135
|
-
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const ThreadClient = resource(useThreadClient);
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
2
|
import type { SubscribableWithState } from "../../subscribable/subscribable";
|
|
3
3
|
|
|
4
4
|
export const useSubscribable = <T>(
|
|
5
5
|
subscribable: Omit<SubscribableWithState<T, any>, "path">,
|
|
6
6
|
) => {
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setState(subscribable.getState());
|
|
10
|
-
return subscribable.subscribe(() => {
|
|
11
|
-
setState(subscribable.getState());
|
|
12
|
-
});
|
|
13
|
-
}, [subscribable]);
|
|
14
|
-
|
|
15
|
-
return subscribable.getState();
|
|
7
|
+
return useSyncExternalStore(subscribable.subscribe, subscribable.getState);
|
|
16
8
|
};
|
|
@@ -42,6 +42,7 @@ export type MessageMethods = {
|
|
|
42
42
|
*/
|
|
43
43
|
getState(): MessageState;
|
|
44
44
|
composer(): ComposerMethods;
|
|
45
|
+
delete(): void | Promise<void>;
|
|
45
46
|
reload(config?: { runConfig?: RunConfig }): void;
|
|
46
47
|
/** @deprecated This API is still under active development and might change without notice. */
|
|
47
48
|
speak(): void;
|
package/src/store/scopes/part.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ToolResponse } from "assistant-stream";
|
|
|
2
2
|
import type {
|
|
3
3
|
ThreadUserMessagePart,
|
|
4
4
|
ThreadAssistantMessagePart,
|
|
5
|
+
ToolApprovalResponse,
|
|
5
6
|
ToolCallMessagePartStatus,
|
|
6
7
|
} from "../../types/message";
|
|
7
8
|
import type { MessagePartStatus } from "../../types/message";
|
|
@@ -27,9 +28,11 @@ export type PartMethods = {
|
|
|
27
28
|
*/
|
|
28
29
|
resumeToolCall(payload: unknown): void;
|
|
29
30
|
/**
|
|
30
|
-
* Respond to a server-side tool approval gate. The approval id is read from
|
|
31
|
+
* Respond to a server-side tool approval gate. The approval id is read from
|
|
32
|
+
* the part. Accepts a boolean decision or the id of one of the approval's
|
|
33
|
+
* options.
|
|
31
34
|
*/
|
|
32
|
-
respondToToolApproval(response:
|
|
35
|
+
respondToToolApproval(response: ToolApprovalResponse): void;
|
|
33
36
|
__internal_getRuntime?(): MessagePartRuntime;
|
|
34
37
|
};
|
|
35
38
|
|
|
@@ -6,6 +6,7 @@ export type ThreadListItemState = {
|
|
|
6
6
|
readonly remoteId: string | undefined;
|
|
7
7
|
readonly externalId: string | undefined;
|
|
8
8
|
readonly title?: string | undefined;
|
|
9
|
+
readonly lastMessageAt?: Date | undefined;
|
|
9
10
|
readonly status: ThreadListItemStatus;
|
|
10
11
|
readonly custom?: Record<string, unknown> | undefined;
|
|
11
12
|
};
|
|
@@ -88,6 +88,7 @@ export type ThreadMethods = {
|
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
90
|
append(message: CreateAppendMessage): void;
|
|
91
|
+
deleteMessage(messageId: string): void | Promise<void>;
|
|
91
92
|
/**
|
|
92
93
|
* Start a new run with the given configuration.
|
|
93
94
|
* @param config The configuration for starting the run
|
|
@@ -49,6 +49,15 @@ describe("ExternalStoreThreadRuntimeCore - state reference stability", () => {
|
|
|
49
49
|
expect(runtime.capabilities).not.toBe(capsBefore);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
it("enables delete when setMessages is provided", () => {
|
|
53
|
+
const runtime = new ExternalStoreThreadRuntimeCore(
|
|
54
|
+
mockContextProvider,
|
|
55
|
+
makeStore({ setMessages: vi.fn() }),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(runtime.capabilities.delete).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
52
61
|
it("should maintain stable reference across repeated setAdapter calls", () => {
|
|
53
62
|
const runtime = new ExternalStoreThreadRuntimeCore(
|
|
54
63
|
mockContextProvider,
|
|
@@ -152,6 +161,54 @@ describe("ExternalStoreThreadRuntimeCore - state reference stability", () => {
|
|
|
152
161
|
|
|
153
162
|
expect(runtime.capabilities).toBe(capsBefore);
|
|
154
163
|
});
|
|
164
|
+
|
|
165
|
+
describe("deleteMessage", () => {
|
|
166
|
+
it("removes only the selected message", async () => {
|
|
167
|
+
const setMessages = vi.fn();
|
|
168
|
+
const runtime = new ExternalStoreThreadRuntimeCore(
|
|
169
|
+
mockContextProvider,
|
|
170
|
+
makeStore({
|
|
171
|
+
messages: [
|
|
172
|
+
{
|
|
173
|
+
id: "u1",
|
|
174
|
+
role: "user",
|
|
175
|
+
content: [{ type: "text", text: "first" }],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "a1",
|
|
179
|
+
role: "assistant",
|
|
180
|
+
content: [{ type: "text", text: "answer" }],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "u2",
|
|
184
|
+
role: "user",
|
|
185
|
+
content: [{ type: "text", text: "second" }],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
setMessages,
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
await runtime.deleteMessage("a1");
|
|
193
|
+
|
|
194
|
+
expect(setMessages).toHaveBeenCalledWith([
|
|
195
|
+
expect.objectContaining({ id: "u1" }),
|
|
196
|
+
expect.objectContaining({ id: "u2" }),
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("delegates to onDelete when provided", async () => {
|
|
201
|
+
const onDelete = vi.fn();
|
|
202
|
+
const runtime = new ExternalStoreThreadRuntimeCore(
|
|
203
|
+
mockContextProvider,
|
|
204
|
+
makeStore({ onDelete }),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
await runtime.deleteMessage("m1");
|
|
208
|
+
|
|
209
|
+
expect(onDelete).toHaveBeenCalledWith("m1");
|
|
210
|
+
});
|
|
211
|
+
});
|
|
155
212
|
});
|
|
156
213
|
describe("ExternalStoreThreadRuntimeCore - optimistic message reconciliation", () => {
|
|
157
214
|
type Raw = {
|