@assistant-ui/core 0.3.19 → 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/suggestion.d.ts +5 -6
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/adapters/thread-history.d.ts +6 -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/internal/duplicate-detection.d.ts +1 -2
- package/dist/internal/duplicate-detection.d.ts.map +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/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/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 +20 -34
- 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/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/RemoteThreadList.d.ts +2 -3
- package/dist/react/client/RemoteThreadList.d.ts.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/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/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/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/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 +2 -3
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.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 +3 -4
- package/dist/react/primitives/part/PartMessages.d.ts.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/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/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 +2 -3
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +17 -4
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -2
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +11 -3
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +63 -2
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +4 -5
- package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.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 +1 -2
- package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/sdkIdentity.js +1 -1
- 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 +6 -6
- package/dist/react/runtimes/external-message-converter.d.ts.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 +2 -2
- 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 +7 -8
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/useJSONEqual.d.ts +2 -3
- package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
- package/dist/react/utils/useJSONSchemaDependency.d.ts +1 -2
- package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
- 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/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 +1 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +8 -3
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +71 -27
- 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 +17 -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 +5 -4
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +9 -1
- 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 +7 -8
- package/dist/runtime/utils/auto-status.d.ts.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 +15 -16
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
- package/dist/runtime/utils/external-message-conversion.js +3 -2
- 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/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 +5 -5
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtime/utils/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 +29 -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/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 +9 -4
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +53 -9
- 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/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 +15 -11
- 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 +3 -4
- package/dist/store/clients/thread-tasks.d.ts.map +1 -1
- package/dist/store/env.d.ts +1 -2
- package/dist/store/env.d.ts.map +1 -1
- 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 +2 -2
- 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/useSubscribable.d.ts +1 -2
- package/dist/store/runtime-clients/useSubscribable.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 +4 -5
- package/dist/store/scopes/task.d.ts.map +1 -1
- 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 +5 -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 -16
- package/dist/subscribable/subscribable.d.ts.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/message.d.ts +48 -46
- 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/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 +2 -3
- package/dist/utils/getGroupStatus.d.ts.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/package.json +14 -13
- package/src/adapters/attachment.ts +8 -1
- package/src/adapters/feedback.ts +1 -0
- package/src/model-context/frame/provider.test.ts +45 -20
- package/src/react/RuntimeAdapter.test.ts +4 -1
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +117 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +27 -74
- package/src/react/client/Interactables.test.ts +12 -7
- package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
- package/src/react/client/RemoteThreadList.test.ts +5 -6
- package/src/react/interactables-legacy/Interactables.test.ts +9 -3
- package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +40 -22
- package/src/react/model-context/useInteractable.test.tsx +56 -29
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -5
- 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 +4 -1
- package/src/react/primitives/thread/ThreadMessages.test.tsx +25 -7
- 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/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.tsx +102 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +24 -11
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +8 -4
- package/src/react/runtimes/cloud/auiV0.ts +121 -1
- package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +522 -0
- package/src/react/runtimes/external-message-converter.test.ts +7 -3
- 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 +5 -1
- package/src/runtime/api/message-part-runtime.ts +4 -1
- package/src/runtime/api/message-runtime.ts +15 -2
- package/src/runtime/base/base-thread-runtime-core.test.ts +761 -18
- package/src/runtime/base/base-thread-runtime-core.ts +89 -26
- 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 +2 -0
- package/src/runtime/queue/message-queue.ts +11 -1
- package/src/runtime/utils/external-message-conversion.test.ts +43 -0
- package/src/runtime/utils/external-message-conversion.ts +6 -2
- package/src/runtime/utils/stored-message-parts.ts +174 -0
- package/src/runtime/utils/thread-message-like.ts +7 -2
- package/src/runtimes/external-store/external-store-adapter.ts +4 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +44 -9
- package/src/runtimes/local/local-thread-runtime-core.test.ts +168 -12
- package/src/runtimes/local/local-thread-runtime-core.ts +80 -9
- package/src/store/clients/external-thread.ts +34 -13
- package/src/store/primitive-predicates.test.ts +16 -0
- package/src/store/primitive-predicates.ts +4 -1
- package/src/store/runtime-clients/thread-runtime-client.test.tsx +110 -0
- package/src/store/scopes/message.ts +4 -1
- package/src/subscribable/subscribable.test.ts +7 -2
- package/src/tests/attachment-adapters.test.ts +16 -1
- package/src/tests/auiV0Encode.test.ts +4 -0
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
- package/src/tests/base-composer-runtime-core.test.ts +16 -5
- 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 +229 -27
- package/src/tests/external-store-thread-runtime-core.test.ts +31 -0
- package/src/tests/external-thread-attachments.test.tsx +22 -23
- package/src/tests/external-thread-feedback.test.tsx +20 -7
- package/src/tests/external-thread-parity.test.tsx +1 -1
- package/src/tests/message-queue.test.ts +45 -10
- package/src/tests/thread-switch-events.test.tsx +11 -7
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +2 -1
- package/src/types/message.test.ts +19 -0
- package/src/types/message.ts +16 -8
|
@@ -22,11 +22,13 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
22
22
|
_getBaseMessages() {
|
|
23
23
|
return this.repository.getMessages();
|
|
24
24
|
}
|
|
25
|
+
_commitVoiceMessage(_message) {}
|
|
25
26
|
get messages() {
|
|
26
27
|
if (this._voiceMessages.length === 0) return this._getBaseMessages();
|
|
27
28
|
const base = this._getBaseMessages();
|
|
28
29
|
if (this._cachedVoiceGeneration !== this._voiceGeneration || this._cachedMergedBase !== base) {
|
|
29
|
-
|
|
30
|
+
const baseMessageIds = new Set(base.map((message) => message.id));
|
|
31
|
+
this._cachedMergedMessages = [...base, ...this._voiceMessages.filter((message) => !baseMessageIds.has(message.id))];
|
|
30
32
|
this._cachedVoiceGeneration = this._voiceGeneration;
|
|
31
33
|
this._cachedMergedBase = base;
|
|
32
34
|
}
|
|
@@ -83,7 +85,11 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
83
85
|
_isVoiceMessage(messageId) {
|
|
84
86
|
return messageId !== null && this._voiceMessages.some((m) => m.id === messageId);
|
|
85
87
|
}
|
|
88
|
+
_resolveAppendParent(parentId) {
|
|
89
|
+
return this._isVoiceMessage(parentId) ? this._getBaseMessages().at(-1)?.id ?? null : parentId;
|
|
90
|
+
}
|
|
86
91
|
beginEdit(messageId) {
|
|
92
|
+
if (this.voice) throw new Error("Cannot edit a message while a voice session is connected");
|
|
87
93
|
if (this._isVoiceMessage(messageId)) throw new Error("Voice transcript messages cannot be edited");
|
|
88
94
|
if (this._editComposers.has(messageId)) throw new Error("Edit already in progress");
|
|
89
95
|
this._editComposers.set(messageId, new DefaultEditComposerRuntimeCore(this, () => this._editComposers.delete(messageId), this.repository.getMessage(messageId)));
|
|
@@ -124,22 +130,26 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
124
130
|
approved
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
|
-
submitFeedback({ messageId, type }) {
|
|
133
|
+
submitFeedback({ messageId, type, comment }) {
|
|
128
134
|
const adapter = this.adapters?.feedback;
|
|
129
|
-
if (!adapter) throw new Error("Feedback adapter not configured");
|
|
130
135
|
const entry = this.getMessageById(messageId);
|
|
131
136
|
if (!entry) throw new Error(`Message not found: ${messageId}`);
|
|
132
137
|
const { message, parentId } = entry;
|
|
133
|
-
|
|
138
|
+
const trimmed = comment?.trim();
|
|
139
|
+
const feedback = {
|
|
140
|
+
type,
|
|
141
|
+
...trimmed ? { comment: trimmed } : void 0
|
|
142
|
+
};
|
|
143
|
+
adapter?.submit({
|
|
134
144
|
message,
|
|
135
|
-
|
|
145
|
+
...feedback
|
|
136
146
|
});
|
|
137
147
|
if (message.role === "assistant") {
|
|
138
148
|
const updatedMessage = {
|
|
139
149
|
...message,
|
|
140
150
|
metadata: {
|
|
141
151
|
...message.metadata,
|
|
142
|
-
submittedFeedback:
|
|
152
|
+
submittedFeedback: feedback
|
|
143
153
|
}
|
|
144
154
|
};
|
|
145
155
|
const voiceIdx = this._voiceMessages.findIndex((voiceMessage) => voiceMessage.id === messageId);
|
|
@@ -231,15 +241,30 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
231
241
|
this._voiceVolumeSubscribers.add(callback);
|
|
232
242
|
return () => this._voiceVolumeSubscribers.delete(callback);
|
|
233
243
|
};
|
|
244
|
+
_onVoiceConnected() {}
|
|
245
|
+
_onVoiceDisconnected() {}
|
|
246
|
+
_isRunActive() {
|
|
247
|
+
if (this.isRunning) return true;
|
|
248
|
+
const last = this._getBaseMessages().at(-1);
|
|
249
|
+
return last?.role === "assistant" && (last.status.type === "running" || last.status.type === "requires-action");
|
|
250
|
+
}
|
|
234
251
|
connectVoice() {
|
|
235
252
|
const adapter = this.adapters?.voice;
|
|
236
253
|
if (!adapter) throw new Error("Voice adapter not configured");
|
|
254
|
+
if (this._isRunActive()) throw new Error("Cannot start a voice session while a run is in progress or paused on a pending tool action");
|
|
255
|
+
const replacing = this._voiceSession !== void 0;
|
|
237
256
|
try {
|
|
238
|
-
this.
|
|
257
|
+
this._disconnectVoice(false);
|
|
239
258
|
} catch (error) {
|
|
240
259
|
console.error("[assistant-ui] Voice cleanup threw before reconnect", error);
|
|
241
260
|
}
|
|
242
|
-
|
|
261
|
+
let session;
|
|
262
|
+
try {
|
|
263
|
+
session = adapter.connect({});
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (replacing && this._voiceSession === void 0) this._onVoiceDisconnected();
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
243
268
|
this._voiceSession = session;
|
|
244
269
|
const unsubs = [];
|
|
245
270
|
this._voiceUnsubs = unsubs;
|
|
@@ -263,10 +288,12 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
263
288
|
this._notifySubscribers();
|
|
264
289
|
if (finishDetachedSetup()) return;
|
|
265
290
|
unsubs.push(session.onStatusChange((status) => {
|
|
291
|
+
if (this._voiceSession !== session) return;
|
|
266
292
|
if (status.type === "ended") {
|
|
267
293
|
this._finishVoiceAssistantMessage();
|
|
268
294
|
this._voiceSession = void 0;
|
|
269
295
|
this.voice = void 0;
|
|
296
|
+
this._onVoiceDisconnected();
|
|
270
297
|
} else this.voice = {
|
|
271
298
|
status,
|
|
272
299
|
isMuted: session.isMuted,
|
|
@@ -294,14 +321,16 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
294
321
|
unsubs.push(session.onTranscript((transcript) => {
|
|
295
322
|
this._handleVoiceTranscript(transcript);
|
|
296
323
|
}));
|
|
297
|
-
finishDetachedSetup();
|
|
324
|
+
if (!finishDetachedSetup()) this._onVoiceConnected();
|
|
298
325
|
} catch (error) {
|
|
299
|
-
if (this._voiceSession === session && this._voiceUnsubs === unsubs)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
326
|
+
if (this._voiceSession === session && this._voiceUnsubs === unsubs) {
|
|
327
|
+
try {
|
|
328
|
+
this._disconnectVoice(false);
|
|
329
|
+
} catch (cleanupError) {
|
|
330
|
+
console.error("[assistant-ui] Voice rollback cleanup threw", cleanupError);
|
|
331
|
+
}
|
|
332
|
+
if (replacing && this._voiceSession === void 0) this._onVoiceDisconnected();
|
|
333
|
+
} else finishDetachedSetup();
|
|
305
334
|
throw error;
|
|
306
335
|
}
|
|
307
336
|
}
|
|
@@ -312,7 +341,7 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
312
341
|
this._finishVoiceAssistantMessage();
|
|
313
342
|
this._currentAssistantMsg = null;
|
|
314
343
|
if (transcript.isFinal) {
|
|
315
|
-
|
|
344
|
+
const message = {
|
|
316
345
|
id: generateId(),
|
|
317
346
|
role: "user",
|
|
318
347
|
content: [{
|
|
@@ -329,7 +358,9 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
329
358
|
reason: "unknown"
|
|
330
359
|
},
|
|
331
360
|
attachments: []
|
|
332
|
-
}
|
|
361
|
+
};
|
|
362
|
+
this._voiceMessages.push(message);
|
|
363
|
+
this._commitVoiceMessage(message);
|
|
333
364
|
this._markVoiceMessagesDirty();
|
|
334
365
|
this._notifySubscribers();
|
|
335
366
|
}
|
|
@@ -372,12 +403,15 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
372
403
|
this._voiceMessages[idx] = updated;
|
|
373
404
|
this._currentAssistantMsg = updated;
|
|
374
405
|
}
|
|
375
|
-
if (transcript.isFinal)
|
|
406
|
+
if (transcript.isFinal) {
|
|
407
|
+
this._commitVoiceMessage(this._currentAssistantMsg);
|
|
408
|
+
this._currentAssistantMsg = null;
|
|
409
|
+
}
|
|
376
410
|
this._markVoiceMessagesDirty();
|
|
377
411
|
this._notifySubscribers();
|
|
378
412
|
}
|
|
379
413
|
}
|
|
380
|
-
_finishVoiceAssistantMessage() {
|
|
414
|
+
_finishVoiceAssistantMessage(notify = true) {
|
|
381
415
|
const last = this._voiceMessages.at(-1);
|
|
382
416
|
if (last?.role === "assistant" && last.status.type === "running") {
|
|
383
417
|
const idx = this._voiceMessages.length - 1;
|
|
@@ -388,11 +422,17 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
388
422
|
reason: "stop"
|
|
389
423
|
}
|
|
390
424
|
};
|
|
425
|
+
this._commitVoiceMessage(this._voiceMessages[idx]);
|
|
426
|
+
this._currentAssistantMsg = null;
|
|
391
427
|
this._markVoiceMessagesDirty();
|
|
392
|
-
this._notifySubscribers();
|
|
428
|
+
if (notify) this._notifySubscribers();
|
|
393
429
|
}
|
|
394
430
|
}
|
|
395
431
|
disconnectVoice() {
|
|
432
|
+
this._disconnectVoice(true);
|
|
433
|
+
}
|
|
434
|
+
_disconnectVoice(fireHook) {
|
|
435
|
+
this._finishVoiceAssistantMessage(false);
|
|
396
436
|
this._currentAssistantMsg = null;
|
|
397
437
|
const unsubs = this._voiceUnsubs.splice(0);
|
|
398
438
|
this._voiceUnsubs = [];
|
|
@@ -403,13 +443,17 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
403
443
|
const stopSpeaking = this.speech && this._isVoiceMessage(this.speech.messageId) ? this._stopSpeaking : void 0;
|
|
404
444
|
this._voiceMessages = [];
|
|
405
445
|
this._markVoiceMessagesDirty();
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
446
|
+
try {
|
|
447
|
+
notifySubscribers([
|
|
448
|
+
...unsubs,
|
|
449
|
+
...stopSpeaking ? [stopSpeaking] : [],
|
|
450
|
+
...session ? [() => session.disconnect()] : [],
|
|
451
|
+
() => notifyEventListeners(this._voiceVolumeSubscribers, void 0, "Voice volume"),
|
|
452
|
+
() => this._notifySubscribers()
|
|
453
|
+
]);
|
|
454
|
+
} finally {
|
|
455
|
+
if (fireHook && session && this._voiceSession === void 0) this._onVoiceDisconnected();
|
|
456
|
+
}
|
|
413
457
|
}
|
|
414
458
|
muteVoice() {
|
|
415
459
|
if (!this._voiceSession) throw new Error("No active voice session");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-thread-runtime-core.js","names":["AppendMessage","ThreadAssistantMessage","ThreadMessage","Unsubscribe","ModelContextProvider","getThreadMessageText","generateId","ExportedMessageRepository","MessageRepository","DefaultThreadComposerRuntimeCore","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","ThreadSuggestion","SubmitFeedbackOptions","ThreadRuntimeCore","SpeechState","VoiceSessionState","RuntimeCapabilities","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","DefaultEditComposerRuntimeCore","SpeechSynthesisAdapter","FeedbackAdapter","AttachmentAdapter","RealtimeVoiceAdapter","ThreadMessageLike","notifyEventListeners","gateInteractableComposerMetadata","BaseSubscribable","notifySubscribers","BaseThreadAdapters","speech","feedback","attachments","voice","BaseThreadRuntimeCore","_isInitialized","repository","adapters","isDisabled","isSendDisabled","isLoading","suggestions","extras","capabilities","append","message","deleteMessage","messageId","Promise","startRun","config","resumeRun","addToolResult","options","resumeToolCall","respondToToolApproval","cancelRun","exportExternalState","importExternalState","state","unstable_notifySessionReset","_voiceMessages","_voiceGeneration","_cachedMergedMessages","_cachedVoiceGeneration","_cachedMergedBase","_markVoiceMessagesDirty","_getBaseMessages","getMessages","messages","length","base","mostRecentAssistantMessage","this","role","metadata","unstable_state","composer","_contextProvider","constructor","getModelContext","enrichAppendMetadata","anchorId","parentId","parentIndex","findIndex","m","id","composerMetadata","unstable_composerMetadata","slice","custom","_editComposers","Map","getEditComposer","get","_isVoiceMessage","some","beginEdit","Error","has","set","delete","getMessage","_notifySubscribers","getMessageById","baseMessages","voiceIdx","at","index","undefined","getBranches","switchToBranch","branchId","_notifyEventSubscribers","event","E","payload","subscribers","_eventSubscribers","_notifyToolApprovalAnswered","toolCallId","toolName","approved","submitFeedback","type","adapter","entry","submit","updatedMessage","submittedFeedback","voiceMessage","addOrUpdateMessage","_currentAssistantMsg","_stopSpeaking","speak","previousStop","utterance","Utterance","error","notificationError","console","unsub","clear","cleanup","stop","cancel","update","status","subscribe","cleanupError","stopSpeaking","_voiceSession","Session","_voiceUnsubs","Array","_voiceVolume","_voiceVolumeSubscribers","Set","getVoiceVolume","subscribeVoiceVolume","callback","add","connectVoice","disconnectVoice","session","connect","unsubs","finishDetachedSetup","splice","currentMode","Mode","isMuted","mode","push","onStatusChange","_finishVoiceAssistantMessage","onModeChange","onVolumeChange","volume","onTranscript","transcript","_handleVoiceTranscript","TranscriptItem","ensureInitialized","isFinal","content","text","modality","createdAt","Date","reason","unstable_annotations","unstable_data","steps","idx","indexOf","updated","last","disconnect","muteVoice","mute","unmuteVoice","unmute","export","import","data","reset","initialMessages","fromArray","unstable_on","wrapped","queueMicrotask"],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"sourcesContent":["import type {\n AppendMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { generateId } from \"../../utils/id\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/message-repository\";\nimport { DefaultThreadComposerRuntimeCore } from \"./default-thread-composer-runtime-core\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n VoiceSessionState,\n RuntimeCapabilities,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../interfaces/thread-runtime-core\";\nimport { DefaultEditComposerRuntimeCore } from \"./default-edit-composer-runtime-core\";\nimport type { SpeechSynthesisAdapter } from \"../../adapters/speech\";\nimport type { FeedbackAdapter } from \"../../adapters/feedback\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { RealtimeVoiceAdapter } from \"../../adapters/voice\";\nimport type { ThreadMessageLike } from \"../utils/thread-message-like\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport { gateInteractableComposerMetadata } from \"../../model-context/interactable-composer-metadata\";\nimport {\n BaseSubscribable,\n notifySubscribers,\n} from \"../../subscribable/subscribable\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n voice?: RealtimeVoiceAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _isInitialized = false;\n\n protected repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get isSendDisabled(): boolean;\n public abstract get isLoading(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract deleteMessage(messageId: string): void | Promise<void>;\n public abstract startRun(config: StartRunConfig): void;\n public abstract resumeRun(config: ResumeRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract resumeToolCall(options: ResumeToolCallOptions): void;\n public abstract respondToToolApproval(\n options: RespondToToolApprovalOptions,\n ): Promise<void>;\n public abstract cancelRun(): void;\n public abstract exportExternalState(): any;\n public abstract importExternalState(state: any): void;\n public abstract unstable_notifySessionReset(): void;\n\n protected _voiceMessages: ThreadMessage[] = [];\n protected _voiceGeneration = 0;\n private _cachedMergedMessages: readonly ThreadMessage[] | null = null;\n private _cachedVoiceGeneration = -1;\n private _cachedMergedBase: readonly ThreadMessage[] | null = null;\n\n protected _markVoiceMessagesDirty() {\n this._voiceGeneration++;\n this._cachedMergedMessages = null;\n }\n\n protected _getBaseMessages(): readonly ThreadMessage[] {\n return this.repository.getMessages();\n }\n\n public get messages(): readonly ThreadMessage[] {\n if (this._voiceMessages.length === 0) {\n return this._getBaseMessages();\n }\n const base = this._getBaseMessages();\n if (\n this._cachedVoiceGeneration !== this._voiceGeneration ||\n this._cachedMergedBase !== base\n ) {\n this._cachedMergedMessages = [...base, ...this._voiceMessages];\n this._cachedVoiceGeneration = this._voiceGeneration;\n this._cachedMergedBase = base;\n }\n return this._cachedMergedMessages!;\n }\n\n public get state() {\n let mostRecentAssistantMessage: (typeof this.messages)[number] | undefined;\n for (const message of this.messages) {\n if (message.role === \"assistant\") {\n mostRecentAssistantMessage = message;\n }\n }\n\n return mostRecentAssistantMessage?.metadata.unstable_state ?? null;\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n private readonly _contextProvider: ModelContextProvider;\n\n constructor(_contextProvider: ModelContextProvider) {\n super();\n this._contextProvider = _contextProvider;\n }\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n /**\n * Stamps provider-contributed composer metadata onto an outgoing message.\n * Called at dispatch rather than in the composer, so programmatic sends are\n * covered too, and exactly once per message: a queued send is stamped when\n * it leaves the lane, never when it enters.\n *\n * Only user messages are stamped, matching the readers: both the version\n * fold and the model injection skip every other role.\n *\n * @param anchorId Message the gated branch prefix ends at. A queued send\n * passes the current tail, having waited through a run that grew the prefix\n * past the parent it was created with.\n */\n protected enrichAppendMetadata(\n message: AppendMessage,\n anchorId: string | null = message.parentId,\n ): AppendMessage {\n if (message.role !== \"user\") return message;\n const messages = this.messages;\n const parentIndex =\n anchorId === null ? -1 : messages.findIndex((m) => m.id === anchorId);\n const composerMetadata = gateInteractableComposerMetadata(\n this.getModelContext().unstable_composerMetadata,\n messages.slice(0, parentIndex + 1),\n );\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n };\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n protected _isVoiceMessage(messageId: string | null) {\n return (\n messageId !== null && this._voiceMessages.some((m) => m.id === messageId)\n );\n }\n\n public beginEdit(messageId: string) {\n if (this._isVoiceMessage(messageId)) {\n throw new Error(\"Voice transcript messages cannot be edited\");\n }\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n try {\n return this.repository.getMessage(messageId);\n } catch {\n // Check voice messages\n const baseMessages = this.repository.getMessages();\n const voiceIdx = this._voiceMessages.findIndex((m) => m.id === messageId);\n if (voiceIdx !== -1) {\n const parentId =\n voiceIdx > 0\n ? this._voiceMessages[voiceIdx - 1]!.id\n : (baseMessages.at(-1)?.id ?? null);\n return {\n parentId,\n message: this._voiceMessages[voiceIdx]!,\n index: baseMessages.length + voiceIdx,\n };\n }\n return undefined;\n }\n }\n\n public getBranches(messageId: string): string[] {\n if (this._voiceMessages.some((m) => m.id === messageId)) {\n return [];\n }\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n public _notifyEventSubscribers<E extends ThreadRuntimeEventType>(\n event: E,\n payload: ThreadRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Thread runtime \"${event}\"`);\n }\n\n protected _notifyToolApprovalAnswered(\n messageId: string,\n toolCallId: string,\n toolName: string,\n approved: boolean,\n ) {\n this._notifyEventSubscribers(\"toolApprovalAnswered\", {\n messageId,\n toolCallId,\n toolName,\n approved,\n });\n }\n\n public submitFeedback({ messageId, type }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n if (!adapter) throw new Error(\"Feedback adapter not configured\");\n\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message, parentId } = entry;\n adapter.submit({ message, type });\n\n if (message.role === \"assistant\") {\n const updatedMessage: ThreadMessage = {\n ...message,\n metadata: {\n ...message.metadata,\n submittedFeedback: { type },\n },\n };\n const voiceIdx = this._voiceMessages.findIndex(\n (voiceMessage) => voiceMessage.id === messageId,\n );\n if (voiceIdx === -1) {\n this.repository.addOrUpdateMessage(parentId, updatedMessage);\n } else {\n this._voiceMessages[voiceIdx] = updatedMessage;\n if (this._currentAssistantMsg === message) {\n this._currentAssistantMsg = updatedMessage as ThreadAssistantMessage;\n }\n this._markVoiceMessagesDirty();\n }\n }\n\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message } = entry;\n\n const previousStop = this._stopSpeaking;\n let utterance: SpeechSynthesisAdapter.Utterance;\n try {\n previousStop?.();\n utterance = adapter.speak(getThreadMessageText(message));\n } catch (error) {\n if (previousStop && !this._stopSpeaking) {\n try {\n this._notifySubscribers();\n } catch (notificationError) {\n console.error(\n \"[assistant-ui] Speech rollback notification threw\",\n notificationError,\n );\n }\n }\n throw error;\n }\n let unsub: Unsubscribe | undefined;\n const clear = () => {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n const cleanup = unsub;\n unsub = undefined;\n cleanup?.();\n };\n const stop = () => {\n if (this._stopSpeaking !== stop) return;\n try {\n clear();\n } finally {\n utterance.cancel();\n }\n };\n const update = () => {\n if (this._stopSpeaking !== stop) return;\n if (utterance.status.type === \"ended\") {\n notifySubscribers([clear, () => this._notifySubscribers()]);\n } else {\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n }\n };\n\n this._stopSpeaking = stop;\n try {\n unsub = utterance.subscribe(update);\n if (this._stopSpeaking !== stop) {\n unsub();\n return;\n }\n update();\n } catch (error) {\n if (this._stopSpeaking === stop) {\n try {\n notifySubscribers([stop, () => this._notifySubscribers()]);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Speech rollback cleanup threw\",\n cleanupError,\n );\n }\n }\n throw error;\n }\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n notifySubscribers([this._stopSpeaking, () => this._notifySubscribers()]);\n }\n\n private _voiceSession: RealtimeVoiceAdapter.Session | undefined;\n private _voiceUnsubs: Array<() => void> = [];\n public voice: VoiceSessionState | undefined;\n\n private _voiceVolume = 0;\n private _voiceVolumeSubscribers = new Set<() => void>();\n\n public getVoiceVolume = () => this._voiceVolume;\n\n public subscribeVoiceVolume = (callback: () => void): Unsubscribe => {\n this._voiceVolumeSubscribers.add(callback);\n return () => this._voiceVolumeSubscribers.delete(callback);\n };\n\n public connectVoice() {\n const adapter = this.adapters?.voice;\n if (!adapter) throw new Error(\"Voice adapter not configured\");\n\n try {\n this.disconnectVoice();\n } catch (error) {\n console.error(\n \"[assistant-ui] Voice cleanup threw before reconnect\",\n error,\n );\n }\n\n const session = adapter.connect({});\n this._voiceSession = session;\n const unsubs: Array<() => void> = [];\n this._voiceUnsubs = unsubs;\n\n // The cleanup-list identity preserves ownership after an ended status clears the session.\n const finishDetachedSetup = () => {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n return false;\n }\n\n try {\n notifySubscribers(unsubs.splice(0));\n } catch (error) {\n console.error(\n \"[assistant-ui] Detached voice setup cleanup threw\",\n error,\n );\n }\n return true;\n };\n\n try {\n let currentMode: RealtimeVoiceAdapter.Mode = \"listening\";\n\n this.voice = {\n status: session.status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n this._voiceVolume = 0;\n this._notifySubscribers();\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onStatusChange((status) => {\n if (status.type === \"ended\") {\n this._finishVoiceAssistantMessage();\n this._voiceSession = undefined;\n this.voice = undefined;\n } else {\n this.voice = {\n status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n }\n this._notifySubscribers();\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onModeChange((mode) => {\n currentMode = mode;\n if (this.voice) {\n this.voice = { ...this.voice, mode };\n this._notifySubscribers();\n }\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onVolumeChange((volume) => {\n this._voiceVolume = volume;\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n );\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onTranscript((transcript) => {\n this._handleVoiceTranscript(transcript);\n }),\n );\n finishDetachedSetup();\n } catch (error) {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n try {\n this.disconnectVoice();\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Voice rollback cleanup threw\",\n cleanupError,\n );\n }\n } else {\n finishDetachedSetup();\n }\n throw error;\n }\n }\n\n private _currentAssistantMsg: ThreadAssistantMessage | null = null;\n\n private _handleVoiceTranscript(\n transcript: RealtimeVoiceAdapter.TranscriptItem,\n ) {\n this.ensureInitialized();\n\n if (transcript.role === \"user\") {\n this._finishVoiceAssistantMessage();\n this._currentAssistantMsg = null;\n\n if (transcript.isFinal) {\n this._voiceMessages.push({\n id: generateId(),\n role: \"user\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: { modality: \"voice\", custom: {} },\n createdAt: new Date(),\n status: { type: \"complete\", reason: \"unknown\" },\n attachments: [],\n });\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n } else {\n const status: ThreadAssistantMessage[\"status\"] = transcript.isFinal\n ? { type: \"complete\", reason: \"stop\" }\n : { type: \"running\" };\n\n if (!this._currentAssistantMsg) {\n this._currentAssistantMsg = {\n id: generateId(),\n role: \"assistant\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n modality: \"voice\",\n custom: {},\n },\n status,\n createdAt: new Date(),\n };\n this._voiceMessages.push(this._currentAssistantMsg);\n } else {\n const idx = this._voiceMessages.indexOf(this._currentAssistantMsg);\n if (idx === -1) return;\n const updated: ThreadAssistantMessage = {\n ...this._currentAssistantMsg,\n content: [{ type: \"text\", text: transcript.text }],\n status,\n };\n this._voiceMessages[idx] = updated;\n this._currentAssistantMsg = updated;\n }\n\n if (transcript.isFinal) {\n this._currentAssistantMsg = null;\n }\n\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n }\n\n private _finishVoiceAssistantMessage() {\n const last = this._voiceMessages.at(-1);\n if (last?.role === \"assistant\" && last.status.type === \"running\") {\n const idx = this._voiceMessages.length - 1;\n this._voiceMessages[idx] = {\n ...(last as ThreadAssistantMessage),\n status: { type: \"complete\", reason: \"stop\" },\n };\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n }\n\n public disconnectVoice() {\n this._currentAssistantMsg = null;\n // Drain the shared list in place so reentrant setup cannot release the same handles again.\n const unsubs = this._voiceUnsubs.splice(0);\n this._voiceUnsubs = [];\n const session = this._voiceSession;\n this._voiceSession = undefined;\n this.voice = undefined;\n this._voiceVolume = 0;\n const stopSpeaking =\n this.speech && this._isVoiceMessage(this.speech.messageId)\n ? this._stopSpeaking\n : undefined;\n this._voiceMessages = [];\n this._markVoiceMessagesDirty();\n\n notifySubscribers([\n ...unsubs,\n ...(stopSpeaking ? [stopSpeaking] : []),\n ...(session ? [() => session.disconnect()] : []),\n () =>\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n ),\n () => this._notifySubscribers(),\n ]);\n }\n\n public muteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.mute();\n this.voice = {\n ...this.voice!,\n isMuted: true,\n };\n this._notifySubscribers();\n }\n\n public unmuteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.unmute();\n this.voice = {\n ...this.voice!,\n isMuted: false,\n };\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\", {});\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this.import(ExportedMessageRepository.fromArray(initialMessages ?? []));\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n public unstable_on<E extends ThreadRuntimeEventType>(\n event: E,\n callback: ThreadRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n if (event === \"modelContextUpdate\") {\n // provider.subscribe is `() => void`; pump the typed empty payload to the user callback.\n return (\n this._contextProvider.subscribe?.(() =>\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`),\n ) ?? (() => {})\n );\n }\n\n let subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n subscribers = new Set();\n this._eventSubscribers.set(event, subscribers);\n }\n subscribers.add(wrapped);\n\n // `initialize` latches: replay it (deferred) to subscribers that attach\n // after the thread already initialized, mirroring a BehaviorSubject.\n if (event === \"initialize\" && this._isInitialized) {\n queueMicrotask(() => {\n if (subscribers.has(wrapped)) {\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`);\n }\n });\n }\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAkDA,IAAsBuC,wBAAtB,cACUP,iBAEV;CACE,iBAAyB;CAEzB,aAAuB,IAAIxB,kBAAkB;CAuB7C,iBAA4C,CAAA;CAC5C,mBAA6B;CAC7B,wBAAiE;CACjE,yBAAiC;CACjC,oBAA6D;CAE7D,0BAAoC;EAClC,KAAK2D;EACL,KAAKC,wBAAwB;CAC/B;CAEA,mBAAuD;EACrD,OAAO,KAAK3B,WAAWgC,YAAY;CACrC;CAEA,IAAWC,W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IAAI;EAC3B,KAAKtG,mBAAmB;CAC1B;CAEA,MAAawG,iBAAgD;EAC3D,KAAKH,OAAO3M,0BAA0B+M,UAAUD,mBAAmB,CAAA,CAAE,CAAC;CACxE;CAEA,oCAA4B,IAAInH,IAG9B;CAEF,YACEsB,OACA8C,UACA;EACA,MAAMkD,UAAUlD;EAChB,IAAI9C,UAAU,sBAEZ,OACE,KAAKrC,iBAAiBuE,kBACpB5H,qBAAqB,CAAC0L,OAAO,GAAG,CAAC,GAAG,mBAAmBhG,MAAK,EAAG,CACjE,YAAY,CAAC;EAIjB,IAAIG,cAAc,KAAKC,kBAAkBxB,IAAIoB,KAAK;EAClD,IAAI,CAACG,aAAa;GAChBA,8BAAc,IAAIwC,IAAI;GACtB,KAAKvC,kBAAkBlB,IAAIc,OAAOG,WAAW;EAC/C;EACAA,YAAY4C,IAAIiD,OAAO;EAIvB,IAAIhG,UAAU,gBAAgB,KAAKhF,gBACjCiL,qBAAqB;GACnB,IAAI9F,YAAYlB,IAAI+G,OAAO,GACzB1L,qBAAqB,CAAC0L,OAAO,GAAG,CAAC,GAAG,mBAAmBhG,MAAK,EAAG;EAEnE,CAAC;EAGH,aAAa;GACX,KAAKI,kBAAkBxB,IAAIoB,KAAK,CAAC,EAAEb,OAAO6G,OAAO;EACnD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"base-thread-runtime-core.js","names":["AppendMessage","ThreadAssistantMessage","ThreadMessage","Unsubscribe","ModelContextProvider","getThreadMessageText","generateId","ExportedMessageRepository","MessageRepository","DefaultThreadComposerRuntimeCore","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","ThreadSuggestion","SubmitFeedbackOptions","ThreadRuntimeCore","SpeechState","VoiceSessionState","RuntimeCapabilities","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","DefaultEditComposerRuntimeCore","SpeechSynthesisAdapter","FeedbackAdapter","AttachmentAdapter","RealtimeVoiceAdapter","ThreadMessageLike","notifyEventListeners","gateInteractableComposerMetadata","BaseSubscribable","notifySubscribers","BaseThreadAdapters","speech","feedback","attachments","voice","BaseThreadRuntimeCore","_isInitialized","repository","adapters","isDisabled","isSendDisabled","isLoading","suggestions","extras","capabilities","append","message","deleteMessage","messageId","Promise","startRun","config","resumeRun","addToolResult","options","resumeToolCall","respondToToolApproval","cancelRun","exportExternalState","importExternalState","state","unstable_notifySessionReset","_voiceMessages","_voiceGeneration","_cachedMergedMessages","_cachedVoiceGeneration","_cachedMergedBase","_markVoiceMessagesDirty","_getBaseMessages","getMessages","_commitVoiceMessage","_message","messages","length","base","baseMessageIds","Set","map","id","filter","has","mostRecentAssistantMessage","this","role","metadata","unstable_state","composer","_contextProvider","constructor","getModelContext","enrichAppendMetadata","anchorId","parentId","parentIndex","findIndex","m","composerMetadata","unstable_composerMetadata","slice","custom","_editComposers","Map","getEditComposer","get","_isVoiceMessage","some","_resolveAppendParent","at","beginEdit","Error","set","delete","getMessage","_notifySubscribers","getMessageById","baseMessages","voiceIdx","index","undefined","getBranches","switchToBranch","branchId","_notifyEventSubscribers","event","E","payload","subscribers","_eventSubscribers","_notifyToolApprovalAnswered","toolCallId","toolName","approved","submitFeedback","type","comment","adapter","entry","trimmed","trim","submit","updatedMessage","submittedFeedback","voiceMessage","addOrUpdateMessage","_currentAssistantMsg","_stopSpeaking","speak","previousStop","utterance","Utterance","error","notificationError","console","unsub","clear","cleanup","stop","cancel","update","status","subscribe","cleanupError","stopSpeaking","_voiceSession","Session","_voiceUnsubs","Array","_voiceVolume","_voiceVolumeSubscribers","getVoiceVolume","subscribeVoiceVolume","callback","add","_onVoiceConnected","_onVoiceDisconnected","_isRunActive","runtime","isRunning","last","connectVoice","replacing","_disconnectVoice","session","connect","unsubs","finishDetachedSetup","splice","currentMode","Mode","isMuted","mode","push","onStatusChange","_finishVoiceAssistantMessage","onModeChange","onVolumeChange","volume","onTranscript","transcript","_handleVoiceTranscript","TranscriptItem","ensureInitialized","isFinal","content","text","modality","createdAt","Date","reason","unstable_annotations","unstable_data","steps","idx","indexOf","updated","notify","disconnectVoice","fireHook","disconnect","muteVoice","mute","unmuteVoice","unmute","export","import","data","reset","initialMessages","fromArray","unstable_on","wrapped","queueMicrotask"],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"sourcesContent":["import type {\n AppendMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { generateId } from \"../../utils/id\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/message-repository\";\nimport { DefaultThreadComposerRuntimeCore } from \"./default-thread-composer-runtime-core\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n VoiceSessionState,\n RuntimeCapabilities,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../interfaces/thread-runtime-core\";\nimport { DefaultEditComposerRuntimeCore } from \"./default-edit-composer-runtime-core\";\nimport type { SpeechSynthesisAdapter } from \"../../adapters/speech\";\nimport type { FeedbackAdapter } from \"../../adapters/feedback\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { RealtimeVoiceAdapter } from \"../../adapters/voice\";\nimport type { ThreadMessageLike } from \"../utils/thread-message-like\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport { gateInteractableComposerMetadata } from \"../../model-context/interactable-composer-metadata\";\nimport {\n BaseSubscribable,\n notifySubscribers,\n} from \"../../subscribable/subscribable\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n voice?: RealtimeVoiceAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _isInitialized = false;\n\n protected repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get isSendDisabled(): boolean;\n public abstract get isLoading(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract deleteMessage(messageId: string): void | Promise<void>;\n public abstract startRun(config: StartRunConfig): void;\n public abstract resumeRun(config: ResumeRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract resumeToolCall(options: ResumeToolCallOptions): void;\n public abstract respondToToolApproval(\n options: RespondToToolApprovalOptions,\n ): Promise<void>;\n public abstract cancelRun(): void;\n public abstract exportExternalState(): any;\n public abstract importExternalState(state: any): void;\n public abstract unstable_notifySessionReset(): void;\n\n protected _voiceMessages: ThreadMessage[] = [];\n protected _voiceGeneration = 0;\n private _cachedMergedMessages: readonly ThreadMessage[] | null = null;\n private _cachedVoiceGeneration = -1;\n private _cachedMergedBase: readonly ThreadMessage[] | null = null;\n\n protected _markVoiceMessagesDirty() {\n this._voiceGeneration++;\n this._cachedMergedMessages = null;\n }\n\n protected _getBaseMessages(): readonly ThreadMessage[] {\n return this.repository.getMessages();\n }\n\n protected _commitVoiceMessage(_message: ThreadMessage): void {}\n\n public get messages(): readonly ThreadMessage[] {\n if (this._voiceMessages.length === 0) {\n return this._getBaseMessages();\n }\n const base = this._getBaseMessages();\n if (\n this._cachedVoiceGeneration !== this._voiceGeneration ||\n this._cachedMergedBase !== base\n ) {\n const baseMessageIds = new Set(base.map((message) => message.id));\n this._cachedMergedMessages = [\n ...base,\n ...this._voiceMessages.filter(\n (message) => !baseMessageIds.has(message.id),\n ),\n ];\n this._cachedVoiceGeneration = this._voiceGeneration;\n this._cachedMergedBase = base;\n }\n return this._cachedMergedMessages!;\n }\n\n public get state() {\n let mostRecentAssistantMessage: (typeof this.messages)[number] | undefined;\n for (const message of this.messages) {\n if (message.role === \"assistant\") {\n mostRecentAssistantMessage = message;\n }\n }\n\n return mostRecentAssistantMessage?.metadata.unstable_state ?? null;\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n private readonly _contextProvider: ModelContextProvider;\n\n constructor(_contextProvider: ModelContextProvider) {\n super();\n this._contextProvider = _contextProvider;\n }\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n /**\n * Stamps provider-contributed composer metadata onto an outgoing message.\n * Called at dispatch rather than in the composer, so programmatic sends are\n * covered too, and exactly once per message: a queued send is stamped when\n * it leaves the lane, never when it enters.\n *\n * Only user messages are stamped, matching the readers: both the version\n * fold and the model injection skip every other role.\n *\n * @param anchorId Message the gated branch prefix ends at. A queued send\n * passes the current tail, having waited through a run that grew the prefix\n * past the parent it was created with.\n */\n protected enrichAppendMetadata(\n message: AppendMessage,\n anchorId: string | null = message.parentId,\n ): AppendMessage {\n if (message.role !== \"user\") return message;\n const messages = this.messages;\n const parentIndex =\n anchorId === null ? -1 : messages.findIndex((m) => m.id === anchorId);\n const composerMetadata = gateInteractableComposerMetadata(\n this.getModelContext().unstable_composerMetadata,\n messages.slice(0, parentIndex + 1),\n );\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n };\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n protected _isVoiceMessage(messageId: string | null) {\n return (\n messageId !== null && this._voiceMessages.some((m) => m.id === messageId)\n );\n }\n\n protected _resolveAppendParent(parentId: string | null): string | null {\n return this._isVoiceMessage(parentId)\n ? (this._getBaseMessages().at(-1)?.id ?? null)\n : parentId;\n }\n\n public beginEdit(messageId: string) {\n if (this.voice)\n throw new Error(\n \"Cannot edit a message while a voice session is connected\",\n );\n if (this._isVoiceMessage(messageId)) {\n throw new Error(\"Voice transcript messages cannot be edited\");\n }\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n try {\n return this.repository.getMessage(messageId);\n } catch {\n // Check voice messages\n const baseMessages = this.repository.getMessages();\n const voiceIdx = this._voiceMessages.findIndex((m) => m.id === messageId);\n if (voiceIdx !== -1) {\n const parentId =\n voiceIdx > 0\n ? this._voiceMessages[voiceIdx - 1]!.id\n : (baseMessages.at(-1)?.id ?? null);\n return {\n parentId,\n message: this._voiceMessages[voiceIdx]!,\n index: baseMessages.length + voiceIdx,\n };\n }\n return undefined;\n }\n }\n\n public getBranches(messageId: string): string[] {\n if (this._voiceMessages.some((m) => m.id === messageId)) {\n return [];\n }\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n public _notifyEventSubscribers<E extends ThreadRuntimeEventType>(\n event: E,\n payload: ThreadRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Thread runtime \"${event}\"`);\n }\n\n protected _notifyToolApprovalAnswered(\n messageId: string,\n toolCallId: string,\n toolName: string,\n approved: boolean,\n ) {\n this._notifyEventSubscribers(\"toolApprovalAnswered\", {\n messageId,\n toolCallId,\n toolName,\n approved,\n });\n }\n\n public submitFeedback({ messageId, type, comment }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message, parentId } = entry;\n const trimmed = comment?.trim();\n const feedback = { type, ...(trimmed ? { comment: trimmed } : undefined) };\n adapter?.submit({ message, ...feedback });\n\n if (message.role === \"assistant\") {\n const updatedMessage: ThreadMessage = {\n ...message,\n metadata: {\n ...message.metadata,\n submittedFeedback: feedback,\n },\n };\n const voiceIdx = this._voiceMessages.findIndex(\n (voiceMessage) => voiceMessage.id === messageId,\n );\n if (voiceIdx === -1) {\n this.repository.addOrUpdateMessage(parentId, updatedMessage);\n } else {\n this._voiceMessages[voiceIdx] = updatedMessage;\n if (this._currentAssistantMsg === message) {\n this._currentAssistantMsg = updatedMessage as ThreadAssistantMessage;\n }\n this._markVoiceMessagesDirty();\n }\n }\n\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message } = entry;\n\n const previousStop = this._stopSpeaking;\n let utterance: SpeechSynthesisAdapter.Utterance;\n try {\n previousStop?.();\n utterance = adapter.speak(getThreadMessageText(message));\n } catch (error) {\n if (previousStop && !this._stopSpeaking) {\n try {\n this._notifySubscribers();\n } catch (notificationError) {\n console.error(\n \"[assistant-ui] Speech rollback notification threw\",\n notificationError,\n );\n }\n }\n throw error;\n }\n let unsub: Unsubscribe | undefined;\n const clear = () => {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n const cleanup = unsub;\n unsub = undefined;\n cleanup?.();\n };\n const stop = () => {\n if (this._stopSpeaking !== stop) return;\n try {\n clear();\n } finally {\n utterance.cancel();\n }\n };\n const update = () => {\n if (this._stopSpeaking !== stop) return;\n if (utterance.status.type === \"ended\") {\n notifySubscribers([clear, () => this._notifySubscribers()]);\n } else {\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n }\n };\n\n this._stopSpeaking = stop;\n try {\n unsub = utterance.subscribe(update);\n if (this._stopSpeaking !== stop) {\n unsub();\n return;\n }\n update();\n } catch (error) {\n if (this._stopSpeaking === stop) {\n try {\n notifySubscribers([stop, () => this._notifySubscribers()]);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Speech rollback cleanup threw\",\n cleanupError,\n );\n }\n }\n throw error;\n }\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n notifySubscribers([this._stopSpeaking, () => this._notifySubscribers()]);\n }\n\n private _voiceSession: RealtimeVoiceAdapter.Session | undefined;\n private _voiceUnsubs: Array<() => void> = [];\n public voice: VoiceSessionState | undefined;\n\n private _voiceVolume = 0;\n private _voiceVolumeSubscribers = new Set<() => void>();\n\n public getVoiceVolume = () => this._voiceVolume;\n\n public subscribeVoiceVolume = (callback: () => void): Unsubscribe => {\n this._voiceVolumeSubscribers.add(callback);\n return () => this._voiceVolumeSubscribers.delete(callback);\n };\n\n protected _onVoiceConnected(): void {}\n\n protected _onVoiceDisconnected(): void {}\n\n protected _isRunActive(): boolean {\n const runtime: ThreadRuntimeCore = this;\n if (runtime.isRunning) return true;\n const last = this._getBaseMessages().at(-1);\n return (\n last?.role === \"assistant\" &&\n (last.status.type === \"running\" || last.status.type === \"requires-action\")\n );\n }\n\n public connectVoice() {\n const adapter = this.adapters?.voice;\n if (!adapter) throw new Error(\"Voice adapter not configured\");\n if (this._isRunActive())\n throw new Error(\n \"Cannot start a voice session while a run is in progress or paused on a pending tool action\",\n );\n const replacing = this._voiceSession !== undefined;\n\n try {\n this._disconnectVoice(false);\n } catch (error) {\n console.error(\n \"[assistant-ui] Voice cleanup threw before reconnect\",\n error,\n );\n }\n\n let session: RealtimeVoiceAdapter.Session;\n try {\n session = adapter.connect({});\n } catch (error) {\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n throw error;\n }\n this._voiceSession = session;\n const unsubs: Array<() => void> = [];\n this._voiceUnsubs = unsubs;\n\n // The cleanup-list identity preserves ownership after an ended status clears the session.\n const finishDetachedSetup = () => {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n return false;\n }\n\n try {\n notifySubscribers(unsubs.splice(0));\n } catch (error) {\n console.error(\n \"[assistant-ui] Detached voice setup cleanup threw\",\n error,\n );\n }\n return true;\n };\n\n try {\n let currentMode: RealtimeVoiceAdapter.Mode = \"listening\";\n\n this.voice = {\n status: session.status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n this._voiceVolume = 0;\n this._notifySubscribers();\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onStatusChange((status) => {\n if (this._voiceSession !== session) return;\n if (status.type === \"ended\") {\n this._finishVoiceAssistantMessage();\n this._voiceSession = undefined;\n this.voice = undefined;\n this._onVoiceDisconnected();\n } else {\n this.voice = {\n status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n }\n this._notifySubscribers();\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onModeChange((mode) => {\n currentMode = mode;\n if (this.voice) {\n this.voice = { ...this.voice, mode };\n this._notifySubscribers();\n }\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onVolumeChange((volume) => {\n this._voiceVolume = volume;\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n );\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onTranscript((transcript) => {\n this._handleVoiceTranscript(transcript);\n }),\n );\n if (!finishDetachedSetup()) this._onVoiceConnected();\n } catch (error) {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n try {\n this._disconnectVoice(false);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Voice rollback cleanup threw\",\n cleanupError,\n );\n }\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n } else {\n finishDetachedSetup();\n }\n throw error;\n }\n }\n\n private _currentAssistantMsg: ThreadAssistantMessage | null = null;\n\n private _handleVoiceTranscript(\n transcript: RealtimeVoiceAdapter.TranscriptItem,\n ) {\n this.ensureInitialized();\n\n if (transcript.role === \"user\") {\n this._finishVoiceAssistantMessage();\n this._currentAssistantMsg = null;\n\n if (transcript.isFinal) {\n const message: ThreadMessage = {\n id: generateId(),\n role: \"user\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: { modality: \"voice\", custom: {} },\n createdAt: new Date(),\n status: { type: \"complete\", reason: \"unknown\" },\n attachments: [],\n };\n this._voiceMessages.push(message);\n this._commitVoiceMessage(message);\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n } else {\n const status: ThreadAssistantMessage[\"status\"] = transcript.isFinal\n ? { type: \"complete\", reason: \"stop\" }\n : { type: \"running\" };\n\n if (!this._currentAssistantMsg) {\n this._currentAssistantMsg = {\n id: generateId(),\n role: \"assistant\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n modality: \"voice\",\n custom: {},\n },\n status,\n createdAt: new Date(),\n };\n this._voiceMessages.push(this._currentAssistantMsg);\n } else {\n const idx = this._voiceMessages.indexOf(this._currentAssistantMsg);\n if (idx === -1) return;\n const updated: ThreadAssistantMessage = {\n ...this._currentAssistantMsg,\n content: [{ type: \"text\", text: transcript.text }],\n status,\n };\n this._voiceMessages[idx] = updated;\n this._currentAssistantMsg = updated;\n }\n\n if (transcript.isFinal) {\n this._commitVoiceMessage(this._currentAssistantMsg);\n this._currentAssistantMsg = null;\n }\n\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n }\n\n private _finishVoiceAssistantMessage(notify = true) {\n const last = this._voiceMessages.at(-1);\n if (last?.role === \"assistant\" && last.status.type === \"running\") {\n const idx = this._voiceMessages.length - 1;\n this._voiceMessages[idx] = {\n ...(last as ThreadAssistantMessage),\n status: { type: \"complete\", reason: \"stop\" },\n };\n this._commitVoiceMessage(this._voiceMessages[idx]!);\n this._currentAssistantMsg = null;\n this._markVoiceMessagesDirty();\n if (notify) this._notifySubscribers();\n }\n }\n\n public disconnectVoice() {\n this._disconnectVoice(true);\n }\n\n private _disconnectVoice(fireHook: boolean) {\n this._finishVoiceAssistantMessage(false);\n this._currentAssistantMsg = null;\n // Drain the shared list in place so reentrant setup cannot release the same handles again.\n const unsubs = this._voiceUnsubs.splice(0);\n this._voiceUnsubs = [];\n const session = this._voiceSession;\n this._voiceSession = undefined;\n this.voice = undefined;\n this._voiceVolume = 0;\n const stopSpeaking =\n this.speech && this._isVoiceMessage(this.speech.messageId)\n ? this._stopSpeaking\n : undefined;\n this._voiceMessages = [];\n this._markVoiceMessagesDirty();\n\n try {\n notifySubscribers([\n ...unsubs,\n ...(stopSpeaking ? [stopSpeaking] : []),\n ...(session ? [() => session.disconnect()] : []),\n () =>\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n ),\n () => this._notifySubscribers(),\n ]);\n } finally {\n if (fireHook && session && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n }\n }\n\n public muteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.mute();\n this.voice = {\n ...this.voice!,\n isMuted: true,\n };\n this._notifySubscribers();\n }\n\n public unmuteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.unmute();\n this.voice = {\n ...this.voice!,\n isMuted: false,\n };\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\", {});\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this.import(ExportedMessageRepository.fromArray(initialMessages ?? []));\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n public unstable_on<E extends ThreadRuntimeEventType>(\n event: E,\n callback: ThreadRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n if (event === \"modelContextUpdate\") {\n // provider.subscribe is `() => void`; pump the typed empty payload to the user callback.\n return (\n this._contextProvider.subscribe?.(() =>\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`),\n ) ?? (() => {})\n );\n }\n\n let subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n subscribers = new Set();\n this._eventSubscribers.set(event, subscribers);\n }\n subscribers.add(wrapped);\n\n // `initialize` latches: replay it (deferred) to subscribers that attach\n // after the thread already initialized, mirroring a BehaviorSubject.\n if (event === \"initialize\" && this._isInitialized) {\n queueMicrotask(() => {\n if (subscribers.has(wrapped)) {\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`);\n }\n });\n }\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAkDA,IAAsBuC,wBAAtB,cACUP,iBAEV;CACE,iBAAyB;CAEzB,aAAuB,IAAIxB,kBAAkB;CAuB7C,iBAA4C,CAAA;CAC5C,mBAA6B;CAC7B,wBAAiE;CACjE,yBAAiC;CACjC,oBAA6D;CAE7D,0BAAoC;EAClC,KAAK2D;EACL,KAAKC,wBAAwB;CAC/B;CAEA,mBAAuD;EACrD,OAAO,KAAK3B,WAAWgC,YAAY;CACrC;CAEA,oBAA8BE,UAA+B,CAAC;CAE9D,IAAWC,WAAqC;EAC9C,IAAI,KAAKV,eAAeW,WAAW,GACjC,OAAO,KAAKL,iBAAiB;EAE/B,MAAMM,OAAO,KAAKN,iBAAiB;EACnC,IACE,KAAKH,2BAA2B,KAAKF,oBACrC,KAAKG,sBAAsBQ,MAC3B;GACA,MAAMC,iBAAiB,IAAIC,IAAIF,KAAKG,KAAK/B,YAAYA,QAAQgC,EAAE,CAAC;GAChE,KAAKd,wBAAwB,CAC3B,GAAGU,MACH,GAAG,KAAKZ,eAAeiB,QACpBjC,YAAY,CAAC6B,eAAeK,IAAIlC,QAAQgC,EAAE,CAC7C,CAAC;GAEH,KAAKb,y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CAEA,oCAA4B,IAAI9H,IAG9B;CAEF,YACEsB,OACAgD,UACA;EACA,MAAM2D,UAAU3D;EAChB,IAAIhD,UAAU,sBAEZ,OACE,KAAKpC,iBAAiByE,kBACpBtI,qBAAqB,CAAC4M,OAAO,GAAG,CAAC,GAAG,mBAAmB3G,MAAK,EAAG,CACjE,YAAY,CAAC;EAIjB,IAAIG,cAAc,KAAKC,kBAAkBxB,IAAIoB,KAAK;EAClD,IAAI,CAACG,aAAa;GAChBA,8BAAc,IAAIlD,IAAI;GACtB,KAAKmD,kBAAkBjB,IAAIa,OAAOG,WAAW;EAC/C;EACAA,YAAY8C,IAAI0D,OAAO;EAIvB,IAAI3G,UAAU,gBAAgB,KAAKvF,gBACjCmM,qBAAqB;GACnB,IAAIzG,YAAY9C,IAAIsJ,OAAO,GACzB5M,qBAAqB,CAAC4M,OAAO,GAAG,CAAC,GAAG,mBAAmB3G,MAAK,EAAG;EAEnE,CAAC;EAGH,aAAa;GACX,KAAKI,kBAAkBxB,IAAIoB,KAAK,CAAC,EAAEZ,OAAOuH,OAAO;EACnD;CACF;AACF"}
|
|
@@ -5,7 +5,7 @@ import { SendOptions } from "../interfaces/composer-runtime-core.js";
|
|
|
5
5
|
import { ThreadRuntimeCore } from "../interfaces/thread-runtime-core.js";
|
|
6
6
|
import { BaseComposerRuntimeCore } from "./base-composer-runtime-core.js";
|
|
7
7
|
//#region src/runtime/base/default-edit-composer-runtime-core.d.ts
|
|
8
|
-
declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
8
|
+
export declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
9
9
|
get canCancel(): boolean;
|
|
10
10
|
get canSend(): boolean;
|
|
11
11
|
protected getAttachmentAdapter(): AttachmentAdapter | undefined;
|
|
@@ -30,5 +30,4 @@ declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
30
30
|
handleCancel(): void;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
-
export { DefaultEditComposerRuntimeCore };
|
|
34
33
|
//# sourceMappingURL=default-edit-composer-runtime-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-edit-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"default-edit-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"mappings":";;;;;;;qBAUa,uCAAuC;MACvC;MAIA;YAID,wBAAoB;YAIpB,uBAAmB;UAIrB;UACA;UACA;UACA;UAQA;EAGN,YAAA,SAAS;IACP;MAEM,cAAc;MACd,YAAY;;KAIpB,+BACE,UAAU;IAAa;IAAyB,SAAS;;MAuClD;MAIA;EAIE,WACX,SAAS,KAAK,yCACd,UAAU,cAAW;EAqBhB"}
|
|
@@ -7,7 +7,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
get canSend() {
|
|
10
|
-
return !this.isEmpty && !this._isSending;
|
|
10
|
+
return !this.isEmpty && !this.runtime.voice && !this._isSending;
|
|
11
11
|
}
|
|
12
12
|
getAttachmentAdapter() {
|
|
13
13
|
return this.runtime.adapters?.attachments;
|
|
@@ -23,7 +23,17 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
23
23
|
constructor(runtime, endEditCallback, { parentId, message }) {
|
|
24
24
|
super();
|
|
25
25
|
this.runtime = runtime;
|
|
26
|
-
|
|
26
|
+
let lastHasVoice = runtime.voice !== void 0;
|
|
27
|
+
const unsubscribe = runtime.subscribe(() => {
|
|
28
|
+
const hasVoice = runtime.voice !== void 0;
|
|
29
|
+
if (hasVoice === lastHasVoice) return;
|
|
30
|
+
lastHasVoice = hasVoice;
|
|
31
|
+
this._notifySubscribers();
|
|
32
|
+
});
|
|
33
|
+
this.endEditCallback = () => {
|
|
34
|
+
unsubscribe();
|
|
35
|
+
endEditCallback();
|
|
36
|
+
};
|
|
27
37
|
this._parentId = parentId;
|
|
28
38
|
this._sourceId = message.id;
|
|
29
39
|
this.setText(getThreadMessageText(message));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","liftNonTextParts","AttachmentAdapter","DictationAdapter","SendOptions","ThreadRuntimeCore","BaseComposerRuntimeCore","DefaultEditComposerRuntimeCore","canCancel","canSend","isEmpty","
|
|
1
|
+
{"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","liftNonTextParts","AttachmentAdapter","DictationAdapter","SendOptions","ThreadRuntimeCore","BaseComposerRuntimeCore","DefaultEditComposerRuntimeCore","canCancel","canSend","isEmpty","runtime","voice","_isSending","getAttachmentAdapter","adapters","attachments","getDictationAdapter","dictation","_nonTextPassthrough","_parentId","_sourceId","endEditCallback","constructor","parentId","message","lastHasVoice","undefined","unsubscribe","subscribe","hasVoice","_notifySubscribers","id","setText","setRole","role","content","filter","p","type","setAttachments","setRunConfig","composer","runConfig","sourceId","handleSend","Omit","options","length","appendTask","append","startRun","handleCancel"],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage, ThreadMessage } from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { liftNonTextParts } from \"../../adapters/attachment\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { SendOptions } from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n public get canSend() {\n return !this.isEmpty && !this.runtime.voice && !this._isSending;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n protected getDictationAdapter() {\n return this.runtime.adapters?.dictation;\n }\n\n private _nonTextPassthrough: readonly ThreadMessage[\"content\"][number][];\n private _parentId: string | null;\n private _sourceId: string | null;\n private runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n };\n private endEditCallback: () => void;\n\n constructor(\n runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n },\n endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this.runtime = runtime;\n let lastHasVoice = runtime.voice !== undefined;\n const unsubscribe = runtime.subscribe(() => {\n const hasVoice = runtime.voice !== undefined;\n if (hasVoice === lastHasVoice) return;\n lastHasVoice = hasVoice;\n this._notifySubscribers();\n });\n this.endEditCallback = () => {\n unsubscribe();\n endEditCallback();\n };\n this._parentId = parentId;\n this._sourceId = message.id;\n this.setText(getThreadMessageText(message));\n\n this.setRole(message.role);\n\n let attachments: readonly CompleteAttachment[];\n if (message.role === \"user\") {\n attachments = [\n ...(message.attachments ?? []),\n ...liftNonTextParts(message.content),\n ];\n this._nonTextPassthrough = [];\n } else {\n attachments = message.attachments ?? [];\n this._nonTextPassthrough = message.content.filter(\n (p) => p.type !== \"text\",\n );\n }\n this.setAttachments(attachments);\n\n this.setRunConfig({ ...runtime.composer.runConfig });\n }\n\n public get parentId() {\n return this._parentId;\n }\n\n public get sourceId() {\n return this._sourceId;\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ) {\n const content =\n this._nonTextPassthrough.length > 0\n ? ([\n ...message.content,\n ...this._nonTextPassthrough,\n ] as AppendMessage[\"content\"])\n : message.content;\n const appendTask = this.runtime.append({\n ...message,\n content,\n parentId: this._parentId,\n sourceId: this._sourceId,\n startRun: options?.startRun,\n });\n\n this.handleCancel();\n return appendTask;\n }\n\n public handleCancel() {\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;AAUA,IAAaU,iCAAb,cAAoDD,wBAAwB;CAC1E,IAAWE,YAAY;EACrB,OAAO;CACT;CAEA,IAAWC,UAAU;EACnB,OAAO,CAAC,KAAKC,WAAW,CAAC,KAAKC,QAAQC,SAAS,CAAC,KAAKC;CACvD;CAEA,uBAAiC;EAC/B,OAAO,KAAKF,QAAQI,UAAUC;CAChC;CAEA,sBAAgC;EAC9B,OAAO,KAAKL,QAAQI,UAAUG;CAChC;CAEA;CACA;CACA;CACA;CAQA;CAEAK,YACEZ,SAQAW,iBACA,EAAEE,UAAUC,WACZ;EACA,MAAM;EACN,KAAKd,UAAUA;EACf,IAAIe,eAAef,QAAQC,UAAUe,KAAAA;EACrC,MAAMC,cAAcjB,QAAQkB,gBAAgB;GAC1C,MAAMC,WAAWnB,QAAQC,UAAUe,KAAAA;GACnC,IAAIG,aAAaJ,cAAc;GAC/BA,eAAeI;GACf,KAAKC,mBAAmB;EAC1B,CAAC;EACD,KAAKT,wBAAwB;GAC3BM,YAAY;GACZN,gBAAgB;EAClB;EACA,KAAKF,YAAYI;EACjB,KAAKH,YAAYI,QAAQO;EACzB,KAAKC,QAAQjC,qBAAqByB,OAAO,CAAC;EAE1C,KAAKS,QAAQT,QAAQU,IAAI;EAEzB,IAAInB;EACJ,IAAIS,QAAQU,SAAS,QAAQ;GAC3BnB,cAAc,CACZ,GAAIS,QAAQT,eAAe,CAAA,GAC3B,GAAGf,iBAAiBwB,QAAQW,OAAO,CAAC;GAEtC,KAAKjB,sBAAsB,CAAA;EAC7B,OAAO;GACLH,cAAcS,QAAQT,eAAe,CAAA;GACrC,KAAKG,sBAAsBM,QAAQW,QAAQC,QACxCC,MAAMA,EAAEC,SAAS,MACpB;EACF;EACA,KAAKC,eAAexB,WAAW;EAE/B,KAAKyB,aAAa,EAAE,GAAG9B,QAAQ+B,SAASC,UAAU,CAAC;CACrD;CAEA,IAAWnB,WAAW;EACpB,OAAO,KAAKJ;CACd;CAEA,IAAWwB,WAAW;EACpB,OAAO,KAAKvB;CACd;CAEA,MAAawB,WACXpB,SACAsB,SACA;EACA,MAAMX,UACJ,KAAKjB,oBAAoB6B,SAAS,IAC7B,CACC,GAAGvB,QAAQW,SACX,GAAG,KAAKjB,mBAAmB,IAE7BM,QAAQW;EACd,MAAMa,aAAa,KAAKtC,QAAQuC,OAAO;GACrC,GAAGzB;GACHW;GACAZ,UAAU,KAAKJ;GACfwB,UAAU,KAAKvB;GACf8B,UAAUJ,SAASI;EACrB,CAAC;EAED,KAAKC,aAAa;EAClB,OAAOH;CACT;CAEA,eAAsB;EACpB,KAAK3B,gBAAgB;EACrB,KAAKS,mBAAmB;CAC1B;AACF"}
|
|
@@ -9,7 +9,7 @@ import { ThreadRuntimeCore } from "../interfaces/thread-runtime-core.js";
|
|
|
9
9
|
import { BaseComposerRuntimeCore } from "./base-composer-runtime-core.js";
|
|
10
10
|
import "../../index.js";
|
|
11
11
|
//#region src/runtime/base/default-thread-composer-runtime-core.d.ts
|
|
12
|
-
declare class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore implements ThreadComposerRuntimeCore {
|
|
12
|
+
export declare class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore implements ThreadComposerRuntimeCore {
|
|
13
13
|
get canCancel(): boolean;
|
|
14
14
|
get canSend(): boolean;
|
|
15
15
|
private _queueCache;
|
|
@@ -30,5 +30,4 @@ declare class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore i
|
|
|
30
30
|
handleCancel(): Promise<void>;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
-
export { DefaultThreadComposerRuntimeCore };
|
|
34
33
|
//# sourceMappingURL=default-thread-composer-runtime-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-thread-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-thread-composer-runtime-core.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"default-thread-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-thread-composer-runtime-core.ts"],"mappings":";;;;;;;;;;;qBAmBa,yCACH,mCACG;MAEA;MAIA;UASH;MAQY,kBAAkB;EAgBtB,cACd,qBACA,WAAW;EAKG,gBAAgB;YAItB,wBAAoB;YAIpB,uBAAmB;UAIrB;EAUN,YAAA,SAAS,KAAK;IACZ;MAEM,cAAc;MACd,YAAY;;;EAUf,WAVe;EAuCT,WACX,SAAS,KAAK,yCACd,UAAU,cAAW;EAWV,gBAAY"}
|
|
@@ -11,7 +11,7 @@ var DefaultThreadComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
11
11
|
return isCancelable(this.runtime);
|
|
12
12
|
}
|
|
13
13
|
get canSend() {
|
|
14
|
-
return !this.isEmpty && !this.runtime.isSendDisabled && !this._isSending;
|
|
14
|
+
return !this.isEmpty && !this.runtime.isSendDisabled && !this.runtime.voice && !this._isSending;
|
|
15
15
|
}
|
|
16
16
|
_queueCache;
|
|
17
17
|
get queue() {
|
|
@@ -48,6 +48,7 @@ var DefaultThreadComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
48
48
|
connect() {
|
|
49
49
|
let lastCanCancel = false;
|
|
50
50
|
let lastIsSendDisabled = this.runtime.isSendDisabled;
|
|
51
|
+
let lastHasVoice = this.runtime.voice !== void 0;
|
|
51
52
|
let lastQueue = this.queue;
|
|
52
53
|
return this.runtime.subscribe(() => {
|
|
53
54
|
let changed = false;
|
|
@@ -60,6 +61,11 @@ var DefaultThreadComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
60
61
|
lastIsSendDisabled = this.runtime.isSendDisabled;
|
|
61
62
|
changed = true;
|
|
62
63
|
}
|
|
64
|
+
const hasVoice = this.runtime.voice !== void 0;
|
|
65
|
+
if (lastHasVoice !== hasVoice) {
|
|
66
|
+
lastHasVoice = hasVoice;
|
|
67
|
+
changed = true;
|
|
68
|
+
}
|
|
63
69
|
if (lastQueue !== this.queue) {
|
|
64
70
|
lastQueue = this.queue;
|
|
65
71
|
changed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-thread-composer-runtime-core.js","names":["AppendMessage","AttachmentAdapter","DictationAdapter","SendOptions","ThreadComposerRuntimeCore","ThreadRuntimeCore","getThreadRuntimeCoreIsRunning","QueuePlacement","EMPTY_QUEUE_ITEMS","QueueItemState","BaseComposerRuntimeCore","isCancelable","runtime","Omit","capabilities","cancel","DefaultThreadComposerRuntimeCore","canCancel","canSend","isEmpty","isSendDisabled","_isSending","_queueCache","steer","queue","flat","getSteerQueueItems","getQueueItems","cache","length","moveQueueItem","queueItemId","placement","removeQueueItem","getAttachmentAdapter","adapters","attachments","getDictationAdapter","dictation","constructor","connect","lastCanCancel","lastIsSendDisabled","lastQueue","subscribe","changed","nextCanCancel","_notifySubscribers","handleSend","message","options","append","parentId","messages","at","id","sourceId","startRun","handleCancel","cancelRun"],"sources":["../../../src/runtime/base/default-thread-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage } from \"../../types/message\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type {\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { getThreadRuntimeCoreIsRunning } from \"../api/thread-runtime\";\nimport type { QueuePlacement } from \"../queue/external-thread-queue-adapter\";\nimport { EMPTY_QUEUE_ITEMS, type QueueItemState } from \"../queue/queue-item\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\n\nconst isCancelable = (runtime: Omit<ThreadRuntimeCore, \"composer\">) => {\n // capabilities is a subclass field assigned after this composer is constructed\n if (!runtime.capabilities?.cancel) return false;\n return getThreadRuntimeCoreIsRunning(runtime);\n};\n\nexport class DefaultThreadComposerRuntimeCore\n extends BaseComposerRuntimeCore\n implements ThreadComposerRuntimeCore\n{\n public get canCancel() {\n return isCancelable(this.runtime);\n }\n\n public get canSend() {\n return !this.isEmpty
|
|
1
|
+
{"version":3,"file":"default-thread-composer-runtime-core.js","names":["AppendMessage","AttachmentAdapter","DictationAdapter","SendOptions","ThreadComposerRuntimeCore","ThreadRuntimeCore","getThreadRuntimeCoreIsRunning","QueuePlacement","EMPTY_QUEUE_ITEMS","QueueItemState","BaseComposerRuntimeCore","isCancelable","runtime","Omit","capabilities","cancel","DefaultThreadComposerRuntimeCore","canCancel","canSend","isEmpty","isSendDisabled","voice","_isSending","_queueCache","steer","queue","flat","getSteerQueueItems","getQueueItems","cache","length","moveQueueItem","queueItemId","placement","removeQueueItem","getAttachmentAdapter","adapters","attachments","getDictationAdapter","dictation","constructor","connect","lastCanCancel","lastIsSendDisabled","lastHasVoice","undefined","lastQueue","subscribe","changed","nextCanCancel","hasVoice","_notifySubscribers","handleSend","message","options","append","parentId","messages","at","id","sourceId","startRun","handleCancel","cancelRun"],"sources":["../../../src/runtime/base/default-thread-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage } from \"../../types/message\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type {\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { getThreadRuntimeCoreIsRunning } from \"../api/thread-runtime\";\nimport type { QueuePlacement } from \"../queue/external-thread-queue-adapter\";\nimport { EMPTY_QUEUE_ITEMS, type QueueItemState } from \"../queue/queue-item\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\n\nconst isCancelable = (runtime: Omit<ThreadRuntimeCore, \"composer\">) => {\n // capabilities is a subclass field assigned after this composer is constructed\n if (!runtime.capabilities?.cancel) return false;\n return getThreadRuntimeCoreIsRunning(runtime);\n};\n\nexport class DefaultThreadComposerRuntimeCore\n extends BaseComposerRuntimeCore\n implements ThreadComposerRuntimeCore\n{\n public get canCancel() {\n return isCancelable(this.runtime);\n }\n\n public get canSend() {\n return (\n !this.isEmpty &&\n !this.runtime.isSendDisabled &&\n !this.runtime.voice &&\n !this._isSending\n );\n }\n\n private _queueCache:\n | {\n steer: readonly QueueItemState[];\n queue: readonly QueueItemState[];\n flat: readonly QueueItemState[];\n }\n | undefined;\n\n public override get queue(): readonly QueueItemState[] {\n const steer = this.runtime.getSteerQueueItems?.() ?? EMPTY_QUEUE_ITEMS;\n const queue = this.runtime.getQueueItems?.() ?? EMPTY_QUEUE_ITEMS;\n const cache = this._queueCache;\n if (cache && cache.steer === steer && cache.queue === queue)\n return cache.flat;\n const flat =\n steer.length === 0\n ? queue\n : queue.length === 0\n ? steer\n : [...steer, ...queue];\n this._queueCache = { steer, queue, flat };\n return flat;\n }\n\n public override moveQueueItem(\n queueItemId: string,\n placement: QueuePlacement,\n ): void {\n this.runtime.moveQueueItem?.(queueItemId, placement);\n }\n\n public override removeQueueItem(queueItemId: string): void {\n this.runtime.removeQueueItem?.(queueItemId);\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n protected getDictationAdapter() {\n return this.runtime.adapters?.dictation;\n }\n\n private runtime: Omit<ThreadRuntimeCore, \"composer\"> & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n };\n\n constructor(\n runtime: Omit<ThreadRuntimeCore, \"composer\"> & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n },\n ) {\n super();\n this.runtime = runtime;\n this.connect();\n }\n\n public connect() {\n let lastCanCancel = false;\n let lastIsSendDisabled = this.runtime.isSendDisabled;\n let lastHasVoice = this.runtime.voice !== undefined;\n let lastQueue = this.queue;\n return this.runtime.subscribe(() => {\n let changed = false;\n const nextCanCancel = this.canCancel;\n if (lastCanCancel !== nextCanCancel) {\n lastCanCancel = nextCanCancel;\n changed = true;\n }\n if (lastIsSendDisabled !== this.runtime.isSendDisabled) {\n lastIsSendDisabled = this.runtime.isSendDisabled;\n changed = true;\n }\n const hasVoice = this.runtime.voice !== undefined;\n if (lastHasVoice !== hasVoice) {\n lastHasVoice = hasVoice;\n changed = true;\n }\n if (lastQueue !== this.queue) {\n lastQueue = this.queue;\n changed = true;\n }\n if (changed) this._notifySubscribers();\n });\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ) {\n return this.runtime.append({\n ...(message as AppendMessage),\n parentId: this.runtime.messages.at(-1)?.id ?? null,\n sourceId: null,\n startRun: options?.startRun,\n steer: options?.steer,\n });\n }\n\n public async handleCancel() {\n this.runtime.cancelRun();\n }\n}\n"],"mappings":";;;;AAaA,MAAMW,gBAAgBC,YAAiD;CAErE,IAAI,CAACA,QAAQE,cAAcC,QAAQ,OAAO;CAC1C,OAAOT,8BAA8BM,OAAO;AAC9C;AAEA,IAAaI,mCAAb,cACUN,wBAEV;CACE,IAAWO,YAAY;EACrB,OAAON,aAAa,KAAKC,OAAO;CAClC;CAEA,IAAWM,UAAU;EACnB,OACE,CAAC,KAAKC,WACN,CAAC,KAAKP,QAAQQ,kBACd,CAAC,KAAKR,QAAQS,SACd,CAAC,KAAKC;CAEV;CAEA;CAQA,IAAoBG,QAAmC;EACrD,MAAMD,QAAQ,KAAKZ,QAAQe,qBAAqB,KAAKnB;EACrD,MAAMiB,QAAQ,KAAKb,QAAQgB,gBAAgB,KAAKpB;EAChD,MAAMqB,QAAQ,KAAKN;EACnB,IAAIM,SAASA,MAAML,UAAUA,SAASK,MAAMJ,UAAUA,OACpD,OAAOI,MAAMH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AAU,KAAK5C,QAAQ6C,SAASC,GAAG,EAAE,CAAC,EAAEC,MAAM;GAC9CC,UAAU;GACVC,UAAUP,SAASO;GACnBrC,OAAO8B,SAAS9B;EAClB,CAAC;CACH;CAEA,MAAasC,eAAe;EAC1B,KAAKlD,QAAQmD,UAAU;CACzB;AACF"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* payload carries the edited message's own id as both `parentId` and
|
|
10
10
|
* `sourceId`.
|
|
11
11
|
*/
|
|
12
|
-
type ExternalThreadBranchAdapter = {
|
|
12
|
+
export type ExternalThreadBranchAdapter = {
|
|
13
13
|
/**
|
|
14
14
|
* Returns the sibling branch ids for a message in display order, including
|
|
15
15
|
* the message's own id. Return an empty array for messages without
|
|
@@ -26,5 +26,4 @@ type ExternalThreadBranchAdapter = {
|
|
|
26
26
|
switchToBranch: (branchId: string) => void;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
-
export { ExternalThreadBranchAdapter };
|
|
30
29
|
//# sourceMappingURL=external-thread-branch-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-thread-branch-adapter.d.ts","names":[],"sources":["../../../src/runtime/branch/external-thread-branch-adapter.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"external-thread-branch-adapter.d.ts","names":[],"sources":["../../../src/runtime/branch/external-thread-branch-adapter.ts"],"mappings":";;;;;;;;;;;YAUY;;;;;;EAMV,cAAc;;;;;;;;EAQd,iBAAiB"}
|
|
@@ -2,12 +2,11 @@ import { Unsubscribe } from "../../types/unsubscribe.js";
|
|
|
2
2
|
import { ModelContextProvider } from "../../model-context/types.js";
|
|
3
3
|
import { ThreadListRuntimeCore } from "./thread-list-runtime-core.js";
|
|
4
4
|
//#region src/runtime/interfaces/assistant-runtime-core.d.ts
|
|
5
|
-
type AssistantRuntimeCore = {
|
|
5
|
+
export type AssistantRuntimeCore = {
|
|
6
6
|
readonly threads: ThreadListRuntimeCore;
|
|
7
7
|
registerModelContextProvider: (provider: ModelContextProvider) => Unsubscribe;
|
|
8
8
|
getModelContextProvider: () => ModelContextProvider;
|
|
9
9
|
readonly RenderComponent?: ((...args: any[]) => unknown) | undefined;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
|
-
export { AssistantRuntimeCore };
|
|
13
12
|
//# sourceMappingURL=assistant-runtime-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/interfaces/assistant-runtime-core.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"assistant-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/interfaces/assistant-runtime-core.ts"],"mappings":";;;;YAIY;WACD,SAAS;EAElB,+BAA+B,UAAU,yBAAyB;EAClE,+BAA+B;WAEtB,uBAAuB"}
|