@assistant-ui/react 0.10.23 → 0.10.25
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/api/{ContentPartRuntime.d.ts → MessagePartRuntime.d.ts} +14 -14
- package/dist/api/{ContentPartRuntime.d.ts.map → MessagePartRuntime.d.ts.map} +1 -1
- package/dist/api/{ContentPartRuntime.js → MessagePartRuntime.js} +6 -6
- package/dist/api/{ContentPartRuntime.js.map → MessagePartRuntime.js.map} +1 -1
- package/dist/api/MessageRuntime.d.ts +8 -8
- package/dist/api/MessageRuntime.js +17 -17
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +2 -2
- package/dist/api/ThreadListRuntime.d.ts +3 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +5 -1
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +5 -0
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +1 -0
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/cloud/AssistantCloudThreadHistoryAdapter.d.ts +1 -1
- package/dist/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/cloud/auiV0.d.ts +3 -3
- package/dist/cloud/auiV0.d.ts.map +1 -1
- package/dist/cloud/auiV0.js +1 -1
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/index.d.ts +1 -1
- package/dist/cloud/index.d.ts.map +1 -1
- package/dist/cloud/index.js +1 -1
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/context/providers/MessagePartRuntimeProvider.d.ts +9 -0
- package/dist/context/providers/{ContentPartRuntimeProvider.d.ts.map → MessagePartRuntimeProvider.d.ts.map} +1 -1
- package/dist/context/providers/{ContentPartRuntimeProvider.js → MessagePartRuntimeProvider.js} +9 -9
- package/dist/context/providers/MessagePartRuntimeProvider.js.map +1 -0
- package/dist/context/providers/{TextContentPartProvider.d.ts → TextMessagePartProvider.d.ts} +3 -3
- package/dist/context/providers/{TextContentPartProvider.d.ts.map → TextMessagePartProvider.d.ts.map} +1 -1
- package/dist/context/providers/{TextContentPartProvider.js → TextMessagePartProvider.js} +19 -19
- package/dist/context/providers/{TextContentPartProvider.js.map → TextMessagePartProvider.js.map} +1 -1
- package/dist/context/providers/index.d.ts +2 -1
- package/dist/context/providers/index.d.ts.map +1 -1
- package/dist/context/providers/index.js +4 -2
- package/dist/context/providers/index.js.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +23 -0
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +72 -72
- package/dist/context/react/ComposerContext.d.ts +64 -0
- package/dist/context/react/ComposerContext.d.ts.map +1 -1
- package/dist/context/react/ComposerContext.js.map +1 -1
- package/dist/context/react/MessageContext.d.ts +56 -0
- package/dist/context/react/MessageContext.d.ts.map +1 -1
- package/dist/context/react/MessageContext.js.map +1 -1
- package/dist/context/react/MessagePartContext.d.ts +41 -0
- package/dist/context/react/{ContentPartContext.d.ts.map → MessagePartContext.d.ts.map} +1 -1
- package/dist/context/react/MessagePartContext.js +25 -0
- package/dist/context/react/MessagePartContext.js.map +1 -0
- package/dist/context/react/ThreadContext.d.ts +42 -0
- package/dist/context/react/ThreadContext.d.ts.map +1 -1
- package/dist/context/react/ThreadContext.js.map +1 -1
- package/dist/context/react/index.d.ts +1 -1
- package/dist/context/react/index.js +3 -3
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.d.ts +3 -3
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/model-context/useAssistantTool.d.ts +2 -2
- package/dist/model-context/useAssistantTool.js.map +1 -1
- package/dist/model-context/useAssistantToolUI.d.ts +2 -2
- package/dist/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/model-context/useInlineRender.d.ts +2 -2
- package/dist/model-context/useInlineRender.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts +42 -0
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts +38 -0
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts +39 -0
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +56 -0
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +2 -0
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +2 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.d.ts +18 -0
- package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts +17 -0
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts +17 -0
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +38 -0
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +27 -0
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +11 -8
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts +17 -0
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +72 -0
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +19 -0
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts +18 -0
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/index.d.ts +12 -6
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +23 -11
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +11 -8
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +116 -0
- package/dist/primitives/message/MessageParts.d.ts.map +1 -0
- package/dist/primitives/message/MessageParts.js +208 -0
- package/dist/primitives/message/MessageParts.js.map +1 -0
- package/dist/primitives/message/MessageRoot.d.ts +22 -0
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message/index.d.ts +2 -1
- package/dist/primitives/message/index.d.ts.map +1 -1
- package/dist/primitives/message/index.js +4 -2
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartImage.d.ts +29 -0
- package/dist/primitives/messagePart/MessagePartImage.d.ts.map +1 -0
- package/dist/primitives/messagePart/MessagePartImage.js +16 -0
- package/dist/primitives/messagePart/MessagePartImage.js.map +1 -0
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts +6 -0
- package/dist/primitives/{contentPart/ContentPartInProgress.d.ts.map → messagePart/MessagePartInProgress.d.ts.map} +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +13 -0
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -0
- package/dist/primitives/messagePart/MessagePartText.d.ts +50 -0
- package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -0
- package/dist/primitives/messagePart/MessagePartText.js +18 -0
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -0
- package/dist/primitives/messagePart/index.d.ts +4 -0
- package/dist/primitives/{contentPart → messagePart}/index.d.ts.map +1 -1
- package/dist/primitives/messagePart/index.js +10 -0
- package/dist/primitives/messagePart/index.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartFile.js +18 -0
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartImage.js +18 -0
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.js +18 -0
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartSource.d.ts +5 -0
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartSource.js +18 -0
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -0
- package/dist/primitives/messagePart/useMessagePartText.d.ts +7 -0
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -0
- package/dist/primitives/messagePart/useMessagePartText.js +18 -0
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -0
- package/dist/primitives/thread/ThreadMessages.d.ts +44 -0
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +5 -2
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +19 -0
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +24 -0
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +12 -9
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts +54 -0
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts +33 -0
- package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts +47 -0
- package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +2 -0
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +3 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +3 -3
- package/dist/runtimes/external-store/ThreadMessageLike.js +3 -3
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/createMessageConverter.js +3 -3
- package/dist/runtimes/external-store/createMessageConverter.js.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.js.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +4 -4
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +2 -2
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +2 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +12 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +1 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.js +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +1 -1
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/tests/setup.js +8 -8
- package/dist/tests/setup.js.map +1 -1
- package/dist/types/AssistantTypes.d.ts +15 -15
- package/dist/types/AttachmentTypes.d.ts +3 -3
- package/dist/types/MessagePartComponentTypes.d.ts +25 -0
- package/dist/types/{ContentPartComponentTypes.d.ts.map → MessagePartComponentTypes.d.ts.map} +1 -1
- package/dist/types/MessagePartComponentTypes.js +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/getThreadMessageText.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +3 -3
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts +3 -3
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +3 -3
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +9 -8
- package/src/api/{ContentPartRuntime.ts → MessagePartRuntime.ts} +20 -20
- package/src/api/MessageRuntime.ts +32 -32
- package/src/api/RuntimePathTypes.ts +2 -2
- package/src/api/ThreadListRuntime.ts +8 -0
- package/src/api/ThreadRuntime.ts +6 -0
- package/src/api/index.ts +11 -3
- package/src/cloud/AssistantCloudThreadHistoryAdapter.tsx +1 -1
- package/src/cloud/auiV0.ts +4 -4
- package/src/cloud/index.ts +1 -1
- package/src/cloud/useCloudThreadListRuntime.tsx +1 -1
- package/src/context/providers/MessagePartRuntimeProvider.tsx +42 -0
- package/src/context/providers/{TextContentPartProvider.tsx → TextMessagePartProvider.tsx} +27 -27
- package/src/context/providers/index.ts +4 -1
- package/src/context/react/AssistantContext.ts +23 -0
- package/src/context/react/ComposerContext.ts +64 -0
- package/src/context/react/MessageContext.ts +56 -0
- package/src/context/react/MessagePartContext.ts +37 -0
- package/src/context/react/ThreadContext.ts +42 -0
- package/src/context/react/index.ts +1 -1
- package/src/context/stores/AssistantToolUIs.ts +4 -4
- package/src/model-context/useAssistantTool.tsx +2 -2
- package/src/model-context/useAssistantToolUI.tsx +2 -2
- package/src/model-context/useInlineRender.tsx +3 -3
- package/src/primitives/actionBar/ActionBarCopy.tsx +42 -0
- package/src/primitives/actionBar/ActionBarEdit.tsx +38 -0
- package/src/primitives/actionBar/ActionBarReload.tsx +39 -0
- package/src/primitives/actionBar/ActionBarRoot.tsx +38 -0
- package/src/primitives/assistantModal/AssistantModalContent.tsx +5 -1
- package/src/primitives/attachment/AttachmentRoot.tsx +18 -0
- package/src/primitives/branchPicker/BranchPickerCount.tsx +17 -0
- package/src/primitives/branchPicker/BranchPickerNext.tsx +17 -0
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +38 -0
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +22 -0
- package/src/primitives/composer/ComposerAttachments.tsx +11 -7
- package/src/primitives/composer/ComposerCancel.tsx +17 -0
- package/src/primitives/composer/ComposerInput.tsx +44 -0
- package/src/primitives/composer/ComposerRoot.tsx +19 -0
- package/src/primitives/composer/ComposerSend.tsx +18 -0
- package/src/primitives/index.ts +14 -6
- package/src/primitives/message/MessageAttachments.tsx +11 -7
- package/src/primitives/message/MessageParts.tsx +423 -0
- package/src/primitives/message/MessageRoot.tsx +22 -0
- package/src/primitives/message/index.ts +2 -1
- package/src/primitives/messagePart/MessagePartImage.tsx +39 -0
- package/src/primitives/messagePart/MessagePartInProgress.tsx +19 -0
- package/src/primitives/messagePart/MessagePartText.tsx +62 -0
- package/src/primitives/messagePart/index.ts +3 -0
- package/src/primitives/messagePart/useMessagePartFile.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartImage.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartReasoning.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartSource.tsx +18 -0
- package/src/primitives/messagePart/useMessagePartText.tsx +18 -0
- package/src/primitives/thread/ThreadMessages.tsx +52 -4
- package/src/primitives/thread/ThreadRoot.tsx +19 -0
- package/src/primitives/thread/ThreadViewport.tsx +19 -0
- package/src/primitives/threadList/ThreadListItems.tsx +12 -8
- package/src/runtimes/adapters/attachment/AttachmentAdapter.ts +56 -0
- package/src/runtimes/adapters/feedback/FeedbackAdapter.ts +33 -0
- package/src/runtimes/adapters/speech/SpeechAdapterTypes.ts +47 -0
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +1 -0
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +1 -0
- package/src/runtimes/core/ThreadRuntimeCore.tsx +1 -0
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +2 -0
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +3 -0
- package/src/runtimes/external-store/ThreadMessageLike.tsx +20 -20
- package/src/runtimes/external-store/createMessageConverter.tsx +3 -3
- package/src/runtimes/external-store/external-message-converter.tsx +2 -2
- package/src/runtimes/local/ChatModelAdapter.tsx +13 -13
- package/src/runtimes/local/LocalRuntimeOptions.tsx +1 -1
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +30 -15
- package/src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx +1 -0
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/remote-thread-list/adapter/cloud.tsx +1 -1
- package/src/runtimes/utils/MessageRepository.tsx +1 -1
- package/src/tests/MessageRepository.test.ts +6 -6
- package/src/types/AssistantTypes.ts +24 -24
- package/src/types/AttachmentTypes.ts +3 -3
- package/src/types/MessagePartComponentTypes.tsx +52 -0
- package/src/types/index.ts +69 -28
- package/src/utils/getThreadMessageText.tsx +2 -2
- package/src/utils/smooth/SmoothContext.tsx +7 -7
- package/src/utils/smooth/useSmooth.tsx +7 -7
- package/src/utils/useToolArgsFieldStatus.tsx +3 -3
- package/dist/cloud/AssistantCloud.d.ts +0 -15
- package/dist/cloud/AssistantCloud.d.ts.map +0 -1
- package/dist/cloud/AssistantCloud.js +0 -25
- package/dist/cloud/AssistantCloud.js.map +0 -1
- package/dist/cloud/AssistantCloudAPI.d.ts +0 -28
- package/dist/cloud/AssistantCloudAPI.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudAPI.js +0 -87
- package/dist/cloud/AssistantCloudAPI.js.map +0 -1
- package/dist/cloud/AssistantCloudAuthStrategy.d.ts +0 -30
- package/dist/cloud/AssistantCloudAuthStrategy.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudAuthStrategy.js +0 -139
- package/dist/cloud/AssistantCloudAuthStrategy.js.map +0 -1
- package/dist/cloud/AssistantCloudAuthTokens.d.ts +0 -11
- package/dist/cloud/AssistantCloudAuthTokens.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudAuthTokens.js +0 -13
- package/dist/cloud/AssistantCloudAuthTokens.js.map +0 -1
- package/dist/cloud/AssistantCloudFiles.d.ts +0 -27
- package/dist/cloud/AssistantCloudFiles.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudFiles.js +0 -25
- package/dist/cloud/AssistantCloudFiles.js.map +0 -1
- package/dist/cloud/AssistantCloudRuns.d.ts +0 -26
- package/dist/cloud/AssistantCloudRuns.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudRuns.js +0 -39
- package/dist/cloud/AssistantCloudRuns.js.map +0 -1
- package/dist/cloud/AssistantCloudThreadMessages.d.ts +0 -30
- package/dist/cloud/AssistantCloudThreadMessages.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudThreadMessages.js +0 -21
- package/dist/cloud/AssistantCloudThreadMessages.js.map +0 -1
- package/dist/cloud/AssistantCloudThreads.d.ts +0 -48
- package/dist/cloud/AssistantCloudThreads.d.ts.map +0 -1
- package/dist/cloud/AssistantCloudThreads.js +0 -30
- package/dist/cloud/AssistantCloudThreads.js.map +0 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +0 -9
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +0 -1
- package/dist/context/react/ContentPartContext.d.ts +0 -41
- package/dist/context/react/ContentPartContext.js +0 -25
- package/dist/context/react/ContentPartContext.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartImage.d.ts +0 -10
- package/dist/primitives/contentPart/ContentPartImage.d.ts.map +0 -1
- package/dist/primitives/contentPart/ContentPartImage.js +0 -16
- package/dist/primitives/contentPart/ContentPartImage.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartInProgress.d.ts +0 -6
- package/dist/primitives/contentPart/ContentPartInProgress.js +0 -13
- package/dist/primitives/contentPart/ContentPartInProgress.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartText.d.ts +0 -16
- package/dist/primitives/contentPart/ContentPartText.d.ts.map +0 -1
- package/dist/primitives/contentPart/ContentPartText.js +0 -18
- package/dist/primitives/contentPart/ContentPartText.js.map +0 -1
- package/dist/primitives/contentPart/index.d.ts +0 -4
- package/dist/primitives/contentPart/index.js +0 -10
- package/dist/primitives/contentPart/index.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartFile.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartFile.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartFile.js +0 -18
- package/dist/primitives/contentPart/useContentPartFile.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartImage.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartImage.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartImage.js +0 -18
- package/dist/primitives/contentPart/useContentPartImage.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartReasoning.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartReasoning.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartReasoning.js +0 -18
- package/dist/primitives/contentPart/useContentPartReasoning.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartSource.d.ts +0 -5
- package/dist/primitives/contentPart/useContentPartSource.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartSource.js +0 -18
- package/dist/primitives/contentPart/useContentPartSource.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartText.d.ts +0 -7
- package/dist/primitives/contentPart/useContentPartText.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartText.js +0 -18
- package/dist/primitives/contentPart/useContentPartText.js.map +0 -1
- package/dist/primitives/message/MessageContent.d.ts +0 -23
- package/dist/primitives/message/MessageContent.d.ts.map +0 -1
- package/dist/primitives/message/MessageContent.js +0 -138
- package/dist/primitives/message/MessageContent.js.map +0 -1
- package/dist/types/ContentPartComponentTypes.d.ts +0 -25
- package/dist/types/ContentPartComponentTypes.js +0 -1
- package/src/cloud/AssistantCloud.tsx +0 -22
- package/src/cloud/AssistantCloudAPI.tsx +0 -121
- package/src/cloud/AssistantCloudAuthStrategy.tsx +0 -193
- package/src/cloud/AssistantCloudAuthTokens.tsx +0 -13
- package/src/cloud/AssistantCloudFiles.tsx +0 -48
- package/src/cloud/AssistantCloudRuns.tsx +0 -45
- package/src/cloud/AssistantCloudThreadMessages.tsx +0 -48
- package/src/cloud/AssistantCloudThreads.tsx +0 -79
- package/src/context/providers/ContentPartRuntimeProvider.tsx +0 -42
- package/src/context/react/ContentPartContext.ts +0 -37
- package/src/primitives/contentPart/ContentPartImage.tsx +0 -20
- package/src/primitives/contentPart/ContentPartInProgress.tsx +0 -19
- package/src/primitives/contentPart/ContentPartText.tsx +0 -37
- package/src/primitives/contentPart/index.ts +0 -3
- package/src/primitives/contentPart/useContentPartFile.tsx +0 -18
- package/src/primitives/contentPart/useContentPartImage.tsx +0 -18
- package/src/primitives/contentPart/useContentPartReasoning.tsx +0 -18
- package/src/primitives/contentPart/useContentPartSource.tsx +0 -18
- package/src/primitives/contentPart/useContentPartText.tsx +0 -18
- package/src/primitives/message/MessageContent.tsx +0 -241
- package/src/tests/AssistantCloudFiles.test.ts +0 -564
- package/src/types/ContentPartComponentTypes.tsx +0 -52
- /package/dist/types/{ContentPartComponentTypes.js.map → MessagePartComponentTypes.js.map} +0 -0
@@ -8,25 +8,51 @@ import { ThreadMessage as ThreadMessageType } from "../../types";
|
|
8
8
|
|
9
9
|
export namespace ThreadPrimitiveMessages {
|
10
10
|
export type Props = {
|
11
|
+
/**
|
12
|
+
* Component configuration for rendering different types of messages and composers.
|
13
|
+
*
|
14
|
+
* You can provide either:
|
15
|
+
* 1. A single `Message` component that handles all message types
|
16
|
+
* 2. Specific components for `UserMessage` and `AssistantMessage` (with optional `SystemMessage`)
|
17
|
+
*
|
18
|
+
* Optional edit composer components can be provided to customize the editing experience
|
19
|
+
* for different message types when users edit their messages.
|
20
|
+
*/
|
11
21
|
components:
|
12
22
|
| {
|
23
|
+
/** Component used to render all message types */
|
13
24
|
Message: ComponentType;
|
25
|
+
/** Component used when editing any message type */
|
14
26
|
EditComposer?: ComponentType | undefined;
|
27
|
+
/** Component used when editing user messages specifically */
|
15
28
|
UserEditComposer?: ComponentType | undefined;
|
29
|
+
/** Component used when editing assistant messages specifically */
|
16
30
|
AssistantEditComposer?: ComponentType | undefined;
|
31
|
+
/** Component used when editing system messages specifically */
|
17
32
|
SystemEditComposer?: ComponentType | undefined;
|
33
|
+
/** Component used to render user messages specifically */
|
18
34
|
UserMessage?: ComponentType | undefined;
|
35
|
+
/** Component used to render assistant messages specifically */
|
19
36
|
AssistantMessage?: ComponentType | undefined;
|
37
|
+
/** Component used to render system messages specifically */
|
20
38
|
SystemMessage?: ComponentType | undefined;
|
21
39
|
}
|
22
40
|
| {
|
41
|
+
/** Component used to render all message types (fallback) */
|
23
42
|
Message?: ComponentType | undefined;
|
43
|
+
/** Component used when editing any message type */
|
24
44
|
EditComposer?: ComponentType | undefined;
|
45
|
+
/** Component used when editing user messages specifically */
|
25
46
|
UserEditComposer?: ComponentType | undefined;
|
47
|
+
/** Component used when editing assistant messages specifically */
|
26
48
|
AssistantEditComposer?: ComponentType | undefined;
|
49
|
+
/** Component used when editing system messages specifically */
|
27
50
|
SystemEditComposer?: ComponentType | undefined;
|
51
|
+
/** Component used to render user messages */
|
28
52
|
UserMessage: ComponentType;
|
53
|
+
/** Component used to render assistant messages */
|
29
54
|
AssistantMessage: ComponentType;
|
55
|
+
/** Component used to render system messages */
|
30
56
|
SystemMessage?: ComponentType | undefined;
|
31
57
|
};
|
32
58
|
};
|
@@ -140,15 +166,37 @@ const ThreadMessage = memo(
|
|
140
166
|
isComponentsSame(prev.components, next.components),
|
141
167
|
);
|
142
168
|
|
169
|
+
/**
|
170
|
+
* Renders all messages in the current thread using the provided component configuration.
|
171
|
+
*
|
172
|
+
* This component automatically renders all messages in the thread, providing the appropriate
|
173
|
+
* message context for each message. It handles different message types (user, assistant, system)
|
174
|
+
* and supports editing mode through the provided edit composer components.
|
175
|
+
*
|
176
|
+
* @example
|
177
|
+
* ```tsx
|
178
|
+
* <ThreadPrimitive.Messages
|
179
|
+
* components={{
|
180
|
+
* UserMessage: MyUserMessage,
|
181
|
+
* AssistantMessage: MyAssistantMessage,
|
182
|
+
* EditComposer: MyEditComposer
|
183
|
+
* }}
|
184
|
+
* />
|
185
|
+
* ```
|
186
|
+
*/
|
143
187
|
export const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({
|
144
188
|
components,
|
145
189
|
}) => {
|
146
190
|
const messagesLength = useThread((t) => t.messages.length);
|
147
|
-
if (messagesLength === 0) return null;
|
148
191
|
|
149
|
-
|
150
|
-
|
151
|
-
|
192
|
+
const messageElements = useMemo(() => {
|
193
|
+
if (messagesLength === 0) return null;
|
194
|
+
return Array.from({ length: messagesLength }, (_, index) => (
|
195
|
+
<ThreadMessage key={index} messageIndex={index} components={components} />
|
196
|
+
));
|
197
|
+
}, [messagesLength, components]);
|
198
|
+
|
199
|
+
return messageElements;
|
152
200
|
};
|
153
201
|
|
154
202
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
@@ -5,9 +5,28 @@ import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
|
5
5
|
|
6
6
|
export namespace ThreadPrimitiveRoot {
|
7
7
|
export type Element = ComponentRef<typeof Primitive.div>;
|
8
|
+
/**
|
9
|
+
* Props for the ThreadPrimitive.Root component.
|
10
|
+
* Accepts all standard div element props.
|
11
|
+
*/
|
8
12
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
9
13
|
}
|
10
14
|
|
15
|
+
/**
|
16
|
+
* The root container component for a thread.
|
17
|
+
*
|
18
|
+
* This component serves as the foundational wrapper for all thread-related components.
|
19
|
+
* It provides the basic structure and context needed for thread functionality.
|
20
|
+
*
|
21
|
+
* @example
|
22
|
+
* ```tsx
|
23
|
+
* <ThreadPrimitive.Root>
|
24
|
+
* <ThreadPrimitive.Viewport>
|
25
|
+
* <ThreadPrimitive.Messages components={{ Message: MyMessage }} />
|
26
|
+
* </ThreadPrimitive.Viewport>
|
27
|
+
* </ThreadPrimitive.Root>
|
28
|
+
* ```
|
29
|
+
*/
|
11
30
|
export const ThreadPrimitiveRoot = forwardRef<
|
12
31
|
ThreadPrimitiveRoot.Element,
|
13
32
|
ThreadPrimitiveRoot.Props
|
@@ -9,6 +9,11 @@ import { ThreadViewportProvider } from "../../context/providers/ThreadViewportPr
|
|
9
9
|
export namespace ThreadPrimitiveViewport {
|
10
10
|
export type Element = ComponentRef<typeof Primitive.div>;
|
11
11
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {
|
12
|
+
/**
|
13
|
+
* Whether to automatically scroll to the bottom when new messages are added.
|
14
|
+
* When enabled, the viewport will automatically scroll to show the latest content.
|
15
|
+
* @default true
|
16
|
+
*/
|
12
17
|
autoScroll?: boolean | undefined;
|
13
18
|
};
|
14
19
|
}
|
@@ -33,6 +38,20 @@ const ThreadPrimitiveViewportScrollable = forwardRef<
|
|
33
38
|
ThreadPrimitiveViewportScrollable.displayName =
|
34
39
|
"ThreadPrimitive.ViewportScrollable";
|
35
40
|
|
41
|
+
/**
|
42
|
+
* A scrollable viewport container for thread messages.
|
43
|
+
*
|
44
|
+
* This component provides a scrollable area for displaying thread messages with
|
45
|
+
* automatic scrolling capabilities. It manages the viewport state and provides
|
46
|
+
* context for child components to access viewport-related functionality.
|
47
|
+
*
|
48
|
+
* @example
|
49
|
+
* ```tsx
|
50
|
+
* <ThreadPrimitive.Viewport autoScroll={true}>
|
51
|
+
* <ThreadPrimitive.Messages components={{ Message: MyMessage }} />
|
52
|
+
* </ThreadPrimitive.Viewport>
|
53
|
+
* ```
|
54
|
+
*/
|
36
55
|
export const ThreadPrimitiveViewport = forwardRef<
|
37
56
|
ThreadPrimitiveViewport.Element,
|
38
57
|
ThreadPrimitiveViewport.Props
|
@@ -58,14 +58,18 @@ export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
|
58
58
|
archived ? s.archivedThreads.length : s.threads.length,
|
59
59
|
);
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
const listElements = useMemo(() => {
|
62
|
+
return Array.from({ length: contentLength }, (_, index) => (
|
63
|
+
<ThreadListItem
|
64
|
+
key={index}
|
65
|
+
partIndex={index}
|
66
|
+
archived={archived}
|
67
|
+
components={components}
|
68
|
+
/>
|
69
|
+
));
|
70
|
+
}, [contentLength, archived, components]);
|
71
|
+
|
72
|
+
return listElements;
|
69
73
|
};
|
70
74
|
|
71
75
|
ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
|
@@ -4,12 +4,68 @@ import {
|
|
4
4
|
CompleteAttachment,
|
5
5
|
} from "../../../types/AttachmentTypes";
|
6
6
|
|
7
|
+
/**
|
8
|
+
* Interface for handling file attachments in the assistant runtime.
|
9
|
+
*
|
10
|
+
* AttachmentAdapter provides methods for managing file attachments throughout
|
11
|
+
* their lifecycle: adding, processing, removing, and sending attachments with messages.
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* ```tsx
|
15
|
+
* const imageAdapter: AttachmentAdapter = {
|
16
|
+
* accept: "image/*",
|
17
|
+
*
|
18
|
+
* async add({ file }) {
|
19
|
+
* return {
|
20
|
+
* id: generateId(),
|
21
|
+
* type: "image",
|
22
|
+
* name: file.name,
|
23
|
+
* file,
|
24
|
+
* status: { type: "uploading" }
|
25
|
+
* };
|
26
|
+
* },
|
27
|
+
*
|
28
|
+
* async remove(attachment) {
|
29
|
+
* // Clean up resources
|
30
|
+
* },
|
31
|
+
*
|
32
|
+
* async send(attachment) {
|
33
|
+
* const url = await uploadFile(attachment.file);
|
34
|
+
* return { ...attachment, url, status: { type: "complete" } };
|
35
|
+
* }
|
36
|
+
* };
|
37
|
+
* ```
|
38
|
+
*/
|
7
39
|
export type AttachmentAdapter = {
|
40
|
+
/**
|
41
|
+
* MIME type pattern for accepted file types (e.g., "image/*", "text/plain").
|
42
|
+
*/
|
8
43
|
accept: string;
|
9
44
|
|
45
|
+
/**
|
46
|
+
* Processes a file when it's added as an attachment.
|
47
|
+
*
|
48
|
+
* @param state - Object containing the file to process
|
49
|
+
* @param state.file - The File object to be attached
|
50
|
+
* @returns Promise or AsyncGenerator yielding PendingAttachment states
|
51
|
+
*/
|
10
52
|
add(state: {
|
11
53
|
file: File;
|
12
54
|
}): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Removes an attachment and cleans up associated resources.
|
58
|
+
*
|
59
|
+
* @param attachment - The attachment to remove
|
60
|
+
* @returns Promise that resolves when removal is complete
|
61
|
+
*/
|
13
62
|
remove(attachment: Attachment): Promise<void>;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Finalizes an attachment for sending with a message.
|
66
|
+
*
|
67
|
+
* @param attachment - The pending attachment to finalize
|
68
|
+
* @returns Promise resolving to the complete attachment
|
69
|
+
*/
|
14
70
|
send(attachment: PendingAttachment): Promise<CompleteAttachment>;
|
15
71
|
};
|
@@ -1,10 +1,43 @@
|
|
1
1
|
import { ThreadMessage } from "../../../types/AssistantTypes";
|
2
2
|
|
3
|
+
/**
|
4
|
+
* Feedback data structure for rating messages.
|
5
|
+
*/
|
3
6
|
type FeedbackAdapterFeedback = {
|
7
|
+
/** The message being rated */
|
4
8
|
message: ThreadMessage;
|
9
|
+
/** The type of feedback being provided */
|
5
10
|
type: "positive" | "negative";
|
6
11
|
};
|
7
12
|
|
13
|
+
/**
|
14
|
+
* Interface for handling user feedback on assistant messages.
|
15
|
+
*
|
16
|
+
* FeedbackAdapter allows users to provide positive or negative feedback
|
17
|
+
* on assistant responses, which can be used for analytics, model improvement,
|
18
|
+
* or user experience tracking.
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```tsx
|
22
|
+
* const feedbackAdapter: FeedbackAdapter = {
|
23
|
+
* submit: (feedback) => {
|
24
|
+
* console.log(`User gave ${feedback.type} feedback on message:`, feedback.message.id);
|
25
|
+
*
|
26
|
+
* // Send to analytics service
|
27
|
+
* analytics.track('message_feedback', {
|
28
|
+
* messageId: feedback.message.id,
|
29
|
+
* feedbackType: feedback.type,
|
30
|
+
* messageContent: feedback.message.content
|
31
|
+
* });
|
32
|
+
* }
|
33
|
+
* };
|
34
|
+
* ```
|
35
|
+
*/
|
8
36
|
export type FeedbackAdapter = {
|
37
|
+
/**
|
38
|
+
* Submits user feedback for a message.
|
39
|
+
*
|
40
|
+
* @param feedback - The feedback data containing message and rating type
|
41
|
+
*/
|
9
42
|
submit: (feedback: FeedbackAdapterFeedback) => void;
|
10
43
|
};
|
@@ -1,24 +1,71 @@
|
|
1
1
|
import { Unsubscribe } from "../../../types";
|
2
2
|
|
3
|
+
/**
|
4
|
+
* Types and interfaces for speech synthesis (text-to-speech) functionality.
|
5
|
+
*/
|
3
6
|
export namespace SpeechSynthesisAdapter {
|
7
|
+
/**
|
8
|
+
* Status of a speech synthesis operation.
|
9
|
+
*/
|
4
10
|
export type Status =
|
5
11
|
| {
|
12
|
+
/** Speech is starting or currently running */
|
6
13
|
type: "starting" | "running";
|
7
14
|
}
|
8
15
|
| {
|
16
|
+
/** Speech has ended */
|
9
17
|
type: "ended";
|
18
|
+
/** Reason why speech ended */
|
10
19
|
reason: "finished" | "cancelled" | "error";
|
20
|
+
/** Error details if speech ended due to error */
|
11
21
|
error?: unknown;
|
12
22
|
};
|
13
23
|
|
24
|
+
/**
|
25
|
+
* Represents a single speech utterance with control and status tracking.
|
26
|
+
*/
|
14
27
|
export type Utterance = {
|
28
|
+
/** Current status of the utterance */
|
15
29
|
status: Status;
|
30
|
+
/** Cancel the current speech */
|
16
31
|
cancel: () => void;
|
32
|
+
/** Subscribe to status changes */
|
17
33
|
subscribe: (callback: () => void) => Unsubscribe;
|
18
34
|
};
|
19
35
|
}
|
20
36
|
|
37
|
+
/**
|
38
|
+
* Interface for text-to-speech functionality.
|
39
|
+
*
|
40
|
+
* SpeechSynthesisAdapter provides the ability to convert text content
|
41
|
+
* into spoken audio, with status tracking and cancellation support.
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* ```tsx
|
45
|
+
* const speechAdapter: SpeechSynthesisAdapter = {
|
46
|
+
* speak: (text) => {
|
47
|
+
* const utterance = new SpeechSynthesisUtterance(text);
|
48
|
+
* speechSynthesis.speak(utterance);
|
49
|
+
*
|
50
|
+
* return {
|
51
|
+
* status: { type: "starting" },
|
52
|
+
* cancel: () => speechSynthesis.cancel(),
|
53
|
+
* subscribe: (callback) => {
|
54
|
+
* utterance.addEventListener('end', callback);
|
55
|
+
* return () => utterance.removeEventListener('end', callback);
|
56
|
+
* }
|
57
|
+
* };
|
58
|
+
* }
|
59
|
+
* };
|
60
|
+
* ```
|
61
|
+
*/
|
21
62
|
export type SpeechSynthesisAdapter = {
|
63
|
+
/**
|
64
|
+
* Converts text to speech and returns an utterance object for control.
|
65
|
+
*
|
66
|
+
* @param text - The text content to speak
|
67
|
+
* @returns An utterance object with status and control methods
|
68
|
+
*/
|
22
69
|
speak: (text: string) => SpeechSynthesisAdapter.Utterance;
|
23
70
|
};
|
24
71
|
|
@@ -36,6 +36,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
|
36
36
|
protected readonly repository = new MessageRepository();
|
37
37
|
public abstract get adapters(): BaseThreadAdapters | undefined;
|
38
38
|
public abstract get isDisabled(): boolean;
|
39
|
+
public abstract get isLoading(): boolean;
|
39
40
|
public abstract get suggestions(): readonly ThreadSuggestion[];
|
40
41
|
public abstract get extras(): unknown;
|
41
42
|
|
@@ -101,6 +101,7 @@ export type ThreadRuntimeCore = Readonly<{
|
|
101
101
|
|
102
102
|
capabilities: Readonly<RuntimeCapabilities>;
|
103
103
|
isDisabled: boolean;
|
104
|
+
isLoading: boolean;
|
104
105
|
messages: readonly ThreadMessage[];
|
105
106
|
state: ReadonlyJSONValue;
|
106
107
|
suggestions: readonly ThreadSuggestion[];
|
@@ -20,6 +20,7 @@ export type ExternalStoreThreadListAdapter = {
|
|
20
20
|
* @deprecated This API is still under active development and might change without notice.
|
21
21
|
*/
|
22
22
|
threadId?: string | undefined;
|
23
|
+
isLoading?: boolean | undefined;
|
23
24
|
threads?: readonly ExternalStoreThreadData<"regular">[] | undefined;
|
24
25
|
archivedThreads?: readonly ExternalStoreThreadData<"archived">[] | undefined;
|
25
26
|
/**
|
@@ -51,6 +52,7 @@ type ExternalStoreMessageConverterAdapter<T> = {
|
|
51
52
|
type ExternalStoreAdapterBase<T> = {
|
52
53
|
isDisabled?: boolean | undefined;
|
53
54
|
isRunning?: boolean | undefined;
|
55
|
+
isLoading?: boolean | undefined;
|
54
56
|
messages: readonly T[];
|
55
57
|
suggestions?: readonly ThreadSuggestion[] | undefined;
|
56
58
|
extras?: unknown;
|
@@ -24,6 +24,10 @@ export class ExternalStoreThreadListRuntimeCore
|
|
24
24
|
private _threads: readonly string[] = DEFAULT_THREADS;
|
25
25
|
private _archivedThreads: readonly string[] = EMPTY_ARRAY;
|
26
26
|
|
27
|
+
public get isLoading() {
|
28
|
+
return this.adapter.isLoading ?? false;
|
29
|
+
}
|
30
|
+
|
27
31
|
public get newThreadId() {
|
28
32
|
return undefined;
|
29
33
|
}
|
@@ -53,6 +53,9 @@ export class ExternalStoreThreadRuntimeCore
|
|
53
53
|
|
54
54
|
private _messages!: readonly ThreadMessage[];
|
55
55
|
public isDisabled!: boolean;
|
56
|
+
public get isLoading() {
|
57
|
+
return this._store.isLoading ?? false;
|
58
|
+
}
|
56
59
|
|
57
60
|
public override get messages() {
|
58
61
|
return this._messages;
|
@@ -2,21 +2,21 @@ import { parsePartialJsonObject } from "assistant-stream/utils";
|
|
2
2
|
import { generateId } from "../../internal";
|
3
3
|
import {
|
4
4
|
MessageStatus,
|
5
|
-
|
6
|
-
|
5
|
+
TextMessagePart,
|
6
|
+
ImageMessagePart,
|
7
7
|
ThreadMessage,
|
8
|
-
|
8
|
+
ThreadAssistantMessagePart,
|
9
9
|
ThreadAssistantMessage,
|
10
|
-
|
10
|
+
ThreadUserMessagePart,
|
11
11
|
ThreadUserMessage,
|
12
12
|
ThreadSystemMessage,
|
13
13
|
CompleteAttachment,
|
14
|
-
|
15
|
-
|
14
|
+
FileMessagePart,
|
15
|
+
Unstable_AudioMessagePart,
|
16
16
|
} from "../../types";
|
17
17
|
import {
|
18
|
-
|
19
|
-
|
18
|
+
ReasoningMessagePart,
|
19
|
+
SourceMessagePart,
|
20
20
|
ThreadStep,
|
21
21
|
} from "../../types/AssistantTypes";
|
22
22
|
import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
|
@@ -26,12 +26,12 @@ export type ThreadMessageLike = {
|
|
26
26
|
readonly content:
|
27
27
|
| string
|
28
28
|
| readonly (
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
| TextMessagePart
|
30
|
+
| ReasoningMessagePart
|
31
|
+
| SourceMessagePart
|
32
|
+
| ImageMessagePart
|
33
|
+
| FileMessagePart
|
34
|
+
| Unstable_AudioMessagePart
|
35
35
|
| {
|
36
36
|
readonly type: "tool-call";
|
37
37
|
readonly toolCallId?: string;
|
@@ -91,7 +91,7 @@ export const fromThreadMessageLike = (
|
|
91
91
|
...common,
|
92
92
|
role,
|
93
93
|
content: content
|
94
|
-
.map((part):
|
94
|
+
.map((part): ThreadAssistantMessagePart | null => {
|
95
95
|
const type = part.type;
|
96
96
|
switch (type) {
|
97
97
|
case "text":
|
@@ -126,7 +126,7 @@ export const fromThreadMessageLike = (
|
|
126
126
|
default: {
|
127
127
|
const unhandledType: "image" | "audio" = type;
|
128
128
|
throw new Error(
|
129
|
-
`Unsupported assistant
|
129
|
+
`Unsupported assistant message part type: ${unhandledType}`,
|
130
130
|
);
|
131
131
|
}
|
132
132
|
}
|
@@ -146,7 +146,7 @@ export const fromThreadMessageLike = (
|
|
146
146
|
return {
|
147
147
|
...common,
|
148
148
|
role,
|
149
|
-
content: content.map((part):
|
149
|
+
content: content.map((part): ThreadUserMessagePart => {
|
150
150
|
const type = part.type;
|
151
151
|
switch (type) {
|
152
152
|
case "text":
|
@@ -158,7 +158,7 @@ export const fromThreadMessageLike = (
|
|
158
158
|
default: {
|
159
159
|
const unhandledType: "tool-call" | "reasoning" | "source" = type;
|
160
160
|
throw new Error(
|
161
|
-
`Unsupported user
|
161
|
+
`Unsupported user message part type: ${unhandledType}`,
|
162
162
|
);
|
163
163
|
}
|
164
164
|
}
|
@@ -172,13 +172,13 @@ export const fromThreadMessageLike = (
|
|
172
172
|
case "system":
|
173
173
|
if (content.length !== 1 || content[0]!.type !== "text")
|
174
174
|
throw new Error(
|
175
|
-
"System messages must have exactly one text
|
175
|
+
"System messages must have exactly one text message part.",
|
176
176
|
);
|
177
177
|
|
178
178
|
return {
|
179
179
|
...common,
|
180
180
|
role,
|
181
|
-
content: content as [
|
181
|
+
content: content as [TextMessagePart],
|
182
182
|
metadata: {
|
183
183
|
custom: metadata?.custom ?? {},
|
184
184
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { ThreadState } from "../../api";
|
3
|
-
import {
|
3
|
+
import { useMessagePart, useMessage } from "../../context";
|
4
4
|
import { ThreadMessage } from "../../types";
|
5
5
|
import {
|
6
6
|
useExternalMessageConverter,
|
@@ -50,13 +50,13 @@ export const createMessageConverter = <T extends object>(
|
|
50
50
|
return first;
|
51
51
|
},
|
52
52
|
useOriginalMessages: () => {
|
53
|
-
const
|
53
|
+
const MessagePartMessages = useMessagePart<T[]>({
|
54
54
|
optional: true,
|
55
55
|
selector: getExternalStoreMessages,
|
56
56
|
});
|
57
57
|
|
58
58
|
const messageMessages = useMessage<T[]>(getExternalStoreMessages);
|
59
|
-
const messages =
|
59
|
+
const messages = MessagePartMessages ?? messageMessages;
|
60
60
|
if (messages.length === 0) throw new Error("No original messages found");
|
61
61
|
return messages;
|
62
62
|
},
|
@@ -8,7 +8,7 @@ import {
|
|
8
8
|
} from "./getExternalStoreMessage";
|
9
9
|
import { fromThreadMessageLike, ThreadMessageLike } from "./ThreadMessageLike";
|
10
10
|
import { getAutoStatus, isAutoStatus } from "./auto-status";
|
11
|
-
import {
|
11
|
+
import { ToolCallMessagePart } from "../../types";
|
12
12
|
|
13
13
|
export namespace useExternalMessageConverter {
|
14
14
|
export type Message =
|
@@ -61,7 +61,7 @@ const joinExternalMessages = (
|
|
61
61
|
if (toolCallIdx !== -1) {
|
62
62
|
const toolCall = assistantMessage.content[
|
63
63
|
toolCallIdx
|
64
|
-
]! as
|
64
|
+
]! as ToolCallMessagePart;
|
65
65
|
if (output.toolName) {
|
66
66
|
if (toolCall.toolName !== output.toolName)
|
67
67
|
throw new Error(
|
@@ -1,25 +1,25 @@
|
|
1
1
|
import type {
|
2
|
-
|
2
|
+
FileMessagePart,
|
3
3
|
MessageStatus,
|
4
|
-
|
4
|
+
ReasoningMessagePart,
|
5
5
|
RunConfig,
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
SourceMessagePart,
|
7
|
+
TextMessagePart,
|
8
|
+
ThreadAssistantMessagePart,
|
9
9
|
ThreadMessage,
|
10
10
|
ThreadStep,
|
11
|
-
|
11
|
+
ToolCallMessagePart,
|
12
12
|
} from "../../types/AssistantTypes";
|
13
13
|
import type { ModelContext } from "../../model-context/ModelContextTypes";
|
14
14
|
import { ReadonlyJSONValue } from "assistant-stream/utils";
|
15
15
|
|
16
16
|
export type ChatModelRunUpdate = {
|
17
|
-
readonly content: readonly
|
17
|
+
readonly content: readonly ThreadAssistantMessagePart[];
|
18
18
|
readonly metadata?: Record<string, unknown>;
|
19
19
|
};
|
20
20
|
|
21
21
|
export type ChatModelRunResult = {
|
22
|
-
readonly content?: readonly
|
22
|
+
readonly content?: readonly ThreadAssistantMessagePart[] | undefined;
|
23
23
|
readonly status?: MessageStatus | undefined;
|
24
24
|
readonly metadata?: {
|
25
25
|
readonly unstable_state?: ReadonlyJSONValue;
|
@@ -32,11 +32,11 @@ export type ChatModelRunResult = {
|
|
32
32
|
|
33
33
|
export type CoreChatModelRunResult = Omit<ChatModelRunResult, "content"> & {
|
34
34
|
readonly content: readonly (
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
| TextMessagePart
|
36
|
+
| ReasoningMessagePart
|
37
|
+
| ToolCallMessagePart
|
38
|
+
| SourceMessagePart
|
39
|
+
| FileMessagePart
|
40
40
|
)[];
|
41
41
|
};
|
42
42
|
|
@@ -4,7 +4,7 @@ import { ThreadMessageLike } from "../external-store";
|
|
4
4
|
import { FeedbackAdapter } from "../adapters/feedback/FeedbackAdapter";
|
5
5
|
import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
|
6
6
|
import { ChatModelAdapter } from "./ChatModelAdapter";
|
7
|
-
import { AssistantCloud } from "
|
7
|
+
import { AssistantCloud } from "assistant-cloud";
|
8
8
|
import { SuggestionAdapter } from "../adapters";
|
9
9
|
|
10
10
|
export type LocalRuntimeOptionsBase = {
|