@assistant-ui/react 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -82,6 +82,12 @@ type ChatModelAdapter = {
82
82
 
83
83
  declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
84
84
  private _thread;
85
+ get capabilities(): Readonly<{
86
+ edit: boolean;
87
+ reload: boolean;
88
+ cancel: boolean;
89
+ copy: boolean;
90
+ }>;
85
91
  constructor(_thread: TThreadRuntime);
86
92
  private _unsubscribe;
87
93
  get thread(): TThreadRuntime;
@@ -114,7 +120,13 @@ declare class LocalThreadRuntime implements ThreadRuntime {
114
120
  adapter: ChatModelAdapter;
115
121
  private _subscriptions;
116
122
  private abortController;
117
- private repository;
123
+ private readonly repository;
124
+ readonly capabilities: Readonly<{
125
+ edit: true;
126
+ reload: true;
127
+ cancel: true;
128
+ copy: true;
129
+ }>;
118
130
  get messages(): ThreadMessage[];
119
131
  get isRunning(): boolean;
120
132
  constructor(_configProviders: Set<ModelConfigProvider>, adapter: ChatModelAdapter);
@@ -131,6 +143,12 @@ declare class LocalThreadRuntime implements ThreadRuntime {
131
143
  declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
132
144
 
133
145
  type ThreadActionsState = Readonly<{
146
+ capabilities: Readonly<{
147
+ edit: boolean;
148
+ reload: boolean;
149
+ cancel: boolean;
150
+ copy: boolean;
151
+ }>;
134
152
  getBranches: (messageId: string) => readonly string[];
135
153
  switchToBranch: (branchId: string) => void;
136
154
  append: (message: AppendMessage) => void;
@@ -202,10 +220,11 @@ type BaseComposerState = Readonly<{
202
220
  type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
203
221
 
204
222
  type EditComposerState = BaseComposerState & Readonly<{
223
+ canCancel: boolean;
205
224
  isEditing: boolean;
206
225
  edit: () => void;
207
226
  send: () => void;
208
- cancel: () => boolean;
227
+ cancel: () => void;
209
228
  }>;
210
229
 
211
230
  type ThreadState = Readonly<{
@@ -271,9 +290,10 @@ type ContentPartContextValue = {
271
290
  declare const useContentPartContext: () => ContentPartContextValue;
272
291
 
273
292
  type ComposerState = BaseComposerState & Readonly<{
293
+ canCancel: boolean;
274
294
  isEditing: true;
275
295
  send: () => void;
276
- cancel: () => boolean;
296
+ cancel: () => void;
277
297
  focus: () => void;
278
298
  onFocus: (listener: () => void) => Unsubscribe;
279
299
  }>;
@@ -336,9 +356,15 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
336
356
 
337
357
  declare const useComposerSend: () => (() => void) | null;
338
358
 
339
- declare const useContentPartDisplay: () => react.ReactNode;
359
+ declare const useContentPartDisplay: () => Readonly<{
360
+ status: "in_progress" | "done" | "error";
361
+ part: UIContentPart;
362
+ }>;
340
363
 
341
- declare const useContentPartImage: () => string;
364
+ declare const useContentPartImage: () => Readonly<{
365
+ status: "in_progress" | "done" | "error";
366
+ part: ImageContentPart;
367
+ }>;
342
368
 
343
369
  declare const useContentPartText: () => Readonly<{
344
370
  status: "in_progress" | "done" | "error";
@@ -508,8 +534,16 @@ declare namespace index$3 {
508
534
  }
509
535
 
510
536
  type PrimitiveSpanProps$1 = ComponentPropsWithoutRef<typeof Primitive.span>;
511
- type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children">;
512
- declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<ContentPartPrimitiveTextProps & react.RefAttributes<HTMLSpanElement>>;
537
+ type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children"> & {
538
+ smooth?: boolean;
539
+ };
540
+ declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
541
+ 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;
542
+ } & {
543
+ asChild?: boolean;
544
+ }, "ref">, "children"> & {
545
+ smooth?: boolean;
546
+ } & react.RefAttributes<HTMLSpanElement>>;
513
547
 
514
548
  type PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;
515
549
  type ContentPartPrimitiveImageProps = PrimitiveImageProps;
@@ -605,7 +639,7 @@ type ThreadPrimitiveMessagesProps = {
605
639
  AssistantMessage: ComponentType;
606
640
  };
607
641
  };
608
- declare const ThreadPrimitiveMessages: FC<ThreadPrimitiveMessagesProps>;
642
+ declare const ThreadPrimitiveMessages: react.NamedExoticComponent<ThreadPrimitiveMessagesProps>;
609
643
 
610
644
  type ThreadPrimitiveScrollToBottomProps = ActionButtonProps<typeof useThreadScrollToBottom>;
611
645
  declare const ThreadPrimitiveScrollToBottom: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -645,14 +679,17 @@ declare class MessageRepository {
645
679
  resetHead(messageId: string | null): void;
646
680
  }
647
681
 
682
+ declare const useSmooth: (text: string, smooth?: boolean) => string;
683
+
648
684
  type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
649
685
  declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
650
686
  type internal_MessageRepository = MessageRepository;
651
687
  declare const internal_MessageRepository: typeof MessageRepository;
652
688
  type internal_ProxyConfigProvider = ProxyConfigProvider;
653
689
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
690
+ declare const internal_useSmooth: typeof useSmooth;
654
691
  declare namespace internal {
655
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
692
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_useSmooth as useSmooth };
656
693
  }
657
694
 
658
695
  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 ContentPartPrimitiveInProgressProps, 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 };
package/dist/index.d.ts CHANGED
@@ -82,6 +82,12 @@ type ChatModelAdapter = {
82
82
 
83
83
  declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
84
84
  private _thread;
85
+ get capabilities(): Readonly<{
86
+ edit: boolean;
87
+ reload: boolean;
88
+ cancel: boolean;
89
+ copy: boolean;
90
+ }>;
85
91
  constructor(_thread: TThreadRuntime);
86
92
  private _unsubscribe;
87
93
  get thread(): TThreadRuntime;
@@ -114,7 +120,13 @@ declare class LocalThreadRuntime implements ThreadRuntime {
114
120
  adapter: ChatModelAdapter;
115
121
  private _subscriptions;
116
122
  private abortController;
117
- private repository;
123
+ private readonly repository;
124
+ readonly capabilities: Readonly<{
125
+ edit: true;
126
+ reload: true;
127
+ cancel: true;
128
+ copy: true;
129
+ }>;
118
130
  get messages(): ThreadMessage[];
119
131
  get isRunning(): boolean;
120
132
  constructor(_configProviders: Set<ModelConfigProvider>, adapter: ChatModelAdapter);
@@ -131,6 +143,12 @@ declare class LocalThreadRuntime implements ThreadRuntime {
131
143
  declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
132
144
 
133
145
  type ThreadActionsState = Readonly<{
146
+ capabilities: Readonly<{
147
+ edit: boolean;
148
+ reload: boolean;
149
+ cancel: boolean;
150
+ copy: boolean;
151
+ }>;
134
152
  getBranches: (messageId: string) => readonly string[];
135
153
  switchToBranch: (branchId: string) => void;
136
154
  append: (message: AppendMessage) => void;
@@ -202,10 +220,11 @@ type BaseComposerState = Readonly<{
202
220
  type ReadonlyStore<T> = UseBoundStore<Omit<StoreApi<T>, "setState" | "destroy">>;
203
221
 
204
222
  type EditComposerState = BaseComposerState & Readonly<{
223
+ canCancel: boolean;
205
224
  isEditing: boolean;
206
225
  edit: () => void;
207
226
  send: () => void;
208
- cancel: () => boolean;
227
+ cancel: () => void;
209
228
  }>;
210
229
 
211
230
  type ThreadState = Readonly<{
@@ -271,9 +290,10 @@ type ContentPartContextValue = {
271
290
  declare const useContentPartContext: () => ContentPartContextValue;
272
291
 
273
292
  type ComposerState = BaseComposerState & Readonly<{
293
+ canCancel: boolean;
274
294
  isEditing: true;
275
295
  send: () => void;
276
- cancel: () => boolean;
296
+ cancel: () => void;
277
297
  focus: () => void;
278
298
  onFocus: (listener: () => void) => Unsubscribe;
279
299
  }>;
@@ -336,9 +356,15 @@ declare const useComposerIf: (props: UseComposerIfProps) => boolean;
336
356
 
337
357
  declare const useComposerSend: () => (() => void) | null;
338
358
 
339
- declare const useContentPartDisplay: () => react.ReactNode;
359
+ declare const useContentPartDisplay: () => Readonly<{
360
+ status: "in_progress" | "done" | "error";
361
+ part: UIContentPart;
362
+ }>;
340
363
 
341
- declare const useContentPartImage: () => string;
364
+ declare const useContentPartImage: () => Readonly<{
365
+ status: "in_progress" | "done" | "error";
366
+ part: ImageContentPart;
367
+ }>;
342
368
 
343
369
  declare const useContentPartText: () => Readonly<{
344
370
  status: "in_progress" | "done" | "error";
@@ -508,8 +534,16 @@ declare namespace index$3 {
508
534
  }
509
535
 
510
536
  type PrimitiveSpanProps$1 = ComponentPropsWithoutRef<typeof Primitive.span>;
511
- type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children">;
512
- declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<ContentPartPrimitiveTextProps & react.RefAttributes<HTMLSpanElement>>;
537
+ type ContentPartPrimitiveTextProps = Omit<PrimitiveSpanProps$1, "children"> & {
538
+ smooth?: boolean;
539
+ };
540
+ declare const ContentPartPrimitiveText: react.ForwardRefExoticComponent<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
541
+ 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;
542
+ } & {
543
+ asChild?: boolean;
544
+ }, "ref">, "children"> & {
545
+ smooth?: boolean;
546
+ } & react.RefAttributes<HTMLSpanElement>>;
513
547
 
514
548
  type PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;
515
549
  type ContentPartPrimitiveImageProps = PrimitiveImageProps;
@@ -605,7 +639,7 @@ type ThreadPrimitiveMessagesProps = {
605
639
  AssistantMessage: ComponentType;
606
640
  };
607
641
  };
608
- declare const ThreadPrimitiveMessages: FC<ThreadPrimitiveMessagesProps>;
642
+ declare const ThreadPrimitiveMessages: react.NamedExoticComponent<ThreadPrimitiveMessagesProps>;
609
643
 
610
644
  type ThreadPrimitiveScrollToBottomProps = ActionButtonProps<typeof useThreadScrollToBottom>;
611
645
  declare const ThreadPrimitiveScrollToBottom: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -645,14 +679,17 @@ declare class MessageRepository {
645
679
  resetHead(messageId: string | null): void;
646
680
  }
647
681
 
682
+ declare const useSmooth: (text: string, smooth?: boolean) => string;
683
+
648
684
  type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
649
685
  declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
650
686
  type internal_MessageRepository = MessageRepository;
651
687
  declare const internal_MessageRepository: typeof MessageRepository;
652
688
  type internal_ProxyConfigProvider = ProxyConfigProvider;
653
689
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
690
+ declare const internal_useSmooth: typeof useSmooth;
654
691
  declare namespace internal {
655
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider };
692
+ export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_useSmooth as useSmooth };
656
693
  }
657
694
 
658
695
  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 ContentPartPrimitiveInProgressProps, 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 };