@hyperwindmill/caretaker-cli 0.29.0 → 0.31.0

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.
Files changed (76) hide show
  1. package/dist/agents/dispatch.d.ts.map +1 -1
  2. package/dist/agents/dispatch.js +4 -1
  3. package/dist/cli/web/server.d.ts.map +1 -1
  4. package/dist/cli/web/server.js +29 -7
  5. package/dist/cli/web/session_scope.d.ts +11 -0
  6. package/dist/cli/web/session_scope.d.ts.map +1 -0
  7. package/dist/cli/web/session_scope.js +13 -0
  8. package/dist/cli/web/turn_guard.d.ts +9 -0
  9. package/dist/cli/web/turn_guard.d.ts.map +1 -0
  10. package/dist/cli/web/turn_guard.js +18 -0
  11. package/dist/cli/web/voice_backend.d.ts +4 -0
  12. package/dist/cli/web/voice_backend.d.ts.map +1 -1
  13. package/dist/cli/web/voice_backend.js +14 -3
  14. package/dist/cli/web/voice_builtin.d.ts +3 -0
  15. package/dist/cli/web/voice_builtin.d.ts.map +1 -0
  16. package/dist/cli/web/voice_builtin.js +74 -0
  17. package/dist/cli/web/voice_proxy.d.ts +36 -1
  18. package/dist/cli/web/voice_proxy.d.ts.map +1 -1
  19. package/dist/cli/web/voice_proxy.js +201 -30
  20. package/dist/commands/loader.js +2 -2
  21. package/dist/harness/tools/builtin/index.d.ts.map +1 -1
  22. package/dist/harness/tools/builtin/index.js +4 -0
  23. package/dist/harness/tools/builtin/set_workspace.d.ts +3 -0
  24. package/dist/harness/tools/builtin/set_workspace.d.ts.map +1 -0
  25. package/dist/harness/tools/builtin/set_workspace.js +71 -0
  26. package/dist/plugins/manifest.d.ts +1 -1
  27. package/dist/plugins/manifest.js +1 -1
  28. package/dist/session/store.d.ts +6 -0
  29. package/dist/session/store.d.ts.map +1 -1
  30. package/dist/session/store.js +11 -0
  31. package/dist/session/types.d.ts +5 -0
  32. package/dist/session/types.d.ts.map +1 -1
  33. package/dist/store/db.d.ts.map +1 -1
  34. package/dist/store/db.js +3 -1
  35. package/dist/voice/pocket/catalog.d.ts +24 -0
  36. package/dist/voice/pocket/catalog.d.ts.map +1 -0
  37. package/dist/voice/pocket/catalog.js +152 -0
  38. package/dist/voice/pocket/engine.d.ts +17 -0
  39. package/dist/voice/pocket/engine.d.ts.map +1 -0
  40. package/dist/voice/pocket/engine.js +145 -0
  41. package/dist/voice/pocket/inference.d.ts +36 -0
  42. package/dist/voice/pocket/inference.d.ts.map +1 -0
  43. package/dist/voice/pocket/inference.js +228 -0
  44. package/dist/voice/pocket/install.d.ts +68 -0
  45. package/dist/voice/pocket/install.d.ts.map +1 -0
  46. package/dist/voice/pocket/install.js +329 -0
  47. package/dist/voice/pocket/tokenizer.d.ts +42 -0
  48. package/dist/voice/pocket/tokenizer.d.ts.map +1 -0
  49. package/dist/voice/pocket/tokenizer.js +279 -0
  50. package/dist/voice/pocket/voices.d.ts +9 -0
  51. package/dist/voice/pocket/voices.d.ts.map +1 -0
  52. package/dist/voice/pocket/voices.js +88 -0
  53. package/dist/voice/pronunciation.d.ts +16 -0
  54. package/dist/voice/pronunciation.d.ts.map +1 -0
  55. package/dist/voice/pronunciation.js +54 -0
  56. package/dist/voice/whisper/catalog.d.ts +15 -0
  57. package/dist/voice/whisper/catalog.d.ts.map +1 -0
  58. package/dist/voice/whisper/catalog.js +53 -0
  59. package/dist/voice/whisper/decoder.d.ts +3 -0
  60. package/dist/voice/whisper/decoder.d.ts.map +1 -0
  61. package/dist/voice/whisper/decoder.js +48 -0
  62. package/dist/voice/whisper/engine.d.ts +8 -0
  63. package/dist/voice/whisper/engine.d.ts.map +1 -0
  64. package/dist/voice/whisper/engine.js +77 -0
  65. package/dist/voice/whisper/features.d.ts +10 -0
  66. package/dist/voice/whisper/features.d.ts.map +1 -0
  67. package/dist/voice/whisper/features.js +149 -0
  68. package/dist/voice/whisper/inference.d.ts +17 -0
  69. package/dist/voice/whisper/inference.d.ts.map +1 -0
  70. package/dist/voice/whisper/inference.js +257 -0
  71. package/dist/voice/whisper/wav.d.ts +5 -0
  72. package/dist/voice/whisper/wav.d.ts.map +1 -0
  73. package/dist/voice/whisper/wav.js +48 -0
  74. package/dist/webview/standalone.js +1777 -743
  75. package/dist/webview/standalone.js.map +4 -4
  76. package/package.json +3 -3
@@ -14583,11 +14583,34 @@
14583
14583
  });
14584
14584
 
14585
14585
  // src/standalone.tsx
14586
- var import_react23 = __toESM(require_react(), 1);
14586
+ var import_react26 = __toESM(require_react(), 1);
14587
14587
  var import_client = __toESM(require_client(), 1);
14588
14588
 
14589
14589
  // src/App.tsx
14590
- var import_react22 = __toESM(require_react(), 1);
14590
+ var import_react25 = __toESM(require_react(), 1);
14591
+
14592
+ // src/assistant_activation.ts
14593
+ function beginActivation(agentId, confirmedAgentId, knownAgentIds, current) {
14594
+ if (!knownAgentIds.includes(agentId)) return current;
14595
+ if (current?.step === "awaiting-agent" && current.agentId === agentId) return current;
14596
+ return { agentId, step: agentId === confirmedAgentId ? "open" : "awaiting-agent" };
14597
+ }
14598
+ function onAgentSelected(a2, agentId) {
14599
+ if (a2 && a2.step === "awaiting-agent" && a2.agentId === agentId) return { agentId, step: "open" };
14600
+ return a2;
14601
+ }
14602
+ function onSelectFailed(a2) {
14603
+ return a2?.step === "awaiting-agent" ? null : a2;
14604
+ }
14605
+ function resolvePending(pendingId, confirmedAgentId, knownAgentIds, current) {
14606
+ if (!pendingId) return { activation: current, pending: null };
14607
+ if (knownAgentIds.length === 0) return { activation: current, pending: pendingId };
14608
+ return { activation: beginActivation(pendingId, confirmedAgentId, knownAgentIds, current), pending: null };
14609
+ }
14610
+ function localSelectionFor(a2, selectedAgentId) {
14611
+ if (a2?.step !== "open" || a2.agentId === selectedAgentId) return null;
14612
+ return a2.agentId;
14613
+ }
14591
14614
 
14592
14615
  // src/MessageList.tsx
14593
14616
  var import_react5 = __toESM(require_react(), 1);
@@ -17075,7 +17098,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
17075
17098
  voice = null,
17076
17099
  value: propValue,
17077
17100
  onValueChange: propOnValueChange,
17078
- allowAttachments = true
17101
+ allowAttachments = true,
17102
+ focusToken
17079
17103
  }) {
17080
17104
  const [internalValue, setInternalValue] = (0, import_react6.useState)("");
17081
17105
  const value = propValue !== void 0 ? propValue : internalValue;
@@ -17102,6 +17126,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
17102
17126
  }
17103
17127
  prevDisabled.current = disabled;
17104
17128
  }, [disabled]);
17129
+ (0, import_react6.useEffect)(() => {
17130
+ if (focusToken) inputRef.current?.focus();
17131
+ }, [focusToken]);
17105
17132
  const send = () => {
17106
17133
  onSend(value, attachments.length > 0 ? attachments : void 0);
17107
17134
  setValue("");
@@ -17365,7 +17392,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
17365
17392
  }
17366
17393
 
17367
17394
  // src/SettingsPanel.tsx
17368
- var import_react18 = __toESM(require_react(), 1);
17395
+ var import_react21 = __toESM(require_react(), 1);
17369
17396
 
17370
17397
  // src/ProvidersTab.tsx
17371
17398
  var import_react7 = __toESM(require_react(), 1);
@@ -20747,7 +20774,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20747
20774
  }
20748
20775
 
20749
20776
  // src/VoiceTab.tsx
20750
- var import_react16 = __toESM(require_react(), 1);
20777
+ var import_react18 = __toESM(require_react(), 1);
20751
20778
 
20752
20779
  // src/voice_utils.ts
20753
20780
  var END_OF_TURN_MS = 1200;
@@ -20810,7 +20837,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20810
20837
  v2.ttsVoice ?? "",
20811
20838
  v2.ttsSpeed ?? "",
20812
20839
  v2.lang ?? "",
20813
- v2.autoStartBackend === true
20840
+ v2.autoStartBackend === true,
20841
+ v2.ttsEngine ?? "",
20842
+ v2.sttEngine ?? "",
20843
+ v2.sttBuiltinModel ?? "",
20844
+ v2.ttsLanguage ?? "",
20845
+ v2.pronunciationEnabled === true,
20846
+ v2.pronunciation ?? null,
20847
+ v2.playbackBufferMs ?? ""
20814
20848
  ]);
20815
20849
  }
20816
20850
 
@@ -20975,10 +21009,573 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20975
21009
  ] });
20976
21010
  }
20977
21011
 
20978
- // src/VoiceTab.tsx
21012
+ // src/BuiltinVoiceBlock.tsx
21013
+ var import_react16 = __toESM(require_react(), 1);
20979
21014
  var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
20980
- var BACKEND_POLL_MS = 1e4;
20981
- var EMPTY = { enabled: false, endpoint: "", sttModel: "" };
21015
+ var MB = 1024 * 1024;
21016
+ function sizeLabel(bytes) {
21017
+ return `${Math.max(1, Math.round(bytes / MB))} MB`;
21018
+ }
21019
+ function progressText(p) {
21020
+ if (p.step === "done" || p.step === "error") return null;
21021
+ const what = p.step === "runtime" ? "Runtime" : "Voice";
21022
+ const pct = p.total > 0 ? ` ${Math.floor(p.received / p.total * 100)}%` : "";
21023
+ return `${what}: ${p.file}${pct}`;
21024
+ }
21025
+ function BuiltinVoiceBlock({
21026
+ status,
21027
+ onStatusChange,
21028
+ language,
21029
+ onLanguageChange,
21030
+ voice,
21031
+ onVoiceChange
21032
+ }) {
21033
+ const [busy, setBusy] = (0, import_react16.useState)(false);
21034
+ const [progress, setProgress] = (0, import_react16.useState)(null);
21035
+ const [error, setError] = (0, import_react16.useState)(null);
21036
+ const [confirmingDelete, setConfirmingDelete] = (0, import_react16.useState)(false);
21037
+ const loadError = status.runtime.loadError;
21038
+ const selected = status.languages.find((l) => l.id === language);
21039
+ const query = `?language=${encodeURIComponent(language)}`;
21040
+ const voices = selected ? [selected.nativeVoice, ...status.voices.filter((v2) => v2 !== selected.nativeVoice)] : status.voices;
21041
+ const install = async () => {
21042
+ setBusy(true);
21043
+ setError(null);
21044
+ setProgress("Starting\u2026");
21045
+ try {
21046
+ const res = await fetch(`/api/voice/builtin/install${query}`, { method: "POST" });
21047
+ if (!res.ok || !res.body) {
21048
+ setError(await res.text().catch(() => "") || "Install failed.");
21049
+ return;
21050
+ }
21051
+ const reader = res.body.getReader();
21052
+ const decoder = new TextDecoder();
21053
+ let buffer = "";
21054
+ for (; ; ) {
21055
+ const { done, value } = await reader.read();
21056
+ if (done) break;
21057
+ const { lines, remainder } = splitNdjsonLines(buffer, decoder.decode(value, { stream: true }));
21058
+ buffer = remainder;
21059
+ for (const line of lines) {
21060
+ let p;
21061
+ try {
21062
+ p = JSON.parse(line);
21063
+ } catch {
21064
+ continue;
21065
+ }
21066
+ if (p.step === "done") onStatusChange(p.status);
21067
+ else if (p.step === "error") setError(p.message);
21068
+ else setProgress(progressText(p));
21069
+ }
21070
+ }
21071
+ } catch (err) {
21072
+ setError(err instanceof Error ? err.message : String(err));
21073
+ } finally {
21074
+ setBusy(false);
21075
+ setProgress(null);
21076
+ }
21077
+ };
21078
+ const remove = async () => {
21079
+ setConfirmingDelete(false);
21080
+ setBusy(true);
21081
+ setError(null);
21082
+ try {
21083
+ const res = await fetch(`/api/voice/builtin/delete${query}`, { method: "POST" });
21084
+ if (res.ok) onStatusChange(await res.json());
21085
+ else setError(await res.text().catch(() => "") || "Delete failed.");
21086
+ } catch (err) {
21087
+ setError(err instanceof Error ? err.message : String(err));
21088
+ } finally {
21089
+ setBusy(false);
21090
+ }
21091
+ };
21092
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21093
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: "voice-builtin-language", children: [
21094
+ "Built-in voice",
21095
+ " ",
21096
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("em", { children: "(not available on this system)" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("em", { children: "(recommended)" })
21097
+ ] }),
21098
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "form-error", children: loadError }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
21099
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
21100
+ "select",
21101
+ {
21102
+ id: "voice-builtin-language",
21103
+ value: language,
21104
+ onChange: (e) => {
21105
+ onLanguageChange(e.target.value);
21106
+ setConfirmingDelete(false);
21107
+ },
21108
+ children: [
21109
+ !selected && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: language, children: language || "-- Select a language --" }),
21110
+ status.languages.map((l) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("option", { value: l.id, children: [
21111
+ l.id,
21112
+ " (",
21113
+ l.code,
21114
+ ") \u2014 ",
21115
+ l.installed ? "installed" : `not installed, ${sizeLabel(l.bytes)}`
21116
+ ] }, l.id))
21117
+ ]
21118
+ }
21119
+ ),
21120
+ selected && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "voice-backend-status", children: [
21121
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: progress ?? (selected.installed ? `Installed (${sizeLabel(selected.bytes)})` : `Not installed \u2014 downloads ${sizeLabel(selected.bytes)}`) }),
21122
+ !selected.installed && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", onClick: install, disabled: busy, children: busy ? "Installing\u2026" : "Install" }),
21123
+ selected.installed && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21124
+ "button",
21125
+ {
21126
+ type: "button",
21127
+ onClick: confirmingDelete ? remove : () => setConfirmingDelete(true),
21128
+ disabled: busy,
21129
+ children: confirmingDelete ? "Really delete?" : "Delete"
21130
+ }
21131
+ )
21132
+ ] }),
21133
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "form-error", children: error }),
21134
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-builtin-voice", style: { marginTop: "0.6em" }, children: "Voice" }),
21135
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { id: "voice-builtin-voice", value: voice, onChange: (e) => onVoiceChange(e.target.value), children: [
21136
+ voice && !voices.includes(voice) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: voice, children: voice }),
21137
+ voices.map((v2) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: v2, children: v2 }, v2))
21138
+ ] }),
21139
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Runs inside caretaker \u2014 no server or Docker. Speaking rate is not adjustable with this engine." })
21140
+ ] }),
21141
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21142
+ "Voice model",
21143
+ " ",
21144
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { href: "https://huggingface.co/kyutai/pocket-tts", target: "_blank", rel: "noreferrer", children: "Pocket TTS" }),
21145
+ " ",
21146
+ "by Kyutai, via the",
21147
+ " ",
21148
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21149
+ "a",
21150
+ {
21151
+ href: "https://huggingface.co/Alias-Alias/pocket-3-3-0-tts-onnx",
21152
+ target: "_blank",
21153
+ rel: "noreferrer",
21154
+ children: "ONNX export"
21155
+ }
21156
+ ),
21157
+ ", licensed CC BY 4.0."
21158
+ ] })
21159
+ ] });
21160
+ }
21161
+
21162
+ // src/BuiltinSttBlock.tsx
21163
+ var import_react17 = __toESM(require_react(), 1);
21164
+ var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
21165
+ var MB2 = 1024 * 1024;
21166
+ function sizeLabel2(bytes) {
21167
+ return `${Math.max(1, Math.round(bytes / MB2))} MB`;
21168
+ }
21169
+ function BuiltinSttBlock({ status, onStatusChange, model, onModelChange }) {
21170
+ const [busy, setBusy] = (0, import_react17.useState)(false);
21171
+ const [progress, setProgress] = (0, import_react17.useState)(null);
21172
+ const [error, setError] = (0, import_react17.useState)(null);
21173
+ const [confirmingDelete, setConfirmingDelete] = (0, import_react17.useState)(false);
21174
+ const loadError = status.runtime.loadError;
21175
+ const selected = status.stt.find((m2) => m2.id === model);
21176
+ const query = `?stt=${encodeURIComponent(model)}`;
21177
+ const install = async () => {
21178
+ setBusy(true);
21179
+ setError(null);
21180
+ setProgress("Starting\u2026");
21181
+ try {
21182
+ const res = await fetch(`/api/voice/builtin/install${query}`, { method: "POST" });
21183
+ if (!res.ok || !res.body) {
21184
+ setError(await res.text().catch(() => "") || "Install failed.");
21185
+ return;
21186
+ }
21187
+ const reader = res.body.getReader();
21188
+ const decoder = new TextDecoder();
21189
+ let buffer = "";
21190
+ for (; ; ) {
21191
+ const { done, value } = await reader.read();
21192
+ if (done) break;
21193
+ const { lines, remainder } = splitNdjsonLines(buffer, decoder.decode(value, { stream: true }));
21194
+ buffer = remainder;
21195
+ for (const line of lines) {
21196
+ let p;
21197
+ try {
21198
+ p = JSON.parse(line);
21199
+ } catch {
21200
+ continue;
21201
+ }
21202
+ if (p.step === "done") onStatusChange(p.status);
21203
+ else if (p.step === "error") setError(p.message);
21204
+ else {
21205
+ const pct = p.total > 0 ? ` ${Math.floor(p.received / p.total * 100)}%` : "";
21206
+ setProgress(`${p.step === "runtime" ? "Runtime" : "Model"}: ${p.file}${pct}`);
21207
+ }
21208
+ }
21209
+ }
21210
+ } catch (err) {
21211
+ setError(err instanceof Error ? err.message : String(err));
21212
+ } finally {
21213
+ setBusy(false);
21214
+ setProgress(null);
21215
+ }
21216
+ };
21217
+ const remove = async () => {
21218
+ setConfirmingDelete(false);
21219
+ setBusy(true);
21220
+ setError(null);
21221
+ try {
21222
+ const res = await fetch(`/api/voice/builtin/delete${query}`, { method: "POST" });
21223
+ if (res.ok) onStatusChange(await res.json());
21224
+ else setError(await res.text().catch(() => "") || "Delete failed.");
21225
+ } catch (err) {
21226
+ setError(err instanceof Error ? err.message : String(err));
21227
+ } finally {
21228
+ setBusy(false);
21229
+ }
21230
+ };
21231
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group", children: [
21232
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { htmlFor: "voice-builtin-stt", children: [
21233
+ "Built-in transcription",
21234
+ " ",
21235
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("em", { children: "(not available on this system)" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("em", { children: "(Whisper)" })
21236
+ ] }),
21237
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { className: "form-error", children: loadError }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
21238
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21239
+ "select",
21240
+ {
21241
+ id: "voice-builtin-stt",
21242
+ value: model,
21243
+ onChange: (e) => {
21244
+ onModelChange(e.target.value);
21245
+ setConfirmingDelete(false);
21246
+ },
21247
+ children: status.stt.map((m2) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("option", { value: m2.id, children: [
21248
+ m2.id,
21249
+ m2.id === "base" ? " (recommended)" : "",
21250
+ " \u2014",
21251
+ " ",
21252
+ m2.installed ? "installed" : `not installed, ${sizeLabel2(m2.bytes)}`
21253
+ ] }, m2.id))
21254
+ }
21255
+ ),
21256
+ selected && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "voice-backend-status", children: [
21257
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: progress ?? (selected.installed ? `Installed (${sizeLabel2(selected.bytes)})` : `Not installed \u2014 downloads ${sizeLabel2(selected.bytes)}`) }),
21258
+ !selected.installed && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: install, disabled: busy, children: busy ? "Installing\u2026" : "Install" }),
21259
+ selected.installed && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21260
+ "button",
21261
+ {
21262
+ type: "button",
21263
+ onClick: confirmingDelete ? remove : () => setConfirmingDelete(true),
21264
+ disabled: busy,
21265
+ children: confirmingDelete ? "Really delete?" : "Delete"
21266
+ }
21267
+ )
21268
+ ] }),
21269
+ error && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { className: "form-error", children: error }),
21270
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: "Runs inside caretaker \u2014 no server or Docker. Small is slow for conversation on most CPUs; base is the better trade-off." })
21271
+ ] }),
21272
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("small", { children: [
21273
+ "Whisper by OpenAI (MIT), ONNX export by",
21274
+ " ",
21275
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21276
+ "a",
21277
+ {
21278
+ href: `https://huggingface.co/onnx-community/whisper-${model || "base"}`,
21279
+ target: "_blank",
21280
+ rel: "noreferrer",
21281
+ children: "onnx-community"
21282
+ }
21283
+ ),
21284
+ "."
21285
+ ] })
21286
+ ] });
21287
+ }
21288
+
21289
+ // src/PronunciationTable.tsx
21290
+ var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
21291
+ function PronunciationTable({
21292
+ code,
21293
+ entries,
21294
+ enabled,
21295
+ onEnabledChange,
21296
+ onChange,
21297
+ onRestoreDefaults,
21298
+ onListen,
21299
+ listening,
21300
+ listenError
21301
+ }) {
21302
+ const update = (i, patch) => onChange(entries.map((e, j) => j === i ? { ...e, ...patch } : e));
21303
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21304
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "form-group--checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { htmlFor: "voice-pron-enabled", children: [
21305
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21306
+ "input",
21307
+ {
21308
+ id: "voice-pron-enabled",
21309
+ type: "checkbox",
21310
+ checked: enabled,
21311
+ onChange: (e) => onEnabledChange(e.target.checked)
21312
+ }
21313
+ ),
21314
+ "Pronunciation dictionary"
21315
+ ] }) }),
21316
+ code === null ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Set a language above to edit its dictionary." }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
21317
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { children: [
21318
+ "Words below are respelled before synthesis (whole word, case-insensitive, longest first) for language ",
21319
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: code }),
21320
+ ". Listen uses the unsaved form."
21321
+ ] }),
21322
+ entries.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "voice-backend-status", children: [
21323
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21324
+ "input",
21325
+ {
21326
+ type: "text",
21327
+ "aria-label": "Term",
21328
+ placeholder: "term",
21329
+ value: e.term,
21330
+ onChange: (ev) => update(i, { term: ev.target.value })
21331
+ }
21332
+ ),
21333
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21334
+ "input",
21335
+ {
21336
+ type: "text",
21337
+ "aria-label": "Spoken as",
21338
+ placeholder: "spoken as",
21339
+ value: e.say,
21340
+ onChange: (ev) => update(i, { say: ev.target.value })
21341
+ }
21342
+ ),
21343
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21344
+ "button",
21345
+ {
21346
+ type: "button",
21347
+ disabled: listening || !e.term.trim(),
21348
+ onClick: () => onListen(e.term.trim()),
21349
+ children: "Listen"
21350
+ }
21351
+ ),
21352
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: () => onChange(entries.filter((_2, j) => j !== i)), children: "Remove" })
21353
+ ] }, i)),
21354
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "voice-backend-status", children: [
21355
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: () => onChange([...entries, { term: "", say: "" }]), children: "Add word" }),
21356
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: onRestoreDefaults, children: "Restore defaults" })
21357
+ ] })
21358
+ ] }),
21359
+ listenError && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { className: "form-error", children: [
21360
+ "Listen failed: ",
21361
+ listenError
21362
+ ] })
21363
+ ] });
21364
+ }
21365
+
21366
+ // src/voice_stream.ts
21367
+ function parsePcmType(contentType) {
21368
+ if (!contentType) return null;
21369
+ const [type, ...params] = contentType.split(";").map((s) => s.trim().toLowerCase());
21370
+ if (type !== "audio/pcm" && type !== "audio/l16") return null;
21371
+ const get = (key) => {
21372
+ const p = params.find((x) => x.startsWith(`${key}=`));
21373
+ return p ? Number(p.slice(key.length + 1)) : NaN;
21374
+ };
21375
+ const rate = get("rate");
21376
+ const channels = get("channels");
21377
+ return {
21378
+ rate: Number.isFinite(rate) && rate > 0 ? rate : 24e3,
21379
+ channels: Number.isFinite(channels) && channels > 0 ? channels : 1
21380
+ };
21381
+ }
21382
+ function pcm16Chunk(bytes, carry) {
21383
+ let data = bytes;
21384
+ if (carry && carry.length > 0) {
21385
+ data = new Uint8Array(carry.length + bytes.length);
21386
+ data.set(carry, 0);
21387
+ data.set(bytes, carry.length);
21388
+ }
21389
+ const count = data.length >> 1;
21390
+ const samples = new Float32Array(count);
21391
+ for (let i = 0; i < count; i++) {
21392
+ const v2 = data[2 * i] | data[2 * i + 1] << 8;
21393
+ samples[i] = (v2 >= 32768 ? v2 - 65536 : v2) / 32768;
21394
+ }
21395
+ return { samples, carry: data.length & 1 ? data.slice(data.length - 1) : null };
21396
+ }
21397
+ function nextStart(now, cursor, bufferSeconds2) {
21398
+ return cursor > now + MIN_AHEAD_SECONDS ? cursor : now + bufferSeconds2;
21399
+ }
21400
+ var MIN_AHEAD_SECONDS = 0.01;
21401
+ var DEFAULT_PLAYBACK_BUFFER_MS = 500;
21402
+ var MAX_PLAYBACK_BUFFER_MS = 5e3;
21403
+ function bufferSeconds(ms) {
21404
+ const v2 = Number.isFinite(ms) ? ms : DEFAULT_PLAYBACK_BUFFER_MS;
21405
+ return Math.min(Math.max(v2, 0), MAX_PLAYBACK_BUFFER_MS) / 1e3;
21406
+ }
21407
+ function choosePath(contentType, mseSupports) {
21408
+ if (parsePcmType(contentType)) return "pcm";
21409
+ const type = (contentType ?? "").split(";")[0].trim().toLowerCase();
21410
+ if (type === "audio/mpeg" && mseSupports("audio/mpeg")) return "mse";
21411
+ return "buffered";
21412
+ }
21413
+
21414
+ // src/speech_player.ts
21415
+ async function playSpeech(res, signal, opts = {}) {
21416
+ if (signal.aborted) return;
21417
+ const buffer = bufferSeconds(opts.bufferMs);
21418
+ const contentType = res.headers.get("content-type");
21419
+ const path = choosePath(contentType, (t) => typeof MediaSource !== "undefined" && MediaSource.isTypeSupported(t));
21420
+ if (path === "pcm" && res.body) return playPcm(res, signal, parsePcmType(contentType), buffer);
21421
+ if (path === "mse" && res.body) return playMse(res, signal, buffer);
21422
+ return playBuffered(res, signal);
21423
+ }
21424
+ async function playPcm(res, signal, fmt, buffer) {
21425
+ const ctx = new AudioContext({ sampleRate: fmt.rate });
21426
+ const reader = res.body.getReader();
21427
+ const sources = [];
21428
+ const onAbort = () => {
21429
+ void reader.cancel().catch(() => {
21430
+ });
21431
+ for (const s of sources) {
21432
+ s.onended = null;
21433
+ try {
21434
+ s.stop();
21435
+ } catch {
21436
+ }
21437
+ }
21438
+ };
21439
+ signal.addEventListener("abort", onAbort, { once: true });
21440
+ try {
21441
+ await ctx.resume();
21442
+ let carry = null;
21443
+ let rest = new Float32Array(0);
21444
+ let cursor = 0;
21445
+ let last = null;
21446
+ let chunks = 0;
21447
+ let dry = 0;
21448
+ for (; ; ) {
21449
+ const { done, value } = await reader.read();
21450
+ if (signal.aborted) return;
21451
+ if (done) break;
21452
+ const out = pcm16Chunk(value, carry);
21453
+ carry = out.carry;
21454
+ let samples = out.samples;
21455
+ if (rest.length) {
21456
+ const joined = new Float32Array(rest.length + samples.length);
21457
+ joined.set(rest, 0);
21458
+ joined.set(samples, rest.length);
21459
+ samples = joined;
21460
+ }
21461
+ const frames = Math.floor(samples.length / fmt.channels);
21462
+ rest = samples.slice(frames * fmt.channels);
21463
+ if (frames === 0) continue;
21464
+ const buf = ctx.createBuffer(fmt.channels, frames, fmt.rate);
21465
+ for (let c2 = 0; c2 < fmt.channels; c2++) {
21466
+ const ch = buf.getChannelData(c2);
21467
+ for (let i = 0; i < frames; i++) ch[i] = samples[i * fmt.channels + c2];
21468
+ }
21469
+ const src = ctx.createBufferSource();
21470
+ src.buffer = buf;
21471
+ src.connect(ctx.destination);
21472
+ const now = ctx.currentTime;
21473
+ const at2 = nextStart(now, cursor, buffer);
21474
+ if (chunks > 0 && at2 !== cursor) {
21475
+ dry++;
21476
+ console.warn(
21477
+ `[voice] playback ran dry before chunk ${chunks}: ${Math.round((now - cursor) * 1e3)} ms late, re-buffering ${Math.round(buffer * 1e3)} ms`
21478
+ );
21479
+ }
21480
+ chunks++;
21481
+ src.start(at2);
21482
+ cursor = at2 + buf.duration;
21483
+ sources.push(src);
21484
+ last = src;
21485
+ }
21486
+ if (!last) return;
21487
+ if (dry > 0) console.warn(`[voice] ${dry} of ${chunks} chunks arrived after the audio ran dry`);
21488
+ const latency = (ctx.outputLatency || 0) + (ctx.baseLatency || 0);
21489
+ const remainingMs = Math.max(0, (cursor - ctx.currentTime + latency) * 1e3);
21490
+ await new Promise((resolve) => {
21491
+ const timer = setTimeout(resolve, remainingMs);
21492
+ signal.addEventListener("abort", () => (clearTimeout(timer), resolve()), { once: true });
21493
+ });
21494
+ } finally {
21495
+ signal.removeEventListener("abort", onAbort);
21496
+ void ctx.close().catch(() => {
21497
+ });
21498
+ }
21499
+ }
21500
+ async function playMse(res, signal, buffer) {
21501
+ const ms = new MediaSource();
21502
+ const url = URL.createObjectURL(ms);
21503
+ const audio = new Audio(url);
21504
+ const reader = res.body.getReader();
21505
+ const onAbort = () => {
21506
+ void reader.cancel().catch(() => {
21507
+ });
21508
+ audio.pause();
21509
+ };
21510
+ signal.addEventListener("abort", onAbort, { once: true });
21511
+ try {
21512
+ await new Promise((resolve) => ms.addEventListener("sourceopen", () => resolve(), { once: true }));
21513
+ const sb = ms.addSourceBuffer("audio/mpeg");
21514
+ const append = (data) => new Promise((resolve, reject) => {
21515
+ sb.addEventListener("updateend", () => resolve(), { once: true });
21516
+ sb.addEventListener("error", () => reject(new Error("Could not decode the synthesized reply.")), { once: true });
21517
+ sb.appendBuffer(data);
21518
+ });
21519
+ let failPlayback;
21520
+ const ended = new Promise((resolve, reject) => {
21521
+ failPlayback = reject;
21522
+ audio.onended = () => resolve();
21523
+ audio.onerror = () => reject(new Error("Could not play the synthesized reply."));
21524
+ signal.addEventListener("abort", () => resolve(), { once: true });
21525
+ });
21526
+ ended.catch(() => {
21527
+ });
21528
+ let started = false;
21529
+ const start = () => {
21530
+ started = true;
21531
+ audio.play().catch((e) => !signal.aborted && failPlayback(e));
21532
+ };
21533
+ for (; ; ) {
21534
+ const { done, value } = await reader.read();
21535
+ if (signal.aborted) return;
21536
+ if (done) break;
21537
+ await append(value);
21538
+ if (signal.aborted) return;
21539
+ if (!started && bufferedEnd(sb) >= buffer) start();
21540
+ }
21541
+ if (!started && bufferedEnd(sb) > 0) start();
21542
+ if (!started) return;
21543
+ if (ms.readyState === "open") ms.endOfStream();
21544
+ await ended;
21545
+ } finally {
21546
+ signal.removeEventListener("abort", onAbort);
21547
+ audio.pause();
21548
+ audio.removeAttribute("src");
21549
+ URL.revokeObjectURL(url);
21550
+ }
21551
+ }
21552
+ async function playBuffered(res, signal) {
21553
+ const blob = await res.blob();
21554
+ if (signal.aborted) return;
21555
+ const url = URL.createObjectURL(blob);
21556
+ const audio = new Audio(url);
21557
+ const onAbort = () => audio.pause();
21558
+ signal.addEventListener("abort", onAbort, { once: true });
21559
+ try {
21560
+ const ended = new Promise((resolve, reject) => {
21561
+ audio.onended = () => resolve();
21562
+ audio.onerror = () => reject(new Error("Could not play the synthesized reply."));
21563
+ signal.addEventListener("abort", () => resolve(), { once: true });
21564
+ });
21565
+ await audio.play();
21566
+ await ended;
21567
+ } finally {
21568
+ signal.removeEventListener("abort", onAbort);
21569
+ audio.pause();
21570
+ audio.removeAttribute("src");
21571
+ URL.revokeObjectURL(url);
21572
+ }
21573
+ }
21574
+ function bufferedEnd(sb) {
21575
+ return sb.buffered.length ? sb.buffered.end(sb.buffered.length - 1) : 0;
21576
+ }
21577
+
21578
+ // src/voice_tab_presets.ts
20982
21579
  var LOCAL_DEFAULTS = {
20983
21580
  endpoint: "http://127.0.0.1:8969/v1",
20984
21581
  sttModel: "Systran/faster-whisper-small",
@@ -20990,6 +21587,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20990
21587
  ttsModel: "tts-1",
20991
21588
  ttsVoice: "it-IT-ElsaNeural"
20992
21589
  };
21590
+ function pocketLanguageFor(bcp47, status) {
21591
+ const primary = (bcp47 ?? "").trim().toLowerCase().split(/[-_]/)[0];
21592
+ const hit = primary ? status.languages.find((l) => l.code === primary) : void 0;
21593
+ return hit?.id ?? "english";
21594
+ }
21595
+ function builtinPreset(lang, status) {
21596
+ const id = pocketLanguageFor(lang, status);
21597
+ const entry = status.languages.find((l) => l.id === id);
21598
+ return {
21599
+ sttEngine: "builtin",
21600
+ sttBuiltinModel: "base",
21601
+ ttsEngine: "builtin",
21602
+ ttsLanguage: id,
21603
+ ttsVoice: entry?.nativeVoice ?? status.voices[0] ?? "",
21604
+ pronunciationEnabled: true
21605
+ };
21606
+ }
21607
+ function edgePreset() {
21608
+ return { ...EDGE_TTS_DEFAULTS, sttEngine: "endpoint", ttsEngine: "endpoint", pronunciationEnabled: false };
21609
+ }
21610
+ function localDefaultsPreset(lang, status) {
21611
+ const stt = { enabled: true, sttEngine: "endpoint", endpoint: LOCAL_DEFAULTS.endpoint, sttModel: LOCAL_DEFAULTS.sttModel };
21612
+ if (status && !status.runtime.loadError) return { ...stt, ...builtinPreset(lang, status), sttEngine: "endpoint" };
21613
+ return {
21614
+ ...stt,
21615
+ ttsEngine: "endpoint",
21616
+ ttsModel: LOCAL_DEFAULTS.ttsModel,
21617
+ ttsVoice: LOCAL_DEFAULTS.ttsVoice
21618
+ };
21619
+ }
21620
+
21621
+ // src/VoiceTab.tsx
21622
+ var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
21623
+ function parsedBufferMs(v2) {
21624
+ const n = Number.parseInt(v2, 10);
21625
+ return Number.isFinite(n) ? Math.min(Math.max(n, 0), MAX_PLAYBACK_BUFFER_MS) : void 0;
21626
+ }
21627
+ var BACKEND_POLL_MS = 1e4;
21628
+ var EMPTY = { enabled: false, endpoint: "", sttModel: "" };
21629
+ var SAMPLES = {
21630
+ it: "Ciao, questa \xE8 una prova della voce.",
21631
+ en: "Hello, this is a test of the voice."
21632
+ };
20993
21633
  function withCurrent(ids, current) {
20994
21634
  const trimmed = current.trim();
20995
21635
  if (!trimmed || ids.includes(trimmed)) return ids;
@@ -21001,24 +21641,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21001
21641
  }
21002
21642
  function VoiceTab({ config, onSave, postMessage, sttCatalogResult, ttsCatalogResult }) {
21003
21643
  const current = config.voice ?? EMPTY;
21004
- const [enabled, setEnabled] = (0, import_react16.useState)(current.enabled);
21005
- const [endpoint, setEndpoint] = (0, import_react16.useState)(current.endpoint);
21006
- const [apiKey, setApiKey] = (0, import_react16.useState)(current.apiKey ?? "");
21007
- const [sttModel, setSttModel] = (0, import_react16.useState)(current.sttModel);
21008
- const [ttsEndpoint, setTtsEndpoint] = (0, import_react16.useState)(current.ttsEndpoint ?? "");
21009
- const [ttsApiKey, setTtsApiKey] = (0, import_react16.useState)(current.ttsApiKey ?? "");
21010
- const [ttsModel, setTtsModel] = (0, import_react16.useState)(current.ttsModel ?? "");
21011
- const [ttsVoice, setTtsVoice] = (0, import_react16.useState)(current.ttsVoice ?? "");
21012
- const [ttsSpeed, setTtsSpeed] = (0, import_react16.useState)(
21644
+ const [enabled, setEnabled] = (0, import_react18.useState)(current.enabled);
21645
+ const [endpoint, setEndpoint] = (0, import_react18.useState)(current.endpoint);
21646
+ const [apiKey, setApiKey] = (0, import_react18.useState)(current.apiKey ?? "");
21647
+ const [sttModel, setSttModel] = (0, import_react18.useState)(current.sttModel);
21648
+ const [ttsEndpoint, setTtsEndpoint] = (0, import_react18.useState)(current.ttsEndpoint ?? "");
21649
+ const [ttsApiKey, setTtsApiKey] = (0, import_react18.useState)(current.ttsApiKey ?? "");
21650
+ const [ttsModel, setTtsModel] = (0, import_react18.useState)(current.ttsModel ?? "");
21651
+ const [ttsVoice, setTtsVoice] = (0, import_react18.useState)(current.ttsVoice ?? "");
21652
+ const [ttsSpeed, setTtsSpeed] = (0, import_react18.useState)(
21013
21653
  current.ttsSpeed === void 0 ? "" : String(current.ttsSpeed)
21014
21654
  );
21015
- const [lang, setLang] = (0, import_react16.useState)(current.lang ?? "");
21016
- const [fetching, setFetching] = (0, import_react16.useState)(false);
21017
- const [fetchingTts, setFetchingTts] = (0, import_react16.useState)(false);
21018
- const [saveState, setSaveState] = (0, import_react16.useState)("idle");
21019
- const pendingSave = (0, import_react16.useRef)(null);
21020
- const [autoStartBackend, setAutoStartBackend] = (0, import_react16.useState)(current.autoStartBackend ?? false);
21021
- const [backendStatuses, setBackendStatuses] = (0, import_react16.useState)(null);
21655
+ const [lang, setLang] = (0, import_react18.useState)(current.lang ?? "");
21656
+ const [bufferMs, setBufferMs] = (0, import_react18.useState)(
21657
+ current.playbackBufferMs === void 0 ? "" : String(current.playbackBufferMs)
21658
+ );
21659
+ const [ttsEngine, setTtsEngine] = (0, import_react18.useState)(current.ttsEngine ?? "endpoint");
21660
+ const [sttEngine, setSttEngine] = (0, import_react18.useState)(current.sttEngine ?? "endpoint");
21661
+ const [sttBuiltinModel, setSttBuiltinModel] = (0, import_react18.useState)(current.sttBuiltinModel ?? "base");
21662
+ const [ttsLanguage, setTtsLanguage] = (0, import_react18.useState)(current.ttsLanguage ?? "");
21663
+ const [pronEnabled, setPronEnabled] = (0, import_react18.useState)(current.pronunciationEnabled ?? false);
21664
+ const [pronunciation, setPronunciation] = (0, import_react18.useState)(
21665
+ current.pronunciation ?? {}
21666
+ );
21667
+ const [builtinStatus, setBuiltinStatus] = (0, import_react18.useState)(null);
21668
+ const [listening, setListening] = (0, import_react18.useState)(false);
21669
+ const [listenError, setListenError] = (0, import_react18.useState)(null);
21670
+ const listenAbort = (0, import_react18.useRef)(null);
21671
+ const [fetching, setFetching] = (0, import_react18.useState)(false);
21672
+ const [fetchingTts, setFetchingTts] = (0, import_react18.useState)(false);
21673
+ const [saveState, setSaveState] = (0, import_react18.useState)("idle");
21674
+ const pendingSave = (0, import_react18.useRef)(null);
21675
+ const [autoStartBackend, setAutoStartBackend] = (0, import_react18.useState)(current.autoStartBackend ?? false);
21676
+ const [backendStatuses, setBackendStatuses] = (0, import_react18.useState)(null);
21022
21677
  const fetchBackendStatuses = async () => {
21023
21678
  try {
21024
21679
  const res = await fetch("/api/voice/backend");
@@ -21028,7 +21683,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21028
21683
  } catch {
21029
21684
  }
21030
21685
  };
21031
- (0, import_react16.useEffect)(() => {
21686
+ (0, import_react18.useEffect)(() => {
21687
+ fetch("/api/voice/builtin").then((res) => res.ok ? res.json() : null).then((st2) => st2 && setBuiltinStatus(st2)).catch(() => {
21688
+ });
21689
+ return () => listenAbort.current?.abort();
21690
+ }, []);
21691
+ (0, import_react18.useEffect)(() => {
21032
21692
  fetchBackendStatuses();
21033
21693
  const interval = setInterval(fetchBackendStatuses, BACKEND_POLL_MS);
21034
21694
  return () => clearInterval(interval);
@@ -21038,23 +21698,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21038
21698
  (prev) => prev ? { ...prev, [target]: status } : { stt: status, tts: null }
21039
21699
  );
21040
21700
  };
21041
- (0, import_react16.useEffect)(() => {
21701
+ (0, import_react18.useEffect)(() => {
21042
21702
  if (sttCatalogResult) setFetching(false);
21043
21703
  }, [sttCatalogResult]);
21044
- (0, import_react16.useEffect)(() => {
21704
+ (0, import_react18.useEffect)(() => {
21045
21705
  if (ttsCatalogResult) setFetchingTts(false);
21046
21706
  }, [ttsCatalogResult]);
21047
- (0, import_react16.useEffect)(() => {
21707
+ (0, import_react18.useEffect)(() => {
21048
21708
  if (saveState !== "saving" || pendingSave.current === null) return;
21049
21709
  if (voiceSignature(config.voice) !== pendingSave.current) return;
21050
21710
  setSaveState("saved");
21051
21711
  }, [config.voice, saveState]);
21052
- (0, import_react16.useEffect)(() => {
21712
+ (0, import_react18.useEffect)(() => {
21053
21713
  if (saveState !== "saved") return;
21054
21714
  const clear = setTimeout(() => setSaveState("idle"), 2500);
21055
21715
  return () => clearTimeout(clear);
21056
21716
  }, [saveState]);
21057
- (0, import_react16.useEffect)(() => {
21717
+ (0, import_react18.useEffect)(() => {
21058
21718
  if (saveState !== "saving") return;
21059
21719
  const giveUp = setTimeout(() => setSaveState("idle"), 6e3);
21060
21720
  return () => clearTimeout(giveUp);
@@ -21083,46 +21743,113 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21083
21743
  });
21084
21744
  };
21085
21745
  const voicesForModel = ttsCatalog?.tts.find((m2) => m2.id === ttsModel.trim())?.voices ?? [];
21086
- const save = () => {
21087
- const voice = { enabled, endpoint: endpoint.trim(), sttModel: sttModel.trim() };
21088
- if (apiKey.trim()) voice.apiKey = apiKey.trim();
21089
- if (ttsEndpoint.trim()) voice.ttsEndpoint = ttsEndpoint.trim();
21090
- if (ttsApiKey.trim()) voice.ttsApiKey = ttsApiKey.trim();
21091
- if (ttsModel.trim()) voice.ttsModel = ttsModel.trim();
21746
+ const applyPreset = (p) => {
21747
+ if (p.enabled !== void 0) setEnabled(p.enabled);
21748
+ if (p.endpoint !== void 0) setEndpoint(p.endpoint);
21749
+ if (p.sttModel !== void 0) setSttModel(p.sttModel);
21750
+ if (p.sttEngine !== void 0) setSttEngine(p.sttEngine);
21751
+ if (p.sttBuiltinModel !== void 0) setSttBuiltinModel(p.sttBuiltinModel);
21752
+ if (p.ttsEngine !== void 0) setTtsEngine(p.ttsEngine);
21753
+ if (p.ttsLanguage !== void 0) setTtsLanguage(p.ttsLanguage);
21754
+ if (p.ttsEndpoint !== void 0) setTtsEndpoint(p.ttsEndpoint);
21755
+ if (p.ttsModel !== void 0) setTtsModel(p.ttsModel);
21756
+ if (p.ttsVoice !== void 0) setTtsVoice(p.ttsVoice);
21757
+ if (p.pronunciationEnabled !== void 0) setPronEnabled(p.pronunciationEnabled);
21758
+ };
21759
+ const builtin = ttsEngine === "builtin";
21760
+ const sttBuiltin = sttEngine === "builtin" && !!builtinStatus;
21761
+ const showEndpoint = !sttBuiltin || !builtin;
21762
+ const synthCode = (0, import_react18.useMemo)(() => {
21763
+ if (builtin) return builtinStatus?.languages.find((l) => l.id === ttsLanguage)?.code ?? null;
21764
+ return lang.trim().split(/[-_]/)[0].toLowerCase() || null;
21765
+ }, [builtin, builtinStatus, ttsLanguage, lang]);
21766
+ const pronEntries = synthCode ? pronunciation[synthCode] ?? builtinStatus?.defaults[synthCode] ?? [] : [];
21767
+ const stopListening = () => listenAbort.current?.abort();
21768
+ const listen = async (text) => {
21769
+ const code = synthCode ?? "en";
21770
+ const sample = text ? `${text}.` : SAMPLES[code] ?? SAMPLES.en;
21771
+ const speed = Number.parseFloat(ttsSpeed);
21772
+ const ac = new AbortController();
21773
+ listenAbort.current = ac;
21774
+ setListening(true);
21775
+ setListenError(null);
21776
+ try {
21777
+ const res = await fetch("/api/voice/preview", {
21778
+ method: "POST",
21779
+ headers: { "content-type": "application/json" },
21780
+ signal: ac.signal,
21781
+ body: JSON.stringify({
21782
+ text: sample,
21783
+ settings: {
21784
+ ttsEngine,
21785
+ ttsLanguage,
21786
+ ttsVoice: ttsVoice.trim(),
21787
+ ttsModel: ttsModel.trim(),
21788
+ ttsSpeed: Number.isFinite(speed) && speed > 0 ? speed : void 0,
21789
+ ttsEndpoint: ttsEndpoint.trim(),
21790
+ pronunciationEnabled: pronEnabled,
21791
+ pronunciation: synthCode ? pronEntries.filter((e) => e.term.trim()) : void 0
21792
+ }
21793
+ })
21794
+ });
21795
+ if (!res.ok) {
21796
+ setListenError(await res.text().catch(() => "") || `HTTP ${res.status}`);
21797
+ return;
21798
+ }
21799
+ await playSpeech(res, ac.signal, { bufferMs: parsedBufferMs(bufferMs) });
21800
+ } catch (err) {
21801
+ if (!ac.signal.aborted) setListenError(err instanceof Error ? err.message : String(err));
21802
+ } finally {
21803
+ setListening(false);
21804
+ }
21805
+ };
21806
+ const save = () => {
21807
+ const voice = { enabled, endpoint: endpoint.trim(), sttModel: sttModel.trim() };
21808
+ if (apiKey.trim()) voice.apiKey = apiKey.trim();
21809
+ if (ttsEndpoint.trim()) voice.ttsEndpoint = ttsEndpoint.trim();
21810
+ if (ttsApiKey.trim()) voice.ttsApiKey = ttsApiKey.trim();
21811
+ if (ttsModel.trim()) voice.ttsModel = ttsModel.trim();
21092
21812
  if (ttsVoice.trim()) voice.ttsVoice = ttsVoice.trim();
21093
21813
  const speed = Number.parseFloat(ttsSpeed);
21094
21814
  if (Number.isFinite(speed) && speed > 0) {
21095
21815
  voice.ttsSpeed = Math.min(Math.max(speed, 0.5), 2);
21096
21816
  }
21097
21817
  if (lang.trim()) voice.lang = lang.trim();
21818
+ const buf = parsedBufferMs(bufferMs);
21819
+ if (buf !== void 0) voice.playbackBufferMs = buf;
21098
21820
  if (autoStartBackend) voice.autoStartBackend = true;
21821
+ if (sttEngine === "builtin") {
21822
+ voice.sttEngine = "builtin";
21823
+ voice.sttBuiltinModel = sttBuiltinModel;
21824
+ }
21825
+ if (builtin) {
21826
+ voice.ttsEngine = "builtin";
21827
+ if (ttsLanguage) voice.ttsLanguage = ttsLanguage;
21828
+ }
21829
+ if (pronEnabled) voice.pronunciationEnabled = true;
21830
+ const dict = {};
21831
+ for (const [code, entries] of Object.entries(pronunciation)) {
21832
+ dict[code] = entries.filter((e) => e.term.trim());
21833
+ }
21834
+ if (Object.keys(dict).length) voice.pronunciation = dict;
21099
21835
  pendingSave.current = voiceSignature(voice);
21100
21836
  setSaveState("saving");
21101
21837
  onSave({ ...config, voice });
21102
21838
  };
21103
21839
  const showSttBackend = backendStatuses !== null && backendStatuses.stt.docker !== "absent" && backendStatuses.stt.port !== null;
21104
21840
  const showTtsBackend = backendStatuses !== null && backendStatuses.tts !== null && backendStatuses.tts.docker !== "absent" && backendStatuses.tts.port !== null;
21105
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "glass-form", children: [
21106
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h4", { children: "Voice" }),
21107
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "glass-form__body", children: [
21108
- !endpoint.trim() && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21109
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21110
- "button",
21111
- {
21112
- type: "button",
21113
- onClick: () => {
21114
- setEnabled(true);
21115
- setEndpoint(LOCAL_DEFAULTS.endpoint);
21116
- setSttModel(LOCAL_DEFAULTS.sttModel);
21117
- setTtsModel(LOCAL_DEFAULTS.ttsModel);
21118
- setTtsVoice(LOCAL_DEFAULTS.ttsVoice);
21119
- },
21120
- children: "Use local defaults"
21121
- }
21122
- ),
21123
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Fills the form for a fully local backend (a Speaches container on port 8969) that caretaker can run for you if Docker is installed. Nothing is saved yet \u2014 adjust anything, including the port in the endpoint, then press Save; a Start button appears below afterwards." })
21841
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "glass-form", children: [
21842
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h4", { children: "Voice" }),
21843
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "glass-form__body", children: [
21844
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21845
+ builtinStatus && !builtinStatus.runtime.loadError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: () => applyPreset(builtinPreset(lang, builtinStatus)), children: "Use built-in voice (recommended)" }),
21846
+ " ",
21847
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: () => applyPreset(localDefaultsPreset(lang, builtinStatus)), children: "Use local defaults" }),
21848
+ " ",
21849
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: () => applyPreset(edgePreset()), children: "Use Microsoft Edge voices" }),
21850
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Presets only fill the form. The built-in voice runs inside caretaker; local defaults add a Speaches container on port 8969 for transcription (caretaker can run it for you if Docker is installed); Edge voices use an openai-edge-tts container on port 5050. Nothing is saved yet \u2014 adjust anything, then press Save." })
21124
21851
  ] }),
21125
- showSttBackend && backendStatuses && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21852
+ showSttBackend && backendStatuses && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21126
21853
  VoiceBackendBlock,
21127
21854
  {
21128
21855
  target: "stt",
@@ -21132,7 +21859,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21132
21859
  hint: "The first start downloads about 2 GB. The container publishes on the port in your endpoint \u2014 if that port is taken, change it there and save; caretaker never picks a port for you. Delete removes the container but keeps the downloaded models \u2014 try it when the backend misbehaves after switching networks."
21133
21860
  }
21134
21861
  ),
21135
- showTtsBackend && backendStatuses?.tts && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21862
+ showTtsBackend && backendStatuses?.tts && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21136
21863
  VoiceBackendBlock,
21137
21864
  {
21138
21865
  target: "tts",
@@ -21142,9 +21869,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21142
21869
  hint: "A small image. The container publishes on the port in your synthesis endpoint. Delete removes the container; the image stays cached."
21143
21870
  }
21144
21871
  ),
21145
- (showSttBackend || showTtsBackend) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group form-group--checkbox", children: [
21146
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: "voice-backend-autostart", children: [
21147
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21872
+ (showSttBackend || showTtsBackend) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group form-group--checkbox", children: [
21873
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { htmlFor: "voice-backend-autostart", children: [
21874
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21148
21875
  "input",
21149
21876
  {
21150
21877
  id: "voice-backend-autostart",
@@ -21155,10 +21882,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21155
21882
  ),
21156
21883
  "Start automatically with caretaker"
21157
21884
  ] }),
21158
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Applies to both containers: a Speaches pull does not block the edge-tts start \u2014 they are independent." })
21885
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Applies to both containers: a Speaches pull does not block the edge-tts start \u2014 they are independent." })
21159
21886
  ] }),
21160
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "form-group form-group--checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: "voice-enabled", children: [
21161
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21887
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "form-group form-group--checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { htmlFor: "voice-enabled", children: [
21888
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21162
21889
  "input",
21163
21890
  {
21164
21891
  id: "voice-enabled",
@@ -21169,220 +21896,280 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21169
21896
  ),
21170
21897
  "Enable voice mode"
21171
21898
  ] }) }),
21172
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21173
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-endpoint", children: "Speech Endpoint" }),
21174
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21175
- "input",
21176
- {
21177
- id: "voice-endpoint",
21178
- type: "text",
21179
- placeholder: "http://127.0.0.1:8969/v1",
21180
- value: endpoint,
21181
- onChange: (e) => setEndpoint(e.target.value)
21182
- }
21183
- ),
21184
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21185
- "OpenAI-compatible speech endpoint \u2014 e.g. a local Speaches container. Transcription posts to ",
21186
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "/audio/transcriptions" }),
21187
- ". When no separate synthesis endpoint is set below, synthesis also posts to",
21188
- " ",
21189
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "/audio/speech" }),
21190
- " here. Voice is unavailable in the VSCode sidebar."
21191
- ] })
21192
- ] }),
21193
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21194
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-key", children: "API Key (optional)" }),
21195
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21196
- "input",
21197
- {
21198
- id: "voice-key",
21199
- type: "password",
21200
- placeholder: "Leave empty for a local server with no auth",
21201
- value: apiKey,
21202
- onChange: (e) => setApiKey(e.target.value)
21203
- }
21204
- ),
21205
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Stored encrypted. Never sent to the browser \u2014 requests are proxied." })
21206
- ] }),
21207
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21208
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", onClick: fetchSttCatalog, disabled: fetching || !endpoint.trim(), children: fetching ? "Fetching\u2026" : "Fetch models" }),
21209
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Reads the endpoint's installed models so the transcription field below becomes a list. Endpoints that do not report a task per model still work \u2014 the field stays free text." }),
21210
- sttFetchError && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { className: "form-error", children: [
21211
- "Fetch failed: ",
21212
- sttFetchError
21213
- ] })
21214
- ] }),
21215
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21216
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-stt", children: "Transcription Model" }),
21217
- sttCatalog && sttCatalog.stt.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
21899
+ builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21900
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-stt-engine", children: "Transcription engine" }),
21901
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
21218
21902
  "select",
21219
21903
  {
21220
- id: "voice-stt",
21221
- value: sttModel,
21222
- onChange: (e) => setSttModel(e.target.value),
21904
+ id: "voice-stt-engine",
21905
+ value: sttEngine,
21906
+ onChange: (e) => setSttEngine(e.target.value),
21223
21907
  children: [
21224
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "-- Select a model --" }),
21225
- withCurrent(sttCatalog.stt, sttModel).map((id) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: id, children: id }, id))
21908
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "endpoint", children: "Speech endpoint (Speaches, OpenAI\u2026)" }),
21909
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "builtin", children: "Built-in transcription (Whisper)" })
21226
21910
  ]
21227
21911
  }
21228
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21229
- "input",
21230
- {
21231
- id: "voice-stt",
21232
- type: "text",
21233
- placeholder: "e.g. Systran/faster-whisper-small",
21234
- value: sttModel,
21235
- onChange: (e) => setSttModel(e.target.value)
21236
- }
21237
21912
  )
21238
21913
  ] }),
21239
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21240
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-tts-endpoint", children: "Synthesis Endpoint (optional)" }),
21241
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21242
- "input",
21243
- {
21244
- id: "voice-tts-endpoint",
21245
- type: "text",
21246
- placeholder: "Leave empty when one server does both",
21247
- value: ttsEndpoint,
21248
- onChange: (e) => setTtsEndpoint(e.target.value)
21249
- }
21250
- ),
21251
- !ttsEndpoint.trim() && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21252
- "button",
21253
- {
21254
- type: "button",
21255
- onClick: () => {
21256
- setTtsEndpoint(EDGE_TTS_DEFAULTS.ttsEndpoint);
21257
- setTtsModel(EDGE_TTS_DEFAULTS.ttsModel);
21258
- setTtsVoice(EDGE_TTS_DEFAULTS.ttsVoice);
21259
- },
21260
- style: { marginTop: "0.4em" },
21261
- children: "Use Microsoft Edge voices"
21262
- }
21263
- ),
21264
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21265
- "Leave empty when one server does both. A local openai-edge-tts container gives you Microsoft Neural voices such as",
21266
- " ",
21267
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "it-IT-ElsaNeural" }),
21268
- " or ",
21269
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "it-IT-DiegoNeural" }),
21270
- ", but cannot transcribe \u2014 transcription always uses the endpoint above. Nothing is saved yet \u2014 press Save after adjusting."
21914
+ sttBuiltin && builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21915
+ BuiltinSttBlock,
21916
+ {
21917
+ status: builtinStatus,
21918
+ onStatusChange: setBuiltinStatus,
21919
+ model: sttBuiltinModel,
21920
+ onModelChange: setSttBuiltinModel
21921
+ }
21922
+ ),
21923
+ showEndpoint && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
21924
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21925
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-endpoint", children: "Speech Endpoint" }),
21926
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21927
+ "input",
21928
+ {
21929
+ id: "voice-endpoint",
21930
+ type: "text",
21931
+ placeholder: "http://127.0.0.1:8969/v1",
21932
+ value: endpoint,
21933
+ onChange: (e) => setEndpoint(e.target.value)
21934
+ }
21935
+ ),
21936
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { children: [
21937
+ "OpenAI-compatible speech endpoint \u2014 e.g. a local Speaches container. Transcription posts to ",
21938
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: "/audio/transcriptions" }),
21939
+ ". When no separate synthesis endpoint is set below, synthesis also posts to",
21940
+ " ",
21941
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: "/audio/speech" }),
21942
+ " here. Voice is unavailable in the VSCode sidebar."
21943
+ ] })
21944
+ ] }),
21945
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21946
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-key", children: "API Key (optional)" }),
21947
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21948
+ "input",
21949
+ {
21950
+ id: "voice-key",
21951
+ type: "password",
21952
+ placeholder: "Leave empty for a local server with no auth",
21953
+ value: apiKey,
21954
+ onChange: (e) => setApiKey(e.target.value)
21955
+ }
21956
+ ),
21957
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Stored encrypted. Never sent to the browser \u2014 requests are proxied." })
21271
21958
  ] })
21272
21959
  ] }),
21273
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21274
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-tts-key", children: "Synthesis API Key (optional)" }),
21275
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21276
- "input",
21277
- {
21278
- id: "voice-tts-key",
21279
- type: "password",
21280
- placeholder: "Leave empty for a local server with no auth",
21281
- value: ttsApiKey,
21282
- onChange: (e) => setTtsApiKey(e.target.value)
21283
- }
21284
- ),
21285
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Stored encrypted. Only sent to the synthesis endpoint \u2014 the transcription key is never sent there, and vice versa." })
21286
- ] }),
21287
- ttsEndpoint.trim() && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21288
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21289
- "button",
21290
- {
21291
- type: "button",
21292
- onClick: fetchTtsCatalog,
21293
- disabled: fetchingTts,
21294
- children: fetchingTts ? "Fetching\u2026" : "Fetch synthesis models"
21295
- }
21296
- ),
21297
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21298
- "Reads the synthesis endpoint's models and voices. For edge-tts, the voice list comes from ",
21299
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "/voices/all" }),
21300
- "."
21960
+ !sttBuiltin && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
21961
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21962
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: fetchSttCatalog, disabled: fetching || !endpoint.trim(), children: fetching ? "Fetching\u2026" : "Fetch models" }),
21963
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Reads the endpoint's installed models so the transcription field below becomes a list. Endpoints that do not report a task per model still work \u2014 the field stays free text." }),
21964
+ sttFetchError && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { className: "form-error", children: [
21965
+ "Fetch failed: ",
21966
+ sttFetchError
21967
+ ] })
21301
21968
  ] }),
21302
- ttsFetchError && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { className: "form-error", children: [
21303
- "Fetch failed: ",
21304
- ttsFetchError
21969
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21970
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-stt", children: "Transcription Model" }),
21971
+ sttCatalog && sttCatalog.stt.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
21972
+ "select",
21973
+ {
21974
+ id: "voice-stt",
21975
+ value: sttModel,
21976
+ onChange: (e) => setSttModel(e.target.value),
21977
+ children: [
21978
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "-- Select a model --" }),
21979
+ withCurrent(sttCatalog.stt, sttModel).map((id) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: id, children: id }, id))
21980
+ ]
21981
+ }
21982
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21983
+ "input",
21984
+ {
21985
+ id: "voice-stt",
21986
+ type: "text",
21987
+ placeholder: "e.g. Systran/faster-whisper-small",
21988
+ value: sttModel,
21989
+ onChange: (e) => setSttModel(e.target.value)
21990
+ }
21991
+ )
21305
21992
  ] })
21306
21993
  ] }),
21307
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21308
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-tts", children: "Synthesis Model (optional)" }),
21309
- ttsCatalog && ttsCatalog.tts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
21994
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
21995
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-engine", children: "Synthesis engine" }),
21996
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
21310
21997
  "select",
21311
21998
  {
21312
- id: "voice-tts",
21313
- value: ttsModel,
21314
- onChange: (e) => {
21315
- setTtsModel(e.target.value);
21316
- const next = ttsCatalog.tts.find((m2) => m2.id === e.target.value);
21317
- if (next && !next.voices.some((v2) => v2.id === ttsVoice)) {
21318
- setTtsVoice(next.voices.length === 1 ? next.voices[0].id : "");
21319
- }
21320
- },
21999
+ id: "voice-engine",
22000
+ value: ttsEngine,
22001
+ onChange: (e) => setTtsEngine(e.target.value),
21321
22002
  children: [
21322
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "-- None (dictation only) --" }),
21323
- withCurrent(
21324
- ttsCatalog.tts.map((m2) => m2.id),
21325
- ttsModel
21326
- ).map((id) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: id, children: id }, id))
22003
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "endpoint", children: "Speech endpoint (Speaches, edge-tts, OpenAI\u2026)" }),
22004
+ builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "builtin", children: "Built-in voice" })
21327
22005
  ]
21328
22006
  }
21329
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21330
- "input",
21331
- {
21332
- id: "voice-tts",
21333
- type: "text",
21334
- placeholder: "e.g. speaches-ai/Kokoro-82M-v1.0-ONNX or tts-1",
21335
- value: ttsModel,
21336
- onChange: (e) => setTtsModel(e.target.value)
21337
- }
21338
- ),
21339
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Required for conversation mode. Without it, only dictation is offered." })
22007
+ )
21340
22008
  ] }),
21341
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21342
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-voice", children: "Voice (optional)" }),
21343
- voicesForModel.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
21344
- "select",
21345
- {
21346
- id: "voice-voice",
21347
- value: ttsVoice,
21348
- onChange: (e) => setTtsVoice(e.target.value),
21349
- children: [
21350
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: "-- Select a voice --" }),
21351
- voicesForModel.map((v2) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: v2.id, children: voiceLabel(v2) }, v2.id))
21352
- ]
21353
- }
21354
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21355
- "input",
21356
- {
21357
- id: "voice-voice",
21358
- type: "text",
21359
- placeholder: "e.g. af_heart or it-IT-ElsaNeural",
21360
- value: ttsVoice,
21361
- onChange: (e) => setTtsVoice(e.target.value)
21362
- }
21363
- ),
21364
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Pick one whose language matches yours. A model trained mostly on English keeps an English inflection even on its other-language voices." })
22009
+ builtin && builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22010
+ BuiltinVoiceBlock,
22011
+ {
22012
+ status: builtinStatus,
22013
+ onStatusChange: setBuiltinStatus,
22014
+ language: ttsLanguage,
22015
+ onLanguageChange: setTtsLanguage,
22016
+ voice: ttsVoice,
22017
+ onVoiceChange: setTtsVoice
22018
+ }
22019
+ ),
22020
+ !builtin && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
22021
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22022
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-tts-endpoint", children: "Synthesis Endpoint (optional)" }),
22023
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22024
+ "input",
22025
+ {
22026
+ id: "voice-tts-endpoint",
22027
+ type: "text",
22028
+ placeholder: "Leave empty when one server does both",
22029
+ value: ttsEndpoint,
22030
+ onChange: (e) => setTtsEndpoint(e.target.value)
22031
+ }
22032
+ ),
22033
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { children: [
22034
+ "Leave empty when one server does both. A local openai-edge-tts container gives you Microsoft Neural voices such as",
22035
+ " ",
22036
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: "it-IT-ElsaNeural" }),
22037
+ " or ",
22038
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: "it-IT-DiegoNeural" }),
22039
+ ", but cannot transcribe \u2014 transcription always uses the endpoint above. Nothing is saved yet \u2014 press Save after adjusting."
22040
+ ] })
22041
+ ] }),
22042
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22043
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-tts-key", children: "Synthesis API Key (optional)" }),
22044
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22045
+ "input",
22046
+ {
22047
+ id: "voice-tts-key",
22048
+ type: "password",
22049
+ placeholder: "Leave empty for a local server with no auth",
22050
+ value: ttsApiKey,
22051
+ onChange: (e) => setTtsApiKey(e.target.value)
22052
+ }
22053
+ ),
22054
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Stored encrypted. Only sent to the synthesis endpoint \u2014 the transcription key is never sent there, and vice versa." })
22055
+ ] }),
22056
+ ttsEndpoint.trim() && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22057
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22058
+ "button",
22059
+ {
22060
+ type: "button",
22061
+ onClick: fetchTtsCatalog,
22062
+ disabled: fetchingTts,
22063
+ children: fetchingTts ? "Fetching\u2026" : "Fetch synthesis models"
22064
+ }
22065
+ ),
22066
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { children: [
22067
+ "Reads the synthesis endpoint's models and voices. For edge-tts, the voice list comes from ",
22068
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { children: "/voices/all" }),
22069
+ "."
22070
+ ] }),
22071
+ ttsFetchError && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { className: "form-error", children: [
22072
+ "Fetch failed: ",
22073
+ ttsFetchError
22074
+ ] })
22075
+ ] }),
22076
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22077
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-tts", children: "Synthesis Model (optional)" }),
22078
+ ttsCatalog && ttsCatalog.tts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
22079
+ "select",
22080
+ {
22081
+ id: "voice-tts",
22082
+ value: ttsModel,
22083
+ onChange: (e) => {
22084
+ setTtsModel(e.target.value);
22085
+ const next = ttsCatalog.tts.find((m2) => m2.id === e.target.value);
22086
+ if (next && !next.voices.some((v2) => v2.id === ttsVoice)) {
22087
+ setTtsVoice(next.voices.length === 1 ? next.voices[0].id : "");
22088
+ }
22089
+ },
22090
+ children: [
22091
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "-- None (dictation only) --" }),
22092
+ withCurrent(
22093
+ ttsCatalog.tts.map((m2) => m2.id),
22094
+ ttsModel
22095
+ ).map((id) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: id, children: id }, id))
22096
+ ]
22097
+ }
22098
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22099
+ "input",
22100
+ {
22101
+ id: "voice-tts",
22102
+ type: "text",
22103
+ placeholder: "e.g. speaches-ai/Kokoro-82M-v1.0-ONNX or tts-1",
22104
+ value: ttsModel,
22105
+ onChange: (e) => setTtsModel(e.target.value)
22106
+ }
22107
+ ),
22108
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Required for conversation mode. Without it, only dictation is offered." })
22109
+ ] }),
22110
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22111
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-voice", children: "Voice (optional)" }),
22112
+ voicesForModel.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
22113
+ "select",
22114
+ {
22115
+ id: "voice-voice",
22116
+ value: ttsVoice,
22117
+ onChange: (e) => setTtsVoice(e.target.value),
22118
+ children: [
22119
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "-- Select a voice --" }),
22120
+ voicesForModel.map((v2) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: v2.id, children: voiceLabel(v2) }, v2.id))
22121
+ ]
22122
+ }
22123
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22124
+ "input",
22125
+ {
22126
+ id: "voice-voice",
22127
+ type: "text",
22128
+ placeholder: "e.g. af_heart or it-IT-ElsaNeural",
22129
+ value: ttsVoice,
22130
+ onChange: (e) => setTtsVoice(e.target.value)
22131
+ }
22132
+ ),
22133
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Pick one whose language matches yours. A model trained mostly on English keeps an English inflection even on its other-language voices." })
22134
+ ] }),
22135
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22136
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-speed", children: "Speaking Rate (optional)" }),
22137
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22138
+ "input",
22139
+ {
22140
+ id: "voice-speed",
22141
+ type: "number",
22142
+ min: "0.5",
22143
+ max: "2",
22144
+ step: "0.05",
22145
+ placeholder: "1 \u2014 the model's natural pace",
22146
+ value: ttsSpeed,
22147
+ onChange: (e) => setTtsSpeed(e.target.value)
22148
+ }
22149
+ ),
22150
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Multiplier, clamped to 0.5\u20132. Useful because some voices are just slow: raise it if the reply drags. Piper responds less to this than Kokoro, since for Piper it stretches phoneme durations." })
22151
+ ] })
21365
22152
  ] }),
21366
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21367
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-speed", children: "Speaking Rate (optional)" }),
21368
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
22153
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22154
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-buffer", children: "Playback buffer, ms (optional)" }),
22155
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21369
22156
  "input",
21370
22157
  {
21371
- id: "voice-speed",
22158
+ id: "voice-buffer",
21372
22159
  type: "number",
21373
- min: "0.5",
21374
- max: "2",
21375
- step: "0.05",
21376
- placeholder: "1 \u2014 the model's natural pace",
21377
- value: ttsSpeed,
21378
- onChange: (e) => setTtsSpeed(e.target.value)
22160
+ min: "0",
22161
+ max: MAX_PLAYBACK_BUFFER_MS,
22162
+ step: "100",
22163
+ placeholder: `${DEFAULT_PLAYBACK_BUFFER_MS} \u2014 default`,
22164
+ value: bufferMs,
22165
+ onChange: (e) => setBufferMs(e.target.value)
21379
22166
  }
21380
22167
  ),
21381
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Multiplier, clamped to 0.5\u20132. Useful because some voices are just slow: raise it if the reply drags. Piper responds less to this than Kokoro, since for Piper it stretches phoneme durations." })
22168
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Audio collected before speech starts, and again if it runs dry. Raise it if speech stutters (a slower machine or endpoint); lower it for a quicker start. Listen uses the value in the form, so you can try it before saving." })
21382
22169
  ] }),
21383
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21384
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-lang", children: "Language (optional)" }),
21385
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
22170
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22171
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "voice-lang", children: "Language (optional)" }),
22172
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21386
22173
  "input",
21387
22174
  {
21388
22175
  id: "voice-lang",
@@ -21392,17 +22179,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21392
22179
  onChange: (e) => setLang(e.target.value)
21393
22180
  }
21394
22181
  )
22182
+ ] }),
22183
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
22184
+ PronunciationTable,
22185
+ {
22186
+ code: synthCode,
22187
+ entries: pronEntries,
22188
+ enabled: pronEnabled,
22189
+ onEnabledChange: setPronEnabled,
22190
+ onChange: (entries) => synthCode && setPronunciation((p) => ({ ...p, [synthCode]: entries })),
22191
+ onRestoreDefaults: () => synthCode && setPronunciation((p) => {
22192
+ const { [synthCode]: _drop, ...rest } = p;
22193
+ return rest;
22194
+ }),
22195
+ onListen: (t) => void listen(t),
22196
+ listening,
22197
+ listenError
22198
+ }
22199
+ ),
22200
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22201
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: listening ? stopListening : () => void listen(), children: listening ? "Stop" : "Listen" }),
22202
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "Speaks a sample sentence with the form as it is now, without saving." })
21395
22203
  ] })
21396
22204
  ] }),
21397
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-actions", children: [
21398
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", onClick: save, children: "Save" }),
21399
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
22205
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-actions", children: [
22206
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: save, children: "Save" }),
22207
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
21400
22208
  ] })
21401
22209
  ] });
21402
22210
  }
21403
22211
 
21404
22212
  // src/MemoryTab.tsx
21405
- var import_react17 = __toESM(require_react(), 1);
22213
+ var import_react19 = __toESM(require_react(), 1);
21406
22214
 
21407
22215
  // src/memory_tab_utils.ts
21408
22216
  function buildMemoryConfig(form) {
@@ -21421,26 +22229,26 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21421
22229
  }
21422
22230
 
21423
22231
  // src/MemoryTab.tsx
21424
- var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
22232
+ var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
21425
22233
  function MemoryTab({ config, agents, onSave }) {
21426
22234
  const current = config.memory;
21427
- const [enabled, setEnabled] = (0, import_react17.useState)(!!current);
21428
- const [agentId, setAgentId] = (0, import_react17.useState)(current?.agentId ?? "");
21429
- const [sweepMinutes, setSweepMinutes] = (0, import_react17.useState)(
22235
+ const [enabled, setEnabled] = (0, import_react19.useState)(!!current);
22236
+ const [agentId, setAgentId] = (0, import_react19.useState)(current?.agentId ?? "");
22237
+ const [sweepMinutes, setSweepMinutes] = (0, import_react19.useState)(
21430
22238
  current?.sweepMinutes === void 0 ? "" : String(current.sweepMinutes)
21431
22239
  );
21432
- const [minNewMessages, setMinNewMessages] = (0, import_react17.useState)(
22240
+ const [minNewMessages, setMinNewMessages] = (0, import_react19.useState)(
21433
22241
  current?.minNewMessages === void 0 ? "" : String(current.minNewMessages)
21434
22242
  );
21435
- const [saveState, setSaveState] = (0, import_react17.useState)("idle");
21436
- const pendingSave = (0, import_react17.useRef)(null);
21437
- (0, import_react17.useEffect)(() => {
22243
+ const [saveState, setSaveState] = (0, import_react19.useState)("idle");
22244
+ const pendingSave = (0, import_react19.useRef)(null);
22245
+ (0, import_react19.useEffect)(() => {
21438
22246
  if (saveState !== "saving" || pendingSave.current === null) return;
21439
22247
  if (memorySignature(config.memory) !== pendingSave.current)
21440
22248
  return;
21441
22249
  setSaveState("saved");
21442
22250
  }, [config.memory, saveState]);
21443
- (0, import_react17.useEffect)(() => {
22251
+ (0, import_react19.useEffect)(() => {
21444
22252
  if (saveState !== "saved") return;
21445
22253
  const t = setTimeout(() => setSaveState("idle"), 2e3);
21446
22254
  return () => clearTimeout(t);
@@ -21456,12 +22264,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21456
22264
  else delete next.memory;
21457
22265
  onSave(next);
21458
22266
  };
21459
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "glass-form", children: [
21460
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h4", { children: "Memory" }),
21461
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "glass-form__body", children: [
21462
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group form-group--checkbox", children: [
21463
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { htmlFor: "memory-enabled", children: [
21464
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
22267
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "glass-form", children: [
22268
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { children: "Memory" }),
22269
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "glass-form__body", children: [
22270
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group form-group--checkbox", children: [
22271
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { htmlFor: "memory-enabled", children: [
22272
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
21465
22273
  "input",
21466
22274
  {
21467
22275
  id: "memory-enabled",
@@ -21472,25 +22280,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21472
22280
  ),
21473
22281
  "Enable memory"
21474
22282
  ] }),
21475
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: "A background sweep keeps a rolling summary of every chat session. It runs only while the web server (or the desktop app) is up, like the rest of the scheduler." })
22283
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: "A background sweep keeps a rolling summary of every chat session. It runs only while the web server (or the desktop app) is up, like the rest of the scheduler." })
21476
22284
  ] }),
21477
- enabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
21478
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group", children: [
21479
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: "memory-agent", children: "Memory agent" }),
21480
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("select", { id: "memory-agent", value: agentId, onChange: (e) => setAgentId(e.target.value), children: [
21481
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "\u2014 select an agent \u2014" }),
21482
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("option", { value: a2.id, children: [
22285
+ enabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
22286
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group", children: [
22287
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: "memory-agent", children: "Memory agent" }),
22288
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("select", { id: "memory-agent", value: agentId, onChange: (e) => setAgentId(e.target.value), children: [
22289
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "\u2014 select an agent \u2014" }),
22290
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
21483
22291
  a2.name,
21484
22292
  " \xB7 ",
21485
22293
  a2.model
21486
22294
  ] }, a2.id))
21487
22295
  ] }),
21488
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: "The agent whose identity (system prompt, provider, model) runs the summarize calls \u2014 every provider works, Claude Code included. Calls are always fresh one-shot conversations, never the agent's own sessions. A lean dedicated agent (short system prompt, no plugins) keeps them cheap." }),
21489
- missingAgent && agentId && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { className: "form-error", children: "This agent no longer exists \u2014 pick another." })
22296
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: "The agent whose identity (system prompt, provider, model) runs the summarize calls \u2014 every provider works, Claude Code included. Calls are always fresh one-shot conversations, never the agent's own sessions. A lean dedicated agent (short system prompt, no plugins) keeps them cheap." }),
22297
+ missingAgent && agentId && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { className: "form-error", children: "This agent no longer exists \u2014 pick another." })
21490
22298
  ] }),
21491
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group", children: [
21492
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: "memory-sweep-minutes", children: "Sweep interval (minutes)" }),
21493
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
22299
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group", children: [
22300
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: "memory-sweep-minutes", children: "Sweep interval (minutes)" }),
22301
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
21494
22302
  "input",
21495
22303
  {
21496
22304
  id: "memory-sweep-minutes",
@@ -21502,9 +22310,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21502
22310
  }
21503
22311
  )
21504
22312
  ] }),
21505
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group", children: [
21506
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: "memory-min-new", children: "Min new messages per session" }),
21507
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
22313
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group", children: [
22314
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: "memory-min-new", children: "Min new messages per session" }),
22315
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
21508
22316
  "input",
21509
22317
  {
21510
22318
  id: "memory-min-new",
@@ -21515,19 +22323,131 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21515
22323
  onChange: (e) => setMinNewMessages(e.target.value)
21516
22324
  }
21517
22325
  ),
21518
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: "A session is re-summarized only once it accumulated at least this many new messages since the last pass." })
22326
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: "A session is re-summarized only once it accumulated at least this many new messages since the last pass." })
21519
22327
  ] })
21520
22328
  ] })
21521
22329
  ] }),
21522
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-actions", children: [
21523
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: save, disabled: enabled && !agentId, children: "Save" }),
21524
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
22330
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-actions", children: [
22331
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: save, disabled: enabled && !agentId, children: "Save" }),
22332
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
22333
+ ] })
22334
+ ] });
22335
+ }
22336
+
22337
+ // src/DesktopTab.tsx
22338
+ var import_react20 = __toESM(require_react(), 1);
22339
+
22340
+ // src/desktop_tab_utils.ts
22341
+ var DEFAULT_ASSISTANT_SHORTCUT = "CommandOrControl+Shift+Space";
22342
+ function buildDesktopAssistantConfig(form) {
22343
+ const agentId = form.agentId.trim();
22344
+ if (!form.enabled || !agentId) return void 0;
22345
+ return { agentId, shortcut: form.shortcut.trim() || DEFAULT_ASSISTANT_SHORTCUT };
22346
+ }
22347
+ function desktopAssistantSignature(c2) {
22348
+ if (!c2) return "";
22349
+ return JSON.stringify([c2.agentId ?? "", c2.shortcut ?? ""]);
22350
+ }
22351
+
22352
+ // src/DesktopTab.tsx
22353
+ var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
22354
+ function DesktopTab({ config, agents, onSave }) {
22355
+ const current = config.desktopAssistant;
22356
+ const [enabled, setEnabled] = (0, import_react20.useState)(!!current);
22357
+ const [agentId, setAgentId] = (0, import_react20.useState)(current?.agentId ?? "");
22358
+ const [shortcut, setShortcut] = (0, import_react20.useState)(current?.shortcut ?? "");
22359
+ const [saveState, setSaveState] = (0, import_react20.useState)("idle");
22360
+ const pendingSave = (0, import_react20.useRef)(null);
22361
+ (0, import_react20.useEffect)(() => {
22362
+ if (saveState !== "saving" || pendingSave.current === null) return;
22363
+ if (desktopAssistantSignature(config.desktopAssistant) !== pendingSave.current)
22364
+ return;
22365
+ setSaveState("saved");
22366
+ }, [config.desktopAssistant, saveState]);
22367
+ (0, import_react20.useEffect)(() => {
22368
+ if (saveState !== "saved") return;
22369
+ const t = setTimeout(() => setSaveState("idle"), 2e3);
22370
+ return () => clearTimeout(t);
22371
+ }, [saveState]);
22372
+ const missingAgent = enabled && !!agentId && !agents.some((a2) => a2.id === agentId);
22373
+ const save = () => {
22374
+ const cfg = buildDesktopAssistantConfig({ enabled, agentId, shortcut });
22375
+ pendingSave.current = desktopAssistantSignature(cfg);
22376
+ setSaveState("saving");
22377
+ const next = { ...config };
22378
+ if (cfg) next.desktopAssistant = cfg;
22379
+ else delete next.desktopAssistant;
22380
+ onSave(next);
22381
+ };
22382
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "glass-form", children: [
22383
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h4", { children: "Desktop assistant" }),
22384
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "glass-form__body", children: [
22385
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "form-group form-group--checkbox", children: [
22386
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { htmlFor: "desktop-assistant-enabled", children: [
22387
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
22388
+ "input",
22389
+ {
22390
+ id: "desktop-assistant-enabled",
22391
+ type: "checkbox",
22392
+ checked: enabled,
22393
+ onChange: (e) => setEnabled(e.target.checked)
22394
+ }
22395
+ ),
22396
+ "Enable desktop assistant"
22397
+ ] }),
22398
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: "Desktop app only. Press the shortcut from any app to open caretaker on a new conversation with this agent \u2014 in voice conversation mode when voice is configured." })
22399
+ ] }),
22400
+ enabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
22401
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "form-group", children: [
22402
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { htmlFor: "desktop-assistant-agent", children: "Assistant agent" }),
22403
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
22404
+ "select",
22405
+ {
22406
+ id: "desktop-assistant-agent",
22407
+ value: agentId,
22408
+ onChange: (e) => setAgentId(e.target.value),
22409
+ children: [
22410
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "\u2014 select an agent \u2014" }),
22411
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("option", { value: a2.id, children: [
22412
+ a2.name,
22413
+ " \xB7 ",
22414
+ a2.model
22415
+ ] }, a2.id))
22416
+ ]
22417
+ }
22418
+ ),
22419
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: "To let it move the conversation into one of your projects, enable the set_workspace tool on the agent. That needs a native agent: Claude Code and ACP agents have no caretaker tools." }),
22420
+ missingAgent && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { className: "form-error", children: "This agent no longer exists \u2014 pick another." })
22421
+ ] }),
22422
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "form-group", children: [
22423
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { htmlFor: "desktop-assistant-shortcut", children: "Global shortcut" }),
22424
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
22425
+ "input",
22426
+ {
22427
+ id: "desktop-assistant-shortcut",
22428
+ type: "text",
22429
+ placeholder: DEFAULT_ASSISTANT_SHORTCUT,
22430
+ value: shortcut,
22431
+ onChange: (e) => setShortcut(e.target.value)
22432
+ }
22433
+ ),
22434
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("small", { children: [
22435
+ "An Electron accelerator. On Linux under Wayland the global shortcut does not fire: bind this command to a keyboard shortcut in your desktop environment instead \u2014",
22436
+ " ",
22437
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("code", { children: "caretaker-desktop --assistant" })
22438
+ ] })
22439
+ ] })
22440
+ ] })
22441
+ ] }),
22442
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "form-actions", children: [
22443
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: save, disabled: enabled && !agentId, children: "Save" }),
22444
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
21525
22445
  ] })
21526
22446
  ] });
21527
22447
  }
21528
22448
 
21529
22449
  // src/SettingsPanel.tsx
21530
- var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
22450
+ var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
21531
22451
  function SettingsPanel({
21532
22452
  layout = "compact",
21533
22453
  postMessage,
@@ -21548,16 +22468,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21548
22468
  onClose,
21549
22469
  initialTab = "providers"
21550
22470
  }) {
21551
- const [activeTab, setActiveTab] = (0, import_react18.useState)(initialTab);
22471
+ const [activeTab, setActiveTab] = (0, import_react21.useState)(initialTab);
21552
22472
  if (!settingsData) {
21553
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "settings-panel settings-panel--loading", children: [
21554
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, children: [
21555
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArrowLeft, { size: 14 }),
22473
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "settings-panel settings-panel--loading", children: [
22474
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, children: [
22475
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArrowLeft, { size: 14 }),
21556
22476
  " Back to Chat"
21557
22477
  ] }),
21558
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "settings-panel__loading-spinner", children: [
21559
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "spinner" }),
21560
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "Loading configurations..." })
22478
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "settings-panel__loading-spinner", children: [
22479
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "spinner" }),
22480
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "Loading configurations..." })
21561
22481
  ] })
21562
22482
  ] });
21563
22483
  }
@@ -21565,7 +22485,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21565
22485
  const renderTabContent = () => {
21566
22486
  switch (activeTab) {
21567
22487
  case "providers":
21568
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22488
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21569
22489
  ProvidersTab,
21570
22490
  {
21571
22491
  config,
@@ -21577,7 +22497,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21577
22497
  }
21578
22498
  );
21579
22499
  case "projects":
21580
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22500
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21581
22501
  ProjectsTabSettings,
21582
22502
  {
21583
22503
  config,
@@ -21586,7 +22506,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21586
22506
  }
21587
22507
  );
21588
22508
  case "agents":
21589
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22509
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21590
22510
  AgentsTab,
21591
22511
  {
21592
22512
  config,
@@ -21600,7 +22520,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21600
22520
  }
21601
22521
  );
21602
22522
  case "plugins":
21603
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22523
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21604
22524
  PluginsTab,
21605
22525
  {
21606
22526
  pluginsFile,
@@ -21611,7 +22531,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21611
22531
  }
21612
22532
  );
21613
22533
  case "mcp":
21614
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22534
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21615
22535
  McpTab,
21616
22536
  {
21617
22537
  mcpServersFile,
@@ -21621,7 +22541,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21621
22541
  }
21622
22542
  );
21623
22543
  case "services":
21624
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22544
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21625
22545
  ServicesTab,
21626
22546
  {
21627
22547
  config,
@@ -21631,7 +22551,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21631
22551
  }
21632
22552
  );
21633
22553
  case "voice":
21634
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22554
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21635
22555
  VoiceTab,
21636
22556
  {
21637
22557
  config,
@@ -21642,7 +22562,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21642
22562
  }
21643
22563
  );
21644
22564
  case "memory":
21645
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22565
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21646
22566
  MemoryTab,
21647
22567
  {
21648
22568
  config,
@@ -21650,18 +22570,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21650
22570
  onSave: (updatedConfig) => postMessage({ type: "saveConfig", config: updatedConfig })
21651
22571
  }
21652
22572
  );
22573
+ case "desktop":
22574
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
22575
+ DesktopTab,
22576
+ {
22577
+ config,
22578
+ agents,
22579
+ onSave: (updatedConfig) => postMessage({ type: "saveConfig", config: updatedConfig })
22580
+ }
22581
+ );
21653
22582
  }
21654
22583
  };
21655
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "settings-panel", children: [
21656
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("header", { className: "settings-panel__header", children: [
21657
- layout !== "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, title: "Go back to chat", children: [
21658
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArrowLeft, { size: 14 }),
22584
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "settings-panel", children: [
22585
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { className: "settings-panel__header", children: [
22586
+ layout !== "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, title: "Go back to chat", children: [
22587
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArrowLeft, { size: 14 }),
21659
22588
  " Chat"
21660
22589
  ] }),
21661
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: "settings-panel__title", children: "Caretaker Config" })
22590
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { className: "settings-panel__title", children: "Caretaker Config" })
21662
22591
  ] }),
21663
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("nav", { className: "settings-panel__tabs", children: [
21664
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22592
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("nav", { className: "settings-panel__tabs", children: [
22593
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21665
22594
  "button",
21666
22595
  {
21667
22596
  className: `settings-panel__tab-btn ${activeTab === "providers" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21669,7 +22598,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21669
22598
  children: "Providers"
21670
22599
  }
21671
22600
  ),
21672
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22601
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21673
22602
  "button",
21674
22603
  {
21675
22604
  className: `settings-panel__tab-btn ${activeTab === "projects" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21677,7 +22606,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21677
22606
  children: "Projects"
21678
22607
  }
21679
22608
  ),
21680
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22609
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21681
22610
  "button",
21682
22611
  {
21683
22612
  className: `settings-panel__tab-btn ${activeTab === "agents" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21685,7 +22614,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21685
22614
  children: "Agents"
21686
22615
  }
21687
22616
  ),
21688
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22617
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21689
22618
  "button",
21690
22619
  {
21691
22620
  className: `settings-panel__tab-btn ${activeTab === "plugins" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21693,7 +22622,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21693
22622
  children: "Plugins"
21694
22623
  }
21695
22624
  ),
21696
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22625
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21697
22626
  "button",
21698
22627
  {
21699
22628
  className: `settings-panel__tab-btn ${activeTab === "mcp" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21701,7 +22630,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21701
22630
  children: "MCP"
21702
22631
  }
21703
22632
  ),
21704
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22633
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21705
22634
  "button",
21706
22635
  {
21707
22636
  className: `settings-panel__tab-btn ${activeTab === "services" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21709,7 +22638,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21709
22638
  children: "Services"
21710
22639
  }
21711
22640
  ),
21712
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22641
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21713
22642
  "button",
21714
22643
  {
21715
22644
  className: `settings-panel__tab-btn ${activeTab === "voice" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21717,24 +22646,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21717
22646
  children: "Voice"
21718
22647
  }
21719
22648
  ),
21720
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22649
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
21721
22650
  "button",
21722
22651
  {
21723
22652
  className: `settings-panel__tab-btn ${activeTab === "memory" ? "settings-panel__tab-btn--active" : ""}`,
21724
22653
  onClick: () => setActiveTab("memory"),
21725
22654
  children: "Memory"
21726
22655
  }
22656
+ ),
22657
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
22658
+ "button",
22659
+ {
22660
+ className: `settings-panel__tab-btn ${activeTab === "desktop" ? "settings-panel__tab-btn--active" : ""}`,
22661
+ onClick: () => setActiveTab("desktop"),
22662
+ children: "Desktop"
22663
+ }
21727
22664
  )
21728
22665
  ] }),
21729
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("main", { className: "settings-panel__content", children: renderTabContent() })
22666
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("main", { className: "settings-panel__content", children: renderTabContent() })
21730
22667
  ] });
21731
22668
  }
21732
22669
 
21733
22670
  // src/ProjectsTab.tsx
21734
- var import_react20 = __toESM(require_react(), 1);
22671
+ var import_react23 = __toESM(require_react(), 1);
21735
22672
 
21736
22673
  // src/TaskCycleView.tsx
21737
- var import_react19 = __toESM(require_react(), 1);
22674
+ var import_react22 = __toESM(require_react(), 1);
21738
22675
 
21739
22676
  // src/chat_state.ts
21740
22677
  function closeStreamingAssistant2(items) {
@@ -21910,13 +22847,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21910
22847
  };
21911
22848
 
21912
22849
  // src/TaskCycleView.tsx
21913
- var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
22850
+ var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
21914
22851
  function TaskCycleView({ item, postMessage, onBack }) {
21915
- const [chat, dispatch] = (0, import_react19.useReducer)(chatReducer, initialChatState);
22852
+ const [chat, dispatch] = (0, import_react22.useReducer)(chatReducer, initialChatState);
21916
22853
  const { sessionId, agentId } = item;
21917
- const postRef = (0, import_react19.useRef)(postMessage);
22854
+ const postRef = (0, import_react22.useRef)(postMessage);
21918
22855
  postRef.current = postMessage;
21919
- (0, import_react19.useEffect)(() => {
22856
+ (0, import_react22.useEffect)(() => {
21920
22857
  function handle(event) {
21921
22858
  const msg = event.data;
21922
22859
  if (!msg || typeof msg !== "object" || !("type" in msg) || !("sessionId" in msg)) return;
@@ -21957,25 +22894,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21957
22894
  };
21958
22895
  }, [sessionId, agentId]);
21959
22896
  const running = chat.status === "streaming";
21960
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
21961
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "10px 14px" }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
21962
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to the task thread", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ArrowLeft, { size: 13 }) }),
21963
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "app__chat-header-info", children: [
21964
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
22897
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
22898
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "10px 14px" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
22899
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to the task thread", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArrowLeft, { size: 13 }) }),
22900
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app__chat-header-info", children: [
22901
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
21965
22902
  cycleRoleLabel(item.role),
21966
22903
  " cycle",
21967
22904
  item.label ? ` \xB7 ${item.label}` : ""
21968
22905
  ] }),
21969
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: running ? "running" : cycleOutcomeLabel(item.outcome) })
22906
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: running ? "running" : cycleOutcomeLabel(item.outcome) })
21970
22907
  ] })
21971
22908
  ] }) }),
21972
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageList, { items: chat.items, sessionId: null, isStreaming: running, agentName: item.label }),
21973
- chat.errorText && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "notice notice--block", children: chat.errorText })
22909
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MessageList, { items: chat.items, sessionId: null, isStreaming: running, agentName: item.label }),
22910
+ chat.errorText && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "notice notice--block", children: chat.errorText })
21974
22911
  ] });
21975
22912
  }
21976
22913
 
21977
22914
  // src/ProjectsTab.tsx
21978
- var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
22915
+ var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
21979
22916
  var LS_ARCHIVED_KEY = "caretaker.taskView.showArchived";
21980
22917
  function persistLastProject(id) {
21981
22918
  void fetch("/api/ui-state", {
@@ -22000,15 +22937,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22000
22937
  }
22001
22938
  var PAGE_SIZE = 20;
22002
22939
  function ProjectsTab({ agents, onOpenSettings, postMessage }) {
22003
- const [projects, setProjects] = (0, import_react20.useState)([]);
22004
- const [selectedProjectId, setSelectedProjectId] = (0, import_react20.useState)(null);
22005
- const [tasks, setTasks] = (0, import_react20.useState)([]);
22006
- const [selectedTaskId, setSelectedTaskId] = (0, import_react20.useState)(null);
22007
- const [taskMessages, setTaskMessages] = (0, import_react20.useState)([]);
22008
- const [view, setView] = (0, import_react20.useState)("list");
22009
- const [page, setPage] = (0, import_react20.useState)(0);
22010
- const [isNewTaskOpen, setIsNewTaskOpen] = (0, import_react20.useState)(false);
22011
- const [newTask, setNewTask] = (0, import_react20.useState)({
22940
+ const [projects, setProjects] = (0, import_react23.useState)([]);
22941
+ const [selectedProjectId, setSelectedProjectId] = (0, import_react23.useState)(null);
22942
+ const [tasks, setTasks] = (0, import_react23.useState)([]);
22943
+ const [selectedTaskId, setSelectedTaskId] = (0, import_react23.useState)(null);
22944
+ const [taskMessages, setTaskMessages] = (0, import_react23.useState)([]);
22945
+ const [view, setView] = (0, import_react23.useState)("list");
22946
+ const [page, setPage] = (0, import_react23.useState)(0);
22947
+ const [isNewTaskOpen, setIsNewTaskOpen] = (0, import_react23.useState)(false);
22948
+ const [newTask, setNewTask] = (0, import_react23.useState)({
22012
22949
  title: "",
22013
22950
  objective: "",
22014
22951
  checklistText: "",
@@ -22017,12 +22954,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22017
22954
  plannerAgentId: "",
22018
22955
  reviewerAgentId: ""
22019
22956
  });
22020
- const [isSending, setIsSending] = (0, import_react20.useState)(false);
22021
- const [showArchived, setShowArchived] = (0, import_react20.useState)(loadShowArchived);
22022
- const [pendingConfirm, setPendingConfirm] = (0, import_react20.useState)(null);
22023
- const [taskError, setTaskError] = (0, import_react20.useState)(null);
22024
- const threadIntervalRef = (0, import_react20.useRef)(null);
22025
- (0, import_react20.useEffect)(() => {
22957
+ const [isSending, setIsSending] = (0, import_react23.useState)(false);
22958
+ const [showArchived, setShowArchived] = (0, import_react23.useState)(loadShowArchived);
22959
+ const [pendingConfirm, setPendingConfirm] = (0, import_react23.useState)(null);
22960
+ const [taskError, setTaskError] = (0, import_react23.useState)(null);
22961
+ const threadIntervalRef = (0, import_react23.useRef)(null);
22962
+ (0, import_react23.useEffect)(() => {
22026
22963
  void (async () => {
22027
22964
  try {
22028
22965
  const res = await fetch("/api/ui-state");
@@ -22038,7 +22975,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22038
22975
  stopThreadPolling();
22039
22976
  };
22040
22977
  }, []);
22041
- (0, import_react20.useEffect)(() => {
22978
+ (0, import_react23.useEffect)(() => {
22042
22979
  if (projects.length > 0 && selectedProjectId === null) {
22043
22980
  setSelectedProjectId(projects[0].id);
22044
22981
  }
@@ -22049,10 +22986,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22049
22986
  setSelectedProjectId(null);
22050
22987
  }
22051
22988
  }, [projects]);
22052
- (0, import_react20.useEffect)(() => {
22989
+ (0, import_react23.useEffect)(() => {
22053
22990
  saveShowArchived(showArchived);
22054
22991
  }, [showArchived]);
22055
- (0, import_react20.useEffect)(() => {
22992
+ (0, import_react23.useEffect)(() => {
22056
22993
  if (selectedProjectId !== null) {
22057
22994
  fetchTasks(selectedProjectId);
22058
22995
  setView("list");
@@ -22064,7 +23001,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22064
23001
  setTasks([]);
22065
23002
  }
22066
23003
  }, [selectedProjectId, showArchived]);
22067
- (0, import_react20.useEffect)(() => {
23004
+ (0, import_react23.useEffect)(() => {
22068
23005
  if (selectedTaskId !== null) {
22069
23006
  fetchTaskMessages(selectedTaskId);
22070
23007
  startThreadPolling(selectedTaskId);
@@ -22237,7 +23174,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22237
23174
  const cancelPendingAction = () => {
22238
23175
  setPendingConfirm(null);
22239
23176
  };
22240
- (0, import_react20.useEffect)(() => {
23177
+ (0, import_react23.useEffect)(() => {
22241
23178
  if (!pendingConfirm) return;
22242
23179
  function handleKeyDown(event) {
22243
23180
  if (event.key === "Escape") {
@@ -22247,7 +23184,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22247
23184
  window.addEventListener("keydown", handleKeyDown);
22248
23185
  return () => window.removeEventListener("keydown", handleKeyDown);
22249
23186
  }, [pendingConfirm]);
22250
- (0, import_react20.useEffect)(() => {
23187
+ (0, import_react23.useEffect)(() => {
22251
23188
  if (!taskError) return;
22252
23189
  const t = setTimeout(() => setTaskError(null), 5e3);
22253
23190
  return () => clearTimeout(t);
@@ -22378,7 +23315,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22378
23315
  const selectedProject = projects.find((p) => p.id === selectedProjectId);
22379
23316
  const selectedTask = tasks.find((t) => t.id === selectedTaskId);
22380
23317
  const selectedProjectAgentName = agents.find((a2) => a2.id === selectedProject?.agentId)?.name || "Default Agent";
22381
- const taskAgentLabels = (0, import_react20.useMemo)(() => {
23318
+ const taskAgentLabels = (0, import_react23.useMemo)(() => {
22382
23319
  if (!selectedTask) return void 0;
22383
23320
  const agentLabelFor = (agentId) => {
22384
23321
  const a2 = agents.find((x) => x.id === agentId);
@@ -22424,14 +23361,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22424
23361
  const safePage = Math.min(page, totalPages - 1);
22425
23362
  const pageStart = safePage * PAGE_SIZE;
22426
23363
  const pageTasks = tasks.slice(pageStart, pageStart + PAGE_SIZE);
22427
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "app", style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
22428
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("main", { className: "app__chat-pane", style: { flex: 1, display: "flex", flexDirection: "column", background: "var(--vscode-editor-background)" }, children: projects.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("p", { children: [
23364
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app", style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
23365
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("main", { className: "app__chat-pane", style: { flex: 1, display: "flex", flexDirection: "column", background: "var(--vscode-editor-background)" }, children: projects.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { children: [
22429
23366
  "No projects registered.",
22430
23367
  " ",
22431
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "app__link-btn", onClick: onOpenSettings, children: "Create one in Settings" }),
23368
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "app__link-btn", onClick: onOpenSettings, children: "Create one in Settings" }),
22432
23369
  " ",
22433
23370
  "to get started."
22434
- ] }) }) : selectedProject ? view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23371
+ ] }) }) : selectedProject ? view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22435
23372
  TaskListView,
22436
23373
  {
22437
23374
  projects,
@@ -22456,7 +23393,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22456
23393
  onArchive: handleArchiveFromList,
22457
23394
  statusColor
22458
23395
  }
22459
- ) : view === "log" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23396
+ ) : view === "log" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22460
23397
  TaskLogView,
22461
23398
  {
22462
23399
  task: selectedTask,
@@ -22472,7 +23409,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22472
23409
  onToggleStatus: handleToggleTaskStatus,
22473
23410
  statusColor
22474
23411
  }
22475
- ) : view === "edit" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23412
+ ) : view === "edit" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22476
23413
  TaskEditView,
22477
23414
  {
22478
23415
  task: selectedTask,
@@ -22490,11 +23427,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22490
23427
  onOpenLog: () => setView("log"),
22491
23428
  statusColor
22492
23429
  }
22493
- ) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "app__empty-state", children: [
22494
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { children: "Task not found. Go back to the list." }),
22495
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "settings-panel__back-btn", onClick: backToList, style: { marginTop: "12px" }, children: "\u2190 Back to list" })
23430
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__empty-state", children: [
23431
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { children: "Task not found. Go back to the list." }),
23432
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "settings-panel__back-btn", onClick: backToList, style: { marginTop: "12px" }, children: "\u2190 Back to list" })
22496
23433
  ] }) : null }),
22497
- isNewTaskOpen && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23434
+ isNewTaskOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22498
23435
  "div",
22499
23436
  {
22500
23437
  style: {
@@ -22509,7 +23446,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22509
23446
  justifyContent: "center",
22510
23447
  zIndex: 999
22511
23448
  },
22512
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23449
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22513
23450
  "form",
22514
23451
  {
22515
23452
  onSubmit: handleCreateTask,
@@ -22520,14 +23457,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22520
23457
  background: "var(--vscode-sideBar-background)"
22521
23458
  },
22522
23459
  children: [
22523
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "confirm__header", children: [
22524
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "18px", display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Wrench, { size: 18 }) }),
22525
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "confirm__prompt", style: { fontSize: "14px" }, children: "Create New Task" })
23460
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "confirm__header", children: [
23461
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { fontSize: "18px", display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Wrench, { size: 18 }) }),
23462
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "confirm__prompt", style: { fontSize: "14px" }, children: "Create New Task" })
22526
23463
  ] }),
22527
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "10px" }, children: [
22528
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23464
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "10px" }, children: [
23465
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22529
23466
  "Task Title",
22530
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23467
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22531
23468
  "input",
22532
23469
  {
22533
23470
  type: "text",
@@ -22547,9 +23484,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22547
23484
  }
22548
23485
  )
22549
23486
  ] }),
22550
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23487
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22551
23488
  "Objective (Extended markdown goal description)",
22552
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23489
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22553
23490
  "textarea",
22554
23491
  {
22555
23492
  required: true,
@@ -22570,9 +23507,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22570
23507
  }
22571
23508
  )
22572
23509
  ] }),
22573
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23510
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22574
23511
  "Checklist Items (One item per line)",
22575
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23512
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22576
23513
  "textarea",
22577
23514
  {
22578
23515
  placeholder: "Create route handler\nWrite unit tests\nUpdate documentation",
@@ -22592,9 +23529,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22592
23529
  }
22593
23530
  )
22594
23531
  ] }),
22595
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23532
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22596
23533
  "Assigned Agent (optional \u2014 overrides project default)",
22597
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23534
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22598
23535
  "select",
22599
23536
  {
22600
23537
  value: newTask.agentId,
@@ -22609,8 +23546,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22609
23546
  outline: "none"
22610
23547
  },
22611
23548
  children: [
22612
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
22613
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
23549
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
23550
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
22614
23551
  a2.name,
22615
23552
  " (",
22616
23553
  a2.provider,
@@ -22620,9 +23557,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22620
23557
  }
22621
23558
  )
22622
23559
  ] }),
22623
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23560
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22624
23561
  "Planner Agent Override (optional)",
22625
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23562
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22626
23563
  "select",
22627
23564
  {
22628
23565
  value: newTask.plannerAgentId,
@@ -22637,8 +23574,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22637
23574
  outline: "none"
22638
23575
  },
22639
23576
  children: [
22640
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
22641
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
23577
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
23578
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
22642
23579
  a2.name,
22643
23580
  " (",
22644
23581
  a2.provider,
@@ -22648,9 +23585,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22648
23585
  }
22649
23586
  )
22650
23587
  ] }),
22651
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23588
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22652
23589
  "Reviewer Agent Override (optional)",
22653
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23590
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22654
23591
  "select",
22655
23592
  {
22656
23593
  value: newTask.reviewerAgentId,
@@ -22665,8 +23602,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22665
23602
  outline: "none"
22666
23603
  },
22667
23604
  children: [
22668
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
22669
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
23605
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
23606
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
22670
23607
  a2.name,
22671
23608
  " (",
22672
23609
  a2.provider,
@@ -22676,8 +23613,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22676
23613
  }
22677
23614
  )
22678
23615
  ] }),
22679
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "12px", display: "flex", alignItems: "center", gap: "6px", cursor: "pointer", marginTop: "4px" }, children: [
22680
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23616
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "12px", display: "flex", alignItems: "center", gap: "6px", cursor: "pointer", marginTop: "4px" }, children: [
23617
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22681
23618
  "input",
22682
23619
  {
22683
23620
  type: "checkbox",
@@ -22686,24 +23623,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22686
23623
  style: { cursor: "pointer" }
22687
23624
  }
22688
23625
  ),
22689
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Start active immediately (Heartbeat loop claims it)" })
23626
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: "Start active immediately (Heartbeat loop claims it)" })
22690
23627
  ] })
22691
23628
  ] }),
22692
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "confirm__buttons", style: { justifyContent: "flex-end", marginTop: "10px" }, children: [
22693
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "confirm__btn", onClick: () => setIsNewTaskOpen(false), children: "Cancel" }),
22694
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "submit", className: "confirm__btn confirm__btn--primary", children: "Create Task" })
23629
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "confirm__buttons", style: { justifyContent: "flex-end", marginTop: "10px" }, children: [
23630
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: "confirm__btn", onClick: () => setIsNewTaskOpen(false), children: "Cancel" }),
23631
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "submit", className: "confirm__btn confirm__btn--primary", children: "Create Task" })
22695
23632
  ] })
22696
23633
  ]
22697
23634
  }
22698
23635
  )
22699
23636
  }
22700
23637
  ),
22701
- pendingConfirm && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__confirm-overlay", onClick: cancelPendingAction, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
22702
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__confirm-title", children: pendingConfirm.type === "delete" ? "Delete task" : pendingConfirm.type === "archive" ? "Archive task" : "Discard worktree" }),
22703
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "app__confirm-message", children: pendingConfirm.type === "delete" ? `Permanently delete task #${pendingConfirm.task.id} "${pendingConfirm.task.title}"? This removes the task and all its messages from the store. This action cannot be undone.` : pendingConfirm.type === "archive" ? `Archive task #${pendingConfirm.task.id} "${pendingConfirm.task.title}"? It will be hidden from the list and excluded from the scheduler. You can unarchive it later by enabling "Show archived".` : `Discard the worktree for task #${pendingConfirm.task.id}? Pending changes are committed to branch ${pendingConfirm.task.branch}; the branch is kept.` }),
22704
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "app__confirm-buttons", children: [
22705
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "app__confirm-btn", onClick: cancelPendingAction, children: "Cancel" }),
22706
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23638
+ pendingConfirm && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__confirm-overlay", onClick: cancelPendingAction, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
23639
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__confirm-title", children: pendingConfirm.type === "delete" ? "Delete task" : pendingConfirm.type === "archive" ? "Archive task" : "Discard worktree" }),
23640
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "app__confirm-message", children: pendingConfirm.type === "delete" ? `Permanently delete task #${pendingConfirm.task.id} "${pendingConfirm.task.title}"? This removes the task and all its messages from the store. This action cannot be undone.` : pendingConfirm.type === "archive" ? `Archive task #${pendingConfirm.task.id} "${pendingConfirm.task.title}"? It will be hidden from the list and excluded from the scheduler. You can unarchive it later by enabling "Show archived".` : `Discard the worktree for task #${pendingConfirm.task.id}? Pending changes are committed to branch ${pendingConfirm.task.branch}; the branch is kept.` }),
23641
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__confirm-buttons", children: [
23642
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "app__confirm-btn", onClick: cancelPendingAction, children: "Cancel" }),
23643
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22707
23644
  "button",
22708
23645
  {
22709
23646
  className: `app__confirm-btn ${pendingConfirm.type === "delete" ? "app__confirm-btn--danger" : ""}`,
@@ -22713,7 +23650,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22713
23650
  )
22714
23651
  ] })
22715
23652
  ] }) }),
22716
- taskError && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__error-banner", onClick: () => setTaskError(null), title: "Click to dismiss", children: taskError })
23653
+ taskError && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__error-banner", onClick: () => setTaskError(null), title: "Click to dismiss", children: taskError })
22717
23654
  ] });
22718
23655
  }
22719
23656
  function TaskListView({
@@ -22736,10 +23673,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22736
23673
  onArchive,
22737
23674
  statusColor
22738
23675
  }) {
22739
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
22740
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "task-view__header", children: [
22741
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
22742
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23676
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
23677
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "task-view__header", children: [
23678
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23679
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22743
23680
  "select",
22744
23681
  {
22745
23682
  className: "task-view__project-filter",
@@ -22756,17 +23693,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22756
23693
  outline: "none",
22757
23694
  cursor: "pointer"
22758
23695
  },
22759
- children: projects.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: p.id, children: p.name }, p.id))
23696
+ children: projects.map((p) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: p.id, children: p.name }, p.id))
22760
23697
  }
22761
23698
  ),
22762
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: [
23699
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: [
22763
23700
  "Agent: ",
22764
23701
  agentName
22765
23702
  ] })
22766
23703
  ] }),
22767
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
22768
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "task-view__archived-toggle", children: [
22769
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23704
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
23705
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "task-view__archived-toggle", children: [
23706
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22770
23707
  "input",
22771
23708
  {
22772
23709
  type: "checkbox",
@@ -22777,42 +23714,42 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22777
23714
  ),
22778
23715
  "Show archived"
22779
23716
  ] }),
22780
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "app__new-chat-btn", onClick: onNewTask, style: { padding: "4px 10px", fontSize: "11px" }, children: "+ New Task" })
23717
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "app__new-chat-btn", onClick: onNewTask, style: { padding: "4px 10px", fontSize: "11px" }, children: "+ New Task" })
22781
23718
  ] })
22782
23719
  ] }),
22783
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { flex: 1, overflowY: "auto", padding: "0 16px 16px" }, children: allTasksCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("p", { children: [
23720
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { flex: 1, overflowY: "auto", padding: "0 16px 16px" }, children: allTasksCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { children: [
22784
23721
  "No tasks created for ",
22785
23722
  project.name,
22786
23723
  '. Click "+ New Task" to start.'
22787
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("table", { className: "task-table", children: [
22788
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("tr", { children: [
22789
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "60px" }, children: "#" }),
22790
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", children: "Title" }),
22791
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "90px" }, children: "Status" }),
22792
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "100px" }, children: "Agent" }),
22793
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "120px" }, children: "Checklist" }),
22794
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "180px" }, children: "Branch" }),
22795
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "150px" }, children: "Updated" }),
22796
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("th", { className: "task-table__th", style: { width: "70px" } })
23724
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("table", { className: "task-table", children: [
23725
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("tr", { children: [
23726
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "60px" }, children: "#" }),
23727
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", children: "Title" }),
23728
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "90px" }, children: "Status" }),
23729
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "100px" }, children: "Agent" }),
23730
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "120px" }, children: "Checklist" }),
23731
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "180px" }, children: "Branch" }),
23732
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "150px" }, children: "Updated" }),
23733
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { className: "task-table__th", style: { width: "70px" } })
22797
23734
  ] }) }),
22798
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tbody", { children: tasks.map((task) => {
23735
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tbody", { children: tasks.map((task) => {
22799
23736
  const completedCount = task.checklist.filter((c2) => c2.status === "done").length;
22800
23737
  const totalCount = task.checklist.length;
22801
23738
  const isArchived = !!task.archived;
22802
23739
  const updated = new Date(task.updatedAt);
22803
23740
  const updatedStr = isNaN(updated.getTime()) ? task.updatedAt : updated.toLocaleString(void 0, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
22804
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23741
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22805
23742
  "tr",
22806
23743
  {
22807
23744
  className: `task-table__row${isArchived ? " task-table__row--archived" : ""}`,
22808
23745
  onClick: () => onOpenLog(task),
22809
23746
  children: [
22810
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td task-table__td--mono", children: task.id }),
22811
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__title", children: [
22812
- isArchived && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Archive, { size: 11 }),
23747
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td task-table__td--mono", children: task.id }),
23748
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "task-table__title", children: [
23749
+ isArchived && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Archive, { size: 11 }),
22813
23750
  task.title
22814
23751
  ] }) }),
22815
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23752
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22816
23753
  "span",
22817
23754
  {
22818
23755
  className: "task-table__badge",
@@ -22820,28 +23757,28 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22820
23757
  children: task.status
22821
23758
  }
22822
23759
  ) }),
22823
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", style: { fontSize: "11px" }, children: task.agentId ? agents.find((a2) => a2.id === task.agentId)?.name || task.agentId : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { opacity: 0.4 }, children: "default" }) }),
22824
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: totalCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "task-table__progress", children: [
22825
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "task-table__progress-bar", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23760
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", style: { fontSize: "11px" }, children: task.agentId ? agents.find((a2) => a2.id === task.agentId)?.name || task.agentId : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { opacity: 0.4 }, children: "default" }) }),
23761
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", children: totalCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "task-table__progress", children: [
23762
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "task-table__progress-bar", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22826
23763
  "span",
22827
23764
  {
22828
23765
  className: "task-table__progress-fill",
22829
23766
  style: { width: `${completedCount / totalCount * 100}%` }
22830
23767
  }
22831
23768
  ) }),
22832
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__progress-text", children: [
23769
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "task-table__progress-text", children: [
22833
23770
  completedCount,
22834
23771
  "/",
22835
23772
  totalCount
22836
23773
  ] })
22837
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
22838
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: task.branch ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__branch", children: [
22839
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(GitBranch, { size: 11 }),
22840
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { children: task.branch })
22841
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
22842
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td task-table__td--muted", children: updatedStr }),
22843
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "inline-flex", gap: "2px" }, children: [
22844
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23774
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
23775
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", children: task.branch ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "task-table__branch", children: [
23776
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(GitBranch, { size: 11 }),
23777
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("code", { children: task.branch })
23778
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
23779
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td task-table__td--muted", children: updatedStr }),
23780
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "inline-flex", gap: "2px" }, children: [
23781
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22845
23782
  "button",
22846
23783
  {
22847
23784
  className: "task-table__edit-btn",
@@ -22851,10 +23788,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22851
23788
  },
22852
23789
  title: task.archived ? "Unarchive task" : "Archive task",
22853
23790
  "aria-label": task.archived ? "Unarchive task" : "Archive task",
22854
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Archive, { size: 13 })
23791
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Archive, { size: 13 })
22855
23792
  }
22856
23793
  ),
22857
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23794
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22858
23795
  "button",
22859
23796
  {
22860
23797
  className: "task-table__edit-btn",
@@ -22864,7 +23801,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22864
23801
  },
22865
23802
  title: "Edit task",
22866
23803
  "aria-label": "Edit task",
22867
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Pencil, { size: 13 })
23804
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Pencil, { size: 13 })
22868
23805
  }
22869
23806
  )
22870
23807
  ] }) })
@@ -22874,8 +23811,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22874
23811
  );
22875
23812
  }) })
22876
23813
  ] }) }),
22877
- totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "task-table__pagination", children: [
22878
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23814
+ totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "task-table__pagination", children: [
23815
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22879
23816
  "button",
22880
23817
  {
22881
23818
  className: "task-table__page-btn",
@@ -22884,13 +23821,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22884
23821
  children: "\u2039 Prev"
22885
23822
  }
22886
23823
  ),
22887
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__page-info", children: [
23824
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "task-table__page-info", children: [
22888
23825
  "Page ",
22889
23826
  page + 1,
22890
23827
  " of ",
22891
23828
  totalPages
22892
23829
  ] }),
22893
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23830
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22894
23831
  "button",
22895
23832
  {
22896
23833
  className: "task-table__page-btn",
@@ -22918,31 +23855,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22918
23855
  }) {
22919
23856
  const completedCount = task.checklist.filter((c2) => c2.status === "done").length;
22920
23857
  const totalCount = task.checklist.length;
22921
- const chatItems = (0, import_react20.useMemo)(() => taskMessagesToChatItems(taskMessages, agentLabels), [taskMessages, agentLabels]);
22922
- const [openCycle, setOpenCycle] = (0, import_react20.useState)(null);
22923
- const [draft, setDraft] = (0, import_react20.useState)("");
22924
- const openCycleItem = (0, import_react20.useCallback)((item) => setOpenCycle(item), []);
22925
- const autoOpenedFor = (0, import_react20.useRef)(null);
22926
- (0, import_react20.useEffect)(() => {
23858
+ const chatItems = (0, import_react23.useMemo)(() => taskMessagesToChatItems(taskMessages, agentLabels), [taskMessages, agentLabels]);
23859
+ const [openCycle, setOpenCycle] = (0, import_react23.useState)(null);
23860
+ const [draft, setDraft] = (0, import_react23.useState)("");
23861
+ const openCycleItem = (0, import_react23.useCallback)((item) => setOpenCycle(item), []);
23862
+ const autoOpenedFor = (0, import_react23.useRef)(null);
23863
+ (0, import_react23.useEffect)(() => {
22927
23864
  if (autoOpenedFor.current === task.id || taskMessages.length === 0) return;
22928
23865
  autoOpenedFor.current = task.id;
22929
23866
  const latest = [...chatItems].reverse().find((i) => i.kind === "cycle");
22930
23867
  if (latest && latest.outcome === "running") setOpenCycle(latest);
22931
23868
  }, [task.id, taskMessages.length, chatItems]);
22932
23869
  const liveCycle = openCycle ? chatItems.find((i) => i.kind === "cycle" && i.sessionId === openCycle.sessionId) ?? openCycle : null;
22933
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
22934
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "12px 14px" }, children: [
22935
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
22936
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArrowLeft, { size: 13 }) }),
22937
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "app__chat-header-info", children: [
22938
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
23870
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
23871
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "12px 14px" }, children: [
23872
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23873
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArrowLeft, { size: 13 }) }),
23874
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__chat-header-info", children: [
23875
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
22939
23876
  "Task #",
22940
23877
  task.id,
22941
23878
  ": ",
22942
23879
  task.title
22943
23880
  ] }),
22944
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: [
22945
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23881
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: [
23882
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22946
23883
  "span",
22947
23884
  {
22948
23885
  className: `agent-status-dot agent-status-dot--active ${isActiveLike ? "agent-status-dot--pulsing" : ""}`,
@@ -22953,24 +23890,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22953
23890
  ] })
22954
23891
  ] })
22955
23892
  ] }),
22956
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
22957
- task.status !== "done" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23893
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
23894
+ task.status !== "done" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22958
23895
  "button",
22959
23896
  {
22960
23897
  className: "confirm__btn confirm__btn--primary",
22961
23898
  onClick: () => onToggleStatus(task),
22962
23899
  title: isActiveLike ? "Pause this task (aborts the running agent)" : "Activate this task",
22963
23900
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
22964
- children: isActiveLike ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
22965
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Pause, { size: 12 }),
23901
+ children: isActiveLike ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
23902
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Pause, { size: 12 }),
22966
23903
  " Pause"
22967
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
22968
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Play, { size: 12 }),
23904
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
23905
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Play, { size: 12 }),
22969
23906
  " Activate"
22970
23907
  ] })
22971
23908
  }
22972
23909
  ),
22973
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23910
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
22974
23911
  "span",
22975
23912
  {
22976
23913
  className: "task-table__badge",
@@ -22980,8 +23917,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22980
23917
  )
22981
23918
  ] })
22982
23919
  ] }),
22983
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "row" }, children: [
22984
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23920
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "row" }, children: [
23921
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
22985
23922
  "aside",
22986
23923
  {
22987
23924
  style: {
@@ -22994,19 +23931,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22994
23931
  background: "var(--vscode-sideBar-background, rgba(0,0,0,0.1))"
22995
23932
  },
22996
23933
  children: [
22997
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { padding: "10px 12px", borderBottom: "1px solid var(--vscode-panel-border, rgba(255,255,255,0.05))" }, children: [
22998
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: 0, fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
22999
- totalCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { fontSize: "10px", opacity: 0.5, marginTop: "2px" }, children: [
23934
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: "10px 12px", borderBottom: "1px solid var(--vscode-panel-border, rgba(255,255,255,0.05))" }, children: [
23935
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: 0, fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
23936
+ totalCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { fontSize: "10px", opacity: 0.5, marginTop: "2px" }, children: [
23000
23937
  completedCount,
23001
23938
  "/",
23002
23939
  totalCount,
23003
23940
  " done"
23004
23941
  ] })
23005
23942
  ] }),
23006
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { padding: "8px 10px", display: "flex", flexDirection: "column", gap: "4px" }, children: totalCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "11px", opacity: 0.4, padding: "8px 4px" }, children: "No checklist items." }) : (task.checklist || []).map((item) => {
23943
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { padding: "8px 10px", display: "flex", flexDirection: "column", gap: "4px" }, children: totalCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { fontSize: "11px", opacity: 0.4, padding: "8px 4px" }, children: "No checklist items." }) : (task.checklist || []).map((item) => {
23007
23944
  const isDone = item.status === "done";
23008
23945
  const isInProgress = item.status === "in_progress";
23009
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23946
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23010
23947
  "label",
23011
23948
  {
23012
23949
  style: {
@@ -23023,7 +23960,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23023
23960
  },
23024
23961
  title: isInProgress ? "In progress" : isDone ? "Done" : "Pending",
23025
23962
  children: [
23026
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23963
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23027
23964
  "input",
23028
23965
  {
23029
23966
  type: "checkbox",
@@ -23032,7 +23969,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23032
23969
  style: { marginTop: "2px", cursor: "pointer", flexShrink: 0 }
23033
23970
  }
23034
23971
  ),
23035
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { wordBreak: "break-word" }, children: item.text })
23972
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { wordBreak: "break-word" }, children: item.text })
23036
23973
  ]
23037
23974
  },
23038
23975
  item.id
@@ -23041,8 +23978,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23041
23978
  ]
23042
23979
  }
23043
23980
  ),
23044
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: [
23045
- liveCycle ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23981
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: [
23982
+ liveCycle ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23046
23983
  TaskCycleView,
23047
23984
  {
23048
23985
  item: liveCycle,
@@ -23050,8 +23987,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23050
23987
  onBack: () => setOpenCycle(null)
23051
23988
  },
23052
23989
  liveCycle.sessionId
23053
- ) : taskMessages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "messages messages--empty", children: "No messages in this execution yet. Agent will start on next tick." }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessageList, { items: chatItems, sessionId: null, compact: true, onOpenCycle: openCycleItem }),
23054
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23990
+ ) : taskMessages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "messages messages--empty", children: "No messages in this execution yet. Agent will start on next tick." }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MessageList, { items: chatItems, sessionId: null, compact: true, onOpenCycle: openCycleItem }),
23991
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23055
23992
  Composer,
23056
23993
  {
23057
23994
  disabled: isSending,
@@ -23088,12 +24025,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23088
24025
  statusColor
23089
24026
  }) {
23090
24027
  const isRunning = task.status === "active" || task.status === "reviewing" || task.status === "planning";
23091
- const [draftTitle, setDraftTitle] = (0, import_react20.useState)(task.title);
23092
- const [draftObjective, setDraftObjective] = (0, import_react20.useState)(task.objective);
23093
- const [lastTaskId, setLastTaskId] = (0, import_react20.useState)(task.id);
24028
+ const [draftTitle, setDraftTitle] = (0, import_react23.useState)(task.title);
24029
+ const [draftObjective, setDraftObjective] = (0, import_react23.useState)(task.objective);
24030
+ const [lastTaskId, setLastTaskId] = (0, import_react23.useState)(task.id);
23094
24031
  const trimmedTitle = draftTitle.trim();
23095
24032
  const isDirty = trimmedTitle !== task.title.trim() || draftObjective.trim() !== task.objective.trim();
23096
- (0, import_react20.useEffect)(() => {
24033
+ (0, import_react23.useEffect)(() => {
23097
24034
  if (task.id !== lastTaskId) {
23098
24035
  setDraftTitle(task.title);
23099
24036
  setDraftObjective(task.objective);
@@ -23108,16 +24045,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23108
24045
  setDraftTitle(task.title);
23109
24046
  setDraftObjective(task.objective);
23110
24047
  };
23111
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%", overflowY: "auto" }, children: [
23112
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "task-view__sub-header", style: { padding: "12px 14px", display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
23113
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23114
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArrowLeft, { size: 13 }) }),
23115
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("h3", { style: { margin: 0, fontSize: "15px", fontWeight: 700, display: "flex", alignItems: "center", gap: "6px" }, children: [
23116
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { opacity: 0.6 }, children: [
24048
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%", overflowY: "auto" }, children: [
24049
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "task-view__sub-header", style: { padding: "12px 14px", display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
24050
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
24051
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArrowLeft, { size: 13 }) }),
24052
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("h3", { style: { margin: 0, fontSize: "15px", fontWeight: 700, display: "flex", alignItems: "center", gap: "6px" }, children: [
24053
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { style: { opacity: 0.6 }, children: [
23117
24054
  "Task #",
23118
24055
  task.id
23119
24056
  ] }),
23120
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24057
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23121
24058
  "input",
23122
24059
  {
23123
24060
  value: draftTitle,
@@ -23138,7 +24075,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23138
24075
  }
23139
24076
  )
23140
24077
  ] }),
23141
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24078
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23142
24079
  "span",
23143
24080
  {
23144
24081
  className: "task-table__badge",
@@ -23147,8 +24084,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23147
24084
  }
23148
24085
  )
23149
24086
  ] }),
23150
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "inline-flex", gap: "6px" }, children: [
23151
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24087
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "inline-flex", gap: "6px" }, children: [
24088
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23152
24089
  "button",
23153
24090
  {
23154
24091
  className: "confirm__btn",
@@ -23158,7 +24095,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23158
24095
  children: "View Log"
23159
24096
  }
23160
24097
  ),
23161
- task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24098
+ task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23162
24099
  "button",
23163
24100
  {
23164
24101
  className: "confirm__btn",
@@ -23166,12 +24103,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23166
24103
  title: `Commit pending changes to ${task.branch} and remove the worktree`,
23167
24104
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
23168
24105
  children: [
23169
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(GitBranch, { size: 12 }),
24106
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(GitBranch, { size: 12 }),
23170
24107
  " Discard worktree"
23171
24108
  ]
23172
24109
  }
23173
24110
  ),
23174
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24111
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23175
24112
  "button",
23176
24113
  {
23177
24114
  className: "confirm__btn",
@@ -23179,28 +24116,28 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23179
24116
  title: task.archived ? "Unarchive this task" : "Archive this task (hides it from the list, excludes from scheduler)",
23180
24117
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
23181
24118
  children: [
23182
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Archive, { size: 12 }),
24119
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Archive, { size: 12 }),
23183
24120
  " ",
23184
24121
  task.archived ? "Unarchive" : "Archive"
23185
24122
  ]
23186
24123
  }
23187
24124
  ),
23188
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24125
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23189
24126
  "button",
23190
24127
  {
23191
24128
  className: "confirm__btn confirm__btn--primary",
23192
24129
  onClick: () => onToggleStatus(task),
23193
24130
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
23194
- children: task.status === "active" || task.status === "reviewing" || task.status === "planning" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
23195
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Pause, { size: 12 }),
24131
+ children: task.status === "active" || task.status === "reviewing" || task.status === "planning" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
24132
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Pause, { size: 12 }),
23196
24133
  " Pause"
23197
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
23198
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Play, { size: 12 }),
24134
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
24135
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Play, { size: 12 }),
23199
24136
  " Activate"
23200
24137
  ] })
23201
24138
  }
23202
24139
  ),
23203
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24140
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23204
24141
  "button",
23205
24142
  {
23206
24143
  className: "confirm__btn",
@@ -23208,22 +24145,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23208
24145
  title: "Permanently delete this task and all its messages",
23209
24146
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px", color: "#ef4444" },
23210
24147
  children: [
23211
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Trash, { size: 12 }),
24148
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 12 }),
23212
24149
  " Delete"
23213
24150
  ]
23214
24151
  }
23215
24152
  )
23216
24153
  ] })
23217
24154
  ] }),
23218
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { padding: "16px", maxWidth: "720px" }, children: [
23219
- task.branch && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px", display: "flex", alignItems: "center", gap: "6px", fontSize: "11px", opacity: 0.75 }, children: [
23220
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(GitBranch, { size: 12 }),
23221
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { style: { fontFamily: "monospace" }, children: task.branch }),
23222
- !task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { opacity: 0.6 }, children: "(worktree removed)" })
24155
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { padding: "16px", maxWidth: "720px" }, children: [
24156
+ task.branch && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px", display: "flex", alignItems: "center", gap: "6px", fontSize: "11px", opacity: 0.75 }, children: [
24157
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(GitBranch, { size: 12 }),
24158
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("code", { style: { fontFamily: "monospace" }, children: task.branch }),
24159
+ !task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { opacity: 0.6 }, children: "(worktree removed)" })
23223
24160
  ] }),
23224
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23225
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Objective" }),
23226
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24161
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24162
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Objective" }),
24163
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23227
24164
  "textarea",
23228
24165
  {
23229
24166
  value: draftObjective,
@@ -23247,8 +24184,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23247
24184
  }
23248
24185
  }
23249
24186
  ),
23250
- isDirty && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "flex", gap: "6px", alignItems: "center", marginTop: "8px" }, children: [
23251
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24187
+ isDirty && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex", gap: "6px", alignItems: "center", marginTop: "8px" }, children: [
24188
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23252
24189
  "button",
23253
24190
  {
23254
24191
  className: "confirm__btn confirm__btn--primary",
@@ -23261,13 +24198,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23261
24198
  children: "Save"
23262
24199
  }
23263
24200
  ),
23264
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "confirm__btn", onClick: resetDraft, style: { padding: "3px 10px", fontSize: "10px" }, children: "Cancel" }),
23265
- isRunning && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: "Applies from the next cycle." })
24201
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "confirm__btn", onClick: resetDraft, style: { padding: "3px 10px", fontSize: "10px" }, children: "Cancel" }),
24202
+ isRunning && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: "Applies from the next cycle." })
23266
24203
  ] })
23267
24204
  ] }),
23268
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23269
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Assigned Agent" }),
23270
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24205
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24206
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Assigned Agent" }),
24207
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23271
24208
  "select",
23272
24209
  {
23273
24210
  value: task.agentId || "",
@@ -23287,8 +24224,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23287
24224
  },
23288
24225
  title: isRunning ? "Pause the task before changing its agent" : "Choose which agent runs this task",
23289
24226
  children: [
23290
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
23291
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
24227
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
24228
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
23292
24229
  a2.name,
23293
24230
  " (",
23294
24231
  a2.provider,
@@ -23298,9 +24235,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23298
24235
  }
23299
24236
  )
23300
24237
  ] }),
23301
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23302
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Planner Agent" }),
23303
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24238
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24239
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Planner Agent" }),
24240
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23304
24241
  "select",
23305
24242
  {
23306
24243
  value: task.plannerAgentId || "",
@@ -23309,8 +24246,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23309
24246
  style: { background: "var(--vscode-input-background, #252526)", color: "var(--vscode-input-foreground)", border: "1px solid var(--vscode-input-border, #3c3c3c)", borderRadius: "4px", padding: "6px 8px", fontSize: "12px", outline: "none", width: "100%", cursor: isRunning ? "not-allowed" : "pointer", opacity: isRunning ? 0.6 : 1 },
23310
24247
  title: isRunning ? "Pause the task before changing its planner" : "Agent that runs the planning phase (read-only). Unset: falls back to the project planner, then the developer.",
23311
24248
  children: [
23312
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
23313
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
24249
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
24250
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
23314
24251
  a2.name,
23315
24252
  " (",
23316
24253
  a2.provider,
@@ -23320,9 +24257,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23320
24257
  }
23321
24258
  )
23322
24259
  ] }),
23323
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23324
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Reviewer Agent" }),
23325
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24260
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24261
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Reviewer Agent" }),
24262
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23326
24263
  "select",
23327
24264
  {
23328
24265
  value: task.reviewerAgentId || "",
@@ -23331,8 +24268,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23331
24268
  style: { background: "var(--vscode-input-background, #252526)", color: "var(--vscode-input-foreground)", border: "1px solid var(--vscode-input-border, #3c3c3c)", borderRadius: "4px", padding: "6px 8px", fontSize: "12px", outline: "none", width: "100%", cursor: isRunning ? "not-allowed" : "pointer", opacity: isRunning ? 0.6 : 1 },
23332
24269
  title: isRunning ? "Pause the task before changing its reviewer" : "Agent that reviews the branch at DONE. Unset: falls back to the project reviewer, then the developer.",
23333
24270
  children: [
23334
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Project default" }),
23335
- agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
24271
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", children: "Project default" }),
24272
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("option", { value: a2.id, children: [
23336
24273
  a2.name,
23337
24274
  " (",
23338
24275
  a2.provider,
@@ -23342,31 +24279,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23342
24279
  }
23343
24280
  )
23344
24281
  ] }),
23345
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23346
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Phases" }),
23347
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", gap: "12px" }, children: [
24282
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24283
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Phases" }),
24284
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { display: "flex", gap: "12px" }, children: [
23348
24285
  { flag: "planningEnabled", label: "Planning phase", value: task.planningEnabled },
23349
24286
  { flag: "reviewEnabled", label: "Review at DONE", value: task.reviewEnabled },
23350
24287
  { flag: "sddEnabled", label: "SDD mode (.md specs)", value: task.sddEnabled }
23351
- ].map(({ flag, label, value }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", flex: 1 }, children: [
24288
+ ].map(({ flag, label, value }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", flex: 1 }, children: [
23352
24289
  label,
23353
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24290
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23354
24291
  "select",
23355
24292
  {
23356
24293
  value: value === true ? "on" : value === false ? "off" : "inherit",
23357
24294
  onChange: (e) => onSetFlag(task, flag, e.target.value === "inherit" ? null : e.target.value === "on"),
23358
24295
  style: { background: "var(--vscode-input-background, #252526)", color: "var(--vscode-input-foreground)", border: "1px solid var(--vscode-input-border, #3c3c3c)", borderRadius: "4px", padding: "6px 8px", fontSize: "12px", outline: "none" },
23359
24296
  children: [
23360
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "inherit", children: "Project default" }),
23361
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "on", children: "On" }),
23362
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "off", children: "Off" })
24297
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "inherit", children: "Project default" }),
24298
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "on", children: "On" }),
24299
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "off", children: "Off" })
23363
24300
  ]
23364
24301
  }
23365
24302
  )
23366
24303
  ] }, flag)) }),
23367
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", marginTop: "12px", maxWidth: "260px" }, children: [
24304
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", marginTop: "12px", maxWidth: "260px" }, children: [
23368
24305
  "Max run seconds per cycle",
23369
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24306
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23370
24307
  "input",
23371
24308
  {
23372
24309
  type: "number",
@@ -23389,7 +24326,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23389
24326
  )
23390
24327
  ] })
23391
24328
  ] }),
23392
- task.status === "blocked" && task.blockedReason && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24329
+ task.status === "blocked" && task.blockedReason && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23393
24330
  "div",
23394
24331
  {
23395
24332
  style: {
@@ -23402,19 +24339,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23402
24339
  fontSize: "12px"
23403
24340
  },
23404
24341
  children: [
23405
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { children: [
23406
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TriangleAlert, { size: 13 }),
24342
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("strong", { children: [
24343
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TriangleAlert, { size: 13 }),
23407
24344
  " Blocked Reason:"
23408
24345
  ] }),
23409
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { style: { margin: "4px 0 0 0" }, children: task.blockedReason })
24346
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { style: { margin: "4px 0 0 0" }, children: task.blockedReason })
23410
24347
  ]
23411
24348
  }
23412
24349
  ),
23413
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
23414
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { style: { margin: "0 0 8px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
23415
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: (task.checklist || []).map((item) => {
24350
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { children: [
24351
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h4", { style: { margin: "0 0 8px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
24352
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: (task.checklist || []).map((item) => {
23416
24353
  const isDone = item.status === "done";
23417
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24354
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23418
24355
  "label",
23419
24356
  {
23420
24357
  style: {
@@ -23431,7 +24368,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23431
24368
  opacity: isDone ? 0.6 : 1
23432
24369
  },
23433
24370
  children: [
23434
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24371
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
23435
24372
  "input",
23436
24373
  {
23437
24374
  type: "checkbox",
@@ -23440,7 +24377,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23440
24377
  style: { marginTop: "2px", cursor: "pointer" }
23441
24378
  }
23442
24379
  ),
23443
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: item.text })
24380
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: item.text })
23444
24381
  ]
23445
24382
  },
23446
24383
  item.id
@@ -23452,7 +24389,51 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23452
24389
  }
23453
24390
 
23454
24391
  // src/useVoice.ts
23455
- var import_react21 = __toESM(require_react(), 1);
24392
+ var import_react24 = __toESM(require_react(), 1);
24393
+
24394
+ // src/pcm_wav.ts
24395
+ function encodeWavPcm16(samples, rate) {
24396
+ const out = new Uint8Array(44 + samples.length * 2);
24397
+ const view = new DataView(out.buffer);
24398
+ const tag = (at2, s) => {
24399
+ for (let i = 0; i < s.length; i++) view.setUint8(at2 + i, s.charCodeAt(i));
24400
+ };
24401
+ tag(0, "RIFF");
24402
+ view.setUint32(4, 36 + samples.length * 2, true);
24403
+ tag(8, "WAVE");
24404
+ tag(12, "fmt ");
24405
+ view.setUint32(16, 16, true);
24406
+ view.setUint16(20, 1, true);
24407
+ view.setUint16(22, 1, true);
24408
+ view.setUint32(24, rate, true);
24409
+ view.setUint32(28, rate * 2, true);
24410
+ view.setUint16(32, 2, true);
24411
+ view.setUint16(34, 16, true);
24412
+ tag(36, "data");
24413
+ view.setUint32(40, samples.length * 2, true);
24414
+ for (let i = 0; i < samples.length; i++) {
24415
+ const s = Math.max(-1, Math.min(1, samples[i]));
24416
+ view.setInt16(44 + i * 2, s < 0 ? s * 32768 : s * 32767, true);
24417
+ }
24418
+ return out;
24419
+ }
24420
+ async function toWav16k(blob) {
24421
+ const ctx = new AudioContext();
24422
+ try {
24423
+ const decoded = await ctx.decodeAudioData(await blob.arrayBuffer());
24424
+ const offline = new OfflineAudioContext(1, Math.max(1, Math.ceil(decoded.duration * 16e3)), 16e3);
24425
+ const src = offline.createBufferSource();
24426
+ src.buffer = decoded;
24427
+ src.connect(offline.destination);
24428
+ src.start();
24429
+ const rendered = await offline.startRendering();
24430
+ return new Blob([encodeWavPcm16(rendered.getChannelData(0), 16e3)], { type: "audio/wav" });
24431
+ } finally {
24432
+ void ctx.close();
24433
+ }
24434
+ }
24435
+
24436
+ // src/useVoice.ts
23456
24437
  function canCapture() {
23457
24438
  return typeof window !== "undefined" && typeof MediaRecorder !== "undefined" && !!navigator.mediaDevices?.getUserMedia;
23458
24439
  }
@@ -23477,37 +24458,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23477
24458
  const { voice, chatStatus, pendingConfirmCount, items, onTranscript } = opts;
23478
24459
  const available = !!voice && voice.enabled && voice.configured && canCapture();
23479
24460
  const canSpeak = !!voice?.canSpeak;
23480
- const [phase, setPhase] = (0, import_react21.useState)("idle");
23481
- const [mode, setMode] = (0, import_react21.useState)("dictate");
23482
- const [error, setError] = (0, import_react21.useState)(null);
23483
- const phaseRef = (0, import_react21.useRef)(phase);
24461
+ const [phase, setPhase] = (0, import_react24.useState)("idle");
24462
+ const [mode, setMode] = (0, import_react24.useState)("dictate");
24463
+ const [error, setError] = (0, import_react24.useState)(null);
24464
+ const voiceRef = (0, import_react24.useRef)(voice);
24465
+ voiceRef.current = voice;
24466
+ const bufferMsRef = (0, import_react24.useRef)(voice?.playbackBufferMs);
24467
+ bufferMsRef.current = voice?.playbackBufferMs;
24468
+ const phaseRef = (0, import_react24.useRef)(phase);
23484
24469
  phaseRef.current = phase;
23485
- const modeRef = (0, import_react21.useRef)(mode);
24470
+ const modeRef = (0, import_react24.useRef)(mode);
23486
24471
  modeRef.current = mode;
23487
- const onTranscriptRef = (0, import_react21.useRef)(onTranscript);
24472
+ const onTranscriptRef = (0, import_react24.useRef)(onTranscript);
23488
24473
  onTranscriptRef.current = onTranscript;
23489
- const itemsRef = (0, import_react21.useRef)(items);
24474
+ const itemsRef = (0, import_react24.useRef)(items);
23490
24475
  itemsRef.current = items;
23491
- const chatStatusRef = (0, import_react21.useRef)(chatStatus);
24476
+ const chatStatusRef = (0, import_react24.useRef)(chatStatus);
23492
24477
  chatStatusRef.current = chatStatus;
23493
- const streamRef = (0, import_react21.useRef)(null);
23494
- const recorderRef = (0, import_react21.useRef)(null);
23495
- const chunksRef = (0, import_react21.useRef)([]);
23496
- const vadRef = (0, import_react21.useRef)(null);
23497
- const audioRef = (0, import_react21.useRef)(null);
23498
- const idleTimerRef = (0, import_react21.useRef)(null);
23499
- const heardSpeechRef = (0, import_react21.useRef)(false);
23500
- const sawStreamingRef = (0, import_react21.useRef)(false);
23501
- const cursorRef = (0, import_react21.useRef)(0);
23502
- const queueRef = (0, import_react21.useRef)([]);
23503
- const apply = (0, import_react21.useCallback)((event) => {
24478
+ const streamRef = (0, import_react24.useRef)(null);
24479
+ const recorderRef = (0, import_react24.useRef)(null);
24480
+ const chunksRef = (0, import_react24.useRef)([]);
24481
+ const vadRef = (0, import_react24.useRef)(null);
24482
+ const speechAbortRef = (0, import_react24.useRef)(null);
24483
+ const idleTimerRef = (0, import_react24.useRef)(null);
24484
+ const heardSpeechRef = (0, import_react24.useRef)(false);
24485
+ const sawStreamingRef = (0, import_react24.useRef)(false);
24486
+ const cursorRef = (0, import_react24.useRef)(0);
24487
+ const queueRef = (0, import_react24.useRef)([]);
24488
+ const apply = (0, import_react24.useCallback)((event) => {
23504
24489
  setPhase((current) => nextPhase(current, event));
23505
24490
  }, []);
23506
24491
  const clearIdleTimer = () => {
23507
24492
  if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
23508
24493
  idleTimerRef.current = null;
23509
24494
  };
23510
- const teardownCapture = (0, import_react21.useCallback)(() => {
24495
+ const teardownCapture = (0, import_react24.useCallback)(() => {
23511
24496
  clearIdleTimer();
23512
24497
  try {
23513
24498
  vadRef.current?.destroy();
@@ -23524,14 +24509,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23524
24509
  chunksRef.current = [];
23525
24510
  heardSpeechRef.current = false;
23526
24511
  }, []);
23527
- const stopPlayback = (0, import_react21.useCallback)(() => {
23528
- if (audioRef.current) {
23529
- audioRef.current.pause();
23530
- audioRef.current.src = "";
23531
- audioRef.current = null;
23532
- }
24512
+ const stopPlayback = (0, import_react24.useCallback)(() => {
24513
+ speechAbortRef.current?.abort();
24514
+ speechAbortRef.current = null;
23533
24515
  }, []);
23534
- const fail = (0, import_react21.useCallback)(
24516
+ const fail = (0, import_react24.useCallback)(
23535
24517
  (message) => {
23536
24518
  teardownCapture();
23537
24519
  stopPlayback();
@@ -23540,7 +24522,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23540
24522
  },
23541
24523
  [apply, teardownCapture, stopPlayback]
23542
24524
  );
23543
- const finishRecording = (0, import_react21.useCallback)(() => {
24525
+ const finishRecording = (0, import_react24.useCallback)(() => {
23544
24526
  const recorder = recorderRef.current;
23545
24527
  if (!recorder || recorder.state === "inactive") return;
23546
24528
  recorder.onstop = async () => {
@@ -23548,7 +24530,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23548
24530
  teardownCapture();
23549
24531
  try {
23550
24532
  const form = new FormData();
23551
- form.set("file", blob, "turn.webm");
24533
+ if (voiceRef.current?.sttEngine === "builtin") form.set("file", await toWav16k(blob), "audio.wav");
24534
+ else form.set("file", blob, "turn.webm");
23552
24535
  const res = await fetch("/api/voice/transcribe", { method: "POST", body: form });
23553
24536
  if (!res.ok) return fail(await res.text());
23554
24537
  const { text } = await res.json();
@@ -23569,7 +24552,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23569
24552
  };
23570
24553
  recorder.stop();
23571
24554
  }, [apply, fail, teardownCapture]);
23572
- const startRecording = (0, import_react21.useCallback)(async () => {
24555
+ const startRecording = (0, import_react24.useCallback)(async () => {
23573
24556
  setError(null);
23574
24557
  chunksRef.current = [];
23575
24558
  heardSpeechRef.current = false;
@@ -23614,7 +24597,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23614
24597
  fail(`Microphone unavailable: ${err}`);
23615
24598
  }
23616
24599
  }, [apply, fail, finishRecording, teardownCapture]);
23617
- const speakReply = (0, import_react21.useCallback)(async () => {
24600
+ const speakReply = (0, import_react24.useCallback)(async () => {
23618
24601
  const text = queueRef.current.shift();
23619
24602
  if (!text) {
23620
24603
  apply({
@@ -23624,44 +24607,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23624
24607
  });
23625
24608
  return;
23626
24609
  }
24610
+ const ac = new AbortController();
24611
+ speechAbortRef.current = ac;
23627
24612
  try {
23628
24613
  const res = await fetch("/api/voice/speak", {
23629
24614
  method: "POST",
23630
24615
  headers: { "content-type": "application/json" },
23631
- body: JSON.stringify({ text: stripMarkdownForSpeech(text) })
24616
+ body: JSON.stringify({ text: stripMarkdownForSpeech(text) }),
24617
+ signal: ac.signal
23632
24618
  });
23633
24619
  if (!res.ok) return fail(await res.text());
23634
- const url = URL.createObjectURL(await res.blob());
23635
- const audio = new Audio(url);
23636
- audioRef.current = audio;
23637
- audio.onended = () => {
23638
- URL.revokeObjectURL(url);
23639
- audioRef.current = null;
23640
- setTimeout(() => {
23641
- if (queueRef.current.length > 0) {
23642
- void speakReply();
23643
- } else {
23644
- apply({
23645
- kind: "playbackEnded",
23646
- mode: "conversation",
23647
- turnComplete: chatStatusRef.current === "idle"
23648
- });
23649
- }
23650
- }, POST_PLAYBACK_MS);
23651
- };
23652
- audio.onerror = () => {
23653
- URL.revokeObjectURL(url);
23654
- fail("Could not play the synthesized reply.");
23655
- };
23656
- await audio.play();
24620
+ await playSpeech(res, ac.signal, { bufferMs: bufferMsRef.current });
24621
+ if (ac.signal.aborted) return;
24622
+ speechAbortRef.current = null;
24623
+ setTimeout(() => {
24624
+ if (queueRef.current.length > 0) {
24625
+ void speakReply();
24626
+ } else {
24627
+ apply({
24628
+ kind: "playbackEnded",
24629
+ mode: "conversation",
24630
+ turnComplete: chatStatusRef.current === "idle"
24631
+ });
24632
+ }
24633
+ }, POST_PLAYBACK_MS);
23657
24634
  } catch (err) {
24635
+ if (ac.signal.aborted) return;
23658
24636
  fail(`Synthesis failed: ${err}`);
23659
24637
  }
23660
24638
  }, [apply, fail]);
23661
- (0, import_react21.useEffect)(() => {
24639
+ (0, import_react24.useEffect)(() => {
23662
24640
  if (chatStatus === "streaming") sawStreamingRef.current = true;
23663
24641
  }, [chatStatus]);
23664
- (0, import_react21.useEffect)(() => {
24642
+ (0, import_react24.useEffect)(() => {
23665
24643
  if (modeRef.current !== "conversation") return;
23666
24644
  if (phaseRef.current === "idle") return;
23667
24645
  const { texts, cursor } = takeFinalizedBubbles(items, cursorRef.current);
@@ -23670,7 +24648,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23670
24648
  queueRef.current.push(...texts);
23671
24649
  apply({ kind: "speechQueued", mode: "conversation", canSpeak });
23672
24650
  }, [items, canSpeak, apply]);
23673
- (0, import_react21.useEffect)(() => {
24651
+ (0, import_react24.useEffect)(() => {
23674
24652
  if (phase !== "awaiting") return;
23675
24653
  if (chatStatus === "error") {
23676
24654
  apply({ kind: "failed", mode: "conversation" });
@@ -23692,8 +24670,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23692
24670
  pendingSpeech: queueRef.current.length
23693
24671
  });
23694
24672
  }, [phase, chatStatus, pendingConfirmCount, canSpeak, apply]);
23695
- const prevPhase = (0, import_react21.useRef)("idle");
23696
- (0, import_react21.useEffect)(() => {
24673
+ const prevPhase = (0, import_react24.useRef)("idle");
24674
+ (0, import_react24.useEffect)(() => {
23697
24675
  const from = prevPhase.current;
23698
24676
  prevPhase.current = phase;
23699
24677
  if (from === phase) return;
@@ -23705,14 +24683,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23705
24683
  queueRef.current = [];
23706
24684
  }
23707
24685
  }, [phase, startRecording, speakReply, teardownCapture, stopPlayback]);
23708
- (0, import_react21.useEffect)(
24686
+ (0, import_react24.useEffect)(
23709
24687
  () => () => {
23710
24688
  teardownCapture();
23711
24689
  stopPlayback();
23712
24690
  },
23713
24691
  [teardownCapture, stopPlayback]
23714
24692
  );
23715
- const toggle = (0, import_react21.useCallback)(() => {
24693
+ const toggle = (0, import_react24.useCallback)(() => {
23716
24694
  if (!available) return;
23717
24695
  const current = phaseRef.current;
23718
24696
  if (current === "idle") {
@@ -23726,7 +24704,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23726
24704
  }
23727
24705
  apply({ kind: "userStop", mode: modeRef.current });
23728
24706
  }, [available, apply, finishRecording]);
23729
- const changeMode = (0, import_react21.useCallback)(
24707
+ const changeMode = (0, import_react24.useCallback)(
23730
24708
  (next) => {
23731
24709
  apply({ kind: "userStop", mode: modeRef.current });
23732
24710
  setMode(next);
@@ -23737,34 +24715,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23737
24715
  }
23738
24716
 
23739
24717
  // src/App.tsx
23740
- var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
24718
+ var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
24719
+ function takeInjectedActivation() {
24720
+ const w2 = window;
24721
+ const id = typeof w2.__caretakerAssistant === "string" ? w2.__caretakerAssistant : null;
24722
+ delete w2.__caretakerAssistant;
24723
+ return id;
24724
+ }
23741
24725
  function App({ postMessage, layout = "compact" }) {
23742
- const [chatState, dispatch] = (0, import_react22.useReducer)(chatReducer, initialChatState);
23743
- const [agents, setAgents] = (0, import_react22.useState)([]);
23744
- const [sessions, setSessions] = (0, import_react22.useState)([]);
23745
- const [selectedAgentId, setSelectedAgentId] = (0, import_react22.useState)(null);
23746
- const [selectedSessionId, setSelectedSessionId] = (0, import_react22.useState)(null);
23747
- const [showSessions, setShowSessions] = (0, import_react22.useState)(false);
23748
- const [showAllAgents, setShowAllAgents] = (0, import_react22.useState)(false);
23749
- const [pendingDelete, setPendingDelete] = (0, import_react22.useState)(null);
23750
- const [activeScreen, setActiveScreen] = (0, import_react22.useState)("chat");
23751
- const [settingsTab, setSettingsTab] = (0, import_react22.useState)();
23752
- const [settingsData, setSettingsData] = (0, import_react22.useState)(null);
23753
- const [modelsResult, setModelsResult] = (0, import_react22.useState)(null);
23754
- const [acpRegistry, setAcpRegistry] = (0, import_react22.useState)(null);
23755
- const [acpInstall, setAcpInstall] = (0, import_react22.useState)(null);
23756
- const [refreshingSourceId, setRefreshingSourceId] = (0, import_react22.useState)(null);
23757
- const [refreshOutcome, setRefreshOutcome] = (0, import_react22.useState)(null);
23758
- const [mcpAuthOutcome, setMcpAuthOutcome] = (0, import_react22.useState)(null);
23759
- const [taskRuns, setTaskRuns] = (0, import_react22.useState)({});
23760
- const [voiceConfig, setVoiceConfig] = (0, import_react22.useState)(null);
23761
- const [sttCatalogResult, setSttCatalogResult] = (0, import_react22.useState)(null);
23762
- const [ttsCatalogResult, setTtsCatalogResult] = (0, import_react22.useState)(null);
23763
- const [composerDraft, setComposerDraft] = (0, import_react22.useState)("");
23764
- (0, import_react22.useEffect)(() => {
24726
+ const [chatState, dispatch] = (0, import_react25.useReducer)(chatReducer, initialChatState);
24727
+ const [agents, setAgents] = (0, import_react25.useState)([]);
24728
+ const [sessions, setSessions] = (0, import_react25.useState)([]);
24729
+ const [selectedAgentId, setSelectedAgentId] = (0, import_react25.useState)(null);
24730
+ const [selectedSessionId, setSelectedSessionId] = (0, import_react25.useState)(null);
24731
+ const [showSessions, setShowSessions] = (0, import_react25.useState)(false);
24732
+ const [showAllAgents, setShowAllAgents] = (0, import_react25.useState)(false);
24733
+ const [pendingDelete, setPendingDelete] = (0, import_react25.useState)(null);
24734
+ const [activeScreen, setActiveScreen] = (0, import_react25.useState)("chat");
24735
+ const [settingsTab, setSettingsTab] = (0, import_react25.useState)();
24736
+ const [settingsData, setSettingsData] = (0, import_react25.useState)(null);
24737
+ const [modelsResult, setModelsResult] = (0, import_react25.useState)(null);
24738
+ const [acpRegistry, setAcpRegistry] = (0, import_react25.useState)(null);
24739
+ const [acpInstall, setAcpInstall] = (0, import_react25.useState)(null);
24740
+ const [refreshingSourceId, setRefreshingSourceId] = (0, import_react25.useState)(null);
24741
+ const [refreshOutcome, setRefreshOutcome] = (0, import_react25.useState)(null);
24742
+ const [mcpAuthOutcome, setMcpAuthOutcome] = (0, import_react25.useState)(null);
24743
+ const [taskRuns, setTaskRuns] = (0, import_react25.useState)({});
24744
+ const [voiceConfig, setVoiceConfig] = (0, import_react25.useState)(null);
24745
+ const [sttCatalogResult, setSttCatalogResult] = (0, import_react25.useState)(null);
24746
+ const [ttsCatalogResult, setTtsCatalogResult] = (0, import_react25.useState)(null);
24747
+ const [composerDraft, setComposerDraft] = (0, import_react25.useState)("");
24748
+ const [activation, setActivation] = (0, import_react25.useState)(null);
24749
+ const [confirmedAgentId, setConfirmedAgentId] = (0, import_react25.useState)(null);
24750
+ const [pendingAssistantId, setPendingAssistantId] = (0, import_react25.useState)(() => takeInjectedActivation());
24751
+ const [composerFocusToken, setComposerFocusToken] = (0, import_react25.useState)(0);
24752
+ (0, import_react25.useEffect)(() => {
23765
24753
  postMessage({ type: "webviewReady" });
23766
24754
  }, []);
23767
- (0, import_react22.useEffect)(() => {
24755
+ (0, import_react25.useEffect)(() => {
23768
24756
  function handle(event) {
23769
24757
  const msg = event.data;
23770
24758
  if (!msg || typeof msg !== "object" || !("type" in msg)) return;
@@ -23805,6 +24793,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23805
24793
  return;
23806
24794
  case "error":
23807
24795
  dispatch({ kind: "error", text: msg.message });
24796
+ setActivation(onSelectFailed);
23808
24797
  return;
23809
24798
  case "contextUsage":
23810
24799
  dispatch({ kind: "context-usage", usage: msg.usage });
@@ -23857,11 +24846,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23857
24846
  case "voiceConfig":
23858
24847
  setVoiceConfig(msg.voice);
23859
24848
  return;
24849
+ case "assistantActivate":
24850
+ takeInjectedActivation();
24851
+ setPendingAssistantId(msg.agentId);
24852
+ return;
24853
+ case "agentSelected":
24854
+ setConfirmedAgentId(msg.agentId);
24855
+ setActivation((cur) => onAgentSelected(cur, msg.agentId));
24856
+ return;
23860
24857
  }
23861
24858
  }
23862
24859
  window.addEventListener("message", handle);
23863
24860
  return () => window.removeEventListener("message", handle);
23864
- }, [selectedAgentId]);
24861
+ }, [selectedAgentId, agents]);
23865
24862
  const voice = useVoice({
23866
24863
  voice: voiceConfig,
23867
24864
  chatStatus: chatState.status,
@@ -23887,15 +24884,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23887
24884
  if (voice2) msg.voice = true;
23888
24885
  postMessage(msg);
23889
24886
  };
23890
- const onConfirm = (0, import_react22.useCallback)((id, decision) => {
24887
+ const onConfirm = (0, import_react25.useCallback)((id, decision) => {
23891
24888
  dispatch({ kind: "permission-resolved", id });
23892
24889
  postMessage({ type: "permission_response", id, decision });
23893
24890
  }, [postMessage]);
23894
24891
  const onAbort = () => {
23895
24892
  postMessage({ type: "abort" });
23896
24893
  };
23897
- const confirmCards = (0, import_react22.useMemo)(
23898
- () => chatState.pendingConfirms.map((p) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ConfirmCard, { pending: p, onDecide: onConfirm }, p.id)),
24894
+ const confirmCards = (0, import_react25.useMemo)(
24895
+ () => chatState.pendingConfirms.map((p) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ConfirmCard, { pending: p, onDecide: onConfirm }, p.id)),
23899
24896
  [chatState.pendingConfirms, onConfirm]
23900
24897
  );
23901
24898
  const onSelectAgent = (agentId) => {
@@ -23935,7 +24932,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23935
24932
  const cancelDeleteSession = () => {
23936
24933
  setPendingDelete(null);
23937
24934
  };
23938
- (0, import_react22.useEffect)(() => {
24935
+ (0, import_react25.useEffect)(() => {
23939
24936
  if (!pendingDelete) return;
23940
24937
  function handleKeyDown(event) {
23941
24938
  if (event.key === "Escape") {
@@ -23950,7 +24947,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23950
24947
  setShowSessions(!showSessions);
23951
24948
  }
23952
24949
  };
23953
- (0, import_react22.useEffect)(() => {
24950
+ (0, import_react25.useEffect)(() => {
23954
24951
  function handleClickOutside(event) {
23955
24952
  const target = event.target;
23956
24953
  if (showSessions && !target.closest(".app__sessions-dropdown")) {
@@ -23960,6 +24957,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23960
24957
  document.addEventListener("mousedown", handleClickOutside);
23961
24958
  return () => document.removeEventListener("mousedown", handleClickOutside);
23962
24959
  }, [showSessions]);
24960
+ (0, import_react25.useEffect)(() => {
24961
+ if (!pendingAssistantId) return;
24962
+ const r = resolvePending(pendingAssistantId, confirmedAgentId, agents.map((a2) => a2.id), activation);
24963
+ setPendingAssistantId(r.pending);
24964
+ if (r.pending || r.activation === activation) return;
24965
+ setActiveScreen("chat");
24966
+ if (r.activation?.step === "awaiting-agent") onSelectAgent(r.activation.agentId);
24967
+ setActivation(r.activation);
24968
+ }, [pendingAssistantId, agents]);
24969
+ (0, import_react25.useEffect)(() => {
24970
+ if (activation?.step !== "open") return;
24971
+ const adopt = localSelectionFor(activation, selectedAgentId);
24972
+ if (adopt) {
24973
+ setSelectedAgentId(adopt);
24974
+ setShowAllAgents(false);
24975
+ }
24976
+ onCreateSession();
24977
+ if (voice.available) {
24978
+ voice.setMode("conversation");
24979
+ setActivation({ ...activation, step: "mic" });
24980
+ } else {
24981
+ setComposerFocusToken((t) => t + 1);
24982
+ setActivation(null);
24983
+ }
24984
+ }, [activation]);
24985
+ (0, import_react25.useEffect)(() => {
24986
+ if (activation?.step !== "mic") return;
24987
+ if (voice.mode !== "conversation" || voice.phase !== "idle") return;
24988
+ voice.toggle();
24989
+ setActivation(null);
24990
+ }, [activation, voice.mode, voice.phase]);
23963
24991
  const composerDisabled = chatState.status === "streaming" || chatState.pendingConfirms.length > 0 || !selectedAgentId;
23964
24992
  const selectedAgentName = agents.find((a2) => a2.id === selectedAgentId)?.name;
23965
24993
  const activeAgent = agents.find((a2) => a2.id === selectedAgentId);
@@ -23973,30 +25001,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23973
25001
  { id: "projects", label: "Projects", Icon: FolderKanban },
23974
25002
  { id: "settings", label: "Settings", Icon: Settings }
23975
25003
  ];
23976
- const navRail = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("nav", { className: "app__nav", children: [
23977
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo app__nav-logo" }),
23978
- navItems.map(({ id, label, Icon: Icon2 }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25004
+ const navRail = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("nav", { className: "app__nav", children: [
25005
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo app__nav-logo" }),
25006
+ navItems.map(({ id, label, Icon: Icon2 }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
23979
25007
  "button",
23980
25008
  {
23981
25009
  className: `app__nav-btn ${activeScreen === id ? "app__nav-btn--active" : ""}`,
23982
25010
  onClick: () => openScreen(id),
23983
25011
  title: label,
23984
25012
  children: [
23985
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon2, { size: 18 }),
23986
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: label })
25013
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Icon2, { size: 18 }),
25014
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: label })
23987
25015
  ]
23988
25016
  },
23989
25017
  id
23990
25018
  ))
23991
25019
  ] });
23992
25020
  if (activeScreen === "projects" && layout === "sidebar") {
23993
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
25021
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app app--with-sidebar", children: [
23994
25022
  navRail,
23995
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__screen", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ProjectsTab, { agents, onOpenSettings: () => openScreen("settings", "projects"), postMessage }) })
25023
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__screen", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ProjectsTab, { agents, onOpenSettings: () => openScreen("settings", "projects"), postMessage }) })
23996
25024
  ] });
23997
25025
  }
23998
25026
  if (activeScreen === "settings") {
23999
- const panel = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `app ${layout === "sidebar" ? "app--settings-centered app__screen" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25027
+ const panel = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: `app ${layout === "sidebar" ? "app--settings-centered app__screen" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24000
25028
  SettingsPanel,
24001
25029
  {
24002
25030
  layout,
@@ -24019,44 +25047,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24019
25047
  onClose: () => setActiveScreen("chat")
24020
25048
  }
24021
25049
  ) });
24022
- return layout === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
25050
+ return layout === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app app--with-sidebar", children: [
24023
25051
  navRail,
24024
25052
  panel
24025
25053
  ] }) : panel;
24026
25054
  }
24027
- const deleteOverlay = pendingDelete && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__confirm-overlay", onClick: cancelDeleteSession, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
24028
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__confirm-title", children: "Delete conversation" }),
24029
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { className: "app__confirm-message", children: [
25055
+ const deleteOverlay = pendingDelete && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__confirm-overlay", onClick: cancelDeleteSession, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
25056
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__confirm-title", children: "Delete conversation" }),
25057
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "app__confirm-message", children: [
24030
25058
  "Delete conversation \u201C",
24031
25059
  pendingDelete.title,
24032
25060
  "\u201D? This cannot be undone."
24033
25061
  ] }),
24034
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__confirm-buttons", children: [
24035
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { className: "app__confirm-btn", onClick: cancelDeleteSession, children: "Cancel" }),
24036
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { className: "app__confirm-btn app__confirm-btn--danger", onClick: confirmDeleteSession, children: "Delete" })
25062
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__confirm-buttons", children: [
25063
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { className: "app__confirm-btn", onClick: cancelDeleteSession, children: "Cancel" }),
25064
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { className: "app__confirm-btn app__confirm-btn--danger", onClick: confirmDeleteSession, children: "Delete" })
24037
25065
  ] })
24038
25066
  ] }) });
24039
25067
  if (layout === "sidebar") {
24040
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
25068
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app app--with-sidebar", children: [
24041
25069
  navRail,
24042
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("aside", { className: "app__sidebar", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sidebar-content", children: [
24043
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sidebar-section", children: [
24044
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sidebar-section-title", children: "Agents" }),
24045
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sidebar-agents-list", children: selectedAgentId && !showAllAgents ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25070
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("aside", { className: "app__sidebar", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sidebar-content", children: [
25071
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sidebar-section", children: [
25072
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sidebar-section-title", children: "Agents" }),
25073
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sidebar-agents-list", children: selectedAgentId && !showAllAgents ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24046
25074
  "button",
24047
25075
  {
24048
25076
  className: "app__sidebar-agent-item app__sidebar-agent-item--collapsed-active",
24049
25077
  onClick: () => setShowAllAgents(true),
24050
25078
  title: "Switch Agent",
24051
25079
  children: [
24052
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "agent-status-dot agent-status-dot--active" }),
24053
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__sidebar-agent-name", children: activeAgent?.name || selectedAgentId }),
24054
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChevronDown, { className: "app__sidebar-chevron", size: 10 })
25080
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "agent-status-dot agent-status-dot--active" }),
25081
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__sidebar-agent-name", children: activeAgent?.name || selectedAgentId }),
25082
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ChevronDown, { className: "app__sidebar-chevron", size: 10 })
24055
25083
  ]
24056
25084
  }
24057
- ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `app__sidebar-agents-list-expanded ${selectedAgentId ? "app__sidebar-agents-list-expanded--has-active" : ""}`, children: agents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sidebar-empty-text", children: "No agents found" }) : agents.map((agent) => {
25085
+ ) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: `app__sidebar-agents-list-expanded ${selectedAgentId ? "app__sidebar-agents-list-expanded--has-active" : ""}`, children: agents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sidebar-empty-text", children: "No agents found" }) : agents.map((agent) => {
24058
25086
  const isSelected = selectedAgentId === agent.id;
24059
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25087
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24060
25088
  "button",
24061
25089
  {
24062
25090
  className: `app__sidebar-agent-item ${isSelected ? "app__sidebar-agent-item--active" : ""}`,
@@ -24064,23 +25092,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24064
25092
  if (isSelected) {
24065
25093
  setShowAllAgents(false);
24066
25094
  } else {
25095
+ setActivation(null);
24067
25096
  onSelectAgent(agent.id);
24068
25097
  }
24069
25098
  },
24070
25099
  children: [
24071
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: `agent-status-dot ${isSelected ? "agent-status-dot--active" : ""}` }),
24072
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__sidebar-agent-name", children: agent.name }),
24073
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChevronUp, { className: "app__sidebar-chevron app__sidebar-chevron--up", size: 10 })
25100
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: `agent-status-dot ${isSelected ? "agent-status-dot--active" : ""}` }),
25101
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__sidebar-agent-name", children: agent.name }),
25102
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ChevronUp, { className: "app__sidebar-chevron app__sidebar-chevron--up", size: 10 })
24074
25103
  ]
24075
25104
  },
24076
25105
  agent.id
24077
25106
  );
24078
25107
  }) }) })
24079
25108
  ] }),
24080
- selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sidebar-section", children: [
24081
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sidebar-section-header", children: [
24082
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__sidebar-section-title", children: "Conversations" }),
24083
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25109
+ selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sidebar-section", children: [
25110
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sidebar-section-header", children: [
25111
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__sidebar-section-title", children: "Conversations" }),
25112
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24084
25113
  "button",
24085
25114
  {
24086
25115
  className: "app__sidebar-new-chat-btn",
@@ -24090,15 +25119,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24090
25119
  }
24091
25120
  )
24092
25121
  ] }),
24093
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sidebar-sessions-list", children: sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sidebar-empty-text", children: "No conversations yet" }) : sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25122
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sidebar-sessions-list", children: sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sidebar-empty-text", children: "No conversations yet" }) : sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24094
25123
  "div",
24095
25124
  {
24096
25125
  className: `app__sidebar-session-item ${selectedSessionId === session.id ? "app__sidebar-session-item--active" : ""}`,
24097
25126
  onClick: () => onSelectSession(session.id),
24098
25127
  children: [
24099
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__sidebar-session-icon", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MessageSquare, { size: 13 }) }),
24100
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__sidebar-session-title", title: session.title, children: session.title }),
24101
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25128
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__sidebar-session-icon", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(MessageSquare, { size: 13 }) }),
25129
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__sidebar-session-title", title: session.title, children: session.title }),
25130
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24102
25131
  "button",
24103
25132
  {
24104
25133
  className: "app__sidebar-session-delete",
@@ -24107,7 +25136,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24107
25136
  e.stopPropagation();
24108
25137
  onDeleteSession(session.id, session.title);
24109
25138
  },
24110
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 12 })
25139
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Trash, { size: 12 })
24111
25140
  }
24112
25141
  )
24113
25142
  ]
@@ -24116,15 +25145,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24116
25145
  )) })
24117
25146
  ] })
24118
25147
  ] }) }),
24119
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("main", { className: "app__chat-pane", children: selectedAgentId ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
24120
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("header", { className: "app__chat-header", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__chat-header-info", children: [
24121
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "app__chat-header-title", children: selectedAgentName }),
24122
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "app__chat-header-status", children: [
24123
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: `agent-status-dot agent-status-dot--active ${chatState.status === "streaming" ? "agent-status-dot--pulsing" : ""}` }),
25148
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("main", { className: "app__chat-pane", children: selectedAgentId ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
25149
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("header", { className: "app__chat-header", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__chat-header-info", children: [
25150
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h2", { className: "app__chat-header-title", children: selectedAgentName }),
25151
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "app__chat-header-status", children: [
25152
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: `agent-status-dot agent-status-dot--active ${chatState.status === "streaming" ? "agent-status-dot--pulsing" : ""}` }),
24124
25153
  chatState.status === "streaming" ? "Streaming response..." : "Ready"
24125
25154
  ] })
24126
25155
  ] }) }),
24127
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25156
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24128
25157
  MessageList,
24129
25158
  {
24130
25159
  items: chatState.items,
@@ -24134,15 +25163,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24134
25163
  trailing: confirmCards
24135
25164
  }
24136
25165
  ),
24137
- (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__error", children: [
24138
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TriangleAlert, { size: 14 }),
25166
+ (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__error", children: [
25167
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TriangleAlert, { size: 14 }),
24139
25168
  " ",
24140
25169
  chatState.errorText || voice.error
24141
25170
  ] }),
24142
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25171
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24143
25172
  Composer,
24144
25173
  {
24145
25174
  disabled: composerDisabled,
25175
+ focusToken: composerFocusToken,
24146
25176
  onSend,
24147
25177
  canAbort: chatState.status === "streaming",
24148
25178
  onAbort,
@@ -24158,30 +25188,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24158
25188
  onValueChange: setComposerDraft
24159
25189
  }
24160
25190
  )
24161
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { children: "Select an agent from the sidebar to start chatting" }) }) }),
25191
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { children: "Select an agent from the sidebar to start chatting" }) }) }),
24162
25192
  deleteOverlay
24163
25193
  ] });
24164
25194
  }
24165
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app", children: [
24166
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("header", { className: "app__header", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__header-row", children: [
24167
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__logo-title-wrapper", children: [
24168
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo" }),
24169
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Caretaker" })
25195
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app", children: [
25196
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("header", { className: "app__header", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__header-row", children: [
25197
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__logo-title-wrapper", children: [
25198
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo" }),
25199
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Caretaker" })
24170
25200
  ] }),
24171
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__controls", children: [
24172
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__agent-select-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25201
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__controls", children: [
25202
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__agent-select-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24173
25203
  "select",
24174
25204
  {
24175
25205
  className: "app__agent-select",
24176
25206
  value: selectedAgentId ?? "",
24177
- onChange: (e) => onSelectAgent(e.target.value),
25207
+ onChange: (e) => {
25208
+ setActivation(null);
25209
+ onSelectAgent(e.target.value);
25210
+ },
24178
25211
  children: [
24179
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", disabled: true, children: "-- Select Agent --" }),
24180
- agents.map((agent) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: agent.id, children: agent.name }, agent.id))
25212
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: "", disabled: true, children: "-- Select Agent --" }),
25213
+ agents.map((agent) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("option", { value: agent.id, children: agent.name }, agent.id))
24181
25214
  ]
24182
25215
  }
24183
25216
  ) }),
24184
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25217
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24185
25218
  "button",
24186
25219
  {
24187
25220
  className: "app__sessions-btn",
@@ -24189,13 +25222,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24189
25222
  disabled: !selectedAgentId,
24190
25223
  title: "View conversations",
24191
25224
  children: [
24192
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MessageSquare, { size: 13 }),
25225
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(MessageSquare, { size: 13 }),
24193
25226
  " ",
24194
25227
  sessions.length
24195
25228
  ]
24196
25229
  }
24197
25230
  ),
24198
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25231
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24199
25232
  "button",
24200
25233
  {
24201
25234
  className: "app__new-chat-btn",
@@ -24205,7 +25238,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24205
25238
  children: "+ New"
24206
25239
  }
24207
25240
  ),
24208
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25241
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24209
25242
  "button",
24210
25243
  {
24211
25244
  className: "app__settings-btn",
@@ -24214,24 +25247,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24214
25247
  postMessage({ type: "getSettingsData" });
24215
25248
  },
24216
25249
  title: "Caretaker Settings",
24217
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Settings, { className: "app__settings-icon", size: 14 })
25250
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Settings, { className: "app__settings-icon", size: 14 })
24218
25251
  }
24219
25252
  )
24220
25253
  ] })
24221
25254
  ] }) }),
24222
- showSessions && sessions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sessions-dropdown", children: [
24223
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sessions-title", children: [
25255
+ showSessions && sessions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sessions-dropdown", children: [
25256
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sessions-title", children: [
24224
25257
  "Conversations for ",
24225
25258
  selectedAgentName
24226
25259
  ] }),
24227
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sessions-list", children: sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25260
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sessions-list", children: sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24228
25261
  "div",
24229
25262
  {
24230
25263
  className: `app__session-item ${selectedSessionId === session.id ? "app__session-item--active" : ""}`,
24231
25264
  onClick: () => onSelectSession(session.id),
24232
25265
  children: [
24233
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__session-item-title", children: session.title }),
24234
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25266
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "app__session-item-title", children: session.title }),
25267
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24235
25268
  "button",
24236
25269
  {
24237
25270
  className: "app__session-item-delete",
@@ -24240,7 +25273,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24240
25273
  e.stopPropagation();
24241
25274
  onDeleteSession(session.id, session.title);
24242
25275
  },
24243
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 12 })
25276
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Trash, { size: 12 })
24244
25277
  }
24245
25278
  )
24246
25279
  ]
@@ -24248,12 +25281,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24248
25281
  session.id
24249
25282
  )) })
24250
25283
  ] }),
24251
- showSessions && sessions.length === 0 && selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__sessions-dropdown app__sessions-dropdown--empty", children: [
24252
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sessions-title", children: "No conversations yet" }),
24253
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "app__sessions-empty", children: "Start a new chat to create a conversation" })
25284
+ showSessions && sessions.length === 0 && selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__sessions-dropdown app__sessions-dropdown--empty", children: [
25285
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__sessions-title", children: "No conversations yet" }),
25286
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "app__sessions-empty", children: "Start a new chat to create a conversation" })
24254
25287
  ] }),
24255
- !selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { children: "Select an agent to start chatting" }) }),
24256
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25288
+ !selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { children: "Select an agent to start chatting" }) }),
25289
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24257
25290
  MessageList,
24258
25291
  {
24259
25292
  items: chatState.items,
@@ -24263,15 +25296,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24263
25296
  trailing: confirmCards
24264
25297
  }
24265
25298
  ),
24266
- (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app__error", children: [
24267
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TriangleAlert, { size: 14 }),
25299
+ (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "app__error", children: [
25300
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TriangleAlert, { size: 14 }),
24268
25301
  " ",
24269
25302
  chatState.errorText || voice.error
24270
25303
  ] }),
24271
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25304
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24272
25305
  Composer,
24273
25306
  {
24274
25307
  disabled: composerDisabled,
25308
+ focusToken: composerFocusToken,
24275
25309
  onSend,
24276
25310
  canAbort: chatState.status === "streaming",
24277
25311
  onAbort,
@@ -24292,12 +25326,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24292
25326
  }
24293
25327
 
24294
25328
  // src/standalone.tsx
24295
- var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
25329
+ var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
24296
25330
  function StandaloneApp() {
24297
- const [ws, setWs] = (0, import_react23.useState)(null);
24298
- const [connected, setConnected] = (0, import_react23.useState)(false);
24299
- const [error, setError] = (0, import_react23.useState)(null);
24300
- (0, import_react23.useEffect)(() => {
25331
+ const [ws, setWs] = (0, import_react26.useState)(null);
25332
+ const [connected, setConnected] = (0, import_react26.useState)(false);
25333
+ const [error, setError] = (0, import_react26.useState)(null);
25334
+ (0, import_react26.useEffect)(() => {
24301
25335
  let active = true;
24302
25336
  const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
24303
25337
  const socket = new WebSocket(`${protocol}//${window.location.host}/api/ws`);
@@ -24343,7 +25377,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24343
25377
  }
24344
25378
  };
24345
25379
  if (error) {
24346
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: {
25380
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: {
24347
25381
  display: "flex",
24348
25382
  flexDirection: "column",
24349
25383
  alignItems: "center",
@@ -24355,9 +25389,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24355
25389
  padding: "20px",
24356
25390
  textAlign: "center"
24357
25391
  }, children: [
24358
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { style: { color: "#ff6b6b" }, children: "Caretaker Connection Failed" }),
24359
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: error }),
24360
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
25392
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { style: { color: "#ff6b6b" }, children: "Caretaker Connection Failed" }),
25393
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { children: error }),
25394
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
24361
25395
  "button",
24362
25396
  {
24363
25397
  onClick: () => setWs(null),
@@ -24376,7 +25410,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24376
25410
  ] });
24377
25411
  }
24378
25412
  if (!connected) {
24379
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: {
25413
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: {
24380
25414
  display: "flex",
24381
25415
  flexDirection: "column",
24382
25416
  alignItems: "center",
@@ -24386,7 +25420,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24386
25420
  background: "#1e1e1e",
24387
25421
  color: "#f1f1f1"
24388
25422
  }, children: [
24389
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: {
25423
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { style: {
24390
25424
  border: "4px solid rgba(255,255,255,0.1)",
24391
25425
  width: "36px",
24392
25426
  height: "36px",
@@ -24395,8 +25429,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24395
25429
  animation: "spin 1s linear infinite",
24396
25430
  marginBottom: "16px"
24397
25431
  } }),
24398
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "Connecting to Caretaker server..." }),
24399
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("style", { children: `
25432
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: "Connecting to Caretaker server..." }),
25433
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("style", { children: `
24400
25434
  @keyframes spin {
24401
25435
  0% { transform: rotate(0deg); }
24402
25436
  100% { transform: rotate(360deg); }
@@ -24404,12 +25438,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24404
25438
  ` })
24405
25439
  ] });
24406
25440
  }
24407
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(App, { postMessage, layout: "sidebar" });
25441
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(App, { postMessage, layout: "sidebar" });
24408
25442
  }
24409
25443
  var rootEl = document.getElementById("root");
24410
25444
  if (!rootEl) throw new Error("#root not found");
24411
25445
  (0, import_client.createRoot)(rootEl).render(
24412
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react23.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(StandaloneApp, {}) })
25446
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react26.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(StandaloneApp, {}) })
24413
25447
  );
24414
25448
  })();
24415
25449
  /*! Bundled license information: