kaizen-agent 1.74.0 → 1.75.1
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/cli/agent-prefs.ts +4 -0
- package/cli/state.ts +1 -1
- package/cli/term-history.ts +49 -0
- package/cli/web.ts +13 -2
- package/package.json +1 -1
- package/web/board/badge.ts +4 -0
- package/web/board/new-agent.ts +20 -0
- package/web/board/phone.ts +3 -3
- package/web/board/run-view.ts +6 -2
- package/web/board/term-sessions.ts +14 -0
- package/web/board/terminal-viewport.ts +37 -0
- package/web/board/terms.ts +8 -6
- package/web/board/views.ts +7 -0
- package/web/board.html +40 -1
- package/web/board.js +77 -77
- package/web/notebook.js +106 -106
- package/web/notes.html +3 -1
- package/web/term.js +48 -48
- package/web/term.ts +182 -18
- package/web/video.html +3 -1
- package/web/video.js +116 -116
package/cli/agent-prefs.ts
CHANGED
|
@@ -50,6 +50,10 @@ export const prefersBypass = (cmd: string, p = readPrefs()) => {
|
|
|
50
50
|
const own = p.agents[cmd]?.permissions;
|
|
51
51
|
return own === "bypass" || (own !== "own" && p.permissions === "bypass");
|
|
52
52
|
};
|
|
53
|
+
// Explicit per-launch choices override defaults; unsupported agents never receive bypass.
|
|
54
|
+
export const bypassForLaunch = (cmd: string, requested: unknown, supported: boolean, p = readPrefs()) =>
|
|
55
|
+
supported && (typeof requested === "boolean" ? requested : prefersBypass(cmd, p));
|
|
56
|
+
|
|
53
57
|
// Through env, so a value is never read by a shell. Windows has no env(1): the page says so.
|
|
54
58
|
export const withEnv = (argv: string[], cmd: string, p = readPrefs(), win = process.platform === "win32") => {
|
|
55
59
|
const e = Object.entries(p.agents[cmd]?.env ?? {});
|
package/cli/state.ts
CHANGED
|
@@ -168,7 +168,7 @@ export function agentChoices(projectDir: string) {
|
|
|
168
168
|
return {
|
|
169
169
|
default: detectDefaultAgent(projectDir).cmd,
|
|
170
170
|
agents: KNOWN_AGENTS.filter((a) => agentUsable(a.cmd)).map((a) => ({
|
|
171
|
-
...accountChoices(a.cmd), name: a.name, cmd: a.cmd, model: agentConfig(projectDir, a.cmd).model ?? "", models: !!MODEL_FLAGS[a.cmd], yolo: !!YOLO_FLAGS[a.cmd],
|
|
171
|
+
...accountChoices(a.cmd), name: a.name, cmd: a.cmd, model: agentConfig(projectDir, a.cmd).model ?? "", models: !!MODEL_FLAGS[a.cmd], yolo: !!YOLO_FLAGS[a.cmd], bypassDefault: prefersBypass(a.cmd) && !!YOLO_FLAGS[a.cmd],
|
|
172
172
|
})),
|
|
173
173
|
};
|
|
174
174
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { open } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join, basename } from "node:path";
|
|
4
|
+
|
|
5
|
+
// Read saved history without starting a shell or executing its startup files.
|
|
6
|
+
export function parseHistory(text: string, kind: string): string[] {
|
|
7
|
+
if (kind === "fish") return text.split(/\r?\n/).filter((s) => s.startsWith("- cmd: ")).map((s) => s.slice(7).replace(/\\(\\|n)/g, (_, c) => c === "n" ? "\n" : "\\"));
|
|
8
|
+
const commands: string[] = [];
|
|
9
|
+
let pending = "";
|
|
10
|
+
for (const line of text.split(/\r?\n/)) {
|
|
11
|
+
if (kind === "bash" && /^#\d+$/.test(line)) continue;
|
|
12
|
+
const value = kind === "zsh" ? line.replace(/^: \d+:\d+;/, "") : line;
|
|
13
|
+
if (kind === "zsh" && value.endsWith("\\")) { pending += value.slice(0, -1) + "\n"; continue; }
|
|
14
|
+
if (value || pending) commands.push(pending + value);
|
|
15
|
+
pending = "";
|
|
16
|
+
}
|
|
17
|
+
if (pending) commands.push(pending.trimEnd());
|
|
18
|
+
return commands;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function shellHistory(env: NodeJS.ProcessEnv = process.env, root = homedir()): Promise<string[]> {
|
|
22
|
+
const preferred = basename(env.SHELL || "bash").replace(/\.exe$/i, "");
|
|
23
|
+
const files: [string, string][] = [
|
|
24
|
+
[join(root, ".bash_history"), "bash"],
|
|
25
|
+
[join(env.ZDOTDIR || root, ".zsh_history"), "zsh"],
|
|
26
|
+
[join(env.XDG_DATA_HOME || join(root, ".local", "share"), "fish", "fish_history"), "fish"],
|
|
27
|
+
[join(env.APPDATA || join(root, "AppData", "Roaming"), "Microsoft", "Windows", "PowerShell", "PSReadLine", "ConsoleHost_history.txt"), "powershell"],
|
|
28
|
+
[join(env.XDG_DATA_HOME || join(root, ".local", "share"), "powershell", "PSReadLine", "ConsoleHost_history.txt"), "powershell"],
|
|
29
|
+
];
|
|
30
|
+
files.sort((a, b) => Number(a[1] === preferred) - Number(b[1] === preferred));
|
|
31
|
+
if (env.HISTFILE) files.push([env.HISTFILE.replace(/^~\//, root + "/"), preferred]);
|
|
32
|
+
const commands: string[] = [];
|
|
33
|
+
for (const [path, kind] of files) {
|
|
34
|
+
let file;
|
|
35
|
+
try {
|
|
36
|
+
file = await open(path, "r");
|
|
37
|
+
const stat = await file.stat();
|
|
38
|
+
if (!stat.isFile()) continue;
|
|
39
|
+
const start = Math.max(0, stat.size - 512 * 1024);
|
|
40
|
+
const buffer = Buffer.alloc(Math.min(stat.size, 512 * 1024));
|
|
41
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, start);
|
|
42
|
+
let text = buffer.subarray(0, bytesRead).toString("utf8");
|
|
43
|
+
if (start) text = text.slice(text.indexOf("\n") + 1);
|
|
44
|
+
commands.push(...parseHistory(text, kind));
|
|
45
|
+
} catch { /* A shell may have no saved history or disable it. */ }
|
|
46
|
+
finally { await file?.close(); }
|
|
47
|
+
}
|
|
48
|
+
return [...new Set(commands.reverse().filter((s) => s.trim()))].slice(0, 500);
|
|
49
|
+
}
|
package/cli/web.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// `kaizen web`: the board in a browser. A loopback HTTP server over state.ts and
|
|
2
2
|
// one HTML page; the page never sees the filesystem, only JSON.
|
|
3
|
-
import { agentEnabled, argsOf, commandOf, prefersBypass, publicPref, readPrefs, savePrefs, withEnv } from "./agent-prefs.ts";
|
|
3
|
+
import { bypassForLaunch, agentEnabled, argsOf, commandOf, prefersBypass, publicPref, readPrefs, savePrefs, withEnv } from "./agent-prefs.ts";
|
|
4
4
|
import { awakeHolder, wantAwake } from "./keep-awake.ts";
|
|
5
5
|
import { existsSync, readdirSync, readlinkSync, statSync, lstatSync, realpathSync, readFileSync, watch, appendFileSync, mkdirSync, cpSync, rmSync, writeFileSync, type FSWatcher } from "node:fs";
|
|
6
6
|
import { join, dirname, resolve, sep, basename } from "node:path";
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { ACCOUNT_VAR, accountDir, addAccount, readAccounts, renameAccount, signedIn, removeAccount, resolveAccount, setDefaultAccount } from "./accounts.ts";
|
|
15
15
|
import { readReport, signalOf } from "./report.ts";
|
|
16
16
|
import { MAX_IMAGE, saveImage } from "./term-image.ts";
|
|
17
|
+
import { shellHistory } from "./term-history.ts";
|
|
17
18
|
import { bundledSkills, repairSkill, setSkill, skillsHeld, skillsOff, skillStatus } from "./skills.ts";
|
|
18
19
|
import * as rea from "./rea.ts";
|
|
19
20
|
import { accountEnv, accountForRun, agentUsable, CHILD_ENV, heartbeatMinutes, keepAwake, launchPreview, trustFolder, YOLO_FLAGS } from "./state.ts";
|
|
@@ -913,6 +914,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
913
914
|
return bad("websocket expected", 426);
|
|
914
915
|
}
|
|
915
916
|
|
|
917
|
+
if (req.method === "POST" && path === "/pty/history") {
|
|
918
|
+
const refused = strict(req);
|
|
919
|
+
if (refused) return refused;
|
|
920
|
+
let body: any;
|
|
921
|
+
try { body = await req.json(); } catch { return bad("json body expected"); }
|
|
922
|
+
const key = String(body.key ?? "");
|
|
923
|
+
if (!/^[\w-]+$/.test(key) || !ptyState(key)) return bad("no such terminal", 404);
|
|
924
|
+
return new Response(JSON.stringify({ history: await shellHistory() }), { headers: { "content-type": "application/json", "cache-control": "no-store" } });
|
|
925
|
+
}
|
|
926
|
+
|
|
916
927
|
// The Terminal page's ×: the agent is asked to /exit, and ended if it will not.
|
|
917
928
|
if (req.method === "POST" && path === "/pty/exit") {
|
|
918
929
|
if (!local(req)) return bad("cross-origin write refused", 403);
|
|
@@ -1000,7 +1011,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1000
1011
|
const signIn = typeof body.account === "string" && body.account !== "";
|
|
1001
1012
|
const acct = resolveAccount(a.cmd, signIn ? body.account : undefined);
|
|
1002
1013
|
if (acct.error) return bad(acct.error, 400);
|
|
1003
|
-
bypass = !signIn &&
|
|
1014
|
+
bypass = !signIn && bypassForLaunch(a.cmd, body.yolo, !!YOLO_FLAGS[a.cmd]);
|
|
1004
1015
|
const line = signIn ? [commandOf(a.cmd), ...(a.cmd === "codex" ? ["login"] : [])] : withEnv([commandOf(a.cmd), ...(bypass ? YOLO_FLAGS[a.cmd]! : []), ...argsOf(a.cmd)], a.cmd);
|
|
1005
1016
|
cmd = acct.dir ? ["env", ...accountEnv(acct), ...line] : line;
|
|
1006
1017
|
} else cmd = process.platform === "win32" ? [powershellExe()] : [process.env.SHELL || "sh", "-l"];
|
package/package.json
CHANGED
package/web/board/badge.ts
CHANGED
|
@@ -5,11 +5,15 @@ export function waitingCount(cards: BadgeCard[]) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
// The rail's Projects list draws from the same cards: one fetch feeds both.
|
|
8
|
+
export let allBoardCards: any[] | null = null;
|
|
9
|
+
|
|
8
10
|
let onCards: ((cards: any[], projects?: any[], agents?: any[]) => void) | null = null;
|
|
9
11
|
export const onBoardCards = (f: typeof onCards) => { onCards = f; };
|
|
10
12
|
|
|
11
13
|
export function boardBadge(cards: BadgeCard[], projects?: unknown[], agents?: unknown[]) {
|
|
12
14
|
generation++;
|
|
15
|
+
allBoardCards = cards;
|
|
16
|
+
if (typeof window !== "undefined") dispatchEvent(new Event("kz-all-cards"));
|
|
13
17
|
onCards?.(cards, projects, agents);
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { html, raw } from "./dom.ts";
|
|
2
|
+
|
|
3
|
+
// A launch choice, separate from the user's saved default permission policy.
|
|
4
|
+
export function chooseAgentPermissions(agent: { name: string; cmd: string; yolo?: boolean; bypassDefault?: boolean }): Promise<boolean | null> {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
const d = document.createElement("dialog");
|
|
7
|
+
d.className = "pagsheet agent-create";
|
|
8
|
+
d.innerHTML = String(html`<h4>New ${agent.name}</h4>${agent.yolo ? html`<label class="agent-yolo"><span>Yolo / bypass permissions<small>Run commands without permission prompts</small></span><input type="checkbox" role="switch" aria-label="Yolo / bypass permissions"${raw(agent.bypassDefault ? " checked" : "")}></label>` : html`<p>This agent uses its own permission settings.</p>`}<button type="button" data-create>Create agent</button><button type="button" data-cancel>Cancel</button>`);
|
|
9
|
+
let result: boolean | null = null;
|
|
10
|
+
d.querySelector("[data-create]")!.addEventListener("click", () => {
|
|
11
|
+
result = !!agent.yolo && !!d.querySelector<HTMLInputElement>("input")?.checked;
|
|
12
|
+
d.close();
|
|
13
|
+
});
|
|
14
|
+
d.querySelector("[data-cancel]")!.addEventListener("click", () => d.close());
|
|
15
|
+
d.addEventListener("click", (e) => { if (e.target === d) d.close(); });
|
|
16
|
+
d.addEventListener("close", () => { d.remove(); resolve(result); }, { once: true });
|
|
17
|
+
document.body.append(d);
|
|
18
|
+
d.showModal();
|
|
19
|
+
});
|
|
20
|
+
}
|
package/web/board/phone.ts
CHANGED
|
@@ -83,17 +83,17 @@ async function newSheet(dir?: string, ws?: string) {
|
|
|
83
83
|
const on = spots.find((x) => x.dir === (dir ?? first?.dir) && x.ws === (ws ?? first?.ws)) ?? spots[0];
|
|
84
84
|
if (!on) return toast("Add a project on a computer first");
|
|
85
85
|
const list = await fetch("/agents?dir=" + encodeURIComponent(on.dir)).then((r) => r.json(), () => null);
|
|
86
|
-
const kinds: { cmd: string; name: string }[] = [...(list?.agents ?? []), { cmd: "", name: "Shell" }];
|
|
86
|
+
const kinds: { cmd: string; name: string; yolo?: boolean; bypassDefault?: boolean }[] = [...(list?.agents ?? []), { cmd: "", name: "Shell" }];
|
|
87
87
|
const d = document.createElement("dialog");
|
|
88
88
|
d.className = "pagsheet";
|
|
89
|
-
d.innerHTML = String(html`<h4>New in</h4><select aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select>${kinds.map((k, i) => html`<button type="button" data-i="${String(i)}">${k.cmd ? agentIco({ agent: k.cmd } as Agent) : raw(`<svg class="pag-ico" aria-hidden="true"><use href="#i-term"/></svg>`)}${k.name}</button>`)}`);
|
|
89
|
+
d.innerHTML = String(html`<h4>New in</h4><select aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select><label class="agent-yolo"><span>Yolo / bypass permissions<small>Run commands without permission prompts</small></span><input type="checkbox" role="switch" aria-label="Yolo / bypass permissions"${raw(list?.agents?.find((a) => a.cmd === list.default)?.bypassDefault ? " checked" : "")}></label>${kinds.map((k, i) => html`<button type="button" data-i="${String(i)}">${k.cmd ? agentIco({ agent: k.cmd } as Agent) : raw(`<svg class="pag-ico" aria-hidden="true"><use href="#i-term"/></svg>`)}${k.name}</button>`)}`);
|
|
90
90
|
d.addEventListener("click", async (e) => {
|
|
91
91
|
const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
|
|
92
92
|
if (e.target === d) return d.close();
|
|
93
93
|
if (!b) return;
|
|
94
94
|
const at = spots[Number(d.querySelector("select")!.value)], cmd = kinds[Number(b.dataset.i)].cmd;
|
|
95
95
|
d.close();
|
|
96
|
-
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);
|
|
96
|
+
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, yolo: !!kinds[Number(b.dataset.i)].yolo && d.querySelector<HTMLInputElement>('input[type="checkbox"]')!.checked } : {}) }) }).catch(() => null);
|
|
97
97
|
const sh = r?.ok ? await r.json() : null;
|
|
98
98
|
if (sh) openTerm({ dir: at.dir, ws: at.ws, key: sh.key } as Agent);
|
|
99
99
|
else toast("No new terminal: " + ((await r?.json().catch(() => null))?.error || "kaizen did not answer"));
|
package/web/board/run-view.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// kzTerm mounts on /pty that live as long as their tab, so a tab switch or a /state tick never
|
|
9
9
|
// reconnects them. Split right or down shows a second tab beside the first, sized with the
|
|
10
10
|
// Terminal page's handles.
|
|
11
|
+
import { chooseAgentPermissions } from "./new-agent.ts";
|
|
11
12
|
import { pick } from "./projects.ts";
|
|
12
13
|
import { store } from "./store.ts";
|
|
13
14
|
import { toast } from "./toast.ts";
|
|
@@ -56,7 +57,7 @@ let card: any = null;
|
|
|
56
57
|
let shells: any[] = [];
|
|
57
58
|
let noPty = false;
|
|
58
59
|
// Every agent installed for this project (from /agents), each offered as a bare session.
|
|
59
|
-
let agents: { name: string; cmd: string }[] = [];
|
|
60
|
+
let agents: { name: string; cmd: string; yolo?: boolean; bypassDefault?: boolean }[] = [];
|
|
60
61
|
let defAgent = "";
|
|
61
62
|
// The agents with their own mark in the sprite; the rest show the generic one.
|
|
62
63
|
const MARKS = ["claude", "codex", "gemini"];
|
|
@@ -667,7 +668,10 @@ async function openAgent(c, again = false, focus = true) {
|
|
|
667
668
|
}
|
|
668
669
|
|
|
669
670
|
async function newPty(agent?: string) {
|
|
670
|
-
const
|
|
671
|
+
const target = ctx;
|
|
672
|
+
const choice = agent ? await chooseAgentPermissions(agents.find((a) => a.cmd === agent) ?? { cmd: agent, name: agent }) : undefined;
|
|
673
|
+
if (choice === null || ctx !== target) return;
|
|
674
|
+
const r = await fetch("/shell", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir: ctx!.dir, ws: ctx!.ws, run: ctx!.k, ...(agent ? { agent, yolo: choice } : {}) }) });
|
|
671
675
|
if (r.status === 501) {
|
|
672
676
|
noPty = true;
|
|
673
677
|
return draw();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// One tile per PTY across the all-project snapshot, including secondary stage agents.
|
|
2
|
+
// Only the primary session carries asking/busy state; other entries in `all` are live keys.
|
|
3
|
+
export function terminalSessions(cards: any[], shells: any[]) {
|
|
4
|
+
const sessions = new Map<string, any>();
|
|
5
|
+
for (const c of cards) {
|
|
6
|
+
if (c.archived || !c.pty) continue;
|
|
7
|
+
for (const key of c.pty.all?.length ? c.pty.all : [c.pty.key]) {
|
|
8
|
+
const pty = key === c.pty.key ? c.pty : { key, alive: true, asking: false };
|
|
9
|
+
sessions.set(key, { ...c, pty });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
for (const s of shells) sessions.set(s.key, { kind: "shell", text: s.title, where: s.dir.replace(/[\\/]\.kaizen$/, ""), state: s.dir, pty: { key: s.key, alive: true, asking: false } });
|
|
13
|
+
return sessions;
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// iOS keeps the layout viewport tall when the soft keyboard covers it. Fit the app
|
|
2
|
+
// to the visual viewport while a terminal/composer owns focus, including raw xterm input.
|
|
3
|
+
let users = 0;
|
|
4
|
+
let detach = () => {};
|
|
5
|
+
export function keyboardViewport(height: number, fullHeight: number, scale: number, focused: boolean) {
|
|
6
|
+
return focused && Math.abs(scale - 1) < 0.05 && fullHeight - height > 100 ? Math.round(height) : null;
|
|
7
|
+
}
|
|
8
|
+
export function trackTerminalViewport() {
|
|
9
|
+
if (users++ === 0) {
|
|
10
|
+
const vv = window.visualViewport;
|
|
11
|
+
const update = () => {
|
|
12
|
+
const active = document.activeElement;
|
|
13
|
+
const focused = active instanceof HTMLElement && !!active.closest(".term, .termkeys");
|
|
14
|
+
const height = vv && matchMedia("(max-width:640px)").matches ? keyboardViewport(vv.height, window.innerHeight, vv.scale, focused) : null;
|
|
15
|
+
document.body.classList.toggle("term-keyboard", height !== null);
|
|
16
|
+
if (height !== null) document.documentElement.style.setProperty("--term-viewport-height", `${height}px`);
|
|
17
|
+
else document.documentElement.style.removeProperty("--term-viewport-height");
|
|
18
|
+
};
|
|
19
|
+
const focus = () => requestAnimationFrame(update);
|
|
20
|
+
vv?.addEventListener("resize", update);
|
|
21
|
+
vv?.addEventListener("scroll", update);
|
|
22
|
+
window.addEventListener("resize", update);
|
|
23
|
+
document.addEventListener("focusin", focus);
|
|
24
|
+
document.addEventListener("focusout", focus);
|
|
25
|
+
update();
|
|
26
|
+
detach = () => {
|
|
27
|
+
vv?.removeEventListener("resize", update);
|
|
28
|
+
vv?.removeEventListener("scroll", update);
|
|
29
|
+
window.removeEventListener("resize", update);
|
|
30
|
+
document.removeEventListener("focusin", focus);
|
|
31
|
+
document.removeEventListener("focusout", focus);
|
|
32
|
+
document.body.classList.remove("term-keyboard");
|
|
33
|
+
document.documentElement.style.removeProperty("--term-viewport-height");
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return () => { if (--users === 0) detach(); };
|
|
37
|
+
}
|
package/web/board/terms.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { terminalSessions } from "./term-sessions.ts";
|
|
2
|
+
import { allBoardCards, refreshBoardBadge } from "./badge.ts";
|
|
1
3
|
import { store } from "./store.ts";
|
|
2
4
|
import { $, html, ico } from "./dom.ts";
|
|
3
5
|
import { load, post } from "./api.ts";
|
|
@@ -44,11 +46,7 @@ const tst = (c) => (!c.pty.alive ? "ended" : c.pty.asking ? "asking" : "running"
|
|
|
44
46
|
const projOf = (c) => String(c.where || "").split(/[\\/]/).filter(Boolean).pop() || c.where || "";
|
|
45
47
|
// One card per session; the newest card wins a shared key.
|
|
46
48
|
function sessions() {
|
|
47
|
-
|
|
48
|
-
for (const c of store.S.cards) if (c.pty && !c.archived) m.set(c.pty.key, c);
|
|
49
|
-
// Shells and bare agent sessions a run workspace opened (POST /shell): a tile each too.
|
|
50
|
-
for (const s of store.shells) m.set(s.key, { kind: "shell", text: s.title, where: s.dir.replace(/[\\/]\.kaizen$/, ""), state: s.dir, pty: { key: s.key, alive: true, asking: false } });
|
|
51
|
-
return m;
|
|
49
|
+
return terminalSessions(allBoardCards ?? store.S.cards, store.shells);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
// The side menu's Terminal entry counts the tiles hidden here (the Hidden bar's chips), on every page.
|
|
@@ -75,7 +73,10 @@ const focusTerm = (k: string) => tiles.get(k)?.el.querySelector<HTMLElement>(".x
|
|
|
75
73
|
// Ctrl+Shift+M maximises or restores the tile being typed in. Escape belongs to the agent,
|
|
76
74
|
// so the key is read in capture, before xterm sends it on.
|
|
77
75
|
// The footer's /shells read changed the shell list.
|
|
78
|
-
if (typeof window !== "undefined")
|
|
76
|
+
if (typeof window !== "undefined") {
|
|
77
|
+
addEventListener("kz-shells", () => showing && openTerms());
|
|
78
|
+
addEventListener("kz-all-cards", () => showing && openTerms());
|
|
79
|
+
}
|
|
79
80
|
if (typeof window !== "undefined") addEventListener(
|
|
80
81
|
"keydown",
|
|
81
82
|
(e) => {
|
|
@@ -114,6 +115,7 @@ if (typeof window !== "undefined") addEventListener(
|
|
|
114
115
|
);
|
|
115
116
|
|
|
116
117
|
export function openTerms() {
|
|
118
|
+
if (!showing) void refreshBoardBadge();
|
|
117
119
|
showing = true;
|
|
118
120
|
if (!phone) (phone = matchMedia("(max-width:640px)")).onchange = () => showing && openTerms();
|
|
119
121
|
// A /state tick mid-drag would rebuild the handle being dragged.
|
package/web/board/views.ts
CHANGED
|
@@ -28,6 +28,8 @@ export const markView = (v) => {
|
|
|
28
28
|
};
|
|
29
29
|
export function go(v, push) {
|
|
30
30
|
store.pageGen++;
|
|
31
|
+
document.body.classList.remove("phone-menu-open");
|
|
32
|
+
$("phone-menu")?.setAttribute("aria-expanded", "false");
|
|
31
33
|
if (v === "icebox") v = "sources";
|
|
32
34
|
// A workspace address shows in the run view, which resolves it to a card.
|
|
33
35
|
if (v === "ws") v = "run";
|
|
@@ -93,6 +95,11 @@ export function go(v, push) {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
export function initViews() {
|
|
98
|
+
$("phone-menu").onclick = () => {
|
|
99
|
+
const on = document.body.classList.toggle("phone-menu-open");
|
|
100
|
+
$("phone-menu").setAttribute("aria-expanded", String(on));
|
|
101
|
+
$("phone-menu").setAttribute("aria-label", on ? "Hide navigation menu" : "Show navigation menu");
|
|
102
|
+
};
|
|
96
103
|
initTasks(go);
|
|
97
104
|
initRunView();
|
|
98
105
|
initPhone(go, openWorkspace);
|
package/web/board.html
CHANGED
|
@@ -145,7 +145,7 @@ body .rail a.upd::after{left:calc(50% + 6px);top:4px}body .toast{left:16px;botto
|
|
|
145
145
|
@media(max-width:640px){
|
|
146
146
|
.rail a.it:is([data-view=board],[data-view=tasks],[data-view=sources]),#foot,#ctx-open,body .rail .rbot .rib{display:none!important}
|
|
147
147
|
.rail a.it.ponly{display:flex}
|
|
148
|
-
.rail a.it[data-view=
|
|
148
|
+
.rail a.it[data-view=device]{order:1}.rail a.it.gs-it{order:2}.rail a.it[data-view=home]{order:3}.rail a.it[data-view=chat]{order:4}.rail a.it[data-view=terminal]{order:5}.rail a.it[data-view=settings]{display:none}
|
|
149
149
|
.rail,[data-rail=min] .rail{padding:8px 8px max(2px,calc(env(safe-area-inset-bottom) - 8px));border-top:1px solid color-mix(in srgb,var(--line) 70%,transparent)}
|
|
150
150
|
.rail a.it,[data-rail=min] .rail a.it{min-height:46px;gap:3px;font-size:10.5px;letter-spacing:.01em}
|
|
151
151
|
.rail a.it svg{width:44px;height:26px;padding:4px 12px;box-sizing:border-box;border-radius:13px;transition:background .15s}
|
|
@@ -710,6 +710,42 @@ body.termv #terms{flex:1;min-height:0;display:flex;flex-direction:column;gap:0;p
|
|
|
710
710
|
.tile.max{position:fixed;inset:8px;z-index:10;box-shadow:var(--shadow-1)}body.tmax .tsplit{display:none}
|
|
711
711
|
body.tdrag{user-select:none}body.tdrag .tile{pointer-events:none}
|
|
712
712
|
@media(max-width:900px){body.termv #terms{padding-inline:0}}
|
|
713
|
+
.agent-yolo{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 8px;border-block:1px solid var(--line);margin:8px 0;font-size:14px}.agent-yolo small{display:block;font-size:12px;color:var(--dim);margin-top:3px}.agent-yolo input{appearance:none;position:relative;flex:none;width:44px;height:26px;border:0;border-radius:13px;background:color-mix(in srgb,var(--dim) 40%,transparent);cursor:pointer}.agent-yolo input::after{content:"";position:absolute;left:2px;top:2px;width:22px;height:22px;border-radius:50%;background:#fff;transition:transform .12s}.agent-yolo input:checked{background:var(--accent)}.agent-yolo input:checked::after{transform:translateX(18px)}.agent-yolo input:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
|
714
|
+
@media(min-width:641px){dialog.agent-create{inset:0;margin:auto;width:min(420px,calc(100vw - 32px));height:fit-content;border:1px solid var(--line);border-radius:16px;padding:20px}}
|
|
715
|
+
@media(max-width:640px){html body.term-keyboard{height:var(--term-viewport-height)!important;max-height:var(--term-viewport-height)!important;min-height:0!important;padding-bottom:0}.term-keyboard .termkeys{padding-bottom:0}}
|
|
716
|
+
/* Termius-sized phone accessories: composer toggle, keyboard rows, two panel tabs. */
|
|
717
|
+
.termkeys{flex:none;padding-bottom:env(safe-area-inset-bottom);border-radius:16px 16px 0 0;overflow:hidden}
|
|
718
|
+
.termkeys .compose{padding:8px 10px;gap:8px;align-items:center}
|
|
719
|
+
.termkeys .compose input{height:34px;padding:0 12px;border-radius:10px}
|
|
720
|
+
.termkeys .compose button{height:34px;width:34px;border-radius:10px;font-size:14px;flex:none}
|
|
721
|
+
.termkeys .compose .rawkeyboard{display:grid;place-items:center;background:var(--hover);color:var(--ink-hi)}
|
|
722
|
+
.termkeys .compose .rawkeyboard[aria-pressed=true]{background:var(--accent);color:var(--on-accent)}
|
|
723
|
+
.termkeys .compose .termtoggle{display:grid;place-items:center;background:var(--hover);color:var(--ink-hi)}
|
|
724
|
+
.termkeys .compose .termtoggle.on{background:var(--hover);color:var(--ink-hi)}
|
|
725
|
+
.termkeys .chips{padding:0 10px 6px;gap:4px}
|
|
726
|
+
.termkeys .chips button{height:32px;min-width:32px;padding:0 8px;border:0;border-radius:7px;background:transparent;font-size:12px}
|
|
727
|
+
.termdock{display:flex;justify-content:center;gap:30px;padding:9px 12px;border-top:1px solid var(--line)}
|
|
728
|
+
.termkeys .termdock button{display:grid;place-items:center;width:40px;min-width:40px;height:38px;padding:0;border:0;border-radius:10px;color:var(--dim)}
|
|
729
|
+
.termkeys .termdock button.on{background:var(--hover);color:var(--ink-hi)}
|
|
730
|
+
.termgrid{display:flex;flex-direction:column;gap:12px;padding:10px;max-height:46dvh;overflow-y:auto;overscroll-behavior:contain}
|
|
731
|
+
.termkeygroup{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:7px}
|
|
732
|
+
.termkeygroup+.termkeygroup{padding-top:10px;border-top:1px solid var(--line)}
|
|
733
|
+
.termkeys .termgrid button{min-width:0;height:34px;padding:0 1px;border:0;border-radius:7px;background:var(--hover);font:11px var(--mono)}
|
|
734
|
+
.termkeys .termgrid .enter{height:auto;font-size:22px;align-self:stretch}
|
|
735
|
+
.termkeygroup.functions{grid-template-columns:repeat(6,minmax(0,1fr))}
|
|
736
|
+
.termkeys .termgrid button.on{background:var(--accent);color:var(--on-accent)}
|
|
737
|
+
.termhistory{padding:12px;min-height:230px;max-height:38dvh;overflow-y:auto;overscroll-behavior:contain}
|
|
738
|
+
.termhistory input{width:100%;height:34px;padding:0 12px;margin-bottom:12px;border:1px solid var(--line);border-radius:10px;background:var(--bg);color:var(--ink-hi);font:16px var(--font)}
|
|
739
|
+
.termhistory>div{font:13px var(--font);color:var(--dim)}
|
|
740
|
+
.termkeys .termhistory button{display:block;width:100%;height:44px;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:0;border-radius:8px;font:12px var(--mono);margin-bottom:6px}
|
|
741
|
+
.termkeys button:focus-visible,.termkeys input:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
|
|
742
|
+
.termkeys [hidden]{display:none!important}
|
|
743
|
+
/* A visible terminal owns the phone screen; the header keeps navigation reachable. */
|
|
744
|
+
#phone-menu{display:none}
|
|
745
|
+
@media(max-width:640px){
|
|
746
|
+
html body:is(.runv:has(#rpanes .rpane:not([hidden]) .term),.termv:has(.tile:not(.off) .term)) .hdr>#phone-menu{display:flex!important}
|
|
747
|
+
body:is(.runv:has(#rpanes .rpane:not([hidden]) .term),.termv:has(.tile:not(.off) .term)):not(.phone-menu-open) .rail{display:none}
|
|
748
|
+
}
|
|
713
749
|
/* A phone has no room for a grid or a stack: one terminal fills the page, and tabs above pick which */
|
|
714
750
|
.ttabs{display:none}
|
|
715
751
|
@media(max-width:640px){body.termv #tmodes,.tile [data-a=max],.tsplit{display:none}.ttabs{display:flex;order:-1;flex:1 0 100%;min-width:0;gap:6px;overflow-x:auto;scrollbar-width:none}.ttabs button{flex:none;display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 10px;border:1px solid var(--line);border-radius:var(--r-pill);background:none;color:var(--dim);font:inherit;font-size:12px;white-space:nowrap}.ttabs button.on{color:var(--ink);background:var(--hover);border-color:var(--accent)}.tgrid{display:flex;flex-direction:column}.tile{flex:1}.tile.off{display:none}}
|
|
@@ -1152,11 +1188,13 @@ html body.wsb:not(.paged) #board{grid-template-columns:repeat(4,minmax(200px,1fr
|
|
|
1152
1188
|
<symbol id="r-desk" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></symbol>
|
|
1153
1189
|
<symbol id="r-chat" viewBox="0 0 24 24"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></symbol>
|
|
1154
1190
|
<symbol id="r-runs" viewBox="0 0 24 24"><path d="M9 6h11M9 12h11M9 18h11"/><circle cx="4.5" cy="6" r="1.2"/><circle cx="4.5" cy="12" r="1.2"/><circle cx="4.5" cy="18" r="1.2"/></symbol>
|
|
1191
|
+
<symbol id="r-term" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3M13 15h4"/></symbol>
|
|
1155
1192
|
</defs></svg>
|
|
1156
1193
|
<a class="it gs-it" href="#" id="gsearch" title="Search everything"><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" stroke-width="2"/><path d="M20 20l-4-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg><span class="lbl">Search</span></a>
|
|
1157
1194
|
<a class="it" href="/" data-view="home" title="Home: chat with the project's agent"><svg><use href="#i-home"/></svg><span class="lbl">Home</span></a>
|
|
1158
1195
|
<a class="it ponly" href="/?view=chat" data-view="chat" title="Chat with kaizen's agent"><svg><use href="#r-chat"/></svg><span class="lbl">Chat</span></a>
|
|
1159
1196
|
<a class="it ponly" href="/?view=device" data-view="device" title="This computer's runs"><svg><use href="#r-runs"/></svg><span class="lbl">Runs</span></a>
|
|
1197
|
+
<a class="it ponly" href="/?view=terminal" data-view="terminal" title="Open terminals across all projects"><svg><use href="#r-term"/></svg><span class="lbl">Terminal</span></a>
|
|
1160
1198
|
<a class="it fold" href="/?view=icebox" data-view="sources" title="Icebox: requests gathered from your sources"><svg><use href="#r-tray"/></svg><span class="lbl">Icebox</span><span class="srcs" id="rail-srcs"></span><span class="n" id="ice-n"></span></a>
|
|
1161
1199
|
<a class="it" href="/?view=tasks" data-view="tasks" title="Tasks: every task and run, filtered"><svg><use href="#r-bulb"/></svg><span class="lbl">Tasks</span></a>
|
|
1162
1200
|
<a class="it" href="/?setup=1" id="rsetup" hidden title="Continue setup"><span class="ring"></span><span class="lbl">Setup</span></a>
|
|
@@ -1195,6 +1233,7 @@ html body.wsb:not(.paged) #board{grid-template-columns:repeat(4,minmax(200px,1fr
|
|
|
1195
1233
|
</script>
|
|
1196
1234
|
<div class="app">
|
|
1197
1235
|
<div class="hdr">
|
|
1236
|
+
<button type="button" class="ib" id="phone-menu" aria-label="Show navigation menu" aria-expanded="false" title="Show navigation menu"><svg><use href="#i-more"/></svg></button>
|
|
1198
1237
|
<button class="ib" id="hsidetop" aria-label="Chats" title="Chats"><svg><use href="#i-side"/></svg></button>
|
|
1199
1238
|
<h1>Board</h1>
|
|
1200
1239
|
<div class="combo" id="combo"><button class="sel" id="proj" aria-label="project" aria-haspopup="listbox" aria-expanded="false"></button><div class="menu-pop" id="projpop" hidden><input class="sel" id="projq" aria-label="Search projects" placeholder="Search projects…" spellcheck="false" autocomplete="off"><div id="projs" role="listbox"></div></div></div>
|