@assistant-ui/core 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/attachment.d.ts +1 -1
- package/dist/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/feedback.d.ts +1 -1
- package/dist/adapters/feedback.d.ts.map +1 -1
- package/dist/adapters/speech.d.ts +1 -1
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/suggestion.d.ts +1 -1
- package/dist/adapters/suggestion.d.ts.map +1 -1
- package/dist/index.d.ts +44 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +13 -2
- package/dist/internal.js.map +1 -1
- package/dist/model-context/frame/host.d.ts +1 -1
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/provider.d.ts +1 -1
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/registry.d.ts +1 -1
- package/dist/model-context/registry.d.ts.map +1 -1
- package/dist/model-context/types.d.ts +1 -1
- package/dist/model-context/types.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.d.ts +0 -1
- package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/react/AssistantRuntimeProvider.js +0 -9
- package/dist/react/AssistantRuntimeProvider.js.map +1 -1
- package/dist/react/RuntimeAdapter.d.ts.map +1 -1
- package/dist/react/RuntimeAdapter.js +2 -1
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/index.d.ts +67 -9
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +67 -8
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-context/useInlineRender.d.ts +1 -1
- package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +5 -0
- package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useActionBarSpeak.js +15 -0
- package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -0
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +5 -0
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +11 -0
- package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -0
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +5 -0
- package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useBranchPickerNext.js +18 -0
- package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -0
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +5 -0
- package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js +18 -0
- package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -0
- package/dist/react/primitive-hooks/useComposerDictate.d.ts +5 -0
- package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useComposerDictate.js +13 -0
- package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -0
- package/dist/react/primitive-hooks/useMessageError.d.ts +2 -0
- package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useMessageError.js +8 -0
- package/dist/react/primitive-hooks/useMessageError.js.map +1 -0
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +10 -0
- package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useSuggestionTrigger.js +32 -0
- package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +4 -0
- package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemArchive.js +10 -0
- package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +4 -0
- package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemDelete.js +10 -0
- package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +4 -0
- package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js +10 -0
- package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +4 -0
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +10 -0
- package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -0
- package/dist/react/primitive-hooks/useThreadListNew.d.ts +4 -0
- package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListNew.js +10 -0
- package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -0
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +23 -13
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +16 -8
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.d.ts +19 -8
- package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js +19 -7
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.d.ts +19 -8
- package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js +19 -7
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +41 -5
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +113 -5
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/message/MessageQuote.d.ts +10 -0
- package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -0
- package/dist/react/primitives/message/MessageQuote.js +27 -0
- package/dist/react/primitives/message/MessageQuote.js.map +1 -0
- package/dist/react/primitives/part/PartMessages.d.ts +37 -0
- package/dist/react/primitives/part/PartMessages.d.ts.map +1 -0
- package/dist/react/primitives/part/PartMessages.js +49 -0
- package/dist/react/primitives/part/PartMessages.js.map +1 -0
- package/dist/react/primitives/thread/ThreadMessages.d.ts +54 -72
- package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js +32 -37
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts +18 -10
- package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js +25 -11
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.d.ts +18 -6
- package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js +15 -7
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/providers/ReadonlyThreadProvider.d.ts +9 -0
- package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -0
- package/dist/react/providers/ReadonlyThreadProvider.js +52 -0
- package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +2 -1
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +6 -6
- package/dist/react/runtimes/useLocalRuntime.js +1 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/react/runtimes/useToolInvocations.d.ts +1 -1
- package/dist/react/runtimes/useToolInvocations.d.ts.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +3 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/utils/getMessageQuote.d.ts +9 -0
- package/dist/react/utils/getMessageQuote.d.ts.map +1 -0
- package/dist/react/utils/getMessageQuote.js +7 -0
- package/dist/react/utils/getMessageQuote.js.map +1 -0
- package/dist/runtime/api/assistant-runtime.d.ts +2 -2
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts +2 -1
- 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/bindings.d.ts +1 -1
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts +5 -1
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.js +2 -1
- package/dist/runtime/api/composer-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +3 -1
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +3 -1
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +2 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +2 -1
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +18 -10
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +9 -3
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-assistant-runtime-core.d.ts +2 -2
- package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +5 -2
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +3 -2
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts +2 -2
- package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts +5 -1
- package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -2
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/utils/auto-status.d.ts +1 -1
- package/dist/runtime/utils/auto-status.d.ts.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +3 -2
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +1 -1
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts +2 -1
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/message-repository.js.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +3 -1
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +2 -2
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts +1 -1
- package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
- package/dist/runtimes/internal.d.ts +1 -0
- package/dist/runtimes/internal.d.ts.map +1 -1
- package/dist/runtimes/internal.js +2 -0
- package/dist/runtimes/internal.js.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.js +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +2 -2
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/should-continue.d.ts +1 -1
- package/dist/runtimes/local/should-continue.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +85 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +169 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/clients/model-context-client.js +1 -1
- package/dist/store/clients/model-context-client.js.map +1 -1
- package/dist/store/clients/runtime-adapter.js +1 -1
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.d.ts.map +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.map +1 -1
- package/dist/store/index.d.ts +16 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +5 -3
- package/dist/store/index.js.map +1 -1
- package/dist/store/internal.d.ts +7 -1
- package/dist/store/internal.d.ts.map +1 -1
- package/dist/store/internal.js +7 -1
- 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/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/tap-subscribable.d.ts +1 -1
- package/dist/store/runtime-clients/tap-subscribable.d.ts.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.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -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.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 +2 -1
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scopes/attachment.d.ts +2 -2
- package/dist/store/scopes/attachment.d.ts.map +1 -1
- package/dist/store/scopes/chain-of-thought.d.ts +2 -1
- package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
- package/dist/store/scopes/composer.d.ts +6 -2
- package/dist/store/scopes/composer.d.ts.map +1 -1
- package/dist/store/scopes/message.d.ts +4 -2
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/model-context.d.ts +2 -2
- package/dist/store/scopes/model-context.d.ts.map +1 -1
- package/dist/store/scopes/part.d.ts +3 -2
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/store/scopes/thread-list-item.d.ts +2 -1
- package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +9 -2
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +1 -1
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +1 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.d.ts +1 -1
- package/dist/utils/composite-context-provider.d.ts.map +1 -1
- package/dist/utils/composite-context-provider.js +1 -1
- package/dist/utils/composite-context-provider.js.map +1 -1
- package/dist/utils/text.d.ts +1 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js.map +1 -1
- package/package.json +10 -10
- package/src/adapters/attachment.ts +1 -1
- package/src/adapters/feedback.ts +1 -1
- package/src/adapters/speech.ts +1 -1
- package/src/adapters/suggestion.ts +1 -1
- package/src/index.ts +254 -5
- package/src/internal.ts +37 -2
- package/src/model-context/frame/host.ts +1 -1
- package/src/model-context/frame/provider.ts +1 -1
- package/src/model-context/registry.ts +1 -1
- package/src/model-context/types.ts +1 -1
- package/src/react/AssistantRuntimeProvider.tsx +1 -12
- package/src/react/RuntimeAdapter.ts +2 -1
- package/src/react/client/DataRenderers.ts +2 -2
- package/src/react/client/Tools.ts +2 -2
- package/src/react/index.ts +157 -10
- package/src/react/model-context/useInlineRender.ts +1 -1
- package/src/react/primitive-hooks/useActionBarSpeak.ts +20 -0
- package/src/react/primitive-hooks/useActionBarStopSpeaking.ts +13 -0
- package/src/react/primitive-hooks/useBranchPickerNext.ts +19 -0
- package/src/react/primitive-hooks/useBranchPickerPrevious.ts +19 -0
- package/src/react/primitive-hooks/useComposerDictate.ts +18 -0
- package/src/react/primitive-hooks/useMessageError.ts +10 -0
- package/src/react/primitive-hooks/useSuggestionTrigger.ts +43 -0
- package/src/react/primitive-hooks/useThreadListItemArchive.ts +12 -0
- package/src/react/primitive-hooks/useThreadListItemDelete.ts +12 -0
- package/src/react/primitive-hooks/useThreadListItemTrigger.ts +12 -0
- package/src/react/primitive-hooks/useThreadListItemUnarchive.ts +12 -0
- package/src/react/primitive-hooks/useThreadListNew.ts +12 -0
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +72 -28
- package/src/react/primitives/composer/ComposerAttachments.tsx +69 -30
- package/src/react/primitives/message/MessageAttachments.tsx +69 -30
- package/src/react/primitives/message/MessageParts.tsx +212 -24
- package/src/react/primitives/message/MessageQuote.tsx +37 -0
- package/src/react/primitives/part/PartMessages.tsx +75 -0
- package/src/react/primitives/thread/ThreadMessages.tsx +113 -99
- package/src/react/primitives/thread/ThreadSuggestions.tsx +72 -28
- package/src/react/primitives/threadList/ThreadListItems.tsx +69 -23
- package/src/react/providers/ReadonlyThreadProvider.tsx +84 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +1 -1
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -1
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +1 -1
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +2 -2
- package/src/react/runtimes/cloud/auiV0.ts +1 -1
- package/src/react/runtimes/createMessageConverter.ts +1 -1
- package/src/react/runtimes/external-message-converter.ts +2 -2
- package/src/react/runtimes/useLocalRuntime.ts +1 -1
- package/src/react/runtimes/useToolInvocations.ts +1 -1
- package/src/react/types/MessagePartComponentTypes.ts +4 -0
- package/src/react/utils/getMessageQuote.ts +18 -0
- package/src/runtime/api/assistant-runtime.ts +2 -2
- package/src/runtime/api/attachment-runtime.ts +2 -1
- package/src/runtime/api/bindings.ts +1 -1
- package/src/runtime/api/composer-runtime.ts +9 -10
- package/src/runtime/api/message-part-runtime.ts +3 -3
- package/src/runtime/api/message-runtime.ts +5 -6
- package/src/runtime/api/thread-list-item-runtime.ts +1 -1
- package/src/runtime/api/thread-list-runtime.ts +5 -3
- package/src/runtime/api/thread-runtime.ts +19 -11
- package/src/runtime/base/base-assistant-runtime-core.ts +2 -2
- package/src/runtime/base/base-composer-runtime-core.ts +6 -7
- package/src/runtime/base/base-thread-runtime-core.ts +3 -2
- package/src/runtime/base/default-edit-composer-runtime-core.ts +1 -1
- package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -1
- package/src/runtime/interfaces/assistant-runtime-core.ts +2 -2
- package/src/runtime/interfaces/composer-runtime-core.ts +5 -8
- package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -1
- package/src/runtime/interfaces/thread-runtime-core.ts +4 -7
- package/src/runtime/utils/auto-status.ts +1 -1
- package/src/runtime/utils/chat-model-adapter.ts +7 -5
- package/src/runtime/utils/external-store-message.ts +1 -1
- package/src/runtime/utils/message-repository.ts +2 -1
- package/src/runtime/utils/thread-message-like.ts +3 -4
- package/src/runtimes/external-store/external-store-adapter.ts +1 -1
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +1 -1
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +2 -2
- package/src/runtimes/external-store/thread-message-converter.ts +1 -1
- package/src/runtimes/internal.ts +3 -0
- package/src/runtimes/local/local-thread-list-runtime-core.ts +1 -1
- package/src/runtimes/local/local-thread-runtime-core.ts +3 -3
- package/src/runtimes/local/should-continue.ts +1 -1
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +223 -0
- package/src/runtimes/remote-thread-list/types.ts +1 -1
- package/src/store/clients/chain-of-thought-client.ts +1 -1
- package/src/store/clients/model-context-client.ts +2 -2
- package/src/store/clients/no-op-composer-client.ts +1 -1
- package/src/store/clients/runtime-adapter.ts +1 -1
- package/src/store/clients/suggestions.ts +2 -1
- package/src/store/clients/thread-message-client.ts +4 -3
- package/src/store/index.ts +76 -2
- package/src/store/internal.ts +7 -1
- package/src/store/runtime-clients/attachment-runtime-client.ts +1 -1
- package/src/store/runtime-clients/composer-runtime-client.ts +4 -4
- package/src/store/runtime-clients/message-part-runtime-client.ts +1 -1
- package/src/store/runtime-clients/message-runtime-client.ts +2 -2
- package/src/store/runtime-clients/tap-subscribable.ts +1 -1
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -2
- package/src/store/runtime-clients/thread-list-runtime-client.ts +3 -2
- package/src/store/runtime-clients/thread-runtime-client.ts +6 -4
- package/src/store/scopes/attachment.ts +2 -2
- package/src/store/scopes/chain-of-thought.ts +2 -1
- package/src/store/scopes/composer.ts +6 -8
- package/src/store/scopes/message.ts +4 -3
- package/src/store/scopes/model-context.ts +2 -2
- package/src/store/scopes/part.ts +3 -3
- package/src/store/scopes/thread-list-item.ts +2 -4
- package/src/store/scopes/thread.ts +11 -4
- package/src/store/scopes/threads.ts +1 -1
- package/src/subscribable/subscribable.ts +1 -1
- package/src/tests/MessageRepository.test.ts +2 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +1 -1
- package/src/utils/composite-context-provider.ts +1 -1
- package/src/utils/text.ts +2 -1
- package/dist/adapters/index.d.ts +0 -8
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -3
- package/dist/adapters/index.js.map +0 -1
- package/dist/model-context/frame/index.d.ts +0 -5
- package/dist/model-context/frame/index.d.ts.map +0 -1
- package/dist/model-context/frame/index.js +0 -4
- package/dist/model-context/frame/index.js.map +0 -1
- package/dist/model-context/index.d.ts +0 -8
- package/dist/model-context/index.d.ts.map +0 -1
- package/dist/model-context/index.js +0 -9
- package/dist/model-context/index.js.map +0 -1
- package/dist/react/client/index.d.ts +0 -3
- package/dist/react/client/index.d.ts.map +0 -1
- package/dist/react/client/index.js +0 -3
- package/dist/react/client/index.js.map +0 -1
- package/dist/react/model-context/index.d.ts +0 -12
- package/dist/react/model-context/index.d.ts.map +0 -1
- package/dist/react/model-context/index.js +0 -11
- package/dist/react/model-context/index.js.map +0 -1
- package/dist/react/primitive-hooks/index.d.ts +0 -15
- package/dist/react/primitive-hooks/index.d.ts.map +0 -1
- package/dist/react/primitive-hooks/index.js +0 -15
- package/dist/react/primitive-hooks/index.js.map +0 -1
- package/dist/react/providers/index.d.ts +0 -10
- package/dist/react/providers/index.d.ts.map +0 -1
- package/dist/react/providers/index.js +0 -10
- package/dist/react/providers/index.js.map +0 -1
- package/dist/react/runtimes/cloud/index.d.ts +0 -4
- package/dist/react/runtimes/cloud/index.d.ts.map +0 -1
- package/dist/react/runtimes/cloud/index.js +0 -4
- package/dist/react/runtimes/cloud/index.js.map +0 -1
- package/dist/react/runtimes/index.d.ts +0 -11
- package/dist/react/runtimes/index.d.ts.map +0 -1
- package/dist/react/runtimes/index.js +0 -11
- package/dist/react/runtimes/index.js.map +0 -1
- package/dist/react/types/index.d.ts +0 -3
- package/dist/react/types/index.d.ts.map +0 -1
- package/dist/react/types/index.js +0 -2
- package/dist/react/types/index.js.map +0 -1
- package/dist/react/types/scopes/index.d.ts +0 -3
- package/dist/react/types/scopes/index.d.ts.map +0 -1
- package/dist/react/types/scopes/index.js +0 -2
- package/dist/react/types/scopes/index.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -20
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -7
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtimes/external-store/index.d.ts +0 -8
- package/dist/runtimes/external-store/index.d.ts.map +0 -1
- package/dist/runtimes/external-store/index.js +0 -5
- package/dist/runtimes/external-store/index.js.map +0 -1
- package/dist/runtimes/index.d.ts +0 -6
- package/dist/runtimes/index.d.ts.map +0 -1
- package/dist/runtimes/index.js +0 -4
- package/dist/runtimes/index.js.map +0 -1
- package/dist/runtimes/local/index.d.ts +0 -7
- package/dist/runtimes/local/index.d.ts.map +0 -1
- package/dist/runtimes/local/index.js +0 -5
- package/dist/runtimes/local/index.js.map +0 -1
- package/dist/store/clients/index.d.ts +0 -6
- package/dist/store/clients/index.d.ts.map +0 -1
- package/dist/store/clients/index.js +0 -6
- package/dist/store/clients/index.js.map +0 -1
- package/dist/store/runtime-clients/index.d.ts +0 -8
- package/dist/store/runtime-clients/index.d.ts.map +0 -1
- package/dist/store/runtime-clients/index.js +0 -8
- package/dist/store/runtime-clients/index.js.map +0 -1
- package/dist/store/scopes/index.d.ts +0 -12
- package/dist/store/scopes/index.d.ts.map +0 -1
- package/dist/store/scopes/index.js +0 -2
- package/dist/store/scopes/index.js.map +0 -1
- package/dist/subscribable/index.d.ts +0 -3
- package/dist/subscribable/index.d.ts.map +0 -1
- package/dist/subscribable/index.js +0 -8
- package/dist/subscribable/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -7
- package/dist/utils/index.js.map +0 -1
- package/src/adapters/index.ts +0 -30
- package/src/model-context/frame/index.ts +0 -10
- package/src/model-context/index.ts +0 -35
- package/src/react/client/index.ts +0 -2
- package/src/react/model-context/index.ts +0 -25
- package/src/react/primitive-hooks/index.ts +0 -20
- package/src/react/providers/index.ts +0 -15
- package/src/react/runtimes/cloud/index.ts +0 -3
- package/src/react/runtimes/index.ts +0 -36
- package/src/react/types/index.ts +0 -31
- package/src/react/types/scopes/index.ts +0 -6
- package/src/runtime/index.ts +0 -109
- package/src/runtimes/external-store/index.ts +0 -15
- package/src/runtimes/index.ts +0 -28
- package/src/runtimes/local/index.ts +0 -6
- package/src/store/clients/index.ts +0 -8
- package/src/store/runtime-clients/index.ts +0 -7
- package/src/store/scopes/index.ts +0 -68
- package/src/subscribable/index.ts +0 -21
- package/src/types/index.ts +0 -40
- package/src/utils/index.ts +0 -14
|
@@ -1,23 +1,31 @@
|
|
|
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";
|
|
1
|
+
import type { Attachment } from "../../../types/attachment";
|
|
2
|
+
import { ComponentType, type FC, type ReactNode, memo, useMemo } from "react";
|
|
3
|
+
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { ComposerAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider";
|
|
5
|
+
|
|
6
|
+
type ComposerAttachmentsComponentConfig = {
|
|
7
|
+
Image?: ComponentType | undefined;
|
|
8
|
+
Document?: ComponentType | undefined;
|
|
9
|
+
File?: ComponentType | undefined;
|
|
10
|
+
Attachment?: ComponentType | undefined;
|
|
11
|
+
};
|
|
5
12
|
|
|
6
13
|
export namespace ComposerPrimitiveAttachments {
|
|
7
|
-
export type Props =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export type Props =
|
|
15
|
+
| {
|
|
16
|
+
/** @deprecated Use the children render function instead. */
|
|
17
|
+
components: ComposerAttachmentsComponentConfig;
|
|
18
|
+
children?: never;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
/** Render function called for each attachment. Receives the attachment. */
|
|
22
|
+
children: (value: { attachment: Attachment }) => ReactNode;
|
|
23
|
+
components?: never;
|
|
24
|
+
};
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
const getComponent = (
|
|
20
|
-
components:
|
|
28
|
+
components: ComposerAttachmentsComponentConfig | undefined,
|
|
21
29
|
attachment: Attachment,
|
|
22
30
|
) => {
|
|
23
31
|
const type = attachment.type;
|
|
@@ -34,7 +42,7 @@ const getComponent = (
|
|
|
34
42
|
};
|
|
35
43
|
|
|
36
44
|
const AttachmentComponent: FC<{
|
|
37
|
-
components:
|
|
45
|
+
components: ComposerAttachmentsComponentConfig | undefined;
|
|
38
46
|
}> = ({ components }) => {
|
|
39
47
|
const attachment = useAuiState((s) => s.attachment);
|
|
40
48
|
if (!attachment) return null;
|
|
@@ -47,7 +55,7 @@ const AttachmentComponent: FC<{
|
|
|
47
55
|
export namespace ComposerPrimitiveAttachmentByIndex {
|
|
48
56
|
export type Props = {
|
|
49
57
|
index: number;
|
|
50
|
-
components?:
|
|
58
|
+
components?: ComposerAttachmentsComponentConfig;
|
|
51
59
|
};
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -74,22 +82,53 @@ export const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentB
|
|
|
74
82
|
ComposerPrimitiveAttachmentByIndex.displayName =
|
|
75
83
|
"ComposerPrimitive.AttachmentByIndex";
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
> = ({
|
|
85
|
+
const ComposerPrimitiveAttachmentsInner: FC<{
|
|
86
|
+
children: (value: { attachment: Attachment }) => ReactNode;
|
|
87
|
+
}> = ({ children }) => {
|
|
80
88
|
const attachmentsCount = useAuiState((s) => s.composer.attachments.length);
|
|
81
89
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
key={index}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
return useMemo(
|
|
91
|
+
() =>
|
|
92
|
+
Array.from({ length: attachmentsCount }, (_, index) => (
|
|
93
|
+
<ComposerAttachmentByIndexProvider key={index} index={index}>
|
|
94
|
+
<RenderChildrenWithAccessor
|
|
95
|
+
getItemState={(aui) =>
|
|
96
|
+
aui.composer().attachment({ index }).getState()
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
{(getItem) =>
|
|
100
|
+
children({
|
|
101
|
+
get attachment() {
|
|
102
|
+
return getItem();
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
</RenderChildrenWithAccessor>
|
|
107
|
+
</ComposerAttachmentByIndexProvider>
|
|
108
|
+
)),
|
|
109
|
+
[attachmentsCount, children],
|
|
110
|
+
);
|
|
111
|
+
};
|
|
91
112
|
|
|
92
|
-
|
|
113
|
+
export const ComposerPrimitiveAttachments: FC<
|
|
114
|
+
ComposerPrimitiveAttachments.Props
|
|
115
|
+
> = ({ components, children }) => {
|
|
116
|
+
if (components) {
|
|
117
|
+
return (
|
|
118
|
+
<ComposerPrimitiveAttachmentsInner>
|
|
119
|
+
{({ attachment }) => {
|
|
120
|
+
const Component = getComponent(components, attachment);
|
|
121
|
+
if (!Component) return null;
|
|
122
|
+
return <Component />;
|
|
123
|
+
}}
|
|
124
|
+
</ComposerPrimitiveAttachmentsInner>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return (
|
|
128
|
+
<ComposerPrimitiveAttachmentsInner>
|
|
129
|
+
{children}
|
|
130
|
+
</ComposerPrimitiveAttachmentsInner>
|
|
131
|
+
);
|
|
93
132
|
};
|
|
94
133
|
|
|
95
134
|
ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
|
|
@@ -1,23 +1,31 @@
|
|
|
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";
|
|
1
|
+
import type { CompleteAttachment } from "../../../types/attachment";
|
|
2
|
+
import { ComponentType, type FC, type ReactNode, memo, useMemo } from "react";
|
|
3
|
+
import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { MessageAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider";
|
|
5
|
+
|
|
6
|
+
type MessageAttachmentsComponentConfig = {
|
|
7
|
+
Image?: ComponentType | undefined;
|
|
8
|
+
Document?: ComponentType | undefined;
|
|
9
|
+
File?: ComponentType | undefined;
|
|
10
|
+
Attachment?: ComponentType | undefined;
|
|
11
|
+
};
|
|
5
12
|
|
|
6
13
|
export namespace MessagePrimitiveAttachments {
|
|
7
|
-
export type Props =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export type Props =
|
|
15
|
+
| {
|
|
16
|
+
/** @deprecated Use the children render function instead. */
|
|
17
|
+
components: MessageAttachmentsComponentConfig;
|
|
18
|
+
children?: never;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
/** Render function called for each attachment. Receives the attachment. */
|
|
22
|
+
children: (value: { attachment: CompleteAttachment }) => ReactNode;
|
|
23
|
+
components?: never;
|
|
24
|
+
};
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
const getComponent = (
|
|
20
|
-
components:
|
|
28
|
+
components: MessageAttachmentsComponentConfig | undefined,
|
|
21
29
|
attachment: CompleteAttachment,
|
|
22
30
|
) => {
|
|
23
31
|
const type = attachment.type;
|
|
@@ -34,7 +42,7 @@ const getComponent = (
|
|
|
34
42
|
};
|
|
35
43
|
|
|
36
44
|
const AttachmentComponent: FC<{
|
|
37
|
-
components:
|
|
45
|
+
components: MessageAttachmentsComponentConfig | undefined;
|
|
38
46
|
}> = ({ components }) => {
|
|
39
47
|
const attachment = useAuiState((s) => s.attachment);
|
|
40
48
|
if (!attachment) return null;
|
|
@@ -47,7 +55,7 @@ const AttachmentComponent: FC<{
|
|
|
47
55
|
export namespace MessagePrimitiveAttachmentByIndex {
|
|
48
56
|
export type Props = {
|
|
49
57
|
index: number;
|
|
50
|
-
components?:
|
|
58
|
+
components?: MessageAttachmentsComponentConfig;
|
|
51
59
|
};
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -74,25 +82,56 @@ export const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByI
|
|
|
74
82
|
MessagePrimitiveAttachmentByIndex.displayName =
|
|
75
83
|
"MessagePrimitive.AttachmentByIndex";
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
> = ({
|
|
85
|
+
const MessagePrimitiveAttachmentsInner: FC<{
|
|
86
|
+
children: (value: { attachment: CompleteAttachment }) => ReactNode;
|
|
87
|
+
}> = ({ children }) => {
|
|
80
88
|
const attachmentsCount = useAuiState((s) => {
|
|
81
89
|
if (s.message.role !== "user") return 0;
|
|
82
90
|
return s.message.attachments.length;
|
|
83
91
|
});
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
key={index}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
return useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
Array.from({ length: attachmentsCount }, (_, index) => (
|
|
96
|
+
<MessageAttachmentByIndexProvider key={index} index={index}>
|
|
97
|
+
<RenderChildrenWithAccessor
|
|
98
|
+
getItemState={(aui) =>
|
|
99
|
+
aui.message().attachment({ index }).getState()
|
|
100
|
+
}
|
|
101
|
+
>
|
|
102
|
+
{(getItem) =>
|
|
103
|
+
children({
|
|
104
|
+
get attachment() {
|
|
105
|
+
return getItem() as CompleteAttachment;
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
</RenderChildrenWithAccessor>
|
|
110
|
+
</MessageAttachmentByIndexProvider>
|
|
111
|
+
)),
|
|
112
|
+
[attachmentsCount, children],
|
|
113
|
+
);
|
|
114
|
+
};
|
|
94
115
|
|
|
95
|
-
|
|
116
|
+
export const MessagePrimitiveAttachments: FC<
|
|
117
|
+
MessagePrimitiveAttachments.Props
|
|
118
|
+
> = ({ components, children }) => {
|
|
119
|
+
if (components) {
|
|
120
|
+
return (
|
|
121
|
+
<MessagePrimitiveAttachmentsInner>
|
|
122
|
+
{({ attachment }) => {
|
|
123
|
+
const Component = getComponent(components, attachment);
|
|
124
|
+
if (!Component) return null;
|
|
125
|
+
return <Component />;
|
|
126
|
+
}}
|
|
127
|
+
</MessagePrimitiveAttachmentsInner>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return (
|
|
131
|
+
<MessagePrimitiveAttachmentsInner>
|
|
132
|
+
{children}
|
|
133
|
+
</MessagePrimitiveAttachmentsInner>
|
|
134
|
+
);
|
|
96
135
|
};
|
|
97
136
|
|
|
98
137
|
MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ComponentType,
|
|
3
3
|
type FC,
|
|
4
|
+
type ReactNode,
|
|
4
5
|
memo,
|
|
5
6
|
PropsWithChildren,
|
|
6
7
|
useMemo,
|
|
7
8
|
} from "react";
|
|
8
|
-
import {
|
|
9
|
-
|
|
9
|
+
import {
|
|
10
|
+
RenderChildrenWithAccessor,
|
|
11
|
+
useAuiState,
|
|
12
|
+
useAui,
|
|
13
|
+
} from "@assistant-ui/store";
|
|
14
|
+
import type { PartState } from "../../../store/scopes/part";
|
|
15
|
+
import { PartByIndexProvider } from "../../providers/PartByIndexProvider";
|
|
16
|
+
import { TextMessagePartProvider } from "../../providers/TextMessagePartProvider";
|
|
10
17
|
import { ChainOfThoughtByIndicesProvider } from "../../providers/ChainOfThoughtByIndicesProvider";
|
|
18
|
+
import { getMessageQuote } from "../../utils/getMessageQuote";
|
|
11
19
|
import type {
|
|
12
20
|
Unstable_AudioMessagePartComponent,
|
|
13
21
|
DataMessagePartComponent,
|
|
@@ -21,8 +29,9 @@ import type {
|
|
|
21
29
|
FileMessagePartComponent,
|
|
22
30
|
ReasoningMessagePartComponent,
|
|
23
31
|
ReasoningGroupComponent,
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
QuoteMessagePartComponent,
|
|
33
|
+
} from "../../types/MessagePartComponentTypes";
|
|
34
|
+
import type { MessagePartStatus } from "../../../types/message";
|
|
26
35
|
import { useShallow } from "zustand/shallow";
|
|
27
36
|
|
|
28
37
|
type MessagePartRange =
|
|
@@ -161,6 +170,8 @@ export namespace MessagePrimitiveParts {
|
|
|
161
170
|
Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;
|
|
162
171
|
/** Configuration for data part rendering */
|
|
163
172
|
data?: DataConfig | undefined;
|
|
173
|
+
/** Component for rendering a quoted message reference (from metadata, not parts) */
|
|
174
|
+
Quote?: QuoteMessagePartComponent | undefined;
|
|
164
175
|
};
|
|
165
176
|
|
|
166
177
|
type ToolsConfig =
|
|
@@ -230,24 +241,32 @@ export namespace MessagePrimitiveParts {
|
|
|
230
241
|
ReasoningGroup?: never;
|
|
231
242
|
};
|
|
232
243
|
|
|
233
|
-
export type Props =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
244
|
+
export type Props =
|
|
245
|
+
| {
|
|
246
|
+
/**
|
|
247
|
+
* Component configuration for rendering different types of message content.
|
|
248
|
+
*
|
|
249
|
+
* Use either `Reasoning`/`tools`/`ToolGroup`/`ReasoningGroup` for standard rendering,
|
|
250
|
+
* or `ChainOfThought` to group all reasoning and tool-call parts into a single
|
|
251
|
+
* collapsible component. These two modes are mutually exclusive.
|
|
252
|
+
*/
|
|
253
|
+
components?: StandardComponents | ChainOfThoughtComponents | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* When enabled, shows the Empty component if the last part in the message
|
|
256
|
+
* is anything other than Text or Reasoning.
|
|
257
|
+
*
|
|
258
|
+
* @experimental This API is experimental and may change in future versions.
|
|
259
|
+
* @default true
|
|
260
|
+
*/
|
|
261
|
+
unstable_showEmptyOnNonTextEnd?: boolean | undefined;
|
|
262
|
+
children?: never;
|
|
263
|
+
}
|
|
264
|
+
| {
|
|
265
|
+
/** Render function called for each part. Receives the enriched part state. */
|
|
266
|
+
children: (value: { part: EnrichedPartState }) => ReactNode;
|
|
267
|
+
components?: never;
|
|
268
|
+
unstable_showEmptyOnNonTextEnd?: never;
|
|
269
|
+
};
|
|
251
270
|
}
|
|
252
271
|
|
|
253
272
|
const ToolUIDisplay = ({
|
|
@@ -460,6 +479,158 @@ const ConditionalEmpty = memo(
|
|
|
460
479
|
prev.components?.Text === next.components?.Text,
|
|
461
480
|
);
|
|
462
481
|
|
|
482
|
+
const QuoteRendererImpl: FC<{ Quote: QuoteMessagePartComponent }> = ({
|
|
483
|
+
Quote,
|
|
484
|
+
}) => {
|
|
485
|
+
const quoteInfo = useAuiState(getMessageQuote);
|
|
486
|
+
if (!quoteInfo) return null;
|
|
487
|
+
return <Quote text={quoteInfo.text} messageId={quoteInfo.messageId} />;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const QuoteRenderer = memo(QuoteRendererImpl);
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Stable propless component that renders the registered tool UI for the
|
|
494
|
+
* current part context. Reads tool registry and part state from context.
|
|
495
|
+
*/
|
|
496
|
+
const RegisteredToolUI: FC = () => {
|
|
497
|
+
const aui = useAui();
|
|
498
|
+
const part = useAuiState((s) => s.part);
|
|
499
|
+
const Render = useAuiState((s) => {
|
|
500
|
+
if (s.part.type !== "tool-call") return null;
|
|
501
|
+
const entry = s.tools.tools[s.part.toolName];
|
|
502
|
+
if (Array.isArray(entry)) return entry[0] ?? null;
|
|
503
|
+
return entry ?? null;
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
if (!Render || part.type !== "tool-call") return null;
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<Render
|
|
510
|
+
{...part}
|
|
511
|
+
addResult={aui.part().addToolResult}
|
|
512
|
+
resume={aui.part().resumeToolCall}
|
|
513
|
+
/>
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Stable propless component that renders the registered data renderer UI
|
|
519
|
+
* for the current part context.
|
|
520
|
+
*/
|
|
521
|
+
const RegisteredDataRendererUI: FC = () => {
|
|
522
|
+
const part = useAuiState((s) => s.part);
|
|
523
|
+
const Render = useAuiState((s) => {
|
|
524
|
+
if (s.part.type !== "data") return null;
|
|
525
|
+
const entry = s.dataRenderers.renderers[s.part.name];
|
|
526
|
+
if (Array.isArray(entry)) return entry[0] ?? null;
|
|
527
|
+
return entry ?? null;
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
if (!Render || part.type !== "data") return null;
|
|
531
|
+
|
|
532
|
+
return <Render {...(part as DataMessagePartProps)} />;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Fallback component rendered when the children render function returns null.
|
|
537
|
+
* Renders registered tool/data UIs via context.
|
|
538
|
+
* For all other part types, renders nothing.
|
|
539
|
+
*
|
|
540
|
+
* This allows users to write:
|
|
541
|
+
* {({ part }) => {
|
|
542
|
+
* if (part.type === "text") return <MyText />;
|
|
543
|
+
* return null; // tool UIs and data UIs still render via registry
|
|
544
|
+
* }}
|
|
545
|
+
*
|
|
546
|
+
* To explicitly render nothing (suppressing registered UIs), return <></>.
|
|
547
|
+
*/
|
|
548
|
+
const DefaultPartFallback: FC = () => {
|
|
549
|
+
const partType = useAuiState((s) => s.part.type);
|
|
550
|
+
|
|
551
|
+
if (partType === "tool-call") return <RegisteredToolUI />;
|
|
552
|
+
if (partType === "data") return <RegisteredDataRendererUI />;
|
|
553
|
+
|
|
554
|
+
return null;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
export type { PartState };
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Enriched part state passed to children render functions.
|
|
561
|
+
*
|
|
562
|
+
* For tool-call parts, adds `toolUI`, `addResult`, and `resume`.
|
|
563
|
+
* For data parts, adds `dataRendererUI`.
|
|
564
|
+
*/
|
|
565
|
+
export type EnrichedPartState =
|
|
566
|
+
| (Extract<PartState, { type: "tool-call" }> & {
|
|
567
|
+
/** The registered tool UI element, or null if none registered. */
|
|
568
|
+
readonly toolUI: ReactNode;
|
|
569
|
+
/** Add a tool result to this tool call. */
|
|
570
|
+
addResult: ToolCallMessagePartProps["addResult"];
|
|
571
|
+
/** Resume a tool call waiting for human input. */
|
|
572
|
+
resume: ToolCallMessagePartProps["resume"];
|
|
573
|
+
})
|
|
574
|
+
| (Extract<PartState, { type: "data" }> & {
|
|
575
|
+
/** The registered data renderer UI element, or null if none registered. */
|
|
576
|
+
readonly dataRendererUI: ReactNode;
|
|
577
|
+
})
|
|
578
|
+
| Exclude<PartState, { type: "tool-call" } | { type: "data" }>;
|
|
579
|
+
|
|
580
|
+
const MessagePrimitivePartsInner: FC<{
|
|
581
|
+
children: (value: { part: EnrichedPartState }) => ReactNode;
|
|
582
|
+
}> = ({ children }) => {
|
|
583
|
+
const aui = useAui();
|
|
584
|
+
const contentLength = useAuiState((s) => s.message.parts.length);
|
|
585
|
+
|
|
586
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: aui accessors are stable refs
|
|
587
|
+
return useMemo(
|
|
588
|
+
() =>
|
|
589
|
+
Array.from({ length: contentLength }, (_, index) => (
|
|
590
|
+
<PartByIndexProvider key={index} index={index}>
|
|
591
|
+
<RenderChildrenWithAccessor
|
|
592
|
+
getItemState={(aui) => aui.message().part({ index }).getState()}
|
|
593
|
+
>
|
|
594
|
+
{(getItem) => {
|
|
595
|
+
const result = children({
|
|
596
|
+
get part() {
|
|
597
|
+
const state = getItem();
|
|
598
|
+
if (state.type === "tool-call") {
|
|
599
|
+
const entry = aui.tools().getState().tools[state.toolName];
|
|
600
|
+
const hasUI = Array.isArray(entry) ? !!entry[0] : !!entry;
|
|
601
|
+
const partMethods = aui.message().part({ index });
|
|
602
|
+
return {
|
|
603
|
+
...state,
|
|
604
|
+
toolUI: hasUI ? <RegisteredToolUI /> : null,
|
|
605
|
+
addResult: partMethods.addToolResult,
|
|
606
|
+
resume: partMethods.resumeToolCall,
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (state.type === "data") {
|
|
610
|
+
const entry = aui.dataRenderers().getState().renderers[
|
|
611
|
+
state.name
|
|
612
|
+
];
|
|
613
|
+
const hasUI = Array.isArray(entry) ? !!entry[0] : !!entry;
|
|
614
|
+
return {
|
|
615
|
+
...state,
|
|
616
|
+
dataRendererUI: hasUI ? (
|
|
617
|
+
<RegisteredDataRendererUI />
|
|
618
|
+
) : null,
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
return state;
|
|
622
|
+
},
|
|
623
|
+
});
|
|
624
|
+
if (result !== null) return result;
|
|
625
|
+
return <DefaultPartFallback />;
|
|
626
|
+
}}
|
|
627
|
+
</RenderChildrenWithAccessor>
|
|
628
|
+
</PartByIndexProvider>
|
|
629
|
+
)),
|
|
630
|
+
[contentLength, children],
|
|
631
|
+
);
|
|
632
|
+
};
|
|
633
|
+
|
|
463
634
|
/**
|
|
464
635
|
* Renders the parts of a message with support for multiple content types.
|
|
465
636
|
*
|
|
@@ -469,7 +640,25 @@ const ConditionalEmpty = memo(
|
|
|
469
640
|
export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
470
641
|
components,
|
|
471
642
|
unstable_showEmptyOnNonTextEnd = true,
|
|
643
|
+
children,
|
|
472
644
|
}) => {
|
|
645
|
+
if (children) {
|
|
646
|
+
return <MessagePrimitivePartsInner>{children}</MessagePrimitivePartsInner>;
|
|
647
|
+
}
|
|
648
|
+
return (
|
|
649
|
+
<MessagePrimitivePartsCompat
|
|
650
|
+
components={components}
|
|
651
|
+
unstable_showEmptyOnNonTextEnd={unstable_showEmptyOnNonTextEnd}
|
|
652
|
+
/>
|
|
653
|
+
);
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
MessagePrimitiveParts.displayName = "MessagePrimitive.Parts";
|
|
657
|
+
|
|
658
|
+
const MessagePrimitivePartsCompat: FC<{
|
|
659
|
+
components: MessagePrimitiveParts.Props["components"];
|
|
660
|
+
unstable_showEmptyOnNonTextEnd: boolean;
|
|
661
|
+
}> = ({ components, unstable_showEmptyOnNonTextEnd }) => {
|
|
473
662
|
const contentLength = useAuiState((s) => s.message.parts.length);
|
|
474
663
|
const useChainOfThought = !!components?.ChainOfThought;
|
|
475
664
|
const messageRanges = useMessagePartsGroups(useChainOfThought);
|
|
@@ -549,6 +738,7 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
|
549
738
|
|
|
550
739
|
return (
|
|
551
740
|
<>
|
|
741
|
+
{components?.Quote && <QuoteRenderer Quote={components.Quote} />}
|
|
552
742
|
{partsElements}
|
|
553
743
|
<ConditionalEmpty
|
|
554
744
|
components={components}
|
|
@@ -557,5 +747,3 @@ export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
|
557
747
|
</>
|
|
558
748
|
);
|
|
559
749
|
};
|
|
560
|
-
|
|
561
|
-
MessagePrimitiveParts.displayName = "MessagePrimitive.Parts";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type FC, type ReactNode, memo } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
import { getMessageQuote } from "../../utils/getMessageQuote";
|
|
4
|
+
import type { QuoteInfo } from "../../../types/quote";
|
|
5
|
+
|
|
6
|
+
export namespace MessagePrimitiveQuote {
|
|
7
|
+
export type Props = {
|
|
8
|
+
/** Render function called when a quote is present. Receives quote info. */
|
|
9
|
+
children: (value: QuoteInfo) => ReactNode;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Renders a quote block if the message has quote metadata.
|
|
15
|
+
* Place this above `MessagePrimitive.Parts` in your message layout.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <MessagePrimitive.Quote>
|
|
20
|
+
* {({ text, messageId }) => <QuoteBlock text={text} messageId={messageId} />}
|
|
21
|
+
* </MessagePrimitive.Quote>
|
|
22
|
+
* <MessagePrimitive.Parts>
|
|
23
|
+
* {({ part }) => { ... }}
|
|
24
|
+
* </MessagePrimitive.Parts>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const MessagePrimitiveQuoteImpl: FC<MessagePrimitiveQuote.Props> = ({
|
|
28
|
+
children,
|
|
29
|
+
}) => {
|
|
30
|
+
const quoteInfo = useAuiState(getMessageQuote);
|
|
31
|
+
if (!quoteInfo) return null;
|
|
32
|
+
return <>{children(quoteInfo)}</>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const MessagePrimitiveQuote = memo(MessagePrimitiveQuoteImpl);
|
|
36
|
+
|
|
37
|
+
MessagePrimitiveQuote.displayName = "MessagePrimitive.Quote";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type FC, type ReactNode, memo } from "react";
|
|
2
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
3
|
+
import type { ThreadMessage } from "../../../types/message";
|
|
4
|
+
import { ReadonlyThreadProvider } from "../../providers/ReadonlyThreadProvider";
|
|
5
|
+
import {
|
|
6
|
+
ThreadPrimitiveMessages,
|
|
7
|
+
ThreadPrimitiveMessagesImpl,
|
|
8
|
+
} from "../thread/ThreadMessages";
|
|
9
|
+
|
|
10
|
+
export namespace PartPrimitiveMessages {
|
|
11
|
+
export type Props = {
|
|
12
|
+
components?: ThreadPrimitiveMessages.Props["components"];
|
|
13
|
+
/** Render function called for each message. Receives the message. */
|
|
14
|
+
children?: (value: { message: ThreadMessage }) => ReactNode;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const usePartMessages = (): readonly ThreadMessage[] | undefined => {
|
|
19
|
+
return useAuiState((s) => {
|
|
20
|
+
const part = s.part;
|
|
21
|
+
if (part.type !== "tool-call") return undefined;
|
|
22
|
+
return "messages" in part
|
|
23
|
+
? (part.messages as readonly ThreadMessage[] | undefined)
|
|
24
|
+
: undefined;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renders the nested messages of a tool call part (e.g. sub-agent conversation).
|
|
30
|
+
*
|
|
31
|
+
* This primitive reads `messages` from the current tool call part in the PartScope
|
|
32
|
+
* and renders them using a readonly thread context. All existing message and part
|
|
33
|
+
* primitives work inside, and parent tool UI registrations are inherited.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* const SubAgentToolUI = makeAssistantToolUI({
|
|
38
|
+
* toolName: "invoke_sub_agent",
|
|
39
|
+
* render: () => (
|
|
40
|
+
* <PartPrimitive.Messages>
|
|
41
|
+
* {({ message }) => {
|
|
42
|
+
* if (message.role === "user") return <MyUserMessage />;
|
|
43
|
+
* return <MyAssistantMessage />;
|
|
44
|
+
* }}
|
|
45
|
+
* </PartPrimitive.Messages>
|
|
46
|
+
* ),
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const PartPrimitiveMessagesImpl: FC<PartPrimitiveMessages.Props> = ({
|
|
51
|
+
components,
|
|
52
|
+
children,
|
|
53
|
+
}) => {
|
|
54
|
+
const messages = usePartMessages();
|
|
55
|
+
|
|
56
|
+
if (!messages?.length) return null;
|
|
57
|
+
|
|
58
|
+
if (children) {
|
|
59
|
+
return (
|
|
60
|
+
<ReadonlyThreadProvider messages={messages}>
|
|
61
|
+
<ThreadPrimitiveMessagesImpl>{children}</ThreadPrimitiveMessagesImpl>
|
|
62
|
+
</ReadonlyThreadProvider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<ReadonlyThreadProvider messages={messages}>
|
|
68
|
+
<ThreadPrimitiveMessagesImpl components={components!} />
|
|
69
|
+
</ReadonlyThreadProvider>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
PartPrimitiveMessagesImpl.displayName = "PartPrimitive.Messages";
|
|
74
|
+
|
|
75
|
+
export const PartPrimitiveMessages = memo(PartPrimitiveMessagesImpl);
|