@assistant-ui/react 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,15 +1,21 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType, PropsWithChildren, ComponentPropsWithoutRef, FC } from 'react';
3
3
  import { z } from 'zod';
4
+ import { JSONSchema7 } from 'json-schema';
5
+ import { LanguageModelV1FinishReason, LanguageModelV1LogProbs } from '@ai-sdk/provider';
4
6
  import { UseBoundStore, StoreApi } from 'zustand';
5
7
  import { Primitive } from '@radix-ui/react-primitive';
6
8
  import * as PopoverPrimitive from '@radix-ui/react-popover';
9
+ import * as react_textarea_autosize from 'react-textarea-autosize';
7
10
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
11
+ import * as class_variance_authority from 'class-variance-authority';
12
+ import { VariantProps } from 'class-variance-authority';
13
+ import * as class_variance_authority_types from 'class-variance-authority/types';
8
14
 
9
15
  type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
10
16
  type Tool<TArgs = unknown, TResult = unknown> = {
11
17
  description?: string | undefined;
12
- parameters: z.ZodSchema<TArgs>;
18
+ parameters: z.ZodSchema<TArgs> | JSONSchema7;
13
19
  execute: ToolExecuteFunction<TArgs, TResult>;
14
20
  };
15
21
  type ModelConfig = {
@@ -40,41 +46,76 @@ type ToolCallContentPart<TArgs = unknown, TResult = unknown> = {
40
46
  args: TArgs;
41
47
  result?: TResult;
42
48
  };
43
- type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
44
- type AssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
49
+ type ThreadUserContentPart = TextContentPart | ImageContentPart | UIContentPart;
50
+ type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
45
51
  type AppendContentPart = TextContentPart | ImageContentPart;
46
- type BaseMessage = {
52
+ type MessageCommonProps = {
47
53
  id: string;
48
54
  createdAt: Date;
49
55
  };
50
- type UserMessage = BaseMessage & {
56
+ type MessageStatus = {
57
+ type: "in_progress";
58
+ } | {
59
+ type: "done";
60
+ finishReason?: LanguageModelV1FinishReason;
61
+ logprops?: LanguageModelV1LogProbs;
62
+ usage?: {
63
+ promptTokens: number;
64
+ completionTokens: number;
65
+ };
66
+ } | {
67
+ type: "error";
68
+ error: unknown;
69
+ };
70
+ type ThreadSystemMessage = MessageCommonProps & {
71
+ role: "system";
72
+ content: [TextContentPart];
73
+ };
74
+ type ThreadUserMessage = MessageCommonProps & {
51
75
  role: "user";
52
- content: UserContentPart[];
76
+ content: ThreadUserContentPart[];
53
77
  };
54
- type AssistantMessage = BaseMessage & {
78
+ type ThreadAssistantMessage = MessageCommonProps & {
55
79
  role: "assistant";
56
- content: AssistantContentPart[];
57
- status: "in_progress" | "done" | "error";
80
+ content: ThreadAssistantContentPart[];
81
+ status: MessageStatus;
58
82
  };
59
83
  type AppendMessage = {
60
84
  parentId: string | null;
61
85
  role: "user";
62
86
  content: AppendContentPart[];
63
87
  };
64
- type ThreadMessage = UserMessage | AssistantMessage;
88
+ type ThreadMessage = ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage;
89
+ /** Core Message Types (without UI content parts) */
90
+ type CoreUserContentPart = TextContentPart | ImageContentPart;
91
+ type CoreAssistantContentPart = TextContentPart | ToolCallContentPart;
92
+ type CoreUserMessage = MessageCommonProps & {
93
+ role: "user";
94
+ content: CoreUserContentPart[];
95
+ };
96
+ type CoreAssistantMessage = MessageCommonProps & {
97
+ role: "assistant";
98
+ content: CoreAssistantContentPart[];
99
+ status: MessageStatus;
100
+ };
101
+ type CoreThreadMessage = ThreadSystemMessage | CoreUserMessage | CoreAssistantMessage;
65
102
 
66
103
  type ReactThreadRuntime = ThreadRuntime & {
67
104
  unstable_synchronizer?: ComponentType;
68
105
  };
69
106
 
107
+ type ChatModelRunUpdate = {
108
+ content: ThreadAssistantContentPart[];
109
+ };
70
110
  type ChatModelRunResult = {
71
- content: AssistantContentPart[];
111
+ content: ThreadAssistantContentPart[];
112
+ status?: MessageStatus;
72
113
  };
73
114
  type ChatModelRunOptions = {
74
115
  messages: ThreadMessage[];
75
116
  abortSignal: AbortSignal;
76
117
  config: ModelConfig;
77
- onUpdate: (result: ChatModelRunResult) => void;
118
+ onUpdate: (result: ChatModelRunUpdate) => void;
78
119
  };
79
120
  type ChatModelAdapter = {
80
121
  run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
@@ -101,7 +142,7 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
101
142
  append(message: AppendMessage): void;
102
143
  startRun(parentId: string | null): void;
103
144
  cancelRun(): void;
104
- addToolResult(toolCallId: string, result: any): void;
145
+ addToolResult(options: AddToolResultOptions): void;
105
146
  private _subscriptions;
106
147
  subscribe(callback: () => void): Unsubscribe;
107
148
  private subscriptionHandler;
@@ -137,11 +178,21 @@ declare class LocalThreadRuntime implements ThreadRuntime {
137
178
  cancelRun(): void;
138
179
  private notifySubscribers;
139
180
  subscribe(callback: () => void): Unsubscribe;
140
- addToolResult(): void;
181
+ addToolResult({ messageId, toolCallId, result }: AddToolResultOptions): void;
141
182
  }
142
183
 
143
184
  declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
144
185
 
186
+ type EdgeRuntimeOptions = {
187
+ api: string;
188
+ };
189
+ declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => LocalRuntime;
190
+
191
+ type AddToolResultOptions = {
192
+ messageId: string;
193
+ toolCallId: string;
194
+ result: any;
195
+ };
145
196
  type ThreadActionsState = Readonly<{
146
197
  capabilities: Readonly<{
147
198
  edit: boolean;
@@ -154,28 +205,27 @@ type ThreadActionsState = Readonly<{
154
205
  append: (message: AppendMessage) => void;
155
206
  startRun: (parentId: string | null) => void;
156
207
  cancelRun: () => void;
157
- addToolResult: (toolCallId: string, result: any) => void;
208
+ addToolResult: (options: AddToolResultOptions) => void;
158
209
  }>;
159
210
 
160
- type ContentPartStatus = "done" | "in_progress" | "error";
161
211
  type TextContentPartProps = {
162
212
  part: TextContentPart;
163
- status: ContentPartStatus;
213
+ status: MessageStatus;
164
214
  };
165
215
  type TextContentPartComponent = ComponentType<TextContentPartProps>;
166
216
  type ImageContentPartProps = {
167
217
  part: ImageContentPart;
168
- status: ContentPartStatus;
218
+ status: MessageStatus;
169
219
  };
170
220
  type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
171
221
  type UIContentPartProps = {
172
222
  part: UIContentPart;
173
- status: ContentPartStatus;
223
+ status: MessageStatus;
174
224
  };
175
225
  type UIContentPartComponent = ComponentType<UIContentPartProps>;
176
226
  type ToolCallContentPartProps<TArgs = any, TResult = any> = {
177
227
  part: ToolCallContentPart<TArgs, TResult>;
178
- status: ContentPartStatus;
228
+ status: MessageStatus;
179
229
  addResult: (result: any) => void;
180
230
  };
181
231
  type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
@@ -195,21 +245,18 @@ type AssistantRuntimeProviderProps = {
195
245
  };
196
246
  declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
197
247
 
248
+ type AssistantActionsState = Readonly<{
249
+ switchToThread: (threadId: string | null) => void;
250
+ }>;
251
+
198
252
  type AssistantModelConfigState = Readonly<{
199
253
  getModelConfig: ModelConfigProvider;
200
254
  registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
201
255
  }>;
202
256
 
203
- type ContentPartState = Readonly<{
204
- status: "in_progress" | "done" | "error";
205
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
206
- }>;
207
-
208
- type MessageState = Readonly<{
209
- message: Readonly<ThreadMessage>;
210
- parentId: string | null;
211
- branches: readonly string[];
212
- isLast: boolean;
257
+ type AssistantToolUIsState = Readonly<{
258
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
259
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
213
260
  }>;
214
261
 
215
262
  type BaseComposerState = Readonly<{
@@ -219,33 +266,19 @@ type BaseComposerState = Readonly<{
219
266
 
220
267
  type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
221
268
 
222
- type EditComposerState = BaseComposerState & Readonly<{
223
- canCancel: boolean;
224
- isEditing: boolean;
225
- edit: () => void;
226
- send: () => void;
227
- cancel: () => void;
228
- }>;
229
-
230
- type ThreadState = Readonly<{
231
- isRunning: boolean;
232
- }>;
233
-
234
- type AssistantToolUIsState = Readonly<{
235
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
236
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
237
- }>;
238
-
239
- type AssistantActionsState = Readonly<{
240
- switchToThread: (threadId: string | null) => void;
241
- }>;
242
-
243
269
  type AssistantContextValue = {
244
270
  useModelConfig: ReadonlyStore<AssistantModelConfigState>;
245
271
  useToolUIs: ReadonlyStore<AssistantToolUIsState>;
246
272
  useAssistantActions: ReadonlyStore<AssistantActionsState>;
247
273
  };
248
- declare const useAssistantContext: () => AssistantContextValue;
274
+ declare function useAssistantContext(): AssistantContextValue;
275
+ declare function useAssistantContext(options: {
276
+ optional: true;
277
+ }): AssistantContextValue | null;
278
+
279
+ type ThreadState = Readonly<{
280
+ isRunning: boolean;
281
+ }>;
249
282
 
250
283
  type ThreadViewportState = Readonly<{
251
284
  isAtBottom: boolean;
@@ -262,7 +295,18 @@ type ThreadContextValue = {
262
295
  useComposer: ReadonlyStore<ComposerState>;
263
296
  useViewport: ReadonlyStore<ThreadViewportState>;
264
297
  };
265
- declare const useThreadContext: () => ThreadContextValue;
298
+ declare function useThreadContext(): ThreadContextValue;
299
+ declare function useThreadContext(options: {
300
+ optional: true;
301
+ }): ThreadContextValue | null;
302
+
303
+ type EditComposerState = BaseComposerState & Readonly<{
304
+ canCancel: boolean;
305
+ isEditing: boolean;
306
+ edit: () => void;
307
+ send: () => void;
308
+ cancel: () => void;
309
+ }>;
266
310
 
267
311
  type ComposerContextValue = {
268
312
  useComposer: ReadonlyStore<EditComposerState | ComposerState>;
@@ -270,6 +314,13 @@ type ComposerContextValue = {
270
314
  };
271
315
  declare const useComposerContext: () => ComposerContextValue;
272
316
 
317
+ type MessageState = Readonly<{
318
+ message: Readonly<ThreadMessage>;
319
+ parentId: string | null;
320
+ branches: readonly string[];
321
+ isLast: boolean;
322
+ }>;
323
+
273
324
  type MessageUtilsState = Readonly<{
274
325
  isCopied: boolean;
275
326
  setIsCopied: (value: boolean) => void;
@@ -282,12 +333,23 @@ type MessageContextValue = {
282
333
  useMessageUtils: ReadonlyStore<MessageUtilsState>;
283
334
  useEditComposer: ReadonlyStore<EditComposerState>;
284
335
  };
285
- declare const useMessageContext: () => MessageContextValue;
336
+ declare function useMessageContext(): MessageContextValue;
337
+ declare function useMessageContext(options: {
338
+ optional: true;
339
+ }): MessageContextValue | null;
340
+
341
+ type ContentPartState = Readonly<{
342
+ status: MessageStatus;
343
+ part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
344
+ }>;
286
345
 
287
346
  type ContentPartContextValue = {
288
347
  useContentPart: ReadonlyStore<ContentPartState>;
289
348
  };
290
- declare const useContentPartContext: () => ContentPartContextValue;
349
+ declare function useContentPartContext(): ContentPartContextValue;
350
+ declare function useContentPartContext(options: {
351
+ optional: true;
352
+ }): ContentPartContextValue | null;
291
353
 
292
354
  type ComposerState = BaseComposerState & Readonly<{
293
355
  canCancel: boolean;
@@ -357,23 +419,24 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
357
419
  declare const useComposerSend: () => (() => void) | null;
358
420
 
359
421
  declare const useContentPartDisplay: () => Readonly<{
360
- status: "in_progress" | "done" | "error";
422
+ status: MessageStatus;
361
423
  part: UIContentPart;
362
424
  }>;
363
425
 
364
426
  declare const useContentPartImage: () => Readonly<{
365
- status: "in_progress" | "done" | "error";
427
+ status: MessageStatus;
366
428
  part: ImageContentPart;
367
429
  }>;
368
430
 
369
431
  declare const useContentPartText: () => Readonly<{
370
- status: "in_progress" | "done" | "error";
432
+ status: MessageStatus;
371
433
  part: TextContentPart;
372
434
  }>;
373
435
 
374
436
  type MessageIfFilters = {
375
437
  user: boolean | undefined;
376
438
  assistant: boolean | undefined;
439
+ system: boolean | undefined;
377
440
  hasBranches: boolean | undefined;
378
441
  copied: boolean | undefined;
379
442
  lastOrHover: boolean | undefined;
@@ -632,11 +695,13 @@ type ThreadPrimitiveMessagesProps = {
632
695
  UserMessage?: ComponentType | undefined;
633
696
  EditComposer?: ComponentType | undefined;
634
697
  AssistantMessage?: ComponentType | undefined;
698
+ SystemMessage?: ComponentType | undefined;
635
699
  } | {
636
700
  Message?: ComponentType | undefined;
637
701
  UserMessage: ComponentType;
638
702
  EditComposer?: ComponentType | undefined;
639
703
  AssistantMessage: ComponentType;
704
+ SystemMessage?: ComponentType | undefined;
640
705
  };
641
706
  };
642
707
  declare const ThreadPrimitiveMessages: react.NamedExoticComponent<ThreadPrimitiveMessagesProps>;
@@ -659,6 +724,298 @@ declare namespace index {
659
724
  export { ThreadPrimitiveEmpty as Empty, ThreadPrimitiveIf as If, ThreadPrimitiveMessages as Messages, ThreadPrimitiveRoot as Root, ThreadPrimitiveScrollToBottom as ScrollToBottom, ThreadPrimitiveSuggestion as Suggestion, ThreadPrimitiveViewport as Viewport };
660
725
  }
661
726
 
727
+ type AvatarProps = {
728
+ src?: string | undefined;
729
+ alt?: string | undefined;
730
+ fallback?: string | undefined;
731
+ };
732
+
733
+ type SuggestionConfig = {
734
+ text: string;
735
+ prompt?: string;
736
+ };
737
+ type ThreadWelcomeConfig = {
738
+ message?: string | null | undefined;
739
+ suggestions?: SuggestionConfig[] | undefined;
740
+ };
741
+ type UserMessageConfig = {
742
+ allowEdit?: boolean | undefined;
743
+ };
744
+ type AssistantMessageConfig = {
745
+ allowReload?: boolean | undefined;
746
+ allowCopy?: boolean | undefined;
747
+ components?: {
748
+ Text?: TextContentPartComponent | undefined;
749
+ } | undefined;
750
+ };
751
+ type StringsConfig = {
752
+ assistantModal?: {
753
+ open: {
754
+ button: {
755
+ tooltip?: string | undefined;
756
+ };
757
+ };
758
+ closed: {
759
+ button: {
760
+ tooltip?: string | undefined;
761
+ };
762
+ };
763
+ };
764
+ thread?: {
765
+ scrollToBottom?: {
766
+ tooltip?: string | undefined;
767
+ };
768
+ };
769
+ userMessage?: {
770
+ edit?: {
771
+ tooltip?: string | undefined;
772
+ };
773
+ };
774
+ assistantMessage?: {
775
+ reload?: {
776
+ tooltip?: string | undefined;
777
+ };
778
+ copy?: {
779
+ tooltip?: string | undefined;
780
+ };
781
+ };
782
+ branchPicker?: {
783
+ previous?: {
784
+ tooltip?: string | undefined;
785
+ };
786
+ next?: {
787
+ tooltip?: string | undefined;
788
+ };
789
+ };
790
+ composer?: {
791
+ send?: {
792
+ tooltip?: string | undefined;
793
+ } | undefined;
794
+ cancel?: {
795
+ tooltip?: string | undefined;
796
+ } | undefined;
797
+ input?: {
798
+ placeholder?: string | undefined;
799
+ };
800
+ };
801
+ editComposer?: {
802
+ send?: {
803
+ label?: string | undefined;
804
+ };
805
+ cancel?: {
806
+ label?: string | undefined;
807
+ };
808
+ };
809
+ code?: {
810
+ header?: {
811
+ copy?: {
812
+ tooltip?: string | undefined;
813
+ };
814
+ };
815
+ };
816
+ };
817
+ type ThreadConfig = {
818
+ runtime?: AssistantRuntime;
819
+ assistantAvatar?: AvatarProps;
820
+ welcome?: ThreadWelcomeConfig;
821
+ assistantMessage?: AssistantMessageConfig;
822
+ userMessage?: UserMessageConfig;
823
+ strings?: StringsConfig;
824
+ };
825
+ declare const useThreadConfig: () => Omit<ThreadConfig, "runtime">;
826
+ type ThreadConfigProviderProps = PropsWithChildren<{
827
+ config?: ThreadConfig | undefined;
828
+ }>;
829
+ declare const ThreadConfigProvider: FC<ThreadConfigProviderProps>;
830
+
831
+ declare const buttonVariants: (props?: ({
832
+ variant?: "default" | "outline" | "ghost" | null | undefined;
833
+ size?: "default" | "icon" | null | undefined;
834
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
835
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
836
+
837
+ type TooltipIconButtonProps = ButtonProps & {
838
+ tooltip: string;
839
+ side?: "top" | "bottom" | "left" | "right";
840
+ };
841
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
842
+ ref?: ((instance: HTMLButtonElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLButtonElement> | null | undefined;
843
+ } & {
844
+ asChild?: boolean;
845
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
846
+ variant?: "default" | "outline" | "ghost" | null | undefined;
847
+ size?: "default" | "icon" | null | undefined;
848
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
849
+ tooltip: string;
850
+ side?: "top" | "bottom" | "left" | "right";
851
+ } & react.RefAttributes<HTMLButtonElement>>;
852
+
853
+ declare const AssistantActionBar: FC;
854
+ declare const exports$a: {
855
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
856
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
857
+ } & {
858
+ asChild?: boolean;
859
+ }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
860
+ Reload: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
861
+ Copy: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
862
+ };
863
+ declare const _default$9: typeof AssistantActionBar & typeof exports$a;
864
+
865
+ declare const AssistantMessage: FC;
866
+ type AssistantMessageContentProps = MessagePrimitiveContentProps & ComponentPropsWithoutRef<"div">;
867
+ declare const exports$9: {
868
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
869
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
870
+ } & {
871
+ asChild?: boolean;
872
+ }, "ref"> & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
873
+ Avatar: FC;
874
+ Content: react.ForwardRefExoticComponent<MessagePrimitiveContentProps & Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
875
+ };
876
+ declare const _default$8: typeof AssistantMessage & typeof exports$9;
877
+
878
+ declare const AssistantModal: FC<ThreadConfig>;
879
+ declare const exports$8: {
880
+ Root: FC<PopoverPrimitive.PopoverProps & {
881
+ config?: ThreadConfig | undefined;
882
+ } & {
883
+ children?: react.ReactNode | undefined;
884
+ }>;
885
+ Trigger: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
886
+ Content: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<PopoverPrimitive.PopoverContentProps & react.RefAttributes<HTMLDivElement>, "ref"> & {
887
+ dissmissOnInteractOutside?: boolean | undefined;
888
+ } & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
889
+ };
890
+ declare const _default$7: typeof AssistantModal & typeof exports$8;
891
+
892
+ declare const BranchPicker: FC;
893
+ declare const exports$7: {
894
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
895
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
896
+ } & {
897
+ asChild?: boolean;
898
+ }, "ref"> & {
899
+ hideWhenSingleBranch?: boolean | undefined;
900
+ } & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
901
+ Previous: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
902
+ Next: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
903
+ };
904
+ declare const _default$6: typeof BranchPicker & typeof exports$7;
905
+
906
+ declare const Composer: FC;
907
+ declare const ComposerInputStyled: react.ForwardRefExoticComponent<Partial<Omit<Omit<react_textarea_autosize.TextareaAutosizeProps & {
908
+ asChild?: boolean | undefined;
909
+ } & react.RefAttributes<HTMLTextAreaElement>, "ref">, "asChild">> & react.RefAttributes<HTMLTextAreaElement>>;
910
+ type ComposerInputProps = ComponentPropsWithoutRef<typeof ComposerInputStyled>;
911
+ declare const exports$6: {
912
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
913
+ ref?: ((instance: HTMLFormElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLFormElement> | null | undefined;
914
+ } & {
915
+ asChild?: boolean;
916
+ }, "ref"> & react.RefAttributes<HTMLFormElement>, "ref">, "asChild">> & react.RefAttributes<HTMLFormElement>>;
917
+ Input: react.ForwardRefExoticComponent<Omit<Partial<Omit<Omit<react_textarea_autosize.TextareaAutosizeProps & {
918
+ asChild?: boolean | undefined;
919
+ } & react.RefAttributes<HTMLTextAreaElement>, "ref">, "asChild">> & react.RefAttributes<HTMLTextAreaElement>, "ref"> & react.RefAttributes<HTMLTextAreaElement>>;
920
+ Action: FC;
921
+ Send: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
922
+ Cancel: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
923
+ };
924
+ declare const _default$5: typeof Composer & typeof exports$6;
925
+
926
+ declare const EditComposer: FC;
927
+ declare const exports$5: {
928
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
929
+ ref?: ((instance: HTMLFormElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLFormElement> | null | undefined;
930
+ } & {
931
+ asChild?: boolean;
932
+ }, "ref"> & react.RefAttributes<HTMLFormElement>, "ref">, "asChild">> & react.RefAttributes<HTMLFormElement>>;
933
+ Input: react.ForwardRefExoticComponent<Partial<Omit<Omit<react_textarea_autosize.TextareaAutosizeProps & {
934
+ asChild?: boolean | undefined;
935
+ } & react.RefAttributes<HTMLTextAreaElement>, "ref">, "asChild">> & react.RefAttributes<HTMLTextAreaElement>>;
936
+ Footer: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
937
+ Cancel: react.ForwardRefExoticComponent<Partial<ButtonProps> & react.RefAttributes<HTMLButtonElement>>;
938
+ Send: react.ForwardRefExoticComponent<Partial<ButtonProps> & react.RefAttributes<HTMLButtonElement>>;
939
+ };
940
+ declare const _default$4: typeof EditComposer & typeof exports$5;
941
+
942
+ declare const Thread: FC<ThreadConfig>;
943
+ type ThreadRootProps = ThreadPrimitiveRootProps & ThreadConfigProviderProps;
944
+ declare const exports$4: {
945
+ Root: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
946
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
947
+ } & {
948
+ asChild?: boolean;
949
+ }, "ref"> & {
950
+ config?: ThreadConfig | undefined;
951
+ } & {
952
+ children?: react.ReactNode | undefined;
953
+ } & react.RefAttributes<HTMLDivElement>>;
954
+ Viewport: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
955
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
956
+ } & {
957
+ asChild?: boolean;
958
+ }, "ref"> & UseThreadViewportAutoScrollProps & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
959
+ Messages: FC<{
960
+ components?: {
961
+ UserMessage?: ComponentType | undefined;
962
+ EditComposer?: ComponentType | undefined;
963
+ AssistantMessage?: ComponentType | undefined;
964
+ SystemMessage?: ComponentType | undefined;
965
+ };
966
+ }>;
967
+ ScrollToBottom: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
968
+ ViewportFooter: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
969
+ };
970
+ declare const _default$3: typeof Thread & typeof exports$4;
971
+
972
+ declare const UserMessage: FC;
973
+ type UserMessageContentProps = MessagePrimitiveContentProps & ComponentPropsWithoutRef<"div">;
974
+ declare const exports$3: {
975
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
976
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
977
+ } & {
978
+ asChild?: boolean;
979
+ }, "ref"> & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
980
+ Content: react.ForwardRefExoticComponent<MessagePrimitiveContentProps & Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
981
+ };
982
+ declare const _default$2: typeof UserMessage & typeof exports$3;
983
+
984
+ declare const UserActionBar: FC;
985
+ declare const exports$2: {
986
+ Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
987
+ ref?: ((instance: HTMLDivElement | null) => void | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | react.RefObject<HTMLDivElement> | null | undefined;
988
+ } & {
989
+ asChild?: boolean;
990
+ }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
991
+ Edit: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
992
+ };
993
+ declare const _default$1: typeof UserActionBar & typeof exports$2;
994
+
995
+ declare const ThreadWelcome: FC;
996
+ declare const ThreadWelcomeMessageStyled: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "asChild">> & react.RefAttributes<HTMLParagraphElement>>;
997
+ type ThreadWelcomeMessageProps = Omit<ComponentPropsWithoutRef<typeof ThreadWelcomeMessageStyled>, "children"> & {
998
+ message?: string | undefined;
999
+ };
1000
+ type ThreadWelcomeSuggestionProps = {
1001
+ suggestion: SuggestionConfig;
1002
+ };
1003
+ declare const exports$1: {
1004
+ Root: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
1005
+ Center: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
1006
+ Avatar: FC;
1007
+ Message: react.ForwardRefExoticComponent<Omit<Omit<Partial<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref">, "asChild">> & react.RefAttributes<HTMLParagraphElement>, "ref">, "children"> & {
1008
+ message?: string | undefined;
1009
+ } & react.RefAttributes<HTMLParagraphElement>>;
1010
+ Suggestions: FC;
1011
+ Suggestion: FC<ThreadWelcomeSuggestionProps>;
1012
+ };
1013
+ declare const _default: typeof ThreadWelcome & typeof exports$1;
1014
+
1015
+ declare const exports: {
1016
+ Text: FC<TextContentPartProps>;
1017
+ };
1018
+
662
1019
  declare class ProxyConfigProvider {
663
1020
  private _providers;
664
1021
  getModelConfig(): ModelConfig;
@@ -672,6 +1029,10 @@ declare class MessageRepository {
672
1029
  private performOp;
673
1030
  getMessages(): ThreadMessage[];
674
1031
  addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
1032
+ getMessage(messageId: string): {
1033
+ parentId: string | null;
1034
+ message: ThreadMessage;
1035
+ };
675
1036
  appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
676
1037
  deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
677
1038
  getBranches(messageId: string): string[];
@@ -687,9 +1048,10 @@ type internal_MessageRepository = MessageRepository;
687
1048
  declare const internal_MessageRepository: typeof MessageRepository;
688
1049
  type internal_ProxyConfigProvider = ProxyConfigProvider;
689
1050
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
1051
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
690
1052
  declare const internal_useSmooth: typeof useSmooth;
691
1053
  declare namespace internal {
692
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_useSmooth as useSmooth };
1054
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_useSmooth as useSmooth };
693
1055
  }
694
1056
 
695
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantContextValue, type AssistantMessage, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ComposerContextValue, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, type ThreadContextValue, type ThreadMessage, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRuntime, type ThreadState, type ThreadViewportState, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UserContentPart, type UserMessage, makeAssistantTool, makeAssistantToolUI, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
1057
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type AppendContentPart, type AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type CoreAssistantContentPart, type CoreAssistantMessage, type CoreThreadMessage, type CoreUserContentPart, type CoreUserMessage, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type MessageStatus, type MessageUtilsState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type StringsConfig, type SuggestionConfig, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, type ThreadAssistantContentPart, type ThreadAssistantMessage, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadMessage, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserContentPart, type ThreadUserMessage, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, makeAssistantTool, makeAssistantToolUI, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };