@join-pantheon/cli 0.37.2 → 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/accounts.js +4 -0
- package/dist/admin-founder.js +5 -2
- package/dist/admin-pages.js +29 -2
- package/dist/cli.js +310 -39
- package/dist/crash-loop.js +207 -0
- package/dist/doctor.js +45 -1
- package/dist/email-templates.js +2 -2
- package/dist/email.js +2 -2
- package/dist/finish-line.js +25 -7
- package/dist/flag-signin.js +6 -2
- 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 +127 -0
- package/dist/notifier.js +242 -15
- package/dist/onboard-copy.js +6 -2
- package/dist/pickup.js +11 -3
- package/dist/quickstart.js +41 -21
- package/dist/recover-offer.js +16 -5
- package/dist/relay.js +65 -12
- 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/notifier.js
CHANGED
|
@@ -9,17 +9,22 @@ import { dirname, join, resolve } from "node:path";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { PantheonClient } from "./client.js";
|
|
11
11
|
import { CONFIG_DIR } from "./config.js";
|
|
12
|
+
import { awaitingDecision, pickupEstimate } from "./pickup.js";
|
|
12
13
|
import { loadProfile } from "./profile.js";
|
|
13
|
-
import { APP_TOOLS, CLAUDE_APP_CHOSEN, composeDecision,
|
|
14
|
+
import { APP_TOOLS, CLAUDE_APP_CHOSEN, composeDecision, composeJoined, composePassedOver, composeReplies, composeUnpicked, composeWaiting, composeWakeAsk, declineCodeOf, neverAlerts, passedOverNotice, TOOL_LABELS } from "./notice.js";
|
|
14
15
|
import { loadPolicy } from "./worker-policy.js";
|
|
15
16
|
import { withoutAgentMarkers } from "./setup-changes.js";
|
|
16
|
-
import { wakeAlerted } from "./continued.js";
|
|
17
|
+
import { liveReadAt, wakeAlerted } from "./continued.js";
|
|
18
|
+
import { teamPinId } from "./pins.js";
|
|
19
|
+
import { signedRead } from "./reads.js";
|
|
17
20
|
import { cliOnPath, detectAvailable } from "./agents.js";
|
|
18
21
|
import { CLAUDE_APP_TOOL, chosenOpenIn, claudeAppPresent, effectiveOpenIn } from "./open-in.js";
|
|
19
22
|
import { whichPantheon } from "./service.js";
|
|
20
23
|
import { powerNow } from "./power.js";
|
|
21
24
|
import { obligationSignature, StatusNudger } from "./status-nudge.js";
|
|
22
25
|
import { clientState, ConnectionReport } from "./conn-report.js";
|
|
26
|
+
import { noteServiceConnected } from "./crash-loop.js";
|
|
27
|
+
import { refusalOf } from "./refusal.js";
|
|
23
28
|
import { removalFor, removalHolds, removalRefusal, removalWords, removedLine, removedNotice, takeTold } from "./removed.js";
|
|
24
29
|
export const DEFAULT_REMINDER_MS = 4 * 60 * 60 * 1_000;
|
|
25
30
|
export const JOIN_BATCH_MS = 20_000;
|
|
@@ -32,6 +37,62 @@ export function reminderGap(n, reminderMs) {
|
|
|
32
37
|
export function wakeAskWhat(body) {
|
|
33
38
|
return /answer while you are away:\s*(.+)$/m.exec(body)?.[1]?.trim() ?? body.split("\n")[0] ?? "";
|
|
34
39
|
}
|
|
40
|
+
export const WAITING_AFTER_MS = 5 * 60_000;
|
|
41
|
+
export const WAITING_EVERY_MS = 30 * 60_000;
|
|
42
|
+
export const WAITING_MAX_AGE_MS = 24 * 3_600_000;
|
|
43
|
+
export function requestFrom(body) {
|
|
44
|
+
return /^([a-z0-9._-]+)\s+(?:asked|proposed|objected|delivered|escalated)\s*:/i.exec(body)?.[1]
|
|
45
|
+
?? /^(?:ASK|PROPOSE|DELIVERED|CONTRACT|COMMIT|OBJECT)\s+from\s+([a-z0-9._-]+)/i.exec(body)?.[1];
|
|
46
|
+
}
|
|
47
|
+
let machineWaitingAt = 0;
|
|
48
|
+
export function resetWaitingClock() { machineWaitingAt = 0; }
|
|
49
|
+
export function waitingRequests(obligations, member, state, now, fromOf) {
|
|
50
|
+
return obligations.filter((o) => o.owner === member && o.kind !== "HUMAN" && o.kind !== "CONTINUE" && !o.claimed_by
|
|
51
|
+
&& now - o.created_at >= WAITING_AFTER_MS && now - o.created_at < WAITING_MAX_AGE_MS
|
|
52
|
+
&& state.notified_at[`act:wait:${o.ref}`] === undefined
|
|
53
|
+
&& !awaitingDecision(obligations, o)
|
|
54
|
+
&& (() => { const f = fromOf(o); return !!f && f !== member; })());
|
|
55
|
+
}
|
|
56
|
+
export const ASKED_FOLLOWUP_MS = 60 * 60_000;
|
|
57
|
+
export const ASKED_EVERY_MS = 10 * 60_000;
|
|
58
|
+
export const REPLY_BATCH_MS = 2_500;
|
|
59
|
+
let machineAskedAt = 0;
|
|
60
|
+
export function resetAskedClock() { machineAskedAt = 0; }
|
|
61
|
+
export function unpickedRequests(obligations, member, state, now, fromOf, o = {}) {
|
|
62
|
+
const byRef = new Map();
|
|
63
|
+
for (const x of obligations) {
|
|
64
|
+
if (x.owner === member || x.owner.startsWith("human:") || x.kind === "HUMAN" || x.kind === "CONTINUE" || x.kind === "DELIVER")
|
|
65
|
+
continue;
|
|
66
|
+
byRef.set(x.ref, [...(byRef.get(x.ref) ?? []), x]);
|
|
67
|
+
}
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const [ref, owed] of byRef) {
|
|
70
|
+
if (state.notified_at[`act:asked:${ref}`] !== undefined)
|
|
71
|
+
continue;
|
|
72
|
+
if (owed.some((x) => x.claimed_by))
|
|
73
|
+
continue;
|
|
74
|
+
if (fromOf(owed[0]) !== member)
|
|
75
|
+
continue;
|
|
76
|
+
const at = Math.min(...owed.map((x) => x.created_at));
|
|
77
|
+
if (now - at < ASKED_FOLLOWUP_MS || now - at >= WAITING_MAX_AGE_MS)
|
|
78
|
+
continue;
|
|
79
|
+
if (owed.some((x) => awaitingDecision(obligations, x)))
|
|
80
|
+
continue;
|
|
81
|
+
const goal = owed[0].goal;
|
|
82
|
+
if (goal && o.closed?.(goal))
|
|
83
|
+
continue;
|
|
84
|
+
const to = o.sentTo?.(ref)?.filter((t) => t !== member);
|
|
85
|
+
if (to?.length && owed.length < to.length)
|
|
86
|
+
continue;
|
|
87
|
+
if (o.replied?.(ref, to?.length ? to : owed.map((x) => x.owner)))
|
|
88
|
+
continue;
|
|
89
|
+
out.push({ ref, owed });
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
export function repliedIn(acts, ref, askedOf) {
|
|
94
|
+
return acts.some((a) => a.ref === ref && askedOf.includes(a.from) && !(a.act === "NOTE" && a.role === "worker" && !a.meta?.declined));
|
|
95
|
+
}
|
|
35
96
|
export function humanObligations(obligations, member) {
|
|
36
97
|
return obligations.filter((o) => o.kind === "HUMAN" && o.owner === `human:${member}`);
|
|
37
98
|
}
|
|
@@ -259,6 +320,7 @@ export class HumanNotifier {
|
|
|
259
320
|
report.close();
|
|
260
321
|
throw e;
|
|
261
322
|
}
|
|
323
|
+
noteServiceConnected();
|
|
262
324
|
try {
|
|
263
325
|
await this.serve(client);
|
|
264
326
|
}
|
|
@@ -281,6 +343,23 @@ export class HumanNotifier {
|
|
|
281
343
|
const joined = new Set();
|
|
282
344
|
const settled = new Set();
|
|
283
345
|
let joinedSince = 0;
|
|
346
|
+
let replies = [];
|
|
347
|
+
let repliesSince = 0;
|
|
348
|
+
const batched = new Set();
|
|
349
|
+
const own = new Map();
|
|
350
|
+
const ownAct = async (id) => {
|
|
351
|
+
const seen = client.seenAct(id);
|
|
352
|
+
if (seen)
|
|
353
|
+
return seen;
|
|
354
|
+
if (own.has(id))
|
|
355
|
+
return own.get(id);
|
|
356
|
+
const r = await client.storedAct(id, 3_000).catch(() => null);
|
|
357
|
+
own.set(id, r);
|
|
358
|
+
if (own.size > 500)
|
|
359
|
+
own.delete(own.keys().next().value);
|
|
360
|
+
return r;
|
|
361
|
+
};
|
|
362
|
+
const byRun = (a) => a.sig?.role === "run" || a.role === "worker";
|
|
284
363
|
try {
|
|
285
364
|
let removedSaid = false;
|
|
286
365
|
while (!this.stopped) {
|
|
@@ -355,6 +434,94 @@ export class HumanNotifier {
|
|
|
355
434
|
this.opts.log(`! could not show a desktop notification for ${obligation.id}`);
|
|
356
435
|
}
|
|
357
436
|
}
|
|
437
|
+
if (prefs.decisions) {
|
|
438
|
+
const fromOf = (o) => client.seenAct(o.ref)?.from ?? requestFrom(o.body);
|
|
439
|
+
const relayNow = now() + (client.relayNow() - Date.now());
|
|
440
|
+
const me = client.roster.find((m) => m.id === this.cfg.member);
|
|
441
|
+
const workerBusy = me?.worker?.state === "running" && me.sessions.some((x) => x.role === "worker");
|
|
442
|
+
const waiting = workerBusy ? [] : waitingRequests(client.obligations, this.cfg.member, state, relayNow, fromOf);
|
|
443
|
+
const last = Math.max(state.notified_at["act:wait:last"] ?? 0, machineWaitingAt);
|
|
444
|
+
if (waiting.length && (last === 0 || now() - last >= WAITING_EVERY_MS)) {
|
|
445
|
+
const items = waiting.map((o) => ({ from: fromOf(o), what: client.seenAct(o.ref)?.summary ?? o.body }));
|
|
446
|
+
const before = machineWaitingAt;
|
|
447
|
+
machineWaitingAt = now();
|
|
448
|
+
const ok = await send(withLabel(composeWaiting(items, this.cfg.space, { tools, preferred: preferredTool(profile, tools), now: now() })));
|
|
449
|
+
if (!ok)
|
|
450
|
+
machineWaitingAt = before;
|
|
451
|
+
if (ok) {
|
|
452
|
+
for (const o of waiting)
|
|
453
|
+
state.notified_at[`act:wait:${o.ref}`] = now();
|
|
454
|
+
state.notified_at["act:wait:last"] = now();
|
|
455
|
+
machineWaitingAt = now();
|
|
456
|
+
dirty = true;
|
|
457
|
+
this.opts.log(`> waiting alert: ${waiting.length} request${waiting.length === 1 ? "" : "s"} nothing here picked up`);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (prefs.decisions) {
|
|
462
|
+
const relayNow = now() + (client.relayNow() - Date.now());
|
|
463
|
+
const fromOf = (o) => client.seenAct(o.ref)?.from ?? own.get(o.ref)?.from ?? requestFrom(o.body);
|
|
464
|
+
let due = unpickedRequests(client.obligations, this.cfg.member, state, relayNow, fromOf, {
|
|
465
|
+
closed: (g) => client.goals.get(g)?.state === "CLOSED",
|
|
466
|
+
sentTo: (ref) => (client.seenAct(ref) ?? own.get(ref))?.to,
|
|
467
|
+
replied: (ref, askedOf) => repliedIn(client.seenSince(0), ref, askedOf),
|
|
468
|
+
});
|
|
469
|
+
const last = Math.max(state.notified_at["act:asked:last"] ?? 0, machineAskedAt);
|
|
470
|
+
if (due.length && (last === 0 || now() - last >= ASKED_EVERY_MS)) {
|
|
471
|
+
const before = machineAskedAt;
|
|
472
|
+
machineAskedAt = now();
|
|
473
|
+
const runs = [];
|
|
474
|
+
for (const d of due) {
|
|
475
|
+
const a = await ownAct(d.ref);
|
|
476
|
+
if (a && byRun(a))
|
|
477
|
+
runs.push(d.ref);
|
|
478
|
+
}
|
|
479
|
+
for (const ref of runs) {
|
|
480
|
+
state.notified_at[`act:asked:${ref}`] = now();
|
|
481
|
+
dirty = true;
|
|
482
|
+
}
|
|
483
|
+
due = due.filter((d) => !runs.includes(d.ref) && !((a) => a?.to?.length && d.owed.length < a.to.filter((t) => t !== this.cfg.member).length)(own.get(d.ref) ?? client.seenAct(d.ref)));
|
|
484
|
+
const replied = [];
|
|
485
|
+
for (const d of due) {
|
|
486
|
+
const mine = client.seenAct(d.ref) ?? own.get(d.ref);
|
|
487
|
+
const to = mine?.to?.filter((t) => t !== this.cfg.member);
|
|
488
|
+
const askedOf = to?.length ? to : d.owed.map((x) => x.owner);
|
|
489
|
+
try {
|
|
490
|
+
const goal = d.owed[0].goal;
|
|
491
|
+
const res = await signedRead(this.cfg, "/history", goal ? { goal } : { since: String(Math.max(0, (mine?.seq ?? 1) - 1)) }, { timeoutMs: 3_000 });
|
|
492
|
+
const acts = res.ok ? (await res.json()).acts ?? [] : [];
|
|
493
|
+
if (repliedIn(acts, d.ref, askedOf))
|
|
494
|
+
replied.push(d.ref);
|
|
495
|
+
}
|
|
496
|
+
catch { }
|
|
497
|
+
}
|
|
498
|
+
for (const ref of replied) {
|
|
499
|
+
state.notified_at[`act:asked:${ref}`] = now();
|
|
500
|
+
dirty = true;
|
|
501
|
+
}
|
|
502
|
+
due = due.filter((d) => !replied.includes(d.ref));
|
|
503
|
+
if (due.length) {
|
|
504
|
+
const mayWake = client.members.find((m) => m.member === this.cfg.member)?.may_wake;
|
|
505
|
+
const items = due.map((d) => {
|
|
506
|
+
const owners = [...new Set(d.owed.map((o) => o.owner))];
|
|
507
|
+
const peer = client.roster.find((m) => m.id === owners[0]) ?? { id: owners[0], sessions: [] };
|
|
508
|
+
const est = owners.length === 1 ? pickupEstimate(peer, { now: relayNow, about: { ref: d.ref, goal: d.owed[0].goal }, claimedBy: null, ...(mayWake !== undefined ? { mayWake } : {}) }) : null;
|
|
509
|
+
const why = est && est.kind !== "soon" ? est.says : undefined;
|
|
510
|
+
const mine = client.seenAct(d.ref) ?? own.get(d.ref);
|
|
511
|
+
return { owners, what: mine?.summary ?? mine?.body ?? d.owed[0].body, ...(why ? { why } : {}) };
|
|
512
|
+
});
|
|
513
|
+
const ok = await send(withLabel(composeUnpicked(items, this.cfg.space, { tools, preferred: preferredTool(profile, tools), now: now() })));
|
|
514
|
+
for (const d of due)
|
|
515
|
+
state.notified_at[`act:asked:${d.ref}`] = now();
|
|
516
|
+
state.notified_at["act:asked:last"] = now();
|
|
517
|
+
machineAskedAt = now();
|
|
518
|
+
dirty = true;
|
|
519
|
+
this.opts.log(ok ? `> follow-up alert: ${due.length} request${due.length === 1 ? "" : "s"} of yours nobody picked up` : `! could not show the follow-up alert for ${due.length} request${due.length === 1 ? "" : "s"}`);
|
|
520
|
+
}
|
|
521
|
+
else
|
|
522
|
+
machineAskedAt = before;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
358
525
|
if (dirty || !existsSync(stateFile))
|
|
359
526
|
writeState(stateFile, state);
|
|
360
527
|
const arrived = await client.next(pollMs);
|
|
@@ -418,21 +585,66 @@ export class HumanNotifier {
|
|
|
418
585
|
writeState(stateFile, state);
|
|
419
586
|
}
|
|
420
587
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
588
|
+
for (const r of arrived) {
|
|
589
|
+
if (!prefs.decisions && !prefs.deliveries)
|
|
590
|
+
break;
|
|
591
|
+
if (r.from === this.cfg.member || neverAlerts(r) || batched.has(r.id) || state.notified_at[`act:${r.id}`])
|
|
592
|
+
continue;
|
|
593
|
+
if (r.act !== "ANSWER" && r.act !== "DELIVERED" && !declineCodeOf(r))
|
|
594
|
+
continue;
|
|
595
|
+
if (client.relayNow() - r.ts > WAITING_MAX_AGE_MS)
|
|
596
|
+
continue;
|
|
597
|
+
const goal = r.goal ? client.goals.get(r.goal) : undefined;
|
|
598
|
+
const code = declineCodeOf(r);
|
|
599
|
+
const asked = r.ref && prefs.decisions ? await ownAct(r.ref) : null;
|
|
600
|
+
let item = null;
|
|
601
|
+
if (!prefs.decisions) { }
|
|
602
|
+
else if (asked && asked.from === this.cfg.member && !byRun(asked)) {
|
|
603
|
+
item = code ? (r.to?.includes(this.cfg.member) ? { kind: "declined", act: r, code, asked: asked.summary ?? asked.body } : null)
|
|
604
|
+
: { kind: r.act === "ANSWER" ? "answer" : "delivery", act: r };
|
|
605
|
+
}
|
|
606
|
+
else if (!r.ref && !code) {
|
|
607
|
+
if (r.act === "ANSWER" && r.to?.includes(this.cfg.member))
|
|
608
|
+
item = { kind: "answer", act: r };
|
|
609
|
+
else if (r.act === "DELIVERED" && goal?.opened_by === this.cfg.member && goal.sig?.role !== "run"
|
|
610
|
+
&& (r.to?.length ? r.to.includes(this.cfg.member) : goal.members.length === 2))
|
|
611
|
+
item = { kind: "delivery", act: r };
|
|
612
|
+
}
|
|
613
|
+
if (!item && prefs.deliveries && r.act === "DELIVERED") {
|
|
426
614
|
const forMe = r.to?.length ? r.to.includes(this.cfg.member) : (goal?.members.includes(this.cfg.member) ?? false);
|
|
427
|
-
if (
|
|
428
|
-
|
|
429
|
-
const ok = await send(withLabel(composeDelivery(r, goal, peerOf(r.from), { tools, preferred: preferredTool(profile, tools), now: now() })));
|
|
430
|
-
if (ok) {
|
|
431
|
-
state.notified_at[`act:${r.id}`] = now();
|
|
432
|
-
writeState(stateFile, state);
|
|
433
|
-
this.opts.log(`> delivery alert for ${r.id} from ${r.from}`);
|
|
434
|
-
}
|
|
615
|
+
if (forMe)
|
|
616
|
+
item = { kind: "delivery", act: r };
|
|
435
617
|
}
|
|
618
|
+
if (!item)
|
|
619
|
+
continue;
|
|
620
|
+
if (!replies.length)
|
|
621
|
+
repliesSince = now();
|
|
622
|
+
replies.push(item);
|
|
623
|
+
batched.add(r.id);
|
|
624
|
+
}
|
|
625
|
+
if (replies.length && now() - repliesSince >= (this.opts.replyBatchMs ?? REPLY_BATCH_MS)) {
|
|
626
|
+
const batch = replies;
|
|
627
|
+
replies = [];
|
|
628
|
+
const pin = [teamPinId(this.cfg)];
|
|
629
|
+
const shown = (x) => x.kind !== "declined" && (() => { try {
|
|
630
|
+
return liveReadAt(pin, x.act.id).length > 0;
|
|
631
|
+
}
|
|
632
|
+
catch {
|
|
633
|
+
return false;
|
|
634
|
+
} })();
|
|
635
|
+
const say = batch.filter((x) => !shown(x));
|
|
636
|
+
for (const x of batch) {
|
|
637
|
+
state.notified_at[`act:${x.act.id}`] = now();
|
|
638
|
+
batched.delete(x.act.id);
|
|
639
|
+
}
|
|
640
|
+
for (const x of batch)
|
|
641
|
+
if (x.kind === "declined" && x.act.ref)
|
|
642
|
+
state.notified_at[`act:asked:${x.act.ref}`] = now();
|
|
643
|
+
if (say.length) {
|
|
644
|
+
const ok = await send(withLabel(composeReplies(say, this.cfg.space, (g) => (g ? client.goals.get(g) : undefined), (m) => peerOf(m), { tools, preferred: preferredTool(profile, tools), now: now() })));
|
|
645
|
+
this.opts.log(ok ? `> reply alert: ${say.map((x) => `${x.kind} ${x.act.id} from ${x.act.from}`).join(", ")}` : `! could not show the reply alert for ${say.length}`);
|
|
646
|
+
}
|
|
647
|
+
writeState(stateFile, state);
|
|
436
648
|
}
|
|
437
649
|
}
|
|
438
650
|
}
|
|
@@ -441,9 +653,19 @@ export class HumanNotifier {
|
|
|
441
653
|
}
|
|
442
654
|
}
|
|
443
655
|
}
|
|
656
|
+
export function onlyNetworkFailures(errors) {
|
|
657
|
+
return errors.length > 0 && errors.every((e) => {
|
|
658
|
+
const r = refusalOf(e);
|
|
659
|
+
if (r && PASSING_OR_SAID.has(r.code))
|
|
660
|
+
return true;
|
|
661
|
+
return !r && !/^SPACE_MISMATCH\b/.test(e.trim());
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
const PASSING_OR_SAID = new Set(["SPACE_UNREADABLE", "BAD_NONCE", "STORAGE", "SHUTTING_DOWN", "SPACE_DELETED"]);
|
|
444
665
|
export async function runNotifiers(teams, o) {
|
|
445
666
|
const sleep = o.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
446
667
|
const failing = new Set();
|
|
668
|
+
const lastError = new Map();
|
|
447
669
|
let gaveUp = false;
|
|
448
670
|
let giveUp;
|
|
449
671
|
const allFailing = new Promise((r) => { giveUp = () => r(false); });
|
|
@@ -460,9 +682,14 @@ export async function runNotifiers(teams, o) {
|
|
|
460
682
|
removed = !!removalRefusal(e.message);
|
|
461
683
|
if (!removed) {
|
|
462
684
|
failing.add(i);
|
|
685
|
+
lastError.set(i, e.message);
|
|
463
686
|
o.log(`[${t.label}] ! not connecting: ${e.message.split("\n")[0]}`);
|
|
464
687
|
if (failing.size === teams.length) {
|
|
465
688
|
gaveUp = true;
|
|
689
|
+
try {
|
|
690
|
+
o.onGiveUp?.([...failing].map((n) => lastError.get(n) ?? ""));
|
|
691
|
+
}
|
|
692
|
+
catch { }
|
|
466
693
|
giveUp();
|
|
467
694
|
return;
|
|
468
695
|
}
|
package/dist/onboard-copy.js
CHANGED
|
@@ -48,6 +48,7 @@ function stepsFor(invite, o) {
|
|
|
48
48
|
const npm = ["npm install -g @join-pantheon/cli", `pantheon ${cmd.map(q).join(" ")}`];
|
|
49
49
|
return { person, npm, agent: agentRequest(invite, o) };
|
|
50
50
|
}
|
|
51
|
+
export const FOLDER_ASK = "If it ends by asking which folder I work in for the team, show me the folders it lists and ask me which one — a project, or a folder of documents. Run the line it gives for the one I pick, or for a folder I name. Never pick one for me.";
|
|
51
52
|
export function agentRequest(invite, o) {
|
|
52
53
|
const base = invite === null || quotableInvite(invite) === invite ? baseOf(o) : null;
|
|
53
54
|
const what = invite ? "join my teammate's Pantheon team" : "set up Pantheon and start a team";
|
|
@@ -61,8 +62,10 @@ export function agentRequest(invite, o) {
|
|
|
61
62
|
`First ask me for my email and for the username my teammates will see (it can't be changed later).${invite ? " Don't open the invite link: it holds a one-time secret, and the installer takes it as it is." : ""}`,
|
|
62
63
|
`On a Mac or Linux: download the installer and read it before running it — curl -fsSL ${base}/install.sh -o pantheon-install.sh — then run: sh pantheon-install.sh ${verb} ${flags}`,
|
|
63
64
|
`On Windows: curl.exe -fsSL ${base}/install.ps1 -o pantheon-install.ps1, read it, then run: powershell -NoProfile -Command "Set-Item Env:PANTHEON_ARGS '${psVerb} ${flags}'; Get-Content -Raw pantheon-install.ps1 | iex"`,
|
|
64
|
-
`It emails me a 6-digit code (it may land in spam).
|
|
65
|
-
|
|
65
|
+
`It emails me a 6-digit code and a link (it may land in spam), and prints two words in capitals. When you ask me for the code, show me those two words too: I can give you the code, or open the email's link and type the words there. Then, for the way I used, run the exact command it prints next (it names Pantheon by its full path, since this shell may not find \`pantheon\` yet), with the code in place of <the 6-digit code>.`,
|
|
66
|
+
...(invite ? [] : [`If it says I'm already in some teams, show me their names and ask which this computer should join, then run the line it gives for each one I pick. Don't ask me to name a new team unless I say I want one.`]),
|
|
67
|
+
FOLDER_ASK,
|
|
68
|
+
`The download, the sign-in and the setup need network access, and the setup starts Pantheon's background helpers, which a sandbox blocks. If your shell runs in a sandbox (Codex's does), ask me to approve running each of them outside it. In Codex, ask me to approve running them with network access. If the request is turned down without asking me, or this shell still can't go online, don't look for a way around it: tell me to choose "Ask for approval" in Codex's permissions menu (under the message box), then try again when I say so.`,
|
|
66
69
|
"What it changes, to tell me before running it:",
|
|
67
70
|
...INSTALL_CHANGES.slice(0, 3).map((c) => `- ${c}`),
|
|
68
71
|
].join("\n");
|
|
@@ -71,6 +74,7 @@ export function agentRequest(invite, o) {
|
|
|
71
74
|
intro,
|
|
72
75
|
`It needs Node.js 22.13 or newer. Run: npm install -g @join-pantheon/cli — then: pantheon ${verb} --json`,
|
|
73
76
|
`If it exits with code 10, I need to sign in once: give me the line it prints to run in a terminal of my own, and run it again after.${invite ? " Don't open the invite link: it holds a one-time secret." : ""}`,
|
|
77
|
+
FOLDER_ASK,
|
|
74
78
|
].join("\n");
|
|
75
79
|
}
|
|
76
80
|
export function inviteBlock(invite, o) {
|
package/dist/pickup.js
CHANGED
|
@@ -8,6 +8,12 @@ export function inWords(ms) {
|
|
|
8
8
|
const h = Math.round(m / 60);
|
|
9
9
|
return `about ${h} hour${h === 1 ? "" : "s"}`;
|
|
10
10
|
}
|
|
11
|
+
export function machineOn(peer) {
|
|
12
|
+
return (peer.sessions ?? []).length > 0;
|
|
13
|
+
}
|
|
14
|
+
export function notSetUpWords(who) {
|
|
15
|
+
return `${who}'s computer is on, but nothing there is set up to take requests while ${who} is away`;
|
|
16
|
+
}
|
|
11
17
|
const UNAVAILABLE = {
|
|
12
18
|
no_agent: "Claude Code (or another agent CLI) isn't installed there",
|
|
13
19
|
kiro_only: "only Kiro is installed there, and Kiro answers in live sessions only",
|
|
@@ -38,9 +44,11 @@ export function pickupEstimate(peer, o = {}) {
|
|
|
38
44
|
return { kind: "no-wake", says: `${who}'s worker does not take your requests (the team does not let you wake it), so this waits for ${who}${live ? ", who has a live session open" : ""}` };
|
|
39
45
|
}
|
|
40
46
|
if (!workerOn) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
if (live)
|
|
48
|
+
return { kind: "not-set-up", says: `${who} has a session open, which sees this when their agent next looks; nothing on ${who}'s computer is set up to take requests while ${who} is away` };
|
|
49
|
+
if (machineOn(peer))
|
|
50
|
+
return { kind: "not-set-up", says: notSetUpWords(who) };
|
|
51
|
+
return { kind: "offline", says: `${who}'s worker is offline, so this waits until ${who} is back` };
|
|
44
52
|
}
|
|
45
53
|
const cb = o.claimedBy;
|
|
46
54
|
if (cb && cb.role === "worker" && !(peer.sessions ?? []).some((s) => s.id === cb.session)) {
|
package/dist/quickstart.js
CHANGED
|
@@ -8,22 +8,23 @@ import { lookup } from "node:dns/promises";
|
|
|
8
8
|
import { describeRelayFailure, interceptedText, RelayReplyError } from "./network.js";
|
|
9
9
|
import { PantheonClient } from "./client.js";
|
|
10
10
|
import { holdsRepo } from "./repo-find.js";
|
|
11
|
-
import { folderFacts, folderRefusal,
|
|
11
|
+
import { folderFacts, folderRefusal, isInside } from "./folder-guard.js";
|
|
12
12
|
import { load, loadAll, identity, save, toInvite, resolveFor, repoInfo, bindRepo, bindFolder, folderBinding, DEFAULT_RELAY } from "./config.js";
|
|
13
13
|
import { looksLikePlaceholder, teamSlug } from "./team-name.js";
|
|
14
|
-
import { commandsChosen, loadProfile, wakeChosen, wakeDefault } from "./profile.js";
|
|
14
|
+
import { commandsChosen, decisionAlertsOn, loadProfile, wakeChosen, wakeDefault } from "./profile.js";
|
|
15
|
+
import { turnedOff } from "./setup-changes.js";
|
|
15
16
|
import { newKeypair } from "./identity.js";
|
|
16
17
|
import { installForUser } from "./install.js";
|
|
17
18
|
import { writeIntent, installHooks } from "./notify.js";
|
|
18
19
|
import { detectAvailable, agentById, agentsNeedingUnsandboxed, folderReaderLine, recordedAgent } from "./agents.js";
|
|
19
|
-
import { installService, installedServiceArgs, keepServiceFlags, servicesUnavailable } from "./service.js";
|
|
20
|
+
import { borrowedHome, installService, installedServiceArgs, keepServiceFlags, serviceState, servicesUnavailable } from "./service.js";
|
|
20
21
|
import { clearTrayQuit } from "./win-host.js";
|
|
21
22
|
import { ensureNativeNotifier } from "./notifier.js";
|
|
22
23
|
import { ensureTrayBinary, writeTrayCommands } from "./tray.js";
|
|
23
24
|
import { desktopUnavailable, ephemeralWarning, hostEnv } from "./host-env.js";
|
|
24
|
-
import {
|
|
25
|
+
import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
25
26
|
import { localAddresses } from "./machine.js";
|
|
26
|
-
import {
|
|
27
|
+
import { grantSelfUpgradeAtSetup, loadPolicy, unsandboxedAllowed } from "./worker-policy.js";
|
|
27
28
|
import { Relay } from "./relay.js";
|
|
28
29
|
import { loginShellEnv, which } from "./which.js";
|
|
29
30
|
const sh = (cmd) => {
|
|
@@ -39,6 +40,24 @@ const notLoaded = (r) => r && typeof r === "object" && r.loaded === false
|
|
|
39
40
|
: null;
|
|
40
41
|
export function wireUp(opts, deps = {}) {
|
|
41
42
|
const installSvc = deps.installService ?? installService;
|
|
43
|
+
const running = (kind) => { try {
|
|
44
|
+
return (deps.running ?? ((k) => !borrowedHome() && serviceState(k).running))(kind);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
} };
|
|
49
|
+
const offByPerson = (s) => { try {
|
|
50
|
+
return (deps.turnedOff ?? turnedOff)(s) && !running(s === "worker" ? "worker" : "notifier");
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
} };
|
|
55
|
+
const alertsOff = () => { try {
|
|
56
|
+
return offByPerson("alerts") || !(deps.alertsOn ?? decisionAlertsOn)();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
} };
|
|
42
61
|
const workerFlags = (wanted, decided) => keepServiceFlags(deps.installService ? null : installedServiceArgs("worker"), wanted, decided);
|
|
43
62
|
const ensureNotifier = deps.ensureNotifier ?? ensureNativeNotifier;
|
|
44
63
|
const ensureTray = deps.ensureTray ?? ensureTrayBinary;
|
|
@@ -69,6 +88,9 @@ export function wireUp(opts, deps = {}) {
|
|
|
69
88
|
if (opts.notifications && !host.desktop) {
|
|
70
89
|
tools.push({ tool: "notifications", status: desktopUnavailable(host, "desktop alerts") });
|
|
71
90
|
}
|
|
91
|
+
else if (opts.notifications && alertsOff()) {
|
|
92
|
+
tools.push({ tool: "notifications", status: "off — you turned alerts off on this computer, and they stay so. To turn them on: pantheon setup --alerts decisions" });
|
|
93
|
+
}
|
|
72
94
|
else if (opts.notifications) {
|
|
73
95
|
try {
|
|
74
96
|
const mac = host.platform === "darwin";
|
|
@@ -124,6 +146,9 @@ export function wireUp(opts, deps = {}) {
|
|
|
124
146
|
if (how === "off") {
|
|
125
147
|
tools.push({ tool: "worker", status: "off (--no-worker) — this machine cannot answer the team while you are away" });
|
|
126
148
|
}
|
|
149
|
+
else if (how === "default" && opts.unattended && offByPerson("worker")) {
|
|
150
|
+
tools.push({ tool: "worker", status: "off — you turned it off on this computer, and it stays so: teammates' requests wait for you. To turn it on: pantheon service install worker" });
|
|
151
|
+
}
|
|
127
152
|
else if (opts.unattended && noServices) {
|
|
128
153
|
tools.push({ tool: "worker", status: noServices });
|
|
129
154
|
}
|
|
@@ -160,6 +185,9 @@ export function wireUp(opts, deps = {}) {
|
|
|
160
185
|
} })();
|
|
161
186
|
if (reader && !reader.ok)
|
|
162
187
|
warnings.push(`${reader.line} — until then, teammates' requests for this folder wait for your live session`);
|
|
188
|
+
const selfUpgrade = grantSelfUpgradeAtSetup();
|
|
189
|
+
if (selfUpgrade)
|
|
190
|
+
granted.push(selfUpgrade);
|
|
163
191
|
}
|
|
164
192
|
}
|
|
165
193
|
catch (e) {
|
|
@@ -197,12 +225,9 @@ export function wireUp(opts, deps = {}) {
|
|
|
197
225
|
} })();
|
|
198
226
|
if (away.length && unsandboxedAllowed(loadPolicy()))
|
|
199
227
|
granted.push(`${away.join(", ")} ${away.length === 1 ? "answers" : "answer"} those requests, so teammates get answers even when you're offline. To have them wait for you instead: pantheon setup --unsandboxed no`);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
savePolicy(pol);
|
|
204
|
-
granted.push(`The worker keeps pantheon itself current with your team's relay (fast-forward pull + rebuild, reported on the ledger). Revoke: pantheon policy revoke self-upgrade`);
|
|
205
|
-
}
|
|
228
|
+
const selfUpgrade = grantSelfUpgradeAtSetup();
|
|
229
|
+
if (selfUpgrade)
|
|
230
|
+
granted.push(selfUpgrade);
|
|
206
231
|
}
|
|
207
232
|
catch (e) {
|
|
208
233
|
tools.push({ tool: "worker", status: `could not install: ${e.message}` });
|
|
@@ -513,12 +538,14 @@ export async function start(opts) {
|
|
|
513
538
|
if (repo && !client.repos.some((r) => r.fingerprint === repo.fingerprint)) {
|
|
514
539
|
await client.bindRepo(repo.fingerprint, repo.origin).catch((e) => warnings.push(`could not register this repo with the team: ${e.message}`));
|
|
515
540
|
}
|
|
516
|
-
|
|
541
|
+
const linkedAlready = reuse && Object.values(loadAll()?.bindings ?? {}).some((b) => b.space === c.spaceId);
|
|
542
|
+
if (!repo && c.spaceId && bindableFolder(process.cwd()) && !linkedAlready) {
|
|
517
543
|
bindFolder(process.cwd(), c.spaceId);
|
|
518
544
|
folderBound = process.cwd();
|
|
519
545
|
}
|
|
520
|
-
else if (!repo && c.spaceId)
|
|
521
|
-
|
|
546
|
+
else if (!repo && c.spaceId && linkedAlready && !folderBinding(loadAll(), process.cwd()) && bindableFolder(process.cwd())) {
|
|
547
|
+
opts.log(` folder this folder was not added — "${c.space}" already has its folders on this computer (to add this one too: pantheon use ${c.space} --here)`);
|
|
548
|
+
}
|
|
522
549
|
if (repo && c.spaceId) {
|
|
523
550
|
const { replaced } = bindRepo(repo, c.spaceId);
|
|
524
551
|
const was = replaced ?? (here.binding && here.binding.space !== c.spaceId ? here.binding : null);
|
|
@@ -613,8 +640,6 @@ export async function join(opts) {
|
|
|
613
640
|
bindFolder(process.cwd(), cfg.spaceId);
|
|
614
641
|
opts.log(` folder ${process.cwd()} → bound to "${cfg.space}" (agents opened here speak in it; no git needed)`);
|
|
615
642
|
}
|
|
616
|
-
else if (!repo && cfg.spaceId)
|
|
617
|
-
temporaryFolderNote(process.cwd(), opts.log, cfg.space);
|
|
618
643
|
if (repo && cfg.spaceId) {
|
|
619
644
|
const { replaced } = bindRepo(repo, cfg.spaceId);
|
|
620
645
|
if (replaced)
|
|
@@ -660,11 +685,6 @@ export function bindableFolder(dir) {
|
|
|
660
685
|
catch { }
|
|
661
686
|
return true;
|
|
662
687
|
}
|
|
663
|
-
function temporaryFolderNote(dir, log, team) {
|
|
664
|
-
const r = folderRefusalHere(dir);
|
|
665
|
-
if (isTemporaryRefusal(r))
|
|
666
|
-
log(` folder not bound — ${r.why.replace("<team>", team)}`);
|
|
667
|
-
}
|
|
668
688
|
function detectAgent(prior) {
|
|
669
689
|
return recordedAgent(prior, { fresh: true });
|
|
670
690
|
}
|
package/dist/recover-offer.js
CHANGED
|
@@ -63,12 +63,14 @@ export async function offerSeats(seats, deps) {
|
|
|
63
63
|
deps.log(` ${strayLine(s)}`);
|
|
64
64
|
if (!offered.length)
|
|
65
65
|
return out;
|
|
66
|
-
for (const s of offered)
|
|
67
|
-
deps.log(` ${seatLine(s)}`);
|
|
68
66
|
if (!deps.tty) {
|
|
69
|
-
deps.log(`
|
|
67
|
+
deps.log(` ${teamsQuestion(offered)}`);
|
|
68
|
+
for (const s of offered)
|
|
69
|
+
deps.log(` ${seatLine(s)}`);
|
|
70
70
|
return out;
|
|
71
71
|
}
|
|
72
|
+
for (const s of offered)
|
|
73
|
+
deps.log(` ${seatLine(s)}`);
|
|
72
74
|
for (const s of offered) {
|
|
73
75
|
const a = ((await deps.ask(` Move your seat in ${s.space} to this machine now? [Y/n] `)) ?? "n").trim().toLowerCase();
|
|
74
76
|
if (a === "" || a === "y" || a === "yes") {
|
|
@@ -87,6 +89,15 @@ export async function offerSeats(seats, deps) {
|
|
|
87
89
|
}
|
|
88
90
|
return out;
|
|
89
91
|
}
|
|
92
|
+
export function listTeams(seats) {
|
|
93
|
+
const n = seats.map((s) => s.space);
|
|
94
|
+
return n.length <= 1 ? (n[0] ?? "") : `${n.slice(0, -1).join(", ")} and ${n[n.length - 1]}`;
|
|
95
|
+
}
|
|
96
|
+
export function teamsQuestion(seats) {
|
|
97
|
+
return seats.length === 1
|
|
98
|
+
? `Ask the person: "You're already in ${seats[0].space}. Bring it to this computer?" (It moves from your other computer.) On a yes, run:`
|
|
99
|
+
: `Ask the person which of these teams this computer should join (each one moves from your other computer); it can be several. Then run the line for each:`;
|
|
100
|
+
}
|
|
90
101
|
export async function startGate(o) {
|
|
91
102
|
const asked = o.asked ?? [];
|
|
92
103
|
const waiting = seatsToMove(o.seats).filter((s) => !o.moved.includes(s.space) && !asked.includes(s.space));
|
|
@@ -112,9 +123,9 @@ export async function startGate(o) {
|
|
|
112
123
|
const how = waiting.map((s) => ` ${recoverCommand(s.space)}`);
|
|
113
124
|
if (!o.tty) {
|
|
114
125
|
return { go: false, code: 1, lines: [
|
|
115
|
-
`not creating a new team:
|
|
126
|
+
`not creating a new team: you're already in ${listTeams(waiting)}. ${teamsQuestion(waiting)}`,
|
|
116
127
|
...how,
|
|
117
|
-
`
|
|
128
|
+
` Only if the person says they want a separate, new team as well: pantheon start --space <the name they give> --new-team (never make a name up, and don't ask for one unless they want a new team)`,
|
|
118
129
|
] };
|
|
119
130
|
}
|
|
120
131
|
const a = ((await o.ask(` Create a new team anyway, instead of moving ${waiting.length === 1 ? "that seat" : "those seats"}? [y/N] `)) ?? "").trim().toLowerCase();
|