@join-pantheon/cli 0.34.3 → 0.35.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/dist/admin-ui.js CHANGED
@@ -448,11 +448,8 @@ export const when = (ts, f = "time") => {
448
448
  const text = fmt === "date" ? longDay(ts) : fmt === "full" ? `${longDay(ts)} ${hhmm(ts)} UTC` : fmt === "sec" ? `${new Date(ts).toISOString().slice(11, 19)} UTC` : `${hhmm(ts)} UTC`;
449
449
  return `<time data-t="${ts}" data-f="${f}" datetime="${new Date(ts).toISOString()}">${text}</time>`;
450
450
  };
451
- export const ACT_WORDS = {
452
- JOIN: "Arrived", LEAVE: "Left", NOTE: "Note", ASK: "Ask", ANSWER: "Answer", PROPOSE: "Proposal", ACCEPT: "Accepted",
453
- OBJECT: "Objection", CONTRACT: "Agreement", COMMIT: "Commitment", DELIVERED: "Delivered", ESCALATE: "Escalation",
454
- HUMAN_REQUIRED: "Needs a person", RETRACT: "Retraction", WITHDRAW: "Release request", CLOSE: "Goal closed",
455
- };
451
+ import { ACT_WORDS } from "./plain.js";
452
+ export { ACT_WORDS };
456
453
  export const actWords = (act) => ACT_WORDS[act] ?? cap(act.toLowerCase().replace(/_/g, " "));
457
454
  const ACT_KIND = {
458
455
  HUMAN_REQUIRED: "need", ESCALATE: "need", OBJECT: "push", RETRACT: "push", WITHDRAW: "push",
@@ -50,10 +50,24 @@ function namedTime(line, now) {
50
50
  t += 24 * HOUR;
51
51
  return t;
52
52
  }
53
+ export function ownWords(line, re, opts = {}) {
54
+ const m = new RegExp(re.source, re.flags.replace("g", "")).exec(line);
55
+ if (!m)
56
+ return false;
57
+ if (/\b(?:expect(?:ed|s)?|assert(?:ion)?(?:Error)?|snapshot|fixture|toEqual|toBe|toMatch|received|mock(?:ed)?)\b/i.test(line))
58
+ return false;
59
+ if (opts.quotes === false)
60
+ return true;
61
+ const before = line.slice(0, m.index);
62
+ const count = (c) => before.split(c).length - 1;
63
+ if (count('"') % 2 === 1 || count("`") % 2 === 1 || count("“") > count("”"))
64
+ return false;
65
+ return true;
66
+ }
53
67
  export function detectOutage(agent, tail, now = Date.now()) {
54
68
  const lines = tail.split("\n").map((l) => l.trim()).filter(Boolean).slice(-TAIL_LINES);
55
69
  for (const k of KINDS[agent] ?? []) {
56
- const line = lines.find((l) => k.re.test(l));
70
+ const line = lines.find((l) => ownWords(l, k.re, { quotes: k.why === SIGNIN }));
57
71
  if (!line)
58
72
  continue;
59
73
  const epoch = agent === "claude-code" ? /Claude AI usage limit reached\|(\d{10})\b/i.exec(line) : null;
package/dist/agents.js CHANGED
@@ -7,7 +7,7 @@ import { join, dirname, isAbsolute, relative } from "node:path";
7
7
  import { copyInside, mkdirInside, writeInside } from "./safe-write.js";
8
8
  import { gitCallEnv, safeGitArgs } from "./git-safe.js";
9
9
  import { launcher, kiroDir } from "./install.js";
10
- import { agentSpawn, loginShellLookup, loginShellRunner, which } from "./which.js";
10
+ import { agentSpawn, loginShellEnv, loginShellLookup, loginShellRunner, which } from "./which.js";
11
11
  import { probeLinuxSandbox, sandboxAdvice } from "./linux-sandbox.js";
12
12
  import { earliest, whenAgain } from "./agent-outage.js";
13
13
  import { PANTHEON_TOOL_NAMES, PANTHEON_TOOLS } from "./tools.js";
@@ -44,7 +44,7 @@ export function hasCopilotExtension(home = homedir()) {
44
44
  }
45
45
  const sh = (cmd, timeoutMs = 5_000) => {
46
46
  try {
47
- return execFileSync("sh", ["-lc", cmd], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: timeoutMs, killSignal: "SIGKILL" }).trim() || null;
47
+ return execFileSync("sh", ["-lc", cmd], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: timeoutMs, killSignal: "SIGKILL", env: loginShellEnv() }).trim() || null;
48
48
  }
49
49
  catch {
50
50
  return null;
package/dist/board.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { ACT_WORDS } from "./plain.js";
1
2
  import { createServer } from "node:http";
2
3
  import { createHash, createHmac, randomBytes, timingSafeEqual } from "node:crypto";
3
4
  import { spawn } from "node:child_process";
@@ -1182,6 +1183,8 @@ const BOARD_JS = `
1182
1183
  "use strict";
1183
1184
  const $ = (id) => document.getElementById(id);
1184
1185
  const LANES = ${JSON.stringify(LANES.map((l) => l.id))};
1186
+ // Each message's kind in plain words (plain.ts), not the protocol's name.
1187
+ const ACT_WORDS = ${JSON.stringify(ACT_WORDS)};
1185
1188
  // The link's single-use nonce, traded once for a session secret. The secret
1186
1189
  // lives in sessionStorage (this exact origin, port included) and goes out only
1187
1190
  // as a header this page sets — never as a cookie, which the browser would also
@@ -1201,7 +1204,14 @@ try { const s = sessionStorage.getItem(SESSION_KEY); if (s && /^[0-9a-f]{64}$/.t
1201
1204
  function keepSession(s) { session = s; try { if (s) sessionStorage.setItem(SESSION_KEY, s); else sessionStorage.removeItem(SESSION_KEY); } catch { /* storage off */ } }
1202
1205
  let state = null;
1203
1206
  let current = null;
1204
- let lastSent = null;
1207
+ // Per decision (#79): a send that finishes after the person moved on must never write into the
1208
+ // decision they are on now — its draft, its "Answered", its Retract — and an unsent draft
1209
+ // survives closing the dialog.
1210
+ const keyOf = (item) => (item ? item.space + "|" + item.id : "");
1211
+ const drafts = new Map(); // keyOf(item) -> { text, kind }: the words and the kind of reply chosen for them
1212
+ // A click's dialog closes only if it is still the dialog of what was clicked (#79): never the one opened since.
1213
+ const closeIf = (item, r) => { if (r && r.ok && keyOf(current) === keyOf(item)) $("detail").close(); };
1214
+ const sentFor = new Map(); // keyOf(item) -> { sent, until }
1205
1215
  let retractTimer = null;
1206
1216
  let timer = null;
1207
1217
  let refreshMs = ${BOARD_REFRESH_MS};
@@ -1443,28 +1453,28 @@ async function openDetail(item, focusReply) {
1443
1453
  blocks($("d-body"), [{ kind: "para", text: item.detail || "" }]);
1444
1454
  $("d-options").hidden = true; $("d-options").replaceChildren();
1445
1455
  const ch = $("d-choices"); ch.replaceChildren();
1446
- if (item.wake) wakeButtons(item, () => d.close()).forEach((b) => ch.append(b));
1447
- else (item.choices || []).forEach((c, idx) => ch.append(button(c.label, (ev) => act({ op: "choose", id: item.id, space: item.space, index: idx }, ev.currentTarget, c.label + " — sent.").then((r) => { if (r && r.ok) d.close(); }), idx === 0 ? "primary" : "")));
1456
+ if (item.wake) wakeButtons(item, () => closeIf(item, { ok: true })).forEach((b) => ch.append(b));
1457
+ else (item.choices || []).forEach((c, idx) => ch.append(button(c.label, (ev) => act({ op: "choose", id: item.id, space: item.space, index: idx }, ev.currentTarget, c.label + " — sent.").then((r) => closeIf(item, r)), idx === 0 ? "primary" : "")));
1448
1458
  ch.hidden = !(item.wake || (item.choices && item.choices.length));
1449
1459
  const kind = $("d-kind"); kind.replaceChildren();
1450
1460
  for (const [v, label] of (item.kind === "decision" ? [["ANSWER", "Answer"], ["NOTE", "Note"], ["ASK", "Ask back"]] : [["NOTE", "Note"], ["ASK", "Ask back"]])) { const o = el("option", "", label); o.value = v; kind.append(o); }
1451
- $("d-text").value = "";
1461
+ { const dr = drafts.get(keyOf(item)); $("d-text").value = dr ? dr.text : ""; if (dr && dr.kind && [...$("d-kind").options].some((o) => o.value === dr.kind)) $("d-kind").value = dr.kind; }
1452
1462
  setStatus("");
1453
- $("d-retract").hidden = true;
1463
+ { const s = sentFor.get(keyOf(item)); $("d-retract").hidden = !(s && s.until > Date.now()); }
1454
1464
  const actions = $("d-actions"); actions.replaceChildren();
1455
1465
  // A change to this person's setup: everything it would do is shown above, then Approve or Keep as is.
1456
1466
  $("d-reply").hidden = item.kind === "change";
1457
1467
  if (item.kind === "change") {
1458
1468
  blocks($("d-body"), (item.detail || "").split("\\n\\n").map((t) => ({ kind: "para", text: t })));
1459
- ch.append(button("Approve", (ev) => act({ op: "change-approve", id: item.id }, ev.currentTarget).then((r) => { if (r && r.ok) d.close(); })));
1460
- ch.append(button("Keep as is", (ev) => act({ op: "change-keep", id: item.id }, ev.currentTarget).then((r) => { if (r && r.ok) d.close(); })));
1469
+ ch.append(button("Approve", (ev) => act({ op: "change-approve", id: item.id }, ev.currentTarget).then((r) => closeIf(item, r))));
1470
+ ch.append(button("Keep as is", (ev) => act({ op: "change-keep", id: item.id }, ev.currentTarget).then((r) => closeIf(item, r))));
1461
1471
  ch.hidden = false;
1462
1472
  $("d-thread").hidden = true; $("d-thread").replaceChildren();
1463
1473
  if (!d.open) d.showModal();
1464
1474
  $("d-close").focus();
1465
1475
  return;
1466
1476
  }
1467
- if (item.kind === "decision" && !item.wake) actions.append(button("Mark done", (ev) => act({ op: "done", id: item.id, space: item.space }, ev.currentTarget).then((r) => { if (r && r.ok) d.close(); })));
1477
+ if (item.kind === "decision" && !item.wake) actions.append(button("Mark done", (ev) => act({ op: "done", id: item.id, space: item.space }, ev.currentTarget).then((r) => closeIf(item, r))));
1468
1478
  actions.append(button("Explain in " + surface(), (ev) => act({ op: "open", id: item.id, space: item.space }, ev.currentTarget)));
1469
1479
  if (item.goal && item.space) actions.append(button("Show the thread", () => thread(item)));
1470
1480
  actions.append(button("Copy the question", () => copy(item.prompt)));
@@ -1479,7 +1489,7 @@ async function openDetail(item, focusReply) {
1479
1489
  if (Array.isArray(j.blocks) && j.blocks.length) blocks($("d-body"), j.blocks);
1480
1490
  if (item.kind === "decision" && Array.isArray(j.options) && j.options.length) {
1481
1491
  const host = $("d-options");
1482
- for (const o of j.options) host.append(button("(" + o.key + ") " + o.text, (ev) => act({ op: "reply", id: item.id, space: item.space, kind: "ANSWER", body: "(" + o.key + ") " + o.text }, ev.currentTarget, "Answered (" + o.key + ") — it is no longer waiting on you.").then((r) => { if (r && r.ok) d.close(); })));
1492
+ for (const o of j.options) host.append(button("(" + o.key + ") " + o.text, (ev) => act({ op: "reply", id: item.id, space: item.space, kind: "ANSWER", body: "(" + o.key + ") " + o.text }, ev.currentTarget, "Answered (" + o.key + ") — it is no longer waiting on you.").then((r) => closeIf(item, r))));
1483
1493
  host.hidden = false;
1484
1494
  }
1485
1495
  } catch { /* the short text stays */ }
@@ -1495,7 +1505,7 @@ async function thread(item) {
1495
1505
  if (!j.ok || !j.acts.length) { host.append(el("p", "muted", j.ok ? "Nothing in this thread yet." : j.error)); return; }
1496
1506
  for (const a of j.acts) {
1497
1507
  const art = el("article");
1498
- art.append(el("p", "meta", [a.from, a.act, ago(a.ts)].filter(Boolean).join(" · ")));
1508
+ art.append(el("p", "meta", [a.from, ACT_WORDS[a.act] || a.act, ago(a.ts)].filter(Boolean).join(" · ")));
1499
1509
  art.append(el("p", "body-text", a.summary && a.body.length > 600 ? a.summary : a.body));
1500
1510
  host.append(art);
1501
1511
  }
@@ -1512,31 +1522,52 @@ async function send() {
1512
1522
  if (btn.disabled) return;
1513
1523
  btn.disabled = true;
1514
1524
  setStatus("Sending…");
1525
+ const k = keyOf(item);
1526
+ const here = () => keyOf(current) === k; // still the decision this was sent from?
1527
+ // In flight, the words are not a draft: reopening this decision meanwhile does not show them as unsent.
1528
+ drafts.delete(k);
1529
+ const putBack = () => { if (!drafts.has(k)) drafts.set(k, { text, kind }); if (here() && !$("d-text").value) $("d-text").value = text; };
1530
+ const name = item.headline || item.title || "that decision";
1515
1531
  try {
1516
1532
  const r = await api("/api/action", { op: "reply", id: item.id, space: item.space, kind, body: text });
1517
- if (!r.ok) { setStatus("Not sent — " + r.message + " Your words are still in the box."); return; }
1518
- $("d-text").value = "";
1519
- setStatus(kind === "ANSWER" ? "Answered — it is no longer waiting on you." : kind === "ASK" ? "Asked — the agent that raised this owes you a reply." : "Noted — it stays waiting.");
1520
- if (r.sent) {
1521
- lastSent = r.sent;
1522
- $("d-retract").hidden = false;
1523
- if (retractTimer) clearTimeout(retractTimer);
1524
- retractTimer = setTimeout(() => { $("d-retract").hidden = true; lastSent = null; }, 60000);
1533
+ if (!r.ok) {
1534
+ putBack();
1535
+ if (here()) setStatus("Not sent — " + r.message + " Your words are still in the box.");
1536
+ else toast("Not sent to “" + name + "” — " + r.message + " Your words are kept on it.");
1537
+ return;
1525
1538
  }
1539
+ drafts.delete(k);
1540
+ const said = kind === "ANSWER" ? "Answered — it is no longer waiting on you." : kind === "ASK" ? "Asked — the agent that raised this owes you a reply." : "Noted — it stays waiting.";
1541
+ if (r.sent) sentFor.set(k, { sent: r.sent, until: Date.now() + 60000 });
1542
+ if (here()) {
1543
+ $("d-text").value = "";
1544
+ setStatus(said);
1545
+ if (r.sent) {
1546
+ $("d-retract").hidden = false;
1547
+ if (retractTimer) clearTimeout(retractTimer);
1548
+ retractTimer = setTimeout(() => { if (keyOf(current) === k) $("d-retract").hidden = true; sentFor.delete(k); }, 60000);
1549
+ }
1550
+ } else toast("“" + name + "”: " + said);
1526
1551
  refresh();
1527
1552
  } catch (e) {
1528
- setStatus(e.auth ? "This board link has expired. Run pantheon board to open a fresh one." : "Not sent — " + (e.gone ? "the board has stopped." : e.message) + " Your words are still in the box.");
1553
+ putBack();
1554
+ const why = e.auth ? "This board link has expired. Run pantheon board to open a fresh one." : "Not sent — " + (e.gone ? "the board has stopped." : e.message);
1555
+ if (here()) setStatus(why + (e.auth ? "" : " Your words are still in the box."));
1556
+ else toast("“" + name + "”: " + why + (e.auth ? "" : " Your words are kept on it."));
1529
1557
  } finally { btn.disabled = false; }
1530
1558
  }
1531
1559
 
1532
1560
  async function retract() {
1561
+ const k = keyOf(current);
1562
+ const s = sentFor.get(k);
1563
+ const lastSent = s && s.until > Date.now() ? s.sent : null;
1533
1564
  if (!lastSent) return;
1534
1565
  const btn = $("d-retract");
1535
1566
  btn.disabled = true;
1536
1567
  setStatus("Retracting…");
1537
1568
  try {
1538
1569
  const r = await api("/api/action", { op: "retract", act: lastSent });
1539
- if (r.ok) { lastSent = null; btn.hidden = true; setStatus("Retracted."); refresh(); }
1570
+ if (r.ok) { sentFor.delete(k); if (keyOf(current) === k) { btn.hidden = true; setStatus("Retracted."); } else toast("Retracted."); refresh(); }
1540
1571
  else setStatus("Could not retract — " + (r.message || r.error));
1541
1572
  } catch (e) { setStatus("Could not retract — " + e.message); }
1542
1573
  finally { btn.disabled = false; }
@@ -1565,6 +1596,10 @@ $("d-close").addEventListener("click", () => $("detail").close());
1565
1596
  $("detail").addEventListener("close", () => { current = null; });
1566
1597
  $("d-send").addEventListener("click", () => send());
1567
1598
  $("d-retract").addEventListener("click", () => retract());
1599
+ // The words typed are kept per decision until sent (#79): closing or switching never throws them away.
1600
+ const keepDraft = () => { if (current) { const v = $("d-text").value; if (v) drafts.set(keyOf(current), { text: v, kind: $("d-kind").value }); else drafts.delete(keyOf(current)); } };
1601
+ $("d-text").addEventListener("input", keepDraft);
1602
+ $("d-kind").addEventListener("change", keepDraft);
1568
1603
  $("d-text").addEventListener("keydown", (ev) => { if (ev.key === "Enter" && (ev.ctrlKey || ev.metaKey)) { ev.preventDefault(); send(); } });
1569
1604
  // A hidden tab stops asking: the relay is not polled for nobody, and the board
1570
1605
  // can stop itself once no one is looking.
package/dist/brief.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { OWED_WORDS, plainRequest } from "./plain.js";
1
2
  export function clip(value, max = 160) {
2
3
  const line = value.replace(/\s+/g, " ").trim();
3
4
  return line.length <= max ? line : `${line.slice(0, max - 1)}…`;
@@ -42,24 +43,24 @@ export function renderBrief(input) {
42
43
  }
43
44
  else {
44
45
  for (const o of human) {
45
- lines.push(` ${ageOf(o.created_at, now).padEnd(10)} ${clip(o.body)}`);
46
+ lines.push(` ${ageOf(o.created_at, now).padEnd(10)} ${clip(plainRequest(o.body, input.person.member))}`);
46
47
  }
47
48
  }
48
49
  if (rest.length) {
49
50
  lines.push("");
50
51
  lines.push("your agent still owes");
51
52
  for (const o of rest) {
52
- lines.push(` ${o.kind.padEnd(8)} ${clip(o.body)}`);
53
+ lines.push(` ${(OWED_WORDS[o.kind] ?? o.kind.toLowerCase()).padEnd(22)} ${clip(plainRequest(o.body, input.person.member))}`);
53
54
  }
54
55
  }
55
56
  lines.push("");
56
57
  lines.push("your agent (last 24h)");
57
58
  if (!input.recentRuns.length) {
58
- lines.push(" no unattended runs");
59
+ lines.push(" nothing done while you were away");
59
60
  }
60
61
  else {
61
62
  for (const r of input.recentRuns) {
62
- const mark = r.ok ? "did" : "failed";
63
+ const mark = r.ok ? "handled" : "couldn't finish";
63
64
  const who = r.triggeredBy && r.triggeredBy !== "unknown" ? ` for ${r.triggeredBy}` : "";
64
65
  const summary = r.summary ? ` — ${clip(r.summary, 120)}` : "";
65
66
  lines.push(` ${ageOf(r.at, now).padEnd(10)} ${mark}${who}${summary}`);