@assistant-ui/react 0.11.57 → 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/external-store/external-message-converter.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.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 +9 -8
- 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/external-store/external-message-converter.tsx +1 -1
- 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,15 +6,19 @@ import {
|
|
|
6
6
|
tapMemo,
|
|
7
7
|
tapEffect,
|
|
8
8
|
type tapRef,
|
|
9
|
+
withKey,
|
|
9
10
|
} from "@assistant-ui/tap";
|
|
11
|
+
import {
|
|
12
|
+
type ClientOutput,
|
|
13
|
+
tapAssistantEmit,
|
|
14
|
+
tapClientLookup,
|
|
15
|
+
tapClientResource,
|
|
16
|
+
} from "@assistant-ui/store";
|
|
10
17
|
import { ComposerClient } from "./ComposerRuntimeClient";
|
|
11
18
|
import { MessageClient } from "./MessageRuntimeClient";
|
|
12
19
|
import { tapSubscribable } from "../util-hooks/tapSubscribable";
|
|
13
|
-
import { tapApi } from "../../utils/tap-store";
|
|
14
|
-
import { tapLookupResources } from "../../client/util-hooks/tapLookupResources";
|
|
15
20
|
import { Unsubscribe } from "../../types";
|
|
16
|
-
import {
|
|
17
|
-
import { ThreadClientState, ThreadClientApi } from "../../client/types/Thread";
|
|
21
|
+
import { ThreadState } from "../../types/scopes";
|
|
18
22
|
|
|
19
23
|
const MessageClientById = resource(
|
|
20
24
|
({
|
|
@@ -38,10 +42,9 @@ const MessageClientById = resource(
|
|
|
38
42
|
);
|
|
39
43
|
|
|
40
44
|
export const ThreadClient = resource(
|
|
41
|
-
({ runtime }: { runtime: ThreadRuntime }) => {
|
|
45
|
+
({ runtime }: { runtime: ThreadRuntime }): ClientOutput<"thread"> => {
|
|
42
46
|
const runtimeState = tapSubscribable(runtime);
|
|
43
|
-
|
|
44
|
-
const events = tapEvents();
|
|
47
|
+
const emit = tapAssistantEmit();
|
|
45
48
|
|
|
46
49
|
// Bind thread events to event manager
|
|
47
50
|
tapEffect(() => {
|
|
@@ -49,16 +52,16 @@ export const ThreadClient = resource(
|
|
|
49
52
|
|
|
50
53
|
// Subscribe to thread events
|
|
51
54
|
const threadEvents: ThreadRuntimeEventType[] = [
|
|
52
|
-
"
|
|
53
|
-
"
|
|
55
|
+
"runStart",
|
|
56
|
+
"runEnd",
|
|
54
57
|
"initialize",
|
|
55
|
-
"
|
|
58
|
+
"modelContextUpdate",
|
|
56
59
|
];
|
|
57
60
|
|
|
58
61
|
for (const event of threadEvents) {
|
|
59
62
|
const unsubscribe = runtime.unstable_on(event, () => {
|
|
60
63
|
const threadId = runtime.getState()?.threadId || "unknown";
|
|
61
|
-
|
|
64
|
+
emit(`thread.${event}`, {
|
|
62
65
|
threadId,
|
|
63
66
|
});
|
|
64
67
|
});
|
|
@@ -68,7 +71,7 @@ export const ThreadClient = resource(
|
|
|
68
71
|
return () => {
|
|
69
72
|
for (const unsub of unsubscribers) unsub();
|
|
70
73
|
};
|
|
71
|
-
}, [runtime]);
|
|
74
|
+
}, [runtime, emit]);
|
|
72
75
|
|
|
73
76
|
const threadIdRef = tapMemo(
|
|
74
77
|
() => ({
|
|
@@ -79,21 +82,22 @@ export const ThreadClient = resource(
|
|
|
79
82
|
[runtime],
|
|
80
83
|
);
|
|
81
84
|
|
|
82
|
-
const composer =
|
|
85
|
+
const composer = tapClientResource(
|
|
83
86
|
ComposerClient({
|
|
84
87
|
runtime: runtime.composer,
|
|
85
88
|
threadIdRef,
|
|
86
89
|
}),
|
|
87
90
|
);
|
|
88
91
|
|
|
89
|
-
const messages =
|
|
90
|
-
|
|
91
|
-
m
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const messages = tapClientLookup(
|
|
93
|
+
() =>
|
|
94
|
+
runtimeState.messages.map((m) =>
|
|
95
|
+
withKey(m.id, MessageClientById({ runtime, id: m.id, threadIdRef })),
|
|
96
|
+
),
|
|
97
|
+
[runtimeState.messages, runtime, threadIdRef],
|
|
94
98
|
);
|
|
95
99
|
|
|
96
|
-
const state = tapMemo<
|
|
100
|
+
const state = tapMemo<ThreadState>(() => {
|
|
97
101
|
return {
|
|
98
102
|
isEmpty: messages.state.length === 0 && !runtimeState.isLoading,
|
|
99
103
|
isDisabled: runtimeState.isDisabled,
|
|
@@ -110,36 +114,35 @@ export const ThreadClient = resource(
|
|
|
110
114
|
};
|
|
111
115
|
}, [runtimeState, messages, composer.state]);
|
|
112
116
|
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
117
|
+
return {
|
|
118
|
+
state,
|
|
119
|
+
methods: {
|
|
120
|
+
getState: () => state,
|
|
121
|
+
composer: composer.methods,
|
|
122
|
+
append: runtime.append,
|
|
123
|
+
startRun: runtime.startRun,
|
|
124
|
+
unstable_resumeRun: runtime.unstable_resumeRun,
|
|
125
|
+
cancelRun: runtime.cancelRun,
|
|
126
|
+
getModelContext: runtime.getModelContext,
|
|
127
|
+
export: runtime.export,
|
|
128
|
+
import: runtime.import,
|
|
129
|
+
reset: runtime.reset,
|
|
130
|
+
stopSpeaking: runtime.stopSpeaking,
|
|
131
|
+
startVoice: async () => {
|
|
132
|
+
throw new Error("startVoice is not supported in this runtime");
|
|
133
|
+
},
|
|
134
|
+
stopVoice: async () => {
|
|
135
|
+
throw new Error("stopVoice is not supported in this runtime");
|
|
136
|
+
},
|
|
137
|
+
message: (selector) => {
|
|
138
|
+
if ("id" in selector) {
|
|
139
|
+
return messages.get({ key: selector.id });
|
|
140
|
+
} else {
|
|
141
|
+
return messages.get(selector);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
__internal_getRuntime: () => runtime,
|
|
140
145
|
},
|
|
141
|
-
|
|
142
|
-
__internal_getRuntime: () => runtime,
|
|
143
|
-
});
|
|
146
|
+
};
|
|
144
147
|
},
|
|
145
148
|
);
|
|
@@ -11,15 +11,12 @@ import {
|
|
|
11
11
|
} from "../runtime-cores/adapters/thread-history/MessageFormatAdapter";
|
|
12
12
|
import { GenericThreadHistoryAdapter } from "../runtime-cores/adapters/thread-history/ThreadHistoryAdapter";
|
|
13
13
|
import { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
useAssistantApi,
|
|
17
|
-
} from "../../context/react/AssistantApiContext";
|
|
18
|
-
import { ThreadListItemClientApi } from "../../client/types/ThreadListItem";
|
|
14
|
+
import { AssistantClient, useAui } from "@assistant-ui/store";
|
|
15
|
+
import { ThreadListItemMethods } from "../../types/scopes";
|
|
19
16
|
|
|
20
17
|
// Global WeakMap to store message ID mappings across adapter instances
|
|
21
18
|
const globalMessageIdMapping = new WeakMap<
|
|
22
|
-
|
|
19
|
+
ThreadListItemMethods,
|
|
23
20
|
Record<string, string | Promise<string>>
|
|
24
21
|
>();
|
|
25
22
|
|
|
@@ -58,14 +55,14 @@ class FormattedThreadHistoryAdapter<TMessage, TStorageFormat>
|
|
|
58
55
|
class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
59
56
|
constructor(
|
|
60
57
|
private cloudRef: RefObject<AssistantCloud>,
|
|
61
|
-
private
|
|
58
|
+
private aui: AssistantClient,
|
|
62
59
|
) {}
|
|
63
60
|
|
|
64
61
|
private get _getIdForLocalId(): Record<string, string | Promise<string>> {
|
|
65
|
-
if (!globalMessageIdMapping.has(this.
|
|
66
|
-
globalMessageIdMapping.set(this.
|
|
62
|
+
if (!globalMessageIdMapping.has(this.aui.threadListItem())) {
|
|
63
|
+
globalMessageIdMapping.set(this.aui.threadListItem(), {});
|
|
67
64
|
}
|
|
68
|
-
return globalMessageIdMapping.get(this.
|
|
65
|
+
return globalMessageIdMapping.get(this.aui.threadListItem())!;
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
withFormat<TMessage, TStorageFormat>(
|
|
@@ -75,7 +72,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
async append({ parentId, message }: ExportedMessageRepositoryItem) {
|
|
78
|
-
const { remoteId } = await this.
|
|
75
|
+
const { remoteId } = await this.aui.threadListItem().initialize();
|
|
79
76
|
const task = this.cloudRef.current.threads.messages
|
|
80
77
|
.create(remoteId, {
|
|
81
78
|
parent_id: parentId
|
|
@@ -95,7 +92,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
async load() {
|
|
98
|
-
const remoteId = this.
|
|
95
|
+
const remoteId = this.aui.threadListItem().getState().remoteId;
|
|
99
96
|
if (!remoteId) return { messages: [] };
|
|
100
97
|
const { messages } = await this.cloudRef.current.threads.messages.list(
|
|
101
98
|
remoteId,
|
|
@@ -121,7 +118,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
121
118
|
format: string,
|
|
122
119
|
content: T,
|
|
123
120
|
) {
|
|
124
|
-
const { remoteId } = await this.
|
|
121
|
+
const { remoteId } = await this.aui.threadListItem().initialize();
|
|
125
122
|
|
|
126
123
|
const task = this.cloudRef.current.threads.messages
|
|
127
124
|
.create(remoteId, {
|
|
@@ -147,7 +144,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
147
144
|
message: MessageStorageEntry<TStorageFormat>,
|
|
148
145
|
) => MessageFormatItem<TMessage>,
|
|
149
146
|
): Promise<MessageFormatRepository<TMessage>> {
|
|
150
|
-
const remoteId = this.
|
|
147
|
+
const remoteId = this.aui.threadListItem().getState().remoteId;
|
|
151
148
|
if (!remoteId) return { messages: [] };
|
|
152
149
|
|
|
153
150
|
const { messages } = await this.cloudRef.current.threads.messages.list(
|
|
@@ -176,9 +173,9 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
176
173
|
export const useAssistantCloudThreadHistoryAdapter = (
|
|
177
174
|
cloudRef: RefObject<AssistantCloud>,
|
|
178
175
|
): ThreadHistoryAdapter => {
|
|
179
|
-
const
|
|
176
|
+
const aui = useAui();
|
|
180
177
|
const [adapter] = useState(
|
|
181
|
-
() => new AssistantCloudThreadHistoryAdapter(cloudRef,
|
|
178
|
+
() => new AssistantCloudThreadHistoryAdapter(cloudRef, aui),
|
|
182
179
|
);
|
|
183
180
|
|
|
184
181
|
return adapter;
|
|
@@ -37,6 +37,16 @@ type AuiV0MessageMessagePart =
|
|
|
37
37
|
readonly argsText: string;
|
|
38
38
|
readonly result?: ReadonlyJSONValue;
|
|
39
39
|
readonly isError?: true;
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
readonly type: "image";
|
|
43
|
+
readonly image: string;
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
readonly type: "file";
|
|
47
|
+
readonly data: string;
|
|
48
|
+
readonly mimeType: string;
|
|
49
|
+
readonly filename?: string;
|
|
40
50
|
};
|
|
41
51
|
|
|
42
52
|
type AuiV0Message = {
|
|
@@ -111,8 +121,24 @@ export const auiV0Encode = (message: ThreadMessage): AuiV0Message => {
|
|
|
111
121
|
};
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
case "image": {
|
|
125
|
+
return {
|
|
126
|
+
type: "image",
|
|
127
|
+
image: part.image,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
case "file": {
|
|
132
|
+
return {
|
|
133
|
+
type: "file",
|
|
134
|
+
data: part.data,
|
|
135
|
+
mimeType: part.mimeType,
|
|
136
|
+
...(part.filename ? { filename: part.filename } : undefined),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
114
140
|
default: {
|
|
115
|
-
const unhandledType: "
|
|
141
|
+
const unhandledType: "audio" | "data" = type;
|
|
116
142
|
throw new Error(
|
|
117
143
|
`Message part type not supported by aui/v0: ${unhandledType}`,
|
|
118
144
|
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useAui } from "@assistant-ui/store";
|
|
4
4
|
import { AssistantRuntime } from "../runtime/AssistantRuntime";
|
|
5
5
|
import type { ThreadListRuntime } from "../runtime/ThreadListRuntime";
|
|
6
6
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated Use `
|
|
9
|
+
* @deprecated Use `useAui()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
10
10
|
*
|
|
11
11
|
* Hook to access the AssistantRuntime from the current context.
|
|
12
12
|
*
|
|
@@ -30,9 +30,9 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
|
|
|
30
30
|
*
|
|
31
31
|
* // After:
|
|
32
32
|
* function MyComponent() {
|
|
33
|
-
* const
|
|
33
|
+
* const aui = useAui();
|
|
34
34
|
* const handleNewThread = () => {
|
|
35
|
-
*
|
|
35
|
+
* aui.threads().switchToNewThread();
|
|
36
36
|
* };
|
|
37
37
|
* return <button onClick={handleNewThread}>New Thread</button>;
|
|
38
38
|
* }
|
|
@@ -47,8 +47,8 @@ export function useAssistantRuntime(options?: {
|
|
|
47
47
|
export function useAssistantRuntime(options?: {
|
|
48
48
|
optional?: boolean | undefined;
|
|
49
49
|
}) {
|
|
50
|
-
const
|
|
51
|
-
const runtime =
|
|
50
|
+
const aui = useAui();
|
|
51
|
+
const runtime = aui.threads().__internal_getAssistantRuntime?.() ?? null;
|
|
52
52
|
|
|
53
53
|
if (!runtime && !options?.optional) {
|
|
54
54
|
throw new Error("AssistantRuntime is not available");
|
|
@@ -62,6 +62,6 @@ const useThreadListRuntime = (opt: {
|
|
|
62
62
|
}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* @deprecated Use `
|
|
65
|
+
* @deprecated Use `useAuiState(({ threads }) => threads)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
66
66
|
*/
|
|
67
67
|
export const useThreadList = createStateHookForRuntime(useThreadListRuntime);
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { AttachmentRuntime } from "../runtime/AttachmentRuntime";
|
|
4
4
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
5
|
-
import {
|
|
5
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @deprecated Use `
|
|
8
|
+
* @deprecated Use `useAui()` with `aui.attachment()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
9
9
|
*/
|
|
10
10
|
export function useAttachmentRuntime(options?: {
|
|
11
11
|
optional?: false | undefined;
|
|
@@ -16,10 +16,10 @@ export function useAttachmentRuntime(options?: {
|
|
|
16
16
|
export function useAttachmentRuntime(options?: {
|
|
17
17
|
optional?: boolean | undefined;
|
|
18
18
|
}): AttachmentRuntime | null {
|
|
19
|
-
const
|
|
20
|
-
const runtime =
|
|
21
|
-
|
|
22
|
-
? (
|
|
19
|
+
const aui = useAui();
|
|
20
|
+
const runtime = useAuiState(() =>
|
|
21
|
+
aui.attachment.source
|
|
22
|
+
? (aui.attachment().__internal_getRuntime?.() ?? null)
|
|
23
23
|
: null,
|
|
24
24
|
);
|
|
25
25
|
if (!runtime && !options?.optional) {
|
|
@@ -84,7 +84,7 @@ export function useMessageAttachmentRuntime(options?: {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* @deprecated Use `
|
|
87
|
+
* @deprecated Use `useAuiState(({ attachment }) => attachment)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
88
88
|
*/
|
|
89
89
|
export const useAttachment = createStateHookForRuntime(useAttachmentRuntime);
|
|
90
90
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
4
|
import { ComposerRuntime } from "../runtime/ComposerRuntime";
|
|
5
5
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @deprecated Use `
|
|
8
|
+
* @deprecated Use `useAui()` with `aui.composer()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
9
9
|
*
|
|
10
10
|
* Hook to access the ComposerRuntime from the current context.
|
|
11
11
|
*
|
|
@@ -43,17 +43,17 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
|
|
|
43
43
|
*
|
|
44
44
|
* // After:
|
|
45
45
|
* function ComposerActions() {
|
|
46
|
-
* const
|
|
47
|
-
* const canSend =
|
|
48
|
-
* const canCancel =
|
|
46
|
+
* const aui = useAui();
|
|
47
|
+
* const canSend = useAuiState(({ composer }) => composer.canSend);
|
|
48
|
+
* const canCancel = useAuiState(({ composer }) => composer.canCancel);
|
|
49
49
|
* const handleSend = () => {
|
|
50
50
|
* if (canSend) {
|
|
51
|
-
*
|
|
51
|
+
* aui.composer().send();
|
|
52
52
|
* }
|
|
53
53
|
* };
|
|
54
54
|
* const handleCancel = () => {
|
|
55
55
|
* if (canCancel) {
|
|
56
|
-
*
|
|
56
|
+
* aui.composer().cancel();
|
|
57
57
|
* }
|
|
58
58
|
* };
|
|
59
59
|
* return (
|
|
@@ -74,10 +74,10 @@ export function useComposerRuntime(options?: {
|
|
|
74
74
|
export function useComposerRuntime(options?: {
|
|
75
75
|
optional?: boolean | undefined;
|
|
76
76
|
}): ComposerRuntime | null {
|
|
77
|
-
const
|
|
78
|
-
const runtime =
|
|
79
|
-
|
|
80
|
-
? (
|
|
77
|
+
const aui = useAui();
|
|
78
|
+
const runtime = useAuiState(() =>
|
|
79
|
+
aui.composer.source
|
|
80
|
+
? (aui.composer().__internal_getRuntime?.() ?? null)
|
|
81
81
|
: null,
|
|
82
82
|
);
|
|
83
83
|
if (!runtime && !options?.optional) {
|
|
@@ -87,7 +87,7 @@ export function useComposerRuntime(options?: {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* @deprecated Use `
|
|
90
|
+
* @deprecated Use `useAuiState(({ composer }) => composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
91
91
|
*
|
|
92
92
|
* Hook to access the current composer state.
|
|
93
93
|
*
|
|
@@ -115,9 +115,9 @@ export function useComposerRuntime(options?: {
|
|
|
115
115
|
*
|
|
116
116
|
* // After:
|
|
117
117
|
* function ComposerStatus() {
|
|
118
|
-
* const text =
|
|
119
|
-
* const canSend =
|
|
120
|
-
* const attachmentCount =
|
|
118
|
+
* const text = useAuiState(({ composer }) => composer.text);
|
|
119
|
+
* const canSend = useAuiState(({ composer }) => composer.canSend);
|
|
120
|
+
* const attachmentCount = useAuiState(({ composer }) => composer.attachments.length);
|
|
121
121
|
* return (
|
|
122
122
|
* <div>
|
|
123
123
|
* Text: {text.length} chars,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { MessageRuntime } from "../runtime/MessageRuntime";
|
|
4
|
-
import {
|
|
4
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
5
5
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
6
6
|
import { EditComposerRuntime } from "../runtime";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated Use `
|
|
9
|
+
* @deprecated Use `useAui()` with `aui.message()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
10
10
|
*
|
|
11
11
|
* Hook to access the MessageRuntime from the current context.
|
|
12
12
|
*
|
|
@@ -38,12 +38,12 @@ import { EditComposerRuntime } from "../runtime";
|
|
|
38
38
|
*
|
|
39
39
|
* // After:
|
|
40
40
|
* function MessageActions() {
|
|
41
|
-
* const
|
|
41
|
+
* const aui = useAui();
|
|
42
42
|
* const handleReload = () => {
|
|
43
|
-
*
|
|
43
|
+
* aui.message().reload();
|
|
44
44
|
* };
|
|
45
45
|
* const handleEdit = () => {
|
|
46
|
-
*
|
|
46
|
+
* aui.message().startEdit();
|
|
47
47
|
* };
|
|
48
48
|
* return (
|
|
49
49
|
* <div>
|
|
@@ -63,10 +63,10 @@ export function useMessageRuntime(options?: {
|
|
|
63
63
|
export function useMessageRuntime(options?: {
|
|
64
64
|
optional?: boolean | undefined;
|
|
65
65
|
}) {
|
|
66
|
-
const
|
|
67
|
-
const runtime =
|
|
68
|
-
|
|
69
|
-
? (
|
|
66
|
+
const aui = useAui();
|
|
67
|
+
const runtime = useAuiState(() =>
|
|
68
|
+
aui.message.source
|
|
69
|
+
? (aui.message().__internal_getRuntime?.() ?? null)
|
|
70
70
|
: null,
|
|
71
71
|
);
|
|
72
72
|
if (!runtime && !options?.optional) {
|
|
@@ -76,7 +76,7 @@ export function useMessageRuntime(options?: {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @deprecated Use `
|
|
79
|
+
* @deprecated Use `useAuiState(({ message }) => message)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
80
80
|
*
|
|
81
81
|
* Hook to access the current message state.
|
|
82
82
|
*
|
|
@@ -102,9 +102,9 @@ export function useMessageRuntime(options?: {
|
|
|
102
102
|
*
|
|
103
103
|
* // After:
|
|
104
104
|
* function MessageContent() {
|
|
105
|
-
* const role =
|
|
106
|
-
* const content =
|
|
107
|
-
* const isLoading =
|
|
105
|
+
* const role = useAuiState(({ message }) => message.role);
|
|
106
|
+
* const content = useAuiState(({ message }) => message.content);
|
|
107
|
+
* const isLoading = useAuiState(({ message }) => message.status.type === "running");
|
|
108
108
|
* return (
|
|
109
109
|
* <div className={`message-${role}`}>
|
|
110
110
|
* {isLoading ? "Loading..." : content.map(part => part.text).join("")}
|
|
@@ -120,7 +120,7 @@ const useEditComposerRuntime = (opt: {
|
|
|
120
120
|
}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* @deprecated Use `
|
|
123
|
+
* @deprecated Use `useAuiState(({ message }) => message.composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
124
124
|
*/
|
|
125
125
|
export const useEditComposer = createStateHookForRuntime(
|
|
126
126
|
useEditComposerRuntime,
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { MessagePartRuntime } from "../runtime/MessagePartRuntime";
|
|
4
4
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
5
|
-
import {
|
|
5
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @deprecated Use `
|
|
8
|
+
* @deprecated Use `useAui()` with `aui.part()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
9
9
|
*/
|
|
10
10
|
export function useMessagePartRuntime(options?: {
|
|
11
11
|
optional?: false | undefined;
|
|
@@ -16,9 +16,9 @@ export function useMessagePartRuntime(options?: {
|
|
|
16
16
|
export function useMessagePartRuntime(options?: {
|
|
17
17
|
optional?: boolean | undefined;
|
|
18
18
|
}) {
|
|
19
|
-
const
|
|
20
|
-
const runtime =
|
|
21
|
-
|
|
19
|
+
const aui = useAui();
|
|
20
|
+
const runtime = useAuiState(() =>
|
|
21
|
+
aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,
|
|
22
22
|
);
|
|
23
23
|
if (!runtime && !options?.optional) {
|
|
24
24
|
throw new Error("MessagePartRuntime is not available");
|
|
@@ -27,6 +27,6 @@ export function useMessagePartRuntime(options?: {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* @deprecated Use `
|
|
30
|
+
* @deprecated Use `useAuiState(({ part }) => part)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
31
31
|
*/
|
|
32
32
|
export const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);
|
|
@@ -5,14 +5,10 @@ import { ThreadRuntime } from "../runtime/ThreadRuntime";
|
|
|
5
5
|
import { ModelContext } from "../../model-context";
|
|
6
6
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
|
|
7
7
|
import { ThreadComposerRuntime } from "../runtime";
|
|
8
|
-
import {
|
|
9
|
-
useAssistantApi,
|
|
10
|
-
useAssistantEvent,
|
|
11
|
-
useAssistantState,
|
|
12
|
-
} from "../../context/react";
|
|
8
|
+
import { useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
|
-
* @deprecated Use `
|
|
11
|
+
* @deprecated Use `useAui()` with `aui.thread()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
16
12
|
*
|
|
17
13
|
* Hook to access the ThreadRuntime from the current context.
|
|
18
14
|
*
|
|
@@ -36,9 +32,9 @@ import {
|
|
|
36
32
|
*
|
|
37
33
|
* // After:
|
|
38
34
|
* function MyComponent() {
|
|
39
|
-
* const
|
|
35
|
+
* const aui = useAui();
|
|
40
36
|
* const handleSendMessage = (text: string) => {
|
|
41
|
-
*
|
|
37
|
+
* aui.thread().append({ role: "user", content: [{ type: "text", text }] });
|
|
42
38
|
* };
|
|
43
39
|
* return <button onClick={() => handleSendMessage("Hello!")}>Send</button>;
|
|
44
40
|
* }
|
|
@@ -51,9 +47,9 @@ export function useThreadRuntime(options?: {
|
|
|
51
47
|
optional?: boolean | undefined;
|
|
52
48
|
}): ThreadRuntime | null;
|
|
53
49
|
export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
|
|
54
|
-
const
|
|
55
|
-
const runtime =
|
|
56
|
-
|
|
50
|
+
const aui = useAui();
|
|
51
|
+
const runtime = useAuiState(() =>
|
|
52
|
+
aui.thread.source ? (aui.thread().__internal_getRuntime?.() ?? null) : null,
|
|
57
53
|
);
|
|
58
54
|
if (!runtime && !options?.optional) {
|
|
59
55
|
throw new Error("ThreadRuntime is not available");
|
|
@@ -62,7 +58,7 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
|
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
/**
|
|
65
|
-
* @deprecated Use `
|
|
61
|
+
* @deprecated Use `useAuiState(({ thread }) => thread)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
66
62
|
*
|
|
67
63
|
* Hook to access the current thread state.
|
|
68
64
|
*
|
|
@@ -83,8 +79,8 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
|
|
|
83
79
|
*
|
|
84
80
|
* // After:
|
|
85
81
|
* function ThreadStatus() {
|
|
86
|
-
* const isRunning =
|
|
87
|
-
* const messageCount =
|
|
82
|
+
* const isRunning = useAuiState(({ thread }) => thread.isRunning);
|
|
83
|
+
* const messageCount = useAuiState(({ thread }) => thread.messages.length);
|
|
88
84
|
* return <div>Running: {isRunning}, Messages: {messageCount}</div>;
|
|
89
85
|
* }
|
|
90
86
|
* ```
|
|
@@ -96,14 +92,14 @@ const useThreadComposerRuntime = (opt: {
|
|
|
96
92
|
}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;
|
|
97
93
|
|
|
98
94
|
/**
|
|
99
|
-
* @deprecated Use `
|
|
95
|
+
* @deprecated Use `useAuiState(({ thread }) => thread.composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
100
96
|
*/
|
|
101
97
|
export const useThreadComposer = createStateHookForRuntime(
|
|
102
98
|
useThreadComposerRuntime,
|
|
103
99
|
);
|
|
104
100
|
|
|
105
101
|
/**
|
|
106
|
-
* @deprecated Use `
|
|
102
|
+
* @deprecated Use `useAuiState(({ thread }) => thread.modelContext)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
107
103
|
*/
|
|
108
104
|
export function useThreadModelContext(options?: {
|
|
109
105
|
optional?: false | undefined;
|
|
@@ -117,7 +113,7 @@ export function useThreadModelContext(options?: {
|
|
|
117
113
|
const [, rerender] = useState({});
|
|
118
114
|
|
|
119
115
|
const runtime = useThreadRuntime(options);
|
|
120
|
-
|
|
116
|
+
useAuiEvent("thread.modelContextUpdate", () => rerender({}));
|
|
121
117
|
|
|
122
118
|
if (!runtime) return null;
|
|
123
119
|
return runtime?.getModelContext();
|