@covro/covro 0.11.1-dev.3 → 0.11.1-dev.5

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 (131) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/backups/manager.js +1 -1
  4. package/dist/backups/manager.js.map +2 -2
  5. package/dist/cli/background.js +10 -4
  6. package/dist/cli/background.js.map +2 -2
  7. package/dist/cli/control.js +18 -1
  8. package/dist/cli/control.js.map +2 -2
  9. package/dist/cli/daemon.js +15 -1
  10. package/dist/cli/daemon.js.map +2 -2
  11. package/dist/cli/main.js +6 -3
  12. package/dist/cli/main.js.map +2 -2
  13. package/dist/cli/service-restart.js +262 -0
  14. package/dist/cli/service-restart.js.map +7 -0
  15. package/dist/codex/adapter.js +68 -39
  16. package/dist/codex/adapter.js.map +2 -2
  17. package/dist/server/db/operations.js +6 -1
  18. package/dist/server/db/operations.js.map +2 -2
  19. package/dist/server/events.js +31 -15
  20. package/dist/server/events.js.map +2 -2
  21. package/dist/server/http.js +23 -2
  22. package/dist/server/http.js.map +2 -2
  23. package/dist/server/main.js +1 -0
  24. package/dist/server/main.js.map +2 -2
  25. package/dist/server/service.js +87 -18
  26. package/dist/server/service.js.map +2 -2
  27. package/dist/server/websocket.js +52 -21
  28. package/dist/server/websocket.js.map +2 -2
  29. package/dist/shared/service-restart.js +18 -0
  30. package/dist/shared/service-restart.js.map +7 -0
  31. package/dist/shared/thread-patch.js +7 -2
  32. package/dist/shared/thread-patch.js.map +2 -2
  33. package/dist/shared/validation.js +2 -1
  34. package/dist/shared/validation.js.map +2 -2
  35. package/dist/update-worker.cjs +257 -209
  36. package/dist/updates/manager.js +16 -6
  37. package/dist/updates/manager.js.map +2 -2
  38. package/dist/updates/service-restart.js +27 -0
  39. package/dist/updates/service-restart.js.map +7 -0
  40. package/dist/updates/transaction.js +30 -17
  41. package/dist/updates/transaction.js.map +2 -2
  42. package/dist/updates/worker.js +26 -34
  43. package/dist/updates/worker.js.map +2 -2
  44. package/dist/web/assets/{abnfDiagram-WEYOIA3C-DkoBYFgB.js → abnfDiagram-WEYOIA3C-DMR1ojSV.js} +1 -1
  45. package/dist/web/assets/{arc-D6xiz7Tx.js → arc-wV3pM9yZ.js} +1 -1
  46. package/dist/web/assets/{architecture-WOLXFQ4H-B222jK8a.js → architecture-WOLXFQ4H-CO1aIerG.js} +1 -1
  47. package/dist/web/assets/{architectureDiagram-ZHVYKT53-B_PRMrq2.js → architectureDiagram-ZHVYKT53-DSBK8xyg.js} +1 -1
  48. package/dist/web/assets/{blockDiagram-RJAE7QA3-BEXBHinK.js → blockDiagram-RJAE7QA3-8q5ceoaJ.js} +1 -1
  49. package/dist/web/assets/{c4Diagram-XDPPPE54-Cdle0CHL.js → c4Diagram-XDPPPE54-DA_LQQ49.js} +1 -1
  50. package/dist/web/assets/channel-CVldk7XH.js +1 -0
  51. package/dist/web/assets/{chunk-2E7WHVMD-CWoBX-us.js → chunk-2E7WHVMD-VtnckU7X.js} +1 -1
  52. package/dist/web/assets/{chunk-4EMNKR2T-CQOB2JO9.js → chunk-4EMNKR2T-DTKaH06l.js} +1 -1
  53. package/dist/web/assets/{chunk-55XCU76K--3bESPbB.js → chunk-55XCU76K-CQ_QWH1o.js} +1 -1
  54. package/dist/web/assets/{chunk-7S6XSTFO-C-_bgqD9.js → chunk-7S6XSTFO-C6VR0MrI.js} +1 -1
  55. package/dist/web/assets/{chunk-AQDTSKZB-CTlabJ1l.js → chunk-AQDTSKZB-BtlZ9yXF.js} +1 -1
  56. package/dist/web/assets/{chunk-DSNLSHJZ-CJaeSVhU.js → chunk-DSNLSHJZ-DW0o5V-T.js} +1 -1
  57. package/dist/web/assets/{chunk-HAGFOTED-zZa-8Kks.js → chunk-HAGFOTED-CzIr7eCr.js} +1 -1
  58. package/dist/web/assets/{chunk-HNE4Q36P-CkmR39os.js → chunk-HNE4Q36P-UeNhe-3X.js} +1 -1
  59. package/dist/web/assets/{chunk-NQOKRVIF-B_s_8Xw4.js → chunk-NQOKRVIF-CCe5IOsJ.js} +1 -1
  60. package/dist/web/assets/{chunk-UHW7PFBP-CltzAJ8a.js → chunk-UHW7PFBP-DbarrMyN.js} +1 -1
  61. package/dist/web/assets/{chunk-VQ5W62QI-BapAOp9h.js → chunk-VQ5W62QI-B0XuDbrJ.js} +1 -1
  62. package/dist/web/assets/{chunk-WQQL4CDK-Cd9VS_0s.js → chunk-WQQL4CDK-XgYp90_Z.js} +1 -1
  63. package/dist/web/assets/{chunk-XXDRQBXY-BPx8UIty.js → chunk-XXDRQBXY-VKZMwEnM.js} +1 -1
  64. package/dist/web/assets/{chunk-YZO67HFG-D42n-u1U.js → chunk-YZO67HFG-CDJ_RpGr.js} +1 -1
  65. package/dist/web/assets/{chunk-ZAUX2LTX-Bzgj3Xhx.js → chunk-ZAUX2LTX-wYlFXEp2.js} +1 -1
  66. package/dist/web/assets/{chunk-ZCHMQSOR-CheZXnv-.js → chunk-ZCHMQSOR-D1S-wIj8.js} +1 -1
  67. package/dist/web/assets/{classDiagram-v2-4MYWR3UA-Cr5OUMEf.js → classDiagram-v2-4MYWR3UA-BYM6I3gh.js} +1 -1
  68. package/dist/web/assets/{cose-bilkent-JH36ORCC-DOjVt0Sl.js → cose-bilkent-JH36ORCC-rEWARyux.js} +1 -1
  69. package/dist/web/assets/{cynefin-EF2NZ3EQ-BnOV8O_j.js → cynefin-EF2NZ3EQ-BDO_JnV6.js} +1 -1
  70. package/dist/web/assets/{cynefinDiagram-WF24UDRP-DEgEp6Wh.js → cynefinDiagram-WF24UDRP-UIu1XVv_.js} +1 -1
  71. package/dist/web/assets/{dagre-NK4GIZVX-CUg8AW-_.js → dagre-NK4GIZVX-hATkoggW.js} +1 -1
  72. package/dist/web/assets/{diagram-CBK3MWTC-s6XpyPnN.js → diagram-CBK3MWTC-DBr4FFFK.js} +1 -1
  73. package/dist/web/assets/{diagram-I5XIIV2D-7o0d7keQ.js → diagram-I5XIIV2D-iPE1IUrM.js} +1 -1
  74. package/dist/web/assets/{diagram-ODIL2UCW-eIhXL7RA.js → diagram-ODIL2UCW-BbjwhD5t.js} +1 -1
  75. package/dist/web/assets/{diagram-PFBEJUXE-BRBGsPra.js → diagram-PFBEJUXE-AWIlOyvA.js} +1 -1
  76. package/dist/web/assets/{diagram-RJA3I4VV-MQRQ4tsw.js → diagram-RJA3I4VV-6ltFUT1v.js} +1 -1
  77. package/dist/web/assets/{diagram-TYUNFSNR-BXw5xC6-.js → diagram-TYUNFSNR-CK5ctyQW.js} +1 -1
  78. package/dist/web/assets/{dist-DwsSr3Dg.js → dist-DJlPIIZ8.js} +1 -1
  79. package/dist/web/assets/{ebnfDiagram-V4P3TTPT-BD9Fg-dw.js → ebnfDiagram-V4P3TTPT-CXw5ZSx3.js} +1 -1
  80. package/dist/web/assets/{elk-QONTBCTQ-CyqlDbj0.js → elk-QONTBCTQ-D-fVvHhQ.js} +1 -1
  81. package/dist/web/assets/{erDiagram-KYQIGQAA-Dvez91ch.js → erDiagram-KYQIGQAA-AVAvisy5.js} +1 -1
  82. package/dist/web/assets/{eventmodeling-K75KTNOO-CyvY5QEt.js → eventmodeling-K75KTNOO-D9a_VpSY.js} +1 -1
  83. package/dist/web/assets/flowDiagram-IUGLLWBU-CKIlY0G2.js +1 -0
  84. package/dist/web/assets/{ganttDiagram-R7GPNTJY-Box2K2l7.js → ganttDiagram-R7GPNTJY-hHVlL1Eh.js} +1 -1
  85. package/dist/web/assets/{gitGraph-VSP46ZUC-aQq6qKlI.js → gitGraph-VSP46ZUC-DdgQti8v.js} +1 -1
  86. package/dist/web/assets/{gitGraphDiagram-PDYL7XHY-DBANLWAB.js → gitGraphDiagram-PDYL7XHY-DmJUrgq6.js} +1 -1
  87. package/dist/web/assets/index-BTrqcezH.js +166 -0
  88. package/dist/web/assets/index-MOYbbSyt.css +1 -0
  89. package/dist/web/assets/{info-OHQRW6UA-CvAiRKw0.js → info-OHQRW6UA-BJNiLoMT.js} +1 -1
  90. package/dist/web/assets/{infoDiagram-MVDRKAX5-CHBWRwPI.js → infoDiagram-MVDRKAX5-BRKti2aX.js} +1 -1
  91. package/dist/web/assets/{ishikawaDiagram-HPEHV2GE-DFyHCVUj.js → ishikawaDiagram-HPEHV2GE-FJUwWKmm.js} +1 -1
  92. package/dist/web/assets/{journeyDiagram-BOSHW7O7-BimlRYbv.js → journeyDiagram-BOSHW7O7-CkqcEO4t.js} +1 -1
  93. package/dist/web/assets/{kanban-definition-FNSA4HC5-CXvVhuee.js → kanban-definition-FNSA4HC5-Bf634kRD.js} +1 -1
  94. package/dist/web/assets/{line-DPVr8D8O.js → line-CyNQeMMF.js} +1 -1
  95. package/dist/web/assets/{linear-CcHoIPMF.js → linear-b30wqcMz.js} +1 -1
  96. package/dist/web/assets/{mermaid-parser.core-DHFoD8cR.js → mermaid-parser.core-I1Y8ZenR.js} +3 -3
  97. package/dist/web/assets/{mermaid.core-CVgPi04Z.js → mermaid.core-DyEsuDUM.js} +4 -4
  98. package/dist/web/assets/{mindmap-definition-6OY57UG3--Po862kR.js → mindmap-definition-6OY57UG3-C4mbyzfX.js} +1 -1
  99. package/dist/web/assets/{packet-JDAUHWVQ-CBoEHMEm.js → packet-JDAUHWVQ-Cyz-quE_.js} +1 -1
  100. package/dist/web/assets/{pegDiagram-ECIUJNBX-Bo-I3OO-.js → pegDiagram-ECIUJNBX-JWEpGB0F.js} +1 -1
  101. package/dist/web/assets/{pie-XZMESJXO-hShZUfG9.js → pie-XZMESJXO-CO3Ef7pf.js} +1 -1
  102. package/dist/web/assets/{pieDiagram-GNMPY74T-CKgXlP85.js → pieDiagram-GNMPY74T-Ce8GcQCK.js} +1 -1
  103. package/dist/web/assets/{quadrantDiagram-D57K4MC3-CL7tR8uc.js → quadrantDiagram-D57K4MC3-Nqnta5u6.js} +1 -1
  104. package/dist/web/assets/{radar-ABXABTNO-bvdBCrz0.js → radar-ABXABTNO-C00k6dDA.js} +1 -1
  105. package/dist/web/assets/{railroad-I3PHUGI6-lUxML02n.js → railroad-I3PHUGI6-DdCDigre.js} +1 -1
  106. package/dist/web/assets/{railroad-abnf-LNEFI6M7-Cf9Z-O_7.js → railroad-abnf-LNEFI6M7-xMw4T7WP.js} +1 -1
  107. package/dist/web/assets/{railroad-ebnf-DWYD2UWJ-CYkuaL_U.js → railroad-ebnf-DWYD2UWJ-Db_r4DuS.js} +1 -1
  108. package/dist/web/assets/{railroad-peg-JR7BVNR7-BJMcQ4gy.js → railroad-peg-JR7BVNR7-CUV_HU1F.js} +1 -1
  109. package/dist/web/assets/{railroadDiagram-Y72NRBL7-FEz2VrX9.js → railroadDiagram-Y72NRBL7-CaaNRw7b.js} +1 -1
  110. package/dist/web/assets/{requirementDiagram-EQYSW5RA-CWMVg-PW.js → requirementDiagram-EQYSW5RA-B1xVekKb.js} +1 -1
  111. package/dist/web/assets/{sankeyDiagram-SY24JHO5-BuMjSRsM.js → sankeyDiagram-SY24JHO5-DvQ1KufH.js} +1 -1
  112. package/dist/web/assets/{sequenceDiagram-BLEHNHQU-bHp4zb1V.js → sequenceDiagram-BLEHNHQU-Dzkz-0dd.js} +1 -1
  113. package/dist/web/assets/{src-DJgK_FQp.js → src-B8KMOlSk.js} +1 -1
  114. package/dist/web/assets/{stateDiagram-v2-A6IESKWZ-qDBXmIyr.js → stateDiagram-v2-A6IESKWZ-DAFgKOEQ.js} +1 -1
  115. package/dist/web/assets/{swimlanes-B3ENRKFQ-CV22zb6Q.js → swimlanes-B3ENRKFQ-BMMAb_g5.js} +1 -1
  116. package/dist/web/assets/swimlanesDiagram-AYQRV4AK-B-P9KeiY.js +8 -0
  117. package/dist/web/assets/{timeline-definition-JXYKGLGB-DSYiwwsP.js → timeline-definition-JXYKGLGB-BZOjsr7o.js} +1 -1
  118. package/dist/web/assets/{treeView-D4JQ5SDB-D3Q97Dl3.js → treeView-D4JQ5SDB-DMmR6Mxs.js} +1 -1
  119. package/dist/web/assets/{treemap-SAJKECNS-C23y8QJ-.js → treemap-SAJKECNS-Be7mtuT5.js} +1 -1
  120. package/dist/web/assets/{usecaseDiagram-WPOLBNNX-Od84xtH5.js → usecaseDiagram-WPOLBNNX-C_rBlmjr.js} +1 -1
  121. package/dist/web/assets/{vennDiagram-Q3Y3IDCW-CA8-fpuK.js → vennDiagram-Q3Y3IDCW-CVMEfmmD.js} +1 -1
  122. package/dist/web/assets/{wardley-7MLQ67FV-fldEz7q9.js → wardley-7MLQ67FV-CKeq2UM4.js} +1 -1
  123. package/dist/web/assets/{wardleyDiagram-IVAIDKWA-B95sV3gs.js → wardleyDiagram-IVAIDKWA-DCGUwYMW.js} +1 -1
  124. package/dist/web/assets/{xychartDiagram-4URNHDU4-Df_MPFNj.js → xychartDiagram-4URNHDU4-f4vCOcps.js} +1 -1
  125. package/dist/web/index.html +2 -2
  126. package/package.json +3 -3
  127. package/dist/web/assets/channel-Bj7s7cVd.js +0 -1
  128. package/dist/web/assets/flowDiagram-IUGLLWBU-CYOGg0f6.js +0 -1
  129. package/dist/web/assets/index-BJYWNZtB.js +0 -166
  130. package/dist/web/assets/index-CXOkSxnS.css +0 -1
  131. package/dist/web/assets/swimlanesDiagram-AYQRV4AK-Cjvz5LgK.js +0 -8
@@ -2045,7 +2045,7 @@ var require_thread_stream = __commonJS({
2045
2045
  var { version: version3 } = require_package();
2046
2046
  var { EventEmitter } = require("events");
2047
2047
  var { Worker: Worker2 } = require("worker_threads");
2048
- var { join: join15 } = require("path");
2048
+ var { join: join16 } = require("path");
2049
2049
  var { pathToFileURL } = require("url");
2050
2050
  var { wait } = require_wait();
2051
2051
  var {
@@ -2097,7 +2097,7 @@ var require_thread_stream = __commonJS({
2097
2097
  function createWorker(stream, opts) {
2098
2098
  const { filename, workerData } = opts;
2099
2099
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2100
- const toExecute = bundlerOverrides["thread-stream-worker"] || join15(__dirname, "lib", "worker.js");
2100
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join16(__dirname, "lib", "worker.js");
2101
2101
  const worker2 = new Worker2(toExecute, {
2102
2102
  ...opts.workerOpts,
2103
2103
  name: opts.workerOpts?.name || "thread-stream",
@@ -2610,7 +2610,7 @@ var require_transport = __commonJS({
2610
2610
  var { createRequire: createRequire2 } = require("module");
2611
2611
  var { existsSync } = require("node:fs");
2612
2612
  var getCallers = require_caller();
2613
- var { join: join15, isAbsolute: isAbsolute3, sep } = require("node:path");
2613
+ var { join: join16, isAbsolute: isAbsolute3, sep } = require("node:path");
2614
2614
  var { fileURLToPath } = require("node:url");
2615
2615
  var sleep = require_atomic_sleep();
2616
2616
  var onExit = require_on_exit_leak_free();
@@ -2765,7 +2765,7 @@ var require_transport = __commonJS({
2765
2765
  throw new Error("only one of target or targets can be specified");
2766
2766
  }
2767
2767
  if (targets) {
2768
- target = bundlerOverrides["pino-worker"] || join15(__dirname, "worker.js");
2768
+ target = bundlerOverrides["pino-worker"] || join16(__dirname, "worker.js");
2769
2769
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2770
2770
  return {
2771
2771
  ...dest,
@@ -2786,7 +2786,7 @@ var require_transport = __commonJS({
2786
2786
  const pipelinesHaveLevel = options.pipelines.some((p) => p.some((t) => t.level != null));
2787
2787
  usesMultistream = options.targets.length + options.pipelines.length > 1 || targetsHaveLevel || pipelinesHaveLevel;
2788
2788
  } else if (pipeline) {
2789
- target = bundlerOverrides["pino-worker"] || join15(__dirname, "worker.js");
2789
+ target = bundlerOverrides["pino-worker"] || join16(__dirname, "worker.js");
2790
2790
  options.pipelines = [pipeline.map((dest) => {
2791
2791
  return {
2792
2792
  ...dest,
@@ -2813,7 +2813,7 @@ var require_transport = __commonJS({
2813
2813
  return origin2;
2814
2814
  }
2815
2815
  if (origin2 === "pino/file") {
2816
- return join15(__dirname, "..", "file.js");
2816
+ return join16(__dirname, "..", "file.js");
2817
2817
  }
2818
2818
  let fixTarget2;
2819
2819
  for (const filePath of callers) {
@@ -3793,7 +3793,7 @@ var require_safe_stable_stringify = __commonJS({
3793
3793
  return circularValue;
3794
3794
  }
3795
3795
  let res = "";
3796
- let join15 = ",";
3796
+ let join16 = ",";
3797
3797
  const originalIndentation = indentation;
3798
3798
  if (Array.isArray(value)) {
3799
3799
  if (value.length === 0) {
@@ -3807,7 +3807,7 @@ var require_safe_stable_stringify = __commonJS({
3807
3807
  indentation += spacer;
3808
3808
  res += `
3809
3809
  ${indentation}`;
3810
- join15 = `,
3810
+ join16 = `,
3811
3811
  ${indentation}`;
3812
3812
  }
3813
3813
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3815,13 +3815,13 @@ ${indentation}`;
3815
3815
  for (; i < maximumValuesToStringify - 1; i++) {
3816
3816
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3817
3817
  res += tmp2 !== void 0 ? tmp2 : "null";
3818
- res += join15;
3818
+ res += join16;
3819
3819
  }
3820
3820
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3821
3821
  res += tmp !== void 0 ? tmp : "null";
3822
3822
  if (value.length - 1 > maximumBreadth) {
3823
3823
  const removedKeys = value.length - maximumBreadth - 1;
3824
- res += `${join15}"... ${getItemCount(removedKeys)} not stringified"`;
3824
+ res += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
3825
3825
  }
3826
3826
  if (spacer !== "") {
3827
3827
  res += `
@@ -3842,7 +3842,7 @@ ${originalIndentation}`;
3842
3842
  let separator = "";
3843
3843
  if (spacer !== "") {
3844
3844
  indentation += spacer;
3845
- join15 = `,
3845
+ join16 = `,
3846
3846
  ${indentation}`;
3847
3847
  whitespace = " ";
3848
3848
  }
@@ -3856,13 +3856,13 @@ ${indentation}`;
3856
3856
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
3857
3857
  if (tmp !== void 0) {
3858
3858
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3859
- separator = join15;
3859
+ separator = join16;
3860
3860
  }
3861
3861
  }
3862
3862
  if (keyLength > maximumBreadth) {
3863
3863
  const removedKeys = keyLength - maximumBreadth;
3864
3864
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3865
- separator = join15;
3865
+ separator = join16;
3866
3866
  }
3867
3867
  if (spacer !== "" && separator.length > 1) {
3868
3868
  res = `
@@ -3903,7 +3903,7 @@ ${originalIndentation}`;
3903
3903
  }
3904
3904
  const originalIndentation = indentation;
3905
3905
  let res = "";
3906
- let join15 = ",";
3906
+ let join16 = ",";
3907
3907
  if (Array.isArray(value)) {
3908
3908
  if (value.length === 0) {
3909
3909
  return "[]";
@@ -3916,7 +3916,7 @@ ${originalIndentation}`;
3916
3916
  indentation += spacer;
3917
3917
  res += `
3918
3918
  ${indentation}`;
3919
- join15 = `,
3919
+ join16 = `,
3920
3920
  ${indentation}`;
3921
3921
  }
3922
3922
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3924,13 +3924,13 @@ ${indentation}`;
3924
3924
  for (; i < maximumValuesToStringify - 1; i++) {
3925
3925
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3926
3926
  res += tmp2 !== void 0 ? tmp2 : "null";
3927
- res += join15;
3927
+ res += join16;
3928
3928
  }
3929
3929
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3930
3930
  res += tmp !== void 0 ? tmp : "null";
3931
3931
  if (value.length - 1 > maximumBreadth) {
3932
3932
  const removedKeys = value.length - maximumBreadth - 1;
3933
- res += `${join15}"... ${getItemCount(removedKeys)} not stringified"`;
3933
+ res += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
3934
3934
  }
3935
3935
  if (spacer !== "") {
3936
3936
  res += `
@@ -3943,7 +3943,7 @@ ${originalIndentation}`;
3943
3943
  let whitespace = "";
3944
3944
  if (spacer !== "") {
3945
3945
  indentation += spacer;
3946
- join15 = `,
3946
+ join16 = `,
3947
3947
  ${indentation}`;
3948
3948
  whitespace = " ";
3949
3949
  }
@@ -3952,7 +3952,7 @@ ${indentation}`;
3952
3952
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
3953
3953
  if (tmp !== void 0) {
3954
3954
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3955
- separator = join15;
3955
+ separator = join16;
3956
3956
  }
3957
3957
  }
3958
3958
  if (spacer !== "" && separator.length > 1) {
@@ -4010,20 +4010,20 @@ ${originalIndentation}`;
4010
4010
  indentation += spacer;
4011
4011
  let res2 = `
4012
4012
  ${indentation}`;
4013
- const join16 = `,
4013
+ const join17 = `,
4014
4014
  ${indentation}`;
4015
4015
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
4016
4016
  let i = 0;
4017
4017
  for (; i < maximumValuesToStringify - 1; i++) {
4018
4018
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4019
4019
  res2 += tmp2 !== void 0 ? tmp2 : "null";
4020
- res2 += join16;
4020
+ res2 += join17;
4021
4021
  }
4022
4022
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4023
4023
  res2 += tmp !== void 0 ? tmp : "null";
4024
4024
  if (value.length - 1 > maximumBreadth) {
4025
4025
  const removedKeys = value.length - maximumBreadth - 1;
4026
- res2 += `${join16}"... ${getItemCount(removedKeys)} not stringified"`;
4026
+ res2 += `${join17}"... ${getItemCount(removedKeys)} not stringified"`;
4027
4027
  }
4028
4028
  res2 += `
4029
4029
  ${originalIndentation}`;
@@ -4039,16 +4039,16 @@ ${originalIndentation}`;
4039
4039
  return '"[Object]"';
4040
4040
  }
4041
4041
  indentation += spacer;
4042
- const join15 = `,
4042
+ const join16 = `,
4043
4043
  ${indentation}`;
4044
4044
  let res = "";
4045
4045
  let separator = "";
4046
4046
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
4047
4047
  if (isTypedArrayWithEntries(value)) {
4048
- res += stringifyTypedArray(value, join15, maximumBreadth);
4048
+ res += stringifyTypedArray(value, join16, maximumBreadth);
4049
4049
  keys = keys.slice(value.length);
4050
4050
  maximumPropertiesToStringify -= value.length;
4051
- separator = join15;
4051
+ separator = join16;
4052
4052
  }
4053
4053
  if (deterministic) {
4054
4054
  keys = sort(keys, comparator);
@@ -4059,13 +4059,13 @@ ${indentation}`;
4059
4059
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
4060
4060
  if (tmp !== void 0) {
4061
4061
  res += `${separator}${strEscape(key2)}: ${tmp}`;
4062
- separator = join15;
4062
+ separator = join16;
4063
4063
  }
4064
4064
  }
4065
4065
  if (keyLength > maximumBreadth) {
4066
4066
  const removedKeys = keyLength - maximumBreadth;
4067
4067
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
4068
- separator = join15;
4068
+ separator = join16;
4069
4069
  }
4070
4070
  if (separator !== "") {
4071
4071
  res = `
@@ -15887,7 +15887,7 @@ var require_utils2 = __commonJS({
15887
15887
  "use strict";
15888
15888
  var { readdir: readdir4, stat, unlink: unlink3, symlink, lstat: lstat5, readlink } = require("fs/promises");
15889
15889
  var { symlinkSync, unlinkSync, lstatSync, readlinkSync } = require("fs");
15890
- var { dirname: dirname8, join: join15 } = require("path");
15890
+ var { dirname: dirname8, join: join16 } = require("path");
15891
15891
  var { format, addDays, addHours, parse: parse3, isValid } = require_date_fns();
15892
15892
  var { promisify: promisify8 } = require("util");
15893
15893
  var sleep = promisify8(setTimeout);
@@ -16016,7 +16016,7 @@ var require_utils2 = __commonJS({
16016
16016
  async function readFileTrailingNumbers(folder, time3, fileExtension) {
16017
16017
  const numbers2 = [1];
16018
16018
  for (const file2 of await readdir4(folder)) {
16019
- if (time3 && !await isMatchingTime(join15(folder, file2), time3)) {
16019
+ if (time3 && !await isMatchingTime(join16(folder, file2), time3)) {
16020
16020
  continue;
16021
16021
  }
16022
16022
  const number4 = extractTrailingNumber(file2, fileExtension);
@@ -16070,7 +16070,7 @@ var require_utils2 = __commonJS({
16070
16070
  let files = [];
16071
16071
  const pathSegments = getFileName(baseFile).split(/(\\|\/)/g);
16072
16072
  const baseFileNameStr = pathSegments.pop();
16073
- for (const fileEntry of await readdir4(join15(...pathSegments))) {
16073
+ for (const fileEntry of await readdir4(join16(...pathSegments))) {
16074
16074
  const f = identifyLogFile(fileEntry, baseFileNameStr, dateFormat, extension);
16075
16075
  if (f) {
16076
16076
  files.push(f);
@@ -16085,7 +16085,7 @@ var require_utils2 = __commonJS({
16085
16085
  if (files.length > count) {
16086
16086
  const filesToRemove = files.slice(0, files.length - count);
16087
16087
  await Promise.allSettled(
16088
- filesToRemove.map((file2) => unlinkWithRetry(join15(...pathSegments, file2.fileName)))
16088
+ filesToRemove.map((file2) => unlinkWithRetry(join16(...pathSegments, file2.fileName)))
16089
16089
  );
16090
16090
  }
16091
16091
  }
@@ -16102,7 +16102,7 @@ var require_utils2 = __commonJS({
16102
16102
  return true;
16103
16103
  }
16104
16104
  async function createSymlink(fileVal) {
16105
- const linkPath = join15(dirname8(fileVal), "current.log");
16105
+ const linkPath = join16(dirname8(fileVal), "current.log");
16106
16106
  const shouldCreateSymlink = await checkSymlink(fileVal, linkPath);
16107
16107
  if (shouldCreateSymlink) {
16108
16108
  await symlink(extractFileName(fileVal), linkPath);
@@ -16128,7 +16128,7 @@ var require_utils2 = __commonJS({
16128
16128
  }
16129
16129
  }
16130
16130
  function createSymlinkSync(fileVal) {
16131
- const linkPath = join15(dirname8(fileVal), "current.log");
16131
+ const linkPath = join16(dirname8(fileVal), "current.log");
16132
16132
  const shouldCreateSymlink = checkSymlinkSync(fileVal, linkPath);
16133
16133
  if (shouldCreateSymlink) {
16134
16134
  symlinkSync(extractFileName(fileVal), linkPath);
@@ -38739,13 +38739,14 @@ function requireCodexCompatibility(metadata, running, confirmed = false, basis =
38739
38739
  var import_node_child_process7 = require("node:child_process");
38740
38740
  var import_node_util7 = require("node:util");
38741
38741
  var import_node_module = require("node:module");
38742
- var import_promises18 = require("node:fs/promises");
38742
+ var import_promises19 = require("node:fs/promises");
38743
38743
  var import_node_fs6 = require("node:fs");
38744
- var import_node_path16 = require("node:path");
38745
- var import_promises19 = require("node:timers/promises");
38744
+ var import_node_path17 = require("node:path");
38745
+ var import_promises20 = require("node:timers/promises");
38746
38746
  var import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
38747
38747
 
38748
38748
  // src/cli/control.ts
38749
+ var import_node_path8 = require("node:path");
38749
38750
  var import_node_http = require("node:http");
38750
38751
  var import_proper_lockfile5 = __toESM(require_proper_lockfile(), 1);
38751
38752
  var import_promises7 = require("node:timers/promises");
@@ -38793,7 +38794,19 @@ function control(location, action, input2 = {}) {
38793
38794
  function isNotRunning(error62) {
38794
38795
  return ["ENOENT", "ECONNREFUSED"].includes(error62.code ?? "");
38795
38796
  }
38797
+ var restartFile = (location) => (0, import_node_path8.join)(location.state, "restart.json");
38798
+ async function lastServiceRestart(location) {
38799
+ return (await readJson(restartFile(location)))?.run;
38800
+ }
38801
+ async function waitForRestartHandoff(location) {
38802
+ for (; ; ) {
38803
+ const run = await lastServiceRestart(location);
38804
+ if (run?.phase !== "restarting" || (run.recoveryDeadline ?? 0) <= Date.now()) return;
38805
+ await (0, import_promises7.setTimeout)(250);
38806
+ }
38807
+ }
38796
38808
  async function stopAndWait(location) {
38809
+ await waitForRestartHandoff(location);
38797
38810
  try {
38798
38811
  await control(location, "stop");
38799
38812
  } catch (error62) {
@@ -38814,7 +38827,7 @@ async function stopAndWait(location) {
38814
38827
  // src/cli/background.ts
38815
38828
  var import_node_child_process3 = require("node:child_process");
38816
38829
  var import_promises11 = require("node:fs/promises");
38817
- var import_node_path11 = require("node:path");
38830
+ var import_node_path12 = require("node:path");
38818
38831
  var import_node_util3 = require("node:util");
38819
38832
  var import_promises12 = require("node:timers/promises");
38820
38833
  var import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
@@ -38824,16 +38837,16 @@ var import_node_child_process = require("node:child_process");
38824
38837
  var import_node_util = require("node:util");
38825
38838
  var import_node_crypto6 = require("node:crypto");
38826
38839
  var import_node_os = require("node:os");
38827
- var import_node_path9 = require("node:path");
38840
+ var import_node_path10 = require("node:path");
38828
38841
  var import_promises9 = require("node:fs/promises");
38829
38842
 
38830
38843
  // src/cli/launch-environment.ts
38831
38844
  var import_node_net = require("node:net");
38832
38845
  var import_promises8 = require("node:fs/promises");
38833
38846
  var import_node_crypto5 = require("node:crypto");
38834
- var import_node_path8 = require("node:path");
38847
+ var import_node_path9 = require("node:path");
38835
38848
  async function environmentBridge(home, runtimePath = process.env.PATH) {
38836
- const path = (0, import_node_path8.join)(home, `e-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}.sock`);
38849
+ const path = (0, import_node_path9.join)(home, `e-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}.sock`);
38837
38850
  const clients = /* @__PURE__ */ new Set();
38838
38851
  let accept;
38839
38852
  const consumed = new Promise((resolve4) => {
@@ -38930,8 +38943,8 @@ function launchdPaths(location, label = `dev.covro.${location.key}.${(0, import_
38930
38943
  label,
38931
38944
  domain: domain2,
38932
38945
  target: `${domain2}/${label}`,
38933
- temporary: (0, import_node_path9.join)(location.state, "launchd.plist"),
38934
- login: (0, import_node_path9.join)((0, import_node_os.homedir)(), "Library/LaunchAgents", `${label}.plist`)
38946
+ temporary: (0, import_node_path10.join)(location.state, "launchd.plist"),
38947
+ login: (0, import_node_path10.join)((0, import_node_os.homedir)(), "Library/LaunchAgents", `${label}.plist`)
38935
38948
  };
38936
38949
  }
38937
38950
  async function loaded(target) {
@@ -38952,7 +38965,7 @@ async function guiSessionAvailable(location) {
38952
38965
  }
38953
38966
  async function loginRegistration(location) {
38954
38967
  const installed = await readJson(
38955
- (0, import_node_path9.join)(location.state, "service.json")
38968
+ (0, import_node_path10.join)(location.state, "service.json")
38956
38969
  );
38957
38970
  if (installed?.platform !== "darwin") return void 0;
38958
38971
  if (installed.label !== launchdPaths(location).label && installed.label !== `dev.covro.${location.key}`)
@@ -39013,7 +39026,7 @@ async function startLaunchd(location, entry, runtime) {
39013
39026
  }
39014
39027
  const bridge = await environmentBridge(location.home, runtime?.path);
39015
39028
  try {
39016
- const runner = (0, import_node_path9.join)(location.state, "launch-runner.mjs");
39029
+ const runner = (0, import_node_path10.join)(location.state, "launch-runner.mjs");
39017
39030
  await (0, import_promises9.writeFile)(runner, launchRunner, { mode: 384 });
39018
39031
  await (0, import_promises9.writeFile)(
39019
39032
  temporary,
@@ -39050,10 +39063,10 @@ var import_node_child_process2 = require("node:child_process");
39050
39063
  var import_node_util2 = require("node:util");
39051
39064
  var import_promises10 = require("node:fs/promises");
39052
39065
  var import_node_os2 = require("node:os");
39053
- var import_node_path10 = require("node:path");
39066
+ var import_node_path11 = require("node:path");
39054
39067
  var exec2 = (0, import_node_util2.promisify)(import_node_child_process2.execFile);
39055
39068
  var schema = external_exports.object({ node: external_exports.string().startsWith("/"), entry: external_exports.string().startsWith("/"), path: external_exports.string() }).strict();
39056
- var runtimeFile = (location) => (0, import_node_path10.join)(location.state, "runtime.json");
39069
+ var runtimeFile = (location) => (0, import_node_path11.join)(location.state, "runtime.json");
39057
39070
  async function launchRuntime(location, entry, override) {
39058
39071
  const saved = override ?? await readJson(runtimeFile(location));
39059
39072
  return saved ? schema.parse(saved) : { node: process.execPath, entry, path: process.env.PATH ?? "/usr/bin:/bin" };
@@ -39074,7 +39087,7 @@ function serviceContent(location, runtime, service) {
39074
39087
  async function snapshotLaunch(location, current) {
39075
39088
  const runtime = await readJson(runtimeFile(location));
39076
39089
  const installed = await readJson(
39077
- (0, import_node_path10.join)(location.state, "service.json")
39090
+ (0, import_node_path11.join)(location.state, "service.json")
39078
39091
  );
39079
39092
  if (!installed) {
39080
39093
  if (process.env.INVOCATION_ID || process.env.PM2_HOME || process.env.SUPERVISOR_ENABLED)
@@ -39083,7 +39096,7 @@ async function snapshotLaunch(location, current) {
39083
39096
  }
39084
39097
  if (installed.platform !== process.platform || installed.label !== `dev.covro.${location.key}`)
39085
39098
  throw new Error("\u767B\u5F55\u670D\u52A1\u8EAB\u4EFD\u4E0D\u5339\u914D\uFF1B\u8BF7\u7528\u76EE\u6807 Node \u91CD\u65B0\u5B89\u88C5 Covro \u767B\u5F55\u670D\u52A1\u3002");
39086
- const filename = installed.platform === "darwin" ? launchdPaths(location, installed.label).login : (0, import_node_path10.join)((0, import_node_os2.homedir)(), ".config/systemd/user", `${installed.label}.service`);
39099
+ const filename = installed.platform === "darwin" ? launchdPaths(location, installed.label).login : (0, import_node_path11.join)((0, import_node_os2.homedir)(), ".config/systemd/user", `${installed.label}.service`);
39087
39100
  const content = await (0, import_promises10.readFile)(filename, "utf8");
39088
39101
  const expected = installed.platform === "darwin" ? `<key>ProgramArguments</key><array>${[current.node, current.entry, "run", "--config", location.config].map((arg) => `<string>${xml2(arg)}</string>`).join("")}</array>` : `ExecStart=${[current.node, current.entry, "run", "--config", location.config].map(systemdQuote).join(" ")}`;
39089
39102
  if (!content.includes(expected))
@@ -39145,15 +39158,20 @@ async function restoreLaunch(location, snapshot) {
39145
39158
 
39146
39159
  // src/cli/background.ts
39147
39160
  var exec3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
39148
- async function lifecycle(location, action) {
39161
+ async function acquireLifecycle(location, wait = true) {
39149
39162
  await (0, import_promises11.mkdir)(location.state, { recursive: true, mode: 448 });
39150
- const release = await import_proper_lockfile6.default.lock(location.state, {
39151
- lockfilePath: (0, import_node_path11.join)(location.state, "lifecycle.lock"),
39163
+ return import_proper_lockfile6.default.lock((0, import_node_path12.join)(location.state, "lifecycle"), {
39164
+ realpath: false,
39165
+ lockfilePath: (0, import_node_path12.join)(location.state, "lifecycle.lock"),
39152
39166
  stale: 1e4,
39153
39167
  update: 2e3,
39154
- retries: { retries: 280, minTimeout: 250, maxTimeout: 250 }
39168
+ retries: wait ? { retries: 280, minTimeout: 250, maxTimeout: 250 } : 0
39155
39169
  });
39170
+ }
39171
+ async function lifecycle(location, action) {
39172
+ const release = await acquireLifecycle(location);
39156
39173
  try {
39174
+ await waitForRestartHandoff(location);
39157
39175
  return await action();
39158
39176
  } finally {
39159
39177
  await release();
@@ -39168,7 +39186,7 @@ async function start(location, entry, override) {
39168
39186
  let child;
39169
39187
  const runtime = await launchRuntime(location, entry, override);
39170
39188
  const installed = await readJson(
39171
- (0, import_node_path11.join)(location.state, "service.json")
39189
+ (0, import_node_path12.join)(location.state, "service.json")
39172
39190
  );
39173
39191
  if (process.platform === "darwin" && await startLaunchd(location, runtime.entry, runtime)) {
39174
39192
  } else if (installed?.platform === "linux") {
@@ -39211,7 +39229,7 @@ async function stop(location) {
39211
39229
  if (process.platform === "darwin") await unloadLaunchd(location);
39212
39230
  else {
39213
39231
  const installed = await readJson(
39214
- (0, import_node_path11.join)(location.state, "service.json")
39232
+ (0, import_node_path12.join)(location.state, "service.json")
39215
39233
  );
39216
39234
  if (installed?.platform === "linux")
39217
39235
  await exec3("systemctl", ["--user", "stop", `${installed.label}.service`]);
@@ -39223,7 +39241,7 @@ var stopBackground = (location) => lifecycle(location, () => stop(location));
39223
39241
  // src/updates/registry.ts
39224
39242
  var import_promises13 = require("node:fs/promises");
39225
39243
  var import_node_fs4 = require("node:fs");
39226
- var import_node_path12 = require("node:path");
39244
+ var import_node_path13 = require("node:path");
39227
39245
  var registry2 = "https://registry.npmjs.org";
39228
39246
  var releaseSchema = external_exports.object({
39229
39247
  name: external_exports.literal(npmPackageName),
@@ -39234,10 +39252,10 @@ var releaseSchema = external_exports.object({
39234
39252
  });
39235
39253
  async function inspectInstallation(root) {
39236
39254
  try {
39237
- const globalRoot = (0, import_node_path12.dirname)((0, import_node_path12.dirname)((0, import_node_path12.resolve)(root)));
39255
+ const globalRoot = (0, import_node_path13.dirname)((0, import_node_path13.dirname)((0, import_node_path13.resolve)(root)));
39238
39256
  if (!globalRoot.endsWith("/lib/node_modules"))
39239
39257
  return "\u5F53\u524D\u4E3A\u975E npm \u5168\u5C40\u5B89\u88C5\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
39240
- if (await (0, import_promises13.realpath)((0, import_node_path12.join)((0, import_node_path12.dirname)((0, import_node_path12.dirname)(globalRoot)), "bin/covro")) !== (0, import_node_path12.join)((0, import_node_path12.resolve)(root), "bin/covro.mjs"))
39258
+ if (await (0, import_promises13.realpath)((0, import_node_path13.join)((0, import_node_path13.dirname)((0, import_node_path13.dirname)(globalRoot)), "bin/covro")) !== (0, import_node_path13.join)((0, import_node_path13.resolve)(root), "bin/covro.mjs"))
39241
39259
  return "\u5F53\u524D Covro \u5165\u53E3\u4E0E npm \u5168\u5C40\u5B89\u88C5\u6765\u6E90\u4E0D\u5339\u914D\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
39242
39260
  return await inspectPackageDirectory(root, globalRoot);
39243
39261
  } catch {
@@ -39245,11 +39263,11 @@ async function inspectInstallation(root) {
39245
39263
  }
39246
39264
  }
39247
39265
  async function inspectPackageDirectory(root, globalRoot) {
39248
- const expected = (0, import_node_path12.join)(await (0, import_promises13.realpath)(globalRoot), npmPackageName);
39266
+ const expected = (0, import_node_path13.join)(await (0, import_promises13.realpath)(globalRoot), npmPackageName);
39249
39267
  if ((await (0, import_promises13.lstat)(expected)).isSymbolicLink() || await (0, import_promises13.realpath)(root) !== expected)
39250
39268
  return "\u5F53\u524D\u4E3A\u6E90\u7801\u3001\u94FE\u63A5\u6216\u975E npm \u5168\u5C40\u5B89\u88C5\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
39251
39269
  try {
39252
- await (0, import_promises13.lstat)((0, import_node_path12.join)(expected, ".git"));
39270
+ await (0, import_promises13.lstat)((0, import_node_path13.join)(expected, ".git"));
39253
39271
  return "\u5F53\u524D\u5B89\u88C5\u5305\u542B Git \u5DE5\u4F5C\u533A\uFF1B\u8BF7\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u3002";
39254
39272
  } catch (error62) {
39255
39273
  if (error62.code !== "ENOENT") throw error62;
@@ -39315,8 +39333,34 @@ async function confirmAutomaticFreeze(id, freeze, readRun) {
39315
39333
  }
39316
39334
 
39317
39335
  // src/updates/transaction.ts
39318
- var import_promises14 = require("node:fs/promises");
39319
- var import_node_path13 = require("node:path");
39336
+ var import_promises15 = require("node:fs/promises");
39337
+ var import_node_path14 = require("node:path");
39338
+
39339
+ // src/updates/service-restart.ts
39340
+ var import_promises14 = require("node:timers/promises");
39341
+ async function waitFor(probe2, { interval, signal, deadline = Infinity, timeout }) {
39342
+ for (; ; ) {
39343
+ signal?.throwIfAborted();
39344
+ const remaining = deadline - Date.now();
39345
+ if (remaining <= 0) throw timeout?.() ?? new Error("Covro service readiness timed out");
39346
+ const ready = await probe2();
39347
+ signal?.throwIfAborted();
39348
+ if (ready) return;
39349
+ await (0, import_promises14.setTimeout)(Math.min(interval, remaining), void 0, { signal });
39350
+ }
39351
+ }
39352
+ async function restartService(effects, wait) {
39353
+ await waitFor(effects.prepare, wait);
39354
+ await effects.stop();
39355
+ await effects.start();
39356
+ await effects.confirm?.();
39357
+ }
39358
+ async function confirmRestart(probe2, record2, wait) {
39359
+ await waitFor(probe2, wait);
39360
+ await record2();
39361
+ }
39362
+
39363
+ // src/updates/transaction.ts
39320
39364
  async function activateUpdate(paths, effects, reuseTarget = false) {
39321
39365
  let stopped = false;
39322
39366
  let moved = false;
@@ -39324,23 +39368,35 @@ async function activateUpdate(paths, effects, reuseTarget = false) {
39324
39368
  let committed = false;
39325
39369
  try {
39326
39370
  await effects.phase("waiting", "\u5019\u9009\u5305\u5DF2\u51C6\u5907\u597D\uFF0C\u7B49\u5F85\u6240\u6709\u4EFB\u52A1\u3001\u5BA1\u6279\u4E0E\u5F85\u6838\u5BF9\u64CD\u4F5C\u7ED3\u675F");
39327
- await effects.waitForIdle();
39328
- await effects.beforeStop?.();
39329
- await effects.phase("stopping", "\u5DF2\u5173\u95ED\u65B0\u4EFB\u52A1\u5165\u53E3\uFF0C\u6B63\u5728\u505C\u6B62\u65E7\u670D\u52A1\u5E76\u5907\u4EFD\u6570\u636E");
39330
- stopped = true;
39331
- await effects.stop();
39332
- await effects.backup();
39333
- backedUp = true;
39334
- if (!reuseTarget) {
39335
- await (0, import_promises14.rename)(paths.root, paths.previous);
39336
- moved = true;
39337
- await (0, import_promises14.rename)(paths.candidate, paths.root);
39338
- }
39339
- await effects.switchLaunch?.();
39340
- await effects.phase("verifying", "\u6B63\u5728\u542F\u52A8\u65B0\u7248\u3001\u8FC1\u79FB\u6570\u636E\u5E93\u5E76\u9A8C\u8BC1\uFF1B\u4E1A\u52A1\u5199\u5165\u4FDD\u6301\u6682\u505C");
39341
- await effects.start(true);
39342
- await effects.verify();
39343
- await effects.commit();
39371
+ await restartService(
39372
+ {
39373
+ prepare: effects.prepare,
39374
+ stop: async () => {
39375
+ await effects.beforeStop?.();
39376
+ await effects.phase("stopping", "\u5DF2\u5173\u95ED\u65B0\u4EFB\u52A1\u5165\u53E3\uFF0C\u6B63\u5728\u505C\u6B62\u65E7\u670D\u52A1\u5E76\u5907\u4EFD\u6570\u636E");
39377
+ stopped = true;
39378
+ await effects.stop();
39379
+ },
39380
+ start: async () => {
39381
+ await effects.backup();
39382
+ backedUp = true;
39383
+ if (!reuseTarget) {
39384
+ await (0, import_promises15.rename)(paths.root, paths.previous);
39385
+ moved = true;
39386
+ await (0, import_promises15.rename)(paths.candidate, paths.root);
39387
+ }
39388
+ await effects.switchLaunch?.();
39389
+ await effects.phase("verifying", "\u6B63\u5728\u542F\u52A8\u65B0\u7248\u3001\u8FC1\u79FB\u6570\u636E\u5E93\u5E76\u9A8C\u8BC1\uFF1B\u4E1A\u52A1\u5199\u5165\u4FDD\u6301\u6682\u505C");
39390
+ await effects.start(true);
39391
+ },
39392
+ confirm: () => confirmRestart(effects.verify, effects.commit, {
39393
+ interval: 250,
39394
+ deadline: Date.now() + 6e4,
39395
+ timeout: () => new Error("\u65B0\u7248\u670D\u52A1\u6216 Codex \u8FDE\u63A5\u672A\u5C31\u7EEA\uFF0C\u62D2\u7EDD\u6FC0\u6D3B")
39396
+ })
39397
+ },
39398
+ { interval: 2e3 }
39399
+ );
39344
39400
  committed = true;
39345
39401
  return;
39346
39402
  } catch (error62) {
@@ -39353,8 +39409,8 @@ async function activateUpdate(paths, effects, reuseTarget = false) {
39353
39409
  try {
39354
39410
  await effects.stop();
39355
39411
  if (moved) {
39356
- await (0, import_promises14.rm)(paths.root, { recursive: true, force: true });
39357
- await (0, import_promises14.rename)(paths.previous, paths.root);
39412
+ await (0, import_promises15.rm)(paths.root, { recursive: true, force: true });
39413
+ await (0, import_promises15.rename)(paths.previous, paths.root);
39358
39414
  }
39359
39415
  if (backedUp) await effects.restore();
39360
39416
  await effects.restoreLaunch?.();
@@ -39374,16 +39430,16 @@ async function activateUpdate(paths, effects, reuseTarget = false) {
39374
39430
  }
39375
39431
  }
39376
39432
  function transactionPaths(root, id, dataDir, config2, backup) {
39377
- const prefix = (0, import_node_path13.join)((0, import_node_path13.dirname)(root), `.covro-stage-${id}`);
39433
+ const prefix = (0, import_node_path14.join)((0, import_node_path14.dirname)(root), `.covro-stage-${id}`);
39378
39434
  return {
39379
39435
  root,
39380
39436
  prefix,
39381
- candidate: (0, import_node_path13.join)(
39437
+ candidate: (0, import_node_path14.join)(
39382
39438
  prefix,
39383
39439
  process.platform === "win32" ? "node_modules" : "lib/node_modules",
39384
39440
  npmPackageName
39385
39441
  ),
39386
- previous: (0, import_node_path13.join)((0, import_node_path13.dirname)(root), `.covro-previous-${id}`),
39442
+ previous: (0, import_node_path14.join)((0, import_node_path14.dirname)(root), `.covro-previous-${id}`),
39387
39443
  backup,
39388
39444
  dataDir,
39389
39445
  config: config2
@@ -39394,9 +39450,9 @@ function transactionPaths(root, id, dataDir, config2, backup) {
39394
39450
  var import_node_child_process4 = require("node:child_process");
39395
39451
  var import_node_util4 = require("node:util");
39396
39452
  var import_node_os3 = require("node:os");
39397
- var import_promises15 = require("node:fs/promises");
39453
+ var import_promises16 = require("node:fs/promises");
39398
39454
  var import_node_fs5 = require("node:fs");
39399
- var import_node_path14 = require("node:path");
39455
+ var import_node_path15 = require("node:path");
39400
39456
  var exec4 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
39401
39457
  function assertRuntime(actual, expected) {
39402
39458
  if (!actual || actual.node !== expected.node || actual.nodeVersion !== expected.nodeVersion || actual.root !== expected.root || actual.entry !== expected.entry)
@@ -39437,18 +39493,18 @@ function targetNpmEnvironment(path, config2 = {}) {
39437
39493
  var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
39438
39494
  async function defaultNodeEnvironment() {
39439
39495
  const shell = (0, import_node_os3.userInfo)().shell;
39440
- if (!shell || !["bash", "zsh", "sh", "dash", "fish"].includes((0, import_node_path14.basename)(shell)))
39496
+ if (!shell || !["bash", "zsh", "sh", "dash", "fish"].includes((0, import_node_path15.basename)(shell)))
39441
39497
  throw new Error(
39442
39498
  "\u65E0\u6CD5\u8BC6\u522B\u9ED8\u8BA4\u767B\u5F55 shell\uFF1B\u8BF7\u5728\u76EE\u6807 Node \u7684\u7EC8\u7AEF\u4F7F\u7528\u539F\u90E8\u7F72\u65B9\u5F0F\u66F4\u65B0\u5E76\u91CD\u65B0\u5B89\u88C5\u767B\u5F55\u670D\u52A1\u3002"
39443
39499
  );
39444
- const oldBin = (0, import_node_path14.dirname)(process.execPath);
39445
- const path = (process.env.PATH ?? "").split(import_node_path14.delimiter).filter(
39500
+ const oldBin = (0, import_node_path15.dirname)(process.execPath);
39501
+ const path = (process.env.PATH ?? "").split(import_node_path15.delimiter).filter(
39446
39502
  (part) => part && part !== oldBin && !/fnm_multishells|\/node-versions\/|\/\.nvm\/versions\/node\//.test(part)
39447
39503
  );
39448
39504
  const env = {
39449
39505
  ...process.env,
39450
39506
  PATH: [.../* @__PURE__ */ new Set([...path, "/usr/local/bin", "/opt/homebrew/bin", "/usr/bin", "/bin"])].join(
39451
- import_node_path14.delimiter
39507
+ import_node_path15.delimiter
39452
39508
  )
39453
39509
  };
39454
39510
  for (const key of ["FNM_MULTISHELL_PATH", "NVM_BIN", "NVM_INC", "NODE_OPTIONS", "NODE_PATH"])
@@ -39469,12 +39525,12 @@ async function defaultNodeEnvironment() {
39469
39525
  return probeSchema.parse(JSON.parse(lines[0].slice(marker.length)));
39470
39526
  }
39471
39527
  async function executable(name, path) {
39472
- for (const directory of path.split(import_node_path14.delimiter)) {
39473
- if (!(0, import_node_path14.isAbsolute)(directory)) continue;
39474
- const filename = (0, import_node_path14.join)(directory, name);
39528
+ for (const directory of path.split(import_node_path15.delimiter)) {
39529
+ if (!(0, import_node_path15.isAbsolute)(directory)) continue;
39530
+ const filename = (0, import_node_path15.join)(directory, name);
39475
39531
  try {
39476
- await (0, import_promises15.access)(filename, import_node_fs5.constants.X_OK);
39477
- return await (0, import_promises15.realpath)(filename);
39532
+ await (0, import_promises16.access)(filename, import_node_fs5.constants.X_OK);
39533
+ return await (0, import_promises16.realpath)(filename);
39478
39534
  } catch (error62) {
39479
39535
  if (!["ENOENT", "EACCES", "ENOTDIR"].includes(error62.code ?? ""))
39480
39536
  throw error62;
@@ -39486,8 +39542,8 @@ async function executable(name, path) {
39486
39542
  }
39487
39543
  async function resolveRuntimeTarget(environment = defaultNodeEnvironment) {
39488
39544
  const found = await environment();
39489
- const node2 = await (0, import_promises15.realpath)(found.node);
39490
- await (0, import_promises15.access)(node2, import_node_fs5.constants.X_OK);
39545
+ const node2 = await (0, import_promises16.realpath)(found.node);
39546
+ await (0, import_promises16.access)(node2, import_node_fs5.constants.X_OK);
39491
39547
  const { stdout } = await exec4(node2, ["-p", "process.versions.node"], {
39492
39548
  env: targetNpmEnvironment(found.path, found.npmConfig),
39493
39549
  timeout: 15e3
@@ -39498,19 +39554,19 @@ async function resolveRuntimeTarget(environment = defaultNodeEnvironment) {
39498
39554
  `\u76EE\u6807 Node ${nodeVersion} \u4E0D\u53D7\u652F\u6301\uFF1B\u9700\u8981 >=24.19.0 <25\uFF0C\u8BF7\u8C03\u6574\u9ED8\u8BA4 Node \u540E\u91CD\u8BD5\u3002`
39499
39555
  );
39500
39556
  const npm = await executable("npm", found.path);
39501
- if (await (0, import_promises15.realpath)((0, import_node_path14.join)((0, import_node_path14.dirname)(node2), "npm")).catch(() => void 0) !== npm)
39557
+ if (await (0, import_promises16.realpath)((0, import_node_path15.join)((0, import_node_path15.dirname)(node2), "npm")).catch(() => void 0) !== npm)
39502
39558
  throw new Error("\u9ED8\u8BA4 Node \u548C npm \u6765\u81EA\u4E0D\u540C\u5B89\u88C5\uFF1B\u8BF7\u4FEE\u590D\u767B\u5F55 shell \u7684 PATH \u540E\u91CD\u65B0\u68C0\u67E5\u3002");
39503
- const npmInfo = JSON.parse(await (0, import_promises15.readFile)((0, import_node_path14.join)((0, import_node_path14.dirname)(npm), "../package.json"), "utf8"));
39504
- if ((0, import_node_path14.basename)(npm) !== "npm-cli.js" || npmInfo.name !== "npm")
39559
+ const npmInfo = JSON.parse(await (0, import_promises16.readFile)((0, import_node_path15.join)((0, import_node_path15.dirname)(npm), "../package.json"), "utf8"));
39560
+ if ((0, import_node_path15.basename)(npm) !== "npm-cli.js" || npmInfo.name !== "npm")
39505
39561
  throw new Error(
39506
39562
  "\u76EE\u6807 npm \u662F\u65E0\u6CD5\u786E\u8BA4\u7684 shim\uFF1B\u8BF7\u8BA9\u767B\u5F55 shell \u7684 PATH \u6307\u5411\u76EE\u6807 Node \u81EA\u5E26\u7684 npm \u540E\u91CD\u8BD5\u3002"
39507
39563
  );
39508
39564
  const directories = await Promise.all(
39509
- found.path.split(import_node_path14.delimiter).filter(import_node_path14.isAbsolute).map((part) => (0, import_promises15.realpath)(part).catch(() => void 0))
39565
+ found.path.split(import_node_path15.delimiter).filter(import_node_path15.isAbsolute).map((part) => (0, import_promises16.realpath)(part).catch(() => void 0))
39510
39566
  );
39511
39567
  const path = [
39512
- .../* @__PURE__ */ new Set([(0, import_node_path14.dirname)(node2), ...directories.filter((part) => Boolean(part))])
39513
- ].join(import_node_path14.delimiter);
39568
+ .../* @__PURE__ */ new Set([(0, import_node_path15.dirname)(node2), ...directories.filter((part) => Boolean(part))])
39569
+ ].join(import_node_path15.delimiter);
39514
39570
  const options = {
39515
39571
  env: targetNpmEnvironment(path, found.npmConfig),
39516
39572
  cwd: (0, import_node_os3.homedir)(),
@@ -39521,21 +39577,21 @@ async function resolveRuntimeTarget(environment = defaultNodeEnvironment) {
39521
39577
  exec4(node2, [npm, "root", "--global"], options),
39522
39578
  exec4(node2, [npm, "--version"], options)
39523
39579
  ]);
39524
- const prefix = await (0, import_promises15.realpath)(prefixResult.stdout.trim());
39525
- const globalRoot = await (0, import_promises15.realpath)(rootResult.stdout.trim());
39526
- if (globalRoot !== (0, import_node_path14.join)(prefix, "lib/node_modules"))
39580
+ const prefix = await (0, import_promises16.realpath)(prefixResult.stdout.trim());
39581
+ const globalRoot = await (0, import_promises16.realpath)(rootResult.stdout.trim());
39582
+ if (globalRoot !== (0, import_node_path15.join)(prefix, "lib/node_modules"))
39527
39583
  throw new Error("\u76EE\u6807 npm \u5168\u5C40\u76EE\u5F55\u5E03\u5C40\u4E0D\u53D7\u652F\u6301\u3002");
39528
- const root = (0, import_node_path14.join)(globalRoot, npmPackageName);
39584
+ const root = (0, import_node_path15.join)(globalRoot, npmPackageName);
39529
39585
  const npmVersion = npmVersionResult.stdout.trim();
39530
39586
  if (!validVersion(npmVersion))
39531
39587
  throw new Error("\u76EE\u6807 npm \u672A\u8FD4\u56DE\u6709\u6548\u7248\u672C\uFF0C\u8BF7\u68C0\u67E5 npm \u5B89\u88C5\u540E\u91CD\u8BD5\u3002");
39532
39588
  try {
39533
39589
  const reason = await inspectPackageDirectory(root, globalRoot);
39534
39590
  if (reason) throw new Error(reason);
39535
- const entry = (0, import_node_path14.join)(root, "bin/covro.mjs");
39536
- if ((await (0, import_promises15.lstat)(entry)).isSymbolicLink() || await (0, import_promises15.realpath)((0, import_node_path14.join)(prefix, "bin/covro")) !== entry)
39591
+ const entry = (0, import_node_path15.join)(root, "bin/covro.mjs");
39592
+ if ((await (0, import_promises16.lstat)(entry)).isSymbolicLink() || await (0, import_promises16.realpath)((0, import_node_path15.join)(prefix, "bin/covro")) !== entry)
39537
39593
  throw new Error("\u5168\u5C40 covro \u5165\u53E3\u4E0E npm \u5B89\u88C5\u76EE\u5F55\u4E0D\u5339\u914D");
39538
- const metadata = JSON.parse(await (0, import_promises15.readFile)((0, import_node_path14.join)(root, "package.json"), "utf8"));
39594
+ const metadata = JSON.parse(await (0, import_promises16.readFile)((0, import_node_path15.join)(root, "package.json"), "utf8"));
39539
39595
  if (metadata.name !== npmPackageName || !validVersion(metadata.version))
39540
39596
  throw new Error("Covro \u5305\u8EAB\u4EFD\u65E0\u6548");
39541
39597
  return {
@@ -39565,9 +39621,9 @@ async function resolveRuntimeTarget(environment = defaultNodeEnvironment) {
39565
39621
  var import_node_child_process6 = require("node:child_process");
39566
39622
  var import_node_util6 = require("node:util");
39567
39623
  var import_node_crypto7 = require("node:crypto");
39568
- var import_promises16 = require("node:fs/promises");
39569
- var import_node_path15 = require("node:path");
39570
- var import_promises17 = require("node:timers/promises");
39624
+ var import_promises17 = require("node:fs/promises");
39625
+ var import_node_path16 = require("node:path");
39626
+ var import_promises18 = require("node:timers/promises");
39571
39627
 
39572
39628
  // src/codex/identity.ts
39573
39629
  var import_node_child_process5 = require("node:child_process");
@@ -39604,7 +39660,7 @@ var identity = external_exports.object({
39604
39660
  environment: external_exports.string()
39605
39661
  }).strict();
39606
39662
  var digest = (value) => (0, import_node_crypto7.createHash)("sha256").update(value).digest("hex");
39607
- var codexConfiguration = async (config2) => digest(await (0, import_promises16.readFile)(config2, "utf8"));
39663
+ var codexConfiguration = async (config2) => digest(await (0, import_promises17.readFile)(config2, "utf8"));
39608
39664
  function result(stdout) {
39609
39665
  const value = external_exports.object({ identity: identity.optional(), error: external_exports.string().optional() }).parse(JSON.parse(stdout));
39610
39666
  if (!value.identity)
@@ -39621,13 +39677,13 @@ function plist(value) {
39621
39677
  throw new CodexTargetError("\u767B\u5F55\u670D\u52A1\u5305\u542B\u65E0\u6CD5\u590D\u73B0\u7684\u542F\u52A8\u5C5E\u6027");
39622
39678
  }
39623
39679
  async function launchdProbe(location, content, args) {
39624
- const directory = await (0, import_promises16.mkdtemp)((0, import_node_path15.join)(location.state, "codex-probe-"));
39680
+ const directory = await (0, import_promises17.mkdtemp)((0, import_node_path16.join)(location.state, "codex-probe-"));
39625
39681
  const label = `dev.covro.probe.${(0, import_node_crypto7.randomUUID)()}`;
39626
39682
  const target = `${launchdPaths(location).domain}/${label}`;
39627
39683
  let loaded2 = false;
39628
39684
  try {
39629
- const filename = (0, import_node_path15.join)(directory, "probe.plist");
39630
- await (0, import_promises16.writeFile)(filename, content, { mode: 384 });
39685
+ const filename = (0, import_node_path16.join)(directory, "probe.plist");
39686
+ await (0, import_promises17.writeFile)(filename, content, { mode: 384 });
39631
39687
  const parsed = JSON.parse(
39632
39688
  (await exec6("/usr/bin/plutil", ["-convert", "json", "-o", "-", filename], { timeout: 5e3 })).stdout
39633
39689
  );
@@ -39650,22 +39706,22 @@ async function launchdProbe(location, content, args) {
39650
39706
  parsed.Label = label;
39651
39707
  parsed.ProgramArguments = args;
39652
39708
  parsed.RunAtLoad = true;
39653
- parsed.StandardOutPath = (0, import_node_path15.join)(directory, "result.json");
39654
- parsed.StandardErrorPath = (0, import_node_path15.join)(directory, "stderr");
39655
- await (0, import_promises16.writeFile)(filename, `<?xml version="1.0"?><plist version="1.0">${plist(parsed)}</plist>`);
39709
+ parsed.StandardOutPath = (0, import_node_path16.join)(directory, "result.json");
39710
+ parsed.StandardErrorPath = (0, import_node_path16.join)(directory, "stderr");
39711
+ await (0, import_promises17.writeFile)(filename, `<?xml version="1.0"?><plist version="1.0">${plist(parsed)}</plist>`);
39656
39712
  await exec6("/bin/launchctl", ["bootstrap", launchdPaths(location).domain, filename], {
39657
39713
  timeout: 5e3
39658
39714
  });
39659
39715
  loaded2 = true;
39660
39716
  for (let attempt = 0; attempt < 80; attempt++) {
39661
- const output2 = await (0, import_promises16.readFile)((0, import_node_path15.join)(directory, "result.json"), "utf8").catch(() => "");
39717
+ const output2 = await (0, import_promises17.readFile)((0, import_node_path16.join)(directory, "result.json"), "utf8").catch(() => "");
39662
39718
  if (output2.trim()) return result(output2);
39663
- await (0, import_promises17.setTimeout)(100);
39719
+ await (0, import_promises18.setTimeout)(100);
39664
39720
  }
39665
39721
  throw new CodexTargetError("\u767B\u5F55\u670D\u52A1\u672A\u8FD4\u56DE Codex \u63A2\u6D4B\u7ED3\u679C\uFF0C\u8BF7\u68C0\u67E5\u76EE\u6807 Node \u4E0E\u670D\u52A1\u73AF\u5883");
39666
39722
  } finally {
39667
39723
  if (loaded2) await exec6("/bin/launchctl", ["bootout", target], { timeout: 5e3 });
39668
- await (0, import_promises16.rm)(directory, { recursive: true, force: true });
39724
+ await (0, import_promises17.rm)(directory, { recursive: true, force: true });
39669
39725
  }
39670
39726
  }
39671
39727
  async function systemdProbe(content, args) {
@@ -39720,12 +39776,12 @@ async function systemdProbe(content, args) {
39720
39776
  return result(stdout);
39721
39777
  }
39722
39778
  async function observeRestartCodex(location, root, target, expectedSource, probeRoot = root) {
39723
- const current = await launchRuntime(location, (0, import_node_path15.join)(root, "bin/covro.mjs"));
39779
+ const current = await launchRuntime(location, (0, import_node_path16.join)(root, "bin/covro.mjs"));
39724
39780
  if (expectedSource && JSON.stringify(current) !== JSON.stringify(expectedSource))
39725
39781
  throw new CodexTargetError("\u4FDD\u5B58\u7684\u542F\u52A8\u6765\u6E90\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u66F4\u65B0");
39726
39782
  const snapshot = await snapshotLaunch(location, current);
39727
39783
  const configuration = await codexConfiguration(location.config);
39728
- const args = [target.node, (0, import_node_path15.join)(probeRoot, "dist/cli/codex-probe.js"), location.config];
39784
+ const args = [target.node, (0, import_node_path16.join)(probeRoot, "dist/cli/codex-probe.js"), location.config];
39729
39785
  let found;
39730
39786
  if (snapshot.service) {
39731
39787
  const content = serviceContent(location, target, snapshot.service);
@@ -39773,7 +39829,7 @@ async function startService(context2, candidate = false) {
39773
39829
  const target = candidate ? context2.target : void 0;
39774
39830
  await startBackground(
39775
39831
  context2.location,
39776
- (0, import_node_path16.join)(context2.root, "bin/covro.mjs"),
39832
+ (0, import_node_path17.join)(context2.root, "bin/covro.mjs"),
39777
39833
  target ? { node: target.node, entry: target.entry, path: target.path } : context2.source
39778
39834
  );
39779
39835
  }
@@ -39786,29 +39842,29 @@ async function verifyRestoredService(context2, version3) {
39786
39842
  const restored = await control(context2.location, "status");
39787
39843
  if (restored.version !== version3 || restored.maintenance)
39788
39844
  throw new Error("\u65E7\u7248\u6062\u590D\u8EAB\u4EFD\u4E0D\u5339\u914D");
39789
- const record2 = await readJson((0, import_node_path16.join)(context2.directory, "run.json"));
39845
+ const record2 = await readJson((0, import_node_path17.join)(context2.directory, "run.json"));
39790
39846
  if (record2?.runtime) assertRuntime(restored.runtime, record2.runtime.from);
39791
39847
  return;
39792
39848
  } catch (error62) {
39793
39849
  if (attempt === 239) throw error62;
39794
39850
  }
39795
- await (0, import_promises19.setTimeout)(250);
39851
+ await (0, import_promises20.setTimeout)(250);
39796
39852
  }
39797
39853
  }
39798
39854
  async function verifyMigrations(context2, candidate) {
39799
- const require2 = (0, import_node_module.createRequire)((0, import_node_path16.join)(context2.root, "package.json"));
39855
+ const require2 = (0, import_node_module.createRequire)((0, import_node_path17.join)(context2.root, "package.json"));
39800
39856
  const Sqlite = require2("better-sqlite3");
39801
- const filename = (0, import_node_path16.join)(context2.dataDir, "app.sqlite");
39857
+ const filename = (0, import_node_path17.join)(context2.dataDir, "app.sqlite");
39802
39858
  try {
39803
- await (0, import_promises18.access)(filename);
39859
+ await (0, import_promises19.access)(filename);
39804
39860
  } catch (error62) {
39805
39861
  if (error62.code === "ENOENT") return;
39806
39862
  throw error62;
39807
39863
  }
39808
39864
  const db = new Sqlite(filename, { readonly: true, fileMustExist: true });
39809
39865
  try {
39810
- const migrations = readMigrations((0, import_node_path16.join)(candidate, "dist/drizzle"));
39811
- const metadata = await readJson((0, import_node_path16.join)(candidate, "package.json"));
39866
+ const migrations = readMigrations((0, import_node_path17.join)(candidate, "dist/drizzle"));
39867
+ const metadata = await readJson((0, import_node_path17.join)(candidate, "package.json"));
39812
39868
  if (metadata?.covroDatabase) {
39813
39869
  const contract = databaseCompatibilitySchema.parse(metadata.covroDatabase);
39814
39870
  if (contract.schemaVersion !== migrations.length)
@@ -39820,21 +39876,21 @@ async function verifyMigrations(context2, candidate) {
39820
39876
  }
39821
39877
  }
39822
39878
  async function workerCore(directory, logger) {
39823
- await (0, import_promises18.mkdir)(directory, { recursive: true, mode: 448 });
39879
+ await (0, import_promises19.mkdir)(directory, { recursive: true, mode: 448 });
39824
39880
  const release = await import_proper_lockfile7.default.lock(directory, {
39825
39881
  stale: 1e4,
39826
39882
  update: 2e3,
39827
39883
  retries: { retries: 30, minTimeout: 100, maxTimeout: 500 }
39828
39884
  });
39829
- let record2 = await readJson((0, import_node_path16.join)(directory, "run.json"));
39830
- const context2 = await readJson((0, import_node_path16.join)(directory, "context.json"));
39885
+ let record2 = await readJson((0, import_node_path17.join)(directory, "run.json"));
39886
+ const context2 = await readJson((0, import_node_path17.join)(directory, "context.json"));
39831
39887
  if (!record2 || !context2) {
39832
39888
  await release();
39833
39889
  throw new Error("\u7F3A\u5C11\u5347\u7EA7\u8BB0\u5F55");
39834
39890
  }
39835
39891
  const update = async (phase, detail) => {
39836
39892
  record2 = { ...record2, phase, message: detail, updatedAt: Date.now() };
39837
- await saveJson((0, import_node_path16.join)(directory, "run.json"), record2);
39893
+ await saveJson((0, import_node_path17.join)(directory, "run.json"), record2);
39838
39894
  logger.info("update.phase_changed", { updateId: record2.id, stage: phase });
39839
39895
  };
39840
39896
  let paths = transactionPaths(
@@ -39842,7 +39898,7 @@ async function workerCore(directory, logger) {
39842
39898
  record2.id,
39843
39899
  context2.dataDir,
39844
39900
  context2.location.config,
39845
- (0, import_node_path16.join)(backupDirectory(context2.location.home, context2.dataDir), record2.id)
39901
+ (0, import_node_path17.join)(backupDirectory(context2.location.home, context2.dataDir), record2.id)
39846
39902
  );
39847
39903
  let releaseMaintenance;
39848
39904
  let releaseData;
@@ -39853,16 +39909,16 @@ async function workerCore(directory, logger) {
39853
39909
  readiness: () => control(context2.location, "update-readiness"),
39854
39910
  save: async (next) => {
39855
39911
  record2 = next;
39856
- await saveJson((0, import_node_path16.join)(directory, "run.json"), record2);
39912
+ await saveJson((0, import_node_path17.join)(directory, "run.json"), record2);
39857
39913
  },
39858
39914
  freeze: (checkedAt) => confirmAutomaticFreeze(
39859
39915
  record2.id,
39860
39916
  () => control(context2.location, "freeze-automatic-update", { id: record2.id, checkedAt }),
39861
- () => readJson((0, import_node_path16.join)(directory, "run.json"))
39917
+ () => readJson((0, import_node_path17.join)(directory, "run.json"))
39862
39918
  ),
39863
- pause: () => (0, import_promises19.setTimeout)(2e3)
39919
+ pause: () => (0, import_promises20.setTimeout)(2e3)
39864
39920
  });
39865
- const frozen = await readJson((0, import_node_path16.join)(directory, "context.json"));
39921
+ const frozen = await readJson((0, import_node_path17.join)(directory, "context.json"));
39866
39922
  if (!frozen) throw new Error("\u7F3A\u5C11\u56FA\u5B9A\u76EE\u6807\u8FD0\u884C\u73AF\u5883");
39867
39923
  Object.assign(context2, frozen);
39868
39924
  paths = transactionPaths(
@@ -39870,20 +39926,20 @@ async function workerCore(directory, logger) {
39870
39926
  record2.id,
39871
39927
  context2.dataDir,
39872
39928
  context2.location.config,
39873
- (0, import_node_path16.join)(backupDirectory(context2.location.home, context2.dataDir), record2.id)
39929
+ (0, import_node_path17.join)(backupDirectory(context2.location.home, context2.dataDir), record2.id)
39874
39930
  );
39875
39931
  }
39876
39932
  if (record2.runtime) await verifyRuntimeExecutable(record2.runtime.from);
39877
39933
  const previousMetadata = await readJson(
39878
- (0, import_node_path16.join)(paths.previous, "package.json")
39934
+ (0, import_node_path17.join)(paths.previous, "package.json")
39879
39935
  );
39880
39936
  const sameRoot = paths.root.replace(/\/$/, "") === context2.root.replace(/\/$/, "");
39881
39937
  const originalRoot = sameRoot && previousMetadata?.version === record2.from ? paths.previous : context2.root;
39882
- const originalMetadata = await readJson((0, import_node_path16.join)(originalRoot, "package.json"));
39883
- const requireOriginal = (0, import_node_module.createRequire)((0, import_node_path16.join)(originalRoot, "package.json"));
39938
+ const originalMetadata = await readJson((0, import_node_path17.join)(originalRoot, "package.json"));
39939
+ const requireOriginal = (0, import_node_module.createRequire)((0, import_node_path17.join)(originalRoot, "package.json"));
39884
39940
  const sqliteModulePath = requireOriginal.resolve("better-sqlite3");
39885
39941
  const Sqlite = requireOriginal(sqliteModulePath);
39886
- const migrations = readMigrations((0, import_node_path16.join)(originalRoot, "dist/drizzle"));
39942
+ const migrations = readMigrations((0, import_node_path17.join)(originalRoot, "dist/drizzle"));
39887
39943
  const backups = new BackupStore({
39888
39944
  directory: backupDirectory(context2.location.home, context2.dataDir),
39889
39945
  config: paths.config,
@@ -39903,8 +39959,8 @@ async function workerCore(directory, logger) {
39903
39959
  });
39904
39960
  if (process.argv[3] === "--repair") {
39905
39961
  releaseMaintenance = await acquireMaintenanceLock(context2.dataDir);
39906
- if (!await readJson((0, import_node_path16.join)(paths.backup, "snapshot.json")))
39907
- paths.backup = (0, import_node_path16.join)(directory, `backup-${record2.id}`);
39962
+ if (!await readJson((0, import_node_path17.join)(paths.backup, "snapshot.json")))
39963
+ paths.backup = (0, import_node_path17.join)(directory, `backup-${record2.id}`);
39908
39964
  const active = await control(context2.location, "status").catch(
39909
39965
  (error62) => {
39910
39966
  if (isNotRunning(error62)) return void 0;
@@ -39915,7 +39971,7 @@ async function workerCore(directory, logger) {
39915
39971
  if (active && !active.maintenance && active.version !== record2.from)
39916
39972
  throw new Error("\u5F53\u524D\u670D\u52A1\u53EF\u80FD\u5DF2\u63A5\u53D7\u65B0\u7248\u4E1A\u52A1\u6570\u636E\uFF1B\u62D2\u7EDD\u6062\u590D\u65E7\u5FEB\u7167\uFF0C\u8BF7\u4F7F\u7528\u517C\u5BB9\u7248\u672C\u68C0\u67E5\u3002");
39917
39973
  const previous = await readJson(
39918
- (0, import_node_path16.join)(paths.previous, "package.json")
39974
+ (0, import_node_path17.join)(paths.previous, "package.json")
39919
39975
  );
39920
39976
  if (previous || context2.reuseTarget) {
39921
39977
  if (active && !active.maintenance)
@@ -39923,16 +39979,16 @@ async function workerCore(directory, logger) {
39923
39979
  if (previous && (previous.name !== npmPackageName || previous.version !== (context2.target?.version ?? record2.from)))
39924
39980
  throw new Error("\u65E7\u7248\u5907\u4EFD\u8EAB\u4EFD\u4E0D\u5339\u914D");
39925
39981
  const snapshot = await readJson(
39926
- (0, import_node_path16.join)(paths.backup, "snapshot.json")
39982
+ (0, import_node_path17.join)(paths.backup, "snapshot.json")
39927
39983
  );
39928
39984
  if (snapshot?.formatVersion === 1) {
39929
39985
  const verified = await backups.verify(record2.id);
39930
39986
  if (verified.appVersion !== record2.from || verified.protectedBy !== record2.id || verified.configPath !== paths.config || verified.dataDir !== paths.dataDir)
39931
39987
  throw new Error("\u5907\u4EFD\u8EAB\u4EFD\u4E0D\u5339\u914D");
39932
- } else await verifyLegacySnapshot(paths.backup, Sqlite, (0, import_node_path16.join)(originalRoot, "dist/drizzle"));
39988
+ } else await verifyLegacySnapshot(paths.backup, Sqlite, (0, import_node_path17.join)(originalRoot, "dist/drizzle"));
39933
39989
  } else if (sameRoot) {
39934
39990
  const original = await readJson(
39935
- (0, import_node_path16.join)(paths.root, "package.json")
39991
+ (0, import_node_path17.join)(paths.root, "package.json")
39936
39992
  );
39937
39993
  if (original?.name !== npmPackageName || original.version !== record2.from)
39938
39994
  throw new Error("\u672A\u627E\u5230\u5B8C\u6574\u7684\u4E0A\u4E00\u7248\u672C\u5B89\u88C5");
@@ -39944,24 +40000,24 @@ async function workerCore(directory, logger) {
39944
40000
  await stopService(context2);
39945
40001
  releaseData = await acquireInstanceLock(context2.dataDir);
39946
40002
  if (previous) {
39947
- await (0, import_promises18.rm)(paths.root, { recursive: true, force: true });
39948
- await (0, import_promises18.rename)(paths.previous, paths.root);
40003
+ await (0, import_promises19.rm)(paths.root, { recursive: true, force: true });
40004
+ await (0, import_promises19.rename)(paths.previous, paths.root);
39949
40005
  }
39950
40006
  if (previous || context2.reuseTarget) {
39951
40007
  for (const name of ["app.sqlite", "app.sqlite-wal", "app.sqlite-shm"]) {
39952
- await (0, import_promises18.rm)((0, import_node_path16.join)(paths.dataDir, name), { force: true });
40008
+ await (0, import_promises19.rm)((0, import_node_path17.join)(paths.dataDir, name), { force: true });
39953
40009
  try {
39954
- await copyDurable((0, import_node_path16.join)(paths.backup, name), (0, import_node_path16.join)(paths.dataDir, name));
40010
+ await copyDurable((0, import_node_path17.join)(paths.backup, name), (0, import_node_path17.join)(paths.dataDir, name));
39955
40011
  } catch (error62) {
39956
40012
  if (error62.code !== "ENOENT") throw error62;
39957
40013
  }
39958
40014
  }
39959
- await copyDurable((0, import_node_path16.join)(paths.backup, "config.json"), paths.config);
40015
+ await copyDurable((0, import_node_path17.join)(paths.backup, "config.json"), paths.config);
39960
40016
  }
39961
- const launch2 = await readJson((0, import_node_path16.join)(directory, `launch-${record2.id}.json`));
40017
+ const launch2 = await readJson((0, import_node_path17.join)(directory, `launch-${record2.id}.json`));
39962
40018
  if (launch2) await restoreLaunch(context2.location, launch2);
39963
40019
  const restored = await readJson(
39964
- (0, import_node_path16.join)(context2.root, "package.json")
40020
+ (0, import_node_path17.join)(context2.root, "package.json")
39965
40021
  );
39966
40022
  if (restored?.name !== npmPackageName || restored.version !== record2.from)
39967
40023
  throw new Error("\u672A\u627E\u5230\u5B8C\u6574\u7684\u4E0A\u4E00\u7248\u672C\u5B89\u88C5");
@@ -39980,10 +40036,10 @@ async function workerCore(directory, logger) {
39980
40036
  }
39981
40037
  const reason = await inspectInstallation(context2.root);
39982
40038
  if (reason) throw new Error(reason);
39983
- for (const key of await (0, import_promises18.readdir)((0, import_node_path16.join)(context2.location.home, "instances"))) {
40039
+ for (const key of await (0, import_promises19.readdir)((0, import_node_path17.join)(context2.location.home, "instances"))) {
39984
40040
  if (key === context2.location.key) continue;
39985
40041
  const instance = await readJson(
39986
- (0, import_node_path16.join)(context2.location.home, "instances", key, "instance.json")
40042
+ (0, import_node_path17.join)(context2.location.home, "instances", key, "instance.json")
39987
40043
  );
39988
40044
  if (!instance || ![context2.root.replace(/\/$/, ""), paths.root].includes(instance.root.replace(/\/$/, "")))
39989
40045
  continue;
@@ -39994,8 +40050,8 @@ async function workerCore(directory, logger) {
39994
40050
  if (!isNotRunning(error62)) throw error62;
39995
40051
  }
39996
40052
  }
39997
- await (0, import_promises18.access)((0, import_node_path16.dirname)(context2.root), import_node_fs6.constants.W_OK);
39998
- await (0, import_promises18.access)((0, import_node_path16.dirname)(paths.root), import_node_fs6.constants.W_OK);
40053
+ await (0, import_promises19.access)((0, import_node_path17.dirname)(context2.root), import_node_fs6.constants.W_OK);
40054
+ await (0, import_promises19.access)((0, import_node_path17.dirname)(paths.root), import_node_fs6.constants.W_OK);
39999
40055
  if (context2.target) {
40000
40056
  const target = await resolveRuntimeTarget();
40001
40057
  assertRuntime(target, context2.target);
@@ -40049,7 +40105,7 @@ async function workerCore(directory, logger) {
40049
40105
  ],
40050
40106
  { env, timeout: 10 * 6e4, maxBuffer: 2 * 1024 * 1024 }
40051
40107
  );
40052
- const candidate = await readJson((0, import_node_path16.join)(candidateRoot, "package.json"));
40108
+ const candidate = await readJson((0, import_node_path17.join)(candidateRoot, "package.json"));
40053
40109
  if (candidate?.name !== npmPackageName || candidate.version !== record2.target)
40054
40110
  throw new Error("\u5019\u9009\u5305\u8EAB\u4EFD\u6216\u7248\u672C\u4E0D\u5339\u914D");
40055
40111
  if (record2.commit && (candidate.covroCommit ?? candidate.gitHead) !== record2.commit)
@@ -40070,7 +40126,7 @@ async function workerCore(directory, logger) {
40070
40126
  };
40071
40127
  probeRoot = candidateRoot;
40072
40128
  await checkRestartCodex();
40073
- const versionProbe = await exec7(node2, [(0, import_node_path16.join)(candidateRoot, "bin/covro.mjs"), "--version"], {
40129
+ const versionProbe = await exec7(node2, [(0, import_node_path17.join)(candidateRoot, "bin/covro.mjs"), "--version"], {
40074
40130
  timeout: 3e4,
40075
40131
  env
40076
40132
  });
@@ -40079,7 +40135,7 @@ async function workerCore(directory, logger) {
40079
40135
  const nativeProbe = 'const {createRequire}=await import("node:module"); const r=createRequire(process.argv[1]); const DB=r("better-sqlite3"); const db=new DB(":memory:"); db.close();';
40080
40136
  await exec7(
40081
40137
  node2,
40082
- ["--input-type=module", "-e", nativeProbe, (0, import_node_path16.join)(candidateRoot, "package.json")],
40138
+ ["--input-type=module", "-e", nativeProbe, (0, import_node_path17.join)(candidateRoot, "package.json")],
40083
40139
  { env, timeout: 3e4 }
40084
40140
  );
40085
40141
  await verifyMigrations(context2, candidateRoot);
@@ -40087,13 +40143,13 @@ async function workerCore(directory, logger) {
40087
40143
  context2.location,
40088
40144
  context2.source ?? {
40089
40145
  node: process.execPath,
40090
- entry: (0, import_node_path16.join)(context2.root, "bin/covro.mjs"),
40146
+ entry: (0, import_node_path17.join)(context2.root, "bin/covro.mjs"),
40091
40147
  path: process.env.PATH ?? "/usr/bin:/bin"
40092
40148
  }
40093
40149
  );
40094
40150
  if (context2.target)
40095
40151
  launch.target = { node: node2, entry: context2.target.entry, path: context2.target.path };
40096
- await saveJson((0, import_node_path16.join)(directory, `launch-${record2.id}.json`), launch);
40152
+ await saveJson((0, import_node_path17.join)(directory, `launch-${record2.id}.json`), launch);
40097
40153
  releaseMaintenance = await acquireMaintenanceLock(context2.dataDir);
40098
40154
  await activateUpdate(
40099
40155
  paths,
@@ -40113,24 +40169,22 @@ async function workerCore(directory, logger) {
40113
40169
  ) : void 0,
40114
40170
  restoreLaunch: () => restoreLaunch(context2.location, launch),
40115
40171
  phase: update,
40116
- waitForIdle: async () => {
40117
- for (; ; ) {
40118
- await checkRestartCodex();
40119
- const result2 = await control(
40120
- context2.location,
40121
- "prepare-update"
40122
- );
40123
- if (result2.ready) {
40124
- await checkRestartCodex();
40125
- await verifyMigrations(context2, candidateRoot);
40126
- const pinned = await readJson((0, import_node_path16.join)(candidateRoot, "package.json"));
40127
- if (JSON.stringify(pinned) !== JSON.stringify(candidate))
40128
- throw new Error("\u56FA\u5B9A\u5019\u9009\u5305\u5728\u5B89\u88C5\u540E\u53D1\u751F\u53D8\u5316\uFF0C\u62D2\u7EDD\u5207\u6362");
40129
- return;
40130
- }
40172
+ prepare: async () => {
40173
+ await checkRestartCodex();
40174
+ const result2 = await control(
40175
+ context2.location,
40176
+ "prepare-update"
40177
+ );
40178
+ if (!result2.ready) {
40131
40179
  await update("waiting", result2.reason ?? "\u7B49\u5F85\u6240\u6709\u4EFB\u52A1\u7ED3\u675F");
40132
- await (0, import_promises19.setTimeout)(2e3);
40180
+ return false;
40133
40181
  }
40182
+ await checkRestartCodex();
40183
+ await verifyMigrations(context2, candidateRoot);
40184
+ const pinned = await readJson((0, import_node_path17.join)(candidateRoot, "package.json"));
40185
+ if (JSON.stringify(pinned) !== JSON.stringify(candidate))
40186
+ throw new Error("\u56FA\u5B9A\u5019\u9009\u5305\u5728\u5B89\u88C5\u540E\u53D1\u751F\u53D8\u5316\uFF0C\u62D2\u7EDD\u5207\u6362");
40187
+ return true;
40134
40188
  },
40135
40189
  beforeStop: checkRestartCodex,
40136
40190
  stop: () => stopService(context2),
@@ -40141,35 +40195,29 @@ async function workerCore(directory, logger) {
40141
40195
  if (!candidate2) await verifyRestoredService(context2, record2.from);
40142
40196
  },
40143
40197
  verify: async () => {
40144
- for (let attempt = 0; attempt < 240; attempt++) {
40145
- const current = await control(context2.location, "status").catch(
40146
- () => void 0
40147
- );
40148
- if (current) {
40149
- if (current.version !== record2.target || !current.maintenance)
40150
- throw new Error("\u65B0\u7248\u670D\u52A1\u8EAB\u4EFD\u6216\u7EF4\u62A4\u72B6\u6001\u4E0D\u5339\u914D");
40151
- if (record2.runtime) assertRuntime(current.runtime, record2.runtime.target);
40152
- if (current.codexVersion && current.codexVersion !== record2.codex.version)
40153
- throw new Error("\u91CD\u542F\u540E\u7684 Codex \u7248\u672C\u4E0E\u5347\u7EA7\u6821\u9A8C\u8BB0\u5F55\u4E0D\u5339\u914D");
40154
- if (current.codexReady) {
40155
- checkRunningCodex(current);
40156
- return;
40157
- }
40158
- }
40159
- await (0, import_promises19.setTimeout)(250);
40160
- }
40161
- throw new Error("\u65B0\u7248\u670D\u52A1\u6216 Codex \u8FDE\u63A5\u672A\u5C31\u7EEA\uFF0C\u62D2\u7EDD\u6FC0\u6D3B");
40198
+ const current = await control(context2.location, "status").catch(
40199
+ () => void 0
40200
+ );
40201
+ if (!current) return false;
40202
+ if (current.version !== record2.target || !current.maintenance)
40203
+ throw new Error("\u65B0\u7248\u670D\u52A1\u8EAB\u4EFD\u6216\u7EF4\u62A4\u72B6\u6001\u4E0D\u5339\u914D");
40204
+ if (record2.runtime) assertRuntime(current.runtime, record2.runtime.target);
40205
+ if (current.codexVersion && current.codexVersion !== record2.codex.version)
40206
+ throw new Error("\u91CD\u542F\u540E\u7684 Codex \u7248\u672C\u4E0E\u5347\u7EA7\u6821\u9A8C\u8BB0\u5F55\u4E0D\u5339\u914D");
40207
+ if (!current.codexReady) return false;
40208
+ checkRunningCodex(current);
40209
+ return true;
40162
40210
  },
40163
40211
  commit: async () => {
40164
40212
  await control(context2.location, "activate-update", {
40165
40213
  id: record2.id,
40166
40214
  channel: record2.channel
40167
40215
  });
40168
- const final = await readJson((0, import_node_path16.join)(directory, "run.json"));
40216
+ const final = await readJson((0, import_node_path17.join)(directory, "run.json"));
40169
40217
  if (!final?.committed) throw new Error("\u65B0\u7248\u5C1A\u672A\u786E\u8BA4\u5347\u7EA7\u63D0\u4EA4");
40170
40218
  record2 = final;
40171
40219
  },
40172
- hasCommitted: async () => Boolean((await readJson((0, import_node_path16.join)(directory, "run.json")))?.committed),
40220
+ hasCommitted: async () => Boolean((await readJson((0, import_node_path17.join)(directory, "run.json")))?.committed),
40173
40221
  resume: async () => {
40174
40222
  await control(context2.location, "cancel-update").catch(() => {
40175
40223
  });
@@ -40178,7 +40226,7 @@ async function workerCore(directory, logger) {
40178
40226
  context2.reuseTarget
40179
40227
  );
40180
40228
  } catch (error62) {
40181
- const latest = await readJson((0, import_node_path16.join)(directory, "run.json"));
40229
+ const latest = await readJson((0, import_node_path17.join)(directory, "run.json"));
40182
40230
  if (latest?.committed) {
40183
40231
  record2 = latest;
40184
40232
  } else if (!["rolledBack", "failed"].includes(record2.phase))
@@ -40193,16 +40241,16 @@ async function workerCore(directory, logger) {
40193
40241
  await releaseMaintenance?.();
40194
40242
  await release();
40195
40243
  if (record2.phase === "succeeded" || record2.phase === "rolledBack") {
40196
- await (0, import_promises18.rm)(paths.prefix, { recursive: true, force: true });
40244
+ await (0, import_promises19.rm)(paths.prefix, { recursive: true, force: true });
40197
40245
  }
40198
40246
  }
40199
40247
  }
40200
40248
  async function worker(directory) {
40201
- const context2 = await readJson((0, import_node_path16.join)(directory, "context.json"));
40249
+ const context2 = await readJson((0, import_node_path17.join)(directory, "context.json"));
40202
40250
  if (!context2) throw new Error("Missing update context");
40203
- const record2 = await readJson((0, import_node_path16.join)(directory, "run.json"));
40251
+ const record2 = await readJson((0, import_node_path17.join)(directory, "run.json"));
40204
40252
  const logging = await createLogging({
40205
- ...loggingOptions((0, import_node_path16.join)(context2.location.state, "logs"), record2?.from ?? "unknown"),
40253
+ ...loggingOptions((0, import_node_path17.join)(context2.location.state, "logs"), record2?.from ?? "unknown"),
40206
40254
  component: "update_worker"
40207
40255
  });
40208
40256
  const removeMonitor = monitorCrashes(logging.logger, logging.flushSync);