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

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
@@ -92,6 +92,7 @@ __export(src_exports, {
92
92
  McpAppLine: () => McpAppLine,
93
93
  McpAppRpcError: () => McpAppRpcError,
94
94
  McpAppSandboxLink: () => McpAppSandboxLink,
95
+ MemoryCard: () => MemoryCard,
95
96
  MemoryCredentialStore: () => import_agent_web8.MemoryCredentialStore,
96
97
  MemorySkillStore: () => import_agent_web8.MemorySkillStore,
97
98
  MemoryStore: () => import_agent_web8.MemoryStore,
@@ -180,6 +181,7 @@ __export(src_exports, {
180
181
  imageSizeOf: () => imageSizeOf,
181
182
  isMcpAppSandboxMessage: () => isMcpAppSandboxMessage,
182
183
  isWebGPUAvailable: () => import_agent_web8.isWebGPUAvailable,
184
+ languageOfText: () => languageOfText,
183
185
  lessonsOf: () => lessonsOf,
184
186
  linkedFilesOf: () => linkedFilesOf,
185
187
  loadSkillFromUrl: () => import_agent_web8.loadSkillFromUrl,
@@ -216,6 +218,8 @@ __export(src_exports, {
216
218
  sandboxedCsp: () => sandboxedCsp,
217
219
  saveAppFile: () => saveAppFile,
218
220
  saveChat: () => saveChat,
221
+ scriptOfLanguage: () => scriptOfLanguage,
222
+ scriptOfText: () => scriptOfText,
219
223
  serveSubagentWorker: () => import_agent_web8.serveSubagentWorker,
220
224
  settleAudioDuration: () => settleAudioDuration,
221
225
  speakableText: () => speakableText,
@@ -512,8 +516,15 @@ var resetRun = (state) => ({
512
516
  seq: state.seq,
513
517
  learned: state.learned,
514
518
  // An MCP App's request is the user's, not the run's: it waits across runs.
515
- approvals: state.approvals.filter((a) => a.app && a.status === "pending")
519
+ approvals: state.approvals.filter((a) => a.app && a.status === "pending"),
520
+ // So is what this tab sent to another tab's run, until that tab answers (a replay that opens
521
+ // with the run's start is not an answer).
522
+ queued: sentToOtherTab(state.queued)
516
523
  });
524
+ var sentToOtherTab = (queued) => queued.filter((q) => q.sentTo === "another-tab");
525
+ var sentEntryOf = (queued, text2) => queued.findIndex(
526
+ (q) => q.sentTo === "another-tab" && (q.text === text2 || text2.endsWith("\u2026") && q.text.length > text2.length && q.text.startsWith(text2.slice(0, -1)))
527
+ );
517
528
  var patchStep = (steps, id, fn) => steps.map((s) => s.id === id ? fn(s) : s);
518
529
  var withoutSkillBody = (a) => {
519
530
  if (!a.skill || a.skill.body === void 0) return a;
@@ -993,6 +1004,7 @@ var applyEvent = (state, event, ctx) => {
993
1004
  const base2 = resetRun(ctx.remote ? state : withoutSubmitted(state));
994
1005
  const userId = `msg-${base2.seq}`;
995
1006
  const assistantId = `msg-${base2.seq + 1}`;
1007
+ const began = ctx.at !== void 0 ? { startedAt: ctx.at } : {};
996
1008
  return {
997
1009
  ...base2,
998
1010
  // Another tab's run keeps the view of it; a run of this tab's ends it (and any wait).
@@ -1010,6 +1022,7 @@ var applyEvent = (state, event, ctx) => {
1010
1022
  content: event.goal,
1011
1023
  pending: false,
1012
1024
  ...ctx.remote ? { remote: true } : {},
1025
+ ...began,
1013
1026
  ...ctx.attachments?.length ? { attachments: ctx.attachments } : {}
1014
1027
  },
1015
1028
  {
@@ -1017,7 +1030,8 @@ var applyEvent = (state, event, ctx) => {
1017
1030
  role: "assistant",
1018
1031
  content: "",
1019
1032
  pending: true,
1020
- ...ctx.remote ? { remote: true } : {}
1033
+ ...ctx.remote ? { remote: true } : {},
1034
+ ...began
1021
1035
  }
1022
1036
  ],
1023
1037
  seq: base2.seq + 2
@@ -1262,14 +1276,17 @@ var applyEvent = (state, event, ctx) => {
1262
1276
  return fileDeleted(state, event.path);
1263
1277
  case "mcp.app":
1264
1278
  return ctx.remote ? state : addApp(state, event);
1265
- case "message.queued":
1266
- return state.queued.some((q) => q.id === event.id) ? state : {
1267
- ...state,
1268
- queued: [
1269
- ...state.queued,
1270
- { id: event.id, text: event.text, ...event.origin ? { origin: event.origin } : {} }
1271
- ]
1279
+ case "message.queued": {
1280
+ if (state.queued.some((q) => q.id === event.id)) return state;
1281
+ const entry = {
1282
+ id: event.id,
1283
+ text: event.text,
1284
+ ...event.origin ? { origin: event.origin } : {}
1272
1285
  };
1286
+ const mine = ctx.remote && event.origin === "another-tab" ? sentEntryOf(state.queued, event.text) : -1;
1287
+ if (mine < 0) return { ...state, queued: [...state.queued, entry] };
1288
+ return { ...state, queued: state.queued.map((q, i) => i === mine ? entry : q) };
1289
+ }
1273
1290
  case "message.delivered": {
1274
1291
  const anchor = event.at === "round" ? runningStepId(state.steps) : event.at === "step" ? state.steps[state.steps.length - 1]?.id : void 0;
1275
1292
  return {
@@ -1597,9 +1614,21 @@ var agentStateReducer = (state, action) => {
1597
1614
  case "undelivered":
1598
1615
  return {
1599
1616
  ...state,
1600
- queued: action.keepQueued ? state.queued : [],
1617
+ queued: action.keepQueued ? state.queued : sentToOtherTab(state.queued),
1601
1618
  undelivered: action.texts
1602
1619
  };
1620
+ case "remote-send":
1621
+ return state.queued.some((q) => q.id === action.id) ? state : {
1622
+ ...state,
1623
+ queued: [
1624
+ ...state.queued,
1625
+ { id: action.id, text: action.text, sentTo: "another-tab" }
1626
+ ]
1627
+ };
1628
+ case "remote-answer": {
1629
+ const queued = state.queued.filter((q) => q.id !== action.id);
1630
+ return action.answer === "refused" ? { ...state, queued, undelivered: [...state.undelivered, action.text] } : { ...state, queued };
1631
+ }
1603
1632
  case "load": {
1604
1633
  const maxSeq = action.messages.reduce((n, m) => {
1605
1634
  const k = Number(/^msg-(\d+)$/.exec(m.id)?.[1] ?? -1);
@@ -1648,6 +1677,7 @@ var followOtherTabs = (core6, dbName, accept, settle, ms = 100) => {
1648
1677
  later.cancel();
1649
1678
  };
1650
1679
  };
1680
+ var remoteAnswerOf = (ok, stillWatching) => ok ? "taken" : stillWatching ? "refused" : "unknown";
1651
1681
 
1652
1682
  // src/hooks/use-agent.ts
1653
1683
  var dbNameOf = (store) => {
@@ -1883,18 +1913,16 @@ var useAgent = (config, options = {}) => {
1883
1913
  );
1884
1914
  runRef.current = run;
1885
1915
  const send = (0, import_react.useCallback)((text2) => controlRef.current?.send(text2) ?? false, []);
1916
+ const remoteSendsRef = (0, import_react.useRef)(0);
1886
1917
  const sendRemote = (0, import_react.useCallback)((text2) => {
1887
1918
  const watch = watchRef.current;
1888
1919
  const clean = typeof text2 === "string" ? text2.trim() : "";
1889
1920
  if (!watch?.state.running || !clean) return false;
1921
+ const id = `to-other-tab-${remoteSendsRef.current += 1}`;
1922
+ dispatch({ type: "remote-send", id, text: clean });
1890
1923
  void watch.send(clean).then((ok) => {
1891
- if (!ok) {
1892
- dispatch({
1893
- type: "undelivered",
1894
- texts: [...stateRef.current.undelivered, clean],
1895
- keepQueued: true
1896
- });
1897
- }
1924
+ const answer = remoteAnswerOf(ok, watchRef.current === watch);
1925
+ dispatch({ type: "remote-answer", id, text: clean, answer });
1898
1926
  });
1899
1927
  return true;
1900
1928
  }, []);
@@ -2247,6 +2275,22 @@ var renumber = (own, after) => {
2247
2275
  );
2248
2276
  return own.map((m) => ({ ...m, id: `msg-${next += 1}` }));
2249
2277
  };
2278
+ var turnAt = (m) => typeof m.startedAt === "number" && Number.isFinite(m.startedAt) ? m.startedAt : void 0;
2279
+ var placeByTurn = (stored, own) => {
2280
+ let i = stored.length;
2281
+ while (i > 0 && turnAt(stored[i - 1]) !== void 0) i -= 1;
2282
+ const out = stored.slice(0, i);
2283
+ for (const m of own) {
2284
+ const at = turnAt(m);
2285
+ while (i < stored.length && (at === void 0 || turnAt(stored[i]) <= at)) {
2286
+ out.push(stored[i]);
2287
+ i += 1;
2288
+ }
2289
+ out.push(m);
2290
+ }
2291
+ return [...out, ...stored.slice(i)];
2292
+ };
2293
+ var ownUnsaved = (messages, base2) => messages.some((m) => !m.remote && !base2?.known.has(m));
2250
2294
  var unchangedSince = (messages, base2) => base2 !== void 0 && messages.length === base2.known.size && messages.every((m) => base2.known.has(m));
2251
2295
  var mergeChatRecord = (view, stored, base2, texts) => {
2252
2296
  const local = view.messages.filter((m) => !m.remote);
@@ -2254,7 +2298,7 @@ var mergeChatRecord = (view, stored, base2, texts) => {
2254
2298
  return { record: { ...view, messages: local }, merged: false };
2255
2299
  }
2256
2300
  const own = local.filter((m) => !base2?.known.has(m));
2257
- const messages = [...stored.messages, ...renumber(own, stored.messages)];
2301
+ const messages = placeByTurn(stored.messages, renumber(own, stored.messages));
2258
2302
  return {
2259
2303
  record: {
2260
2304
  ...view,
@@ -2367,9 +2411,10 @@ var useChatHistory = (agent, options = {}) => {
2367
2411
  void select(sessionId);
2368
2412
  return;
2369
2413
  }
2370
- if (remote || messages.length === 0) return;
2414
+ if (messages.length === 0) return;
2371
2415
  const base2 = baseRef.current?.id === sessionId ? baseRef.current : void 0;
2372
2416
  if (unchangedSince(messages, base2)) return;
2417
+ if (remote && !ownUnsaved(messages, base2)) return;
2373
2418
  const now = Date.now();
2374
2419
  const createdAt = createdRef.current.get(sessionId) ?? now;
2375
2420
  createdRef.current.set(sessionId, createdAt);
@@ -2818,189 +2863,6 @@ var useAudioRecorder = (options = {}) => {
2818
2863
 
2819
2864
  // src/hooks/use-read-aloud.ts
2820
2865
  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
2866
 
3005
2867
  // src/voice/speak.ts
3006
2868
  var SpeechOutputError = class extends Error {
@@ -3067,10 +2929,98 @@ var splitForSpeech = (text2, max = 220) => {
3067
2929
  if (rest) pieces.push(rest);
3068
2930
  return pieces;
3069
2931
  };
2932
+ var SCRIPT_RANGES = [
2933
+ ["latin", /\p{Script=Latin}/u],
2934
+ ["cyrillic", /\p{Script=Cyrillic}/u],
2935
+ ["greek", /\p{Script=Greek}/u],
2936
+ ["arabic", /\p{Script=Arabic}/u],
2937
+ ["hebrew", /\p{Script=Hebrew}/u],
2938
+ ["kana", /[\p{Script=Hiragana}\p{Script=Katakana}]/u],
2939
+ ["han", /\p{Script=Han}/u],
2940
+ ["hangul", /\p{Script=Hangul}/u],
2941
+ ["devanagari", /\p{Script=Devanagari}/u],
2942
+ ["thai", /\p{Script=Thai}/u],
2943
+ ["georgian", /\p{Script=Georgian}/u],
2944
+ ["armenian", /\p{Script=Armenian}/u]
2945
+ ];
2946
+ var LANGUAGE_SCRIPT = {
2947
+ ru: "cyrillic",
2948
+ uk: "cyrillic",
2949
+ be: "cyrillic",
2950
+ bg: "cyrillic",
2951
+ sr: "cyrillic",
2952
+ mk: "cyrillic",
2953
+ kk: "cyrillic",
2954
+ ky: "cyrillic",
2955
+ tg: "cyrillic",
2956
+ mn: "cyrillic",
2957
+ el: "greek",
2958
+ ar: "arabic",
2959
+ fa: "arabic",
2960
+ ur: "arabic",
2961
+ he: "hebrew",
2962
+ yi: "hebrew",
2963
+ zh: "han",
2964
+ ja: "kana",
2965
+ ko: "hangul",
2966
+ hi: "devanagari",
2967
+ mr: "devanagari",
2968
+ ne: "devanagari",
2969
+ th: "thai",
2970
+ ka: "georgian",
2971
+ hy: "armenian"
2972
+ };
2973
+ var SCRIPT_DEFAULT = {
2974
+ latin: "en",
2975
+ cyrillic: "ru",
2976
+ greek: "el",
2977
+ arabic: "ar",
2978
+ hebrew: "he",
2979
+ han: "zh",
2980
+ kana: "ja",
2981
+ hangul: "ko",
2982
+ devanagari: "hi",
2983
+ thai: "th",
2984
+ georgian: "ka",
2985
+ armenian: "hy"
2986
+ };
2987
+ var scriptOfLanguage = (lang) => {
2988
+ const parts = lang.toLowerCase().replace(/_/g, "-").split("-");
2989
+ if (parts.includes("latn")) return "latin";
2990
+ if (parts.includes("cyrl")) return "cyrillic";
2991
+ return LANGUAGE_SCRIPT[parts[0]] ?? "latin";
2992
+ };
2993
+ var scriptOfText = (text2) => {
2994
+ const counts = /* @__PURE__ */ new Map();
2995
+ for (const ch of text2) {
2996
+ if (!/\p{L}/u.test(ch)) continue;
2997
+ const found = SCRIPT_RANGES.find(([, re]) => re.test(ch));
2998
+ if (!found) continue;
2999
+ counts.set(found[0], (counts.get(found[0]) ?? 0) + 1);
3000
+ }
3001
+ if (counts.has("kana")) {
3002
+ counts.set("kana", (counts.get("kana") ?? 0) + (counts.get("han") ?? 0));
3003
+ counts.delete("han");
3004
+ }
3005
+ let best;
3006
+ let most = 0;
3007
+ for (const [script, n] of counts)
3008
+ if (n > most) {
3009
+ best = script;
3010
+ most = n;
3011
+ }
3012
+ return best;
3013
+ };
3014
+ var languageOfText = (text2, preferred = []) => {
3015
+ const mine = preferred.filter((l) => Boolean(l));
3016
+ const script = scriptOfText(text2);
3017
+ if (!script) return mine[0];
3018
+ return mine.find((l) => scriptOfLanguage(l) === script) ?? SCRIPT_DEFAULT[script];
3019
+ };
3070
3020
  var voiceFor = (voices, lang, preferred) => {
3071
3021
  if (preferred) {
3072
3022
  const chosen = voices.find((v) => v.voiceURI === preferred);
3073
- if (chosen) return chosen;
3023
+ if (chosen && (!lang || scriptOfLanguage(chosen.lang) === scriptOfLanguage(lang))) return chosen;
3074
3024
  }
3075
3025
  if (!lang) return void 0;
3076
3026
  const norm = (l) => l.toLowerCase().replace(/_/g, "-");
@@ -3284,6 +3234,193 @@ var createAudioSpeaker = (options) => (text2, { lang, onState }) => {
3284
3234
  };
3285
3235
  };
3286
3236
 
3237
+ // src/hooks/use-read-aloud.ts
3238
+ var browserLanguages = () => typeof navigator !== "undefined" && Array.isArray(navigator.languages) ? navigator.languages : [];
3239
+ var useReadAloud = (speak, lang) => {
3240
+ const [current, setCurrent] = (0, import_react6.useState)();
3241
+ const [state, setState] = (0, import_react6.useState)();
3242
+ const [failed, setFailed] = (0, import_react6.useState)();
3243
+ const playback = (0, import_react6.useRef)(void 0);
3244
+ const langRef = (0, import_react6.useRef)(lang);
3245
+ langRef.current = lang;
3246
+ const stop = (0, import_react6.useCallback)(() => {
3247
+ const now = playback.current;
3248
+ playback.current = void 0;
3249
+ now?.handle.stop();
3250
+ setCurrent(void 0);
3251
+ setState(void 0);
3252
+ }, []);
3253
+ const start = (0, import_react6.useCallback)(
3254
+ (id, text2) => {
3255
+ if (!speak) return;
3256
+ stop();
3257
+ setFailed(void 0);
3258
+ setCurrent(id);
3259
+ setState("loading");
3260
+ const mine = { id, handle: void 0 };
3261
+ playback.current = mine;
3262
+ let handle;
3263
+ try {
3264
+ handle = speak(text2, {
3265
+ // The TEXT's language: a Russian answer in an English interface is read in Russian.
3266
+ lang: languageOfText(text2, [langRef.current, ...browserLanguages()]),
3267
+ onState: (s) => {
3268
+ if (playback.current === mine) setState(s);
3269
+ }
3270
+ });
3271
+ } catch (err) {
3272
+ playback.current = void 0;
3273
+ setCurrent(void 0);
3274
+ setState(void 0);
3275
+ const own = err instanceof Error && err.name !== "SpeechOutputError";
3276
+ setFailed({ id, ...own && err.message ? { message: err.message } : {} });
3277
+ return;
3278
+ }
3279
+ mine.handle = handle;
3280
+ handle.done.then(
3281
+ () => {
3282
+ if (playback.current !== mine) return;
3283
+ playback.current = void 0;
3284
+ setCurrent(void 0);
3285
+ setState(void 0);
3286
+ },
3287
+ (err) => {
3288
+ if (playback.current !== mine) return;
3289
+ playback.current = void 0;
3290
+ setCurrent(void 0);
3291
+ setState(void 0);
3292
+ const own = err instanceof Error && err.name !== "SpeechOutputError";
3293
+ setFailed({ id, ...own && err.message ? { message: err.message } : {} });
3294
+ }
3295
+ );
3296
+ },
3297
+ [speak, stop]
3298
+ );
3299
+ (0, import_react6.useEffect)(() => stop, [speak, stop]);
3300
+ return {
3301
+ current,
3302
+ state,
3303
+ failed,
3304
+ start,
3305
+ pause: () => playback.current?.handle.pause(),
3306
+ resume: () => playback.current?.handle.resume(),
3307
+ stop
3308
+ };
3309
+ };
3310
+
3311
+ // src/hooks/use-speech-voices.ts
3312
+ var import_react7 = require("react");
3313
+ var useSpeechVoices = () => {
3314
+ const synth = typeof globalThis !== "undefined" ? globalThis.speechSynthesis : void 0;
3315
+ const read = () => {
3316
+ try {
3317
+ return (synth?.getVoices() ?? []).map((v) => ({
3318
+ voiceURI: v.voiceURI,
3319
+ name: v.name,
3320
+ lang: v.lang,
3321
+ localService: v.localService,
3322
+ default: v.default
3323
+ }));
3324
+ } catch {
3325
+ return [];
3326
+ }
3327
+ };
3328
+ const [voices, setVoices] = (0, import_react7.useState)(read);
3329
+ (0, import_react7.useEffect)(() => {
3330
+ if (!synth) return;
3331
+ const update = () => setVoices(read());
3332
+ update();
3333
+ synth.addEventListener?.("voiceschanged", update);
3334
+ return () => synth.removeEventListener?.("voiceschanged", update);
3335
+ }, [synth]);
3336
+ return voices;
3337
+ };
3338
+
3339
+ // src/voice/recognizer.ts
3340
+ var createRecordingRecognizer = (options) => () => {
3341
+ let recording;
3342
+ let starting;
3343
+ let stopAsked = false;
3344
+ let aborted = false;
3345
+ let ended = false;
3346
+ const controller = new AbortController();
3347
+ const rec = {
3348
+ lang: "",
3349
+ continuous: true,
3350
+ interimResults: false,
3351
+ onresult: null,
3352
+ onerror: null,
3353
+ onend: null,
3354
+ start() {
3355
+ if (starting) return;
3356
+ starting = (async () => {
3357
+ try {
3358
+ recording = await startRecording({
3359
+ ...options,
3360
+ maxMs: options.maxMs,
3361
+ onLimit: () => rec.stop()
3362
+ });
3363
+ } catch (err) {
3364
+ if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
3365
+ return finish();
3366
+ }
3367
+ if (aborted) {
3368
+ recording.cancel();
3369
+ return finish();
3370
+ }
3371
+ if (stopAsked) void transcribeNow();
3372
+ })();
3373
+ },
3374
+ stop() {
3375
+ if (stopAsked || ended) return;
3376
+ stopAsked = true;
3377
+ if (recording) void transcribeNow();
3378
+ },
3379
+ abort() {
3380
+ if (ended) return;
3381
+ aborted = true;
3382
+ controller.abort();
3383
+ recording?.cancel();
3384
+ if (!starting || recording) finish();
3385
+ }
3386
+ };
3387
+ const finish = () => {
3388
+ if (ended) return;
3389
+ ended = true;
3390
+ rec.onend?.();
3391
+ };
3392
+ let transcribing = false;
3393
+ const transcribeNow = async () => {
3394
+ if (transcribing || !recording) return;
3395
+ transcribing = true;
3396
+ let audio;
3397
+ try {
3398
+ audio = await recording.stop();
3399
+ } catch (err) {
3400
+ if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
3401
+ return finish();
3402
+ }
3403
+ if (aborted) return finish();
3404
+ if (audio.blob.size === 0) return finish();
3405
+ try {
3406
+ const text2 = (await options.transcribe(audio, { lang: rec.lang, signal: controller.signal })).replace(/\s+/g, " ").trim();
3407
+ if (!aborted && text2)
3408
+ rec.onresult?.({
3409
+ resultIndex: 0,
3410
+ results: [{ isFinal: true, 0: { transcript: text2 } }]
3411
+ });
3412
+ } catch (err) {
3413
+ if (!aborted)
3414
+ rec.onerror?.({
3415
+ error: "transcription",
3416
+ message: err instanceof Error ? err.message : String(err)
3417
+ });
3418
+ }
3419
+ finish();
3420
+ };
3421
+ return rec;
3422
+ };
3423
+
3287
3424
  // src/hooks/use-credentials.ts
3288
3425
  var import_react8 = require("react");
3289
3426
  var core5 = __toESM(require("@dudko.dev/agent-web"), 1);
@@ -3695,6 +3832,11 @@ var defaultLabels = {
3695
3832
  notebookForget: "Forget",
3696
3833
  notebookRevision: (n) => `revision ${n}`,
3697
3834
  notebookFrom: "from",
3835
+ memorySaved: "Remembered",
3836
+ memoryUpdated: "Memory updated",
3837
+ memoryForgotten: "Forgotten",
3838
+ memoryUndo: "Undo",
3839
+ memoryUndone: "Undone",
3698
3840
  placeholder: "Ask the agent to do something\u2026 ( / for commands, Ctrl+V to paste an image )",
3699
3841
  listening: "Listening\u2026",
3700
3842
  message: "Message",
@@ -3794,6 +3936,7 @@ var defaultLabels = {
3794
3936
  noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
3795
3937
  queuedWaiting: "waiting for the agent\u2019s next step",
3796
3938
  queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
3939
+ queuedForOtherTab: "waiting for the other tab to pick it up",
3797
3940
  noteAt: {
3798
3941
  round: "you said, between tool calls",
3799
3942
  step: "you said, after this step",
@@ -5722,6 +5865,7 @@ var BookIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.
5722
5865
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2Z" }),
5723
5866
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 19V5M9 7h6" })
5724
5867
  ] });
5868
+ var BookmarkIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M6 3h12v18l-6-4-6 4Z" }) });
5725
5869
  var GlobeIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { ...base(size), className, children: [
5726
5870
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
5727
5871
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 12h18M12 3c3 3.2 3 14.8 0 18M12 3c-3 3.2-3 14.8 0 18" })
@@ -6843,6 +6987,47 @@ ${draftText}` : draftText);
6843
6987
  if (full) noRoom[full].push(name);
6844
6988
  else setPending((cur) => [...cur, a]);
6845
6989
  };
6990
+ const sendAs = async (name, f, kind, mediaType, transform, id) => {
6991
+ const blob = transform === "downscale" ? await downscaleImage(f, {
6992
+ maxDimension: imageMax,
6993
+ maxPixels: attachCfg.imageMaxPixels
6994
+ }) : f;
6995
+ const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
6996
+ if (sentOver) return overLimitText(name, sentOver);
6997
+ add(name, {
6998
+ id,
6999
+ name,
7000
+ kind,
7001
+ mediaType: blob.type || mediaType,
7002
+ dataUrl: await readDataUrl2(blob),
7003
+ bytes: blob.size,
7004
+ ...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
7005
+ });
7006
+ return void 0;
7007
+ };
7008
+ const addImage = async (name, blob, id) => {
7009
+ const mediaType = blob.type || "image/jpeg";
7010
+ if (attachmentKindOf(mediaType, name) !== "image") return L.binaryText(name);
7011
+ const transform = attachmentTransformOf({
7012
+ kind: "image",
7013
+ mediaType,
7014
+ imageMaxDimension: imageMax,
7015
+ converts: false
7016
+ });
7017
+ const size = transform === "downscale" ? await imageSizeOf(blob) : void 0;
7018
+ const over = attachmentOverLimit(
7019
+ { bytes: blob.size, pixels: size && size.width * size.height },
7020
+ "original",
7021
+ transform,
7022
+ bounds
7023
+ );
7024
+ if (over) return overLimitText(name, over);
7025
+ if (messageOverLimit(pendingRef.current, { kind: "image", bytes: 0 }, bounds) === "images") {
7026
+ noRoom.images.push(name);
7027
+ return void 0;
7028
+ }
7029
+ return sendAs(name, blob, "image", mediaType, transform, id);
7030
+ };
6846
7031
  for (const f of list) {
6847
7032
  const mediaType = f.type || "application/octet-stream";
6848
7033
  const name = f.name || `pasted-${Date.now()}.${mediaType.split("/")[1] ?? "bin"}`;
@@ -6881,9 +7066,9 @@ ${draftText}` : draftText);
6881
7066
  const converted = await convertFile(f);
6882
7067
  if (converted) {
6883
7068
  const bytes = new Blob([converted.text]).size;
6884
- const sentOver2 = attachmentOverLimit({ bytes }, "sent", transform, bounds);
6885
- if (sentOver2) {
6886
- problem = overLimitText(name, sentOver2);
7069
+ const sentOver = attachmentOverLimit({ bytes }, "sent", transform, bounds);
7070
+ if (sentOver) {
7071
+ problem = overLimitText(name, sentOver);
6887
7072
  continue;
6888
7073
  }
6889
7074
  add(name, {
@@ -6893,8 +7078,18 @@ ${draftText}` : draftText);
6893
7078
  mediaType: "text/markdown",
6894
7079
  text: converted.text,
6895
7080
  bytes,
6896
- note: L.convertedFrom(name)
7081
+ note: converted.note ?? L.convertedFrom(name)
6897
7082
  });
7083
+ const images = converted.images ?? [];
7084
+ if (images.length > 0) {
7085
+ const imageRefusal = attachmentRefusal("image", caps);
7086
+ if (imageRefusal) problem = imageRefusal;
7087
+ else
7088
+ for (const image of images) {
7089
+ const said3 = await addImage(image.name, image.blob, `att-${attachSeq += 1}`);
7090
+ if (said3) problem = said3;
7091
+ }
7092
+ }
6898
7093
  continue;
6899
7094
  }
6900
7095
  }
@@ -6902,24 +7097,8 @@ ${draftText}` : draftText);
6902
7097
  problem = refusal;
6903
7098
  continue;
6904
7099
  }
6905
- const blob = transform === "downscale" ? await downscaleImage(f, {
6906
- maxDimension: imageMax,
6907
- maxPixels: attachCfg.imageMaxPixels
6908
- }) : f;
6909
- const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
6910
- if (sentOver) {
6911
- problem = overLimitText(name, sentOver);
6912
- continue;
6913
- }
6914
- add(name, {
6915
- id,
6916
- name,
6917
- kind,
6918
- mediaType: blob.type || mediaType,
6919
- dataUrl: await readDataUrl2(blob),
6920
- bytes: blob.size,
6921
- ...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
6922
- });
7100
+ const said2 = await sendAs(name, f, kind, mediaType, transform, id);
7101
+ if (said2) problem = said2;
6923
7102
  } catch (err) {
6924
7103
  problem = `${name}: ${err instanceof Error ? err.message : String(err)}`;
6925
7104
  }
@@ -7171,7 +7350,7 @@ ${draftText}` : draftText);
7171
7350
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClockIcon, { size: 13, className: "awr-queued__icon" }),
7172
7351
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__text", title: q.text, children: q.text }),
7173
7352
  q.origin === "another-tab" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
7174
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
7353
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: q.sentTo ? L.queuedForOtherTab : q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
7175
7354
  ] }, q.id)),
7176
7355
  agent.undelivered.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
7177
7356
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AlertIcon, { size: 13, className: "awr-queued__icon" }),
@@ -9509,6 +9688,12 @@ var AttachmentView = ({
9509
9688
  " ",
9510
9689
  a.name
9511
9690
  ] });
9691
+ var toolCardsOf = (m, render) => (m.steps ?? []).flatMap(
9692
+ (step, s) => step.toolCalls.flatMap((call, c) => {
9693
+ const node = render(call, m);
9694
+ return node === null || node === void 0 || node === false ? [] : [{ key: `${s}:${c}`, node }];
9695
+ })
9696
+ );
9512
9697
  var toolCallCount = (m) => (m.steps ?? []).reduce((n, s) => n + s.toolCalls.length, 0);
9513
9698
  var activitySummary = (m, showToolCalls, showLearned, showTiers, showFileChips, L, showApps = false) => {
9514
9699
  const steps = m.steps ?? [];
@@ -9554,6 +9739,8 @@ var MessageList = ({
9554
9739
  renderMessage,
9555
9740
  renderAttachment,
9556
9741
  renderToolCall,
9742
+ renderToolCard,
9743
+ showToolCards = true,
9557
9744
  renderApp,
9558
9745
  showApps = true,
9559
9746
  imageViewer = true,
@@ -9571,6 +9758,7 @@ var MessageList = ({
9571
9758
  const steps = m.steps ?? [];
9572
9759
  const hasActivity = showActivity && (steps.length > 0 || (m.subagents?.length ?? 0) > 0 || m.pending && !!liveExtra);
9573
9760
  const usage = showUsage ? usageLine(m.usage, m.durationMs) : "";
9761
+ const cards = showToolCards && renderToolCard && m.role === "assistant" ? toolCardsOf(m, renderToolCard) : [];
9574
9762
  const node = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9575
9763
  "div",
9576
9764
  {
@@ -9637,12 +9825,22 @@ var MessageList = ({
9637
9825
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "awr-thought__text", children: m.reasoning.trim() })
9638
9826
  ] })
9639
9827
  ] }),
9828
+ cards.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__cards", children: cards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__card", children: card.node }, card.key)) }),
9640
9829
  showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
9641
9830
  showMedia && m.transcripts?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
9642
9831
  (m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__bubble", children: [
9643
9832
  m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
9644
9833
  m.pending && !m.content && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
9645
9834
  ] }),
9835
+ readAloud && m.role === "assistant" && m.content && !m.pending && !m.error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9836
+ ReadAloudControl,
9837
+ {
9838
+ id: m.id,
9839
+ text: () => readAloud.textOf ? readAloud.textOf(m) : speakableText(m.content, { code: L.readAloudCode }),
9840
+ reader,
9841
+ labels: L
9842
+ }
9843
+ ),
9646
9844
  showMedia && m.media?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
9647
9845
  const built = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GeneratedMedia, { media: item, files, labels }, i);
9648
9846
  return renderMedia ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__mediaitem", children: renderMedia(item, m, built) }, i) : built;
@@ -9668,15 +9866,6 @@ var MessageList = ({
9668
9866
  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
9867
  }
9670
9868
  ) : 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
- ),
9680
9869
  m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
9681
9870
  ] })
9682
9871
  },
@@ -10301,6 +10490,8 @@ var AgentChatInner = ({
10301
10490
  renderAttachment,
10302
10491
  readAloud,
10303
10492
  renderToolCall,
10493
+ renderToolCard,
10494
+ showToolCards = true,
10304
10495
  renderSubagent,
10305
10496
  renderMedia,
10306
10497
  renderFile,
@@ -10612,6 +10803,8 @@ var AgentChatInner = ({
10612
10803
  renderAttachment,
10613
10804
  readAloud,
10614
10805
  renderToolCall,
10806
+ renderToolCard,
10807
+ showToolCards,
10615
10808
  showApps: appsOn,
10616
10809
  renderApp: appsOn ? drawApp : void 0,
10617
10810
  imageViewer,
@@ -10785,9 +10978,59 @@ var LearnedSkills = ({
10785
10978
  ] });
10786
10979
  };
10787
10980
 
10788
- // src/components/Composer.tsx
10981
+ // src/components/MemoryCard.tsx
10789
10982
  var import_react26 = require("react");
10790
10983
  var import_jsx_runtime24 = require("react/jsx-runtime");
10984
+ var MemoryCard = ({
10985
+ kind,
10986
+ text: text2,
10987
+ onUndo,
10988
+ undone = false,
10989
+ problem,
10990
+ labels,
10991
+ className
10992
+ }) => {
10993
+ const L = useLabels(labels);
10994
+ const [busy, setBusy] = (0, import_react26.useState)(false);
10995
+ const label = kind === "saved" ? L.memorySaved : kind === "updated" ? L.memoryUpdated : L.memoryForgotten;
10996
+ const undo = () => {
10997
+ if (!onUndo || busy) return;
10998
+ setBusy(true);
10999
+ void Promise.resolve().then(onUndo).catch(() => {
11000
+ }).finally(() => setBusy(false));
11001
+ };
11002
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
11003
+ "div",
11004
+ {
11005
+ className: ["awr-memory", `awr-memory--${kind}`, undone ? "is-undone" : "", className].filter(Boolean).join(" "),
11006
+ "data-memory": kind,
11007
+ children: [
11008
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(BookmarkIcon, { size: 14, className: "awr-memory__icon" }),
11009
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "awr-memory__body", children: [
11010
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "awr-memory__label", children: label }),
11011
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "awr-memory__text", children: text2 }),
11012
+ problem && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "awr-memory__problem", role: "alert", children: problem })
11013
+ ] }),
11014
+ undone ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "awr-memory__undone", children: L.memoryUndone }) : onUndo ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11015
+ "button",
11016
+ {
11017
+ type: "button",
11018
+ className: "awr-memory__undo",
11019
+ disabled: busy,
11020
+ "aria-busy": busy,
11021
+ "aria-label": `${L.memoryUndo}: ${text2}`,
11022
+ onClick: undo,
11023
+ children: L.memoryUndo
11024
+ }
11025
+ ) : null
11026
+ ]
11027
+ }
11028
+ );
11029
+ };
11030
+
11031
+ // src/components/Composer.tsx
11032
+ var import_react27 = require("react");
11033
+ var import_jsx_runtime25 = require("react/jsx-runtime");
10791
11034
  var Composer = ({
10792
11035
  onSubmit,
10793
11036
  busy = false,
@@ -10796,7 +11039,7 @@ var Composer = ({
10796
11039
  placeholder = "Ask the agent to do something\u2026",
10797
11040
  className
10798
11041
  }) => {
10799
- const [text2, setText] = (0, import_react26.useState)("");
11042
+ const [text2, setText] = (0, import_react27.useState)("");
10800
11043
  const submit = () => {
10801
11044
  const value = text2.trim();
10802
11045
  if (!value || busy || disabled) return;
@@ -10809,7 +11052,7 @@ var Composer = ({
10809
11052
  submit();
10810
11053
  }
10811
11054
  };
10812
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
11055
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
10813
11056
  "form",
10814
11057
  {
10815
11058
  className: ["awr-composer", className].filter(Boolean).join(" "),
@@ -10818,7 +11061,7 @@ var Composer = ({
10818
11061
  submit();
10819
11062
  },
10820
11063
  children: [
10821
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11064
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
10822
11065
  "textarea",
10823
11066
  {
10824
11067
  className: "awr-composer__input",
@@ -10830,23 +11073,23 @@ var Composer = ({
10830
11073
  rows: 1
10831
11074
  }
10832
11075
  ),
10833
- busy ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11076
+ busy ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
10834
11077
  "button",
10835
11078
  {
10836
11079
  type: "button",
10837
11080
  className: "awr-composer__btn awr-composer__btn--stop",
10838
11081
  onClick: onStop,
10839
11082
  "aria-label": "Stop",
10840
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(StopIcon, { size: 18 })
11083
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(StopIcon, { size: 18 })
10841
11084
  }
10842
- ) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11085
+ ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
10843
11086
  "button",
10844
11087
  {
10845
11088
  type: "submit",
10846
11089
  className: "awr-composer__btn",
10847
11090
  disabled: disabled || !text2.trim(),
10848
11091
  "aria-label": "Send",
10849
- children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SendIcon, { size: 18 })
11092
+ children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SendIcon, { size: 18 })
10850
11093
  }
10851
11094
  )
10852
11095
  ]
@@ -10855,17 +11098,17 @@ var Composer = ({
10855
11098
  };
10856
11099
 
10857
11100
  // src/components/PlanView.tsx
10858
- var import_jsx_runtime25 = require("react/jsx-runtime");
11101
+ var import_jsx_runtime26 = require("react/jsx-runtime");
10859
11102
  var PlanView = ({ plan, showThought = true, className }) => {
10860
11103
  if (!plan.steps.length && !plan.thought) return null;
10861
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
10862
- showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
10863
- plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
11104
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
11105
+ showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
11106
+ plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
10864
11107
  ] });
10865
11108
  };
10866
11109
 
10867
11110
  // src/components/ApprovalModeSwitch.tsx
10868
- var import_jsx_runtime26 = require("react/jsx-runtime");
11111
+ var import_jsx_runtime27 = require("react/jsx-runtime");
10869
11112
  var DEFAULT_LABELS = {
10870
11113
  autopilot: "Autopilot",
10871
11114
  "ask-writes": "Ask before changes",
@@ -10885,13 +11128,13 @@ var ApprovalModeSwitch = ({
10885
11128
  labels,
10886
11129
  disabled,
10887
11130
  className
10888
- }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
11131
+ }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
10889
11132
  "div",
10890
11133
  {
10891
11134
  className: ["awr-modeswitch", className].filter(Boolean).join(" "),
10892
11135
  role: "radiogroup",
10893
11136
  "aria-label": "Tool consent",
10894
- children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
11137
+ children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
10895
11138
  "button",
10896
11139
  {
10897
11140
  type: "button",
@@ -10909,8 +11152,8 @@ var ApprovalModeSwitch = ({
10909
11152
  );
10910
11153
 
10911
11154
  // src/components/ApiKeyForm.tsx
10912
- var import_react27 = require("react");
10913
- var import_jsx_runtime27 = require("react/jsx-runtime");
11155
+ var import_react28 = require("react");
11156
+ var import_jsx_runtime28 = require("react/jsx-runtime");
10914
11157
  var ApiKeyForm = ({
10915
11158
  credentials,
10916
11159
  credentialRef,
@@ -10919,10 +11162,10 @@ var ApiKeyForm = ({
10919
11162
  onChange,
10920
11163
  className
10921
11164
  }) => {
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)(() => {
11165
+ const [value, setValue] = (0, import_react28.useState)("");
11166
+ const [present, setPresent] = (0, import_react28.useState)(false);
11167
+ const [busy, setBusy] = (0, import_react28.useState)(false);
11168
+ (0, import_react28.useEffect)(() => {
10926
11169
  let active = true;
10927
11170
  credentials.hasKey(credentialRef).then((has) => {
10928
11171
  if (active) setPresent(has);
@@ -10954,16 +11197,16 @@ var ApiKeyForm = ({
10954
11197
  setBusy(false);
10955
11198
  }
10956
11199
  };
10957
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
10958
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "awr-keyform__label", children: [
11200
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
11201
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("label", { className: "awr-keyform__label", children: [
10959
11202
  label,
10960
- present && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "awr-keyform__saved", children: [
10961
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckIcon, { size: 12 }),
11203
+ present && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "awr-keyform__saved", children: [
11204
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CheckIcon, { size: 12 }),
10962
11205
  " stored, encrypted"
10963
11206
  ] })
10964
11207
  ] }),
10965
- /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "awr-keyform__row", children: [
10966
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
11208
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "awr-keyform__row", children: [
11209
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10967
11210
  "input",
10968
11211
  {
10969
11212
  className: "awr-keyform__input",
@@ -10981,7 +11224,7 @@ var ApiKeyForm = ({
10981
11224
  disabled: busy
10982
11225
  }
10983
11226
  ),
10984
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
11227
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10985
11228
  "button",
10986
11229
  {
10987
11230
  type: "button",
@@ -10991,7 +11234,7 @@ var ApiKeyForm = ({
10991
11234
  children: "Save"
10992
11235
  }
10993
11236
  ),
10994
- present && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
11237
+ present && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
10995
11238
  "button",
10996
11239
  {
10997
11240
  type: "button",
@@ -11071,6 +11314,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
11071
11314
  McpAppLine,
11072
11315
  McpAppRpcError,
11073
11316
  McpAppSandboxLink,
11317
+ MemoryCard,
11074
11318
  MemoryCredentialStore,
11075
11319
  MemorySkillStore,
11076
11320
  MemoryStore,
@@ -11159,6 +11403,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
11159
11403
  imageSizeOf,
11160
11404
  isMcpAppSandboxMessage,
11161
11405
  isWebGPUAvailable,
11406
+ languageOfText,
11162
11407
  lessonsOf,
11163
11408
  linkedFilesOf,
11164
11409
  loadSkillFromUrl,
@@ -11195,6 +11440,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
11195
11440
  sandboxedCsp,
11196
11441
  saveAppFile,
11197
11442
  saveChat,
11443
+ scriptOfLanguage,
11444
+ scriptOfText,
11198
11445
  serveSubagentWorker,
11199
11446
  settleAudioDuration,
11200
11447
  speakableText,