@dudko.dev/agent-web-react 0.0.37 → 0.0.39

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-NV1_UPkJ.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-NV1_UPkJ.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-DdzjMut9.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-DdzjMut9.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`). */
@@ -356,8 +357,23 @@ declare class ChatHistoryStore {
356
357
  delete(id: string): Promise<void>;
357
358
  clear(): Promise<void>;
358
359
  }
359
- /** A chat's title: its first user message, trimmed. */
360
- declare const chatTitle: (messages: ChatMessage[]) => string;
360
+ /** The words a chat's title and a message of attachments only are said with (`AgentLabels`'). */
361
+ interface AttachmentTexts {
362
+ /** A recording - audio attachments only (default "Voice message"). */
363
+ voiceMessage?: string;
364
+ }
365
+ /**
366
+ * A message of attachments only, in words - where a text is needed (a chat's title, the name a
367
+ * screen reader gives the message): `voiceMessage` when every attachment is audio (a voice
368
+ * message), else the files' names.
369
+ */
370
+ declare const attachmentsText: (attachments: readonly ChatAttachment[], texts?: AttachmentTexts) => string;
371
+ /**
372
+ * A chat's title: its first user message, trimmed. A first message of attachments only is named
373
+ * by what was said in it once the run has transcribed it (the next answer's transcript of an
374
+ * attachment), else by `attachmentsText` - "Voice message", or the files' names.
375
+ */
376
+ declare const chatTitle: (messages: ChatMessage[], texts?: AttachmentTexts) => string;
361
377
  /** A fresh, sortable conversation id (also a valid memory session id). */
362
378
  declare const newChatId: () => string;
363
379
 
@@ -368,6 +384,12 @@ interface UseChatHistoryOptions {
368
384
  enabled?: boolean;
369
385
  /** Open the most recent chat on mount (default true). */
370
386
  resumeLatest?: boolean;
387
+ /**
388
+ * The words a chat that starts with attachments only is titled with (`chatTitle`): pass your
389
+ * `voiceMessage` label so that a chat begun by a voice message is named in your language until
390
+ * its transcript is there.
391
+ */
392
+ labels?: AttachmentTexts;
371
393
  }
372
394
  interface UseChatHistoryReturn {
373
395
  chats: ChatSummary[];
@@ -396,7 +418,9 @@ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefin
396
418
  * everything that is not this tab's own: this tab's own new messages - by identity, not by count,
397
419
  * so a reset or a trim here drops nothing there - go after it.
398
420
  */
399
- declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined) => {
421
+ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined,
422
+ /** The words of a title of attachments only (`chatTitle`). */
423
+ texts?: AttachmentTexts) => {
400
424
  record: ChatRecord;
401
425
  merged: boolean;
402
426
  };
@@ -405,7 +429,7 @@ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined
405
429
  * written in ONE readwrite transaction (`ChatHistoryStore.putMerged`), so another tab's save
406
430
  * cannot land between the two.
407
431
  */
408
- declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined) => Promise<{
432
+ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined, texts?: AttachmentTexts) => Promise<{
409
433
  record: ChatRecord;
410
434
  merged: boolean;
411
435
  }>;
@@ -452,8 +476,13 @@ interface SpeechRecognizerLike {
452
476
  stop(): void;
453
477
  abort?(): void;
454
478
  onresult: ((ev: SpeechResultEventLike) => void) | null;
479
+ /**
480
+ * `error` is the Web Speech API's code (`not-allowed`, `audio-capture`, `network`, ...) or a
481
+ * recognizer's own; `message`, when given, is what to say - in the host's words.
482
+ */
455
483
  onerror: ((ev: {
456
484
  error?: string;
485
+ message?: string;
457
486
  }) => void) | null;
458
487
  onend: (() => void) | null;
459
488
  }
@@ -472,8 +501,9 @@ interface UseSpeechToTextOptions {
472
501
  /** Keep listening across pauses until stopped (default true). */
473
502
  continuous?: boolean;
474
503
  /**
475
- * Build your own recognizer (e.g. a fully local Whisper/WebGPU one) instead
476
- * of the browser's `SpeechRecognition`.
504
+ * Build your own recognizer instead of the browser's `SpeechRecognition` - a fully local
505
+ * Whisper / WebGPU one, or a model of your provider through `createRecordingRecognizer`
506
+ * (records, then transcribes).
477
507
  */
478
508
  createRecognizer?: () => SpeechRecognizerLike;
479
509
  /** Final text chunks, as they are recognized. */
@@ -483,9 +513,17 @@ interface UseSpeechToTextReturn {
483
513
  /** The browser (or your `createRecognizer`) can do speech-to-text. */
484
514
  supported: boolean;
485
515
  listening: boolean;
516
+ /**
517
+ * Stopped, and the last words are still coming: a recording recognizer is waiting for its
518
+ * model (show "Transcribing…"); the browser's is finishing what it heard.
519
+ */
520
+ finishing: boolean;
486
521
  /** Words heard but not final yet (for a live preview). */
487
522
  interim: string;
523
+ /** The last error's code (`not-allowed`: the microphone was refused). */
488
524
  error?: string;
525
+ /** What the recognizer said of it, when it said something (already in the host's words). */
526
+ errorMessage?: string;
489
527
  start: () => void;
490
528
  stop: () => void;
491
529
  toggle: () => void;
@@ -497,6 +535,341 @@ interface UseSpeechToTextReturn {
497
535
  */
498
536
  declare const useSpeechToText: (options?: UseSpeechToTextOptions) => UseSpeechToTextReturn;
499
537
 
538
+ /**
539
+ * Recording from the microphone, for dictation through a model and for voice messages. No React:
540
+ * a hook and the composer are built on it. The browser's `getUserMedia` and `MediaRecorder` can
541
+ * be handed in (`RecordingDeps`), which is how the tests drive it.
542
+ *
543
+ * The rules it keeps:
544
+ * - the permission is asked only by `startRecording` - call it from the person's tap;
545
+ * - every track of the stream is stopped when the recording ends: stopped, cancelled, cut at its
546
+ * longest, or failed - the browser's "recording" indicator goes away;
547
+ * - nothing is kept here: the audio is handed to the caller once, as a `Blob`.
548
+ */
549
+ /** Why the microphone could not be used, as the composer says it (`micProblemLabel`). */
550
+ type MicProblem =
551
+ /** The person (or the browser, for this site) refused the permission. */
552
+ 'not-allowed'
553
+ /** No microphone on the device (or none that fits). */
554
+ | 'audio-capture'
555
+ /** The microphone is held by another app (or the system refused to start it). */
556
+ | 'busy'
557
+ /** No recording here at all: no `mediaDevices` (an insecure page) or no `MediaRecorder`. */
558
+ | 'unsupported' | 'failed';
559
+ /** An error of the microphone, with its `MicProblem`. */
560
+ declare class MicError extends Error {
561
+ readonly code: MicProblem;
562
+ constructor(code: MicProblem, message?: string);
563
+ }
564
+ /** What a recording gave: the bytes, their media type (no codec parameters) and how long it ran. */
565
+ interface RecordedAudio {
566
+ blob: Blob;
567
+ /** `audio/webm`, `audio/mp4` (Safari, iOS), `audio/ogg`... - the container, without `;codecs=`. */
568
+ mediaType: string;
569
+ durationMs: number;
570
+ }
571
+ /** The slice of `MediaRecorder` this module drives. */
572
+ interface MediaRecorderLike {
573
+ readonly mimeType: string;
574
+ readonly state: 'inactive' | 'recording' | 'paused';
575
+ start(timeslice?: number): void;
576
+ stop(): void;
577
+ ondataavailable: ((event: {
578
+ data: Blob;
579
+ }) => void) | null;
580
+ onstop: (() => void) | null;
581
+ onerror: ((event: unknown) => void) | null;
582
+ }
583
+ interface MediaRecorderConstructorLike {
584
+ new (stream: MediaStream, options?: {
585
+ mimeType?: string;
586
+ }): MediaRecorderLike;
587
+ isTypeSupported?(type: string): boolean;
588
+ }
589
+ interface RecordingDeps {
590
+ /** Default: `navigator.mediaDevices.getUserMedia`. */
591
+ getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
592
+ /** Default: the page's `MediaRecorder`. */
593
+ MediaRecorder?: MediaRecorderConstructorLike;
594
+ /** Default: `Date.now`. */
595
+ now?: () => number;
596
+ }
597
+ /** The longest recording unless the caller says otherwise: five minutes. */
598
+ declare const RECORDING_DEFAULT_MAX_MS: number;
599
+ /**
600
+ * The containers asked for, in order: Opus in WebM (Chrome, Edge, Firefox), AAC in MP4 (Safari -
601
+ * iOS records nothing else), Opus in Ogg. Every one is a type the core transcribes and plays.
602
+ */
603
+ declare const RECORDING_TYPES: readonly ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus", "audio/ogg"];
604
+ /** The first type the recorder takes, or undefined (the browser then picks its own). */
605
+ declare const pickRecordingType: (isTypeSupported: ((type: string) => boolean) | undefined) => string | undefined;
606
+ /**
607
+ * A recorder's media type as a file's: the container without parameters, and the names browsers
608
+ * use for the same thing brought to one (`audio/x-m4a`, `audio/m4a`, `video/mp4` from Safari →
609
+ * `audio/mp4`; `video/webm` → `audio/webm`). Unknown or empty: `audio/webm`.
610
+ */
611
+ declare const audioTypeOf: (type: string | undefined) => string;
612
+ /** The file extension of an audio type (`audioTypeOf`'s): `webm`, `m4a`, `ogg`, `wav`, `mp3`, `aac`. */
613
+ declare const audioExtensionOf: (type: string) => string;
614
+ /** What a failed `getUserMedia` (or recorder) means, by the DOMException's name. */
615
+ declare const micProblemOf: (err: unknown) => MicProblem;
616
+ /** Whether this browser can record at all (it does not ask for anything). */
617
+ declare const recordingSupported: (deps?: RecordingDeps) => boolean;
618
+ /** Stop every track of a stream: the microphone is let go. */
619
+ declare const stopTracks: (stream: MediaStream | undefined) => void;
620
+ /** A recording under way. */
621
+ interface Recording {
622
+ /** When it started (the clock of `RecordingDeps.now`). */
623
+ readonly startedAt: number;
624
+ /** Stop it and get the audio. The microphone is let go first. */
625
+ stop(): Promise<RecordedAudio>;
626
+ /** Throw it away. The microphone is let go; `stop` then rejects. */
627
+ cancel(): void;
628
+ /** Settles when the recording has ended, whichever way (the tracks are stopped by then). */
629
+ readonly ended: Promise<void>;
630
+ }
631
+ interface StartRecordingOptions extends RecordingDeps {
632
+ /** Cut it here (default `RECORDING_DEFAULT_MAX_MS`); `onLimit` is told, `stop` still gives the audio. */
633
+ maxMs?: number;
634
+ onLimit?: () => void;
635
+ }
636
+ /**
637
+ * Ask for the microphone and start recording. Rejects with a `MicError` when the microphone
638
+ * cannot be had (the permission refused, no device, held elsewhere, no recorder) - and then no
639
+ * track is left running.
640
+ */
641
+ declare const startRecording: (options?: StartRecordingOptions) => Promise<Recording>;
642
+
643
+ interface UseAudioRecorderOptions extends RecordingDeps {
644
+ /** The longest recording (default five minutes): it is then stopped and kept. */
645
+ maxMs?: number;
646
+ }
647
+ interface UseAudioRecorderReturn {
648
+ /** This browser can record (`getUserMedia` and `MediaRecorder`). */
649
+ supported: boolean;
650
+ /** `starting`: the permission is being asked; `stopping`: the last bytes are being collected. */
651
+ state: 'idle' | 'starting' | 'recording' | 'stopping';
652
+ /** Milliseconds recorded so far (while recording). */
653
+ elapsedMs: number;
654
+ /** Why the last start failed. */
655
+ error: MicProblem | undefined;
656
+ /** A recording that reached `maxMs` and was stopped by itself, waiting to be taken. */
657
+ limited: RecordedAudio | undefined;
658
+ /** Ask for the microphone and record (call it from a tap). */
659
+ start: () => Promise<void>;
660
+ /** Stop and get the audio; undefined when nothing was being recorded. */
661
+ stop: () => Promise<RecordedAudio | undefined>;
662
+ /** Throw the recording away. */
663
+ cancel: () => void;
664
+ /** Forget `limited` and `error`. */
665
+ clear: () => void;
666
+ }
667
+ /**
668
+ * Record from the microphone (a voice message): the permission is asked at `start`, every track
669
+ * is stopped when the recording ends - `stop`, `cancel`, `maxMs`, a failure, or unmount.
670
+ */
671
+ declare const useAudioRecorder: (options?: UseAudioRecorderOptions) => UseAudioRecorderReturn;
672
+
673
+ /**
674
+ * Reading answers aloud: the text an answer is read as (`speakableText`), and two engines behind
675
+ * one shape (`SpeakText`) - the browser's own `speechSynthesis` (on the device, free, offline
676
+ * where the voice is local) and any engine that makes audio (`createAudioSpeaker`: a provider's
677
+ * text-to-speech model, played from a `blob:` URL). No React; `useReadAloud` and the message
678
+ * list's Listen button are built on it.
679
+ */
680
+ /** Where a reading is: making its audio, playing, paused. */
681
+ type ReadAloudState = 'loading' | 'playing' | 'paused';
682
+ /** A reading under way. */
683
+ interface SpeechPlayback {
684
+ pause(): void;
685
+ resume(): void;
686
+ /** End it now; `done` then resolves. */
687
+ stop(): void;
688
+ /** Resolves when the reading ends - read to the end, or stopped; rejects when it failed. */
689
+ readonly done: Promise<void>;
690
+ }
691
+ /** Start reading a text. `onState` hears every change of state until `done` settles. */
692
+ type SpeakText = (text: string, options: {
693
+ lang?: string;
694
+ onState: (state: ReadAloudState) => void;
695
+ }) => SpeechPlayback;
696
+ /**
697
+ * A reading that failed in the engine itself (the browser's voice, the audio element) - a code,
698
+ * not words for the person: the Listen button says its own label. An error a host's
699
+ * `synthesize` throws is shown with its message.
700
+ */
701
+ declare class SpeechOutputError extends Error {
702
+ readonly code: string;
703
+ constructor(code: string);
704
+ }
705
+ interface SpeakableOptions {
706
+ /** Said in place of a code block (default: nothing - the block is skipped). */
707
+ code?: string;
708
+ }
709
+ /**
710
+ * An answer's Markdown as the words to say: no markers (`#`, `*`, `_`, backticks, `>`, list
711
+ * bullets, table rules), a link as its text, a picture as its alt text, a bare URL as its host, a
712
+ * code block NOT read symbol by symbol (left out, or said as `options.code`), inline code as its
713
+ * text, a table's cells one after another. Blocks end in a stop so the voice pauses between them.
714
+ */
715
+ declare const speakableText: (markdown: string, options?: SpeakableOptions) => string;
716
+ /**
717
+ * A text in pieces of at most `max` characters, cut after a sentence where one ends in time,
718
+ * else after a word: engines read long text badly in one go (Chrome's voices stop after some
719
+ * seconds; a provider takes a few thousand characters per call).
720
+ */
721
+ declare const splitForSpeech: (text: string, max?: number) => string[];
722
+ /** The slice of a `SpeechSynthesisVoice` used here. */
723
+ interface SpeechVoiceLike {
724
+ voiceURI: string;
725
+ name: string;
726
+ lang: string;
727
+ localService?: boolean;
728
+ default?: boolean;
729
+ }
730
+ /**
731
+ * The voice to read a language with: the person's (by `voiceURI`) while the browser has it; else
732
+ * one of exactly that language (`pt-BR`), then of its base (`pt`) - a voice on the device before a
733
+ * network one, the browser's default of the language first. Undefined: none for the language (the
734
+ * browser then reads with its own default).
735
+ */
736
+ declare const voiceFor: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined, preferred?: string) => V | undefined;
737
+ /** The voices of a language (`voiceFor`'s matching), for a picker. */
738
+ declare const voicesOf: <V extends SpeechVoiceLike>(voices: readonly V[], lang: string | undefined) => V[];
739
+ /** The slice of `speechSynthesis` this module drives. */
740
+ interface SpeechSynthesisLike {
741
+ speak(utterance: SpeechUtteranceLike): void;
742
+ cancel(): void;
743
+ pause(): void;
744
+ resume(): void;
745
+ getVoices(): SpeechVoiceLike[];
746
+ readonly speaking?: boolean;
747
+ }
748
+ interface SpeechUtteranceLike {
749
+ text: string;
750
+ lang: string;
751
+ voice: SpeechVoiceLike | null;
752
+ rate: number;
753
+ onstart: (() => void) | null;
754
+ onend: (() => void) | null;
755
+ onerror: ((event: {
756
+ error?: string;
757
+ }) => void) | null;
758
+ }
759
+ /** Whether the browser can read aloud (it has `speechSynthesis`). */
760
+ declare const speechSynthesisSupported: () => boolean;
761
+ interface BrowserSpeakerOptions {
762
+ /** The person's voice (`voiceURI`); else one of the text's language (`voiceFor`). */
763
+ voice?: string;
764
+ /** 0.1-10, default 1. */
765
+ rate?: number;
766
+ /** Default: the page's `speechSynthesis` and `SpeechSynthesisUtterance` (tests hand in their own). */
767
+ synth?: SpeechSynthesisLike;
768
+ createUtterance?: (text: string) => SpeechUtteranceLike;
769
+ }
770
+ /**
771
+ * Read with the browser's `speechSynthesis`: on the device (a local voice works offline), free.
772
+ * The text goes in pieces (`splitForSpeech`); one reading at a time in the whole page - starting
773
+ * one cancels any other.
774
+ */
775
+ declare const createBrowserSpeaker: (options?: BrowserSpeakerOptions) => SpeakText;
776
+ /** Make the audio of a text: the host's call to a text-to-speech model. */
777
+ type SynthesizeSpeech = (text: string, context: {
778
+ lang?: string;
779
+ signal: AbortSignal;
780
+ }) => Promise<Blob>;
781
+ /** The slice of an `HTMLAudioElement` this module drives. */
782
+ interface AudioLike {
783
+ src: string;
784
+ paused: boolean;
785
+ play(): Promise<void>;
786
+ pause(): void;
787
+ onended: (() => void) | null;
788
+ onerror: (() => void) | null;
789
+ }
790
+ interface AudioSpeakerOptions {
791
+ synthesize: SynthesizeSpeech;
792
+ /** Characters per call (default 2000): a long answer is several calls, the next made while one plays. */
793
+ maxChars?: number;
794
+ /** Default: `new Audio()`. */
795
+ createAudio?: () => AudioLike;
796
+ /** Default: `URL.createObjectURL` / `URL.revokeObjectURL`. */
797
+ objectUrl?: {
798
+ create: (blob: Blob) => string;
799
+ revoke: (url: string) => void;
800
+ };
801
+ /**
802
+ * Play a moment of silence on the element at once, inside the person's tap (default true): iOS
803
+ * Safari plays an element later - after the audio was made - only if it was played inside the
804
+ * gesture. Call `speak` from the click handler for it to count.
805
+ */
806
+ unlock?: boolean;
807
+ }
808
+ /**
809
+ * Read with an engine that makes audio - a provider's text-to-speech model: each piece of the text
810
+ * (`maxChars`) is made by `synthesize` and played from a `blob:` URL, revoked when it has played
811
+ * or the reading stops. Stopping aborts a call in flight (`signal`). Nothing is stored.
812
+ */
813
+ declare const createAudioSpeaker: (options: AudioSpeakerOptions) => SpeakText;
814
+
815
+ interface UseReadAloudReturn {
816
+ /** The id of what is being read (a message's), or undefined. */
817
+ current: string | undefined;
818
+ /** Where that reading is. */
819
+ state: ReadAloudState | undefined;
820
+ /**
821
+ * The id whose last reading failed (until another starts), with the host's words for it - none
822
+ * when the engine itself failed (`SpeechOutputError`: say your own label).
823
+ */
824
+ failed: {
825
+ id: string;
826
+ message?: string;
827
+ } | undefined;
828
+ /** Read `text` as `id`: whatever else was being read stops first - one at a time. */
829
+ start: (id: string, text: string) => void;
830
+ pause: () => void;
831
+ resume: () => void;
832
+ stop: () => void;
833
+ }
834
+ /**
835
+ * One reading at a time over a list (the chat's answers): `start` stops the one before, `stop`
836
+ * ends it, unmounting ends it. The engine is any `SpeakText` - the browser's voices
837
+ * (`createBrowserSpeaker`) or a provider's (`createAudioSpeaker`).
838
+ */
839
+ declare const useReadAloud: (speak: SpeakText | undefined, lang?: string) => UseReadAloudReturn;
840
+
841
+ /**
842
+ * The browser's voices (`speechSynthesis.getVoices()`), kept current: most browsers fill the list
843
+ * after the page loads (`voiceschanged`). Empty where there is no `speechSynthesis`.
844
+ */
845
+ declare const useSpeechVoices: () => SpeechVoiceLike[];
846
+
847
+ /** Turn a recording into text: the host's call to a speech-to-text model. */
848
+ type TranscribeAudio = (audio: RecordedAudio, context: {
849
+ /** The recognizer's language (BCP-47), a hint for the model. */
850
+ lang: string;
851
+ /** Aborted when the person cancels (or the composer goes away). */
852
+ signal: AbortSignal;
853
+ }) => Promise<string>;
854
+ interface RecordingRecognizerOptions extends RecordingDeps {
855
+ /** The speech-to-text call - a provider's transcription model, an on-device engine. */
856
+ transcribe: TranscribeAudio;
857
+ /** The longest dictation (default: the recorder's five minutes). */
858
+ maxMs?: number;
859
+ }
860
+ /**
861
+ * A recognizer for `useSpeechToText` / the composer's mic (`speech.createRecognizer`) that
862
+ * RECORDS and then hands the audio to `transcribe`: tap to start (the microphone is asked for
863
+ * then), tap again to stop - the words arrive once, as one final result, after the model has
864
+ * answered (`useSpeechToText().finishing` meanwhile). The microphone is let go as soon as the
865
+ * recording stops; the audio is given to `transcribe` and kept nowhere.
866
+ *
867
+ * Errors come as the Web Speech API's codes where there is one (`not-allowed`, `audio-capture`),
868
+ * the recorder's otherwise (`busy`, `unsupported`), and `transcription` with the thrown error's
869
+ * `message` - say it in the host's words: the composer shows the message as given.
870
+ */
871
+ declare const createRecordingRecognizer: (options: RecordingRecognizerOptions) => (() => SpeechRecognizerLike);
872
+
500
873
  interface UseCredentialsReturn {
501
874
  /** The underlying store — pass this straight to `createAgent({ credentials })`. */
502
875
  store: CredentialStore;
@@ -765,14 +1138,76 @@ interface ComposerAttachment {
765
1138
  path?: string;
766
1139
  /** "converted from report.pdf" and the like. */
767
1140
  note?: string;
1141
+ /** A recording's length in milliseconds (a voice message). */
1142
+ durationMs?: number;
768
1143
  }
769
1144
  /** The kind of an attachment from its media type and name. */
770
1145
  declare const attachmentKindOf: (mediaType: string, name: string) => ComposerAttachment["kind"];
771
1146
  /**
772
1147
  * The goal the agent receives: the typed text followed by each attached TEXT
773
- * file in a fenced block. Binary attachments travel as file parts instead.
1148
+ * file in a fenced block. Binary attachments travel as file parts instead; the
1149
+ * ones saved in the workspace (`path`) are named with it, so a tool can take
1150
+ * the file itself (`generate_image`'s reference pictures).
774
1151
  */
775
1152
  declare const withAttachments: (text: string, files: ComposerAttachment[]) => string;
1153
+ /**
1154
+ * The size bounds of an attachment (`<AgentComposer attachments={…}>`; these are the defaults).
1155
+ * - `maxBytes`: what is SENT. A file that goes as it is, by its size; one the composer transforms
1156
+ * first, by the result - an image it downscales (a 13 MB photo goes as a few hundred KB), a
1157
+ * file the host's `convertFile` turns into text (a 30 MB PDF goes as its Markdown).
1158
+ * - `maxSourceBytes`: the ORIGINAL of one it transforms, judged before it is read or decoded.
1159
+ * - `imageMaxSourcePixels`: the original of an image it downscales, by the pixels its header
1160
+ * declares (`imageSizeOf`) - a decoded picture takes ~4 bytes a pixel. A format whose header is
1161
+ * not read is held to the bytes only.
1162
+ * - `maxImages` / `maxTotalBytes`: ONE message - its pictures, and what all its attachments carry
1163
+ * together (`messageOverLimit`), so a batch never meets the provider's request-size error.
1164
+ */
1165
+ interface AttachmentBounds {
1166
+ maxBytes: number;
1167
+ maxSourceBytes: number;
1168
+ imageMaxSourcePixels: number;
1169
+ maxImages: number;
1170
+ maxTotalBytes: number;
1171
+ }
1172
+ declare const ATTACHMENT_BOUNDS: AttachmentBounds;
1173
+ /**
1174
+ * How an attachment goes to the model: `'convert'` - as the text the host's `convertFile` makes
1175
+ * of it (`converts`: the composer will call it for this file); `'downscale'` - an image of a type
1176
+ * the composer draws smaller (not GIF - animated - or SVG - drawn at any size), while
1177
+ * `imageMaxDimension` is not false; `'none'` - as it is.
1178
+ */
1179
+ type AttachmentTransform = 'none' | 'downscale' | 'convert';
1180
+ declare const attachmentTransformOf: (input: {
1181
+ kind: ComposerAttachment["kind"];
1182
+ mediaType: string;
1183
+ imageMaxDimension: number | false;
1184
+ converts: boolean;
1185
+ }) => AttachmentTransform;
1186
+ /** The bound an attachment is over, and its value (bytes or pixels). */
1187
+ type AttachmentOverLimit = {
1188
+ bound: 'bytes' | 'pixels';
1189
+ limit: number;
1190
+ };
1191
+ /**
1192
+ * Which bound an attachment is over, or undefined. `stage` is when it is judged: `'original'` -
1193
+ * the file as picked (and, for an image to downscale, its pixels when known); `'sent'` - what
1194
+ * goes to the model (the downscaled image, the converted text, or the file as it is). The
1195
+ * original of one the composer transforms is held to `maxSourceBytes` - never below `maxBytes`,
1196
+ * so nothing that passed before is refused for its size - and an image's to
1197
+ * `imageMaxSourcePixels`; what is sent, to `maxBytes`. One it does not transform: `maxBytes` on
1198
+ * the original, as it is.
1199
+ */
1200
+ declare const attachmentOverLimit: (file: {
1201
+ bytes: number;
1202
+ pixels?: number;
1203
+ }, stage: "original" | "sent", transform: AttachmentTransform, bounds: AttachmentBounds) => AttachmentOverLimit | undefined;
1204
+ /**
1205
+ * Which limit of ONE message adding `next` to the attachments already in it would break:
1206
+ * `'images'` - it is a picture and `maxImages` are there; `'bytes'` - what they would carry
1207
+ * together is over `maxTotalBytes`. Each counts as it goes (`bytes`): a picture as downscaled, a
1208
+ * converted file as its text, a text file as itself. undefined: it fits.
1209
+ */
1210
+ declare const messageOverLimit: (inMessage: readonly Pick<ComposerAttachment, "kind" | "bytes">[], next: Pick<ComposerAttachment, "kind" | "bytes">, bounds: Pick<AttachmentBounds, "maxImages" | "maxTotalBytes">) => "images" | "bytes" | undefined;
776
1211
  /**
777
1212
  * Can the current model take this attachment? Returns the reason it can't
778
1213
  * (an actionable sentence), or undefined. `caps` is the core agent's
@@ -823,6 +1258,16 @@ interface NoticeTexts {
823
1258
  * latest compaction, a failure to start. Pure — derived from the UI state.
824
1259
  */
825
1260
  declare const noticesOf: (state: AgentUiState, texts?: Partial<NoticeTexts>) => ComposerNotice[];
1261
+ /** A recording's length as a clock: `0:07`, `12:30`, `1:02:05`. */
1262
+ declare const formatClock: (ms: number) => string;
1263
+ /**
1264
+ * What to say of a microphone or dictation failure: the recognizer's own words when it gave some
1265
+ * (a host's transcription error, already in its language), else the label of the code - a refused
1266
+ * permission says how to allow it again.
1267
+ */
1268
+ declare const micProblemText: (code: string | undefined, message: string | undefined, labels: Pick<AgentLabels, "micDenied" | "micMissing" | "micBusy" | "micUnsupported" | "dictationFailed" | "microphone">) => string;
1269
+ /** A voice message's file name, from when it was recorded: `voice-2026-11-29-1052.webm`. */
1270
+ declare const voiceMessageName: (at: Date, extension: string) => string;
826
1271
 
827
1272
  /**
828
1273
  * What a workspace file is to the UI. `image` is only what the core's media tools accept
@@ -891,6 +1336,35 @@ interface AgentLabels {
891
1336
  dictateTitle: string;
892
1337
  stopDictation: string;
893
1338
  microphone: string;
1339
+ /** While a recording recognizer waits for its model (`useSpeechToText().finishing`). */
1340
+ transcribing: string;
1341
+ /** The microphone was refused (`not-allowed`): how to allow it again. */
1342
+ micDenied: string;
1343
+ /** No microphone on the device (`audio-capture`). */
1344
+ micMissing: string;
1345
+ /** The microphone is held by another app (`busy`). */
1346
+ micBusy: string;
1347
+ /** No recording here at all (`unsupported`: an insecure page, no `MediaRecorder`). */
1348
+ micUnsupported: string;
1349
+ /** A dictation that failed without words of its own. */
1350
+ dictationFailed: string;
1351
+ /** The composer's voice-message button (`voiceMessage` of the composer). */
1352
+ recordVoiceMessage: string;
1353
+ /**
1354
+ * A recording, in words: the title of a chat a voice message starts (until its transcript is
1355
+ * there), the name a screen reader gives a message that is only a recording.
1356
+ */
1357
+ voiceMessage: string;
1358
+ /** The length shown beside a voice message's player (`formatClock`: "0:07"). */
1359
+ audioDuration: (clock: string) => string;
1360
+ /** The strip while a voice message is recorded: "Recording 0:07". */
1361
+ recording: (elapsed: string) => string;
1362
+ /** Its button that keeps the recording as an attachment. */
1363
+ recordingDone: string;
1364
+ /** Its button that throws the recording away. */
1365
+ recordingCancel: string;
1366
+ /** A voice message that reached the longest recording and was stopped by itself. */
1367
+ recordingLimit: string;
894
1368
  model: string;
895
1369
  thinking: string;
896
1370
  toolConsent: string;
@@ -904,10 +1378,21 @@ interface AgentLabels {
904
1378
  agentsTitle: string;
905
1379
  /** Banners: a limit stopped the run / the context was compacted. */
906
1380
  notices: NoticeTexts;
1381
+ /** No longer shown: a message of attachments only is shown as its attachments, with no text. */
907
1382
  attachmentsOnly: string;
908
1383
  seeAttachments: string;
909
1384
  tooLarge: (name: string, mb: number) => string;
1385
+ /** A picture with more pixels than `attachments.imageMaxSourcePixels` (in millions). */
1386
+ tooManyPixels: (name: string, megapixels: number) => string;
910
1387
  binaryText: (name: string) => string;
1388
+ /** An attachment's note: an image sent smaller (`size` is `bytes` of the original). */
1389
+ downscaledFrom: (size: string) => string;
1390
+ /** An attachment's note: a file sent as the text `convertFile` made of it. */
1391
+ convertedFrom: (name: string) => string;
1392
+ /** Files left out: the message has `attachments.maxImages` pictures (`names`: up to three). */
1393
+ tooManyImages: (names: string, max: number) => string;
1394
+ /** Files left out: the message would carry more than `attachments.maxTotalBytes` (in MB). */
1395
+ messageTooLarge: (names: string, mb: number) => string;
911
1396
  commandGroups: {
912
1397
  commands: string;
913
1398
  consent: string;
@@ -1026,10 +1511,26 @@ interface AgentLabels {
1026
1511
  mediaAudio: (path: string) => string;
1027
1512
  /** A generated file that cannot be shown here (no workspace, the file is gone, an unknown type). */
1028
1513
  mediaFile: (path: string) => string;
1514
+ /** Under a generated picture made with reference pictures: their names ("me.jpg, dog.png"). */
1515
+ mediaReferences: (names: string) => string;
1516
+ /** ...and when the image model took none: the picture was made from the text alone. */
1517
+ mediaReferencesUnused: (names: string) => string;
1029
1518
  /** The summary of a transcript block. */
1030
1519
  transcriptOf: (name: string) => string;
1031
1520
  /** Says whose words a transcript is: the content of the user's file, not the agent's. */
1032
1521
  transcriptNote: string;
1522
+ /** The accessible name of an attached audio file's player (a voice message). */
1523
+ audioAttachment: (name: string) => string;
1524
+ readAloud: string;
1525
+ readAloudPause: string;
1526
+ readAloudResume: string;
1527
+ readAloudStop: string;
1528
+ /** While the audio is made (a provider's voice). */
1529
+ readAloudLoading: string;
1530
+ /** Said in place of a code block - the code is not read out. Empty: the block is skipped. */
1531
+ readAloudCode: string;
1532
+ /** A reading that failed without words of its own. */
1533
+ readAloudFailed: string;
1033
1534
  /** Above the chips: "3 files written in this turn". */
1034
1535
  filesWritten: (n: number) => string;
1035
1536
  /** In the activity summary: "3 files". */
@@ -1328,6 +1829,18 @@ interface DownscaleOptions {
1328
1829
  /** JPEG/WebP quality 0..1 (default 0.9). */
1329
1830
  quality?: number;
1330
1831
  }
1832
+ /** A picture's size in pixels, as its file declares it. */
1833
+ interface ImageSize {
1834
+ width: number;
1835
+ height: number;
1836
+ }
1837
+ /**
1838
+ * A picture's size in pixels read from its file's header - a few small reads, nothing decoded -
1839
+ * for PNG, JPEG and WebP (by their bytes, whatever the file's type says). undefined for any
1840
+ * other format, a header that does not add up, or a file that cannot be read: the caller then
1841
+ * goes by the bytes alone. Never throws.
1842
+ */
1843
+ declare const imageSizeOf: (file: Blob) => Promise<ImageSize | undefined>;
1331
1844
  /** The image, smaller when it is larger than the limits; the original otherwise. */
1332
1845
  declare const downscaleImage: (file: Blob, opts?: DownscaleOptions) => Promise<Blob>;
1333
1846
 
@@ -1468,6 +1981,11 @@ interface ComposerModelOption {
1468
1981
  interface ComposerModelChip {
1469
1982
  /** What the chip says, e.g. "Gemini 3.5 Flash". */
1470
1983
  label: string;
1984
+ /**
1985
+ * What it says when `label` does not fit (a phone) - e.g. "Auto" for "Google AI · Auto". Taken
1986
+ * only while the full label would be cut; the full `label` stays its tooltip.
1987
+ */
1988
+ shortLabel?: string;
1471
1989
  /** Models to switch to from the chip's menu (omit for a read-only label). */
1472
1990
  options?: ComposerModelOption[];
1473
1991
  value?: string;
@@ -1513,7 +2031,11 @@ interface AgentComposerProps {
1513
2031
  attachments?: boolean | {
1514
2032
  /** The file picker's `accept`. */
1515
2033
  accept?: string;
1516
- /** Refuse larger files (default 20 MB). */
2034
+ /**
2035
+ * Refuse larger files (default 20 MB) - judged on what is SENT: an image the composer
2036
+ * downscales by the result (a 13 MB photo goes as a few hundred KB), a file `convertFile`
2037
+ * turns into text by the text.
2038
+ */
1517
2039
  maxBytes?: number;
1518
2040
  /**
1519
2041
  * Downscale images to this longest edge before sending (default 1568 —
@@ -1522,6 +2044,24 @@ interface AgentComposerProps {
1522
2044
  imageMaxDimension?: number | false;
1523
2045
  /** …and to this many pixels (default 1 150 000). */
1524
2046
  imageMaxPixels?: number;
2047
+ /**
2048
+ * The original of a file it downscales or converts may be this large (default 50 MB;
2049
+ * never below `maxBytes`): a larger one is refused before it is read.
2050
+ */
2051
+ maxSourceBytes?: number;
2052
+ /**
2053
+ * The original of an image it downscales may have this many pixels, read from its header
2054
+ * before it is decoded (default 200 000 000 - a decoded picture takes ~4 bytes a pixel).
2055
+ * Formats whose header is not read: the bytes only.
2056
+ */
2057
+ imageMaxSourcePixels?: number;
2058
+ /** Pictures in one message, those already attached included (default 20). */
2059
+ maxImages?: number;
2060
+ /**
2061
+ * What one message's attachments carry together (default 20 MB): a picture as downscaled,
2062
+ * a converted file as its text. A file that would go over it is not added.
2063
+ */
2064
+ maxTotalBytes?: number;
1525
2065
  };
1526
2066
  /**
1527
2067
  * Turn a file into text — e.g. PDF → Markdown with `@dudko.dev/pdf-to-md-core`.
@@ -1539,9 +2079,23 @@ interface AgentComposerProps {
1539
2079
  * its own panel).
1540
2080
  */
1541
2081
  dropZone?: 'self' | 'window' | RefObject<HTMLElement | null>;
1542
- /** Speech-to-text mic — the browser's Web Speech API (default: on when supported). */
2082
+ /**
2083
+ * Speech-to-text mic (default: on when supported): the browser's Web Speech API, or your own
2084
+ * recognizer - `createRecognizer` (keep it stable), e.g. `createRecordingRecognizer` with a
2085
+ * provider's transcription model: it records, and the words land in the box when the model has
2086
+ * answered. The microphone is asked for only when the mic is tapped.
2087
+ */
1543
2088
  speech?: boolean | {
1544
2089
  lang?: string;
2090
+ createRecognizer?: () => SpeechRecognizerLike;
2091
+ };
2092
+ /**
2093
+ * A voice-message button beside "+" (default false): tap to record, then attach the recording
2094
+ * (or discard it); it is sent as an audio attachment - for an agent whose core transcribes audio
2095
+ * (`media.transcriptionModel`). Needs `attachments`. `maxMs`: the longest (default 5 min).
2096
+ */
2097
+ voiceMessage?: boolean | {
2098
+ maxMs?: number;
1545
2099
  };
1546
2100
  /** Run timer chip (default true). */
1547
2101
  showTimer?: boolean;
@@ -1595,7 +2149,7 @@ interface AgentComposerProps {
1595
2149
  *
1596
2150
  * Every piece can be switched off; `<AgentChat>` uses it as its footer.
1597
2151
  */
1598
- 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;
2152
+ 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;
1599
2153
 
1600
2154
  interface ChatHistoryListProps {
1601
2155
  /** From `useChatHistory(agent)`. */
@@ -1936,6 +2490,15 @@ interface StepListProps {
1936
2490
  */
1937
2491
  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;
1938
2492
 
2493
+ /** Read the answers aloud: a Listen button on each finished answer (`<AgentChat readAloud>`). */
2494
+ interface ReadAloudOptions {
2495
+ /** The engine: `createBrowserSpeaker()` (the device's voices) or `createAudioSpeaker(...)`. Keep it stable. */
2496
+ speak: SpeakText;
2497
+ /** The answers' language (BCP-47): the browser's voice is picked for it. */
2498
+ lang?: string;
2499
+ /** What is read of an answer. Default: its Markdown as words (`speakableText`, code left out). */
2500
+ textOf?: (message: ChatMessage) => string;
2501
+ }
1939
2502
  interface MessageListProps {
1940
2503
  messages: ChatMessage[];
1941
2504
  /** Rendered when there are no messages yet. */
@@ -2001,6 +2564,11 @@ interface MessageListProps {
2001
2564
  renderMessage?: (message: ChatMessage, fallback: ReactNode) => ReactNode;
2002
2565
  /** An attachment shown with a message (thumbnail / chip by default). */
2003
2566
  renderAttachment?: (attachment: ChatAttachment, message: ChatMessage) => ReactNode;
2567
+ /**
2568
+ * A Listen button on each finished answer - one reading at a time, with Pause / Resume / Stop
2569
+ * (default: none).
2570
+ */
2571
+ readAloud?: ReadAloudOptions;
2004
2572
  /** Tool calls inside the activity. */
2005
2573
  renderToolCall?: RenderToolCall;
2006
2574
  /**
@@ -2022,9 +2590,21 @@ interface MessageListProps {
2022
2590
  }
2023
2591
  /** "in 12k · out 456 · think 120 · cached 9k · 4.2 s" for one answer. */
2024
2592
  declare const usageLine: (usage: IUsage | undefined, durationMs?: number) => string;
2025
- /** The built-in attachment: an image thumbnail (opens in the viewer) or a file chip. */
2026
- declare const AttachmentView: ({ attachment: a }: {
2593
+ /**
2594
+ * Chrome's recordings (WebM from `MediaRecorder`) carry no duration: the native player shows
2595
+ * 0:00 and cannot seek until the media was read to its end. Seeking far past the end makes the
2596
+ * browser read it and set the duration; then it goes back to the start. Only for such a file.
2597
+ */
2598
+ declare const settleAudioDuration: (el: HTMLAudioElement) => void;
2599
+ /**
2600
+ * The built-in attachment: an image thumbnail (opens in the viewer), an audio file as a player
2601
+ * (with `files` and the file's workspace path: read into a `blob:` URL; else a chip with its
2602
+ * length), or a file chip.
2603
+ */
2604
+ declare const AttachmentView: ({ attachment: a, files, labels, }: {
2027
2605
  attachment: ChatAttachment;
2606
+ files?: VirtualFileSystem;
2607
+ labels?: AgentLabelsOverride;
2028
2608
  }) => react.JSX.Element;
2029
2609
  /**
2030
2610
  * The chat transcript. User turns show their text and attachments (image
@@ -2033,7 +2613,7 @@ declare const AttachmentView: ({ attachment: a }: {
2033
2613
  * subagents, consent decisions — and the tokens it spent by kind. Every part
2034
2614
  * can be hidden, relabelled or rendered by the host.
2035
2615
  */
2036
- 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;
2616
+ 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, readAloud, labels, className, }: MessageListProps) => react.JSX.Element | null;
2037
2617
 
2038
2618
  interface QuestionPromptProps {
2039
2619
  /**
@@ -2281,6 +2861,12 @@ interface AgentChatProps {
2281
2861
  renderContent?: MessageListProps['renderContent'];
2282
2862
  renderMessage?: MessageListProps['renderMessage'];
2283
2863
  renderAttachment?: MessageListProps['renderAttachment'];
2864
+ /**
2865
+ * A Listen button on each finished answer (default: none): `{ speak, lang? }` with
2866
+ * `createBrowserSpeaker()` for the device's voices, or `createAudioSpeaker({ synthesize })` for
2867
+ * a provider's. One answer is read at a time.
2868
+ */
2869
+ readAloud?: MessageListProps['readAloud'];
2284
2870
  renderToolCall?: RenderToolCall;
2285
2871
  /** A node of the subagent tree. */
2286
2872
  renderSubagent?: RenderSubagent;
@@ -2842,5 +3428,5 @@ interface AppRequestPromptProps {
2842
3428
  */
2843
3429
  declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
2844
3430
 
2845
- export { ASK_USER_TOOL_NAME, 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, attachmentRefusal, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createQuestionQueue, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, followsAfterResize, followsAfterScroll, formatElapsed, imageExtensionOf, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, 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 };
2846
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerModelOption, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, 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 };
3431
+ 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, 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, lessonsOf, linkedFilesOf, mediaFamilyOf, menuKeyTarget, menuSections, mergeChatRecord, mergeLabels, messageOverLimit, micProblemOf, micProblemText, newChatId, noticesOf, parseSlash, pendingApprovalsOf, pickRecordingType, questionChoiceOf, questionOtherOf, questionTimeoutOf, recordingSupported, sandboxTokens, sandboxedCsp, saveChat, 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 };
3432
+ 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, 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, 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 };