@chibitek/chibi 0.1.183 → 0.1.184

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 (68) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-BJRKA6IQ.js → abnfDiagram-O67JEVCF-D63grDEy.js} +1 -1
  2. package/dist/assets/{arc-CZc_uW-u.js → arc-bQvylCdS.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-DNLaTXeO.js → architectureDiagram-NJMV4G6O-BOAFaaj7.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-DLXsik0_.js → blockDiagram-BEXU5L5S-ewLAgFlb.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-DG6hN1C0.js → c4Diagram-YGBWAQC7-Dn_C6A7b.js} +1 -1
  6. package/dist/assets/channel-DaRjZag9.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-D5Yjh7-1.js → chunk-2Q5K7J3B-DpB_wNSI.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-Bxyjopy0.js → chunk-3FUC2YCW-DIelvlCV.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-DDQZDrcU.js → chunk-5VM5RSS4-O-aALIul.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-OwVykJDf.js → chunk-GTNCS2PH-Dqe5r4Ji.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-BJRJdRRn.js → chunk-GWA4HPMP-FzFr6U_I.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-D0rQf2t4.js → chunk-JWPE2WC7-BuJO0Fyh.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-DbgIhGxq.js → chunk-NETBCI7D-DMgFuMgZ.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-NVC6qgIT.js → chunk-WEXAMYUT-BYXYAyMu.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-B9iYAoH7.js → chunk-XXDRQBXY-s_OT2iv7.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-Cma68soF.js → classDiagram-v2-NBCMYWYE-Cdbr4CZV.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-BrXaARl8.js → cose-bilkent-JH36ORCC-CXjx4058.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-DaxVySTi.js → cynefin-OW5HDTMX-Cc2YqzW6.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-BhqakyPn.js → cynefinDiagram-VND7K2PF-Cze_i1Vk.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-C1GSPYtM.js → dagre-6A5THRUB-oPouQ7XU.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-BJ3lUPTt.js → diagram-22UHCM2B-DNRc977u.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-B15DdW5N.js → diagram-3UASUU5V-B8vBo05Y.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-CXiw2lST.js → diagram-ATOU4E4O-dCch9eKa.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-DoqH99bW.js → diagram-CDSNMT55-CYJSen9G.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-snN4K-CB.js → diagram-MLGK6HIB-RxYVGgc6.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-DgJvwpZO.js → diagram-MPIPVDR6-B-UyrObe.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-AO646Cux.js → ebnfDiagram-ZINNZB2B-CxGXwVT7.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-BQwiFuXz.js → elk-276RUBZZ-CHGRRKuJ.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-B5VI88HR.js → erDiagram-OPXOYQCR-BMJusoDl.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-BNaAddPG.js → flowDiagram-KWPJA3E3-DtiBETZe.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-C_ZoEfA5.js → ganttDiagram-FUAMR5RP-DAXqRUQM.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-xthNWdmM.js → gitGraphDiagram-X574FWY7-Cx_M7do1.js} +1 -1
  33. package/dist/assets/{index-DmYwoh4R.js → index-COCy7XsD.js} +133 -133
  34. package/dist/assets/{index-ASohJJer.js → index-DKt9qb9g.js} +1 -1
  35. package/dist/assets/{infoDiagram-VRGFBTTK-Qhrkz09J.js → infoDiagram-VRGFBTTK-CNgfLxed.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-OU5B5YK6-DzU3-GrV.js → ishikawaDiagram-OU5B5YK6-BvdGqyOz.js} +1 -1
  37. package/dist/assets/{journeyDiagram-ZHPQQLJL-Dif-aG4a.js → journeyDiagram-ZHPQQLJL-atzjOsJ2.js} +1 -1
  38. package/dist/assets/{kanban-definition-PNTS6WVX-NJ0l6rbK.js → kanban-definition-PNTS6WVX-miq8ywtS.js} +1 -1
  39. package/dist/assets/{linear-DpEaZ_8H.js → linear-3skQIwEd.js} +1 -1
  40. package/dist/assets/{mermaid.core-DOBTmT-1.js → mermaid.core-CcefVt63.js} +5 -5
  41. package/dist/assets/{mindmap-definition-NLK3R4M7-kPRBSQ6K.js → mindmap-definition-NLK3R4M7-CyJLiFXW.js} +1 -1
  42. package/dist/assets/{pegDiagram-GJSIUBJH-BgX62j0G.js → pegDiagram-GJSIUBJH-DdBX63bl.js} +1 -1
  43. package/dist/assets/{pieDiagram-5QR66LMP-DpC0-6hx.js → pieDiagram-5QR66LMP-DNO9-2f5.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-O4NWA36T-CNrmwxvV.js → quadrantDiagram-O4NWA36T-BciZP71K.js} +1 -1
  45. package/dist/assets/{railroadDiagram-XR7U4H2S-wl7o4Y2J.js → railroadDiagram-XR7U4H2S-4IdVOKPa.js} +1 -1
  46. package/dist/assets/{requirementDiagram-PLB6GJNP-D2qhVvpT.js → requirementDiagram-PLB6GJNP-DFdsFYy-.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-IPEJSGJF-DZOSOZWs.js → sankeyDiagram-IPEJSGJF-HH2WFlmw.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-PO4LG4MO-eBogKj3g.js → sequenceDiagram-PO4LG4MO-CP91Sy-s.js} +1 -1
  49. package/dist/assets/{sizeCapture-INFHLROL-Dp_Vdw0m.js → sizeCapture-INFHLROL-DhZiuL4S.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-GCMORJYK-K79Em0_p.js → stateDiagram-v2-GCMORJYK-DIa0uzhR.js} +1 -1
  51. package/dist/assets/{swimlanes-2SLR337P-ByKYlFa_.js → swimlanes-2SLR337P-CXr7kql9.js} +1 -1
  52. package/dist/assets/swimlanesDiagram-TC7HE7FX-CtuksGU4.js +8 -0
  53. package/dist/assets/{timeline-definition-EJHVYXUP-CzeMeYU0.js → timeline-definition-EJHVYXUP-BidOWl1X.js} +1 -1
  54. package/dist/assets/{usecaseDiagram-POWQR4AR-uQjp5Yz3.js → usecaseDiagram-POWQR4AR-Dt0DqsBc.js} +1 -1
  55. package/dist/assets/{vennDiagram-UO4OBE2U-De8_78dQ.js → vennDiagram-UO4OBE2U-DMfDgcZH.js} +1 -1
  56. package/dist/assets/{wardleyDiagram-VNRHLVJA-Dk_VO2LR.js → wardleyDiagram-VNRHLVJA-jgsJZ4n4.js} +1 -1
  57. package/dist/assets/{xychartDiagram-PMCCYNJV-DMx2Y7qW.js → xychartDiagram-PMCCYNJV-AllqBdcw.js} +1 -1
  58. package/dist/handbook/atomic-handbook.html +1 -5
  59. package/dist/index.html +1 -1
  60. package/dist-server/index.js +149 -113
  61. package/dist-server/server/workspace-backup-copy.js +34 -1
  62. package/dist-server/server/workspace-backup-http.js +8 -5
  63. package/dist-server/server/workspace-backup-secrets.js +2 -2
  64. package/dist-server/server/workspace-backup.js +38 -52
  65. package/dist-server/shared/workspace-backup.js +23 -1
  66. package/package.json +1 -1
  67. package/dist/assets/channel-DmcLphYK.js +0 -1
  68. package/dist/assets/swimlanesDiagram-TC7HE7FX-BnN5frkm.js +0 -8
@@ -32204,7 +32204,7 @@ async function receiveGoalCommand(runtime, store2, botId, threadId, command, tex
32204
32204
  // server/index.ts
32205
32205
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
32206
32206
  import { createHash as createHash54, randomBytes as randomBytes15, randomUUID as randomUUID49, timingSafeEqual as timingSafeEqual9 } from "node:crypto";
32207
- import { existsSync as existsSync84, readFileSync as readFileSync107, realpathSync as realpathSync15, rmSync as rmSync24, mkdirSync as mkdirSync72, statSync as statSync30 } from "node:fs";
32207
+ import { existsSync as existsSync84, readFileSync as readFileSync108, realpathSync as realpathSync15, rmSync as rmSync24, mkdirSync as mkdirSync72, statSync as statSync30 } from "node:fs";
32208
32208
  import { rm as removeDirectory } from "node:fs/promises";
32209
32209
  import { createServer as createServer4 } from "node:http";
32210
32210
 
@@ -101057,7 +101057,7 @@ import {
101057
101057
  lstatSync as lstatSync13,
101058
101058
  mkdirSync as mkdirSync55,
101059
101059
  openSync as openSync17,
101060
- readFileSync as readFileSync86,
101060
+ readFileSync as readFileSync87,
101061
101061
  readdirSync as readdirSync23,
101062
101062
  readlinkSync as readlinkSync2,
101063
101063
  readSync as readSync12,
@@ -101072,7 +101072,7 @@ import { backup, DatabaseSync as DatabaseSync3 } from "node:sqlite";
101072
101072
 
101073
101073
  // server/workspace-backup-copy.ts
101074
101074
  import { createHash as createHash43 } from "node:crypto";
101075
- import { closeSync as closeSync16, constants as constants10, fstatSync as fstatSync9, fsyncSync as fsyncSync4, lstatSync as lstatSync11, openSync as openSync16, readSync as readSync11, writeSync as writeSync3 } from "node:fs";
101075
+ import { closeSync as closeSync16, constants as constants10, fstatSync as fstatSync9, fsyncSync as fsyncSync4, lstatSync as lstatSync11, openSync as openSync16, readFileSync as readFileSync83, readSync as readSync11, writeSync as writeSync3 } from "node:fs";
101076
101076
 
101077
101077
  // server/workspace-backup-archive.ts
101078
101078
  import { createCipheriv, createDecipheriv, createHash as createHash42, randomBytes as randomBytes7, scrypt } from "node:crypto";
@@ -101242,6 +101242,31 @@ function copyRegular(source3, destination, onLiveChange) {
101242
101242
  }
101243
101243
  return captured ?? null;
101244
101244
  }
101245
+ var MAX_METADATA_BYTES = 64 * 1024 ** 2;
101246
+ function entryExists(path2) {
101247
+ try {
101248
+ lstatSync11(path2);
101249
+ return true;
101250
+ } catch (error51) {
101251
+ if (error51.code === "ENOENT") return false;
101252
+ throw error51;
101253
+ }
101254
+ }
101255
+ function privateJson(path2) {
101256
+ const fd = openSync16(path2, constants10.O_RDONLY | constants10.O_NOFOLLOW);
101257
+ try {
101258
+ const stat8 = fstatSync9(fd);
101259
+ if (!stat8.isFile() || stat8.size > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata is too large or is not a regular file.");
101260
+ return JSON.parse(readFileSync83(fd, "utf8"));
101261
+ } finally {
101262
+ closeSync16(fd);
101263
+ }
101264
+ }
101265
+ function writeJson(path2, value) {
101266
+ const text18 = JSON.stringify(value);
101267
+ if (Buffer.byteLength(text18) > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata exceeds the size limit.");
101268
+ writeFileAtomic(path2, text18, { mode: 384 });
101269
+ }
101245
101270
 
101246
101271
  // server/workspace-backup-policy.ts
101247
101272
  var PORTABLE_CONFIG_KEYS = [
@@ -101273,8 +101298,33 @@ function ephemeralWorkspaceTokenPath(path2) {
101273
101298
  return /^hook-tokens(?:\/|$)/.test(path2);
101274
101299
  }
101275
101300
 
101301
+ // shared/workspace-backup.ts
101302
+ var WORKSPACE_RESTORE_PARTS = ["conversations", "settings", "routines", "credentials", "desktops"];
101303
+ var PART_BY_NAME = {
101304
+ "config.json": "settings",
101305
+ "webhooks.json": "settings",
101306
+ "routines.json": "routines",
101307
+ "calendar-calls.json": "routines",
101308
+ "providers": "credentials",
101309
+ "workspace-credentials.json": "credentials",
101310
+ "instance-keys.json": "credentials",
101311
+ "external-runtimes.json": "credentials",
101312
+ "vm-home": "desktops",
101313
+ "vm-homes": "desktops"
101314
+ };
101315
+ function workspaceRestorePart(name2) {
101316
+ const key5 = name2.toLowerCase();
101317
+ return Object.hasOwn(PART_BY_NAME, key5) ? PART_BY_NAME[key5] : "conversations";
101318
+ }
101319
+ function validWorkspaceRestoreKeep(value) {
101320
+ if (value === void 0) return [];
101321
+ if (!Array.isArray(value) || !value.every((part) => WORKSPACE_RESTORE_PARTS.includes(part)) || new Set(value).size !== value.length) throw new Error("Invalid restore choices.");
101322
+ if (value.includes("settings") && !value.includes("credentials")) throw new Error("Restore app settings with saved credentials, or keep both on this computer.");
101323
+ return value;
101324
+ }
101325
+
101276
101326
  // server/workspace-backup-private.ts
101277
- import { existsSync as existsSync58, readFileSync as readFileSync83 } from "node:fs";
101327
+ import { existsSync as existsSync58, readFileSync as readFileSync84 } from "node:fs";
101278
101328
  import { join as join107 } from "node:path";
101279
101329
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
101280
101330
  function record9(value) {
@@ -101287,7 +101337,7 @@ function privateBotIds(dataDir2) {
101287
101337
  if (!existsSync58(path2)) return { botIds, threadIds };
101288
101338
  let value;
101289
101339
  try {
101290
- value = JSON.parse(readFileSync83(path2, "utf8"));
101340
+ value = JSON.parse(readFileSync84(path2, "utf8"));
101291
101341
  } catch {
101292
101342
  return { botIds, threadIds };
101293
101343
  }
@@ -101339,7 +101389,7 @@ function scrubPrivateMessages(dbPath, botIds, threadIds) {
101339
101389
 
101340
101390
  // server/workspace-backup-secrets.ts
101341
101391
  import { randomUUID as randomUUID34 } from "node:crypto";
101342
- import { existsSync as existsSync59, readFileSync as readFileSync84 } from "node:fs";
101392
+ import { existsSync as existsSync59, readFileSync as readFileSync85 } from "node:fs";
101343
101393
  import { join as join108 } from "node:path";
101344
101394
 
101345
101395
  // electron/workspace-credentials.mjs
@@ -101381,7 +101431,7 @@ function desktopWorkspaceSecrets() {
101381
101431
  }
101382
101432
  function installWorkspaceSecrets(port, dataDir2, restore2) {
101383
101433
  if (!port) {
101384
- if (restore2.restored && restore2.id && restore2.summary?.secrets) markRestoreSecrets(dataDir2, restore2, "failed");
101434
+ if (restore2.restored && restore2.id && restore2.summary?.secrets && !restore2.keep?.includes("credentials")) markRestoreSecrets(dataDir2, restore2, "failed");
101385
101435
  return;
101386
101436
  }
101387
101437
  const waiting = /* @__PURE__ */ new Map();
@@ -101417,7 +101467,7 @@ function installWorkspaceSecrets(port, dataDir2, restore2) {
101417
101467
  return (await request4({ action: "apply", id })).applied === true;
101418
101468
  }
101419
101469
  };
101420
- if (restore2.restored && restore2.id && restore2.summary?.secrets) {
101470
+ if (restore2.restored && restore2.id && restore2.summary?.secrets && !restore2.keep?.includes("credentials")) {
101421
101471
  void desktop.apply(restore2.id).then(
101422
101472
  (applied) => markRestoreSecrets(dataDir2, restore2, applied ? "applied" : "failed"),
101423
101473
  (error51) => {
@@ -101431,14 +101481,14 @@ function markRestoreSecrets(dataDir2, restore2, outcome) {
101431
101481
  restore2.secrets = outcome;
101432
101482
  const path2 = join108(dataDir2, ".backups", "last-restore.json");
101433
101483
  if (!existsSync59(path2)) return;
101434
- const receipt = JSON.parse(readFileSync84(path2, "utf8"));
101484
+ const receipt = JSON.parse(readFileSync85(path2, "utf8"));
101435
101485
  if (!receipt || typeof receipt !== "object" || receipt.id !== restore2.id) return;
101436
101486
  writeFileAtomic(path2, JSON.stringify({ ...receipt, secrets: outcome }), { mode: 384 });
101437
101487
  }
101438
101488
 
101439
101489
  // server/workspace-restore-paths.ts
101440
101490
  import { execFileSync as execFileSync3 } from "node:child_process";
101441
- import { existsSync as existsSync60, lstatSync as lstatSync12, readFileSync as readFileSync85, readdirSync as readdirSync22, renameSync as renameSync15, symlinkSync as symlinkSync2, writeFileSync as writeFileSync31 } from "node:fs";
101491
+ import { existsSync as existsSync60, lstatSync as lstatSync12, readFileSync as readFileSync86, readdirSync as readdirSync22, renameSync as renameSync15, symlinkSync as symlinkSync2, writeFileSync as writeFileSync31 } from "node:fs";
101442
101492
  import { dirname as dirname30, isAbsolute as isAbsolute19, join as join109, posix as posix3, relative as relative9, resolve as resolve26, win32 as win324 } from "node:path";
101443
101493
  function validRelative(path2) {
101444
101494
  return !!path2 && path2.length <= 4096 && !isAbsolute19(path2) && !/[\\\0:]/.test(path2) && path2.split("/").every((part) => !!part && part !== "." && part !== ".." && !/[. ]$/.test(part) && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part));
@@ -101495,7 +101545,7 @@ function rebaseTree(root, pairs2) {
101495
101545
  if (name2 === "projects" && relative9(root, path2).startsWith("providers")) renameProjectDirs(path2, pairs2);
101496
101546
  if (depth < 12) visit3(path2, depth + 1);
101497
101547
  } else if (stat8.isFile() && TEXT_FILE.test(name2) && stat8.size <= MAX_REWRITE_BYTES) {
101498
- const text18 = readFileSync85(path2, "utf8");
101548
+ const text18 = readFileSync86(path2, "utf8");
101499
101549
  const next = rebaseText(text18, pairs2);
101500
101550
  if (next !== text18) writeFileSync31(path2, next, { mode: stat8.mode & 511 });
101501
101551
  }
@@ -101552,16 +101602,16 @@ function checkoutRemote(directory) {
101552
101602
  try {
101553
101603
  readdirSync22(gitDir);
101554
101604
  } catch {
101555
- const pointer = /^gitdir:\s*(.+)$/m.exec(readFileSync85(gitDir, "utf8"))?.[1]?.trim();
101605
+ const pointer = /^gitdir:\s*(.+)$/m.exec(readFileSync86(gitDir, "utf8"))?.[1]?.trim();
101556
101606
  if (!pointer) return null;
101557
101607
  gitDir = isAbsolute19(pointer) ? pointer : join109(directory, pointer);
101558
101608
  const common = join109(gitDir, "commondir");
101559
101609
  if (existsSync60(common)) {
101560
- const shared = readFileSync85(common, "utf8").trim();
101610
+ const shared = readFileSync86(common, "utf8").trim();
101561
101611
  gitDir = isAbsolute19(shared) ? shared : join109(gitDir, shared);
101562
101612
  }
101563
101613
  }
101564
- const config2 = readFileSync85(join109(gitDir, "config"), "utf8");
101614
+ const config2 = readFileSync86(join109(gitDir, "config"), "utf8");
101565
101615
  return /\[remote "origin"\][^[]*?\burl\s*=\s*(\S+)/.exec(config2)?.[1] ?? null;
101566
101616
  } catch {
101567
101617
  return null;
@@ -101570,7 +101620,6 @@ function checkoutRemote(directory) {
101570
101620
 
101571
101621
  // server/workspace-backup.ts
101572
101622
  var MAX_WORKSPACE_BACKUP_FILES = 1e5;
101573
- var MAX_METADATA_BYTES = 16 * 1024 ** 2;
101574
101623
  var MAX_REPORTED_PATHS = 200;
101575
101624
  var ID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
101576
101625
  var EXCLUDED = /* @__PURE__ */ new Set([
@@ -101592,6 +101641,7 @@ var EXCLUDED = /* @__PURE__ */ new Set([
101592
101641
  "messages.db-wal",
101593
101642
  "messages.db-shm"
101594
101643
  ]);
101644
+ var ANTIGRAVITY_TOOL_CATALOG = /^providers\/antigravity\/[^/]+\/antigravity-acp\/brain\/[^/]+\/mcp$/;
101595
101645
  var REINSTALLABLE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".pnpm-store", ".venv", "venv", "__pycache__", ".next", ".turbo", "DerivedData", ".build"]);
101596
101646
  var BROWSER_LOCK_LINKS = /* @__PURE__ */ new Set(["lock", ".parentlock", "SingletonLock", "SingletonSocket", "SingletonCookie"]);
101597
101647
  var SECRETS_NOTE = "Saved credentials, provider and MCP connections, managed provider login homes and browser login profiles are not transferred. Destination connections are preserved; reconnect on a new device.";
@@ -101651,30 +101701,6 @@ function newJob(dataDir2) {
101651
101701
  function record10(value) {
101652
101702
  return value !== null && typeof value === "object" && !Array.isArray(value);
101653
101703
  }
101654
- function entryExists(path2) {
101655
- try {
101656
- lstatSync13(path2);
101657
- return true;
101658
- } catch (error51) {
101659
- if (error51.code === "ENOENT") return false;
101660
- throw error51;
101661
- }
101662
- }
101663
- function privateJson(path2) {
101664
- const fd = openSync17(path2, constants11.O_RDONLY | constants11.O_NOFOLLOW);
101665
- try {
101666
- const stat8 = fstatSync10(fd);
101667
- if (!stat8.isFile() || stat8.size > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata is too large or is not a regular file.");
101668
- return JSON.parse(readFileSync86(fd, "utf8"));
101669
- } finally {
101670
- closeSync17(fd);
101671
- }
101672
- }
101673
- function writeJson(path2, value) {
101674
- const text18 = JSON.stringify(value);
101675
- if (Buffer.byteLength(text18) > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata exceeds the size limit.");
101676
- writeFileAtomic(path2, text18, { mode: 384 });
101677
- }
101678
101704
  function privateMetadata(manifest) {
101679
101705
  return { summary: manifest.summary, clientState: manifest.clientState };
101680
101706
  }
@@ -101819,6 +101845,7 @@ async function createWorkspaceBackup(dataDir2, options) {
101819
101845
  continue;
101820
101846
  }
101821
101847
  if (prefix && REINSTALLABLE_DIRS.has(name2) && (stat8.isDirectory() || stat8.isSymbolicLink()) || path3.startsWith("task-workspaces/") && (name2 === ".git" || stat8.isDirectory() && /^(?:.+-derived|.+\.xcarchive|dist.*|release)$/.test(name2))) continue;
101848
+ if (stat8.isDirectory() && ANTIGRAVITY_TOOL_CATALOG.test(path3)) continue;
101822
101849
  if (stat8.isSymbolicLink() && BROWSER_LOCK_LINKS.has(name2)) continue;
101823
101850
  if (stat8.isSymbolicLink()) {
101824
101851
  if (/^workspaces\/[^/]+\/\.(?:claude|agents|grok)\/skills\/[^/]+$/.test(path3)) {
@@ -101846,7 +101873,7 @@ async function createWorkspaceBackup(dataDir2, options) {
101846
101873
  writeJson(destination, Array.isArray(value) ? value.filter((bot) => !(record10(bot) && bot.personal === true)) : value);
101847
101874
  copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
101848
101875
  } else if (hiddenIds.size && name2.endsWith(".jsonl")) {
101849
- const kept = readFileSync86(source3, "utf8").split("\n").filter((line3) => ![...hiddenIds].some((id) => line3.includes(id)));
101876
+ const kept = readFileSync87(source3, "utf8").split("\n").filter((line3) => ![...hiddenIds].some((id) => line3.includes(id)));
101850
101877
  writeFileSync32(destination, kept.join("\n"), { mode: 384, flag: "wx" });
101851
101878
  copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
101852
101879
  } else if ((path3 === "config.json" || path3 === "webhooks.json") && !secrets) {
@@ -102083,14 +102110,17 @@ function readStagedWorkspaceBackup(dataDir2, id) {
102083
102110
  const manifest = validateManifest(privateJson(join110(directory, "staged", "manifest.json")));
102084
102111
  return { id, ...privateMetadata(manifest) };
102085
102112
  }
102086
- function commitPendingWorkspaceRestore(dataDir2, id) {
102113
+ function commitPendingWorkspaceRestore(dataDir2, id, keep = []) {
102114
+ keep = validWorkspaceRestoreKeep(keep);
102087
102115
  const root = backupRoot(dataDir2);
102088
102116
  if (existsSync61(join110(root, "pending-restore.json"))) throw new Error("A workspace restore is already waiting for restart.");
102089
102117
  if (existsSync61(join110(root, `safety-${id}`))) throw new Error("This restore was already attempted. Preview the backup again to create a fresh restore attempt.");
102090
102118
  const metadata = readStagedWorkspaceBackup(dataDir2, id);
102091
102119
  const manifest = validateStaged(join110(jobPath(dataDir2, id), "staged"));
102092
- prepareRestore(dataDir2, id, manifest);
102093
- writeJson(join110(root, "pending-restore.json"), { id });
102120
+ const incoming = new Set(manifest.entries.map((entry) => workspaceRestorePart(entry.path.split("/")[0])));
102121
+ if (keep.length && ![...incoming].some((part) => !keep.includes(part))) throw new Error("Choose at least one part of this backup to restore.");
102122
+ prepareRestore(dataDir2, id, manifest, keep);
102123
+ writeJson(join110(root, "pending-restore.json"), { id, keep });
102094
102124
  return { id, restartRequired: true, summary: metadata.summary };
102095
102125
  }
102096
102126
  function readPendingWorkspaceRestoreMetadata(dataDir2) {
@@ -102160,15 +102190,16 @@ function rebaseMessage(message4, pairs2) {
102160
102190
  function pathPairs(dataDir2, manifest) {
102161
102191
  return restorePathPairs({ dataDir: manifest.sourceDataDir, home: manifest.sourceHome }, { dataDir: resolve27(dataDir2), home: homedir42() });
102162
102192
  }
102163
- function prepareRestore(dataDir2, id, manifest) {
102193
+ function prepareRestore(dataDir2, id, manifest, keep) {
102164
102194
  assertLocalAuthOutsideSnapshot(dataDir2);
102165
102195
  const pairs2 = pathPairs(dataDir2, manifest);
102166
- const secrets = manifest.summary.secrets === true;
102196
+ const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
102167
102197
  const job = jobPath(dataDir2, id);
102168
102198
  const prepared = join110(job, "apply", "data");
102169
102199
  if (existsSync61(join110(job, "apply"))) rmSync18(join110(job, "apply"), { recursive: true, force: true });
102170
102200
  folder2(prepared);
102171
- const installed2 = manifest.entries.filter((entry) => !ephemeralWorkspaceTokenPath(entry.path));
102201
+ const kept = (path2) => keep.includes(workspaceRestorePart(path2.split("/")[0]));
102202
+ const installed2 = manifest.entries.filter((entry) => !ephemeralWorkspaceTokenPath(entry.path) && !kept(entry.path));
102172
102203
  for (const entry of installed2.filter((entry2) => entry2.type === "directory")) folder2(join110(prepared, entry.path));
102173
102204
  for (const entry of installed2) {
102174
102205
  const destination = join110(prepared, entry.path);
@@ -102176,9 +102207,9 @@ function prepareRestore(dataDir2, id, manifest) {
102176
102207
  }
102177
102208
  const unresolved = { paths: /* @__PURE__ */ new Set(), exists: (path2) => {
102178
102209
  const inside2 = relative10(resolve27(dataDir2), path2);
102179
- return inside2 && !inside2.startsWith("..") && !isAbsolute20(inside2) ? entryExists(join110(prepared, inside2)) : existsSync61(path2);
102210
+ return inside2 && !inside2.startsWith("..") && !isAbsolute20(inside2) && !kept(inside2) ? entryExists(join110(prepared, inside2)) : existsSync61(path2);
102180
102211
  } };
102181
- const skippedLinks = restoreLinks(prepared, dataDir2, manifest.links ?? [], pairs2, unresolved.paths);
102212
+ const skippedLinks = restoreLinks(prepared, dataDir2, (manifest.links ?? []).filter((link2) => !kept(link2.path)), pairs2, unresolved.paths);
102182
102213
  if (pairs2.length) rebaseTree(prepared, pairs2);
102183
102214
  const changeJson = (name2, change) => {
102184
102215
  const path2 = join110(prepared, name2);
@@ -102196,7 +102227,7 @@ function prepareRestore(dataDir2, id, manifest) {
102196
102227
  });
102197
102228
  const oldConfig = join110(dataDir2, "config.json");
102198
102229
  const newConfig = join110(prepared, "config.json");
102199
- if (!secrets && (existsSync61(oldConfig) || existsSync61(newConfig))) {
102230
+ if (!kept("config.json") && !secrets && (existsSync61(oldConfig) || existsSync61(newConfig))) {
102200
102231
  writeJson(newConfig, restoredWorkspaceConfig(existsSync61(newConfig) ? privateJson(newConfig) : {}, existsSync61(oldConfig) ? privateJson(oldConfig) : {}));
102201
102232
  }
102202
102233
  changeJson("config.json", (value) => rebaseFields(value, pairs2, unresolved));
@@ -102205,9 +102236,9 @@ function prepareRestore(dataDir2, id, manifest) {
102205
102236
  folder2(join110(prepared, "providers", "native-vault"));
102206
102237
  copyFileSync3(vaultKey, join110(prepared, "providers", "native-vault", "key.bin"));
102207
102238
  }
102208
- const browserHomes = ["vm-home"];
102239
+ const browserHomes = kept("vm-home") ? [] : ["vm-home"];
102209
102240
  const vmHomes = join110(dataDir2, "vm-homes");
102210
- if (entryExists(vmHomes)) {
102241
+ if (!kept("vm-homes") && entryExists(vmHomes)) {
102211
102242
  if (!lstatSync13(vmHomes).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
102212
102243
  for (const name2 of readdirSync23(vmHomes)) if (validRelative(name2)) browserHomes.push(`vm-homes/${name2}`);
102213
102244
  }
@@ -102301,7 +102332,7 @@ function readLastWorkspaceRestore(dataDir2) {
102301
102332
  if (!record10(raw) || raw.restored !== true || typeof raw.id !== "string" || !ID2.test(raw.id)) throw new Error("Invalid workspace restore receipt.");
102302
102333
  return raw;
102303
102334
  }
102304
- function finishRestore(dataDir2, id, consumePending = true) {
102335
+ function finishRestore(dataDir2, id, consumePending = true, keep = []) {
102305
102336
  const root = backupRoot(dataDir2);
102306
102337
  const { summary, clientState } = readStagedWorkspaceBackup(dataDir2, id);
102307
102338
  const draftAttachments = clientState["omb-draft-attachments"];
@@ -102317,7 +102348,7 @@ function finishRestore(dataDir2, id, consumePending = true) {
102317
102348
  const unresolvedFile = join110(jobPath(dataDir2, id), "unresolved.json");
102318
102349
  const listed = existsSync61(unresolvedFile) ? privateJson(unresolvedFile) : [];
102319
102350
  const unresolvedPaths = Array.isArray(listed) ? listed.filter((path2) => typeof path2 === "string") : [];
102320
- const result = { restored: true, id, safetyCopyPath: join110(root, `safety-${id}`), summary, clientState, unresolvedPaths };
102351
+ const result = { restored: true, id, safetyCopyPath: join110(root, `safety-${id}`), summary, clientState, unresolvedPaths, keep };
102321
102352
  writeJson(join110(root, "last-restore.json"), result);
102322
102353
  if (consumePending) rmSync18(join110(root, "pending-restore.json"), { force: true });
102323
102354
  return result;
@@ -102337,25 +102368,28 @@ function applyPendingWorkspaceRestore(dataDir2) {
102337
102368
  if (previous2.phase === "committed" && existsSync61(pendingFile)) {
102338
102369
  const pending3 = privateJson(pendingFile);
102339
102370
  if (record10(pending3) && pending3.id === previous2.id) {
102340
- return finishRestore(dataDir2, previous2.id);
102371
+ return finishRestore(dataDir2, previous2.id, true, validWorkspaceRestoreKeep(previous2.keep));
102341
102372
  }
102342
102373
  }
102343
102374
  }
102344
102375
  const pending2 = readPendingWorkspaceRestoreMetadata(dataDir2);
102345
102376
  if (!pending2) return { restored: false };
102377
+ const keep = validWorkspaceRestoreKeep(privateJson(pendingFile).keep);
102378
+ const kept = (name2) => keep.includes(workspaceRestorePart(name2));
102346
102379
  const staged = join110(jobPath(dataDir2, pending2.id), "staged");
102347
102380
  const manifest = validateStaged(staged);
102348
- const prepared = prepareRestore(dataDir2, pending2.id, manifest);
102381
+ const prepared = prepareRestore(dataDir2, pending2.id, manifest, keep);
102349
102382
  const safetyCopyPath = join110(root, `safety-${pending2.id}`);
102350
102383
  if (existsSync61(safetyCopyPath)) throw new Error("A safety copy already exists for this restore. Original files have not been changed.");
102351
102384
  folder2(join110(safetyCopyPath, "data"));
102352
- const secrets = manifest.summary.secrets === true;
102385
+ const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
102353
102386
  const journal = {
102354
102387
  id: pending2.id,
102355
102388
  phase: "applying",
102356
- existing: readdirSync23(dataDir2).filter((name2) => !preserved(name2, secrets)).sort(),
102357
- incoming: readdirSync23(prepared).sort(),
102358
- secrets
102389
+ existing: readdirSync23(dataDir2).filter((name2) => !preserved(name2, secrets) && !kept(name2)).sort(),
102390
+ incoming: readdirSync23(prepared).filter((name2) => !kept(name2)).sort(),
102391
+ secrets,
102392
+ keep
102359
102393
  };
102360
102394
  for (const name2 of [...journal.existing, ...journal.incoming]) {
102361
102395
  if (!validRelative(name2) || name2.includes("/") || preserved(name2, secrets)) throw new Error("Unsafe workspace restore target.");
@@ -102366,7 +102400,7 @@ function applyPendingWorkspaceRestore(dataDir2) {
102366
102400
  try {
102367
102401
  for (const name2 of journal.existing) renameSync16(join110(dataDir2, name2), join110(safetyCopyPath, "data", name2));
102368
102402
  for (const name2 of journal.incoming) if (entryExists(join110(prepared, name2))) renameSync16(join110(prepared, name2), join110(dataDir2, name2));
102369
- finishRestore(dataDir2, pending2.id, false);
102403
+ finishRestore(dataDir2, pending2.id, false, keep);
102370
102404
  writeJson(journalFile2, { ...journal, phase: "committed" });
102371
102405
  } catch (error51) {
102372
102406
  rollback(dataDir2, journal);
@@ -102374,7 +102408,7 @@ function applyPendingWorkspaceRestore(dataDir2) {
102374
102408
  rmSync18(pendingFile, { force: true });
102375
102409
  throw new Error("The workspace restore failed and the previous workspace was recovered.", { cause: error51 });
102376
102410
  }
102377
- return finishRestore(dataDir2, pending2.id);
102411
+ return finishRestore(dataDir2, pending2.id, true, keep);
102378
102412
  }
102379
102413
  function removeWorkspaceBackupJob(dataDir2, id) {
102380
102414
  const path2 = jobPath(dataDir2, id);
@@ -102514,7 +102548,8 @@ function createWorkspaceBackupRoutes(options) {
102514
102548
  safetyCopyPath: restored.safetyCopyPath ?? null,
102515
102549
  // What Settings shows after a restore: what to sign in to or clone again.
102516
102550
  lastRestore: restored.restored ? {
102517
- secretsIncluded: restored.summary?.secrets === true,
102551
+ secretsIncluded: restored.summary?.secrets === true && !restored.keep?.includes("credentials"),
102552
+ keep: restored.keep ?? [],
102518
102553
  secrets: restored.secrets ?? null,
102519
102554
  unresolvedPaths: restored.unresolvedPaths ?? [],
102520
102555
  checkouts: restored.summary?.checkouts ?? [],
@@ -102527,7 +102562,7 @@ function createWorkspaceBackupRoutes(options) {
102527
102562
  const body = external_exports.object({ restoreId: external_exports.string().uuid() }).parse(await options.readBody(req));
102528
102563
  check2(req, auth);
102529
102564
  if (!options.restored.restored || body.restoreId !== options.restored.id) throw failure3("This restore has not completed. Restart Atomic first.", 409);
102530
- json5(res, 200, { clientState: options.restored.clientState ?? {} });
102565
+ json5(res, 200, { clientState: options.restored.clientState ?? {}, keep: options.restored.keep ?? [] });
102531
102566
  return true;
102532
102567
  }
102533
102568
  if (method === "POST" && path2 === `${PREFIX}/export`) {
@@ -102673,14 +102708,15 @@ function createWorkspaceBackupRoutes(options) {
102673
102708
  return true;
102674
102709
  }
102675
102710
  if (method === "POST" && path2 === `${PREFIX}/restore`) {
102676
- const body = external_exports.object({ id: external_exports.string().uuid(), confirmation: external_exports.literal("REPLACE") }).parse(await options.readBody(req));
102711
+ const body = external_exports.object({ id: external_exports.string().uuid(), confirmation: external_exports.literal("REPLACE"), keep: external_exports.array(external_exports.enum(WORKSPACE_RESTORE_PARTS)).max(WORKSPACE_RESTORE_PARTS.length).optional() }).parse(await options.readBody(req));
102712
+ if (body.keep?.includes("settings") && !body.keep.includes("credentials")) throw failure3("Restore app settings with saved credentials, or keep both on this computer.", 400);
102677
102713
  get(body.id, auth, "staged");
102678
102714
  const result = await operate(() => options.exclusive(async () => {
102679
102715
  check2(req, auth);
102680
102716
  const secrets = stagedSecrets.get(body.id);
102681
102717
  const desktop2 = desktopWorkspaceSecrets();
102682
- if (secrets && desktop2) await desktop2.stage(body.id, secrets);
102683
- return commitPendingWorkspaceRestore(options.dataDir, body.id);
102718
+ if (secrets && desktop2 && !body.keep?.includes("credentials")) await desktop2.stage(body.id, secrets);
102719
+ return commitPendingWorkspaceRestore(options.dataDir, body.id, body.keep);
102684
102720
  }, true));
102685
102721
  artifacts.delete(body.id);
102686
102722
  stagedSecrets.delete(body.id);
@@ -103417,7 +103453,7 @@ import { isIP as isIP2 } from "node:net";
103417
103453
 
103418
103454
  // server/connected-assistants.ts
103419
103455
  import { createHash as createHash45, randomBytes as randomBytes10, randomUUID as randomUUID37, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
103420
- import { existsSync as existsSync63, mkdirSync as mkdirSync57, readdirSync as readdirSync25, readFileSync as readFileSync87, rmSync as rmSync19 } from "node:fs";
103456
+ import { existsSync as existsSync63, mkdirSync as mkdirSync57, readdirSync as readdirSync25, readFileSync as readFileSync88, rmSync as rmSync19 } from "node:fs";
103421
103457
  import { appendFile as appendFile5, mkdir as mkdir8 } from "node:fs/promises";
103422
103458
  import { dirname as dirname31, join as join112 } from "node:path";
103423
103459
  var ASSISTANT_TOKEN_PREFIX = "omb_asst_";
@@ -103442,7 +103478,7 @@ var ConnectedAssistants = class {
103442
103478
  this.now = options.now ?? Date.now;
103443
103479
  if (!existsSync63(this.file)) return;
103444
103480
  try {
103445
- const parsed = fileSchema3.safeParse(JSON.parse(readFileSync87(this.file, "utf8")));
103481
+ const parsed = fileSchema3.safeParse(JSON.parse(readFileSync88(this.file, "utf8")));
103446
103482
  if (parsed.success) this.assistants = parsed.data.assistants;
103447
103483
  } catch {
103448
103484
  }
@@ -103555,7 +103591,7 @@ function recentAssistantAudit(dataDir2, limit = 20, assistantId) {
103555
103591
  const files = readdirSync25(dir).filter((name2) => MONTH_FILE2.test(name2)).sort().slice(-2).reverse();
103556
103592
  const rows = [];
103557
103593
  for (const name2 of files) {
103558
- const lines = readFileSync87(join112(dir, name2), "utf8").split("\n").filter(Boolean).reverse();
103594
+ const lines = readFileSync88(join112(dir, name2), "utf8").split("\n").filter(Boolean).reverse();
103559
103595
  for (const line3 of lines) {
103560
103596
  try {
103561
103597
  const row = JSON.parse(line3);
@@ -104132,7 +104168,7 @@ function resolveRequestAuth(req, options) {
104132
104168
 
104133
104169
  // server/sessions.ts
104134
104170
  import { createHash as createHash46, randomBytes as randomBytes11, randomUUID as randomUUID38, timingSafeEqual as timingSafeEqual6 } from "node:crypto";
104135
- import { closeSync as closeSync18, existsSync as existsSync64, fsyncSync as fsyncSync5, mkdirSync as mkdirSync58, openSync as openSync18, readFileSync as readFileSync88, unlinkSync as unlinkSync15 } from "node:fs";
104171
+ import { closeSync as closeSync18, existsSync as existsSync64, fsyncSync as fsyncSync5, mkdirSync as mkdirSync58, openSync as openSync18, readFileSync as readFileSync89, unlinkSync as unlinkSync15 } from "node:fs";
104136
104172
  import { dirname as dirname32 } from "node:path";
104137
104173
  var SCOPES = ["admin", "client"];
104138
104174
  var PAIRING_CODE_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
@@ -104246,7 +104282,7 @@ var SessionRegistry = class {
104246
104282
  if (!existsSync64(this.options.file)) return;
104247
104283
  let raw;
104248
104284
  try {
104249
- raw = JSON.parse(readFileSync88(this.options.file, "utf8"));
104285
+ raw = JSON.parse(readFileSync89(this.options.file, "utf8"));
104250
104286
  } catch {
104251
104287
  return;
104252
104288
  }
@@ -104561,13 +104597,13 @@ var SessionRegistry = class {
104561
104597
  };
104562
104598
 
104563
104599
  // server/editor-connect.ts
104564
- import { copyFileSync as copyFileSync6, existsSync as existsSync66, mkdirSync as mkdirSync59, readFileSync as readFileSync90, statSync as statSync25 } from "node:fs";
104600
+ import { copyFileSync as copyFileSync6, existsSync as existsSync66, mkdirSync as mkdirSync59, readFileSync as readFileSync91, statSync as statSync25 } from "node:fs";
104565
104601
  import { homedir as homedir44 } from "node:os";
104566
104602
  import { dirname as dirname33, join as join114 } from "node:path";
104567
104603
 
104568
104604
  // server/claude-code-connect.ts
104569
104605
  import { execFile as execFile10 } from "node:child_process";
104570
- import { copyFileSync as copyFileSync5, existsSync as existsSync65, readFileSync as readFileSync89, statSync as statSync24 } from "node:fs";
104606
+ import { copyFileSync as copyFileSync5, existsSync as existsSync65, readFileSync as readFileSync90, statSync as statSync24 } from "node:fs";
104571
104607
  import { homedir as homedir43 } from "node:os";
104572
104608
  import { join as join113 } from "node:path";
104573
104609
  import { promisify as promisify6 } from "node:util";
@@ -104630,7 +104666,7 @@ async function unregisterFromClaudeCode(options = {}) {
104630
104666
  }
104631
104667
  function claudeCodeHasEntry(options = {}) {
104632
104668
  try {
104633
- const config2 = JSON.parse(readFileSync89(claudeCodeConfigPath(options.env, options.home), "utf8"));
104669
+ const config2 = JSON.parse(readFileSync90(claudeCodeConfigPath(options.env, options.home), "utf8"));
104634
104670
  return Boolean(config2?.mcpServers?.[CLAUDE_CODE_SERVER_NAME]);
104635
104671
  } catch {
104636
104672
  return false;
@@ -104640,7 +104676,7 @@ function editConfig(configPath, change) {
104640
104676
  let config2 = {};
104641
104677
  let mode = 384;
104642
104678
  if (existsSync65(configPath)) {
104643
- const raw = readFileSync89(configPath, "utf8");
104679
+ const raw = readFileSync90(configPath, "utf8");
104644
104680
  const parsed = raw.trim() ? JSON.parse(raw) : {};
104645
104681
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${configPath} is not a JSON object; add the entry with \`claude mcp add-json\` instead`);
104646
104682
  config2 = parsed;
@@ -104682,7 +104718,7 @@ function editorEntry(format, entry) {
104682
104718
  var serversKey = (format) => format === "vscode" ? "servers" : format === "opencode" ? "mcp" : "mcpServers";
104683
104719
  function readConfig(path2) {
104684
104720
  if (!existsSync66(path2)) return {};
104685
- const raw = readFileSync90(path2, "utf8");
104721
+ const raw = readFileSync91(path2, "utf8");
104686
104722
  const parsed = raw.trim() ? JSON.parse(raw) : {};
104687
104723
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${path2} is not a JSON object`);
104688
104724
  return parsed;
@@ -104723,7 +104759,7 @@ function editorHasEntry(target) {
104723
104759
  }
104724
104760
 
104725
104761
  // server/thread-starters.ts
104726
- import { readFileSync as readFileSync91 } from "node:fs";
104762
+ import { readFileSync as readFileSync92 } from "node:fs";
104727
104763
  var KEY = /^p_[\w-]{22}$/;
104728
104764
  var THREAD = /^[\w-]{1,128}$/;
104729
104765
  var MAX_ENTRIES3 = 5e4;
@@ -104734,7 +104770,7 @@ var ThreadStarters = class {
104734
104770
  this.file = file2;
104735
104771
  let raw;
104736
104772
  try {
104737
- raw = JSON.parse(readFileSync91(file2, "utf8"));
104773
+ raw = JSON.parse(readFileSync92(file2, "utf8"));
104738
104774
  } catch {
104739
104775
  return;
104740
104776
  }
@@ -104760,7 +104796,7 @@ var ThreadStarters = class {
104760
104796
  };
104761
104797
 
104762
104798
  // server/admin-activity.ts
104763
- import { readdirSync as readdirSync26, readFileSync as readFileSync92 } from "node:fs";
104799
+ import { readdirSync as readdirSync26, readFileSync as readFileSync93 } from "node:fs";
104764
104800
  import { appendFile as appendFile6, mkdir as mkdir9 } from "node:fs/promises";
104765
104801
  import { basename as basename18, join as join115 } from "node:path";
104766
104802
  var ADMIN_ACTIVITY_CATEGORIES = ["config", "people", "session", "webhook", "mcp", "engine", "bot", "budget", "visibility"];
@@ -104980,7 +105016,7 @@ var isRow2 = (value) => isPlainObject2(value) && typeof value.at === "string" &&
104980
105016
  function readRows2(path2) {
104981
105017
  let text18;
104982
105018
  try {
104983
- text18 = readFileSync92(path2, "utf8");
105019
+ text18 = readFileSync93(path2, "utf8");
104984
105020
  } catch {
104985
105021
  return [];
104986
105022
  }
@@ -105092,7 +105128,7 @@ function activityCsv(entries2) {
105092
105128
  }
105093
105129
 
105094
105130
  // server/brand.ts
105095
- import { existsSync as existsSync67, readFileSync as readFileSync93 } from "node:fs";
105131
+ import { existsSync as existsSync67, readFileSync as readFileSync94 } from "node:fs";
105096
105132
  import { join as join116 } from "node:path";
105097
105133
  var HEX_COLOUR = /^#[0-9a-fA-F]{6}$/;
105098
105134
  var MAX_LOGO_CHARS = 3e5;
@@ -105141,7 +105177,7 @@ function loadBrand(options = {}) {
105141
105177
  if (!existsSync67(file2)) return fallback();
105142
105178
  let raw;
105143
105179
  try {
105144
- raw = JSON.parse(readFileSync93(file2, "utf8"));
105180
+ raw = JSON.parse(readFileSync94(file2, "utf8"));
105145
105181
  } catch (error51) {
105146
105182
  return fallback(`${file2} is not valid JSON (${error51 instanceof Error ? error51.message : String(error51)}); using the default brand`);
105147
105183
  }
@@ -107664,7 +107700,7 @@ var PhoneSecretBridge = class {
107664
107700
 
107665
107701
  // server/bot-work-modes.ts
107666
107702
  import { randomUUID as randomUUID39 } from "node:crypto";
107667
- import { existsSync as existsSync68, readFileSync as readFileSync94 } from "node:fs";
107703
+ import { existsSync as existsSync68, readFileSync as readFileSync95 } from "node:fs";
107668
107704
  var WORK_MODES = ["plan", "ask", "edits", "full"];
107669
107705
  var valid2 = (value) => WORK_MODES.includes(value);
107670
107706
  var BotWorkModes = class {
@@ -107676,7 +107712,7 @@ var BotWorkModes = class {
107676
107712
  this.file = file2;
107677
107713
  if (!existsSync68(file2)) return;
107678
107714
  try {
107679
- const data = JSON.parse(readFileSync94(file2, "utf8"));
107715
+ const data = JSON.parse(readFileSync95(file2, "utf8"));
107680
107716
  if (Array.isArray(data.allowed)) this.allowed = ["ask", ...data.allowed.filter((mode) => valid2(mode) && mode !== "ask")];
107681
107717
  for (const [id, entry] of Object.entries(data.selections ?? {})) {
107682
107718
  const item = entry;
@@ -111473,7 +111509,7 @@ function mergeHistoryEnvVars(result, history) {
111473
111509
  }
111474
111510
 
111475
111511
  // server/model-levels/overrides.ts
111476
- import { existsSync as existsSync71, mkdirSync as mkdirSync60, readFileSync as readFileSync95 } from "node:fs";
111512
+ import { existsSync as existsSync71, mkdirSync as mkdirSync60, readFileSync as readFileSync96 } from "node:fs";
111477
111513
  import { dirname as dirname36 } from "node:path";
111478
111514
  var OVERRIDES_FILE = "model-levels-overrides.json";
111479
111515
  var LEGACY_CAPABILITY_ORDER = ["*", "agent", "coding", "writing", "search", "tools"];
@@ -111530,7 +111566,7 @@ function parseOverrides(raw) {
111530
111566
  function readOverrides(path2) {
111531
111567
  if (!existsSync71(path2)) return parseOverrides(void 0);
111532
111568
  try {
111533
- return parseOverrides(JSON.parse(readFileSync95(path2, "utf8")));
111569
+ return parseOverrides(JSON.parse(readFileSync96(path2, "utf8")));
111534
111570
  } catch (error51) {
111535
111571
  return { overrides: { aliases: {}, classes: {} }, problems: [`${path2}: ${error51 instanceof Error ? error51.message : String(error51)}`] };
111536
111572
  }
@@ -113143,7 +113179,7 @@ import { createServer as createServer3 } from "node:http";
113143
113179
 
113144
113180
  // server/oauth-account-vault.ts
113145
113181
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes12, randomUUID as randomUUID43 } from "node:crypto";
113146
- import { mkdirSync as mkdirSync63, readFileSync as readFileSync96 } from "node:fs";
113182
+ import { mkdirSync as mkdirSync63, readFileSync as readFileSync97 } from "node:fs";
113147
113183
  import { join as join125 } from "node:path";
113148
113184
  var MAX_OAUTH_ACCOUNTS = 40;
113149
113185
  var OAUTH_ACCOUNTS_ENV = "OMB_OAUTH_ACCOUNTS";
@@ -113245,7 +113281,7 @@ var FileAccountVault = class {
113245
113281
  key() {
113246
113282
  const file2 = join125(this.directory, "key");
113247
113283
  try {
113248
- const existing = readFileSync96(file2, "utf8").trim();
113284
+ const existing = readFileSync97(file2, "utf8").trim();
113249
113285
  if (/^[0-9a-f]{64}$/u.test(existing)) return Buffer.from(existing, "hex");
113250
113286
  } catch {
113251
113287
  }
@@ -113258,7 +113294,7 @@ var FileAccountVault = class {
113258
113294
  load() {
113259
113295
  let raw;
113260
113296
  try {
113261
- raw = readFileSync96(join125(this.directory, "accounts.enc"), "utf8");
113297
+ raw = readFileSync97(join125(this.directory, "accounts.enc"), "utf8");
113262
113298
  } catch {
113263
113299
  return {};
113264
113300
  }
@@ -113976,7 +114012,7 @@ import { timingSafeEqual as timingSafeEqual8 } from "node:crypto";
113976
114012
 
113977
114013
  // server/vault/store.ts
113978
114014
  import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes14, randomUUID as randomUUID45 } from "node:crypto";
113979
- import { lstatSync as lstatSync15, mkdirSync as mkdirSync64, readFileSync as readFileSync97, rmdirSync } from "node:fs";
114015
+ import { lstatSync as lstatSync15, mkdirSync as mkdirSync64, readFileSync as readFileSync98, rmdirSync } from "node:fs";
113980
114016
  import { join as join126 } from "node:path";
113981
114017
 
113982
114018
  // shared/vault.ts
@@ -114092,7 +114128,7 @@ var VaultStore = class {
114092
114128
  throw error51;
114093
114129
  }
114094
114130
  if (!stat8.isFile() || stat8.isSymbolicLink() || stat8.size > MAX_BYTES2) throw new Error();
114095
- const envelope = envelopeSchema.parse(JSON.parse(readFileSync97(this.#file, "utf8")));
114131
+ const envelope = envelopeSchema.parse(JSON.parse(readFileSync98(this.#file, "utf8")));
114096
114132
  const decipher = createDecipheriv3("aes-256-gcm", this.#key, Buffer.from(envelope.iv, "hex"));
114097
114133
  decipher.setAAD(AAD);
114098
114134
  decipher.setAuthTag(Buffer.from(envelope.tag, "hex"));
@@ -116181,7 +116217,7 @@ function localTag(model2) {
116181
116217
  }
116182
116218
 
116183
116219
  // server/model-levels/artificial-analysis.ts
116184
- import { existsSync as existsSync75, readFileSync as readFileSync98 } from "node:fs";
116220
+ import { existsSync as existsSync75, readFileSync as readFileSync99 } from "node:fs";
116185
116221
  import { homedir as homedir50 } from "node:os";
116186
116222
  import { join as join128 } from "node:path";
116187
116223
  var AA_MODELS_URL = "https://artificialanalysis.ai/api/v2/data/llms/models";
@@ -116193,7 +116229,7 @@ function artificialAnalysisKey(env = process.env, envFile = join128(homedir50(),
116193
116229
  let text18;
116194
116230
  try {
116195
116231
  if (!existsSync75(envFile)) return void 0;
116196
- text18 = readFileSync98(envFile, "utf8");
116232
+ text18 = readFileSync99(envFile, "utf8");
116197
116233
  } catch {
116198
116234
  return void 0;
116199
116235
  }
@@ -117523,7 +117559,7 @@ var BASELINE = {
117523
117559
  };
117524
117560
 
117525
117561
  // server/model-levels/cache.ts
117526
- import { existsSync as existsSync76, mkdirSync as mkdirSync65, readFileSync as readFileSync99 } from "node:fs";
117562
+ import { existsSync as existsSync76, mkdirSync as mkdirSync65, readFileSync as readFileSync100 } from "node:fs";
117527
117563
  import { dirname as dirname37 } from "node:path";
117528
117564
  var CACHE_FILE = "model-levels.json";
117529
117565
  var AA_CACHE_FILE = "model-classes-aa.json";
@@ -117552,7 +117588,7 @@ function validSnapshots(value, knownSources) {
117552
117588
  function readCache2(path2, knownSources) {
117553
117589
  if (!existsSync76(path2)) return [];
117554
117590
  try {
117555
- const parsed = JSON.parse(readFileSync99(path2, "utf8"));
117591
+ const parsed = JSON.parse(readFileSync100(path2, "utf8"));
117556
117592
  if (parsed.version !== VERSION && parsed.version !== 1) return [];
117557
117593
  return validSnapshots(parsed.snapshots, knownSources);
117558
117594
  } catch {
@@ -117576,7 +117612,7 @@ function validAaRow(row) {
117576
117612
  function readAaCache(path2) {
117577
117613
  if (!existsSync76(path2)) return null;
117578
117614
  try {
117579
- const parsed = JSON.parse(readFileSync99(path2, "utf8"));
117615
+ const parsed = JSON.parse(readFileSync100(path2, "utf8"));
117580
117616
  if (parsed.version !== AA_VERSION || typeof parsed.snapshot?.fetchedAt !== "string" || !Array.isArray(parsed.snapshot.rows)) return null;
117581
117617
  const rows = parsed.snapshot.rows.filter(validAaRow);
117582
117618
  return rows.length ? { fetchedAt: parsed.snapshot.fetchedAt, rows } : null;
@@ -117591,7 +117627,7 @@ function writeAaCache(path2, snapshot2, now) {
117591
117627
  }
117592
117628
 
117593
117629
  // server/model-levels/chibitek-rankings.ts
117594
- import { existsSync as existsSync77, mkdirSync as mkdirSync66, readFileSync as readFileSync100 } from "node:fs";
117630
+ import { existsSync as existsSync77, mkdirSync as mkdirSync66, readFileSync as readFileSync101 } from "node:fs";
117595
117631
  import { dirname as dirname38 } from "node:path";
117596
117632
  var CHIBITEK_RANKINGS_CACHE = "model-rankings-chibitek.json";
117597
117633
  var CACHE_VERSION = 1;
@@ -117629,7 +117665,7 @@ function parseRankings(raw, catalog2, fetchedAt) {
117629
117665
  function readRankingsCache(path2, catalog2) {
117630
117666
  if (!existsSync77(path2)) return null;
117631
117667
  try {
117632
- const parsed = JSON.parse(readFileSync100(path2, "utf8"));
117668
+ const parsed = JSON.parse(readFileSync101(path2, "utf8"));
117633
117669
  if (parsed.version !== CACHE_VERSION || typeof parsed.fetchedAt !== "string") return null;
117634
117670
  return parseRankings(parsed.document, catalog2, parsed.fetchedAt)?.rankings ?? null;
117635
117671
  } catch {
@@ -118837,7 +118873,7 @@ function isChange(value) {
118837
118873
  }
118838
118874
 
118839
118875
  // server/primary-bot.ts
118840
- import { existsSync as existsSync78, mkdirSync as mkdirSync67, readFileSync as readFileSync101 } from "node:fs";
118876
+ import { existsSync as existsSync78, mkdirSync as mkdirSync67, readFileSync as readFileSync102 } from "node:fs";
118841
118877
  import { dirname as dirname39, join as join130 } from "node:path";
118842
118878
  var PRIMARY_BOT_FILE = "primary-bot.json";
118843
118879
  var PRIMARY_BOT_THREAD_TITLE = "Primary Bot sweeps";
@@ -119212,7 +119248,7 @@ var PrimaryBotStore = class {
119212
119248
  const empty = () => ({ version: 1, settings: normalizeSettings(void 0), history: [], attempted: {}, checkedIn: {}, threadAttempts: {}, failures: [] });
119213
119249
  if (!existsSync78(this.path)) return empty();
119214
119250
  try {
119215
- const raw = JSON.parse(readFileSync101(this.path, "utf8"));
119251
+ const raw = JSON.parse(readFileSync102(this.path, "utf8"));
119216
119252
  const file2 = empty();
119217
119253
  file2.settings = normalizeSettings(raw.settings);
119218
119254
  file2.history = (Array.isArray(raw.history) ? raw.history : []).filter((record12) => record12 && typeof record12.id === "string" && finite4(record12.at)).slice(0, HISTORY_LIMIT2);
@@ -119484,7 +119520,7 @@ function moveIntoChibi(botId, deps) {
119484
119520
  }
119485
119521
 
119486
119522
  // server/engine-rest.ts
119487
- import { existsSync as existsSync79, mkdirSync as mkdirSync68, readFileSync as readFileSync102 } from "node:fs";
119523
+ import { existsSync as existsSync79, mkdirSync as mkdirSync68, readFileSync as readFileSync103 } from "node:fs";
119488
119524
  import { dirname as dirname40, join as join131 } from "node:path";
119489
119525
  var ENGINE_REST_FILE = "engine-rest.json";
119490
119526
  var MINUTE_MS2 = 6e4;
@@ -119729,7 +119765,7 @@ var EngineRestStore = class {
119729
119765
  load() {
119730
119766
  if (!existsSync79(this.path)) return;
119731
119767
  try {
119732
- const raw = JSON.parse(readFileSync102(this.path, "utf8"));
119768
+ const raw = JSON.parse(readFileSync103(this.path, "utf8"));
119733
119769
  for (const entry of Array.isArray(raw.entries) ? raw.entries : []) {
119734
119770
  if (!validEntry(entry)) continue;
119735
119771
  this.entries.set(keyOf(entry.instanceId, entry.account, entry.scope), entry);
@@ -119769,7 +119805,7 @@ function validRecord(value) {
119769
119805
  }
119770
119806
 
119771
119807
  // server/pay-per-use.ts
119772
- import { existsSync as existsSync80, mkdirSync as mkdirSync69, readFileSync as readFileSync103 } from "node:fs";
119808
+ import { existsSync as existsSync80, mkdirSync as mkdirSync69, readFileSync as readFileSync104 } from "node:fs";
119773
119809
  import { dirname as dirname41, join as join132 } from "node:path";
119774
119810
  var PAY_PER_USE_FILE = "pay-per-use.json";
119775
119811
  var PERSONAL_PAY_PER_USE_FILE = "pay-per-use-personal.json";
@@ -119900,7 +119936,7 @@ var PayPerUseEpisodes = class {
119900
119936
  load() {
119901
119937
  if (!existsSync80(this.path)) return;
119902
119938
  try {
119903
- const raw = JSON.parse(readFileSync103(this.path, "utf8"));
119939
+ const raw = JSON.parse(readFileSync104(this.path, "utf8"));
119904
119940
  this.episodes = (Array.isArray(raw.episodes) ? raw.episodes : []).filter(validEpisode).slice(0, HISTORY_LIMIT4);
119905
119941
  } catch (error51) {
119906
119942
  console.error(`pay-per-use: ignoring unreadable ${this.path}: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -120912,7 +120948,7 @@ function createTeamRoomsRoutes(deps) {
120912
120948
 
120913
120949
  // server/team-rooms/host.ts
120914
120950
  import { randomUUID as randomUUID47 } from "node:crypto";
120915
- import { existsSync as existsSync82, mkdirSync as mkdirSync71, readFileSync as readFileSync105, writeFileSync as writeFileSync36 } from "node:fs";
120951
+ import { existsSync as existsSync82, mkdirSync as mkdirSync71, readFileSync as readFileSync106, writeFileSync as writeFileSync36 } from "node:fs";
120916
120952
  import { join as join134 } from "node:path";
120917
120953
 
120918
120954
  // server/stiki-session.ts
@@ -120944,7 +120980,7 @@ function onStikiSessionChange(listener) {
120944
120980
 
120945
120981
  // server/team-rooms/service.ts
120946
120982
  import { randomUUID as randomUUID46 } from "node:crypto";
120947
- import { existsSync as existsSync81, mkdirSync as mkdirSync70, readdirSync as readdirSync27, readFileSync as readFileSync104, rmSync as rmSync23, writeFileSync as writeFileSync35 } from "node:fs";
120983
+ import { existsSync as existsSync81, mkdirSync as mkdirSync70, readdirSync as readdirSync27, readFileSync as readFileSync105, rmSync as rmSync23, writeFileSync as writeFileSync35 } from "node:fs";
120948
120984
  import { join as join133 } from "node:path";
120949
120985
 
120950
120986
  // server/team-rooms/realtime.ts
@@ -121784,7 +121820,7 @@ var TeamRoomsService = class {
121784
121820
  try {
121785
121821
  for (const name2 of readdirSync27(dir)) {
121786
121822
  if (!name2.endsWith(".json")) continue;
121787
- const raw = JSON.parse(readFileSync104(join133(dir, name2), "utf8"));
121823
+ const raw = JSON.parse(readFileSync105(join133(dir, name2), "utf8"));
121788
121824
  if (raw?.room?.id && !this.rooms.has(raw.room.id)) this.rooms.set(raw.room.id, { ...raw, turns: /* @__PURE__ */ new Map(), approvals: /* @__PURE__ */ new Map() });
121789
121825
  }
121790
121826
  } catch {
@@ -121948,7 +121984,7 @@ var TeamRoomsHost = class {
121948
121984
  }
121949
121985
  readThreads() {
121950
121986
  try {
121951
- return JSON.parse(readFileSync105(join134(this.deps.dataDir, "team-rooms", "threads.json"), "utf8"));
121987
+ return JSON.parse(readFileSync106(join134(this.deps.dataDir, "team-rooms", "threads.json"), "utf8"));
121952
121988
  } catch {
121953
121989
  return {};
121954
121990
  }
@@ -121974,7 +122010,7 @@ function loadInstallId(dataDir2) {
121974
122010
  const dir = join134(dataDir2, "team-rooms");
121975
122011
  const file2 = join134(dir, "install-id");
121976
122012
  if (existsSync82(file2)) {
121977
- const id2 = readFileSync105(file2, "utf8").trim();
122013
+ const id2 = readFileSync106(file2, "utf8").trim();
121978
122014
  if (/^[\w.:-]{8,200}$/.test(id2)) return id2;
121979
122015
  }
121980
122016
  mkdirSync71(dir, { recursive: true, mode: 448 });
@@ -122880,7 +122916,7 @@ async function runAnswerCheck(input, deps) {
122880
122916
  }
122881
122917
 
122882
122918
  // server/jev/key.ts
122883
- import { existsSync as existsSync83, readFileSync as readFileSync106 } from "node:fs";
122919
+ import { existsSync as existsSync83, readFileSync as readFileSync107 } from "node:fs";
122884
122920
  import { homedir as homedir51 } from "node:os";
122885
122921
  import { join as join135 } from "node:path";
122886
122922
  var TYPESAFE_KEY_VARIABLE = "TYPESAFE_API_KEY";
@@ -122894,7 +122930,7 @@ function readEnvKey(name2, env = process.env, envFile = defaultEnvFile()) {
122894
122930
  let text18;
122895
122931
  try {
122896
122932
  if (!existsSync83(envFile)) return void 0;
122897
- text18 = readFileSync106(envFile, "utf8");
122933
+ text18 = readFileSync107(envFile, "utf8");
122898
122934
  } catch {
122899
122935
  return void 0;
122900
122936
  }
@@ -136517,13 +136553,13 @@ function serveStatic(res, path2) {
136517
136553
  const safe3 = path2 === "/" ? "/index.html" : path2.replace(/\.\./g, "");
136518
136554
  const file2 = join136(STATIC_DIR, safe3);
136519
136555
  try {
136520
- const data = readFileSync107(file2);
136556
+ const data = readFileSync108(file2);
136521
136557
  res.writeHead(200, { "content-type": MIME3[extname7(file2)] ?? "application/octet-stream" });
136522
136558
  res.end(data);
136523
136559
  return true;
136524
136560
  } catch {
136525
136561
  try {
136526
- const data = readFileSync107(join136(STATIC_DIR, "index.html"));
136562
+ const data = readFileSync108(join136(STATIC_DIR, "index.html"));
136527
136563
  res.writeHead(200, { "content-type": "text/html" });
136528
136564
  res.end(data);
136529
136565
  return true;