@join-pantheon/cli 0.37.3 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-founder.js +5 -2
- package/dist/admin-pages.js +29 -2
- package/dist/cli.js +285 -38
- package/dist/crash-loop.js +207 -0
- package/dist/doctor.js +38 -1
- package/dist/finish-line.js +14 -7
- package/dist/folder-ask.js +104 -0
- package/dist/founder-stats.js +24 -1
- package/dist/home-guard.js +21 -0
- package/dist/home-safety.js +2 -0
- package/dist/install-stats.js +314 -0
- package/dist/machine.js +2 -0
- package/dist/mcp.js +37 -1
- package/dist/notice.js +106 -0
- package/dist/notifier.js +206 -16
- package/dist/onboard-copy.js +3 -0
- package/dist/pickup.js +11 -3
- package/dist/quickstart.js +41 -21
- package/dist/relay.js +56 -6
- package/dist/service.js +5 -0
- package/dist/setup-changes.js +5 -0
- package/dist/setup-guide.js +25 -4
- package/dist/status-engine.js +1 -1
- package/dist/tray.js +9 -2
- package/dist/version-health.js +288 -0
- package/dist/win-host.js +2 -0
- package/dist/worker-policy.js +45 -3
- package/dist/worker.js +61 -24
- package/npm-shrinkwrap.json +13 -2
- package/package.json +2 -1
package/dist/worker.js
CHANGED
|
@@ -20,6 +20,8 @@ import { AGENTS, headlessSpawn, materializeSpawnFiles, chooseAgent, agentById, d
|
|
|
20
20
|
import { activeOutages, detectOutage, earliest, isSignOut, outagePredicate, whenAgain, SIGNIN_REFUSED } from "./agent-outage.js";
|
|
21
21
|
import { agentSpawn, CmdLineUnsafe } from "./which.js";
|
|
22
22
|
import { VERSION } from "./version.js";
|
|
23
|
+
import { composeUpgradeFailed, fetchRelayPkg, recordRelayPkg, upgradeFailedOnce } from "./version-health.js";
|
|
24
|
+
import { noteServiceConnected } from "./crash-loop.js";
|
|
23
25
|
import { applyAnswer, ASK_EXPIRY_MS, policyUnreadable, CAPABILITY_ARGS, CARRY_REASON, carryOverWakers, dropLedgerGrants, hasWakeOnce, isApprovedWaker, mayAskWake, takeWakeOnce, OLD_RELAY_WAKE, relayKnowsAdmitters, loadPolicy, mayAsk, needsSelfUpgrade, parseGrantAnswer, recordAsk, savePolicy, useGrant, WOKEN_RUN_ENV, takeTeamFlagOnYes, unsandboxedAllowed, policyPath, isNewer, RUN_MINUTES, effectiveRunMinutes, effectiveIdleSeconds, readinessRecheckPath, policyHome, describeRunMinutes, parseRunMinutes, currentMode, wakeSettled, } from "./worker-policy.js";
|
|
24
26
|
import { readinessAlerts } from "./readiness-alert.js";
|
|
25
27
|
import { clearDeclined, markDeclined, personsOwnThread, pruneDeclined } from "./declined.js";
|
|
@@ -2925,7 +2927,8 @@ export class Worker {
|
|
|
2925
2927
|
act: "NOTE", goal: o.goal, ref: o.ref, to: [member], after_seq: Math.max(client.readSeq, client.seq),
|
|
2926
2928
|
summary: `${this.cfg.member} has been asked to let you start work on their machine — this waits for that`,
|
|
2927
2929
|
body: `${this.cfg.member}'s machine takes unattended requests only from people ${this.cfg.member} approved there. ${this.cfg.member} has just been asked about you; once they say yes, this runs on its own. Nothing was run yet.`,
|
|
2928
|
-
|
|
2930
|
+
meta: { declined: "wake_ask" },
|
|
2931
|
+
}).then(() => this.markFor("declined-told", o.id), () => { });
|
|
2929
2932
|
}
|
|
2930
2933
|
catch (e) {
|
|
2931
2934
|
this.opts.log(`! could not ask whether ${member} may wake this machine: ${e.message}`);
|
|
@@ -3132,6 +3135,7 @@ export class Worker {
|
|
|
3132
3135
|
try {
|
|
3133
3136
|
await this.recoverGuard();
|
|
3134
3137
|
await client.connect();
|
|
3138
|
+
noteServiceConnected();
|
|
3135
3139
|
this.client = client;
|
|
3136
3140
|
await (this.opts.alertsOnly ? this.sayKeyChanges(client) : this.opts.housekeeping ? this.keepHouse(client) : this.serve(client));
|
|
3137
3141
|
}
|
|
@@ -3382,8 +3386,6 @@ export class Worker {
|
|
|
3382
3386
|
: /cannot tell who sent it/.test(refusedWake.why) ? "it could not be told who sent it"
|
|
3383
3387
|
: `${asker} isn't approved to start work on this computer`;
|
|
3384
3388
|
this.decline(o.ref, why);
|
|
3385
|
-
if (this.mode() === "autopilot" && !refusedWake.transient)
|
|
3386
|
-
await this.tellAskerDeclined(client, o, reqAct, refusedWake.askable ? `it waits for ${this.cfg.member} to approve you` : "this machine doesn't start work for you on its own");
|
|
3387
3389
|
if (!this.skipLogged.has(`wake:${o.id}`)) {
|
|
3388
3390
|
this.skipLogged.add(`wake:${o.id}`);
|
|
3389
3391
|
this.opts.log(`- not taking ${owedLabel(o.kind)} ${o.id}: ${refusedWake.why} — it waits for a live session`);
|
|
@@ -3402,6 +3404,19 @@ export class Worker {
|
|
|
3402
3404
|
this.tickHold = { reason: "awaiting_wake_approval", detail: "asking its person whether this teammate may start work here" };
|
|
3403
3405
|
}
|
|
3404
3406
|
}
|
|
3407
|
+
if (!refusedWake.transient) {
|
|
3408
|
+
const asking = !!refusedWake.askable && (() => {
|
|
3409
|
+
try {
|
|
3410
|
+
const pol = loadPolicy(this.opts.home);
|
|
3411
|
+
const ts = [this.cfg.spaceId, this.cfg.space].filter((t) => !!t);
|
|
3412
|
+
return Object.values(pol.wakeAsks ?? {}).some((a) => ts.includes(a.team) && a.member === refusedWake.askable);
|
|
3413
|
+
}
|
|
3414
|
+
catch {
|
|
3415
|
+
return false;
|
|
3416
|
+
}
|
|
3417
|
+
})();
|
|
3418
|
+
await this.tellAskerDeclined(client, o, reqAct, asking ? `it waits for ${this.cfg.member} to approve you` : "this machine doesn't start work for you on its own", asking ? "wake_ask" : /^this machine is set not to be woken/.test(refusedWake.why) ? "wake_off" : /^the team does not let/.test(refusedWake.why) ? "team_wake" : "wake");
|
|
3419
|
+
}
|
|
3405
3420
|
continue;
|
|
3406
3421
|
}
|
|
3407
3422
|
if (presentNow && await this.personThread(client, reqAct)) {
|
|
@@ -3415,8 +3430,7 @@ export class Worker {
|
|
|
3415
3430
|
const sel = this.selectPersona(client, o, reqAct?.from);
|
|
3416
3431
|
if (sel.skip) {
|
|
3417
3432
|
this.decline(o.ref, "no playbook here covers it");
|
|
3418
|
-
|
|
3419
|
-
await this.tellAskerDeclined(client, o, reqAct, "none of its playbooks covers it");
|
|
3433
|
+
await this.tellAskerDeclined(client, o, reqAct, "none of its playbooks covers it", "playbook");
|
|
3420
3434
|
if (!this.skipLogged.has(o.id)) {
|
|
3421
3435
|
this.skipLogged.add(o.id);
|
|
3422
3436
|
this.opts.log(`- not taking ${owedLabel(o.kind)} ${o.id}: ${sel.skip}`);
|
|
@@ -3570,7 +3584,7 @@ export class Worker {
|
|
|
3570
3584
|
held.push({ o: next.o, act: next.act });
|
|
3571
3585
|
for (const h of held) {
|
|
3572
3586
|
this.decline(h.o.ref, `it has done its ${gate.cap.n} runs ${gate.cap.per === "hour" ? "this hour" : "today"}`, line);
|
|
3573
|
-
await this.tellAskerDeclined(client, h.o, h.act ?? await this.fetchActById(h.o.ref), `it has used its runs for now${when ? `; it can take it after ${when}` : ""}
|
|
3587
|
+
await this.tellAskerDeclined(client, h.o, h.act ?? await this.fetchActById(h.o.ref), `it has used its runs for now${when ? `; it can take it after ${when}` : ""}`, "capped");
|
|
3574
3588
|
}
|
|
3575
3589
|
}
|
|
3576
3590
|
if (continuation)
|
|
@@ -4178,6 +4192,7 @@ export class Worker {
|
|
|
4178
4192
|
cause: "repo_not_here", says,
|
|
4179
4193
|
fix: route.kind === "missing" ? `Clone ${name} and run pantheon repo find (or pantheon use ${this.cfg.space} --here inside it); the request waits until then.` : `Bind a repo or folder: pantheon use ${this.cfg.space} --here`,
|
|
4180
4194
|
peer: {
|
|
4195
|
+
code: route.kind === "missing" ? "not_here" : "no_folder",
|
|
4181
4196
|
summary: route.kind === "missing" ? `${name} is not on ${this.cfg.member}'s machine — this waits for ${this.cfg.member}` : `nothing on ${this.cfg.member}'s machine is bound to this team yet`,
|
|
4182
4197
|
body: route.kind === "missing"
|
|
4183
4198
|
? `${this.cfg.member}'s machine does not have ${name}, so its worker cannot look at it — and it will not answer from another repo's code.\nThis is still owed and waits for ${this.cfg.member}; a teammate who works on ${name} can take it meanwhile. Nothing was run.`
|
|
@@ -5250,6 +5265,7 @@ export class Worker {
|
|
|
5250
5265
|
`${this.cfg.member} will pick this up in their next session on this machine.`,
|
|
5251
5266
|
`It is still owed. Nothing was run.`,
|
|
5252
5267
|
].join("\n"),
|
|
5268
|
+
meta: { declined: d.peer?.code ?? (d.cause === "not_signed_in" ? "signed_out" : "unavailable") },
|
|
5253
5269
|
});
|
|
5254
5270
|
markContinued(space, key, this.opts.home);
|
|
5255
5271
|
this.opts.log(d.cause === "agent_unavailable" ? `* told ${peer ?? "the teammate"} that ${o.id} waits: ${d.says}`
|
|
@@ -5373,6 +5389,10 @@ export class Worker {
|
|
|
5373
5389
|
this.decline(candidate.ref, "its run failed twice on this computer");
|
|
5374
5390
|
if (failures >= 2 && diagnosis)
|
|
5375
5391
|
await this.reportStuck(client, candidate, diagnosis, attempts);
|
|
5392
|
+
if (failures >= 2) {
|
|
5393
|
+
const commands = diagnosis?.cause === "no_commands" || diagnosis?.cause === "no_sandbox_commands";
|
|
5394
|
+
await this.tellAskerDeclined(client, candidate, client.seenAct(candidate.ref) ?? await this.fetchActById(candidate.ref), commands ? `it needs ${this.cfg.member}'s OK to run commands for it` : "it tried and couldn't finish it", commands ? "commands" : "failed");
|
|
5395
|
+
}
|
|
5376
5396
|
}
|
|
5377
5397
|
async noteOnDecision(client, o, d, decision, blocked = []) {
|
|
5378
5398
|
const key = `stuck-note:${decision}`;
|
|
@@ -5892,6 +5912,7 @@ export class Worker {
|
|
|
5892
5912
|
return;
|
|
5893
5913
|
this.lastHealthCheck = Date.now();
|
|
5894
5914
|
const relayPkg = await (this.opts.selfUpgrade?.check ?? (() => this.fetchRelayPkg()))();
|
|
5915
|
+
recordRelayPkg(this.cfg.relay, relayPkg, home ? { home } : {});
|
|
5895
5916
|
const policy = loadPolicy(home);
|
|
5896
5917
|
const lastAttempt = policy.attempts.self_upgrade ?? null;
|
|
5897
5918
|
if (!needsSelfUpgrade(VERSION, relayPkg, lastAttempt))
|
|
@@ -5921,8 +5942,11 @@ export class Worker {
|
|
|
5921
5942
|
this.opts.log(`! self-upgrade failed: ${e.message}`);
|
|
5922
5943
|
}
|
|
5923
5944
|
if (result.needsPerson) {
|
|
5924
|
-
if (grantBefore)
|
|
5945
|
+
if (grantBefore) {
|
|
5925
5946
|
policy.grants.self_upgrade = grantBefore;
|
|
5947
|
+
if (policy.usedOnce)
|
|
5948
|
+
delete policy.usedOnce.self_upgrade;
|
|
5949
|
+
}
|
|
5926
5950
|
delete policy.attempts.self_upgrade;
|
|
5927
5951
|
policy.upgradeHeld = { version: relayPkg ?? result.to, node: nodeNow(), at: Date.now(), why: result.needsPerson };
|
|
5928
5952
|
savePolicy(policy, home);
|
|
@@ -5954,6 +5978,20 @@ export class Worker {
|
|
|
5954
5978
|
}
|
|
5955
5979
|
else if (!result.ok) {
|
|
5956
5980
|
this.opts.log("! self-upgrade did not complete — will not retry for an hour; run `pantheon upgrade` by hand to see why");
|
|
5981
|
+
const pkg = relayPkg ?? result.to;
|
|
5982
|
+
const canAlert = !!this.opts.notify && decisionAlertsOn() && (() => { try {
|
|
5983
|
+
return !this.opts.canAlert || this.opts.canAlert();
|
|
5984
|
+
}
|
|
5985
|
+
catch {
|
|
5986
|
+
return false;
|
|
5987
|
+
} })();
|
|
5988
|
+
if (upgradeFailedOnce(pkg, { ...(home ? { home } : {}), canAlert })) {
|
|
5989
|
+
try {
|
|
5990
|
+
this.opts.notify?.({ ...composeUpgradeFailed(VERSION, pkg), context: this.cfg.space });
|
|
5991
|
+
}
|
|
5992
|
+
catch { }
|
|
5993
|
+
}
|
|
5994
|
+
this.writeState("needs you", `could not update pantheon ${VERSION} -> ${pkg}: run pantheon upgrade to see why`);
|
|
5957
5995
|
}
|
|
5958
5996
|
return;
|
|
5959
5997
|
}
|
|
@@ -6256,17 +6294,7 @@ export class Worker {
|
|
|
6256
6294
|
return null;
|
|
6257
6295
|
}
|
|
6258
6296
|
}
|
|
6259
|
-
async fetchRelayPkg() {
|
|
6260
|
-
try {
|
|
6261
|
-
const base = this.cfg.relay.replace(/^ws/, "http").replace(/\/+$/, "");
|
|
6262
|
-
const res = await fetch(`${base}/health`, { signal: AbortSignal.timeout(3000) });
|
|
6263
|
-
const j = await res.json();
|
|
6264
|
-
return typeof j.pkg === "string" ? j.pkg : null;
|
|
6265
|
-
}
|
|
6266
|
-
catch {
|
|
6267
|
-
return null;
|
|
6268
|
-
}
|
|
6269
|
-
}
|
|
6297
|
+
async fetchRelayPkg() { return fetchRelayPkg(this.cfg.relay); }
|
|
6270
6298
|
cursorFile() { return join(this.opts.home ?? process.env.PANTHEON_HOME ?? join(homedir(), ".pantheon"), "worker-cursor.json"); }
|
|
6271
6299
|
cursorSaid = 0;
|
|
6272
6300
|
readCursor() {
|
|
@@ -6363,22 +6391,31 @@ export class Worker {
|
|
|
6363
6391
|
}, Math.max(PICKUP_COALESCE_MS, b.shownAt + PICKUP_MIN_GAP_MS - now));
|
|
6364
6392
|
b.timer.unref?.();
|
|
6365
6393
|
}
|
|
6366
|
-
async tellAskerDeclined(client, o, act, why) {
|
|
6394
|
+
async tellAskerDeclined(client, o, act, why, code) {
|
|
6367
6395
|
const peer = act?.from ?? client.recentFrom(o.ref);
|
|
6368
6396
|
if (!peer || peer === this.cfg.member)
|
|
6369
6397
|
return;
|
|
6370
|
-
|
|
6371
|
-
const space = this.spaceKey();
|
|
6372
|
-
if (this.contDone.has(key) || loadContinued(space, this.opts.home).has(key))
|
|
6398
|
+
if (client.relayNow() - o.created_at > 24 * 3_600_000)
|
|
6373
6399
|
return;
|
|
6400
|
+
this.learnRequests([o]);
|
|
6401
|
+
this.loadContinued();
|
|
6402
|
+
const key = `declined-told:${this.oKey(o.id)}`;
|
|
6403
|
+
if (this.marked("declined-told", o.id))
|
|
6404
|
+
return;
|
|
6405
|
+
const told = (prefix) => this.marked(prefix, o.id) || this.continuedHas(`${prefix}:${this.oKey(o.id)}`) || this.continuedHas(`${prefix}:${o.id}`);
|
|
6406
|
+
if (told("declined-told") || told("refused")) {
|
|
6407
|
+
this.contDone.add(key);
|
|
6408
|
+
return;
|
|
6409
|
+
}
|
|
6374
6410
|
this.contDone.add(key);
|
|
6375
6411
|
try {
|
|
6376
6412
|
await client.send({
|
|
6377
6413
|
act: "NOTE", goal: o.goal, ref: o.ref, after_seq: Math.max(client.readSeq, client.seq), to: [peer],
|
|
6378
6414
|
summary: `${this.cfg.member}'s agent won't take this on its own — it's with ${this.cfg.member}`,
|
|
6379
|
-
body: `${this.cfg.member}'s agent won't take this one on its own (${why}), so it's with ${this.cfg.member} now. It is still owed.`,
|
|
6415
|
+
body: `${this.cfg.member}'s agent won't take this one on its own (${why}), so it's with ${this.cfg.member} now. It is still owed. If it can't wait, remind ${this.cfg.member} or ask someone else.`,
|
|
6416
|
+
meta: { declined: code },
|
|
6380
6417
|
});
|
|
6381
|
-
|
|
6418
|
+
this.markDone(key);
|
|
6382
6419
|
this.opts.log(`* told ${peer} that ${o.id} is with ${this.cfg.member}: ${why}`);
|
|
6383
6420
|
}
|
|
6384
6421
|
catch (e) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@join-pantheon/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
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.38.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
13
|
+
"mmdb-lib": "3.0.3",
|
|
13
14
|
"undici": "^7.29.1",
|
|
14
15
|
"ws": "^8.18.0",
|
|
15
16
|
"zod": "^3.23.8"
|
|
@@ -777,6 +778,16 @@
|
|
|
777
778
|
"url": "https://opencollective.com/express"
|
|
778
779
|
}
|
|
779
780
|
},
|
|
781
|
+
"node_modules/mmdb-lib": {
|
|
782
|
+
"version": "3.0.3",
|
|
783
|
+
"resolved": "https://registry.npmjs.org/mmdb-lib/-/mmdb-lib-3.0.3.tgz",
|
|
784
|
+
"integrity": "sha512-xQPoBXcNjjHiOvOraFBKtA++uNWF6aCVHL9dRKFXEov8eI3QJwtgiw3qApsonFT5SpoqsEVISUTg3HIDs2DiXw==",
|
|
785
|
+
"license": "MIT",
|
|
786
|
+
"engines": {
|
|
787
|
+
"node": ">=10",
|
|
788
|
+
"npm": ">=6"
|
|
789
|
+
}
|
|
790
|
+
},
|
|
780
791
|
"node_modules/ms": {
|
|
781
792
|
"version": "2.1.3",
|
|
782
793
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@join-pantheon/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
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": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
29
|
+
"mmdb-lib": "3.0.3",
|
|
29
30
|
"undici": "^7.29.1",
|
|
30
31
|
"ws": "^8.18.0",
|
|
31
32
|
"zod": "^3.23.8"
|