@assistant-ui/core 0.3.14 → 0.3.16
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/voice.js +11 -0
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +8 -2
- package/dist/internal.js +9 -3
- package/dist/model-context/frame/host.d.ts +1 -1
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +20 -5
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +6 -0
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +126 -16
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/frame/types.d.ts +4 -1
- package/dist/model-context/frame/types.d.ts.map +1 -1
- package/dist/model-context/frame/types.js.map +1 -1
- package/dist/model-context/interactable-composer-metadata.d.ts +1 -1
- package/dist/model-context/interactable-composer-metadata.js +1 -1
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/model-context/registry.d.ts +2 -2
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/registry.js +9 -28
- package/dist/model-context/registry.js.map +1 -1
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/react/client/InMemoryThreadList.js +24 -20
- package/dist/react/client/InMemoryThreadList.js.map +1 -1
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +59 -177
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +1 -1
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
- package/dist/react/client/RemoteThreadList.js +117 -78
- package/dist/react/client/RemoteThreadList.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +56 -174
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +24 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +138 -0
- package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -0
- package/dist/react/primitive-hooks/useActionBarCopy.js +7 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +3 -0
- package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsEmpty.js +3 -0
- package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +3 -0
- package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useThreadIsRunning.js +3 -0
- package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +3 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +6 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +7 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +174 -64
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.js +2 -0
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/runManager.js +2 -12
- package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +1 -1
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +3 -10
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +20 -67
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +12 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.js +10 -0
- package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.js.map +1 -0
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +38 -5
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +2 -1
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +6 -25
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +33 -233
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +1 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +1 -2
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +14 -29
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -4
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +3 -9
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +1 -1
- package/dist/runtime/internal.d.ts +2 -1
- package/dist/runtime/internal.js +2 -1
- package/dist/runtime/queue/external-thread-queue-adapter.d.ts +1 -1
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +1 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/queue/queue-item.d.ts +12 -0
- package/dist/runtime/queue/queue-item.d.ts.map +1 -0
- package/dist/runtime/queue/queue-item.js +6 -0
- package/dist/runtime/queue/queue-item.js.map +1 -0
- package/dist/runtime/utils/abortable-thread-load.d.ts +15 -0
- package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -0
- package/dist/runtime/utils/abortable-thread-load.js +35 -0
- package/dist/runtime/utils/abortable-thread-load.js.map +1 -0
- package/dist/runtime/utils/attachment-add-operations.d.ts +18 -0
- package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -0
- package/dist/runtime/utils/attachment-add-operations.js +43 -0
- package/dist/runtime/utils/attachment-add-operations.js.map +1 -0
- package/dist/runtime/utils/auto-status.d.ts +6 -1
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.js +7 -1
- package/dist/runtime/utils/auto-status.js.map +1 -1
- package/dist/runtime/utils/external-message-conversion.d.ts +47 -0
- package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -0
- package/dist/runtime/utils/external-message-conversion.js +221 -0
- package/dist/runtime/utils/external-message-conversion.js.map +1 -0
- package/dist/runtime/utils/external-store-message.d.ts +2 -1
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.js +2 -1
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/message-repository-session.d.ts +30 -0
- package/dist/runtime/utils/message-repository-session.d.ts.map +1 -0
- package/dist/runtime/utils/message-repository-session.js +130 -0
- package/dist/runtime/utils/message-repository-session.js.map +1 -0
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +30 -22
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/pending-tool-calls.d.ts +20 -0
- package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -0
- package/dist/runtime/utils/pending-tool-calls.js +22 -0
- package/dist/runtime/utils/pending-tool-calls.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.d.ts +2 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +2 -5
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +3 -10
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +19 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +124 -20
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +102 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.js +156 -0
- package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +3 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +45 -8
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +12 -60
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +10 -145
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +9 -0
- package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter-changed.js +13 -0
- package/dist/runtimes/remote-thread-list/adapter-changed.js.map +1 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +16 -155
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +11 -0
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +12 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +77 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -0
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/external-thread.d.ts.map +1 -1
- package/dist/store/clients/external-thread.js +75 -100
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/single-thread-list.d.ts.map +1 -1
- package/dist/store/clients/single-thread-list.js +1 -1
- package/dist/store/clients/single-thread-list.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +16 -7
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/index.d.ts +4 -2
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.js +2 -0
- package/dist/store/runtime-clients/handle-runtime-action.js.map +1 -1
- package/dist/store/scope-registration.d.ts +1 -1
- package/dist/store/scopes/composer.d.ts +2 -1
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +1 -1
- package/dist/store/scopes/queue-item.d.ts +2 -9
- package/dist/store/scopes/queue-item.d.ts.map +1 -1
- package/dist/store/scopes/queue-item.js +0 -6
- package/dist/types/message.d.ts +8 -4
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/data-url.d.ts +14 -1
- package/dist/utils/data-url.d.ts.map +1 -1
- package/dist/utils/data-url.js +13 -1
- package/dist/utils/data-url.js.map +1 -1
- package/dist/utils/invoke-user-callback.d.ts +5 -0
- package/dist/utils/invoke-user-callback.d.ts.map +1 -0
- package/dist/utils/invoke-user-callback.js +19 -0
- package/dist/utils/invoke-user-callback.js.map +1 -0
- package/dist/utils/normalizePartStatus.js.map +1 -1
- package/dist/utils/silent-runtime-action.d.ts +6 -0
- package/dist/utils/silent-runtime-action.d.ts.map +1 -0
- package/dist/utils/silent-runtime-action.js +7 -0
- package/dist/utils/silent-runtime-action.js.map +1 -0
- package/package.json +10 -10
- package/src/adapters/voice.test.ts +66 -1
- package/src/adapters/voice.ts +8 -0
- package/src/internal.ts +13 -0
- package/src/model-context/frame/host.test.ts +152 -9
- package/src/model-context/frame/host.ts +23 -5
- package/src/model-context/frame/provider.test.ts +601 -19
- package/src/model-context/frame/provider.ts +158 -20
- package/src/model-context/frame/types.ts +5 -0
- package/src/model-context/interactable-composer-metadata.ts +1 -1
- package/src/model-context/registry.test.ts +44 -0
- package/src/model-context/registry.ts +13 -35
- package/src/react/client/InMemoryThreadList.test.tsx +49 -0
- package/src/react/client/InMemoryThreadList.ts +7 -1
- package/src/react/client/Interactables.ts +19 -178
- package/src/react/client/RemoteThreadList.test.ts +292 -0
- package/src/react/client/RemoteThreadList.ts +119 -82
- package/src/react/interactables-legacy/Interactables.ts +20 -177
- package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +161 -0
- package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +206 -0
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +15 -0
- package/src/react/primitive-hooks/useActionBarCopy.ts +13 -3
- package/src/react/primitive-hooks/useThreadIsEmpty.ts +3 -0
- package/src/react/primitive-hooks/useThreadIsRunning.ts +3 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +12 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.republish.test.ts +87 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +251 -76
- package/src/react/runtimes/RemoteThreadResource.ts +2 -0
- package/src/react/runtimes/assistant-transport/runManager.ts +4 -17
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +58 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +3 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +92 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +40 -141
- package/src/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.test.ts +37 -0
- package/src/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.ts +18 -0
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +98 -3
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +68 -6
- package/src/react/runtimes/external-message-converter.test.ts +0 -14
- package/src/react/runtimes/external-message-converter.test.tsx +77 -0
- package/src/react/runtimes/external-message-converter.ts +58 -481
- package/src/react/runtimes/useLocalRuntime.test.tsx +5 -5
- package/src/runtime/api/composer-runtime.ts +1 -1
- package/src/runtime/api/message-runtime.test.ts +28 -1
- package/src/runtime/base/base-composer-runtime-core.ts +20 -40
- package/src/runtime/base/base-thread-runtime-core.test.ts +16 -0
- package/src/runtime/base/base-thread-runtime-core.ts +6 -11
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -4
- package/src/runtime/interfaces/composer-runtime-core.ts +1 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +1 -1
- package/src/runtime/internal.ts +5 -0
- package/src/runtime/queue/external-thread-queue-adapter.ts +1 -1
- package/src/runtime/queue/message-queue.ts +1 -4
- package/src/runtime/queue/queue-item.ts +10 -0
- package/src/runtime/utils/abortable-thread-load.test.ts +87 -0
- package/src/runtime/utils/abortable-thread-load.ts +53 -0
- package/src/runtime/utils/attachment-add-operations.ts +59 -0
- package/src/runtime/utils/auto-status.ts +33 -0
- package/src/runtime/utils/external-message-conversion.test.ts +113 -0
- package/src/runtime/utils/external-message-conversion.ts +494 -0
- package/src/runtime/utils/external-store-message.ts +2 -0
- package/src/runtime/utils/message-repository-session.test.ts +195 -0
- package/src/runtime/utils/message-repository-session.ts +176 -0
- package/src/runtime/utils/message-repository.ts +33 -22
- package/src/runtime/utils/pending-tool-calls.test.ts +57 -0
- package/src/runtime/utils/pending-tool-calls.ts +35 -0
- package/src/runtime/utils/thread-message-like.ts +2 -0
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +6 -14
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +179 -28
- package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +253 -0
- package/src/runtimes/inert/InertThreadRuntimeCore.ts +232 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +491 -1
- package/src/runtimes/local/local-thread-runtime-core.ts +86 -11
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +17 -209
- package/src/runtimes/remote-thread-list/adapter-changed.ts +10 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +28 -221
- package/src/runtimes/remote-thread-list/optimistic-state.test.ts +18 -0
- package/src/runtimes/remote-thread-list/optimistic-state.ts +13 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.test.ts +37 -0
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +123 -0
- package/src/runtimes/remote-thread-list/types.ts +4 -0
- package/src/runtimes/tool-invocations/EDGE_CASES.md +17 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +140 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +3 -0
- package/src/store/clients/external-thread.ts +17 -62
- package/src/store/clients/single-thread-list.ts +4 -1
- package/src/store/clients/suggestions.test.ts +31 -0
- package/src/store/clients/suggestions.ts +18 -19
- package/src/store/runtime-clients/handle-runtime-action.test.ts +40 -0
- package/src/store/runtime-clients/handle-runtime-action.ts +3 -0
- package/src/store/scopes/message.ts +1 -1
- package/src/store/scopes/queue-item.ts +2 -9
- package/src/tests/MessageRepository.test.ts +125 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +2 -2
- package/src/tests/RemoteThreadListThreadListRuntimeCore-load-race.test.ts +194 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +8 -6
- package/src/tests/RemoteThreadListThreadListRuntimeCore-title-race.test.ts +158 -0
- package/src/tests/empty-thread-core.test.ts +6 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +184 -0
- package/src/tests/external-store-thread-runtime-core.test.ts +642 -0
- package/src/tests/external-thread-attachments.test.tsx +173 -0
- package/src/tests/external-thread-isEmpty.test.tsx +100 -0
- package/src/tests/remote-thread-list-adapter-switch.test.ts +383 -0
- package/src/tests/single-thread-list-item.test.tsx +47 -0
- package/src/tests/thread-message-like.test.ts +39 -1
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +67 -0
- package/src/types/message.ts +9 -4
- package/src/utils/data-url.test.ts +52 -1
- package/src/utils/data-url.ts +21 -0
- package/src/utils/invoke-user-callback.test.ts +82 -0
- package/src/utils/invoke-user-callback.ts +31 -0
- package/src/utils/normalizePartStatus.ts +1 -1
- package/src/utils/silent-runtime-action.ts +6 -0
- package/dist/store/scopes/queue-item.js.map +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ThreadMessage } from "../../types/message.js";
|
|
2
|
+
import { Unsubscribe } from "../../types/unsubscribe.js";
|
|
3
|
+
import { ExportedMessageRepository } from "../../runtime/utils/message-repository.js";
|
|
4
|
+
import { ThreadRuntimeCore } from "../../runtime/interfaces/thread-runtime-core.js";
|
|
5
|
+
import { BaseSubscribable } from "../../subscribable/subscribable.js";
|
|
6
|
+
//#region src/runtimes/inert/InertThreadRuntimeCore.d.ts
|
|
7
|
+
declare const createInertComposer: <TIsEditing extends boolean>(error: Error, isEditing: TIsEditing) => {
|
|
8
|
+
attachments: never[];
|
|
9
|
+
attachmentAccept: string;
|
|
10
|
+
addAttachment(): Promise<never>;
|
|
11
|
+
removeAttachment(): Promise<never>;
|
|
12
|
+
isEditing: TIsEditing;
|
|
13
|
+
canCancel: boolean;
|
|
14
|
+
canSend: boolean;
|
|
15
|
+
isEmpty: boolean;
|
|
16
|
+
text: string;
|
|
17
|
+
setText(): never;
|
|
18
|
+
role: "user";
|
|
19
|
+
setRole(): never;
|
|
20
|
+
runConfig: {};
|
|
21
|
+
setRunConfig(): never;
|
|
22
|
+
reset(): Promise<void>;
|
|
23
|
+
clearAttachments(): Promise<void>;
|
|
24
|
+
send(): never;
|
|
25
|
+
cancel(): void;
|
|
26
|
+
queue: never[];
|
|
27
|
+
moveQueueItem(): void;
|
|
28
|
+
removeQueueItem(): void;
|
|
29
|
+
dictation: undefined;
|
|
30
|
+
startDictation(): never;
|
|
31
|
+
stopDictation(): void;
|
|
32
|
+
quote: undefined;
|
|
33
|
+
setQuote(): never;
|
|
34
|
+
subscribe(): () => void;
|
|
35
|
+
unstable_on(): () => void;
|
|
36
|
+
};
|
|
37
|
+
declare abstract class InertThreadRuntimeCore extends BaseSubscribable implements ThreadRuntimeCore {
|
|
38
|
+
protected abstract get error(): Error;
|
|
39
|
+
abstract readonly messages: readonly ThreadMessage[];
|
|
40
|
+
abstract readonly isLoading: boolean;
|
|
41
|
+
abstract readonly composer: ThreadRuntimeCore["composer"];
|
|
42
|
+
abstract getMessageById(messageId: string): {
|
|
43
|
+
parentId: string | null;
|
|
44
|
+
message: ThreadMessage;
|
|
45
|
+
index: number;
|
|
46
|
+
} | undefined;
|
|
47
|
+
abstract getBranches(messageId: string): readonly string[];
|
|
48
|
+
abstract export(): ExportedMessageRepository;
|
|
49
|
+
switchToBranch(): void;
|
|
50
|
+
append(): void;
|
|
51
|
+
deleteMessage(): void;
|
|
52
|
+
startRun(): void;
|
|
53
|
+
resumeRun(): void;
|
|
54
|
+
cancelRun(): void;
|
|
55
|
+
unstable_notifySessionReset(): void;
|
|
56
|
+
addToolResult(): void;
|
|
57
|
+
resumeToolCall(): void;
|
|
58
|
+
respondToToolApproval(): void;
|
|
59
|
+
speak(): void;
|
|
60
|
+
stopSpeaking(): void;
|
|
61
|
+
connectVoice(): void;
|
|
62
|
+
disconnectVoice(): void;
|
|
63
|
+
muteVoice(): void;
|
|
64
|
+
unmuteVoice(): void;
|
|
65
|
+
submitFeedback(): void;
|
|
66
|
+
exportExternalState(): void;
|
|
67
|
+
importExternalState(): void;
|
|
68
|
+
beginEdit(): void;
|
|
69
|
+
import(): void;
|
|
70
|
+
reset(): void;
|
|
71
|
+
getModelContext(): {};
|
|
72
|
+
getEditComposer(): undefined;
|
|
73
|
+
getVoiceVolume: () => number;
|
|
74
|
+
subscribeVoiceVolume: () => Unsubscribe;
|
|
75
|
+
speech: undefined;
|
|
76
|
+
voice: undefined;
|
|
77
|
+
capabilities: {
|
|
78
|
+
readonly switchToBranch: false;
|
|
79
|
+
readonly switchBranchDuringRun: false;
|
|
80
|
+
readonly edit: false;
|
|
81
|
+
readonly delete: false;
|
|
82
|
+
readonly reload: false;
|
|
83
|
+
readonly refetchThread: false;
|
|
84
|
+
readonly cancel: false;
|
|
85
|
+
readonly unstable_copy: false;
|
|
86
|
+
readonly speech: false;
|
|
87
|
+
readonly dictation: false;
|
|
88
|
+
readonly voice: false;
|
|
89
|
+
readonly attachments: false;
|
|
90
|
+
readonly feedback: false;
|
|
91
|
+
readonly queue: false;
|
|
92
|
+
};
|
|
93
|
+
isDisabled: boolean;
|
|
94
|
+
isSendDisabled: boolean;
|
|
95
|
+
state: null;
|
|
96
|
+
suggestions: never[];
|
|
97
|
+
extras: undefined;
|
|
98
|
+
unstable_on(): Unsubscribe;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { InertThreadRuntimeCore, createInertComposer };
|
|
102
|
+
//# sourceMappingURL=InertThreadRuntimeCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InertThreadRuntimeCore.d.ts","names":[],"sources":["../../../src/runtimes/inert/InertThreadRuntimeCore.ts"],"mappings":";;;;;;cAMa,sBAAuB,4BAClC,OAAO,OACP,WAAW;EAEQ;;;;;;;;;;;;;;;;;;EA2CN;;;;;;;;;;;uBA2BO,+BACZ,4BACG;yBAEY,SAAS;oBAEd,mBAAmB;oBACnB;oBACA,UAAU;WAEnB,eAAe;IAElB;IACA,SAAS;IACT;;WAIG,YAAY;WAEZ,UAAU;EAEnB;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EAIA;EACA,4BAA2B;EAE3B;EACA;EAEA;;;;;;;;;;;;;;;;EAiBA;EACA;EAEA;EACA;EACA;EAEA,eAAe"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { BaseSubscribable } from "../../subscribable/subscribable.js";
|
|
2
|
+
//#region src/runtimes/inert/InertThreadRuntimeCore.ts
|
|
3
|
+
const createInertComposer = (error, isEditing) => ({
|
|
4
|
+
attachments: [],
|
|
5
|
+
attachmentAccept: "*",
|
|
6
|
+
async addAttachment() {
|
|
7
|
+
throw error;
|
|
8
|
+
},
|
|
9
|
+
async removeAttachment() {
|
|
10
|
+
throw error;
|
|
11
|
+
},
|
|
12
|
+
isEditing,
|
|
13
|
+
canCancel: false,
|
|
14
|
+
canSend: false,
|
|
15
|
+
isEmpty: true,
|
|
16
|
+
text: "",
|
|
17
|
+
setText() {
|
|
18
|
+
throw error;
|
|
19
|
+
},
|
|
20
|
+
role: "user",
|
|
21
|
+
setRole() {
|
|
22
|
+
throw error;
|
|
23
|
+
},
|
|
24
|
+
runConfig: {},
|
|
25
|
+
setRunConfig() {
|
|
26
|
+
throw error;
|
|
27
|
+
},
|
|
28
|
+
async reset() {},
|
|
29
|
+
async clearAttachments() {},
|
|
30
|
+
send() {
|
|
31
|
+
throw error;
|
|
32
|
+
},
|
|
33
|
+
cancel() {},
|
|
34
|
+
queue: [],
|
|
35
|
+
moveQueueItem() {},
|
|
36
|
+
removeQueueItem() {},
|
|
37
|
+
dictation: void 0,
|
|
38
|
+
startDictation() {
|
|
39
|
+
throw error;
|
|
40
|
+
},
|
|
41
|
+
stopDictation() {},
|
|
42
|
+
quote: void 0,
|
|
43
|
+
setQuote() {
|
|
44
|
+
throw error;
|
|
45
|
+
},
|
|
46
|
+
subscribe() {
|
|
47
|
+
return () => {};
|
|
48
|
+
},
|
|
49
|
+
unstable_on() {
|
|
50
|
+
return () => {};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
var InertThreadRuntimeCore = class extends BaseSubscribable {
|
|
54
|
+
switchToBranch() {
|
|
55
|
+
throw this.error;
|
|
56
|
+
}
|
|
57
|
+
append() {
|
|
58
|
+
throw this.error;
|
|
59
|
+
}
|
|
60
|
+
deleteMessage() {
|
|
61
|
+
throw this.error;
|
|
62
|
+
}
|
|
63
|
+
startRun() {
|
|
64
|
+
throw this.error;
|
|
65
|
+
}
|
|
66
|
+
resumeRun() {
|
|
67
|
+
throw this.error;
|
|
68
|
+
}
|
|
69
|
+
cancelRun() {
|
|
70
|
+
throw this.error;
|
|
71
|
+
}
|
|
72
|
+
unstable_notifySessionReset() {
|
|
73
|
+
throw this.error;
|
|
74
|
+
}
|
|
75
|
+
addToolResult() {
|
|
76
|
+
throw this.error;
|
|
77
|
+
}
|
|
78
|
+
resumeToolCall() {
|
|
79
|
+
throw this.error;
|
|
80
|
+
}
|
|
81
|
+
respondToToolApproval() {
|
|
82
|
+
throw this.error;
|
|
83
|
+
}
|
|
84
|
+
speak() {
|
|
85
|
+
throw this.error;
|
|
86
|
+
}
|
|
87
|
+
stopSpeaking() {
|
|
88
|
+
throw this.error;
|
|
89
|
+
}
|
|
90
|
+
connectVoice() {
|
|
91
|
+
throw this.error;
|
|
92
|
+
}
|
|
93
|
+
disconnectVoice() {
|
|
94
|
+
throw this.error;
|
|
95
|
+
}
|
|
96
|
+
muteVoice() {
|
|
97
|
+
throw this.error;
|
|
98
|
+
}
|
|
99
|
+
unmuteVoice() {
|
|
100
|
+
throw this.error;
|
|
101
|
+
}
|
|
102
|
+
submitFeedback() {
|
|
103
|
+
throw this.error;
|
|
104
|
+
}
|
|
105
|
+
exportExternalState() {
|
|
106
|
+
throw this.error;
|
|
107
|
+
}
|
|
108
|
+
importExternalState() {
|
|
109
|
+
throw this.error;
|
|
110
|
+
}
|
|
111
|
+
beginEdit() {
|
|
112
|
+
throw this.error;
|
|
113
|
+
}
|
|
114
|
+
import() {
|
|
115
|
+
throw this.error;
|
|
116
|
+
}
|
|
117
|
+
reset() {
|
|
118
|
+
throw this.error;
|
|
119
|
+
}
|
|
120
|
+
getModelContext() {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
getEditComposer() {}
|
|
124
|
+
getVoiceVolume = () => 0;
|
|
125
|
+
subscribeVoiceVolume = () => () => {};
|
|
126
|
+
speech = void 0;
|
|
127
|
+
voice = void 0;
|
|
128
|
+
capabilities = {
|
|
129
|
+
switchToBranch: false,
|
|
130
|
+
switchBranchDuringRun: false,
|
|
131
|
+
edit: false,
|
|
132
|
+
delete: false,
|
|
133
|
+
reload: false,
|
|
134
|
+
refetchThread: false,
|
|
135
|
+
cancel: false,
|
|
136
|
+
unstable_copy: false,
|
|
137
|
+
speech: false,
|
|
138
|
+
dictation: false,
|
|
139
|
+
voice: false,
|
|
140
|
+
attachments: false,
|
|
141
|
+
feedback: false,
|
|
142
|
+
queue: false
|
|
143
|
+
};
|
|
144
|
+
isDisabled = false;
|
|
145
|
+
isSendDisabled = false;
|
|
146
|
+
state = null;
|
|
147
|
+
suggestions = [];
|
|
148
|
+
extras = void 0;
|
|
149
|
+
unstable_on() {
|
|
150
|
+
return () => {};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
//#endregion
|
|
154
|
+
export { InertThreadRuntimeCore, createInertComposer };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=InertThreadRuntimeCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InertThreadRuntimeCore.js","names":["Unsubscribe","ThreadMessage","ThreadRuntimeCore","ExportedMessageRepository","BaseSubscribable","createInertComposer","error","Error","isEditing","TIsEditing","attachments","attachmentAccept","addAttachment","removeAttachment","canCancel","canSend","isEmpty","text","setText","role","const","setRole","runConfig","setRunConfig","reset","clearAttachments","send","cancel","queue","moveQueueItem","removeQueueItem","dictation","undefined","startDictation","stopDictation","quote","setQuote","subscribe","unstable_on","InertThreadRuntimeCore","messages","isLoading","composer","getMessageById","messageId","parentId","message","index","getBranches","export","switchToBranch","append","deleteMessage","startRun","resumeRun","cancelRun","unstable_notifySessionReset","addToolResult","resumeToolCall","respondToToolApproval","speak","stopSpeaking","connectVoice","disconnectVoice","muteVoice","unmuteVoice","submitFeedback","exportExternalState","importExternalState","beginEdit","import","getModelContext","getEditComposer","getVoiceVolume","subscribeVoiceVolume","speech","voice","capabilities","switchBranchDuringRun","edit","delete","reload","refetchThread","unstable_copy","feedback","isDisabled","isSendDisabled","state","suggestions","extras"],"sources":["../../../src/runtimes/inert/InertThreadRuntimeCore.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ThreadMessage } from \"../../types/message\";\nimport type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\nimport type { ExportedMessageRepository } from \"../../runtime/utils/message-repository\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\n\nexport const createInertComposer = <TIsEditing extends boolean>(\n error: Error,\n isEditing: TIsEditing,\n) => ({\n attachments: [] as never[],\n attachmentAccept: \"*\",\n\n async addAttachment() {\n throw error;\n },\n\n async removeAttachment() {\n throw error;\n },\n\n isEditing,\n canCancel: false,\n canSend: false,\n isEmpty: true,\n text: \"\",\n\n setText() {\n throw error;\n },\n\n role: \"user\" as const,\n\n setRole() {\n throw error;\n },\n\n runConfig: {},\n\n setRunConfig() {\n throw error;\n },\n\n async reset() {},\n\n async clearAttachments() {},\n\n send() {\n throw error;\n },\n\n cancel() {},\n\n queue: [] as never[],\n moveQueueItem() {},\n removeQueueItem() {},\n\n dictation: undefined,\n\n startDictation() {\n throw error;\n },\n\n stopDictation() {},\n\n quote: undefined,\n\n setQuote() {\n throw error;\n },\n\n subscribe() {\n return () => {};\n },\n\n unstable_on() {\n return () => {};\n },\n});\n\nexport abstract class InertThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n protected abstract get error(): Error;\n\n abstract readonly messages: readonly ThreadMessage[];\n abstract readonly isLoading: boolean;\n abstract readonly composer: ThreadRuntimeCore[\"composer\"];\n\n abstract getMessageById(messageId: string):\n | {\n parentId: string | null;\n message: ThreadMessage;\n index: number;\n }\n | undefined;\n\n abstract getBranches(messageId: string): readonly string[];\n\n abstract export(): ExportedMessageRepository;\n\n switchToBranch(): void {\n throw this.error;\n }\n\n append(): void {\n throw this.error;\n }\n\n deleteMessage(): void {\n throw this.error;\n }\n\n startRun(): void {\n throw this.error;\n }\n\n resumeRun(): void {\n throw this.error;\n }\n\n cancelRun(): void {\n throw this.error;\n }\n\n unstable_notifySessionReset(): void {\n throw this.error;\n }\n\n addToolResult(): void {\n throw this.error;\n }\n\n resumeToolCall(): void {\n throw this.error;\n }\n\n respondToToolApproval(): void {\n throw this.error;\n }\n\n speak(): void {\n throw this.error;\n }\n\n stopSpeaking(): void {\n throw this.error;\n }\n\n connectVoice(): void {\n throw this.error;\n }\n\n disconnectVoice(): void {\n throw this.error;\n }\n\n muteVoice(): void {\n throw this.error;\n }\n\n unmuteVoice(): void {\n throw this.error;\n }\n\n submitFeedback(): void {\n throw this.error;\n }\n\n exportExternalState(): void {\n throw this.error;\n }\n\n importExternalState(): void {\n throw this.error;\n }\n\n beginEdit(): void {\n throw this.error;\n }\n\n import(): void {\n throw this.error;\n }\n\n reset(): void {\n throw this.error;\n }\n\n getModelContext() {\n return {};\n }\n\n getEditComposer() {\n return undefined;\n }\n\n getVoiceVolume = () => 0;\n subscribeVoiceVolume = (): Unsubscribe => () => {};\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 refetchThread: 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\n state = null;\n suggestions = [] as never[];\n extras = undefined;\n\n unstable_on(): Unsubscribe {\n return () => {};\n }\n}\n"],"mappings":";;AAMA,MAAaK,uBACXC,OACAE,eACI;CACJE,aAAa,CAAA;CACbC,kBAAkB;CAElB,MAAMC,gBAAgB;EACpB,MAAMN;CACR;CAEA,MAAMO,mBAAmB;EACvB,MAAMP;CACR;CAEAE;CACAM,WAAW;CACXC,SAAS;CACTC,SAAS;CACTC,MAAM;CAENC,UAAU;EACR,MAAMZ;CACR;CAEAa,MAAM;CAENE,UAAU;EACR,MAAMf;CACR;CAEAgB,WAAW,CAAC;CAEZC,eAAe;EACb,MAAMjB;CACR;CAEA,MAAMkB,QAAQ,CAAC;CAEf,MAAMC,mBAAmB,CAAC;CAE1BC,OAAO;EACL,MAAMpB;CACR;CAEAqB,SAAS,CAAC;CAEVC,OAAO,CAAA;CACPC,gBAAgB,CAAC;CACjBC,kBAAkB,CAAC;CAEnBC,WAAWC,KAAAA;CAEXC,iBAAiB;EACf,MAAM3B;CACR;CAEA4B,gBAAgB,CAAC;CAEjBC,OAAOH,KAAAA;CAEPI,WAAW;EACT,MAAM9B;CACR;CAEA+B,YAAY;EACV,aAAa,CAAC;CAChB;CAEAC,cAAc;EACZ,aAAa,CAAC;CAChB;AACF;AAEA,IAAsBC,yBAAtB,cACUnC,iBAEV;CAmBE8C,iBAAuB;EACrB,MAAM,KAAK5C;CACb;CAEA6C,SAAe;EACb,MAAM,KAAK7C;CACb;CAEA8C,gBAAsB;EACpB,MAAM,KAAK9C;CACb;CAEA+C,WAAiB;EACf,MAAM,KAAK/C;CACb;CAEAgD,YAAkB;EAChB,MAAM,KAAKhD;CACb;CAEAiD,YAAkB;EAChB,MAAM,KAAKjD;CACb;CAEAkD,8BAAoC;EAClC,MAAM,KAAKlD;CACb;CAEAmD,gBAAsB;EACpB,MAAM,KAAKnD;CACb;CAEAoD,iBAAuB;EACrB,MAAM,KAAKpD;CACb;CAEAqD,wBAA8B;EAC5B,MAAM,KAAKrD;CACb;CAEAsD,QAAc;EACZ,MAAM,KAAKtD;CACb;CAEAuD,eAAqB;EACnB,MAAM,KAAKvD;CACb;CAEAwD,eAAqB;EACnB,MAAM,KAAKxD;CACb;CAEAyD,kBAAwB;EACtB,MAAM,KAAKzD;CACb;CAEA0D,YAAkB;EAChB,MAAM,KAAK1D;CACb;CAEA2D,cAAoB;EAClB,MAAM,KAAK3D;CACb;CAEA4D,iBAAuB;EACrB,MAAM,KAAK5D;CACb;CAEA6D,sBAA4B;EAC1B,MAAM,KAAK7D;CACb;CAEA8D,sBAA4B;EAC1B,MAAM,KAAK9D;CACb;CAEA+D,YAAkB;EAChB,MAAM,KAAK/D;CACb;CAEAgE,SAAe;EACb,MAAM,KAAKhE;CACb;CAEAkB,QAAc;EACZ,MAAM,KAAKlB;CACb;CAEAiE,kBAAkB;EAChB,OAAO,CAAC;CACV;CAEAC,kBAAkB,CAElB;CAEAC,uBAAuB;CACvBC,mCAAgD,CAAC;CAEjDC,SAAS3C,KAAAA;CACT4C,QAAQ5C,KAAAA;CAER6C,eAAe;EACb3B,gBAAgB;EAChB4B,uBAAuB;EACvBC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,eAAe;EACfvD,QAAQ;EACRwD,eAAe;EACfR,QAAQ;EACR5C,WAAW;EACX6C,OAAO;EACPlE,aAAa;EACb0E,UAAU;EACVxD,OAAO;CACT;CAEAyD,aAAa;CACbC,iBAAiB;CAEjBC,QAAQ;CACRC,cAAc,CAAA;CACdC,SAASzD,KAAAA;CAETM,cAA2B;EACzB,aAAa,CAAC;CAChB;AACF"}
|
|
@@ -5,8 +5,9 @@ import { DictationAdapter, SpeechSynthesisAdapter } from "../../adapters/speech.
|
|
|
5
5
|
import { RealtimeVoiceAdapter } from "../../adapters/voice.js";
|
|
6
6
|
import { ModelContextProvider } from "../../model-context/types.js";
|
|
7
7
|
import { ChatModelAdapter } from "../../runtime/utils/chat-model-adapter.js";
|
|
8
|
+
import { ExportedMessageRepository } from "../../runtime/utils/message-repository.js";
|
|
9
|
+
import { QueueItemState } from "../../runtime/queue/queue-item.js";
|
|
8
10
|
import { QueuePlacement } from "../../runtime/queue/external-thread-queue-adapter.js";
|
|
9
|
-
import { QueueItemState } from "../../store/scopes/queue-item.js";
|
|
10
11
|
import { AddToolResultOptions, RespondToToolApprovalOptions, ResumeRunConfig, ResumeToolCallOptions, StartRunConfig, ThreadRuntimeCore, ThreadSuggestion } from "../../runtime/interfaces/thread-runtime-core.js";
|
|
11
12
|
import { SuggestionAdapter } from "../../adapters/suggestion.js";
|
|
12
13
|
import { ThreadHistoryAdapter } from "../../adapters/thread-history.js";
|
|
@@ -78,6 +79,7 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
|
|
|
78
79
|
deleteMessage(messageId: string): Promise<void>;
|
|
79
80
|
resumeRun({ stream, ...startConfig }: ResumeRunConfig): Promise<void>;
|
|
80
81
|
exportExternalState(): any;
|
|
82
|
+
import(data: ExportedMessageRepository): void;
|
|
81
83
|
importExternalState(): void;
|
|
82
84
|
unstable_notifySessionReset(): void;
|
|
83
85
|
startRun({ parentId, runConfig }: StartRunConfig, runCallback?: ChatModelAdapter["run"]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtimes/local/local-thread-runtime-core.ts"],"mappings":";;;;;;;;;;;;;;;;;cA4Fa,+BACH,iCACG;WAEK;;;;;;;;;;;;;;;;UAiBR;UAEA;UACA;UACA;UACA;UAEA;UAIA;UAuBA;WAYQ;WACA;UAER;MACG;UAIH;UACA;MACG,wBAAwB;MAIxB;;;;;;;;;;EAKT,YAAA,iBAAiB,sBACjB,SAAS;UAMH;UAEA;UAEA;EAED,0BAA0B;UAIzB;EAED,mCACL,kBAAkB;MAKT;EAIJ,sBAAsB,SAAS;UA6F9B;UACA;EACD,mBAAe;EAyCT,OAAO,SAAS,gBAAgB;EAkBtC,0BAA0B;EAM1B,+BAA+B;EAI/B,cAAc,qBAAqB,WAAW;EAI9C,gBAAgB;UAIf;UASM;EA4DD,cAAc,oBAAoB;EAmBxC,YAAY,WAAW,eAAe,kBAAkB;EAMxD;EAIS,OAAO,MAAM;EAItB;EAIA;EAIM,WACT,UAAU,aAAa,gBACzB,cAAc,0BACb;UAuBW;UA6EA;EA8NP;EAWA;EAgBA,gBACL,WACA,YACA,QACA,SACA,YACC;EA6CI,eAAe,UAAU;EAMzB,wBACL,YACA,UACA,UACA,UACC"}
|
|
@@ -2,7 +2,8 @@ import { generateId } from "../../utils/id.js";
|
|
|
2
2
|
import { consumeSuggestionResult } from "../../adapters/suggestion.js";
|
|
3
3
|
import { MessageNotSentError, toAssistantError } from "../../types/error.js";
|
|
4
4
|
import { fromThreadMessageLike } from "../../runtime/utils/thread-message-like.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getAutoStatus } from "../../runtime/utils/auto-status.js";
|
|
6
|
+
import { EMPTY_QUEUE_ITEMS } from "../../runtime/queue/queue-item.js";
|
|
6
7
|
import { createMessageQueue } from "../../runtime/queue/message-queue.js";
|
|
7
8
|
import { BaseThreadRuntimeCore } from "../../runtime/base/base-thread-runtime-core.js";
|
|
8
9
|
import { shouldContinue } from "./should-continue.js";
|
|
@@ -16,6 +17,20 @@ var AbortError = class extends Error {
|
|
|
16
17
|
this.detach = detach;
|
|
17
18
|
}
|
|
18
19
|
};
|
|
20
|
+
const withLocalPauseReason = (message) => {
|
|
21
|
+
if (message.role !== "assistant" || message.status.type !== "requires-action" || message.status.reason !== "interrupt" || message.content.some((c) => c.type === "tool-call" && c.result === void 0 && c.interrupt != null)) return message;
|
|
22
|
+
return {
|
|
23
|
+
...message,
|
|
24
|
+
status: getAutoStatus(false, false, false, message.content.some((c) => c.type === "tool-call" && c.result === void 0))
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const withLocalPauseReasons = (data) => ({
|
|
28
|
+
...data,
|
|
29
|
+
messages: data.messages.map((item) => ({
|
|
30
|
+
...item,
|
|
31
|
+
message: withLocalPauseReason(item.message)
|
|
32
|
+
}))
|
|
33
|
+
});
|
|
19
34
|
var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
20
35
|
capabilities = {
|
|
21
36
|
switchToBranch: true,
|
|
@@ -159,7 +174,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
159
174
|
this._notifySubscribers();
|
|
160
175
|
this._loadPromise = promise.then((repo) => {
|
|
161
176
|
if (!repo) return;
|
|
162
|
-
this.repository.import(repo);
|
|
177
|
+
this.repository.import(withLocalPauseReasons(repo));
|
|
163
178
|
if (repo.messages.length > 0) this.ensureInitialized();
|
|
164
179
|
this._notifySubscribers();
|
|
165
180
|
const resume = this.adapters.history?.resume?.bind(this.adapters.history);
|
|
@@ -271,6 +286,9 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
271
286
|
exportExternalState() {
|
|
272
287
|
throw new Error("Runtime does not support exporting external states.");
|
|
273
288
|
}
|
|
289
|
+
import(data) {
|
|
290
|
+
super.import(withLocalPauseReasons(data));
|
|
291
|
+
}
|
|
274
292
|
importExternalState() {
|
|
275
293
|
throw new Error("Runtime does not support importing external states.");
|
|
276
294
|
}
|
|
@@ -309,8 +327,9 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
309
327
|
this._suggestionsController = null;
|
|
310
328
|
this._notifySubscribers();
|
|
311
329
|
do {
|
|
312
|
-
message = await this.performRoundtrip(parentId, message, runConfig, alreadyPersisted, runCallback);
|
|
330
|
+
message = await this.performRoundtrip(parentId, message, runConfig, alreadyPersisted, run, runCallback);
|
|
313
331
|
runCallback = void 0;
|
|
332
|
+
if (this._activeRun !== run) break;
|
|
314
333
|
} while (shouldContinue(message, this._options.unstable_humanToolNames));
|
|
315
334
|
} finally {
|
|
316
335
|
this._notifyEventSubscribers("runEnd", {});
|
|
@@ -339,7 +358,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
339
358
|
})();
|
|
340
359
|
}
|
|
341
360
|
}
|
|
342
|
-
async performRoundtrip(parentId, message, runConfig, alreadyPersisted, runCallback) {
|
|
361
|
+
async performRoundtrip(parentId, message, runConfig, alreadyPersisted, run, runCallback) {
|
|
343
362
|
const messages = parentId ? this.repository.getMessages(parentId) : [];
|
|
344
363
|
this.abortController?.abort();
|
|
345
364
|
const abortController = new AbortController();
|
|
@@ -349,7 +368,22 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
349
368
|
const initialData = message.metadata?.unstable_data;
|
|
350
369
|
const initialSteps = message.metadata?.steps;
|
|
351
370
|
const initialCustom = message.metadata?.custom;
|
|
371
|
+
let hasStoredMessage = true;
|
|
372
|
+
try {
|
|
373
|
+
this.repository.getMessage(message.id);
|
|
374
|
+
} catch {
|
|
375
|
+
hasStoredMessage = false;
|
|
376
|
+
}
|
|
377
|
+
const ownsMessage = () => {
|
|
378
|
+
if (!hasStoredMessage) return this._activeRun === run;
|
|
379
|
+
try {
|
|
380
|
+
return this.repository.getMessage(message.id).message === message;
|
|
381
|
+
} catch {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
352
385
|
const updateMessage = (m) => {
|
|
386
|
+
if (!ownsMessage()) return;
|
|
353
387
|
const newSteps = m.metadata?.steps;
|
|
354
388
|
const steps = newSteps ? [...initialSteps ?? [], ...newSteps] : void 0;
|
|
355
389
|
const newAnnotations = m.metadata?.unstable_annotations;
|
|
@@ -374,6 +408,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
374
408
|
} } : void 0
|
|
375
409
|
};
|
|
376
410
|
this.repository.addOrUpdateMessage(parentId, message);
|
|
411
|
+
hasStoredMessage = true;
|
|
377
412
|
this._notifySubscribers();
|
|
378
413
|
};
|
|
379
414
|
const maxSteps = this._options.maxSteps ?? 2;
|
|
@@ -392,6 +427,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
392
427
|
const { unstable_composerMetadata: _, ...context } = this.getModelContext();
|
|
393
428
|
runCallback = runCallback ?? this.adapters.chatModel.run.bind(this.adapters.chatModel);
|
|
394
429
|
const abortSignal = abortController.signal;
|
|
430
|
+
const shouldCancelMessage = () => abortSignal.aborted && (message.status.type === "running" || message.status.type === "requires-action" && (this._activeRun !== run || shouldContinue(message, this._options.unstable_humanToolNames)));
|
|
395
431
|
const threadId = this._getThreadId?.();
|
|
396
432
|
const promiseOrGenerator = runCallback({
|
|
397
433
|
messages,
|
|
@@ -407,7 +443,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
407
443
|
});
|
|
408
444
|
if (Symbol.asyncIterator in promiseOrGenerator) for await (const r of promiseOrGenerator) {
|
|
409
445
|
if (abortSignal.aborted) {
|
|
410
|
-
updateMessage({ status: {
|
|
446
|
+
if (shouldCancelMessage()) updateMessage({ status: {
|
|
411
447
|
type: "incomplete",
|
|
412
448
|
reason: "cancelled"
|
|
413
449
|
} });
|
|
@@ -416,10 +452,11 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
416
452
|
updateMessage(r);
|
|
417
453
|
}
|
|
418
454
|
else updateMessage(await promiseOrGenerator);
|
|
419
|
-
if (
|
|
455
|
+
if (shouldCancelMessage()) updateMessage({ status: {
|
|
420
456
|
type: "incomplete",
|
|
421
457
|
reason: "cancelled"
|
|
422
|
-
}
|
|
458
|
+
} });
|
|
459
|
+
else if (message.status.type === "running") updateMessage({ status: {
|
|
423
460
|
type: "complete",
|
|
424
461
|
reason: "unknown"
|
|
425
462
|
} });
|
|
@@ -450,7 +487,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
|
450
487
|
};
|
|
451
488
|
const isTerminal = message.status.type === "complete" || message.status.type === "incomplete";
|
|
452
489
|
const isPausing = message.status.type === "requires-action" && !shouldContinue(message, this._options.unstable_humanToolNames);
|
|
453
|
-
if (isTerminal || isPausing && history?.update) {
|
|
490
|
+
if (ownsMessage() && (isTerminal || isPausing && history?.update)) {
|
|
454
491
|
const write = alreadyPersisted && history?.update ? history.update.bind(history) : history?.append.bind(history);
|
|
455
492
|
if (write) await this._chainHistoryWrite(message.id, () => write(item));
|
|
456
493
|
}
|