@join-pantheon/cli 0.36.0 → 0.37.0-rc.2
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 +95 -0
- package/dist/agent-check.js +115 -0
- package/dist/agents.js +1 -0
- package/dist/cli.js +298 -58
- package/dist/config.js +29 -2
- 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 +335 -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 +237 -17
- 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";
|
|
@@ -363,6 +364,9 @@ function firstLedgerName(file) {
|
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
366
|
const GOAL_OPENED = /^goal opened: ([^\n]*)\nacceptance: ([\s\S]*?)(?:\ndeadline: (\S+))?(?:\nkind: (\w+)[\s\S]*)?$/;
|
|
367
|
+
const STATUS_PER_NETWORK = 1_200;
|
|
368
|
+
const AUTH_PER_ADDRESS = 120;
|
|
369
|
+
const JOIN_LOOKUPS_PER_ADDRESS = 20;
|
|
366
370
|
const LIMITS_GOAL_READ = 1000;
|
|
367
371
|
function repoLabelSafe(v) {
|
|
368
372
|
if (!v)
|
|
@@ -637,7 +641,7 @@ export class Relay {
|
|
|
637
641
|
}
|
|
638
642
|
const bad = e instanceof TypeError || e instanceof URIError;
|
|
639
643
|
if (!bad)
|
|
640
|
-
this.log(`! http ${req.method} ${String(req.url ?? "").slice(0, 120)} failed: ${e?.message ?? e}`);
|
|
644
|
+
this.log(`! http ${req.method} ${String(req.url ?? "").replace(/([?&]t=)[^&]*/g, "$1…").slice(0, 120)} failed: ${e?.message ?? e}`);
|
|
641
645
|
if (isStorageError(e))
|
|
642
646
|
this.noteStorageFailure(`http ${String(req.url ?? "").split("?")[0].slice(0, 60)}`, e);
|
|
643
647
|
try {
|
|
@@ -953,9 +957,15 @@ export class Relay {
|
|
|
953
957
|
void this.serveInstaller(req, res, url.pathname.slice(1));
|
|
954
958
|
return;
|
|
955
959
|
}
|
|
960
|
+
if (url.pathname === "/onboard.json" || url.pathname === "/skills/join.md" || url.pathname === "/skills/onboard.md") {
|
|
961
|
+
if (req.method !== "GET" && req.method !== "HEAD")
|
|
962
|
+
return this.json(res, 405, { error: "GET only" });
|
|
963
|
+
void this.serveCopy(req, res, url.pathname);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
956
966
|
if (url.pathname === "/join") {
|
|
957
|
-
if (!this.
|
|
958
|
-
return this.json(res, 429, { error: "too many lookups from your network — wait a minute" });
|
|
967
|
+
if (!this.localTrusted(ip) && !this.hitsOk(this.joinHits, ip, JOIN_LOOKUPS_PER_ADDRESS))
|
|
968
|
+
return this.json(res, 429, { error: "too many lookups from your network — wait a minute", reason: "lookups_busy" }, { "retry-after": String(this.retryAfter(this.joinHits, ip)) });
|
|
959
969
|
const token = (url.searchParams.get("token") ?? "").trim();
|
|
960
970
|
if (!/^[A-Za-z0-9_-]{16,64}$/.test(token))
|
|
961
971
|
return this.json(res, 400, { error: "an invite code is required: /join?token=<code>" });
|
|
@@ -1270,10 +1280,15 @@ export class Relay {
|
|
|
1270
1280
|
return this.json(res, 409, { error: msg, reason: started.reason });
|
|
1271
1281
|
}
|
|
1272
1282
|
A.audit({ event: "signup", target: normalizeUsername(b.username), ip });
|
|
1273
|
-
const
|
|
1283
|
+
const linked = b.link === true ? this.linkFor(b.email, b.pubkey, String(b.label ?? "a device"), ip) : null;
|
|
1284
|
+
if (typeof b.joining === "string")
|
|
1285
|
+
this.noteJoining(b.email, b.joining);
|
|
1286
|
+
else
|
|
1287
|
+
this.noteJoining(b.email, null);
|
|
1288
|
+
const sent = await this.email.sendCode(b.email, started.code, "signup", linked?.url);
|
|
1274
1289
|
if (sent)
|
|
1275
1290
|
this.noteEmailSent("signup", b.email, ip);
|
|
1276
|
-
return this.json(res, 200, { ok: true, sent, via: this.email.kind });
|
|
1291
|
+
return this.json(res, 200, { ok: true, sent, via: this.email.kind, ...(linked ? { link: true, words: linked.words, status_aud: linked.aud } : {}) });
|
|
1277
1292
|
});
|
|
1278
1293
|
}
|
|
1279
1294
|
if (url.pathname === "/auth/login" && req.method === "POST") {
|
|
@@ -1296,10 +1311,11 @@ export class Relay {
|
|
|
1296
1311
|
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
1312
|
return this.json(res, code, { error: msg, reason: started.reason });
|
|
1298
1313
|
}
|
|
1299
|
-
const
|
|
1314
|
+
const linked = b.link === true ? this.linkFor(b.email, b.pubkey, String(b.label ?? "a device"), ip) : null;
|
|
1315
|
+
const sent = await this.email.sendCode(b.email, started.code, "login", linked?.url);
|
|
1300
1316
|
if (sent)
|
|
1301
1317
|
this.noteEmailSent("login", b.email, ip, b.pubkey, own);
|
|
1302
|
-
return this.json(res, 200, { ok: true, sent, via: this.email.kind });
|
|
1318
|
+
return this.json(res, 200, { ok: true, sent, via: this.email.kind, ...(linked ? { link: true, words: linked.words, status_aud: linked.aud } : {}) });
|
|
1303
1319
|
});
|
|
1304
1320
|
}
|
|
1305
1321
|
if (url.pathname === "/auth/verify" && req.method === "POST") {
|
|
@@ -1324,10 +1340,52 @@ export class Relay {
|
|
|
1324
1340
|
}
|
|
1325
1341
|
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
1342
|
if (r.welcome)
|
|
1327
|
-
this.sendWelcome(r.account.email, ip);
|
|
1343
|
+
this.sendWelcome(r.account.email, ip, this.takeJoining(r.account.email));
|
|
1328
1344
|
return;
|
|
1329
1345
|
});
|
|
1330
1346
|
}
|
|
1347
|
+
if (url.pathname === "/auth/confirm" && (req.method === "GET" || req.method === "POST")) {
|
|
1348
|
+
if (req.method === "GET")
|
|
1349
|
+
return this.confirmPage(res, url.searchParams.get("t") ?? "");
|
|
1350
|
+
if (!this.authRateOk(ip))
|
|
1351
|
+
return this.confirmPage(res, "", { said: "Too many tries from your network. Wait a minute, or use the 6-digit code from the email." });
|
|
1352
|
+
return this.readForm(req, res, (f) => {
|
|
1353
|
+
const t = String(f.t ?? "");
|
|
1354
|
+
const r = A.confirmLink(t, String(f.words ?? ""), ip);
|
|
1355
|
+
if (r.ok) {
|
|
1356
|
+
const acct = r.account;
|
|
1357
|
+
this.confirmPage(res, "", { done: true });
|
|
1358
|
+
if (r.welcome)
|
|
1359
|
+
this.sendWelcome(acct.email, ip, this.takeJoining(acct.email));
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
const why = r.reason;
|
|
1363
|
+
if (why === "empty")
|
|
1364
|
+
return this.confirmPage(res, t, { said: "Type the two words your screen or your coding agent shows." });
|
|
1365
|
+
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."
|
|
1366
|
+
: 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."
|
|
1367
|
+
: why === "device_other_account" ? DEVICE_OTHER_ACCOUNT
|
|
1368
|
+
: "This link has expired or was already used. Use the 6-digit code from the email, or ask for a new one." });
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
if (url.pathname === "/auth/status" && req.method === "GET") {
|
|
1372
|
+
const key = String(req.headers["x-pantheon-key"] ?? ""), nonce = String(req.headers["x-pantheon-nonce"] ?? "");
|
|
1373
|
+
const ts = Number(req.headers["x-pantheon-ts"] ?? NaN), sig = String(req.headers["x-pantheon-sig"] ?? "");
|
|
1374
|
+
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)
|
|
1375
|
+
return this.json(res, 400, { error: "a signed status request needs x-pantheon-key, -ts (within 2 minutes), -nonce and -sig" });
|
|
1376
|
+
if (!this.localTrusted(ip) && !this.networkStatusOk(netOf(ip)))
|
|
1377
|
+
return this.json(res, 429, { error: "too many requests from your network — wait a minute", reason: "network_busy" }, { "retry-after": String(this.networkStatusRetry(netOf(ip))) });
|
|
1378
|
+
if (!verifyStatus(key, ts, nonce, sig, this.statusAudience(req)))
|
|
1379
|
+
return this.json(res, 403, { error: "this request must be signed by the device that is signing in, for this relay" });
|
|
1380
|
+
if (!this.statusBudgetOk(key))
|
|
1381
|
+
return this.json(res, 429, { error: "asking too often — once every few seconds is enough", reason: "too_often" }, { "retry-after": String(this.retryAfter(this.statusHits, key)) });
|
|
1382
|
+
if (!this.freshNonce(nonce))
|
|
1383
|
+
return this.json(res, 403, { error: "that request was already answered" });
|
|
1384
|
+
const acct = A.signedInDevice(key);
|
|
1385
|
+
if (acct)
|
|
1386
|
+
return this.json(res, 200, { state: "confirmed", account: { username: acct.username, email: acct.email } });
|
|
1387
|
+
return this.json(res, 200, { state: A.pendingFor(key) ? "pending" : "none" });
|
|
1388
|
+
}
|
|
1331
1389
|
if (url.pathname === "/account/sessions" && req.method === "GET") {
|
|
1332
1390
|
const who = this.verifySignedAccount(url, "GET", "/account/sessions", ip);
|
|
1333
1391
|
if (!who)
|
|
@@ -1476,7 +1534,7 @@ export class Relay {
|
|
|
1476
1534
|
const cap = Number(process.env.PANTHEON_EMAIL_MAX_PER_HOUR) || 200;
|
|
1477
1535
|
const reserved = Math.min(cap - 1, Math.max(0, Number(process.env.PANTHEON_EMAIL_RESERVED_PER_HOUR ?? Math.floor(cap / 4)) || 0));
|
|
1478
1536
|
const perAddress = Number(process.env.PANTHEON_EMAIL_MAX_PER_ADDRESS) || 5;
|
|
1479
|
-
const perNet = Number(process.env.PANTHEON_EMAIL_MAX_PER_NETWORK) ||
|
|
1537
|
+
const perNet = Number(process.env.PANTHEON_EMAIL_MAX_PER_NETWORK) || 100;
|
|
1480
1538
|
if (live(this.emailSendsTo.get(this.emailBucket(email, pubkey, own)) ?? []).length >= perAddress) {
|
|
1481
1539
|
return own ? "this device has asked for too many codes in the last hour — use the latest one, or try again in an hour"
|
|
1482
1540
|
: "too many codes were sent to this address in the last hour — use the latest one, or try again in an hour";
|
|
@@ -1511,7 +1569,126 @@ export class Relay {
|
|
|
1511
1569
|
if (kind !== "welcome" && !own && !this.localTrusted(ip))
|
|
1512
1570
|
bump(this.emailSendsFrom, netOf(ip));
|
|
1513
1571
|
}
|
|
1514
|
-
|
|
1572
|
+
linkFor(email, pubkey, label, ip) {
|
|
1573
|
+
const pub = publicBase(null);
|
|
1574
|
+
if (!pub || !this.accounts)
|
|
1575
|
+
return null;
|
|
1576
|
+
const l = this.accounts.startLink(email, pubkey, { label, ip });
|
|
1577
|
+
return l ? { url: `${pub}/auth/confirm?t=${encodeURIComponent(l.token)}`, words: l.words, aud: new URL(pub).host } : null;
|
|
1578
|
+
}
|
|
1579
|
+
statusAudience(req) {
|
|
1580
|
+
const pub = publicBase(null);
|
|
1581
|
+
try {
|
|
1582
|
+
if (pub)
|
|
1583
|
+
return new URL(pub).host;
|
|
1584
|
+
}
|
|
1585
|
+
catch { }
|
|
1586
|
+
return String(req.headers.host ?? "");
|
|
1587
|
+
}
|
|
1588
|
+
statusHits = new Map();
|
|
1589
|
+
joinHits = new Map();
|
|
1590
|
+
statusIpWindow = new Map();
|
|
1591
|
+
networkStatusOk(net) {
|
|
1592
|
+
const t = Date.now();
|
|
1593
|
+
let w = this.statusIpWindow.get(net);
|
|
1594
|
+
if (!w || t - w.from >= 60_000) {
|
|
1595
|
+
if (this.statusIpWindow.size > 10_000)
|
|
1596
|
+
for (const [k, v] of this.statusIpWindow)
|
|
1597
|
+
if (t - v.from >= 60_000)
|
|
1598
|
+
this.statusIpWindow.delete(k);
|
|
1599
|
+
w = { from: t, n: 0 };
|
|
1600
|
+
this.statusIpWindow.set(net, w);
|
|
1601
|
+
}
|
|
1602
|
+
if (w.n >= STATUS_PER_NETWORK)
|
|
1603
|
+
return false;
|
|
1604
|
+
w.n++;
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
networkStatusRetry(net) {
|
|
1608
|
+
const w = this.statusIpWindow.get(net);
|
|
1609
|
+
return w ? Math.min(60, Math.max(1, Math.ceil((w.from + 60_000 - Date.now()) / 1000))) : 1;
|
|
1610
|
+
}
|
|
1611
|
+
hitsOk(map, key, limit) {
|
|
1612
|
+
const t = Date.now();
|
|
1613
|
+
const recent = (map.get(key) ?? []).filter((x) => t - x < 60_000);
|
|
1614
|
+
const ok = recent.length < limit;
|
|
1615
|
+
if (ok)
|
|
1616
|
+
recent.push(t);
|
|
1617
|
+
map.set(key, recent);
|
|
1618
|
+
if (map.size > 10_000)
|
|
1619
|
+
for (const [k, v] of map)
|
|
1620
|
+
if (!v.some((x) => t - x < 60_000))
|
|
1621
|
+
map.delete(k);
|
|
1622
|
+
return ok;
|
|
1623
|
+
}
|
|
1624
|
+
retryAfter(map, key) {
|
|
1625
|
+
const oldest = (map.get(key) ?? [])[0];
|
|
1626
|
+
return oldest === undefined ? 1 : Math.min(60, Math.max(1, Math.ceil((oldest + 60_000 - Date.now()) / 1000)));
|
|
1627
|
+
}
|
|
1628
|
+
statusBudgetOk(key) { return this.hitsOk(this.statusHits, key, 40); }
|
|
1629
|
+
statusNonces = new Map();
|
|
1630
|
+
statusNonceSweep = 0;
|
|
1631
|
+
freshNonce(nonce) {
|
|
1632
|
+
const t = Date.now();
|
|
1633
|
+
if (this.statusNonces.has(nonce))
|
|
1634
|
+
return false;
|
|
1635
|
+
this.statusNonces.set(nonce, t);
|
|
1636
|
+
if (this.statusNonces.size > 20_000 && t - this.statusNonceSweep > 10_000) {
|
|
1637
|
+
this.statusNonceSweep = t;
|
|
1638
|
+
for (const [k, v] of this.statusNonces)
|
|
1639
|
+
if (t - v > 300_000)
|
|
1640
|
+
this.statusNonces.delete(k);
|
|
1641
|
+
}
|
|
1642
|
+
return true;
|
|
1643
|
+
}
|
|
1644
|
+
confirmPage(res, token, o = {}) {
|
|
1645
|
+
const A = this.accounts;
|
|
1646
|
+
const info = token ? A.linkInfo(token) : null;
|
|
1647
|
+
const esc = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1648
|
+
const mask = (ip) => ip.replace(/^(\d+\.\d+)\.\d+\.\d+$/, "$1.x.x").replace(/^([0-9a-f]+:[0-9a-f]+):.*$/i, "$1:…");
|
|
1649
|
+
const body = o.done
|
|
1650
|
+
? `<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>`
|
|
1651
|
+
: info
|
|
1652
|
+
? `<h1>Sign in this computer?</h1>
|
|
1653
|
+
<p>A computer asked to sign in to Pantheon as <b>${esc(info.email)}</b>.</p>
|
|
1654
|
+
<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>
|
|
1655
|
+
<p>Only go on if you started this yourself, just now, on your own computer or through your own coding agent.</p>
|
|
1656
|
+
${o.said ? `<p class="said">${esc(o.said)}</p>` : ""}
|
|
1657
|
+
<form method="post" action="/auth/confirm"><input type="hidden" name="t" value="${esc(token)}">
|
|
1658
|
+
<label for="w">The two words your screen or your coding agent shows</label>
|
|
1659
|
+
<input id="w" name="words" autocomplete="off" autocapitalize="off" spellcheck="false" placeholder="two words">
|
|
1660
|
+
<button type="submit">Confirm</button></form>`
|
|
1661
|
+
: `<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>`;
|
|
1662
|
+
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>
|
|
1663
|
+
<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>
|
|
1664
|
+
${body}`;
|
|
1665
|
+
res.writeHead(200, {
|
|
1666
|
+
"content-type": "text/html; charset=utf-8", "cache-control": "no-store", "referrer-policy": "no-referrer",
|
|
1667
|
+
"x-frame-options": "DENY", "x-content-type-options": "nosniff",
|
|
1668
|
+
"content-security-policy": "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'",
|
|
1669
|
+
});
|
|
1670
|
+
res.end(html);
|
|
1671
|
+
}
|
|
1672
|
+
joiningByEmail = new Map();
|
|
1673
|
+
noteJoining(email, team) {
|
|
1674
|
+
const k = normalizeEmail(email);
|
|
1675
|
+
if (team === null) {
|
|
1676
|
+
this.joiningByEmail.delete(k);
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
if (!RELAY_TEAM_NAME.test(team))
|
|
1680
|
+
team = "";
|
|
1681
|
+
if (this.joiningByEmail.size >= 10_000)
|
|
1682
|
+
this.joiningByEmail.delete(this.joiningByEmail.keys().next().value);
|
|
1683
|
+
this.joiningByEmail.set(k, { team, at: Date.now() });
|
|
1684
|
+
}
|
|
1685
|
+
takeJoining(email) {
|
|
1686
|
+
const k = normalizeEmail(email);
|
|
1687
|
+
const j = this.joiningByEmail.get(k);
|
|
1688
|
+
this.joiningByEmail.delete(k);
|
|
1689
|
+
return j && Date.now() - j.at < 30 * 60_000 ? j.team : undefined;
|
|
1690
|
+
}
|
|
1691
|
+
sendWelcome(to, ip, joining) {
|
|
1515
1692
|
if (!this.email.sendWelcome)
|
|
1516
1693
|
return;
|
|
1517
1694
|
if (this.emailRefusal("welcome", to, ip)) {
|
|
@@ -1520,7 +1697,7 @@ export class Relay {
|
|
|
1520
1697
|
}
|
|
1521
1698
|
let sending;
|
|
1522
1699
|
try {
|
|
1523
|
-
sending = Promise.resolve(this.email.sendWelcome(to));
|
|
1700
|
+
sending = Promise.resolve(joining !== undefined ? this.email.sendWelcome(to, joining) : this.email.sendWelcome(to));
|
|
1524
1701
|
}
|
|
1525
1702
|
catch {
|
|
1526
1703
|
return;
|
|
@@ -1533,7 +1710,9 @@ export class Relay {
|
|
|
1533
1710
|
return true;
|
|
1534
1711
|
const now = Date.now();
|
|
1535
1712
|
const recent = (this.authHits.get(ip) ?? []).filter((t) => now - t < 60_000);
|
|
1536
|
-
recent.
|
|
1713
|
+
const ok = recent.length < AUTH_PER_ADDRESS;
|
|
1714
|
+
if (ok)
|
|
1715
|
+
recent.push(now);
|
|
1537
1716
|
this.authHits.set(ip, recent);
|
|
1538
1717
|
if (this.authHits.size > 10_000) {
|
|
1539
1718
|
for (const [k, v] of this.authHits) {
|
|
@@ -1544,7 +1723,7 @@ export class Relay {
|
|
|
1544
1723
|
this.authHits.delete(k);
|
|
1545
1724
|
}
|
|
1546
1725
|
}
|
|
1547
|
-
return
|
|
1726
|
+
return ok;
|
|
1548
1727
|
}
|
|
1549
1728
|
readBody(req, res, limit, cb) {
|
|
1550
1729
|
const HARD = 4 * 1024 * 1024;
|
|
@@ -4244,6 +4423,40 @@ export class Relay {
|
|
|
4244
4423
|
}
|
|
4245
4424
|
catch { } });
|
|
4246
4425
|
}
|
|
4426
|
+
async serveCopy(req, res, path) {
|
|
4427
|
+
try {
|
|
4428
|
+
const host = String(req.headers.host ?? "").replace(/[^A-Za-z0-9.:\[\]-]/g, "");
|
|
4429
|
+
const proto = forwardedProto(req) === "https" ? "https" : "http";
|
|
4430
|
+
const relay = publicBase(null) ?? (host ? `${proto}://${host}` : null);
|
|
4431
|
+
const choice = await this.installerGate.choose();
|
|
4432
|
+
if (res.writableEnded || res.destroyed)
|
|
4433
|
+
return;
|
|
4434
|
+
const served = !("unavailable" in choice) && installerScript("install.sh", undefined, choice.version) !== null;
|
|
4435
|
+
const o = served ? { relay, installs: choice.version } : { relay, installs: null, serves: false };
|
|
4436
|
+
const [type, body] = path === "/onboard.json"
|
|
4437
|
+
? ["application/json", JSON.stringify(onboardJson({ ...o, version: VERSION }))]
|
|
4438
|
+
: ["text/markdown; charset=utf-8", path === "/skills/join.md" ? joinMd(o) : onboardMd(o)];
|
|
4439
|
+
res.writeHead(200, {
|
|
4440
|
+
"content-type": type,
|
|
4441
|
+
"content-length": Buffer.byteLength(body),
|
|
4442
|
+
"cache-control": publicBase(null) ? "public, max-age=300" : "no-store",
|
|
4443
|
+
vary: "Host, X-Forwarded-Proto",
|
|
4444
|
+
"access-control-allow-origin": "*",
|
|
4445
|
+
"x-content-type-options": "nosniff",
|
|
4446
|
+
});
|
|
4447
|
+
res.end(req.method === "HEAD" ? undefined : body);
|
|
4448
|
+
}
|
|
4449
|
+
catch (e) {
|
|
4450
|
+
this.log(`! ${path} failed: ${e?.message ?? e}`);
|
|
4451
|
+
try {
|
|
4452
|
+
if (!res.headersSent)
|
|
4453
|
+
this.json(res, 500, { error: "the relay could not handle that request" });
|
|
4454
|
+
else
|
|
4455
|
+
res.end();
|
|
4456
|
+
}
|
|
4457
|
+
catch { }
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4247
4460
|
landingPage(req, res) {
|
|
4248
4461
|
const host = String(req.headers.host ?? "").replace(/[^A-Za-z0-9.:\[\]-]/g, "");
|
|
4249
4462
|
const proto = String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim() === "https" ? "https" : "http";
|
|
@@ -4305,9 +4518,9 @@ pantheon start</code></pre>
|
|
|
4305
4518
|
catch { }
|
|
4306
4519
|
}
|
|
4307
4520
|
}
|
|
4308
|
-
json(res, code, body) {
|
|
4521
|
+
json(res, code, body, headers = {}) {
|
|
4309
4522
|
const s = JSON.stringify(body);
|
|
4310
|
-
res.writeHead(code, { "content-type": "application/json", "content-length": Buffer.byteLength(s) });
|
|
4523
|
+
res.writeHead(code, { ...headers, "content-type": "application/json", "content-length": Buffer.byteLength(s) });
|
|
4311
4524
|
res.end(s);
|
|
4312
4525
|
}
|
|
4313
4526
|
onSocket(ws, ip = "unknown") {
|
|
@@ -4607,6 +4820,7 @@ pantheon start</code></pre>
|
|
|
4607
4820
|
}
|
|
4608
4821
|
enrolled = this.ensureToken(sp);
|
|
4609
4822
|
this.log(`[${sp.name}] * ENROLLED ${m.member} via invite from ${r.entry.admitted_by}${r.entry.may_wake ? " (may wake)" : ""}`);
|
|
4823
|
+
this.broadcast(sp, { t: "members", members: this.members(sp) });
|
|
4610
4824
|
}
|
|
4611
4825
|
if (staleToken && !enrolled) {
|
|
4612
4826
|
const e = sp.allow.get(m.member);
|
|
@@ -4787,6 +5001,10 @@ pantheon start</code></pre>
|
|
|
4787
5001
|
m.profile = { ...m.profile, authority: Object.fromEntries(Object.entries(m.profile.authority).filter(([k]) => !isCatchAllDomain(k))) };
|
|
4788
5002
|
this.log(`[${space.name}] ~ ${me.id}'s profile: dropped ${vague.map((k) => JSON.stringify(k)).join(", ")} — not a decision area`);
|
|
4789
5003
|
}
|
|
5004
|
+
if (m.profile.team_setup && (me.id !== space.allow.founder() || ![space.allow.spaceId(), space.name].includes(m.profile.team_setup.team))) {
|
|
5005
|
+
const { team_setup: _drop, ...rest } = m.profile;
|
|
5006
|
+
m.profile = rest;
|
|
5007
|
+
}
|
|
4790
5008
|
const current = space.profiles.get(me.id);
|
|
4791
5009
|
if (!current || m.profile.updated_at > current.updated_at) {
|
|
4792
5010
|
space.profiles.set(me.id, m.profile);
|
|
@@ -6551,6 +6769,8 @@ pantheon start</code></pre>
|
|
|
6551
6769
|
member: e.member, admitted: e.admitted, may_wake: e.may_wake,
|
|
6552
6770
|
fingerprint: fingerprint(e.publicKey), pubkey: e.publicKey,
|
|
6553
6771
|
...(e.admitted_by ? { admitted_by: e.admitted_by } : {}),
|
|
6772
|
+
...(e.invite_fp ? { invite_fp: e.invite_fp } : {}),
|
|
6773
|
+
...(e.joined_at ? { joined_at: e.joined_at } : {}),
|
|
6554
6774
|
...(e.revoked_at ? { revoked_at: e.revoked_at, ...(e.revoked_by ? { revoked_by: e.revoked_by } : {}) } : {}),
|
|
6555
6775
|
...(sp.allow.founder() === e.member ? { founder: true } : {}),
|
|
6556
6776
|
...((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.2",
|
|
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.2",
|
|
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.2",
|
|
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",
|