@join-pantheon/cli 0.24.0 → 0.24.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.
@@ -0,0 +1,35 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { CONFIG_DIR } from "./config.js";
4
+ const KEEP = 500;
5
+ export function continuedPath(home) {
6
+ return join(home ?? CONFIG_DIR, "continued.json");
7
+ }
8
+ function readAll(home) {
9
+ try {
10
+ const p = continuedPath(home);
11
+ if (!existsSync(p))
12
+ return {};
13
+ const v = JSON.parse(readFileSync(p, "utf8"));
14
+ return v && typeof v === "object" ? v : {};
15
+ }
16
+ catch {
17
+ return {};
18
+ }
19
+ }
20
+ export function loadContinued(space, home) {
21
+ return new Set(readAll(home)[space] ?? []);
22
+ }
23
+ export function markContinued(space, id, home) {
24
+ try {
25
+ const all = readAll(home);
26
+ const list = (all[space] ?? []).filter((x) => x !== id);
27
+ list.push(id);
28
+ all[space] = list.slice(-KEEP);
29
+ const p = continuedPath(home);
30
+ mkdirSync(dirname(p), { recursive: true });
31
+ writeFileSync(p, JSON.stringify(all));
32
+ }
33
+ catch { }
34
+ }
35
+ //# sourceMappingURL=continued.js.map
package/dist/upgrade.js CHANGED
@@ -87,7 +87,11 @@ export function upgrade(deps = defaultDeps()) {
87
87
  catch (e) {
88
88
  steps.push({ name: "wire", ok: false, detail: `could not refresh agent config: ${e.message.split("\n")[0]} (run \`pantheon install --user\`)` });
89
89
  }
90
- const to = deps.npmLatest() ?? "latest";
90
+ const to = deps.version(root);
91
+ if (to === from) {
92
+ steps.push({ name: "check", ok: true, detail: `${from} is the newest the registry serves right now — a version published minutes ago can take a few minutes to appear` });
93
+ return { root, from, to, steps, ok: true, alreadyCurrent: true, restart: [] };
94
+ }
91
95
  const restart = [...deps.running(), "your agent session"];
92
96
  return { root, from, to, steps, ok: true, alreadyCurrent: false, restart };
93
97
  }
package/dist/worker.js CHANGED
@@ -10,6 +10,7 @@ import { applyAnswer, loadPolicy, mayAsk, needsSelfUpgrade, recordAsk, savePolic
10
10
  import { agentHookStates, repairHook } from "./notify.js";
11
11
  import { fence, assess } from "./untrusted.js";
12
12
  import { allowed, recordRun } from "./spend.js";
13
+ import { loadContinued, markContinued } from "./continued.js";
13
14
  import { loadProfile, reservedDecisionsNote } from "./profile.js";
14
15
  import { clip } from "./brief.js";
15
16
  import { composeWorker } from "./notice.js";
@@ -178,6 +179,7 @@ There is no human in this session. Do not ask for approval; you will not get an
178
179
  Act, reply if a reply is owed, then finish.`;
179
180
  }
180
181
  let fleetLock = null;
182
+ const CONTINUATION_HORIZON_MS = 24 * 60 * 60_000;
181
183
  export class Worker {
182
184
  cfg;
183
185
  opts;
@@ -218,6 +220,19 @@ export class Worker {
218
220
  this.cfg = cfg;
219
221
  this.opts = opts;
220
222
  }
223
+ spaceKey() { return this.cfg.spaceId ?? this.cfg.space; }
224
+ contLoaded = false;
225
+ loadContinued() {
226
+ if (this.contLoaded)
227
+ return;
228
+ this.contLoaded = true;
229
+ for (const id of loadContinued(this.spaceKey(), this.opts.home))
230
+ this.contDone.add(id);
231
+ }
232
+ markDone(id) {
233
+ this.contDone.add(id);
234
+ markContinued(this.spaceKey(), id, this.opts.home);
235
+ }
221
236
  async bringMachineAlong() {
222
237
  if (this.opts.selfUpgrade?.run)
223
238
  return;
@@ -459,7 +474,7 @@ export class Worker {
459
474
  this.requeueContinuation(continuation, 10_000);
460
475
  }
461
476
  else {
462
- this.contDone.add(continuation.id);
477
+ this.markDone(continuation.id);
463
478
  if (!this.skipLogged.has(`cont:${continuation.id}`)) {
464
479
  this.skipLogged.add(`cont:${continuation.id}`);
465
480
  this.opts.log(`- not continuing from ${continuation.id}: ${msg.split("\n")[0]}`);
@@ -510,7 +525,7 @@ export class Worker {
510
525
  return this.runJob(client, o, persona, policy, (branch) => buildBrief(o, trigger, branch, persona), true);
511
526
  }
512
527
  async handleContinuation(client, act, persona, policy) {
513
- this.contDone.add(act.id);
528
+ this.markDone(act.id);
514
529
  const o = {
515
530
  id: `cont:${act.id}`, kind: "CONTINUE", owner: this.cfg.member,
516
531
  ref: act.id, goal: act.goal, created_at: act.ts,
@@ -590,19 +605,23 @@ export class Worker {
590
605
  at: Date.now(), goal: o.goal, obligation: o.id, ok,
591
606
  triggeredBy, summary,
592
607
  }, this.opts.home);
593
- if (this.opts.notify && (!ok || loadProfile(this.cfg).notifications?.worker_done)) {
608
+ const sent = client.mineSince(startedAt, o.goal);
609
+ const quiet = ok && !requireReply && sent.length === 0;
610
+ if (this.opts.notify && !quiet && (!ok || loadProfile(this.cfg).notifications?.worker_done)) {
594
611
  try {
595
- const reply = client.mineSince(startedAt, o.goal).pop() ?? null;
612
+ const reply = sent[sent.length - 1] ?? null;
596
613
  this.opts.notify(composeWorker({ ok, triggeredBy, obligationBody: o.body, goal: o.goal ? client.goals.get(o.goal) : undefined, reply, obligationRef: o.ref }, (() => { const tools = installedTools(); return { tools, preferred: preferredTool(loadProfile(this.cfg), tools, this.opts.home) }; })()));
597
614
  }
598
615
  catch { }
599
616
  }
600
- this.opts.log(ok ? `< handled ${o.id} on ${branch}`
601
- : !exited ? `! run failed for ${o.id}: ${detail.split("\n")[0]} (see ${runLog})`
602
- : `! run exited cleanly but sent no act for ${o.id} — see ${runLog}`);
617
+ this.opts.log(quiet ? `< read ${o.id} on ${branch} — the thread was already settled, nothing sent`
618
+ : ok ? `< handled ${o.id} on ${branch}`
619
+ : !exited ? `! run failed for ${o.id}: ${detail.split("\n")[0]} (see ${runLog})`
620
+ : `! run exited cleanly but sent no act for ${o.id} — see ${runLog}`);
603
621
  return { obligation: o, branch, worktree, ok, detail };
604
622
  }
605
623
  enqueueContinuations(client, arrived) {
624
+ this.loadContinued();
606
625
  for (const r of arrived) {
607
626
  if (this.contDone.has(r.id) || this.contQueue.some((c) => c.act.id === r.id))
608
627
  continue;
@@ -613,6 +632,11 @@ export class Worker {
613
632
  ...(g ? { goalMembers: g.members, goalState: g.state } : {}),
614
633
  }))
615
634
  continue;
635
+ if (Date.now() - r.ts > CONTINUATION_HORIZON_MS) {
636
+ this.markDone(r.id);
637
+ this.opts.log(`- not continuing from ${r.act} ${r.id}: it landed ${Math.round((Date.now() - r.ts) / 3_600_000)}h ago — that thread is for a live session to read`);
638
+ continue;
639
+ }
616
640
  this.contQueue.push({ act: r, notBefore: Date.now() });
617
641
  if (this.contQueue.length > 20)
618
642
  this.contQueue.shift();
@@ -638,7 +662,7 @@ export class Worker {
638
662
  ref: r.id, goal: r.goal, created_at: r.ts, body: r.body.slice(0, 120),
639
663
  });
640
664
  if (sel.skip) {
641
- this.contDone.add(r.id);
665
+ this.markDone(r.id);
642
666
  if (!this.skipLogged.has(`cont:${r.id}`)) {
643
667
  this.skipLogged.add(`cont:${r.id}`);
644
668
  this.opts.log(`- not continuing from ${r.act} ${r.id}: ${sel.skip}`);
@@ -689,10 +713,10 @@ export class Worker {
689
713
  result = { ok: false, alreadyCurrent: false, from: VERSION, to: relayPkg ?? "?" };
690
714
  this.opts.log(`! self-upgrade failed: ${e.message}`);
691
715
  }
692
- if (result.ok && !result.alreadyCurrent && result.to === result.from) {
716
+ if (result.ok && result.to === result.from) {
693
717
  delete policy.attempts.self_upgrade;
694
718
  savePolicy(policy, home);
695
- this.opts.log(`* self-upgrade: the registry does not serve ${relayPkg} yet (installed ${result.to}); will check again`);
719
+ this.opts.log(`* self-upgrade: nothing newer than ${result.to} to install yet (the relay runs ${relayPkg}); will check again`);
696
720
  return;
697
721
  }
698
722
  if (result.ok && !result.alreadyCurrent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@join-pantheon/cli",
3
- "version": "0.24.0",
3
+ "version": "0.24.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": {