@assistant-ui/react 0.11.58 → 0.12.0
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/client/ModelContextClient.d.ts +2 -6
- package/dist/client/ModelContextClient.d.ts.map +1 -1
- package/dist/client/ModelContextClient.js +13 -10
- package/dist/client/ModelContextClient.js.map +1 -1
- package/dist/client/NoOpComposerClient.d.ts +4 -6
- package/dist/client/NoOpComposerClient.d.ts.map +1 -1
- package/dist/client/NoOpComposerClient.js +42 -40
- package/dist/client/NoOpComposerClient.js.map +1 -1
- package/dist/client/ThreadMessageClient.d.ts +2 -6
- package/dist/client/ThreadMessageClient.d.ts.map +1 -1
- package/dist/client/ThreadMessageClient.js +87 -81
- package/dist/client/ThreadMessageClient.js.map +1 -1
- package/dist/client/Tools.d.ts +4 -6
- package/dist/client/Tools.d.ts.map +1 -1
- package/dist/client/Tools.js +33 -31
- package/dist/client/Tools.js.map +1 -1
- package/dist/context/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentByIndexProvider.js +9 -12
- package/dist/context/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/context/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageByIndexProvider.js +7 -22
- package/dist/context/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/context/providers/MessageProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageProvider.js +4 -13
- package/dist/context/providers/MessageProvider.js.map +1 -1
- package/dist/context/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/PartByIndexProvider.js +5 -7
- package/dist/context/providers/PartByIndexProvider.js.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.js +16 -22
- package/dist/context/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.js +9 -35
- package/dist/context/providers/ThreadListItemProvider.js.map +1 -1
- package/dist/context/react/index.d.ts +0 -4
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +0 -6
- package/dist/context/react/index.js.map +1 -1
- package/dist/devtools/DevToolsHooks.d.ts +3 -3
- package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
- package/dist/devtools/DevToolsHooks.js +5 -5
- package/dist/devtools/DevToolsHooks.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +3 -3
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/RuntimeAdapter.d.ts +1 -5
- package/dist/legacy-runtime/RuntimeAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/RuntimeAdapter.js +25 -4
- package/dist/legacy-runtime/RuntimeAdapter.js.map +1 -1
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.d.ts +4 -6
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.js +8 -8
- package/dist/legacy-runtime/client/AttachmentRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts +6 -6
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js +38 -37
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.d.ts +4 -6
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js +9 -12
- package/dist/legacy-runtime/client/MessagePartRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.d.ts +5 -6
- package/dist/legacy-runtime/client/MessageRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/MessageRuntimeClient.js +38 -44
- package/dist/legacy-runtime/client/MessageRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.d.ts +4 -6
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.js +23 -23
- package/dist/legacy-runtime/client/ThreadListItemRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.d.ts +5 -6
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.js +30 -31
- package/dist/legacy-runtime/client/ThreadListRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/client/ThreadRuntimeClient.d.ts +4 -6
- package/dist/legacy-runtime/client/ThreadRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ThreadRuntimeClient.js +40 -42
- package/dist/legacy-runtime/client/ThreadRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js +13 -13
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts +8 -0
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js +14 -0
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +4 -4
- package/dist/legacy-runtime/hooks/AssistantContext.js +4 -4
- package/dist/legacy-runtime/hooks/AssistantContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +14 -14
- package/dist/legacy-runtime/hooks/AttachmentContext.js +5 -5
- package/dist/legacy-runtime/hooks/AttachmentContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +10 -10
- package/dist/legacy-runtime/hooks/ComposerContext.js +8 -8
- package/dist/legacy-runtime/hooks/ComposerContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +9 -9
- package/dist/legacy-runtime/hooks/MessageContext.js +9 -9
- package/dist/legacy-runtime/hooks/MessageContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/MessagePartContext.js +4 -4
- package/dist/legacy-runtime/hooks/MessagePartContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +8 -8
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.js +8 -8
- package/dist/legacy-runtime/hooks/ThreadContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +2 -2
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +5 -5
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts +1 -1
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.js +3 -3
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +5 -5
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +15 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.js +1 -1
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js +2 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js +2 -5
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +5 -5
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js +7 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +5 -5
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -8
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +3 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +4 -4
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/model-context/useAssistantInstructions.js +4 -4
- package/dist/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/model-context/useAssistantTool.js +6 -6
- package/dist/model-context/useAssistantTool.js.map +1 -1
- package/dist/model-context/useAssistantToolUI.js +4 -4
- package/dist/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +10 -10
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +5 -5
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +5 -5
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +5 -5
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +5 -5
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +5 -5
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +5 -5
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +5 -5
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +2 -2
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +4 -4
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js +2 -2
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +4 -4
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +2 -2
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +2 -2
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +5 -5
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +2 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +5 -5
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +6 -6
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +4 -4
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +4 -3
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +5 -5
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js +5 -5
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +2 -2
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.d.ts +1 -1
- package/dist/primitives/composer/ComposerIf.js +3 -3
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +19 -19
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +5 -5
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +6 -5
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js +2 -2
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/index.d.ts +0 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +0 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +4 -3
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageError.js +2 -2
- package/dist/primitives/message/MessageError.js.map +1 -1
- package/dist/primitives/message/MessageIf.d.ts +1 -1
- package/dist/primitives/message/MessageIf.js +3 -3
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +10 -9
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +10 -9
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js +4 -4
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +2 -2
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +2 -2
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +2 -2
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +2 -2
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +2 -2
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +2 -2
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +2 -2
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +2 -2
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.d.ts +1 -1
- package/dist/primitives/thread/ThreadIf.js +3 -3
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +5 -4
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +10 -10
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportSlack.js +2 -2
- package/dist/primitives/thread/ThreadViewportSlack.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +4 -4
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +3 -2
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +4 -4
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +4 -4
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +4 -4
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +4 -4
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +4 -4
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/scopes/attachment.d.ts +22 -0
- package/dist/types/scopes/attachment.d.ts.map +1 -0
- package/dist/types/scopes/attachment.js +2 -0
- package/dist/types/scopes/attachment.js.map +1 -0
- package/dist/{client/types/Composer.d.ts → types/scopes/composer.d.ts} +29 -9
- package/dist/types/scopes/composer.d.ts.map +1 -0
- package/dist/types/scopes/composer.js +2 -0
- package/dist/types/scopes/composer.js.map +1 -0
- package/dist/types/scopes/index.d.ts +10 -0
- package/dist/types/scopes/index.d.ts.map +1 -0
- package/dist/types/scopes/index.js +2 -0
- package/dist/types/scopes/index.js.map +1 -0
- package/dist/{client/types/Message.d.ts → types/scopes/message.d.ts} +35 -27
- package/dist/types/scopes/message.d.ts.map +1 -0
- package/dist/types/scopes/message.js +2 -0
- package/dist/types/scopes/message.js.map +1 -0
- package/dist/types/scopes/modelContext.d.ts +12 -0
- package/dist/types/scopes/modelContext.d.ts.map +1 -0
- package/dist/types/scopes/modelContext.js +2 -0
- package/dist/types/scopes/modelContext.js.map +1 -0
- package/dist/types/scopes/part.d.ts +37 -0
- package/dist/types/scopes/part.d.ts.map +1 -0
- package/dist/types/scopes/part.js +2 -0
- package/dist/types/scopes/part.js.map +1 -0
- package/dist/{client/types/Thread.d.ts → types/scopes/thread.d.ts} +45 -25
- package/dist/types/scopes/thread.d.ts.map +1 -0
- package/dist/types/scopes/thread.js +2 -0
- package/dist/types/scopes/thread.js.map +1 -0
- package/dist/types/scopes/threadListItem.d.ts +50 -0
- package/dist/types/scopes/threadListItem.d.ts.map +1 -0
- package/dist/types/scopes/threadListItem.js +2 -0
- package/dist/types/scopes/threadListItem.js.map +1 -0
- package/dist/types/scopes/threads.d.ts +28 -0
- package/dist/types/scopes/threads.d.ts.map +1 -0
- package/dist/types/scopes/threads.js +2 -0
- package/dist/types/scopes/threads.js.map +1 -0
- package/dist/types/scopes/tools.d.ts +14 -0
- package/dist/types/scopes/tools.d.ts.map +1 -0
- package/dist/types/scopes/tools.js +2 -0
- package/dist/types/scopes/tools.js.map +1 -0
- package/dist/types/store-augmentation.d.ts +24 -0
- package/dist/types/store-augmentation.d.ts.map +1 -0
- package/dist/types/store-augmentation.js +2 -0
- package/dist/types/store-augmentation.js.map +1 -0
- package/dist/utils/smooth/SmoothContext.js +3 -3
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +2 -2
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +2 -2
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +3 -2
- package/src/client/ModelContextClient.ts +19 -12
- package/src/client/NoOpComposerClient.tsx +45 -42
- package/src/client/ThreadMessageClient.tsx +99 -86
- package/src/client/Tools.ts +73 -62
- package/src/context/providers/AttachmentByIndexProvider.tsx +9 -17
- package/src/context/providers/MessageByIndexProvider.tsx +7 -32
- package/src/context/providers/MessageProvider.tsx +4 -16
- package/src/context/providers/PartByIndexProvider.tsx +5 -11
- package/src/context/providers/TextMessagePartProvider.tsx +24 -32
- package/src/context/providers/ThreadListItemProvider.tsx +9 -45
- package/src/context/react/index.ts +0 -13
- package/src/devtools/DevToolsHooks.ts +7 -7
- package/src/index.ts +42 -0
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +4 -7
- package/src/legacy-runtime/RuntimeAdapter.ts +32 -4
- package/src/legacy-runtime/client/AttachmentRuntimeClient.ts +7 -9
- package/src/legacy-runtime/client/ComposerRuntimeClient.ts +54 -50
- package/src/legacy-runtime/client/MessagePartRuntimeClient.ts +12 -17
- package/src/legacy-runtime/client/MessageRuntimeClient.ts +40 -34
- package/src/legacy-runtime/client/ThreadListItemRuntimeClient.ts +17 -17
- package/src/legacy-runtime/client/ThreadListRuntimeClient.ts +47 -42
- package/src/legacy-runtime/client/ThreadRuntimeClient.ts +52 -49
- package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.tsx +13 -16
- package/src/legacy-runtime/cloud/auiV0.ts +27 -1
- package/src/legacy-runtime/hooks/AssistantContext.ts +7 -7
- package/src/legacy-runtime/hooks/AttachmentContext.ts +7 -7
- package/src/legacy-runtime/hooks/ComposerContext.ts +15 -15
- package/src/legacy-runtime/hooks/MessageContext.ts +14 -14
- package/src/legacy-runtime/hooks/MessagePartContext.ts +6 -6
- package/src/legacy-runtime/hooks/ThreadContext.ts +13 -17
- package/src/legacy-runtime/hooks/ThreadListItemContext.ts +7 -7
- package/src/legacy-runtime/runtime/ThreadListItemRuntime.ts +4 -4
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +5 -7
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +17 -1
- package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.tsx +1 -1
- package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx +3 -3
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.tsx +2 -2
- package/src/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.tsx +4 -6
- package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.tsx +5 -5
- package/src/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.tsx +6 -2
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx +11 -14
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +9 -8
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx +3 -3
- package/src/model-context/makeAssistantVisible.tsx +4 -4
- package/src/model-context/useAssistantInstructions.tsx +4 -4
- package/src/model-context/useAssistantTool.tsx +6 -6
- package/src/model-context/useAssistantToolUI.tsx +4 -4
- package/src/primitives/actionBar/ActionBarCopy.tsx +10 -10
- package/src/primitives/actionBar/ActionBarEdit.tsx +5 -5
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +5 -5
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +5 -5
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +5 -5
- package/src/primitives/actionBar/ActionBarReload.tsx +5 -5
- package/src/primitives/actionBar/ActionBarSpeak.tsx +5 -5
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +5 -5
- package/src/primitives/actionBar/useActionBarFloatStatus.tsx +2 -2
- package/src/primitives/assistantModal/AssistantModalRoot.tsx +4 -4
- package/src/primitives/attachment/AttachmentName.tsx +2 -2
- package/src/primitives/attachment/AttachmentRemove.tsx +4 -4
- package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerCount.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerNext.tsx +5 -5
- package/src/primitives/branchPicker/BranchPickerNumber.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +5 -5
- package/src/primitives/composer/ComposerAddAttachment.tsx +6 -6
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +4 -4
- package/src/primitives/composer/ComposerAttachments.tsx +4 -8
- package/src/primitives/composer/ComposerCancel.tsx +5 -5
- package/src/primitives/composer/ComposerDictate.tsx +5 -5
- package/src/primitives/composer/ComposerDictationTranscript.tsx +2 -2
- package/src/primitives/composer/ComposerIf.tsx +3 -3
- package/src/primitives/composer/ComposerInput.tsx +19 -19
- package/src/primitives/composer/ComposerSend.tsx +5 -5
- package/src/primitives/composer/ComposerStopDictation.tsx +6 -7
- package/src/primitives/error/ErrorMessage.tsx +2 -2
- package/src/primitives/index.ts +0 -2
- package/src/primitives/message/MessageAttachments.tsx +4 -6
- package/src/primitives/message/MessageError.tsx +2 -2
- package/src/primitives/message/MessageIf.tsx +3 -3
- package/src/primitives/message/MessageParts.tsx +10 -13
- package/src/primitives/message/MessagePartsGrouped.tsx +10 -13
- package/src/primitives/message/MessageRoot.tsx +4 -4
- package/src/primitives/messagePart/MessagePartInProgress.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartData.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartFile.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartImage.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartReasoning.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartSource.tsx +2 -2
- package/src/primitives/messagePart/useMessagePartText.tsx +2 -2
- package/src/primitives/thread/ThreadEmpty.tsx +2 -2
- package/src/primitives/thread/ThreadIf.tsx +3 -3
- package/src/primitives/thread/ThreadMessages.tsx +5 -8
- package/src/primitives/thread/ThreadSuggestion.tsx +10 -10
- package/src/primitives/thread/ThreadViewportSlack.tsx +2 -2
- package/src/primitives/thread/useThreadViewportAutoScroll.tsx +4 -4
- package/src/primitives/threadList/ThreadListItems.tsx +3 -5
- package/src/primitives/threadList/ThreadListNew.tsx +4 -4
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +4 -4
- package/src/primitives/threadListItem/ThreadListItemDelete.ts +4 -4
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -2
- package/src/primitives/threadListItem/ThreadListItemTitle.tsx +2 -2
- package/src/primitives/threadListItem/ThreadListItemTrigger.ts +4 -4
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +4 -4
- package/src/types/index.ts +0 -8
- package/src/types/scopes/attachment.ts +22 -0
- package/src/{client/types/Composer.ts → types/scopes/composer.ts} +26 -9
- package/src/types/scopes/index.ts +50 -0
- package/src/{client/types/Message.ts → types/scopes/message.ts} +30 -38
- package/src/types/scopes/modelContext.ts +14 -0
- package/src/{client/types/Part.ts → types/scopes/part.ts} +21 -14
- package/src/{client/types/Thread.ts → types/scopes/thread.ts} +44 -53
- package/src/types/scopes/threadListItem.ts +44 -0
- package/src/{client/types/ThreadList.ts → types/scopes/threads.ts} +17 -17
- package/src/types/scopes/tools.ts +19 -0
- package/src/types/store-augmentation.ts +25 -0
- package/src/utils/smooth/SmoothContext.tsx +3 -3
- package/src/utils/smooth/useSmooth.tsx +2 -2
- package/src/utils/useToolArgsFieldStatus.tsx +2 -2
- package/dist/client/AssistantClient.d.ts +0 -21
- package/dist/client/AssistantClient.d.ts.map +0 -1
- package/dist/client/AssistantClient.js +0 -96
- package/dist/client/AssistantClient.js.map +0 -1
- package/dist/client/EventContext.d.ts +0 -4
- package/dist/client/EventContext.d.ts.map +0 -1
- package/dist/client/EventContext.js +0 -12
- package/dist/client/EventContext.js.map +0 -1
- package/dist/client/ModelContext.d.ts +0 -8
- package/dist/client/ModelContext.d.ts.map +0 -1
- package/dist/client/ModelContext.js +0 -12
- package/dist/client/ModelContext.js.map +0 -1
- package/dist/client/types/Attachment.d.ts +0 -7
- package/dist/client/types/Attachment.d.ts.map +0 -1
- package/dist/client/types/Attachment.js +0 -2
- package/dist/client/types/Attachment.js.map +0 -1
- package/dist/client/types/Composer.d.ts.map +0 -1
- package/dist/client/types/Composer.js +0 -2
- package/dist/client/types/Composer.js.map +0 -1
- package/dist/client/types/Message.d.ts.map +0 -1
- package/dist/client/types/Message.js +0 -2
- package/dist/client/types/Message.js.map +0 -1
- package/dist/client/types/ModelContext.d.ts +0 -12
- package/dist/client/types/ModelContext.d.ts.map +0 -1
- package/dist/client/types/ModelContext.js +0 -2
- package/dist/client/types/ModelContext.js.map +0 -1
- package/dist/client/types/Part.d.ts +0 -22
- package/dist/client/types/Part.d.ts.map +0 -1
- package/dist/client/types/Part.js +0 -2
- package/dist/client/types/Part.js.map +0 -1
- package/dist/client/types/Thread.d.ts.map +0 -1
- package/dist/client/types/Thread.js +0 -2
- package/dist/client/types/Thread.js.map +0 -1
- package/dist/client/types/ThreadList.d.ts +0 -24
- package/dist/client/types/ThreadList.d.ts.map +0 -1
- package/dist/client/types/ThreadList.js +0 -2
- package/dist/client/types/ThreadList.js.map +0 -1
- package/dist/client/types/ThreadListItem.d.ts +0 -23
- package/dist/client/types/ThreadListItem.d.ts.map +0 -1
- package/dist/client/types/ThreadListItem.js +0 -2
- package/dist/client/types/ThreadListItem.js.map +0 -1
- package/dist/client/types/Tools.d.ts +0 -13
- package/dist/client/types/Tools.d.ts.map +0 -1
- package/dist/client/types/Tools.js +0 -2
- package/dist/client/types/Tools.js.map +0 -1
- package/dist/client/util-hooks/tapLookupResources.d.ts +0 -15
- package/dist/client/util-hooks/tapLookupResources.d.ts.map +0 -1
- package/dist/client/util-hooks/tapLookupResources.js +0 -26
- package/dist/client/util-hooks/tapLookupResources.js.map +0 -1
- package/dist/context/react/AssistantApiContext.d.ts +0 -138
- package/dist/context/react/AssistantApiContext.d.ts.map +0 -1
- package/dist/context/react/AssistantApiContext.js +0 -158
- package/dist/context/react/AssistantApiContext.js.map +0 -1
- package/dist/context/react/hooks/useAssistantEvent.d.ts +0 -3
- package/dist/context/react/hooks/useAssistantEvent.d.ts.map +0 -1
- package/dist/context/react/hooks/useAssistantEvent.js +0 -13
- package/dist/context/react/hooks/useAssistantEvent.js.map +0 -1
- package/dist/context/react/hooks/useAssistantState.d.ts +0 -3
- package/dist/context/react/hooks/useAssistantState.d.ts.map +0 -1
- package/dist/context/react/hooks/useAssistantState.js +0 -42
- package/dist/context/react/hooks/useAssistantState.js.map +0 -1
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.d.ts +0 -11
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.d.ts.map +0 -1
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.js +0 -44
- package/dist/legacy-runtime/client/EventManagerRuntimeClient.js.map +0 -1
- package/dist/primitives/assistant/AssistantIf.d.ts +0 -12
- package/dist/primitives/assistant/AssistantIf.d.ts.map +0 -1
- package/dist/primitives/assistant/AssistantIf.js +0 -11
- package/dist/primitives/assistant/AssistantIf.js.map +0 -1
- package/dist/types/EventTypes.d.ts +0 -57
- package/dist/types/EventTypes.d.ts.map +0 -1
- package/dist/types/EventTypes.js +0 -17
- package/dist/types/EventTypes.js.map +0 -1
- package/dist/utils/tap-store/derived-scopes.d.ts +0 -75
- package/dist/utils/tap-store/derived-scopes.d.ts.map +0 -1
- package/dist/utils/tap-store/derived-scopes.js +0 -56
- package/dist/utils/tap-store/derived-scopes.js.map +0 -1
- package/dist/utils/tap-store/index.d.ts +0 -4
- package/dist/utils/tap-store/index.d.ts.map +0 -1
- package/dist/utils/tap-store/index.js +0 -4
- package/dist/utils/tap-store/index.js.map +0 -1
- package/dist/utils/tap-store/store.d.ts +0 -14
- package/dist/utils/tap-store/store.d.ts.map +0 -1
- package/dist/utils/tap-store/store.js +0 -9
- package/dist/utils/tap-store/store.js.map +0 -1
- package/dist/utils/tap-store/tap-api.d.ts +0 -13
- package/dist/utils/tap-store/tap-api.d.ts.map +0 -1
- package/dist/utils/tap-store/tap-api.js +0 -49
- package/dist/utils/tap-store/tap-api.js.map +0 -1
- package/src/client/AssistantClient.ts +0 -175
- package/src/client/EventContext.ts +0 -22
- package/src/client/ModelContext.ts +0 -28
- package/src/client/types/Attachment.ts +0 -13
- package/src/client/types/ModelContext.ts +0 -14
- package/src/client/types/ThreadListItem.ts +0 -26
- package/src/client/types/Tools.ts +0 -19
- package/src/client/util-hooks/tapLookupResources.ts +0 -45
- package/src/context/react/AssistantApiContext.tsx +0 -340
- package/src/context/react/hooks/useAssistantEvent.ts +0 -25
- package/src/context/react/hooks/useAssistantState.tsx +0 -65
- package/src/legacy-runtime/client/EventManagerRuntimeClient.ts +0 -81
- package/src/primitives/assistant/AssistantIf.tsx +0 -25
- package/src/types/EventTypes.ts +0 -103
- package/src/utils/tap-store/derived-scopes.ts +0 -175
- package/src/utils/tap-store/index.ts +0 -10
- package/src/utils/tap-store/store.ts +0 -35
- package/src/utils/tap-store/tap-api.ts +0 -70
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
8
|
import { useCallback } from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
10
10
|
|
|
11
11
|
const useComposerAddAttachment = ({
|
|
12
12
|
multiple = true,
|
|
@@ -14,8 +14,8 @@ const useComposerAddAttachment = ({
|
|
|
14
14
|
/** allow selecting multiple files */
|
|
15
15
|
multiple?: boolean | undefined;
|
|
16
16
|
} = {}) => {
|
|
17
|
-
const disabled =
|
|
18
|
-
const
|
|
17
|
+
const disabled = useAuiState(({ composer }) => !composer.isEditing);
|
|
18
|
+
const aui = useAui();
|
|
19
19
|
|
|
20
20
|
const callback = useCallback(() => {
|
|
21
21
|
const input = document.createElement("input");
|
|
@@ -23,7 +23,7 @@ const useComposerAddAttachment = ({
|
|
|
23
23
|
input.multiple = multiple;
|
|
24
24
|
input.hidden = true;
|
|
25
25
|
|
|
26
|
-
const attachmentAccept =
|
|
26
|
+
const attachmentAccept = aui.composer().getState().attachmentAccept;
|
|
27
27
|
if (attachmentAccept !== "*") {
|
|
28
28
|
input.accept = attachmentAccept;
|
|
29
29
|
}
|
|
@@ -34,7 +34,7 @@ const useComposerAddAttachment = ({
|
|
|
34
34
|
const fileList = (e.target as HTMLInputElement).files;
|
|
35
35
|
if (!fileList) return;
|
|
36
36
|
for (const file of fileList) {
|
|
37
|
-
|
|
37
|
+
aui.composer().addAttachment(file);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
document.body.removeChild(input);
|
|
@@ -47,7 +47,7 @@ const useComposerAddAttachment = ({
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
input.click();
|
|
50
|
-
}, [
|
|
50
|
+
}, [aui, multiple]);
|
|
51
51
|
|
|
52
52
|
if (disabled) return null;
|
|
53
53
|
return callback;
|
|
@@ -4,7 +4,7 @@ import { forwardRef, useCallback, useState } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
import React from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { useAui } from "@assistant-ui/store";
|
|
8
8
|
|
|
9
9
|
export namespace ComposerPrimitiveAttachmentDropzone {
|
|
10
10
|
export type Element = HTMLDivElement;
|
|
@@ -19,7 +19,7 @@ export const ComposerPrimitiveAttachmentDropzone = forwardRef<
|
|
|
19
19
|
ComposerPrimitiveAttachmentDropzone.Props
|
|
20
20
|
>(({ disabled, asChild = false, children, ...rest }, ref) => {
|
|
21
21
|
const [isDragging, setIsDragging] = useState(false);
|
|
22
|
-
const
|
|
22
|
+
const aui = useAui();
|
|
23
23
|
|
|
24
24
|
const handleDragEnterCapture = useCallback(
|
|
25
25
|
(e: React.DragEvent) => {
|
|
@@ -59,13 +59,13 @@ export const ComposerPrimitiveAttachmentDropzone = forwardRef<
|
|
|
59
59
|
setIsDragging(false);
|
|
60
60
|
for (const file of e.dataTransfer.files) {
|
|
61
61
|
try {
|
|
62
|
-
await
|
|
62
|
+
await aui.composer().addAttachment(file);
|
|
63
63
|
} catch (error) {
|
|
64
64
|
console.error("Failed to add attachment:", error);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
[disabled,
|
|
68
|
+
[disabled, aui],
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
const dragProps = {
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { ComponentType, type FC, memo, useMemo } from "react";
|
|
4
4
|
import { Attachment } from "../../types";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
ComposerAttachmentByIndexProvider,
|
|
8
|
-
} from "../../context";
|
|
5
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
6
|
+
import { ComposerAttachmentByIndexProvider } from "../../context/providers";
|
|
9
7
|
|
|
10
8
|
export namespace ComposerPrimitiveAttachments {
|
|
11
9
|
export type Props = {
|
|
@@ -41,7 +39,7 @@ const getComponent = (
|
|
|
41
39
|
const AttachmentComponent: FC<{
|
|
42
40
|
components: ComposerPrimitiveAttachments.Props["components"];
|
|
43
41
|
}> = ({ components }) => {
|
|
44
|
-
const attachment =
|
|
42
|
+
const attachment = useAuiState(({ attachment }) => attachment);
|
|
45
43
|
if (!attachment) return null;
|
|
46
44
|
|
|
47
45
|
const Component = getComponent(components, attachment);
|
|
@@ -96,9 +94,7 @@ ComposerPrimitiveAttachmentByIndex.displayName =
|
|
|
96
94
|
export const ComposerPrimitiveAttachments: FC<
|
|
97
95
|
ComposerPrimitiveAttachments.Props
|
|
98
96
|
> = ({ components }) => {
|
|
99
|
-
const attachmentsCount =
|
|
100
|
-
(s) => s.composer.attachments.length,
|
|
101
|
-
);
|
|
97
|
+
const attachmentsCount = useAuiState((s) => s.composer.attachments.length);
|
|
102
98
|
|
|
103
99
|
const attachmentElements = useMemo(() => {
|
|
104
100
|
return Array.from({ length: attachmentsCount }, (_, index) => (
|
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
8
|
import { useCallback } from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
10
10
|
|
|
11
11
|
const useComposerCancel = () => {
|
|
12
|
-
const
|
|
13
|
-
const disabled =
|
|
12
|
+
const aui = useAui();
|
|
13
|
+
const disabled = useAuiState(({ composer }) => !composer.canCancel);
|
|
14
14
|
|
|
15
15
|
const callback = useCallback(() => {
|
|
16
|
-
|
|
17
|
-
}, [
|
|
16
|
+
aui.composer().cancel();
|
|
17
|
+
}, [aui]);
|
|
18
18
|
|
|
19
19
|
if (disabled) return null;
|
|
20
20
|
return callback;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import type {
|
|
6
6
|
ActionButtonElement,
|
|
7
7
|
ActionButtonProps,
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
import { createActionButton } from "../../utils/createActionButton";
|
|
10
10
|
|
|
11
11
|
const useComposerDictate = () => {
|
|
12
|
-
const
|
|
13
|
-
const disabled =
|
|
12
|
+
const aui = useAui();
|
|
13
|
+
const disabled = useAuiState(
|
|
14
14
|
({ thread, composer }) =>
|
|
15
15
|
composer.dictation != null ||
|
|
16
16
|
!thread.capabilities.dictation ||
|
|
@@ -18,8 +18,8 @@ const useComposerDictate = () => {
|
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const callback = useCallback(() => {
|
|
21
|
-
|
|
22
|
-
}, [
|
|
21
|
+
aui.composer().startDictation();
|
|
22
|
+
}, [aui]);
|
|
23
23
|
|
|
24
24
|
if (disabled) return null;
|
|
25
25
|
return callback;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
4
|
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
6
6
|
|
|
7
7
|
export namespace ComposerPrimitiveDictationTranscript {
|
|
8
8
|
export type Element = ComponentRef<typeof Primitive.span>;
|
|
@@ -28,7 +28,7 @@ export const ComposerPrimitiveDictationTranscript = forwardRef<
|
|
|
28
28
|
ComposerPrimitiveDictationTranscript.Element,
|
|
29
29
|
ComposerPrimitiveDictationTranscript.Props
|
|
30
30
|
>(({ children, ...props }, forwardRef) => {
|
|
31
|
-
const transcript =
|
|
31
|
+
const transcript = useAuiState(
|
|
32
32
|
({ composer }) => composer.dictation?.transcript,
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { FC, PropsWithChildren } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import type { RequireAtLeastOne } from "../../utils/RequireAtLeastOne";
|
|
6
6
|
|
|
7
7
|
type ComposerIfFilters = {
|
|
@@ -14,7 +14,7 @@ type ComposerIfFilters = {
|
|
|
14
14
|
export type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;
|
|
15
15
|
|
|
16
16
|
const useComposerIf = (props: UseComposerIfProps) => {
|
|
17
|
-
return
|
|
17
|
+
return useAuiState(({ composer }) => {
|
|
18
18
|
if (props.editing === true && !composer.isEditing) return false;
|
|
19
19
|
if (props.editing === false && composer.isEditing) return false;
|
|
20
20
|
|
|
@@ -31,7 +31,7 @@ export namespace ComposerPrimitiveIf {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @deprecated Use `<
|
|
34
|
+
* @deprecated Use `<AuiIf condition={({ composer }) => ...} />` instead.
|
|
35
35
|
*/
|
|
36
36
|
export const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({
|
|
37
37
|
children,
|
|
@@ -16,8 +16,8 @@ import TextareaAutosize, {
|
|
|
16
16
|
} from "react-textarea-autosize";
|
|
17
17
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
|
18
18
|
import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
20
|
+
import { flushResourcesSync } from "@assistant-ui/tap";
|
|
21
21
|
|
|
22
22
|
export namespace ComposerPrimitiveInput {
|
|
23
23
|
export type Element = HTMLTextAreaElement;
|
|
@@ -98,9 +98,9 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
98
98
|
},
|
|
99
99
|
forwardedRef,
|
|
100
100
|
) => {
|
|
101
|
-
const
|
|
101
|
+
const aui = useAui();
|
|
102
102
|
|
|
103
|
-
const value =
|
|
103
|
+
const value = useAuiState(({ composer }) => {
|
|
104
104
|
if (!composer.isEditing) return "";
|
|
105
105
|
return composer.text;
|
|
106
106
|
});
|
|
@@ -108,7 +108,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
108
108
|
const Component = asChild ? Slot : TextareaAutosize;
|
|
109
109
|
|
|
110
110
|
const isDisabled =
|
|
111
|
-
|
|
111
|
+
useAuiState(
|
|
112
112
|
({ thread, composer }) =>
|
|
113
113
|
thread.isDisabled || composer.dictation?.inputDisabled,
|
|
114
114
|
) || disabledProp;
|
|
@@ -121,7 +121,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
121
121
|
// Only handle ESC if it originated from within this input
|
|
122
122
|
if (!textareaRef.current?.contains(e.target as Node)) return;
|
|
123
123
|
|
|
124
|
-
const composer =
|
|
124
|
+
const composer = aui.composer();
|
|
125
125
|
if (composer.getState().canCancel) {
|
|
126
126
|
composer.cancel();
|
|
127
127
|
e.preventDefault();
|
|
@@ -135,7 +135,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
135
135
|
if (e.nativeEvent.isComposing) return;
|
|
136
136
|
|
|
137
137
|
if (e.key === "Enter" && e.shiftKey === false) {
|
|
138
|
-
const isRunning =
|
|
138
|
+
const isRunning = aui.thread().getState().isRunning;
|
|
139
139
|
|
|
140
140
|
if (!isRunning) {
|
|
141
141
|
e.preventDefault();
|
|
@@ -147,14 +147,14 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
147
147
|
|
|
148
148
|
const handlePaste = async (e: ClipboardEvent<HTMLTextAreaElement>) => {
|
|
149
149
|
if (!addAttachmentOnPaste) return;
|
|
150
|
-
const threadCapabilities =
|
|
150
|
+
const threadCapabilities = aui.thread().getState().capabilities;
|
|
151
151
|
const files = Array.from(e.clipboardData?.files || []);
|
|
152
152
|
|
|
153
153
|
if (threadCapabilities.attachments && files.length > 0) {
|
|
154
154
|
try {
|
|
155
155
|
e.preventDefault();
|
|
156
156
|
await Promise.all(
|
|
157
|
-
files.map((file) =>
|
|
157
|
+
files.map((file) => aui.composer().addAttachment(file)),
|
|
158
158
|
);
|
|
159
159
|
} catch (error) {
|
|
160
160
|
console.error("Error adding attachment:", error);
|
|
@@ -175,7 +175,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
175
175
|
|
|
176
176
|
useOnScrollToBottom(() => {
|
|
177
177
|
if (
|
|
178
|
-
|
|
178
|
+
aui.composer().getState().type === "thread" &&
|
|
179
179
|
unstable_focusOnScrollToBottom
|
|
180
180
|
) {
|
|
181
181
|
focus();
|
|
@@ -184,23 +184,23 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
184
184
|
|
|
185
185
|
useEffect(() => {
|
|
186
186
|
if (
|
|
187
|
-
|
|
187
|
+
aui.composer().getState().type !== "thread" ||
|
|
188
188
|
!unstable_focusOnRunStart
|
|
189
189
|
)
|
|
190
190
|
return undefined;
|
|
191
191
|
|
|
192
|
-
return
|
|
193
|
-
}, [unstable_focusOnRunStart, focus,
|
|
192
|
+
return aui.on("thread.runStart", focus);
|
|
193
|
+
}, [unstable_focusOnRunStart, focus, aui]);
|
|
194
194
|
|
|
195
195
|
useEffect(() => {
|
|
196
196
|
if (
|
|
197
|
-
|
|
197
|
+
aui.composer().getState().type !== "thread" ||
|
|
198
198
|
!unstable_focusOnThreadSwitched
|
|
199
199
|
)
|
|
200
200
|
return undefined;
|
|
201
201
|
|
|
202
|
-
return
|
|
203
|
-
}, [unstable_focusOnThreadSwitched, focus,
|
|
202
|
+
return aui.on("threadListItem.switchedTo", focus);
|
|
203
|
+
}, [unstable_focusOnThreadSwitched, focus, aui]);
|
|
204
204
|
|
|
205
205
|
return (
|
|
206
206
|
<Component
|
|
@@ -210,9 +210,9 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
210
210
|
ref={ref as React.ForwardedRef<HTMLTextAreaElement>}
|
|
211
211
|
disabled={isDisabled}
|
|
212
212
|
onChange={composeEventHandlers(onChange, (e) => {
|
|
213
|
-
if (!
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
if (!aui.composer().getState().isEditing) return;
|
|
214
|
+
flushResourcesSync(() => {
|
|
215
|
+
aui.composer().setText(e.target.value);
|
|
216
216
|
});
|
|
217
217
|
})}
|
|
218
218
|
onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}
|
|
@@ -6,18 +6,18 @@ import {
|
|
|
6
6
|
createActionButton,
|
|
7
7
|
} from "../../utils/createActionButton";
|
|
8
8
|
import { useCallback } from "react";
|
|
9
|
-
import {
|
|
9
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
10
10
|
|
|
11
11
|
export const useComposerSend = () => {
|
|
12
|
-
const
|
|
12
|
+
const aui = useAui();
|
|
13
13
|
|
|
14
|
-
const disabled =
|
|
14
|
+
const disabled = useAuiState(
|
|
15
15
|
(s) => s.thread.isRunning || !s.composer.isEditing || s.composer.isEmpty,
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
const callback = useCallback(() => {
|
|
19
|
-
|
|
20
|
-
}, [
|
|
19
|
+
aui.composer().send();
|
|
20
|
+
}, [aui]);
|
|
21
21
|
|
|
22
22
|
if (disabled) return null;
|
|
23
23
|
return callback;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAui } from "@assistant-ui/store";
|
|
5
5
|
import type {
|
|
6
6
|
ActionButtonElement,
|
|
7
7
|
ActionButtonProps,
|
|
8
8
|
} from "../../utils/createActionButton";
|
|
9
9
|
import { createActionButton } from "../../utils/createActionButton";
|
|
10
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
10
11
|
|
|
11
12
|
const useComposerStopDictation = () => {
|
|
12
|
-
const
|
|
13
|
-
const isDictating =
|
|
14
|
-
({ composer }) => composer.dictation != null,
|
|
15
|
-
);
|
|
13
|
+
const aui = useAui();
|
|
14
|
+
const isDictating = useAuiState(({ composer }) => composer.dictation != null);
|
|
16
15
|
|
|
17
16
|
const callback = useCallback(() => {
|
|
18
|
-
|
|
19
|
-
}, [
|
|
17
|
+
aui.composer().stopDictation();
|
|
18
|
+
}, [aui]);
|
|
20
19
|
|
|
21
20
|
if (!isDictating) return null;
|
|
22
21
|
return callback;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
4
|
import { type ComponentRef, forwardRef, ComponentPropsWithoutRef } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
6
6
|
|
|
7
7
|
export namespace ErrorPrimitiveMessage {
|
|
8
8
|
export type Element = ComponentRef<typeof Primitive.span>;
|
|
@@ -13,7 +13,7 @@ export const ErrorPrimitiveMessage = forwardRef<
|
|
|
13
13
|
ErrorPrimitiveMessage.Element,
|
|
14
14
|
ErrorPrimitiveMessage.Props
|
|
15
15
|
>(({ children, ...props }, forwardRef) => {
|
|
16
|
-
const error =
|
|
16
|
+
const error = useAuiState(({ message }) => {
|
|
17
17
|
return message.status?.type === "incomplete" &&
|
|
18
18
|
message.status.reason === "error"
|
|
19
19
|
? message.status.error
|
package/src/primitives/index.ts
CHANGED
|
@@ -12,8 +12,6 @@ export * as ThreadListPrimitive from "./threadList";
|
|
|
12
12
|
export * as ThreadListItemPrimitive from "./threadListItem";
|
|
13
13
|
export * as ThreadListItemMorePrimitive from "./threadListItemMore";
|
|
14
14
|
|
|
15
|
-
export { AssistantIf } from "./assistant/AssistantIf";
|
|
16
|
-
|
|
17
15
|
export { useMessagePartText } from "./messagePart/useMessagePartText";
|
|
18
16
|
export { useMessagePartReasoning } from "./messagePart/useMessagePartReasoning";
|
|
19
17
|
export { useMessagePartSource } from "./messagePart/useMessagePartSource";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { ComponentType, type FC, memo, useMemo } from "react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
MessageAttachmentByIndexProvider,
|
|
7
|
-
} from "../../context";
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
|
+
import { MessageAttachmentByIndexProvider } from "../../context/providers";
|
|
8
6
|
import { CompleteAttachment } from "../../types";
|
|
9
7
|
|
|
10
8
|
export namespace MessagePrimitiveAttachments {
|
|
@@ -41,7 +39,7 @@ const getComponent = (
|
|
|
41
39
|
const AttachmentComponent: FC<{
|
|
42
40
|
components: MessagePrimitiveAttachments.Props["components"];
|
|
43
41
|
}> = ({ components }) => {
|
|
44
|
-
const attachment =
|
|
42
|
+
const attachment = useAuiState(({ attachment }) => attachment);
|
|
45
43
|
if (!attachment) return null;
|
|
46
44
|
|
|
47
45
|
const Component = getComponent(components, attachment as CompleteAttachment);
|
|
@@ -96,7 +94,7 @@ MessagePrimitiveAttachmentByIndex.displayName =
|
|
|
96
94
|
export const MessagePrimitiveAttachments: FC<
|
|
97
95
|
MessagePrimitiveAttachments.Props
|
|
98
96
|
> = ({ components }) => {
|
|
99
|
-
const attachmentsCount =
|
|
97
|
+
const attachmentsCount = useAuiState(({ message }) => {
|
|
100
98
|
if (message.role !== "user") return 0;
|
|
101
99
|
return message.attachments.length;
|
|
102
100
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { FC, PropsWithChildren } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
5
|
|
|
6
6
|
export const MessagePrimitiveError: FC<PropsWithChildren> = ({ children }) => {
|
|
7
|
-
const hasError =
|
|
7
|
+
const hasError = useAuiState(
|
|
8
8
|
({ message }) =>
|
|
9
9
|
message.status?.type === "incomplete" &&
|
|
10
10
|
message.status.reason === "error",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { FC, PropsWithChildren } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import type { RequireAtLeastOne } from "../../utils/RequireAtLeastOne";
|
|
6
6
|
|
|
7
7
|
type MessageIfFilters = {
|
|
@@ -20,7 +20,7 @@ type MessageIfFilters = {
|
|
|
20
20
|
type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
|
|
21
21
|
|
|
22
22
|
const useMessageIf = (props: UseMessageIfProps) => {
|
|
23
|
-
return
|
|
23
|
+
return useAuiState(({ message }) => {
|
|
24
24
|
const {
|
|
25
25
|
role,
|
|
26
26
|
attachments,
|
|
@@ -78,7 +78,7 @@ export namespace MessagePrimitiveIf {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* @deprecated Use `<
|
|
81
|
+
* @deprecated Use `<AuiIf condition={({ message }) => ...} />` instead.
|
|
82
82
|
*/
|
|
83
83
|
export const MessagePrimitiveIf: FC<MessagePrimitiveIf.Props> = ({
|
|
84
84
|
children,
|
|
@@ -7,12 +7,11 @@ import {
|
|
|
7
7
|
PropsWithChildren,
|
|
8
8
|
useMemo,
|
|
9
9
|
} from "react";
|
|
10
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
10
11
|
import {
|
|
11
|
-
useAssistantState,
|
|
12
|
-
useAssistantApi,
|
|
13
12
|
PartByIndexProvider,
|
|
14
13
|
TextMessagePartProvider,
|
|
15
|
-
} from "../../context";
|
|
14
|
+
} from "../../context/providers";
|
|
16
15
|
import { MessagePartPrimitiveText } from "../messagePart/MessagePartText";
|
|
17
16
|
import { MessagePartPrimitiveImage } from "../messagePart/MessagePartImage";
|
|
18
17
|
import type {
|
|
@@ -107,7 +106,7 @@ const groupMessageParts = (
|
|
|
107
106
|
};
|
|
108
107
|
|
|
109
108
|
const useMessagePartsGroups = (): MessagePartRange[] => {
|
|
110
|
-
const messageTypes =
|
|
109
|
+
const messageTypes = useAuiState(
|
|
111
110
|
useShallow((s) => s.message.parts.map((c: any) => c.type)),
|
|
112
111
|
);
|
|
113
112
|
|
|
@@ -252,7 +251,7 @@ const ToolUIDisplay = ({
|
|
|
252
251
|
}: {
|
|
253
252
|
Fallback: ToolCallMessagePartComponent | undefined;
|
|
254
253
|
} & ToolCallMessagePartProps) => {
|
|
255
|
-
const Render =
|
|
254
|
+
const Render = useAuiState(({ tools }) => {
|
|
256
255
|
const Render = tools.tools[props.toolName] ?? Fallback;
|
|
257
256
|
if (Array.isArray(Render)) return Render[0] ?? Fallback;
|
|
258
257
|
return Render;
|
|
@@ -294,13 +293,13 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
|
|
|
294
293
|
tools = {},
|
|
295
294
|
} = {},
|
|
296
295
|
}) => {
|
|
297
|
-
const
|
|
298
|
-
const part =
|
|
296
|
+
const aui = useAui();
|
|
297
|
+
const part = useAuiState(({ part }) => part);
|
|
299
298
|
|
|
300
299
|
const type = part.type;
|
|
301
300
|
if (type === "tool-call") {
|
|
302
|
-
const addResult =
|
|
303
|
-
const resume =
|
|
301
|
+
const addResult = aui.part().addToolResult;
|
|
302
|
+
const resume = aui.part().resumeToolCall;
|
|
304
303
|
if ("Override" in tools)
|
|
305
304
|
return <tools.Override {...part} addResult={addResult} resume={resume} />;
|
|
306
305
|
const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;
|
|
@@ -409,7 +408,7 @@ const COMPLETE_STATUS: MessagePartStatus = Object.freeze({
|
|
|
409
408
|
});
|
|
410
409
|
|
|
411
410
|
const EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {
|
|
412
|
-
const status =
|
|
411
|
+
const status = useAuiState(
|
|
413
412
|
(s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,
|
|
414
413
|
);
|
|
415
414
|
|
|
@@ -457,9 +456,7 @@ const EmptyParts = memo(
|
|
|
457
456
|
export const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({
|
|
458
457
|
components,
|
|
459
458
|
}) => {
|
|
460
|
-
const contentLength =
|
|
461
|
-
({ message }) => message.parts.length,
|
|
462
|
-
);
|
|
459
|
+
const contentLength = useAuiState(({ message }) => message.parts.length);
|
|
463
460
|
const messageRanges = useMessagePartsGroups();
|
|
464
461
|
|
|
465
462
|
const partsElements = useMemo(() => {
|
|
@@ -7,12 +7,11 @@ import {
|
|
|
7
7
|
PropsWithChildren,
|
|
8
8
|
useMemo,
|
|
9
9
|
} from "react";
|
|
10
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
10
11
|
import {
|
|
11
|
-
useAssistantState,
|
|
12
12
|
PartByIndexProvider,
|
|
13
|
-
useAssistantApi,
|
|
14
13
|
TextMessagePartProvider,
|
|
15
|
-
} from "../../context";
|
|
14
|
+
} from "../../context/providers";
|
|
16
15
|
import { MessagePartPrimitiveText } from "../messagePart/MessagePartText";
|
|
17
16
|
import { MessagePartPrimitiveImage } from "../messagePart/MessagePartImage";
|
|
18
17
|
import type {
|
|
@@ -75,7 +74,7 @@ const groupMessagePartsByParentId: GroupingFunction = (
|
|
|
75
74
|
const useMessagePartsGrouped = (
|
|
76
75
|
groupingFunction: GroupingFunction,
|
|
77
76
|
): MessagePartGroup[] => {
|
|
78
|
-
const parts =
|
|
77
|
+
const parts = useAuiState(({ message }) => message.parts);
|
|
79
78
|
|
|
80
79
|
return useMemo(() => {
|
|
81
80
|
if (parts.length === 0) {
|
|
@@ -220,7 +219,7 @@ const ToolUIDisplay = ({
|
|
|
220
219
|
}: {
|
|
221
220
|
Fallback: ToolCallMessagePartComponent | undefined;
|
|
222
221
|
} & ToolCallMessagePartProps) => {
|
|
223
|
-
const Render =
|
|
222
|
+
const Render = useAuiState(({ tools }) => {
|
|
224
223
|
const Render = tools.tools[props.toolName] ?? Fallback;
|
|
225
224
|
if (Array.isArray(Render)) return Render[0] ?? Fallback;
|
|
226
225
|
return Render;
|
|
@@ -261,13 +260,13 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
|
|
|
261
260
|
tools = {},
|
|
262
261
|
} = {},
|
|
263
262
|
}) => {
|
|
264
|
-
const
|
|
265
|
-
const part =
|
|
263
|
+
const aui = useAui();
|
|
264
|
+
const part = useAuiState(({ part }) => part);
|
|
266
265
|
|
|
267
266
|
const type = part.type;
|
|
268
267
|
if (type === "tool-call") {
|
|
269
|
-
const addResult = (result: any) =>
|
|
270
|
-
const resume =
|
|
268
|
+
const addResult = (result: any) => aui.part().addToolResult(result);
|
|
269
|
+
const resume = aui.part().resumeToolCall;
|
|
271
270
|
if ("Override" in tools)
|
|
272
271
|
return <tools.Override {...part} addResult={addResult} resume={resume} />;
|
|
273
272
|
const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;
|
|
@@ -355,7 +354,7 @@ const COMPLETE_STATUS: MessagePartStatus = Object.freeze({
|
|
|
355
354
|
});
|
|
356
355
|
|
|
357
356
|
const EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {
|
|
358
|
-
const status =
|
|
357
|
+
const status = useAuiState(
|
|
359
358
|
(s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,
|
|
360
359
|
);
|
|
361
360
|
|
|
@@ -427,9 +426,7 @@ const EmptyParts = memo(
|
|
|
427
426
|
export const MessagePrimitiveUnstable_PartsGrouped: FC<
|
|
428
427
|
MessagePrimitiveUnstable_PartsGrouped.Props
|
|
429
428
|
> = ({ groupingFunction, components }) => {
|
|
430
|
-
const contentLength =
|
|
431
|
-
({ message }) => message.parts.length,
|
|
432
|
-
);
|
|
429
|
+
const contentLength = useAuiState(({ message }) => message.parts.length);
|
|
433
430
|
const messageGroups = useMessagePartsGrouped(groupingFunction);
|
|
434
431
|
|
|
435
432
|
const partsElements = useMemo(() => {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ComponentPropsWithoutRef,
|
|
8
8
|
useCallback,
|
|
9
9
|
} from "react";
|
|
10
|
-
import {
|
|
10
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
11
11
|
import { useManagedRef } from "../../utils/hooks/useManagedRef";
|
|
12
12
|
import { useSizeHandle } from "../../utils/hooks/useSizeHandle";
|
|
13
13
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
@@ -15,8 +15,8 @@ import { useThreadViewport } from "../../context/react/ThreadViewportContext";
|
|
|
15
15
|
import { ThreadPrimitiveViewportSlack } from "../thread/ThreadViewportSlack";
|
|
16
16
|
|
|
17
17
|
const useIsHoveringRef = () => {
|
|
18
|
-
const
|
|
19
|
-
const message =
|
|
18
|
+
const aui = useAui();
|
|
19
|
+
const message = useAuiState(() => aui.message());
|
|
20
20
|
|
|
21
21
|
const callbackRef = useCallback(
|
|
22
22
|
(el: HTMLElement) => {
|
|
@@ -59,7 +59,7 @@ const useMessageViewportRef = () => {
|
|
|
59
59
|
|
|
60
60
|
// inset rules:
|
|
61
61
|
// - the previous user message before the last assistant message registers its full height
|
|
62
|
-
const shouldRegisterAsInset =
|
|
62
|
+
const shouldRegisterAsInset = useAuiState(
|
|
63
63
|
({ thread, message }) =>
|
|
64
64
|
turnAnchor === "top" &&
|
|
65
65
|
message.role === "user" &&
|