@assistant-ui/react 0.5.81 → 0.5.83

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Attachment$1, P as PendingAttachment, T as ThreadMessage, C as CoreMessage, a as AppendMessage, M as ModelConfig, b as ModelConfigProvider, c as ThreadAssistantContentPart, d as MessageStatus, e as ThreadStep, f as PendingAttachmentStatus, g as CompleteAttachment, h as CompleteAttachmentStatus, i as Tool, j as TextContentPart, I as ImageContentPart, k as ToolCallContentPart, l as CoreToolCallContentPart, U as UIContentPart, m as CreateEdgeRuntimeAPIOptions, n as ThreadUserContentPart, o as ContentPartStatus, p as ToolCallContentPartStatus } from './edge-rTP-G718.mjs';
2
- export { q as AttachmentStatus, v as CoreAssistantContentPart, y as CoreAssistantMessage, w as CoreSystemMessage, u as CoreUserContentPart, x as CoreUserMessage, E as EdgeRuntimeRequestOptions, s as ThreadAssistantMessage, r as ThreadSystemMessage, t as ThreadUserMessage } from './edge-rTP-G718.mjs';
1
+ import { A as Attachment$1, U as Unsubscribe, P as PendingAttachment, T as ThreadMessage, C as CoreMessage, a as AppendMessage, M as ModelConfig, b as ModelConfigProvider, c as ThreadAssistantContentPart, d as MessageStatus, e as ThreadStep, f as PendingAttachmentStatus, g as CompleteAttachment, h as CompleteAttachmentStatus, i as TextContentPart, j as Tool, I as ImageContentPart, k as ToolCallContentPart, l as CoreToolCallContentPart, m as UIContentPart, n as CreateEdgeRuntimeAPIOptions, o as ThreadUserContentPart, p as ContentPartStatus, q as ToolCallContentPartStatus } from './edge-B3YIacNl.mjs';
2
+ export { r as AttachmentStatus, w as CoreAssistantContentPart, z as CoreAssistantMessage, x as CoreSystemMessage, v as CoreUserContentPart, y as CoreUserMessage, E as EdgeRuntimeRequestOptions, t as ThreadAssistantMessage, s as ThreadSystemMessage, u as ThreadUserMessage } from './edge-B3YIacNl.mjs';
3
3
  import * as react from 'react';
4
4
  import { ComponentType, PropsWithChildren, FC, ElementRef, ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
5
5
  import { StoreApi, UseBoundStore } from 'zustand';
@@ -36,8 +36,6 @@ type ThreadComposerRuntimeCore = ComposerRuntimeCore & Readonly<{
36
36
  attachments: readonly PendingAttachment[];
37
37
  }>;
38
38
 
39
- type Unsubscribe = () => void;
40
-
41
39
  declare namespace SpeechSynthesisAdapter {
42
40
  type Status = {
43
41
  type: "starting" | "running";
@@ -53,11 +51,11 @@ declare namespace SpeechSynthesisAdapter {
53
51
  };
54
52
  }
55
53
  type SpeechSynthesisAdapter = {
56
- speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance;
54
+ speak: (text: string) => SpeechSynthesisAdapter.Utterance;
57
55
  };
58
56
 
59
57
  declare class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter {
60
- speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance;
58
+ speak(text: string): SpeechSynthesisAdapter.Utterance;
61
59
  }
62
60
 
63
61
  interface ExportedMessageRepository {
@@ -117,7 +115,12 @@ type SpeechState = Readonly<{
117
115
  type SubmittedFeedback = Readonly<{
118
116
  type: "negative" | "positive";
119
117
  }>;
118
+ type ThreadRuntimeEventType = "switched-to" | "switched-away" | "run-start" | "model-config-update";
120
119
  type ThreadRuntimeCore = Readonly<{
120
+ getMessageById: (messageId: string) => {
121
+ parentId: string | null;
122
+ message: ThreadMessage;
123
+ } | undefined;
121
124
  getBranches: (messageId: string) => readonly string[];
122
125
  switchToBranch: (branchId: string) => void;
123
126
  append: (message: AppendMessage) => void;
@@ -142,19 +145,29 @@ type ThreadRuntimeCore = Readonly<{
142
145
  subscribe: (callback: () => void) => Unsubscribe;
143
146
  import(repository: ExportedMessageRepository): void;
144
147
  export(): ExportedMessageRepository;
145
- unstable_on(event: "switched-to" | "run-start", callback: () => void): Unsubscribe;
148
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
146
149
  }>;
147
150
 
148
- type AssistantRuntimeCore = {
149
- readonly thread: ThreadRuntimeCore;
150
- switchToNewThread: () => void;
151
+ type ThreadManagerMetadata = {
152
+ threadId: string;
153
+ title?: string;
154
+ };
155
+ type ThreadManagerRuntimeCore = {
156
+ mainThread: ThreadRuntimeCore;
157
+ threads: readonly ThreadManagerMetadata[];
158
+ archivedThreads: readonly ThreadManagerMetadata[];
151
159
  switchToThread(threadId: string): void;
152
- /**
153
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
154
- */
155
- switchToThread(threadId: string | null): void;
160
+ switchToNewThread(): void;
161
+ rename(threadId: string, newTitle: string): Promise<void>;
162
+ archive(threadId: string): Promise<void>;
163
+ unarchive(threadId: string): Promise<void>;
164
+ delete(threadId: string): Promise<void>;
165
+ subscribe(callback: () => void): Unsubscribe;
166
+ };
167
+
168
+ type AssistantRuntimeCore = {
169
+ readonly threadManager: ThreadManagerRuntimeCore;
156
170
  registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
157
- subscribe: (callback: () => void) => Unsubscribe;
158
171
  };
159
172
 
160
173
  /**
@@ -191,26 +204,21 @@ type ChatModelAdapter = {
191
204
  run: (options: ChatModelRunOptions) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;
192
205
  };
193
206
 
194
- declare abstract class BaseAssistantRuntimeCore<TThreadRuntime extends ThreadRuntimeCore> implements AssistantRuntimeCore {
195
- private _thread;
196
- constructor(_thread: TThreadRuntime);
197
- get thread(): TThreadRuntime;
198
- set thread(thread: TThreadRuntime);
199
- abstract switchToNewThread(): void;
200
- abstract registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
201
- abstract switchToThread(threadId: string | null): void;
202
- private _subscriptions;
203
- subscribe(callback: () => void): Unsubscribe;
204
- private subscriptionHandler;
207
+ declare class ProxyConfigProvider implements ModelConfigProvider {
208
+ private _providers;
209
+ getModelConfig(): ModelConfig;
210
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
211
+ private _subscribers;
212
+ notifySubscribers(): void;
213
+ subscribe(callback: () => void): () => boolean;
205
214
  }
206
215
 
207
- type FeedbackAdapterFeedback = {
208
- message: ThreadMessage;
209
- type: "positive" | "negative";
210
- };
211
- type FeedbackAdapter = {
212
- submit: (feedback: FeedbackAdapterFeedback) => void;
213
- };
216
+ declare abstract class BaseAssistantRuntimeCore implements AssistantRuntimeCore {
217
+ protected readonly _proxyConfigProvider: ProxyConfigProvider;
218
+ abstract get threadManager(): ThreadManagerRuntimeCore;
219
+ constructor();
220
+ registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
221
+ }
214
222
 
215
223
  type AttachmentAdapter = {
216
224
  accept: string;
@@ -225,18 +233,30 @@ type AttachmentAdapter = {
225
233
  }>;
226
234
  };
227
235
 
228
- type LocalRuntimeOptions = {
229
- initialMessages?: readonly CoreMessage[] | undefined;
236
+ type FeedbackAdapterFeedback = {
237
+ message: ThreadMessage;
238
+ type: "positive" | "negative";
239
+ };
240
+ type FeedbackAdapter = {
241
+ submit: (feedback: FeedbackAdapterFeedback) => void;
242
+ };
243
+
244
+ type LocalRuntimeOptionsBase = {
230
245
  maxSteps?: number | undefined;
231
246
  /**
232
247
  * @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.
233
248
  */
234
249
  maxToolRoundtrips?: number | undefined;
235
- adapters?: {
250
+ adapters: {
251
+ chatModel: ChatModelAdapter;
236
252
  attachments?: AttachmentAdapter | undefined;
237
253
  speech?: SpeechSynthesisAdapter | undefined;
238
254
  feedback?: FeedbackAdapter | undefined;
239
- } | undefined;
255
+ };
256
+ };
257
+ type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, "adapters"> & {
258
+ initialMessages?: readonly CoreMessage[] | undefined;
259
+ adapters?: Omit<LocalRuntimeOptionsBase["adapters"], "chatModel"> | undefined;
240
260
  };
241
261
 
242
262
  declare class SimpleImageAttachmentAdapter implements AttachmentAdapter {
@@ -357,10 +377,14 @@ declare abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
357
377
  private _editComposers;
358
378
  getEditComposer(messageId: string): DefaultEditComposerRuntimeCore | undefined;
359
379
  beginEdit(messageId: string): void;
380
+ getMessageById(messageId: string): {
381
+ parentId: string | null;
382
+ message: ThreadMessage;
383
+ };
360
384
  getBranches(messageId: string): string[];
361
385
  switchToBranch(branchId: string): void;
362
386
  protected _notifySubscribers(): void;
363
- _notifyEventSubscribers(event: "switched-to" | "run-start"): void;
387
+ _notifyEventSubscribers(event: ThreadRuntimeEventType): void;
364
388
  subscribe(callback: () => void): Unsubscribe;
365
389
  private _submittedFeedback;
366
390
  getSubmittedFeedback(messageId: string): Readonly<{
@@ -374,11 +398,11 @@ declare abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
374
398
  export(): ExportedMessageRepository;
375
399
  import(data: ExportedMessageRepository): void;
376
400
  private _eventSubscribers;
377
- unstable_on(event: "switched-to" | "run-start", callback: () => void): () => void;
401
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
378
402
  }
379
403
 
380
404
  declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements ThreadRuntimeCore {
381
- adapter: ChatModelAdapter;
405
+ readonly threadId: string;
382
406
  readonly capabilities: {
383
407
  switchToBranch: boolean;
384
408
  edit: boolean;
@@ -390,19 +414,18 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
390
414
  feedback: boolean;
391
415
  };
392
416
  private abortController;
393
- readonly threadId: string;
394
417
  readonly isDisabled = false;
395
418
  readonly suggestions: readonly ThreadSuggestion[];
396
419
  get adapters(): {
420
+ chatModel: ChatModelAdapter;
397
421
  attachments?: AttachmentAdapter | undefined;
398
422
  speech?: SpeechSynthesisAdapter | undefined;
399
423
  feedback?: FeedbackAdapter | undefined;
400
- } | undefined;
401
- constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
424
+ };
425
+ constructor(configProvider: ModelConfigProvider, threadId: string, options: LocalRuntimeOptionsBase);
402
426
  private _options;
403
- get options(): LocalRuntimeOptions;
404
427
  get extras(): undefined;
405
- set options({ initialMessages, ...options }: LocalRuntimeOptions);
428
+ setOptions(options: LocalRuntimeOptionsBase): void;
406
429
  append(message: AppendMessage): Promise<void>;
407
430
  startRun(parentId: string | null): Promise<void>;
408
431
  private performRoundtrip;
@@ -410,167 +433,104 @@ declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements Th
410
433
  addToolResult({ messageId, toolCallId, result, }: AddToolResultOptions): void;
411
434
  }
412
435
 
413
- declare class LocalRuntimeCore extends BaseAssistantRuntimeCore<LocalThreadRuntimeCore> {
414
- private readonly _proxyConfigProvider;
415
- constructor(adapter: ChatModelAdapter, options: LocalRuntimeOptions);
416
- registerModelConfigProvider(provider: ModelConfigProvider): () => void;
417
- switchToNewThread(): void;
418
- switchToThread(threadId: string | null): void;
419
- reset({ initialMessages, }?: {
420
- initialMessages?: readonly CoreMessage[] | undefined;
421
- }): void;
422
- }
423
-
424
- type AssistantRuntime = {
425
- thread: ThreadRuntime;
426
- switchToNewThread(): void;
436
+ type LocalThreadFactory = (threadId: string, data: ExportedMessageRepository) => LocalThreadRuntimeCore;
437
+ declare class LocalThreadManagerRuntimeCore implements ThreadManagerRuntimeCore {
438
+ private _threadFactory;
439
+ private _threadData;
440
+ private _threads;
441
+ private _archivedThreads;
442
+ get threads(): readonly ThreadManagerMetadata[];
443
+ get archivedThreads(): readonly ThreadManagerMetadata[];
444
+ private _mainThread;
445
+ get mainThread(): LocalThreadRuntimeCore;
446
+ constructor(_threadFactory: LocalThreadFactory);
427
447
  switchToThread(threadId: string): void;
428
- /**
429
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
430
- */
431
- switchToThread(threadId: string | null): void;
432
- registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
433
- /**
434
- * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
435
- */
436
- subscribe(callback: () => void): Unsubscribe;
437
- };
438
- declare class AssistantRuntimeImpl implements AssistantRuntimeCore, AssistantRuntime {
439
- private readonly _core;
440
- private readonly _thread;
441
- protected constructor(_core: AssistantRuntimeCore, _thread: ThreadRuntime);
442
- get thread(): ThreadRuntime;
443
448
  switchToNewThread(): void;
444
- switchToThread(threadId: string): void;
445
- /**
446
- * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
447
- */
448
- switchToThread(threadId: string | null): void;
449
- registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
450
- /**
451
- * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
452
- */
449
+ private _performThreadSwitch;
450
+ private _performMoveOp;
451
+ rename(threadId: string, newTitle: string): Promise<void>;
452
+ archive(threadId: string): Promise<void>;
453
+ unarchive(threadId: string): Promise<void>;
454
+ delete(threadId: string): Promise<void>;
455
+ private _subscriptions;
453
456
  subscribe(callback: () => void): Unsubscribe;
454
- protected static createThreadRuntime(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): ThreadRuntime;
455
- static create(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): AssistantRuntime;
457
+ private _notifySubscribers;
456
458
  }
457
459
 
458
- type LocalRuntime = AssistantRuntime & {
459
- reset: (options?: Parameters<LocalRuntimeCore["reset"]>[0]) => void;
460
- };
461
- declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
462
-
463
- declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
464
-
465
- type fromLanguageModelMessagesOptions = {
466
- mergeSteps: boolean;
467
- };
468
- declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeSteps }: fromLanguageModelMessagesOptions) => CoreMessage[];
469
-
470
- declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
471
- declare const fromCoreMessage: (message: CoreMessage, { id, status, attachments, }?: {
472
- id?: string | undefined;
473
- status?: MessageStatus | undefined;
474
- attachments?: readonly CompleteAttachment[] | undefined;
475
- }) => ThreadMessage;
476
-
477
- declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
478
- declare const toCoreMessage: (message: ThreadMessage) => CoreMessage;
479
-
480
- declare const fromLanguageModelTools: (tools: LanguageModelV1FunctionTool[]) => Record<string, Tool<any, any>>;
481
-
482
- declare const toLanguageModelTools: (tools: Record<string, Tool<any, any>>) => LanguageModelV1FunctionTool[];
483
-
484
- declare class PipeableTransformStream<I, O> extends TransformStream<I, O> {
485
- constructor(transform: (readable: ReadableStream<I>) => ReadableStream<O>);
460
+ declare class LocalRuntimeCore extends BaseAssistantRuntimeCore {
461
+ readonly threadManager: LocalThreadManagerRuntimeCore;
462
+ private _options;
463
+ constructor(options: LocalRuntimeOptionsBase, initialMessages?: CoreMessage[]);
464
+ setOptions(options: LocalRuntimeOptionsBase): void;
465
+ reset({ initialMessages, }?: {
466
+ initialMessages?: readonly CoreMessage[] | undefined;
467
+ }): void;
486
468
  }
487
469
 
488
- type StreamPart<T extends Record<string, unknown>> = {
489
- [K in keyof T]: {
490
- type: K;
491
- value: T[K];
492
- };
493
- }[keyof T];
494
-
495
- declare function streamPartDecoderStream<T extends Record<string, unknown>>(): PipeableTransformStream<unknown, StreamPart<T>>;
496
-
497
- declare function streamPartEncoderStream<T extends Record<string, unknown>>(): PipeableTransformStream<unknown, Uint8Array>;
498
-
499
- declare namespace StreamUtils {
500
- export type { StreamPart };
501
- }
502
- /**
503
- * @deprecated `streamUtils` will be replaced with `assistant-stream` once it is ready.
504
- */
505
- declare const streamUtils: {
506
- streamPartEncoderStream: typeof streamPartEncoderStream;
507
- streamPartDecoderStream: typeof streamPartDecoderStream;
470
+ type Subscribable = {
471
+ subscribe: (callback: () => void) => Unsubscribe;
508
472
  };
509
-
510
- type EdgeChatAdapterOptions = {
511
- api: string;
512
- credentials?: RequestCredentials;
513
- headers?: Record<string, string> | Headers;
514
- body?: object;
473
+ type SubscribableWithState<TState, TPath> = Subscribable & {
474
+ path: TPath;
475
+ getState: () => TState;
515
476
  };
516
- declare class EdgeChatAdapter implements ChatModelAdapter {
517
- private options;
518
- constructor(options: EdgeChatAdapterOptions);
519
- run({ messages, abortSignal, config }: ChatModelRunOptions): AsyncGenerator<ChatModelRunResult, void, unknown>;
520
- }
521
-
522
- type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
523
- declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => LocalRuntime;
524
477
 
525
- type ThreadMessageLike = {
526
- role: "assistant" | "user" | "system";
527
- content: string | (TextContentPart | ImageContentPart | ToolCallContentPart<any, any> | CoreToolCallContentPart<any, any> | UIContentPart)[];
528
- id?: string | undefined;
529
- createdAt?: Date | undefined;
530
- status?: MessageStatus | undefined;
531
- attachments?: CompleteAttachment[] | undefined;
478
+ type ThreadManagerRuntimePath = {
479
+ ref: string;
532
480
  };
533
-
534
- type ExternalStoreMessageConverter<T> = (message: T, idx: number) => ThreadMessageLike;
535
- type ExternalStoreMessageConverterAdapter<T> = {
536
- convertMessage: ExternalStoreMessageConverter<T>;
481
+ type ThreadRuntimePath = {
482
+ ref: string;
483
+ threadSelector: {
484
+ type: "main";
485
+ };
537
486
  };
538
- type ExternalStoreAdapterBase<T> = {
539
- threadId?: string | undefined;
540
- isDisabled?: boolean | undefined;
541
- isRunning?: boolean | undefined;
542
- messages: T[];
543
- suggestions?: readonly ThreadSuggestion[] | undefined;
544
- extras?: unknown;
545
- setMessages?: ((messages: T[]) => void) | undefined;
546
- onNew: (message: AppendMessage) => Promise<void>;
547
- onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
548
- onReload?: ((parentId: string | null) => Promise<void>) | undefined;
549
- onCancel?: (() => Promise<void>) | undefined;
550
- onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
551
- onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
552
- onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
553
- convertMessage?: ExternalStoreMessageConverter<T> | undefined;
554
- adapters?: {
555
- attachments?: AttachmentAdapter | undefined;
556
- speech?: SpeechSynthesisAdapter | undefined;
557
- feedback?: FeedbackAdapter | undefined;
487
+ type MessageRuntimePath = ThreadRuntimePath & {
488
+ messageSelector: {
489
+ type: "messageId";
490
+ messageId: string;
491
+ } | {
492
+ type: "index";
493
+ index: number;
558
494
  };
559
- unstable_capabilities?: {
560
- copy?: boolean | undefined;
561
- } | undefined;
562
495
  };
563
- type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
564
-
565
- type Subscribable = {
566
- subscribe: (callback: () => void) => Unsubscribe;
496
+ type ContentPartRuntimePath = MessageRuntimePath & {
497
+ contentPartSelector: {
498
+ type: "index";
499
+ index: number;
500
+ } | {
501
+ type: "toolCallId";
502
+ toolCallId: string;
503
+ };
567
504
  };
568
- type SubscribableWithState<TState> = Subscribable & {
569
- getState: () => TState;
505
+ type AttachmentRuntimePath = ((MessageRuntimePath & {
506
+ attachmentSource: "message" | "edit-composer";
507
+ }) | (ThreadRuntimePath & {
508
+ attachmentSource: "thread-composer";
509
+ })) & {
510
+ attachmentSelector: {
511
+ type: "index";
512
+ index: number;
513
+ } | {
514
+ type: "index";
515
+ index: number;
516
+ } | {
517
+ type: "index";
518
+ index: number;
519
+ };
570
520
  };
571
-
572
- type ThreadComposerRuntimeCoreBinding = SubscribableWithState<ThreadComposerRuntimeCore | undefined>;
573
- type ComposerRuntimeCoreBinding = SubscribableWithState<ComposerRuntimeCore | undefined>;
521
+ type ComposerRuntimePath = (ThreadRuntimePath & {
522
+ composerSource: "thread";
523
+ }) | (MessageRuntimePath & {
524
+ composerSource: "edit";
525
+ });
526
+
527
+ type ThreadComposerRuntimeCoreBinding = SubscribableWithState<ThreadComposerRuntimeCore | undefined, ComposerRuntimePath & {
528
+ composerSource: "thread";
529
+ }>;
530
+ type EditComposerRuntimeCoreBinding = SubscribableWithState<ComposerRuntimeCore | undefined, ComposerRuntimePath & {
531
+ composerSource: "edit";
532
+ }>;
533
+ type ComposerRuntimeCoreBinding = SubscribableWithState<ComposerRuntimeCore | undefined, ComposerRuntimePath>;
574
534
  type LegacyEditComposerState = Readonly<{
575
535
  type: "edit";
576
536
  /** @deprecated Use `text` instead. This will be removed in 0.6.0. */
@@ -640,6 +600,7 @@ type EditComposerState = LegacyEditComposerState & BaseComposerState & {
640
600
  };
641
601
  type ComposerState = ThreadComposerState | EditComposerState;
642
602
  type ComposerRuntime = {
603
+ path: ComposerRuntimePath;
643
604
  readonly type: "edit" | "thread";
644
605
  getState(): ComposerState;
645
606
  /** @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0. */
@@ -669,6 +630,7 @@ type ComposerRuntime = {
669
630
  };
670
631
  declare abstract class ComposerRuntimeImpl implements ComposerRuntimeCore, ComposerRuntime {
671
632
  protected _core: ComposerRuntimeCoreBinding;
633
+ get path(): ComposerRuntimePath;
672
634
  abstract get type(): "edit" | "thread";
673
635
  constructor(_core: ComposerRuntimeCoreBinding);
674
636
  /**
@@ -714,6 +676,9 @@ declare abstract class ComposerRuntimeImpl implements ComposerRuntimeCore, Compo
714
676
  abstract getAttachmentByIndex(idx: number): AttachmentRuntime;
715
677
  }
716
678
  type ThreadComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentByIndex"> & {
679
+ readonly path: ComposerRuntimePath & {
680
+ composerSource: "thread";
681
+ };
717
682
  readonly type: "thread";
718
683
  getState(): ThreadComposerState;
719
684
  /**
@@ -725,6 +690,9 @@ type ThreadComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentBy
725
690
  };
726
691
  };
727
692
  declare class ThreadComposerRuntimeImpl extends ComposerRuntimeImpl implements ThreadComposerRuntime, ThreadComposerState {
693
+ get path(): ComposerRuntimePath & {
694
+ composerSource: "thread";
695
+ };
728
696
  get type(): "thread";
729
697
  private _getState;
730
698
  constructor(core: ThreadComposerRuntimeCoreBinding);
@@ -733,6 +701,9 @@ declare class ThreadComposerRuntimeImpl extends ComposerRuntimeImpl implements T
733
701
  getAttachmentByIndex(idx: number): ThreadComposerAttachmentRuntimeImpl;
734
702
  }
735
703
  type EditComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentByIndex"> & {
704
+ readonly path: ComposerRuntimePath & {
705
+ composerSource: "edit";
706
+ };
736
707
  readonly type: "edit";
737
708
  getState(): EditComposerState;
738
709
  beginEdit(): void;
@@ -746,9 +717,12 @@ type EditComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentByIn
746
717
  };
747
718
  declare class EditComposerRuntimeImpl extends ComposerRuntimeImpl implements EditComposerRuntime, EditComposerState {
748
719
  private _beginEdit;
720
+ get path(): ComposerRuntimePath & {
721
+ composerSource: "edit";
722
+ };
749
723
  get type(): "edit";
750
724
  private _getState;
751
- constructor(core: ComposerRuntimeCoreBinding, _beginEdit: () => void);
725
+ constructor(core: EditComposerRuntimeCoreBinding, _beginEdit: () => void);
752
726
  getState(): EditComposerState;
753
727
  beginEdit(): void;
754
728
  /**
@@ -782,9 +756,14 @@ type EditComposerAttachmentState = Attachment$1 & {
782
756
  type AttachmentState = ThreadComposerAttachmentState | EditComposerAttachmentState | MessageAttachmentState;
783
757
  type AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> = SubscribableWithState<AttachmentState & {
784
758
  source: Source;
759
+ }, AttachmentRuntimePath & {
760
+ attachmentSource: Source;
785
761
  }>;
786
762
  type AttachmentRuntimeSource = AttachmentState["source"];
787
763
  type AttachmentRuntime<TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource> = {
764
+ path: AttachmentRuntimePath & {
765
+ attachmentSource: TSource;
766
+ };
788
767
  readonly source: TSource;
789
768
  getState(): AttachmentState & {
790
769
  source: TSource;
@@ -794,6 +773,9 @@ type AttachmentRuntime<TSource extends AttachmentRuntimeSource = AttachmentRunti
794
773
  };
795
774
  declare abstract class AttachmentRuntimeImpl<Source extends AttachmentRuntimeSource = AttachmentRuntimeSource> implements AttachmentRuntime {
796
775
  private _core;
776
+ get path(): AttachmentRuntimePath & {
777
+ attachmentSource: Source;
778
+ };
797
779
  abstract get source(): Source;
798
780
  constructor(_core: AttachmentSnapshotBinding<Source>);
799
781
  getState(): AttachmentState & {
@@ -832,15 +814,25 @@ type MessageState = ThreadMessage & {
832
814
  branches: readonly string[];
833
815
  branchNumber: number;
834
816
  branchCount: number;
817
+ /**
818
+ * @deprecated This API is still under active development and might change without notice.
819
+ */
835
820
  speech: SpeechState | undefined;
836
821
  submittedFeedback: SubmittedFeedback | undefined;
837
822
  };
838
- type MessageStateBinding = SubscribableWithState<MessageState>;
823
+ type MessageStateBinding = SubscribableWithState<MessageState, MessageRuntimePath>;
839
824
  type MessageRuntime = {
840
- composer: EditComposerRuntime;
825
+ readonly path: MessageRuntimePath;
826
+ readonly composer: EditComposerRuntime;
841
827
  getState(): MessageState;
842
828
  reload(): void;
829
+ /**
830
+ * @deprecated This API is still under active development and might change without notice.
831
+ */
843
832
  speak(): void;
833
+ /**
834
+ * @deprecated This API is still under active development and might change without notice.
835
+ */
844
836
  stopSpeaking(): void;
845
837
  submitFeedback({ type }: {
846
838
  type: "positive" | "negative";
@@ -849,8 +841,10 @@ type MessageRuntime = {
849
841
  position?: "previous" | "next" | undefined;
850
842
  branchId?: string | undefined;
851
843
  }): void;
844
+ unstable_getCopyText(): string;
852
845
  subscribe(callback: () => void): Unsubscribe;
853
846
  getContentPartByIndex(idx: number): ContentPartRuntime;
847
+ getContentPartByToolCallId(toolCallId: string): ContentPartRuntime;
854
848
  getAttachmentByIndex(idx: number): AttachmentRuntime & {
855
849
  source: "message";
856
850
  };
@@ -858,6 +852,7 @@ type MessageRuntime = {
858
852
  declare class MessageRuntimeImpl implements MessageRuntime {
859
853
  private _core;
860
854
  private _threadBinding;
855
+ get path(): MessageRuntimePath;
861
856
  constructor(_core: MessageStateBinding, _threadBinding: ThreadRuntimeCoreBinding);
862
857
  composer: EditComposerRuntimeImpl;
863
858
  getState(): MessageState;
@@ -871,346 +866,734 @@ declare class MessageRuntimeImpl implements MessageRuntime {
871
866
  position?: "previous" | "next" | undefined;
872
867
  branchId?: string | undefined;
873
868
  }): void;
869
+ unstable_getCopyText(): string;
874
870
  subscribe(callback: () => void): Unsubscribe;
875
871
  getContentPartByIndex(idx: number): ContentPartRuntimeImpl;
872
+ getContentPartByToolCallId(toolCallId: string): ContentPartRuntimeImpl;
876
873
  getAttachmentByIndex(idx: number): MessageAttachmentRuntimeImpl;
877
874
  }
878
875
 
879
- declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntime;
880
-
881
- declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
882
-
883
- declare namespace useExternalMessageConverter {
884
- type Message = ThreadMessageLike | {
885
- role: "tool";
886
- toolCallId: string;
887
- toolName?: string | undefined;
888
- result: any;
889
- };
890
- type Callback<T> = (message: T) => Message | Message[];
891
- }
892
- declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
893
- callback: useExternalMessageConverter.Callback<T>;
894
- messages: T[];
895
- isRunning: boolean;
896
- }) => ThreadMessage[];
897
-
898
- type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
899
-
900
- type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
901
- declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => LocalRuntime;
876
+ declare const buttonVariants: (props?: ({
877
+ variant?: "default" | "outline" | "ghost" | null | undefined;
878
+ size?: "default" | "icon" | null | undefined;
879
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
880
+ type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
902
881
 
903
- type CreateAppendMessage = string | {
904
- parentId?: string | null | undefined;
905
- role?: AppendMessage["role"] | undefined;
906
- content: AppendMessage["content"];
907
- attachments?: AppendMessage["attachments"] | undefined;
882
+ type TooltipIconButtonProps = ButtonProps & {
883
+ tooltip: string;
884
+ side?: "top" | "bottom" | "left" | "right";
908
885
  };
909
- type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore> & {
910
- outerSubscribe(callback: () => void): Unsubscribe;
886
+ declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
887
+ 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;
888
+ } & {
889
+ asChild?: boolean;
890
+ }, "ref"> & class_variance_authority.VariantProps<(props?: ({
891
+ variant?: "default" | "outline" | "ghost" | null | undefined;
892
+ size?: "default" | "icon" | null | undefined;
893
+ } & class_variance_authority_types.ClassProp) | undefined) => string> & {
894
+ tooltip: string;
895
+ side?: "top" | "bottom" | "left" | "right";
896
+ } & react.RefAttributes<HTMLButtonElement>>;
897
+
898
+ declare const generateId: (size?: number) => string;
899
+
900
+ declare const useSmooth: (state: ContentPartState & TextContentPart, smooth?: boolean) => ContentPartState & TextContentPart;
901
+
902
+ type ReadonlyStore<T> = Omit<StoreApi<T>, "setState" | "destroy">;
903
+
904
+ declare const withSmoothContextProvider: <C extends ComponentType<any>>(Component: C) => C;
905
+ declare const useSmoothStatus: {
906
+ (): {
907
+ type: "running";
908
+ } | {
909
+ type: "complete";
910
+ } | {
911
+ type: "incomplete";
912
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
913
+ error?: unknown;
914
+ } | {
915
+ type: "requires-action";
916
+ reason: "tool-calls";
917
+ };
918
+ <TSelected>(selector: (state: {
919
+ type: "running";
920
+ } | {
921
+ type: "complete";
922
+ } | {
923
+ type: "incomplete";
924
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
925
+ error?: unknown;
926
+ } | {
927
+ type: "requires-action";
928
+ reason: "tool-calls";
929
+ }) => TSelected): TSelected;
930
+ (options: {
931
+ optional: true;
932
+ }): {
933
+ type: "running";
934
+ } | {
935
+ type: "complete";
936
+ } | {
937
+ type: "incomplete";
938
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
939
+ error?: unknown;
940
+ } | {
941
+ type: "requires-action";
942
+ reason: "tool-calls";
943
+ } | null;
944
+ <TSelected>(options: {
945
+ optional: true;
946
+ selector?: (state: {
947
+ type: "running";
948
+ } | {
949
+ type: "complete";
950
+ } | {
951
+ type: "incomplete";
952
+ reason: "cancelled" | "length" | "content-filter" | "other" | "error";
953
+ error?: unknown;
954
+ } | {
955
+ type: "requires-action";
956
+ reason: "tool-calls";
957
+ }) => TSelected;
958
+ }): TSelected | null;
911
959
  };
912
- type ThreadState = Readonly<{
913
- threadId: string;
914
- isDisabled: boolean;
915
- isRunning: boolean;
916
- capabilities: RuntimeCapabilities;
917
- messages: readonly ThreadMessage[];
918
- suggestions: readonly ThreadSuggestion[];
919
- extras: unknown;
920
- speech: SpeechState | undefined;
960
+
961
+ type internal_AssistantRuntimeImpl = AssistantRuntimeImpl;
962
+ declare const internal_AssistantRuntimeImpl: typeof AssistantRuntimeImpl;
963
+ type internal_BaseAssistantRuntimeCore = BaseAssistantRuntimeCore;
964
+ declare const internal_BaseAssistantRuntimeCore: typeof BaseAssistantRuntimeCore;
965
+ type internal_DefaultThreadComposerRuntimeCore = DefaultThreadComposerRuntimeCore;
966
+ declare const internal_DefaultThreadComposerRuntimeCore: typeof DefaultThreadComposerRuntimeCore;
967
+ type internal_MessageRepository = MessageRepository;
968
+ declare const internal_MessageRepository: typeof MessageRepository;
969
+ type internal_ProxyConfigProvider = ProxyConfigProvider;
970
+ declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
971
+ type internal_ThreadManagerRuntimeCore = ThreadManagerRuntimeCore;
972
+ type internal_ThreadRuntimeCore = ThreadRuntimeCore;
973
+ type internal_ThreadRuntimeCoreBinding = ThreadRuntimeCoreBinding;
974
+ type internal_ThreadRuntimeImpl = ThreadRuntimeImpl;
975
+ declare const internal_ThreadRuntimeImpl: typeof ThreadRuntimeImpl;
976
+ declare const internal_TooltipIconButton: typeof TooltipIconButton;
977
+ declare const internal_generateId: typeof generateId;
978
+ declare const internal_useSmooth: typeof useSmooth;
979
+ declare const internal_useSmoothStatus: typeof useSmoothStatus;
980
+ declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
981
+ declare namespace internal {
982
+ export { internal_AssistantRuntimeImpl as AssistantRuntimeImpl, internal_BaseAssistantRuntimeCore as BaseAssistantRuntimeCore, internal_DefaultThreadComposerRuntimeCore as DefaultThreadComposerRuntimeCore, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, type internal_ThreadManagerRuntimeCore as ThreadManagerRuntimeCore, type internal_ThreadRuntimeCore as ThreadRuntimeCore, type internal_ThreadRuntimeCoreBinding as ThreadRuntimeCoreBinding, internal_ThreadRuntimeImpl as ThreadRuntimeImpl, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
983
+ }
984
+
985
+ type ThreadManagerState = Readonly<{
986
+ threads: readonly ThreadManagerMetadata[];
987
+ archivedThreads: readonly ThreadManagerMetadata[];
921
988
  }>;
922
- type ThreadRuntime = {
923
- composer: ThreadComposerRuntime;
924
- getState(): ThreadState;
925
- /**
926
- * @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
927
- */
928
- unstable_getCore(): ThreadRuntimeCore;
929
- append(message: CreateAppendMessage): void;
930
- startRun(parentId: string | null): void;
989
+ type ThreadManagerRuntime = Readonly<{
990
+ path: ThreadManagerRuntimePath;
991
+ getState(): ThreadManagerState;
992
+ rename(threadId: string, newTitle: string): Promise<void>;
993
+ archive(threadId: string): Promise<void>;
994
+ unarchive(threadId: string): Promise<void>;
995
+ delete(threadId: string): Promise<void>;
931
996
  subscribe(callback: () => void): Unsubscribe;
932
- cancelRun(): void;
933
- getModelConfig(): ModelConfig;
934
- export(): ExportedMessageRepository;
935
- import(repository: ExportedMessageRepository): void;
936
- getMesssageByIndex(idx: number): MessageRuntime;
937
- stopSpeaking: () => void;
938
- unstable_on(event: "switched-to" | "run-start", callback: () => void): Unsubscribe;
939
- /**
940
- * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
941
- */
942
- capabilities: Readonly<RuntimeCapabilities>;
943
- /**
944
- * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
945
- */
946
- threadId: string;
947
- /**
948
- * @deprecated Use `getState().isDisabled` instead. This will be removed in 0.6.0.
949
- */
950
- isDisabled: boolean;
951
- /**
952
- * @deprecated Use `getState().isRunning` instead. This will be removed in 0.6.0.
953
- */
954
- isRunning: boolean;
955
- /**
956
- * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
957
- */
958
- messages: readonly ThreadMessage[];
959
- /**
960
- * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
961
- */
962
- suggestions: readonly ThreadSuggestion[];
963
- /**
964
- * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
965
- */
966
- speech: SpeechState | undefined;
967
- /**
968
- * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
969
- */
970
- extras: unknown;
971
- /**
972
- * @deprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
973
- */
974
- getBranches: (messageId: string) => readonly string[];
975
- /**
976
- * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
977
- */
978
- switchToBranch: (branchId: string) => void;
979
- /**
980
- * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
981
- */
982
- addToolResult: (options: AddToolResultOptions) => void;
983
- /**
984
- * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
985
- */
986
- speak: (messageId: string) => void;
987
- /**
988
- * @deprecated Use `getMesssageById(id).getState().submittedFeedback` instead. This will be removed in 0.6.0.
989
- */
990
- getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
991
- /**
992
- * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
993
- */
994
- submitFeedback: (feedback: SubmitFeedbackOptions) => void;
997
+ }>;
998
+ type ThreadManagerRuntimeCoreBinding = ThreadManagerRuntimeCore;
999
+ declare class ThreadManagerRuntimeImpl implements ThreadManagerRuntime {
1000
+ private _core;
1001
+ get path(): {
1002
+ ref: string;
1003
+ };
1004
+ private _getState;
1005
+ constructor(_core: ThreadManagerRuntimeCoreBinding);
1006
+ getState(): ThreadManagerState;
1007
+ rename(threadId: string, newTitle: string): Promise<void>;
1008
+ archive(threadId: string): Promise<void>;
1009
+ unarchive(threadId: string): Promise<void>;
1010
+ delete(threadId: string): Promise<void>;
1011
+ subscribe(callback: () => void): Unsubscribe;
1012
+ }
1013
+
1014
+ type AssistantRuntime = {
1015
+ thread: ThreadRuntime;
1016
+ threadManager: ThreadManagerRuntime;
1017
+ switchToNewThread(): void;
1018
+ switchToThread(threadId: string): void;
995
1019
  /**
996
- * @deprecated Use `getMesssageById(id).composer` instead. This will be removed in 0.6.0.
1020
+ * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
997
1021
  */
998
- getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1022
+ switchToThread(threadId: string | null): void;
1023
+ registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
999
1024
  /**
1000
- * @deprecated Use `getMesssageById(id).composer.beginEdit()` instead. This will be removed in 0.6.0.
1025
+ * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
1001
1026
  */
1002
- beginEdit: (messageId: string) => void;
1027
+ subscribe(callback: () => void): Unsubscribe;
1003
1028
  };
1004
- declare class ThreadRuntimeImpl implements ThreadRuntimeCore, ThreadRuntime {
1005
- /**
1006
- * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
1007
- */
1008
- get threadId(): string;
1009
- /**
1010
- * @deprecated Use `getState().isDisabled` instead. This will be removed in 0.6.0.
1011
- */
1012
- get isDisabled(): boolean;
1013
- /**
1014
- * @deprecated Use `getState().isRunning` instead. This will be removed in 0.6.0.
1015
- */
1016
- get isRunning(): boolean;
1017
- /**
1018
- * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
1019
- */
1020
- get capabilities(): Readonly<{
1021
- switchToBranch: boolean;
1022
- edit: boolean;
1023
- reload: boolean;
1024
- cancel: boolean;
1025
- unstable_copy: boolean;
1026
- speech: boolean;
1027
- attachments: boolean;
1028
- feedback: boolean;
1029
+ declare class AssistantRuntimeImpl implements Omit<AssistantRuntimeCore, "thread" | "threadManager">, AssistantRuntime {
1030
+ private readonly _core;
1031
+ private readonly _thread;
1032
+ readonly threadManager: ThreadManagerRuntimeImpl;
1033
+ protected constructor(_core: AssistantRuntimeCore, _thread: ThreadRuntime);
1034
+ get thread(): Readonly<{
1035
+ readonly path: ThreadRuntimePath;
1036
+ readonly composer: ThreadComposerRuntime;
1037
+ getState(): ThreadState;
1038
+ unstable_getCore(): ThreadRuntimeCore;
1039
+ append(message: CreateAppendMessage): void;
1040
+ startRun(parentId: string | null): void;
1041
+ subscribe(callback: () => void): Unsubscribe;
1042
+ cancelRun(): void;
1043
+ getModelConfig(): ModelConfig;
1044
+ export(): ExportedMessageRepository;
1045
+ import(repository: ExportedMessageRepository): void;
1046
+ getMesssageByIndex(idx: number): MessageRuntime;
1047
+ getMesssageById(messageId: string): MessageRuntime;
1048
+ stopSpeaking: () => void;
1049
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1050
+ capabilities: Readonly<RuntimeCapabilities>;
1051
+ threadId: string;
1052
+ isDisabled: boolean;
1053
+ isRunning: boolean;
1054
+ messages: readonly ThreadMessage[];
1055
+ suggestions: readonly ThreadSuggestion[];
1056
+ speech: SpeechState | undefined;
1057
+ extras: unknown;
1058
+ getBranches: (messageId: string) => readonly string[];
1059
+ switchToBranch: (branchId: string) => void;
1060
+ addToolResult: (options: AddToolResultOptions) => void;
1061
+ speak: (messageId: string) => void;
1062
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1063
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1064
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1065
+ beginEdit: (messageId: string) => void;
1029
1066
  }>;
1067
+ switchToNewThread(): void;
1068
+ switchToThread(threadId: string): void;
1030
1069
  /**
1031
- * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
1032
- */
1033
- get extras(): unknown;
1034
- /**
1035
- * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
1070
+ * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0.
1036
1071
  */
1037
- get suggestions(): readonly ThreadSuggestion[];
1072
+ switchToThread(threadId: string | null): void;
1073
+ registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
1038
1074
  /**
1039
- * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
1075
+ * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
1040
1076
  */
1041
- get messages(): readonly ThreadMessage[];
1042
- /**
1043
- * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
1044
- */
1045
- get speech(): Readonly<{
1046
- messageId: string;
1047
- status: SpeechSynthesisAdapter.Status;
1048
- }> | undefined;
1049
- unstable_getCore(): Readonly<{
1050
- getBranches: (messageId: string) => readonly string[];
1051
- switchToBranch: (branchId: string) => void;
1052
- append: (message: AppendMessage) => void;
1053
- startRun: (parentId: string | null) => void;
1054
- cancelRun: () => void;
1055
- addToolResult: (options: AddToolResultOptions) => void;
1056
- speak: (messageId: string) => void;
1077
+ subscribe(): () => void;
1078
+ protected static createMainThreadRuntime(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): Readonly<{
1079
+ readonly path: ThreadRuntimePath;
1080
+ readonly composer: ThreadComposerRuntime;
1081
+ getState(): ThreadState;
1082
+ unstable_getCore(): ThreadRuntimeCore;
1083
+ append(message: CreateAppendMessage): void;
1084
+ startRun(parentId: string | null): void;
1085
+ subscribe(callback: () => void): Unsubscribe;
1086
+ cancelRun(): void;
1087
+ getModelConfig(): ModelConfig;
1088
+ export(): ExportedMessageRepository;
1089
+ import(repository: ExportedMessageRepository): void;
1090
+ getMesssageByIndex(idx: number): MessageRuntime;
1091
+ getMesssageById(messageId: string): MessageRuntime;
1057
1092
  stopSpeaking: () => void;
1058
- getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1059
- submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1060
- getModelConfig: () => ModelConfig;
1061
- composer: ThreadComposerRuntimeCore;
1062
- getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1063
- beginEdit: (messageId: string) => void;
1064
- speech: SpeechState | undefined;
1093
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1065
1094
  capabilities: Readonly<RuntimeCapabilities>;
1066
- threadId: string;
1067
- isDisabled: boolean;
1068
- messages: readonly ThreadMessage[];
1069
- suggestions: readonly ThreadSuggestion[];
1070
- extras: unknown;
1071
- subscribe: (callback: () => void) => Unsubscribe;
1072
- import(repository: ExportedMessageRepository): void;
1073
- export(): ExportedMessageRepository;
1074
- unstable_on(event: "switched-to" | "run-start", callback: () => void): Unsubscribe;
1075
- }>;
1076
- private _threadBinding;
1077
- constructor(threadBinding: ThreadRuntimeCoreBinding);
1078
- readonly composer: ThreadComposerRuntimeImpl;
1079
- getState(): Readonly<{
1080
1095
  threadId: string;
1081
1096
  isDisabled: boolean;
1082
1097
  isRunning: boolean;
1083
- capabilities: RuntimeCapabilities;
1084
1098
  messages: readonly ThreadMessage[];
1085
1099
  suggestions: readonly ThreadSuggestion[];
1086
- extras: unknown;
1087
1100
  speech: SpeechState | undefined;
1101
+ extras: unknown;
1102
+ getBranches: (messageId: string) => readonly string[];
1103
+ switchToBranch: (branchId: string) => void;
1104
+ addToolResult: (options: AddToolResultOptions) => void;
1105
+ speak: (messageId: string) => void;
1106
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1107
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1108
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1109
+ beginEdit: (messageId: string) => void;
1088
1110
  }>;
1089
- append(message: CreateAppendMessage): void;
1090
- subscribe(callback: () => void): Unsubscribe;
1091
- /**
1092
- * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
1093
- */
1094
- getBranches(messageId: string): readonly string[];
1095
- getModelConfig(): ModelConfig;
1096
- startRun(parentId: string | null): void;
1097
- cancelRun(): void;
1098
- /**
1099
- * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
1100
- */
1101
- addToolResult(options: AddToolResultOptions): void;
1102
- /**
1103
- * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
1104
- */
1105
- switchToBranch(branchId: string): void;
1106
- /**
1107
- * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
1108
- */
1109
- speak(messageId: string): void;
1110
- stopSpeaking(): void;
1111
- getSubmittedFeedback(messageId: string): Readonly<{
1112
- type: "negative" | "positive";
1113
- }> | undefined;
1114
- /**
1115
- * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
1116
- */
1117
- submitFeedback(options: SubmitFeedbackOptions): void;
1118
- /**
1119
- * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
1120
- */
1121
- getEditComposer(messageId: string): Readonly<{
1122
- attachments: readonly Attachment$1[];
1123
- getAttachmentAccept(): string;
1124
- addAttachment: (file: File) => Promise<void>;
1125
- removeAttachment: (attachmentId: string) => Promise<void>;
1126
- isEditing: boolean;
1127
- canCancel: boolean;
1128
- isEmpty: boolean;
1129
- text: string;
1130
- setText: (value: string) => void;
1131
- reset: () => void;
1132
- send: () => void;
1133
- cancel: () => void;
1134
- subscribe: (callback: () => void) => Unsubscribe;
1135
- }> | undefined;
1136
- /**
1137
- * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
1138
- */
1139
- beginEdit(messageId: string): void;
1140
- export(): ExportedMessageRepository;
1141
- import(data: ExportedMessageRepository): void;
1142
- getMesssageByIndex(idx: number): MessageRuntimeImpl;
1143
- private _eventListenerNestedSubscriptions;
1144
- unstable_on(event: "switched-to" | "run-start", callback: () => void): Unsubscribe;
1111
+ static create(_core: AssistantRuntimeCore, CustomThreadRuntime?: new (binding: ThreadRuntimeCoreBinding) => ThreadRuntime): AssistantRuntime;
1145
1112
  }
1146
1113
 
1147
- type ContentPartState = (ThreadUserContentPart | ThreadAssistantContentPart) & {
1148
- /**
1149
- * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1150
- */
1151
- part: ThreadUserContentPart | ThreadAssistantContentPart;
1152
- status: ContentPartStatus | ToolCallContentPartStatus;
1114
+ type LocalRuntime = AssistantRuntime & {
1115
+ reset: (options?: Parameters<LocalRuntimeCore["reset"]>[0]) => void;
1153
1116
  };
1154
- type ContentPartSnapshotBinding = SubscribableWithState<ContentPartState>;
1155
- type ContentPartRuntime = {
1156
- getState(): ContentPartState;
1157
- addToolResult(result: any): void;
1158
- subscribe(callback: () => void): Unsubscribe;
1117
+ declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
1118
+
1119
+ declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
1120
+
1121
+ type fromLanguageModelMessagesOptions = {
1122
+ mergeSteps: boolean;
1159
1123
  };
1160
- declare class ContentPartRuntimeImpl implements ContentPartRuntime {
1161
- private contentBinding;
1162
- private messageApi;
1163
- private threadApi;
1164
- constructor(contentBinding: ContentPartSnapshotBinding, messageApi: MessageStateBinding, threadApi: ThreadRuntimeCoreBinding);
1165
- getState(): ContentPartState;
1166
- addToolResult(result: any): void;
1167
- subscribe(callback: () => void): Unsubscribe;
1124
+ declare const fromLanguageModelMessages: (lm: LanguageModelV1Message[], { mergeSteps }: fromLanguageModelMessagesOptions) => CoreMessage[];
1125
+
1126
+ declare const fromCoreMessages: (message: readonly CoreMessage[]) => ThreadMessage[];
1127
+ declare const fromCoreMessage: (message: CoreMessage, { id, status, attachments, }?: {
1128
+ id?: string | undefined;
1129
+ status?: MessageStatus | undefined;
1130
+ attachments?: readonly CompleteAttachment[] | undefined;
1131
+ }) => ThreadMessage;
1132
+
1133
+ declare const toCoreMessages: (message: ThreadMessage[]) => CoreMessage[];
1134
+ declare const toCoreMessage: (message: ThreadMessage) => CoreMessage;
1135
+
1136
+ declare const fromLanguageModelTools: (tools: LanguageModelV1FunctionTool[]) => Record<string, Tool<any, any>>;
1137
+
1138
+ declare const toLanguageModelTools: (tools: Record<string, Tool<any, any>>) => LanguageModelV1FunctionTool[];
1139
+
1140
+ declare class PipeableTransformStream<I, O> extends TransformStream<I, O> {
1141
+ constructor(transform: (readable: ReadableStream<I>) => ReadableStream<O>);
1168
1142
  }
1169
1143
 
1170
- type EmptyContentPartProps = {
1171
- status: ContentPartStatus;
1144
+ type StreamPart<T extends Record<string, unknown>> = {
1145
+ [K in keyof T]: {
1146
+ type: K;
1147
+ value: T[K];
1148
+ };
1149
+ }[keyof T];
1150
+
1151
+ declare function streamPartDecoderStream<T extends Record<string, unknown>>(): PipeableTransformStream<unknown, StreamPart<T>>;
1152
+
1153
+ declare function streamPartEncoderStream<T extends Record<string, unknown>>(): PipeableTransformStream<unknown, Uint8Array>;
1154
+
1155
+ declare namespace StreamUtils {
1156
+ export type { StreamPart };
1157
+ }
1158
+ /**
1159
+ * @deprecated `streamUtils` will be replaced with `assistant-stream` once it is ready.
1160
+ */
1161
+ declare const streamUtils: {
1162
+ streamPartEncoderStream: typeof streamPartEncoderStream;
1163
+ streamPartDecoderStream: typeof streamPartDecoderStream;
1172
1164
  };
1173
- type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
1174
- type TextContentPartProps = ContentPartState & TextContentPart & {
1175
- /**
1176
- * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1177
- */
1178
- part: TextContentPart;
1165
+
1166
+ type EdgeChatAdapterOptions = {
1167
+ api: string;
1168
+ credentials?: RequestCredentials;
1169
+ headers?: Record<string, string> | Headers;
1170
+ body?: object;
1179
1171
  };
1180
- type TextContentPartComponent = ComponentType<TextContentPartProps>;
1181
- type ImageContentPartProps = ContentPartState & ImageContentPart & {
1172
+ declare class EdgeChatAdapter implements ChatModelAdapter {
1173
+ private options;
1174
+ constructor(options: EdgeChatAdapterOptions);
1175
+ run({ messages, abortSignal, config }: ChatModelRunOptions): AsyncGenerator<ChatModelRunResult, void, unknown>;
1176
+ }
1177
+
1178
+ type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
1179
+ declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => LocalRuntime;
1180
+
1181
+ type ThreadMessageLike = {
1182
+ role: "assistant" | "user" | "system";
1183
+ content: string | (TextContentPart | ImageContentPart | ToolCallContentPart<any, any> | CoreToolCallContentPart<any, any> | UIContentPart)[];
1184
+ id?: string | undefined;
1185
+ createdAt?: Date | undefined;
1186
+ status?: MessageStatus | undefined;
1187
+ attachments?: CompleteAttachment[] | undefined;
1188
+ };
1189
+
1190
+ type ExternalStoreThreadManagerAdapter = {
1191
+ threadId?: string | undefined;
1192
+ threads?: readonly ThreadManagerMetadata[] | undefined;
1193
+ archivedThreads?: readonly ThreadManagerMetadata[] | undefined;
1194
+ onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
1195
+ onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
1196
+ onRename?: (threadId: string, newTitle: string) => (Promise<void> | void) | undefined;
1197
+ onArchive?: ((threadId: string) => Promise<void> | void) | undefined;
1198
+ onUnarchive?: ((threadId: string) => Promise<void> | void) | undefined;
1199
+ onDelete?: ((threadId: string) => Promise<void> | void) | undefined;
1200
+ };
1201
+ type ExternalStoreMessageConverter<T> = (message: T, idx: number) => ThreadMessageLike;
1202
+ type ExternalStoreMessageConverterAdapter<T> = {
1203
+ convertMessage: ExternalStoreMessageConverter<T>;
1204
+ };
1205
+ type ExternalStoreAdapterBase<T> = {
1182
1206
  /**
1183
- * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1207
+ * @deprecated Use `adapters.threadManager.threadId` instead. This will be removed in 0.6.0.
1184
1208
  */
1185
- part: ImageContentPart;
1186
- };
1187
- type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
1188
- type UIContentPartProps = ContentPartState & UIContentPart & {
1209
+ threadId?: string | undefined;
1189
1210
  /**
1190
- * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1211
+ * @deprecated Use `adapters.threadManager.onSwitchToThread` instead. This will be removed in 0.6.0.
1191
1212
  */
1192
- part: UIContentPart;
1193
- };
1194
- type UIContentPartComponent = ComponentType<UIContentPartProps>;
1195
- type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = ContentPartState & ToolCallContentPart<TArgs, TResult> & {
1213
+ onSwitchToThread?: ((threadId: string) => Promise<void> | void) | undefined;
1196
1214
  /**
1197
- * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1215
+ * @deprecated Use `adapters.threadManager.onSwitchToNewThread` instead. This will be removed in 0.6.0.
1198
1216
  */
1199
- part: ToolCallContentPart<TArgs, TResult>;
1200
- addResult: (result: any) => void;
1201
- };
1202
- type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
1203
-
1204
- type AssistantRuntimeProviderProps = {
1205
- runtime: AssistantRuntime;
1206
- };
1207
- declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
1208
-
1209
- type TextContentPartProviderProps = {
1210
- text: string;
1217
+ onSwitchToNewThread?: (() => Promise<void> | void) | undefined;
1218
+ isDisabled?: boolean | undefined;
1211
1219
  isRunning?: boolean | undefined;
1220
+ messages: T[];
1221
+ suggestions?: readonly ThreadSuggestion[] | undefined;
1222
+ extras?: unknown;
1223
+ setMessages?: ((messages: T[]) => void) | undefined;
1224
+ onNew: (message: AppendMessage) => Promise<void>;
1225
+ onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
1226
+ onReload?: ((parentId: string | null) => Promise<void>) | undefined;
1227
+ onCancel?: (() => Promise<void>) | undefined;
1228
+ onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
1229
+ convertMessage?: ExternalStoreMessageConverter<T> | undefined;
1230
+ adapters?: {
1231
+ attachments?: AttachmentAdapter | undefined;
1232
+ speech?: SpeechSynthesisAdapter | undefined;
1233
+ feedback?: FeedbackAdapter | undefined;
1234
+ threadManager?: ExternalStoreThreadManagerAdapter | undefined;
1235
+ };
1236
+ unstable_capabilities?: {
1237
+ copy?: boolean | undefined;
1238
+ } | undefined;
1212
1239
  };
1213
- declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
1240
+ type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
1241
+
1242
+ declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntime;
1243
+
1244
+ declare const getExternalStoreMessage: <T>(message: ThreadMessage) => T | undefined;
1245
+
1246
+ declare namespace useExternalMessageConverter {
1247
+ type Message = ThreadMessageLike | {
1248
+ role: "tool";
1249
+ toolCallId: string;
1250
+ toolName?: string | undefined;
1251
+ result: any;
1252
+ };
1253
+ type Callback<T> = (message: T) => Message | Message[];
1254
+ }
1255
+ declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, }: {
1256
+ callback: useExternalMessageConverter.Callback<T>;
1257
+ messages: T[];
1258
+ isRunning: boolean;
1259
+ }) => ThreadMessage[];
1260
+
1261
+ type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
1262
+
1263
+ type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
1264
+ declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => LocalRuntime;
1265
+
1266
+ type CreateAppendMessage = string | {
1267
+ parentId?: string | null | undefined;
1268
+ role?: AppendMessage["role"] | undefined;
1269
+ content: AppendMessage["content"];
1270
+ attachments?: AppendMessage["attachments"] | undefined;
1271
+ };
1272
+ type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore, ThreadRuntimePath> & {
1273
+ outerSubscribe(callback: () => void): Unsubscribe;
1274
+ };
1275
+ type ThreadState = Readonly<{
1276
+ threadId: string;
1277
+ isDisabled: boolean;
1278
+ isRunning: boolean;
1279
+ capabilities: RuntimeCapabilities;
1280
+ messages: readonly ThreadMessage[];
1281
+ suggestions: readonly ThreadSuggestion[];
1282
+ extras: unknown;
1283
+ /**
1284
+ * @deprecated This API is still under active development and might change without notice.
1285
+ */
1286
+ speech: SpeechState | undefined;
1287
+ }>;
1288
+ type ThreadRuntime = Readonly<{
1289
+ readonly path: ThreadRuntimePath;
1290
+ readonly composer: ThreadComposerRuntime;
1291
+ getState(): ThreadState;
1292
+ /**
1293
+ * @deprecated This method will be removed in 0.6.0. Submit feedback if you need this functionality.
1294
+ */
1295
+ unstable_getCore(): ThreadRuntimeCore;
1296
+ append(message: CreateAppendMessage): void;
1297
+ startRun(parentId: string | null): void;
1298
+ subscribe(callback: () => void): Unsubscribe;
1299
+ cancelRun(): void;
1300
+ getModelConfig(): ModelConfig;
1301
+ export(): ExportedMessageRepository;
1302
+ import(repository: ExportedMessageRepository): void;
1303
+ getMesssageByIndex(idx: number): MessageRuntime;
1304
+ getMesssageById(messageId: string): MessageRuntime;
1305
+ /**
1306
+ * @deprecated This API is still under active development and might change without notice.
1307
+ */
1308
+ stopSpeaking: () => void;
1309
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1310
+ /**
1311
+ * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
1312
+ */
1313
+ capabilities: Readonly<RuntimeCapabilities>;
1314
+ /**
1315
+ * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
1316
+ */
1317
+ threadId: string;
1318
+ /**
1319
+ * @deprecated Use `getState().isDisabled` instead. This will be removed in 0.6.0.
1320
+ */
1321
+ isDisabled: boolean;
1322
+ /**
1323
+ * @deprecated Use `getState().isRunning` instead. This will be removed in 0.6.0.
1324
+ */
1325
+ isRunning: boolean;
1326
+ /**
1327
+ * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
1328
+ */
1329
+ messages: readonly ThreadMessage[];
1330
+ /**
1331
+ * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
1332
+ */
1333
+ suggestions: readonly ThreadSuggestion[];
1334
+ /**
1335
+ * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
1336
+ */
1337
+ speech: SpeechState | undefined;
1338
+ /**
1339
+ * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
1340
+ */
1341
+ extras: unknown;
1342
+ /**
1343
+ * @deprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
1344
+ */
1345
+ getBranches: (messageId: string) => readonly string[];
1346
+ /**
1347
+ * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
1348
+ */
1349
+ switchToBranch: (branchId: string) => void;
1350
+ /**
1351
+ * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
1352
+ */
1353
+ addToolResult: (options: AddToolResultOptions) => void;
1354
+ /**
1355
+ * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
1356
+ */
1357
+ speak: (messageId: string) => void;
1358
+ /**
1359
+ * @deprecated Use `getMesssageById(id).getState().submittedFeedback` instead. This will be removed in 0.6.0.
1360
+ */
1361
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1362
+ /**
1363
+ * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
1364
+ */
1365
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1366
+ /**
1367
+ * @deprecated Use `getMesssageById(id).composer` instead. This will be removed in 0.6.0.
1368
+ */
1369
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1370
+ /**
1371
+ * @deprecated Use `getMesssageById(id).composer.beginEdit()` instead. This will be removed in 0.6.0.
1372
+ */
1373
+ beginEdit: (messageId: string) => void;
1374
+ }>;
1375
+ declare class ThreadRuntimeImpl implements Omit<ThreadRuntimeCore, "getMessageById">, ThreadRuntime {
1376
+ get path(): ThreadRuntimePath;
1377
+ /**
1378
+ * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
1379
+ */
1380
+ get threadId(): string;
1381
+ /**
1382
+ * @deprecated Use `getState().isDisabled` instead. This will be removed in 0.6.0.
1383
+ */
1384
+ get isDisabled(): boolean;
1385
+ /**
1386
+ * @deprecated Use `getState().isRunning` instead. This will be removed in 0.6.0.
1387
+ */
1388
+ get isRunning(): boolean;
1389
+ /**
1390
+ * @deprecated Use `getState().capabilities` instead. This will be removed in 0.6.0.
1391
+ */
1392
+ get capabilities(): Readonly<{
1393
+ switchToBranch: boolean;
1394
+ edit: boolean;
1395
+ reload: boolean;
1396
+ cancel: boolean;
1397
+ unstable_copy: boolean;
1398
+ speech: boolean;
1399
+ attachments: boolean;
1400
+ feedback: boolean;
1401
+ }>;
1402
+ /**
1403
+ * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
1404
+ */
1405
+ get extras(): unknown;
1406
+ /**
1407
+ * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
1408
+ */
1409
+ get suggestions(): readonly ThreadSuggestion[];
1410
+ /**
1411
+ * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
1412
+ */
1413
+ get messages(): readonly ThreadMessage[];
1414
+ /**
1415
+ * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
1416
+ */
1417
+ get speech(): Readonly<{
1418
+ messageId: string;
1419
+ status: SpeechSynthesisAdapter.Status;
1420
+ }> | undefined;
1421
+ unstable_getCore(): Readonly<{
1422
+ getMessageById: (messageId: string) => {
1423
+ parentId: string | null;
1424
+ message: ThreadMessage;
1425
+ } | undefined;
1426
+ getBranches: (messageId: string) => readonly string[];
1427
+ switchToBranch: (branchId: string) => void;
1428
+ append: (message: AppendMessage) => void;
1429
+ startRun: (parentId: string | null) => void;
1430
+ cancelRun: () => void;
1431
+ addToolResult: (options: AddToolResultOptions) => void;
1432
+ speak: (messageId: string) => void;
1433
+ stopSpeaking: () => void;
1434
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1435
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1436
+ getModelConfig: () => ModelConfig;
1437
+ composer: ThreadComposerRuntimeCore;
1438
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1439
+ beginEdit: (messageId: string) => void;
1440
+ speech: SpeechState | undefined;
1441
+ capabilities: Readonly<RuntimeCapabilities>;
1442
+ threadId: string;
1443
+ isDisabled: boolean;
1444
+ messages: readonly ThreadMessage[];
1445
+ suggestions: readonly ThreadSuggestion[];
1446
+ extras: unknown;
1447
+ subscribe: (callback: () => void) => Unsubscribe;
1448
+ import(repository: ExportedMessageRepository): void;
1449
+ export(): ExportedMessageRepository;
1450
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1451
+ }>;
1452
+ private _threadBinding;
1453
+ constructor(threadBinding: ThreadRuntimeCoreBinding);
1454
+ readonly composer: ThreadComposerRuntimeImpl;
1455
+ getState(): Readonly<{
1456
+ threadId: string;
1457
+ isDisabled: boolean;
1458
+ isRunning: boolean;
1459
+ capabilities: RuntimeCapabilities;
1460
+ messages: readonly ThreadMessage[];
1461
+ suggestions: readonly ThreadSuggestion[];
1462
+ extras: unknown;
1463
+ /**
1464
+ * @deprecated This API is still under active development and might change without notice.
1465
+ */
1466
+ speech: SpeechState | undefined;
1467
+ }>;
1468
+ append(message: CreateAppendMessage): void;
1469
+ subscribe(callback: () => void): Unsubscribe;
1470
+ /**
1471
+ * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
1472
+ */
1473
+ getBranches(messageId: string): readonly string[];
1474
+ getModelConfig(): ModelConfig;
1475
+ startRun(parentId: string | null): void;
1476
+ cancelRun(): void;
1477
+ /**
1478
+ * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
1479
+ */
1480
+ addToolResult(options: AddToolResultOptions): void;
1481
+ /**
1482
+ * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
1483
+ */
1484
+ switchToBranch(branchId: string): void;
1485
+ /**
1486
+ * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
1487
+ */
1488
+ speak(messageId: string): void;
1489
+ stopSpeaking(): void;
1490
+ getSubmittedFeedback(messageId: string): Readonly<{
1491
+ type: "negative" | "positive";
1492
+ }> | undefined;
1493
+ /**
1494
+ * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
1495
+ */
1496
+ submitFeedback(options: SubmitFeedbackOptions): void;
1497
+ /**
1498
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
1499
+ */
1500
+ getEditComposer(messageId: string): Readonly<{
1501
+ attachments: readonly Attachment$1[];
1502
+ getAttachmentAccept(): string;
1503
+ addAttachment: (file: File) => Promise<void>;
1504
+ removeAttachment: (attachmentId: string) => Promise<void>;
1505
+ isEditing: boolean;
1506
+ canCancel: boolean;
1507
+ isEmpty: boolean;
1508
+ text: string;
1509
+ setText: (value: string) => void;
1510
+ reset: () => void;
1511
+ send: () => void;
1512
+ cancel: () => void;
1513
+ subscribe: (callback: () => void) => Unsubscribe;
1514
+ }> | undefined;
1515
+ /**
1516
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
1517
+ */
1518
+ beginEdit(messageId: string): void;
1519
+ export(): ExportedMessageRepository;
1520
+ import(data: ExportedMessageRepository): void;
1521
+ getMesssageByIndex(idx: number): MessageRuntimeImpl;
1522
+ getMesssageById(messageId: string): MessageRuntimeImpl;
1523
+ private _getMessageRuntime;
1524
+ private _eventListenerNestedSubscriptions;
1525
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1526
+ }
1527
+
1528
+ type ContentPartState = (ThreadUserContentPart | ThreadAssistantContentPart) & {
1529
+ /**
1530
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1531
+ */
1532
+ part: ThreadUserContentPart | ThreadAssistantContentPart;
1533
+ status: ContentPartStatus | ToolCallContentPartStatus;
1534
+ };
1535
+ type ContentPartSnapshotBinding = SubscribableWithState<ContentPartState, ContentPartRuntimePath>;
1536
+ type ContentPartRuntime = {
1537
+ path: ContentPartRuntimePath;
1538
+ getState(): ContentPartState;
1539
+ addToolResult(result: any): void;
1540
+ subscribe(callback: () => void): Unsubscribe;
1541
+ };
1542
+ declare class ContentPartRuntimeImpl implements ContentPartRuntime {
1543
+ private contentBinding;
1544
+ private messageApi;
1545
+ private threadApi;
1546
+ get path(): ContentPartRuntimePath;
1547
+ constructor(contentBinding: ContentPartSnapshotBinding, messageApi: MessageStateBinding, threadApi: ThreadRuntimeCoreBinding);
1548
+ getState(): ContentPartState;
1549
+ addToolResult(result: any): void;
1550
+ subscribe(callback: () => void): Unsubscribe;
1551
+ }
1552
+
1553
+ type EmptyContentPartProps = {
1554
+ status: ContentPartStatus;
1555
+ };
1556
+ type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;
1557
+ type TextContentPartProps = ContentPartState & TextContentPart & {
1558
+ /**
1559
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1560
+ */
1561
+ part: TextContentPart;
1562
+ };
1563
+ type TextContentPartComponent = ComponentType<TextContentPartProps>;
1564
+ type ImageContentPartProps = ContentPartState & ImageContentPart & {
1565
+ /**
1566
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1567
+ */
1568
+ part: ImageContentPart;
1569
+ };
1570
+ type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
1571
+ type UIContentPartProps = ContentPartState & UIContentPart & {
1572
+ /**
1573
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1574
+ */
1575
+ part: UIContentPart;
1576
+ };
1577
+ type UIContentPartComponent = ComponentType<UIContentPartProps>;
1578
+ type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = ContentPartState & ToolCallContentPart<TArgs, TResult> & {
1579
+ /**
1580
+ * @deprecated You can directly access content part fields in the state. Replace `.part.type` with `.type` etc. This will be removed in 0.6.0.
1581
+ */
1582
+ part: ToolCallContentPart<TArgs, TResult>;
1583
+ addResult: (result: any) => void;
1584
+ };
1585
+ type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
1586
+
1587
+ type AssistantRuntimeProviderProps = {
1588
+ runtime: AssistantRuntime;
1589
+ };
1590
+ declare const AssistantRuntimeProvider: react.NamedExoticComponent<PropsWithChildren<AssistantRuntimeProviderProps>>;
1591
+
1592
+ type TextContentPartProviderProps = {
1593
+ text: string;
1594
+ isRunning?: boolean | undefined;
1595
+ };
1596
+ declare const TextContentPartProvider: FC<PropsWithChildren<TextContentPartProviderProps>>;
1214
1597
 
1215
1598
  type AssistantToolUIsState = Readonly<{
1216
1599
  getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
@@ -1230,154 +1613,1032 @@ type ThreadViewportState = Readonly<{
1230
1613
  onScrollToBottom: (callback: () => void) => Unsubscribe;
1231
1614
  }>;
1232
1615
 
1233
- type ReadonlyStore<T> = Omit<StoreApi<T>, "setState" | "destroy">;
1616
+ type AssistantContextValue = {
1617
+ useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
1618
+ useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
1619
+ useThreadManager: UseBoundStore<ReadonlyStore<ThreadManagerState>>;
1620
+ /**
1621
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1622
+ */
1623
+ useAssistantActions: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
1624
+ };
1625
+ declare const useAssistantContext: {
1626
+ (options?: {
1627
+ optional?: false | undefined;
1628
+ } | undefined): AssistantContextValue;
1629
+ (options?: {
1630
+ optional?: boolean | undefined;
1631
+ } | undefined): AssistantContextValue | null;
1632
+ };
1633
+ declare function useAssistantRuntime(options?: {
1634
+ optional?: false | undefined;
1635
+ }): AssistantRuntime;
1636
+ declare function useAssistantRuntime(options?: {
1637
+ optional?: boolean | undefined;
1638
+ }): AssistantRuntime | null;
1639
+ /**
1640
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1641
+ */
1642
+ declare const useAssistantActionsStore: {
1643
+ (): ReadonlyStore<AssistantRuntime>;
1644
+ (options: {
1645
+ optional: true;
1646
+ }): ReadonlyStore<AssistantRuntime> | null;
1647
+ };
1648
+ /**
1649
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1650
+ */
1651
+ declare const useAssistantActions: {
1652
+ (): AssistantRuntime;
1653
+ <TSelected>(selector: (state: AssistantRuntime) => TSelected): TSelected;
1654
+ (options: {
1655
+ optional: true;
1656
+ }): AssistantRuntime | null;
1657
+ <TSelected>(options: {
1658
+ optional: true;
1659
+ selector?: (state: AssistantRuntime) => TSelected;
1660
+ }): TSelected | null;
1661
+ };
1662
+ /**
1663
+ * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1664
+ */
1665
+ declare const useAssistantRuntimeStore: {
1666
+ (): ReadonlyStore<AssistantRuntime>;
1667
+ (options: {
1668
+ optional: true;
1669
+ }): ReadonlyStore<AssistantRuntime> | null;
1670
+ };
1671
+ declare const useToolUIs: {
1672
+ (): Readonly<{
1673
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1674
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1675
+ }>;
1676
+ <TSelected>(selector: (state: Readonly<{
1677
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1678
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1679
+ }>) => TSelected): TSelected;
1680
+ (options: {
1681
+ optional: true;
1682
+ }): Readonly<{
1683
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1684
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1685
+ }> | null;
1686
+ <TSelected>(options: {
1687
+ optional: true;
1688
+ selector?: (state: Readonly<{
1689
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1690
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1691
+ }>) => TSelected;
1692
+ }): TSelected | null;
1693
+ };
1694
+ declare const useToolUIsStore: {
1695
+ (): ReadonlyStore<Readonly<{
1696
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1697
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1698
+ }>>;
1699
+ (options: {
1700
+ optional: true;
1701
+ }): ReadonlyStore<Readonly<{
1702
+ getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1703
+ setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1704
+ }>> | null;
1705
+ };
1706
+ declare const useThreadManager: {
1707
+ (): Readonly<{
1708
+ threads: readonly ThreadManagerMetadata[];
1709
+ archivedThreads: readonly ThreadManagerMetadata[];
1710
+ }>;
1711
+ <TSelected>(selector: (state: Readonly<{
1712
+ threads: readonly ThreadManagerMetadata[];
1713
+ archivedThreads: readonly ThreadManagerMetadata[];
1714
+ }>) => TSelected): TSelected;
1715
+ (options: {
1716
+ optional: true;
1717
+ }): Readonly<{
1718
+ threads: readonly ThreadManagerMetadata[];
1719
+ archivedThreads: readonly ThreadManagerMetadata[];
1720
+ }> | null;
1721
+ <TSelected>(options: {
1722
+ optional: true;
1723
+ selector?: (state: Readonly<{
1724
+ threads: readonly ThreadManagerMetadata[];
1725
+ archivedThreads: readonly ThreadManagerMetadata[];
1726
+ }>) => TSelected;
1727
+ }): TSelected | null;
1728
+ };
1234
1729
 
1235
- type AssistantContextValue = {
1236
- useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
1237
- useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
1730
+ type ThreadContextValue = {
1731
+ useThread: UseBoundStore<ReadonlyStore<ThreadState>>;
1238
1732
  /**
1239
- * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1733
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1240
1734
  */
1241
- useAssistantActions: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
1735
+ useThreadActions: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
1736
+ useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
1737
+ useThreadMessages: UseBoundStore<ReadonlyStore<readonly ThreadMessage[]>>;
1738
+ useComposer: UseBoundStore<ReadonlyStore<ThreadComposerState>>;
1739
+ useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
1242
1740
  };
1243
- declare const useAssistantContext: {
1741
+ declare const useThreadContext: {
1244
1742
  (options?: {
1245
1743
  optional?: false | undefined;
1246
- } | undefined): AssistantContextValue;
1744
+ } | undefined): ThreadContextValue;
1247
1745
  (options?: {
1248
1746
  optional?: boolean | undefined;
1249
- } | undefined): AssistantContextValue | null;
1747
+ } | undefined): ThreadContextValue | null;
1250
1748
  };
1251
- declare function useAssistantRuntime(options?: {
1749
+ declare function useThreadRuntime(options?: {
1252
1750
  optional?: false | undefined;
1253
- }): AssistantRuntime;
1254
- declare function useAssistantRuntime(options?: {
1751
+ }): ThreadRuntime;
1752
+ declare function useThreadRuntime(options?: {
1255
1753
  optional?: boolean | undefined;
1256
- }): AssistantRuntime | null;
1257
- /**
1258
- * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1259
- */
1260
- declare const useAssistantActionsStore: {
1261
- (): ReadonlyStore<AssistantRuntime>;
1262
- (options: {
1263
- optional: true;
1264
- }): ReadonlyStore<AssistantRuntime> | null;
1265
- };
1754
+ }): ThreadRuntime | null;
1266
1755
  /**
1267
- * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1756
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1268
1757
  */
1269
- declare const useAssistantActions: {
1270
- (): AssistantRuntime;
1271
- <TSelected>(selector: (state: AssistantRuntime) => TSelected): TSelected;
1758
+ declare const useThreadActionsStore: {
1759
+ (): ReadonlyStore<Readonly<{
1760
+ readonly path: ThreadRuntimePath;
1761
+ readonly composer: ThreadComposerRuntime;
1762
+ getState(): Readonly<{
1763
+ threadId: string;
1764
+ isDisabled: boolean;
1765
+ isRunning: boolean;
1766
+ capabilities: Readonly<{
1767
+ switchToBranch: boolean;
1768
+ edit: boolean;
1769
+ reload: boolean;
1770
+ cancel: boolean;
1771
+ unstable_copy: boolean;
1772
+ speech: boolean;
1773
+ attachments: boolean;
1774
+ feedback: boolean;
1775
+ }>;
1776
+ messages: readonly ThreadMessage[];
1777
+ suggestions: readonly ThreadSuggestion[];
1778
+ extras: unknown;
1779
+ speech: Readonly<{
1780
+ messageId: string;
1781
+ status: SpeechSynthesisAdapter.Status;
1782
+ }> | undefined;
1783
+ }>;
1784
+ unstable_getCore(): Readonly<{
1785
+ getMessageById: (messageId: string) => {
1786
+ parentId: string | null;
1787
+ message: ThreadMessage;
1788
+ } | undefined;
1789
+ getBranches: (messageId: string) => readonly string[];
1790
+ switchToBranch: (branchId: string) => void;
1791
+ append: (message: AppendMessage) => void;
1792
+ startRun: (parentId: string | null) => void;
1793
+ cancelRun: () => void;
1794
+ addToolResult: (options: AddToolResultOptions) => void;
1795
+ speak: (messageId: string) => void;
1796
+ stopSpeaking: () => void;
1797
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1798
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1799
+ getModelConfig: () => ModelConfig;
1800
+ composer: ThreadComposerRuntimeCore;
1801
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1802
+ beginEdit: (messageId: string) => void;
1803
+ speech: Readonly<{
1804
+ messageId: string;
1805
+ status: SpeechSynthesisAdapter.Status;
1806
+ }> | undefined;
1807
+ capabilities: Readonly<Readonly<{
1808
+ switchToBranch: boolean;
1809
+ edit: boolean;
1810
+ reload: boolean;
1811
+ cancel: boolean;
1812
+ unstable_copy: boolean;
1813
+ speech: boolean;
1814
+ attachments: boolean;
1815
+ feedback: boolean;
1816
+ }>>;
1817
+ threadId: string;
1818
+ isDisabled: boolean;
1819
+ messages: readonly ThreadMessage[];
1820
+ suggestions: readonly ThreadSuggestion[];
1821
+ extras: unknown;
1822
+ subscribe: (callback: () => void) => Unsubscribe;
1823
+ import(repository: ExportedMessageRepository): void;
1824
+ export(): ExportedMessageRepository;
1825
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1826
+ }>;
1827
+ append(message: CreateAppendMessage): void;
1828
+ startRun(parentId: string | null): void;
1829
+ subscribe(callback: () => void): Unsubscribe;
1830
+ cancelRun(): void;
1831
+ getModelConfig(): ModelConfig;
1832
+ export(): ExportedMessageRepository;
1833
+ import(repository: ExportedMessageRepository): void;
1834
+ getMesssageByIndex(idx: number): MessageRuntime;
1835
+ getMesssageById(messageId: string): MessageRuntime;
1836
+ stopSpeaking: () => void;
1837
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1838
+ capabilities: Readonly<Readonly<{
1839
+ switchToBranch: boolean;
1840
+ edit: boolean;
1841
+ reload: boolean;
1842
+ cancel: boolean;
1843
+ unstable_copy: boolean;
1844
+ speech: boolean;
1845
+ attachments: boolean;
1846
+ feedback: boolean;
1847
+ }>>;
1848
+ threadId: string;
1849
+ isDisabled: boolean;
1850
+ isRunning: boolean;
1851
+ messages: readonly ThreadMessage[];
1852
+ suggestions: readonly ThreadSuggestion[];
1853
+ speech: Readonly<{
1854
+ messageId: string;
1855
+ status: SpeechSynthesisAdapter.Status;
1856
+ }> | undefined;
1857
+ extras: unknown;
1858
+ getBranches: (messageId: string) => readonly string[];
1859
+ switchToBranch: (branchId: string) => void;
1860
+ addToolResult: (options: AddToolResultOptions) => void;
1861
+ speak: (messageId: string) => void;
1862
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1863
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1864
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1865
+ beginEdit: (messageId: string) => void;
1866
+ }>>;
1272
1867
  (options: {
1273
1868
  optional: true;
1274
- }): AssistantRuntime | null;
1275
- <TSelected>(options: {
1276
- optional: true;
1277
- selector?: (state: AssistantRuntime) => TSelected;
1278
- }): TSelected | null;
1869
+ }): ReadonlyStore<Readonly<{
1870
+ readonly path: ThreadRuntimePath;
1871
+ readonly composer: ThreadComposerRuntime;
1872
+ getState(): Readonly<{
1873
+ threadId: string;
1874
+ isDisabled: boolean;
1875
+ isRunning: boolean;
1876
+ capabilities: Readonly<{
1877
+ switchToBranch: boolean;
1878
+ edit: boolean;
1879
+ reload: boolean;
1880
+ cancel: boolean;
1881
+ unstable_copy: boolean;
1882
+ speech: boolean;
1883
+ attachments: boolean;
1884
+ feedback: boolean;
1885
+ }>;
1886
+ messages: readonly ThreadMessage[];
1887
+ suggestions: readonly ThreadSuggestion[];
1888
+ extras: unknown;
1889
+ speech: Readonly<{
1890
+ messageId: string;
1891
+ status: SpeechSynthesisAdapter.Status;
1892
+ }> | undefined;
1893
+ }>;
1894
+ unstable_getCore(): Readonly<{
1895
+ getMessageById: (messageId: string) => {
1896
+ parentId: string | null;
1897
+ message: ThreadMessage;
1898
+ } | undefined;
1899
+ getBranches: (messageId: string) => readonly string[];
1900
+ switchToBranch: (branchId: string) => void;
1901
+ append: (message: AppendMessage) => void;
1902
+ startRun: (parentId: string | null) => void;
1903
+ cancelRun: () => void;
1904
+ addToolResult: (options: AddToolResultOptions) => void;
1905
+ speak: (messageId: string) => void;
1906
+ stopSpeaking: () => void;
1907
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1908
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1909
+ getModelConfig: () => ModelConfig;
1910
+ composer: ThreadComposerRuntimeCore;
1911
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1912
+ beginEdit: (messageId: string) => void;
1913
+ speech: Readonly<{
1914
+ messageId: string;
1915
+ status: SpeechSynthesisAdapter.Status;
1916
+ }> | undefined;
1917
+ capabilities: Readonly<Readonly<{
1918
+ switchToBranch: boolean;
1919
+ edit: boolean;
1920
+ reload: boolean;
1921
+ cancel: boolean;
1922
+ unstable_copy: boolean;
1923
+ speech: boolean;
1924
+ attachments: boolean;
1925
+ feedback: boolean;
1926
+ }>>;
1927
+ threadId: string;
1928
+ isDisabled: boolean;
1929
+ messages: readonly ThreadMessage[];
1930
+ suggestions: readonly ThreadSuggestion[];
1931
+ extras: unknown;
1932
+ subscribe: (callback: () => void) => Unsubscribe;
1933
+ import(repository: ExportedMessageRepository): void;
1934
+ export(): ExportedMessageRepository;
1935
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1936
+ }>;
1937
+ append(message: CreateAppendMessage): void;
1938
+ startRun(parentId: string | null): void;
1939
+ subscribe(callback: () => void): Unsubscribe;
1940
+ cancelRun(): void;
1941
+ getModelConfig(): ModelConfig;
1942
+ export(): ExportedMessageRepository;
1943
+ import(repository: ExportedMessageRepository): void;
1944
+ getMesssageByIndex(idx: number): MessageRuntime;
1945
+ getMesssageById(messageId: string): MessageRuntime;
1946
+ stopSpeaking: () => void;
1947
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
1948
+ capabilities: Readonly<Readonly<{
1949
+ switchToBranch: boolean;
1950
+ edit: boolean;
1951
+ reload: boolean;
1952
+ cancel: boolean;
1953
+ unstable_copy: boolean;
1954
+ speech: boolean;
1955
+ attachments: boolean;
1956
+ feedback: boolean;
1957
+ }>>;
1958
+ threadId: string;
1959
+ isDisabled: boolean;
1960
+ isRunning: boolean;
1961
+ messages: readonly ThreadMessage[];
1962
+ suggestions: readonly ThreadSuggestion[];
1963
+ speech: Readonly<{
1964
+ messageId: string;
1965
+ status: SpeechSynthesisAdapter.Status;
1966
+ }> | undefined;
1967
+ extras: unknown;
1968
+ getBranches: (messageId: string) => readonly string[];
1969
+ switchToBranch: (branchId: string) => void;
1970
+ addToolResult: (options: AddToolResultOptions) => void;
1971
+ speak: (messageId: string) => void;
1972
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
1973
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
1974
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
1975
+ beginEdit: (messageId: string) => void;
1976
+ }>> | null;
1279
1977
  };
1280
1978
  /**
1281
- * @deprecated Use `useAssistantRuntime` instead. This will be removed in 0.6.0.
1979
+ * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1282
1980
  */
1283
- declare const useAssistantRuntimeStore: {
1284
- (): ReadonlyStore<AssistantRuntime>;
1285
- (options: {
1286
- optional: true;
1287
- }): ReadonlyStore<AssistantRuntime> | null;
1288
- };
1289
- declare const useToolUIs: {
1981
+ declare const useThreadActions: {
1290
1982
  (): Readonly<{
1291
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1292
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1983
+ readonly path: ThreadRuntimePath;
1984
+ readonly composer: ThreadComposerRuntime;
1985
+ getState(): Readonly<{
1986
+ threadId: string;
1987
+ isDisabled: boolean;
1988
+ isRunning: boolean;
1989
+ capabilities: Readonly<{
1990
+ switchToBranch: boolean;
1991
+ edit: boolean;
1992
+ reload: boolean;
1993
+ cancel: boolean;
1994
+ unstable_copy: boolean;
1995
+ speech: boolean;
1996
+ attachments: boolean;
1997
+ feedback: boolean;
1998
+ }>;
1999
+ messages: readonly ThreadMessage[];
2000
+ suggestions: readonly ThreadSuggestion[];
2001
+ extras: unknown;
2002
+ speech: Readonly<{
2003
+ messageId: string;
2004
+ status: SpeechSynthesisAdapter.Status;
2005
+ }> | undefined;
2006
+ }>;
2007
+ unstable_getCore(): Readonly<{
2008
+ getMessageById: (messageId: string) => {
2009
+ parentId: string | null;
2010
+ message: ThreadMessage;
2011
+ } | undefined;
2012
+ getBranches: (messageId: string) => readonly string[];
2013
+ switchToBranch: (branchId: string) => void;
2014
+ append: (message: AppendMessage) => void;
2015
+ startRun: (parentId: string | null) => void;
2016
+ cancelRun: () => void;
2017
+ addToolResult: (options: AddToolResultOptions) => void;
2018
+ speak: (messageId: string) => void;
2019
+ stopSpeaking: () => void;
2020
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2021
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2022
+ getModelConfig: () => ModelConfig;
2023
+ composer: ThreadComposerRuntimeCore;
2024
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2025
+ beginEdit: (messageId: string) => void;
2026
+ speech: Readonly<{
2027
+ messageId: string;
2028
+ status: SpeechSynthesisAdapter.Status;
2029
+ }> | undefined;
2030
+ capabilities: Readonly<Readonly<{
2031
+ switchToBranch: boolean;
2032
+ edit: boolean;
2033
+ reload: boolean;
2034
+ cancel: boolean;
2035
+ unstable_copy: boolean;
2036
+ speech: boolean;
2037
+ attachments: boolean;
2038
+ feedback: boolean;
2039
+ }>>;
2040
+ threadId: string;
2041
+ isDisabled: boolean;
2042
+ messages: readonly ThreadMessage[];
2043
+ suggestions: readonly ThreadSuggestion[];
2044
+ extras: unknown;
2045
+ subscribe: (callback: () => void) => Unsubscribe;
2046
+ import(repository: ExportedMessageRepository): void;
2047
+ export(): ExportedMessageRepository;
2048
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2049
+ }>;
2050
+ append(message: CreateAppendMessage): void;
2051
+ startRun(parentId: string | null): void;
2052
+ subscribe(callback: () => void): Unsubscribe;
2053
+ cancelRun(): void;
2054
+ getModelConfig(): ModelConfig;
2055
+ export(): ExportedMessageRepository;
2056
+ import(repository: ExportedMessageRepository): void;
2057
+ getMesssageByIndex(idx: number): MessageRuntime;
2058
+ getMesssageById(messageId: string): MessageRuntime;
2059
+ stopSpeaking: () => void;
2060
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2061
+ capabilities: Readonly<Readonly<{
2062
+ switchToBranch: boolean;
2063
+ edit: boolean;
2064
+ reload: boolean;
2065
+ cancel: boolean;
2066
+ unstable_copy: boolean;
2067
+ speech: boolean;
2068
+ attachments: boolean;
2069
+ feedback: boolean;
2070
+ }>>;
2071
+ threadId: string;
2072
+ isDisabled: boolean;
2073
+ isRunning: boolean;
2074
+ messages: readonly ThreadMessage[];
2075
+ suggestions: readonly ThreadSuggestion[];
2076
+ speech: Readonly<{
2077
+ messageId: string;
2078
+ status: SpeechSynthesisAdapter.Status;
2079
+ }> | undefined;
2080
+ extras: unknown;
2081
+ getBranches: (messageId: string) => readonly string[];
2082
+ switchToBranch: (branchId: string) => void;
2083
+ addToolResult: (options: AddToolResultOptions) => void;
2084
+ speak: (messageId: string) => void;
2085
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2086
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2087
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2088
+ beginEdit: (messageId: string) => void;
1293
2089
  }>;
1294
2090
  <TSelected>(selector: (state: Readonly<{
1295
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1296
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
2091
+ readonly path: ThreadRuntimePath;
2092
+ readonly composer: ThreadComposerRuntime;
2093
+ getState(): Readonly<{
2094
+ threadId: string;
2095
+ isDisabled: boolean;
2096
+ isRunning: boolean;
2097
+ capabilities: Readonly<{
2098
+ switchToBranch: boolean;
2099
+ edit: boolean;
2100
+ reload: boolean;
2101
+ cancel: boolean;
2102
+ unstable_copy: boolean;
2103
+ speech: boolean;
2104
+ attachments: boolean;
2105
+ feedback: boolean;
2106
+ }>;
2107
+ messages: readonly ThreadMessage[];
2108
+ suggestions: readonly ThreadSuggestion[];
2109
+ extras: unknown;
2110
+ speech: Readonly<{
2111
+ messageId: string;
2112
+ status: SpeechSynthesisAdapter.Status;
2113
+ }> | undefined;
2114
+ }>;
2115
+ unstable_getCore(): Readonly<{
2116
+ getMessageById: (messageId: string) => {
2117
+ parentId: string | null;
2118
+ message: ThreadMessage;
2119
+ } | undefined;
2120
+ getBranches: (messageId: string) => readonly string[];
2121
+ switchToBranch: (branchId: string) => void;
2122
+ append: (message: AppendMessage) => void;
2123
+ startRun: (parentId: string | null) => void;
2124
+ cancelRun: () => void;
2125
+ addToolResult: (options: AddToolResultOptions) => void;
2126
+ speak: (messageId: string) => void;
2127
+ stopSpeaking: () => void;
2128
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2129
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2130
+ getModelConfig: () => ModelConfig;
2131
+ composer: ThreadComposerRuntimeCore;
2132
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2133
+ beginEdit: (messageId: string) => void;
2134
+ speech: Readonly<{
2135
+ messageId: string;
2136
+ status: SpeechSynthesisAdapter.Status;
2137
+ }> | undefined;
2138
+ capabilities: Readonly<Readonly<{
2139
+ switchToBranch: boolean;
2140
+ edit: boolean;
2141
+ reload: boolean;
2142
+ cancel: boolean;
2143
+ unstable_copy: boolean;
2144
+ speech: boolean;
2145
+ attachments: boolean;
2146
+ feedback: boolean;
2147
+ }>>;
2148
+ threadId: string;
2149
+ isDisabled: boolean;
2150
+ messages: readonly ThreadMessage[];
2151
+ suggestions: readonly ThreadSuggestion[];
2152
+ extras: unknown;
2153
+ subscribe: (callback: () => void) => Unsubscribe;
2154
+ import(repository: ExportedMessageRepository): void;
2155
+ export(): ExportedMessageRepository;
2156
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2157
+ }>;
2158
+ append(message: CreateAppendMessage): void;
2159
+ startRun(parentId: string | null): void;
2160
+ subscribe(callback: () => void): Unsubscribe;
2161
+ cancelRun(): void;
2162
+ getModelConfig(): ModelConfig;
2163
+ export(): ExportedMessageRepository;
2164
+ import(repository: ExportedMessageRepository): void;
2165
+ getMesssageByIndex(idx: number): MessageRuntime;
2166
+ getMesssageById(messageId: string): MessageRuntime;
2167
+ stopSpeaking: () => void;
2168
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2169
+ capabilities: Readonly<Readonly<{
2170
+ switchToBranch: boolean;
2171
+ edit: boolean;
2172
+ reload: boolean;
2173
+ cancel: boolean;
2174
+ unstable_copy: boolean;
2175
+ speech: boolean;
2176
+ attachments: boolean;
2177
+ feedback: boolean;
2178
+ }>>;
2179
+ threadId: string;
2180
+ isDisabled: boolean;
2181
+ isRunning: boolean;
2182
+ messages: readonly ThreadMessage[];
2183
+ suggestions: readonly ThreadSuggestion[];
2184
+ speech: Readonly<{
2185
+ messageId: string;
2186
+ status: SpeechSynthesisAdapter.Status;
2187
+ }> | undefined;
2188
+ extras: unknown;
2189
+ getBranches: (messageId: string) => readonly string[];
2190
+ switchToBranch: (branchId: string) => void;
2191
+ addToolResult: (options: AddToolResultOptions) => void;
2192
+ speak: (messageId: string) => void;
2193
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2194
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2195
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2196
+ beginEdit: (messageId: string) => void;
1297
2197
  }>) => TSelected): TSelected;
1298
2198
  (options: {
1299
2199
  optional: true;
1300
2200
  }): Readonly<{
1301
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1302
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
2201
+ readonly path: ThreadRuntimePath;
2202
+ readonly composer: ThreadComposerRuntime;
2203
+ getState(): Readonly<{
2204
+ threadId: string;
2205
+ isDisabled: boolean;
2206
+ isRunning: boolean;
2207
+ capabilities: Readonly<{
2208
+ switchToBranch: boolean;
2209
+ edit: boolean;
2210
+ reload: boolean;
2211
+ cancel: boolean;
2212
+ unstable_copy: boolean;
2213
+ speech: boolean;
2214
+ attachments: boolean;
2215
+ feedback: boolean;
2216
+ }>;
2217
+ messages: readonly ThreadMessage[];
2218
+ suggestions: readonly ThreadSuggestion[];
2219
+ extras: unknown;
2220
+ speech: Readonly<{
2221
+ messageId: string;
2222
+ status: SpeechSynthesisAdapter.Status;
2223
+ }> | undefined;
2224
+ }>;
2225
+ unstable_getCore(): Readonly<{
2226
+ getMessageById: (messageId: string) => {
2227
+ parentId: string | null;
2228
+ message: ThreadMessage;
2229
+ } | undefined;
2230
+ getBranches: (messageId: string) => readonly string[];
2231
+ switchToBranch: (branchId: string) => void;
2232
+ append: (message: AppendMessage) => void;
2233
+ startRun: (parentId: string | null) => void;
2234
+ cancelRun: () => void;
2235
+ addToolResult: (options: AddToolResultOptions) => void;
2236
+ speak: (messageId: string) => void;
2237
+ stopSpeaking: () => void;
2238
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2239
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2240
+ getModelConfig: () => ModelConfig;
2241
+ composer: ThreadComposerRuntimeCore;
2242
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2243
+ beginEdit: (messageId: string) => void;
2244
+ speech: Readonly<{
2245
+ messageId: string;
2246
+ status: SpeechSynthesisAdapter.Status;
2247
+ }> | undefined;
2248
+ capabilities: Readonly<Readonly<{
2249
+ switchToBranch: boolean;
2250
+ edit: boolean;
2251
+ reload: boolean;
2252
+ cancel: boolean;
2253
+ unstable_copy: boolean;
2254
+ speech: boolean;
2255
+ attachments: boolean;
2256
+ feedback: boolean;
2257
+ }>>;
2258
+ threadId: string;
2259
+ isDisabled: boolean;
2260
+ messages: readonly ThreadMessage[];
2261
+ suggestions: readonly ThreadSuggestion[];
2262
+ extras: unknown;
2263
+ subscribe: (callback: () => void) => Unsubscribe;
2264
+ import(repository: ExportedMessageRepository): void;
2265
+ export(): ExportedMessageRepository;
2266
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2267
+ }>;
2268
+ append(message: CreateAppendMessage): void;
2269
+ startRun(parentId: string | null): void;
2270
+ subscribe(callback: () => void): Unsubscribe;
2271
+ cancelRun(): void;
2272
+ getModelConfig(): ModelConfig;
2273
+ export(): ExportedMessageRepository;
2274
+ import(repository: ExportedMessageRepository): void;
2275
+ getMesssageByIndex(idx: number): MessageRuntime;
2276
+ getMesssageById(messageId: string): MessageRuntime;
2277
+ stopSpeaking: () => void;
2278
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2279
+ capabilities: Readonly<Readonly<{
2280
+ switchToBranch: boolean;
2281
+ edit: boolean;
2282
+ reload: boolean;
2283
+ cancel: boolean;
2284
+ unstable_copy: boolean;
2285
+ speech: boolean;
2286
+ attachments: boolean;
2287
+ feedback: boolean;
2288
+ }>>;
2289
+ threadId: string;
2290
+ isDisabled: boolean;
2291
+ isRunning: boolean;
2292
+ messages: readonly ThreadMessage[];
2293
+ suggestions: readonly ThreadSuggestion[];
2294
+ speech: Readonly<{
2295
+ messageId: string;
2296
+ status: SpeechSynthesisAdapter.Status;
2297
+ }> | undefined;
2298
+ extras: unknown;
2299
+ getBranches: (messageId: string) => readonly string[];
2300
+ switchToBranch: (branchId: string) => void;
2301
+ addToolResult: (options: AddToolResultOptions) => void;
2302
+ speak: (messageId: string) => void;
2303
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2304
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2305
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2306
+ beginEdit: (messageId: string) => void;
1303
2307
  }> | null;
1304
2308
  <TSelected>(options: {
1305
2309
  optional: true;
1306
2310
  selector?: (state: Readonly<{
1307
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1308
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
2311
+ readonly path: ThreadRuntimePath;
2312
+ readonly composer: ThreadComposerRuntime;
2313
+ getState(): Readonly<{
2314
+ threadId: string;
2315
+ isDisabled: boolean;
2316
+ isRunning: boolean;
2317
+ capabilities: Readonly<{
2318
+ switchToBranch: boolean;
2319
+ edit: boolean;
2320
+ reload: boolean;
2321
+ cancel: boolean;
2322
+ unstable_copy: boolean;
2323
+ speech: boolean;
2324
+ attachments: boolean;
2325
+ feedback: boolean;
2326
+ }>;
2327
+ messages: readonly ThreadMessage[];
2328
+ suggestions: readonly ThreadSuggestion[];
2329
+ extras: unknown;
2330
+ speech: Readonly<{
2331
+ messageId: string;
2332
+ status: SpeechSynthesisAdapter.Status;
2333
+ }> | undefined;
2334
+ }>;
2335
+ unstable_getCore(): Readonly<{
2336
+ getMessageById: (messageId: string) => {
2337
+ parentId: string | null;
2338
+ message: ThreadMessage;
2339
+ } | undefined;
2340
+ getBranches: (messageId: string) => readonly string[];
2341
+ switchToBranch: (branchId: string) => void;
2342
+ append: (message: AppendMessage) => void;
2343
+ startRun: (parentId: string | null) => void;
2344
+ cancelRun: () => void;
2345
+ addToolResult: (options: AddToolResultOptions) => void;
2346
+ speak: (messageId: string) => void;
2347
+ stopSpeaking: () => void;
2348
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2349
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2350
+ getModelConfig: () => ModelConfig;
2351
+ composer: ThreadComposerRuntimeCore;
2352
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2353
+ beginEdit: (messageId: string) => void;
2354
+ speech: Readonly<{
2355
+ messageId: string;
2356
+ status: SpeechSynthesisAdapter.Status;
2357
+ }> | undefined;
2358
+ capabilities: Readonly<Readonly<{
2359
+ switchToBranch: boolean;
2360
+ edit: boolean;
2361
+ reload: boolean;
2362
+ cancel: boolean;
2363
+ unstable_copy: boolean;
2364
+ speech: boolean;
2365
+ attachments: boolean;
2366
+ feedback: boolean;
2367
+ }>>;
2368
+ threadId: string;
2369
+ isDisabled: boolean;
2370
+ messages: readonly ThreadMessage[];
2371
+ suggestions: readonly ThreadSuggestion[];
2372
+ extras: unknown;
2373
+ subscribe: (callback: () => void) => Unsubscribe;
2374
+ import(repository: ExportedMessageRepository): void;
2375
+ export(): ExportedMessageRepository;
2376
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2377
+ }>;
2378
+ append(message: CreateAppendMessage): void;
2379
+ startRun(parentId: string | null): void;
2380
+ subscribe(callback: () => void): Unsubscribe;
2381
+ cancelRun(): void;
2382
+ getModelConfig(): ModelConfig;
2383
+ export(): ExportedMessageRepository;
2384
+ import(repository: ExportedMessageRepository): void;
2385
+ getMesssageByIndex(idx: number): MessageRuntime;
2386
+ getMesssageById(messageId: string): MessageRuntime;
2387
+ stopSpeaking: () => void;
2388
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2389
+ capabilities: Readonly<Readonly<{
2390
+ switchToBranch: boolean;
2391
+ edit: boolean;
2392
+ reload: boolean;
2393
+ cancel: boolean;
2394
+ unstable_copy: boolean;
2395
+ speech: boolean;
2396
+ attachments: boolean;
2397
+ feedback: boolean;
2398
+ }>>;
2399
+ threadId: string;
2400
+ isDisabled: boolean;
2401
+ isRunning: boolean;
2402
+ messages: readonly ThreadMessage[];
2403
+ suggestions: readonly ThreadSuggestion[];
2404
+ speech: Readonly<{
2405
+ messageId: string;
2406
+ status: SpeechSynthesisAdapter.Status;
2407
+ }> | undefined;
2408
+ extras: unknown;
2409
+ getBranches: (messageId: string) => readonly string[];
2410
+ switchToBranch: (branchId: string) => void;
2411
+ addToolResult: (options: AddToolResultOptions) => void;
2412
+ speak: (messageId: string) => void;
2413
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2414
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2415
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2416
+ beginEdit: (messageId: string) => void;
1309
2417
  }>) => TSelected;
1310
2418
  }): TSelected | null;
1311
2419
  };
1312
- declare const useToolUIsStore: {
1313
- (): ReadonlyStore<Readonly<{
1314
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1315
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1316
- }>>;
1317
- (options: {
1318
- optional: true;
1319
- }): ReadonlyStore<Readonly<{
1320
- getToolUI: (toolName: string) => ToolCallContentPartComponent | null;
1321
- setToolUI: (toolName: string, render: ToolCallContentPartComponent) => () => void;
1322
- }>> | null;
1323
- };
1324
-
1325
- type ThreadContextValue = {
1326
- useThread: UseBoundStore<ReadonlyStore<ThreadState>>;
1327
- /**
1328
- * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1329
- */
1330
- useThreadActions: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
1331
- useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;
1332
- useThreadMessages: UseBoundStore<ReadonlyStore<readonly ThreadMessage[]>>;
1333
- useComposer: UseBoundStore<ReadonlyStore<ThreadComposerState>>;
1334
- useViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;
1335
- };
1336
- declare const useThreadContext: {
1337
- (options?: {
1338
- optional?: false | undefined;
1339
- } | undefined): ThreadContextValue;
1340
- (options?: {
1341
- optional?: boolean | undefined;
1342
- } | undefined): ThreadContextValue | null;
1343
- };
1344
- declare function useThreadRuntime(options?: {
1345
- optional?: false | undefined;
1346
- }): ThreadRuntime;
1347
- declare function useThreadRuntime(options?: {
1348
- optional?: boolean | undefined;
1349
- }): ThreadRuntime | null;
1350
- /**
1351
- * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1352
- */
1353
- declare const useThreadActionsStore: {
1354
- (): ReadonlyStore<ThreadRuntime>;
1355
- (options: {
1356
- optional: true;
1357
- }): ReadonlyStore<ThreadRuntime> | null;
1358
- };
1359
- /**
1360
- * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1361
- */
1362
- declare const useThreadActions: {
1363
- (): ThreadRuntime;
1364
- <TSelected>(selector: (state: ThreadRuntime) => TSelected): TSelected;
1365
- (options: {
1366
- optional: true;
1367
- }): ThreadRuntime | null;
1368
- <TSelected>(options: {
1369
- optional: true;
1370
- selector?: (state: ThreadRuntime) => TSelected;
1371
- }): TSelected | null;
1372
- };
1373
2420
  /**
1374
2421
  * @deprecated Use `useThreadRuntime` instead. This will be removed in 0.6.0.
1375
2422
  */
1376
2423
  declare const useThreadRuntimeStore: {
1377
- (): ReadonlyStore<ThreadRuntime>;
2424
+ (): ReadonlyStore<Readonly<{
2425
+ readonly path: ThreadRuntimePath;
2426
+ readonly composer: ThreadComposerRuntime;
2427
+ getState(): Readonly<{
2428
+ threadId: string;
2429
+ isDisabled: boolean;
2430
+ isRunning: boolean;
2431
+ capabilities: Readonly<{
2432
+ switchToBranch: boolean;
2433
+ edit: boolean;
2434
+ reload: boolean;
2435
+ cancel: boolean;
2436
+ unstable_copy: boolean;
2437
+ speech: boolean;
2438
+ attachments: boolean;
2439
+ feedback: boolean;
2440
+ }>;
2441
+ messages: readonly ThreadMessage[];
2442
+ suggestions: readonly ThreadSuggestion[];
2443
+ extras: unknown;
2444
+ speech: Readonly<{
2445
+ messageId: string;
2446
+ status: SpeechSynthesisAdapter.Status;
2447
+ }> | undefined;
2448
+ }>;
2449
+ unstable_getCore(): Readonly<{
2450
+ getMessageById: (messageId: string) => {
2451
+ parentId: string | null;
2452
+ message: ThreadMessage;
2453
+ } | undefined;
2454
+ getBranches: (messageId: string) => readonly string[];
2455
+ switchToBranch: (branchId: string) => void;
2456
+ append: (message: AppendMessage) => void;
2457
+ startRun: (parentId: string | null) => void;
2458
+ cancelRun: () => void;
2459
+ addToolResult: (options: AddToolResultOptions) => void;
2460
+ speak: (messageId: string) => void;
2461
+ stopSpeaking: () => void;
2462
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2463
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2464
+ getModelConfig: () => ModelConfig;
2465
+ composer: ThreadComposerRuntimeCore;
2466
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2467
+ beginEdit: (messageId: string) => void;
2468
+ speech: Readonly<{
2469
+ messageId: string;
2470
+ status: SpeechSynthesisAdapter.Status;
2471
+ }> | undefined;
2472
+ capabilities: Readonly<Readonly<{
2473
+ switchToBranch: boolean;
2474
+ edit: boolean;
2475
+ reload: boolean;
2476
+ cancel: boolean;
2477
+ unstable_copy: boolean;
2478
+ speech: boolean;
2479
+ attachments: boolean;
2480
+ feedback: boolean;
2481
+ }>>;
2482
+ threadId: string;
2483
+ isDisabled: boolean;
2484
+ messages: readonly ThreadMessage[];
2485
+ suggestions: readonly ThreadSuggestion[];
2486
+ extras: unknown;
2487
+ subscribe: (callback: () => void) => Unsubscribe;
2488
+ import(repository: ExportedMessageRepository): void;
2489
+ export(): ExportedMessageRepository;
2490
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2491
+ }>;
2492
+ append(message: CreateAppendMessage): void;
2493
+ startRun(parentId: string | null): void;
2494
+ subscribe(callback: () => void): Unsubscribe;
2495
+ cancelRun(): void;
2496
+ getModelConfig(): ModelConfig;
2497
+ export(): ExportedMessageRepository;
2498
+ import(repository: ExportedMessageRepository): void;
2499
+ getMesssageByIndex(idx: number): MessageRuntime;
2500
+ getMesssageById(messageId: string): MessageRuntime;
2501
+ stopSpeaking: () => void;
2502
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2503
+ capabilities: Readonly<Readonly<{
2504
+ switchToBranch: boolean;
2505
+ edit: boolean;
2506
+ reload: boolean;
2507
+ cancel: boolean;
2508
+ unstable_copy: boolean;
2509
+ speech: boolean;
2510
+ attachments: boolean;
2511
+ feedback: boolean;
2512
+ }>>;
2513
+ threadId: string;
2514
+ isDisabled: boolean;
2515
+ isRunning: boolean;
2516
+ messages: readonly ThreadMessage[];
2517
+ suggestions: readonly ThreadSuggestion[];
2518
+ speech: Readonly<{
2519
+ messageId: string;
2520
+ status: SpeechSynthesisAdapter.Status;
2521
+ }> | undefined;
2522
+ extras: unknown;
2523
+ getBranches: (messageId: string) => readonly string[];
2524
+ switchToBranch: (branchId: string) => void;
2525
+ addToolResult: (options: AddToolResultOptions) => void;
2526
+ speak: (messageId: string) => void;
2527
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2528
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2529
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2530
+ beginEdit: (messageId: string) => void;
2531
+ }>>;
1378
2532
  (options: {
1379
2533
  optional: true;
1380
- }): ReadonlyStore<ThreadRuntime> | null;
2534
+ }): ReadonlyStore<Readonly<{
2535
+ readonly path: ThreadRuntimePath;
2536
+ readonly composer: ThreadComposerRuntime;
2537
+ getState(): Readonly<{
2538
+ threadId: string;
2539
+ isDisabled: boolean;
2540
+ isRunning: boolean;
2541
+ capabilities: Readonly<{
2542
+ switchToBranch: boolean;
2543
+ edit: boolean;
2544
+ reload: boolean;
2545
+ cancel: boolean;
2546
+ unstable_copy: boolean;
2547
+ speech: boolean;
2548
+ attachments: boolean;
2549
+ feedback: boolean;
2550
+ }>;
2551
+ messages: readonly ThreadMessage[];
2552
+ suggestions: readonly ThreadSuggestion[];
2553
+ extras: unknown;
2554
+ speech: Readonly<{
2555
+ messageId: string;
2556
+ status: SpeechSynthesisAdapter.Status;
2557
+ }> | undefined;
2558
+ }>;
2559
+ unstable_getCore(): Readonly<{
2560
+ getMessageById: (messageId: string) => {
2561
+ parentId: string | null;
2562
+ message: ThreadMessage;
2563
+ } | undefined;
2564
+ getBranches: (messageId: string) => readonly string[];
2565
+ switchToBranch: (branchId: string) => void;
2566
+ append: (message: AppendMessage) => void;
2567
+ startRun: (parentId: string | null) => void;
2568
+ cancelRun: () => void;
2569
+ addToolResult: (options: AddToolResultOptions) => void;
2570
+ speak: (messageId: string) => void;
2571
+ stopSpeaking: () => void;
2572
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2573
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2574
+ getModelConfig: () => ModelConfig;
2575
+ composer: ThreadComposerRuntimeCore;
2576
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2577
+ beginEdit: (messageId: string) => void;
2578
+ speech: Readonly<{
2579
+ messageId: string;
2580
+ status: SpeechSynthesisAdapter.Status;
2581
+ }> | undefined;
2582
+ capabilities: Readonly<Readonly<{
2583
+ switchToBranch: boolean;
2584
+ edit: boolean;
2585
+ reload: boolean;
2586
+ cancel: boolean;
2587
+ unstable_copy: boolean;
2588
+ speech: boolean;
2589
+ attachments: boolean;
2590
+ feedback: boolean;
2591
+ }>>;
2592
+ threadId: string;
2593
+ isDisabled: boolean;
2594
+ messages: readonly ThreadMessage[];
2595
+ suggestions: readonly ThreadSuggestion[];
2596
+ extras: unknown;
2597
+ subscribe: (callback: () => void) => Unsubscribe;
2598
+ import(repository: ExportedMessageRepository): void;
2599
+ export(): ExportedMessageRepository;
2600
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2601
+ }>;
2602
+ append(message: CreateAppendMessage): void;
2603
+ startRun(parentId: string | null): void;
2604
+ subscribe(callback: () => void): Unsubscribe;
2605
+ cancelRun(): void;
2606
+ getModelConfig(): ModelConfig;
2607
+ export(): ExportedMessageRepository;
2608
+ import(repository: ExportedMessageRepository): void;
2609
+ getMesssageByIndex(idx: number): MessageRuntime;
2610
+ getMesssageById(messageId: string): MessageRuntime;
2611
+ stopSpeaking: () => void;
2612
+ unstable_on(event: ThreadRuntimeEventType, callback: () => void): Unsubscribe;
2613
+ capabilities: Readonly<Readonly<{
2614
+ switchToBranch: boolean;
2615
+ edit: boolean;
2616
+ reload: boolean;
2617
+ cancel: boolean;
2618
+ unstable_copy: boolean;
2619
+ speech: boolean;
2620
+ attachments: boolean;
2621
+ feedback: boolean;
2622
+ }>>;
2623
+ threadId: string;
2624
+ isDisabled: boolean;
2625
+ isRunning: boolean;
2626
+ messages: readonly ThreadMessage[];
2627
+ suggestions: readonly ThreadSuggestion[];
2628
+ speech: Readonly<{
2629
+ messageId: string;
2630
+ status: SpeechSynthesisAdapter.Status;
2631
+ }> | undefined;
2632
+ extras: unknown;
2633
+ getBranches: (messageId: string) => readonly string[];
2634
+ switchToBranch: (branchId: string) => void;
2635
+ addToolResult: (options: AddToolResultOptions) => void;
2636
+ speak: (messageId: string) => void;
2637
+ getSubmittedFeedback: (messageId: string) => SubmittedFeedback | undefined;
2638
+ submitFeedback: (feedback: SubmitFeedbackOptions) => void;
2639
+ getEditComposer: (messageId: string) => ComposerRuntimeCore | undefined;
2640
+ beginEdit: (messageId: string) => void;
2641
+ }>> | null;
1381
2642
  };
1382
2643
  declare const useThread: {
1383
2644
  (): Readonly<{
@@ -1603,6 +2864,12 @@ declare const useThreadViewportStore: {
1603
2864
  onScrollToBottom: (callback: () => void) => Unsubscribe;
1604
2865
  }>> | null;
1605
2866
  };
2867
+ declare function useThreadModelConfig(options?: {
2868
+ optional?: false | undefined;
2869
+ }): ModelConfig;
2870
+ declare function useThreadModelConfig(options?: {
2871
+ optional?: boolean | undefined;
2872
+ }): ModelConfig | null;
1606
2873
 
1607
2874
  type MessageContextValue = {
1608
2875
  useMessageRuntime: UseBoundStore<ReadonlyStore<MessageRuntime>>;
@@ -2571,6 +3838,9 @@ type StringsConfig = {
2571
3838
  tooltip?: string | undefined;
2572
3839
  };
2573
3840
  };
3841
+ welcome?: {
3842
+ message?: string | undefined;
3843
+ };
2574
3844
  userMessage?: {
2575
3845
  edit?: {
2576
3846
  tooltip?: string | undefined;
@@ -2660,28 +3930,6 @@ type ThreadConfigProviderProps = PropsWithChildren<{
2660
3930
  }>;
2661
3931
  declare const ThreadConfigProvider: FC<ThreadConfigProviderProps>;
2662
3932
 
2663
- declare const buttonVariants: (props?: ({
2664
- variant?: "default" | "outline" | "ghost" | null | undefined;
2665
- size?: "default" | "icon" | null | undefined;
2666
- } & class_variance_authority_types.ClassProp) | undefined) => string;
2667
- type ButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button> & VariantProps<typeof buttonVariants>;
2668
-
2669
- type TooltipIconButtonProps = ButtonProps & {
2670
- tooltip: string;
2671
- side?: "top" | "bottom" | "left" | "right";
2672
- };
2673
- declare const TooltipIconButton: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
2674
- 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;
2675
- } & {
2676
- asChild?: boolean;
2677
- }, "ref"> & class_variance_authority.VariantProps<(props?: ({
2678
- variant?: "default" | "outline" | "ghost" | null | undefined;
2679
- size?: "default" | "icon" | null | undefined;
2680
- } & class_variance_authority_types.ClassProp) | undefined) => string> & {
2681
- tooltip: string;
2682
- side?: "top" | "bottom" | "left" | "right";
2683
- } & react.RefAttributes<HTMLButtonElement>>;
2684
-
2685
3933
  declare const AssistantActionBar: FC;
2686
3934
  declare const exports$b: {
2687
3935
  Root: react.ForwardRefExoticComponent<Partial<Omit<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -2947,94 +4195,4 @@ declare const exports: {
2947
4195
  Text: FC;
2948
4196
  };
2949
4197
 
2950
- declare class ProxyConfigProvider implements ModelConfigProvider {
2951
- private _providers;
2952
- getModelConfig(): ModelConfig;
2953
- registerModelConfigProvider(provider: ModelConfigProvider): () => void;
2954
- }
2955
-
2956
- declare const generateId: (size?: number) => string;
2957
-
2958
- declare const useSmooth: (state: ContentPartState & TextContentPart, smooth?: boolean) => ContentPartState & TextContentPart;
2959
-
2960
- declare const withSmoothContextProvider: <C extends ComponentType<any>>(Component: C) => C;
2961
- declare const useSmoothStatus: {
2962
- (): {
2963
- type: "running";
2964
- } | {
2965
- type: "complete";
2966
- } | {
2967
- type: "incomplete";
2968
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2969
- error?: unknown;
2970
- } | {
2971
- type: "requires-action";
2972
- reason: "tool-calls";
2973
- };
2974
- <TSelected>(selector: (state: {
2975
- type: "running";
2976
- } | {
2977
- type: "complete";
2978
- } | {
2979
- type: "incomplete";
2980
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2981
- error?: unknown;
2982
- } | {
2983
- type: "requires-action";
2984
- reason: "tool-calls";
2985
- }) => TSelected): TSelected;
2986
- (options: {
2987
- optional: true;
2988
- }): {
2989
- type: "running";
2990
- } | {
2991
- type: "complete";
2992
- } | {
2993
- type: "incomplete";
2994
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
2995
- error?: unknown;
2996
- } | {
2997
- type: "requires-action";
2998
- reason: "tool-calls";
2999
- } | null;
3000
- <TSelected>(options: {
3001
- optional: true;
3002
- selector?: (state: {
3003
- type: "running";
3004
- } | {
3005
- type: "complete";
3006
- } | {
3007
- type: "incomplete";
3008
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
3009
- error?: unknown;
3010
- } | {
3011
- type: "requires-action";
3012
- reason: "tool-calls";
3013
- }) => TSelected;
3014
- }): TSelected | null;
3015
- };
3016
-
3017
- type internal_AssistantRuntimeImpl = AssistantRuntimeImpl;
3018
- declare const internal_AssistantRuntimeImpl: typeof AssistantRuntimeImpl;
3019
- type internal_BaseAssistantRuntimeCore<TThreadRuntime extends ThreadRuntimeCore> = BaseAssistantRuntimeCore<TThreadRuntime>;
3020
- declare const internal_BaseAssistantRuntimeCore: typeof BaseAssistantRuntimeCore;
3021
- type internal_DefaultThreadComposerRuntimeCore = DefaultThreadComposerRuntimeCore;
3022
- declare const internal_DefaultThreadComposerRuntimeCore: typeof DefaultThreadComposerRuntimeCore;
3023
- type internal_MessageRepository = MessageRepository;
3024
- declare const internal_MessageRepository: typeof MessageRepository;
3025
- type internal_ProxyConfigProvider = ProxyConfigProvider;
3026
- declare const internal_ProxyConfigProvider: typeof ProxyConfigProvider;
3027
- type internal_ThreadRuntimeCore = ThreadRuntimeCore;
3028
- type internal_ThreadRuntimeCoreBinding = ThreadRuntimeCoreBinding;
3029
- type internal_ThreadRuntimeImpl = ThreadRuntimeImpl;
3030
- declare const internal_ThreadRuntimeImpl: typeof ThreadRuntimeImpl;
3031
- declare const internal_TooltipIconButton: typeof TooltipIconButton;
3032
- declare const internal_generateId: typeof generateId;
3033
- declare const internal_useSmooth: typeof useSmooth;
3034
- declare const internal_useSmoothStatus: typeof useSmoothStatus;
3035
- declare const internal_withSmoothContextProvider: typeof withSmoothContextProvider;
3036
- declare namespace internal {
3037
- export { internal_AssistantRuntimeImpl as AssistantRuntimeImpl, internal_BaseAssistantRuntimeCore as BaseAssistantRuntimeCore, internal_DefaultThreadComposerRuntimeCore as DefaultThreadComposerRuntimeCore, internal_MessageRepository as MessageRepository, internal_ProxyConfigProvider as ProxyConfigProvider, type internal_ThreadRuntimeCore as ThreadRuntimeCore, type internal_ThreadRuntimeCoreBinding as ThreadRuntimeCoreBinding, internal_ThreadRuntimeImpl as ThreadRuntimeImpl, internal_TooltipIconButton as TooltipIconButton, internal_generateId as generateId, internal_useSmooth as useSmooth, internal_useSmoothStatus as useSmoothStatus, internal_withSmoothContextProvider as withSmoothContextProvider };
3038
- }
3039
-
3040
- export { index$7 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveFeedbackNegativeProps, type ActionBarPrimitiveFeedbackPositiveProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$a as AssistantActionBar, type AssistantContextValue, _default$9 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$8 as AssistantModal, index$6 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, Attachment$1 as Attachment, type AttachmentAdapter, index$5 as AttachmentPrimitive, _default$5 as AttachmentUI, _default$7 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CompleteAttachment, _default$6 as Composer, _default$5 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerRuntime, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartRuntime, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerRuntime, 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, type MessageRuntime, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, PendingAttachment, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SubmitFeedbackOptions, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$3 as Thread, ThreadAssistantContentPart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSuggestion, 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$1 as UserActionBar, _default$2 as UserMessage, _default$5 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantActions, useAssistantActionsStore, useAssistantContext, useAssistantInstructions, useAssistantRuntime, useAssistantRuntimeStore, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposer, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerRuntime, useComposerSend, useComposerStore, useContentPart, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartRuntime, useContentPartStore, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useEditComposer, useEditComposerStore, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessage, useMessageContext, useMessageIf, useMessageRuntime, useMessageStore, useMessageUtils, useMessageUtilsStore, useSwitchToNewThread, useThread, useThreadActions, useThreadActionsStore, useThreadComposer, useThreadComposerStore, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadMessages, useThreadMessagesStore, useThreadRuntime, useThreadRuntimeStore, useThreadScrollToBottom, useThreadStore, useThreadSuggestion, useThreadViewport, useThreadViewportStore, useToolUIs, useToolUIsStore };
4198
+ export { index$7 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveFeedbackNegativeProps, type ActionBarPrimitiveFeedbackPositiveProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$a as AssistantActionBar, type AssistantContextValue, _default$9 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$8 as AssistantModal, index$6 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantRuntime, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantToolUIsState, Attachment$1 as Attachment, type AttachmentAdapter, index$5 as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, _default$5 as AttachmentUI, _default$7 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CompleteAttachment, _default$6 as Composer, _default$5 as ComposerAttachment, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerRuntime, type ComposerState, CompositeAttachmentAdapter, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartRuntime, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerRuntime, 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, type MessageRuntime, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, PendingAttachment, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SubmitFeedbackOptions, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, TextContentPartProvider, _default$3 as Thread, ThreadAssistantContentPart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, type ThreadManagerRuntime, type ThreadManagerState, ThreadMessage, type ThreadMessageLike, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, type ThreadRuntime, type ThreadState, type ThreadSuggestion, ThreadUserContentPart, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, _default$5 as UserMessageAttachment, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantActions, useAssistantActionsStore, useAssistantContext, useAssistantInstructions, useAssistantRuntime, useAssistantRuntimeStore, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposer, useComposerAddAttachment, useComposerCancel, useComposerContext, useComposerIf, useComposerRuntime, useComposerSend, useComposerStore, useContentPart, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartRuntime, useContentPartStore, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useEditComposer, useEditComposerStore, useExternalMessageConverter, useExternalStoreRuntime, useLocalRuntime, useMessage, useMessageContext, useMessageIf, useMessageRuntime, useMessageStore, useMessageUtils, useMessageUtilsStore, useSwitchToNewThread, useThread, useThreadActions, useThreadActionsStore, useThreadComposer, useThreadComposerStore, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadManager, useThreadMessages, useThreadMessagesStore, useThreadModelConfig, useThreadRuntime, useThreadRuntimeStore, useThreadScrollToBottom, useThreadStore, useThreadSuggestion, useThreadViewport, useThreadViewportStore, useToolUIs, useToolUIsStore };