@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,10 +1,11 @@
|
|
|
1
1
|
import { findModelKnownState, interactableToolName } from "../../model-context/interactable-composer-metadata.js";
|
|
2
|
+
import { notifySubscribers } from "../../subscribable/subscribable.js";
|
|
2
3
|
import { ModelContext } from "../../store/clients/model-context-client.js";
|
|
3
4
|
import { buildInteractableModelContext } from "./interactable-model-context.js";
|
|
4
5
|
import { toJSONSchema, toPartialJSONSchema } from "assistant-stream";
|
|
5
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
6
7
|
import { resource } from "@assistant-ui/tap";
|
|
7
|
-
import { attachTransformScopes, useAssistantClientRef } from "@assistant-ui/store/client";
|
|
8
|
+
import { attachTransformScopes, useAssistantClientRef, useAssistantScopeEffect } from "@assistant-ui/store/client";
|
|
8
9
|
//#region src/react/client/Interactables.ts
|
|
9
10
|
const PERSISTENCE_DEBOUNCE_MS = 500;
|
|
10
11
|
const hasInteractableCreateCall = (messages, id, name) => messages.some((message) => message.role === "assistant" && message.content?.some((part) => {
|
|
@@ -31,9 +32,12 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
31
32
|
const adapterRef = useRef(void 0);
|
|
32
33
|
const debounceTimerRef = useRef(void 0);
|
|
33
34
|
const syncSeqRef = useRef(0);
|
|
34
|
-
const
|
|
35
|
+
const latestSyncSeqByIdRef = useRef(/* @__PURE__ */ new Map());
|
|
36
|
+
const inFlightPersistenceRef = useRef(0);
|
|
35
37
|
const flushResolversRef = useRef([]);
|
|
36
38
|
const dirtyIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
39
|
+
const outgoingQueueRef = useRef([]);
|
|
40
|
+
const runPersistenceRef = useRef(() => {});
|
|
37
41
|
const setStateAndRef = useCallback((updater) => {
|
|
38
42
|
const next = updater(stateRef.current);
|
|
39
43
|
stateRef.current = next;
|
|
@@ -50,93 +54,135 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
50
54
|
}
|
|
51
55
|
return result;
|
|
52
56
|
}, []);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (!adapter) {
|
|
56
|
-
for (const resolve of flushResolversRef.current) resolve();
|
|
57
|
-
flushResolversRef.current = [];
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const seq = ++syncSeqRef.current;
|
|
57
|
+
const takeDirtyBatch = useCallback((adapter) => {
|
|
58
|
+
if (dirtyIdsRef.current.size === 0) return;
|
|
61
59
|
const dirtyIds = new Set(dirtyIdsRef.current);
|
|
62
60
|
dirtyIdsRef.current.clear();
|
|
63
|
-
|
|
64
|
-
const
|
|
61
|
+
const seq = ++syncSeqRef.current;
|
|
62
|
+
for (const id_0 of dirtyIds) latestSyncSeqByIdRef.current.set(id_0, seq);
|
|
63
|
+
return {
|
|
64
|
+
adapter,
|
|
65
|
+
payload: exportState(),
|
|
66
|
+
dirtyIds,
|
|
67
|
+
seq
|
|
68
|
+
};
|
|
69
|
+
}, [exportState]);
|
|
70
|
+
const enqueuePersistence = useCallback((adapter_0) => {
|
|
71
|
+
const batch = takeDirtyBatch(adapter_0);
|
|
72
|
+
if (!batch) return;
|
|
73
|
+
if (inFlightPersistenceRef.current === 0) runPersistenceRef.current(batch);
|
|
74
|
+
else outgoingQueueRef.current.push(batch);
|
|
75
|
+
}, [takeDirtyBatch]);
|
|
76
|
+
const runPersistence = useCallback(async (batch_0) => {
|
|
77
|
+
const resolved = batch_0 ?? (adapterRef.current ? takeDirtyBatch(adapterRef.current) : void 0);
|
|
78
|
+
if (!resolved) {
|
|
79
|
+
if (inFlightPersistenceRef.current === 0) {
|
|
80
|
+
for (const resolve of flushResolversRef.current) resolve();
|
|
81
|
+
flushResolversRef.current = [];
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { adapter: adapter_1, payload, dirtyIds: dirtyIds_0, seq: seq_0 } = resolved;
|
|
86
|
+
inFlightPersistenceRef.current += 1;
|
|
65
87
|
setStateAndRef((prev) => ({
|
|
66
88
|
...prev,
|
|
67
89
|
persistence: {
|
|
68
90
|
...prev.persistence,
|
|
69
|
-
...Object.fromEntries([...
|
|
91
|
+
...Object.fromEntries([...dirtyIds_0].map((id_1) => [id_1, {
|
|
70
92
|
isPending: true,
|
|
71
93
|
error: void 0
|
|
72
94
|
}]))
|
|
73
95
|
}
|
|
74
96
|
}));
|
|
75
97
|
try {
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
await adapter_1.save(payload);
|
|
99
|
+
setStateAndRef((prev_1) => {
|
|
100
|
+
let changed_0 = false;
|
|
101
|
+
const persistence_1 = { ...prev_1.persistence };
|
|
102
|
+
for (const id_3 of dirtyIds_0) {
|
|
103
|
+
if (latestSyncSeqByIdRef.current.get(id_3) !== seq_0 || dirtyIdsRef.current.has(id_3)) continue;
|
|
104
|
+
latestSyncSeqByIdRef.current.delete(id_3);
|
|
105
|
+
delete persistence_1[id_3];
|
|
106
|
+
changed_0 = true;
|
|
107
|
+
}
|
|
108
|
+
return changed_0 ? {
|
|
109
|
+
...prev_1,
|
|
110
|
+
persistence: persistence_1
|
|
111
|
+
} : prev_1;
|
|
112
|
+
});
|
|
88
113
|
} catch (e) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
setStateAndRef((prev_0) => {
|
|
115
|
+
let changed = false;
|
|
116
|
+
const persistence_0 = { ...prev_0.persistence };
|
|
117
|
+
for (const id_2 of dirtyIds_0) {
|
|
118
|
+
if (latestSyncSeqByIdRef.current.get(id_2) !== seq_0 || dirtyIdsRef.current.has(id_2)) continue;
|
|
119
|
+
latestSyncSeqByIdRef.current.delete(id_2);
|
|
120
|
+
persistence_0[id_2] = {
|
|
121
|
+
isPending: false,
|
|
122
|
+
error: e
|
|
123
|
+
};
|
|
124
|
+
changed = true;
|
|
125
|
+
}
|
|
126
|
+
return changed ? {
|
|
92
127
|
...prev_0,
|
|
93
|
-
persistence:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
isPending: false,
|
|
97
|
-
error: e
|
|
98
|
-
}]))
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
128
|
+
persistence: persistence_0
|
|
129
|
+
} : prev_0;
|
|
130
|
+
});
|
|
102
131
|
} finally {
|
|
103
|
-
|
|
104
|
-
|
|
132
|
+
inFlightPersistenceRef.current -= 1;
|
|
133
|
+
const next = outgoingQueueRef.current.shift() ?? (adapterRef.current && dirtyIdsRef.current.size > 0 ? takeDirtyBatch(adapterRef.current) : void 0);
|
|
134
|
+
if (next) {
|
|
135
|
+
if (debounceTimerRef.current !== void 0) {
|
|
136
|
+
clearTimeout(debounceTimerRef.current);
|
|
137
|
+
debounceTimerRef.current = void 0;
|
|
138
|
+
}
|
|
139
|
+
runPersistenceRef.current(next);
|
|
140
|
+
} else if (inFlightPersistenceRef.current === 0) {
|
|
105
141
|
for (const resolve of flushResolversRef.current) resolve();
|
|
106
142
|
flushResolversRef.current = [];
|
|
107
143
|
}
|
|
108
144
|
}
|
|
109
|
-
}, [
|
|
110
|
-
|
|
145
|
+
}, [setStateAndRef, takeDirtyBatch]);
|
|
146
|
+
runPersistenceRef.current = (nextBatch) => {
|
|
147
|
+
runPersistence(nextBatch);
|
|
148
|
+
};
|
|
149
|
+
const flushIfPending = useCallback(() => {
|
|
150
|
+
if (debounceTimerRef.current !== void 0) {
|
|
151
|
+
clearTimeout(debounceTimerRef.current);
|
|
152
|
+
debounceTimerRef.current = void 0;
|
|
153
|
+
}
|
|
154
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
155
|
+
}, [enqueuePersistence]);
|
|
156
|
+
const schedulePersistence = useCallback((id_4) => {
|
|
111
157
|
if (!adapterRef.current) return;
|
|
112
|
-
dirtyIdsRef.current.add(
|
|
158
|
+
dirtyIdsRef.current.add(id_4);
|
|
113
159
|
if (debounceTimerRef.current !== void 0) clearTimeout(debounceTimerRef.current);
|
|
114
160
|
debounceTimerRef.current = setTimeout(() => {
|
|
115
161
|
debounceTimerRef.current = void 0;
|
|
116
|
-
if (
|
|
162
|
+
if (inFlightPersistenceRef.current === 0 && adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
117
163
|
else debounceTimerRef.current = setTimeout(() => {
|
|
118
164
|
debounceTimerRef.current = void 0;
|
|
119
|
-
|
|
165
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
120
166
|
}, PERSISTENCE_DEBOUNCE_MS);
|
|
121
167
|
}, PERSISTENCE_DEBOUNCE_MS);
|
|
122
|
-
}, [
|
|
168
|
+
}, [enqueuePersistence]);
|
|
123
169
|
const restorePersistedState = useCallback((saved, options) => {
|
|
124
170
|
const shouldStash = options.shouldStash ?? (() => true);
|
|
125
171
|
const shouldApply = options.shouldApply ?? (() => true);
|
|
126
|
-
for (const [
|
|
172
|
+
for (const [id_5, entry] of Object.entries(saved)) if (shouldStash(id_5)) options.stash.set(id_5, entry.state);
|
|
127
173
|
setStateAndRef((prev_2) => {
|
|
128
|
-
let
|
|
174
|
+
let changed_1 = false;
|
|
129
175
|
const definitions = { ...prev_2.definitions };
|
|
130
|
-
for (const [
|
|
131
|
-
const def_0 = definitions[
|
|
132
|
-
if (!def_0 || !shouldApply(
|
|
133
|
-
definitions[
|
|
176
|
+
for (const [id_6, entry_0] of Object.entries(saved)) {
|
|
177
|
+
const def_0 = definitions[id_6];
|
|
178
|
+
if (!def_0 || !shouldApply(id_6, def_0)) continue;
|
|
179
|
+
definitions[id_6] = {
|
|
134
180
|
...def_0,
|
|
135
181
|
state: entry_0.state
|
|
136
182
|
};
|
|
137
|
-
|
|
183
|
+
changed_1 = true;
|
|
138
184
|
}
|
|
139
|
-
if (!
|
|
185
|
+
if (!changed_1) return prev_2;
|
|
140
186
|
return {
|
|
141
187
|
...prev_2,
|
|
142
188
|
definitions
|
|
@@ -149,24 +195,25 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
149
195
|
const applyLoadedState = useCallback((saved_1) => {
|
|
150
196
|
restorePersistedState(saved_1, {
|
|
151
197
|
stash: loadedStateRef.current,
|
|
152
|
-
shouldStash: (
|
|
153
|
-
shouldApply: (
|
|
198
|
+
shouldStash: (id_7) => !touchedIdsRef.current.has(id_7),
|
|
199
|
+
shouldApply: (id_8, def_1) => !touchedIdsRef.current.has(id_8) && def_1.scope !== "thread"
|
|
154
200
|
});
|
|
155
201
|
}, [restorePersistedState]);
|
|
156
|
-
const loadFromAdapter = useCallback(async (
|
|
157
|
-
if (!
|
|
202
|
+
const loadFromAdapter = useCallback(async (adapter_2) => {
|
|
203
|
+
if (!adapter_2.load) return;
|
|
158
204
|
try {
|
|
159
|
-
const saved_2 = await
|
|
160
|
-
if (!saved_2 || adapterRef.current !==
|
|
205
|
+
const saved_2 = await adapter_2.load();
|
|
206
|
+
if (!saved_2 || adapterRef.current !== adapter_2) return;
|
|
161
207
|
applyLoadedState(saved_2);
|
|
162
208
|
} catch (e_0) {
|
|
163
209
|
console.warn("[Interactables] Persistence load failed.", e_0);
|
|
164
210
|
}
|
|
165
211
|
}, [applyLoadedState]);
|
|
166
|
-
const setPersistenceAdapter = useCallback((
|
|
167
|
-
adapterRef.current
|
|
168
|
-
|
|
169
|
-
|
|
212
|
+
const setPersistenceAdapter = useCallback((adapter_3) => {
|
|
213
|
+
if (adapterRef.current !== adapter_3) flushIfPending();
|
|
214
|
+
adapterRef.current = adapter_3;
|
|
215
|
+
if (adapter_3) loadFromAdapter(adapter_3);
|
|
216
|
+
}, [flushIfPending, loadFromAdapter]);
|
|
170
217
|
const getCurrentThreadId = useCallback(() => {
|
|
171
218
|
const client = clientRef.current;
|
|
172
219
|
if (!client) return void 0;
|
|
@@ -179,7 +226,7 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
179
226
|
if (!persistence) return;
|
|
180
227
|
setPersistenceAdapter(persistence);
|
|
181
228
|
return () => {
|
|
182
|
-
if (adapterRef.current === persistence)
|
|
229
|
+
if (adapterRef.current === persistence) setPersistenceAdapter(void 0);
|
|
183
230
|
};
|
|
184
231
|
}, [persistence, setPersistenceAdapter]);
|
|
185
232
|
const flush = useCallback(async () => {
|
|
@@ -187,38 +234,30 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
187
234
|
clearTimeout(debounceTimerRef.current);
|
|
188
235
|
debounceTimerRef.current = void 0;
|
|
189
236
|
}
|
|
190
|
-
if (!
|
|
191
|
-
if (!hasPendingLocalChangeRef.current && dirtyIdsRef.current.size === 0) return;
|
|
237
|
+
if (!(inFlightPersistenceRef.current > 0 || dirtyIdsRef.current.size > 0 || outgoingQueueRef.current.length > 0)) return;
|
|
192
238
|
const p = new Promise((resolve_0) => {
|
|
193
239
|
flushResolversRef.current.push(resolve_0);
|
|
194
240
|
});
|
|
195
|
-
if (
|
|
241
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
196
242
|
return p;
|
|
197
|
-
}, [
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
clearTimeout(debounceTimerRef.current);
|
|
201
|
-
debounceTimerRef.current = void 0;
|
|
202
|
-
runPersistence();
|
|
203
|
-
}
|
|
204
|
-
}, [runPersistence]);
|
|
205
|
-
const setDefState = useCallback((id_8, updater_0) => {
|
|
206
|
-
touchedIdsRef.current.add(id_8);
|
|
243
|
+
}, [enqueuePersistence]);
|
|
244
|
+
const setDefState = useCallback((id_9, updater_0) => {
|
|
245
|
+
touchedIdsRef.current.add(id_9);
|
|
207
246
|
setStateAndRef((prev_3) => {
|
|
208
|
-
const existing = prev_3.definitions[
|
|
247
|
+
const existing = prev_3.definitions[id_9];
|
|
209
248
|
if (!existing) return prev_3;
|
|
210
249
|
return {
|
|
211
250
|
...prev_3,
|
|
212
251
|
definitions: {
|
|
213
252
|
...prev_3.definitions,
|
|
214
|
-
[
|
|
253
|
+
[id_9]: {
|
|
215
254
|
...existing,
|
|
216
255
|
state: updater_0(existing.state)
|
|
217
256
|
}
|
|
218
257
|
}
|
|
219
258
|
};
|
|
220
259
|
});
|
|
221
|
-
if (stateRef.current.definitions[
|
|
260
|
+
if (stateRef.current.definitions[id_9]?.scope !== "thread") schedulePersistence(id_9);
|
|
222
261
|
}, [schedulePersistence, setStateAndRef]);
|
|
223
262
|
const provider = useMemo(() => ({
|
|
224
263
|
getModelContext: () => {
|
|
@@ -233,11 +272,28 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
233
272
|
}
|
|
234
273
|
}), [setDefState]);
|
|
235
274
|
useEffect(() => {
|
|
236
|
-
|
|
275
|
+
notifySubscribers(subscribersRef.current);
|
|
237
276
|
}, [state]);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
277
|
+
useAssistantScopeEffect("modelContext", () => clientRef.current.modelContext().register(provider), [provider]);
|
|
278
|
+
const installUpdateToolUI = useCallback((name, entry_1) => {
|
|
279
|
+
const toolsAccessor = clientRef.current?.tools;
|
|
280
|
+
if (!toolsAccessor || toolsAccessor.source == null) return false;
|
|
281
|
+
entry_1.unsubscribe = toolsAccessor().setToolUI(interactableToolName(name), entry_1.render, { standalone: true });
|
|
282
|
+
return true;
|
|
283
|
+
}, [clientRef]);
|
|
284
|
+
useAssistantScopeEffect("tools", () => {
|
|
285
|
+
for (const [name_0, entry_2] of updateToolUIsRef.current) {
|
|
286
|
+
entry_2.unsubscribe?.();
|
|
287
|
+
entry_2.unsubscribe = void 0;
|
|
288
|
+
installUpdateToolUI(name_0, entry_2);
|
|
289
|
+
}
|
|
290
|
+
return () => {
|
|
291
|
+
for (const entry_3 of updateToolUIsRef.current.values()) {
|
|
292
|
+
entry_3.unsubscribe?.();
|
|
293
|
+
entry_3.unsubscribe = void 0;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}, [installUpdateToolUI]);
|
|
241
297
|
return {
|
|
242
298
|
getState: () => stateRef.current,
|
|
243
299
|
register: useCallback((def_2) => {
|
|
@@ -248,24 +304,24 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
248
304
|
registrationCountsRef.current.set(def_2.id, (registrationCountsRef.current.get(def_2.id) ?? 0) + 1);
|
|
249
305
|
let releaseUpdateToolUI;
|
|
250
306
|
if (def_2.updateRender) {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
}
|
|
307
|
+
const existing_0 = updateToolUIsRef.current.get(def_2.name);
|
|
308
|
+
const entry_4 = existing_0 ?? {
|
|
309
|
+
count: 0,
|
|
310
|
+
render: def_2.updateRender,
|
|
311
|
+
unsubscribe: void 0
|
|
312
|
+
};
|
|
313
|
+
entry_4.count++;
|
|
314
|
+
if (!existing_0) updateToolUIsRef.current.set(def_2.name, entry_4);
|
|
315
|
+
if (!entry_4.unsubscribe && !installUpdateToolUI(def_2.name, entry_4) && process.env.NODE_ENV !== "production") console.warn(`[Interactables] "${def_2.name}" supplied an updateRender, but no tools scope is available yet; it will be installed once one appears.`);
|
|
316
|
+
releaseUpdateToolUI = () => {
|
|
317
|
+
const entry_5 = updateToolUIsRef.current.get(def_2.name);
|
|
318
|
+
if (!entry_5) return;
|
|
319
|
+
if (--entry_5.count === 0) {
|
|
320
|
+
updateToolUIsRef.current.delete(def_2.name);
|
|
321
|
+
entry_5.unsubscribe?.();
|
|
322
|
+
entry_5.unsubscribe = void 0;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
269
325
|
}
|
|
270
326
|
if (!partialSchemaCacheRef.current.has(def_2.id)) try {
|
|
271
327
|
const jsonSchema = toJSONSchema(def_2.stateSchema);
|
|
@@ -333,6 +389,7 @@ const useInteractablesResource = ({ persistence } = {}) => {
|
|
|
333
389
|
flushIfPending,
|
|
334
390
|
clientRef,
|
|
335
391
|
getCurrentThreadId,
|
|
392
|
+
installUpdateToolUI,
|
|
336
393
|
setStateAndRef
|
|
337
394
|
]),
|
|
338
395
|
setState: setDefState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interactables.js","names":["useState","useEffect","useCallback","useRef","useMemo","resource","ClientOutput","attachTransformScopes","useAssistantClientRef","Unstable_InteractablesState","Unstable_InteractableRegistration","Unstable_InteractablePersistedState","Unstable_InteractablePersistenceAdapter","Unstable_InteractablesConfig","toJSONSchema","toPartialJSONSchema","ModelContext","buildInteractableModelContext","PartialJSONSchema","findModelKnownState","interactableToolName","PERSISTENCE_DEBOUNCE_MS","RestorePersistedStateOptions","stash","Map","shouldStash","id","shouldApply","def","ToolCallLikePart","type","toolCallId","toolName","MessageLike","role","content","InternalInteractableRegistration","scope","hasInteractableCreateCall","messages","name","some","message","part","p","useInteractablesResource","persistence","state","setState","definitions","clientRef","stateRef","subscribersRef","Set","partialSchemaCacheRef","streamBaselinesRef","targetId","detachedAppStateRef","detachedThreadStateRef","registrationCountsRef","updateToolUIsRef","count","unsubscribe","loadedStateRef","touchedIdsRef","adapterRef","undefined","debounceTimerRef","ReturnType","setTimeout","syncSeqRef","hasPendingLocalChangeRef","flushResolversRef","Array","dirtyIdsRef","setStateAndRef","updater","prev","next","current","exportState","result","Object","entries","runPersistence","adapter","resolve","seq","dirtyIds","clear","payload","fromEntries","map","isPending","error","save","e","size","schedulePersistence","add","clearTimeout","restorePersistedState","saved","options","entry","set","changed","importState","applyLoadedState","has","loadFromAdapter","load","console","warn","setPersistenceAdapter","getCurrentThreadId","client","threadListItem","source","getState","threads","mainThreadId","flush","Promise","push","flushIfPending","setDefState","existing","provider","getModelContext","defs","subscribe","callback","delete","cb","modelContext","register","threadAccessor","thread","threadMessages","process","env","NODE_ENV","get","releaseUpdateToolUI","updateRender","toolsAccessor","tools","setToolUI","standalone","jsonSchema","stateSchema","threadId","detached","loaded","known","description","initialState","remaining","stateById","_","rest","__","restPersistence","unstable_Interactables","scopes","parent"],"sources":["../../../src/react/client/Interactables.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport {\n attachTransformScopes,\n useAssistantClientRef,\n} from \"@assistant-ui/store/client\";\nimport type {\n Unstable_InteractablesState,\n Unstable_InteractableRegistration,\n Unstable_InteractablePersistedState,\n Unstable_InteractablePersistenceAdapter,\n Unstable_InteractablesConfig,\n} from \"../types/scopes/interactables\";\nimport { toJSONSchema, toPartialJSONSchema } from \"assistant-stream\";\nimport { ModelContext } from \"../../store/clients/model-context-client\";\nimport {\n buildInteractableModelContext,\n type PartialJSONSchema,\n} from \"./interactable-model-context\";\nimport {\n findModelKnownState,\n interactableToolName,\n} from \"../../model-context/interactable-composer-metadata\";\n\nconst PERSISTENCE_DEBOUNCE_MS = 500;\n\ntype RestorePersistedStateOptions = {\n stash: Map<string, unknown>;\n shouldStash?: (id: string) => boolean;\n shouldApply?: (\n id: string,\n def: Unstable_InteractablesState[\"definitions\"][string],\n ) => boolean;\n};\n\ntype ToolCallLikePart = {\n type?: string;\n toolCallId?: string;\n toolName?: string;\n};\n\ntype MessageLike = {\n role?: string;\n content?: readonly unknown[] | undefined;\n};\n\ntype InternalInteractableRegistration = Unstable_InteractableRegistration & {\n scope?: \"thread\" | undefined;\n};\n\nconst hasInteractableCreateCall = (\n messages: readonly MessageLike[],\n id: string,\n name: string,\n) =>\n messages.some(\n (message) =>\n message.role === \"assistant\" &&\n message.content?.some((part) => {\n if (!part || typeof part !== \"object\") return false;\n const p = part as ToolCallLikePart;\n return (\n p.type === \"tool-call\" && p.toolCallId === id && p.toolName === name\n );\n }),\n );\n\nconst useInteractablesResource = ({\n persistence,\n}: Unstable_InteractablesConfig = {}): ClientOutput<\"unstable_interactables\"> => {\n const [state, setState] = useState<Unstable_InteractablesState>(() => ({\n definitions: {},\n persistence: {},\n }));\n\n const clientRef = useAssistantClientRef();\n\n const stateRef = useRef(state);\n\n const subscribersRef = useRef(new Set<() => void>());\n const partialSchemaCacheRef = useRef(new Map<string, PartialJSONSchema>());\n const streamBaselinesRef = useRef(\n new Map<string, { targetId: string; state: unknown }>(),\n );\n const detachedAppStateRef = useRef(new Map<string, unknown>());\n const detachedThreadStateRef = useRef(\n new Map<string, Map<string, unknown>>(),\n );\n // An instance may be registered from several anchors (its creating tool\n // call plus update_* calls); the definition lives until the last one leaves.\n const registrationCountsRef = useRef(new Map<string, number>());\n // One update-tool UI per interactable name, alive while any registrant\n // that supplied an updateRender is mounted.\n const updateToolUIsRef = useRef(\n new Map<string, { count: number; unsubscribe: () => void }>(),\n );\n // App-scoped state restored via adapter.load(), consumed as components register.\n const loadedStateRef = useRef(new Map<string, unknown>());\n // Ids edited locally this session — a local edit always wins over a slow load.\n const touchedIdsRef = useRef(new Set<string>());\n\n const adapterRef = useRef<\n Unstable_InteractablePersistenceAdapter | undefined\n >(undefined);\n const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const syncSeqRef = useRef(0);\n const hasPendingLocalChangeRef = useRef(false);\n const flushResolversRef = useRef<Array<() => void>>([]);\n const dirtyIdsRef = useRef(new Set<string>());\n\n const setStateAndRef = useCallback(\n (\n updater: (\n prev: Unstable_InteractablesState,\n ) => Unstable_InteractablesState,\n ) => {\n const next = updater(stateRef.current);\n stateRef.current = next;\n setState(next);\n },\n [],\n );\n\n const exportState = useCallback((): Unstable_InteractablePersistedState => {\n const result: Unstable_InteractablePersistedState = {};\n for (const [id, def] of Object.entries(stateRef.current.definitions)) {\n if (def.scope === \"thread\") continue; // thread items persist via snapshot, not the adapter\n result[id] = { name: def.name, state: def.state };\n }\n return result;\n }, []);\n\n const runPersistence = useCallback(async () => {\n const adapter = adapterRef.current;\n if (!adapter) {\n for (const resolve of flushResolversRef.current) resolve();\n flushResolversRef.current = [];\n return;\n }\n\n const seq = ++syncSeqRef.current;\n const dirtyIds = new Set(dirtyIdsRef.current);\n dirtyIdsRef.current.clear();\n hasPendingLocalChangeRef.current = true;\n\n // Snapshot before any await so unregistered definitions are still included.\n const payload = exportState();\n\n setStateAndRef((prev) => ({\n ...prev,\n persistence: {\n ...prev.persistence,\n ...Object.fromEntries(\n [...dirtyIds].map((id) => [\n id,\n { isPending: true, error: undefined },\n ]),\n ),\n },\n }));\n\n try {\n await adapter.save(payload);\n if (syncSeqRef.current === seq) {\n hasPendingLocalChangeRef.current = false;\n setStateAndRef((prev) => {\n const persistence = { ...prev.persistence };\n for (const id of dirtyIds) delete persistence[id];\n return { ...prev, persistence };\n });\n }\n } catch (e) {\n if (syncSeqRef.current === seq) {\n hasPendingLocalChangeRef.current = false;\n setStateAndRef((prev) => ({\n ...prev,\n persistence: {\n ...prev.persistence,\n ...Object.fromEntries(\n [...dirtyIds].map((id) => [id, { isPending: false, error: e }]),\n ),\n },\n }));\n }\n } finally {\n if (dirtyIdsRef.current.size > 0 && adapterRef.current) {\n runPersistence();\n } else {\n for (const resolve of flushResolversRef.current) resolve();\n flushResolversRef.current = [];\n }\n }\n }, [exportState, setStateAndRef]);\n\n const schedulePersistence = useCallback(\n (id: string) => {\n if (!adapterRef.current) return;\n dirtyIdsRef.current.add(id);\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n }\n debounceTimerRef.current = setTimeout(() => {\n debounceTimerRef.current = undefined;\n if (!hasPendingLocalChangeRef.current) {\n runPersistence();\n } else {\n debounceTimerRef.current = setTimeout(() => {\n debounceTimerRef.current = undefined;\n runPersistence();\n }, PERSISTENCE_DEBOUNCE_MS);\n }\n }, PERSISTENCE_DEBOUNCE_MS);\n },\n [runPersistence],\n );\n\n const restorePersistedState = useCallback(\n (\n saved: Unstable_InteractablePersistedState,\n options: RestorePersistedStateOptions,\n ) => {\n const shouldStash = options.shouldStash ?? (() => true);\n const shouldApply = options.shouldApply ?? (() => true);\n\n for (const [id, entry] of Object.entries(saved)) {\n if (shouldStash(id)) options.stash.set(id, entry.state);\n }\n setStateAndRef((prev) => {\n let changed = false;\n const definitions = { ...prev.definitions };\n for (const [id, entry] of Object.entries(saved)) {\n const def = definitions[id];\n if (!def || !shouldApply(id, def)) continue;\n definitions[id] = { ...def, state: entry.state };\n changed = true;\n }\n if (!changed) return prev;\n return { ...prev, definitions };\n });\n },\n [setStateAndRef],\n );\n\n const importState = useCallback(\n (saved: Unstable_InteractablePersistedState) => {\n restorePersistedState(saved, { stash: detachedAppStateRef.current });\n },\n [restorePersistedState],\n );\n\n // Applies adapter.load() output: a local edit made while the load was in\n // flight wins, and thread-scoped items never restore from the adapter.\n const applyLoadedState = useCallback(\n (saved: Unstable_InteractablePersistedState) => {\n restorePersistedState(saved, {\n stash: loadedStateRef.current,\n shouldStash: (id) => !touchedIdsRef.current.has(id),\n shouldApply: (id, def) =>\n !touchedIdsRef.current.has(id) && def.scope !== \"thread\",\n });\n },\n [restorePersistedState],\n );\n\n const loadFromAdapter = useCallback(\n async (adapter: Unstable_InteractablePersistenceAdapter) => {\n if (!adapter.load) return;\n try {\n const saved = await adapter.load();\n if (!saved || adapterRef.current !== adapter) return;\n applyLoadedState(saved);\n } catch (e) {\n console.warn(\"[Interactables] Persistence load failed.\", e);\n }\n },\n [applyLoadedState],\n );\n\n const setPersistenceAdapter = useCallback(\n (adapter: Unstable_InteractablePersistenceAdapter | undefined) => {\n adapterRef.current = adapter;\n if (adapter) void loadFromAdapter(adapter);\n },\n [loadFromAdapter],\n );\n\n const getCurrentThreadId = useCallback((): string | undefined => {\n const client = clientRef.current;\n if (!client) return undefined;\n\n const threadListItem = client.threadListItem;\n if (threadListItem.source != null) {\n return threadListItem().getState().id;\n }\n\n const threads = client.threads;\n if (threads.source != null) {\n return threads().getState().mainThreadId;\n }\n\n return undefined;\n }, [clientRef]);\n\n useEffect(() => {\n if (!persistence) return;\n setPersistenceAdapter(persistence);\n return () => {\n if (adapterRef.current === persistence) {\n adapterRef.current = undefined;\n }\n };\n }, [persistence, setPersistenceAdapter]);\n\n const flush = useCallback(async () => {\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n debounceTimerRef.current = undefined;\n }\n if (!adapterRef.current) return;\n if (!hasPendingLocalChangeRef.current && dirtyIdsRef.current.size === 0)\n return;\n const p = new Promise<void>((resolve) => {\n flushResolversRef.current.push(resolve);\n });\n if (!hasPendingLocalChangeRef.current) {\n runPersistence();\n }\n return p;\n }, [runPersistence]);\n\n const flushIfPending = useCallback(() => {\n if (adapterRef.current && debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n debounceTimerRef.current = undefined;\n runPersistence();\n }\n }, [runPersistence]);\n\n const setDefState = useCallback(\n (id: string, updater: (prev: unknown) => unknown) => {\n touchedIdsRef.current.add(id);\n setStateAndRef((prev) => {\n const existing = prev.definitions[id];\n if (!existing) return prev;\n return {\n ...prev,\n definitions: {\n ...prev.definitions,\n [id]: { ...existing, state: updater(existing.state) },\n },\n };\n });\n if (stateRef.current.definitions[id]?.scope !== \"thread\") {\n schedulePersistence(id);\n }\n },\n [schedulePersistence, setStateAndRef],\n );\n\n const provider = useMemo(\n () => ({\n getModelContext: () => {\n const defs = stateRef.current.definitions;\n return (\n buildInteractableModelContext(\n defs,\n partialSchemaCacheRef.current,\n setDefState,\n streamBaselinesRef.current,\n ) ?? {}\n );\n },\n subscribe: (callback: () => void) => {\n subscribersRef.current.add(callback);\n return () => {\n subscribersRef.current.delete(callback);\n };\n },\n }),\n [setDefState],\n );\n\n useEffect(() => {\n for (const cb of subscribersRef.current) cb();\n }, [state]);\n\n useEffect(() => {\n return clientRef.current!.modelContext().register(provider);\n }, [clientRef, provider]);\n\n const register = useCallback(\n (def: InternalInteractableRegistration) => {\n const threadAccessor = clientRef.current?.thread;\n const threadMessages =\n threadAccessor && threadAccessor.source != null\n ? (threadAccessor().getState().messages ?? [])\n : [];\n const scope =\n def.scope ??\n (hasInteractableCreateCall(threadMessages, def.id, def.name)\n ? \"thread\"\n : \"app\");\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n stateRef.current.definitions[def.id] &&\n scope !== \"thread\"\n ) {\n console.warn(\n `[Interactables] \"${def.name}\" (${def.id}) is already registered. ` +\n `Register an app-scoped interactable once (unstable_useInteractable) and ` +\n `read it from other components with unstable_useInteractableState.`,\n );\n }\n\n registrationCountsRef.current.set(\n def.id,\n (registrationCountsRef.current.get(def.id) ?? 0) + 1,\n );\n\n let releaseUpdateToolUI: (() => void) | undefined;\n if (def.updateRender) {\n const toolsAccessor = clientRef.current?.tools;\n if (toolsAccessor && toolsAccessor.source != null) {\n const toolName = interactableToolName(def.name);\n const existing = updateToolUIsRef.current.get(def.name);\n if (existing) {\n existing.count++;\n } else {\n updateToolUIsRef.current.set(def.name, {\n count: 1,\n unsubscribe: toolsAccessor().setToolUI(\n toolName,\n def.updateRender,\n { standalone: true },\n ),\n });\n }\n releaseUpdateToolUI = () => {\n const entry = updateToolUIsRef.current.get(def.name);\n if (!entry) return;\n if (--entry.count === 0) {\n updateToolUIsRef.current.delete(def.name);\n entry.unsubscribe();\n }\n };\n } else if (process.env.NODE_ENV !== \"production\") {\n console.warn(\n `[Interactables] \"${def.name}\" supplied an updateRender, but no ` +\n `tools scope is available to install it into.`,\n );\n }\n }\n\n // The same id re-registers once per anchor (its create call + each update_*).\n if (!partialSchemaCacheRef.current.has(def.id)) {\n try {\n const jsonSchema = toJSONSchema(def.stateSchema);\n partialSchemaCacheRef.current.set(\n def.id,\n toPartialJSONSchema(jsonSchema),\n );\n } catch (e) {\n console.warn(\n `[Interactables] Failed to create partial schema for \"${def.name}\". The update tool will accept arbitrary fields without validation.`,\n e,\n );\n }\n }\n\n const threadId = scope === \"thread\" ? getCurrentThreadId() : undefined;\n const detached =\n scope === \"thread\"\n ? threadId\n ? detachedThreadStateRef.current.get(threadId)?.get(def.id)\n : undefined\n : detachedAppStateRef.current.get(def.id);\n if (scope === \"thread\") {\n if (threadId)\n detachedThreadStateRef.current.get(threadId)?.delete(def.id);\n } else {\n detachedAppStateRef.current.delete(def.id);\n }\n const loaded =\n scope === \"thread\" ? undefined : loadedStateRef.current.get(def.id);\n\n // Tool-created items restore from what the model already knows in this\n // thread (the creating call's args, sent snapshots, and the model's own\n // update_* calls) on a fresh reload; detached (in-session remount) still\n // wins so an unsent edit survives a scroll/virtualization cycle.\n const known =\n scope === \"thread\"\n ? findModelKnownState(threadMessages, def.id, def.name)\n : undefined;\n\n setStateAndRef((prev) => ({\n ...prev,\n definitions: {\n ...prev.definitions,\n [def.id]: {\n id: def.id,\n name: def.name,\n description: def.description,\n stateSchema: def.stateSchema,\n initialState: def.initialState,\n scope,\n state:\n prev.definitions[def.id]?.state ??\n detached ??\n known?.state ??\n loaded ??\n def.initialState,\n },\n },\n }));\n\n return () => {\n releaseUpdateToolUI?.();\n\n const remaining = (registrationCountsRef.current.get(def.id) ?? 1) - 1;\n if (remaining > 0) {\n registrationCountsRef.current.set(def.id, remaining);\n return;\n }\n registrationCountsRef.current.delete(def.id);\n\n flushIfPending();\n setStateAndRef((prev) => {\n const existing = prev.definitions[def.id];\n if (existing) {\n if (existing.scope === \"thread\") {\n const threadId = getCurrentThreadId();\n if (threadId) {\n let stateById = detachedThreadStateRef.current.get(threadId);\n if (!stateById) {\n stateById = new Map();\n detachedThreadStateRef.current.set(threadId, stateById);\n }\n stateById.set(def.id, existing.state);\n }\n } else {\n detachedAppStateRef.current.set(def.id, existing.state);\n }\n }\n partialSchemaCacheRef.current.delete(def.id);\n const { [def.id]: _, ...rest } = prev.definitions;\n const { [def.id]: __, ...restPersistence } = prev.persistence;\n return { ...prev, definitions: rest, persistence: restPersistence };\n });\n };\n },\n [flushIfPending, clientRef, getCurrentThreadId, setStateAndRef],\n );\n\n return {\n getState: () => stateRef.current,\n register,\n setState: setDefState,\n exportState,\n importState,\n setPersistenceAdapter,\n flush,\n };\n};\n\n/**\n * Registers the unstable interactables store scope.\n *\n * @deprecated Unstable / Experimental (not actually removed).\n */\nexport const unstable_Interactables = resource(useInteractablesResource);\n\nattachTransformScopes(useInteractablesResource, (scopes, parent) => {\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n});\n"],"mappings":";;;;;;;;AAyBA,MAAMqB,0BAA0B;AA0BhC,MAAMiB,6BACJC,UACAb,IACAc,SAEAD,SAASE,MACNC,YACCA,QAAQR,SAAS,eACjBQ,QAAQP,SAASM,MAAME,SAAS;CAC9B,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU,OAAO;CAC9C,MAAMC,IAAID;CACV,OACEC,EAAEd,SAAS,eAAec,EAAEb,eAAeL,MAAMkB,EAAEZ,aAAaQ;AAEpE,CAAC,CACL;AAEF,MAAMK,4BAA4B,EAChCC,gBACgC,CAAC,MAA8C;CAC/E,MAAM,CAACC,OAAOC,YAAYhD,gBAA6C;EACrEiD,aAAa,CAAC;EACdH,aAAa,CAAC;CAChB,EAAE;CAEF,MAAMI,YAAY1C,sBAAsB;CAExC,MAAM2C,WAAWhD,OAAO4C,KAAK;CAE7B,MAAMK,iBAAiBjD,uBAAO,IAAIkD,IAAgB,CAAC;CACnD,MAAMC,wBAAwBnD,uBAAO,IAAIqB,IAA+B,CAAC;CACzE,MAAM+B,qBAAqBpD,uBACzB,IAAIqB,IAAkD,CACxD;CACA,MAAMiC,sBAAsBtD,uBAAO,IAAIqB,IAAqB,CAAC;CAC7D,MAAMkC,yBAAyBvD,uBAC7B,IAAIqB,IAAkC,CAC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GAAGE,MAAIF,KAAKsI,GAAG,GAAGC,SAASpF,OAAK5B;KACtC,MAAM,GAAGrB,MAAIF,KAAKwI,IAAI,GAAGC,oBAAoBtF,OAAK/B;KAClD,OAAO;MAAE,GAAG+B;MAAM5B,aAAagH;MAAMnH,aAAaqH;KAAgB;IACpE,CAAC;GACH;EACF,GACA;GAACtC;GAAgB3E;GAAWiE;GAAoBxC;EAAc,CAK9D6D;EACAxF,UAAU8E;EACV9C;EACA2B;EACAO;EACAQ;CACF;AACF;;;;;;AAOA,MAAa0C,yBAAyB/J,SAASwC,wBAAwB;AAEvEtC,sBAAsBsC,2BAA2BwH,QAAQC,WAAW;CAClE,IAAI,CAACD,OAAO9B,gBAAgB+B,OAAO/B,aAAajB,WAAW,MACzD+C,OAAO9B,eAAevH,aAAa;AAEvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Interactables.js","names":["useState","useEffect","useCallback","useRef","useMemo","resource","ClientOutput","attachTransformScopes","useAssistantClientRef","useAssistantScopeEffect","Unstable_InteractablesState","Unstable_InteractableRegistration","Unstable_InteractablePersistedState","Unstable_InteractablePersistenceAdapter","Unstable_InteractablesConfig","toJSONSchema","toPartialJSONSchema","ModelContext","buildInteractableModelContext","PartialJSONSchema","findModelKnownState","interactableToolName","notifySubscribers","notifyStateSubscribers","PERSISTENCE_DEBOUNCE_MS","RestorePersistedStateOptions","stash","Map","shouldStash","id","shouldApply","def","ToolCallLikePart","type","toolCallId","toolName","MessageLike","role","content","InternalInteractableRegistration","scope","UpdateToolUIEntry","count","render","NonNullable","unsubscribe","hasInteractableCreateCall","messages","name","some","message","part","p","useInteractablesResource","persistence","state","setState","definitions","clientRef","stateRef","subscribersRef","Set","partialSchemaCacheRef","streamBaselinesRef","targetId","detachedAppStateRef","detachedThreadStateRef","registrationCountsRef","updateToolUIsRef","loadedStateRef","touchedIdsRef","adapterRef","undefined","debounceTimerRef","ReturnType","setTimeout","syncSeqRef","latestSyncSeqByIdRef","inFlightPersistenceRef","flushResolversRef","Array","dirtyIdsRef","PersistenceBatch","adapter","payload","dirtyIds","seq","outgoingQueueRef","runPersistenceRef","batch","setStateAndRef","updater","prev","next","current","exportState","result","Object","entries","takeDirtyBatch","size","clear","set","enqueuePersistence","push","runPersistence","resolved","resolve","fromEntries","map","isPending","error","save","changed","get","has","delete","e","shift","clearTimeout","nextBatch","flushIfPending","schedulePersistence","add","restorePersistedState","saved","options","entry","importState","applyLoadedState","loadFromAdapter","load","console","warn","setPersistenceAdapter","getCurrentThreadId","client","threadListItem","source","getState","threads","mainThreadId","flush","hasWork","length","Promise","setDefState","existing","provider","getModelContext","defs","subscribe","callback","modelContext","register","installUpdateToolUI","toolsAccessor","tools","setToolUI","standalone","values","threadAccessor","thread","threadMessages","process","env","NODE_ENV","releaseUpdateToolUI","updateRender","jsonSchema","stateSchema","threadId","detached","loaded","known","description","initialState","remaining","stateById","_","rest","__","restPersistence","unstable_Interactables","scopes","parent"],"sources":["../../../src/react/client/Interactables.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport {\n attachTransformScopes,\n useAssistantClientRef,\n useAssistantScopeEffect,\n} from \"@assistant-ui/store/client\";\nimport type {\n Unstable_InteractablesState,\n Unstable_InteractableRegistration,\n Unstable_InteractablePersistedState,\n Unstable_InteractablePersistenceAdapter,\n Unstable_InteractablesConfig,\n} from \"../types/scopes/interactables\";\nimport { toJSONSchema, toPartialJSONSchema } from \"assistant-stream\";\nimport { ModelContext } from \"../../store/clients/model-context-client\";\nimport {\n buildInteractableModelContext,\n type PartialJSONSchema,\n} from \"./interactable-model-context\";\nimport {\n findModelKnownState,\n interactableToolName,\n} from \"../../model-context/interactable-composer-metadata\";\nimport { notifySubscribers as notifyStateSubscribers } from \"../../subscribable/subscribable\";\n\nconst PERSISTENCE_DEBOUNCE_MS = 500;\n\ntype RestorePersistedStateOptions = {\n stash: Map<string, unknown>;\n shouldStash?: (id: string) => boolean;\n shouldApply?: (\n id: string,\n def: Unstable_InteractablesState[\"definitions\"][string],\n ) => boolean;\n};\n\ntype ToolCallLikePart = {\n type?: string;\n toolCallId?: string;\n toolName?: string;\n};\n\ntype MessageLike = {\n role?: string;\n content?: readonly unknown[] | undefined;\n};\n\ntype InternalInteractableRegistration = Unstable_InteractableRegistration & {\n scope?: \"thread\" | undefined;\n};\n\ntype UpdateToolUIEntry = {\n count: number;\n render: NonNullable<Unstable_InteractableRegistration[\"updateRender\"]>;\n unsubscribe: (() => void) | undefined;\n};\n\nconst hasInteractableCreateCall = (\n messages: readonly MessageLike[],\n id: string,\n name: string,\n) =>\n messages.some(\n (message) =>\n message.role === \"assistant\" &&\n message.content?.some((part) => {\n if (!part || typeof part !== \"object\") return false;\n const p = part as ToolCallLikePart;\n return (\n p.type === \"tool-call\" && p.toolCallId === id && p.toolName === name\n );\n }),\n );\n\nconst useInteractablesResource = ({\n persistence,\n}: Unstable_InteractablesConfig = {}): ClientOutput<\"unstable_interactables\"> => {\n const [state, setState] = useState<Unstable_InteractablesState>(() => ({\n definitions: {},\n persistence: {},\n }));\n\n const clientRef = useAssistantClientRef();\n\n const stateRef = useRef(state);\n\n const subscribersRef = useRef(new Set<() => void>());\n const partialSchemaCacheRef = useRef(new Map<string, PartialJSONSchema>());\n const streamBaselinesRef = useRef(\n new Map<string, { targetId: string; state: unknown }>(),\n );\n const detachedAppStateRef = useRef(new Map<string, unknown>());\n const detachedThreadStateRef = useRef(\n new Map<string, Map<string, unknown>>(),\n );\n // An instance may be registered from several anchors (its creating tool\n // call plus update_* calls); the definition lives until the last one leaves.\n const registrationCountsRef = useRef(new Map<string, number>());\n // One update-tool UI per interactable name, alive while any registrant\n // that supplied an updateRender is mounted.\n const updateToolUIsRef = useRef(new Map<string, UpdateToolUIEntry>());\n // App-scoped state restored via adapter.load(), consumed as components register.\n const loadedStateRef = useRef(new Map<string, unknown>());\n // Ids edited locally this session — a local edit always wins over a slow load.\n const touchedIdsRef = useRef(new Set<string>());\n\n const adapterRef = useRef<\n Unstable_InteractablePersistenceAdapter | undefined\n >(undefined);\n const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const syncSeqRef = useRef(0);\n const latestSyncSeqByIdRef = useRef(new Map<string, number>());\n const inFlightPersistenceRef = useRef(0);\n const flushResolversRef = useRef<Array<() => void>>([]);\n const dirtyIdsRef = useRef(new Set<string>());\n\n type PersistenceBatch = {\n adapter: Unstable_InteractablePersistenceAdapter;\n payload: Unstable_InteractablePersistedState;\n dirtyIds: Set<string>;\n seq: number;\n };\n\n const outgoingQueueRef = useRef<PersistenceBatch[]>([]);\n const runPersistenceRef = useRef<(batch?: PersistenceBatch) => void>(\n () => {},\n );\n\n const setStateAndRef = useCallback(\n (\n updater: (\n prev: Unstable_InteractablesState,\n ) => Unstable_InteractablesState,\n ) => {\n const next = updater(stateRef.current);\n stateRef.current = next;\n setState(next);\n },\n [],\n );\n\n const exportState = useCallback((): Unstable_InteractablePersistedState => {\n const result: Unstable_InteractablePersistedState = {};\n for (const [id, def] of Object.entries(stateRef.current.definitions)) {\n if (def.scope === \"thread\") continue; // thread items persist via snapshot, not the adapter\n result[id] = { name: def.name, state: def.state };\n }\n return result;\n }, []);\n\n const takeDirtyBatch = useCallback(\n (\n adapter: Unstable_InteractablePersistenceAdapter,\n ): PersistenceBatch | undefined => {\n if (dirtyIdsRef.current.size === 0) return;\n const dirtyIds = new Set(dirtyIdsRef.current);\n dirtyIdsRef.current.clear();\n const seq = ++syncSeqRef.current;\n for (const id of dirtyIds) latestSyncSeqByIdRef.current.set(id, seq);\n return { adapter, payload: exportState(), dirtyIds, seq };\n },\n [exportState],\n );\n\n const enqueuePersistence = useCallback(\n (adapter: Unstable_InteractablePersistenceAdapter) => {\n const batch = takeDirtyBatch(adapter);\n if (!batch) return;\n if (inFlightPersistenceRef.current === 0) {\n runPersistenceRef.current(batch);\n } else {\n outgoingQueueRef.current.push(batch);\n }\n },\n [takeDirtyBatch],\n );\n\n const runPersistence = useCallback(\n async (batch?: PersistenceBatch) => {\n const resolved =\n batch ??\n (adapterRef.current ? takeDirtyBatch(adapterRef.current) : undefined);\n if (!resolved) {\n if (inFlightPersistenceRef.current === 0) {\n for (const resolve of flushResolversRef.current) resolve();\n flushResolversRef.current = [];\n }\n return;\n }\n\n const { adapter, payload, dirtyIds, seq } = resolved;\n inFlightPersistenceRef.current += 1;\n\n setStateAndRef((prev) => ({\n ...prev,\n persistence: {\n ...prev.persistence,\n ...Object.fromEntries(\n [...dirtyIds].map((id) => [\n id,\n { isPending: true, error: undefined },\n ]),\n ),\n },\n }));\n\n try {\n await adapter.save(payload);\n setStateAndRef((prev) => {\n let changed = false;\n const persistence = { ...prev.persistence };\n for (const id of dirtyIds) {\n if (\n latestSyncSeqByIdRef.current.get(id) !== seq ||\n dirtyIdsRef.current.has(id)\n )\n continue;\n latestSyncSeqByIdRef.current.delete(id);\n delete persistence[id];\n changed = true;\n }\n return changed ? { ...prev, persistence } : prev;\n });\n } catch (e) {\n setStateAndRef((prev) => {\n let changed = false;\n const persistence = { ...prev.persistence };\n for (const id of dirtyIds) {\n if (\n latestSyncSeqByIdRef.current.get(id) !== seq ||\n dirtyIdsRef.current.has(id)\n )\n continue;\n latestSyncSeqByIdRef.current.delete(id);\n persistence[id] = { isPending: false, error: e };\n changed = true;\n }\n return changed ? { ...prev, persistence } : prev;\n });\n } finally {\n inFlightPersistenceRef.current -= 1;\n const next =\n outgoingQueueRef.current.shift() ??\n (adapterRef.current && dirtyIdsRef.current.size > 0\n ? takeDirtyBatch(adapterRef.current)\n : undefined);\n if (next) {\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n debounceTimerRef.current = undefined;\n }\n runPersistenceRef.current(next);\n } else if (inFlightPersistenceRef.current === 0) {\n for (const resolve of flushResolversRef.current) resolve();\n flushResolversRef.current = [];\n }\n }\n },\n [setStateAndRef, takeDirtyBatch],\n );\n runPersistenceRef.current = (nextBatch) => {\n void runPersistence(nextBatch);\n };\n\n const flushIfPending = useCallback(() => {\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n debounceTimerRef.current = undefined;\n }\n if (adapterRef.current) enqueuePersistence(adapterRef.current);\n }, [enqueuePersistence]);\n\n const schedulePersistence = useCallback(\n (id: string) => {\n if (!adapterRef.current) return;\n dirtyIdsRef.current.add(id);\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n }\n debounceTimerRef.current = setTimeout(() => {\n debounceTimerRef.current = undefined;\n if (inFlightPersistenceRef.current === 0 && adapterRef.current) {\n enqueuePersistence(adapterRef.current);\n } else {\n debounceTimerRef.current = setTimeout(() => {\n debounceTimerRef.current = undefined;\n if (adapterRef.current) enqueuePersistence(adapterRef.current);\n }, PERSISTENCE_DEBOUNCE_MS);\n }\n }, PERSISTENCE_DEBOUNCE_MS);\n },\n [enqueuePersistence],\n );\n\n const restorePersistedState = useCallback(\n (\n saved: Unstable_InteractablePersistedState,\n options: RestorePersistedStateOptions,\n ) => {\n const shouldStash = options.shouldStash ?? (() => true);\n const shouldApply = options.shouldApply ?? (() => true);\n\n for (const [id, entry] of Object.entries(saved)) {\n if (shouldStash(id)) options.stash.set(id, entry.state);\n }\n setStateAndRef((prev) => {\n let changed = false;\n const definitions = { ...prev.definitions };\n for (const [id, entry] of Object.entries(saved)) {\n const def = definitions[id];\n if (!def || !shouldApply(id, def)) continue;\n definitions[id] = { ...def, state: entry.state };\n changed = true;\n }\n if (!changed) return prev;\n return { ...prev, definitions };\n });\n },\n [setStateAndRef],\n );\n\n const importState = useCallback(\n (saved: Unstable_InteractablePersistedState) => {\n restorePersistedState(saved, { stash: detachedAppStateRef.current });\n },\n [restorePersistedState],\n );\n\n // Applies adapter.load() output: a local edit made while the load was in\n // flight wins, and thread-scoped items never restore from the adapter.\n const applyLoadedState = useCallback(\n (saved: Unstable_InteractablePersistedState) => {\n restorePersistedState(saved, {\n stash: loadedStateRef.current,\n shouldStash: (id) => !touchedIdsRef.current.has(id),\n shouldApply: (id, def) =>\n !touchedIdsRef.current.has(id) && def.scope !== \"thread\",\n });\n },\n [restorePersistedState],\n );\n\n const loadFromAdapter = useCallback(\n async (adapter: Unstable_InteractablePersistenceAdapter) => {\n if (!adapter.load) return;\n try {\n const saved = await adapter.load();\n if (!saved || adapterRef.current !== adapter) return;\n applyLoadedState(saved);\n } catch (e) {\n console.warn(\"[Interactables] Persistence load failed.\", e);\n }\n },\n [applyLoadedState],\n );\n\n const setPersistenceAdapter = useCallback(\n (adapter: Unstable_InteractablePersistenceAdapter | undefined) => {\n if (adapterRef.current !== adapter) flushIfPending();\n adapterRef.current = adapter;\n if (adapter) void loadFromAdapter(adapter);\n },\n [flushIfPending, loadFromAdapter],\n );\n\n const getCurrentThreadId = useCallback((): string | undefined => {\n const client = clientRef.current;\n if (!client) return undefined;\n\n const threadListItem = client.threadListItem;\n if (threadListItem.source != null) {\n return threadListItem().getState().id;\n }\n\n const threads = client.threads;\n if (threads.source != null) {\n return threads().getState().mainThreadId;\n }\n\n return undefined;\n }, [clientRef]);\n\n useEffect(() => {\n if (!persistence) return;\n setPersistenceAdapter(persistence);\n return () => {\n if (adapterRef.current === persistence) {\n setPersistenceAdapter(undefined);\n }\n };\n }, [persistence, setPersistenceAdapter]);\n\n const flush = useCallback(async () => {\n if (debounceTimerRef.current !== undefined) {\n clearTimeout(debounceTimerRef.current);\n debounceTimerRef.current = undefined;\n }\n const hasWork =\n inFlightPersistenceRef.current > 0 ||\n dirtyIdsRef.current.size > 0 ||\n outgoingQueueRef.current.length > 0;\n if (!hasWork) return;\n const p = new Promise<void>((resolve) => {\n flushResolversRef.current.push(resolve);\n });\n if (adapterRef.current) enqueuePersistence(adapterRef.current);\n return p;\n }, [enqueuePersistence]);\n\n const setDefState = useCallback(\n (id: string, updater: (prev: unknown) => unknown) => {\n touchedIdsRef.current.add(id);\n setStateAndRef((prev) => {\n const existing = prev.definitions[id];\n if (!existing) return prev;\n return {\n ...prev,\n definitions: {\n ...prev.definitions,\n [id]: { ...existing, state: updater(existing.state) },\n },\n };\n });\n if (stateRef.current.definitions[id]?.scope !== \"thread\") {\n schedulePersistence(id);\n }\n },\n [schedulePersistence, setStateAndRef],\n );\n\n const provider = useMemo(\n () => ({\n getModelContext: () => {\n const defs = stateRef.current.definitions;\n return (\n buildInteractableModelContext(\n defs,\n partialSchemaCacheRef.current,\n setDefState,\n streamBaselinesRef.current,\n ) ?? {}\n );\n },\n subscribe: (callback: () => void) => {\n subscribersRef.current.add(callback);\n return () => {\n subscribersRef.current.delete(callback);\n };\n },\n }),\n [setDefState],\n );\n\n useEffect(() => {\n notifyStateSubscribers(subscribersRef.current);\n }, [state]);\n\n useAssistantScopeEffect(\n \"modelContext\",\n () => clientRef.current!.modelContext().register(provider),\n [provider],\n );\n\n const installUpdateToolUI = useCallback(\n (name: string, entry: UpdateToolUIEntry) => {\n const toolsAccessor = clientRef.current?.tools;\n if (!toolsAccessor || toolsAccessor.source == null) return false;\n entry.unsubscribe = toolsAccessor().setToolUI(\n interactableToolName(name),\n entry.render,\n { standalone: true },\n );\n return true;\n },\n [clientRef],\n );\n\n // register() installs update-tool UIs against the tools instance bound at\n // call time; this re-applies the retained entries when that instance is\n // structurally replaced and installs entries recorded while no tools\n // scope was available. Each re-apply releases the entry's previous\n // install first, so it is an orphaned no-op against a replaced instance\n // and an idempotent replacement against a live one.\n useAssistantScopeEffect(\n \"tools\",\n () => {\n for (const [name, entry] of updateToolUIsRef.current) {\n entry.unsubscribe?.();\n entry.unsubscribe = undefined;\n installUpdateToolUI(name, entry);\n }\n return () => {\n for (const entry of updateToolUIsRef.current.values()) {\n entry.unsubscribe?.();\n entry.unsubscribe = undefined;\n }\n };\n },\n [installUpdateToolUI],\n );\n\n const register = useCallback(\n (def: InternalInteractableRegistration) => {\n const threadAccessor = clientRef.current?.thread;\n const threadMessages =\n threadAccessor && threadAccessor.source != null\n ? (threadAccessor().getState().messages ?? [])\n : [];\n const scope =\n def.scope ??\n (hasInteractableCreateCall(threadMessages, def.id, def.name)\n ? \"thread\"\n : \"app\");\n\n if (\n process.env.NODE_ENV !== \"production\" &&\n stateRef.current.definitions[def.id] &&\n scope !== \"thread\"\n ) {\n console.warn(\n `[Interactables] \"${def.name}\" (${def.id}) is already registered. ` +\n `Register an app-scoped interactable once (unstable_useInteractable) and ` +\n `read it from other components with unstable_useInteractableState.`,\n );\n }\n\n registrationCountsRef.current.set(\n def.id,\n (registrationCountsRef.current.get(def.id) ?? 0) + 1,\n );\n\n let releaseUpdateToolUI: (() => void) | undefined;\n if (def.updateRender) {\n const existing = updateToolUIsRef.current.get(def.name);\n const entry = existing ?? {\n count: 0,\n render: def.updateRender,\n unsubscribe: undefined,\n };\n entry.count++;\n if (!existing) updateToolUIsRef.current.set(def.name, entry);\n\n if (\n !entry.unsubscribe &&\n !installUpdateToolUI(def.name, entry) &&\n process.env.NODE_ENV !== \"production\"\n ) {\n console.warn(\n `[Interactables] \"${def.name}\" supplied an updateRender, but no ` +\n `tools scope is available yet; it will be installed once one appears.`,\n );\n }\n\n releaseUpdateToolUI = () => {\n const entry = updateToolUIsRef.current.get(def.name);\n if (!entry) return;\n if (--entry.count === 0) {\n updateToolUIsRef.current.delete(def.name);\n entry.unsubscribe?.();\n entry.unsubscribe = undefined;\n }\n };\n }\n\n // The same id re-registers once per anchor (its create call + each update_*).\n if (!partialSchemaCacheRef.current.has(def.id)) {\n try {\n const jsonSchema = toJSONSchema(def.stateSchema);\n partialSchemaCacheRef.current.set(\n def.id,\n toPartialJSONSchema(jsonSchema),\n );\n } catch (e) {\n console.warn(\n `[Interactables] Failed to create partial schema for \"${def.name}\". The update tool will accept arbitrary fields without validation.`,\n e,\n );\n }\n }\n\n const threadId = scope === \"thread\" ? getCurrentThreadId() : undefined;\n const detached =\n scope === \"thread\"\n ? threadId\n ? detachedThreadStateRef.current.get(threadId)?.get(def.id)\n : undefined\n : detachedAppStateRef.current.get(def.id);\n if (scope === \"thread\") {\n if (threadId)\n detachedThreadStateRef.current.get(threadId)?.delete(def.id);\n } else {\n detachedAppStateRef.current.delete(def.id);\n }\n const loaded =\n scope === \"thread\" ? undefined : loadedStateRef.current.get(def.id);\n\n // Tool-created items restore from what the model already knows in this\n // thread (the creating call's args, sent snapshots, and the model's own\n // update_* calls) on a fresh reload; detached (in-session remount) still\n // wins so an unsent edit survives a scroll/virtualization cycle.\n const known =\n scope === \"thread\"\n ? findModelKnownState(threadMessages, def.id, def.name)\n : undefined;\n\n setStateAndRef((prev) => ({\n ...prev,\n definitions: {\n ...prev.definitions,\n [def.id]: {\n id: def.id,\n name: def.name,\n description: def.description,\n stateSchema: def.stateSchema,\n initialState: def.initialState,\n scope,\n state:\n prev.definitions[def.id]?.state ??\n detached ??\n known?.state ??\n loaded ??\n def.initialState,\n },\n },\n }));\n\n return () => {\n releaseUpdateToolUI?.();\n\n const remaining = (registrationCountsRef.current.get(def.id) ?? 1) - 1;\n if (remaining > 0) {\n registrationCountsRef.current.set(def.id, remaining);\n return;\n }\n registrationCountsRef.current.delete(def.id);\n\n flushIfPending();\n setStateAndRef((prev) => {\n const existing = prev.definitions[def.id];\n if (existing) {\n if (existing.scope === \"thread\") {\n const threadId = getCurrentThreadId();\n if (threadId) {\n let stateById = detachedThreadStateRef.current.get(threadId);\n if (!stateById) {\n stateById = new Map();\n detachedThreadStateRef.current.set(threadId, stateById);\n }\n stateById.set(def.id, existing.state);\n }\n } else {\n detachedAppStateRef.current.set(def.id, existing.state);\n }\n }\n partialSchemaCacheRef.current.delete(def.id);\n const { [def.id]: _, ...rest } = prev.definitions;\n const { [def.id]: __, ...restPersistence } = prev.persistence;\n return { ...prev, definitions: rest, persistence: restPersistence };\n });\n };\n },\n [\n flushIfPending,\n clientRef,\n getCurrentThreadId,\n installUpdateToolUI,\n setStateAndRef,\n ],\n );\n\n return {\n getState: () => stateRef.current,\n register,\n setState: setDefState,\n exportState,\n importState,\n setPersistenceAdapter,\n flush,\n };\n};\n\n/**\n * Registers the unstable interactables store scope.\n *\n * @deprecated Unstable / Experimental (not actually removed).\n */\nexport const unstable_Interactables = resource(useInteractablesResource);\n\nattachTransformScopes(useInteractablesResource, (scopes, parent) => {\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n});\n"],"mappings":";;;;;;;;;AA2BA,MAAMwB,0BAA0B;AAgChC,MAAMsB,6BACJC,UACAlB,IACAmB,SAEAD,SAASE,MACNC,YACCA,QAAQb,SAAS,eACjBa,QAAQZ,SAASW,MAAME,SAAS;CAC9B,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU,OAAO;CAC9C,MAAMC,IAAID;CACV,OACEC,EAAEnB,SAAS,eAAemB,EAAElB,eAAeL,MAAMuB,EAAEjB,aAAaa;AAEpE,CAAC,CACL;AAEF,MAAMK,4BAA4B,EAChCC,gBACgC,CAAC,MAA8C;CAC/E,MAAM,CAACC,OAAOC,YAAYxD,gBAA6C;EACrEyD,aAAa,CAAC;EACdH,aAAa,CAAC;CAChB,EAAE;CAEF,MAAMI,YAAYlD,sBAAsB;CAExC,MAAMmD,WAAWxD,OAAOoD,KAAK;CAE7B,MAAMK,iBAAiBzD,uBAAO,IAAI0D,IAAgB,CAAC;CACnD,MAAMC,wBAAwB3D,uBAAO,IAAIwB,IAA+B,CAAC;CACzE,MAAMoC,qBAAqB5D,uBACzB,IAAIwB,IAAkD,CACxD;CACA,MAAMsC,sBAAsB9D,uBAAO,IAAIwB,IAAqB,CAAC;CAC7D,MAAMuC,yBAAyB/D,uBAC7B,IAAIwB,IAAkC,CACxC;CAGA,MAAMwC,wBAAwBhE,uBAAO,IAAIwB,IAAoB,CAAC;CAG9D,MAAMyC,mBAAmBjE,uBAAO,IAAIwB,IAA+B,CAAC;CAEpE,MAAM0C,iBAAiBlE,uBAAO,IAAIwB,IAAqB,CAAC;CAExD,MAAM2C,gBAAgBnE,uBAAO,IAAI0D,IAAY,CAAC;CAE9C,MAAMU,aAAapE,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AAEvC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InMemoryThreadListProps } from "./InMemoryThreadList.js";
|
|
2
|
+
import { RemoteThreadListAdapter } from "../../runtimes/remote-thread-list/types.js";
|
|
3
|
+
import { ClientOutput } from "@assistant-ui/store";
|
|
4
|
+
//#region src/react/client/RemoteThreadList.d.ts
|
|
5
|
+
type RemoteThreadListProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Swapping this to a different backing store does not reload the list. Call `reload()` after a genuine swap. A recreated object for the same store is a no-op. `reload()` after a different adapter instance resets selection and cached records before loading.
|
|
8
|
+
*/
|
|
9
|
+
adapter: RemoteThreadListAdapter;
|
|
10
|
+
/**
|
|
11
|
+
* Factory for the visible thread. Per-thread history reload requires a
|
|
12
|
+
* resource keyed by thread id (`withKey(id, thread(...))`). An unkeyed
|
|
13
|
+
* factory keeps one instance across switches, so a mount-once history
|
|
14
|
+
* loader will not fetch the next thread.
|
|
15
|
+
*/
|
|
16
|
+
thread: InMemoryThreadListProps["thread"];
|
|
17
|
+
threadId?: string | undefined;
|
|
18
|
+
onThreadIdChange?: ((threadId: string | undefined) => void) | undefined;
|
|
19
|
+
onSwitchToThread?: ((threadId: string) => void) | undefined;
|
|
20
|
+
onSwitchToNewThread?: (() => void) | undefined;
|
|
21
|
+
onDelete?: ((threadId: string) => void) | undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `AuiConfig` `threads` entry backed by a `RemoteThreadListAdapter`. Thread
|
|
25
|
+
* bodies are born from the `thread` factory inside the client tree, so any
|
|
26
|
+
* `AssistantClient` host can run a remote or cloud list. Per-thread history
|
|
27
|
+
* and attachments come from `unstable_useAdapters`. `useRemoteThreadListRuntime`
|
|
28
|
+
* uses the same hook when `unstable_Provider` is omitted. Key the factory
|
|
29
|
+
* with `withKey` so history reloads when the visible thread changes.
|
|
30
|
+
*/
|
|
31
|
+
declare const RemoteThreadList: import("@assistant-ui/tap").Resource<ClientOutput<"threads">, [props: RemoteThreadListProps]>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { RemoteThreadList, RemoteThreadListProps };
|
|
34
|
+
//# sourceMappingURL=RemoteThreadList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteThreadList.d.ts","names":[],"sources":["../../../src/react/client/RemoteThreadList.ts"],"mappings":";;;;KAqDY;;;;EAIV,SAAS;;;;;;;EAOT,QAAQ;EACR;EACA,qBAAqB;EACrB,qBAAqB;EACrB;EACA,aAAa;;;;;;;;;;cAwiCF,8CAAgB,SAAA,0BAAA,OAAA"}
|