@assistant-ui/core 0.3.15 → 0.3.17
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/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +8 -2
- package/dist/internal.js +9 -3
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +3 -2
- 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 +141 -28
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/interactable-composer-metadata.d.ts +1 -1
- package/dist/model-context/interactable-composer-metadata.js +1 -1
- package/dist/model-context/interactable-composer-metadata.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/registry.js +9 -28
- 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/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 +25 -21
- 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 +60 -178
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +15 -0
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +263 -194
- 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 +6 -2
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +2 -1
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +60 -178
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +24 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +138 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -0
- 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/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/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/ComposerIf.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -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 +7 -5
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +44 -22
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +7 -6
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +102 -117
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +1 -6
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +3 -3
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.js +2 -12
- package/dist/react/runtimes/assistant-transport/runManager.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 +3 -10
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +43 -85
- 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 +159 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +12 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.js +10 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.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/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +2 -1
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +6 -25
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +33 -233
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +14 -6
- 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/composer-runtime.d.ts +1 -1
- package/dist/runtime/api/composer-runtime.js.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-runtime.d.ts +9 -1
- 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 +2 -3
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +14 -29
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +4 -6
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +5 -11
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +14 -2
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +16 -2
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +2 -1
- package/dist/runtime/internal.js +2 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +1 -1
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +1 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/queue/queue-item.d.ts +12 -0
- package/dist/runtime/queue/queue-item.d.ts.map +1 -0
- package/dist/runtime/queue/queue-item.js +6 -0
- package/dist/runtime/queue/queue-item.js.map +1 -0
- package/dist/runtime/utils/abortable-thread-load.d.ts +15 -0
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -0
- package/dist/runtime/utils/abortable-thread-load.js +35 -0
- package/dist/runtime/utils/abortable-thread-load.js.map +1 -0
- package/dist/runtime/utils/attachment-add-operations.d.ts +18 -0
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -0
- package/dist/runtime/utils/attachment-add-operations.js +43 -0
- package/dist/runtime/utils/attachment-add-operations.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +7 -2
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +13 -3
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +48 -0
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -0
- package/dist/runtime/utils/external-message-conversion.js +222 -0
- package/dist/runtime/utils/external-message-conversion.js.map +1 -0
- package/dist/runtime/utils/external-store-message.d.ts +2 -1
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.js +2 -1
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +30 -0
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -0
- package/dist/runtime/utils/message-repository-session.js +130 -0
- package/dist/runtime/utils/message-repository-session.js.map +1 -0
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +3 -4
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +20 -0
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -0
- package/dist/runtime/utils/pending-tool-calls.js +22 -0
- package/dist/runtime/utils/pending-tool-calls.js.map +1 -0
- 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 +3 -10
- 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/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 +2 -5
- 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 +3 -10
- 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 +21 -2
- 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 +154 -46
- 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/local/local-thread-runtime-core.d.ts +4 -2
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +23 -3
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +12 -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 +107 -14
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +9 -0
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/title.js +6 -0
- package/dist/runtimes/remote-thread-list/title.js.map +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts +6 -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 +98 -59
- 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 +85 -103
- package/dist/store/clients/external-thread.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 -2
- 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 +33 -12
- 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 +6 -3
- 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.js +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +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 +124 -105
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +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/scope-registration.d.ts +1 -1
- package/dist/store/scopes/composer.d.ts +2 -1
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +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/queue-item.d.ts +2 -9
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js +0 -6
- 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/message.d.ts +47 -4
- 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/data-url.d.ts +14 -1
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/data-url.js +13 -1
- package/dist/utils/data-url.js.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +5 -0
- package/dist/utils/invoke-user-callback.d.ts.map +1 -0
- package/dist/utils/invoke-user-callback.js +19 -0
- package/dist/utils/invoke-user-callback.js.map +1 -0
- package/dist/utils/normalizePartStatus.js.map +1 -1
- package/package.json +12 -17
- package/src/index.ts +6 -1
- package/src/internal.ts +20 -0
- package/src/model-context/frame/host.test.ts +91 -7
- package/src/model-context/frame/host.ts +7 -2
- package/src/model-context/frame/provider.test.ts +484 -13
- package/src/model-context/frame/provider.ts +205 -35
- package/src/model-context/interactable-composer-metadata.ts +1 -1
- package/src/model-context/registry.test.ts +44 -0
- package/src/model-context/registry.ts +13 -35
- package/src/model-context/tool-call-text.test.ts +67 -0
- package/src/model-context/tool-call-text.ts +67 -0
- package/src/react/AssistantRuntimeProvider.test.tsx +66 -2
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +1 -3
- package/src/react/client/InMemoryThreadList.test.tsx +49 -0
- package/src/react/client/InMemoryThreadList.ts +7 -1
- package/src/react/client/Interactables.ts +19 -178
- package/src/react/client/RemoteThreadList.background.test.ts +384 -0
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +274 -0
- package/src/react/client/RemoteThreadList.test.ts +369 -1
- package/src/react/client/RemoteThreadList.ts +320 -142
- package/src/react/client/Tools.ts +7 -1
- package/src/react/index.ts +4 -0
- package/src/react/interactables-legacy/Interactables.ts +20 -177
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +161 -0
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +206 -0
- 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/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/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.running.test.tsx +94 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +72 -31
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.switch-delete.test.ts +169 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +140 -124
- package/src/react/runtimes/RemoteThreadResource.ts +1 -4
- package/src/react/runtimes/assistant-transport/runManager.ts +4 -17
- 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 +157 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +82 -176
- package/src/react/runtimes/cloud/auiV0.ts +5 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +88 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +236 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.test.ts +37 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.ts +18 -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.test.ts +0 -14
- package/src/react/runtimes/external-message-converter.test.tsx +77 -0
- package/src/react/runtimes/external-message-converter.ts +59 -481
- package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +216 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +24 -6
- package/src/react/types/MessagePartComponentTypes.ts +7 -3
- package/src/react/types/scopes/tools.ts +2 -0
- package/src/runtime/api/composer-runtime.ts +1 -1
- package/src/runtime/api/message-part-runtime.ts +3 -3
- package/src/runtime/api/message-runtime.test.ts +28 -1
- package/src/runtime/api/thread-list-runtime.ts +25 -1
- package/src/runtime/base/base-composer-runtime-core.ts +20 -40
- package/src/runtime/base/base-thread-runtime-core.test.ts +110 -3
- package/src/runtime/base/base-thread-runtime-core.ts +16 -15
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -4
- package/src/runtime/interfaces/composer-runtime-core.ts +1 -1
- package/src/runtime/interfaces/thread-list-runtime-core.ts +20 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +18 -2
- package/src/runtime/internal.ts +5 -0
- package/src/runtime/queue/external-thread-queue-adapter.ts +1 -1
- package/src/runtime/queue/message-queue.ts +1 -4
- package/src/runtime/queue/queue-item.ts +10 -0
- package/src/runtime/utils/abortable-thread-load.test.ts +87 -0
- package/src/runtime/utils/abortable-thread-load.ts +53 -0
- package/src/runtime/utils/attachment-add-operations.ts +59 -0
- package/src/runtime/utils/auto-status.test.ts +57 -0
- package/src/runtime/utils/auto-status.ts +46 -1
- package/src/runtime/utils/external-message-conversion.test.ts +210 -0
- package/src/runtime/utils/external-message-conversion.ts +510 -0
- package/src/runtime/utils/external-store-message.ts +2 -0
- package/src/runtime/utils/message-repository-session.test.ts +195 -0
- package/src/runtime/utils/message-repository-session.ts +176 -0
- package/src/runtime/utils/message-repository.ts +7 -4
- package/src/runtime/utils/pending-tool-calls.test.ts +57 -0
- package/src/runtime/utils/pending-tool-calls.ts +35 -0
- 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 +4 -10
- 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 +6 -14
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +231 -61
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +1 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +201 -4
- package/src/runtimes/local/local-thread-runtime-core.ts +53 -4
- package/src/runtimes/remote-thread-list/remote-thread-state.test.ts +149 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +178 -16
- package/src/runtimes/remote-thread-list/title.ts +3 -0
- package/src/runtimes/remote-thread-list/types.ts +6 -5
- package/src/runtimes/tool-invocations/EDGE_CASES.md +125 -3
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +856 -102
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +145 -89
- package/src/store/clients/external-thread.ts +30 -69
- package/src/store/clients/single-thread-list.ts +4 -1
- package/src/store/clients/suggestions.test.ts +185 -0
- package/src/store/clients/suggestions.ts +42 -35
- 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/thread-list-runtime-client.ts +16 -2
- package/src/store/runtime-clients/useSubscribable.ts +8 -2
- package/src/store/scopes/message.ts +1 -1
- package/src/store/scopes/part.ts +6 -3
- package/src/store/scopes/queue-item.ts +2 -9
- package/src/subscribable/subscribable.test.ts +50 -0
- package/src/subscribable/subscribable.ts +33 -21
- package/src/tests/MessageRepository.test.ts +77 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-load-race.test.ts +305 -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 +158 -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-runtime-core-adapter.test.ts +186 -16
- package/src/tests/external-store-thread-runtime-core.test.ts +642 -0
- package/src/tests/external-thread-attachments.test.tsx +258 -1
- package/src/tests/remote-thread-list-adapter-switch.test.ts +66 -1
- package/src/tests/single-thread-list-item.test.tsx +47 -0
- package/src/tests/thread-message-like.test.ts +39 -1
- package/src/tests/thread-switch-events.test.tsx +397 -2
- package/src/types/message.ts +58 -5
- package/src/utils/data-url.test.ts +52 -1
- package/src/utils/data-url.ts +21 -0
- package/src/utils/invoke-user-callback.test.ts +82 -0
- package/src/utils/invoke-user-callback.ts +31 -0
- package/src/utils/normalizePartStatus.ts +1 -1
- package/dist/store/scopes/queue-item.js.map +0 -1
|
@@ -21,12 +21,33 @@ const mocks = vi.hoisted(() => {
|
|
|
21
21
|
};
|
|
22
22
|
return {
|
|
23
23
|
threadListItem,
|
|
24
|
-
threads: {
|
|
24
|
+
threads: {
|
|
25
|
+
item: vi.fn(() => threadListItem),
|
|
26
|
+
getState: () => ({ threadItems: [{ id, remoteId }] }),
|
|
27
|
+
},
|
|
28
|
+
} as unknown as import("@assistant-ui/store").AssistantClient;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const makeSplitClient = (remoteId: string) => {
|
|
32
|
+
const itemShape = () => ({
|
|
33
|
+
source: "threads",
|
|
34
|
+
getState: () => ({ id: remoteId, remoteId }),
|
|
35
|
+
initialize: async () => ({ remoteId, externalId: undefined }),
|
|
36
|
+
});
|
|
37
|
+
const live = itemShape();
|
|
38
|
+
const listItem = itemShape();
|
|
39
|
+
return {
|
|
40
|
+
threadListItem: live,
|
|
41
|
+
threads: {
|
|
42
|
+
item: vi.fn(() => listItem),
|
|
43
|
+
getState: () => ({ threadItems: [{ id: remoteId, remoteId }] }),
|
|
44
|
+
},
|
|
25
45
|
} as unknown as import("@assistant-ui/store").AssistantClient;
|
|
26
46
|
};
|
|
27
47
|
|
|
28
48
|
return {
|
|
29
49
|
makeClient,
|
|
50
|
+
makeSplitClient,
|
|
30
51
|
aui: makeClient("thread-1"),
|
|
31
52
|
};
|
|
32
53
|
});
|
|
@@ -188,6 +209,98 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
188
209
|
);
|
|
189
210
|
});
|
|
190
211
|
|
|
212
|
+
it("reports frontend and MCP sources for ai-sdk/v6 tool calls", () => {
|
|
213
|
+
mocks.aui = mocks.makeClient("thread-1");
|
|
214
|
+
const cloud = makeCloud();
|
|
215
|
+
const cloudRef = { current: cloud };
|
|
216
|
+
const { result } = renderHook(() =>
|
|
217
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
218
|
+
);
|
|
219
|
+
const formatted = result.current.withFormat({
|
|
220
|
+
format: "ai-sdk/v6",
|
|
221
|
+
encode: ({ message }) => message,
|
|
222
|
+
decode: ({ parent_id, content }) => ({
|
|
223
|
+
parentId: parent_id,
|
|
224
|
+
message: content as { id: string },
|
|
225
|
+
}),
|
|
226
|
+
getId: (message: { id: string }) => message.id,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
formatted.reportTelemetry([
|
|
230
|
+
{
|
|
231
|
+
parentId: null,
|
|
232
|
+
message: {
|
|
233
|
+
id: "message-1",
|
|
234
|
+
role: "assistant",
|
|
235
|
+
parts: [
|
|
236
|
+
{ type: "step-start" },
|
|
237
|
+
{
|
|
238
|
+
type: "tool-search",
|
|
239
|
+
toolCallId: "static-1",
|
|
240
|
+
input: { query: "test" },
|
|
241
|
+
output: { result: "ok" },
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
type: "dynamic-tool",
|
|
245
|
+
toolName: "mcp-search",
|
|
246
|
+
toolCallId: "dynamic-1",
|
|
247
|
+
input: { query: "test" },
|
|
248
|
+
output: { result: "ok" },
|
|
249
|
+
},
|
|
250
|
+
{ type: "step-start" },
|
|
251
|
+
{
|
|
252
|
+
type: "tool-search",
|
|
253
|
+
toolCallId: "static-2",
|
|
254
|
+
input: { query: "again" },
|
|
255
|
+
output: { result: "ok" },
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
]);
|
|
261
|
+
|
|
262
|
+
expect(cloud.runs.report).toHaveBeenCalledWith(
|
|
263
|
+
expect.objectContaining({
|
|
264
|
+
tool_calls: [
|
|
265
|
+
expect.objectContaining({
|
|
266
|
+
tool_call_id: "static-1",
|
|
267
|
+
tool_source: "frontend",
|
|
268
|
+
}),
|
|
269
|
+
expect.objectContaining({
|
|
270
|
+
tool_call_id: "dynamic-1",
|
|
271
|
+
tool_source: "mcp",
|
|
272
|
+
}),
|
|
273
|
+
expect.objectContaining({
|
|
274
|
+
tool_call_id: "static-2",
|
|
275
|
+
tool_source: "frontend",
|
|
276
|
+
}),
|
|
277
|
+
],
|
|
278
|
+
steps: [
|
|
279
|
+
{
|
|
280
|
+
tool_calls: [
|
|
281
|
+
expect.objectContaining({
|
|
282
|
+
tool_call_id: "static-1",
|
|
283
|
+
tool_source: "frontend",
|
|
284
|
+
}),
|
|
285
|
+
expect.objectContaining({
|
|
286
|
+
tool_call_id: "dynamic-1",
|
|
287
|
+
tool_source: "mcp",
|
|
288
|
+
}),
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
tool_calls: [
|
|
293
|
+
expect.objectContaining({
|
|
294
|
+
tool_call_id: "static-2",
|
|
295
|
+
tool_source: "frontend",
|
|
296
|
+
}),
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
}),
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
|
|
191
304
|
it("initializes the pinned item instead of the new main thread", async () => {
|
|
192
305
|
mocks.aui = mocks.makeClient(undefined, "new-thread", "thread-1");
|
|
193
306
|
const cloud = makeCloud();
|
|
@@ -216,4 +329,47 @@ describe("useAssistantCloudThreadHistoryAdapter", () => {
|
|
|
216
329
|
expect.anything(),
|
|
217
330
|
);
|
|
218
331
|
});
|
|
332
|
+
|
|
333
|
+
it("updates a history-loaded message when the list item identity differs from the live item", async () => {
|
|
334
|
+
mocks.aui = mocks.makeSplitClient("thread-split");
|
|
335
|
+
const cloud = makeCloud();
|
|
336
|
+
(cloud.threads.messages.list as ReturnType<typeof vi.fn>).mockResolvedValue(
|
|
337
|
+
{
|
|
338
|
+
messages: [
|
|
339
|
+
{
|
|
340
|
+
id: "m1",
|
|
341
|
+
parent_id: null,
|
|
342
|
+
format: "test",
|
|
343
|
+
content: { id: "m1" },
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
const cloudRef = { current: cloud };
|
|
349
|
+
const { result } = renderHook(() =>
|
|
350
|
+
useAssistantCloudThreadHistoryAdapter(cloudRef),
|
|
351
|
+
);
|
|
352
|
+
const formatted = result.current.withFormat<
|
|
353
|
+
{ id: string },
|
|
354
|
+
Record<string, unknown>
|
|
355
|
+
>({
|
|
356
|
+
format: "test",
|
|
357
|
+
encode: ({ message }) => message,
|
|
358
|
+
decode: ({ parent_id, content }) => ({
|
|
359
|
+
parentId: parent_id,
|
|
360
|
+
message: content as { id: string },
|
|
361
|
+
}),
|
|
362
|
+
getId: (message) => message.id,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
formatted.pin!();
|
|
366
|
+
await formatted.load();
|
|
367
|
+
await formatted.update!({ parentId: null, message: { id: "m1" } }, "m1");
|
|
368
|
+
|
|
369
|
+
expect(cloud.threads.messages.update).toHaveBeenCalledWith(
|
|
370
|
+
"thread-split",
|
|
371
|
+
"m1",
|
|
372
|
+
expect.anything(),
|
|
373
|
+
);
|
|
374
|
+
});
|
|
219
375
|
});
|
|
@@ -9,8 +9,13 @@ import type {
|
|
|
9
9
|
import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository";
|
|
10
10
|
import {
|
|
11
11
|
type AssistantCloud,
|
|
12
|
+
type AssistantCloudRunReportToolCall,
|
|
12
13
|
CloudMessagePersistence,
|
|
13
14
|
createFormattedPersistence,
|
|
15
|
+
createRunTelemetryToolCall,
|
|
16
|
+
normalizeRunTelemetryUsage,
|
|
17
|
+
type RunTelemetryUsageInit,
|
|
18
|
+
truncateRunTelemetryText,
|
|
14
19
|
} from "assistant-cloud";
|
|
15
20
|
import { auiV0Decode, auiV0Encode } from "./auiV0";
|
|
16
21
|
import { type AssistantClient, getClientId, useAui } from "@assistant-ui/store";
|
|
@@ -64,7 +69,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
64
69
|
if (!live.source) return undefined;
|
|
65
70
|
const id = live.getState().id;
|
|
66
71
|
if (id === undefined) return undefined;
|
|
67
|
-
|
|
72
|
+
// A body can resolve before the list's committed items include its
|
|
73
|
+
// thread; the live item is already the per-thread anchor in that window.
|
|
74
|
+
const listed = this.aui.threads
|
|
75
|
+
.getState()
|
|
76
|
+
.threadItems.some((item) => item.id === id || item.remoteId === id);
|
|
77
|
+
return listed ? this.aui.threads.item({ id }) : live;
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
withFormat<TMessage, TStorageFormat extends Record<string, unknown>>(
|
|
@@ -78,8 +88,6 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
78
88
|
return threadListItem;
|
|
79
89
|
};
|
|
80
90
|
const resolvePinned = () => threadListItem ?? pinCurrent();
|
|
81
|
-
const getFormatted = () =>
|
|
82
|
-
createFormattedPersistence(adapter._persistence, formatAdapter);
|
|
83
91
|
const getTargetFormatted = (item: CloudThreadListItem) =>
|
|
84
92
|
createFormattedPersistence(adapter.getPersistence(item), formatAdapter);
|
|
85
93
|
return {
|
|
@@ -130,11 +138,14 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
130
138
|
);
|
|
131
139
|
},
|
|
132
140
|
async load(): Promise<MessageFormatRepository<TMessage>> {
|
|
133
|
-
|
|
141
|
+
// Loads re-pin and resolve through the pinned item, so the id mapping
|
|
142
|
+
// they populate lives on the same persistence instance later writes
|
|
143
|
+
// resolve, whichever of the list item or the live graft won the pin.
|
|
144
|
+
const pinned = pinCurrent();
|
|
134
145
|
const live = adapter.aui.threadListItem;
|
|
135
146
|
const remoteId = live.source ? live.getState().remoteId : undefined;
|
|
136
147
|
if (!remoteId) return { messages: [] };
|
|
137
|
-
return
|
|
148
|
+
return getTargetFormatted(pinned ?? live).load(remoteId);
|
|
138
149
|
},
|
|
139
150
|
};
|
|
140
151
|
}
|
|
@@ -268,85 +279,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
268
279
|
}
|
|
269
280
|
}
|
|
270
281
|
|
|
271
|
-
const MAX_SPAN_CONTENT = 50_000;
|
|
272
|
-
|
|
273
|
-
function truncateStr(value: string): string {
|
|
274
|
-
if (value.length <= MAX_SPAN_CONTENT) return value;
|
|
275
|
-
return value.slice(0, MAX_SPAN_CONTENT);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function safeStringify(value: unknown): string | undefined {
|
|
279
|
-
if (value == null) return undefined;
|
|
280
|
-
try {
|
|
281
|
-
return truncateStr(JSON.stringify(value));
|
|
282
|
-
} catch {
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
type TelemetryToolCall = {
|
|
288
|
-
tool_name: string;
|
|
289
|
-
tool_call_id: string;
|
|
290
|
-
tool_args?: string;
|
|
291
|
-
tool_result?: string;
|
|
292
|
-
tool_source?: "mcp" | "frontend" | "backend";
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const BASE64_PATTERN = /^[A-Za-z0-9+/]{100,}={0,2}$/;
|
|
296
|
-
|
|
297
|
-
function summarizeMcpResult(value: unknown): string | undefined {
|
|
298
|
-
if (value == null) return undefined;
|
|
299
|
-
try {
|
|
300
|
-
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
301
|
-
if (Array.isArray(parsed)) {
|
|
302
|
-
const summarized = parsed.map((item) => {
|
|
303
|
-
if (item && typeof item === "object" && item.type) {
|
|
304
|
-
if (
|
|
305
|
-
(item.type === "image" || item.type === "audio") &&
|
|
306
|
-
typeof item.data === "string" &&
|
|
307
|
-
BASE64_PATTERN.test(item.data.slice(0, 200))
|
|
308
|
-
) {
|
|
309
|
-
const sizeKB = ((item.data.length * 3) / 4 / 1024).toFixed(1);
|
|
310
|
-
return { ...item, data: `[${item.type}: ${sizeKB}KB]` };
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return item;
|
|
314
|
-
});
|
|
315
|
-
return truncateStr(JSON.stringify(summarized));
|
|
316
|
-
}
|
|
317
|
-
} catch {
|
|
318
|
-
// not JSON array, fall through
|
|
319
|
-
}
|
|
320
|
-
return safeStringify(value);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function buildToolCall(
|
|
324
|
-
toolName: string,
|
|
325
|
-
toolCallId: string,
|
|
326
|
-
args: unknown,
|
|
327
|
-
result: unknown,
|
|
328
|
-
argsText?: string,
|
|
329
|
-
toolSource?: "mcp" | "frontend" | "backend",
|
|
330
|
-
): TelemetryToolCall {
|
|
331
|
-
const call: TelemetryToolCall = {
|
|
332
|
-
tool_name: toolName,
|
|
333
|
-
tool_call_id: toolCallId,
|
|
334
|
-
};
|
|
335
|
-
const toolArgs = argsText ?? safeStringify(args);
|
|
336
|
-
if (toolArgs !== undefined) call.tool_args = toolArgs;
|
|
337
|
-
const toolResult =
|
|
338
|
-
toolSource === "mcp" ? summarizeMcpResult(result) : safeStringify(result);
|
|
339
|
-
if (toolResult !== undefined) call.tool_result = toolResult;
|
|
340
|
-
if (toolSource) call.tool_source = toolSource;
|
|
341
|
-
return call;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
282
|
type TelemetryStepData = {
|
|
345
283
|
input_tokens?: number;
|
|
346
284
|
output_tokens?: number;
|
|
347
285
|
reasoning_tokens?: number;
|
|
348
286
|
cached_input_tokens?: number;
|
|
349
|
-
tool_calls?:
|
|
287
|
+
tool_calls?: AssistantCloudRunReportToolCall[];
|
|
350
288
|
start_ms?: number;
|
|
351
289
|
end_ms?: number;
|
|
352
290
|
};
|
|
@@ -369,7 +307,7 @@ function mergeStepTimestamps(
|
|
|
369
307
|
|
|
370
308
|
type TelemetryData = {
|
|
371
309
|
status: "completed" | "incomplete" | "error";
|
|
372
|
-
toolCalls?:
|
|
310
|
+
toolCalls?: AssistantCloudRunReportToolCall[];
|
|
373
311
|
totalSteps?: number;
|
|
374
312
|
inputTokens?: number;
|
|
375
313
|
outputTokens?: number;
|
|
@@ -426,14 +364,7 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
426
364
|
}[];
|
|
427
365
|
metadata?: {
|
|
428
366
|
modelId?: string;
|
|
429
|
-
steps?: readonly {
|
|
430
|
-
usage?: {
|
|
431
|
-
inputTokens?: number;
|
|
432
|
-
outputTokens?: number;
|
|
433
|
-
reasoningTokens?: number;
|
|
434
|
-
cachedInputTokens?: number;
|
|
435
|
-
};
|
|
436
|
-
}[];
|
|
367
|
+
steps?: readonly { usage?: RunTelemetryUsageInit }[];
|
|
437
368
|
custom?: Record<string, unknown> & { modelId?: string };
|
|
438
369
|
};
|
|
439
370
|
};
|
|
@@ -446,13 +377,19 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
446
377
|
const toolCalls = msg.content
|
|
447
378
|
?.filter((p) => p.type === "tool-call" && p.toolName && p.toolCallId)
|
|
448
379
|
.map((p) =>
|
|
449
|
-
|
|
380
|
+
createRunTelemetryToolCall({
|
|
381
|
+
toolName: p.toolName!,
|
|
382
|
+
toolCallId: p.toolCallId!,
|
|
383
|
+
args: p.args,
|
|
384
|
+
result: p.result,
|
|
385
|
+
argsText: p.argsText,
|
|
386
|
+
}),
|
|
450
387
|
);
|
|
451
388
|
|
|
452
389
|
const textParts = msg.content?.filter((p) => p.type === "text" && p.text);
|
|
453
390
|
const outputText =
|
|
454
391
|
textParts && textParts.length > 0
|
|
455
|
-
?
|
|
392
|
+
? truncateRunTelemetryText(textParts.map((p) => p.text).join(""))
|
|
456
393
|
: undefined;
|
|
457
394
|
|
|
458
395
|
const steps = msg.metadata?.steps;
|
|
@@ -470,20 +407,23 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
470
407
|
let hasReasoning = false;
|
|
471
408
|
let hasCachedInput = false;
|
|
472
409
|
for (const step of steps) {
|
|
473
|
-
if (step.usage
|
|
474
|
-
|
|
410
|
+
if (!step.usage) continue;
|
|
411
|
+
const usage = normalizeRunTelemetryUsage(step.usage);
|
|
412
|
+
if (!usage) continue;
|
|
413
|
+
if (usage.inputTokens != null) {
|
|
414
|
+
totalInput += usage.inputTokens;
|
|
475
415
|
hasInput = true;
|
|
476
416
|
}
|
|
477
|
-
if (
|
|
478
|
-
totalOutput +=
|
|
417
|
+
if (usage.outputTokens != null) {
|
|
418
|
+
totalOutput += usage.outputTokens;
|
|
479
419
|
hasOutput = true;
|
|
480
420
|
}
|
|
481
|
-
if (
|
|
482
|
-
totalReasoning +=
|
|
421
|
+
if (usage.reasoningTokens != null) {
|
|
422
|
+
totalReasoning += usage.reasoningTokens;
|
|
483
423
|
hasReasoning = true;
|
|
484
424
|
}
|
|
485
|
-
if (
|
|
486
|
-
totalCachedInput +=
|
|
425
|
+
if (usage.cachedInputTokens != null) {
|
|
426
|
+
totalCachedInput += usage.cachedInputTokens;
|
|
487
427
|
hasCachedInput = true;
|
|
488
428
|
}
|
|
489
429
|
}
|
|
@@ -506,20 +446,25 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
506
446
|
|
|
507
447
|
const telemetrySteps: TelemetryStepData[] | undefined =
|
|
508
448
|
steps && steps.length > 1
|
|
509
|
-
? steps.map((s) =>
|
|
510
|
-
|
|
511
|
-
?
|
|
512
|
-
: undefined
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
449
|
+
? steps.map((s) => {
|
|
450
|
+
const usage = s.usage
|
|
451
|
+
? normalizeRunTelemetryUsage(s.usage)
|
|
452
|
+
: undefined;
|
|
453
|
+
return {
|
|
454
|
+
...(usage?.inputTokens != null
|
|
455
|
+
? { input_tokens: usage.inputTokens }
|
|
456
|
+
: undefined),
|
|
457
|
+
...(usage?.outputTokens != null
|
|
458
|
+
? { output_tokens: usage.outputTokens }
|
|
459
|
+
: undefined),
|
|
460
|
+
...(usage?.reasoningTokens != null
|
|
461
|
+
? { reasoning_tokens: usage.reasoningTokens }
|
|
462
|
+
: undefined),
|
|
463
|
+
...(usage?.cachedInputTokens != null
|
|
464
|
+
? { cached_input_tokens: usage.cachedInputTokens }
|
|
465
|
+
: undefined),
|
|
466
|
+
};
|
|
467
|
+
})
|
|
523
468
|
: undefined;
|
|
524
469
|
|
|
525
470
|
return {
|
|
@@ -564,29 +509,28 @@ function isDynamicToolPart(p: AiSdkV6Part): boolean {
|
|
|
564
509
|
return p.type === "dynamic-tool" || p.type.startsWith("dynamic-tool-");
|
|
565
510
|
}
|
|
566
511
|
|
|
567
|
-
function partToToolCall(p: AiSdkV6Part):
|
|
568
|
-
const toolSource: "mcp" |
|
|
512
|
+
function partToToolCall(p: AiSdkV6Part): AssistantCloudRunReportToolCall {
|
|
513
|
+
const toolSource: "mcp" | "frontend" = isDynamicToolPart(p)
|
|
569
514
|
? "mcp"
|
|
570
|
-
:
|
|
571
|
-
return
|
|
572
|
-
p.toolName ?? p.type.slice(5),
|
|
573
|
-
p.toolCallId!,
|
|
574
|
-
p.args ?? p.input,
|
|
575
|
-
p.result ?? p.output,
|
|
576
|
-
undefined,
|
|
515
|
+
: "frontend";
|
|
516
|
+
return createRunTelemetryToolCall({
|
|
517
|
+
toolName: p.toolName ?? p.type.slice(5),
|
|
518
|
+
toolCallId: p.toolCallId!,
|
|
519
|
+
args: p.args ?? p.input,
|
|
520
|
+
result: p.result ?? p.output,
|
|
577
521
|
toolSource,
|
|
578
|
-
);
|
|
522
|
+
});
|
|
579
523
|
}
|
|
580
524
|
|
|
581
525
|
function collectAiSdkV6Parts(parts: readonly AiSdkV6Part[]): {
|
|
582
526
|
textParts: string[];
|
|
583
|
-
toolCalls:
|
|
584
|
-
stepsData: { tool_calls:
|
|
527
|
+
toolCalls: AssistantCloudRunReportToolCall[];
|
|
528
|
+
stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[];
|
|
585
529
|
} {
|
|
586
530
|
const textParts: string[] = [];
|
|
587
|
-
const toolCalls:
|
|
588
|
-
const stepsData: { tool_calls:
|
|
589
|
-
let currentStepToolCalls:
|
|
531
|
+
const toolCalls: AssistantCloudRunReportToolCall[] = [];
|
|
532
|
+
const stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
|
|
533
|
+
let currentStepToolCalls: AssistantCloudRunReportToolCall[] | null = null;
|
|
590
534
|
|
|
591
535
|
for (const p of parts) {
|
|
592
536
|
if (p.type === "step-start") {
|
|
@@ -624,10 +568,10 @@ function extractModelId(
|
|
|
624
568
|
|
|
625
569
|
function buildAiSdkV6Result(
|
|
626
570
|
textParts: string[],
|
|
627
|
-
toolCalls:
|
|
571
|
+
toolCalls: AssistantCloudRunReportToolCall[],
|
|
628
572
|
totalSteps: number,
|
|
629
573
|
metadata?: Record<string, unknown>,
|
|
630
|
-
stepsData?: { tool_calls:
|
|
574
|
+
stepsData?: { tool_calls: AssistantCloudRunReportToolCall[] }[],
|
|
631
575
|
usage?: {
|
|
632
576
|
inputTokens?: number;
|
|
633
577
|
outputTokens?: number;
|
|
@@ -636,7 +580,9 @@ function buildAiSdkV6Result(
|
|
|
636
580
|
},
|
|
637
581
|
): TelemetryData {
|
|
638
582
|
const hasText = textParts.length > 0;
|
|
639
|
-
const outputText = hasText
|
|
583
|
+
const outputText = hasText
|
|
584
|
+
? truncateRunTelemetryText(textParts.join(""))
|
|
585
|
+
: undefined;
|
|
640
586
|
const modelId = extractModelId(metadata);
|
|
641
587
|
|
|
642
588
|
const steps: TelemetryStepData[] | undefined =
|
|
@@ -671,46 +617,6 @@ function buildAiSdkV6Result(
|
|
|
671
617
|
};
|
|
672
618
|
}
|
|
673
619
|
|
|
674
|
-
type UsageFields = {
|
|
675
|
-
inputTokens?: number;
|
|
676
|
-
outputTokens?: number;
|
|
677
|
-
promptTokens?: number;
|
|
678
|
-
completionTokens?: number;
|
|
679
|
-
reasoningTokens?: number;
|
|
680
|
-
cachedInputTokens?: number;
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
function normalizeUsage(u: UsageFields):
|
|
684
|
-
| {
|
|
685
|
-
inputTokens?: number;
|
|
686
|
-
outputTokens?: number;
|
|
687
|
-
reasoningTokens?: number;
|
|
688
|
-
cachedInputTokens?: number;
|
|
689
|
-
}
|
|
690
|
-
| undefined {
|
|
691
|
-
const input = u.inputTokens ?? u.promptTokens;
|
|
692
|
-
const output = u.outputTokens ?? u.completionTokens;
|
|
693
|
-
if (
|
|
694
|
-
input == null &&
|
|
695
|
-
output == null &&
|
|
696
|
-
u.reasoningTokens == null &&
|
|
697
|
-
u.cachedInputTokens == null
|
|
698
|
-
) {
|
|
699
|
-
return undefined;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
return {
|
|
703
|
-
...(input != null ? { inputTokens: input } : undefined),
|
|
704
|
-
...(output != null ? { outputTokens: output } : undefined),
|
|
705
|
-
...(u.reasoningTokens != null
|
|
706
|
-
? { reasoningTokens: u.reasoningTokens }
|
|
707
|
-
: undefined),
|
|
708
|
-
...(u.cachedInputTokens != null
|
|
709
|
-
? { cachedInputTokens: u.cachedInputTokens }
|
|
710
|
-
: undefined),
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
|
|
714
620
|
function extractAiSdkV6Usage(metadata?: Record<string, unknown>):
|
|
715
621
|
| {
|
|
716
622
|
inputTokens?: number;
|
|
@@ -720,15 +626,15 @@ function extractAiSdkV6Usage(metadata?: Record<string, unknown>):
|
|
|
720
626
|
}
|
|
721
627
|
| undefined {
|
|
722
628
|
// Try top-level metadata.usage
|
|
723
|
-
const usage = metadata?.usage as
|
|
629
|
+
const usage = metadata?.usage as RunTelemetryUsageInit | undefined;
|
|
724
630
|
if (usage) {
|
|
725
|
-
const normalized =
|
|
631
|
+
const normalized = normalizeRunTelemetryUsage(usage);
|
|
726
632
|
if (normalized) return normalized;
|
|
727
633
|
}
|
|
728
634
|
|
|
729
635
|
// Try aggregating from metadata.steps[].usage
|
|
730
636
|
const steps = metadata?.steps as
|
|
731
|
-
| readonly { usage?:
|
|
637
|
+
| readonly { usage?: RunTelemetryUsageInit }[]
|
|
732
638
|
| undefined;
|
|
733
639
|
if (steps && steps.length > 0) {
|
|
734
640
|
let inputTokens = 0;
|
|
@@ -742,7 +648,7 @@ function extractAiSdkV6Usage(metadata?: Record<string, unknown>):
|
|
|
742
648
|
let hasAny = false;
|
|
743
649
|
for (const s of steps) {
|
|
744
650
|
if (!s.usage) continue;
|
|
745
|
-
const n =
|
|
651
|
+
const n = normalizeRunTelemetryUsage(s.usage);
|
|
746
652
|
if (n) {
|
|
747
653
|
if (n.inputTokens != null) {
|
|
748
654
|
inputTokens += n.inputTokens;
|
|
@@ -795,8 +701,8 @@ function extractAiSdkV6<T>(content: T): TelemetryData | null {
|
|
|
795
701
|
|
|
796
702
|
function aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {
|
|
797
703
|
const allTextParts: string[] = [];
|
|
798
|
-
const allToolCalls:
|
|
799
|
-
const allStepsData: { tool_calls:
|
|
704
|
+
const allToolCalls: AssistantCloudRunReportToolCall[] = [];
|
|
705
|
+
const allStepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
|
|
800
706
|
let hasAssistant = false;
|
|
801
707
|
let metadata: Record<string, unknown> | undefined;
|
|
802
708
|
let inputTokens = 0;
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
MessageStatus,
|
|
3
3
|
SourceProviderMetadata,
|
|
4
4
|
ThreadMessage,
|
|
5
|
+
ToolApprovalDisplay,
|
|
5
6
|
ToolApprovalOption,
|
|
6
7
|
} from "../../../types/message";
|
|
7
8
|
import type { CompleteAttachment } from "../../../types/attachment";
|
|
@@ -16,11 +17,15 @@ import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/messa
|
|
|
16
17
|
|
|
17
18
|
type AuiV0ToolApproval = {
|
|
18
19
|
readonly id: string;
|
|
20
|
+
readonly prompt?: string;
|
|
21
|
+
readonly display?: ToolApprovalDisplay;
|
|
22
|
+
readonly allowFreeform?: boolean;
|
|
19
23
|
readonly approved?: boolean;
|
|
20
24
|
readonly reason?: string;
|
|
21
25
|
readonly isAutomatic?: boolean;
|
|
22
26
|
readonly options?: readonly ToolApprovalOption[];
|
|
23
27
|
readonly optionId?: string;
|
|
28
|
+
readonly text?: string;
|
|
24
29
|
readonly resolution?: "cancelled" | "expired";
|
|
25
30
|
};
|
|
26
31
|
|