@join-pantheon/cli 0.36.0-rc.1 → 0.37.0-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/README.md +21 -35
- package/dist/accounts.js +90 -0
- package/dist/agent-check.js +115 -0
- package/dist/agents.js +1 -0
- package/dist/cli.js +294 -58
- package/dist/email-templates.js +18 -8
- package/dist/email.js +11 -10
- package/dist/finish-line.js +1 -1
- package/dist/flag-signin.js +305 -0
- package/dist/home-safety.js +2 -0
- package/dist/identity.js +19 -0
- package/dist/invites-sent.js +65 -0
- package/dist/managed.js +11 -26
- package/dist/mcp.js +21 -4
- package/dist/notice.js +15 -0
- package/dist/notifier.js +45 -1
- package/dist/onboard-copy.js +217 -0
- package/dist/profile.js +3 -1
- package/dist/protocol.js +10 -0
- package/dist/quickstart.js +4 -2
- package/dist/relay.js +195 -10
- package/dist/roster-file.js +1 -0
- package/dist/setup-guide.js +41 -7
- package/helper/macos/prebuilt/manifest.json +1 -1
- package/installer/install.ps1 +5 -2
- package/installer/install.sh +6 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
package/dist/relay.js
CHANGED
|
@@ -9,8 +9,9 @@ import { badRemote, Inbound, isCatchAllDomain, isContinuationFor, LIMITS, newId,
|
|
|
9
9
|
import { VERSION } from "./version.js";
|
|
10
10
|
import { compareVersions, INSTALLER_MIN_CLI, isVersion, installerScript, InstallerGate } from "./installer.js";
|
|
11
11
|
import { installerLine } from "./managed.js";
|
|
12
|
+
import { joinMd, onboardJson, onboardMd } from "./onboard-copy.js";
|
|
12
13
|
import { Ledger, SpaceFull } from "./ledger.js";
|
|
13
|
-
import { fingerprint, newNonce, verifyChallenge, verifyActivity, verifyAccount, verifyRead, actPayload, goalPayload, verifyBytes, verifyDelegate, canonicalJson } from "./identity.js";
|
|
14
|
+
import { fingerprint, newNonce, verifyChallenge, verifyActivity, verifyAccount, verifyRead, verifyStatus, canonicalKey, actPayload, goalPayload, verifyBytes, verifyDelegate, canonicalJson } from "./identity.js";
|
|
14
15
|
import { ADMIN_SESSION_MS, Accounts, normalizeEmail, normalizeUsername, validEmail, validUsername, VIEWER_DEFAULT_DAYS, VIEWER_MAX_DAYS, VIEWER_SESSION_MAX_MS } from "./accounts.js";
|
|
15
16
|
import { renderViewerBusy, renderViewerUnreadable, renderViewerEnded, renderViewerGoal, renderViewerHome, renderViewerNeedsHttps, renderViewerSignin, renderViewerTeam } from "./viewer-pages.js";
|
|
16
17
|
import { emailSenderFromEnv, maskEmail } from "./email.js";
|
|
@@ -28,7 +29,7 @@ import { newNonce as newUiNonce, pageHeaders, rangeOf } from "./admin-ui.js";
|
|
|
28
29
|
import { renderAdminLogin, renderAudit, renderGoal, renderOverview, renderPeople, renderPlans, renderSecurity, renderTeam, renderTeamUnreadable } from "./admin-pages.js";
|
|
29
30
|
import { fmtLimit, inviteLimit, parseLimits, planLimits, PLAN_NAME } from "./plans.js";
|
|
30
31
|
import { FEEDBACK_ADDRESS } from "./feedback.js";
|
|
31
|
-
import { relayShellArg, teamNameProblem } from "./team-name.js";
|
|
32
|
+
import { RELAY_TEAM_NAME, relayShellArg, teamNameProblem } from "./team-name.js";
|
|
32
33
|
import { reservedBy, routeDecision } from "./profile.js";
|
|
33
34
|
import { ANSWER_OPTIONS_SCAN, answerOptions, clipClause, DECISION_ASKS, decisionDue, decisionQuestion, namedMarker } from "./decision-ui.js";
|
|
34
35
|
import { ByteLru } from "./byte-lru.js";
|
|
@@ -637,7 +638,7 @@ export class Relay {
|
|
|
637
638
|
}
|
|
638
639
|
const bad = e instanceof TypeError || e instanceof URIError;
|
|
639
640
|
if (!bad)
|
|
640
|
-
this.log(`! http ${req.method} ${String(req.url ?? "").slice(0, 120)} failed: ${e?.message ?? e}`);
|
|
641
|
+
this.log(`! http ${req.method} ${String(req.url ?? "").replace(/([?&]t=)[^&]*/g, "$1…").slice(0, 120)} failed: ${e?.message ?? e}`);
|
|
641
642
|
if (isStorageError(e))
|
|
642
643
|
this.noteStorageFailure(`http ${String(req.url ?? "").split("?")[0].slice(0, 60)}`, e);
|
|
643
644
|
try {
|
|
@@ -953,6 +954,12 @@ export class Relay {
|
|
|
953
954
|
void this.serveInstaller(req, res, url.pathname.slice(1));
|
|
954
955
|
return;
|
|
955
956
|
}
|
|
957
|
+
if (url.pathname === "/onboard.json" || url.pathname === "/skills/join.md" || url.pathname === "/skills/onboard.md") {
|
|
958
|
+
if (req.method !== "GET" && req.method !== "HEAD")
|
|
959
|
+
return this.json(res, 405, { error: "GET only" });
|
|
960
|
+
void this.serveCopy(req, res, url.pathname);
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
956
963
|
if (url.pathname === "/join") {
|
|
957
964
|
if (!this.authRateOk(ip))
|
|
958
965
|
return this.json(res, 429, { error: "too many lookups from your network — wait a minute" });
|
|
@@ -1270,10 +1277,15 @@ export class Relay {
|
|
|
1270
1277
|
return this.json(res, 409, { error: msg, reason: started.reason });
|
|
1271
1278
|
}
|
|
1272
1279
|
A.audit({ event: "signup", target: normalizeUsername(b.username), ip });
|
|
1273
|
-
const
|
|
1280
|
+
const linked = b.link === true ? this.linkFor(b.email, b.pubkey, String(b.label ?? "a device"), ip) : null;
|
|
1281
|
+
if (typeof b.joining === "string")
|
|
1282
|
+
this.noteJoining(b.email, b.joining);
|
|
1283
|
+
else
|
|
1284
|
+
this.noteJoining(b.email, null);
|
|
1285
|
+
const sent = await this.email.sendCode(b.email, started.code, "signup", linked?.url);
|
|
1274
1286
|
if (sent)
|
|
1275
1287
|
this.noteEmailSent("signup", b.email, ip);
|
|
1276
|
-
return this.json(res, 200, { ok: true, sent, via: this.email.kind });
|
|
1288
|
+
return this.json(res, 200, { ok: true, sent, via: this.email.kind, ...(linked ? { link: true, words: linked.words, status_aud: linked.aud } : {}) });
|
|
1277
1289
|
});
|
|
1278
1290
|
}
|
|
1279
1291
|
if (url.pathname === "/auth/login" && req.method === "POST") {
|
|
@@ -1296,10 +1308,11 @@ export class Relay {
|
|
|
1296
1308
|
const msg = started.reason === "too_soon" ? "a code was just sent — check your email, or wait a minute" : started.reason === "locked" ? LOCKED_MSG : "no active account for that email — `pantheon signup` first";
|
|
1297
1309
|
return this.json(res, code, { error: msg, reason: started.reason });
|
|
1298
1310
|
}
|
|
1299
|
-
const
|
|
1311
|
+
const linked = b.link === true ? this.linkFor(b.email, b.pubkey, String(b.label ?? "a device"), ip) : null;
|
|
1312
|
+
const sent = await this.email.sendCode(b.email, started.code, "login", linked?.url);
|
|
1300
1313
|
if (sent)
|
|
1301
1314
|
this.noteEmailSent("login", b.email, ip, b.pubkey, own);
|
|
1302
|
-
return this.json(res, 200, { ok: true, sent, via: this.email.kind });
|
|
1315
|
+
return this.json(res, 200, { ok: true, sent, via: this.email.kind, ...(linked ? { link: true, words: linked.words, status_aud: linked.aud } : {}) });
|
|
1303
1316
|
});
|
|
1304
1317
|
}
|
|
1305
1318
|
if (url.pathname === "/auth/verify" && req.method === "POST") {
|
|
@@ -1324,10 +1337,52 @@ export class Relay {
|
|
|
1324
1337
|
}
|
|
1325
1338
|
this.json(res, 200, { ok: true, account: { id: r.account.id, username: r.account.username, email: r.account.email }, session: r.session.id, device: r.device.id });
|
|
1326
1339
|
if (r.welcome)
|
|
1327
|
-
this.sendWelcome(r.account.email, ip);
|
|
1340
|
+
this.sendWelcome(r.account.email, ip, this.takeJoining(r.account.email));
|
|
1328
1341
|
return;
|
|
1329
1342
|
});
|
|
1330
1343
|
}
|
|
1344
|
+
if (url.pathname === "/auth/confirm" && (req.method === "GET" || req.method === "POST")) {
|
|
1345
|
+
if (req.method === "GET")
|
|
1346
|
+
return this.confirmPage(res, url.searchParams.get("t") ?? "");
|
|
1347
|
+
if (!this.authRateOk(ip))
|
|
1348
|
+
return this.confirmPage(res, "", { said: "Too many tries from your network. Wait a minute, or use the 6-digit code from the email." });
|
|
1349
|
+
return this.readForm(req, res, (f) => {
|
|
1350
|
+
const t = String(f.t ?? "");
|
|
1351
|
+
const r = A.confirmLink(t, String(f.words ?? ""), ip);
|
|
1352
|
+
if (r.ok) {
|
|
1353
|
+
const acct = r.account;
|
|
1354
|
+
this.confirmPage(res, "", { done: true });
|
|
1355
|
+
if (r.welcome)
|
|
1356
|
+
this.sendWelcome(acct.email, ip, this.takeJoining(acct.email));
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
const why = r.reason;
|
|
1360
|
+
if (why === "empty")
|
|
1361
|
+
return this.confirmPage(res, t, { said: "Type the two words your screen or your coding agent shows." });
|
|
1362
|
+
return this.confirmPage(res, "", { said: why === "wrong_words" ? "Those words do not match, so this link no longer works. The 6-digit code in the email still does."
|
|
1363
|
+
: why === "links_locked" ? "Too many wrong words for this address in the last hour, so links are off for now. Use the 6-digit code from the email."
|
|
1364
|
+
: why === "device_other_account" ? DEVICE_OTHER_ACCOUNT
|
|
1365
|
+
: "This link has expired or was already used. Use the 6-digit code from the email, or ask for a new one." });
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
if (url.pathname === "/auth/status" && req.method === "GET") {
|
|
1369
|
+
const key = String(req.headers["x-pantheon-key"] ?? ""), nonce = String(req.headers["x-pantheon-nonce"] ?? "");
|
|
1370
|
+
const ts = Number(req.headers["x-pantheon-ts"] ?? NaN), sig = String(req.headers["x-pantheon-sig"] ?? "");
|
|
1371
|
+
if (!key || key.length > 200 || !canonicalKey(key) || !/^[A-Za-z0-9_-]{16,64}$/.test(nonce) || !Number.isFinite(ts) || Math.abs(Date.now() - ts) > 120_000)
|
|
1372
|
+
return this.json(res, 400, { error: "a signed status request needs x-pantheon-key, -ts (within 2 minutes), -nonce and -sig" });
|
|
1373
|
+
if (!this.localTrusted(ip) && !this.hitsOk(this.statusIpHits, ip, 120))
|
|
1374
|
+
return this.json(res, 429, { error: "too many requests from your network — wait a minute" });
|
|
1375
|
+
if (!verifyStatus(key, ts, nonce, sig, this.statusAudience(req)))
|
|
1376
|
+
return this.json(res, 403, { error: "this request must be signed by the device that is signing in, for this relay" });
|
|
1377
|
+
if (!this.statusBudgetOk(key))
|
|
1378
|
+
return this.json(res, 429, { error: "asking too often — once every few seconds is enough" });
|
|
1379
|
+
if (!this.freshNonce(nonce))
|
|
1380
|
+
return this.json(res, 403, { error: "that request was already answered" });
|
|
1381
|
+
const acct = A.signedInDevice(key);
|
|
1382
|
+
if (acct)
|
|
1383
|
+
return this.json(res, 200, { state: "confirmed", account: { username: acct.username, email: acct.email } });
|
|
1384
|
+
return this.json(res, 200, { state: A.pendingFor(key) ? "pending" : "none" });
|
|
1385
|
+
}
|
|
1331
1386
|
if (url.pathname === "/account/sessions" && req.method === "GET") {
|
|
1332
1387
|
const who = this.verifySignedAccount(url, "GET", "/account/sessions", ip);
|
|
1333
1388
|
if (!who)
|
|
@@ -1511,7 +1566,96 @@ export class Relay {
|
|
|
1511
1566
|
if (kind !== "welcome" && !own && !this.localTrusted(ip))
|
|
1512
1567
|
bump(this.emailSendsFrom, netOf(ip));
|
|
1513
1568
|
}
|
|
1514
|
-
|
|
1569
|
+
linkFor(email, pubkey, label, ip) {
|
|
1570
|
+
const pub = publicBase(null);
|
|
1571
|
+
if (!pub || !this.accounts)
|
|
1572
|
+
return null;
|
|
1573
|
+
const l = this.accounts.startLink(email, pubkey, { label, ip });
|
|
1574
|
+
return l ? { url: `${pub}/auth/confirm?t=${encodeURIComponent(l.token)}`, words: l.words, aud: new URL(pub).host } : null;
|
|
1575
|
+
}
|
|
1576
|
+
statusAudience(req) {
|
|
1577
|
+
const pub = publicBase(null);
|
|
1578
|
+
try {
|
|
1579
|
+
if (pub)
|
|
1580
|
+
return new URL(pub).host;
|
|
1581
|
+
}
|
|
1582
|
+
catch { }
|
|
1583
|
+
return String(req.headers.host ?? "");
|
|
1584
|
+
}
|
|
1585
|
+
statusHits = new Map();
|
|
1586
|
+
statusIpHits = new Map();
|
|
1587
|
+
hitsOk(map, key, limit) {
|
|
1588
|
+
const t = Date.now();
|
|
1589
|
+
const recent = (map.get(key) ?? []).filter((x) => t - x < 60_000);
|
|
1590
|
+
recent.push(t);
|
|
1591
|
+
map.set(key, recent);
|
|
1592
|
+
if (map.size > 10_000)
|
|
1593
|
+
for (const [k, v] of map)
|
|
1594
|
+
if (!v.some((x) => t - x < 60_000))
|
|
1595
|
+
map.delete(k);
|
|
1596
|
+
return recent.length <= limit;
|
|
1597
|
+
}
|
|
1598
|
+
statusBudgetOk(key) { return this.hitsOk(this.statusHits, key, 40); }
|
|
1599
|
+
statusNonces = new Map();
|
|
1600
|
+
freshNonce(nonce) {
|
|
1601
|
+
const t = Date.now();
|
|
1602
|
+
if (this.statusNonces.has(nonce))
|
|
1603
|
+
return false;
|
|
1604
|
+
this.statusNonces.set(nonce, t);
|
|
1605
|
+
if (this.statusNonces.size > 20_000)
|
|
1606
|
+
for (const [k, v] of this.statusNonces)
|
|
1607
|
+
if (t - v > 300_000)
|
|
1608
|
+
this.statusNonces.delete(k);
|
|
1609
|
+
return true;
|
|
1610
|
+
}
|
|
1611
|
+
confirmPage(res, token, o = {}) {
|
|
1612
|
+
const A = this.accounts;
|
|
1613
|
+
const info = token ? A.linkInfo(token) : null;
|
|
1614
|
+
const esc = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1615
|
+
const mask = (ip) => ip.replace(/^(\d+\.\d+)\.\d+\.\d+$/, "$1.x.x").replace(/^([0-9a-f]+:[0-9a-f]+):.*$/i, "$1:…");
|
|
1616
|
+
const body = o.done
|
|
1617
|
+
? `<h1>Done.</h1><p>This computer is signed in to Pantheon. Go back to your terminal or your coding agent: it carries on by itself, or runs the command it showed you.</p>`
|
|
1618
|
+
: info
|
|
1619
|
+
? `<h1>Sign in this computer?</h1>
|
|
1620
|
+
<p>A computer asked to sign in to Pantheon as <b>${esc(info.email)}</b>.</p>
|
|
1621
|
+
<p>It calls itself <b>${esc(info.label)}</b> (named by that computer itself). It asked from network ${esc(mask(info.ip))} at ${esc(new Date(info.created_at).toUTCString())}.</p>
|
|
1622
|
+
<p>Only go on if you started this yourself, just now, on your own computer or through your own coding agent.</p>
|
|
1623
|
+
${o.said ? `<p class="said">${esc(o.said)}</p>` : ""}
|
|
1624
|
+
<form method="post" action="/auth/confirm"><input type="hidden" name="t" value="${esc(token)}">
|
|
1625
|
+
<label for="w">The two words your screen or your coding agent shows</label>
|
|
1626
|
+
<input id="w" name="words" autocomplete="off" autocapitalize="off" spellcheck="false" placeholder="two words">
|
|
1627
|
+
<button type="submit">Confirm</button></form>`
|
|
1628
|
+
: `<h1>This link does not work.</h1><p>${esc(o.said ?? "It has expired or was already used. Use the 6-digit code from the email, or ask for a new one.")}</p>`;
|
|
1629
|
+
const html = `<!doctype html><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=referrer content=no-referrer><title>Pantheon sign-in</title>
|
|
1630
|
+
<style>body{font:16px/1.6 "Space Mono",Menlo,Consolas,monospace;background:#ece0c8;color:#1b1917;max-width:34rem;margin:10vh auto;padding:0 16px}h1{font:400 28px/1.15 "Archivo Black","Arial Black",Arial,sans-serif}label{display:block;margin:18px 0 6px}input{font:inherit;width:100%;box-sizing:border-box;padding:10px;border:2px solid #1b1917;border-radius:8px;background:#f1e7d3}button{margin-top:12px;font:inherit;font-weight:700;background:#e36f55;color:#1b1917;border:0;border-radius:8px;padding:10px 18px}.said{background:#f1e7d3;border-left:4px solid #b8492f;padding:8px 12px}</style>
|
|
1631
|
+
${body}`;
|
|
1632
|
+
res.writeHead(200, {
|
|
1633
|
+
"content-type": "text/html; charset=utf-8", "cache-control": "no-store", "referrer-policy": "no-referrer",
|
|
1634
|
+
"x-frame-options": "DENY", "x-content-type-options": "nosniff",
|
|
1635
|
+
"content-security-policy": "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'",
|
|
1636
|
+
});
|
|
1637
|
+
res.end(html);
|
|
1638
|
+
}
|
|
1639
|
+
joiningByEmail = new Map();
|
|
1640
|
+
noteJoining(email, team) {
|
|
1641
|
+
const k = normalizeEmail(email);
|
|
1642
|
+
if (team === null) {
|
|
1643
|
+
this.joiningByEmail.delete(k);
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
if (!RELAY_TEAM_NAME.test(team))
|
|
1647
|
+
team = "";
|
|
1648
|
+
if (this.joiningByEmail.size >= 10_000)
|
|
1649
|
+
this.joiningByEmail.delete(this.joiningByEmail.keys().next().value);
|
|
1650
|
+
this.joiningByEmail.set(k, { team, at: Date.now() });
|
|
1651
|
+
}
|
|
1652
|
+
takeJoining(email) {
|
|
1653
|
+
const k = normalizeEmail(email);
|
|
1654
|
+
const j = this.joiningByEmail.get(k);
|
|
1655
|
+
this.joiningByEmail.delete(k);
|
|
1656
|
+
return j && Date.now() - j.at < 30 * 60_000 ? j.team : undefined;
|
|
1657
|
+
}
|
|
1658
|
+
sendWelcome(to, ip, joining) {
|
|
1515
1659
|
if (!this.email.sendWelcome)
|
|
1516
1660
|
return;
|
|
1517
1661
|
if (this.emailRefusal("welcome", to, ip)) {
|
|
@@ -1520,7 +1664,7 @@ export class Relay {
|
|
|
1520
1664
|
}
|
|
1521
1665
|
let sending;
|
|
1522
1666
|
try {
|
|
1523
|
-
sending = Promise.resolve(this.email.sendWelcome(to));
|
|
1667
|
+
sending = Promise.resolve(joining !== undefined ? this.email.sendWelcome(to, joining) : this.email.sendWelcome(to));
|
|
1524
1668
|
}
|
|
1525
1669
|
catch {
|
|
1526
1670
|
return;
|
|
@@ -4244,6 +4388,40 @@ export class Relay {
|
|
|
4244
4388
|
}
|
|
4245
4389
|
catch { } });
|
|
4246
4390
|
}
|
|
4391
|
+
async serveCopy(req, res, path) {
|
|
4392
|
+
try {
|
|
4393
|
+
const host = String(req.headers.host ?? "").replace(/[^A-Za-z0-9.:\[\]-]/g, "");
|
|
4394
|
+
const proto = forwardedProto(req) === "https" ? "https" : "http";
|
|
4395
|
+
const relay = publicBase(null) ?? (host ? `${proto}://${host}` : null);
|
|
4396
|
+
const choice = await this.installerGate.choose();
|
|
4397
|
+
if (res.writableEnded || res.destroyed)
|
|
4398
|
+
return;
|
|
4399
|
+
const served = !("unavailable" in choice) && installerScript("install.sh", undefined, choice.version) !== null;
|
|
4400
|
+
const o = served ? { relay, installs: choice.version } : { relay, installs: null, serves: false };
|
|
4401
|
+
const [type, body] = path === "/onboard.json"
|
|
4402
|
+
? ["application/json", JSON.stringify(onboardJson({ ...o, version: VERSION }))]
|
|
4403
|
+
: ["text/markdown; charset=utf-8", path === "/skills/join.md" ? joinMd(o) : onboardMd(o)];
|
|
4404
|
+
res.writeHead(200, {
|
|
4405
|
+
"content-type": type,
|
|
4406
|
+
"content-length": Buffer.byteLength(body),
|
|
4407
|
+
"cache-control": publicBase(null) ? "public, max-age=300" : "no-store",
|
|
4408
|
+
vary: "Host, X-Forwarded-Proto",
|
|
4409
|
+
"access-control-allow-origin": "*",
|
|
4410
|
+
"x-content-type-options": "nosniff",
|
|
4411
|
+
});
|
|
4412
|
+
res.end(req.method === "HEAD" ? undefined : body);
|
|
4413
|
+
}
|
|
4414
|
+
catch (e) {
|
|
4415
|
+
this.log(`! ${path} failed: ${e?.message ?? e}`);
|
|
4416
|
+
try {
|
|
4417
|
+
if (!res.headersSent)
|
|
4418
|
+
this.json(res, 500, { error: "the relay could not handle that request" });
|
|
4419
|
+
else
|
|
4420
|
+
res.end();
|
|
4421
|
+
}
|
|
4422
|
+
catch { }
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4247
4425
|
landingPage(req, res) {
|
|
4248
4426
|
const host = String(req.headers.host ?? "").replace(/[^A-Za-z0-9.:\[\]-]/g, "");
|
|
4249
4427
|
const proto = String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim() === "https" ? "https" : "http";
|
|
@@ -4607,6 +4785,7 @@ pantheon start</code></pre>
|
|
|
4607
4785
|
}
|
|
4608
4786
|
enrolled = this.ensureToken(sp);
|
|
4609
4787
|
this.log(`[${sp.name}] * ENROLLED ${m.member} via invite from ${r.entry.admitted_by}${r.entry.may_wake ? " (may wake)" : ""}`);
|
|
4788
|
+
this.broadcast(sp, { t: "members", members: this.members(sp) });
|
|
4610
4789
|
}
|
|
4611
4790
|
if (staleToken && !enrolled) {
|
|
4612
4791
|
const e = sp.allow.get(m.member);
|
|
@@ -4787,6 +4966,10 @@ pantheon start</code></pre>
|
|
|
4787
4966
|
m.profile = { ...m.profile, authority: Object.fromEntries(Object.entries(m.profile.authority).filter(([k]) => !isCatchAllDomain(k))) };
|
|
4788
4967
|
this.log(`[${space.name}] ~ ${me.id}'s profile: dropped ${vague.map((k) => JSON.stringify(k)).join(", ")} — not a decision area`);
|
|
4789
4968
|
}
|
|
4969
|
+
if (m.profile.team_setup && (me.id !== space.allow.founder() || ![space.allow.spaceId(), space.name].includes(m.profile.team_setup.team))) {
|
|
4970
|
+
const { team_setup: _drop, ...rest } = m.profile;
|
|
4971
|
+
m.profile = rest;
|
|
4972
|
+
}
|
|
4790
4973
|
const current = space.profiles.get(me.id);
|
|
4791
4974
|
if (!current || m.profile.updated_at > current.updated_at) {
|
|
4792
4975
|
space.profiles.set(me.id, m.profile);
|
|
@@ -6551,6 +6734,8 @@ pantheon start</code></pre>
|
|
|
6551
6734
|
member: e.member, admitted: e.admitted, may_wake: e.may_wake,
|
|
6552
6735
|
fingerprint: fingerprint(e.publicKey), pubkey: e.publicKey,
|
|
6553
6736
|
...(e.admitted_by ? { admitted_by: e.admitted_by } : {}),
|
|
6737
|
+
...(e.invite_fp ? { invite_fp: e.invite_fp } : {}),
|
|
6738
|
+
...(e.joined_at ? { joined_at: e.joined_at } : {}),
|
|
6554
6739
|
...(e.revoked_at ? { revoked_at: e.revoked_at, ...(e.revoked_by ? { revoked_by: e.revoked_by } : {}) } : {}),
|
|
6555
6740
|
...(sp.allow.founder() === e.member ? { founder: true } : {}),
|
|
6556
6741
|
...((r) => r ? { recovery: { fp: r.fp, label: r.label, requested_at: r.requested_at, due_at: r.due_at } } : {})(sp.allow.recoveryOf(e.member)),
|
package/dist/roster-file.js
CHANGED
|
@@ -296,6 +296,7 @@ export class Allowlist {
|
|
|
296
296
|
const entry = {
|
|
297
297
|
member, publicKey, admitted: true, admitted_by: this.founderName === member ? member : inv.created_by,
|
|
298
298
|
first_seen: existing?.first_seen ?? Date.now(), may_wake: inv.may_wake,
|
|
299
|
+
invite_fp: hashToken(token).slice(0, 16), joined_at: Date.now(),
|
|
299
300
|
};
|
|
300
301
|
this.entries.set(member, entry);
|
|
301
302
|
inv.used_by = member;
|
package/dist/setup-guide.js
CHANGED
|
@@ -3,7 +3,7 @@ import { approvalSummary, installForUser } from "./install.js";
|
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { applyProfileInit, dropCatchAllClaims, loadProfile, profilePath, saveProfile, spaceOverride, teamProfile, wakeMode } from "./profile.js";
|
|
6
|
+
import { applyProfileInit, dropCatchAllClaims, loadProfile, profilePath, saveProfile, setupChosen, spaceOverride, teamProfile, wakeMode } from "./profile.js";
|
|
7
7
|
import { isCatchAllDomain } from "./protocol.js";
|
|
8
8
|
import { installService as realInstall, uninstallService as realUninstall, serviceInstalled as realInstalled, installedServiceArgs, keepServiceFlags } from "./service.js";
|
|
9
9
|
import { unsandboxedRisk } from "./setup-changes.js";
|
|
@@ -52,7 +52,8 @@ export function guideDefaults(profile, cfg) {
|
|
|
52
52
|
wake: wakeMode(profile),
|
|
53
53
|
commands: profile.agent.allow_bash ?? false,
|
|
54
54
|
approval: profile.agent.approval ?? "approve",
|
|
55
|
-
name: profile.human.display_name
|
|
55
|
+
name: (profile.human.display_name && !(profile.human.display_name === cfg.member && !setupChosen(profile)) ? profile.human.display_name : "")
|
|
56
|
+
|| cfg.display || gitUserName() || cfg.member,
|
|
56
57
|
title: profile.human.title || "",
|
|
57
58
|
decides: Object.entries(teamProfile(profile, cfg.spaceId, cfg.space).authority).filter(([, m]) => m === "human_required").map(([d]) => d),
|
|
58
59
|
notifications: !n.decisions ? "none" : n.worker_done ? "worker" : n.deliveries ? "deliveries" : "decisions",
|
|
@@ -326,7 +327,20 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
326
327
|
if (io && ctx.summary && !ctx.founder) {
|
|
327
328
|
const nowMode = preset.mode ?? effectiveMode(loadPolicy(deps.policyHome));
|
|
328
329
|
const base = preset.base;
|
|
329
|
-
const
|
|
330
|
+
const sug = ctx.suggested && !setupChosen(profile) ? ctx.suggested : null;
|
|
331
|
+
const s = {
|
|
332
|
+
...a, title: d.title || "Member", mode: nowMode,
|
|
333
|
+
...(sug ? {
|
|
334
|
+
mode: preset.mode ?? sug.mode,
|
|
335
|
+
wake: preset.wake ?? sug.wake,
|
|
336
|
+
commands: preset.commands ?? (sug.wake === "no" ? false : sug.commands),
|
|
337
|
+
notifications: preset.notifications ?? sug.notifications,
|
|
338
|
+
} : {}),
|
|
339
|
+
};
|
|
340
|
+
if (sug)
|
|
341
|
+
io.say(`Your team's suggested setup, from ${sug.by.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").slice(0, 60)} — Enter takes it, c changes it:`);
|
|
342
|
+
else if (ctx.suggested)
|
|
343
|
+
io.say("This machine is set up already, so your setup stays as it is.");
|
|
330
344
|
if (s.wake !== "no" && ctx.project)
|
|
331
345
|
s.persona = preset.persona ?? (setUp ? playbookExists : true);
|
|
332
346
|
for (const l of teammateSummary(s, { serves, project: !!ctx.project, base, awayAgents: awayAgents.length && s.wake !== "no" && serves?.repos && unsandboxedAllowed(loadPolicy(deps.policyHome)) ? awayAgents : [] }))
|
|
@@ -353,10 +367,19 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
353
367
|
}
|
|
354
368
|
if (io && !summaryKept) {
|
|
355
369
|
io.say("A few questions, then one screen of defaults. Enter keeps the suggested answer.\n");
|
|
356
|
-
a.name = (await io.ask("Your name, as teammates will see it", d.name)).trim() || d.name;
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
370
|
+
const askName = async () => { a.name = (await io.ask("Your name, as teammates will see it", a.name || d.name)).trim() || a.name || d.name; };
|
|
371
|
+
const askRole = async () => {
|
|
372
|
+
const cur = a.title || d.title;
|
|
373
|
+
const known = TITLE_OPTIONS.findIndex((t) => t.toLowerCase() === cur.toLowerCase());
|
|
374
|
+
const t = await io.choose("Your role, in a word — it goes on the team directory", TITLE_OPTIONS, known >= 0 ? known : cur || !ctx.founder ? TITLE_OPTIONS.length - 1 : 0);
|
|
375
|
+
a.title = t === TITLE_OPTIONS.length - 1 ? (await io.ask("Your role", cur)).trim() || cur || "Member" : TITLE_OPTIONS[t];
|
|
376
|
+
};
|
|
377
|
+
const quickName = !!ctx.founder && !setUp;
|
|
378
|
+
if (quickName)
|
|
379
|
+
a.name = d.name;
|
|
380
|
+
else
|
|
381
|
+
await askName();
|
|
382
|
+
await askRole();
|
|
360
383
|
const nowMode = preset.mode ?? effectiveMode(loadPolicy(deps.policyHome));
|
|
361
384
|
const m = await io.choose("Who finishes teammates' requests?", MODE_OPTIONS.map((o) => o.label), Math.max(0, MODE_OPTIONS.findIndex((o) => o.id === nowMode)));
|
|
362
385
|
a.mode = MODE_OPTIONS[m].id;
|
|
@@ -372,6 +395,8 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
372
395
|
a.persona = preset.persona ?? (setUp ? playbookExists : true);
|
|
373
396
|
const shortAlert = (id) => ALERT_OPTIONS.find((o) => o.id === id).label.split(" — ")[0].replace(/ \(recommended\)/, "");
|
|
374
397
|
io.say("\nThe rest has defaults. Change them now, or any time with `pantheon setup`:");
|
|
398
|
+
if (quickName)
|
|
399
|
+
io.say(` • Your name: ${a.name} — as teammates see you`);
|
|
375
400
|
io.say(` • Wake: ${a.wake === "no" ? "off — this machine only works while you are at it"
|
|
376
401
|
: serves && !serves.repos ? (a.wake === "anyone"
|
|
377
402
|
? "teammates can ask your worker about this folder while you're away — it reads it, never changes it"
|
|
@@ -408,6 +433,8 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
408
433
|
a.base = suggestedBase;
|
|
409
434
|
}
|
|
410
435
|
else {
|
|
436
|
+
if (quickName)
|
|
437
|
+
await askName();
|
|
411
438
|
const wakeIdx = await io.choose("While you're away, may teammates hand work to this machine? Your agent would run here on its own, in a separate copy of the repo, and deliver on a branch for review.", WAKE_OPTIONS.map((o) => o.label), Math.max(0, WAKE_OPTIONS.findIndex((o) => o.id === a.wake)));
|
|
412
439
|
a.wake = WAKE_OPTIONS[wakeIdx].id;
|
|
413
440
|
if (a.wake === "no") {
|
|
@@ -476,6 +503,13 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
476
503
|
},
|
|
477
504
|
updated_at: Date.now(),
|
|
478
505
|
};
|
|
506
|
+
const suggestKey = [ctx.cfg.spaceId, ctx.cfg.space].find((k) => k && next.spaces?.[k]) ?? ctx.cfg.spaceId ?? ctx.cfg.space;
|
|
507
|
+
const suggestedBefore = !!(suggestKey && spaceOverride(next, ctx.cfg.spaceId, ctx.cfg.space)?.team_setup);
|
|
508
|
+
if ((ctx.founder || suggestedBefore) && io && deps.teamSetup && suggestKey) {
|
|
509
|
+
const ts = deps.teamSetup(a);
|
|
510
|
+
if (ts)
|
|
511
|
+
next = { ...next, spaces: { ...next.spaces, [suggestKey]: { ...(next.spaces?.[suggestKey] ?? {}), team_setup: ts } } };
|
|
512
|
+
}
|
|
479
513
|
saveProfile(next, file);
|
|
480
514
|
applied.push(`profile: ${next.human.display_name}${next.human.title ? `, ${next.human.title}` : ""}${a.decides.length ? ` — you personally decide ${a.decides.join(", ")}` : " — no decisions reserved for you; your agent may decide"}`);
|
|
481
515
|
if (deps.publish) {
|
package/installer/install.ps1
CHANGED
|
@@ -710,7 +710,10 @@ function Install-Pantheon {
|
|
|
710
710
|
$said = if (Test-Path -LiteralPath $errFile) { [IO.File]::ReadAllText($errFile) } else { '' }
|
|
711
711
|
if ($said) { [Console]::Error.Write($said) }
|
|
712
712
|
# 10: pantheon after 0.35.3 says "sign in first" by its exit code; older ones only in words.
|
|
713
|
-
|
|
713
|
+
# Signing in by flags (--email, then --code: 0.37.0) ends on pantheon's own next
|
|
714
|
+
# step, which is then the last line: a second, different one here would contradict it.
|
|
715
|
+
$byFlags = [bool]($Arguments | Where-Object { $_ -match '^--(email|code)(=|$)|^--continue$' })
|
|
716
|
+
if ((-not $byFlags) -and ($State.code -eq 10 -or ($State.code -ne 0 -and $said -match 'sign in first|NOT_SIGNED_IN')) -and $Arguments[0] -in @('join', 'start')) {
|
|
714
717
|
$pantheonHome = if ($env:PANTHEON_HOME) { $env:PANTHEON_HOME } else { Join-Path ([Environment]::GetFolderPath('UserProfile')) '.pantheon' }
|
|
715
718
|
$signedIn = $false
|
|
716
719
|
try { $signedIn = [bool]((Get-Content -LiteralPath (Join-Path $pantheonHome 'config.json') -Raw | ConvertFrom-Json).account) } catch { $signedIn = $false }
|
|
@@ -725,7 +728,7 @@ function Install-Pantheon {
|
|
|
725
728
|
$show = Format-PantheonCommand $launcher $shown 'powershell'
|
|
726
729
|
$what = if ($Arguments[0] -eq 'join') { 'joining' } else { 'creating your team' }
|
|
727
730
|
Say ''
|
|
728
|
-
Say "Pantheon is installed. To finish $what, open PowerShell and run: $show"
|
|
731
|
+
Say "Pantheon is installed. To finish $what, open PowerShell and run: $show (or sign in from here: add --email you@work.com)"
|
|
729
732
|
}
|
|
730
733
|
}
|
|
731
734
|
} finally {
|
package/installer/install.sh
CHANGED
|
@@ -780,7 +780,11 @@ if [ -n "$said" ]; then
|
|
|
780
780
|
else
|
|
781
781
|
"$LAUNCHER" "$@" </dev/null || code=$?
|
|
782
782
|
fi
|
|
783
|
-
|
|
783
|
+
# Signing in by flags (--email, then --code: 0.37.0) ends on pantheon's own next
|
|
784
|
+
# step, which is then the last line: a second, different one here would contradict it.
|
|
785
|
+
byflags=0
|
|
786
|
+
for a in "$@"; do case "$a" in --email | --code | --email=* | --code=* | --continue) byflags=1 ;; esac; done
|
|
787
|
+
if [ "$byflags" -eq 0 ] && { [ "$code" -eq 10 ] || { [ "$code" -ne 0 ] && [ -n "$said" ] && grep -qE 'sign in first|NOT_SIGNED_IN' "$said" 2>/dev/null; }; }; then
|
|
784
788
|
case "$1" in
|
|
785
789
|
join | start)
|
|
786
790
|
cfg="${PANTHEON_HOME:-$HOME/.pantheon}/config.json"
|
|
@@ -797,7 +801,7 @@ if [ "$code" -eq 10 ] || { [ "$code" -ne 0 ] && [ -n "$said" ] && grep -qE 'sign
|
|
|
797
801
|
if [ "$1" = join ] && [ "$n" -eq 2 ]; then line="$line '<your invite link>'"; else line="$line $(shown "$a")"; fi
|
|
798
802
|
done
|
|
799
803
|
if [ "$1" = join ]; then what="joining"; else what="creating your team"; fi
|
|
800
|
-
printf '\nPantheon is installed. To finish %s, open a terminal and run: %s\n' "$what" "$line" >&2
|
|
804
|
+
printf '\nPantheon is installed. To finish %s, open a terminal and run: %s (or sign in from here: add --email you@work.com)\n' "$what" "$line" >&2
|
|
801
805
|
fi
|
|
802
806
|
;;
|
|
803
807
|
esac
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@join-pantheon/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0-rc.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@join-pantheon/cli",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.37.0-rc.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@join-pantheon/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0-rc.1",
|
|
4
4
|
"description": "Let your coding agent collaborate directly with your teammates' agents — ask, agree an interface, and deliver, without a human relaying messages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"start": "node dist/cli.js relay",
|
|
22
22
|
"test:ci": "node scripts/test.mjs",
|
|
23
23
|
"smoke": "node scripts/smoke.mjs",
|
|
24
|
-
"test:installer": "node scripts/installer-tests/run.mjs"
|
|
24
|
+
"test:installer": "node scripts/installer-tests/run.mjs",
|
|
25
|
+
"gen:copy": "npm run build && node scripts/gen-copy.mjs"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@modelcontextprotocol/sdk": "^1.32.1",
|