@assistant-ui/react 0.5.75 → 0.5.76

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -15,8 +15,8 @@ import 'json-schema';
15
15
  import 'zod';
16
16
 
17
17
  type ComposerRuntimeCore = Readonly<{
18
- attachmentAccept: string;
19
18
  attachments: readonly Attachment[];
19
+ getAttachmentAccept(): string;
20
20
  addAttachment: (file: File) => Promise<void>;
21
21
  removeAttachment: (attachmentId: string) => Promise<void>;
22
22
  isEditing: boolean;
@@ -93,7 +93,7 @@ type RuntimeCapabilities = Readonly<{
93
93
  reload: boolean;
94
94
  cancel: boolean;
95
95
  unstable_copy: boolean;
96
- speak: boolean;
96
+ speech: boolean;
97
97
  attachments: boolean;
98
98
  feedback: boolean;
99
99
  }>;
@@ -114,6 +114,9 @@ type SpeechState = Readonly<{
114
114
  messageId: string;
115
115
  status: SpeechSynthesisAdapter.Status;
116
116
  }>;
117
+ type SubmittedFeedback = Readonly<{
118
+ type: "negative" | "positive";
119
+ }>;
117
120
  type ThreadRuntimeCore = Readonly<{
118
121
  getBranches: (messageId: string) => readonly string[];
119
122
  switchToBranch: (branchId: string) => void;
@@ -123,12 +126,13 @@ type ThreadRuntimeCore = Readonly<{
123
126
  addToolResult: (options: AddToolResultOptions) => void;
124
127
  speak: (messageId: string) => void;
125
128
  stopSpeaking: () => void;
129
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
126
130
  submitFeedback: (feedback: SubmitFeedbackOptions) => void;
127
131
  getModelConfig: () => ModelConfig;
128
132
  composer: ThreadComposerRuntimeCore;
129
133
  getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
130
134
  beginEdit: (messageId: string) => void;
131
- speech: SpeechState | null;
135
+ speech: SpeechState | undefined;
132
136
  capabilities: Readonly<RuntimeCapabilities>;
133
137
  threadId: string;
134
138
  isDisabled: boolean;
@@ -199,6 +203,14 @@ declare abstract class BaseAssistantRuntimeCore<TThreadRuntime extends ThreadRun
199
203
  private subscriptionHandler;
200
204
  }
201
205
 
206
+ type FeedbackAdapterFeedback = {
207
+ message: ThreadMessage;
208
+ type: "positive" | "negative";
209
+ };
210
+ type FeedbackAdapter = {
211
+ submit: (feedback: FeedbackAdapterFeedback) => void;
212
+ };
213
+
202
214
  type AttachmentAdapter = {
203
215
  accept: string;
204
216
  add(state: {
@@ -212,6 +224,20 @@ type AttachmentAdapter = {
212
224
  }>;
213
225
  };
214
226
 
227
+ type LocalRuntimeOptions = {
228
+ initialMessages?: readonly CoreMessage[] | undefined;
229
+ maxSteps?: number | undefined;
230
+ /**
231
+ * @deprecated Use `maxSteps` (which is `maxToolRoundtrips` + 1; if you set `maxToolRoundtrips` to 2, set `maxSteps` to 3) instead. This field will be removed in v0.6.
232
+ */
233
+ maxToolRoundtrips?: number | undefined;
234
+ adapters?: {
235
+ attachments?: AttachmentAdapter | undefined;
236
+ speech?: SpeechSynthesisAdapter | undefined;
237
+ feedback?: FeedbackAdapter | undefined;
238
+ } | undefined;
239
+ };
240
+
215
241
  declare class SimpleImageAttachmentAdapter implements AttachmentAdapter {
216
242
  accept: string;
217
243
  add(state: {
@@ -247,7 +273,8 @@ declare class CompositeAttachmentAdapter implements AttachmentAdapter {
247
273
 
248
274
  declare abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
249
275
  readonly isEditing = true;
250
- attachmentAccept: string;
276
+ protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;
277
+ getAttachmentAccept(): string;
251
278
  private _attachments;
252
279
  protected set attachments(value: readonly Attachment[]);
253
280
  get attachments(): readonly Attachment[];
@@ -260,8 +287,6 @@ declare abstract class BaseComposerRuntimeCore implements ComposerRuntimeCore {
260
287
  send(): Promise<void>;
261
288
  abstract handleSend(message: Omit<AppendMessage, "parentId">): void;
262
289
  abstract cancel(): void;
263
- protected _attachmentAdapter?: AttachmentAdapter | undefined;
264
- setAttachmentAdapter(adapter: AttachmentAdapter | undefined): void;
265
290
  addAttachment(file: File): Promise<void>;
266
291
  removeAttachment(attachmentId: string): Promise<void>;
267
292
  private _subscriptions;
@@ -274,42 +299,30 @@ declare class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore i
274
299
  private _canCancel;
275
300
  get canCancel(): boolean;
276
301
  get attachments(): readonly PendingAttachment[];
277
- constructor(runtime: Omit<ThreadRuntimeCore, "composer">);
302
+ protected getAttachmentAdapter(): AttachmentAdapter | undefined;
303
+ constructor(runtime: Omit<ThreadRuntimeCore, "composer"> & {
304
+ adapters?: {
305
+ attachments?: AttachmentAdapter | undefined;
306
+ } | undefined;
307
+ });
278
308
  connect(): Unsubscribe;
279
309
  handleSend(message: Omit<AppendMessage, "parentId">): Promise<void>;
280
310
  cancel(): Promise<void>;
281
311
  }
282
312
 
283
- type FeedbackAdapterFeedback = {
284
- message: ThreadMessage;
285
- type: "positive" | "negative";
286
- };
287
- type FeedbackAdapter = {
288
- submit: (feedback: FeedbackAdapterFeedback) => void;
289
- };
290
-
291
- type LocalRuntimeOptions = {
292
- initialMessages?: readonly CoreMessage[] | undefined;
293
- maxSteps?: number | undefined;
294
- /**
295
- * @deprecated Use `maxSteps` (which is `maxToolRoundtrips` + 1; if you set `maxToolRoundtrips` to 2, set `maxSteps` to 3) instead. This field will be removed in v0.6.
296
- */
297
- maxToolRoundtrips?: number | undefined;
298
- adapters?: {
299
- attachments?: AttachmentAdapter | undefined;
300
- speech?: SpeechSynthesisAdapter | undefined;
301
- feedback?: FeedbackAdapter | undefined;
302
- } | undefined;
303
- };
304
-
305
313
  declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
306
314
  private runtime;
307
315
  private endEditCallback;
308
316
  get canCancel(): boolean;
317
+ protected getAttachmentAdapter(): AttachmentAdapter | undefined;
309
318
  private _nonTextParts;
310
319
  private _previousText;
311
320
  private _parentId;
312
- constructor(runtime: Omit<ThreadRuntimeCore, "composer">, endEditCallback: () => void, { parentId, message }: {
321
+ constructor(runtime: Omit<ThreadRuntimeCore, "composer"> & {
322
+ adapters?: {
323
+ attachments?: AttachmentAdapter | undefined;
324
+ } | undefined;
325
+ }, endEditCallback: () => void, { parentId, message }: {
313
326
  parentId: string | null;
314
327
  message: ThreadMessage;
315
328
  });
@@ -317,52 +330,80 @@ declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
317
330
  cancel(): Promise<void>;
318
331
  }
319
332
 
320
- declare class LocalThreadRuntimeCore implements ThreadRuntimeCore {
333
+ type BaseThreadAdapters = {
334
+ speech?: SpeechSynthesisAdapter | undefined;
335
+ feedback?: FeedbackAdapter | undefined;
336
+ attachments?: AttachmentAdapter | undefined;
337
+ };
338
+ declare abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
321
339
  private configProvider;
322
- adapter: ChatModelAdapter;
323
340
  private _subscriptions;
324
- private abortController;
325
- private readonly repository;
341
+ protected readonly repository: MessageRepository;
342
+ abstract get adapters(): BaseThreadAdapters | undefined;
343
+ abstract get threadId(): string;
344
+ abstract get isDisabled(): boolean;
345
+ abstract get suggestions(): readonly ThreadSuggestion[];
346
+ abstract get extras(): unknown;
347
+ abstract get capabilities(): RuntimeCapabilities;
348
+ abstract append(message: AppendMessage): void;
349
+ abstract startRun(parentId: string | null): void;
350
+ abstract addToolResult(options: AddToolResultOptions): void;
351
+ abstract cancelRun(): void;
352
+ get messages(): ThreadMessage[];
353
+ readonly composer: DefaultThreadComposerRuntimeCore;
354
+ constructor(configProvider: ModelConfigProvider);
355
+ getModelConfig(): ModelConfig;
356
+ private _editComposers;
357
+ getEditComposer(messageId: string): DefaultEditComposerRuntimeCore | undefined;
358
+ beginEdit(messageId: string): void;
359
+ getBranches(messageId: string): string[];
360
+ switchToBranch(branchId: string): void;
361
+ protected notifySubscribers(): void;
362
+ subscribe(callback: () => void): Unsubscribe;
363
+ private _submittedFeedback;
364
+ getSubmittedFeedback(messageId: string): Readonly<{
365
+ type: "negative" | "positive";
366
+ }> | undefined;
367
+ submitFeedback({ messageId, type }: SubmitFeedbackOptions): void;
368
+ private _stopSpeaking;
369
+ speech: SpeechState | undefined;
370
+ speak(messageId: string): void;
371
+ stopSpeaking(): void;
372
+ export(): ExportedMessageRepository;
373
+ import(data: ExportedMessageRepository): void;
374
+ }
375
+
376
+ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements ThreadRuntimeCore {
377
+ adapter: ChatModelAdapter;
326
378
  readonly capabilities: {
327
379
  switchToBranch: boolean;
328
380
  edit: boolean;
329
381
  reload: boolean;
330
382
  cancel: boolean;
331
383
  unstable_copy: boolean;
332
- speak: boolean;
384
+ speech: boolean;
333
385
  attachments: boolean;
334
386
  feedback: boolean;
335
387
  };
388
+ private abortController;
336
389
  readonly threadId: string;
337
390
  readonly isDisabled = false;
338
391
  readonly suggestions: readonly ThreadSuggestion[];
339
- get messages(): ThreadMessage[];
340
- readonly composer: DefaultThreadComposerRuntimeCore;
392
+ get adapters(): {
393
+ attachments?: AttachmentAdapter | undefined;
394
+ speech?: SpeechSynthesisAdapter | undefined;
395
+ feedback?: FeedbackAdapter | undefined;
396
+ } | undefined;
341
397
  constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
342
- getModelConfig(): ModelConfig;
343
398
  private _options;
344
399
  get options(): LocalRuntimeOptions;
345
400
  get extras(): undefined;
346
401
  set options({ initialMessages, ...options }: LocalRuntimeOptions);
347
- private _editComposers;
348
- getEditComposer(messageId: string): DefaultEditComposerRuntimeCore | undefined;
349
- beginEdit(messageId: string): void;
350
- getBranches(messageId: string): string[];
351
- switchToBranch(branchId: string): void;
352
402
  append(message: AppendMessage): Promise<void>;
353
403
  startRun(parentId: string | null): Promise<void>;
354
404
  private performRoundtrip;
355
405
  cancelRun(): void;
356
- private notifySubscribers;
357
- subscribe(callback: () => void): Unsubscribe;
358
406
  addToolResult({ messageId, toolCallId, result, }: AddToolResultOptions): void;
359
- private _stopSpeaking;
360
- speech: SpeechState | null;
361
- speak(messageId: string): void;
362
- stopSpeaking(): void;
363
- submitFeedback({ messageId, type }: SubmitFeedbackOptions): void;
364
- export(): ExportedMessageRepository;
365
- import(data: ExportedMessageRepository): void;
366
407
  }
367
408
 
368
409
  declare class LocalRuntimeCore extends BaseAssistantRuntimeCore<LocalThreadRuntimeCore> {
@@ -390,10 +431,11 @@ type AssistantRuntime = {
390
431
  */
391
432
  subscribe(callback: () => void): Unsubscribe;
392
433
  };
393
- declare class AssistantRuntimeImpl<TThreadRuntime extends ThreadRuntime = ThreadRuntime> implements AssistantRuntimeCore, AssistantRuntime {
394
- private _core;
395
- constructor(_core: AssistantRuntimeCore, CustomThreadRuntime: new (binding: ThreadRuntimeCoreBinding) => TThreadRuntime);
396
- readonly thread: TThreadRuntime;
434
+ declare class AssistantRuntimeImpl implements AssistantRuntimeCore, AssistantRuntime {
435
+ private readonly _core;
436
+ private readonly _thread;
437
+ protected constructor(_core: AssistantRuntimeCore, _thread: ThreadRuntime);
438
+ get thread(): ThreadRuntime;
397
439
  switchToNewThread(): void;
398
440
  switchToThread(threadId: string): void;
399
441
  /**
@@ -405,13 +447,13 @@ declare class AssistantRuntimeImpl<TThreadRuntime extends ThreadRuntime = Thread
405
447
  * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
406
448
  */
407
449
  subscribe(callback: () => void): Unsubscribe;
450
+ protected static createThreadRuntime(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): ThreadRuntime;
451
+ static create(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): AssistantRuntime;
408
452
  }
409
453
 
410
- declare class LocalRuntime extends AssistantRuntimeImpl {
411
- private core;
412
- constructor(core: LocalRuntimeCore);
413
- reset(options?: Parameters<LocalRuntimeCore["reset"]>[0]): void;
414
- }
454
+ type LocalRuntime = AssistantRuntime & {
455
+ reset: (options?: Parameters<LocalRuntimeCore["reset"]>[0]) => void;
456
+ };
415
457
  declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
416
458
 
417
459
  declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
@@ -504,10 +546,6 @@ type ExternalStoreAdapterBase<T> = {
504
546
  onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
505
547
  onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
506
548
  onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
507
- /**
508
- * @deprecated Provide a speech adapter to `ExternalStoreAdapter.adapters.speech` instead. This will be removed in 0.6.
509
- */
510
- onSpeak?: ((message: ThreadMessage) => SpeechSynthesisAdapter.Utterance) | undefined;
511
549
  convertMessage?: ExternalStoreMessageConverter<T> | undefined;
512
550
  adapters?: {
513
551
  attachments?: AttachmentAdapter | undefined;
@@ -520,30 +558,6 @@ type ExternalStoreAdapterBase<T> = {
520
558
  };
521
559
  type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
522
560
 
523
- declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntimeImpl<ThreadRuntimeImpl>;
524
-
525
- declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
526
-
527
- declare namespace useExternalMessageConverter {
528
- type Message = ThreadMessageLike | {
529
- role: "tool";
530
- toolCallId: string;
531
- toolName?: string | undefined;
532
- result: any;
533
- };
534
- type Callback<T> = (message: T) => Message | Message[];
535
- }
536
- declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
537
- callback: useExternalMessageConverter.Callback<T>;
538
- messages: T[];
539
- isRunning: boolean;
540
- }) => ThreadMessage[];
541
-
542
- type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
543
-
544
- type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
545
- declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => LocalRuntime;
546
-
547
561
  type Subscribable = {
548
562
  subscribe: (callback: () => void) => Unsubscribe;
549
563
  };
@@ -586,7 +600,6 @@ type LegacyThreadComposerState = Readonly<{
586
600
  value: string;
587
601
  /** @deprecated Use `useComposerRuntime().setText` instead. This will be removed in 0.6.0. */
588
602
  setValue: (value: string) => void;
589
- attachmentAccept: string;
590
603
  attachments: readonly Attachment[];
591
604
  /** @deprecated Use `useComposerRuntime().addAttachment` instead. This will be removed in 0.6.0. */
592
605
  addAttachment: (file: File) => Promise<void>;
@@ -613,7 +626,6 @@ type LegacyThreadComposerState = Readonly<{
613
626
  }>;
614
627
  type BaseComposerState = {
615
628
  text: string;
616
- attachmentAccept: string;
617
629
  attachments: readonly Attachment[];
618
630
  canCancel: boolean;
619
631
  isEditing: boolean;
@@ -638,14 +650,13 @@ type ComposerRuntime = {
638
650
  readonly canCancel: boolean;
639
651
  /** @deprecated Use `getState().text` instead. This will be removed in 0.6.0. */
640
652
  readonly text: string;
641
- /** @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0. */
642
- readonly attachmentAccept: string;
643
653
  /** @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0. */
644
654
  readonly attachments: readonly Attachment[];
645
655
  /** @deprecated Use `getState().text` instead. This will be removed in 0.6.0. */
646
656
  readonly value: string;
647
657
  setText(text: string): void;
648
658
  setValue(text: string): void;
659
+ getAttachmentAccept(): string;
649
660
  addAttachment(file: File): Promise<void>;
650
661
  /** @deprecated Use `getAttachmentById(id).removeAttachment()` instead. This will be removed in 0.6.0. */
651
662
  removeAttachment(attachmentId: string): Promise<void>;
@@ -676,10 +687,6 @@ declare abstract class ComposerRuntimeImpl implements ComposerRuntimeCore, Compo
676
687
  * @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
677
688
  */
678
689
  get text(): string;
679
- /**
680
- * @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
681
- */
682
- get attachmentAccept(): string;
683
690
  /**
684
691
  * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
685
692
  */
@@ -703,6 +710,7 @@ declare abstract class ComposerRuntimeImpl implements ComposerRuntimeCore, Compo
703
710
  send(): void;
704
711
  cancel(): void;
705
712
  subscribe(callback: () => void): Unsubscribe;
713
+ getAttachmentAccept(): string;
706
714
  abstract getAttachmentByIndex(idx: number): AttachmentRuntime;
707
715
  }
708
716
  type ThreadComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentByIndex"> & {
@@ -837,7 +845,8 @@ type MessageState = ThreadMessage & {
837
845
  branches: readonly string[];
838
846
  branchNumber: number;
839
847
  branchCount: number;
840
- speech: SpeechState | null;
848
+ speech: SpeechState | undefined;
849
+ submittedFeedback: SubmittedFeedback | undefined;
841
850
  };
842
851
  type MessageStateBinding = SubscribableWithState<MessageState>;
843
852
  type MessageRuntime = {
@@ -880,6 +889,30 @@ declare class MessageRuntimeImpl implements MessageRuntime {
880
889
  getAttachmentByIndex(idx: number): MessageAttachmentRuntimeImpl;
881
890
  }
882
891
 
892
+ declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntime;
893
+
894
+ declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
895
+
896
+ declare namespace useExternalMessageConverter {
897
+ type Message = ThreadMessageLike | {
898
+ role: "tool";
899
+ toolCallId: string;
900
+ toolName?: string | undefined;
901
+ result: any;
902
+ };
903
+ type Callback<T> = (message: T) => Message | Message[];
904
+ }
905
+ declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
906
+ callback: useExternalMessageConverter.Callback<T>;
907
+ messages: T[];
908
+ isRunning: boolean;
909
+ }) => ThreadMessage[];
910
+
911
+ type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
912
+
913
+ type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
914
+ declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => LocalRuntime;
915
+
883
916
  type CreateAppendMessage = string | {
884
917
  parentId?: string | null | undefined;
885
918
  role?: AppendMessage["role"] | undefined;
@@ -895,7 +928,7 @@ type ThreadState = Readonly<{
895
928
  messages: readonly ThreadMessage[];
896
929
  suggestions: readonly ThreadSuggestion[];
897
930
  extras: unknown;
898
- speech: SpeechState | null;
931
+ speech: SpeechState | undefined;
899
932
  }>;
900
933
  type ThreadRuntime = {
901
934
  composer: ThreadComposerRuntime;
@@ -940,7 +973,7 @@ type ThreadRuntime = {
940
973
  /**
941
974
  * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
942
975
  */
943
- speech: SpeechState | null;
976
+ speech: SpeechState | undefined;
944
977
  /**
945
978
  * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
946
979
  */
@@ -961,6 +994,10 @@ type ThreadRuntime = {
961
994
  * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
962
995
  */
963
996
  speak: (messageId: string) => void;
997
+ /**
998
+ * @deprecated Use `getMesssageById(id).getState().submittedFeedback` instead. This will be removed in 0.6.0.
999
+ */
1000
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
964
1001
  /**
965
1002
  * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
966
1003
  */
@@ -996,7 +1033,7 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
996
1033
  reload: boolean;
997
1034
  cancel: boolean;
998
1035
  unstable_copy: boolean;
999
- speak: boolean;
1036
+ speech: boolean;
1000
1037
  attachments: boolean;
1001
1038
  feedback: boolean;
1002
1039
  }>;
@@ -1018,7 +1055,7 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1018
1055
  get speech(): Readonly<{
1019
1056
  messageId: string;
1020
1057
  status: SpeechSynthesisAdapter.Status;
1021
- }> | null;
1058
+ }> | undefined;
1022
1059
  unstable_getCore(): Readonly<{
1023
1060
  getBranches: (messageId: string) => readonly string[];
1024
1061
  switchToBranch: (branchId: string) => void;
@@ -1028,12 +1065,13 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1028
1065
  addToolResult: (options: AddToolResultOptions) => void;
1029
1066
  speak: (messageId: string) => void;
1030
1067
  stopSpeaking: () => void;
1068
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1031
1069
  submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1032
1070
  getModelConfig: () => ModelConfig;
1033
1071
  composer: ThreadComposerRuntimeCore;
1034
1072
  getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1035
1073
  beginEdit: (messageId: string) => void;
1036
- speech: SpeechState | null;
1074
+ speech: SpeechState | undefined;
1037
1075
  capabilities: Readonly<RuntimeCapabilities>;
1038
1076
  threadId: string;
1039
1077
  isDisabled: boolean;
@@ -1055,7 +1093,7 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1055
1093
  messages: readonly ThreadMessage[];
1056
1094
  suggestions: readonly ThreadSuggestion[];
1057
1095
  extras: unknown;
1058
- speech: SpeechState | null;
1096
+ speech: SpeechState | undefined;
1059
1097
  }>;
1060
1098
  append(message: CreateAppendMessage): void;
1061
1099
  subscribe(callback: () => void): Unsubscribe;
@@ -1079,6 +1117,9 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1079
1117
  */
1080
1118
  speak(messageId: string): void;
1081
1119
  stopSpeaking(): void;
1120
+ getSubmittedFeedback(messageId: string): Readonly<{
1121
+ type: "negative" | "positive";
1122
+ }> | undefined;
1082
1123
  /**
1083
1124
  * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
1084
1125
  */
@@ -1087,8 +1128,8 @@ declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1087
1128
  * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
1088
1129
  */
1089
1130
  getEditComposer(messageId: string): Readonly<{
1090
- attachmentAccept: string;
1091
1131
  attachments: readonly Attachment[];
1132
+ getAttachmentAccept(): string;
1092
1133
  addAttachment: (file: File) => Promise<void>;
1093
1134
  removeAttachment: (attachmentId: string) => Promise<void>;
1094
1135
  isEditing: boolean;
@@ -1188,10 +1229,6 @@ type MessageUtilsState = Readonly<{
1188
1229
  setIsCopied: (value: boolean) => void;
1189
1230
  isHovering: boolean;
1190
1231
  setIsHovering: (value: boolean) => void;
1191
- /** @deprecated This will be moved to `useMessage().submittedFeedback`. This will be removed in 0.6.0. */
1192
- submittedFeedback: "positive" | "negative" | null;
1193
- /** @deprecated This will be moved to `useMessageRuntime().submitFeedback()` instead. This will be removed in 0.6.0. */
1194
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1195
1232
  }>;
1196
1233
 
1197
1234
  type ThreadViewportState = Readonly<{
@@ -1360,7 +1397,7 @@ declare const useThread: {
1360
1397
  reload: boolean;
1361
1398
  cancel: boolean;
1362
1399
  unstable_copy: boolean;
1363
- speak: boolean;
1400
+ speech: boolean;
1364
1401
  attachments: boolean;
1365
1402
  feedback: boolean;
1366
1403
  }>;
@@ -1370,7 +1407,7 @@ declare const useThread: {
1370
1407
  speech: Readonly<{
1371
1408
  messageId: string;
1372
1409
  status: SpeechSynthesisAdapter.Status;
1373
- }> | null;
1410
+ }> | undefined;
1374
1411
  }>;
1375
1412
  <TSelected>(selector: (state: Readonly<{
1376
1413
  threadId: string;
@@ -1382,7 +1419,7 @@ declare const useThread: {
1382
1419
  reload: boolean;
1383
1420
  cancel: boolean;
1384
1421
  unstable_copy: boolean;
1385
- speak: boolean;
1422
+ speech: boolean;
1386
1423
  attachments: boolean;
1387
1424
  feedback: boolean;
1388
1425
  }>;
@@ -1392,7 +1429,7 @@ declare const useThread: {
1392
1429
  speech: Readonly<{
1393
1430
  messageId: string;
1394
1431
  status: SpeechSynthesisAdapter.Status;
1395
- }> | null;
1432
+ }> | undefined;
1396
1433
  }>) => TSelected): TSelected;
1397
1434
  (options: {
1398
1435
  optional: true;
@@ -1406,7 +1443,7 @@ declare const useThread: {
1406
1443
  reload: boolean;
1407
1444
  cancel: boolean;
1408
1445
  unstable_copy: boolean;
1409
- speak: boolean;
1446
+ speech: boolean;
1410
1447
  attachments: boolean;
1411
1448
  feedback: boolean;
1412
1449
  }>;
@@ -1416,7 +1453,7 @@ declare const useThread: {
1416
1453
  speech: Readonly<{
1417
1454
  messageId: string;
1418
1455
  status: SpeechSynthesisAdapter.Status;
1419
- }> | null;
1456
+ }> | undefined;
1420
1457
  }> | null;
1421
1458
  <TSelected>(options: {
1422
1459
  optional: true;
@@ -1430,7 +1467,7 @@ declare const useThread: {
1430
1467
  reload: boolean;
1431
1468
  cancel: boolean;
1432
1469
  unstable_copy: boolean;
1433
- speak: boolean;
1470
+ speech: boolean;
1434
1471
  attachments: boolean;
1435
1472
  feedback: boolean;
1436
1473
  }>;
@@ -1440,7 +1477,7 @@ declare const useThread: {
1440
1477
  speech: Readonly<{
1441
1478
  messageId: string;
1442
1479
  status: SpeechSynthesisAdapter.Status;
1443
- }> | null;
1480
+ }> | undefined;
1444
1481
  }>) => TSelected;
1445
1482
  }): TSelected | null;
1446
1483
  };
@@ -1455,7 +1492,7 @@ declare const useThreadStore: {
1455
1492
  reload: boolean;
1456
1493
  cancel: boolean;
1457
1494
  unstable_copy: boolean;
1458
- speak: boolean;
1495
+ speech: boolean;
1459
1496
  attachments: boolean;
1460
1497
  feedback: boolean;
1461
1498
  }>;
@@ -1465,7 +1502,7 @@ declare const useThreadStore: {
1465
1502
  speech: Readonly<{
1466
1503
  messageId: string;
1467
1504
  status: SpeechSynthesisAdapter.Status;
1468
- }> | null;
1505
+ }> | undefined;
1469
1506
  }>>;
1470
1507
  (options: {
1471
1508
  optional: true;
@@ -1479,7 +1516,7 @@ declare const useThreadStore: {
1479
1516
  reload: boolean;
1480
1517
  cancel: boolean;
1481
1518
  unstable_copy: boolean;
1482
- speak: boolean;
1519
+ speech: boolean;
1483
1520
  attachments: boolean;
1484
1521
  feedback: boolean;
1485
1522
  }>;
@@ -1489,7 +1526,7 @@ declare const useThreadStore: {
1489
1526
  speech: Readonly<{
1490
1527
  messageId: string;
1491
1528
  status: SpeechSynthesisAdapter.Status;
1492
- }> | null;
1529
+ }> | undefined;
1493
1530
  }>> | null;
1494
1531
  };
1495
1532
  /**
@@ -1617,16 +1654,12 @@ declare const useMessageUtils: {
1617
1654
  setIsCopied: (value: boolean) => void;
1618
1655
  isHovering: boolean;
1619
1656
  setIsHovering: (value: boolean) => void;
1620
- submittedFeedback: "positive" | "negative" | null;
1621
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1622
1657
  }>;
1623
1658
  <TSelected>(selector: (state: Readonly<{
1624
1659
  isCopied: boolean;
1625
1660
  setIsCopied: (value: boolean) => void;
1626
1661
  isHovering: boolean;
1627
1662
  setIsHovering: (value: boolean) => void;
1628
- submittedFeedback: "positive" | "negative" | null;
1629
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1630
1663
  }>) => TSelected): TSelected;
1631
1664
  (options: {
1632
1665
  optional: true;
@@ -1635,8 +1668,6 @@ declare const useMessageUtils: {
1635
1668
  setIsCopied: (value: boolean) => void;
1636
1669
  isHovering: boolean;
1637
1670
  setIsHovering: (value: boolean) => void;
1638
- submittedFeedback: "positive" | "negative" | null;
1639
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1640
1671
  }> | null;
1641
1672
  <TSelected>(options: {
1642
1673
  optional: true;
@@ -1645,8 +1676,6 @@ declare const useMessageUtils: {
1645
1676
  setIsCopied: (value: boolean) => void;
1646
1677
  isHovering: boolean;
1647
1678
  setIsHovering: (value: boolean) => void;
1648
- submittedFeedback: "positive" | "negative" | null;
1649
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1650
1679
  }>) => TSelected;
1651
1680
  }): TSelected | null;
1652
1681
  };
@@ -1656,8 +1685,6 @@ declare const useMessageUtilsStore: {
1656
1685
  setIsCopied: (value: boolean) => void;
1657
1686
  isHovering: boolean;
1658
1687
  setIsHovering: (value: boolean) => void;
1659
- submittedFeedback: "positive" | "negative" | null;
1660
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1661
1688
  }>>;
1662
1689
  (options: {
1663
1690
  optional: true;
@@ -1666,8 +1693,6 @@ declare const useMessageUtilsStore: {
1666
1693
  setIsCopied: (value: boolean) => void;
1667
1694
  isHovering: boolean;
1668
1695
  setIsHovering: (value: boolean) => void;
1669
- submittedFeedback: "positive" | "negative" | null;
1670
- setSubmittedFeedback: (feedback: "positive" | "negative" | null) => void;
1671
1696
  }>> | null;
1672
1697
  };
1673
1698
  declare const useEditComposer: {
@@ -1858,6 +1883,7 @@ type MessageIfFilters = {
1858
1883
  lastOrHover: boolean | undefined;
1859
1884
  speaking: boolean | undefined;
1860
1885
  hasAttachments: boolean | undefined;
1886
+ hasContent: boolean | undefined;
1861
1887
  submittedFeedback: "positive" | "negative" | null | undefined;
1862
1888
  };
1863
1889
  type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
@@ -2984,7 +3010,7 @@ declare const useSmoothStatus: {
2984
3010
  }): TSelected | null;
2985
3011
  };
2986
3012
 
2987
- type internal_AssistantRuntimeImpl<TThreadRuntime extends ThreadRuntime = ThreadRuntime> = AssistantRuntimeImpl<TThreadRuntime>;
3013
+ type internal_AssistantRuntimeImpl = AssistantRuntimeImpl;
2988
3014
  declare const internal_AssistantRuntimeImpl: typeof AssistantRuntimeImpl;
2989
3015
  type internal_BaseAssistantRuntimeCore<TThreadRuntime extends ThreadRuntimeCore> = BaseAssistantRuntimeCore<TThreadRuntime>;
2990
3016
  declare const internal_BaseAssistantRuntimeCore: typeof BaseAssistantRuntimeCore;