@assistant-ui/core 0.3.13 → 0.3.14
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 +27 -15
- package/dist/adapters/voice.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +6 -6
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +2 -1
- package/dist/model-context/frame/host.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 +826 -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 +13 -18
- 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/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 +22 -10
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +109 -71
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +40 -13
- 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 +134 -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 +22 -12
- 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/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 +35 -13
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- 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 +53 -13
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +3 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +3 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +29 -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/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 +12 -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/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/package.json +7 -7
- 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 +69 -0
- package/src/adapters/voice.ts +27 -27
- package/src/index.ts +1 -0
- package/src/model-context/frame/host.test.ts +23 -0
- package/src/model-context/frame/host.ts +2 -1
- 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 +1026 -0
- package/src/react/client/RemoteThreadList.ts +1067 -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.ts +2 -7
- 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/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 +159 -124
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +59 -20
- package/src/react/runtimes/RemoteThreadResource.test.ts +141 -0
- package/src/react/runtimes/RemoteThreadResource.ts +231 -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 +625 -0
- package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +481 -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.tsx +36 -21
- 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 +130 -4
- 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/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 +99 -34
- package/src/runtimes/local/local-thread-runtime-core.test.ts +373 -4
- package/src/runtimes/local/local-thread-runtime-core.ts +79 -14
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +4 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +4 -0
- package/src/runtimes/remote-thread-list/types.ts +30 -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/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.ts +11 -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/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/external-store-thread-list-runtime-core.test.ts +101 -0
- package/src/tests/external-store-thread-runtime-core-adapter.test.ts +191 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +124 -0
- package/src/tests/interactables-toolui-migration.test.tsx +66 -0
- package/src/tests/message-queue.test.ts +28 -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/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
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { notifySubscribers } from "../../subscribable/subscribable.js";
|
|
1
2
|
import { ModelContext } from "../../store/clients/model-context-client.js";
|
|
2
3
|
import { buildInteractableModelContext } from "./interactable-model-context.js";
|
|
3
4
|
import { toJSONSchema, toPartialJSONSchema } from "assistant-stream";
|
|
4
5
|
import { useCallback, useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
5
6
|
import { attachTransformScopes, useAssistantClientRef } from "@assistant-ui/store";
|
|
6
7
|
import { resource } from "@assistant-ui/tap";
|
|
8
|
+
import { useAssistantScopeEffect } from "@assistant-ui/store/client";
|
|
7
9
|
//#region src/react/interactables-legacy/Interactables.ts
|
|
8
10
|
const PERSISTENCE_DEBOUNCE_MS = 500;
|
|
9
11
|
const useInteractables = () => {
|
|
@@ -13,144 +15,179 @@ const useInteractables = () => {
|
|
|
13
15
|
}));
|
|
14
16
|
const clientRef = useAssistantClientRef();
|
|
15
17
|
const stateRef = useRef(state);
|
|
16
|
-
|
|
17
|
-
stateRef.current
|
|
18
|
-
|
|
18
|
+
const setStateAndRef = useCallback((updater) => {
|
|
19
|
+
const next = updater(stateRef.current);
|
|
20
|
+
stateRef.current = next;
|
|
21
|
+
setState(next);
|
|
22
|
+
}, []);
|
|
19
23
|
const subscribersRef = useRef(/* @__PURE__ */ new Set());
|
|
20
24
|
const partialSchemaCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
21
25
|
const detachedStateRef = useRef(/* @__PURE__ */ new Map());
|
|
22
26
|
const adapterRef = useRef(void 0);
|
|
23
27
|
const debounceTimerRef = useRef(void 0);
|
|
24
28
|
const syncSeqRef = useRef(0);
|
|
25
|
-
const
|
|
29
|
+
const latestSyncSeqByIdRef = useRef(/* @__PURE__ */ new Map());
|
|
30
|
+
const inFlightPersistenceRef = useRef(0);
|
|
26
31
|
const flushResolversRef = useRef([]);
|
|
27
32
|
const dirtyIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const seq = ++syncSeqRef.current;
|
|
36
|
-
const dirtyIds = new Set(dirtyIdsRef.current);
|
|
37
|
-
dirtyIdsRef.current.clear();
|
|
38
|
-
hasPendingLocalChangeRef.current = true;
|
|
39
|
-
const exported = stateRef.current.definitions;
|
|
40
|
-
const payload = {};
|
|
41
|
-
for (const [id, def] of Object.entries(exported)) payload[id] = {
|
|
33
|
+
const outgoingQueueRef = useRef([]);
|
|
34
|
+
const runPersistenceRef = useRef(() => {});
|
|
35
|
+
const exportState = useCallback(() => {
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const [id, def] of Object.entries(stateRef.current.definitions)) result[id] = {
|
|
42
38
|
name: def.name,
|
|
43
39
|
state: def.state
|
|
44
40
|
};
|
|
45
|
-
|
|
41
|
+
return result;
|
|
42
|
+
}, []);
|
|
43
|
+
const takeDirtyBatch = useCallback((adapter) => {
|
|
44
|
+
if (dirtyIdsRef.current.size === 0) return;
|
|
45
|
+
const dirtyIds = new Set(dirtyIdsRef.current);
|
|
46
|
+
dirtyIdsRef.current.clear();
|
|
47
|
+
const seq = ++syncSeqRef.current;
|
|
48
|
+
for (const id_0 of dirtyIds) latestSyncSeqByIdRef.current.set(id_0, seq);
|
|
49
|
+
return {
|
|
50
|
+
adapter,
|
|
51
|
+
payload: exportState(),
|
|
52
|
+
dirtyIds,
|
|
53
|
+
seq
|
|
54
|
+
};
|
|
55
|
+
}, [exportState]);
|
|
56
|
+
const enqueuePersistence = useCallback((adapter_0) => {
|
|
57
|
+
const batch = takeDirtyBatch(adapter_0);
|
|
58
|
+
if (!batch) return;
|
|
59
|
+
if (inFlightPersistenceRef.current === 0) runPersistenceRef.current(batch);
|
|
60
|
+
else outgoingQueueRef.current.push(batch);
|
|
61
|
+
}, [takeDirtyBatch]);
|
|
62
|
+
const runPersistence = useCallback(async (batch_0) => {
|
|
63
|
+
const resolved = batch_0 ?? (adapterRef.current ? takeDirtyBatch(adapterRef.current) : void 0);
|
|
64
|
+
if (!resolved) {
|
|
65
|
+
if (inFlightPersistenceRef.current === 0) {
|
|
66
|
+
for (const resolve of flushResolversRef.current) resolve();
|
|
67
|
+
flushResolversRef.current = [];
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { adapter: adapter_1, payload, dirtyIds: dirtyIds_0, seq: seq_0 } = resolved;
|
|
72
|
+
inFlightPersistenceRef.current += 1;
|
|
73
|
+
setStateAndRef((prev) => ({
|
|
46
74
|
...prev,
|
|
47
75
|
persistence: {
|
|
48
76
|
...prev.persistence,
|
|
49
|
-
...Object.fromEntries([...
|
|
77
|
+
...Object.fromEntries([...dirtyIds_0].map((id_1) => [id_1, {
|
|
50
78
|
isPending: true,
|
|
51
79
|
error: void 0
|
|
52
80
|
}]))
|
|
53
81
|
}
|
|
54
82
|
}));
|
|
55
83
|
try {
|
|
56
|
-
await
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
await adapter_1.save(payload);
|
|
85
|
+
setStateAndRef((prev_1) => {
|
|
86
|
+
let changed_0 = false;
|
|
87
|
+
const persistence_0 = { ...prev_1.persistence };
|
|
88
|
+
for (const id_3 of dirtyIds_0) {
|
|
89
|
+
if (latestSyncSeqByIdRef.current.get(id_3) !== seq_0 || dirtyIdsRef.current.has(id_3)) continue;
|
|
90
|
+
latestSyncSeqByIdRef.current.delete(id_3);
|
|
91
|
+
delete persistence_0[id_3];
|
|
92
|
+
changed_0 = true;
|
|
93
|
+
}
|
|
94
|
+
return changed_0 ? {
|
|
95
|
+
...prev_1,
|
|
96
|
+
persistence: persistence_0
|
|
97
|
+
} : prev_1;
|
|
98
|
+
});
|
|
68
99
|
} catch (e) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
100
|
+
setStateAndRef((prev_0) => {
|
|
101
|
+
let changed = false;
|
|
102
|
+
const persistence = { ...prev_0.persistence };
|
|
103
|
+
for (const id_2 of dirtyIds_0) {
|
|
104
|
+
if (latestSyncSeqByIdRef.current.get(id_2) !== seq_0 || dirtyIdsRef.current.has(id_2)) continue;
|
|
105
|
+
latestSyncSeqByIdRef.current.delete(id_2);
|
|
106
|
+
persistence[id_2] = {
|
|
107
|
+
isPending: false,
|
|
108
|
+
error: e
|
|
109
|
+
};
|
|
110
|
+
changed = true;
|
|
111
|
+
}
|
|
112
|
+
return changed ? {
|
|
72
113
|
...prev_0,
|
|
73
|
-
persistence
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
isPending: false,
|
|
77
|
-
error: e
|
|
78
|
-
}]))
|
|
79
|
-
}
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
114
|
+
persistence
|
|
115
|
+
} : prev_0;
|
|
116
|
+
});
|
|
82
117
|
} finally {
|
|
83
|
-
|
|
84
|
-
|
|
118
|
+
inFlightPersistenceRef.current -= 1;
|
|
119
|
+
const next = outgoingQueueRef.current.shift() ?? (adapterRef.current && dirtyIdsRef.current.size > 0 ? takeDirtyBatch(adapterRef.current) : void 0);
|
|
120
|
+
if (next) {
|
|
121
|
+
if (debounceTimerRef.current !== void 0) {
|
|
122
|
+
clearTimeout(debounceTimerRef.current);
|
|
123
|
+
debounceTimerRef.current = void 0;
|
|
124
|
+
}
|
|
125
|
+
runPersistenceRef.current(next);
|
|
126
|
+
} else if (inFlightPersistenceRef.current === 0) {
|
|
85
127
|
for (const resolve of flushResolversRef.current) resolve();
|
|
86
128
|
flushResolversRef.current = [];
|
|
87
129
|
}
|
|
88
130
|
}
|
|
89
|
-
}, []);
|
|
90
|
-
|
|
131
|
+
}, [setStateAndRef, takeDirtyBatch]);
|
|
132
|
+
runPersistenceRef.current = (nextBatch) => {
|
|
133
|
+
runPersistence(nextBatch);
|
|
134
|
+
};
|
|
135
|
+
const schedulePersistence = useCallback((id_4) => {
|
|
91
136
|
if (!adapterRef.current) return;
|
|
92
|
-
dirtyIdsRef.current.add(
|
|
137
|
+
dirtyIdsRef.current.add(id_4);
|
|
93
138
|
if (debounceTimerRef.current !== void 0) clearTimeout(debounceTimerRef.current);
|
|
94
139
|
debounceTimerRef.current = setTimeout(() => {
|
|
95
140
|
debounceTimerRef.current = void 0;
|
|
96
|
-
if (
|
|
141
|
+
if (inFlightPersistenceRef.current === 0 && adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
97
142
|
else debounceTimerRef.current = setTimeout(() => {
|
|
98
143
|
debounceTimerRef.current = void 0;
|
|
99
|
-
|
|
144
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
100
145
|
}, PERSISTENCE_DEBOUNCE_MS);
|
|
101
146
|
}, PERSISTENCE_DEBOUNCE_MS);
|
|
102
|
-
}, [
|
|
103
|
-
const exportState = useCallback(() => {
|
|
104
|
-
const result = {};
|
|
105
|
-
for (const [id_4, def_0] of Object.entries(stateRef.current.definitions)) result[id_4] = {
|
|
106
|
-
name: def_0.name,
|
|
107
|
-
state: def_0.state
|
|
108
|
-
};
|
|
109
|
-
return result;
|
|
110
|
-
}, []);
|
|
147
|
+
}, [enqueuePersistence]);
|
|
111
148
|
const importState = useCallback((saved) => {
|
|
112
149
|
for (const [id_5, entry] of Object.entries(saved)) detachedStateRef.current.set(id_5, entry.state);
|
|
113
|
-
|
|
114
|
-
let
|
|
150
|
+
setStateAndRef((prev_2) => {
|
|
151
|
+
let changed_1 = false;
|
|
115
152
|
const definitions = { ...prev_2.definitions };
|
|
116
153
|
for (const [id_6, entry_0] of Object.entries(saved)) if (definitions[id_6]) {
|
|
117
154
|
definitions[id_6] = {
|
|
118
155
|
...definitions[id_6],
|
|
119
156
|
state: entry_0.state
|
|
120
157
|
};
|
|
121
|
-
|
|
158
|
+
changed_1 = true;
|
|
122
159
|
}
|
|
123
|
-
return
|
|
160
|
+
return changed_1 ? {
|
|
124
161
|
...prev_2,
|
|
125
162
|
definitions
|
|
126
163
|
} : prev_2;
|
|
127
164
|
});
|
|
128
|
-
}, []);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
165
|
+
}, [setStateAndRef]);
|
|
166
|
+
const flushIfPending = useCallback(() => {
|
|
167
|
+
if (debounceTimerRef.current !== void 0) {
|
|
168
|
+
clearTimeout(debounceTimerRef.current);
|
|
169
|
+
debounceTimerRef.current = void 0;
|
|
170
|
+
}
|
|
171
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
172
|
+
}, [enqueuePersistence]);
|
|
132
173
|
const flush = useCallback(async () => {
|
|
133
174
|
if (debounceTimerRef.current !== void 0) {
|
|
134
175
|
clearTimeout(debounceTimerRef.current);
|
|
135
176
|
debounceTimerRef.current = void 0;
|
|
136
177
|
}
|
|
137
|
-
if (!
|
|
138
|
-
if (!hasPendingLocalChangeRef.current && dirtyIdsRef.current.size === 0) return;
|
|
178
|
+
if (!(inFlightPersistenceRef.current > 0 || dirtyIdsRef.current.size > 0 || outgoingQueueRef.current.length > 0)) return;
|
|
139
179
|
const p = new Promise((resolve_0) => {
|
|
140
180
|
flushResolversRef.current.push(resolve_0);
|
|
141
181
|
});
|
|
142
|
-
if (
|
|
182
|
+
if (adapterRef.current) enqueuePersistence(adapterRef.current);
|
|
143
183
|
return p;
|
|
144
|
-
}, [
|
|
145
|
-
const
|
|
146
|
-
if (adapterRef.current
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}, [runPersistence]);
|
|
152
|
-
const setDefState = useCallback((id_7, updater) => {
|
|
153
|
-
setState((prev_3) => {
|
|
184
|
+
}, [enqueuePersistence]);
|
|
185
|
+
const setPersistenceAdapter = useCallback((adapter_2) => {
|
|
186
|
+
if (adapterRef.current !== adapter_2) flushIfPending();
|
|
187
|
+
adapterRef.current = adapter_2;
|
|
188
|
+
}, [flushIfPending]);
|
|
189
|
+
const setDefState = useCallback((id_7, updater_0) => {
|
|
190
|
+
setStateAndRef((prev_3) => {
|
|
154
191
|
const existing = prev_3.definitions[id_7];
|
|
155
192
|
if (!existing) return prev_3;
|
|
156
193
|
return {
|
|
@@ -159,15 +196,15 @@ const useInteractables = () => {
|
|
|
159
196
|
...prev_3.definitions,
|
|
160
197
|
[id_7]: {
|
|
161
198
|
...existing,
|
|
162
|
-
state:
|
|
199
|
+
state: updater_0(existing.state)
|
|
163
200
|
}
|
|
164
201
|
}
|
|
165
202
|
};
|
|
166
203
|
});
|
|
167
204
|
if (stateRef.current.definitions[id_7]) schedulePersistence(id_7);
|
|
168
|
-
}, [schedulePersistence]);
|
|
205
|
+
}, [schedulePersistence, setStateAndRef]);
|
|
169
206
|
const setDefSelected = useCallback((id_8, selected) => {
|
|
170
|
-
|
|
207
|
+
setStateAndRef((prev_4) => {
|
|
171
208
|
const existing_0 = prev_4.definitions[id_8];
|
|
172
209
|
if (!existing_0) return prev_4;
|
|
173
210
|
return {
|
|
@@ -181,7 +218,7 @@ const useInteractables = () => {
|
|
|
181
218
|
}
|
|
182
219
|
};
|
|
183
220
|
});
|
|
184
|
-
}, []);
|
|
221
|
+
}, [setStateAndRef]);
|
|
185
222
|
const provider = useMemo(() => ({
|
|
186
223
|
getModelContext: () => {
|
|
187
224
|
const defs = stateRef.current.definitions;
|
|
@@ -195,44 +232,42 @@ const useInteractables = () => {
|
|
|
195
232
|
}
|
|
196
233
|
}), [setDefState]);
|
|
197
234
|
useEffect(() => {
|
|
198
|
-
|
|
235
|
+
notifySubscribers(subscribersRef.current);
|
|
199
236
|
}, [state]);
|
|
200
|
-
|
|
201
|
-
return clientRef.current.modelContext().register(provider);
|
|
202
|
-
}, [clientRef, provider]);
|
|
237
|
+
useAssistantScopeEffect("modelContext", () => clientRef.current.modelContext().register(provider), [provider]);
|
|
203
238
|
return {
|
|
204
239
|
getState: () => state,
|
|
205
|
-
register: useCallback((
|
|
240
|
+
register: useCallback((def_0) => {
|
|
206
241
|
try {
|
|
207
|
-
const jsonSchema = toJSONSchema(
|
|
208
|
-
partialSchemaCacheRef.current.set(
|
|
242
|
+
const jsonSchema = toJSONSchema(def_0.stateSchema);
|
|
243
|
+
partialSchemaCacheRef.current.set(def_0.id, toPartialJSONSchema(jsonSchema));
|
|
209
244
|
} catch (e_0) {
|
|
210
|
-
console.warn(`[Interactables] Failed to create partial schema for "${
|
|
245
|
+
console.warn(`[Interactables] Failed to create partial schema for "${def_0.name}". The update tool will require all fields.`, e_0);
|
|
211
246
|
}
|
|
212
|
-
const detached = detachedStateRef.current.get(
|
|
213
|
-
detachedStateRef.current.delete(
|
|
214
|
-
|
|
247
|
+
const detached = detachedStateRef.current.get(def_0.id);
|
|
248
|
+
detachedStateRef.current.delete(def_0.id);
|
|
249
|
+
setStateAndRef((prev_5) => ({
|
|
215
250
|
...prev_5,
|
|
216
251
|
definitions: {
|
|
217
252
|
...prev_5.definitions,
|
|
218
|
-
[
|
|
219
|
-
id:
|
|
220
|
-
name:
|
|
221
|
-
description:
|
|
222
|
-
stateSchema:
|
|
223
|
-
state: prev_5.definitions[
|
|
224
|
-
selected:
|
|
253
|
+
[def_0.id]: {
|
|
254
|
+
id: def_0.id,
|
|
255
|
+
name: def_0.name,
|
|
256
|
+
description: def_0.description,
|
|
257
|
+
stateSchema: def_0.stateSchema,
|
|
258
|
+
state: prev_5.definitions[def_0.id]?.state ?? detached ?? def_0.initialState,
|
|
259
|
+
selected: def_0.selected
|
|
225
260
|
}
|
|
226
261
|
}
|
|
227
262
|
}));
|
|
228
263
|
return () => {
|
|
229
264
|
flushIfPending();
|
|
230
|
-
|
|
231
|
-
const existing_1 = prev_6.definitions[
|
|
232
|
-
if (existing_1) detachedStateRef.current.set(
|
|
233
|
-
partialSchemaCacheRef.current.delete(
|
|
234
|
-
const { [
|
|
235
|
-
const { [
|
|
265
|
+
setStateAndRef((prev_6) => {
|
|
266
|
+
const existing_1 = prev_6.definitions[def_0.id];
|
|
267
|
+
if (existing_1) detachedStateRef.current.set(def_0.id, existing_1.state);
|
|
268
|
+
partialSchemaCacheRef.current.delete(def_0.id);
|
|
269
|
+
const { [def_0.id]: _, ...rest } = prev_6.definitions;
|
|
270
|
+
const { [def_0.id]: __, ...restPersistence } = prev_6.persistence;
|
|
236
271
|
return {
|
|
237
272
|
...prev_6,
|
|
238
273
|
definitions: rest,
|
|
@@ -240,7 +275,7 @@ const useInteractables = () => {
|
|
|
240
275
|
};
|
|
241
276
|
});
|
|
242
277
|
};
|
|
243
|
-
}, [flushIfPending]),
|
|
278
|
+
}, [flushIfPending, setStateAndRef]),
|
|
244
279
|
setState: setDefState,
|
|
245
280
|
setSelected: setDefSelected,
|
|
246
281
|
exportState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interactables.js","names":["useState","useEffect","useCallback","useRef","useMemo","resource","useAssistantClientRef","ClientOutput","attachTransformScopes","InteractablesState","InteractableRegistration","InteractableStateSchema","InteractablePersistedState","InteractablePersistenceAdapter","toJSONSchema","toPartialJSONSchema","ModelContext","buildInteractableModelContext","PERSISTENCE_DEBOUNCE_MS","useInteractables","state","setState","definitions","persistence","clientRef","stateRef","current","subscribersRef","Set","partialSchemaCacheRef","Map","detachedStateRef","adapterRef","undefined","debounceTimerRef","ReturnType","setTimeout","syncSeqRef","hasPendingLocalChangeRef","flushResolversRef","Array","dirtyIdsRef","runPersistence","adapter","resolve","seq","dirtyIds","clear","exported","payload","id","def","Object","entries","name","prev","fromEntries","map","isPending","error","save","e","size","schedulePersistence","add","clearTimeout","exportState","result","importState","saved","entry","set","changed","setPersistenceAdapter","flush","p","Promise","push","flushIfPending","setDefState","updater","existing","setDefSelected","selected","provider","getModelContext","defs","subscribe","callback","delete","cb","modelContext","register","jsonSchema","stateSchema","console","warn","detached","get","description","initialState","_","rest","__","restPersistence","getState","setSelected","Interactables","scopes","parent","source"],"sources":["../../../src/react/interactables-legacy/Interactables.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport {\n useAssistantClientRef,\n type ClientOutput,\n attachTransformScopes,\n} from \"@assistant-ui/store\";\nimport type {\n InteractablesState,\n InteractableRegistration,\n InteractableStateSchema,\n InteractablePersistedState,\n InteractablePersistenceAdapter,\n} from \"./scopes\";\nimport { toJSONSchema, toPartialJSONSchema } from \"assistant-stream\";\nimport { ModelContext } from \"../../store\";\nimport { buildInteractableModelContext } from \"./interactable-model-context\";\n\nconst PERSISTENCE_DEBOUNCE_MS = 500;\n\nconst useInteractables = (): ClientOutput<\"interactables\"> => {\n const [state, setState] = useState<InteractablesState>(() => ({\n definitions: {},\n persistence: {},\n }));\n\n const clientRef = useAssistantClientRef();\n\n const stateRef = useRef(state);\n useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n const subscribersRef = useRef(new Set<() => void>());\n const partialSchemaCacheRef = useRef(\n new Map<string, InteractableStateSchema>(),\n );\n const detachedStateRef = useRef(new Map<string, unknown>());\n\n const adapterRef = useRef<InteractablePersistenceAdapter | undefined>(\n undefined,\n );\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 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 exported = stateRef.current.definitions;\n const payload: InteractablePersistedState = {};\n for (const [id, def] of Object.entries(exported)) {\n payload[id] = { name: def.name, state: def.state };\n }\n\n setState((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 setState((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 setState((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 }, []);\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 exportState = useCallback((): InteractablePersistedState => {\n const result: InteractablePersistedState = {};\n for (const [id, def] of Object.entries(stateRef.current.definitions)) {\n result[id] = { name: def.name, state: def.state };\n }\n return result;\n }, []);\n\n const importState = useCallback((saved: InteractablePersistedState) => {\n for (const [id, entry] of Object.entries(saved)) {\n detachedStateRef.current.set(id, entry.state);\n }\n setState((prev) => {\n let changed = false;\n const definitions = { ...prev.definitions };\n for (const [id, entry] of Object.entries(saved)) {\n if (definitions[id]) {\n definitions[id] = { ...definitions[id], state: entry.state };\n changed = true;\n }\n }\n return changed ? { ...prev, definitions } : prev;\n });\n }, []);\n\n const setPersistenceAdapter = useCallback(\n (adapter: InteractablePersistenceAdapter | undefined) => {\n adapterRef.current = adapter;\n },\n [],\n );\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 setState((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]) schedulePersistence(id);\n },\n [schedulePersistence],\n );\n\n const setDefSelected = useCallback((id: string, selected: boolean) => {\n setState((prev) => {\n const existing = prev.definitions[id];\n if (!existing) return prev;\n return {\n ...prev,\n definitions: {\n ...prev.definitions,\n [id]: { ...existing, selected },\n },\n };\n });\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 ) ?? {}\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: InteractableRegistration) => {\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 require all fields.`,\n e,\n );\n }\n\n const detached = detachedStateRef.current.get(def.id);\n detachedStateRef.current.delete(def.id);\n\n setState((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 state:\n prev.definitions[def.id]?.state ?? detached ?? def.initialState,\n selected: def.selected,\n },\n },\n }));\n\n return () => {\n flushIfPending();\n setState((prev) => {\n const existing = prev.definitions[def.id];\n if (existing) {\n detachedStateRef.current.set(def.id, existing.state);\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],\n );\n\n return {\n getState: () => state,\n register,\n setState: setDefState,\n setSelected: setDefSelected,\n exportState,\n importState,\n setPersistenceAdapter,\n flush,\n };\n};\n\n/**\n * @deprecated Since 2026-06-14 — migrate to the Unstable / Experimental API.\n * Scheduled for removal on/after 2026-09-14. See\n * {@link https://www.assistant-ui.com/docs/tools/interactables#migrating-from-the-previous-api | Interactables migration guide}.\n */\nexport const Interactables = resource(useInteractables);\n\nattachTransformScopes(useInteractables, (scopes, parent) => {\n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ACXL,eAAe;IACfzD,UAAUkC,WAAS;KACjB,MAAM0B,aAAW1B,OAAKjC,YAAY6B,MAAID;KACtC,IAAI+B,YACFlD,iBAAiBL,QAAQ6C,IAAIpB,MAAID,IAAI+B,WAAS7D,KAAK;KAErDS,sBAAsBH,QAAQ+D,OAAOtC,MAAID,EAAE;KAC3C,MAAM,GAAGC,MAAID,KAAKmD,GAAG,GAAGC,SAAS/C,OAAKjC;KACtC,MAAM,GAAG6B,MAAID,KAAKqD,IAAI,GAAGC,oBAAoBjD,OAAKhC;KAClD,OAAO;MAAE,GAAGgC;MAAMjC,aAAagF;MAAM/E,aAAaiF;KAAgB;IACpE,CAAC;GACH;EACF,GACA,CAAC1B,cAAc,CAKfc;EACAvE,UAAU0D;EACV2B,aAAaxB;EACbhB;EACAE;EACAK;EACAC;CACF;AACF;;;;;;AAOA,MAAaiC,gBAAgBtG,SAASc,gBAAgB;AAEtDX,sBAAsBW,mBAAmByF,QAAQC,WAAW;CAC1D,IAAI,CAACD,OAAOjB,gBAAgBkB,OAAOlB,aAAamB,WAAW,MACzDF,OAAOjB,eAAe3E,aAAa;AAEvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Interactables.js","names":["useState","useEffect","useCallback","useRef","useMemo","resource","useAssistantClientRef","ClientOutput","attachTransformScopes","useAssistantScopeEffect","InteractablesState","InteractableRegistration","InteractableStateSchema","InteractablePersistedState","InteractablePersistenceAdapter","toJSONSchema","toPartialJSONSchema","ModelContext","buildInteractableModelContext","notifySubscribers","notifyStateSubscribers","PERSISTENCE_DEBOUNCE_MS","useInteractables","state","setState","definitions","persistence","clientRef","stateRef","setStateAndRef","updater","prev","next","current","subscribersRef","Set","partialSchemaCacheRef","Map","detachedStateRef","adapterRef","undefined","debounceTimerRef","ReturnType","setTimeout","syncSeqRef","latestSyncSeqByIdRef","inFlightPersistenceRef","flushResolversRef","Array","dirtyIdsRef","PersistenceBatch","adapter","payload","dirtyIds","seq","outgoingQueueRef","runPersistenceRef","batch","exportState","result","id","def","Object","entries","name","takeDirtyBatch","size","clear","set","enqueuePersistence","push","runPersistence","resolved","resolve","fromEntries","map","isPending","error","save","changed","get","has","delete","e","shift","clearTimeout","nextBatch","schedulePersistence","add","importState","saved","entry","flushIfPending","flush","hasWork","length","p","Promise","setPersistenceAdapter","setDefState","existing","setDefSelected","selected","provider","getModelContext","defs","subscribe","callback","modelContext","register","jsonSchema","stateSchema","console","warn","detached","description","initialState","_","rest","__","restPersistence","getState","setSelected","Interactables","scopes","parent","source"],"sources":["../../../src/react/interactables-legacy/Interactables.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport {\n useAssistantClientRef,\n type ClientOutput,\n attachTransformScopes,\n} from \"@assistant-ui/store\";\nimport { useAssistantScopeEffect } from \"@assistant-ui/store/client\";\nimport type {\n InteractablesState,\n InteractableRegistration,\n InteractableStateSchema,\n InteractablePersistedState,\n InteractablePersistenceAdapter,\n} from \"./scopes\";\nimport { toJSONSchema, toPartialJSONSchema } from \"assistant-stream\";\nimport { ModelContext } from \"../../store\";\nimport { buildInteractableModelContext } from \"./interactable-model-context\";\nimport { notifySubscribers as notifyStateSubscribers } from \"../../subscribable/subscribable\";\n\nconst PERSISTENCE_DEBOUNCE_MS = 500;\n\nconst useInteractables = (): ClientOutput<\"interactables\"> => {\n const [state, setState] = useState<InteractablesState>(() => ({\n definitions: {},\n persistence: {},\n }));\n\n const clientRef = useAssistantClientRef();\n\n const stateRef = useRef(state);\n\n const setStateAndRef = useCallback(\n (updater: (prev: InteractablesState) => InteractablesState) => {\n const next = updater(stateRef.current);\n stateRef.current = next;\n setState(next);\n },\n [],\n );\n\n const subscribersRef = useRef(new Set<() => void>());\n const partialSchemaCacheRef = useRef(\n new Map<string, InteractableStateSchema>(),\n );\n const detachedStateRef = useRef(new Map<string, unknown>());\n\n const adapterRef = useRef<InteractablePersistenceAdapter | undefined>(\n undefined,\n );\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: InteractablePersistenceAdapter;\n payload: 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 exportState = useCallback((): InteractablePersistedState => {\n const result: InteractablePersistedState = {};\n for (const [id, def] of Object.entries(stateRef.current.definitions)) {\n result[id] = { name: def.name, state: def.state };\n }\n return result;\n }, []);\n\n const takeDirtyBatch = useCallback(\n (adapter: InteractablePersistenceAdapter): 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: 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 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 importState = useCallback(\n (saved: InteractablePersistedState) => {\n for (const [id, entry] of Object.entries(saved)) {\n detachedStateRef.current.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 if (definitions[id]) {\n definitions[id] = { ...definitions[id], state: entry.state };\n changed = true;\n }\n }\n return changed ? { ...prev, definitions } : prev;\n });\n },\n [setStateAndRef],\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 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 setPersistenceAdapter = useCallback(\n (adapter: InteractablePersistenceAdapter | undefined) => {\n if (adapterRef.current !== adapter) flushIfPending();\n adapterRef.current = adapter;\n },\n [flushIfPending],\n );\n\n const setDefState = useCallback(\n (id: string, updater: (prev: unknown) => unknown) => {\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]) schedulePersistence(id);\n },\n [schedulePersistence, setStateAndRef],\n );\n\n const setDefSelected = useCallback(\n (id: string, selected: boolean) => {\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, selected },\n },\n };\n });\n },\n [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 ) ?? {}\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 register = useCallback(\n (def: InteractableRegistration) => {\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 require all fields.`,\n e,\n );\n }\n\n const detached = detachedStateRef.current.get(def.id);\n detachedStateRef.current.delete(def.id);\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 state:\n prev.definitions[def.id]?.state ?? detached ?? def.initialState,\n selected: def.selected,\n },\n },\n }));\n\n return () => {\n flushIfPending();\n setStateAndRef((prev) => {\n const existing = prev.definitions[def.id];\n if (existing) {\n detachedStateRef.current.set(def.id, existing.state);\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, setStateAndRef],\n );\n\n return {\n getState: () => state,\n register,\n setState: setDefState,\n setSelected: setDefSelected,\n exportState,\n importState,\n setPersistenceAdapter,\n flush,\n };\n};\n\n/**\n * @deprecated Since 2026-06-14 — migrate to the Unstable / Experimental API.\n * Scheduled for removal on/after 2026-09-14. See\n * {@link https://www.assistant-ui.com/docs/tools/interactables#migrating-from-the-previous-api | Interactables migration guide}.\n */\nexport const Interactables = resource(useInteractables);\n\nattachTransformScopes(useInteractables, (scopes, parent) => {\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n});\n"],"mappings":";;;;;;;;;AAoBA,MAAMqB,0BAA0B;AAEhC,MAAMC,yBAAwD;CAC5D,MAAM,CAACC,OAAOC,YAAYxB,gBAAoC;EAC5DyB,aAAa,CAAC;EACdC,aAAa,CAAC;CAChB,EAAE;CAEF,MAAMC,YAAYrB,sBAAsB;CAExC,MAAMsB,WAAWzB,OAAOoB,KAAK;CAE7B,MAAMM,iBAAiB3B,aACpB4B,YAA8D;EAC7D,MAAME,OAAOF,QAAQF,SAASK,OAAO;EACrCL,SAASK,UAAUD;EACnBR,SAASQ,IAAI;CACf,GACA,CAAA,CACF;CAEA,MAAME,iBAAiB/B,uBAAO,IAAIgC,IAAgB,CAAC;CACnD,MAAMC,wBAAwBjC,uBAC5B,IAAIkC,IAAqC,CAC3C;CACA,MAAMC,mBAAmBnC,uBAAO,IAAIkC,IAAqB,CAAC;CAE1D,MAAME,aAAapC,OACjBqC,KAAAA,CACF;CACA,MAAMC,mBAAmBtC,OACvBqC,KAAAA,CACF;CACA,MAAMI,aAAazC,OAAO,CAAC;CAC3B,MAAM0C,uBAAuB1C,uBAAO,IAAIkC,IAAoB,CAAC;CAC7D,MAAMS,yBAAyB3C,OAAO,CAAC;CACvC,MAAM4C,oBAAoB5C,OAA0B,CAAA,CAAE;CACtD,MAAM8C,cAAc9C,uBAAO,IAAIgC,IAAY,CAAC;CAS5C,MAAMoB,mBAAmBpD,OAA2B,CAAA,CAAE;CACtD,MAAMqD,oBAAoBrD,aAClB,CAAC,CACT;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"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useActionBarCopy.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"mappings":";KAIY;EACV;EACA,oBAAoB,wBAAwB;;cAGjC,qBAAoB,gBAAA,oBAG9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { actionBarCopyDisabled } from "../../store/primitive-predicates.js";
|
|
1
2
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
3
|
import { useEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
3
4
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
@@ -13,10 +14,10 @@ const useActionBarCopy = (t0) => {
|
|
|
13
14
|
const { copiedDuration: t2, copyToClipboard } = t1;
|
|
14
15
|
const copiedDuration = t2 === void 0 ? 3e3 : t2;
|
|
15
16
|
const aui = useAui();
|
|
16
|
-
const disabled = useAuiState(
|
|
17
|
-
const isCopied = useAuiState(
|
|
18
|
-
const isEditing = useAuiState(
|
|
19
|
-
const composerValue = useAuiState(
|
|
17
|
+
const disabled = useAuiState(actionBarCopyDisabled);
|
|
18
|
+
const isCopied = useAuiState(_temp);
|
|
19
|
+
const isEditing = useAuiState(_temp2);
|
|
20
|
+
const composerValue = useAuiState(_temp3);
|
|
20
21
|
const copiedTimerRef = useRef(void 0);
|
|
21
22
|
const scopeGenerationRef = useRef(0);
|
|
22
23
|
let t3;
|
|
@@ -53,7 +54,7 @@ const useActionBarCopy = (t0) => {
|
|
|
53
54
|
copiedTimerRef.current = void 0;
|
|
54
55
|
aui.message.setIsCopied(false);
|
|
55
56
|
}, copiedDuration);
|
|
56
|
-
},
|
|
57
|
+
}, _temp4);
|
|
57
58
|
};
|
|
58
59
|
$[5] = aui;
|
|
59
60
|
$[6] = composerValue;
|
|
@@ -78,22 +79,16 @@ const useActionBarCopy = (t0) => {
|
|
|
78
79
|
} else t7 = $[14];
|
|
79
80
|
return t7;
|
|
80
81
|
};
|
|
81
|
-
function _temp(
|
|
82
|
-
return
|
|
82
|
+
function _temp(s) {
|
|
83
|
+
return s.message.isCopied;
|
|
83
84
|
}
|
|
84
|
-
function _temp2(
|
|
85
|
-
return
|
|
85
|
+
function _temp2(s_0) {
|
|
86
|
+
return s_0.composer.isEditing;
|
|
86
87
|
}
|
|
87
|
-
function _temp3(
|
|
88
|
-
return
|
|
88
|
+
function _temp3(s_1) {
|
|
89
|
+
return s_1.composer.text;
|
|
89
90
|
}
|
|
90
|
-
function _temp4(
|
|
91
|
-
return s_1.composer.isEditing;
|
|
92
|
-
}
|
|
93
|
-
function _temp5(s_2) {
|
|
94
|
-
return s_2.composer.text;
|
|
95
|
-
}
|
|
96
|
-
function _temp6() {}
|
|
91
|
+
function _temp4() {}
|
|
97
92
|
//#endregion
|
|
98
93
|
export { useActionBarCopy };
|
|
99
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarCopy.js","names":["useCallback","useEffect","useRef","useAui","useAuiState","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","
|
|
1
|
+
{"version":3,"file":"useActionBarCopy.js","names":["useCallback","useEffect","useRef","useAui","useAuiState","actionBarCopyDisabled","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","isCopied","_temp","isEditing","_temp2","composerValue","_temp3","copiedTimerRef","scopeGenerationRef","t3","t4","current","clearTimeout","message","setIsCopied","t5","valueToCopy","getCopyText","scopeGeneration","resolve","then","setTimeout","_temp4","copy","t6","t7","s","s_0","composer","s_1"],"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { actionBarCopyDisabled } from \"../../store/primitive-predicates\";\n\nexport type UseActionBarCopyOptions = {\n copiedDuration?: number | undefined;\n copyToClipboard?: ((text: string) => void | Promise<void>) | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n copyToClipboard,\n}: UseActionBarCopyOptions = {}) => {\n const aui = useAui();\n const disabled = useAuiState(actionBarCopyDisabled);\n const isCopied = useAuiState((s) => s.message.isCopied);\n const isEditing = useAuiState((s) => s.composer.isEditing);\n const composerValue = useAuiState((s) => s.composer.text);\n const copiedTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const scopeGenerationRef = useRef(0);\n\n useEffect(\n () => () => {\n scopeGenerationRef.current += 1;\n if (copiedTimerRef.current === undefined) return;\n\n clearTimeout(copiedTimerRef.current);\n copiedTimerRef.current = undefined;\n aui.message.setIsCopied(false);\n },\n [aui],\n );\n\n const copy = useCallback(() => {\n if (!copyToClipboard) return;\n\n const valueToCopy = isEditing ? composerValue : aui.message.getCopyText();\n if (!valueToCopy) return;\n const scopeGeneration = scopeGenerationRef.current;\n\n // The rejection handler swallows clipboard write failures (permission denied,\n // API unavailable) so they don't surface as unhandled promise rejections.\n Promise.resolve(copyToClipboard(valueToCopy)).then(\n () => {\n if (scopeGeneration !== scopeGenerationRef.current) return;\n\n if (copiedTimerRef.current !== undefined) {\n clearTimeout(copiedTimerRef.current);\n }\n aui.message.setIsCopied(true);\n copiedTimerRef.current = setTimeout(() => {\n copiedTimerRef.current = undefined;\n aui.message.setIsCopied(false);\n }, copiedDuration);\n },\n () => {},\n );\n }, [aui, isEditing, composerValue, copiedDuration, copyToClipboard]);\n\n return { copy, disabled: disabled || !copyToClipboard, isCopied };\n};\n"],"mappings":";;;;;AASA,MAAaW,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAACG,KAAAH,OAAAI,KAAAA,IAAA,CAGH,IAHGJ;EAGFC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAA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KAAAA,GAC7Be,aAAaL,eAAcI,OAAQ;IAErCZ,IAAGc,QAAQC,YAAa,IAAI;IAC5BP,eAAcI,UAAWU,iBAAW;KAClCd,eAAcI,UAAWd,KAAAA;KACzBE,IAAGc,QAAQC,YAAa,KAAK;IAAC,GAC7B1B,cAAc;GAHK,GAKxBkC,MACF;EAAC;EACF5B,EAAA,KAAAK;EAAAL,EAAA,KAAAW;EAAAX,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAS;EAAAT,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAxBD,MAAA6B,OAAaR;CA0BY,MAAAS,KAAAxB,YAAA,CAAaX;CAAe,IAAAoC;CAAA,IAAA/B,EAAA,QAAA6B,QAAA7B,EAAA,QAAAO,YAAAP,EAAA,QAAA8B,IAAA;EAA9CC,KAAA;GAAAF;GAAAvB,UAAkBwB;GAA4BvB;EAAW;EAACP,EAAA,MAAA6B;EAAA7B,EAAA,MAAAO;EAAAP,EAAA,MAAA8B;EAAA9B,EAAA,MAAA+B;CAAA,OAAAA,KAAA/B,EAAA;CAAA,OAA1D+B;AAA0D;AApDnC,SAAAvB,MAAAwB,GAAA;CAAA,OAMMA,EAACb,QAAQZ;AAAS;AANxB,SAAAG,OAAAuB,KAAA;CAAA,OAOOD,IAACE,SAASzB;AAAU;AAP3B,SAAAG,OAAAuB,KAAA;CAAA,OAQWH,IAACE,SAAStC;AAAK;AAR1B,SAAAgC,SAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarEdit.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useActionBarEdit.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useActionBarEdit.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useActionBarEdit.ts"],"mappings":";cAIa;EAAA;EAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { actionBarEditDisabled } from "../../store/primitive-predicates.js";
|
|
1
2
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
3
|
import "@assistant-ui/tap/react-shim";
|
|
3
4
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
@@ -5,7 +6,7 @@ import { useAui, useAuiState } from "@assistant-ui/store";
|
|
|
5
6
|
const useActionBarEdit = () => {
|
|
6
7
|
const $ = c(5);
|
|
7
8
|
const aui = useAui();
|
|
8
|
-
const disabled = useAuiState(
|
|
9
|
+
const disabled = useAuiState(actionBarEditDisabled);
|
|
9
10
|
let t0;
|
|
10
11
|
if ($[0] !== aui) {
|
|
11
12
|
t0 = () => {
|
|
@@ -27,9 +28,6 @@ const useActionBarEdit = () => {
|
|
|
27
28
|
} else t1 = $[4];
|
|
28
29
|
return t1;
|
|
29
30
|
};
|
|
30
|
-
function _temp(s) {
|
|
31
|
-
return s.composer.isEditing;
|
|
32
|
-
}
|
|
33
31
|
//#endregion
|
|
34
32
|
export { useActionBarEdit };
|
|
35
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarEdit.js","names":["useCallback","useAui","useAuiState","useActionBarEdit","$","_c","aui","disabled","
|
|
1
|
+
{"version":3,"file":"useActionBarEdit.js","names":["useCallback","useAui","useAuiState","actionBarEditDisabled","useActionBarEdit","$","_c","aui","disabled","t0","composer","beginEdit","edit","t1"],"sources":["../../../src/react/primitive-hooks/useActionBarEdit.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { actionBarEditDisabled } from \"../../store/primitive-predicates\";\n\nexport const useActionBarEdit = () => {\n const aui = useAui();\n const disabled = useAuiState(actionBarEditDisabled);\n\n const edit = useCallback(() => {\n aui.composer.beginEdit();\n }, [aui]);\n\n return { edit, disabled };\n};\n"],"mappings":";;;;;AAIA,MAAaI,yBAAmB;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAC9B,MAAAC,MAAYN,OAAO;CACnB,MAAAO,WAAiBN,YAAYC,qBAAqB;CAAE,IAAAM;CAAA,IAAAJ,EAAA,OAAAE,KAAA;EAE3BE,WAAA;GACvBF,IAAGG,SAASC,UAAW;EAAC;EACzBN,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAFD,MAAAO,OAAaH;CAEH,IAAAI;CAAA,IAAAR,EAAA,OAAAG,YAAAH,EAAA,OAAAO,MAAA;EAEHC,KAAA;GAAAD;GAAAJ;EAAiB;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAAlBQ;AAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarReload.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useActionBarReload.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useActionBarReload.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useActionBarReload.ts"],"mappings":";cAIa;EAAA;EAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { actionBarReloadDisabled } from "../../store/primitive-predicates.js";
|
|
1
2
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
3
|
import "@assistant-ui/tap/react-shim";
|
|
3
4
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
@@ -5,7 +6,7 @@ import { useAui, useAuiState } from "@assistant-ui/store";
|
|
|
5
6
|
const useActionBarReload = () => {
|
|
6
7
|
const $ = c(5);
|
|
7
8
|
const aui = useAui();
|
|
8
|
-
const disabled = useAuiState(
|
|
9
|
+
const disabled = useAuiState(actionBarReloadDisabled);
|
|
9
10
|
let t0;
|
|
10
11
|
if ($[0] !== aui) {
|
|
11
12
|
t0 = () => {
|
|
@@ -27,9 +28,6 @@ const useActionBarReload = () => {
|
|
|
27
28
|
} else t1 = $[4];
|
|
28
29
|
return t1;
|
|
29
30
|
};
|
|
30
|
-
function _temp(s) {
|
|
31
|
-
return s.thread.isRunning || s.thread.isDisabled || s.message.role !== "assistant";
|
|
32
|
-
}
|
|
33
31
|
//#endregion
|
|
34
32
|
export { useActionBarReload };
|
|
35
33
|
|