@deslop/workbench 0.0.305 → 0.0.320

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 (136) hide show
  1. package/dist/client/assets/{(home)-DOBmFAyb.js → (home)-DVKAaI4b.js} +1 -1
  2. package/dist/client/assets/agent-DAD7EQOa.js +2 -0
  3. package/dist/client/assets/{agent-DAtPiqFc.js → agent-DHWhwvQy.js} +1 -1
  4. package/dist/client/assets/arc-CuHXSNPr.js +1 -0
  5. package/dist/client/assets/architecture-7EHR7CIX-BQpCYB3J.js +1 -0
  6. package/dist/client/assets/architectureDiagram-3BPJPVTR-hs4IN-ZW.js +36 -0
  7. package/dist/client/assets/array-BifhSqXX.js +1 -0
  8. package/dist/client/assets/blockDiagram-GPEHLZMM-D3jiL-uN.js +132 -0
  9. package/dist/client/assets/button-fe_R2wzr.js +16 -0
  10. package/dist/client/assets/c4Diagram-AAUBKEIU-bA47L7u8.js +10 -0
  11. package/dist/client/assets/channel-CHiC1IgU.js +1 -0
  12. package/dist/client/assets/chunk-2J33WTMH-optplvap.js +1 -0
  13. package/dist/client/assets/chunk-3OPIFGDE-k7mTnOn5.js +62 -0
  14. package/dist/client/assets/chunk-4BX2VUAB-Co5qfYem.js +1 -0
  15. package/dist/client/assets/chunk-4EGX6M5U-BfCFom1o.js +1 -0
  16. package/dist/client/assets/chunk-55IACEB6-7AWIUH7L.js +1 -0
  17. package/dist/client/assets/chunk-5DO6E6H7-DP8QnaJj.js +1 -0
  18. package/dist/client/assets/chunk-5ZQYHXKU-Bub4jU0C.js +2 -0
  19. package/dist/client/assets/chunk-727SXJPM-DcofuxtV.js +206 -0
  20. package/dist/client/assets/chunk-AQP2D5EJ-CBwGmuY5.js +231 -0
  21. package/dist/client/assets/chunk-BR22UD5L-CT6fcRkN.js +1 -0
  22. package/dist/client/assets/chunk-BSJP7CBP-BInTsaMb.js +1 -0
  23. package/dist/client/assets/chunk-CSCIHK7Q-BTHSw3Fl.js +124 -0
  24. package/dist/client/assets/chunk-FHYWG6QK-Ce318laP.js +1 -0
  25. package/dist/client/assets/chunk-FMBD7UC4-BQD4ioRx.js +15 -0
  26. package/dist/client/assets/chunk-KSCS5N6A-CUDSaUx0.js +10 -0
  27. package/dist/client/assets/chunk-L5ZTLDWV-D0-tvK0S.js +1 -0
  28. package/dist/client/assets/chunk-LZXEDZCA-BkJ5xlLM.js +2 -0
  29. package/dist/client/assets/chunk-MPE355IW-C_vkbqLj.js +1 -0
  30. package/dist/client/assets/chunk-MZUSXYTE-BnVcgphH.js +1 -0
  31. package/dist/client/assets/chunk-N66VUXT2-B6CG-CnY.js +1 -0
  32. package/dist/client/assets/chunk-ND2GUHAM-COdW9HuZ.js +1 -0
  33. package/dist/client/assets/chunk-NNHCCRGN-DlpIbxXb.js +159 -0
  34. package/dist/client/assets/chunk-NZK2D7GU-Byrnkfto.js +1 -0
  35. package/dist/client/assets/chunk-O5CBEL6O-C_CProRX.js +70 -0
  36. package/dist/client/assets/chunk-PUPMXCY4-BZ88kQjK.js +1 -0
  37. package/dist/client/assets/chunk-QTnfLwEv.js +1 -0
  38. package/dist/client/assets/chunk-QZHKN3VN-SFi3gsXX.js +1 -0
  39. package/dist/client/assets/chunk-UIBZB4QT-r8p3pBHw.js +1 -0
  40. package/dist/client/assets/chunk-WCWK7LTN-DrKYkgXF.js +1 -0
  41. package/dist/client/assets/chunk-WU5MYG2G-OzrGGim9.js +1 -0
  42. package/dist/client/assets/chunk-XPW4576I-DWr3727k.js +32 -0
  43. package/dist/client/assets/classDiagram-4FO5ZUOK-DvZGz7Ek.js +1 -0
  44. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DvZGz7Ek.js +1 -0
  45. package/dist/client/assets/compiler-runtime-rGeCHUuX.js +1 -0
  46. package/dist/client/assets/cose-bilkent-S5V4N54A-BzitJXTQ.js +1 -0
  47. package/dist/client/assets/cytoscape.esm-FqbQrHcz.js +321 -0
  48. package/dist/client/assets/dagre-BM42HDAG-Bwiv8kFL.js +4 -0
  49. package/dist/client/assets/dagre-Bx709z4p.js +1 -0
  50. package/dist/client/assets/defaultLocale-C8Fc0cco.js +1 -0
  51. package/dist/client/assets/diagram-2AECGRRQ-BY9KXQPi.js +43 -0
  52. package/dist/client/assets/diagram-5GNKFQAL-C-jmG8LL.js +10 -0
  53. package/dist/client/assets/diagram-KO2AKTUF-qDHWGr5P.js +3 -0
  54. package/dist/client/assets/diagram-LMA3HP47-Dg8zuIuL.js +24 -0
  55. package/dist/client/assets/diagram-OG6HWLK6-DupmLmKo.js +24 -0
  56. package/dist/client/assets/diff-BbjpVkn4.js +217 -0
  57. package/dist/client/assets/diff-HFsBcdrM.js +2 -0
  58. package/dist/client/assets/dist-lRkD-JPF.js +1 -0
  59. package/dist/client/assets/erDiagram-TEJ5UH35-DcYoMsDA.js +85 -0
  60. package/dist/client/assets/eventmodeling-FCH6USID-D-VxYsbw.js +1 -0
  61. package/dist/client/assets/external-link-CTjuCORn.js +1 -0
  62. package/dist/client/assets/{fallbacks-CzbUcCp6.js → fallbacks-DZ7ciusO.js} +1 -1
  63. package/dist/client/assets/flowDiagram-I6XJVG4X-xLfWiyaL.js +162 -0
  64. package/dist/client/assets/ganttDiagram-6RSMTGT7-hA3inn7u.js +292 -0
  65. package/dist/client/assets/gitGraph-WXDBUCRP-CRS5XD98.js +1 -0
  66. package/dist/client/assets/gitGraphDiagram-PVQCEYII-DE7nmb1q.js +106 -0
  67. package/dist/client/assets/graphlib-B8gBHxth.js +1 -0
  68. package/dist/client/assets/{index-Cl7Hl1HJ.css → index-Ci3BZgXN.css} +1 -1
  69. package/dist/client/assets/index-Ds4rq0zQ.js +10 -0
  70. package/dist/client/assets/info-J43DQDTF-CdrjkAmK.js +1 -0
  71. package/dist/client/assets/infoDiagram-5YYISTIA-CUzdfhph.js +2 -0
  72. package/dist/client/assets/init-D6jRqBbL.js +1 -0
  73. package/dist/client/assets/input-group-BtEJur4W.js +153 -0
  74. package/dist/client/assets/ishikawaDiagram-YF4QCWOH-D3h5fT3O.js +70 -0
  75. package/dist/client/assets/journeyDiagram-JHISSGLW-DXqP7IZk.js +139 -0
  76. package/dist/client/assets/kanban-definition-UN3LZRKU-BBdz3OGi.js +89 -0
  77. package/dist/client/assets/katex-Vhh-h91d.js +257 -0
  78. package/dist/client/assets/line-D2nnU070.js +1 -0
  79. package/dist/client/assets/linear-BifnMVyn.js +1 -0
  80. package/dist/client/assets/loader-circle-B1mHTP2Y.js +1 -0
  81. package/dist/client/assets/mermaid-parser.core-CKHoAf1J.js +4 -0
  82. package/dist/client/assets/mindmap-definition-RKZ34NQL-BAbACAeS.js +96 -0
  83. package/dist/client/assets/ordinal-hYBb2elL.js +1 -0
  84. package/dist/client/assets/packet-YPE3B663-r4oAflYS.js +1 -0
  85. package/dist/client/assets/path-BWPyau1x.js +1 -0
  86. package/dist/client/assets/pie-LRSECV5Y-DkaVktH1.js +1 -0
  87. package/dist/client/assets/pieDiagram-4H26LBE5-YjWBEaV3.js +30 -0
  88. package/dist/client/assets/portless-DFKFPX3Z.js +1 -0
  89. package/dist/client/assets/portless-DexDlqwA.js +2 -0
  90. package/dist/client/assets/preload-helper-CjdClQve.js +1 -0
  91. package/dist/client/assets/quadrantDiagram-W4KKPZXB-0qpR8bhI.js +7 -0
  92. package/dist/client/assets/radar-GUYGQ44K-Bjhhjq-k.js +1 -0
  93. package/dist/client/assets/requirementDiagram-4Y6WPE33-UxrH60_h.js +84 -0
  94. package/dist/client/assets/resizable-B1fIW9sm.js +1 -0
  95. package/dist/client/assets/rough.esm-CSKSodPl.js +1 -0
  96. package/dist/client/assets/route-CUHeGENe.js +45 -0
  97. package/dist/client/assets/route-DOWKJR6H.js +2 -0
  98. package/dist/client/assets/run-BvHiSlty.js +2 -0
  99. package/dist/client/assets/run-L2YCL4H0.js +1 -0
  100. package/dist/client/assets/sankeyDiagram-5OEKKPKP-CtfCq9EV.js +40 -0
  101. package/dist/client/assets/sequenceDiagram-3UESZ5HK-BgLwmDnV.js +162 -0
  102. package/dist/client/assets/src-oaGqIoNi.js +1 -0
  103. package/dist/client/assets/state-T-ZhKyUm.js +2 -0
  104. package/dist/client/assets/stateDiagram-AJRCARHV--lvnWH2s.js +1 -0
  105. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BggoNPhO.js +1 -0
  106. package/dist/client/assets/{terminal-BxxTf_cr.js → terminal-CGe8qF7_.js} +1 -1
  107. package/dist/client/assets/{terminal-rDaSmJ0r.js → terminal-Ci9YBovb.js} +2 -2
  108. package/dist/client/assets/terminal-t4CeG_V9.js +2 -0
  109. package/dist/client/assets/timeline-definition-PNZ67QCA-BbIMEZmJ.js +120 -0
  110. package/dist/client/assets/treeView-BLDUP644-DbX5QpdZ.js +1 -0
  111. package/dist/client/assets/treemap-LRROVOQU-DT4YRX1p.js +1 -0
  112. package/dist/client/assets/{triangle-alert-BQeVqgy8.js → triangle-alert-CGj-8H_a.js} +1 -1
  113. package/dist/client/assets/vennDiagram-CIIHVFJN-ClrNZ6mc.js +34 -0
  114. package/dist/client/assets/wardley-L42UT6IY-Ba5lVG9E.js +1 -0
  115. package/dist/client/assets/wardleyDiagram-YWT4CUSO-B104yVOC.js +78 -0
  116. package/dist/client/assets/xychartDiagram-2RQKCTM6-BBRSu-ZO.js +7 -0
  117. package/dist/client/index.html +15 -13
  118. package/dist/server.js +797 -1324
  119. package/package.json +5 -4
  120. package/dist/client/assets/agent-C7AGYCbR.js +0 -2
  121. package/dist/client/assets/browser-C9CioR-6.js +0 -1
  122. package/dist/client/assets/browser-tjb_rUHN.js +0 -2
  123. package/dist/client/assets/button-CcQhG-Sh.js +0 -16
  124. package/dist/client/assets/compiler-runtime-CUwoe8mk.js +0 -1
  125. package/dist/client/assets/composite-D6OT7BpY.js +0 -1
  126. package/dist/client/assets/dialog-BEWSq-pP.js +0 -153
  127. package/dist/client/assets/diff-CkEZJzkn.js +0 -2
  128. package/dist/client/assets/diff-sODa_qu9.js +0 -115
  129. package/dist/client/assets/index-Pxxow7tc.js +0 -10
  130. package/dist/client/assets/loader-circle-CS6z4ADU.js +0 -1
  131. package/dist/client/assets/route-DStELzmA.js +0 -2
  132. package/dist/client/assets/route-aA7yFkjp.js +0 -45
  133. package/dist/client/assets/run-Ck2ZRm8_.js +0 -1
  134. package/dist/client/assets/run-xTdsjUtJ.js +0 -2
  135. package/dist/client/assets/state-DUa-6AT3.js +0 -2
  136. package/dist/client/assets/terminal-SjWbsgWp.js +0 -2
package/dist/server.js CHANGED
@@ -16,12 +16,10 @@ import { randomUUID } from "node:crypto";
16
16
  import * as NFS from "node:fs";
17
17
  import * as OS from "node:os";
18
18
  import * as Path from "node:path";
19
- import path, { join } from "node:path";
19
+ import path from "node:path";
20
20
  import * as NodeStreamP from "node:stream/promises";
21
21
  import { pipeline } from "node:stream/promises";
22
- import { readFile } from "node:fs/promises";
23
22
  import * as readline from "node:readline";
24
- import nodeProcess from "node:process";
25
23
  import * as nodePty from "@lydell/node-pty";
26
24
  //#region \0rolldown/runtime.js
27
25
  var __create = Object.create;
@@ -4360,7 +4358,7 @@ const done$2 = (value) => {
4360
4358
  * @category constructors
4361
4359
  * @since 2.0.0
4362
4360
  */
4363
- const make$65 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
4361
+ const make$64 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
4364
4362
  const isStrictEquivalent = (x, y) => x === y;
4365
4363
  /**
4366
4364
  * Creates an equivalence relation that uses strict equality (`===`) to compare values.
@@ -4473,7 +4471,7 @@ const strictEqual = () => isStrictEquivalent;
4473
4471
  * @since 4.0.0
4474
4472
  */
4475
4473
  function Tuple$1(elements) {
4476
- return make$65((self, that) => {
4474
+ return make$64((self, that) => {
4477
4475
  if (self.length !== that.length) return false;
4478
4476
  for (let i = 0; i < self.length; i++) if (!elements[i](self[i], that[i])) return false;
4479
4477
  return true;
@@ -4483,7 +4481,7 @@ function Tuple$1(elements) {
4483
4481
  * @since 4.0.0
4484
4482
  */
4485
4483
  function Array_(item) {
4486
- return make$65((self, that) => {
4484
+ return make$64((self, that) => {
4487
4485
  if (self.length !== that.length) return false;
4488
4486
  for (let i = 0; i < self.length; i++) if (!item(self[i], that[i])) return false;
4489
4487
  return true;
@@ -4501,9 +4499,9 @@ const isArrayNonEmpty$1 = (self) => self.length > 0;
4501
4499
  /**
4502
4500
  * @since 2.0.0
4503
4501
  */
4504
- const TypeId$51 = "~effect/data/Option";
4502
+ const TypeId$50 = "~effect/data/Option";
4505
4503
  const CommonProto$1 = {
4506
- [TypeId$51]: { _A: (_) => _ },
4504
+ [TypeId$50]: { _A: (_) => _ },
4507
4505
  ...PipeInspectableProto,
4508
4506
  [Symbol.iterator]() {
4509
4507
  return new SingleShotGen(this);
@@ -4554,7 +4552,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
4554
4552
  }
4555
4553
  });
4556
4554
  /** @internal */
4557
- const isOption = (input) => hasProperty(input, TypeId$51);
4555
+ const isOption = (input) => hasProperty(input, TypeId$50);
4558
4556
  /** @internal */
4559
4557
  const isNone$1 = (fa) => fa._tag === "None";
4560
4558
  /** @internal */
@@ -4562,16 +4560,16 @@ const isSome$1 = (fa) => fa._tag === "Some";
4562
4560
  /** @internal */
4563
4561
  const none$1 = /*#__PURE__*/ Object.create(NoneProto);
4564
4562
  /** @internal */
4565
- const some$1 = (value) => {
4563
+ const some$2 = (value) => {
4566
4564
  const a = Object.create(SomeProto);
4567
4565
  a.value = value;
4568
4566
  return a;
4569
4567
  };
4570
4568
  //#endregion
4571
4569
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/result.js
4572
- const TypeId$50 = "~effect/data/Result";
4570
+ const TypeId$49 = "~effect/data/Result";
4573
4571
  const CommonProto = {
4574
- [TypeId$50]: {
4572
+ [TypeId$49]: {
4575
4573
  /* v8 ignore next 2 */
4576
4574
  _A: (_) => _,
4577
4575
  _E: (_) => _
@@ -4622,7 +4620,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4622
4620
  }
4623
4621
  });
4624
4622
  /** @internal */
4625
- const isResult = (input) => hasProperty(input, TypeId$50);
4623
+ const isResult = (input) => hasProperty(input, TypeId$49);
4626
4624
  /** @internal */
4627
4625
  const isFailure$2 = (result) => result._tag === "Failure";
4628
4626
  /** @internal */
@@ -4756,7 +4754,7 @@ const succeed$8 = (success) => {
4756
4754
  * @category constructors
4757
4755
  * @since 2.0.0
4758
4756
  */
4759
- function make$64(compare) {
4757
+ function make$63(compare) {
4760
4758
  return (self, that) => self === that ? 0 : compare(self, that);
4761
4759
  }
4762
4760
  /**
@@ -4789,7 +4787,7 @@ function make$64(compare) {
4789
4787
  * @category instances
4790
4788
  * @since 4.0.0
4791
4789
  */
4792
- const String$5 = /*#__PURE__*/ make$64((self, that) => self < that ? -1 : 1);
4790
+ const String$5 = /*#__PURE__*/ make$63((self, that) => self < that ? -1 : 1);
4793
4791
  /**
4794
4792
  * Order instance for numbers that compares them numerically.
4795
4793
  *
@@ -4824,7 +4822,7 @@ const String$5 = /*#__PURE__*/ make$64((self, that) => self < that ? -1 : 1);
4824
4822
  * @category instances
4825
4823
  * @since 4.0.0
4826
4824
  */
4827
- const Number$5 = /*#__PURE__*/ make$64((self, that) => {
4825
+ const Number$5 = /*#__PURE__*/ make$63((self, that) => {
4828
4826
  if (globalThis.Number.isNaN(self) && globalThis.Number.isNaN(that)) return 0;
4829
4827
  if (globalThis.Number.isNaN(self)) return -1;
4830
4828
  if (globalThis.Number.isNaN(that)) return 1;
@@ -4863,7 +4861,7 @@ const Number$5 = /*#__PURE__*/ make$64((self, that) => {
4863
4861
  * @category mapping
4864
4862
  * @since 2.0.0
4865
4863
  */
4866
- const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$64((b1, b2) => self(f(b1), f(b2))));
4864
+ const mapInput = /*#__PURE__*/ dual(2, (self, f) => make$63((b1, b2) => self(f(b1), f(b2))));
4867
4865
  /**
4868
4866
  * Checks whether one value is strictly less than another according to the given order.
4869
4867
  *
@@ -5061,7 +5059,7 @@ const none = () => none$1;
5061
5059
  * @category constructors
5062
5060
  * @since 2.0.0
5063
5061
  */
5064
- const some = some$1;
5062
+ const some$1 = some$2;
5065
5063
  /**
5066
5064
  * Checks whether an `Option` is `None` (absent).
5067
5065
  *
@@ -5256,7 +5254,7 @@ const orElse$1 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : s
5256
5254
  * @category converting
5257
5255
  * @since 4.0.0
5258
5256
  */
5259
- const fromNullishOr = (a) => a == null ? none() : some(a);
5257
+ const fromNullishOr = (a) => a == null ? none() : some$1(a);
5260
5258
  /**
5261
5259
  * Converts a possibly `undefined` value into an `Option`, leaving `null`
5262
5260
  * as a valid `Some`.
@@ -5291,7 +5289,7 @@ const fromNullishOr = (a) => a == null ? none() : some(a);
5291
5289
  * @category converting
5292
5290
  * @since 4.0.0
5293
5291
  */
5294
- const fromUndefinedOr = (a) => a === void 0 ? none() : some(a);
5292
+ const fromUndefinedOr = (a) => a === void 0 ? none() : some$1(a);
5295
5293
  /**
5296
5294
  * Extracts the value from a `Some`, or returns `undefined` for `None`.
5297
5295
  *
@@ -5355,7 +5353,7 @@ const getOrUndefined$1 = /*#__PURE__*/ getOrElse$1(constUndefined);
5355
5353
  * @category mapping
5356
5354
  * @since 2.0.0
5357
5355
  */
5358
- const map$9 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
5356
+ const map$9 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some$1(f(self.value)));
5359
5357
  /**
5360
5358
  * Applies a function that returns an `Option` to the value of a `Some`,
5361
5359
  * flattening the result. Returns `None` if the input is `None`.
@@ -5442,43 +5440,7 @@ const flatMap$6 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(s
5442
5440
  * @category filtering
5443
5441
  * @since 2.0.0
5444
5442
  */
5445
- const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some(self.value) : none());
5446
- /**
5447
- * Lifts a `Predicate` or `Refinement` into the `Option` context: returns
5448
- * `Some(value)` when the predicate holds, `None` otherwise.
5449
- *
5450
- * **When to use**
5451
- *
5452
- * Use to convert a boolean check into an `Option`-returning function
5453
- * - Validating input and wrapping it in `Option`
5454
- *
5455
- * **Details**
5456
- *
5457
- * - `predicate(value)` is `true` → `Some(value)`
5458
- * - `predicate(value)` is `false` → `None`
5459
- * - Supports refinements for type narrowing
5460
- *
5461
- * **Example** (Validating positive numbers)
5462
- *
5463
- * ```ts
5464
- * import { Option } from "effect"
5465
- *
5466
- * const parsePositive = Option.liftPredicate((n: number) => n > 0)
5467
- *
5468
- * console.log(parsePositive(1))
5469
- * // Output: { _id: 'Option', _tag: 'Some', value: 1 }
5470
- *
5471
- * console.log(parsePositive(-1))
5472
- * // Output: { _id: 'Option', _tag: 'None' }
5473
- * ```
5474
- *
5475
- * @see {@link filter} to apply a predicate to an existing `Option`
5476
- * @see {@link toRefinement} for the inverse direction
5477
- *
5478
- * @category lifting
5479
- * @since 2.0.0
5480
- */
5481
- const liftPredicate = /*#__PURE__*/ dual(2, (b, predicate) => predicate(b) ? some(b) : none());
5443
+ const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some$1(self.value) : none());
5482
5444
  //#endregion
5483
5445
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Result.js
5484
5446
  /**
@@ -5668,34 +5630,6 @@ const match$4 = /*#__PURE__*/ dual(2, (self, { onFailure, onSuccess }) => isFail
5668
5630
  //#endregion
5669
5631
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Tuple.js
5670
5632
  /**
5671
- * Creates a tuple from the provided arguments.
5672
- *
5673
- * **When to use**
5674
- *
5675
- * Use when you use this instead of `[a, b, c] as const` when you want a properly typed tuple
5676
- * without a manual cast.
5677
- *
5678
- * **Details**
5679
- *
5680
- * The returned value has the exact tuple type, with each element's literal type
5681
- * preserved.
5682
- *
5683
- * **Example** (Creating a tuple)
5684
- *
5685
- * ```ts
5686
- * import { Tuple } from "effect"
5687
- *
5688
- * const point = Tuple.make(10, 20, "red")
5689
- * console.log(point) // [10, 20, "red"]
5690
- * ```
5691
- *
5692
- * @see {@link get} – access a single element by index
5693
- * @see {@link appendElement} – append an element to a tuple
5694
- * @category constructors
5695
- * @since 2.0.0
5696
- */
5697
- const make$63 = (...elements) => elements;
5698
- /**
5699
5633
  * Creates an `Equivalence` for tuples by comparing corresponding elements
5700
5634
  * using the provided per-position `Equivalence`s. Two tuples are equivalent
5701
5635
  * when all their corresponding elements are equivalent.
@@ -5816,27 +5750,6 @@ const empty$14 = () => constEmpty;
5816
5750
  */
5817
5751
  const isEmptyRecord = (self) => Object.keys(self).length === 0;
5818
5752
  /**
5819
- * Takes a record and returns an array of tuples containing its keys and values.
5820
- *
5821
- * **Example** (Converting a record to entries)
5822
- *
5823
- * ```ts
5824
- * import { Record } from "effect"
5825
- * import * as assert from "node:assert"
5826
- *
5827
- * const x = { a: 1, b: 2, c: 3 }
5828
- * assert.deepStrictEqual(Record.toEntries(x), [["a", 1], ["b", 2], ["c", 3]])
5829
- * ```
5830
- *
5831
- * @category converting
5832
- * @since 2.0.0
5833
- */
5834
- const toEntries = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, f) => {
5835
- const out = [];
5836
- for (const key of keys(self)) out.push(f(key, self[key]));
5837
- return out;
5838
- }))((key, value) => [key, value]);
5839
- /**
5840
5753
  * Checks whether a given `key` exists in a record.
5841
5754
  *
5842
5755
  * **Example** (Checking key membership)
@@ -6386,7 +6299,7 @@ const headNonEmpty = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, index) => {
6386
6299
  * @category getters
6387
6300
  * @since 2.0.0
6388
6301
  */
6389
- const last = (self) => isReadonlyArrayNonEmpty(self) ? some(lastNonEmpty(self)) : none();
6302
+ const last = (self) => isReadonlyArrayNonEmpty(self) ? some$1(lastNonEmpty(self)) : none();
6390
6303
  /**
6391
6304
  * Returns the last element of a `NonEmptyReadonlyArray` directly (no `Option`
6392
6305
  * wrapper).
@@ -6433,6 +6346,45 @@ const lastNonEmpty = (self) => self[self.length - 1];
6433
6346
  */
6434
6347
  const tailNonEmpty = (self) => self.slice(1);
6435
6348
  /**
6349
+ * Takes elements from the start while the predicate holds, stopping at the
6350
+ * first element that fails.
6351
+ *
6352
+ * **When to use**
6353
+ *
6354
+ * Use to keep the leading elements of an iterable while each element satisfies
6355
+ * a predicate, returning the retained prefix as an array.
6356
+ *
6357
+ * **Details**
6358
+ *
6359
+ * - Supports refinements for type narrowing.
6360
+ * - The predicate receives `(element, index)`.
6361
+ *
6362
+ * **Example** (Taking while condition holds)
6363
+ *
6364
+ * ```ts
6365
+ * import { Array } from "effect"
6366
+ *
6367
+ * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2]
6368
+ * ```
6369
+ *
6370
+ * @see {@link take} for keeping a fixed number of leading elements
6371
+ * @see {@link dropWhile} for removing the matching prefix and keeping the rest
6372
+ * @see {@link span} for splitting the matching prefix from the remaining elements
6373
+ *
6374
+ * @category getters
6375
+ * @since 2.0.0
6376
+ */
6377
+ const takeWhile = /*#__PURE__*/ dual(2, (self, predicate) => {
6378
+ let i = 0;
6379
+ const out = [];
6380
+ for (const a of self) {
6381
+ if (!predicate(a, i)) break;
6382
+ out.push(a);
6383
+ i++;
6384
+ }
6385
+ return out;
6386
+ });
6387
+ /**
6436
6388
  * Removes the first `n` elements, creating a new array.
6437
6389
  *
6438
6390
  * **When to use**
@@ -6488,38 +6440,6 @@ const drop$1 = /*#__PURE__*/ dual(2, (self, n) => {
6488
6440
  */
6489
6441
  const reverse = (self) => Array$1.from(self).reverse();
6490
6442
  /**
6491
- * Sorts an array by the given `Order`, returning a new array.
6492
- *
6493
- * **When to use**
6494
- *
6495
- * Use to sort an array using a single `Order` comparator.
6496
- *
6497
- * **Details**
6498
- *
6499
- * - Preserves `NonEmptyArray` in the return type.
6500
- * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for
6501
- * multi-key sorting.
6502
- *
6503
- * **Example** (Sorting numbers)
6504
- *
6505
- * ```ts
6506
- * import { Array, Order } from "effect"
6507
- *
6508
- * console.log(Array.sort([3, 1, 4, 1, 5], Order.Number)) // [1, 1, 3, 4, 5]
6509
- * ```
6510
- *
6511
- * @see {@link sortWith} — sort by a mapping function
6512
- * @see {@link sortBy} — sort by multiple orders
6513
- *
6514
- * @category sorting
6515
- * @since 2.0.0
6516
- */
6517
- const sort = /*#__PURE__*/ dual(2, (self, O) => {
6518
- const out = Array$1.from(self);
6519
- out.sort(O);
6520
- return out;
6521
- });
6522
- /**
6523
6443
  * Sorts an array by a derived key using a mapping function and an `Order` for
6524
6444
  * that key.
6525
6445
  *
@@ -6754,6 +6674,28 @@ const flatMap$5 = /*#__PURE__*/ dual(2, (self, f) => {
6754
6674
  return out;
6755
6675
  });
6756
6676
  /**
6677
+ * Flattens a nested array of arrays into a single array.
6678
+ *
6679
+ * **When to use**
6680
+ *
6681
+ * Use to collapse one level of nested arrays when no per-element mapping is
6682
+ * needed.
6683
+ *
6684
+ * **Example** (Flattening nested arrays)
6685
+ *
6686
+ * ```ts
6687
+ * import { Array } from "effect"
6688
+ *
6689
+ * console.log(Array.flatten([[1, 2], [], [3, 4], [], [5, 6]])) // [1, 2, 3, 4, 5, 6]
6690
+ * ```
6691
+ *
6692
+ * @see {@link flatMap} — map then flatten in one step
6693
+ *
6694
+ * @category sequencing
6695
+ * @since 2.0.0
6696
+ */
6697
+ const flatten$3 = /*#__PURE__*/ flatMap$5(identity);
6698
+ /**
6757
6699
  * Extracts all `Some` values from an iterable of `Option`s, discarding `None`s.
6758
6700
  *
6759
6701
  * **When to use**
@@ -6810,43 +6752,6 @@ const getSuccesses = (self) => {
6810
6752
  return out;
6811
6753
  };
6812
6754
  /**
6813
- * Keeps transformed values for elements where a `Filter` succeeds.
6814
- *
6815
- * **When to use**
6816
- *
6817
- * Use to transform elements with a `Result`-returning filter while discarding
6818
- * failures.
6819
- *
6820
- * **Details**
6821
- *
6822
- * - The filter receives `(element, index)`.
6823
- * - Failures are discarded.
6824
- *
6825
- * **Example** (Filter and transform)
6826
- *
6827
- * ```ts
6828
- * import { Array, Result } from "effect"
6829
- *
6830
- * console.log(Array.filterMap([1, 2, 3, 4], (n) => n % 2 === 0 ? Result.succeed(n * 10) : Result.failVoid))
6831
- * // [20, 40]
6832
- * ```
6833
- *
6834
- * @see {@link filter} — keep original elements matching a predicate
6835
- * @see {@link partition} for keeping both failures and successes
6836
- *
6837
- * @category filtering
6838
- * @since 2.0.0
6839
- */
6840
- const filterMap$1 = /*#__PURE__*/ dual(2, (self, f) => {
6841
- const as = fromIterable$2(self);
6842
- const out = [];
6843
- for (let i = 0; i < as.length; i++) {
6844
- const result = f(as[i], i);
6845
- if (isSuccess$1(result)) out.push(result.success);
6846
- }
6847
- return out;
6848
- });
6849
- /**
6850
6755
  * Keeps only elements satisfying a predicate (or refinement).
6851
6756
  *
6852
6757
  * **When to use**
@@ -6929,6 +6834,26 @@ const reduce = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable$2(self).reduce
6929
6834
  */
6930
6835
  const every = /*#__PURE__*/ dual(2, (self, refinement) => self.every(refinement));
6931
6836
  /**
6837
+ * Checks whether at least one element satisfies the predicate. Narrows the type
6838
+ * to `NonEmptyReadonlyArray` on success.
6839
+ *
6840
+ * **Example** (Testing for any match)
6841
+ *
6842
+ * ```ts
6843
+ * import { Array } from "effect"
6844
+ *
6845
+ * console.log(Array.some([1, 3, 4], (x) => x % 2 === 0)) // true
6846
+ * console.log(Array.some([1, 3, 5], (x) => x % 2 === 0)) // false
6847
+ * ```
6848
+ *
6849
+ * @see {@link every} — test if all elements match
6850
+ * @see {@link contains} — test for a specific value
6851
+ *
6852
+ * @category elements
6853
+ * @since 2.0.0
6854
+ */
6855
+ const some = /*#__PURE__*/ dual(2, (self, predicate) => self.some(predicate));
6856
+ /**
6932
6857
  * Creates an `Equivalence` for arrays based on an element `Equivalence`. Two
6933
6858
  * arrays are equivalent when they have the same length and all elements are
6934
6859
  * pairwise equivalent.
@@ -6982,30 +6907,6 @@ const dedupeWith = /*#__PURE__*/ dual(2, (self, isEquivalent) => {
6982
6907
  return [];
6983
6908
  });
6984
6909
  /**
6985
- * Removes duplicates using `Equal.equivalence()`, preserving the order of the
6986
- * first occurrence.
6987
- *
6988
- * **When to use**
6989
- *
6990
- * Use to remove repeated values from an iterable when Effect's default equality
6991
- * is the right comparison, preserving the first occurrence.
6992
- *
6993
- * **Example** (Removing duplicates)
6994
- *
6995
- * ```ts
6996
- * import { Array } from "effect"
6997
- *
6998
- * console.log(Array.dedupe([1, 2, 1, 3, 2, 4])) // [1, 2, 3, 4]
6999
- * ```
7000
- *
7001
- * @see {@link dedupeWith} — use custom equality
7002
- * @see {@link dedupeAdjacent} — only dedupes consecutive elements
7003
- *
7004
- * @category elements
7005
- * @since 2.0.0
7006
- */
7007
- const dedupe = (self) => dedupeWith(self, asEquivalence());
7008
- /**
7009
6910
  * Joins string elements with a separator.
7010
6911
  *
7011
6912
  * **Example** (Joining strings)
@@ -7021,7 +6922,7 @@ const dedupe = (self) => dedupeWith(self, asEquivalence());
7021
6922
  * @category folding
7022
6923
  * @since 2.0.0
7023
6924
  */
7024
- const join$3 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$2(self).join(sep));
6925
+ const join$2 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$2(self).join(sep));
7025
6926
  //#endregion
7026
6927
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Effectable.js
7027
6928
  /**
@@ -7158,7 +7059,7 @@ const ServiceProto = {
7158
7059
  }
7159
7060
  };
7160
7061
  const ReferenceTypeId = "~effect/Context/Reference";
7161
- const TypeId$49 = "~effect/Context";
7062
+ const TypeId$48 = "~effect/Context";
7162
7063
  /**
7163
7064
  * Creates a `Context` from an existing service map without validating or
7164
7065
  * copying it.
@@ -7193,7 +7094,7 @@ const makeUnsafe$8 = (mapUnsafe) => {
7193
7094
  };
7194
7095
  const Proto$15 = {
7195
7096
  ...PipeInspectableProto,
7196
- [TypeId$49]: { _Services: (_) => _ },
7097
+ [TypeId$48]: { _Services: (_) => _ },
7197
7098
  toJSON() {
7198
7099
  return {
7199
7100
  _id: "Context",
@@ -7245,7 +7146,7 @@ const Proto$15 = {
7245
7146
  * @category guards
7246
7147
  * @since 2.0.0
7247
7148
  */
7248
- const isContext = (u) => hasProperty(u, TypeId$49);
7149
+ const isContext = (u) => hasProperty(u, TypeId$48);
7249
7150
  /**
7250
7151
  * Checks whether the provided argument is a `Reference`.
7251
7152
  *
@@ -7598,8 +7499,8 @@ const serviceNotFoundError = (service) => {
7598
7499
  * @since 2.0.0
7599
7500
  */
7600
7501
  const getOption = /*#__PURE__*/ dual(2, (self, service) => {
7601
- if (self.mapUnsafe.has(service.key)) return some(self.mapUnsafe.get(service.key));
7602
- return isReference(service) ? some(getDefaultValue(service)) : none();
7502
+ if (self.mapUnsafe.has(service.key)) return some$1(self.mapUnsafe.get(service.key));
7503
+ return isReference(service) ? some$1(getDefaultValue(service)) : none();
7603
7504
  });
7604
7505
  /**
7605
7506
  * Merges two `Context`s into one.
@@ -7749,7 +7650,7 @@ const withMapUnsafe = (self, f) => {
7749
7650
  const Reference = Service;
7750
7651
  //#endregion
7751
7652
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Duration.js
7752
- const TypeId$48 = "~effect/time/Duration";
7653
+ const TypeId$47 = "~effect/time/Duration";
7753
7654
  const bigint0$2 = /*#__PURE__*/ BigInt(0);
7754
7655
  const bigint1e3 = /*#__PURE__*/ BigInt(1e3);
7755
7656
  const bigint1e6 = /*#__PURE__*/ BigInt(1e6);
@@ -7808,7 +7709,7 @@ const fromInputUnsafe = (input) => {
7808
7709
  }
7809
7710
  case "object": {
7810
7711
  if (input === null) break;
7811
- if (TypeId$48 in input) return input;
7712
+ if (TypeId$47 in input) return input;
7812
7713
  if (Array.isArray(input)) {
7813
7714
  if (input.length !== 2 || !input.every(isNumber)) return invalid(input);
7814
7715
  if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$1;
@@ -7843,7 +7744,7 @@ const zeroDurationValue = {
7843
7744
  const infinityDurationValue = { _tag: "Infinity" };
7844
7745
  const negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
7845
7746
  const DurationProto = {
7846
- [TypeId$48]: TypeId$48,
7747
+ [TypeId$47]: TypeId$47,
7847
7748
  [symbol$3]() {
7848
7749
  return structure(this.value);
7849
7750
  },
@@ -7921,7 +7822,7 @@ const make$61 = (input) => {
7921
7822
  * @category guards
7922
7823
  * @since 2.0.0
7923
7824
  */
7924
- const isDuration = (u) => hasProperty(u, TypeId$48);
7825
+ const isDuration = (u) => hasProperty(u, TypeId$47);
7925
7826
  /**
7926
7827
  * Checks whether a Duration is finite (not infinite).
7927
7828
  *
@@ -9454,7 +9355,7 @@ const yieldNow$1 = /*#__PURE__*/ (/* @__PURE__ */ makePrimitive({
9454
9355
  }
9455
9356
  }))(0);
9456
9357
  /** @internal */
9457
- const succeedSome$1 = (a) => succeed$6(some(a));
9358
+ const succeedSome$1 = (a) => succeed$6(some$1(a));
9458
9359
  /** @internal */
9459
9360
  const succeedNone$1 = /*#__PURE__*/ succeed$6(/*#__PURE__*/ none());
9460
9361
  /** @internal */
@@ -9609,7 +9510,7 @@ const as$1 = /*#__PURE__*/ dual(2, (self, value) => {
9609
9510
  return flatMap$4(self, (_) => b);
9610
9511
  });
9611
9512
  /** @internal */
9612
- const asSome$1 = (self) => map$6(self, some);
9513
+ const asSome$1 = (self) => map$6(self, some$1);
9613
9514
  /** @internal */
9614
9515
  const andThen$1 = /*#__PURE__*/ dual(2, (self, f) => flatMap$4(self, (a) => isEffect$1(f) ? f : internalCall(() => f(a))));
9615
9516
  /** @internal */
@@ -9726,7 +9627,7 @@ const exitAsVoidAll = (exits) => {
9726
9627
  return failures.length === 0 ? exitVoid : exitFailCause(causeFromReasons(failures));
9727
9628
  };
9728
9629
  /** @internal */
9729
- const exitGetSuccess = (self) => exitIsSuccess(self) ? some(self.value) : none();
9630
+ const exitGetSuccess = (self) => exitIsSuccess(self) ? some$1(self.value) : none();
9730
9631
  /** @internal */
9731
9632
  const service$1 = (service) => service;
9732
9633
  /** @internal */
@@ -9770,7 +9671,7 @@ const provideServiceImpl = (self, service, implementation) => updateContext$1(se
9770
9671
  /** @internal */
9771
9672
  const when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$4(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
9772
9673
  /** @internal */
9773
- const forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9674
+ const forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9774
9675
  while: constTrue,
9775
9676
  body: constant(options?.disableYield ? self : flatMap$4(self, (_) => yieldNow$1)),
9776
9677
  step: constVoid
@@ -9853,7 +9754,7 @@ const ignore$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, option
9853
9754
  /** @internal */
9854
9755
  const option$2 = (self) => match$1(self, {
9855
9756
  onFailure: none,
9856
- onSuccess: some
9757
+ onSuccess: some$1
9857
9758
  });
9858
9759
  /** @internal */
9859
9760
  const result = (self) => matchEager(self, {
@@ -10160,7 +10061,7 @@ const findFirst$1 = /*#__PURE__*/ dual((args) => isIterable(args[0]) && !isEffec
10160
10061
  return succeed$6(none());
10161
10062
  }));
10162
10063
  const findFirstLoop = (iterator, index, predicate, value) => flatMap$4(predicate(value, index), (keep) => {
10163
- if (keep) return succeed$6(some(value));
10064
+ if (keep) return succeed$6(some$1(value));
10164
10065
  const next = iterator.next();
10165
10066
  if (!next.done) return findFirstLoop(iterator, index + 1, predicate, next.value);
10166
10067
  return succeed$6(none());
@@ -10494,12 +10395,12 @@ const NoopSpanProto = {
10494
10395
  const noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options);
10495
10396
  const filterDisablePropagation = (span) => {
10496
10397
  if (!span) return none();
10497
- return get$9(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some(span);
10398
+ return get$9(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some$1(span);
10498
10399
  };
10499
10400
  /** @internal */
10500
10401
  const makeSpanUnsafe = (fiber, name, options) => {
10501
10402
  const disablePropagation = !fiber.getRef(TracerEnabled$1) || options?.annotations && get$9(options.annotations, DisablePropagation);
10502
- const parent = options?.parent !== void 0 ? some(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.currentSpan);
10403
+ const parent = options?.parent !== void 0 ? some$1(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.currentSpan);
10503
10404
  let span;
10504
10405
  if (disablePropagation) span = noopSpan({
10505
10406
  name,
@@ -10798,7 +10699,7 @@ const reportCauseUnsafe = (fiber, cause, defectsOnly) => {
10798
10699
  };
10799
10700
  //#endregion
10800
10701
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Deferred.js
10801
- const TypeId$47 = "~effect/Deferred";
10702
+ const TypeId$46 = "~effect/Deferred";
10802
10703
  /**
10803
10704
  * Checks whether a value is a `Deferred`.
10804
10705
  *
@@ -10810,9 +10711,9 @@ const TypeId$47 = "~effect/Deferred";
10810
10711
  * @category guards
10811
10712
  * @since 4.0.0
10812
10713
  */
10813
- const isDeferred = (u) => hasProperty(u, TypeId$47);
10714
+ const isDeferred = (u) => hasProperty(u, TypeId$46);
10814
10715
  const DeferredProto = {
10815
- [TypeId$47]: {
10716
+ [TypeId$46]: {
10816
10717
  _A: identity,
10817
10718
  _E: identity
10818
10719
  },
@@ -11854,14 +11755,14 @@ const close = scopeClose;
11854
11755
  const closeUnsafe = scopeCloseUnsafe;
11855
11756
  //#endregion
11856
11757
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Layer.js
11857
- const TypeId$46 = "~effect/Layer";
11758
+ const TypeId$45 = "~effect/Layer";
11858
11759
  const MemoMapTypeId = "~effect/Layer/MemoMap";
11859
11760
  const memoMapReuse = (entry, scope) => {
11860
11761
  entry.observers++;
11861
11762
  return andThen$1(scopeAddFinalizerExit(scope, (exit) => entry.finalizer(exit)), entry.effect);
11862
11763
  };
11863
11764
  const LayerProto = {
11864
- [TypeId$46]: {
11765
+ [TypeId$45]: {
11865
11766
  _ROut: identity,
11866
11767
  _E: identity,
11867
11768
  _RIn: identity
@@ -13656,11 +13557,11 @@ const Clock = ClockRef;
13656
13557
  //#endregion
13657
13558
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/dateTime.js
13658
13559
  /** @internal */
13659
- const TypeId$45 = "~effect/time/DateTime";
13560
+ const TypeId$44 = "~effect/time/DateTime";
13660
13561
  /** @internal */
13661
13562
  const TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
13662
13563
  const Proto$14 = {
13663
- [TypeId$45]: TypeId$45,
13564
+ [TypeId$44]: TypeId$44,
13664
13565
  pipe() {
13665
13566
  return pipeArguments(this, arguments);
13666
13567
  },
@@ -13767,12 +13668,12 @@ const nextPow2 = (n) => {
13767
13668
  * @since 2.0.0
13768
13669
  */
13769
13670
  const parse$2 = (s) => {
13770
- if (s === "NaN") return some(NaN);
13771
- if (s === "Infinity") return some(Infinity);
13772
- if (s === "-Infinity") return some(-Infinity);
13671
+ if (s === "NaN") return some$1(NaN);
13672
+ if (s === "Infinity") return some$1(Infinity);
13673
+ if (s === "-Infinity") return some$1(-Infinity);
13773
13674
  if (s.trim() === "") return none();
13774
13675
  const n = Number$4(s);
13775
- return Number$4.isNaN(n) ? none() : some(n);
13676
+ return Number$4.isNaN(n) ? none() : some$1(n);
13776
13677
  };
13777
13678
  globalThis.String;
13778
13679
  /**
@@ -13818,6 +13719,23 @@ const replace = (searchValue, replaceValue) => (self) => self.replace(searchValu
13818
13719
  */
13819
13720
  const trim = (self) => self.trim();
13820
13721
  /**
13722
+ * Checks whether a `string` is empty.
13723
+ *
13724
+ * **Example** (Checking for empty strings)
13725
+ *
13726
+ * ```ts
13727
+ * import { String } from "effect"
13728
+ * import * as assert from "node:assert"
13729
+ *
13730
+ * assert.deepStrictEqual(String.isEmpty(""), true)
13731
+ * assert.deepStrictEqual(String.isEmpty("a"), false)
13732
+ * ```
13733
+ *
13734
+ * @category predicates
13735
+ * @since 2.0.0
13736
+ */
13737
+ const isEmpty$1 = (self) => self.length === 0;
13738
+ /**
13821
13739
  * Checks whether a `string` is non-empty.
13822
13740
  *
13823
13741
  * **Example** (Checking for non-empty strings)
@@ -13906,76 +13824,6 @@ const endsWith = (searchString, position) => (self) => self.endsWith(searchStrin
13906
13824
  * @since 2.0.0
13907
13825
  */
13908
13826
  const replaceAll = (searchValue, replaceValue) => (self) => self.replaceAll(searchValue, replaceValue);
13909
- const CR = 13;
13910
- const LF = 10;
13911
- /**
13912
- * Returns an `IterableIterator` which yields each line contained within the
13913
- * string, trimming off the trailing newline character.
13914
- *
13915
- * **Example** (Iterating lines without separators)
13916
- *
13917
- * ```ts
13918
- * import { String } from "effect"
13919
- *
13920
- * const lines = String.linesIterator("hello\nworld\n")
13921
- * console.log(Array.from(lines)) // ["hello", "world"]
13922
- * ```
13923
- *
13924
- * @category splitting
13925
- * @since 2.0.0
13926
- */
13927
- const linesIterator = (self) => linesSeparated(self, true);
13928
- var LinesIterator = class LinesIterator {
13929
- index;
13930
- length;
13931
- s;
13932
- stripped;
13933
- constructor(s, stripped = false) {
13934
- this.s = s;
13935
- this.stripped = stripped;
13936
- this.index = 0;
13937
- this.length = s.length;
13938
- }
13939
- next() {
13940
- if (this.done) return {
13941
- done: true,
13942
- value: void 0
13943
- };
13944
- const start = this.index;
13945
- while (!this.done && !isLineBreak(this.s[this.index])) this.index = this.index + 1;
13946
- let end = this.index;
13947
- if (!this.done) {
13948
- const char = this.s[this.index];
13949
- this.index = this.index + 1;
13950
- if (!this.done && isLineBreak2(char, this.s[this.index])) this.index = this.index + 1;
13951
- if (!this.stripped) end = this.index;
13952
- }
13953
- return {
13954
- done: false,
13955
- value: this.s.substring(start, end)
13956
- };
13957
- }
13958
- [Symbol.iterator]() {
13959
- return new LinesIterator(this.s, this.stripped);
13960
- }
13961
- get done() {
13962
- return this.index >= this.length;
13963
- }
13964
- };
13965
- /**
13966
- * Checks whether the provided character is a line break character (i.e. either `"\r"`
13967
- * or `"\n"`).
13968
- */
13969
- const isLineBreak = (char) => {
13970
- const code = char.charCodeAt(0);
13971
- return code === CR || code === LF;
13972
- };
13973
- /**
13974
- * Checks whether the provided characters combine to form a carriage return/line-feed
13975
- * (i.e. `"\r\n"`).
13976
- */
13977
- const isLineBreak2 = (char0, char1) => char0.charCodeAt(0) === CR && char1.charCodeAt(0) === LF;
13978
- const linesSeparated = (self, stripped) => new LinesIterator(self, stripped);
13979
13827
  //#endregion
13980
13828
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/random.js
13981
13829
  /** @internal */
@@ -14158,434 +14006,10 @@ const matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$
14158
14006
  }
14159
14007
  }));
14160
14008
  //#endregion
14161
- //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Schedule.js
14162
- /**
14163
- * Declarative policies for retrying, repeating, and pacing Effect programs.
14164
- *
14165
- * A `Schedule<Output, Input, Error, Env>` is a stateful policy that is stepped
14166
- * with an input value. Each step either stops the recurrence or emits an output
14167
- * together with the delay before the next step. Schedules are values: they can
14168
- * be transformed, combined, and passed to retry, repeat, stream, and channel
14169
- * APIs without running anything until the surrounding Effect program runs.
14170
- *
14171
- * **Mental model**
14172
- *
14173
- * - Constructors such as {@link recurs}, {@link spaced}, {@link fixed},
14174
- * {@link exponential}, and {@link fibonacci} define the base cadence or
14175
- * stopping rule.
14176
- * - Combinators such as {@link both}, {@link either}, and {@link andThen}
14177
- * combine schedules and determine both stopping behavior and output shape.
14178
- * - Delay helpers such as {@link addDelay}, {@link modifyDelay}, and
14179
- * {@link jittered} adjust pacing while preserving the schedule's control
14180
- * flow.
14181
- * - Metadata-aware constructors and {@link CurrentMetadata} expose attempts,
14182
- * elapsed time, input, output, and duration for advanced policies.
14183
- *
14184
- * **Common tasks**
14185
- *
14186
- * - Retry a failing effect with exponential backoff and a maximum retry count.
14187
- * - Repeat a successful effect on a fixed or spaced interval.
14188
- * - Add jitter so concurrent clients do not retry at the same instant.
14189
- * - Transform or retain schedule outputs with {@link map},
14190
- * {@link collectOutputs}, and {@link take}.
14191
- *
14192
- * **Example** (Retrying with bounded exponential backoff)
14193
- *
14194
- * ```ts
14195
- * import { Effect, Schedule } from "effect"
14196
- *
14197
- * let attempts = 0
14198
- *
14199
- * const request = Effect.sync(() => {
14200
- * attempts += 1
14201
- * return attempts
14202
- * }).pipe(
14203
- * Effect.flatMap((attempt) =>
14204
- * attempt < 3 ? Effect.fail("temporary failure") : Effect.succeed("ok")
14205
- * )
14206
- * )
14207
- *
14208
- * const policy = Schedule.exponential("100 millis").pipe(
14209
- * Schedule.jittered,
14210
- * Schedule.both(Schedule.recurs(5))
14211
- * )
14212
- *
14213
- * const program = Effect.retry(request, policy)
14214
- * ```
14215
- *
14216
- * **Gotchas**
14217
- *
14218
- * - A schedule is a description; delays happen only when an operation such as
14219
- * `Effect.retry` or `Effect.repeat` runs it.
14220
- * - `Schedule.recurs(3)` allows three recurrences in addition to the first run
14221
- * performed by retry or repeat.
14222
- * - Combining schedules changes the output type as well as the stopping rule,
14223
- * so check the resulting type when using {@link both}, {@link either}, or
14224
- * {@link andThen}.
14225
- *
14226
- * @since 2.0.0
14227
- */
14228
- const TypeId$44 = "~effect/Schedule";
14229
- /**
14230
- * Context reference containing metadata for the currently running schedule step.
14231
- *
14232
- * **Details**
14233
- *
14234
- * Repeat, retry, stream, and channel scheduling operations provide this service
14235
- * to effects run between schedule steps. The default value contains undefined
14236
- * input and output values, zero duration, and zeroed timing fields before any
14237
- * schedule step has produced metadata.
14238
- *
14239
- * @category metadata
14240
- * @since 4.0.0
14241
- */
14242
- const CurrentMetadata = /*#__PURE__*/ Reference("effect/Schedule/CurrentMetadata", { defaultValue: /*#__PURE__*/ constant({
14243
- input: void 0,
14244
- output: void 0,
14245
- duration: zero$1,
14246
- attempt: 0,
14247
- start: 0,
14248
- now: 0,
14249
- elapsed: 0,
14250
- elapsedSincePrevious: 0
14251
- }) });
14252
- const ScheduleProto = {
14253
- [TypeId$44]: {
14254
- _Out: identity,
14255
- _In: identity,
14256
- _Env: identity
14257
- },
14258
- pipe() {
14259
- return pipeArguments(this, arguments);
14260
- }
14261
- };
14262
- /**
14263
- * Type guard that checks if a value is a Schedule.
14264
- *
14265
- * **Example** (Checking for schedules)
14266
- *
14267
- * ```ts
14268
- * import { Schedule } from "effect"
14269
- *
14270
- * const schedule = Schedule.exponential("100 millis")
14271
- * const notSchedule = { foo: "bar" }
14272
- *
14273
- * console.log(Schedule.isSchedule(schedule)) // true
14274
- * console.log(Schedule.isSchedule(notSchedule)) // false
14275
- * console.log(Schedule.isSchedule(null)) // false
14276
- * console.log(Schedule.isSchedule(undefined)) // false
14277
- * ```
14278
- *
14279
- * @category guards
14280
- * @since 2.0.0
14281
- */
14282
- const isSchedule = (u) => hasProperty(u, TypeId$44);
14283
- /**
14284
- * Creates a Schedule from a step function that returns a Pull.
14285
- *
14286
- * **Example** (Creating a custom schedule from a step function)
14287
- *
14288
- * ```ts
14289
- * import { Cause, Duration, Effect, Schedule } from "effect"
14290
- *
14291
- * const schedule = Schedule.fromStep(Effect.sync(() => {
14292
- * let count = 0
14293
- *
14294
- * return (_now: number, _input: string) => {
14295
- * if (count >= 3) {
14296
- * return Cause.done(count)
14297
- * }
14298
- * return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
14299
- * }
14300
- * }))
14301
- * ```
14302
- *
14303
- * @category constructors
14304
- * @since 4.0.0
14305
- */
14306
- const fromStep = (step) => {
14307
- const self = Object.create(ScheduleProto);
14308
- self.step = step;
14309
- return self;
14310
- };
14311
- const metadataFn = () => {
14312
- let n = 0;
14313
- let previous;
14314
- let start;
14315
- return (now, input) => {
14316
- if (start === void 0) start = now;
14317
- const elapsed = now - start;
14318
- const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
14319
- previous = now;
14320
- return {
14321
- input,
14322
- attempt: ++n,
14323
- start,
14324
- now,
14325
- elapsed,
14326
- elapsedSincePrevious
14327
- };
14328
- };
14329
- };
14330
- /**
14331
- * Creates a Schedule from a step function that receives metadata about the schedule's execution.
14332
- *
14333
- * **Example** (Creating a metadata-aware schedule)
14334
- *
14335
- * ```ts
14336
- * import { Cause, Duration, Effect, Schedule } from "effect"
14337
- *
14338
- * const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
14339
- * if (metadata.attempt > 3) {
14340
- * return Cause.done("finished")
14341
- * }
14342
- *
14343
- * return Effect.succeed([
14344
- * `attempt ${metadata.attempt}: ${metadata.input}`,
14345
- * Duration.millis(250)
14346
- * ] as [string, Duration.Duration])
14347
- * }))
14348
- * ```
14349
- *
14350
- * @category constructors
14351
- * @since 4.0.0
14352
- */
14353
- const fromStepWithMetadata = (step) => fromStep(map$6(step, (f) => {
14354
- const meta = metadataFn();
14355
- return (now, input) => f(meta(now, input));
14356
- }));
14357
- /**
14358
- * Extracts the step function from a Schedule.
14359
- *
14360
- * **Example** (Extracting a schedule step function)
14361
- *
14362
- * ```ts
14363
- * import { Effect, Schedule } from "effect"
14364
- *
14365
- * // Extract step function from an existing schedule
14366
- * const schedule = Schedule.exponential("100 millis").pipe(Schedule.take(3))
14367
- *
14368
- * const program = Effect.gen(function*() {
14369
- * const stepFn = yield* Schedule.toStep(schedule)
14370
- *
14371
- * // Use the step function directly for custom logic. The timestamp is
14372
- * // supplied by the caller, so tests can pass a deterministic value.
14373
- * const now = 0
14374
- * const result = yield* stepFn(now, "input")
14375
- *
14376
- * console.log(`Step result: ${result}`)
14377
- * })
14378
- * ```
14379
- *
14380
- * @category destructors
14381
- * @since 4.0.0
14382
- */
14383
- const toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$6(() => failCause$5(cause)));
14384
- /**
14385
- * Extracts a step function from a `Schedule` that sleeps for each computed
14386
- * delay and returns metadata for the completed step.
14387
- *
14388
- * **When to use**
14389
- *
14390
- * Use to drive a schedule manually while preserving the computed output,
14391
- * delay, input, attempt, and elapsed timing metadata for each step.
14392
- *
14393
- * **Details**
14394
- *
14395
- * The returned step reads the current time from `Clock` when invoked, calls the
14396
- * schedule step with that timestamp and input, sleeps for the returned
14397
- * duration, and then yields `Metadata`.
14398
- *
14399
- * @see {@link toStep} for manually supplying the timestamp and handling the returned delay yourself
14400
- * @see {@link toStepWithSleep} for the same automatic sleeping behavior when only the schedule output is needed
14401
- *
14402
- * @category destructors
14403
- * @since 4.0.0
14404
- */
14405
- const toStepWithMetadata = (schedule) => clockWith$1((clock) => map$6(toStep(schedule), (step) => {
14406
- const metaFn = metadataFn();
14407
- return (input) => suspend$3(() => {
14408
- const now = clock.currentTimeMillisUnsafe();
14409
- return flatMap$4(step(now, input), ([output, duration]) => {
14410
- const meta = metaFn(now, input);
14411
- meta.output = output;
14412
- meta.duration = duration;
14413
- return as$1(sleep$1(duration), meta);
14414
- });
14415
- });
14416
- }));
14417
- /**
14418
- * Returns a new `Schedule` that outputs the inputs of the specified schedule.
14419
- *
14420
- * **Example** (Passing inputs through as outputs)
14421
- *
14422
- * ```ts
14423
- * import { Console, Effect, Schedule } from "effect"
14424
- *
14425
- * // Create a schedule that outputs the inputs instead of original outputs
14426
- * const inputSchedule = Schedule.passthrough(
14427
- * Schedule.exponential("100 millis").pipe(Schedule.take(3))
14428
- * )
14429
- *
14430
- * const program = Effect.gen(function*() {
14431
- * let counter = 0
14432
- * yield* Effect.repeat(
14433
- * Effect.gen(function*() {
14434
- * counter++
14435
- * yield* Console.log(`Task ${counter} executed`)
14436
- * return `result-${counter}`
14437
- * }),
14438
- * inputSchedule
14439
- * )
14440
- * })
14441
- * ```
14442
- *
14443
- * @category mapping
14444
- * @since 2.0.0
14445
- */
14446
- const passthrough$2 = (self) => fromStep(map$6(toStep(self), (step) => (now, input) => matchEffect$1(step(now, input), {
14447
- onSuccess: (result) => succeed$6([input, result[1]]),
14448
- onFailure: failCause$5,
14449
- onDone: () => done(input)
14450
- })));
14451
- /**
14452
- * Returns a schedule that recurs continuously, each repetition spaced the
14453
- * specified duration from the last run.
14454
- *
14455
- * **When to use**
14456
- *
14457
- * Use when each delay should start after the previous action
14458
- * completes. Use `fixed` when recurrences should stay aligned to a regular
14459
- * cadence.
14460
- *
14461
- * **Example** (Repeating with fixed spacing)
14462
- *
14463
- * ```ts
14464
- * import { Console, Effect, Schedule } from "effect"
14465
- *
14466
- * // Basic spaced schedule - runs every 2 seconds
14467
- * const everyTwoSeconds = Schedule.spaced("2 seconds")
14468
- *
14469
- * // Heartbeat that runs indefinitely with fixed spacing
14470
- * const heartbeat = Effect.gen(function*() {
14471
- * yield* Console.log("Heartbeat")
14472
- * }).pipe(
14473
- * Effect.repeat(everyTwoSeconds)
14474
- * )
14475
- *
14476
- * // Limited repeat - run only 5 times with 1-second spacing
14477
- * const limitedTask = Effect.gen(function*() {
14478
- * yield* Console.log("Executing scheduled task...")
14479
- * yield* Effect.sleep("500 millis") // simulate work
14480
- * return "Task completed"
14481
- * }).pipe(
14482
- * Effect.repeat(
14483
- * Schedule.spaced("1 second").pipe(Schedule.take(5))
14484
- * )
14485
- * )
14486
- *
14487
- * // Simple spaced schedule with limited repetitions
14488
- * const limitedSpaced = Schedule.spaced("100 millis").pipe(
14489
- * Schedule.both(Schedule.recurs(5)) // at most 5 times
14490
- * )
14491
- *
14492
- * const program = Effect.gen(function*() {
14493
- * yield* Console.log("Starting spaced execution...")
14494
- *
14495
- * yield* Effect.repeat(
14496
- * Effect.succeed("work item"),
14497
- * limitedSpaced
14498
- * )
14499
- *
14500
- * yield* Console.log("Completed executions")
14501
- * })
14502
- * ```
14503
- *
14504
- * @see {@link fixed} for recurrence aligned to a regular cadence
14505
- *
14506
- * @category constructors
14507
- * @since 2.0.0
14508
- */
14509
- const spaced = (duration) => {
14510
- const decoded = fromInputUnsafe(duration);
14511
- return fromStepWithMetadata(succeed$6((meta) => succeed$6([meta.attempt - 1, decoded])));
14512
- };
14513
- const while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$6(toStep(self), (step) => {
14514
- const meta = metadataFn();
14515
- return (now, input) => flatMap$4(step(now, input), (result) => {
14516
- const [output, duration] = result;
14517
- const eff = predicate({
14518
- ...meta(now, input),
14519
- output,
14520
- duration
14521
- });
14522
- return flatMap$4(isEffect$1(eff) ? eff : succeed$6(eff), (check) => check ? succeed$6(result) : done(output));
14523
- });
14524
- })));
14525
- /**
14526
- * Returns a new `Schedule` that will recur forever.
14527
- *
14528
- * **Details**
14529
- *
14530
- * The output of the schedule is the current count of its repetitions thus far
14531
- * (i.e. `0, 1, 2, ...`).
14532
- *
14533
- * **Example** (Repeating forever)
14534
- *
14535
- * ```ts
14536
- * import { Console, Effect, Schedule } from "effect"
14537
- *
14538
- * // A schedule that runs forever with no delay
14539
- * const infiniteSchedule = Schedule.forever
14540
- *
14541
- * const program = Effect.gen(function*() {
14542
- * yield* Effect.repeat(
14543
- * Effect.gen(function*() {
14544
- * yield* Console.log("Running forever...")
14545
- * return "continuous-task"
14546
- * }),
14547
- * infiniteSchedule.pipe(Schedule.take(5)) // Limit for demo
14548
- * )
14549
- * })
14550
- * ```
14551
- *
14552
- * @category constructors
14553
- * @since 2.0.0
14554
- */
14555
- const forever$1 = /*#__PURE__*/ spaced(zero$1);
14556
- //#endregion
14557
14009
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/layer.js
14558
14010
  const provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$4(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$3(self, context)));
14559
14011
  /** @internal */
14560
14012
  const provide$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, source, options) => isContext(source) ? provideContext$3(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll$1(...source) : source, options));
14561
- //#endregion
14562
- //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/schedule.js
14563
- /** @internal */
14564
- const repeatOrElse = /*#__PURE__*/ dual(3, (self, schedule, orElse) => flatMap$4(toStepWithMetadata(schedule), (step) => {
14565
- let meta = CurrentMetadata.defaultValue();
14566
- return catch_$3(forever$2(tap$1(flatMap$4(suspend$3(() => provideService$1(self, CurrentMetadata, meta)), step), (meta_) => sync$1(() => {
14567
- meta = meta_;
14568
- })), { disableYield: true }), (error) => isDone$2(error) ? succeed$6(error.value) : orElse(error, meta.attempt === 0 ? none() : some(meta)));
14569
- }));
14570
- /** @internal */
14571
- const repeat$1 = /*#__PURE__*/ dual(2, (self, options) => {
14572
- return repeatOrElse(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$6);
14573
- });
14574
- const passthroughForever = /*#__PURE__*/ passthrough$2(forever$1);
14575
- /** @internal */
14576
- const buildFromOptions = (options) => {
14577
- let schedule = options.schedule ? passthrough$2(options.schedule) : passthroughForever;
14578
- if (options.while) schedule = while_(schedule, ({ input }) => {
14579
- const applied = options.while(input);
14580
- return isEffect$1(applied) ? applied : succeed$6(applied);
14581
- });
14582
- if (options.until) schedule = while_(schedule, ({ input }) => {
14583
- const applied = options.until(input);
14584
- return isEffect$1(applied) ? map$6(applied, (b) => !b) : succeed$6(!applied);
14585
- });
14586
- if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$6(attempt <= options.times));
14587
- return schedule;
14588
- };
14589
14013
  /**
14590
14014
  * Context reference for the metric registry in the current context.
14591
14015
  *
@@ -17696,84 +17120,7 @@ const interruptibleMask = interruptibleMask$1;
17696
17120
  * @category repetition
17697
17121
  * @since 2.0.0
17698
17122
  */
17699
- const forever = forever$2;
17700
- /**
17701
- * Repeats an effect based on a specified schedule or until the first failure.
17702
- *
17703
- * **When to use**
17704
- *
17705
- * Use to rerun an effect after successful executions.
17706
- *
17707
- * **Details**
17708
- *
17709
- * This function executes an effect repeatedly according to the given schedule.
17710
- * Each repetition occurs after the initial execution of the effect, meaning
17711
- * that the schedule determines the number of additional repetitions. For
17712
- * example, using `Schedule.once` will result in the effect being executed twice
17713
- * (once initially and once as part of the repetition).
17714
- *
17715
- * If the effect succeeds, it is repeated according to the schedule. If it
17716
- * fails, the repetition stops immediately, and the failure is returned.
17717
- *
17718
- * The schedule can also specify delays between repetitions, making it useful
17719
- * for tasks like retrying operations with backoff, periodic execution, or
17720
- * performing a series of dependent actions.
17721
- *
17722
- * You can combine schedules for more advanced repetition logic, such as adding
17723
- * delays, limiting recursions, or dynamically adjusting based on the outcome of
17724
- * each execution.
17725
- *
17726
- * **Gotchas**
17727
- *
17728
- * The source effect is always evaluated once before the schedule is stepped.
17729
- * The schedule controls additional repetitions, not the initial execution.
17730
- *
17731
- * **Example** (Repeating successful effects with a schedule)
17732
- *
17733
- * ```ts
17734
- * // Success Example
17735
- * import { Console, Effect, Schedule } from "effect"
17736
- *
17737
- * const action = Console.log("success")
17738
- * const policy = Schedule.addDelay(Schedule.recurs(2), () => Effect.succeed("100 millis"))
17739
- * const program = Effect.repeat(action, policy)
17740
- *
17741
- * // Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
17742
- * ```
17743
- *
17744
- * **Example** (Stopping repetition on failure)
17745
- *
17746
- * ```ts
17747
- * // Failure Example
17748
- * import { Effect, Schedule } from "effect"
17749
- *
17750
- * let count = 0
17751
- *
17752
- * // Define a callback effect that simulates an action with possible failures
17753
- * const action = Effect.callback<string, string>((resume) => {
17754
- * if (count > 1) {
17755
- * console.log("failure")
17756
- * resume(Effect.fail("Uh oh!"))
17757
- * } else {
17758
- * count++
17759
- * console.log("success")
17760
- * resume(Effect.succeed("yay!"))
17761
- * }
17762
- * })
17763
- *
17764
- * const policy = Schedule.addDelay(Schedule.recurs(2), () => Effect.succeed("100 millis"))
17765
- * const program = Effect.repeat(action, policy)
17766
- *
17767
- * // Effect.runPromiseExit(program).then(console.log)
17768
- * ```
17769
- *
17770
- * @see {@link retry} for failure-based repetition
17771
- * @see {@link repeatOrElse} for fallback handling when repetition fails
17772
- *
17773
- * @category repetition
17774
- * @since 2.0.0
17775
- */
17776
- const repeat = repeat$1;
17123
+ const forever = forever$1;
17777
17124
  /**
17778
17125
  * Create a new span for tracing, and automatically close it when the effect
17779
17126
  * completes.
@@ -19406,14 +18753,14 @@ var OneOf = class extends Base$1 {
19406
18753
  };
19407
18754
  function makeFilterIssue(input, entry) {
19408
18755
  if (isIssue(entry)) return entry;
19409
- if (typeof entry === "string") return new InvalidValue(some(input), { message: entry });
19410
- const inner = typeof entry.issue === "string" ? new InvalidValue(some(input), { message: entry.issue }) : entry.issue;
18756
+ if (typeof entry === "string") return new InvalidValue(some$1(input), { message: entry });
18757
+ const inner = typeof entry.issue === "string" ? new InvalidValue(some$1(input), { message: entry.issue }) : entry.issue;
19411
18758
  return new Pointer(entry.path, inner);
19412
18759
  }
19413
18760
  /** @internal */
19414
18761
  function makeSingle(input, out) {
19415
18762
  if (out === void 0) return;
19416
- if (typeof out === "boolean") return out ? void 0 : new InvalidValue(some(input));
18763
+ if (typeof out === "boolean") return out ? void 0 : new InvalidValue(some$1(input));
19417
18764
  return makeFilterIssue(input, out);
19418
18765
  }
19419
18766
  /** @internal */
@@ -19421,7 +18768,7 @@ function make$55(input, ast, out) {
19421
18768
  if (Array.isArray(out)) {
19422
18769
  if (isReadonlyArrayNonEmpty(out)) {
19423
18770
  if (out.length === 1) return makeFilterIssue(input, out[0]);
19424
- return new Composite(ast, some(input), map$7(out, (entry) => makeFilterIssue(input, entry)));
18771
+ return new Composite(ast, some$1(input), map$7(out, (entry) => makeFilterIssue(input, entry)));
19425
18772
  }
19426
18773
  return;
19427
18774
  }
@@ -19898,7 +19245,7 @@ function transformOptional(f) {
19898
19245
  function withDefault$1(defaultValue) {
19899
19246
  return new Getter((o) => {
19900
19247
  const filtered = filter$3(o, isNotUndefined);
19901
- return isSome(filtered) ? succeed$3(filtered) : mapEager(defaultValue, some);
19248
+ return isSome(filtered) ? succeed$3(filtered) : mapEager(defaultValue, some$1);
19902
19249
  });
19903
19250
  }
19904
19251
  /**
@@ -19961,8 +19308,8 @@ function Number$3() {
19961
19308
  }
19962
19309
  function parseJson(options) {
19963
19310
  return onSome((input) => try_({
19964
- try: () => some(JSON.parse(input, options?.reviver)),
19965
- catch: (e) => new InvalidValue(some(input), { message: globalThis.String(e) })
19311
+ try: () => some$1(JSON.parse(input, options?.reviver)),
19312
+ catch: (e) => new InvalidValue(some$1(input), { message: globalThis.String(e) })
19966
19313
  }));
19967
19314
  }
19968
19315
  /**
@@ -19999,8 +19346,8 @@ function parseJson(options) {
19999
19346
  */
20000
19347
  function stringifyJson(options) {
20001
19348
  return onSome((input) => try_({
20002
- try: () => some(JSON.stringify(input, options?.replacer, options?.space)),
20003
- catch: (e) => new InvalidValue(some(input), { message: globalThis.String(e) })
19349
+ try: () => some$1(JSON.stringify(input, options?.replacer, options?.space)),
19350
+ catch: (e) => new InvalidValue(some$1(input), { message: globalThis.String(e) })
20004
19351
  }));
20005
19352
  }
20006
19353
  /**
@@ -20318,7 +19665,7 @@ const abs = (n) => n.value < bigint0 ? make$54(-n.value, n.scale) : n;
20318
19665
  * @category instances
20319
19666
  * @since 2.0.0
20320
19667
  */
20321
- const Equivalence$2 = /*#__PURE__*/ make$65((self, that) => {
19668
+ const Equivalence$2 = /*#__PURE__*/ make$64((self, that) => {
20322
19669
  if (self.scale > that.scale) return scale(that, self.scale).value === self.value;
20323
19670
  if (self.scale < that.scale) return scale(self, that.scale).value === that.value;
20324
19671
  return self.value === that.value;
@@ -21019,7 +20366,7 @@ var Declaration = class Declaration extends Base {
21019
20366
  const run = this.run(this.typeParameters);
21020
20367
  return (oinput, options) => {
21021
20368
  if (isNone(oinput)) return succeedNone;
21022
- return mapEager(run(oinput.value, this, options), some);
20369
+ return mapEager(run(oinput.value, this, options), some$1);
21023
20370
  };
21024
20371
  }
21025
20372
  /** @internal */
@@ -21510,7 +20857,7 @@ var Arrays = class Arrays extends Base {
21510
20857
  else return yield* fail$3(new Composite(ast, oinput, [issue]));
21511
20858
  }
21512
20859
  if (state.issues) return yield* fail$3(new Composite(ast, oinput, state.issues));
21513
- return some(state.output);
20860
+ return some$1(state.output);
21514
20861
  });
21515
20862
  }
21516
20863
  /** @internal */
@@ -21526,7 +20873,7 @@ var Arrays = class Arrays extends Base {
21526
20873
  };
21527
20874
  const parseArray = /*#__PURE__*/ iterateEager()({
21528
20875
  onItem(s, item, i) {
21529
- const value = i < s.len ? some(item) : none();
20876
+ const value = i < s.len ? some$1(item) : none();
21530
20877
  return s.getParser(s.tailThreshold, i).parser(value, s.options);
21531
20878
  },
21532
20879
  step(s, _, exit, i) {
@@ -21730,14 +21077,14 @@ var Objects = class Objects extends Base {
21730
21077
  if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) return fromRefinement(ast, isNotNullish);
21731
21078
  const parseIndexes = indexCount > 0 ? iterateEager()({
21732
21079
  onItem: fnUntracedEager(function* (s, [key, is]) {
21733
- const effKey = recur(indexSignatureParameterFromString(is.parameter))(some(key), s.options);
21080
+ const effKey = recur(indexSignatureParameterFromString(is.parameter))(some$1(key), s.options);
21734
21081
  const exitKey = effectIsExit(effKey) ? effKey : yield* exit(effKey);
21735
21082
  if (exitKey._tag === "Failure") {
21736
21083
  const eff = wrapPropertyKeyIssue(s, ast, key, exitKey);
21737
21084
  if (eff) yield* eff;
21738
21085
  return;
21739
21086
  }
21740
- const value = some(s.input[key]);
21087
+ const value = some$1(s.input[key]);
21741
21088
  const effValue = recur(is.type)(value, s.options);
21742
21089
  const exitValue = effectIsExit(effValue) ? effValue : yield* exit(effValue);
21743
21090
  if (exitValue._tag === "Failure") {
@@ -21807,9 +21154,9 @@ var Objects = class Objects extends Base {
21807
21154
  const keys = (inputKeys ?? Reflect.ownKeys(input)).concat(expectedKeys);
21808
21155
  const preserved = {};
21809
21156
  for (const key of keys) if (Object.hasOwn(out, key)) set$7(preserved, key, out[key]);
21810
- return some(preserved);
21157
+ return some$1(preserved);
21811
21158
  }
21812
- return some(out);
21159
+ return some$1(out);
21813
21160
  });
21814
21161
  }
21815
21162
  rebuild(recur, flipMerge) {
@@ -21841,7 +21188,7 @@ var Objects = class Objects extends Base {
21841
21188
  };
21842
21189
  const parseProperties = /*#__PURE__*/ iterateEager()({
21843
21190
  onItem(s, p) {
21844
- const value = Object.hasOwn(s.input, p.name) ? some(s.input[p.name]) : none();
21191
+ const value = Object.hasOwn(s.input, p.name) ? some$1(s.input[p.name]) : none();
21845
21192
  return p.parser(value, s.options);
21846
21193
  },
21847
21194
  step(s, p, exit) {
@@ -22641,7 +21988,7 @@ function isJson(u) {
22641
21988
  }
22642
21989
  }
22643
21990
  /** @internal */
22644
- const Json = /*#__PURE__*/ new Declaration([], () => (input, ast) => isJson(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some(input))), {
21991
+ const Json = /*#__PURE__*/ new Declaration([], () => (input, ast) => isJson(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some$1(input))), {
22645
21992
  typeConstructor: { _tag: "effect/Json" },
22646
21993
  generation: {
22647
21994
  runtime: `Schema.Json`,
@@ -22674,7 +22021,7 @@ function isStringTree(u) {
22674
22021
  }
22675
22022
  }
22676
22023
  /** @internal */
22677
- const unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declaration([], () => (input, ast) => isStringTree(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some(input))), {
22024
+ const unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declaration([], () => (input, ast) => isStringTree(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some$1(input))), {
22678
22025
  expected: "StringTree",
22679
22026
  toCodecStringTree: () => new Link(unknown, passthrough())
22680
22027
  }), /*#__PURE__*/ passthrough());
@@ -22695,7 +22042,7 @@ const unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declarati
22695
22042
  */
22696
22043
  function nominal() {
22697
22044
  return Object.assign((input) => input, {
22698
- option: (input) => some(input),
22045
+ option: (input) => some$1(input),
22699
22046
  result: (input) => succeed$7(input),
22700
22047
  is: (_) => true
22701
22048
  });
@@ -22905,7 +22252,7 @@ const badArgument = (options) => new PlatformError(new BadArgument(options));
22905
22252
  * @category combinators
22906
22253
  * @since 2.0.0
22907
22254
  */
22908
- const join$2 = fiberJoin;
22255
+ const join$1 = fiberJoin;
22909
22256
  /**
22910
22257
  * Interrupts a fiber, causing it to stop executing and clean up any
22911
22258
  * acquired resources.
@@ -26505,7 +25852,7 @@ const fromIteratorArray = (iterator, chunkSize = DefaultChunkSize) => fromPull$1
26505
25852
  const state = iter.next();
26506
25853
  if (state.done) {
26507
25854
  if (buffer.length === 0) return done(state.value);
26508
- done$15 = some(state.value);
25855
+ done$15 = some$1(state.value);
26509
25856
  break;
26510
25857
  }
26511
25858
  buffer.push(state.value);
@@ -27114,7 +26461,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
27114
26461
  const fiber = runFork(f(value, i++));
27115
26462
  trackFiber(fiber);
27116
26463
  fiber.addObserver(onExit);
27117
- return offer(effects, join$2(fiber));
26464
+ return offer(effects, join$1(fiber));
27118
26465
  }), forever({ disableYield: true }), catchCause$1((cause) => offer(effects, failCause$3(cause)).pipe(andThen(failCause$1(effects, cause)))), forkIn(forkedScope));
27119
26466
  }
27120
26467
  return take$1(queue);
@@ -27587,7 +26934,7 @@ const splitLines$1 = () => fromTransform$1((upstream, _scope) => sync(() => {
27587
26934
  onSuccess: loop,
27588
26935
  onFailure: failCause$2,
27589
26936
  onDone: (leftover) => {
27590
- done$13 = some(leftover);
26937
+ done$13 = some$1(leftover);
27591
26938
  if (stringBuilder.length > 0 || midCRLF) {
27592
26939
  const last = stringBuilder;
27593
26940
  stringBuilder = "";
@@ -28159,10 +27506,10 @@ const empty$9 = () => {
28159
27506
  * @since 2.0.0
28160
27507
  */
28161
27508
  const get$7 = /*#__PURE__*/ dual(2, (self, key) => {
28162
- if (self.backing.has(key)) return some(self.backing.get(key));
27509
+ if (self.backing.has(key)) return some$1(self.backing.get(key));
28163
27510
  else if (isSimpleKey(key)) return none();
28164
27511
  const refKey = referentialKeysCache.get(self);
28165
- if (refKey !== void 0) return self.backing.has(refKey) ? some(self.backing.get(refKey)) : none();
27512
+ if (refKey !== void 0) return self.backing.has(refKey) ? some$1(self.backing.get(refKey)) : none();
28166
27513
  const hash$5 = hash(key);
28167
27514
  const bucket = self.buckets.get(hash$5);
28168
27515
  if (bucket === void 0) return none();
@@ -28174,7 +27521,7 @@ const getFromBucket = (self, bucket, key) => {
28174
27521
  for (let i = 0, len = bucket.length; i < len; i++) if (equals$2(key, bucket[i])) {
28175
27522
  const refKey = bucket[i];
28176
27523
  referentialKeysCache.set(key, refKey);
28177
- return some(self.backing.get(refKey));
27524
+ return some$1(self.backing.get(refKey));
28178
27525
  }
28179
27526
  return none();
28180
27527
  };
@@ -31970,7 +31317,7 @@ var LeafNode = class LeafNode extends Node {
31970
31317
  return 1;
31971
31318
  }
31972
31319
  get(_shift, hash, key) {
31973
- if (this.hash === hash && equals$2(this.key, key)) return some(this.value);
31320
+ if (this.hash === hash && equals$2(this.key, key)) return some$1(this.value);
31974
31321
  return none();
31975
31322
  }
31976
31323
  has(_shift, hash, key) {
@@ -32023,7 +31370,7 @@ var CollisionNode = class CollisionNode extends Node {
32023
31370
  }
32024
31371
  get(_shift, hash, key) {
32025
31372
  if (this.hash !== hash) return none();
32026
- for (const [k, v] of this.entries) if (equals$2(k, key)) return some(v);
31373
+ for (const [k, v] of this.entries) if (equals$2(k, key)) return some$1(v);
32027
31374
  return none();
32028
31375
  }
32029
31376
  has(_shift, hash, key) {
@@ -32876,29 +32223,6 @@ function decodeUnknownEffect$1(schema, options) {
32876
32223
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
32877
32224
  }
32878
32225
  /**
32879
- * Creates a synchronous decoder for `unknown` input.
32880
- *
32881
- * **When to use**
32882
- *
32883
- * Use to decode untrusted or dynamically typed input at a synchronous boundary
32884
- * where invalid data should be reported by throwing.
32885
- *
32886
- * **Details**
32887
- *
32888
- * The returned function returns the decoded `Type` on success and throws an
32889
- * `Error` with the `SchemaIssue.Issue` in its `cause` on decoding failure.
32890
- *
32891
- * @see {@link decodeSync} for input already typed as the schema's `Encoded` type
32892
- * @see {@link decodeUnknownEffect} for preserving decoding failures in `Effect`
32893
- * @see {@link decodeUnknownResult} for returning schema issues as data
32894
- *
32895
- * @category decoding
32896
- * @since 3.10.0
32897
- */
32898
- function decodeUnknownSync$1(schema, options) {
32899
- return asSync(decodeUnknownEffect$1(schema, options));
32900
- }
32901
- /**
32902
32226
  * Creates an effectful encoder for `unknown` input.
32903
32227
  *
32904
32228
  * **When to use**
@@ -32974,7 +32298,7 @@ const mergeParseOptions = (options, overrideOptions) => overrideOptions === void
32974
32298
  /** @internal */
32975
32299
  function run(ast) {
32976
32300
  const parser = recur$1(ast);
32977
- return (input, options) => flatMapEager(parser(some(input), options ?? defaultParseOptions), (oa) => {
32301
+ return (input, options) => flatMapEager(parser(some$1(input), options ?? defaultParseOptions), (oa) => {
32978
32302
  if (oa._tag === "None") return fail$3(new InvalidValue(oa));
32979
32303
  return succeed$3(oa.value);
32980
32304
  });
@@ -33204,7 +32528,7 @@ function declareConstructor() {
33204
32528
  * @since 3.10.0
33205
32529
  */
33206
32530
  function declare(is, annotations) {
33207
- return declareConstructor()([], () => (input, ast) => is(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some(input))), annotations);
32531
+ return declareConstructor()([], () => (input, ast) => is(input) ? succeed$3(input) : fail$3(new InvalidType(ast, some$1(input))), annotations);
33208
32532
  }
33209
32533
  /**
33210
32534
  * Returns `true` if `u` is a {@link SchemaError}.
@@ -33273,44 +32597,6 @@ function decodeUnknownEffect(schema, options) {
33273
32597
  */
33274
32598
  const decodeEffect = decodeUnknownEffect;
33275
32599
  /**
33276
- * Decodes an `unknown` input against a schema synchronously, returning the
33277
- * decoded value or throwing an `Error` whose cause contains the schema issue.
33278
- *
33279
- * **When to use**
33280
- *
33281
- * Use when validating unknown data at a boundary and treating schema mismatches
33282
- * as exceptions.
33283
- *
33284
- * **Details**
33285
- *
33286
- * For typed input use `decodeSync`.
33287
- * Only service-free schemas can be decoded synchronously. For non-throwing
33288
- * alternatives see `decodeUnknownOption`, `decodeUnknownExit`, or
33289
- * `decodeUnknownEffect`. Options may be provided either when creating the
33290
- * decoder or when applying it; application options override creation options.
33291
- *
33292
- * **Example** (Decoding with a transformation schema)
33293
- *
33294
- * ```ts
33295
- * import { Schema } from "effect"
33296
- *
33297
- * const NumberFromString = Schema.NumberFromString
33298
- *
33299
- * console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
33300
- * // Output: 42
33301
- *
33302
- * Schema.decodeUnknownSync(NumberFromString)("not a number")
33303
- * // throws SchemaError: NumberFromString
33304
- * // └─ Encoded side transformation failure
33305
- * // └─ NumberFromString
33306
- * // └─ Expected a numeric string, actual "not a number"
33307
- * ```
33308
- *
33309
- * @category decoding
33310
- * @since 4.0.0
33311
- */
33312
- const decodeUnknownSync = decodeUnknownSync$1;
33313
- /**
33314
32600
  * Encodes an `unknown` input against a schema, returning an `Effect` that
33315
32601
  * succeeds with the encoded value or fails with a {@link SchemaError}.
33316
32602
  *
@@ -34072,15 +33358,15 @@ function isInt(annotations) {
34072
33358
  */
34073
33359
  function CauseReason(error, defect) {
34074
33360
  return make$35(declareConstructor()([error, defect], ([error, defect]) => (input, ast, options) => {
34075
- if (!isReason(input)) return fail$3(new InvalidType(ast, some(input)));
33361
+ if (!isReason(input)) return fail$3(new InvalidType(ast, some$1(input)));
34076
33362
  switch (input._tag) {
34077
33363
  case "Fail": return mapBothEager(decodeUnknownEffect$1(error)(input.error, options), {
34078
33364
  onSuccess: makeFailReason,
34079
- onFailure: (issue) => new Composite(ast, some(input), [new Pointer(["error"], issue)])
33365
+ onFailure: (issue) => new Composite(ast, some$1(input), [new Pointer(["error"], issue)])
34080
33366
  });
34081
33367
  case "Die": return mapBothEager(decodeUnknownEffect$1(defect)(input.defect, options), {
34082
33368
  onSuccess: makeDieReason,
34083
- onFailure: (issue) => new Composite(ast, some(input), [new Pointer(["defect"], issue)])
33369
+ onFailure: (issue) => new Composite(ast, some$1(input), [new Pointer(["defect"], issue)])
34084
33370
  });
34085
33371
  case "Interrupt": return succeed$3(input);
34086
33372
  }
@@ -34175,10 +33461,10 @@ function Cause(error, defect) {
34175
33461
  return make$35(declareConstructor()([error, defect], ([error, defect]) => {
34176
33462
  const failures = ArraySchema(CauseReason(error, defect));
34177
33463
  return (input, ast, options) => {
34178
- if (!isCause(input)) return fail$3(new InvalidType(ast, some(input)));
33464
+ if (!isCause(input)) return fail$3(new InvalidType(ast, some$1(input)));
34179
33465
  return mapBothEager(decodeUnknownEffect$1(failures)(input.reasons, options), {
34180
33466
  onSuccess: fromReasons,
34181
- onFailure: (issue) => new Composite(ast, some(input), [new Pointer(["failures"], issue)])
33467
+ onFailure: (issue) => new Composite(ast, some$1(input), [new Pointer(["failures"], issue)])
34182
33468
  });
34183
33469
  };
34184
33470
  }, {
@@ -34282,15 +33568,15 @@ function Exit(value, error, defect) {
34282
33568
  ], ([value, error, defect]) => {
34283
33569
  const cause = Cause(error, defect);
34284
33570
  return (input, ast, options) => {
34285
- if (!isExit(input)) return fail$3(new InvalidType(ast, some(input)));
33571
+ if (!isExit(input)) return fail$3(new InvalidType(ast, some$1(input)));
34286
33572
  switch (input._tag) {
34287
33573
  case "Success": return mapBothEager(decodeUnknownEffect$1(value)(input.value, options), {
34288
33574
  onSuccess: succeed$5,
34289
- onFailure: (issue) => new Composite(ast, some(input), [new Pointer(["value"], issue)])
33575
+ onFailure: (issue) => new Composite(ast, some$1(input), [new Pointer(["value"], issue)])
34290
33576
  });
34291
33577
  case "Failure": return mapBothEager(decodeUnknownEffect$1(cause)(input.cause, options), {
34292
33578
  onSuccess: failCause$3,
34293
- onFailure: (issue) => new Composite(ast, some(input), [new Pointer(["cause"], issue)])
33579
+ onFailure: (issue) => new Composite(ast, some$1(input), [new Pointer(["cause"], issue)])
34294
33580
  });
34295
33581
  }
34296
33582
  };
@@ -34518,7 +33804,7 @@ function getClassSchemaFactory(from, identifier, annotations) {
34518
33804
  if (memo === void 0) {
34519
33805
  const transformation = getClassTransformation(self);
34520
33806
  const to = make$35(new Declaration([from.ast], () => (input, ast) => {
34521
- return input instanceof self || hasProperty(input, getClassTypeId(identifier)) ? succeed$3(input) : fail$3(new InvalidType(ast, some(input)));
33807
+ return input instanceof self || hasProperty(input, getClassTypeId(identifier)) ? succeed$3(input) : fail$3(new InvalidType(ast, some$1(input)));
34522
33808
  }, {
34523
33809
  identifier,
34524
33810
  [ClassTypeId]: ([from]) => new Link(from, transformation),
@@ -35655,7 +34941,7 @@ const fromInputNested = (input) => {
35655
34941
  * @category instances
35656
34942
  * @since 4.0.0
35657
34943
  */
35658
- const Equivalence = /*#__PURE__*/ make$65((a, b) => arrayEquivalence(a.params, b.params));
34944
+ const Equivalence = /*#__PURE__*/ make$64((a, b) => arrayEquivalence(a.params, b.params));
35659
34945
  const arrayEquivalence = /*#__PURE__*/ makeEquivalence(/*#__PURE__*/ makeEquivalence$2([/*#__PURE__*/ strictEqual(), /*#__PURE__*/ strictEqual()]));
35660
34946
  /**
35661
34947
  * An empty `UrlParams` value.
@@ -36145,7 +35431,7 @@ const setUrlParams = /*#__PURE__*/ dual(2, (self, input) => makeWith$1(self.meth
36145
35431
  * @category combinators
36146
35432
  * @since 4.0.0
36147
35433
  */
36148
- const setHash = /*#__PURE__*/ dual(2, (self, hash) => makeWith$1(self.method, self.url, self.urlParams, some(hash), self.headers, self.body));
35434
+ const setHash = /*#__PURE__*/ dual(2, (self, hash) => makeWith$1(self.method, self.url, self.urlParams, some$1(hash), self.headers, self.body));
36149
35435
  /**
36150
35436
  * Sets the request body and updates `Content-Type` and `Content-Length` headers from the body metadata when available.
36151
35437
  *
@@ -36479,7 +35765,7 @@ const b3 = (headers) => {
36479
35765
  if (!("b3" in headers)) return none();
36480
35766
  const parts = headers["b3"].split("-");
36481
35767
  if (parts.length < 2) return none();
36482
- return some(externalSpan({
35768
+ return some$1(externalSpan({
36483
35769
  traceId: parts[0],
36484
35770
  spanId: parts[1],
36485
35771
  sampled: parts[2] ? parts[2] === "1" : true
@@ -36498,7 +35784,7 @@ const b3 = (headers) => {
36498
35784
  */
36499
35785
  const xb3 = (headers) => {
36500
35786
  if (!headers["x-b3-traceid"] || !headers["x-b3-spanid"]) return none();
36501
- return some(externalSpan({
35787
+ return some$1(externalSpan({
36502
35788
  traceId: headers["x-b3-traceid"],
36503
35789
  spanId: headers["x-b3-spanid"],
36504
35790
  sampled: headers["x-b3-sampled"] ? headers["x-b3-sampled"] === "1" : true
@@ -36524,7 +35810,7 @@ const w3c = (headers) => {
36524
35810
  switch (version) {
36525
35811
  case "00":
36526
35812
  if (w3cTraceId.test(traceId) === false || w3cSpanId.test(spanId) === false) return none();
36527
- return some(externalSpan({
35813
+ return some$1(externalSpan({
36528
35814
  traceId,
36529
35815
  spanId,
36530
35816
  sampled: (parseInt(flags, 16) & 1) === 1
@@ -37972,7 +37258,7 @@ const causeResponseStripped = (cause) => {
37972
37258
  }
37973
37259
  return true;
37974
37260
  });
37975
- return [response ?? internalServerError, failures.length > 0 ? some(fromReasons(failures)) : none()];
37261
+ return [response ?? internalServerError, failures.length > 0 ? some$1(fromReasons(failures)) : none()];
37976
37262
  };
37977
37263
  const internalServerError = /*#__PURE__*/ empty({ status: 500 });
37978
37264
  const succeedInternalServerError = /*#__PURE__*/ succeed$3(internalServerError);
@@ -38223,7 +37509,7 @@ const runtime = (self) => () => map$4(context$1(), (services) => {
38223
37509
  * @category combinators
38224
37510
  * @since 2.0.0
38225
37511
  */
38226
- const join$1 = (self) => _await(self.deferred);
37512
+ const join = (self) => _await(self.deferred);
38227
37513
  //#endregion
38228
37514
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/socket/Socket.js
38229
37515
  /**
@@ -38263,6 +37549,36 @@ const encoder = /*#__PURE__*/ new TextEncoder();
38263
37549
  const decoder$1 = /*#__PURE__*/ new TextDecoder();
38264
37550
  const CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
38265
37551
  /**
37552
+ * Represents a socket close event value carrying a close code and optional
37553
+ * reason.
37554
+ *
37555
+ * @category models
37556
+ * @since 4.0.0
37557
+ */
37558
+ var CloseEvent = class {
37559
+ /**
37560
+ * Marks this value as a socket close event for runtime guards.
37561
+ *
37562
+ * @since 4.0.0
37563
+ */
37564
+ [CloseEventTypeId];
37565
+ code;
37566
+ reason;
37567
+ constructor(code = 1e3, reason) {
37568
+ this[CloseEventTypeId] = CloseEventTypeId;
37569
+ this.code = code;
37570
+ this.reason = reason;
37571
+ }
37572
+ /**
37573
+ * Formats the close code and optional reason for display.
37574
+ *
37575
+ * @since 4.0.0
37576
+ */
37577
+ toString() {
37578
+ return this.reason ? `${this.code}: ${this.reason}` : `${this.code}`;
37579
+ }
37580
+ };
37581
+ /**
38266
37582
  * Returns `true` when a value is a `CloseEvent`.
38267
37583
  *
38268
37584
  * @category refinements
@@ -38509,13 +37825,13 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
38509
37825
  kind: "Timeout",
38510
37826
  cause: /* @__PURE__ */ new Error("timeout waiting for \"open\"")
38511
37827
  }) }))
38512
- }), raceFirst(join$1(fiberSet)));
37828
+ }), raceFirst(join(fiberSet)));
38513
37829
  }
38514
37830
  open = true;
38515
37831
  currentWS = ws;
38516
37832
  latch.openUnsafe();
38517
37833
  if (opts?.onOpen) yield* opts.onOpen;
38518
- return yield* catchFilter(join$1(fiberSet), SocketCloseError.filterClean((_) => !closeCodeIsError(_)), () => void_$1);
37834
+ return yield* catchFilter(join(fiberSet), SocketCloseError.filterClean((_) => !closeCodeIsError(_)), () => void_$1);
38519
37835
  })).pipe(updateContext((input) => merge$3(acquireContext, input)), ensuring$2(sync(() => {
38520
37836
  latch.closeUnsafe();
38521
37837
  currentWS = void 0;
@@ -39711,7 +39027,7 @@ const toURL = (self) => {
39711
39027
  const host = self.headers.host ?? "localhost";
39712
39028
  const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http";
39713
39029
  try {
39714
- return some(new URL(self.url, `${protocol}://${host}`));
39030
+ return some$1(new URL(self.url, `${protocol}://${host}`));
39715
39031
  } catch {
39716
39032
  return none();
39717
39033
  }
@@ -40456,7 +39772,7 @@ const RouteTypeId = "~effect/http/HttpRouter/Route";
40456
39772
  const makeRoute = (options) => ({
40457
39773
  ...options,
40458
39774
  uninterruptible: options.uninterruptible ?? false,
40459
- prefix: typeof options.prefix === "string" ? some(options.prefix) : options.prefix ?? none(),
39775
+ prefix: typeof options.prefix === "string" ? some$1(options.prefix) : options.prefix ?? none(),
40460
39776
  [RouteTypeId]: RouteTypeId
40461
39777
  });
40462
39778
  /**
@@ -40787,7 +40103,7 @@ function isStreamSchema(schema) {
40787
40103
  }
40788
40104
  /** @internal */
40789
40105
  function getStreamSchemas(schema) {
40790
- return isStreamSchema(schema) ? some({
40106
+ return isStreamSchema(schema) ? some$1({
40791
40107
  success: schema.success,
40792
40108
  error: schema.error
40793
40109
  }) : none();
@@ -45091,7 +44407,7 @@ const withDefault = /*#__PURE__*/ dual(2, (self, defaultValue) => {
45091
44407
  * @category combinators
45092
44408
  * @since 2.0.0
45093
44409
  */
45094
- const option = (self) => self.pipe(map(some), withDefault(none()));
44410
+ const option = (self) => self.pipe(map(some$1), withDefault(none()));
45095
44411
  /**
45096
44412
  * Constructs a `Config<T>` from a value matching `Wrap<T>`.
45097
44413
  *
@@ -49117,10 +48433,10 @@ const makeFile = /*#__PURE__*/ (() => {
49117
48433
  }), (bytesRead) => {
49118
48434
  if (bytesRead === 0) return none();
49119
48435
  this.position = position + BigInt(bytesRead);
49120
- if (bytesRead === sizeNumber) return some(buffer);
48436
+ if (bytesRead === sizeNumber) return some$1(buffer);
49121
48437
  const dst = Buffer.allocUnsafeSlow(bytesRead);
49122
48438
  buffer.copy(dst, 0, 0, bytesRead);
49123
- return some(dst);
48439
+ return some$1(dst);
49124
48440
  });
49125
48441
  });
49126
48442
  }
@@ -49184,7 +48500,7 @@ const readDirectory = (path, options) => tryPromise({
49184
48500
  try: () => NFS.promises.readdir(path, options),
49185
48501
  catch: (err) => handleErrnoException("FileSystem", "readDirectory")(err, [path])
49186
48502
  });
49187
- const readFile$1 = (path) => callback$1((resume, signal) => {
48503
+ const readFile = (path) => callback$1((resume, signal) => {
49188
48504
  try {
49189
48505
  NFS.readFile(path, { signal }, (err, data) => {
49190
48506
  if (err) resume(fail$3(handleErrnoException("FileSystem", "readFile")(err, [path])));
@@ -49219,7 +48535,7 @@ const makeFileInfo = (stat) => ({
49219
48535
  uid: fromNullishOr(stat.uid),
49220
48536
  gid: fromNullishOr(stat.gid),
49221
48537
  size: Size(stat.size),
49222
- blksize: stat.blksize !== void 0 ? some(Size(stat.blksize)) : none(),
48538
+ blksize: stat.blksize !== void 0 ? some$1(Size(stat.blksize)) : none(),
49223
48539
  blocks: fromNullishOr(stat.blocks)
49224
48540
  });
49225
48541
  const stat = /*#__PURE__*/ (() => {
@@ -49305,7 +48621,7 @@ const makeFileSystem = /*#__PURE__*/ map$4(/*#__PURE__*/ serviceOption(WatchBack
49305
48621
  makeTempFileScoped,
49306
48622
  open,
49307
48623
  readDirectory,
49308
- readFile: readFile$1,
48624
+ readFile,
49309
48625
  readLink,
49310
48626
  realPath,
49311
48627
  remove,
@@ -51527,7 +50843,7 @@ const toSchemaStore = (self, schema) => {
51527
50843
  const modify = (key, f) => flatMap$2(get(key), (o) => {
51528
50844
  if (isNone(o)) return succeedNone;
51529
50845
  const newValue = f(o.value);
51530
- return as(set(key, newValue), some(newValue));
50846
+ return as(set(key, newValue), some$1(newValue));
51531
50847
  });
51532
50848
  return {
51533
50849
  [SchemaStoreTypeId]: SchemaStoreTypeId,
@@ -51780,37 +51096,6 @@ const set = /*#__PURE__*/ dual(2, (self, value) => self.semaphore.withPermit(syn
51780
51096
  * @since 2.0.0
51781
51097
  */
51782
51098
  const update = /*#__PURE__*/ dual(2, (self, update) => self.semaphore.withPermit(sync(() => setUnsafe(self, update(self.value)))));
51783
- /**
51784
- * Applies an update function to the current value. If it returns
51785
- * `Option.some`, sets and publishes that value; if it returns `Option.none`,
51786
- * leaves the reference unchanged and does not publish.
51787
- *
51788
- * **Example** (Conditionally updating a value)
51789
- *
51790
- * ```ts
51791
- * import { Effect, Option, SubscriptionRef } from "effect"
51792
- *
51793
- * const program = Effect.gen(function*() {
51794
- * const ref = yield* SubscriptionRef.make(10)
51795
- *
51796
- * yield* SubscriptionRef.updateSome(
51797
- * ref,
51798
- * (n) => n > 5 ? Option.some(n * 2) : Option.none()
51799
- * )
51800
- *
51801
- * const value = yield* SubscriptionRef.get(ref)
51802
- * console.log(value)
51803
- * })
51804
- * ```
51805
- *
51806
- * @category updating
51807
- * @since 2.0.0
51808
- */
51809
- const updateSome = /*#__PURE__*/ dual(2, (self, update) => self.semaphore.withPermit(sync(() => {
51810
- const option = update(self.value);
51811
- if (isNone(option)) return;
51812
- setUnsafe(self, option.value);
51813
- })));
51814
51099
  //#endregion
51815
51100
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpStaticServer.js
51816
51101
  /**
@@ -52122,7 +51407,6 @@ const GitDiffStatus = Literals([
52122
51407
  "modified",
52123
51408
  "renamed"
52124
51409
  ]);
52125
- const GitDiffScope = Literals(["staged-to-worktree", "head-to-staged"]);
52126
51410
  var GitDiffSegment = class extends Class("GitDiffSegment")({
52127
51411
  filePath: String$1,
52128
51412
  fingerprint: String$1,
@@ -52155,8 +51439,21 @@ var GitCommit = class extends Class("GitCommit")({
52155
51439
  }) {};
52156
51440
  var GitReviewMetadata = class extends Class("GitReviewMetadata")({
52157
51441
  base: String$1,
51442
+ branch: String$1,
52158
51443
  commits: ArraySchema(GitCommit),
52159
- dirty: Boolean$1
51444
+ defaultBranch: String$1,
51445
+ dirty: Boolean$1,
51446
+ prUrl: optional(String$1),
51447
+ unpushedCommits: Boolean$1
51448
+ }) {};
51449
+ var GitHubReviewThread = class extends Class("GitHubReviewThread")({
51450
+ body: String$1,
51451
+ filePath: String$1,
51452
+ id: String$1,
51453
+ lineNumber: Number$1,
51454
+ resolved: Boolean$1,
51455
+ side: optional(Literals(["additions", "deletions"])),
51456
+ url: optional(String$1)
52160
51457
  }) {};
52161
51458
  var GitRepository = class extends Class("GitRepository")({
52162
51459
  gitDirectory: String$1,
@@ -52211,7 +51508,6 @@ Union([
52211
51508
  Struct({ type: Literal("stop") })
52212
51509
  ]);
52213
51510
  const TerminalState = Struct({
52214
- ports: ArraySchema(Number$1),
52215
51511
  runId: Number$1,
52216
51512
  state: Literals([
52217
51513
  "idle",
@@ -52241,8 +51537,22 @@ const TerminalPayload = Struct({
52241
51537
  args: optional(ArraySchema(String$1)),
52242
51538
  command: optional(String$1),
52243
51539
  cwd: String$1,
51540
+ env: optional(Record(String$1, String$1)),
52244
51541
  sessionId: optional(String$1)
52245
51542
  });
51543
+ const RunScript = Struct({
51544
+ baseOrigin: optional(String$1),
51545
+ command: String$1,
51546
+ cwd: String$1,
51547
+ env: optional(Record(String$1, String$1)),
51548
+ name: String$1,
51549
+ origin: optional(String$1),
51550
+ packageFolder: String$1,
51551
+ packagePath: String$1,
51552
+ portless: optional(Boolean$1),
51553
+ service: optional(String$1),
51554
+ sessionId: String$1
51555
+ });
52246
51556
  const AgentSession = Struct({
52247
51557
  args: ArraySchema(String$1),
52248
51558
  command: String$1,
@@ -52264,6 +51574,7 @@ var ReviewComment = class extends Class("ReviewComment")({
52264
51574
  body: String$1,
52265
51575
  filePath: String$1,
52266
51576
  lineNumber: Number$1,
51577
+ resolved: optional(Boolean$1),
52267
51578
  side: optional(Literals(["additions", "deletions"]))
52268
51579
  }) {};
52269
51580
  var ReviewState = class extends Class("ReviewState")({
@@ -52302,14 +51613,6 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52302
51613
  error: GitError,
52303
51614
  payload: Struct({ cwd: String$1 }),
52304
51615
  success: GitBranchesSnapshot
52305
- }), make$18("review.watch", {
52306
- error: GitError,
52307
- payload: Struct({
52308
- cwd: String$1,
52309
- scope: GitDiffScope
52310
- }),
52311
- stream: true,
52312
- success: ArraySchema(GitDiff)
52313
51616
  }), make$18("review.metadata", {
52314
51617
  error: GitError,
52315
51618
  payload: Struct({
@@ -52355,7 +51658,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52355
51658
  comment: ReviewComment,
52356
51659
  cwd: String$1
52357
51660
  })
52358
- }), make$18("review.comments.delete", {
51661
+ }), make$18("review.comments.resolve", {
52359
51662
  error: GitError,
52360
51663
  payload: Struct({
52361
51664
  base: String$1,
@@ -52377,6 +51680,16 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52377
51680
  cwd: String$1,
52378
51681
  message: String$1
52379
51682
  })
51683
+ }), make$18("review.githubThreads", {
51684
+ error: GitError,
51685
+ payload: Struct({ cwd: String$1 }),
51686
+ success: ArraySchema(GitHubReviewThread)
51687
+ }), make$18("review.githubThreads.resolve", {
51688
+ error: GitError,
51689
+ payload: Struct({
51690
+ cwd: String$1,
51691
+ threadId: String$1
51692
+ })
52380
51693
  }), make$18("review.stageFile", {
52381
51694
  error: GitError,
52382
51695
  payload: Struct({
@@ -52414,14 +51727,10 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52414
51727
  cwd: String$1,
52415
51728
  force: Boolean$1
52416
51729
  })
52417
- }), make$18("runs.scripts", {
51730
+ }), make$18("runs.portless", {
52418
51731
  error: TerminalError,
52419
51732
  payload: Struct({ cwd: String$1 }),
52420
- success: ArraySchema(Struct({
52421
- command: String$1,
52422
- name: String$1,
52423
- tasks: ArraySchema(String$1)
52424
- }))
51733
+ success: ArraySchema(RunScript)
52425
51734
  }), make$18("terminal.write", {
52426
51735
  error: TerminalError,
52427
51736
  payload: Struct({
@@ -52429,6 +51738,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52429
51738
  command: optional(String$1),
52430
51739
  cwd: String$1,
52431
51740
  data: String$1,
51741
+ env: optional(Record(String$1, String$1)),
52432
51742
  sessionId: optional(String$1)
52433
51743
  }),
52434
51744
  success: TerminalState
@@ -52439,6 +51749,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52439
51749
  cols: Number$1,
52440
51750
  command: optional(String$1),
52441
51751
  cwd: String$1,
51752
+ env: optional(Record(String$1, String$1)),
52442
51753
  rows: Number$1,
52443
51754
  sessionId: optional(String$1)
52444
51755
  }),
@@ -52451,11 +51762,6 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52451
51762
  error: TerminalError,
52452
51763
  payload: TerminalPayload,
52453
51764
  success: TerminalState
52454
- }), make$18("terminal.ports", {
52455
- error: TerminalError,
52456
- payload: TerminalPayload,
52457
- stream: true,
52458
- success: ArraySchema(Number$1)
52459
51765
  }), make$18("terminal.watch", {
52460
51766
  error: TerminalError,
52461
51767
  payload: TerminalPayload,
@@ -52615,7 +51921,7 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52615
51921
  "--format=%(refname:short)",
52616
51922
  "refs/remotes"
52617
51923
  ]), map$4((lines) => pipe(lines, filter$2((name) => !endsWith("/HEAD")(name)), map$7((name) => new GitBranch({
52618
- name: pipe(split$1("/")(name), drop$1(1), join$3("/")),
51924
+ name: pipe(split$1("/")(name), drop$1(1), join$2("/")),
52619
51925
  remote: split$1("/")(name)[0],
52620
51926
  type: "remote"
52621
51927
  })), filter$2((branch) => isNonEmpty$1(branch.name)), appendAll(localBranches)))))),
@@ -52737,12 +52043,11 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52737
52043
  static layer = effect(this, this.make);
52738
52044
  };
52739
52045
  var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { make: fnUntraced(function* (config) {
52046
+ const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
52740
52047
  const git = yield* makeGitExecutor;
52741
52048
  const fs = yield* FileSystem;
52742
52049
  const path = yield* Path$1;
52743
- const hasWorktreeChanges = gen(function* () {
52744
- return yield* pipe(git.lines(config.cwd, ["status", "--porcelain"]), map$4((lines) => !isReadonlyArrayEmpty(lines)));
52745
- });
52050
+ const hasWorktreeChanges = pipe(git.lines(config.cwd, ["status", "--porcelain"]), map$4((lines) => !isReadonlyArrayEmpty(lines)));
52746
52051
  const resolveFrom = fnUntraced(function* (from) {
52747
52052
  if (from.type === "ref") return from.ref;
52748
52053
  return yield* pipe(git.string(config.cwd, [
@@ -52755,7 +52060,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52755
52060
  return to.type === "ref" ? [to.ref] : empty$13();
52756
52061
  }
52757
52062
  function segmentsByFile(segments) {
52758
- return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some(append$1(getOrElse$1(current, () => empty$13()), segment))));
52063
+ return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52759
52064
  }
52760
52065
  function diffFromPatchChunk(chunk, segments) {
52761
52066
  const deleted = /^deleted file mode /mu.test(chunk);
@@ -52794,31 +52099,21 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52794
52099
  "--no-ext-diff"
52795
52100
  ]), input.segments);
52796
52101
  });
52797
- const untrackedDiffs = gen(function* () {
52798
- return yield* forEach$1(yield* git.lines(config.cwd, [
52799
- "ls-files",
52800
- "--others",
52801
- "--exclude-standard"
52802
- ]), (filePath) => pipe(fs.readFileString(path.join(config.cwd, filePath)), orElseSucceed(() => ""), map$4((content) => new GitDiff({
52102
+ const untrackedDiffs = pipe(git.lines(config.cwd, [
52103
+ "ls-files",
52104
+ "--others",
52105
+ "--exclude-standard"
52106
+ ]), flatMap$2((files) => forEach$1(files, (filePath) => pipe(fs.readFileString(path.join(config.cwd, filePath)), orElseSucceed(() => ""), map$4((content) => new GitDiff({
52107
+ filePath,
52108
+ patch: `diff --git a/${filePath} b/${filePath}\nnew file mode 100644\n--- /dev/null\n+++ b/${filePath}\n@@ -0,0 +1,${length(split$1("\n")(content))} @@\n${pipe(split$1("\n")(content), map$7((line) => `+${line}`), join$2("\n"))}`,
52109
+ segments: [new GitDiffSegment({
52803
52110
  filePath,
52804
- patch: `diff --git a/${filePath} b/${filePath}\nnew file mode 100644\n--- /dev/null\n+++ b/${filePath}\n@@ -0,0 +1,${length(split$1("\n")(content))} @@\n${pipe(split$1("\n")(content), map$7((line) => `+${line}`), join$3("\n"))}`,
52805
- segments: [new GitDiffSegment({
52806
- filePath,
52807
- fingerprint: content,
52808
- id: "HEAD->worktree",
52809
- type: "worktree"
52810
- })],
52811
- status: "added"
52812
- }))), { concurrency: "unbounded" });
52813
- });
52814
- const reviewDiffs = fnUntraced(function* (scope) {
52815
- const diffs = yield* gitDiffs({
52816
- args: scope === "head-to-staged" ? ["--cached"] : empty$13(),
52817
- segments: empty$13()
52818
- });
52819
- if (scope === "head-to-staged") return diffs;
52820
- return yield* pipe(untrackedDiffs, map$4(appendAll(diffs)));
52821
- });
52111
+ fingerprint: content,
52112
+ id: "HEAD->worktree",
52113
+ type: "worktree"
52114
+ })],
52115
+ status: "added"
52116
+ }))), { concurrency: "unbounded" })));
52822
52117
  const commitSegmentDiffs = fnUntraced(function* (input) {
52823
52118
  return pipe((yield* git.string(config.cwd, [
52824
52119
  "log",
@@ -52885,23 +52180,44 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52885
52180
  if (input.to.type === "ref") return diffsWithSegments;
52886
52181
  return appendAll(diffsWithSegments, untracked);
52887
52182
  });
52888
- const suggestBase = gen(function* () {
52889
- return yield* pipe([
52890
- yield* pipe(git.string(config.cwd, [
52891
- "symbolic-ref",
52892
- "--short",
52893
- "refs/remotes/origin/HEAD"
52894
- ]), map$4(flow(trim, replace(/^origin\//u, "origin/"))), orElseSucceed(() => "origin/main")),
52895
- "origin/main",
52896
- "origin/master",
52897
- "main",
52898
- "master"
52899
- ], findFirst((candidate) => pipe(git.string(config.cwd, [
52183
+ const ghString = fnUntraced(function* (args) {
52184
+ return yield* pipe(execString(make$40("gh", args, { cwd: config.cwd })), mapError$2((cause) => new GitError({ cause })));
52185
+ });
52186
+ const currentBranch = pipe(git.string(config.cwd, ["branch", "--show-current"]), map$4(trim));
52187
+ const defaultBranchName = pipe(git.string(config.cwd, [
52188
+ "symbolic-ref",
52189
+ "--short",
52190
+ "refs/remotes/origin/HEAD"
52191
+ ]), map$4(flow(trim, replace(/^origin\//u, ""))));
52192
+ const branchBase = fnUntraced(function* (defaultBranch) {
52193
+ return yield* pipe([`origin/${defaultBranch}`, defaultBranch], findFirst((candidate) => pipe(git.string(config.cwd, [
52900
52194
  "rev-parse",
52901
52195
  "--verify",
52902
52196
  candidate
52903
52197
  ]), as(true), orElseSucceed(() => false))), map$4(getOrElse$1(() => "HEAD")));
52904
52198
  });
52199
+ const branchPrUrl = pipe(ghString([
52200
+ "pr",
52201
+ "view",
52202
+ "--json",
52203
+ "url",
52204
+ "--jq",
52205
+ ".url"
52206
+ ]), map$4(trim), map$4((url) => isNonEmpty$1(url) ? some$1(url) : none()), catchTag("GitError", () => succeed$3(none())));
52207
+ function isWipSubject(subject) {
52208
+ return subject === "wip" || startsWith("wip: ")(subject);
52209
+ }
52210
+ function commitFromLogLine(line) {
52211
+ const parts = split$1("\0")(line);
52212
+ const subject = parts[2] ?? "";
52213
+ return new GitCommit({
52214
+ hash: parts[0] ?? "",
52215
+ parents: pipe(parts[3] ?? "", split$1(" "), filter$2(isNonEmpty$1)),
52216
+ shortHash: parts[1] ?? "",
52217
+ subject,
52218
+ wip: isWipSubject(subject)
52219
+ });
52220
+ }
52905
52221
  const commits = fnUntraced(function* (base) {
52906
52222
  const from = yield* pipe(git.string(config.cwd, [
52907
52223
  "merge-base",
@@ -52913,55 +52229,148 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52913
52229
  "--max-count=80",
52914
52230
  "--format=%H%x00%h%x00%s%x00%P",
52915
52231
  `${from}..HEAD`
52916
- ]), map$4(map$7((line) => {
52917
- const parts = split$1("\0")(line);
52918
- const subject = parts[2] ?? "";
52919
- return new GitCommit({
52920
- hash: parts[0] ?? "",
52921
- parents: pipe(parts[3] ?? "", split$1(" "), filter$2(isNonEmpty$1)),
52922
- shortHash: parts[1] ?? "",
52923
- subject,
52924
- wip: startsWith("wip: ")(subject)
52925
- });
52232
+ ]), map$4(map$7(commitFromLogLine)));
52233
+ });
52234
+ const firstParentCommits = pipe(git.lines(config.cwd, [
52235
+ "log",
52236
+ "--first-parent",
52237
+ "--max-count=80",
52238
+ "--format=%H%x00%h%x00%s%x00%P",
52239
+ "HEAD"
52240
+ ]), map$4(map$7(commitFromLogLine)));
52241
+ const pushCurrentBranch = gen(function* () {
52242
+ const branch = yield* currentBranch;
52243
+ yield* pipe(git.string(config.cwd, [
52244
+ "push",
52245
+ "-u",
52246
+ "origin",
52247
+ `HEAD:${branch}`
52248
+ ]), asVoid);
52249
+ });
52250
+ const hasPushableCommits = pipe(gen(function* () {
52251
+ const remoteBranch = `origin/${yield* currentBranch}`;
52252
+ if (yield* pipe(git.string(config.cwd, [
52253
+ "rev-parse",
52254
+ "--verify",
52255
+ remoteBranch
52256
+ ]), as(true), orElseSucceed(() => false))) return yield* git.lines(config.cwd, [
52257
+ "log",
52258
+ "--format=%s",
52259
+ `${remoteBranch}..HEAD`
52260
+ ]);
52261
+ const base = yield* branchBase(yield* defaultBranchName);
52262
+ const from = yield* pipe(git.string(config.cwd, [
52263
+ "merge-base",
52264
+ base,
52265
+ "HEAD"
52266
+ ]), map$4(trim), catchTag("GitError", () => succeed$3(base)));
52267
+ return yield* git.lines(config.cwd, [
52268
+ "log",
52269
+ "--format=%s",
52270
+ `${from}..HEAD`
52271
+ ]);
52272
+ }), map$4((subjects) => !some(subjects, isWipSubject) && !isReadonlyArrayEmpty(subjects)));
52273
+ const createDraftPr = pipe(ghString([
52274
+ "pr",
52275
+ "create",
52276
+ "--draft",
52277
+ "--fill"
52278
+ ]), map$4((output) => {
52279
+ const url = output.match(/https?:\/\/\S+/u)?.[0] ?? trim(output);
52280
+ return isNonEmpty$1(url) ? some$1(url) : none();
52281
+ }));
52282
+ const prReviewThreads = gen(function* () {
52283
+ const pr = yield* pipe(ghString([
52284
+ "pr",
52285
+ "view",
52286
+ "--json",
52287
+ "number",
52288
+ "--jq",
52289
+ ".number"
52290
+ ]), map$4(flow(trim, parse$2)), flatMap$2(match$5({
52291
+ onNone: () => new GitError({ message: "No PR found." }),
52292
+ onSome: succeed$3
52926
52293
  })));
52294
+ const repository = yield* pipe(ghString([
52295
+ "repo",
52296
+ "view",
52297
+ "--json",
52298
+ "owner,name"
52299
+ ]), map$4((output) => JSON.parse(output)));
52300
+ const response = yield* ghString([
52301
+ "api",
52302
+ "graphql",
52303
+ "-f",
52304
+ `query=
52305
+ query(\$owner: String!, \$name: String!, \$number: Int!) {
52306
+ repository(owner: \$owner, name: \$name) {
52307
+ pullRequest(number: \$number) {
52308
+ reviewThreads(first: 100) {
52309
+ nodes {
52310
+ id
52311
+ isResolved
52312
+ diffSide
52313
+ comments(first: 20) {
52314
+ nodes {
52315
+ body
52316
+ line
52317
+ originalLine
52318
+ path
52319
+ url
52320
+ }
52321
+ }
52322
+ }
52323
+ }
52324
+ }
52325
+ }
52326
+ }`,
52327
+ "-f",
52328
+ `owner=${repository.owner.login}`,
52329
+ "-f",
52330
+ `name=${repository.name}`,
52331
+ "-F",
52332
+ `number=${pr}`
52333
+ ]);
52334
+ return pipe(JSON.parse(response).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], filter$2((thread) => thread.id !== void 0), flatMap$5((thread) => pipe(thread.comments?.nodes ?? [], filter$2((comment) => comment.body !== void 0 && comment.path !== void 0), map$7((comment) => new GitHubReviewThread({
52335
+ body: comment.body ?? "",
52336
+ filePath: comment.path ?? "",
52337
+ id: thread.id ?? "",
52338
+ lineNumber: comment.line ?? comment.originalLine ?? 1,
52339
+ resolved: thread.isResolved === true,
52340
+ side: thread.diffSide === "LEFT" ? "deletions" : "additions",
52341
+ url: comment.url
52342
+ })))));
52927
52343
  });
52928
52344
  const worktreeChanges = pipe(make$43(void 0), merge$1(pipe(fs.watch(config.cwd), catch_(() => empty$8), map$2(() => void 0))), debounce(millis(50)));
52929
52345
  return {
52930
52346
  commitAndPush: fnUntraced(function* (input) {
52931
- if (yield* hasWorktreeChanges) return yield* fail$3(new GitError({ message: "Create a WIP commit before squashing." }));
52932
- const oldestWip = pipe(yield* commits(input.base), filter$2((commit) => commit.wip), last, getOrUndefined$1);
52933
- if (!oldestWip) return yield* fail$3(new GitError({ message: "No WIP commits to squash." }));
52934
- yield* pipe(git.string(config.cwd, [
52347
+ const oldestWip = pipe(yield* commits(input.base), takeWhile((commit) => commit.wip), last, getOrUndefined$1);
52348
+ const dirty = yield* hasWorktreeChanges;
52349
+ if (oldestWip) yield* pipe(git.string(config.cwd, [
52935
52350
  "reset",
52936
52351
  "--soft",
52937
52352
  `${oldestWip.hash}^`
52938
52353
  ]), asVoid);
52354
+ else if (!dirty) return yield* new GitError({ message: "No changes to commit." });
52355
+ yield* pipe(git.string(config.cwd, ["add", "-A"]), asVoid);
52939
52356
  yield* pipe(git.string(config.cwd, [
52940
52357
  "commit",
52941
52358
  "-m",
52942
52359
  input.message
52943
52360
  ]), asVoid);
52944
- const branch = yield* pipe(git.string(config.cwd, ["branch", "--show-current"]), map$4(trim));
52945
- yield* pipe((yield* pipe(git.string(config.cwd, [
52946
- "rev-parse",
52947
- "--abbrev-ref",
52948
- "--symbolic-full-name",
52949
- "@{u}"
52950
- ]), as(true), orElseSucceed(() => false))) ? git.string(config.cwd, ["push"]) : git.string(config.cwd, [
52951
- "push",
52952
- "-u",
52953
- "origin",
52954
- branch
52955
- ]), asVoid);
52361
+ yield* pushCurrentBranch;
52362
+ if (yield* hasPushableCommits) return yield* new GitError({ message: "Push completed but the branch still has unpushed commits." });
52363
+ if ((yield* currentBranch) !== (yield* defaultBranchName) && isNone(yield* branchPrUrl)) yield* createDraftPr;
52956
52364
  }),
52957
52365
  commits,
52958
52366
  createWipCommit: fnUntraced(function* (message) {
52959
- if (!(yield* hasWorktreeChanges)) return yield* fail$3(new GitError({ message: "No changes to commit." }));
52367
+ if (!(yield* hasWorktreeChanges)) return yield* new GitError({ message: "No changes to commit." });
52960
52368
  yield* pipe(git.string(config.cwd, ["add", "-A"]), asVoid);
52369
+ const subject = pipe(message, trim, (message) => isEmpty$1(message) ? "wip" : `wip: ${message}`);
52961
52370
  yield* pipe(git.string(config.cwd, [
52962
52371
  "commit",
52963
52372
  "-m",
52964
- `wip: ${message}`
52373
+ subject
52965
52374
  ]), asVoid);
52966
52375
  }),
52967
52376
  discardFile: fnUntraced(function* (filePath) {
@@ -52986,15 +52395,38 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52986
52395
  ]), asVoid);
52987
52396
  }),
52988
52397
  metadata: fnUntraced(function* (input) {
52989
- const base = input?.base ?? (yield* suggestBase);
52398
+ const branch = yield* currentBranch;
52399
+ const defaultBranch = yield* defaultBranchName;
52400
+ const base = input?.base ?? (yield* branchBase(defaultBranch));
52990
52401
  return new GitReviewMetadata({
52991
52402
  base,
52992
- commits: yield* commits(base),
52993
- dirty: yield* hasWorktreeChanges
52403
+ branch,
52404
+ commits: branch === defaultBranch ? yield* firstParentCommits : yield* commits(base),
52405
+ defaultBranch,
52406
+ dirty: yield* hasWorktreeChanges,
52407
+ prUrl: getOrUndefined$1(yield* branchPrUrl),
52408
+ unpushedCommits: yield* hasPushableCommits
52994
52409
  });
52995
52410
  }),
52996
- reviewDiffs,
52411
+ resolveReviewThread: fnUntraced(function* (threadId) {
52412
+ yield* pipe(ghString([
52413
+ "api",
52414
+ "graphql",
52415
+ "-f",
52416
+ `query=
52417
+ mutation(\$threadId: ID!) {
52418
+ resolveReviewThread(input: {threadId: \$threadId}) {
52419
+ thread {
52420
+ id
52421
+ }
52422
+ }
52423
+ }`,
52424
+ "-f",
52425
+ `threadId=${threadId}`
52426
+ ]), asVoid);
52427
+ }),
52997
52428
  reviewRangeDiffs,
52429
+ reviewThreads: pipe(prReviewThreads, catchTag("GitError", () => succeed$3(empty$13()))),
52998
52430
  stageFile: fnUntraced(function* (filePath) {
52999
52431
  yield* pipe(git.string(config.cwd, [
53000
52432
  "add",
@@ -53010,56 +52442,261 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53010
52442
  filePath
53011
52443
  ]), asVoid);
53012
52444
  }),
53013
- watchReviewDiffs: (scope) => pipe(worktreeChanges, mapEffect(() => pipe(reviewDiffs(scope), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => right[index] !== void 0 && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch))),
53014
52445
  watchReviewRangeDiffs: (input) => pipe(worktreeChanges, mapEffect(() => pipe(reviewRangeDiffs(input), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => right[index] !== void 0 && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch)))
53015
52446
  };
53016
52447
  }) }) {
53017
52448
  static layer = flow(this.make, effect(this));
53018
52449
  };
53019
52450
  //#endregion
53020
- //#region ../../packages/terminal/src/service.ts
53021
- function parseProcessParents(output) {
53022
- return new Map(pipe(linesIterator(output), fromIterable$2, filterMap$1((line) => {
53023
- const columns = split$1(/\s+/)(trim(line));
53024
- const pid = Number(columns[0]);
53025
- const ppid = Number(columns[1]);
53026
- return Number.isFinite(pid) && Number.isFinite(ppid) ? succeed$7(make$63(pid, ppid)) : failVoid;
53027
- })));
52451
+ //#region ../../packages/portless/src/lib/utils.ts
52452
+ function command(script, port) {
52453
+ return make$40("vp", [
52454
+ "run",
52455
+ script.name,
52456
+ .../^vp\s+dev(?:\s|$)/u.test(script.command) ? [
52457
+ "--host",
52458
+ "127.0.0.1",
52459
+ "--port",
52460
+ port.toString(),
52461
+ "--strictPort"
52462
+ ] : []
52463
+ ]);
53028
52464
  }
53029
- function parseListeningPorts(output) {
53030
- return pipe(linesIterator(output), fromIterable$2, filterMap$1((line) => {
53031
- const columns = split$1(/\s+/)(trim(line));
53032
- const port = Number(columns[3]?.match(/:(\d+)$/)?.[1]);
53033
- const pid = Number(line.match(/pid=(\d+)/)?.[1]);
53034
- return Number.isFinite(port) && Number.isFinite(pid) ? succeed$7({
53035
- pid,
53036
- port
53037
- }) : failVoid;
52465
+ const discover = fnUntraced(function* (cwd, input) {
52466
+ const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
52467
+ const fs = yield* FileSystem;
52468
+ const path = yield* Path$1;
52469
+ const output = yield* execString(make$40("git", [
52470
+ "ls-files",
52471
+ "-co",
52472
+ "--exclude-standard",
52473
+ "--",
52474
+ "package.json",
52475
+ "**/package.json"
52476
+ ], { cwd }));
52477
+ return yield* pipe(pipe(split$1("\n")(output), filter$2((path) => path === "package.json" || endsWith("/package.json")(path))), map$7((packagePath) => pipe(pipe(fs.readFileString(path.join(cwd, packagePath)), map$4((source) => ({
52478
+ packageJson: JSON.parse(source),
52479
+ packagePath
52480
+ })), catch_$2(() => succeed$3(void 0))), flatMap$2((result) => {
52481
+ if (result === void 0) return succeed$3([]);
52482
+ const packageDirectory = result.packagePath === "package.json" ? cwd : path.join(cwd, path.dirname(result.packagePath));
52483
+ const folder = path.basename(packageDirectory);
52484
+ const scriptEntries = pipe(Object.entries(result.packageJson.scripts ?? {}), filter$2((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
52485
+ const packageOrigin = `http://${[
52486
+ folder,
52487
+ path.basename(cwd),
52488
+ "localhost"
52489
+ ].join(".")}:${input.proxyPort}`;
52490
+ return pipe(scriptEntries, map$7((entry) => {
52491
+ const name = entry[0];
52492
+ const scriptCommand = entry[1];
52493
+ return map$4(input.port(`${result.packagePath}:${name}`), (port) => {
52494
+ const service = /^dev:(.+)$/u.exec(name)?.[1] ?? "dev";
52495
+ const host = [
52496
+ service,
52497
+ folder,
52498
+ path.basename(cwd),
52499
+ "localhost"
52500
+ ].join(".");
52501
+ const origin = `http://${host}:${input.proxyPort}`;
52502
+ return {
52503
+ host,
52504
+ port,
52505
+ script: {
52506
+ baseOrigin: packageOrigin,
52507
+ command: scriptCommand,
52508
+ cwd: packageDirectory,
52509
+ env: {
52510
+ HOST: "127.0.0.1",
52511
+ PORT: port.toString(),
52512
+ PORTLESS_BASE_ORIGIN: packageOrigin,
52513
+ PORTLESS_ORIGIN: origin,
52514
+ VITE_PORTLESS_BASE_ORIGIN: packageOrigin,
52515
+ VITE_PORTLESS_ORIGIN: origin
52516
+ },
52517
+ name,
52518
+ origin,
52519
+ packageFolder: folder,
52520
+ packagePath: result.packagePath,
52521
+ service,
52522
+ sessionId: `${result.packagePath}:${name}:${Date.now()}:${Math.random()}`
52523
+ }
52524
+ };
52525
+ });
52526
+ }), all);
52527
+ }))), all, map$4((routes) => flatten$3(routes).sort((left, right) => `${left.script.packagePath}:${left.script.name}`.localeCompare(`${right.script.packagePath}:${right.script.name}`))));
52528
+ });
52529
+ //#endregion
52530
+ //#region ../../packages/portless/src/http.ts
52531
+ const INJECTED_HEAD = `<script>
52532
+ (() => {
52533
+ if (window.__deslopBrowserBridge) return
52534
+ window.__deslopBrowserBridge = true
52535
+
52536
+ const serialize = value => {
52537
+ if (typeof value === 'string') return value
52538
+ try { return JSON.stringify(value) } catch { return String(value) }
52539
+ }
52540
+ const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
52541
+ const sendFavicon = () => {
52542
+ const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
52543
+ window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
52544
+ }
52545
+
52546
+ for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
52547
+ const original = console[level]
52548
+ console[level] = (...args) => {
52549
+ send(level, args.map(serialize).join(' '))
52550
+ original.apply(console, args)
52551
+ }
52552
+ }
52553
+
52554
+ window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
52555
+ window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
52556
+ window.addEventListener('message', event => {
52557
+ if (event.data?.__deslopBrowserClear !== true) return
52558
+ localStorage.clear()
52559
+ sessionStorage.clear()
52560
+ document.cookie.split(';').forEach(cookie => {
52561
+ document.cookie = cookie.replace(/^\\s*([^=]+)=.*$/, '$1=; Max-Age=0; Path=/')
52562
+ })
52563
+ caches?.keys?.().then(keys => Promise.all(keys.map(key => caches.delete(key))))
52564
+ navigator.serviceWorker?.getRegistrations?.().then(registrations => Promise.all(registrations.map(registration => registration.unregister())))
52565
+ location.reload()
52566
+ })
52567
+
52568
+ const sendLocation = () => window.parent?.postMessage({__deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
52569
+ const wrapHistory = name => {
52570
+ const original = history[name]
52571
+ history[name] = function(...args) {
52572
+ const result = original.apply(this, args)
52573
+ sendLocation()
52574
+ return result
52575
+ }
52576
+ }
52577
+ wrapHistory('pushState')
52578
+ wrapHistory('replaceState')
52579
+ window.addEventListener('popstate', sendLocation)
52580
+ window.addEventListener('hashchange', sendLocation)
52581
+
52582
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendFavicon, {once: true})
52583
+ else sendFavicon()
52584
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendLocation, {once: true})
52585
+ else sendLocation()
52586
+ })()
52587
+ <\/script>
52588
+ <script crossorigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" onload="window.reactScan?.({allowInIframe: true, _debug: 'verbose'})"><\/script>
52589
+ <script src="https://unpkg.com/react-grab/dist/index.global.js"><\/script>`;
52590
+ const injectScripts = fnUntraced(function* (html) {
52591
+ return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}\n${INJECTED_HEAD}`) : `${INJECTED_HEAD}\n${html}`;
52592
+ });
52593
+ const proxy = fnUntraced(function* (request, origin) {
52594
+ const webRequest = yield* toWeb(request);
52595
+ const [pathname = "/", search = ""] = request.url.split("?");
52596
+ const upstreamHeaders = new Headers(webRequest.headers);
52597
+ upstreamHeaders.set("host", new URL(origin).host);
52598
+ const upstreamRequest = new Request(`${origin}${pathname}${search ? `?${search}` : ""}`, {
52599
+ body: webRequest.body,
52600
+ headers: upstreamHeaders,
52601
+ method: webRequest.method,
52602
+ redirect: webRequest.redirect,
52603
+ signal: webRequest.signal
52604
+ });
52605
+ const upstreamResponse = yield* tryPromise(() => fetch(upstreamRequest));
52606
+ const headers = new Headers(upstreamResponse.headers);
52607
+ headers.delete("content-length");
52608
+ headers.delete("content-encoding");
52609
+ if (!(request.method === "GET" && (upstreamResponse.headers.get("content-type") ?? "").includes("text/html"))) return fromWeb(new Response(upstreamResponse.body, {
52610
+ headers,
52611
+ status: upstreamResponse.status,
52612
+ statusText: upstreamResponse.statusText
53038
52613
  }));
53039
- }
53040
- function isDescendant(pid, ancestorPid, parents) {
53041
- let current = pid;
53042
- const seen = /* @__PURE__ */ new Set();
53043
- while (!seen.has(current)) {
53044
- if (current === ancestorPid) return true;
53045
- seen.add(current);
53046
- const parent = parents.get(current);
53047
- if (!parent || parent === current) return false;
53048
- current = parent;
53049
- }
53050
- return false;
53051
- }
53052
- function descendantsOf(ancestorPid, parents) {
53053
- return pipe(fromIterable$2(parents.keys()), filter$2((pid) => pid !== ancestorPid && isDescendant(pid, ancestorPid, parents)));
53054
- }
53055
- const commandString = fnUntraced(function* (command, args, message) {
53056
- return yield* pipe((yield* ChildProcessSpawner.useSync((spawner) => spawner.string))(make$40(command, args)), mapError$2((cause) => new TerminalError({
53057
- cause,
53058
- message
53059
- })));
52614
+ const body = yield* tryPromise(() => upstreamResponse.text());
52615
+ headers.set("content-type", "text/html; charset=utf-8");
52616
+ return fromWeb(new Response(yield* injectScripts(body), {
52617
+ headers,
52618
+ status: upstreamResponse.status,
52619
+ statusText: upstreamResponse.statusText
52620
+ }));
52621
+ });
52622
+ const proxyWebSocket = fnUntraced(function* (request, origin) {
52623
+ const [pathname = "/", search = ""] = request.url.split("?");
52624
+ const protocols = request.headers["sec-websocket-protocol"]?.split(",").map((protocol) => protocol.trim()).filter((protocol) => protocol.length > 0);
52625
+ const inbound = yield* request.upgrade;
52626
+ const upstreamUrl = new URL(origin);
52627
+ upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
52628
+ upstreamUrl.pathname = pathname;
52629
+ upstreamUrl.search = search;
52630
+ const outbound = yield* makeWebSocket(upstreamUrl.toString(), { protocols }).pipe(provide(layerWebSocketConstructorGlobal));
52631
+ const writeInbound = yield* inbound.writer;
52632
+ const writeOutbound = yield* outbound.writer;
52633
+ yield* outbound.runRaw((message) => writeInbound(message)).pipe(catchReason("SocketError", "SocketCloseError", (reason) => writeInbound(new CloseEvent(reason.code, reason.closeReason)).pipe(catch_$2(() => void_$1))), catch_$2(() => writeInbound(new CloseEvent(1011, "proxy error")).pipe(catch_$2(() => void_$1))), forkScoped);
52634
+ yield* inbound.runRaw((message) => writeOutbound(typeof message === "string" ? message : message.slice())).pipe(catch_$2(() => void_$1), ensuring$2(writeOutbound(new CloseEvent()).pipe(catch_$2(() => void_$1))));
52635
+ return empty();
52636
+ });
52637
+ const requestHostname = fnUntraced(function* (host) {
52638
+ return fromUndefinedOr(host?.split(":")[0]);
53060
52639
  });
53061
- const readProcessParents = pipe(commandString("ps", ["-eo", "pid=,ppid="], "failed to list terminal processes"), map$4(parseProcessParents));
53062
- const readListeningPorts = pipe(commandString("ss", ["-H", "-ltnp"], "failed to list terminal ports"), map$4(parseListeningPorts));
52640
+ function isLocalHostname(hostname) {
52641
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
52642
+ }
52643
+ var Portless = class Portless extends Service()("@deslop/portless/Portless", { make: sync(() => {
52644
+ const ports = /* @__PURE__ */ new Map();
52645
+ const routes = /* @__PURE__ */ new Map();
52646
+ const middleware = fnUntraced(function* (app) {
52647
+ const request = yield* HttpServerRequest;
52648
+ const hostname = yield* requestHostname(request.headers["host"]);
52649
+ if (isNone(hostname) || isLocalHostname(hostname.value)) return yield* app;
52650
+ if (!hostname.value.endsWith(".localhost")) return yield* app;
52651
+ const route = yield* lookup(request.headers["host"]);
52652
+ if (isNone(route)) return empty({ status: 404 });
52653
+ if (request.headers["upgrade"]?.toLowerCase() === "websocket") return yield* proxyWebSocket(request, route.value);
52654
+ return yield* proxy(request, route.value);
52655
+ });
52656
+ const lookup = fnUntraced(function* (host) {
52657
+ return pipe(yield* requestHostname(host), flatMap$6((hostname) => fromUndefinedOr(routes.get(hostname))));
52658
+ });
52659
+ const port = fnUntraced(function* (key) {
52660
+ const existing = ports.get(key);
52661
+ if (existing !== void 0) return existing;
52662
+ const reserved = new Set(ports.values());
52663
+ for (let port = 4e3; port <= 4999; port += 1) {
52664
+ const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${port}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
52665
+ if (!reserved.has(port) && !occupied) {
52666
+ ports.set(key, port);
52667
+ return port;
52668
+ }
52669
+ }
52670
+ throw new Error("no portless app ports available");
52671
+ });
52672
+ return {
52673
+ middleware,
52674
+ port,
52675
+ register: fnUntraced(function* (host, port) {
52676
+ routes.set(host, `http://127.0.0.1:${port}`);
52677
+ }),
52678
+ scripts: fnUntraced(function* (cwd, input) {
52679
+ return yield* pipe(discover(cwd, {
52680
+ port: (sessionId) => port(`${cwd}:${sessionId}`),
52681
+ proxyPort: input.proxyPort
52682
+ }), map$4((routes) => routes.map((route) => ({
52683
+ host: route.host,
52684
+ port: route.port,
52685
+ script: {
52686
+ ...route.script,
52687
+ preparedCommand: command(route.script, route.port)
52688
+ }
52689
+ }))));
52690
+ })
52691
+ };
52692
+ }) }) {
52693
+ static layer = effect(this, this.make);
52694
+ static middleware = fnUntraced(function* (app) {
52695
+ return yield* (yield* Portless).middleware(app);
52696
+ });
52697
+ };
52698
+ //#endregion
52699
+ //#region ../../packages/terminal/src/service.ts
53063
52700
  function snapshotEvents(data) {
53064
52701
  if (data === "") return empty$13();
53065
52702
  const events = [];
@@ -53069,9 +52706,6 @@ function snapshotEvents(data) {
53069
52706
  });
53070
52707
  return events;
53071
52708
  }
53072
- function samePorts(left, right) {
53073
- return left.length === right.length && every(left, (leftPort, index) => leftPort === right[index]);
53074
- }
53075
52709
  function parseTitleSignal(title) {
53076
52710
  const trimmed = trim(title);
53077
52711
  if (/^\[\s*[!.]\s*\]\s*Action Required\b/i.test(trimmed)) return {
@@ -53133,18 +52767,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53133
52767
  const screenLock = yield* make$47(1);
53134
52768
  const sequenceRef = yield* make$38(0);
53135
52769
  const signalBuffer = yield* make$38("");
53136
- const portOwners = yield* make$38(/* @__PURE__ */ new Map());
53137
52770
  const processRef = yield* make$38(void 0);
53138
52771
  const sizeRef = yield* make$38({
53139
52772
  cols: 120,
53140
52773
  rows: 32
53141
52774
  });
53142
52775
  const shell = yield* string("SHELL").pipe(orElseSucceed(() => "bash"));
53143
- const processCommand = config.command ?? shell;
53144
- const processArgs = config.args ?? [];
53145
- const autostart = config.command === void 0;
52776
+ const processCommand = config.preparedCommand?.command ?? config.command ?? shell;
52777
+ const processArgs = config.preparedCommand?.args ?? config.args ?? [];
52778
+ const autostart = config.command === void 0 && config.preparedCommand === void 0;
53146
52779
  const stateRef = yield* make$3({
53147
- ports: [],
53148
52780
  runId: 0,
53149
52781
  state: autostart ? "starting" : "idle",
53150
52782
  title: ""
@@ -53195,17 +52827,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53195
52827
  }
53196
52828
  const startRun = pipe(update(stateRef, (state) => ({
53197
52829
  ...state,
53198
- ports: [],
53199
52830
  runId: state.runId + 1,
53200
52831
  state: "starting",
53201
52832
  title: ""
53202
52833
  })), andThen(get(stateRef)));
53203
- function setPorts(ports) {
53204
- return updateSome(stateRef, (state) => samePorts(state.ports, ports) ? none() : some({
53205
- ...state,
53206
- ports: [...ports]
53207
- }));
53208
- }
53209
52834
  function readSignals(data) {
53210
52835
  for (const match of data.matchAll(/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) {
53211
52836
  const title = match[1];
@@ -53218,24 +52843,17 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53218
52843
  yield* set$4(signalBuffer, next.pending);
53219
52844
  readSignals(next.complete);
53220
52845
  });
53221
- const interruptProcessTree = fnUntraced(function* (subprocess, signal) {
53222
- const descendants = yield* pipe(all([readProcessParents, get$3(portOwners)]), map$4(([parents, owners]) => dedupe([...descendantsOf(subprocess.pid, parents), ...fromIterable$2(owners.values())])), timeoutOption("250 millis"), map$4((option) => getOrElse$1(option, empty$13)), catch_$2(() => succeed$3(empty$13())));
52846
+ const interruptProcess = fnUntraced(function* (subprocess, signal) {
53223
52847
  yield* sync(() => {
53224
- try {
53225
- if (nodeProcess.platform !== "win32") nodeProcess.kill(-subprocess.pid, signal);
53226
- } catch {}
53227
- for (const pid of descendants.toReversed()) try {
53228
- nodeProcess.kill(pid, signal);
53229
- } catch {}
53230
52848
  try {
53231
52849
  subprocess.kill(signal);
53232
52850
  } catch {}
53233
52851
  });
53234
52852
  });
53235
52853
  const terminateProcess = fnUntraced(function* (subprocess) {
53236
- yield* interruptProcessTree(subprocess, "SIGTERM");
52854
+ yield* interruptProcess(subprocess, "SIGTERM");
53237
52855
  yield* sleep("250 millis");
53238
- yield* interruptProcessTree(subprocess, "SIGKILL");
52856
+ yield* interruptProcess(subprocess, "SIGKILL");
53239
52857
  });
53240
52858
  const writeScreen = fnUntraced(function* (data) {
53241
52859
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
@@ -53249,8 +52867,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53249
52867
  });
53250
52868
  const clearProcess = fnUntraced(function* (handle) {
53251
52869
  yield* update$1(processRef, (current) => current === handle ? void 0 : current);
53252
- yield* set$4(portOwners, /* @__PURE__ */ new Map());
53253
- yield* setPorts([]);
53254
52870
  });
53255
52871
  const stopProcess = fnUntraced(function* (state) {
53256
52872
  const handle = yield* get$3(processRef);
@@ -53282,6 +52898,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53282
52898
  cwd: config.cwd,
53283
52899
  env: {
53284
52900
  ...process.env,
52901
+ ...config.env,
53285
52902
  TERM: "xterm-256color"
53286
52903
  },
53287
52904
  name: "xterm-256color",
@@ -53324,22 +52941,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53324
52941
  discard: true
53325
52942
  }));
53326
52943
  if (autostart) yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => setState("failed")));
53327
- yield* pipe(gen(function* () {
53328
- const process = yield* get$3(processRef);
53329
- if (!process?.process.pid) {
53330
- yield* set$4(portOwners, /* @__PURE__ */ new Map());
53331
- yield* setPorts([]);
53332
- return;
53333
- }
53334
- const [parents, listeningPorts] = yield* all([readProcessParents, readListeningPorts]);
53335
- const nextPortOwners = /* @__PURE__ */ new Map();
53336
- const nextPorts = pipe(listeningPorts, filter$2((port) => isDescendant(port.pid, process.process.pid, parents)), map$7((port) => {
53337
- nextPortOwners.set(port.port, port.pid);
53338
- return port.port;
53339
- }), dedupe, sort(Number$5));
53340
- yield* set$4(portOwners, nextPortOwners);
53341
- yield* setPorts(nextPorts);
53342
- }), ignore$1, repeat(spaced("1 second")), forkScoped);
53343
52944
  const resize = fnUntraced(function* (nextSize) {
53344
52945
  const size = yield* get$3(sizeRef);
53345
52946
  if (size.cols === nextSize.cols && size.rows === nextSize.rows) return;
@@ -53388,7 +52989,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53388
52989
  ...filter$2(pending, (event) => event.sequence > snapshot.sequence)
53389
52990
  ]), concat(fromEffectRepeat(take$2(subscription))));
53390
52991
  })));
53391
- const ports = pipe(changes(stateRef), map$2((state) => state.ports), changesWith(samePorts));
53392
52992
  const updates = merge$1(changes(stateRef).pipe(map$2((state) => ({
53393
52993
  state,
53394
52994
  type: "state"
@@ -53397,7 +52997,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53397
52997
  type: "event"
53398
52998
  }))));
53399
52999
  return {
53400
- ports,
53401
53000
  resize: fnUntraced(function* (size) {
53402
53001
  return yield* pipe(resize(size), andThen(get(stateRef)));
53403
53002
  }),
@@ -53417,72 +53016,18 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53417
53016
  static layer = flow(this.make, effect(this));
53418
53017
  };
53419
53018
  //#endregion
53420
- //#region ../../packages/terminal/src/utils.ts
53421
- function splitParallelCommands(script) {
53422
- const state = pipe(split$1("")(script), reduce({
53423
- commands: [],
53424
- current: "",
53425
- escaped: false,
53426
- skipNext: false
53427
- }, (state, char, index) => {
53428
- if (state.skipNext) return {
53429
- ...state,
53430
- skipNext: false
53431
- };
53432
- if (state.escaped) return {
53433
- ...state,
53434
- current: state.current + char,
53435
- escaped: false
53436
- };
53437
- if (char === "\\") return {
53438
- ...state,
53439
- current: state.current + char,
53440
- escaped: true
53441
- };
53442
- if (state.quote) return {
53443
- ...state,
53444
- current: state.current + char,
53445
- quote: char === state.quote ? void 0 : state.quote
53446
- };
53447
- if (char === "\"" || char === "'") return {
53448
- ...state,
53449
- current: state.current + char,
53450
- quote: char
53451
- };
53452
- if (char === "&" && script[index + 1] === "&") return {
53453
- ...state,
53454
- current: `${state.current}&&`,
53455
- skipNext: true
53456
- };
53457
- if (char !== "&") return {
53458
- ...state,
53459
- current: state.current + char
53460
- };
53461
- return pipe(liftPredicate(trim(state.current), isNonEmpty$1), match$5({
53462
- onNone: () => ({
53463
- ...state,
53464
- current: ""
53465
- }),
53466
- onSome: (command) => ({
53467
- ...state,
53468
- commands: [...state.commands, command],
53469
- current: ""
53470
- })
53471
- }));
53472
- }));
53473
- return pipe(liftPredicate(trim(state.current), isNonEmpty$1), match$5({
53474
- onNone: () => state.commands,
53475
- onSome: (command) => [...state.commands, command]
53476
- }));
53477
- }
53478
- //#endregion
53479
53019
  //#region src/rpcs/handlers.ts
53480
53020
  const TerminalSessionKey = Struct({
53481
53021
  args: optional(ArraySchema(String$1)),
53482
53022
  command: optional(String$1),
53483
53023
  cwd: String$1,
53024
+ env: optional(Record(String$1, String$1)),
53484
53025
  sessionId: optional(String$1)
53485
53026
  });
53027
+ const emptyReviewState = new ReviewState({
53028
+ comments: empty$13(),
53029
+ marks: empty$13()
53030
+ });
53486
53031
  const AgentSessionKey = Struct({
53487
53032
  cwd: String$1,
53488
53033
  uuid: String$1
@@ -53504,19 +53049,51 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53504
53049
  const terminals = yield* TerminalSessions;
53505
53050
  const gitWorktrees = yield* GitWorktreeSessions;
53506
53051
  const fs = yield* FileSystem;
53052
+ const portless = yield* Portless;
53053
+ const portlessScripts = yield* make$38(empty$6());
53507
53054
  const reviewStore = toSchemaStore(yield* KeyValueStore, ReviewState);
53055
+ const portlessWorktrees = yield* make$46({
53056
+ idleTimeToLive: infinity,
53057
+ lookup: fnUntraced(function* (cwd) {
53058
+ const scripts = yield* pipe(portless.scripts(cwd, { proxyPort: process.env["PORT"] ?? "4010" }), mapError$2((cause) => new TerminalError({
53059
+ cause,
53060
+ message: `failed to discover portless scripts in ${cwd}`
53061
+ })));
53062
+ yield* all(pipe(scripts, map$7((script) => all([portless.register(script.host, script.port), update$1(portlessScripts, (current) => set$2(current, script.script.sessionId, script.script))], { discard: true }))), { discard: true });
53063
+ return pipe(scripts, map$7((route) => ({
53064
+ baseOrigin: route.script.baseOrigin,
53065
+ command: route.script.command,
53066
+ cwd: route.script.cwd,
53067
+ name: route.script.name,
53068
+ origin: route.script.origin,
53069
+ packageFolder: route.script.packageFolder,
53070
+ packagePath: route.script.packagePath,
53071
+ portless: true,
53072
+ service: route.script.service,
53073
+ sessionId: route.script.sessionId
53074
+ })));
53075
+ })
53076
+ });
53077
+ const terminalSession = fnUntraced(function* (input) {
53078
+ if (input.sessionId === void 0 || input.command !== void 0) return input;
53079
+ const script = pipe(yield* get$3(portlessScripts), get$1(input.sessionId), getOrUndefined$1);
53080
+ if (script === void 0) return input;
53081
+ return {
53082
+ cwd: script.cwd,
53083
+ env: script.env,
53084
+ preparedCommand: script.preparedCommand,
53085
+ sessionId: script.sessionId
53086
+ };
53087
+ });
53088
+ const terminal = fnUntraced(function* (input) {
53089
+ return yield* pipe(terminalSession(input), flatMap$2((session) => get$6(terminals, session)));
53090
+ });
53508
53091
  const reviewStateKey = fnUntraced(function* (input) {
53509
53092
  const root = yield* pipe(fs.realPath(input.cwd), orElseSucceed(() => input.cwd));
53510
53093
  return Buffer.from(`${root}\u0000${input.base}`, "utf8").toString("base64url");
53511
53094
  });
53512
53095
  const readReviewState = fnUntraced(function* (key) {
53513
- return yield* pipe(reviewStore.get(`review-state/${key}`), map$4(getOrElse$1(() => new ReviewState({
53514
- comments: empty$13(),
53515
- marks: empty$13()
53516
- }))), orElseSucceed(() => new ReviewState({
53517
- comments: empty$13(),
53518
- marks: empty$13()
53519
- })));
53096
+ return yield* pipe(reviewStore.get(`review-state/${key}`), map$4(getOrElse$1(() => emptyReviewState)), orElseSucceed(() => emptyReviewState));
53520
53097
  });
53521
53098
  const reviewStates = yield* make$46({
53522
53099
  idleTimeToLive: minutes(5),
@@ -53577,8 +53154,8 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53577
53154
  "projects.branches": (payload) => git.branches(payload.cwd),
53578
53155
  "projects.createWorktree": (payload) => git.createWorktree(payload),
53579
53156
  "projects.deleteWorktree": (payload) => git.deleteWorktree(payload),
53580
- "projects.watch": () => unwrap$1(pipe(get(git.projects), map$4((projects) => pipe(make$43(projects), concat(drop(1)(changes(git.projects))))))),
53581
- "review.comments.delete": (payload) => updateReviewState(payload, (state) => {
53157
+ "projects.watch": () => unwrap$1(map$4(get(git.projects), (projects) => pipe(make$43(projects), concat(drop(1)(changes(git.projects)))))),
53158
+ "review.comments.resolve": (payload) => updateReviewState(payload, (state) => {
53582
53159
  const key = commentKey(payload);
53583
53160
  return new ReviewState({
53584
53161
  comments: filter$2(state.comments, (comment) => commentKey(comment) !== key),
@@ -53588,7 +53165,10 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53588
53165
  "review.comments.save": (payload) => updateReviewState(payload, (state) => {
53589
53166
  const key = commentKey(payload.comment);
53590
53167
  return new ReviewState({
53591
- comments: append$1(filter$2(state.comments, (comment) => commentKey(comment) !== key), payload.comment),
53168
+ comments: append$1(filter$2(state.comments, (comment) => commentKey(comment) !== key), new ReviewComment({
53169
+ ...payload.comment,
53170
+ resolved: false
53171
+ })),
53592
53172
  marks: state.marks
53593
53173
  });
53594
53174
  }),
@@ -53598,6 +53178,8 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53598
53178
  }))),
53599
53179
  "review.createWipCommit": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.createWipCommit(payload.message))),
53600
53180
  "review.discardFile": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.discardFile(payload.filePath))),
53181
+ "review.githubThreads": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.reviewThreads)),
53182
+ "review.githubThreads.resolve": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.resolveReviewThread(payload.threadId))),
53601
53183
  "review.metadata": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.metadata({ base: payload.base }))),
53602
53184
  "review.stageFile": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.stageFile(payload.filePath))),
53603
53185
  "review.state.mark": (payload) => updateReviewState(payload, (state) => {
@@ -53616,31 +53198,19 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53616
53198
  }),
53617
53199
  "review.state.watch": (payload) => unwrap$1(pipe(reviewStateKey(payload), flatMap$2((key) => get$6(reviewStates, key)), flatMap$2((ref) => pipe(get(ref), map$4((state) => concat(drop(1)(changes(ref)))(make$43(state))))))),
53618
53200
  "review.unstageFile": (payload) => pipe(get$6(gitWorktrees, payload.cwd), flatMap$2((worktree) => worktree.unstageFile(payload.filePath))),
53619
- "review.watch": (payload) => unwrap$1(pipe(get$6(gitWorktrees, payload.cwd), map$4((worktree) => worktree.watchReviewDiffs(payload.scope)))),
53620
53201
  "review.watchRange": (payload) => unwrap$1(pipe(get$6(gitWorktrees, payload.cwd), map$4((worktree) => worktree.watchReviewRangeDiffs({
53621
53202
  from: payload.from,
53622
53203
  to: payload.to
53623
53204
  })))),
53624
- "runs.scripts": (payload) => pipe(tryPromise({
53625
- catch: (cause) => new TerminalError({
53626
- cause,
53627
- message: `failed to read package.json in ${payload.cwd}`
53628
- }),
53629
- try: () => readFile(join(payload.cwd, "package.json"), "utf8")
53630
- }), map$4(decodeUnknownSync(fromJsonString(Struct({ scripts: optional(Record(String$1, String$1)) })))), map$4((packageJson) => pipe(packageJson.scripts ?? {}, toEntries, map$7(([name, command]) => ({
53631
- command,
53632
- name,
53633
- tasks: splitParallelCommands(command)
53634
- }))))),
53635
- "terminal.ports": (payload) => unwrap$1(pipe(get$6(terminals, TerminalSessionKey.make(payload)), map$4((terminal) => terminal.ports))),
53636
- "terminal.resize": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
53205
+ "runs.portless": (payload) => get$6(portlessWorktrees, payload.cwd),
53206
+ "terminal.resize": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
53637
53207
  cols: payload.cols,
53638
53208
  rows: payload.rows
53639
53209
  }))),
53640
- "terminal.restart": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.restart())),
53641
- "terminal.stop": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.stop())),
53642
- "terminal.watch": (payload) => unwrap$1(pipe(get$6(terminals, TerminalSessionKey.make(payload)), map$4((terminal) => terminal.updates))),
53643
- "terminal.write": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
53210
+ "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
53211
+ "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
53212
+ "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
53213
+ "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
53644
53214
  });
53645
53215
  }));
53646
53216
  //#endregion
@@ -67202,7 +66772,7 @@ const isSampled = (traceFlags) => (traceFlags & TraceFlags.SAMPLED) === TraceFla
67202
66772
  const getOtelParent = (tracer, context, annotations) => {
67203
66773
  const otelParent = tracer.getSpan(context)?.spanContext();
67204
66774
  if (!otelParent) return none();
67205
- return some(externalSpan({
66775
+ return some$1(externalSpan({
67206
66776
  spanId: otelParent.spanId,
67207
66777
  traceId: otelParent.traceId,
67208
66778
  sampled: (otelParent.traceFlags & 1) === 1,
@@ -70423,104 +69993,7 @@ function OtelLayer(serviceName) {
70423
69993
  }
70424
69994
  //#endregion
70425
69995
  //#region src/lib/serverRuntime.ts
70426
- const LiveLayers = pipe(empty$11, provideMerge(RpcHandlers), provideMerge(GitWorkspace.layer), provideMerge(unwrap$4(pipe(string("HOME"), withDefault(process.cwd()), map$4((home) => layerFileSystem(path.join(home, ".deslop")))))), provideMerge(OtelLayer("workbench-server")), provideMerge(layer$16), provideMerge(layerMsgPack));
70427
- //#endregion
70428
- //#region ../../packages/browser/src/http.ts
70429
- const INJECTED_HEAD = `<script>
70430
- (() => {
70431
- if (window.__deslopBrowserBridge) return
70432
- window.__deslopBrowserBridge = true
70433
-
70434
- const serialize = value => {
70435
- if (typeof value === 'string') return value
70436
- try { return JSON.stringify(value) } catch { return String(value) }
70437
- }
70438
- const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
70439
- const sendFavicon = () => {
70440
- const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
70441
- window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
70442
- }
70443
-
70444
- for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
70445
- const original = console[level]
70446
- console[level] = (...args) => {
70447
- send(level, args.map(serialize).join(' '))
70448
- original.apply(console, args)
70449
- }
70450
- }
70451
-
70452
- window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
70453
- window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
70454
- window.addEventListener('message', event => {
70455
- if (event.data?.__deslopBrowserClear !== true) return
70456
- localStorage.clear()
70457
- sessionStorage.clear()
70458
- document.cookie.split(';').forEach(cookie => {
70459
- document.cookie = cookie.replace(/^\\s*([^=]+)=.*$/, '$1=; Max-Age=0; Path=/')
70460
- })
70461
- caches?.keys?.().then(keys => Promise.all(keys.map(key => caches.delete(key))))
70462
- navigator.serviceWorker?.getRegistrations?.().then(registrations => Promise.all(registrations.map(registration => registration.unregister())))
70463
- location.reload()
70464
- })
70465
-
70466
- if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendFavicon, {once: true})
70467
- else sendFavicon()
70468
- })()
70469
- <\/script>
70470
- <script crossorigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" onload="window.reactScan?.({allowInIframe: true, _debug: 'verbose'})"><\/script>
70471
- <script src="https://unpkg.com/react-grab/dist/index.global.js"><\/script>`;
70472
- function injectScripts(html) {
70473
- return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}\n${INJECTED_HEAD}`) : `${INJECTED_HEAD}\n${html}`;
70474
- }
70475
- const proxy = fnUntraced(function* (request, port) {
70476
- const webRequest = yield* toWeb(request);
70477
- const [pathname = "/", search = ""] = request.url.split("?");
70478
- const upstreamHeaders = new Headers(webRequest.headers);
70479
- upstreamHeaders.set("host", `localhost:${port}`);
70480
- const upstreamRequest = new Request(`http://localhost:${port}${pathname}${search ? `?${search}` : ""}`, {
70481
- body: webRequest.body,
70482
- headers: upstreamHeaders,
70483
- method: webRequest.method,
70484
- redirect: webRequest.redirect,
70485
- signal: webRequest.signal
70486
- });
70487
- const upstreamResponse = yield* tryPromise(() => fetch(upstreamRequest));
70488
- const shouldRewriteHtml = request.method === "GET" && (upstreamResponse.headers.get("content-type") ?? "").includes("text/html");
70489
- const headers = new Headers(upstreamResponse.headers);
70490
- headers.delete("content-length");
70491
- headers.delete("content-encoding");
70492
- if (!shouldRewriteHtml) return fromWeb(new Response(upstreamResponse.body, {
70493
- headers,
70494
- status: upstreamResponse.status,
70495
- statusText: upstreamResponse.statusText
70496
- }));
70497
- const body = yield* tryPromise(() => upstreamResponse.text());
70498
- headers.set("content-type", "text/html; charset=utf-8");
70499
- return fromWeb(new Response(injectScripts(body), {
70500
- headers,
70501
- status: upstreamResponse.status,
70502
- statusText: upstreamResponse.statusText
70503
- }));
70504
- });
70505
- const proxyWebSocket = fnUntraced(function* (request, port) {
70506
- const [pathname = "/", search = ""] = request.url.split("?");
70507
- const protocols = request.headers["sec-websocket-protocol"]?.split(",").map((protocol) => protocol.trim()).filter((protocol) => protocol.length > 0);
70508
- const clientSocket = yield* request.upgrade;
70509
- const upstreamSocket = yield* makeWebSocket(`ws://localhost:${port}${pathname}${search ? `?${search}` : ""}`, { protocols }).pipe(provide(layerWebSocketConstructorGlobal));
70510
- const clientWriter = yield* clientSocket.writer;
70511
- const upstreamWriter = yield* upstreamSocket.writer;
70512
- yield* all([clientSocket.runRaw(upstreamWriter), upstreamSocket.runRaw(clientWriter)], { concurrency: "unbounded" }).pipe(scoped$3, catch_$2(() => void_$1));
70513
- return empty();
70514
- });
70515
- function BrowserProxyMiddleware(app) {
70516
- return gen(function* () {
70517
- const request = yield* HttpServerRequest;
70518
- const port = /^(\d+)\.localhost(?::\d+)?$/u.exec(request.headers["host"] ?? "")?.[1];
70519
- if (!port) return yield* app;
70520
- if (request.headers["upgrade"]?.toLowerCase() === "websocket") return yield* proxyWebSocket(request, port);
70521
- return yield* proxy(request, port);
70522
- });
70523
- }
69996
+ const LiveLayers = pipe(empty$11, provideMerge(RpcHandlers), provideMerge(Portless.layer), provideMerge(GitWorkspace.layer), provideMerge(unwrap$4(pipe(string("HOME"), withDefault(process.cwd()), map$4((home) => layerFileSystem(path.join(home, ".deslop")))))), provideMerge(OtelLayer("workbench-server")), provideMerge(layer$16), provideMerge(layerMsgPack));
70524
69997
  //#endregion
70525
69998
  //#region src/main.server.ts
70526
69999
  runMain(pipe(serve(mergeAll$1(layerHttp({
@@ -70531,9 +70004,9 @@ runMain(pipe(serve(mergeAll$1(layerHttp({
70531
70004
  index: "index.html",
70532
70005
  root: fileURLToPath(new URL("./client", import.meta.url)),
70533
70006
  spa: true
70534
- }), middleware(BrowserProxyMiddleware, { global: true }), middleware(xForwardedHeaders, { global: true })), { disableLogger: true }), provide$2(LiveLayers), provide$2(layerConfig(createServer, {
70007
+ }), middleware(Portless.middleware, { global: true }), middleware(xForwardedHeaders, { global: true })), { disableLogger: true }), provide$2(LiveLayers), provide$2(layerConfig(createServer, {
70535
70008
  gracefulShutdownTimeout: succeed("1500 millis"),
70536
- port: port("PORT").pipe(withDefault(4010))
70009
+ port: port("PORT").pipe(withDefault(5010))
70537
70010
  })), provide$2(layer$6), launch));
70538
70011
  //#endregion
70539
70012
  export { __toCommonJS as a, __require as i, init_esm$2 as n, __commonJSMin as r, esm_exports$2 as t };