@dudko.dev/agent-web-react 0.0.38 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,8 +2,8 @@ import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
3
  import { AskUserRequest, AskUserContext, AskUserAnswer, AskUserConfig, AskUserHandler, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, AppToolCallRequest, AppSamplingRequest, AppSamplingView, AppSamplingResult, CompactResult, IUsage, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions, ModelTier, TierReason, EscalationReason, DecisionFallbackReason, Skill, IPlan, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
4
4
  export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AskUserAnswer, AskUserConfig, AskUserContext, AskUserHandler, AskUserOption, AskUserRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, SessionBusyError, SessionHolder, SessionLockMode, SessionRunState, SessionWatch, Skill, SkillStore, StorageChange, StorageChangeKind, StorageChangeOp, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, WatchSessionOptions, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, onStorageChange, parseSkillMarkdown, postStorageChange, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel, watchSession } from '@dudko.dev/agent-web';
5
- import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-BgSf-xzh.cjs';
6
- export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-BgSf-xzh.cjs';
5
+ import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, Q as QuestionView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-IpjGRDD-.cjs';
6
+ export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, V as ElicitationOption, X as FetchView, Y as MCP_APP_DISPLAY_MODES, Z as MCP_APP_MAX_ARGS_CHARS, _ as MCP_APP_MAX_DOWNLOAD_BYTES, $ as MCP_APP_MAX_FILE_NAME_CHARS, a0 as MCP_APP_MAX_IN_FLIGHT, a1 as MCP_APP_MAX_MESSAGE_CHARS, a2 as MCP_APP_MAX_URL_CHARS, a3 as MCP_APP_NOTIFICATIONS, a4 as MCP_APP_OPTIONAL_REQUESTS, a5 as MCP_APP_PROTOCOL_VERSION, a6 as MCP_APP_REFUSED, a7 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a8 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a9 as MCP_APP_RELAY, aa as MCP_APP_REQUESTS, ab as MCP_APP_SANDBOX_FRAME_TOKENS, ac as MCP_APP_SANDBOX_GRACE_MS, ad as MCP_APP_SANDBOX_SERVER, ae as MCP_APP_SANDBOX_TIMEOUT_MS, af as McpAppBridge, ag as McpAppBridgeHandlers, ah as McpAppBridgeOptions, ai as McpAppDisplayMode, aj as McpAppRpcError, ak as McpAppRpcMessage, al as McpAppSandboxInput, am as McpAppSandboxLink, an as McpAppSandboxLinkOptions, ao as McpAppSandboxTarget, ap as McpElicitationFieldSchema, aq as McpElicitationRequest, ar as McpElicitationSchema, as as QueuedMessageView, at as ReplanState, au as SkillConsentView, av as StepEscalationView, aw as UseMcpAppHostOptions, ax as appDisplayModeAllowed, ay as appDownloadOf, az as appDownloadRefusal, aA as appFileExtensionOf, aB as appFileNameOf, aC as appGestureOf, aD as appLinkOf, aE as appMessageTextOf, aF as appMimeTypeOf, aG as appSamplingErrorOf, aH as buildMcpAppDocument, aI as buildMcpAppSandboxShell, aJ as clampAppHeight, aK as elicitationFields, aL as elicitationFormAnswer, aM as elicitationInitialDraft, aN as elicitationLink, aO as formatCountdown, aP as grantedAppCsp, aQ as mcpAppCsp, aR as mcpAppHostCapabilities, aS as mcpAppSandboxProxyUrl, aT as mcpAppSandboxShellCsp, aU as mcpAppSandboxTarget, aV as resolveAppDownload, aW as saveAppFile, aX as useMcpAppHost } from './elicitation-IpjGRDD-.cjs';
7
7
  export { M as MCP_APP_POLICY_TOKEN_MAX_CHARS, a as MCP_APP_SANDBOX_PROXY_READY, b as MCP_APP_SANDBOX_RESOURCE_READY, i as isMcpAppSandboxMessage, m as mcpAppPolicyToken } from './mcp-app-policy-DIUmGPJP.cjs';
8
8
 
9
9
  /**
@@ -156,6 +156,7 @@ interface RunGoalOptions {
156
156
  /**
157
157
  * What the transcript shows for this turn when it differs from what the
158
158
  * agent receives — e.g. the typed text without the attached files' contents.
159
+ * `''` with `attachments`: a message of attachments only - the transcript shows them, no text.
159
160
  */
160
161
  label?: string;
161
162
  /** Images sent to the model with the goal (vision models; see `agent.capabilities`). */
@@ -185,8 +186,10 @@ interface UseAgentReturn extends AgentUiState {
185
186
  /**
186
187
  * Say something to the conversation's run in another tab (`remote`): it reaches that run's
187
188
  * model at its next boundary, marked as from another tab. `false` when no such run is followed
188
- * or the text is empty. A message that tab refuses (or never answers) comes back in
189
- * `undelivered`.
189
+ * or the text is empty. Until that tab answers, the text is in `queued` marked
190
+ * `sentTo: 'another-tab'` (shown "waiting for the other tab to pick it up") - with no time
191
+ * limit: a tab the browser froze answers when it wakes. Taken, that run's own entry takes its
192
+ * place; refused, or that run ended without it, it comes back in `undelivered`.
190
193
  */
191
194
  sendRemote: (text: string) => boolean;
192
195
  /**
@@ -356,8 +359,23 @@ declare class ChatHistoryStore {
356
359
  delete(id: string): Promise<void>;
357
360
  clear(): Promise<void>;
358
361
  }
359
- /** A chat's title: its first user message, trimmed. */
360
- declare const chatTitle: (messages: ChatMessage[]) => string;
362
+ /** The words a chat's title and a message of attachments only are said with (`AgentLabels`'). */
363
+ interface AttachmentTexts {
364
+ /** A recording - audio attachments only (default "Voice message"). */
365
+ voiceMessage?: string;
366
+ }
367
+ /**
368
+ * A message of attachments only, in words - where a text is needed (a chat's title, the name a
369
+ * screen reader gives the message): `voiceMessage` when every attachment is audio (a voice
370
+ * message), else the files' names.
371
+ */
372
+ declare const attachmentsText: (attachments: readonly ChatAttachment[], texts?: AttachmentTexts) => string;
373
+ /**
374
+ * A chat's title: its first user message, trimmed. A first message of attachments only is named
375
+ * by what was said in it once the run has transcribed it (the next answer's transcript of an
376
+ * attachment), else by `attachmentsText` - "Voice message", or the files' names.
377
+ */
378
+ declare const chatTitle: (messages: ChatMessage[], texts?: AttachmentTexts) => string;
361
379
  /** A fresh, sortable conversation id (also a valid memory session id). */
362
380
  declare const newChatId: () => string;
363
381
 
@@ -368,6 +386,12 @@ interface UseChatHistoryOptions {
368
386
  enabled?: boolean;
369
387
  /** Open the most recent chat on mount (default true). */
370
388
  resumeLatest?: boolean;
389
+ /**
390
+ * The words a chat that starts with attachments only is titled with (`chatTitle`): pass your
391
+ * `voiceMessage` label so that a chat begun by a voice message is named in your language until
392
+ * its transcript is there.
393
+ */
394
+ labels?: AttachmentTexts;
371
395
  }
372
396
  interface UseChatHistoryReturn {
373
397
  chats: ChatSummary[];
@@ -396,7 +420,9 @@ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefin
396
420
  * everything that is not this tab's own: this tab's own new messages - by identity, not by count,
397
421
  * so a reset or a trim here drops nothing there - go after it.
398
422
  */
399
- declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined) => {
423
+ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined,
424
+ /** The words of a title of attachments only (`chatTitle`). */
425
+ texts?: AttachmentTexts) => {
400
426
  record: ChatRecord;
401
427
  merged: boolean;
402
428
  };
@@ -405,7 +431,7 @@ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined
405
431
  * written in ONE readwrite transaction (`ChatHistoryStore.putMerged`), so another tab's save
406
432
  * cannot land between the two.
407
433
  */
408
- declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined) => Promise<{
434
+ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined, texts?: AttachmentTexts) => Promise<{
409
435
  record: ChatRecord;
410
436
  merged: boolean;
411
437
  }>;
@@ -452,8 +478,13 @@ interface SpeechRecognizerLike {
452
478
  stop(): void;
453
479
  abort?(): void;
454
480
  onresult: ((ev: SpeechResultEventLike) => void) | null;
481
+ /**
482
+ * `error` is the Web Speech API's code (`not-allowed`, `audio-capture`, `network`, ...) or a
483
+ * recognizer's own; `message`, when given, is what to say - in the host's words.
484
+ */
455
485
  onerror: ((ev: {
456
486
  error?: string;
487
+ message?: string;
457
488
  }) => void) | null;
458
489
  onend: (() => void) | null;
459
490
  }
@@ -472,8 +503,9 @@ interface UseSpeechToTextOptions {
472
503
  /** Keep listening across pauses until stopped (default true). */
473
504
  continuous?: boolean;
474
505
  /**
475
- * Build your own recognizer (e.g. a fully local Whisper/WebGPU one) instead
476
- * of the browser's `SpeechRecognition`.
506
+ * Build your own recognizer instead of the browser's `SpeechRecognition` - a fully local
507
+ * Whisper / WebGPU one, or a model of your provider through `createRecordingRecognizer`
508
+ * (records, then transcribes).
477
509
  */
478
510
  createRecognizer?: () => SpeechRecognizerLike;
479
511
  /** Final text chunks, as they are recognized. */
@@ -483,9 +515,17 @@ interface UseSpeechToTextReturn {
483
515
  /** The browser (or your `createRecognizer`) can do speech-to-text. */
484
516
  supported: boolean;
485
517
  listening: boolean;
518
+ /**
519
+ * Stopped, and the last words are still coming: a recording recognizer is waiting for its
520
+ * model (show "Transcribing…"); the browser's is finishing what it heard.
521
+ */
522
+ finishing: boolean;
486
523
  /** Words heard but not final yet (for a live preview). */
487
524
  interim: string;
525
+ /** The last error's code (`not-allowed`: the microphone was refused). */
488
526
  error?: string;
527
+ /** What the recognizer said of it, when it said something (already in the host's words). */
528
+ errorMessage?: string;
489
529
  start: () => void;
490
530
  stop: () => void;
491
531
  toggle: () => void;
@@ -497,6 +537,359 @@ interface UseSpeechToTextReturn {
497
537
  */
498
538
  declare const useSpeechToText: (options?: UseSpeechToTextOptions) => UseSpeechToTextReturn;
499
539
 
540
+ /**
541
+ * Recording from the microphone, for dictation through a model and for voice messages. No React:
542
+ * a hook and the composer are built on it. The browser's `getUserMedia` and `MediaRecorder` can
543
+ * be handed in (`RecordingDeps`), which is how the tests drive it.
544
+ *
545
+ * The rules it keeps:
546
+ * - the permission is asked only by `startRecording` - call it from the person's tap;
547
+ * - every track of the stream is stopped when the recording ends: stopped, cancelled, cut at its
548
+ * longest, or failed - the browser's "recording" indicator goes away;
549
+ * - nothing is kept here: the audio is handed to the caller once, as a `Blob`.
550
+ */
551
+ /** Why the microphone could not be used, as the composer says it (`micProblemLabel`). */
552
+ type MicProblem =
553
+ /** The person (or the browser, for this site) refused the permission. */
554
+ 'not-allowed'
555
+ /** No microphone on the device (or none that fits). */
556
+ | 'audio-capture'
557
+ /** The microphone is held by another app (or the system refused to start it). */
558
+ | 'busy'
559
+ /** No recording here at all: no `mediaDevices` (an insecure page) or no `MediaRecorder`. */
560
+ | 'unsupported' | 'failed';
561
+ /** An error of the microphone, with its `MicProblem`. */
562
+ declare class MicError extends Error {
563
+ readonly code: MicProblem;
564
+ constructor(code: MicProblem, message?: string);
565
+ }
566
+ /** What a recording gave: the bytes, their media type (no codec parameters) and how long it ran. */
567
+ interface RecordedAudio {
568
+ blob: Blob;
569
+ /** `audio/webm`, `audio/mp4` (Safari, iOS), `audio/ogg`... - the container, without `;codecs=`. */
570
+ mediaType: string;
571
+ durationMs: number;
572
+ }
573
+ /** The slice of `MediaRecorder` this module drives. */
574
+ interface MediaRecorderLike {
575
+ readonly mimeType: string;
576
+ readonly state: 'inactive' | 'recording' | 'paused';
577
+ start(timeslice?: number): void;
578
+ stop(): void;
579
+ ondataavailable: ((event: {
580
+ data: Blob;
581
+ }) => void) | null;
582
+ onstop: (() => void) | null;
583
+ onerror: ((event: unknown) => void) | null;
584
+ }
585
+ interface MediaRecorderConstructorLike {
586
+ new (stream: MediaStream, options?: {
587
+ mimeType?: string;
588
+ }): MediaRecorderLike;
589
+ isTypeSupported?(type: string): boolean;
590
+ }
591
+ interface RecordingDeps {
592
+ /** Default: `navigator.mediaDevices.getUserMedia`. */
593
+ getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
594
+ /** Default: the page's `MediaRecorder`. */
595
+ MediaRecorder?: MediaRecorderConstructorLike;
596
+ /** Default: `Date.now`. */
597
+ now?: () => number;
598
+ }
599
+ /** The longest recording unless the caller says otherwise: five minutes. */
600
+ declare const RECORDING_DEFAULT_MAX_MS: number;
601
+ /**
602
+ * The containers asked for, in order: Opus in WebM (Chrome, Edge, Firefox), AAC in MP4 (Safari -
603
+ * iOS records nothing else), Opus in Ogg. Every one is a type the core transcribes and plays.
604
+ */
605
+ declare const RECORDING_TYPES: readonly ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus", "audio/ogg"];
606
+ /** The first type the recorder takes, or undefined (the browser then picks its own). */
607
+ declare const pickRecordingType: (isTypeSupported: ((type: string) => boolean) | undefined) => string | undefined;
608
+ /**
609
+ * A recorder's media type as a file's: the container without parameters, and the names browsers
610
+ * use for the same thing brought to one (`audio/x-m4a`, `audio/m4a`, `video/mp4` from Safari →
611
+ * `audio/mp4`; `video/webm` → `audio/webm`). Unknown or empty: `audio/webm`.
612
+ */
613
+ declare const audioTypeOf: (type: string | undefined) => string;
614
+ /** The file extension of an audio type (`audioTypeOf`'s): `webm`, `m4a`, `ogg`, `wav`, `mp3`, `aac`. */
615
+ declare const audioExtensionOf: (type: string) => string;
616
+ /** What a failed `getUserMedia` (or recorder) means, by the DOMException's name. */
617
+ declare const micProblemOf: (err: unknown) => MicProblem;
618
+ /** Whether this browser can record at all (it does not ask for anything). */
619
+ declare const recordingSupported: (deps?: RecordingDeps) => boolean;
620
+ /** Stop every track of a stream: the microphone is let go. */
621
+ declare const stopTracks: (stream: MediaStream | undefined) => void;
622
+ /** A recording under way. */
623
+ interface Recording {
624
+ /** When it started (the clock of `RecordingDeps.now`). */
625
+ readonly startedAt: number;
626
+ /** Stop it and get the audio. The microphone is let go first. */
627
+ stop(): Promise<RecordedAudio>;
628
+ /** Throw it away. The microphone is let go; `stop` then rejects. */
629
+ cancel(): void;
630
+ /** Settles when the recording has ended, whichever way (the tracks are stopped by then). */
631
+ readonly ended: Promise<void>;
632
+ }
633
+ interface StartRecordingOptions extends RecordingDeps {
634
+ /** Cut it here (default `RECORDING_DEFAULT_MAX_MS`); `onLimit` is told, `stop` still gives the audio. */
635
+ maxMs?: number;
636
+ onLimit?: () => void;
637
+ }
638
+ /**
639
+ * Ask for the microphone and start recording. Rejects with a `MicError` when the microphone
640
+ * cannot be had (the permission refused, no device, held elsewhere, no recorder) - and then no
641
+ * track is left running.
642
+ */
643
+ declare const startRecording: (options?: StartRecordingOptions) => Promise<Recording>;
644
+
645
+ interface UseAudioRecorderOptions extends RecordingDeps {
646
+ /** The longest recording (default five minutes): it is then stopped and kept. */
647
+ maxMs?: number;
648
+ }
649
+ interface UseAudioRecorderReturn {
650
+ /** This browser can record (`getUserMedia` and `MediaRecorder`). */
651
+ supported: boolean;
652
+ /** `starting`: the permission is being asked; `stopping`: the last bytes are being collected. */
653
+ state: 'idle' | 'starting' | 'recording' | 'stopping';
654
+ /** Milliseconds recorded so far (while recording). */
655
+ elapsedMs: number;
656
+ /** Why the last start failed. */
657
+ error: MicProblem | undefined;
658
+ /** A recording that reached `maxMs` and was stopped by itself, waiting to be taken. */
659
+ limited: RecordedAudio | undefined;
660
+ /** Ask for the microphone and record (call it from a tap). */
661
+ start: () => Promise<void>;
662
+ /** Stop and get the audio; undefined when nothing was being recorded. */
663
+ stop: () => Promise<RecordedAudio | undefined>;
664
+ /** Throw the recording away. */
665
+ cancel: () => void;
666
+ /** Forget `limited` and `error`. */
667
+ clear: () => void;
668
+ }
669
+ /**
670
+ * Record from the microphone (a voice message): the permission is asked at `start`, every track
671
+ * is stopped when the recording ends - `stop`, `cancel`, `maxMs`, a failure, or unmount.
672
+ */
673
+ declare const useAudioRecorder: (options?: UseAudioRecorderOptions) => UseAudioRecorderReturn;
674
+
675
+ /**
676
+ * Reading answers aloud: the text an answer is read as (`speakableText`), and two engines behind
677
+ * one shape (`SpeakText`) - the browser's own `speechSynthesis` (on the device, free, offline
678
+ * where the voice is local) and any engine that makes audio (`createAudioSpeaker`: a provider's
679
+ * text-to-speech model, played from a `blob:` URL). No React; `useReadAloud` and the message
680
+ * list's Listen button are built on it.
681
+ */
682
+ /** Where a reading is: making its audio, playing, paused. */
683
+ type ReadAloudState = 'loading' | 'playing' | 'paused';
684
+ /** A reading under way. */
685
+ interface SpeechPlayback {
686
+ pause(): void;
687
+ resume(): void;
688
+ /** End it now; `done` then resolves. */
689
+ stop(): void;
690
+ /** Resolves when the reading ends - read to the end, or stopped; rejects when it failed. */
691
+ readonly done: Promise<void>;
692
+ }
693
+ /** Start reading a text. `onState` hears every change of state until `done` settles. */
694
+ type SpeakText = (text: string, options: {
695
+ lang?: string;
696
+ onState: (state: ReadAloudState) => void;
697
+ }) => SpeechPlayback;
698
+ /**
699
+ * A reading that failed in the engine itself (the browser's voice, the audio element) - a code,
700
+ * not words for the person: the Listen button says its own label. An error a host's
701
+ * `synthesize` throws is shown with its message.
702
+ */
703
+ declare class SpeechOutputError extends Error {
704
+ readonly code: string;
705
+ constructor(code: string);
706
+ }
707
+ interface SpeakableOptions {
708
+ /** Said in place of a code block (default: nothing - the block is skipped). */
709
+ code?: string;
710
+ }
711
+ /**
712
+ * An answer's Markdown as the words to say: no markers (`#`, `*`, `_`, backticks, `>`, list
713
+ * bullets, table rules), a link as its text, a picture as its alt text, a bare URL as its host, a
714
+ * code block NOT read symbol by symbol (left out, or said as `options.code`), inline code as its
715
+ * text, a table's cells one after another. Blocks end in a stop so the voice pauses between them.
716
+ */
717
+ declare const speakableText: (markdown: string, options?: SpeakableOptions) => string;
718
+ /**
719
+ * A text in pieces of at most `max` characters, cut after a sentence where one ends in time,
720
+ * else after a word: engines read long text badly in one go (Chrome's voices stop after some
721
+ * seconds; a provider takes a few thousand characters per call).
722
+ */
723
+ declare const splitForSpeech: (text: string, max?: number) => string[];
724
+ /** A writing system, as far as a voice needs to know: the letters it can read. */
725
+ type SpeechScript = 'latin' | 'cyrillic' | 'greek' | 'arabic' | 'hebrew' | 'han' | 'kana' | 'hangul' | 'devanagari' | 'thai' | 'georgian' | 'armenian';
726
+ /** The script a language (BCP-47) is written in: `sr-Latn` is Latin, `zh-*` Han, `ja` kana. */
727
+ declare const scriptOfLanguage: (lang: string) => SpeechScript;
728
+ /**
729
+ * The script most of a text's letters are written in (digits, signs and spaces do not count);
730
+ * a text with any kana is Japanese (it is mostly Han letters too). Undefined: no letters.
731
+ */
732
+ declare const scriptOfText: (text: string) => SpeechScript | undefined;
733
+ /**
734
+ * The language to read a text in: the first of `preferred` (the UI's language, then the
735
+ * browser's, `navigator.languages`) written in the text's script - so a Russian answer in an
736
+ * English interface is read in Russian, not spelled by an English voice -, else the script's
737
+ * usual language. A text without letters: the first preferred. Which of the languages of ONE
738
+ * script (English or French) cannot be told from the letters: the person's order decides.
739
+ */
740
+ declare const languageOfText: (text: string, preferred?: readonly (string | undefined)[]) => string | undefined;
741
+ /** The slice of a `SpeechSynthesisVoice` used here. */
742
+ interface SpeechVoiceLike {
743
+ voiceURI: string;
744
+ name: string;
745
+ lang: string;
746
+ localService?: boolean;
747
+ default?: boolean;
748
+ }
749
+ /**
750
+ * The voice to read a language with: the person's (by `voiceURI`) while the browser has it and it
751
+ * reads that language's script; else
752
+ * one of exactly that language (`pt-BR`), then of its base (`pt`) - a voice on the device before a
753
+ * network one, the browser's default of the language first. Undefined: none for the language (the
754
+ * browser then reads with its own default).
755
+ */
756
+ declare const voiceFor: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined, preferred?: string) => V | undefined;
757
+ /** The voices of a language (`voiceFor`'s matching), for a picker. */
758
+ declare const voicesOf: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined) => V[];
759
+ /** The slice of `speechSynthesis` this module drives. */
760
+ interface SpeechSynthesisLike {
761
+ speak(utterance: SpeechUtteranceLike): void;
762
+ cancel(): void;
763
+ pause(): void;
764
+ resume(): void;
765
+ getVoices(): SpeechVoiceLike[];
766
+ readonly speaking?: boolean;
767
+ }
768
+ interface SpeechUtteranceLike {
769
+ text: string;
770
+ lang: string;
771
+ voice: SpeechVoiceLike | null;
772
+ rate: number;
773
+ onstart: (() => void) | null;
774
+ onend: (() => void) | null;
775
+ onerror: ((event: {
776
+ error?: string;
777
+ }) => void) | null;
778
+ }
779
+ /** Whether the browser can read aloud (it has `speechSynthesis`). */
780
+ declare const speechSynthesisSupported: () => boolean;
781
+ interface BrowserSpeakerOptions {
782
+ /** The person's voice (`voiceURI`); else one of the text's language (`voiceFor`). */
783
+ voice?: string;
784
+ /** 0.1-10, default 1. */
785
+ rate?: number;
786
+ /** Default: the page's `speechSynthesis` and `SpeechSynthesisUtterance` (tests hand in their own). */
787
+ synth?: SpeechSynthesisLike;
788
+ createUtterance?: (text: string) => SpeechUtteranceLike;
789
+ }
790
+ /**
791
+ * Read with the browser's `speechSynthesis`: on the device (a local voice works offline), free.
792
+ * The text goes in pieces (`splitForSpeech`); one reading at a time in the whole page - starting
793
+ * one cancels any other.
794
+ */
795
+ declare const createBrowserSpeaker: (options?: BrowserSpeakerOptions) => SpeakText;
796
+ /** Make the audio of a text: the host's call to a text-to-speech model. */
797
+ type SynthesizeSpeech = (text: string, context: {
798
+ lang?: string;
799
+ signal: AbortSignal;
800
+ }) => Promise<Blob>;
801
+ /** The slice of an `HTMLAudioElement` this module drives. */
802
+ interface AudioLike {
803
+ src: string;
804
+ paused: boolean;
805
+ play(): Promise<void>;
806
+ pause(): void;
807
+ onended: (() => void) | null;
808
+ onerror: (() => void) | null;
809
+ }
810
+ interface AudioSpeakerOptions {
811
+ synthesize: SynthesizeSpeech;
812
+ /** Characters per call (default 2000): a long answer is several calls, the next made while one plays. */
813
+ maxChars?: number;
814
+ /** Default: `new Audio()`. */
815
+ createAudio?: () => AudioLike;
816
+ /** Default: `URL.createObjectURL` / `URL.revokeObjectURL`. */
817
+ objectUrl?: {
818
+ create: (blob: Blob) => string;
819
+ revoke: (url: string) => void;
820
+ };
821
+ /**
822
+ * Play a moment of silence on the element at once, inside the person's tap (default true): iOS
823
+ * Safari plays an element later - after the audio was made - only if it was played inside the
824
+ * gesture. Call `speak` from the click handler for it to count.
825
+ */
826
+ unlock?: boolean;
827
+ }
828
+ /**
829
+ * Read with an engine that makes audio - a provider's text-to-speech model: each piece of the text
830
+ * (`maxChars`) is made by `synthesize` and played from a `blob:` URL, revoked when it has played
831
+ * or the reading stops. Stopping aborts a call in flight (`signal`). Nothing is stored.
832
+ */
833
+ declare const createAudioSpeaker: (options: AudioSpeakerOptions) => SpeakText;
834
+
835
+ interface UseReadAloudReturn {
836
+ /** The id of what is being read (a message's), or undefined. */
837
+ current: string | undefined;
838
+ /** Where that reading is. */
839
+ state: ReadAloudState | undefined;
840
+ /**
841
+ * The id whose last reading failed (until another starts), with the host's words for it - none
842
+ * when the engine itself failed (`SpeechOutputError`: say your own label).
843
+ */
844
+ failed: {
845
+ id: string;
846
+ message?: string;
847
+ } | undefined;
848
+ /** Read `text` as `id`: whatever else was being read stops first - one at a time. */
849
+ start: (id: string, text: string) => void;
850
+ pause: () => void;
851
+ resume: () => void;
852
+ stop: () => void;
853
+ }
854
+ /**
855
+ * One reading at a time over a list (the chat's answers): `start` stops the one before, `stop`
856
+ * ends it, unmounting ends it. The engine is any `SpeakText` - the browser's voices
857
+ * (`createBrowserSpeaker`) or a provider's (`createAudioSpeaker`).
858
+ */
859
+ declare const useReadAloud: (speak: SpeakText | undefined, lang?: string) => UseReadAloudReturn;
860
+
861
+ /**
862
+ * The browser's voices (`speechSynthesis.getVoices()`), kept current: most browsers fill the list
863
+ * after the page loads (`voiceschanged`). Empty where there is no `speechSynthesis`.
864
+ */
865
+ declare const useSpeechVoices: () => SpeechVoiceLike[];
866
+
867
+ /** Turn a recording into text: the host's call to a speech-to-text model. */
868
+ type TranscribeAudio = (audio: RecordedAudio, context: {
869
+ /** The recognizer's language (BCP-47), a hint for the model. */
870
+ lang: string;
871
+ /** Aborted when the person cancels (or the composer goes away). */
872
+ signal: AbortSignal;
873
+ }) => Promise<string>;
874
+ interface RecordingRecognizerOptions extends RecordingDeps {
875
+ /** The speech-to-text call - a provider's transcription model, an on-device engine. */
876
+ transcribe: TranscribeAudio;
877
+ /** The longest dictation (default: the recorder's five minutes). */
878
+ maxMs?: number;
879
+ }
880
+ /**
881
+ * A recognizer for `useSpeechToText` / the composer's mic (`speech.createRecognizer`) that
882
+ * RECORDS and then hands the audio to `transcribe`: tap to start (the microphone is asked for
883
+ * then), tap again to stop - the words arrive once, as one final result, after the model has
884
+ * answered (`useSpeechToText().finishing` meanwhile). The microphone is let go as soon as the
885
+ * recording stops; the audio is given to `transcribe` and kept nowhere.
886
+ *
887
+ * Errors come as the Web Speech API's codes where there is one (`not-allowed`, `audio-capture`),
888
+ * the recorder's otherwise (`busy`, `unsupported`), and `transcription` with the thrown error's
889
+ * `message` - say it in the host's words: the composer shows the message as given.
890
+ */
891
+ declare const createRecordingRecognizer: (options: RecordingRecognizerOptions) => (() => SpeechRecognizerLike);
892
+
500
893
  interface UseCredentialsReturn {
501
894
  /** The underlying store — pass this straight to `createAgent({ credentials })`. */
502
895
  store: CredentialStore;
@@ -765,6 +1158,8 @@ interface ComposerAttachment {
765
1158
  path?: string;
766
1159
  /** "converted from report.pdf" and the like. */
767
1160
  note?: string;
1161
+ /** A recording's length in milliseconds (a voice message). */
1162
+ durationMs?: number;
768
1163
  }
769
1164
  /** The kind of an attachment from its media type and name. */
770
1165
  declare const attachmentKindOf: (mediaType: string, name: string) => ComposerAttachment["kind"];
@@ -883,6 +1278,16 @@ interface NoticeTexts {
883
1278
  * latest compaction, a failure to start. Pure — derived from the UI state.
884
1279
  */
885
1280
  declare const noticesOf: (state: AgentUiState, texts?: Partial<NoticeTexts>) => ComposerNotice[];
1281
+ /** A recording's length as a clock: `0:07`, `12:30`, `1:02:05`. */
1282
+ declare const formatClock: (ms: number) => string;
1283
+ /**
1284
+ * What to say of a microphone or dictation failure: the recognizer's own words when it gave some
1285
+ * (a host's transcription error, already in its language), else the label of the code - a refused
1286
+ * permission says how to allow it again.
1287
+ */
1288
+ declare const micProblemText: (code: string | undefined, message: string | undefined, labels: Pick<AgentLabels, "micDenied" | "micMissing" | "micBusy" | "micUnsupported" | "dictationFailed" | "microphone">) => string;
1289
+ /** A voice message's file name, from when it was recorded: `voice-2026-11-29-1052.webm`. */
1290
+ declare const voiceMessageName: (at: Date, extension: string) => string;
886
1291
 
887
1292
  /**
888
1293
  * What a workspace file is to the UI. `image` is only what the core's media tools accept
@@ -935,6 +1340,16 @@ interface AgentLabels {
935
1340
  notebookRevision: (n: number) => string;
936
1341
  /** Before the sources a lesson came from. */
937
1342
  notebookFrom: string;
1343
+ /** Before a fact that was just saved. */
1344
+ memorySaved: string;
1345
+ /** Before a fact that was just changed. */
1346
+ memoryUpdated: string;
1347
+ /** Before a fact that was just forgotten. */
1348
+ memoryForgotten: string;
1349
+ /** The card's button that takes it back. */
1350
+ memoryUndo: string;
1351
+ /** In place of the button once it was taken back. */
1352
+ memoryUndone: string;
938
1353
  placeholder: string;
939
1354
  listening: string;
940
1355
  message: string;
@@ -951,6 +1366,35 @@ interface AgentLabels {
951
1366
  dictateTitle: string;
952
1367
  stopDictation: string;
953
1368
  microphone: string;
1369
+ /** While a recording recognizer waits for its model (`useSpeechToText().finishing`). */
1370
+ transcribing: string;
1371
+ /** The microphone was refused (`not-allowed`): how to allow it again. */
1372
+ micDenied: string;
1373
+ /** No microphone on the device (`audio-capture`). */
1374
+ micMissing: string;
1375
+ /** The microphone is held by another app (`busy`). */
1376
+ micBusy: string;
1377
+ /** No recording here at all (`unsupported`: an insecure page, no `MediaRecorder`). */
1378
+ micUnsupported: string;
1379
+ /** A dictation that failed without words of its own. */
1380
+ dictationFailed: string;
1381
+ /** The composer's voice-message button (`voiceMessage` of the composer). */
1382
+ recordVoiceMessage: string;
1383
+ /**
1384
+ * A recording, in words: the title of a chat a voice message starts (until its transcript is
1385
+ * there), the name a screen reader gives a message that is only a recording.
1386
+ */
1387
+ voiceMessage: string;
1388
+ /** The length shown beside a voice message's player (`formatClock`: "0:07"). */
1389
+ audioDuration: (clock: string) => string;
1390
+ /** The strip while a voice message is recorded: "Recording 0:07". */
1391
+ recording: (elapsed: string) => string;
1392
+ /** Its button that keeps the recording as an attachment. */
1393
+ recordingDone: string;
1394
+ /** Its button that throws the recording away. */
1395
+ recordingCancel: string;
1396
+ /** A voice message that reached the longest recording and was stopped by itself. */
1397
+ recordingLimit: string;
954
1398
  model: string;
955
1399
  thinking: string;
956
1400
  toolConsent: string;
@@ -964,6 +1408,7 @@ interface AgentLabels {
964
1408
  agentsTitle: string;
965
1409
  /** Banners: a limit stopped the run / the context was compacted. */
966
1410
  notices: NoticeTexts;
1411
+ /** No longer shown: a message of attachments only is shown as its attachments, with no text. */
967
1412
  attachmentsOnly: string;
968
1413
  seeAttachments: string;
969
1414
  tooLarge: (name: string, mb: number) => string;
@@ -1032,6 +1477,11 @@ interface AgentLabels {
1032
1477
  * run (`sessionBusy`) - in another tab, or in this one - to finish. Shown only while that lasts.
1033
1478
  */
1034
1479
  queuedForSession: (heldBy: 'another-tab' | 'this-tab') => string;
1480
+ /**
1481
+ * What this tab said to the conversation's run in another tab (`sendRemote`), while that tab has
1482
+ * not answered (it may be in the background, frozen by the browser): it is not refused.
1483
+ */
1484
+ queuedForOtherTab: string;
1035
1485
  /** Where a note landed: between tool calls / after a step / before the answer. */
1036
1486
  noteAt: Record<'round' | 'step' | 'final', string>;
1037
1487
  /** Messages the run ended without delivering, offered for sending. */
@@ -1104,6 +1554,18 @@ interface AgentLabels {
1104
1554
  transcriptOf: (name: string) => string;
1105
1555
  /** Says whose words a transcript is: the content of the user's file, not the agent's. */
1106
1556
  transcriptNote: string;
1557
+ /** The accessible name of an attached audio file's player (a voice message). */
1558
+ audioAttachment: (name: string) => string;
1559
+ readAloud: string;
1560
+ readAloudPause: string;
1561
+ readAloudResume: string;
1562
+ readAloudStop: string;
1563
+ /** While the audio is made (a provider's voice). */
1564
+ readAloudLoading: string;
1565
+ /** Said in place of a code block - the code is not read out. Empty: the block is skipped. */
1566
+ readAloudCode: string;
1567
+ /** A reading that failed without words of its own. */
1568
+ readAloudFailed: string;
1107
1569
  /** Above the chips: "3 files written in this turn". */
1108
1570
  filesWritten: (n: number) => string;
1109
1571
  /** In the activity summary: "3 files". */
@@ -1504,6 +1966,28 @@ type AgentAction =
1504
1966
  texts: string[];
1505
1967
  keepQueued?: boolean;
1506
1968
  }
1969
+ /**
1970
+ * `sendRemote`: the text went to the conversation's run in another tab, which has not answered
1971
+ * yet - shown in `queued`, marked `sentTo: 'another-tab'`, until `remote-answer` with this `id`
1972
+ * (or that run's own `message.queued` for it, which takes its place).
1973
+ */
1974
+ | {
1975
+ type: 'remote-send';
1976
+ id: string;
1977
+ text: string;
1978
+ }
1979
+ /**
1980
+ * That tab's answer to `remote-send` `id`: `taken` (its run has it), `refused` (refused, or its
1981
+ * run ended without taking it - the text comes back in `undelivered`, to send again or drop), or
1982
+ * `unknown` (the watch that sent it was closed - another conversation is in view: nothing is
1983
+ * offered, as that tab may still take it). Either way the waiting entry goes.
1984
+ */
1985
+ | {
1986
+ type: 'remote-answer';
1987
+ id: string;
1988
+ text: string;
1989
+ answer: 'taken' | 'refused' | 'unknown';
1990
+ }
1507
1991
  /**
1508
1992
  * The user sent a goal and this tab's run is getting going: its turn is shown at once (a
1509
1993
  * user message and a pending answer), until the run's `run.start` takes its place.
@@ -1554,6 +2038,11 @@ interface ComposerModelOption {
1554
2038
  interface ComposerModelChip {
1555
2039
  /** What the chip says, e.g. "Gemini 3.5 Flash". */
1556
2040
  label: string;
2041
+ /**
2042
+ * What it says when `label` does not fit (a phone) - e.g. "Auto" for "Google AI · Auto". Taken
2043
+ * only while the full label would be cut; the full `label` stays its tooltip.
2044
+ */
2045
+ shortLabel?: string;
1557
2046
  /** Models to switch to from the chip's menu (omit for a read-only label). */
1558
2047
  options?: ComposerModelOption[];
1559
2048
  value?: string;
@@ -1647,9 +2136,23 @@ interface AgentComposerProps {
1647
2136
  * its own panel).
1648
2137
  */
1649
2138
  dropZone?: 'self' | 'window' | RefObject<HTMLElement | null>;
1650
- /** Speech-to-text mic — the browser's Web Speech API (default: on when supported). */
2139
+ /**
2140
+ * Speech-to-text mic (default: on when supported): the browser's Web Speech API, or your own
2141
+ * recognizer - `createRecognizer` (keep it stable), e.g. `createRecordingRecognizer` with a
2142
+ * provider's transcription model: it records, and the words land in the box when the model has
2143
+ * answered. The microphone is asked for only when the mic is tapped.
2144
+ */
1651
2145
  speech?: boolean | {
1652
2146
  lang?: string;
2147
+ createRecognizer?: () => SpeechRecognizerLike;
2148
+ };
2149
+ /**
2150
+ * A voice-message button beside "+" (default false): tap to record, then attach the recording
2151
+ * (or discard it); it is sent as an audio attachment - for an agent whose core transcribes audio
2152
+ * (`media.transcriptionModel`). Needs `attachments`. `maxMs`: the longest (default 5 min).
2153
+ */
2154
+ voiceMessage?: boolean | {
2155
+ maxMs?: number;
1653
2156
  };
1654
2157
  /** Run timer chip (default true). */
1655
2158
  showTimer?: boolean;
@@ -1703,7 +2206,7 @@ interface AgentComposerProps {
1703
2206
  *
1704
2207
  * Every piece can be switched off; `<AgentChat>` uses it as its footer.
1705
2208
  */
1706
- declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, showTimer, showAgents, showApprovalMode, showNotices, steering, showQueued, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, draft, disabled, className, }: AgentComposerProps) => react.JSX.Element;
2209
+ declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, voiceMessage, showTimer, showAgents, showApprovalMode, showNotices, steering, showQueued, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, draft, disabled, className, }: AgentComposerProps) => react.JSX.Element;
1707
2210
 
1708
2211
  interface ChatHistoryListProps {
1709
2212
  /** From `useChatHistory(agent)`. */
@@ -2044,6 +2547,20 @@ interface StepListProps {
2044
2547
  */
2045
2548
  declare const StepList: ({ steps, subagents, approvals, notes, showNotes, onStopSubagent, showToolCalls, showUsage, showThoughts, showTiers, showReplanFailed, showDecisions, showSearchResults, showSubagents, renderToolCall, renderSubagent, labels, className, }: StepListProps) => react.JSX.Element | null;
2046
2549
 
2550
+ /** Read the answers aloud: a Listen button on each finished answer (`<AgentChat readAloud>`). */
2551
+ interface ReadAloudOptions {
2552
+ /** The engine: `createBrowserSpeaker()` (the device's voices) or `createAudioSpeaker(...)`. Keep it stable. */
2553
+ speak: SpeakText;
2554
+ /**
2555
+ * The interface's language (BCP-47), the first choice for a text in its script: each answer is
2556
+ * read in ITS language - the script of its letters decides (`languageOfText`: this, then the
2557
+ * browser's languages, then the script's usual one), so a Russian answer in an English
2558
+ * interface is read by a Russian voice.
2559
+ */
2560
+ lang?: string;
2561
+ /** What is read of an answer. Default: its Markdown as words (`speakableText`, code left out). */
2562
+ textOf?: (message: ChatMessage) => string;
2563
+ }
2047
2564
  interface MessageListProps {
2048
2565
  messages: ChatMessage[];
2049
2566
  /** Rendered when there are no messages yet. */
@@ -2109,8 +2626,22 @@ interface MessageListProps {
2109
2626
  renderMessage?: (message: ChatMessage, fallback: ReactNode) => ReactNode;
2110
2627
  /** An attachment shown with a message (thumbnail / chip by default). */
2111
2628
  renderAttachment?: (attachment: ChatAttachment, message: ChatMessage) => ReactNode;
2629
+ /**
2630
+ * A Listen button on each finished answer - one reading at a time, with Pause / Resume / Stop
2631
+ * (default: none).
2632
+ */
2633
+ readAloud?: ReadAloudOptions;
2112
2634
  /** Tool calls inside the activity. */
2113
2635
  renderToolCall?: RenderToolCall;
2636
+ /**
2637
+ * A tool call as a card in the answer itself - outside the folded activity, above the text -
2638
+ * for the calls the user should see without opening it (a fact remembered, an order placed):
2639
+ * return a node for those (`<MemoryCard>` is one), `null` / `undefined` for the rest. Called for
2640
+ * every tool call of an assistant turn, in order; nothing is drawn without it.
2641
+ */
2642
+ renderToolCard?: (call: ToolCallView, message: ChatMessage) => ReactNode;
2643
+ /** Draw the tool cards (default true; needs `renderToolCard`). */
2644
+ showToolCards?: boolean;
2114
2645
  /**
2115
2646
  * The MCP Apps an answer's tool calls came with (`message.apps`), drawn between its activity
2116
2647
  * and its text. `<AgentChat mcpApps>` passes `<McpAppFrame>`; without this prop none is drawn.
@@ -2130,9 +2661,21 @@ interface MessageListProps {
2130
2661
  }
2131
2662
  /** "in 12k · out 456 · think 120 · cached 9k · 4.2 s" for one answer. */
2132
2663
  declare const usageLine: (usage: IUsage | undefined, durationMs?: number) => string;
2133
- /** The built-in attachment: an image thumbnail (opens in the viewer) or a file chip. */
2134
- declare const AttachmentView: ({ attachment: a }: {
2664
+ /**
2665
+ * Chrome's recordings (WebM from `MediaRecorder`) carry no duration: the native player shows
2666
+ * 0:00 and cannot seek until the media was read to its end. Seeking far past the end makes the
2667
+ * browser read it and set the duration; then it goes back to the start. Only for such a file.
2668
+ */
2669
+ declare const settleAudioDuration: (el: HTMLAudioElement) => void;
2670
+ /**
2671
+ * The built-in attachment: an image thumbnail (opens in the viewer), an audio file as a player
2672
+ * (with `files` and the file's workspace path: read into a `blob:` URL; else a chip with its
2673
+ * length), or a file chip.
2674
+ */
2675
+ declare const AttachmentView: ({ attachment: a, files, labels, }: {
2135
2676
  attachment: ChatAttachment;
2677
+ files?: VirtualFileSystem;
2678
+ labels?: AgentLabelsOverride;
2136
2679
  }) => react.JSX.Element;
2137
2680
  /**
2138
2681
  * The chat transcript. User turns show their text and attachments (image
@@ -2141,7 +2684,7 @@ declare const AttachmentView: ({ attachment: a }: {
2141
2684
  * subagents, consent decisions — and the tokens it spent by kind. Every part
2142
2685
  * can be hidden, relabelled or rendered by the host.
2143
2686
  */
2144
- declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, showNotes, showLearned, showTiers, showReplanFailed, showDecisions, showSearchResults, showSubagents, showMedia, showFileChips, files, htmlPreview, onShowFiles, renderFile, renderFileContent, renderMedia, renderSubagent, onStopSubagent, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, renderApp, showApps, imageViewer, renderImageViewer, labels, className, }: MessageListProps) => react.JSX.Element | null;
2687
+ declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, showNotes, showLearned, showTiers, showReplanFailed, showDecisions, showSearchResults, showSubagents, showMedia, showFileChips, files, htmlPreview, onShowFiles, renderFile, renderFileContent, renderMedia, renderSubagent, onStopSubagent, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, renderToolCard, showToolCards, renderApp, showApps, imageViewer, renderImageViewer, readAloud, labels, className, }: MessageListProps) => react.JSX.Element | null;
2145
2688
 
2146
2689
  interface QuestionPromptProps {
2147
2690
  /**
@@ -2389,7 +2932,17 @@ interface AgentChatProps {
2389
2932
  renderContent?: MessageListProps['renderContent'];
2390
2933
  renderMessage?: MessageListProps['renderMessage'];
2391
2934
  renderAttachment?: MessageListProps['renderAttachment'];
2935
+ /**
2936
+ * A Listen button on each finished answer (default: none): `{ speak, lang? }` with
2937
+ * `createBrowserSpeaker()` for the device's voices, or `createAudioSpeaker({ synthesize })` for
2938
+ * a provider's. One answer is read at a time.
2939
+ */
2940
+ readAloud?: MessageListProps['readAloud'];
2392
2941
  renderToolCall?: RenderToolCall;
2942
+ /** A tool call as a card in the answer, outside the activity (`<MemoryCard>`; see `MessageList`). */
2943
+ renderToolCard?: MessageListProps['renderToolCard'];
2944
+ /** Draw the tool cards (default true; needs `renderToolCard`). */
2945
+ showToolCards?: boolean;
2393
2946
  /** A node of the subagent tree. */
2394
2947
  renderSubagent?: RenderSubagent;
2395
2948
  /** A generated image / audio file. */
@@ -2521,6 +3074,34 @@ interface LearnedSkillsProps {
2521
3074
  */
2522
3075
  declare const LearnedSkills: ({ controller, lessons, onForget, showSources, empty, hideTitle, labels, className, }: LearnedSkillsProps) => react.JSX.Element;
2523
3076
 
3077
+ interface MemoryCardProps {
3078
+ /** What happened: a fact saved, a fact changed, a fact forgotten. */
3079
+ kind: 'saved' | 'updated' | 'forgotten';
3080
+ /** The fact: as it was saved or changed to, or as it was when it was forgotten. Drawn as text. */
3081
+ text: string;
3082
+ /**
3083
+ * Take it back - the host does the work (delete the fact saved, put back the one forgotten or
3084
+ * changed). Absent: no button.
3085
+ */
3086
+ onUndo?: () => void | Promise<unknown>;
3087
+ /**
3088
+ * It has been taken back: the host knows (its store no longer has the fact saved, or has the one
3089
+ * forgotten again) - "Undone" in place of the button, even after a reload.
3090
+ */
3091
+ undone?: boolean;
3092
+ /** Why the last Undo did not go through, in the host's words (shown under the text). */
3093
+ problem?: string;
3094
+ labels?: AgentLabelsOverride;
3095
+ className?: string;
3096
+ }
3097
+ /**
3098
+ * One fact the host's app remembered, changed or forgot about the user, as a card in the answer -
3099
+ * its text and an Undo. The package keeps no memory of its own: the host decides which tool calls
3100
+ * are memory (`<AgentChat renderToolCard>`), what Undo does and when it is undone. The text is a
3101
+ * text node, never markup.
3102
+ */
3103
+ declare const MemoryCard: ({ kind, text, onUndo, undone, problem, labels, className, }: MemoryCardProps) => react.JSX.Element;
3104
+
2524
3105
  interface ComposerProps {
2525
3106
  /** Called with the trimmed text when the user submits. */
2526
3107
  onSubmit: (text: string) => void;
@@ -2950,5 +3531,5 @@ interface AppRequestPromptProps {
2950
3531
  */
2951
3532
  declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
2952
3533
 
2953
- export { ASK_USER_TOOL_NAME, ATTACHMENT_BOUNDS, AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, ImageThumb, ImageViewer, ImageViewerProvider, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MessageList, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, QUESTION_TIMEOUT_MS, QuestionPrompt, QuestionView, RemoteRunView, SandboxedFrame, SourceView, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, askUserOutputKept, askUserWith, attachmentKindOf, attachmentOverLimit, attachmentRefusal, attachmentTransformOf, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createQuestionQueue, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, followsAfterResize, followsAfterScroll, formatElapsed, imageExtensionOf, imageSizeOf, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, messageOverLimit, newChatId, noticesOf, parseSlash, pendingApprovalsOf, questionChoiceOf, questionOtherOf, questionTimeoutOf, sandboxTokens, sandboxedCsp, saveChat, steerIntent, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useFollowScroll, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, webSearchOf, withAttachments, withCspFirst, withPolicyFirst, withoutOwnWords };
2954
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTransform, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MenuSection, MessageListProps, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeechRecognizerLike, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, ToolApprovalPromptProps, ToolCallRowProps, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };
3534
+ export { ASK_USER_TOOL_NAME, ATTACHMENT_BOUNDS, AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, ImageThumb, ImageViewer, ImageViewerProvider, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MemoryCard, MessageList, MicError, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, QUESTION_TIMEOUT_MS, QuestionPrompt, QuestionView, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SandboxedFrame, SourceView, SpeechOutputError, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, askUserOutputKept, askUserWith, attachmentKindOf, attachmentOverLimit, attachmentRefusal, attachmentTransformOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createQuestionQueue, createRecordingRecognizer, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, followsAfterResize, followsAfterScroll, formatClock, formatElapsed, imageExtensionOf, imageSizeOf, languageOfText, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, messageOverLimit, micProblemOf, micProblemText, newChatId, noticesOf, parseSlash, pendingApprovalsOf, pickRecordingType, questionChoiceOf, questionOtherOf, questionTimeoutOf, recordingSupported, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, settleAudioDuration, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, steerIntent, stopTracks, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useAudioRecorder, useChatHistory, useCredentials, useFollowScroll, useLabels, useLocalModel, useOptionalAgentContext, useReadAloud, useSpeechToText, useSpeechVoices, useVirtualFiles, useWebLLMModel, voiceFor, voiceMessageName, voicesOf, webSearchOf, withAttachments, withCspFirst, withPolicyFirst, withoutOwnWords };
3535
+ export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, AttachmentBounds, AttachmentOverLimit, AttachmentTexts, AttachmentTransform, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, ImageSize, ImageThumbProps, ImageViewerProps, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MediaRecorderConstructorLike, MediaRecorderLike, MemoryCardProps, MenuSection, MessageListProps, MicProblem, ModelLoadBarProps, NoticeTexts, PendingQuestion, PlanViewProps, QuestionOutcomeReason, QuestionPromptProps, QuestionQueue, QuestionQueueOptions, ReadAloudOptions, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, RenderImageViewer, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, ScrollMeasure, SlashCommand, SourceToken, SourceViewProps, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, SynthesizeSpeech, ToolApprovalPromptProps, ToolCallRowProps, TranscribeAudio, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseAudioRecorderOptions, UseAudioRecorderReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseReadAloudReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, ViewerImage, WebLLMModelFactory, WebSearchResultView, WebSearchView };