@assistant-ui/react 0.1.11 → 0.2.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,10 +1,10 @@
1
1
  import * as react from 'react';
2
- import { FC, ReactNode, PropsWithChildren, ComponentType, ComponentPropsWithoutRef } from 'react';
2
+ import { FC, PropsWithChildren, ComponentPropsWithoutRef, ReactNode, ComponentType } from 'react';
3
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
3
4
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
- import { T as TextContentPartComponent, I as ImageContentPartComponent, U as UIContentPartComponent, a as ToolCallContentPartComponent, b as ToolCallContentPartProps, c as ThreadState, d as ThreadActionsState, e as Unsubscribe, M as ModelConfigProvider, f as ThreadMessage, g as ModelConfig, A as AssistantContentPart, h as AppendMessage } from './ThreadActions-BLcKtagX.mjs';
5
- export { l as AppendContentPart, i as AssistantMessage, m as TextContentPart, k as UserContentPart, j as UserMessage } from './ThreadActions-BLcKtagX.mjs';
6
5
  import { Primitive } from '@radix-ui/react-primitive';
7
- import 'zod';
6
+ import { z } from 'zod';
7
+ import { UseBoundStore, StoreApi } from 'zustand';
8
8
 
9
9
  type UseActionBarCopyProps = {
10
10
  copiedDuration?: number;
@@ -73,63 +73,80 @@ type UseApplyThreadSuggestionProps = {
73
73
  };
74
74
  declare const useThreadSuggestion: ({ prompt, autoSend, }: UseApplyThreadSuggestionProps) => (() => void) | null;
75
75
 
76
- declare const ThreadRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
76
+ type UseActionBarFloatStatusProps = {
77
+ hideWhenRunning?: boolean | undefined;
78
+ autohide?: "always" | "not-last" | "never" | undefined;
79
+ autohideFloat?: "always" | "single-branch" | "never" | undefined;
80
+ };
81
+ declare const ActionBarRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
77
82
  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;
78
83
  } & {
79
84
  asChild?: boolean;
80
- }, "ref"> & react.RefAttributes<HTMLDivElement>>;
81
-
82
- type ThreadEmptyProps = {
83
- children: ReactNode;
84
- };
85
- declare const ThreadEmpty: FC<ThreadEmptyProps>;
85
+ }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>>;
86
86
 
87
- type ThreadIfProps = PropsWithChildren<UseThreadIfProps>;
88
- declare const ThreadIf: FC<ThreadIfProps>;
87
+ declare const ActionBarCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
88
+ 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;
89
+ } & {
90
+ asChild?: boolean;
91
+ }, "ref"> & {
92
+ copiedDuration?: number;
93
+ } & react.RefAttributes<HTMLButtonElement>>;
89
94
 
90
- type UseThreadViewportAutoScrollProps = {
91
- autoScroll?: boolean | undefined;
92
- };
95
+ declare const ActionBarReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
96
+ 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;
97
+ } & {
98
+ asChild?: boolean;
99
+ }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
93
100
 
94
- declare const ThreadViewport: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
95
- 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;
101
+ declare const ActionBarEdit: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
102
+ 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;
96
103
  } & {
97
104
  asChild?: boolean;
98
- }, "ref"> & UseThreadViewportAutoScrollProps & react.RefAttributes<HTMLDivElement>>;
105
+ }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
99
106
 
100
- type ThreadMessagesProps = {
101
- components: {
102
- Message: ComponentType;
103
- UserMessage?: ComponentType;
104
- EditComposer?: ComponentType;
105
- AssistantMessage?: ComponentType;
106
- } | {
107
- Message?: ComponentType;
108
- UserMessage: ComponentType;
109
- EditComposer?: ComponentType;
110
- AssistantMessage: ComponentType;
111
- };
112
- };
113
- declare const ThreadMessages: FC<ThreadMessagesProps>;
107
+ declare namespace index$6 {
108
+ export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
109
+ }
114
110
 
115
- declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
111
+ type AssistantModalRootProps = PopoverPrimitive.PopoverProps;
112
+ declare const AssistantModalRoot: FC<AssistantModalRootProps>;
113
+
114
+ declare const AssistantModalTrigger: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverTriggerProps & react.RefAttributes<HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
115
+
116
+ declare const AssistantModalContent: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & react.RefAttributes<HTMLDivElement>, "ref"> & {
117
+ dissmissOnInteractOutside?: boolean;
118
+ } & react.RefAttributes<HTMLDivElement>>;
119
+
120
+ declare namespace index$5 {
121
+ export { AssistantModalContent as Content, AssistantModalRoot as Root, AssistantModalTrigger as Trigger };
122
+ }
123
+
124
+ declare const BranchPickerNext: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
116
125
  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;
117
126
  } & {
118
127
  asChild?: boolean;
119
128
  }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
120
129
 
121
- declare const ThreadSuggestion: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
130
+ declare const BranchPickerPrevious: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
122
131
  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;
123
132
  } & {
124
133
  asChild?: boolean;
134
+ }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
135
+
136
+ declare const BranchPickerCount: FC;
137
+
138
+ declare const BranchPickerNumber: FC;
139
+
140
+ declare const BranchPickerRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
141
+ 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;
142
+ } & {
143
+ asChild?: boolean;
125
144
  }, "ref"> & {
126
- prompt: string;
127
- method: "replace";
128
- autoSend?: boolean;
129
- } & react.RefAttributes<HTMLButtonElement>>;
145
+ hideWhenSingleBranch?: boolean;
146
+ } & react.RefAttributes<HTMLDivElement>>;
130
147
 
131
- declare namespace index$5 {
132
- export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
148
+ declare namespace index$4 {
149
+ export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
133
150
  }
134
151
 
135
152
  declare const ComposerRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
@@ -157,10 +174,28 @@ declare const ComposerCancel: react.ForwardRefExoticComponent<Omit<Omit<react.De
157
174
  type ComposerIfProps = PropsWithChildren<UseComposerIfProps>;
158
175
  declare const ComposerIf: FC<ComposerIfProps>;
159
176
 
160
- declare namespace index$4 {
177
+ declare namespace index$3 {
161
178
  export { ComposerCancel as Cancel, ComposerIf as If, ComposerInput as Input, ComposerRoot as Root, ComposerSend as Send };
162
179
  }
163
180
 
181
+ declare const ContentPartInProgressIndicator: FC;
182
+
183
+ type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.p>;
184
+ type ContentPartTextProps = Omit<PrimitiveSpanProps, "children">;
185
+ declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<HTMLParagraphElement>>;
186
+
187
+ declare const ContentPartImage: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
188
+ ref?: ((instance: HTMLImageElement | 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<HTMLImageElement> | null | undefined;
189
+ } & {
190
+ asChild?: boolean;
191
+ }, "ref"> & react.RefAttributes<HTMLImageElement>>;
192
+
193
+ declare const ContentPartDisplay: FC;
194
+
195
+ declare namespace index$2 {
196
+ export { ContentPartDisplay as Display, ContentPartImage as Image, ContentPartInProgressIndicator as InProgressIndicator, ContentPartText as Text };
197
+ }
198
+
164
199
  declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
165
200
  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;
166
201
  } & {
@@ -170,6 +205,71 @@ declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.Detai
170
205
  type MessageIfProps = PropsWithChildren<UseMessageIfProps>;
171
206
  declare const MessageIf: FC<MessageIfProps>;
172
207
 
208
+ type TextContentPart = {
209
+ type: "text";
210
+ text: string;
211
+ };
212
+ type ImageContentPart = {
213
+ type: "image";
214
+ image: string;
215
+ };
216
+ type UIContentPart = {
217
+ type: "ui";
218
+ display: ReactNode;
219
+ };
220
+ type ToolCallContentPart<TArgs = unknown, TResult = unknown> = {
221
+ type: "tool-call";
222
+ toolCallId: string;
223
+ toolName: string;
224
+ args: TArgs;
225
+ result?: TResult;
226
+ };
227
+ type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
228
+ type AssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
229
+ type AppendContentPart = TextContentPart | ImageContentPart;
230
+ type BaseMessage = {
231
+ id: string;
232
+ createdAt: Date;
233
+ };
234
+ type UserMessage = BaseMessage & {
235
+ role: "user";
236
+ content: UserContentPart[];
237
+ };
238
+ type AssistantMessage = BaseMessage & {
239
+ role: "assistant";
240
+ content: AssistantContentPart[];
241
+ status: "in_progress" | "done" | "error";
242
+ };
243
+ type AppendMessage = {
244
+ parentId: string | null;
245
+ role: "user";
246
+ content: AppendContentPart[];
247
+ };
248
+ type ThreadMessage = UserMessage | AssistantMessage;
249
+
250
+ type ContentPartStatus = "done" | "in_progress" | "error";
251
+ type TextContentPartProps = {
252
+ part: TextContentPart;
253
+ status: ContentPartStatus;
254
+ };
255
+ type TextContentPartComponent = ComponentType<TextContentPartProps>;
256
+ type ImageContentPartProps = {
257
+ part: ImageContentPart;
258
+ status: ContentPartStatus;
259
+ };
260
+ type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
261
+ type UIContentPartProps = {
262
+ part: UIContentPart;
263
+ status: ContentPartStatus;
264
+ };
265
+ type UIContentPartComponent = ComponentType<UIContentPartProps>;
266
+ type ToolCallContentPartProps<TArgs = any, TResult = any> = {
267
+ part: ToolCallContentPart<TArgs, TResult>;
268
+ status: ContentPartStatus;
269
+ addResult: (result: any) => void;
270
+ };
271
+ type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
272
+
173
273
  type MessageContentProps = {
174
274
  components?: {
175
275
  Text?: TextContentPartComponent;
@@ -189,90 +289,193 @@ declare const MessageInProgress: react.ForwardRefExoticComponent<Omit<Omit<react
189
289
  asChild?: boolean;
190
290
  }, "ref"> & react.RefAttributes<HTMLSpanElement>>;
191
291
 
192
- declare namespace index$3 {
292
+ declare namespace index$1 {
193
293
  export { MessageContent as Content, MessageIf as If, MessageInProgress as InProgress, MessageRoot as Root };
194
294
  }
195
295
 
196
- declare const BranchPickerNext: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
197
- 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;
296
+ declare const ThreadRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
297
+ 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;
198
298
  } & {
199
299
  asChild?: boolean;
200
- }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
300
+ }, "ref"> & react.RefAttributes<HTMLDivElement>>;
201
301
 
202
- declare const BranchPickerPrevious: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
203
- 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;
204
- } & {
205
- asChild?: boolean;
206
- }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
302
+ type ThreadEmptyProps = {
303
+ children: ReactNode;
304
+ };
305
+ declare const ThreadEmpty: FC<ThreadEmptyProps>;
207
306
 
208
- declare const BranchPickerCount: FC;
307
+ type ThreadIfProps = PropsWithChildren<UseThreadIfProps>;
308
+ declare const ThreadIf: FC<ThreadIfProps>;
209
309
 
210
- declare const BranchPickerNumber: FC;
310
+ type UseThreadViewportAutoScrollProps = {
311
+ autoScroll?: boolean | undefined;
312
+ };
211
313
 
212
- declare const BranchPickerRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
314
+ declare const ThreadViewport: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
213
315
  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;
214
316
  } & {
215
317
  asChild?: boolean;
216
- }, "ref"> & {
217
- hideWhenSingleBranch?: boolean;
218
- } & react.RefAttributes<HTMLDivElement>>;
219
-
220
- declare namespace index$2 {
221
- export { BranchPickerCount as Count, BranchPickerNext as Next, BranchPickerNumber as Number, BranchPickerPrevious as Previous, BranchPickerRoot as Root };
222
- }
318
+ }, "ref"> & UseThreadViewportAutoScrollProps & react.RefAttributes<HTMLDivElement>>;
223
319
 
224
- type UseActionBarFloatStatusProps = {
225
- hideWhenRunning?: boolean | undefined;
226
- autohide?: "always" | "not-last" | "never" | undefined;
227
- autohideFloat?: "always" | "single-branch" | "never" | undefined;
320
+ type ThreadMessagesProps = {
321
+ components: {
322
+ Message: ComponentType;
323
+ UserMessage?: ComponentType;
324
+ EditComposer?: ComponentType;
325
+ AssistantMessage?: ComponentType;
326
+ } | {
327
+ Message?: ComponentType;
328
+ UserMessage: ComponentType;
329
+ EditComposer?: ComponentType;
330
+ AssistantMessage: ComponentType;
331
+ };
228
332
  };
229
- declare const ActionBarRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
230
- 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;
231
- } & {
232
- asChild?: boolean;
233
- }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>>;
234
-
235
- declare const ActionBarCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
236
- 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;
237
- } & {
238
- asChild?: boolean;
239
- }, "ref"> & {
240
- copiedDuration?: number;
241
- } & react.RefAttributes<HTMLButtonElement>>;
333
+ declare const ThreadMessages: FC<ThreadMessagesProps>;
242
334
 
243
- declare const ActionBarReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
335
+ declare const ThreadScrollToBottom: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
244
336
  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;
245
337
  } & {
246
338
  asChild?: boolean;
247
339
  }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
248
340
 
249
- declare const ActionBarEdit: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
341
+ declare const ThreadSuggestion: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
250
342
  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;
251
343
  } & {
252
344
  asChild?: boolean;
253
- }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
345
+ }, "ref"> & {
346
+ prompt: string;
347
+ method: "replace";
348
+ autoSend?: boolean;
349
+ } & react.RefAttributes<HTMLButtonElement>>;
254
350
 
255
- declare namespace index$1 {
256
- export { ActionBarCopy as Copy, ActionBarEdit as Edit, ActionBarReload as Reload, ActionBarRoot as Root };
351
+ declare namespace index {
352
+ export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
257
353
  }
258
354
 
259
- declare const ContentPartInProgressIndicator: FC;
355
+ type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
356
+ type Tool<TArgs = unknown, TResult = unknown> = {
357
+ description?: string;
358
+ parameters: z.ZodSchema<TArgs>;
359
+ execute: ToolExecuteFunction<TArgs, TResult>;
360
+ };
361
+ type ModelConfig = {
362
+ priority?: number;
363
+ system?: string;
364
+ tools?: Record<string, Tool<any, any>>;
365
+ };
366
+ type ModelConfigProvider = () => ModelConfig;
260
367
 
261
- type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;
262
- type ContentPartTextProps = Omit<PrimitiveSpanProps, "children">;
263
- declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<HTMLSpanElement>>;
368
+ type Unsubscribe = () => void;
264
369
 
265
- declare const ContentPartImage: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
266
- ref?: ((instance: HTMLImageElement | 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<HTMLImageElement> | null | undefined;
267
- } & {
268
- asChild?: boolean;
269
- }, "ref"> & react.RefAttributes<HTMLImageElement>>;
370
+ type AssistantRuntimeProviderProps = {
371
+ runtime: AssistantRuntime;
372
+ };
373
+ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
270
374
 
271
- declare const ContentPartDisplay: FC;
375
+ type AssistantModelConfigState = Readonly<{
376
+ getModelConfig: ModelConfigProvider;
377
+ registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
378
+ }>;
272
379
 
273
- declare namespace index {
274
- export { ContentPartDisplay as Display, ContentPartImage as Image, ContentPartInProgressIndicator as InProgressIndicator, ContentPartText as Text };
275
- }
380
+ type ContentPartState = Readonly<{
381
+ status: "in_progress" | "done" | "error";
382
+ part: ThreadMessage["content"][number];
383
+ }>;
384
+
385
+ type MessageState = Readonly<{
386
+ message: Readonly<ThreadMessage>;
387
+ parentId: string | null;
388
+ branches: readonly string[];
389
+ isLast: boolean;
390
+ }>;
391
+
392
+ type BaseComposerState = Readonly<{
393
+ value: string;
394
+ setValue: (value: string) => void;
395
+ }>;
396
+
397
+ type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
398
+
399
+ type EditComposerState = BaseComposerState & Readonly<{
400
+ isEditing: boolean;
401
+ edit: () => void;
402
+ send: () => void;
403
+ cancel: () => boolean;
404
+ }>;
405
+
406
+ type ThreadState = Readonly<{
407
+ messages: readonly ThreadMessage[];
408
+ isRunning: boolean;
409
+ }>;
410
+
411
+ type ThreadActionsState = Readonly<{
412
+ getBranches: (messageId: string) => readonly string[];
413
+ switchToBranch: (branchId: string) => void;
414
+ append: (message: AppendMessage) => void;
415
+ startRun: (parentId: string | null) => void;
416
+ cancelRun: () => void;
417
+ addToolResult: (toolCallId: string, result: any) => void;
418
+ }>;
419
+
420
+ type ComposerState = BaseComposerState & Readonly<{
421
+ isEditing: true;
422
+ send: () => void;
423
+ cancel: () => boolean;
424
+ focus: () => void;
425
+ onFocus: (listener: () => void) => Unsubscribe;
426
+ }>;
427
+
428
+ type ThreadViewportState = Readonly<{
429
+ isAtBottom: boolean;
430
+ scrollToBottom: () => void;
431
+ onScrollToBottom: (callback: () => void) => Unsubscribe;
432
+ }>;
433
+
434
+ type AssistantToolUIsState = Readonly<{
435
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
436
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
437
+ }>;
438
+
439
+ type AssistantContextValue = {
440
+ useModelConfig: ReadonlyStore<AssistantModelConfigState>;
441
+ useToolUIs: ReadonlyStore<AssistantToolUIsState>;
442
+ };
443
+ declare const useAssistantContext: () => AssistantContextValue;
444
+
445
+ type ThreadContextValue = {
446
+ useThread: ReadonlyStore<ThreadState>;
447
+ useThreadActions: ReadonlyStore<ThreadActionsState>;
448
+ useComposer: ReadonlyStore<ComposerState>;
449
+ useViewport: ReadonlyStore<ThreadViewportState>;
450
+ };
451
+ declare const useThreadContext: () => ThreadContextValue;
452
+
453
+ type ComposerContextValue = {
454
+ useComposer: ReadonlyStore<EditComposerState | ComposerState>;
455
+ type: "edit" | "new";
456
+ };
457
+ declare const useComposerContext: () => ComposerContextValue;
458
+
459
+ type MessageUtilsState = Readonly<{
460
+ inProgressIndicator: ReactNode | null;
461
+ setInProgressIndicator: (value: ReactNode | null) => void;
462
+ isCopied: boolean;
463
+ setIsCopied: (value: boolean) => void;
464
+ isHovering: boolean;
465
+ setIsHovering: (value: boolean) => void;
466
+ }>;
467
+
468
+ type MessageContextValue = {
469
+ useMessage: ReadonlyStore<MessageState>;
470
+ useMessageUtils: ReadonlyStore<MessageUtilsState>;
471
+ useEditComposer: ReadonlyStore<EditComposerState>;
472
+ };
473
+ declare const useMessageContext: () => MessageContextValue;
474
+
475
+ type ContentPartContextValue = {
476
+ useContentPart: ReadonlyStore<ContentPartState>;
477
+ };
478
+ declare const useContentPartContext: () => ContentPartContextValue;
276
479
 
277
480
  type ThreadRuntime = Readonly<ThreadState & ThreadActionsState & {
278
481
  subscribe: (callback: () => void) => Unsubscribe;
@@ -321,10 +524,23 @@ declare class LocalRuntime implements AssistantRuntime {
321
524
 
322
525
  declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
323
526
 
324
- type AssistantRuntimeProviderProps = {
325
- runtime: AssistantRuntime;
527
+ type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
528
+ toolName: string;
529
+ render?: ToolCallContentPartComponent<TArgs, TResult>;
326
530
  };
327
- declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
531
+ declare const useAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => void;
532
+
533
+ declare const makeAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => () => null;
534
+
535
+ type AssistantToolUIProps<TArgs, TResult> = {
536
+ toolName: string;
537
+ render: ToolCallContentPartComponent<TArgs, TResult>;
538
+ };
539
+ declare const useAssistantToolUI: (tool: AssistantToolUIProps<any, any> | null) => void;
540
+
541
+ declare const makeAssistantToolUI: <TArgs, TResult>(tool: AssistantToolUIProps<TArgs, TResult>) => () => null;
542
+
543
+ declare const useAssistantInstructions: (instruction: string) => void;
328
544
 
329
545
  declare class ProxyConfigProvider {
330
546
  private _providers;
@@ -354,4 +570,4 @@ declare namespace internal {
354
570
  export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
355
571
  }
356
572
 
357
- export { index$1 as ActionBarPrimitive, AppendMessage, AssistantContentPart, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$4 as ComposerPrimitive, index as ContentPartPrimitive, internal as INTERNAL, index$3 as MessagePrimitive, type ReactThreadRuntime, ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, Unsubscribe, useActionBarCopy, useActionBarEdit, useActionBarReload, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerIf, useComposerSend, useContentPartDisplay, useContentPartImage, useContentPartInProgressIndicator, useContentPartText, useLocalRuntime, useMessageIf, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
573
+ export { index$6 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantContextValue, type AssistantMessage, index$5 as AssistantModalPrimitive, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, index$4 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ComposerContextValue, index$3 as ComposerPrimitive, type ComposerState, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartState, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type MessageContextValue, index$1 as MessagePrimitive, type MessageState, type ModelConfig, type ReactThreadRuntime, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, type ThreadContextValue, type ThreadMessage, index as ThreadPrimitive, 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, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartInProgressIndicator, useContentPartText, useLocalRuntime, useMessageContext, useMessageIf, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };