@assistant-ui/core 0.3.17 → 0.3.19
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/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +13 -3
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +4 -0
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -3
- package/dist/internal.js +3 -2
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +35 -14
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +2 -0
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +30 -7
- 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 +27 -18
- 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/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/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +45 -7
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +20 -15
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.js +62 -56
- 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 +35 -32
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +1 -0
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +154 -143
- 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 +18 -16
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.js +3 -2
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/interactables-legacy/Interactables.js +242 -121
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.js +3 -0
- package/dist/react/interactables-legacy/useAssistantInteractable.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/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/useInteractable.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.js +4 -1
- package/dist/react/model-context/useInteractable.js.map +1 -1
- package/dist/react/model-context/useInteractableVersions.js +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/primitives/message/MessageGroupedParts.d.ts +11 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +3 -2
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +1 -0
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.js +1 -0
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +6 -5
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +16 -8
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +5 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +105 -104
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +1 -0
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +13 -11
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +5 -24
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +354 -226
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -0
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +22 -2
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +40 -15
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +62 -15
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +2 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +6 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +6 -0
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/sdkIdentity.js +9 -0
- package/dist/react/runtimes/cloud/sdkIdentity.js.map +1 -0
- package/dist/react/runtimes/external-message-converter.d.ts +12 -2
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +26 -61
- 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 +64 -24
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/utils/groupParts.d.ts +6 -1
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +6 -0
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +3 -1
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.js +6 -1
- package/dist/react/utils/useJSONEqual.js.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +7 -0
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -0
- package/dist/react/utils/useJSONSchemaDependency.js +20 -0
- package/dist/react/utils/useJSONSchemaDependency.js.map +1 -0
- 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 +3 -0
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +18 -14
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +4 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +3 -6
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -0
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +62 -22
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +161 -69
- 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 +4 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +6 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +5 -0
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +61 -6
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/auto-status.d.ts +6 -2
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +12 -4
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +16 -4
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +49 -13
- 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 +18 -9
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +2 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +5 -3
- package/dist/runtime/utils/thread-message-like.js.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.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +8 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/internal.d.ts +3 -3
- 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 +4 -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 +130 -42
- 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 +3 -1
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.js +9 -1
- package/dist/runtimes/remote-thread-list/title.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +10 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +260 -203
- 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 +1 -0
- 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 +5 -4
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +13 -0
- package/dist/store/clients/thread-tasks.d.ts.map +1 -0
- package/dist/store/clients/thread-tasks.js +69 -0
- package/dist/store/clients/thread-tasks.js.map +1 -0
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +3 -3
- package/dist/store/primitive-predicates.d.ts.map +1 -1
- package/dist/store/primitive-predicates.js +4 -4
- 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 +97 -61
- 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 +1 -1
- 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 +54 -52
- 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 +246 -126
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +2 -0
- package/dist/store/scope-registration.d.ts.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/task.d.ts +36 -0
- package/dist/store/scopes/task.d.ts.map +1 -0
- package/dist/store/scopes/task.js +0 -0
- 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 +28 -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 +2 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +23 -15
- 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/index.d.ts +2 -2
- package/dist/types/message.d.ts +8 -1
- package/dist/types/message.d.ts.map +1 -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 +88 -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/getGroupStatus.d.ts +18 -2
- package/dist/utils/getGroupStatus.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.js +32 -7
- package/dist/utils/getGroupStatus.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/dist/utils/wire-media.d.ts.map +1 -1
- package/dist/utils/wire-media.js +2 -2
- package/dist/utils/wire-media.js.map +1 -1
- package/package.json +11 -11
- package/src/adapters/attachment.test.ts +50 -1
- package/src/adapters/attachment.ts +7 -4
- package/src/adapters/speech.test.ts +236 -0
- package/src/adapters/speech.ts +17 -10
- package/src/adapters/thread-history.ts +3 -0
- package/src/index.ts +2 -0
- package/src/internal.ts +4 -0
- package/src/model-context/frame/host.test.ts +137 -1
- package/src/model-context/frame/host.ts +49 -16
- package/src/model-context/frame/provider.test.ts +71 -0
- package/src/model-context/frame/provider.ts +37 -7
- package/src/model-context/interactable-composer-metadata.test.ts +58 -0
- package/src/model-context/interactable-composer-metadata.ts +19 -13
- package/src/model-context/registry.test.ts +12 -0
- package/src/model-context/registry.ts +3 -2
- package/src/model-context/types.test.ts +25 -0
- package/src/model-context/types.ts +9 -4
- package/src/react/RuntimeAdapter.test.ts +34 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +244 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +104 -7
- package/src/react/client/DataRenderers.test.tsx +45 -0
- package/src/react/client/DataRenderers.ts +13 -9
- package/src/react/client/InMemoryThreadList.ts +1 -0
- package/src/react/client/Interactables.test.ts +72 -1
- package/src/react/client/Interactables.ts +22 -14
- package/src/react/client/RemoteThreadList.background.test.ts +148 -6
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +42 -1
- package/src/react/client/RemoteThreadList.test.ts +386 -4
- package/src/react/client/RemoteThreadList.ts +181 -112
- package/src/react/client/Tools.ts +22 -11
- package/src/react/client/interactable-model-context.test.ts +44 -0
- package/src/react/client/interactable-model-context.ts +3 -2
- package/src/react/index.ts +5 -1
- package/src/react/interactables-legacy/Interactables.ts +16 -16
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +132 -0
- package/src/react/interactables-legacy/useAssistantInteractable.ts +10 -1
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +9 -10
- package/src/react/model-context/makeAssistantTool.ts +2 -2
- package/src/react/model-context/useAssistantTool.ts +2 -2
- package/src/react/model-context/useInteractable.test.tsx +177 -0
- package/src/react/model-context/useInteractable.ts +3 -0
- package/src/react/model-context/useToolArgsStatus.test.tsx +30 -0
- package/src/react/model-context/useToolArgsStatus.ts +2 -1
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +0 -1
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +0 -1
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +96 -0
- package/src/react/primitives/message/MessageGroupedParts.tsx +15 -4
- package/src/react/primitives/part/PartMessages.test.tsx +104 -1
- package/src/react/primitives/part/PartMessages.tsx +1 -0
- package/src/react/primitives/thread/ThreadMessages.test.tsx +142 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +8 -5
- package/src/react/providers/ReadonlyThreadProvider.test.tsx +56 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.destroy.test.tsx +172 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +33 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +7 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +28 -5
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.load-error.test.ts +132 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.switch-delete.test.ts +105 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +143 -112
- package/src/react/runtimes/RemoteThreadResource.test.ts +9 -0
- package/src/react/runtimes/RemoteThreadResource.ts +19 -12
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +20 -14
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +703 -6
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +492 -402
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +77 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +27 -1
- package/src/react/runtimes/cloud/auiV0.ts +160 -25
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +36 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +8 -1
- package/src/react/runtimes/cloud/sdkIdentity.ts +9 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +18 -4
- package/src/react/runtimes/external-message-converter.test.ts +136 -1
- package/src/react/runtimes/external-message-converter.ts +39 -93
- 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.load-error.test.tsx +108 -0
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +34 -1
- package/src/react/utils/groupParts.ts +12 -1
- package/src/react/utils/useJSONEqual.ts +9 -0
- package/src/react/utils/useJSONSchemaDependency.ts +22 -0
- 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 +21 -11
- package/src/runtime/api/thread-runtime.test.ts +136 -0
- package/src/runtime/api/thread-runtime.ts +10 -5
- package/src/runtime/base/base-composer-runtime-core.ts +105 -24
- package/src/runtime/base/base-thread-runtime-core.test.ts +1063 -2
- package/src/runtime/base/base-thread-runtime-core.ts +228 -87
- package/src/runtime/interfaces/composer-runtime-core.ts +10 -5
- package/src/runtime/interfaces/thread-list-runtime-core.ts +5 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +6 -0
- package/src/runtime/queue/message-queue.ts +68 -6
- package/src/runtime/utils/auto-status.test.ts +112 -1
- package/src/runtime/utils/auto-status.ts +31 -5
- package/src/runtime/utils/external-message-conversion.test.ts +202 -0
- package/src/runtime/utils/external-message-conversion.ts +123 -32
- package/src/runtime/utils/message-repository.test.ts +49 -0
- package/src/runtime/utils/message-repository.ts +32 -20
- package/src/runtime/utils/thread-message-like.test.ts +52 -0
- package/src/runtime/utils/thread-message-like.ts +5 -1
- 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 +31 -1
- package/src/runtimes/internal.ts +1 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +21 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +11 -1
- package/src/runtimes/remote-thread-list/remote-thread-state.test.ts +128 -2
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +182 -42
- 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 +13 -0
- package/src/runtimes/remote-thread-list/types.ts +10 -0
- package/src/runtimes/tool-invocations/EDGE_CASES.md +2 -6
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +133 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +10 -6
- package/src/store/clients/external-thread.ts +67 -4
- 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 +40 -0
- package/src/store/clients/suggestions.ts +13 -10
- package/src/store/clients/thread-tasks.test.ts +274 -0
- package/src/store/clients/thread-tasks.ts +138 -0
- package/src/store/index.ts +8 -0
- package/src/store/primitive-predicates.test.ts +48 -5
- package/src/store/primitive-predicates.ts +7 -2
- 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 +1 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +89 -11
- package/src/store/scope-registration.ts +2 -0
- package/src/store/scopes/composer.ts +16 -4
- package/src/store/scopes/message.ts +14 -0
- package/src/store/scopes/task.ts +34 -0
- package/src/store/scopes/thread-list-item.ts +5 -2
- package/src/store/scopes/thread.ts +20 -0
- package/src/store/scopes/threads.ts +1 -0
- package/src/store/thread-tasks.test.tsx +209 -0
- package/src/subscribable/subscribable.test.ts +156 -1
- package/src/subscribable/subscribable.ts +25 -15
- package/src/tests/MessageRepository.test.ts +117 -5
- 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 +47 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-title-race.test.ts +89 -0
- package/src/tests/attachment-adapters.test.ts +14 -0
- package/src/tests/auiV0Encode.test.ts +300 -0
- package/src/tests/base-composer-runtime-core-send.test.ts +51 -0
- package/src/tests/base-composer-runtime-core.test.ts +353 -2
- package/src/tests/external-store-thread-list-runtime-core.test.ts +83 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +178 -18
- package/src/tests/external-thread-attachments.test.tsx +208 -0
- package/src/tests/external-thread-parity.test.tsx +57 -0
- package/src/tests/groupParts.test.ts +71 -0
- package/src/tests/message-queue.test.ts +253 -0
- package/src/tests/remote-thread-list-isLoading.test.ts +1 -0
- package/src/tests/remote-thread-list-reactive-threadId.test.ts +51 -0
- package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +1 -0
- package/src/tests/thread-switch-events.test.tsx +78 -0
- package/src/tests/tools-scope-migration.test.tsx +28 -0
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +43 -0
- package/src/types/attachment.ts +4 -0
- package/src/types/index.ts +1 -0
- package/src/types/message.ts +8 -0
- package/src/utils/abortable-iterable.test.ts +328 -0
- package/src/utils/abortable-iterable.ts +104 -0
- package/src/utils/composite-context-provider.test.ts +25 -0
- package/src/utils/composite-context-provider.ts +23 -2
- package/src/utils/getGroupStatus.test.ts +70 -4
- package/src/utils/getGroupStatus.ts +35 -12
- package/src/utils/record.test.ts +48 -0
- package/src/utils/record.ts +11 -0
- package/src/utils/wire-media.test.ts +10 -0
- package/src/utils/wire-media.ts +6 -2
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { auiV0Decode, auiV0Encode } from "./auiV0.js";
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
3
|
import { useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
3
4
|
import { getClientId, useAui } from "@assistant-ui/store";
|
|
4
|
-
import { CloudMessagePersistence, createFormattedPersistence, createRunTelemetryToolCall, normalizeRunTelemetryUsage, truncateRunTelemetryText } from "assistant-cloud";
|
|
5
|
+
import { CloudEngagementReporter, CloudMessagePersistence, CloudRunReporter, createFormattedPersistence, createRunTelemetryToolCall, deriveRunOutcome, describeRunError, extractRunTelemetryModelId, normalizeRunTelemetryUsage, truncateRunTelemetryText } from "assistant-cloud";
|
|
6
|
+
import { extractAISDKRunTelemetry } from "assistant-cloud/ai-sdk";
|
|
5
7
|
//#region src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts
|
|
6
8
|
const globalPersistence = /* @__PURE__ */ new WeakMap();
|
|
7
9
|
var AssistantCloudThreadHistoryAdapter = class {
|
|
8
10
|
cloudRef;
|
|
9
11
|
getAui;
|
|
12
|
+
runReporter;
|
|
13
|
+
engagementReporter;
|
|
10
14
|
constructor(cloudRef, getAui) {
|
|
11
15
|
this.cloudRef = cloudRef;
|
|
12
16
|
this.getAui = getAui;
|
|
17
|
+
this.runReporter = new CloudRunReporter(() => this.cloudRef.current);
|
|
18
|
+
this.engagementReporter = new CloudEngagementReporter(() => this.cloudRef.current, (threadId, messageId, options) => this.resolveEngagementEventIds(threadId, messageId, options));
|
|
13
19
|
}
|
|
14
20
|
get aui() {
|
|
15
21
|
return this.getAui();
|
|
@@ -22,6 +28,41 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
22
28
|
get _persistence() {
|
|
23
29
|
return this.getPersistence();
|
|
24
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A send is the moment the runtime creates the remote thread, so that one
|
|
33
|
+
* event waits for the id; every other event reads the id that already
|
|
34
|
+
* exists, because initializing a thread nobody has written to would create
|
|
35
|
+
* an empty remote thread just to attribute an event.
|
|
36
|
+
*/
|
|
37
|
+
async resolveEngagementEventIds(threadId, messageId, options) {
|
|
38
|
+
const threadListItem = this.getThreadListItem(threadId);
|
|
39
|
+
if (!threadListItem) return {};
|
|
40
|
+
let remoteThreadId = threadListItem.getState().remoteId;
|
|
41
|
+
if (!remoteThreadId && options?.awaitThread) remoteThreadId = await threadListItem.initialize().then((result) => result.remoteId).catch(() => void 0);
|
|
42
|
+
const remoteMessageId = messageId ? this.getPersistence(threadListItem).getResolvedRemoteId(messageId) : void 0;
|
|
43
|
+
return {
|
|
44
|
+
...remoteThreadId ? { thread_id: remoteThreadId } : void 0,
|
|
45
|
+
...remoteMessageId ? { message_id: remoteMessageId } : void 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
feedback = { submit: ({ message, type }) => {
|
|
49
|
+
(async () => {
|
|
50
|
+
const threadListItem = this.tryGetKeyedThreadListItem();
|
|
51
|
+
const remoteThreadId = threadListItem?.getState().remoteId;
|
|
52
|
+
if (!threadListItem || !remoteThreadId) {
|
|
53
|
+
console.warn(`[assistant-ui] Skipping feedback for message ${message.id}: the thread has no remote id.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const cloudMessageId = await this.getPersistence(threadListItem).getRemoteId(message.id);
|
|
57
|
+
if (!cloudMessageId) {
|
|
58
|
+
console.warn(`[assistant-ui] Skipping feedback for message ${message.id}: no cloud message id is mapped.`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await this.cloudRef.current.threads.messages.feedback(remoteThreadId, cloudMessageId, { type });
|
|
62
|
+
})().catch((error) => {
|
|
63
|
+
console.error("[assistant-ui] Cloud feedback submission failed:", error);
|
|
64
|
+
});
|
|
65
|
+
} };
|
|
25
66
|
tryGetKeyedThreadListItem() {
|
|
26
67
|
const live = this.aui.threadListItem;
|
|
27
68
|
if (!live.source) return void 0;
|
|
@@ -29,6 +70,13 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
29
70
|
if (id === void 0) return void 0;
|
|
30
71
|
return this.aui.threads.getState().threadItems.some((item) => item.id === id || item.remoteId === id) ? this.aui.threads.item({ id }) : live;
|
|
31
72
|
}
|
|
73
|
+
getThreadListItem(threadId) {
|
|
74
|
+
const current = this.aui.threadListItem;
|
|
75
|
+
const currentState = current.getState();
|
|
76
|
+
if (currentState.id === threadId || currentState.remoteId === threadId) return current;
|
|
77
|
+
const listed = this.aui.threads.getState().threadItems.find((item) => item.id === threadId || item.remoteId === threadId);
|
|
78
|
+
return listed ? this.aui.threads.item({ id: listed.id }) : void 0;
|
|
79
|
+
}
|
|
32
80
|
withFormat(formatAdapter) {
|
|
33
81
|
const adapter = this;
|
|
34
82
|
let threadListItem;
|
|
@@ -60,7 +108,7 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
60
108
|
},
|
|
61
109
|
reportTelemetry(items, options) {
|
|
62
110
|
const encodedRunMessages = items.map((item) => formatAdapter.encode(item));
|
|
63
|
-
adapter._reportRunTelemetry(formatAdapter.format, encodedRunMessages, options, resolvePinned());
|
|
111
|
+
adapter._reportRunTelemetry(formatAdapter.format, encodedRunMessages, options, resolvePinned(), mergeRunMessageInfo(extractLastRunMessageInfo(items, formatAdapter), options?.message ? extractRunMessageInfo(options.message, "aui/v0") : void 0));
|
|
64
112
|
},
|
|
65
113
|
async load() {
|
|
66
114
|
const pinned = pinCurrent();
|
|
@@ -75,7 +123,7 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
75
123
|
const { remoteId } = await this.aui.threadListItem.initialize();
|
|
76
124
|
const encoded = auiV0Encode(message);
|
|
77
125
|
await this._persistence.append(remoteId, message.id, parentId, "aui/v0", encoded);
|
|
78
|
-
if (this.cloudRef.current.telemetry.enabled) this._maybeReportRun(remoteId, "aui/v0", encoded);
|
|
126
|
+
if (this.cloudRef.current.telemetry.enabled) this._maybeReportRun(remoteId, "aui/v0", encoded, extractRunMessageInfo(message, "aui/v0"));
|
|
79
127
|
}
|
|
80
128
|
async update(item) {
|
|
81
129
|
if (!this._persistence.isPersisted(item.message.id)) return this.append(item);
|
|
@@ -84,7 +132,7 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
84
132
|
if (!remoteId) return;
|
|
85
133
|
const encoded = auiV0Encode(message);
|
|
86
134
|
await this._persistence.update(remoteId, message.id, "aui/v0", encoded);
|
|
87
|
-
if (this.cloudRef.current.telemetry.enabled) this._maybeReportRun(remoteId, "aui/v0", encoded);
|
|
135
|
+
if (this.cloudRef.current.telemetry.enabled) this._maybeReportRun(remoteId, "aui/v0", encoded, extractRunMessageInfo(message, "aui/v0"));
|
|
88
136
|
}
|
|
89
137
|
async delete() {
|
|
90
138
|
throw new Error("Assistant Cloud does not support deleting thread messages yet.");
|
|
@@ -94,70 +142,120 @@ var AssistantCloudThreadHistoryAdapter = class {
|
|
|
94
142
|
if (!remoteId) return { messages: [] };
|
|
95
143
|
return { messages: (await this._persistence.load(remoteId, "aui/v0")).filter((m) => m.format === "aui/v0").map(auiV0Decode).reverse() };
|
|
96
144
|
}
|
|
97
|
-
_reportRunTelemetry(format, runMessages, options, threadListItem) {
|
|
98
|
-
|
|
99
|
-
const remoteId =
|
|
145
|
+
_reportRunTelemetry(format, runMessages, options, threadListItem, messageInfo) {
|
|
146
|
+
const item = threadListItem ?? this.aui.threadListItem;
|
|
147
|
+
const remoteId = item.getState().remoteId;
|
|
100
148
|
if (!remoteId) return;
|
|
101
|
-
const extracted = extractRunTelemetry(format, runMessages);
|
|
149
|
+
const extracted = extractRunTelemetry(format, runMessages) ?? (messageInfo?.status !== void 0 ? { status: "incomplete" } : void 0);
|
|
102
150
|
if (!extracted) return;
|
|
103
|
-
this._sendReport(remoteId, extracted, options?.durationMs, options?.stepTimestamps);
|
|
151
|
+
this._sendReport(remoteId, extracted, options?.durationMs, options?.stepTimestamps, messageInfo, this.getPersistence(item));
|
|
104
152
|
}
|
|
105
|
-
_maybeReportRun(remoteId, format, content) {
|
|
153
|
+
_maybeReportRun(remoteId, format, content, messageInfo) {
|
|
106
154
|
const extracted = extractTelemetry(format, content);
|
|
107
155
|
if (!extracted) return;
|
|
108
|
-
this._sendReport(remoteId, extracted);
|
|
156
|
+
this._sendReport(remoteId, extracted, void 0, void 0, messageInfo);
|
|
109
157
|
}
|
|
110
|
-
_sendReport(remoteId, data, durationMs, stepTimestamps) {
|
|
158
|
+
_sendReport(remoteId, data, durationMs, stepTimestamps, messageInfo, persistence = this._persistence) {
|
|
111
159
|
const mergedSteps = mergeStepTimestamps(data.steps, stepTimestamps);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
160
|
+
const messageId = messageInfo?.localMessageId ? persistence.getResolvedRemoteId(messageInfo.localMessageId) : void 0;
|
|
161
|
+
this.runReporter.report({
|
|
162
|
+
threadId: remoteId,
|
|
163
|
+
status: messageInfo?.status ?? data.status,
|
|
164
|
+
outcome: messageInfo?.outcomeType,
|
|
165
|
+
error: messageInfo?.error,
|
|
166
|
+
errorCode: messageInfo?.errorCode,
|
|
167
|
+
messageId,
|
|
168
|
+
traceId: messageInfo?.traceId,
|
|
169
|
+
modelId: data.modelId,
|
|
170
|
+
provider: messageInfo?.provider,
|
|
171
|
+
usage: data.usage,
|
|
172
|
+
steps: mergedSteps,
|
|
173
|
+
totalSteps: data.totalSteps,
|
|
174
|
+
toolCalls: data.toolCalls,
|
|
175
|
+
durationMs,
|
|
176
|
+
firstTokenMs: messageInfo?.firstTokenMs,
|
|
177
|
+
outputText: data.outputText,
|
|
178
|
+
metadata: data.metadata
|
|
179
|
+
});
|
|
131
180
|
}
|
|
132
181
|
};
|
|
133
182
|
function mergeStepTimestamps(steps, timestamps) {
|
|
134
183
|
if (!timestamps) return steps;
|
|
135
|
-
if (!steps) return timestamps.map((
|
|
184
|
+
if (!steps) return timestamps.map(({ start_ms, end_ms }) => ({
|
|
185
|
+
startMs: start_ms,
|
|
186
|
+
endMs: end_ms
|
|
187
|
+
}));
|
|
136
188
|
const len = Math.min(steps.length, timestamps.length);
|
|
137
|
-
return steps.map((
|
|
138
|
-
...
|
|
139
|
-
...
|
|
189
|
+
return steps.map((step, index) => ({
|
|
190
|
+
...step,
|
|
191
|
+
...index < len ? {
|
|
192
|
+
startMs: timestamps[index].start_ms,
|
|
193
|
+
endMs: timestamps[index].end_ms
|
|
194
|
+
} : void 0
|
|
140
195
|
}));
|
|
141
196
|
}
|
|
197
|
+
function extractLastRunMessageInfo(items, formatAdapter) {
|
|
198
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
199
|
+
const item = items[i];
|
|
200
|
+
const info = extractRunMessageInfo(item.message, formatAdapter.format, formatAdapter.getId(item.message));
|
|
201
|
+
if (info) return info;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function mergeRunMessageInfo(stored, observed) {
|
|
205
|
+
if (!observed) return stored;
|
|
206
|
+
const { localMessageId: _observedId, ...outcome } = observed;
|
|
207
|
+
return {
|
|
208
|
+
...stored,
|
|
209
|
+
...outcome
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function extractRunMessageInfo(message, format, localMessageId) {
|
|
213
|
+
if (!isRecord(message) || message.role !== "assistant") return void 0;
|
|
214
|
+
const status = isRecord(message.status) ? message.status : void 0;
|
|
215
|
+
const metadata = isRecord(message.metadata) ? message.metadata : void 0;
|
|
216
|
+
const custom = isRecord(metadata?.custom) ? metadata.custom : void 0;
|
|
217
|
+
const firstTokenTime = (isRecord(metadata?.timing) ? metadata.timing : void 0)?.firstTokenTime;
|
|
218
|
+
const firstTokenMs = typeof firstTokenTime === "number" && Number.isFinite(firstTokenTime) ? Math.round(firstTokenTime) : void 0;
|
|
219
|
+
const finishReason = status?.type === "incomplete" ? typeof status.reason === "string" ? status.reason : void 0 : typeof metadata?.finishReason === "string" ? metadata.finishReason : void 0;
|
|
220
|
+
const failed = status?.type === "incomplete" && status.reason === "error";
|
|
221
|
+
const outcome = deriveRunOutcome({
|
|
222
|
+
finishReason,
|
|
223
|
+
isError: failed
|
|
224
|
+
});
|
|
225
|
+
const outcomeType = outcome.outcome;
|
|
226
|
+
const runStatus = outcome.status === "error" ? "error" : status?.type === "incomplete" ? "incomplete" : finishReason !== void 0 ? outcome.status : void 0;
|
|
227
|
+
const failure = failed ? describeRunError(status.error) : {};
|
|
228
|
+
const messageId = localMessageId ?? (typeof message.id === "string" ? message.id : void 0);
|
|
229
|
+
const traceId = format === "aui/v0" ? custom?.traceId : format === "ai-sdk/v6" ? metadata?.traceId : void 0;
|
|
230
|
+
const provider = typeof custom?.provider === "string" ? custom.provider : typeof metadata?.provider === "string" ? metadata.provider : void 0;
|
|
231
|
+
return {
|
|
232
|
+
...messageId ? { localMessageId: messageId } : void 0,
|
|
233
|
+
...runStatus !== void 0 ? { status: runStatus } : void 0,
|
|
234
|
+
...outcomeType ? { outcomeType } : void 0,
|
|
235
|
+
...failure,
|
|
236
|
+
...firstTokenMs != null && firstTokenMs >= 0 ? { firstTokenMs } : void 0,
|
|
237
|
+
...typeof traceId === "string" ? { traceId } : void 0,
|
|
238
|
+
...provider !== void 0 ? { provider } : void 0
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function isRecord(value) {
|
|
242
|
+
return value !== null && typeof value === "object";
|
|
243
|
+
}
|
|
142
244
|
function extractTelemetry(format, content) {
|
|
143
245
|
switch (format) {
|
|
144
246
|
case "aui/v0": return extractAuiV0(content);
|
|
145
|
-
case "ai-sdk/v6": return
|
|
247
|
+
case "ai-sdk/v6": return extractAISDKRunTelemetry([content]);
|
|
146
248
|
default: return null;
|
|
147
249
|
}
|
|
148
250
|
}
|
|
149
251
|
function extractRunTelemetry(format, runMessages) {
|
|
150
|
-
if (format === "ai-sdk/v6") return
|
|
252
|
+
if (format === "ai-sdk/v6") return extractAISDKRunTelemetry(runMessages);
|
|
151
253
|
for (let i = runMessages.length - 1; i >= 0; i--) {
|
|
152
254
|
const result = extractTelemetry(format, runMessages[i]);
|
|
153
255
|
if (result) return result;
|
|
154
256
|
}
|
|
155
257
|
return null;
|
|
156
258
|
}
|
|
157
|
-
const AUI_STATUS_MAP = {
|
|
158
|
-
error: "error",
|
|
159
|
-
incomplete: "incomplete"
|
|
160
|
-
};
|
|
161
259
|
function extractAuiV0(content) {
|
|
162
260
|
const msg = content;
|
|
163
261
|
if (msg.role !== "assistant") return null;
|
|
@@ -211,202 +309,26 @@ function extractAuiV0(content) {
|
|
|
211
309
|
reasoningTokens = hasReasoning ? totalReasoning : void 0;
|
|
212
310
|
cachedInputTokens = hasCachedInput ? totalCachedInput : void 0;
|
|
213
311
|
}
|
|
214
|
-
const
|
|
215
|
-
const status = statusType && AUI_STATUS_MAP[statusType] || "completed";
|
|
312
|
+
const status = msg.status?.type === "incomplete" ? "incomplete" : "completed";
|
|
216
313
|
const metadata = msg.metadata?.custom;
|
|
217
|
-
const modelId =
|
|
218
|
-
const telemetrySteps = steps && steps.length >
|
|
219
|
-
const usage = s.usage ? normalizeRunTelemetryUsage(s.usage) : void 0;
|
|
220
|
-
return {
|
|
221
|
-
...usage?.inputTokens != null ? { input_tokens: usage.inputTokens } : void 0,
|
|
222
|
-
...usage?.outputTokens != null ? { output_tokens: usage.outputTokens } : void 0,
|
|
223
|
-
...usage?.reasoningTokens != null ? { reasoning_tokens: usage.reasoningTokens } : void 0,
|
|
224
|
-
...usage?.cachedInputTokens != null ? { cached_input_tokens: usage.cachedInputTokens } : void 0
|
|
225
|
-
};
|
|
226
|
-
}) : void 0;
|
|
314
|
+
const modelId = extractRunTelemetryModelId(msg.metadata);
|
|
315
|
+
const telemetrySteps = steps && steps.length > 0 ? steps.map((step) => step.usage ? { usage: step.usage } : {}) : void 0;
|
|
227
316
|
return {
|
|
228
317
|
status,
|
|
229
318
|
...toolCalls && toolCalls.length > 0 ? { toolCalls } : void 0,
|
|
230
319
|
...steps?.length ? { totalSteps: steps.length } : void 0,
|
|
231
|
-
...inputTokens != null ? {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
320
|
+
...inputTokens != null || outputTokens != null || reasoningTokens != null || cachedInputTokens != null ? { usage: {
|
|
321
|
+
...inputTokens != null ? { inputTokens } : void 0,
|
|
322
|
+
...outputTokens != null ? { outputTokens } : void 0,
|
|
323
|
+
...reasoningTokens != null ? { reasoningTokens } : void 0,
|
|
324
|
+
...cachedInputTokens != null ? { cachedInputTokens } : void 0
|
|
325
|
+
} } : void 0,
|
|
235
326
|
...outputText != null ? { outputText } : void 0,
|
|
236
327
|
...metadata ? { metadata } : void 0,
|
|
237
328
|
...telemetrySteps ? { steps: telemetrySteps } : void 0,
|
|
238
329
|
...modelId ? { modelId } : void 0
|
|
239
330
|
};
|
|
240
331
|
}
|
|
241
|
-
function isToolCallPart(p) {
|
|
242
|
-
if (!p.toolCallId) return false;
|
|
243
|
-
if (p.type === "tool-call" || p.type === "dynamic-tool") return !!p.toolName;
|
|
244
|
-
return p.type.startsWith("tool-") || p.type.startsWith("dynamic-tool-");
|
|
245
|
-
}
|
|
246
|
-
function isDynamicToolPart(p) {
|
|
247
|
-
return p.type === "dynamic-tool" || p.type.startsWith("dynamic-tool-");
|
|
248
|
-
}
|
|
249
|
-
function partToToolCall(p) {
|
|
250
|
-
const toolSource = isDynamicToolPart(p) ? "mcp" : "frontend";
|
|
251
|
-
return createRunTelemetryToolCall({
|
|
252
|
-
toolName: p.toolName ?? p.type.slice(5),
|
|
253
|
-
toolCallId: p.toolCallId,
|
|
254
|
-
args: p.args ?? p.input,
|
|
255
|
-
result: p.result ?? p.output,
|
|
256
|
-
toolSource
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
function collectAiSdkV6Parts(parts) {
|
|
260
|
-
const textParts = [];
|
|
261
|
-
const toolCalls = [];
|
|
262
|
-
const stepsData = [];
|
|
263
|
-
let currentStepToolCalls = null;
|
|
264
|
-
for (const p of parts) if (p.type === "step-start") {
|
|
265
|
-
if (currentStepToolCalls !== null) stepsData.push({ tool_calls: currentStepToolCalls });
|
|
266
|
-
currentStepToolCalls = [];
|
|
267
|
-
} else if (p.type === "text" && p.text) textParts.push(p.text);
|
|
268
|
-
else if (isToolCallPart(p)) {
|
|
269
|
-
const tc = partToToolCall(p);
|
|
270
|
-
toolCalls.push(tc);
|
|
271
|
-
if (currentStepToolCalls !== null) currentStepToolCalls.push(tc);
|
|
272
|
-
}
|
|
273
|
-
if (currentStepToolCalls !== null) stepsData.push({ tool_calls: currentStepToolCalls });
|
|
274
|
-
return {
|
|
275
|
-
textParts,
|
|
276
|
-
toolCalls,
|
|
277
|
-
stepsData
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
function extractModelId(metadata) {
|
|
281
|
-
if (!metadata) return void 0;
|
|
282
|
-
if (typeof metadata.modelId === "string") return metadata.modelId;
|
|
283
|
-
const custom = metadata.custom;
|
|
284
|
-
if (typeof custom?.modelId === "string") return custom.modelId;
|
|
285
|
-
}
|
|
286
|
-
function buildAiSdkV6Result(textParts, toolCalls, totalSteps, metadata, stepsData, usage) {
|
|
287
|
-
const hasText = textParts.length > 0;
|
|
288
|
-
const outputText = hasText ? truncateRunTelemetryText(textParts.join("")) : void 0;
|
|
289
|
-
const modelId = extractModelId(metadata);
|
|
290
|
-
const steps = stepsData && stepsData.length > 1 ? stepsData.map((s) => ({ ...s.tool_calls.length > 0 ? { tool_calls: s.tool_calls } : void 0 })) : void 0;
|
|
291
|
-
return {
|
|
292
|
-
status: hasText ? "completed" : "incomplete",
|
|
293
|
-
...toolCalls.length > 0 ? { toolCalls } : void 0,
|
|
294
|
-
...totalSteps > 0 ? { totalSteps } : void 0,
|
|
295
|
-
...usage?.inputTokens != null ? { inputTokens: usage.inputTokens } : void 0,
|
|
296
|
-
...usage?.outputTokens != null ? { outputTokens: usage.outputTokens } : void 0,
|
|
297
|
-
...usage?.reasoningTokens != null ? { reasoningTokens: usage.reasoningTokens } : void 0,
|
|
298
|
-
...usage?.cachedInputTokens != null ? { cachedInputTokens: usage.cachedInputTokens } : void 0,
|
|
299
|
-
...outputText != null ? { outputText } : void 0,
|
|
300
|
-
...metadata ? { metadata } : void 0,
|
|
301
|
-
...steps ? { steps } : void 0,
|
|
302
|
-
...modelId ? { modelId } : void 0
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
function extractAiSdkV6Usage(metadata) {
|
|
306
|
-
const usage = metadata?.usage;
|
|
307
|
-
if (usage) {
|
|
308
|
-
const normalized = normalizeRunTelemetryUsage(usage);
|
|
309
|
-
if (normalized) return normalized;
|
|
310
|
-
}
|
|
311
|
-
const steps = metadata?.steps;
|
|
312
|
-
if (steps && steps.length > 0) {
|
|
313
|
-
let inputTokens = 0;
|
|
314
|
-
let outputTokens = 0;
|
|
315
|
-
let reasoningTokens = 0;
|
|
316
|
-
let cachedInputTokens = 0;
|
|
317
|
-
let hasInput = false;
|
|
318
|
-
let hasOutput = false;
|
|
319
|
-
let hasReasoning = false;
|
|
320
|
-
let hasCachedInput = false;
|
|
321
|
-
let hasAny = false;
|
|
322
|
-
for (const s of steps) {
|
|
323
|
-
if (!s.usage) continue;
|
|
324
|
-
const n = normalizeRunTelemetryUsage(s.usage);
|
|
325
|
-
if (n) {
|
|
326
|
-
if (n.inputTokens != null) {
|
|
327
|
-
inputTokens += n.inputTokens;
|
|
328
|
-
hasInput = true;
|
|
329
|
-
}
|
|
330
|
-
if (n.outputTokens != null) {
|
|
331
|
-
outputTokens += n.outputTokens;
|
|
332
|
-
hasOutput = true;
|
|
333
|
-
}
|
|
334
|
-
if (n.reasoningTokens != null) {
|
|
335
|
-
reasoningTokens += n.reasoningTokens;
|
|
336
|
-
hasReasoning = true;
|
|
337
|
-
}
|
|
338
|
-
if (n.cachedInputTokens != null) {
|
|
339
|
-
cachedInputTokens += n.cachedInputTokens;
|
|
340
|
-
hasCachedInput = true;
|
|
341
|
-
}
|
|
342
|
-
hasAny = true;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (hasAny) return {
|
|
346
|
-
...hasInput ? { inputTokens } : void 0,
|
|
347
|
-
...hasOutput ? { outputTokens } : void 0,
|
|
348
|
-
...hasReasoning ? { reasoningTokens } : void 0,
|
|
349
|
-
...hasCachedInput ? { cachedInputTokens } : void 0
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
function extractAiSdkV6(content) {
|
|
354
|
-
const msg = content;
|
|
355
|
-
if (msg.role !== "assistant") return null;
|
|
356
|
-
const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(msg.parts ?? []);
|
|
357
|
-
return buildAiSdkV6Result(textParts, toolCalls, stepsData.length, msg.metadata, stepsData, extractAiSdkV6Usage(msg.metadata));
|
|
358
|
-
}
|
|
359
|
-
function aggregateAiSdkV6RunSteps(stepMessages) {
|
|
360
|
-
const allTextParts = [];
|
|
361
|
-
const allToolCalls = [];
|
|
362
|
-
const allStepsData = [];
|
|
363
|
-
let hasAssistant = false;
|
|
364
|
-
let metadata;
|
|
365
|
-
let inputTokens = 0;
|
|
366
|
-
let outputTokens = 0;
|
|
367
|
-
let reasoningTokens = 0;
|
|
368
|
-
let cachedInputTokens = 0;
|
|
369
|
-
let hasInput = false;
|
|
370
|
-
let hasOutput = false;
|
|
371
|
-
let hasReasoning = false;
|
|
372
|
-
let hasCachedInput = false;
|
|
373
|
-
for (const content of stepMessages) {
|
|
374
|
-
const msg = content;
|
|
375
|
-
if (msg.role !== "assistant") continue;
|
|
376
|
-
hasAssistant = true;
|
|
377
|
-
const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(msg.parts ?? []);
|
|
378
|
-
allTextParts.push(...textParts);
|
|
379
|
-
allToolCalls.push(...toolCalls);
|
|
380
|
-
allStepsData.push(...stepsData);
|
|
381
|
-
if (msg.metadata) metadata = msg.metadata;
|
|
382
|
-
const usage = extractAiSdkV6Usage(msg.metadata);
|
|
383
|
-
if (usage) {
|
|
384
|
-
if (usage.inputTokens != null) {
|
|
385
|
-
inputTokens += usage.inputTokens;
|
|
386
|
-
hasInput = true;
|
|
387
|
-
}
|
|
388
|
-
if (usage.outputTokens != null) {
|
|
389
|
-
outputTokens += usage.outputTokens;
|
|
390
|
-
hasOutput = true;
|
|
391
|
-
}
|
|
392
|
-
if (usage.reasoningTokens != null) {
|
|
393
|
-
reasoningTokens += usage.reasoningTokens;
|
|
394
|
-
hasReasoning = true;
|
|
395
|
-
}
|
|
396
|
-
if (usage.cachedInputTokens != null) {
|
|
397
|
-
cachedInputTokens += usage.cachedInputTokens;
|
|
398
|
-
hasCachedInput = true;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (!hasAssistant) return null;
|
|
403
|
-
return buildAiSdkV6Result(allTextParts, allToolCalls, allStepsData.length, metadata, allStepsData, {
|
|
404
|
-
...hasInput ? { inputTokens } : void 0,
|
|
405
|
-
...hasOutput ? { outputTokens } : void 0,
|
|
406
|
-
...hasReasoning ? { reasoningTokens } : void 0,
|
|
407
|
-
...hasCachedInput ? { cachedInputTokens } : void 0
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
332
|
function useAssistantCloudThreadHistoryAdapter(cloudRef) {
|
|
411
333
|
const aui = useAui();
|
|
412
334
|
const auiRef = useRef(aui);
|
|
@@ -414,8 +336,214 @@ function useAssistantCloudThreadHistoryAdapter(cloudRef) {
|
|
|
414
336
|
auiRef.current = aui;
|
|
415
337
|
});
|
|
416
338
|
const [adapter] = useState(() => new AssistantCloudThreadHistoryAdapter(cloudRef, () => auiRef.current));
|
|
339
|
+
useAssistantCloudEngagementEvents(adapter, aui);
|
|
417
340
|
return adapter;
|
|
418
341
|
}
|
|
342
|
+
const rootEngagementTrackers = /* @__PURE__ */ new WeakMap();
|
|
343
|
+
/**
|
|
344
|
+
* Thread switches are a thread list event, so one subscription per assistant
|
|
345
|
+
* client reports them; every thread runtime mounted under it shares the
|
|
346
|
+
* subscription and the last one to unmount removes it.
|
|
347
|
+
*/
|
|
348
|
+
const useRootEngagementEvents = (adapter, aui) => {
|
|
349
|
+
const $ = c(6);
|
|
350
|
+
let t0;
|
|
351
|
+
if ($[0] !== adapter.engagementReporter || $[1] !== aui) {
|
|
352
|
+
t0 = () => {
|
|
353
|
+
let tracker = rootEngagementTrackers.get(aui);
|
|
354
|
+
if (!tracker) {
|
|
355
|
+
const created = {
|
|
356
|
+
count: 0,
|
|
357
|
+
engagementReporter: adapter.engagementReporter,
|
|
358
|
+
dispose: _temp
|
|
359
|
+
};
|
|
360
|
+
created.dispose = aui.on({
|
|
361
|
+
scope: "*",
|
|
362
|
+
event: "threads.selectionChanged"
|
|
363
|
+
}, (payload) => {
|
|
364
|
+
created.engagementReporter.threadSwitched(payload.threadId);
|
|
365
|
+
});
|
|
366
|
+
rootEngagementTrackers.set(aui, created);
|
|
367
|
+
tracker = created;
|
|
368
|
+
}
|
|
369
|
+
const active = tracker;
|
|
370
|
+
active.engagementReporter = adapter.engagementReporter;
|
|
371
|
+
active.count = active.count + 1;
|
|
372
|
+
return () => {
|
|
373
|
+
active.count = active.count - 1;
|
|
374
|
+
if (active.count === 0) {
|
|
375
|
+
active.dispose();
|
|
376
|
+
rootEngagementTrackers.delete(aui);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
$[0] = adapter.engagementReporter;
|
|
381
|
+
$[1] = aui;
|
|
382
|
+
$[2] = t0;
|
|
383
|
+
} else t0 = $[2];
|
|
384
|
+
let t1;
|
|
385
|
+
if ($[3] !== adapter || $[4] !== aui) {
|
|
386
|
+
t1 = [adapter, aui];
|
|
387
|
+
$[3] = adapter;
|
|
388
|
+
$[4] = aui;
|
|
389
|
+
$[5] = t1;
|
|
390
|
+
} else t1 = $[5];
|
|
391
|
+
useEffect(t0, t1);
|
|
392
|
+
};
|
|
393
|
+
const useAssistantCloudEngagementEvents = (adapter, aui) => {
|
|
394
|
+
const $ = c(12);
|
|
395
|
+
useRootEngagementEvents(adapter, aui);
|
|
396
|
+
let t0;
|
|
397
|
+
if ($[0] !== adapter.engagementReporter || $[1] !== aui) {
|
|
398
|
+
t0 = () => {
|
|
399
|
+
const reporter = adapter.engagementReporter;
|
|
400
|
+
const unsubscribers = [
|
|
401
|
+
aui.on({
|
|
402
|
+
scope: "thread",
|
|
403
|
+
event: "composer.send"
|
|
404
|
+
}, (payload) => {
|
|
405
|
+
if (payload.messageId) reporter.messageEdited(payload.threadId, {
|
|
406
|
+
messageId: payload.messageId,
|
|
407
|
+
chars: payload.chars
|
|
408
|
+
});
|
|
409
|
+
else reporter.messageSent(payload.threadId, {
|
|
410
|
+
chars: payload.chars,
|
|
411
|
+
attachments: payload.attachments
|
|
412
|
+
});
|
|
413
|
+
if (payload.suggestion) reporter.suggestionClicked(payload.threadId);
|
|
414
|
+
}),
|
|
415
|
+
aui.on({
|
|
416
|
+
scope: "thread",
|
|
417
|
+
event: "composer.attachmentAdd"
|
|
418
|
+
}, (payload_0) => {
|
|
419
|
+
reporter.attachmentAdded(payload_0.threadId, {
|
|
420
|
+
messageId: payload_0.messageId,
|
|
421
|
+
contentType: payload_0.contentType
|
|
422
|
+
});
|
|
423
|
+
}),
|
|
424
|
+
aui.on({
|
|
425
|
+
scope: "thread",
|
|
426
|
+
event: "composer.attachmentAddError"
|
|
427
|
+
}, (payload_1) => {
|
|
428
|
+
reporter.attachmentFailed(payload_1.threadId, {
|
|
429
|
+
messageId: payload_1.messageId,
|
|
430
|
+
contentType: payload_1.contentType
|
|
431
|
+
});
|
|
432
|
+
}),
|
|
433
|
+
aui.on({
|
|
434
|
+
scope: "thread",
|
|
435
|
+
event: "composer.cancel"
|
|
436
|
+
}, (payload_2) => {
|
|
437
|
+
reporter.runStopped(payload_2.threadId);
|
|
438
|
+
}),
|
|
439
|
+
aui.on({
|
|
440
|
+
scope: "thread",
|
|
441
|
+
event: "thread.runStart"
|
|
442
|
+
}, (payload_3) => {
|
|
443
|
+
reporter.runStarted(payload_3.threadId);
|
|
444
|
+
}),
|
|
445
|
+
aui.on({
|
|
446
|
+
scope: "thread",
|
|
447
|
+
event: "thread.runEnd"
|
|
448
|
+
}, (payload_4) => {
|
|
449
|
+
reporter.runEnded(payload_4.threadId);
|
|
450
|
+
}),
|
|
451
|
+
aui.on({
|
|
452
|
+
scope: "thread",
|
|
453
|
+
event: "thread.cancelRun"
|
|
454
|
+
}, (payload_5) => {
|
|
455
|
+
reporter.runStopped(payload_5.threadId);
|
|
456
|
+
}),
|
|
457
|
+
aui.on({
|
|
458
|
+
scope: "thread",
|
|
459
|
+
event: "thread.voiceStarted"
|
|
460
|
+
}, (payload_6) => {
|
|
461
|
+
reporter.voiceStarted(payload_6.threadId);
|
|
462
|
+
}),
|
|
463
|
+
aui.on({
|
|
464
|
+
scope: "thread",
|
|
465
|
+
event: "message.reload"
|
|
466
|
+
}, (payload_7) => {
|
|
467
|
+
reporter.messageRegenerated(payload_7.threadId, payload_7.messageId);
|
|
468
|
+
}),
|
|
469
|
+
aui.on({
|
|
470
|
+
scope: "thread",
|
|
471
|
+
event: "message.branchSwitched"
|
|
472
|
+
}, (payload_8) => {
|
|
473
|
+
reporter.branchSwitched(payload_8.threadId, payload_8.messageId);
|
|
474
|
+
}),
|
|
475
|
+
aui.on({
|
|
476
|
+
scope: "thread",
|
|
477
|
+
event: "message.copied"
|
|
478
|
+
}, (payload_9) => {
|
|
479
|
+
reporter.messageCopied(payload_9.threadId, payload_9.messageId);
|
|
480
|
+
}),
|
|
481
|
+
aui.on({
|
|
482
|
+
scope: "thread",
|
|
483
|
+
event: "thread.toolApprovalAnswered"
|
|
484
|
+
}, (payload_10) => {
|
|
485
|
+
if (payload_10.approved) reporter.toolApproved(payload_10.threadId, payload_10.messageId, payload_10.toolCallId, payload_10.toolName);
|
|
486
|
+
else reporter.toolRejected(payload_10.threadId, payload_10.messageId, payload_10.toolCallId, payload_10.toolName);
|
|
487
|
+
}),
|
|
488
|
+
aui.on({
|
|
489
|
+
scope: "thread",
|
|
490
|
+
event: "message.speak"
|
|
491
|
+
}, (payload_11) => {
|
|
492
|
+
reporter.speechStarted(payload_11.threadId, payload_11.messageId);
|
|
493
|
+
}),
|
|
494
|
+
aui.on({
|
|
495
|
+
scope: "thread",
|
|
496
|
+
event: "message.error"
|
|
497
|
+
}, (payload_12) => {
|
|
498
|
+
reporter.errorShown(payload_12.threadId, {
|
|
499
|
+
messageId: payload_12.messageId,
|
|
500
|
+
reason: payload_12.reason
|
|
501
|
+
});
|
|
502
|
+
})
|
|
503
|
+
];
|
|
504
|
+
return () => {
|
|
505
|
+
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
$[0] = adapter.engagementReporter;
|
|
509
|
+
$[1] = aui;
|
|
510
|
+
$[2] = t0;
|
|
511
|
+
} else t0 = $[2];
|
|
512
|
+
let t1;
|
|
513
|
+
if ($[3] !== adapter || $[4] !== aui) {
|
|
514
|
+
t1 = [adapter, aui];
|
|
515
|
+
$[3] = adapter;
|
|
516
|
+
$[4] = aui;
|
|
517
|
+
$[5] = t1;
|
|
518
|
+
} else t1 = $[5];
|
|
519
|
+
useEffect(t0, t1);
|
|
520
|
+
let t2;
|
|
521
|
+
if ($[6] !== adapter.engagementReporter || $[7] !== aui) {
|
|
522
|
+
t2 = () => {
|
|
523
|
+
const reportSuggestions = () => {
|
|
524
|
+
const { mainThreadId } = aui.threads.getState();
|
|
525
|
+
if (aui.threadListItem.getState().id !== mainThreadId) return;
|
|
526
|
+
const { isEmpty, suggestions } = aui.thread.getState();
|
|
527
|
+
if (!isEmpty || suggestions.length === 0) return;
|
|
528
|
+
adapter.engagementReporter.suggestionsShown(mainThreadId, suggestions.length);
|
|
529
|
+
};
|
|
530
|
+
reportSuggestions();
|
|
531
|
+
return aui.subscribe(reportSuggestions);
|
|
532
|
+
};
|
|
533
|
+
$[6] = adapter.engagementReporter;
|
|
534
|
+
$[7] = aui;
|
|
535
|
+
$[8] = t2;
|
|
536
|
+
} else t2 = $[8];
|
|
537
|
+
let t3;
|
|
538
|
+
if ($[9] !== adapter || $[10] !== aui) {
|
|
539
|
+
t3 = [adapter, aui];
|
|
540
|
+
$[9] = adapter;
|
|
541
|
+
$[10] = aui;
|
|
542
|
+
$[11] = t3;
|
|
543
|
+
} else t3 = $[11];
|
|
544
|
+
useEffect(t2, t3);
|
|
545
|
+
};
|
|
546
|
+
function _temp() {}
|
|
419
547
|
//#endregion
|
|
420
548
|
export { extractAuiV0, useAssistantCloudThreadHistoryAdapter };
|
|
421
549
|
|