@assistant-ui/react 0.12.9 → 0.12.10
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/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +10 -0
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/NoOpComposerClient.d.ts.map +1 -1
- package/dist/client/NoOpComposerClient.js +4 -0
- package/dist/client/NoOpComposerClient.js.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/context/react/utils/ensureBinding.js +1 -1
- package/dist/context/react/utils/ensureBinding.js.map +1 -1
- package/dist/hooks/useMessageQuote.d.ts +17 -0
- package/dist/hooks/useMessageQuote.d.ts.map +1 -0
- package/dist/hooks/useMessageQuote.js +20 -0
- package/dist/hooks/useMessageQuote.js.map +1 -0
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -2
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js +2 -0
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.js +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.js +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +6 -6
- package/dist/legacy-runtime/hooks/ComposerContext.js +4 -4
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +5 -5
- package/dist/legacy-runtime/hooks/MessageContext.js +5 -5
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.js +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +5 -5
- package/dist/legacy-runtime/hooks/ThreadContext.js +4 -4
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +1 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts +12 -0
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.js +9 -0
- package/dist/legacy-runtime/runtime/ComposerRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +2 -0
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +5 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.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 +36 -26
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +7 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts +4 -0
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +16 -2
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +3 -0
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.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 +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +4 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +7 -6
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +4 -3
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +4 -3
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +5 -5
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js +1 -1
- package/dist/primitives/attachment/AttachmentName.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 +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +3 -3
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +3 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +1 -1
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js +3 -3
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.js +4 -4
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +35 -45
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +25 -9
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.d.ts +52 -0
- package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQuote.js +57 -0
- package/dist/primitives/composer/ComposerQuote.js.map +1 -0
- package/dist/primitives/composer/ComposerStopDictation.js +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/index.d.ts +3 -0
- package/dist/primitives/composer/index.d.ts.map +1 -1
- package/dist/primitives/composer/index.js +3 -0
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js +4 -4
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +4 -4
- 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.js +3 -3
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.js +7 -7
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +5 -5
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js +6 -5
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +3 -3
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +3 -3
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +3 -3
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +3 -3
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +3 -3
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +3 -3
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts +24 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +37 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts +31 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +85 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -0
- package/dist/primitives/selectionToolbar/index.d.ts +3 -0
- package/dist/primitives/selectionToolbar/index.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/index.js +3 -0
- package/dist/primitives/selectionToolbar/index.js.map +1 -0
- package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +6 -3
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +1 -1
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +7 -7
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +3 -3
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +5 -2
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestions.js +1 -1
- package/dist/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportSlack.js +4 -4
- package/dist/primitives/thread/ThreadViewportSlack.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +1 -1
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +1 -1
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/types/QuoteTypes.d.ts +5 -0
- package/dist/types/QuoteTypes.d.ts.map +1 -0
- package/dist/types/QuoteTypes.js +2 -0
- package/dist/types/QuoteTypes.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/scopes/composer.d.ts +10 -0
- package/dist/types/scopes/composer.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.d.ts +2 -0
- package/dist/utils/getSelectionMessageId.d.ts.map +1 -0
- package/dist/utils/getSelectionMessageId.js +21 -0
- package/dist/utils/getSelectionMessageId.js.map +1 -0
- package/dist/utils/smooth/useSmooth.js +1 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +5 -5
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +2 -2
- package/src/client/ExternalThread.ts +12 -0
- package/src/client/NoOpComposerClient.tsx +4 -0
- package/src/context/providers/ChainOfThoughtByIndicesProvider.tsx +1 -1
- package/src/context/react/utils/ensureBinding.ts +1 -1
- package/src/hooks/useMessageQuote.ts +27 -0
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +1 -4
- package/src/legacy-runtime/client/ComposerRuntimeClient.ts +2 -0
- package/src/legacy-runtime/hooks/AssistantContext.ts +1 -1
- package/src/legacy-runtime/hooks/AttachmentContext.ts +1 -1
- package/src/legacy-runtime/hooks/ComposerContext.ts +6 -6
- package/src/legacy-runtime/hooks/MessageContext.ts +5 -5
- package/src/legacy-runtime/hooks/MessagePartContext.ts +1 -1
- package/src/legacy-runtime/hooks/ThreadContext.ts +5 -5
- package/src/legacy-runtime/hooks/ThreadListItemContext.ts +1 -1
- package/src/legacy-runtime/runtime/ComposerRuntime.ts +22 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +5 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +41 -31
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +8 -8
- package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.tsx +21 -2
- package/src/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.tsx +4 -0
- package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.tsx +2 -2
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx +1 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.tsx +6 -0
- package/src/primitives/actionBar/ActionBarCopy.tsx +7 -6
- package/src/primitives/actionBar/ActionBarEdit.tsx +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +4 -3
- package/src/primitives/actionBar/ActionBarSpeak.tsx +4 -3
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +1 -1
- package/src/primitives/actionBar/useActionBarFloatStatus.tsx +5 -5
- package/src/primitives/attachment/AttachmentName.tsx +1 -1
- package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerCount.tsx +1 -1
- package/src/primitives/branchPicker/BranchPickerNext.tsx +3 -3
- package/src/primitives/branchPicker/BranchPickerNumber.tsx +1 -1
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +3 -3
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +1 -3
- package/src/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -3
- package/src/primitives/composer/ComposerAddAttachment.tsx +1 -1
- package/src/primitives/composer/ComposerAttachments.tsx +1 -1
- package/src/primitives/composer/ComposerCancel.tsx +1 -1
- package/src/primitives/composer/ComposerDictate.tsx +4 -4
- package/src/primitives/composer/ComposerDictationTranscript.tsx +1 -3
- package/src/primitives/composer/ComposerIf.tsx +4 -4
- package/src/primitives/composer/ComposerInput.tsx +57 -17
- package/src/primitives/composer/ComposerQuote.tsx +109 -0
- package/src/primitives/composer/ComposerStopDictation.tsx +1 -1
- package/src/primitives/composer/index.ts +3 -0
- package/src/primitives/error/ErrorMessage.tsx +4 -4
- package/src/primitives/index.ts +2 -0
- package/src/primitives/message/MessageAttachments.tsx +4 -4
- package/src/primitives/message/MessageError.tsx +3 -3
- package/src/primitives/message/MessageIf.tsx +3 -3
- package/src/primitives/message/MessageParts.tsx +7 -7
- package/src/primitives/message/MessagePartsGrouped.tsx +5 -5
- package/src/primitives/message/MessageRoot.tsx +6 -5
- package/src/primitives/messagePart/MessagePartInProgress.tsx +1 -3
- package/src/primitives/messagePart/useMessagePartData.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartFile.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartImage.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartReasoning.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartSource.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartText.tsx +4 -3
- package/src/primitives/selectionToolbar/SelectionToolbarQuote.tsx +62 -0
- package/src/primitives/selectionToolbar/SelectionToolbarRoot.tsx +131 -0
- package/src/primitives/selectionToolbar/index.ts +8 -0
- package/src/primitives/suggestion/SuggestionDescription.tsx +1 -1
- package/src/primitives/suggestion/SuggestionTitle.tsx +1 -1
- package/src/primitives/suggestion/SuggestionTrigger.tsx +6 -3
- package/src/primitives/thread/ThreadEmpty.tsx +1 -1
- package/src/primitives/thread/ThreadIf.tsx +8 -8
- package/src/primitives/thread/ThreadMessages.tsx +3 -3
- package/src/primitives/thread/ThreadSuggestion.tsx +5 -2
- package/src/primitives/thread/ThreadSuggestions.tsx +1 -1
- package/src/primitives/thread/ThreadViewportSlack.tsx +5 -5
- package/src/primitives/threadList/ThreadListItems.tsx +2 -2
- package/src/primitives/threadList/ThreadListNew.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemTitle.tsx +1 -1
- package/src/types/QuoteTypes.ts +4 -0
- package/src/types/index.ts +2 -0
- package/src/types/scopes/composer.ts +12 -0
- package/src/utils/getSelectionMessageId.ts +20 -0
- package/src/utils/smooth/useSmooth.tsx +1 -1
- package/src/utils/useToolArgsFieldStatus.tsx +5 -5
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import type { QuoteInfo } from "../types/QuoteTypes";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook that returns the quote info for the current message, if any.
|
|
8
|
+
*
|
|
9
|
+
* Reads from `message.metadata.custom.quote`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function QuoteBlock() {
|
|
14
|
+
* const quote = useMessageQuote();
|
|
15
|
+
* if (!quote) return null;
|
|
16
|
+
* return <blockquote>{quote.text}</blockquote>;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const useMessageQuote = (): QuoteInfo | undefined => {
|
|
21
|
+
return useAuiState(
|
|
22
|
+
(s) =>
|
|
23
|
+
(s.message.metadata?.custom as Record<string, unknown>)?.quote as
|
|
24
|
+
| QuoteInfo
|
|
25
|
+
| undefined,
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -32,10 +32,7 @@ export const AssistantRuntimeProviderImpl: FC<
|
|
|
32
32
|
const aui = useAui({ threads: RuntimeAdapter(runtime) }, { parent: parent });
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
35
|
-
if (
|
|
36
|
-
typeof process === "undefined" ||
|
|
37
|
-
process.env["NODE_ENV"] === "production"
|
|
38
|
-
)
|
|
35
|
+
if (typeof process === "undefined" || process.env.NODE_ENV === "production")
|
|
39
36
|
return;
|
|
40
37
|
return DevToolsProviderApi.register(aui);
|
|
41
38
|
}, [aui]);
|
|
@@ -100,6 +100,7 @@ export const ComposerClient = resource(
|
|
|
100
100
|
isEmpty: runtimeState.isEmpty,
|
|
101
101
|
type: runtimeState.type ?? "thread",
|
|
102
102
|
dictation: runtimeState.dictation,
|
|
103
|
+
quote: runtimeState.quote,
|
|
103
104
|
};
|
|
104
105
|
}, [runtimeState, attachments.state]);
|
|
105
106
|
|
|
@@ -122,6 +123,7 @@ export const ComposerClient = resource(
|
|
|
122
123
|
}),
|
|
123
124
|
startDictation: runtime.startDictation,
|
|
124
125
|
stopDictation: runtime.stopDictation,
|
|
126
|
+
setQuote: runtime.setQuote,
|
|
125
127
|
attachment: (selector) => {
|
|
126
128
|
if ("id" in selector) {
|
|
127
129
|
return attachments.get({ key: selector.id });
|
|
@@ -62,6 +62,6 @@ const useThreadListRuntime = (opt: {
|
|
|
62
62
|
}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* @deprecated Use `useAuiState((
|
|
65
|
+
* @deprecated Use `useAuiState((s) => s.threads)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
66
66
|
*/
|
|
67
67
|
export const useThreadList = createStateHookForRuntime(useThreadListRuntime);
|
|
@@ -84,7 +84,7 @@ export function useMessageAttachmentRuntime(options?: {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* @deprecated Use `useAuiState((
|
|
87
|
+
* @deprecated Use `useAuiState((s) => s.attachment)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
88
88
|
*/
|
|
89
89
|
export const useAttachment = createStateHookForRuntime(useAttachmentRuntime);
|
|
90
90
|
|
|
@@ -44,8 +44,8 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
|
|
|
44
44
|
* // After:
|
|
45
45
|
* function ComposerActions() {
|
|
46
46
|
* const aui = useAui();
|
|
47
|
-
* const canSend = useAuiState((
|
|
48
|
-
* const canCancel = useAuiState((
|
|
47
|
+
* const canSend = useAuiState((s) => s.composer.canSend);
|
|
48
|
+
* const canCancel = useAuiState((s) => s.composer.canCancel);
|
|
49
49
|
* const handleSend = () => {
|
|
50
50
|
* if (canSend) {
|
|
51
51
|
* aui.composer().send();
|
|
@@ -87,7 +87,7 @@ export function useComposerRuntime(options?: {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* @deprecated Use `useAuiState((
|
|
90
|
+
* @deprecated Use `useAuiState((s) => s.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 = useAuiState((
|
|
119
|
-
* const canSend = useAuiState((
|
|
120
|
-
* const attachmentCount = useAuiState((
|
|
118
|
+
* const text = useAuiState((s) => s.composer.text);
|
|
119
|
+
* const canSend = useAuiState((s) => s.composer.canSend);
|
|
120
|
+
* const attachmentCount = useAuiState((s) => s.composer.attachments.length);
|
|
121
121
|
* return (
|
|
122
122
|
* <div>
|
|
123
123
|
* Text: {text.length} chars,
|
|
@@ -76,7 +76,7 @@ export function useMessageRuntime(options?: {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @deprecated Use `useAuiState((
|
|
79
|
+
* @deprecated Use `useAuiState((s) => s.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 = useAuiState((
|
|
106
|
-
* const content = useAuiState((
|
|
107
|
-
* const isLoading = useAuiState((
|
|
105
|
+
* const role = useAuiState((s) => s.message.role);
|
|
106
|
+
* const content = useAuiState((s) => s.message.content);
|
|
107
|
+
* const isLoading = useAuiState((s) => s.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 `useAuiState((
|
|
123
|
+
* @deprecated Use `useAuiState((s) => s.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,
|
|
@@ -27,6 +27,6 @@ export function useMessagePartRuntime(options?: {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* @deprecated Use `useAuiState((
|
|
30
|
+
* @deprecated Use `useAuiState((s) => s.part)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
31
31
|
*/
|
|
32
32
|
export const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);
|
|
@@ -58,7 +58,7 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* @deprecated Use `useAuiState((
|
|
61
|
+
* @deprecated Use `useAuiState((s) => s.thread)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
62
62
|
*
|
|
63
63
|
* Hook to access the current thread state.
|
|
64
64
|
*
|
|
@@ -79,8 +79,8 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
|
|
|
79
79
|
*
|
|
80
80
|
* // After:
|
|
81
81
|
* function ThreadStatus() {
|
|
82
|
-
* const isRunning = useAuiState((
|
|
83
|
-
* const messageCount = useAuiState((
|
|
82
|
+
* const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
83
|
+
* const messageCount = useAuiState((s) => s.thread.messages.length);
|
|
84
84
|
* return <div>Running: {isRunning}, Messages: {messageCount}</div>;
|
|
85
85
|
* }
|
|
86
86
|
* ```
|
|
@@ -92,14 +92,14 @@ const useThreadComposerRuntime = (opt: {
|
|
|
92
92
|
}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* @deprecated Use `useAuiState((
|
|
95
|
+
* @deprecated Use `useAuiState((s) => s.thread.composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
96
96
|
*/
|
|
97
97
|
export const useThreadComposer = createStateHookForRuntime(
|
|
98
98
|
useThreadComposerRuntime,
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* @deprecated Use `useAuiState((
|
|
102
|
+
* @deprecated Use `useAuiState((s) => s.thread.modelContext)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
103
103
|
*/
|
|
104
104
|
export function useThreadModelContext(options?: {
|
|
105
105
|
optional?: false | undefined;
|
|
@@ -29,7 +29,7 @@ export function useThreadListItemRuntime(options?: {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @deprecated Use `useAuiState((
|
|
32
|
+
* @deprecated Use `useAuiState((s) => s.threadListItem)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
|
|
33
33
|
*/
|
|
34
34
|
export const useThreadListItem = createStateHookForRuntime(
|
|
35
35
|
useThreadListItemRuntime,
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
} from "../runtime-cores/core/ComposerRuntimeCore";
|
|
11
11
|
import type { Unsubscribe } from "../../types";
|
|
12
12
|
import type { MessageRole, RunConfig } from "../../types/AssistantTypes";
|
|
13
|
+
import type { QuoteInfo } from "../../types/QuoteTypes";
|
|
13
14
|
import type {
|
|
14
15
|
ThreadComposerRuntimeCoreBinding,
|
|
15
16
|
EditComposerRuntimeCoreBinding,
|
|
@@ -51,6 +52,12 @@ type BaseComposerState = {
|
|
|
51
52
|
* Undefined when dictation is not active.
|
|
52
53
|
*/
|
|
53
54
|
readonly dictation: DictationState | undefined;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The currently quoted text, if any.
|
|
58
|
+
* Undefined when no quote is set.
|
|
59
|
+
*/
|
|
60
|
+
readonly quote: QuoteInfo | undefined;
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
export type ThreadComposerState = BaseComposerState & {
|
|
@@ -83,6 +90,7 @@ const getThreadComposerState = (
|
|
|
83
90
|
runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
|
|
84
91
|
attachmentAccept: runtime?.attachmentAccept ?? "",
|
|
85
92
|
dictation: runtime?.dictation,
|
|
93
|
+
quote: runtime?.quote,
|
|
86
94
|
|
|
87
95
|
value: runtime?.text ?? "",
|
|
88
96
|
});
|
|
@@ -104,6 +112,7 @@ const getEditComposerState = (
|
|
|
104
112
|
runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
|
|
105
113
|
attachmentAccept: runtime?.attachmentAccept ?? "",
|
|
106
114
|
dictation: runtime?.dictation,
|
|
115
|
+
quote: runtime?.quote,
|
|
107
116
|
|
|
108
117
|
value: runtime?.text ?? "",
|
|
109
118
|
});
|
|
@@ -192,6 +201,12 @@ export type ComposerRuntime = {
|
|
|
192
201
|
*/
|
|
193
202
|
stopDictation(): void;
|
|
194
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Set a quote for the next message. Pass undefined to clear.
|
|
206
|
+
* @param quote The quote info to set, or undefined to clear.
|
|
207
|
+
*/
|
|
208
|
+
setQuote(quote: QuoteInfo | undefined): void;
|
|
209
|
+
|
|
195
210
|
/**
|
|
196
211
|
* @deprecated This API is still under active development and might change without notice.
|
|
197
212
|
*/
|
|
@@ -224,6 +239,7 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
224
239
|
this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);
|
|
225
240
|
this.startDictation = this.startDictation.bind(this);
|
|
226
241
|
this.stopDictation = this.stopDictation.bind(this);
|
|
242
|
+
this.setQuote = this.setQuote.bind(this);
|
|
227
243
|
this.unstable_on = this.unstable_on.bind(this);
|
|
228
244
|
}
|
|
229
245
|
|
|
@@ -289,6 +305,12 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
289
305
|
core.stopDictation();
|
|
290
306
|
}
|
|
291
307
|
|
|
308
|
+
public setQuote(quote: QuoteInfo | undefined) {
|
|
309
|
+
const core = this._core.getState();
|
|
310
|
+
if (!core) throw new Error("Composer is not available");
|
|
311
|
+
core.setQuote(quote);
|
|
312
|
+
}
|
|
313
|
+
|
|
292
314
|
public subscribe(callback: () => void) {
|
|
293
315
|
return this._core.subscribe(callback);
|
|
294
316
|
}
|
|
@@ -31,6 +31,8 @@ export type AssistantMessage = {
|
|
|
31
31
|
export type AddMessageCommand = {
|
|
32
32
|
readonly type: "add-message";
|
|
33
33
|
readonly message: UserMessage | AssistantMessage;
|
|
34
|
+
readonly parentId: string | null;
|
|
35
|
+
readonly sourceId: string | null;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
export type AddToolResultCommand = {
|
|
@@ -109,6 +111,9 @@ export type AssistantTransportOptions<T> = {
|
|
|
109
111
|
updateState: (updater: (state: T) => T) => void;
|
|
110
112
|
error?: Error;
|
|
111
113
|
}) => void;
|
|
114
|
+
capabilities?: {
|
|
115
|
+
edit?: boolean;
|
|
116
|
+
};
|
|
112
117
|
adapters?: {
|
|
113
118
|
attachments?: AttachmentAdapter | undefined;
|
|
114
119
|
history?: ThreadHistoryAdapter | undefined;
|
package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx
CHANGED
|
@@ -35,6 +35,36 @@ import { InMemoryThreadListAdapter } from "../remote-thread-list/adapter/in-memo
|
|
|
35
35
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
36
36
|
import { UserExternalState } from "../../../augmentations";
|
|
37
37
|
|
|
38
|
+
const convertAppendMessageToCommand = (
|
|
39
|
+
message: AppendMessage,
|
|
40
|
+
): AddMessageCommand => {
|
|
41
|
+
if (message.role !== "user")
|
|
42
|
+
throw new Error("Only user messages are supported");
|
|
43
|
+
|
|
44
|
+
const parts: UserMessagePart[] = [];
|
|
45
|
+
const content = [
|
|
46
|
+
...message.content,
|
|
47
|
+
...(message.attachments?.flatMap((a) => a.content) ?? []),
|
|
48
|
+
];
|
|
49
|
+
for (const contentPart of content) {
|
|
50
|
+
if (contentPart.type === "text") {
|
|
51
|
+
parts.push({ type: "text", text: contentPart.text });
|
|
52
|
+
} else if (contentPart.type === "image") {
|
|
53
|
+
parts.push({ type: "image", image: contentPart.image });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
type: "add-message",
|
|
59
|
+
message: {
|
|
60
|
+
role: "user",
|
|
61
|
+
parts,
|
|
62
|
+
},
|
|
63
|
+
parentId: message.parentId,
|
|
64
|
+
sourceId: message.sourceId,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
38
68
|
const symbolAssistantTransportExtras = Symbol("assistant-transport-extras");
|
|
39
69
|
type AssistantTransportExtras = {
|
|
40
70
|
[symbolAssistantTransportExtras]: true;
|
|
@@ -74,8 +104,8 @@ export function useAssistantTransportState<T>(
|
|
|
74
104
|
export function useAssistantTransportState<T>(
|
|
75
105
|
selector: (state: UserExternalState) => T = (t) => t as T,
|
|
76
106
|
): T | UserExternalState {
|
|
77
|
-
return useAuiState((
|
|
78
|
-
selector(asAssistantTransportExtras(thread.extras).state),
|
|
107
|
+
return useAuiState((s) =>
|
|
108
|
+
selector(asAssistantTransportExtras(s.thread.extras).state),
|
|
79
109
|
);
|
|
80
110
|
}
|
|
81
111
|
|
|
@@ -90,7 +120,7 @@ const useAssistantTransportThreadRuntime = <T,>(
|
|
|
90
120
|
onQueue: () => runManager.schedule(),
|
|
91
121
|
});
|
|
92
122
|
|
|
93
|
-
const threadId = useAuiState((
|
|
123
|
+
const threadId = useAuiState((s) => s.threadListItem.remoteId);
|
|
94
124
|
|
|
95
125
|
const runManager = useRunManager({
|
|
96
126
|
onRun: async (signal: AbortSignal) => {
|
|
@@ -254,37 +284,17 @@ const useAssistantTransportThreadRuntime = <T,>(
|
|
|
254
284
|
state: agentStateRef.current as UserExternalState,
|
|
255
285
|
} satisfies AssistantTransportExtras,
|
|
256
286
|
onNew: async (message: AppendMessage): Promise<void> => {
|
|
257
|
-
if (message.role !== "user")
|
|
258
|
-
throw new Error("Only user messages are supported");
|
|
259
|
-
|
|
260
|
-
// Store parentId for the request
|
|
261
287
|
parentIdRef.current = message.parentId;
|
|
262
|
-
|
|
263
|
-
// Convert AppendMessage to AddMessageCommand
|
|
264
|
-
const parts: UserMessagePart[] = [];
|
|
265
|
-
|
|
266
|
-
const content = [
|
|
267
|
-
...message.content,
|
|
268
|
-
...(message.attachments?.flatMap((a) => a.content) ?? []),
|
|
269
|
-
];
|
|
270
|
-
for (const contentPart of content) {
|
|
271
|
-
if (contentPart.type === "text") {
|
|
272
|
-
parts.push({ type: "text", text: contentPart.text });
|
|
273
|
-
} else if (contentPart.type === "image") {
|
|
274
|
-
parts.push({ type: "image", image: contentPart.image });
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const command: AddMessageCommand = {
|
|
279
|
-
type: "add-message",
|
|
280
|
-
message: {
|
|
281
|
-
role: "user",
|
|
282
|
-
parts,
|
|
283
|
-
},
|
|
284
|
-
};
|
|
285
|
-
|
|
288
|
+
const command = convertAppendMessageToCommand(message);
|
|
286
289
|
commandQueue.enqueue(command);
|
|
287
290
|
},
|
|
291
|
+
...(options.capabilities?.edit && {
|
|
292
|
+
onEdit: async (message: AppendMessage): Promise<void> => {
|
|
293
|
+
parentIdRef.current = message.parentId;
|
|
294
|
+
const command = convertAppendMessageToCommand(message);
|
|
295
|
+
commandQueue.enqueue(command);
|
|
296
|
+
},
|
|
297
|
+
}),
|
|
288
298
|
onCancel: async () => {
|
|
289
299
|
runManager.cancel();
|
|
290
300
|
await toolInvocations.abort();
|
|
@@ -181,7 +181,7 @@ export function useToolInvocations({
|
|
|
181
181
|
|
|
182
182
|
if (content.argsText !== lastState.argsText) {
|
|
183
183
|
if (lastState.argsComplete) {
|
|
184
|
-
if (process.env
|
|
184
|
+
if (process.env.NODE_ENV !== "production") {
|
|
185
185
|
console.warn(
|
|
186
186
|
"argsText updated after controller was closed:",
|
|
187
187
|
{
|
|
@@ -233,6 +233,13 @@ export function useToolInvocations({
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
if (content.result !== undefined && !lastState.hasResult) {
|
|
236
|
+
lastToolStates.current[content.toolCallId] = {
|
|
237
|
+
hasResult: true,
|
|
238
|
+
argsComplete: true,
|
|
239
|
+
argsText: lastState.argsText,
|
|
240
|
+
controller: lastState.controller,
|
|
241
|
+
};
|
|
242
|
+
|
|
236
243
|
lastState.controller.setResponse(
|
|
237
244
|
new ToolResponse({
|
|
238
245
|
result: content.result as ReadonlyJSONValue,
|
|
@@ -241,13 +248,6 @@ export function useToolInvocations({
|
|
|
241
248
|
}),
|
|
242
249
|
);
|
|
243
250
|
lastState.controller.close();
|
|
244
|
-
|
|
245
|
-
lastToolStates.current[content.toolCallId] = {
|
|
246
|
-
hasResult: true,
|
|
247
|
-
argsComplete: true,
|
|
248
|
-
argsText: lastState.argsText,
|
|
249
|
-
controller: lastState.controller,
|
|
250
|
-
};
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
DictationState,
|
|
12
12
|
} from "../core/ComposerRuntimeCore";
|
|
13
13
|
import type { MessageRole, RunConfig } from "../../../types/AssistantTypes";
|
|
14
|
+
import type { QuoteInfo } from "../../../types/QuoteTypes";
|
|
14
15
|
import { BaseSubscribable } from "../remote-thread-list/BaseSubscribable";
|
|
15
16
|
import type { DictationAdapter } from "../adapters/speech/SpeechAdapterTypes";
|
|
16
17
|
|
|
@@ -64,6 +65,19 @@ export abstract class BaseComposerRuntimeCore
|
|
|
64
65
|
return this._runConfig;
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
private _quote: QuoteInfo | undefined = undefined;
|
|
69
|
+
|
|
70
|
+
get quote() {
|
|
71
|
+
return this._quote;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public setQuote(quote: QuoteInfo | undefined) {
|
|
75
|
+
if (this._quote === quote) return;
|
|
76
|
+
|
|
77
|
+
this._quote = quote;
|
|
78
|
+
this._notifySubscribers();
|
|
79
|
+
}
|
|
80
|
+
|
|
67
81
|
public setText(value: string) {
|
|
68
82
|
if (this._text === value) return;
|
|
69
83
|
|
|
@@ -112,13 +126,15 @@ export abstract class BaseComposerRuntimeCore
|
|
|
112
126
|
this._attachments.length === 0 &&
|
|
113
127
|
this._text === "" &&
|
|
114
128
|
this._role === "user" &&
|
|
115
|
-
Object.keys(this._runConfig).length === 0
|
|
129
|
+
Object.keys(this._runConfig).length === 0 &&
|
|
130
|
+
this._quote === undefined
|
|
116
131
|
) {
|
|
117
132
|
return;
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
this._role = "user";
|
|
121
136
|
this._runConfig = {};
|
|
137
|
+
this._quote = undefined;
|
|
122
138
|
|
|
123
139
|
const task = this._onClearAttachments();
|
|
124
140
|
this._emptyTextAndAttachments();
|
|
@@ -151,14 +167,17 @@ export abstract class BaseComposerRuntimeCore
|
|
|
151
167
|
: [];
|
|
152
168
|
|
|
153
169
|
const text = this.text;
|
|
170
|
+
const quote = this._quote;
|
|
171
|
+
this._quote = undefined;
|
|
154
172
|
this._emptyTextAndAttachments();
|
|
173
|
+
|
|
155
174
|
const message: Omit<AppendMessage, "parentId" | "sourceId"> = {
|
|
156
175
|
createdAt: new Date(),
|
|
157
176
|
role: this.role,
|
|
158
177
|
content: text ? [{ type: "text", text }] : [],
|
|
159
178
|
attachments: await attachments,
|
|
160
179
|
runConfig: this.runConfig,
|
|
161
|
-
metadata: { custom: {} },
|
|
180
|
+
metadata: { custom: { ...(quote ? { quote } : {}) } },
|
|
162
181
|
};
|
|
163
182
|
|
|
164
183
|
this.handleSend(message);
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
} from "../../../types";
|
|
6
6
|
import type { MessageRole, RunConfig } from "../../../types/AssistantTypes";
|
|
7
7
|
import type { DictationAdapter } from "../adapters/speech/SpeechAdapterTypes";
|
|
8
|
+
import type { QuoteInfo } from "../../../types/QuoteTypes";
|
|
8
9
|
|
|
9
10
|
export type ComposerRuntimeEventType = "send" | "attachmentAdd";
|
|
10
11
|
|
|
@@ -49,6 +50,9 @@ export type ComposerRuntimeCore = Readonly<{
|
|
|
49
50
|
runConfig: RunConfig;
|
|
50
51
|
setRunConfig: (runConfig: RunConfig) => void;
|
|
51
52
|
|
|
53
|
+
quote: QuoteInfo | undefined;
|
|
54
|
+
setQuote: (quote: QuoteInfo | undefined) => void;
|
|
55
|
+
|
|
52
56
|
reset: () => Promise<void>;
|
|
53
57
|
clearAttachments: () => Promise<void>;
|
|
54
58
|
|
|
@@ -63,8 +63,8 @@ export const createMessageConverter = <T extends object>(
|
|
|
63
63
|
return undefined;
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
const messageMessages = useAuiState<T[]>((
|
|
67
|
-
getExternalStoreMessages(message),
|
|
66
|
+
const messageMessages = useAuiState<T[]>((s) =>
|
|
67
|
+
getExternalStoreMessages(s.message),
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
const messages = partMessages ?? messageMessages;
|
|
@@ -27,9 +27,7 @@ const useLocalThreadRuntime = (
|
|
|
27
27
|
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
28
28
|
|
|
29
29
|
const threadIdRef = useRef<string | undefined>(undefined);
|
|
30
|
-
threadIdRef.current = useAuiState(
|
|
31
|
-
({ threadListItem }) => threadListItem.remoteId,
|
|
32
|
-
);
|
|
30
|
+
threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);
|
|
33
31
|
|
|
34
32
|
useEffect(() => {
|
|
35
33
|
runtime.threads
|
|
@@ -37,15 +37,16 @@ const useActionBarPrimitiveCopy = ({
|
|
|
37
37
|
copiedDuration?: number | undefined;
|
|
38
38
|
} = {}) => {
|
|
39
39
|
const aui = useAui();
|
|
40
|
-
const hasCopyableContent = useAuiState((
|
|
40
|
+
const hasCopyableContent = useAuiState((s) => {
|
|
41
41
|
return (
|
|
42
|
-
(message.role !== "assistant" ||
|
|
43
|
-
|
|
42
|
+
(s.message.role !== "assistant" ||
|
|
43
|
+
s.message.status?.type !== "running") &&
|
|
44
|
+
s.message.parts.some((c) => c.type === "text" && c.text.length > 0)
|
|
44
45
|
);
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
const isEditing = useAuiState((
|
|
48
|
-
const composerValue = useAuiState((
|
|
48
|
+
const isEditing = useAuiState((s) => s.composer.isEditing);
|
|
49
|
+
const composerValue = useAuiState((s) => s.composer.text);
|
|
49
50
|
|
|
50
51
|
const callback = useCallback(() => {
|
|
51
52
|
const valueToCopy = isEditing ? composerValue : aui.message().getCopyText();
|
|
@@ -89,7 +90,7 @@ export const ActionBarPrimitiveCopy = forwardRef<
|
|
|
89
90
|
ActionBarPrimitiveCopy.Element,
|
|
90
91
|
ActionBarPrimitiveCopy.Props
|
|
91
92
|
>(({ copiedDuration, onClick, disabled, ...props }, forwardedRef) => {
|
|
92
|
-
const isCopied = useAuiState((
|
|
93
|
+
const isCopied = useAuiState((s) => s.message.isCopied);
|
|
93
94
|
const callback = useActionBarPrimitiveCopy({ copiedDuration });
|
|
94
95
|
return (
|
|
95
96
|
<Primitive.button
|
|
@@ -31,7 +31,7 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
31
31
|
*/
|
|
32
32
|
const useActionBarEdit = () => {
|
|
33
33
|
const aui = useAui();
|
|
34
|
-
const disabled = useAuiState((
|
|
34
|
+
const disabled = useAuiState((s) => s.composer.isEditing);
|
|
35
35
|
|
|
36
36
|
const callback = useCallback(() => {
|
|
37
37
|
aui.composer().beginEdit();
|
|
@@ -14,10 +14,11 @@ const useActionBarExportMarkdown = ({
|
|
|
14
14
|
onExport?: ((content: string) => void | Promise<void>) | undefined;
|
|
15
15
|
} = {}) => {
|
|
16
16
|
const aui = useAui();
|
|
17
|
-
const hasExportableContent = useAuiState((
|
|
17
|
+
const hasExportableContent = useAuiState((s) => {
|
|
18
18
|
return (
|
|
19
|
-
(message.role !== "assistant" ||
|
|
20
|
-
|
|
19
|
+
(s.message.role !== "assistant" ||
|
|
20
|
+
s.message.status?.type !== "running") &&
|
|
21
|
+
s.message.parts.some((c) => c.type === "text" && c.text.length > 0)
|
|
21
22
|
);
|
|
22
23
|
});
|
|
23
24
|
|
|
@@ -14,10 +14,11 @@ const useActionBarSpeak = () => {
|
|
|
14
14
|
aui.message().speak();
|
|
15
15
|
}, [aui]);
|
|
16
16
|
|
|
17
|
-
const hasSpeakableContent = useAuiState((
|
|
17
|
+
const hasSpeakableContent = useAuiState((s) => {
|
|
18
18
|
return (
|
|
19
|
-
(message.role !== "assistant" ||
|
|
20
|
-
|
|
19
|
+
(s.message.role !== "assistant" ||
|
|
20
|
+
s.message.status?.type !== "running") &&
|
|
21
|
+
s.message.parts.some((c) => c.type === "text" && c.text.length > 0)
|
|
21
22
|
);
|
|
22
23
|
});
|
|
23
24
|
|
|
@@ -10,7 +10,7 @@ import { useAuiState, useAui } from "@assistant-ui/store";
|
|
|
10
10
|
|
|
11
11
|
const useActionBarStopSpeaking = () => {
|
|
12
12
|
const aui = useAui();
|
|
13
|
-
const isSpeaking = useAuiState((
|
|
13
|
+
const isSpeaking = useAuiState((s) => s.message.speech != null);
|
|
14
14
|
|
|
15
15
|
const callback = useCallback(() => {
|
|
16
16
|
aui.message().stopSpeaking();
|
|
@@ -19,22 +19,22 @@ export const useActionBarFloatStatus = ({
|
|
|
19
19
|
autohide,
|
|
20
20
|
autohideFloat,
|
|
21
21
|
}: UseActionBarFloatStatusProps) => {
|
|
22
|
-
return useAuiState((
|
|
23
|
-
if (hideWhenRunning && thread.isRunning) return HideAndFloatStatus.Hidden;
|
|
22
|
+
return useAuiState((s) => {
|
|
23
|
+
if (hideWhenRunning && s.thread.isRunning) return HideAndFloatStatus.Hidden;
|
|
24
24
|
|
|
25
25
|
const autohideEnabled =
|
|
26
|
-
autohide === "always" || (autohide === "not-last" && !message.isLast);
|
|
26
|
+
autohide === "always" || (autohide === "not-last" && !s.message.isLast);
|
|
27
27
|
|
|
28
28
|
// normal status
|
|
29
29
|
if (!autohideEnabled) return HideAndFloatStatus.Normal;
|
|
30
30
|
|
|
31
31
|
// hidden status
|
|
32
|
-
if (!message.isHovering) return HideAndFloatStatus.Hidden;
|
|
32
|
+
if (!s.message.isHovering) return HideAndFloatStatus.Hidden;
|
|
33
33
|
|
|
34
34
|
// floating status
|
|
35
35
|
if (
|
|
36
36
|
autohideFloat === "always" ||
|
|
37
|
-
(autohideFloat === "single-branch" && message.branchCount <= 1)
|
|
37
|
+
(autohideFloat === "single-branch" && s.message.branchCount <= 1)
|
|
38
38
|
)
|
|
39
39
|
return HideAndFloatStatus.Floating;
|
|
40
40
|
|