@assistant-ui/react 0.5.59 → 0.5.62

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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.js';
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.js';
1
3
  import * as react from 'react';
2
4
  import { ComponentType, PropsWithChildren, FC, ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
3
- import { T as ThreadAssistantContentPart, M as MessageStatus, a as ThreadRoundtrip, b as ThreadMessage, c as ModelConfig, d as ModelConfigProvider, C as ContentPartStatus, e as TextContentPart, I as ImageContentPart, U as UIContentPart, f as ToolCallContentPart, g as ToolCallContentPartStatus, h as CoreMessage, i as ThreadComposerAttachment, j as MessageAttachment, A as AppendMessage, k as Tool, l as CoreToolCallContentPart, m as CreateEdgeRuntimeAPIOptions } from './edge-BJordJU0.js';
4
- 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, n as ThreadUserContentPart, q as ThreadUserMessage } from './edge-BJordJU0.js';
5
5
  import { StoreApi, UseBoundStore } from 'zustand';
6
6
  import { Primitive } from '@radix-ui/react-primitive';
7
7
  import * as PopoverPrimitive from '@radix-ui/react-popover';
@@ -14,54 +14,6 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
14
14
  import 'json-schema';
15
15
  import 'zod';
16
16
 
17
- type Unsubscribe = () => void;
18
-
19
- type ReadonlyStore<T> = Omit<StoreApi<T>, "setState" | "destroy">;
20
-
21
- type ReactThreadRuntime = ThreadRuntime & {
22
- unstable_synchronizer?: ComponentType;
23
- };
24
-
25
- declare const subscribeToMainThread: (runtime: ThreadRuntimeWithSubscribe, callback: () => void) => () => void;
26
-
27
- type ChatModelRunUpdate = {
28
- content: ThreadAssistantContentPart[];
29
- metadata?: Record<string, unknown>;
30
- };
31
- type ChatModelRunResult = {
32
- content?: ThreadAssistantContentPart[];
33
- status?: MessageStatus;
34
- metadata?: {
35
- roundtrips?: ThreadRoundtrip[];
36
- custom?: Record<string, unknown>;
37
- };
38
- };
39
- type ChatModelRunOptions = {
40
- messages: ThreadMessage[];
41
- abortSignal: AbortSignal;
42
- config: ModelConfig;
43
- /**
44
- * @deprecated Declare the run function as an AsyncGenerator instead. This method will be removed in v0.6
45
- */
46
- onUpdate: (result: ChatModelRunUpdate) => void;
47
- };
48
- type ChatModelAdapter = {
49
- run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;
50
- };
51
-
52
- declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> implements AssistantRuntime {
53
- private _thread;
54
- constructor(_thread: TThreadRuntime);
55
- get thread(): TThreadRuntime;
56
- set thread(thread: TThreadRuntime);
57
- abstract switchToNewThread(): void;
58
- abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
59
- abstract switchToThread(threadId: string | null): void;
60
- private _subscriptions;
61
- subscribe(callback: () => void): Unsubscribe;
62
- private subscriptionHandler;
63
- }
64
-
65
17
  type EmptyContentPartProps = {
66
18
  status: ContentPartStatus;
67
19
  };
@@ -88,6 +40,49 @@ type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResu
88
40
  };
89
41
  type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
90
42
 
43
+ type Unsubscribe = () => void;
44
+
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
+ declare namespace SpeechSynthesisAdapter {
65
+ type Status = {
66
+ type: "starting" | "running";
67
+ } | {
68
+ type: "ended";
69
+ reason: "finished" | "cancelled" | "error";
70
+ error?: unknown;
71
+ };
72
+ type Utterance = {
73
+ status: Status;
74
+ cancel: () => void;
75
+ onEnd: (callback: () => void) => Unsubscribe;
76
+ };
77
+ }
78
+ type SpeechSynthesisAdapter = {
79
+ speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance;
80
+ };
81
+
82
+ declare class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter {
83
+ speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance;
84
+ }
85
+
91
86
  interface ExportedMessageRepository {
92
87
  headId?: string | null;
93
88
  messages: Array<{
@@ -115,6 +110,108 @@ declare class MessageRepository {
115
110
  import({ headId, messages }: ExportedMessageRepository): void;
116
111
  }
117
112
 
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;
124
+ }>;
125
+
126
+ type AddToolResultOptions = {
127
+ messageId: string;
128
+ toolName: string;
129
+ toolCallId: string;
130
+ result: any;
131
+ };
132
+ type SubmitFeedbackOptions = {
133
+ messageId: string;
134
+ type: "negative" | "positive";
135
+ };
136
+ type ThreadRuntimeCore = Readonly<{
137
+ getBranches: (messageId: string) => readonly string[];
138
+ switchToBranch: (branchId: string) => void;
139
+ append: (message: AppendMessage) => void;
140
+ startRun: (parentId: string | null) => void;
141
+ cancelRun: () => void;
142
+ addToolResult: (options: AddToolResultOptions) => void;
143
+ speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
144
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
145
+ getModelConfig: () => ModelConfig;
146
+ composer: ThreadComposerRuntimeCore;
147
+ capabilities: Readonly<RuntimeCapabilities>;
148
+ threadId: string;
149
+ isDisabled: boolean;
150
+ messages: readonly ThreadMessage[];
151
+ subscribe: (callback: () => void) => Unsubscribe;
152
+ import(repository: ExportedMessageRepository): void;
153
+ export(): ExportedMessageRepository;
154
+ }>;
155
+
156
+ type AssistantRuntimeCore = {
157
+ readonly thread: ThreadRuntimeCore;
158
+ switchToNewThread: () => void;
159
+ switchToThread(threadId: string): void;
160
+ /**
161
+ * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
162
+ */
163
+ switchToThread(threadId: string | null): void;
164
+ registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
165
+ subscribe: (callback: () => void) => Unsubscribe;
166
+ };
167
+
168
+ /**
169
+ * @deprecated Use `runtime.thread.subscribe` instead. This will be removed in 0.6.0.
170
+ */
171
+ declare const subscribeToMainThread: (runtime: AssistantRuntimeCore, callback: () => void) => () => void;
172
+
173
+ type ChatModelRunUpdate = {
174
+ content: ThreadAssistantContentPart[];
175
+ metadata?: Record<string, unknown>;
176
+ };
177
+ type ChatModelRunResult = {
178
+ content?: ThreadAssistantContentPart[];
179
+ status?: MessageStatus;
180
+ metadata?: {
181
+ roundtrips?: ThreadRoundtrip[];
182
+ custom?: Record<string, unknown>;
183
+ };
184
+ };
185
+ type ChatModelRunOptions = {
186
+ messages: ThreadMessage[];
187
+ abortSignal: AbortSignal;
188
+ config: ModelConfig;
189
+ /**
190
+ * @deprecated Declare the run function as an AsyncGenerator instead. This method will be removed in v0.6
191
+ */
192
+ onUpdate: (result: ChatModelRunUpdate) => void;
193
+ };
194
+ type ChatModelAdapter = {
195
+ run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;
196
+ };
197
+
198
+ type ReactThreadRuntimeCore = ThreadRuntimeCore & {
199
+ unstable_synchronizer?: ComponentType;
200
+ };
201
+
202
+ declare abstract class BaseAssistantRuntimeCore<TThreadRuntime extends ReactThreadRuntimeCore> implements AssistantRuntimeCore {
203
+ private _thread;
204
+ constructor(_thread: TThreadRuntime);
205
+ get thread(): TThreadRuntime;
206
+ set thread(thread: TThreadRuntime);
207
+ abstract switchToNewThread(): void;
208
+ abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
209
+ abstract switchToThread(threadId: string | null): void;
210
+ private _subscriptions;
211
+ subscribe(callback: () => void): Unsubscribe;
212
+ private subscriptionHandler;
213
+ }
214
+
118
215
  type AttachmentAdapter = {
119
216
  accept: string;
120
217
  add(state: {
@@ -124,16 +221,15 @@ type AttachmentAdapter = {
124
221
  send(attachment: ThreadComposerAttachment): Promise<MessageAttachment>;
125
222
  };
126
223
 
127
- declare class ThreadRuntimeComposer implements ThreadRuntime.Composer {
224
+ declare class BaseThreadComposerRuntimeCore implements ThreadComposerRuntimeCore {
128
225
  private runtime;
129
- private notifySubscribers;
130
226
  private _attachmentAdapter?;
131
227
  attachmentAccept: string;
132
228
  get isEmpty(): boolean;
133
229
  constructor(runtime: {
134
- messages: ThreadRuntime["messages"];
230
+ messages: ThreadRuntimeCore["messages"];
135
231
  append: (message: AppendMessage) => void;
136
- }, notifySubscribers: () => void);
232
+ });
137
233
  setAttachmentAdapter(adapter: AttachmentAdapter | undefined): boolean;
138
234
  private _attachments;
139
235
  get attachments(): ThreadComposerAttachment[];
@@ -144,24 +240,17 @@ declare class ThreadRuntimeComposer implements ThreadRuntime.Composer {
144
240
  setText(value: string): void;
145
241
  reset(): void;
146
242
  send(): Promise<void>;
243
+ private _subscriptions;
244
+ private notifySubscribers;
245
+ subscribe(callback: () => void): Unsubscribe;
147
246
  }
148
247
 
149
- declare namespace SpeechSynthesisAdapter {
150
- type Status = {
151
- type: "starting" | "running";
152
- } | {
153
- type: "ended";
154
- reason: "finished" | "cancelled" | "error";
155
- error?: unknown;
156
- };
157
- type Utterance = {
158
- status: Status;
159
- cancel: () => void;
160
- onEnd: (callback: () => void) => Unsubscribe;
161
- };
162
- }
163
- type SpeechSynthesisAdapter = {
164
- speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance;
248
+ type FeedbackAdapterFeedback = {
249
+ message: ThreadMessage;
250
+ type: "positive" | "negative";
251
+ };
252
+ type FeedbackAdapter = {
253
+ submit: (feedback: FeedbackAdapterFeedback) => void;
165
254
  };
166
255
 
167
256
  type LocalRuntimeOptions = {
@@ -170,14 +259,11 @@ type LocalRuntimeOptions = {
170
259
  adapters?: {
171
260
  attachments?: AttachmentAdapter | undefined;
172
261
  speech?: SpeechSynthesisAdapter | undefined;
262
+ feedback?: FeedbackAdapter | undefined;
173
263
  } | undefined;
174
264
  };
175
265
 
176
- declare class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter {
177
- speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance;
178
- }
179
-
180
- declare class LocalThreadRuntime implements ThreadRuntime {
266
+ declare class LocalThreadRuntimeCore implements ThreadRuntimeCore {
181
267
  private configProvider;
182
268
  adapter: ChatModelAdapter;
183
269
  private _subscriptions;
@@ -191,12 +277,14 @@ declare class LocalThreadRuntime implements ThreadRuntime {
191
277
  unstable_copy: boolean;
192
278
  speak: boolean;
193
279
  attachments: boolean;
280
+ feedback: boolean;
194
281
  };
195
282
  readonly threadId: string;
196
283
  readonly isDisabled = false;
197
284
  get messages(): ThreadMessage[];
198
- readonly composer: ThreadRuntimeComposer;
285
+ readonly composer: BaseThreadComposerRuntimeCore;
199
286
  constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
287
+ getModelConfig(): ModelConfig;
200
288
  private _options;
201
289
  get options(): LocalRuntimeOptions;
202
290
  set options({ initialMessages, ...options }: LocalRuntimeOptions);
@@ -211,23 +299,27 @@ declare class LocalThreadRuntime implements ThreadRuntime {
211
299
  addToolResult({ messageId, toolCallId, result, }: AddToolResultOptions): void;
212
300
  private _utterance;
213
301
  speak(messageId: string): SpeechSynthesisAdapter.Utterance;
302
+ submitFeedback({ messageId, type }: SubmitFeedbackOptions): void;
214
303
  export(): ExportedMessageRepository;
215
304
  import(data: ExportedMessageRepository): void;
216
305
  }
217
306
 
218
- declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
307
+ declare class LocalRuntimeCore extends BaseAssistantRuntimeCore<LocalThreadRuntimeCore> {
219
308
  private readonly _proxyConfigProvider;
220
309
  constructor(adapter: ChatModelAdapter, options: LocalRuntimeOptions);
221
- set adapter(adapter: ChatModelAdapter);
222
- set options(options: LocalRuntimeOptions);
223
310
  registerModelConfigProvider(provider: ModelConfigProvider): () => void;
224
- switchToNewThread(): LocalThreadRuntime;
311
+ switchToNewThread(): void;
225
312
  switchToThread(threadId: string | null): void;
226
313
  reset({ initialMessages, }?: {
227
314
  initialMessages?: readonly CoreMessage[] | undefined;
228
315
  }): void;
229
316
  }
230
317
 
318
+ declare class LocalRuntime extends AssistantRuntime {
319
+ private core;
320
+ constructor(core: LocalRuntimeCore);
321
+ reset(options?: Parameters<LocalRuntimeCore["reset"]>[0]): void;
322
+ }
231
323
  declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
232
324
 
233
325
  declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
@@ -348,6 +440,7 @@ type ExternalStoreAdapterBase<T> = {
348
440
  convertMessage?: ExternalStoreMessageConverter<T> | undefined;
349
441
  adapters?: {
350
442
  attachments?: AttachmentAdapter | undefined;
443
+ feedback?: FeedbackAdapter | undefined;
351
444
  };
352
445
  unstable_capabilities?: {
353
446
  copy?: boolean | undefined;
@@ -355,6 +448,212 @@ type ExternalStoreAdapterBase<T> = {
355
448
  };
356
449
  type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
357
450
 
451
+ declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntime<ThreadRuntime>;
452
+
453
+ declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
454
+
455
+ declare namespace useExternalMessageConverter {
456
+ type Message = ThreadMessageLike | {
457
+ role: "tool";
458
+ toolCallId: string;
459
+ toolName?: string | undefined;
460
+ result: any;
461
+ };
462
+ type Callback<T> = (message: T) => Message | Message[];
463
+ }
464
+ declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
465
+ callback: useExternalMessageConverter.Callback<T>;
466
+ messages: T[];
467
+ isRunning: boolean;
468
+ }) => ThreadMessage[];
469
+
470
+ type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
471
+
472
+ type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
473
+ declare const useDangerousInBrowserRuntime: ({ initialMessages, ...options }: DangerousInBrowserRuntimeOptions) => LocalRuntime;
474
+
475
+ type Subscribable = {
476
+ subscribe: (callback: () => void) => Unsubscribe;
477
+ };
478
+ type SubscribableWithState<TState> = Subscribable & {
479
+ getState: () => TState;
480
+ };
481
+
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
+ /**
501
+ * @deprecated Use `branchNumber` and `branchCount` instead. This will be removed in 0.6.0.
502
+ */
503
+ branches: readonly string[];
504
+ branchNumber: number;
505
+ branchCount: number;
506
+ };
507
+ type MessageSnapshotBinding = SubscribableWithState<MessageSnapshot>;
508
+ type MessageState$1 = ThreadMessage & MessageSnapshot & {
509
+ /**
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.
511
+ */
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 {
544
+ private _core;
545
+ constructor(_core: ThreadComposerRuntimeCoreBinding);
546
+ /**
547
+ * @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
548
+ */
549
+ get isEmpty(): boolean;
550
+ /**
551
+ * @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
552
+ */
553
+ get text(): string;
554
+ /**
555
+ * @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
556
+ */
557
+ get attachmentAccept(): string;
558
+ /**
559
+ * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
560
+ */
561
+ get attachments(): ThreadComposerAttachment[];
562
+ private _state;
563
+ getState(): ComposerState;
564
+ setText(text: string): void;
565
+ addAttachment(file: File): Promise<void>;
566
+ removeAttachment(attachmentId: string): Promise<void>;
567
+ /**
568
+ * @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
569
+ */
570
+ reset(): void;
571
+ send(): void;
572
+ subscribe(callback: () => void): Unsubscribe;
573
+ }
574
+
575
+ type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore>;
576
+ declare class ThreadState {
577
+ private _core;
578
+ constructor(_core: ThreadRuntimeCore);
579
+ get threadId(): string;
580
+ get isDisabled(): boolean;
581
+ get isRunning(): boolean;
582
+ get capabilities(): Readonly<RuntimeCapabilities>;
583
+ }
584
+ declare class ThreadRuntime implements ThreadRuntimeCore {
585
+ private _threadBinding;
586
+ /**
587
+ * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
588
+ */
589
+ get threadId(): string;
590
+ /**
591
+ * @deprecated Use `getState().isDisabled` instead. This will be removed in 0.6.0.
592
+ */
593
+ get isDisabled(): boolean;
594
+ /**
595
+ * @deprecated Use `getState().isRunning` instead. This will be removed in 0.6.0.
596
+ */
597
+ get isRunning(): boolean;
598
+ /**
599
+ * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
600
+ */
601
+ get capabilities(): Readonly<RuntimeCapabilities>;
602
+ get messages(): readonly ThreadMessage[];
603
+ unstable_getCore(): Readonly<{
604
+ getBranches: (messageId: string) => readonly string[];
605
+ switchToBranch: (branchId: string) => void;
606
+ append: (message: AppendMessage) => void;
607
+ startRun: (parentId: string | null) => void;
608
+ cancelRun: () => void;
609
+ addToolResult: (options: AddToolResultOptions) => void;
610
+ speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
611
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
612
+ getModelConfig: () => ModelConfig;
613
+ composer: ThreadComposerRuntimeCore;
614
+ capabilities: Readonly<RuntimeCapabilities>;
615
+ threadId: string;
616
+ isDisabled: boolean;
617
+ messages: readonly ThreadMessage[];
618
+ subscribe: (callback: () => void) => Unsubscribe;
619
+ import(repository: ExportedMessageRepository): void;
620
+ export(): ExportedMessageRepository;
621
+ }>;
622
+ constructor(_threadBinding: ThreadRuntimeCoreBinding);
623
+ readonly composer: ThreadComposerRuntime;
624
+ getState(): ThreadState;
625
+ append(message: AppendMessage): void;
626
+ subscribe(callback: () => void): Unsubscribe;
627
+ getBranches(messageId: string): readonly string[];
628
+ getModelConfig(): ModelConfig;
629
+ startRun(parentId: string | null): void;
630
+ cancelRun(): void;
631
+ addToolResult(options: AddToolResultOptions): void;
632
+ switchToBranch(branchId: string): void;
633
+ speak(messageId: string): SpeechSynthesisAdapter.Utterance;
634
+ submitFeedback(options: SubmitFeedbackOptions): void;
635
+ export(): ExportedMessageRepository;
636
+ import(data: ExportedMessageRepository): void;
637
+ unstable_getMesssageByIndex(idx: number): MessageRuntime;
638
+ }
639
+
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;
646
+ /**
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.
653
+ */
654
+ subscribe(callback: () => void): Unsubscribe;
655
+ }
656
+
358
657
  declare class ProxyConfigProvider implements ModelConfigProvider {
359
658
  private _providers;
360
659
  getModelConfig(): ModelConfig;
@@ -453,161 +752,27 @@ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react
453
752
 
454
753
  declare const generateId: (size?: number) => string;
455
754
 
456
- type internal_BaseAssistantRuntime<TThreadRuntime extends ReactThreadRuntime> = BaseAssistantRuntime<TThreadRuntime>;
457
- declare const internal_BaseAssistantRuntime: typeof BaseAssistantRuntime;
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;
458
759
  type internal_MessageRepository = MessageRepository;
459
760
  declare const internal_MessageRepository: typeof MessageRepository;
460
761
  type internal_ProxyConfigProvider = ProxyConfigProvider;
461
762
  declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
462
- type internal_ThreadRuntimeComposer = ThreadRuntimeComposer;
463
- declare const internal_ThreadRuntimeComposer: typeof ThreadRuntimeComposer;
763
+ type internal_ReactThreadRuntimeCore = ReactThreadRuntimeCore;
764
+ type internal_ThreadRuntime = ThreadRuntime;
765
+ declare const internal_ThreadRuntime: typeof ThreadRuntime;
766
+ type internal_ThreadRuntimeCoreBinding = ThreadRuntimeCoreBinding;
464
767
  declare const internal_TooltipIconButton: typeof TooltipIconButton;
465
768
  declare const internal_generateId: typeof generateId;
466
769
  declare const internal_useSmooth: typeof useSmooth;
467
770
  declare const internal_useSmoothStatus: typeof useSmoothStatus;
468
771
  declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
469
772
  declare namespace internal {
470
- export { internal_BaseAssistantRuntime as BaseAssistantRuntime, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, internal_ThreadRuntimeComposer as ThreadRuntimeComposer, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
471
- }
472
-
473
- type ConverterCallback<TIn> = (cache: ThreadMessage | undefined, message: TIn, idx: number) => ThreadMessage;
474
- declare class ThreadMessageConverter {
475
- private readonly cache;
476
- convertMessages<TIn extends WeakKey>(messages: TIn[], converter: ConverterCallback<TIn>): ThreadMessage[];
477
- }
478
-
479
- declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
480
- private _subscriptions;
481
- private repository;
482
- private assistantOptimisticId;
483
- private _capabilities;
484
- get capabilities(): RuntimeCapabilities;
485
- threadId: string;
486
- messages: ThreadMessage[];
487
- isDisabled: boolean;
488
- converter: ThreadMessageConverter;
489
- private _store;
490
- readonly composer: ThreadRuntimeComposer;
491
- constructor(store: ExternalStoreAdapter<any>);
492
- get store(): ExternalStoreAdapter<any>;
493
- set store(store: ExternalStoreAdapter<any>);
494
- private notifySubscribers;
495
- getBranches(messageId: string): string[];
496
- switchToBranch(branchId: string): void;
497
- append(message: AppendMessage): Promise<void>;
498
- startRun(parentId: string | null): Promise<void>;
499
- cancelRun(): void;
500
- addToolResult(options: AddToolResultOptions): void;
501
- speak(messageId: string): SpeechSynthesisAdapter.Utterance;
502
- subscribe(callback: () => void): Unsubscribe;
503
- private updateMessages;
504
- }
505
-
506
- declare class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {
507
- private readonly _proxyConfigProvider;
508
- constructor(store: ExternalStoreAdapter<any>);
509
- get store(): ExternalStoreAdapter<any>;
510
- set store(store: ExternalStoreAdapter<any>);
511
- getModelConfig(): ModelConfig;
512
- registerModelConfigProvider(provider: ModelConfigProvider): () => void;
513
- switchToNewThread(): Promise<void>;
514
- switchToThread(threadId: string | null): Promise<void>;
515
- }
516
-
517
- declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => ExternalStoreRuntime;
518
-
519
- declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
520
-
521
- declare namespace useExternalMessageConverter {
522
- type Message = ThreadMessageLike | {
523
- role: "tool";
524
- toolCallId: string;
525
- toolName?: string | undefined;
526
- result: any;
527
- };
528
- type Callback<T> = (message: T) => Message | Message[];
529
- }
530
- declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
531
- callback: useExternalMessageConverter.Callback<T>;
532
- messages: T[];
533
- isRunning: boolean;
534
- }) => ThreadMessage[];
535
-
536
- type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
537
-
538
- type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
539
- declare const useDangerousInBrowserRuntime: ({ initialMessages, ...options }: DangerousInBrowserRuntimeOptions) => LocalRuntime;
540
-
541
- type ThreadRuntimeStore = ThreadRuntime;
542
-
543
- type ThreadState = Readonly<{
544
- capabilities: Readonly<RuntimeCapabilities>;
545
- threadId: string;
546
- isRunning: boolean;
547
- isDisabled: boolean;
548
- }>;
549
- type RuntimeCapabilities = {
550
- switchToBranch: boolean;
551
- edit: boolean;
552
- reload: boolean;
553
- cancel: boolean;
554
- unstable_copy: boolean;
555
- speak: boolean;
556
- attachments: boolean;
557
- };
558
-
559
- type AddToolResultOptions = {
560
- messageId: string;
561
- toolName: string;
562
- toolCallId: string;
563
- result: any;
564
- };
565
- type ThreadActionsState = Readonly<{
566
- getBranches: (messageId: string) => readonly string[];
567
- switchToBranch: (branchId: string) => void;
568
- append: (message: AppendMessage) => void;
569
- startRun: (parentId: string | null) => void;
570
- cancelRun: () => void;
571
- addToolResult: (options: AddToolResultOptions) => void;
572
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
573
- }>;
574
-
575
- type ThreadRuntime = ThreadActionsState & Readonly<{
576
- composer: ThreadRuntime.Composer;
577
- capabilities: Readonly<RuntimeCapabilities>;
578
- threadId: string;
579
- isDisabled: boolean;
580
- messages: readonly ThreadMessage[];
581
- subscribe: (callback: () => void) => Unsubscribe;
582
- }>;
583
- declare namespace ThreadRuntime {
584
- type Composer = Readonly<{
585
- attachmentAccept: string;
586
- attachments: ThreadComposerAttachment[];
587
- addAttachment: (file: File) => Promise<void>;
588
- removeAttachment: (attachmentId: string) => Promise<void>;
589
- isEmpty: boolean;
590
- text: string;
591
- setText: (value: string) => void;
592
- reset: () => void;
593
- send: () => void;
594
- }>;
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 };
595
774
  }
596
775
 
597
- type ThreadRuntimeWithSubscribe = {
598
- readonly thread: ThreadRuntime;
599
- subscribe: (callback: () => void) => Unsubscribe;
600
- };
601
- type AssistantRuntime = ThreadRuntimeWithSubscribe & {
602
- switchToNewThread: () => void;
603
- /**
604
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
605
- */
606
- switchToThread(threadId: null): void;
607
- switchToThread(threadId: string): void;
608
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
609
- };
610
-
611
776
  type AssistantRuntimeProviderProps = {
612
777
  runtime: AssistantRuntime;
613
778
  };
@@ -619,16 +784,6 @@ type TextContentPartProviderProps = {
619
784
  };
620
785
  declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
621
786
 
622
- type AssistantActionsState = Readonly<{
623
- /**
624
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
625
- */
626
- switchToThread(threadId: null): void;
627
- switchToThread(threadId: string): void;
628
- switchToNewThread: () => void;
629
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
630
- }>;
631
-
632
787
  type AssistantToolUIsState = Readonly<{
633
788
  getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
634
789
  setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
@@ -637,7 +792,10 @@ type AssistantToolUIsState = Readonly<{
637
792
  type AssistantContextValue = {
638
793
  useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
639
794
  useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
640
- useAssistantActions: UseBoundStore<ReadonlyStore<AssistantActionsState>>;
795
+ /**
796
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
797
+ */
798
+ useAssistantActions: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
641
799
  };
642
800
  declare const useAssistantContext: {
643
801
  (options?: {
@@ -647,22 +805,43 @@ declare const useAssistantContext: {
647
805
  optional?: boolean | undefined;
648
806
  } | undefined): AssistantContextValue | null;
649
807
  };
650
- declare const useAssistantRuntime: {
651
- (): AssistantRuntime;
652
- <TSelected>(selector: (state: AssistantRuntime) => TSelected): TSelected;
808
+ declare function useAssistantRuntime(options?: {
809
+ optional?: false | undefined;
810
+ }): AssistantRuntime;
811
+ declare function useAssistantRuntime(options?: {
812
+ optional?: boolean | undefined;
813
+ }): AssistantRuntime | null;
814
+ /**
815
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
816
+ */
817
+ declare const useAssistantActionsStore: {
818
+ (): ReadonlyStore<AssistantRuntime<ThreadRuntime>>;
819
+ (options: {
820
+ optional: true;
821
+ }): ReadonlyStore<AssistantRuntime<ThreadRuntime>> | null;
822
+ };
823
+ /**
824
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
825
+ */
826
+ declare const useAssistantActions: {
827
+ (): AssistantRuntime<ThreadRuntime>;
828
+ <TSelected>(selector: (state: AssistantRuntime<ThreadRuntime>) => TSelected): TSelected;
653
829
  (options: {
654
830
  optional: true;
655
- }): AssistantRuntime | null;
831
+ }): AssistantRuntime<ThreadRuntime> | null;
656
832
  <TSelected>(options: {
657
833
  optional: true;
658
- selector?: (state: AssistantRuntime) => TSelected;
834
+ selector?: (state: AssistantRuntime<ThreadRuntime>) => TSelected;
659
835
  }): TSelected | null;
660
836
  };
837
+ /**
838
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
839
+ */
661
840
  declare const useAssistantRuntimeStore: {
662
- (): ReadonlyStore<AssistantRuntime>;
841
+ (): ReadonlyStore<AssistantRuntime<ThreadRuntime>>;
663
842
  (options: {
664
843
  optional: true;
665
- }): ReadonlyStore<AssistantRuntime> | null;
844
+ }): ReadonlyStore<AssistantRuntime<ThreadRuntime>> | null;
666
845
  };
667
846
  declare const useToolUIs: {
668
847
  (): Readonly<{
@@ -699,53 +878,6 @@ declare const useToolUIsStore: {
699
878
  setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
700
879
  }>> | null;
701
880
  };
702
- declare const useAssistantActions: {
703
- (): Readonly<{
704
- switchToThread(threadId: null): void;
705
- switchToThread(threadId: string): void;
706
- switchToNewThread: () => void;
707
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
708
- }>;
709
- <TSelected>(selector: (state: Readonly<{
710
- switchToThread(threadId: null): void;
711
- switchToThread(threadId: string): void;
712
- switchToNewThread: () => void;
713
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
714
- }>) => TSelected): TSelected;
715
- (options: {
716
- optional: true;
717
- }): Readonly<{
718
- switchToThread(threadId: null): void;
719
- switchToThread(threadId: string): void;
720
- switchToNewThread: () => void;
721
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
722
- }> | null;
723
- <TSelected>(options: {
724
- optional: true;
725
- selector?: (state: Readonly<{
726
- switchToThread(threadId: null): void;
727
- switchToThread(threadId: string): void;
728
- switchToNewThread: () => void;
729
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
730
- }>) => TSelected;
731
- }): TSelected | null;
732
- };
733
- declare const useAssistantActionsStore: {
734
- (): ReadonlyStore<Readonly<{
735
- switchToThread(threadId: null): void;
736
- switchToThread(threadId: string): void;
737
- switchToNewThread: () => void;
738
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
739
- }>>;
740
- (options: {
741
- optional: true;
742
- }): ReadonlyStore<Readonly<{
743
- switchToThread(threadId: null): void;
744
- switchToThread(threadId: string): void;
745
- switchToNewThread: () => void;
746
- registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
747
- }>> | null;
748
- };
749
881
 
750
882
  type ThreadViewportState = Readonly<{
751
883
  isAtBottom: boolean;
@@ -756,10 +888,13 @@ type ThreadViewportState = Readonly<{
756
888
  type ThreadMessagesState = readonly ThreadMessage[];
757
889
 
758
890
  type ThreadContextValue = {
759
- useThread: UseBoundStore<ReadonlyStore<ThreadState>>;
760
- useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntimeStore>>;
891
+ useThread: UseBoundStore<ReadonlyStore<ThreadState$1>>;
892
+ /**
893
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
894
+ */
895
+ useThreadActions: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
896
+ useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
761
897
  useThreadMessages: UseBoundStore<ReadonlyStore<ThreadMessagesState>>;
762
- useThreadActions: UseBoundStore<ReadonlyStore<ThreadActionsState>>;
763
898
  useComposer: UseBoundStore<ReadonlyStore<ThreadComposerState>>;
764
899
  useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
765
900
  };
@@ -771,7 +906,25 @@ declare const useThreadContext: {
771
906
  optional?: boolean | undefined;
772
907
  } | undefined): ThreadContextValue | null;
773
908
  };
774
- declare const useThreadRuntime: {
909
+ declare function useThreadRuntime(options?: {
910
+ optional?: false | undefined;
911
+ }): ThreadRuntime;
912
+ declare function useThreadRuntime(options?: {
913
+ optional?: boolean | undefined;
914
+ }): ThreadRuntime | null;
915
+ /**
916
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
917
+ */
918
+ declare const useThreadActionsStore: {
919
+ (): ReadonlyStore<ThreadRuntime>;
920
+ (options: {
921
+ optional: true;
922
+ }): ReadonlyStore<ThreadRuntime> | null;
923
+ };
924
+ /**
925
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
926
+ */
927
+ declare const useThreadActions: {
775
928
  (): ThreadRuntime;
776
929
  <TSelected>(selector: (state: ThreadRuntime) => TSelected): TSelected;
777
930
  (options: {
@@ -782,6 +935,9 @@ declare const useThreadRuntime: {
782
935
  selector?: (state: ThreadRuntime) => TSelected;
783
936
  }): TSelected | null;
784
937
  };
938
+ /**
939
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
940
+ */
785
941
  declare const useThreadRuntimeStore: {
786
942
  (): ReadonlyStore<ThreadRuntime>;
787
943
  (options: {
@@ -852,71 +1008,6 @@ declare const useThreadMessagesStore: {
852
1008
  optional: true;
853
1009
  }): ReadonlyStore<ThreadMessagesState> | null;
854
1010
  };
855
- declare const useThreadActions: {
856
- (): Readonly<{
857
- getBranches: (messageId: string) => readonly string[];
858
- switchToBranch: (branchId: string) => void;
859
- append: (message: AppendMessage) => void;
860
- startRun: (parentId: string | null) => void;
861
- cancelRun: () => void;
862
- addToolResult: (options: AddToolResultOptions) => void;
863
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
864
- }>;
865
- <TSelected>(selector: (state: Readonly<{
866
- getBranches: (messageId: string) => readonly string[];
867
- switchToBranch: (branchId: string) => void;
868
- append: (message: AppendMessage) => void;
869
- startRun: (parentId: string | null) => void;
870
- cancelRun: () => void;
871
- addToolResult: (options: AddToolResultOptions) => void;
872
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
873
- }>) => TSelected): TSelected;
874
- (options: {
875
- optional: true;
876
- }): Readonly<{
877
- getBranches: (messageId: string) => readonly string[];
878
- switchToBranch: (branchId: string) => void;
879
- append: (message: AppendMessage) => void;
880
- startRun: (parentId: string | null) => void;
881
- cancelRun: () => void;
882
- addToolResult: (options: AddToolResultOptions) => void;
883
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
884
- }> | null;
885
- <TSelected>(options: {
886
- optional: true;
887
- selector?: (state: Readonly<{
888
- getBranches: (messageId: string) => readonly string[];
889
- switchToBranch: (branchId: string) => void;
890
- append: (message: AppendMessage) => void;
891
- startRun: (parentId: string | null) => void;
892
- cancelRun: () => void;
893
- addToolResult: (options: AddToolResultOptions) => void;
894
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
895
- }>) => TSelected;
896
- }): TSelected | null;
897
- };
898
- declare const useThreadActionsStore: {
899
- (): ReadonlyStore<Readonly<{
900
- getBranches: (messageId: string) => readonly string[];
901
- switchToBranch: (branchId: string) => void;
902
- append: (message: AppendMessage) => void;
903
- startRun: (parentId: string | null) => void;
904
- cancelRun: () => void;
905
- addToolResult: (options: AddToolResultOptions) => void;
906
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
907
- }>>;
908
- (options: {
909
- optional: true;
910
- }): ReadonlyStore<Readonly<{
911
- getBranches: (messageId: string) => readonly string[];
912
- switchToBranch: (branchId: string) => void;
913
- append: (message: AppendMessage) => void;
914
- startRun: (parentId: string | null) => void;
915
- cancelRun: () => void;
916
- addToolResult: (options: AddToolResultOptions) => void;
917
- speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
918
- }>> | null;
919
- };
920
1011
  declare const useThreadComposer: {
921
1012
  (): Readonly<{
922
1013
  type: "thread";
@@ -1115,6 +1206,8 @@ type MessageUtilsState = Readonly<{
1115
1206
  isSpeaking: boolean;
1116
1207
  stopSpeaking: () => void;
1117
1208
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1209
+ submittedFeedback: "positive" | "negative" | null;
1210
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1118
1211
  }>;
1119
1212
 
1120
1213
  type MessageContextValue = {
@@ -1186,6 +1279,8 @@ declare const useMessageUtils: {
1186
1279
  isSpeaking: boolean;
1187
1280
  stopSpeaking: () => void;
1188
1281
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1282
+ submittedFeedback: "positive" | "negative" | null;
1283
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1189
1284
  }>;
1190
1285
  <TSelected>(selector: (state: Readonly<{
1191
1286
  isCopied: boolean;
@@ -1195,6 +1290,8 @@ declare const useMessageUtils: {
1195
1290
  isSpeaking: boolean;
1196
1291
  stopSpeaking: () => void;
1197
1292
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1293
+ submittedFeedback: "positive" | "negative" | null;
1294
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1198
1295
  }>) => TSelected): TSelected;
1199
1296
  (options: {
1200
1297
  optional: true;
@@ -1206,6 +1303,8 @@ declare const useMessageUtils: {
1206
1303
  isSpeaking: boolean;
1207
1304
  stopSpeaking: () => void;
1208
1305
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1306
+ submittedFeedback: "positive" | "negative" | null;
1307
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1209
1308
  }> | null;
1210
1309
  <TSelected>(options: {
1211
1310
  optional: true;
@@ -1217,6 +1316,8 @@ declare const useMessageUtils: {
1217
1316
  isSpeaking: boolean;
1218
1317
  stopSpeaking: () => void;
1219
1318
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1319
+ submittedFeedback: "positive" | "negative" | null;
1320
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1220
1321
  }>) => TSelected;
1221
1322
  }): TSelected | null;
1222
1323
  };
@@ -1229,6 +1330,8 @@ declare const useMessageUtilsStore: {
1229
1330
  isSpeaking: boolean;
1230
1331
  stopSpeaking: () => void;
1231
1332
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1333
+ submittedFeedback: "positive" | "negative" | null;
1334
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1232
1335
  }>>;
1233
1336
  (options: {
1234
1337
  optional: true;
@@ -1240,6 +1343,8 @@ declare const useMessageUtilsStore: {
1240
1343
  isSpeaking: boolean;
1241
1344
  stopSpeaking: () => void;
1242
1345
  addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
1346
+ submittedFeedback: "positive" | "negative" | null;
1347
+ setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1243
1348
  }>> | null;
1244
1349
  };
1245
1350
  declare const useEditComposer: {
@@ -1654,6 +1759,10 @@ declare const useActionBarSpeak: () => (() => Promise<void>) | null;
1654
1759
 
1655
1760
  declare const useActionBarStopSpeaking: () => (() => Promise<void>) | null;
1656
1761
 
1762
+ declare const useActionBarFeedbackPositive: () => () => void;
1763
+
1764
+ declare const useActionBarFeedbackNegative: () => () => void;
1765
+
1657
1766
  declare const useBranchPickerCount: () => number;
1658
1767
 
1659
1768
  declare const useBranchPickerNext: () => (() => void) | null;
@@ -1702,6 +1811,7 @@ type MessageIfFilters = {
1702
1811
  lastOrHover: boolean | undefined;
1703
1812
  speaking: boolean | undefined;
1704
1813
  hasAttachments: boolean | undefined;
1814
+ submittedFeedback: "positive" | "negative" | null | undefined;
1705
1815
  };
1706
1816
  type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
1707
1817
  declare const useMessageIf: (props: UseMessageIfProps) => boolean;
@@ -1743,11 +1853,11 @@ type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;
1743
1853
  type ActionButtonProps<THook> = PrimitiveButtonProps & (THook extends (props: infer TProps) => unknown ? TProps : never);
1744
1854
 
1745
1855
  type ActionBarPrimitiveCopyProps = ActionButtonProps<typeof useActionBarCopy>;
1746
- declare const ActionBarPrimitiveCopy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
1856
+ declare const ActionBarPrimitiveCopy: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
1747
1857
  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;
1748
1858
  } & {
1749
1859
  asChild?: boolean;
1750
- }, "ref"> & UseActionBarCopyProps & react.RefAttributes<HTMLButtonElement>>;
1860
+ }, "ref"> & UseActionBarCopyProps> & react.RefAttributes<HTMLButtonElement>>;
1751
1861
 
1752
1862
  type ActionBarPrimitiveReloadProps = ActionButtonProps<typeof useActionBarReload>;
1753
1863
  declare const ActionBarPrimitiveReload: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -1777,8 +1887,22 @@ declare const ActionBarPrimitiveStopSpeaking: react.ForwardRefExoticComponent<Pa
1777
1887
  asChild?: boolean;
1778
1888
  }, "ref">> & react.RefAttributes<HTMLButtonElement>>;
1779
1889
 
1890
+ type ActionBarPrimitiveFeedbackPositiveProps = ActionButtonProps<typeof useActionBarFeedbackPositive>;
1891
+ declare const ActionBarPrimitiveFeedbackPositive: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
1892
+ 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;
1893
+ } & {
1894
+ asChild?: boolean;
1895
+ }, "ref">> & react.RefAttributes<HTMLButtonElement>>;
1896
+
1897
+ type ActionBarPrimitiveFeedbackNegativeProps = ActionButtonProps<typeof useActionBarFeedbackNegative>;
1898
+ declare const ActionBarPrimitiveFeedbackNegative: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
1899
+ 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;
1900
+ } & {
1901
+ asChild?: boolean;
1902
+ }, "ref">> & react.RefAttributes<HTMLButtonElement>>;
1903
+
1780
1904
  declare namespace index$6 {
1781
- export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking };
1905
+ export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveFeedbackNegative as FeedbackNegative, ActionBarPrimitiveFeedbackPositive as FeedbackPositive, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking };
1782
1906
  }
1783
1907
 
1784
1908
  type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;
@@ -2056,6 +2180,8 @@ type AssistantMessageConfig = {
2056
2180
  allowReload?: boolean | undefined;
2057
2181
  allowCopy?: boolean | undefined;
2058
2182
  allowSpeak?: boolean | undefined;
2183
+ allowFeedbackPositive?: boolean | undefined;
2184
+ allowFeedbackNegative?: boolean | undefined;
2059
2185
  components?: {
2060
2186
  Text?: TextContentPartComponent | undefined;
2061
2187
  ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;
@@ -2103,6 +2229,14 @@ type StringsConfig = {
2103
2229
  tooltip?: string | undefined;
2104
2230
  };
2105
2231
  };
2232
+ feedback?: {
2233
+ positive?: {
2234
+ tooltip?: string | undefined;
2235
+ };
2236
+ negative?: {
2237
+ tooltip?: string | undefined;
2238
+ };
2239
+ };
2106
2240
  };
2107
2241
  branchPicker?: {
2108
2242
  previous?: {
@@ -2174,6 +2308,8 @@ declare const exports$c: {
2174
2308
  Speak: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
2175
2309
  StopSpeaking: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
2176
2310
  SpeechControl: FC;
2311
+ FeedbackPositive: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
2312
+ FeedbackNegative: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
2177
2313
  };
2178
2314
  declare const _default$b: typeof AssistantActionBar & typeof exports$c;
2179
2315
 
@@ -2352,4 +2488,4 @@ declare const exports: {
2352
2488
  Text: FC;
2353
2489
  };
2354
2490
 
2355
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$b as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$a as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$9 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type 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, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$5 as EditComposer, type EditComposerState, type EmptyContentPartComponent, type EmptyContentPartProps, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$4 as Thread, type ThreadActionsState, ThreadAssistantContentPart, 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, 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, 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 };
2491
+ 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 };