@assistant-ui/core 0.1.13 → 0.1.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.d.ts +6 -0
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +54 -9
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/{mention.d.ts → directive-formatter.d.ts} +2 -4
- package/dist/adapters/directive-formatter.d.ts.map +1 -0
- package/dist/adapters/{mention.js → directive-formatter.js} +4 -9
- package/dist/adapters/directive-formatter.js.map +1 -0
- package/dist/adapters/index.d.ts +1 -3
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +1 -3
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +1 -0
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +1 -18
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- 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 +1 -0
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +1 -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/registry.d.ts +2 -2
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +1 -1
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +1 -1
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/model-context/types.js +0 -3
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -1
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +14 -0
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Tools.d.ts +1 -1
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +1 -0
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +2 -2
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.js +1 -0
- package/dist/react/model-context/useInlineRender.js.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +1 -1
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +16 -17
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +2 -1
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +1 -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 +3 -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 +5 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +22 -7
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +2 -2
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +2 -2
- package/dist/react/runtimes/cloud/auiV0.d.ts.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 +4 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +10 -0
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +6 -0
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/useToolInvocations.d.ts.map +1 -1
- package/dist/react/runtimes/useToolInvocations.js +2 -0
- package/dist/react/runtimes/useToolInvocations.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +2 -0
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +1 -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/attachment-runtime.js +0 -3
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +6 -6
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +4 -2
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +5 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +10 -9
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +4 -3
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +2 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +26 -5
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- 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 +7 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +1 -4
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/utils/auto-status.d.ts +1 -1
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +6 -0
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +17 -0
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +1 -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.d.ts +1 -1
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/assistant-transport/utils.js +1 -1
- package/dist/runtimes/assistant-transport/utils.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +8 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -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-list-runtime-core.js +27 -25
- 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 +4 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +2 -2
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -2
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -2
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -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 +1 -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 +2 -2
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +1 -0
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +1 -15
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +12 -0
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -0
- package/dist/tests/remote-thread-list-test-helpers.js +48 -0
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -0
- package/dist/types/directive.d.ts +19 -0
- package/dist/types/directive.d.ts.map +1 -0
- package/dist/types/directive.js +2 -0
- package/dist/types/directive.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +2 -2
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +1 -1
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/adapters/attachment.ts +68 -16
- package/src/adapters/{mention.ts → directive-formatter.ts} +8 -20
- package/src/adapters/index.ts +2 -9
- package/src/adapters/speech.ts +1 -16
- package/src/adapters/thread-history.ts +1 -8
- package/src/adapters/trigger.ts +1 -37
- package/src/index.ts +3 -24
- package/src/model-context/frame/host.ts +6 -5
- package/src/model-context/frame/provider.ts +6 -5
- package/src/model-context/registry.ts +6 -6
- package/src/model-context/tool.ts +1 -1
- package/src/model-context/types.ts +1 -17
- package/src/react/AssistantRuntimeProvider.tsx +1 -1
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +1 -1
- package/src/react/client/DataRenderers.ts +19 -3
- package/src/react/client/Tools.ts +4 -3
- package/src/react/model-context/makeAssistantTool.ts +1 -1
- package/src/react/model-context/makeAssistantToolUI.ts +1 -1
- package/src/react/model-context/useInlineRender.ts +3 -2
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -0
- package/src/react/primitives/composer/ComposerAttachments.tsx +7 -1
- package/src/react/primitives/message/MessageAttachments.tsx +7 -1
- package/src/react/primitives/message/MessageParts.tsx +27 -17
- package/src/react/primitives/part/PartMessages.tsx +1 -1
- package/src/react/primitives/thread/ThreadMessages.tsx +3 -2
- package/src/react/primitives/threadList/ThreadListItems.tsx +7 -1
- package/src/react/providers/AttachmentByIndexProvider.tsx +1 -1
- package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +1 -1
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +1 -1
- package/src/react/providers/MessageByIndexProvider.tsx +1 -1
- package/src/react/providers/PartByIndexProvider.tsx +1 -1
- package/src/react/providers/QueueItemByIndexProvider.tsx +1 -1
- package/src/react/providers/SuggestionByIndexProvider.tsx +1 -1
- package/src/react/providers/TextMessagePartProvider.tsx +1 -1
- package/src/react/providers/ThreadListItemByIndexProvider.tsx +1 -1
- package/src/react/providers/ThreadListItemRuntimeProvider.tsx +1 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +7 -8
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +28 -8
- package/src/react/runtimes/RuntimeAdapterProvider.tsx +1 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +3 -3
- package/src/react/runtimes/cloud/auiV0.ts +5 -2
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -3
- package/src/react/runtimes/useLocalRuntime.ts +10 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +6 -0
- package/src/react/runtimes/useToolInvocations.ts +2 -0
- package/src/react/types/MessagePartComponentTypes.ts +1 -1
- package/src/react/types/scopes/dataRenderers.ts +2 -0
- package/src/runtime/api/assistant-runtime.ts +1 -1
- package/src/runtime/api/attachment-runtime.ts +0 -4
- package/src/runtime/api/message-runtime.ts +8 -8
- package/src/runtime/api/thread-list-runtime.ts +13 -5
- package/src/runtime/api/thread-runtime.ts +13 -12
- package/src/runtime/base/base-thread-runtime-core.ts +1 -1
- package/src/runtime/base/default-edit-composer-runtime-core.ts +35 -5
- package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +7 -0
- package/src/runtime/internal.ts +1 -4
- package/src/runtime/utils/auto-status.ts +1 -1
- package/src/runtime/utils/chat-model-adapter.ts +1 -1
- package/src/runtime/utils/message-repository.ts +26 -0
- package/src/runtime/utils/thread-message-like.ts +4 -1
- package/src/runtimes/assistant-transport/utils.ts +5 -1
- package/src/runtimes/external-store/external-store-adapter.ts +8 -0
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +35 -29
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +4 -0
- package/src/runtimes/remote-thread-list/adapter/in-memory.ts +2 -2
- package/src/runtimes/remote-thread-list/types.ts +1 -1
- package/src/store/runtime-clients/attachment-runtime-client.ts +2 -2
- package/src/store/runtime-clients/composer-runtime-client.ts +2 -2
- package/src/store/runtime-clients/message-part-runtime-client.ts +2 -2
- package/src/store/runtime-clients/message-runtime-client.ts +2 -2
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +1 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +4 -3
- package/src/store/runtime-clients/thread-runtime-client.ts +3 -3
- package/src/store/scopes/threads.ts +1 -0
- package/src/subscribable/subscribable.ts +1 -24
- package/src/tests/MessageRepository.test.ts +141 -0
- package/src/tests/OptimisticState-list-race.test.ts +5 -9
- package/src/tests/RemoteThreadListThreadListRuntimeCore-reload.test.ts +209 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-dedupe.test.ts +139 -0
- package/src/tests/attachment.test.ts +180 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +312 -0
- package/src/tests/{mention-formatter.test.ts → directive-formatter.test.ts} +26 -1
- package/src/tests/external-store-thread-list-runtime-core.test.ts +212 -0
- package/src/tests/get-thread-state-isRunning.test.ts +93 -0
- package/src/tests/remote-thread-list-isLoading.test.ts +6 -10
- package/src/tests/remote-thread-list-test-helpers.ts +70 -0
- package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +17 -1
- package/src/types/directive.ts +19 -0
- package/src/types/index.ts +1 -3
- package/src/types/message.ts +0 -12
- package/src/types/trigger.ts +2 -10
- package/src/utils/json/is-json.ts +1 -1
- package/dist/adapters/mention.d.ts.map +0 -1
- package/dist/adapters/mention.js.map +0 -1
- package/dist/types/mention.d.ts +0 -21
- package/dist/types/mention.d.ts.map +0 -1
- package/dist/types/mention.js +0 -2
- package/dist/types/mention.js.map +0 -1
- package/src/types/mention.ts +0 -39
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { resource, tapState, tapCallback } from "@assistant-ui/tap";
|
|
2
|
-
import {
|
|
3
|
-
import { DataRenderersState } from "../types/scopes/dataRenderers";
|
|
4
|
-
import { DataMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
2
|
+
import type { ClientOutput } from "@assistant-ui/store";
|
|
3
|
+
import type { DataRenderersState } from "../types/scopes/dataRenderers";
|
|
4
|
+
import type { DataMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
5
5
|
|
|
6
6
|
export const DataRenderers = resource((): ClientOutput<"dataRenderers"> => {
|
|
7
7
|
const [state, setState] = tapState<DataRenderersState>(() => ({
|
|
8
8
|
renderers: {},
|
|
9
|
+
fallbacks: [],
|
|
9
10
|
}));
|
|
10
11
|
|
|
11
12
|
const setDataUI = tapCallback(
|
|
@@ -35,8 +36,23 @@ export const DataRenderers = resource((): ClientOutput<"dataRenderers"> => {
|
|
|
35
36
|
[],
|
|
36
37
|
);
|
|
37
38
|
|
|
39
|
+
const setFallbackDataUI = tapCallback((render: DataMessagePartComponent) => {
|
|
40
|
+
setState((prev) => ({
|
|
41
|
+
...prev,
|
|
42
|
+
fallbacks: [...prev.fallbacks, render],
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
setState((prev) => ({
|
|
47
|
+
...prev,
|
|
48
|
+
fallbacks: prev.fallbacks.filter((r) => r !== render),
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
38
53
|
return {
|
|
39
54
|
getState: () => state,
|
|
40
55
|
setDataUI,
|
|
56
|
+
setFallbackDataUI,
|
|
41
57
|
};
|
|
42
58
|
});
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
type ClientOutput,
|
|
5
5
|
attachTransformScopes,
|
|
6
6
|
} from "@assistant-ui/store";
|
|
7
|
-
import { ToolsState } from "../types/scopes/tools";
|
|
7
|
+
import type { ToolsState } from "../types/scopes/tools";
|
|
8
8
|
import type { Tool } from "assistant-stream";
|
|
9
|
-
import {
|
|
10
|
-
import { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
9
|
+
import type { Toolkit } from "../model-context/toolbox";
|
|
10
|
+
import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
11
11
|
import { ModelContext } from "../../store";
|
|
12
12
|
|
|
13
13
|
export const Tools = resource(
|
|
@@ -78,6 +78,7 @@ export const Tools = resource(
|
|
|
78
78
|
);
|
|
79
79
|
|
|
80
80
|
return () => {
|
|
81
|
+
// biome-ignore lint/suspicious/useIterableCallbackReturn: forEach callback intentionally has no return
|
|
81
82
|
unsubscribes.forEach((fn) => fn());
|
|
82
83
|
};
|
|
83
84
|
}, [toolkit, setToolUI, clientRef]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FC, useCallback, useEffect, useState } from "react";
|
|
2
|
-
import { ToolCallMessagePartProps } from "../types/MessagePartComponentTypes";
|
|
1
|
+
import { type FC, useCallback, useEffect, useState } from "react";
|
|
2
|
+
import type { ToolCallMessagePartProps } from "../types/MessagePartComponentTypes";
|
|
3
3
|
import { create } from "zustand";
|
|
4
4
|
|
|
5
5
|
export const useInlineRender = <TArgs, TResult>(
|
|
@@ -17,6 +17,7 @@ export const useInlineRender = <TArgs, TResult>(
|
|
|
17
17
|
|
|
18
18
|
return useCallback(
|
|
19
19
|
function ToolUI(args) {
|
|
20
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
20
21
|
const store = useToolUIStore();
|
|
21
22
|
return store.toolUI(args);
|
|
22
23
|
},
|
|
@@ -87,6 +87,7 @@ export const ChainOfThoughtPrimitiveParts: FC<
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
90
91
|
const messageComponents = useMemo(
|
|
91
92
|
() => ({
|
|
92
93
|
Reasoning: components?.Reasoning,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Attachment } from "../../../types/attachment";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ComponentType,
|
|
4
|
+
type FC,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
memo,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from "react";
|
|
3
9
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
10
|
import { ComposerAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider";
|
|
5
11
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { CompleteAttachment } from "../../../types/attachment";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ComponentType,
|
|
4
|
+
type FC,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
memo,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from "react";
|
|
3
9
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
10
|
import { MessageAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider";
|
|
5
11
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type FC,
|
|
4
4
|
type ReactNode,
|
|
5
5
|
memo,
|
|
6
|
-
PropsWithChildren,
|
|
6
|
+
type PropsWithChildren,
|
|
7
7
|
useMemo,
|
|
8
8
|
} from "react";
|
|
9
9
|
import {
|
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
QuoteMessagePartComponent,
|
|
33
33
|
} from "../../types/MessagePartComponentTypes";
|
|
34
34
|
import type { MessagePartStatus } from "../../../types/message";
|
|
35
|
+
import type { DataRenderersState } from "../../types/scopes/dataRenderers";
|
|
35
36
|
import { useShallow } from "zustand/shallow";
|
|
36
37
|
|
|
37
38
|
type MessagePartRange =
|
|
@@ -284,17 +285,25 @@ const ToolUIDisplay = ({
|
|
|
284
285
|
return <Render {...props} />;
|
|
285
286
|
};
|
|
286
287
|
|
|
288
|
+
const getDataRenderer = (
|
|
289
|
+
dataRenderers: DataRenderersState,
|
|
290
|
+
name: string,
|
|
291
|
+
inlineFallback: DataMessagePartComponent | undefined,
|
|
292
|
+
): DataMessagePartComponent | undefined => {
|
|
293
|
+
const named = dataRenderers.renderers[name]?.[0];
|
|
294
|
+
if (named) return named;
|
|
295
|
+
return dataRenderers.fallbacks[0] ?? inlineFallback;
|
|
296
|
+
};
|
|
297
|
+
|
|
287
298
|
const DataUIDisplay = ({
|
|
288
299
|
Fallback,
|
|
289
300
|
...props
|
|
290
301
|
}: {
|
|
291
302
|
Fallback: DataMessagePartComponent | undefined;
|
|
292
303
|
} & DataMessagePartProps) => {
|
|
293
|
-
const Render = useAuiState((s) =>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return Render;
|
|
297
|
-
});
|
|
304
|
+
const Render = useAuiState((s) =>
|
|
305
|
+
getDataRenderer(s.dataRenderers, props.name, Fallback),
|
|
306
|
+
);
|
|
298
307
|
if (!Render) return null;
|
|
299
308
|
return <Render {...props} />;
|
|
300
309
|
};
|
|
@@ -522,12 +531,11 @@ const RegisteredToolUI: FC = () => {
|
|
|
522
531
|
*/
|
|
523
532
|
const RegisteredDataRendererUI: FC = () => {
|
|
524
533
|
const part = useAuiState((s) => s.part);
|
|
525
|
-
const Render = useAuiState((s) =>
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
});
|
|
534
|
+
const Render = useAuiState((s) =>
|
|
535
|
+
s.part.type === "data"
|
|
536
|
+
? (getDataRenderer(s.dataRenderers, s.part.name, undefined) ?? null)
|
|
537
|
+
: null,
|
|
538
|
+
);
|
|
531
539
|
|
|
532
540
|
if (!Render || part.type !== "data") return null;
|
|
533
541
|
|
|
@@ -584,6 +592,9 @@ const MessagePrimitivePartsInner: FC<{
|
|
|
584
592
|
}> = ({ children }) => {
|
|
585
593
|
const aui = useAui();
|
|
586
594
|
const contentLength = useAuiState((s) => s.message.parts.length);
|
|
595
|
+
// Subscribed (not snapshotted like `tools`) so fallbacks registered after
|
|
596
|
+
// the first render trigger a re-render and `hasUI` re-evaluates.
|
|
597
|
+
const dataRenderers = useAuiState((s) => s.dataRenderers);
|
|
587
598
|
|
|
588
599
|
// biome-ignore lint/correctness/useExhaustiveDependencies: aui accessors are stable refs
|
|
589
600
|
return useMemo(
|
|
@@ -609,10 +620,9 @@ const MessagePrimitivePartsInner: FC<{
|
|
|
609
620
|
};
|
|
610
621
|
}
|
|
611
622
|
if (state.type === "data") {
|
|
612
|
-
const
|
|
613
|
-
state.name
|
|
614
|
-
|
|
615
|
-
const hasUI = Array.isArray(entry) ? !!entry[0] : !!entry;
|
|
623
|
+
const hasUI =
|
|
624
|
+
getDataRenderer(dataRenderers, state.name, undefined) !==
|
|
625
|
+
undefined;
|
|
616
626
|
return {
|
|
617
627
|
...state,
|
|
618
628
|
dataRendererUI: hasUI ? (
|
|
@@ -629,7 +639,7 @@ const MessagePrimitivePartsInner: FC<{
|
|
|
629
639
|
</RenderChildrenWithAccessor>
|
|
630
640
|
</PartByIndexProvider>
|
|
631
641
|
)),
|
|
632
|
-
[contentLength, children],
|
|
642
|
+
[contentLength, children, dataRenderers],
|
|
633
643
|
);
|
|
634
644
|
};
|
|
635
645
|
|
|
@@ -3,7 +3,7 @@ import { useAuiState } from "@assistant-ui/store";
|
|
|
3
3
|
import type { ThreadMessage } from "../../../types/message";
|
|
4
4
|
import { ReadonlyThreadProvider } from "../../providers/ReadonlyThreadProvider";
|
|
5
5
|
import {
|
|
6
|
-
ThreadPrimitiveMessages,
|
|
6
|
+
type ThreadPrimitiveMessages,
|
|
7
7
|
ThreadPrimitiveMessagesImpl,
|
|
8
8
|
} from "../thread/ThreadMessages";
|
|
9
9
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "react";
|
|
8
8
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
9
9
|
import { MessageByIndexProvider } from "../../providers/MessageByIndexProvider";
|
|
10
|
-
import { MessageState } from "../../../store";
|
|
10
|
+
import type { MessageState } from "../../../store";
|
|
11
11
|
|
|
12
12
|
type MessagesComponentConfig =
|
|
13
13
|
| {
|
|
@@ -124,9 +124,10 @@ const getComponent = (
|
|
|
124
124
|
DEFAULT_SYSTEM_MESSAGE
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
|
-
default:
|
|
127
|
+
default: {
|
|
128
128
|
const _exhaustiveCheck: never = role;
|
|
129
129
|
throw new Error(`Unknown message role: ${_exhaustiveCheck}`);
|
|
130
|
+
}
|
|
130
131
|
}
|
|
131
132
|
};
|
|
132
133
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ComponentType,
|
|
3
|
+
type FC,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
memo,
|
|
6
|
+
useMemo,
|
|
7
|
+
} from "react";
|
|
2
8
|
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
3
9
|
import type { ThreadListItemState } from "../../../store/scopes/thread-list-item";
|
|
4
10
|
import { ThreadListItemByIndexProvider } from "../../providers/ThreadListItemByIndexProvider";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
2
|
import { useAui, useAuiState, AuiProvider } from "@assistant-ui/store";
|
|
3
3
|
import { ChainOfThoughtClient } from "../../store/clients/chain-of-thought-client";
|
|
4
4
|
import type { ChainOfThoughtPart } from "../../store/scopes/chain-of-thought";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
2
|
import { useAui, AuiProvider, type ClientOutput } from "@assistant-ui/store";
|
|
3
3
|
import type { PartState } from "../../store/scopes/part";
|
|
4
4
|
import { resource, tapMemo } from "@assistant-ui/tap";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
2
|
import { useAui, AuiProvider } from "@assistant-ui/store";
|
|
3
3
|
import type { ThreadListItemRuntime } from "../..";
|
|
4
4
|
import { ThreadListItemClient } from "../../store/internal";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FC,
|
|
2
|
+
type FC,
|
|
3
3
|
useCallback,
|
|
4
4
|
useRef,
|
|
5
5
|
useEffect,
|
|
6
6
|
memo,
|
|
7
|
-
PropsWithChildren,
|
|
8
|
-
ComponentType,
|
|
7
|
+
type PropsWithChildren,
|
|
8
|
+
type ComponentType,
|
|
9
9
|
useMemo,
|
|
10
10
|
} from "react";
|
|
11
|
-
import { UseBoundStore, StoreApi, create } from "zustand";
|
|
11
|
+
import { type UseBoundStore, type StoreApi, create } from "zustand";
|
|
12
12
|
import { useAui } from "@assistant-ui/store";
|
|
13
13
|
import { ThreadListItemRuntimeProvider } from "../providers/ThreadListItemRuntimeProvider";
|
|
14
14
|
import type { ThreadRuntimeCore } from "../../runtime/interfaces/thread-runtime-core";
|
|
15
15
|
import type { ThreadListRuntimeCore } from "../../runtime/interfaces/thread-list-runtime-core";
|
|
16
16
|
import type { AssistantRuntime } from "../../runtime/api/assistant-runtime";
|
|
17
17
|
import { BaseSubscribable } from "../../subscribable/subscribable";
|
|
18
|
-
import { ThreadRuntimeImpl } from "../../runtime/api/thread-runtime";
|
|
18
|
+
import type { ThreadRuntimeImpl } from "../../runtime/api/thread-runtime";
|
|
19
19
|
import { ThreadListRuntimeImpl } from "../../runtime/api/thread-list-runtime";
|
|
20
20
|
|
|
21
21
|
type RemoteThreadListHook = () => AssistantRuntime;
|
|
@@ -116,9 +116,8 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
|
116
116
|
|
|
117
117
|
useEffect(() => {
|
|
118
118
|
const runtimeCore = threadBinding.getState();
|
|
119
|
-
const setGetInitializePromise = (runtimeCore as Record<string, unknown>)
|
|
120
|
-
|
|
121
|
-
];
|
|
119
|
+
const setGetInitializePromise = (runtimeCore as Record<string, unknown>)
|
|
120
|
+
.__internal_setGetInitializePromise;
|
|
122
121
|
if (typeof setGetInitializePromise === "function") {
|
|
123
122
|
setGetInitializePromise.call(runtimeCore, () => initPromiseRef.current);
|
|
124
123
|
}
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
import type { RemoteThreadListOptions } from "../../runtimes/remote-thread-list/types";
|
|
17
17
|
import { RemoteThreadListHookInstanceManager } from "./RemoteThreadListHookInstanceManager";
|
|
18
18
|
import {
|
|
19
|
-
ComponentType,
|
|
20
|
-
FC,
|
|
19
|
+
type ComponentType,
|
|
20
|
+
type FC,
|
|
21
21
|
Fragment,
|
|
22
|
-
PropsWithChildren,
|
|
22
|
+
type PropsWithChildren,
|
|
23
23
|
useEffect,
|
|
24
24
|
useId,
|
|
25
25
|
} from "react";
|
|
@@ -36,6 +36,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
36
36
|
private readonly _hookManager: RemoteThreadListHookInstanceManager;
|
|
37
37
|
|
|
38
38
|
private _loadThreadsPromise: Promise<void> | undefined;
|
|
39
|
+
private _loadGeneration = 0;
|
|
39
40
|
|
|
40
41
|
private _mainThreadId!: string;
|
|
41
42
|
private readonly _state = new OptimisticState<RemoteThreadState>({
|
|
@@ -54,6 +55,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
54
55
|
public getLoadThreadsPromise() {
|
|
55
56
|
// TODO this needs to be cached in case this promise is loaded during suspense
|
|
56
57
|
if (!this._loadThreadsPromise) {
|
|
58
|
+
const generation = this._loadGeneration;
|
|
57
59
|
this._loadThreadsPromise = this._state
|
|
58
60
|
.optimisticUpdate({
|
|
59
61
|
execute: () => this._options.adapter.list(),
|
|
@@ -63,7 +65,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
63
65
|
isLoading: true,
|
|
64
66
|
};
|
|
65
67
|
},
|
|
68
|
+
// biome-ignore lint/suspicious/noThenProperty: OptimisticState reducer pattern
|
|
66
69
|
then: (state, l) => {
|
|
70
|
+
if (generation !== this._loadGeneration) return state;
|
|
67
71
|
const newThreadIds = [];
|
|
68
72
|
const newArchivedThreadIds = [];
|
|
69
73
|
const newThreadIdMap = {} as Record<string, THREAD_MAPPING_ID>;
|
|
@@ -118,6 +122,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
118
122
|
},
|
|
119
123
|
})
|
|
120
124
|
.catch(() => {
|
|
125
|
+
if (generation !== this._loadGeneration) return;
|
|
121
126
|
this._loadThreadsPromise = undefined;
|
|
122
127
|
this._state.update({
|
|
123
128
|
...this._state.baseValue,
|
|
@@ -179,6 +184,12 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
186
|
|
|
187
|
+
public reload() {
|
|
188
|
+
this._loadGeneration++;
|
|
189
|
+
this._loadThreadsPromise = undefined;
|
|
190
|
+
return this.getLoadThreadsPromise();
|
|
191
|
+
}
|
|
192
|
+
|
|
182
193
|
public get isLoading() {
|
|
183
194
|
return this._state.value.isLoading;
|
|
184
195
|
}
|
|
@@ -247,15 +258,23 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
247
258
|
[remoteMetadata.remoteId]: mappingId,
|
|
248
259
|
};
|
|
249
260
|
|
|
261
|
+
// Filter both arrays first so a concurrent `list()` can't leave the id
|
|
262
|
+
// duplicated or under the wrong status.
|
|
263
|
+
const threadIdsWithoutRemote = state.threadIds.filter(
|
|
264
|
+
(id) => id !== remoteMetadata.remoteId,
|
|
265
|
+
);
|
|
266
|
+
const archivedThreadIdsWithoutRemote = state.archivedThreadIds.filter(
|
|
267
|
+
(id) => id !== remoteMetadata.remoteId,
|
|
268
|
+
);
|
|
269
|
+
|
|
250
270
|
const newThreadIds =
|
|
251
271
|
remoteMetadata.status === "regular"
|
|
252
|
-
? [...
|
|
253
|
-
:
|
|
254
|
-
|
|
272
|
+
? [...threadIdsWithoutRemote, remoteMetadata.remoteId]
|
|
273
|
+
: threadIdsWithoutRemote;
|
|
255
274
|
const newArchivedThreadIds =
|
|
256
275
|
remoteMetadata.status === "archived"
|
|
257
|
-
? [...
|
|
258
|
-
:
|
|
276
|
+
? [...archivedThreadIdsWithoutRemote, remoteMetadata.remoteId]
|
|
277
|
+
: archivedThreadIdsWithoutRemote;
|
|
259
278
|
|
|
260
279
|
this._state.update({
|
|
261
280
|
...state,
|
|
@@ -352,6 +371,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
352
371
|
},
|
|
353
372
|
};
|
|
354
373
|
},
|
|
374
|
+
// biome-ignore lint/suspicious/noThenProperty: OptimisticState reducer pattern
|
|
355
375
|
then: (state, { remoteId, externalId }) => {
|
|
356
376
|
const data = getThreadData(state, threadId);
|
|
357
377
|
if (!data) return state;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, FC, ReactNode, useContext } from "react";
|
|
1
|
+
import { createContext, type FC, type ReactNode, useContext } from "react";
|
|
2
2
|
import type { ThreadHistoryAdapter } from "../../adapters/thread-history";
|
|
3
3
|
import type { AttachmentAdapter } from "../../adapters/attachment";
|
|
4
4
|
import type { ModelContextProvider } from "../../model-context/types";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RefObject, useState } from "react";
|
|
1
|
+
import { type RefObject, useState } from "react";
|
|
2
2
|
import type {
|
|
3
3
|
GenericThreadHistoryAdapter,
|
|
4
4
|
ThreadHistoryAdapter,
|
|
@@ -8,12 +8,12 @@ import type {
|
|
|
8
8
|
} from "../../../adapters/thread-history";
|
|
9
9
|
import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository";
|
|
10
10
|
import {
|
|
11
|
-
AssistantCloud,
|
|
11
|
+
type AssistantCloud,
|
|
12
12
|
CloudMessagePersistence,
|
|
13
13
|
createFormattedPersistence,
|
|
14
14
|
} from "assistant-cloud";
|
|
15
15
|
import { auiV0Decode, auiV0Encode } from "./auiV0";
|
|
16
|
-
import { AssistantClient, useAui } from "@assistant-ui/store";
|
|
16
|
+
import { type AssistantClient, useAui } from "@assistant-ui/store";
|
|
17
17
|
import type { ThreadListItemMethods } from "../../../store/scopes/thread-list-item";
|
|
18
18
|
|
|
19
19
|
const globalPersistence = new WeakMap<
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { MessageStatus, ThreadMessage } from "../../../types/message";
|
|
2
2
|
import { fromThreadMessageLike } from "../../../runtime/utils/thread-message-like";
|
|
3
|
-
import { CloudMessage } from "assistant-cloud";
|
|
3
|
+
import type { CloudMessage } from "assistant-cloud";
|
|
4
4
|
import { isJSONValue } from "../../../utils/json/is-json";
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
|
+
ReadonlyJSONObject,
|
|
7
|
+
ReadonlyJSONValue,
|
|
8
|
+
} from "assistant-stream/utils";
|
|
6
9
|
import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository";
|
|
7
10
|
|
|
8
11
|
type AuiV0MessagePart =
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare const process: { env: Record<string, string | undefined> };
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
FC,
|
|
5
|
-
PropsWithChildren,
|
|
4
|
+
type FC,
|
|
5
|
+
type PropsWithChildren,
|
|
6
6
|
useCallback,
|
|
7
7
|
useEffect,
|
|
8
8
|
useMemo,
|
|
@@ -28,7 +28,7 @@ type CloudThreadListAdapterOptions = {
|
|
|
28
28
|
|
|
29
29
|
const baseUrl =
|
|
30
30
|
typeof process !== "undefined" &&
|
|
31
|
-
process?.env?.
|
|
31
|
+
process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;
|
|
32
32
|
const autoCloud = baseUrl
|
|
33
33
|
? new AssistantCloud({ baseUrl, anonymous: true })
|
|
34
34
|
: undefined;
|
|
@@ -43,17 +43,20 @@ export const useCloudThreadListAdapter = (
|
|
|
43
43
|
|
|
44
44
|
const unstable_Provider = useCallback<FC<PropsWithChildren>>(
|
|
45
45
|
function Provider({ children }) {
|
|
46
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
46
47
|
const history = useAssistantCloudThreadHistoryAdapter({
|
|
47
48
|
get current() {
|
|
48
49
|
return adapterRef.current.cloud ?? autoCloud!;
|
|
49
50
|
},
|
|
50
51
|
});
|
|
51
52
|
const cloudInstance = adapterRef.current.cloud ?? autoCloud!;
|
|
53
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
52
54
|
const attachments = useMemo(
|
|
53
55
|
() => new CloudFileAttachmentAdapter(cloudInstance),
|
|
54
56
|
[cloudInstance],
|
|
55
57
|
);
|
|
56
58
|
|
|
59
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
57
60
|
const adapters = useMemo(
|
|
58
61
|
() => ({
|
|
59
62
|
history,
|
|
@@ -22,6 +22,7 @@ const useLocalThreadRuntime = (
|
|
|
22
22
|
chatModel: ChatModelAdapter,
|
|
23
23
|
{ initialMessages, ...options }: LocalRuntimeOptions,
|
|
24
24
|
): AssistantRuntime => {
|
|
25
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
25
26
|
const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};
|
|
26
27
|
const opt = {
|
|
27
28
|
...options,
|
|
@@ -32,33 +33,41 @@ const useLocalThreadRuntime = (
|
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
35
37
|
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
36
38
|
|
|
39
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
37
40
|
const threadIdRef = useRef<string | undefined>(undefined);
|
|
41
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
38
42
|
threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);
|
|
39
43
|
|
|
44
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
40
45
|
useEffect(() => {
|
|
41
46
|
runtime.threads
|
|
42
47
|
.getMainThreadRuntimeCore()
|
|
43
48
|
.__internal_setGetThreadId(() => threadIdRef.current);
|
|
44
49
|
}, [runtime]);
|
|
45
50
|
|
|
51
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
46
52
|
useEffect(() => {
|
|
47
53
|
return () => {
|
|
48
54
|
runtime.threads.getMainThreadRuntimeCore().detach();
|
|
49
55
|
};
|
|
50
56
|
}, [runtime]);
|
|
51
57
|
|
|
58
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
52
59
|
useEffect(() => {
|
|
53
60
|
runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);
|
|
54
61
|
runtime.threads.getMainThreadRuntimeCore().__internal_load();
|
|
55
62
|
});
|
|
56
63
|
|
|
64
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
57
65
|
useEffect(() => {
|
|
58
66
|
if (!modelContext) return undefined;
|
|
59
67
|
return runtime.registerModelContextProvider(modelContext);
|
|
60
68
|
}, [modelContext, runtime]);
|
|
61
69
|
|
|
70
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
62
71
|
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
|
63
72
|
};
|
|
64
73
|
|
|
@@ -93,6 +102,7 @@ export const useLocalRuntime = (
|
|
|
93
102
|
const cloudAdapter = useCloudThreadListAdapter({ cloud });
|
|
94
103
|
return useRemoteThreadListRuntime({
|
|
95
104
|
runtimeHook: function RuntimeHook() {
|
|
105
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
96
106
|
return useLocalThreadRuntime(chatModel, options);
|
|
97
107
|
},
|
|
98
108
|
adapter: cloudAdapter,
|
|
@@ -29,12 +29,15 @@ class RemoteThreadListRuntimeCore
|
|
|
29
29
|
const useRemoteThreadListRuntimeImpl = (
|
|
30
30
|
options: RemoteThreadListOptions,
|
|
31
31
|
): AssistantRuntime => {
|
|
32
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
32
33
|
const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));
|
|
34
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
33
35
|
useEffect(() => {
|
|
34
36
|
runtime.threads.__internal_setOptions(options);
|
|
35
37
|
runtime.threads.__internal_load();
|
|
36
38
|
}, [runtime, options]);
|
|
37
39
|
|
|
40
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
38
41
|
return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
|
|
39
42
|
};
|
|
40
43
|
|
|
@@ -77,9 +80,12 @@ export const useRemoteThreadListRuntime = (
|
|
|
77
80
|
return stableRuntimeHook();
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
80
84
|
const runtime = useRemoteThreadListRuntimeImpl(stableOptions);
|
|
81
85
|
|
|
86
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
82
87
|
const prevThreadIdRef = useRef(options.threadId);
|
|
88
|
+
// biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
|
|
83
89
|
useEffect(() => {
|
|
84
90
|
if (options.threadId === prevThreadIdRef.current) return;
|
|
85
91
|
prevThreadIdRef.current = options.threadId;
|