@assistant-ui/core 0.3.13 → 0.3.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/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +9 -15
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/thread-history.d.ts +2 -0
- package/dist/adapters/thread-history.d.ts.map +1 -1
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +38 -15
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.js +8 -7
- 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 +19 -4
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts +4 -0
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +50 -3
- 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/registry.d.ts.map +1 -1
- package/dist/model-context/registry.js +16 -4
- package/dist/model-context/registry.js.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts +8 -1
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.js +23 -18
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +28 -12
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/AdaptedRemoteThread.d.ts +11 -0
- package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -0
- package/dist/react/client/AdaptedRemoteThread.js +27 -0
- package/dist/react/client/AdaptedRemoteThread.js.map +1 -0
- package/dist/react/client/InMemoryThreadList.d.ts +19 -0
- package/dist/react/client/InMemoryThreadList.d.ts.map +1 -0
- package/dist/react/client/InMemoryThreadList.js +418 -0
- package/dist/react/client/InMemoryThreadList.js.map +1 -0
- package/dist/react/client/Interactables.d.ts.map +1 -1
- package/dist/react/client/Interactables.js +159 -102
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/RemoteThreadList.d.ts +34 -0
- package/dist/react/client/RemoteThreadList.d.ts.map +1 -0
- package/dist/react/client/RemoteThreadList.js +898 -0
- package/dist/react/client/RemoteThreadList.js.map +1 -0
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/Tools.js +38 -27
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +7 -2
- package/dist/react/index.js +5 -2
- package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
- package/dist/react/interactables-legacy/Interactables.js +145 -110
- package/dist/react/interactables-legacy/Interactables.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +20 -19
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarEdit.js +2 -4
- package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarReload.js +2 -4
- package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerNext.js +2 -6
- package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +2 -6
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerCancel.js +2 -4
- package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.js +2 -4
- package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +6 -2
- package/dist/react/primitive-hooks/useSuggestionTrigger.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/message/MessageParts.d.ts +13 -0
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +24 -10
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +115 -71
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +14 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +232 -63
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadResource.d.ts +30 -0
- package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -0
- package/dist/react/runtimes/RemoteThreadResource.js +136 -0
- package/dist/react/runtimes/RemoteThreadResource.js.map +1 -0
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +3 -10
- package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/react/runtimes/RuntimeAdapterProvider.js +3 -6
- package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +17 -0
- package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/commandQueue.js +55 -0
- package/dist/react/runtimes/assistant-transport/commandQueue.js.map +1 -0
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +11 -0
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js +165 -0
- package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js.map +1 -0
- package/dist/react/runtimes/assistant-transport/runManager.d.ts +15 -0
- package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/runManager.js +86 -0
- package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -0
- package/dist/react/runtimes/assistant-transport/types.d.ts +130 -0
- package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/types.js +0 -0
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +14 -0
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +296 -0
- package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -0
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +7 -0
- package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/useConvertedState.js +25 -0
- package/dist/react/runtimes/assistant-transport/useConvertedState.js.map +1 -0
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +7 -0
- package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -0
- package/dist/react/runtimes/assistant-transport/useLatestRef.js +27 -0
- package/dist/react/runtimes/assistant-transport/useLatestRef.js.map +1 -0
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +39 -13
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +2 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +3 -3
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +4 -0
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +7 -0
- 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 +60 -17
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +16 -0
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -0
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.js +36 -0
- package/dist/react/runtimes/cloud/useCloudThreadListRuntime.js.map +1 -0
- package/dist/react/runtimes/external-message-converter.js +14 -14
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useExternalStoreRuntime.js +44 -28
- package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
- package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +1 -1
- package/dist/react/runtimes/useRuntimeAdapters.d.ts +9 -0
- package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -0
- package/dist/react/runtimes/useRuntimeAdapters.js +20 -0
- package/dist/react/runtimes/useRuntimeAdapters.js.map +1 -0
- package/dist/runtime/api/composer-runtime.d.ts +5 -0
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-runtime.js +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +1 -0
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +4 -2
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +12 -2
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +8 -2
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +8 -7
- 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 +3 -3
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +0 -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 +10 -4
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +6 -0
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/internal.js +5 -5
- package/dist/runtime/queue/message-queue.d.ts.map +1 -1
- package/dist/runtime/queue/message-queue.js +2 -1
- package/dist/runtime/queue/message-queue.js.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js +27 -18
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +8 -0
- package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -0
- package/dist/runtime/utils/thread-runtime-lifecycle.js +11 -0
- package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -0
- package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +4 -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 +8 -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 +37 -13
- 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/internal.d.ts +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +3 -0
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +78 -19
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +12 -59
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +10 -142
- 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 -152
- 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/types.d.ts +32 -1
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +1 -12
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +67 -38
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/external-thread.js +1 -1
- package/dist/store/clients/external-thread.js.map +1 -1
- package/dist/store/clients/suggestions.js +2 -2
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-selection-events.d.ts +10 -0
- package/dist/store/clients/thread-selection-events.d.ts.map +1 -0
- package/dist/store/clients/thread-selection-events.js +40 -0
- package/dist/store/clients/thread-selection-events.js.map +1 -0
- package/dist/store/env.d.ts +5 -0
- package/dist/store/env.d.ts.map +1 -0
- package/dist/store/env.js +12 -0
- package/dist/store/env.js.map +1 -0
- package/dist/store/index.d.ts +5 -3
- package/dist/store/index.js +4 -2
- package/dist/store/internal.d.ts +4 -1
- package/dist/store/internal.js +4 -1
- package/dist/store/primitive-predicates.d.ts +19 -0
- package/dist/store/primitive-predicates.d.ts.map +1 -0
- package/dist/store/primitive-predicates.js +19 -0
- package/dist/store/primitive-predicates.js.map +1 -0
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.js +18 -11
- package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/handle-runtime-action.d.ts +5 -0
- package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -0
- package/dist/store/runtime-clients/handle-runtime-action.js +14 -0
- package/dist/store/runtime-clients/handle-runtime-action.js.map +1 -0
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts +5 -0
- package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -0
- package/dist/store/runtime-clients/handle-thread-list-action.js +7 -0
- package/dist/store/runtime-clients/handle-thread-list-action.js.map +1 -0
- 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 +62 -29
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +5 -6
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/scopes/composer.d.ts +9 -4
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +7 -6
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +8 -7
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +17 -1
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +2 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +23 -18
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/message.d.ts +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +1 -0
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.js +25 -9
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/notify-event-listeners.d.ts +2 -2
- package/dist/utils/notify-event-listeners.d.ts.map +1 -1
- package/dist/utils/notify-event-listeners.js +2 -2
- package/dist/utils/notify-event-listeners.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 +8 -8
- package/src/adapters/speech.test.ts +118 -1
- package/src/adapters/speech.ts +21 -22
- package/src/adapters/thread-history.ts +2 -0
- package/src/adapters/voice.test.ts +134 -0
- package/src/adapters/voice.ts +35 -27
- package/src/index.ts +1 -0
- package/src/internal.ts +1 -0
- package/src/model-context/frame/host.test.ts +87 -5
- package/src/model-context/frame/host.ts +18 -4
- package/src/model-context/frame/provider.test.ts +347 -20
- package/src/model-context/frame/provider.ts +58 -2
- package/src/model-context/frame/types.ts +5 -0
- package/src/model-context/registry.test.ts +131 -0
- package/src/model-context/registry.ts +16 -6
- package/src/react/RuntimeAdapter.test.ts +2 -0
- package/src/react/RuntimeAdapter.ts +20 -8
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +34 -17
- package/src/react/client/AdaptedRemoteThread.ts +41 -0
- package/src/react/client/InMemoryThreadList.test.tsx +148 -0
- package/src/react/client/InMemoryThreadList.ts +290 -0
- package/src/react/client/Interactables.test.ts +326 -2
- package/src/react/client/Interactables.ts +227 -110
- package/src/react/client/RemoteThreadList.test.ts +1222 -0
- package/src/react/client/RemoteThreadList.ts +1136 -0
- package/src/react/client/Tools.ts +36 -29
- package/src/react/index.ts +13 -0
- package/src/react/interactables-legacy/Interactables.test.ts +317 -0
- package/src/react/interactables-legacy/Interactables.ts +204 -128
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +15 -0
- package/src/react/primitive-hooks/useActionBarCopy.ts +15 -10
- package/src/react/primitive-hooks/useActionBarEdit.ts +2 -1
- package/src/react/primitive-hooks/useActionBarReload.ts +2 -6
- package/src/react/primitive-hooks/useBranchPickerNext.ts +2 -7
- package/src/react/primitive-hooks/useBranchPickerPrevious.ts +2 -7
- package/src/react/primitive-hooks/useComposerCancel.ts +2 -1
- package/src/react/primitive-hooks/useComposerSend.ts +2 -5
- package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +11 -0
- package/src/react/primitive-hooks/useSuggestionTrigger.ts +4 -5
- package/src/react/primitive-hooks/useThreadIsEmpty.ts +3 -0
- package/src/react/primitive-hooks/useThreadIsRunning.ts +3 -0
- package/src/react/primitives/message/MessageParts.tsx +0 -1
- package/src/react/primitives/thread/ThreadMessages.tsx +2 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +116 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +1 -1
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +57 -6
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +272 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +171 -124
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.republish.test.ts +87 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +327 -83
- package/src/react/runtimes/RemoteThreadResource.test.ts +141 -0
- package/src/react/runtimes/RemoteThreadResource.ts +233 -0
- package/src/react/runtimes/RuntimeAdapterProvider.tsx +8 -20
- package/src/react/runtimes/assistant-transport/commandQueue.ts +68 -0
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +455 -0
- package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +172 -0
- package/src/react/runtimes/assistant-transport/runManager.ts +124 -0
- package/src/react/runtimes/assistant-transport/transport-delivery.test.tsx +79 -0
- package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +97 -0
- package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +414 -0
- package/src/react/runtimes/assistant-transport/types.ts +170 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +141 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +683 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +483 -0
- package/src/react/runtimes/assistant-transport/useConvertedState.ts +20 -0
- package/src/react/runtimes/assistant-transport/useLatestRef.ts +9 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +131 -6
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +61 -15
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +6 -4
- package/src/react/runtimes/cloud/auiV0.ts +17 -1
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +98 -3
- package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +104 -27
- package/src/react/runtimes/cloud/useCloudThreadListRuntime.test.tsx +56 -0
- package/src/react/runtimes/cloud/useCloudThreadListRuntime.ts +31 -0
- package/src/react/runtimes/external-message-converter.test.ts +143 -0
- package/src/react/runtimes/external-message-converter.ts +41 -41
- package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +58 -0
- package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +83 -0
- package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +13 -3
- package/src/react/runtimes/useExternalStoreRuntime.ts +7 -0
- package/src/react/runtimes/useExternalStoreSharedOptions.ts +3 -1
- package/src/react/runtimes/useLocalRuntime.test.tsx +134 -8
- package/src/react/runtimes/useRuntimeAdapters.test.tsx +62 -0
- package/src/react/runtimes/useRuntimeAdapters.ts +28 -0
- package/src/runtime/api/composer-runtime.ts +5 -0
- package/src/runtime/api/thread-list-runtime.ts +3 -1
- package/src/runtime/api/thread-runtime.ts +20 -2
- package/src/runtime/base/base-composer-runtime-core.ts +6 -5
- package/src/runtime/base/base-thread-runtime-core.test.ts +191 -0
- package/src/runtime/base/base-thread-runtime-core.ts +11 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +12 -4
- package/src/runtime/interfaces/thread-runtime-core.ts +6 -0
- package/src/runtime/queue/message-queue.ts +2 -1
- package/src/runtime/utils/message-repository.ts +26 -18
- package/src/runtime/utils/thread-runtime-lifecycle.ts +18 -0
- package/src/runtimes/external-store/external-store-shared-options.ts +3 -1
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +4 -1
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +103 -34
- 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 +692 -4
- package/src/runtimes/local/local-thread-runtime-core.ts +117 -22
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +17 -205
- package/src/runtimes/remote-thread-list/adapter-changed.ts +10 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +28 -217
- 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/types.ts +34 -0
- package/src/runtimes/tool-invocations/EDGE_CASES.md +17 -6
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +243 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +127 -61
- package/src/store/clients/external-thread.ts +1 -1
- package/src/store/clients/model-context-client.test.ts +16 -8
- package/src/store/clients/suggestions.ts +2 -2
- package/src/store/clients/thread-selection-events.ts +21 -0
- package/src/store/env.ts +11 -0
- package/src/store/index.ts +14 -1
- package/src/store/internal.ts +13 -0
- package/src/store/primitive-predicates.test.ts +184 -0
- package/src/store/primitive-predicates.ts +43 -0
- package/src/store/runtime-clients/attachment-runtime-client.test.ts +41 -0
- package/src/store/runtime-clients/attachment-runtime-client.ts +2 -1
- package/src/store/runtime-clients/handle-runtime-action.test.ts +40 -0
- package/src/store/runtime-clients/handle-runtime-action.ts +14 -0
- package/src/store/runtime-clients/handle-thread-list-action.test.ts +69 -0
- package/src/store/runtime-clients/handle-thread-list-action.ts +6 -0
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +15 -7
- package/src/store/runtime-clients/thread-list-runtime-client.ts +9 -6
- package/src/store/scopes/composer.ts +9 -4
- package/src/store/scopes/thread-list-item.ts +7 -6
- package/src/store/scopes/thread.ts +8 -7
- package/src/store/scopes/threads.ts +14 -0
- package/src/subscribable/subscribable.test.ts +77 -1
- package/src/subscribable/subscribable.ts +38 -23
- package/src/tests/MessageRepository.test.ts +48 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +2 -2
- package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +8 -6
- package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-unarchive.test.ts +25 -0
- package/src/tests/auiV0Encode.test.ts +66 -0
- package/src/tests/base-composer-runtime-core-send.test.ts +30 -0
- package/src/tests/base-composer-runtime-core.test.ts +28 -0
- package/src/tests/composer-can-cancel.test.ts +101 -0
- package/src/tests/empty-thread-core.test.ts +6 -0
- package/src/tests/external-store-thread-list-runtime-core.test.ts +101 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +211 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +124 -0
- package/src/tests/external-thread-isEmpty.test.tsx +100 -0
- package/src/tests/interactables-toolui-migration.test.tsx +66 -0
- package/src/tests/message-queue.test.ts +28 -0
- package/src/tests/remote-thread-list-adapter-switch.test.ts +383 -0
- package/src/tests/session-reset-notification.test.ts +145 -0
- package/src/tests/thread-switch-events.test.tsx +99 -1
- package/src/tests/tools-scope-migration.test.tsx +58 -0
- package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +67 -0
- package/src/types/message.ts +1 -1
- package/src/utils/composite-context-provider.test.ts +139 -0
- package/src/utils/composite-context-provider.ts +26 -8
- package/src/utils/notify-event-listeners.ts +10 -5
- package/src/utils/silent-runtime-action.ts +6 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { BaseSubscribable } from "../../subscribable/subscribable.js";
|
|
2
2
|
import { getThreadRuntimeCoreIsRunning } from "../../runtime/api/thread-runtime.js";
|
|
3
3
|
import { ThreadListRuntimeImpl } from "../../runtime/api/thread-list-runtime.js";
|
|
4
|
+
import { invalidateThreadRuntime } from "../../runtime/utils/thread-runtime-lifecycle.js";
|
|
5
|
+
import { useRuntimeAdapters } from "./useRuntimeAdapters.js";
|
|
4
6
|
import { ThreadListItemRuntimeProvider } from "../providers/ThreadListItemRuntimeProvider.js";
|
|
7
|
+
import { RemoteThreadResource } from "./RemoteThreadResource.js";
|
|
5
8
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
6
|
-
import { Fragment, memo,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { Fragment, memo, useEffect, useLayoutEffect, useMemo, useRef } from "@assistant-ui/tap/react-shim";
|
|
10
|
+
import { useResources, withKey } from "@assistant-ui/tap";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
12
|
import { create } from "zustand";
|
|
10
13
|
//#region src/react/runtimes/RemoteThreadListHookInstanceManager.tsx
|
|
11
14
|
const ProviderRenderDetector = (t0) => {
|
|
@@ -29,15 +32,23 @@ const ProviderRenderDetector = (t0) => {
|
|
|
29
32
|
return null;
|
|
30
33
|
};
|
|
31
34
|
var RemoteThreadListHookInstanceManager = class extends BaseSubscribable {
|
|
32
|
-
|
|
35
|
+
runtimeHook;
|
|
36
|
+
adapterStore = create(() => ({
|
|
37
|
+
defaultAdapters: null,
|
|
38
|
+
threadAdapters: /* @__PURE__ */ new Map()
|
|
39
|
+
}));
|
|
40
|
+
hostStore = create(() => ({
|
|
41
|
+
threads: [],
|
|
42
|
+
hookEpoch: 0
|
|
43
|
+
}));
|
|
44
|
+
pendingThreadAdapters = /* @__PURE__ */ new Map();
|
|
33
45
|
instances = /* @__PURE__ */ new Map();
|
|
34
46
|
nextGeneration = 0;
|
|
35
|
-
useAliveThreadsKeysChanged = create(() => ({}));
|
|
36
47
|
parent;
|
|
37
48
|
constructor(runtimeHook, parent) {
|
|
38
49
|
super();
|
|
39
50
|
this.parent = parent;
|
|
40
|
-
this.
|
|
51
|
+
this.runtimeHook = runtimeHook;
|
|
41
52
|
}
|
|
42
53
|
_whenRuntimeAttached(threadId) {
|
|
43
54
|
return new Promise((resolve, reject) => {
|
|
@@ -58,19 +69,21 @@ var RemoteThreadListHookInstanceManager = class extends BaseSubscribable {
|
|
|
58
69
|
}
|
|
59
70
|
startThreadRuntime(threadId) {
|
|
60
71
|
if (!this.instances.has(threadId)) {
|
|
72
|
+
const generation = this.nextGeneration++;
|
|
61
73
|
this.instances.set(threadId, {
|
|
62
|
-
generation
|
|
74
|
+
generation,
|
|
63
75
|
isRunning: false
|
|
64
76
|
});
|
|
65
|
-
this.
|
|
77
|
+
this._syncHostThreads();
|
|
66
78
|
}
|
|
67
79
|
return this._whenRuntimeAttached(threadId);
|
|
68
80
|
}
|
|
69
81
|
__internal_restartThreadRuntime(threadId) {
|
|
70
82
|
const instance = this.instances.get(threadId);
|
|
71
83
|
if (!instance) return this.startThreadRuntime(threadId);
|
|
84
|
+
if (instance.runtime) invalidateThreadRuntime(instance.runtime);
|
|
72
85
|
instance.generation = this.nextGeneration++;
|
|
73
|
-
this.
|
|
86
|
+
this._syncHostThreads();
|
|
74
87
|
this._notifySubscribers();
|
|
75
88
|
return this._whenRuntimeAttached(threadId);
|
|
76
89
|
}
|
|
@@ -83,24 +96,28 @@ var RemoteThreadListHookInstanceManager = class extends BaseSubscribable {
|
|
|
83
96
|
return this.instances.get(threadId)?.isRunning ?? false;
|
|
84
97
|
}
|
|
85
98
|
runningSubscribers = /* @__PURE__ */ new Set();
|
|
86
|
-
/**
|
|
87
|
-
* Fires when any thread crosses the running boundary. Separate from the
|
|
88
|
-
* general subscription so a run does not push the thread list through the
|
|
89
|
-
* channel that resolves pending runtime attachments.
|
|
90
|
-
*/
|
|
91
99
|
__internal_subscribeRunningChanged(callback) {
|
|
92
100
|
this.runningSubscribers.add(callback);
|
|
93
101
|
return () => this.runningSubscribers.delete(callback);
|
|
94
102
|
}
|
|
103
|
+
_publish = (threadId, runtime, generation) => {
|
|
104
|
+
this._publishThreadRuntime(threadId, runtime, generation);
|
|
105
|
+
};
|
|
95
106
|
_publishThreadRuntime(threadId, runtime, generation) {
|
|
96
107
|
const instance = this.instances.get(threadId);
|
|
97
|
-
if (!instance)
|
|
108
|
+
if (!instance) return;
|
|
98
109
|
if (instance.generation !== generation) return;
|
|
99
110
|
const previousRuntime = instance.runtime;
|
|
100
111
|
instance.runtime = runtime;
|
|
101
112
|
instance.publishedGeneration = generation;
|
|
102
113
|
if (previousRuntime !== runtime) this._trackRunning(instance);
|
|
103
114
|
this._notifySubscribers();
|
|
115
|
+
if (previousRuntime !== void 0 && previousRuntime !== runtime) for (const callback of this.replacedSubscribers) callback();
|
|
116
|
+
}
|
|
117
|
+
replacedSubscribers = /* @__PURE__ */ new Set();
|
|
118
|
+
__internal_subscribeRuntimeReplaced(callback) {
|
|
119
|
+
this.replacedSubscribers.add(callback);
|
|
120
|
+
return () => this.replacedSubscribers.delete(callback);
|
|
104
121
|
}
|
|
105
122
|
_trackRunning(instance) {
|
|
106
123
|
instance.unsubscribeRunning?.();
|
|
@@ -121,83 +138,110 @@ var RemoteThreadListHookInstanceManager = class extends BaseSubscribable {
|
|
|
121
138
|
for (const callback of this.runningSubscribers) callback();
|
|
122
139
|
}
|
|
123
140
|
stopThreadRuntime(threadId) {
|
|
124
|
-
this.instances.get(threadId)
|
|
141
|
+
const instance = this.instances.get(threadId);
|
|
142
|
+
if (instance?.runtime) invalidateThreadRuntime(instance.runtime);
|
|
143
|
+
instance?.unsubscribeRunning?.();
|
|
125
144
|
this.instances.delete(threadId);
|
|
126
|
-
this.
|
|
145
|
+
this.pendingThreadAdapters.delete(threadId);
|
|
146
|
+
this._syncHostThreads();
|
|
127
147
|
this._notifySubscribers();
|
|
128
148
|
}
|
|
129
149
|
setRuntimeHook(newRuntimeHook) {
|
|
130
|
-
if (this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
150
|
+
if (this.runtimeHook === newRuntimeHook) return;
|
|
151
|
+
this.runtimeHook = newRuntimeHook;
|
|
152
|
+
this.hostStore.setState((state) => ({
|
|
153
|
+
...state,
|
|
154
|
+
hookEpoch: state.hookEpoch + 1
|
|
155
|
+
}), true);
|
|
156
|
+
}
|
|
157
|
+
__internal_setDefaultAdapters(adapters) {
|
|
158
|
+
const current = this.adapterStore.getState();
|
|
159
|
+
if (current.defaultAdapters === adapters) return;
|
|
160
|
+
this.adapterStore.setState({
|
|
161
|
+
...current,
|
|
162
|
+
defaultAdapters: adapters
|
|
163
|
+
}, true);
|
|
164
|
+
}
|
|
165
|
+
__internal_setThreadAdapters(threadId, adapters) {
|
|
166
|
+
const current = this.adapterStore.getState();
|
|
167
|
+
const next = new Map(current.threadAdapters);
|
|
168
|
+
if (adapters === null) next.delete(threadId);
|
|
169
|
+
else next.set(threadId, adapters);
|
|
170
|
+
this.adapterStore.setState({
|
|
171
|
+
...current,
|
|
172
|
+
threadAdapters: next
|
|
173
|
+
}, true);
|
|
174
|
+
}
|
|
175
|
+
__internal_dispose() {
|
|
176
|
+
for (const threadId of [...this.instances.keys()]) this.stopThreadRuntime(threadId);
|
|
177
|
+
}
|
|
178
|
+
_syncHostThreads() {
|
|
179
|
+
this.hostStore.setState((state) => ({
|
|
180
|
+
...state,
|
|
181
|
+
threads: Array.from(this.instances.entries()).map(([id, { generation }]) => ({
|
|
182
|
+
id,
|
|
183
|
+
generation
|
|
184
|
+
}))
|
|
185
|
+
}), true);
|
|
186
|
+
}
|
|
187
|
+
__internal_useHost(parentClient) {
|
|
188
|
+
const { threads, hookEpoch } = this.hostStore();
|
|
189
|
+
const adapters = this.adapterStore();
|
|
190
|
+
const runtimeHook = this.runtimeHook;
|
|
191
|
+
return useResources(threads.map(({ id, generation }) => {
|
|
192
|
+
const threadAdapters = this.pendingThreadAdapters.has(id) ? this.pendingThreadAdapters.get(id) : adapters.threadAdapters.get(id) ?? adapters.defaultAdapters;
|
|
193
|
+
return withKey(`${id}:${generation}:${hookEpoch}`, RemoteThreadResource({
|
|
194
|
+
threadId: id,
|
|
195
|
+
generation,
|
|
196
|
+
parentList: this.parent,
|
|
197
|
+
runtimeHook,
|
|
198
|
+
parentClient,
|
|
199
|
+
adapters: threadAdapters,
|
|
200
|
+
publish: this._publish
|
|
201
|
+
}));
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
__internal_RenderThreadRuntimes = ({ provider }) => {
|
|
205
|
+
this.hostStore();
|
|
206
|
+
return Array.from(this.instances.entries()).map(([threadId, { generation }]) => /* @__PURE__ */ jsx(this._OuterActiveThreadProvider, {
|
|
139
207
|
threadId,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
isMounted.current = true;
|
|
147
|
-
updateRuntime();
|
|
148
|
-
return threadBinding.outerSubscribe(updateRuntime);
|
|
149
|
-
}, [threadBinding, updateRuntime]);
|
|
150
|
-
const aui = useAui();
|
|
151
|
-
const initPromiseRef = useRef(void 0);
|
|
152
|
-
const hasInitializedRef = useRef(false);
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
const runtimeCore = threadBinding.getState();
|
|
155
|
-
const setGetInitializePromise = runtimeCore.__internal_setGetInitializePromise;
|
|
156
|
-
if (typeof setGetInitializePromise === "function") setGetInitializePromise.call(runtimeCore, () => initPromiseRef.current);
|
|
157
|
-
}, [threadBinding]);
|
|
158
|
-
const handleInitialize = useEffectEvent(() => {
|
|
159
|
-
if (hasInitializedRef.current) return;
|
|
160
|
-
if (aui.threadListItem.getState().status !== "new") return;
|
|
161
|
-
hasInitializedRef.current = true;
|
|
162
|
-
initPromiseRef.current = aui.threadListItem.initialize();
|
|
163
|
-
const dispose = runtime.thread.unstable_on("runEnd", () => {
|
|
164
|
-
dispose();
|
|
165
|
-
aui.threadListItem.generateTitle();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
hasInitializedRef.current = false;
|
|
170
|
-
return runtime.threads.main.unstable_on("initialize", handleInitialize);
|
|
171
|
-
}, [runtime]);
|
|
172
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
208
|
+
provider
|
|
209
|
+
}, `${threadId}:${generation}`));
|
|
210
|
+
};
|
|
211
|
+
__internal_Host = ({ parentClient }) => {
|
|
212
|
+
this.__internal_useHost(parentClient);
|
|
213
|
+
return null;
|
|
173
214
|
};
|
|
174
|
-
_OuterActiveThreadProvider = memo(({ threadId,
|
|
215
|
+
_OuterActiveThreadProvider = memo(({ threadId, provider: Provider }) => {
|
|
175
216
|
const runtime = useMemo(() => new ThreadListRuntimeImpl(this.parent).getItemById(threadId), [threadId]);
|
|
176
217
|
const detectorRef = useRef(false);
|
|
177
218
|
useEffect(() => {
|
|
178
219
|
if (process.env.NODE_ENV !== "production" && Provider !== Fragment) {
|
|
179
220
|
const id = setTimeout(() => {
|
|
180
|
-
if (!detectorRef.current) console.warn("RemoteThreadListAdapter.unstable_Provider did not render its `children` synchronously. Render `children` on first commit; deferring them behind a loading state, Suspense boundary, or `useEffect` gate strands the runtime
|
|
221
|
+
if (!detectorRef.current) console.warn("RemoteThreadListAdapter.unstable_Provider did not render its `children` synchronously. Render `children` on first commit; deferring them behind a loading state, Suspense boundary, or `useEffect` gate strands the runtime host and leaves the thread without context.");
|
|
181
222
|
}, 100);
|
|
182
223
|
return () => clearTimeout(id);
|
|
183
224
|
}
|
|
184
225
|
}, [Provider]);
|
|
185
226
|
return /* @__PURE__ */ jsx(ThreadListItemRuntimeProvider, {
|
|
186
227
|
runtime,
|
|
187
|
-
children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsx(this.
|
|
228
|
+
children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsx(this._AdapterSink, {
|
|
188
229
|
threadId,
|
|
189
|
-
|
|
190
|
-
children: /* @__PURE__ */ jsx(ProviderRenderDetector, { detectorRef })
|
|
230
|
+
detectorRef
|
|
191
231
|
}) })
|
|
192
232
|
});
|
|
193
233
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
234
|
+
_AdapterSink = ({ threadId, detectorRef }) => {
|
|
235
|
+
const adapters = useRuntimeAdapters();
|
|
236
|
+
this.pendingThreadAdapters.set(threadId, adapters);
|
|
237
|
+
useLayoutEffect(() => {
|
|
238
|
+
this.__internal_setThreadAdapters(threadId, adapters);
|
|
239
|
+
return () => {
|
|
240
|
+
if (this.pendingThreadAdapters.get(threadId) === adapters) this.pendingThreadAdapters.delete(threadId);
|
|
241
|
+
this.__internal_setThreadAdapters(threadId, null);
|
|
242
|
+
};
|
|
243
|
+
}, [threadId, adapters]);
|
|
244
|
+
return /* @__PURE__ */ jsx(ProviderRenderDetector, { detectorRef });
|
|
201
245
|
};
|
|
202
246
|
};
|
|
203
247
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListHookInstanceManager.js","names":["FC","RefObject","useCallback","useRef","useEffect","useEffectEvent","useLayoutEffect","memo","PropsWithChildren","ComponentType","useMemo","Fragment","UseBoundStore","StoreApi","create","useAui","ThreadListItemRuntimeProvider","ThreadRuntimeCore","ThreadListRuntimeCore","AssistantRuntime","Unsubscribe","BaseSubscribable","getThreadRuntimeCoreIsRunning","ThreadRuntimeImpl","ThreadListRuntimeImpl","RemoteThreadListHook","RemoteThreadListHookInstance","runtime","publishedGeneration","generation","isRunning","unsubscribeRunning","ProviderRenderDetector","detectorRef","t0","$","_c","t1","t2","current","RemoteThreadListHookInstanceManager","useRuntimeHook","useRuntime","instances","Map","nextGeneration","useAliveThreadsKeysChanged","parent","constructor","runtimeHook","_whenRuntimeAttached","threadId","Promise","resolve","reject","callback","instance","get","dispose","Error","subscribe","startThreadRuntime","has","set","setState","__internal_restartThreadRuntime","_notifySubscribers","getThreadRuntimeCore","undefined","__internal_isThreadRunning","runningSubscribers","Set","__internal_subscribeRunningChanged","add","delete","_publishThreadRuntime","previousRuntime","_trackRunning","_setRunning","stopThreadRuntime","setRuntimeHook","newRuntimeHook","prevRuntimeHook","getState","_RuntimeBinder","children","threadBinding","thread","__internal_threadBinding","updateRuntime","isMounted","outerSubscribe","aui","initPromiseRef","hasInitializedRef","runtimeCore","setGetInitializePromise","Record","__internal_setGetInitializePromise","call","handleInitialize","state","threadListItem","status","initialize","unstable_on","generateTitle","threads","main","_OuterActiveThreadProvider","provider","Provider","getItemById","process","env","NODE_ENV","id","setTimeout","console","warn","clearTimeout","__internal_RenderThreadRuntimes","Array","from","entries","map"],"sources":["../../../src/react/runtimes/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["import {\n type FC,\n type RefObject,\n useCallback,\n useRef,\n useEffect,\n useEffectEvent,\n useLayoutEffect,\n memo,\n type PropsWithChildren,\n type ComponentType,\n useMemo,\n Fragment,\n} from \"react\";\nimport { type UseBoundStore, type StoreApi, create } from \"zustand\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { ThreadListItemRuntimeProvider } from \"../providers/ThreadListItemRuntimeProvider\";\nimport type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\nimport type { ThreadListRuntimeCore } from \"../../runtime/interfaces/thread-list-runtime-core\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport {\n getThreadRuntimeCoreIsRunning,\n type ThreadRuntimeImpl,\n} from \"../../runtime/api/thread-runtime\";\nimport { ThreadListRuntimeImpl } from \"../../runtime/api/thread-list-runtime\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore | undefined;\n // A runtime riding across a restart stays readable, but only counts as\n // attached once a binder of the current generation re-publishes it.\n publishedGeneration?: number | undefined;\n // Part of the binder's React key, so only a bump remounts the hook.\n generation: number;\n isRunning: boolean;\n unsubscribeRunning?: Unsubscribe | undefined;\n};\n\nconst ProviderRenderDetector: FC<{\n detectorRef: RefObject<boolean>;\n}> = ({ detectorRef }) => {\n useLayoutEffect(() => {\n detectorRef.current = true;\n }, [detectorRef]);\n return null;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n // Manager-wide so it survives instance deletion: a stop and start within one\n // React commit must not reuse a binder key.\n private nextGeneration = 0;\n private useAliveThreadsKeysChanged = create(() => ({}));\n private parent: ThreadListRuntimeCore;\n\n constructor(\n runtimeHook: RemoteThreadListHook,\n parent: ThreadListRuntimeCore,\n ) {\n super();\n this.parent = parent;\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n private _whenRuntimeAttached(threadId: string) {\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (\n !instance.runtime ||\n instance.publishedGeneration !== instance.generation\n ) {\n return; // not yet published by the current generation's binder\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {\n generation: this.nextGeneration++,\n isRunning: false,\n });\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return this._whenRuntimeAttached(threadId);\n }\n\n public __internal_restartThreadRuntime(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return this.startThreadRuntime(threadId);\n\n instance.generation = this.nextGeneration++;\n this.useAliveThreadsKeysChanged.setState({}, true);\n this._notifySubscribers();\n\n return this._whenRuntimeAttached(threadId);\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return undefined;\n return instance.runtime;\n }\n\n public __internal_isThreadRunning(threadId: string) {\n return this.instances.get(threadId)?.isRunning ?? false;\n }\n\n private runningSubscribers = new Set<() => void>();\n\n /**\n * Fires when any thread crosses the running boundary. Separate from the\n * general subscription so a run does not push the thread list through the\n * channel that resolves pending runtime attachments.\n */\n public __internal_subscribeRunningChanged(callback: () => void): Unsubscribe {\n this.runningSubscribers.add(callback);\n return () => this.runningSubscribers.delete(callback);\n }\n\n private _publishThreadRuntime(\n threadId: string,\n runtime: ThreadRuntimeCore,\n generation: number,\n ) {\n const instance = this.instances.get(threadId);\n if (!instance)\n throw new Error(\n `Thread \"${threadId}\" runtime binding not found. This is a bug in assistant-ui.`,\n );\n\n // An outgoing binder outlives its generation until React commits the key\n // change, and must not publish over the incoming one.\n if (instance.generation !== generation) return;\n\n const previousRuntime = instance.runtime;\n instance.runtime = runtime;\n instance.publishedGeneration = generation;\n if (previousRuntime !== runtime) {\n this._trackRunning(instance);\n }\n this._notifySubscribers();\n }\n\n // Run state changes far more often than the thread list does, so the list is\n // only notified when a thread crosses the running boundary.\n private _trackRunning(instance: RemoteThreadListHookInstance) {\n instance.unsubscribeRunning?.();\n\n const runtime = instance.runtime;\n if (!runtime) {\n instance.unsubscribeRunning = undefined;\n this._setRunning(instance, false);\n return;\n }\n\n this._setRunning(instance, getThreadRuntimeCoreIsRunning(runtime));\n instance.unsubscribeRunning = runtime.subscribe(() => {\n this._setRunning(instance, getThreadRuntimeCoreIsRunning(runtime));\n });\n }\n\n private _setRunning(\n instance: RemoteThreadListHookInstance,\n isRunning: boolean,\n ) {\n if (instance.isRunning === isRunning) return;\n instance.isRunning = isRunning;\n for (const callback of this.runningSubscribers) callback();\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.get(threadId)?.unsubscribeRunning?.();\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n this._notifySubscribers();\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n // Rendered as a child of the user's Provider so the runtime hook can\n // read context the Provider injects (e.g. RuntimeAdapterProvider).\n private _RuntimeBinder: FC<\n PropsWithChildren<{ threadId: string; generation: number }>\n > = ({ threadId, generation, children }) => {\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n this._publishThreadRuntime(\n threadId,\n threadBinding.getState(),\n generation,\n );\n }, [threadId, generation, threadBinding]);\n\n const isMounted = useRef(false);\n if (!isMounted.current) {\n updateRuntime();\n }\n\n useEffect(() => {\n isMounted.current = true;\n updateRuntime();\n return threadBinding.outerSubscribe(updateRuntime);\n }, [threadBinding, updateRuntime]);\n\n const aui = useAui();\n const initPromiseRef = useRef<Promise<unknown> | undefined>(undefined);\n const hasInitializedRef = useRef(false);\n\n useEffect(() => {\n const runtimeCore = threadBinding.getState();\n const setGetInitializePromise = (runtimeCore as Record<string, unknown>)\n .__internal_setGetInitializePromise;\n if (typeof setGetInitializePromise === \"function\") {\n setGetInitializePromise.call(runtimeCore, () => initPromiseRef.current);\n }\n }, [threadBinding]);\n\n const handleInitialize = useEffectEvent(() => {\n if (hasInitializedRef.current) return;\n\n const state = aui.threadListItem.getState();\n if (state.status !== \"new\") return;\n hasInitializedRef.current = true;\n\n initPromiseRef.current = aui.threadListItem.initialize();\n\n const dispose = runtime.thread.unstable_on(\"runEnd\", () => {\n dispose();\n aui.threadListItem.generateTitle();\n });\n });\n\n useEffect(() => {\n hasInitializedRef.current = false;\n return runtime.threads.main.unstable_on(\"initialize\", handleInitialize);\n }, [runtime]);\n\n return <>{children}</>;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n generation: number;\n provider: ComponentType<PropsWithChildren>;\n }> = memo(({ threadId, generation, provider: Provider }) => {\n const runtime = useMemo(\n () => new ThreadListRuntimeImpl(this.parent).getItemById(threadId),\n [threadId],\n );\n\n const detectorRef = useRef(false);\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && Provider !== Fragment) {\n const id = setTimeout(() => {\n if (!detectorRef.current) {\n console.warn(\n \"RemoteThreadListAdapter.unstable_Provider did not render its `children` synchronously. \" +\n \"Render `children` on first commit; deferring them behind a loading state, Suspense boundary, \" +\n \"or `useEffect` gate strands the runtime binder and leaves the thread without context.\",\n );\n }\n }, 100);\n return () => clearTimeout(id);\n }\n return undefined;\n }, [Provider]);\n\n return (\n <ThreadListItemRuntimeProvider runtime={runtime}>\n <Provider>\n <this._RuntimeBinder threadId={threadId} generation={generation}>\n <ProviderRenderDetector detectorRef={detectorRef} />\n </this._RuntimeBinder>\n </Provider>\n </ThreadListItemRuntimeProvider>\n );\n });\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change\n\n return Array.from(this.instances.entries()).map(\n ([threadId, { generation }]) => (\n <this._OuterActiveThreadProvider\n key={`${threadId}:${generation}`}\n threadId={threadId}\n generation={generation}\n provider={provider}\n />\n ),\n );\n };\n}\n"],"mappings":";;;;;;;;;;AAyCA,MAAMgC,0BAEDE,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAH,gBAAAC;CAAe,IAAAG;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,aAAA;EACHI,WAAA;GACdJ,YAAWM,UAAW;EAAH;EAClBD,KAAA,CAACL,WAAW;EAACE,EAAA,KAAAF;EAAAE,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAD,KAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAFhB7B,gBAAgB+B,IAEbC,EAAa;CAAC,OACV;AAAI;AAEb,IAAaE,sCAAb,cAAyDnB,iBAAiB;CACxE;CAGA,4BAAoB,IAAIuB,IAA0C;CAGlE,iBAAyB;CACzB,6BAAqC9B,cAAc,CAAC,EAAE;CACtD;CAEAkC,YACEC,aACAF,QACA;EACA,MAAM;EACN,KAAKA,SAASA;EACd,KAAKN,iBAAiB3B,cAAc,EAAE4B,YAAYO,YAAY,EAAE;CAClE;CAEA,qBAA6BE,UAAkB;EAC7C,OAAO,IAAIC,SAA4BC,SAASC,WAAW;GACzD,MAAMC,iBAAiB;IACrB,MAAMC,WAAW,KAAKb,UAAUc,IAAIN,QAAQ;IAC5C,IAAI,CAACK,UAAU;KACbE,QAAQ;KACRJ,uBAAO,IAAIK,MAAM,+CAA+C,CAAC;IACnE,OAAO,IACL,CAACH,SAAS7B,WACV6B,SAAS5B,wBAAwB4B,SAAS3B,YAE1C;SACK;KACL6B,QAAQ;KACRL,QAAQG,SAAS7B,OAAO;IAC1B;GACF;GACA,MAAM+B,UAAU,KAAKE,UAAUL,QAAQ;GACvCA,SAAS;EACX,CAAC;CACH;CAEA,mBAA0BJ,UAAkB;EAC1C,IAAI,CAAC,KAAKR,UAAUmB,IAAIX,QAAQ,GAAG;GACj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J,GAAG,GAAG;IACN,aAAaC,aAAaJ,EAAE;GAC9B;EAEF,GAAG,CAACL,QAAQ,CAAC;EAEb,OACE,oBAAC,+BAAD;GAAwCpF;GACtC,UAAA,oBAAC,UAAD,EAAA,UACE,oBAAC,KAAK,gBAAN;IAA+BwB;IAAsBtB;IACnD,UAAA,oBAAC,wBAAD,EAAqCI,YAAY,CAAA;GAC9B,CAAA,EACb,CAAA;EACmB,CAAA;CAEnC,CAAC;CAED,mCAEM,EAAE6E,eAAe;EACrB,KAAKhE,2BAA2B;EAEhC,OAAO4E,MAAMC,KAAK,KAAKhF,UAAUiF,QAAQ,CAAC,CAAC,CAACC,KACzC,CAAC1E,UAAU,EAAEtB,kBACZ,oBAAC,KAAK,4BAAN;GAEYsB;GACEtB;GACFiF;EAAS,GAHd,GAAG3D,SAAQ,GAAItB,YAGD,CAGzB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"RemoteThreadListHookInstanceManager.js","names":["FC","RefObject","useEffect","useLayoutEffect","useMemo","useRef","memo","PropsWithChildren","ComponentType","Fragment","create","useResources","withKey","AssistantClient","ThreadListItemRuntimeProvider","ThreadRuntimeCore","ThreadListRuntimeCore","Unsubscribe","BaseSubscribable","getThreadRuntimeCoreIsRunning","ThreadListRuntimeImpl","invalidateThreadRuntime","useRuntimeAdapters","RuntimeAdapters","RemoteThreadResource","RemoteThreadListHook","RemoteThreadListHookInstance","runtime","publishedGeneration","generation","isRunning","unsubscribeRunning","AdapterSnapshot","defaultAdapters","threadAdapters","ReadonlyMap","HostSnapshot","threads","id","hookEpoch","ProviderRenderDetector","detectorRef","t0","$","_c","t1","t2","current","RemoteThreadListHookInstanceManager","runtimeHook","adapterStore","Map","hostStore","pendingThreadAdapters","instances","nextGeneration","parent","constructor","_whenRuntimeAttached","threadId","Promise","resolve","reject","callback","instance","get","dispose","Error","subscribe","startThreadRuntime","has","set","_syncHostThreads","__internal_restartThreadRuntime","_notifySubscribers","getThreadRuntimeCore","undefined","__internal_isThreadRunning","runningSubscribers","Set","__internal_subscribeRunningChanged","add","delete","_publish","_publishThreadRuntime","previousRuntime","_trackRunning","replacedSubscribers","__internal_subscribeRuntimeReplaced","_setRunning","stopThreadRuntime","setRuntimeHook","newRuntimeHook","setState","state","__internal_setDefaultAdapters","adapters","getState","__internal_setThreadAdapters","next","__internal_dispose","keys","Array","from","entries","map","__internal_useHost","parentClient","parentList","publish","__internal_RenderThreadRuntimes","provider","__internal_Host","_OuterActiveThreadProvider","Provider","getItemById","process","env","NODE_ENV","setTimeout","console","warn","clearTimeout","_AdapterSink"],"sources":["../../../src/react/runtimes/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["import {\n type FC,\n type RefObject,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n memo,\n type PropsWithChildren,\n type ComponentType,\n Fragment,\n} from \"react\";\nimport { create } from \"zustand\";\nimport { useResources, withKey } from \"@assistant-ui/tap\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\nimport { ThreadListItemRuntimeProvider } from \"../providers/ThreadListItemRuntimeProvider\";\nimport type { ThreadRuntimeCore } from \"../../runtime/interfaces/thread-runtime-core\";\nimport type { ThreadListRuntimeCore } from \"../../runtime/interfaces/thread-list-runtime-core\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport { getThreadRuntimeCoreIsRunning } from \"../../runtime/api/thread-runtime\";\nimport { ThreadListRuntimeImpl } from \"../../runtime/api/thread-list-runtime\";\nimport { invalidateThreadRuntime } from \"../../runtime/utils/thread-runtime-lifecycle\";\nimport {\n useRuntimeAdapters,\n type RuntimeAdapters,\n} from \"./RuntimeAdapterProvider\";\nimport {\n RemoteThreadResource,\n type RemoteThreadListHook,\n} from \"./RemoteThreadResource\";\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore | undefined;\n publishedGeneration?: number | undefined;\n generation: number;\n isRunning: boolean;\n unsubscribeRunning?: Unsubscribe | undefined;\n};\n\ntype AdapterSnapshot = {\n defaultAdapters: RuntimeAdapters | null;\n threadAdapters: ReadonlyMap<string, RuntimeAdapters | null>;\n};\n\ntype HostSnapshot = {\n threads: readonly { id: string; generation: number }[];\n hookEpoch: number;\n};\n\nconst ProviderRenderDetector: FC<{\n detectorRef: RefObject<boolean>;\n}> = ({ detectorRef }) => {\n useLayoutEffect(() => {\n detectorRef.current = true;\n }, [detectorRef]);\n return null;\n};\n\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private runtimeHook: RemoteThreadListHook;\n private readonly adapterStore = create<AdapterSnapshot>(() => ({\n defaultAdapters: null,\n threadAdapters: new Map(),\n }));\n private readonly hostStore = create<HostSnapshot>(() => ({\n threads: [],\n hookEpoch: 0,\n }));\n private readonly pendingThreadAdapters = new Map<\n string,\n RuntimeAdapters | null\n >();\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private nextGeneration = 0;\n private parent: ThreadListRuntimeCore;\n\n constructor(\n runtimeHook: RemoteThreadListHook,\n parent: ThreadListRuntimeCore,\n ) {\n super();\n this.parent = parent;\n this.runtimeHook = runtimeHook;\n }\n\n private _whenRuntimeAttached(threadId: string) {\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (\n !instance.runtime ||\n instance.publishedGeneration !== instance.generation\n ) {\n return;\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n const generation = this.nextGeneration++;\n this.instances.set(threadId, {\n generation,\n isRunning: false,\n });\n this._syncHostThreads();\n }\n\n return this._whenRuntimeAttached(threadId);\n }\n\n public __internal_restartThreadRuntime(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return this.startThreadRuntime(threadId);\n\n if (instance.runtime) invalidateThreadRuntime(instance.runtime);\n instance.generation = this.nextGeneration++;\n this._syncHostThreads();\n this._notifySubscribers();\n\n return this._whenRuntimeAttached(threadId);\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return undefined;\n return instance.runtime;\n }\n\n public __internal_isThreadRunning(threadId: string) {\n return this.instances.get(threadId)?.isRunning ?? false;\n }\n\n private runningSubscribers = new Set<() => void>();\n\n public __internal_subscribeRunningChanged(callback: () => void): Unsubscribe {\n this.runningSubscribers.add(callback);\n return () => this.runningSubscribers.delete(callback);\n }\n\n private _publish = (\n threadId: string,\n runtime: ThreadRuntimeCore,\n generation: number,\n ) => {\n this._publishThreadRuntime(threadId, runtime, generation);\n };\n\n private _publishThreadRuntime(\n threadId: string,\n runtime: ThreadRuntimeCore,\n generation: number,\n ) {\n const instance = this.instances.get(threadId);\n if (!instance) return;\n\n if (instance.generation !== generation) return;\n\n const previousRuntime = instance.runtime;\n instance.runtime = runtime;\n instance.publishedGeneration = generation;\n if (previousRuntime !== runtime) {\n this._trackRunning(instance);\n }\n this._notifySubscribers();\n if (previousRuntime !== undefined && previousRuntime !== runtime) {\n for (const callback of this.replacedSubscribers) callback();\n }\n }\n\n private replacedSubscribers = new Set<() => void>();\n\n public __internal_subscribeRuntimeReplaced(\n callback: () => void,\n ): Unsubscribe {\n this.replacedSubscribers.add(callback);\n return () => this.replacedSubscribers.delete(callback);\n }\n\n private _trackRunning(instance: RemoteThreadListHookInstance) {\n instance.unsubscribeRunning?.();\n\n const runtime = instance.runtime;\n if (!runtime) {\n instance.unsubscribeRunning = undefined;\n this._setRunning(instance, false);\n return;\n }\n\n this._setRunning(instance, getThreadRuntimeCoreIsRunning(runtime));\n instance.unsubscribeRunning = runtime.subscribe(() => {\n this._setRunning(instance, getThreadRuntimeCoreIsRunning(runtime));\n });\n }\n\n private _setRunning(\n instance: RemoteThreadListHookInstance,\n isRunning: boolean,\n ) {\n if (instance.isRunning === isRunning) return;\n instance.isRunning = isRunning;\n for (const callback of this.runningSubscribers) callback();\n }\n\n public stopThreadRuntime(threadId: string) {\n const instance = this.instances.get(threadId);\n if (instance?.runtime) invalidateThreadRuntime(instance.runtime);\n instance?.unsubscribeRunning?.();\n this.instances.delete(threadId);\n this.pendingThreadAdapters.delete(threadId);\n this._syncHostThreads();\n this._notifySubscribers();\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n if (this.runtimeHook === newRuntimeHook) return;\n this.runtimeHook = newRuntimeHook;\n this.hostStore.setState(\n (state) => ({ ...state, hookEpoch: state.hookEpoch + 1 }),\n true,\n );\n }\n\n public __internal_setDefaultAdapters(adapters: RuntimeAdapters | null) {\n const current = this.adapterStore.getState();\n if (current.defaultAdapters === adapters) return;\n this.adapterStore.setState({ ...current, defaultAdapters: adapters }, true);\n }\n\n public __internal_setThreadAdapters(\n threadId: string,\n adapters: RuntimeAdapters | null,\n ) {\n const current = this.adapterStore.getState();\n const next = new Map(current.threadAdapters);\n if (adapters === null) next.delete(threadId);\n else next.set(threadId, adapters);\n this.adapterStore.setState({ ...current, threadAdapters: next }, true);\n }\n\n public __internal_dispose() {\n for (const threadId of [...this.instances.keys()]) {\n this.stopThreadRuntime(threadId);\n }\n }\n\n private _syncHostThreads() {\n this.hostStore.setState(\n (state) => ({\n ...state,\n threads: Array.from(this.instances.entries()).map(\n ([id, { generation }]) => ({ id, generation }),\n ),\n }),\n true,\n );\n }\n\n public __internal_useHost(parentClient: AssistantClient) {\n const { threads, hookEpoch } = this.hostStore();\n const adapters = this.adapterStore();\n const runtimeHook = this.runtimeHook;\n return useResources(\n threads.map(({ id, generation }) => {\n const threadAdapters = this.pendingThreadAdapters.has(id)\n ? this.pendingThreadAdapters.get(id)!\n : (adapters.threadAdapters.get(id) ?? adapters.defaultAdapters);\n return withKey(\n `${id}:${generation}:${hookEpoch}`,\n RemoteThreadResource({\n threadId: id,\n generation,\n parentList: this.parent,\n runtimeHook,\n parentClient,\n adapters: threadAdapters,\n publish: this._publish,\n }),\n );\n }),\n );\n }\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.hostStore();\n\n return Array.from(this.instances.entries()).map(\n ([threadId, { generation }]) => (\n <this._OuterActiveThreadProvider\n key={`${threadId}:${generation}`}\n threadId={threadId}\n provider={provider}\n />\n ),\n );\n };\n\n public __internal_Host: FC<{ parentClient: AssistantClient }> = ({\n parentClient,\n }) => {\n this.__internal_useHost(parentClient);\n return null;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n provider: ComponentType<PropsWithChildren>;\n }> = memo(({ threadId, provider: Provider }) => {\n const runtime = useMemo(\n () => new ThreadListRuntimeImpl(this.parent).getItemById(threadId),\n [threadId],\n );\n\n const detectorRef = useRef(false);\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && Provider !== Fragment) {\n const id = setTimeout(() => {\n if (!detectorRef.current) {\n console.warn(\n \"RemoteThreadListAdapter.unstable_Provider did not render its `children` synchronously. \" +\n \"Render `children` on first commit; deferring them behind a loading state, Suspense boundary, \" +\n \"or `useEffect` gate strands the runtime host and leaves the thread without context.\",\n );\n }\n }, 100);\n return () => clearTimeout(id);\n }\n return undefined;\n }, [Provider]);\n\n return (\n <ThreadListItemRuntimeProvider runtime={runtime}>\n <Provider>\n <this._AdapterSink threadId={threadId} detectorRef={detectorRef} />\n </Provider>\n </ThreadListItemRuntimeProvider>\n );\n });\n\n private _AdapterSink: FC<{\n threadId: string;\n detectorRef: RefObject<boolean>;\n }> = ({ threadId, detectorRef }) => {\n const adapters = useRuntimeAdapters();\n this.pendingThreadAdapters.set(threadId, adapters);\n useLayoutEffect(() => {\n this.__internal_setThreadAdapters(threadId, adapters);\n return () => {\n if (this.pendingThreadAdapters.get(threadId) === adapters) {\n this.pendingThreadAdapters.delete(threadId);\n }\n this.__internal_setThreadAdapters(threadId, null);\n };\n }, [threadId, adapters]);\n return <ProviderRenderDetector detectorRef={detectorRef} />;\n };\n}\n"],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C,sBAAsBY,IAAIN,QAAQ,MAAMqC,UAC/C,KAAK3C,sBAAsB6B,OAAOvB,QAAQ;IAE5C,KAAKuC,6BAA6BvC,UAAU,IAAI;GAClD;EACF,GAAG,CAACA,UAAUqC,QAAQ,CAAC;EACvB,OAAO,oBAAC,wBAAD,EAAqCvD,YAAY,CAAA;CAC1D;AACF"}
|
|
@@ -9,8 +9,8 @@ import { EditComposerRuntimeCore, ThreadComposerRuntimeCore } from "../../runtim
|
|
|
9
9
|
import { AddToolResultOptions, RespondToToolApprovalOptions, ResumeRunConfig, ResumeToolCallOptions, RuntimeCapabilities, SpeechState, StartRunConfig, SubmitFeedbackOptions, ThreadRuntimeEventCallback, ThreadRuntimeEventType, ThreadSuggestion, VoiceSessionState } from "../../runtime/interfaces/thread-runtime-core.js";
|
|
10
10
|
import { ThreadListRuntimeCore } from "../../runtime/interfaces/thread-list-runtime-core.js";
|
|
11
11
|
import { BaseSubscribable } from "../../subscribable/subscribable.js";
|
|
12
|
-
import "../../store/index.js";
|
|
13
12
|
import { RemoteThreadListOptions } from "../../runtimes/remote-thread-list/types.js";
|
|
13
|
+
import "../../store/index.js";
|
|
14
14
|
import { RemoteThreadData, THREAD_MAPPING_ID } from "../../runtimes/remote-thread-list/remote-thread-state.js";
|
|
15
15
|
import "../../internal.js";
|
|
16
16
|
import "../../index.js";
|
|
@@ -19,21 +19,30 @@ import { FC } from "react";
|
|
|
19
19
|
declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscribable implements ThreadListRuntimeCore {
|
|
20
20
|
private _options;
|
|
21
21
|
private readonly _hookManager;
|
|
22
|
+
private readonly _runtimeAdapters;
|
|
22
23
|
private _loadThreadsPromise;
|
|
23
24
|
private _loadMorePromise;
|
|
24
25
|
private _loadGeneration;
|
|
26
|
+
private _adapterGeneration;
|
|
27
|
+
private _replaceListOnNextLoad;
|
|
28
|
+
private _staleThreadIdsOnReplace;
|
|
25
29
|
private _switchGeneration;
|
|
26
30
|
private _switchTask;
|
|
27
31
|
private _mainThreadId;
|
|
28
32
|
private readonly _state;
|
|
33
|
+
private readonly _useAdaptersProvider;
|
|
34
|
+
private readonly _SynthesizedAdapters;
|
|
35
|
+
private resolveProvider;
|
|
29
36
|
get threadItems(): Readonly<Record<THREAD_MAPPING_ID, RemoteThreadData>>;
|
|
30
37
|
getLoadThreadsPromise(): Promise<void>;
|
|
31
38
|
loadMore(): Promise<void>;
|
|
32
|
-
private readonly contextProvider;
|
|
33
39
|
constructor(options: RemoteThreadListOptions, contextProvider: ModelContextProvider);
|
|
34
40
|
private _initialThreadLoaded;
|
|
35
41
|
private useProvider;
|
|
36
42
|
__internal_setOptions(options: RemoteThreadListOptions): void;
|
|
43
|
+
private _requireAdapterGeneration;
|
|
44
|
+
private _requireAdapterSettled;
|
|
45
|
+
private _replaceWithThreads;
|
|
37
46
|
__internal_load(): void;
|
|
38
47
|
reloadMainThread(): Promise<void>;
|
|
39
48
|
reload(): Promise<void>;
|
|
@@ -60,6 +69,7 @@ declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscribable imp
|
|
|
60
69
|
startRun: (config: StartRunConfig) => void;
|
|
61
70
|
resumeRun: (config: ResumeRunConfig) => void;
|
|
62
71
|
cancelRun: () => void;
|
|
72
|
+
unstable_notifySessionReset: () => void;
|
|
63
73
|
addToolResult: (options: AddToolResultOptions) => void;
|
|
64
74
|
resumeToolCall: (options: ResumeToolCallOptions) => void;
|
|
65
75
|
respondToToolApproval: (options: RespondToToolApprovalOptions) => void;
|
|
@@ -113,6 +123,7 @@ declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscribable imp
|
|
|
113
123
|
startRun: (config: StartRunConfig) => void;
|
|
114
124
|
resumeRun: (config: ResumeRunConfig) => void;
|
|
115
125
|
cancelRun: () => void;
|
|
126
|
+
unstable_notifySessionReset: () => void;
|
|
116
127
|
addToolResult: (options: AddToolResultOptions) => void;
|
|
117
128
|
resumeToolCall: (options: ResumeToolCallOptions) => void;
|
|
118
129
|
respondToToolApproval: (options: RespondToToolApprovalOptions) => void;
|
|
@@ -175,6 +186,7 @@ declare class RemoteThreadListThreadListRuntimeCore extends BaseSubscribable imp
|
|
|
175
186
|
archive(threadIdOrRemoteId: string): Promise<void>;
|
|
176
187
|
unarchive(threadIdOrRemoteId: string): Promise<void>;
|
|
177
188
|
delete(threadIdOrRemoteId: string): Promise<void>;
|
|
189
|
+
__internal_dispose(): void;
|
|
178
190
|
detach(threadIdOrRemoteId: string): Promise<void>;
|
|
179
191
|
private useBoundIds;
|
|
180
192
|
__internal_RenderComponent: FC;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteThreadListThreadListRuntimeCore.d.ts","names":[],"sources":["../../../src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx"],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RemoteThreadListThreadListRuntimeCore.d.ts","names":[],"sources":["../../../src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx"],"mappings":";;;;;;;;;;;;;;;;;;cA6Fa,8CACH,4BACG;UAEH;mBACS;mBACA;UAET;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UAEA;mBACS;mBAIA;mBAYA;UAcT;MAUG,eAAW,SAAA,OA1DX,mBA0DW;EAIf,yBAAqB;EAyErB,YAAY;EAqDjB,YAAA,SAAS,yBACT,iBAAiB;UA6BX;UACA;EAED,sBAAsB,SAAS;UA2C9B;UAMA;UAMA;EAiGD;EAgBM,oBAAoB;EA4B1B,UAAM;MAWF;MAIA;MAIA;MAIA;MAIA;MAIA;MAIA;cAMC;UAKJ;UAEA;EASD,4BAAwB;;;eAzDlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DN,qBAAqB,6BAA0B;;;eANvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBxB,yBAAyB;EAMzB,YAAY,6BAA0B;EAItC,eACL,4BACA;IAAY;MACX;UAIK;UAgBM;EAgHP,qBAAqB;UAIpB;UAMA;UAOM;EAwBP,aAAoB,qBAAgB;;;;EA+DpC,gBAAuB,qBAAgB;EAwCjC,OACX,4BACA,mBACC;EAiCU,aACX,4BACA,QAAQ,sCACP;UAoDW;EAsBD,QAAQ,6BAA0B;EAwBlC,UAAU,6BAA6B;EA4BvC,OAAO,6BAA0B;EAyBvC;EAIM,OAAO,6BAA6B;UAYzC;EAED,4BAA4B"}
|