kaizen-agent 1.61.5 → 1.62.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 (101) hide show
  1. package/README.md +2 -2
  2. package/agents/kaizen-builder.md +3 -0
  3. package/agents/kaizen-planner.md +3 -0
  4. package/agents/kaizen-reviewer.md +2 -0
  5. package/assets/kaizen-logo.png +0 -0
  6. package/assets/kaizen.ico +0 -0
  7. package/cli/__pycache__/computer-helper.cpython-314.pyc +0 -0
  8. package/cli/accounts.test.ts +126 -0
  9. package/cli/accounts.ts +116 -0
  10. package/cli/add-project.ts +4 -2
  11. package/cli/agent-prefs.test.ts +127 -0
  12. package/cli/agent-prefs.ts +106 -0
  13. package/cli/board.test.ts +4 -5
  14. package/cli/computer-helper.py +299 -0
  15. package/cli/computer.test.ts +155 -0
  16. package/cli/computer.ts +66 -0
  17. package/cli/dashboard.ts +14 -15
  18. package/cli/install.ts +67 -4
  19. package/cli/keep-awake.ts +30 -0
  20. package/cli/notes.test.ts +9 -0
  21. package/cli/project-tree.test.ts +1 -0
  22. package/cli/pty.test.ts +2 -1
  23. package/cli/pty.ts +6 -5
  24. package/cli/report.test.ts +59 -0
  25. package/cli/report.ts +62 -0
  26. package/cli/restart.test.ts +1 -0
  27. package/cli/settings.test.ts +21 -1
  28. package/cli/settings.ts +19 -11
  29. package/cli/setup.test.ts +2 -2
  30. package/cli/skills.test.ts +89 -0
  31. package/cli/skills.ts +112 -0
  32. package/cli/state.test.ts +46 -4
  33. package/cli/state.ts +127 -41
  34. package/cli/term-image.test.ts +23 -0
  35. package/cli/term-image.ts +26 -0
  36. package/cli/usage.test.ts +8 -2
  37. package/cli/usage.ts +8 -6
  38. package/cli/video.test.ts +5 -5
  39. package/cli/web-accept.test.ts +1 -0
  40. package/cli/web-decide.test.ts +1 -0
  41. package/cli/web-pr.test.ts +1 -0
  42. package/cli/web-skills.test.ts +32 -0
  43. package/cli/web-symlink.test.ts +1 -0
  44. package/cli/web.ts +179 -20
  45. package/cli/workers.test.ts +319 -0
  46. package/cli/workers.ts +380 -0
  47. package/cli/worktree.test.ts +21 -2
  48. package/cli/worktree.ts +21 -2
  49. package/package.json +1 -1
  50. package/skills/kaizen/config.default.yml +33 -1
  51. package/skills/kaizen/settings.md +1 -1
  52. package/skills/kaizen/skill.json +1 -0
  53. package/skills/kaizen/spec-build.md +22 -2
  54. package/skills/kaizen/spec-main.md +9 -0
  55. package/skills/kaizen/spec-plan.md +18 -1
  56. package/skills/kaizen/spec-review.md +4 -0
  57. package/skills/kaizen/spec.md +15 -0
  58. package/skills/kaizen-help/SKILL.md +1 -0
  59. package/skills/kaizen-help/skill.json +1 -0
  60. package/skills/media/kaizen-book/skill.json +1 -0
  61. package/skills/media/kaizen-deck/skill.json +1 -0
  62. package/skills/media/kaizen-video/skill.json +1 -0
  63. package/skills/optional/kaizen-computer/SKILL.md +38 -0
  64. package/skills/optional/kaizen-computer/skill.json +1 -0
  65. package/web/board/add-project.ts +3 -3
  66. package/web/board/agent-favicons.ts +9 -0
  67. package/web/board/agent-term.ts +1 -1
  68. package/web/board/api.ts +1 -1
  69. package/web/board/approvals.ts +1 -1
  70. package/web/board/cards.ts +50 -7
  71. package/web/board/dictation.ts +46 -3
  72. package/web/board/fixes.ts +1 -1
  73. package/web/board/home.ts +1 -1
  74. package/web/board/icebox.ts +1 -1
  75. package/web/board/keys.ts +5 -15
  76. package/web/board/onboarding.ts +1 -1
  77. package/web/board/panel.ts +24 -20
  78. package/web/board/phone.ts +4 -1
  79. package/web/board/run-view.ts +11 -6
  80. package/web/board/settings-accounts.ts +60 -0
  81. package/web/board/settings-agents.ts +102 -0
  82. package/web/board/settings-orchestration.ts +32 -0
  83. package/web/board/settings-pages.test.ts +5 -0
  84. package/web/board/settings-pages.ts +10 -4
  85. package/web/board/settings-skills.ts +47 -0
  86. package/web/board/settings-voice.test.ts +18 -0
  87. package/web/board/settings-voice.ts +28 -0
  88. package/web/board/settings.ts +40 -4
  89. package/web/board/terms.ts +2 -2
  90. package/web/board/update.ts +1 -1
  91. package/web/board/views.ts +1 -0
  92. package/web/board/ws-board.test.ts +6 -0
  93. package/web/board/ws-board.ts +2 -0
  94. package/web/board.html +21 -7
  95. package/web/board.js +134 -84
  96. package/web/notebook.js +2 -2
  97. package/web/notes.html +8 -6
  98. package/web/term.js +27 -27
  99. package/web/term.ts +25 -3
  100. package/web/video.html +7 -5
  101. package/web/video.js +2 -2
@@ -163,13 +163,13 @@ export async function showRunView(nav = false) {
163
163
  if (!c) {
164
164
  if (await away()) return showRunView(nav);
165
165
  if (!store.all && find(railData().cards)) location.href = "/?all=1&" + p.toString();
166
- else (stopPanes(), (ctx = card = null), none(`That ${id ? "run" : "idea"} is not on this board.`));
166
+ else (stopPanes(), (ctx = card = null), none(`That ${id ? "run" : "idea"} was not found.`));
167
167
  return;
168
168
  }
169
169
  want = c;
170
170
  ws = wsOfCard(c);
171
171
  }
172
- if (!dir || !ws) return void (stopPanes(), (ctx = card = null), none("That workspace is not on this board."));
172
+ if (!dir || !ws) return void (stopPanes(), (ctx = card = null), none("That workspace was not found."));
173
173
  const k = wsKey(dir, ws);
174
174
  const fresh = ctx?.k !== k;
175
175
  // Each workspace has its own centre: switching unmounts this one's panes (its shells keep running on the server).
@@ -457,7 +457,7 @@ function browser(el: HTMLElement) {
457
457
  frame.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals allow-downloads");
458
458
  const note = document.createElement("p");
459
459
  note.className = "rnote";
460
- const far = "This page is on the computer running the board; from this device localhost is the device itself. Use Open in browser on that computer.";
460
+ const far = "This page is on the computer running kaizen; from this device localhost is the device itself. Use Open in browser on that computer.";
461
461
  el.append(frame, note);
462
462
  const go = (u, push = true) => {
463
463
  if (push && url !== u) back.push(url), (fwd.length = 0);
@@ -484,7 +484,7 @@ function browser(el: HTMLElement) {
484
484
  note.hidden = false;
485
485
  // The fallback card: the page refuses to be framed, so offer it outside the board.
486
486
  note.textContent = "";
487
- note.insertAdjacentHTML("beforeend", String(html`<b>This page refuses to be shown inside the board</b>${new URL(u).host} sends a header that forbids framing. <a class="rwin" target="_blank" rel="noopener" href="${u}">${ico("popout")}<span>Open in new tab</span></a>${winBtn(u)}`));
487
+ note.insertAdjacentHTML("beforeend", String(html`<b>This page refuses to be shown inside kaizen</b>${new URL(u).host} sends a header that forbids framing. <a class="rwin" target="_blank" rel="noopener" href="${u}">${ico("popout")}<span>Open in new tab</span></a>${winBtn(u)}`));
488
488
  })
489
489
  .catch(() => {});
490
490
  };
@@ -566,7 +566,10 @@ function show(id: string) {
566
566
  draw();
567
567
  }
568
568
  export const openNoteTab = (name: string) => addTab({ id: "note:" + name, kind: "note", title: name.slice(name.lastIndexOf("/") + 1), note: name });
569
- const openPreview = () => addTab({ id: "preview", kind: "preview", title: "Preview" });
569
+ const openPreview = () => {
570
+ addTab({ id: "preview", kind: "preview", title: "Preview" });
571
+ if (isPhone()) $("pclose").click(); // Preview is a centre tab: the sheet would sit over it
572
+ };
570
573
 
571
574
  // The run's recorded session, resumed in a board terminal tied to it. While it still runs in
572
575
  // another terminal the server says so (409 live) and a tab explains; with no session, a shell.
@@ -895,7 +898,9 @@ function initSheet() {
895
898
  };
896
899
  p.addEventListener("touchend", end);
897
900
  p.addEventListener("touchcancel", end);
898
- addEventListener("click", (e) => on() && !(e.target as Element).closest?.("#panel,#rside,dialog,.toast") && shut());
901
+ // composedPath, not target: a strip button redraws #ptabs in its own click, so by here
902
+ // the target is detached and closest() would call a tap inside the sheet an outside one.
903
+ addEventListener("click", (e) => on() && !e.composedPath().some((n) => (n as Element).matches?.("#panel,#rside,dialog,.toast")) && shut());
899
904
  }
900
905
 
901
906
  export function initRunView() {
@@ -0,0 +1,60 @@
1
+ import { AGENT_FAVICONS } from "./agent-favicons.ts";
2
+ import { post } from "./api.ts";
3
+ import { $, html } from "./dom.ts";
4
+ import { store } from "./store.ts";
5
+ import { toast } from "./toast.ts";
6
+
7
+ // Settings → AI Provider Accounts. /accounts never carries a token.
8
+ type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any };
9
+ const TOOL: Record<string, string> = { claude: "Claude", codex: "Codex" };
10
+
11
+ function usageLine(u: any, signed: boolean) {
12
+ if (!u) return html`<span class="ac-u${signed ? "" : " bad"}">${signed ? "Signed in · no usage yet" : "Not signed in"}</span>`;
13
+ if (u.expired) return html`<span class="ac-u bad">Sign-in expired. Sign in again</span>`;
14
+ if (u.error) return html`<span class="ac-u bad">Usage unavailable</span>`;
15
+ return html`<span class="ac-u">${u.five ? `${u.five.pct}% of 5 hours` : ""}${u.five && u.week ? " · " : ""}${u.week ? `${u.week.pct}% of the week` : ""}</span>`;
16
+ }
17
+
18
+ const row = (a: Row) =>
19
+ html`<div class="sk" data-q="account ${a.name.toLowerCase()} ${a.tool}">
20
+ <div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${usageLine(a.usage, a.signedIn)}</span>
21
+ ${a.signedIn && !a.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="${a.id}" data-tool="${a.tool}">Sign in</button>`}
22
+ <button type="button" class="btn" data-ac-def="${a.isDefault ? "" : a.id}" data-tool="${a.tool}" aria-pressed="${String(a.isDefault)}">${a.isDefault ? "✓ Default" : "Default"}</button>
23
+ <button type="button" class="btn" data-ac-rm="${a.id}" data-name="${a.name}">Remove</button></div>
24
+ ${a.signedIn && !a.usage?.expired ? "" : html`<div class="sk-a"><code>${a.signIn}</code></div>`}
25
+ </div>`;
26
+
27
+ export const accountRows = (d: { accounts: Row[]; windows: boolean }) =>
28
+ html`${["claude", "codex"].filter((t) => d.accounts.some((a) => a.tool === t)).map((t) => html`<h3 class="sg">${TOOL[t]} accounts</h3><div class="sgrp">${d.accounts.filter((a) => a.tool === t).map(row)}</div>`)}
29
+ <h3 class="sg">Add an account</h3><div class="sgrp"><div class="ac-add" data-q="add account sign in claude codex provider">
30
+ <div class="achips">${["claude", "codex"].map((t) => html`<button type="button" data-ac-new="${t}"${d.windows ? " disabled" : ""}><img src="${AGENT_FAVICONS[t]}" alt="" width="16" height="16">Add ${TOOL[t]} account</button>`)}</div></div></div>`;
31
+
32
+ export function wireAccounts(redraw: () => Promise<unknown>) {
33
+ const send = async (body: object) => {
34
+ const j = await post("/accounts", body);
35
+ toast(j.error ? j.error : "Saved");
36
+ await redraw();
37
+ };
38
+ const root = $("pbody");
39
+ root.querySelectorAll<HTMLInputElement>("[data-ac-name]").forEach((i) => (i.onchange = () => send({ op: "rename", id: i.dataset.acName, name: i.value })));
40
+ root.querySelectorAll<HTMLElement>("[data-ac-new]").forEach((b) => (b.onclick = async () => {
41
+ const j = await post("/accounts", { op: "add", tool: b.dataset.acNew });
42
+ if (j.error || !j.added) return toast(j.error || "Could not add the account");
43
+ await signIn(j.added, b.dataset.acNew!);
44
+ redraw();
45
+ }));
46
+ root.querySelectorAll<HTMLElement>("[data-ac-def]").forEach((b) => (b.onclick = () => send({ op: "default", tool: b.dataset.tool, id: b.dataset.acDef })));
47
+ root.querySelectorAll<HTMLElement>("[data-ac-rm]").forEach((b) => (b.onclick = () => {
48
+ if (!confirm(`Remove ${b.dataset.name}? Runs started on it won't start until you pick another.`)) return;
49
+ send({ op: "remove", id: b.dataset.acRm, deleteFolder: confirm("Also delete its folder, with its login and conversations? Cancel keeps them.") });
50
+ }));
51
+ const signIn = async (id: string, tool: string) => {
52
+ const dir = store.dir || store.S?.dir;
53
+ if (!dir) return toast("Open a project first, or run the line shown here in a terminal");
54
+ const j = await post("/shell", { dir, agent: tool, account: id });
55
+ if (j.error || !j.key) return toast(j.error || "Could not open a terminal. Run the line shown here");
56
+ const opened = !dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir, ws: j.ws, key: j.key } }));
57
+ toast(opened ? "Sign in, then close the terminal" : "Terminal started. Open it from the side menu");
58
+ };
59
+ root.querySelectorAll<HTMLElement>("[data-ac-sign]").forEach((b) => (b.onclick = () => signIn(b.dataset.acSign!, b.dataset.tool!)));
60
+ }
@@ -0,0 +1,102 @@
1
+ import { AGENT_FAVICONS } from "./agent-favicons.ts";
2
+ import { post } from "./api.ts";
3
+ import { $, html, ico } from "./dom.ts";
4
+ import { toast } from "./toast.ts";
5
+
6
+ // Settings → Agents, above the page's ordinary rows: the default, permissions and one row
7
+ // per agent. These saves are per user (/agent-prefs); only the default is scoped.
8
+ type Row = { cmd: string; name: string; installed: boolean; bypass: boolean; enabled: boolean; permissions: string; command: string; args: string; env: string[]; preview: string };
9
+ type View = { permissions: string; envWorks: boolean; agents: Row[] };
10
+
11
+ // Open rows survive the redraw each save does.
12
+ const open = new Set<string>();
13
+ const MODES = [["own", "Each agent's own settings"], ["bypass", "Bypass every permission prompt"]];
14
+
15
+ const bar = (id: string, vals: [string, string][], on: string, off = false) =>
16
+ html`<span class="bar" id="${id}" role="group">${vals.map(([v, l]) => html`<button type="button" data-v="${v}" class="${v === on ? "on" : ""}" aria-pressed="${String(v === on)}"${off ? " disabled" : ""}>${l}</button>`)}</span>`;
17
+
18
+ function agentRow(a: Row, view: View, def: string) {
19
+ const id = "ag-" + a.cmd;
20
+ const allMode = MODES.find(([v]) => v === view.permissions)![1];
21
+ return html`<div class="ag${a.installed ? "" : " gone"}" data-q="${[a.name, a.cmd, "agent installed command arguments environment permissions"].join(" ").toLowerCase()}">
22
+ <div class="ag-h">
23
+ <img class="ag-i" src="${AGENT_FAVICONS[a.cmd] ?? ""}" alt="" width="28" height="28">
24
+ <span class="ag-n"><b>${a.name}</b><code>${a.command || a.cmd}</code></span>
25
+ ${a.installed ? "" : html`<span class="hint">Not installed</span>`}
26
+ ${bar(id + "-on", [["true", "Enabled"], ["false", "Disabled"]], String(a.enabled))}
27
+ <button type="button" class="btn" id="${id}-def" aria-pressed="${String(def === a.cmd)}"${!a.enabled || !a.installed ? " disabled" : ""}>${def === a.cmd ? "✓ Default" : "Default"}</button>
28
+ <button type="button" class="ib ag-more" id="${id}-more" aria-expanded="${String(open.has(a.cmd))}" aria-controls="${id}-b" aria-label="Details for ${a.name}">${ico("chev")}</button>
29
+ </div>
30
+ <div class="ag-b" id="${id}-b"${open.has(a.cmd) ? "" : " hidden"}>
31
+ <label id="${id}-pl">Permissions</label>
32
+ ${a.bypass ? html`<select class="sel" id="${id}-perm" aria-labelledby="${id}-pl">${[["all", `Same as all agents · ${allMode}`], ["own", `Use ${a.name}'s own settings`], ["bypass", "Bypass every permission prompt"]].map(([v, l]) => html`<option value="${v}"${v === a.permissions ? " selected" : ""}>${l}</option>`)}</select>` : html`<p class="hint">${a.name} has no bypass mode, so it uses its own settings.</p>`}
33
+ <label for="${id}-cmd">Command</label>
34
+ <input class="sel" id="${id}-cmd" value="${a.command}" placeholder="${a.cmd}" spellcheck="false" autocomplete="off">
35
+ <label for="${id}-args">Arguments</label>
36
+ <input class="sel" id="${id}-args" value="${a.args}" placeholder="No default arguments" spellcheck="false" autocomplete="off">
37
+ <label>Environment</label>
38
+ ${a.env.map((k) => html`<div class="ag-env"><code>${k}=•••</code><button type="button" class="btn" data-rm="${k}" data-agent="${a.cmd}">Remove</button></div>`)}
39
+ <div class="ag-add"><input class="sel" id="${id}-ek" placeholder="NAME" aria-label="Variable name" spellcheck="false" autocomplete="off"><input class="sel" id="${id}-ev" type="password" placeholder="value" aria-label="Variable value" autocomplete="new-password"><button type="button" class="btn" id="${id}-ea">Add</button></div>
40
+ <p class="hint">Don't store secrets here: values are saved as plain text in ~/.kaizen/agents.json and are visible in the process list while the agent runs.${view.envWorks ? "" : " Not applied on Windows yet."}</p>
41
+ <label>Launch line</label>
42
+ <pre>${a.preview}</pre>
43
+ </div>
44
+ </div>`;
45
+ }
46
+
47
+ export function agentRows(view: View, def: string, scopeName: string) {
48
+ const usable = view.agents.filter((a) => a.enabled && a.installed);
49
+ const seen = view.agents.filter((a) => a.installed).length;
50
+ return html`<h3 class="sg">Default agent</h3><div class="sgrp"><div class="srow" data-q="default agent auto tool launches ${usable.map((a) => a.name).join(" ").toLowerCase()}"><label id="ag-def-l">Default for new agents${scopeName ? ` in ${scopeName}` : ""}</label>
51
+ <div class="achips" role="group" aria-labelledby="ag-def-l">${[{ cmd: "auto", name: "Auto" }, ...usable].map((a) => html`<button type="button" data-def="${a.cmd}" class="${a.cmd === def ? "on" : ""}" aria-pressed="${String(a.cmd === def)}">${AGENT_FAVICONS[a.cmd] ? html`<img src="${AGENT_FAVICONS[a.cmd]}" alt="" width="16" height="16">` : ""}${a.name}${a.cmd === def ? " ✓" : ""}</button>`)}</div></div></div>
52
+ <h3 class="sg">Permissions</h3><div class="sgrp"><div class="srow" data-q="permissions bypass yolo all agents without asking"><label for="ag-perm">All agents</label>
53
+ <select class="sel" id="ag-perm">${MODES.map(([v, l]) => html`<option value="${v}"${v === view.permissions ? " selected" : ""}>${l}</option>`)}</select>
54
+ <p class="hint">What every agent may do without asking, for all your projects. You can set one agent differently below. Cards show when a run uses bypass.</p></div></div>
55
+ <h3 class="sg">Installed · ${seen} detected <button type="button" id="ag-refresh">Refresh</button></h3><div class="sgrp">${view.agents.map((a) => agentRow(a, view, def))}</div>`;
56
+ }
57
+
58
+ export function wireAgents(redraw: () => Promise<unknown>, scope: string | null) {
59
+ const root = $("pbody");
60
+ const save = async (patch: object) => {
61
+ const j = await post("/agent-prefs", patch);
62
+ toast(j.error ? j.error : "Saved");
63
+ await redraw();
64
+ };
65
+ const setDefault = async (cmd: string) => {
66
+ const j = await post("/settings", { key: "agent.default", value: cmd, scope });
67
+ toast(j.ok ? "Saved" : j.error || "Could not save");
68
+ await redraw();
69
+ };
70
+ root.querySelectorAll<HTMLElement>("[data-def]").forEach((b) => (b.onclick = () => setDefault(b.dataset.def!)));
71
+ $("ag-refresh").onclick = () => redraw();
72
+ $("ag-perm").onchange = (e) => {
73
+ const v = e.target.value;
74
+ if (v === "bypass" && !confirm("Agents will run commands without asking, in every project. Turn on bypass?")) return redraw();
75
+ save({ permissions: v });
76
+ };
77
+ root.querySelectorAll<HTMLElement>("[data-rm]").forEach((b) => (b.onclick = () => save({ agent: b.dataset.agent, envRemove: b.dataset.rm })));
78
+ root.querySelectorAll<HTMLElement>(".ag-more").forEach((b) => (b.onclick = () => {
79
+ const cmd = b.id.slice(3, -5), body = $(`ag-${cmd}-b`);
80
+ body.hidden = !body.hidden;
81
+ b.setAttribute("aria-expanded", String(!body.hidden));
82
+ body.hidden ? open.delete(cmd) : open.add(cmd);
83
+ }));
84
+ root.querySelectorAll<HTMLElement>(".ag-h [id$='-on'] [data-v]").forEach((b) => (b.onclick = () => {
85
+ const cmd = b.parentElement!.id.slice(3, -3);
86
+ save({ agent: cmd, enabled: b.dataset.v === "true" });
87
+ }));
88
+ root.querySelectorAll<HTMLElement>("[id$='-def'].btn").forEach((b) => (b.onclick = () => setDefault(b.id.slice(3, -4))));
89
+ root.querySelectorAll<HTMLInputElement>("input[id$='-cmd']").forEach((i) => (i.onchange = () => save({ agent: i.id.slice(3, -4), command: i.value })));
90
+ root.querySelectorAll<HTMLInputElement>("input[id$='-args']").forEach((i) => (i.onchange = () => save({ agent: i.id.slice(3, -5), args: i.value })));
91
+ root.querySelectorAll<HTMLSelectElement>("select[id$='-perm']").forEach((s) => {
92
+ if (s.id === "ag-perm") return;
93
+ s.onchange = () => {
94
+ if (s.value === "bypass" && !confirm("This agent will run commands without asking. Turn on bypass?")) return redraw();
95
+ save({ agent: s.id.slice(3, -5), agentPermissions: s.value });
96
+ };
97
+ });
98
+ root.querySelectorAll<HTMLElement>("[id$='-ea']").forEach((b) => (b.onclick = () => {
99
+ const cmd = b.id.slice(3, -3), k = $(`ag-${cmd}-ek`) as HTMLInputElement, v = $(`ag-${cmd}-ev`) as HTMLInputElement;
100
+ if (k.value.trim()) save({ agent: cmd, envName: k.value.trim(), envValue: v.value });
101
+ }));
102
+ }
@@ -0,0 +1,32 @@
1
+ import { AGENT_FAVICONS } from "./agent-favicons.ts";
2
+ import { html } from "./dom.ts";
3
+
4
+ // Names worth suggesting, per tool, from the tool's own docs; typing any other name stays allowed.
5
+ // ponytail: claude only, add another tool's names when its own CLI help lists them.
6
+ const SUGGEST: Record<string, string[]> = { claude: ["haiku", "sonnet", "opus"] };
7
+
8
+ // The worker model row's label (the tool's icon and name) and its input with that tool's suggestions.
9
+ export const modelLabel = (r: { key: string; label: string }) =>
10
+ html`<img class="ag-i" src="${AGENT_FAVICONS[r.key.split(".").pop()!] ?? ""}" alt="" width="16" height="16" style="width:16px;height:16px;vertical-align:-3px;margin-right:6px;border-radius:3px">${r.label.replace("Worker model: ", "")}`;
11
+ export const modelInput = (r: { key: string; value: string }, id: string) => {
12
+ const tool = r.key.split(".").pop()!;
13
+ return html`<span><input class="sel" id="${id}" value="${r.value}" placeholder="inherit" list="${id}-dl" spellcheck="false" autocomplete="off">${SUGGEST[tool] ? html`<datalist id="${id}-dl">${SUGGEST[tool]!.map((m) => html`<option value="${m}"></option>`)}</datalist>` : ""}</span>`;
14
+ };
15
+
16
+ // Settings → Orchestration: a picture of the flow, and warnings where they apply, above the three rows. The rows themselves are the generic ones.
17
+ const note = (text: unknown, q: string) => html`<div class="srow" data-q="orchestration workers ${q}"><p class="hint">${text}</p></div>`;
18
+
19
+ // The plan reaches the conductor, which hands out tasks; workers bring work back; it goes on to review. Joined by beams of light. currentColor and var(--accent), so it follows light and
20
+ // dark. CSS only; with reduced motion the lines simply stay lit.
21
+ const flow = html`<div class="orch-flow" data-q="orchestration workers flow plan merge review"><svg viewBox="0 0 910 250" width="100%" role="img" aria-label="A conductor takes the approved plan and hands tasks to workers. Each worker brings its work back to the conductor, which merges it and sends it to review.">
22
+ <style>.orch-flow svg{display:block;overflow:visible;width:100%!important;height:auto!important;max-width:none!important;fill:none}.orch-l{fill:none;stroke:currentColor;stroke-width:2;opacity:.16}.orch-b{fill:none;stroke:var(--accent);stroke-width:3;stroke-linecap:round;filter:drop-shadow(0 0 5px var(--accent))}.orch-flow rect{fill:var(--bg);stroke:currentColor;stroke-width:1.5}.orch-i path,.orch-i circle{fill:none;stroke:var(--accent);stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}.orch-flow text{fill:currentColor;stroke:none;font:600 15px var(--mono,ui-monospace,monospace)}@keyframes orch-beam{from{stroke-dashoffset:125}to{stroke-dashoffset:-25}}@media (prefers-reduced-motion:no-preference){.orch-b{stroke-dasharray:25 100;stroke-dashoffset:125;animation:orch-beam 4s linear infinite}}</style>
23
+ <path class="orch-l" d="M150 125H200"/><path class="orch-l" d="M265 96V50Q265 32 283 32H500"/><path class="orch-l" d="M265 154V200Q265 218 283 218H500"/><path class="orch-l" d="M500 60H335Q317 60 317 78V96"/><path class="orch-l" d="M500 190H335Q317 190 317 172V154"/><path class="orch-l" d="M382 125H740"/>
24
+ <path class="orch-b" pathLength="100" style="animation-delay:0s" d="M150 125H200"/><path class="orch-b" pathLength="100" style="animation-delay:0.5s" d="M265 96V50Q265 32 283 32H500"/><path class="orch-b" pathLength="100" style="animation-delay:0.5s" d="M265 154V200Q265 218 283 218H500"/><path class="orch-b" pathLength="100" style="animation-delay:1.7s" d="M500 60H335Q317 60 317 78V96"/><path class="orch-b" pathLength="100" style="animation-delay:1.7s" d="M500 190H335Q317 190 317 172V154"/><path class="orch-b" pathLength="100" style="animation-delay:2.8s" d="M382 125H740"/>
25
+ <g transform="translate(20 96)"><rect width="130" height="58" rx="12"/><g transform="translate(18 21) scale(1.15)" class="orch-i"><path d="M1 1h7l4 4v9H1zM8 1v4h4"/></g><text x="44" y="35">plan</text></g><g transform="translate(200 96)"><rect width="182" height="58" rx="12"/><g transform="translate(18 21) scale(1.15)" class="orch-i"><circle cx="6.5" cy="6.5" r="2.5"/><path d="M6.5 0v3M6.5 10v3M0 6.5h3M10 6.5h3"/></g><text x="44" y="35">conductor</text></g><g transform="translate(500 18)"><rect width="160" height="58" rx="12"/><g transform="translate(18 21) scale(1.15)" class="orch-i"><path d="M1 2l4 3-4 3M7 10h5"/></g><text x="44" y="35">worker 1</text></g><g transform="translate(500 174)"><rect width="160" height="58" rx="12"/><g transform="translate(18 21) scale(1.15)" class="orch-i"><path d="M1 2l4 3-4 3M7 10h5"/></g><text x="44" y="35">worker 2</text></g><g transform="translate(740 96)"><rect width="150" height="58" rx="12"/><g transform="translate(18 21) scale(1.15)" class="orch-i"><circle cx="6.5" cy="6.5" r="6"/><path d="M4 6.5l2 2 3.5-4"/></g><text x="44" y="35">review</text></g>
26
+ </svg></div>`;
27
+
28
+ export const orchestrationRows = (d: { windows: boolean; bypass: boolean }) =>
29
+ html`${flow}<div class="sgrp">
30
+ ${d.windows ? note("Not available on Windows: workers run in real terminals on Linux and macOS. Orchestration reads as off here.", "windows") : ""}
31
+ ${d.bypass ? note("Warning: bypass skips every prompt in every worker. Each worker tab and the run's card say so.", "bypass permissions") : ""}
32
+ </div>`;
@@ -17,3 +17,8 @@ test("every setting lands on a real page, under a named subsection", () => {
17
17
  test("a setting not placed yet falls back to General", () => {
18
18
  expect(placeOf("new.thing")).toEqual(["general", "Other"]);
19
19
  });
20
+
21
+ test("the Orchestration page exists and holds its three settings", () => {
22
+ expect(pages.has("orchestration")).toBe(true);
23
+ for (const k of ["enabled", "max_workers", "permissions", "worker_model.claude"]) expect(placeOf(`orchestration.${k}`)).toEqual(["orchestration", "Workers"]);
24
+ });
@@ -3,13 +3,16 @@
3
3
  export type SettingsPage = { id: string; title: string; desc: string; ico: string };
4
4
  export const SETTINGS_NAV: [string, SettingsPage[]][] = [
5
5
  ["AI Capabilities", [
6
- { id: "agents", title: "Agents", desc: "Which tool runs, and who does each stage.", ico: "ai" },
6
+ { id: "agents", title: "Agents", desc: "Manage AI agents, set a default, and customize commands.", ico: "ai" },
7
+ { id: "accounts", title: "AI Provider Accounts", desc: "Optional. Your normal logins keep working; add accounts only to switch between them.", ico: "link" },
8
+ { id: "orchestration", title: "Orchestration", desc: "Split a run into workers, each in its own terminal. Off by default.", ico: "ai" },
9
+ { id: "skills", title: "Skills", desc: "What your agents can do. Changes apply to new sessions.", ico: "note" },
7
10
  { id: "voice", title: "Voice", desc: "Speech-to-text dictation, run in the browser.", ico: "mic" },
8
11
  ]],
9
12
  ["Set Up", [
10
13
  { id: "general", title: "General", desc: "Which settings you are editing, folders, and maintenance.", ico: "gear" },
11
14
  { id: "integrations", title: "Integrations", desc: "Request sources and your Google account.", ico: "link" },
12
- { id: "mobile", title: "Mobile", desc: "Open this board from your phone.", ico: "send" },
15
+ { id: "mobile", title: "Mobile", desc: "Open kaizen from your phone.", ico: "send" },
13
16
  ]],
14
17
  ["Workflows", [
15
18
  { id: "approvals", title: "Approvals", desc: "Where a run stops and waits for you.", ico: "check" },
@@ -25,8 +28,11 @@ export const SETTINGS_NAV: [string, SettingsPage[]][] = [
25
28
  ];
26
29
  // First match wins: [key pattern, page, subsection].
27
30
  const PLACES: [RegExp, string, string][] = [
28
- [/^preset$/, "agents", "Defaults"],
29
- [/^(runner|build\.|review\.executor|agent\.|subagents\.)/, "agents", "Agents"],
31
+ [/^(preset|runner|build\.|review\.executor)/, "agents", "Workflow"],
32
+ [/^subagents\./, "agents", "Subagents"],
33
+ [/^agent\.default$/, "agents", "Default agent"],
34
+ [/^agent\./, "agents", "Running agents"],
35
+ [/^orchestration\./, "orchestration", "Workers"],
30
36
  [/^dictation\./, "voice", "Dictation"],
31
37
  [/^sources\./, "integrations", "Request sources"],
32
38
  [/^(mode|approvals\.|auto_accept)/, "approvals", "Approvals"],
@@ -0,0 +1,47 @@
1
+ import { AGENT_FAVICONS } from "./agent-favicons.ts";
2
+ import { post } from "./api.ts";
3
+ import { $, html, raw } from "./dom.ts";
4
+ import { toast } from "./toast.ts";
5
+
6
+ // Settings → Skills: one row per bundled skill, grouped. /skills scans the folders, so
7
+ // a new skill shows here with no change to this file.
8
+ type Row = { id: string; title: string; description: string; group: string; off: boolean; agents: { agent: string; state: string }[]; needs: { name: string; found: boolean }[]; offByDefault?: boolean; note?: string };
9
+ const GROUPS: [string, string][] = [["core", "Core"], ["media", "Media"], ["optional", "Optional"]];
10
+ const WORD: Record<string, string> = { installed: "installed", missing: "missing", other: "your own copy" };
11
+
12
+ const AGENT_CMD: Record<string, string> = { "Claude Code": "claude", Codex: "codex", Antigravity: "agy", OpenCode: "opencode", Cursor: "cursor", "Gemini CLI": "gemini" };
13
+ // One drawn mark per skill, by id; a skill without one gets the puzzle piece.
14
+ const SKILL_ICONS: Record<string, string> = {
15
+ kaizen: '<path d="M4 7h11M4 12h7M4 17h11"/><path d="m16 11 2 2 3-4"/>',
16
+ "kaizen-help": '<circle cx="12" cy="12" r="9"/><path d="M9.5 9.5a2.5 2.5 0 1 1 3.8 2.1c-.9.6-1.3 1.1-1.3 2.1"/><path d="M12 17h.01"/>',
17
+ "kaizen-book": '<path d="M12 6c-2-1.5-5-2-8-2v15c3 0 6 .5 8 2 2-1.5 5-2 8-2V4c-3 0-6 .5-8 2Z"/><path d="M12 6v15"/>',
18
+ "kaizen-deck": '<rect x="3" y="4" width="18" height="12" rx="1"/><path d="M12 16v4M8 20h8M8 12l3-3 2 2 3-3"/>',
19
+ "kaizen-computer": '<rect x="3" y="4" width="18" height="12" rx="1"/><path d="M8 20h8M12 16v4M9 8l5 3-2 .8-.8 2Z"/>',
20
+ "kaizen-video": '<rect x="3" y="6" width="13" height="12" rx="2"/><path d="m16 10 5-3v10l-5-3"/>',
21
+ };
22
+ const PUZZLE = '<path d="M10 4a2 2 0 1 1 4 0v2h5v5h-2a2 2 0 1 0 0 4h2v5H5v-5h2a2 2 0 1 0 0-4H5V6h5Z"/>';
23
+ const skillIcon = (id: string) => raw(`<svg class="sk-i" viewBox="0 0 24 24" aria-hidden="true">${SKILL_ICONS[id] ?? PUZZLE}</svg>`);
24
+
25
+ const row = (s: Row) =>
26
+ html`<div class="sk" data-q="${[s.title, s.id, s.description, s.group, "skill"].join(" ").toLowerCase()}">
27
+ <div class="sk-h">${skillIcon(s.id)}<span class="sk-n"><b>${s.title}</b><span>${s.description}</span></span>
28
+ ${s.group === "core" ? html`<span class="hint">Always on</span>` : html`${!s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}<button type="button" class="chk sm${s.off ? "" : " on"}" data-skill="${s.id}" data-on="${String(s.off)}" data-warn="${String(!!s.offByDefault)}" role="switch" aria-checked="${String(!s.off)}" aria-label="${s.title}" title="${s.off ? "Off" : "On"}"></button>`}</div>
29
+ <div class="sk-a">${s.agents.map((a) => html`<img class="sk-ag${a.state === "installed" ? "" : " off"}" src="${AGENT_FAVICONS[AGENT_CMD[a.agent] ?? ""] ?? ""}" width="18" height="18" alt="${a.agent}: ${WORD[a.state] ?? a.state}" title="${a.agent}: ${WORD[a.state] ?? a.state}">`)}${s.needs.map((n) => html`<span class="${n.found ? "" : "miss"}">Needs ${n.name}${n.found ? "" : " (not found)"}</span>`)}${s.note ? html`<span>${s.note}</span>` : ""}</div>
30
+ </div>`;
31
+
32
+ export const skillRows = (skills: Row[]) =>
33
+ html`${GROUPS.filter(([g]) => skills.some((s) => s.group === g)).map(([g, label], i) => html`<h3 class="sg">${label}${i ? "" : html` <button type="button" id="sk-recheck">Re-check</button>`}</h3><div class="sgrp">${skills.filter((s) => s.group === g).map(row)}</div>`)}`;
34
+
35
+ export function wireSkills(redraw: () => Promise<unknown>, token = "") {
36
+ const again = $("sk-recheck");
37
+ if (again) again.onclick = () => redraw();
38
+ $("pbody").querySelectorAll<HTMLElement>("[data-skill]").forEach((b) => (b.onclick = async () => {
39
+ const on = b.dataset.on === "true";
40
+ // An off-by-default skill gives agents a power the user never had to grant: say so, then ask.
41
+ const warn = on && b.dataset.warn === "true";
42
+ if (warn && !confirm("Let agents read and operate the apps on your desktop?\n\nThey see the window text of the apps they open and can click, set values and type in them, as you. A password manager is blocked by its name only, so one inside a browser or under another name is not. Any other open app is in reach. Turn on?")) return;
43
+ const j = await post("/skills", { id: b.dataset.skill, on, ...(warn ? { confirm: true, token } : {}) });
44
+ toast(j.error ? j.error : "Saved. Applies to new sessions");
45
+ await redraw();
46
+ }));
47
+ }
@@ -0,0 +1,18 @@
1
+ import { expect, test } from "bun:test";
2
+ import { micAudio, openMic } from "./settings-voice.ts";
3
+
4
+ test("no saved device asks for the default microphone; a saved one is exact", () => {
5
+ expect(micAudio().deviceId).toBeUndefined();
6
+ expect(micAudio("abc").deviceId).toEqual({ exact: "abc" });
7
+ expect(micAudio("abc").channelCount).toBe(1);
8
+ });
9
+
10
+ test("an unplugged microphone falls back to the default and says so; a refusal does not", async () => {
11
+ const asked: any[] = [], said: string[] = [];
12
+ const gone = async (a: any) => { asked.push(a); if (a.deviceId) throw Object.assign(new Error(), { name: "OverconstrainedError" }); return "ok" as any; };
13
+ expect(await openMic(gone, "abc", (m) => said.push(m))).toBe("ok");
14
+ expect(asked.length).toBe(2);
15
+ expect(said.length).toBe(1);
16
+ const refused = async () => { throw Object.assign(new Error(), { name: "NotAllowedError" }); };
17
+ await expect(openMic(refused, "abc", () => {})).rejects.toThrow();
18
+ });
@@ -0,0 +1,28 @@
1
+ import { $, html } from "./dom.ts";
2
+
3
+ // The microphone dictation uses, per browser. No choice means the system default.
4
+ const KEY = "kz-mic";
5
+ export const savedMic = () => { try { return localStorage.getItem(KEY) || ""; } catch { return ""; } };
6
+ export const micAudio = (device = "") => ({ channelCount: 1, noiseSuppression: true, echoCancellation: true, ...(device ? { deviceId: { exact: device } } : {}) });
7
+
8
+ // An unplugged choice falls back to the default, and says so. Anything else is the caller's.
9
+ export async function openMic(get: (audio: object) => Promise<MediaStream>, device: string, warn: (m: string) => void) {
10
+ try { return await get(micAudio(device)); } catch (err: any) {
11
+ if (!device || err?.name !== "OverconstrainedError") throw err;
12
+ warn("Chosen microphone not found. Using the default");
13
+ return get(micAudio());
14
+ }
15
+ }
16
+
17
+ export const micRow = () => html`<select class="sel" id="v-mic" aria-labelledby="v-mic-l"><option value="">System default</option></select>`;
18
+
19
+ // Device names appear only once the browser has microphone permission.
20
+ export async function fillMics() {
21
+ const s = $("v-mic") as HTMLSelectElement | null;
22
+ if (!s || !navigator.mediaDevices?.enumerateDevices) return;
23
+ const saved = savedMic();
24
+ const mics = (await navigator.mediaDevices.enumerateDevices().catch(() => [])).filter((d) => d.kind === "audioinput" && d.deviceId && d.deviceId !== "default");
25
+ s.innerHTML = html`<option value="">System default</option>${mics.map((d, i) => html`<option value="${d.deviceId}">${d.label || `Microphone ${i + 1}`}</option>`)}`.s;
26
+ s.value = mics.some((d) => d.deviceId === saved) ? saved : "";
27
+ s.onchange = () => { try { localStorage.setItem(KEY, s.value); } catch { /* this browser keeps nothing */ } };
28
+ }
@@ -4,6 +4,11 @@ import { load, post } from "./api.ts";
4
4
  import { stopDictation } from "./dictation.ts";
5
5
  import { $, html, ico, raw } from "./dom.ts";
6
6
  import { close } from "./panel.ts";
7
+ import { accountRows, wireAccounts } from "./settings-accounts.ts";
8
+ import { agentRows, wireAgents } from "./settings-agents.ts";
9
+ import { modelInput, modelLabel, orchestrationRows } from "./settings-orchestration.ts";
10
+ import { skillRows, wireSkills } from "./settings-skills.ts";
11
+ import { fillMics, micRow } from "./settings-voice.ts";
7
12
  import { placeOf, SETTINGS_NAV } from "./settings-pages.ts";
8
13
  import { askNotify, notifyOn, playSound, soundPick, SOUNDS, toast } from "./toast.ts";
9
14
  import { updBar } from "./update.ts";
@@ -56,6 +61,15 @@ export async function openSettings() {
56
61
  const gg = await fetch("/google")
57
62
  .then((r) => r.json())
58
63
  .catch(() => ({}));
64
+ const ap = await fetch("/agent-prefs")
65
+ .then((r) => (r.ok ? r.json() : null))
66
+ .catch(() => null);
67
+ const ac = await fetch("/accounts")
68
+ .then((r) => (r.ok ? r.json() : null))
69
+ .catch(() => null);
70
+ const sk = await fetch("/skills")
71
+ .then((r) => (r.ok ? r.json() : null))
72
+ .catch(() => null);
59
73
  if (gen !== store.pageGen) return;
60
74
  $("psub").textContent = "";
61
75
  $("psub").title = "";
@@ -102,6 +116,7 @@ export async function openSettings() {
102
116
  if (!m.has(sub)) m.set(sub, []);
103
117
  m.get(sub).push(r);
104
118
  };
119
+ const defaultAgent = cfg?.rows.find((r) => r.key === "agent.default")?.value ?? "auto";
105
120
  if (cfg) {
106
121
  put("general", "Scope", row(
107
122
  "Settings for",
@@ -110,13 +125,18 @@ export async function openSettings() {
110
125
  "s-scope",
111
126
  "settings for scope project all projects",
112
127
  ));
128
+ // Drawn as chips with the agent list, above the rest of the page.
129
+ cfg.rows = cfg.rows.filter((r) => !(r.key === "agent.default" && ap));
113
130
  for (const r of cfg.rows) {
114
131
  const id = "s-" + r.key.replace(/\./g, "-");
115
132
  const [page, sub] = placeOf(r.key);
133
+ const wm = r.key.startsWith("orchestration.worker_model.");
116
134
  put(page, sub + (scoped && r.group === "Board" ? " · all projects" : ""), row(
117
- r.label,
135
+ wm ? modelLabel(r) : r.label,
118
136
  r.text
119
- ? r.folder
137
+ ? wm
138
+ ? modelInput(r, id)
139
+ : r.folder
120
140
  ? html`<span class="fpick"><input class="sel" id="${id}" value="${r.value}" placeholder="not set" spellcheck="false"><button class="btn" id="${id}-pick" type="button">Browse…</button></span>`
121
141
  : html`<input class="sel" id="${id}" value="${r.value}" placeholder="not set" spellcheck="false">`
122
142
  : ctl(id, r.values, r.value),
@@ -127,14 +147,20 @@ export async function openSettings() {
127
147
  ));
128
148
  }
129
149
  }
150
+ put("voice", "Dictation", row("Microphone", micRow(), "Used by this browser. Names appear after you first allow the microphone. Ctrl+Alt+D dictates into the focused terminal.", "v-mic", "microphone input device mic dictation shortcut"));
130
151
  put("mobile", "Phone", row("Phone address", cfg?.phoneUrls?.length ? html`<span class="phoneurls">${cfg.phoneUrls.map((url) => html`<a href="${url}" target="_blank" rel="noopener">${url}</a>`)}</span>` : html`<span>Not set</span>`, cfg?.phoneUrls?.length ? "Configured address; Tailscale must be running on both devices." : "Run kaizen setup on this PC to connect your phone.", "phone-url", "phone address url tailscale setup"));
131
152
  put("integrations", "Google", row("OAuth client id", html`<input class="sel" id="gg-id" placeholder="${gg.hasClient ? "Saved. Paste a new one to replace it" : "Desktop app client id from Google Cloud"}" spellcheck="false" autocomplete="off">`, "", "gg-id", "google oauth client id sheets write back"));
132
153
  put("integrations", "Google", row("OAuth client secret", html`<span class="fpick"><input class="sel" id="gg-secret" type="password" placeholder="${gg.hasClient ? "Saved. Paste a new one to replace it" : ""}" spellcheck="false" autocomplete="off"><button class="btn" id="gg-save" type="button">Save</button></span>`, "", "gg-secret", "google oauth client secret"));
154
+ let hapton = true;
155
+ try {
156
+ hapton = localStorage.getItem("kz-haptic") !== "off";
157
+ } catch (e) {}
133
158
  put("integrations", "Google", row("Google account", html`<button class="btn${gg.connected ? "" : " pri"}" id="gg-conn" type="button"${gg.hasClient || gg.connected ? "" : " disabled"}>${gg.connected ? "Disconnect" : "Connect"}</button>`, "", "gg-conn", "google account connect sheets write back"));
134
159
  put("appearance", "Browser", row("Theme", ctl("th", ["system", "light", "dark"], cur), "", "th", "theme light dark system browser"));
135
160
  put("appearance", "Browser", row("Color", ctl("co", ["monochrome", "blue"], colour), "", "co", "color colour palette monochrome blue theme browser"));
136
- put("appearance", "Browser", row("Motion", ctl("mo", ["system", "full", "reduce"], document.documentElement.dataset.motion || "system"), "Animations on the board and notes. System follows the device's reduce-motion setting.", "mo", "motion animation reduce reduced browser"));
161
+ put("appearance", "Browser", row("Motion", ctl("mo", ["system", "full", "reduce"], document.documentElement.dataset.motion || "system"), "Animations across kaizen. System follows the device's reduce-motion setting.", "mo", "motion animation reduce reduced browser"));
137
162
  put("notifications", "Browser", row("Notifications", html`<button class="chk sm${nton ? " on" : ""}" id="nt" role="switch" aria-checked="${String(nton)}"></button>`, ntHelp, "nt", "notifications " + ntHelp + " browser"));
163
+ put("notifications", "Browser", row("Haptic feedback", html`<button class="chk sm${hapton ? " on" : ""}" id="hp" role="switch" aria-checked="${String(hapton)}"></button>`, "A light tick when you tap something on a phone.", "hp", "haptic feedback vibrate vibration touch tap phone browser"));
138
164
  put("notifications", "Browser", row("Notification sound", ctl("ns", SOUNDS, soundPick()), "Plays with each notice. Changing it plays it.", "ns", "notification sound audio browser " + SOUNDS.join(" "), !nton));
139
165
  // A narrow screen starts on the list of pages, a wide one on the first page.
140
166
  store.setPage ??= new URLSearchParams(location.search).get("page") || "";
@@ -152,7 +178,7 @@ export async function openSettings() {
152
178
  <button class="sup" type="button">${ico("chev")}Settings</button>
153
179
  <header><h2>${p.title}</h2><p>${p.desc}${scopeName ? ` Editing ${scopeName}.` : ""}</p></header>
154
180
  ${p.id === "general" ? html`<div id="supd"></div>` : ""}
155
- <div class="scard">${[...pageRows.get(p.id)].map(([sub, rows]) => html`<h3 class="sg">${sub}</h3><div class="sgrp">${rows}</div>`)}</div>
181
+ <div class="scard">${p.id === "agents" && ap ? agentRows(ap, defaultAgent, scopeName) : ""}${p.id === "accounts" && ac ? accountRows(ac) : ""}${p.id === "orchestration" && cfg ? orchestrationRows({ windows: !!cfg.windows, bypass: cfg.rows.some((r) => r.key === "orchestration.permissions" && r.value === "bypass") }) : ""}${p.id === "skills" && sk ? skillRows(sk.skills) : ""}${[...pageRows.get(p.id)].map(([sub, rows]) => html`<h3 class="sg">${sub}</h3><div class="sgrp">${rows}</div>`)}</div>
156
182
  </div>`)}
157
183
  ${cfg ? "" : html`<p class="snone">Settings could not be read. Run <code>kaizen settings</code>.</p>`}
158
184
  <p class="snone" id="snone" hidden></p>
@@ -215,6 +241,10 @@ export async function openSettings() {
215
241
  filter();
216
242
  } else close();
217
243
  };
244
+ if (ap) wireAgents(openSettings, cfg?.scope ?? null);
245
+ if (sk) wireSkills(openSettings, sk.token);
246
+ fillMics();
247
+ if (ac) wireAccounts(openSettings);
218
248
  filter();
219
249
  $("smain").scrollTop = top;
220
250
  if (hadFocus) {
@@ -289,6 +319,12 @@ export async function openSettings() {
289
319
  if (on) askNotify();
290
320
  setTimeout(openSettings, 300);
291
321
  };
322
+ $("hp").onclick = () => {
323
+ try {
324
+ localStorage.setItem("kz-haptic", hapton ? "off" : "on");
325
+ } catch (e) {}
326
+ openSettings();
327
+ };
292
328
  choice($("ns"), SOUNDS, soundPick(), (v) => {
293
329
  try {
294
330
  localStorage.setItem("kz-sound", v);
@@ -59,7 +59,7 @@ export function termsBadge() {
59
59
  if (!a) return;
60
60
  if (n) a.dataset.n = String(n);
61
61
  else delete a.dataset.n;
62
- a.title = "Terminal: every agent running in its card" + (n ? ` (${n} hidden)` : "");
62
+ a.title = "Terminal: every agent kaizen runs" + (n ? ` (${n} hidden)` : "");
63
63
  }
64
64
 
65
65
  export function termsStop() {
@@ -178,7 +178,7 @@ export function openTerms() {
178
178
  grid.querySelectorAll(".tsplit").forEach((s) => s.remove());
179
179
  grid.insertAdjacentHTML(
180
180
  "beforeend",
181
- html`<div class="empty tempty"><div class="mascot"></div><b>${hid.length ? "Every terminal is hidden" : "No terminals running"}</b><p>Runs started with the agent in its card show here, from Ideas to Done.</p></div>`.s,
181
+ html`<div class="empty tempty"><div class="mascot"></div><b>${hid.length ? "Every terminal is hidden" : "No terminals running"}</b><p>Runs with an agent open in kaizen show here, from Ideas to Done.</p></div>`.s,
182
182
  );
183
183
  return;
184
184
  }
@@ -62,7 +62,7 @@ export function updBar() {
62
62
  }
63
63
 
64
64
  async function upgrade(b) {
65
- if (!confirm(`Update kaizen to ${upd.latest}? The board restarts, and agents running inside cards stop.`)) return;
65
+ if (!confirm(`Update kaizen to ${upd.latest}? kaizen restarts, and agents it runs stop.`)) return;
66
66
  const label = b.textContent;
67
67
  b.disabled = true;
68
68
  b.textContent = "Updating…";
@@ -23,6 +23,7 @@ export const markView = (v) => {
23
23
  );
24
24
  // The Icebox is titled in the header, top left, like the board.
25
25
  document.querySelector(".hdr h1").textContent = v === "sources" ? "Icebox" : v === "ideas" ? "Ideas" : v === "run" ? "Run" : v === "terminal" ? "Terminal" : v === "home" ? (isPhone() ? "kaizen" : "Home") : v === "chat" ? "Chat" : v === "device" ? "Runs" : "Board";
26
+ if (v === "home" && isPhone()) document.querySelector(".hdr h1").innerHTML = '<pre class="mark" role="img" aria-label="kaizen">' + document.querySelector(".rail pre.mark").innerHTML + "</pre>";
26
27
  };
27
28
  export function go(v, push) {
28
29
  store.pageGen++;
@@ -69,3 +69,9 @@ test("cardLine: waiting on you says so with what it waits for", () => {
69
69
  expect(cardLine(run("a", "building"), "build", "building · 5m")).toBe("building · 5m");
70
70
  expect(cardLine(undefined, "", "")).toBe("no runs");
71
71
  });
72
+
73
+ test("a card's agent signal leads its line", () => {
74
+ expect(cardLine({ signal: "blocked", blocked: { question: "Which?" } }, "running", "building")).toBe("waiting on you · Which?");
75
+ expect(cardLine({ signal: "stale" }, "running", "building")).toBe("stale");
76
+ expect(cardLine({ signal: "unverified" }, "running", "building")).toBe("unverified");
77
+ });
@@ -39,6 +39,8 @@ export function groupWs(cards: any[], projects: any[], wsOfCard) {
39
39
  // The words under a workspace card: a run waiting on the user says so, with what it waits for
40
40
  // ("waiting on you · plan approval"); otherwise the run's own line.
41
41
  export function cardLine(lead: any, leadState: string, sub: string) {
42
+ if (lead?.signal === "blocked") return `waiting on you · ${lead.blocked?.question ?? ""}`;
43
+ if (lead?.signal === "stale" || lead?.signal === "unverified") return lead.signal;
42
44
  if (!lead) return "no runs";
43
45
  if (leadState !== "wait" || lead.kind !== "run") return sub;
44
46
  return lead.status === "waiting" && sub.includes(" · ") ? `waiting on you · ${sub.split(" · ").slice(1).join(" · ")}` : "waiting on you";