@assistant-ui/react 0.5.40 → 0.5.41

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -110,32 +110,47 @@ declare class MessageRepository {
110
110
  import({ headId, messages }: ExportedMessageRepository): void;
111
111
  }
112
112
 
113
+ declare namespace SpeechSynthesisAdapter {
114
+ type Utterance = {
115
+ stop: () => void;
116
+ onEnd: (callback: () => void) => Unsubscribe;
117
+ };
118
+ }
119
+ type SpeechSynthesisAdapter = {
120
+ speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance;
121
+ };
122
+
113
123
  type LocalRuntimeOptions = {
114
124
  initialMessages?: readonly CoreMessage[] | undefined;
115
125
  maxToolRoundtrips?: number | undefined;
126
+ adapters?: {
127
+ speech?: SpeechSynthesisAdapter | undefined;
128
+ } | undefined;
116
129
  };
117
130
 
118
131
  declare class LocalThreadRuntime implements ThreadRuntime {
119
132
  private configProvider;
120
133
  adapter: ChatModelAdapter;
121
- options: LocalRuntimeOptions;
122
134
  private _subscriptions;
123
135
  private abortController;
124
136
  private readonly repository;
125
- readonly capabilities: Readonly<{
126
- switchToBranch: true;
127
- edit: true;
128
- reload: true;
129
- cancel: true;
130
- copy: true;
131
- }>;
137
+ readonly capabilities: {
138
+ switchToBranch: boolean;
139
+ edit: boolean;
140
+ reload: boolean;
141
+ cancel: boolean;
142
+ unstable_copy: boolean;
143
+ speak: boolean;
144
+ };
132
145
  readonly isDisabled = false;
133
146
  get messages(): ThreadMessage[];
134
147
  readonly composer: {
135
148
  text: string;
136
149
  setText: (value: string) => void;
137
150
  };
138
- constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options: LocalRuntimeOptions);
151
+ constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
152
+ private _options;
153
+ set options({ initialMessages, ...options }: LocalRuntimeOptions);
139
154
  getBranches(messageId: string): string[];
140
155
  switchToBranch(branchId: string): void;
141
156
  append(message: AppendMessage): Promise<void>;
@@ -144,7 +159,8 @@ declare class LocalThreadRuntime implements ThreadRuntime {
144
159
  cancelRun(): void;
145
160
  private notifySubscribers;
146
161
  subscribe(callback: () => void): Unsubscribe;
147
- addToolResult({ messageId, toolCallId, result }: AddToolResultOptions): void;
162
+ addToolResult({ messageId, toolCallId, result, }: AddToolResultOptions): void;
163
+ speak(messageId: string): SpeechSynthesisAdapter.Utterance;
148
164
  export(): ExportedMessageRepository;
149
165
  import(data: ExportedMessageRepository): void;
150
166
  }
@@ -219,7 +235,7 @@ declare class EdgeChatAdapter implements ChatModelAdapter {
219
235
  }
220
236
 
221
237
  type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
222
- declare const useEdgeRuntime: ({ initialMessages, maxToolRoundtrips, ...options }: EdgeRuntimeOptions) => LocalRuntime;
238
+ declare const useEdgeRuntime: ({ initialMessages, maxToolRoundtrips, adapters, ...options }: EdgeRuntimeOptions) => LocalRuntime;
223
239
 
224
240
  type ThreadMessageLike = {
225
241
  role: "assistant" | "user" | "system";
@@ -243,11 +259,14 @@ type ExternalStoreAdapterBase<T> = {
243
259
  onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
244
260
  onReload?: ((parentId: string | null) => Promise<void>) | undefined;
245
261
  onCancel?: (() => Promise<void>) | undefined;
246
- onCopy?: (() => Promise<void>) | null | undefined;
247
262
  onNewThread?: (() => Promise<void> | void) | undefined;
248
263
  onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
249
264
  onSwitchThread?: ((threadId: string | null) => Promise<void> | void) | undefined;
265
+ onSpeak?: ((message: ThreadMessage) => SpeechSynthesisAdapter.Utterance) | undefined;
250
266
  convertMessage?: ExternalStoreMessageConverter<T> | undefined;
267
+ unstable_capabilities?: {
268
+ copy?: boolean | undefined;
269
+ } | undefined;
251
270
  };
252
271
  type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
253
272
 
@@ -349,9 +368,10 @@ declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
349
368
  append(message: AppendMessage): Promise<void>;
350
369
  startRun(parentId: string | null): Promise<void>;
351
370
  cancelRun(): void;
371
+ addToolResult(options: AddToolResultOptions): void;
372
+ speak(messageId: string): SpeechSynthesisAdapter.Utterance;
352
373
  subscribe(callback: () => void): Unsubscribe;
353
374
  private updateMessages;
354
- addToolResult(options: AddToolResultOptions): void;
355
375
  }
356
376
 
357
377
  declare class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {
@@ -372,6 +392,10 @@ type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
372
392
  type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
373
393
  declare const useDangerousInBrowserRuntime: ({ initialMessages, ...options }: DangerousInBrowserRuntimeOptions) => LocalRuntime;
374
394
 
395
+ declare class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter {
396
+ speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance;
397
+ }
398
+
375
399
  type ThreadRuntimeStore = ThreadRuntime;
376
400
 
377
401
  type ThreadState = Readonly<{
@@ -384,7 +408,8 @@ type RuntimeCapabilities = {
384
408
  edit: boolean;
385
409
  reload: boolean;
386
410
  cancel: boolean;
387
- copy: boolean;
411
+ unstable_copy: boolean;
412
+ speak: boolean;
388
413
  };
389
414
 
390
415
  type AddToolResultOptions = {
@@ -399,6 +424,7 @@ type ThreadActionsState = Readonly<{
399
424
  startRun: (parentId: string | null) => void;
400
425
  cancelRun: () => void;
401
426
  addToolResult: (options: AddToolResultOptions) => void;
427
+ speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
402
428
  }>;
403
429
 
404
430
  type ThreadRuntime = ThreadActionsState & Readonly<{
@@ -507,6 +533,9 @@ type MessageUtilsState = Readonly<{
507
533
  setIsCopied: (value: boolean) => void;
508
534
  isHovering: boolean;
509
535
  setIsHovering: (value: boolean) => void;
536
+ isSpeaking: boolean;
537
+ stopSpeaking: () => void;
538
+ addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
510
539
  }>;
511
540
 
512
541
  type MessageContextValue = {
@@ -578,6 +607,10 @@ declare const useActionBarEdit: () => (() => void) | null;
578
607
 
579
608
  declare const useActionBarReload: () => (() => void) | null;
580
609
 
610
+ declare const useActionBarSpeak: () => (() => Promise<void>) | null;
611
+
612
+ declare const useActionBarStopSpeaking: () => (() => Promise<void>) | null;
613
+
581
614
  declare const useBranchPickerCount: () => number;
582
615
 
583
616
  declare const useBranchPickerNext: () => (() => void) | null;
@@ -622,6 +655,7 @@ type MessageIfFilters = {
622
655
  hasBranches: boolean | undefined;
623
656
  copied: boolean | undefined;
624
657
  lastOrHover: boolean | undefined;
658
+ speaking: boolean | undefined;
625
659
  };
626
660
  type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
627
661
  declare const useMessageIf: (props: UseMessageIfProps) => boolean;
@@ -683,8 +717,22 @@ declare const ActionBarPrimitiveEdit: react.ForwardRefExoticComponent<Omit<Omit<
683
717
  asChild?: boolean;
684
718
  }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
685
719
 
720
+ type ActionBarPrimitiveSpeakProps = ActionButtonProps<typeof useActionBarSpeak>;
721
+ declare const ActionBarPrimitiveSpeak: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
722
+ 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;
723
+ } & {
724
+ asChild?: boolean;
725
+ }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
726
+
727
+ type ActionBarPrimitiveStopSpeakingProps = ActionButtonProps<typeof useActionBarStopSpeaking>;
728
+ declare const ActionBarPrimitiveStopSpeaking: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
729
+ 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;
730
+ } & {
731
+ asChild?: boolean;
732
+ }, "ref">> & react.RefAttributes<HTMLButtonElement>>;
733
+
686
734
  declare namespace index$6 {
687
- export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root };
735
+ export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking };
688
736
  }
689
737
 
690
738
  type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;
@@ -930,6 +978,7 @@ type UserMessageConfig = {
930
978
  type AssistantMessageConfig = {
931
979
  allowReload?: boolean | undefined;
932
980
  allowCopy?: boolean | undefined;
981
+ allowSpeak?: boolean | undefined;
933
982
  components?: {
934
983
  Text?: TextContentPartComponent | undefined;
935
984
  } | undefined;
@@ -967,6 +1016,12 @@ type StringsConfig = {
967
1016
  copy?: {
968
1017
  tooltip?: string | undefined;
969
1018
  };
1019
+ speak?: {
1020
+ tooltip?: string | undefined;
1021
+ stop?: {
1022
+ tooltip?: string | undefined;
1023
+ };
1024
+ };
970
1025
  };
971
1026
  branchPicker?: {
972
1027
  previous?: {
@@ -1027,6 +1082,9 @@ declare const exports$a: {
1027
1082
  }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
1028
1083
  Reload: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1029
1084
  Copy: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1085
+ Speak: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1086
+ StopSpeaking: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1087
+ SpeechControl: FC;
1030
1088
  };
1031
1089
  declare const _default$9: typeof AssistantActionBar & typeof exports$a;
1032
1090
 
@@ -1189,4 +1247,4 @@ declare const exports: {
1189
1247
  Text: FC;
1190
1248
  };
1191
1249
 
1192
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
1250
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
package/dist/index.d.ts CHANGED
@@ -110,32 +110,47 @@ declare class MessageRepository {
110
110
  import({ headId, messages }: ExportedMessageRepository): void;
111
111
  }
112
112
 
113
+ declare namespace SpeechSynthesisAdapter {
114
+ type Utterance = {
115
+ stop: () => void;
116
+ onEnd: (callback: () => void) => Unsubscribe;
117
+ };
118
+ }
119
+ type SpeechSynthesisAdapter = {
120
+ speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance;
121
+ };
122
+
113
123
  type LocalRuntimeOptions = {
114
124
  initialMessages?: readonly CoreMessage[] | undefined;
115
125
  maxToolRoundtrips?: number | undefined;
126
+ adapters?: {
127
+ speech?: SpeechSynthesisAdapter | undefined;
128
+ } | undefined;
116
129
  };
117
130
 
118
131
  declare class LocalThreadRuntime implements ThreadRuntime {
119
132
  private configProvider;
120
133
  adapter: ChatModelAdapter;
121
- options: LocalRuntimeOptions;
122
134
  private _subscriptions;
123
135
  private abortController;
124
136
  private readonly repository;
125
- readonly capabilities: Readonly<{
126
- switchToBranch: true;
127
- edit: true;
128
- reload: true;
129
- cancel: true;
130
- copy: true;
131
- }>;
137
+ readonly capabilities: {
138
+ switchToBranch: boolean;
139
+ edit: boolean;
140
+ reload: boolean;
141
+ cancel: boolean;
142
+ unstable_copy: boolean;
143
+ speak: boolean;
144
+ };
132
145
  readonly isDisabled = false;
133
146
  get messages(): ThreadMessage[];
134
147
  readonly composer: {
135
148
  text: string;
136
149
  setText: (value: string) => void;
137
150
  };
138
- constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options: LocalRuntimeOptions);
151
+ constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, { initialMessages, ...options }: LocalRuntimeOptions);
152
+ private _options;
153
+ set options({ initialMessages, ...options }: LocalRuntimeOptions);
139
154
  getBranches(messageId: string): string[];
140
155
  switchToBranch(branchId: string): void;
141
156
  append(message: AppendMessage): Promise<void>;
@@ -144,7 +159,8 @@ declare class LocalThreadRuntime implements ThreadRuntime {
144
159
  cancelRun(): void;
145
160
  private notifySubscribers;
146
161
  subscribe(callback: () => void): Unsubscribe;
147
- addToolResult({ messageId, toolCallId, result }: AddToolResultOptions): void;
162
+ addToolResult({ messageId, toolCallId, result, }: AddToolResultOptions): void;
163
+ speak(messageId: string): SpeechSynthesisAdapter.Utterance;
148
164
  export(): ExportedMessageRepository;
149
165
  import(data: ExportedMessageRepository): void;
150
166
  }
@@ -219,7 +235,7 @@ declare class EdgeChatAdapter implements ChatModelAdapter {
219
235
  }
220
236
 
221
237
  type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
222
- declare const useEdgeRuntime: ({ initialMessages, maxToolRoundtrips, ...options }: EdgeRuntimeOptions) => LocalRuntime;
238
+ declare const useEdgeRuntime: ({ initialMessages, maxToolRoundtrips, adapters, ...options }: EdgeRuntimeOptions) => LocalRuntime;
223
239
 
224
240
  type ThreadMessageLike = {
225
241
  role: "assistant" | "user" | "system";
@@ -243,11 +259,14 @@ type ExternalStoreAdapterBase<T> = {
243
259
  onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
244
260
  onReload?: ((parentId: string | null) => Promise<void>) | undefined;
245
261
  onCancel?: (() => Promise<void>) | undefined;
246
- onCopy?: (() => Promise<void>) | null | undefined;
247
262
  onNewThread?: (() => Promise<void> | void) | undefined;
248
263
  onAddToolResult?: ((options: AddToolResultOptions) => Promise<void> | void) | undefined;
249
264
  onSwitchThread?: ((threadId: string | null) => Promise<void> | void) | undefined;
265
+ onSpeak?: ((message: ThreadMessage) => SpeechSynthesisAdapter.Utterance) | undefined;
250
266
  convertMessage?: ExternalStoreMessageConverter<T> | undefined;
267
+ unstable_capabilities?: {
268
+ copy?: boolean | undefined;
269
+ } | undefined;
251
270
  };
252
271
  type ExternalStoreAdapter<T = ThreadMessage> = ExternalStoreAdapterBase<T> & (T extends ThreadMessage ? object : ExternalStoreMessageConverterAdapter<T>);
253
272
 
@@ -349,9 +368,10 @@ declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
349
368
  append(message: AppendMessage): Promise<void>;
350
369
  startRun(parentId: string | null): Promise<void>;
351
370
  cancelRun(): void;
371
+ addToolResult(options: AddToolResultOptions): void;
372
+ speak(messageId: string): SpeechSynthesisAdapter.Utterance;
352
373
  subscribe(callback: () => void): Unsubscribe;
353
374
  private updateMessages;
354
- addToolResult(options: AddToolResultOptions): void;
355
375
  }
356
376
 
357
377
  declare class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {
@@ -372,6 +392,10 @@ type DangerousInBrowserAdapterOptions = CreateEdgeRuntimeAPIOptions;
372
392
  type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
373
393
  declare const useDangerousInBrowserRuntime: ({ initialMessages, ...options }: DangerousInBrowserRuntimeOptions) => LocalRuntime;
374
394
 
395
+ declare class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter {
396
+ speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance;
397
+ }
398
+
375
399
  type ThreadRuntimeStore = ThreadRuntime;
376
400
 
377
401
  type ThreadState = Readonly<{
@@ -384,7 +408,8 @@ type RuntimeCapabilities = {
384
408
  edit: boolean;
385
409
  reload: boolean;
386
410
  cancel: boolean;
387
- copy: boolean;
411
+ unstable_copy: boolean;
412
+ speak: boolean;
388
413
  };
389
414
 
390
415
  type AddToolResultOptions = {
@@ -399,6 +424,7 @@ type ThreadActionsState = Readonly<{
399
424
  startRun: (parentId: string | null) => void;
400
425
  cancelRun: () => void;
401
426
  addToolResult: (options: AddToolResultOptions) => void;
427
+ speak: (messageId: string) => SpeechSynthesisAdapter.Utterance;
402
428
  }>;
403
429
 
404
430
  type ThreadRuntime = ThreadActionsState & Readonly<{
@@ -507,6 +533,9 @@ type MessageUtilsState = Readonly<{
507
533
  setIsCopied: (value: boolean) => void;
508
534
  isHovering: boolean;
509
535
  setIsHovering: (value: boolean) => void;
536
+ isSpeaking: boolean;
537
+ stopSpeaking: () => void;
538
+ addUtterance: (utterance: SpeechSynthesisAdapter.Utterance) => void;
510
539
  }>;
511
540
 
512
541
  type MessageContextValue = {
@@ -578,6 +607,10 @@ declare const useActionBarEdit: () => (() => void) | null;
578
607
 
579
608
  declare const useActionBarReload: () => (() => void) | null;
580
609
 
610
+ declare const useActionBarSpeak: () => (() => Promise<void>) | null;
611
+
612
+ declare const useActionBarStopSpeaking: () => (() => Promise<void>) | null;
613
+
581
614
  declare const useBranchPickerCount: () => number;
582
615
 
583
616
  declare const useBranchPickerNext: () => (() => void) | null;
@@ -622,6 +655,7 @@ type MessageIfFilters = {
622
655
  hasBranches: boolean | undefined;
623
656
  copied: boolean | undefined;
624
657
  lastOrHover: boolean | undefined;
658
+ speaking: boolean | undefined;
625
659
  };
626
660
  type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
627
661
  declare const useMessageIf: (props: UseMessageIfProps) => boolean;
@@ -683,8 +717,22 @@ declare const ActionBarPrimitiveEdit: react.ForwardRefExoticComponent<Omit<Omit<
683
717
  asChild?: boolean;
684
718
  }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
685
719
 
720
+ type ActionBarPrimitiveSpeakProps = ActionButtonProps<typeof useActionBarSpeak>;
721
+ declare const ActionBarPrimitiveSpeak: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
722
+ 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;
723
+ } & {
724
+ asChild?: boolean;
725
+ }, "ref"> & react.RefAttributes<HTMLButtonElement>>;
726
+
727
+ type ActionBarPrimitiveStopSpeakingProps = ActionButtonProps<typeof useActionBarStopSpeaking>;
728
+ declare const ActionBarPrimitiveStopSpeaking: react.ForwardRefExoticComponent<Partial<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
729
+ 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;
730
+ } & {
731
+ asChild?: boolean;
732
+ }, "ref">> & react.RefAttributes<HTMLButtonElement>>;
733
+
686
734
  declare namespace index$6 {
687
- export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root };
735
+ export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking };
688
736
  }
689
737
 
690
738
  type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;
@@ -930,6 +978,7 @@ type UserMessageConfig = {
930
978
  type AssistantMessageConfig = {
931
979
  allowReload?: boolean | undefined;
932
980
  allowCopy?: boolean | undefined;
981
+ allowSpeak?: boolean | undefined;
933
982
  components?: {
934
983
  Text?: TextContentPartComponent | undefined;
935
984
  } | undefined;
@@ -967,6 +1016,12 @@ type StringsConfig = {
967
1016
  copy?: {
968
1017
  tooltip?: string | undefined;
969
1018
  };
1019
+ speak?: {
1020
+ tooltip?: string | undefined;
1021
+ stop?: {
1022
+ tooltip?: string | undefined;
1023
+ };
1024
+ };
970
1025
  };
971
1026
  branchPicker?: {
972
1027
  previous?: {
@@ -1027,6 +1082,9 @@ declare const exports$a: {
1027
1082
  }, "ref"> & UseActionBarFloatStatusProps & react.RefAttributes<HTMLDivElement>, "ref">, "asChild">> & react.RefAttributes<HTMLDivElement>>;
1028
1083
  Reload: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1029
1084
  Copy: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1085
+ Speak: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1086
+ StopSpeaking: react.ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & react.RefAttributes<HTMLButtonElement>>;
1087
+ SpeechControl: FC;
1030
1088
  };
1031
1089
  declare const _default$9: typeof AssistantActionBar & typeof exports$a;
1032
1090
 
@@ -1189,4 +1247,4 @@ declare const exports: {
1189
1247
  Text: FC;
1190
1248
  };
1191
1249
 
1192
- export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type AddToolResultOptions, AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };
1250
+ export { index$6 as ActionBarPrimitive, type ActionBarPrimitiveCopyProps, type ActionBarPrimitiveEditProps, type ActionBarPrimitiveReloadProps, type ActionBarPrimitiveRootProps, type ActionBarPrimitiveSpeakProps, type ActionBarPrimitiveStopSpeakingProps, type AddToolResultOptions, AppendMessage, _default$9 as AssistantActionBar, type AssistantActionsState, type AssistantContextValue, _default$8 as AssistantMessage, type AssistantMessageConfig, type AssistantMessageContentProps, _default$7 as AssistantModal, index$5 as AssistantModalPrimitive, type AssistantModalPrimitiveContentProps, type AssistantModalPrimitiveRootProps, type AssistantModalPrimitiveTriggerProps, type AssistantModelConfigState, type AssistantRuntime, AssistantRuntimeProvider, type AssistantToolProps, type AssistantToolUIProps, type AssistantToolUIsState, _default$6 as BranchPicker, index$4 as BranchPickerPrimitive, type BranchPickerPrimitiveCountProps, type BranchPickerPrimitiveNextProps, type BranchPickerPrimitiveNumberProps, type BranchPickerPrimitivePreviousProps, type BranchPickerPrimitiveRootProps, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, _default$5 as Composer, type ComposerContextValue, type ComposerInputProps, index$3 as ComposerPrimitive, type ComposerPrimitiveCancelProps, type ComposerPrimitiveIfProps, type ComposerPrimitiveInputProps, type ComposerPrimitiveRootProps, type ComposerPrimitiveSendProps, type ComposerState, exports as ContentPart, type ContentPartContextValue, index$2 as ContentPartPrimitive, type ContentPartPrimitiveDisplayProps, type ContentPartPrimitiveImageProps, type ContentPartPrimitiveInProgressProps, type ContentPartPrimitiveTextProps, type ContentPartState, CoreMessage, type DangerousInBrowserRuntimeOptions, EdgeChatAdapter, type EdgeRuntimeOptions, _default$4 as EditComposer, type EditComposerState, type ExternalStoreAdapter, type ExternalStoreMessageConverter, ExternalStoreRuntime, internal as INTERNAL, ImageContentPart, type ImageContentPartComponent, type ImageContentPartProps, type LocalRuntimeOptions, type MessageContextValue, index$1 as MessagePrimitive, type MessagePrimitiveContentProps, type MessagePrimitiveIfProps, type MessagePrimitiveInProgressProps, type MessagePrimitiveRootProps, type MessageState, MessageStatus, type MessageUtilsState, ModelConfig, ModelConfigProvider, type ReactThreadRuntime, SpeechSynthesisAdapter, StreamUtils, type StringsConfig, type SuggestionConfig, TextContentPart, type TextContentPartComponent, type TextContentPartProps, _default$3 as Thread, type ThreadActionsState, ThreadAssistantContentPart, type ThreadConfig, ThreadConfigProvider, type ThreadConfigProviderProps, type ThreadContextValue, ThreadMessage, type ThreadMessageLike, type ThreadMessagesState, index as ThreadPrimitive, type ThreadPrimitiveEmptyProps, type ThreadPrimitiveIfProps, type ThreadPrimitiveMessagesProps, type ThreadPrimitiveRootProps, type ThreadPrimitiveScrollToBottomProps, type ThreadPrimitiveSuggestionProps, type ThreadPrimitiveViewportProps, type ThreadRootProps, ThreadRuntime, type ThreadState, type ThreadViewportState, _default as ThreadWelcome, type ThreadWelcomeConfig, type ThreadWelcomeMessageProps, type ThreadWelcomeSuggestionProps, Tool, ToolCallContentPart, type ToolCallContentPartComponent, type ToolCallContentPartProps, UIContentPart, type UIContentPartComponent, type UIContentPartProps, type Unsubscribe, type UseActionBarCopyProps, _default$1 as UserActionBar, _default$2 as UserMessage, type UserMessageConfig, type UserMessageContentProps, WebSpeechSynthesisAdapter, fromCoreMessage, fromCoreMessages, fromLanguageModelMessages, fromLanguageModelTools, getExternalStoreMessage, makeAssistantTool, makeAssistantToolUI, streamUtils, subscribeToMainThread, toCoreMessage, toCoreMessages, toLanguageModelMessages, toLanguageModelTools, useActionBarCopy, useActionBarEdit, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAppendMessage, useAssistantContext, useAssistantInstructions, useAssistantTool, useAssistantToolUI, useBranchPickerCount, useBranchPickerNext, useBranchPickerNumber, useBranchPickerPrevious, useComposerCancel, useComposerContext, useComposerIf, useComposerSend, useContentPartContext, useContentPartDisplay, useContentPartImage, useContentPartText, useDangerousInBrowserRuntime, useEdgeRuntime, useExternalStoreRuntime, useLocalRuntime, useMessageContext, useMessageIf, useSwitchToNewThread, useThreadConfig, useThreadContext, useThreadEmpty, useThreadIf, useThreadScrollToBottom, useThreadSuggestion };