@assistant-ui/core 0.2.12 → 0.2.15
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.js.map +1 -1
- package/dist/adapters/directive-formatter.js.map +1 -1
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +3 -1
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/duplicate-detection.js.map +1 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +2 -1
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.js.map +1 -1
- package/dist/model-context/registry.js.map +1 -1
- package/dist/model-context/tool.js.map +1 -1
- package/dist/model-context/types.d.ts +1 -0
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/AssistantProvider.js +7 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/AssistantRuntimeProvider.js +18 -6
- package/dist/react/AssistantRuntimeProvider.js.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +1 -1
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.js +35 -6
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +29 -7
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/adapters/TitleGenerationAdapter.js.map +1 -1
- package/dist/react/client/DataRenderers.d.ts +1 -8
- package/dist/react/client/DataRenderers.d.ts.map +1 -1
- package/dist/react/client/DataRenderers.js +56 -36
- package/dist/react/client/DataRenderers.js.map +1 -1
- package/dist/react/client/Interactables.d.ts +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +71 -70
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +2 -13
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +121 -57
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/client/interactable-model-context.js.map +1 -1
- package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
- package/dist/react/model-context/define-toolkit.js.map +1 -1
- package/dist/react/model-context/external-tool.js.map +1 -1
- package/dist/react/model-context/human-tool.js.map +1 -1
- package/dist/react/model-context/makeAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/makeAssistantTool.js.map +1 -1
- package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/provider-tool.js.map +1 -1
- package/dist/react/model-context/stub-tool.js.map +1 -1
- package/dist/react/model-context/toolbox.js.map +1 -1
- package/dist/react/model-context/useAssistantContext.js.map +1 -1
- package/dist/react/model-context/useAssistantDataUI.js +27 -8
- package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
- package/dist/react/model-context/useAssistantInstructions.js +33 -10
- package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
- package/dist/react/model-context/useAssistantTool.js +59 -17
- package/dist/react/model-context/useAssistantTool.js.map +1 -1
- package/dist/react/model-context/useAssistantToolUI.js +30 -9
- package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
- package/dist/react/model-context/useInlineRender.js +35 -8
- package/dist/react/model-context/useInlineRender.js.map +1 -1
- package/dist/react/model-context/useInteractableState.js +65 -19
- package/dist/react/model-context/useInteractableState.js.map +1 -1
- package/dist/react/model-context/useToolArgsStatus.js +42 -14
- package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +59 -22
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.js +25 -7
- package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarFeedback.js +49 -13
- package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.js +25 -7
- package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.js +28 -9
- package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +25 -7
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +27 -11
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.js +24 -8
- package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.js +25 -7
- package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerDictate.js +25 -7
- package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerCancel.js +18 -4
- package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useEditComposerSend.js +25 -7
- package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageBranching.js +41 -9
- package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageError.js +4 -1
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
- package/dist/react/primitive-hooks/useMessageReload.js +25 -7
- package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +31 -13
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js +4 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemArchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemDelete.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +18 -4
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +25 -7
- package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListNew.js +18 -4
- package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadMessages.js +4 -1
- package/dist/react/primitive-hooks/useThreadMessages.js.map +1 -1
- package/dist/react/primitive-hooks/useVoice.js +63 -13
- package/dist/react/primitive-hooks/useVoice.js.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +42 -7
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +67 -16
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.js +30 -9
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.js +55 -13
- package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +68 -16
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +6 -6
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +28 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +665 -163
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.js +18 -2
- package/dist/react/primitives/message/MessageQuote.js.map +1 -1
- package/dist/react/primitives/messagePart/MessagePartInProgress.js +6 -2
- package/dist/react/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.js +46 -14
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +67 -10
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +50 -10
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +55 -14
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +15 -2
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/react/providers/AttachmentByIndexProvider.js +57 -12
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +33 -11
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +29 -6
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/MessageByIndexProvider.js +49 -19
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +29 -6
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/providers/QueueItemByIndexProvider.js +29 -6
- package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.js +83 -28
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
- package/dist/react/providers/SuggestionByIndexProvider.js +29 -6
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +75 -26
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemByIndexProvider.js +30 -6
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +28 -5
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +19 -4
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js +27 -10
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +16 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +19 -17
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +67 -30
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +44 -10
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.js +17 -12
- package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useRemoteThreadListRuntime.js +34 -6
- package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +5 -6
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.js.map +1 -1
- package/dist/react/utils/groupParts.d.ts +13 -1
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +17 -5
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/runtime/api/assistant-runtime.js.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +1 -0
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +3 -9
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +3 -6
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +2 -0
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +5 -0
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +1 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +3 -0
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +4 -0
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
- package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
- package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +15 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js +35 -0
- package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.d.ts +5 -1
- 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/runtimes/assistant-transport/utils.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -0
- 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 +13 -0
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.js.map +1 -1
- package/dist/runtimes/local/local-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +9 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +65 -5
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/should-continue.js +4 -2
- package/dist/runtimes/local/should-continue.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/chain-of-thought-client.js +39 -20
- package/dist/store/clients/chain-of-thought-client.js.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.js +67 -16
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +2 -4
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.js +96 -54
- package/dist/store/clients/no-op-composer-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +1 -3
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +2 -15
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts +1 -4
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +63 -23
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +184 -73
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/internal.d.ts +2 -2
- package/dist/store/internal.js +2 -2
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.js +31 -7
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +195 -72
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/liveRef.d.ts +7 -0
- package/dist/store/runtime-clients/liveRef.d.ts.map +1 -0
- package/dist/store/runtime-clients/liveRef.js +8 -0
- package/dist/store/runtime-clients/liveRef.js.map +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +49 -9
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +220 -54
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +71 -26
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +141 -36
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +196 -72
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/useSubscribable.js +2 -9
- package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
- package/dist/store/scopes/message.d.ts +1 -0
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +5 -6
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +1 -0
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +1 -0
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/types/message.d.ts +38 -5
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/json/is-json-equal.js.map +1 -1
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/text.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/thread-history.ts +2 -0
- package/src/index.ts +5 -0
- package/src/internal.ts +1 -0
- package/src/model-context/types.ts +1 -0
- package/src/react/AssistantProvider.tsx +10 -1
- package/src/react/RuntimeAdapter.ts +25 -8
- package/src/react/client/DataRenderers.ts +42 -45
- package/src/react/client/Interactables.ts +261 -261
- package/src/react/client/Tools.ts +9 -9
- package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
- package/src/react/primitives/message/MessageParts.tsx +64 -13
- package/src/react/providers/TextMessagePartProvider.tsx +5 -3
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
- package/src/react/runtimes/external-message-converter.ts +3 -1
- package/src/react/types/MessagePartComponentTypes.ts +5 -5
- package/src/react/utils/groupParts.ts +27 -0
- package/src/runtime/api/bindings.ts +1 -0
- package/src/runtime/api/message-part-runtime.ts +14 -11
- package/src/runtime/api/message-runtime.ts +7 -0
- package/src/runtime/api/thread-list-runtime.ts +1 -0
- package/src/runtime/api/thread-runtime.ts +7 -0
- package/src/runtime/base/base-thread-runtime-core.ts +1 -0
- package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
- package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +4 -0
- package/src/runtime/utils/resolveToolApprovalResponse.test.ts +91 -0
- package/src/runtime/utils/resolveToolApprovalResponse.ts +55 -0
- package/src/runtime/utils/thread-message-like.ts +10 -1
- package/src/runtimes/external-store/external-store-adapter.ts +1 -0
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
- package/src/runtimes/local/local-runtime-options.ts +1 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +370 -0
- package/src/runtimes/local/local-thread-runtime-core.ts +113 -7
- package/src/runtimes/local/should-continue.ts +24 -13
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
- package/src/runtimes/remote-thread-list/types.ts +1 -0
- package/src/store/clients/chain-of-thought-client.ts +5 -3
- package/src/store/clients/model-context-client.test.ts +5 -4
- package/src/store/clients/model-context-client.ts +21 -21
- package/src/store/clients/no-op-composer-client.ts +5 -3
- package/src/store/clients/runtime-adapter.ts +0 -24
- package/src/store/clients/suggestions.ts +12 -23
- package/src/store/clients/thread-message-client.ts +42 -40
- package/src/store/internal.ts +1 -4
- package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
- package/src/store/runtime-clients/composer-runtime-client.ts +48 -45
- package/src/store/runtime-clients/liveRef.ts +5 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
- package/src/store/runtime-clients/message-runtime-client.ts +42 -40
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
- package/src/store/runtime-clients/thread-list-runtime-client.ts +13 -11
- package/src/store/runtime-clients/thread-runtime-client.ts +20 -16
- package/src/store/runtime-clients/useSubscribable.ts +2 -10
- package/src/store/scopes/message.ts +1 -0
- package/src/store/scopes/part.ts +5 -2
- package/src/store/scopes/thread-list-item.ts +1 -0
- package/src/store/scopes/thread.ts +1 -0
- package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
- package/src/tests/groupMessageParts.test.ts +84 -0
- package/src/tests/groupParts.test.ts +55 -0
- package/src/types/message.ts +45 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-converter.js","names":[],"sources":["../../../src/runtimes/external-store/thread-message-converter.ts"],"sourcesContent":["import type { ThreadMessage } from \"../../types/message\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: readonly TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":";AAQA,
|
|
1
|
+
{"version":3,"file":"thread-message-converter.js","names":["ThreadMessage","ConverterCallback","cache","message","TIn","idx","ThreadMessageConverter","WeakMap","WeakKey","convertMessages","messages","converter","map","m","cached","get","newMessage","set"],"sources":["../../../src/runtimes/external-store/thread-message-converter.ts"],"sourcesContent":["import type { ThreadMessage } from \"../../types/message\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: readonly TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":";AAQA,IAAaM,yBAAb,MAAoC;CAClC,wBAAyB,IAAIC,QAAgC;CAE7DE,gBACEC,UACAC,WACiB;EACjB,OAAOD,SAASE,KAAKC,GAAGR,QAAQ;GAE9B,MAAMW,aAAaL,UADJ,KAAKT,MAAMa,IAAIF,CACDC,GAAQD,GAAGR,GAAG;GAC3C,KAAKH,MAAMe,IAAIJ,GAAGG,UAAU;GAC5B,OAAOA;EACT,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-runtime-core.js","names":[],"sources":["../../../src/runtimes/local/local-runtime-core.ts"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { LocalThreadRuntimeCore } from \"./local-thread-runtime-core\";\nimport type { LocalRuntimeOptionsBase } from \"./local-runtime-options\";\nimport { LocalThreadListRuntimeCore } from \"./local-thread-list-runtime-core\";\nimport { ExportedMessageRepository } from \"../../runtime/utils/message-repository\";\nimport type { ThreadMessageLike } from \"../../runtime/utils/thread-message-like\";\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threads;\n public readonly Provider = undefined;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly ThreadMessageLike[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threads = new LocalThreadListRuntimeCore(() => {\n return new LocalThreadRuntimeCore(this._contextProvider, this._options);\n });\n\n if (initialMessages) {\n this.threads\n .getMainThreadRuntimeCore()\n .import(ExportedMessageRepository.fromArray(initialMessages));\n }\n }\n}\n"],"mappings":";;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"local-runtime-core.js","names":["BaseAssistantRuntimeCore","LocalThreadRuntimeCore","LocalRuntimeOptionsBase","LocalThreadListRuntimeCore","ExportedMessageRepository","ThreadMessageLike","LocalRuntimeCore","threads","Provider","undefined","_options","constructor","options","initialMessages","_contextProvider","getMainThreadRuntimeCore","import","fromArray"],"sources":["../../../src/runtimes/local/local-runtime-core.ts"],"sourcesContent":["import { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { LocalThreadRuntimeCore } from \"./local-thread-runtime-core\";\nimport type { LocalRuntimeOptionsBase } from \"./local-runtime-options\";\nimport { LocalThreadListRuntimeCore } from \"./local-thread-list-runtime-core\";\nimport { ExportedMessageRepository } from \"../../runtime/utils/message-repository\";\nimport type { ThreadMessageLike } from \"../../runtime/utils/thread-message-like\";\n\nexport class LocalRuntimeCore extends BaseAssistantRuntimeCore {\n public readonly threads;\n public readonly Provider = undefined;\n\n private _options: LocalRuntimeOptionsBase;\n\n constructor(\n options: LocalRuntimeOptionsBase,\n initialMessages: readonly ThreadMessageLike[] | undefined,\n ) {\n super();\n\n this._options = options;\n\n this.threads = new LocalThreadListRuntimeCore(() => {\n return new LocalThreadRuntimeCore(this._contextProvider, this._options);\n });\n\n if (initialMessages) {\n this.threads\n .getMainThreadRuntimeCore()\n .import(ExportedMessageRepository.fromArray(initialMessages));\n }\n }\n}\n"],"mappings":";;;;;AAOA,IAAaM,mBAAb,cAAsCN,yBAAyB;CAC7D;CACA,WAA2BS,KAAAA;CAE3B;CAEAE,YACEC,SACAC,iBACA;EACA,MAAM;EAEN,KAAKH,WAAWE;EAEhB,KAAKL,UAAU,IAAIJ,iCAAiC;GAClD,OAAO,IAAIF,uBAAuB,KAAKa,kBAAkB,KAAKJ,QAAQ;EACxE,CAAC;EAED,IAAIG,iBACF,KAAKN,QACFQ,yBAAyB,CAAC,CAC1BC,OAAOZ,0BAA0Ba,UAAUJ,eAAe,CAAC;CAElE;AACF"}
|
|
@@ -20,7 +20,7 @@ type LocalRuntimeOptionsBase = {
|
|
|
20
20
|
suggestion?: SuggestionAdapter | undefined;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* Names of tools that
|
|
23
|
+
* Names of tools that pause the run until a result is supplied via `addToolResult`.
|
|
24
24
|
*/
|
|
25
25
|
unstable_humanToolNames?: string[] | undefined;
|
|
26
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-thread-list-runtime-core.js","names":[],"sources":["../../../src/runtimes/local/local-thread-list-runtime-core.ts"],"sourcesContent":["import type { ThreadListRuntimeCore } from \"../../runtime/interfaces/thread-list-runtime-core\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport type { LocalThreadRuntimeCore } from \"./local-thread-runtime-core\";\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"__DEFAULT_ID__\";\nconst DEFAULT_THREAD_DATA = Object.freeze({\n [DEFAULT_THREAD_ID]: {\n id: DEFAULT_THREAD_ID,\n remoteId: undefined,\n externalId: undefined,\n status: \"regular\" as const,\n title: undefined,\n },\n});\nexport class LocalThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _mainThread: LocalThreadRuntimeCore;\n constructor(_threadFactory: LocalThreadFactory) {\n super();\n\n this._mainThread = _threadFactory();\n }\n\n public get isLoading() {\n return false;\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public get newThreadId(): string | undefined {\n return undefined;\n }\n\n public get threadIds(): readonly string[] {\n return EMPTY_ARRAY;\n }\n\n public get archivedThreadIds(): readonly string[] {\n return EMPTY_ARRAY;\n }\n\n public get mainThreadId(): string {\n return DEFAULT_THREAD_ID;\n }\n\n public get threadItems() {\n return DEFAULT_THREAD_DATA;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return Promise.resolve();\n }\n\n public getItemById(threadId: string) {\n if (threadId === this.mainThreadId) {\n return {\n status: \"regular\" as const,\n id: this.mainThreadId,\n remoteId: this.mainThreadId,\n externalId: undefined,\n title: undefined,\n isMain: true,\n };\n }\n throw new Error(\"Method not implemented\");\n }\n\n public async switchToThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public switchToNewThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public rename(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public archive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public detach(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public unarchive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public delete(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public initialize(\n threadId: string,\n ): Promise<{ remoteId: string; externalId: string | undefined }> {\n return Promise.resolve({ remoteId: threadId, externalId: undefined });\n }\n\n public generateTitle(): never {\n throw new Error(\"Method not implemented.\");\n }\n}\n"],"mappings":";;AAMA,
|
|
1
|
+
{"version":3,"file":"local-thread-list-runtime-core.js","names":["ThreadListRuntimeCore","BaseSubscribable","LocalThreadRuntimeCore","LocalThreadFactory","EMPTY_ARRAY","Object","freeze","DEFAULT_THREAD_ID","DEFAULT_THREAD_DATA","id","remoteId","undefined","externalId","status","const","title","LocalThreadListRuntimeCore","_mainThread","constructor","_threadFactory","isLoading","getMainThreadRuntimeCore","newThreadId","threadIds","archivedThreadIds","mainThreadId","threadItems","getThreadRuntimeCore","Error","getLoadThreadsPromise","Promise","resolve","getItemById","threadId","isMain","switchToThread","switchToNewThread","rename","archive","detach","unarchive","delete","initialize","generateTitle"],"sources":["../../../src/runtimes/local/local-thread-list-runtime-core.ts"],"sourcesContent":["import type { ThreadListRuntimeCore } from \"../../runtime/interfaces/thread-list-runtime-core\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport type { LocalThreadRuntimeCore } from \"./local-thread-runtime-core\";\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"__DEFAULT_ID__\";\nconst DEFAULT_THREAD_DATA = Object.freeze({\n [DEFAULT_THREAD_ID]: {\n id: DEFAULT_THREAD_ID,\n remoteId: undefined,\n externalId: undefined,\n status: \"regular\" as const,\n title: undefined,\n },\n});\nexport class LocalThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _mainThread: LocalThreadRuntimeCore;\n constructor(_threadFactory: LocalThreadFactory) {\n super();\n\n this._mainThread = _threadFactory();\n }\n\n public get isLoading() {\n return false;\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public get newThreadId(): string | undefined {\n return undefined;\n }\n\n public get threadIds(): readonly string[] {\n return EMPTY_ARRAY;\n }\n\n public get archivedThreadIds(): readonly string[] {\n return EMPTY_ARRAY;\n }\n\n public get mainThreadId(): string {\n return DEFAULT_THREAD_ID;\n }\n\n public get threadItems() {\n return DEFAULT_THREAD_DATA;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return Promise.resolve();\n }\n\n public getItemById(threadId: string) {\n if (threadId === this.mainThreadId) {\n return {\n status: \"regular\" as const,\n id: this.mainThreadId,\n remoteId: this.mainThreadId,\n externalId: undefined,\n title: undefined,\n isMain: true,\n };\n }\n throw new Error(\"Method not implemented\");\n }\n\n public async switchToThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public switchToNewThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public rename(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public archive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public detach(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public unarchive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public delete(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public initialize(\n threadId: string,\n ): Promise<{ remoteId: string; externalId: string | undefined }> {\n return Promise.resolve({ remoteId: threadId, externalId: undefined });\n }\n\n public generateTitle(): never {\n throw new Error(\"Method not implemented.\");\n }\n}\n"],"mappings":";;AAMA,MAAMI,cAAcC,OAAOC,OAAO,CAAA,CAAE;AACpC,MAAMC,oBAAoB;AAC1B,MAAMC,sBAAsBH,OAAOC,OAAO,GACvCC,oBAAoB;CACnBE,IAAIF;CACJG,UAAUC,KAAAA;CACVC,YAAYD,KAAAA;CACZE,QAAQ;CACRE,OAAOJ,KAAAA;AACT,EACF,CAAC;AACD,IAAaK,6BAAb,cACUf,iBAEV;CACE;CACAiB,YAAYC,gBAAoC;EAC9C,MAAM;EAEN,KAAKF,cAAcE,eAAe;CACpC;CAEA,IAAWC,YAAY;EACrB,OAAO;CACT;CAEA,2BAAkC;EAChC,OAAO,KAAKH;CACd;CAEA,IAAWK,cAAkC,CAE7C;CAEA,IAAWC,YAA+B;EACxC,OAAOnB;CACT;CAEA,IAAWoB,oBAAuC;EAChD,OAAOpB;CACT;CAEA,IAAWqB,eAAuB;EAChC,OAAOlB;CACT;CAEA,IAAWmB,cAAc;EACvB,OAAOlB;CACT;CAEA,uBAAqC;EACnC,MAAM,IAAIoB,MAAM,yBAAyB;CAC3C;CAEA,wBAA8C;EAC5C,OAAOE,QAAQC,QAAQ;CACzB;CAEA,YAAmBE,UAAkB;EACnC,IAAIA,aAAa,KAAKR,cACpB,OAAO;GACLZ,QAAQ;GACRJ,IAAI,KAAKgB;GACTf,UAAU,KAAKe;GACfb,YAAYD,KAAAA;GACZI,OAAOJ,KAAAA;GACPuB,QAAQ;EACV;EAEF,MAAM,IAAIN,MAAM,wBAAwB;CAC1C;CAEA,MAAaO,iBAAgC;EAC3C,MAAM,IAAIP,MAAM,yBAAyB;CAC3C;CAEA,oBAA0C;EACxC,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,SAA+B;EAC7B,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,UAAgC;EAC9B,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,SAA+B;EAC7B,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,YAAkC;EAChC,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,SAA+B;EAC7B,MAAM,IAAIA,MAAM,yBAAyB;CAC3C;CAEA,WACEK,UAC+D;EAC/D,OAAOH,QAAQC,QAAQ;GAAErB,UAAUuB;GAAUrB,YAAYD,KAAAA;EAAU,CAAC;CACtE;CAEA,gBAA8B;EAC5B,MAAM,IAAIiB,MAAM,yBAAyB;CAC3C;AACF"}
|
|
@@ -17,6 +17,7 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
|
|
|
17
17
|
switchToBranch: boolean;
|
|
18
18
|
switchBranchDuringRun: boolean;
|
|
19
19
|
edit: boolean;
|
|
20
|
+
delete: boolean;
|
|
20
21
|
reload: boolean;
|
|
21
22
|
cancel: boolean;
|
|
22
23
|
unstable_copy: boolean;
|
|
@@ -63,6 +64,7 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
|
|
|
63
64
|
steerQueueItem(queueItemId: string): void;
|
|
64
65
|
removeQueueItem(queueItemId: string): void;
|
|
65
66
|
private _runAppend;
|
|
67
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
66
68
|
resumeRun({
|
|
67
69
|
stream,
|
|
68
70
|
...startConfig
|
|
@@ -73,6 +75,7 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
|
|
|
73
75
|
parentId,
|
|
74
76
|
runConfig
|
|
75
77
|
}: StartRunConfig, runCallback?: ChatModelAdapter["run"]): Promise<void>;
|
|
78
|
+
private _runLoop;
|
|
76
79
|
private performRoundtrip;
|
|
77
80
|
detach(): void;
|
|
78
81
|
cancelRun(): void;
|
|
@@ -84,7 +87,12 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
|
|
|
84
87
|
artifact
|
|
85
88
|
}: AddToolResultOptions): void;
|
|
86
89
|
resumeToolCall(_options: ResumeToolCallOptions): void;
|
|
87
|
-
respondToToolApproval(
|
|
90
|
+
respondToToolApproval({
|
|
91
|
+
approvalId,
|
|
92
|
+
approved,
|
|
93
|
+
optionId,
|
|
94
|
+
reason
|
|
95
|
+
}: RespondToToolApprovalOptions): void;
|
|
88
96
|
}
|
|
89
97
|
//#endregion
|
|
90
98
|
export { LocalThreadRuntimeCore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"mappings":";;;;;;;;;;;;;;cA2Ca,sBAAA,SACH,qBAAA,YACG,iBAAA;EAAA,SAEK,YAAA
|
|
1
|
+
{"version":3,"file":"local-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"mappings":";;;;;;;;;;;;;;cA2Ca,sBAAA,SACH,qBAAA,YACG,iBAAA;EAAA,SAEK,YAAA;;;;;;;;;;;;;;;UAgBR,eAAA;EAAA,QAEA,MAAA;EAAA,QACA,iBAAA;EAAA,SAEQ,UAAA;EAAA,SACA,cAAA;EAAA,QAER,UAAA;EAAA,IACG,SAAA;EAAA,QAIH,YAAA;EAAA,QACA,sBAAA;EAAA,IACG,WAAA,aAAwB,gBAAA;EAAA,IAIxB,QAAA;;;;;;;;;;cAKT,eAAA,EAAiB,oBAAA,EACjB,OAAA,EAAS,uBAAA;EAAA,QAMH,QAAA;EAAA,QAEA,cAAA;EAAA,QAEA,YAAA;EAED,yBAAA,CAA0B,WAAA;EAAA,QAIzB,qBAAA;EAED,kCAAA,CACL,UAAA,QAAkB,OAAA;EAAA,IAKT,MAAA;EAIJ,qBAAA,CAAsB,OAAA,EAAS,uBAAA;EAAA,QAuE9B,YAAA;EACD,eAAA,IAAe,OAAA;EAuCT,MAAA,CAAO,OAAA,EAAS,aAAA,GAAgB,OAAA;EAWtC,aAAA,aAA0B,cAAA;EAM1B,cAAA,CAAe,WAAA;EAIf,eAAA,CAAgB,WAAA;EAAA,QAIT,UAAA;EAgCD,aAAA,CAAc,SAAA,WAAoB,OAAA;EAmBxC,SAAA;IAAY,MAAA;IAAA,GAAW;EAAA,GAAe,eAAA,GAAkB,OAAA;EAMxD,mBAAA;EAIA,mBAAA;EAIM,QAAA;IACT,QAAA;IAAU;EAAA,GAAa,cAAA,EACzB,WAAA,GAAc,gBAAA,UACb,OAAA;EAAA,QAuBW,QAAA;EAAA,QA2DA,gBAAA;EAgLP,MAAA;EAOA,SAAA;EAOA,aAAA;IACL,SAAA;IACA,UAAA;IACA,MAAA;IACA,OAAA;IACA;EAAA,GACC,oBAAA;EA2CI,cAAA,CAAe,QAAA,EAAU,qBAAA;EAMzB,qBAAA;IACL,UAAA;IACA,QAAA;IACA,QAAA;IACA;EAAA,GACC,4BAAA;AAAA"}
|
|
@@ -18,6 +18,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
18
18
|
switchToBranch: true,
|
|
19
19
|
switchBranchDuringRun: true,
|
|
20
20
|
edit: true,
|
|
21
|
+
delete: false,
|
|
21
22
|
reload: true,
|
|
22
23
|
cancel: true,
|
|
23
24
|
unstable_copy: true,
|
|
@@ -89,6 +90,11 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
89
90
|
this.capabilities.feedback = canFeedback;
|
|
90
91
|
hasUpdates = true;
|
|
91
92
|
}
|
|
93
|
+
const canDelete = options.adapters?.history?.delete !== void 0;
|
|
94
|
+
if (this.capabilities.delete !== canDelete) {
|
|
95
|
+
this.capabilities.delete = canDelete;
|
|
96
|
+
hasUpdates = true;
|
|
97
|
+
}
|
|
92
98
|
const canQueue = options.unstable_enableMessageQueue === true;
|
|
93
99
|
if (canQueue && !this._queue) {
|
|
94
100
|
this._queue = createMessageQueue({ run: (message) => {
|
|
@@ -175,6 +181,21 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
175
181
|
this._notifySubscribers();
|
|
176
182
|
}
|
|
177
183
|
}
|
|
184
|
+
async deleteMessage(messageId) {
|
|
185
|
+
const adapter = this._options.adapters.history;
|
|
186
|
+
if (!adapter?.delete) throw new Error("Runtime does not support deleting messages.");
|
|
187
|
+
const messages = this.repository.getMessages();
|
|
188
|
+
const messageIndex = messages.findIndex((m) => m.id === messageId);
|
|
189
|
+
if (messageIndex === -1) throw new Error("Message not found.");
|
|
190
|
+
const message = messages[messageIndex];
|
|
191
|
+
const items = [{
|
|
192
|
+
parentId: messages[messageIndex - 1]?.id ?? null,
|
|
193
|
+
message
|
|
194
|
+
}];
|
|
195
|
+
await adapter.delete(items);
|
|
196
|
+
this.repository.deleteMessage(messageId);
|
|
197
|
+
this._notifySubscribers();
|
|
198
|
+
}
|
|
178
199
|
resumeRun({ stream, ...startConfig }) {
|
|
179
200
|
if (!stream) throw new Error("You must pass a stream parameter to resume runs.");
|
|
180
201
|
return this.startRun(startConfig, stream);
|
|
@@ -187,7 +208,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
187
208
|
}
|
|
188
209
|
async startRun({ parentId, runConfig }, runCallback) {
|
|
189
210
|
this.ensureInitialized();
|
|
190
|
-
|
|
211
|
+
const message = {
|
|
191
212
|
id: generateId(),
|
|
192
213
|
role: "assistant",
|
|
193
214
|
status: { type: "running" },
|
|
@@ -201,6 +222,9 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
201
222
|
},
|
|
202
223
|
createdAt: /* @__PURE__ */ new Date()
|
|
203
224
|
};
|
|
225
|
+
return this._runLoop(parentId, message, runConfig, runCallback);
|
|
226
|
+
}
|
|
227
|
+
async _runLoop(parentId, message, runConfig, runCallback) {
|
|
204
228
|
this._notifyEventSubscribers("runStart", {});
|
|
205
229
|
try {
|
|
206
230
|
this._queue?.notifyBusy();
|
|
@@ -378,13 +402,49 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
378
402
|
content: newContent
|
|
379
403
|
};
|
|
380
404
|
this.repository.addOrUpdateMessage(parentId, message);
|
|
381
|
-
|
|
405
|
+
this._notifySubscribers();
|
|
406
|
+
if (added && shouldContinue(message, this._options.unstable_humanToolNames)) this._runLoop(parentId, message, this._lastRunConfig).catch(() => {});
|
|
382
407
|
}
|
|
383
408
|
resumeToolCall(_options) {
|
|
384
|
-
throw new Error("Local runtime does not support resuming tool calls.");
|
|
409
|
+
throw new Error("Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.");
|
|
385
410
|
}
|
|
386
|
-
respondToToolApproval(
|
|
387
|
-
|
|
411
|
+
respondToToolApproval({ approvalId, approved, optionId, reason }) {
|
|
412
|
+
let message = this.repository.getMessages().findLast((m) => m.role === "assistant" && m.content.some((c) => c.type === "tool-call" && c.approval?.id === approvalId));
|
|
413
|
+
if (!message) throw new Error("Tried to respond to a non-existing tool approval");
|
|
414
|
+
if (this.abortController !== null) throw new Error("Tried to respond to a tool approval while a run is in progress");
|
|
415
|
+
if (message.status?.type !== "requires-action") throw new Error("Tried to respond to a tool approval on a message whose status is not requires-action");
|
|
416
|
+
const target = message.content.find((c) => c.type === "tool-call" && c.approval?.id === approvalId);
|
|
417
|
+
if (target?.type !== "tool-call" || !target.approval) throw new Error("Tried to respond to a non-existing tool approval");
|
|
418
|
+
if (target.approval.resolution !== void 0) throw new Error("Tried to respond to a tool approval that was cancelled or expired");
|
|
419
|
+
if (target.approval.approved !== void 0) throw new Error("Tried to respond to an already decided tool approval");
|
|
420
|
+
const targetApproval = target.approval;
|
|
421
|
+
const newContent = message.content.map((c) => {
|
|
422
|
+
if (c !== target) return c;
|
|
423
|
+
const approval = {
|
|
424
|
+
...targetApproval,
|
|
425
|
+
approved,
|
|
426
|
+
...optionId != null && { optionId },
|
|
427
|
+
...reason != null && { reason }
|
|
428
|
+
};
|
|
429
|
+
if (approved) return {
|
|
430
|
+
...c,
|
|
431
|
+
approval
|
|
432
|
+
};
|
|
433
|
+
return {
|
|
434
|
+
...c,
|
|
435
|
+
approval,
|
|
436
|
+
result: { error: reason || "Tool approval denied" },
|
|
437
|
+
isError: true
|
|
438
|
+
};
|
|
439
|
+
});
|
|
440
|
+
message = {
|
|
441
|
+
...message,
|
|
442
|
+
content: newContent
|
|
443
|
+
};
|
|
444
|
+
const { parentId } = this.repository.getMessage(message.id);
|
|
445
|
+
this.repository.addOrUpdateMessage(parentId, message);
|
|
446
|
+
this._notifySubscribers();
|
|
447
|
+
if (this.repository.headId === message.id && shouldContinue(message, this._options.unstable_humanToolNames)) this._runLoop(parentId, message, this._lastRunConfig).catch(() => {});
|
|
388
448
|
}
|
|
389
449
|
};
|
|
390
450
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-thread-runtime-core.js","names":[],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"sourcesContent":["import { fromThreadMessageLike } from \"../../runtime/utils/thread-message-like\";\nimport { generateId } from \"../../utils/id\";\nimport type {\n ChatModelAdapter,\n ChatModelRunResult,\n} from \"../../runtime/utils/chat-model-adapter\";\nimport { shouldContinue } from \"./should-continue\";\nimport type { LocalRuntimeOptionsBase } from \"./local-runtime-options\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../../runtime/interfaces/thread-runtime-core\";\nimport { BaseThreadRuntimeCore } from \"../../runtime/base/base-thread-runtime-core\";\nimport type {\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types/message\";\nimport type { RunConfig } from \"../../types/message\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport {\n createMessageQueue,\n type MessageQueueController,\n} from \"../../runtime/queue/message-queue\";\nimport {\n EMPTY_QUEUE_ITEMS,\n type QueueItemState,\n} from \"../../store/scopes/queue-item\";\n\nclass AbortError extends Error {\n override name = \"AbortError\";\n detach: boolean;\n\n constructor(detach: boolean, message?: string) {\n super(message);\n this.detach = detach;\n }\n}\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n switchBranchDuringRun: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n };\n\n private abortController: AbortController | null = null;\n\n private _queue: MessageQueueController | null = null;\n private _queueRunInFlight = false;\n\n public readonly isDisabled = false;\n public readonly isSendDisabled = false;\n\n private _isLoading = false;\n public get isLoading() {\n return this._isLoading;\n }\n\n private _suggestions: readonly ThreadSuggestion[] = [];\n private _suggestionsController: AbortController | null = null;\n public get suggestions(): readonly ThreadSuggestion[] {\n return this._suggestions;\n }\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n options: LocalRuntimeOptionsBase,\n ) {\n super(contextProvider);\n this.__internal_setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n private _lastRunConfig: RunConfig = {};\n\n private _getThreadId?: () => string | undefined;\n\n public __internal_setGetThreadId(getThreadId: () => string | undefined) {\n this._getThreadId = getThreadId;\n }\n\n private _getInitializePromise?: () => Promise<unknown> | undefined;\n\n public __internal_setGetInitializePromise(\n getPromise: () => Promise<unknown> | undefined,\n ) {\n this._getInitializePromise = getPromise;\n }\n\n public get extras() {\n return undefined;\n }\n\n public __internal_setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canDictate = options.adapters?.dictation !== undefined;\n if (this.capabilities.dictation !== canDictate) {\n this.capabilities.dictation = canDictate;\n hasUpdates = true;\n }\n\n const canVoice = options.adapters?.voice !== undefined;\n if (this.capabilities.voice !== canVoice) {\n this.capabilities.voice = canVoice;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n const canQueue = options.unstable_enableMessageQueue === true;\n if (canQueue && !this._queue) {\n this._queue = createMessageQueue({\n run: (message) => {\n // release the queue when the dispatch settles, even if it rejects\n // before reaching startRun's finally, so a failure can't deadlock it\n this._queueRunInFlight = true;\n void this._runAppend(message)\n .finally(() => {\n this._queueRunInFlight = false;\n this._queue?.notifyIdle();\n })\n .catch(() => {});\n },\n });\n this._queue.subscribe(() => this._notifySubscribers());\n } else if (!canQueue && this._queue) {\n this._queue.adapter.clear(\"cancel-run\");\n this._queue = null;\n }\n if (this.capabilities.queue !== canQueue) {\n this.capabilities.queue = canQueue;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _loadPromise: Promise<void> | undefined;\n public __internal_load() {\n if (this._loadPromise) return this._loadPromise;\n\n const promise = this.adapters.history?.load() ?? Promise.resolve(null);\n\n this._isLoading = true;\n this._notifySubscribers();\n\n this._loadPromise = promise\n .then((repo) => {\n if (!repo) return;\n this.repository.import(repo);\n if (repo.messages.length > 0) {\n this.ensureInitialized();\n }\n this._notifySubscribers();\n\n const resume = this.adapters.history?.resume?.bind(\n this.adapters.history,\n );\n if (repo.unstable_resume && resume) {\n this.startRun(\n {\n parentId: this.repository.headId,\n sourceId: this.repository.headId,\n runConfig: this._lastRunConfig,\n },\n resume,\n ).catch(() => {});\n }\n })\n .finally(() => {\n this._isLoading = false;\n this._notifySubscribers();\n });\n\n return this._loadPromise;\n }\n\n public async append(message: AppendMessage): Promise<void> {\n const isTail = message.parentId === (this.messages.at(-1)?.id ?? null);\n const willRun = message.startRun ?? message.role === \"user\";\n if (this._queue && willRun && isTail) {\n this._queue.adapter.enqueue(message, { steer: message.steer ?? false });\n return;\n }\n if (this._queue && !isTail) this._queue.adapter.clear(\"edit\");\n return this._runAppend(message);\n }\n\n public getQueueItems(): readonly QueueItemState[] {\n // Reads can arrive during base-thread construction, before the queue field\n // is assigned, so guard against the unset field.\n return this._queue?.adapter.items ?? EMPTY_QUEUE_ITEMS;\n }\n\n public steerQueueItem(queueItemId: string): void {\n this._queue?.adapter.steer(queueItemId);\n }\n\n public removeQueueItem(queueItemId: string): void {\n this._queue?.adapter.remove(queueItemId);\n }\n\n private async _runAppend(message: AppendMessage): Promise<void> {\n this.ensureInitialized();\n\n const initPromise = this._getInitializePromise?.();\n if (initPromise) {\n await initPromise;\n }\n\n const newMessage = fromThreadMessageLike(message, generateId(), {\n type: \"complete\",\n reason: \"unknown\",\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n this._options.adapters.history?.append({\n parentId: message.parentId,\n message: newMessage,\n ...(message.runConfig !== undefined && { runConfig: message.runConfig }),\n });\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun({\n parentId: newMessage.id,\n sourceId: message.sourceId,\n runConfig: message.runConfig ?? {},\n });\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public resumeRun({ stream, ...startConfig }: ResumeRunConfig): Promise<void> {\n if (!stream)\n throw new Error(\"You must pass a stream parameter to resume runs.\");\n return this.startRun(startConfig, stream);\n }\n\n public exportExternalState(): any {\n throw new Error(\"Runtime does not support exporting external states.\");\n }\n\n public importExternalState(): void {\n throw new Error(\"Runtime does not support importing external states.\");\n }\n\n public async startRun(\n { parentId, runConfig }: StartRunConfig,\n runCallback?: ChatModelAdapter[\"run\"],\n ): Promise<void> {\n this.ensureInitialized();\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n custom: {},\n },\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"runStart\", {});\n\n try {\n // mark busy for runs not started through the queue (regenerate, resume)\n this._queue?.notifyBusy();\n this._suggestions = [];\n this._suggestionsController?.abort();\n this._suggestionsController = null;\n this._notifySubscribers();\n\n do {\n message = await this.performRoundtrip(\n parentId,\n message,\n runConfig,\n runCallback,\n );\n runCallback = undefined;\n } while (shouldContinue(message, this._options.unstable_humanToolNames));\n } finally {\n this._notifyEventSubscribers(\"runEnd\", {});\n // queue-driven runs release from the driver settle handler; a direct\n // run (regenerate, resume) releases here\n if (!this._queueRunInFlight) {\n queueMicrotask(() => this._queue?.notifyIdle());\n }\n }\n\n this._suggestionsController = new AbortController();\n const signal = this._suggestionsController.signal;\n if (\n this.adapters.suggestion &&\n message.status?.type !== \"requires-action\"\n ) {\n const promiseOrGenerator = this.adapters.suggestion?.generate({\n messages: this.messages,\n });\n\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n if (signal.aborted) break;\n this._suggestions = r;\n this._notifySubscribers();\n }\n } else {\n const result = await promiseOrGenerator;\n if (signal.aborted) return;\n this._suggestions = result;\n this._notifySubscribers();\n }\n }\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n runConfig: RunConfig | undefined,\n runCallback?: ChatModelAdapter[\"run\"],\n ) {\n const messages = parentId ? this.repository.getMessages(parentId) : [];\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialAnnotations = message.metadata?.unstable_annotations;\n const initialData = message.metadata?.unstable_data;\n const initialSteps = message.metadata?.steps;\n const initialCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n const newAnnotations = m.metadata?.unstable_annotations;\n const newData = m.metadata?.unstable_data;\n const annotations = newAnnotations\n ? [...(initialAnnotations ?? []), ...newAnnotations]\n : undefined;\n const data = newData ? [...(initialData ?? []), ...newData] : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(m.metadata.unstable_state\n ? { unstable_state: m.metadata.unstable_state }\n : undefined),\n ...(annotations\n ? { unstable_annotations: annotations }\n : undefined),\n ...(data ? { unstable_data: data } : undefined),\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.timing\n ? { timing: m.metadata.timing }\n : undefined),\n ...(m.metadata?.custom\n ? {\n custom: {\n ...(initialCustom ?? {}),\n ...m.metadata.custom,\n },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n\n // Switch to the new message branch right after adding it for the first time\n this.repository.resetHead(message.id);\n this._notifySubscribers();\n }\n\n try {\n this._lastRunConfig = runConfig ?? {};\n const context = this.getModelContext();\n\n runCallback =\n runCallback ??\n this.adapters.chatModel.run.bind(this.adapters.chatModel);\n\n const abortSignal = this.abortController.signal;\n const threadId = this._getThreadId?.();\n const promiseOrGenerator = runCallback({\n messages,\n runConfig: this._lastRunConfig,\n abortSignal,\n context,\n unstable_assistantMessageId: message.id,\n unstable_threadId: threadId,\n unstable_parentId: parentId,\n unstable_getMessage() {\n return message;\n },\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n if (abortSignal.aborted) {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n break;\n }\n\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n // TODO this should be handled by the run result stream\n if (e instanceof AbortError) {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"error\",\n error:\n e instanceof Error\n ? e.message\n : `[${typeof e}] ${new String(e).toString()}`,\n },\n });\n\n throw e;\n }\n } finally {\n this.abortController = null;\n\n if (\n message.status.type === \"complete\" ||\n message.status.type === \"incomplete\"\n ) {\n await this._options.adapters.history?.append({\n parentId,\n message: message,\n runConfig: this._lastRunConfig,\n });\n }\n }\n return message;\n }\n\n public detach() {\n this._queue?.adapter.clear(\"cancel-run\");\n const error = new AbortError(true);\n this.abortController?.abort(error);\n this.abortController = null;\n }\n\n public cancelRun() {\n this._queue?.adapter.clear(\"cancel-run\");\n const error = new AbortError(false);\n this.abortController?.abort(error);\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n isError,\n artifact,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n artifact,\n isError,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (\n added &&\n shouldContinue(message, this._options.unstable_humanToolNames)\n ) {\n this.performRoundtrip(parentId, message, this._lastRunConfig).catch(\n () => {},\n );\n }\n }\n\n public resumeToolCall(_options: ResumeToolCallOptions) {\n throw new Error(\"Local runtime does not support resuming tool calls.\");\n }\n\n public respondToToolApproval(_options: RespondToToolApprovalOptions) {\n throw new Error(\"Local runtime does not support tool approvals.\");\n }\n}\n"],"mappings":";;;;;;;AAiCA,IAAM,aAAN,cAAyB,MAAM;CAC7B,OAAgB;CAChB;CAEA,YAAY,QAAiB,SAAkB;EAC7C,MAAM,OAAO;EACb,KAAK,SAAS;CAChB;AACF;AAEA,IAAa,yBAAb,cACU,sBAEV;CACE,eAA+B;EAC7B,gBAAgB;EAChB,uBAAuB;EACvB,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,eAAe;EACf,QAAQ;EACR,WAAW;EACX,OAAO;EACP,aAAa;EACb,UAAU;EACV,OAAO;CACT;CAEA,kBAAkD;CAElD,SAAgD;CAChD,oBAA4B;CAE5B,aAA6B;CAC7B,iBAAiC;CAEjC,aAAqB;CACrB,IAAW,YAAY;EACrB,OAAO,KAAK;CACd;CAEA,eAAoD,CAAC;CACrD,yBAAyD;CACzD,IAAW,cAA2C;EACpD,OAAO,KAAK;CACd;CAEA,IAAW,WAAW;EACpB,OAAO,KAAK,SAAS;CACvB;CAEA,YACE,iBACA,SACA;EACA,MAAM,eAAe;EACrB,KAAK,sBAAsB,OAAO;CACpC;CAEA;CAEA,iBAAoC,CAAC;CAErC;CAEA,0BAAiC,aAAuC;EACtE,KAAK,eAAe;CACtB;CAEA;CAEA,mCACE,YACA;EACA,KAAK,wBAAwB;CAC/B;CAEA,I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O;CACT;CAEA,SAAgB;EACd,KAAK,QAAQ,QAAQ,MAAM,YAAY;EACvC,MAAM,QAAQ,IAAI,WAAW,IAAI;EACjC,KAAK,iBAAiB,MAAM,KAAK;EACjC,KAAK,kBAAkB;CACzB;CAEA,YAAmB;EACjB,KAAK,QAAQ,QAAQ,MAAM,YAAY;EACvC,MAAM,QAAQ,IAAI,WAAW,KAAK;EAClC,KAAK,iBAAiB,MAAM,KAAK;EACjC,KAAK,kBAAkB;CACzB;CAEA,cAAqB,EACnB,WACA,YACA,QACA,SACA,YACuB;EACvB,MAAM,cAAc,KAAK,WAAW,WAAW,SAAS;EACxD,MAAM,EAAE,aAAa;EACrB,IAAI,EAAE,YAAY;EAElB,IAAI,QAAQ,SAAS,aACnB,MAAM,IAAI,MAAM,mDAAmD;EAErE,IAAI,QAAQ;EACZ,IAAI,QAAQ;EACZ,MAAM,aAAa,QAAQ,QAAQ,KAAK,MAAM;GAC5C,IAAI,EAAE,SAAS,aAAa,OAAO;GACnC,IAAI,EAAE,eAAe,YAAY,OAAO;GACxC,QAAQ;GACR,IAAI,CAAC,EAAE,QAAQ,QAAQ;GACvB,OAAO;IACL,GAAG;IACH;IACA;IACA;GACF;EACF,CAAC;EAED,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oDAAoD;EAEtE,UAAU;GACR,GAAG;GACH,SAAS;EACX;EACA,KAAK,WAAW,mBAAmB,UAAU,OAAO;EAEpD,IACE,SACA,eAAe,SAAS,KAAK,SAAS,uBAAuB,GAE7D,KAAK,iBAAiB,UAAU,SAAS,KAAK,cAAc,CAAC,CAAC,YACtD,CAAC,CACT;CAEJ;CAEA,eAAsB,UAAiC;EACrD,MAAM,IAAI,MAAM,qDAAqD;CACvE;CAEA,sBAA6B,UAAwC;EACnE,MAAM,IAAI,MAAM,gDAAgD;CAClE;AACF"}
|
|
1
|
+
{"version":3,"file":"local-thread-runtime-core.js","names":["fromThreadMessageLike","generateId","ChatModelAdapter","ChatModelRunResult","shouldContinue","LocalRuntimeOptionsBase","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","ThreadSuggestion","ThreadRuntimeCore","StartRunConfig","ResumeRunConfig","BaseThreadRuntimeCore","AppendMessage","ThreadAssistantMessage","RunConfig","ModelContextProvider","createMessageQueue","MessageQueueController","EMPTY_QUEUE_ITEMS","QueueItemState","AbortError","Error","name","detach","constructor","message","LocalThreadRuntimeCore","capabilities","switchToBranch","switchBranchDuringRun","edit","delete","reload","cancel","unstable_copy","speech","dictation","voice","attachments","feedback","queue","abortController","AbortController","_queue","_queueRunInFlight","isDisabled","isSendDisabled","_isLoading","isLoading","_suggestions","_suggestionsController","suggestions","adapters","_options","contextProvider","options","__internal_setOptions","_lastRunConfig","_getThreadId","__internal_setGetThreadId","getThreadId","_getInitializePromise","Promise","__internal_setGetInitializePromise","getPromise","extras","undefined","hasUpdates","canSpeak","canDictate","canVoice","canAttach","canFeedback","canDelete","history","canQueue","unstable_enableMessageQueue","run","_runAppend","finally","notifyIdle","catch","subscribe","_notifySubscribers","adapter","clear","_loadPromise","__internal_load","promise","load","resolve","then","repo","repository","import","messages","length","ensureInitialized","resume","bind","unstable_resume","startRun","parentId","headId","sourceId","runConfig","append","isTail","at","id","willRun","role","enqueue","steer","getQueueItems","items","steerQueueItem","queueItemId","removeQueueItem","remove","initPromise","newMessage","type","reason","addOrUpdateMessage","resetHead","deleteMessage","messageId","getMessages","messageIndex","findIndex","m","resumeRun","stream","startConfig","exportExternalState","importExternalState","runCallback","status","content","metadata","unstable_state","state","unstable_annotations","unstable_data","steps","custom","createdAt","Date","_runLoop","_notifyEventSubscribers","notifyBusy","abort","performRoundtrip","unstable_humanToolNames","queueMicrotask","signal","suggestion","promiseOrGenerator","generate","Symbol","asyncIterator","r","aborted","result","initialContent","initialAnnotations","initialData","initialSteps","initialCustom","updateMessage","Partial","newSteps","newAnnotations","newData","annotations","data","timing","maxSteps","context","getModelContext","chatModel","abortSignal","threadId","unstable_assistantMessageId","unstable_threadId","unstable_parentId","unstable_getMessage","e","error","String","toString","cancelRun","addToolResult","toolCallId","isError","artifact","messageData","getMessage","added","found","newContent","map","c","resumeToolCall","respondToToolApproval","approvalId","approved","optionId","findLast","some","approval","target","find","resolution","targetApproval"],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"sourcesContent":["import { fromThreadMessageLike } from \"../../runtime/utils/thread-message-like\";\nimport { generateId } from \"../../utils/id\";\nimport type {\n ChatModelAdapter,\n ChatModelRunResult,\n} from \"../../runtime/utils/chat-model-adapter\";\nimport { shouldContinue } from \"./should-continue\";\nimport type { LocalRuntimeOptionsBase } from \"./local-runtime-options\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../../runtime/interfaces/thread-runtime-core\";\nimport { BaseThreadRuntimeCore } from \"../../runtime/base/base-thread-runtime-core\";\nimport type {\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types/message\";\nimport type { RunConfig } from \"../../types/message\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport {\n createMessageQueue,\n type MessageQueueController,\n} from \"../../runtime/queue/message-queue\";\nimport {\n EMPTY_QUEUE_ITEMS,\n type QueueItemState,\n} from \"../../store/scopes/queue-item\";\n\nclass AbortError extends Error {\n override name = \"AbortError\";\n detach: boolean;\n\n constructor(detach: boolean, message?: string) {\n super(message);\n this.detach = detach;\n }\n}\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n switchBranchDuringRun: true,\n edit: true,\n delete: false,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n };\n\n private abortController: AbortController | null = null;\n\n private _queue: MessageQueueController | null = null;\n private _queueRunInFlight = false;\n\n public readonly isDisabled = false;\n public readonly isSendDisabled = false;\n\n private _isLoading = false;\n public get isLoading() {\n return this._isLoading;\n }\n\n private _suggestions: readonly ThreadSuggestion[] = [];\n private _suggestionsController: AbortController | null = null;\n public get suggestions(): readonly ThreadSuggestion[] {\n return this._suggestions;\n }\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n options: LocalRuntimeOptionsBase,\n ) {\n super(contextProvider);\n this.__internal_setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n private _lastRunConfig: RunConfig = {};\n\n private _getThreadId?: () => string | undefined;\n\n public __internal_setGetThreadId(getThreadId: () => string | undefined) {\n this._getThreadId = getThreadId;\n }\n\n private _getInitializePromise?: () => Promise<unknown> | undefined;\n\n public __internal_setGetInitializePromise(\n getPromise: () => Promise<unknown> | undefined,\n ) {\n this._getInitializePromise = getPromise;\n }\n\n public get extras() {\n return undefined;\n }\n\n public __internal_setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canDictate = options.adapters?.dictation !== undefined;\n if (this.capabilities.dictation !== canDictate) {\n this.capabilities.dictation = canDictate;\n hasUpdates = true;\n }\n\n const canVoice = options.adapters?.voice !== undefined;\n if (this.capabilities.voice !== canVoice) {\n this.capabilities.voice = canVoice;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n const canDelete = options.adapters?.history?.delete !== undefined;\n if (this.capabilities.delete !== canDelete) {\n this.capabilities.delete = canDelete;\n hasUpdates = true;\n }\n\n const canQueue = options.unstable_enableMessageQueue === true;\n if (canQueue && !this._queue) {\n this._queue = createMessageQueue({\n run: (message) => {\n // release the queue when the dispatch settles, even if it rejects\n // before reaching startRun's finally, so a failure can't deadlock it\n this._queueRunInFlight = true;\n void this._runAppend(message)\n .finally(() => {\n this._queueRunInFlight = false;\n this._queue?.notifyIdle();\n })\n .catch(() => {});\n },\n });\n this._queue.subscribe(() => this._notifySubscribers());\n } else if (!canQueue && this._queue) {\n this._queue.adapter.clear(\"cancel-run\");\n this._queue = null;\n }\n if (this.capabilities.queue !== canQueue) {\n this.capabilities.queue = canQueue;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _loadPromise: Promise<void> | undefined;\n public __internal_load() {\n if (this._loadPromise) return this._loadPromise;\n\n const promise = this.adapters.history?.load() ?? Promise.resolve(null);\n\n this._isLoading = true;\n this._notifySubscribers();\n\n this._loadPromise = promise\n .then((repo) => {\n if (!repo) return;\n this.repository.import(repo);\n if (repo.messages.length > 0) {\n this.ensureInitialized();\n }\n this._notifySubscribers();\n\n const resume = this.adapters.history?.resume?.bind(\n this.adapters.history,\n );\n if (repo.unstable_resume && resume) {\n this.startRun(\n {\n parentId: this.repository.headId,\n sourceId: this.repository.headId,\n runConfig: this._lastRunConfig,\n },\n resume,\n ).catch(() => {});\n }\n })\n .finally(() => {\n this._isLoading = false;\n this._notifySubscribers();\n });\n\n return this._loadPromise;\n }\n\n public async append(message: AppendMessage): Promise<void> {\n const isTail = message.parentId === (this.messages.at(-1)?.id ?? null);\n const willRun = message.startRun ?? message.role === \"user\";\n if (this._queue && willRun && isTail) {\n this._queue.adapter.enqueue(message, { steer: message.steer ?? false });\n return;\n }\n if (this._queue && !isTail) this._queue.adapter.clear(\"edit\");\n return this._runAppend(message);\n }\n\n public getQueueItems(): readonly QueueItemState[] {\n // Reads can arrive during base-thread construction, before the queue field\n // is assigned, so guard against the unset field.\n return this._queue?.adapter.items ?? EMPTY_QUEUE_ITEMS;\n }\n\n public steerQueueItem(queueItemId: string): void {\n this._queue?.adapter.steer(queueItemId);\n }\n\n public removeQueueItem(queueItemId: string): void {\n this._queue?.adapter.remove(queueItemId);\n }\n\n private async _runAppend(message: AppendMessage): Promise<void> {\n this.ensureInitialized();\n\n const initPromise = this._getInitializePromise?.();\n if (initPromise) {\n await initPromise;\n }\n\n const newMessage = fromThreadMessageLike(message, generateId(), {\n type: \"complete\",\n reason: \"unknown\",\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n this._options.adapters.history?.append({\n parentId: message.parentId,\n message: newMessage,\n ...(message.runConfig !== undefined && { runConfig: message.runConfig }),\n });\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun({\n parentId: newMessage.id,\n sourceId: message.sourceId,\n runConfig: message.runConfig ?? {},\n });\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async deleteMessage(messageId: string): Promise<void> {\n const adapter = this._options.adapters.history;\n if (!adapter?.delete)\n throw new Error(\"Runtime does not support deleting messages.\");\n\n const messages = this.repository.getMessages();\n const messageIndex = messages.findIndex((m) => m.id === messageId);\n if (messageIndex === -1) throw new Error(\"Message not found.\");\n\n const message = messages[messageIndex]!;\n const parentId = messages[messageIndex - 1]?.id ?? null;\n const items = [{ parentId, message }];\n\n await adapter.delete(items);\n\n this.repository.deleteMessage(messageId);\n this._notifySubscribers();\n }\n\n public resumeRun({ stream, ...startConfig }: ResumeRunConfig): Promise<void> {\n if (!stream)\n throw new Error(\"You must pass a stream parameter to resume runs.\");\n return this.startRun(startConfig, stream);\n }\n\n public exportExternalState(): any {\n throw new Error(\"Runtime does not support exporting external states.\");\n }\n\n public importExternalState(): void {\n throw new Error(\"Runtime does not support importing external states.\");\n }\n\n public async startRun(\n { parentId, runConfig }: StartRunConfig,\n runCallback?: ChatModelAdapter[\"run\"],\n ): Promise<void> {\n this.ensureInitialized();\n\n // add assistant message\n const id = generateId();\n const message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n custom: {},\n },\n createdAt: new Date(),\n };\n\n return this._runLoop(parentId, message, runConfig, runCallback);\n }\n\n private async _runLoop(\n parentId: string | null,\n message: ThreadAssistantMessage,\n runConfig: RunConfig | undefined,\n runCallback?: ChatModelAdapter[\"run\"],\n ): Promise<void> {\n this._notifyEventSubscribers(\"runStart\", {});\n\n try {\n // mark busy for runs not started through the queue (regenerate, resume)\n this._queue?.notifyBusy();\n this._suggestions = [];\n this._suggestionsController?.abort();\n this._suggestionsController = null;\n this._notifySubscribers();\n\n do {\n message = await this.performRoundtrip(\n parentId,\n message,\n runConfig,\n runCallback,\n );\n runCallback = undefined;\n } while (shouldContinue(message, this._options.unstable_humanToolNames));\n } finally {\n this._notifyEventSubscribers(\"runEnd\", {});\n // queue-driven runs release from the driver settle handler; a direct\n // run (regenerate, resume) releases here\n if (!this._queueRunInFlight) {\n queueMicrotask(() => this._queue?.notifyIdle());\n }\n }\n\n this._suggestionsController = new AbortController();\n const signal = this._suggestionsController.signal;\n if (\n this.adapters.suggestion &&\n message.status?.type !== \"requires-action\"\n ) {\n const promiseOrGenerator = this.adapters.suggestion?.generate({\n messages: this.messages,\n });\n\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n if (signal.aborted) break;\n this._suggestions = r;\n this._notifySubscribers();\n }\n } else {\n const result = await promiseOrGenerator;\n if (signal.aborted) return;\n this._suggestions = result;\n this._notifySubscribers();\n }\n }\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n runConfig: RunConfig | undefined,\n runCallback?: ChatModelAdapter[\"run\"],\n ) {\n const messages = parentId ? this.repository.getMessages(parentId) : [];\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialAnnotations = message.metadata?.unstable_annotations;\n const initialData = message.metadata?.unstable_data;\n const initialSteps = message.metadata?.steps;\n const initialCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n const newAnnotations = m.metadata?.unstable_annotations;\n const newData = m.metadata?.unstable_data;\n const annotations = newAnnotations\n ? [...(initialAnnotations ?? []), ...newAnnotations]\n : undefined;\n const data = newData ? [...(initialData ?? []), ...newData] : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(m.metadata.unstable_state\n ? { unstable_state: m.metadata.unstable_state }\n : undefined),\n ...(annotations\n ? { unstable_annotations: annotations }\n : undefined),\n ...(data ? { unstable_data: data } : undefined),\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.timing\n ? { timing: m.metadata.timing }\n : undefined),\n ...(m.metadata?.custom\n ? {\n custom: {\n ...(initialCustom ?? {}),\n ...m.metadata.custom,\n },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n\n // Switch to the new message branch right after adding it for the first time\n this.repository.resetHead(message.id);\n this._notifySubscribers();\n }\n\n try {\n this._lastRunConfig = runConfig ?? {};\n const context = this.getModelContext();\n\n runCallback =\n runCallback ??\n this.adapters.chatModel.run.bind(this.adapters.chatModel);\n\n const abortSignal = this.abortController.signal;\n const threadId = this._getThreadId?.();\n const promiseOrGenerator = runCallback({\n messages,\n runConfig: this._lastRunConfig,\n abortSignal,\n context,\n unstable_assistantMessageId: message.id,\n unstable_threadId: threadId,\n unstable_parentId: parentId,\n unstable_getMessage() {\n return message;\n },\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n if (abortSignal.aborted) {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n break;\n }\n\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n // TODO this should be handled by the run result stream\n if (e instanceof AbortError) {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"error\",\n error:\n e instanceof Error\n ? e.message\n : `[${typeof e}] ${new String(e).toString()}`,\n },\n });\n\n throw e;\n }\n } finally {\n this.abortController = null;\n\n if (\n message.status.type === \"complete\" ||\n message.status.type === \"incomplete\"\n ) {\n await this._options.adapters.history?.append({\n parentId,\n message: message,\n runConfig: this._lastRunConfig,\n });\n }\n }\n return message;\n }\n\n public detach() {\n this._queue?.adapter.clear(\"cancel-run\");\n const error = new AbortError(true);\n this.abortController?.abort(error);\n this.abortController = null;\n }\n\n public cancelRun() {\n this._queue?.adapter.clear(\"cancel-run\");\n const error = new AbortError(false);\n this.abortController?.abort(error);\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n isError,\n artifact,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n artifact,\n isError,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n\n // a result may arrive mid-run or on a non-head message; the resume\n // intentionally aborts any in-flight run, unlike respondToToolApproval\n if (\n added &&\n shouldContinue(message, this._options.unstable_humanToolNames)\n ) {\n this._runLoop(parentId, message, this._lastRunConfig).catch(() => {});\n }\n }\n\n public resumeToolCall(_options: ResumeToolCallOptions) {\n throw new Error(\n \"Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.\",\n );\n }\n\n public respondToToolApproval({\n approvalId,\n approved,\n optionId,\n reason,\n }: RespondToToolApprovalOptions) {\n let message = this.repository\n .getMessages()\n .findLast(\n (m): m is ThreadAssistantMessage =>\n m.role === \"assistant\" &&\n m.content.some(\n (c) => c.type === \"tool-call\" && c.approval?.id === approvalId,\n ),\n );\n\n if (!message)\n throw new Error(\"Tried to respond to a non-existing tool approval\");\n\n if (this.abortController !== null)\n throw new Error(\n \"Tried to respond to a tool approval while a run is in progress\",\n );\n\n if (message.status?.type !== \"requires-action\")\n throw new Error(\n \"Tried to respond to a tool approval on a message whose status is not requires-action\",\n );\n\n const target = message.content.find(\n (c) => c.type === \"tool-call\" && c.approval?.id === approvalId,\n );\n if (target?.type !== \"tool-call\" || !target.approval)\n throw new Error(\"Tried to respond to a non-existing tool approval\");\n if (target.approval.resolution !== undefined)\n throw new Error(\n \"Tried to respond to a tool approval that was cancelled or expired\",\n );\n if (target.approval.approved !== undefined)\n throw new Error(\"Tried to respond to an already decided tool approval\");\n\n const targetApproval = target.approval;\n const newContent = message.content.map((c) => {\n if (c !== target) return c;\n const approval = {\n ...targetApproval,\n approved,\n ...(optionId != null && { optionId }),\n ...(reason != null && { reason }),\n };\n if (approved) return { ...c, approval };\n return {\n ...c,\n approval,\n result: { error: reason || \"Tool approval denied\" },\n isError: true,\n };\n });\n\n message = { ...message, content: newContent };\n const { parentId } = this.repository.getMessage(message.id);\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n\n if (\n this.repository.headId === message.id &&\n shouldContinue(message, this._options.unstable_humanToolNames)\n ) {\n this._runLoop(parentId, message, this._lastRunConfig).catch(() => {});\n }\n }\n}\n"],"mappings":";;;;;;;AAiCA,IAAMsB,aAAN,cAAyBC,MAAM;CAC7B,OAAgB;CAChBE;CAEAC,YAAYD,QAAiBE,SAAkB;EAC7C,MAAMA,OAAO;EACb,KAAKF,SAASA;CAChB;AACF;AAEA,IAAaG,yBAAb,cACUf,sBAEV;CACE,eAA+B;EAC7BiB,gBAAgB;EAChBC,uBAAuB;EACvBC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,WAAW;EACXC,OAAO;EACPC,aAAa;EACbC,UAAU;EACVC,OAAO;CACT;CAEA,kBAAkD;CAElD,SAAgD;CAChD,oBAA4B;CAE5B,aAA6B;CAC7B,iBAAiC;CAEjC,aAAqB;CACrB,IAAWQ,YAAY;EACrB,OAAO,KAAKD;CACd;CAEA,eAAoD,CAAA;CACpD,yBAAyD;CACzD,IAAWI,cAA2C;EACpD,OAAO,KAAKF;CACd;CAEA,IAAWG,WAAW;EACpB,OAAO,KAAKC,SAASD;CACvB;CAEA5B,YACE8B,iBACAC,SACA;EACA,MAAMD,eAAe;EACrB,KAAKE,sBAAsBD,OAAO;CACpC;CAEA;CAEA,iBAAoC,CAAC;CAErC;CAEA,0BAAiCK,aAAuC;EACtE,KAAKF,eAAeE;CACtB;CAEA;CAEA,mCACEI,YACA;EACA,KAAKH,wBAAwBG;CAC/B;CAEA,IAAWC,SAAS,CAEpB;CAEA,sBAA6BV,SAAkC;EAC7D,IAAI,KAAKF,aAAaE,SAAS;EAE/B,KAAKF,WAAWE;EAEhB,IAAIY,aAA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/B,MAAM,IAAI7C,MAAM,sDAAsD;EAExE,MAAMkM,iBAAiBH,OAAOD;EAC9B,MAAMV,aAAahL,QAAQkH,QAAQ+D,KAAKC,MAAM;GAC5C,IAAIA,MAAMS,QAAQ,OAAOT;GACzB,MAAMQ,WAAW;IACf,GAAGI;IACHR;IACA,GAAIC,YAAY,QAAQ,EAAEA,SAAS;IACnC,GAAIrF,UAAU,QAAQ,EAAEA,OAAO;GACjC;GACA,IAAIoF,UAAU,OAAO;IAAE,GAAGJ;IAAGQ;GAAS;GACtC,OAAO;IACL,GAAGR;IACHQ;IACA/C,QAAQ,EAAEyB,OAAOlE,UAAU,uBAAuB;IAClDwE,SAAS;GACX;EACF,CAAC;EAED1K,UAAU;GAAE,GAAGA;GAASkH,SAAS8D;EAAW;EAC5C,MAAM,EAAEnG,aAAa,KAAKT,WAAWyG,WAAW7K,QAAQoF,EAAE;EAC1D,KAAKhB,WAAW+B,mBAAmBtB,UAAU7E,OAAO;EACpD,KAAK0D,mBAAmB;EAExB,IACE,KAAKU,WAAWU,WAAW9E,QAAQoF,MACnC3G,eAAeuB,SAAS,KAAK4B,SAASqG,uBAAuB,GAE7D,KAAKL,SAAS/C,UAAU7E,SAAS,KAAKgC,cAAc,CAAC,CAACwB,YAAY,CAAC,CAAC;CAExE;AACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
//#region src/runtimes/local/should-continue.ts
|
|
2
2
|
const shouldContinue = (result, humanToolNames) => {
|
|
3
|
-
if (
|
|
4
|
-
|
|
3
|
+
if (result.status?.type !== "requires-action" || result.status.reason !== "tool-calls") return false;
|
|
4
|
+
if (result.content.some((c) => c.type === "tool-call" && c.result === void 0 && c.approval !== void 0 && c.approval.approved === void 0 && c.approval.resolution === void 0)) return false;
|
|
5
|
+
if (humanToolNames === void 0) return result.content.every((c) => c.type !== "tool-call" || !!c.result || c.approval !== void 0);
|
|
6
|
+
return result.content.every((c) => c.type !== "tool-call" || !!c.result || c.approval !== void 0 || !humanToolNames.includes(c.toolName));
|
|
5
7
|
};
|
|
6
8
|
//#endregion
|
|
7
9
|
export { shouldContinue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-continue.js","names":[],"sources":["../../../src/runtimes/local/should-continue.ts"],"sourcesContent":["import type { ThreadAssistantMessage } from \"../../types/message\";\n\nexport const shouldContinue = (\n result: ThreadAssistantMessage,\n humanToolNames: string[] | undefined,\n) => {\n
|
|
1
|
+
{"version":3,"file":"should-continue.js","names":["ThreadAssistantMessage","shouldContinue","result","humanToolNames","status","type","reason","hasPendingApproval","content","some","c","undefined","approval","approved","resolution","every","includes","toolName"],"sources":["../../../src/runtimes/local/should-continue.ts"],"sourcesContent":["import type { ThreadAssistantMessage } from \"../../types/message\";\n\nexport const shouldContinue = (\n result: ThreadAssistantMessage,\n humanToolNames: string[] | undefined,\n) => {\n if (\n result.status?.type !== \"requires-action\" ||\n result.status.reason !== \"tool-calls\"\n )\n return false;\n\n const hasPendingApproval = result.content.some(\n (c) =>\n c.type === \"tool-call\" &&\n c.result === undefined &&\n c.approval !== undefined &&\n c.approval.approved === undefined &&\n c.approval.resolution === undefined,\n );\n if (hasPendingApproval) return false;\n\n // TODO legacy behavior -- make specifying human tool names required\n if (humanToolNames === undefined) {\n return result.content.every(\n (c) => c.type !== \"tool-call\" || !!c.result || c.approval !== undefined,\n );\n }\n\n return result.content.every(\n (c) =>\n c.type !== \"tool-call\" ||\n !!c.result ||\n c.approval !== undefined ||\n !humanToolNames.includes(c.toolName),\n );\n};\n"],"mappings":";AAEA,MAAaC,kBACXC,QACAC,mBACG;CACH,IACED,OAAOE,QAAQC,SAAS,qBACxBH,OAAOE,OAAOE,WAAW,cAEzB,OAAO;CAUT,IAR2BJ,OAAOM,QAAQC,MACvCC,MACCA,EAAEL,SAAS,eACXK,EAAER,WAAWS,KAAAA,KACbD,EAAEE,aAAaD,KAAAA,KACfD,EAAEE,SAASC,aAAaF,KAAAA,KACxBD,EAAEE,SAASE,eAAeH,KAAAA,CAE1BJ,GAAoB,OAAO;CAG/B,IAAIJ,mBAAmBQ,KAAAA,GACrB,OAAOT,OAAOM,QAAQO,OACnBL,MAAMA,EAAEL,SAAS,eAAe,CAAC,CAACK,EAAER,UAAUQ,EAAEE,aAAaD,KAAAA,CAChE;CAGF,OAAOT,OAAOM,QAAQO,OACnBL,MACCA,EAAEL,SAAS,eACX,CAAC,CAACK,EAAER,UACJQ,EAAEE,aAAaD,KAAAA,KACf,CAACR,eAAea,SAASN,EAAEO,QAAQ,CACvC;AACF"}
|
|
@@ -16,6 +16,7 @@ declare class ReadonlyThreadRuntimeCore extends BaseSubscribable implements Thre
|
|
|
16
16
|
getBranches(messageId: string): string[];
|
|
17
17
|
switchToBranch(): void;
|
|
18
18
|
append(): void;
|
|
19
|
+
deleteMessage(): void;
|
|
19
20
|
startRun(): void;
|
|
20
21
|
resumeRun(): void;
|
|
21
22
|
cancelRun(): void;
|
|
@@ -72,6 +73,7 @@ declare class ReadonlyThreadRuntimeCore extends BaseSubscribable implements Thre
|
|
|
72
73
|
readonly switchToBranch: false;
|
|
73
74
|
readonly switchBranchDuringRun: false;
|
|
74
75
|
readonly edit: false;
|
|
76
|
+
readonly delete: false;
|
|
75
77
|
readonly reload: false;
|
|
76
78
|
readonly cancel: false;
|
|
77
79
|
readonly unstable_copy: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadonlyThreadRuntimeCore.d.ts","names":[],"sources":["../../../src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts"],"mappings":";;;;;;cASa,yBAAA,SACH,gBAAA,YACG,iBAAA;EAAA,QAEH,SAAA;EAAA,IAEJ,QAAA,aAAQ,aAAA;EAIZ,WAAA,CAAY,QAAA,WAAmB,aAAA;EAM/B,cAAA,CAAe,SAAA;;;;;EAUf,WAAA,CAAY,SAAA;EAMZ,cAAA;EAIA,MAAA;EAIA,QAAA;EAIA,SAAA;EAIA,SAAA;EAEA,aAAA;EAIA,cAAA;EAIA,qBAAA;EAIA,KAAA;EAIA,YAAA;EAEA,YAAA;EAIA,eAAA;EAEA,cAAA;EACA,oBAAA,QAA2B,WAAA;EAE3B,SAAA;EAIA,WAAA;EAIA,cAAA;EAIA,eAAA;EAIA,mBAAA;EAIA,mBAAA;EAIA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,eAAA;EAIA,SAAA;EAIA,MAAA;EACA,KAAA;EAEA,YAAA;IAAA
|
|
1
|
+
{"version":3,"file":"ReadonlyThreadRuntimeCore.d.ts","names":[],"sources":["../../../src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts"],"mappings":";;;;;;cASa,yBAAA,SACH,gBAAA,YACG,iBAAA;EAAA,QAEH,SAAA;EAAA,IAEJ,QAAA,aAAQ,aAAA;EAIZ,WAAA,CAAY,QAAA,WAAmB,aAAA;EAM/B,cAAA,CAAe,SAAA;;;;;EAUf,WAAA,CAAY,SAAA;EAMZ,cAAA;EAIA,MAAA;EAIA,aAAA;EAIA,QAAA;EAIA,SAAA;EAIA,SAAA;EAEA,aAAA;EAIA,cAAA;EAIA,qBAAA;EAIA,KAAA;EAIA,YAAA;EAEA,YAAA;EAIA,eAAA;EAEA,cAAA;EACA,oBAAA,QAA2B,WAAA;EAE3B,SAAA;EAIA,WAAA;EAIA,cAAA;EAIA,eAAA;EAIA,mBAAA;EAIA,mBAAA;EAIA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,eAAA;EAIA,SAAA;EAIA,MAAA;EACA,KAAA;EAEA,YAAA;IAAA;;;;;;;;;;;;;;EAgBA,UAAA;EACA,cAAA;EACA,SAAA;EAEA,KAAA;EACA,WAAA;EACA,MAAA;EAEA,MAAA;EAIA,MAAA;;;;;;EASA,KAAA;EAIA,WAAA,IAAe,WAAA;AAAA"}
|
|
@@ -30,6 +30,9 @@ var ReadonlyThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
30
30
|
append() {
|
|
31
31
|
throw READONLY_THREAD_ERROR;
|
|
32
32
|
}
|
|
33
|
+
deleteMessage() {
|
|
34
|
+
throw READONLY_THREAD_ERROR;
|
|
35
|
+
}
|
|
33
36
|
startRun() {
|
|
34
37
|
throw READONLY_THREAD_ERROR;
|
|
35
38
|
}
|
|
@@ -134,6 +137,7 @@ var ReadonlyThreadRuntimeCore = class extends BaseSubscribable {
|
|
|
134
137
|
switchToBranch: false,
|
|
135
138
|
switchBranchDuringRun: false,
|
|
136
139
|
edit: false,
|
|
140
|
+
delete: false,
|
|
137
141
|
reload: false,
|
|
138
142
|
cancel: false,
|
|
139
143
|
unstable_copy: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadonlyThreadRuntimeCore.js","names":[],"sources":["../../../src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ThreadMessage } from \"../../types/message\";\nimport type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\n\nconst READONLY_THREAD_ERROR = new Error(\n \"This is a readonly thread. You cannot perform mutations on readonly threads.\",\n);\n\nexport class ReadonlyThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _messages: readonly ThreadMessage[] = [];\n\n get messages() {\n return this._messages;\n }\n\n setMessages(messages: readonly ThreadMessage[]) {\n if (this._messages === messages) return;\n this._messages = messages;\n this._notifySubscribers();\n }\n\n getMessageById(messageId: string) {\n const idx = this._messages.findIndex((m) => m.id === messageId);\n if (idx === -1) return undefined;\n return {\n parentId: this._messages[idx - 1]?.id ?? null,\n message: this._messages[idx]!,\n index: idx,\n };\n }\n\n getBranches(messageId: string) {\n const idx = this._messages.findIndex((m) => m.id === messageId);\n if (idx === -1) return [];\n return [messageId];\n }\n\n switchToBranch(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n append(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n startRun(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n resumeRun(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n cancelRun(): void {}\n\n addToolResult(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n resumeToolCall(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n respondToToolApproval(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n speak(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n stopSpeaking(): void {}\n\n connectVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n disconnectVoice(): void {}\n\n getVoiceVolume = () => 0;\n subscribeVoiceVolume = (): Unsubscribe => () => {};\n\n muteVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n unmuteVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n submitFeedback(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n getModelContext() {\n return {};\n }\n\n exportExternalState() {\n throw READONLY_THREAD_ERROR;\n }\n\n importExternalState(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n composer = {\n attachments: [] as never[],\n attachmentAccept: \"*\",\n\n async addAttachment() {\n throw READONLY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw READONLY_THREAD_ERROR;\n },\n\n isEditing: false as const,\n canCancel: false,\n canSend: false,\n isEmpty: true,\n text: \"\",\n\n setText() {\n throw READONLY_THREAD_ERROR;\n },\n\n role: \"user\" as const,\n\n setRole() {\n throw READONLY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw READONLY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw READONLY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n queue: [] as never[],\n steerQueueItem() {},\n removeQueueItem() {},\n\n dictation: undefined,\n\n startDictation() {\n throw READONLY_THREAD_ERROR;\n },\n\n stopDictation() {\n // noop\n },\n\n quote: undefined,\n\n setQuote() {\n throw READONLY_THREAD_ERROR;\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n };\n\n getEditComposer() {\n return undefined;\n }\n\n beginEdit(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n speech = undefined;\n voice = undefined;\n\n capabilities = {\n switchToBranch: false,\n switchBranchDuringRun: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n } as const;\n\n isDisabled = false;\n isSendDisabled = false;\n isLoading = false;\n\n state = null;\n suggestions = [] as never[];\n extras = undefined;\n\n import(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n export() {\n return {\n messages: this._messages.map((message, idx) => ({\n message,\n parentId: this._messages[idx - 1]?.id ?? null,\n })),\n };\n }\n\n reset(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n unstable_on(): Unsubscribe {\n return () => {};\n }\n}\n"],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"ReadonlyThreadRuntimeCore.js","names":["Unsubscribe","ThreadMessage","ThreadRuntimeCore","BaseSubscribable","READONLY_THREAD_ERROR","Error","ReadonlyThreadRuntimeCore","_messages","messages","setMessages","_notifySubscribers","getMessageById","messageId","idx","findIndex","m","id","undefined","parentId","message","index","getBranches","switchToBranch","append","deleteMessage","startRun","resumeRun","cancelRun","addToolResult","resumeToolCall","respondToToolApproval","speak","stopSpeaking","connectVoice","disconnectVoice","getVoiceVolume","subscribeVoiceVolume","muteVoice","unmuteVoice","submitFeedback","getModelContext","exportExternalState","importExternalState","composer","attachments","attachmentAccept","addAttachment","removeAttachment","isEditing","const","canCancel","canSend","isEmpty","text","setText","role","setRole","runConfig","setRunConfig","reset","clearAttachments","send","cancel","queue","steerQueueItem","removeQueueItem","dictation","startDictation","stopDictation","quote","setQuote","subscribe","unstable_on","getEditComposer","beginEdit","speech","voice","capabilities","switchBranchDuringRun","edit","delete","reload","unstable_copy","feedback","isDisabled","isSendDisabled","isLoading","state","suggestions","extras","import","export","map"],"sources":["../../../src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ThreadMessage } from \"../../types/message\";\nimport type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\n\nconst READONLY_THREAD_ERROR = new Error(\n \"This is a readonly thread. You cannot perform mutations on readonly threads.\",\n);\n\nexport class ReadonlyThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _messages: readonly ThreadMessage[] = [];\n\n get messages() {\n return this._messages;\n }\n\n setMessages(messages: readonly ThreadMessage[]) {\n if (this._messages === messages) return;\n this._messages = messages;\n this._notifySubscribers();\n }\n\n getMessageById(messageId: string) {\n const idx = this._messages.findIndex((m) => m.id === messageId);\n if (idx === -1) return undefined;\n return {\n parentId: this._messages[idx - 1]?.id ?? null,\n message: this._messages[idx]!,\n index: idx,\n };\n }\n\n getBranches(messageId: string) {\n const idx = this._messages.findIndex((m) => m.id === messageId);\n if (idx === -1) return [];\n return [messageId];\n }\n\n switchToBranch(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n append(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n deleteMessage(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n startRun(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n resumeRun(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n cancelRun(): void {}\n\n addToolResult(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n resumeToolCall(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n respondToToolApproval(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n speak(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n stopSpeaking(): void {}\n\n connectVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n disconnectVoice(): void {}\n\n getVoiceVolume = () => 0;\n subscribeVoiceVolume = (): Unsubscribe => () => {};\n\n muteVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n unmuteVoice(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n submitFeedback(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n getModelContext() {\n return {};\n }\n\n exportExternalState() {\n throw READONLY_THREAD_ERROR;\n }\n\n importExternalState(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n composer = {\n attachments: [] as never[],\n attachmentAccept: \"*\",\n\n async addAttachment() {\n throw READONLY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw READONLY_THREAD_ERROR;\n },\n\n isEditing: false as const,\n canCancel: false,\n canSend: false,\n isEmpty: true,\n text: \"\",\n\n setText() {\n throw READONLY_THREAD_ERROR;\n },\n\n role: \"user\" as const,\n\n setRole() {\n throw READONLY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw READONLY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw READONLY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n queue: [] as never[],\n steerQueueItem() {},\n removeQueueItem() {},\n\n dictation: undefined,\n\n startDictation() {\n throw READONLY_THREAD_ERROR;\n },\n\n stopDictation() {\n // noop\n },\n\n quote: undefined,\n\n setQuote() {\n throw READONLY_THREAD_ERROR;\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n };\n\n getEditComposer() {\n return undefined;\n }\n\n beginEdit(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n speech = undefined;\n voice = undefined;\n\n capabilities = {\n switchToBranch: false,\n switchBranchDuringRun: false,\n edit: false,\n delete: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n } as const;\n\n isDisabled = false;\n isSendDisabled = false;\n isLoading = false;\n\n state = null;\n suggestions = [] as never[];\n extras = undefined;\n\n import(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n export() {\n return {\n messages: this._messages.map((message, idx) => ({\n message,\n parentId: this._messages[idx - 1]?.id ?? null,\n })),\n };\n }\n\n reset(): void {\n throw READONLY_THREAD_ERROR;\n }\n\n unstable_on(): Unsubscribe {\n return () => {};\n }\n}\n"],"mappings":";;AAKA,MAAMI,wCAAwB,IAAIC,MAChC,8EACF;AAEA,IAAaC,4BAAb,cACUH,iBAEV;CACE,YAA8C,CAAA;CAE9C,IAAIK,WAAW;EACb,OAAO,KAAKD;CACd;CAEAE,YAAYD,UAAoC;EAC9C,IAAI,KAAKD,cAAcC,UAAU;EACjC,KAAKD,YAAYC;EACjB,KAAKE,mBAAmB;CAC1B;CAEAC,eAAeC,WAAmB;EAChC,MAAMC,MAAM,KAAKN,UAAUO,WAAWC,MAAMA,EAAEC,OAAOJ,SAAS;EAC9D,IAAIC,QAAQ,IAAI,OAAOI,KAAAA;EACvB,OAAO;GACLC,UAAU,KAAKX,UAAUM,MAAM,EAAE,EAAEG,MAAM;GACzCG,SAAS,KAAKZ,UAAUM;GACxBO,OAAOP;EACT;CACF;CAEAQ,YAAYT,WAAmB;EAE7B,IADY,KAAKL,UAAUO,WAAWC,MAAMA,EAAEC,OAAOJ,SACjDC,MAAQ,IAAI,OAAO,CAAA;EACvB,OAAO,CAACD,SAAS;CACnB;CAEAU,iBAAuB;EACrB,MAAMlB;CACR;CAEAmB,SAAe;EACb,MAAMnB;CACR;CAEAoB,gBAAsB;EACpB,MAAMpB;CACR;CAEAqB,WAAiB;EACf,MAAMrB;CACR;CAEAsB,YAAkB;EAChB,MAAMtB;CACR;CAEAuB,YAAkB,CAAC;CAEnBC,gBAAsB;EACpB,MAAMxB;CACR;CAEAyB,iBAAuB;EACrB,MAAMzB;CACR;CAEA0B,wBAA8B;EAC5B,MAAM1B;CACR;CAEA2B,QAAc;EACZ,MAAM3B;CACR;CAEA4B,eAAqB,CAAC;CAEtBC,eAAqB;EACnB,MAAM7B;CACR;CAEA8B,kBAAwB,CAAC;C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AAU;EACVpB,OAAO;CACT;CAEAqB,aAAa;CACbC,iBAAiB;CACjBC,YAAY;CAEZC,QAAQ;CACRC,cAAc,CAAA;CACdC,SAASxE,KAAAA;CAETyE,SAAe;EACb,MAAMtF;CACR;CAEAuF,SAAS;EACP,OAAO,EACLnF,UAAU,KAAKD,UAAUqF,KAAKzE,SAASN,SAAS;GAC9CM;GACAD,UAAU,KAAKX,UAAUM,MAAM,EAAE,EAAEG,MAAM;EAC3C,EAAE,EACJ;CACF;CAEA2C,QAAc;EACZ,MAAMvD;CACR;CAEAoE,cAA2B;EACzB,aAAa,CAAC;CAChB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory.js","names":[],"sources":["../../../../src/runtimes/remote-thread-list/adapter/in-memory.ts"],"sourcesContent":["import type { AssistantStream, AssistantStreamChunk } from \"assistant-stream\";\nimport type {\n RemoteThreadInitializeResponse,\n RemoteThreadListAdapter,\n RemoteThreadListResponse,\n RemoteThreadMetadata,\n} from \"../types\";\n\nexport class InMemoryThreadListAdapter implements RemoteThreadListAdapter {\n list(): Promise<RemoteThreadListResponse> {\n return Promise.resolve({\n threads: [],\n });\n }\n\n rename(): Promise<void> {\n return Promise.resolve();\n }\n\n updateCustom(): Promise<void> {\n return Promise.resolve();\n }\n\n archive(): Promise<void> {\n return Promise.resolve();\n }\n\n unarchive(): Promise<void> {\n return Promise.resolve();\n }\n\n delete(): Promise<void> {\n return Promise.resolve();\n }\n\n initialize(threadId: string): Promise<RemoteThreadInitializeResponse> {\n return Promise.resolve({ remoteId: threadId, externalId: undefined });\n }\n\n generateTitle(): Promise<AssistantStream> {\n return Promise.resolve(new ReadableStream<AssistantStreamChunk>());\n }\n\n fetch(_threadId: string): Promise<RemoteThreadMetadata> {\n return Promise.reject(new Error(\"Thread not found\"));\n }\n}\n"],"mappings":";AAQA,
|
|
1
|
+
{"version":3,"file":"in-memory.js","names":["AssistantStream","AssistantStreamChunk","RemoteThreadInitializeResponse","RemoteThreadListAdapter","RemoteThreadListResponse","RemoteThreadMetadata","InMemoryThreadListAdapter","list","Promise","resolve","threads","rename","updateCustom","archive","unarchive","delete","initialize","threadId","remoteId","externalId","undefined","generateTitle","ReadableStream","fetch","_threadId","reject","Error"],"sources":["../../../../src/runtimes/remote-thread-list/adapter/in-memory.ts"],"sourcesContent":["import type { AssistantStream, AssistantStreamChunk } from \"assistant-stream\";\nimport type {\n RemoteThreadInitializeResponse,\n RemoteThreadListAdapter,\n RemoteThreadListResponse,\n RemoteThreadMetadata,\n} from \"../types\";\n\nexport class InMemoryThreadListAdapter implements RemoteThreadListAdapter {\n list(): Promise<RemoteThreadListResponse> {\n return Promise.resolve({\n threads: [],\n });\n }\n\n rename(): Promise<void> {\n return Promise.resolve();\n }\n\n updateCustom(): Promise<void> {\n return Promise.resolve();\n }\n\n archive(): Promise<void> {\n return Promise.resolve();\n }\n\n unarchive(): Promise<void> {\n return Promise.resolve();\n }\n\n delete(): Promise<void> {\n return Promise.resolve();\n }\n\n initialize(threadId: string): Promise<RemoteThreadInitializeResponse> {\n return Promise.resolve({ remoteId: threadId, externalId: undefined });\n }\n\n generateTitle(): Promise<AssistantStream> {\n return Promise.resolve(new ReadableStream<AssistantStreamChunk>());\n }\n\n fetch(_threadId: string): Promise<RemoteThreadMetadata> {\n return Promise.reject(new Error(\"Thread not found\"));\n }\n}\n"],"mappings":";AAQA,IAAaM,4BAAb,MAA0E;CACxEC,OAA0C;EACxC,OAAOC,QAAQC,QAAQ,EACrBC,SAAS,CAAA,EACX,CAAC;CACH;CAEAC,SAAwB;EACtB,OAAOH,QAAQC,QAAQ;CACzB;CAEAG,eAA8B;EAC5B,OAAOJ,QAAQC,QAAQ;CACzB;CAEAI,UAAyB;EACvB,OAAOL,QAAQC,QAAQ;CACzB;CAEAK,YAA2B;EACzB,OAAON,QAAQC,QAAQ;CACzB;CAEAM,SAAwB;EACtB,OAAOP,QAAQC,QAAQ;CACzB;CAEAO,WAAWC,UAA2D;EACpE,OAAOT,QAAQC,QAAQ;GAAES,UAAUD;GAAUE,YAAYC,KAAAA;EAAU,CAAC;CACtE;CAEAC,gBAA0C;EACxC,OAAOb,QAAQC,QAAQ,IAAIa,eAAqC,CAAC;CACnE;CAEAC,MAAMC,WAAkD;EACtD,OAAOhB,QAAQiB,uBAAO,IAAIC,MAAM,kBAAkB,CAAC;CACrD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty-thread-core.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/empty-thread-core.ts"],"mappings":";;;cAKa,iBAAA,EAAmB,
|
|
1
|
+
{"version":3,"file":"empty-thread-core.d.ts","names":[],"sources":["../../../src/runtimes/remote-thread-list/empty-thread-core.ts"],"mappings":";;;cAKa,iBAAA,EAAmB,iBAmO/B"}
|
|
@@ -11,6 +11,9 @@ const EMPTY_THREAD_CORE = {
|
|
|
11
11
|
append() {
|
|
12
12
|
throw EMPTY_THREAD_ERROR;
|
|
13
13
|
},
|
|
14
|
+
deleteMessage() {
|
|
15
|
+
throw EMPTY_THREAD_ERROR;
|
|
16
|
+
},
|
|
14
17
|
startRun() {
|
|
15
18
|
throw EMPTY_THREAD_ERROR;
|
|
16
19
|
},
|
|
@@ -121,6 +124,7 @@ const EMPTY_THREAD_CORE = {
|
|
|
121
124
|
switchToBranch: false,
|
|
122
125
|
switchBranchDuringRun: false,
|
|
123
126
|
edit: false,
|
|
127
|
+
delete: false,
|
|
124
128
|
reload: false,
|
|
125
129
|
cancel: false,
|
|
126
130
|
unstable_copy: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty-thread-core.js","names":[],"sources":["../../../src/runtimes/remote-thread-list/empty-thread-core.ts"],"sourcesContent":["import type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n resumeRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n resumeToolCall() {\n throw EMPTY_THREAD_ERROR;\n },\n\n respondToToolApproval() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n connectVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n disconnectVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getVoiceVolume: () => 0,\n subscribeVoiceVolume: () => () => {},\n\n muteVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n unmuteVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelContext() {\n return {};\n },\n\n exportExternalState() {\n throw EMPTY_THREAD_ERROR;\n },\n\n importExternalState() {\n throw EMPTY_THREAD_ERROR;\n },\n\n composer: {\n attachments: [],\n attachmentAccept: \"*\",\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: true,\n\n canCancel: false,\n canSend: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n queue: [] as never[],\n steerQueueItem() {},\n removeQueueItem() {},\n\n dictation: undefined,\n\n startDictation() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopDictation() {\n // noop\n },\n\n quote: undefined,\n\n setQuote() {\n throw EMPTY_THREAD_ERROR;\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n },\n\n getEditComposer() {\n return undefined;\n },\n\n beginEdit() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speech: undefined,\n voice: undefined,\n\n capabilities: {\n switchToBranch: false,\n switchBranchDuringRun: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n },\n\n isDisabled: false,\n isSendDisabled: false,\n isLoading: true,\n\n messages: [],\n\n state: null,\n\n suggestions: [],\n\n extras: undefined,\n\n subscribe() {\n return () => {};\n },\n\n import() {\n throw EMPTY_THREAD_ERROR;\n },\n\n export() {\n return { messages: [] };\n },\n\n reset() {\n throw EMPTY_THREAD_ERROR;\n },\n\n unstable_on() {\n return () => {};\n },\n};\n"],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"empty-thread-core.js","names":["ThreadRuntimeCore","EMPTY_THREAD_ERROR","Error","EMPTY_THREAD_CORE","getMessageById","undefined","getBranches","switchToBranch","append","deleteMessage","startRun","resumeRun","cancelRun","addToolResult","resumeToolCall","respondToToolApproval","speak","stopSpeaking","connectVoice","disconnectVoice","getVoiceVolume","subscribeVoiceVolume","muteVoice","unmuteVoice","submitFeedback","getModelContext","exportExternalState","importExternalState","composer","attachments","attachmentAccept","addAttachment","removeAttachment","isEditing","canCancel","canSend","isEmpty","text","setText","role","setRole","runConfig","setRunConfig","reset","clearAttachments","send","cancel","queue","steerQueueItem","removeQueueItem","dictation","startDictation","stopDictation","quote","setQuote","subscribe","unstable_on","getEditComposer","beginEdit","speech","voice","capabilities","switchBranchDuringRun","edit","delete","reload","unstable_copy","feedback","isDisabled","isSendDisabled","isLoading","messages","state","suggestions","extras","import","export"],"sources":["../../../src/runtimes/remote-thread-list/empty-thread-core.ts"],"sourcesContent":["import type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\n\nconst EMPTY_THREAD_ERROR = new Error(\n \"This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead.\",\n);\nexport const EMPTY_THREAD_CORE: ThreadRuntimeCore = {\n getMessageById() {\n return undefined;\n },\n\n getBranches() {\n return [];\n },\n\n switchToBranch() {\n throw EMPTY_THREAD_ERROR;\n },\n\n append() {\n throw EMPTY_THREAD_ERROR;\n },\n\n deleteMessage() {\n throw EMPTY_THREAD_ERROR;\n },\n\n startRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n resumeRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancelRun() {\n throw EMPTY_THREAD_ERROR;\n },\n\n addToolResult() {\n throw EMPTY_THREAD_ERROR;\n },\n\n resumeToolCall() {\n throw EMPTY_THREAD_ERROR;\n },\n\n respondToToolApproval() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speak() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopSpeaking() {\n throw EMPTY_THREAD_ERROR;\n },\n\n connectVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n disconnectVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getVoiceVolume: () => 0,\n subscribeVoiceVolume: () => () => {},\n\n muteVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n unmuteVoice() {\n throw EMPTY_THREAD_ERROR;\n },\n\n submitFeedback() {\n throw EMPTY_THREAD_ERROR;\n },\n\n getModelContext() {\n return {};\n },\n\n exportExternalState() {\n throw EMPTY_THREAD_ERROR;\n },\n\n importExternalState() {\n throw EMPTY_THREAD_ERROR;\n },\n\n composer: {\n attachments: [],\n attachmentAccept: \"*\",\n\n async addAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async removeAttachment() {\n throw EMPTY_THREAD_ERROR;\n },\n\n isEditing: true,\n\n canCancel: false,\n canSend: false,\n isEmpty: true,\n\n text: \"\",\n\n setText() {\n throw EMPTY_THREAD_ERROR;\n },\n\n role: \"user\",\n\n setRole() {\n throw EMPTY_THREAD_ERROR;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw EMPTY_THREAD_ERROR;\n },\n\n async reset() {\n // noop\n },\n\n async clearAttachments() {\n // noop\n },\n\n send() {\n throw EMPTY_THREAD_ERROR;\n },\n\n cancel() {\n // noop\n },\n\n queue: [] as never[],\n steerQueueItem() {},\n removeQueueItem() {},\n\n dictation: undefined,\n\n startDictation() {\n throw EMPTY_THREAD_ERROR;\n },\n\n stopDictation() {\n // noop\n },\n\n quote: undefined,\n\n setQuote() {\n throw EMPTY_THREAD_ERROR;\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n },\n\n getEditComposer() {\n return undefined;\n },\n\n beginEdit() {\n throw EMPTY_THREAD_ERROR;\n },\n\n speech: undefined,\n voice: undefined,\n\n capabilities: {\n switchToBranch: false,\n switchBranchDuringRun: false,\n edit: false,\n delete: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n dictation: false,\n voice: false,\n attachments: false,\n feedback: false,\n queue: false,\n },\n\n isDisabled: false,\n isSendDisabled: false,\n isLoading: true,\n\n messages: [],\n\n state: null,\n\n suggestions: [],\n\n extras: undefined,\n\n subscribe() {\n return () => {};\n },\n\n import() {\n throw EMPTY_THREAD_ERROR;\n },\n\n export() {\n return { messages: [] };\n },\n\n reset() {\n throw EMPTY_THREAD_ERROR;\n },\n\n unstable_on() {\n return () => {};\n },\n};\n"],"mappings":";AAEA,MAAMC,qCAAqB,IAAIC,MAC7B,mQACF;AACA,MAAaC,oBAAuC;CAClDC,iB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