@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,30 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useAui } from "@assistant-ui/store";
|
|
3
|
+
import type { AssistantInstructionsConfig } from "../..";
|
|
4
|
+
|
|
5
|
+
export type { AssistantInstructionsConfig };
|
|
6
|
+
|
|
7
|
+
const getInstructions = (
|
|
8
|
+
instruction: string | AssistantInstructionsConfig,
|
|
9
|
+
): AssistantInstructionsConfig => {
|
|
10
|
+
if (typeof instruction === "string") return { instruction };
|
|
11
|
+
return instruction;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const useAssistantInstructions = (
|
|
15
|
+
config: string | AssistantInstructionsConfig,
|
|
16
|
+
) => {
|
|
17
|
+
const { instruction, disabled = false } = getInstructions(config);
|
|
18
|
+
const aui = useAui();
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (disabled) return;
|
|
22
|
+
|
|
23
|
+
const config = {
|
|
24
|
+
system: instruction,
|
|
25
|
+
};
|
|
26
|
+
return aui.modelContext().register({
|
|
27
|
+
getModelContext: () => config,
|
|
28
|
+
});
|
|
29
|
+
}, [aui, instruction, disabled]);
|
|
30
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useAui } from "@assistant-ui/store";
|
|
3
|
+
import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
4
|
+
import type { AssistantToolProps as CoreAssistantToolProps } from "../..";
|
|
5
|
+
|
|
6
|
+
export type AssistantToolProps<
|
|
7
|
+
TArgs extends Record<string, unknown>,
|
|
8
|
+
TResult,
|
|
9
|
+
> = CoreAssistantToolProps<TArgs, TResult> & {
|
|
10
|
+
render?: ToolCallMessagePartComponent<TArgs, TResult> | undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const useAssistantTool = <
|
|
14
|
+
TArgs extends Record<string, unknown>,
|
|
15
|
+
TResult,
|
|
16
|
+
>(
|
|
17
|
+
tool: AssistantToolProps<TArgs, TResult>,
|
|
18
|
+
) => {
|
|
19
|
+
const aui = useAui();
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!tool.render) return undefined;
|
|
23
|
+
return aui.tools().setToolUI(tool.toolName, tool.render);
|
|
24
|
+
}, [aui, tool.toolName, tool.render]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const { toolName, render, ...rest } = tool;
|
|
28
|
+
const context = {
|
|
29
|
+
tools: {
|
|
30
|
+
[toolName]: rest,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return aui.modelContext().register({
|
|
34
|
+
getModelContext: () => context,
|
|
35
|
+
});
|
|
36
|
+
}, [aui, tool]);
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useAui } from "@assistant-ui/store";
|
|
3
|
+
import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
|
|
4
|
+
|
|
5
|
+
export type AssistantToolUIProps<TArgs, TResult> = {
|
|
6
|
+
toolName: string;
|
|
7
|
+
render: ToolCallMessagePartComponent<TArgs, TResult>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const useAssistantToolUI = (
|
|
11
|
+
tool: AssistantToolUIProps<any, any> | null,
|
|
12
|
+
) => {
|
|
13
|
+
const aui = useAui();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!tool?.toolName || !tool?.render) return undefined;
|
|
16
|
+
return aui.tools().setToolUI(tool.toolName, tool.render);
|
|
17
|
+
}, [aui, tool?.toolName, tool?.render]);
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC, useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { ToolCallMessagePartProps } from "../types";
|
|
3
|
+
import { create } from "zustand";
|
|
4
|
+
|
|
5
|
+
export const useInlineRender = <TArgs, TResult>(
|
|
6
|
+
toolUI: FC<ToolCallMessagePartProps<TArgs, TResult>>,
|
|
7
|
+
): FC<ToolCallMessagePartProps<TArgs, TResult>> => {
|
|
8
|
+
const [useToolUIStore] = useState(() =>
|
|
9
|
+
create(() => ({
|
|
10
|
+
toolUI,
|
|
11
|
+
})),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
useToolUIStore.setState({ toolUI });
|
|
16
|
+
}, [toolUI, useToolUIStore]);
|
|
17
|
+
|
|
18
|
+
return useCallback(
|
|
19
|
+
function ToolUI(args) {
|
|
20
|
+
const store = useToolUIStore();
|
|
21
|
+
return store.toolUI(args);
|
|
22
|
+
},
|
|
23
|
+
[useToolUIStore],
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentType,
|
|
3
|
+
type FC,
|
|
4
|
+
type PropsWithChildren,
|
|
5
|
+
useMemo,
|
|
6
|
+
} from "react";
|
|
7
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
8
|
+
import { ChainOfThoughtPartByIndexProvider } from "../../providers/ChainOfThoughtPartByIndexProvider";
|
|
9
|
+
import { MessagePartComponent } from "../message/MessageParts";
|
|
10
|
+
import type {
|
|
11
|
+
ReasoningMessagePartComponent,
|
|
12
|
+
ToolCallMessagePartComponent,
|
|
13
|
+
} from "../../types";
|
|
14
|
+
|
|
15
|
+
export namespace ChainOfThoughtPrimitiveParts {
|
|
16
|
+
export type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* Component configuration for rendering chain of thought parts.
|
|
19
|
+
*/
|
|
20
|
+
components?: {
|
|
21
|
+
/** Component for rendering reasoning parts */
|
|
22
|
+
Reasoning?: ReasoningMessagePartComponent | undefined;
|
|
23
|
+
/** Fallback component for tool-call parts */
|
|
24
|
+
tools?: {
|
|
25
|
+
Fallback?: ToolCallMessagePartComponent | undefined;
|
|
26
|
+
};
|
|
27
|
+
/** Layout component to wrap the rendered parts when expanded */
|
|
28
|
+
Layout?: ComponentType<PropsWithChildren> | undefined;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Renders the parts within a chain of thought, with support for collapsed/expanded states.
|
|
35
|
+
*
|
|
36
|
+
* When collapsed, no parts are shown. When expanded, all parts are rendered
|
|
37
|
+
* using the provided component configuration through the part scope mechanism.
|
|
38
|
+
*/
|
|
39
|
+
export const ChainOfThoughtPrimitiveParts: FC<
|
|
40
|
+
ChainOfThoughtPrimitiveParts.Props
|
|
41
|
+
> = ({ components }) => {
|
|
42
|
+
const partsLength = useAuiState((s) => s.chainOfThought.parts.length);
|
|
43
|
+
|
|
44
|
+
const messageComponents = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
Reasoning: components?.Reasoning,
|
|
47
|
+
tools: {
|
|
48
|
+
Fallback: components?.tools?.Fallback,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
[components?.Reasoning, components?.tools?.Fallback],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const Layout = components?.Layout;
|
|
55
|
+
|
|
56
|
+
const elements = useMemo(() => {
|
|
57
|
+
return Array.from({ length: partsLength }, (_, index) => (
|
|
58
|
+
<ChainOfThoughtPartByIndexProvider key={index} index={index}>
|
|
59
|
+
{Layout ? (
|
|
60
|
+
<Layout>
|
|
61
|
+
<MessagePartComponent components={messageComponents} />
|
|
62
|
+
</Layout>
|
|
63
|
+
) : (
|
|
64
|
+
<MessagePartComponent components={messageComponents} />
|
|
65
|
+
)}
|
|
66
|
+
</ChainOfThoughtPartByIndexProvider>
|
|
67
|
+
));
|
|
68
|
+
}, [partsLength, messageComponents, Layout]);
|
|
69
|
+
|
|
70
|
+
return <>{elements}</>;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
ChainOfThoughtPrimitiveParts.displayName = "ChainOfThoughtPrimitive.Parts";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Attachment } from "../../../types";
|
|
2
|
+
import { ComponentType, type FC, memo, useMemo } from "react";
|
|
3
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { ComposerAttachmentByIndexProvider } from "../../providers";
|
|
5
|
+
|
|
6
|
+
export namespace ComposerPrimitiveAttachments {
|
|
7
|
+
export type Props = {
|
|
8
|
+
components:
|
|
9
|
+
| {
|
|
10
|
+
Image?: ComponentType | undefined;
|
|
11
|
+
Document?: ComponentType | undefined;
|
|
12
|
+
File?: ComponentType | undefined;
|
|
13
|
+
Attachment?: ComponentType | undefined;
|
|
14
|
+
}
|
|
15
|
+
| undefined;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const getComponent = (
|
|
20
|
+
components: ComposerPrimitiveAttachments.Props["components"],
|
|
21
|
+
attachment: Attachment,
|
|
22
|
+
) => {
|
|
23
|
+
const type = attachment.type;
|
|
24
|
+
switch (type) {
|
|
25
|
+
case "image":
|
|
26
|
+
return components?.Image ?? components?.Attachment;
|
|
27
|
+
case "document":
|
|
28
|
+
return components?.Document ?? components?.Attachment;
|
|
29
|
+
case "file":
|
|
30
|
+
return components?.File ?? components?.Attachment;
|
|
31
|
+
default:
|
|
32
|
+
return components?.Attachment;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const AttachmentComponent: FC<{
|
|
37
|
+
components: ComposerPrimitiveAttachments.Props["components"];
|
|
38
|
+
}> = ({ components }) => {
|
|
39
|
+
const attachment = useAuiState((s) => s.attachment);
|
|
40
|
+
if (!attachment) return null;
|
|
41
|
+
|
|
42
|
+
const Component = getComponent(components, attachment);
|
|
43
|
+
if (!Component) return null;
|
|
44
|
+
return <Component />;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export namespace ComposerPrimitiveAttachmentByIndex {
|
|
48
|
+
export type Props = {
|
|
49
|
+
index: number;
|
|
50
|
+
components?: ComposerPrimitiveAttachments.Props["components"];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Renders a single attachment at the specified index within the composer.
|
|
56
|
+
*/
|
|
57
|
+
export const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =
|
|
58
|
+
memo(
|
|
59
|
+
({ index, components }) => {
|
|
60
|
+
return (
|
|
61
|
+
<ComposerAttachmentByIndexProvider index={index}>
|
|
62
|
+
<AttachmentComponent components={components} />
|
|
63
|
+
</ComposerAttachmentByIndexProvider>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
(prev, next) =>
|
|
67
|
+
prev.index === next.index &&
|
|
68
|
+
prev.components?.Image === next.components?.Image &&
|
|
69
|
+
prev.components?.Document === next.components?.Document &&
|
|
70
|
+
prev.components?.File === next.components?.File &&
|
|
71
|
+
prev.components?.Attachment === next.components?.Attachment,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
ComposerPrimitiveAttachmentByIndex.displayName =
|
|
75
|
+
"ComposerPrimitive.AttachmentByIndex";
|
|
76
|
+
|
|
77
|
+
export const ComposerPrimitiveAttachments: FC<
|
|
78
|
+
ComposerPrimitiveAttachments.Props
|
|
79
|
+
> = ({ components }) => {
|
|
80
|
+
const attachmentsCount = useAuiState((s) => s.composer.attachments.length);
|
|
81
|
+
|
|
82
|
+
const attachmentElements = useMemo(() => {
|
|
83
|
+
return Array.from({ length: attachmentsCount }, (_, index) => (
|
|
84
|
+
<ComposerPrimitiveAttachmentByIndex
|
|
85
|
+
key={index}
|
|
86
|
+
index={index}
|
|
87
|
+
components={components}
|
|
88
|
+
/>
|
|
89
|
+
));
|
|
90
|
+
}, [attachmentsCount, components]);
|
|
91
|
+
|
|
92
|
+
return attachmentElements;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
|
|
4
|
+
type ComposerIfFilters = {
|
|
5
|
+
/** Whether the composer is in editing mode */
|
|
6
|
+
editing: boolean | undefined;
|
|
7
|
+
/** Whether dictation is currently active */
|
|
8
|
+
dictation: boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
|
12
|
+
T,
|
|
13
|
+
Exclude<keyof T, Keys>
|
|
14
|
+
> &
|
|
15
|
+
{
|
|
16
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
17
|
+
}[Keys];
|
|
18
|
+
|
|
19
|
+
export type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;
|
|
20
|
+
|
|
21
|
+
const useComposerIf = (props: UseComposerIfProps) => {
|
|
22
|
+
return useAuiState((s) => {
|
|
23
|
+
if (props.editing === true && !s.composer.isEditing) return false;
|
|
24
|
+
if (props.editing === false && s.composer.isEditing) return false;
|
|
25
|
+
|
|
26
|
+
const isDictating = s.composer.dictation != null;
|
|
27
|
+
if (props.dictation === true && !isDictating) return false;
|
|
28
|
+
if (props.dictation === false && isDictating) return false;
|
|
29
|
+
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export namespace ComposerPrimitiveIf {
|
|
35
|
+
export type Props = PropsWithChildren<UseComposerIfProps>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.
|
|
40
|
+
*/
|
|
41
|
+
export const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({
|
|
42
|
+
children,
|
|
43
|
+
...query
|
|
44
|
+
}) => {
|
|
45
|
+
const result = useComposerIf(query);
|
|
46
|
+
return result ? children : null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CompleteAttachment } from "../../../types";
|
|
2
|
+
import { ComponentType, type FC, memo, useMemo } from "react";
|
|
3
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { MessageAttachmentByIndexProvider } from "../../providers";
|
|
5
|
+
|
|
6
|
+
export namespace MessagePrimitiveAttachments {
|
|
7
|
+
export type Props = {
|
|
8
|
+
components:
|
|
9
|
+
| {
|
|
10
|
+
Image?: ComponentType | undefined;
|
|
11
|
+
Document?: ComponentType | undefined;
|
|
12
|
+
File?: ComponentType | undefined;
|
|
13
|
+
Attachment?: ComponentType | undefined;
|
|
14
|
+
}
|
|
15
|
+
| undefined;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const getComponent = (
|
|
20
|
+
components: MessagePrimitiveAttachments.Props["components"],
|
|
21
|
+
attachment: CompleteAttachment,
|
|
22
|
+
) => {
|
|
23
|
+
const type = attachment.type;
|
|
24
|
+
switch (type) {
|
|
25
|
+
case "image":
|
|
26
|
+
return components?.Image ?? components?.Attachment;
|
|
27
|
+
case "document":
|
|
28
|
+
return components?.Document ?? components?.Attachment;
|
|
29
|
+
case "file":
|
|
30
|
+
return components?.File ?? components?.Attachment;
|
|
31
|
+
default:
|
|
32
|
+
return components?.Attachment;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const AttachmentComponent: FC<{
|
|
37
|
+
components: MessagePrimitiveAttachments.Props["components"];
|
|
38
|
+
}> = ({ components }) => {
|
|
39
|
+
const attachment = useAuiState((s) => s.attachment);
|
|
40
|
+
if (!attachment) return null;
|
|
41
|
+
|
|
42
|
+
const Component = getComponent(components, attachment as CompleteAttachment);
|
|
43
|
+
if (!Component) return null;
|
|
44
|
+
return <Component />;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export namespace MessagePrimitiveAttachmentByIndex {
|
|
48
|
+
export type Props = {
|
|
49
|
+
index: number;
|
|
50
|
+
components?: MessagePrimitiveAttachments.Props["components"];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Renders a single attachment at the specified index within the current message.
|
|
56
|
+
*/
|
|
57
|
+
export const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =
|
|
58
|
+
memo(
|
|
59
|
+
({ index, components }) => {
|
|
60
|
+
return (
|
|
61
|
+
<MessageAttachmentByIndexProvider index={index}>
|
|
62
|
+
<AttachmentComponent components={components} />
|
|
63
|
+
</MessageAttachmentByIndexProvider>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
(prev, next) =>
|
|
67
|
+
prev.index === next.index &&
|
|
68
|
+
prev.components?.Image === next.components?.Image &&
|
|
69
|
+
prev.components?.Document === next.components?.Document &&
|
|
70
|
+
prev.components?.File === next.components?.File &&
|
|
71
|
+
prev.components?.Attachment === next.components?.Attachment,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
MessagePrimitiveAttachmentByIndex.displayName =
|
|
75
|
+
"MessagePrimitive.AttachmentByIndex";
|
|
76
|
+
|
|
77
|
+
export const MessagePrimitiveAttachments: FC<
|
|
78
|
+
MessagePrimitiveAttachments.Props
|
|
79
|
+
> = ({ components }) => {
|
|
80
|
+
const attachmentsCount = useAuiState((s) => {
|
|
81
|
+
if (s.message.role !== "user") return 0;
|
|
82
|
+
return s.message.attachments.length;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const attachmentElements = useMemo(() => {
|
|
86
|
+
return Array.from({ length: attachmentsCount }, (_, index) => (
|
|
87
|
+
<MessagePrimitiveAttachmentByIndex
|
|
88
|
+
key={index}
|
|
89
|
+
index={index}
|
|
90
|
+
components={components}
|
|
91
|
+
/>
|
|
92
|
+
));
|
|
93
|
+
}, [attachmentsCount, components]);
|
|
94
|
+
|
|
95
|
+
return attachmentElements;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
|