kaizen-agent 1.61.6 → 1.63.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.
- package/README.md +2 -2
- package/agents/kaizen-builder.md +3 -0
- package/agents/kaizen-planner.md +3 -0
- package/agents/kaizen-reviewer.md +2 -0
- package/assets/kaizen-logo.png +0 -0
- package/assets/kaizen.ico +0 -0
- package/cli/__pycache__/computer-helper.cpython-314.pyc +0 -0
- package/cli/accounts.test.ts +126 -0
- package/cli/accounts.ts +116 -0
- package/cli/add-project.ts +4 -2
- package/cli/agent-prefs.test.ts +127 -0
- package/cli/agent-prefs.ts +106 -0
- package/cli/automations.test.ts +167 -0
- package/cli/automations.ts +298 -0
- package/cli/board.test.ts +4 -5
- package/cli/computer-helper.py +299 -0
- package/cli/computer.test.ts +155 -0
- package/cli/computer.ts +66 -0
- package/cli/dashboard.ts +15 -22
- package/cli/install.test.ts +16 -0
- package/cli/install.ts +134 -193
- package/cli/keep-awake.ts +30 -0
- package/cli/look.ts +33 -0
- package/cli/project-tree.test.ts +1 -0
- package/cli/pty.test.ts +2 -1
- package/cli/pty.ts +6 -5
- package/cli/report.test.ts +59 -0
- package/cli/report.ts +62 -0
- package/cli/restart.test.ts +1 -0
- package/cli/settings.test.ts +21 -1
- package/cli/settings.ts +22 -13
- package/cli/setup.test.ts +24 -4
- package/cli/setup.ts +101 -51
- package/cli/skills.test.ts +89 -0
- package/cli/skills.ts +112 -0
- package/cli/sources.ts +1 -1
- package/cli/state.test.ts +53 -4
- package/cli/state.ts +132 -42
- package/cli/term-image.test.ts +23 -0
- package/cli/term-image.ts +26 -0
- package/cli/usage.test.ts +8 -2
- package/cli/usage.ts +8 -6
- package/cli/video.test.ts +5 -5
- package/cli/web-accept.test.ts +1 -0
- package/cli/web-decide.test.ts +1 -0
- package/cli/web-pr.test.ts +1 -0
- package/cli/web-skills.test.ts +32 -0
- package/cli/web-symlink.test.ts +1 -0
- package/cli/web.ts +227 -21
- package/cli/workers.test.ts +319 -0
- package/cli/workers.ts +380 -0
- package/cli/worktree.test.ts +21 -2
- package/cli/worktree.ts +21 -2
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +40 -1
- package/skills/kaizen/settings.md +2 -1
- package/skills/kaizen/skill.json +1 -0
- package/skills/kaizen/spec-build.md +22 -2
- package/skills/kaizen/spec-main.md +9 -0
- package/skills/kaizen/spec-plan.md +18 -1
- package/skills/kaizen/spec-review.md +4 -0
- package/skills/kaizen/spec.md +15 -0
- package/skills/kaizen-help/SKILL.md +2 -0
- package/skills/kaizen-help/skill.json +1 -0
- package/skills/media/kaizen-book/skill.json +1 -0
- package/skills/media/kaizen-deck/SKILL.md +21 -2
- package/skills/media/kaizen-deck/scripts/motion.py +99 -0
- package/skills/media/kaizen-deck/skill.json +1 -0
- package/skills/media/kaizen-video/scripts/__pycache__/intake.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_film.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_tiktok.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/render_cut.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/sfx.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/srt.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/transcribe.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/vo.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/skill.json +1 -0
- package/skills/optional/kaizen-computer/SKILL.md +38 -0
- package/skills/optional/kaizen-computer/skill.json +1 -0
- package/web/board/add-project.ts +3 -3
- package/web/board/agent-favicons.ts +9 -0
- package/web/board/agent-term.ts +1 -1
- package/web/board/api.ts +1 -1
- package/web/board/approvals.ts +1 -1
- package/web/board/cards.ts +50 -7
- package/web/board/dictation.ts +46 -3
- package/web/board/fixes.ts +1 -1
- package/web/board/home.ts +1 -1
- package/web/board/icebox.ts +1 -1
- package/web/board/keys.ts +5 -15
- package/web/board/onboarding.ts +1 -1
- package/web/board/panel.ts +24 -20
- package/web/board/phone.ts +6 -1
- package/web/board/run-view.ts +118 -7
- package/web/board/search.ts +6 -0
- package/web/board/settings-accounts.ts +60 -0
- package/web/board/settings-agents.ts +102 -0
- package/web/board/settings-automations.ts +71 -0
- package/web/board/settings-orchestration.ts +32 -0
- package/web/board/settings-pages.test.ts +9 -0
- package/web/board/settings-pages.ts +11 -4
- package/web/board/settings-skills.ts +47 -0
- package/web/board/settings-voice.test.ts +18 -0
- package/web/board/settings-voice.ts +28 -0
- package/web/board/settings.ts +48 -5
- package/web/board/terms.ts +2 -2
- package/web/board/update.ts +1 -1
- package/web/board/workspace.ts +5 -1
- package/web/board/ws-board.test.ts +6 -0
- package/web/board/ws-board.ts +2 -0
- package/web/board/ws-tabs.test.ts +12 -1
- package/web/board/ws-tabs.ts +18 -0
- package/web/board.html +22 -5
- package/web/board.js +156 -85
- package/web/notebook.js +22 -22
- package/web/notes.html +3 -3
- package/web/term.js +27 -27
- package/web/term.ts +25 -3
- package/web/video.html +2 -2
- package/web/video.js +31 -31
package/web/board/onboarding.ts
CHANGED
|
@@ -77,7 +77,7 @@ function looks() {
|
|
|
77
77
|
function alerts() {
|
|
78
78
|
const s = notif();
|
|
79
79
|
const msg = {
|
|
80
|
-
na: "Notifications are not available at this address. Open
|
|
80
|
+
na: "Notifications are not available at this address. Open kaizen at localhost or over HTTPS to turn them on.",
|
|
81
81
|
default: "Allow notifications so a run that needs you, or an agent that finishes, reaches you in another window.",
|
|
82
82
|
granted: "Notifications are on. kaizen will tell you when a run needs you or an agent is done.",
|
|
83
83
|
denied: "Notifications are blocked for this site. Allow them in your browser's site settings, then come back.",
|
package/web/board/panel.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { store } from "./store.ts";
|
|
|
2
2
|
import { showTerm, termStop } from "./agent-term.ts";
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { APPROVAL, answer, confirmAnswers, confirmRevise, decide, decided, resumable, resume } from "./approvals.ts";
|
|
5
|
-
import { cardEl, key, render, runPopup } from "./cards.ts";
|
|
5
|
+
import { cardEl, formPopup, key, render, runPopup } from "./cards.ts";
|
|
6
6
|
import { chat } from "./chat.ts";
|
|
7
7
|
import { stopDictation } from "./dictation.ts";
|
|
8
8
|
import { $, html, raw } from "./dom.ts";
|
|
@@ -11,7 +11,7 @@ import { gitPending, gitShown, gitTab } from "./git.ts";
|
|
|
11
11
|
import { ICON, WORD, need } from "./labels.ts";
|
|
12
12
|
import { attach, brief, md, planQuestions, preview, progress } from "./markdown.ts";
|
|
13
13
|
import { toast } from "./toast.ts";
|
|
14
|
-
import {
|
|
14
|
+
import { view } from "./views.ts";
|
|
15
15
|
import { isPhone } from "./phone.ts";
|
|
16
16
|
import { openWorkspace } from "./run-view.ts";
|
|
17
17
|
|
|
@@ -40,11 +40,18 @@ const readable = (t) =>
|
|
|
40
40
|
.map((w) => (/^(ui|ux|api|cli|ai|ci|id|url|pr|tui|ios|pwa)$/i.test(w) ? w.toUpperCase() : w))
|
|
41
41
|
.join(" "),
|
|
42
42
|
);
|
|
43
|
+
// Set while a card waits for its workspace to mount this panel: the tab it asked for survives.
|
|
44
|
+
let keepNext = false;
|
|
43
45
|
export function open(c, keepTab) {
|
|
44
|
-
// A
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (view !== "
|
|
46
|
+
// A run is worked on in its workspace, which docks this panel; so is everything on a phone.
|
|
47
|
+
// Ideas keep the panel on the Board and Ideas pages. An archived run has no workspace row: it stays here to be restored.
|
|
48
|
+
const here = view === "board" || view === "ideas";
|
|
49
|
+
if (view !== "run" && (isPhone() || !here || (c.kind === "run" && !c.archived))) {
|
|
50
|
+
keepNext = !!keepTab;
|
|
51
|
+
return void openWorkspace(c);
|
|
52
|
+
}
|
|
53
|
+
keepTab ||= keepNext;
|
|
54
|
+
keepNext = false;
|
|
48
55
|
stopDictation(true); // the panel body is about to be replaced
|
|
49
56
|
fixOff.clear();
|
|
50
57
|
store.openKey = key(c);
|
|
@@ -76,13 +83,7 @@ export function open(c, keepTab) {
|
|
|
76
83
|
}
|
|
77
84
|
// Over the page it is on, as Start does: no trip to the board.
|
|
78
85
|
if (a === "run") return runPopup(c);
|
|
79
|
-
|
|
80
|
-
// The form lives on the board: the run workspace hands over to it.
|
|
81
|
-
if (view === "run") go("board", true);
|
|
82
|
-
close();
|
|
83
|
-
store.mode = a;
|
|
84
|
-
store.modeKey = k;
|
|
85
|
-
render();
|
|
86
|
+
formPopup(c, a);
|
|
86
87
|
}),
|
|
87
88
|
);
|
|
88
89
|
return;
|
|
@@ -271,7 +272,7 @@ export async function openRun(c, refresh, again) {
|
|
|
271
272
|
? ` ${qs.length === 1 ? "1 question" : qs.length + " questions"}.`
|
|
272
273
|
: "";
|
|
273
274
|
const more =
|
|
274
|
-
`<button data-a="archive">Archive</button
|
|
275
|
+
`<button data-a="archive">Archive</button>${c.column === 1 ? `<button data-a="toidea">Back to idea</button>` : ""}<hr><button data-a="ab" class="danger">Abandon</button>`;
|
|
275
276
|
foot.innerHTML = html`<span class="note">${sent ? "Sent to your agent." : APPROVAL[c.awaiting] + asks}</span><details class="more"><summary class="btn ghost">More</summary><div class="menu-pop">${raw(more)}</div></details>${raw(rs)}<span class="dec"><button class="btn" data-a="revise"${sent ? " disabled" : ""}>Revise</button><button class="btn pri" data-a="approve"${sent ? " disabled" : ""}>${c.awaiting === "findings" ? "Approve as-is" : "Approve"}</button></span>`;
|
|
276
277
|
} else if (c.status === "waiting")
|
|
277
278
|
foot.innerHTML = html`<span class="note">Waiting: ${need(c.awaiting)}.</span>${raw(arch)}<button class="btn ghost" data-a="ab">Abandon</button>${raw(rs)}`;
|
|
@@ -315,11 +316,14 @@ export async function openRun(c, refresh, again) {
|
|
|
315
316
|
resume(c, b);
|
|
316
317
|
return;
|
|
317
318
|
}
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
if (a === "toidea") {
|
|
320
|
+
post("/to-idea", { dir: c.state, id: c.id }).then((r) => {
|
|
321
|
+
if (r.ok) toast("Back in Ideas");
|
|
322
|
+
load();
|
|
323
|
+
});
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
formPopup(c, "reject");
|
|
323
327
|
}),
|
|
324
328
|
);
|
|
325
329
|
}
|
|
@@ -339,7 +343,7 @@ export function deep() {
|
|
|
339
343
|
(x) => x.state === d && (id ? x.kind === "run" && x.id === id : x.kind === "idea" && x.text === idea),
|
|
340
344
|
);
|
|
341
345
|
if (!c) {
|
|
342
|
-
toast(id ? "That run
|
|
346
|
+
toast(id ? "That run was not found" : "That idea was not found");
|
|
343
347
|
return;
|
|
344
348
|
}
|
|
345
349
|
const m = /^(finding|backlog)-(\d+)$/.exec(p.get("item") || "");
|
package/web/board/phone.ts
CHANGED
|
@@ -98,7 +98,7 @@ async function newSheet(dir?: string, ws?: string) {
|
|
|
98
98
|
const r = await fetch("/shell", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: at.dir, ws: at.ws, run: wsKey(at.dir, at.ws), ...(cmd ? { agent: cmd } : {}) }) }).catch(() => null);
|
|
99
99
|
const sh = r?.ok ? await r.json() : null;
|
|
100
100
|
if (sh) openTerm({ dir: at.dir, ws: at.ws, key: sh.key } as Agent);
|
|
101
|
-
else toast("No new terminal: " + ((await r?.json().catch(() => null))?.error || "
|
|
101
|
+
else toast("No new terminal: " + ((await r?.json().catch(() => null))?.error || "kaizen did not answer"));
|
|
102
102
|
});
|
|
103
103
|
d.addEventListener("close", () => d.remove());
|
|
104
104
|
document.body.append(d);
|
|
@@ -168,11 +168,16 @@ export function openPhone(m: "home" | "device" | null) {
|
|
|
168
168
|
// but Safari ticks when a switch checkbox toggles, so a hidden one is toggled through its label.
|
|
169
169
|
let tick: HTMLLabelElement | null = null;
|
|
170
170
|
function haptic() {
|
|
171
|
+
try {
|
|
172
|
+
if (localStorage.getItem("kz-haptic") === "off") return;
|
|
173
|
+
} catch (e) {}
|
|
171
174
|
if (navigator.vibrate) return void navigator.vibrate(8);
|
|
172
175
|
if (!tick) {
|
|
173
176
|
tick = document.createElement("label");
|
|
174
177
|
tick.hidden = true;
|
|
175
178
|
tick.innerHTML = `<input type="checkbox" switch>`;
|
|
179
|
+
// This click is not the user's: a window listener would read it as a tap outside a sheet.
|
|
180
|
+
tick.onclick = (e) => e.stopPropagation();
|
|
176
181
|
document.body.append(tick);
|
|
177
182
|
}
|
|
178
183
|
tick.click();
|
package/web/board/run-view.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { load, post } from "./api.ts";
|
|
|
19
19
|
import { attach, md, preview } from "./markdown.ts";
|
|
20
20
|
import { layout } from "./terms.ts";
|
|
21
21
|
import { cardHref, markCurrent, railData, stateOf, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
22
|
-
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
22
|
+
import { type Node, type Box, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, nearestPane, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
23
23
|
import { drawPick, hidePick, initPick, setOpen } from "./run-pick.ts";
|
|
24
24
|
import { age } from "./labels.ts";
|
|
25
25
|
import { go } from "./views.ts";
|
|
@@ -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"}
|
|
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
|
|
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
|
|
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
|
|
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 = () =>
|
|
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,10 +898,118 @@ function initSheet() {
|
|
|
895
898
|
};
|
|
896
899
|
p.addEventListener("touchend", end);
|
|
897
900
|
p.addEventListener("touchcancel", end);
|
|
898
|
-
|
|
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());
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// The keyboard, tmux style: Ctrl+Space puts focus in the current pane, then one more key
|
|
907
|
+
// moves it: arrows or hjkl between panes, 1-9, n, p between tabs.
|
|
908
|
+
const focusPane = (id?: string) => {
|
|
909
|
+
const el = id ? panes.get(id)?.el : null;
|
|
910
|
+
requestAnimationFrame(() => el?.querySelector<HTMLElement>("textarea,input,iframe")?.focus());
|
|
911
|
+
};
|
|
912
|
+
const setPane = (sc: Screen, id: string) => {
|
|
913
|
+
sc.focus = id;
|
|
914
|
+
save();
|
|
915
|
+
draw();
|
|
916
|
+
focusPane(id);
|
|
917
|
+
};
|
|
918
|
+
const DIRS = { ArrowLeft: "l", h: "l", ArrowRight: "r", l: "r", ArrowUp: "u", k: "u", ArrowDown: "d", j: "d" } as const;
|
|
919
|
+
function paneKey(k: string) {
|
|
920
|
+
if (k === "?") {
|
|
921
|
+
(document.activeElement as HTMLElement)?.blur(); // Escape closes it only from outside the terminal
|
|
922
|
+
return void $("help").classList.add("on");
|
|
923
|
+
}
|
|
924
|
+
if (k === "x") {
|
|
925
|
+
const sc = screens().find((x) => x.id === saved().on);
|
|
926
|
+
if (sc) void closeTab(sc.focus).then(() => focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
const mode = { c: "tab", r: "cols", d: "rows" }[k];
|
|
930
|
+
if (mode) {
|
|
931
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(`.radd[data-mode=${mode}]`);
|
|
932
|
+
if (add) add.open = true;
|
|
933
|
+
requestAnimationFrame(() => add?.querySelector<HTMLElement>(".menu-pop button")?.focus());
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const s = saved(),
|
|
937
|
+
scs = screens(),
|
|
938
|
+
at = scs.findIndex((x) => x.id === s.on),
|
|
939
|
+
sc = scs[at];
|
|
940
|
+
if (!sc) return;
|
|
941
|
+
if (DIRS[k]) {
|
|
942
|
+
const boxes: Record<string, Box> = {};
|
|
943
|
+
for (const id of leaves(sc.tree)) {
|
|
944
|
+
const el = panes.get(id)?.el;
|
|
945
|
+
if (el) boxes[id] = el.getBoundingClientRect();
|
|
946
|
+
}
|
|
947
|
+
const to = nearestPane(boxes, sc.focus, DIRS[k]);
|
|
948
|
+
if (to) setPane(sc, to);
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const i = k === "n" ? (at + 1) % scs.length : k === "p" ? (at - 1 + scs.length) % scs.length : /^[1-9]$/.test(k) ? +k - 1 : -1;
|
|
952
|
+
const to = scs[i];
|
|
953
|
+
if (!to) return;
|
|
954
|
+
s.on = to.id;
|
|
955
|
+
save();
|
|
956
|
+
draw();
|
|
957
|
+
focusPane(to.focus);
|
|
958
|
+
}
|
|
959
|
+
// While the prefix waits for its key, a chip says so and lists the keys.
|
|
960
|
+
function keyHint(on: boolean) {
|
|
961
|
+
document.getElementById("keyhint")?.remove();
|
|
962
|
+
if (!on) return;
|
|
963
|
+
const h = document.createElement("div");
|
|
964
|
+
h.id = "keyhint";
|
|
965
|
+
h.setAttribute("role", "status");
|
|
966
|
+
const keys = [["←↓↑→", "pane"], ["1-9", "tab"], ["n p", "next, prev"], ["c", "new tab"], ["r", "split right"], ["d", "split down"], ["x", "close pane"], ["?", "all keys"]];
|
|
967
|
+
h.innerHTML = String(html`${keys.map(([k, t]) => html`<span><kbd>${k}</kbd>${t}</span>`)}`);
|
|
968
|
+
document.body.append(h);
|
|
969
|
+
}
|
|
970
|
+
function initPaneKeys() {
|
|
971
|
+
let armed: Timer | undefined;
|
|
972
|
+
// Capture: xterm must not see these. Ctrl+B would reach an agent or a tmux inside the pane.
|
|
973
|
+
addEventListener(
|
|
974
|
+
"keydown",
|
|
975
|
+
(e) => {
|
|
976
|
+
if (!ctx || !document.body.classList.contains("runv") || document.querySelector("dialog[open]")) return;
|
|
977
|
+
if (e.ctrlKey && !e.shiftKey && e.code === "Space") {
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
e.stopPropagation();
|
|
980
|
+
focusPane(screens().find((x) => x.id === saved().on)?.focus);
|
|
981
|
+
clearTimeout(armed);
|
|
982
|
+
keyHint(true);
|
|
983
|
+
armed = setTimeout(() => ((armed = undefined), keyHint(false)), 2000);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// The open +, split right or split down menu: arrows or j k walk it, Enter picks, Escape closes.
|
|
987
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(".radd[open]");
|
|
988
|
+
if (add) {
|
|
989
|
+
const step = { ArrowDown: 1, j: 1, ArrowUp: -1, k: -1 }[e.key];
|
|
990
|
+
if (step || e.key === "Escape") {
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
e.stopPropagation();
|
|
993
|
+
if (!step) return void ((add.open = false), focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
994
|
+
const items = [...add.querySelectorAll<HTMLElement>(".menu-pop button")];
|
|
995
|
+
items[(items.indexOf(document.activeElement as HTMLElement) + step + items.length) % items.length]?.focus();
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
if (!armed || ["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
|
|
1000
|
+
e.preventDefault();
|
|
1001
|
+
e.stopPropagation();
|
|
1002
|
+
clearTimeout(armed);
|
|
1003
|
+
armed = undefined;
|
|
1004
|
+
keyHint(false);
|
|
1005
|
+
paneKey(e.key);
|
|
1006
|
+
},
|
|
1007
|
+
true,
|
|
1008
|
+
);
|
|
899
1009
|
}
|
|
900
1010
|
|
|
901
1011
|
export function initRunView() {
|
|
1012
|
+
initPaneKeys();
|
|
902
1013
|
// A phone's sheet closes with the panel's ×, which here hides the sheet rather than closing the card.
|
|
903
1014
|
document.addEventListener(
|
|
904
1015
|
"click",
|
package/web/board/search.ts
CHANGED
|
@@ -309,6 +309,12 @@ export function initSearch() {
|
|
|
309
309
|
addEventListener(
|
|
310
310
|
"keydown",
|
|
311
311
|
(e) => {
|
|
312
|
+
// Ctrl+Shift+Space works in a terminal too: no shell or agent needs it.
|
|
313
|
+
if (e.ctrlKey && e.shiftKey && e.code === "Space") {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
e.stopPropagation();
|
|
316
|
+
return void (dl ? dl.close() : openSearch());
|
|
317
|
+
}
|
|
312
318
|
// A terminal keeps its keys: Ctrl+K there is the shell's kill-line.
|
|
313
319
|
if ((e.target as Element)?.closest?.(".xterm")) return;
|
|
314
320
|
const mod = mac ? e.metaKey : e.ctrlKey;
|
|
@@ -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,71 @@
|
|
|
1
|
+
import { post } from "./api.ts";
|
|
2
|
+
import { $, html, raw } from "./dom.ts";
|
|
3
|
+
import { toast } from "./toast.ts";
|
|
4
|
+
|
|
5
|
+
// Settings → Workflows → Automations: schedules that start a run in this project. /automations
|
|
6
|
+
// answers for the page's project; the server makes every decision, this only draws and posts.
|
|
7
|
+
type Hist = { fire: string; at: number; kind: string; status: string; reason?: string; run?: string };
|
|
8
|
+
type Rule = { id: string; name: string; text: string; cron: string; kind: string; enabled: boolean; agent?: string; precheck?: string; precheck_timeout: number; grace_minutes: number; next: number | null; history: Hist[] };
|
|
9
|
+
export type Auto = { zone: string; cap: number; project: string; agents: { cmd: string; name: string }[]; rules: Rule[] };
|
|
10
|
+
|
|
11
|
+
// The form survives the redraw every change event causes.
|
|
12
|
+
const draft: Record<string, string> = { kind: "daily", time: "09:00", day: "mon", grace_minutes: "720", precheck_timeout: "60" };
|
|
13
|
+
let editing = "";
|
|
14
|
+
const when = (t: number) => new Date(t).toLocaleString([], { weekday: "short", hour: "2-digit", minute: "2-digit", day: "numeric", month: "short" });
|
|
15
|
+
const SCHEDULE: Record<string, string> = { hourly: "Every hour", daily: "Every day", weekdays: "Weekdays", weekly: "Every week", cron: "Cron" };
|
|
16
|
+
const f = (k: string) => draft[k] ?? "";
|
|
17
|
+
|
|
18
|
+
const hist = (h: Hist) => html`<li><time>${when(h.at)}</time> · ${h.kind} · <b>${h.status.replace(/_/g, " ")}</b>${h.reason ? html` · ${h.reason}` : ""}${h.run ? html` · <code>${h.run}</code>` : ""}</li>`;
|
|
19
|
+
|
|
20
|
+
const row = (r: Rule) => html`<div class="sk" data-q="${["automation", r.name, r.text, r.cron].join(" ").toLowerCase()}">
|
|
21
|
+
<div class="sk-h"><span class="sk-n"><b>${r.name}</b><span>${SCHEDULE[r.kind]} · <code>${r.cron}</code> · ${r.enabled ? (r.next ? "next " + when(r.next) : "never") : "paused"}</span></span>
|
|
22
|
+
<button type="button" class="btn" data-auto="run" data-id="${r.id}">Run now</button>
|
|
23
|
+
<button type="button" class="btn" data-auto="edit" data-id="${r.id}">Edit</button>
|
|
24
|
+
<button type="button" class="btn" data-auto="delete" data-id="${r.id}">Delete</button>
|
|
25
|
+
<button type="button" class="chk sm${r.enabled ? " on" : ""}" data-auto="${r.enabled ? "pause" : "resume"}" data-id="${r.id}" role="switch" aria-checked="${String(r.enabled)}" aria-label="${r.name}" title="${r.enabled ? "On" : "Paused"}"></button></div>
|
|
26
|
+
<div class="sk-a"><span>${r.text.length > 140 ? r.text.slice(0, 140) + "…" : r.text}</span></div>
|
|
27
|
+
${r.history.length ? html`<details class="sk-a"><summary>History (${r.history.length})</summary><ul>${r.history.map(hist)}</ul></details>` : ""}
|
|
28
|
+
</div>`;
|
|
29
|
+
|
|
30
|
+
const field = (label: string, id: string, ctl: unknown) => html`<label class="sk-n" style="display:block;margin-top:8px"><span style="display:block">${label}</span>${ctl}</label>`;
|
|
31
|
+
const input = (k: string, attrs = "") => html`<input class="sel" data-f="${k}" value="${f(k)}" ${raw(attrs)} spellcheck="false" autocomplete="off" style="width:100%">`;
|
|
32
|
+
|
|
33
|
+
const form = (d: Auto) => html`<div class="sk" data-q="automation new create add schedule">
|
|
34
|
+
<div class="sk-n"><b>${editing ? "Edit automation" : "New automation"}</b><span>Project: ${d.project}. Times are ${d.zone}, this computer's. One board per project: runs start only while a board is open.</span></div>
|
|
35
|
+
<p class="hint" role="alert" style="color:var(--warn)">Warning: an automation runs unattended in auto mode. It plans, builds and reviews with nobody watching, so it changes code in this project and spends tokens. It stops at the final approval only if your approval settings say so. At most ${d.cap} runs a day, and one open run at a time.</p>
|
|
36
|
+
${field("Name", "name", input("name", 'maxlength="60"'))}
|
|
37
|
+
${field("Request (what each run should do)", "text", html`<textarea class="sel" data-f="text" rows="3" style="width:100%">${f("text")}</textarea>`)}
|
|
38
|
+
${field("Schedule", "kind", html`<select class="sel" data-f="kind" style="width:100%">${Object.entries(SCHEDULE).map(([k, v]) => html`<option value="${k}"${f("kind") === k ? " selected" : ""}>${v}</option>`)}</select>`)}
|
|
39
|
+
${f("kind") === "cron" ? field("Cron (minute hour day month weekday)", "cron", input("cron", 'placeholder="0 9 * * 1-5"')) : html`${field(f("kind") === "hourly" ? "At minute (uses the minutes of HH:MM)" : "Time (HH:MM)", "time", input("time", 'placeholder="09:00"'))}${f("kind") === "weekly" ? field("Day", "day", html`<select class="sel" data-f="day" style="width:100%">${["mon", "tue", "wed", "thu", "fri", "sat", "sun"].map((x) => html`<option${f("day") === x ? " selected" : ""}>${x}</option>`)}</select>`) : ""}`}
|
|
40
|
+
${field("Agent", "agent", html`<select class="sel" data-f="agent" style="width:100%"><option value="">Project default</option>${d.agents.map((a) => html`<option value="${a.cmd}"${f("agent") === a.cmd ? " selected" : ""}>${a.name}</option>`)}</select>`)}
|
|
41
|
+
${field("Check before each scheduled run (optional shell command; exit 0 continues)", "precheck", input("precheck", 'placeholder="git fetch -q && test -n "$(git log --since=7.days -1)""'))}
|
|
42
|
+
<p class="hint">Runs on this computer, in the project folder, every time this fires. Not run by Run now.</p>
|
|
43
|
+
${field("Check time limit (seconds)", "precheck_timeout", input("precheck_timeout", 'inputmode="numeric"'))}
|
|
44
|
+
${field("Late start allowed (minutes after the due time)", "grace_minutes", input("grace_minutes", 'inputmode="numeric"'))}
|
|
45
|
+
<div class="sk-a"><button type="button" class="btn pri" data-auto="save">${editing ? "Save" : "Create"}</button>${editing ? html`<button type="button" class="btn" data-auto="cancel">Cancel</button>` : ""}</div>
|
|
46
|
+
</div>`;
|
|
47
|
+
|
|
48
|
+
export const automationRows = (d: Auto) => html`<h3 class="sg">Automations</h3><div class="sgrp">${d.rules.map(row)}${form(d)}</div>`;
|
|
49
|
+
|
|
50
|
+
export function wireAutomations(d: Auto, redraw: () => Promise<unknown>) {
|
|
51
|
+
$("pbody").querySelectorAll<HTMLInputElement>("[data-f]").forEach((el) => {
|
|
52
|
+
el.oninput = () => { draft[el.dataset.f!] = el.value; };
|
|
53
|
+
el.onchange = () => { draft[el.dataset.f!] = el.value; if (el.dataset.f === "kind") redraw(); };
|
|
54
|
+
});
|
|
55
|
+
$("pbody").querySelectorAll<HTMLElement>("[data-auto]").forEach((b) => (b.onclick = async () => {
|
|
56
|
+
const op = b.dataset.auto!, id = b.dataset.id ?? "";
|
|
57
|
+
if (op === "edit") {
|
|
58
|
+
const r = d.rules.find((x) => x.id === id)!;
|
|
59
|
+
editing = id;
|
|
60
|
+
Object.assign(draft, { name: r.name, text: r.text, kind: r.kind, cron: r.cron, agent: r.agent ?? "", precheck: r.precheck ?? "", precheck_timeout: String(r.precheck_timeout), grace_minutes: String(r.grace_minutes), time: "09:00", day: "mon" });
|
|
61
|
+
return void redraw();
|
|
62
|
+
}
|
|
63
|
+
if (op === "cancel") { editing = ""; return void redraw(); }
|
|
64
|
+
if (op === "delete" && !confirm("Delete this automation and its history?")) return;
|
|
65
|
+
const j = await post("/automations", op === "save" ? { op: editing ? "update" : "create", id: editing, ...draft } : { op, id });
|
|
66
|
+
if (j.error) return toast(j.error);
|
|
67
|
+
if (op === "save") { editing = ""; for (const k of ["name", "text", "cron", "agent", "precheck"]) delete draft[k]; toast("Saved"); }
|
|
68
|
+
else if (op === "run") toast(j.ok ? "Started" : (j.status ?? "not started").replace(/_/g, " ") + (j.why ? ": " + j.why : ""));
|
|
69
|
+
await redraw();
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
@@ -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,12 @@ 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
|
+
});
|
|
25
|
+
|
|
26
|
+
test("the Automations page sits under Workflows", () => {
|
|
27
|
+
expect(SETTINGS_NAV.find(([g]) => g === "Workflows")![1].some((p) => p.id === "automations")).toBe(true);
|
|
28
|
+
});
|