@assistant-ui/core 0.3.16 → 0.3.18
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.map +1 -1
- package/dist/adapters/attachment.js +5 -4
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.js +4 -2
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +10 -4
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +5 -0
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +101 -28
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +16 -9
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/registry.js +3 -5
- package/dist/model-context/registry.js.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +26 -0
- package/dist/model-context/tool-call-text.d.ts.map +1 -0
- package/dist/model-context/tool-call-text.js +18 -0
- package/dist/model-context/tool-call-text.js.map +1 -0
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/model-context/types.js +5 -4
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/RuntimeAdapter.js +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.js +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.js +63 -57
- package/dist/react/client/InMemoryThreadList.js.map +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +25 -28
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +16 -0
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +354 -242
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +24 -18
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/interactables-legacy/Interactables.js +246 -125
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +11 -9
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +2 -2
- package/dist/react/model-context/makeAssistantTool.js +1 -1
- package/dist/react/model-context/makeAssistantTool.js.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +2 -14
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.js +1 -13
- package/dist/react/model-context/toolbox.js.map +1 -1
- package/dist/react/model-context/useAssistantContext.js +37 -7
- package/dist/react/model-context/useAssistantContext.js.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +2 -2
- package/dist/react/model-context/useAssistantTool.js +1 -1
- package/dist/react/model-context/useAssistantTool.js.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.js +31 -5
- package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.js +10 -36
- package/dist/react/model-context/useInlineRender.js.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.js +2 -1
- package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.js +2 -8
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +2 -4
- package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +4 -3
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js +4 -3
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +7 -6
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +2 -2
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +3 -3
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +5 -4
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +6 -4
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +59 -29
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +11 -6
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +160 -143
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +2 -6
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +15 -13
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.js +2 -2
- package/dist/react/runtimes/assistant-transport/useLatestRef.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +4 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +424 -52
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +5 -1
- 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/createCloudThreadListAdapter.d.ts +29 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +160 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +1 -9
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +16 -153
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +1 -1
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +75 -46
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +77 -29
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +7 -3
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +2 -0
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +2 -2
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +1 -1
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +7 -3
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js +2 -2
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +12 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +23 -14
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +5 -1
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +1 -1
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +16 -12
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -2
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +8 -7
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +12 -5
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +18 -3
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +15 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.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/auto-status.js +6 -2
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +3 -2
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +5 -4
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +1 -0
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +15 -6
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +6 -3
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.js +12 -3
- package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +2 -10
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/tool-call-tree.d.ts +39 -0
- package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -0
- package/dist/runtime/utils/tool-call-tree.js +85 -0
- package/dist/runtime/utils/tool-call-tree.js.map +1 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts +29 -2
- 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.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +21 -27
- 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 +2 -1
- 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 +34 -28
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/internal.d.ts +2 -2
- package/dist/runtimes/internal.js +2 -2
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +3 -1
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +18 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +148 -43
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/title-generation.d.ts +49 -0
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/title-generation.js +197 -0
- package/dist/runtimes/remote-thread-list/title-generation.js.map +1 -0
- package/dist/runtimes/remote-thread-list/title.d.ts +11 -0
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/title.js +14 -0
- package/dist/runtimes/remote-thread-list/title.js.map +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts +16 -5
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +31 -8
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +97 -60
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/external-thread.d.ts +1 -1
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +30 -7
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.js +2 -1
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.js +2 -1
- package/dist/store/clients/single-thread-list.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +19 -6
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.js +1 -1
- package/dist/store/clients/thread-selection-events.js +1 -1
- package/dist/store/index.d.ts +2 -1
- package/dist/store/index.js +2 -1
- package/dist/store/internal.d.ts +2 -2
- package/dist/store/internal.js +2 -2
- package/dist/store/primitive-predicates.d.ts +4 -1
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +9 -1
- package/dist/store/primitive-predicates.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -0
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +98 -62
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -0
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +221 -144
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- 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 +2 -2
- 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.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +128 -107
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +194 -122
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +3 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.js +1 -1
- package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
- package/dist/store/scopes/composer.d.ts +10 -2
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +30 -1
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +6 -3
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +2 -2
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +8 -0
- package/dist/store/scopes/thread.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 +8 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +24 -16
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/attachment.d.ts +2 -1
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/attachment.js +2 -1
- package/dist/types/attachment.js.map +1 -1
- package/dist/types/message.d.ts +40 -1
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js +7 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +19 -0
- package/dist/utils/abortable-iterable.d.ts.map +1 -0
- package/dist/utils/abortable-iterable.js +72 -0
- package/dist/utils/abortable-iterable.js.map +1 -0
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.js +20 -2
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/record.d.ts +11 -0
- package/dist/utils/record.d.ts.map +1 -0
- package/dist/utils/record.js +12 -0
- package/dist/utils/record.js.map +1 -0
- package/package.json +12 -17
- package/src/adapters/attachment.test.ts +50 -1
- package/src/adapters/attachment.ts +7 -4
- package/src/index.ts +7 -1
- package/src/internal.ts +12 -0
- package/src/model-context/frame/host.test.ts +24 -0
- package/src/model-context/frame/host.ts +10 -4
- package/src/model-context/frame/provider.test.ts +288 -1
- package/src/model-context/frame/provider.ts +148 -30
- package/src/model-context/interactable-composer-metadata.test.ts +28 -0
- package/src/model-context/interactable-composer-metadata.ts +9 -3
- package/src/model-context/registry.test.ts +12 -0
- package/src/model-context/registry.ts +3 -2
- package/src/model-context/tool-call-text.test.ts +67 -0
- package/src/model-context/tool-call-text.ts +67 -0
- package/src/model-context/types.test.ts +25 -0
- package/src/model-context/types.ts +9 -4
- package/src/react/AssistantRuntimeProvider.test.tsx +66 -2
- package/src/react/RuntimeAdapter.test.ts +34 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +1 -3
- package/src/react/client/InMemoryThreadList.ts +1 -0
- package/src/react/client/Interactables.test.ts +28 -0
- package/src/react/client/Interactables.ts +15 -13
- package/src/react/client/RemoteThreadList.background.test.ts +526 -0
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +315 -0
- package/src/react/client/RemoteThreadList.test.ts +617 -3
- package/src/react/client/RemoteThreadList.ts +433 -167
- package/src/react/client/Tools.ts +29 -12
- package/src/react/index.ts +4 -0
- package/src/react/interactables-legacy/Interactables.ts +16 -16
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +9 -10
- package/src/react/model-context/makeAssistantTool.ts +2 -2
- package/src/react/model-context/modelContextHooks.test.tsx +131 -0
- package/src/react/model-context/toolbox.test.ts +9 -9
- package/src/react/model-context/toolbox.ts +9 -36
- package/src/react/model-context/useAssistantContext.ts +4 -2
- package/src/react/model-context/useAssistantTool.ts +2 -2
- package/src/react/model-context/useAuiToolOverrides.ts +4 -2
- package/src/react/model-context/useInlineRender.test.tsx +48 -0
- package/src/react/model-context/useInlineRender.ts +14 -10
- package/src/react/model-context/useToolArgsStatus.test.tsx +30 -0
- package/src/react/model-context/useToolArgsStatus.ts +2 -1
- package/src/react/primitive-hooks/useMessageError.ts +2 -19
- package/src/react/primitive-hooks/useThreadListLoadMore.ts +2 -3
- package/src/react/primitives/composer/ComposerAttachments.test.tsx +76 -0
- package/src/react/primitives/composer/ComposerAttachments.tsx +9 -4
- package/src/react/primitives/composer/ComposerQueue.test.tsx +72 -0
- package/src/react/primitives/composer/ComposerQueue.tsx +7 -4
- package/src/react/primitives/message/MessageAttachments.test.tsx +107 -37
- package/src/react/primitives/message/MessageAttachments.tsx +10 -7
- package/src/react/primitives/message/MessageGroupedParts.tsx +2 -2
- package/src/react/primitives/message/MessageParts.tsx +3 -3
- package/src/react/primitives/threadList/ThreadListItems.test.tsx +99 -0
- package/src/react/primitives/threadList/ThreadListItems.tsx +8 -5
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.destroy.test.tsx +172 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +127 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +7 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +99 -35
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.load-error.test.ts +132 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.switch-delete.test.ts +274 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +223 -152
- package/src/react/runtimes/RemoteThreadResource.test.ts +9 -0
- package/src/react/runtimes/RemoteThreadResource.ts +20 -16
- package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +51 -2
- package/src/react/runtimes/assistant-transport/useLatestRef.ts +2 -2
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +45 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +546 -5
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +546 -103
- package/src/react/runtimes/cloud/auiV0.ts +5 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +103 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +237 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +90 -1
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +33 -238
- package/src/react/runtimes/external-message-converter.ts +1 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +41 -0
- package/src/react/runtimes/useExternalStoreRuntime.ts +10 -4
- package/src/react/runtimes/useLocalRuntime.test.tsx +20 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +216 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.load-error.test.tsx +108 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +57 -6
- package/src/react/types/MessagePartComponentTypes.ts +7 -3
- package/src/react/types/scopes/tools.ts +2 -0
- package/src/runtime/api/message-part-runtime.ts +3 -3
- package/src/runtime/api/message-runtime.test.ts +75 -0
- package/src/runtime/api/thread-list-item-runtime.ts +10 -3
- package/src/runtime/api/thread-list-runtime.ts +46 -12
- package/src/runtime/api/thread-runtime.test.ts +78 -0
- package/src/runtime/api/thread-runtime.ts +8 -1
- package/src/runtime/base/base-composer-runtime-core.ts +36 -8
- package/src/runtime/base/base-thread-runtime-core.test.ts +149 -4
- package/src/runtime/base/base-thread-runtime-core.ts +16 -8
- package/src/runtime/interfaces/composer-runtime-core.ts +10 -5
- package/src/runtime/interfaces/thread-list-runtime-core.ts +25 -2
- package/src/runtime/interfaces/thread-runtime-core.ts +17 -1
- package/src/runtime/utils/auto-status.test.ts +57 -0
- package/src/runtime/utils/auto-status.ts +13 -1
- package/src/runtime/utils/external-message-conversion.test.ts +165 -0
- package/src/runtime/utils/external-message-conversion.ts +18 -2
- package/src/runtime/utils/message-repository.ts +29 -17
- package/src/runtime/utils/resolveToolApprovalResponse.test.ts +73 -0
- package/src/runtime/utils/resolveToolApprovalResponse.ts +27 -6
- package/src/runtime/utils/thread-message-like.ts +3 -11
- package/src/runtime/utils/tool-call-tree.test.ts +191 -0
- package/src/runtime/utils/tool-call-tree.ts +97 -0
- package/src/runtimes/external-store/external-store-adapter.ts +38 -2
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +18 -13
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +56 -33
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +1 -1
- package/src/runtimes/internal.ts +1 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +29 -3
- package/src/runtimes/local/local-thread-runtime-core.ts +5 -1
- package/src/runtimes/remote-thread-list/remote-thread-state.test.ts +238 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +223 -44
- package/src/runtimes/remote-thread-list/title-generation.test.ts +602 -0
- package/src/runtimes/remote-thread-list/title-generation.ts +329 -0
- package/src/runtimes/remote-thread-list/title.test.ts +62 -0
- package/src/runtimes/remote-thread-list/title.ts +16 -0
- package/src/runtimes/remote-thread-list/types.ts +16 -5
- package/src/runtimes/tool-invocations/EDGE_CASES.md +110 -5
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +750 -136
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +144 -91
- package/src/store/clients/external-thread.ts +62 -11
- package/src/store/clients/model-context-client.ts +5 -1
- package/src/store/clients/single-thread-list.ts +1 -0
- package/src/store/clients/suggestions.test.ts +195 -1
- package/src/store/clients/suggestions.ts +45 -34
- package/src/store/index.ts +4 -0
- package/src/store/internal.ts +2 -0
- package/src/store/primitive-predicates.ts +35 -0
- package/src/store/runtime-clients/composer-runtime-client.ts +42 -9
- package/src/store/runtime-clients/message-runtime-client.ts +54 -6
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +4 -2
- package/src/store/runtime-clients/thread-list-runtime-client.ts +17 -2
- package/src/store/runtime-clients/thread-runtime-client.ts +58 -10
- package/src/store/runtime-clients/useSubscribable.ts +8 -2
- package/src/store/scopes/composer.ts +16 -4
- package/src/store/scopes/message.ts +14 -0
- package/src/store/scopes/part.ts +6 -3
- package/src/store/scopes/thread-list-item.ts +5 -2
- package/src/store/scopes/thread.ts +4 -0
- package/src/store/scopes/threads.ts +1 -0
- package/src/subscribable/subscribable.test.ts +50 -0
- package/src/subscribable/subscribable.ts +33 -21
- package/src/tests/MessageRepository.test.ts +116 -0
- package/src/tests/OptimisticState-list-race.test.ts +1 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-initialize-adapter-change.test.ts +38 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-load-race.test.ts +158 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +78 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-reload.test.ts +52 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-title-race.test.ts +89 -0
- package/src/tests/attachment-adapters.test.ts +14 -0
- package/src/tests/base-composer-runtime-core.test.ts +39 -0
- package/src/tests/external-store-optimistic-id.test.ts +79 -0
- package/src/tests/external-store-repository-instance.test.ts +166 -0
- package/src/tests/external-store-thread-list-runtime-core.test.ts +83 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +49 -34
- package/src/tests/external-thread-attachments.test.tsx +224 -1
- package/src/tests/external-thread-parity.test.tsx +23 -0
- package/src/tests/remote-thread-list-adapter-switch.test.ts +66 -1
- package/src/tests/remote-thread-list-isLoading.test.ts +1 -0
- package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +1 -0
- package/src/tests/thread-switch-events.test.tsx +475 -2
- package/src/tests/tools-scope-migration.test.tsx +28 -0
- package/src/types/attachment.ts +4 -0
- package/src/types/message.ts +50 -2
- package/src/utils/abortable-iterable.test.ts +213 -0
- package/src/utils/abortable-iterable.ts +93 -0
- package/src/utils/composite-context-provider.test.ts +25 -0
- package/src/utils/composite-context-provider.ts +23 -2
- package/src/utils/record.test.ts +48 -0
- package/src/utils/record.ts +11 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
2
|
|
|
3
|
-
import { renderHook } from "@testing-library/react";
|
|
3
|
+
import { renderHook, waitFor } from "@testing-library/react";
|
|
4
4
|
import type { AssistantCloud } from "assistant-cloud";
|
|
5
|
-
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import type { ThreadAssistantMessage } from "../../../types/message";
|
|
6
7
|
import { useAssistantCloudThreadHistoryAdapter } from "./AssistantCloudThreadHistoryAdapter";
|
|
7
8
|
|
|
8
9
|
const mocks = vi.hoisted(() => {
|
|
@@ -21,12 +22,45 @@ const mocks = vi.hoisted(() => {
|
|
|
21
22
|
};
|
|
22
23
|
return {
|
|
23
24
|
threadListItem,
|
|
24
|
-
threads: {
|
|
25
|
+
threads: {
|
|
26
|
+
item: vi.fn(() => threadListItem),
|
|
27
|
+
getState: () => ({
|
|
28
|
+
mainThreadId: id,
|
|
29
|
+
threadItems: [{ id, remoteId }],
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
thread: { getState: () => ({ isEmpty: false, suggestions: [] }) },
|
|
33
|
+
on: () => () => {},
|
|
34
|
+
subscribe: () => () => {},
|
|
35
|
+
} as unknown as import("@assistant-ui/store").AssistantClient;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const makeSplitClient = (remoteId: string) => {
|
|
39
|
+
const itemShape = () => ({
|
|
40
|
+
source: "threads",
|
|
41
|
+
getState: () => ({ id: remoteId, remoteId }),
|
|
42
|
+
initialize: async () => ({ remoteId, externalId: undefined }),
|
|
43
|
+
});
|
|
44
|
+
const live = itemShape();
|
|
45
|
+
const listItem = itemShape();
|
|
46
|
+
return {
|
|
47
|
+
threadListItem: live,
|
|
48
|
+
threads: {
|
|
49
|
+
item: vi.fn(() => listItem),
|
|
50
|
+
getState: () => ({
|
|
51
|
+
mainThreadId: remoteId,
|
|
52
|
+
threadItems: [{ id: remoteId, remoteId }],
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
thread: { getState: () => ({ isEmpty: false, suggestions: [] }) },
|
|
56
|
+
on: () => () => {},
|
|
57
|
+
subscribe: () => () => {},
|
|
25
58
|
} as unknown as import("@assistant-ui/store").AssistantClient;
|
|
26
59
|
};
|
|
27
60
|
|
|
28
61
|
return {
|
|
29
62
|
makeClient,
|
|
63
|
+
makeSplitClient,
|
|
30
64
|
aui: makeClient("thread-1"),
|
|
31
65
|
};
|
|
32
66
|
});
|
|
@@ -36,20 +70,188 @@ vi.mock("@assistant-ui/store", async (importOriginal) => ({
|
|
|
36
70
|
useAui: () => mocks.aui,
|
|
37
71
|
}));
|
|
38
72
|
|
|
39
|
-
const makeCloud = () =>
|
|
73
|
+
const makeCloud = (telemetry: Partial<AssistantCloud["telemetry"]> = {}) =>
|
|
40
74
|
({
|
|
41
75
|
threads: {
|
|
42
76
|
messages: {
|
|
43
77
|
list: vi.fn().mockResolvedValue({ messages: [] }),
|
|
44
78
|
create: vi.fn().mockResolvedValue({ message_id: "remote-message-1" }),
|
|
45
79
|
update: vi.fn().mockResolvedValue(undefined),
|
|
80
|
+
feedback: vi.fn().mockResolvedValue({
|
|
81
|
+
feedback_id: "feedback-1",
|
|
82
|
+
type: "positive",
|
|
83
|
+
}),
|
|
46
84
|
},
|
|
47
85
|
},
|
|
48
|
-
|
|
86
|
+
events: { track: vi.fn() },
|
|
87
|
+
telemetry: { enabled: true, ...telemetry },
|
|
49
88
|
runs: { report: vi.fn().mockResolvedValue(undefined) },
|
|
50
89
|
}) as unknown as AssistantCloud;
|
|
51
90
|
|
|
91
|
+
const makeAssistantMessage = (id: string): ThreadAssistantMessage => ({
|
|
92
|
+
id,
|
|
93
|
+
role: "assistant",
|
|
94
|
+
content: [{ type: "text", text: "done" }],
|
|
95
|
+
status: { type: "complete", reason: "stop" },
|
|
96
|
+
createdAt: new Date(0),
|
|
97
|
+
metadata: {
|
|
98
|
+
unstable_state: null,
|
|
99
|
+
unstable_annotations: [],
|
|
100
|
+
unstable_data: [],
|
|
101
|
+
steps: [],
|
|
102
|
+
custom: {},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
vi.restoreAllMocks();
|
|
108
|
+
});
|
|
109
|
+
|
|
52
110
|
describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
111
|
+
it("tracks cloud engagement events without message content", async () => {
|
|
112
|
+
const now = vi.spyOn(Date, "now").mockReturnValue(100);
|
|
113
|
+
const listeners = new Map<string, (payload: any) => void>();
|
|
114
|
+
let notify: (() => void) | undefined;
|
|
115
|
+
const threadState = {
|
|
116
|
+
isEmpty: false,
|
|
117
|
+
suggestions: [] as { prompt: string }[],
|
|
118
|
+
};
|
|
119
|
+
const threadListItem = {
|
|
120
|
+
source: "threads",
|
|
121
|
+
getState: () => ({ id: "thread-1", remoteId: "thread-1" }),
|
|
122
|
+
initialize: async () => ({ remoteId: "thread-1", externalId: undefined }),
|
|
123
|
+
};
|
|
124
|
+
mocks.aui = {
|
|
125
|
+
threadListItem,
|
|
126
|
+
threads: {
|
|
127
|
+
item: vi.fn(() => threadListItem),
|
|
128
|
+
getState: () => ({
|
|
129
|
+
mainThreadId: "thread-1",
|
|
130
|
+
threadItems: [{ id: "thread-1", remoteId: "thread-1" }],
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
thread: { getState: () => threadState },
|
|
134
|
+
on: vi.fn((selector, callback) => {
|
|
135
|
+
listeners.set(selector.event, callback);
|
|
136
|
+
return () => listeners.delete(selector.event);
|
|
137
|
+
}),
|
|
138
|
+
subscribe: vi.fn((callback) => {
|
|
139
|
+
notify = callback;
|
|
140
|
+
return () => {};
|
|
141
|
+
}),
|
|
142
|
+
} as unknown as import("@assistant-ui/store").AssistantClient;
|
|
143
|
+
const cloud = makeCloud();
|
|
144
|
+
const { result } = renderHook(() =>
|
|
145
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
146
|
+
);
|
|
147
|
+
const message = makeAssistantMessage("local-message-1");
|
|
148
|
+
|
|
149
|
+
await result.current.append({ parentId: null, message });
|
|
150
|
+
await waitFor(() => expect(listeners.size).toBeGreaterThan(0));
|
|
151
|
+
|
|
152
|
+
listeners.get("thread.runEnd")!({ threadId: "thread-1" });
|
|
153
|
+
now.mockReturnValue(125);
|
|
154
|
+
listeners.get("composer.send")!({
|
|
155
|
+
threadId: "thread-1",
|
|
156
|
+
chars: 5,
|
|
157
|
+
attachments: 1,
|
|
158
|
+
suggestion: true,
|
|
159
|
+
});
|
|
160
|
+
listeners.get("composer.send")!({
|
|
161
|
+
threadId: "thread-1",
|
|
162
|
+
messageId: "local-message-1",
|
|
163
|
+
chars: 7,
|
|
164
|
+
attachments: 0,
|
|
165
|
+
});
|
|
166
|
+
listeners.get("thread.runStart")!({ threadId: "thread-1" });
|
|
167
|
+
now.mockReturnValue(150);
|
|
168
|
+
listeners.get("thread.cancelRun")!({ threadId: "thread-1" });
|
|
169
|
+
listeners.get("message.reload")!({
|
|
170
|
+
threadId: "thread-1",
|
|
171
|
+
messageId: "local-message-1",
|
|
172
|
+
});
|
|
173
|
+
listeners.get("message.branchSwitched")!({
|
|
174
|
+
threadId: "thread-1",
|
|
175
|
+
messageId: "local-message-1",
|
|
176
|
+
});
|
|
177
|
+
listeners.get("message.copied")!({
|
|
178
|
+
threadId: "thread-1",
|
|
179
|
+
messageId: "local-message-1",
|
|
180
|
+
});
|
|
181
|
+
listeners.get("composer.attachmentAdd")!({
|
|
182
|
+
threadId: "thread-1",
|
|
183
|
+
contentType: "image/png",
|
|
184
|
+
});
|
|
185
|
+
listeners.get("composer.attachmentAddError")!({
|
|
186
|
+
threadId: "thread-1",
|
|
187
|
+
reason: "adapter-error",
|
|
188
|
+
message: "not sent",
|
|
189
|
+
contentType: "application/pdf",
|
|
190
|
+
});
|
|
191
|
+
listeners.get("threads.selectionChanged")!({
|
|
192
|
+
threadId: "thread-1",
|
|
193
|
+
previousThreadId: "thread-0",
|
|
194
|
+
});
|
|
195
|
+
listeners.get("message.speak")!({
|
|
196
|
+
threadId: "thread-1",
|
|
197
|
+
messageId: "local-message-1",
|
|
198
|
+
});
|
|
199
|
+
listeners.get("thread.voiceStarted")!({ threadId: "thread-1" });
|
|
200
|
+
listeners.get("message.error")!({
|
|
201
|
+
threadId: "thread-1",
|
|
202
|
+
messageId: "local-message-1",
|
|
203
|
+
reason: "error",
|
|
204
|
+
});
|
|
205
|
+
threadState.isEmpty = true;
|
|
206
|
+
threadState.suggestions = [{ prompt: "one" }, { prompt: "two" }];
|
|
207
|
+
notify!();
|
|
208
|
+
await waitFor(() =>
|
|
209
|
+
expect(vi.mocked(cloud.events.track).mock.calls.length).toBeGreaterThan(
|
|
210
|
+
12,
|
|
211
|
+
),
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
expect(
|
|
215
|
+
vi.mocked(cloud.events.track).mock.calls.map(([event]) => event),
|
|
216
|
+
).toEqual(
|
|
217
|
+
expect.arrayContaining([
|
|
218
|
+
expect.objectContaining({
|
|
219
|
+
kind: "message_sent",
|
|
220
|
+
thread_id: "thread-1",
|
|
221
|
+
value: 25,
|
|
222
|
+
props: { chars: 5, attachments: 1 },
|
|
223
|
+
}),
|
|
224
|
+
expect.objectContaining({
|
|
225
|
+
kind: "message_edited",
|
|
226
|
+
thread_id: "thread-1",
|
|
227
|
+
message_id: "remote-message-1",
|
|
228
|
+
props: { chars: 7 },
|
|
229
|
+
}),
|
|
230
|
+
expect.objectContaining({ kind: "suggestion_clicked" }),
|
|
231
|
+
expect.objectContaining({ kind: "run_stopped", value: 25 }),
|
|
232
|
+
expect.objectContaining({ kind: "message_regenerated" }),
|
|
233
|
+
expect.objectContaining({ kind: "branch_switched" }),
|
|
234
|
+
expect.objectContaining({ kind: "message_copied" }),
|
|
235
|
+
expect.objectContaining({
|
|
236
|
+
kind: "attachment_added",
|
|
237
|
+
props: { type: "image/png" },
|
|
238
|
+
}),
|
|
239
|
+
expect.objectContaining({
|
|
240
|
+
kind: "attachment_failed",
|
|
241
|
+
props: { type: "application/pdf" },
|
|
242
|
+
}),
|
|
243
|
+
expect.objectContaining({ kind: "thread_switched" }),
|
|
244
|
+
expect.objectContaining({ kind: "speech_started" }),
|
|
245
|
+
expect.objectContaining({ kind: "voice_started" }),
|
|
246
|
+
expect.objectContaining({
|
|
247
|
+
kind: "error_shown",
|
|
248
|
+
props: { reason: "error" },
|
|
249
|
+
}),
|
|
250
|
+
expect.objectContaining({ kind: "suggestions_shown", value: 2 }),
|
|
251
|
+
]),
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
53
255
|
it("refreshes formatted persistence when the Cloud client changes", async () => {
|
|
54
256
|
mocks.aui = mocks.makeClient("thread-1");
|
|
55
257
|
const firstCloud = makeCloud();
|
|
@@ -83,6 +285,7 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
83
285
|
expect(secondCloud.threads.messages.list).toHaveBeenCalledOnce();
|
|
84
286
|
expect(secondCloud.threads.messages.list).toHaveBeenCalledWith("thread-1", {
|
|
85
287
|
format: "test",
|
|
288
|
+
limit: 200,
|
|
86
289
|
});
|
|
87
290
|
});
|
|
88
291
|
|
|
@@ -109,6 +312,7 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
109
312
|
await formatted.load();
|
|
110
313
|
expect(cloud.threads.messages.list).toHaveBeenCalledWith("thread-1", {
|
|
111
314
|
format: "test",
|
|
315
|
+
limit: 200,
|
|
112
316
|
});
|
|
113
317
|
|
|
114
318
|
mocks.aui = mocks.makeClient("thread-2");
|
|
@@ -116,6 +320,7 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
116
320
|
await formatted.load();
|
|
117
321
|
expect(cloud.threads.messages.list).toHaveBeenCalledWith("thread-2", {
|
|
118
322
|
format: "test",
|
|
323
|
+
limit: 200,
|
|
119
324
|
});
|
|
120
325
|
});
|
|
121
326
|
|
|
@@ -130,6 +335,7 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
130
335
|
await result.current.load();
|
|
131
336
|
expect(cloud.threads.messages.list).toHaveBeenCalledWith("thread-1", {
|
|
132
337
|
format: "aui/v0",
|
|
338
|
+
limit: 200,
|
|
133
339
|
});
|
|
134
340
|
|
|
135
341
|
mocks.aui = mocks.makeClient("thread-2");
|
|
@@ -138,6 +344,92 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
138
344
|
await result.current.load();
|
|
139
345
|
expect(cloud.threads.messages.list).toHaveBeenCalledWith("thread-2", {
|
|
140
346
|
format: "aui/v0",
|
|
347
|
+
limit: 200,
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("submits feedback with the mapped cloud message ID", async () => {
|
|
352
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
353
|
+
const cloud = makeCloud();
|
|
354
|
+
const cloudRef = { current: cloud };
|
|
355
|
+
const { result } = renderHook(() =>
|
|
356
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
357
|
+
);
|
|
358
|
+
const message = makeAssistantMessage("local-message-1");
|
|
359
|
+
|
|
360
|
+
await result.current.append({ parentId: null, message });
|
|
361
|
+
result.current.feedback.submit({ message, type: "positive" });
|
|
362
|
+
|
|
363
|
+
await waitFor(() => {
|
|
364
|
+
expect(cloud.threads.messages.feedback).toHaveBeenCalledWith(
|
|
365
|
+
"thread-1",
|
|
366
|
+
"remote-message-1",
|
|
367
|
+
{ type: "positive" },
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it("warns and skips feedback before the thread has a remote ID", async () => {
|
|
373
|
+
mocks.aui = mocks.makeClient(undefined, "local-thread", "thread-1");
|
|
374
|
+
const cloud = makeCloud();
|
|
375
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
376
|
+
const { result } = renderHook(() =>
|
|
377
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
378
|
+
);
|
|
379
|
+
const message = makeAssistantMessage("local-message-1");
|
|
380
|
+
|
|
381
|
+
result.current.feedback.submit({ message, type: "negative" });
|
|
382
|
+
|
|
383
|
+
await waitFor(() => {
|
|
384
|
+
expect(warn).toHaveBeenCalledWith(
|
|
385
|
+
"[assistant-ui] Skipping feedback for message local-message-1: the thread has no remote id.",
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
expect(cloud.threads.messages.feedback).not.toHaveBeenCalled();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it("warns and skips feedback before the message has a cloud ID", async () => {
|
|
392
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
393
|
+
const cloud = makeCloud();
|
|
394
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
395
|
+
const { result } = renderHook(() =>
|
|
396
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
397
|
+
);
|
|
398
|
+
const message = makeAssistantMessage("local-message-1");
|
|
399
|
+
|
|
400
|
+
result.current.feedback.submit({ message, type: "negative" });
|
|
401
|
+
|
|
402
|
+
await waitFor(() => {
|
|
403
|
+
expect(warn).toHaveBeenCalledWith(
|
|
404
|
+
"[assistant-ui] Skipping feedback for message local-message-1: no cloud message id is mapped.",
|
|
405
|
+
);
|
|
406
|
+
});
|
|
407
|
+
expect(cloud.threads.messages.feedback).not.toHaveBeenCalled();
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it("reports cloud feedback errors without throwing them into the UI", async () => {
|
|
411
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
412
|
+
const cloud = makeCloud();
|
|
413
|
+
const error = new Error("feedback unavailable");
|
|
414
|
+
vi.mocked(cloud.threads.messages.feedback).mockRejectedValue(error);
|
|
415
|
+
const consoleError = vi
|
|
416
|
+
.spyOn(console, "error")
|
|
417
|
+
.mockImplementation(() => {});
|
|
418
|
+
const { result } = renderHook(() =>
|
|
419
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
420
|
+
);
|
|
421
|
+
const message = makeAssistantMessage("local-message-1");
|
|
422
|
+
|
|
423
|
+
await result.current.append({ parentId: null, message });
|
|
424
|
+
expect(() =>
|
|
425
|
+
result.current.feedback.submit({ message, type: "positive" }),
|
|
426
|
+
).not.toThrow();
|
|
427
|
+
|
|
428
|
+
await waitFor(() => {
|
|
429
|
+
expect(consoleError).toHaveBeenCalledWith(
|
|
430
|
+
"[assistant-ui] Cloud feedback submission failed:",
|
|
431
|
+
error,
|
|
432
|
+
);
|
|
141
433
|
});
|
|
142
434
|
});
|
|
143
435
|
|
|
@@ -188,6 +480,132 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
188
480
|
);
|
|
189
481
|
});
|
|
190
482
|
|
|
483
|
+
it("reports persisted assistant telemetry dimensions", async () => {
|
|
484
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
485
|
+
const cloud = makeCloud({
|
|
486
|
+
release: "web-2026.09.08",
|
|
487
|
+
environment: "production",
|
|
488
|
+
tags: ["region:sg", "tier:paid"],
|
|
489
|
+
});
|
|
490
|
+
const { result } = renderHook(() =>
|
|
491
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
492
|
+
);
|
|
493
|
+
const message: ThreadAssistantMessage = {
|
|
494
|
+
...makeAssistantMessage("local-message-1"),
|
|
495
|
+
status: { type: "incomplete", reason: "length" },
|
|
496
|
+
metadata: {
|
|
497
|
+
...makeAssistantMessage("local-message-1").metadata,
|
|
498
|
+
custom: {
|
|
499
|
+
traceId: "AABBCCDDEEFF00112233445566778899",
|
|
500
|
+
provider: "openai",
|
|
501
|
+
},
|
|
502
|
+
timing: {
|
|
503
|
+
streamStartTime: 100,
|
|
504
|
+
firstTokenTime: 155.6,
|
|
505
|
+
totalChunks: 1,
|
|
506
|
+
toolCallCount: 0,
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
await result.current.append({ parentId: null, message });
|
|
512
|
+
|
|
513
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
514
|
+
expect.objectContaining({
|
|
515
|
+
thread_id: "thread-1",
|
|
516
|
+
status: "incomplete",
|
|
517
|
+
outcome_type: "length",
|
|
518
|
+
message_id: "remote-message-1",
|
|
519
|
+
first_token_ms: 56,
|
|
520
|
+
trace_id: "aabbccddeeff00112233445566778899",
|
|
521
|
+
provider: "openai",
|
|
522
|
+
provider_type: "openai",
|
|
523
|
+
release: "web-2026.09.08",
|
|
524
|
+
environment: "production",
|
|
525
|
+
tags: ["region:sg", "tier:paid"],
|
|
526
|
+
}),
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it("reports the error message and code of a failed run", async () => {
|
|
531
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
532
|
+
const cloud = makeCloud();
|
|
533
|
+
const { result } = renderHook(() =>
|
|
534
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
535
|
+
);
|
|
536
|
+
const error = new Error("Rate limited");
|
|
537
|
+
error.name = "AI_APICallError";
|
|
538
|
+
const message: ThreadAssistantMessage = {
|
|
539
|
+
...makeAssistantMessage("local-message-1"),
|
|
540
|
+
status: { type: "incomplete", reason: "error", error },
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
await result.current.append({ parentId: null, message });
|
|
544
|
+
|
|
545
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
546
|
+
expect.objectContaining({
|
|
547
|
+
status: "error",
|
|
548
|
+
error: "Rate limited",
|
|
549
|
+
error_code: "AI_APICallError",
|
|
550
|
+
}),
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
it.each([
|
|
555
|
+
["cancelled", "aborted"],
|
|
556
|
+
["length", "length"],
|
|
557
|
+
["content-filter", "content_filter"],
|
|
558
|
+
] as const)("maps incomplete %s to outcome %s", async (reason, outcome) => {
|
|
559
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
560
|
+
const cloud = makeCloud();
|
|
561
|
+
const { result } = renderHook(() =>
|
|
562
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
563
|
+
);
|
|
564
|
+
const message: ThreadAssistantMessage = {
|
|
565
|
+
...makeAssistantMessage("local-message-1"),
|
|
566
|
+
status: { type: "incomplete", reason },
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
await result.current.append({ parentId: null, message });
|
|
570
|
+
|
|
571
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
572
|
+
expect.objectContaining({ outcome_type: outcome }),
|
|
573
|
+
);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it("omits a clean outcome and an unknown cloud message ID", () => {
|
|
577
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
578
|
+
const cloud = makeCloud();
|
|
579
|
+
const { result } = renderHook(() =>
|
|
580
|
+
useAssistantCloudThreadHistoryAdapter({ current: cloud }),
|
|
581
|
+
);
|
|
582
|
+
const formatted = result.current.withFormat({
|
|
583
|
+
format: "aui/v0",
|
|
584
|
+
encode: ({ message }) => message,
|
|
585
|
+
decode: ({ parent_id, content }) => ({
|
|
586
|
+
parentId: parent_id,
|
|
587
|
+
message: content as { id: string },
|
|
588
|
+
}),
|
|
589
|
+
getId: (message: { id: string }) => message.id,
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
formatted.reportTelemetry([
|
|
593
|
+
{
|
|
594
|
+
parentId: null,
|
|
595
|
+
message: {
|
|
596
|
+
id: "local-message-1",
|
|
597
|
+
role: "assistant",
|
|
598
|
+
content: [{ type: "text", text: "done" }],
|
|
599
|
+
status: { type: "complete", reason: "stop" },
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
]);
|
|
603
|
+
|
|
604
|
+
const report = vi.mocked(cloud.runs.report).mock.calls[0]![0]!;
|
|
605
|
+
expect(report).not.toHaveProperty("outcome_type");
|
|
606
|
+
expect(report).not.toHaveProperty("message_id");
|
|
607
|
+
});
|
|
608
|
+
|
|
191
609
|
it("reports frontend and MCP sources for ai-sdk/v6 tool calls", () => {
|
|
192
610
|
mocks.aui = mocks.makeClient("thread-1");
|
|
193
611
|
const cloud = makeCloud();
|
|
@@ -234,6 +652,10 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
234
652
|
output: { result: "ok" },
|
|
235
653
|
},
|
|
236
654
|
],
|
|
655
|
+
metadata: {
|
|
656
|
+
traceId: "00112233445566778899AABBCCDDEEFF",
|
|
657
|
+
provider: "anthropic",
|
|
658
|
+
},
|
|
237
659
|
},
|
|
238
660
|
},
|
|
239
661
|
]);
|
|
@@ -276,7 +698,83 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
276
698
|
],
|
|
277
699
|
},
|
|
278
700
|
],
|
|
701
|
+
trace_id: "00112233445566778899aabbccddeeff",
|
|
702
|
+
provider: "anthropic",
|
|
703
|
+
provider_type: "anthropic",
|
|
704
|
+
}),
|
|
705
|
+
);
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
it("reports the model ID carried by aui/v0 step metadata", () => {
|
|
709
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
710
|
+
const cloud = makeCloud();
|
|
711
|
+
const cloudRef = { current: cloud };
|
|
712
|
+
const { result } = renderHook(() =>
|
|
713
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
714
|
+
);
|
|
715
|
+
const formatted = result.current.withFormat({
|
|
716
|
+
format: "aui/v0",
|
|
717
|
+
encode: ({ message }) => message,
|
|
718
|
+
decode: ({ parent_id, content }) => ({
|
|
719
|
+
parentId: parent_id,
|
|
720
|
+
message: content as { id: string },
|
|
721
|
+
}),
|
|
722
|
+
getId: (message: { id: string }) => message.id,
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
formatted.reportTelemetry([
|
|
726
|
+
{
|
|
727
|
+
parentId: null,
|
|
728
|
+
message: {
|
|
729
|
+
id: "message-1",
|
|
730
|
+
role: "assistant",
|
|
731
|
+
content: [{ type: "text", text: "done" }],
|
|
732
|
+
status: { type: "complete" },
|
|
733
|
+
metadata: {
|
|
734
|
+
steps: [{ response: { modelId: "provider/model-1" } }],
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
]);
|
|
739
|
+
|
|
740
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
741
|
+
expect.objectContaining({ model_id: "provider/model-1" }),
|
|
742
|
+
);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
it("reports the model ID carried by ai-sdk/v6 step metadata", () => {
|
|
746
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
747
|
+
const cloud = makeCloud();
|
|
748
|
+
const cloudRef = { current: cloud };
|
|
749
|
+
const { result } = renderHook(() =>
|
|
750
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
751
|
+
);
|
|
752
|
+
const formatted = result.current.withFormat({
|
|
753
|
+
format: "ai-sdk/v6",
|
|
754
|
+
encode: ({ message }) => message,
|
|
755
|
+
decode: ({ parent_id, content }) => ({
|
|
756
|
+
parentId: parent_id,
|
|
757
|
+
message: content as { id: string },
|
|
279
758
|
}),
|
|
759
|
+
getId: (message: { id: string }) => message.id,
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
formatted.reportTelemetry([
|
|
763
|
+
{
|
|
764
|
+
parentId: null,
|
|
765
|
+
message: {
|
|
766
|
+
id: "message-1",
|
|
767
|
+
role: "assistant",
|
|
768
|
+
parts: [{ type: "text", text: "done" }],
|
|
769
|
+
metadata: {
|
|
770
|
+
steps: [{ response: { modelId: "provider/model-1" } }],
|
|
771
|
+
},
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
]);
|
|
775
|
+
|
|
776
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
777
|
+
expect.objectContaining({ model_id: "provider/model-1" }),
|
|
280
778
|
);
|
|
281
779
|
});
|
|
282
780
|
|
|
@@ -308,4 +806,47 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
308
806
|
expect.anything(),
|
|
309
807
|
);
|
|
310
808
|
});
|
|
809
|
+
|
|
810
|
+
it("updates a history-loaded message when the list item identity differs from the live item", async () => {
|
|
811
|
+
mocks.aui = mocks.makeSplitClient("thread-split");
|
|
812
|
+
const cloud = makeCloud();
|
|
813
|
+
(cloud.threads.messages.list as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
814
|
+
{
|
|
815
|
+
messages: [
|
|
816
|
+
{
|
|
817
|
+
id: "m1",
|
|
818
|
+
parent_id: null,
|
|
819
|
+
format: "test",
|
|
820
|
+
content: { id: "m1" },
|
|
821
|
+
},
|
|
822
|
+
],
|
|
823
|
+
},
|
|
824
|
+
);
|
|
825
|
+
const cloudRef = { current: cloud };
|
|
826
|
+
const { result } = renderHook(() =>
|
|
827
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
828
|
+
);
|
|
829
|
+
const formatted = result.current.withFormat<
|
|
830
|
+
{ id: string },
|
|
831
|
+
Record<string, unknown>
|
|
832
|
+
>({
|
|
833
|
+
format: "test",
|
|
834
|
+
encode: ({ message }) => message,
|
|
835
|
+
decode: ({ parent_id, content }) => ({
|
|
836
|
+
parentId: parent_id,
|
|
837
|
+
message: content as { id: string },
|
|
838
|
+
}),
|
|
839
|
+
getId: (message) => message.id,
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
formatted.pin!();
|
|
843
|
+
await formatted.load();
|
|
844
|
+
await formatted.update!({ parentId: null, message: { id: "m1" } }, "m1");
|
|
845
|
+
|
|
846
|
+
expect(cloud.threads.messages.update).toHaveBeenCalledWith(
|
|
847
|
+
"thread-split",
|
|
848
|
+
"m1",
|
|
849
|
+
expect.anything(),
|
|
850
|
+
);
|
|
851
|
+
});
|
|
311
852
|
});
|