@assistant-ui/react 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/edge.js +17 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +17 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +126 -64
- package/dist/index.d.ts +126 -64
- package/dist/index.js +246 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +211 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -550,6 +550,131 @@ declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.extendSh
|
|
550
550
|
}>;
|
551
551
|
type EdgeRuntimeRequestOptions = z.infer<typeof EdgeRuntimeRequestOptionsSchema>;
|
552
552
|
|
553
|
+
type ExternalStoreMessageConverter<T> = (message: T, idx: number) => ThreadMessage;
|
554
|
+
type ExternalStoreMessageConverterAdapter<T> = {
|
555
|
+
convertMessage: ExternalStoreMessageConverter<T>;
|
556
|
+
};
|
557
|
+
type ExternalStoreAdapterBase<T> = {
|
558
|
+
threadId?: string;
|
559
|
+
isRunning?: boolean;
|
560
|
+
messages: T[];
|
561
|
+
setMessages?: (messages: T[]) => void;
|
562
|
+
onNew: (message: AppendMessage) => Promise<void>;
|
563
|
+
onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
|
564
|
+
onReload?: ((parentId: string | null) => Promise<void>) | undefined;
|
565
|
+
onCancel?: (() => Promise<void>) | undefined;
|
566
|
+
onNewThread?: () => Promise<void> | void;
|
567
|
+
onAddToolResult?: (options: AddToolResultOptions) => Promise<void> | void;
|
568
|
+
onSwitchThread?: (threadId: string | null) => Promise<void> | void;
|
569
|
+
convertMessage?: ExternalStoreMessageConverter<T> | undefined;
|
570
|
+
};
|
571
|
+
type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
|
572
|
+
|
573
|
+
declare class ProxyConfigProvider implements ModelConfigProvider {
|
574
|
+
private _providers;
|
575
|
+
getModelConfig(): ModelConfig;
|
576
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
577
|
+
}
|
578
|
+
|
579
|
+
declare class MessageRepository {
|
580
|
+
private messages;
|
581
|
+
private head;
|
582
|
+
private root;
|
583
|
+
private performOp;
|
584
|
+
getMessages(): ThreadMessage[];
|
585
|
+
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
586
|
+
getMessage(messageId: string): {
|
587
|
+
parentId: string | null;
|
588
|
+
message: ThreadMessage;
|
589
|
+
};
|
590
|
+
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
591
|
+
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
592
|
+
getBranches(messageId: string): string[];
|
593
|
+
switchToBranch(messageId: string): void;
|
594
|
+
resetHead(messageId: string | null): void;
|
595
|
+
}
|
596
|
+
|
597
|
+
declare const useSmooth: (text: string, smooth?: boolean) => string;
|
598
|
+
|
599
|
+
declare const buttonVariants: (props?: ({
|
600
|
+
variant?: "default" | "outline" | "ghost" | null | undefined;
|
601
|
+
size?: "default" | "icon" | null | undefined;
|
602
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
603
|
+
type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
|
604
|
+
|
605
|
+
type TooltipIconButtonProps = ButtonProps & {
|
606
|
+
tooltip: string;
|
607
|
+
side?: "top" | "bottom" | "left" | "right";
|
608
|
+
};
|
609
|
+
declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
610
|
+
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;
|
611
|
+
} & {
|
612
|
+
asChild?: boolean;
|
613
|
+
}, "ref"> & class_variance_authority.VariantProps<(props?: ({
|
614
|
+
variant?: "default" | "outline" | "ghost" | null | undefined;
|
615
|
+
size?: "default" | "icon" | null | undefined;
|
616
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
617
|
+
tooltip: string;
|
618
|
+
side?: "top" | "bottom" | "left" | "right";
|
619
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
620
|
+
|
621
|
+
declare const generateId: (size?: number) => string;
|
622
|
+
|
623
|
+
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
624
|
+
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
625
|
+
type internal_MessageRepository = MessageRepository;
|
626
|
+
declare const internal_MessageRepository: typeof MessageRepository;
|
627
|
+
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
628
|
+
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
629
|
+
declare const internal_TooltipIconButton: typeof TooltipIconButton;
|
630
|
+
declare const internal_generateId: typeof generateId;
|
631
|
+
declare const internal_useSmooth: typeof useSmooth;
|
632
|
+
declare namespace internal {
|
633
|
+
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth };
|
634
|
+
}
|
635
|
+
|
636
|
+
declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
|
637
|
+
store: ExternalStoreAdapter<any>;
|
638
|
+
private _subscriptions;
|
639
|
+
private repository;
|
640
|
+
private assistantOptimisticId;
|
641
|
+
private useStore;
|
642
|
+
get capabilities(): {
|
643
|
+
edit: boolean;
|
644
|
+
reload: boolean;
|
645
|
+
cancel: boolean;
|
646
|
+
copy: boolean;
|
647
|
+
};
|
648
|
+
messages: ThreadMessage[];
|
649
|
+
isRunning: boolean;
|
650
|
+
constructor(store: ExternalStoreAdapter<any>);
|
651
|
+
getBranches(messageId: string): string[];
|
652
|
+
switchToBranch(branchId: string): void;
|
653
|
+
append(message: AppendMessage): Promise<void>;
|
654
|
+
startRun(parentId: string | null): Promise<void>;
|
655
|
+
cancelRun(): void;
|
656
|
+
subscribe(callback: () => void): Unsubscribe;
|
657
|
+
private updateMessages;
|
658
|
+
onStoreUpdated(): void;
|
659
|
+
private updateData;
|
660
|
+
unstable_synchronizer: () => null;
|
661
|
+
addToolResult(options: AddToolResultOptions): void;
|
662
|
+
}
|
663
|
+
|
664
|
+
declare class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {
|
665
|
+
private readonly _proxyConfigProvider;
|
666
|
+
constructor(store: ExternalStoreAdapter<any>);
|
667
|
+
set store(store: ExternalStoreAdapter<any>);
|
668
|
+
onStoreUpdated(): void;
|
669
|
+
getModelConfig(): ModelConfig;
|
670
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
671
|
+
switchToThread(threadId: string | null): void | Promise<void>;
|
672
|
+
}
|
673
|
+
|
674
|
+
declare const useExternalStoreRuntime: (store: ExternalStoreAdapter<any>) => ExternalStoreRuntime;
|
675
|
+
|
676
|
+
declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
|
677
|
+
|
553
678
|
type ThreadRuntimeStore = ThreadRuntime;
|
554
679
|
|
555
680
|
type AddToolResultOptions = {
|
@@ -1173,28 +1298,6 @@ type ThreadConfigProviderProps = PropsWithChildren<{
|
|
1173
1298
|
}>;
|
1174
1299
|
declare const ThreadConfigProvider: FC<ThreadConfigProviderProps>;
|
1175
1300
|
|
1176
|
-
declare const buttonVariants: (props?: ({
|
1177
|
-
variant?: "default" | "outline" | "ghost" | null | undefined;
|
1178
|
-
size?: "default" | "icon" | null | undefined;
|
1179
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
1180
|
-
type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
|
1181
|
-
|
1182
|
-
type TooltipIconButtonProps = ButtonProps & {
|
1183
|
-
tooltip: string;
|
1184
|
-
side?: "top" | "bottom" | "left" | "right";
|
1185
|
-
};
|
1186
|
-
declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
1187
|
-
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;
|
1188
|
-
} & {
|
1189
|
-
asChild?: boolean;
|
1190
|
-
}, "ref"> & class_variance_authority.VariantProps<(props?: ({
|
1191
|
-
variant?: "default" | "outline" | "ghost" | null | undefined;
|
1192
|
-
size?: "default" | "icon" | null | undefined;
|
1193
|
-
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
1194
|
-
tooltip: string;
|
1195
|
-
side?: "top" | "bottom" | "left" | "right";
|
1196
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
1197
|
-
|
1198
1301
|
declare const AssistantActionBar: FC;
|
1199
1302
|
declare const exports$a: {
|
1200
1303
|
Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
@@ -1361,45 +1464,4 @@ declare const exports: {
|
|
1361
1464
|
Text: FC<TextContentPartProps>;
|
1362
1465
|
};
|
1363
1466
|
|
1364
|
-
|
1365
|
-
private _providers;
|
1366
|
-
getModelConfig(): ModelConfig;
|
1367
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
1368
|
-
}
|
1369
|
-
|
1370
|
-
declare class MessageRepository {
|
1371
|
-
private messages;
|
1372
|
-
private head;
|
1373
|
-
private root;
|
1374
|
-
private performOp;
|
1375
|
-
getMessages(): ThreadMessage[];
|
1376
|
-
addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
|
1377
|
-
getMessage(messageId: string): {
|
1378
|
-
parentId: string | null;
|
1379
|
-
message: ThreadMessage;
|
1380
|
-
};
|
1381
|
-
appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
|
1382
|
-
deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
|
1383
|
-
getBranches(messageId: string): string[];
|
1384
|
-
switchToBranch(messageId: string): void;
|
1385
|
-
resetHead(messageId: string | null): void;
|
1386
|
-
}
|
1387
|
-
|
1388
|
-
declare const useSmooth: (text: string, smooth?: boolean) => string;
|
1389
|
-
|
1390
|
-
declare const generateId: (size?: number) => string;
|
1391
|
-
|
1392
|
-
type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
|
1393
|
-
declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
|
1394
|
-
type internal_MessageRepository = MessageRepository;
|
1395
|
-
declare const internal_MessageRepository: typeof MessageRepository;
|
1396
|
-
type internal_ProxyConfigProvider = ProxyConfigProvider;
|
1397
|
-
declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
|
1398
|
-
declare const internal_TooltipIconButton: typeof TooltipIconButton;
|
1399
|
-
declare const internal_generateId: typeof generateId;
|
1400
|
-
declare const internal_useSmooth: typeof useSmooth;
|
1401
|
-
declare namespace internal {
|
1402
|
-
export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth };
|
1403
|
-
}
|
1404
|
-
|
1405
|
-
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type CoreAssistantContentPart, type CoreAssistantMessage, type CoreMessage, type CoreSystemMessage, type CoreUserContentPart, type CoreUserMessage, EdgeChatAdapter, type EdgeRuntimeOptions, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type MessageStatus, type MessageUtilsState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type StringsConfig, type SuggestionConfig, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, type ThreadAssistantContentPart, type ThreadAssistantMessage, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadMessage, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserContentPart, type ThreadUserMessage, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, type Tool, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, makeAssistantTool, makeAssistantToolUI, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|
1467
|
+
export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, type AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, type CoreAssistantContentPart, type CoreAssistantMessage, type CoreMessage, type CoreSystemMessage, type CoreUserContentPart, type CoreUserMessage, EdgeChatAdapter, type EdgeRuntimeOptions, type EdgeRuntimeRequestOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, type ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, type MessageStatus, type MessageUtilsState, type ModelConfig, type ModelConfigProvider, type ReactThreadRuntime, type StringsConfig, type SuggestionConfig, type TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, type ThreadAssistantContentPart, type ThreadAssistantMessage, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadMessage, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserContentPart, type ThreadUserMessage, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, type Tool, type ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, type UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
|