@chibitek/chibi 0.1.180 → 0.1.182

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 (67) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-C91sfqR5.js → abnfDiagram-O67JEVCF-B8rB4VYk.js} +1 -1
  2. package/dist/assets/{arc-ywHVvcgD.js → arc-COTt5eKp.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-BgUERWVi.js → architectureDiagram-NJMV4G6O-CPejbWZ8.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-CpeTJJap.js → blockDiagram-BEXU5L5S-DoioDp90.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-BgdM3M47.js → c4Diagram-YGBWAQC7-8PWWVdYW.js} +1 -1
  6. package/dist/assets/channel-CDw9Li4I.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-BcMR6SsJ.js → chunk-2Q5K7J3B-DxtJtts-.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-DNzXM7Mm.js → chunk-3FUC2YCW-D3YkXW5d.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-kVNi7GcP.js → chunk-5VM5RSS4-CsKzmOcP.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-B5bYzLKn.js → chunk-GTNCS2PH-gZEIPwuj.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-DiMuTVC6.js → chunk-GWA4HPMP-Bjt2-00s.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-Bl2yeh-K.js → chunk-JWPE2WC7-BvUQuiRB.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-Klel5WGa.js → chunk-NETBCI7D-Dq0TzVqk.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-CPIykbsI.js → chunk-WEXAMYUT-DYCSZnMz.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-8cVOBFNO.js → chunk-XXDRQBXY-B_OfX3TH.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-DxDpAPju.js → classDiagram-v2-NBCMYWYE-CyGFfePO.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-Bb935SMz.js → cose-bilkent-JH36ORCC-v7FbM5j-.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-CxYWe3QR.js → cynefin-OW5HDTMX-CqvJgX3t.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-CYhyAhYv.js → cynefinDiagram-VND7K2PF-CA2yN6Xd.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-Bb41Vmni.js → dagre-6A5THRUB-Zr9etAoq.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-BNvUBpgi.js → diagram-22UHCM2B-DtUG2c4U.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-D9x2CdxS.js → diagram-3UASUU5V-D9Y-Wrhr.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-BXIrC_GF.js → diagram-ATOU4E4O-DkeBHA-m.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-OI4ao0qQ.js → diagram-CDSNMT55-CdGlcHWC.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-_zZZdxaC.js → diagram-MLGK6HIB-BeHhIQjn.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-9k65oUfK.js → diagram-MPIPVDR6-AgCxokZc.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-Chvztd4J.js → ebnfDiagram-ZINNZB2B-CqYoX9yZ.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-CMWtKZmi.js → elk-276RUBZZ-Br_wamlb.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-2vqBM9HW.js → erDiagram-OPXOYQCR-YuGMoUl0.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-C6y9L478.js → flowDiagram-KWPJA3E3-VflMWlTN.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-uWHpQwJY.js → ganttDiagram-FUAMR5RP-q1LvQaev.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-BLM0_X6z.js → gitGraphDiagram-X574FWY7-CHRdJIvn.js} +1 -1
  33. package/dist/assets/{index-CPnrJ6T1.js → index-B_gcNCKf.js} +3 -3
  34. package/dist/assets/{index-YJUVFbCT.js → index-C2q5K4Lk.js} +1 -1
  35. package/dist/assets/{infoDiagram-VRGFBTTK-DWeJ1wdL.js → infoDiagram-VRGFBTTK-DRwVvitP.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-OU5B5YK6-R28kPwvB.js → ishikawaDiagram-OU5B5YK6-BXZw4L0c.js} +1 -1
  37. package/dist/assets/{journeyDiagram-ZHPQQLJL-BHWE5-BX.js → journeyDiagram-ZHPQQLJL-B7AeEVRV.js} +1 -1
  38. package/dist/assets/{kanban-definition-PNTS6WVX-M-Er9io8.js → kanban-definition-PNTS6WVX-CQLN4aVl.js} +1 -1
  39. package/dist/assets/{linear-UI6pE8Wd.js → linear-CbYhE1pa.js} +1 -1
  40. package/dist/assets/{mermaid.core-B_hsjjFv.js → mermaid.core-D1syQdvp.js} +5 -5
  41. package/dist/assets/{mindmap-definition-NLK3R4M7-C6u7tH0B.js → mindmap-definition-NLK3R4M7-B2IFEIiB.js} +1 -1
  42. package/dist/assets/{pegDiagram-GJSIUBJH-HdJHW3kd.js → pegDiagram-GJSIUBJH-DHZYilhs.js} +1 -1
  43. package/dist/assets/{pieDiagram-5QR66LMP-DYm0T2vD.js → pieDiagram-5QR66LMP-DO_aJLMk.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-O4NWA36T-CEqOPSKh.js → quadrantDiagram-O4NWA36T-gUPrtKHH.js} +1 -1
  45. package/dist/assets/{railroadDiagram-XR7U4H2S-I8gLnKDm.js → railroadDiagram-XR7U4H2S-BBF0wp-6.js} +1 -1
  46. package/dist/assets/{requirementDiagram-PLB6GJNP-0AbgBQwX.js → requirementDiagram-PLB6GJNP-xcAp1hln.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-IPEJSGJF-CELks0t3.js → sankeyDiagram-IPEJSGJF-Dm5c9FwQ.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-PO4LG4MO-Lv5pg-Nj.js → sequenceDiagram-PO4LG4MO-vRzb3zIA.js} +1 -1
  49. package/dist/assets/{sizeCapture-INFHLROL-D13uYR-m.js → sizeCapture-INFHLROL-Czu8kIt2.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-GCMORJYK-C6ntlRJp.js → stateDiagram-v2-GCMORJYK-BOfJjcD1.js} +1 -1
  51. package/dist/assets/{swimlanes-2SLR337P-BBMTJMbP.js → swimlanes-2SLR337P-D0ipJonR.js} +1 -1
  52. package/dist/assets/swimlanesDiagram-TC7HE7FX-BJpOJd6C.js +8 -0
  53. package/dist/assets/{timeline-definition-EJHVYXUP-CQqiq_9n.js → timeline-definition-EJHVYXUP-TpaYbjnd.js} +1 -1
  54. package/dist/assets/{usecaseDiagram-POWQR4AR-CMdMUvua.js → usecaseDiagram-POWQR4AR-B-jKTFl6.js} +1 -1
  55. package/dist/assets/{vennDiagram-UO4OBE2U-DwNRIC20.js → vennDiagram-UO4OBE2U-Dy6k1yAu.js} +1 -1
  56. package/dist/assets/{wardleyDiagram-VNRHLVJA-BDP4uswI.js → wardleyDiagram-VNRHLVJA-DYRJUBY6.js} +1 -1
  57. package/dist/assets/{xychartDiagram-PMCCYNJV-B9qFFRsi.js → xychartDiagram-PMCCYNJV-CETDzaRA.js} +1 -1
  58. package/dist/index.html +1 -1
  59. package/dist-server/index.js +297 -229
  60. package/dist-server/server/index.js +4 -3
  61. package/dist-server/server/workspace-backup-copy.js +67 -0
  62. package/dist-server/server/workspace-backup-http.js +1 -0
  63. package/dist-server/server/workspace-backup-maintenance.js +12 -2
  64. package/dist-server/server/workspace-backup.js +32 -50
  65. package/package.json +1 -1
  66. package/dist/assets/channel-Ck_atLKb.js +0 -1
  67. package/dist/assets/swimlanesDiagram-TC7HE7FX-CN2rFhol.js +0 -8
@@ -409,11 +409,11 @@ var require_codegen = __commonJS({
409
409
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
410
410
  return `${varKind} ${this.name}${rhs};` + _n2;
411
411
  }
412
- optimizeNames(names3, constants12) {
412
+ optimizeNames(names3, constants13) {
413
413
  if (!names3[this.name.str])
414
414
  return;
415
415
  if (this.rhs)
416
- this.rhs = optimizeExpr(this.rhs, names3, constants12);
416
+ this.rhs = optimizeExpr(this.rhs, names3, constants13);
417
417
  return this;
418
418
  }
419
419
  get names() {
@@ -430,10 +430,10 @@ var require_codegen = __commonJS({
430
430
  render({ _n: _n2 }) {
431
431
  return `${this.lhs} = ${this.rhs};` + _n2;
432
432
  }
433
- optimizeNames(names3, constants12) {
433
+ optimizeNames(names3, constants13) {
434
434
  if (this.lhs instanceof code_1.Name && !names3[this.lhs.str] && !this.sideEffects)
435
435
  return;
436
- this.rhs = optimizeExpr(this.rhs, names3, constants12);
436
+ this.rhs = optimizeExpr(this.rhs, names3, constants13);
437
437
  return this;
438
438
  }
439
439
  get names() {
@@ -494,8 +494,8 @@ var require_codegen = __commonJS({
494
494
  optimizeNodes() {
495
495
  return `${this.code}` ? this : void 0;
496
496
  }
497
- optimizeNames(names3, constants12) {
498
- this.code = optimizeExpr(this.code, names3, constants12);
497
+ optimizeNames(names3, constants13) {
498
+ this.code = optimizeExpr(this.code, names3, constants13);
499
499
  return this;
500
500
  }
501
501
  get names() {
@@ -524,12 +524,12 @@ var require_codegen = __commonJS({
524
524
  }
525
525
  return nodes.length > 0 ? this : void 0;
526
526
  }
527
- optimizeNames(names3, constants12) {
527
+ optimizeNames(names3, constants13) {
528
528
  const { nodes } = this;
529
529
  let i = nodes.length;
530
530
  while (i--) {
531
531
  const n = nodes[i];
532
- if (n.optimizeNames(names3, constants12))
532
+ if (n.optimizeNames(names3, constants13))
533
533
  continue;
534
534
  subtractNames(names3, n.names);
535
535
  nodes.splice(i, 1);
@@ -582,12 +582,12 @@ var require_codegen = __commonJS({
582
582
  return void 0;
583
583
  return this;
584
584
  }
585
- optimizeNames(names3, constants12) {
585
+ optimizeNames(names3, constants13) {
586
586
  var _a4;
587
- this.else = (_a4 = this.else) === null || _a4 === void 0 ? void 0 : _a4.optimizeNames(names3, constants12);
588
- if (!(super.optimizeNames(names3, constants12) || this.else))
587
+ this.else = (_a4 = this.else) === null || _a4 === void 0 ? void 0 : _a4.optimizeNames(names3, constants13);
588
+ if (!(super.optimizeNames(names3, constants13) || this.else))
589
589
  return;
590
- this.condition = optimizeExpr(this.condition, names3, constants12);
590
+ this.condition = optimizeExpr(this.condition, names3, constants13);
591
591
  return this;
592
592
  }
593
593
  get names() {
@@ -610,10 +610,10 @@ var require_codegen = __commonJS({
610
610
  render(opts) {
611
611
  return `for(${this.iteration})` + super.render(opts);
612
612
  }
613
- optimizeNames(names3, constants12) {
614
- if (!super.optimizeNames(names3, constants12))
613
+ optimizeNames(names3, constants13) {
614
+ if (!super.optimizeNames(names3, constants13))
615
615
  return;
616
- this.iteration = optimizeExpr(this.iteration, names3, constants12);
616
+ this.iteration = optimizeExpr(this.iteration, names3, constants13);
617
617
  return this;
618
618
  }
619
619
  get names() {
@@ -649,10 +649,10 @@ var require_codegen = __commonJS({
649
649
  render(opts) {
650
650
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
651
651
  }
652
- optimizeNames(names3, constants12) {
653
- if (!super.optimizeNames(names3, constants12))
652
+ optimizeNames(names3, constants13) {
653
+ if (!super.optimizeNames(names3, constants13))
654
654
  return;
655
- this.iterable = optimizeExpr(this.iterable, names3, constants12);
655
+ this.iterable = optimizeExpr(this.iterable, names3, constants13);
656
656
  return this;
657
657
  }
658
658
  get names() {
@@ -694,11 +694,11 @@ var require_codegen = __commonJS({
694
694
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
695
695
  return this;
696
696
  }
697
- optimizeNames(names3, constants12) {
697
+ optimizeNames(names3, constants13) {
698
698
  var _a4, _b;
699
- super.optimizeNames(names3, constants12);
700
- (_a4 = this.catch) === null || _a4 === void 0 ? void 0 : _a4.optimizeNames(names3, constants12);
701
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names3, constants12);
699
+ super.optimizeNames(names3, constants13);
700
+ (_a4 = this.catch) === null || _a4 === void 0 ? void 0 : _a4.optimizeNames(names3, constants13);
701
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names3, constants13);
702
702
  return this;
703
703
  }
704
704
  get names() {
@@ -999,7 +999,7 @@ var require_codegen = __commonJS({
999
999
  function addExprNames(names3, from) {
1000
1000
  return from instanceof code_1._CodeOrName ? addNames(names3, from.names) : names3;
1001
1001
  }
1002
- function optimizeExpr(expr, names3, constants12) {
1002
+ function optimizeExpr(expr, names3, constants13) {
1003
1003
  if (expr instanceof code_1.Name)
1004
1004
  return replaceName(expr);
1005
1005
  if (!canOptimize(expr))
@@ -1014,14 +1014,14 @@ var require_codegen = __commonJS({
1014
1014
  return items;
1015
1015
  }, []));
1016
1016
  function replaceName(n) {
1017
- const c = constants12[n.str];
1017
+ const c = constants13[n.str];
1018
1018
  if (c === void 0 || names3[n.str] !== 1)
1019
1019
  return n;
1020
1020
  delete names3[n.str];
1021
1021
  return c;
1022
1022
  }
1023
1023
  function canOptimize(e) {
1024
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names3[c.str] === 1 && constants12[c.str] !== void 0);
1024
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names3[c.str] === 1 && constants13[c.str] !== void 0);
1025
1025
  }
1026
1026
  }
1027
1027
  function subtractNames(names3, from) {
@@ -8022,6 +8022,22 @@ var require_dist = __commonJS({
8022
8022
  }
8023
8023
  });
8024
8024
 
8025
+ // electron/socket-qos.mjs
8026
+ import { Socket } from "node:net";
8027
+ function installSocketQosCompatibility(prototype = Socket.prototype) {
8028
+ const original = prototype.setTypeOfService;
8029
+ if (typeof original !== "function") return;
8030
+ prototype.setTypeOfService = function(...args) {
8031
+ try {
8032
+ return original.apply(this, args);
8033
+ } catch (error51) {
8034
+ if (error51?.code !== "EINVAL" || error51?.syscall !== "setTypeOfService") throw error51;
8035
+ return this;
8036
+ }
8037
+ };
8038
+ }
8039
+ if (process.platform === "darwin") installSocketQosCompatibility();
8040
+
8025
8041
  // server/message-file.ts
8026
8042
  import { constants } from "node:fs";
8027
8043
  import { open, realpath, stat } from "node:fs/promises";
@@ -32187,7 +32203,7 @@ async function receiveGoalCommand(runtime, store2, botId, threadId, command, tex
32187
32203
 
32188
32204
  // server/index.ts
32189
32205
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
32190
- import { createHash as createHash53, randomBytes as randomBytes15, randomUUID as randomUUID49, timingSafeEqual as timingSafeEqual9 } from "node:crypto";
32206
+ import { createHash as createHash54, randomBytes as randomBytes15, randomUUID as randomUUID49, timingSafeEqual as timingSafeEqual9 } from "node:crypto";
32191
32207
  import { existsSync as existsSync84, readFileSync as readFileSync107, realpathSync as realpathSync15, rmSync as rmSync24, mkdirSync as mkdirSync72, statSync as statSync30 } from "node:fs";
32192
32208
  import { rm as removeDirectory } from "node:fs/promises";
32193
32209
  import { createServer as createServer4 } from "node:http";
@@ -100957,7 +100973,16 @@ var WorkspaceBackupMaintenance = class {
100957
100973
  }
100958
100974
  async run(work, hooks, keepLocked = false) {
100959
100975
  this.assertAvailable();
100960
- if (this.requests || !hooks.idle()) throw Object.assign(new Error("Wait for bot turns, approvals, sign-ins, and computer actions to finish before backing up or restoring."), { status: 409 });
100976
+ if (!keepLocked) {
100977
+ const release2 = this.request();
100978
+ try {
100979
+ await hooks.flush();
100980
+ return await work();
100981
+ } finally {
100982
+ release2();
100983
+ }
100984
+ }
100985
+ if (this.requests || !hooks.idle()) throw Object.assign(new Error("Wait for bot turns, approvals, sign-ins, and computer actions to finish before restoring."), { status: 409 });
100961
100986
  this.active = true;
100962
100987
  let committed = false;
100963
100988
  try {
@@ -100979,7 +101004,7 @@ var WorkspaceBackupMaintenance = class {
100979
101004
 
100980
101005
  // server/workspace-backup-http.ts
100981
101006
  import { randomUUID as randomUUID36 } from "node:crypto";
100982
- import { copyFileSync as copyFileSync4, createReadStream as createReadStream4, createWriteStream as createWriteStream4, existsSync as existsSync62, lstatSync as lstatSync13, mkdirSync as mkdirSync56, readdirSync as readdirSync24, statSync as statSync23, unlinkSync as unlinkSync14 } from "node:fs";
101007
+ import { copyFileSync as copyFileSync4, createReadStream as createReadStream4, createWriteStream as createWriteStream4, existsSync as existsSync62, lstatSync as lstatSync14, mkdirSync as mkdirSync56, readdirSync as readdirSync24, statSync as statSync23, unlinkSync as unlinkSync14 } from "node:fs";
100983
101008
  import { join as join111 } from "node:path";
100984
101009
  import { Transform as Transform3 } from "node:stream";
100985
101010
  import { pipeline as pipeline4 } from "node:stream/promises";
@@ -100999,126 +101024,34 @@ var WORKSPACE_BACKUP_CLIENT_KEYS = [
100999
101024
  ];
101000
101025
 
101001
101026
  // server/workspace-backup.ts
101002
- import { createHash as createHash43, randomBytes as randomBytes8, randomUUID as randomUUID35 } from "node:crypto";
101027
+ import { createHash as createHash44, randomBytes as randomBytes8, randomUUID as randomUUID35 } from "node:crypto";
101003
101028
  import {
101004
101029
  chmodSync as chmodSync9,
101005
- closeSync as closeSync16,
101006
- constants as constants10,
101030
+ closeSync as closeSync17,
101031
+ constants as constants11,
101007
101032
  copyFileSync as copyFileSync3,
101008
101033
  cpSync as cpSync2,
101009
101034
  existsSync as existsSync61,
101010
- fstatSync as fstatSync9,
101011
- fsyncSync as fsyncSync4,
101012
- lstatSync as lstatSync12,
101035
+ fstatSync as fstatSync10,
101036
+ lstatSync as lstatSync13,
101013
101037
  mkdirSync as mkdirSync55,
101014
- openSync as openSync16,
101038
+ openSync as openSync17,
101015
101039
  readFileSync as readFileSync86,
101016
101040
  readdirSync as readdirSync23,
101017
101041
  readlinkSync as readlinkSync2,
101018
- readSync as readSync11,
101042
+ readSync as readSync12,
101019
101043
  realpathSync as realpathSync13,
101020
101044
  renameSync as renameSync16,
101021
101045
  rmSync as rmSync18,
101022
- writeFileSync as writeFileSync32,
101023
- writeSync as writeSync3
101046
+ writeFileSync as writeFileSync32
101024
101047
  } from "node:fs";
101025
101048
  import { isAbsolute as isAbsolute20, join as join110, parse as parse6, posix as posix4, relative as relative10, resolve as resolve27, win32 as win325 } from "node:path";
101026
101049
  import { homedir as homedir42 } from "node:os";
101027
101050
  import { backup, DatabaseSync as DatabaseSync3 } from "node:sqlite";
101028
101051
 
101029
- // server/workspace-backup-policy.ts
101030
- var PORTABLE_CONFIG_KEYS = [
101031
- "profile",
101032
- "language",
101033
- "budgets",
101034
- "billing",
101035
- "rooms",
101036
- "threads",
101037
- "localVm",
101038
- "features",
101039
- "browserProfiles"
101040
- ];
101041
- function portableWorkspaceConfig(value) {
101042
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid workspace configuration in backup.");
101043
- const config2 = parseStoredConfig(value);
101044
- return Object.fromEntries(PORTABLE_CONFIG_KEYS.filter((key5) => config2[key5] !== void 0).map((key5) => [key5, config2[key5]]));
101045
- }
101046
- function restoredWorkspaceConfig(portable, destination) {
101047
- if (!destination || typeof destination !== "object" || Array.isArray(destination)) throw new Error("Invalid destination workspace configuration; connections were not changed.");
101048
- const merged = { ...destination };
101049
- for (const key5 of PORTABLE_CONFIG_KEYS) delete merged[key5];
101050
- return { ...merged, ...portableWorkspaceConfig(portable) };
101051
- }
101052
- function excludedWorkspaceAuthPath(path2) {
101053
- return /^(?:(?:providers|caddy|chrome-profile|\.agent-browser)(?:\/|$)|workspace-credentials\.json$|instance-keys\.json$|external-runtimes\.json$|browser-engine-key$)/.test(path2) || /^(?:config\.json|webhooks\.json|workspace-credentials\.json|instance-keys\.json|external-runtimes\.json|browser-engine-key|sessions\.json|tunnel-account\.json)\.\d+(?:\.[0-9a-f-]+)?\.tmp$/.test(path2) || /^(?:vm-home|vm-homes\/[^/]+)\/\.browser-profiles(?:\/|$)/.test(path2);
101054
- }
101055
- function ephemeralWorkspaceTokenPath(path2) {
101056
- return /^hook-tokens(?:\/|$)/.test(path2);
101057
- }
101058
-
101059
- // server/workspace-backup-private.ts
101060
- import { existsSync as existsSync58, readFileSync as readFileSync83 } from "node:fs";
101061
- import { join as join107 } from "node:path";
101062
- import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
101063
- function record9(value) {
101064
- return value !== null && typeof value === "object" && !Array.isArray(value);
101065
- }
101066
- function privateBotIds(dataDir2) {
101067
- const botIds = /* @__PURE__ */ new Set();
101068
- const threadIds = /* @__PURE__ */ new Set();
101069
- const path2 = join107(dataDir2, "bots.json");
101070
- if (!existsSync58(path2)) return { botIds, threadIds };
101071
- let value;
101072
- try {
101073
- value = JSON.parse(readFileSync83(path2, "utf8"));
101074
- } catch {
101075
- return { botIds, threadIds };
101076
- }
101077
- if (!Array.isArray(value)) return { botIds, threadIds };
101078
- for (const bot of value) {
101079
- if (!record9(bot) || bot.personal !== true || typeof bot.id !== "string") continue;
101080
- botIds.add(bot.id);
101081
- if (typeof bot.threadId === "string") threadIds.add(bot.threadId);
101082
- if (Array.isArray(bot.tasks)) {
101083
- for (const task2 of bot.tasks) if (record9(task2) && typeof task2.threadId === "string") threadIds.add(task2.threadId);
101084
- }
101085
- }
101086
- return { botIds, threadIds };
101087
- }
101088
- function privateBotPath(path2, ids2) {
101089
- if (ids2.size === 0) return false;
101090
- const parts = path2.split("/");
101091
- return parts.slice(1).some((part) => {
101092
- const stem = part.split(".")[0] ?? part;
101093
- return ids2.has(part) || ids2.has(stem);
101094
- });
101095
- }
101096
- function scrubPrivateMessages(dbPath, botIds, threadIds) {
101097
- const attachments = /* @__PURE__ */ new Set();
101098
- if (!existsSync58(dbPath) || botIds.size === 0 && threadIds.size === 0) return attachments;
101099
- const db2 = new DatabaseSync2(dbPath);
101100
- try {
101101
- const threads = [...threadIds];
101102
- const bots = [...botIds];
101103
- const tables = new Set(db2.prepare("SELECT name FROM sqlite_master WHERE type='table'").all().map((row) => String(row.name)));
101104
- const marks = (count) => Array.from({ length: count }, () => "?").join(", ");
101105
- if (threads.length && tables.has("messages")) {
101106
- for (const row of db2.prepare(`SELECT json FROM messages WHERE thread_id IN (${marks(threads.length)})`).all(...threads)) {
101107
- for (const match of String(row.json).matchAll(/\/api\/attachments\/([A-Za-z0-9._-]{1,200})/g)) attachments.add(match[1]);
101108
- }
101109
- db2.prepare(`DELETE FROM messages WHERE thread_id IN (${marks(threads.length)})`).run(...threads);
101110
- }
101111
- if (threads.length && tables.has("thread_state")) db2.prepare(`DELETE FROM thread_state WHERE thread_id IN (${marks(threads.length)})`).run(...threads);
101112
- if (tables.has("chat_followups") && (threads.length || bots.length)) {
101113
- db2.prepare(`DELETE FROM chat_followups WHERE thread_id IN (${marks(threads.length || 1)}) OR owner_id IN (${marks(bots.length || 1)})`).run(...threads.length ? threads : [""], ...bots.length ? bots : [""]);
101114
- }
101115
- if (bots.length && tables.has("memory_files")) db2.prepare(`DELETE FROM memory_files WHERE bot_id IN (${marks(bots.length)})`).run(...bots);
101116
- db2.exec("VACUUM");
101117
- } finally {
101118
- db2.close();
101119
- }
101120
- return attachments;
101121
- }
101052
+ // server/workspace-backup-copy.ts
101053
+ import { createHash as createHash43 } from "node:crypto";
101054
+ 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";
101122
101055
 
101123
101056
  // server/workspace-backup-archive.ts
101124
101057
  import { createCipheriv, createDecipheriv, createHash as createHash42, randomBytes as randomBytes7, scrypt } from "node:crypto";
@@ -101239,6 +101172,150 @@ async function readArchive(inputPath, plaintext, password) {
101239
101172
  }
101240
101173
  }
101241
101174
 
101175
+ // server/workspace-backup-copy.ts
101176
+ function copyRegular(source3, destination, onLiveChange) {
101177
+ let captured;
101178
+ for (let attempt = 0; attempt < 3; attempt++) {
101179
+ let input;
101180
+ try {
101181
+ input = openSync16(source3, constants10.O_RDONLY | constants10.O_NOFOLLOW);
101182
+ } catch (error51) {
101183
+ if (!onLiveChange || error51.code !== "ENOENT") throw error51;
101184
+ onLiveChange(captured ? "changed" : "removed");
101185
+ return captured ?? null;
101186
+ }
101187
+ let output;
101188
+ try {
101189
+ const before = fstatSync9(input);
101190
+ if (!before.isFile() || before.size > MAX_WORKSPACE_BACKUP_BYTES) throw new Error("A workspace file is not regular or exceeds the 64 GB backup limit.");
101191
+ const mode = before.mode & 64 ? 448 : 384;
101192
+ output = openSync16(destination, attempt === 0 ? "wx" : constants10.O_WRONLY | constants10.O_NOFOLLOW | constants10.O_TRUNC, mode);
101193
+ const chunk = Buffer.allocUnsafe(1024 * 1024);
101194
+ const hash4 = createHash43("sha256");
101195
+ let size = 0;
101196
+ while (!onLiveChange || size < before.size) {
101197
+ const length = onLiveChange ? Math.min(chunk.length, before.size - size) : chunk.length;
101198
+ const count = readSync11(input, chunk, 0, length, null);
101199
+ if (!count) break;
101200
+ size += count;
101201
+ if (!onLiveChange && size > before.size) throw new Error("A staged workspace file changed during restore.");
101202
+ hash4.update(chunk.subarray(0, count));
101203
+ let offset = 0;
101204
+ while (offset < count) offset += writeSync3(output, chunk, offset, count - offset);
101205
+ }
101206
+ const after = fstatSync9(input);
101207
+ const current4 = onLiveChange ? null : lstatSync11(source3);
101208
+ const changed2 = size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs || current4 !== null && (current4.ino !== before.ino || current4.dev !== before.dev || current4.isSymbolicLink());
101209
+ if (changed2 && !onLiveChange) throw new Error("A staged workspace file changed during restore.");
101210
+ fsyncSync4(output);
101211
+ captured = { size, mode, sha256: hash4.digest("hex") };
101212
+ if (!changed2) return captured;
101213
+ if (attempt === 2) {
101214
+ onLiveChange?.("changed");
101215
+ return captured;
101216
+ }
101217
+ } finally {
101218
+ closeSync16(input);
101219
+ if (output !== void 0) closeSync16(output);
101220
+ }
101221
+ }
101222
+ return captured ?? null;
101223
+ }
101224
+
101225
+ // server/workspace-backup-policy.ts
101226
+ var PORTABLE_CONFIG_KEYS = [
101227
+ "profile",
101228
+ "language",
101229
+ "budgets",
101230
+ "billing",
101231
+ "rooms",
101232
+ "threads",
101233
+ "localVm",
101234
+ "features",
101235
+ "browserProfiles"
101236
+ ];
101237
+ function portableWorkspaceConfig(value) {
101238
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid workspace configuration in backup.");
101239
+ const config2 = parseStoredConfig(value);
101240
+ return Object.fromEntries(PORTABLE_CONFIG_KEYS.filter((key5) => config2[key5] !== void 0).map((key5) => [key5, config2[key5]]));
101241
+ }
101242
+ function restoredWorkspaceConfig(portable, destination) {
101243
+ if (!destination || typeof destination !== "object" || Array.isArray(destination)) throw new Error("Invalid destination workspace configuration; connections were not changed.");
101244
+ const merged = { ...destination };
101245
+ for (const key5 of PORTABLE_CONFIG_KEYS) delete merged[key5];
101246
+ return { ...merged, ...portableWorkspaceConfig(portable) };
101247
+ }
101248
+ function excludedWorkspaceAuthPath(path2) {
101249
+ return /^(?:(?:providers|caddy|chrome-profile|\.agent-browser)(?:\/|$)|workspace-credentials\.json$|instance-keys\.json$|external-runtimes\.json$|browser-engine-key$)/.test(path2) || /^(?:config\.json|webhooks\.json|workspace-credentials\.json|instance-keys\.json|external-runtimes\.json|browser-engine-key|sessions\.json|tunnel-account\.json)\.\d+(?:\.[0-9a-f-]+)?\.tmp$/.test(path2) || /^(?:vm-home|vm-homes\/[^/]+)\/\.browser-profiles(?:\/|$)/.test(path2);
101250
+ }
101251
+ function ephemeralWorkspaceTokenPath(path2) {
101252
+ return /^hook-tokens(?:\/|$)/.test(path2);
101253
+ }
101254
+
101255
+ // server/workspace-backup-private.ts
101256
+ import { existsSync as existsSync58, readFileSync as readFileSync83 } from "node:fs";
101257
+ import { join as join107 } from "node:path";
101258
+ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
101259
+ function record9(value) {
101260
+ return value !== null && typeof value === "object" && !Array.isArray(value);
101261
+ }
101262
+ function privateBotIds(dataDir2) {
101263
+ const botIds = /* @__PURE__ */ new Set();
101264
+ const threadIds = /* @__PURE__ */ new Set();
101265
+ const path2 = join107(dataDir2, "bots.json");
101266
+ if (!existsSync58(path2)) return { botIds, threadIds };
101267
+ let value;
101268
+ try {
101269
+ value = JSON.parse(readFileSync83(path2, "utf8"));
101270
+ } catch {
101271
+ return { botIds, threadIds };
101272
+ }
101273
+ if (!Array.isArray(value)) return { botIds, threadIds };
101274
+ for (const bot of value) {
101275
+ if (!record9(bot) || bot.personal !== true || typeof bot.id !== "string") continue;
101276
+ botIds.add(bot.id);
101277
+ if (typeof bot.threadId === "string") threadIds.add(bot.threadId);
101278
+ if (Array.isArray(bot.tasks)) {
101279
+ for (const task2 of bot.tasks) if (record9(task2) && typeof task2.threadId === "string") threadIds.add(task2.threadId);
101280
+ }
101281
+ }
101282
+ return { botIds, threadIds };
101283
+ }
101284
+ function privateBotPath(path2, ids2) {
101285
+ if (ids2.size === 0) return false;
101286
+ const parts = path2.split("/");
101287
+ return parts.slice(1).some((part) => {
101288
+ const stem = part.split(".")[0] ?? part;
101289
+ return ids2.has(part) || ids2.has(stem);
101290
+ });
101291
+ }
101292
+ function scrubPrivateMessages(dbPath, botIds, threadIds) {
101293
+ const attachments = /* @__PURE__ */ new Set();
101294
+ if (!existsSync58(dbPath) || botIds.size === 0 && threadIds.size === 0) return attachments;
101295
+ const db2 = new DatabaseSync2(dbPath);
101296
+ try {
101297
+ const threads = [...threadIds];
101298
+ const bots = [...botIds];
101299
+ const tables = new Set(db2.prepare("SELECT name FROM sqlite_master WHERE type='table'").all().map((row) => String(row.name)));
101300
+ const marks = (count) => Array.from({ length: count }, () => "?").join(", ");
101301
+ if (threads.length && tables.has("messages")) {
101302
+ for (const row of db2.prepare(`SELECT json FROM messages WHERE thread_id IN (${marks(threads.length)})`).all(...threads)) {
101303
+ for (const match of String(row.json).matchAll(/\/api\/attachments\/([A-Za-z0-9._-]{1,200})/g)) attachments.add(match[1]);
101304
+ }
101305
+ db2.prepare(`DELETE FROM messages WHERE thread_id IN (${marks(threads.length)})`).run(...threads);
101306
+ }
101307
+ if (threads.length && tables.has("thread_state")) db2.prepare(`DELETE FROM thread_state WHERE thread_id IN (${marks(threads.length)})`).run(...threads);
101308
+ if (tables.has("chat_followups") && (threads.length || bots.length)) {
101309
+ db2.prepare(`DELETE FROM chat_followups WHERE thread_id IN (${marks(threads.length || 1)}) OR owner_id IN (${marks(bots.length || 1)})`).run(...threads.length ? threads : [""], ...bots.length ? bots : [""]);
101310
+ }
101311
+ if (bots.length && tables.has("memory_files")) db2.prepare(`DELETE FROM memory_files WHERE bot_id IN (${marks(bots.length)})`).run(...bots);
101312
+ db2.exec("VACUUM");
101313
+ } finally {
101314
+ db2.close();
101315
+ }
101316
+ return attachments;
101317
+ }
101318
+
101242
101319
  // server/workspace-backup-secrets.ts
101243
101320
  import { randomUUID as randomUUID34 } from "node:crypto";
101244
101321
  import { existsSync as existsSync59, readFileSync as readFileSync84 } from "node:fs";
@@ -101340,7 +101417,7 @@ function markRestoreSecrets(dataDir2, restore2, outcome) {
101340
101417
 
101341
101418
  // server/workspace-restore-paths.ts
101342
101419
  import { execFileSync as execFileSync3 } from "node:child_process";
101343
- import { existsSync as existsSync60, lstatSync as lstatSync11, readFileSync as readFileSync85, readdirSync as readdirSync22, renameSync as renameSync15, symlinkSync as symlinkSync2, writeFileSync as writeFileSync31 } from "node:fs";
101420
+ 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";
101344
101421
  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";
101345
101422
  function validRelative(path2) {
101346
101423
  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));
@@ -101392,7 +101469,7 @@ function rebaseTree(root, pairs2) {
101392
101469
  const visit3 = (directory, depth) => {
101393
101470
  for (const name2 of readdirSync22(directory)) {
101394
101471
  const path2 = join109(directory, name2);
101395
- const stat8 = lstatSync11(path2);
101472
+ const stat8 = lstatSync12(path2);
101396
101473
  if (stat8.isDirectory()) {
101397
101474
  if (name2 === "projects" && relative9(root, path2).startsWith("providers")) renameProjectDirs(path2, pairs2);
101398
101475
  if (depth < 12) visit3(path2, depth + 1);
@@ -101403,7 +101480,7 @@ function rebaseTree(root, pairs2) {
101403
101480
  }
101404
101481
  }
101405
101482
  };
101406
- for (const top of ["workspaces", "skills", "providers"]) if (existsSync60(join109(root, top)) && lstatSync11(join109(root, top)).isDirectory()) visit3(join109(root, top), 0);
101483
+ for (const top of ["workspaces", "skills", "providers"]) if (existsSync60(join109(root, top)) && lstatSync12(join109(root, top)).isDirectory()) visit3(join109(root, top), 0);
101407
101484
  }
101408
101485
  function renameProjectDirs(projects, pairs2) {
101409
101486
  for (const name2 of readdirSync22(projects)) {
@@ -101522,14 +101599,14 @@ function preserved(name2, secrets = false) {
101522
101599
  }
101523
101600
  function folder2(path2) {
101524
101601
  mkdirSync55(path2, { recursive: true, mode: 448 });
101525
- const stat8 = lstatSync12(path2);
101602
+ const stat8 = lstatSync13(path2);
101526
101603
  if (!stat8.isDirectory() || stat8.isSymbolicLink()) throw new Error("The backup directory must be a real directory, not a symbolic link.");
101527
101604
  chmodSync9(path2, 448);
101528
101605
  }
101529
101606
  function backupRoot(dataDir2) {
101530
101607
  const root = resolve27(dataDir2);
101531
101608
  if (root === parse6(root).root) throw new Error("A filesystem root cannot be a workspace backup target.");
101532
- const stat8 = lstatSync12(root);
101609
+ const stat8 = lstatSync13(root);
101533
101610
  if (!stat8.isDirectory() || stat8.isSymbolicLink()) throw new Error("The workspace data directory must not be a symbolic link.");
101534
101611
  const path2 = join110(root, ".backups");
101535
101612
  folder2(path2);
@@ -101539,7 +101616,7 @@ function jobPath(dataDir2, id) {
101539
101616
  if (!ID2.test(id)) throw new Error("Invalid workspace backup identifier.");
101540
101617
  const path2 = join110(backupRoot(dataDir2), id);
101541
101618
  if (entryExists(path2)) {
101542
- const stat8 = lstatSync12(path2);
101619
+ const stat8 = lstatSync13(path2);
101543
101620
  if (!stat8.isDirectory() || stat8.isSymbolicLink()) throw new Error("Unsafe workspace backup job directory.");
101544
101621
  }
101545
101622
  return path2;
@@ -101555,7 +101632,7 @@ function record10(value) {
101555
101632
  }
101556
101633
  function entryExists(path2) {
101557
101634
  try {
101558
- lstatSync12(path2);
101635
+ lstatSync13(path2);
101559
101636
  return true;
101560
101637
  } catch (error51) {
101561
101638
  if (error51.code === "ENOENT") return false;
@@ -101563,13 +101640,13 @@ function entryExists(path2) {
101563
101640
  }
101564
101641
  }
101565
101642
  function privateJson(path2) {
101566
- const fd = openSync16(path2, constants10.O_RDONLY | constants10.O_NOFOLLOW);
101643
+ const fd = openSync17(path2, constants11.O_RDONLY | constants11.O_NOFOLLOW);
101567
101644
  try {
101568
- const stat8 = fstatSync9(fd);
101645
+ const stat8 = fstatSync10(fd);
101569
101646
  if (!stat8.isFile() || stat8.size > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata is too large or is not a regular file.");
101570
101647
  return JSON.parse(readFileSync86(fd, "utf8"));
101571
101648
  } finally {
101572
- closeSync16(fd);
101649
+ closeSync17(fd);
101573
101650
  }
101574
101651
  }
101575
101652
  function writeJson(path2, value) {
@@ -101607,51 +101684,19 @@ function assertLocalAuthOutsideSnapshot(dataDir2) {
101607
101684
  check2(instance.config.configDir, "config.configDir", String(environment.HOME || environment.USERPROFILE || homedir42()));
101608
101685
  }
101609
101686
  }
101610
- function copyRegular(source3, destination) {
101611
- const input = openSync16(source3, constants10.O_RDONLY | constants10.O_NOFOLLOW);
101612
- let output;
101613
- try {
101614
- const before = fstatSync9(input);
101615
- if (!before.isFile() || before.size > MAX_WORKSPACE_BACKUP_BYTES) throw new Error("A workspace file is not regular or exceeds the 64 GB backup limit.");
101616
- const mode = before.mode & 64 ? 448 : 384;
101617
- output = openSync16(destination, "wx", mode);
101618
- const chunk = Buffer.allocUnsafe(1024 * 1024);
101619
- const hash4 = createHash43("sha256");
101620
- let size = 0;
101621
- for (; ; ) {
101622
- const count = readSync11(input, chunk, 0, chunk.length, null);
101623
- if (!count) break;
101624
- size += count;
101625
- if (size > before.size) throw new Error("A workspace file changed during backup. Stop its writer and retry.");
101626
- hash4.update(chunk.subarray(0, count));
101627
- let offset = 0;
101628
- while (offset < count) offset += writeSync3(output, chunk, offset, count - offset);
101629
- }
101630
- const after = fstatSync9(input);
101631
- const current4 = lstatSync12(source3);
101632
- if (size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs || current4.ino !== before.ino || current4.dev !== before.dev || current4.isSymbolicLink()) {
101633
- throw new Error("A workspace file changed during backup. Stop its writer and retry.");
101634
- }
101635
- fsyncSync4(output);
101636
- return { size, mode, sha256: hash4.digest("hex") };
101637
- } finally {
101638
- closeSync16(input);
101639
- if (output !== void 0) closeSync16(output);
101640
- }
101641
- }
101642
101687
  function hashFile(path2) {
101643
- const fd = openSync16(path2, constants10.O_RDONLY | constants10.O_NOFOLLOW);
101688
+ const fd = openSync17(path2, constants11.O_RDONLY | constants11.O_NOFOLLOW);
101644
101689
  try {
101645
- if (!fstatSync9(fd).isFile()) throw new Error("The workspace archive contains an unsafe file.");
101646
- const hash4 = createHash43("sha256");
101690
+ if (!fstatSync10(fd).isFile()) throw new Error("The workspace archive contains an unsafe file.");
101691
+ const hash4 = createHash44("sha256");
101647
101692
  const chunk = Buffer.allocUnsafe(1024 * 1024);
101648
101693
  for (; ; ) {
101649
- const count = readSync11(fd, chunk, 0, chunk.length, null);
101694
+ const count = readSync12(fd, chunk, 0, chunk.length, null);
101650
101695
  if (!count) return hash4.digest("hex");
101651
101696
  hash4.update(chunk.subarray(0, count));
101652
101697
  }
101653
101698
  } finally {
101654
- closeSync16(fd);
101699
+ closeSync17(fd);
101655
101700
  }
101656
101701
  }
101657
101702
  function countJsonArray(path2) {
@@ -101697,19 +101742,21 @@ async function createWorkspaceBackup(dataDir2, options) {
101697
101742
  const links = [];
101698
101743
  const checkouts = [];
101699
101744
  const warnings = [
101700
- "Stop external editors and managed desktops before exporting; files written outside this server cannot be frozen by the backup gate.",
101745
+ "Files are captured as the backup runs. External changes made after a file is captured belong to the next backup.",
101701
101746
  encrypted ? "Conversation text and user files are not redacted and may contain secrets you pasted. Keep the encrypted backup private." : "This backup is not encrypted. Anyone with the file can read your conversations and files; keep it private.",
101702
101747
  ...secrets ? ["This backup holds your keys, passwords and tokens. Anyone with the file and its password can use them."] : [],
101703
101748
  RESTORE_WARNING
101704
101749
  ];
101705
101750
  let bytes2 = 0;
101706
101751
  let skippedLinks = 0;
101752
+ let changedFiles = 0;
101753
+ let removedFiles = 0;
101707
101754
  const progress = () => options.onProgress?.({ phase: "copying", files: entries2.length, bytes: bytes2 });
101708
101755
  try {
101709
101756
  const root = realpathSync13(dataDir2);
101710
101757
  const sourceDb = join110(root, "messages.db");
101711
101758
  if (existsSync61(sourceDb)) {
101712
- if (lstatSync12(sourceDb).isSymbolicLink()) throw new Error("The message database must not be a symbolic link.");
101759
+ if (lstatSync13(sourceDb).isSymbolicLink()) throw new Error("The message database must not be a symbolic link.");
101713
101760
  const db2 = new DatabaseSync3(sourceDb, { readOnly: true });
101714
101761
  const completionPulse = setInterval(() => {
101715
101762
  }, 25);
@@ -101742,7 +101789,14 @@ async function createWorkspaceBackup(dataDir2, options) {
101742
101789
  if (forbiddenArchivePath(path3, secrets)) throw new Error("A workspace filename conflicts with a protected authentication or runtime path.");
101743
101790
  if (!validRelative(path3)) throw new Error("A workspace filename cannot be safely restored on supported platforms.");
101744
101791
  const source3 = join110(directory, name2);
101745
- const stat8 = lstatSync12(source3);
101792
+ let stat8;
101793
+ try {
101794
+ stat8 = lstatSync13(source3);
101795
+ } catch (error51) {
101796
+ if (error51.code !== "ENOENT") throw error51;
101797
+ removedFiles++;
101798
+ continue;
101799
+ }
101746
101800
  if (prefix && REINSTALLABLE_DIRS.has(name2) && (stat8.isDirectory() || stat8.isSymbolicLink())) continue;
101747
101801
  if (stat8.isSymbolicLink() && BROWSER_LOCK_LINKS.has(name2)) continue;
101748
101802
  if (stat8.isSymbolicLink()) {
@@ -101769,11 +101823,11 @@ async function createWorkspaceBackup(dataDir2, options) {
101769
101823
  if (hiddenIds.size && path3 === "bots.json") {
101770
101824
  const value = privateJson(source3);
101771
101825
  writeJson(destination, Array.isArray(value) ? value.filter((bot) => !(record10(bot) && bot.personal === true)) : value);
101772
- copied = { size: lstatSync12(destination).size, mode: 384, sha256: hashFile(destination) };
101826
+ copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
101773
101827
  } else if (hiddenIds.size && name2.endsWith(".jsonl")) {
101774
101828
  const kept = readFileSync86(source3, "utf8").split("\n").filter((line3) => ![...hiddenIds].some((id) => line3.includes(id)));
101775
101829
  writeFileSync32(destination, kept.join("\n"), { mode: 384, flag: "wx" });
101776
- copied = { size: lstatSync12(destination).size, mode: 384, sha256: hashFile(destination) };
101830
+ copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
101777
101831
  } else if ((path3 === "config.json" || path3 === "webhooks.json") && !secrets) {
101778
101832
  const value = privateJson(source3);
101779
101833
  if (path3 === "config.json") writeJson(destination, portableWorkspaceConfig(value));
@@ -101784,8 +101838,19 @@ async function createWorkspaceBackup(dataDir2, options) {
101784
101838
  }
101785
101839
  writeJson(destination, value);
101786
101840
  }
101787
- copied = { size: lstatSync12(destination).size, mode: 384, sha256: hashFile(destination) };
101788
- } else copied = copyRegular(path3 === "messages.db" ? join110(snapshot2, "messages-snapshot.db") : source3, destination);
101841
+ copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
101842
+ } else {
101843
+ const captured = copyRegular(
101844
+ path3 === "messages.db" ? join110(snapshot2, "messages-snapshot.db") : source3,
101845
+ destination,
101846
+ path3 === "messages.db" ? void 0 : (kind) => {
101847
+ if (kind === "changed") changedFiles++;
101848
+ else removedFiles++;
101849
+ }
101850
+ );
101851
+ if (!captured) continue;
101852
+ copied = captured;
101853
+ }
101789
101854
  bytes2 += copied.size;
101790
101855
  if (bytes2 > MAX_WORKSPACE_BACKUP_BYTES) throw new Error("The workspace exceeds the 64 GB backup limit.");
101791
101856
  entries2.push({ path: path3, type: "file", ...copied });
@@ -101794,6 +101859,8 @@ async function createWorkspaceBackup(dataDir2, options) {
101794
101859
  }
101795
101860
  };
101796
101861
  walk2(root);
101862
+ if (changedFiles) warnings.push(`${changedFiles} file(s) kept changing during backup. Their captured bytes are included, but may contain an in-progress write.`);
101863
+ if (removedFiles) warnings.push(`${removedFiles} file(s) disappeared before they could be captured and are not included.`);
101797
101864
  if (skippedLinks) warnings.push(`${skippedLinks} managed skill discovery link(s) were omitted and are recreated by the app.`);
101798
101865
  if (checkouts.length) warnings.push(`${checkouts.length} project checkout(s) with no local changes were left out; clone them again from their remote. Files git ignores in them (such as .env) are not included.`);
101799
101866
  if (secrets && !options.secrets) warnings.push("This computer's secure credential store was not available, so connection keys saved there are not in this backup.");
@@ -101878,12 +101945,12 @@ function validateManifest(value) {
101878
101945
  return value;
101879
101946
  }
101880
101947
  async function inspectTar(path2) {
101881
- const fd = openSync16(path2, "r");
101948
+ const fd = openSync17(path2, "r");
101882
101949
  const signature2 = Buffer.alloc(2);
101883
101950
  try {
101884
- readSync11(fd, signature2, 0, 2, 0);
101951
+ readSync12(fd, signature2, 0, 2, 0);
101885
101952
  } finally {
101886
- closeSync16(fd);
101953
+ closeSync17(fd);
101887
101954
  }
101888
101955
  if (signature2[0] === 31 && signature2[1] === 139) throw new Error("Compressed payloads are not supported in this workspace backup version.");
101889
101956
  const entries2 = /* @__PURE__ */ new Map();
@@ -101919,7 +101986,7 @@ function validateStaged(directory, expected) {
101919
101986
  for (const name2 of readdirSync23(root)) {
101920
101987
  const path2 = prefix ? `${prefix}/${name2}` : name2;
101921
101988
  if (!declared.has(path2)) throw new Error("Staged workspace contains files absent from its manifest.");
101922
- const stat8 = lstatSync12(join110(root, name2));
101989
+ const stat8 = lstatSync13(join110(root, name2));
101923
101990
  if (stat8.isSymbolicLink()) throw new Error("Staged workspace contains a symbolic link.");
101924
101991
  if (stat8.isDirectory()) inspect(join110(root, name2), path2);
101925
101992
  }
@@ -101927,7 +101994,7 @@ function validateStaged(directory, expected) {
101927
101994
  inspect(join110(directory, "data"));
101928
101995
  for (const entry of manifest.entries) {
101929
101996
  const path2 = join110(directory, "data", entry.path);
101930
- const stat8 = lstatSync12(path2);
101997
+ const stat8 = lstatSync13(path2);
101931
101998
  if (stat8.isSymbolicLink() || (entry.type === "file" ? !stat8.isFile() || stat8.size !== entry.size : !stat8.isDirectory())) {
101932
101999
  throw new Error("Staged workspace files do not match the backup manifest.");
101933
102000
  }
@@ -102120,13 +102187,13 @@ function prepareRestore(dataDir2, id, manifest) {
102120
102187
  const browserHomes = ["vm-home"];
102121
102188
  const vmHomes = join110(dataDir2, "vm-homes");
102122
102189
  if (entryExists(vmHomes)) {
102123
- if (!lstatSync12(vmHomes).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
102190
+ if (!lstatSync13(vmHomes).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
102124
102191
  for (const name2 of readdirSync23(vmHomes)) if (validRelative(name2)) browserHomes.push(`vm-homes/${name2}`);
102125
102192
  }
102126
102193
  for (const home of browserHomes) {
102127
102194
  const homePath = join110(dataDir2, home);
102128
102195
  if (!entryExists(homePath)) continue;
102129
- if (!lstatSync12(homePath).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
102196
+ if (!lstatSync13(homePath).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
102130
102197
  const source3 = join110(dataDir2, home, ".browser-profiles");
102131
102198
  if (!entryExists(source3)) continue;
102132
102199
  folder2(join110(prepared, home));
@@ -102298,7 +102365,7 @@ function removeWorkspaceBackupJob(dataDir2, id) {
102298
102365
  }
102299
102366
  if (existsSync61(join110(root, `safety-${id}`))) throw new Error("This backup has a recovery copy and cannot be removed.");
102300
102367
  if (!entryExists(path2)) return;
102301
- if (!lstatSync12(path2).isDirectory() || lstatSync12(path2).isSymbolicLink()) throw new Error("Unsafe workspace backup cleanup target.");
102368
+ if (!lstatSync13(path2).isDirectory() || lstatSync13(path2).isSymbolicLink()) throw new Error("Unsafe workspace backup cleanup target.");
102302
102369
  rmSync18(path2, { recursive: true, force: true });
102303
102370
  }
102304
102371
 
@@ -102347,7 +102414,7 @@ function createWorkspaceBackupRoutes(options) {
102347
102414
  }
102348
102415
  function reclaimAbandoned() {
102349
102416
  const root = join111(options.dataDir, ".backups");
102350
- if (!existsSync62(root) || lstatSync13(root).isSymbolicLink()) return;
102417
+ if (!existsSync62(root) || lstatSync14(root).isSymbolicLink()) return;
102351
102418
  for (const entry of readdirSync24(root, { withFileTypes: true })) {
102352
102419
  if (!entry.isDirectory() || !/^[a-f0-9-]{36}$/.test(entry.name)) continue;
102353
102420
  if (statSync23(join111(root, entry.name)).mtimeMs + EXPIRES_MS > Date.now()) continue;
@@ -102357,7 +102424,7 @@ function createWorkspaceBackupRoutes(options) {
102357
102424
  }
102358
102425
  }
102359
102426
  const uploads = join111(root, "uploads");
102360
- if (!existsSync62(uploads) || lstatSync13(uploads).isSymbolicLink()) return;
102427
+ if (!existsSync62(uploads) || lstatSync14(uploads).isSymbolicLink()) return;
102361
102428
  for (const entry of readdirSync24(uploads, { withFileTypes: true })) {
102362
102429
  if (!entry.isFile() || !/^[a-f0-9-]{36}\.ombbackup$/.test(entry.name)) continue;
102363
102430
  const file2 = join111(uploads, entry.name);
@@ -102394,10 +102461,10 @@ function createWorkspaceBackupRoutes(options) {
102394
102461
  function uploadsDirectory() {
102395
102462
  const root = join111(options.dataDir, ".backups");
102396
102463
  mkdirSync56(root, { recursive: true, mode: 448 });
102397
- if (lstatSync13(root).isSymbolicLink()) throw failure3("Backup storage must not be a symbolic link.");
102464
+ if (lstatSync14(root).isSymbolicLink()) throw failure3("Backup storage must not be a symbolic link.");
102398
102465
  const directory = join111(root, "uploads");
102399
102466
  mkdirSync56(directory, { recursive: true, mode: 448 });
102400
- if (lstatSync13(directory).isSymbolicLink()) throw failure3("Backup storage must not be a symbolic link.");
102467
+ if (lstatSync14(directory).isSymbolicLink()) throw failure3("Backup storage must not be a symbolic link.");
102401
102468
  return directory;
102402
102469
  }
102403
102470
  async function operate(work) {
@@ -102420,6 +102487,7 @@ function createWorkspaceBackupRoutes(options) {
102420
102487
  const restored = options.restored;
102421
102488
  json5(res, 200, {
102422
102489
  ...options.status(),
102490
+ busy: operating || options.status().busy,
102423
102491
  progress,
102424
102492
  lastRestoreId: restored.restored ? restored.id : null,
102425
102493
  safetyCopyPath: restored.safetyCopyPath ?? null,
@@ -103327,7 +103395,7 @@ import { timingSafeEqual as timingSafeEqual5 } from "node:crypto";
103327
103395
  import { isIP as isIP2 } from "node:net";
103328
103396
 
103329
103397
  // server/connected-assistants.ts
103330
- import { createHash as createHash44, randomBytes as randomBytes10, randomUUID as randomUUID37, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
103398
+ import { createHash as createHash45, randomBytes as randomBytes10, randomUUID as randomUUID37, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
103331
103399
  import { existsSync as existsSync63, mkdirSync as mkdirSync57, readdirSync as readdirSync25, readFileSync as readFileSync87, rmSync as rmSync19 } from "node:fs";
103332
103400
  import { appendFile as appendFile5, mkdir as mkdir8 } from "node:fs/promises";
103333
103401
  import { dirname as dirname31, join as join112 } from "node:path";
@@ -103342,7 +103410,7 @@ var recordSchema = external_exports.object({
103342
103410
  allowCreate: external_exports.boolean()
103343
103411
  });
103344
103412
  var fileSchema3 = external_exports.object({ version: external_exports.literal(1), assistants: external_exports.array(recordSchema) });
103345
- var hash3 = (token) => createHash44("sha256").update(token).digest("hex");
103413
+ var hash3 = (token) => createHash45("sha256").update(token).digest("hex");
103346
103414
  var LAST_USED_WRITE_MS = 6e4;
103347
103415
  var ConnectedAssistants = class {
103348
103416
  assistants = [];
@@ -104042,8 +104110,8 @@ function resolveRequestAuth(req, options) {
104042
104110
  }
104043
104111
 
104044
104112
  // server/sessions.ts
104045
- import { createHash as createHash45, randomBytes as randomBytes11, randomUUID as randomUUID38, timingSafeEqual as timingSafeEqual6 } from "node:crypto";
104046
- import { closeSync as closeSync17, existsSync as existsSync64, fsyncSync as fsyncSync5, mkdirSync as mkdirSync58, openSync as openSync17, readFileSync as readFileSync88, unlinkSync as unlinkSync15 } from "node:fs";
104113
+ import { createHash as createHash46, randomBytes as randomBytes11, randomUUID as randomUUID38, timingSafeEqual as timingSafeEqual6 } from "node:crypto";
104114
+ 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";
104047
104115
  import { dirname as dirname32 } from "node:path";
104048
104116
  var SCOPES = ["admin", "client"];
104049
104117
  var PAIRING_CODE_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
@@ -104081,7 +104149,7 @@ var sessionSchema = external_exports.object({
104081
104149
  membershipAuthority: external_exports.literal("portal").optional()
104082
104150
  });
104083
104151
  var fileSchema4 = external_exports.object({ version: external_exports.literal(1), sessions: external_exports.array(sessionSchema) });
104084
- var sha2562 = (value) => createHash45("sha256").update(value).digest("hex");
104152
+ var sha2562 = (value) => createHash46("sha256").update(value).digest("hex");
104085
104153
  function sameDigest(a, b3) {
104086
104154
  const left = Buffer.from(a, "hex");
104087
104155
  const right = Buffer.from(b3, "hex");
@@ -104166,11 +104234,11 @@ var SessionRegistry = class {
104166
104234
  }
104167
104235
  syncDirectory() {
104168
104236
  if (process.platform === "win32") return;
104169
- const fd = openSync17(dirname32(this.options.file), "r");
104237
+ const fd = openSync18(dirname32(this.options.file), "r");
104170
104238
  try {
104171
104239
  fsyncSync5(fd);
104172
104240
  } finally {
104173
- closeSync17(fd);
104241
+ closeSync18(fd);
104174
104242
  }
104175
104243
  }
104176
104244
  /** Atomic write, owner-only, directory owner-only. */
@@ -105131,7 +105199,7 @@ function removeStream(clients, registry3, client) {
105131
105199
  }
105132
105200
 
105133
105201
  // server/phone-secret.ts
105134
- import { createECDH, createHash as createHash46 } from "node:crypto";
105202
+ import { createECDH, createHash as createHash47 } from "node:crypto";
105135
105203
 
105136
105204
  // node_modules/.pnpm/@hpke+common@1.10.1/node_modules/@hpke/common/esm/src/errors.js
105137
105205
  var HpkeError = class extends Error {
@@ -107315,7 +107383,7 @@ function phoneSecretKeyIdFromJwk(jwk) {
107315
107383
  const x2 = decodeBase64URL(jwk.x, 32);
107316
107384
  const y = decodeBase64URL(jwk.y, 32);
107317
107385
  if (!x2 || !y) return null;
107318
- return createHash46("sha256").update(Buffer.concat([Buffer.from([4]), x2, y])).digest().subarray(0, 16).toString("base64url");
107386
+ return createHash47("sha256").update(Buffer.concat([Buffer.from([4]), x2, y])).digest().subarray(0, 16).toString("base64url");
107319
107387
  }
107320
107388
  function phoneSecretAAD(context) {
107321
107389
  const fields = [
@@ -107335,7 +107403,7 @@ function phoneSecretAAD(context) {
107335
107403
  }
107336
107404
  function phoneSecretOperationId(context) {
107337
107405
  const aad = phoneSecretAAD(context);
107338
- return createHash46("sha256").update(aad).update("\0").update(String(context.version)).update("\n").update(context.encapsulatedKey).update("\n").update(context.ciphertext).digest("base64url");
107406
+ return createHash47("sha256").update(aad).update("\0").update(String(context.version)).update("\n").update(context.encapsulatedKey).update("\n").update(context.ciphertext).digest("base64url");
107339
107407
  }
107340
107408
  function assertPhoneSecretRequestMatches(context, authenticatedDeviceId, expected) {
107341
107409
  if (context.deviceId !== authenticatedDeviceId || context.target !== expected.target || context.requestKey !== expected.requestKey) {
@@ -107913,8 +107981,8 @@ function appsByBot(result) {
107913
107981
  }
107914
107982
 
107915
107983
  // server/harness-import/dedupe.ts
107916
- import { createHash as createHash47 } from "node:crypto";
107917
- var fingerprint3 = (skill) => createHash47("sha256").update(skill.files.map((file2) => `${file2.file}\0${file2.content.replace(/\r\n/g, "\n").trim()}`).join("\0\0")).digest("hex");
107984
+ import { createHash as createHash48 } from "node:crypto";
107985
+ var fingerprint3 = (skill) => createHash48("sha256").update(skill.files.map((file2) => `${file2.file}\0${file2.content.replace(/\r\n/g, "\n").trim()}`).join("\0\0")).digest("hex");
107918
107986
  function words3(skill) {
107919
107987
  const text18 = skill.files.map((file2) => file2.content).join("\n").toLowerCase();
107920
107988
  return new Set(text18.match(/[a-z0-9]{3,}/g) ?? []);
@@ -108452,7 +108520,7 @@ Imported from ${names3.label}. This is the start of your notes; the whole of the
108452
108520
  }
108453
108521
 
108454
108522
  // server/harness-import/secrets.ts
108455
- import { createHash as createHash48 } from "node:crypto";
108523
+ import { createHash as createHash49 } from "node:crypto";
108456
108524
  var EXAMPLE_EMAIL_DOMAINS = /@(?:[a-z0-9-]+\.)*(?:example\.(?:com|org|net)|example|test|invalid)$/i;
108457
108525
  var hasLetterAndDigit = (value) => /[A-Za-z]/.test(value) && /\d/.test(value);
108458
108526
  var PATTERNS = [
@@ -108582,7 +108650,7 @@ function createSecretReferencer() {
108582
108650
  const nameByDigest = /* @__PURE__ */ new Map();
108583
108651
  const taken = /* @__PURE__ */ new Set();
108584
108652
  const nameFor = (type, value, base5) => {
108585
- const digest2 = createHash48("sha256").update(`${type}\0${value}`).digest("hex");
108653
+ const digest2 = createHash49("sha256").update(`${type}\0${value}`).digest("hex");
108586
108654
  const known2 = nameByDigest.get(digest2);
108587
108655
  if (known2) return known2;
108588
108656
  let name2 = base5;
@@ -110050,7 +110118,7 @@ In ${identity3.label} this job ran on: ${trigger3}. The event that triggered thi
110050
110118
  }
110051
110119
 
110052
110120
  // server/harness-import/hermes.ts
110053
- import { createHash as createHash49 } from "node:crypto";
110121
+ import { createHash as createHash50 } from "node:crypto";
110054
110122
  import { existsSync as existsSync70, statSync as statSync27 } from "node:fs";
110055
110123
  import { homedir as homedir46 } from "node:os";
110056
110124
  import { basename as basename20, dirname as dirname35, isAbsolute as isAbsolute22, join as join119, resolve as resolve30 } from "node:path";
@@ -110373,7 +110441,7 @@ function bundledSkills(reader, profile) {
110373
110441
  const text18 = reader.readText(`${profile.base}skills/.bundled_manifest`) ?? "";
110374
110442
  return new Set(text18.split(/\r?\n/).map((line3) => line3.split(":")[0].trim()).filter(Boolean));
110375
110443
  }
110376
- var fingerprint4 = (files) => createHash49("sha256").update(files.map((file2) => `${file2.file}\0${file2.content.replace(/\r\n/g, "\n").trim()}`).join("\0\0")).digest("hex");
110444
+ var fingerprint4 = (files) => createHash50("sha256").update(files.map((file2) => `${file2.file}\0${file2.content.replace(/\r\n/g, "\n").trim()}`).join("\0\0")).digest("hex");
110377
110445
  function mergeSkills2(found) {
110378
110446
  const bySlug = /* @__PURE__ */ new Map();
110379
110447
  for (const item of found) bySlug.set(item.slug, [...bySlug.get(item.slug) ?? [], { profile: item.profile, files: item.files, print: fingerprint4(item.files) }]);
@@ -110495,7 +110563,7 @@ function readHermesHome(root, options = {}) {
110495
110563
  }
110496
110564
 
110497
110565
  // server/harness-import/history.ts
110498
- import { createHash as createHash50 } from "node:crypto";
110566
+ import { createHash as createHash51 } from "node:crypto";
110499
110567
  import { mkdtempSync as mkdtempSync6, rmSync as rmSync20, statSync as statSync28, writeFileSync as writeFileSync33 } from "node:fs";
110500
110568
  import { tmpdir as tmpdir11 } from "node:os";
110501
110569
  import { join as join120 } from "node:path";
@@ -110635,7 +110703,7 @@ function locateFile(reader, ownerId, ref) {
110635
110703
  return { key: key5, sourcePath: null, bytes: 0 };
110636
110704
  }
110637
110705
  function uploadIdFor(key5) {
110638
- const hex3 = createHash50("sha256").update(`grokbot-history:${key5}`).digest("hex");
110706
+ const hex3 = createHash51("sha256").update(`grokbot-history:${key5}`).digest("hex");
110639
110707
  const variant = (parseInt(hex3[16], 16) & 3 | 8).toString(16);
110640
110708
  return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-5${hex3.slice(13, 16)}-${variant}${hex3.slice(17, 20)}-${hex3.slice(20, 32)}`;
110641
110709
  }
@@ -111565,8 +111633,8 @@ import { homedir as homedir48 } from "node:os";
111565
111633
  import { delimiter as delimiter7, join as join122 } from "node:path";
111566
111634
 
111567
111635
  // server/app-installers.ts
111568
- import { createHash as createHash51 } from "node:crypto";
111569
- import { accessSync as accessSync3, constants as constants11, createReadStream as createReadStream5, createWriteStream as createWriteStream5, existsSync as existsSync72, mkdirSync as mkdirSync61, mkdtempSync as mkdtempSync7, renameSync as renameSync17, rmSync as rmSync21 } from "node:fs";
111636
+ import { createHash as createHash52 } from "node:crypto";
111637
+ import { accessSync as accessSync3, constants as constants12, createReadStream as createReadStream5, createWriteStream as createWriteStream5, existsSync as existsSync72, mkdirSync as mkdirSync61, mkdtempSync as mkdtempSync7, renameSync as renameSync17, rmSync as rmSync21 } from "node:fs";
111570
111638
  import { homedir as homedir47, tmpdir as tmpdir12 } from "node:os";
111571
111639
  import { join as join121 } from "node:path";
111572
111640
  import { Readable as Readable2 } from "node:stream";
@@ -111638,7 +111706,7 @@ async function downloadAsset(asset, dest, deps = {}) {
111638
111706
  throw new AppInstallError("verify", `The download came from ${final.origin}, not GitHub.`);
111639
111707
  }
111640
111708
  if (!response.ok || !response.body) throw new AppInstallError("download", `The download answered ${response.status}.`);
111641
- const hash4 = createHash51("sha256");
111709
+ const hash4 = createHash52("sha256");
111642
111710
  let received = 0;
111643
111711
  let lastReport = 0;
111644
111712
  const counter = async function* (source3) {
@@ -111691,7 +111759,7 @@ async function verifyPkgSignature(pkg, teamId, run7 = runTool) {
111691
111759
  }
111692
111760
  function writableDir(dir) {
111693
111761
  try {
111694
- accessSync3(dir, constants11.W_OK);
111762
+ accessSync3(dir, constants12.W_OK);
111695
111763
  return true;
111696
111764
  } catch {
111697
111765
  return false;
@@ -113049,7 +113117,7 @@ function botAccountIds(bot) {
113049
113117
  }
113050
113118
 
113051
113119
  // server/oauth-accounts.ts
113052
- import { createHash as createHash52, randomBytes as randomBytes13, randomUUID as randomUUID44, timingSafeEqual as timingSafeEqual7 } from "node:crypto";
113120
+ import { createHash as createHash53, randomBytes as randomBytes13, randomUUID as randomUUID44, timingSafeEqual as timingSafeEqual7 } from "node:crypto";
113053
113121
  import { createServer as createServer3 } from "node:http";
113054
113122
 
113055
113123
  // server/oauth-account-vault.ts
@@ -113234,7 +113302,7 @@ function createPkcePair() {
113234
113302
  return { verifier, challenge: pkceChallenge(verifier) };
113235
113303
  }
113236
113304
  function pkceChallenge(verifier) {
113237
- return base64url3(createHash52("sha256").update(verifier, "ascii").digest());
113305
+ return base64url3(createHash53("sha256").update(verifier, "ascii").digest());
113238
113306
  }
113239
113307
  function buildAuthorizationUrl(input) {
113240
113308
  const provider = OAUTH_PROVIDERS[input.provider];
@@ -113887,7 +113955,7 @@ import { timingSafeEqual as timingSafeEqual8 } from "node:crypto";
113887
113955
 
113888
113956
  // server/vault/store.ts
113889
113957
  import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes14, randomUUID as randomUUID45 } from "node:crypto";
113890
- import { lstatSync as lstatSync14, mkdirSync as mkdirSync64, readFileSync as readFileSync97, rmdirSync } from "node:fs";
113958
+ import { lstatSync as lstatSync15, mkdirSync as mkdirSync64, readFileSync as readFileSync97, rmdirSync } from "node:fs";
113891
113959
  import { join as join126 } from "node:path";
113892
113960
 
113893
113961
  // shared/vault.ts
@@ -113997,7 +114065,7 @@ var VaultStore = class {
113997
114065
  try {
113998
114066
  let stat8;
113999
114067
  try {
114000
- stat8 = lstatSync14(this.#file);
114068
+ stat8 = lstatSync15(this.#file);
114001
114069
  } catch (error51) {
114002
114070
  if (error51.code === "ENOENT") return [];
114003
114071
  throw error51;
@@ -125203,7 +125271,7 @@ function emailPersonKey(email3) {
125203
125271
  return opaquePersonKey(`email:${email3.trim().toLowerCase()}`);
125204
125272
  }
125205
125273
  function opaquePersonKey(basis) {
125206
- return `p_${createHash53("sha256").update(basis).digest("base64url").slice(0, 22)}`;
125274
+ return `p_${createHash54("sha256").update(basis).digest("base64url").slice(0, 22)}`;
125207
125275
  }
125208
125276
  function sharedMembership() {
125209
125277
  return hostedWorkspaceConfiguration()?.portalMembership === true || signInAllowList().members.length > 0;
@@ -129975,7 +130043,7 @@ function ingestEngineHook(capability, body) {
129975
130043
  if (!commandReceipt("hook.ingest", key5)) {
129976
130044
  const dir = join136(TOOL_RESULTS_DIR, threadId.replace(/[^\w.-]/g, "_"));
129977
130045
  mkdirSync72(dir, { recursive: true, mode: 448 });
129978
- const safeId = createHash53("sha256").update(key5).digest("hex");
130046
+ const safeId = createHash54("sha256").update(key5).digest("hex");
129979
130047
  const file2 = join136(dir, `${safeId}.txt`);
129980
130048
  const redacted = redactSecretsInText(text18);
129981
130049
  const bounded4 = redacted.length > TOOL_RESULT_SPILL_MAX ? `${redacted.slice(0, TOOL_RESULT_SPILL_MAX)}
@@ -130890,7 +130958,7 @@ bus.subscribe((event) => {
130890
130958
  source: "delegated-grant"
130891
130959
  } : ownVerdict;
130892
130960
  if (roomAsk && permission && event.requestId && !verdict?.approve) {
130893
- const actionHash = createHash53("sha256").update(JSON.stringify([event.threadId, event.requestId, event.tool, event.summary])).digest("hex");
130961
+ const actionHash = createHash54("sha256").update(JSON.stringify([event.threadId, event.requestId, event.tool, event.summary])).digest("hex");
130894
130962
  teamRoomsHost?.approvalOpened(event.threadId, event.requestId, event.summary || event.tool, actionHash);
130895
130963
  }
130896
130964
  if (permission && asker && event.nativeReview === "inactive" && effectiveApprovalMode === "auto" && !nativeReviewNoticed.has(event.threadId)) {
@@ -132385,7 +132453,7 @@ async function startTurn(botId, text18, opts) {
132385
132453
  sectionContextSystemPrompt(bot.section),
132386
132454
  ...instance.driverKind === "codex" ? [model2, effort ?? null] : []
132387
132455
  ];
132388
- const sessionConfig = (soul) => createHash53("sha256").update(JSON.stringify([...persistentConfig, soul])).digest("hex").slice(0, 16);
132456
+ const sessionConfig = (soul) => createHash54("sha256").update(JSON.stringify([...persistentConfig, soul])).digest("hex").slice(0, 16);
132389
132457
  const plannedConfig = sessionConfig(bot.soul);
132390
132458
  const skillAuthoring = skillAuthoringEnabled(cfg) && agentsMounted;
132391
132459
  const attachedText = commsDepth === 0 ? await withZipListings(providerText) : providerText;
@@ -135488,7 +135556,7 @@ function resolveSkillRequest(args) {
135488
135556
  error: "reviewedSha256 must match the skill shown on the approval card"
135489
135557
  };
135490
135558
  }
135491
- const previewSha256 = createHash53("sha256").update(request4.preview).digest("hex");
135559
+ const previewSha256 = createHash54("sha256").update(request4.preview).digest("hex");
135492
135560
  if (previewSha256 !== request4.sha256) {
135493
135561
  return { claimed: true, status: 422, error: "the skill preview changed after review \u2014 deny and recreate it" };
135494
135562
  }
@@ -136496,7 +136564,7 @@ var workspaceBackupRoutes = createWorkspaceBackupRoutes({
136496
136564
  },
136497
136565
  flush: async () => {
136498
136566
  await Promise.all([flushAllProfileHistory(), flushAllMemoryJournals(), flushUsageLedger(DATA_DIR), flushDecisionLog(DATA_DIR), flushAdminActivity(DATA_DIR)]);
136499
- closeMessageDb();
136567
+ if (keepLocked) closeMessageDb();
136500
136568
  }
136501
136569
  }, keepLocked)
136502
136570
  });