@dudko.dev/agent-web-react 0.0.38 → 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.cjs CHANGED
@@ -96,13 +96,17 @@ __export(src_exports, {
96
96
  MemorySkillStore: () => import_agent_web8.MemorySkillStore,
97
97
  MemoryStore: () => import_agent_web8.MemoryStore,
98
98
  MessageList: () => MessageList,
99
+ MicError: () => MicError,
99
100
  ModelLoadBar: () => ModelLoadBar,
100
101
  PlanView: () => PlanView,
101
102
  QUESTION_TIMEOUT_MS: () => QUESTION_TIMEOUT_MS,
102
103
  QuestionPrompt: () => QuestionPrompt,
104
+ RECORDING_DEFAULT_MAX_MS: () => RECORDING_DEFAULT_MAX_MS,
105
+ RECORDING_TYPES: () => RECORDING_TYPES,
103
106
  SandboxedFrame: () => SandboxedFrame,
104
107
  SessionBusyError: () => import_agent_web8.SessionBusyError,
105
108
  SourceView: () => SourceView,
109
+ SpeechOutputError: () => SpeechOutputError,
106
110
  StepList: () => StepList,
107
111
  SubagentRow: () => SubagentRow,
108
112
  SubagentTree: () => SubagentTree,
@@ -132,6 +136,9 @@ __export(src_exports, {
132
136
  attachmentOverLimit: () => attachmentOverLimit,
133
137
  attachmentRefusal: () => attachmentRefusal,
134
138
  attachmentTransformOf: () => attachmentTransformOf,
139
+ attachmentsText: () => attachmentsText,
140
+ audioExtensionOf: () => audioExtensionOf,
141
+ audioTypeOf: () => audioTypeOf,
135
142
  buildMcpAppDocument: () => buildMcpAppDocument,
136
143
  buildMcpAppSandboxShell: () => buildMcpAppSandboxShell,
137
144
  buildSandboxedDocument: () => buildSandboxedDocument,
@@ -140,9 +147,12 @@ __export(src_exports, {
140
147
  clampFrameHeight: () => clampFrameHeight,
141
148
  createAgent: () => import_agent_web8.createAgent,
142
149
  createApprovalQueue: () => createApprovalQueue,
150
+ createAudioSpeaker: () => createAudioSpeaker,
151
+ createBrowserSpeaker: () => createBrowserSpeaker,
143
152
  createFileTools: () => import_agent_web8.createFileTools,
144
153
  createInitialAgentState: () => createInitialAgentState,
145
154
  createQuestionQueue: () => createQuestionQueue,
155
+ createRecordingRecognizer: () => createRecordingRecognizer,
146
156
  createRunControl: () => import_agent_web8.createRunControl,
147
157
  createSubagentTool: () => import_agent_web8.createSubagentTool,
148
158
  createWebLLMEngine: () => createWebLLMEngine,
@@ -162,6 +172,7 @@ __export(src_exports, {
162
172
  filterCommands: () => filterCommands,
163
173
  followsAfterResize: () => followsAfterResize,
164
174
  followsAfterScroll: () => followsAfterScroll,
175
+ formatClock: () => formatClock,
165
176
  formatCountdown: () => formatCountdown,
166
177
  formatElapsed: () => formatElapsed,
167
178
  grantedAppCsp: () => grantedAppCsp,
@@ -185,24 +196,34 @@ __export(src_exports, {
185
196
  mergeChatRecord: () => mergeChatRecord,
186
197
  mergeLabels: () => mergeLabels,
187
198
  messageOverLimit: () => messageOverLimit,
199
+ micProblemOf: () => micProblemOf,
200
+ micProblemText: () => micProblemText,
188
201
  newChatId: () => newChatId,
189
202
  noticesOf: () => noticesOf,
190
203
  onStorageChange: () => import_agent_web8.onStorageChange,
191
204
  parseSkillMarkdown: () => import_agent_web8.parseSkillMarkdown,
192
205
  parseSlash: () => parseSlash,
193
206
  pendingApprovalsOf: () => pendingApprovalsOf,
207
+ pickRecordingType: () => pickRecordingType,
194
208
  postStorageChange: () => import_agent_web8.postStorageChange,
195
209
  preloadWebLLMModel: () => import_agent_web8.preloadWebLLMModel,
196
210
  questionChoiceOf: () => questionChoiceOf,
197
211
  questionOtherOf: () => questionOtherOf,
198
212
  questionTimeoutOf: () => questionTimeoutOf,
213
+ recordingSupported: () => recordingSupported,
199
214
  resolveAppDownload: () => resolveAppDownload,
200
215
  sandboxTokens: () => sandboxTokens,
201
216
  sandboxedCsp: () => sandboxedCsp,
202
217
  saveAppFile: () => saveAppFile,
203
218
  saveChat: () => saveChat,
204
219
  serveSubagentWorker: () => import_agent_web8.serveSubagentWorker,
220
+ settleAudioDuration: () => settleAudioDuration,
221
+ speakableText: () => speakableText,
222
+ speechSynthesisSupported: () => speechSynthesisSupported,
223
+ splitForSpeech: () => splitForSpeech,
224
+ startRecording: () => startRecording,
205
225
  steerIntent: () => steerIntent,
226
+ stopTracks: () => stopTracks,
206
227
  subagentTree: () => subagentTree,
207
228
  supportsImages: () => import_agent_web8.supportsImages,
208
229
  supportsPdf: () => import_agent_web8.supportsPdf,
@@ -212,6 +233,7 @@ __export(src_exports, {
212
233
  usageLine: () => usageLine,
213
234
  useAgent: () => useAgent,
214
235
  useAgentContext: () => useAgentContext,
236
+ useAudioRecorder: () => useAudioRecorder,
215
237
  useChatHistory: () => useChatHistory,
216
238
  useCredentials: () => useCredentials,
217
239
  useFollowScroll: () => useFollowScroll,
@@ -219,9 +241,14 @@ __export(src_exports, {
219
241
  useLocalModel: () => useLocalModel,
220
242
  useMcpAppHost: () => useMcpAppHost,
221
243
  useOptionalAgentContext: () => useOptionalAgentContext,
244
+ useReadAloud: () => useReadAloud,
222
245
  useSpeechToText: () => useSpeechToText,
246
+ useSpeechVoices: () => useSpeechVoices,
223
247
  useVirtualFiles: () => useVirtualFiles,
224
248
  useWebLLMModel: () => useWebLLMModel,
249
+ voiceFor: () => voiceFor,
250
+ voiceMessageName: () => voiceMessageName,
251
+ voicesOf: () => voicesOf,
225
252
  watchSession: () => import_agent_web8.watchSession,
226
253
  webSearchOf: () => webSearchOf,
227
254
  withAttachments: () => withAttachments,
@@ -1782,7 +1809,8 @@ var useAgent = (config, options = {}) => {
1782
1809
  let began = false;
1783
1810
  const shownGoal = runOptions?.label ?? goal;
1784
1811
  dispatch({ type: "status", status: "running" });
1785
- if (shownGoal.trim()) {
1812
+ const shownAtAll = Boolean(shownGoal.trim() || runOptions?.attachments?.length);
1813
+ if (shownAtAll) {
1786
1814
  dispatch({
1787
1815
  type: "submitted",
1788
1816
  goal: shownGoal,
@@ -1802,14 +1830,16 @@ var useAgent = (config, options = {}) => {
1802
1830
  startedRef.current = true;
1803
1831
  began = true;
1804
1832
  }
1805
- const shown = start && runOptions?.label ? { ...event, goal: runOptions.label } : event;
1833
+ const shown = start && runOptions?.label !== void 0 ? { ...event, goal: runOptions.label } : event;
1806
1834
  dispatch({
1807
1835
  type: "event",
1808
1836
  event: shown,
1809
1837
  maxEvents: optionsRef.current.maxEvents,
1810
1838
  at: Date.now(),
1811
1839
  // What the user sent waits with the run: shown as queued meanwhile.
1812
- ...event.type === "session.busy" && shownGoal.trim() ? { goal: shownGoal } : {},
1840
+ ...event.type === "session.busy" && shownAtAll ? {
1841
+ goal: shownGoal.trim() || (runOptions?.attachments ?? []).map((a) => a.name).join(", ")
1842
+ } : {},
1813
1843
  ...start && runOptions?.attachments?.length ? { attachments: runOptions.attachments } : {}
1814
1844
  });
1815
1845
  try {
@@ -2176,8 +2206,17 @@ var ChatHistoryStore = class {
2176
2206
  await this.write((store) => store.clear(), { op: "clear" });
2177
2207
  }
2178
2208
  };
2179
- var chatTitle = (messages) => {
2180
- const first = messages.find((m) => m.role === "user")?.content.replace(/\s+/g, " ").trim();
2209
+ var attachmentsText = (attachments, texts = {}) => attachments.length > 0 && attachments.every((a) => a.mediaType.toLowerCase().startsWith("audio/")) ? texts.voiceMessage ?? "Voice message" : attachments.map((a) => a.name).join(", ");
2210
+ var oneLine = (text2) => (text2 ?? "").replace(/\s+/g, " ").trim();
2211
+ var chatTitle = (messages, texts = {}) => {
2212
+ const at = messages.findIndex((m) => m.role === "user");
2213
+ const user = at >= 0 ? messages[at] : void 0;
2214
+ let first = oneLine(user?.content);
2215
+ if (!first && user?.attachments?.length) {
2216
+ const answer = messages.slice(at + 1).find((m) => m.role === "assistant");
2217
+ const heard = answer?.transcripts?.find((t) => t.source === "attachment")?.text;
2218
+ first = oneLine(heard) || oneLine(attachmentsText(user.attachments, texts));
2219
+ }
2181
2220
  if (!first) return "New chat";
2182
2221
  return first.length > 60 ? `${first.slice(0, 59)}\u2026` : first;
2183
2222
  };
@@ -2209,7 +2248,7 @@ var renumber = (own, after) => {
2209
2248
  return own.map((m) => ({ ...m, id: `msg-${next += 1}` }));
2210
2249
  };
2211
2250
  var unchangedSince = (messages, base2) => base2 !== void 0 && messages.length === base2.known.size && messages.every((m) => base2.known.has(m));
2212
- var mergeChatRecord = (view, stored, base2) => {
2251
+ var mergeChatRecord = (view, stored, base2, texts) => {
2213
2252
  const local = view.messages.filter((m) => !m.remote);
2214
2253
  if (!stored || base2 && stored.updatedAt <= base2.updatedAt) {
2215
2254
  return { record: { ...view, messages: local }, merged: false };
@@ -2220,7 +2259,7 @@ var mergeChatRecord = (view, stored, base2) => {
2220
2259
  record: {
2221
2260
  ...view,
2222
2261
  createdAt: stored.createdAt,
2223
- title: chatTitle(messages),
2262
+ title: chatTitle(messages, texts),
2224
2263
  messages,
2225
2264
  totalUsage: sumUsage(
2226
2265
  stored.totalUsage,
@@ -2230,10 +2269,10 @@ var mergeChatRecord = (view, stored, base2) => {
2230
2269
  merged: true
2231
2270
  };
2232
2271
  };
2233
- var saveChat = async (store, view, base2) => {
2272
+ var saveChat = async (store, view, base2, texts) => {
2234
2273
  let merged = false;
2235
2274
  const record = await store.putMerged(view.id, (stored) => {
2236
- const out = mergeChatRecord(view, stored, base2);
2275
+ const out = mergeChatRecord(view, stored, base2, texts);
2237
2276
  merged = out.merged;
2238
2277
  return out.record;
2239
2278
  });
@@ -2241,6 +2280,8 @@ var saveChat = async (store, view, base2) => {
2241
2280
  };
2242
2281
  var useChatHistory = (agent, options = {}) => {
2243
2282
  const enabled = options.enabled !== false;
2283
+ const textsRef = (0, import_react2.useRef)(options.labels);
2284
+ textsRef.current = options.labels;
2244
2285
  const store = (0, import_react2.useMemo)(() => options.store ?? new ChatHistoryStore(), [options.store]);
2245
2286
  const [chats, setChats] = (0, import_react2.useState)([]);
2246
2287
  const [loading, setLoading] = (0, import_react2.useState)(enabled);
@@ -2334,14 +2375,14 @@ var useChatHistory = (agent, options = {}) => {
2334
2375
  createdRef.current.set(sessionId, createdAt);
2335
2376
  const view = {
2336
2377
  id: sessionId,
2337
- title: chatTitle(messages),
2378
+ title: chatTitle(messages, textsRef.current),
2338
2379
  createdAt,
2339
2380
  updatedAt: now,
2340
2381
  messages,
2341
2382
  totalUsage
2342
2383
  };
2343
2384
  void (async () => {
2344
- const { record, merged } = await saveChat(store, view, base2);
2385
+ const { record, merged } = await saveChat(store, view, base2, textsRef.current);
2345
2386
  baseRef.current = {
2346
2387
  id: sessionId,
2347
2388
  known: new Set(merged ? record.messages : messages),
@@ -2435,13 +2476,18 @@ var browserRecognizer = () => {
2435
2476
  var useSpeechToText = (options = {}) => {
2436
2477
  const optionsRef = (0, import_react4.useRef)(options);
2437
2478
  optionsRef.current = options;
2438
- const factory = options.createRecognizer ?? browserRecognizer();
2479
+ const own = options.createRecognizer;
2480
+ const factory = (0, import_react4.useMemo)(() => own ?? browserRecognizer(), [own]);
2439
2481
  const [listening, setListening] = (0, import_react4.useState)(false);
2440
2482
  const [interim, setInterim] = (0, import_react4.useState)("");
2441
2483
  const [error, setError] = (0, import_react4.useState)();
2484
+ const [errorMessage, setErrorMessage] = (0, import_react4.useState)();
2485
+ const [finishing, setFinishing] = (0, import_react4.useState)(false);
2442
2486
  const recRef = (0, import_react4.useRef)(void 0);
2443
2487
  const stop = (0, import_react4.useCallback)(() => {
2444
- recRef.current?.stop();
2488
+ if (!recRef.current) return;
2489
+ setFinishing(true);
2490
+ recRef.current.stop();
2445
2491
  }, []);
2446
2492
  const start = (0, import_react4.useCallback)(() => {
2447
2493
  if (!factory || recRef.current) return;
@@ -2459,15 +2505,22 @@ var useSpeechToText = (options = {}) => {
2459
2505
  setInterim(pending);
2460
2506
  };
2461
2507
  rec.onerror = (ev) => {
2462
- if (ev.error && ev.error !== "no-speech" && ev.error !== "aborted") setError(ev.error);
2508
+ if (ev.error && ev.error !== "no-speech" && ev.error !== "aborted") {
2509
+ setError(ev.error);
2510
+ setErrorMessage(ev.message);
2511
+ }
2463
2512
  };
2464
2513
  rec.onend = () => {
2514
+ if (recRef.current !== rec) return;
2465
2515
  recRef.current = void 0;
2466
2516
  setListening(false);
2517
+ setFinishing(false);
2467
2518
  setInterim("");
2468
2519
  };
2469
2520
  recRef.current = rec;
2470
2521
  setError(void 0);
2522
+ setErrorMessage(void 0);
2523
+ setFinishing(false);
2471
2524
  try {
2472
2525
  rec.start();
2473
2526
  setListening(true);
@@ -2476,20 +2529,763 @@ var useSpeechToText = (options = {}) => {
2476
2529
  setError(err instanceof Error ? err.message : String(err));
2477
2530
  }
2478
2531
  }, [factory]);
2479
- (0, import_react4.useEffect)(() => () => recRef.current?.abort?.(), []);
2532
+ (0, import_react4.useEffect)(
2533
+ () => () => {
2534
+ const rec = recRef.current;
2535
+ recRef.current = void 0;
2536
+ rec?.abort?.();
2537
+ },
2538
+ [factory]
2539
+ );
2480
2540
  return {
2481
2541
  supported: Boolean(factory),
2482
2542
  listening,
2543
+ finishing,
2483
2544
  interim,
2484
2545
  error,
2546
+ errorMessage,
2485
2547
  start,
2486
2548
  stop,
2487
2549
  toggle: () => recRef.current ? stop() : start()
2488
2550
  };
2489
2551
  };
2490
2552
 
2491
- // src/hooks/use-credentials.ts
2553
+ // src/hooks/use-audio-recorder.ts
2492
2554
  var import_react5 = require("react");
2555
+
2556
+ // src/voice/record.ts
2557
+ var MicError = class extends Error {
2558
+ code;
2559
+ constructor(code, message = code) {
2560
+ super(message);
2561
+ this.name = "MicError";
2562
+ this.code = code;
2563
+ }
2564
+ };
2565
+ var RECORDING_DEFAULT_MAX_MS = 5 * 60 * 1e3;
2566
+ var RECORDING_TYPES = [
2567
+ "audio/webm;codecs=opus",
2568
+ "audio/webm",
2569
+ "audio/mp4",
2570
+ "audio/ogg;codecs=opus",
2571
+ "audio/ogg"
2572
+ ];
2573
+ var pickRecordingType = (isTypeSupported) => {
2574
+ if (!isTypeSupported) return void 0;
2575
+ for (const type of RECORDING_TYPES) {
2576
+ try {
2577
+ if (isTypeSupported(type)) return type;
2578
+ } catch {
2579
+ }
2580
+ }
2581
+ return void 0;
2582
+ };
2583
+ var audioTypeOf = (type) => {
2584
+ const base2 = (type ?? "").toLowerCase().split(";")[0].trim();
2585
+ if (/^(audio|video)\/(mp4|x-m4a|m4a|aac-mp4)$/.test(base2)) return "audio/mp4";
2586
+ if (/^(audio|video)\/webm$/.test(base2)) return "audio/webm";
2587
+ if (base2 === "audio/ogg" || base2 === "application/ogg") return "audio/ogg";
2588
+ if (base2 === "audio/wav" || base2 === "audio/x-wav" || base2 === "audio/wave") return "audio/wav";
2589
+ if (base2 === "audio/mpeg" || base2 === "audio/mp3") return "audio/mpeg";
2590
+ if (base2 === "audio/aac") return "audio/aac";
2591
+ return "audio/webm";
2592
+ };
2593
+ var audioExtensionOf = (type) => ({
2594
+ "audio/mp4": "m4a",
2595
+ "audio/ogg": "ogg",
2596
+ "audio/wav": "wav",
2597
+ "audio/mpeg": "mp3",
2598
+ "audio/aac": "aac"
2599
+ })[audioTypeOf(type)] ?? "webm";
2600
+ var micProblemOf = (err) => {
2601
+ if (err instanceof MicError) return err.code;
2602
+ const name = err && typeof err === "object" ? String(err.name) : "";
2603
+ if (name === "NotAllowedError" || name === "SecurityError" || name === "PermissionDeniedError")
2604
+ return "not-allowed";
2605
+ if (name === "NotFoundError" || name === "OverconstrainedError" || name === "DevicesNotFoundError")
2606
+ return "audio-capture";
2607
+ if (name === "NotReadableError" || name === "TrackStartError" || name === "AbortError")
2608
+ return "busy";
2609
+ if (name === "NotSupportedError" || name === "TypeError") return "unsupported";
2610
+ return "failed";
2611
+ };
2612
+ var defaults = (deps) => {
2613
+ const g = globalThis;
2614
+ const devices = g.navigator?.mediaDevices;
2615
+ return {
2616
+ getUserMedia: deps.getUserMedia ?? (devices?.getUserMedia ? devices.getUserMedia.bind(devices) : void 0),
2617
+ MediaRecorder: deps.MediaRecorder ?? g.MediaRecorder,
2618
+ now: deps.now ?? Date.now
2619
+ };
2620
+ };
2621
+ var recordingSupported = (deps = {}) => {
2622
+ const d = defaults(deps);
2623
+ return Boolean(d.getUserMedia && d.MediaRecorder);
2624
+ };
2625
+ var stopTracks = (stream) => {
2626
+ for (const track of stream?.getTracks() ?? []) {
2627
+ try {
2628
+ track.stop();
2629
+ } catch {
2630
+ }
2631
+ }
2632
+ };
2633
+ var startRecording = async (options = {}) => {
2634
+ const d = defaults(options);
2635
+ if (!d.getUserMedia || !d.MediaRecorder) throw new MicError("unsupported");
2636
+ let stream;
2637
+ try {
2638
+ stream = await d.getUserMedia({ audio: true });
2639
+ } catch (err) {
2640
+ throw new MicError(micProblemOf(err));
2641
+ }
2642
+ let recorder;
2643
+ try {
2644
+ const type = pickRecordingType(d.MediaRecorder.isTypeSupported?.bind(d.MediaRecorder));
2645
+ recorder = new d.MediaRecorder(stream, type ? { mimeType: type } : void 0);
2646
+ } catch (err) {
2647
+ stopTracks(stream);
2648
+ throw new MicError(micProblemOf(err) === "failed" ? "unsupported" : micProblemOf(err));
2649
+ }
2650
+ const startedAt = d.now();
2651
+ const chunks = [];
2652
+ let cancelled = false;
2653
+ let failure;
2654
+ let settle = () => {
2655
+ };
2656
+ const ended = new Promise((resolve) => settle = resolve);
2657
+ let finish;
2658
+ let fail;
2659
+ const result = new Promise((resolve, reject) => {
2660
+ finish = resolve;
2661
+ fail = reject;
2662
+ });
2663
+ result.catch(() => {
2664
+ });
2665
+ let limit;
2666
+ const end = () => {
2667
+ stopTracks(stream);
2668
+ clearTimeout(limit);
2669
+ settle();
2670
+ };
2671
+ recorder.ondataavailable = (event) => {
2672
+ if (event.data && event.data.size > 0) chunks.push(event.data);
2673
+ };
2674
+ recorder.onerror = () => {
2675
+ failure = new MicError("failed");
2676
+ end();
2677
+ fail?.(failure);
2678
+ };
2679
+ recorder.onstop = () => {
2680
+ end();
2681
+ if (cancelled) return fail?.(new MicError("failed", "cancelled"));
2682
+ if (failure) return fail?.(failure);
2683
+ const mediaType = audioTypeOf(recorder.mimeType || chunks[0]?.type);
2684
+ finish?.({
2685
+ blob: new Blob(chunks, { type: mediaType }),
2686
+ mediaType,
2687
+ durationMs: Math.max(0, d.now() - startedAt)
2688
+ });
2689
+ };
2690
+ const stopRecorder = () => {
2691
+ try {
2692
+ if (recorder.state !== "inactive") recorder.stop();
2693
+ else recorder.onstop?.();
2694
+ } catch {
2695
+ recorder.onstop?.();
2696
+ }
2697
+ };
2698
+ const maxMs = options.maxMs ?? RECORDING_DEFAULT_MAX_MS;
2699
+ limit = setTimeout(() => {
2700
+ stopRecorder();
2701
+ options.onLimit?.();
2702
+ }, maxMs);
2703
+ try {
2704
+ recorder.start(1e3);
2705
+ } catch (err) {
2706
+ end();
2707
+ throw new MicError(micProblemOf(err) === "failed" ? "unsupported" : micProblemOf(err));
2708
+ }
2709
+ return {
2710
+ startedAt,
2711
+ ended,
2712
+ stop: () => {
2713
+ stopRecorder();
2714
+ return result;
2715
+ },
2716
+ cancel: () => {
2717
+ cancelled = true;
2718
+ chunks.length = 0;
2719
+ stopRecorder();
2720
+ end();
2721
+ }
2722
+ };
2723
+ };
2724
+
2725
+ // src/hooks/use-audio-recorder.ts
2726
+ var useAudioRecorder = (options = {}) => {
2727
+ const opts = (0, import_react5.useRef)(options);
2728
+ opts.current = options;
2729
+ const [state, setState] = (0, import_react5.useState)("idle");
2730
+ const [elapsedMs, setElapsed] = (0, import_react5.useState)(0);
2731
+ const [error, setError] = (0, import_react5.useState)();
2732
+ const [limited, setLimited] = (0, import_react5.useState)();
2733
+ const rec = (0, import_react5.useRef)(void 0);
2734
+ const pending = (0, import_react5.useRef)(false);
2735
+ const gone = (0, import_react5.useRef)(false);
2736
+ (0, import_react5.useEffect)(() => {
2737
+ if (state !== "recording") return;
2738
+ const at = rec.current?.startedAt ?? Date.now();
2739
+ const now = opts.current.now ?? Date.now;
2740
+ setElapsed(Math.max(0, now() - at));
2741
+ const id = setInterval(() => setElapsed(Math.max(0, now() - at)), 250);
2742
+ return () => clearInterval(id);
2743
+ }, [state]);
2744
+ const start = (0, import_react5.useCallback)(async () => {
2745
+ if (rec.current || pending.current) return;
2746
+ pending.current = true;
2747
+ setError(void 0);
2748
+ setLimited(void 0);
2749
+ setState("starting");
2750
+ try {
2751
+ const started = await startRecording({
2752
+ ...opts.current,
2753
+ onLimit: () => {
2754
+ const r = rec.current;
2755
+ rec.current = void 0;
2756
+ setState("stopping");
2757
+ void r?.stop().then(
2758
+ (audio) => !gone.current && setLimited(audio),
2759
+ () => void 0
2760
+ ).finally(() => !gone.current && setState("idle"));
2761
+ }
2762
+ });
2763
+ if (gone.current) return started.cancel();
2764
+ rec.current = started;
2765
+ setState("recording");
2766
+ } catch (err) {
2767
+ if (!gone.current) {
2768
+ setError(micProblemOf(err));
2769
+ setState("idle");
2770
+ }
2771
+ } finally {
2772
+ pending.current = false;
2773
+ }
2774
+ }, []);
2775
+ const stop = (0, import_react5.useCallback)(async () => {
2776
+ const r = rec.current;
2777
+ if (!r) return void 0;
2778
+ rec.current = void 0;
2779
+ setState("stopping");
2780
+ try {
2781
+ return await r.stop();
2782
+ } catch {
2783
+ return void 0;
2784
+ } finally {
2785
+ if (!gone.current) setState("idle");
2786
+ }
2787
+ }, []);
2788
+ const cancel = (0, import_react5.useCallback)(() => {
2789
+ const r = rec.current;
2790
+ rec.current = void 0;
2791
+ r?.cancel();
2792
+ setLimited(void 0);
2793
+ setState("idle");
2794
+ }, []);
2795
+ (0, import_react5.useEffect)(() => {
2796
+ gone.current = false;
2797
+ return () => {
2798
+ gone.current = true;
2799
+ rec.current?.cancel();
2800
+ rec.current = void 0;
2801
+ };
2802
+ }, []);
2803
+ return {
2804
+ supported: recordingSupported(options),
2805
+ state,
2806
+ elapsedMs,
2807
+ error,
2808
+ limited,
2809
+ start,
2810
+ stop,
2811
+ cancel,
2812
+ clear: () => {
2813
+ setLimited(void 0);
2814
+ setError(void 0);
2815
+ }
2816
+ };
2817
+ };
2818
+
2819
+ // src/hooks/use-read-aloud.ts
2820
+ var import_react6 = require("react");
2821
+ var useReadAloud = (speak, lang) => {
2822
+ const [current, setCurrent] = (0, import_react6.useState)();
2823
+ const [state, setState] = (0, import_react6.useState)();
2824
+ const [failed, setFailed] = (0, import_react6.useState)();
2825
+ const playback = (0, import_react6.useRef)(void 0);
2826
+ const langRef = (0, import_react6.useRef)(lang);
2827
+ langRef.current = lang;
2828
+ const stop = (0, import_react6.useCallback)(() => {
2829
+ const now = playback.current;
2830
+ playback.current = void 0;
2831
+ now?.handle.stop();
2832
+ setCurrent(void 0);
2833
+ setState(void 0);
2834
+ }, []);
2835
+ const start = (0, import_react6.useCallback)(
2836
+ (id, text2) => {
2837
+ if (!speak) return;
2838
+ stop();
2839
+ setFailed(void 0);
2840
+ setCurrent(id);
2841
+ setState("loading");
2842
+ const mine = { id, handle: void 0 };
2843
+ playback.current = mine;
2844
+ let handle;
2845
+ try {
2846
+ handle = speak(text2, {
2847
+ lang: langRef.current,
2848
+ onState: (s) => {
2849
+ if (playback.current === mine) setState(s);
2850
+ }
2851
+ });
2852
+ } catch (err) {
2853
+ playback.current = void 0;
2854
+ setCurrent(void 0);
2855
+ setState(void 0);
2856
+ const own = err instanceof Error && err.name !== "SpeechOutputError";
2857
+ setFailed({ id, ...own && err.message ? { message: err.message } : {} });
2858
+ return;
2859
+ }
2860
+ mine.handle = handle;
2861
+ handle.done.then(
2862
+ () => {
2863
+ if (playback.current !== mine) return;
2864
+ playback.current = void 0;
2865
+ setCurrent(void 0);
2866
+ setState(void 0);
2867
+ },
2868
+ (err) => {
2869
+ if (playback.current !== mine) return;
2870
+ playback.current = void 0;
2871
+ setCurrent(void 0);
2872
+ setState(void 0);
2873
+ const own = err instanceof Error && err.name !== "SpeechOutputError";
2874
+ setFailed({ id, ...own && err.message ? { message: err.message } : {} });
2875
+ }
2876
+ );
2877
+ },
2878
+ [speak, stop]
2879
+ );
2880
+ (0, import_react6.useEffect)(() => stop, [speak, stop]);
2881
+ return {
2882
+ current,
2883
+ state,
2884
+ failed,
2885
+ start,
2886
+ pause: () => playback.current?.handle.pause(),
2887
+ resume: () => playback.current?.handle.resume(),
2888
+ stop
2889
+ };
2890
+ };
2891
+
2892
+ // src/hooks/use-speech-voices.ts
2893
+ var import_react7 = require("react");
2894
+ var useSpeechVoices = () => {
2895
+ const synth = typeof globalThis !== "undefined" ? globalThis.speechSynthesis : void 0;
2896
+ const read = () => {
2897
+ try {
2898
+ return (synth?.getVoices() ?? []).map((v) => ({
2899
+ voiceURI: v.voiceURI,
2900
+ name: v.name,
2901
+ lang: v.lang,
2902
+ localService: v.localService,
2903
+ default: v.default
2904
+ }));
2905
+ } catch {
2906
+ return [];
2907
+ }
2908
+ };
2909
+ const [voices, setVoices] = (0, import_react7.useState)(read);
2910
+ (0, import_react7.useEffect)(() => {
2911
+ if (!synth) return;
2912
+ const update = () => setVoices(read());
2913
+ update();
2914
+ synth.addEventListener?.("voiceschanged", update);
2915
+ return () => synth.removeEventListener?.("voiceschanged", update);
2916
+ }, [synth]);
2917
+ return voices;
2918
+ };
2919
+
2920
+ // src/voice/recognizer.ts
2921
+ var createRecordingRecognizer = (options) => () => {
2922
+ let recording;
2923
+ let starting;
2924
+ let stopAsked = false;
2925
+ let aborted = false;
2926
+ let ended = false;
2927
+ const controller = new AbortController();
2928
+ const rec = {
2929
+ lang: "",
2930
+ continuous: true,
2931
+ interimResults: false,
2932
+ onresult: null,
2933
+ onerror: null,
2934
+ onend: null,
2935
+ start() {
2936
+ if (starting) return;
2937
+ starting = (async () => {
2938
+ try {
2939
+ recording = await startRecording({
2940
+ ...options,
2941
+ maxMs: options.maxMs,
2942
+ onLimit: () => rec.stop()
2943
+ });
2944
+ } catch (err) {
2945
+ if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
2946
+ return finish();
2947
+ }
2948
+ if (aborted) {
2949
+ recording.cancel();
2950
+ return finish();
2951
+ }
2952
+ if (stopAsked) void transcribeNow();
2953
+ })();
2954
+ },
2955
+ stop() {
2956
+ if (stopAsked || ended) return;
2957
+ stopAsked = true;
2958
+ if (recording) void transcribeNow();
2959
+ },
2960
+ abort() {
2961
+ if (ended) return;
2962
+ aborted = true;
2963
+ controller.abort();
2964
+ recording?.cancel();
2965
+ if (!starting || recording) finish();
2966
+ }
2967
+ };
2968
+ const finish = () => {
2969
+ if (ended) return;
2970
+ ended = true;
2971
+ rec.onend?.();
2972
+ };
2973
+ let transcribing = false;
2974
+ const transcribeNow = async () => {
2975
+ if (transcribing || !recording) return;
2976
+ transcribing = true;
2977
+ let audio;
2978
+ try {
2979
+ audio = await recording.stop();
2980
+ } catch (err) {
2981
+ if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
2982
+ return finish();
2983
+ }
2984
+ if (aborted) return finish();
2985
+ if (audio.blob.size === 0) return finish();
2986
+ try {
2987
+ const text2 = (await options.transcribe(audio, { lang: rec.lang, signal: controller.signal })).replace(/\s+/g, " ").trim();
2988
+ if (!aborted && text2)
2989
+ rec.onresult?.({
2990
+ resultIndex: 0,
2991
+ results: [{ isFinal: true, 0: { transcript: text2 } }]
2992
+ });
2993
+ } catch (err) {
2994
+ if (!aborted)
2995
+ rec.onerror?.({
2996
+ error: "transcription",
2997
+ message: err instanceof Error ? err.message : String(err)
2998
+ });
2999
+ }
3000
+ finish();
3001
+ };
3002
+ return rec;
3003
+ };
3004
+
3005
+ // src/voice/speak.ts
3006
+ var SpeechOutputError = class extends Error {
3007
+ code;
3008
+ constructor(code) {
3009
+ super(code);
3010
+ this.name = "SpeechOutputError";
3011
+ this.code = code;
3012
+ }
3013
+ };
3014
+ var asOutputError = (err) => err instanceof SpeechOutputError ? err : new SpeechOutputError(
3015
+ err && typeof err === "object" && "name" in err ? String(err.name) : "playback-failed"
3016
+ );
3017
+ var speakableText = (markdown, options = {}) => {
3018
+ const out = [];
3019
+ const lines = markdown.replace(/\r\n?/g, "\n").split("\n");
3020
+ let fence;
3021
+ let fenceSaid = false;
3022
+ for (const raw of lines) {
3023
+ const line = raw.trimEnd();
3024
+ const opener = /^\s*(`{3,}|~{3,})/.exec(line);
3025
+ if (fence !== void 0) {
3026
+ if (opener && opener[1][0] === fence[0] && opener[1].length >= fence.length) fence = void 0;
3027
+ continue;
3028
+ }
3029
+ if (opener) {
3030
+ fence = opener[1];
3031
+ if (options.code && !fenceSaid) out.push(options.code);
3032
+ fenceSaid = true;
3033
+ continue;
3034
+ }
3035
+ fenceSaid = false;
3036
+ if (/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(line)) continue;
3037
+ if (/^\s*([-*_])\s*(\1\s*){2,}$/.test(line)) continue;
3038
+ let text2 = line.replace(/^\s{0,3}#{1,6}\s+/, "").replace(/^\s*>\s?/, "").replace(/^\s*(?:[-*+]|\d+[.)])\s+(\[[ xX]\]\s+)?/, "");
3039
+ if (/^\s*\|.*\|\s*$/.test(text2))
3040
+ text2 = text2.replace(/^\s*\||\|\s*$/g, "").split("|").map((c) => c.trim()).filter(Boolean).join(", ");
3041
+ text2 = text2.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/<(https?:\/\/[^>\s]+)>/g, (_m, url) => hostOf(url)).replace(/\bhttps?:\/\/[^\s)]+/g, (url) => hostOf(url)).replace(/`+([^`]*)`+/g, "$1").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/(^|[^\w*])[*_]([^*_\s][^*_]*?)[*_](?=[^\w*]|$)/g, "$1$2").replace(/~~(.+?)~~/g, "$1").replace(/<\/?[a-z][^>]*>/gi, "").replace(/[*_#`~>|]/g, " ").replace(/\s+/g, " ").trim();
3042
+ if (!text2) continue;
3043
+ out.push(/[.!?…:;。!?]$/.test(text2) ? text2 : `${text2}.`);
3044
+ }
3045
+ return out.join(" ").trim();
3046
+ };
3047
+ var hostOf = (url) => {
3048
+ try {
3049
+ return new URL(url).hostname.replace(/^www\./, "");
3050
+ } catch {
3051
+ return "";
3052
+ }
3053
+ };
3054
+ var splitForSpeech = (text2, max = 220) => {
3055
+ const pieces = [];
3056
+ let rest = text2.trim();
3057
+ while (rest.length > max) {
3058
+ const window2 = rest.slice(0, max + 1);
3059
+ let cut = -1;
3060
+ for (const m of window2.matchAll(/[.!?…。!?;:](\s|$)/g))
3061
+ if (m.index !== void 0 && m.index + 1 <= max) cut = m.index + 1;
3062
+ if (cut < max / 3) cut = window2.lastIndexOf(" ");
3063
+ if (cut <= 0) cut = max;
3064
+ pieces.push(rest.slice(0, cut).trim());
3065
+ rest = rest.slice(cut).trim();
3066
+ }
3067
+ if (rest) pieces.push(rest);
3068
+ return pieces;
3069
+ };
3070
+ var voiceFor = (voices, lang, preferred) => {
3071
+ if (preferred) {
3072
+ const chosen = voices.find((v) => v.voiceURI === preferred);
3073
+ if (chosen) return chosen;
3074
+ }
3075
+ if (!lang) return void 0;
3076
+ const norm = (l) => l.toLowerCase().replace(/_/g, "-");
3077
+ const want = norm(lang);
3078
+ const base2 = want.split("-")[0];
3079
+ const rank = (v) => [v.localService ? 1 : 0, v.default ? 1 : 0];
3080
+ const best = (list) => [...list].sort((a, b) => {
3081
+ const ra = rank(a);
3082
+ const rb = rank(b);
3083
+ return rb[0] - ra[0] || rb[1] - ra[1] || a.name.localeCompare(b.name);
3084
+ })[0];
3085
+ const exact = voices.filter((v) => norm(v.lang) === want);
3086
+ if (exact.length) return best(exact);
3087
+ const same = voices.filter((v) => norm(v.lang).split("-")[0] === base2);
3088
+ return same.length ? best(same) : void 0;
3089
+ };
3090
+ var voicesOf = (voices, lang) => {
3091
+ if (!lang) return [...voices];
3092
+ const base2 = lang.toLowerCase().split(/[-_]/)[0];
3093
+ return voices.filter((v) => v.lang.toLowerCase().split(/[-_]/)[0] === base2);
3094
+ };
3095
+ var speechSynthesisSupported = () => typeof globalThis !== "undefined" && "speechSynthesis" in globalThis && typeof globalThis.SpeechSynthesisUtterance === "function";
3096
+ var createBrowserSpeaker = (options = {}) => (text2, { lang, onState }) => {
3097
+ const synth = options.synth ?? globalThis.speechSynthesis;
3098
+ const make = options.createUtterance ?? ((t) => new globalThis.SpeechSynthesisUtterance(t));
3099
+ const voice = voiceFor(synth.getVoices(), lang, options.voice);
3100
+ let settle;
3101
+ let fail;
3102
+ const done = new Promise((resolve, reject) => {
3103
+ settle = resolve;
3104
+ fail = reject;
3105
+ });
3106
+ done.catch(() => {
3107
+ });
3108
+ let over = false;
3109
+ const end = (err) => {
3110
+ if (over) return;
3111
+ over = true;
3112
+ if (err) fail(err);
3113
+ else settle();
3114
+ };
3115
+ const pieces = splitForSpeech(text2);
3116
+ synth.cancel();
3117
+ if (pieces.length === 0) {
3118
+ end();
3119
+ return { pause() {
3120
+ }, resume() {
3121
+ }, stop() {
3122
+ }, done };
3123
+ }
3124
+ let started = false;
3125
+ pieces.forEach((piece, i) => {
3126
+ const u = make(piece);
3127
+ u.lang = voice?.lang ?? lang ?? "";
3128
+ try {
3129
+ u.voice = voice ?? null;
3130
+ } catch {
3131
+ }
3132
+ u.rate = options.rate ?? 1;
3133
+ u.onstart = () => {
3134
+ if (!started && !over) onState("playing");
3135
+ started = true;
3136
+ };
3137
+ u.onend = () => {
3138
+ if (i === pieces.length - 1) end();
3139
+ };
3140
+ u.onerror = (event) => {
3141
+ if (event.error === "interrupted" || event.error === "canceled") end();
3142
+ else end(new SpeechOutputError(event.error || "synthesis-failed"));
3143
+ };
3144
+ synth.speak(u);
3145
+ });
3146
+ onState("loading");
3147
+ return {
3148
+ pause: () => {
3149
+ if (over) return;
3150
+ synth.pause();
3151
+ onState("paused");
3152
+ },
3153
+ resume: () => {
3154
+ if (over) return;
3155
+ synth.resume();
3156
+ onState("playing");
3157
+ },
3158
+ stop: () => {
3159
+ if (over) return;
3160
+ synth.cancel();
3161
+ end();
3162
+ },
3163
+ done
3164
+ };
3165
+ };
3166
+ var silence = () => {
3167
+ const samples = 16;
3168
+ const view = new DataView(new ArrayBuffer(44 + samples * 2));
3169
+ const text2 = (at, s) => {
3170
+ for (let i = 0; i < s.length; i++) view.setUint8(at + i, s.charCodeAt(i));
3171
+ };
3172
+ text2(0, "RIFF");
3173
+ view.setUint32(4, 36 + samples * 2, true);
3174
+ text2(8, "WAVEfmt ");
3175
+ view.setUint32(16, 16, true);
3176
+ view.setUint16(20, 1, true);
3177
+ view.setUint16(22, 1, true);
3178
+ view.setUint32(24, 8e3, true);
3179
+ view.setUint32(28, 16e3, true);
3180
+ view.setUint16(32, 2, true);
3181
+ view.setUint16(34, 16, true);
3182
+ text2(36, "data");
3183
+ view.setUint32(40, samples * 2, true);
3184
+ return new Blob([view.buffer], { type: "audio/wav" });
3185
+ };
3186
+ var createAudioSpeaker = (options) => (text2, { lang, onState }) => {
3187
+ const urls = options.objectUrl ?? {
3188
+ create: (b) => URL.createObjectURL(b),
3189
+ revoke: (u) => URL.revokeObjectURL(u)
3190
+ };
3191
+ const audio = options.createAudio?.() ?? new Audio();
3192
+ const controller = new AbortController();
3193
+ const pieces = splitForSpeech(text2, options.maxChars ?? 2e3);
3194
+ let settle;
3195
+ let fail;
3196
+ const done = new Promise((resolve, reject) => {
3197
+ settle = resolve;
3198
+ fail = reject;
3199
+ });
3200
+ done.catch(() => {
3201
+ });
3202
+ let over = false;
3203
+ let paused = false;
3204
+ let current;
3205
+ const made = /* @__PURE__ */ new Map();
3206
+ const make = (i) => {
3207
+ if (!made.has(i)) {
3208
+ const p = options.synthesize(pieces[i], { lang, signal: controller.signal });
3209
+ p.catch(() => {
3210
+ });
3211
+ made.set(i, p);
3212
+ }
3213
+ return made.get(i);
3214
+ };
3215
+ const release = () => {
3216
+ if (current) urls.revoke(current);
3217
+ current = void 0;
3218
+ };
3219
+ const end = (err) => {
3220
+ if (over) return;
3221
+ over = true;
3222
+ controller.abort();
3223
+ audio.pause();
3224
+ audio.onended = null;
3225
+ audio.onerror = null;
3226
+ release();
3227
+ if (err) fail(err);
3228
+ else settle();
3229
+ };
3230
+ const playFrom = async (i) => {
3231
+ if (over) return;
3232
+ if (i >= pieces.length) return end();
3233
+ onState(i === 0 || !current ? "loading" : "playing");
3234
+ let blob;
3235
+ try {
3236
+ blob = await make(i);
3237
+ } catch (err) {
3238
+ return end(err instanceof Error ? err : new Error(String(err)));
3239
+ }
3240
+ if (over) return;
3241
+ if (i + 1 < pieces.length) make(i + 1);
3242
+ release();
3243
+ current = urls.create(blob);
3244
+ audio.src = current;
3245
+ audio.onended = () => void playFrom(i + 1);
3246
+ audio.onerror = () => end(new SpeechOutputError("playback-failed"));
3247
+ if (paused) return onState("paused");
3248
+ try {
3249
+ await audio.play();
3250
+ if (!over) onState("playing");
3251
+ } catch (err) {
3252
+ end(asOutputError(err));
3253
+ }
3254
+ };
3255
+ if (pieces.length === 0) end();
3256
+ else {
3257
+ if (options.unlock !== false) {
3258
+ current = urls.create(silence());
3259
+ audio.src = current;
3260
+ audio.play().catch(() => {
3261
+ });
3262
+ }
3263
+ void playFrom(0);
3264
+ }
3265
+ return {
3266
+ pause: () => {
3267
+ if (over) return;
3268
+ paused = true;
3269
+ audio.pause();
3270
+ onState("paused");
3271
+ },
3272
+ resume: () => {
3273
+ if (over || !paused) return;
3274
+ paused = false;
3275
+ if (current)
3276
+ audio.play().then(
3277
+ () => !over && onState("playing"),
3278
+ (err) => end(asOutputError(err))
3279
+ );
3280
+ else onState("loading");
3281
+ },
3282
+ stop: () => end(),
3283
+ done
3284
+ };
3285
+ };
3286
+
3287
+ // src/hooks/use-credentials.ts
3288
+ var import_react8 = require("react");
2493
3289
  var core5 = __toESM(require("@dudko.dev/agent-web"), 1);
2494
3290
  var import_agent_web3 = require("@dudko.dev/agent-web");
2495
3291
  var storeDbName = (store) => {
@@ -2497,10 +3293,10 @@ var storeDbName = (store) => {
2497
3293
  return typeof name === "string" && name ? name : void 0;
2498
3294
  };
2499
3295
  var useCredentials = (store) => {
2500
- const resolved = (0, import_react5.useMemo)(() => store ?? new import_agent_web3.VaultCredentialStore(), [store]);
2501
- const [version, setVersion] = (0, import_react5.useState)(0);
3296
+ const resolved = (0, import_react8.useMemo)(() => store ?? new import_agent_web3.VaultCredentialStore(), [store]);
3297
+ const [version, setVersion] = (0, import_react8.useState)(0);
2502
3298
  const dbName = storeDbName(resolved);
2503
- (0, import_react5.useEffect)(() => {
3299
+ (0, import_react8.useEffect)(() => {
2504
3300
  return followOtherTabs(
2505
3301
  core5,
2506
3302
  dbName,
@@ -2508,21 +3304,21 @@ var useCredentials = (store) => {
2508
3304
  () => setVersion((v) => v + 1)
2509
3305
  );
2510
3306
  }, [dbName]);
2511
- const setKey = (0, import_react5.useCallback)(
3307
+ const setKey = (0, import_react8.useCallback)(
2512
3308
  async (ref, key) => {
2513
3309
  await resolved.setApiKey(ref, key);
2514
3310
  setVersion((v) => v + 1);
2515
3311
  },
2516
3312
  [resolved]
2517
3313
  );
2518
- const removeKey = (0, import_react5.useCallback)(
3314
+ const removeKey = (0, import_react8.useCallback)(
2519
3315
  async (ref) => {
2520
3316
  await resolved.deleteApiKey(ref);
2521
3317
  setVersion((v) => v + 1);
2522
3318
  },
2523
3319
  [resolved]
2524
3320
  );
2525
- const hasKey = (0, import_react5.useCallback)(
3321
+ const hasKey = (0, import_react8.useCallback)(
2526
3322
  async (ref) => await resolved.getApiKey(ref) !== void 0,
2527
3323
  [resolved]
2528
3324
  );
@@ -2533,21 +3329,21 @@ var useCredentials = (store) => {
2533
3329
  var import_agent_web4 = require("@dudko.dev/agent-web");
2534
3330
 
2535
3331
  // src/hooks/use-local-model.ts
2536
- var import_react6 = require("react");
3332
+ var import_react9 = require("react");
2537
3333
  var keyOf = (id, tokens) => tokens ? `${id}@${tokens}` : id;
2538
3334
  var useLocalModel = (modelId, engine, options) => {
2539
- const [loaded, setLoaded] = (0, import_react6.useState)(void 0);
2540
- const [pending, setPending] = (0, import_react6.useState)();
2541
- const [failure, setFailure] = (0, import_react6.useState)();
2542
- const engineRef = (0, import_react6.useRef)(engine);
3335
+ const [loaded, setLoaded] = (0, import_react9.useState)(void 0);
3336
+ const [pending, setPending] = (0, import_react9.useState)();
3337
+ const [failure, setFailure] = (0, import_react9.useState)();
3338
+ const engineRef = (0, import_react9.useRef)(engine);
2543
3339
  engineRef.current = engine;
2544
- const loadedRef = (0, import_react6.useRef)(void 0);
2545
- const inflightRef = (0, import_react6.useRef)(
3340
+ const loadedRef = (0, import_react9.useRef)(void 0);
3341
+ const inflightRef = (0, import_react9.useRef)(
2546
3342
  void 0
2547
3343
  );
2548
3344
  const windowTokens = options?.contextWindowTokens;
2549
3345
  const key = keyOf(modelId, windowTokens);
2550
- const seqRef = (0, import_react6.useRef)(0);
3346
+ const seqRef = (0, import_react9.useRef)(0);
2551
3347
  const setHeld = (next) => {
2552
3348
  loadedRef.current = next;
2553
3349
  setLoaded(next);
@@ -2558,7 +3354,7 @@ var useLocalModel = (modelId, engine, options) => {
2558
3354
  } catch {
2559
3355
  }
2560
3356
  };
2561
- const load = (0, import_react6.useCallback)(() => {
3357
+ const load = (0, import_react9.useCallback)(() => {
2562
3358
  const id = modelId;
2563
3359
  if (loadedRef.current?.key === key) return Promise.resolve(loadedRef.current.model);
2564
3360
  if (inflightRef.current?.key === key) return inflightRef.current.promise;
@@ -2610,7 +3406,7 @@ var useLocalModel = (modelId, engine, options) => {
2610
3406
  inflightRef.current = { key, promise };
2611
3407
  return promise;
2612
3408
  }, [modelId, key]);
2613
- const unload = (0, import_react6.useCallback)(async () => {
3409
+ const unload = (0, import_react9.useCallback)(async () => {
2614
3410
  seqRef.current++;
2615
3411
  inflightRef.current = void 0;
2616
3412
  setPending(void 0);
@@ -2672,7 +3468,7 @@ var createWebLLMEngine = (options) => {
2672
3468
  };
2673
3469
 
2674
3470
  // src/labels.tsx
2675
- var import_react7 = require("react");
3471
+ var import_react10 = require("react");
2676
3472
 
2677
3473
  // src/composer.ts
2678
3474
  var parseSlash = (text2) => {
@@ -2838,6 +3634,27 @@ var noticesOf = (state, texts = {}) => {
2838
3634
  }
2839
3635
  return out;
2840
3636
  };
3637
+ var formatClock = (ms) => {
3638
+ const s = Math.max(0, Math.floor(ms / 1e3));
3639
+ const two = (n) => String(n).padStart(2, "0");
3640
+ const h = Math.floor(s / 3600);
3641
+ const m = Math.floor(s % 3600 / 60);
3642
+ return h > 0 ? `${h}:${two(m)}:${two(s % 60)}` : `${m}:${two(s % 60)}`;
3643
+ };
3644
+ var micProblemText = (code, message, labels) => {
3645
+ if (code === "not-allowed" || code === "service-not-allowed") return labels.micDenied;
3646
+ if (code === "audio-capture") return labels.micMissing;
3647
+ if (code === "busy") return labels.micBusy;
3648
+ if (code === "unsupported") return labels.micUnsupported;
3649
+ if (message) return message;
3650
+ return code && code !== "transcription" && code !== "failed" ? `${labels.dictationFailed} (${code})` : labels.dictationFailed;
3651
+ };
3652
+ var voiceMessageName = (at, extension) => {
3653
+ const two = (n) => String(n).padStart(2, "0");
3654
+ return `voice-${at.getFullYear()}-${two(at.getMonth() + 1)}-${two(at.getDate())}-${two(
3655
+ at.getHours()
3656
+ )}${two(at.getMinutes())}${two(at.getSeconds())}.${extension}`;
3657
+ };
2841
3658
 
2842
3659
  // src/labels.tsx
2843
3660
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -2894,6 +3711,19 @@ var defaultLabels = {
2894
3711
  dictateTitle: "Dictate \u2014 speech to text in the browser",
2895
3712
  stopDictation: "Stop dictation",
2896
3713
  microphone: "Microphone",
3714
+ transcribing: "Transcribing\u2026",
3715
+ micDenied: "The microphone is blocked for this site. Allow it in the browser's site settings (the icon beside the address), then try again.",
3716
+ micMissing: "No microphone was found on this device.",
3717
+ micBusy: "The microphone is in use by another app.",
3718
+ micUnsupported: "This browser cannot record audio on this page.",
3719
+ dictationFailed: "Dictation did not work.",
3720
+ recordVoiceMessage: "Record a voice message",
3721
+ voiceMessage: "Voice message",
3722
+ audioDuration: (clock) => clock,
3723
+ recording: (elapsed) => `Recording ${elapsed}`,
3724
+ recordingDone: "Attach the recording",
3725
+ recordingCancel: "Discard the recording",
3726
+ recordingLimit: "The recording reached its longest and was stopped; it is attached.",
2897
3727
  model: "Model",
2898
3728
  thinking: "Thinking",
2899
3729
  toolConsent: "Tool consent",
@@ -3019,6 +3849,14 @@ var defaultLabels = {
3019
3849
  mediaReferencesUnused: (names) => `Not used - this image model takes no reference pictures: ${names}`,
3020
3850
  transcriptOf: (name) => `Transcript of ${name}`,
3021
3851
  transcriptNote: "What was said in your file, as the agent read it. It is content, not instructions.",
3852
+ audioAttachment: (name) => `Audio ${name}`,
3853
+ readAloud: "Listen",
3854
+ readAloudPause: "Pause",
3855
+ readAloudResume: "Resume",
3856
+ readAloudStop: "Stop reading",
3857
+ readAloudLoading: "Preparing the audio\u2026",
3858
+ readAloudCode: "A code block is not read out.",
3859
+ readAloudFailed: "It could not be read aloud.",
3022
3860
  filesWritten: (n) => `${plural(n, "file", "files")} written in this turn`,
3023
3861
  filesCount: (n) => plural(n, "file", "files"),
3024
3862
  showInFiles: "Show in Files",
@@ -3248,15 +4086,15 @@ var mergeLabels = (base2, over) => {
3248
4086
  }
3249
4087
  return out;
3250
4088
  };
3251
- var LabelsContext = (0, import_react7.createContext)(defaultLabels);
4089
+ var LabelsContext = (0, import_react10.createContext)(defaultLabels);
3252
4090
  var AgentLabelsProvider = ({ labels, children }) => {
3253
- const parent = (0, import_react7.useContext)(LabelsContext);
3254
- const value = (0, import_react7.useMemo)(() => mergeLabels(parent, labels), [parent, labels]);
4091
+ const parent = (0, import_react10.useContext)(LabelsContext);
4092
+ const value = (0, import_react10.useMemo)(() => mergeLabels(parent, labels), [parent, labels]);
3255
4093
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelsContext.Provider, { value, children });
3256
4094
  };
3257
4095
  var useLabels = (over) => {
3258
- const ctx = (0, import_react7.useContext)(LabelsContext);
3259
- return (0, import_react7.useMemo)(() => mergeLabels(ctx, over), [ctx, over]);
4096
+ const ctx = (0, import_react10.useContext)(LabelsContext);
4097
+ return (0, import_react10.useMemo)(() => mergeLabels(ctx, over), [ctx, over]);
3260
4098
  };
3261
4099
 
3262
4100
  // src/image-resize.ts
@@ -3375,19 +4213,19 @@ var downscaleImage = async (file, opts = {}) => {
3375
4213
  };
3376
4214
 
3377
4215
  // src/context.tsx
3378
- var import_react8 = require("react");
4216
+ var import_react11 = require("react");
3379
4217
  var import_jsx_runtime2 = require("react/jsx-runtime");
3380
- var AgentContext = (0, import_react8.createContext)(null);
4218
+ var AgentContext = (0, import_react11.createContext)(null);
3381
4219
  var AgentProvider = ({ config, children, ...options }) => {
3382
4220
  const agent = useAgent(config, options);
3383
4221
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AgentContext.Provider, { value: agent, children });
3384
4222
  };
3385
4223
  var useAgentContext = () => {
3386
- const ctx = (0, import_react8.useContext)(AgentContext);
4224
+ const ctx = (0, import_react11.useContext)(AgentContext);
3387
4225
  if (!ctx) throw new Error("useAgentContext must be used within an <AgentProvider>");
3388
4226
  return ctx;
3389
4227
  };
3390
- var useOptionalAgentContext = () => (0, import_react8.useContext)(AgentContext);
4228
+ var useOptionalAgentContext = () => (0, import_react11.useContext)(AgentContext);
3391
4229
 
3392
4230
  // src/elicitation.ts
3393
4231
  var titled = (options) => options.map((o) => ({ value: o.const, label: o.title || o.const }));
@@ -3594,11 +4432,11 @@ var formatCountdown = (ms) => {
3594
4432
  };
3595
4433
 
3596
4434
  // src/components/AgentChat.tsx
3597
- var import_react22 = require("react");
4435
+ var import_react25 = require("react");
3598
4436
  var import_react_dom2 = require("react-dom");
3599
4437
 
3600
4438
  // src/hooks/use-follow-scroll.ts
3601
- var import_react9 = require("react");
4439
+ var import_react12 = require("react");
3602
4440
 
3603
4441
  // src/follow-scroll.ts
3604
4442
  var FOLLOW_REJOIN_PX = 80;
@@ -3615,7 +4453,7 @@ var followsAfterScroll = (following, before, now) => {
3615
4453
  var followsAfterResize = (following, before, now) => following && !(now.clientHeight === before.clientHeight && now.scrollHeight >= before.scrollHeight && now.scrollTop < reach(before) - FOLLOW_LEAVE_PX);
3616
4454
 
3617
4455
  // src/hooks/use-follow-scroll.ts
3618
- var useIsoLayoutEffect = typeof window === "undefined" ? import_react9.useEffect : import_react9.useLayoutEffect;
4456
+ var useIsoLayoutEffect = typeof window === "undefined" ? import_react12.useEffect : import_react12.useLayoutEffect;
3619
4457
  var measure = (el) => ({
3620
4458
  scrollTop: el.scrollTop,
3621
4459
  scrollHeight: el.scrollHeight,
@@ -3637,12 +4475,12 @@ var anchorOf = (el) => {
3637
4475
  return marks.length ? { marks, top: el.scrollTop } : void 0;
3638
4476
  };
3639
4477
  var useFollowScroll = (ref, turn, live = true) => {
3640
- const following = (0, import_react9.useRef)(true);
3641
- const last = (0, import_react9.useRef)(void 0);
3642
- const anchor = (0, import_react9.useRef)(void 0);
3643
- const settle = (0, import_react9.useRef)(() => {
4478
+ const following = (0, import_react12.useRef)(true);
4479
+ const last = (0, import_react12.useRef)(void 0);
4480
+ const anchor = (0, import_react12.useRef)(void 0);
4481
+ const settle = (0, import_react12.useRef)(() => {
3644
4482
  });
3645
- const arriving = (0, import_react9.useRef)(live);
4483
+ const arriving = (0, import_react12.useRef)(live);
3646
4484
  arriving.current = live;
3647
4485
  useIsoLayoutEffect(() => {
3648
4486
  const el = ref.current;
@@ -3715,7 +4553,7 @@ var useFollowScroll = (ref, turn, live = true) => {
3715
4553
  };
3716
4554
 
3717
4555
  // src/hooks/use-mcp-app-host.ts
3718
- var import_react10 = require("react");
4556
+ var import_react13 = require("react");
3719
4557
 
3720
4558
  // src/mcp-app.ts
3721
4559
  var import_agent_web5 = require("@dudko.dev/agent-web");
@@ -4581,27 +5419,27 @@ var useMcpAppHost = ({
4581
5419
  sampling = false,
4582
5420
  sample: sampleFn
4583
5421
  }) => {
4584
- const [requests, setRequests] = (0, import_react10.useState)([]);
4585
- const [draft, setDraft] = (0, import_react10.useState)();
4586
- const waiting = (0, import_react10.useRef)(
5422
+ const [requests, setRequests] = (0, import_react13.useState)([]);
5423
+ const [draft, setDraft] = (0, import_react13.useState)();
5424
+ const waiting = (0, import_react13.useRef)(
4587
5425
  /* @__PURE__ */ new Map()
4588
5426
  );
4589
- const samplingAllowed = (0, import_react10.useRef)(/* @__PURE__ */ new Set());
4590
- const sampleRef = (0, import_react10.useRef)(sampleFn);
5427
+ const samplingAllowed = (0, import_react13.useRef)(/* @__PURE__ */ new Set());
5428
+ const sampleRef = (0, import_react13.useRef)(sampleFn);
4591
5429
  sampleRef.current = sampleFn;
4592
- const [gated, setGated] = (0, import_react10.useState)({});
4593
- const connectionRef = (0, import_react10.useRef)(connection);
5430
+ const [gated, setGated] = (0, import_react13.useState)({});
5431
+ const connectionRef = (0, import_react13.useRef)(connection);
4594
5432
  connectionRef.current = connection;
4595
- const approveRef = (0, import_react10.useRef)(approve);
5433
+ const approveRef = (0, import_react13.useRef)(approve);
4596
5434
  approveRef.current = approve;
4597
- (0, import_react10.useEffect)(
5435
+ (0, import_react13.useEffect)(
4598
5436
  () => () => {
4599
5437
  for (const { resolve } of waiting.current.values()) resolve(false);
4600
5438
  waiting.current.clear();
4601
5439
  },
4602
5440
  []
4603
5441
  );
4604
- const ask = (0, import_react10.useCallback)(
5442
+ const ask = (0, import_react13.useCallback)(
4605
5443
  (request, signal, extra = {}) => {
4606
5444
  for (const w of waiting.current.values()) {
4607
5445
  if (w.request.appId === request.appId) {
@@ -4626,7 +5464,7 @@ var useMcpAppHost = ({
4626
5464
  },
4627
5465
  []
4628
5466
  );
4629
- const answer = (0, import_react10.useCallback)((id, accept, options) => {
5467
+ const answer = (0, import_react13.useCallback)((id, accept, options) => {
4630
5468
  const w = waiting.current.get(id);
4631
5469
  if (!w) return;
4632
5470
  if (accept && w.request.kind === "link" && w.request.link) {
@@ -4652,16 +5490,16 @@ var useMcpAppHost = ({
4652
5490
  }
4653
5491
  w.resolve(accept);
4654
5492
  }, []);
4655
- const read = (0, import_react10.useCallback)((app, signal) => {
5493
+ const read = (0, import_react13.useCallback)((app, signal) => {
4656
5494
  const c = connectionRef.current;
4657
5495
  if (!c) return Promise.reject(new Error(`no connection to the server \u201C${app.server}\u201D`));
4658
5496
  return c.readUiResource(app.server, app.resourceUri, signal ? { signal } : void 0);
4659
5497
  }, []);
4660
- const tool = (0, import_react10.useCallback)(
5498
+ const tool = (0, import_react13.useCallback)(
4661
5499
  (app) => connectionRef.current?.appTool(app.server, app.toolName),
4662
5500
  []
4663
5501
  );
4664
- const callTool = (0, import_react10.useCallback)(
5502
+ const callTool = (0, import_react13.useCallback)(
4665
5503
  async (app, name, args, signal) => {
4666
5504
  const c = connectionRef.current;
4667
5505
  if (!c) throw refused(`The server \u201C${app.server}\u201D is not connected`);
@@ -4698,15 +5536,15 @@ var useMcpAppHost = ({
4698
5536
  },
4699
5537
  []
4700
5538
  );
4701
- const openLink = (0, import_react10.useCallback)(
5539
+ const openLink = (0, import_react13.useCallback)(
4702
5540
  (app, link, signal) => ask({ appId: app.id, server: app.server, kind: "link", link }, signal),
4703
5541
  [ask]
4704
5542
  );
4705
- const message = (0, import_react10.useCallback)(
5543
+ const message = (0, import_react13.useCallback)(
4706
5544
  (app, text2, signal) => ask({ appId: app.id, server: app.server, kind: "message", text: text2 }, signal),
4707
5545
  [ask]
4708
5546
  );
4709
- const downloadFile2 = (0, import_react10.useCallback)(
5547
+ const downloadFile2 = (0, import_react13.useCallback)(
4710
5548
  async (app, file, signal) => {
4711
5549
  const c = connectionRef.current;
4712
5550
  if (file.kind === "link" && !c) throw refused(`The server \u201C${app.server}\u201D is not connected`);
@@ -4729,7 +5567,7 @@ var useMcpAppHost = ({
4729
5567
  },
4730
5568
  [ask]
4731
5569
  );
4732
- const sample = (0, import_react10.useCallback)(
5570
+ const sample = (0, import_react13.useCallback)(
4733
5571
  async (app, params, signal) => {
4734
5572
  const fn = sampleRef.current;
4735
5573
  if (!fn) throw refused("This host cannot answer sampling requests");
@@ -4750,19 +5588,19 @@ var useMcpAppHost = ({
4750
5588
  },
4751
5589
  [ask]
4752
5590
  );
4753
- const pendingAppServers = (0, import_react10.useMemo)(
5591
+ const pendingAppServers = (0, import_react13.useMemo)(
4754
5592
  () => new Set(
4755
5593
  approvals.filter((a) => a.app && a.status === "pending").map((a) => `${a.app.server}\0${a.app.resourceUri}`)
4756
5594
  ),
4757
5595
  [approvals]
4758
5596
  );
4759
- const isWaiting = (0, import_react10.useCallback)(
5597
+ const isWaiting = (0, import_react13.useCallback)(
4760
5598
  (app) => requests.some((r) => r.appId === app.id) || Boolean(gated[app.id]) && pendingAppServers.has(`${app.server}\0${app.resourceUri}`),
4761
5599
  [requests, gated, pendingAppServers]
4762
5600
  );
4763
5601
  const sandboxUrl = sandbox?.url;
4764
5602
  const sandboxTimeout = sandbox?.timeoutMs;
4765
- const sandboxSetting = (0, import_react10.useMemo)(
5603
+ const sandboxSetting = (0, import_react13.useMemo)(
4766
5604
  () => sandboxUrl === void 0 ? void 0 : {
4767
5605
  url: sandboxUrl,
4768
5606
  ...sandboxTimeout !== void 0 ? { timeoutMs: sandboxTimeout } : {}
@@ -4770,7 +5608,7 @@ var useMcpAppHost = ({
4770
5608
  [sandboxUrl, sandboxTimeout]
4771
5609
  );
4772
5610
  const samplingOn = sampling && Boolean(sampleFn);
4773
- return (0, import_react10.useMemo)(
5611
+ return (0, import_react13.useMemo)(
4774
5612
  () => ({
4775
5613
  connected: Boolean(connection),
4776
5614
  read,
@@ -4859,6 +5697,13 @@ var MicIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.j
4859
5697
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "9", y: "3", width: "6", height: "11", rx: "3" }),
4860
5698
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M5 11a7 7 0 0 0 14 0M12 18v3" })
4861
5699
  ] });
5700
+ var WaveIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 10v4M8 6v12M12 3v18M16 7v10M20 10v4" }) });
5701
+ var SpeakerIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { ...base(size), className, children: [
5702
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 9h4l5-4v14l-5-4H4Z" }),
5703
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12" })
5704
+ ] });
5705
+ var PauseIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M9 5v14M15 5v14" }) });
5706
+ var PlayIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7 4.5v15l12-7.5Z" }) });
4862
5707
  var BoltIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M13 2 4 14h7l-1 8 9-12h-7Z" }) });
4863
5708
  var EyeIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { ...base(size), className, children: [
4864
5709
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" }),
@@ -5053,11 +5898,11 @@ var AppRequestPrompt = ({
5053
5898
  };
5054
5899
 
5055
5900
  // src/components/McpAppFrame.tsx
5056
- var import_react11 = require("react");
5901
+ var import_react14 = require("react");
5057
5902
  var import_jsx_runtime5 = require("react/jsx-runtime");
5058
5903
  var HOST_INFO = { name: "@dudko.dev/agent-web-react", version: "1" };
5059
5904
  var MAX_LISTED_CALLS = 12;
5060
- var useIsoLayoutEffect2 = typeof window === "undefined" ? import_react11.useEffect : import_react11.useLayoutEffect;
5905
+ var useIsoLayoutEffect2 = typeof window === "undefined" ? import_react14.useEffect : import_react14.useLayoutEffect;
5061
5906
  var userActivation = () => typeof navigator === "undefined" ? void 0 : navigator.userActivation?.isActive;
5062
5907
  var silentSandboxes = /* @__PURE__ */ new Set();
5063
5908
  var warned = /* @__PURE__ */ new Set();
@@ -5090,36 +5935,36 @@ var McpAppFrame = ({
5090
5935
  className
5091
5936
  }) => {
5092
5937
  const L = useLabels(labels);
5093
- const [collapsed, setCollapsed] = (0, import_react11.useState)(defaultCollapsed);
5094
- const [menu, setMenu] = (0, import_react11.useState)(false);
5095
- const [reload, setReload] = (0, import_react11.useState)(0);
5096
- const [loaded, setLoaded] = (0, import_react11.useState)();
5097
- const [height, setHeight] = (0, import_react11.useState)(APP_DEFAULT_HEIGHT);
5098
- const [calls, setCalls] = (0, import_react11.useState)([]);
5099
- const [fallback, setFallback] = (0, import_react11.useState)();
5100
- const [broken, setBroken] = (0, import_react11.useState)(false);
5101
- const [onOrigin, setOnOrigin] = (0, import_react11.useState)(false);
5102
- const shellLoaded = (0, import_react11.useRef)(void 0);
5103
- const [mode, setMode] = (0, import_react11.useState)("inline");
5104
- const modeRef = (0, import_react11.useRef)("inline");
5105
- const [holder, setHolder] = (0, import_react11.useState)(0);
5106
- const [fullRect, setFullRect] = (0, import_react11.useState)();
5107
- const leaveRef = (0, import_react11.useRef)(void 0);
5108
- const rootRef = (0, import_react11.useRef)(null);
5109
- const exitRef = (0, import_react11.useRef)(null);
5110
- const allowFullscreenRef = (0, import_react11.useRef)(allowFullscreen);
5938
+ const [collapsed, setCollapsed] = (0, import_react14.useState)(defaultCollapsed);
5939
+ const [menu, setMenu] = (0, import_react14.useState)(false);
5940
+ const [reload, setReload] = (0, import_react14.useState)(0);
5941
+ const [loaded, setLoaded] = (0, import_react14.useState)();
5942
+ const [height, setHeight] = (0, import_react14.useState)(APP_DEFAULT_HEIGHT);
5943
+ const [calls, setCalls] = (0, import_react14.useState)([]);
5944
+ const [fallback, setFallback] = (0, import_react14.useState)();
5945
+ const [broken, setBroken] = (0, import_react14.useState)(false);
5946
+ const [onOrigin, setOnOrigin] = (0, import_react14.useState)(false);
5947
+ const shellLoaded = (0, import_react14.useRef)(void 0);
5948
+ const [mode, setMode] = (0, import_react14.useState)("inline");
5949
+ const modeRef = (0, import_react14.useRef)("inline");
5950
+ const [holder, setHolder] = (0, import_react14.useState)(0);
5951
+ const [fullRect, setFullRect] = (0, import_react14.useState)();
5952
+ const leaveRef = (0, import_react14.useRef)(void 0);
5953
+ const rootRef = (0, import_react14.useRef)(null);
5954
+ const exitRef = (0, import_react14.useRef)(null);
5955
+ const allowFullscreenRef = (0, import_react14.useRef)(allowFullscreen);
5111
5956
  allowFullscreenRef.current = allowFullscreen;
5112
- const iframeRef = (0, import_react11.useRef)(null);
5113
- const bridgeRef = (0, import_react11.useRef)(void 0);
5114
- const menuRef = (0, import_react11.useRef)(null);
5115
- const themeRef = (0, import_react11.useRef)(theme);
5957
+ const iframeRef = (0, import_react14.useRef)(null);
5958
+ const bridgeRef = (0, import_react14.useRef)(void 0);
5959
+ const menuRef = (0, import_react14.useRef)(null);
5960
+ const themeRef = (0, import_react14.useRef)(theme);
5116
5961
  themeRef.current = theme;
5117
- const hostRef = (0, import_react11.useRef)(host);
5962
+ const hostRef = (0, import_react14.useRef)(host);
5118
5963
  hostRef.current = host;
5119
- const appRef = (0, import_react11.useRef)(app);
5964
+ const appRef = (0, import_react14.useRef)(app);
5120
5965
  appRef.current = app;
5121
5966
  const live = !collapsed;
5122
- (0, import_react11.useEffect)(() => {
5967
+ (0, import_react14.useEffect)(() => {
5123
5968
  if (!live) return;
5124
5969
  if (!hostRef.current.connected) {
5125
5970
  setLoaded({ unavailable: true });
@@ -5142,7 +5987,7 @@ var McpAppFrame = ({
5142
5987
  const resource = loaded && "resource" in loaded ? loaded.resource : void 0;
5143
5988
  const sandboxUrl = host.sandbox?.url;
5144
5989
  const timeoutMs = host.sandbox?.timeoutMs ?? MCP_APP_SANDBOX_TIMEOUT_MS;
5145
- const placement = (0, import_react11.useMemo)(() => {
5990
+ const placement = (0, import_react14.useMemo)(() => {
5146
5991
  if (!resource) return void 0;
5147
5992
  if (sandboxUrl === void 0) return { mode: "opaque" };
5148
5993
  if (fallback) return { mode: "opaque", reason: fallback };
@@ -5153,11 +5998,11 @@ var McpAppFrame = ({
5153
5998
  if (!url) return { mode: "opaque", reason: "too-many-origins" };
5154
5999
  return { mode: "origin", origin: target.origin, url };
5155
6000
  }, [resource, sandboxUrl, fallback, app.server, reload]);
5156
- const doc = (0, import_react11.useMemo)(
6001
+ const doc = (0, import_react14.useMemo)(
5157
6002
  () => !resource || !placement ? void 0 : placement.mode === "origin" ? buildMcpAppSandboxShell(placement.url) : buildMcpAppDocument(resource.html, resource.csp),
5158
6003
  [resource, placement]
5159
6004
  );
5160
- (0, import_react11.useEffect)(() => {
6005
+ (0, import_react14.useEffect)(() => {
5161
6006
  const reason = placement?.mode === "opaque" ? placement.reason : void 0;
5162
6007
  if (reason && reason !== "no-answer" && sandboxUrl !== void 0) {
5163
6008
  warnOnce(
@@ -5166,7 +6011,7 @@ var McpAppFrame = ({
5166
6011
  );
5167
6012
  }
5168
6013
  }, [placement, sandboxUrl]);
5169
- (0, import_react11.useEffect)(() => {
6014
+ (0, import_react14.useEffect)(() => {
5170
6015
  const frame = iframeRef.current;
5171
6016
  if (!live || !resource || !frame || !placement || broken) return;
5172
6017
  const abort = new AbortController();
@@ -5311,7 +6156,7 @@ var McpAppFrame = ({
5311
6156
  }, [live, resource, reload, variant, app.id, placement, broken, timeoutMs]);
5312
6157
  const fullscreen = mode === "fullscreen" && live && !broken;
5313
6158
  const waitingNow = host.isWaiting(app);
5314
- (0, import_react11.useEffect)(() => {
6159
+ (0, import_react14.useEffect)(() => {
5315
6160
  if (fullscreen && waitingNow) leaveRef.current?.();
5316
6161
  }, [fullscreen, waitingNow]);
5317
6162
  useIsoLayoutEffect2(() => {
@@ -5346,7 +6191,7 @@ var McpAppFrame = ({
5346
6191
  ro?.disconnect();
5347
6192
  };
5348
6193
  }, [fullscreen]);
5349
- (0, import_react11.useEffect)(() => {
6194
+ (0, import_react14.useEffect)(() => {
5350
6195
  if (!fullscreen) return;
5351
6196
  const before = document.activeElement;
5352
6197
  exitRef.current?.focus();
@@ -5363,10 +6208,10 @@ var McpAppFrame = ({
5363
6208
  if (frame && (before === frame || document.activeElement === document.body)) frame.focus();
5364
6209
  };
5365
6210
  }, [fullscreen]);
5366
- (0, import_react11.useEffect)(() => {
6211
+ (0, import_react14.useEffect)(() => {
5367
6212
  if (theme) bridgeRef.current?.updateContext({ theme });
5368
6213
  }, [theme]);
5369
- (0, import_react11.useEffect)(() => {
6214
+ (0, import_react14.useEffect)(() => {
5370
6215
  if (!menu) return;
5371
6216
  const close = (e) => {
5372
6217
  if (e instanceof KeyboardEvent ? e.key === "Escape" : !menuRef.current?.contains(e.target)) {
@@ -5671,7 +6516,7 @@ var McpAppLine = ({ app, note, action, onAction, labels, className }) => {
5671
6516
  };
5672
6517
 
5673
6518
  // src/components/AgentComposer.tsx
5674
- var import_react12 = require("react");
6519
+ var import_react15 = require("react");
5675
6520
  var import_jsx_runtime6 = require("react/jsx-runtime");
5676
6521
  var thinkingDefaults = (l) => [
5677
6522
  { id: "off", label: l.thinkingLevels.off },
@@ -5683,7 +6528,7 @@ var thinkingDefaults = (l) => [
5683
6528
  var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
5684
6529
  var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EyeIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ShieldIcon, { size: 14 });
5685
6530
  var useMenuKeys = (open, menuRef, chipRef, close) => {
5686
- (0, import_react12.useEffect)(() => {
6531
+ (0, import_react15.useEffect)(() => {
5687
6532
  if (!open) return;
5688
6533
  const menu = menuRef.current;
5689
6534
  const rows = menu ? [...menu.querySelectorAll('[role^="menuitem"]')] : [];
@@ -5711,9 +6556,9 @@ var useMenuKeys = (open, menuRef, chipRef, close) => {
5711
6556
  };
5712
6557
  var opensMenu = (key) => key === "ArrowDown" || key === "ArrowUp";
5713
6558
  var attachSeq = 0;
5714
- var useIsoLayoutEffect3 = typeof window === "undefined" ? import_react12.useEffect : import_react12.useLayoutEffect;
6559
+ var useIsoLayoutEffect3 = typeof window === "undefined" ? import_react15.useEffect : import_react15.useLayoutEffect;
5715
6560
  var useMenuPlacement = (open, anchor, align) => {
5716
- const [style, setStyle] = (0, import_react12.useState)();
6561
+ const [style, setStyle] = (0, import_react15.useState)();
5717
6562
  useIsoLayoutEffect3(() => {
5718
6563
  if (!open) return;
5719
6564
  const place = () => {
@@ -5774,6 +6619,7 @@ var AgentComposer = ({
5774
6619
  files: vfs,
5775
6620
  dropZone = "self",
5776
6621
  speech = true,
6622
+ voiceMessage = false,
5777
6623
  showTimer = true,
5778
6624
  showAgents = true,
5779
6625
  showApprovalMode = true,
@@ -5791,41 +6637,52 @@ var AgentComposer = ({
5791
6637
  const L = useLabels(labelsOverride);
5792
6638
  const MODE_CHIP = L.modes;
5793
6639
  const DEFAULT_THINKING = thinkingDefaults(L);
5794
- const [text2, setText] = (0, import_react12.useState)("");
5795
- const [pending, setPendingState] = (0, import_react12.useState)([]);
5796
- const pendingRef = (0, import_react12.useRef)([]);
6640
+ const [text2, setText] = (0, import_react15.useState)("");
6641
+ const [pending, setPendingState] = (0, import_react15.useState)([]);
6642
+ const pendingRef = (0, import_react15.useRef)([]);
5797
6643
  const setPending = (next) => {
5798
6644
  pendingRef.current = typeof next === "function" ? next(pendingRef.current) : next;
5799
6645
  setPendingState(pendingRef.current);
5800
6646
  };
5801
- const [menu, setMenu] = (0, import_react12.useState)(void 0);
5802
- const [active, setActive] = (0, import_react12.useState)(0);
5803
- const [dismissed, setDismissed] = (0, import_react12.useState)(() => /* @__PURE__ */ new Set());
5804
- const [attachError, setAttachError] = (0, import_react12.useState)();
5805
- const [dragging, setDragging] = (0, import_react12.useState)(false);
5806
- const rootRef = (0, import_react12.useRef)(null);
5807
- const modelRef = (0, import_react12.useRef)(null);
5808
- const modeRef = (0, import_react12.useRef)(null);
5809
- const modelChipRef = (0, import_react12.useRef)(null);
5810
- const modeChipRef = (0, import_react12.useRef)(null);
5811
- const modelMenuRef = (0, import_react12.useRef)(null);
5812
- const modeMenuRef = (0, import_react12.useRef)(null);
5813
- const [dropRect, setDropRect] = (0, import_react12.useState)();
5814
- const [compactBar, setCompactBar] = (0, import_react12.useState)(false);
5815
- (0, import_react12.useEffect)(() => {
6647
+ const [menu, setMenu] = (0, import_react15.useState)(void 0);
6648
+ const [active, setActive] = (0, import_react15.useState)(0);
6649
+ const [dismissed, setDismissed] = (0, import_react15.useState)(() => /* @__PURE__ */ new Set());
6650
+ const [attachError, setAttachError] = (0, import_react15.useState)();
6651
+ const [dragging, setDragging] = (0, import_react15.useState)(false);
6652
+ const rootRef = (0, import_react15.useRef)(null);
6653
+ const modelRef = (0, import_react15.useRef)(null);
6654
+ const modeRef = (0, import_react15.useRef)(null);
6655
+ const modelChipRef = (0, import_react15.useRef)(null);
6656
+ const modeChipRef = (0, import_react15.useRef)(null);
6657
+ const modelMenuRef = (0, import_react15.useRef)(null);
6658
+ const modeMenuRef = (0, import_react15.useRef)(null);
6659
+ const [dropRect, setDropRect] = (0, import_react15.useState)();
6660
+ const [compactBar, setCompactBar] = (0, import_react15.useState)(false);
6661
+ const [barWidth, setBarWidth] = (0, import_react15.useState)(0);
6662
+ (0, import_react15.useEffect)(() => {
5816
6663
  const el = rootRef.current;
5817
6664
  if (!el || typeof ResizeObserver === "undefined") return;
5818
- const ro = new ResizeObserver(
5819
- () => setCompactBar(el.getBoundingClientRect().width < compactWidth)
5820
- );
6665
+ const ro = new ResizeObserver(() => {
6666
+ const width = el.getBoundingClientRect().width;
6667
+ setCompactBar(width < compactWidth);
6668
+ setBarWidth(Math.round(width));
6669
+ });
5821
6670
  ro.observe(el);
5822
6671
  return () => ro.disconnect();
5823
6672
  }, [compactWidth]);
5824
- const fileRef = (0, import_react12.useRef)(null);
5825
- const inputRef = (0, import_react12.useRef)(null);
6673
+ const chipLabelRef = (0, import_react15.useRef)(null);
6674
+ const [chipShort, setChipShort] = (0, import_react15.useState)(false);
6675
+ (0, import_react15.useLayoutEffect)(() => setChipShort(false), [barWidth, model?.label, model?.shortLabel]);
6676
+ (0, import_react15.useLayoutEffect)(() => {
6677
+ const el = chipLabelRef.current;
6678
+ if (chipShort || !el || !model?.shortLabel) return;
6679
+ if (el.scrollWidth > el.clientWidth + 1) setChipShort(true);
6680
+ });
6681
+ const fileRef = (0, import_react15.useRef)(null);
6682
+ const inputRef = (0, import_react15.useRef)(null);
5826
6683
  const draftId = draft?.id;
5827
6684
  const draftText = draft?.text;
5828
- (0, import_react12.useEffect)(() => {
6685
+ (0, import_react15.useEffect)(() => {
5829
6686
  if (draftId === void 0 || !draftText) return;
5830
6687
  setText((t) => t.trim() ? `${t.trimEnd()}
5831
6688
  ${draftText}` : draftText);
@@ -5839,13 +6696,20 @@ ${draftText}` : draftText);
5839
6696
  const caps = agent.agent?.capabilities;
5840
6697
  const stt = useSpeechToText({
5841
6698
  lang: typeof speech === "object" ? speech.lang : void 0,
6699
+ createRecognizer: typeof speech === "object" ? speech.createRecognizer : void 0,
5842
6700
  onFinal: (heard) => setText((t) => t.trim() ? `${t.trimEnd()} ${heard}` : heard)
5843
6701
  });
5844
6702
  const showMic = speech !== false && stt.supported;
5845
- const [startedAt, setStartedAt] = (0, import_react12.useState)();
5846
- const [now, setNow] = (0, import_react12.useState)(() => Date.now());
5847
- const [lastElapsed, setLastElapsed] = (0, import_react12.useState)();
5848
- (0, import_react12.useEffect)(() => {
6703
+ const recorder = useAudioRecorder({
6704
+ maxMs: typeof voiceMessage === "object" ? voiceMessage.maxMs : void 0
6705
+ });
6706
+ const showVoice = voiceMessage !== false && attachments !== false && recorder.supported;
6707
+ const recordingOn = recorder.state !== "idle";
6708
+ const [voiceNote, setVoiceNote] = (0, import_react15.useState)();
6709
+ const [startedAt, setStartedAt] = (0, import_react15.useState)();
6710
+ const [now, setNow] = (0, import_react15.useState)(() => Date.now());
6711
+ const [lastElapsed, setLastElapsed] = (0, import_react15.useState)();
6712
+ (0, import_react15.useEffect)(() => {
5849
6713
  if (!busy) {
5850
6714
  if (startedAt !== void 0) setLastElapsed(Date.now() - startedAt);
5851
6715
  setStartedAt(void 0);
@@ -5858,7 +6722,7 @@ ${draftText}` : draftText);
5858
6722
  return () => clearInterval(id);
5859
6723
  }, [busy]);
5860
6724
  const elapsed = startedAt !== void 0 ? now - startedAt : lastElapsed;
5861
- const allCommands = (0, import_react12.useMemo)(() => {
6725
+ const allCommands = (0, import_react15.useMemo)(() => {
5862
6726
  const out = [];
5863
6727
  if (builtinCommands) {
5864
6728
  out.push(
@@ -5941,8 +6805,8 @@ ${draftText}` : draftText);
5941
6805
  const closeMenu = () => setMenu(void 0);
5942
6806
  const modelMenuKeys = useMenuKeys(menu === "model", modelMenuRef, modelChipRef, closeMenu);
5943
6807
  const modeMenuKeys = useMenuKeys(menu === "mode", modeMenuRef, modeChipRef, closeMenu);
5944
- (0, import_react12.useEffect)(() => setActive(0), [text2, menu]);
5945
- (0, import_react12.useEffect)(() => {
6808
+ (0, import_react15.useEffect)(() => setActive(0), [text2, menu]);
6809
+ (0, import_react15.useEffect)(() => {
5946
6810
  if (!menu) return;
5947
6811
  const onDown = (e) => {
5948
6812
  if (!rootRef.current?.contains(e.target)) setMenu(void 0);
@@ -6069,6 +6933,44 @@ ${draftText}` : draftText);
6069
6933
  setAttachError(said.filter(Boolean).join(" ") || void 0);
6070
6934
  if (fileRef.current) fileRef.current.value = "";
6071
6935
  };
6936
+ const addRecording = async (audio) => {
6937
+ if (audio.blob.size === 0) return;
6938
+ const name = voiceMessageName(/* @__PURE__ */ new Date(), audioExtensionOf(audio.mediaType));
6939
+ const over = attachmentOverLimit({ bytes: audio.blob.size }, "sent", "none", bounds);
6940
+ if (over) {
6941
+ setAttachError(overLimitText(L.voiceMessage, over));
6942
+ return;
6943
+ }
6944
+ const a = {
6945
+ id: `att-${attachSeq += 1}`,
6946
+ name,
6947
+ kind: "file",
6948
+ mediaType: audio.mediaType,
6949
+ dataUrl: await readDataUrl2(audio.blob),
6950
+ bytes: audio.blob.size,
6951
+ durationMs: audio.durationMs,
6952
+ note: L.audioDuration(formatClock(audio.durationMs))
6953
+ };
6954
+ if (messageOverLimit(pendingRef.current, a, bounds) === "bytes") {
6955
+ setAttachError(
6956
+ L.messageTooLarge(L.voiceMessage, Math.round(bounds.maxTotalBytes / 1024 / 1024))
6957
+ );
6958
+ return;
6959
+ }
6960
+ setPending((cur) => [...cur, a]);
6961
+ };
6962
+ const finishRecording = async () => {
6963
+ const audio = await recorder.stop();
6964
+ if (audio) await addRecording(audio);
6965
+ inputRef.current?.focus();
6966
+ };
6967
+ const limited = recorder.limited;
6968
+ (0, import_react15.useEffect)(() => {
6969
+ if (!limited) return;
6970
+ recorder.clear();
6971
+ setVoiceNote(L.recordingLimit);
6972
+ void addRecording(limited);
6973
+ }, [limited]);
6072
6974
  const onPaste = (e) => {
6073
6975
  if (attachments === false) return;
6074
6976
  const pasted = Array.from(e.clipboardData?.files ?? []);
@@ -6076,9 +6978,9 @@ ${draftText}` : draftText);
6076
6978
  e.preventDefault();
6077
6979
  void addFiles(pasted);
6078
6980
  };
6079
- const addFilesRef = (0, import_react12.useRef)(addFiles);
6981
+ const addFilesRef = (0, import_react15.useRef)(addFiles);
6080
6982
  addFilesRef.current = addFiles;
6081
- (0, import_react12.useEffect)(() => {
6983
+ (0, import_react15.useEffect)(() => {
6082
6984
  if (attachments === false) return;
6083
6985
  const target = dropZone === "window" ? globalThis.window : dropZone === "self" ? rootRef.current : dropZone.current;
6084
6986
  if (!target) return;
@@ -6200,10 +7102,11 @@ ${draftText}` : draftText);
6200
7102
  mediaType: a.mediaType,
6201
7103
  size: a.bytes,
6202
7104
  ...a.kind === "image" && a.dataUrl ? { dataUrl: a.dataUrl } : {},
6203
- ...a.path ? { path: a.path } : {}
7105
+ ...a.path ? { path: a.path } : {},
7106
+ ...a.durationMs !== void 0 ? { durationMs: a.durationMs } : {}
6204
7107
  }));
6205
7108
  const full = withAttachments(goal || L.seeAttachments, items);
6206
- const label = shown || (items.length ? L.attachmentsOnly : "");
7109
+ const label = shown;
6207
7110
  void agent.run(full, {
6208
7111
  ...full !== label ? { label } : {},
6209
7112
  images: items.filter((a) => a.kind === "image" && a.dataUrl).map(toModel),
@@ -6244,16 +7147,24 @@ ${draftText}` : draftText);
6244
7147
  ...attachError ? [{ id: `attach:${attachError}`, tone: "warn", text: attachError }] : [],
6245
7148
  ...stt.error ? [
6246
7149
  {
6247
- id: `stt:${stt.error}`,
7150
+ id: `stt:${stt.error}:${stt.errorMessage ?? ""}`,
6248
7151
  tone: "warn",
6249
- text: `${L.microphone}: ${stt.error}`
7152
+ text: micProblemText(stt.error, stt.errorMessage, L)
6250
7153
  }
6251
- ] : []
7154
+ ] : [],
7155
+ ...recorder.error ? [
7156
+ {
7157
+ id: `rec:${recorder.error}`,
7158
+ tone: "warn",
7159
+ text: micProblemText(recorder.error, void 0, L)
7160
+ }
7161
+ ] : [],
7162
+ ...voiceNote ? [{ id: `voice:${voiceNote}`, tone: "info", text: voiceNote }] : []
6252
7163
  ].filter((n) => !dismissed.has(n.id)) : [];
6253
7164
  const runningAgents = agent.subagents.filter((s) => s.status === "running");
6254
7165
  const thinkingOptions = thinking?.options ?? DEFAULT_THINKING;
6255
7166
  const thinkingLabel = thinking ? thinkingOptions.find((o) => o.id === thinking.value)?.label ?? thinking.value : void 0;
6256
- const canSend = ready && (text2.trim().length > 0 || pending.length > 0);
7167
+ const canSend = ready && !recordingOn && (text2.trim().length > 0 || pending.length > 0);
6257
7168
  const canSteer = busy && steering && text2.trim().length > 0;
6258
7169
  const queuedStrip = showQueued && (agent.queued.length > 0 || agent.undelivered.length > 0) ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued", children: [
6259
7170
  agent.queued.map((q) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued__item", role: "status", children: [
@@ -6297,6 +7208,8 @@ ${draftText}` : draftText);
6297
7208
  onClick: () => {
6298
7209
  setDismissed((d) => new Set(d).add(n.id));
6299
7210
  if (n.id.startsWith("attach:")) setAttachError(void 0);
7211
+ if (n.id.startsWith("rec:")) recorder.clear();
7212
+ if (n.id.startsWith("voice:")) setVoiceNote(void 0);
6300
7213
  },
6301
7214
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(XIcon, { size: 14 })
6302
7215
  }
@@ -6334,7 +7247,7 @@ ${draftText}` : draftText);
6334
7247
  const remove = () => setPending((cur) => cur.filter((x) => x.id !== a.id));
6335
7248
  if (renderAttachment) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: renderAttachment(a, remove) }, a.id);
6336
7249
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-chip awr-file", title: a.note ?? a.mediaType, children: [
6337
- a.kind === "image" && a.dataUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "awr-file__thumb", src: a.dataUrl, alt: a.name }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FileIcon, { size: 14 }),
7250
+ a.kind === "image" && a.dataUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "awr-file__thumb", src: a.dataUrl, alt: a.name }) : a.mediaType.startsWith("audio/") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WaveIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FileIcon, { size: 14 }),
6338
7251
  a.note ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-file__text", children: [
6339
7252
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__name", children: a.name }),
6340
7253
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__note", children: a.note })
@@ -6351,6 +7264,33 @@ ${draftText}` : draftText);
6351
7264
  )
6352
7265
  ] }, a.id);
6353
7266
  }) }),
7267
+ showVoice && recordingOn && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-recording", role: "status", "aria-live": "polite", children: [
7268
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-recording__dot", "aria-hidden": "true" }),
7269
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-recording__time", children: L.recording(formatClock(recorder.elapsedMs)) }),
7270
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
7271
+ "button",
7272
+ {
7273
+ type: "button",
7274
+ className: "awr-iconbtn",
7275
+ "aria-label": L.recordingCancel,
7276
+ title: L.recordingCancel,
7277
+ onClick: recorder.cancel,
7278
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(XIcon, { size: 16 })
7279
+ }
7280
+ ),
7281
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
7282
+ "button",
7283
+ {
7284
+ type: "button",
7285
+ className: "awr-iconbtn awr-recording__done",
7286
+ "aria-label": L.recordingDone,
7287
+ title: L.recordingDone,
7288
+ onClick: () => void finishRecording(),
7289
+ disabled: recorder.state !== "recording",
7290
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, { size: 16 })
7291
+ }
7292
+ )
7293
+ ] }),
6354
7294
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-composer2__inputrow", children: [
6355
7295
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6356
7296
  "textarea",
@@ -6361,7 +7301,7 @@ ${draftText}` : draftText);
6361
7301
  onChange: (e) => setText(e.target.value),
6362
7302
  onKeyDown,
6363
7303
  onPaste,
6364
- placeholder: stt.listening ? L.listening : busy && steering ? L.placeholderBusy : placeholder ?? L.placeholder,
7304
+ placeholder: stt.finishing ? L.transcribing : stt.listening ? L.listening : busy && steering ? L.placeholderBusy : placeholder ?? L.placeholder,
6365
7305
  disabled,
6366
7306
  rows: 2,
6367
7307
  "aria-label": L.message
@@ -6371,16 +7311,18 @@ ${draftText}` : draftText);
6371
7311
  "button",
6372
7312
  {
6373
7313
  type: "button",
6374
- className: `awr-iconbtn awr-mic${stt.listening ? " is-on" : ""}`,
7314
+ className: `awr-iconbtn awr-mic${stt.listening ? " is-on" : ""}${stt.finishing ? " is-busy" : ""}`,
6375
7315
  "aria-label": stt.listening ? L.stopDictation : L.dictate,
7316
+ "aria-pressed": stt.listening,
6376
7317
  title: stt.listening ? L.stopDictation : L.dictateTitle,
6377
7318
  onClick: stt.toggle,
6378
- disabled,
6379
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MicIcon, { size: 18 })
7319
+ disabled: disabled || recordingOn || stt.finishing,
7320
+ children: stt.finishing ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MicIcon, { size: 18 })
6380
7321
  }
6381
7322
  )
6382
7323
  ] }),
6383
7324
  stt.listening && stt.interim && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-composer2__interim", children: stt.interim }),
7325
+ stt.finishing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-composer2__interim", role: "status", children: L.transcribing }),
6384
7326
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-toolbar", children: [
6385
7327
  attachments !== false && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6386
7328
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -6395,6 +7337,22 @@ ${draftText}` : draftText);
6395
7337
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlusIcon, { size: 18 })
6396
7338
  }
6397
7339
  ),
7340
+ showVoice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
7341
+ "button",
7342
+ {
7343
+ type: "button",
7344
+ className: `awr-iconbtn awr-voicebtn${recordingOn ? " is-on" : ""}`,
7345
+ "aria-label": L.recordVoiceMessage,
7346
+ title: L.recordVoiceMessage,
7347
+ "aria-pressed": recordingOn,
7348
+ onClick: () => {
7349
+ setVoiceNote(void 0);
7350
+ void recorder.start();
7351
+ },
7352
+ disabled: disabled || recordingOn || stt.listening,
7353
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WaveIcon, { size: 18 })
7354
+ }
7355
+ ),
6398
7356
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6399
7357
  "input",
6400
7358
  {
@@ -6419,7 +7377,7 @@ ${draftText}` : draftText);
6419
7377
  }
6420
7378
  ),
6421
7379
  toolbarExtra,
6422
- showTimer && elapsed !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-tchip", title: busy ? L.timerRunning : L.timerLast, children: [
7380
+ showTimer && elapsed !== void 0 && (busy || !compactBar) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-tchip", title: busy ? L.timerRunning : L.timerLast, children: [
6423
7381
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClockIcon, { size: 14 }),
6424
7382
  " ",
6425
7383
  formatElapsed(elapsed)
@@ -6455,7 +7413,7 @@ ${draftText}` : draftText);
6455
7413
  "aria-expanded": menu === "model",
6456
7414
  title: [model?.label, thinkingLabel].filter(Boolean).join(" \xB7 "),
6457
7415
  children: [
6458
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-tchip__label", children: model?.label ?? L.model }),
7416
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-tchip__label", ref: chipLabelRef, children: chipShort && model?.shortLabel || model?.label || L.model }),
6459
7417
  thinkingLabel && !compactBar && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-tchip__sub", children: thinkingLabel })
6460
7418
  ]
6461
7419
  }
@@ -6529,7 +7487,7 @@ ${draftText}` : draftText);
6529
7487
  },
6530
7488
  `s${i}`
6531
7489
  );
6532
- return runs[i - 1]?.section ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__section awr-menu__section--plain", children: rows }, `s${i}`) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react12.Fragment, { children: rows }, `s${i}`);
7490
+ return runs[i - 1]?.section ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__section awr-menu__section--plain", children: rows }, `s${i}`) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react15.Fragment, { children: rows }, `s${i}`);
6533
7491
  })
6534
7492
  ] }) : null
6535
7493
  ]
@@ -6624,7 +7582,7 @@ ${draftText}` : draftText);
6624
7582
  };
6625
7583
 
6626
7584
  // src/components/ChatHistoryList.tsx
6627
- var import_react13 = require("react");
7585
+ var import_react16 = require("react");
6628
7586
  var import_jsx_runtime7 = require("react/jsx-runtime");
6629
7587
  var defaultTime = (ms) => {
6630
7588
  const d = new Date(ms);
@@ -6694,7 +7652,7 @@ var ChatHistoryList = ({
6694
7652
  }
6695
7653
  )
6696
7654
  ] }, c.id);
6697
- return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react13.Fragment, { children: renderChat(c, active, row) }, c.id) : row;
7655
+ return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react16.Fragment, { children: renderChat(c, active, row) }, c.id) : row;
6698
7656
  }) })
6699
7657
  ] });
6700
7658
  };
@@ -6860,7 +7818,7 @@ var ContextMeter = ({
6860
7818
  };
6861
7819
 
6862
7820
  // src/components/ElicitationPrompt.tsx
6863
- var import_react14 = require("react");
7821
+ var import_react17 = require("react");
6864
7822
  var import_jsx_runtime9 = require("react/jsx-runtime");
6865
7823
  var reasonText = (outcome, L) => {
6866
7824
  const reason = outcome.reason;
@@ -6870,8 +7828,8 @@ var reasonText = (outcome, L) => {
6870
7828
  return reason || outcome.status;
6871
7829
  };
6872
7830
  var useNow = (active) => {
6873
- const [now, setNow] = (0, import_react14.useState)(() => Date.now());
6874
- (0, import_react14.useEffect)(() => {
7831
+ const [now, setNow] = (0, import_react17.useState)(() => Date.now());
7832
+ (0, import_react17.useEffect)(() => {
6875
7833
  if (!active) return;
6876
7834
  setNow(Date.now());
6877
7835
  const timer = setInterval(() => setNow(Date.now()), 1e3);
@@ -6999,11 +7957,11 @@ var FieldControl = ({ field, id, value, issue, onChange, L }) => {
6999
7957
  ] });
7000
7958
  };
7001
7959
  var FormBody = ({ elicitation, answer, L }) => {
7002
- const baseId = (0, import_react14.useId)();
7960
+ const baseId = (0, import_react17.useId)();
7003
7961
  const schema = elicitation.requestedSchema;
7004
7962
  const fields = elicitationFields(schema);
7005
- const [draft, setDraft] = (0, import_react14.useState)(() => elicitationInitialDraft(schema));
7006
- const [issues, setIssues] = (0, import_react14.useState)(void 0);
7963
+ const [draft, setDraft] = (0, import_react17.useState)(() => elicitationInitialDraft(schema));
7964
+ const [issues, setIssues] = (0, import_react17.useState)(void 0);
7007
7965
  const fieldId = (i) => `${baseId}-f${i}`;
7008
7966
  const submit = (e) => {
7009
7967
  e.preventDefault();
@@ -7058,7 +8016,7 @@ var FormBody = ({ elicitation, answer, L }) => {
7058
8016
  };
7059
8017
  var UrlBody = ({ elicitation, answer, L }) => {
7060
8018
  const link = elicitationLink(elicitation.url);
7061
- const [opened, setOpened] = (0, import_react14.useState)(false);
8019
+ const [opened, setOpened] = (0, import_react17.useState)(false);
7062
8020
  const open = () => {
7063
8021
  if (!link.openable || typeof window === "undefined") return;
7064
8022
  window.open(link.href, "_blank", "noopener,noreferrer");
@@ -7122,7 +8080,7 @@ var ElicitationPrompt = ({
7122
8080
  className
7123
8081
  }) => {
7124
8082
  const L = useLabels(labels);
7125
- const [dismissed, setDismissed] = (0, import_react14.useState)(() => /* @__PURE__ */ new Set());
8083
+ const [dismissed, setDismissed] = (0, import_react17.useState)(() => /* @__PURE__ */ new Set());
7126
8084
  const automatic = showOutcomes ? (outcomes ?? []).filter(
7127
8085
  (o) => o.automatic === true && o.status !== "pending" && !dismissed.has(o.id)
7128
8086
  ) : [];
@@ -7183,21 +8141,21 @@ var ElicitationPrompt = ({
7183
8141
  };
7184
8142
 
7185
8143
  // src/components/FilesPanel.tsx
7186
- var import_react16 = require("react");
8144
+ var import_react19 = require("react");
7187
8145
 
7188
8146
  // src/components/ImageViewer.tsx
7189
- var import_react15 = require("react");
8147
+ var import_react18 = require("react");
7190
8148
  var import_react_dom = require("react-dom");
7191
8149
  var import_jsx_runtime10 = require("react/jsx-runtime");
7192
8150
  var fileNameOf = (name) => name.split(/[\\/]/).filter(Boolean).pop() ?? name;
7193
8151
  var SWIPE_PX = 48;
7194
8152
  var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
7195
8153
  const L = useLabels(labels);
7196
- const rootRef = (0, import_react15.useRef)(null);
7197
- const closeRef = (0, import_react15.useRef)(null);
7198
- const imgRef = (0, import_react15.useRef)(null);
7199
- const touch = (0, import_react15.useRef)(void 0);
7200
- const [zoom, setZoom] = (0, import_react15.useState)(void 0);
8154
+ const rootRef = (0, import_react18.useRef)(null);
8155
+ const closeRef = (0, import_react18.useRef)(null);
8156
+ const imgRef = (0, import_react18.useRef)(null);
8157
+ const touch = (0, import_react18.useRef)(void 0);
8158
+ const [zoom, setZoom] = (0, import_react18.useState)(void 0);
7201
8159
  const count = images.length;
7202
8160
  const at = Math.min(Math.max(index, 0), count - 1);
7203
8161
  const image = images[at];
@@ -7206,7 +8164,7 @@ var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
7206
8164
  setZoom(void 0);
7207
8165
  onIndex((at + step + count) % count);
7208
8166
  };
7209
- (0, import_react15.useEffect)(() => {
8167
+ (0, import_react18.useEffect)(() => {
7210
8168
  closeRef.current?.focus();
7211
8169
  const root = document.documentElement;
7212
8170
  const before = root.style.overflow;
@@ -7215,7 +8173,7 @@ var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
7215
8173
  root.style.overflow = before;
7216
8174
  };
7217
8175
  }, []);
7218
- const keys = (0, import_react15.useRef)(() => {
8176
+ const keys = (0, import_react18.useRef)(() => {
7219
8177
  });
7220
8178
  keys.current = (e) => {
7221
8179
  if (e.key === "Escape") {
@@ -7241,7 +8199,7 @@ var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
7241
8199
  }
7242
8200
  }
7243
8201
  };
7244
- (0, import_react15.useEffect)(() => {
8202
+ (0, import_react18.useEffect)(() => {
7245
8203
  const onKey = (e) => keys.current(e);
7246
8204
  document.addEventListener("keydown", onKey, true);
7247
8205
  return () => document.removeEventListener("keydown", onKey, true);
@@ -7355,7 +8313,7 @@ var ImageViewer = ({ images, index, onIndex, onClose, labels }) => {
7355
8313
  ] })
7356
8314
  ] });
7357
8315
  };
7358
- var ImageViewerContext = (0, import_react15.createContext)({ enabled: true });
8316
+ var ImageViewerContext = (0, import_react18.createContext)({ enabled: true });
7359
8317
  var ImageViewerProvider = ({
7360
8318
  enabled = true,
7361
8319
  render,
@@ -7384,9 +8342,9 @@ var ImageThumb = ({
7384
8342
  labels
7385
8343
  }) => {
7386
8344
  const L = useLabels(labels);
7387
- const { enabled, render } = (0, import_react15.useContext)(ImageViewerContext);
7388
- const ref = (0, import_react15.useRef)(null);
7389
- const [open, setOpen] = (0, import_react15.useState)(void 0);
8345
+ const { enabled, render } = (0, import_react18.useContext)(ImageViewerContext);
8346
+ const ref = (0, import_react18.useRef)(null);
8347
+ const [open, setOpen] = (0, import_react18.useState)(void 0);
7390
8348
  const img = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("img", { className: imgClassName, src, alt });
7391
8349
  if (!enabled) {
7392
8350
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { className, href: src, target: "_blank", rel: "noopener noreferrer", title, children: img });
@@ -7448,9 +8406,9 @@ var FilesPanel = ({
7448
8406
  }) => {
7449
8407
  const L = useLabels(labels);
7450
8408
  const fs = useVirtualFiles(vfs, prefix);
7451
- const [preview, setPreview] = (0, import_react16.useState)();
7452
- const inputRef = (0, import_react16.useRef)(null);
7453
- (0, import_react16.useEffect)(() => {
8409
+ const [preview, setPreview] = (0, import_react19.useState)();
8410
+ const inputRef = (0, import_react19.useRef)(null);
8411
+ (0, import_react19.useEffect)(() => {
7454
8412
  if (preview && !fs.files.some((f) => f.path === preview.path)) setPreview(void 0);
7455
8413
  }, [fs.files, preview]);
7456
8414
  const open = async (f) => {
@@ -7551,7 +8509,7 @@ var FilesPanel = ({
7551
8509
  },
7552
8510
  f.path
7553
8511
  );
7554
- return renderFile ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react16.Fragment, { children: renderFile(f, row) }, f.path) : row;
8512
+ return renderFile ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react19.Fragment, { children: renderFile(f, row) }, f.path) : row;
7555
8513
  }) }),
7556
8514
  preview && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "awr-filepreview", children: preview.kind === "image" ? (
7557
8515
  // A click (Enter, Space) opens it over the chat, fitted to the screen.
@@ -7571,7 +8529,7 @@ var FilesPanel = ({
7571
8529
  };
7572
8530
 
7573
8531
  // src/components/FileChips.tsx
7574
- var import_react18 = require("react");
8532
+ var import_react21 = require("react");
7575
8533
 
7576
8534
  // src/file-kinds.ts
7577
8535
  var import_agent_web6 = require("@dudko.dev/agent-web");
@@ -7592,7 +8550,7 @@ var fileKindOf = (path, mediaType) => {
7592
8550
  var fileNameOf2 = (path) => path.split("/").filter(Boolean).pop() || "file";
7593
8551
 
7594
8552
  // src/components/Media.tsx
7595
- var import_react17 = require("react");
8553
+ var import_react20 = require("react");
7596
8554
  var import_agent_web7 = require("@dudko.dev/agent-web");
7597
8555
  var import_jsx_runtime12 = require("react/jsx-runtime");
7598
8556
  var mediaFamilyOf = (mediaType) => {
@@ -7609,8 +8567,8 @@ var bytesOf = (content, encoding) => {
7609
8567
  return bytes;
7610
8568
  };
7611
8569
  var useFileUrl = (files, path, mediaType) => {
7612
- const [url, setUrl] = (0, import_react17.useState)(void 0);
7613
- (0, import_react17.useEffect)(() => {
8570
+ const [url, setUrl] = (0, import_react20.useState)(void 0);
8571
+ (0, import_react20.useEffect)(() => {
7614
8572
  if (!files || !mediaType) return;
7615
8573
  let made;
7616
8574
  let gone = false;
@@ -7794,14 +8752,14 @@ var SourceView = ({
7794
8752
  const L = useLabels(labels);
7795
8753
  const cut = text2.length > maxChars;
7796
8754
  const shown = cut ? text2.slice(0, maxChars) : text2;
7797
- const lines = (0, import_react18.useMemo)(
8755
+ const lines = (0, import_react21.useMemo)(
7798
8756
  () => linesOf(html ? tokenizeHtml(shown) : [{ kind: "text", text: shown }]),
7799
8757
  [shown, html]
7800
8758
  );
7801
8759
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
7802
8760
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pre", { className: ["awr-source", className].filter(Boolean).join(" "), tabIndex: 0, children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "awr-source__line", children: [
7803
8761
  line.map(
7804
- (t, k) => t.kind === "text" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react18.Fragment, { children: t.text }, k) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `awr-source__${t.kind}`, children: t.text }, k)
8762
+ (t, k) => t.kind === "text" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react21.Fragment, { children: t.text }, k) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `awr-source__${t.kind}`, children: t.text }, k)
7805
8763
  ),
7806
8764
  "\n"
7807
8765
  ] }, i)) }),
@@ -7809,16 +8767,16 @@ var SourceView = ({
7809
8767
  ] });
7810
8768
  };
7811
8769
  var HtmlPreview = ({ written, file, htmlPreview, previewChars, L }) => {
7812
- const html = (0, import_react18.useMemo)(() => textOf(file), [file]);
8770
+ const html = (0, import_react21.useMemo)(() => textOf(file), [file]);
7813
8771
  const options = htmlPreview === false ? void 0 : htmlPreview;
7814
8772
  const tooLarge = html.length > HTML_PREVIEW_MAX_CHARS;
7815
8773
  const canFrame = Boolean(options) && !tooLarge;
7816
- const [view, setView] = (0, import_react18.useState)(canFrame ? "preview" : "source");
7817
- const [tall, setTall] = (0, import_react18.useState)(false);
8774
+ const [view, setView] = (0, import_react21.useState)(canFrame ? "preview" : "source");
8775
+ const [tall, setTall] = (0, import_react21.useState)(false);
7818
8776
  const showing = canFrame ? view : "source";
7819
8777
  const scripts = options?.scripts === true;
7820
8778
  const height = options?.height ?? 300;
7821
- const linked = (0, import_react18.useMemo)(() => showing === "preview" ? linkedFilesOf(html) : [], [html, showing]);
8779
+ const linked = (0, import_react21.useMemo)(() => showing === "preview" ? linkedFilesOf(html) : [], [html, showing]);
7822
8780
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
7823
8781
  SandboxedFrame,
7824
8782
  {
@@ -7931,14 +8889,14 @@ var TextPreview = ({
7931
8889
  onClose,
7932
8890
  L
7933
8891
  }) => {
7934
- const text2 = (0, import_react18.useMemo)(() => textOf(file), [file]);
7935
- const rendered = (0, import_react18.useMemo)(
8892
+ const text2 = (0, import_react21.useMemo)(() => textOf(file), [file]);
8893
+ const rendered = (0, import_react21.useMemo)(
7936
8894
  () => renderFileContent?.(written, text2.slice(0, previewChars)),
7937
8895
  [renderFileContent, written, text2, previewChars]
7938
8896
  );
7939
8897
  const hasRendered = rendered !== void 0 && rendered !== null && rendered !== false;
7940
- const [view, setView] = (0, import_react18.useState)("rendered");
7941
- const [all, setAll] = (0, import_react18.useState)(false);
8898
+ const [view, setView] = (0, import_react21.useState)("rendered");
8899
+ const [all, setAll] = (0, import_react21.useState)(false);
7942
8900
  const showing = hasRendered ? view : "source";
7943
8901
  const long = text2.length > 1200 || text2.split("\n").length > 16;
7944
8902
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-fileview", children: [
@@ -7980,11 +8938,11 @@ var FileChips = ({
7980
8938
  }) => {
7981
8939
  const L = useLabels(labels);
7982
8940
  const live = useVirtualFiles(vfs);
7983
- const [openPath, setOpenPath] = (0, import_react18.useState)(defaultOpen);
7984
- const [file, setFile] = (0, import_react18.useState)();
8941
+ const [openPath, setOpenPath] = (0, import_react21.useState)(defaultOpen);
8942
+ const [file, setFile] = (0, import_react21.useState)();
7985
8943
  const open = written.find((f) => f.path === openPath);
7986
8944
  const stamp = live.files.find((f) => f.path === openPath)?.updatedAt;
7987
- (0, import_react18.useEffect)(() => {
8945
+ (0, import_react21.useEffect)(() => {
7988
8946
  if (!vfs || !openPath) return setFile(void 0);
7989
8947
  let gone = false;
7990
8948
  vfs.read(openPath).then((f) => {
@@ -8107,14 +9065,14 @@ var FileChip = ({
8107
9065
  };
8108
9066
 
8109
9067
  // src/components/StepList.tsx
8110
- var import_react20 = require("react");
9068
+ var import_react23 = require("react");
8111
9069
 
8112
9070
  // src/components/SubagentTree.tsx
8113
- var import_react19 = require("react");
9071
+ var import_react22 = require("react");
8114
9072
  var import_jsx_runtime15 = require("react/jsx-runtime");
8115
9073
  var useElapsed = (startedAt, running) => {
8116
- const [now, setNow] = (0, import_react19.useState)(void 0);
8117
- (0, import_react19.useEffect)(() => {
9074
+ const [now, setNow] = (0, import_react22.useState)(void 0);
9075
+ (0, import_react22.useEffect)(() => {
8118
9076
  if (!running || startedAt === void 0) return;
8119
9077
  setNow(Date.now());
8120
9078
  const timer = setInterval(() => setNow(Date.now()), 1e3);
@@ -8204,7 +9162,7 @@ var SubagentTree = ({
8204
9162
  },
8205
9163
  node.id
8206
9164
  );
8207
- return renderSubagent ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react19.Fragment, { children: renderSubagent(node, row) }, node.id) : row;
9165
+ return renderSubagent ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react22.Fragment, { children: renderSubagent(node, row) }, node.id) : row;
8208
9166
  })
8209
9167
  }
8210
9168
  );
@@ -8383,7 +9341,7 @@ var StepItem = ({
8383
9341
  },
8384
9342
  i
8385
9343
  );
8386
- return renderToolCall ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react20.Fragment, { children: renderToolCall(call, row) }, i) : row;
9344
+ return renderToolCall ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react23.Fragment, { children: renderToolCall(call, row) }, i) : row;
8387
9345
  }) }),
8388
9346
  approvals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
8389
9347
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
@@ -8490,7 +9448,54 @@ var usageLine = (usage, durationMs) => {
8490
9448
  if (durationMs !== void 0) parts.push(formatDuration(durationMs));
8491
9449
  return parts.join(" \xB7 ");
8492
9450
  };
8493
- var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9451
+ var lengthOf = (ms) => typeof ms === "number" && Number.isFinite(ms) && ms >= 0 && ms < 864e5 ? ms : void 0;
9452
+ var settleAudioDuration = (el) => {
9453
+ if (el.duration !== Infinity) return;
9454
+ const back = () => {
9455
+ if (!Number.isFinite(el.duration)) return;
9456
+ el.removeEventListener("durationchange", back);
9457
+ el.removeEventListener("timeupdate", back);
9458
+ el.currentTime = 0;
9459
+ };
9460
+ el.addEventListener("durationchange", back);
9461
+ el.addEventListener("timeupdate", back);
9462
+ el.currentTime = Number.MAX_SAFE_INTEGER;
9463
+ };
9464
+ var AttachedAudio = ({
9465
+ attachment: a,
9466
+ files,
9467
+ labels
9468
+ }) => {
9469
+ const L = useLabels(labels);
9470
+ const type = a.mediaType.toLowerCase().split(";")[0].trim();
9471
+ const url = useFileUrl(files, a.path ?? "", files && a.path ? type : void 0);
9472
+ const length = lengthOf(a.durationMs);
9473
+ const said = length !== void 0 ? L.audioDuration(formatClock(length)) : void 0;
9474
+ return url ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "awr-media awr-media--audio awr-msg__audio", title: a.path ?? a.name, children: [
9475
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9476
+ "audio",
9477
+ {
9478
+ className: "awr-media__audio",
9479
+ controls: true,
9480
+ preload: "metadata",
9481
+ src: url,
9482
+ "aria-label": said ? `${L.audioAttachment(a.name)} (${said})` : L.audioAttachment(a.name),
9483
+ onLoadedMetadata: (e) => settleAudioDuration(e.currentTarget)
9484
+ }
9485
+ ),
9486
+ said && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__audiolen", "aria-hidden": "true", children: said })
9487
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "awr-chip awr-file", title: a.path ?? a.mediaType, children: [
9488
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(WaveIcon, { size: 13 }),
9489
+ " ",
9490
+ a.name,
9491
+ said ? ` \xB7 ${said}` : ""
9492
+ ] });
9493
+ };
9494
+ var AttachmentView = ({
9495
+ attachment: a,
9496
+ files,
9497
+ labels
9498
+ }) => mediaFamilyOf(a.mediaType) === "audio" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AttachedAudio, { attachment: a, files, labels }) : a.dataUrl && a.mediaType.startsWith("image/") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8494
9499
  ImageThumb,
8495
9500
  {
8496
9501
  src: a.dataUrl,
@@ -8553,10 +9558,12 @@ var MessageList = ({
8553
9558
  showApps = true,
8554
9559
  imageViewer = true,
8555
9560
  renderImageViewer,
9561
+ readAloud,
8556
9562
  labels,
8557
9563
  className
8558
9564
  }) => {
8559
9565
  const L = useLabels(labels);
9566
+ const reader = useReadAloud(readAloud?.speak, readAloud?.lang);
8560
9567
  if (messages.length === 0) {
8561
9568
  return empty ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-messages__empty", children: empty }) : null;
8562
9569
  }
@@ -8652,7 +9659,24 @@ var MessageList = ({
8652
9659
  labels
8653
9660
  }
8654
9661
  ) : null,
8655
- m.attachments?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__attachments", "aria-label": L.attachments, children: m.attachments.map((a, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AttachmentView, { attachment: a }) }, i)) }) : null,
9662
+ m.attachments?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9663
+ "div",
9664
+ {
9665
+ className: "awr-msg__attachments",
9666
+ role: "group",
9667
+ "aria-label": m.content.trim() ? L.attachments : attachmentsText(m.attachments, { voiceMessage: L.voiceMessage }),
9668
+ children: m.attachments.map((a, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AttachmentView, { attachment: a, files, labels }) }, i))
9669
+ }
9670
+ ) : null,
9671
+ readAloud && m.role === "assistant" && m.content && !m.pending && !m.error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9672
+ ReadAloudControl,
9673
+ {
9674
+ id: m.id,
9675
+ text: () => readAloud.textOf ? readAloud.textOf(m) : speakableText(m.content, { code: L.readAloudCode }),
9676
+ reader,
9677
+ labels: L
9678
+ }
9679
+ ),
8656
9680
  m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
8657
9681
  ] })
8658
9682
  },
@@ -8661,6 +9685,78 @@ var MessageList = ({
8661
9685
  return renderMessage ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: renderMessage(m, node) }, m.id) : node;
8662
9686
  }) }) });
8663
9687
  };
9688
+ var ReadAloudControl = ({
9689
+ id,
9690
+ text: text2,
9691
+ reader,
9692
+ labels: L
9693
+ }) => {
9694
+ const mine = reader.current === id;
9695
+ const failed = reader.failed?.id === id ? reader.failed : void 0;
9696
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-readaloud", "data-state": mine ? reader.state : "idle", children: [
9697
+ !mine ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
9698
+ "button",
9699
+ {
9700
+ type: "button",
9701
+ className: "awr-linkbtn awr-readaloud__btn",
9702
+ onClick: () => reader.start(id, text2()),
9703
+ "aria-label": L.readAloud,
9704
+ children: [
9705
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpeakerIcon, { size: 14 }),
9706
+ " ",
9707
+ L.readAloud
9708
+ ]
9709
+ }
9710
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
9711
+ reader.state === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "awr-readaloud__status", role: "status", children: [
9712
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14 }),
9713
+ " ",
9714
+ L.readAloudLoading
9715
+ ] }) : reader.state === "paused" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
9716
+ "button",
9717
+ {
9718
+ type: "button",
9719
+ className: "awr-linkbtn awr-readaloud__btn",
9720
+ onClick: reader.resume,
9721
+ "aria-label": L.readAloudResume,
9722
+ children: [
9723
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PlayIcon, { size: 14 }),
9724
+ " ",
9725
+ L.readAloudResume
9726
+ ]
9727
+ }
9728
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
9729
+ "button",
9730
+ {
9731
+ type: "button",
9732
+ className: "awr-linkbtn awr-readaloud__btn",
9733
+ onClick: reader.pause,
9734
+ "aria-label": L.readAloudPause,
9735
+ children: [
9736
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PauseIcon, { size: 14 }),
9737
+ " ",
9738
+ L.readAloudPause
9739
+ ]
9740
+ }
9741
+ ),
9742
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
9743
+ "button",
9744
+ {
9745
+ type: "button",
9746
+ className: "awr-linkbtn awr-readaloud__btn",
9747
+ onClick: reader.stop,
9748
+ "aria-label": L.readAloudStop,
9749
+ children: [
9750
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(StopIcon, { size: 14 }),
9751
+ " ",
9752
+ L.readAloudStop
9753
+ ]
9754
+ }
9755
+ )
9756
+ ] }),
9757
+ failed && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-readaloud__error", role: "alert", children: failed.message ?? L.readAloudFailed })
9758
+ ] });
9759
+ };
8664
9760
 
8665
9761
  // src/components/ModelLoadBar.tsx
8666
9762
  var import_jsx_runtime18 = require("react/jsx-runtime");
@@ -8679,11 +9775,11 @@ var ModelLoadBar = ({ load, className }) => {
8679
9775
  };
8680
9776
 
8681
9777
  // src/components/QuestionPrompt.tsx
8682
- var import_react21 = require("react");
9778
+ var import_react24 = require("react");
8683
9779
  var import_jsx_runtime19 = require("react/jsx-runtime");
8684
9780
  var useNow2 = (active) => {
8685
- const [now, setNow] = (0, import_react21.useState)(() => Date.now());
8686
- (0, import_react21.useEffect)(() => {
9781
+ const [now, setNow] = (0, import_react24.useState)(() => Date.now());
9782
+ (0, import_react24.useEffect)(() => {
8687
9783
  if (!active) return;
8688
9784
  setNow(Date.now());
8689
9785
  const timer = setInterval(() => setNow(Date.now()), 1e3);
@@ -8712,15 +9808,15 @@ var QuestionCard = ({
8712
9808
  numberKeys,
8713
9809
  L
8714
9810
  }) => {
8715
- const baseId = (0, import_react21.useId)();
9811
+ const baseId = (0, import_react24.useId)();
8716
9812
  const textId = `${baseId}-q`;
8717
9813
  const otherId = `${baseId}-other`;
8718
- const [picked, setPicked] = (0, import_react21.useState)([]);
8719
- const [otherOpen, setOtherOpen] = (0, import_react21.useState)(false);
8720
- const [otherText, setOtherText] = (0, import_react21.useState)("");
8721
- const otherField = (0, import_react21.useRef)(null);
8722
- const otherButton = (0, import_react21.useRef)(null);
8723
- (0, import_react21.useEffect)(() => {
9814
+ const [picked, setPicked] = (0, import_react24.useState)([]);
9815
+ const [otherOpen, setOtherOpen] = (0, import_react24.useState)(false);
9816
+ const [otherText, setOtherText] = (0, import_react24.useState)("");
9817
+ const otherField = (0, import_react24.useRef)(null);
9818
+ const otherButton = (0, import_react24.useRef)(null);
9819
+ (0, import_react24.useEffect)(() => {
8724
9820
  if (otherOpen) otherField.current?.focus();
8725
9821
  }, [otherOpen]);
8726
9822
  const helper = showHelper && q.subagent ? { ...q.subagent, ...view?.subagent } : void 0;
@@ -8851,7 +9947,7 @@ var QuestionCard = ({
8851
9947
  );
8852
9948
  };
8853
9949
  var RemoteQuestion = ({ view, L }) => {
8854
- const textId = `${(0, import_react21.useId)()}-q`;
9950
+ const textId = `${(0, import_react24.useId)()}-q`;
8855
9951
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
8856
9952
  "section",
8857
9953
  {
@@ -8888,7 +9984,7 @@ var QuestionPrompt = ({
8888
9984
  className
8889
9985
  }) => {
8890
9986
  const L = useLabels(labels);
8891
- const [dismissed, setDismissed] = (0, import_react21.useState)(() => /* @__PURE__ */ new Set());
9987
+ const [dismissed, setDismissed] = (0, import_react24.useState)(() => /* @__PURE__ */ new Set());
8892
9988
  const automatic = showOutcomes ? (outcomes ?? []).filter(
8893
9989
  (o) => o.automatic === true && o.status !== "pending" && o.status !== "stopped" && !dismissed.has(o.id)
8894
9990
  ) : [];
@@ -9145,10 +10241,10 @@ var UsageBadge = ({
9145
10241
  var import_jsx_runtime22 = require("react/jsx-runtime");
9146
10242
  var usePrefersDark = () => {
9147
10243
  const query = "(prefers-color-scheme: dark)";
9148
- const [dark, setDark] = (0, import_react22.useState)(
10244
+ const [dark, setDark] = (0, import_react25.useState)(
9149
10245
  () => typeof matchMedia === "function" && matchMedia(query).matches
9150
10246
  );
9151
- (0, import_react22.useEffect)(() => {
10247
+ (0, import_react25.useEffect)(() => {
9152
10248
  if (typeof matchMedia !== "function") return;
9153
10249
  const mq = matchMedia(query);
9154
10250
  const on = () => setDark(mq.matches);
@@ -9203,6 +10299,7 @@ var AgentChatInner = ({
9203
10299
  renderContent,
9204
10300
  renderMessage,
9205
10301
  renderAttachment,
10302
+ readAloud,
9206
10303
  renderToolCall,
9207
10304
  renderSubagent,
9208
10305
  renderMedia,
@@ -9238,17 +10335,19 @@ var AgentChatInner = ({
9238
10335
  }
9239
10336
  const L = useLabels();
9240
10337
  const external = isHistoryHook(history) ? history : void 0;
9241
- const [ownStore] = (0, import_react22.useState)(
10338
+ const [ownStore] = (0, import_react25.useState)(
9242
10339
  () => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
9243
10340
  );
9244
10341
  const own = useChatHistory(agent, {
9245
10342
  store: ownStore,
9246
- enabled: Boolean(history) && !external
10343
+ enabled: Boolean(history) && !external,
10344
+ // A chat begun by a voice message is titled in the chat's language.
10345
+ labels: { voiceMessage: L.voiceMessage }
9247
10346
  });
9248
10347
  const chats = history ? external ?? own : void 0;
9249
- const rootRef = (0, import_react22.useRef)(null);
9250
- const [narrow, setNarrow] = (0, import_react22.useState)(void 0);
9251
- (0, import_react22.useEffect)(() => {
10348
+ const rootRef = (0, import_react25.useRef)(null);
10349
+ const [narrow, setNarrow] = (0, import_react25.useState)(void 0);
10350
+ (0, import_react25.useEffect)(() => {
9252
10351
  const el = rootRef.current;
9253
10352
  if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
9254
10353
  const measure2 = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
@@ -9257,9 +10356,9 @@ var AgentChatInner = ({
9257
10356
  ro.observe(el);
9258
10357
  return () => ro.disconnect();
9259
10358
  }, [narrowWidth]);
9260
- const [historyChoice, setHistoryOpen] = (0, import_react22.useState)(defaultHistoryOpen);
10359
+ const [historyChoice, setHistoryOpen] = (0, import_react25.useState)(defaultHistoryOpen);
9261
10360
  const historyOpen = historyChoice ?? narrow === false;
9262
- const [filesOpen, setFilesOpen] = (0, import_react22.useState)(defaultFilesOpen);
10361
+ const [filesOpen, setFilesOpen] = (0, import_react25.useState)(defaultFilesOpen);
9263
10362
  const toggleHistory = () => {
9264
10363
  setHistoryOpen(!historyOpen);
9265
10364
  if (narrow && !historyOpen) setFilesOpen(false);
@@ -9277,7 +10376,7 @@ var AgentChatInner = ({
9277
10376
  setHistoryOpen(false);
9278
10377
  setFilesOpen(false);
9279
10378
  };
9280
- (0, import_react22.useEffect)(() => {
10379
+ (0, import_react25.useEffect)(() => {
9281
10380
  if (!overlayOpen) return;
9282
10381
  const onKey = (e) => {
9283
10382
  if (e.key !== "Escape" || e.defaultPrevented) return;
@@ -9287,7 +10386,7 @@ var AgentChatInner = ({
9287
10386
  document.addEventListener("keydown", onKey);
9288
10387
  return () => document.removeEventListener("keydown", onKey);
9289
10388
  }, [overlayOpen]);
9290
- const bodyRef = (0, import_react22.useRef)(null);
10389
+ const bodyRef = (0, import_react25.useRef)(null);
9291
10390
  const appHost = useMcpAppHost({
9292
10391
  connection: mcpApps,
9293
10392
  approve: agent.approveAppToolCall,
@@ -9299,7 +10398,7 @@ var AgentChatInner = ({
9299
10398
  });
9300
10399
  const prefersDark = usePrefersDark();
9301
10400
  const appTheme = theme === "auto" ? prefersDark ? "dark" : "light" : theme;
9302
- const [panelApp, setPanelAppState] = (0, import_react22.useState)();
10401
+ const [panelApp, setPanelAppState] = (0, import_react25.useState)();
9303
10402
  const setPanelApp = (app) => {
9304
10403
  setPanelAppState(app);
9305
10404
  onAppPanel?.(app);
@@ -9313,7 +10412,7 @@ var AgentChatInner = ({
9313
10412
  const panelAllowed = appPanel !== false && appPanel !== null;
9314
10413
  const panelTarget = typeof appPanel === "object" && appPanel ? appPanel : void 0;
9315
10414
  const asSheet = !panelTarget && (appPanel === "sheet" || Boolean(narrow));
9316
- (0, import_react22.useEffect)(() => {
10415
+ (0, import_react25.useEffect)(() => {
9317
10416
  if (panelApp && !agent.messages.some((m) => m.apps?.some((a) => a.id === panelApp.id))) {
9318
10417
  setPanelAppState(void 0);
9319
10418
  onAppPanel?.(void 0);
@@ -9353,7 +10452,7 @@ var AgentChatInner = ({
9353
10452
  },
9354
10453
  panelApp.id
9355
10454
  ) : null;
9356
- const [compacting, setCompacting] = (0, import_react22.useState)(false);
10455
+ const [compacting, setCompacting] = (0, import_react25.useState)(false);
9357
10456
  const compact = () => {
9358
10457
  setCompacting(true);
9359
10458
  void agent.compact().finally(() => setCompacting(false));
@@ -9511,6 +10610,7 @@ var AgentChatInner = ({
9511
10610
  renderContent,
9512
10611
  renderMessage,
9513
10612
  renderAttachment,
10613
+ readAloud,
9514
10614
  renderToolCall,
9515
10615
  showApps: appsOn,
9516
10616
  renderApp: appsOn ? drawApp : void 0,
@@ -9686,7 +10786,7 @@ var LearnedSkills = ({
9686
10786
  };
9687
10787
 
9688
10788
  // src/components/Composer.tsx
9689
- var import_react23 = require("react");
10789
+ var import_react26 = require("react");
9690
10790
  var import_jsx_runtime24 = require("react/jsx-runtime");
9691
10791
  var Composer = ({
9692
10792
  onSubmit,
@@ -9696,7 +10796,7 @@ var Composer = ({
9696
10796
  placeholder = "Ask the agent to do something\u2026",
9697
10797
  className
9698
10798
  }) => {
9699
- const [text2, setText] = (0, import_react23.useState)("");
10799
+ const [text2, setText] = (0, import_react26.useState)("");
9700
10800
  const submit = () => {
9701
10801
  const value = text2.trim();
9702
10802
  if (!value || busy || disabled) return;
@@ -9809,7 +10909,7 @@ var ApprovalModeSwitch = ({
9809
10909
  );
9810
10910
 
9811
10911
  // src/components/ApiKeyForm.tsx
9812
- var import_react24 = require("react");
10912
+ var import_react27 = require("react");
9813
10913
  var import_jsx_runtime27 = require("react/jsx-runtime");
9814
10914
  var ApiKeyForm = ({
9815
10915
  credentials,
@@ -9819,10 +10919,10 @@ var ApiKeyForm = ({
9819
10919
  onChange,
9820
10920
  className
9821
10921
  }) => {
9822
- const [value, setValue] = (0, import_react24.useState)("");
9823
- const [present, setPresent] = (0, import_react24.useState)(false);
9824
- const [busy, setBusy] = (0, import_react24.useState)(false);
9825
- (0, import_react24.useEffect)(() => {
10922
+ const [value, setValue] = (0, import_react27.useState)("");
10923
+ const [present, setPresent] = (0, import_react27.useState)(false);
10924
+ const [busy, setBusy] = (0, import_react27.useState)(false);
10925
+ (0, import_react27.useEffect)(() => {
9826
10926
  let active = true;
9827
10927
  credentials.hasKey(credentialRef).then((has) => {
9828
10928
  if (active) setPresent(has);
@@ -9975,13 +11075,17 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9975
11075
  MemorySkillStore,
9976
11076
  MemoryStore,
9977
11077
  MessageList,
11078
+ MicError,
9978
11079
  ModelLoadBar,
9979
11080
  PlanView,
9980
11081
  QUESTION_TIMEOUT_MS,
9981
11082
  QuestionPrompt,
11083
+ RECORDING_DEFAULT_MAX_MS,
11084
+ RECORDING_TYPES,
9982
11085
  SandboxedFrame,
9983
11086
  SessionBusyError,
9984
11087
  SourceView,
11088
+ SpeechOutputError,
9985
11089
  StepList,
9986
11090
  SubagentRow,
9987
11091
  SubagentTree,
@@ -10011,6 +11115,9 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10011
11115
  attachmentOverLimit,
10012
11116
  attachmentRefusal,
10013
11117
  attachmentTransformOf,
11118
+ attachmentsText,
11119
+ audioExtensionOf,
11120
+ audioTypeOf,
10014
11121
  buildMcpAppDocument,
10015
11122
  buildMcpAppSandboxShell,
10016
11123
  buildSandboxedDocument,
@@ -10019,9 +11126,12 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10019
11126
  clampFrameHeight,
10020
11127
  createAgent,
10021
11128
  createApprovalQueue,
11129
+ createAudioSpeaker,
11130
+ createBrowserSpeaker,
10022
11131
  createFileTools,
10023
11132
  createInitialAgentState,
10024
11133
  createQuestionQueue,
11134
+ createRecordingRecognizer,
10025
11135
  createRunControl,
10026
11136
  createSubagentTool,
10027
11137
  createWebLLMEngine,
@@ -10041,6 +11151,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10041
11151
  filterCommands,
10042
11152
  followsAfterResize,
10043
11153
  followsAfterScroll,
11154
+ formatClock,
10044
11155
  formatCountdown,
10045
11156
  formatElapsed,
10046
11157
  grantedAppCsp,
@@ -10064,24 +11175,34 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10064
11175
  mergeChatRecord,
10065
11176
  mergeLabels,
10066
11177
  messageOverLimit,
11178
+ micProblemOf,
11179
+ micProblemText,
10067
11180
  newChatId,
10068
11181
  noticesOf,
10069
11182
  onStorageChange,
10070
11183
  parseSkillMarkdown,
10071
11184
  parseSlash,
10072
11185
  pendingApprovalsOf,
11186
+ pickRecordingType,
10073
11187
  postStorageChange,
10074
11188
  preloadWebLLMModel,
10075
11189
  questionChoiceOf,
10076
11190
  questionOtherOf,
10077
11191
  questionTimeoutOf,
11192
+ recordingSupported,
10078
11193
  resolveAppDownload,
10079
11194
  sandboxTokens,
10080
11195
  sandboxedCsp,
10081
11196
  saveAppFile,
10082
11197
  saveChat,
10083
11198
  serveSubagentWorker,
11199
+ settleAudioDuration,
11200
+ speakableText,
11201
+ speechSynthesisSupported,
11202
+ splitForSpeech,
11203
+ startRecording,
10084
11204
  steerIntent,
11205
+ stopTracks,
10085
11206
  subagentTree,
10086
11207
  supportsImages,
10087
11208
  supportsPdf,
@@ -10091,6 +11212,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10091
11212
  usageLine,
10092
11213
  useAgent,
10093
11214
  useAgentContext,
11215
+ useAudioRecorder,
10094
11216
  useChatHistory,
10095
11217
  useCredentials,
10096
11218
  useFollowScroll,
@@ -10098,9 +11220,14 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
10098
11220
  useLocalModel,
10099
11221
  useMcpAppHost,
10100
11222
  useOptionalAgentContext,
11223
+ useReadAloud,
10101
11224
  useSpeechToText,
11225
+ useSpeechVoices,
10102
11226
  useVirtualFiles,
10103
11227
  useWebLLMModel,
11228
+ voiceFor,
11229
+ voiceMessageName,
11230
+ voicesOf,
10104
11231
  watchSession,
10105
11232
  webSearchOf,
10106
11233
  withAttachments,