toolroll 0.9.128 → 0.9.130

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/accent-colors.js +3 -1
  3. package/dist/agent-fence.js +0 -2
  4. package/dist/agents-board.js +0 -3
  5. package/dist/approval-authority.js +2 -1
  6. package/dist/assignment.js +56 -2
  7. package/dist/backup-ui.js +6 -3
  8. package/dist/backup.js +6 -0
  9. package/dist/bounded-spawn.js +0 -1
  10. package/dist/browser/manifest.json +57 -0
  11. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.br +0 -0
  12. package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.gz +0 -0
  13. package/dist/browser/{terminal.css → terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css} +1 -1
  14. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.br +0 -0
  15. package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.gz +0 -0
  16. package/dist/browser/{workspace.js → workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js} +25 -25
  17. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.br +0 -0
  18. package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.gz +0 -0
  19. package/dist/browser/{workspace.css → workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css} +1 -1
  20. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.br +0 -0
  21. package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.gz +0 -0
  22. package/dist/browser-shell.js +271 -25
  23. package/dist/canvas-freshness.js +122 -0
  24. package/dist/canvas-fs.js +273 -0
  25. package/dist/canvas-reads.js +747 -0
  26. package/dist/canvas-state-key.js +45 -0
  27. package/dist/canvas-state-worker.js +12 -0
  28. package/dist/central-recovery-stage.js +3 -3
  29. package/dist/chat-actions.js +26 -0
  30. package/dist/chat-channel.js +4 -3
  31. package/dist/chat-task-actions.js +1 -1
  32. package/dist/chat-warmth.js +0 -1
  33. package/dist/check-report.js +0 -6
  34. package/dist/commit-extract.js +79 -40
  35. package/dist/companion/access.js +162 -0
  36. package/dist/companion/actions.js +622 -0
  37. package/dist/companion/bonjour.js +45 -0
  38. package/dist/companion/canvas.js +141 -0
  39. package/dist/companion/chat-origin.js +92 -0
  40. package/dist/companion/chat.js +571 -0
  41. package/dist/companion/daemon.js +1387 -0
  42. package/dist/companion/direct-server.js +177 -0
  43. package/dist/companion/finish.js +51 -0
  44. package/dist/companion/framing.js +498 -0
  45. package/dist/companion/noise.js +461 -0
  46. package/dist/companion/passkey-gate.js +287 -0
  47. package/dist/companion/paths.js +90 -0
  48. package/dist/companion/reads.js +283 -0
  49. package/dist/companion/relay-auth.js +265 -0
  50. package/dist/companion/relay-server.js +870 -0
  51. package/dist/companion/schema.js +289 -0
  52. package/dist/companion/service.js +581 -0
  53. package/dist/companion/store.js +325 -0
  54. package/dist/companion/webauthn.js +407 -0
  55. package/dist/console-instance.js +0 -4
  56. package/dist/contracts/console-api.js +18 -0
  57. package/dist/converse.js +0 -1
  58. package/dist/coordinator.js +1 -1
  59. package/dist/design/kit.css +30 -0
  60. package/dist/desktop-config.js +156 -0
  61. package/dist/desktop-host.js +6 -152
  62. package/dist/desktop-update.js +1 -1
  63. package/dist/finished-task-sql.js +14 -0
  64. package/dist/flexible-answers.js +0 -1
  65. package/dist/github-read.js +41 -0
  66. package/dist/guides.js +4 -3
  67. package/dist/lead-doors.js +50 -3
  68. package/dist/lead-queue-runtime.js +11 -2
  69. package/dist/lead-queue.js +25 -0
  70. package/dist/live-backup-change.js +93 -0
  71. package/dist/live-backup.js +75 -31
  72. package/dist/live-bus.js +3 -2
  73. package/dist/live-records.js +0 -1
  74. package/dist/local-landing.js +47 -0
  75. package/dist/local-owner.js +0 -1
  76. package/dist/model-choices.js +0 -11
  77. package/dist/nightly-check.js +0 -3
  78. package/dist/nightly-github.js +1 -2
  79. package/dist/notification-retention.js +119 -0
  80. package/dist/observations.js +0 -1
  81. package/dist/operate.js +17 -4
  82. package/dist/person-proof.js +5 -1
  83. package/dist/pull-request-flow.js +116 -2
  84. package/dist/qr.js +360 -0
  85. package/dist/release-adapters.js +14 -43
  86. package/dist/release-auto.js +17 -13
  87. package/dist/release-card.js +0 -4
  88. package/dist/release-cli.js +37 -2
  89. package/dist/release.js +13 -2
  90. package/dist/restore-retirement.js +6 -1
  91. package/dist/result-review.js +0 -3
  92. package/dist/retention-ui.js +1 -1
  93. package/dist/retention.js +14 -21
  94. package/dist/review-context.js +0 -5
  95. package/dist/route-rules.js +1 -5
  96. package/dist/sandbox-runtime.js +0 -1
  97. package/dist/scope.js +68 -17
  98. package/dist/scout.js +0 -6
  99. package/dist/serve.js +60 -9
  100. package/dist/server/kit.js +1 -0
  101. package/dist/server/live.js +9 -2
  102. package/dist/server/pages.js +12 -4
  103. package/dist/server/phone-engine-api.js +79 -0
  104. package/dist/server/render-pages.js +1 -11
  105. package/dist/server/render-results.js +0 -1
  106. package/dist/server/render-tasks.js +0 -68
  107. package/dist/server/route-table.js +12 -1
  108. package/dist/server/settings-phone.js +515 -0
  109. package/dist/server/settings-scripts.js +2 -0
  110. package/dist/server/settings-section-table.js +0 -3
  111. package/dist/server/settings-sections.js +10 -4
  112. package/dist/server/settings.js +20 -5
  113. package/dist/server/terminals.js +2 -1
  114. package/dist/settings-groups-ui.js +2 -1
  115. package/dist/settings-proofs.js +6 -0
  116. package/dist/store.js +52 -4
  117. package/dist/structured-output.js +0 -1
  118. package/dist/style-asset.js +20 -7
  119. package/dist/tailnet.js +39 -0
  120. package/dist/task-control.js +5 -0
  121. package/dist/task-sizing.js +0 -1
  122. package/dist/toolroll-update-cli.js +19 -3
  123. package/dist/toolroll-update-ui.js +2 -2
  124. package/dist/toolroll-update.js +98 -16
  125. package/dist/youiyoux-intake.js +8 -0
  126. package/package.json +7 -2
  127. package/dist/contracts/contract-test.js +0 -55
  128. package/dist/unfenced-test-support.js +0 -6
  129. /package/dist/browser/{terminal.js → terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js} +0 -0
@@ -5,7 +5,7 @@ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
5
5
  import { Worker } from "node:worker_threads";
6
6
  import { checkBackupFolder, databaseTag } from "./backup.js";
7
7
  import { holdLiveBackup, liveBackupState, recordLiveBackup, releaseLiveBackup } from "./store.js";
8
- export const LIVE_EVERY_MINUTES = [1, 5, 15, 30];
8
+ import { LIVE_FULL_CHECK_EVERY_MS, liveCheckOf, MARKER_SOURCE, markerOffThread, newLiveCopyMemory, QUICK_SUFFIX } from "./live-backup-change.js";
9
9
  export const LIVE_DAILY_DAYS = 7;
10
10
  const LEASE_MS = 15 * 60_000;
11
11
  export function defaultLiveFolder(databaseFile) {
@@ -58,7 +58,7 @@ export function liveFolderProblem(folder, forbidden, protectedRoot) {
58
58
  return `${folder} goes through a link; choose its real path (${real}).`;
59
59
  return null;
60
60
  }
61
- const NAME = (tag) => new RegExp(`^live-${tag}-(\\d{4}-\\d{2}-\\d{2})-(\\d{6})(?:-(\\d+))?\\.db$`);
61
+ const NAME = (tag) => new RegExp(`^live-${tag}-(\\d{4}-\\d{2}-\\d{2})-(\\d{6})(?:-(\\d+))?(?:\\.quick)?\\.db$`);
62
62
  const PARTIAL = (tag) => new RegExp(`^\\.live-${tag}-.*\\.partial$`);
63
63
  const stampOf = (now) => now.toISOString().replace(/\.\d+Z$/, "").replace("T", "-").replace(/:/g, "");
64
64
  export function liveCopies(folder, tag) {
@@ -81,8 +81,12 @@ export function liveCopies(folder, tag) {
81
81
  catch {
82
82
  return [];
83
83
  }
84
- return [{ name, path: join(folder, name), day: m[1], order: `${m[1]}-${m[2]}-${(m[3] ?? "1").padStart(6, "0")}` }];
85
- }).sort((a, b) => a.order < b.order ? 1 : a.order > b.order ? -1 : 0).map(({ name, path, day }) => ({ name, path, day }));
84
+ const time = m[2], madeAt = `${m[1]}T${time.slice(0, 2)}:${time.slice(2, 4)}:${time.slice(4, 6)}.000Z`;
85
+ return [{ name, path: join(folder, name), day: m[1], check: liveCheckOf(name), madeAt, order: `${m[1]}-${m[2]}-${(m[3] ?? "1").padStart(6, "0")}` }];
86
+ }).sort((a, b) => a.order < b.order ? 1 : a.order > b.order ? -1 : 0).map(({ name, path, day, check, madeAt }) => ({ name, path, day, check, madeAt }));
87
+ }
88
+ export function lastFullCheckAt(folder, tag) {
89
+ return liveCopies(folder, tag).find(one => one.check === "integrity")?.madeAt ?? null;
86
90
  }
87
91
  export function pruneLiveCopies(folder, tag, keep, now, protect) {
88
92
  const copies = liveCopies(folder, tag);
@@ -94,8 +98,9 @@ export function pruneLiveCopies(folder, tag, keep, now, protect) {
94
98
  days.add(one.day);
95
99
  kept.add(one.path);
96
100
  }
97
- if (protect !== null)
98
- kept.add(resolve(protect));
101
+ for (const one of typeof protect === "string" || protect === null ? [protect] : protect)
102
+ if (one !== null)
103
+ kept.add(resolve(one));
99
104
  let removed = 0;
100
105
  for (const one of copies)
101
106
  if (!kept.has(one.path)) {
@@ -119,8 +124,9 @@ const COPY_THREAD = `
119
124
  const { workerData, parentPort } = require("node:worker_threads");
120
125
  const { DatabaseSync, backup } = require("node:sqlite");
121
126
  const fs = require("node:fs"), crypto = require("node:crypto"), path = require("node:path");
127
+ ${MARKER_SOURCE}
122
128
  (async () => {
123
- const { source, partial, target } = workerData;
129
+ const { source, partial, target, check } = workerData;
124
130
  try {
125
131
  const db = new DatabaseSync(source);
126
132
  db.exec("PRAGMA busy_timeout = 5000");
@@ -129,29 +135,32 @@ const fs = require("node:fs"), crypto = require("node:crypto"), path = require("
129
135
  try { await backup(db, partial, { rate: 1000000 }); } finally { db.close(); }
130
136
  fs.chmodSync(partial, 0o600);
131
137
  const copy = new DatabaseSync(partial);
132
- let schemaVersion;
138
+ let schemaVersion, marker;
133
139
  try {
134
140
  copy.exec("PRAGMA journal_mode = DELETE");
135
- const check = copy.prepare("PRAGMA integrity_check").all();
136
- if (check.length !== 1 || check[0].integrity_check !== "ok") throw new Error("the copy failed SQLite's integrity check");
141
+ const pragma = check === "integrity" ? "integrity_check" : "quick_check";
142
+ const answer = copy.prepare("PRAGMA " + pragma).all();
143
+ if (answer.length !== 1 || answer[0][pragma] !== "ok") throw new Error(check === "integrity" ? "the copy failed SQLite's integrity check" : "the copy failed SQLite's quick check");
137
144
  schemaVersion = Number(copy.prepare("SELECT version FROM schema_version").get()?.version);
138
145
  if (!Number.isSafeInteger(schemaVersion) || schemaVersion < 1) throw new Error("the copy has no settled schema version");
146
+ // A marker that can't be read (no dbstat in this SQLite) only means the next pass copies again.
147
+ try { marker = backupMarker(copy, crypto); } catch { marker = null; }
139
148
  } finally { copy.close(); }
140
149
  const hash = crypto.createHash("sha256"), buffer = Buffer.alloc(1 << 20), fd = fs.openSync(partial, "r");
141
150
  try { let n; while ((n = fs.readSync(fd, buffer, 0, buffer.length, null)) > 0) hash.update(buffer.subarray(0, n)); fs.fsyncSync(fd); } finally { fs.closeSync(fd); }
142
151
  fs.renameSync(partial, target);
143
152
  const dir = fs.openSync(path.dirname(target), "r");
144
153
  try { fs.fsyncSync(dir); } finally { fs.closeSync(dir); }
145
- parentPort.postMessage({ ok: true, sha256: hash.digest("hex"), bytes: fs.statSync(target).size, schemaVersion });
154
+ parentPort.postMessage({ ok: true, sha256: hash.digest("hex"), bytes: fs.statSync(target).size, schemaVersion, marker });
146
155
  } catch (error) {
147
156
  try { fs.rmSync(partial, { force: true }); } catch {}
148
157
  parentPort.postMessage({ ok: false, problem: String((error && error.message) || error).slice(0, 300) });
149
158
  }
150
159
  })();
151
160
  `;
152
- export function copyOffThread(source, folder, tag, now) {
153
- const stamp = stampOf(now);
154
- let name = `live-${tag}-${stamp}.db`;
161
+ export function copyOffThread(source, folder, tag, now, check = "integrity") {
162
+ const stamp = stampOf(now), end = check === "quick" ? QUICK_SUFFIX : ".db";
163
+ let name = `live-${tag}-${stamp}${end}`;
155
164
  for (let n = 2; (() => { try {
156
165
  lstatSync(join(folder, name));
157
166
  return true;
@@ -159,59 +168,93 @@ export function copyOffThread(source, folder, tag, now) {
159
168
  catch {
160
169
  return false;
161
170
  } })(); n++)
162
- name = `live-${tag}-${stamp}-${n}.db`;
171
+ name = `live-${tag}-${stamp}-${n}${end}`;
163
172
  const target = join(folder, name), partial = join(folder, `.live-${tag}-${stamp}.${randomBytes(4).toString("hex")}.partial`);
164
173
  return new Promise(done => {
165
- const thread = new Worker(COPY_THREAD, { eval: true, workerData: { source, partial, target } });
174
+ const thread = new Worker(COPY_THREAD, { eval: true, workerData: { source, partial, target, check } });
166
175
  let settled = false;
167
176
  const finish = (answer) => { if (!settled) {
168
177
  settled = true;
169
178
  done(answer);
170
179
  } };
171
180
  thread.once("message", (message) => finish(message.ok
172
- ? { ok: true, copy: { file: target, sha256: String(message.sha256), bytes: Number(message.bytes), schemaVersion: Number(message.schemaVersion) } }
181
+ ? { ok: true, check, marker: typeof message.marker === "string" ? message.marker : null, copy: { file: target, sha256: String(message.sha256), bytes: Number(message.bytes), schemaVersion: Number(message.schemaVersion) } }
173
182
  : { ok: false, problem: message.problem ?? "the copy failed" }));
174
183
  thread.once("error", (error) => { rmSync(partial, { force: true }); finish({ ok: false, problem: String(error.message).slice(0, 300) }); });
175
184
  thread.once("exit", () => finish({ ok: false, problem: "the copy stopped before it finished" }));
176
185
  });
177
186
  }
178
- export function liveCopyDue(store, now) {
187
+ export function liveCopyDue(store, now, memory) {
179
188
  const state = liveBackupState(store);
180
189
  if (!state.settings.enabled)
181
190
  return false;
182
191
  const every = state.settings.everyMinutes * 60_000;
183
- const last = Math.max(state.latest === null ? 0 : Date.parse(state.latest.madeAt), state.triedAt === null ? 0 : Date.parse(state.triedAt));
192
+ const last = Math.max(state.latest === null ? 0 : Date.parse(state.latest.madeAt), state.triedAt === null ? 0 : Date.parse(state.triedAt), memory?.lookedAt ?? 0);
184
193
  return !Number.isFinite(last) || now.getTime() - last >= every;
185
194
  }
186
- export async function liveBackupPass(store, databaseFile, holder, forbidden, clock = () => new Date()) {
195
+ function stillCovers(covered, folder, tag) {
196
+ if (covered === null || liveCopies(folder, tag)[0]?.path !== covered.file)
197
+ return false;
198
+ try {
199
+ const stat = lstatSync(covered.file);
200
+ return stat.isFile() && stat.size === covered.bytes;
201
+ }
202
+ catch {
203
+ return false;
204
+ }
205
+ }
206
+ function noteQuickCopy(store, now) {
207
+ store.handle.prepare("UPDATE live_backup SET tried_at = ?, problem = NULL WHERE id = 1").run(now.toISOString());
208
+ }
209
+ export async function liveBackupPass(store, databaseFile, holder, forbidden, clock = () => new Date(), memory = newLiveCopyMemory()) {
187
210
  const now = clock();
188
- if (!liveCopyDue(store, now))
211
+ if (!liveCopyDue(store, now, memory))
189
212
  return null;
213
+ const tag = databaseTag(databaseFile), protectedRoot = dirname(defaultLiveFolder(databaseFile));
214
+ const before = liveBackupState(store);
215
+ const folder = liveFolderOf(before.settings, databaseFile);
216
+ const usable = liveFolderProblem(folder, forbidden(), protectedRoot) === null;
217
+ const lastFull = usable ? lastFullCheckAt(folder, tag) : null;
218
+ const fullAge = lastFull === null ? NaN : now.getTime() - Date.parse(lastFull);
219
+ const fullDue = !(fullAge >= 0 && fullAge < LIVE_FULL_CHECK_EVERY_MS);
220
+ if (usable && !fullDue && stillCovers(memory.covered, folder, tag)) {
221
+ const covered = memory.covered;
222
+ memory.lookedAt = now.getTime();
223
+ const seen = await markerOffThread(databaseFile);
224
+ if (seen.ok && seen.marker === covered.marker)
225
+ return { ok: true, unchanged: true, file: covered.file };
226
+ }
190
227
  if (!holdLiveBackup(store, holder, now, new Date(now.getTime() + LEASE_MS)))
191
228
  return null;
192
229
  try {
193
230
  const state = liveBackupState(store);
194
- const folder = liveFolderOf(state.settings, databaseFile);
231
+ const at = liveFolderOf(state.settings, databaseFile);
195
232
  const fail = (problem) => { recordLiveBackup(store, { ok: false, problem }, clock()); return { ok: false, problem }; };
196
- let problem = liveFolderProblem(folder, forbidden(), dirname(defaultLiveFolder(databaseFile)));
233
+ let problem = liveFolderProblem(at, forbidden(), protectedRoot);
197
234
  if (problem !== null)
198
235
  return fail(problem);
199
236
  try {
200
- mkdirSync(folder, { recursive: true, mode: 0o700 });
237
+ mkdirSync(at, { recursive: true, mode: 0o700 });
201
238
  }
202
239
  catch (error) {
203
- return fail(`${folder} couldn't be made (${error.message})`);
240
+ return fail(`${at} couldn't be made (${error.message})`);
204
241
  }
205
- problem = liveFolderProblem(folder, forbidden(), dirname(defaultLiveFolder(databaseFile)));
242
+ problem = liveFolderProblem(at, forbidden(), protectedRoot);
206
243
  if (problem !== null)
207
244
  return fail(problem);
208
- const made = await copyOffThread(databaseFile, folder, databaseTag(databaseFile), now);
245
+ const full = at !== folder || fullDue || lastFullCheckAt(at, tag) === null;
246
+ const made = await copyOffThread(databaseFile, at, tag, now, full ? "integrity" : "quick");
209
247
  if (!made.ok)
210
248
  return fail(made.problem);
211
249
  const copy = { ...made.copy, madeAt: now.toISOString() };
212
- recordLiveBackup(store, { ok: true, copy }, clock());
213
- pruneLiveCopies(folder, databaseTag(databaseFile), state.settings.keep, clock(), copy.file);
214
- return { ok: true, copy };
250
+ if (made.check === "integrity")
251
+ recordLiveBackup(store, { ok: true, copy }, clock());
252
+ else
253
+ noteQuickCopy(store, clock());
254
+ memory.covered = made.marker === null ? null : { file: copy.file, bytes: copy.bytes, marker: made.marker };
255
+ memory.lookedAt = now.getTime();
256
+ pruneLiveCopies(at, tag, state.settings.keep, clock(), [copy.file, liveBackupState(store).latest?.file ?? null]);
257
+ return { ok: true, copy, check: made.check };
215
258
  }
216
259
  finally {
217
260
  releaseLiveBackup(store, holder);
@@ -219,11 +262,12 @@ export async function liveBackupPass(store, databaseFile, holder, forbidden, clo
219
262
  }
220
263
  export function startLiveBackups(store, databaseFile, forbidden, everyMs = 60_000) {
221
264
  const holder = `${hostname()}:${process.pid}:${randomUUID().slice(0, 8)}`;
265
+ const memory = newLiveCopyMemory();
222
266
  let stopped = false, timer = null, running = Promise.resolve();
223
267
  const pass = () => {
224
268
  if (stopped)
225
269
  return;
226
- running = liveBackupPass(store, databaseFile, holder, forbidden).catch(() => null).finally(() => {
270
+ running = liveBackupPass(store, databaseFile, holder, forbidden, () => new Date(), memory).catch(() => null).finally(() => {
227
271
  if (!stopped) {
228
272
  timer = setTimeout(pass, everyMs);
229
273
  timer.unref?.();
package/dist/live-bus.js CHANGED
@@ -271,6 +271,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
271
271
  const safetyNetMs = options.safetyNetMs ?? SAFETY_NET_MS;
272
272
  const minIntervalMs = options.minIntervalMs ?? 0;
273
273
  const readSettleMs = options.readSettleMs ?? 0;
274
+ const frameOf = options.frame ?? ((at) => ({ at }));
274
275
  const rooms = new Map();
275
276
  let unsubscribe = null;
276
277
  const announce = (key, room) => {
@@ -384,7 +385,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
384
385
  const say = (key, room) => {
385
386
  room.saidAt = Date.now();
386
387
  for (const viewer of [...room.viewers.keys()])
387
- deliver(key, room, viewer, "change", { at: room.last, revision: room.revision }, room.lastOrder || undefined);
388
+ deliver(key, room, viewer, "change", { ...frameOf(room.last), revision: room.revision }, room.lastOrder || undefined);
388
389
  };
389
390
  const heard = (change) => {
390
391
  for (const [key, room] of [...rooms]) {
@@ -422,7 +423,7 @@ export function createLiveRooms(fingerprint, presence, options = {}) {
422
423
  const forget = viewer.connection.onClose(() => leave(key, viewer));
423
424
  const unprove = viewer.connection.onKeepAlive(() => { deliver(key, joined, viewer); });
424
425
  room.viewers.set(viewer, () => { forget(); unprove(); });
425
- if (!deliver(key, room, viewer, "change", { at: room.last, revision: bus?.revision() ?? null }, room.lastOrder || undefined) || presence === null)
426
+ if (!deliver(key, room, viewer, "change", { ...frameOf(room.last), revision: bus?.revision() ?? null }, room.lastOrder || undefined) || presence === null)
426
427
  return;
427
428
  if (deliver(key, room, viewer, "here", { people: presence([...room.viewers.keys()], viewer.name) }, room.order = liveOrderAfter(room.order)))
428
429
  announce(key, room);
@@ -264,7 +264,6 @@ function liveHost(given) {
264
264
  }
265
265
  }
266
266
  const short = (given) => (typeof given === "string" ? liveTarget(given.split(/\r?\n/)[0] ?? "", SHORT_CAP) : null);
267
- export const liveShort = short;
268
267
  const CLAUDE_KINDS = new Map([
269
268
  ["Edit", "edit"], ["Write", "edit"], ["MultiEdit", "edit"], ["NotebookEdit", "edit"],
270
269
  ["Bash", "command"], ["Read", "read"], ["LS", "read"], ["Glob", "search"], ["Grep", "search"],
@@ -12,8 +12,12 @@ import { localActNow, LOCAL_OWNER_LAPSED } from "./local-owner.js";
12
12
  import { publishingOf } from "./pull-request-flow.js";
13
13
  import { readGit, wholeChangeBaseOf } from "./task-base.js";
14
14
  import { catchUpConflictOf } from "./revision-catch-up.js";
15
+ import { checkPasskeyAction, consumePasskeyAction } from "./companion/passkey-gate.js";
16
+ import { passkeyProofDetail } from "./companion/webauthn.js";
17
+ import { deviceAccountStands, getPairedDevice } from "./companion/store.js";
15
18
  export const LAND_DESTINATION = "land destination";
16
19
  export const LAND_INTENT = "land intent";
20
+ export const LAND_PROVED_ACTION = "land proved";
17
21
  export const LAND_SETTLED = "land settled";
18
22
  export const LAND_HANDOFF = "land handoff";
19
23
  export const LAND_HANDOFF_SETTLED = "land handoff settled";
@@ -444,6 +448,14 @@ function standing(store, authority, repo) {
444
448
  const proved = reproveApprover(store, authority.who);
445
449
  if (!proved.ok || !authority.who.repos.includes(repo) || !store.accountCanAccess(authority.who.name, repo))
446
450
  return refuse("authority", "Your access changed. Sign in again.");
451
+ if (authority.kind === "passkey") {
452
+ const dev = getPairedDevice(store.handle, authority.proof.deviceId);
453
+ const identity = store.workspaceIdentity();
454
+ if (dev === null || dev.revokedAt !== null || dev.activatedAt === null || dev.accountName !== authority.who.name
455
+ || dev.recoveryGeneration !== identity.recoveryGeneration || !deviceAccountStands(dev, store.accountOf(authority.who.name))) {
456
+ return refuse("authority", "This iPhone is no longer paired or your account changed.");
457
+ }
458
+ }
447
459
  return { ok: true, actor: `operator:${authority.who.name}` };
448
460
  }
449
461
  const projectLocks = new Map();
@@ -548,6 +560,39 @@ export async function land(store, taskId, input, authority, access, now, options
548
560
  const pre = standing(store, authority, plan.repo);
549
561
  if (!pre.ok)
550
562
  return pre;
563
+ const landBinding = { verb: "land", taskId, planKey: plan.key, into: input.into ?? null, undo: input.undo === true };
564
+ const passkeyChecked = authority.kind !== "passkey" ? null
565
+ : checkPasskeyAction(store, { accountName: authority.who.name, repo: plan.repo, verb: "land", expectedBinding: landBinding, proof: authority.proof, now });
566
+ if (passkeyChecked !== null && !passkeyChecked.ok)
567
+ return refuse("authority", passkeyChecked.message);
568
+ const consumeLandPasskey = () => {
569
+ if (authority.kind !== "passkey" || passkeyChecked === null || !passkeyChecked.ok)
570
+ return;
571
+ const at = authority.clock();
572
+ const consumed = consumePasskeyAction(store, passkeyChecked, { repo: plan.repo, now: at });
573
+ if (!consumed.ok)
574
+ throw new Refused(refuse("authority", consumed.message));
575
+ store.recordAction({
576
+ at: at.toISOString(),
577
+ actor: authority.who.name,
578
+ repo: plan.repo,
579
+ taskId: plan.rootId,
580
+ runId: plan.runId,
581
+ action: LAND_PROVED_ACTION,
582
+ outcome: "passkey",
583
+ source: "request",
584
+ detail: passkeyProofDetail({
585
+ at,
586
+ generation: consumed.accountGeneration,
587
+ digest: plan.key,
588
+ verb: "land",
589
+ credentialId: consumed.credentialId,
590
+ pairedDeviceId: consumed.deviceId,
591
+ be: consumed.be,
592
+ bs: consumed.bs,
593
+ }),
594
+ });
595
+ };
551
596
  const made = plan.kind === "undo" ? await revertCommit(git, plan, options.scratch) : await squashCommit(git, plan, options.scratch);
552
597
  if (!made.ok)
553
598
  return made;
@@ -573,6 +618,7 @@ export async function land(store, taskId, input, authority, access, now, options
573
618
  replayed = earlier.settled;
574
619
  return earlier.id;
575
620
  }
621
+ consumeLandPasskey();
576
622
  if (!plan.recorded)
577
623
  recordActionWhole(store.handle, { at: now.toISOString(), actor: who.actor, repo: plan.repo, taskId: null, runId: null, action: LAND_DESTINATION, outcome: plan.ref, source: "request" }, { v: 1, ref: plan.ref, common: project.common });
578
624
  return recordActionWhole(store.handle, { at: now.toISOString(), actor: who.actor, repo: plan.repo, taskId: plan.rootId, runId: plan.runId, action: LAND_HANDOFF, outcome: "pending", source: "request" }, { v: 1, key: plan.key, ref: plan.ref, old: plan.old, commit, keep, folder: project.repo, policy: "squash", candidate: plan.candidate, base: plan.squash.base, tree: plan.squash.tree,
@@ -601,6 +647,7 @@ export async function land(store, taskId, input, authority, access, now, options
601
647
  throw new Refused(who);
602
648
  if (intents(store, "repo = ?", [plan.repo]).some(one => settledOf(store, one.id) === null))
603
649
  throw new Refused(refuse("busy", "Another landing in this project hasn't finished. Try again in a moment."));
650
+ consumeLandPasskey();
604
651
  if (!plan.recorded)
605
652
  recordActionWhole(store.handle, { at: now.toISOString(), actor: who.actor, repo: plan.repo, taskId: null, runId: null, action: LAND_DESTINATION, outcome: plan.ref, source: "request" }, { v: 1, ref: plan.ref, common: project.common });
606
653
  return recordActionWhole(store.handle, { at: now.toISOString(), actor: who.actor, repo: plan.repo, taskId: plan.rootId, runId: plan.runId, action: LAND_INTENT, outcome: "pending", source: "request" }, { v: 1, kind: plan.kind, key: plan.key, ref: plan.ref, old: plan.old, commit, mode: "ref", ...(plan.reverts === undefined ? {} : { reverts: plan.reverts.source }),
@@ -1,7 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { currentActor } from "./actor.js";
3
3
  import { activeRemote } from "./remote-run.js";
4
- export const AUTHORITIES = Object.freeze(["full", "local-owner"]);
5
4
  export function authorityOf(value) {
6
5
  return value === "full" || value === "local-owner" ? value : null;
7
6
  }
@@ -17,9 +17,6 @@ export const ALL_SLOTS = Object.freeze([
17
17
  ]);
18
18
  const order = (slot) => ALL_SLOTS.findIndex(one => one.phase === slot.phase && one.tier === slot.tier);
19
19
  export const slotKey = (slot) => slot.tier === "routine" ? slot.phase : `${slot.phase}-${slot.tier}`;
20
- export function slotOf(key) {
21
- return SLOTS.find(one => slotKey(one) === key) ?? null;
22
- }
23
20
  export function slotWords(slot) {
24
21
  if (slot.phase === "build")
25
22
  return slot.tier === "light" ? "Builder for small tasks" : slot.tier === "strong" ? "Builder for large or risky tasks" : "Builder for routine tasks";
@@ -41,10 +38,6 @@ export function stateDigest(store, scope) {
41
38
  });
42
39
  return sha({ scope, installation: rows(INSTALLATION_SCOPE), project: scope === INSTALLATION_SCOPE ? null : rows(scope) });
43
40
  }
44
- export function changeDigest(scope, change) {
45
- const ordered = [...change].sort((a, b) => order(a.slot) - order(b.slot));
46
- return sha({ scope, change: ordered.map(one => [slotKey(one.slot), one.to === null ? null : [one.to.provider, one.to.model]]) });
47
- }
48
41
  export function diffDigest(scope, diff) {
49
42
  return sha({ scope, diff: diff.map(row => [slotKey(row.slot), row.before, row.after]) });
50
43
  }
@@ -220,10 +213,6 @@ export function browserWords(problem) {
220
213
  const said = problem.split(" — ")[0].replace(/`[^`]*`/g, "").replace(/\s+([:;,.])/g, "$1").replace(/\s{2,}/g, " ").trim();
221
214
  return said.length === 0 ? "This choice can't run." : `${said.charAt(0).toUpperCase()}${said.slice(1)}${/[.!?]$/.test(said) ? "" : "."}`;
222
215
  }
223
- export function scopeProblem(store, repo) {
224
- const checked = checkScope(store, repo);
225
- return checked.kind === "ok" ? null : checked.problem;
226
- }
227
216
  const pairWords = (pair) => pair === null ? "not set" : `${pair.provider} · ${pair.model ?? "its default model"}`;
228
217
  const ACTION_OF = (slot) => slot.tier === "routine" ? `agent for ${slot.phase} changed` : `${slot.tier} agent for ${slot.phase} changed`;
229
218
  export function applyModelChoices(store, input, authority, now) {
@@ -286,6 +286,3 @@ export function nightlyHealthWords(store, repo, configuredAt, now) {
286
286
  return last === undefined ? `the nightly check hasn't run since it was set up (${since.slice(0, 16).replace("T", " ")})` : `the nightly check hasn't run since ${since.slice(0, 16).replace("T", " ")}`;
287
287
  }
288
288
  export { fileIdentity, groupIdentity, journeyIdentity, unitIdentity, versionIdentity };
289
- export function openMainFailureItems(store, repo) {
290
- return store.handle.prepare("SELECT DISTINCT item FROM main_check_failure WHERE repo = ? AND cleared_at IS NULL ORDER BY item").all(repo).map(row => String(row["item"]));
291
- }
@@ -25,7 +25,6 @@ const LANE_PREFIX = {
25
25
  };
26
26
  const AGGREGATE = /^node (\d+) · (ubuntu|macos)-latest$/;
27
27
  export const SHARDS_PASSED_STEP = "Every shard passed";
28
- export const SHARDS_COVERED_STEP = "Every shard ran the whole suite";
29
28
  const object = (value) => (value !== null && typeof value === "object" && !Array.isArray(value) ? value : null);
30
29
  const isoOf = (value) => {
31
30
  if (typeof value !== "string" || value === "")
@@ -834,7 +833,7 @@ export async function refreshNightlyForDeploy(store, input) {
834
833
  const at = input.now();
835
834
  try {
836
835
  const gh = input.gh ?? await (async () => {
837
- const [{ exec, githubReads }, { releaseTools }] = await Promise.all([import("./release-adapters.js"), import("./release-git.js")]);
836
+ const [{ exec, githubReads }, { releaseTools }] = await Promise.all([import("./github-read.js"), import("./release-git.js")]);
838
837
  return githubReads(exec, releaseTools().gh);
839
838
  })();
840
839
  const deps = { ...mainHistoryOf(store, repo, at), gh, now: input.now };
@@ -0,0 +1,119 @@
1
+ import { finishedTask } from "./finished-task-sql.js";
2
+ import { LIFECYCLE_KEY_PREFIX, LIFECYCLE_KINDS } from "./notification-rows.js";
3
+ export const LIFECYCLE_RETENTION_DAYS = 30;
4
+ export const NOTIFICATION_SWEEP_BATCH = 2000;
5
+ export const LEGACY_DESTINATION = "legacy:single-destination";
6
+ export const LEGACY_SETTLED_RECEIPT = "skipped:legacy-undeliverable";
7
+ export const NOTIFICATION_RETENTION_CATEGORIES = Object.freeze({
8
+ "lifecycle-ping": { days: LIFECYCLE_RETENTION_DAYS, words: "progress updates (task filed, build started, phase, finished…) once delivered and their task is finished" },
9
+ "legacy-delivery": { days: LIFECYCLE_RETENTION_DAYS, words: "old single-destination delivery records that can never be delivered" },
10
+ });
11
+ export const NOTIFICATION_RETENTION_WORDS = `Progress updates and undeliverable old delivery records go after ${LIFECYCLE_RETENTION_DAYS} days once settled, whatever this says.`;
12
+ const KINDS = LIFECYCLE_KINDS.map(kind => `'${kind}'`).join(", ");
13
+ const LIFECYCLE_PING = (n) => `(${n}.kind IN (${KINDS})
14
+ AND substr(${n}.dedupe_key, 1, length('${LIFECYCLE_KEY_PREFIX}' || ${n}.kind || ':')) = '${LIFECYCLE_KEY_PREFIX}' || ${n}.kind || ':'
15
+ AND length(${n}.dedupe_key) - length(replace(${n}.dedupe_key, ':', '')) = 3
16
+ AND rtrim(${n}.dedupe_key, '0123456789') <> ${n}.dedupe_key AND substr(rtrim(${n}.dedupe_key, '0123456789'), -1) = ':')`;
17
+ export const UNDER_LIFECYCLE_KEY = (n) => `substr(${n}.dedupe_key, 1, ${LIFECYCLE_KEY_PREFIX.length}) = '${LIFECYCLE_KEY_PREFIX}'`;
18
+ const FAMILY = (n) => `rtrim(${n}.dedupe_key, '0123456789')`;
19
+ const UNSETTLED = (d) => `((${d}.delivered_at IS NULL AND (${d}.receipt IS NULL OR ${d}.receipt NOT LIKE 'skipped:%'))
20
+ OR (${d}.claim_owner IS NOT NULL AND ${d}.claim_expires_at > :now))`;
21
+ const PING_MAY_GO = (n, outbound) => `(${LIFECYCLE_PING(n)} AND ${n}.created_at < :cutoff
22
+ AND NOT EXISTS (SELECT 1 FROM notification_delivery d WHERE d.notification = ${n}.id AND ${UNSETTLED("d")})
23
+ AND (EXISTS (SELECT 1 FROM notification_delivery d WHERE d.notification = ${n}.id)
24
+ OR NOT EXISTS (SELECT 1 FROM chat_binding b WHERE b.revoked IS NULL))
25
+ AND NOT EXISTS (SELECT 1 FROM push_delivery p WHERE p.notification = ${n}.id AND p.state IN ('pending', 'claimed'))
26
+ AND ${n}.id NOT IN (SELECT i.notification FROM chat_batch_item i JOIN chat_batch b ON b.id = i.batch WHERE i.notification IS NOT NULL AND b.opened_at >= :cutoff)
27
+ ${outbound ? `AND ${n}.id NOT IN (SELECT o.notification FROM telegram_outbound_message o)` : ""}
28
+ AND (${n}.task_ref IS NULL OR ${n}.task_ref IN (SELECT value FROM json_each(:finished))))`;
29
+ function finishedRefs(store, cutoff, only) {
30
+ const among = only === undefined
31
+ ? `SELECT DISTINCT n.task_ref FROM notification n WHERE substr(n.dedupe_key, 1, ${LIFECYCLE_KEY_PREFIX.length}) = '${LIFECYCLE_KEY_PREFIX}' AND n.created_at < :cutoff AND n.task_ref IS NOT NULL`
32
+ : "SELECT value FROM json_each(:only)";
33
+ const params = only === undefined ? { cutoff } : { only: JSON.stringify(only) };
34
+ return JSON.stringify(store.handle.prepare(`SELECT r.id AS id FROM task_ref r WHERE r.id IN (${among}) AND ${finishedTask("r")}`).all(params).map(row => Number(row["id"])));
35
+ }
36
+ const cutoffOf = (now) => new Date(now.getTime() - LIFECYCLE_RETENTION_DAYS * 86_400_000).toISOString();
37
+ const hasTable = (store, name) => store.handle.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(name) !== undefined;
38
+ function familiesThatMayGo(store, now, limit, finished = finishedRefs(store, cutoffOf(now))) {
39
+ const outbound = hasTable(store, "telegram_outbound_message");
40
+ return store.handle.prepare(`SELECT ${FAMILY("n")} AS family, COUNT(*) AS pings
41
+ FROM notification n WHERE substr(n.dedupe_key, 1, ${LIFECYCLE_KEY_PREFIX.length}) = '${LIFECYCLE_KEY_PREFIX}'
42
+ GROUP BY family HAVING MIN(${PING_MAY_GO("n", outbound)}) = 1 ORDER BY MIN(n.id) LIMIT :limit`)
43
+ .all({ now: now.toISOString(), cutoff: cutoffOf(now), limit, finished })
44
+ .map(row => ({ family: String(row["family"]), pings: Number(row["pings"]) }));
45
+ }
46
+ export function notificationLifecyclePreview(store, now) {
47
+ const db = store.handle;
48
+ const settle = Number(db.prepare(`SELECT COUNT(*) AS n FROM notification_delivery d WHERE d.destination = :legacy AND d.delivered_at IS NULL AND d.receipt IS NULL
49
+ AND NOT (d.claim_owner IS NOT NULL AND d.claim_expires_at > :now)`).get({ legacy: LEGACY_DESTINATION, now: now.toISOString() })?.["n"] ?? 0);
50
+ const pings = familiesThatMayGo(store, now, -1).reduce((sum, one) => sum + one.pings, 0);
51
+ const legacy = Number(db.prepare(`SELECT COUNT(*) AS n FROM notification_delivery d JOIN notification n ON n.id = d.notification
52
+ WHERE d.destination = :legacy AND (d.receipt = :settled OR (d.delivered_at IS NULL AND d.receipt IS NULL)) AND n.created_at < :cutoff`)
53
+ .get({ legacy: LEGACY_DESTINATION, settled: LEGACY_SETTLED_RECEIPT, cutoff: cutoffOf(now) })?.["n"] ?? 0);
54
+ return { settle, pings, legacy };
55
+ }
56
+ export function sweepNotificationLifecycle(store, now, batch = NOTIFICATION_SWEEP_BATCH) {
57
+ const db = store.handle;
58
+ const at = now.toISOString(), cutoff = cutoffOf(now);
59
+ const settled = store.transact(() => Number(db.prepare(`UPDATE notification_delivery SET receipt = :settled WHERE rowid IN (
60
+ SELECT d.rowid FROM notification_delivery d WHERE d.destination = :legacy AND d.delivered_at IS NULL AND d.receipt IS NULL
61
+ AND NOT (d.claim_owner IS NOT NULL AND d.claim_expires_at > :now) LIMIT :batch)`)
62
+ .run({ settled: LEGACY_SETTLED_RECEIPT, legacy: LEGACY_DESTINATION, now: at, batch }).changes));
63
+ const families = [];
64
+ const deferred = { families: 0, pings: 0 };
65
+ let pings = 0, bytes = 0, more = false;
66
+ for (const one of familiesThatMayGo(store, now, -1)) {
67
+ if (one.pings > batch) {
68
+ deferred.families++;
69
+ deferred.pings += one.pings;
70
+ continue;
71
+ }
72
+ if (more || pings + one.pings > batch) {
73
+ more = true;
74
+ continue;
75
+ }
76
+ families.push(one.family);
77
+ pings += one.pings;
78
+ }
79
+ return store.transact(() => {
80
+ let removed = 0;
81
+ if (families.length > 0) {
82
+ const outbound = hasTable(store, "telegram_outbound_message");
83
+ const named = { families: JSON.stringify(families) };
84
+ const inFamilies = `${FAMILY("n")} IN (SELECT value FROM json_each(:families)) AND substr(n.dedupe_key, 1, ${LIFECYCLE_KEY_PREFIX.length}) = '${LIFECYCLE_KEY_PREFIX}'`;
85
+ const all = db.prepare(`SELECT ${FAMILY("n")} AS family, n.id AS id, n.task_ref AS ref FROM notification n WHERE ${inFamilies}`).all(named);
86
+ const refs = [...new Set(all.map(row => row["ref"]).filter(ref => ref !== null && ref !== undefined).map(Number))];
87
+ const finished = finishedRefs(store, cutoff, refs);
88
+ const free = new Set(db.prepare(`SELECT n.id AS id FROM notification n WHERE ${inFamilies} AND ${PING_MAY_GO("n", outbound)}`)
89
+ .all({ ...named, now: at, cutoff, finished }).map(row => Number(row["id"])));
90
+ const blocked = new Set(all.filter(row => !free.has(Number(row["id"]))).map(row => String(row["family"])));
91
+ const ids = all.filter(row => !blocked.has(String(row["family"]))).map(row => Number(row["id"]));
92
+ if (ids.length > 0) {
93
+ const list = JSON.stringify(ids);
94
+ bytes = Number(db.prepare("SELECT SUM(length(subject) + length(body) + 64) AS n FROM notification WHERE id IN (SELECT value FROM json_each(?))").get(list)?.["n"] ?? 0);
95
+ for (const table of ["notification_delivery", "chat_message_ref", "push_delivery", "notification_actor"]) {
96
+ db.prepare(`DELETE FROM ${table} WHERE notification IN (SELECT value FROM json_each(?))`).run(list);
97
+ }
98
+ removed = Number(db.prepare("DELETE FROM notification WHERE id IN (SELECT value FROM json_each(?))").run(list).changes);
99
+ }
100
+ }
101
+ const legacyCleared = Number(db.prepare(`DELETE FROM notification_delivery WHERE rowid IN (
102
+ SELECT d.rowid FROM notification_delivery d JOIN notification n ON n.id = d.notification
103
+ WHERE d.destination = :legacy AND d.receipt = :settled AND n.created_at < :cutoff LIMIT :batch)`)
104
+ .run({ legacy: LEGACY_DESTINATION, settled: LEGACY_SETTLED_RECEIPT, cutoff, batch }).changes);
105
+ more ||= settled === batch || legacyCleared === batch;
106
+ return { settled, pings: removed, legacyCleared, bytes: removed > 0 ? bytes : 0, more, deferred };
107
+ });
108
+ }
109
+ export function lifecycleWords(sweep) {
110
+ const parts = [
111
+ sweep.pings > 0 ? `${sweep.pings} progress update${sweep.pings === 1 ? "" : "s"}` : "",
112
+ sweep.legacyCleared > 0 ? `${sweep.legacyCleared} undeliverable delivery record${sweep.legacyCleared === 1 ? "" : "s"}` : "",
113
+ ].filter(Boolean);
114
+ const settled = sweep.settled > 0 ? `${sweep.settled} undeliverable delivery record${sweep.settled === 1 ? "" : "s"} settled` : "";
115
+ const held = sweep.deferred.families > 0
116
+ ? `${sweep.deferred.families} progress update famil${sweep.deferred.families === 1 ? "y" : "ies"} (${sweep.deferred.pings} updates) held over: each is larger than one sweep's limit of ${NOTIFICATION_SWEEP_BATCH}`
117
+ : "";
118
+ return [parts.join(", "), settled, held].filter(Boolean).join("; ");
119
+ }
@@ -7,7 +7,6 @@ import { readVerifiedArtifact, scanForSecrets, storeEvidence } from "./evidence.
7
7
  import { readObservationRequest } from "./contracts/observation-request.js";
8
8
  export const OBSERVATION_MAILBOX = "STANDING-ORDERS-OBSERVATIONS.json";
9
9
  export const OBSERVATION_CAPTURE = "machine focused observations v1";
10
- export const OBSERVATION_FILE = "REVIEW-OBSERVATIONS.json";
11
10
  const sha = (bytes) => createHash("sha256").update(bytes).digest("hex");
12
11
  const revision = (value) => typeof value === "string" && /^[0-9a-f]{40,64}$/.test(value);
13
12
  const pathOkay = (value) => typeof value === "string" && value.length > 0 && value.length <= 500 &&
package/dist/operate.js CHANGED
@@ -44,6 +44,7 @@ import { RemoteMains } from "./remote-main.js";
44
44
  import { checkoutPlan, cleanCheckouts, discardCheckout, finishedCheckouts, slimKeptCheckouts, whyWords } from "./checkout-cleanup.js";
45
45
  import { closeOutCheckouts, closeOutRuns, stoppedWords } from "./run-closeout.js";
46
46
  import { proveFinishedRunsStopped, proveRunStopped } from "./stop-proof.js";
47
+ import { LIFECYCLE_RETENTION_DAYS, NOTIFICATION_RETENTION_WORDS, notificationLifecyclePreview } from "./notification-retention.js";
47
48
  import { MIN_DAYS, RETENTION_KINDS, countWords, dailyRetention, isRetentionKind, lastSweepAt, parsePeriod, periodLabel, periodWords, retentionPlan, sweepWords } from "./retention.js";
48
49
  import { checkPolicy, parseList, policyParts } from "./policy.js";
49
50
  import { billingOf, budgetHoldWords, budgetLabel, budgetStates, monthNamed, monthOf, spendItems, subagentNames, usd as spendUsd } from "./spend.js";
@@ -107,7 +108,7 @@ import { taskReviewBrief, renderReviewBrief } from "./task-review-brief.js";
107
108
  import { homedir, hostname } from "node:os";
108
109
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
109
110
  import { CHECK_RECOVERY_HELD, readCheckRecoveryHoldsForTaskRef } from "./check-recovery-hold.js";
110
- import { releaseStalledUpdate, waitingUpdate } from "./toolroll-update.js";
111
+ import { currentRuntime, driftWords, releaseStalledUpdate, serviceDriftHere, waitingUpdate } from "./toolroll-update.js";
111
112
  import { dur } from "./design/kit.js";
112
113
  import { requeueEligibility, checkoutIdle, setCheckoutIdle, leadQuickAnswersOn, setLeadQuickAnswers, openStore, openStoreNoMigrate, initLocalMode, localModeCandidate, consoleServingNow, consoleComponent, consoleRowForPort, openConsoleRows, enrollOwnerPassword, installationCreatedBy, laptopPortOf, recordLaptopPort, localModeOf, localOwnerBinding, archiveTaskFamily, restoreTaskFamily, shipChecksForTask, elapsedSeconds, CONCURRENT_WRITER_WAIT_MS, isDatabaseBusy, databasePath, BUILT_IN, parseCapabilityKey, verifiedAuthor, isDigestTime, predecessorWatches, RESULT_SCREENSHOTS, lifecycleOf, reportLifecycle, beatLifecycle, } from "./store.js";
113
114
  import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
@@ -3514,6 +3515,7 @@ export async function startConsole(options) {
3514
3515
  clock: context.clock,
3515
3516
  telegramTokenFile: context.telegramTokenFile,
3516
3517
  configDir: dirname(context.databaseFile),
3518
+ browserAssetCache: join(dirname(context.databaseFile), "browser-assets"),
3517
3519
  ...(options.localRunner === undefined ? {} : { localRunner: options.localRunner }),
3518
3520
  poolRoot: options.poolRoot,
3519
3521
  ...(options.allowedHosts === undefined ? {} : { allowedHosts: options.allowedHosts }),
@@ -7537,6 +7539,14 @@ async function statusCommand(positional, flags, context) {
7537
7539
  const waiting = waitingUpdate(context.databaseFile, run => context.store.stopQuiescenceProblem(run) !== null, context.clock());
7538
7540
  const updateWaiting = waiting === null ? {} : { updateWaiting: { app: waiting.app, version: waiting.version, stopped: waiting.stopped, run: waiting.run, on: waiting.on, action: waiting.action } };
7539
7541
  const legacyWebhookWarning = loadWebhookTargets(process.env, dirname(context.databaseFile)).length > 0 ? LEGACY_WEBHOOK_WARNING : null;
7542
+ const drift = ["source", "npx", "desktop"].includes(method.kind) ? null : (() => { try {
7543
+ return serviceDriftHere(context.databaseFile, { version: current, dist: context.laptopSeams?.dist ?? currentRuntime(current).dist }, context.laptopSeams ?? {});
7544
+ }
7545
+ catch {
7546
+ return null;
7547
+ } })();
7548
+ const driftLine = drift === null ? null : driftWords(drift.service, drift.cli);
7549
+ const runtimeDrift = drift === null ? {} : { runtimeDrift: { service: drift.service.version, serviceRuntime: drift.service.dist, cli: current, words: driftLine, fix: "toolroll update --yes" } };
7540
7550
  const projects = projectBuildsStatus(context);
7541
7551
  const projectsLine = projects.length === 0 ? null
7542
7552
  : `Builds by project: ${projects.slice(0, 8).map(one => `${one.name} ${one.running} of ${one.limit}`).join(", ")}${projects.length > 8 ? ", …" : ""}`;
@@ -7546,7 +7556,7 @@ async function statusCommand(positional, flags, context) {
7546
7556
  const laptop = { laptop: await laptopStatus(context.store, context.databaseFile, context.laptopSeams) };
7547
7557
  if (!laptop.laptop.running && laptop.laptop.background === "on" && !machineActing())
7548
7558
  await restartOwnBuilder(context.store, context.databaseFile, context.laptopSeams, context.clock()).catch(() => null);
7549
- return succeed(context.write, context.json, command, { ...status, projects, ...laptop, ...update, ...integrations, ...signedOut, ...updateWaiting, ...unsentReplies, ...(legacyWebhookWarning === null ? {} : { legacyWebhookWarning }) }, () => [...(waiting === null ? [] : [waiting.words]), ...(unsentLine === null ? [] : [unsentLine]), ...renderInstallationStatus(status), ...(projectsLine === null ? [] : [projectsLine]), ...(line === null ? [] : [line]), ...signedOutLines, ...(brokenLine === null ? [] : [brokenLine]), ...(legacyWebhookWarning === null ? [] : [legacyWebhookWarning])]);
7559
+ return succeed(context.write, context.json, command, { ...status, projects, ...laptop, ...update, ...integrations, ...signedOut, ...updateWaiting, ...runtimeDrift, ...unsentReplies, ...(legacyWebhookWarning === null ? {} : { legacyWebhookWarning }) }, () => [...(waiting === null ? [] : [waiting.words]), ...(unsentLine === null ? [] : [unsentLine]), ...renderInstallationStatus(status), ...(projectsLine === null ? [] : [projectsLine]), ...(line === null ? [] : [line]), ...(driftLine === null ? [] : [driftLine]), ...signedOutLines, ...(brokenLine === null ? [] : [brokenLine]), ...(legacyWebhookWarning === null ? [] : [legacyWebhookWarning])]);
7550
7560
  }
7551
7561
  function unsentRepliesLine(unsent) {
7552
7562
  if (unsent.length === 0)
@@ -10151,15 +10161,18 @@ async function retentionCommand(positional, flags, context) {
10151
10161
  const last = lastSweepAt(store);
10152
10162
  return succeed(context.write, context.json, command, { periods, defaulted, lastSweep: last }, () => [
10153
10163
  ...RETENTION_KINDS.map(one => ` ${one.kind.padEnd(14)} ${periodLabel(one.kind, periods[one.kind], one.kind in chosen).toLowerCase().padEnd(18)} ${one.label}`),
10164
+ ` ${NOTIFICATION_RETENTION_WORDS}`,
10154
10165
  last === null ? "No sweep yet; the worker runs one a day." : `Last sweep ${last.slice(0, 16).replace("T", " ")} UTC.`,
10155
10166
  ]);
10156
10167
  }
10157
10168
  if (action === "preview") {
10158
10169
  const plan = retentionPlan(store, context.evidenceRoot, context.clock());
10159
10170
  const kept = plan.counts.filter(one => one.days === null).map(one => one.kind);
10160
- return succeed(context.write, context.json, command, { counts: plan.counts }, () => [
10171
+ const fixed = notificationLifecyclePreview(store, context.clock());
10172
+ return succeed(context.write, context.json, command, { counts: plan.counts, lifecycle: fixed }, () => [
10161
10173
  ...plan.counts.filter(one => one.days !== null).map(one => ` ${label(one.kind).padEnd(26)} ${countWords(one)} older than ${periodWords(one.days)}, about ${bytesWords(one.bytes)}${one.more ? " (more after this sweep)" : ""}`),
10162
- kept.length === RETENTION_KINDS.length ? "Everything is kept forever; nothing would be removed." : `Nothing was removed.${kept.length === 0 ? "" : ` Kept forever: ${kept.join(", ")}.`}`,
10174
+ ` ${"Progress updates".padEnd(26)} ${fixed.pings} settled and older than ${LIFECYCLE_RETENTION_DAYS} days, task finished; ${fixed.legacy} undeliverable delivery records older than ${LIFECYCLE_RETENTION_DAYS} days`,
10175
+ kept.length === RETENTION_KINDS.length ? "Everything else is kept forever." : `Nothing was removed.${kept.length === 0 ? "" : ` Kept forever: ${kept.join(", ")}.`}`,
10163
10176
  ]);
10164
10177
  }
10165
10178
  if (action !== "set")
@@ -3,7 +3,11 @@ const METHOD_IS_PERSON = {
3
3
  "remote-token": false, "lead-token": false,
4
4
  "local-owner": true,
5
5
  };
6
- const OTHER_PERSON_PROOFS = new Set(["chat", "passkey"]);
6
+ const OTHER_PERSON_PROOFS = new Set(["chat", "passkey", "passkey-fresh"]);
7
+ export const PERSON_PROOFS = Object.freeze([
8
+ ...Object.entries(METHOD_IS_PERSON).filter(([, person]) => person).map(([method]) => method),
9
+ ...OTHER_PERSON_PROOFS,
10
+ ]);
7
11
  export function personProof(proof) {
8
12
  if (typeof proof !== "string")
9
13
  return false;