@assistant-ui/react 0.2.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +398 -310
- package/dist/index.d.ts +398 -310
- package/dist/index.js +749 -566
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +716 -530
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,310 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import {
|
3
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
4
|
-
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
5
|
-
import { Primitive } from '@radix-ui/react-primitive';
|
2
|
+
import { ReactNode, ComponentType, PropsWithChildren, ComponentPropsWithoutRef, FC } from 'react';
|
6
3
|
import { z } from 'zod';
|
7
4
|
import { UseBoundStore, StoreApi } from 'zustand';
|
5
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
6
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
7
|
+
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
8
|
+
|
9
|
+
type ToolExecuteFunction<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
|
10
|
+
type Tool<TArgs = unknown, TResult = unknown> = {
|
11
|
+
description?: string;
|
12
|
+
parameters: z.ZodSchema<TArgs>;
|
13
|
+
execute: ToolExecuteFunction<TArgs, TResult>;
|
14
|
+
};
|
15
|
+
type ModelConfig = {
|
16
|
+
priority?: number;
|
17
|
+
system?: string;
|
18
|
+
tools?: Record<string, Tool<any, any>>;
|
19
|
+
};
|
20
|
+
type ModelConfigProvider = () => ModelConfig;
|
21
|
+
|
22
|
+
type Unsubscribe = () => void;
|
23
|
+
|
24
|
+
type TextContentPart = {
|
25
|
+
type: "text";
|
26
|
+
text: string;
|
27
|
+
};
|
28
|
+
type ImageContentPart = {
|
29
|
+
type: "image";
|
30
|
+
image: string;
|
31
|
+
};
|
32
|
+
type UIContentPart = {
|
33
|
+
type: "ui";
|
34
|
+
display: ReactNode;
|
35
|
+
};
|
36
|
+
type ToolCallContentPart<TArgs = unknown, TResult = unknown> = {
|
37
|
+
type: "tool-call";
|
38
|
+
toolCallId: string;
|
39
|
+
toolName: string;
|
40
|
+
args: TArgs;
|
41
|
+
result?: TResult;
|
42
|
+
};
|
43
|
+
type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
|
44
|
+
type AssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
|
45
|
+
type AppendContentPart = TextContentPart | ImageContentPart;
|
46
|
+
type BaseMessage = {
|
47
|
+
id: string;
|
48
|
+
createdAt: Date;
|
49
|
+
};
|
50
|
+
type UserMessage = BaseMessage & {
|
51
|
+
role: "user";
|
52
|
+
content: UserContentPart[];
|
53
|
+
};
|
54
|
+
type AssistantMessage = BaseMessage & {
|
55
|
+
role: "assistant";
|
56
|
+
content: AssistantContentPart[];
|
57
|
+
status: "in_progress" | "done" | "error";
|
58
|
+
};
|
59
|
+
type AppendMessage = {
|
60
|
+
parentId: string | null;
|
61
|
+
role: "user";
|
62
|
+
content: AppendContentPart[];
|
63
|
+
};
|
64
|
+
type ThreadMessage = UserMessage | AssistantMessage;
|
65
|
+
|
66
|
+
type ReactThreadRuntime = ThreadRuntime & {
|
67
|
+
unstable_synchronizer?: ComponentType;
|
68
|
+
};
|
69
|
+
|
70
|
+
type ChatModelRunResult = {
|
71
|
+
content: AssistantContentPart[];
|
72
|
+
};
|
73
|
+
type ChatModelRunOptions = {
|
74
|
+
messages: ThreadMessage[];
|
75
|
+
abortSignal: AbortSignal;
|
76
|
+
config: ModelConfig;
|
77
|
+
onUpdate: (result: ChatModelRunResult) => void;
|
78
|
+
};
|
79
|
+
type ChatModelAdapter = {
|
80
|
+
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
81
|
+
};
|
82
|
+
|
83
|
+
declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
|
84
|
+
private _thread;
|
85
|
+
constructor(_thread: TThreadRuntime);
|
86
|
+
private _unsubscribe;
|
87
|
+
get thread(): TThreadRuntime;
|
88
|
+
set thread(thread: TThreadRuntime);
|
89
|
+
abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
90
|
+
abstract switchToThread(threadId: string | null): void;
|
91
|
+
get messages(): readonly ThreadMessage[];
|
92
|
+
get isRunning(): boolean;
|
93
|
+
getBranches(messageId: string): readonly string[];
|
94
|
+
switchToBranch(branchId: string): void;
|
95
|
+
append(message: AppendMessage): void;
|
96
|
+
startRun(parentId: string | null): void;
|
97
|
+
cancelRun(): void;
|
98
|
+
addToolResult(toolCallId: string, result: any): void;
|
99
|
+
private _subscriptions;
|
100
|
+
subscribe(callback: () => void): Unsubscribe;
|
101
|
+
private subscriptionHandler;
|
102
|
+
get unstable_synchronizer(): react.ComponentType | undefined;
|
103
|
+
}
|
104
|
+
|
105
|
+
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
106
|
+
private readonly _configProviders;
|
107
|
+
constructor(adapter: ChatModelAdapter);
|
108
|
+
set adapter(adapter: ChatModelAdapter);
|
109
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => boolean;
|
110
|
+
switchToThread(threadId: string | null): LocalThreadRuntime;
|
111
|
+
}
|
112
|
+
declare class LocalThreadRuntime implements ThreadRuntime {
|
113
|
+
private _configProviders;
|
114
|
+
adapter: ChatModelAdapter;
|
115
|
+
private _subscriptions;
|
116
|
+
private abortController;
|
117
|
+
private repository;
|
118
|
+
get messages(): ThreadMessage[];
|
119
|
+
get isRunning(): boolean;
|
120
|
+
constructor(_configProviders: Set<ModelConfigProvider>, adapter: ChatModelAdapter);
|
121
|
+
getBranches(messageId: string): string[];
|
122
|
+
switchToBranch(branchId: string): void;
|
123
|
+
append(message: AppendMessage): Promise<void>;
|
124
|
+
startRun(parentId: string | null): Promise<void>;
|
125
|
+
cancelRun(): void;
|
126
|
+
private notifySubscribers;
|
127
|
+
subscribe(callback: () => void): Unsubscribe;
|
128
|
+
addToolResult(): void;
|
129
|
+
}
|
130
|
+
|
131
|
+
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
132
|
+
|
133
|
+
type ThreadActionsState = Readonly<{
|
134
|
+
getBranches: (messageId: string) => readonly string[];
|
135
|
+
switchToBranch: (branchId: string) => void;
|
136
|
+
append: (message: AppendMessage) => void;
|
137
|
+
startRun: (parentId: string | null) => void;
|
138
|
+
cancelRun: () => void;
|
139
|
+
addToolResult: (toolCallId: string, result: any) => void;
|
140
|
+
}>;
|
141
|
+
|
142
|
+
type ContentPartStatus = "done" | "in_progress" | "error";
|
143
|
+
type TextContentPartProps = {
|
144
|
+
part: TextContentPart;
|
145
|
+
status: ContentPartStatus;
|
146
|
+
};
|
147
|
+
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
148
|
+
type ImageContentPartProps = {
|
149
|
+
part: ImageContentPart;
|
150
|
+
status: ContentPartStatus;
|
151
|
+
};
|
152
|
+
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
153
|
+
type UIContentPartProps = {
|
154
|
+
part: UIContentPart;
|
155
|
+
status: ContentPartStatus;
|
156
|
+
};
|
157
|
+
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
158
|
+
type ToolCallContentPartProps<TArgs = any, TResult = any> = {
|
159
|
+
part: ToolCallContentPart<TArgs, TResult>;
|
160
|
+
status: ContentPartStatus;
|
161
|
+
addResult: (result: any) => void;
|
162
|
+
};
|
163
|
+
type ToolCallContentPartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
164
|
+
|
165
|
+
type ThreadRuntime = Readonly<ThreadState & ThreadActionsState & {
|
166
|
+
messages: readonly ThreadMessage[];
|
167
|
+
subscribe: (callback: () => void) => Unsubscribe;
|
168
|
+
}>;
|
169
|
+
|
170
|
+
type AssistantRuntime = ThreadRuntime & {
|
171
|
+
switchToThread: (threadId: string | null) => void;
|
172
|
+
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
173
|
+
};
|
174
|
+
|
175
|
+
type AssistantRuntimeProviderProps = {
|
176
|
+
runtime: AssistantRuntime;
|
177
|
+
};
|
178
|
+
declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
|
179
|
+
|
180
|
+
type AssistantModelConfigState = Readonly<{
|
181
|
+
getModelConfig: ModelConfigProvider;
|
182
|
+
registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
|
183
|
+
}>;
|
184
|
+
|
185
|
+
type ContentPartState = Readonly<{
|
186
|
+
status: "in_progress" | "done" | "error";
|
187
|
+
part: ThreadMessage["content"][number];
|
188
|
+
}>;
|
189
|
+
|
190
|
+
type MessageState = Readonly<{
|
191
|
+
message: Readonly<ThreadMessage>;
|
192
|
+
parentId: string | null;
|
193
|
+
branches: readonly string[];
|
194
|
+
isLast: boolean;
|
195
|
+
}>;
|
196
|
+
|
197
|
+
type BaseComposerState = Readonly<{
|
198
|
+
value: string;
|
199
|
+
setValue: (value: string) => void;
|
200
|
+
}>;
|
201
|
+
|
202
|
+
type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
|
203
|
+
|
204
|
+
type EditComposerState = BaseComposerState & Readonly<{
|
205
|
+
isEditing: boolean;
|
206
|
+
edit: () => void;
|
207
|
+
send: () => void;
|
208
|
+
cancel: () => boolean;
|
209
|
+
}>;
|
210
|
+
|
211
|
+
type ThreadState = Readonly<{
|
212
|
+
isRunning: boolean;
|
213
|
+
}>;
|
214
|
+
|
215
|
+
type AssistantToolUIsState = Readonly<{
|
216
|
+
getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
|
217
|
+
setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
|
218
|
+
}>;
|
219
|
+
|
220
|
+
type AssistantActionsState = Readonly<{
|
221
|
+
switchToThread: (threadId: string | null) => void;
|
222
|
+
}>;
|
223
|
+
|
224
|
+
type AssistantContextValue = {
|
225
|
+
useModelConfig: ReadonlyStore<AssistantModelConfigState>;
|
226
|
+
useToolUIs: ReadonlyStore<AssistantToolUIsState>;
|
227
|
+
useAssistantActions: ReadonlyStore<AssistantActionsState>;
|
228
|
+
};
|
229
|
+
declare const useAssistantContext: () => AssistantContextValue;
|
230
|
+
|
231
|
+
type ThreadViewportState = Readonly<{
|
232
|
+
isAtBottom: boolean;
|
233
|
+
scrollToBottom: () => void;
|
234
|
+
onScrollToBottom: (callback: () => void) => Unsubscribe;
|
235
|
+
}>;
|
236
|
+
|
237
|
+
type ThreadMessagesState = readonly ThreadMessage[];
|
238
|
+
|
239
|
+
type ThreadContextValue = {
|
240
|
+
useThread: ReadonlyStore<ThreadState>;
|
241
|
+
useThreadMessages: ReadonlyStore<ThreadMessagesState>;
|
242
|
+
useThreadActions: ReadonlyStore<ThreadActionsState>;
|
243
|
+
useComposer: ReadonlyStore<ComposerState>;
|
244
|
+
useViewport: ReadonlyStore<ThreadViewportState>;
|
245
|
+
};
|
246
|
+
declare const useThreadContext: () => ThreadContextValue;
|
247
|
+
|
248
|
+
type ComposerContextValue = {
|
249
|
+
useComposer: ReadonlyStore<EditComposerState | ComposerState>;
|
250
|
+
type: "edit" | "new";
|
251
|
+
};
|
252
|
+
declare const useComposerContext: () => ComposerContextValue;
|
253
|
+
|
254
|
+
type MessageUtilsState = Readonly<{
|
255
|
+
inProgressIndicator: HTMLSpanElement;
|
256
|
+
isCopied: boolean;
|
257
|
+
setIsCopied: (value: boolean) => void;
|
258
|
+
isHovering: boolean;
|
259
|
+
setIsHovering: (value: boolean) => void;
|
260
|
+
}>;
|
261
|
+
|
262
|
+
type MessageContextValue = {
|
263
|
+
useMessage: ReadonlyStore<MessageState>;
|
264
|
+
useMessageUtils: ReadonlyStore<MessageUtilsState>;
|
265
|
+
useEditComposer: ReadonlyStore<EditComposerState>;
|
266
|
+
};
|
267
|
+
declare const useMessageContext: () => MessageContextValue;
|
268
|
+
|
269
|
+
type ContentPartContextValue = {
|
270
|
+
useContentPart: ReadonlyStore<ContentPartState>;
|
271
|
+
};
|
272
|
+
declare const useContentPartContext: () => ContentPartContextValue;
|
273
|
+
|
274
|
+
type ComposerState = BaseComposerState & Readonly<{
|
275
|
+
isEditing: true;
|
276
|
+
send: () => void;
|
277
|
+
cancel: () => boolean;
|
278
|
+
focus: () => void;
|
279
|
+
onFocus: (listener: () => void) => Unsubscribe;
|
280
|
+
}>;
|
281
|
+
|
282
|
+
type CreateAppendMessage = string | {
|
283
|
+
parentId?: string | null | undefined;
|
284
|
+
role?: AppendMessage["role"];
|
285
|
+
content: AppendMessage["content"];
|
286
|
+
};
|
287
|
+
declare const useAppendMessage: () => (message: CreateAppendMessage) => void;
|
288
|
+
|
289
|
+
declare const useSwitchToNewThread: () => () => void;
|
290
|
+
|
291
|
+
type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
292
|
+
toolName: string;
|
293
|
+
render?: ToolCallContentPartComponent<TArgs, TResult>;
|
294
|
+
};
|
295
|
+
declare const useAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => void;
|
296
|
+
|
297
|
+
declare const makeAssistantTool: <TArgs, TResult>(tool: AssistantToolProps<TArgs, TResult>) => () => null;
|
298
|
+
|
299
|
+
type AssistantToolUIProps<TArgs, TResult> = {
|
300
|
+
toolName: string;
|
301
|
+
render: ToolCallContentPartComponent<TArgs, TResult>;
|
302
|
+
};
|
303
|
+
declare const useAssistantToolUI: (tool: AssistantToolUIProps<any, any> | null) => void;
|
304
|
+
|
305
|
+
declare const makeAssistantToolUI: <TArgs, TResult>(tool: AssistantToolUIProps<TArgs, TResult>) => () => null;
|
306
|
+
|
307
|
+
declare const useAssistantInstructions: (instruction: string) => void;
|
8
308
|
|
9
309
|
type UseActionBarCopyProps = {
|
10
310
|
copiedDuration?: number;
|
@@ -41,8 +341,6 @@ declare const useContentPartDisplay: () => react.ReactNode;
|
|
41
341
|
|
42
342
|
declare const useContentPartImage: () => string;
|
43
343
|
|
44
|
-
declare const useContentPartInProgressIndicator: () => react.ReactNode;
|
45
|
-
|
46
344
|
declare const useContentPartText: () => string;
|
47
345
|
|
48
346
|
type MessageIfFilters = {
|
@@ -78,13 +376,20 @@ type UseActionBarFloatStatusProps = {
|
|
78
376
|
autohide?: "always" | "not-last" | "never" | undefined;
|
79
377
|
autohideFloat?: "always" | "single-branch" | "never" | undefined;
|
80
378
|
};
|
81
|
-
|
379
|
+
|
380
|
+
type PrimitiveDivProps$4 = ComponentPropsWithoutRef<typeof Primitive.div>;
|
381
|
+
type ActionBarPrimitiveRootProps = PrimitiveDivProps$4 & UseActionBarFloatStatusProps;
|
382
|
+
declare const ActionBarPrimitiveRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
82
383
|
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;
|
83
384
|
} & {
|
84
385
|
asChild?: boolean;
|
85
386
|
}, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>>;
|
86
387
|
|
87
|
-
|
388
|
+
type PrimitiveButtonProps$1 = ComponentPropsWithoutRef<typeof Primitive.button>;
|
389
|
+
type ActionButtonProps<THook> = PrimitiveButtonProps$1 & (THook extends (props: infer TProps) => unknown ? TProps : never);
|
390
|
+
|
391
|
+
type ActionBarPrimitiveCopyProps = ActionButtonProps<typeof useActionBarCopy>;
|
392
|
+
declare const ActionBarPrimitiveCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
88
393
|
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
394
|
} & {
|
90
395
|
asChild?: boolean;
|
@@ -92,52 +397,66 @@ declare const ActionBarCopy: react.ForwardRefExoticComponent<Omit<Omit<react.Det
|
|
92
397
|
copiedDuration?: number;
|
93
398
|
} & react.RefAttributes<HTMLButtonElement>>;
|
94
399
|
|
95
|
-
|
400
|
+
type ActionBarPrimitiveReloadProps = ActionButtonProps<typeof useActionBarReload>;
|
401
|
+
declare const ActionBarPrimitiveReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
96
402
|
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
403
|
} & {
|
98
404
|
asChild?: boolean;
|
99
405
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
100
406
|
|
101
|
-
|
407
|
+
type ActionBarPrimitiveEditProps = ActionButtonProps<typeof useActionBarEdit>;
|
408
|
+
declare const ActionBarPrimitiveEdit: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
102
409
|
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;
|
103
410
|
} & {
|
104
411
|
asChild?: boolean;
|
105
412
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
106
413
|
|
107
414
|
declare namespace index$6 {
|
108
|
-
export {
|
415
|
+
export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root };
|
109
416
|
}
|
110
417
|
|
111
|
-
type
|
112
|
-
declare const
|
418
|
+
type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;
|
419
|
+
declare const AssistantModalPrimitiveRoot: FC<AssistantModalPrimitiveRootProps>;
|
113
420
|
|
114
|
-
|
421
|
+
type AssistantModalPrimitiveTriggerProps = ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>;
|
422
|
+
declare const AssistantModalPrimitiveTrigger: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverTriggerProps & react.RefAttributes<HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
115
423
|
|
116
|
-
|
424
|
+
type AssistantModalPrimitiveContentProps = ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {
|
425
|
+
dissmissOnInteractOutside?: boolean;
|
426
|
+
};
|
427
|
+
declare const AssistantModalPrimitiveContent: react.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & react.RefAttributes<HTMLDivElement>, "ref"> & {
|
117
428
|
dissmissOnInteractOutside?: boolean;
|
118
429
|
} & react.RefAttributes<HTMLDivElement>>;
|
119
430
|
|
120
431
|
declare namespace index$5 {
|
121
|
-
export {
|
432
|
+
export { AssistantModalPrimitiveContent as Content, AssistantModalPrimitiveRoot as Root, AssistantModalPrimitiveTrigger as Trigger };
|
122
433
|
}
|
123
434
|
|
124
|
-
|
435
|
+
type BranchPickerPrimitiveNextProps = ActionButtonProps<typeof useBranchPickerNext>;
|
436
|
+
declare const BranchPickerPrimitiveNext: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
125
437
|
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;
|
126
438
|
} & {
|
127
439
|
asChild?: boolean;
|
128
440
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
129
441
|
|
442
|
+
type BranchPickerPrimitivePreviousProps = ActionButtonProps<typeof useBranchPickerPrevious>;
|
130
443
|
declare const BranchPickerPrevious: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
131
444
|
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;
|
132
445
|
} & {
|
133
446
|
asChild?: boolean;
|
134
447
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
135
448
|
|
136
|
-
|
449
|
+
type BranchPickerPrimitiveCountProps = {};
|
450
|
+
declare const BranchPickerPrimitiveCount: FC<BranchPickerPrimitiveCountProps>;
|
137
451
|
|
138
|
-
|
452
|
+
type BranchPickerPrimitiveNumberProps = {};
|
453
|
+
declare const BranchPickerPrimitiveNumber: FC<BranchPickerPrimitiveNumberProps>;
|
139
454
|
|
140
|
-
|
455
|
+
type PrimitiveDivProps$3 = ComponentPropsWithoutRef<typeof Primitive.div>;
|
456
|
+
type BranchPickerPrimitiveRootProps = PrimitiveDivProps$3 & {
|
457
|
+
hideWhenSingleBranch?: boolean;
|
458
|
+
};
|
459
|
+
declare const BranchPickerPrimitiveRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
141
460
|
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
461
|
} & {
|
143
462
|
asChild?: boolean;
|
@@ -146,131 +465,80 @@ declare const BranchPickerRoot: react.ForwardRefExoticComponent<Omit<Omit<react.
|
|
146
465
|
} & react.RefAttributes<HTMLDivElement>>;
|
147
466
|
|
148
467
|
declare namespace index$4 {
|
149
|
-
export {
|
468
|
+
export { BranchPickerPrimitiveCount as Count, BranchPickerPrimitiveNext as Next, BranchPickerPrimitiveNumber as Number, BranchPickerPrevious as Previous, BranchPickerPrimitiveRoot as Root };
|
150
469
|
}
|
151
470
|
|
152
|
-
|
471
|
+
type PrimitiveFormProps = ComponentPropsWithoutRef<typeof Primitive.form>;
|
472
|
+
type ComposerPrimitiveRootProps = PrimitiveFormProps;
|
473
|
+
declare const ComposerPrimitiveRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & {
|
153
474
|
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;
|
154
475
|
} & {
|
155
476
|
asChild?: boolean;
|
156
477
|
}, "ref"> & react.RefAttributes<HTMLFormElement>>;
|
157
478
|
|
158
|
-
|
479
|
+
type ComposerPrimitiveInputProps = TextareaAutosizeProps & {
|
480
|
+
asChild?: boolean;
|
481
|
+
};
|
482
|
+
declare const ComposerPrimitiveInput: react.ForwardRefExoticComponent<TextareaAutosizeProps & {
|
159
483
|
asChild?: boolean;
|
160
484
|
} & react.RefAttributes<HTMLTextAreaElement>>;
|
161
485
|
|
162
|
-
|
486
|
+
type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;
|
487
|
+
type ComposerPrimitiveSendProps = PrimitiveButtonProps;
|
488
|
+
declare const ComposerPrimitiveSend: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
163
489
|
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;
|
164
490
|
} & {
|
165
491
|
asChild?: boolean;
|
166
492
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
167
493
|
|
168
|
-
|
494
|
+
type ComposerPrimitiveCancelProps = ActionButtonProps<typeof useComposerCancel>;
|
495
|
+
declare const ComposerPrimitiveCancel: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
169
496
|
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;
|
170
497
|
} & {
|
171
498
|
asChild?: boolean;
|
172
499
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
173
500
|
|
174
|
-
type
|
175
|
-
declare const
|
501
|
+
type ComposerPrimitiveIfProps = PropsWithChildren<UseComposerIfProps>;
|
502
|
+
declare const ComposerPrimitiveIf: FC<ComposerPrimitiveIfProps>;
|
176
503
|
|
177
504
|
declare namespace index$3 {
|
178
|
-
export {
|
505
|
+
export { ComposerPrimitiveCancel as Cancel, ComposerPrimitiveIf as If, ComposerPrimitiveInput as Input, ComposerPrimitiveRoot as Root, ComposerPrimitiveSend as Send };
|
179
506
|
}
|
180
507
|
|
181
|
-
|
508
|
+
type ContentPartPrimitiveInProgressIndicatorProps = {};
|
509
|
+
declare const ContentPartPrimitiveInProgressIndicator: FC<ContentPartPrimitiveInProgressIndicatorProps>;
|
182
510
|
|
183
|
-
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.p>;
|
184
|
-
type
|
185
|
-
declare const
|
511
|
+
type PrimitiveSpanProps$1 = ComponentPropsWithoutRef<typeof Primitive.p>;
|
512
|
+
type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children">;
|
513
|
+
declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<ContentPartPrimitiveTextProps & react.RefAttributes<HTMLParagraphElement>>;
|
186
514
|
|
187
|
-
|
515
|
+
type PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;
|
516
|
+
type ContentPartPrimitiveImageProps = PrimitiveImageProps;
|
517
|
+
declare const ContentPartPrimitiveImage: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
|
188
518
|
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
519
|
} & {
|
190
520
|
asChild?: boolean;
|
191
521
|
}, "ref"> & react.RefAttributes<HTMLImageElement>>;
|
192
522
|
|
193
|
-
|
523
|
+
type ContentPartPrimitiveDisplayProps = {};
|
524
|
+
declare const ContentPartPrimitiveDisplay: FC<ContentPartPrimitiveDisplayProps>;
|
194
525
|
|
195
526
|
declare namespace index$2 {
|
196
|
-
export {
|
527
|
+
export { ContentPartPrimitiveDisplay as Display, ContentPartPrimitiveImage as Image, ContentPartPrimitiveInProgressIndicator as InProgressIndicator, ContentPartPrimitiveText as Text };
|
197
528
|
}
|
198
529
|
|
199
|
-
|
530
|
+
type PrimitiveDivProps$2 = ComponentPropsWithoutRef<typeof Primitive.div>;
|
531
|
+
type MessagePrimitiveRootProps = PrimitiveDivProps$2;
|
532
|
+
declare const MessagePrimitiveRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
200
533
|
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;
|
201
534
|
} & {
|
202
535
|
asChild?: boolean;
|
203
536
|
}, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
204
537
|
|
205
|
-
type
|
206
|
-
declare const
|
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>>;
|
538
|
+
type MessagePrimitiveIfProps = PropsWithChildren<UseMessageIfProps>;
|
539
|
+
declare const MessagePrimitiveIf: FC<MessagePrimitiveIfProps>;
|
272
540
|
|
273
|
-
type
|
541
|
+
type MessagePrimitiveContentProps = {
|
274
542
|
components?: {
|
275
543
|
Text?: TextContentPartComponent;
|
276
544
|
Image?: ImageContentPartComponent;
|
@@ -281,43 +549,49 @@ type MessageContentProps = {
|
|
281
549
|
};
|
282
550
|
};
|
283
551
|
};
|
284
|
-
declare const
|
552
|
+
declare const MessagePrimitiveContent: FC<MessagePrimitiveContentProps>;
|
285
553
|
|
286
|
-
|
554
|
+
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;
|
555
|
+
type MessagePrimitiveInProgressProps = PrimitiveSpanProps;
|
556
|
+
declare const MessagePrimitiveInProgress: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
287
557
|
ref?: ((instance: HTMLSpanElement | 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<HTMLSpanElement> | null | undefined;
|
288
558
|
} & {
|
289
559
|
asChild?: boolean;
|
290
560
|
}, "ref"> & react.RefAttributes<HTMLSpanElement>>;
|
291
561
|
|
292
562
|
declare namespace index$1 {
|
293
|
-
export {
|
563
|
+
export { MessagePrimitiveContent as Content, MessagePrimitiveIf as If, MessagePrimitiveInProgress as InProgress, MessagePrimitiveRoot as Root };
|
294
564
|
}
|
295
565
|
|
296
|
-
|
566
|
+
type PrimitiveDivProps$1 = ComponentPropsWithoutRef<typeof Primitive.div>;
|
567
|
+
type ThreadPrimitiveRootProps = PrimitiveDivProps$1;
|
568
|
+
declare const ThreadPrimitiveRoot: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
297
569
|
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;
|
298
570
|
} & {
|
299
571
|
asChild?: boolean;
|
300
572
|
}, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
301
573
|
|
302
|
-
type
|
574
|
+
type ThreadPrimitiveEmptyProps = {
|
303
575
|
children: ReactNode;
|
304
576
|
};
|
305
|
-
declare const
|
577
|
+
declare const ThreadPrimitiveEmpty: FC<ThreadPrimitiveEmptyProps>;
|
306
578
|
|
307
|
-
type
|
308
|
-
declare const
|
579
|
+
type ThreadPrimitiveIfProps = PropsWithChildren<UseThreadIfProps>;
|
580
|
+
declare const ThreadPrimitiveIf: FC<ThreadPrimitiveIfProps>;
|
309
581
|
|
310
582
|
type UseThreadViewportAutoScrollProps = {
|
311
583
|
autoScroll?: boolean | undefined;
|
312
584
|
};
|
313
585
|
|
314
|
-
|
586
|
+
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
|
587
|
+
type ThreadPrimitiveViewportProps = PrimitiveDivProps & UseThreadViewportAutoScrollProps;
|
588
|
+
declare const ThreadPrimitiveViewport: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
315
589
|
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;
|
316
590
|
} & {
|
317
591
|
asChild?: boolean;
|
318
592
|
}, "ref"> & UseThreadViewportAutoScrollProps & react.RefAttributes<HTMLDivElement>>;
|
319
593
|
|
320
|
-
type
|
594
|
+
type ThreadPrimitiveMessagesProps = {
|
321
595
|
components: {
|
322
596
|
Message: ComponentType;
|
323
597
|
UserMessage?: ComponentType;
|
@@ -330,15 +604,17 @@ type ThreadMessagesProps = {
|
|
330
604
|
AssistantMessage: ComponentType;
|
331
605
|
};
|
332
606
|
};
|
333
|
-
declare const
|
607
|
+
declare const ThreadPrimitiveMessages: FC<ThreadPrimitiveMessagesProps>;
|
334
608
|
|
335
|
-
|
609
|
+
type ThreadPrimitiveScrollToBottomProps = ActionButtonProps<typeof useThreadScrollToBottom>;
|
610
|
+
declare const ThreadPrimitiveScrollToBottom: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
336
611
|
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;
|
337
612
|
} & {
|
338
613
|
asChild?: boolean;
|
339
614
|
}, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
340
615
|
|
341
|
-
|
616
|
+
type ThreadPrimitiveSuggestionProps = ActionButtonProps<typeof useThreadSuggestion>;
|
617
|
+
declare const ThreadPrimitiveSuggestion: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
342
618
|
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;
|
343
619
|
} & {
|
344
620
|
asChild?: boolean;
|
@@ -349,199 +625,9 @@ declare const ThreadSuggestion: react.ForwardRefExoticComponent<Omit<Omit<react.
|
|
349
625
|
} & react.RefAttributes<HTMLButtonElement>>;
|
350
626
|
|
351
627
|
declare namespace index {
|
352
|
-
export {
|
353
|
-
}
|
354
|
-
|
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;
|
367
|
-
|
368
|
-
type Unsubscribe = () => void;
|
369
|
-
|
370
|
-
type AssistantRuntimeProviderProps = {
|
371
|
-
runtime: AssistantRuntime;
|
372
|
-
};
|
373
|
-
declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
|
374
|
-
|
375
|
-
type AssistantModelConfigState = Readonly<{
|
376
|
-
getModelConfig: ModelConfigProvider;
|
377
|
-
registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;
|
378
|
-
}>;
|
379
|
-
|
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;
|
479
|
-
|
480
|
-
type ThreadRuntime = Readonly<ThreadState & ThreadActionsState & {
|
481
|
-
subscribe: (callback: () => void) => Unsubscribe;
|
482
|
-
}>;
|
483
|
-
|
484
|
-
type AssistantRuntime = ThreadRuntime & {
|
485
|
-
registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
|
486
|
-
};
|
487
|
-
|
488
|
-
type ReactThreadRuntime = ThreadRuntime & {
|
489
|
-
unstable_synchronizer?: ComponentType;
|
490
|
-
};
|
491
|
-
|
492
|
-
type ChatModelRunResult = {
|
493
|
-
content: AssistantContentPart[];
|
494
|
-
};
|
495
|
-
type ChatModelRunOptions = {
|
496
|
-
messages: ThreadMessage[];
|
497
|
-
abortSignal: AbortSignal;
|
498
|
-
config: ModelConfig;
|
499
|
-
onUpdate: (result: ChatModelRunResult) => void;
|
500
|
-
};
|
501
|
-
type ChatModelAdapter = {
|
502
|
-
run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
|
503
|
-
};
|
504
|
-
|
505
|
-
declare class LocalRuntime implements AssistantRuntime {
|
506
|
-
adapter: ChatModelAdapter;
|
507
|
-
private _subscriptions;
|
508
|
-
private _configProviders;
|
509
|
-
private abortController;
|
510
|
-
private repository;
|
511
|
-
get messages(): ThreadMessage[];
|
512
|
-
get isRunning(): boolean;
|
513
|
-
constructor(adapter: ChatModelAdapter);
|
514
|
-
getBranches(messageId: string): string[];
|
515
|
-
switchToBranch(branchId: string): void;
|
516
|
-
append(message: AppendMessage): Promise<void>;
|
517
|
-
startRun(parentId: string | null): Promise<void>;
|
518
|
-
cancelRun(): void;
|
519
|
-
private notifySubscribers;
|
520
|
-
subscribe(callback: () => void): Unsubscribe;
|
521
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () => boolean;
|
522
|
-
addToolResult(): void;
|
628
|
+
export { ThreadPrimitiveEmpty as Empty, ThreadPrimitiveIf as If, ThreadPrimitiveMessages as Messages, ThreadPrimitiveRoot as Root, ThreadPrimitiveScrollToBottom as ScrollToBottom, ThreadPrimitiveSuggestion as Suggestion, ThreadPrimitiveViewport as Viewport };
|
523
629
|
}
|
524
630
|
|
525
|
-
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
526
|
-
|
527
|
-
type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
528
|
-
toolName: string;
|
529
|
-
render?: ToolCallContentPartComponent<TArgs, TResult>;
|
530
|
-
};
|
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;
|
544
|
-
|
545
631
|
declare class ProxyConfigProvider {
|
546
632
|
private _providers;
|
547
633
|
getModelConfig(): ModelConfig;
|
@@ -562,12 +648,14 @@ declare class MessageRepository {
|
|
562
648
|
resetHead(messageId: string | null): void;
|
563
649
|
}
|
564
650
|
|
651
|
+
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
652
|
+
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
565
653
|
type internal_MessageRepository = MessageRepository;
|
566
654
|
declare const internal_MessageRepository: typeof MessageRepository;
|
567
655
|
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
568
656
|
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
569
657
|
declare namespace internal {
|
570
|
-
export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
658
|
+
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
571
659
|
}
|
572
660
|
|
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,
|
661
|
+
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 ContentPartPrimitiveInProgressIndicatorProps, 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 };
|