@assistant-ui/react 0.5.65 → 0.5.67

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ContentPartStatus, T as TextContentPart, I as ImageContentPart, U as UIContentPart, a as ToolCallContentPart, b as ToolCallContentPartStatus, c as ThreadMessage, d as CoreMessage, e as ThreadComposerAttachment, A as AppendMessage, M as ModelConfig, f as ModelConfigProvider, g as ThreadAssistantContentPart, h as MessageStatus, i as ThreadRoundtrip, j as MessageAttachment, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions, n as ThreadUserContentPart } from './edge-D7ch2oPK.mjs';
2
- export { s as CoreAssistantContentPart, v as CoreAssistantMessage, t as CoreSystemMessage, r as CoreUserContentPart, u as CoreUserMessage, E as EdgeRuntimeRequestOptions, p as ThreadAssistantMessage, o as ThreadSystemMessage, q as ThreadUserMessage } from './edge-D7ch2oPK.mjs';
1
+ import { T as ThreadComposerAttachment, a as ThreadMessage, C as CoreMessage, A as AppendMessage, M as ModelConfig, b as ModelConfigProvider, c as ThreadAssistantContentPart, d as MessageStatus, e as ThreadRoundtrip, f as MessageAttachment, g as Tool, h as TextContentPart, I as ImageContentPart, i as ToolCallContentPart, j as CoreToolCallContentPart, U as UIContentPart, k as CreateEdgeRuntimeAPIOptions, l as ThreadUserContentPart, m as ContentPartStatus, n as ToolCallContentPartStatus } from './edge-BDAlTCC1.mjs';
2
+ export { s as CoreAssistantContentPart, v as CoreAssistantMessage, t as CoreSystemMessage, r as CoreUserContentPart, u as CoreUserMessage, E as EdgeRuntimeRequestOptions, p as ThreadAssistantMessage, o as ThreadSystemMessage, q as ThreadUserMessage } from './edge-BDAlTCC1.mjs';
3
3
  import * as react from 'react';
4
4
  import { ComponentType, PropsWithChildren, FC, ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
5
5
  import { StoreApi, UseBoundStore } from 'zustand';
@@ -14,53 +14,27 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
14
14
  import 'json-schema';
15
15
  import 'zod';
16
16
 
17
- type EmptyContentPartProps = {
18
- status: ContentPartStatus;
19
- };
20
- type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
21
- type TextContentPartProps = {
22
- part: TextContentPart;
23
- status: ContentPartStatus;
24
- };
25
- type TextContentPartComponent = ComponentType<TextContentPartProps>;
26
- type ImageContentPartProps = {
27
- part: ImageContentPart;
28
- status: ContentPartStatus;
29
- };
30
- type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
31
- type UIContentPartProps = {
32
- part: UIContentPart;
33
- status: ContentPartStatus;
34
- };
35
- type UIContentPartComponent = ComponentType<UIContentPartProps>;
36
- type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
37
- part: ToolCallContentPart<TArgs, TResult>;
38
- status: ToolCallContentPartStatus;
39
- addResult: (result: any) => void;
40
- };
41
- type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
17
+ type ComposerRuntimeCore = Readonly<{
18
+ attachmentAccept: string;
19
+ attachments: readonly ThreadComposerAttachment[];
20
+ addAttachment: (file: File) => Promise<void>;
21
+ removeAttachment: (attachmentId: string) => Promise<void>;
22
+ isEditing: boolean;
23
+ canCancel: boolean;
24
+ isEmpty: boolean;
25
+ text: string;
26
+ setText: (value: string) => void;
27
+ /**
28
+ * @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
29
+ */
30
+ reset: () => void;
31
+ send: () => void;
32
+ cancel: () => void;
33
+ subscribe: (callback: () => void) => Unsubscribe;
34
+ }>;
42
35
 
43
36
  type Unsubscribe = () => void;
44
37
 
45
- type ReadonlyStore<T> = Omit<StoreApi<T>, "setState" | "destroy">;
46
-
47
- type ThreadState$1 = Readonly<{
48
- capabilities: Readonly<RuntimeCapabilities>;
49
- threadId: string;
50
- isRunning: boolean;
51
- isDisabled: boolean;
52
- }>;
53
- type RuntimeCapabilities = {
54
- switchToBranch: boolean;
55
- edit: boolean;
56
- reload: boolean;
57
- cancel: boolean;
58
- unstable_copy: boolean;
59
- speak: boolean;
60
- attachments: boolean;
61
- feedback: boolean;
62
- };
63
-
64
38
  declare namespace SpeechSynthesisAdapter {
65
39
  type Status = {
66
40
  type: "starting" | "running";
@@ -110,19 +84,16 @@ declare class MessageRepository {
110
84
  import({ headId, messages }: ExportedMessageRepository): void;
111
85
  }
112
86
 
113
- type ThreadComposerRuntimeCore = Readonly<{
114
- attachmentAccept: string;
115
- attachments: ThreadComposerAttachment[];
116
- addAttachment: (file: File) => Promise<void>;
117
- removeAttachment: (attachmentId: string) => Promise<void>;
118
- isEmpty: boolean;
119
- text: string;
120
- setText: (value: string) => void;
121
- reset: () => void;
122
- send: () => void;
123
- subscribe: (callback: () => void) => Unsubscribe;
87
+ type RuntimeCapabilities = Readonly<{
88
+ switchToBranch: boolean;
89
+ edit: boolean;
90
+ reload: boolean;
91
+ cancel: boolean;
92
+ unstable_copy: boolean;
93
+ speak: boolean;
94
+ attachments: boolean;
95
+ feedback: boolean;
124
96
  }>;
125
-
126
97
  type AddToolResultOptions = {
127
98
  messageId: string;
128
99
  toolName: string;
@@ -143,7 +114,9 @@ type ThreadRuntimeCore = Readonly<{
143
114
  speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
144
115
  submitFeedback: (feedback: SubmitFeedbackOptions) => void;
145
116
  getModelConfig: () => ModelConfig;
146
- composer: ThreadComposerRuntimeCore;
117
+ composer: ComposerRuntimeCore;
118
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
119
+ beginEdit: (messageId: string) => void;
147
120
  capabilities: Readonly<RuntimeCapabilities>;
148
121
  threadId: string;
149
122
  isDisabled: boolean;
@@ -221,30 +194,69 @@ type AttachmentAdapter = {
221
194
  send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
222
195
  };
223
196
 
224
- declare class BaseThreadComposerRuntimeCore implements ThreadComposerRuntimeCore {
225
- private runtime;
226
- private _attachmentAdapter?;
197
+ declare class SimpleImageAttachmentAdapter implements AttachmentAdapter {
198
+ accept: string;
199
+ add(state: {
200
+ file: File;
201
+ }): Promise<ThreadComposerAttachment>;
202
+ send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
203
+ remove(): Promise<void>;
204
+ }
205
+
206
+ declare class SimpleTextAttachmentAdapter implements AttachmentAdapter {
207
+ accept: string;
208
+ add(state: {
209
+ file: File;
210
+ }): Promise<ThreadComposerAttachment>;
211
+ send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
212
+ remove(): Promise<void>;
213
+ }
214
+
215
+ declare class CompositeAttachmentAdapter implements AttachmentAdapter {
216
+ private _adapters;
217
+ accept: string;
218
+ constructor(adapters: AttachmentAdapter[]);
219
+ add(state: {
220
+ file: File;
221
+ }): Promise<ThreadComposerAttachment>;
222
+ send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
223
+ remove(attachment: ThreadComposerAttachment): Promise<void>;
224
+ }
225
+
226
+ declare abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
227
+ readonly isEditing = true;
227
228
  attachmentAccept: string;
228
- get isEmpty(): boolean;
229
- constructor(runtime: {
230
- messages: ThreadRuntimeCore["messages"];
231
- append: (message: AppendMessage) => void;
232
- });
233
- setAttachmentAdapter(adapter: AttachmentAdapter | undefined): boolean;
234
229
  private _attachments;
235
- get attachments(): ThreadComposerAttachment[];
236
- addAttachment(file: File): Promise<void>;
237
- removeAttachment(attachmentId: string): Promise<void>;
230
+ protected set attachments(value: readonly ThreadComposerAttachment[]);
231
+ get attachments(): readonly ThreadComposerAttachment[];
232
+ abstract get canCancel(): boolean;
233
+ get isEmpty(): boolean;
238
234
  private _text;
239
235
  get text(): string;
240
236
  setText(value: string): void;
241
237
  reset(): void;
242
238
  send(): Promise<void>;
239
+ abstract handleSend(message: Omit<AppendMessage, "parentId">): void;
240
+ abstract cancel(): void;
241
+ protected _attachmentAdapter?: AttachmentAdapter | undefined;
242
+ setAttachmentAdapter(adapter: AttachmentAdapter | undefined): void;
243
+ addAttachment(file: File): Promise<void>;
244
+ removeAttachment(attachmentId: string): Promise<void>;
243
245
  private _subscriptions;
244
- private notifySubscribers;
246
+ protected notifySubscribers(): void;
245
247
  subscribe(callback: () => void): Unsubscribe;
246
248
  }
247
249
 
250
+ declare class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore {
251
+ private runtime;
252
+ private _canCancel;
253
+ get canCancel(): boolean;
254
+ constructor(runtime: Omit<ThreadRuntimeCore, "composer">);
255
+ connect(): Unsubscribe;
256
+ handleSend(message: Omit<AppendMessage, "parentId">): Promise<void>;
257
+ cancel(): Promise<void>;
258
+ }
259
+
248
260
  type FeedbackAdapterFeedback = {
249
261
  message: ThreadMessage;
250
262
  type: "positive" | "negative";
@@ -263,6 +275,21 @@ type LocalRuntimeOptions = {
263
275
  } | undefined;
264
276
  };
265
277
 
278
+ declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
279
+ private runtime;
280
+ private endEditCallback;
281
+ get canCancel(): boolean;
282
+ private _nonTextParts;
283
+ private _previousText;
284
+ private _parentId;
285
+ constructor(runtime: Omit<ThreadRuntimeCore, "composer">, endEditCallback: () => void, { parentId, message }: {
286
+ parentId: string | null;
287
+ message: ThreadMessage;
288
+ });
289
+ handleSend(message: Omit<AppendMessage, "parentId">): Promise<void>;
290
+ cancel(): Promise<void>;
291
+ }
292
+
266
293
  declare class LocalThreadRuntimeCore implements ThreadRuntimeCore {
267
294
  private configProvider;
268
295
  adapter: ChatModelAdapter;
@@ -282,12 +309,15 @@ declare class LocalThreadRuntimeCore implements ThreadRuntimeCore {
282
309
  readonly threadId: string;
283
310
  readonly isDisabled = false;
284
311
  get messages(): ThreadMessage[];
285
- readonly composer: BaseThreadComposerRuntimeCore;
312
+ readonly composer: DefaultThreadComposerRuntimeCore;
286
313
  constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
287
314
  getModelConfig(): ModelConfig;
288
315
  private _options;
289
316
  get options(): LocalRuntimeOptions;
290
317
  set options({ initialMessages, ...options }: LocalRuntimeOptions);
318
+ private _editComposers;
319
+ getEditComposer(messageId: string): DefaultEditComposerRuntimeCore | undefined;
320
+ beginEdit(messageId: string): void;
291
321
  getBranches(messageId: string): string[];
292
322
  switchToBranch(branchId: string): void;
293
323
  append(message: AppendMessage): Promise<void>;
@@ -315,6 +345,23 @@ declare class LocalRuntimeCore extends BaseAssistantRuntimeCore<LocalThreadRunti
315
345
  }): void;
316
346
  }
317
347
 
348
+ declare class AssistantRuntime<TThreadRuntime extends ThreadRuntime = ThreadRuntime> implements AssistantRuntimeCore {
349
+ private _core;
350
+ constructor(_core: AssistantRuntimeCore, CustomThreadRuntime: new (binding: ThreadRuntimeCoreBinding) => TThreadRuntime);
351
+ readonly thread: TThreadRuntime;
352
+ switchToNewThread(): void;
353
+ switchToThread(threadId: string): void;
354
+ /**
355
+ * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
356
+ */
357
+ switchToThread(threadId: string | null): void;
358
+ registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
359
+ /**
360
+ * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
361
+ */
362
+ subscribe(callback: () => void): Unsubscribe;
363
+ }
364
+
318
365
  declare class LocalRuntime extends AssistantRuntime {
319
366
  private core;
320
367
  constructor(core: LocalRuntimeCore);
@@ -381,35 +428,6 @@ declare class EdgeChatAdapter implements ChatModelAdapter {
381
428
  type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
382
429
  declare const useEdgeRuntime: ({ initialMessages, maxToolRoundtrips, adapters, ...options }: EdgeRuntimeOptions) => LocalRuntime;
383
430
 
384
- declare class SimpleImageAttachmentAdapter implements AttachmentAdapter {
385
- accept: string;
386
- add(state: {
387
- file: File;
388
- }): Promise<ThreadComposerAttachment>;
389
- send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
390
- remove(): Promise<void>;
391
- }
392
-
393
- declare class SimpleTextAttachmentAdapter implements AttachmentAdapter {
394
- accept: string;
395
- add(state: {
396
- file: File;
397
- }): Promise<ThreadComposerAttachment>;
398
- send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
399
- remove(): Promise<void>;
400
- }
401
-
402
- declare class CompositeAttachmentAdapter implements AttachmentAdapter {
403
- private _adapters;
404
- accept: string;
405
- constructor(adapters: AttachmentAdapter[]);
406
- add(state: {
407
- file: File;
408
- }): Promise<ThreadComposerAttachment>;
409
- send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
410
- remove(attachment: ThreadComposerAttachment): Promise<void>;
411
- }
412
-
413
431
  type ThreadMessageLike = {
414
432
  role: "assistant" | "user" | "system";
415
433
  content: string | (TextContentPart | ImageContentPart | ToolCallContentPart<any, any> | CoreToolCallContentPart<any, any> | UIContentPart)[];
@@ -479,74 +497,95 @@ type SubscribableWithState<TState> = Subscribable & {
479
497
  getState: () => TState;
480
498
  };
481
499
 
482
- type ContentPartSnapshot = {
483
- part: ThreadUserContentPart | ThreadAssistantContentPart;
484
- status: ContentPartStatus | ToolCallContentPartStatus;
485
- };
486
- type ContentPartSnapshotBinding = SubscribableWithState<ContentPartSnapshot | undefined>;
487
- declare class ContentPartRuntime {
488
- private contentBinding;
489
- private messageApi;
490
- private threadApi;
491
- constructor(contentBinding: ContentPartSnapshotBinding, messageApi: MessageSnapshotBinding, threadApi: ThreadRuntimeCoreBinding);
492
- getState(): ContentPartSnapshot | undefined;
493
- addToolResult(result: any): void;
494
- }
495
-
496
- type MessageSnapshot = {
497
- message: ThreadMessage;
498
- parentId: string | null;
499
- isLast: boolean;
500
+ type ThreadComposerRuntimeCoreBinding = SubscribableWithState<ComposerRuntimeCore | undefined>;
501
+ type LegacyEditComposerState = Readonly<{
502
+ type: "edit" | "thread";
503
+ /** @deprecated Use `text` instead. This will be removed in 0.6.0. */
504
+ value: string;
505
+ /** @deprecated Use `useComposerRuntime().setText()` instead. This will be removed in 0.6.0. */
506
+ setValue: (value: string) => void;
507
+ text: string;
500
508
  /**
501
- * @deprecated Use `branchNumber` and `branchCount` instead. This will be removed in 0.6.0.
509
+ * @deprecated Use `useComposerRuntime().setText()` instead. This will be removed in 0.6.0.
502
510
  */
503
- branches: readonly string[];
504
- branchNumber: number;
505
- branchCount: number;
506
- };
507
- type MessageSnapshotBinding = SubscribableWithState<MessageSnapshot>;
508
- type MessageState$1 = ThreadMessage & MessageSnapshot & {
511
+ setText: (value: string) => void;
512
+ canCancel: boolean;
513
+ isEditing: boolean;
514
+ isEmpty: boolean;
509
515
  /**
510
- * @deprecated You can directly access message fields in the state. Replace `.message.content` with `.content` etc. This will be removed in 0.6.0.
516
+ * @deprecated Use useComposerRuntime().beginEdit() instead. This will be removed in 0.6.0.
511
517
  */
512
- message: ThreadMessage;
513
- };
514
- declare const MessageState$1: new (snapshot: MessageSnapshot) => MessageState$1;
515
- declare class MessageRuntime {
516
- private _core;
517
- private _threadBinding;
518
- constructor(_core: MessageSnapshotBinding, _threadBinding: ThreadRuntimeCoreBinding);
519
- getState(): MessageState$1;
520
- edit(message: Omit<AppendMessage, "parentId">): void;
521
- reload(): void;
522
- speak(): void;
523
- submitFeedback({ type }: {
524
- type: "positive" | "negative";
525
- }): void;
526
- switchToBranch({ position, branchId, }: {
527
- position?: "previous" | "next" | undefined;
528
- branchId?: string | undefined;
529
- }): void;
530
- subscribe(callback: () => void): Unsubscribe;
531
- getContentPartByIdx(idx: number): ContentPartRuntime;
532
- }
533
-
534
- type ThreadComposerRuntimeCoreBinding = SubscribableWithState<ThreadComposerRuntimeCore>;
535
- declare class ComposerState {
536
- private _composerBinding;
537
- constructor(_composerBinding: ThreadComposerRuntimeCoreBinding);
538
- get isEmpty(): boolean;
539
- get text(): string;
540
- get attachmentAccept(): string;
541
- get attachments(): ThreadComposerAttachment[];
542
- }
543
- declare class ThreadComposerRuntime implements ThreadComposerRuntimeCore {
518
+ edit: () => void;
519
+ /**
520
+ * @deprecated Use `useComposerRuntime().send()` instead. This will be removed in 0.6.0.
521
+ */
522
+ send: () => void;
523
+ /**
524
+ * @deprecated Use `useComposerRuntime().cancel()` instead. This will be removed in 0.6.0.
525
+ */
526
+ cancel: () => void;
527
+ }>;
528
+ type LegacyThreadComposerState = Readonly<{
529
+ type: "thread" | "edit";
530
+ /** @deprecated Use `text` instead. This will be removed in 0.6.0. */
531
+ value: string;
532
+ /** @deprecated Use `useComposerRuntime().setText` instead. This will be removed in 0.6.0. */
533
+ setValue: (value: string) => void;
534
+ attachmentAccept: string;
535
+ attachments: readonly ThreadComposerAttachment[];
536
+ /** @deprecated Use `useComposerRuntime().addAttachment` instead. This will be removed in 0.6.0. */
537
+ addAttachment: (file: File) => void;
538
+ /** @deprecated Use `useComposerRuntime().removeAttachment` instead. This will be removed in 0.6.0. */
539
+ removeAttachment: (attachmentId: string) => void;
540
+ text: string;
541
+ /** @deprecated Use `useComposerRuntime().setText` instead. This will be removed in 0.6.0. */
542
+ setText: (value: string) => void;
543
+ /** @deprecated Use `useComposerRuntime().reset` instead. This will be removed in 0.6.0. */
544
+ reset: () => void;
545
+ canCancel: boolean;
546
+ isEditing: boolean;
547
+ isEmpty: boolean;
548
+ /**
549
+ * @deprecated Use `useComposerRuntime().send` instead. This will be removed in 0.6.0.
550
+ **/
551
+ send: () => void;
552
+ /** @deprecated Use `useComposerRuntime().cancel` instead. This will be removed in 0.6.0. */
553
+ cancel: () => void;
554
+ /** @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it. */
555
+ focus: () => void;
556
+ /** @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it. */
557
+ onFocus: (listener: () => void) => Unsubscribe;
558
+ }>;
559
+ type ComposerState = LegacyThreadComposerState & LegacyEditComposerState & Readonly<{
560
+ type: "thread" | "edit";
561
+ text: string;
562
+ attachmentAccept: string;
563
+ attachments: readonly ThreadComposerAttachment[];
564
+ canCancel: boolean;
565
+ isEditing: boolean;
566
+ isEmpty: boolean;
567
+ }>;
568
+ /** @deprecated Use `ComposerState` instead. */
569
+ type ThreadComposerState = ComposerState;
570
+ /** @deprecated Use `ComposerState` instead. */
571
+ type EditComposerState = ComposerState;
572
+ declare class ComposerRuntime implements ComposerRuntimeCore {
544
573
  private _core;
545
- constructor(_core: ThreadComposerRuntimeCoreBinding);
574
+ private _beginEdit?;
575
+ get type(): "edit" | "thread";
576
+ constructor(_core: ThreadComposerRuntimeCoreBinding, _beginEdit?: (() => void) | undefined);
577
+ /**
578
+ * @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0.
579
+ */
580
+ get isEditing(): boolean;
546
581
  /**
547
582
  * @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
548
583
  */
549
584
  get isEmpty(): boolean;
585
+ /**
586
+ * @deprecated Use `getState().canCancel` instead. This will be removed in 0.6.0.
587
+ */
588
+ get canCancel(): boolean;
550
589
  /**
551
590
  * @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
552
591
  */
@@ -558,10 +597,14 @@ declare class ThreadComposerRuntime implements ThreadComposerRuntimeCore {
558
597
  /**
559
598
  * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
560
599
  */
561
- get attachments(): ThreadComposerAttachment[];
562
- private _state;
600
+ get attachments(): readonly ThreadComposerAttachment[];
601
+ /**
602
+ * @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
603
+ */
604
+ get value(): string;
563
605
  getState(): ComposerState;
564
606
  setText(text: string): void;
607
+ setValue(text: string): void;
565
608
  addAttachment(file: File): Promise<void>;
566
609
  removeAttachment(attachmentId: string): Promise<void>;
567
610
  /**
@@ -569,20 +612,70 @@ declare class ThreadComposerRuntime implements ThreadComposerRuntimeCore {
569
612
  */
570
613
  reset(): void;
571
614
  send(): void;
615
+ cancel(): void;
616
+ beginEdit(): void;
617
+ /**
618
+ * @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
619
+ */
620
+ edit(): void;
572
621
  subscribe(callback: () => void): Unsubscribe;
622
+ private _focusListeners;
623
+ private focus;
624
+ private onFocus;
573
625
  }
574
626
 
575
- type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore>;
576
- declare class ThreadState {
627
+ type MessageState = ThreadMessage & {
628
+ /**
629
+ * @deprecated You can directly access message fields in the state. Replace `.message.content` with `.content` etc. This will be removed in 0.6.0.
630
+ */
631
+ message: ThreadMessage;
632
+ parentId: string | null;
633
+ isLast: boolean;
634
+ /**
635
+ * @deprecated Use `branchNumber` and `branchCount` instead. This will be removed in 0.6.0.
636
+ */
637
+ branches: readonly string[];
638
+ branchNumber: number;
639
+ branchCount: number;
640
+ };
641
+ type MessageStateBinding = SubscribableWithState<MessageState>;
642
+ declare class MessageRuntime {
577
643
  private _core;
578
- constructor(_core: ThreadRuntimeCore);
579
- get threadId(): string;
580
- get isDisabled(): boolean;
581
- get isRunning(): boolean;
582
- get capabilities(): Readonly<RuntimeCapabilities>;
644
+ private _threadBinding;
645
+ constructor(_core: MessageStateBinding, _threadBinding: ThreadRuntimeCoreBinding);
646
+ composer: ComposerRuntime & {
647
+ type: "edit";
648
+ };
649
+ getState(): MessageState;
650
+ unstable_edit(message: Omit<AppendMessage, "parentId">): void;
651
+ reload(): void;
652
+ speak(): SpeechSynthesisAdapter.Utterance;
653
+ submitFeedback({ type }: {
654
+ type: "positive" | "negative";
655
+ }): void;
656
+ switchToBranch({ position, branchId, }: {
657
+ position?: "previous" | "next" | undefined;
658
+ branchId?: string | undefined;
659
+ }): void;
660
+ subscribe(callback: () => void): Unsubscribe;
661
+ unstable_getContentPartByIndex(idx: number): ContentPartRuntime;
583
662
  }
663
+
664
+ type CreateAppendMessage = string | {
665
+ parentId?: string | null | undefined;
666
+ role?: AppendMessage["role"] | undefined;
667
+ content: AppendMessage["content"];
668
+ attachments?: AppendMessage["attachments"] | undefined;
669
+ };
670
+ type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore>;
671
+ type ThreadState = Readonly<{
672
+ threadId: string;
673
+ isDisabled: boolean;
674
+ isRunning: boolean;
675
+ capabilities: RuntimeCapabilities;
676
+ messages: readonly ThreadMessage[];
677
+ }>;
584
678
  declare class ThreadRuntime implements ThreadRuntimeCore {
585
- private _threadBinding;
586
679
  /**
587
680
  * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
588
681
  */
@@ -598,7 +691,19 @@ declare class ThreadRuntime implements ThreadRuntimeCore {
598
691
  /**
599
692
  * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
600
693
  */
601
- get capabilities(): Readonly<RuntimeCapabilities>;
694
+ get capabilities(): Readonly<{
695
+ switchToBranch: boolean;
696
+ edit: boolean;
697
+ reload: boolean;
698
+ cancel: boolean;
699
+ unstable_copy: boolean;
700
+ speak: boolean;
701
+ attachments: boolean;
702
+ feedback: boolean;
703
+ }>;
704
+ /**
705
+ * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
706
+ */
602
707
  get messages(): readonly ThreadMessage[];
603
708
  unstable_getCore(): Readonly<{
604
709
  getBranches: (messageId: string) => readonly string[];
@@ -610,7 +715,9 @@ declare class ThreadRuntime implements ThreadRuntimeCore {
610
715
  speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
611
716
  submitFeedback: (feedback: SubmitFeedbackOptions) => void;
612
717
  getModelConfig: () => ModelConfig;
613
- composer: ThreadComposerRuntimeCore;
718
+ composer: ComposerRuntimeCore;
719
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
720
+ beginEdit: (messageId: string) => void;
614
721
  capabilities: Readonly<RuntimeCapabilities>;
615
722
  threadId: string;
616
723
  isDisabled: boolean;
@@ -619,10 +726,17 @@ declare class ThreadRuntime implements ThreadRuntimeCore {
619
726
  import(repository: ExportedMessageRepository): void;
620
727
  export(): ExportedMessageRepository;
621
728
  }>;
622
- constructor(_threadBinding: ThreadRuntimeCoreBinding);
623
- readonly composer: ThreadComposerRuntime;
624
- getState(): ThreadState;
625
- append(message: AppendMessage): void;
729
+ private _threadBinding;
730
+ constructor(threadBinding: ThreadRuntimeCoreBinding);
731
+ readonly composer: ComposerRuntime;
732
+ getState(): Readonly<{
733
+ threadId: string;
734
+ isDisabled: boolean;
735
+ isRunning: boolean;
736
+ capabilities: RuntimeCapabilities;
737
+ messages: readonly ThreadMessage[];
738
+ }>;
739
+ append(message: CreateAppendMessage): void;
626
740
  subscribe(callback: () => void): Unsubscribe;
627
741
  getBranches(messageId: string): readonly string[];
628
742
  getModelConfig(): ModelConfig;
@@ -632,146 +746,84 @@ declare class ThreadRuntime implements ThreadRuntimeCore {
632
746
  switchToBranch(branchId: string): void;
633
747
  speak(messageId: string): SpeechSynthesisAdapter.Utterance;
634
748
  submitFeedback(options: SubmitFeedbackOptions): void;
749
+ /**
750
+ * @deprecated This is a temporary API. This will be removed in 0.6.0.
751
+ */
752
+ getEditComposer(messageId: string): Readonly<{
753
+ attachmentAccept: string;
754
+ attachments: readonly ThreadComposerAttachment[];
755
+ addAttachment: (file: File) => Promise<void>;
756
+ removeAttachment: (attachmentId: string) => Promise<void>;
757
+ isEditing: boolean;
758
+ canCancel: boolean;
759
+ isEmpty: boolean;
760
+ text: string;
761
+ setText: (value: string) => void;
762
+ reset: () => void;
763
+ send: () => void;
764
+ cancel: () => void;
765
+ subscribe: (callback: () => void) => Unsubscribe;
766
+ }> | undefined;
767
+ /**
768
+ * @deprecated This is a temporary API. This will be removed in 0.6.0.
769
+ */
770
+ beginEdit(messageId: string): void;
635
771
  export(): ExportedMessageRepository;
636
772
  import(data: ExportedMessageRepository): void;
637
773
  unstable_getMesssageByIndex(idx: number): MessageRuntime;
638
774
  }
639
775
 
640
- declare class AssistantRuntime<TThreadRuntime extends ThreadRuntime = ThreadRuntime> implements AssistantRuntimeCore {
641
- private _core;
642
- constructor(_core: AssistantRuntimeCore, CustomThreadRuntime: new (binding: ThreadRuntimeCoreBinding) => TThreadRuntime);
643
- readonly thread: TThreadRuntime;
644
- switchToNewThread(): void;
645
- switchToThread(threadId: string): void;
776
+ type ContentPartState = (ThreadUserContentPart | ThreadAssistantContentPart) & {
646
777
  /**
647
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
648
- */
649
- switchToThread(threadId: string | null): void;
650
- registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
651
- /**
652
- * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
778
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
653
779
  */
780
+ part: ThreadUserContentPart | ThreadAssistantContentPart;
781
+ status: ContentPartStatus | ToolCallContentPartStatus;
782
+ };
783
+ type ContentPartSnapshotBinding = SubscribableWithState<ContentPartState>;
784
+ declare class ContentPartRuntime {
785
+ private contentBinding;
786
+ private messageApi;
787
+ private threadApi;
788
+ constructor(contentBinding: ContentPartSnapshotBinding, messageApi: MessageStateBinding, threadApi: ThreadRuntimeCoreBinding);
789
+ getState(): ContentPartState;
790
+ addToolResult(result: any): void;
654
791
  subscribe(callback: () => void): Unsubscribe;
655
792
  }
656
793
 
657
- declare class ProxyConfigProvider implements ModelConfigProvider {
658
- private _providers;
659
- getModelConfig(): ModelConfig;
660
- registerModelConfigProvider(provider: ModelConfigProvider): () => void;
661
- }
662
-
663
- type TextContentPartState = Readonly<{
794
+ type EmptyContentPartProps = {
664
795
  status: ContentPartStatus;
796
+ };
797
+ type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
798
+ type TextContentPartProps = ContentPartState & TextContentPart & {
799
+ /**
800
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
801
+ */
665
802
  part: TextContentPart;
666
- }>;
667
- type ContentPartState = Readonly<{
668
- status: ContentPartStatus | ToolCallContentPartStatus;
669
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
670
- }>;
671
-
672
- declare const useSmooth: (state: TextContentPartState, smooth?: boolean) => TextContentPartState;
673
-
674
- declare const withSmoothContextProvider: <C extends ComponentType<any>>(Component: C) => C;
675
- declare const useSmoothStatus: {
676
- (): {
677
- type: "running";
678
- } | {
679
- type: "complete";
680
- } | {
681
- type: "incomplete";
682
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
683
- error?: unknown;
684
- } | {
685
- type: "requires-action";
686
- reason: "tool-calls";
687
- };
688
- <TSelected>(selector: (state: {
689
- type: "running";
690
- } | {
691
- type: "complete";
692
- } | {
693
- type: "incomplete";
694
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
695
- error?: unknown;
696
- } | {
697
- type: "requires-action";
698
- reason: "tool-calls";
699
- }) => TSelected): TSelected;
700
- (options: {
701
- optional: true;
702
- }): {
703
- type: "running";
704
- } | {
705
- type: "complete";
706
- } | {
707
- type: "incomplete";
708
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
709
- error?: unknown;
710
- } | {
711
- type: "requires-action";
712
- reason: "tool-calls";
713
- } | null;
714
- <TSelected>(options: {
715
- optional: true;
716
- selector?: (state: {
717
- type: "running";
718
- } | {
719
- type: "complete";
720
- } | {
721
- type: "incomplete";
722
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
723
- error?: unknown;
724
- } | {
725
- type: "requires-action";
726
- reason: "tool-calls";
727
- }) => TSelected;
728
- }): TSelected | null;
729
803
  };
730
-
731
- declare const buttonVariants: (props?: ({
732
- variant?: "default" | "outline" | "ghost" | null | undefined;
733
- size?: "default" | "icon" | null | undefined;
734
- } & class_variance_authority_types.ClassProp) | undefined) => string;
735
- type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
736
-
737
- type TooltipIconButtonProps = ButtonProps & {
738
- tooltip: string;
739
- side?: "top" | "bottom" | "left" | "right";
804
+ type TextContentPartComponent = ComponentType<TextContentPartProps>;
805
+ type ImageContentPartProps = ContentPartState & ImageContentPart & {
806
+ /**
807
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
808
+ */
809
+ part: ImageContentPart;
740
810
  };
741
- declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
742
- 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;
743
- } & {
744
- asChild?: boolean;
745
- }, "ref"> & class_variance_authority.VariantProps<(props?: ({
746
- variant?: "default" | "outline" | "ghost" | null | undefined;
747
- size?: "default" | "icon" | null | undefined;
748
- } & class_variance_authority_types.ClassProp) | undefined) => string> & {
749
- tooltip: string;
750
- side?: "top" | "bottom" | "left" | "right";
751
- } & react.RefAttributes<HTMLButtonElement>>;
752
-
753
- declare const generateId: (size?: number) => string;
754
-
755
- type internal_AssistantRuntime<TThreadRuntime extends ThreadRuntime = ThreadRuntime> = AssistantRuntime<TThreadRuntime>;
756
- declare const internal_AssistantRuntime: typeof AssistantRuntime;
757
- type internal_BaseAssistantRuntimeCore<TThreadRuntime extends ReactThreadRuntimeCore> = BaseAssistantRuntimeCore<TThreadRuntime>;
758
- declare const internal_BaseAssistantRuntimeCore: typeof BaseAssistantRuntimeCore;
759
- type internal_MessageRepository = MessageRepository;
760
- declare const internal_MessageRepository: typeof MessageRepository;
761
- type internal_ProxyConfigProvider = ProxyConfigProvider;
762
- declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
763
- type internal_ReactThreadRuntimeCore = ReactThreadRuntimeCore;
764
- type internal_ThreadRuntime = ThreadRuntime;
765
- declare const internal_ThreadRuntime: typeof ThreadRuntime;
766
- type internal_ThreadRuntimeCoreBinding = ThreadRuntimeCoreBinding;
767
- declare const internal_TooltipIconButton: typeof TooltipIconButton;
768
- declare const internal_generateId: typeof generateId;
769
- declare const internal_useSmooth: typeof useSmooth;
770
- declare const internal_useSmoothStatus: typeof useSmoothStatus;
771
- declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
772
- declare namespace internal {
773
- export { internal_AssistantRuntime as AssistantRuntime, internal_BaseAssistantRuntimeCore as BaseAssistantRuntimeCore, BaseThreadComposerRuntimeCore as BaseThreadRuntimeComposerCore, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, type internal_ReactThreadRuntimeCore as ReactThreadRuntimeCore, internal_ThreadRuntime as ThreadRuntime, type internal_ThreadRuntimeCoreBinding as ThreadRuntimeCoreBinding, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
774
- }
811
+ type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
812
+ type UIContentPartProps = ContentPartState & UIContentPart & {
813
+ /**
814
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
815
+ */
816
+ part: UIContentPart;
817
+ };
818
+ type UIContentPartComponent = ComponentType<UIContentPartProps>;
819
+ type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = ContentPartState & ToolCallContentPart<TArgs, TResult> & {
820
+ /**
821
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
822
+ */
823
+ part: ToolCallContentPart<TArgs, TResult>;
824
+ addResult: (result: any) => void;
825
+ };
826
+ type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
775
827
 
776
828
  type AssistantRuntimeProviderProps = {
777
829
  runtime: AssistantRuntime;
@@ -789,6 +841,26 @@ type AssistantToolUIsState = Readonly<{
789
841
  setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
790
842
  }>;
791
843
 
844
+ type MessageUtilsState = Readonly<{
845
+ isCopied: boolean;
846
+ setIsCopied: (value: boolean) => void;
847
+ isHovering: boolean;
848
+ setIsHovering: (value: boolean) => void;
849
+ isSpeaking: boolean;
850
+ stopSpeaking: () => void;
851
+ addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
852
+ submittedFeedback: "positive" | "negative" | null;
853
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
854
+ }>;
855
+
856
+ type ThreadViewportState = Readonly<{
857
+ isAtBottom: boolean;
858
+ scrollToBottom: () => void;
859
+ onScrollToBottom: (callback: () => void) => Unsubscribe;
860
+ }>;
861
+
862
+ type ReadonlyStore<T> = Omit<StoreApi<T>, "setState" | "destroy">;
863
+
792
864
  type AssistantContextValue = {
793
865
  useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
794
866
  useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
@@ -879,22 +951,14 @@ declare const useToolUIsStore: {
879
951
  }>> | null;
880
952
  };
881
953
 
882
- type ThreadViewportState = Readonly<{
883
- isAtBottom: boolean;
884
- scrollToBottom: () => void;
885
- onScrollToBottom: (callback: () => void) => Unsubscribe;
886
- }>;
887
-
888
- type ThreadMessagesState = readonly ThreadMessage[];
889
-
890
954
  type ThreadContextValue = {
891
- useThread: UseBoundStore<ReadonlyStore<ThreadState$1>>;
955
+ useThread: UseBoundStore<ReadonlyStore<ThreadState>>;
892
956
  /**
893
957
  * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
894
958
  */
895
959
  useThreadActions: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
896
960
  useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
897
- useThreadMessages: UseBoundStore<ReadonlyStore<ThreadMessagesState>>;
961
+ useThreadMessages: UseBoundStore<ReadonlyStore<readonly ThreadMessage[]>>;
898
962
  useComposer: UseBoundStore<ReadonlyStore<ThreadComposerState>>;
899
963
  useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
900
964
  };
@@ -946,192 +1010,150 @@ declare const useThreadRuntimeStore: {
946
1010
  };
947
1011
  declare const useThread: {
948
1012
  (): Readonly<{
949
- capabilities: Readonly<RuntimeCapabilities>;
950
1013
  threadId: string;
951
- isRunning: boolean;
952
1014
  isDisabled: boolean;
1015
+ isRunning: boolean;
1016
+ capabilities: Readonly<{
1017
+ switchToBranch: boolean;
1018
+ edit: boolean;
1019
+ reload: boolean;
1020
+ cancel: boolean;
1021
+ unstable_copy: boolean;
1022
+ speak: boolean;
1023
+ attachments: boolean;
1024
+ feedback: boolean;
1025
+ }>;
1026
+ messages: readonly ThreadMessage[];
953
1027
  }>;
954
1028
  <TSelected>(selector: (state: Readonly<{
955
- capabilities: Readonly<RuntimeCapabilities>;
956
1029
  threadId: string;
957
- isRunning: boolean;
958
1030
  isDisabled: boolean;
1031
+ isRunning: boolean;
1032
+ capabilities: Readonly<{
1033
+ switchToBranch: boolean;
1034
+ edit: boolean;
1035
+ reload: boolean;
1036
+ cancel: boolean;
1037
+ unstable_copy: boolean;
1038
+ speak: boolean;
1039
+ attachments: boolean;
1040
+ feedback: boolean;
1041
+ }>;
1042
+ messages: readonly ThreadMessage[];
959
1043
  }>) => TSelected): TSelected;
960
1044
  (options: {
961
1045
  optional: true;
962
1046
  }): Readonly<{
963
- capabilities: Readonly<RuntimeCapabilities>;
964
1047
  threadId: string;
965
- isRunning: boolean;
966
1048
  isDisabled: boolean;
1049
+ isRunning: boolean;
1050
+ capabilities: Readonly<{
1051
+ switchToBranch: boolean;
1052
+ edit: boolean;
1053
+ reload: boolean;
1054
+ cancel: boolean;
1055
+ unstable_copy: boolean;
1056
+ speak: boolean;
1057
+ attachments: boolean;
1058
+ feedback: boolean;
1059
+ }>;
1060
+ messages: readonly ThreadMessage[];
967
1061
  }> | null;
968
1062
  <TSelected>(options: {
969
1063
  optional: true;
970
1064
  selector?: (state: Readonly<{
971
- capabilities: Readonly<RuntimeCapabilities>;
972
1065
  threadId: string;
973
- isRunning: boolean;
974
1066
  isDisabled: boolean;
1067
+ isRunning: boolean;
1068
+ capabilities: Readonly<{
1069
+ switchToBranch: boolean;
1070
+ edit: boolean;
1071
+ reload: boolean;
1072
+ cancel: boolean;
1073
+ unstable_copy: boolean;
1074
+ speak: boolean;
1075
+ attachments: boolean;
1076
+ feedback: boolean;
1077
+ }>;
1078
+ messages: readonly ThreadMessage[];
975
1079
  }>) => TSelected;
976
1080
  }): TSelected | null;
977
1081
  };
978
1082
  declare const useThreadStore: {
979
1083
  (): ReadonlyStore<Readonly<{
980
- capabilities: Readonly<RuntimeCapabilities>;
981
1084
  threadId: string;
982
- isRunning: boolean;
983
1085
  isDisabled: boolean;
1086
+ isRunning: boolean;
1087
+ capabilities: Readonly<{
1088
+ switchToBranch: boolean;
1089
+ edit: boolean;
1090
+ reload: boolean;
1091
+ cancel: boolean;
1092
+ unstable_copy: boolean;
1093
+ speak: boolean;
1094
+ attachments: boolean;
1095
+ feedback: boolean;
1096
+ }>;
1097
+ messages: readonly ThreadMessage[];
984
1098
  }>>;
985
1099
  (options: {
986
1100
  optional: true;
987
1101
  }): ReadonlyStore<Readonly<{
988
- capabilities: Readonly<RuntimeCapabilities>;
989
1102
  threadId: string;
990
- isRunning: boolean;
991
1103
  isDisabled: boolean;
1104
+ isRunning: boolean;
1105
+ capabilities: Readonly<{
1106
+ switchToBranch: boolean;
1107
+ edit: boolean;
1108
+ reload: boolean;
1109
+ cancel: boolean;
1110
+ unstable_copy: boolean;
1111
+ speak: boolean;
1112
+ attachments: boolean;
1113
+ feedback: boolean;
1114
+ }>;
1115
+ messages: readonly ThreadMessage[];
992
1116
  }>> | null;
993
1117
  };
1118
+ /**
1119
+ * @deprecated Use `useThread().messages` instead. This will be removed in 0.6.0.
1120
+ */
994
1121
  declare const useThreadMessages: {
995
- (): ThreadMessagesState;
996
- <TSelected>(selector: (state: ThreadMessagesState) => TSelected): TSelected;
1122
+ (): readonly ThreadMessage[];
1123
+ <TSelected>(selector: (state: readonly ThreadMessage[]) => TSelected): TSelected;
997
1124
  (options: {
998
1125
  optional: true;
999
- }): ThreadMessagesState | null;
1126
+ }): readonly ThreadMessage[] | null;
1000
1127
  <TSelected>(options: {
1001
1128
  optional: true;
1002
- selector?: (state: ThreadMessagesState) => TSelected;
1129
+ selector?: (state: readonly ThreadMessage[]) => TSelected;
1003
1130
  }): TSelected | null;
1004
1131
  };
1132
+ /**
1133
+ * @deprecated Use `useThreadRuntime().getState().messages` instead. This will be removed in 0.6.0.
1134
+ */
1005
1135
  declare const useThreadMessagesStore: {
1006
- (): ReadonlyStore<ThreadMessagesState>;
1136
+ (): ReadonlyStore<readonly ThreadMessage[]>;
1007
1137
  (options: {
1008
1138
  optional: true;
1009
- }): ReadonlyStore<ThreadMessagesState> | null;
1139
+ }): ReadonlyStore<readonly ThreadMessage[]> | null;
1010
1140
  };
1011
1141
  declare const useThreadComposer: {
1012
- (): Readonly<{
1013
- type: "thread";
1014
- value: string;
1015
- setValue: (value: string) => void;
1016
- attachmentAccept: string;
1017
- attachments: readonly ThreadComposerAttachment[];
1018
- addAttachment: (file: File) => void;
1019
- removeAttachment: (attachmentId: string) => void;
1020
- text: string;
1021
- setText: (value: string) => void;
1022
- reset: () => void;
1023
- canCancel: boolean;
1024
- isEditing: true;
1025
- isEmpty: boolean;
1026
- send: () => void;
1027
- cancel: () => void;
1028
- focus: () => void;
1029
- onFocus: (listener: () => void) => Unsubscribe;
1030
- }>;
1031
- <TSelected>(selector: (state: Readonly<{
1032
- type: "thread";
1033
- value: string;
1034
- setValue: (value: string) => void;
1035
- attachmentAccept: string;
1036
- attachments: readonly ThreadComposerAttachment[];
1037
- addAttachment: (file: File) => void;
1038
- removeAttachment: (attachmentId: string) => void;
1039
- text: string;
1040
- setText: (value: string) => void;
1041
- reset: () => void;
1042
- canCancel: boolean;
1043
- isEditing: true;
1044
- isEmpty: boolean;
1045
- send: () => void;
1046
- cancel: () => void;
1047
- focus: () => void;
1048
- onFocus: (listener: () => void) => Unsubscribe;
1049
- }>) => TSelected): TSelected;
1142
+ (): ComposerState;
1143
+ <TSelected>(selector: (state: ComposerState) => TSelected): TSelected;
1050
1144
  (options: {
1051
1145
  optional: true;
1052
- }): Readonly<{
1053
- type: "thread";
1054
- value: string;
1055
- setValue: (value: string) => void;
1056
- attachmentAccept: string;
1057
- attachments: readonly ThreadComposerAttachment[];
1058
- addAttachment: (file: File) => void;
1059
- removeAttachment: (attachmentId: string) => void;
1060
- text: string;
1061
- setText: (value: string) => void;
1062
- reset: () => void;
1063
- canCancel: boolean;
1064
- isEditing: true;
1065
- isEmpty: boolean;
1066
- send: () => void;
1067
- cancel: () => void;
1068
- focus: () => void;
1069
- onFocus: (listener: () => void) => Unsubscribe;
1070
- }> | null;
1146
+ }): ComposerState | null;
1071
1147
  <TSelected>(options: {
1072
1148
  optional: true;
1073
- selector?: (state: Readonly<{
1074
- type: "thread";
1075
- value: string;
1076
- setValue: (value: string) => void;
1077
- attachmentAccept: string;
1078
- attachments: readonly ThreadComposerAttachment[];
1079
- addAttachment: (file: File) => void;
1080
- removeAttachment: (attachmentId: string) => void;
1081
- text: string;
1082
- setText: (value: string) => void;
1083
- reset: () => void;
1084
- canCancel: boolean;
1085
- isEditing: true;
1086
- isEmpty: boolean;
1087
- send: () => void;
1088
- cancel: () => void;
1089
- focus: () => void;
1090
- onFocus: (listener: () => void) => Unsubscribe;
1091
- }>) => TSelected;
1149
+ selector?: (state: ComposerState) => TSelected;
1092
1150
  }): TSelected | null;
1093
1151
  };
1094
1152
  declare const useThreadComposerStore: {
1095
- (): ReadonlyStore<Readonly<{
1096
- type: "thread";
1097
- value: string;
1098
- setValue: (value: string) => void;
1099
- attachmentAccept: string;
1100
- attachments: readonly ThreadComposerAttachment[];
1101
- addAttachment: (file: File) => void;
1102
- removeAttachment: (attachmentId: string) => void;
1103
- text: string;
1104
- setText: (value: string) => void;
1105
- reset: () => void;
1106
- canCancel: boolean;
1107
- isEditing: true;
1108
- isEmpty: boolean;
1109
- send: () => void;
1110
- cancel: () => void;
1111
- focus: () => void;
1112
- onFocus: (listener: () => void) => Unsubscribe;
1113
- }>>;
1153
+ (): ReadonlyStore<ComposerState>;
1114
1154
  (options: {
1115
1155
  optional: true;
1116
- }): ReadonlyStore<Readonly<{
1117
- type: "thread";
1118
- value: string;
1119
- setValue: (value: string) => void;
1120
- attachmentAccept: string;
1121
- attachments: readonly ThreadComposerAttachment[];
1122
- addAttachment: (file: File) => void;
1123
- removeAttachment: (attachmentId: string) => void;
1124
- text: string;
1125
- setText: (value: string) => void;
1126
- reset: () => void;
1127
- canCancel: boolean;
1128
- isEditing: true;
1129
- isEmpty: boolean;
1130
- send: () => void;
1131
- cancel: () => void;
1132
- focus: () => void;
1133
- onFocus: (listener: () => void) => Unsubscribe;
1134
- }>> | null;
1156
+ }): ReadonlyStore<ComposerState> | null;
1135
1157
  };
1136
1158
  declare const useThreadViewport: {
1137
1159
  (): Readonly<{
@@ -1175,42 +1197,8 @@ declare const useThreadViewportStore: {
1175
1197
  }>> | null;
1176
1198
  };
1177
1199
 
1178
- type MessageState = Readonly<{
1179
- message: Readonly<ThreadMessage>;
1180
- parentId: string | null;
1181
- branches: readonly string[];
1182
- isLast: boolean;
1183
- }>;
1184
-
1185
- type EditComposerState = Readonly<{
1186
- type: "edit";
1187
- /** @deprecated Use `text` instead. This will be removed in 0.6.0. */
1188
- value: string;
1189
- /** @deprecated Use `setText` instead. This will be removed in 0.6.0. */
1190
- setValue: (value: string) => void;
1191
- text: string;
1192
- setText: (value: string) => void;
1193
- canCancel: boolean;
1194
- isEditing: boolean;
1195
- isEmpty: boolean;
1196
- edit: () => void;
1197
- send: () => void;
1198
- cancel: () => void;
1199
- }>;
1200
-
1201
- type MessageUtilsState = Readonly<{
1202
- isCopied: boolean;
1203
- setIsCopied: (value: boolean) => void;
1204
- isHovering: boolean;
1205
- setIsHovering: (value: boolean) => void;
1206
- isSpeaking: boolean;
1207
- stopSpeaking: () => void;
1208
- addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1209
- submittedFeedback: "positive" | "negative" | null;
1210
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1211
- }>;
1212
-
1213
1200
  type MessageContextValue = {
1201
+ useMessageRuntime: UseBoundStore<ReadonlyStore<MessageRuntime>>;
1214
1202
  useMessage: UseBoundStore<ReadonlyStore<MessageState>>;
1215
1203
  useMessageUtils: UseBoundStore<ReadonlyStore<MessageUtilsState>>;
1216
1204
  useEditComposer: UseBoundStore<ReadonlyStore<EditComposerState>>;
@@ -1223,52 +1211,28 @@ declare const useMessageContext: {
1223
1211
  optional?: boolean | undefined;
1224
1212
  } | undefined): MessageContextValue | null;
1225
1213
  };
1214
+ declare function useMessageRuntime(options?: {
1215
+ optional?: false | undefined;
1216
+ }): MessageRuntime;
1217
+ declare function useMessageRuntime(options?: {
1218
+ optional?: boolean | undefined;
1219
+ }): MessageRuntime | null;
1226
1220
  declare const useMessage: {
1227
- (): Readonly<{
1228
- message: Readonly<ThreadMessage>;
1229
- parentId: string | null;
1230
- branches: readonly string[];
1231
- isLast: boolean;
1232
- }>;
1233
- <TSelected>(selector: (state: Readonly<{
1234
- message: Readonly<ThreadMessage>;
1235
- parentId: string | null;
1236
- branches: readonly string[];
1237
- isLast: boolean;
1238
- }>) => TSelected): TSelected;
1221
+ (): MessageState;
1222
+ <TSelected>(selector: (state: MessageState) => TSelected): TSelected;
1239
1223
  (options: {
1240
1224
  optional: true;
1241
- }): Readonly<{
1242
- message: Readonly<ThreadMessage>;
1243
- parentId: string | null;
1244
- branches: readonly string[];
1245
- isLast: boolean;
1246
- }> | null;
1225
+ }): MessageState | null;
1247
1226
  <TSelected>(options: {
1248
1227
  optional: true;
1249
- selector?: (state: Readonly<{
1250
- message: Readonly<ThreadMessage>;
1251
- parentId: string | null;
1252
- branches: readonly string[];
1253
- isLast: boolean;
1254
- }>) => TSelected;
1228
+ selector?: (state: MessageState) => TSelected;
1255
1229
  }): TSelected | null;
1256
1230
  };
1257
1231
  declare const useMessageStore: {
1258
- (): ReadonlyStore<Readonly<{
1259
- message: Readonly<ThreadMessage>;
1260
- parentId: string | null;
1261
- branches: readonly string[];
1262
- isLast: boolean;
1263
- }>>;
1232
+ (): ReadonlyStore<MessageState>;
1264
1233
  (options: {
1265
1234
  optional: true;
1266
- }): ReadonlyStore<Readonly<{
1267
- message: Readonly<ThreadMessage>;
1268
- parentId: string | null;
1269
- branches: readonly string[];
1270
- isLast: boolean;
1271
- }>> | null;
1235
+ }): ReadonlyStore<MessageState> | null;
1272
1236
  };
1273
1237
  declare const useMessageUtils: {
1274
1238
  (): Readonly<{
@@ -1348,96 +1312,25 @@ declare const useMessageUtilsStore: {
1348
1312
  }>> | null;
1349
1313
  };
1350
1314
  declare const useEditComposer: {
1351
- (): Readonly<{
1352
- type: "edit";
1353
- value: string;
1354
- setValue: (value: string) => void;
1355
- text: string;
1356
- setText: (value: string) => void;
1357
- canCancel: boolean;
1358
- isEditing: boolean;
1359
- isEmpty: boolean;
1360
- edit: () => void;
1361
- send: () => void;
1362
- cancel: () => void;
1363
- }>;
1364
- <TSelected>(selector: (state: Readonly<{
1365
- type: "edit";
1366
- value: string;
1367
- setValue: (value: string) => void;
1368
- text: string;
1369
- setText: (value: string) => void;
1370
- canCancel: boolean;
1371
- isEditing: boolean;
1372
- isEmpty: boolean;
1373
- edit: () => void;
1374
- send: () => void;
1375
- cancel: () => void;
1376
- }>) => TSelected): TSelected;
1315
+ (): ComposerState;
1316
+ <TSelected>(selector: (state: ComposerState) => TSelected): TSelected;
1377
1317
  (options: {
1378
1318
  optional: true;
1379
- }): Readonly<{
1380
- type: "edit";
1381
- value: string;
1382
- setValue: (value: string) => void;
1383
- text: string;
1384
- setText: (value: string) => void;
1385
- canCancel: boolean;
1386
- isEditing: boolean;
1387
- isEmpty: boolean;
1388
- edit: () => void;
1389
- send: () => void;
1390
- cancel: () => void;
1391
- }> | null;
1319
+ }): ComposerState | null;
1392
1320
  <TSelected>(options: {
1393
1321
  optional: true;
1394
- selector?: (state: Readonly<{
1395
- type: "edit";
1396
- value: string;
1397
- setValue: (value: string) => void;
1398
- text: string;
1399
- setText: (value: string) => void;
1400
- canCancel: boolean;
1401
- isEditing: boolean;
1402
- isEmpty: boolean;
1403
- edit: () => void;
1404
- send: () => void;
1405
- cancel: () => void;
1406
- }>) => TSelected;
1322
+ selector?: (state: ComposerState) => TSelected;
1407
1323
  }): TSelected | null;
1408
1324
  };
1409
1325
  declare const useEditComposerStore: {
1410
- (): ReadonlyStore<Readonly<{
1411
- type: "edit";
1412
- value: string;
1413
- setValue: (value: string) => void;
1414
- text: string;
1415
- setText: (value: string) => void;
1416
- canCancel: boolean;
1417
- isEditing: boolean;
1418
- isEmpty: boolean;
1419
- edit: () => void;
1420
- send: () => void;
1421
- cancel: () => void;
1422
- }>>;
1326
+ (): ReadonlyStore<ComposerState>;
1423
1327
  (options: {
1424
1328
  optional: true;
1425
- }): ReadonlyStore<Readonly<{
1426
- type: "edit";
1427
- value: string;
1428
- setValue: (value: string) => void;
1429
- text: string;
1430
- setText: (value: string) => void;
1431
- canCancel: boolean;
1432
- isEditing: boolean;
1433
- isEmpty: boolean;
1434
- edit: () => void;
1435
- send: () => void;
1436
- cancel: () => void;
1437
- }>> | null;
1329
+ }): ReadonlyStore<ComposerState> | null;
1438
1330
  };
1439
1331
 
1440
1332
  type ContentPartContextValue = {
1333
+ useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;
1441
1334
  useContentPart: UseBoundStore<ReadonlyStore<ContentPartState>>;
1442
1335
  };
1443
1336
  declare const useContentPartContext: {
@@ -1448,273 +1341,59 @@ declare const useContentPartContext: {
1448
1341
  optional?: boolean | undefined;
1449
1342
  } | undefined): ContentPartContextValue | null;
1450
1343
  };
1344
+ declare function useContentPartRuntime(options?: {
1345
+ optional?: false | undefined;
1346
+ }): ContentPartRuntime;
1347
+ declare function useContentPartRuntime(options?: {
1348
+ optional?: boolean | undefined;
1349
+ }): ContentPartRuntime | null;
1451
1350
  declare const useContentPart: {
1452
- (): Readonly<{
1453
- status: ContentPartStatus | ToolCallContentPartStatus;
1454
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1455
- }>;
1456
- <TSelected>(selector: (state: Readonly<{
1457
- status: ContentPartStatus | ToolCallContentPartStatus;
1458
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1459
- }>) => TSelected): TSelected;
1351
+ (): ContentPartState;
1352
+ <TSelected>(selector: (state: ContentPartState) => TSelected): TSelected;
1460
1353
  (options: {
1461
1354
  optional: true;
1462
- }): Readonly<{
1463
- status: ContentPartStatus | ToolCallContentPartStatus;
1464
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1465
- }> | null;
1355
+ }): ContentPartState | null;
1466
1356
  <TSelected>(options: {
1467
1357
  optional: true;
1468
- selector?: (state: Readonly<{
1469
- status: ContentPartStatus | ToolCallContentPartStatus;
1470
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1471
- }>) => TSelected;
1358
+ selector?: (state: ContentPartState) => TSelected;
1472
1359
  }): TSelected | null;
1473
1360
  };
1474
1361
  declare const useContentPartStore: {
1475
- (): ReadonlyStore<Readonly<{
1476
- status: ContentPartStatus | ToolCallContentPartStatus;
1477
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1478
- }>>;
1362
+ (): ReadonlyStore<ContentPartState>;
1479
1363
  (options: {
1480
1364
  optional: true;
1481
- }): ReadonlyStore<Readonly<{
1482
- status: ContentPartStatus | ToolCallContentPartStatus;
1483
- part: TextContentPart | ImageContentPart | UIContentPart | ToolCallContentPart;
1484
- }>> | null;
1365
+ }): ReadonlyStore<ContentPartState> | null;
1485
1366
  };
1486
1367
 
1487
1368
  type ComposerContextValue = {
1488
- useComposer: ReadonlyStore<EditComposerState | ThreadComposerState>;
1369
+ useComposer: ReadonlyStore<ComposerState>;
1489
1370
  type: "edit" | "new";
1490
1371
  };
1491
1372
  declare const useComposerContext: () => ComposerContextValue;
1492
1373
  declare const useComposer: {
1493
- (): Readonly<{
1494
- type: "edit";
1495
- value: string;
1496
- setValue: (value: string) => void;
1497
- text: string;
1498
- setText: (value: string) => void;
1499
- canCancel: boolean;
1500
- isEditing: boolean;
1501
- isEmpty: boolean;
1502
- edit: () => void;
1503
- send: () => void;
1504
- cancel: () => void;
1505
- }> | Readonly<{
1506
- type: "thread";
1507
- value: string;
1508
- setValue: (value: string) => void;
1509
- attachmentAccept: string;
1510
- attachments: readonly ThreadComposerAttachment[];
1511
- addAttachment: (file: File) => void;
1512
- removeAttachment: (attachmentId: string) => void;
1513
- text: string;
1514
- setText: (value: string) => void;
1515
- reset: () => void;
1516
- canCancel: boolean;
1517
- isEditing: true;
1518
- isEmpty: boolean;
1519
- send: () => void;
1520
- cancel: () => void;
1521
- focus: () => void;
1522
- onFocus: (listener: () => void) => Unsubscribe;
1523
- }>;
1524
- <TSelected>(selector: (state: Readonly<{
1525
- type: "edit";
1526
- value: string;
1527
- setValue: (value: string) => void;
1528
- text: string;
1529
- setText: (value: string) => void;
1530
- canCancel: boolean;
1531
- isEditing: boolean;
1532
- isEmpty: boolean;
1533
- edit: () => void;
1534
- send: () => void;
1535
- cancel: () => void;
1536
- }> | Readonly<{
1537
- type: "thread";
1538
- value: string;
1539
- setValue: (value: string) => void;
1540
- attachmentAccept: string;
1541
- attachments: readonly ThreadComposerAttachment[];
1542
- addAttachment: (file: File) => void;
1543
- removeAttachment: (attachmentId: string) => void;
1544
- text: string;
1545
- setText: (value: string) => void;
1546
- reset: () => void;
1547
- canCancel: boolean;
1548
- isEditing: true;
1549
- isEmpty: boolean;
1550
- send: () => void;
1551
- cancel: () => void;
1552
- focus: () => void;
1553
- onFocus: (listener: () => void) => Unsubscribe;
1554
- }>) => TSelected): TSelected;
1374
+ (): ComposerState;
1375
+ <TSelected>(selector: (state: ComposerState) => TSelected): TSelected;
1555
1376
  (options: {
1556
1377
  optional: true;
1557
- }): Readonly<{
1558
- type: "edit";
1559
- value: string;
1560
- setValue: (value: string) => void;
1561
- text: string;
1562
- setText: (value: string) => void;
1563
- canCancel: boolean;
1564
- isEditing: boolean;
1565
- isEmpty: boolean;
1566
- edit: () => void;
1567
- send: () => void;
1568
- cancel: () => void;
1569
- }> | Readonly<{
1570
- type: "thread";
1571
- value: string;
1572
- setValue: (value: string) => void;
1573
- attachmentAccept: string;
1574
- attachments: readonly ThreadComposerAttachment[];
1575
- addAttachment: (file: File) => void;
1576
- removeAttachment: (attachmentId: string) => void;
1577
- text: string;
1578
- setText: (value: string) => void;
1579
- reset: () => void;
1580
- canCancel: boolean;
1581
- isEditing: true;
1582
- isEmpty: boolean;
1583
- send: () => void;
1584
- cancel: () => void;
1585
- focus: () => void;
1586
- onFocus: (listener: () => void) => Unsubscribe;
1587
- }> | null;
1378
+ }): ComposerState | null;
1588
1379
  <TSelected>(options: {
1589
1380
  optional: true;
1590
- selector?: (state: Readonly<{
1591
- type: "edit";
1592
- value: string;
1593
- setValue: (value: string) => void;
1594
- text: string;
1595
- setText: (value: string) => void;
1596
- canCancel: boolean;
1597
- isEditing: boolean;
1598
- isEmpty: boolean;
1599
- edit: () => void;
1600
- send: () => void;
1601
- cancel: () => void;
1602
- }> | Readonly<{
1603
- type: "thread";
1604
- value: string;
1605
- setValue: (value: string) => void;
1606
- attachmentAccept: string;
1607
- attachments: readonly ThreadComposerAttachment[];
1608
- addAttachment: (file: File) => void;
1609
- removeAttachment: (attachmentId: string) => void;
1610
- text: string;
1611
- setText: (value: string) => void;
1612
- reset: () => void;
1613
- canCancel: boolean;
1614
- isEditing: true;
1615
- isEmpty: boolean;
1616
- send: () => void;
1617
- cancel: () => void;
1618
- focus: () => void;
1619
- onFocus: (listener: () => void) => Unsubscribe;
1620
- }>) => TSelected;
1381
+ selector?: (state: ComposerState) => TSelected;
1621
1382
  }): TSelected | null;
1622
1383
  };
1623
1384
  declare const useComposerStore: {
1624
- (): ReadonlyStore<Readonly<{
1625
- type: "edit";
1626
- value: string;
1627
- setValue: (value: string) => void;
1628
- text: string;
1629
- setText: (value: string) => void;
1630
- canCancel: boolean;
1631
- isEditing: boolean;
1632
- isEmpty: boolean;
1633
- edit: () => void;
1634
- send: () => void;
1635
- cancel: () => void;
1636
- }> | Readonly<{
1637
- type: "thread";
1638
- value: string;
1639
- setValue: (value: string) => void;
1640
- attachmentAccept: string;
1641
- attachments: readonly ThreadComposerAttachment[];
1642
- addAttachment: (file: File) => void;
1643
- removeAttachment: (attachmentId: string) => void;
1644
- text: string;
1645
- setText: (value: string) => void;
1646
- reset: () => void;
1647
- canCancel: boolean;
1648
- isEditing: true;
1649
- isEmpty: boolean;
1650
- send: () => void;
1651
- cancel: () => void;
1652
- focus: () => void;
1653
- onFocus: (listener: () => void) => Unsubscribe;
1654
- }>>;
1385
+ (): ReadonlyStore<ComposerState>;
1655
1386
  (options: {
1656
1387
  optional: true;
1657
- }): ReadonlyStore<Readonly<{
1658
- type: "edit";
1659
- value: string;
1660
- setValue: (value: string) => void;
1661
- text: string;
1662
- setText: (value: string) => void;
1663
- canCancel: boolean;
1664
- isEditing: boolean;
1665
- isEmpty: boolean;
1666
- edit: () => void;
1667
- send: () => void;
1668
- cancel: () => void;
1669
- }> | Readonly<{
1670
- type: "thread";
1671
- value: string;
1672
- setValue: (value: string) => void;
1673
- attachmentAccept: string;
1674
- attachments: readonly ThreadComposerAttachment[];
1675
- addAttachment: (file: File) => void;
1676
- removeAttachment: (attachmentId: string) => void;
1677
- text: string;
1678
- setText: (value: string) => void;
1679
- reset: () => void;
1680
- canCancel: boolean;
1681
- isEditing: true;
1682
- isEmpty: boolean;
1683
- send: () => void;
1684
- cancel: () => void;
1685
- focus: () => void;
1686
- onFocus: (listener: () => void) => Unsubscribe;
1687
- }>> | null;
1388
+ }): ReadonlyStore<ComposerState> | null;
1688
1389
  };
1390
+ declare function useComposerRuntime(options?: {
1391
+ optional?: false | undefined;
1392
+ }): ComposerRuntime;
1393
+ declare function useComposerRuntime(options?: {
1394
+ optional?: boolean | undefined;
1395
+ }): ComposerRuntime | null;
1689
1396
 
1690
- type ThreadComposerState = Readonly<{
1691
- type: "thread";
1692
- /** @deprecated Use `text` instead. */
1693
- value: string;
1694
- /** @deprecated Use `setText` instead. */
1695
- setValue: (value: string) => void;
1696
- attachmentAccept: string;
1697
- attachments: readonly ThreadComposerAttachment[];
1698
- addAttachment: (file: File) => void;
1699
- removeAttachment: (attachmentId: string) => void;
1700
- text: string;
1701
- setText: (value: string) => void;
1702
- reset: () => void;
1703
- canCancel: boolean;
1704
- isEditing: true;
1705
- isEmpty: boolean;
1706
- send: () => void;
1707
- cancel: () => void;
1708
- focus: () => void;
1709
- onFocus: (listener: () => void) => Unsubscribe;
1710
- }>;
1711
-
1712
- type CreateAppendMessage = string | {
1713
- parentId?: string | null | undefined;
1714
- role?: AppendMessage["role"] | undefined;
1715
- content: AppendMessage["content"];
1716
- attachments?: AppendMessage["attachments"] | undefined;
1717
- };
1718
1397
  declare const useAppendMessage: () => (message: CreateAppendMessage) => void;
1719
1398
 
1720
1399
  /**
@@ -1787,20 +1466,20 @@ declare const useComposerSend: () => (() => void) | null;
1787
1466
 
1788
1467
  declare const useComposerAddAttachment: () => (() => void) | null;
1789
1468
 
1790
- declare const useContentPartDisplay: () => Readonly<{
1791
- status: ContentPartStatus;
1792
- part: UIContentPart;
1793
- }>;
1469
+ declare const useContentPartDisplay: () => UIContentPart & {
1470
+ part: ThreadUserContentPart | ThreadAssistantContentPart;
1471
+ status: ContentPartStatus | ToolCallContentPartStatus;
1472
+ };
1794
1473
 
1795
- declare const useContentPartImage: () => Readonly<{
1796
- status: ContentPartStatus;
1797
- part: ImageContentPart;
1798
- }>;
1474
+ declare const useContentPartImage: () => ImageContentPart & {
1475
+ part: ThreadUserContentPart | ThreadAssistantContentPart;
1476
+ status: ContentPartStatus | ToolCallContentPartStatus;
1477
+ };
1799
1478
 
1800
- declare const useContentPartText: () => Readonly<{
1801
- status: ContentPartStatus;
1802
- part: TextContentPart;
1803
- }>;
1479
+ declare const useContentPartText: () => TextContentPart & {
1480
+ part: ThreadUserContentPart | ThreadAssistantContentPart;
1481
+ status: ContentPartStatus | ToolCallContentPartStatus;
1482
+ };
1804
1483
 
1805
1484
  type MessageIfFilters = {
1806
1485
  user: boolean | undefined;
@@ -2300,6 +1979,28 @@ type ThreadConfigProviderProps = PropsWithChildren<{
2300
1979
  }>;
2301
1980
  declare const ThreadConfigProvider: FC<ThreadConfigProviderProps>;
2302
1981
 
1982
+ declare const buttonVariants: (props?: ({
1983
+ variant?: "default" | "outline" | "ghost" | null | undefined;
1984
+ size?: "default" | "icon" | null | undefined;
1985
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
1986
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
1987
+
1988
+ type TooltipIconButtonProps = ButtonProps & {
1989
+ tooltip: string;
1990
+ side?: "top" | "bottom" | "left" | "right";
1991
+ };
1992
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
1993
+ 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;
1994
+ } & {
1995
+ asChild?: boolean;
1996
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
1997
+ variant?: "default" | "outline" | "ghost" | null | undefined;
1998
+ size?: "default" | "icon" | null | undefined;
1999
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
2000
+ tooltip: string;
2001
+ side?: "top" | "bottom" | "left" | "right";
2002
+ } & react.RefAttributes<HTMLButtonElement>>;
2003
+
2303
2004
  declare const AssistantActionBar: FC;
2304
2005
  declare const exports$c: {
2305
2006
  Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -2498,4 +2199,94 @@ declare const exports: {
2498
2199
  Text: FC;
2499
2200
  };
2500
2201
 
2501
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveFeedbackNegativeProps, type ActionBarPrimitiveFeedbackPositiveProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 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$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, ContentPartRuntime, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type EmptyContentPartComponent, type EmptyContentPartProps, type ExternalStoreAdapter, type ExternalStoreMessageConverter, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, MessageRuntime, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SubmitFeedbackOptions, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$4 as Thread, ThreadAssistantContentPart, ThreadComposerRuntime, type ThreadComposerState, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState$1 as ThreadState, ThreadUserContentPart, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantActions, useAssistantActionsStore, useAssistantContext, useAssistantInstructions, useAssistantRuntime, useAssistantRuntimeStore, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposer, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useComposerStore, useContentPart, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartStore, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useEditComposer, useEditComposerStore, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessage, useMessageContext, useMessageIf, useMessageStore, useMessageUtils, useMessageUtilsStore, useSwitchToNewThread, useThread, useThreadActions, useThreadActionsStore, useThreadComposer, useThreadComposerStore, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadMessages, useThreadMessagesStore, useThreadRuntime, useThreadRuntimeStore, useThreadScrollToBottom, useThreadStore, useThreadSuggestion, useThreadViewport, useThreadViewportStore, useToolUIs, useToolUIsStore };
2202
+ declare class ProxyConfigProvider implements ModelConfigProvider {
2203
+ private _providers;
2204
+ getModelConfig(): ModelConfig;
2205
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
2206
+ }
2207
+
2208
+ declare const useSmooth: (state: ContentPartState & TextContentPart, smooth?: boolean) => ContentPartState & TextContentPart;
2209
+
2210
+ declare const withSmoothContextProvider: <C extends ComponentType<any>>(Component: C) => C;
2211
+ declare const useSmoothStatus: {
2212
+ (): {
2213
+ type: "running";
2214
+ } | {
2215
+ type: "complete";
2216
+ } | {
2217
+ type: "incomplete";
2218
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2219
+ error?: unknown;
2220
+ } | {
2221
+ type: "requires-action";
2222
+ reason: "tool-calls";
2223
+ };
2224
+ <TSelected>(selector: (state: {
2225
+ type: "running";
2226
+ } | {
2227
+ type: "complete";
2228
+ } | {
2229
+ type: "incomplete";
2230
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2231
+ error?: unknown;
2232
+ } | {
2233
+ type: "requires-action";
2234
+ reason: "tool-calls";
2235
+ }) => TSelected): TSelected;
2236
+ (options: {
2237
+ optional: true;
2238
+ }): {
2239
+ type: "running";
2240
+ } | {
2241
+ type: "complete";
2242
+ } | {
2243
+ type: "incomplete";
2244
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2245
+ error?: unknown;
2246
+ } | {
2247
+ type: "requires-action";
2248
+ reason: "tool-calls";
2249
+ } | null;
2250
+ <TSelected>(options: {
2251
+ optional: true;
2252
+ selector?: (state: {
2253
+ type: "running";
2254
+ } | {
2255
+ type: "complete";
2256
+ } | {
2257
+ type: "incomplete";
2258
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2259
+ error?: unknown;
2260
+ } | {
2261
+ type: "requires-action";
2262
+ reason: "tool-calls";
2263
+ }) => TSelected;
2264
+ }): TSelected | null;
2265
+ };
2266
+
2267
+ declare const generateId: (size?: number) => string;
2268
+
2269
+ type internal_AssistantRuntime<TThreadRuntime extends ThreadRuntime = ThreadRuntime> = AssistantRuntime<TThreadRuntime>;
2270
+ declare const internal_AssistantRuntime: typeof AssistantRuntime;
2271
+ type internal_BaseAssistantRuntimeCore<TThreadRuntime extends ReactThreadRuntimeCore> = BaseAssistantRuntimeCore<TThreadRuntime>;
2272
+ declare const internal_BaseAssistantRuntimeCore: typeof BaseAssistantRuntimeCore;
2273
+ type internal_DefaultThreadComposerRuntimeCore = DefaultThreadComposerRuntimeCore;
2274
+ declare const internal_DefaultThreadComposerRuntimeCore: typeof DefaultThreadComposerRuntimeCore;
2275
+ type internal_MessageRepository = MessageRepository;
2276
+ declare const internal_MessageRepository: typeof MessageRepository;
2277
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
2278
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
2279
+ type internal_ReactThreadRuntimeCore = ReactThreadRuntimeCore;
2280
+ type internal_ThreadRuntime = ThreadRuntime;
2281
+ declare const internal_ThreadRuntime: typeof ThreadRuntime;
2282
+ type internal_ThreadRuntimeCoreBinding = ThreadRuntimeCoreBinding;
2283
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
2284
+ declare const internal_generateId: typeof generateId;
2285
+ declare const internal_useSmooth: typeof useSmooth;
2286
+ declare const internal_useSmoothStatus: typeof useSmoothStatus;
2287
+ declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
2288
+ declare namespace internal {
2289
+ export { internal_AssistantRuntime as AssistantRuntime, internal_BaseAssistantRuntimeCore as BaseAssistantRuntimeCore, internal_DefaultThreadComposerRuntimeCore as DefaultThreadComposerRuntimeCore, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, type internal_ReactThreadRuntimeCore as ReactThreadRuntimeCore, internal_ThreadRuntime as ThreadRuntime, type internal_ThreadRuntimeCoreBinding as ThreadRuntimeCoreBinding, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
2290
+ }
2291
+
2292
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveFeedbackNegativeProps, type ActionBarPrimitiveFeedbackPositiveProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, type AttachmentAdapter, _default$8 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$7 as Composer, _default$6 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, ComposerRuntime, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, ContentPartRuntime, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type EmptyContentPartComponent, type EmptyContentPartProps, type ExternalStoreAdapter, type ExternalStoreMessageConverter, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, MessageRuntime, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SubmitFeedbackOptions, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$4 as Thread, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, ThreadUserContentPart, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$2 as UserActionBar, _default$3 as UserMessage, _default$1 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantActions, useAssistantActionsStore, useAssistantContext, useAssistantInstructions, useAssistantRuntime, useAssistantRuntimeStore, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposer, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerRuntime, useComposerSend, useComposerStore, useContentPart, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartRuntime, useContentPartStore, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useEditComposer, useEditComposerStore, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessage, useMessageContext, useMessageIf, useMessageRuntime, useMessageStore, useMessageUtils, useMessageUtilsStore, useSwitchToNewThread, useThread, useThreadActions, useThreadActionsStore, useThreadComposer, useThreadComposerStore, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadMessages, useThreadMessagesStore, useThreadRuntime, useThreadRuntimeStore, useThreadScrollToBottom, useThreadStore, useThreadSuggestion, useThreadViewport, useThreadViewportStore, useToolUIs, useToolUIsStore };