@assistant-ui/react 0.1.12 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/experimental.d.mts +1 -115
- package/dist/experimental.d.ts +1 -115
- package/dist/experimental.js +0 -183
- package/dist/experimental.js.map +1 -1
- package/dist/experimental.mjs +0 -88
- package/dist/experimental.mjs.map +1 -1
- package/dist/index.d.mts +212 -10
- package/dist/index.d.ts +212 -10
- package/dist/index.js +477 -388
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -358
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/ThreadActions-BLcKtagX.d.mts +0 -98
- package/dist/ThreadActions-BLcKtagX.d.ts +0 -98
- package/dist/chunk-KUACYNLE.mjs +0 -85
- package/dist/chunk-KUACYNLE.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import { FC, PropsWithChildren, ComponentPropsWithoutRef,
|
2
|
+
import { FC, PropsWithChildren, ComponentPropsWithoutRef, ReactNode, ComponentType } from 'react';
|
3
3
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
4
4
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
6
|
-
import {
|
7
|
-
|
8
|
-
import 'zod';
|
6
|
+
import { z } from 'zod';
|
7
|
+
import { UseBoundStore, StoreApi } from 'zustand';
|
9
8
|
|
10
9
|
type UseActionBarCopyProps = {
|
11
10
|
copiedDuration?: number;
|
@@ -181,9 +180,9 @@ declare namespace index$3 {
|
|
181
180
|
|
182
181
|
declare const ContentPartInProgressIndicator: FC;
|
183
182
|
|
184
|
-
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.
|
183
|
+
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.p>;
|
185
184
|
type ContentPartTextProps = Omit<PrimitiveSpanProps, "children">;
|
186
|
-
declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<
|
185
|
+
declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<HTMLParagraphElement>>;
|
187
186
|
|
188
187
|
declare const ContentPartImage: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
|
189
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;
|
@@ -206,6 +205,71 @@ declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.Detai
|
|
206
205
|
type MessageIfProps = PropsWithChildren<UseMessageIfProps>;
|
207
206
|
declare const MessageIf: FC<MessageIfProps>;
|
208
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
|
+
|
209
273
|
type MessageContentProps = {
|
210
274
|
components?: {
|
211
275
|
Text?: TextContentPartComponent;
|
@@ -288,6 +352,131 @@ declare namespace index {
|
|
288
352
|
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
|
289
353
|
}
|
290
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
|
+
|
291
480
|
type ThreadRuntime = Readonly<ThreadState & ThreadActionsState & {
|
292
481
|
subscribe: (callback: () => void) => Unsubscribe;
|
293
482
|
}>;
|
@@ -335,10 +524,23 @@ declare class LocalRuntime implements AssistantRuntime {
|
|
335
524
|
|
336
525
|
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
337
526
|
|
338
|
-
type
|
339
|
-
|
527
|
+
type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
528
|
+
toolName: string;
|
529
|
+
render?: ToolCallContentPartComponent<TArgs, TResult>;
|
340
530
|
};
|
341
|
-
declare const
|
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;
|
342
544
|
|
343
545
|
declare class ProxyConfigProvider {
|
344
546
|
private _providers;
|
@@ -368,4 +570,4 @@ declare namespace internal {
|
|
368
570
|
export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
369
571
|
}
|
370
572
|
|
371
|
-
export { index$6 as ActionBarPrimitive, AppendMessage, AssistantContentPart, index$5 as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, index$4 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$3 as ComposerPrimitive, index$2 as ContentPartPrimitive, internal as INTERNAL, index$1 as MessagePrimitive, type ReactThreadRuntime, ThreadMessage, index 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 };
|
package/dist/index.d.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import * as react from 'react';
|
2
|
-
import { FC, PropsWithChildren, ComponentPropsWithoutRef,
|
2
|
+
import { FC, PropsWithChildren, ComponentPropsWithoutRef, ReactNode, ComponentType } from 'react';
|
3
3
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
4
4
|
import { TextareaAutosizeProps } from 'react-textarea-autosize';
|
5
5
|
import { Primitive } from '@radix-ui/react-primitive';
|
6
|
-
import {
|
7
|
-
|
8
|
-
import 'zod';
|
6
|
+
import { z } from 'zod';
|
7
|
+
import { UseBoundStore, StoreApi } from 'zustand';
|
9
8
|
|
10
9
|
type UseActionBarCopyProps = {
|
11
10
|
copiedDuration?: number;
|
@@ -181,9 +180,9 @@ declare namespace index$3 {
|
|
181
180
|
|
182
181
|
declare const ContentPartInProgressIndicator: FC;
|
183
182
|
|
184
|
-
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.
|
183
|
+
type PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.p>;
|
185
184
|
type ContentPartTextProps = Omit<PrimitiveSpanProps, "children">;
|
186
|
-
declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<
|
185
|
+
declare const ContentPartText: react.ForwardRefExoticComponent<ContentPartTextProps & react.RefAttributes<HTMLParagraphElement>>;
|
187
186
|
|
188
187
|
declare const ContentPartImage: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref"> & {
|
189
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;
|
@@ -206,6 +205,71 @@ declare const MessageRoot: react.ForwardRefExoticComponent<Omit<Omit<react.Detai
|
|
206
205
|
type MessageIfProps = PropsWithChildren<UseMessageIfProps>;
|
207
206
|
declare const MessageIf: FC<MessageIfProps>;
|
208
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
|
+
|
209
273
|
type MessageContentProps = {
|
210
274
|
components?: {
|
211
275
|
Text?: TextContentPartComponent;
|
@@ -288,6 +352,131 @@ declare namespace index {
|
|
288
352
|
export { ThreadEmpty as Empty, ThreadIf as If, ThreadMessages as Messages, ThreadRoot as Root, ThreadScrollToBottom as ScrollToBottom, ThreadSuggestion as Suggestion, ThreadViewport as Viewport };
|
289
353
|
}
|
290
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
|
+
|
291
480
|
type ThreadRuntime = Readonly<ThreadState & ThreadActionsState & {
|
292
481
|
subscribe: (callback: () => void) => Unsubscribe;
|
293
482
|
}>;
|
@@ -335,10 +524,23 @@ declare class LocalRuntime implements AssistantRuntime {
|
|
335
524
|
|
336
525
|
declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
|
337
526
|
|
338
|
-
type
|
339
|
-
|
527
|
+
type AssistantToolProps<TArgs, TResult> = Tool<TArgs, TResult> & {
|
528
|
+
toolName: string;
|
529
|
+
render?: ToolCallContentPartComponent<TArgs, TResult>;
|
340
530
|
};
|
341
|
-
declare const
|
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;
|
342
544
|
|
343
545
|
declare class ProxyConfigProvider {
|
344
546
|
private _providers;
|
@@ -368,4 +570,4 @@ declare namespace internal {
|
|
368
570
|
export { internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
|
369
571
|
}
|
370
572
|
|
371
|
-
export { index$6 as ActionBarPrimitive, AppendMessage, AssistantContentPart, index$5 as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, index$4 as BranchPickerPrimitive, type ChatModelAdapter, type ChatModelRunOptions, index$3 as ComposerPrimitive, index$2 as ContentPartPrimitive, internal as INTERNAL, index$1 as MessagePrimitive, type ReactThreadRuntime, ThreadMessage, index 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 };
|