@assistant-ui/core 0.3.18 → 0.3.20
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 +9 -10
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/attachment.js +2 -1
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/adapters/directive-formatter.d.ts +1 -2
- package/dist/adapters/directive-formatter.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +2 -2
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/speech.d.ts +6 -7
- 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/suggestion.d.ts +5 -6
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +10 -7
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/trigger.d.ts +1 -2
- package/dist/adapters/trigger.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts +5 -6
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.d.ts +1 -2
- package/dist/internal/duplicate-detection.d.ts.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/model-context/frame/host.d.ts +1 -2
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +26 -11
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +1 -2
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/types.d.ts +5 -6
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.d.ts +9 -10
- package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js +11 -9
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry-handles.d.ts +3 -4
- package/dist/model-context/registry-handles.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +1 -2
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/tool-call-text.d.ts +2 -3
- package/dist/model-context/tool-call-text.d.ts.map +1 -1
- package/dist/model-context/tool.d.ts +2 -3
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +8 -9
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantProvider.d.ts +3 -4
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +1 -2
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +2 -3
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +4 -5
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +43 -19
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -3
- package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +1 -2
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -2
- 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 +3 -4
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/Interactables.d.ts +1 -2
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +11 -5
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +2 -3
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +3 -2
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/client/Tools.d.ts +2 -2
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts +2 -3
- 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.d.ts +1 -2
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/interactable-model-context.d.ts +2 -3
- package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
- package/dist/react/interactables-legacy/scopes.d.ts +9 -10
- package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
- package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +2 -3
- 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-legacy/useInteractableState.d.ts +1 -2
- package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +1 -2
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.d.ts +4 -5
- package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/define-toolkit.d.ts +2 -3
- package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
- package/dist/react/model-context/external-tool.d.ts +1 -2
- package/dist/react/model-context/external-tool.d.ts.map +1 -1
- package/dist/react/model-context/human-tool.d.ts +3 -4
- package/dist/react/model-context/human-tool.d.ts.map +1 -1
- package/dist/react/model-context/interactableTool.d.ts +3 -4
- package/dist/react/model-context/interactableTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.d.ts +2 -3
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantTool.d.ts +2 -3
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.d.ts +2 -3
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/provider-tool.d.ts +2 -3
- package/dist/react/model-context/provider-tool.d.ts.map +1 -1
- package/dist/react/model-context/stub-tool.d.ts +1 -2
- package/dist/react/model-context/stub-tool.d.ts.map +1 -1
- package/dist/react/model-context/toolbox.d.ts +9 -10
- package/dist/react/model-context/toolbox.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantContext.d.ts +2 -2
- package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.d.ts +2 -3
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.d.ts +2 -2
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +2 -3
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.d.ts +2 -3
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.d.ts +1 -2
- package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +1 -2
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.d.ts +4 -5
- 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/useInteractableState.d.ts +1 -2
- package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.d.ts +1 -2
- package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
- package/dist/react/model-context/useInteractableVersions.js +1 -1
- package/dist/react/model-context/useToolArgsStatus.d.ts +2 -3
- package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts +2 -3
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts +1 -2
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +2 -3
- package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts +1 -2
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +1 -2
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +1 -2
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +1 -2
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +1 -2
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +1 -2
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts +1 -2
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +1 -2
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts +1 -2
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -2
- package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts +1 -2
- package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.d.ts +1 -2
- package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.d.ts +1 -2
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.d.ts +1 -2
- package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +2 -3
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -2
- package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useVoice.d.ts +3 -4
- package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +2 -3
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +4 -5
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.d.ts +4 -5
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -3
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +4 -5
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +27 -28
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +4 -5
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +13 -5
- 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/message/MessageParts.d.ts +10 -10
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +2 -3
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -3
- package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/react/primitives/part/PartMessages.d.ts +4 -4
- 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 +7 -8
- 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/primitives/thread/ThreadSuggestions.d.ts +5 -6
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +4 -5
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +2 -3
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +2 -3
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +1 -2
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +1 -2
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIdProvider.d.ts +1 -2
- package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.d.ts +1 -2
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts +1 -2
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -3
- package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +2 -3
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +2 -3
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts +1 -2
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +1 -2
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +1 -2
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +3 -2
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +17 -7
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +1 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +2 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +4 -5
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +3 -3
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +2 -3
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +3 -4
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts +2 -3
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/types.d.ts +17 -18
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +4 -5
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +1 -2
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -2
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +3 -26
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +152 -378
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +2 -2
- 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 +51 -18
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +125 -17
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +6 -6
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +4 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +1 -2
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts +5 -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/cloud/useCloudThreadListAdapter.d.ts +1 -2
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +1 -2
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +1 -2
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +3 -4
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +14 -4
- 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.d.ts +1 -2
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +1 -2
- package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +3 -4
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +1 -2
- package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +3 -3
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +4 -4
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
- package/dist/react/runtimes/useStreamingTiming.d.ts +2 -2
- package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +26 -27
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +3 -4
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
- package/dist/react/types/scopes/interactables.d.ts +10 -11
- package/dist/react/types/scopes/interactables.d.ts.map +1 -1
- package/dist/react/types/scopes/tools.d.ts +4 -5
- package/dist/react/types/scopes/tools.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +1 -2
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +13 -9
- 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 -2
- 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 +6 -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/assistant-runtime.d.ts +2 -3
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +6 -7
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/bindings.d.ts +5 -6
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +10 -10
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +3 -4
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +3 -2
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +8 -6
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +3 -2
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/paths.d.ts +6 -7
- package/dist/runtime/api/paths.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +8 -8
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +4 -5
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +10 -11
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +2 -5
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +1 -2
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +46 -10
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +10 -3
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +212 -77
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +12 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +7 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +1 -2
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +1 -2
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +10 -11
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +4 -5
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +23 -16
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +2 -3
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.d.ts +10 -4
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +70 -7
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/queue/queue-item.d.ts +2 -3
- package/dist/runtime/queue/queue-item.d.ts.map +1 -1
- package/dist/runtime/utils/abortable-thread-load.d.ts +2 -3
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
- package/dist/runtime/utils/attachment-add-operations.d.ts +3 -4
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.d.ts +9 -6
- 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/chat-model-adapter.d.ts +5 -6
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +26 -15
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +51 -14
- package/dist/runtime/utils/external-message-conversion.js.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +4 -5
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +3 -4
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +4 -5
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +3 -3
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +2 -3
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +1 -2
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +2 -3
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
- package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
- package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
- package/dist/runtime/utils/stored-message-parts.js +83 -0
- package/dist/runtime/utils/stored-message-parts.js.map +1 -0
- package/dist/runtime/utils/streaming-timing.d.ts +4 -5
- package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +7 -6
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +4 -2
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +3 -4
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
- package/dist/runtime/utils/tool-call-tree.d.ts +4 -5
- package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
- package/dist/runtimes/assistant-transport/utils.d.ts +1 -2
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +9 -6
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts +1 -2
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.d.ts +2 -3
- package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +2 -3
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -3
- 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 +36 -6
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +2 -3
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +2 -3
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/internal.d.ts +1 -1
- package/dist/runtimes/local/local-runtime-core.d.ts +1 -2
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +1 -2
- package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +2 -3
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +10 -5
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +57 -10
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +1 -2
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -2
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +1 -2
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +16 -17
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title-generation.d.ts +7 -8
- package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/title.d.ts +2 -3
- package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +8 -9
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +4 -5
- 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/chain-of-thought-client.d.ts +1 -2
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/external-thread.d.ts +3 -4
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +256 -211
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -2
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +1 -2
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -2
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts +1 -2
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/suggestions.d.ts +3 -4
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +2 -3
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-selection-events.d.ts +1 -2
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
- package/dist/store/clients/thread-tasks.d.ts +12 -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/env.d.ts +1 -2
- package/dist/store/env.d.ts.map +1 -1
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +3 -3
- package/dist/store/primitive-predicates.d.ts +11 -12
- 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/attachment-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -2
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -2
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +1 -2
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -2
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +176 -128
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.d.ts +1 -2
- package/dist/store/runtime-clients/useSubscribable.d.ts.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/attachment.d.ts +4 -5
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +5 -6
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +6 -7
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +6 -6
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +3 -4
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +4 -5
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.d.ts +4 -4
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/suggestion.d.ts +4 -5
- package/dist/store/scopes/suggestion.d.ts.map +1 -1
- package/dist/store/scopes/suggestions.d.ts +5 -6
- package/dist/store/scopes/suggestions.d.ts.map +1 -1
- package/dist/store/scopes/task.d.ts +35 -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 +5 -6
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +25 -6
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +4 -5
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +15 -15
- 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/tests/remote-thread-list-test-helpers.d.ts +5 -6
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
- package/dist/types/attachment.d.ts +9 -10
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/augmentations.d.ts +3 -4
- package/dist/types/augmentations.d.ts.map +1 -1
- package/dist/types/directive.d.ts +2 -3
- package/dist/types/directive.d.ts.map +1 -1
- package/dist/types/error.d.ts +8 -9
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/message.d.ts +53 -44
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/types/quote.d.ts +1 -2
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/trigger.d.ts +2 -3
- package/dist/types/trigger.d.ts.map +1 -1
- package/dist/types/unsubscribe.d.ts +1 -2
- package/dist/types/unsubscribe.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.d.ts +2 -3
- package/dist/utils/abortable-iterable.d.ts.map +1 -1
- package/dist/utils/abortable-iterable.js +30 -14
- package/dist/utils/abortable-iterable.js.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +1 -2
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/data-url.d.ts +6 -7
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/getGroupStatus.d.ts +17 -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/id.d.ts +3 -4
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/image-media-type.d.ts +1 -2
- package/dist/utils/image-media-type.d.ts.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +1 -2
- package/dist/utils/invoke-user-callback.d.ts.map +1 -1
- package/dist/utils/json/is-json-equal.d.ts +1 -2
- package/dist/utils/json/is-json-equal.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +4 -5
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/stable-stringify-tool-args.d.ts +2 -3
- package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
- package/dist/utils/normalizePartStatus.d.ts +4 -5
- package/dist/utils/normalizePartStatus.d.ts.map +1 -1
- package/dist/utils/notify-event-listeners.d.ts +1 -2
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/record.d.ts +1 -2
- package/dist/utils/record.d.ts.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +2 -3
- package/dist/utils/silent-runtime-action.d.ts.map +1 -1
- package/dist/utils/text.d.ts +1 -2
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/wire-media.d.ts +3 -4
- 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 +15 -14
- package/src/adapters/attachment.ts +8 -1
- package/src/adapters/feedback.ts +1 -0
- 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 +1 -0
- package/src/model-context/frame/host.test.ts +113 -1
- package/src/model-context/frame/host.ts +39 -12
- package/src/model-context/frame/provider.test.ts +45 -20
- package/src/model-context/interactable-composer-metadata.test.ts +30 -0
- package/src/model-context/interactable-composer-metadata.ts +10 -10
- package/src/react/RuntimeAdapter.test.ts +4 -1
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +361 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +69 -19
- package/src/react/client/DataRenderers.test.tsx +45 -0
- package/src/react/client/DataRenderers.ts +13 -9
- package/src/react/client/Interactables.test.ts +52 -4
- package/src/react/client/Interactables.ts +7 -1
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
- package/src/react/client/RemoteThreadList.test.ts +46 -7
- package/src/react/client/RemoteThreadList.ts +15 -2
- 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.test.ts +9 -3
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +150 -0
- package/src/react/interactables-legacy/useAssistantInteractable.ts +10 -1
- package/src/react/model-context/useInteractable.test.tsx +204 -0
- package/src/react/model-context/useInteractable.ts +3 -0
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -6
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +0 -1
- package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +54 -0
- package/src/react/primitives/generativeUI/GenerativeUI.tsx +13 -18
- package/src/react/primitives/message/MessageGroupedParts.test.tsx +99 -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 +160 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +8 -5
- package/src/react/providers/ReadonlyThreadProvider.test.tsx +56 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +23 -20
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +24 -17
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +39 -24
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +7 -1
- package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +66 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +20 -14
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +323 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +190 -523
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +81 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +27 -1
- package/src/react/runtimes/cloud/auiV0.ts +281 -26
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +522 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +21 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +7 -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 +143 -4
- package/src/react/runtimes/external-message-converter.ts +39 -93
- package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +8 -2
- package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
- package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
- package/src/react/runtimes/useRemoteThreadListRuntime.ts +6 -2
- 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-part-runtime.ts +4 -1
- package/src/runtime/api/message-runtime.ts +15 -2
- package/src/runtime/api/thread-runtime.test.ts +58 -0
- package/src/runtime/api/thread-runtime.ts +2 -4
- package/src/runtime/base/base-composer-runtime-core.ts +69 -16
- package/src/runtime/base/base-thread-runtime-core.test.ts +1799 -49
- package/src/runtime/base/base-thread-runtime-core.ts +296 -94
- package/src/runtime/base/default-edit-composer-runtime-core.ts +12 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +12 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +8 -0
- package/src/runtime/queue/message-queue.ts +79 -7
- 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 +177 -0
- package/src/runtime/utils/external-message-conversion.ts +128 -33
- package/src/runtime/utils/message-repository.test.ts +49 -0
- package/src/runtime/utils/message-repository.ts +3 -3
- package/src/runtime/utils/stored-message-parts.ts +174 -0
- package/src/runtime/utils/thread-message-like.test.ts +52 -0
- package/src/runtime/utils/thread-message-like.ts +11 -2
- package/src/runtimes/external-store/external-store-adapter.ts +4 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +74 -9
- package/src/runtimes/local/local-thread-runtime-core.test.ts +189 -12
- package/src/runtimes/local/local-thread-runtime-core.ts +91 -10
- 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 +53 -14
- 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 +64 -5
- package/src/store/primitive-predicates.ts +10 -2
- package/src/store/runtime-clients/thread-runtime-client.test.tsx +110 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +31 -1
- package/src/store/scope-registration.ts +2 -0
- package/src/store/scopes/message.ts +4 -1
- package/src/store/scopes/task.ts +34 -0
- package/src/store/scopes/thread.ts +16 -0
- package/src/store/thread-tasks.test.tsx +209 -0
- package/src/subscribable/subscribable.test.ts +161 -1
- package/src/subscribable/subscribable.ts +25 -15
- package/src/tests/MessageRepository.test.ts +1 -5
- package/src/tests/attachment-adapters.test.ts +16 -1
- package/src/tests/auiV0Encode.test.ts +304 -0
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
- package/src/tests/base-composer-runtime-core-send.test.ts +51 -0
- package/src/tests/base-composer-runtime-core.test.ts +329 -6
- package/src/tests/composer-can-cancel.test.ts +35 -6
- package/src/tests/composer-can-send.test.ts +22 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +47 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +369 -16
- package/src/tests/external-store-thread-runtime-core.test.ts +31 -0
- package/src/tests/external-thread-attachments.test.tsx +91 -23
- package/src/tests/external-thread-feedback.test.tsx +20 -7
- package/src/tests/external-thread-parity.test.tsx +35 -1
- package/src/tests/groupParts.test.ts +71 -0
- package/src/tests/message-queue.test.ts +290 -2
- package/src/tests/remote-thread-list-reactive-threadId.test.ts +51 -0
- package/src/tests/thread-switch-events.test.tsx +11 -7
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +45 -1
- package/src/types/index.ts +1 -0
- package/src/types/message.test.ts +19 -0
- package/src/types/message.ts +23 -7
- package/src/utils/abortable-iterable.test.ts +115 -0
- package/src/utils/abortable-iterable.ts +34 -23
- package/src/utils/getGroupStatus.test.ts +70 -4
- package/src/utils/getGroupStatus.ts +35 -12
- package/src/utils/wire-media.test.ts +10 -0
- package/src/utils/wire-media.ts +6 -2
|
@@ -7,25 +7,30 @@ import type {
|
|
|
7
7
|
MessageFormatRepository,
|
|
8
8
|
} from "../../../adapters/thread-history";
|
|
9
9
|
import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository";
|
|
10
|
+
import type { ThreadMessage } from "../../../types";
|
|
10
11
|
import {
|
|
11
12
|
type AssistantCloud,
|
|
12
13
|
type AssistantCloudEvent,
|
|
13
|
-
|
|
14
|
+
CloudEngagementReporter,
|
|
14
15
|
CloudMessagePersistence,
|
|
16
|
+
CloudRunReporter,
|
|
15
17
|
createFormattedPersistence,
|
|
16
|
-
createRunReport,
|
|
17
18
|
createRunTelemetryToolCall,
|
|
18
19
|
deriveRunOutcome,
|
|
19
20
|
describeRunError,
|
|
20
21
|
extractRunTelemetryModelId,
|
|
21
22
|
normalizeRunTelemetryUsage,
|
|
23
|
+
type RunMessageTelemetry,
|
|
22
24
|
type RunReportOutcome,
|
|
23
25
|
type RunReportStepInit,
|
|
24
|
-
type RunTelemetryUsage,
|
|
25
26
|
type RunTelemetryUsageInit,
|
|
26
27
|
truncateRunTelemetryText,
|
|
27
28
|
} from "assistant-cloud";
|
|
28
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
extractAISDKRunTelemetry,
|
|
31
|
+
type AISDKMessageLike,
|
|
32
|
+
} from "assistant-cloud/ai-sdk";
|
|
33
|
+
import { auiV0DecodeSafely, auiV0Encode } from "./auiV0";
|
|
29
34
|
import { type AssistantClient, getClientId, useAui } from "@assistant-ui/store";
|
|
30
35
|
import type { ThreadListItemMethods } from "../../../store/scopes/thread-list-item";
|
|
31
36
|
import type { FeedbackAdapter } from "../../../adapters/feedback";
|
|
@@ -43,6 +48,8 @@ const globalPersistence = new WeakMap<
|
|
|
43
48
|
class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
44
49
|
private cloudRef: RefObject<AssistantCloud>;
|
|
45
50
|
private getAui: () => AssistantClient;
|
|
51
|
+
private runReporter: CloudRunReporter;
|
|
52
|
+
public readonly engagementReporter: CloudEngagementReporter;
|
|
46
53
|
|
|
47
54
|
constructor(
|
|
48
55
|
cloudRef: RefObject<AssistantCloud>,
|
|
@@ -50,6 +57,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
50
57
|
) {
|
|
51
58
|
this.cloudRef = cloudRef;
|
|
52
59
|
this.getAui = getAui;
|
|
60
|
+
this.runReporter = new CloudRunReporter(() => this.cloudRef.current);
|
|
61
|
+
this.engagementReporter = new CloudEngagementReporter(
|
|
62
|
+
() => this.cloudRef.current,
|
|
63
|
+
(threadId, messageId, options) =>
|
|
64
|
+
this.resolveEngagementEventIds(threadId, messageId, options),
|
|
65
|
+
);
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
private get aui(): AssistantClient {
|
|
@@ -104,7 +117,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
public readonly feedback: FeedbackAdapter = {
|
|
107
|
-
submit: ({ message, type }) => {
|
|
120
|
+
submit: ({ message, type, comment }) => {
|
|
108
121
|
void (async () => {
|
|
109
122
|
const threadListItem = this.tryGetKeyedThreadListItem();
|
|
110
123
|
const remoteThreadId = threadListItem?.getState().remoteId;
|
|
@@ -128,7 +141,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
128
141
|
await this.cloudRef.current.threads.messages.feedback(
|
|
129
142
|
remoteThreadId,
|
|
130
143
|
cloudMessageId,
|
|
131
|
-
{ type },
|
|
144
|
+
{ type, ...(comment ? { comment } : undefined) },
|
|
132
145
|
);
|
|
133
146
|
})().catch((error: unknown) => {
|
|
134
147
|
console.error(
|
|
@@ -215,6 +228,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
215
228
|
options?: {
|
|
216
229
|
durationMs?: number;
|
|
217
230
|
stepTimestamps?: StepTimestamp[];
|
|
231
|
+
message?: ThreadMessage;
|
|
218
232
|
},
|
|
219
233
|
) {
|
|
220
234
|
const encodedRunMessages = items.map((item) =>
|
|
@@ -225,7 +239,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
225
239
|
encodedRunMessages,
|
|
226
240
|
options,
|
|
227
241
|
resolvePinned(),
|
|
228
|
-
|
|
242
|
+
mergeRunMessageInfo(
|
|
243
|
+
extractLastRunMessageInfo(items, formatAdapter),
|
|
244
|
+
options?.message
|
|
245
|
+
? extractRunMessageInfo(options.message, "aui/v0")
|
|
246
|
+
: undefined,
|
|
247
|
+
),
|
|
229
248
|
);
|
|
230
249
|
},
|
|
231
250
|
async load(): Promise<MessageFormatRepository<TMessage>> {
|
|
@@ -292,14 +311,27 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
292
311
|
const remoteId = this.aui.threadListItem.getState().remoteId;
|
|
293
312
|
if (!remoteId) return { messages: [] };
|
|
294
313
|
const messages = await this._persistence.load(remoteId, "aui/v0");
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
314
|
+
// The cloud lists rows newest first, so walking them oldest first puts a
|
|
315
|
+
// parent ahead of its children and a row orphaned by an unreadable parent
|
|
316
|
+
// can be dropped in the same pass; MessageRepository.import throws on a
|
|
317
|
+
// message whose parent is missing.
|
|
318
|
+
const rows = messages
|
|
319
|
+
.filter(
|
|
320
|
+
(m): m is typeof m & { format: "aui/v0" } => m.format === "aui/v0",
|
|
321
|
+
)
|
|
322
|
+
.reverse();
|
|
323
|
+
|
|
324
|
+
const loaded: ExportedMessageRepositoryItem[] = [];
|
|
325
|
+
const loadedIds = new Set<string>();
|
|
326
|
+
for (const row of rows) {
|
|
327
|
+
const item = auiV0DecodeSafely(row);
|
|
328
|
+
if (!item) continue;
|
|
329
|
+
if (item.parentId && !loadedIds.has(item.parentId)) continue;
|
|
330
|
+
loadedIds.add(item.message.id);
|
|
331
|
+
loaded.push(item);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return { messages: loaded };
|
|
303
335
|
}
|
|
304
336
|
|
|
305
337
|
private _reportRunTelemetry<T>(
|
|
@@ -312,13 +344,15 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
312
344
|
threadListItem?: CloudThreadListItem,
|
|
313
345
|
messageInfo?: RunMessageInfo,
|
|
314
346
|
) {
|
|
315
|
-
if (!this.cloudRef.current.telemetry.enabled) return;
|
|
316
|
-
|
|
317
347
|
const item = threadListItem ?? this.aui.threadListItem;
|
|
318
348
|
const remoteId = item.getState().remoteId;
|
|
319
349
|
if (!remoteId) return;
|
|
320
350
|
|
|
321
|
-
const extracted =
|
|
351
|
+
const extracted =
|
|
352
|
+
extractRunTelemetry(format, runMessages) ??
|
|
353
|
+
(messageInfo?.status !== undefined
|
|
354
|
+
? { status: "incomplete" as const }
|
|
355
|
+
: undefined);
|
|
322
356
|
if (!extracted) return;
|
|
323
357
|
|
|
324
358
|
this._sendReport(
|
|
@@ -345,7 +379,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
345
379
|
|
|
346
380
|
private _sendReport(
|
|
347
381
|
remoteId: string,
|
|
348
|
-
data:
|
|
382
|
+
data: RunMessageTelemetry,
|
|
349
383
|
durationMs?: number,
|
|
350
384
|
stepTimestamps?: StepTimestamp[],
|
|
351
385
|
messageInfo?: RunMessageInfo,
|
|
@@ -355,7 +389,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
355
389
|
const messageId = messageInfo?.localMessageId
|
|
356
390
|
? persistence.getResolvedRemoteId(messageInfo.localMessageId)
|
|
357
391
|
: undefined;
|
|
358
|
-
|
|
392
|
+
void this.runReporter.report({
|
|
359
393
|
threadId: remoteId,
|
|
360
394
|
status: messageInfo?.status ?? data.status,
|
|
361
395
|
outcome: messageInfo?.outcomeType,
|
|
@@ -365,90 +399,47 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
365
399
|
traceId: messageInfo?.traceId,
|
|
366
400
|
modelId: data.modelId,
|
|
367
401
|
provider: messageInfo?.provider,
|
|
368
|
-
usage:
|
|
369
|
-
|
|
370
|
-
outputTokens: data.outputTokens,
|
|
371
|
-
reasoningTokens: data.reasoningTokens,
|
|
372
|
-
cachedInputTokens: data.cachedInputTokens,
|
|
373
|
-
},
|
|
374
|
-
steps: toRunReportSteps(mergedSteps),
|
|
402
|
+
usage: data.usage,
|
|
403
|
+
steps: mergedSteps,
|
|
375
404
|
totalSteps: data.totalSteps,
|
|
376
405
|
toolCalls: data.toolCalls,
|
|
377
406
|
durationMs,
|
|
378
407
|
firstTokenMs: messageInfo?.firstTokenMs,
|
|
379
408
|
outputText: data.outputText,
|
|
380
409
|
metadata: data.metadata,
|
|
381
|
-
telemetry: this.cloudRef.current.telemetry,
|
|
382
410
|
});
|
|
383
|
-
|
|
384
|
-
const { beforeReport } = this.cloudRef.current.telemetry;
|
|
385
|
-
const report = beforeReport ? beforeReport(initial) : initial;
|
|
386
|
-
if (!report) return;
|
|
387
|
-
|
|
388
|
-
this.cloudRef.current.runs.report(report).catch(() => {});
|
|
389
411
|
}
|
|
390
412
|
}
|
|
391
413
|
|
|
392
|
-
type TelemetryStepData = {
|
|
393
|
-
input_tokens?: number;
|
|
394
|
-
output_tokens?: number;
|
|
395
|
-
reasoning_tokens?: number;
|
|
396
|
-
cached_input_tokens?: number;
|
|
397
|
-
tool_calls?: AssistantCloudRunReportToolCall[];
|
|
398
|
-
start_ms?: number;
|
|
399
|
-
end_ms?: number;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
414
|
type StepTimestamp = { start_ms: number; end_ms: number };
|
|
403
415
|
|
|
404
|
-
function toRunReportSteps(
|
|
405
|
-
steps: TelemetryStepData[] | undefined,
|
|
406
|
-
): RunReportStepInit[] | undefined {
|
|
407
|
-
if (!steps) return undefined;
|
|
408
|
-
return steps.map((step) => ({
|
|
409
|
-
usage: {
|
|
410
|
-
inputTokens: step.input_tokens,
|
|
411
|
-
outputTokens: step.output_tokens,
|
|
412
|
-
reasoningTokens: step.reasoning_tokens,
|
|
413
|
-
cachedInputTokens: step.cached_input_tokens,
|
|
414
|
-
},
|
|
415
|
-
toolCalls: step.tool_calls,
|
|
416
|
-
startMs: step.start_ms,
|
|
417
|
-
endMs: step.end_ms,
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
|
-
|
|
421
416
|
function mergeStepTimestamps(
|
|
422
|
-
steps:
|
|
417
|
+
steps: RunReportStepInit[] | undefined,
|
|
423
418
|
timestamps: StepTimestamp[] | undefined,
|
|
424
|
-
):
|
|
419
|
+
): RunReportStepInit[] | undefined {
|
|
425
420
|
if (!timestamps) return steps;
|
|
426
|
-
if (!steps)
|
|
421
|
+
if (!steps) {
|
|
422
|
+
return timestamps.map(({ start_ms, end_ms }) => ({
|
|
423
|
+
startMs: start_ms,
|
|
424
|
+
endMs: end_ms,
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
427
|
|
|
428
428
|
const len = Math.min(steps.length, timestamps.length);
|
|
429
|
-
return steps.map((
|
|
430
|
-
...
|
|
431
|
-
...(
|
|
429
|
+
return steps.map((step, index) => ({
|
|
430
|
+
...step,
|
|
431
|
+
...(index < len
|
|
432
|
+
? {
|
|
433
|
+
startMs: timestamps[index]!.start_ms,
|
|
434
|
+
endMs: timestamps[index]!.end_ms,
|
|
435
|
+
}
|
|
436
|
+
: undefined),
|
|
432
437
|
}));
|
|
433
438
|
}
|
|
434
439
|
|
|
435
|
-
type TelemetryData = {
|
|
436
|
-
status: "completed" | "incomplete" | "error";
|
|
437
|
-
toolCalls?: AssistantCloudRunReportToolCall[];
|
|
438
|
-
totalSteps?: number;
|
|
439
|
-
inputTokens?: number;
|
|
440
|
-
outputTokens?: number;
|
|
441
|
-
reasoningTokens?: number;
|
|
442
|
-
cachedInputTokens?: number;
|
|
443
|
-
outputText?: string;
|
|
444
|
-
metadata?: Record<string, unknown>;
|
|
445
|
-
steps?: TelemetryStepData[];
|
|
446
|
-
modelId?: string;
|
|
447
|
-
};
|
|
448
|
-
|
|
449
440
|
type RunMessageInfo = {
|
|
450
441
|
localMessageId?: string;
|
|
451
|
-
status?: "error";
|
|
442
|
+
status?: "completed" | "incomplete" | "error";
|
|
452
443
|
outcomeType?: RunReportOutcome;
|
|
453
444
|
error?: string;
|
|
454
445
|
errorCode?: string;
|
|
@@ -476,6 +467,15 @@ function extractLastRunMessageInfo<
|
|
|
476
467
|
return undefined;
|
|
477
468
|
}
|
|
478
469
|
|
|
470
|
+
function mergeRunMessageInfo(
|
|
471
|
+
stored: RunMessageInfo | undefined,
|
|
472
|
+
observed: RunMessageInfo | undefined,
|
|
473
|
+
): RunMessageInfo | undefined {
|
|
474
|
+
if (!observed) return stored;
|
|
475
|
+
const { localMessageId: _observedId, ...outcome } = observed;
|
|
476
|
+
return { ...stored, ...outcome };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
479
|
function extractRunMessageInfo(
|
|
480
480
|
message: unknown,
|
|
481
481
|
format: string,
|
|
@@ -487,27 +487,30 @@ function extractRunMessageInfo(
|
|
|
487
487
|
const metadata = isRecord(message.metadata) ? message.metadata : undefined;
|
|
488
488
|
const custom = isRecord(metadata?.custom) ? metadata.custom : undefined;
|
|
489
489
|
const timing = isRecord(metadata?.timing) ? metadata.timing : undefined;
|
|
490
|
-
const streamStartTime = timing?.streamStartTime;
|
|
491
490
|
const firstTokenTime = timing?.firstTokenTime;
|
|
492
491
|
const firstTokenMs =
|
|
493
|
-
typeof
|
|
494
|
-
|
|
495
|
-
typeof firstTokenTime === "number" &&
|
|
496
|
-
Number.isFinite(firstTokenTime)
|
|
497
|
-
? Math.round(firstTokenTime - streamStartTime)
|
|
492
|
+
typeof firstTokenTime === "number" && Number.isFinite(firstTokenTime)
|
|
493
|
+
? Math.round(firstTokenTime)
|
|
498
494
|
: undefined;
|
|
499
495
|
const finishReason =
|
|
500
496
|
status?.type === "incomplete"
|
|
501
|
-
? status.reason
|
|
497
|
+
? typeof status.reason === "string"
|
|
498
|
+
? status.reason
|
|
499
|
+
: undefined
|
|
502
500
|
: typeof metadata?.finishReason === "string"
|
|
503
501
|
? metadata.finishReason
|
|
504
502
|
: undefined;
|
|
505
503
|
const failed = status?.type === "incomplete" && status.reason === "error";
|
|
506
|
-
const outcome = deriveRunOutcome({
|
|
507
|
-
finishReason: typeof finishReason === "string" ? finishReason : undefined,
|
|
508
|
-
isError: failed,
|
|
509
|
-
});
|
|
504
|
+
const outcome = deriveRunOutcome({ finishReason, isError: failed });
|
|
510
505
|
const outcomeType = outcome.outcome;
|
|
506
|
+
const runStatus =
|
|
507
|
+
outcome.status === "error"
|
|
508
|
+
? "error"
|
|
509
|
+
: status?.type === "incomplete"
|
|
510
|
+
? "incomplete"
|
|
511
|
+
: finishReason !== undefined
|
|
512
|
+
? outcome.status
|
|
513
|
+
: undefined;
|
|
511
514
|
const failure = failed ? describeRunError(status.error) : {};
|
|
512
515
|
const messageId =
|
|
513
516
|
localMessageId ?? (typeof message.id === "string" ? message.id : undefined);
|
|
@@ -526,7 +529,7 @@ function extractRunMessageInfo(
|
|
|
526
529
|
|
|
527
530
|
return {
|
|
528
531
|
...(messageId ? { localMessageId: messageId } : undefined),
|
|
529
|
-
...(
|
|
532
|
+
...(runStatus !== undefined ? { status: runStatus } : undefined),
|
|
530
533
|
...(outcomeType ? { outcomeType } : undefined),
|
|
531
534
|
...failure,
|
|
532
535
|
...(firstTokenMs != null && firstTokenMs >= 0
|
|
@@ -541,12 +544,15 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
541
544
|
return value !== null && typeof value === "object";
|
|
542
545
|
}
|
|
543
546
|
|
|
544
|
-
function extractTelemetry<T>(
|
|
547
|
+
function extractTelemetry<T>(
|
|
548
|
+
format: string,
|
|
549
|
+
content: T,
|
|
550
|
+
): RunMessageTelemetry | null {
|
|
545
551
|
switch (format) {
|
|
546
552
|
case "aui/v0":
|
|
547
553
|
return extractAuiV0(content);
|
|
548
554
|
case "ai-sdk/v6":
|
|
549
|
-
return
|
|
555
|
+
return extractAISDKRunTelemetry([content as AISDKMessageLike]);
|
|
550
556
|
default:
|
|
551
557
|
return null;
|
|
552
558
|
}
|
|
@@ -555,9 +561,9 @@ function extractTelemetry<T>(format: string, content: T): TelemetryData | null {
|
|
|
555
561
|
function extractRunTelemetry<T>(
|
|
556
562
|
format: string,
|
|
557
563
|
runMessages: T[],
|
|
558
|
-
):
|
|
564
|
+
): RunMessageTelemetry | null {
|
|
559
565
|
if (format === "ai-sdk/v6") {
|
|
560
|
-
return
|
|
566
|
+
return extractAISDKRunTelemetry(runMessages as AISDKMessageLike[]);
|
|
561
567
|
}
|
|
562
568
|
for (let i = runMessages.length - 1; i >= 0; i--) {
|
|
563
569
|
const result = extractTelemetry(format, runMessages[i]!);
|
|
@@ -566,12 +572,7 @@ function extractRunTelemetry<T>(
|
|
|
566
572
|
return null;
|
|
567
573
|
}
|
|
568
574
|
|
|
569
|
-
|
|
570
|
-
error: "error",
|
|
571
|
-
incomplete: "incomplete",
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
575
|
+
export function extractAuiV0<T>(content: T): RunMessageTelemetry | null {
|
|
575
576
|
const msg = content as {
|
|
576
577
|
role?: string;
|
|
577
578
|
status?: { type: string; reason?: string };
|
|
@@ -655,317 +656,42 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
655
656
|
cachedInputTokens = hasCachedInput ? totalCachedInput : undefined;
|
|
656
657
|
}
|
|
657
658
|
|
|
658
|
-
const
|
|
659
|
-
const status: TelemetryData["status"] =
|
|
660
|
-
statusType === "incomplete" && msg.status?.reason === "error"
|
|
661
|
-
? "error"
|
|
662
|
-
: (statusType && AUI_STATUS_MAP[statusType]) || "completed";
|
|
659
|
+
const status = msg.status?.type === "incomplete" ? "incomplete" : "completed";
|
|
663
660
|
|
|
664
661
|
const metadata = msg.metadata?.custom as Record<string, unknown> | undefined;
|
|
665
662
|
const modelId = extractRunTelemetryModelId(
|
|
666
663
|
msg.metadata as Record<string, unknown> | undefined,
|
|
667
664
|
);
|
|
668
665
|
|
|
669
|
-
const telemetrySteps:
|
|
670
|
-
steps && steps.length >
|
|
671
|
-
? steps.map((
|
|
672
|
-
const usage = s.usage
|
|
673
|
-
? normalizeRunTelemetryUsage(s.usage)
|
|
674
|
-
: undefined;
|
|
675
|
-
return {
|
|
676
|
-
...(usage?.inputTokens != null
|
|
677
|
-
? { input_tokens: usage.inputTokens }
|
|
678
|
-
: undefined),
|
|
679
|
-
...(usage?.outputTokens != null
|
|
680
|
-
? { output_tokens: usage.outputTokens }
|
|
681
|
-
: undefined),
|
|
682
|
-
...(usage?.reasoningTokens != null
|
|
683
|
-
? { reasoning_tokens: usage.reasoningTokens }
|
|
684
|
-
: undefined),
|
|
685
|
-
...(usage?.cachedInputTokens != null
|
|
686
|
-
? { cached_input_tokens: usage.cachedInputTokens }
|
|
687
|
-
: undefined),
|
|
688
|
-
};
|
|
689
|
-
})
|
|
666
|
+
const telemetrySteps: RunReportStepInit[] | undefined =
|
|
667
|
+
steps && steps.length > 0
|
|
668
|
+
? steps.map((step) => (step.usage ? { usage: step.usage } : {}))
|
|
690
669
|
: undefined;
|
|
691
670
|
|
|
692
671
|
return {
|
|
693
672
|
status,
|
|
694
673
|
...(toolCalls && toolCalls.length > 0 ? { toolCalls } : undefined),
|
|
695
674
|
...(steps?.length ? { totalSteps: steps.length } : undefined),
|
|
696
|
-
...(inputTokens != null
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
type: string;
|
|
709
|
-
text?: string;
|
|
710
|
-
toolName?: string;
|
|
711
|
-
toolCallId?: string;
|
|
712
|
-
args?: unknown;
|
|
713
|
-
result?: unknown;
|
|
714
|
-
input?: unknown;
|
|
715
|
-
output?: unknown;
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
type AiSdkV6Message = {
|
|
719
|
-
role?: string;
|
|
720
|
-
parts?: readonly AiSdkV6Part[];
|
|
721
|
-
metadata?: Record<string, unknown>;
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
function isToolCallPart(p: AiSdkV6Part): boolean {
|
|
725
|
-
if (!p.toolCallId) return false;
|
|
726
|
-
if (p.type === "tool-call" || p.type === "dynamic-tool") return !!p.toolName;
|
|
727
|
-
return p.type.startsWith("tool-") || p.type.startsWith("dynamic-tool-");
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function isDynamicToolPart(p: AiSdkV6Part): boolean {
|
|
731
|
-
return p.type === "dynamic-tool" || p.type.startsWith("dynamic-tool-");
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
function partToToolCall(p: AiSdkV6Part): AssistantCloudRunReportToolCall {
|
|
735
|
-
const toolSource: "mcp" | "frontend" = isDynamicToolPart(p)
|
|
736
|
-
? "mcp"
|
|
737
|
-
: "frontend";
|
|
738
|
-
return createRunTelemetryToolCall({
|
|
739
|
-
toolName: p.toolName ?? p.type.slice(5),
|
|
740
|
-
toolCallId: p.toolCallId!,
|
|
741
|
-
args: p.args ?? p.input,
|
|
742
|
-
result: p.result ?? p.output,
|
|
743
|
-
toolSource,
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
function collectAiSdkV6Parts(parts: readonly AiSdkV6Part[]): {
|
|
748
|
-
textParts: string[];
|
|
749
|
-
toolCalls: AssistantCloudRunReportToolCall[];
|
|
750
|
-
stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[];
|
|
751
|
-
} {
|
|
752
|
-
const textParts: string[] = [];
|
|
753
|
-
const toolCalls: AssistantCloudRunReportToolCall[] = [];
|
|
754
|
-
const stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
|
|
755
|
-
let currentStepToolCalls: AssistantCloudRunReportToolCall[] | null = null;
|
|
756
|
-
|
|
757
|
-
for (const p of parts) {
|
|
758
|
-
if (p.type === "step-start") {
|
|
759
|
-
if (currentStepToolCalls !== null) {
|
|
760
|
-
stepsData.push({ tool_calls: currentStepToolCalls });
|
|
761
|
-
}
|
|
762
|
-
currentStepToolCalls = [];
|
|
763
|
-
} else if (p.type === "text" && p.text) {
|
|
764
|
-
textParts.push(p.text);
|
|
765
|
-
} else if (isToolCallPart(p)) {
|
|
766
|
-
const tc = partToToolCall(p);
|
|
767
|
-
toolCalls.push(tc);
|
|
768
|
-
if (currentStepToolCalls !== null) {
|
|
769
|
-
currentStepToolCalls.push(tc);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
if (currentStepToolCalls !== null) {
|
|
775
|
-
stepsData.push({ tool_calls: currentStepToolCalls });
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
return { textParts, toolCalls, stepsData };
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
function buildAiSdkV6Result(
|
|
782
|
-
textParts: string[],
|
|
783
|
-
toolCalls: AssistantCloudRunReportToolCall[],
|
|
784
|
-
totalSteps: number,
|
|
785
|
-
metadata?: Record<string, unknown>,
|
|
786
|
-
stepsData?: { tool_calls: AssistantCloudRunReportToolCall[] }[],
|
|
787
|
-
usage?: RunTelemetryUsage,
|
|
788
|
-
): TelemetryData {
|
|
789
|
-
const hasText = textParts.length > 0;
|
|
790
|
-
const outputText = hasText
|
|
791
|
-
? truncateRunTelemetryText(textParts.join(""))
|
|
792
|
-
: undefined;
|
|
793
|
-
const modelId = extractRunTelemetryModelId(metadata);
|
|
794
|
-
|
|
795
|
-
const steps: TelemetryStepData[] | undefined =
|
|
796
|
-
stepsData && stepsData.length > 1
|
|
797
|
-
? stepsData.map((s) => ({
|
|
798
|
-
...(s.tool_calls.length > 0
|
|
799
|
-
? { tool_calls: s.tool_calls }
|
|
800
|
-
: undefined),
|
|
801
|
-
}))
|
|
802
|
-
: undefined;
|
|
803
|
-
|
|
804
|
-
return {
|
|
805
|
-
status: hasText ? "completed" : "incomplete",
|
|
806
|
-
...(toolCalls.length > 0 ? { toolCalls } : undefined),
|
|
807
|
-
...(totalSteps > 0 ? { totalSteps } : undefined),
|
|
808
|
-
...(usage?.inputTokens != null
|
|
809
|
-
? { inputTokens: usage.inputTokens }
|
|
810
|
-
: undefined),
|
|
811
|
-
...(usage?.outputTokens != null
|
|
812
|
-
? { outputTokens: usage.outputTokens }
|
|
813
|
-
: undefined),
|
|
814
|
-
...(usage?.reasoningTokens != null
|
|
815
|
-
? { reasoningTokens: usage.reasoningTokens }
|
|
816
|
-
: undefined),
|
|
817
|
-
...(usage?.cachedInputTokens != null
|
|
818
|
-
? { cachedInputTokens: usage.cachedInputTokens }
|
|
675
|
+
...(inputTokens != null ||
|
|
676
|
+
outputTokens != null ||
|
|
677
|
+
reasoningTokens != null ||
|
|
678
|
+
cachedInputTokens != null
|
|
679
|
+
? {
|
|
680
|
+
usage: {
|
|
681
|
+
...(inputTokens != null ? { inputTokens } : undefined),
|
|
682
|
+
...(outputTokens != null ? { outputTokens } : undefined),
|
|
683
|
+
...(reasoningTokens != null ? { reasoningTokens } : undefined),
|
|
684
|
+
...(cachedInputTokens != null ? { cachedInputTokens } : undefined),
|
|
685
|
+
},
|
|
686
|
+
}
|
|
819
687
|
: undefined),
|
|
820
688
|
...(outputText != null ? { outputText } : undefined),
|
|
821
689
|
...(metadata ? { metadata } : undefined),
|
|
822
|
-
...(
|
|
690
|
+
...(telemetrySteps ? { steps: telemetrySteps } : undefined),
|
|
823
691
|
...(modelId ? { modelId } : undefined),
|
|
824
692
|
};
|
|
825
693
|
}
|
|
826
694
|
|
|
827
|
-
function extractAiSdkV6Usage(
|
|
828
|
-
metadata?: Record<string, unknown>,
|
|
829
|
-
): RunTelemetryUsage | undefined {
|
|
830
|
-
// Try top-level metadata.usage
|
|
831
|
-
const usage = metadata?.usage as RunTelemetryUsageInit | undefined;
|
|
832
|
-
if (usage) {
|
|
833
|
-
const normalized = normalizeRunTelemetryUsage(usage);
|
|
834
|
-
if (normalized) return normalized;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// Try aggregating from metadata.steps[].usage
|
|
838
|
-
const steps = metadata?.steps as
|
|
839
|
-
| readonly { usage?: RunTelemetryUsageInit }[]
|
|
840
|
-
| undefined;
|
|
841
|
-
if (steps && steps.length > 0) {
|
|
842
|
-
let inputTokens = 0;
|
|
843
|
-
let outputTokens = 0;
|
|
844
|
-
let reasoningTokens = 0;
|
|
845
|
-
let cachedInputTokens = 0;
|
|
846
|
-
let hasInput = false;
|
|
847
|
-
let hasOutput = false;
|
|
848
|
-
let hasReasoning = false;
|
|
849
|
-
let hasCachedInput = false;
|
|
850
|
-
let hasAny = false;
|
|
851
|
-
for (const s of steps) {
|
|
852
|
-
if (!s.usage) continue;
|
|
853
|
-
const n = normalizeRunTelemetryUsage(s.usage);
|
|
854
|
-
if (n) {
|
|
855
|
-
if (n.inputTokens != null) {
|
|
856
|
-
inputTokens += n.inputTokens;
|
|
857
|
-
hasInput = true;
|
|
858
|
-
}
|
|
859
|
-
if (n.outputTokens != null) {
|
|
860
|
-
outputTokens += n.outputTokens;
|
|
861
|
-
hasOutput = true;
|
|
862
|
-
}
|
|
863
|
-
if (n.reasoningTokens != null) {
|
|
864
|
-
reasoningTokens += n.reasoningTokens;
|
|
865
|
-
hasReasoning = true;
|
|
866
|
-
}
|
|
867
|
-
if (n.cachedInputTokens != null) {
|
|
868
|
-
cachedInputTokens += n.cachedInputTokens;
|
|
869
|
-
hasCachedInput = true;
|
|
870
|
-
}
|
|
871
|
-
hasAny = true;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
if (hasAny) {
|
|
875
|
-
return {
|
|
876
|
-
...(hasInput ? { inputTokens } : undefined),
|
|
877
|
-
...(hasOutput ? { outputTokens } : undefined),
|
|
878
|
-
...(hasReasoning ? { reasoningTokens } : undefined),
|
|
879
|
-
...(hasCachedInput ? { cachedInputTokens } : undefined),
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
return undefined;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
function extractAiSdkV6<T>(content: T): TelemetryData | null {
|
|
888
|
-
const msg = content as AiSdkV6Message;
|
|
889
|
-
if (msg.role !== "assistant") return null;
|
|
890
|
-
|
|
891
|
-
const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(
|
|
892
|
-
msg.parts ?? [],
|
|
893
|
-
);
|
|
894
|
-
return buildAiSdkV6Result(
|
|
895
|
-
textParts,
|
|
896
|
-
toolCalls,
|
|
897
|
-
stepsData.length,
|
|
898
|
-
msg.metadata,
|
|
899
|
-
stepsData,
|
|
900
|
-
extractAiSdkV6Usage(msg.metadata),
|
|
901
|
-
);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
function aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {
|
|
905
|
-
const allTextParts: string[] = [];
|
|
906
|
-
const allToolCalls: AssistantCloudRunReportToolCall[] = [];
|
|
907
|
-
const allStepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
|
|
908
|
-
let hasAssistant = false;
|
|
909
|
-
let metadata: Record<string, unknown> | undefined;
|
|
910
|
-
let inputTokens = 0;
|
|
911
|
-
let outputTokens = 0;
|
|
912
|
-
let reasoningTokens = 0;
|
|
913
|
-
let cachedInputTokens = 0;
|
|
914
|
-
let hasInput = false;
|
|
915
|
-
let hasOutput = false;
|
|
916
|
-
let hasReasoning = false;
|
|
917
|
-
let hasCachedInput = false;
|
|
918
|
-
|
|
919
|
-
for (const content of stepMessages) {
|
|
920
|
-
const msg = content as AiSdkV6Message;
|
|
921
|
-
if (msg.role !== "assistant") continue;
|
|
922
|
-
hasAssistant = true;
|
|
923
|
-
|
|
924
|
-
const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(
|
|
925
|
-
msg.parts ?? [],
|
|
926
|
-
);
|
|
927
|
-
allTextParts.push(...textParts);
|
|
928
|
-
allToolCalls.push(...toolCalls);
|
|
929
|
-
allStepsData.push(...stepsData);
|
|
930
|
-
if (msg.metadata) metadata = msg.metadata;
|
|
931
|
-
|
|
932
|
-
const usage = extractAiSdkV6Usage(msg.metadata);
|
|
933
|
-
if (usage) {
|
|
934
|
-
if (usage.inputTokens != null) {
|
|
935
|
-
inputTokens += usage.inputTokens;
|
|
936
|
-
hasInput = true;
|
|
937
|
-
}
|
|
938
|
-
if (usage.outputTokens != null) {
|
|
939
|
-
outputTokens += usage.outputTokens;
|
|
940
|
-
hasOutput = true;
|
|
941
|
-
}
|
|
942
|
-
if (usage.reasoningTokens != null) {
|
|
943
|
-
reasoningTokens += usage.reasoningTokens;
|
|
944
|
-
hasReasoning = true;
|
|
945
|
-
}
|
|
946
|
-
if (usage.cachedInputTokens != null) {
|
|
947
|
-
cachedInputTokens += usage.cachedInputTokens;
|
|
948
|
-
hasCachedInput = true;
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
if (!hasAssistant) return null;
|
|
954
|
-
return buildAiSdkV6Result(
|
|
955
|
-
allTextParts,
|
|
956
|
-
allToolCalls,
|
|
957
|
-
allStepsData.length,
|
|
958
|
-
metadata,
|
|
959
|
-
allStepsData,
|
|
960
|
-
{
|
|
961
|
-
...(hasInput ? { inputTokens } : undefined),
|
|
962
|
-
...(hasOutput ? { outputTokens } : undefined),
|
|
963
|
-
...(hasReasoning ? { reasoningTokens } : undefined),
|
|
964
|
-
...(hasCachedInput ? { cachedInputTokens } : undefined),
|
|
965
|
-
},
|
|
966
|
-
);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
695
|
export function useAssistantCloudThreadHistoryAdapter(
|
|
970
696
|
cloudRef: RefObject<AssistantCloud>,
|
|
971
697
|
): ThreadHistoryAdapter & { readonly feedback: FeedbackAdapter } {
|
|
@@ -979,14 +705,13 @@ export function useAssistantCloudThreadHistoryAdapter(
|
|
|
979
705
|
() =>
|
|
980
706
|
new AssistantCloudThreadHistoryAdapter(cloudRef, () => auiRef.current),
|
|
981
707
|
);
|
|
982
|
-
useAssistantCloudEngagementEvents(
|
|
708
|
+
useAssistantCloudEngagementEvents(adapter, aui);
|
|
983
709
|
return adapter;
|
|
984
710
|
}
|
|
985
711
|
|
|
986
712
|
type RootEngagementTracker = {
|
|
987
713
|
count: number;
|
|
988
|
-
|
|
989
|
-
cloudRef: RefObject<AssistantCloud>;
|
|
714
|
+
engagementReporter: CloudEngagementReporter;
|
|
990
715
|
dispose: () => void;
|
|
991
716
|
};
|
|
992
717
|
|
|
@@ -1001,7 +726,6 @@ const rootEngagementTrackers = new WeakMap<
|
|
|
1001
726
|
* subscription and the last one to unmount removes it.
|
|
1002
727
|
*/
|
|
1003
728
|
const useRootEngagementEvents = (
|
|
1004
|
-
cloudRef: RefObject<AssistantCloud>,
|
|
1005
729
|
adapter: AssistantCloudThreadHistoryAdapter,
|
|
1006
730
|
aui: AssistantClient,
|
|
1007
731
|
) => {
|
|
@@ -1010,31 +734,20 @@ const useRootEngagementEvents = (
|
|
|
1010
734
|
if (!tracker) {
|
|
1011
735
|
const created: RootEngagementTracker = {
|
|
1012
736
|
count: 0,
|
|
1013
|
-
adapter,
|
|
1014
|
-
cloudRef,
|
|
737
|
+
engagementReporter: adapter.engagementReporter,
|
|
1015
738
|
dispose: () => {},
|
|
1016
739
|
};
|
|
1017
740
|
created.dispose = aui.on(
|
|
1018
741
|
{ scope: "*", event: "threads.selectionChanged" },
|
|
1019
742
|
(payload) => {
|
|
1020
|
-
|
|
1021
|
-
.resolveEngagementEventIds(payload.threadId)
|
|
1022
|
-
.then((ids) => {
|
|
1023
|
-
if (!ids.thread_id) return;
|
|
1024
|
-
created.cloudRef.current.events?.track({
|
|
1025
|
-
kind: "thread_switched",
|
|
1026
|
-
...ids,
|
|
1027
|
-
});
|
|
1028
|
-
})
|
|
1029
|
-
.catch(() => {});
|
|
743
|
+
created.engagementReporter.threadSwitched(payload.threadId);
|
|
1030
744
|
},
|
|
1031
745
|
);
|
|
1032
746
|
rootEngagementTrackers.set(aui, created);
|
|
1033
747
|
tracker = created;
|
|
1034
748
|
}
|
|
1035
749
|
const active = tracker;
|
|
1036
|
-
active.
|
|
1037
|
-
active.cloudRef = cloudRef;
|
|
750
|
+
active.engagementReporter = adapter.engagementReporter;
|
|
1038
751
|
active.count += 1;
|
|
1039
752
|
return () => {
|
|
1040
753
|
active.count -= 1;
|
|
@@ -1043,175 +756,129 @@ const useRootEngagementEvents = (
|
|
|
1043
756
|
rootEngagementTrackers.delete(aui);
|
|
1044
757
|
}
|
|
1045
758
|
};
|
|
1046
|
-
}, [adapter, aui
|
|
759
|
+
}, [adapter, aui]);
|
|
1047
760
|
};
|
|
1048
761
|
|
|
1049
762
|
const useAssistantCloudEngagementEvents = (
|
|
1050
|
-
cloudRef: RefObject<AssistantCloud>,
|
|
1051
763
|
adapter: AssistantCloudThreadHistoryAdapter,
|
|
1052
764
|
aui: AssistantClient,
|
|
1053
765
|
) => {
|
|
1054
|
-
useRootEngagementEvents(
|
|
1055
|
-
const runStartedAt = useRef(new Map<string, number>());
|
|
1056
|
-
const runEndedAt = useRef(new Map<string, number>());
|
|
1057
|
-
const shownSuggestions = useRef(new Set<string>());
|
|
766
|
+
useRootEngagementEvents(adapter, aui);
|
|
1058
767
|
|
|
1059
768
|
useEffect(() => {
|
|
1060
|
-
const
|
|
1061
|
-
event: AssistantCloudEvent,
|
|
1062
|
-
threadId: string,
|
|
1063
|
-
messageId?: string,
|
|
1064
|
-
options?: { awaitThread?: boolean },
|
|
1065
|
-
) => {
|
|
1066
|
-
void adapter
|
|
1067
|
-
.resolveEngagementEventIds(threadId, messageId, options)
|
|
1068
|
-
.then((ids) => {
|
|
1069
|
-
cloudRef.current.events?.track({ ...event, ...ids });
|
|
1070
|
-
})
|
|
1071
|
-
.catch(() => {});
|
|
1072
|
-
};
|
|
1073
|
-
const trackRunStopped = (threadId: string) => {
|
|
1074
|
-
const startedAt = runStartedAt.current.get(threadId);
|
|
1075
|
-
if (startedAt === undefined) return;
|
|
1076
|
-
runStartedAt.current.delete(threadId);
|
|
1077
|
-
track(
|
|
1078
|
-
{ kind: "run_stopped", value: Math.max(0, Date.now() - startedAt) },
|
|
1079
|
-
threadId,
|
|
1080
|
-
);
|
|
1081
|
-
};
|
|
769
|
+
const reporter = adapter.engagementReporter;
|
|
1082
770
|
|
|
1083
771
|
const unsubscribers = [
|
|
1084
772
|
aui.on({ scope: "thread", event: "composer.send" }, (payload) => {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
}),
|
|
1097
|
-
...(!payload.messageId && previousRunEndedAt !== undefined
|
|
1098
|
-
? { value: Math.max(0, Date.now() - previousRunEndedAt) }
|
|
1099
|
-
: undefined),
|
|
1100
|
-
},
|
|
1101
|
-
payload.threadId,
|
|
1102
|
-
payload.messageId,
|
|
1103
|
-
{ awaitThread: !payload.messageId },
|
|
1104
|
-
);
|
|
773
|
+
if (payload.messageId) {
|
|
774
|
+
reporter.messageEdited(payload.threadId, {
|
|
775
|
+
messageId: payload.messageId,
|
|
776
|
+
chars: payload.chars,
|
|
777
|
+
});
|
|
778
|
+
} else {
|
|
779
|
+
reporter.messageSent(payload.threadId, {
|
|
780
|
+
chars: payload.chars,
|
|
781
|
+
attachments: payload.attachments,
|
|
782
|
+
});
|
|
783
|
+
}
|
|
1105
784
|
if (payload.suggestion) {
|
|
1106
|
-
|
|
785
|
+
reporter.suggestionClicked(payload.threadId);
|
|
1107
786
|
}
|
|
1108
787
|
}),
|
|
1109
788
|
aui.on(
|
|
1110
789
|
{ scope: "thread", event: "composer.attachmentAdd" },
|
|
1111
790
|
(payload) => {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
? { props: { type: payload.contentType } }
|
|
1117
|
-
: undefined),
|
|
1118
|
-
},
|
|
1119
|
-
payload.threadId,
|
|
1120
|
-
payload.messageId,
|
|
1121
|
-
);
|
|
791
|
+
reporter.attachmentAdded(payload.threadId, {
|
|
792
|
+
messageId: payload.messageId,
|
|
793
|
+
contentType: payload.contentType,
|
|
794
|
+
});
|
|
1122
795
|
},
|
|
1123
796
|
),
|
|
1124
797
|
aui.on(
|
|
1125
798
|
{ scope: "thread", event: "composer.attachmentAddError" },
|
|
1126
799
|
(payload) => {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
? { props: { type: payload.contentType } }
|
|
1132
|
-
: undefined),
|
|
1133
|
-
},
|
|
1134
|
-
payload.threadId,
|
|
1135
|
-
payload.messageId,
|
|
1136
|
-
);
|
|
800
|
+
reporter.attachmentFailed(payload.threadId, {
|
|
801
|
+
messageId: payload.messageId,
|
|
802
|
+
contentType: payload.contentType,
|
|
803
|
+
});
|
|
1137
804
|
},
|
|
1138
805
|
),
|
|
1139
806
|
aui.on({ scope: "thread", event: "composer.cancel" }, (payload) => {
|
|
1140
|
-
|
|
807
|
+
reporter.runStopped(payload.threadId);
|
|
1141
808
|
}),
|
|
1142
809
|
aui.on({ scope: "thread", event: "thread.runStart" }, (payload) => {
|
|
1143
|
-
|
|
810
|
+
reporter.runStarted(payload.threadId);
|
|
1144
811
|
}),
|
|
1145
812
|
aui.on({ scope: "thread", event: "thread.runEnd" }, (payload) => {
|
|
1146
|
-
|
|
1147
|
-
runEndedAt.current.set(payload.threadId, Date.now());
|
|
813
|
+
reporter.runEnded(payload.threadId);
|
|
1148
814
|
}),
|
|
1149
815
|
aui.on({ scope: "thread", event: "thread.cancelRun" }, (payload) => {
|
|
1150
|
-
|
|
816
|
+
reporter.runStopped(payload.threadId);
|
|
1151
817
|
}),
|
|
1152
818
|
aui.on({ scope: "thread", event: "thread.voiceStarted" }, (payload) => {
|
|
1153
|
-
|
|
819
|
+
reporter.voiceStarted(payload.threadId);
|
|
1154
820
|
}),
|
|
1155
821
|
aui.on({ scope: "thread", event: "message.reload" }, (payload) => {
|
|
1156
|
-
|
|
1157
|
-
{ kind: "message_regenerated" },
|
|
1158
|
-
payload.threadId,
|
|
1159
|
-
payload.messageId,
|
|
1160
|
-
);
|
|
822
|
+
reporter.messageRegenerated(payload.threadId, payload.messageId);
|
|
1161
823
|
}),
|
|
1162
824
|
aui.on(
|
|
1163
825
|
{ scope: "thread", event: "message.branchSwitched" },
|
|
1164
826
|
(payload) => {
|
|
1165
|
-
|
|
1166
|
-
{ kind: "branch_switched" },
|
|
1167
|
-
payload.threadId,
|
|
1168
|
-
payload.messageId,
|
|
1169
|
-
);
|
|
827
|
+
reporter.branchSwitched(payload.threadId, payload.messageId);
|
|
1170
828
|
},
|
|
1171
829
|
),
|
|
1172
830
|
aui.on({ scope: "thread", event: "message.copied" }, (payload) => {
|
|
1173
|
-
|
|
831
|
+
reporter.messageCopied(payload.threadId, payload.messageId);
|
|
1174
832
|
}),
|
|
833
|
+
aui.on(
|
|
834
|
+
{ scope: "thread", event: "thread.toolApprovalAnswered" },
|
|
835
|
+
(payload) => {
|
|
836
|
+
if (payload.approved) {
|
|
837
|
+
reporter.toolApproved(
|
|
838
|
+
payload.threadId,
|
|
839
|
+
payload.messageId,
|
|
840
|
+
payload.toolCallId,
|
|
841
|
+
payload.toolName,
|
|
842
|
+
);
|
|
843
|
+
} else {
|
|
844
|
+
reporter.toolRejected(
|
|
845
|
+
payload.threadId,
|
|
846
|
+
payload.messageId,
|
|
847
|
+
payload.toolCallId,
|
|
848
|
+
payload.toolName,
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
),
|
|
1175
853
|
aui.on({ scope: "thread", event: "message.speak" }, (payload) => {
|
|
1176
|
-
|
|
854
|
+
reporter.speechStarted(payload.threadId, payload.messageId);
|
|
1177
855
|
}),
|
|
1178
856
|
aui.on({ scope: "thread", event: "message.error" }, (payload) => {
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
payload.
|
|
1182
|
-
|
|
1183
|
-
);
|
|
857
|
+
reporter.errorShown(payload.threadId, {
|
|
858
|
+
messageId: payload.messageId,
|
|
859
|
+
reason: payload.reason,
|
|
860
|
+
});
|
|
1184
861
|
}),
|
|
1185
862
|
];
|
|
1186
863
|
|
|
1187
864
|
return () => {
|
|
1188
865
|
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
1189
866
|
};
|
|
1190
|
-
}, [adapter, aui
|
|
867
|
+
}, [adapter, aui]);
|
|
1191
868
|
|
|
1192
869
|
useEffect(() => {
|
|
1193
870
|
const reportSuggestions = () => {
|
|
1194
871
|
const { mainThreadId } = aui.threads.getState();
|
|
1195
872
|
if (aui.threadListItem.getState().id !== mainThreadId) return;
|
|
1196
873
|
const { isEmpty, suggestions } = aui.thread.getState();
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
)
|
|
1202
|
-
return;
|
|
1203
|
-
}
|
|
1204
|
-
shownSuggestions.current.add(mainThreadId);
|
|
1205
|
-
void adapter.resolveEngagementEventIds(mainThreadId).then((ids) => {
|
|
1206
|
-
cloudRef.current.events?.track({
|
|
1207
|
-
kind: "suggestions_shown",
|
|
1208
|
-
value: suggestions.length,
|
|
1209
|
-
...ids,
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
874
|
+
if (!isEmpty || suggestions.length === 0) return;
|
|
875
|
+
adapter.engagementReporter.suggestionsShown(
|
|
876
|
+
mainThreadId,
|
|
877
|
+
suggestions.length,
|
|
878
|
+
);
|
|
1212
879
|
};
|
|
1213
880
|
|
|
1214
881
|
reportSuggestions();
|
|
1215
882
|
return aui.subscribe(reportSuggestions);
|
|
1216
|
-
}, [adapter, aui
|
|
883
|
+
}, [adapter, aui]);
|
|
1217
884
|
};
|