sphica 0.6.52 → 0.6.54

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/capture.js CHANGED
@@ -2,8 +2,49 @@
2
2
 
3
3
  // server/src/capture.ts
4
4
  import { spawn as spawn2 } from "node:child_process";
5
- import fs6 from "node:fs";
6
- import path7 from "node:path";
5
+ import fs8 from "node:fs";
6
+ import path9 from "node:path";
7
+
8
+ // server/src/codex-log.ts
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ var SESSION_META_BYTES = 256 * 1024;
12
+ var text = (v) => typeof v === "string" ? v : null;
13
+ function codexThread(input) {
14
+ const file = input.transcript_path;
15
+ if (typeof file !== "string" || !path.isAbsolute(file))
16
+ return null;
17
+ let fd;
18
+ try {
19
+ if (!fs.lstatSync(file).isFile())
20
+ return null;
21
+ fd = fs.openSync(file, "r");
22
+ const buffer = Buffer.alloc(SESSION_META_BYTES);
23
+ const read = fs.readSync(fd, buffer, 0, SESSION_META_BYTES, 0);
24
+ const end = buffer.subarray(0, read).indexOf(10);
25
+ if (end < 0)
26
+ return null;
27
+ const line = JSON.parse(buffer.subarray(0, end).toString("utf8"));
28
+ const payload = line?.payload;
29
+ if (line?.type !== "session_meta" || !payload || typeof payload !== "object" || Array.isArray(payload))
30
+ return null;
31
+ const source = payload.source;
32
+ return {
33
+ id: text(payload.id),
34
+ originator: text(payload.originator),
35
+ threadSource: text(payload.thread_source),
36
+ parent: text(payload.parent_thread_id),
37
+ subagent: source && typeof source === "object" ? text(source.subagent) : null
38
+ };
39
+ } catch {
40
+ return null;
41
+ } finally {
42
+ if (fd !== undefined)
43
+ fs.closeSync(fd);
44
+ }
45
+ }
46
+ var ownThread = (input, thread) => Boolean(input.session_id) && thread?.id === input.session_id && thread?.threadSource === "user";
47
+ var childThread = (input, thread) => input.session_id && thread?.threadSource === "subagent" && thread.parent === input.session_id && thread.id !== null && thread.id !== input.session_id && /^[\x21-\x7e]{1,200}$/.test(thread.id) ? thread.id : null;
7
48
 
8
49
  // server/node_modules/kysely/dist/util/object-utils.js
9
50
  function isUndefined(obj) {
@@ -10808,14 +10849,14 @@ function adapt(raw) {
10808
10849
  }
10809
10850
 
10810
10851
  // server/src/sqlite.ts
10811
- import fs3 from "node:fs";
10852
+ import fs4 from "node:fs";
10812
10853
  import os2 from "node:os";
10813
- import path3 from "node:path";
10854
+ import path4 from "node:path";
10814
10855
  import { constants as C, DatabaseSync } from "node:sqlite";
10815
10856
 
10816
10857
  // server/src/plugin.ts
10817
- import fs2 from "node:fs";
10818
- import path2 from "node:path";
10858
+ import fs3 from "node:fs";
10859
+ import path3 from "node:path";
10819
10860
  import { fileURLToPath } from "node:url";
10820
10861
 
10821
10862
  // server/node_modules/smol-toml/dist/error.js
@@ -11087,10 +11128,10 @@ var SHORT = new Set(["SessionEnd", "Interrupt"]);
11087
11128
 
11088
11129
  // server/src/git.ts
11089
11130
  import { execFileSync, spawn } from "node:child_process";
11090
- import fs from "node:fs";
11131
+ import fs2 from "node:fs";
11091
11132
  import os from "node:os";
11092
- import path from "node:path";
11093
- var gitHome = () => path.join(os.homedir(), ".sphica", "git");
11133
+ import path2 from "node:path";
11134
+ var gitHome = () => path2.join(os.homedir(), ".sphica", "git");
11094
11135
  function gitEnv(extra = {}) {
11095
11136
  const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^GIT_/i.test(k)));
11096
11137
  return {
@@ -11102,7 +11143,7 @@ function gitEnv(extra = {}) {
11102
11143
  ...extra
11103
11144
  };
11104
11145
  }
11105
- var gitOptions = (hooks = path.join(gitHome(), "hooks")) => [
11146
+ var gitOptions = (hooks = path2.join(gitHome(), "hooks")) => [
11106
11147
  "-c",
11107
11148
  "core.fsmonitor=",
11108
11149
  "-c",
@@ -11121,7 +11162,7 @@ var DIFF_OPTIONS = [
11121
11162
  ];
11122
11163
  function startDir() {
11123
11164
  const home = os.homedir();
11124
- return fs.statSync(home, { throwIfNoEntry: false })?.isDirectory() ? home : path.dirname(process.execPath);
11165
+ return fs2.statSync(home, { throwIfNoEntry: false })?.isDirectory() ? home : path2.dirname(process.execPath);
11125
11166
  }
11126
11167
  function run(root, args, { max = 1024 * 1024, timeout = 1e4 } = {}) {
11127
11168
  return execFileSync("git", ["-C", root, ...gitOptions(), ...args], {
@@ -11133,7 +11174,7 @@ function run(root, args, { max = 1024 * 1024, timeout = 1e4 } = {}) {
11133
11174
  killSignal: "SIGKILL"
11134
11175
  });
11135
11176
  }
11136
- var text = (root, args, limits) => run(root, args, limits).toString("utf8");
11177
+ var text2 = (root, args, limits) => run(root, args, limits).toString("utf8");
11137
11178
  var list = (out) => out.split("\x00").filter(Boolean);
11138
11179
  function revision(rev) {
11139
11180
  if (!rev || rev.startsWith("-") || /[\0\n]/.test(rev))
@@ -11145,8 +11186,8 @@ function objectId(oid) {
11145
11186
  throw new Error(`not an object id: ${JSON.stringify(oid)}`);
11146
11187
  return oid;
11147
11188
  }
11148
- var topLevel = (dir, limits) => text(dir, ["rev-parse", "--show-toplevel"], limits).trim();
11149
- var commitOf = (root, rev, limits) => text(root, ["rev-parse", "--verify", "-q", `${revision(rev)}^{commit}`], limits).trim();
11189
+ var topLevel = (dir, limits) => text2(dir, ["rev-parse", "--show-toplevel"], limits).trim();
11190
+ var commitOf = (root, rev, limits) => text2(root, ["rev-parse", "--verify", "-q", `${revision(rev)}^{commit}`], limits).trim();
11150
11191
  function isAncestor(root, a, b, limits) {
11151
11192
  try {
11152
11193
  run(root, ["merge-base", "--is-ancestor", objectId(a), objectId(b)], limits);
@@ -11155,15 +11196,15 @@ function isAncestor(root, a, b, limits) {
11155
11196
  return false;
11156
11197
  }
11157
11198
  }
11158
- var commitDiffNames = (root, a, b, limits) => list(text(root, ["diff", ...DIFF_OPTIONS, "--name-only", "-z", objectId(a), objectId(b), "--"], limits));
11159
- var originUrl = (root, limits) => text(root, ["remote", "get-url", "origin"], limits).trim();
11199
+ var commitDiffNames = (root, a, b, limits) => list(text2(root, ["diff", ...DIFF_OPTIONS, "--name-only", "-z", objectId(a), objectId(b), "--"], limits));
11200
+ var originUrl = (root, limits) => text2(root, ["remote", "get-url", "origin"], limits).trim();
11160
11201
  async function worktreeStatus(root, deadline) {
11161
11202
  const out = await inIsolation(root, [{ kind: "status" }], { deadline, max: 16 * 1024 * 1024 });
11162
11203
  return Array.isArray(out) ? out[0] ?? null : null;
11163
11204
  }
11164
11205
  function workerFile() {
11165
- const js = path.join(import.meta.dirname, "git-worker.js");
11166
- return fs.existsSync(js) ? js : path.join(import.meta.dirname, "git-worker.ts");
11206
+ const js = path2.join(import.meta.dirname, "git-worker.js");
11207
+ return fs2.existsSync(js) ? js : path2.join(import.meta.dirname, "git-worker.ts");
11167
11208
  }
11168
11209
  function inIsolation(root, ops, { deadline, max }) {
11169
11210
  return new Promise((resolve) => {
@@ -11265,8 +11306,8 @@ function singular(w) {
11265
11306
  return w.slice(0, -1);
11266
11307
  return w.endsWith("s") && !/(?:ss|us|is)$/.test(w) ? w.slice(0, -1) : w;
11267
11308
  }
11268
- function terms(text2, parts = true) {
11269
- const nfkc = text2.normalize("NFKC");
11309
+ function terms(text3, parts = true) {
11310
+ const nfkc = text3.normalize("NFKC");
11270
11311
  const norm = nfkc.toLowerCase();
11271
11312
  const out = [];
11272
11313
  const keep = (w) => {
@@ -11407,9 +11448,9 @@ var MAX_QUOTED = 4096;
11407
11448
  var BARE_HEAD = /[^\s"',;)]{1,256}/y;
11408
11449
  var BARE_REST = /[^\s"',;)]*/y;
11409
11450
  var NEXT_PARAM = /&[A-Za-z_][\w.-]*=/;
11410
- var bareAt = (re, text2, at) => {
11451
+ var bareAt = (re, text3, at) => {
11411
11452
  re.lastIndex = at;
11412
- const v = re.exec(text2)?.[0] ?? "";
11453
+ const v = re.exec(text3)?.[0] ?? "";
11413
11454
  const cut = v.search(NEXT_PARAM);
11414
11455
  return cut < 0 ? v : v.slice(0, cut);
11415
11456
  };
@@ -11422,49 +11463,49 @@ function secretValue(quoted, v) {
11422
11463
  return false;
11423
11464
  return !/\s/.test(v) || v.split(/\s+/).some((w) => /\d/.test(w) && /[A-Za-z]/.test(w));
11424
11465
  }
11425
- function maskFields(text2) {
11466
+ function maskFields(text3) {
11426
11467
  let out = "";
11427
11468
  let last = 0;
11428
11469
  FIELD_NAME.lastIndex = 0;
11429
- for (let m = FIELD_NAME.exec(text2);m; m = FIELD_NAME.exec(text2)) {
11470
+ for (let m = FIELD_NAME.exec(text3);m; m = FIELD_NAME.exec(text3)) {
11430
11471
  const at = m.index + m[0].length;
11431
- const q = text2[at];
11472
+ const q = text3[at];
11432
11473
  let quote = "";
11433
11474
  let value;
11434
11475
  if (q === '"' || q === "'") {
11435
- const close = text2.indexOf(q, at + 1);
11476
+ const close = text3.indexOf(q, at + 1);
11436
11477
  if (close < 0 || close - at - 1 > MAX_QUOTED)
11437
11478
  continue;
11438
- value = text2.slice(at + 1, close);
11479
+ value = text3.slice(at + 1, close);
11439
11480
  if (value.includes(`
11440
11481
  `))
11441
11482
  continue;
11442
11483
  quote = q;
11443
11484
  } else {
11444
- value = bareAt(BARE_HEAD, text2, at);
11485
+ value = bareAt(BARE_HEAD, text3, at);
11445
11486
  }
11446
11487
  if (!secretValue(quote !== "", value))
11447
11488
  continue;
11448
11489
  if (!quote && value.length === 256)
11449
- value += bareAt(BARE_REST, text2, at + 256);
11450
- out += `${text2.slice(last, at)}${quote}[redacted]`;
11490
+ value += bareAt(BARE_REST, text3, at + 256);
11491
+ out += `${text3.slice(last, at)}${quote}[redacted]`;
11451
11492
  last = at + quote.length + value.length;
11452
11493
  FIELD_NAME.lastIndex = last;
11453
11494
  }
11454
- return out + text2.slice(last);
11495
+ return out + text3.slice(last);
11455
11496
  }
11456
11497
  var MYSQL_COMMAND = /\bmysql(?:dump|admin)?\b(?:'[^'\n]*'|"[^"\n]*"|[^\n;&|\\'"]|\\\r?\n|\\(?!\r?\n))*/g;
11457
11498
  var MYSQL_PASSWORD = /(\s-p)(?:'[^'\n]*'|"[^"\n]*"|(?=[^\s-])\S+)/;
11458
11499
  var URL_CREDENTIALS = /\b((?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?|rediss?|amqps?|https?):\/\/[^:\s/@]*:)[^\s/]*@([^@\s/?#]+)/g;
11459
11500
  var KEY_BEGIN = /-----BEGIN [A-Z ]*PRIVATE KEY-----/g;
11460
11501
  var KEY_END = /-----END [A-Z ]*PRIVATE KEY-----/g;
11461
- function keyBlocks(text2) {
11462
- const ends = [...text2.matchAll(KEY_END)].map((m) => [m.index, m.index + m[0].length]);
11502
+ function keyBlocks(text3) {
11503
+ const ends = [...text3.matchAll(KEY_END)].map((m) => [m.index, m.index + m[0].length]);
11463
11504
  const out = [];
11464
11505
  let last = 0;
11465
11506
  let e = 0;
11466
11507
  if (ends.length > 0)
11467
- for (const m of text2.matchAll(KEY_BEGIN)) {
11508
+ for (const m of text3.matchAll(KEY_BEGIN)) {
11468
11509
  const after = m.index + m[0].length;
11469
11510
  if (m.index < last)
11470
11511
  continue;
@@ -11478,17 +11519,17 @@ function keyBlocks(text2) {
11478
11519
  }
11479
11520
  return out;
11480
11521
  }
11481
- function maskPrivateKeys(text2) {
11522
+ function maskPrivateKeys(text3) {
11482
11523
  let out = "";
11483
11524
  let last = 0;
11484
- for (const [a, b] of keyBlocks(text2)) {
11485
- out += `${text2.slice(last, a)}[redacted: private key]`;
11525
+ for (const [a, b] of keyBlocks(text3)) {
11526
+ out += `${text3.slice(last, a)}[redacted: private key]`;
11486
11527
  last = b;
11487
11528
  }
11488
- return out + text2.slice(last);
11529
+ return out + text3.slice(last);
11489
11530
  }
11490
- function mask(text2) {
11491
- let out = maskFields(maskPrivateKeys(text2).replace(URL_CREDENTIALS, "$1[redacted]@$2").replace(AUTH_HEADER, "$1[redacted]").replace(HEADER_BEARER, "$1[redacted]").replace(ENV_ASSIGN, "$1$2[redacted]")).replace(MYSQL_COMMAND, (command) => command.replace(MYSQL_PASSWORD, "$1[redacted]"));
11531
+ function mask(text3) {
11532
+ let out = maskFields(maskPrivateKeys(text3).replace(URL_CREDENTIALS, "$1[redacted]@$2").replace(AUTH_HEADER, "$1[redacted]").replace(HEADER_BEARER, "$1[redacted]").replace(ENV_ASSIGN, "$1$2[redacted]")).replace(MYSQL_COMMAND, (command) => command.replace(MYSQL_PASSWORD, "$1[redacted]"));
11492
11533
  for (const [re, what] of SECRETS)
11493
11534
  out = out.replace(re, `[redacted: ${what}]`);
11494
11535
  return out;
@@ -11510,11 +11551,11 @@ function explain(e, depth) {
11510
11551
  }
11511
11552
 
11512
11553
  // server/src/panel.ts
11513
- var title = (text2) => `✦ ${text2}`;
11514
- var rule = (text2) => text2.split(`
11554
+ var title = (text3) => `✦ ${text3}`;
11555
+ var rule = (text3) => text3.split(`
11515
11556
  `).map((line) => line ? `│ ${line}` : "│").join(`
11516
11557
  `);
11517
- var foot = (text2) => `╰─ ${text2}`;
11558
+ var foot = (text3) => `╰─ ${text3}`;
11518
11559
  var panel = (head2, lines, end) => [title(head2), ...lines.map(rule), foot(end)].join(`
11519
11560
  `);
11520
11561
  var STRING_SEQUENCE = /\u001b[\]P_^X][^\u0007\u001b]*(?:\u0007|\u001b\\)?/g;
@@ -11522,11 +11563,11 @@ var plain2 = (s) => visible(stripVTControlCharacters(s.replace(STRING_SEQUENCE,
11522
11563
  `).replace(/(?![\t\n])\p{Cc}/gu, ""));
11523
11564
 
11524
11565
  // server/src/plugin.ts
11525
- var MANIFEST = path2.join(".claude-plugin", "plugin.json");
11566
+ var MANIFEST = path3.join(".claude-plugin", "plugin.json");
11526
11567
  var PACKAGE = "package.json";
11527
11568
  function versionAt(root) {
11528
11569
  try {
11529
- const m = JSON.parse(fs2.readFileSync(path2.join(root, MANIFEST), "utf8"));
11570
+ const m = JSON.parse(fs3.readFileSync(path3.join(root, MANIFEST), "utf8"));
11530
11571
  return m.name === "sphica" && typeof m.version === "string" ? m.version : null;
11531
11572
  } catch {
11532
11573
  return null;
@@ -11534,28 +11575,28 @@ function versionAt(root) {
11534
11575
  }
11535
11576
  function packageVersionAt(root) {
11536
11577
  try {
11537
- const m = JSON.parse(fs2.readFileSync(path2.join(root, PACKAGE), "utf8"));
11578
+ const m = JSON.parse(fs3.readFileSync(path3.join(root, PACKAGE), "utf8"));
11538
11579
  return m.name === "sphica" && typeof m.version === "string" ? m.version : null;
11539
11580
  } catch {
11540
11581
  return null;
11541
11582
  }
11542
11583
  }
11543
- var here = path2.dirname(fileURLToPath(import.meta.url));
11544
- var ROOT = [path2.join(here, ".."), path2.join(here, "..", "..", "plugin")].find((r) => versionAt(r) !== null) ?? path2.join(here, "..");
11584
+ var here = path3.dirname(fileURLToPath(import.meta.url));
11585
+ var ROOT = [path3.join(here, ".."), path3.join(here, "..", "..", "plugin")].find((r) => versionAt(r) !== null) ?? path3.join(here, "..");
11545
11586
  var HOST_MARKS = new Set([".orphaned_at", ".in_use"]);
11546
11587
 
11547
11588
  // server/src/sqlite.ts
11548
11589
  var SCHEMA_GENERATION = 2;
11549
11590
  var SCHEMA_REVISION = 12;
11550
- var sphicaHome = () => process.env.SPHICA_HOME || path3.join(os2.homedir(), ".sphica");
11551
- var dbFile = () => process.env.SPHICA_DB || path3.join(sphicaHome(), "sphica.db");
11591
+ var sphicaHome = () => process.env.SPHICA_HOME || path4.join(os2.homedir(), ".sphica");
11592
+ var dbFile = () => process.env.SPHICA_DB || path4.join(sphicaHome(), "sphica.db");
11552
11593
  function requireRuntime() {
11553
11594
  const proto = DatabaseSync.prototype;
11554
11595
  if (typeof proto.setAuthorizer !== "function" || typeof proto.enableDefensive !== "function")
11555
11596
  throw new Error(`Sphica needs Node 24.15 or later (this is ${process.version}). Upgrade Node.`);
11556
11597
  }
11557
11598
  function requireFile(file) {
11558
- if (!fs3.existsSync(file))
11599
+ if (!fs4.existsSync(file))
11559
11600
  throw new Error(`No database at ${file}. Create it with \`sphica init\`.`);
11560
11601
  }
11561
11602
  function prepare(raw, check, busyMs = 5000) {
@@ -11879,7 +11920,7 @@ function connectWriter(role, file = dbFile(), create = false, busyMs) {
11879
11920
  const raw = new DatabaseSync2(file);
11880
11921
  try {
11881
11922
  prepare(raw, create ? "none" : role === "ingest" || role === "forget" ? "revision" : "generation", busyMs);
11882
- raw.function("sphica_terms", { deterministic: true }, (text2) => terms(String(text2 ?? "")).join(" "));
11923
+ raw.function("sphica_terms", { deterministic: true }, (text3) => terms(String(text3 ?? "")).join(" "));
11883
11924
  } catch (e) {
11884
11925
  raw.close();
11885
11926
  throw e;
@@ -11913,17 +11954,39 @@ function openWriter(role, file = dbFile(), busyMs) {
11913
11954
  // server/src/knowledge.ts
11914
11955
  var sessionId = (projectId, host, externalId) => uuidFrom(String(projectId), host, externalId);
11915
11956
 
11916
- // server/src/project.ts
11917
- import fs4 from "node:fs";
11957
+ // server/src/once.ts
11958
+ import fs5 from "node:fs";
11959
+ import os3 from "node:os";
11918
11960
  import path5 from "node:path";
11961
+ function markOnce(kind, key) {
11962
+ const user = (() => {
11963
+ try {
11964
+ return os3.userInfo().username;
11965
+ } catch {
11966
+ return String(process.getuid?.() ?? "user");
11967
+ }
11968
+ })();
11969
+ const dir = path5.join(os3.tmpdir(), `sphica-${sha256(user).toString("hex").slice(0, 12)}`, kind);
11970
+ try {
11971
+ fs5.mkdirSync(dir, { recursive: true, mode: 448 });
11972
+ fs5.writeFileSync(path5.join(dir, sha256(key).toString("hex").slice(0, 24)), "", { flag: "wx" });
11973
+ return true;
11974
+ } catch (e) {
11975
+ return e.code !== "EEXIST";
11976
+ }
11977
+ }
11978
+
11979
+ // server/src/project.ts
11980
+ import fs6 from "node:fs";
11981
+ import path7 from "node:path";
11919
11982
 
11920
11983
  // server/src/anchors.ts
11921
- import path4 from "node:path";
11984
+ import path6 from "node:path";
11922
11985
  var MAX_BYTES = 2 * 1024 * 1024;
11923
- var leaves = (rel) => rel === ".." || rel.startsWith(`..${path4.sep}`) || path4.isAbsolute(rel);
11986
+ var leaves = (rel) => rel === ".." || rel.startsWith(`..${path6.sep}`) || path6.isAbsolute(rel);
11924
11987
 
11925
11988
  // server/src/project.ts
11926
- var localFile = () => path5.join(sphicaHome(), "projects.json");
11989
+ var localFile = () => path7.join(sphicaHome(), "projects.json");
11927
11990
  var LOCAL_KEY = /^[a-z0-9][a-z0-9._-]*$/;
11928
11991
  function legacyRemote(url) {
11929
11992
  const raw = String(url ?? "").trim();
@@ -11962,7 +12025,7 @@ var top = (dir) => ask(() => topLevel(dir, { timeout: 5000 }));
11962
12025
  function localMap() {
11963
12026
  let raw;
11964
12027
  try {
11965
- raw = fs4.readFileSync(localFile(), "utf8");
12028
+ raw = fs6.readFileSync(localFile(), "utf8");
11966
12029
  } catch (e) {
11967
12030
  if (e.code === "ENOENT")
11968
12031
  return {};
@@ -11974,12 +12037,12 @@ function localMap() {
11974
12037
  } catch {
11975
12038
  m = null;
11976
12039
  }
11977
- if (!m || typeof m !== "object" || Array.isArray(m) || Object.entries(m).some(([root, name]) => !path5.isAbsolute(root) || typeof name !== "string" || !LOCAL_KEY.test(name)))
12040
+ if (!m || typeof m !== "object" || Array.isArray(m) || Object.entries(m).some(([root, name]) => !path7.isAbsolute(root) || typeof name !== "string" || !LOCAL_KEY.test(name)))
11978
12041
  throw new Error(`${localFile()} is not a valid JSON project table. Fix or delete it, then name the project again.`);
11979
12042
  return m;
11980
12043
  }
11981
12044
  function identify(dir) {
11982
- const given = path5.resolve(dir);
12045
+ const given = path7.resolve(dir);
11983
12046
  const found = top(given);
11984
12047
  const root = found || given;
11985
12048
  const legacy = found ? legacyRemote(ask(() => originUrl(root, { timeout: 5000 }))) : null;
@@ -11989,20 +12052,20 @@ function identify(dir) {
11989
12052
  return { key, legacyKey: `git:${legacy}`, root, name: remote.split("/").slice(1).join("/") || remote };
11990
12053
  }
11991
12054
  const map = localMap();
11992
- for (let d = root;; d = path5.dirname(d)) {
12055
+ for (let d = root;; d = path7.dirname(d)) {
11993
12056
  const local = map[d];
11994
12057
  if (local && LOCAL_KEY.test(local))
11995
12058
  return { key: `local:${local}`, legacyKey: `local:${local}`, root: d, name: local };
11996
- if (found || path5.dirname(d) === d)
12059
+ if (found || path7.dirname(d) === d)
11997
12060
  return null;
11998
12061
  }
11999
12062
  }
12000
12063
  function relativeTo(root, file, cwd = root) {
12001
- const abs = path5.resolve(cwd, file);
12002
- const rel = path5.relative(root, abs);
12064
+ const abs = path7.resolve(cwd, file);
12065
+ const rel = path7.relative(root, abs);
12003
12066
  if (!rel || leaves(rel) || /\p{Cc}/u.test(rel))
12004
12067
  return null;
12005
- return rel.split(path5.sep).join("/");
12068
+ return rel.split(path7.sep).join("/");
12006
12069
  }
12007
12070
  function patchPaths(patch) {
12008
12071
  const out = [];
@@ -12016,8 +12079,8 @@ function patchPaths(patch) {
12016
12079
  }
12017
12080
 
12018
12081
  // server/src/worktree.ts
12019
- import fs5 from "node:fs";
12020
- import path6 from "node:path";
12082
+ import fs7 from "node:fs";
12083
+ import path8 from "node:path";
12021
12084
  var MAX_PATHS = 200;
12022
12085
  var LIMITS = { timeout: 5000, max: 16 * 1024 * 1024 };
12023
12086
  var STATUS_DEADLINE = 5000;
@@ -12042,7 +12105,7 @@ async function snapshot(root) {
12042
12105
  continue;
12043
12106
  let st;
12044
12107
  try {
12045
- st = fs5.lstatSync(path6.join(root, p), { throwIfNoEntry: false });
12108
+ st = fs7.lstatSync(path8.join(root, p), { throwIfNoEntry: false });
12046
12109
  } catch {
12047
12110
  st = undefined;
12048
12111
  }
@@ -12074,15 +12137,15 @@ function changed(root, before, after) {
12074
12137
  }
12075
12138
 
12076
12139
  // server/src/capture.ts
12077
- var spoolDir = () => path7.join(sphicaHome(), "spool");
12078
- var stateFile = () => path7.join(sphicaHome(), "capture.json");
12079
- var rejectedDir = () => path7.join(spoolDir(), "rejected");
12080
- var unregisteredDir = () => path7.join(spoolDir(), "unregistered");
12081
- var callsDir = () => path7.join(spoolDir(), "calls");
12082
- var callsRejectedDir = () => path7.join(callsDir(), "rejected");
12140
+ var spoolDir = () => path9.join(sphicaHome(), "spool");
12141
+ var stateFile = () => path9.join(sphicaHome(), "capture.json");
12142
+ var rejectedDir = () => path9.join(spoolDir(), "rejected");
12143
+ var unregisteredDir = () => path9.join(spoolDir(), "unregistered");
12144
+ var callsDir = () => path9.join(spoolDir(), "calls");
12145
+ var callsRejectedDir = () => path9.join(callsDir(), "rejected");
12083
12146
  var HOLD_DAYS = 30;
12084
12147
  var HOLD_MAX = 1000;
12085
- var baselineDir = () => path7.join(sphicaHome(), "worktree");
12148
+ var baselineDir = () => path9.join(sphicaHome(), "worktree");
12086
12149
  function current(raw) {
12087
12150
  const r = raw;
12088
12151
  if (typeof r.project !== "string")
@@ -12131,7 +12194,7 @@ ${z}`,
12131
12194
  function prune(held, removed = () => {}) {
12132
12195
  let files;
12133
12196
  try {
12134
- files = fs6.readdirSync(held).filter((f) => f.endsWith(".json") && !f.startsWith(".")).sort();
12197
+ files = fs8.readdirSync(held).filter((f) => f.endsWith(".json") && !f.startsWith(".")).sort();
12135
12198
  } catch {
12136
12199
  return;
12137
12200
  }
@@ -12139,26 +12202,26 @@ function prune(held, removed = () => {}) {
12139
12202
  const stale = files.filter((f) => Number(f.split("-")[0]) < cutoff);
12140
12203
  const over = files.slice(0, Math.max(0, files.length - HOLD_MAX));
12141
12204
  for (const f of new Set([...stale, ...over])) {
12142
- fs6.rmSync(path7.join(held, f), { force: true });
12205
+ fs8.rmSync(path9.join(held, f), { force: true });
12143
12206
  removed();
12144
12207
  }
12145
12208
  }
12146
12209
  function put(dir, record) {
12147
- fs6.mkdirSync(dir, { recursive: true, mode: 448 });
12210
+ fs8.mkdirSync(dir, { recursive: true, mode: 448 });
12148
12211
  const name = `${Date.now()}-${process.pid}-${Math.random().toString(36).slice(2, 10)}.json`;
12149
- const tmp = path7.join(dir, `.${name}`);
12150
- fs6.writeFileSync(tmp, JSON.stringify(record), { mode: 384 });
12151
- fs6.renameSync(tmp, path7.join(dir, name));
12152
- return path7.join(dir, name);
12212
+ const tmp = path9.join(dir, `.${name}`);
12213
+ fs8.writeFileSync(tmp, JSON.stringify(record), { mode: 384 });
12214
+ fs8.renameSync(tmp, path9.join(dir, name));
12215
+ return path9.join(dir, name);
12153
12216
  }
12154
12217
  function spool(record) {
12155
12218
  put(spoolDir(), record);
12156
12219
  }
12157
12220
  var branchOf = (root) => {
12158
12221
  try {
12159
- const dotgit = path7.join(root, ".git");
12160
- const gitdir = fs6.statSync(dotgit).isFile() ? path7.resolve(root, fs6.readFileSync(dotgit, "utf8").match(/^gitdir: (.+)$/m)?.[1]?.trim() ?? "") : dotgit;
12161
- const h = fs6.readFileSync(path7.join(gitdir, "HEAD"), "utf8").trim();
12222
+ const dotgit = path9.join(root, ".git");
12223
+ const gitdir = fs8.statSync(dotgit).isFile() ? path9.resolve(root, fs8.readFileSync(dotgit, "utf8").match(/^gitdir: (.+)$/m)?.[1]?.trim() ?? "") : dotgit;
12224
+ const h = fs8.readFileSync(path9.join(gitdir, "HEAD"), "utf8").trim();
12162
12225
  return h.startsWith("ref: refs/heads/") ? h.slice("ref: refs/heads/".length) : null;
12163
12226
  } catch {
12164
12227
  return null;
@@ -12204,7 +12267,7 @@ Notes: ${notes.trim()}` : "";
12204
12267
  };
12205
12268
  }
12206
12269
  function captureNotice(file = dbFile()) {
12207
- if (!fs6.existsSync(file))
12270
+ if (!fs8.existsSync(file))
12208
12271
  return panel("sphica: no database, so conversations are not recorded", [file], "Create it with sphica init");
12209
12272
  const s = readState();
12210
12273
  if (s.unreadable)
@@ -12215,15 +12278,15 @@ function captureNotice(file = dbFile()) {
12215
12278
  return panel(`sphica: the database rejected ${plural(s.rejected, "record")}`, [rejectedDir(), `Move them back to ${spoolDir()} to resend`], "Fix them first, then check with sphica doctor");
12216
12279
  return null;
12217
12280
  }
12218
- var turnDir = (host, session) => path7.join(baselineDir(), digest(`${host}\x00${session}`));
12219
- var startFile = (dir, turn) => path7.join(dir, `${digest(turn)}.json`);
12281
+ var turnDir = (host, session) => path9.join(baselineDir(), digest(`${host}\x00${session}`));
12282
+ var startFile = (dir, turn) => path9.join(dir, `${digest(turn)}.json`);
12220
12283
  var isStart = (v) => {
12221
12284
  const s = v;
12222
12285
  return !!s && typeof s === "object" && typeof s.turn === "string" && typeof s.running === "boolean" && (s.seq === null || Number.isSafeInteger(s.seq)) && (s.entries === null || typeof s.entries === "object" && !Array.isArray(s.entries)) && (s.head === null || typeof s.head === "string");
12223
12286
  };
12224
12287
  function readStart(file) {
12225
12288
  try {
12226
- const s = JSON.parse(fs6.readFileSync(file, "utf8"));
12289
+ const s = JSON.parse(fs8.readFileSync(file, "utf8"));
12227
12290
  return isStart(s) ? s : null;
12228
12291
  } catch {
12229
12292
  return null;
@@ -12232,7 +12295,7 @@ function readStart(file) {
12232
12295
  function readStarts(dir) {
12233
12296
  let names;
12234
12297
  try {
12235
- names = fs6.readdirSync(dir);
12298
+ names = fs8.readdirSync(dir);
12236
12299
  } catch (e) {
12237
12300
  return e.code === "ENOENT" ? [] : null;
12238
12301
  }
@@ -12240,7 +12303,7 @@ function readStarts(dir) {
12240
12303
  for (const name of names) {
12241
12304
  if (name.startsWith("."))
12242
12305
  continue;
12243
- const s = readStart(path7.join(dir, name));
12306
+ const s = readStart(path9.join(dir, name));
12244
12307
  if (!s)
12245
12308
  return null;
12246
12309
  starts.push(s);
@@ -12255,10 +12318,10 @@ function newestTurn(starts) {
12255
12318
  return at.length === 1 ? at[0]?.turn ?? null : null;
12256
12319
  }
12257
12320
  function writeStart(dir, s, file = startFile(dir, s.turn)) {
12258
- fs6.mkdirSync(dir, { recursive: true, mode: 448 });
12259
- const tmp = path7.join(dir, `.${path7.basename(file)}.${process.pid}.tmp`);
12260
- fs6.writeFileSync(tmp, JSON.stringify(s), { mode: 384 });
12261
- fs6.renameSync(tmp, file);
12321
+ fs8.mkdirSync(dir, { recursive: true, mode: 448 });
12322
+ const tmp = path9.join(dir, `.${path9.basename(file)}.${process.pid}.tmp`);
12323
+ fs8.writeFileSync(tmp, JSON.stringify(s), { mode: 384 });
12324
+ fs8.renameSync(tmp, file);
12262
12325
  }
12263
12326
  async function openTurn(dir, turn, root) {
12264
12327
  if (readStart(startFile(dir, turn))?.running)
@@ -12288,22 +12351,22 @@ function stopTurn(dir, turn) {
12288
12351
  }
12289
12352
  function pruneBaselines() {
12290
12353
  const cutoff = Date.now() - HOLD_DAYS * 24 * 60 * 60 * 1000;
12291
- const fresh = (file) => (fs6.statSync(file, { throwIfNoEntry: false })?.mtimeMs ?? Date.now()) >= cutoff;
12354
+ const fresh = (file) => (fs8.statSync(file, { throwIfNoEntry: false })?.mtimeMs ?? Date.now()) >= cutoff;
12292
12355
  let names;
12293
12356
  try {
12294
- names = fs6.readdirSync(baselineDir());
12357
+ names = fs8.readdirSync(baselineDir());
12295
12358
  } catch {
12296
12359
  return;
12297
12360
  }
12298
12361
  for (const name of names) {
12299
- const at = path7.join(baselineDir(), name);
12300
- if (!fs6.statSync(at, { throwIfNoEntry: false })?.isDirectory()) {
12362
+ const at = path9.join(baselineDir(), name);
12363
+ if (!fs8.statSync(at, { throwIfNoEntry: false })?.isDirectory()) {
12301
12364
  if (!fresh(at))
12302
- fs6.rmSync(at, { force: true });
12365
+ fs8.rmSync(at, { force: true });
12303
12366
  } else {
12304
- const files = fs6.readdirSync(at);
12305
- if (files.length && !files.some((f) => fresh(path7.join(at, f))))
12306
- fs6.rmSync(at, { recursive: true, force: true });
12367
+ const files = fs8.readdirSync(at);
12368
+ if (files.length && !files.some((f) => fresh(path9.join(at, f))))
12369
+ fs8.rmSync(at, { recursive: true, force: true });
12307
12370
  }
12308
12371
  }
12309
12372
  }
@@ -12321,22 +12384,36 @@ async function attemptAsync(fn) {
12321
12384
  return;
12322
12385
  }
12323
12386
  }
12387
+ function whoseTurn(host, input) {
12388
+ if (!isOwnerTurn(input, undefined, undefined, host === "codex" ? process.env.CODEX_THREAD_ID : undefined))
12389
+ return "other";
12390
+ if (host !== "codex")
12391
+ return "owner";
12392
+ const thread = codexThread(input);
12393
+ if (ownThread(input, thread))
12394
+ return "owner";
12395
+ return childThread(input, thread) === null ? "unconfirmed" : "other";
12396
+ }
12397
+ var unconfirmed = (input) => !markOnce("unconfirmed", `codex\x00${input.session_id}`) ? null : typeof input.transcript_path === "string" ? panel("sphica: this Codex session is not recorded", ["Its session log does not show that these messages are yours"], "Update Sphica and Codex; if it stays, report it") : panel("sphica: this Codex session is not recorded", [
12398
+ "Codex named no session log (as with --ephemeral), so Sphica cannot confirm these messages are yours"
12399
+ ], "To record a session, start Codex without --ephemeral");
12324
12400
  async function onHook(host, input) {
12325
12401
  const event = input.hook_event_name;
12326
- const owner = () => isOwnerTurn(input, undefined, undefined, host === "codex" ? process.env.CODEX_THREAD_ID : undefined);
12402
+ const whose = whoseTurn(host, input);
12403
+ if (whose !== "owner")
12404
+ return {
12405
+ flush: false,
12406
+ notice: whose === "unconfirmed" && event === "UserPromptSubmit" ? unconfirmed(input) : null
12407
+ };
12327
12408
  if (event === "SessionStart") {
12328
- if (!owner())
12329
- return { flush: false };
12330
12409
  const file = process.env.CLAUDE_ENV_FILE;
12331
12410
  if (file && input.session_id && /^[A-Za-z0-9_-]+$/.test(input.session_id)) {
12332
- fs6.appendFileSync(file, `export SPHICA_PARENT_SESSION=${input.session_id}
12411
+ fs8.appendFileSync(file, `export SPHICA_PARENT_SESSION=${input.session_id}
12333
12412
  `);
12334
12413
  }
12335
12414
  attempt(pruneBaselines);
12336
12415
  return { flush: false, notice: captureNotice() };
12337
12416
  }
12338
- if (!owner())
12339
- return { flush: false };
12340
12417
  if (event === "Interrupt") {
12341
12418
  const turn2 = input.prompt_id ?? input.turn_id;
12342
12419
  if (turn2)
@@ -12412,7 +12489,7 @@ async function onHook(host, input) {
12412
12489
  function readStateFile() {
12413
12490
  let raw = {};
12414
12491
  try {
12415
- const parsed = JSON.parse(fs6.readFileSync(stateFile(), "utf8"));
12492
+ const parsed = JSON.parse(fs8.readFileSync(stateFile(), "utf8"));
12416
12493
  if (parsed && typeof parsed === "object")
12417
12494
  raw = parsed;
12418
12495
  } catch {}
@@ -12426,7 +12503,7 @@ function readStateFile() {
12426
12503
  }
12427
12504
  function writeState(s) {
12428
12505
  try {
12429
- fs6.writeFileSync(stateFile(), JSON.stringify({ ...s, pruned: s.pruned ?? readStateFile().pruned }));
12506
+ fs8.writeFileSync(stateFile(), JSON.stringify({ ...s, pruned: s.pruned ?? readStateFile().pruned }));
12430
12507
  } catch {}
12431
12508
  }
12432
12509
  function readState() {
@@ -12442,7 +12519,7 @@ function readState() {
12442
12519
  }
12443
12520
  function listQueue(dir) {
12444
12521
  try {
12445
- const names = fs6.readdirSync(dir);
12522
+ const names = fs8.readdirSync(dir);
12446
12523
  return {
12447
12524
  files: names.filter((f) => f.endsWith(".json") && !f.startsWith(".")),
12448
12525
  temp: names.filter((f) => f.endsWith(".json") && f.startsWith(".")),
@@ -12468,7 +12545,7 @@ function queueReport(now = Date.now()) {
12468
12545
  const temp = { count: 0, oldestMs: 0, bytes: 0 };
12469
12546
  for (const name of listed[k].temp)
12470
12547
  try {
12471
- const st = fs6.statSync(path7.join(dirs[k], name));
12548
+ const st = fs8.statSync(path9.join(dirs[k], name));
12472
12549
  const age = now - st.mtimeMs;
12473
12550
  if (age < TEMP_AGE_MS)
12474
12551
  continue;
@@ -12483,9 +12560,9 @@ function queueReport(now = Date.now()) {
12483
12560
  for (const name of listed[k].files ?? []) {
12484
12561
  let why = "unknown";
12485
12562
  try {
12486
- const text2 = fs6.readFileSync(path7.join(dirs[k], `${name}.reason`), "utf8");
12487
- if (REASON.test(text2))
12488
- why = text2;
12563
+ const text3 = fs8.readFileSync(path9.join(dirs[k], `${name}.reason`), "utf8");
12564
+ if (REASON.test(text3))
12565
+ why = text3;
12489
12566
  } catch {}
12490
12567
  out[why] = (out[why] ?? 0) + 1;
12491
12568
  }
@@ -12493,7 +12570,7 @@ function queueReport(now = Date.now()) {
12493
12570
  };
12494
12571
  const read = (dir, name) => {
12495
12572
  try {
12496
- return JSON.parse(fs6.readFileSync(path7.join(dir, name), "utf8"));
12573
+ return JSON.parse(fs8.readFileSync(path9.join(dir, name), "utf8"));
12497
12574
  } catch {
12498
12575
  return null;
12499
12576
  }
@@ -12522,25 +12599,25 @@ function queueReport(now = Date.now()) {
12522
12599
  };
12523
12600
  }
12524
12601
  function lock() {
12525
- const file = path7.join(spoolDir(), ".lock");
12526
- fs6.mkdirSync(spoolDir(), { recursive: true, mode: 448 });
12602
+ const file = path9.join(spoolDir(), ".lock");
12603
+ fs8.mkdirSync(spoolDir(), { recursive: true, mode: 448 });
12527
12604
  for (let attempt2 = 0;attempt2 < 2; attempt2++) {
12528
12605
  try {
12529
- fs6.writeFileSync(file, String(process.pid), { flag: "wx", mode: 384 });
12606
+ fs8.writeFileSync(file, String(process.pid), { flag: "wx", mode: 384 });
12530
12607
  return () => {
12531
12608
  try {
12532
- if (fs6.readFileSync(file, "utf8") === String(process.pid))
12533
- fs6.rmSync(file, { force: true });
12609
+ if (fs8.readFileSync(file, "utf8") === String(process.pid))
12610
+ fs8.rmSync(file, { force: true });
12534
12611
  } catch {}
12535
12612
  };
12536
12613
  } catch (e) {
12537
12614
  if (e.code !== "EEXIST")
12538
12615
  throw e;
12539
12616
  }
12540
- const st = fs6.statSync(file, { throwIfNoEntry: false });
12617
+ const st = fs8.statSync(file, { throwIfNoEntry: false });
12541
12618
  if (!st)
12542
12619
  continue;
12543
- const holder = Number(fs6.readFileSync(file, "utf8") || 0);
12620
+ const holder = Number(fs8.readFileSync(file, "utf8") || 0);
12544
12621
  const fresh = Date.now() - st.mtimeMs < 5 * 60000;
12545
12622
  const alive = (() => {
12546
12623
  if (holder <= 0)
@@ -12553,7 +12630,7 @@ function lock() {
12553
12630
  })();
12554
12631
  if (alive && fresh)
12555
12632
  return null;
12556
- fs6.rmSync(file, { force: true });
12633
+ fs8.rmSync(file, { force: true });
12557
12634
  }
12558
12635
  return null;
12559
12636
  }
@@ -12653,23 +12730,23 @@ var REJECTED = new Set([18, 19, 20, 25]);
12653
12730
  var rejected = (e) => REJECTED.has(sqliteCode(e) ?? -1);
12654
12731
  var queued = (from) => {
12655
12732
  try {
12656
- return fs6.readdirSync(from).filter((f) => f.endsWith(".json") && !f.startsWith(".")).sort().map((name) => ({ name, from }));
12733
+ return fs8.readdirSync(from).filter((f) => f.endsWith(".json") && !f.startsWith(".")).sort().map((name) => ({ name, from }));
12657
12734
  } catch {
12658
12735
  return [];
12659
12736
  }
12660
12737
  };
12661
12738
  var CODE_NAMES = { 18: "TOOBIG", 19: "CONSTRAINT", 20: "MISMATCH", 25: "RANGE" };
12662
12739
  function setAside(from, name, dir, reason2) {
12663
- fs6.mkdirSync(dir, { recursive: true, mode: 448 });
12740
+ fs8.mkdirSync(dir, { recursive: true, mode: 448 });
12664
12741
  try {
12665
- fs6.renameSync(path7.join(from, name), path7.join(dir, name));
12742
+ fs8.renameSync(path9.join(from, name), path9.join(dir, name));
12666
12743
  } catch (e) {
12667
12744
  if (e.code === "ENOENT")
12668
12745
  return;
12669
12746
  throw e;
12670
12747
  }
12671
12748
  try {
12672
- fs6.writeFileSync(path7.join(dir, `${name}.reason`), reason2, { mode: 384 });
12749
+ fs8.writeFileSync(path9.join(dir, `${name}.reason`), reason2, { mode: 384 });
12673
12750
  } catch {}
12674
12751
  }
12675
12752
  async function sendBatch(db, names) {
@@ -12679,7 +12756,7 @@ async function sendBatch(db, names) {
12679
12756
  let raw;
12680
12757
  let r;
12681
12758
  try {
12682
- raw = JSON.parse(fs6.readFileSync(path7.join(from, name), "utf8"));
12759
+ raw = JSON.parse(fs8.readFileSync(path9.join(from, name), "utf8"));
12683
12760
  } catch {
12684
12761
  setAside(from, name, rejectedDir(), "unreadable");
12685
12762
  continue;
@@ -12693,7 +12770,7 @@ async function sendBatch(db, names) {
12693
12770
  if (r)
12694
12771
  records.push({ name, from, r });
12695
12772
  else
12696
- fs6.rmSync(path7.join(from, name), { force: true });
12773
+ fs8.rmSync(path9.join(from, name), { force: true });
12697
12774
  }
12698
12775
  let sent = 0;
12699
12776
  let strayed = [];
@@ -12721,12 +12798,12 @@ async function sendBatch(db, names) {
12721
12798
  for (const x of bad)
12722
12799
  setAside(x.from, x.name, rejectedDir(), x.why);
12723
12800
  if (strayed.length) {
12724
- fs6.mkdirSync(held, { recursive: true, mode: 448 });
12801
+ fs8.mkdirSync(held, { recursive: true, mode: 448 });
12725
12802
  for (const x of strayed) {
12726
12803
  if (x.from === held)
12727
12804
  continue;
12728
12805
  try {
12729
- fs6.renameSync(path7.join(x.from, x.name), path7.join(held, x.name));
12806
+ fs8.renameSync(path9.join(x.from, x.name), path9.join(held, x.name));
12730
12807
  } catch (e) {
12731
12808
  if (e.code !== "ENOENT")
12732
12809
  throw e;
@@ -12736,7 +12813,7 @@ async function sendBatch(db, names) {
12736
12813
  const moved = new Set([...bad, ...strayed].map((x) => x.name));
12737
12814
  for (const x of records)
12738
12815
  if (!moved.has(x.name))
12739
- fs6.rmSync(path7.join(x.from, x.name), { force: true });
12816
+ fs8.rmSync(path9.join(x.from, x.name), { force: true });
12740
12817
  return { sent, rejected: bad.length };
12741
12818
  }
12742
12819
  async function sendObservations(db, names) {
@@ -12747,16 +12824,16 @@ async function sendObservations(db, names) {
12747
12824
  };
12748
12825
  const rows = [];
12749
12826
  for (const { name, from } of names) {
12750
- let text2;
12827
+ let text3;
12751
12828
  try {
12752
- text2 = fs6.readFileSync(path7.join(from, name), "utf8");
12829
+ text3 = fs8.readFileSync(path9.join(from, name), "utf8");
12753
12830
  } catch {
12754
12831
  continue;
12755
12832
  }
12756
12833
  let o = null;
12757
12834
  let why = "unreadable";
12758
12835
  try {
12759
- o = observation(JSON.parse(text2));
12836
+ o = observation(JSON.parse(text3));
12760
12837
  why = "shape";
12761
12838
  } catch {}
12762
12839
  if (o)
@@ -12788,7 +12865,7 @@ async function sendObservations(db, names) {
12788
12865
  aside(x.name, why);
12789
12866
  else
12790
12867
  try {
12791
- fs6.rmSync(path7.join(callsDir(), x.name), { force: true });
12868
+ fs8.rmSync(path9.join(callsDir(), x.name), { force: true });
12792
12869
  } catch {}
12793
12870
  }
12794
12871
  return true;
@@ -12931,7 +13008,7 @@ async function observeRecordCall(file, input, owner, waitMs = OBSERVE_WAIT_MS) {
12931
13008
  }
12932
13009
  if (kept)
12933
13010
  try {
12934
- fs6.rmSync(kept, { force: true });
13011
+ fs8.rmSync(kept, { force: true });
12935
13012
  } catch {}
12936
13013
  }
12937
13014
  async function main() {