@join-pantheon/cli 0.33.9-rc.1 → 0.33.10-rc.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/dist/accounts.js +8 -0
- package/dist/board.js +38 -3
- package/dist/cli.js +99 -25
- package/dist/client.js +13 -2
- package/dist/config.js +17 -0
- package/dist/doctor.js +8 -4
- package/dist/forget-team.js +106 -0
- package/dist/notifier.js +1 -1
- package/dist/readiness-alert.js +27 -0
- package/dist/reads.js +9 -2
- package/dist/relay.js +402 -71
- package/dist/removed.js +63 -7
- package/dist/roster-file.js +15 -2
- package/dist/tray.js +86 -40
- package/dist/worker-fleet.js +1 -1
- package/helper/macos/menubar.swift +39 -3
- package/helper/macos/prebuilt/manifest.json +4 -4
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/helper/macos/prebuilt/pantheon-tray +0 -0
- package/helper/windows/pantheon-tray.ps1 +58 -1
- package/package.json +1 -1
package/dist/accounts.js
CHANGED
|
@@ -604,6 +604,14 @@ export class Accounts {
|
|
|
604
604
|
this.db.prepare("INSERT INTO spaces (name, owner_account, created_at, deleted_at) VALUES (?, ?, ?, NULL) " +
|
|
605
605
|
"ON CONFLICT(name) DO UPDATE SET owner_account = excluded.owner_account, created_at = excluded.created_at, deleted_at = NULL, owner_deleted_at = NULL WHERE spaces.deleted_at IS NOT NULL").run(name, ownerAccount, now());
|
|
606
606
|
}
|
|
607
|
+
liveSpaceRow(name) {
|
|
608
|
+
const r = this.db.prepare("SELECT name FROM spaces WHERE name = ? AND deleted_at IS NULL").get(name);
|
|
609
|
+
return r?.name ?? null;
|
|
610
|
+
}
|
|
611
|
+
spaceRowsWithStem(stem, any = false) {
|
|
612
|
+
const stemOf = (n) => n.replace(/[^a-z0-9._-]/gi, "_");
|
|
613
|
+
return this.db.prepare(`SELECT name FROM spaces${any ? "" : " WHERE deleted_at IS NULL"}`).all().map((r) => r.name).filter((n) => stemOf(n) === stem);
|
|
614
|
+
}
|
|
607
615
|
markSpaceDeleted(name) {
|
|
608
616
|
this.db.prepare("UPDATE spaces SET deleted_at = ? WHERE name = ? AND deleted_at IS NULL").run(now(), name);
|
|
609
617
|
}
|
package/dist/board.js
CHANGED
|
@@ -11,6 +11,7 @@ import { LIMITS } from "./protocol.js";
|
|
|
11
11
|
import { childNodeFlags } from "./managed.js";
|
|
12
12
|
import { which } from "./which.js";
|
|
13
13
|
import { VERSION } from "./version.js";
|
|
14
|
+
import { shellArg } from "./team-name.js";
|
|
14
15
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
15
16
|
export const CLI_ENTRY = resolve(HERE, "cli.js");
|
|
16
17
|
export const BOARD_IDLE_MS = 30 * 60_000;
|
|
@@ -238,6 +239,8 @@ export function parseBoardAction(raw) {
|
|
|
238
239
|
if (space === null)
|
|
239
240
|
return null;
|
|
240
241
|
const sp = space === undefined ? {} : { space };
|
|
242
|
+
if (v.op === "forget")
|
|
243
|
+
return space && Object.keys(v).every((k) => ["op", "space"].includes(k)) ? { op: "forget", space } : null;
|
|
241
244
|
if (v.op === "retract") {
|
|
242
245
|
const act = str(v.act, ID_RE);
|
|
243
246
|
return act && Object.keys(v).every((k) => ["op", "act"].includes(k)) ? { op: "retract", act } : null;
|
|
@@ -543,6 +546,17 @@ export async function startBoardServer(o = {}) {
|
|
|
543
546
|
sendJson(res, 400, { ok: false, error: "bad request" });
|
|
544
547
|
return;
|
|
545
548
|
}
|
|
549
|
+
if (op.op === "forget") {
|
|
550
|
+
const g = ((await status()).gone_spaces ?? []).find((x) => x.space === op.space);
|
|
551
|
+
if (!g) {
|
|
552
|
+
sendJson(res, 200, { ok: false, message: "that team is not listed as gone on this computer" });
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const r = await deps.cli(["leave", g.space, "--yes", "--if-gone"], 60_000);
|
|
556
|
+
const why = r.err.split("\n").map((l) => l.trim()).filter((l) => l && !/^pantheon \d/.test(l)).pop();
|
|
557
|
+
sendJson(res, 200, { ok: r.code === 0, message: r.code === 0 ? `Removed ${g.name} from this computer.` : (why ?? "it could not be removed — run pantheon leave in a terminal") });
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
546
560
|
if (op.op === "retract") {
|
|
547
561
|
const s = sent.get(op.act);
|
|
548
562
|
if (!s || deps.now() - s.at > SENT_KEEP_MS) {
|
|
@@ -882,10 +896,13 @@ export function renderWatch(s, o = { now: Date.now() }) {
|
|
|
882
896
|
}
|
|
883
897
|
const spaces = s.spaces ?? (s.space ? [s.space] : []);
|
|
884
898
|
const multi = spaces.length > 1;
|
|
885
|
-
|
|
899
|
+
const noTeams = !spaces.length && !!s.gone_spaces?.length;
|
|
900
|
+
lines.push(fit(`${B("Pantheon board")} ${termSafe(s.member ?? "")} · ${termSafe(multi ? `${spaces.length} teams` : (s.space ?? ""))} · ${noTeams ? "" : s.relay_ok ? `${s.online ?? 0} of ${s.members ?? 0} online · ` : "relay unreachable · "}worker ${s.worker_running ? "running" : "off"}`, width + (o.color ? 8 : 0)));
|
|
886
901
|
if (s.agent_problem)
|
|
887
902
|
for (const l of wrapWords(`! ${termSafe(s.agent_problem_lead ?? "Unattended work can't run")}: ${termSafe(s.agent_problem)}`, width))
|
|
888
903
|
lines.push(Y(l));
|
|
904
|
+
for (const g of s.gone_spaces ?? [])
|
|
905
|
+
lines.push(fit(`${termSafe(g.line)} · Remove from this computer: pantheon leave ${termSafe(shellArg(g.space))}`));
|
|
889
906
|
if (s.relay_ok === false || s.decisions_ok === false)
|
|
890
907
|
lines.push(Y(fit(`! Could not reach: ${termSafe((s.unavailable_spaces ?? []).join(", ") || "the relay")} — what is shown may be incomplete`)));
|
|
891
908
|
const items = s.items ?? [];
|
|
@@ -1007,6 +1024,7 @@ export function boardHtml(nonce) {
|
|
|
1007
1024
|
<div class="bar"><span id="health" class="muted"></span><button type="button" id="refresh">Refresh</button></div>
|
|
1008
1025
|
</header>
|
|
1009
1026
|
<div id="problem" class="banner problem" role="status" hidden><strong id="problem-lead"></strong> <span id="problem-text"></span></div>
|
|
1027
|
+
<ul id="gone" class="gone" hidden></ul>
|
|
1010
1028
|
<div id="banner" class="banner" role="alert" hidden></div>
|
|
1011
1029
|
<main id="board" tabindex="-1" aria-busy="true">
|
|
1012
1030
|
<p id="loading" class="muted">Loading your board…</p>
|
|
@@ -1079,6 +1097,8 @@ button[disabled]{opacity:.55;cursor:default}
|
|
|
1079
1097
|
.banner{max-width:980px;margin:12px auto 0;padding:10px 14px;border-radius:8px;background:var(--warn-bg);color:var(--warn-text)}
|
|
1080
1098
|
.banner.err{background:var(--err-bg);color:var(--err-text)}
|
|
1081
1099
|
.banner.problem{border-left:4px solid var(--warn-text);overflow-wrap:anywhere}
|
|
1100
|
+
.gone{max-width:980px;margin:12px auto 0;padding:0;list-style:none}
|
|
1101
|
+
.gone>li{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;padding:10px 14px;border:1px solid var(--line);border-radius:8px;background:var(--card);margin:0 0 8px;overflow-wrap:anywhere}
|
|
1082
1102
|
.empty{margin:4px 0}
|
|
1083
1103
|
dialog{border:1px solid var(--line);border-radius:12px;padding:0;background:var(--card);color:var(--text);width:min(760px,96vw);max-height:92vh}
|
|
1084
1104
|
dialog::backdrop{background:rgba(0,0,0,.45)}
|
|
@@ -1200,13 +1220,28 @@ function render() {
|
|
|
1200
1220
|
return;
|
|
1201
1221
|
}
|
|
1202
1222
|
const spaces = s.spaces || (s.space ? [s.space] : []);
|
|
1203
|
-
$("who").textContent = (s.member || "") + " · " + (spaces.length > 1 ? spaces.length + " teams: " + spaces.join(", ") : "team " + (s.space || ""));
|
|
1223
|
+
$("who").textContent = (s.member || "") + " · " + (spaces.length > 1 ? spaces.length + " teams: " + spaces.join(", ") : spaces.length ? "team " + (s.space || "") : (s.space || ""));
|
|
1204
1224
|
// This computer can't take teammates' requests (signed out, no agent CLI): a row of its own, in full, above the lanes.
|
|
1205
1225
|
const problem = s.agent_problem || "";
|
|
1206
1226
|
$("problem").hidden = !problem;
|
|
1207
1227
|
$("problem-lead").textContent = problem ? (s.agent_problem_lead || "Unattended work can't run") + ":" : "";
|
|
1208
1228
|
$("problem-text").textContent = problem;
|
|
1209
|
-
|
|
1229
|
+
// Teams gone for this computer (deleted, or this person removed): one line each, and the one click that removes it.
|
|
1230
|
+
const gone = s.gone_spaces || [];
|
|
1231
|
+
$("gone").hidden = !gone.length;
|
|
1232
|
+
$("gone").replaceChildren(...gone.map((g) => {
|
|
1233
|
+
const li = el("li");
|
|
1234
|
+
li.append(el("span", "", g.line));
|
|
1235
|
+
li.append(button("Remove from this computer", async (ev) => {
|
|
1236
|
+
const b = ev.currentTarget;
|
|
1237
|
+
b.disabled = true;
|
|
1238
|
+
try { const r = await api("/api/action", { op: "forget", space: g.space }); toast(r.message || (r.ok ? "Removed." : "It could not be removed.")); if (r.ok) await refresh(); }
|
|
1239
|
+
catch (e) { toast("It could not be removed: " + e.message); }
|
|
1240
|
+
finally { b.disabled = false; }
|
|
1241
|
+
}));
|
|
1242
|
+
return li;
|
|
1243
|
+
}));
|
|
1244
|
+
$("health").textContent = (!spaces.length && (s.gone_spaces || []).length ? "" : (s.relay_ok ? (s.online || 0) + " of " + (s.members || 0) + " online" : "relay unreachable") + " · ") + "worker " + (s.worker_running ? "running" : "off") + (problem ? "" : s.worker_state ? " (" + s.worker_state + ")" : "");
|
|
1210
1245
|
const down = (s.unavailable_spaces || []);
|
|
1211
1246
|
const items = s.items || [];
|
|
1212
1247
|
if (!s.relay_ok && !items.length) banner("The relay could not be reached" + (down.length ? " for " + down.join(", ") : "") + ". The board will try again in " + Math.round(refreshMs / 1000) + " seconds.", true);
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, wr
|
|
|
12
12
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
13
13
|
import { PantheonClient } from "./client.js";
|
|
14
14
|
import { agentSpawn, CmdLineUnsafe } from "./which.js";
|
|
15
|
-
import { fromInvite, looksLikeInviteCode, resolveInviteCode, load, save, toInvite, toJoinLink, resolveFor, loadAll, identity, repoInfo, bindRepo, bindFolder, unbindRepo, findMembership, setDefaultSpace, removeMembership, configFor, CONFIG_DIR, CONFIG_PATH, DEFAULT_RELAY, resolveForHook } from "./config.js";
|
|
15
|
+
import { fromInvite, looksLikeInviteCode, resolveInviteCode, load, save, toInvite, toJoinLink, resolveFor, loadAll, identity, repoInfo, bindRepo, bindFolder, unbindRepo, findMembership, matchMembership, setDefaultSpace, removeMembership, configFor, CONFIG_DIR, CONFIG_PATH, DEFAULT_RELAY, resolveForHook } from "./config.js";
|
|
16
16
|
import { fmtLimit, lastSlotNotice, ownedTeamsIn, spaceLimitAdvice } from "./plans.js";
|
|
17
17
|
import { validEmail, validUsername } from "./accounts.js";
|
|
18
18
|
import { install, launcher, installForUser, windowsRepoOverrides, agentAsksOnce } from "./install.js";
|
|
@@ -54,7 +54,7 @@ import { ACTS, LIMITS } from "./protocol.js";
|
|
|
54
54
|
import { loadPersonas, personaByName, describePersona, initPersona, personaDir, olderTeammatesNote } from "./persona.js";
|
|
55
55
|
import { fingerprint, newKeypair, signAccount } from "./identity.js";
|
|
56
56
|
import { VERSION } from "./version.js";
|
|
57
|
-
import { connectFailure, signInHint } from "./refusal.js";
|
|
57
|
+
import { connectFailure, refusalOf, signInHint } from "./refusal.js";
|
|
58
58
|
import * as mcpWindows from "./mcp-windows.js";
|
|
59
59
|
import { updateBanner } from "./update-check.js";
|
|
60
60
|
import { inWokenRun } from "./worker-policy.js";
|
|
@@ -1308,7 +1308,7 @@ const COMMAND_FLAGS = {
|
|
|
1308
1308
|
history: "--goal <id> --from <member> --last <n> --since <seq> --short --presence --json",
|
|
1309
1309
|
usage: "--space <team> --days <n> --json",
|
|
1310
1310
|
network: "--proxy <url> [--no-proxy <hosts>] | --direct | --clear",
|
|
1311
|
-
leave: "[<team>] --yes --keep-identity --stop-relay --project <dir>",
|
|
1311
|
+
leave: "[<team> | <team id>] --yes --if-gone (only if the relay still says the team is deleted, or that you were removed) --keep-identity --stop-relay --project <dir>",
|
|
1312
1312
|
uninstall: "--yes --forget-identity --stop-relay --project <dir>",
|
|
1313
1313
|
stop: "[relay|worker|notifier|menubar|all] --port <n>",
|
|
1314
1314
|
logs: "[relay|worker|notifier|menubar] --follow --n <lines>",
|
|
@@ -1340,14 +1340,41 @@ function rememberWorkingProxy() {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
catch { }
|
|
1342
1342
|
}
|
|
1343
|
+
function teamWords(args, valued = []) {
|
|
1344
|
+
const out = [];
|
|
1345
|
+
for (let i = 0; i < args.length; i++) {
|
|
1346
|
+
const a = args[i];
|
|
1347
|
+
if (a.startsWith("--")) {
|
|
1348
|
+
if (valued.includes(a))
|
|
1349
|
+
i++;
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
out.push(a);
|
|
1353
|
+
}
|
|
1354
|
+
return out.join(" ").trim();
|
|
1355
|
+
}
|
|
1356
|
+
function teamArg(all, m) {
|
|
1357
|
+
const hit = matchMembership(all, m.name);
|
|
1358
|
+
return shellArg(hit && "m" in hit && hit.m.id === m.id ? m.name : m.id);
|
|
1359
|
+
}
|
|
1360
|
+
function pickTeam(all, ref, command) {
|
|
1361
|
+
const hit = matchMembership(all, ref);
|
|
1362
|
+
if (hit && "m" in hit)
|
|
1363
|
+
return hit.m;
|
|
1364
|
+
if (hit)
|
|
1365
|
+
die(`several of your teams are called "${ref}" — name the one you mean by its id:\n` +
|
|
1366
|
+
hit.many.map((x) => ` ${command.replace("<id>", shellArg(x.id))} ${D(`"${x.name}" on ${x.relay}`)}`).join("\n"));
|
|
1367
|
+
return die(`you are not in a team called "${ref}". Yours: ${Object.values(all.spaces ?? {}).map((x) => x.name).join(", ") || "none"}`);
|
|
1368
|
+
}
|
|
1343
1369
|
async function teamStanding(all, m) {
|
|
1344
1370
|
const c = new PantheonClient(configFor(all, m, null), undefined, { role: "cli" });
|
|
1345
1371
|
try {
|
|
1346
1372
|
await Promise.race([c.connect(), new Promise((_, rej) => setTimeout(() => rej(new Error("timeout")), 8_000))]);
|
|
1347
1373
|
return { others: c.members.filter((x) => x.admitted && x.member !== all.member).map((x) => x.member), founder: !!c.members.find((x) => x.member === all.member)?.founder };
|
|
1348
1374
|
}
|
|
1349
|
-
catch {
|
|
1350
|
-
|
|
1375
|
+
catch (e) {
|
|
1376
|
+
const r = refusalOf(e);
|
|
1377
|
+
return { others: null, founder: false, ...(r ? { refused: r.code } : {}) };
|
|
1351
1378
|
}
|
|
1352
1379
|
finally {
|
|
1353
1380
|
c.dispose();
|
|
@@ -2095,16 +2122,28 @@ async function main() {
|
|
|
2095
2122
|
return;
|
|
2096
2123
|
}
|
|
2097
2124
|
case "status": {
|
|
2125
|
+
const RM = await import("./removed.js");
|
|
2126
|
+
const teamOf = (cfg) => ({ space: cfg.space, spaceId: cfg.spaceId ?? null, relay: cfg.relay, member: cfg.member });
|
|
2127
|
+
const goneSays = (cfg, g) => console.log(`${RM.goneLine(cfg.space, g)} ${D(`— remove it from this computer: ${RM.leaveCommand(teamOf(cfg))}`)}`);
|
|
2098
2128
|
const showStatus = async (cfg) => {
|
|
2099
2129
|
const client = new PantheonClient(cfg, undefined, { role: "cli" });
|
|
2100
|
-
|
|
2130
|
+
let failed = null;
|
|
2131
|
+
await client.connect().catch((e) => { failed = e; });
|
|
2132
|
+
if (failed) {
|
|
2101
2133
|
if (client.pending) {
|
|
2102
2134
|
console.error(`${B("not admitted yet")} (${C(cfg.member)}, fingerprint ${C(fingerprint(cfg.publicKey))})\n`);
|
|
2103
2135
|
console.error(client.pending);
|
|
2104
2136
|
process.exit(2);
|
|
2105
2137
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2138
|
+
const g = RM.goneOf(teamOf(cfg));
|
|
2139
|
+
const code = refusalOf(failed)?.code;
|
|
2140
|
+
if (g && (code === "REVOKED" || code === "SPACE_DELETED")) {
|
|
2141
|
+
client.dispose();
|
|
2142
|
+
goneSays(cfg, g);
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
die(connectFailure(failed, cfg.relay) + (g ? D(`\n (earlier, on ${RM.localDay(g.at)}: ${g.kind === "deleted" ? "the relay said this team was deleted" : `this machine was removed from it${g.by ? ` by ${g.by}` : ""}`})`) : ""));
|
|
2146
|
+
}
|
|
2108
2147
|
await new Promise((r) => setTimeout(r, 350));
|
|
2109
2148
|
const peers = client.roster.filter((m) => m.id !== cfg.member);
|
|
2110
2149
|
const { termSafe } = await import("./board.js");
|
|
@@ -2194,6 +2233,11 @@ async function main() {
|
|
|
2194
2233
|
for (const [i, c] of ts.entries()) {
|
|
2195
2234
|
if (ts.length > 1)
|
|
2196
2235
|
console.log(`${i ? "\n" : ""}${D("━━━ team")} ${B(c.space)} ${D(`(${i + 1} of ${ts.length}) ━━━`)}`);
|
|
2236
|
+
const g = RM.goneOf(teamOf(c));
|
|
2237
|
+
if (g?.kind === "deleted") {
|
|
2238
|
+
goneSays(c, g);
|
|
2239
|
+
continue;
|
|
2240
|
+
}
|
|
2197
2241
|
await showStatus(c);
|
|
2198
2242
|
}
|
|
2199
2243
|
return;
|
|
@@ -2553,7 +2597,12 @@ async function main() {
|
|
|
2553
2597
|
const RM = await import("./removed.js");
|
|
2554
2598
|
for (const { team, record } of RM.removals(RM.teamsOf(loadAll()))) {
|
|
2555
2599
|
const r = RM.removalWords(team, record.by);
|
|
2556
|
-
|
|
2600
|
+
const g = RM.goneOf(team);
|
|
2601
|
+
if (g?.kind === "deleted") {
|
|
2602
|
+
console.log(` gone ${RM.goneLine(r.name, g)} ${D(`— nothing here connects to it; remove it from this computer: ${r.leave}`)}`);
|
|
2603
|
+
continue;
|
|
2604
|
+
}
|
|
2605
|
+
console.log(` removed from "${r.name}"${r.by ? ` by ${r.by}` : ""} ${D(`on ${RM.localDay(record.at)} — this machine stopped connecting to it (checks now and then, at most every 6 hours); coming back needs a new invite: pantheon join <invite>`)}`);
|
|
2557
2606
|
}
|
|
2558
2607
|
console.log(`\n${B("wired into")}`);
|
|
2559
2608
|
for (const w of wiring())
|
|
@@ -2587,7 +2636,8 @@ async function main() {
|
|
|
2587
2636
|
const up = await upP;
|
|
2588
2637
|
console.log(`\n${B("space")} ${cfg.space} you are ${C(cfg.member)}`);
|
|
2589
2638
|
if (!up) {
|
|
2590
|
-
|
|
2639
|
+
const g = RM.goneOf({ space: cfg.space, spaceId: cfg.spaceId ?? null, relay: cfg.relay, member: cfg.member });
|
|
2640
|
+
console.log(` ${g ? `${RM.goneLine(cfg.space, g)} ${D(`— remove it from this computer: ${RM.leaveCommand({ space: cfg.space, spaceId: cfg.spaceId ?? null, relay: cfg.relay })}`)}` : D(client.pending ? "you are not admitted here right now" : "cannot reach the relay from this machine")}`);
|
|
2591
2641
|
return;
|
|
2592
2642
|
}
|
|
2593
2643
|
await new Promise((r) => setTimeout(r, 300));
|
|
@@ -2921,13 +2971,13 @@ async function main() {
|
|
|
2921
2971
|
}
|
|
2922
2972
|
case "space": {
|
|
2923
2973
|
const sub = argv[1];
|
|
2924
|
-
const name = argv
|
|
2925
|
-
if (sub !== "delete" || !name
|
|
2974
|
+
const name = teamWords(argv.slice(2));
|
|
2975
|
+
if (sub !== "delete" || !name)
|
|
2926
2976
|
die("usage: pantheon space delete <team> --yes");
|
|
2927
2977
|
const all = loadAll() ?? die("not configured");
|
|
2928
|
-
const m =
|
|
2978
|
+
const m = pickTeam(all, name, "pantheon space delete <id> --yes");
|
|
2929
2979
|
if (!argv.includes("--yes"))
|
|
2930
|
-
die(`this deletes "${m.name}" for everyone in it — its history, goals and invites — and cannot be undone.\n If you mean it: pantheon space delete ${m
|
|
2980
|
+
die(`this deletes "${m.name}" for everyone in it — its history, goals and invites — and cannot be undone.\n If you mean it: pantheon space delete ${teamArg(all, m)} --yes`);
|
|
2931
2981
|
const client = new PantheonClient(configFor(all, m, null), undefined, { role: "cli" });
|
|
2932
2982
|
await client.connect().catch((e) => die(client.pending ?? connectFailure(e, m.relay)));
|
|
2933
2983
|
await client.deleteSpace(m.name).catch((e) => { client.close(); die(e.message); });
|
|
@@ -2945,25 +2995,49 @@ async function main() {
|
|
|
2945
2995
|
if (uninstalling) {
|
|
2946
2996
|
if (inWokenRun())
|
|
2947
2997
|
die("a woken run cannot uninstall Pantheon — a person has to run this here");
|
|
2948
|
-
|
|
2949
|
-
|
|
2998
|
+
const words = teamWords(argv.slice(1), ["--project"]);
|
|
2999
|
+
if (words)
|
|
3000
|
+
die(`pantheon uninstall takes no team. To drop just one: pantheon leave ${shellArg(words)}`);
|
|
2950
3001
|
}
|
|
2951
|
-
|
|
3002
|
+
const ref = uninstalling ? "" : teamWords(argv.slice(1), ["--project"]);
|
|
3003
|
+
if (ref) {
|
|
2952
3004
|
const all = loadAll() ?? die("not configured");
|
|
2953
|
-
const m =
|
|
3005
|
+
const m = pickTeam(all, ref, "pantheon leave <id>");
|
|
2954
3006
|
const bound = Object.values(all.bindings ?? {}).filter((b) => b.space === m.id).map((b) => b.origin ?? b.path);
|
|
2955
|
-
const
|
|
2956
|
-
|
|
3007
|
+
const RM = await import("./removed.js");
|
|
3008
|
+
const team = { space: m.name, spaceId: m.id.startsWith("legacy:") ? null : m.id, relay: m.relay, member: all.member };
|
|
3009
|
+
let gone = RM.goneOf(team);
|
|
3010
|
+
let others = null, founder = false;
|
|
3011
|
+
if (argv.includes("--if-gone")) {
|
|
3012
|
+
const st = await teamStanding(all, m);
|
|
3013
|
+
gone = RM.goneOf(team);
|
|
3014
|
+
if (!gone)
|
|
3015
|
+
die(`"${m.name}" is not gone — ${st.others !== null ? "the relay let this machine in just now" : "this machine has no record that it was deleted or that you were removed"}. Nothing was removed.`);
|
|
3016
|
+
if (gone.kind === "removed" && st.refused !== "REVOKED")
|
|
3017
|
+
die(`the relay could not be asked whether you are still removed from "${m.name}", so nothing was removed. Try again, or remove it anyway: ${RM.leaveCommand(team)}`);
|
|
3018
|
+
}
|
|
3019
|
+
else if (!gone) {
|
|
3020
|
+
({ others, founder } = await teamStanding(all, m));
|
|
3021
|
+
gone = RM.goneOf(team);
|
|
3022
|
+
}
|
|
3023
|
+
if (!gone && founder && others?.length === 0 && !argv.includes("--yes")) {
|
|
2957
3024
|
die(`you founded "${m.name}" and nobody else is in it. Leaving keeps it on the relay — holding your plan's team slot — and takes away the only way to delete it.\n` +
|
|
2958
|
-
` Delete it instead: pantheon space delete ${m
|
|
3025
|
+
` Delete it instead: pantheon space delete ${teamArg(all, m)} --yes\n Leave it anyway: pantheon leave ${teamArg(all, m)} --yes`);
|
|
2959
3026
|
}
|
|
2960
3027
|
removeMembership(m.id);
|
|
2961
|
-
|
|
2962
|
-
|
|
3028
|
+
const { forgetTeamTraces } = await import("./forget-team.js");
|
|
3029
|
+
const traces = forgetTeamTraces(all, m);
|
|
3030
|
+
const tail = bound.length ? `, and ${bound.length} binding${bound.length === 1 ? "" : "s"} with it (${bound.join(", ")})` : "";
|
|
3031
|
+
if (gone) {
|
|
3032
|
+
console.error(`${B("left")} "${m.name}": ${gone.kind === "deleted" ? "this team no longer exists on the relay" : `you were removed from it${gone.by ? ` by ${gone.by}` : ""}`} — removed from this computer${tail}.`);
|
|
2963
3033
|
}
|
|
2964
|
-
|
|
2965
|
-
|
|
3034
|
+
else
|
|
3035
|
+
console.error(`${B("left")} "${m.name}" — its token is gone from this machine${tail}.`);
|
|
3036
|
+
for (const l of traces.left)
|
|
3037
|
+
console.error(D(` could not remove ${l}`));
|
|
2966
3038
|
sayDefaultAfter(all, m);
|
|
3039
|
+
if (gone)
|
|
3040
|
+
return;
|
|
2967
3041
|
if (others === null)
|
|
2968
3042
|
console.error(D(`The relay could not be reached to check who else is in "${m.name}". If there are teammates, they still list you; one of them removes you with: pantheon admit ${all.member} --revoke`));
|
|
2969
3043
|
else if (others.length)
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket from "ws";
|
|
2
|
-
import { clearRemoval, recordRemoval, removalFor, removalHoldMs, removalRefusal, REMOVED_CHECK_MS, REMOVED_FIRST_MS, REMOVED_MAX_MS } from "./removed.js";
|
|
2
|
+
import { clearRemoval, recordGone, recordRemoval, restateDeletedWhen, removalFor, removalHoldMs, removalRefusal, REMOVED_CHECK_MS, REMOVED_FIRST_MS, REMOVED_MAX_MS } from "./removed.js";
|
|
3
3
|
import { adoptSpaceId, loadAll, rememberTeamRepos, updateMembershipToken } from "./config.js";
|
|
4
4
|
import { honourClearedAuthority } from "./profile.js";
|
|
5
5
|
import { markContinued } from "./continued.js";
|
|
@@ -417,8 +417,19 @@ export class PantheonClient {
|
|
|
417
417
|
catch { }
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
-
if (msg.code === "SPACE_DELETED")
|
|
420
|
+
if (msg.code === "SPACE_DELETED") {
|
|
421
421
|
this.closed = true;
|
|
422
|
+
const g = msg.gone;
|
|
423
|
+
const ours = !!g && g.gone === "deleted" && typeof g.space_id === "string" && g.space_id === this.cfg.spaceId;
|
|
424
|
+
if (g && typeof g.at === "number" && Number.isFinite(g.at))
|
|
425
|
+
this.lastError = restateDeletedWhen(this.lastError, g.at);
|
|
426
|
+
if (ours && !msg.cid && !this.enroll) {
|
|
427
|
+
try {
|
|
428
|
+
recordGone({ space: this.cfg.space, spaceId: this.cfg.spaceId, relay: this.cfg.relay, member: this.cfg.member }, { by: g?.by ?? null, ...(g?.at ? { at: g.at } : {}) });
|
|
429
|
+
}
|
|
430
|
+
catch { }
|
|
431
|
+
}
|
|
432
|
+
}
|
|
422
433
|
const fn = msg.cid ? this.acks.get(msg.cid) : undefined;
|
|
423
434
|
if (fn && msg.cid) {
|
|
424
435
|
this.acks.delete(msg.cid);
|
package/dist/config.js
CHANGED
|
@@ -570,6 +570,23 @@ export function findMembership(f, ref) {
|
|
|
570
570
|
const spaces = f.spaces ?? {};
|
|
571
571
|
return spaces[ref] ?? Object.values(spaces).find((m) => m.name === ref);
|
|
572
572
|
}
|
|
573
|
+
export function matchMembership(f, ref) {
|
|
574
|
+
const r = ref.trim();
|
|
575
|
+
if (!r)
|
|
576
|
+
return null;
|
|
577
|
+
const spaces = Object.values(f.spaces ?? {});
|
|
578
|
+
const byId = Object.prototype.hasOwnProperty.call(f.spaces ?? {}, r) ? f.spaces[r] : undefined;
|
|
579
|
+
if (byId)
|
|
580
|
+
return { m: byId };
|
|
581
|
+
const want = r.toLowerCase();
|
|
582
|
+
const named = spaces.filter((m) => m.name.toLowerCase() === want);
|
|
583
|
+
if (named.length === 1)
|
|
584
|
+
return { m: named[0] };
|
|
585
|
+
if (named.length > 1)
|
|
586
|
+
return { many: named };
|
|
587
|
+
const ids = spaces.filter((m) => m.id.toLowerCase() === want);
|
|
588
|
+
return ids.length === 1 ? { m: ids[0] } : null;
|
|
589
|
+
}
|
|
573
590
|
export function setDefaultSpace(spaceId) {
|
|
574
591
|
const f = loadAll();
|
|
575
592
|
if (!f?.spaces?.[spaceId])
|
package/dist/doctor.js
CHANGED
|
@@ -23,7 +23,7 @@ import { loadPersonas, olderTeammatesNote } from "./persona.js";
|
|
|
23
23
|
import { workerProc, menubarProc, notifierProc, workerFlagRunMinutes } from "./machine.js";
|
|
24
24
|
import { isCatchAllDomain } from "./protocol.js";
|
|
25
25
|
import { probeLinuxSandbox, sandboxDoctorRow } from "./linux-sandbox.js";
|
|
26
|
-
import { removalKey, removalRefusal, removals, removalWords, teamsOf } from "./removed.js";
|
|
26
|
+
import { goneLine, leaveCommand, removalKey, removalRefusal, removals, removalWords, teamsOf } from "./removed.js";
|
|
27
27
|
import { agentById, chooseAgent, describeChoice, detectAvailable, folderReaderLine, knownUserBinary, unattendedReadiness, unattendedRefusal, skippedSummary, SANDBOXED_FOR_UNATTENDED } from "./agents.js";
|
|
28
28
|
import { loginShellLookup, npmSpawn, onPathNamed, which, whichWindows } from "./which.js";
|
|
29
29
|
import { VERSION } from "./version.js";
|
|
@@ -256,8 +256,12 @@ export async function doctor(projectDir) {
|
|
|
256
256
|
else if (here.reason === "stale")
|
|
257
257
|
add("fail", "team", `this ${here.repo ? "repo" : "folder"} is bound to a team this machine has left (${here.binding?.space})`, "pantheon use <team> --here, or pantheon join <invite>", "bound to a team this machine has left");
|
|
258
258
|
for (const { team, record } of removals(teamsOf(loadAll())).filter((x) => x.record.team !== removalKey(cfg) && x.record.team !== `${cfg.relay}|${cfg.space}`)) {
|
|
259
|
-
const w = removalWords(team, record.by);
|
|
260
|
-
|
|
259
|
+
const w = removalWords(team, record.by, record.gone?.kind);
|
|
260
|
+
if (w.deleted && record.gone) {
|
|
261
|
+
add("warn", "removed", `${goneLine(w.name, record.gone)} — it no longer exists on the relay`, `to remove it from this computer: ${w.leave}`, "a team was deleted");
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
add("warn", "removed", `${w.by ? `${w.by} removed you` : "you were removed"} from "${w.name}" (${new Date(record.at).toISOString().slice(0, 10)}) — this machine stopped connecting to it and checks now and then (at most every 6 hours)`, `to come back, you need a new invite from someone in "${w.name}" (pantheon join <invite>) or for a member to let you back in (pantheon admit ${w.member}); to forget it here: ${w.leave}`, "removed from a team");
|
|
261
265
|
}
|
|
262
266
|
if (here.repo && !here.repo.shared)
|
|
263
267
|
add("warn", "team", "this repo has no origin remote", "DELIVERED must name a commit a teammate can fetch; add a remote before delivering", "repo has no origin remote");
|
|
@@ -530,7 +534,7 @@ export async function doctor(projectDir) {
|
|
|
530
534
|
client.pending
|
|
531
535
|
? add("fail", "membership", "registered but not admitted", `ask an admitted member to run: pantheon admit ${cfg.member} (confirm fingerprint ${fingerprint(cfg.publicKey)} with them by voice first)`, "registered, not admitted")
|
|
532
536
|
: removalRefusal(client.lastError)
|
|
533
|
-
? ((r) => add("fail", "membership", `removed from "${cfg.space}"${r.by ? ` by ${r.by}` : ""} — this machine's worker, alerts and menu bar stopped connecting to it (they check now and then, at most every 6 hours)`, `to come back, you need a new invite from someone in "${cfg.space}" (pantheon join <invite>) or for a member to let you back in (pantheon admit ${cfg.member}); to forget it here:
|
|
537
|
+
? ((r) => add("fail", "membership", `removed from "${cfg.space}"${r.by ? ` by ${r.by}` : ""} — this machine's worker, alerts and menu bar stopped connecting to it (they check now and then, at most every 6 hours)`, `to come back, you need a new invite from someone in "${cfg.space}" (pantheon join <invite>) or for a member to let you back in (pantheon admit ${cfg.member}); to forget it here: ${leaveCommand({ space: cfg.space, spaceId: cfg.spaceId ?? null, relay: cfg.relay })}`, "refused: removed from the team"))(removalRefusal(client.lastError))
|
|
534
538
|
: ((r) => add("fail", "membership", `refused: ${r?.message ?? client.lastError ?? "unknown"}`, (r?.fix ?? "run pantheon status for the relay's reason").replace("<you>", cfg.member), `refused: ${r?.code ?? String(client.lastError ?? "unknown").split(/[\s:]/)[0]}`))(refusalOf(client.lastError ?? ""));
|
|
535
539
|
client.close();
|
|
536
540
|
return out;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readFileSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join, resolve, sep } from "node:path";
|
|
3
|
+
import { CONFIG_DIR } from "./config.js";
|
|
4
|
+
import { clearRemoval } from "./removed.js";
|
|
5
|
+
import { pinScope, teamPinId, updatePins } from "./pins.js";
|
|
6
|
+
import { forgetReadinessTeam } from "./readiness-alert.js";
|
|
7
|
+
import { removePantheonWorktrees } from "./machine.js";
|
|
8
|
+
export function forgetTeamTraces(f, m, home = CONFIG_DIR) {
|
|
9
|
+
const removed = [], left = [];
|
|
10
|
+
const others = Object.values(f.spaces ?? {}).filter((x) => x.id !== m.id);
|
|
11
|
+
const member = f.member;
|
|
12
|
+
try {
|
|
13
|
+
if (clearRemoval({ space: m.name, spaceId: m.id.startsWith("legacy:") ? null : m.id, relay: m.relay }, home))
|
|
14
|
+
removed.push("its removal record");
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
left.push(`its record in removed.json (${e.message})`);
|
|
18
|
+
}
|
|
19
|
+
const pinKeys = new Set([m.id, `${m.name}@${m.relay}`].map((t) => pinScope(t, member)));
|
|
20
|
+
for (const o of others)
|
|
21
|
+
for (const t of [o.id, `${o.name}@${o.relay}`, teamPinId({ spaceId: o.id, space: o.name, relay: o.relay })])
|
|
22
|
+
pinKeys.delete(pinScope(t, member));
|
|
23
|
+
try {
|
|
24
|
+
let n = 0;
|
|
25
|
+
updatePins((p) => { for (const k of pinKeys)
|
|
26
|
+
if (p.teams[k]) {
|
|
27
|
+
delete p.teams[k];
|
|
28
|
+
n++;
|
|
29
|
+
} return n > 0; }, home);
|
|
30
|
+
if (n)
|
|
31
|
+
removed.push("its teammates' pinned keys");
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
left.push(`its pinned keys in keys.json (${e.message})`);
|
|
35
|
+
}
|
|
36
|
+
if (!others.some((o) => o.name === m.name)) {
|
|
37
|
+
const file = join(home, "cursors.json");
|
|
38
|
+
try {
|
|
39
|
+
if (existsSync(file)) {
|
|
40
|
+
const all = JSON.parse(readFileSync(file, "utf8"));
|
|
41
|
+
const keep = Object.fromEntries(Object.entries(all).filter(([k]) => !k.startsWith(`${m.name}:`)));
|
|
42
|
+
if (Object.keys(keep).length !== Object.keys(all).length) {
|
|
43
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
44
|
+
writeFileSync(tmp, JSON.stringify(keep, null, 2) + "\n", { mode: 0o600 });
|
|
45
|
+
renameSync(tmp, file);
|
|
46
|
+
removed.push("its agent sessions' read positions");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
left.push(`its read positions in cursors.json (${e.message})`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
if (forgetReadinessTeam(home, [m.id, m.name].filter((k) => !others.some((o) => o.id === k || o.name === k))))
|
|
56
|
+
removed.push("its worker's readiness record");
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
left.push(`its entry in readiness-alert.json (${e.message})`);
|
|
60
|
+
}
|
|
61
|
+
const root = resolve(home, "worktrees");
|
|
62
|
+
const dir = resolve(root, encodeURIComponent(m.id));
|
|
63
|
+
let st = null;
|
|
64
|
+
try {
|
|
65
|
+
st = m.id && dir.startsWith(root + sep) ? lstatSync(dir) : null;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
st = null;
|
|
69
|
+
}
|
|
70
|
+
if (st?.isSymbolicLink()) {
|
|
71
|
+
try {
|
|
72
|
+
unlinkSync(dir);
|
|
73
|
+
removed.push("its worker's scratch link");
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
left.push(`${dir} (${e.message})`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (st?.isDirectory()) {
|
|
80
|
+
const real = (p) => { try {
|
|
81
|
+
return realpathSync(p);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return resolve(p);
|
|
85
|
+
} };
|
|
86
|
+
const realDir = real(dir);
|
|
87
|
+
const inside = (p) => { const r = real(p); return r === realDir || r.startsWith(realDir + sep); };
|
|
88
|
+
const held = Object.values(f.bindings ?? {}).map((b) => b.path).filter((p) => !!p && inside(p));
|
|
89
|
+
if (held.length)
|
|
90
|
+
left.push(`${dir} — a folder you bound is in it (${held.join(", ")}), so it was left as it is`);
|
|
91
|
+
else {
|
|
92
|
+
const repos = Object.values(f.bindings ?? {}).filter((b) => b.space === m.id && b.path).map((b) => b.path);
|
|
93
|
+
try {
|
|
94
|
+
const trees = removePantheonWorktrees(repos, [dir]);
|
|
95
|
+
left.push(...trees.left);
|
|
96
|
+
rmSync(dir, { recursive: true, force: true });
|
|
97
|
+
removed.push("its worker's scratch worktrees");
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
left.push(`${dir} (${e.message})`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { removed, left };
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=forget-team.js.map
|
package/dist/notifier.js
CHANGED
|
@@ -164,7 +164,7 @@ export class HumanNotifier {
|
|
|
164
164
|
return;
|
|
165
165
|
if (!said) {
|
|
166
166
|
said = true;
|
|
167
|
-
const words = removalWords(team, r.by);
|
|
167
|
+
const words = removalWords(team, r.by, r.gone?.kind);
|
|
168
168
|
this.opts.log(`! ${removedLine(words)}`);
|
|
169
169
|
try {
|
|
170
170
|
if (takeTold(team))
|
package/dist/readiness-alert.js
CHANGED
|
@@ -401,6 +401,33 @@ export function readinessAlerts(home) {
|
|
|
401
401
|
}
|
|
402
402
|
return a;
|
|
403
403
|
}
|
|
404
|
+
export function forgetReadinessTeam(home, teams) {
|
|
405
|
+
const f = join(home, READINESS_ALERT_FILE);
|
|
406
|
+
if (!teams.length || readStateFile(f) === null)
|
|
407
|
+
return false;
|
|
408
|
+
const ours = (k) => teams.some((t) => k === t || k.startsWith(`${t}#`));
|
|
409
|
+
return withFileLock(f, () => {
|
|
410
|
+
const now = Date.now();
|
|
411
|
+
const s = parseState(readStateFile(f), now);
|
|
412
|
+
const drop = Object.keys(s.teams).filter(ours);
|
|
413
|
+
const told = s.told?.teams.some(ours);
|
|
414
|
+
if (!drop.length && !told)
|
|
415
|
+
return false;
|
|
416
|
+
for (const k of drop)
|
|
417
|
+
delete s.teams[k];
|
|
418
|
+
if (s.told && told) {
|
|
419
|
+
const rest = s.told.teams.filter((k) => !ours(k));
|
|
420
|
+
if (rest.length)
|
|
421
|
+
s.told = { ...s.told, teams: rest };
|
|
422
|
+
else
|
|
423
|
+
delete s.told;
|
|
424
|
+
}
|
|
425
|
+
writeWhole(f, JSON.stringify(s) + "\n");
|
|
426
|
+
trustWrite(f);
|
|
427
|
+
byHome.delete(f);
|
|
428
|
+
return true;
|
|
429
|
+
}, 2_000);
|
|
430
|
+
}
|
|
404
431
|
export function forgetReadinessAlerts() { byHome.clear(); }
|
|
405
432
|
export function agentProblem(home, now = Date.now(), os = platform()) {
|
|
406
433
|
let text = null;
|
package/dist/reads.js
CHANGED
|
@@ -29,9 +29,16 @@ export function signedReadQuery(cfg, path, params, at) {
|
|
|
29
29
|
export async function signedRead(cfg, path, params = {}, opts = {}) {
|
|
30
30
|
const signal = opts.signal ?? (opts.timeoutMs ? AbortSignal.timeout(opts.timeoutMs) : undefined);
|
|
31
31
|
const go = () => fetch(`${httpBase(cfg.relay)}${path}?${signedReadQuery(cfg, path, params, Date.now() + clockSkewMs)}`, signal ? { signal } : {});
|
|
32
|
-
|
|
32
|
+
let res = await go();
|
|
33
33
|
if (res.status === 403 && learnRelayClock(res))
|
|
34
|
-
|
|
34
|
+
res = await go();
|
|
35
|
+
if (res.ok && !cfg.delegate) {
|
|
36
|
+
try {
|
|
37
|
+
const { clearRemoval } = await import("./removed.js");
|
|
38
|
+
clearRemoval({ space: cfg.space, spaceId: cfg.spaceId ?? null, relay: cfg.relay });
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
}
|
|
35
42
|
return res;
|
|
36
43
|
}
|
|
37
44
|
//# sourceMappingURL=reads.js.map
|