@assistant-ui/react 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -550,6 +550,132 @@ 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) | undefined;
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
+ onCopy?: (() => Promise<void>) | null | undefined;
567
+ onNewThread?: (() => Promise<void> | void) | undefined;
568
+ onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
569
+ onSwitchThread?: ((threadId: string | null) => Promise<void> | void) | undefined;
570
+ convertMessage?: ExternalStoreMessageConverter<T> | undefined;
571
+ };
572
+ type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
573
+
574
+ declare class ProxyConfigProvider implements ModelConfigProvider {
575
+ private _providers;
576
+ getModelConfig(): ModelConfig;
577
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
578
+ }
579
+
580
+ declare class MessageRepository {
581
+ private messages;
582
+ private head;
583
+ private root;
584
+ private performOp;
585
+ getMessages(): ThreadMessage[];
586
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
587
+ getMessage(messageId: string): {
588
+ parentId: string | null;
589
+ message: ThreadMessage;
590
+ };
591
+ appendOptimisticMessage(parentId: string | null, message: CoreMessage): string;
592
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
593
+ getBranches(messageId: string): string[];
594
+ switchToBranch(messageId: string): void;
595
+ resetHead(messageId: string | null): void;
596
+ }
597
+
598
+ declare const useSmooth: (text: string, smooth?: boolean) => string;
599
+
600
+ declare const buttonVariants: (props?: ({
601
+ variant?: "default" | "outline" | "ghost" | null | undefined;
602
+ size?: "default" | "icon" | null | undefined;
603
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
604
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
605
+
606
+ type TooltipIconButtonProps = ButtonProps & {
607
+ tooltip: string;
608
+ side?: "top" | "bottom" | "left" | "right";
609
+ };
610
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
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;
612
+ } & {
613
+ asChild?: boolean;
614
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
615
+ variant?: "default" | "outline" | "ghost" | null | undefined;
616
+ size?: "default" | "icon" | null | undefined;
617
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
618
+ tooltip: string;
619
+ side?: "top" | "bottom" | "left" | "right";
620
+ } & react.RefAttributes<HTMLButtonElement>>;
621
+
622
+ declare const generateId: (size?: number) => string;
623
+
624
+ type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
625
+ declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
626
+ type internal_MessageRepository = MessageRepository;
627
+ declare const internal_MessageRepository: typeof MessageRepository;
628
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
629
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
630
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
631
+ declare const internal_generateId: typeof generateId;
632
+ declare const internal_useSmooth: typeof useSmooth;
633
+ declare namespace internal {
634
+ 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 };
635
+ }
636
+
637
+ declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
638
+ store: ExternalStoreAdapter<any>;
639
+ private _subscriptions;
640
+ private repository;
641
+ private assistantOptimisticId;
642
+ private useStore;
643
+ get capabilities(): {
644
+ edit: boolean;
645
+ reload: boolean;
646
+ cancel: boolean;
647
+ copy: boolean;
648
+ };
649
+ messages: ThreadMessage[];
650
+ isRunning: boolean;
651
+ constructor(store: ExternalStoreAdapter<any>);
652
+ getBranches(messageId: string): string[];
653
+ switchToBranch(branchId: string): void;
654
+ append(message: AppendMessage): Promise<void>;
655
+ startRun(parentId: string | null): Promise<void>;
656
+ cancelRun(): void;
657
+ subscribe(callback: () => void): Unsubscribe;
658
+ private updateMessages;
659
+ onStoreUpdated(): void;
660
+ private updateData;
661
+ unstable_synchronizer: () => null;
662
+ addToolResult(options: AddToolResultOptions): void;
663
+ }
664
+
665
+ declare class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {
666
+ private readonly _proxyConfigProvider;
667
+ constructor(store: ExternalStoreAdapter<any>);
668
+ set store(store: ExternalStoreAdapter<any>);
669
+ onStoreUpdated(): void;
670
+ getModelConfig(): ModelConfig;
671
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
672
+ switchToThread(threadId: string | null): void | Promise<void>;
673
+ }
674
+
675
+ declare const useExternalStoreRuntime: (store: ExternalStoreAdapter<any>) => ExternalStoreRuntime;
676
+
677
+ declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
678
+
553
679
  type ThreadRuntimeStore = ThreadRuntime;
554
680
 
555
681
  type AddToolResultOptions = {
@@ -1173,28 +1299,6 @@ type ThreadConfigProviderProps = PropsWithChildren<{
1173
1299
  }>;
1174
1300
  declare const ThreadConfigProvider: FC<ThreadConfigProviderProps>;
1175
1301
 
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
1302
  declare const AssistantActionBar: FC;
1199
1303
  declare const exports$a: {
1200
1304
  Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -1361,45 +1465,4 @@ declare const exports: {
1361
1465
  Text: FC<TextContentPartProps>;
1362
1466
  };
1363
1467
 
1364
- declare class ProxyConfigProvider implements ModelConfigProvider {
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 };
1468
+ 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 };