@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,66 @@
|
|
|
1
|
+
import type { ComponentType, PropsWithChildren } from "react";
|
|
2
|
+
import type {
|
|
3
|
+
MessagePartStatus,
|
|
4
|
+
DataMessagePart,
|
|
5
|
+
FileMessagePart,
|
|
6
|
+
ImageMessagePart,
|
|
7
|
+
ReasoningMessagePart,
|
|
8
|
+
SourceMessagePart,
|
|
9
|
+
TextMessagePart,
|
|
10
|
+
ToolCallMessagePart,
|
|
11
|
+
Unstable_AudioMessagePart,
|
|
12
|
+
} from "../..";
|
|
13
|
+
import type { MessagePartState } from "../..";
|
|
14
|
+
import { ToolResponse } from "assistant-stream";
|
|
15
|
+
|
|
16
|
+
export type EmptyMessagePartProps = {
|
|
17
|
+
status: MessagePartStatus;
|
|
18
|
+
};
|
|
19
|
+
export type EmptyMessagePartComponent = ComponentType<EmptyMessagePartProps>;
|
|
20
|
+
|
|
21
|
+
export type TextMessagePartProps = MessagePartState & TextMessagePart;
|
|
22
|
+
export type TextMessagePartComponent = ComponentType<TextMessagePartProps>;
|
|
23
|
+
|
|
24
|
+
export type ReasoningMessagePartProps = MessagePartState & ReasoningMessagePart;
|
|
25
|
+
export type ReasoningMessagePartComponent =
|
|
26
|
+
ComponentType<ReasoningMessagePartProps>;
|
|
27
|
+
|
|
28
|
+
export type ReasoningGroupProps = PropsWithChildren<{
|
|
29
|
+
startIndex: number;
|
|
30
|
+
endIndex: number;
|
|
31
|
+
}>;
|
|
32
|
+
export type ReasoningGroupComponent = ComponentType<ReasoningGroupProps>;
|
|
33
|
+
|
|
34
|
+
export type SourceMessagePartProps = MessagePartState & SourceMessagePart;
|
|
35
|
+
export type SourceMessagePartComponent = ComponentType<SourceMessagePartProps>;
|
|
36
|
+
|
|
37
|
+
export type ImageMessagePartProps = MessagePartState & ImageMessagePart;
|
|
38
|
+
export type ImageMessagePartComponent = ComponentType<ImageMessagePartProps>;
|
|
39
|
+
|
|
40
|
+
export type FileMessagePartProps = MessagePartState & FileMessagePart;
|
|
41
|
+
export type FileMessagePartComponent = ComponentType<FileMessagePartProps>;
|
|
42
|
+
|
|
43
|
+
export type Unstable_AudioMessagePartProps = MessagePartState &
|
|
44
|
+
Unstable_AudioMessagePart;
|
|
45
|
+
export type Unstable_AudioMessagePartComponent =
|
|
46
|
+
ComponentType<Unstable_AudioMessagePartProps>;
|
|
47
|
+
|
|
48
|
+
export type DataMessagePartProps<T = any> = MessagePartState &
|
|
49
|
+
DataMessagePart<T>;
|
|
50
|
+
export type DataMessagePartComponent<T = any> = ComponentType<
|
|
51
|
+
DataMessagePartProps<T>
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
export type ToolCallMessagePartProps<
|
|
55
|
+
TArgs = any,
|
|
56
|
+
TResult = unknown,
|
|
57
|
+
> = MessagePartState &
|
|
58
|
+
ToolCallMessagePart<TArgs, TResult> & {
|
|
59
|
+
addResult: (result: TResult | ToolResponse<TResult>) => void;
|
|
60
|
+
resume: (payload: unknown) => void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type ToolCallMessagePartComponent<
|
|
64
|
+
TArgs = any,
|
|
65
|
+
TResult = any,
|
|
66
|
+
> = ComponentType<ToolCallMessagePartProps<TArgs, TResult>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
EmptyMessagePartComponent,
|
|
3
|
+
EmptyMessagePartProps,
|
|
4
|
+
TextMessagePartComponent,
|
|
5
|
+
TextMessagePartProps,
|
|
6
|
+
ReasoningMessagePartComponent,
|
|
7
|
+
ReasoningMessagePartProps,
|
|
8
|
+
SourceMessagePartComponent,
|
|
9
|
+
SourceMessagePartProps,
|
|
10
|
+
ImageMessagePartComponent,
|
|
11
|
+
ImageMessagePartProps,
|
|
12
|
+
FileMessagePartComponent,
|
|
13
|
+
FileMessagePartProps,
|
|
14
|
+
Unstable_AudioMessagePartComponent,
|
|
15
|
+
Unstable_AudioMessagePartProps,
|
|
16
|
+
DataMessagePartComponent,
|
|
17
|
+
DataMessagePartProps,
|
|
18
|
+
ToolCallMessagePartComponent,
|
|
19
|
+
ToolCallMessagePartProps,
|
|
20
|
+
ReasoningGroupProps,
|
|
21
|
+
ReasoningGroupComponent,
|
|
22
|
+
} from "./MessagePartComponentTypes";
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
ToolsState,
|
|
26
|
+
ToolsMethods,
|
|
27
|
+
ToolsClientSchema,
|
|
28
|
+
DataRenderersState,
|
|
29
|
+
DataRenderersMethods,
|
|
30
|
+
DataRenderersClientSchema,
|
|
31
|
+
} from "./scopes";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataMessagePartComponent } from "../MessagePartComponentTypes";
|
|
2
|
+
import type { Unsubscribe } from "../../..";
|
|
3
|
+
|
|
4
|
+
export type DataRenderersState = {
|
|
5
|
+
renderers: Record<string, DataMessagePartComponent[]>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type DataRenderersMethods = {
|
|
9
|
+
getState(): DataRenderersState;
|
|
10
|
+
setDataUI(name: string, render: DataMessagePartComponent): Unsubscribe;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type DataRenderersClientSchema = {
|
|
14
|
+
methods: DataRenderersMethods;
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolCallMessagePartComponent } from "../MessagePartComponentTypes";
|
|
2
|
+
import type { Unsubscribe } from "../../..";
|
|
3
|
+
|
|
4
|
+
export type ToolsState = {
|
|
5
|
+
tools: Record<string, ToolCallMessagePartComponent[]>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ToolsMethods = {
|
|
9
|
+
getState(): ToolsState;
|
|
10
|
+
setToolUI(
|
|
11
|
+
toolName: string,
|
|
12
|
+
render: ToolCallMessagePartComponent,
|
|
13
|
+
): Unsubscribe;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ToolsClientSchema = {
|
|
17
|
+
methods: ToolsMethods;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "@assistant-ui/store";
|
|
2
|
+
|
|
3
|
+
import type { ToolsClientSchema } from "./scopes/tools";
|
|
4
|
+
import type { DataRenderersClientSchema } from "./scopes/dataRenderers";
|
|
5
|
+
|
|
6
|
+
declare module "@assistant-ui/store" {
|
|
7
|
+
interface ScopeRegistry {
|
|
8
|
+
tools: ToolsClientSchema;
|
|
9
|
+
dataRenderers: DataRenderersClientSchema;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Attachment,
|
|
3
|
-
CompleteAttachment,
|
|
4
|
-
PendingAttachment,
|
|
5
|
-
Unsubscribe,
|
|
6
|
-
} from "../../types";
|
|
1
|
+
import type { Attachment, CompleteAttachment, Unsubscribe } from "../../types";
|
|
7
2
|
import type { SubscribableWithState } from "../../subscribable/subscribable";
|
|
8
3
|
|
|
9
4
|
import type { ComposerRuntimeCoreBinding } from "./bindings";
|
|
@@ -13,7 +8,7 @@ type MessageAttachmentState = CompleteAttachment & {
|
|
|
13
8
|
readonly source: "message";
|
|
14
9
|
};
|
|
15
10
|
|
|
16
|
-
type ThreadComposerAttachmentState =
|
|
11
|
+
type ThreadComposerAttachmentState = Attachment & {
|
|
17
12
|
readonly source: "thread-composer";
|
|
18
13
|
};
|
|
19
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Attachment,
|
|
3
|
-
|
|
3
|
+
CreateAttachment,
|
|
4
4
|
MessageRole,
|
|
5
5
|
RunConfig,
|
|
6
6
|
QuoteInfo,
|
|
@@ -65,8 +65,6 @@ type BaseComposerState = {
|
|
|
65
65
|
|
|
66
66
|
export type ThreadComposerState = BaseComposerState & {
|
|
67
67
|
readonly type: "thread";
|
|
68
|
-
|
|
69
|
-
readonly attachments: readonly PendingAttachment[];
|
|
70
68
|
};
|
|
71
69
|
|
|
72
70
|
export type EditComposerState = BaseComposerState & {
|
|
@@ -131,10 +129,13 @@ export type ComposerRuntime = {
|
|
|
131
129
|
getState(): ComposerState;
|
|
132
130
|
|
|
133
131
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
132
|
+
* Add an attachment to the composer. Accepts either a standard File object
|
|
133
|
+
* (processed through the AttachmentAdapter) or a CreateAttachment descriptor
|
|
134
|
+
* for external-source attachments (URLs, API data, CMS references) that
|
|
135
|
+
* bypasses the adapter entirely.
|
|
136
|
+
* @param fileOrAttachment The file or attachment descriptor to add.
|
|
136
137
|
*/
|
|
137
|
-
addAttachment(
|
|
138
|
+
addAttachment(fileOrAttachment: File | CreateAttachment): Promise<void>;
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
141
|
* Set the text of the composer.
|
|
@@ -260,10 +261,10 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
260
261
|
core.setRunConfig(runConfig);
|
|
261
262
|
}
|
|
262
263
|
|
|
263
|
-
public addAttachment(
|
|
264
|
+
public addAttachment(fileOrAttachment: File | CreateAttachment) {
|
|
264
265
|
const core = this._core.getState();
|
|
265
266
|
if (!core) throw new Error("Composer is not available");
|
|
266
|
-
return core.addAttachment(
|
|
267
|
+
return core.addAttachment(fileOrAttachment);
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
public reset() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Attachment,
|
|
3
3
|
CompleteAttachment,
|
|
4
|
+
CreateAttachment,
|
|
4
5
|
PendingAttachment,
|
|
5
6
|
MessageRole,
|
|
6
7
|
RunConfig,
|
|
@@ -16,6 +17,7 @@ import type {
|
|
|
16
17
|
DictationState,
|
|
17
18
|
} from "../interfaces/composer-runtime-core";
|
|
18
19
|
import type { DictationAdapter } from "../../adapters/speech";
|
|
20
|
+
import { generateId } from "../../utils/id";
|
|
19
21
|
|
|
20
22
|
const isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>
|
|
21
23
|
a.status.type === "complete";
|
|
@@ -116,7 +118,8 @@ export abstract class BaseComposerRuntimeCore
|
|
|
116
118
|
private async _onClearAttachments() {
|
|
117
119
|
const adapter = this.getAttachmentAdapter();
|
|
118
120
|
if (adapter) {
|
|
119
|
-
|
|
121
|
+
const pending = this._attachments.filter((a) => !isAttachmentComplete(a));
|
|
122
|
+
await Promise.all(pending.map((a) => adapter.remove(a)));
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
125
|
|
|
@@ -155,10 +158,11 @@ export abstract class BaseComposerRuntimeCore
|
|
|
155
158
|
|
|
156
159
|
const adapter = this.getAttachmentAdapter();
|
|
157
160
|
const attachments =
|
|
158
|
-
|
|
161
|
+
this.attachments.length > 0
|
|
159
162
|
? Promise.all(
|
|
160
163
|
this.attachments.map(async (a) => {
|
|
161
164
|
if (isAttachmentComplete(a)) return a;
|
|
165
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
|
162
166
|
const result = await adapter.send(a);
|
|
163
167
|
return result as CompleteAttachment;
|
|
164
168
|
}),
|
|
@@ -192,7 +196,22 @@ export abstract class BaseComposerRuntimeCore
|
|
|
192
196
|
): void;
|
|
193
197
|
protected abstract handleCancel(): void;
|
|
194
198
|
|
|
195
|
-
async addAttachment(
|
|
199
|
+
async addAttachment(fileOrAttachment: File | CreateAttachment) {
|
|
200
|
+
if (!(fileOrAttachment instanceof File)) {
|
|
201
|
+
const a: CompleteAttachment = {
|
|
202
|
+
id: fileOrAttachment.id ?? generateId(),
|
|
203
|
+
type: fileOrAttachment.type ?? "document",
|
|
204
|
+
name: fileOrAttachment.name,
|
|
205
|
+
contentType: fileOrAttachment.contentType,
|
|
206
|
+
content: fileOrAttachment.content,
|
|
207
|
+
status: { type: "complete" },
|
|
208
|
+
};
|
|
209
|
+
this._attachments = [...this._attachments, a];
|
|
210
|
+
this._notifyEventSubscribers("attachmentAdd");
|
|
211
|
+
this._notifySubscribers();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
196
215
|
const adapter = this.getAttachmentAdapter();
|
|
197
216
|
if (!adapter) throw new Error("Attachments are not supported");
|
|
198
217
|
|
|
@@ -213,7 +232,7 @@ export abstract class BaseComposerRuntimeCore
|
|
|
213
232
|
this._notifySubscribers();
|
|
214
233
|
};
|
|
215
234
|
|
|
216
|
-
const promiseOrGenerator = adapter.add({ file });
|
|
235
|
+
const promiseOrGenerator = adapter.add({ file: fileOrAttachment });
|
|
217
236
|
if (Symbol.asyncIterator in promiseOrGenerator) {
|
|
218
237
|
for await (const r of promiseOrGenerator) {
|
|
219
238
|
upsertAttachment(r);
|
|
@@ -227,14 +246,15 @@ export abstract class BaseComposerRuntimeCore
|
|
|
227
246
|
}
|
|
228
247
|
|
|
229
248
|
async removeAttachment(attachmentId: string) {
|
|
230
|
-
const adapter = this.getAttachmentAdapter();
|
|
231
|
-
if (!adapter) throw new Error("Attachments are not supported");
|
|
232
|
-
|
|
233
249
|
const index = this._attachments.findIndex((a) => a.id === attachmentId);
|
|
234
250
|
if (index === -1) throw new Error("Attachment not found");
|
|
235
251
|
const attachment = this._attachments[index]!;
|
|
236
252
|
|
|
237
|
-
|
|
253
|
+
if (!isAttachmentComplete(attachment)) {
|
|
254
|
+
const adapter = this.getAttachmentAdapter();
|
|
255
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
|
256
|
+
await adapter.remove(attachment);
|
|
257
|
+
}
|
|
238
258
|
|
|
239
259
|
this._attachments = this._attachments.filter((a) => a.id !== attachmentId);
|
|
240
260
|
this._notifySubscribers();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppendMessage
|
|
1
|
+
import type { AppendMessage } from "../../types";
|
|
2
2
|
import type { AttachmentAdapter } from "../../adapters/attachment";
|
|
3
3
|
import type { DictationAdapter } from "../../adapters/speech";
|
|
4
4
|
import type { ThreadComposerRuntimeCore } from "../interfaces/composer-runtime-core";
|
|
@@ -14,10 +14,6 @@ export class DefaultThreadComposerRuntimeCore
|
|
|
14
14
|
return this._canCancel;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public override get attachments(): readonly PendingAttachment[] {
|
|
18
|
-
return super.attachments as readonly PendingAttachment[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
protected getAttachmentAdapter() {
|
|
22
18
|
return this.runtime.adapters?.attachments;
|
|
23
19
|
}
|
package/src/runtime/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
RunConfig,
|
|
4
4
|
QuoteInfo,
|
|
5
5
|
Attachment,
|
|
6
|
-
|
|
6
|
+
CreateAttachment,
|
|
7
7
|
Unsubscribe,
|
|
8
8
|
} from "../../types";
|
|
9
9
|
import type { DictationAdapter } from "../../adapters/speech";
|
|
@@ -25,7 +25,7 @@ export type ComposerRuntimeCore = Readonly<{
|
|
|
25
25
|
attachments: readonly Attachment[];
|
|
26
26
|
attachmentAccept: string;
|
|
27
27
|
|
|
28
|
-
addAttachment: (
|
|
28
|
+
addAttachment: (fileOrAttachment: File | CreateAttachment) => Promise<void>;
|
|
29
29
|
removeAttachment: (attachmentId: string) => Promise<void>;
|
|
30
30
|
|
|
31
31
|
text: string;
|
|
@@ -58,7 +58,4 @@ export type ComposerRuntimeCore = Readonly<{
|
|
|
58
58
|
) => Unsubscribe;
|
|
59
59
|
}>;
|
|
60
60
|
|
|
61
|
-
export type ThreadComposerRuntimeCore = ComposerRuntimeCore
|
|
62
|
-
Readonly<{
|
|
63
|
-
attachments: readonly PendingAttachment[];
|
|
64
|
-
}>;
|
|
61
|
+
export type ThreadComposerRuntimeCore = ComposerRuntimeCore;
|
|
@@ -18,6 +18,21 @@ export const getExternalStoreMessage = <T>(input: ThreadMessage) => {
|
|
|
18
18
|
|
|
19
19
|
const EMPTY_ARRAY: never[] = [];
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Attach the original external store message(s) to a ThreadMessage or message part.
|
|
23
|
+
* This is a no-op if the target already has a bound message.
|
|
24
|
+
* Use `getExternalStoreMessages` to retrieve the bound messages later.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated This API is experimental and may change without notice.
|
|
27
|
+
*/
|
|
28
|
+
export const bindExternalStoreMessage = <T>(
|
|
29
|
+
target: object,
|
|
30
|
+
message: T | T[],
|
|
31
|
+
): void => {
|
|
32
|
+
if (symbolInnerMessage in target) return;
|
|
33
|
+
(target as WithInnerMessages<T>)[symbolInnerMessage] = message;
|
|
34
|
+
};
|
|
35
|
+
|
|
21
36
|
export const getExternalStoreMessages = <T>(
|
|
22
37
|
input:
|
|
23
38
|
| { messages: readonly ThreadMessage[] }
|
|
@@ -21,6 +21,11 @@ import type {
|
|
|
21
21
|
} from "../../types";
|
|
22
22
|
import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
|
|
23
23
|
|
|
24
|
+
type DataPrefixedPart = {
|
|
25
|
+
readonly type: `data-${string}`;
|
|
26
|
+
readonly data: any;
|
|
27
|
+
};
|
|
28
|
+
|
|
24
29
|
export type ThreadMessageLike = {
|
|
25
30
|
readonly role: "assistant" | "user" | "system";
|
|
26
31
|
readonly content:
|
|
@@ -33,6 +38,7 @@ export type ThreadMessageLike = {
|
|
|
33
38
|
| FileMessagePart
|
|
34
39
|
| DataMessagePart
|
|
35
40
|
| Unstable_AudioMessagePart
|
|
41
|
+
| DataPrefixedPart
|
|
36
42
|
| {
|
|
37
43
|
readonly type: "tool-call";
|
|
38
44
|
readonly toolCallId?: string;
|
|
@@ -49,7 +55,11 @@ export type ThreadMessageLike = {
|
|
|
49
55
|
readonly id?: string | undefined;
|
|
50
56
|
readonly createdAt?: Date | undefined;
|
|
51
57
|
readonly status?: MessageStatus | undefined;
|
|
52
|
-
readonly attachments?:
|
|
58
|
+
readonly attachments?:
|
|
59
|
+
| readonly (Omit<CompleteAttachment, "content"> & {
|
|
60
|
+
readonly content: readonly (ThreadUserMessagePart | DataPrefixedPart)[];
|
|
61
|
+
})[]
|
|
62
|
+
| undefined;
|
|
53
63
|
readonly metadata?:
|
|
54
64
|
| {
|
|
55
65
|
readonly unstable_state?: ReadonlyJSONValue;
|
|
@@ -65,6 +75,14 @@ export type ThreadMessageLike = {
|
|
|
65
75
|
| undefined;
|
|
66
76
|
};
|
|
67
77
|
|
|
78
|
+
const convertDataPrefixedPart = (
|
|
79
|
+
type: string,
|
|
80
|
+
data: unknown,
|
|
81
|
+
): DataMessagePart | undefined => {
|
|
82
|
+
if (!type.startsWith("data-")) return undefined;
|
|
83
|
+
return { type: "data", name: type.substring(5), data };
|
|
84
|
+
};
|
|
85
|
+
|
|
68
86
|
export const fromThreadMessageLike = (
|
|
69
87
|
like: ThreadMessageLike,
|
|
70
88
|
fallbackId: string,
|
|
@@ -152,9 +170,13 @@ export const fromThreadMessageLike = (
|
|
|
152
170
|
}
|
|
153
171
|
|
|
154
172
|
default: {
|
|
155
|
-
const
|
|
173
|
+
const converted = convertDataPrefixedPart(
|
|
174
|
+
type,
|
|
175
|
+
(part as DataPrefixedPart).data,
|
|
176
|
+
);
|
|
177
|
+
if (converted) return converted;
|
|
156
178
|
throw new Error(
|
|
157
|
-
`Unsupported assistant message part type: ${
|
|
179
|
+
`Unsupported assistant message part type: ${type}`,
|
|
158
180
|
);
|
|
159
181
|
}
|
|
160
182
|
}
|
|
@@ -189,14 +211,25 @@ export const fromThreadMessageLike = (
|
|
|
189
211
|
return part;
|
|
190
212
|
|
|
191
213
|
default: {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
214
|
+
const converted = convertDataPrefixedPart(
|
|
215
|
+
type,
|
|
216
|
+
(part as DataPrefixedPart).data,
|
|
195
217
|
);
|
|
218
|
+
if (converted) return converted;
|
|
219
|
+
throw new Error(`Unsupported user message part type: ${type}`);
|
|
196
220
|
}
|
|
197
221
|
}
|
|
198
222
|
}),
|
|
199
|
-
attachments: attachments ?? []
|
|
223
|
+
attachments: (attachments ?? []).map((att) => ({
|
|
224
|
+
...att,
|
|
225
|
+
content: att.content.map((part): ThreadUserMessagePart => {
|
|
226
|
+
const converted = convertDataPrefixedPart(
|
|
227
|
+
part.type,
|
|
228
|
+
(part as DataPrefixedPart).data,
|
|
229
|
+
);
|
|
230
|
+
return converted ?? (part as ThreadUserMessagePart);
|
|
231
|
+
}),
|
|
232
|
+
})),
|
|
200
233
|
metadata: {
|
|
201
234
|
custom: metadata?.custom ?? {},
|
|
202
235
|
},
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import type { ExternalStoreAdapter } from "./external-store-adapter";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
getExternalStoreMessages,
|
|
13
|
+
bindExternalStoreMessage,
|
|
14
14
|
} from "../../runtime/utils/external-store-message";
|
|
15
15
|
import { ThreadMessageConverter } from "./thread-message-converter";
|
|
16
16
|
import { getAutoStatus, isAutoStatus } from "../../runtime/utils/auto-status";
|
|
@@ -30,7 +30,16 @@ import {
|
|
|
30
30
|
MessageRepository,
|
|
31
31
|
} from "../../runtime/utils/message-repository";
|
|
32
32
|
|
|
33
|
-
const EMPTY_ARRAY = Object.freeze([]);
|
|
33
|
+
const EMPTY_ARRAY: readonly ThreadSuggestion[] = Object.freeze([]);
|
|
34
|
+
|
|
35
|
+
const shallowEqual = (a: object, b: object): boolean => {
|
|
36
|
+
const aKeys = Object.keys(a);
|
|
37
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
38
|
+
for (const key of aKeys) {
|
|
39
|
+
if ((a as any)[key] !== (b as any)[key]) return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
34
43
|
|
|
35
44
|
export const hasUpcomingMessage = (
|
|
36
45
|
isRunning: boolean,
|
|
@@ -110,20 +119,30 @@ export class ExternalStoreThreadRuntimeCore
|
|
|
110
119
|
|
|
111
120
|
const oldStore = this._store as ExternalStoreAdapter<any> | undefined;
|
|
112
121
|
this._store = store;
|
|
113
|
-
this.extras
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
if (this.extras !== store.extras) {
|
|
123
|
+
this.extras = store.extras;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const newSuggestions = store.suggestions ?? EMPTY_ARRAY;
|
|
127
|
+
if (!shallowEqual(this.suggestions, newSuggestions)) {
|
|
128
|
+
this.suggestions = newSuggestions;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const newCapabilities: RuntimeCapabilities = {
|
|
116
132
|
switchToBranch: this._store.setMessages !== undefined,
|
|
117
|
-
switchBranchDuringRun: false,
|
|
133
|
+
switchBranchDuringRun: false,
|
|
118
134
|
edit: this._store.onEdit !== undefined,
|
|
119
135
|
reload: this._store.onReload !== undefined,
|
|
120
136
|
cancel: this._store.onCancel !== undefined,
|
|
121
137
|
speech: this._store.adapters?.speech !== undefined,
|
|
122
138
|
dictation: this._store.adapters?.dictation !== undefined,
|
|
123
|
-
unstable_copy: this._store.unstable_capabilities?.copy !== false,
|
|
139
|
+
unstable_copy: this._store.unstable_capabilities?.copy !== false,
|
|
124
140
|
attachments: !!this._store.adapters?.attachments,
|
|
125
141
|
feedback: !!this._store.adapters?.feedback,
|
|
126
142
|
};
|
|
143
|
+
if (!shallowEqual(this._capabilities, newCapabilities)) {
|
|
144
|
+
this._capabilities = newCapabilities;
|
|
145
|
+
}
|
|
127
146
|
|
|
128
147
|
let messages: readonly ThreadMessage[];
|
|
129
148
|
|
|
@@ -189,7 +208,7 @@ export class ExternalStoreThreadRuntimeCore
|
|
|
189
208
|
idx.toString(),
|
|
190
209
|
autoStatus,
|
|
191
210
|
);
|
|
192
|
-
(newMessage
|
|
211
|
+
bindExternalStoreMessage(newMessage, m);
|
|
193
212
|
return newMessage;
|
|
194
213
|
});
|
|
195
214
|
|
|
@@ -357,9 +376,7 @@ export class ExternalStoreThreadRuntimeCore
|
|
|
357
376
|
private updateMessages = (messages: readonly ThreadMessage[]) => {
|
|
358
377
|
const hasConverter = this._store.convertMessage !== undefined;
|
|
359
378
|
if (hasConverter) {
|
|
360
|
-
this._store.setMessages?.(
|
|
361
|
-
messages.flatMap(getExternalStoreMessage).filter((m) => m != null),
|
|
362
|
-
);
|
|
379
|
+
this._store.setMessages?.(messages.flatMap(getExternalStoreMessages));
|
|
363
380
|
} else {
|
|
364
381
|
// TODO mark this as readonly in v0.12.0
|
|
365
382
|
this._store.setMessages?.(messages as ThreadMessage[]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resource, tapMemo, tapState } from "@assistant-ui/tap";
|
|
2
|
-
import type { ClientOutput } from "
|
|
2
|
+
import type { ClientOutput } from "@assistant-ui/store";
|
|
3
3
|
import { CompositeContextProvider } from "../../utils";
|
|
4
4
|
import type { ModelContextState } from "../scopes";
|
|
5
5
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { resource, tapEffect, tapResource } from "@assistant-ui/tap";
|
|
2
|
+
import type { AssistantRuntime } from "../../runtime/api/assistant-runtime";
|
|
3
|
+
import { ThreadListClient } from "../runtime-clients";
|
|
4
|
+
import {
|
|
5
|
+
tapAssistantClientRef,
|
|
6
|
+
Derived,
|
|
7
|
+
type ScopesConfig,
|
|
8
|
+
type AssistantClient,
|
|
9
|
+
} from "@assistant-ui/store";
|
|
10
|
+
import { ModelContext } from "./model-context-client";
|
|
11
|
+
import { Suggestions } from "./suggestions";
|
|
12
|
+
|
|
13
|
+
export const RuntimeAdapterResource = resource((runtime: AssistantRuntime) => {
|
|
14
|
+
const clientRef = tapAssistantClientRef();
|
|
15
|
+
|
|
16
|
+
tapEffect(() => {
|
|
17
|
+
return runtime.registerModelContextProvider(
|
|
18
|
+
clientRef.current!.modelContext(),
|
|
19
|
+
);
|
|
20
|
+
}, [runtime, clientRef]);
|
|
21
|
+
|
|
22
|
+
return tapResource(
|
|
23
|
+
ThreadListClient({
|
|
24
|
+
runtime: runtime.threads,
|
|
25
|
+
__internal_assistantRuntime: runtime,
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const baseRuntimeAdapterTransformScopes = (
|
|
31
|
+
scopes: ScopesConfig,
|
|
32
|
+
parent: AssistantClient,
|
|
33
|
+
): ScopesConfig => {
|
|
34
|
+
const result = {
|
|
35
|
+
...scopes,
|
|
36
|
+
thread:
|
|
37
|
+
scopes.thread ??
|
|
38
|
+
Derived({
|
|
39
|
+
source: "threads",
|
|
40
|
+
query: { type: "main" },
|
|
41
|
+
get: (aui) => aui.threads().thread("main"),
|
|
42
|
+
}),
|
|
43
|
+
threadListItem:
|
|
44
|
+
scopes.threadListItem ??
|
|
45
|
+
Derived({
|
|
46
|
+
source: "threads",
|
|
47
|
+
query: { type: "main" },
|
|
48
|
+
get: (aui) => aui.threads().item("main"),
|
|
49
|
+
}),
|
|
50
|
+
composer:
|
|
51
|
+
scopes.composer ??
|
|
52
|
+
Derived({
|
|
53
|
+
source: "thread",
|
|
54
|
+
query: {},
|
|
55
|
+
get: (aui) => aui.threads().thread("main").composer(),
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (!result.modelContext && parent.modelContext.source === null) {
|
|
60
|
+
result.modelContext = ModelContext();
|
|
61
|
+
}
|
|
62
|
+
if (!result.suggestions && parent.suggestions.source === null) {
|
|
63
|
+
result.suggestions = Suggestions();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
};
|