@assistant-ui/react 0.5.51 → 0.5.53

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, PropsWithChildren, FC, ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
3
- import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as ModelConfigProvider, e as TextContentPart, C as ContentPartStatus, I as ImageContentPart, U as UIContentPart, f as ToolCallContentPart, g as ToolCallContentPartStatus, h as CoreMessage, i as ThreadComposerAttachment, j as MessageAttachment, A as AppendMessage, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions } from './edge-BJordJU0.mjs';
3
+ import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as ModelConfigProvider, C as ContentPartStatus, e as TextContentPart, I as ImageContentPart, U as UIContentPart, f as ToolCallContentPart, g as ToolCallContentPartStatus, h as CoreMessage, i as ThreadComposerAttachment, j as MessageAttachment, A as AppendMessage, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions } from './edge-BJordJU0.mjs';
4
4
  export { s as CoreAssistantContentPart, v as CoreAssistantMessage, t as CoreSystemMessage, r as CoreUserContentPart, u as CoreUserMessage, E as EdgeRuntimeRequestOptions, p as ThreadAssistantMessage, o as ThreadSystemMessage, n as ThreadUserContentPart, q as ThreadUserMessage } from './edge-BJordJU0.mjs';
5
5
  import { UseBoundStore, StoreApi } from 'zustand';
6
6
  import { Primitive } from '@radix-ui/react-primitive';
@@ -61,6 +61,10 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
61
61
  private subscriptionHandler;
62
62
  }
63
63
 
64
+ type EmptyContentPartProps = {
65
+ status: ContentPartStatus;
66
+ };
67
+ type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
64
68
  type TextContentPartProps = {
65
69
  part: TextContentPart;
66
70
  status: ContentPartStatus;
@@ -232,9 +236,10 @@ type fromLanguageModelMessagesOptions = {
232
236
  declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeRoundtrips }: fromLanguageModelMessagesOptions) => CoreMessage[];
233
237
 
234
238
  declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
235
- declare const fromCoreMessage: (message: CoreMessage, { id, status, }?: {
239
+ declare const fromCoreMessage: (message: CoreMessage, { id, status, attachments, }?: {
236
240
  id?: string | undefined;
237
241
  status?: MessageStatus | undefined;
242
+ attachments?: readonly MessageAttachment[] | undefined;
238
243
  }) => ThreadMessage;
239
244
 
240
245
  declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
@@ -557,6 +562,11 @@ type AssistantRuntimeProviderProps = {
557
562
  };
558
563
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
559
564
 
565
+ type TextContentPartProviderProps = {
566
+ text: string;
567
+ };
568
+ declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
569
+
560
570
  type AssistantActionsState = Readonly<{
561
571
  switchToThread: (threadId: string | null) => void;
562
572
  getRuntime: () => AssistantRuntime;
@@ -1005,7 +1015,7 @@ declare const MessagePrimitiveIf: FC<MessagePrimitiveIfProps>;
1005
1015
 
1006
1016
  type MessagePrimitiveContentProps = {
1007
1017
  components?: {
1008
- Empty?: TextContentPartComponent | undefined;
1018
+ Empty?: EmptyContentPartComponent | undefined;
1009
1019
  Text?: TextContentPartComponent | undefined;
1010
1020
  Image?: ImageContentPartComponent | undefined;
1011
1021
  UI?: UIContentPartComponent | undefined;
@@ -1069,14 +1079,20 @@ declare const ThreadPrimitiveViewport: react.ForwardRefExoticComponent<Omit<Omit
1069
1079
  type ThreadPrimitiveMessagesProps = {
1070
1080
  components: {
1071
1081
  Message: ComponentType;
1072
- UserMessage?: ComponentType | undefined;
1073
1082
  EditComposer?: ComponentType | undefined;
1083
+ UserEditComposer?: ComponentType | undefined;
1084
+ AssistantEditComposer?: ComponentType | undefined;
1085
+ SystemEditComposer?: ComponentType | undefined;
1086
+ UserMessage?: ComponentType | undefined;
1074
1087
  AssistantMessage?: ComponentType | undefined;
1075
1088
  SystemMessage?: ComponentType | undefined;
1076
1089
  } | {
1077
1090
  Message?: ComponentType | undefined;
1078
- UserMessage: ComponentType;
1079
1091
  EditComposer?: ComponentType | undefined;
1092
+ UserEditComposer?: ComponentType | undefined;
1093
+ AssistantEditComposer?: ComponentType | undefined;
1094
+ SystemEditComposer?: ComponentType | undefined;
1095
+ UserMessage: ComponentType;
1080
1096
  AssistantMessage: ComponentType;
1081
1097
  SystemMessage?: ComponentType | undefined;
1082
1098
  };
@@ -1418,4 +1434,4 @@ declare const exports: {
1418
1434
  Text: FC;
1419
1435
  };
1420
1436
 
1421
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$4 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
1437
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type EmptyContentPartComponent, type EmptyContentPartProps, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$4 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, PropsWithChildren, FC, ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
3
- import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as ModelConfigProvider, e as TextContentPart, C as ContentPartStatus, I as ImageContentPart, U as UIContentPart, f as ToolCallContentPart, g as ToolCallContentPartStatus, h as CoreMessage, i as ThreadComposerAttachment, j as MessageAttachment, A as AppendMessage, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions } from './edge-BJordJU0.js';
3
+ import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as ModelConfigProvider, C as ContentPartStatus, e as TextContentPart, I as ImageContentPart, U as UIContentPart, f as ToolCallContentPart, g as ToolCallContentPartStatus, h as CoreMessage, i as ThreadComposerAttachment, j as MessageAttachment, A as AppendMessage, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions } from './edge-BJordJU0.js';
4
4
  export { s as CoreAssistantContentPart, v as CoreAssistantMessage, t as CoreSystemMessage, r as CoreUserContentPart, u as CoreUserMessage, E as EdgeRuntimeRequestOptions, p as ThreadAssistantMessage, o as ThreadSystemMessage, n as ThreadUserContentPart, q as ThreadUserMessage } from './edge-BJordJU0.js';
5
5
  import { UseBoundStore, StoreApi } from 'zustand';
6
6
  import { Primitive } from '@radix-ui/react-primitive';
@@ -61,6 +61,10 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
61
61
  private subscriptionHandler;
62
62
  }
63
63
 
64
+ type EmptyContentPartProps = {
65
+ status: ContentPartStatus;
66
+ };
67
+ type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
64
68
  type TextContentPartProps = {
65
69
  part: TextContentPart;
66
70
  status: ContentPartStatus;
@@ -232,9 +236,10 @@ type fromLanguageModelMessagesOptions = {
232
236
  declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeRoundtrips }: fromLanguageModelMessagesOptions) => CoreMessage[];
233
237
 
234
238
  declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
235
- declare const fromCoreMessage: (message: CoreMessage, { id, status, }?: {
239
+ declare const fromCoreMessage: (message: CoreMessage, { id, status, attachments, }?: {
236
240
  id?: string | undefined;
237
241
  status?: MessageStatus | undefined;
242
+ attachments?: readonly MessageAttachment[] | undefined;
238
243
  }) => ThreadMessage;
239
244
 
240
245
  declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
@@ -557,6 +562,11 @@ type AssistantRuntimeProviderProps = {
557
562
  };
558
563
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
559
564
 
565
+ type TextContentPartProviderProps = {
566
+ text: string;
567
+ };
568
+ declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
569
+
560
570
  type AssistantActionsState = Readonly<{
561
571
  switchToThread: (threadId: string | null) => void;
562
572
  getRuntime: () => AssistantRuntime;
@@ -1005,7 +1015,7 @@ declare const MessagePrimitiveIf: FC<MessagePrimitiveIfProps>;
1005
1015
 
1006
1016
  type MessagePrimitiveContentProps = {
1007
1017
  components?: {
1008
- Empty?: TextContentPartComponent | undefined;
1018
+ Empty?: EmptyContentPartComponent | undefined;
1009
1019
  Text?: TextContentPartComponent | undefined;
1010
1020
  Image?: ImageContentPartComponent | undefined;
1011
1021
  UI?: UIContentPartComponent | undefined;
@@ -1069,14 +1079,20 @@ declare const ThreadPrimitiveViewport: react.ForwardRefExoticComponent<Omit<Omit
1069
1079
  type ThreadPrimitiveMessagesProps = {
1070
1080
  components: {
1071
1081
  Message: ComponentType;
1072
- UserMessage?: ComponentType | undefined;
1073
1082
  EditComposer?: ComponentType | undefined;
1083
+ UserEditComposer?: ComponentType | undefined;
1084
+ AssistantEditComposer?: ComponentType | undefined;
1085
+ SystemEditComposer?: ComponentType | undefined;
1086
+ UserMessage?: ComponentType | undefined;
1074
1087
  AssistantMessage?: ComponentType | undefined;
1075
1088
  SystemMessage?: ComponentType | undefined;
1076
1089
  } | {
1077
1090
  Message?: ComponentType | undefined;
1078
- UserMessage: ComponentType;
1079
1091
  EditComposer?: ComponentType | undefined;
1092
+ UserEditComposer?: ComponentType | undefined;
1093
+ AssistantEditComposer?: ComponentType | undefined;
1094
+ SystemEditComposer?: ComponentType | undefined;
1095
+ UserMessage: ComponentType;
1080
1096
  AssistantMessage: ComponentType;
1081
1097
  SystemMessage?: ComponentType | undefined;
1082
1098
  };
@@ -1418,4 +1434,4 @@ declare const exports: {
1418
1434
  Text: FC;
1419
1435
  };
1420
1436
 
1421
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$4 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
1437
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type EmptyContentPartComponent, type EmptyContentPartProps, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$4 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
package/dist/index.js CHANGED
@@ -373,7 +373,8 @@ var fromCoreMessages = (message) => {
373
373
  };
374
374
  var fromCoreMessage = (message, {
375
375
  id = generateId(),
376
- status = { type: "complete", reason: "unknown" }
376
+ status = { type: "complete", reason: "unknown" },
377
+ attachments = []
377
378
  } = {}) => {
378
379
  const commonProps = {
379
380
  id,
@@ -401,7 +402,7 @@ var fromCoreMessage = (message, {
401
402
  ...commonProps,
402
403
  role,
403
404
  content: message.content,
404
- attachments: []
405
+ attachments
405
406
  };
406
407
  case "system":
407
408
  return {
@@ -1218,20 +1219,16 @@ var LocalThreadRuntime = (_class6 = class {
1218
1219
  this.notifySubscribers();
1219
1220
  }
1220
1221
  async append(message) {
1221
- if (message.role !== "user")
1222
- throw new Error(
1223
- "Only appending user messages are supported in LocalRuntime. This is likely an internal bug in assistant-ui."
1224
- );
1225
- const userMessageId = generateId();
1226
- const userMessage = {
1227
- id: userMessageId,
1228
- role: "user",
1229
- content: message.content,
1230
- attachments: _nullishCoalesce(message.attachments, () => ( [])),
1231
- createdAt: /* @__PURE__ */ new Date()
1232
- };
1233
- this.repository.addOrUpdateMessage(message.parentId, userMessage);
1234
- await this.startRun(userMessageId);
1222
+ const newMessage = fromCoreMessage(message, {
1223
+ attachments: message.attachments
1224
+ });
1225
+ this.repository.addOrUpdateMessage(message.parentId, newMessage);
1226
+ if (message.role === "user") {
1227
+ await this.startRun(newMessage.id);
1228
+ } else {
1229
+ this.repository.resetHead(newMessage.id);
1230
+ this.notifySubscribers();
1231
+ }
1235
1232
  }
1236
1233
  async startRun(parentId) {
1237
1234
  this.repository.resetHead(parentId);
@@ -2271,6 +2268,39 @@ var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
2271
2268
  };
2272
2269
  var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
2273
2270
 
2271
+ // src/context/providers/TextContentPartProvider.tsx
2272
+
2273
+
2274
+
2275
+ // src/context/react/ContentPartContext.ts
2276
+
2277
+ var ContentPartContext = _react.createContext.call(void 0,
2278
+ null
2279
+ );
2280
+ function useContentPartContext(options) {
2281
+ const context = _react.useContext.call(void 0, ContentPartContext);
2282
+ if (!_optionalChain([options, 'optionalAccess', _96 => _96.optional]) && !context)
2283
+ throw new Error(
2284
+ "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
2285
+ );
2286
+ return context;
2287
+ }
2288
+
2289
+ // src/context/providers/TextContentPartProvider.tsx
2290
+
2291
+ var TextContentPartProvider = ({ children, text }) => {
2292
+ const [context] = _react.useState.call(void 0, () => {
2293
+ const useContentPart = _zustand.create.call(void 0, () => ({
2294
+ status: { type: "complete" },
2295
+ part: { type: "text", text }
2296
+ }));
2297
+ return {
2298
+ useContentPart
2299
+ };
2300
+ });
2301
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartContext.Provider, { value: context, children });
2302
+ };
2303
+
2274
2304
  // src/context/react/ComposerContext.ts
2275
2305
 
2276
2306
 
@@ -2279,7 +2309,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
2279
2309
  var MessageContext = _react.createContext.call(void 0, null);
2280
2310
  function useMessageContext(options) {
2281
2311
  const context = _react.useContext.call(void 0, MessageContext);
2282
- if (!_optionalChain([options, 'optionalAccess', _96 => _96.optional]) && !context)
2312
+ if (!_optionalChain([options, 'optionalAccess', _97 => _97.optional]) && !context)
2283
2313
  throw new Error(
2284
2314
  "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
2285
2315
  );
@@ -2299,20 +2329,6 @@ var useComposerContext = () => {
2299
2329
  );
2300
2330
  };
2301
2331
 
2302
- // src/context/react/ContentPartContext.ts
2303
-
2304
- var ContentPartContext = _react.createContext.call(void 0,
2305
- null
2306
- );
2307
- function useContentPartContext(options) {
2308
- const context = _react.useContext.call(void 0, ContentPartContext);
2309
- if (!_optionalChain([options, 'optionalAccess', _97 => _97.optional]) && !context)
2310
- throw new Error(
2311
- "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
2312
- );
2313
- return context;
2314
- }
2315
-
2316
2332
  // src/hooks/useAppendMessage.tsx
2317
2333
 
2318
2334
  var toAppendMessage = (useThreadMessages, message) => {
@@ -2487,11 +2503,8 @@ var useActionBarCopy = ({
2487
2503
  // src/primitive-hooks/actionBar/useActionBarEdit.tsx
2488
2504
 
2489
2505
  var useActionBarEdit = () => {
2490
- const { useMessage, useEditComposer } = useMessageContext();
2491
- const disabled = useCombinedStore(
2492
- [useMessage, useEditComposer],
2493
- (m, c) => m.message.role !== "user" || c.isEditing
2494
- );
2506
+ const { useEditComposer } = useMessageContext();
2507
+ const disabled = useEditComposer((c) => c.isEditing);
2495
2508
  const callback = _react.useCallback.call(void 0, () => {
2496
2509
  const { edit } = useEditComposer.getState();
2497
2510
  edit();
@@ -3214,6 +3227,8 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
3214
3227
  } else {
3215
3228
  return null;
3216
3229
  }
3230
+ } else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
3231
+ part = EMPTY_CONTENT;
3217
3232
  }
3218
3233
  const status = toContentPartStatus(message, partIndex, part);
3219
3234
  const currentState = _optionalChain([useContentPart, 'optionalAccess', _114 => _114.getState, 'call', _115 => _115()]);
@@ -3316,8 +3331,8 @@ var defaultComponents = {
3316
3331
  };
3317
3332
  var MessageContentPartComponent = ({
3318
3333
  components: {
3319
- Empty = defaultComponents.Text,
3320
3334
  Text: Text2 = defaultComponents.Text,
3335
+ Empty,
3321
3336
  Image: Image2 = defaultComponents.Image,
3322
3337
  UI = defaultComponents.UI,
3323
3338
  tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
@@ -3333,7 +3348,9 @@ var MessageContentPartComponent = ({
3333
3348
  case "text":
3334
3349
  if (status.type === "requires-action")
3335
3350
  throw new Error("Encountered unexpected requires-action status");
3336
- if (part === EMPTY_CONTENT) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { part, status });
3351
+ if (part === EMPTY_CONTENT && !!Empty) {
3352
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { status });
3353
+ }
3337
3354
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { part, status });
3338
3355
  case "image":
3339
3356
  if (status.type === "requires-action")
@@ -4036,19 +4053,11 @@ var useMessageContext2 = (messageIndex) => {
4036
4053
  const useEditComposer = makeEditComposerStore({
4037
4054
  onEdit: () => {
4038
4055
  const message = useMessage.getState().message;
4039
- if (message.role !== "user")
4040
- throw new Error(
4041
- "Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui."
4042
- );
4043
4056
  const text = getThreadMessageText(message);
4044
4057
  return text;
4045
4058
  },
4046
4059
  onSend: (text) => {
4047
4060
  const { message, parentId } = useMessage.getState();
4048
- if (message.role !== "user")
4049
- throw new Error(
4050
- "Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui."
4051
- );
4052
4061
  const previousText = getThreadMessageText(message);
4053
4062
  if (previousText === text) return;
4054
4063
  const nonTextParts = message.content.filter(
@@ -4056,7 +4065,7 @@ var useMessageContext2 = (messageIndex) => {
4056
4065
  );
4057
4066
  useThreadActions.getState().append({
4058
4067
  parentId,
4059
- role: "user",
4068
+ role: message.role,
4060
4069
  content: [{ type: "text", text }, ...nonTextParts],
4061
4070
  attachments: message.attachments
4062
4071
  });
@@ -4090,32 +4099,53 @@ var MessageProvider = ({
4090
4099
 
4091
4100
  // src/primitives/thread/ThreadMessages.tsx
4092
4101
 
4102
+ var isComponentsSame = (prev, next) => {
4103
+ return prev.Message === next.Message && prev.EditComposer === next.EditComposer && prev.UserEditComposer === next.UserEditComposer && prev.AssistantEditComposer === next.AssistantEditComposer && prev.SystemEditComposer === next.SystemEditComposer && prev.UserMessage === next.UserMessage && prev.AssistantMessage === next.AssistantMessage && prev.SystemMessage === next.SystemMessage;
4104
+ };
4093
4105
  var DEFAULT_SYSTEM_MESSAGE = () => null;
4094
- var getComponents = (components) => {
4095
- return {
4096
- EditComposer: _nullishCoalesce(_nullishCoalesce(components.EditComposer, () => ( components.UserMessage)), () => ( components.Message)),
4097
- UserMessage: _nullishCoalesce(components.UserMessage, () => ( components.Message)),
4098
- AssistantMessage: _nullishCoalesce(components.AssistantMessage, () => ( components.Message)),
4099
- SystemMessage: _nullishCoalesce(components.SystemMessage, () => ( DEFAULT_SYSTEM_MESSAGE))
4100
- };
4106
+ var getComponent3 = (components, role, isEditing) => {
4107
+ switch (role) {
4108
+ case "user":
4109
+ if (isEditing) {
4110
+ return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.UserEditComposer, () => ( components.EditComposer)), () => ( components.UserMessage)), () => ( components.Message));
4111
+ } else {
4112
+ return _nullishCoalesce(components.UserMessage, () => ( components.Message));
4113
+ }
4114
+ case "assistant":
4115
+ if (isEditing) {
4116
+ return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.AssistantEditComposer, () => ( components.EditComposer)), () => ( components.AssistantMessage)), () => ( components.Message));
4117
+ } else {
4118
+ return _nullishCoalesce(components.AssistantMessage, () => ( components.Message));
4119
+ }
4120
+ case "system":
4121
+ if (isEditing) {
4122
+ return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.SystemEditComposer, () => ( components.EditComposer)), () => ( components.SystemMessage)), () => ( components.Message));
4123
+ } else {
4124
+ return _nullishCoalesce(components.SystemMessage, () => ( DEFAULT_SYSTEM_MESSAGE));
4125
+ }
4126
+ default:
4127
+ const _exhaustiveCheck = role;
4128
+ throw new Error(`Unknown message role: ${_exhaustiveCheck}`);
4129
+ }
4130
+ };
4131
+ var ThreadMessageComponent = ({
4132
+ components
4133
+ }) => {
4134
+ const { useMessage, useEditComposer } = useMessageContext();
4135
+ const role = useMessage((m) => m.message.role);
4136
+ const isEditing = useEditComposer((c) => c.isEditing);
4137
+ const Component = getComponent3(components, role, isEditing);
4138
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
4101
4139
  };
4102
4140
  var ThreadMessageImpl = ({
4103
4141
  messageIndex,
4104
4142
  components
4105
4143
  }) => {
4106
- const { UserMessage: UserMessage2, EditComposer: EditComposer2, AssistantMessage: AssistantMessage2, SystemMessage: SystemMessage2 } = getComponents(components);
4107
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessageProvider, { messageIndex, children: [
4108
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessagePrimitiveIf, { user: true, children: [
4109
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessage2, {}) }),
4110
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposer2, {}) })
4111
- ] }),
4112
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessage2, {}) }),
4113
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SystemMessage2, {}) })
4114
- ] });
4144
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageProvider, { messageIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
4115
4145
  };
4116
4146
  var ThreadMessage = _react.memo.call(void 0,
4117
4147
  ThreadMessageImpl,
4118
- (prev, next) => prev.messageIndex === next.messageIndex && prev.components.Message === next.components.Message && prev.components.UserMessage === next.components.UserMessage && prev.components.EditComposer === next.components.EditComposer && prev.components.AssistantMessage === next.components.AssistantMessage && prev.components.SystemMessage === next.components.SystemMessage
4148
+ (prev, next) => prev.messageIndex === next.messageIndex && isComponentsSame(prev.components, next.components)
4119
4149
  );
4120
4150
  var ThreadPrimitiveMessagesImpl = ({
4121
4151
  components
@@ -4128,7 +4158,7 @@ var ThreadPrimitiveMessagesImpl = ({
4128
4158
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
4129
4159
  var ThreadPrimitiveMessages = _react.memo.call(void 0,
4130
4160
  ThreadPrimitiveMessagesImpl,
4131
- (prev, next) => _optionalChain([prev, 'access', _198 => _198.components, 'optionalAccess', _199 => _199.Message]) === _optionalChain([next, 'access', _200 => _200.components, 'optionalAccess', _201 => _201.Message]) && _optionalChain([prev, 'access', _202 => _202.components, 'optionalAccess', _203 => _203.UserMessage]) === _optionalChain([next, 'access', _204 => _204.components, 'optionalAccess', _205 => _205.UserMessage]) && _optionalChain([prev, 'access', _206 => _206.components, 'optionalAccess', _207 => _207.EditComposer]) === _optionalChain([next, 'access', _208 => _208.components, 'optionalAccess', _209 => _209.EditComposer]) && _optionalChain([prev, 'access', _210 => _210.components, 'optionalAccess', _211 => _211.AssistantMessage]) === _optionalChain([next, 'access', _212 => _212.components, 'optionalAccess', _213 => _213.AssistantMessage]) && _optionalChain([prev, 'access', _214 => _214.components, 'optionalAccess', _215 => _215.SystemMessage]) === _optionalChain([next, 'access', _216 => _216.components, 'optionalAccess', _217 => _217.SystemMessage])
4161
+ (prev, next) => isComponentsSame(prev.components, next.components)
4132
4162
  );
4133
4163
 
4134
4164
  // src/primitives/thread/ThreadScrollToBottom.tsx
@@ -4160,7 +4190,7 @@ var ThreadConfigProvider = ({
4160
4190
  }) => {
4161
4191
  const assistant = useAssistantContext({ optional: true });
4162
4192
  const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
4163
- if (!_optionalChain([config, 'optionalAccess', _218 => _218.runtime])) return configProvider;
4193
+ if (!_optionalChain([config, 'optionalAccess', _198 => _198.runtime])) return configProvider;
4164
4194
  if (assistant) {
4165
4195
  throw new Error(
4166
4196
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -4433,7 +4463,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
4433
4463
  {
4434
4464
  components: {
4435
4465
  ...componentsProp,
4436
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _219 => _219.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
4466
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _199 => _199.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
4437
4467
  tools: toolsComponents
4438
4468
  }
4439
4469
  }
@@ -4578,7 +4608,7 @@ var ComposerAttachments = ({ components }) => {
4578
4608
  {
4579
4609
  components: {
4580
4610
  ...components,
4581
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _220 => _220.Attachment]), () => ( composer_attachment_default))
4611
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _200 => _200.Attachment]), () => ( composer_attachment_default))
4582
4612
  }
4583
4613
  }
4584
4614
  ) });
@@ -4711,7 +4741,7 @@ var ThreadWelcomeSuggestion = ({
4711
4741
  };
4712
4742
  var ThreadWelcomeSuggestions = () => {
4713
4743
  const { welcome: { suggestions } = {} } = useThreadConfig();
4714
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _221 => _221.map, 'call', _222 => _222((suggestion, idx) => {
4744
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _201 => _201.map, 'call', _202 => _202((suggestion, idx) => {
4715
4745
  const key = `${suggestion.prompt}-${idx}`;
4716
4746
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
4717
4747
  })]) });
@@ -4812,7 +4842,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
4812
4842
  {
4813
4843
  components: {
4814
4844
  ...components,
4815
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _223 => _223.Text]), () => ( content_part_default.Text))
4845
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _203 => _203.Text]), () => ( content_part_default.Text))
4816
4846
  }
4817
4847
  }
4818
4848
  ) });
@@ -4830,7 +4860,7 @@ var UserMessageAttachments = ({
4830
4860
  {
4831
4861
  components: {
4832
4862
  ...components,
4833
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _224 => _224.Attachment]), () => ( user_message_attachment_default))
4863
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _204 => _204.Attachment]), () => ( user_message_attachment_default))
4834
4864
  }
4835
4865
  }
4836
4866
  ) }) });
@@ -4931,10 +4961,10 @@ var ThreadMessages = ({ components, ...rest }) => {
4931
4961
  thread_exports.Messages,
4932
4962
  {
4933
4963
  components: {
4934
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _225 => _225.UserMessage]), () => ( user_message_default)),
4935
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _226 => _226.EditComposer]), () => ( edit_composer_default)),
4936
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _227 => _227.AssistantMessage]), () => ( assistant_message_default)),
4937
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _228 => _228.SystemMessage]), () => ( SystemMessage))
4964
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _205 => _205.UserMessage]), () => ( user_message_default)),
4965
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _206 => _206.EditComposer]), () => ( edit_composer_default)),
4966
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _207 => _207.AssistantMessage]), () => ( assistant_message_default)),
4967
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _208 => _208.SystemMessage]), () => ( SystemMessage))
4938
4968
  },
4939
4969
  ...rest
4940
4970
  }
@@ -5123,5 +5153,6 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
5123
5153
 
5124
5154
 
5125
5155
 
5126
- exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunk4LR4BB23js.toCoreMessage; exports.toCoreMessages = _chunk4LR4BB23js.toCoreMessages; exports.toLanguageModelMessages = _chunk4LR4BB23js.toLanguageModelMessages; exports.toLanguageModelTools = _chunk4LR4BB23js.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
5156
+
5157
+ exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunk4LR4BB23js.toCoreMessage; exports.toCoreMessages = _chunk4LR4BB23js.toCoreMessages; exports.toLanguageModelMessages = _chunk4LR4BB23js.toLanguageModelMessages; exports.toLanguageModelTools = _chunk4LR4BB23js.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
5127
5158
  //# sourceMappingURL=index.js.map