@hyperwindmill/caretaker-cli 0.29.0 → 0.30.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 (53) 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_builtin.d.ts +3 -0
  12. package/dist/cli/web/voice_builtin.d.ts.map +1 -0
  13. package/dist/cli/web/voice_builtin.js +55 -0
  14. package/dist/cli/web/voice_proxy.d.ts +33 -1
  15. package/dist/cli/web/voice_proxy.d.ts.map +1 -1
  16. package/dist/cli/web/voice_proxy.js +173 -27
  17. package/dist/commands/loader.js +2 -2
  18. package/dist/harness/tools/builtin/index.d.ts.map +1 -1
  19. package/dist/harness/tools/builtin/index.js +4 -0
  20. package/dist/harness/tools/builtin/set_workspace.d.ts +3 -0
  21. package/dist/harness/tools/builtin/set_workspace.d.ts.map +1 -0
  22. package/dist/harness/tools/builtin/set_workspace.js +49 -0
  23. package/dist/plugins/manifest.d.ts +1 -1
  24. package/dist/plugins/manifest.js +1 -1
  25. package/dist/session/store.d.ts +6 -0
  26. package/dist/session/store.d.ts.map +1 -1
  27. package/dist/session/store.js +8 -0
  28. package/dist/session/types.d.ts +4 -0
  29. package/dist/session/types.d.ts.map +1 -1
  30. package/dist/voice/pocket/catalog.d.ts +24 -0
  31. package/dist/voice/pocket/catalog.d.ts.map +1 -0
  32. package/dist/voice/pocket/catalog.js +152 -0
  33. package/dist/voice/pocket/engine.d.ts +17 -0
  34. package/dist/voice/pocket/engine.d.ts.map +1 -0
  35. package/dist/voice/pocket/engine.js +145 -0
  36. package/dist/voice/pocket/inference.d.ts +36 -0
  37. package/dist/voice/pocket/inference.d.ts.map +1 -0
  38. package/dist/voice/pocket/inference.js +228 -0
  39. package/dist/voice/pocket/install.d.ts +54 -0
  40. package/dist/voice/pocket/install.d.ts.map +1 -0
  41. package/dist/voice/pocket/install.js +275 -0
  42. package/dist/voice/pocket/tokenizer.d.ts +42 -0
  43. package/dist/voice/pocket/tokenizer.d.ts.map +1 -0
  44. package/dist/voice/pocket/tokenizer.js +279 -0
  45. package/dist/voice/pocket/voices.d.ts +9 -0
  46. package/dist/voice/pocket/voices.d.ts.map +1 -0
  47. package/dist/voice/pocket/voices.js +88 -0
  48. package/dist/voice/pronunciation.d.ts +16 -0
  49. package/dist/voice/pronunciation.d.ts.map +1 -0
  50. package/dist/voice/pronunciation.js +51 -0
  51. package/dist/webview/standalone.js +1508 -701
  52. package/dist/webview/standalone.js.map +4 -4
  53. 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_react25 = __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_react24 = __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_react20 = __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_react17 = __toESM(require_react(), 1);
20751
20778
 
20752
20779
  // src/voice_utils.ts
20753
20780
  var END_OF_TURN_MS = 1200;
@@ -20810,7 +20837,12 @@ 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.ttsLanguage ?? "",
20843
+ v2.pronunciationEnabled === true,
20844
+ v2.pronunciation ?? null,
20845
+ v2.playbackBufferMs ?? ""
20814
20846
  ]);
20815
20847
  }
20816
20848
 
@@ -20975,10 +21007,435 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20975
21007
  ] });
20976
21008
  }
20977
21009
 
20978
- // src/VoiceTab.tsx
21010
+ // src/BuiltinVoiceBlock.tsx
21011
+ var import_react16 = __toESM(require_react(), 1);
20979
21012
  var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
20980
- var BACKEND_POLL_MS = 1e4;
20981
- var EMPTY = { enabled: false, endpoint: "", sttModel: "" };
21013
+ var MB = 1024 * 1024;
21014
+ function sizeLabel(bytes) {
21015
+ return `${Math.max(1, Math.round(bytes / MB))} MB`;
21016
+ }
21017
+ function progressText(p) {
21018
+ if (p.step === "done" || p.step === "error") return null;
21019
+ const what = p.step === "runtime" ? "Runtime" : "Voice";
21020
+ const pct = p.total > 0 ? ` ${Math.floor(p.received / p.total * 100)}%` : "";
21021
+ return `${what}: ${p.file}${pct}`;
21022
+ }
21023
+ function BuiltinVoiceBlock({
21024
+ status,
21025
+ onStatusChange,
21026
+ language,
21027
+ onLanguageChange,
21028
+ voice,
21029
+ onVoiceChange
21030
+ }) {
21031
+ const [busy, setBusy] = (0, import_react16.useState)(false);
21032
+ const [progress, setProgress] = (0, import_react16.useState)(null);
21033
+ const [error, setError] = (0, import_react16.useState)(null);
21034
+ const [confirmingDelete, setConfirmingDelete] = (0, import_react16.useState)(false);
21035
+ const loadError = status.runtime.loadError;
21036
+ const selected = status.languages.find((l) => l.id === language);
21037
+ const query = `?language=${encodeURIComponent(language)}`;
21038
+ const voices = selected ? [selected.nativeVoice, ...status.voices.filter((v2) => v2 !== selected.nativeVoice)] : status.voices;
21039
+ const install = async () => {
21040
+ setBusy(true);
21041
+ setError(null);
21042
+ setProgress("Starting\u2026");
21043
+ try {
21044
+ const res = await fetch(`/api/voice/builtin/install${query}`, { method: "POST" });
21045
+ if (!res.ok || !res.body) {
21046
+ setError(await res.text().catch(() => "") || "Install failed.");
21047
+ return;
21048
+ }
21049
+ const reader = res.body.getReader();
21050
+ const decoder = new TextDecoder();
21051
+ let buffer = "";
21052
+ for (; ; ) {
21053
+ const { done, value } = await reader.read();
21054
+ if (done) break;
21055
+ const { lines, remainder } = splitNdjsonLines(buffer, decoder.decode(value, { stream: true }));
21056
+ buffer = remainder;
21057
+ for (const line of lines) {
21058
+ let p;
21059
+ try {
21060
+ p = JSON.parse(line);
21061
+ } catch {
21062
+ continue;
21063
+ }
21064
+ if (p.step === "done") onStatusChange(p.status);
21065
+ else if (p.step === "error") setError(p.message);
21066
+ else setProgress(progressText(p));
21067
+ }
21068
+ }
21069
+ } catch (err) {
21070
+ setError(err instanceof Error ? err.message : String(err));
21071
+ } finally {
21072
+ setBusy(false);
21073
+ setProgress(null);
21074
+ }
21075
+ };
21076
+ const remove = async () => {
21077
+ setConfirmingDelete(false);
21078
+ setBusy(true);
21079
+ setError(null);
21080
+ try {
21081
+ const res = await fetch(`/api/voice/builtin/delete${query}`, { method: "POST" });
21082
+ if (res.ok) onStatusChange(await res.json());
21083
+ else setError(await res.text().catch(() => "") || "Delete failed.");
21084
+ } catch (err) {
21085
+ setError(err instanceof Error ? err.message : String(err));
21086
+ } finally {
21087
+ setBusy(false);
21088
+ }
21089
+ };
21090
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "form-group", children: [
21091
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: "voice-builtin-language", children: [
21092
+ "Built-in voice",
21093
+ " ",
21094
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("em", { children: "(not available on this system)" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("em", { children: "(recommended)" })
21095
+ ] }),
21096
+ loadError ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "form-error", children: loadError }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
21097
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
21098
+ "select",
21099
+ {
21100
+ id: "voice-builtin-language",
21101
+ value: language,
21102
+ onChange: (e) => {
21103
+ onLanguageChange(e.target.value);
21104
+ setConfirmingDelete(false);
21105
+ },
21106
+ children: [
21107
+ !selected && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: language, children: language || "-- Select a language --" }),
21108
+ status.languages.map((l) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("option", { value: l.id, children: [
21109
+ l.id,
21110
+ " (",
21111
+ l.code,
21112
+ ") \u2014 ",
21113
+ l.installed ? "installed" : `not installed, ${sizeLabel(l.bytes)}`
21114
+ ] }, l.id))
21115
+ ]
21116
+ }
21117
+ ),
21118
+ selected && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "voice-backend-status", children: [
21119
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: progress ?? (selected.installed ? `Installed (${sizeLabel(selected.bytes)})` : `Not installed \u2014 downloads ${sizeLabel(selected.bytes)}`) }),
21120
+ !selected.installed && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", onClick: install, disabled: busy, children: busy ? "Installing\u2026" : "Install" }),
21121
+ selected.installed && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21122
+ "button",
21123
+ {
21124
+ type: "button",
21125
+ onClick: confirmingDelete ? remove : () => setConfirmingDelete(true),
21126
+ disabled: busy,
21127
+ children: confirmingDelete ? "Really delete?" : "Delete"
21128
+ }
21129
+ )
21130
+ ] }),
21131
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { className: "form-error", children: error }),
21132
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: "voice-builtin-voice", style: { marginTop: "0.6em" }, children: "Voice" }),
21133
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("select", { id: "voice-builtin-voice", value: voice, onChange: (e) => onVoiceChange(e.target.value), children: [
21134
+ voice && !voices.includes(voice) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: voice, children: voice }),
21135
+ voices.map((v2) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: v2, children: v2 }, v2))
21136
+ ] }),
21137
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Runs inside caretaker \u2014 no server or Docker. Speaking rate is not adjustable with this engine." })
21138
+ ] }),
21139
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21140
+ "Voice model",
21141
+ " ",
21142
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { href: "https://huggingface.co/kyutai/pocket-tts", target: "_blank", rel: "noreferrer", children: "Pocket TTS" }),
21143
+ " ",
21144
+ "by Kyutai, via the",
21145
+ " ",
21146
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21147
+ "a",
21148
+ {
21149
+ href: "https://huggingface.co/Alias-Alias/pocket-3-3-0-tts-onnx",
21150
+ target: "_blank",
21151
+ rel: "noreferrer",
21152
+ children: "ONNX export"
21153
+ }
21154
+ ),
21155
+ ", licensed CC BY 4.0."
21156
+ ] })
21157
+ ] });
21158
+ }
21159
+
21160
+ // src/PronunciationTable.tsx
21161
+ var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
21162
+ function PronunciationTable({
21163
+ code,
21164
+ entries,
21165
+ enabled,
21166
+ onEnabledChange,
21167
+ onChange,
21168
+ onRestoreDefaults,
21169
+ onListen,
21170
+ listening,
21171
+ listenError
21172
+ }) {
21173
+ const update = (i, patch) => onChange(entries.map((e, j) => j === i ? { ...e, ...patch } : e));
21174
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "form-group", children: [
21175
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "form-group--checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("label", { htmlFor: "voice-pron-enabled", children: [
21176
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21177
+ "input",
21178
+ {
21179
+ id: "voice-pron-enabled",
21180
+ type: "checkbox",
21181
+ checked: enabled,
21182
+ onChange: (e) => onEnabledChange(e.target.checked)
21183
+ }
21184
+ ),
21185
+ "Pronunciation dictionary"
21186
+ ] }) }),
21187
+ code === null ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("small", { children: "Set a language above to edit its dictionary." }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
21188
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("small", { children: [
21189
+ "Words below are respelled before synthesis (whole word, case-insensitive, longest first) for language ",
21190
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { children: code }),
21191
+ ". Listen uses the unsaved form."
21192
+ ] }),
21193
+ entries.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "voice-backend-status", children: [
21194
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21195
+ "input",
21196
+ {
21197
+ type: "text",
21198
+ "aria-label": "Term",
21199
+ placeholder: "term",
21200
+ value: e.term,
21201
+ onChange: (ev) => update(i, { term: ev.target.value })
21202
+ }
21203
+ ),
21204
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21205
+ "input",
21206
+ {
21207
+ type: "text",
21208
+ "aria-label": "Spoken as",
21209
+ placeholder: "spoken as",
21210
+ value: e.say,
21211
+ onChange: (ev) => update(i, { say: ev.target.value })
21212
+ }
21213
+ ),
21214
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
21215
+ "button",
21216
+ {
21217
+ type: "button",
21218
+ disabled: listening || !e.term.trim(),
21219
+ onClick: () => onListen(e.term.trim()),
21220
+ children: "Listen"
21221
+ }
21222
+ ),
21223
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: () => onChange(entries.filter((_2, j) => j !== i)), children: "Remove" })
21224
+ ] }, i)),
21225
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "voice-backend-status", children: [
21226
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: () => onChange([...entries, { term: "", say: "" }]), children: "Add word" }),
21227
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", onClick: onRestoreDefaults, children: "Restore defaults" })
21228
+ ] })
21229
+ ] }),
21230
+ listenError && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("small", { className: "form-error", children: [
21231
+ "Listen failed: ",
21232
+ listenError
21233
+ ] })
21234
+ ] });
21235
+ }
21236
+
21237
+ // src/voice_stream.ts
21238
+ function parsePcmType(contentType) {
21239
+ if (!contentType) return null;
21240
+ const [type, ...params] = contentType.split(";").map((s) => s.trim().toLowerCase());
21241
+ if (type !== "audio/pcm" && type !== "audio/l16") return null;
21242
+ const get = (key) => {
21243
+ const p = params.find((x) => x.startsWith(`${key}=`));
21244
+ return p ? Number(p.slice(key.length + 1)) : NaN;
21245
+ };
21246
+ const rate = get("rate");
21247
+ const channels = get("channels");
21248
+ return {
21249
+ rate: Number.isFinite(rate) && rate > 0 ? rate : 24e3,
21250
+ channels: Number.isFinite(channels) && channels > 0 ? channels : 1
21251
+ };
21252
+ }
21253
+ function pcm16Chunk(bytes, carry) {
21254
+ let data = bytes;
21255
+ if (carry && carry.length > 0) {
21256
+ data = new Uint8Array(carry.length + bytes.length);
21257
+ data.set(carry, 0);
21258
+ data.set(bytes, carry.length);
21259
+ }
21260
+ const count = data.length >> 1;
21261
+ const samples = new Float32Array(count);
21262
+ for (let i = 0; i < count; i++) {
21263
+ const v2 = data[2 * i] | data[2 * i + 1] << 8;
21264
+ samples[i] = (v2 >= 32768 ? v2 - 65536 : v2) / 32768;
21265
+ }
21266
+ return { samples, carry: data.length & 1 ? data.slice(data.length - 1) : null };
21267
+ }
21268
+ function nextStart(now, cursor, bufferSeconds2) {
21269
+ return cursor > now + MIN_AHEAD_SECONDS ? cursor : now + bufferSeconds2;
21270
+ }
21271
+ var MIN_AHEAD_SECONDS = 0.01;
21272
+ var DEFAULT_PLAYBACK_BUFFER_MS = 500;
21273
+ var MAX_PLAYBACK_BUFFER_MS = 5e3;
21274
+ function bufferSeconds(ms) {
21275
+ const v2 = Number.isFinite(ms) ? ms : DEFAULT_PLAYBACK_BUFFER_MS;
21276
+ return Math.min(Math.max(v2, 0), MAX_PLAYBACK_BUFFER_MS) / 1e3;
21277
+ }
21278
+ function choosePath(contentType, mseSupports) {
21279
+ if (parsePcmType(contentType)) return "pcm";
21280
+ const type = (contentType ?? "").split(";")[0].trim().toLowerCase();
21281
+ if (type === "audio/mpeg" && mseSupports("audio/mpeg")) return "mse";
21282
+ return "buffered";
21283
+ }
21284
+
21285
+ // src/speech_player.ts
21286
+ async function playSpeech(res, signal, opts = {}) {
21287
+ if (signal.aborted) return;
21288
+ const buffer = bufferSeconds(opts.bufferMs);
21289
+ const contentType = res.headers.get("content-type");
21290
+ const path = choosePath(contentType, (t) => typeof MediaSource !== "undefined" && MediaSource.isTypeSupported(t));
21291
+ if (path === "pcm" && res.body) return playPcm(res, signal, parsePcmType(contentType), buffer);
21292
+ if (path === "mse" && res.body) return playMse(res, signal, buffer);
21293
+ return playBuffered(res, signal);
21294
+ }
21295
+ async function playPcm(res, signal, fmt, buffer) {
21296
+ const ctx = new AudioContext();
21297
+ const reader = res.body.getReader();
21298
+ const sources = [];
21299
+ const onAbort = () => {
21300
+ void reader.cancel().catch(() => {
21301
+ });
21302
+ for (const s of sources) {
21303
+ s.onended = null;
21304
+ try {
21305
+ s.stop();
21306
+ } catch {
21307
+ }
21308
+ }
21309
+ };
21310
+ signal.addEventListener("abort", onAbort, { once: true });
21311
+ try {
21312
+ await ctx.resume();
21313
+ let carry = null;
21314
+ let rest = new Float32Array(0);
21315
+ let cursor = 0;
21316
+ let last = null;
21317
+ for (; ; ) {
21318
+ const { done, value } = await reader.read();
21319
+ if (signal.aborted) return;
21320
+ if (done) break;
21321
+ const out = pcm16Chunk(value, carry);
21322
+ carry = out.carry;
21323
+ let samples = out.samples;
21324
+ if (rest.length) {
21325
+ const joined = new Float32Array(rest.length + samples.length);
21326
+ joined.set(rest, 0);
21327
+ joined.set(samples, rest.length);
21328
+ samples = joined;
21329
+ }
21330
+ const frames = Math.floor(samples.length / fmt.channels);
21331
+ rest = samples.slice(frames * fmt.channels);
21332
+ if (frames === 0) continue;
21333
+ const buf = ctx.createBuffer(fmt.channels, frames, fmt.rate);
21334
+ for (let c2 = 0; c2 < fmt.channels; c2++) {
21335
+ const ch = buf.getChannelData(c2);
21336
+ for (let i = 0; i < frames; i++) ch[i] = samples[i * fmt.channels + c2];
21337
+ }
21338
+ const src = ctx.createBufferSource();
21339
+ src.buffer = buf;
21340
+ src.connect(ctx.destination);
21341
+ const at2 = nextStart(ctx.currentTime, cursor, buffer);
21342
+ src.start(at2);
21343
+ cursor = at2 + buf.duration;
21344
+ sources.push(src);
21345
+ last = src;
21346
+ }
21347
+ if (!last) return;
21348
+ const latency = (ctx.outputLatency || 0) + (ctx.baseLatency || 0);
21349
+ const remainingMs = Math.max(0, (cursor - ctx.currentTime + latency) * 1e3);
21350
+ await new Promise((resolve) => {
21351
+ const timer = setTimeout(resolve, remainingMs);
21352
+ signal.addEventListener("abort", () => (clearTimeout(timer), resolve()), { once: true });
21353
+ });
21354
+ } finally {
21355
+ signal.removeEventListener("abort", onAbort);
21356
+ void ctx.close().catch(() => {
21357
+ });
21358
+ }
21359
+ }
21360
+ async function playMse(res, signal, buffer) {
21361
+ const ms = new MediaSource();
21362
+ const url = URL.createObjectURL(ms);
21363
+ const audio = new Audio(url);
21364
+ const reader = res.body.getReader();
21365
+ const onAbort = () => {
21366
+ void reader.cancel().catch(() => {
21367
+ });
21368
+ audio.pause();
21369
+ };
21370
+ signal.addEventListener("abort", onAbort, { once: true });
21371
+ try {
21372
+ await new Promise((resolve) => ms.addEventListener("sourceopen", () => resolve(), { once: true }));
21373
+ const sb = ms.addSourceBuffer("audio/mpeg");
21374
+ const append = (data) => new Promise((resolve, reject) => {
21375
+ sb.addEventListener("updateend", () => resolve(), { once: true });
21376
+ sb.addEventListener("error", () => reject(new Error("Could not decode the synthesized reply.")), { once: true });
21377
+ sb.appendBuffer(data);
21378
+ });
21379
+ let failPlayback;
21380
+ const ended = new Promise((resolve, reject) => {
21381
+ failPlayback = reject;
21382
+ audio.onended = () => resolve();
21383
+ audio.onerror = () => reject(new Error("Could not play the synthesized reply."));
21384
+ signal.addEventListener("abort", () => resolve(), { once: true });
21385
+ });
21386
+ ended.catch(() => {
21387
+ });
21388
+ let started = false;
21389
+ const start = () => {
21390
+ started = true;
21391
+ audio.play().catch((e) => !signal.aborted && failPlayback(e));
21392
+ };
21393
+ for (; ; ) {
21394
+ const { done, value } = await reader.read();
21395
+ if (signal.aborted) return;
21396
+ if (done) break;
21397
+ await append(value);
21398
+ if (signal.aborted) return;
21399
+ if (!started && bufferedEnd(sb) >= buffer) start();
21400
+ }
21401
+ if (!started && bufferedEnd(sb) > 0) start();
21402
+ if (!started) return;
21403
+ if (ms.readyState === "open") ms.endOfStream();
21404
+ await ended;
21405
+ } finally {
21406
+ signal.removeEventListener("abort", onAbort);
21407
+ audio.pause();
21408
+ audio.removeAttribute("src");
21409
+ URL.revokeObjectURL(url);
21410
+ }
21411
+ }
21412
+ async function playBuffered(res, signal) {
21413
+ const blob = await res.blob();
21414
+ if (signal.aborted) return;
21415
+ const url = URL.createObjectURL(blob);
21416
+ const audio = new Audio(url);
21417
+ const onAbort = () => audio.pause();
21418
+ signal.addEventListener("abort", onAbort, { once: true });
21419
+ try {
21420
+ const ended = new Promise((resolve, reject) => {
21421
+ audio.onended = () => resolve();
21422
+ audio.onerror = () => reject(new Error("Could not play the synthesized reply."));
21423
+ signal.addEventListener("abort", () => resolve(), { once: true });
21424
+ });
21425
+ await audio.play();
21426
+ await ended;
21427
+ } finally {
21428
+ signal.removeEventListener("abort", onAbort);
21429
+ audio.pause();
21430
+ audio.removeAttribute("src");
21431
+ URL.revokeObjectURL(url);
21432
+ }
21433
+ }
21434
+ function bufferedEnd(sb) {
21435
+ return sb.buffered.length ? sb.buffered.end(sb.buffered.length - 1) : 0;
21436
+ }
21437
+
21438
+ // src/voice_tab_presets.ts
20982
21439
  var LOCAL_DEFAULTS = {
20983
21440
  endpoint: "http://127.0.0.1:8969/v1",
20984
21441
  sttModel: "Systran/faster-whisper-small",
@@ -20990,6 +21447,47 @@ Please report this to https://github.com/markedjs/marked.`, e) {
20990
21447
  ttsModel: "tts-1",
20991
21448
  ttsVoice: "it-IT-ElsaNeural"
20992
21449
  };
21450
+ function pocketLanguageFor(bcp47, status) {
21451
+ const primary = (bcp47 ?? "").trim().toLowerCase().split(/[-_]/)[0];
21452
+ const hit = primary ? status.languages.find((l) => l.code === primary) : void 0;
21453
+ return hit?.id ?? "english";
21454
+ }
21455
+ function builtinPreset(lang, status) {
21456
+ const id = pocketLanguageFor(lang, status);
21457
+ const entry = status.languages.find((l) => l.id === id);
21458
+ return {
21459
+ ttsEngine: "builtin",
21460
+ ttsLanguage: id,
21461
+ ttsVoice: entry?.nativeVoice ?? status.voices[0] ?? "",
21462
+ pronunciationEnabled: true
21463
+ };
21464
+ }
21465
+ function edgePreset() {
21466
+ return { ...EDGE_TTS_DEFAULTS, ttsEngine: "endpoint", pronunciationEnabled: false };
21467
+ }
21468
+ function localDefaultsPreset(lang, status) {
21469
+ const stt = { enabled: true, endpoint: LOCAL_DEFAULTS.endpoint, sttModel: LOCAL_DEFAULTS.sttModel };
21470
+ if (status && !status.runtime.loadError) return { ...stt, ...builtinPreset(lang, status) };
21471
+ return {
21472
+ ...stt,
21473
+ ttsEngine: "endpoint",
21474
+ ttsModel: LOCAL_DEFAULTS.ttsModel,
21475
+ ttsVoice: LOCAL_DEFAULTS.ttsVoice
21476
+ };
21477
+ }
21478
+
21479
+ // src/VoiceTab.tsx
21480
+ var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
21481
+ function parsedBufferMs(v2) {
21482
+ const n = Number.parseInt(v2, 10);
21483
+ return Number.isFinite(n) ? Math.min(Math.max(n, 0), MAX_PLAYBACK_BUFFER_MS) : void 0;
21484
+ }
21485
+ var BACKEND_POLL_MS = 1e4;
21486
+ var EMPTY = { enabled: false, endpoint: "", sttModel: "" };
21487
+ var SAMPLES = {
21488
+ it: "Ciao, questa \xE8 una prova della voce.",
21489
+ en: "Hello, this is a test of the voice."
21490
+ };
20993
21491
  function withCurrent(ids, current) {
20994
21492
  const trimmed = current.trim();
20995
21493
  if (!trimmed || ids.includes(trimmed)) return ids;
@@ -21001,24 +21499,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21001
21499
  }
21002
21500
  function VoiceTab({ config, onSave, postMessage, sttCatalogResult, ttsCatalogResult }) {
21003
21501
  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)(
21502
+ const [enabled, setEnabled] = (0, import_react17.useState)(current.enabled);
21503
+ const [endpoint, setEndpoint] = (0, import_react17.useState)(current.endpoint);
21504
+ const [apiKey, setApiKey] = (0, import_react17.useState)(current.apiKey ?? "");
21505
+ const [sttModel, setSttModel] = (0, import_react17.useState)(current.sttModel);
21506
+ const [ttsEndpoint, setTtsEndpoint] = (0, import_react17.useState)(current.ttsEndpoint ?? "");
21507
+ const [ttsApiKey, setTtsApiKey] = (0, import_react17.useState)(current.ttsApiKey ?? "");
21508
+ const [ttsModel, setTtsModel] = (0, import_react17.useState)(current.ttsModel ?? "");
21509
+ const [ttsVoice, setTtsVoice] = (0, import_react17.useState)(current.ttsVoice ?? "");
21510
+ const [ttsSpeed, setTtsSpeed] = (0, import_react17.useState)(
21013
21511
  current.ttsSpeed === void 0 ? "" : String(current.ttsSpeed)
21014
21512
  );
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);
21513
+ const [lang, setLang] = (0, import_react17.useState)(current.lang ?? "");
21514
+ const [bufferMs, setBufferMs] = (0, import_react17.useState)(
21515
+ current.playbackBufferMs === void 0 ? "" : String(current.playbackBufferMs)
21516
+ );
21517
+ const [ttsEngine, setTtsEngine] = (0, import_react17.useState)(current.ttsEngine ?? "endpoint");
21518
+ const [ttsLanguage, setTtsLanguage] = (0, import_react17.useState)(current.ttsLanguage ?? "");
21519
+ const [pronEnabled, setPronEnabled] = (0, import_react17.useState)(current.pronunciationEnabled ?? false);
21520
+ const [pronunciation, setPronunciation] = (0, import_react17.useState)(
21521
+ current.pronunciation ?? {}
21522
+ );
21523
+ const [builtinStatus, setBuiltinStatus] = (0, import_react17.useState)(null);
21524
+ const [listening, setListening] = (0, import_react17.useState)(false);
21525
+ const [listenError, setListenError] = (0, import_react17.useState)(null);
21526
+ const listenAbort = (0, import_react17.useRef)(null);
21527
+ const [fetching, setFetching] = (0, import_react17.useState)(false);
21528
+ const [fetchingTts, setFetchingTts] = (0, import_react17.useState)(false);
21529
+ const [saveState, setSaveState] = (0, import_react17.useState)("idle");
21530
+ const pendingSave = (0, import_react17.useRef)(null);
21531
+ const [autoStartBackend, setAutoStartBackend] = (0, import_react17.useState)(current.autoStartBackend ?? false);
21532
+ const [backendStatuses, setBackendStatuses] = (0, import_react17.useState)(null);
21022
21533
  const fetchBackendStatuses = async () => {
21023
21534
  try {
21024
21535
  const res = await fetch("/api/voice/backend");
@@ -21028,7 +21539,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21028
21539
  } catch {
21029
21540
  }
21030
21541
  };
21031
- (0, import_react16.useEffect)(() => {
21542
+ (0, import_react17.useEffect)(() => {
21543
+ fetch("/api/voice/builtin").then((res) => res.ok ? res.json() : null).then((st2) => st2 && setBuiltinStatus(st2)).catch(() => {
21544
+ });
21545
+ return () => listenAbort.current?.abort();
21546
+ }, []);
21547
+ (0, import_react17.useEffect)(() => {
21032
21548
  fetchBackendStatuses();
21033
21549
  const interval = setInterval(fetchBackendStatuses, BACKEND_POLL_MS);
21034
21550
  return () => clearInterval(interval);
@@ -21038,23 +21554,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21038
21554
  (prev) => prev ? { ...prev, [target]: status } : { stt: status, tts: null }
21039
21555
  );
21040
21556
  };
21041
- (0, import_react16.useEffect)(() => {
21557
+ (0, import_react17.useEffect)(() => {
21042
21558
  if (sttCatalogResult) setFetching(false);
21043
21559
  }, [sttCatalogResult]);
21044
- (0, import_react16.useEffect)(() => {
21560
+ (0, import_react17.useEffect)(() => {
21045
21561
  if (ttsCatalogResult) setFetchingTts(false);
21046
21562
  }, [ttsCatalogResult]);
21047
- (0, import_react16.useEffect)(() => {
21563
+ (0, import_react17.useEffect)(() => {
21048
21564
  if (saveState !== "saving" || pendingSave.current === null) return;
21049
21565
  if (voiceSignature(config.voice) !== pendingSave.current) return;
21050
21566
  setSaveState("saved");
21051
21567
  }, [config.voice, saveState]);
21052
- (0, import_react16.useEffect)(() => {
21568
+ (0, import_react17.useEffect)(() => {
21053
21569
  if (saveState !== "saved") return;
21054
21570
  const clear = setTimeout(() => setSaveState("idle"), 2500);
21055
21571
  return () => clearTimeout(clear);
21056
21572
  }, [saveState]);
21057
- (0, import_react16.useEffect)(() => {
21573
+ (0, import_react17.useEffect)(() => {
21058
21574
  if (saveState !== "saving") return;
21059
21575
  const giveUp = setTimeout(() => setSaveState("idle"), 6e3);
21060
21576
  return () => clearTimeout(giveUp);
@@ -21083,6 +21599,62 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21083
21599
  });
21084
21600
  };
21085
21601
  const voicesForModel = ttsCatalog?.tts.find((m2) => m2.id === ttsModel.trim())?.voices ?? [];
21602
+ const applyPreset = (p) => {
21603
+ if (p.enabled !== void 0) setEnabled(p.enabled);
21604
+ if (p.endpoint !== void 0) setEndpoint(p.endpoint);
21605
+ if (p.sttModel !== void 0) setSttModel(p.sttModel);
21606
+ if (p.ttsEngine !== void 0) setTtsEngine(p.ttsEngine);
21607
+ if (p.ttsLanguage !== void 0) setTtsLanguage(p.ttsLanguage);
21608
+ if (p.ttsEndpoint !== void 0) setTtsEndpoint(p.ttsEndpoint);
21609
+ if (p.ttsModel !== void 0) setTtsModel(p.ttsModel);
21610
+ if (p.ttsVoice !== void 0) setTtsVoice(p.ttsVoice);
21611
+ if (p.pronunciationEnabled !== void 0) setPronEnabled(p.pronunciationEnabled);
21612
+ };
21613
+ const builtin = ttsEngine === "builtin";
21614
+ const synthCode = (0, import_react17.useMemo)(() => {
21615
+ if (builtin) return builtinStatus?.languages.find((l) => l.id === ttsLanguage)?.code ?? null;
21616
+ return lang.trim().split(/[-_]/)[0].toLowerCase() || null;
21617
+ }, [builtin, builtinStatus, ttsLanguage, lang]);
21618
+ const pronEntries = synthCode ? pronunciation[synthCode] ?? builtinStatus?.defaults[synthCode] ?? [] : [];
21619
+ const stopListening = () => listenAbort.current?.abort();
21620
+ const listen = async (text) => {
21621
+ const code = synthCode ?? "en";
21622
+ const sample = text ? `${text}.` : SAMPLES[code] ?? SAMPLES.en;
21623
+ const speed = Number.parseFloat(ttsSpeed);
21624
+ const ac = new AbortController();
21625
+ listenAbort.current = ac;
21626
+ setListening(true);
21627
+ setListenError(null);
21628
+ try {
21629
+ const res = await fetch("/api/voice/preview", {
21630
+ method: "POST",
21631
+ headers: { "content-type": "application/json" },
21632
+ signal: ac.signal,
21633
+ body: JSON.stringify({
21634
+ text: sample,
21635
+ settings: {
21636
+ ttsEngine,
21637
+ ttsLanguage,
21638
+ ttsVoice: ttsVoice.trim(),
21639
+ ttsModel: ttsModel.trim(),
21640
+ ttsSpeed: Number.isFinite(speed) && speed > 0 ? speed : void 0,
21641
+ ttsEndpoint: ttsEndpoint.trim(),
21642
+ pronunciationEnabled: pronEnabled,
21643
+ pronunciation: synthCode ? pronEntries.filter((e) => e.term.trim()) : void 0
21644
+ }
21645
+ })
21646
+ });
21647
+ if (!res.ok) {
21648
+ setListenError(await res.text().catch(() => "") || `HTTP ${res.status}`);
21649
+ return;
21650
+ }
21651
+ await playSpeech(res, ac.signal, { bufferMs: parsedBufferMs(bufferMs) });
21652
+ } catch (err) {
21653
+ if (!ac.signal.aborted) setListenError(err instanceof Error ? err.message : String(err));
21654
+ } finally {
21655
+ setListening(false);
21656
+ }
21657
+ };
21086
21658
  const save = () => {
21087
21659
  const voice = { enabled, endpoint: endpoint.trim(), sttModel: sttModel.trim() };
21088
21660
  if (apiKey.trim()) voice.apiKey = apiKey.trim();
@@ -21095,34 +21667,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21095
21667
  voice.ttsSpeed = Math.min(Math.max(speed, 0.5), 2);
21096
21668
  }
21097
21669
  if (lang.trim()) voice.lang = lang.trim();
21670
+ const buf = parsedBufferMs(bufferMs);
21671
+ if (buf !== void 0) voice.playbackBufferMs = buf;
21098
21672
  if (autoStartBackend) voice.autoStartBackend = true;
21673
+ if (builtin) {
21674
+ voice.ttsEngine = "builtin";
21675
+ if (ttsLanguage) voice.ttsLanguage = ttsLanguage;
21676
+ }
21677
+ if (pronEnabled) voice.pronunciationEnabled = true;
21678
+ const dict = {};
21679
+ for (const [code, entries] of Object.entries(pronunciation)) {
21680
+ dict[code] = entries.filter((e) => e.term.trim());
21681
+ }
21682
+ if (Object.keys(dict).length) voice.pronunciation = dict;
21099
21683
  pendingSave.current = voiceSignature(voice);
21100
21684
  setSaveState("saving");
21101
21685
  onSave({ ...config, voice });
21102
21686
  };
21103
21687
  const showSttBackend = backendStatuses !== null && backendStatuses.stt.docker !== "absent" && backendStatuses.stt.port !== null;
21104
21688
  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." })
21689
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "glass-form", children: [
21690
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h4", { children: "Voice" }),
21691
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "glass-form__body", children: [
21692
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21693
+ builtinStatus && !builtinStatus.runtime.loadError && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: () => applyPreset(builtinPreset(lang, builtinStatus)), children: "Use built-in voice (recommended)" }),
21694
+ " ",
21695
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: () => applyPreset(localDefaultsPreset(lang, builtinStatus)), children: "Use local defaults" }),
21696
+ " ",
21697
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: () => applyPreset(edgePreset()), children: "Use Microsoft Edge voices" }),
21698
+ /* @__PURE__ */ (0, import_jsx_runtime16.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
21699
  ] }),
21125
- showSttBackend && backendStatuses && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21700
+ showSttBackend && backendStatuses && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21126
21701
  VoiceBackendBlock,
21127
21702
  {
21128
21703
  target: "stt",
@@ -21132,7 +21707,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21132
21707
  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
21708
  }
21134
21709
  ),
21135
- showTtsBackend && backendStatuses?.tts && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21710
+ showTtsBackend && backendStatuses?.tts && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21136
21711
  VoiceBackendBlock,
21137
21712
  {
21138
21713
  target: "tts",
@@ -21142,9 +21717,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21142
21717
  hint: "A small image. The container publishes on the port in your synthesis endpoint. Delete removes the container; the image stays cached."
21143
21718
  }
21144
21719
  ),
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)(
21720
+ (showSttBackend || showTtsBackend) && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group form-group--checkbox", children: [
21721
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { htmlFor: "voice-backend-autostart", children: [
21722
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21148
21723
  "input",
21149
21724
  {
21150
21725
  id: "voice-backend-autostart",
@@ -21155,10 +21730,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21155
21730
  ),
21156
21731
  "Start automatically with caretaker"
21157
21732
  ] }),
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." })
21733
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Applies to both containers: a Speaches pull does not block the edge-tts start \u2014 they are independent." })
21159
21734
  ] }),
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)(
21735
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "form-group form-group--checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { htmlFor: "voice-enabled", children: [
21736
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21162
21737
  "input",
21163
21738
  {
21164
21739
  id: "voice-enabled",
@@ -21169,9 +21744,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21169
21744
  ),
21170
21745
  "Enable voice mode"
21171
21746
  ] }) }),
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)(
21747
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21748
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-endpoint", children: "Speech Endpoint" }),
21749
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21175
21750
  "input",
21176
21751
  {
21177
21752
  id: "voice-endpoint",
@@ -21181,18 +21756,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21181
21756
  onChange: (e) => setEndpoint(e.target.value)
21182
21757
  }
21183
21758
  ),
21184
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { children: [
21759
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { children: [
21185
21760
  "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" }),
21761
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: "/audio/transcriptions" }),
21187
21762
  ". When no separate synthesis endpoint is set below, synthesis also posts to",
21188
21763
  " ",
21189
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { children: "/audio/speech" }),
21764
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: "/audio/speech" }),
21190
21765
  " here. Voice is unavailable in the VSCode sidebar."
21191
21766
  ] })
21192
21767
  ] }),
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)(
21768
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21769
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-key", children: "API Key (optional)" }),
21770
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21196
21771
  "input",
21197
21772
  {
21198
21773
  id: "voice-key",
@@ -21202,30 +21777,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21202
21777
  onChange: (e) => setApiKey(e.target.value)
21203
21778
  }
21204
21779
  ),
21205
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: "Stored encrypted. Never sent to the browser \u2014 requests are proxied." })
21780
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Stored encrypted. Never sent to the browser \u2014 requests are proxied." })
21206
21781
  ] }),
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: [
21782
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21783
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: fetchSttCatalog, disabled: fetching || !endpoint.trim(), children: fetching ? "Fetching\u2026" : "Fetch models" }),
21784
+ /* @__PURE__ */ (0, import_jsx_runtime16.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." }),
21785
+ sttFetchError && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { className: "form-error", children: [
21211
21786
  "Fetch failed: ",
21212
21787
  sttFetchError
21213
21788
  ] })
21214
21789
  ] }),
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)(
21790
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21791
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-stt", children: "Transcription Model" }),
21792
+ sttCatalog && sttCatalog.stt.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
21218
21793
  "select",
21219
21794
  {
21220
21795
  id: "voice-stt",
21221
21796
  value: sttModel,
21222
21797
  onChange: (e) => setSttModel(e.target.value),
21223
21798
  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))
21799
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "-- Select a model --" }),
21800
+ withCurrent(sttCatalog.stt, sttModel).map((id) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: id, children: id }, id))
21226
21801
  ]
21227
21802
  }
21228
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
21803
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21229
21804
  "input",
21230
21805
  {
21231
21806
  id: "voice-stt",
@@ -21236,153 +21811,185 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21236
21811
  }
21237
21812
  )
21238
21813
  ] }),
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."
21271
- ] })
21272
- ] }),
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
- "."
21301
- ] }),
21302
- ttsFetchError && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("small", { className: "form-error", children: [
21303
- "Fetch failed: ",
21304
- ttsFetchError
21305
- ] })
21306
- ] }),
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)(
21814
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21815
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-engine", children: "Synthesis engine" }),
21816
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
21310
21817
  "select",
21311
21818
  {
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
- },
21819
+ id: "voice-engine",
21820
+ value: ttsEngine,
21821
+ onChange: (e) => setTtsEngine(e.target.value),
21321
21822
  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))
21823
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "endpoint", children: "Speech endpoint (Speaches, edge-tts, OpenAI\u2026)" }),
21824
+ builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "builtin", children: "Built-in voice" })
21327
21825
  ]
21328
21826
  }
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." })
21827
+ )
21340
21828
  ] }),
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." })
21829
+ builtin && builtinStatus && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21830
+ BuiltinVoiceBlock,
21831
+ {
21832
+ status: builtinStatus,
21833
+ onStatusChange: setBuiltinStatus,
21834
+ language: ttsLanguage,
21835
+ onLanguageChange: setTtsLanguage,
21836
+ voice: ttsVoice,
21837
+ onVoiceChange: setTtsVoice
21838
+ }
21839
+ ),
21840
+ !builtin && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
21841
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21842
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-tts-endpoint", children: "Synthesis Endpoint (optional)" }),
21843
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21844
+ "input",
21845
+ {
21846
+ id: "voice-tts-endpoint",
21847
+ type: "text",
21848
+ placeholder: "Leave empty when one server does both",
21849
+ value: ttsEndpoint,
21850
+ onChange: (e) => setTtsEndpoint(e.target.value)
21851
+ }
21852
+ ),
21853
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { children: [
21854
+ "Leave empty when one server does both. A local openai-edge-tts container gives you Microsoft Neural voices such as",
21855
+ " ",
21856
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: "it-IT-ElsaNeural" }),
21857
+ " or ",
21858
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: "it-IT-DiegoNeural" }),
21859
+ ", but cannot transcribe \u2014 transcription always uses the endpoint above. Nothing is saved yet \u2014 press Save after adjusting."
21860
+ ] })
21861
+ ] }),
21862
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21863
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-tts-key", children: "Synthesis API Key (optional)" }),
21864
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21865
+ "input",
21866
+ {
21867
+ id: "voice-tts-key",
21868
+ type: "password",
21869
+ placeholder: "Leave empty for a local server with no auth",
21870
+ value: ttsApiKey,
21871
+ onChange: (e) => setTtsApiKey(e.target.value)
21872
+ }
21873
+ ),
21874
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Stored encrypted. Only sent to the synthesis endpoint \u2014 the transcription key is never sent there, and vice versa." })
21875
+ ] }),
21876
+ ttsEndpoint.trim() && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21877
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21878
+ "button",
21879
+ {
21880
+ type: "button",
21881
+ onClick: fetchTtsCatalog,
21882
+ disabled: fetchingTts,
21883
+ children: fetchingTts ? "Fetching\u2026" : "Fetch synthesis models"
21884
+ }
21885
+ ),
21886
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { children: [
21887
+ "Reads the synthesis endpoint's models and voices. For edge-tts, the voice list comes from ",
21888
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("code", { children: "/voices/all" }),
21889
+ "."
21890
+ ] }),
21891
+ ttsFetchError && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("small", { className: "form-error", children: [
21892
+ "Fetch failed: ",
21893
+ ttsFetchError
21894
+ ] })
21895
+ ] }),
21896
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21897
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-tts", children: "Synthesis Model (optional)" }),
21898
+ ttsCatalog && ttsCatalog.tts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
21899
+ "select",
21900
+ {
21901
+ id: "voice-tts",
21902
+ value: ttsModel,
21903
+ onChange: (e) => {
21904
+ setTtsModel(e.target.value);
21905
+ const next = ttsCatalog.tts.find((m2) => m2.id === e.target.value);
21906
+ if (next && !next.voices.some((v2) => v2.id === ttsVoice)) {
21907
+ setTtsVoice(next.voices.length === 1 ? next.voices[0].id : "");
21908
+ }
21909
+ },
21910
+ children: [
21911
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "-- None (dictation only) --" }),
21912
+ withCurrent(
21913
+ ttsCatalog.tts.map((m2) => m2.id),
21914
+ ttsModel
21915
+ ).map((id) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: id, children: id }, id))
21916
+ ]
21917
+ }
21918
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21919
+ "input",
21920
+ {
21921
+ id: "voice-tts",
21922
+ type: "text",
21923
+ placeholder: "e.g. speaches-ai/Kokoro-82M-v1.0-ONNX or tts-1",
21924
+ value: ttsModel,
21925
+ onChange: (e) => setTtsModel(e.target.value)
21926
+ }
21927
+ ),
21928
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Required for conversation mode. Without it, only dictation is offered." })
21929
+ ] }),
21930
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21931
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-voice", children: "Voice (optional)" }),
21932
+ voicesForModel.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
21933
+ "select",
21934
+ {
21935
+ id: "voice-voice",
21936
+ value: ttsVoice,
21937
+ onChange: (e) => setTtsVoice(e.target.value),
21938
+ children: [
21939
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "-- Select a voice --" }),
21940
+ voicesForModel.map((v2) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: v2.id, children: voiceLabel(v2) }, v2.id))
21941
+ ]
21942
+ }
21943
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21944
+ "input",
21945
+ {
21946
+ id: "voice-voice",
21947
+ type: "text",
21948
+ placeholder: "e.g. af_heart or it-IT-ElsaNeural",
21949
+ value: ttsVoice,
21950
+ onChange: (e) => setTtsVoice(e.target.value)
21951
+ }
21952
+ ),
21953
+ /* @__PURE__ */ (0, import_jsx_runtime16.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." })
21954
+ ] }),
21955
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21956
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-speed", children: "Speaking Rate (optional)" }),
21957
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21958
+ "input",
21959
+ {
21960
+ id: "voice-speed",
21961
+ type: "number",
21962
+ min: "0.5",
21963
+ max: "2",
21964
+ step: "0.05",
21965
+ placeholder: "1 \u2014 the model's natural pace",
21966
+ value: ttsSpeed,
21967
+ onChange: (e) => setTtsSpeed(e.target.value)
21968
+ }
21969
+ ),
21970
+ /* @__PURE__ */ (0, import_jsx_runtime16.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." })
21971
+ ] })
21365
21972
  ] }),
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)(
21973
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21974
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-buffer", children: "Playback buffer, ms (optional)" }),
21975
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21369
21976
  "input",
21370
21977
  {
21371
- id: "voice-speed",
21978
+ id: "voice-buffer",
21372
21979
  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)
21980
+ min: "0",
21981
+ max: MAX_PLAYBACK_BUFFER_MS,
21982
+ step: "100",
21983
+ placeholder: `${DEFAULT_PLAYBACK_BUFFER_MS} \u2014 default`,
21984
+ value: bufferMs,
21985
+ onChange: (e) => setBufferMs(e.target.value)
21379
21986
  }
21380
21987
  ),
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." })
21988
+ /* @__PURE__ */ (0, import_jsx_runtime16.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
21989
  ] }),
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)(
21990
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
21991
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("label", { htmlFor: "voice-lang", children: "Language (optional)" }),
21992
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
21386
21993
  "input",
21387
21994
  {
21388
21995
  id: "voice-lang",
@@ -21392,17 +21999,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21392
21999
  onChange: (e) => setLang(e.target.value)
21393
22000
  }
21394
22001
  )
22002
+ ] }),
22003
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22004
+ PronunciationTable,
22005
+ {
22006
+ code: synthCode,
22007
+ entries: pronEntries,
22008
+ enabled: pronEnabled,
22009
+ onEnabledChange: setPronEnabled,
22010
+ onChange: (entries) => synthCode && setPronunciation((p) => ({ ...p, [synthCode]: entries })),
22011
+ onRestoreDefaults: () => synthCode && setPronunciation((p) => {
22012
+ const { [synthCode]: _drop, ...rest } = p;
22013
+ return rest;
22014
+ }),
22015
+ onListen: (t) => void listen(t),
22016
+ listening,
22017
+ listenError
22018
+ }
22019
+ ),
22020
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-group", children: [
22021
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: listening ? stopListening : () => void listen(), children: listening ? "Stop" : "Listen" }),
22022
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: "Speaks a sample sentence with the form as it is now, without saving." })
21395
22023
  ] })
21396
22024
  ] }),
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" : "" })
22025
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "form-actions", children: [
22026
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", onClick: save, children: "Save" }),
22027
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { role: "status", "aria-live": "polite", className: "form-save-state", children: saveState === "saving" ? "Saving\u2026" : saveState === "saved" ? "Saved \u2713" : "" })
21400
22028
  ] })
21401
22029
  ] });
21402
22030
  }
21403
22031
 
21404
22032
  // src/MemoryTab.tsx
21405
- var import_react17 = __toESM(require_react(), 1);
22033
+ var import_react18 = __toESM(require_react(), 1);
21406
22034
 
21407
22035
  // src/memory_tab_utils.ts
21408
22036
  function buildMemoryConfig(form) {
@@ -21421,26 +22049,26 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21421
22049
  }
21422
22050
 
21423
22051
  // src/MemoryTab.tsx
21424
- var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
22052
+ var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
21425
22053
  function MemoryTab({ config, agents, onSave }) {
21426
22054
  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)(
22055
+ const [enabled, setEnabled] = (0, import_react18.useState)(!!current);
22056
+ const [agentId, setAgentId] = (0, import_react18.useState)(current?.agentId ?? "");
22057
+ const [sweepMinutes, setSweepMinutes] = (0, import_react18.useState)(
21430
22058
  current?.sweepMinutes === void 0 ? "" : String(current.sweepMinutes)
21431
22059
  );
21432
- const [minNewMessages, setMinNewMessages] = (0, import_react17.useState)(
22060
+ const [minNewMessages, setMinNewMessages] = (0, import_react18.useState)(
21433
22061
  current?.minNewMessages === void 0 ? "" : String(current.minNewMessages)
21434
22062
  );
21435
- const [saveState, setSaveState] = (0, import_react17.useState)("idle");
21436
- const pendingSave = (0, import_react17.useRef)(null);
21437
- (0, import_react17.useEffect)(() => {
22063
+ const [saveState, setSaveState] = (0, import_react18.useState)("idle");
22064
+ const pendingSave = (0, import_react18.useRef)(null);
22065
+ (0, import_react18.useEffect)(() => {
21438
22066
  if (saveState !== "saving" || pendingSave.current === null) return;
21439
22067
  if (memorySignature(config.memory) !== pendingSave.current)
21440
22068
  return;
21441
22069
  setSaveState("saved");
21442
22070
  }, [config.memory, saveState]);
21443
- (0, import_react17.useEffect)(() => {
22071
+ (0, import_react18.useEffect)(() => {
21444
22072
  if (saveState !== "saved") return;
21445
22073
  const t = setTimeout(() => setSaveState("idle"), 2e3);
21446
22074
  return () => clearTimeout(t);
@@ -21456,12 +22084,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21456
22084
  else delete next.memory;
21457
22085
  onSave(next);
21458
22086
  };
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)(
22087
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "glass-form", children: [
22088
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h4", { children: "Memory" }),
22089
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "glass-form__body", children: [
22090
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group form-group--checkbox", children: [
22091
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { htmlFor: "memory-enabled", children: [
22092
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21465
22093
  "input",
21466
22094
  {
21467
22095
  id: "memory-enabled",
@@ -21472,25 +22100,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21472
22100
  ),
21473
22101
  "Enable memory"
21474
22102
  ] }),
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." })
22103
+ /* @__PURE__ */ (0, import_jsx_runtime17.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
22104
  ] }),
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: [
22105
+ enabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
22106
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22107
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "memory-agent", children: "Memory agent" }),
22108
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("select", { id: "memory-agent", value: agentId, onChange: (e) => setAgentId(e.target.value), children: [
22109
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "\u2014 select an agent \u2014" }),
22110
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("option", { value: a2.id, children: [
21483
22111
  a2.name,
21484
22112
  " \xB7 ",
21485
22113
  a2.model
21486
22114
  ] }, a2.id))
21487
22115
  ] }),
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." })
22116
+ /* @__PURE__ */ (0, import_jsx_runtime17.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." }),
22117
+ missingAgent && agentId && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { className: "form-error", children: "This agent no longer exists \u2014 pick another." })
21490
22118
  ] }),
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)(
22119
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22120
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "memory-sweep-minutes", children: "Sweep interval (minutes)" }),
22121
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21494
22122
  "input",
21495
22123
  {
21496
22124
  id: "memory-sweep-minutes",
@@ -21502,9 +22130,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21502
22130
  }
21503
22131
  )
21504
22132
  ] }),
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)(
22133
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-group", children: [
22134
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: "memory-min-new", children: "Min new messages per session" }),
22135
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
21508
22136
  "input",
21509
22137
  {
21510
22138
  id: "memory-min-new",
@@ -21515,19 +22143,131 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21515
22143
  onChange: (e) => setMinNewMessages(e.target.value)
21516
22144
  }
21517
22145
  ),
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." })
22146
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: "A session is re-summarized only once it accumulated at least this many new messages since the last pass." })
22147
+ ] })
22148
+ ] })
22149
+ ] }),
22150
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "form-actions", children: [
22151
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: save, disabled: enabled && !agentId, children: "Save" }),
22152
+ /* @__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" : "" })
22153
+ ] })
22154
+ ] });
22155
+ }
22156
+
22157
+ // src/DesktopTab.tsx
22158
+ var import_react19 = __toESM(require_react(), 1);
22159
+
22160
+ // src/desktop_tab_utils.ts
22161
+ var DEFAULT_ASSISTANT_SHORTCUT = "CommandOrControl+Shift+Space";
22162
+ function buildDesktopAssistantConfig(form) {
22163
+ const agentId = form.agentId.trim();
22164
+ if (!form.enabled || !agentId) return void 0;
22165
+ return { agentId, shortcut: form.shortcut.trim() || DEFAULT_ASSISTANT_SHORTCUT };
22166
+ }
22167
+ function desktopAssistantSignature(c2) {
22168
+ if (!c2) return "";
22169
+ return JSON.stringify([c2.agentId ?? "", c2.shortcut ?? ""]);
22170
+ }
22171
+
22172
+ // src/DesktopTab.tsx
22173
+ var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
22174
+ function DesktopTab({ config, agents, onSave }) {
22175
+ const current = config.desktopAssistant;
22176
+ const [enabled, setEnabled] = (0, import_react19.useState)(!!current);
22177
+ const [agentId, setAgentId] = (0, import_react19.useState)(current?.agentId ?? "");
22178
+ const [shortcut, setShortcut] = (0, import_react19.useState)(current?.shortcut ?? "");
22179
+ const [saveState, setSaveState] = (0, import_react19.useState)("idle");
22180
+ const pendingSave = (0, import_react19.useRef)(null);
22181
+ (0, import_react19.useEffect)(() => {
22182
+ if (saveState !== "saving" || pendingSave.current === null) return;
22183
+ if (desktopAssistantSignature(config.desktopAssistant) !== pendingSave.current)
22184
+ return;
22185
+ setSaveState("saved");
22186
+ }, [config.desktopAssistant, saveState]);
22187
+ (0, import_react19.useEffect)(() => {
22188
+ if (saveState !== "saved") return;
22189
+ const t = setTimeout(() => setSaveState("idle"), 2e3);
22190
+ return () => clearTimeout(t);
22191
+ }, [saveState]);
22192
+ const missingAgent = enabled && !!agentId && !agents.some((a2) => a2.id === agentId);
22193
+ const save = () => {
22194
+ const cfg = buildDesktopAssistantConfig({ enabled, agentId, shortcut });
22195
+ pendingSave.current = desktopAssistantSignature(cfg);
22196
+ setSaveState("saving");
22197
+ const next = { ...config };
22198
+ if (cfg) next.desktopAssistant = cfg;
22199
+ else delete next.desktopAssistant;
22200
+ onSave(next);
22201
+ };
22202
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "glass-form", children: [
22203
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { children: "Desktop assistant" }),
22204
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "glass-form__body", children: [
22205
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group form-group--checkbox", children: [
22206
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { htmlFor: "desktop-assistant-enabled", children: [
22207
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
22208
+ "input",
22209
+ {
22210
+ id: "desktop-assistant-enabled",
22211
+ type: "checkbox",
22212
+ checked: enabled,
22213
+ onChange: (e) => setEnabled(e.target.checked)
22214
+ }
22215
+ ),
22216
+ "Enable desktop assistant"
22217
+ ] }),
22218
+ /* @__PURE__ */ (0, import_jsx_runtime18.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." })
22219
+ ] }),
22220
+ enabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
22221
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group", children: [
22222
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: "desktop-assistant-agent", children: "Assistant agent" }),
22223
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
22224
+ "select",
22225
+ {
22226
+ id: "desktop-assistant-agent",
22227
+ value: agentId,
22228
+ onChange: (e) => setAgentId(e.target.value),
22229
+ children: [
22230
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "\u2014 select an agent \u2014" }),
22231
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("option", { value: a2.id, children: [
22232
+ a2.name,
22233
+ " \xB7 ",
22234
+ a2.model
22235
+ ] }, a2.id))
22236
+ ]
22237
+ }
22238
+ ),
22239
+ /* @__PURE__ */ (0, import_jsx_runtime18.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." }),
22240
+ missingAgent && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { className: "form-error", children: "This agent no longer exists \u2014 pick another." })
22241
+ ] }),
22242
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-group", children: [
22243
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: "desktop-assistant-shortcut", children: "Global shortcut" }),
22244
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
22245
+ "input",
22246
+ {
22247
+ id: "desktop-assistant-shortcut",
22248
+ type: "text",
22249
+ placeholder: DEFAULT_ASSISTANT_SHORTCUT,
22250
+ value: shortcut,
22251
+ onChange: (e) => setShortcut(e.target.value)
22252
+ }
22253
+ ),
22254
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("small", { children: [
22255
+ "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",
22256
+ " ",
22257
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { children: "caretaker-desktop --assistant" })
22258
+ ] })
21519
22259
  ] })
21520
22260
  ] })
21521
22261
  ] }),
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" : "" })
22262
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "form-actions", children: [
22263
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: save, disabled: enabled && !agentId, children: "Save" }),
22264
+ /* @__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" : "" })
21525
22265
  ] })
21526
22266
  ] });
21527
22267
  }
21528
22268
 
21529
22269
  // src/SettingsPanel.tsx
21530
- var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
22270
+ var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
21531
22271
  function SettingsPanel({
21532
22272
  layout = "compact",
21533
22273
  postMessage,
@@ -21548,16 +22288,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21548
22288
  onClose,
21549
22289
  initialTab = "providers"
21550
22290
  }) {
21551
- const [activeTab, setActiveTab] = (0, import_react18.useState)(initialTab);
22291
+ const [activeTab, setActiveTab] = (0, import_react20.useState)(initialTab);
21552
22292
  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 }),
22293
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "settings-panel settings-panel--loading", children: [
22294
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, children: [
22295
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArrowLeft, { size: 14 }),
21556
22296
  " Back to Chat"
21557
22297
  ] }),
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..." })
22298
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "settings-panel__loading-spinner", children: [
22299
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "spinner" }),
22300
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Loading configurations..." })
21561
22301
  ] })
21562
22302
  ] });
21563
22303
  }
@@ -21565,7 +22305,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21565
22305
  const renderTabContent = () => {
21566
22306
  switch (activeTab) {
21567
22307
  case "providers":
21568
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22308
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21569
22309
  ProvidersTab,
21570
22310
  {
21571
22311
  config,
@@ -21577,7 +22317,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21577
22317
  }
21578
22318
  );
21579
22319
  case "projects":
21580
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22320
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21581
22321
  ProjectsTabSettings,
21582
22322
  {
21583
22323
  config,
@@ -21586,7 +22326,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21586
22326
  }
21587
22327
  );
21588
22328
  case "agents":
21589
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22329
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21590
22330
  AgentsTab,
21591
22331
  {
21592
22332
  config,
@@ -21600,7 +22340,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21600
22340
  }
21601
22341
  );
21602
22342
  case "plugins":
21603
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22343
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21604
22344
  PluginsTab,
21605
22345
  {
21606
22346
  pluginsFile,
@@ -21611,7 +22351,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21611
22351
  }
21612
22352
  );
21613
22353
  case "mcp":
21614
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22354
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21615
22355
  McpTab,
21616
22356
  {
21617
22357
  mcpServersFile,
@@ -21621,7 +22361,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21621
22361
  }
21622
22362
  );
21623
22363
  case "services":
21624
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22364
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21625
22365
  ServicesTab,
21626
22366
  {
21627
22367
  config,
@@ -21631,7 +22371,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21631
22371
  }
21632
22372
  );
21633
22373
  case "voice":
21634
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22374
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21635
22375
  VoiceTab,
21636
22376
  {
21637
22377
  config,
@@ -21642,7 +22382,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21642
22382
  }
21643
22383
  );
21644
22384
  case "memory":
21645
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22385
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21646
22386
  MemoryTab,
21647
22387
  {
21648
22388
  config,
@@ -21650,18 +22390,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21650
22390
  onSave: (updatedConfig) => postMessage({ type: "saveConfig", config: updatedConfig })
21651
22391
  }
21652
22392
  );
22393
+ case "desktop":
22394
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
22395
+ DesktopTab,
22396
+ {
22397
+ config,
22398
+ agents,
22399
+ onSave: (updatedConfig) => postMessage({ type: "saveConfig", config: updatedConfig })
22400
+ }
22401
+ );
21653
22402
  }
21654
22403
  };
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 }),
22404
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "settings-panel", children: [
22405
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("header", { className: "settings-panel__header", children: [
22406
+ layout !== "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { className: "settings-panel__back-btn", onClick: onClose, title: "Go back to chat", children: [
22407
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArrowLeft, { size: 14 }),
21659
22408
  " Chat"
21660
22409
  ] }),
21661
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: "settings-panel__title", children: "Caretaker Config" })
22410
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "settings-panel__title", children: "Caretaker Config" })
21662
22411
  ] }),
21663
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("nav", { className: "settings-panel__tabs", children: [
21664
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22412
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("nav", { className: "settings-panel__tabs", children: [
22413
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21665
22414
  "button",
21666
22415
  {
21667
22416
  className: `settings-panel__tab-btn ${activeTab === "providers" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21669,7 +22418,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21669
22418
  children: "Providers"
21670
22419
  }
21671
22420
  ),
21672
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22421
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21673
22422
  "button",
21674
22423
  {
21675
22424
  className: `settings-panel__tab-btn ${activeTab === "projects" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21677,7 +22426,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21677
22426
  children: "Projects"
21678
22427
  }
21679
22428
  ),
21680
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22429
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21681
22430
  "button",
21682
22431
  {
21683
22432
  className: `settings-panel__tab-btn ${activeTab === "agents" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21685,7 +22434,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21685
22434
  children: "Agents"
21686
22435
  }
21687
22436
  ),
21688
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22437
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21689
22438
  "button",
21690
22439
  {
21691
22440
  className: `settings-panel__tab-btn ${activeTab === "plugins" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21693,7 +22442,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21693
22442
  children: "Plugins"
21694
22443
  }
21695
22444
  ),
21696
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22445
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21697
22446
  "button",
21698
22447
  {
21699
22448
  className: `settings-panel__tab-btn ${activeTab === "mcp" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21701,7 +22450,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21701
22450
  children: "MCP"
21702
22451
  }
21703
22452
  ),
21704
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22453
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21705
22454
  "button",
21706
22455
  {
21707
22456
  className: `settings-panel__tab-btn ${activeTab === "services" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21709,7 +22458,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21709
22458
  children: "Services"
21710
22459
  }
21711
22460
  ),
21712
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22461
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21713
22462
  "button",
21714
22463
  {
21715
22464
  className: `settings-panel__tab-btn ${activeTab === "voice" ? "settings-panel__tab-btn--active" : ""}`,
@@ -21717,24 +22466,32 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21717
22466
  children: "Voice"
21718
22467
  }
21719
22468
  ),
21720
- layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
22469
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
21721
22470
  "button",
21722
22471
  {
21723
22472
  className: `settings-panel__tab-btn ${activeTab === "memory" ? "settings-panel__tab-btn--active" : ""}`,
21724
22473
  onClick: () => setActiveTab("memory"),
21725
22474
  children: "Memory"
21726
22475
  }
22476
+ ),
22477
+ layout === "sidebar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
22478
+ "button",
22479
+ {
22480
+ className: `settings-panel__tab-btn ${activeTab === "desktop" ? "settings-panel__tab-btn--active" : ""}`,
22481
+ onClick: () => setActiveTab("desktop"),
22482
+ children: "Desktop"
22483
+ }
21727
22484
  )
21728
22485
  ] }),
21729
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("main", { className: "settings-panel__content", children: renderTabContent() })
22486
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("main", { className: "settings-panel__content", children: renderTabContent() })
21730
22487
  ] });
21731
22488
  }
21732
22489
 
21733
22490
  // src/ProjectsTab.tsx
21734
- var import_react20 = __toESM(require_react(), 1);
22491
+ var import_react22 = __toESM(require_react(), 1);
21735
22492
 
21736
22493
  // src/TaskCycleView.tsx
21737
- var import_react19 = __toESM(require_react(), 1);
22494
+ var import_react21 = __toESM(require_react(), 1);
21738
22495
 
21739
22496
  // src/chat_state.ts
21740
22497
  function closeStreamingAssistant2(items) {
@@ -21910,13 +22667,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21910
22667
  };
21911
22668
 
21912
22669
  // src/TaskCycleView.tsx
21913
- var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
22670
+ var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
21914
22671
  function TaskCycleView({ item, postMessage, onBack }) {
21915
- const [chat, dispatch] = (0, import_react19.useReducer)(chatReducer, initialChatState);
22672
+ const [chat, dispatch] = (0, import_react21.useReducer)(chatReducer, initialChatState);
21916
22673
  const { sessionId, agentId } = item;
21917
- const postRef = (0, import_react19.useRef)(postMessage);
22674
+ const postRef = (0, import_react21.useRef)(postMessage);
21918
22675
  postRef.current = postMessage;
21919
- (0, import_react19.useEffect)(() => {
22676
+ (0, import_react21.useEffect)(() => {
21920
22677
  function handle(event) {
21921
22678
  const msg = event.data;
21922
22679
  if (!msg || typeof msg !== "object" || !("type" in msg) || !("sessionId" in msg)) return;
@@ -21957,25 +22714,25 @@ Please report this to https://github.com/markedjs/marked.`, e) {
21957
22714
  };
21958
22715
  }, [sessionId, agentId]);
21959
22716
  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: [
22717
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
22718
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "10px 14px" }, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
22719
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to the task thread", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArrowLeft, { size: 13 }) }),
22720
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "app__chat-header-info", children: [
22721
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
21965
22722
  cycleRoleLabel(item.role),
21966
22723
  " cycle",
21967
22724
  item.label ? ` \xB7 ${item.label}` : ""
21968
22725
  ] }),
21969
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: running ? "running" : cycleOutcomeLabel(item.outcome) })
22726
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: running ? "running" : cycleOutcomeLabel(item.outcome) })
21970
22727
  ] })
21971
22728
  ] }) }),
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 })
22729
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MessageList, { items: chat.items, sessionId: null, isStreaming: running, agentName: item.label }),
22730
+ chat.errorText && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "notice notice--block", children: chat.errorText })
21974
22731
  ] });
21975
22732
  }
21976
22733
 
21977
22734
  // src/ProjectsTab.tsx
21978
- var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
22735
+ var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
21979
22736
  var LS_ARCHIVED_KEY = "caretaker.taskView.showArchived";
21980
22737
  function persistLastProject(id) {
21981
22738
  void fetch("/api/ui-state", {
@@ -22000,15 +22757,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22000
22757
  }
22001
22758
  var PAGE_SIZE = 20;
22002
22759
  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)({
22760
+ const [projects, setProjects] = (0, import_react22.useState)([]);
22761
+ const [selectedProjectId, setSelectedProjectId] = (0, import_react22.useState)(null);
22762
+ const [tasks, setTasks] = (0, import_react22.useState)([]);
22763
+ const [selectedTaskId, setSelectedTaskId] = (0, import_react22.useState)(null);
22764
+ const [taskMessages, setTaskMessages] = (0, import_react22.useState)([]);
22765
+ const [view, setView] = (0, import_react22.useState)("list");
22766
+ const [page, setPage] = (0, import_react22.useState)(0);
22767
+ const [isNewTaskOpen, setIsNewTaskOpen] = (0, import_react22.useState)(false);
22768
+ const [newTask, setNewTask] = (0, import_react22.useState)({
22012
22769
  title: "",
22013
22770
  objective: "",
22014
22771
  checklistText: "",
@@ -22017,12 +22774,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22017
22774
  plannerAgentId: "",
22018
22775
  reviewerAgentId: ""
22019
22776
  });
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)(() => {
22777
+ const [isSending, setIsSending] = (0, import_react22.useState)(false);
22778
+ const [showArchived, setShowArchived] = (0, import_react22.useState)(loadShowArchived);
22779
+ const [pendingConfirm, setPendingConfirm] = (0, import_react22.useState)(null);
22780
+ const [taskError, setTaskError] = (0, import_react22.useState)(null);
22781
+ const threadIntervalRef = (0, import_react22.useRef)(null);
22782
+ (0, import_react22.useEffect)(() => {
22026
22783
  void (async () => {
22027
22784
  try {
22028
22785
  const res = await fetch("/api/ui-state");
@@ -22038,7 +22795,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22038
22795
  stopThreadPolling();
22039
22796
  };
22040
22797
  }, []);
22041
- (0, import_react20.useEffect)(() => {
22798
+ (0, import_react22.useEffect)(() => {
22042
22799
  if (projects.length > 0 && selectedProjectId === null) {
22043
22800
  setSelectedProjectId(projects[0].id);
22044
22801
  }
@@ -22049,10 +22806,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22049
22806
  setSelectedProjectId(null);
22050
22807
  }
22051
22808
  }, [projects]);
22052
- (0, import_react20.useEffect)(() => {
22809
+ (0, import_react22.useEffect)(() => {
22053
22810
  saveShowArchived(showArchived);
22054
22811
  }, [showArchived]);
22055
- (0, import_react20.useEffect)(() => {
22812
+ (0, import_react22.useEffect)(() => {
22056
22813
  if (selectedProjectId !== null) {
22057
22814
  fetchTasks(selectedProjectId);
22058
22815
  setView("list");
@@ -22064,7 +22821,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22064
22821
  setTasks([]);
22065
22822
  }
22066
22823
  }, [selectedProjectId, showArchived]);
22067
- (0, import_react20.useEffect)(() => {
22824
+ (0, import_react22.useEffect)(() => {
22068
22825
  if (selectedTaskId !== null) {
22069
22826
  fetchTaskMessages(selectedTaskId);
22070
22827
  startThreadPolling(selectedTaskId);
@@ -22237,7 +22994,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22237
22994
  const cancelPendingAction = () => {
22238
22995
  setPendingConfirm(null);
22239
22996
  };
22240
- (0, import_react20.useEffect)(() => {
22997
+ (0, import_react22.useEffect)(() => {
22241
22998
  if (!pendingConfirm) return;
22242
22999
  function handleKeyDown(event) {
22243
23000
  if (event.key === "Escape") {
@@ -22247,7 +23004,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22247
23004
  window.addEventListener("keydown", handleKeyDown);
22248
23005
  return () => window.removeEventListener("keydown", handleKeyDown);
22249
23006
  }, [pendingConfirm]);
22250
- (0, import_react20.useEffect)(() => {
23007
+ (0, import_react22.useEffect)(() => {
22251
23008
  if (!taskError) return;
22252
23009
  const t = setTimeout(() => setTaskError(null), 5e3);
22253
23010
  return () => clearTimeout(t);
@@ -22378,7 +23135,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22378
23135
  const selectedProject = projects.find((p) => p.id === selectedProjectId);
22379
23136
  const selectedTask = tasks.find((t) => t.id === selectedTaskId);
22380
23137
  const selectedProjectAgentName = agents.find((a2) => a2.id === selectedProject?.agentId)?.name || "Default Agent";
22381
- const taskAgentLabels = (0, import_react20.useMemo)(() => {
23138
+ const taskAgentLabels = (0, import_react22.useMemo)(() => {
22382
23139
  if (!selectedTask) return void 0;
22383
23140
  const agentLabelFor = (agentId) => {
22384
23141
  const a2 = agents.find((x) => x.id === agentId);
@@ -22424,14 +23181,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22424
23181
  const safePage = Math.min(page, totalPages - 1);
22425
23182
  const pageStart = safePage * PAGE_SIZE;
22426
23183
  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: [
23184
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app", style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
23185
+ /* @__PURE__ */ (0, import_jsx_runtime21.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_runtime21.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { children: [
22429
23186
  "No projects registered.",
22430
23187
  " ",
22431
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "app__link-btn", onClick: onOpenSettings, children: "Create one in Settings" }),
23188
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "app__link-btn", onClick: onOpenSettings, children: "Create one in Settings" }),
22432
23189
  " ",
22433
23190
  "to get started."
22434
- ] }) }) : selectedProject ? view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23191
+ ] }) }) : selectedProject ? view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22435
23192
  TaskListView,
22436
23193
  {
22437
23194
  projects,
@@ -22456,7 +23213,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22456
23213
  onArchive: handleArchiveFromList,
22457
23214
  statusColor
22458
23215
  }
22459
- ) : view === "log" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23216
+ ) : view === "log" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22460
23217
  TaskLogView,
22461
23218
  {
22462
23219
  task: selectedTask,
@@ -22472,7 +23229,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22472
23229
  onToggleStatus: handleToggleTaskStatus,
22473
23230
  statusColor
22474
23231
  }
22475
- ) : view === "edit" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23232
+ ) : view === "edit" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22476
23233
  TaskEditView,
22477
23234
  {
22478
23235
  task: selectedTask,
@@ -22490,11 +23247,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22490
23247
  onOpenLog: () => setView("log"),
22491
23248
  statusColor
22492
23249
  }
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" })
23250
+ ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app__empty-state", children: [
23251
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: "Task not found. Go back to the list." }),
23252
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "settings-panel__back-btn", onClick: backToList, style: { marginTop: "12px" }, children: "\u2190 Back to list" })
22496
23253
  ] }) : null }),
22497
- isNewTaskOpen && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23254
+ isNewTaskOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22498
23255
  "div",
22499
23256
  {
22500
23257
  style: {
@@ -22509,7 +23266,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22509
23266
  justifyContent: "center",
22510
23267
  zIndex: 999
22511
23268
  },
22512
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23269
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22513
23270
  "form",
22514
23271
  {
22515
23272
  onSubmit: handleCreateTask,
@@ -22520,14 +23277,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22520
23277
  background: "var(--vscode-sideBar-background)"
22521
23278
  },
22522
23279
  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" })
23280
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "confirm__header", children: [
23281
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "18px", display: "inline-flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Wrench, { size: 18 }) }),
23282
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "confirm__prompt", style: { fontSize: "14px" }, children: "Create New Task" })
22526
23283
  ] }),
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: [
23284
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "10px" }, children: [
23285
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22529
23286
  "Task Title",
22530
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23287
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22531
23288
  "input",
22532
23289
  {
22533
23290
  type: "text",
@@ -22547,9 +23304,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22547
23304
  }
22548
23305
  )
22549
23306
  ] }),
22550
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23307
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22551
23308
  "Objective (Extended markdown goal description)",
22552
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23309
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22553
23310
  "textarea",
22554
23311
  {
22555
23312
  required: true,
@@ -22570,9 +23327,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22570
23327
  }
22571
23328
  )
22572
23329
  ] }),
22573
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23330
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22574
23331
  "Checklist Items (One item per line)",
22575
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23332
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22576
23333
  "textarea",
22577
23334
  {
22578
23335
  placeholder: "Create route handler\nWrite unit tests\nUpdate documentation",
@@ -22592,9 +23349,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22592
23349
  }
22593
23350
  )
22594
23351
  ] }),
22595
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23352
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22596
23353
  "Assigned Agent (optional \u2014 overrides project default)",
22597
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23354
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22598
23355
  "select",
22599
23356
  {
22600
23357
  value: newTask.agentId,
@@ -22609,8 +23366,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22609
23366
  outline: "none"
22610
23367
  },
22611
23368
  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: [
23369
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
23370
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
22614
23371
  a2.name,
22615
23372
  " (",
22616
23373
  a2.provider,
@@ -22620,9 +23377,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22620
23377
  }
22621
23378
  )
22622
23379
  ] }),
22623
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23380
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22624
23381
  "Planner Agent Override (optional)",
22625
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23382
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22626
23383
  "select",
22627
23384
  {
22628
23385
  value: newTask.plannerAgentId,
@@ -22637,8 +23394,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22637
23394
  outline: "none"
22638
23395
  },
22639
23396
  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: [
23397
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
23398
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
22642
23399
  a2.name,
22643
23400
  " (",
22644
23401
  a2.provider,
@@ -22648,9 +23405,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22648
23405
  }
22649
23406
  )
22650
23407
  ] }),
22651
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
23408
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px" }, children: [
22652
23409
  "Reviewer Agent Override (optional)",
22653
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23410
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22654
23411
  "select",
22655
23412
  {
22656
23413
  value: newTask.reviewerAgentId,
@@ -22665,8 +23422,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22665
23422
  outline: "none"
22666
23423
  },
22667
23424
  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: [
23425
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
23426
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
22670
23427
  a2.name,
22671
23428
  " (",
22672
23429
  a2.provider,
@@ -22676,8 +23433,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22676
23433
  }
22677
23434
  )
22678
23435
  ] }),
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)(
23436
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "12px", display: "flex", alignItems: "center", gap: "6px", cursor: "pointer", marginTop: "4px" }, children: [
23437
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22681
23438
  "input",
22682
23439
  {
22683
23440
  type: "checkbox",
@@ -22686,24 +23443,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22686
23443
  style: { cursor: "pointer" }
22687
23444
  }
22688
23445
  ),
22689
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Start active immediately (Heartbeat loop claims it)" })
23446
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: "Start active immediately (Heartbeat loop claims it)" })
22690
23447
  ] })
22691
23448
  ] }),
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" })
23449
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "confirm__buttons", style: { justifyContent: "flex-end", marginTop: "10px" }, children: [
23450
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: "confirm__btn", onClick: () => setIsNewTaskOpen(false), children: "Cancel" }),
23451
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "submit", className: "confirm__btn confirm__btn--primary", children: "Create Task" })
22695
23452
  ] })
22696
23453
  ]
22697
23454
  }
22698
23455
  )
22699
23456
  }
22700
23457
  ),
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)(
23458
+ pendingConfirm && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "app__confirm-overlay", onClick: cancelPendingAction, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
23459
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "app__confirm-title", children: pendingConfirm.type === "delete" ? "Delete task" : pendingConfirm.type === "archive" ? "Archive task" : "Discard worktree" }),
23460
+ /* @__PURE__ */ (0, import_jsx_runtime21.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.` }),
23461
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app__confirm-buttons", children: [
23462
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "app__confirm-btn", onClick: cancelPendingAction, children: "Cancel" }),
23463
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22707
23464
  "button",
22708
23465
  {
22709
23466
  className: `app__confirm-btn ${pendingConfirm.type === "delete" ? "app__confirm-btn--danger" : ""}`,
@@ -22713,7 +23470,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22713
23470
  )
22714
23471
  ] })
22715
23472
  ] }) }),
22716
- taskError && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "app__error-banner", onClick: () => setTaskError(null), title: "Click to dismiss", children: taskError })
23473
+ taskError && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "app__error-banner", onClick: () => setTaskError(null), title: "Click to dismiss", children: taskError })
22717
23474
  ] });
22718
23475
  }
22719
23476
  function TaskListView({
@@ -22736,10 +23493,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22736
23493
  onArchive,
22737
23494
  statusColor
22738
23495
  }) {
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)(
23496
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
23497
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "task-view__header", children: [
23498
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23499
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22743
23500
  "select",
22744
23501
  {
22745
23502
  className: "task-view__project-filter",
@@ -22756,17 +23513,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22756
23513
  outline: "none",
22757
23514
  cursor: "pointer"
22758
23515
  },
22759
- children: projects.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: p.id, children: p.name }, p.id))
23516
+ children: projects.map((p) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: p.id, children: p.name }, p.id))
22760
23517
  }
22761
23518
  ),
22762
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: [
23519
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: [
22763
23520
  "Agent: ",
22764
23521
  agentName
22765
23522
  ] })
22766
23523
  ] }),
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)(
23524
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
23525
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: "task-view__archived-toggle", children: [
23526
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22770
23527
  "input",
22771
23528
  {
22772
23529
  type: "checkbox",
@@ -22777,42 +23534,42 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22777
23534
  ),
22778
23535
  "Show archived"
22779
23536
  ] }),
22780
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "app__new-chat-btn", onClick: onNewTask, style: { padding: "4px 10px", fontSize: "11px" }, children: "+ New Task" })
23537
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "app__new-chat-btn", onClick: onNewTask, style: { padding: "4px 10px", fontSize: "11px" }, children: "+ New Task" })
22781
23538
  ] })
22782
23539
  ] }),
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: [
23540
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { flex: 1, overflowY: "auto", padding: "0 16px 16px" }, children: allTasksCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { children: [
22784
23541
  "No tasks created for ",
22785
23542
  project.name,
22786
23543
  '. 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" } })
23544
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("table", { className: "task-table", children: [
23545
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("tr", { children: [
23546
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "60px" }, children: "#" }),
23547
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", children: "Title" }),
23548
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "90px" }, children: "Status" }),
23549
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "100px" }, children: "Agent" }),
23550
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "120px" }, children: "Checklist" }),
23551
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "180px" }, children: "Branch" }),
23552
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "150px" }, children: "Updated" }),
23553
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { className: "task-table__th", style: { width: "70px" } })
22797
23554
  ] }) }),
22798
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tbody", { children: tasks.map((task) => {
23555
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tbody", { children: tasks.map((task) => {
22799
23556
  const completedCount = task.checklist.filter((c2) => c2.status === "done").length;
22800
23557
  const totalCount = task.checklist.length;
22801
23558
  const isArchived = !!task.archived;
22802
23559
  const updated = new Date(task.updatedAt);
22803
23560
  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)(
23561
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22805
23562
  "tr",
22806
23563
  {
22807
23564
  className: `task-table__row${isArchived ? " task-table__row--archived" : ""}`,
22808
23565
  onClick: () => onOpenLog(task),
22809
23566
  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 }),
23567
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td task-table__td--mono", children: task.id }),
23568
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "task-table__title", children: [
23569
+ isArchived && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Archive, { size: 11 }),
22813
23570
  task.title
22814
23571
  ] }) }),
22815
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23572
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22816
23573
  "span",
22817
23574
  {
22818
23575
  className: "task-table__badge",
@@ -22820,28 +23577,28 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22820
23577
  children: task.status
22821
23578
  }
22822
23579
  ) }),
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)(
23580
+ /* @__PURE__ */ (0, import_jsx_runtime21.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_runtime21.jsx)("span", { style: { opacity: 0.4 }, children: "default" }) }),
23581
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td", children: totalCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "task-table__progress", children: [
23582
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "task-table__progress-bar", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22826
23583
  "span",
22827
23584
  {
22828
23585
  className: "task-table__progress-fill",
22829
23586
  style: { width: `${completedCount / totalCount * 100}%` }
22830
23587
  }
22831
23588
  ) }),
22832
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__progress-text", children: [
23589
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "task-table__progress-text", children: [
22833
23590
  completedCount,
22834
23591
  "/",
22835
23592
  totalCount
22836
23593
  ] })
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)(
23594
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
23595
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td", children: task.branch ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "task-table__branch", children: [
23596
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(GitBranch, { size: 11 }),
23597
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { children: task.branch })
23598
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { opacity: 0.4, fontSize: "11px" }, children: "\u2014" }) }),
23599
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td task-table__td--muted", children: updatedStr }),
23600
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { className: "task-table__td", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "inline-flex", gap: "2px" }, children: [
23601
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22845
23602
  "button",
22846
23603
  {
22847
23604
  className: "task-table__edit-btn",
@@ -22851,10 +23608,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22851
23608
  },
22852
23609
  title: task.archived ? "Unarchive task" : "Archive task",
22853
23610
  "aria-label": task.archived ? "Unarchive task" : "Archive task",
22854
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Archive, { size: 13 })
23611
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Archive, { size: 13 })
22855
23612
  }
22856
23613
  ),
22857
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23614
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22858
23615
  "button",
22859
23616
  {
22860
23617
  className: "task-table__edit-btn",
@@ -22864,7 +23621,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22864
23621
  },
22865
23622
  title: "Edit task",
22866
23623
  "aria-label": "Edit task",
22867
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Pencil, { size: 13 })
23624
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Pencil, { size: 13 })
22868
23625
  }
22869
23626
  )
22870
23627
  ] }) })
@@ -22874,8 +23631,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22874
23631
  );
22875
23632
  }) })
22876
23633
  ] }) }),
22877
- totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "task-table__pagination", children: [
22878
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23634
+ totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "task-table__pagination", children: [
23635
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22879
23636
  "button",
22880
23637
  {
22881
23638
  className: "task-table__page-btn",
@@ -22884,13 +23641,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22884
23641
  children: "\u2039 Prev"
22885
23642
  }
22886
23643
  ),
22887
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "task-table__page-info", children: [
23644
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "task-table__page-info", children: [
22888
23645
  "Page ",
22889
23646
  page + 1,
22890
23647
  " of ",
22891
23648
  totalPages
22892
23649
  ] }),
22893
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23650
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22894
23651
  "button",
22895
23652
  {
22896
23653
  className: "task-table__page-btn",
@@ -22918,31 +23675,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22918
23675
  }) {
22919
23676
  const completedCount = task.checklist.filter((c2) => c2.status === "done").length;
22920
23677
  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)(() => {
23678
+ const chatItems = (0, import_react22.useMemo)(() => taskMessagesToChatItems(taskMessages, agentLabels), [taskMessages, agentLabels]);
23679
+ const [openCycle, setOpenCycle] = (0, import_react22.useState)(null);
23680
+ const [draft, setDraft] = (0, import_react22.useState)("");
23681
+ const openCycleItem = (0, import_react22.useCallback)((item) => setOpenCycle(item), []);
23682
+ const autoOpenedFor = (0, import_react22.useRef)(null);
23683
+ (0, import_react22.useEffect)(() => {
22927
23684
  if (autoOpenedFor.current === task.id || taskMessages.length === 0) return;
22928
23685
  autoOpenedFor.current = task.id;
22929
23686
  const latest = [...chatItems].reverse().find((i) => i.kind === "cycle");
22930
23687
  if (latest && latest.outcome === "running") setOpenCycle(latest);
22931
23688
  }, [task.id, taskMessages.length, chatItems]);
22932
23689
  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: [
23690
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%" }, children: [
23691
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("header", { className: "app__chat-header task-view__sub-header", style: { padding: "12px 14px" }, children: [
23692
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23693
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArrowLeft, { size: 13 }) }),
23694
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "app__chat-header-info", children: [
23695
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("h3", { className: "app__chat-header-title", style: { fontSize: "13px", margin: 0 }, children: [
22939
23696
  "Task #",
22940
23697
  task.id,
22941
23698
  ": ",
22942
23699
  task.title
22943
23700
  ] }),
22944
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: [
22945
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23701
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "app__chat-header-status", style: { fontSize: "10px" }, children: [
23702
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22946
23703
  "span",
22947
23704
  {
22948
23705
  className: `agent-status-dot agent-status-dot--active ${isActiveLike ? "agent-status-dot--pulsing" : ""}`,
@@ -22953,24 +23710,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22953
23710
  ] })
22954
23711
  ] })
22955
23712
  ] }),
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)(
23713
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
23714
+ task.status !== "done" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22958
23715
  "button",
22959
23716
  {
22960
23717
  className: "confirm__btn confirm__btn--primary",
22961
23718
  onClick: () => onToggleStatus(task),
22962
23719
  title: isActiveLike ? "Pause this task (aborts the running agent)" : "Activate this task",
22963
23720
  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 }),
23721
+ children: isActiveLike ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
23722
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Pause, { size: 12 }),
22966
23723
  " Pause"
22967
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
22968
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Play, { size: 12 }),
23724
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
23725
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Play, { size: 12 }),
22969
23726
  " Activate"
22970
23727
  ] })
22971
23728
  }
22972
23729
  ),
22973
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23730
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
22974
23731
  "span",
22975
23732
  {
22976
23733
  className: "task-table__badge",
@@ -22980,8 +23737,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22980
23737
  )
22981
23738
  ] })
22982
23739
  ] }),
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)(
23740
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "row" }, children: [
23741
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
22985
23742
  "aside",
22986
23743
  {
22987
23744
  style: {
@@ -22994,19 +23751,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
22994
23751
  background: "var(--vscode-sideBar-background, rgba(0,0,0,0.1))"
22995
23752
  },
22996
23753
  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: [
23754
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: "10px 12px", borderBottom: "1px solid var(--vscode-panel-border, rgba(255,255,255,0.05))" }, children: [
23755
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: 0, fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
23756
+ totalCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { fontSize: "10px", opacity: 0.5, marginTop: "2px" }, children: [
23000
23757
  completedCount,
23001
23758
  "/",
23002
23759
  totalCount,
23003
23760
  " done"
23004
23761
  ] })
23005
23762
  ] }),
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) => {
23763
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { padding: "8px 10px", display: "flex", flexDirection: "column", gap: "4px" }, children: totalCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "11px", opacity: 0.4, padding: "8px 4px" }, children: "No checklist items." }) : (task.checklist || []).map((item) => {
23007
23764
  const isDone = item.status === "done";
23008
23765
  const isInProgress = item.status === "in_progress";
23009
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23766
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23010
23767
  "label",
23011
23768
  {
23012
23769
  style: {
@@ -23023,7 +23780,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23023
23780
  },
23024
23781
  title: isInProgress ? "In progress" : isDone ? "Done" : "Pending",
23025
23782
  children: [
23026
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23783
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23027
23784
  "input",
23028
23785
  {
23029
23786
  type: "checkbox",
@@ -23032,7 +23789,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23032
23789
  style: { marginTop: "2px", cursor: "pointer", flexShrink: 0 }
23033
23790
  }
23034
23791
  ),
23035
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { style: { wordBreak: "break-word" }, children: item.text })
23792
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { wordBreak: "break-word" }, children: item.text })
23036
23793
  ]
23037
23794
  },
23038
23795
  item.id
@@ -23041,8 +23798,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23041
23798
  ]
23042
23799
  }
23043
23800
  ),
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)(
23801
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: [
23802
+ liveCycle ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23046
23803
  TaskCycleView,
23047
23804
  {
23048
23805
  item: liveCycle,
@@ -23050,8 +23807,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23050
23807
  onBack: () => setOpenCycle(null)
23051
23808
  },
23052
23809
  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)(
23810
+ ) : taskMessages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "messages messages--empty", children: "No messages in this execution yet. Agent will start on next tick." }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MessageList, { items: chatItems, sessionId: null, compact: true, onOpenCycle: openCycleItem }),
23811
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23055
23812
  Composer,
23056
23813
  {
23057
23814
  disabled: isSending,
@@ -23088,12 +23845,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23088
23845
  statusColor
23089
23846
  }) {
23090
23847
  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);
23848
+ const [draftTitle, setDraftTitle] = (0, import_react22.useState)(task.title);
23849
+ const [draftObjective, setDraftObjective] = (0, import_react22.useState)(task.objective);
23850
+ const [lastTaskId, setLastTaskId] = (0, import_react22.useState)(task.id);
23094
23851
  const trimmedTitle = draftTitle.trim();
23095
23852
  const isDirty = trimmedTitle !== task.title.trim() || draftObjective.trim() !== task.objective.trim();
23096
- (0, import_react20.useEffect)(() => {
23853
+ (0, import_react22.useEffect)(() => {
23097
23854
  if (task.id !== lastTaskId) {
23098
23855
  setDraftTitle(task.title);
23099
23856
  setDraftObjective(task.objective);
@@ -23108,16 +23865,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23108
23865
  setDraftTitle(task.title);
23109
23866
  setDraftObjective(task.objective);
23110
23867
  };
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: [
23868
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", height: "100%", overflowY: "auto" }, children: [
23869
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "task-view__sub-header", style: { padding: "12px 14px", display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
23870
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
23871
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "settings-panel__back-btn", onClick: onBack, title: "Back to task list", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArrowLeft, { size: 13 }) }),
23872
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("h3", { style: { margin: 0, fontSize: "15px", fontWeight: 700, display: "flex", alignItems: "center", gap: "6px" }, children: [
23873
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { style: { opacity: 0.6 }, children: [
23117
23874
  "Task #",
23118
23875
  task.id
23119
23876
  ] }),
23120
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23877
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23121
23878
  "input",
23122
23879
  {
23123
23880
  value: draftTitle,
@@ -23138,7 +23895,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23138
23895
  }
23139
23896
  )
23140
23897
  ] }),
23141
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23898
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23142
23899
  "span",
23143
23900
  {
23144
23901
  className: "task-table__badge",
@@ -23147,8 +23904,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23147
23904
  }
23148
23905
  )
23149
23906
  ] }),
23150
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { display: "inline-flex", gap: "6px" }, children: [
23151
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23907
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "inline-flex", gap: "6px" }, children: [
23908
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23152
23909
  "button",
23153
23910
  {
23154
23911
  className: "confirm__btn",
@@ -23158,7 +23915,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23158
23915
  children: "View Log"
23159
23916
  }
23160
23917
  ),
23161
- task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23918
+ task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23162
23919
  "button",
23163
23920
  {
23164
23921
  className: "confirm__btn",
@@ -23166,12 +23923,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23166
23923
  title: `Commit pending changes to ${task.branch} and remove the worktree`,
23167
23924
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
23168
23925
  children: [
23169
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(GitBranch, { size: 12 }),
23926
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(GitBranch, { size: 12 }),
23170
23927
  " Discard worktree"
23171
23928
  ]
23172
23929
  }
23173
23930
  ),
23174
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23931
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23175
23932
  "button",
23176
23933
  {
23177
23934
  className: "confirm__btn",
@@ -23179,28 +23936,28 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23179
23936
  title: task.archived ? "Unarchive this task" : "Archive this task (hides it from the list, excludes from scheduler)",
23180
23937
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
23181
23938
  children: [
23182
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Archive, { size: 12 }),
23939
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Archive, { size: 12 }),
23183
23940
  " ",
23184
23941
  task.archived ? "Unarchive" : "Archive"
23185
23942
  ]
23186
23943
  }
23187
23944
  ),
23188
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
23945
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23189
23946
  "button",
23190
23947
  {
23191
23948
  className: "confirm__btn confirm__btn--primary",
23192
23949
  onClick: () => onToggleStatus(task),
23193
23950
  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 }),
23951
+ children: task.status === "active" || task.status === "reviewing" || task.status === "planning" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
23952
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Pause, { size: 12 }),
23196
23953
  " Pause"
23197
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
23198
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Play, { size: 12 }),
23954
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
23955
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Play, { size: 12 }),
23199
23956
  " Activate"
23200
23957
  ] })
23201
23958
  }
23202
23959
  ),
23203
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
23960
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23204
23961
  "button",
23205
23962
  {
23206
23963
  className: "confirm__btn",
@@ -23208,22 +23965,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23208
23965
  title: "Permanently delete this task and all its messages",
23209
23966
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px", color: "#ef4444" },
23210
23967
  children: [
23211
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Trash, { size: 12 }),
23968
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Trash, { size: 12 }),
23212
23969
  " Delete"
23213
23970
  ]
23214
23971
  }
23215
23972
  )
23216
23973
  ] })
23217
23974
  ] }),
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)" })
23975
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: "16px", maxWidth: "720px" }, children: [
23976
+ task.branch && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px", display: "flex", alignItems: "center", gap: "6px", fontSize: "11px", opacity: 0.75 }, children: [
23977
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(GitBranch, { size: 12 }),
23978
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("code", { style: { fontFamily: "monospace" }, children: task.branch }),
23979
+ !task.worktreePath && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { opacity: 0.6 }, children: "(worktree removed)" })
23223
23980
  ] }),
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)(
23981
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px" }, children: [
23982
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Objective" }),
23983
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23227
23984
  "textarea",
23228
23985
  {
23229
23986
  value: draftObjective,
@@ -23247,8 +24004,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23247
24004
  }
23248
24005
  }
23249
24006
  ),
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)(
24007
+ isDirty && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", gap: "6px", alignItems: "center", marginTop: "8px" }, children: [
24008
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23252
24009
  "button",
23253
24010
  {
23254
24011
  className: "confirm__btn confirm__btn--primary",
@@ -23261,13 +24018,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23261
24018
  children: "Save"
23262
24019
  }
23263
24020
  ),
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." })
24021
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { className: "confirm__btn", onClick: resetDraft, style: { padding: "3px 10px", fontSize: "10px" }, children: "Cancel" }),
24022
+ isRunning && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", opacity: 0.6 }, children: "Applies from the next cycle." })
23266
24023
  ] })
23267
24024
  ] }),
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)(
24025
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24026
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Assigned Agent" }),
24027
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23271
24028
  "select",
23272
24029
  {
23273
24030
  value: task.agentId || "",
@@ -23287,8 +24044,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23287
24044
  },
23288
24045
  title: isRunning ? "Pause the task before changing its agent" : "Choose which agent runs this task",
23289
24046
  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: [
24047
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
24048
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
23292
24049
  a2.name,
23293
24050
  " (",
23294
24051
  a2.provider,
@@ -23298,9 +24055,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23298
24055
  }
23299
24056
  )
23300
24057
  ] }),
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)(
24058
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24059
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Planner Agent" }),
24060
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23304
24061
  "select",
23305
24062
  {
23306
24063
  value: task.plannerAgentId || "",
@@ -23309,8 +24066,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23309
24066
  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
24067
  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
24068
  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: [
24069
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
24070
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
23314
24071
  a2.name,
23315
24072
  " (",
23316
24073
  a2.provider,
@@ -23320,9 +24077,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23320
24077
  }
23321
24078
  )
23322
24079
  ] }),
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)(
24080
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24081
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Reviewer Agent" }),
24082
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23326
24083
  "select",
23327
24084
  {
23328
24085
  value: task.reviewerAgentId || "",
@@ -23331,8 +24088,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23331
24088
  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
24089
  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
24090
  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: [
24091
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Project default" }),
24092
+ agents.map((a2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: a2.id, children: [
23336
24093
  a2.name,
23337
24094
  " (",
23338
24095
  a2.provider,
@@ -23342,31 +24099,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23342
24099
  }
23343
24100
  )
23344
24101
  ] }),
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: [
24102
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { marginBottom: "16px" }, children: [
24103
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 6px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Phases" }),
24104
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { display: "flex", gap: "12px" }, children: [
23348
24105
  { flag: "planningEnabled", label: "Planning phase", value: task.planningEnabled },
23349
24106
  { flag: "reviewEnabled", label: "Review at DONE", value: task.reviewEnabled },
23350
24107
  { 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: [
24108
+ ].map(({ flag, label, value }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", flex: 1 }, children: [
23352
24109
  label,
23353
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24110
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23354
24111
  "select",
23355
24112
  {
23356
24113
  value: value === true ? "on" : value === false ? "off" : "inherit",
23357
24114
  onChange: (e) => onSetFlag(task, flag, e.target.value === "inherit" ? null : e.target.value === "on"),
23358
24115
  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
24116
  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" })
24117
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "inherit", children: "Project default" }),
24118
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "on", children: "On" }),
24119
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "off", children: "Off" })
23363
24120
  ]
23364
24121
  }
23365
24122
  )
23366
24123
  ] }, flag)) }),
23367
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", marginTop: "12px", maxWidth: "260px" }, children: [
24124
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", marginTop: "12px", maxWidth: "260px" }, children: [
23368
24125
  "Max run seconds per cycle",
23369
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24126
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23370
24127
  "input",
23371
24128
  {
23372
24129
  type: "number",
@@ -23389,7 +24146,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23389
24146
  )
23390
24147
  ] })
23391
24148
  ] }),
23392
- task.status === "blocked" && task.blockedReason && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24149
+ task.status === "blocked" && task.blockedReason && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23393
24150
  "div",
23394
24151
  {
23395
24152
  style: {
@@ -23402,19 +24159,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23402
24159
  fontSize: "12px"
23403
24160
  },
23404
24161
  children: [
23405
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("strong", { children: [
23406
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TriangleAlert, { size: 13 }),
24162
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { children: [
24163
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TriangleAlert, { size: 13 }),
23407
24164
  " Blocked Reason:"
23408
24165
  ] }),
23409
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { style: { margin: "4px 0 0 0" }, children: task.blockedReason })
24166
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { style: { margin: "4px 0 0 0" }, children: task.blockedReason })
23410
24167
  ]
23411
24168
  }
23412
24169
  ),
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) => {
24170
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
24171
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h4", { style: { margin: "0 0 8px 0", fontSize: "10px", textTransform: "uppercase", letterSpacing: "0.08em", opacity: 0.6 }, children: "Checklist" }),
24172
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: (task.checklist || []).map((item) => {
23416
24173
  const isDone = item.status === "done";
23417
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
24174
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
23418
24175
  "label",
23419
24176
  {
23420
24177
  style: {
@@ -23431,7 +24188,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23431
24188
  opacity: isDone ? 0.6 : 1
23432
24189
  },
23433
24190
  children: [
23434
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24191
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
23435
24192
  "input",
23436
24193
  {
23437
24194
  type: "checkbox",
@@ -23440,7 +24197,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23440
24197
  style: { marginTop: "2px", cursor: "pointer" }
23441
24198
  }
23442
24199
  ),
23443
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: item.text })
24200
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: item.text })
23444
24201
  ]
23445
24202
  },
23446
24203
  item.id
@@ -23452,7 +24209,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23452
24209
  }
23453
24210
 
23454
24211
  // src/useVoice.ts
23455
- var import_react21 = __toESM(require_react(), 1);
24212
+ var import_react23 = __toESM(require_react(), 1);
23456
24213
  function canCapture() {
23457
24214
  return typeof window !== "undefined" && typeof MediaRecorder !== "undefined" && !!navigator.mediaDevices?.getUserMedia;
23458
24215
  }
@@ -23477,37 +24234,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23477
24234
  const { voice, chatStatus, pendingConfirmCount, items, onTranscript } = opts;
23478
24235
  const available = !!voice && voice.enabled && voice.configured && canCapture();
23479
24236
  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);
24237
+ const [phase, setPhase] = (0, import_react23.useState)("idle");
24238
+ const [mode, setMode] = (0, import_react23.useState)("dictate");
24239
+ const [error, setError] = (0, import_react23.useState)(null);
24240
+ const bufferMsRef = (0, import_react23.useRef)(voice?.playbackBufferMs);
24241
+ bufferMsRef.current = voice?.playbackBufferMs;
24242
+ const phaseRef = (0, import_react23.useRef)(phase);
23484
24243
  phaseRef.current = phase;
23485
- const modeRef = (0, import_react21.useRef)(mode);
24244
+ const modeRef = (0, import_react23.useRef)(mode);
23486
24245
  modeRef.current = mode;
23487
- const onTranscriptRef = (0, import_react21.useRef)(onTranscript);
24246
+ const onTranscriptRef = (0, import_react23.useRef)(onTranscript);
23488
24247
  onTranscriptRef.current = onTranscript;
23489
- const itemsRef = (0, import_react21.useRef)(items);
24248
+ const itemsRef = (0, import_react23.useRef)(items);
23490
24249
  itemsRef.current = items;
23491
- const chatStatusRef = (0, import_react21.useRef)(chatStatus);
24250
+ const chatStatusRef = (0, import_react23.useRef)(chatStatus);
23492
24251
  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) => {
24252
+ const streamRef = (0, import_react23.useRef)(null);
24253
+ const recorderRef = (0, import_react23.useRef)(null);
24254
+ const chunksRef = (0, import_react23.useRef)([]);
24255
+ const vadRef = (0, import_react23.useRef)(null);
24256
+ const speechAbortRef = (0, import_react23.useRef)(null);
24257
+ const idleTimerRef = (0, import_react23.useRef)(null);
24258
+ const heardSpeechRef = (0, import_react23.useRef)(false);
24259
+ const sawStreamingRef = (0, import_react23.useRef)(false);
24260
+ const cursorRef = (0, import_react23.useRef)(0);
24261
+ const queueRef = (0, import_react23.useRef)([]);
24262
+ const apply = (0, import_react23.useCallback)((event) => {
23504
24263
  setPhase((current) => nextPhase(current, event));
23505
24264
  }, []);
23506
24265
  const clearIdleTimer = () => {
23507
24266
  if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
23508
24267
  idleTimerRef.current = null;
23509
24268
  };
23510
- const teardownCapture = (0, import_react21.useCallback)(() => {
24269
+ const teardownCapture = (0, import_react23.useCallback)(() => {
23511
24270
  clearIdleTimer();
23512
24271
  try {
23513
24272
  vadRef.current?.destroy();
@@ -23524,14 +24283,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23524
24283
  chunksRef.current = [];
23525
24284
  heardSpeechRef.current = false;
23526
24285
  }, []);
23527
- const stopPlayback = (0, import_react21.useCallback)(() => {
23528
- if (audioRef.current) {
23529
- audioRef.current.pause();
23530
- audioRef.current.src = "";
23531
- audioRef.current = null;
23532
- }
24286
+ const stopPlayback = (0, import_react23.useCallback)(() => {
24287
+ speechAbortRef.current?.abort();
24288
+ speechAbortRef.current = null;
23533
24289
  }, []);
23534
- const fail = (0, import_react21.useCallback)(
24290
+ const fail = (0, import_react23.useCallback)(
23535
24291
  (message) => {
23536
24292
  teardownCapture();
23537
24293
  stopPlayback();
@@ -23540,7 +24296,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23540
24296
  },
23541
24297
  [apply, teardownCapture, stopPlayback]
23542
24298
  );
23543
- const finishRecording = (0, import_react21.useCallback)(() => {
24299
+ const finishRecording = (0, import_react23.useCallback)(() => {
23544
24300
  const recorder = recorderRef.current;
23545
24301
  if (!recorder || recorder.state === "inactive") return;
23546
24302
  recorder.onstop = async () => {
@@ -23569,7 +24325,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23569
24325
  };
23570
24326
  recorder.stop();
23571
24327
  }, [apply, fail, teardownCapture]);
23572
- const startRecording = (0, import_react21.useCallback)(async () => {
24328
+ const startRecording = (0, import_react23.useCallback)(async () => {
23573
24329
  setError(null);
23574
24330
  chunksRef.current = [];
23575
24331
  heardSpeechRef.current = false;
@@ -23614,7 +24370,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23614
24370
  fail(`Microphone unavailable: ${err}`);
23615
24371
  }
23616
24372
  }, [apply, fail, finishRecording, teardownCapture]);
23617
- const speakReply = (0, import_react21.useCallback)(async () => {
24373
+ const speakReply = (0, import_react23.useCallback)(async () => {
23618
24374
  const text = queueRef.current.shift();
23619
24375
  if (!text) {
23620
24376
  apply({
@@ -23624,44 +24380,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23624
24380
  });
23625
24381
  return;
23626
24382
  }
24383
+ const ac = new AbortController();
24384
+ speechAbortRef.current = ac;
23627
24385
  try {
23628
24386
  const res = await fetch("/api/voice/speak", {
23629
24387
  method: "POST",
23630
24388
  headers: { "content-type": "application/json" },
23631
- body: JSON.stringify({ text: stripMarkdownForSpeech(text) })
24389
+ body: JSON.stringify({ text: stripMarkdownForSpeech(text) }),
24390
+ signal: ac.signal
23632
24391
  });
23633
24392
  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();
24393
+ await playSpeech(res, ac.signal, { bufferMs: bufferMsRef.current });
24394
+ if (ac.signal.aborted) return;
24395
+ speechAbortRef.current = null;
24396
+ setTimeout(() => {
24397
+ if (queueRef.current.length > 0) {
24398
+ void speakReply();
24399
+ } else {
24400
+ apply({
24401
+ kind: "playbackEnded",
24402
+ mode: "conversation",
24403
+ turnComplete: chatStatusRef.current === "idle"
24404
+ });
24405
+ }
24406
+ }, POST_PLAYBACK_MS);
23657
24407
  } catch (err) {
24408
+ if (ac.signal.aborted) return;
23658
24409
  fail(`Synthesis failed: ${err}`);
23659
24410
  }
23660
24411
  }, [apply, fail]);
23661
- (0, import_react21.useEffect)(() => {
24412
+ (0, import_react23.useEffect)(() => {
23662
24413
  if (chatStatus === "streaming") sawStreamingRef.current = true;
23663
24414
  }, [chatStatus]);
23664
- (0, import_react21.useEffect)(() => {
24415
+ (0, import_react23.useEffect)(() => {
23665
24416
  if (modeRef.current !== "conversation") return;
23666
24417
  if (phaseRef.current === "idle") return;
23667
24418
  const { texts, cursor } = takeFinalizedBubbles(items, cursorRef.current);
@@ -23670,7 +24421,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23670
24421
  queueRef.current.push(...texts);
23671
24422
  apply({ kind: "speechQueued", mode: "conversation", canSpeak });
23672
24423
  }, [items, canSpeak, apply]);
23673
- (0, import_react21.useEffect)(() => {
24424
+ (0, import_react23.useEffect)(() => {
23674
24425
  if (phase !== "awaiting") return;
23675
24426
  if (chatStatus === "error") {
23676
24427
  apply({ kind: "failed", mode: "conversation" });
@@ -23692,8 +24443,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23692
24443
  pendingSpeech: queueRef.current.length
23693
24444
  });
23694
24445
  }, [phase, chatStatus, pendingConfirmCount, canSpeak, apply]);
23695
- const prevPhase = (0, import_react21.useRef)("idle");
23696
- (0, import_react21.useEffect)(() => {
24446
+ const prevPhase = (0, import_react23.useRef)("idle");
24447
+ (0, import_react23.useEffect)(() => {
23697
24448
  const from = prevPhase.current;
23698
24449
  prevPhase.current = phase;
23699
24450
  if (from === phase) return;
@@ -23705,14 +24456,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23705
24456
  queueRef.current = [];
23706
24457
  }
23707
24458
  }, [phase, startRecording, speakReply, teardownCapture, stopPlayback]);
23708
- (0, import_react21.useEffect)(
24459
+ (0, import_react23.useEffect)(
23709
24460
  () => () => {
23710
24461
  teardownCapture();
23711
24462
  stopPlayback();
23712
24463
  },
23713
24464
  [teardownCapture, stopPlayback]
23714
24465
  );
23715
- const toggle = (0, import_react21.useCallback)(() => {
24466
+ const toggle = (0, import_react23.useCallback)(() => {
23716
24467
  if (!available) return;
23717
24468
  const current = phaseRef.current;
23718
24469
  if (current === "idle") {
@@ -23726,7 +24477,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23726
24477
  }
23727
24478
  apply({ kind: "userStop", mode: modeRef.current });
23728
24479
  }, [available, apply, finishRecording]);
23729
- const changeMode = (0, import_react21.useCallback)(
24480
+ const changeMode = (0, import_react23.useCallback)(
23730
24481
  (next) => {
23731
24482
  apply({ kind: "userStop", mode: modeRef.current });
23732
24483
  setMode(next);
@@ -23737,34 +24488,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23737
24488
  }
23738
24489
 
23739
24490
  // src/App.tsx
23740
- var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
24491
+ var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
24492
+ function takeInjectedActivation() {
24493
+ const w2 = window;
24494
+ const id = typeof w2.__caretakerAssistant === "string" ? w2.__caretakerAssistant : null;
24495
+ delete w2.__caretakerAssistant;
24496
+ return id;
24497
+ }
23741
24498
  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)(() => {
24499
+ const [chatState, dispatch] = (0, import_react24.useReducer)(chatReducer, initialChatState);
24500
+ const [agents, setAgents] = (0, import_react24.useState)([]);
24501
+ const [sessions, setSessions] = (0, import_react24.useState)([]);
24502
+ const [selectedAgentId, setSelectedAgentId] = (0, import_react24.useState)(null);
24503
+ const [selectedSessionId, setSelectedSessionId] = (0, import_react24.useState)(null);
24504
+ const [showSessions, setShowSessions] = (0, import_react24.useState)(false);
24505
+ const [showAllAgents, setShowAllAgents] = (0, import_react24.useState)(false);
24506
+ const [pendingDelete, setPendingDelete] = (0, import_react24.useState)(null);
24507
+ const [activeScreen, setActiveScreen] = (0, import_react24.useState)("chat");
24508
+ const [settingsTab, setSettingsTab] = (0, import_react24.useState)();
24509
+ const [settingsData, setSettingsData] = (0, import_react24.useState)(null);
24510
+ const [modelsResult, setModelsResult] = (0, import_react24.useState)(null);
24511
+ const [acpRegistry, setAcpRegistry] = (0, import_react24.useState)(null);
24512
+ const [acpInstall, setAcpInstall] = (0, import_react24.useState)(null);
24513
+ const [refreshingSourceId, setRefreshingSourceId] = (0, import_react24.useState)(null);
24514
+ const [refreshOutcome, setRefreshOutcome] = (0, import_react24.useState)(null);
24515
+ const [mcpAuthOutcome, setMcpAuthOutcome] = (0, import_react24.useState)(null);
24516
+ const [taskRuns, setTaskRuns] = (0, import_react24.useState)({});
24517
+ const [voiceConfig, setVoiceConfig] = (0, import_react24.useState)(null);
24518
+ const [sttCatalogResult, setSttCatalogResult] = (0, import_react24.useState)(null);
24519
+ const [ttsCatalogResult, setTtsCatalogResult] = (0, import_react24.useState)(null);
24520
+ const [composerDraft, setComposerDraft] = (0, import_react24.useState)("");
24521
+ const [activation, setActivation] = (0, import_react24.useState)(null);
24522
+ const [confirmedAgentId, setConfirmedAgentId] = (0, import_react24.useState)(null);
24523
+ const [pendingAssistantId, setPendingAssistantId] = (0, import_react24.useState)(() => takeInjectedActivation());
24524
+ const [composerFocusToken, setComposerFocusToken] = (0, import_react24.useState)(0);
24525
+ (0, import_react24.useEffect)(() => {
23765
24526
  postMessage({ type: "webviewReady" });
23766
24527
  }, []);
23767
- (0, import_react22.useEffect)(() => {
24528
+ (0, import_react24.useEffect)(() => {
23768
24529
  function handle(event) {
23769
24530
  const msg = event.data;
23770
24531
  if (!msg || typeof msg !== "object" || !("type" in msg)) return;
@@ -23805,6 +24566,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23805
24566
  return;
23806
24567
  case "error":
23807
24568
  dispatch({ kind: "error", text: msg.message });
24569
+ setActivation(onSelectFailed);
23808
24570
  return;
23809
24571
  case "contextUsage":
23810
24572
  dispatch({ kind: "context-usage", usage: msg.usage });
@@ -23857,11 +24619,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23857
24619
  case "voiceConfig":
23858
24620
  setVoiceConfig(msg.voice);
23859
24621
  return;
24622
+ case "assistantActivate":
24623
+ takeInjectedActivation();
24624
+ setPendingAssistantId(msg.agentId);
24625
+ return;
24626
+ case "agentSelected":
24627
+ setConfirmedAgentId(msg.agentId);
24628
+ setActivation((cur) => onAgentSelected(cur, msg.agentId));
24629
+ return;
23860
24630
  }
23861
24631
  }
23862
24632
  window.addEventListener("message", handle);
23863
24633
  return () => window.removeEventListener("message", handle);
23864
- }, [selectedAgentId]);
24634
+ }, [selectedAgentId, agents]);
23865
24635
  const voice = useVoice({
23866
24636
  voice: voiceConfig,
23867
24637
  chatStatus: chatState.status,
@@ -23887,15 +24657,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23887
24657
  if (voice2) msg.voice = true;
23888
24658
  postMessage(msg);
23889
24659
  };
23890
- const onConfirm = (0, import_react22.useCallback)((id, decision) => {
24660
+ const onConfirm = (0, import_react24.useCallback)((id, decision) => {
23891
24661
  dispatch({ kind: "permission-resolved", id });
23892
24662
  postMessage({ type: "permission_response", id, decision });
23893
24663
  }, [postMessage]);
23894
24664
  const onAbort = () => {
23895
24665
  postMessage({ type: "abort" });
23896
24666
  };
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)),
24667
+ const confirmCards = (0, import_react24.useMemo)(
24668
+ () => chatState.pendingConfirms.map((p) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ConfirmCard, { pending: p, onDecide: onConfirm }, p.id)),
23899
24669
  [chatState.pendingConfirms, onConfirm]
23900
24670
  );
23901
24671
  const onSelectAgent = (agentId) => {
@@ -23935,7 +24705,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23935
24705
  const cancelDeleteSession = () => {
23936
24706
  setPendingDelete(null);
23937
24707
  };
23938
- (0, import_react22.useEffect)(() => {
24708
+ (0, import_react24.useEffect)(() => {
23939
24709
  if (!pendingDelete) return;
23940
24710
  function handleKeyDown(event) {
23941
24711
  if (event.key === "Escape") {
@@ -23950,7 +24720,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23950
24720
  setShowSessions(!showSessions);
23951
24721
  }
23952
24722
  };
23953
- (0, import_react22.useEffect)(() => {
24723
+ (0, import_react24.useEffect)(() => {
23954
24724
  function handleClickOutside(event) {
23955
24725
  const target = event.target;
23956
24726
  if (showSessions && !target.closest(".app__sessions-dropdown")) {
@@ -23960,6 +24730,37 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23960
24730
  document.addEventListener("mousedown", handleClickOutside);
23961
24731
  return () => document.removeEventListener("mousedown", handleClickOutside);
23962
24732
  }, [showSessions]);
24733
+ (0, import_react24.useEffect)(() => {
24734
+ if (!pendingAssistantId) return;
24735
+ const r = resolvePending(pendingAssistantId, confirmedAgentId, agents.map((a2) => a2.id), activation);
24736
+ setPendingAssistantId(r.pending);
24737
+ if (r.pending || r.activation === activation) return;
24738
+ setActiveScreen("chat");
24739
+ if (r.activation?.step === "awaiting-agent") onSelectAgent(r.activation.agentId);
24740
+ setActivation(r.activation);
24741
+ }, [pendingAssistantId, agents]);
24742
+ (0, import_react24.useEffect)(() => {
24743
+ if (activation?.step !== "open") return;
24744
+ const adopt = localSelectionFor(activation, selectedAgentId);
24745
+ if (adopt) {
24746
+ setSelectedAgentId(adopt);
24747
+ setShowAllAgents(false);
24748
+ }
24749
+ onCreateSession();
24750
+ if (voice.available) {
24751
+ voice.setMode("conversation");
24752
+ setActivation({ ...activation, step: "mic" });
24753
+ } else {
24754
+ setComposerFocusToken((t) => t + 1);
24755
+ setActivation(null);
24756
+ }
24757
+ }, [activation]);
24758
+ (0, import_react24.useEffect)(() => {
24759
+ if (activation?.step !== "mic") return;
24760
+ if (voice.mode !== "conversation" || voice.phase !== "idle") return;
24761
+ voice.toggle();
24762
+ setActivation(null);
24763
+ }, [activation, voice.mode, voice.phase]);
23963
24764
  const composerDisabled = chatState.status === "streaming" || chatState.pendingConfirms.length > 0 || !selectedAgentId;
23964
24765
  const selectedAgentName = agents.find((a2) => a2.id === selectedAgentId)?.name;
23965
24766
  const activeAgent = agents.find((a2) => a2.id === selectedAgentId);
@@ -23973,30 +24774,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
23973
24774
  { id: "projects", label: "Projects", Icon: FolderKanban },
23974
24775
  { id: "settings", label: "Settings", Icon: Settings }
23975
24776
  ];
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)(
24777
+ const navRail = /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("nav", { className: "app__nav", children: [
24778
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo app__nav-logo" }),
24779
+ navItems.map(({ id, label, Icon: Icon2 }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
23979
24780
  "button",
23980
24781
  {
23981
24782
  className: `app__nav-btn ${activeScreen === id ? "app__nav-btn--active" : ""}`,
23982
24783
  onClick: () => openScreen(id),
23983
24784
  title: label,
23984
24785
  children: [
23985
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon2, { size: 18 }),
23986
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: label })
24786
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Icon2, { size: 18 }),
24787
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: label })
23987
24788
  ]
23988
24789
  },
23989
24790
  id
23990
24791
  ))
23991
24792
  ] });
23992
24793
  if (activeScreen === "projects" && layout === "sidebar") {
23993
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
24794
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app app--with-sidebar", children: [
23994
24795
  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 }) })
24796
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__screen", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ProjectsTab, { agents, onOpenSettings: () => openScreen("settings", "projects"), postMessage }) })
23996
24797
  ] });
23997
24798
  }
23998
24799
  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)(
24800
+ const panel = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `app ${layout === "sidebar" ? "app--settings-centered app__screen" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24000
24801
  SettingsPanel,
24001
24802
  {
24002
24803
  layout,
@@ -24019,44 +24820,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24019
24820
  onClose: () => setActiveScreen("chat")
24020
24821
  }
24021
24822
  ) });
24022
- return layout === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
24823
+ return layout === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app app--with-sidebar", children: [
24023
24824
  navRail,
24024
24825
  panel
24025
24826
  ] }) : panel;
24026
24827
  }
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: [
24828
+ const deleteOverlay = pendingDelete && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__confirm-overlay", onClick: cancelDeleteSession, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__confirm-dialog", onClick: (e) => e.stopPropagation(), children: [
24829
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__confirm-title", children: "Delete conversation" }),
24830
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "app__confirm-message", children: [
24030
24831
  "Delete conversation \u201C",
24031
24832
  pendingDelete.title,
24032
24833
  "\u201D? This cannot be undone."
24033
24834
  ] }),
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" })
24835
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__confirm-buttons", children: [
24836
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "app__confirm-btn", onClick: cancelDeleteSession, children: "Cancel" }),
24837
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { className: "app__confirm-btn app__confirm-btn--danger", onClick: confirmDeleteSession, children: "Delete" })
24037
24838
  ] })
24038
24839
  ] }) });
24039
24840
  if (layout === "sidebar") {
24040
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "app app--with-sidebar", children: [
24841
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app app--with-sidebar", children: [
24041
24842
  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)(
24843
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("aside", { className: "app__sidebar", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sidebar-content", children: [
24844
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sidebar-section", children: [
24845
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sidebar-section-title", children: "Agents" }),
24846
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sidebar-agents-list", children: selectedAgentId && !showAllAgents ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24046
24847
  "button",
24047
24848
  {
24048
24849
  className: "app__sidebar-agent-item app__sidebar-agent-item--collapsed-active",
24049
24850
  onClick: () => setShowAllAgents(true),
24050
24851
  title: "Switch Agent",
24051
24852
  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 })
24853
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "agent-status-dot agent-status-dot--active" }),
24854
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__sidebar-agent-name", children: activeAgent?.name || selectedAgentId }),
24855
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChevronDown, { className: "app__sidebar-chevron", size: 10 })
24055
24856
  ]
24056
24857
  }
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) => {
24858
+ ) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `app__sidebar-agents-list-expanded ${selectedAgentId ? "app__sidebar-agents-list-expanded--has-active" : ""}`, children: agents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sidebar-empty-text", children: "No agents found" }) : agents.map((agent) => {
24058
24859
  const isSelected = selectedAgentId === agent.id;
24059
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
24860
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24060
24861
  "button",
24061
24862
  {
24062
24863
  className: `app__sidebar-agent-item ${isSelected ? "app__sidebar-agent-item--active" : ""}`,
@@ -24064,23 +24865,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24064
24865
  if (isSelected) {
24065
24866
  setShowAllAgents(false);
24066
24867
  } else {
24868
+ setActivation(null);
24067
24869
  onSelectAgent(agent.id);
24068
24870
  }
24069
24871
  },
24070
24872
  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 })
24873
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: `agent-status-dot ${isSelected ? "agent-status-dot--active" : ""}` }),
24874
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__sidebar-agent-name", children: agent.name }),
24875
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ChevronUp, { className: "app__sidebar-chevron app__sidebar-chevron--up", size: 10 })
24074
24876
  ]
24075
24877
  },
24076
24878
  agent.id
24077
24879
  );
24078
24880
  }) }) })
24079
24881
  ] }),
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)(
24882
+ selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sidebar-section", children: [
24883
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sidebar-section-header", children: [
24884
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__sidebar-section-title", children: "Conversations" }),
24885
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24084
24886
  "button",
24085
24887
  {
24086
24888
  className: "app__sidebar-new-chat-btn",
@@ -24090,15 +24892,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24090
24892
  }
24091
24893
  )
24092
24894
  ] }),
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)(
24895
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sidebar-sessions-list", children: sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sidebar-empty-text", children: "No conversations yet" }) : sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24094
24896
  "div",
24095
24897
  {
24096
24898
  className: `app__sidebar-session-item ${selectedSessionId === session.id ? "app__sidebar-session-item--active" : ""}`,
24097
24899
  onClick: () => onSelectSession(session.id),
24098
24900
  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)(
24901
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__sidebar-session-icon", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MessageSquare, { size: 13 }) }),
24902
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__sidebar-session-title", title: session.title, children: session.title }),
24903
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24102
24904
  "button",
24103
24905
  {
24104
24906
  className: "app__sidebar-session-delete",
@@ -24107,7 +24909,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24107
24909
  e.stopPropagation();
24108
24910
  onDeleteSession(session.id, session.title);
24109
24911
  },
24110
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 12 })
24912
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 12 })
24111
24913
  }
24112
24914
  )
24113
24915
  ]
@@ -24116,15 +24918,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24116
24918
  )) })
24117
24919
  ] })
24118
24920
  ] }) }),
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" : ""}` }),
24921
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("main", { className: "app__chat-pane", children: selectedAgentId ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
24922
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("header", { className: "app__chat-header", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__chat-header-info", children: [
24923
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { className: "app__chat-header-title", children: selectedAgentName }),
24924
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "app__chat-header-status", children: [
24925
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: `agent-status-dot agent-status-dot--active ${chatState.status === "streaming" ? "agent-status-dot--pulsing" : ""}` }),
24124
24926
  chatState.status === "streaming" ? "Streaming response..." : "Ready"
24125
24927
  ] })
24126
24928
  ] }) }),
24127
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24929
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24128
24930
  MessageList,
24129
24931
  {
24130
24932
  items: chatState.items,
@@ -24134,15 +24936,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24134
24936
  trailing: confirmCards
24135
24937
  }
24136
24938
  ),
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 }),
24939
+ (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__error", children: [
24940
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TriangleAlert, { size: 14 }),
24139
24941
  " ",
24140
24942
  chatState.errorText || voice.error
24141
24943
  ] }),
24142
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24944
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24143
24945
  Composer,
24144
24946
  {
24145
24947
  disabled: composerDisabled,
24948
+ focusToken: composerFocusToken,
24146
24949
  onSend,
24147
24950
  canAbort: chatState.status === "streaming",
24148
24951
  onAbort,
@@ -24158,30 +24961,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24158
24961
  onValueChange: setComposerDraft
24159
24962
  }
24160
24963
  )
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" }) }) }),
24964
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { children: "Select an agent from the sidebar to start chatting" }) }) }),
24162
24965
  deleteOverlay
24163
24966
  ] });
24164
24967
  }
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" })
24968
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app", children: [
24969
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("header", { className: "app__header", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__header-row", children: [
24970
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__logo-title-wrapper", children: [
24971
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("img", { src: caretaker_cli_default, alt: "Caretaker", className: "app__logo" }),
24972
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: "Caretaker" })
24170
24973
  ] }),
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)(
24974
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__controls", children: [
24975
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__agent-select-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24173
24976
  "select",
24174
24977
  {
24175
24978
  className: "app__agent-select",
24176
24979
  value: selectedAgentId ?? "",
24177
- onChange: (e) => onSelectAgent(e.target.value),
24980
+ onChange: (e) => {
24981
+ setActivation(null);
24982
+ onSelectAgent(e.target.value);
24983
+ },
24178
24984
  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))
24985
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: "", disabled: true, children: "-- Select Agent --" }),
24986
+ agents.map((agent) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: agent.id, children: agent.name }, agent.id))
24181
24987
  ]
24182
24988
  }
24183
24989
  ) }),
24184
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
24990
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24185
24991
  "button",
24186
24992
  {
24187
24993
  className: "app__sessions-btn",
@@ -24189,13 +24995,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24189
24995
  disabled: !selectedAgentId,
24190
24996
  title: "View conversations",
24191
24997
  children: [
24192
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MessageSquare, { size: 13 }),
24998
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MessageSquare, { size: 13 }),
24193
24999
  " ",
24194
25000
  sessions.length
24195
25001
  ]
24196
25002
  }
24197
25003
  ),
24198
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25004
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24199
25005
  "button",
24200
25006
  {
24201
25007
  className: "app__new-chat-btn",
@@ -24205,7 +25011,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24205
25011
  children: "+ New"
24206
25012
  }
24207
25013
  ),
24208
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25014
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24209
25015
  "button",
24210
25016
  {
24211
25017
  className: "app__settings-btn",
@@ -24214,24 +25020,24 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24214
25020
  postMessage({ type: "getSettingsData" });
24215
25021
  },
24216
25022
  title: "Caretaker Settings",
24217
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Settings, { className: "app__settings-icon", size: 14 })
25023
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Settings, { className: "app__settings-icon", size: 14 })
24218
25024
  }
24219
25025
  )
24220
25026
  ] })
24221
25027
  ] }) }),
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: [
25028
+ showSessions && sessions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sessions-dropdown", children: [
25029
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sessions-title", children: [
24224
25030
  "Conversations for ",
24225
25031
  selectedAgentName
24226
25032
  ] }),
24227
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "app__sessions-list", children: sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
25033
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sessions-list", children: sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
24228
25034
  "div",
24229
25035
  {
24230
25036
  className: `app__session-item ${selectedSessionId === session.id ? "app__session-item--active" : ""}`,
24231
25037
  onClick: () => onSelectSession(session.id),
24232
25038
  children: [
24233
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "app__session-item-title", children: session.title }),
24234
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25039
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "app__session-item-title", children: session.title }),
25040
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24235
25041
  "button",
24236
25042
  {
24237
25043
  className: "app__session-item-delete",
@@ -24240,7 +25046,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24240
25046
  e.stopPropagation();
24241
25047
  onDeleteSession(session.id, session.title);
24242
25048
  },
24243
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Trash, { size: 12 })
25049
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 12 })
24244
25050
  }
24245
25051
  )
24246
25052
  ]
@@ -24248,12 +25054,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24248
25054
  session.id
24249
25055
  )) })
24250
25056
  ] }),
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" })
25057
+ showSessions && sessions.length === 0 && selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__sessions-dropdown app__sessions-dropdown--empty", children: [
25058
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__sessions-title", children: "No conversations yet" }),
25059
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "app__sessions-empty", children: "Start a new chat to create a conversation" })
24254
25060
  ] }),
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)(
25061
+ !selectedAgentId && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "app__empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { children: "Select an agent to start chatting" }) }),
25062
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24257
25063
  MessageList,
24258
25064
  {
24259
25065
  items: chatState.items,
@@ -24263,15 +25069,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24263
25069
  trailing: confirmCards
24264
25070
  }
24265
25071
  ),
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 }),
25072
+ (chatState.errorText || voice.error) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "app__error", children: [
25073
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TriangleAlert, { size: 14 }),
24268
25074
  " ",
24269
25075
  chatState.errorText || voice.error
24270
25076
  ] }),
24271
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
25077
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24272
25078
  Composer,
24273
25079
  {
24274
25080
  disabled: composerDisabled,
25081
+ focusToken: composerFocusToken,
24275
25082
  onSend,
24276
25083
  canAbort: chatState.status === "streaming",
24277
25084
  onAbort,
@@ -24292,12 +25099,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24292
25099
  }
24293
25100
 
24294
25101
  // src/standalone.tsx
24295
- var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
25102
+ var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
24296
25103
  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)(() => {
25104
+ const [ws, setWs] = (0, import_react25.useState)(null);
25105
+ const [connected, setConnected] = (0, import_react25.useState)(false);
25106
+ const [error, setError] = (0, import_react25.useState)(null);
25107
+ (0, import_react25.useEffect)(() => {
24301
25108
  let active = true;
24302
25109
  const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
24303
25110
  const socket = new WebSocket(`${protocol}//${window.location.host}/api/ws`);
@@ -24343,7 +25150,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24343
25150
  }
24344
25151
  };
24345
25152
  if (error) {
24346
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: {
25153
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: {
24347
25154
  display: "flex",
24348
25155
  flexDirection: "column",
24349
25156
  alignItems: "center",
@@ -24355,9 +25162,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24355
25162
  padding: "20px",
24356
25163
  textAlign: "center"
24357
25164
  }, 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)(
25165
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h3", { style: { color: "#ff6b6b" }, children: "Caretaker Connection Failed" }),
25166
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { children: error }),
25167
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24361
25168
  "button",
24362
25169
  {
24363
25170
  onClick: () => setWs(null),
@@ -24376,7 +25183,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24376
25183
  ] });
24377
25184
  }
24378
25185
  if (!connected) {
24379
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: {
25186
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: {
24380
25187
  display: "flex",
24381
25188
  flexDirection: "column",
24382
25189
  alignItems: "center",
@@ -24386,7 +25193,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24386
25193
  background: "#1e1e1e",
24387
25194
  color: "#f1f1f1"
24388
25195
  }, children: [
24389
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: {
25196
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { style: {
24390
25197
  border: "4px solid rgba(255,255,255,0.1)",
24391
25198
  width: "36px",
24392
25199
  height: "36px",
@@ -24395,8 +25202,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24395
25202
  animation: "spin 1s linear infinite",
24396
25203
  marginBottom: "16px"
24397
25204
  } }),
24398
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "Connecting to Caretaker server..." }),
24399
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("style", { children: `
25205
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: "Connecting to Caretaker server..." }),
25206
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("style", { children: `
24400
25207
  @keyframes spin {
24401
25208
  0% { transform: rotate(0deg); }
24402
25209
  100% { transform: rotate(360deg); }
@@ -24404,12 +25211,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
24404
25211
  ` })
24405
25212
  ] });
24406
25213
  }
24407
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(App, { postMessage, layout: "sidebar" });
25214
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(App, { postMessage, layout: "sidebar" });
24408
25215
  }
24409
25216
  var rootEl = document.getElementById("root");
24410
25217
  if (!rootEl) throw new Error("#root not found");
24411
25218
  (0, import_client.createRoot)(rootEl).render(
24412
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react23.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(StandaloneApp, {}) })
25219
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react25.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(StandaloneApp, {}) })
24413
25220
  );
24414
25221
  })();
24415
25222
  /*! Bundled license information: