@assistant-ui/core 0.1.0 → 0.1.1
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/LICENSE +21 -0
- package/dist/adapters/attachment.js +1 -1
- package/dist/adapters/attachment.js.map +1 -1
- package/dist/react/AssistantProvider.d.ts +10 -0
- package/dist/react/AssistantProvider.d.ts.map +1 -0
- package/dist/react/AssistantProvider.js +13 -0
- package/dist/react/AssistantProvider.js.map +1 -0
- package/dist/react/RuntimeAdapter.d.ts +3 -0
- package/dist/react/RuntimeAdapter.d.ts.map +1 -0
- package/dist/react/RuntimeAdapter.js +13 -0
- package/dist/react/RuntimeAdapter.js.map +1 -0
- package/dist/react/client/DataRenderers.d.ts +3 -0
- package/dist/react/client/DataRenderers.d.ts.map +1 -0
- package/dist/react/client/DataRenderers.js +33 -0
- package/dist/react/client/DataRenderers.js.map +1 -0
- package/dist/react/client/Tools.d.ts +8 -0
- package/dist/react/client/Tools.d.ts.map +1 -0
- package/dist/react/client/Tools.js +68 -0
- package/dist/react/client/Tools.js.map +1 -0
- package/dist/react/client/index.d.ts +3 -0
- package/dist/react/client/index.d.ts.map +1 -0
- package/dist/react/client/index.js +3 -0
- package/dist/react/client/index.js.map +1 -0
- package/dist/react/index.d.ts +17 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +19 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/model-context/index.d.ts +12 -0
- package/dist/react/model-context/index.d.ts.map +1 -0
- package/dist/react/model-context/index.js +11 -0
- package/dist/react/model-context/index.js.map +1 -0
- package/dist/react/model-context/makeAssistantDataUI.d.ts +7 -0
- package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantDataUI.js +10 -0
- package/dist/react/model-context/makeAssistantDataUI.js.map +1 -0
- package/dist/react/model-context/makeAssistantTool.d.ts +7 -0
- package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantTool.js +10 -0
- package/dist/react/model-context/makeAssistantTool.js.map +1 -0
- package/dist/react/model-context/makeAssistantToolUI.d.ts +7 -0
- package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -0
- package/dist/react/model-context/makeAssistantToolUI.js +10 -0
- package/dist/react/model-context/makeAssistantToolUI.js.map +1 -0
- package/dist/react/model-context/toolbox.d.ts +10 -0
- package/dist/react/model-context/toolbox.d.ts.map +1 -0
- package/dist/react/model-context/toolbox.js +2 -0
- package/dist/react/model-context/toolbox.js.map +1 -0
- package/dist/react/model-context/useAssistantDataUI.d.ts +7 -0
- package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantDataUI.js +11 -0
- package/dist/react/model-context/useAssistantDataUI.js.map +1 -0
- package/dist/react/model-context/useAssistantInstructions.d.ts +4 -0
- package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantInstructions.js +22 -0
- package/dist/react/model-context/useAssistantInstructions.js.map +1 -0
- package/dist/react/model-context/useAssistantTool.d.ts +7 -0
- package/dist/react/model-context/useAssistantTool.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantTool.js +22 -0
- package/dist/react/model-context/useAssistantTool.js.map +1 -0
- package/dist/react/model-context/useAssistantToolUI.d.ts +7 -0
- package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -0
- package/dist/react/model-context/useAssistantToolUI.js +11 -0
- package/dist/react/model-context/useAssistantToolUI.js.map +1 -0
- package/dist/react/model-context/useInlineRender.d.ts +4 -0
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -0
- package/dist/react/model-context/useInlineRender.js +15 -0
- package/dist/react/model-context/useInlineRender.js.map +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +27 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -0
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +23 -0
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -0
- package/dist/react/primitives/composer/ComposerAttachments.js +47 -0
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -0
- package/dist/react/primitives/composer/ComposerIf.d.ts +20 -0
- package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -0
- package/dist/react/primitives/composer/ComposerIf.js +24 -0
- package/dist/react/primitives/composer/ComposerIf.js.map +1 -0
- package/dist/react/primitives/message/MessageAttachments.d.ts +23 -0
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -0
- package/dist/react/primitives/message/MessageAttachments.js +51 -0
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -0
- package/dist/react/primitives/message/MessageParts.d.ts +139 -0
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -0
- package/dist/react/primitives/message/MessageParts.js +251 -0
- package/dist/react/primitives/message/MessageParts.js.map +1 -0
- package/dist/react/primitives/thread/ThreadMessages.d.ts +95 -0
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -0
- package/dist/react/primitives/thread/ThreadMessages.js +112 -0
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -0
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +28 -0
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -0
- package/dist/react/primitives/thread/ThreadSuggestions.js +32 -0
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -0
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +22 -0
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -0
- package/dist/react/primitives/threadList/ThreadListItems.js +23 -0
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +8 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +8 -0
- package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -0
- package/dist/react/providers/AttachmentByIndexProvider.d.ts +8 -0
- package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/AttachmentByIndexProvider.js +23 -0
- package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +6 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +20 -0
- package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +5 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +13 -0
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -0
- package/dist/react/providers/MessageByIndexProvider.d.ts +5 -0
- package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/MessageByIndexProvider.js +18 -0
- package/dist/react/providers/MessageByIndexProvider.js.map +1 -0
- package/dist/react/providers/PartByIndexProvider.d.ts +5 -0
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/PartByIndexProvider.js +13 -0
- package/dist/react/providers/PartByIndexProvider.js.map +1 -0
- package/dist/react/providers/SuggestionByIndexProvider.d.ts +6 -0
- package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/SuggestionByIndexProvider.js +13 -0
- package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -0
- package/dist/react/providers/TextMessagePartProvider.d.ts +6 -0
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -0
- package/dist/react/providers/TextMessagePartProvider.js +26 -0
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +6 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.js +13 -0
- package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +6 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.js +10 -0
- package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -0
- package/dist/react/providers/index.d.ts +10 -0
- package/dist/react/providers/index.d.ts.map +1 -0
- package/dist/react/providers/index.js +10 -0
- package/dist/react/providers/index.js.map +1 -0
- package/dist/react/types/MessagePartComponentTypes.d.ts +33 -0
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -0
- package/dist/react/types/MessagePartComponentTypes.js +2 -0
- package/dist/react/types/MessagePartComponentTypes.js.map +1 -0
- package/dist/react/types/index.d.ts +3 -0
- package/dist/react/types/index.d.ts.map +1 -0
- package/dist/react/types/index.js +2 -0
- package/dist/react/types/index.js.map +1 -0
- package/dist/react/types/scopes/dataRenderers.d.ts +13 -0
- package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -0
- package/dist/react/types/scopes/dataRenderers.js +2 -0
- package/dist/react/types/scopes/dataRenderers.js.map +1 -0
- package/dist/react/types/scopes/index.d.ts +3 -0
- package/dist/react/types/scopes/index.d.ts.map +1 -0
- package/dist/react/types/scopes/index.js +2 -0
- package/dist/react/types/scopes/index.js.map +1 -0
- package/dist/react/types/scopes/tools.d.ts +13 -0
- package/dist/react/types/scopes/tools.d.ts.map +1 -0
- package/dist/react/types/scopes/tools.js +2 -0
- package/dist/react/types/scopes/tools.js.map +1 -0
- package/dist/react/types/store-augmentation.d.ts +10 -0
- package/dist/react/types/store-augmentation.d.ts.map +1 -0
- package/dist/react/types/store-augmentation.js +2 -0
- package/dist/react/types/store-augmentation.js.map +1 -0
- package/dist/runtime/api/attachment-runtime.d.ts +2 -2
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +8 -6
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +2 -2
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +27 -2
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +28 -8
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +0 -3
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +3 -5
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +8 -0
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.js +12 -0
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +10 -3
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +20 -5
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +26 -8
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.d.ts +1 -1
- package/dist/store/clients/model-context-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts +5 -0
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -0
- package/dist/store/clients/runtime-adapter.js +46 -0
- package/dist/store/clients/runtime-adapter.js.map +1 -0
- package/dist/store/clients/suggestions.d.ts +1 -1
- package/dist/store/clients/suggestions.d.ts.map +1 -1
- package/dist/store/clients/suggestions.js +1 -1
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +1 -1
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/index.d.ts +1 -11
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +2 -9
- package/dist/store/index.js.map +1 -1
- package/dist/store/internal.d.ts +1 -9
- package/dist/store/internal.d.ts.map +1 -1
- package/dist/store/internal.js +1 -10
- package/dist/store/internal.js.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -1
- 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 +1 -1
- 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 +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 +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scope-registration.d.ts +27 -0
- package/dist/store/scope-registration.d.ts.map +1 -0
- package/dist/store/scope-registration.js +2 -0
- package/dist/store/scope-registration.js.map +1 -0
- package/dist/store/scopes/composer.d.ts +2 -2
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/types/attachment.d.ts +9 -2
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +35 -12
- package/src/adapters/attachment.ts +1 -1
- package/src/react/AssistantProvider.tsx +34 -0
- package/src/react/RuntimeAdapter.ts +22 -0
- package/src/react/client/DataRenderers.ts +42 -0
- package/src/react/client/Tools.ts +97 -0
- package/src/react/client/index.ts +2 -0
- package/src/react/index.ts +50 -0
- package/src/react/model-context/index.ts +25 -0
- package/src/react/model-context/makeAssistantDataUI.ts +20 -0
- package/src/react/model-context/makeAssistantTool.ts +20 -0
- package/src/react/model-context/makeAssistantToolUI.ts +20 -0
- package/src/react/model-context/toolbox.ts +15 -0
- package/src/react/model-context/useAssistantDataUI.ts +16 -0
- package/src/react/model-context/useAssistantInstructions.ts +30 -0
- package/src/react/model-context/useAssistantTool.ts +37 -0
- package/src/react/model-context/useAssistantToolUI.ts +18 -0
- package/src/react/model-context/useInlineRender.ts +25 -0
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +73 -0
- package/src/react/primitives/composer/ComposerAttachments.tsx +95 -0
- package/src/react/primitives/composer/ComposerIf.tsx +49 -0
- package/src/react/primitives/message/MessageAttachments.tsx +98 -0
- package/src/react/primitives/message/MessageParts.tsx +561 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +222 -0
- package/src/react/primitives/thread/ThreadSuggestions.tsx +82 -0
- package/src/react/primitives/threadList/ThreadListItems.tsx +66 -0
- package/src/react/primitives/threadListItem/ThreadListItemTitle.tsx +17 -0
- package/src/react/providers/AttachmentByIndexProvider.tsx +34 -0
- package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +34 -0
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +18 -0
- package/src/react/providers/MessageByIndexProvider.tsx +23 -0
- package/src/react/providers/PartByIndexProvider.tsx +18 -0
- package/src/react/providers/SuggestionByIndexProvider.tsx +21 -0
- package/src/react/providers/TextMessagePartProvider.tsx +46 -0
- package/src/react/providers/ThreadListItemByIndexProvider.tsx +19 -0
- package/src/react/providers/ThreadListItemRuntimeProvider.tsx +16 -0
- package/src/react/providers/index.ts +15 -0
- package/src/react/types/MessagePartComponentTypes.ts +66 -0
- package/src/react/types/index.ts +31 -0
- package/src/react/types/scopes/dataRenderers.ts +15 -0
- package/src/react/types/scopes/index.ts +6 -0
- package/src/react/types/scopes/tools.ts +18 -0
- package/src/react/types/store-augmentation.ts +11 -0
- package/src/runtime/api/attachment-runtime.ts +2 -7
- package/src/runtime/api/composer-runtime.ts +9 -8
- package/src/runtime/base/base-composer-runtime-core.ts +28 -8
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -5
- package/src/runtime/index.ts +1 -0
- package/src/runtime/interfaces/composer-runtime-core.ts +3 -6
- package/src/runtime/utils/external-store-message.ts +15 -0
- package/src/runtime/utils/thread-message-like.ts +40 -7
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +29 -12
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -1
- package/src/store/clients/chain-of-thought-client.ts +1 -1
- package/src/store/clients/model-context-client.ts +1 -1
- package/src/store/clients/no-op-composer-client.ts +1 -1
- package/src/store/clients/runtime-adapter.ts +67 -0
- package/src/store/clients/suggestions.ts +2 -2
- package/src/store/clients/thread-message-client.ts +2 -2
- package/src/store/index.ts +2 -38
- package/src/store/internal.ts +4 -31
- package/src/store/runtime-clients/attachment-runtime-client.ts +1 -1
- package/src/store/runtime-clients/composer-runtime-client.ts +5 -1
- package/src/store/runtime-clients/message-part-runtime-client.ts +1 -1
- package/src/store/runtime-clients/message-runtime-client.ts +5 -1
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +1 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +5 -1
- package/src/store/runtime-clients/thread-runtime-client.ts +1 -1
- package/src/store/scope-registration.ts +27 -0
- package/src/store/scopes/composer.ts +2 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +152 -0
- package/src/tests/thread-message-like.test.ts +110 -0
- package/src/types/attachment.ts +10 -2
- package/src/types/index.ts +1 -0
- package/dist/store/types/client.d.ts +0 -137
- package/dist/store/types/client.d.ts.map +0 -1
- package/dist/store/types/client.js +0 -2
- package/dist/store/types/client.js.map +0 -1
- package/dist/store/types/events.d.ts +0 -33
- package/dist/store/types/events.d.ts.map +0 -1
- package/dist/store/types/events.js +0 -8
- package/dist/store/types/events.js.map +0 -1
- package/dist/store/types/index.d.ts +0 -3
- package/dist/store/types/index.d.ts.map +0 -1
- package/dist/store/types/index.js +0 -2
- package/dist/store/types/index.js.map +0 -1
- package/dist/store/utils/attach-transform-scopes.d.ts +0 -11
- package/dist/store/utils/attach-transform-scopes.d.ts.map +0 -1
- package/dist/store/utils/attach-transform-scopes.js +0 -12
- package/dist/store/utils/attach-transform-scopes.js.map +0 -1
- package/dist/store/utils/base-proxy-handler.d.ts +0 -23
- package/dist/store/utils/base-proxy-handler.d.ts.map +0 -1
- package/dist/store/utils/base-proxy-handler.js +0 -46
- package/dist/store/utils/base-proxy-handler.js.map +0 -1
- package/dist/store/utils/derived.d.ts +0 -34
- package/dist/store/utils/derived.d.ts.map +0 -1
- package/dist/store/utils/derived.js +0 -24
- package/dist/store/utils/derived.js.map +0 -1
- package/dist/store/utils/index.d.ts +0 -7
- package/dist/store/utils/index.d.ts.map +0 -1
- package/dist/store/utils/index.js +0 -7
- package/dist/store/utils/index.js.map +0 -1
- package/dist/store/utils/notification-manager.d.ts +0 -11
- package/dist/store/utils/notification-manager.d.ts.map +0 -1
- package/dist/store/utils/notification-manager.js +0 -84
- package/dist/store/utils/notification-manager.js.map +0 -1
- package/dist/store/utils/proxied-assistant-state.d.ts +0 -8
- package/dist/store/utils/proxied-assistant-state.d.ts.map +0 -1
- package/dist/store/utils/proxied-assistant-state.js +0 -33
- package/dist/store/utils/proxied-assistant-state.js.map +0 -1
- package/dist/store/utils/split-clients.d.ts +0 -10
- package/dist/store/utils/split-clients.d.ts.map +0 -1
- package/dist/store/utils/split-clients.js +0 -53
- package/dist/store/utils/split-clients.js.map +0 -1
- package/dist/store/utils/tap-assistant-context.d.ts +0 -19
- package/dist/store/utils/tap-assistant-context.d.ts.map +0 -1
- package/dist/store/utils/tap-assistant-context.js +0 -23
- package/dist/store/utils/tap-assistant-context.js.map +0 -1
- package/dist/store/utils/tap-client-list.d.ts +0 -28
- package/dist/store/utils/tap-client-list.d.ts.map +0 -1
- package/dist/store/utils/tap-client-list.js +0 -68
- package/dist/store/utils/tap-client-list.js.map +0 -1
- package/dist/store/utils/tap-client-lookup.d.ts +0 -15
- package/dist/store/utils/tap-client-lookup.d.ts.map +0 -1
- package/dist/store/utils/tap-client-lookup.js +0 -42
- package/dist/store/utils/tap-client-lookup.js.map +0 -1
- package/dist/store/utils/tap-client-resource.d.ts +0 -13
- package/dist/store/utils/tap-client-resource.d.ts.map +0 -1
- package/dist/store/utils/tap-client-resource.js +0 -114
- package/dist/store/utils/tap-client-resource.js.map +0 -1
- package/dist/store/utils/tap-client-stack-context.d.ts +0 -23
- package/dist/store/utils/tap-client-stack-context.d.ts.map +0 -1
- package/dist/store/utils/tap-client-stack-context.js +0 -28
- package/dist/store/utils/tap-client-stack-context.js.map +0 -1
- package/dist/store/utils/wrapper-resource.d.ts +0 -3
- package/dist/store/utils/wrapper-resource.d.ts.map +0 -1
- package/dist/store/utils/wrapper-resource.js +0 -11
- package/dist/store/utils/wrapper-resource.js.map +0 -1
- package/src/store/types/client.ts +0 -203
- package/src/store/types/events.ts +0 -77
- package/src/store/types/index.ts +0 -23
- package/src/store/utils/attach-transform-scopes.ts +0 -38
- package/src/store/utils/base-proxy-handler.ts +0 -50
- package/src/store/utils/derived.ts +0 -46
- package/src/store/utils/index.ts +0 -28
- package/src/store/utils/notification-manager.ts +0 -114
- package/src/store/utils/proxied-assistant-state.ts +0 -55
- package/src/store/utils/split-clients.ts +0 -82
- package/src/store/utils/tap-assistant-context.ts +0 -58
- package/src/store/utils/tap-client-list.ts +0 -121
- package/src/store/utils/tap-client-lookup.ts +0 -79
- package/src/store/utils/tap-client-resource.ts +0 -187
- package/src/store/utils/tap-client-stack-context.ts +0 -51
- package/src/store/utils/wrapper-resource.ts +0 -17
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { tapConst, tapState, withKey } from "@assistant-ui/tap";
|
|
2
|
-
import { tapClientLookup } from "./tap-client-lookup.js";
|
|
3
|
-
const createProps = (key, data, remove) => {
|
|
4
|
-
return {
|
|
5
|
-
key,
|
|
6
|
-
getInitialData: () => {
|
|
7
|
-
if (!data.hasData) {
|
|
8
|
-
throw new Error("getInitialData may only be called during initial render");
|
|
9
|
-
}
|
|
10
|
-
return data.data;
|
|
11
|
-
},
|
|
12
|
-
remove,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export const tapClientList = (props) => {
|
|
16
|
-
const { initialValues, getKey, resource: Resource } = props;
|
|
17
|
-
const initialDataHandles = tapConst(() => [], []);
|
|
18
|
-
const [items, setItems] = tapState(() => {
|
|
19
|
-
const entries = [];
|
|
20
|
-
for (const data of initialValues) {
|
|
21
|
-
const key = getKey(data);
|
|
22
|
-
const handle = { data, hasData: true };
|
|
23
|
-
entries.push([
|
|
24
|
-
key,
|
|
25
|
-
createProps(key, handle, () => {
|
|
26
|
-
setItems((items) => {
|
|
27
|
-
const newItems = { ...items };
|
|
28
|
-
delete newItems[key];
|
|
29
|
-
return newItems;
|
|
30
|
-
});
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
33
|
-
initialDataHandles.push(handle);
|
|
34
|
-
}
|
|
35
|
-
return Object.fromEntries(entries);
|
|
36
|
-
});
|
|
37
|
-
const lookup = tapClientLookup(() => Object.values(items).map((props) => withKey(props.key, Resource(props))), [items, Resource]);
|
|
38
|
-
initialDataHandles.forEach((handle) => {
|
|
39
|
-
handle.data = undefined;
|
|
40
|
-
handle.hasData = false;
|
|
41
|
-
});
|
|
42
|
-
const add = (data) => {
|
|
43
|
-
const key = getKey(data);
|
|
44
|
-
setItems((items) => {
|
|
45
|
-
if (key in items) {
|
|
46
|
-
throw new Error(`Tried to add item with a key ${key} that already exists`);
|
|
47
|
-
}
|
|
48
|
-
const handle = { data, hasData: true };
|
|
49
|
-
initialDataHandles.push(handle);
|
|
50
|
-
return {
|
|
51
|
-
...items,
|
|
52
|
-
[key]: createProps(key, handle, () => {
|
|
53
|
-
setItems((items) => {
|
|
54
|
-
const newItems = { ...items };
|
|
55
|
-
delete newItems[key];
|
|
56
|
-
return newItems;
|
|
57
|
-
});
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
state: lookup.state,
|
|
64
|
-
get: lookup.get,
|
|
65
|
-
add,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=tap-client-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-list.js","sourceRoot":"","sources":["../../../src/store/utils/tap-client-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,+BAA4B;AAWtD,MAAM,WAAW,GAAG,CAClB,GAAW,EACX,IAAuB,EACvB,MAAkB,EACkB,EAAE;IACtC,OAAO;QACL,GAAG;QACH,cAAc,EAAE,GAAG,EAAE;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,IAAK,CAAC;QACpB,CAAC;QACD,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAA2C,EAK3C,EAAE;IACF,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAI5D,MAAM,kBAAkB,GAAwB,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAEvE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwB,GAAG,EAAE;QAC7D,MAAM,OAAO,GAAsB,EAAE,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YACzB,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,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E,CAAC;YACvC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEhC,OAAO;gBACL,GAAG,KAAK;gBACR,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;oBACnC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;wBACjB,MAAM,QAAQ,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;wBAC9B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;wBACrB,OAAO,QAAQ,CAAC;oBAClB,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC;aACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ResourceElement } from "@assistant-ui/tap";
|
|
2
|
-
import type { ClientMethods } from "../types/client.js";
|
|
3
|
-
type InferClientState<TMethods> = TMethods extends {
|
|
4
|
-
getState: () => infer S;
|
|
5
|
-
} ? S : unknown;
|
|
6
|
-
export declare function tapClientLookup<TMethods extends ClientMethods>(getElements: () => readonly ResourceElement<TMethods>[], getElementsDeps: readonly unknown[]): {
|
|
7
|
-
state: InferClientState<TMethods>[];
|
|
8
|
-
get: (lookup: {
|
|
9
|
-
index: number;
|
|
10
|
-
} | {
|
|
11
|
-
key: string;
|
|
12
|
-
}) => TMethods;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=tap-client-lookup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-lookup.d.ts","sourceRoot":"","sources":["../../../src/store/utils/tap-client-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,2BAAwB;AAIrD,KAAK,gBAAgB,CAAC,QAAQ,IAAI,QAAQ,SAAS;IACjD,QAAQ,EAAE,MAAM,MAAM,CAAC,CAAC;CACzB,GACG,CAAC,GACD,OAAO,CAAC;AAeZ,wBAAgB,eAAe,CAAC,QAAQ,SAAS,aAAa,EAC5D,WAAW,EAAE,MAAM,SAAS,eAAe,CAAC,QAAQ,CAAC,EAAE,EACvD,eAAe,EAAE,SAAS,OAAO,EAAE,GAClC;IACD,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpC,GAAG,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,QAAQ,CAAC;CAChE,CA2CA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { tapMemo, tapResource, tapResources, } from "@assistant-ui/tap";
|
|
2
|
-
import { ClientResource } from "./tap-client-resource.js";
|
|
3
|
-
import { wrapperResource } from "./wrapper-resource.js";
|
|
4
|
-
const ClientResourceWithKey = wrapperResource((el) => {
|
|
5
|
-
if (el.key === undefined) {
|
|
6
|
-
throw new Error("tapClientResource: Element has no key");
|
|
7
|
-
}
|
|
8
|
-
return tapResource(ClientResource(el));
|
|
9
|
-
});
|
|
10
|
-
export function tapClientLookup(getElements, getElementsDeps) {
|
|
11
|
-
const resources = tapResources(() => getElements().map((el) => ClientResourceWithKey(el)),
|
|
12
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: getElementsDeps is passed through from caller
|
|
13
|
-
getElementsDeps);
|
|
14
|
-
const keys = tapMemo(() => Object.keys(resources), [resources]);
|
|
15
|
-
// For arrays, track element key -> index mapping
|
|
16
|
-
const keyToIndex = tapMemo(() => {
|
|
17
|
-
return resources.reduce((acc, resource, index) => {
|
|
18
|
-
acc[resource.key] = index;
|
|
19
|
-
return acc;
|
|
20
|
-
}, {});
|
|
21
|
-
}, [resources]);
|
|
22
|
-
const state = tapMemo(() => {
|
|
23
|
-
return resources.map((r) => r.state);
|
|
24
|
-
}, [resources]);
|
|
25
|
-
return {
|
|
26
|
-
state,
|
|
27
|
-
get: (lookup) => {
|
|
28
|
-
if ("index" in lookup) {
|
|
29
|
-
if (lookup.index < 0 || lookup.index >= keys.length) {
|
|
30
|
-
throw new Error(`tapClientLookup: Index ${lookup.index} out of bounds (length: ${keys.length})`);
|
|
31
|
-
}
|
|
32
|
-
return resources[lookup.index].methods;
|
|
33
|
-
}
|
|
34
|
-
const index = keyToIndex[lookup.key];
|
|
35
|
-
if (index === undefined) {
|
|
36
|
-
throw new Error(`tapClientLookup: Key "${lookup.key}" not found`);
|
|
37
|
-
}
|
|
38
|
-
return resources[index].methods;
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=tap-client-lookup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-lookup.js","sourceRoot":"","sources":["../../../src/store/utils/tap-client-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EACX,YAAY,GAEb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,iCAA8B;AACvD,OAAO,EAAE,eAAe,EAAE,8BAA2B;AAQrD,MAAM,qBAAqB,GAAG,eAAe,CAC3C,CAAiC,EAA6B,EAAE,EAAE;IAChE,IAAI,EAAE,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC,CAIpC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,WAAuD,EACvD,eAAmC;IAKnC,MAAM,SAAS,GAAG,YAAY,CAC5B,GAAG,EAAE,CAAC,WAAW,EA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AC;YACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC;YACpE,CAAC;YACD,OAAO,SAAS,CAAC,KAAK,CAAE,CAAC,OAAO,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type ResourceElement } from "@assistant-ui/tap";
|
|
2
|
-
import type { ClientMethods } from "../types/client.js";
|
|
3
|
-
export declare const getClientState: (client: ClientMethods) => any;
|
|
4
|
-
type InferClientState<TMethods> = TMethods extends {
|
|
5
|
-
getState: () => infer S;
|
|
6
|
-
} ? S : undefined;
|
|
7
|
-
export declare const tapClientResource: <TMethods extends ClientMethods>(element: ResourceElement<TMethods>) => {
|
|
8
|
-
state: InferClientState<TMethods>;
|
|
9
|
-
methods: TMethods;
|
|
10
|
-
key: string | number | undefined;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=tap-client-resource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-resource.d.ts","sourceRoot":"","sources":["../../../src/store/utils/tap-client-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,2BAAwB;AAsBrD,eAAO,MAAM,cAAc,GAAI,QAAQ,aAAa,QASnD,CAAC;AAkIF,KAAK,gBAAgB,CAAC,QAAQ,IAAI,QAAQ,SAAS;IACjD,QAAQ,EAAE,MAAM,MAAM,CAAC,CAAC;CACzB,GACG,CAAC,GACD,SAAS,CAAC;AAEd,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,aAAa,EAC9D,SAAS,eAAe,CAAC,QAAQ,CAAC,KACjC;IACD,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,EAAE,QAAQ,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAOlC,CAAC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { tapEffect, tapMemo, tapRef, tapResource, } from "@assistant-ui/tap";
|
|
2
|
-
import { tapClientStack, tapWithClientStack, SYMBOL_CLIENT_INDEX, } from "./tap-client-stack-context.js";
|
|
3
|
-
import { BaseProxyHandler, handleIntrospectionProp, } from "./base-proxy-handler.js";
|
|
4
|
-
import { wrapperResource } from "./wrapper-resource.js";
|
|
5
|
-
/**
|
|
6
|
-
* Symbol used internally to get state from ClientProxy.
|
|
7
|
-
* This allows getState() to be optional in the user-facing client.
|
|
8
|
-
*/
|
|
9
|
-
const SYMBOL_GET_OUTPUT = Symbol("assistant-ui.store.getValue");
|
|
10
|
-
export const getClientState = (client) => {
|
|
11
|
-
const output = client[SYMBOL_GET_OUTPUT];
|
|
12
|
-
if (!output) {
|
|
13
|
-
throw new Error("Client scope contains a non-client resource. " +
|
|
14
|
-
"Ensure your Derived get() returns a client created with tapClientResource(), not a plain resource.");
|
|
15
|
-
}
|
|
16
|
-
return output.getState?.();
|
|
17
|
-
};
|
|
18
|
-
// Global cache for function templates by field name
|
|
19
|
-
const fieldAccessFns = new Map();
|
|
20
|
-
function getOrCreateProxyFn(prop) {
|
|
21
|
-
let template = fieldAccessFns.get(prop);
|
|
22
|
-
if (!template) {
|
|
23
|
-
template = function (...args) {
|
|
24
|
-
if (!this || typeof this !== "object") {
|
|
25
|
-
throw new Error(`Method "${String(prop)}" called without proper context. ` +
|
|
26
|
-
`This may indicate the function was called incorrectly.`);
|
|
27
|
-
}
|
|
28
|
-
const output = this[SYMBOL_GET_OUTPUT];
|
|
29
|
-
if (!output) {
|
|
30
|
-
throw new Error(`Method "${String(prop)}" called on invalid client proxy. ` +
|
|
31
|
-
`Ensure you are calling this method on a valid client instance.`);
|
|
32
|
-
}
|
|
33
|
-
const method = output[prop];
|
|
34
|
-
if (!method)
|
|
35
|
-
throw new Error(`Method "${String(prop)}" is not implemented.`);
|
|
36
|
-
if (typeof method !== "function")
|
|
37
|
-
throw new Error(`"${String(prop)}" is not a function.`);
|
|
38
|
-
return method(...args);
|
|
39
|
-
};
|
|
40
|
-
fieldAccessFns.set(prop, template);
|
|
41
|
-
}
|
|
42
|
-
return template;
|
|
43
|
-
}
|
|
44
|
-
class ClientProxyHandler extends BaseProxyHandler {
|
|
45
|
-
outputRef;
|
|
46
|
-
index;
|
|
47
|
-
boundFns;
|
|
48
|
-
cachedReceiver;
|
|
49
|
-
constructor(outputRef, index) {
|
|
50
|
-
super();
|
|
51
|
-
this.outputRef = outputRef;
|
|
52
|
-
this.index = index;
|
|
53
|
-
}
|
|
54
|
-
get(_, prop, receiver) {
|
|
55
|
-
if (prop === SYMBOL_GET_OUTPUT)
|
|
56
|
-
return this.outputRef.current;
|
|
57
|
-
if (prop === SYMBOL_CLIENT_INDEX)
|
|
58
|
-
return this.index;
|
|
59
|
-
const introspection = handleIntrospectionProp(prop, "ClientProxy");
|
|
60
|
-
if (introspection !== false)
|
|
61
|
-
return introspection;
|
|
62
|
-
const value = this.outputRef.current[prop];
|
|
63
|
-
if (typeof value === "function") {
|
|
64
|
-
if (this.cachedReceiver !== receiver) {
|
|
65
|
-
this.boundFns = new Map();
|
|
66
|
-
this.cachedReceiver = receiver;
|
|
67
|
-
}
|
|
68
|
-
let bound = this.boundFns.get(prop);
|
|
69
|
-
if (!bound) {
|
|
70
|
-
bound = getOrCreateProxyFn(prop).bind(receiver);
|
|
71
|
-
this.boundFns.set(prop, bound);
|
|
72
|
-
}
|
|
73
|
-
return bound;
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
ownKeys() {
|
|
78
|
-
return Object.keys(this.outputRef.current);
|
|
79
|
-
}
|
|
80
|
-
has(_, prop) {
|
|
81
|
-
if (prop === SYMBOL_GET_OUTPUT)
|
|
82
|
-
return true;
|
|
83
|
-
if (prop === SYMBOL_CLIENT_INDEX)
|
|
84
|
-
return true;
|
|
85
|
-
return prop in this.outputRef.current;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Resource that wraps a plain resource element to create a stable client proxy.
|
|
90
|
-
*
|
|
91
|
-
* Takes a ResourceElement that returns methods (with optional getState()) and
|
|
92
|
-
* wraps it to produce a stable client proxy. This adds the client to the
|
|
93
|
-
* client stack, enabling event scoping.
|
|
94
|
-
*
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
|
-
export const ClientResource = wrapperResource((element) => {
|
|
98
|
-
const valueRef = tapRef(null);
|
|
99
|
-
const index = tapClientStack().length;
|
|
100
|
-
const methods = tapMemo(() => new Proxy({}, new ClientProxyHandler(valueRef, index)), [index]);
|
|
101
|
-
const value = tapWithClientStack(methods, () => tapResource(element));
|
|
102
|
-
if (!valueRef.current) {
|
|
103
|
-
valueRef.current = value;
|
|
104
|
-
}
|
|
105
|
-
tapEffect(() => {
|
|
106
|
-
valueRef.current = value;
|
|
107
|
-
});
|
|
108
|
-
const state = value.getState?.();
|
|
109
|
-
return { methods, state, key: element.key };
|
|
110
|
-
});
|
|
111
|
-
export const tapClientResource = (element) => {
|
|
112
|
-
return tapResource(ClientResource(element));
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=tap-client-resource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-resource.js","sourceRoot":"","sources":["../../../src/store/utils/tap-client-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EAEN,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,sCAAmC;AACpC,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GACxB,gCAA6B;AAC9B,OAAO,EAAE,eAAe,EAAE,8BAA2B;AAErD;;;GAGG;AACH,MAA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AO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;AAC9C,CAAC,CACF,CAAC;AAQF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAkC,EAKlC,EAAE;IACF,OAAO,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAIzC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ClientMethods } from "../types/client.js";
|
|
2
|
-
/**
|
|
3
|
-
* Symbol used to get the client index from a ClientProxy.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SYMBOL_CLIENT_INDEX: unique symbol;
|
|
6
|
-
/**
|
|
7
|
-
* Get the index of a client (its position in the client stack when created).
|
|
8
|
-
*/
|
|
9
|
-
export declare const getClientIndex: (client: ClientMethods) => number;
|
|
10
|
-
/**
|
|
11
|
-
* The client stack - an array of clients representing the current hierarchy.
|
|
12
|
-
*/
|
|
13
|
-
export type ClientStack = readonly ClientMethods[];
|
|
14
|
-
/**
|
|
15
|
-
* Get the current client stack inside a tap resource.
|
|
16
|
-
*/
|
|
17
|
-
export declare const tapClientStack: () => ClientStack;
|
|
18
|
-
/**
|
|
19
|
-
* Execute a callback with a client pushed onto the stack.
|
|
20
|
-
* The stack is duplicated, not mutated.
|
|
21
|
-
*/
|
|
22
|
-
export declare const tapWithClientStack: <T>(client: ClientMethods, callback: () => T) => T;
|
|
23
|
-
//# sourceMappingURL=tap-client-stack-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-stack-context.d.ts","sourceRoot":"","sources":["../../../src/store/utils/tap-client-stack-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,2BAAwB;AAErD;;GAEG;AACH,eAAO,MAAM,mBAAmB,eAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,aAAa,KAAG,MAItD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,aAAa,EAAE,CAAC;AAInD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,WAEjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAClC,QAAQ,aAAa,EACrB,UAAU,MAAM,CAAC,KAChB,CAOF,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createResourceContext, tap, withContextProvider, tapMemo, } from "@assistant-ui/tap";
|
|
2
|
-
/**
|
|
3
|
-
* Symbol used to get the client index from a ClientProxy.
|
|
4
|
-
*/
|
|
5
|
-
export const SYMBOL_CLIENT_INDEX = Symbol("assistant-ui.store.clientIndex");
|
|
6
|
-
/**
|
|
7
|
-
* Get the index of a client (its position in the client stack when created).
|
|
8
|
-
*/
|
|
9
|
-
export const getClientIndex = (client) => {
|
|
10
|
-
return client[SYMBOL_CLIENT_INDEX];
|
|
11
|
-
};
|
|
12
|
-
const ClientStackContext = createResourceContext([]);
|
|
13
|
-
/**
|
|
14
|
-
* Get the current client stack inside a tap resource.
|
|
15
|
-
*/
|
|
16
|
-
export const tapClientStack = () => {
|
|
17
|
-
return tap(ClientStackContext);
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Execute a callback with a client pushed onto the stack.
|
|
21
|
-
* The stack is duplicated, not mutated.
|
|
22
|
-
*/
|
|
23
|
-
export const tapWithClientStack = (client, callback) => {
|
|
24
|
-
const currentStack = tapClientStack();
|
|
25
|
-
const newStack = tapMemo(() => [...currentStack, client], [currentStack, client]);
|
|
26
|
-
return withContextProvider(ClientStackContext, newStack, callback);
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=tap-client-stack-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tap-client-stack-context.js","sourceRoot":"","sources":["../../../src/store/utils/tap-client-stack-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,GAAG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
|
-
import { resource, withKey, } from "@assistant-ui/tap";
|
|
2
|
-
export const wrapperResource = (fn) => {
|
|
3
|
-
const res = resource(fn);
|
|
4
|
-
return (props) => {
|
|
5
|
-
const el = res(props);
|
|
6
|
-
if (props.key === undefined)
|
|
7
|
-
return el;
|
|
8
|
-
return withKey(props.key, el);
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=wrapper-resource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper-resource.js","sourceRoot":"","sources":["../../../src/store/utils/wrapper-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EACR,OAAO,GACR,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,EAAoC,EACH,EAAE;IACnC,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzB,OAAO,CAAC,KAAyB,EAAE,EAAE;QACnC,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import type { ResourceElement } from "@assistant-ui/tap";
|
|
2
|
-
import type {
|
|
3
|
-
AssistantEventName,
|
|
4
|
-
AssistantEventCallback,
|
|
5
|
-
AssistantEventSelector,
|
|
6
|
-
} from "./events";
|
|
7
|
-
import type { ThreadsClientSchema } from "../scopes/threads";
|
|
8
|
-
import type { ThreadListItemClientSchema } from "../scopes/thread-list-item";
|
|
9
|
-
import type { ThreadClientSchema } from "../scopes/thread";
|
|
10
|
-
import type { MessageClientSchema } from "../scopes/message";
|
|
11
|
-
import type { PartClientSchema } from "../scopes/part";
|
|
12
|
-
import type { ComposerClientSchema } from "../scopes/composer";
|
|
13
|
-
import type { AttachmentClientSchema } from "../scopes/attachment";
|
|
14
|
-
import type { ModelContextClientSchema } from "../scopes/model-context";
|
|
15
|
-
import type { SuggestionsClientSchema } from "../scopes/suggestions";
|
|
16
|
-
import type { SuggestionClientSchema } from "../scopes/suggestion";
|
|
17
|
-
import type { ChainOfThoughtClientSchema } from "../scopes/chain-of-thought";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Base type for methods that can be called on a client.
|
|
21
|
-
*/
|
|
22
|
-
export interface ClientMethods {
|
|
23
|
-
[key: string | symbol]: (...args: any[]) => any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type ClientMetaType = { source: ClientNames; query: Record<string, unknown> };
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Schema of a client in the assistant system (internal type).
|
|
30
|
-
* @template TState - The state type for this client
|
|
31
|
-
* @template TMethods - The methods available on this client
|
|
32
|
-
* @template TMeta - Source/query metadata (optional)
|
|
33
|
-
* @template TEvents - Events that this client can emit (optional)
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export type ClientSchema<
|
|
37
|
-
TMethods extends ClientMethods = ClientMethods,
|
|
38
|
-
TMeta extends ClientMetaType = never,
|
|
39
|
-
TEvents extends Record<string, unknown> = never,
|
|
40
|
-
> = {
|
|
41
|
-
methods: TMethods;
|
|
42
|
-
meta?: TMeta;
|
|
43
|
-
events?: TEvents;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Module augmentation interface for assistant-ui store type extensions.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* declare module "@assistant-ui/core/store" {
|
|
52
|
-
* interface ScopeRegistry {
|
|
53
|
-
* // Simple client (meta and events are optional)
|
|
54
|
-
* foo: {
|
|
55
|
-
* methods: {
|
|
56
|
-
* getState: () => { bar: string };
|
|
57
|
-
* updateBar: (bar: string) => void;
|
|
58
|
-
* };
|
|
59
|
-
* };
|
|
60
|
-
* // Full client with meta and events
|
|
61
|
-
* bar: {
|
|
62
|
-
* methods: {
|
|
63
|
-
* getState: () => { id: string };
|
|
64
|
-
* update: () => void;
|
|
65
|
-
* };
|
|
66
|
-
* meta: { source: "fooList"; query: { index: number } };
|
|
67
|
-
* events: {
|
|
68
|
-
* "bar.updated": { id: string };
|
|
69
|
-
* };
|
|
70
|
-
* };
|
|
71
|
-
* }
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export interface ScopeRegistry {
|
|
76
|
-
threads: ThreadsClientSchema;
|
|
77
|
-
threadListItem: ThreadListItemClientSchema;
|
|
78
|
-
thread: ThreadClientSchema;
|
|
79
|
-
message: MessageClientSchema;
|
|
80
|
-
part: PartClientSchema;
|
|
81
|
-
composer: ComposerClientSchema;
|
|
82
|
-
attachment: AttachmentClientSchema;
|
|
83
|
-
modelContext: ModelContextClientSchema;
|
|
84
|
-
suggestions: SuggestionsClientSchema;
|
|
85
|
-
suggestion: SuggestionClientSchema;
|
|
86
|
-
chainOfThought: ChainOfThoughtClientSchema;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
type ClientEventsType<K extends ClientNames> = Record<
|
|
90
|
-
`${K}.${string}`,
|
|
91
|
-
unknown
|
|
92
|
-
>;
|
|
93
|
-
|
|
94
|
-
type ClientError<E extends string> = {
|
|
95
|
-
methods: Record<E, () => E>;
|
|
96
|
-
meta: { source: ClientNames; query: Record<E, E> };
|
|
97
|
-
events: Record<`${E}.`, E>;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
type ValidateClient<K extends keyof ScopeRegistry> = ScopeRegistry[K] extends {
|
|
101
|
-
methods: ClientMethods;
|
|
102
|
-
}
|
|
103
|
-
? "meta" extends keyof ScopeRegistry[K]
|
|
104
|
-
? ScopeRegistry[K]["meta"] extends ClientMetaType
|
|
105
|
-
? "events" extends keyof ScopeRegistry[K]
|
|
106
|
-
? ScopeRegistry[K]["events"] extends ClientEventsType<K>
|
|
107
|
-
? ScopeRegistry[K]
|
|
108
|
-
: ClientError<`ERROR: ${K & string} has invalid events type`>
|
|
109
|
-
: ScopeRegistry[K]
|
|
110
|
-
: ClientError<`ERROR: ${K & string} has invalid meta type`>
|
|
111
|
-
: "events" extends keyof ScopeRegistry[K]
|
|
112
|
-
? ScopeRegistry[K]["events"] extends ClientEventsType<K>
|
|
113
|
-
? ScopeRegistry[K]
|
|
114
|
-
: ClientError<`ERROR: ${K & string} has invalid events type`>
|
|
115
|
-
: ScopeRegistry[K]
|
|
116
|
-
: ClientError<`ERROR: ${K & string} has invalid methods type`>;
|
|
117
|
-
|
|
118
|
-
type ClientSchemas = keyof ScopeRegistry extends never
|
|
119
|
-
? {
|
|
120
|
-
"ERROR: No clients were defined": ClientError<"ERROR: No clients were defined">;
|
|
121
|
-
}
|
|
122
|
-
: { [K in keyof ScopeRegistry]: ValidateClient<K> };
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Output type that client resources return (just methods).
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* const FooResource = resource((): ClientResourceOutput<"foo"> => {
|
|
130
|
-
* const [state, setState] = tapState({ bar: "hello" });
|
|
131
|
-
* return {
|
|
132
|
-
* getState: () => state,
|
|
133
|
-
* updateBar: (b) => setState({ bar: b }),
|
|
134
|
-
* };
|
|
135
|
-
* });
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
export type ClientOutput<K extends ClientNames> = ClientSchemas[K]["methods"] &
|
|
139
|
-
ClientMethods;
|
|
140
|
-
|
|
141
|
-
export type ClientNames = keyof ClientSchemas extends infer U ? U : never;
|
|
142
|
-
|
|
143
|
-
export type ClientEvents<K extends ClientNames> =
|
|
144
|
-
"events" extends keyof ClientSchemas[K]
|
|
145
|
-
? ClientSchemas[K]["events"] extends ClientEventsType<K>
|
|
146
|
-
? ClientSchemas[K]["events"]
|
|
147
|
-
: never
|
|
148
|
-
: never;
|
|
149
|
-
|
|
150
|
-
export type ClientMeta<K extends ClientNames> =
|
|
151
|
-
"meta" extends keyof ClientSchemas[K]
|
|
152
|
-
? Pick<
|
|
153
|
-
ClientSchemas[K]["meta"] extends ClientMetaType
|
|
154
|
-
? ClientSchemas[K]["meta"]
|
|
155
|
-
: never,
|
|
156
|
-
"source" | "query"
|
|
157
|
-
>
|
|
158
|
-
: never;
|
|
159
|
-
|
|
160
|
-
export type ClientElement<K extends ClientNames> = ResourceElement<
|
|
161
|
-
ClientOutput<K>
|
|
162
|
-
>;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Unsubscribe function type.
|
|
166
|
-
*/
|
|
167
|
-
export type Unsubscribe = () => void;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* State type extracted from all clients via their getState() methods.
|
|
171
|
-
*/
|
|
172
|
-
export type AssistantState = {
|
|
173
|
-
[K in ClientNames]: ClientSchemas[K]["methods"] extends {
|
|
174
|
-
getState: () => infer S;
|
|
175
|
-
}
|
|
176
|
-
? S
|
|
177
|
-
: never;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Type for a client accessor - a function that returns the methods,
|
|
182
|
-
* with source/query metadata attached (derived from meta).
|
|
183
|
-
*/
|
|
184
|
-
export type AssistantClientAccessor<K extends ClientNames> =
|
|
185
|
-
(() => ClientSchemas[K]["methods"]) &
|
|
186
|
-
(
|
|
187
|
-
| ClientMeta<K>
|
|
188
|
-
| { source: "root"; query: Record<string, never> }
|
|
189
|
-
| { source: null; query: null }
|
|
190
|
-
) & { name: K };
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* The assistant client type with all registered clients.
|
|
194
|
-
*/
|
|
195
|
-
export type AssistantClient = {
|
|
196
|
-
[K in ClientNames]: AssistantClientAccessor<K>;
|
|
197
|
-
} & {
|
|
198
|
-
subscribe(listener: () => void): Unsubscribe;
|
|
199
|
-
on<TEvent extends AssistantEventName>(
|
|
200
|
-
selector: AssistantEventSelector<TEvent>,
|
|
201
|
-
callback: AssistantEventCallback<TEvent>,
|
|
202
|
-
): Unsubscribe;
|
|
203
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AssistantClientAccessor,
|
|
3
|
-
ClientEvents,
|
|
4
|
-
ClientNames,
|
|
5
|
-
} from "./client";
|
|
6
|
-
|
|
7
|
-
// --- Event Map Construction ---
|
|
8
|
-
type UnionToIntersection<U> = (
|
|
9
|
-
U extends unknown
|
|
10
|
-
? (x: U) => void
|
|
11
|
-
: never
|
|
12
|
-
) extends (x: infer I) => void
|
|
13
|
-
? I
|
|
14
|
-
: never;
|
|
15
|
-
|
|
16
|
-
type ClientEventMap = UnionToIntersection<
|
|
17
|
-
{ [K in ClientNames]: ClientEvents<K> }[ClientNames]
|
|
18
|
-
>;
|
|
19
|
-
|
|
20
|
-
// --- Core Types ---
|
|
21
|
-
|
|
22
|
-
type WildcardPayload = {
|
|
23
|
-
[K in keyof ClientEventMap]: { event: K; payload: ClientEventMap[K] };
|
|
24
|
-
}[keyof ClientEventMap];
|
|
25
|
-
|
|
26
|
-
export type AssistantEventPayload = ClientEventMap & { "*": WildcardPayload };
|
|
27
|
-
|
|
28
|
-
export type AssistantEventName = keyof AssistantEventPayload;
|
|
29
|
-
|
|
30
|
-
type EventSource<T extends AssistantEventName> =
|
|
31
|
-
T extends `${infer Source}.${string}` ? Source : never;
|
|
32
|
-
|
|
33
|
-
// --- Scoping ---
|
|
34
|
-
|
|
35
|
-
type ParentOf<K extends ClientNames> =
|
|
36
|
-
AssistantClientAccessor<K> extends { source: infer S }
|
|
37
|
-
? S extends ClientNames
|
|
38
|
-
? S
|
|
39
|
-
: never
|
|
40
|
-
: never;
|
|
41
|
-
|
|
42
|
-
type AncestorsOf<
|
|
43
|
-
K extends ClientNames,
|
|
44
|
-
Seen extends ClientNames = never,
|
|
45
|
-
> = K extends Seen
|
|
46
|
-
? never
|
|
47
|
-
: ParentOf<K> extends never
|
|
48
|
-
? never
|
|
49
|
-
: ParentOf<K> | AncestorsOf<ParentOf<K>, Seen | K>;
|
|
50
|
-
|
|
51
|
-
/** Valid scopes: `"*"` | event source | ancestors of event source */
|
|
52
|
-
export type AssistantEventScope<TEvent extends AssistantEventName> =
|
|
53
|
-
| "*"
|
|
54
|
-
| EventSource<TEvent>
|
|
55
|
-
| (EventSource<TEvent> extends ClientNames
|
|
56
|
-
? AncestorsOf<EventSource<TEvent>>
|
|
57
|
-
: never);
|
|
58
|
-
|
|
59
|
-
// --- Selection & Callbacks ---
|
|
60
|
-
|
|
61
|
-
export type AssistantEventSelector<TEvent extends AssistantEventName> =
|
|
62
|
-
| TEvent
|
|
63
|
-
| { scope: AssistantEventScope<TEvent>; event: TEvent };
|
|
64
|
-
|
|
65
|
-
export const normalizeEventSelector = <TEvent extends AssistantEventName>(
|
|
66
|
-
selector: AssistantEventSelector<TEvent>,
|
|
67
|
-
) => {
|
|
68
|
-
if (typeof selector === "string") {
|
|
69
|
-
const source = selector.split(".")[0] as AssistantEventScope<TEvent>;
|
|
70
|
-
return { scope: source, event: selector };
|
|
71
|
-
}
|
|
72
|
-
return { scope: selector.scope, event: selector.event };
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export type AssistantEventCallback<TEvent extends AssistantEventName> = (
|
|
76
|
-
payload: AssistantEventPayload[TEvent],
|
|
77
|
-
) => void;
|