kaizen-agent 1.85.2 → 1.86.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.
@@ -5,7 +5,9 @@ import { toast } from "./toast.ts";
5
5
 
6
6
  // Settings → Skills: one row per bundled skill, grouped. /skills scans the folders, so
7
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; status?: string; rea?: { installed: string | null; latest: string | null; update: boolean; outside: boolean } };
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; status?: string; rea?: { installed: string | null; latest: string | null; update: boolean; outside: boolean; node?: NodeNeed | null } };
9
+ // REA runs on the PC's Node.js: missing, or older than REA accepts. `command` is what the server will run.
10
+ type NodeNeed = { state: "missing" | "old"; have?: string; how: "winget" | "brew" | "link"; command?: string; url?: string };
9
11
  const GROUPS: [string, string][] = [["core", "Core"], ["media", "Media"], ["optional", "Optional"]];
10
12
  const WORD: Record<string, string> = { installed: "installed", missing: "missing", other: "your own copy" };
11
13
 
@@ -32,13 +34,18 @@ const WARN: Record<string, string> = {
32
34
  const row = (s: Row) =>
33
35
  html`<div class="sk" data-q="${[s.title, s.id, s.description, s.group, "skill"].join(" ").toLowerCase()}">
34
36
  <div class="sk-h">${skillIcon(s.id)}<span class="sk-n"><b>${s.title}${s.status && s.status !== "stable" ? html` <em class="sk-st">${s.status === "beta" ? "Beta" : "Experimental"}</em>` : ""}</b><span>${s.description}</span></span>
35
- ${s.group === "core" ? (s.agents.some((a) => a.state !== "installed") ? html`<button type="button" class="btn" data-repair="${s.id}" data-own="${String(s.agents.some((a) => a.state === "other"))}">Repair</button>` : html`<span class="hint">Always on</span>`) : html`${s.rea?.update ? html`<button type="button" class="btn" data-rea-update="1">Update to ${s.rea.latest}</button>` : ""}${!s.rea && !s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}${toggleSwitch(!s.off, { sm: true, attrs: { "data-skill": s.id, "data-on": String(s.off), "data-warn": String(!!s.offByDefault), "aria-label": s.title, title: s.off ? "Off" : "On" } })}`}</div>
37
+ ${s.group === "core" ? (s.agents.some((a) => a.state !== "installed") ? html`<button type="button" class="btn" data-repair="${s.id}" data-own="${String(s.agents.some((a) => a.state === "other"))}">Repair</button>` : html`<span class="hint">Always on</span>`) : html`${s.rea?.node ? nodeButton(s.rea.node) : ""}${s.rea?.update ? html`<button type="button" class="btn" data-rea-update="1">Update to ${s.rea.latest}</button>` : ""}${!s.rea && !s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}${toggleSwitch(!s.off, { sm: true, attrs: { "data-skill": s.id, "data-on": String(s.off), "data-warn": String(!!s.offByDefault), "aria-label": s.title, title: s.off ? "Off" : "On" } })}`}</div>
36
38
  <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>
37
39
  </div>`;
38
40
 
39
41
  export const skillRows = (skills: Row[]) =>
40
42
  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>`)}`;
41
43
 
44
+ const nodeWord = (n: NodeNeed) => n.state === "missing" ? "Install Node.js" : "Update Node.js";
45
+ const nodeButton = (n: NodeNeed) => n.how === "link"
46
+ ? html`<a class="btn" href="${n.url}" target="_blank" rel="noopener">Get Node.js</a>`
47
+ : html`<button type="button" class="btn" data-rea-node="${n.state}" data-cmd="${n.command}">${nodeWord(n)}</button>`;
48
+
42
49
  // REA: the board runs REA's dry run first and shows what would change; only a yes to that
43
50
  // exact plan is applied. Off runs REA's own uninstall, whoever set REA up.
44
51
  async function reaSwitch(on: boolean, update: boolean, redraw: () => Promise<unknown>) {
@@ -65,6 +72,16 @@ export function wireSkills(redraw: () => Promise<unknown>, token = "") {
65
72
  if (again) again.onclick = () => redraw();
66
73
  const up = $("pbody").querySelector<HTMLElement>("[data-rea-update]");
67
74
  if (up) up.onclick = () => reaSwitch(true, true, redraw);
75
+ const nb = $("pbody").querySelector<HTMLElement>("[data-rea-node]");
76
+ if (nb) nb.onclick = async () => {
77
+ const what = nb.dataset.reaNode === "missing" ? "Install" : "Update";
78
+ if (!confirm(`${what} Node.js?\n\nREA needs it. kaizen will run:\n ${nb.dataset.cmd}\n\nThis installs Node.js for the whole computer, so other apps that use Node.js get it too. Your system may ask for permission. Go ahead?`)) return;
79
+ nb.setAttribute("disabled", "");
80
+ toast(`${what === "Install" ? "Installing" : "Updating"} Node.js… this can take a few minutes`);
81
+ const j = await post("/rea", { step: "node", confirm: true, token });
82
+ if (!j.error) toast("Node.js is ready. Restart any agents that are open so REA's tools load");
83
+ await redraw();
84
+ };
68
85
  // A core skill one agent is missing: relink it; a real folder in the way is replaced only after asking.
69
86
  $("pbody").querySelectorAll<HTMLElement>("[data-repair]").forEach((b) => (b.onclick = async () => {
70
87
  const own = b.dataset.own === "true";
@@ -37,6 +37,10 @@ export type TaskView = {
37
37
  legacy?: { kind: string; id?: string; text?: string; state?: string };
38
38
  error?: string;
39
39
  projectName?: string;
40
+ queuePaused?: boolean;
41
+ agentAlive?: boolean;
42
+ // What the server allows now; the page draws this list and decides nothing itself.
43
+ actions?: { accept: boolean; acceptWhy?: string; stop: boolean; resume: boolean; abandon: boolean; archive: boolean; delete: boolean; start: boolean };
40
44
  };
41
45
  export type TaskPageData = {
42
46
  task: TaskView;
@@ -48,6 +52,8 @@ const queued = (t: TaskView) => (t.inputs ?? []).filter((i) => ["received", "que
48
52
  export function canAcceptTask(t: TaskView, result?: TaskResult) {
49
53
  return (
50
54
  !!result &&
55
+ t.actions?.accept !== false &&
56
+ !t.queuePaused &&
51
57
  result.id === t.currentResultId &&
52
58
  !t.decision &&
53
59
  !t.activeRun &&
@@ -259,22 +265,29 @@ function technicalView(t: TaskView, current?: TaskResult): Safe {
259
265
  Permission prompts may require the supported terminal controls in the workspace. Stop requests cancellation; it
260
266
  does not undo files.
261
267
  </p>
262
- ${runs.length ? html`<nav aria-label="Linked runs">${runs.map((id) => html`<a class="btn" href="?view=run&id=${id}&dir=${encodeURIComponent(t.dir)}">Open workspace · ${id}</a>`)}</nav>` : html`<p>No run has started yet.</p>`}<div class="tp-close" role="group" aria-label="Close this task"><button type="button" class="btn ghost" data-close="archive">Archive</button>${t.activeRun ? html`<button type="button" class="btn danger" data-close="abandon">Abandon</button>` : html`<button type="button" class="btn danger" data-close="delete">Delete</button>`}</div><small
268
+ ${runs.length ? html`<nav aria-label="Linked runs">${runs.map((id) => html`<a class="btn" href="?view=run&id=${id}&dir=${encodeURIComponent(t.dir)}">Open workspace · ${id}</a>`)}</nav>` : html`<p>No run has started yet.</p>`}<div class="tp-close" role="group" aria-label="Close this task"><button type="button" class="btn ghost" data-close="archive">Archive</button>${closeButtons(t)}</div><small
263
269
  >Task ${t.id} · revision ${t.revision}</small
264
270
  >
265
271
  </div>`;
266
272
  }
273
+ // Archive is always there; Abandon only for a live run; Delete only before any run exists.
274
+ function closeButtons(t: TaskView) {
275
+ const a = t.actions ?? { abandon: !!t.activeRun, delete: !t.activeRun && !(t.runs ?? []).length };
276
+ return html`${a.abandon ? html`<button type="button" class="btn danger" data-close="abandon">Abandon</button>` : ""}${a.delete ? html`<button type="button" class="btn danger" data-close="delete">Delete</button>` : ""}`;
277
+ }
267
278
  function updateActions() {
268
279
  if (!data) return;
269
280
  const t = data.task,
270
281
  current = (data.results ?? []).find((r) => r.id === t.currentResultId);
271
282
  $("tp-accept").hidden = selectedResult !== t.currentResultId || !canAcceptTask(t, current);
272
- $("tp-stop").hidden = !t.activeRun || ["interrupted", "failed", "stopped"].includes(t.status ?? "");
283
+ $("tp-why").textContent = selectedResult === t.currentResultId && !t.decision ? (t.actions?.acceptWhy ?? "") : "";
284
+ $("tp-stop").hidden = !(t.actions?.stop ?? (!!t.activeRun && !["interrupted", "failed"].includes(t.status ?? "")));
273
285
  $("tp-stop").textContent = t.status === "stopping" ? "Stopping…" : "Stop";
274
286
  $("tp-stop").disabled = pending || t.status === "stopping";
275
- $("tp-resume").hidden = !["interrupted", "failed", "stopped"].includes(t.status ?? "");
287
+ $("tp-resume").hidden = !(t.actions?.resume ?? ["interrupted", "failed"].includes(t.status ?? ""));
276
288
  $("tp-resume").textContent = t.status === "failed" ? "Retry" : "Resume";
277
289
  $("tp-start").hidden =
290
+ t.actions?.start === false ||
278
291
  !t.dir || !!t.activeRun || !!t.currentResultId || t.status !== "draft" || t.decision?.kind === "project";
279
292
  $("tp-submit").disabled = pending;
280
293
  $("tp-submit").textContent = pending ? "Sending…" : t.decision?.kind === "question" ? "Send answer" : "Send";
@@ -328,7 +341,7 @@ function draw() {
328
341
  ><button type="button" class="ib" id="tp-chat" aria-label="Conversation" aria-expanded="false" title="Conversation">${ico("note")}<i class="tp-dot" hidden></i></button
329
342
  ><details class="ice-filt" id="tp-info"><summary class="ib" aria-label="Task details" title="Details">${ico("more")}</summary><div class="ice-fpop tp-info-pop"><div id="tp-technical"></div></div></details>
330
343
  </header>
331
- <div class="tp-status" role="status"><span id="tp-status"></span><span id="tp-next"></span><span id="tp-saved" class="dim"></span></div>
344
+ <div class="tp-status" role="status"><span id="tp-status"></span><span id="tp-next"></span><span id="tp-why" class="dim"></span><span id="tp-saved" class="dim"></span></div>
332
345
  <div class="tp-layout">
333
346
  <section class="tp-results" aria-label="Task results">
334
347
  <div id="tp-history"></div>
@@ -381,7 +394,7 @@ function draw() {
381
394
  const ask = { delete: "Delete this task? It is not recorded anywhere.", abandon: "Abandon this run? Saved files are not rolled back." }[op];
382
395
  if (ask && !confirm(ask)) return;
383
396
  const r = await action(op, op === "abandon" ? { why: "abandoned from the task page" } : {});
384
- if (r?.ok && op !== "abandon") {
397
+ if (r?.ok) {
385
398
  history.pushState(null, "", "?view=tasks");
386
399
  go("tasks");
387
400
  }
package/web/board.html CHANGED
@@ -282,7 +282,7 @@ img.plogo{background:none}.ice-meta .plogo{width:14px;height:14px;font-size:9px;
282
282
  /* the mic button turns into a level meter while listening: five bars, each weighted so the set reads as a wave */
283
283
  .vu{display:inline-flex;gap:2px;align-items:center;height:100%}.vu i{width:2px;border-radius:1px;background:currentColor;height:calc(3px + 12px*min(1,var(--lvl,0)*var(--w)));transition:height .08s}
284
284
  .ib.mic.on{color:var(--accent)}.ib.mic.busy{color:var(--accent)}.ib.mic i{font-style:normal;font-size:10px;font-variant-numeric:tabular-nums}.row .mic{margin-right:auto;align-self:center}
285
- .btn{border:1px solid var(--line);border-radius:var(--r-s);padding:4px 12px;color:var(--ink);background:var(--bg-2);min-height:var(--btn-s);font-size:var(--fs);font-weight:500;box-shadow:var(--shadow-1);transition:background .12s,border-color .12s,color .12s}
285
+ .btn{border:1px solid var(--line);border-radius:var(--r-s);padding:4px 12px;color:var(--ink);background:var(--bg-2);min-height:var(--btn-s);font-size:var(--fs);font-weight:500;box-shadow:var(--shadow-1);transition:background .12s,border-color .12s,color .12s}a.btn{display:inline-flex;align-items:center;text-decoration:none}
286
286
  .btn:hover{border-color:var(--dim)}
287
287
  .btn.pri{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}.btn.pri:hover{background:color-mix(in srgb,var(--accent) 88%,var(--ink))}
288
288
  .btn.warn{border-color:var(--warn);color:var(--warn)}.btn.warn:hover{background:var(--warn);color:var(--bg)}