@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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { ThreadMessage as ThreadMessageType } from "../../../types";
|
|
2
|
+
import { type ComponentType, type FC, memo, useMemo } from "react";
|
|
3
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { MessageByIndexProvider } from "../../providers";
|
|
5
|
+
|
|
6
|
+
export namespace ThreadPrimitiveMessages {
|
|
7
|
+
export type Props = {
|
|
8
|
+
/**
|
|
9
|
+
* Component configuration for rendering different types of messages and composers.
|
|
10
|
+
*
|
|
11
|
+
* You can provide either:
|
|
12
|
+
* 1. A single `Message` component that handles all message types
|
|
13
|
+
* 2. Specific components for `UserMessage` and `AssistantMessage` (with optional `SystemMessage`)
|
|
14
|
+
*
|
|
15
|
+
* Optional edit composer components can be provided to customize the editing experience
|
|
16
|
+
* for different message types when users edit their messages.
|
|
17
|
+
*/
|
|
18
|
+
components:
|
|
19
|
+
| {
|
|
20
|
+
/** Component used to render all message types */
|
|
21
|
+
Message: ComponentType;
|
|
22
|
+
/** Component used when editing any message type */
|
|
23
|
+
EditComposer?: ComponentType | undefined;
|
|
24
|
+
/** Component used when editing user messages specifically */
|
|
25
|
+
UserEditComposer?: ComponentType | undefined;
|
|
26
|
+
/** Component used when editing assistant messages specifically */
|
|
27
|
+
AssistantEditComposer?: ComponentType | undefined;
|
|
28
|
+
/** Component used when editing system messages specifically */
|
|
29
|
+
SystemEditComposer?: ComponentType | undefined;
|
|
30
|
+
/** Component used to render user messages specifically */
|
|
31
|
+
UserMessage?: ComponentType | undefined;
|
|
32
|
+
/** Component used to render assistant messages specifically */
|
|
33
|
+
AssistantMessage?: ComponentType | undefined;
|
|
34
|
+
/** Component used to render system messages specifically */
|
|
35
|
+
SystemMessage?: ComponentType | undefined;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
/** Component used to render all message types (fallback) */
|
|
39
|
+
Message?: ComponentType | undefined;
|
|
40
|
+
/** Component used when editing any message type */
|
|
41
|
+
EditComposer?: ComponentType | undefined;
|
|
42
|
+
/** Component used when editing user messages specifically */
|
|
43
|
+
UserEditComposer?: ComponentType | undefined;
|
|
44
|
+
/** Component used when editing assistant messages specifically */
|
|
45
|
+
AssistantEditComposer?: ComponentType | undefined;
|
|
46
|
+
/** Component used when editing system messages specifically */
|
|
47
|
+
SystemEditComposer?: ComponentType | undefined;
|
|
48
|
+
/** Component used to render user messages */
|
|
49
|
+
UserMessage: ComponentType;
|
|
50
|
+
/** Component used to render assistant messages */
|
|
51
|
+
AssistantMessage: ComponentType;
|
|
52
|
+
/** Component used to render system messages */
|
|
53
|
+
SystemMessage?: ComponentType | undefined;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const isComponentsSame = (
|
|
59
|
+
prev: ThreadPrimitiveMessages.Props["components"],
|
|
60
|
+
next: ThreadPrimitiveMessages.Props["components"],
|
|
61
|
+
) => {
|
|
62
|
+
return (
|
|
63
|
+
prev.Message === next.Message &&
|
|
64
|
+
prev.EditComposer === next.EditComposer &&
|
|
65
|
+
prev.UserEditComposer === next.UserEditComposer &&
|
|
66
|
+
prev.AssistantEditComposer === next.AssistantEditComposer &&
|
|
67
|
+
prev.SystemEditComposer === next.SystemEditComposer &&
|
|
68
|
+
prev.UserMessage === next.UserMessage &&
|
|
69
|
+
prev.AssistantMessage === next.AssistantMessage &&
|
|
70
|
+
prev.SystemMessage === next.SystemMessage
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const DEFAULT_SYSTEM_MESSAGE = () => null;
|
|
75
|
+
|
|
76
|
+
const getComponent = (
|
|
77
|
+
components: ThreadPrimitiveMessages.Props["components"],
|
|
78
|
+
role: ThreadMessageType["role"],
|
|
79
|
+
isEditing: boolean,
|
|
80
|
+
) => {
|
|
81
|
+
switch (role) {
|
|
82
|
+
case "user":
|
|
83
|
+
if (isEditing) {
|
|
84
|
+
return (
|
|
85
|
+
components.UserEditComposer ??
|
|
86
|
+
components.EditComposer ??
|
|
87
|
+
components.UserMessage ??
|
|
88
|
+
(components.Message as ComponentType)
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
return components.UserMessage ?? (components.Message as ComponentType);
|
|
92
|
+
}
|
|
93
|
+
case "assistant":
|
|
94
|
+
if (isEditing) {
|
|
95
|
+
return (
|
|
96
|
+
components.AssistantEditComposer ??
|
|
97
|
+
components.EditComposer ??
|
|
98
|
+
components.AssistantMessage ??
|
|
99
|
+
(components.Message as ComponentType)
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
return (
|
|
103
|
+
components.AssistantMessage ?? (components.Message as ComponentType)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
case "system":
|
|
107
|
+
if (isEditing) {
|
|
108
|
+
return (
|
|
109
|
+
components.SystemEditComposer ??
|
|
110
|
+
components.EditComposer ??
|
|
111
|
+
components.SystemMessage ??
|
|
112
|
+
(components.Message as ComponentType)
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
return (
|
|
116
|
+
components.SystemMessage ??
|
|
117
|
+
(components.Message as ComponentType) ??
|
|
118
|
+
DEFAULT_SYSTEM_MESSAGE
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
const _exhaustiveCheck: never = role;
|
|
123
|
+
throw new Error(`Unknown message role: ${_exhaustiveCheck}`);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
type ThreadMessageComponentProps = {
|
|
128
|
+
components: ThreadPrimitiveMessages.Props["components"];
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({
|
|
132
|
+
components,
|
|
133
|
+
}) => {
|
|
134
|
+
const role = useAuiState((s) => s.message.role);
|
|
135
|
+
const isEditing = useAuiState((s) => s.message.composer.isEditing);
|
|
136
|
+
const Component = getComponent(components, role, isEditing);
|
|
137
|
+
|
|
138
|
+
return <Component />;
|
|
139
|
+
};
|
|
140
|
+
export namespace ThreadPrimitiveMessageByIndex {
|
|
141
|
+
export type Props = {
|
|
142
|
+
index: number;
|
|
143
|
+
components: ThreadPrimitiveMessages.Props["components"];
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Renders a single message at the specified index in the current thread.
|
|
149
|
+
*
|
|
150
|
+
* This component provides message context for a specific message in the thread
|
|
151
|
+
* and renders it using the provided component configuration.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```tsx
|
|
155
|
+
* <ThreadPrimitive.MessageByIndex
|
|
156
|
+
* index={0}
|
|
157
|
+
* components={{
|
|
158
|
+
* UserMessage: MyUserMessage,
|
|
159
|
+
* AssistantMessage: MyAssistantMessage
|
|
160
|
+
* }}
|
|
161
|
+
* />
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =
|
|
165
|
+
memo(
|
|
166
|
+
({ index, components }) => {
|
|
167
|
+
return (
|
|
168
|
+
<MessageByIndexProvider index={index}>
|
|
169
|
+
<ThreadMessageComponent components={components} />
|
|
170
|
+
</MessageByIndexProvider>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
(prev, next) =>
|
|
174
|
+
prev.index === next.index &&
|
|
175
|
+
isComponentsSame(prev.components, next.components),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
ThreadPrimitiveMessageByIndex.displayName = "ThreadPrimitive.MessageByIndex";
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Renders all messages in the current thread using the provided component configuration.
|
|
182
|
+
*
|
|
183
|
+
* This component automatically renders all messages in the thread, providing the appropriate
|
|
184
|
+
* message context for each message. It handles different message types (user, assistant, system)
|
|
185
|
+
* and supports editing mode through the provided edit composer components.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```tsx
|
|
189
|
+
* <ThreadPrimitive.Messages
|
|
190
|
+
* components={{
|
|
191
|
+
* UserMessage: MyUserMessage,
|
|
192
|
+
* AssistantMessage: MyAssistantMessage,
|
|
193
|
+
* EditComposer: MyEditComposer
|
|
194
|
+
* }}
|
|
195
|
+
* />
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({
|
|
199
|
+
components,
|
|
200
|
+
}) => {
|
|
201
|
+
const messagesLength = useAuiState((s) => s.thread.messages.length);
|
|
202
|
+
|
|
203
|
+
const messageElements = useMemo(() => {
|
|
204
|
+
if (messagesLength === 0) return null;
|
|
205
|
+
return Array.from({ length: messagesLength }, (_, index) => (
|
|
206
|
+
<ThreadPrimitiveMessageByIndex
|
|
207
|
+
key={index}
|
|
208
|
+
index={index}
|
|
209
|
+
components={components}
|
|
210
|
+
/>
|
|
211
|
+
));
|
|
212
|
+
}, [messagesLength, components]);
|
|
213
|
+
|
|
214
|
+
return messageElements;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
|
218
|
+
|
|
219
|
+
export const ThreadPrimitiveMessages = memo(
|
|
220
|
+
ThreadPrimitiveMessagesImpl,
|
|
221
|
+
(prev, next) => isComponentsSame(prev.components, next.components),
|
|
222
|
+
);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ComponentType, type FC, memo, useMemo } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
import { SuggestionByIndexProvider } from "../../providers/SuggestionByIndexProvider";
|
|
4
|
+
|
|
5
|
+
export namespace ThreadPrimitiveSuggestions {
|
|
6
|
+
export type Props = {
|
|
7
|
+
/**
|
|
8
|
+
* Component to render for each suggestion.
|
|
9
|
+
*/
|
|
10
|
+
components: {
|
|
11
|
+
/** Component used to render each suggestion */
|
|
12
|
+
Suggestion: ComponentType;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type SuggestionComponentProps = {
|
|
18
|
+
components: ThreadPrimitiveSuggestions.Props["components"];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const SuggestionComponent: FC<SuggestionComponentProps> = ({ components }) => {
|
|
22
|
+
const Component = components.Suggestion;
|
|
23
|
+
return <Component />;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export namespace ThreadPrimitiveSuggestionByIndex {
|
|
27
|
+
export type Props = {
|
|
28
|
+
index: number;
|
|
29
|
+
components: ThreadPrimitiveSuggestions.Props["components"];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders a single suggestion at the specified index.
|
|
35
|
+
*/
|
|
36
|
+
export const ThreadPrimitiveSuggestionByIndex: FC<ThreadPrimitiveSuggestionByIndex.Props> =
|
|
37
|
+
memo(
|
|
38
|
+
({ index, components }) => {
|
|
39
|
+
return (
|
|
40
|
+
<SuggestionByIndexProvider index={index}>
|
|
41
|
+
<SuggestionComponent components={components} />
|
|
42
|
+
</SuggestionByIndexProvider>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
(prev, next) =>
|
|
46
|
+
prev.index === next.index &&
|
|
47
|
+
prev.components.Suggestion === next.components.Suggestion,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
ThreadPrimitiveSuggestionByIndex.displayName =
|
|
51
|
+
"ThreadPrimitive.SuggestionByIndex";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Renders all suggestions using the provided component configuration.
|
|
55
|
+
*/
|
|
56
|
+
export const ThreadPrimitiveSuggestionsImpl: FC<
|
|
57
|
+
ThreadPrimitiveSuggestions.Props
|
|
58
|
+
> = ({ components }) => {
|
|
59
|
+
const suggestionsLength = useAuiState(
|
|
60
|
+
(s) => s.suggestions.suggestions.length,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const suggestionElements = useMemo(() => {
|
|
64
|
+
if (suggestionsLength === 0) return null;
|
|
65
|
+
return Array.from({ length: suggestionsLength }, (_, index) => (
|
|
66
|
+
<ThreadPrimitiveSuggestionByIndex
|
|
67
|
+
key={index}
|
|
68
|
+
index={index}
|
|
69
|
+
components={components}
|
|
70
|
+
/>
|
|
71
|
+
));
|
|
72
|
+
}, [suggestionsLength, components]);
|
|
73
|
+
|
|
74
|
+
return suggestionElements;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
ThreadPrimitiveSuggestionsImpl.displayName = "ThreadPrimitive.Suggestions";
|
|
78
|
+
|
|
79
|
+
export const ThreadPrimitiveSuggestions = memo(
|
|
80
|
+
ThreadPrimitiveSuggestionsImpl,
|
|
81
|
+
(prev, next) => prev.components.Suggestion === next.components.Suggestion,
|
|
82
|
+
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ComponentType, FC, memo, useMemo } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
import { ThreadListItemByIndexProvider } from "../../providers";
|
|
4
|
+
|
|
5
|
+
export namespace ThreadListPrimitiveItems {
|
|
6
|
+
export type Props = {
|
|
7
|
+
archived?: boolean | undefined;
|
|
8
|
+
components: {
|
|
9
|
+
ThreadListItem: ComponentType;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export namespace ThreadListPrimitiveItemByIndex {
|
|
15
|
+
export type Props = {
|
|
16
|
+
index: number;
|
|
17
|
+
archived?: boolean | undefined;
|
|
18
|
+
components: ThreadListPrimitiveItems.Props["components"];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Renders a single thread list item at the specified index.
|
|
24
|
+
*/
|
|
25
|
+
export const ThreadListPrimitiveItemByIndex: FC<ThreadListPrimitiveItemByIndex.Props> =
|
|
26
|
+
memo(
|
|
27
|
+
({ index, archived = false, components }) => {
|
|
28
|
+
const ThreadListItemComponent = components.ThreadListItem;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<ThreadListItemByIndexProvider index={index} archived={archived}>
|
|
32
|
+
<ThreadListItemComponent />
|
|
33
|
+
</ThreadListItemByIndexProvider>
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
(prev, next) =>
|
|
37
|
+
prev.index === next.index &&
|
|
38
|
+
prev.archived === next.archived &&
|
|
39
|
+
prev.components.ThreadListItem === next.components.ThreadListItem,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
|
|
43
|
+
|
|
44
|
+
export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
|
45
|
+
archived = false,
|
|
46
|
+
components,
|
|
47
|
+
}) => {
|
|
48
|
+
const contentLength = useAuiState((s) =>
|
|
49
|
+
archived ? s.threads.archivedThreadIds.length : s.threads.threadIds.length,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const listElements = useMemo(() => {
|
|
53
|
+
return Array.from({ length: contentLength }, (_, index) => (
|
|
54
|
+
<ThreadListPrimitiveItemByIndex
|
|
55
|
+
key={index}
|
|
56
|
+
index={index}
|
|
57
|
+
archived={archived}
|
|
58
|
+
components={components}
|
|
59
|
+
/>
|
|
60
|
+
));
|
|
61
|
+
}, [contentLength, archived, components]);
|
|
62
|
+
|
|
63
|
+
return listElements;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FC, ReactNode } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export namespace ThreadListItemPrimitiveTitle {
|
|
5
|
+
export type Props = {
|
|
6
|
+
fallback?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ThreadListItemPrimitiveTitle: FC<
|
|
11
|
+
ThreadListItemPrimitiveTitle.Props
|
|
12
|
+
> = ({ fallback }) => {
|
|
13
|
+
const title = useAuiState((s) => s.threadListItem.title);
|
|
14
|
+
return <>{title || fallback}</>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
ThreadListItemPrimitiveTitle.displayName = "ThreadListItemPrimitive.Title";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export const MessageAttachmentByIndexProvider: FC<
|
|
5
|
+
PropsWithChildren<{
|
|
6
|
+
index: number;
|
|
7
|
+
}>
|
|
8
|
+
> = ({ index, children }) => {
|
|
9
|
+
const aui = useAui({
|
|
10
|
+
attachment: Derived({
|
|
11
|
+
source: "message",
|
|
12
|
+
query: { type: "index", index },
|
|
13
|
+
get: (aui) => aui.message().attachment({ index }),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ComposerAttachmentByIndexProvider: FC<
|
|
21
|
+
PropsWithChildren<{
|
|
22
|
+
index: number;
|
|
23
|
+
}>
|
|
24
|
+
> = ({ index, children }) => {
|
|
25
|
+
const aui = useAui({
|
|
26
|
+
attachment: Derived({
|
|
27
|
+
source: "composer",
|
|
28
|
+
query: { type: "index", index },
|
|
29
|
+
get: (aui) => aui.composer().attachment({ index }),
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, useAuiState, AuiProvider } from "@assistant-ui/store";
|
|
3
|
+
import { ChainOfThoughtClient } from "../../store/clients/chain-of-thought-client";
|
|
4
|
+
import type { ChainOfThoughtPart } from "../../store/scopes/chain-of-thought";
|
|
5
|
+
|
|
6
|
+
export const ChainOfThoughtByIndicesProvider: FC<
|
|
7
|
+
PropsWithChildren<{
|
|
8
|
+
startIndex: number;
|
|
9
|
+
endIndex: number;
|
|
10
|
+
}>
|
|
11
|
+
> = ({ startIndex, endIndex, children }) => {
|
|
12
|
+
const parts = useAuiState((s) => s.message.parts).slice(
|
|
13
|
+
startIndex,
|
|
14
|
+
endIndex + 1,
|
|
15
|
+
) as ChainOfThoughtPart[];
|
|
16
|
+
|
|
17
|
+
const parentAui = useAui();
|
|
18
|
+
|
|
19
|
+
const aui = useAui({
|
|
20
|
+
chainOfThought: ChainOfThoughtClient({
|
|
21
|
+
parts,
|
|
22
|
+
getMessagePart: ({ index }) => {
|
|
23
|
+
if (index < 0 || index >= parts.length) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`ChainOfThought part index ${index} is out of bounds (0..${parts.length - 1})`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return parentAui.message().part({ index: startIndex + index });
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export const ChainOfThoughtPartByIndexProvider: FC<
|
|
5
|
+
PropsWithChildren<{
|
|
6
|
+
index: number;
|
|
7
|
+
}>
|
|
8
|
+
> = ({ index, children }) => {
|
|
9
|
+
const aui = useAui({
|
|
10
|
+
part: Derived({
|
|
11
|
+
source: "chainOfThought",
|
|
12
|
+
query: { type: "index", index },
|
|
13
|
+
get: (aui) => aui.chainOfThought().part({ index }),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export const MessageByIndexProvider: FC<
|
|
5
|
+
PropsWithChildren<{
|
|
6
|
+
index: number;
|
|
7
|
+
}>
|
|
8
|
+
> = ({ index, children }) => {
|
|
9
|
+
const aui = useAui({
|
|
10
|
+
message: Derived({
|
|
11
|
+
source: "thread",
|
|
12
|
+
query: { type: "index", index },
|
|
13
|
+
get: (aui) => aui.thread().message({ index }),
|
|
14
|
+
}),
|
|
15
|
+
composer: Derived({
|
|
16
|
+
source: "message",
|
|
17
|
+
query: {},
|
|
18
|
+
get: (aui) => aui.thread().message({ index }).composer(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export const PartByIndexProvider: FC<
|
|
5
|
+
PropsWithChildren<{
|
|
6
|
+
index: number;
|
|
7
|
+
}>
|
|
8
|
+
> = ({ index, children }) => {
|
|
9
|
+
const aui = useAui({
|
|
10
|
+
part: Derived({
|
|
11
|
+
source: "message",
|
|
12
|
+
query: { type: "index", index },
|
|
13
|
+
get: (aui) => aui.message().part({ index }),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { AuiProvider, Derived, useAui } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export type SuggestionByIndexProviderProps = PropsWithChildren<{
|
|
5
|
+
index: number;
|
|
6
|
+
}>;
|
|
7
|
+
|
|
8
|
+
export const SuggestionByIndexProvider: FC<SuggestionByIndexProviderProps> = ({
|
|
9
|
+
index,
|
|
10
|
+
children,
|
|
11
|
+
}) => {
|
|
12
|
+
const aui = useAui({
|
|
13
|
+
suggestion: Derived({
|
|
14
|
+
source: "suggestions",
|
|
15
|
+
query: { index },
|
|
16
|
+
get: (aui) => aui.suggestions().suggestion({ index }),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, type ClientOutput } from "@assistant-ui/store";
|
|
3
|
+
import type { PartState } from "../../store/scopes/part";
|
|
4
|
+
import { resource, tapMemo } from "@assistant-ui/tap";
|
|
5
|
+
|
|
6
|
+
const TextMessagePartClient = resource(
|
|
7
|
+
({
|
|
8
|
+
text,
|
|
9
|
+
isRunning,
|
|
10
|
+
}: {
|
|
11
|
+
text: string;
|
|
12
|
+
isRunning: boolean;
|
|
13
|
+
}): ClientOutput<"part"> => {
|
|
14
|
+
const state = tapMemo<PartState>(
|
|
15
|
+
() => ({
|
|
16
|
+
type: "text",
|
|
17
|
+
text,
|
|
18
|
+
status: isRunning ? { type: "running" } : { type: "complete" },
|
|
19
|
+
}),
|
|
20
|
+
[text, isRunning],
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
getState: () => state,
|
|
25
|
+
addToolResult: () => {
|
|
26
|
+
throw new Error("Not supported");
|
|
27
|
+
},
|
|
28
|
+
resumeToolCall: () => {
|
|
29
|
+
throw new Error("Not supported");
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const TextMessagePartProvider: FC<
|
|
36
|
+
PropsWithChildren<{
|
|
37
|
+
text: string;
|
|
38
|
+
isRunning?: boolean;
|
|
39
|
+
}>
|
|
40
|
+
> = ({ text, isRunning = false, children }) => {
|
|
41
|
+
const aui = useAui({
|
|
42
|
+
part: TextMessagePartClient({ text, isRunning }),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider, Derived } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
export const ThreadListItemByIndexProvider: FC<
|
|
5
|
+
PropsWithChildren<{
|
|
6
|
+
index: number;
|
|
7
|
+
archived: boolean;
|
|
8
|
+
}>
|
|
9
|
+
> = ({ index, archived, children }) => {
|
|
10
|
+
const aui = useAui({
|
|
11
|
+
threadListItem: Derived({
|
|
12
|
+
source: "threads",
|
|
13
|
+
query: { type: "index", index, archived },
|
|
14
|
+
get: (aui) => aui.threads().item({ index, archived }),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
|
2
|
+
import { useAui, AuiProvider } from "@assistant-ui/store";
|
|
3
|
+
import type { ThreadListItemRuntime } from "../..";
|
|
4
|
+
import { ThreadListItemClient } from "../../store/internal";
|
|
5
|
+
|
|
6
|
+
export const ThreadListItemRuntimeProvider: FC<
|
|
7
|
+
PropsWithChildren<{
|
|
8
|
+
runtime: ThreadListItemRuntime;
|
|
9
|
+
}>
|
|
10
|
+
> = ({ runtime, children }) => {
|
|
11
|
+
const aui = useAui({
|
|
12
|
+
threadListItem: ThreadListItemClient({ runtime }),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return <AuiProvider value={aui}>{children}</AuiProvider>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
MessageAttachmentByIndexProvider,
|
|
3
|
+
ComposerAttachmentByIndexProvider,
|
|
4
|
+
} from "./AttachmentByIndexProvider";
|
|
5
|
+
export { ThreadListItemRuntimeProvider } from "./ThreadListItemRuntimeProvider";
|
|
6
|
+
export { MessageByIndexProvider } from "./MessageByIndexProvider";
|
|
7
|
+
export { PartByIndexProvider } from "./PartByIndexProvider";
|
|
8
|
+
export { TextMessagePartProvider } from "./TextMessagePartProvider";
|
|
9
|
+
export { ChainOfThoughtByIndicesProvider } from "./ChainOfThoughtByIndicesProvider";
|
|
10
|
+
export { ThreadListItemByIndexProvider } from "./ThreadListItemByIndexProvider";
|
|
11
|
+
export { ChainOfThoughtPartByIndexProvider } from "./ChainOfThoughtPartByIndexProvider";
|
|
12
|
+
export {
|
|
13
|
+
SuggestionByIndexProvider,
|
|
14
|
+
type SuggestionByIndexProviderProps,
|
|
15
|
+
} from "./SuggestionByIndexProvider";
|