@assistant-ui/react 0.0.26 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -13,15 +13,16 @@
13
13
  ## Minimal Example with Vercel AI SDK
14
14
 
15
15
  ```sh
16
- npx assistant-ui add thread
16
+ npx assistant-ui@latest add assistant-modal
17
17
  ```
18
18
 
19
19
  ```tsx
20
20
  "use client";
21
21
 
22
22
  import { useChat } from "@ai-sdk/react";
23
- import { AssistantRuntimeProvider, useVercelUseChatRuntime } from "@assistant-ui/react";
24
- import { Thread } from "@/components/ui/assistant-ui/thread";
23
+ import { AssistantRuntimeProvider } from "@assistant-ui/react";
24
+ import { useVercelUseChatRuntime } from "@assistant-ui/react-ai-sdk";
25
+ import { AssistantModal } from "@/components/ui/assistant-ui/assistant-modal";
25
26
 
26
27
  export default const MyApp = () => {
27
28
  const chat = useChat({
@@ -31,7 +32,7 @@ export default const MyApp = () => {
31
32
 
32
33
  return (
33
34
  <AssistantRuntimeProvider runtime={runtime}>
34
- <Thread />
35
+ <AssistantModal />
35
36
  </AssistantRuntimeProvider>
36
37
  );
37
38
  }
package/dist/index.d.mts CHANGED
@@ -2,9 +2,9 @@ import * as react from 'react';
2
2
  import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from '@ai-sdk/react';
5
- import { Message, LanguageModel } from 'ai';
6
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
6
  import { UseBoundStore, StoreApi } from 'zustand';
7
+ import { Message } from 'ai';
8
8
 
9
9
  declare const useCopyMessage: ({ copiedDuration }: {
10
10
  copiedDuration?: number | undefined;
@@ -294,26 +294,6 @@ type VercelRSCAdapterBase<T> = {
294
294
  };
295
295
  type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
296
296
 
297
- type ThreadState = {
298
- messages: ThreadMessage[];
299
- isRunning: boolean;
300
- getBranches: (messageId: string) => readonly string[];
301
- switchToBranch: (branchId: string) => void;
302
- append: (message: AppendMessage) => void;
303
- startRun: (parentId: string | null) => void;
304
- cancelRun: () => void;
305
- };
306
-
307
- type Unsubscribe = () => void;
308
- type ThreadRuntime = Readonly<ThreadState> & {
309
- subscribe: (callback: () => void) => Unsubscribe;
310
- };
311
- type ReactThreadRuntime = Readonly<ThreadState> & {
312
- unstable_synchronizer?: ComponentType;
313
- };
314
-
315
- type AssistantRuntime = ThreadRuntime;
316
-
317
297
  declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements AssistantRuntime, ReactThreadRuntime {
318
298
  adapter: VercelRSCAdapter<T>;
319
299
  private useAdapter;
@@ -327,7 +307,7 @@ declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements
327
307
  append(message: AppendMessage): Promise<void>;
328
308
  startRun(parentId: string | null): Promise<void>;
329
309
  cancelRun(): void;
330
- subscribe(callback: () => void): Unsubscribe;
310
+ subscribe(callback: () => void): () => void;
331
311
  onAdapterUpdated(): void;
332
312
  private updateData;
333
313
  unstable_synchronizer: () => null;
@@ -353,7 +333,7 @@ declare class VercelAIRuntime implements AssistantRuntime, ReactThreadRuntime {
353
333
  append(message: AppendMessage): Promise<void>;
354
334
  startRun(parentId: string | null): Promise<void>;
355
335
  cancelRun(): void;
356
- subscribe(callback: () => void): Unsubscribe;
336
+ subscribe(callback: () => void): () => void;
357
337
  private updateVercelMessages;
358
338
  onVercelUpdated(): void;
359
339
  private updateData;
@@ -366,72 +346,6 @@ declare const useVercelUseAssistantRuntime: (assistantHelpers: UseAssistantHelpe
366
346
 
367
347
  declare const getVercelAIMessage: (message: ThreadMessage) => Message[] | undefined;
368
348
 
369
- /**
370
- * @deprecated Will be removed in 0.1.0.
371
- */
372
- type VercelAIAssistantProviderProps = PropsWithChildren<{
373
- chat: UseChatHelpers;
374
- } | {
375
- assistant: UseAssistantHelpers;
376
- }>;
377
- /**
378
- * @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
379
- */
380
- declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
381
-
382
- /**
383
- * @deprecated Will be removed in 0.1.0.
384
- */
385
- type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
386
- /**
387
- * @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
388
- */
389
- declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
390
-
391
- type ChatModelRunResult = {
392
- content: AssistantContentPart[];
393
- };
394
- type ChatModelRunOptions = {
395
- messages: ThreadMessage[];
396
- abortSignal: AbortSignal;
397
- onUpdate: (result: ChatModelRunResult) => void;
398
- };
399
- type ChatModelAdapter = {
400
- run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
401
- };
402
-
403
- declare class LocalRuntime implements AssistantRuntime {
404
- adapter: ChatModelAdapter;
405
- private _subscriptions;
406
- private abortController;
407
- private repository;
408
- get messages(): ThreadMessage[];
409
- get isRunning(): boolean;
410
- constructor(adapter: ChatModelAdapter);
411
- getBranches(messageId: string): string[];
412
- switchToBranch(branchId: string): void;
413
- append(message: AppendMessage): Promise<void>;
414
- startRun(parentId: string | null): Promise<void>;
415
- cancelRun(): void;
416
- private notifySubscribers;
417
- subscribe(callback: () => void): Unsubscribe;
418
- }
419
-
420
- declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
421
-
422
- declare class VercelModelAdapter implements ChatModelAdapter {
423
- private readonly model;
424
- constructor(model: LanguageModel);
425
- run({ messages, abortSignal, onUpdate }: ChatModelRunOptions): Promise<{
426
- content: AssistantContentPart[];
427
- }>;
428
- }
429
-
430
- type AssistantRuntimeProviderProps = {
431
- runtime: AssistantRuntime;
432
- };
433
- declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
434
-
435
349
  type ContentPartState = Readonly<{
436
350
  status: "in_progress" | "done" | "error";
437
351
  part: ThreadMessage["content"][number];
@@ -462,6 +376,16 @@ type EditComposerState = BaseComposerState & Readonly<{
462
376
  cancel: () => boolean;
463
377
  }>;
464
378
 
379
+ type ThreadState = {
380
+ messages: readonly ThreadMessage[];
381
+ isRunning: boolean;
382
+ getBranches: (messageId: string) => readonly string[];
383
+ switchToBranch: (branchId: string) => void;
384
+ append: (message: AppendMessage) => void;
385
+ startRun: (parentId: string | null) => void;
386
+ cancelRun: () => void;
387
+ };
388
+
465
389
  type ComposerState = BaseComposerState & Readonly<{
466
390
  isEditing: true;
467
391
  send: () => void;
@@ -498,4 +422,87 @@ type ContentPartContextValue = {
498
422
  };
499
423
  declare const useContentPartContext: () => ContentPartContextValue;
500
424
 
501
- export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantMessage, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, type ThreadMessage, index$5 as ThreadPrimitive, type UserContentPart, type UserMessage, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, type VercelRSCAdapter, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, getVercelAIMessage, getVercelRSCMessage, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, type ComposerContextValue as unstable_ComposerContextValue, type ComposerState as unstable_ComposerState, type ContentPartContextValue as unstable_ContentPartContextValue, type ContentPartState as unstable_ContentPartState, type EditComposerState as unstable_EditComposerState, type ImageContentPart as unstable_ImageContentPart, type MessageContextValue as unstable_MessageContextValue, type MessageState as unstable_MessageState, type ThreadContextValue as unstable_ThreadContextValue, type ThreadState as unstable_ThreadState, type ThreadViewportState as unstable_ThreadViewportState, type ToolCallContentPart as unstable_ToolCallContentPart, type UIContentPart as unstable_UIContentPart, VercelModelAdapter as unstable_VercelModelAdapter, useComposerContext as unstable_useComposerContext, useContentPartContext as unstable_useContentPartContext, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useThreadContext as unstable_useThreadContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage, useVercelRSCRuntime, useVercelUseAssistantRuntime, useVercelUseChatRuntime };
425
+ type Unsubscribe = () => void;
426
+ type ThreadRuntime = Readonly<ThreadState & {
427
+ subscribe: (callback: () => void) => Unsubscribe;
428
+ }>;
429
+
430
+ type AssistantRuntime = ThreadRuntime;
431
+
432
+ type ReactThreadRuntime = ThreadRuntime & {
433
+ unstable_synchronizer?: ComponentType;
434
+ };
435
+
436
+ declare class MessageRepository {
437
+ private messages;
438
+ private head;
439
+ private root;
440
+ private performOp;
441
+ getMessages(): ThreadMessage[];
442
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
443
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
444
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
445
+ getBranches(messageId: string): string[];
446
+ switchToBranch(messageId: string): void;
447
+ resetHead(messageId: string | null): void;
448
+ }
449
+
450
+ /**
451
+ * @deprecated Will be removed in 0.1.0.
452
+ */
453
+ type VercelAIAssistantProviderProps = PropsWithChildren<{
454
+ chat: UseChatHelpers;
455
+ } | {
456
+ assistant: UseAssistantHelpers;
457
+ }>;
458
+ /**
459
+ * @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
460
+ */
461
+ declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
462
+
463
+ /**
464
+ * @deprecated Will be removed in 0.1.0.
465
+ */
466
+ type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
467
+ /**
468
+ * @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
469
+ */
470
+ declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
471
+
472
+ type ChatModelRunResult = {
473
+ content: AssistantContentPart[];
474
+ };
475
+ type ChatModelRunOptions = {
476
+ messages: ThreadMessage[];
477
+ abortSignal: AbortSignal;
478
+ onUpdate: (result: ChatModelRunResult) => void;
479
+ };
480
+ type ChatModelAdapter = {
481
+ run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
482
+ };
483
+
484
+ declare class LocalRuntime implements AssistantRuntime {
485
+ adapter: ChatModelAdapter;
486
+ private _subscriptions;
487
+ private abortController;
488
+ private repository;
489
+ get messages(): ThreadMessage[];
490
+ get isRunning(): boolean;
491
+ constructor(adapter: ChatModelAdapter);
492
+ getBranches(messageId: string): string[];
493
+ switchToBranch(branchId: string): void;
494
+ append(message: AppendMessage): Promise<void>;
495
+ startRun(parentId: string | null): Promise<void>;
496
+ cancelRun(): void;
497
+ private notifySubscribers;
498
+ subscribe(callback: () => void): Unsubscribe;
499
+ }
500
+
501
+ declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
502
+
503
+ type AssistantRuntimeProviderProps = {
504
+ runtime: AssistantRuntime;
505
+ };
506
+ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
507
+
508
+ export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantMessage, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type ReactThreadRuntime, type TextContentPart, type ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, type UserContentPart, type UserMessage, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, type VercelRSCAdapter, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, getVercelAIMessage, getVercelRSCMessage, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, type ComposerContextValue as unstable_ComposerContextValue, type ComposerState as unstable_ComposerState, type ContentPartContextValue as unstable_ContentPartContextValue, type ContentPartState as unstable_ContentPartState, type EditComposerState as unstable_EditComposerState, type ImageContentPart as unstable_ImageContentPart, type MessageContextValue as unstable_MessageContextValue, MessageRepository as unstable_MessageRepository, type MessageState as unstable_MessageState, type ThreadContextValue as unstable_ThreadContextValue, type ThreadState as unstable_ThreadState, type ThreadViewportState as unstable_ThreadViewportState, type ToolCallContentPart as unstable_ToolCallContentPart, type UIContentPart as unstable_UIContentPart, useComposerContext as unstable_useComposerContext, useContentPartContext as unstable_useContentPartContext, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useThreadContext as unstable_useThreadContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage, useVercelRSCRuntime, useVercelUseAssistantRuntime, useVercelUseChatRuntime };
package/dist/index.d.ts CHANGED
@@ -2,9 +2,9 @@ import * as react from 'react';
2
2
  import { FC, ReactNode, PropsWithChildren, ComponentType } from 'react';
3
3
  import { TextareaAutosizeProps } from 'react-textarea-autosize';
4
4
  import { UseChatHelpers, UseAssistantHelpers } from '@ai-sdk/react';
5
- import { Message, LanguageModel } from 'ai';
6
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
6
  import { UseBoundStore, StoreApi } from 'zustand';
7
+ import { Message } from 'ai';
8
8
 
9
9
  declare const useCopyMessage: ({ copiedDuration }: {
10
10
  copiedDuration?: number | undefined;
@@ -294,26 +294,6 @@ type VercelRSCAdapterBase<T> = {
294
294
  };
295
295
  type VercelRSCAdapter<T = VercelRSCMessage> = VercelRSCAdapterBase<T> & (T extends VercelRSCMessage ? object : RSCMessageConverter<T>);
296
296
 
297
- type ThreadState = {
298
- messages: ThreadMessage[];
299
- isRunning: boolean;
300
- getBranches: (messageId: string) => readonly string[];
301
- switchToBranch: (branchId: string) => void;
302
- append: (message: AppendMessage) => void;
303
- startRun: (parentId: string | null) => void;
304
- cancelRun: () => void;
305
- };
306
-
307
- type Unsubscribe = () => void;
308
- type ThreadRuntime = Readonly<ThreadState> & {
309
- subscribe: (callback: () => void) => Unsubscribe;
310
- };
311
- type ReactThreadRuntime = Readonly<ThreadState> & {
312
- unstable_synchronizer?: ComponentType;
313
- };
314
-
315
- type AssistantRuntime = ThreadRuntime;
316
-
317
297
  declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements AssistantRuntime, ReactThreadRuntime {
318
298
  adapter: VercelRSCAdapter<T>;
319
299
  private useAdapter;
@@ -327,7 +307,7 @@ declare class VercelRSCRuntime<T extends WeakKey = VercelRSCMessage> implements
327
307
  append(message: AppendMessage): Promise<void>;
328
308
  startRun(parentId: string | null): Promise<void>;
329
309
  cancelRun(): void;
330
- subscribe(callback: () => void): Unsubscribe;
310
+ subscribe(callback: () => void): () => void;
331
311
  onAdapterUpdated(): void;
332
312
  private updateData;
333
313
  unstable_synchronizer: () => null;
@@ -353,7 +333,7 @@ declare class VercelAIRuntime implements AssistantRuntime, ReactThreadRuntime {
353
333
  append(message: AppendMessage): Promise<void>;
354
334
  startRun(parentId: string | null): Promise<void>;
355
335
  cancelRun(): void;
356
- subscribe(callback: () => void): Unsubscribe;
336
+ subscribe(callback: () => void): () => void;
357
337
  private updateVercelMessages;
358
338
  onVercelUpdated(): void;
359
339
  private updateData;
@@ -366,72 +346,6 @@ declare const useVercelUseAssistantRuntime: (assistantHelpers: UseAssistantHelpe
366
346
 
367
347
  declare const getVercelAIMessage: (message: ThreadMessage) => Message[] | undefined;
368
348
 
369
- /**
370
- * @deprecated Will be removed in 0.1.0.
371
- */
372
- type VercelAIAssistantProviderProps = PropsWithChildren<{
373
- chat: UseChatHelpers;
374
- } | {
375
- assistant: UseAssistantHelpers;
376
- }>;
377
- /**
378
- * @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
379
- */
380
- declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
381
-
382
- /**
383
- * @deprecated Will be removed in 0.1.0.
384
- */
385
- type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
386
- /**
387
- * @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
388
- */
389
- declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
390
-
391
- type ChatModelRunResult = {
392
- content: AssistantContentPart[];
393
- };
394
- type ChatModelRunOptions = {
395
- messages: ThreadMessage[];
396
- abortSignal: AbortSignal;
397
- onUpdate: (result: ChatModelRunResult) => void;
398
- };
399
- type ChatModelAdapter = {
400
- run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
401
- };
402
-
403
- declare class LocalRuntime implements AssistantRuntime {
404
- adapter: ChatModelAdapter;
405
- private _subscriptions;
406
- private abortController;
407
- private repository;
408
- get messages(): ThreadMessage[];
409
- get isRunning(): boolean;
410
- constructor(adapter: ChatModelAdapter);
411
- getBranches(messageId: string): string[];
412
- switchToBranch(branchId: string): void;
413
- append(message: AppendMessage): Promise<void>;
414
- startRun(parentId: string | null): Promise<void>;
415
- cancelRun(): void;
416
- private notifySubscribers;
417
- subscribe(callback: () => void): Unsubscribe;
418
- }
419
-
420
- declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
421
-
422
- declare class VercelModelAdapter implements ChatModelAdapter {
423
- private readonly model;
424
- constructor(model: LanguageModel);
425
- run({ messages, abortSignal, onUpdate }: ChatModelRunOptions): Promise<{
426
- content: AssistantContentPart[];
427
- }>;
428
- }
429
-
430
- type AssistantRuntimeProviderProps = {
431
- runtime: AssistantRuntime;
432
- };
433
- declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
434
-
435
349
  type ContentPartState = Readonly<{
436
350
  status: "in_progress" | "done" | "error";
437
351
  part: ThreadMessage["content"][number];
@@ -462,6 +376,16 @@ type EditComposerState = BaseComposerState & Readonly<{
462
376
  cancel: () => boolean;
463
377
  }>;
464
378
 
379
+ type ThreadState = {
380
+ messages: readonly ThreadMessage[];
381
+ isRunning: boolean;
382
+ getBranches: (messageId: string) => readonly string[];
383
+ switchToBranch: (branchId: string) => void;
384
+ append: (message: AppendMessage) => void;
385
+ startRun: (parentId: string | null) => void;
386
+ cancelRun: () => void;
387
+ };
388
+
465
389
  type ComposerState = BaseComposerState & Readonly<{
466
390
  isEditing: true;
467
391
  send: () => void;
@@ -498,4 +422,87 @@ type ContentPartContextValue = {
498
422
  };
499
423
  declare const useContentPartContext: () => ContentPartContextValue;
500
424
 
501
- export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantMessage, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type TextContentPart, type ThreadMessage, index$5 as ThreadPrimitive, type UserContentPart, type UserMessage, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, type VercelRSCAdapter, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, getVercelAIMessage, getVercelRSCMessage, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, type ComposerContextValue as unstable_ComposerContextValue, type ComposerState as unstable_ComposerState, type ContentPartContextValue as unstable_ContentPartContextValue, type ContentPartState as unstable_ContentPartState, type EditComposerState as unstable_EditComposerState, type ImageContentPart as unstable_ImageContentPart, type MessageContextValue as unstable_MessageContextValue, type MessageState as unstable_MessageState, type ThreadContextValue as unstable_ThreadContextValue, type ThreadState as unstable_ThreadState, type ThreadViewportState as unstable_ThreadViewportState, type ToolCallContentPart as unstable_ToolCallContentPart, type UIContentPart as unstable_UIContentPart, VercelModelAdapter as unstable_VercelModelAdapter, useComposerContext as unstable_useComposerContext, useContentPartContext as unstable_useContentPartContext, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useThreadContext as unstable_useThreadContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage, useVercelRSCRuntime, useVercelUseAssistantRuntime, useVercelUseChatRuntime };
425
+ type Unsubscribe = () => void;
426
+ type ThreadRuntime = Readonly<ThreadState & {
427
+ subscribe: (callback: () => void) => Unsubscribe;
428
+ }>;
429
+
430
+ type AssistantRuntime = ThreadRuntime;
431
+
432
+ type ReactThreadRuntime = ThreadRuntime & {
433
+ unstable_synchronizer?: ComponentType;
434
+ };
435
+
436
+ declare class MessageRepository {
437
+ private messages;
438
+ private head;
439
+ private root;
440
+ private performOp;
441
+ getMessages(): ThreadMessage[];
442
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
443
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
444
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
445
+ getBranches(messageId: string): string[];
446
+ switchToBranch(messageId: string): void;
447
+ resetHead(messageId: string | null): void;
448
+ }
449
+
450
+ /**
451
+ * @deprecated Will be removed in 0.1.0.
452
+ */
453
+ type VercelAIAssistantProviderProps = PropsWithChildren<{
454
+ chat: UseChatHelpers;
455
+ } | {
456
+ assistant: UseAssistantHelpers;
457
+ }>;
458
+ /**
459
+ * @deprecated `const runtime = useVercelUseChatRuntime(chat)` and `<AssistantRuntimeProvider runtime={...} />`. Will be removed in 0.1.0.
460
+ */
461
+ declare const VercelAIAssistantProvider: FC<VercelAIAssistantProviderProps>;
462
+
463
+ /**
464
+ * @deprecated Will be removed in 0.1.0.
465
+ */
466
+ type VercelRSCAssistantProviderProps<T> = PropsWithChildren<VercelRSCAdapter<T>>;
467
+ /**
468
+ * @deprecated Replaced with `const runtime = useVercelRSCRuntime({ messages, append })` and `<AssistantRuntimeProvider runtime={runtime} />`. Will be removed in 0.1.0.
469
+ */
470
+ declare const VercelRSCAssistantProvider: <T extends WeakKey = VercelRSCMessage>({ children, ...adapter }: VercelRSCAssistantProviderProps<T>) => react_jsx_runtime.JSX.Element;
471
+
472
+ type ChatModelRunResult = {
473
+ content: AssistantContentPart[];
474
+ };
475
+ type ChatModelRunOptions = {
476
+ messages: ThreadMessage[];
477
+ abortSignal: AbortSignal;
478
+ onUpdate: (result: ChatModelRunResult) => void;
479
+ };
480
+ type ChatModelAdapter = {
481
+ run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult>;
482
+ };
483
+
484
+ declare class LocalRuntime implements AssistantRuntime {
485
+ adapter: ChatModelAdapter;
486
+ private _subscriptions;
487
+ private abortController;
488
+ private repository;
489
+ get messages(): ThreadMessage[];
490
+ get isRunning(): boolean;
491
+ constructor(adapter: ChatModelAdapter);
492
+ getBranches(messageId: string): string[];
493
+ switchToBranch(branchId: string): void;
494
+ append(message: AppendMessage): Promise<void>;
495
+ startRun(parentId: string | null): Promise<void>;
496
+ cancelRun(): void;
497
+ private notifySubscribers;
498
+ subscribe(callback: () => void): Unsubscribe;
499
+ }
500
+
501
+ declare const useLocalRuntime: (adapter: ChatModelAdapter) => LocalRuntime;
502
+
503
+ type AssistantRuntimeProviderProps = {
504
+ runtime: AssistantRuntime;
505
+ };
506
+ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
507
+
508
+ export { index$1 as ActionBarPrimitive, type AppendContentPart, type AppendMessage, type AssistantContentPart, type AssistantMessage, type AssistantRuntime, AssistantRuntimeProvider, index$2 as BranchPickerPrimitive, index$4 as ComposerPrimitive, index as ContentPartPrimitive, index$3 as MessagePrimitive, type VercelRSCMessage as RSCMessage, type ReactThreadRuntime, type TextContentPart, type ThreadMessage, index$5 as ThreadPrimitive, type ThreadRuntime, type UserContentPart, type UserMessage, VercelAIAssistantProvider, type VercelAIAssistantProviderProps, type VercelRSCAdapter, VercelRSCAssistantProvider, type VercelRSCAssistantProviderProps, type VercelRSCMessage, getVercelAIMessage, getVercelRSCMessage, type ChatModelAdapter as unstable_ChatModelAdapter, type ChatModelRunOptions as unstable_ChatModelRunOptions, type ComposerContextValue as unstable_ComposerContextValue, type ComposerState as unstable_ComposerState, type ContentPartContextValue as unstable_ContentPartContextValue, type ContentPartState as unstable_ContentPartState, type EditComposerState as unstable_EditComposerState, type ImageContentPart as unstable_ImageContentPart, type MessageContextValue as unstable_MessageContextValue, MessageRepository as unstable_MessageRepository, type MessageState as unstable_MessageState, type ThreadContextValue as unstable_ThreadContextValue, type ThreadState as unstable_ThreadState, type ThreadViewportState as unstable_ThreadViewportState, type ToolCallContentPart as unstable_ToolCallContentPart, type UIContentPart as unstable_UIContentPart, useComposerContext as unstable_useComposerContext, useContentPartContext as unstable_useContentPartContext, useLocalRuntime as unstable_useLocalRuntime, useMessageContext as unstable_useMessageContext, useThreadContext as unstable_useThreadContext, useBeginMessageEdit, useCopyMessage, useGoToNextBranch, useGoToPreviousBranch, useReloadMessage, useVercelRSCRuntime, useVercelUseAssistantRuntime, useVercelUseChatRuntime };