@deslop/workbench 0.0.315 → 0.0.321

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 (41) hide show
  1. package/dist/client/assets/agent-DAD7EQOa.js +2 -0
  2. package/dist/client/assets/{agent-BIuVSeAF.js → agent-DHWhwvQy.js} +1 -1
  3. package/dist/client/assets/{button-CP1KTzaA.js → button-fe_R2wzr.js} +11 -11
  4. package/dist/client/assets/{diff-B287sB8S.js → diff-BbjpVkn4.js} +10 -10
  5. package/dist/client/assets/diff-HFsBcdrM.js +2 -0
  6. package/dist/client/assets/{external-link-DxUqDR8g.js → external-link-CTjuCORn.js} +1 -1
  7. package/dist/client/assets/{fallbacks-D55g6vQC.js → fallbacks-DZ7ciusO.js} +1 -1
  8. package/dist/client/assets/index-Ci3BZgXN.css +2 -0
  9. package/dist/client/assets/index-Ds4rq0zQ.js +10 -0
  10. package/dist/client/assets/input-group-BtEJur4W.js +153 -0
  11. package/dist/client/assets/loader-circle-B1mHTP2Y.js +1 -0
  12. package/dist/client/assets/portless-DFKFPX3Z.js +1 -0
  13. package/dist/client/assets/portless-DexDlqwA.js +2 -0
  14. package/dist/client/assets/resizable-B1fIW9sm.js +1 -0
  15. package/dist/client/assets/route-CUHeGENe.js +45 -0
  16. package/dist/client/assets/route-DOWKJR6H.js +2 -0
  17. package/dist/client/assets/run-BvHiSlty.js +2 -0
  18. package/dist/client/assets/run-L2YCL4H0.js +1 -0
  19. package/dist/client/assets/state-T-ZhKyUm.js +2 -0
  20. package/dist/client/assets/{terminal-DWl9BK6U.js → terminal-CGe8qF7_.js} +1 -1
  21. package/dist/client/assets/{terminal-CMql1niz.js → terminal-Ci9YBovb.js} +2 -2
  22. package/dist/client/assets/terminal-t4CeG_V9.js +2 -0
  23. package/dist/client/assets/{triangle-alert-BBj9uTaq.js → triangle-alert-CGj-8H_a.js} +1 -1
  24. package/dist/client/index.html +12 -12
  25. package/dist/server.js +532 -1140
  26. package/package.json +5 -4
  27. package/dist/client/assets/agent-Cvk2rNLW.js +0 -2
  28. package/dist/client/assets/browser-ZCteqApb.js +0 -2
  29. package/dist/client/assets/browser-qFOBXYmj.js +0 -1
  30. package/dist/client/assets/composite-DrpN5NPU.js +0 -1
  31. package/dist/client/assets/dialog-DNzOF5Pr.js +0 -153
  32. package/dist/client/assets/diff-Dz1s0ttU.js +0 -2
  33. package/dist/client/assets/index-4j0hsxXB.css +0 -2
  34. package/dist/client/assets/index-C8lKBTMr.js +0 -10
  35. package/dist/client/assets/loader-circle-CjJdQ-6r.js +0 -1
  36. package/dist/client/assets/route-CaWOfZWN.js +0 -2
  37. package/dist/client/assets/route-VC_QtiiN.js +0 -45
  38. package/dist/client/assets/run-B0jQ0k3F.js +0 -2
  39. package/dist/client/assets/run-CFcWKZn5.js +0 -1
  40. package/dist/client/assets/state-m9GNWCBT.js +0 -2
  41. package/dist/client/assets/terminal-CgkXzq-O.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 */
@@ -4569,9 +4567,9 @@ const some$2 = (value) => {
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
  *
@@ -5443,42 +5441,6 @@ const flatMap$6 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(s
5443
5441
  * @since 2.0.0
5444
5442
  */
5445
5443
  const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some$1(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$1(b) : 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)
@@ -6337,6 +6250,96 @@ function isOutOfBounds(i, as) {
6337
6250
  }
6338
6251
  const clamp = (i, as) => Math.floor(Math.min(Math.max(0, i), as.length));
6339
6252
  /**
6253
+ * Reads an element at the given index safely, returning `Option.some` or
6254
+ * `Option.none` if the index is out of bounds.
6255
+ *
6256
+ * **When to use**
6257
+ *
6258
+ * Use when you need to read an array element by index and handle an
6259
+ * out-of-bounds index as `Option.none`.
6260
+ *
6261
+ * **Details**
6262
+ *
6263
+ * - The index is floored to an integer.
6264
+ * - Never throws.
6265
+ *
6266
+ * **Example** (Safe index access)
6267
+ *
6268
+ * ```ts
6269
+ * import { Array } from "effect"
6270
+ *
6271
+ * console.log(Array.get([1, 2, 3], 1)) // Some(2)
6272
+ * console.log(Array.get([1, 2, 3], 10)) // None
6273
+ * ```
6274
+ *
6275
+ * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds
6276
+ * @see {@link head} for reading the first element as an `Option`
6277
+ * @see {@link last} for reading the last element as an `Option`
6278
+ *
6279
+ * @category getters
6280
+ * @since 2.0.0
6281
+ */
6282
+ const get$10 = /*#__PURE__*/ dual(2, (self, index) => {
6283
+ const i = Math.floor(index);
6284
+ return isOutOfBounds(i, self) ? none() : some$1(self[i]);
6285
+ });
6286
+ /**
6287
+ * Reads an element at the given index, throwing if the index is out of bounds.
6288
+ *
6289
+ * **When to use**
6290
+ *
6291
+ * Use to read an element at a known valid index when out-of-bounds would be a
6292
+ * programming error.
6293
+ *
6294
+ * **Details**
6295
+ *
6296
+ * - Throws an `Error` with the message `"Index out of bounds: <i>"`.
6297
+ * - Prefer {@link get} for safe access.
6298
+ *
6299
+ * **Example** (Unsafe index access)
6300
+ *
6301
+ * ```ts
6302
+ * import { Array } from "effect"
6303
+ *
6304
+ * console.log(Array.getUnsafe([1, 2, 3], 1)) // 2
6305
+ * // Array.getUnsafe([1, 2, 3], 10) // throws Error
6306
+ * ```
6307
+ *
6308
+ * @see {@link get} — safe version returning `Option`
6309
+ *
6310
+ * @category unsafe
6311
+ * @since 4.0.0
6312
+ */
6313
+ const getUnsafe$1 = /*#__PURE__*/ dual(2, (self, index) => {
6314
+ const i = Math.floor(index);
6315
+ if (isOutOfBounds(i, self)) throw new Error(`Index out of bounds: ${i}`);
6316
+ return self[i];
6317
+ });
6318
+ /**
6319
+ * Returns the first element of an array safely wrapped in `Option.some`, or
6320
+ * `Option.none` if the array is empty.
6321
+ *
6322
+ * **When to use**
6323
+ *
6324
+ * Use to safely get the first element of an array that may be empty.
6325
+ *
6326
+ * **Example** (Getting the first element)
6327
+ *
6328
+ * ```ts
6329
+ * import { Array } from "effect"
6330
+ *
6331
+ * console.log(Array.head([1, 2, 3])) // Some(1)
6332
+ * console.log(Array.head([])) // None
6333
+ * ```
6334
+ *
6335
+ * @see {@link headNonEmpty} — direct access when array is known non-empty
6336
+ * @see {@link last} — get the last element
6337
+ *
6338
+ * @category getters
6339
+ * @since 2.0.0
6340
+ */
6341
+ const head = /*#__PURE__*/ get$10(0);
6342
+ /**
6340
6343
  * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option`
6341
6344
  * wrapper).
6342
6345
  *
@@ -6358,11 +6361,7 @@ const clamp = (i, as) => Math.floor(Math.min(Math.max(0, i), as.length));
6358
6361
  * @category getters
6359
6362
  * @since 2.0.0
6360
6363
  */
6361
- const headNonEmpty = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, index) => {
6362
- const i = Math.floor(index);
6363
- if (isOutOfBounds(i, self)) throw new Error(`Index out of bounds: ${i}`);
6364
- return self[i];
6365
- }))(0);
6364
+ const headNonEmpty = /*#__PURE__*/ getUnsafe$1(0);
6366
6365
  /**
6367
6366
  * Returns the last element of an array safely wrapped in `Option.some`, or
6368
6367
  * `Option.none` if the array is empty.
@@ -6527,38 +6526,6 @@ const drop$1 = /*#__PURE__*/ dual(2, (self, n) => {
6527
6526
  */
6528
6527
  const reverse = (self) => Array$1.from(self).reverse();
6529
6528
  /**
6530
- * Sorts an array by the given `Order`, returning a new array.
6531
- *
6532
- * **When to use**
6533
- *
6534
- * Use to sort an array using a single `Order` comparator.
6535
- *
6536
- * **Details**
6537
- *
6538
- * - Preserves `NonEmptyArray` in the return type.
6539
- * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for
6540
- * multi-key sorting.
6541
- *
6542
- * **Example** (Sorting numbers)
6543
- *
6544
- * ```ts
6545
- * import { Array, Order } from "effect"
6546
- *
6547
- * console.log(Array.sort([3, 1, 4, 1, 5], Order.Number)) // [1, 1, 3, 4, 5]
6548
- * ```
6549
- *
6550
- * @see {@link sortWith} — sort by a mapping function
6551
- * @see {@link sortBy} — sort by multiple orders
6552
- *
6553
- * @category sorting
6554
- * @since 2.0.0
6555
- */
6556
- const sort = /*#__PURE__*/ dual(2, (self, O) => {
6557
- const out = Array$1.from(self);
6558
- out.sort(O);
6559
- return out;
6560
- });
6561
- /**
6562
6529
  * Sorts an array by a derived key using a mapping function and an `Order` for
6563
6530
  * that key.
6564
6531
  *
@@ -6793,6 +6760,28 @@ const flatMap$5 = /*#__PURE__*/ dual(2, (self, f) => {
6793
6760
  return out;
6794
6761
  });
6795
6762
  /**
6763
+ * Flattens a nested array of arrays into a single array.
6764
+ *
6765
+ * **When to use**
6766
+ *
6767
+ * Use to collapse one level of nested arrays when no per-element mapping is
6768
+ * needed.
6769
+ *
6770
+ * **Example** (Flattening nested arrays)
6771
+ *
6772
+ * ```ts
6773
+ * import { Array } from "effect"
6774
+ *
6775
+ * console.log(Array.flatten([[1, 2], [], [3, 4], [], [5, 6]])) // [1, 2, 3, 4, 5, 6]
6776
+ * ```
6777
+ *
6778
+ * @see {@link flatMap} — map then flatten in one step
6779
+ *
6780
+ * @category sequencing
6781
+ * @since 2.0.0
6782
+ */
6783
+ const flatten$3 = /*#__PURE__*/ flatMap$5(identity);
6784
+ /**
6796
6785
  * Extracts all `Some` values from an iterable of `Option`s, discarding `None`s.
6797
6786
  *
6798
6787
  * **When to use**
@@ -6849,43 +6838,6 @@ const getSuccesses = (self) => {
6849
6838
  return out;
6850
6839
  };
6851
6840
  /**
6852
- * Keeps transformed values for elements where a `Filter` succeeds.
6853
- *
6854
- * **When to use**
6855
- *
6856
- * Use to transform elements with a `Result`-returning filter while discarding
6857
- * failures.
6858
- *
6859
- * **Details**
6860
- *
6861
- * - The filter receives `(element, index)`.
6862
- * - Failures are discarded.
6863
- *
6864
- * **Example** (Filter and transform)
6865
- *
6866
- * ```ts
6867
- * import { Array, Result } from "effect"
6868
- *
6869
- * console.log(Array.filterMap([1, 2, 3, 4], (n) => n % 2 === 0 ? Result.succeed(n * 10) : Result.failVoid))
6870
- * // [20, 40]
6871
- * ```
6872
- *
6873
- * @see {@link filter} — keep original elements matching a predicate
6874
- * @see {@link partition} for keeping both failures and successes
6875
- *
6876
- * @category filtering
6877
- * @since 2.0.0
6878
- */
6879
- const filterMap$1 = /*#__PURE__*/ dual(2, (self, f) => {
6880
- const as = fromIterable$2(self);
6881
- const out = [];
6882
- for (let i = 0; i < as.length; i++) {
6883
- const result = f(as[i], i);
6884
- if (isSuccess$1(result)) out.push(result.success);
6885
- }
6886
- return out;
6887
- });
6888
- /**
6889
6841
  * Keeps only elements satisfying a predicate (or refinement).
6890
6842
  *
6891
6843
  * **When to use**
@@ -7041,30 +6993,6 @@ const dedupeWith = /*#__PURE__*/ dual(2, (self, isEquivalent) => {
7041
6993
  return [];
7042
6994
  });
7043
6995
  /**
7044
- * Removes duplicates using `Equal.equivalence()`, preserving the order of the
7045
- * first occurrence.
7046
- *
7047
- * **When to use**
7048
- *
7049
- * Use to remove repeated values from an iterable when Effect's default equality
7050
- * is the right comparison, preserving the first occurrence.
7051
- *
7052
- * **Example** (Removing duplicates)
7053
- *
7054
- * ```ts
7055
- * import { Array } from "effect"
7056
- *
7057
- * console.log(Array.dedupe([1, 2, 1, 3, 2, 4])) // [1, 2, 3, 4]
7058
- * ```
7059
- *
7060
- * @see {@link dedupeWith} — use custom equality
7061
- * @see {@link dedupeAdjacent} — only dedupes consecutive elements
7062
- *
7063
- * @category elements
7064
- * @since 2.0.0
7065
- */
7066
- const dedupe = (self) => dedupeWith(self, asEquivalence());
7067
- /**
7068
6996
  * Joins string elements with a separator.
7069
6997
  *
7070
6998
  * **Example** (Joining strings)
@@ -7080,7 +7008,7 @@ const dedupe = (self) => dedupeWith(self, asEquivalence());
7080
7008
  * @category folding
7081
7009
  * @since 2.0.0
7082
7010
  */
7083
- const join$3 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$2(self).join(sep));
7011
+ const join$2 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$2(self).join(sep));
7084
7012
  //#endregion
7085
7013
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Effectable.js
7086
7014
  /**
@@ -7217,7 +7145,7 @@ const ServiceProto = {
7217
7145
  }
7218
7146
  };
7219
7147
  const ReferenceTypeId = "~effect/Context/Reference";
7220
- const TypeId$49 = "~effect/Context";
7148
+ const TypeId$48 = "~effect/Context";
7221
7149
  /**
7222
7150
  * Creates a `Context` from an existing service map without validating or
7223
7151
  * copying it.
@@ -7252,7 +7180,7 @@ const makeUnsafe$8 = (mapUnsafe) => {
7252
7180
  };
7253
7181
  const Proto$15 = {
7254
7182
  ...PipeInspectableProto,
7255
- [TypeId$49]: { _Services: (_) => _ },
7183
+ [TypeId$48]: { _Services: (_) => _ },
7256
7184
  toJSON() {
7257
7185
  return {
7258
7186
  _id: "Context",
@@ -7304,7 +7232,7 @@ const Proto$15 = {
7304
7232
  * @category guards
7305
7233
  * @since 2.0.0
7306
7234
  */
7307
- const isContext = (u) => hasProperty(u, TypeId$49);
7235
+ const isContext = (u) => hasProperty(u, TypeId$48);
7308
7236
  /**
7309
7237
  * Checks whether the provided argument is a `Reference`.
7310
7238
  *
@@ -7808,7 +7736,7 @@ const withMapUnsafe = (self, f) => {
7808
7736
  const Reference = Service;
7809
7737
  //#endregion
7810
7738
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Duration.js
7811
- const TypeId$48 = "~effect/time/Duration";
7739
+ const TypeId$47 = "~effect/time/Duration";
7812
7740
  const bigint0$2 = /*#__PURE__*/ BigInt(0);
7813
7741
  const bigint1e3 = /*#__PURE__*/ BigInt(1e3);
7814
7742
  const bigint1e6 = /*#__PURE__*/ BigInt(1e6);
@@ -7867,7 +7795,7 @@ const fromInputUnsafe = (input) => {
7867
7795
  }
7868
7796
  case "object": {
7869
7797
  if (input === null) break;
7870
- if (TypeId$48 in input) return input;
7798
+ if (TypeId$47 in input) return input;
7871
7799
  if (Array.isArray(input)) {
7872
7800
  if (input.length !== 2 || !input.every(isNumber)) return invalid(input);
7873
7801
  if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$1;
@@ -7902,7 +7830,7 @@ const zeroDurationValue = {
7902
7830
  const infinityDurationValue = { _tag: "Infinity" };
7903
7831
  const negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
7904
7832
  const DurationProto = {
7905
- [TypeId$48]: TypeId$48,
7833
+ [TypeId$47]: TypeId$47,
7906
7834
  [symbol$3]() {
7907
7835
  return structure(this.value);
7908
7836
  },
@@ -7980,7 +7908,7 @@ const make$61 = (input) => {
7980
7908
  * @category guards
7981
7909
  * @since 2.0.0
7982
7910
  */
7983
- const isDuration = (u) => hasProperty(u, TypeId$48);
7911
+ const isDuration = (u) => hasProperty(u, TypeId$47);
7984
7912
  /**
7985
7913
  * Checks whether a Duration is finite (not infinite).
7986
7914
  *
@@ -9829,7 +9757,7 @@ const provideServiceImpl = (self, service, implementation) => updateContext$1(se
9829
9757
  /** @internal */
9830
9758
  const when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$4(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
9831
9759
  /** @internal */
9832
- const forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9760
+ const forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9833
9761
  while: constTrue,
9834
9762
  body: constant(options?.disableYield ? self : flatMap$4(self, (_) => yieldNow$1)),
9835
9763
  step: constVoid
@@ -10857,7 +10785,7 @@ const reportCauseUnsafe = (fiber, cause, defectsOnly) => {
10857
10785
  };
10858
10786
  //#endregion
10859
10787
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Deferred.js
10860
- const TypeId$47 = "~effect/Deferred";
10788
+ const TypeId$46 = "~effect/Deferred";
10861
10789
  /**
10862
10790
  * Checks whether a value is a `Deferred`.
10863
10791
  *
@@ -10869,9 +10797,9 @@ const TypeId$47 = "~effect/Deferred";
10869
10797
  * @category guards
10870
10798
  * @since 4.0.0
10871
10799
  */
10872
- const isDeferred = (u) => hasProperty(u, TypeId$47);
10800
+ const isDeferred = (u) => hasProperty(u, TypeId$46);
10873
10801
  const DeferredProto = {
10874
- [TypeId$47]: {
10802
+ [TypeId$46]: {
10875
10803
  _A: identity,
10876
10804
  _E: identity
10877
10805
  },
@@ -11913,14 +11841,14 @@ const close = scopeClose;
11913
11841
  const closeUnsafe = scopeCloseUnsafe;
11914
11842
  //#endregion
11915
11843
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Layer.js
11916
- const TypeId$46 = "~effect/Layer";
11844
+ const TypeId$45 = "~effect/Layer";
11917
11845
  const MemoMapTypeId = "~effect/Layer/MemoMap";
11918
11846
  const memoMapReuse = (entry, scope) => {
11919
11847
  entry.observers++;
11920
11848
  return andThen$1(scopeAddFinalizerExit(scope, (exit) => entry.finalizer(exit)), entry.effect);
11921
11849
  };
11922
11850
  const LayerProto = {
11923
- [TypeId$46]: {
11851
+ [TypeId$45]: {
11924
11852
  _ROut: identity,
11925
11853
  _E: identity,
11926
11854
  _RIn: identity
@@ -13715,11 +13643,11 @@ const Clock = ClockRef;
13715
13643
  //#endregion
13716
13644
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/dateTime.js
13717
13645
  /** @internal */
13718
- const TypeId$45 = "~effect/time/DateTime";
13646
+ const TypeId$44 = "~effect/time/DateTime";
13719
13647
  /** @internal */
13720
13648
  const TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
13721
13649
  const Proto$14 = {
13722
- [TypeId$45]: TypeId$45,
13650
+ [TypeId$44]: TypeId$44,
13723
13651
  pipe() {
13724
13652
  return pipeArguments(this, arguments);
13725
13653
  },
@@ -13982,76 +13910,6 @@ const endsWith = (searchString, position) => (self) => self.endsWith(searchStrin
13982
13910
  * @since 2.0.0
13983
13911
  */
13984
13912
  const replaceAll = (searchValue, replaceValue) => (self) => self.replaceAll(searchValue, replaceValue);
13985
- const CR = 13;
13986
- const LF = 10;
13987
- /**
13988
- * Returns an `IterableIterator` which yields each line contained within the
13989
- * string, trimming off the trailing newline character.
13990
- *
13991
- * **Example** (Iterating lines without separators)
13992
- *
13993
- * ```ts
13994
- * import { String } from "effect"
13995
- *
13996
- * const lines = String.linesIterator("hello\nworld\n")
13997
- * console.log(Array.from(lines)) // ["hello", "world"]
13998
- * ```
13999
- *
14000
- * @category splitting
14001
- * @since 2.0.0
14002
- */
14003
- const linesIterator = (self) => linesSeparated(self, true);
14004
- var LinesIterator = class LinesIterator {
14005
- index;
14006
- length;
14007
- s;
14008
- stripped;
14009
- constructor(s, stripped = false) {
14010
- this.s = s;
14011
- this.stripped = stripped;
14012
- this.index = 0;
14013
- this.length = s.length;
14014
- }
14015
- next() {
14016
- if (this.done) return {
14017
- done: true,
14018
- value: void 0
14019
- };
14020
- const start = this.index;
14021
- while (!this.done && !isLineBreak(this.s[this.index])) this.index = this.index + 1;
14022
- let end = this.index;
14023
- if (!this.done) {
14024
- const char = this.s[this.index];
14025
- this.index = this.index + 1;
14026
- if (!this.done && isLineBreak2(char, this.s[this.index])) this.index = this.index + 1;
14027
- if (!this.stripped) end = this.index;
14028
- }
14029
- return {
14030
- done: false,
14031
- value: this.s.substring(start, end)
14032
- };
14033
- }
14034
- [Symbol.iterator]() {
14035
- return new LinesIterator(this.s, this.stripped);
14036
- }
14037
- get done() {
14038
- return this.index >= this.length;
14039
- }
14040
- };
14041
- /**
14042
- * Checks whether the provided character is a line break character (i.e. either `"\r"`
14043
- * or `"\n"`).
14044
- */
14045
- const isLineBreak = (char) => {
14046
- const code = char.charCodeAt(0);
14047
- return code === CR || code === LF;
14048
- };
14049
- /**
14050
- * Checks whether the provided characters combine to form a carriage return/line-feed
14051
- * (i.e. `"\r\n"`).
14052
- */
14053
- const isLineBreak2 = (char0, char1) => char0.charCodeAt(0) === CR && char1.charCodeAt(0) === LF;
14054
- const linesSeparated = (self, stripped) => new LinesIterator(self, stripped);
14055
13913
  //#endregion
14056
13914
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/random.js
14057
13915
  /** @internal */
@@ -14234,434 +14092,10 @@ const matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$
14234
14092
  }
14235
14093
  }));
14236
14094
  //#endregion
14237
- //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Schedule.js
14238
- /**
14239
- * Declarative policies for retrying, repeating, and pacing Effect programs.
14240
- *
14241
- * A `Schedule<Output, Input, Error, Env>` is a stateful policy that is stepped
14242
- * with an input value. Each step either stops the recurrence or emits an output
14243
- * together with the delay before the next step. Schedules are values: they can
14244
- * be transformed, combined, and passed to retry, repeat, stream, and channel
14245
- * APIs without running anything until the surrounding Effect program runs.
14246
- *
14247
- * **Mental model**
14248
- *
14249
- * - Constructors such as {@link recurs}, {@link spaced}, {@link fixed},
14250
- * {@link exponential}, and {@link fibonacci} define the base cadence or
14251
- * stopping rule.
14252
- * - Combinators such as {@link both}, {@link either}, and {@link andThen}
14253
- * combine schedules and determine both stopping behavior and output shape.
14254
- * - Delay helpers such as {@link addDelay}, {@link modifyDelay}, and
14255
- * {@link jittered} adjust pacing while preserving the schedule's control
14256
- * flow.
14257
- * - Metadata-aware constructors and {@link CurrentMetadata} expose attempts,
14258
- * elapsed time, input, output, and duration for advanced policies.
14259
- *
14260
- * **Common tasks**
14261
- *
14262
- * - Retry a failing effect with exponential backoff and a maximum retry count.
14263
- * - Repeat a successful effect on a fixed or spaced interval.
14264
- * - Add jitter so concurrent clients do not retry at the same instant.
14265
- * - Transform or retain schedule outputs with {@link map},
14266
- * {@link collectOutputs}, and {@link take}.
14267
- *
14268
- * **Example** (Retrying with bounded exponential backoff)
14269
- *
14270
- * ```ts
14271
- * import { Effect, Schedule } from "effect"
14272
- *
14273
- * let attempts = 0
14274
- *
14275
- * const request = Effect.sync(() => {
14276
- * attempts += 1
14277
- * return attempts
14278
- * }).pipe(
14279
- * Effect.flatMap((attempt) =>
14280
- * attempt < 3 ? Effect.fail("temporary failure") : Effect.succeed("ok")
14281
- * )
14282
- * )
14283
- *
14284
- * const policy = Schedule.exponential("100 millis").pipe(
14285
- * Schedule.jittered,
14286
- * Schedule.both(Schedule.recurs(5))
14287
- * )
14288
- *
14289
- * const program = Effect.retry(request, policy)
14290
- * ```
14291
- *
14292
- * **Gotchas**
14293
- *
14294
- * - A schedule is a description; delays happen only when an operation such as
14295
- * `Effect.retry` or `Effect.repeat` runs it.
14296
- * - `Schedule.recurs(3)` allows three recurrences in addition to the first run
14297
- * performed by retry or repeat.
14298
- * - Combining schedules changes the output type as well as the stopping rule,
14299
- * so check the resulting type when using {@link both}, {@link either}, or
14300
- * {@link andThen}.
14301
- *
14302
- * @since 2.0.0
14303
- */
14304
- const TypeId$44 = "~effect/Schedule";
14305
- /**
14306
- * Context reference containing metadata for the currently running schedule step.
14307
- *
14308
- * **Details**
14309
- *
14310
- * Repeat, retry, stream, and channel scheduling operations provide this service
14311
- * to effects run between schedule steps. The default value contains undefined
14312
- * input and output values, zero duration, and zeroed timing fields before any
14313
- * schedule step has produced metadata.
14314
- *
14315
- * @category metadata
14316
- * @since 4.0.0
14317
- */
14318
- const CurrentMetadata = /*#__PURE__*/ Reference("effect/Schedule/CurrentMetadata", { defaultValue: /*#__PURE__*/ constant({
14319
- input: void 0,
14320
- output: void 0,
14321
- duration: zero$1,
14322
- attempt: 0,
14323
- start: 0,
14324
- now: 0,
14325
- elapsed: 0,
14326
- elapsedSincePrevious: 0
14327
- }) });
14328
- const ScheduleProto = {
14329
- [TypeId$44]: {
14330
- _Out: identity,
14331
- _In: identity,
14332
- _Env: identity
14333
- },
14334
- pipe() {
14335
- return pipeArguments(this, arguments);
14336
- }
14337
- };
14338
- /**
14339
- * Type guard that checks if a value is a Schedule.
14340
- *
14341
- * **Example** (Checking for schedules)
14342
- *
14343
- * ```ts
14344
- * import { Schedule } from "effect"
14345
- *
14346
- * const schedule = Schedule.exponential("100 millis")
14347
- * const notSchedule = { foo: "bar" }
14348
- *
14349
- * console.log(Schedule.isSchedule(schedule)) // true
14350
- * console.log(Schedule.isSchedule(notSchedule)) // false
14351
- * console.log(Schedule.isSchedule(null)) // false
14352
- * console.log(Schedule.isSchedule(undefined)) // false
14353
- * ```
14354
- *
14355
- * @category guards
14356
- * @since 2.0.0
14357
- */
14358
- const isSchedule = (u) => hasProperty(u, TypeId$44);
14359
- /**
14360
- * Creates a Schedule from a step function that returns a Pull.
14361
- *
14362
- * **Example** (Creating a custom schedule from a step function)
14363
- *
14364
- * ```ts
14365
- * import { Cause, Duration, Effect, Schedule } from "effect"
14366
- *
14367
- * const schedule = Schedule.fromStep(Effect.sync(() => {
14368
- * let count = 0
14369
- *
14370
- * return (_now: number, _input: string) => {
14371
- * if (count >= 3) {
14372
- * return Cause.done(count)
14373
- * }
14374
- * return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
14375
- * }
14376
- * }))
14377
- * ```
14378
- *
14379
- * @category constructors
14380
- * @since 4.0.0
14381
- */
14382
- const fromStep = (step) => {
14383
- const self = Object.create(ScheduleProto);
14384
- self.step = step;
14385
- return self;
14386
- };
14387
- const metadataFn = () => {
14388
- let n = 0;
14389
- let previous;
14390
- let start;
14391
- return (now, input) => {
14392
- if (start === void 0) start = now;
14393
- const elapsed = now - start;
14394
- const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
14395
- previous = now;
14396
- return {
14397
- input,
14398
- attempt: ++n,
14399
- start,
14400
- now,
14401
- elapsed,
14402
- elapsedSincePrevious
14403
- };
14404
- };
14405
- };
14406
- /**
14407
- * Creates a Schedule from a step function that receives metadata about the schedule's execution.
14408
- *
14409
- * **Example** (Creating a metadata-aware schedule)
14410
- *
14411
- * ```ts
14412
- * import { Cause, Duration, Effect, Schedule } from "effect"
14413
- *
14414
- * const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
14415
- * if (metadata.attempt > 3) {
14416
- * return Cause.done("finished")
14417
- * }
14418
- *
14419
- * return Effect.succeed([
14420
- * `attempt ${metadata.attempt}: ${metadata.input}`,
14421
- * Duration.millis(250)
14422
- * ] as [string, Duration.Duration])
14423
- * }))
14424
- * ```
14425
- *
14426
- * @category constructors
14427
- * @since 4.0.0
14428
- */
14429
- const fromStepWithMetadata = (step) => fromStep(map$6(step, (f) => {
14430
- const meta = metadataFn();
14431
- return (now, input) => f(meta(now, input));
14432
- }));
14433
- /**
14434
- * Extracts the step function from a Schedule.
14435
- *
14436
- * **Example** (Extracting a schedule step function)
14437
- *
14438
- * ```ts
14439
- * import { Effect, Schedule } from "effect"
14440
- *
14441
- * // Extract step function from an existing schedule
14442
- * const schedule = Schedule.exponential("100 millis").pipe(Schedule.take(3))
14443
- *
14444
- * const program = Effect.gen(function*() {
14445
- * const stepFn = yield* Schedule.toStep(schedule)
14446
- *
14447
- * // Use the step function directly for custom logic. The timestamp is
14448
- * // supplied by the caller, so tests can pass a deterministic value.
14449
- * const now = 0
14450
- * const result = yield* stepFn(now, "input")
14451
- *
14452
- * console.log(`Step result: ${result}`)
14453
- * })
14454
- * ```
14455
- *
14456
- * @category destructors
14457
- * @since 4.0.0
14458
- */
14459
- const toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$6(() => failCause$5(cause)));
14460
- /**
14461
- * Extracts a step function from a `Schedule` that sleeps for each computed
14462
- * delay and returns metadata for the completed step.
14463
- *
14464
- * **When to use**
14465
- *
14466
- * Use to drive a schedule manually while preserving the computed output,
14467
- * delay, input, attempt, and elapsed timing metadata for each step.
14468
- *
14469
- * **Details**
14470
- *
14471
- * The returned step reads the current time from `Clock` when invoked, calls the
14472
- * schedule step with that timestamp and input, sleeps for the returned
14473
- * duration, and then yields `Metadata`.
14474
- *
14475
- * @see {@link toStep} for manually supplying the timestamp and handling the returned delay yourself
14476
- * @see {@link toStepWithSleep} for the same automatic sleeping behavior when only the schedule output is needed
14477
- *
14478
- * @category destructors
14479
- * @since 4.0.0
14480
- */
14481
- const toStepWithMetadata = (schedule) => clockWith$1((clock) => map$6(toStep(schedule), (step) => {
14482
- const metaFn = metadataFn();
14483
- return (input) => suspend$3(() => {
14484
- const now = clock.currentTimeMillisUnsafe();
14485
- return flatMap$4(step(now, input), ([output, duration]) => {
14486
- const meta = metaFn(now, input);
14487
- meta.output = output;
14488
- meta.duration = duration;
14489
- return as$1(sleep$1(duration), meta);
14490
- });
14491
- });
14492
- }));
14493
- /**
14494
- * Returns a new `Schedule` that outputs the inputs of the specified schedule.
14495
- *
14496
- * **Example** (Passing inputs through as outputs)
14497
- *
14498
- * ```ts
14499
- * import { Console, Effect, Schedule } from "effect"
14500
- *
14501
- * // Create a schedule that outputs the inputs instead of original outputs
14502
- * const inputSchedule = Schedule.passthrough(
14503
- * Schedule.exponential("100 millis").pipe(Schedule.take(3))
14504
- * )
14505
- *
14506
- * const program = Effect.gen(function*() {
14507
- * let counter = 0
14508
- * yield* Effect.repeat(
14509
- * Effect.gen(function*() {
14510
- * counter++
14511
- * yield* Console.log(`Task ${counter} executed`)
14512
- * return `result-${counter}`
14513
- * }),
14514
- * inputSchedule
14515
- * )
14516
- * })
14517
- * ```
14518
- *
14519
- * @category mapping
14520
- * @since 2.0.0
14521
- */
14522
- const passthrough$2 = (self) => fromStep(map$6(toStep(self), (step) => (now, input) => matchEffect$1(step(now, input), {
14523
- onSuccess: (result) => succeed$6([input, result[1]]),
14524
- onFailure: failCause$5,
14525
- onDone: () => done(input)
14526
- })));
14527
- /**
14528
- * Returns a schedule that recurs continuously, each repetition spaced the
14529
- * specified duration from the last run.
14530
- *
14531
- * **When to use**
14532
- *
14533
- * Use when each delay should start after the previous action
14534
- * completes. Use `fixed` when recurrences should stay aligned to a regular
14535
- * cadence.
14536
- *
14537
- * **Example** (Repeating with fixed spacing)
14538
- *
14539
- * ```ts
14540
- * import { Console, Effect, Schedule } from "effect"
14541
- *
14542
- * // Basic spaced schedule - runs every 2 seconds
14543
- * const everyTwoSeconds = Schedule.spaced("2 seconds")
14544
- *
14545
- * // Heartbeat that runs indefinitely with fixed spacing
14546
- * const heartbeat = Effect.gen(function*() {
14547
- * yield* Console.log("Heartbeat")
14548
- * }).pipe(
14549
- * Effect.repeat(everyTwoSeconds)
14550
- * )
14551
- *
14552
- * // Limited repeat - run only 5 times with 1-second spacing
14553
- * const limitedTask = Effect.gen(function*() {
14554
- * yield* Console.log("Executing scheduled task...")
14555
- * yield* Effect.sleep("500 millis") // simulate work
14556
- * return "Task completed"
14557
- * }).pipe(
14558
- * Effect.repeat(
14559
- * Schedule.spaced("1 second").pipe(Schedule.take(5))
14560
- * )
14561
- * )
14562
- *
14563
- * // Simple spaced schedule with limited repetitions
14564
- * const limitedSpaced = Schedule.spaced("100 millis").pipe(
14565
- * Schedule.both(Schedule.recurs(5)) // at most 5 times
14566
- * )
14567
- *
14568
- * const program = Effect.gen(function*() {
14569
- * yield* Console.log("Starting spaced execution...")
14570
- *
14571
- * yield* Effect.repeat(
14572
- * Effect.succeed("work item"),
14573
- * limitedSpaced
14574
- * )
14575
- *
14576
- * yield* Console.log("Completed executions")
14577
- * })
14578
- * ```
14579
- *
14580
- * @see {@link fixed} for recurrence aligned to a regular cadence
14581
- *
14582
- * @category constructors
14583
- * @since 2.0.0
14584
- */
14585
- const spaced = (duration) => {
14586
- const decoded = fromInputUnsafe(duration);
14587
- return fromStepWithMetadata(succeed$6((meta) => succeed$6([meta.attempt - 1, decoded])));
14588
- };
14589
- const while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$6(toStep(self), (step) => {
14590
- const meta = metadataFn();
14591
- return (now, input) => flatMap$4(step(now, input), (result) => {
14592
- const [output, duration] = result;
14593
- const eff = predicate({
14594
- ...meta(now, input),
14595
- output,
14596
- duration
14597
- });
14598
- return flatMap$4(isEffect$1(eff) ? eff : succeed$6(eff), (check) => check ? succeed$6(result) : done(output));
14599
- });
14600
- })));
14601
- /**
14602
- * Returns a new `Schedule` that will recur forever.
14603
- *
14604
- * **Details**
14605
- *
14606
- * The output of the schedule is the current count of its repetitions thus far
14607
- * (i.e. `0, 1, 2, ...`).
14608
- *
14609
- * **Example** (Repeating forever)
14610
- *
14611
- * ```ts
14612
- * import { Console, Effect, Schedule } from "effect"
14613
- *
14614
- * // A schedule that runs forever with no delay
14615
- * const infiniteSchedule = Schedule.forever
14616
- *
14617
- * const program = Effect.gen(function*() {
14618
- * yield* Effect.repeat(
14619
- * Effect.gen(function*() {
14620
- * yield* Console.log("Running forever...")
14621
- * return "continuous-task"
14622
- * }),
14623
- * infiniteSchedule.pipe(Schedule.take(5)) // Limit for demo
14624
- * )
14625
- * })
14626
- * ```
14627
- *
14628
- * @category constructors
14629
- * @since 2.0.0
14630
- */
14631
- const forever$1 = /*#__PURE__*/ spaced(zero$1);
14632
- //#endregion
14633
14095
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/layer.js
14634
14096
  const provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$4(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$3(self, context)));
14635
14097
  /** @internal */
14636
14098
  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));
14637
- //#endregion
14638
- //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/schedule.js
14639
- /** @internal */
14640
- const repeatOrElse = /*#__PURE__*/ dual(3, (self, schedule, orElse) => flatMap$4(toStepWithMetadata(schedule), (step) => {
14641
- let meta = CurrentMetadata.defaultValue();
14642
- return catch_$3(forever$2(tap$1(flatMap$4(suspend$3(() => provideService$1(self, CurrentMetadata, meta)), step), (meta_) => sync$1(() => {
14643
- meta = meta_;
14644
- })), { disableYield: true }), (error) => isDone$2(error) ? succeed$6(error.value) : orElse(error, meta.attempt === 0 ? none() : some$1(meta)));
14645
- }));
14646
- /** @internal */
14647
- const repeat$1 = /*#__PURE__*/ dual(2, (self, options) => {
14648
- return repeatOrElse(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$6);
14649
- });
14650
- const passthroughForever = /*#__PURE__*/ passthrough$2(forever$1);
14651
- /** @internal */
14652
- const buildFromOptions = (options) => {
14653
- let schedule = options.schedule ? passthrough$2(options.schedule) : passthroughForever;
14654
- if (options.while) schedule = while_(schedule, ({ input }) => {
14655
- const applied = options.while(input);
14656
- return isEffect$1(applied) ? applied : succeed$6(applied);
14657
- });
14658
- if (options.until) schedule = while_(schedule, ({ input }) => {
14659
- const applied = options.until(input);
14660
- return isEffect$1(applied) ? map$6(applied, (b) => !b) : succeed$6(!applied);
14661
- });
14662
- if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$6(attempt <= options.times));
14663
- return schedule;
14664
- };
14665
14099
  /**
14666
14100
  * Context reference for the metric registry in the current context.
14667
14101
  *
@@ -17772,84 +17206,7 @@ const interruptibleMask = interruptibleMask$1;
17772
17206
  * @category repetition
17773
17207
  * @since 2.0.0
17774
17208
  */
17775
- const forever = forever$2;
17776
- /**
17777
- * Repeats an effect based on a specified schedule or until the first failure.
17778
- *
17779
- * **When to use**
17780
- *
17781
- * Use to rerun an effect after successful executions.
17782
- *
17783
- * **Details**
17784
- *
17785
- * This function executes an effect repeatedly according to the given schedule.
17786
- * Each repetition occurs after the initial execution of the effect, meaning
17787
- * that the schedule determines the number of additional repetitions. For
17788
- * example, using `Schedule.once` will result in the effect being executed twice
17789
- * (once initially and once as part of the repetition).
17790
- *
17791
- * If the effect succeeds, it is repeated according to the schedule. If it
17792
- * fails, the repetition stops immediately, and the failure is returned.
17793
- *
17794
- * The schedule can also specify delays between repetitions, making it useful
17795
- * for tasks like retrying operations with backoff, periodic execution, or
17796
- * performing a series of dependent actions.
17797
- *
17798
- * You can combine schedules for more advanced repetition logic, such as adding
17799
- * delays, limiting recursions, or dynamically adjusting based on the outcome of
17800
- * each execution.
17801
- *
17802
- * **Gotchas**
17803
- *
17804
- * The source effect is always evaluated once before the schedule is stepped.
17805
- * The schedule controls additional repetitions, not the initial execution.
17806
- *
17807
- * **Example** (Repeating successful effects with a schedule)
17808
- *
17809
- * ```ts
17810
- * // Success Example
17811
- * import { Console, Effect, Schedule } from "effect"
17812
- *
17813
- * const action = Console.log("success")
17814
- * const policy = Schedule.addDelay(Schedule.recurs(2), () => Effect.succeed("100 millis"))
17815
- * const program = Effect.repeat(action, policy)
17816
- *
17817
- * // Effect.runPromise(program).then((n) => console.log(`repetitions: ${n}`))
17818
- * ```
17819
- *
17820
- * **Example** (Stopping repetition on failure)
17821
- *
17822
- * ```ts
17823
- * // Failure Example
17824
- * import { Effect, Schedule } from "effect"
17825
- *
17826
- * let count = 0
17827
- *
17828
- * // Define a callback effect that simulates an action with possible failures
17829
- * const action = Effect.callback<string, string>((resume) => {
17830
- * if (count > 1) {
17831
- * console.log("failure")
17832
- * resume(Effect.fail("Uh oh!"))
17833
- * } else {
17834
- * count++
17835
- * console.log("success")
17836
- * resume(Effect.succeed("yay!"))
17837
- * }
17838
- * })
17839
- *
17840
- * const policy = Schedule.addDelay(Schedule.recurs(2), () => Effect.succeed("100 millis"))
17841
- * const program = Effect.repeat(action, policy)
17842
- *
17843
- * // Effect.runPromiseExit(program).then(console.log)
17844
- * ```
17845
- *
17846
- * @see {@link retry} for failure-based repetition
17847
- * @see {@link repeatOrElse} for fallback handling when repetition fails
17848
- *
17849
- * @category repetition
17850
- * @since 2.0.0
17851
- */
17852
- const repeat = repeat$1;
17209
+ const forever = forever$1;
17853
17210
  /**
17854
17211
  * Create a new span for tracing, and automatically close it when the effect
17855
17212
  * completes.
@@ -20394,7 +19751,7 @@ const abs = (n) => n.value < bigint0 ? make$54(-n.value, n.scale) : n;
20394
19751
  * @category instances
20395
19752
  * @since 2.0.0
20396
19753
  */
20397
- const Equivalence$2 = /*#__PURE__*/ make$65((self, that) => {
19754
+ const Equivalence$2 = /*#__PURE__*/ make$64((self, that) => {
20398
19755
  if (self.scale > that.scale) return scale(that, self.scale).value === self.value;
20399
19756
  if (self.scale < that.scale) return scale(self, that.scale).value === that.value;
20400
19757
  return self.value === that.value;
@@ -22981,7 +22338,7 @@ const badArgument = (options) => new PlatformError(new BadArgument(options));
22981
22338
  * @category combinators
22982
22339
  * @since 2.0.0
22983
22340
  */
22984
- const join$2 = fiberJoin;
22341
+ const join$1 = fiberJoin;
22985
22342
  /**
22986
22343
  * Interrupts a fiber, causing it to stop executing and clean up any
22987
22344
  * acquired resources.
@@ -27190,7 +26547,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
27190
26547
  const fiber = runFork(f(value, i++));
27191
26548
  trackFiber(fiber);
27192
26549
  fiber.addObserver(onExit);
27193
- return offer(effects, join$2(fiber));
26550
+ return offer(effects, join$1(fiber));
27194
26551
  }), forever({ disableYield: true }), catchCause$1((cause) => offer(effects, failCause$3(cause)).pipe(andThen(failCause$1(effects, cause)))), forkIn(forkedScope));
27195
26552
  }
27196
26553
  return take$1(queue);
@@ -32952,27 +32309,26 @@ function decodeUnknownEffect$1(schema, options) {
32952
32309
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
32953
32310
  }
32954
32311
  /**
32955
- * Creates a synchronous decoder for `unknown` input.
32312
+ * Creates a decoder for `unknown` input that returns an `Option` safely.
32956
32313
  *
32957
32314
  * **When to use**
32958
32315
  *
32959
- * Use to decode untrusted or dynamically typed input at a synchronous boundary
32960
- * where invalid data should be reported by throwing.
32316
+ * Use when you need a synchronous yes/no decode from untyped input and do not
32317
+ * need schema issue details.
32961
32318
  *
32962
32319
  * **Details**
32963
32320
  *
32964
- * The returned function returns the decoded `Type` on success and throws an
32965
- * `Error` with the `SchemaIssue.Issue` in its `cause` on decoding failure.
32321
+ * The returned function produces `Option.some` with the decoded `Type` on success
32322
+ * or `Option.none` on failure, discarding issue details.
32966
32323
  *
32967
- * @see {@link decodeSync} for input already typed as the schema's `Encoded` type
32968
- * @see {@link decodeUnknownEffect} for preserving decoding failures in `Effect`
32969
- * @see {@link decodeUnknownResult} for returning schema issues as data
32324
+ * @see {@link decodeOption} for input already typed as the schema's `Encoded` type
32325
+ * @see {@link decodeUnknownResult} for retaining schema issues as data
32970
32326
  *
32971
32327
  * @category decoding
32972
32328
  * @since 3.10.0
32973
32329
  */
32974
- function decodeUnknownSync$1(schema, options) {
32975
- return asSync(decodeUnknownEffect$1(schema, options));
32330
+ function decodeUnknownOption$1(schema, options) {
32331
+ return asOption(decodeUnknownEffect$1(schema, options));
32976
32332
  }
32977
32333
  /**
32978
32334
  * Creates an effectful encoder for `unknown` input.
@@ -33058,6 +32414,11 @@ function run(ast) {
33058
32414
  function asExit(parser) {
33059
32415
  return (input, options) => runSyncExit(parser(input, options));
33060
32416
  }
32417
+ /** @internal */
32418
+ function asOption(parser) {
32419
+ const parserExit = asExit(parser);
32420
+ return (input, options) => getSuccess(parserExit(input, options));
32421
+ }
33061
32422
  function asSync(parser) {
33062
32423
  return (input, options) => runSync(mapErrorEager(parser(input, options), (issue) => new Error(issue.toString(), { cause: issue })));
33063
32424
  }
@@ -33349,43 +32710,25 @@ function decodeUnknownEffect(schema, options) {
33349
32710
  */
33350
32711
  const decodeEffect = decodeUnknownEffect;
33351
32712
  /**
33352
- * Decodes an `unknown` input against a schema synchronously, returning the
33353
- * decoded value or throwing an `Error` whose cause contains the schema issue.
32713
+ * Decodes an `unknown` input against a schema, returning an `Option` that is
32714
+ * `Some` with the decoded value on success or `None` on failure.
33354
32715
  *
33355
32716
  * **When to use**
33356
32717
  *
33357
- * Use when validating unknown data at a boundary and treating schema mismatches
33358
- * as exceptions.
32718
+ * Use when the input type is not statically known and you only need to know
32719
+ * whether decoding succeeded.
33359
32720
  *
33360
32721
  * **Details**
33361
32722
  *
33362
- * For typed input use `decodeSync`.
33363
- * Only service-free schemas can be decoded synchronously. For non-throwing
33364
- * alternatives see `decodeUnknownOption`, `decodeUnknownExit`, or
33365
- * `decodeUnknownEffect`. Options may be provided either when creating the
33366
- * decoder or when applying it; application options override creation options.
33367
- *
33368
- * **Example** (Decoding with a transformation schema)
33369
- *
33370
- * ```ts
33371
- * import { Schema } from "effect"
33372
- *
33373
- * const NumberFromString = Schema.NumberFromString
33374
- *
33375
- * console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
33376
- * // Output: 42
33377
- *
33378
- * Schema.decodeUnknownSync(NumberFromString)("not a number")
33379
- * // throws SchemaError: NumberFromString
33380
- * // └─ Encoded side transformation failure
33381
- * // └─ NumberFromString
33382
- * // └─ Expected a numeric string, actual "not a number"
33383
- * ```
32723
+ * Prefer this over {@link decodeUnknownExit} or {@link decodeUnknownEffect}
32724
+ * when you don't need error details. For typed input use {@link decodeOption}.
32725
+ * Options may be provided either when creating the decoder or when applying it;
32726
+ * application options override creation options.
33384
32727
  *
33385
32728
  * @category decoding
33386
- * @since 4.0.0
32729
+ * @since 3.10.0
33387
32730
  */
33388
- const decodeUnknownSync = decodeUnknownSync$1;
32731
+ const decodeUnknownOption = decodeUnknownOption$1;
33389
32732
  /**
33390
32733
  * Encodes an `unknown` input against a schema, returning an `Effect` that
33391
32734
  * succeeds with the encoded value or fails with a {@link SchemaError}.
@@ -35731,7 +35074,7 @@ const fromInputNested = (input) => {
35731
35074
  * @category instances
35732
35075
  * @since 4.0.0
35733
35076
  */
35734
- const Equivalence = /*#__PURE__*/ make$65((a, b) => arrayEquivalence(a.params, b.params));
35077
+ const Equivalence = /*#__PURE__*/ make$64((a, b) => arrayEquivalence(a.params, b.params));
35735
35078
  const arrayEquivalence = /*#__PURE__*/ makeEquivalence(/*#__PURE__*/ makeEquivalence$2([/*#__PURE__*/ strictEqual(), /*#__PURE__*/ strictEqual()]));
35736
35079
  /**
35737
35080
  * An empty `UrlParams` value.
@@ -38299,7 +37642,7 @@ const runtime = (self) => () => map$4(context$1(), (services) => {
38299
37642
  * @category combinators
38300
37643
  * @since 2.0.0
38301
37644
  */
38302
- const join$1 = (self) => _await(self.deferred);
37645
+ const join = (self) => _await(self.deferred);
38303
37646
  //#endregion
38304
37647
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/socket/Socket.js
38305
37648
  /**
@@ -38339,6 +37682,36 @@ const encoder = /*#__PURE__*/ new TextEncoder();
38339
37682
  const decoder$1 = /*#__PURE__*/ new TextDecoder();
38340
37683
  const CloseEventTypeId = "~effect/socket/Socket/CloseEvent";
38341
37684
  /**
37685
+ * Represents a socket close event value carrying a close code and optional
37686
+ * reason.
37687
+ *
37688
+ * @category models
37689
+ * @since 4.0.0
37690
+ */
37691
+ var CloseEvent = class {
37692
+ /**
37693
+ * Marks this value as a socket close event for runtime guards.
37694
+ *
37695
+ * @since 4.0.0
37696
+ */
37697
+ [CloseEventTypeId];
37698
+ code;
37699
+ reason;
37700
+ constructor(code = 1e3, reason) {
37701
+ this[CloseEventTypeId] = CloseEventTypeId;
37702
+ this.code = code;
37703
+ this.reason = reason;
37704
+ }
37705
+ /**
37706
+ * Formats the close code and optional reason for display.
37707
+ *
37708
+ * @since 4.0.0
37709
+ */
37710
+ toString() {
37711
+ return this.reason ? `${this.code}: ${this.reason}` : `${this.code}`;
37712
+ }
37713
+ };
37714
+ /**
38342
37715
  * Returns `true` when a value is a `CloseEvent`.
38343
37716
  *
38344
37717
  * @category refinements
@@ -38585,13 +37958,13 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
38585
37958
  kind: "Timeout",
38586
37959
  cause: /* @__PURE__ */ new Error("timeout waiting for \"open\"")
38587
37960
  }) }))
38588
- }), raceFirst(join$1(fiberSet)));
37961
+ }), raceFirst(join(fiberSet)));
38589
37962
  }
38590
37963
  open = true;
38591
37964
  currentWS = ws;
38592
37965
  latch.openUnsafe();
38593
37966
  if (opts?.onOpen) yield* opts.onOpen;
38594
- return yield* catchFilter(join$1(fiberSet), SocketCloseError.filterClean((_) => !closeCodeIsError(_)), () => void_$1);
37967
+ return yield* catchFilter(join(fiberSet), SocketCloseError.filterClean((_) => !closeCodeIsError(_)), () => void_$1);
38595
37968
  })).pipe(updateContext((input) => merge$3(acquireContext, input)), ensuring$2(sync(() => {
38596
37969
  latch.closeUnsafe();
38597
37970
  currentWS = void 0;
@@ -49260,7 +48633,7 @@ const readDirectory = (path, options) => tryPromise({
49260
48633
  try: () => NFS.promises.readdir(path, options),
49261
48634
  catch: (err) => handleErrnoException("FileSystem", "readDirectory")(err, [path])
49262
48635
  });
49263
- const readFile$1 = (path) => callback$1((resume, signal) => {
48636
+ const readFile = (path) => callback$1((resume, signal) => {
49264
48637
  try {
49265
48638
  NFS.readFile(path, { signal }, (err, data) => {
49266
48639
  if (err) resume(fail$3(handleErrnoException("FileSystem", "readFile")(err, [path])));
@@ -49381,7 +48754,7 @@ const makeFileSystem = /*#__PURE__*/ map$4(/*#__PURE__*/ serviceOption(WatchBack
49381
48754
  makeTempFileScoped,
49382
48755
  open,
49383
48756
  readDirectory,
49384
- readFile: readFile$1,
48757
+ readFile,
49385
48758
  readLink,
49386
48759
  realPath,
49387
48760
  remove,
@@ -51856,37 +51229,6 @@ const set = /*#__PURE__*/ dual(2, (self, value) => self.semaphore.withPermit(syn
51856
51229
  * @since 2.0.0
51857
51230
  */
51858
51231
  const update = /*#__PURE__*/ dual(2, (self, update) => self.semaphore.withPermit(sync(() => setUnsafe(self, update(self.value)))));
51859
- /**
51860
- * Applies an update function to the current value. If it returns
51861
- * `Option.some`, sets and publishes that value; if it returns `Option.none`,
51862
- * leaves the reference unchanged and does not publish.
51863
- *
51864
- * **Example** (Conditionally updating a value)
51865
- *
51866
- * ```ts
51867
- * import { Effect, Option, SubscriptionRef } from "effect"
51868
- *
51869
- * const program = Effect.gen(function*() {
51870
- * const ref = yield* SubscriptionRef.make(10)
51871
- *
51872
- * yield* SubscriptionRef.updateSome(
51873
- * ref,
51874
- * (n) => n > 5 ? Option.some(n * 2) : Option.none()
51875
- * )
51876
- *
51877
- * const value = yield* SubscriptionRef.get(ref)
51878
- * console.log(value)
51879
- * })
51880
- * ```
51881
- *
51882
- * @category updating
51883
- * @since 2.0.0
51884
- */
51885
- const updateSome = /*#__PURE__*/ dual(2, (self, update) => self.semaphore.withPermit(sync(() => {
51886
- const option = update(self.value);
51887
- if (isNone(option)) return;
51888
- setUnsafe(self, option.value);
51889
- })));
51890
51232
  //#endregion
51891
51233
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpStaticServer.js
51892
51234
  /**
@@ -52299,7 +51641,6 @@ Union([
52299
51641
  Struct({ type: Literal("stop") })
52300
51642
  ]);
52301
51643
  const TerminalState = Struct({
52302
- ports: ArraySchema(Number$1),
52303
51644
  runId: Number$1,
52304
51645
  state: Literals([
52305
51646
  "idle",
@@ -52329,8 +51670,22 @@ const TerminalPayload = Struct({
52329
51670
  args: optional(ArraySchema(String$1)),
52330
51671
  command: optional(String$1),
52331
51672
  cwd: String$1,
51673
+ env: optional(Record(String$1, String$1)),
52332
51674
  sessionId: optional(String$1)
52333
51675
  });
51676
+ const RunScript = Struct({
51677
+ baseOrigin: optional(String$1),
51678
+ command: String$1,
51679
+ cwd: String$1,
51680
+ env: optional(Record(String$1, String$1)),
51681
+ name: String$1,
51682
+ origin: optional(String$1),
51683
+ packageFolder: String$1,
51684
+ packagePath: String$1,
51685
+ portless: optional(Boolean$1),
51686
+ service: optional(String$1),
51687
+ sessionId: String$1
51688
+ });
52334
51689
  const AgentSession = Struct({
52335
51690
  args: ArraySchema(String$1),
52336
51691
  command: String$1,
@@ -52505,14 +51860,10 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52505
51860
  cwd: String$1,
52506
51861
  force: Boolean$1
52507
51862
  })
52508
- }), make$18("runs.scripts", {
51863
+ }), make$18("runs.portless", {
52509
51864
  error: TerminalError,
52510
51865
  payload: Struct({ cwd: String$1 }),
52511
- success: ArraySchema(Struct({
52512
- command: String$1,
52513
- name: String$1,
52514
- tasks: ArraySchema(String$1)
52515
- }))
51866
+ success: ArraySchema(RunScript)
52516
51867
  }), make$18("terminal.write", {
52517
51868
  error: TerminalError,
52518
51869
  payload: Struct({
@@ -52520,6 +51871,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52520
51871
  command: optional(String$1),
52521
51872
  cwd: String$1,
52522
51873
  data: String$1,
51874
+ env: optional(Record(String$1, String$1)),
52523
51875
  sessionId: optional(String$1)
52524
51876
  }),
52525
51877
  success: TerminalState
@@ -52530,6 +51882,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52530
51882
  cols: Number$1,
52531
51883
  command: optional(String$1),
52532
51884
  cwd: String$1,
51885
+ env: optional(Record(String$1, String$1)),
52533
51886
  rows: Number$1,
52534
51887
  sessionId: optional(String$1)
52535
51888
  }),
@@ -52542,11 +51895,6 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
52542
51895
  error: TerminalError,
52543
51896
  payload: TerminalPayload,
52544
51897
  success: TerminalState
52545
- }), make$18("terminal.ports", {
52546
- error: TerminalError,
52547
- payload: TerminalPayload,
52548
- stream: true,
52549
- success: ArraySchema(Number$1)
52550
51898
  }), make$18("terminal.watch", {
52551
51899
  error: TerminalError,
52552
51900
  payload: TerminalPayload,
@@ -52706,7 +52054,7 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52706
52054
  "--format=%(refname:short)",
52707
52055
  "refs/remotes"
52708
52056
  ]), map$4((lines) => pipe(lines, filter$2((name) => !endsWith("/HEAD")(name)), map$7((name) => new GitBranch({
52709
- name: pipe(split$1("/")(name), drop$1(1), join$3("/")),
52057
+ name: pipe(split$1("/")(name), drop$1(1), join$2("/")),
52710
52058
  remote: split$1("/")(name)[0],
52711
52059
  type: "remote"
52712
52060
  })), filter$2((branch) => isNonEmpty$1(branch.name)), appendAll(localBranches)))))),
@@ -52890,7 +52238,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52890
52238
  "--exclude-standard"
52891
52239
  ]), flatMap$2((files) => forEach$1(files, (filePath) => pipe(fs.readFileString(path.join(config.cwd, filePath)), orElseSucceed(() => ""), map$4((content) => new GitDiff({
52892
52240
  filePath,
52893
- 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"))}`,
52241
+ 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"))}`,
52894
52242
  segments: [new GitDiffSegment({
52895
52243
  filePath,
52896
52244
  fingerprint: content,
@@ -53233,49 +52581,259 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53233
52581
  static layer = flow(this.make, effect(this));
53234
52582
  };
53235
52583
  //#endregion
53236
- //#region ../../packages/terminal/src/service.ts
53237
- function parseProcessParents(output) {
53238
- return new Map(pipe(linesIterator(output), fromIterable$2, filterMap$1((line) => {
53239
- const columns = split$1(/\s+/)(trim(line));
53240
- const pid = Number(columns[0]);
53241
- const ppid = Number(columns[1]);
53242
- return Number.isFinite(pid) && Number.isFinite(ppid) ? succeed$7(make$63(pid, ppid)) : failVoid;
53243
- })));
52584
+ //#region ../../packages/portless/src/lib/utils.ts
52585
+ const PackageJson = Struct({ scripts: optional(Record(String$1, String$1)) });
52586
+ function command(script, port) {
52587
+ return make$40("vp", [
52588
+ "run",
52589
+ script.name,
52590
+ .../^vp\s+dev(?:\s|$)/u.test(script.command) ? [
52591
+ "--host",
52592
+ "127.0.0.1",
52593
+ "--port",
52594
+ port.toString(),
52595
+ "--strictPort"
52596
+ ] : []
52597
+ ]);
53244
52598
  }
53245
- function parseListeningPorts(output) {
53246
- return pipe(linesIterator(output), fromIterable$2, filterMap$1((line) => {
53247
- const columns = split$1(/\s+/)(trim(line));
53248
- const port = Number(columns[3]?.match(/:(\d+)$/)?.[1]);
53249
- const pid = Number(line.match(/pid=(\d+)/)?.[1]);
53250
- return Number.isFinite(port) && Number.isFinite(pid) ? succeed$7({
53251
- pid,
53252
- port
53253
- }) : failVoid;
53254
- }));
52599
+ const discover = fnUntraced(function* (cwd, input) {
52600
+ const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
52601
+ const fs = yield* FileSystem;
52602
+ const path = yield* Path$1;
52603
+ const output = yield* execString(make$40("git", [
52604
+ "ls-files",
52605
+ "-co",
52606
+ "--exclude-standard",
52607
+ "--",
52608
+ "package.json",
52609
+ "**/package.json"
52610
+ ], { cwd }));
52611
+ return yield* pipe(pipe(split$1("\n")(output), filter$2((path) => path === "package.json" || endsWith("/package.json")(path))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
52612
+ catch: (error) => error,
52613
+ try: () => pipe(JSON.parse(source), decodeUnknownOption(PackageJson))
52614
+ })), catch_$2(() => succeed$3(none())), flatMap$2((packageJson) => {
52615
+ if (isNone(packageJson)) return succeed$3([]);
52616
+ const packageDirectory = packagePath === "package.json" ? cwd : path.join(cwd, path.dirname(packagePath));
52617
+ const folder = path.basename(packageDirectory);
52618
+ const scriptEntries = pipe(Object.entries(packageJson.value.scripts ?? {}), filter$2((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
52619
+ const packageOrigin = input.origin([
52620
+ folder,
52621
+ path.basename(cwd),
52622
+ "localhost"
52623
+ ].join("."));
52624
+ return pipe(scriptEntries, map$7((entry) => {
52625
+ const name = entry[0];
52626
+ const scriptCommand = entry[1];
52627
+ return map$4(input.port(`${packagePath}:${name}`), (port) => {
52628
+ const service = /^dev:(.+)$/u.exec(name)?.[1] ?? "dev";
52629
+ const host = [
52630
+ service,
52631
+ folder,
52632
+ path.basename(cwd),
52633
+ "localhost"
52634
+ ].join(".");
52635
+ const origin = input.origin(host);
52636
+ return {
52637
+ host,
52638
+ port,
52639
+ script: {
52640
+ baseOrigin: packageOrigin,
52641
+ command: scriptCommand,
52642
+ cwd: packageDirectory,
52643
+ env: {
52644
+ HOST: "127.0.0.1",
52645
+ PORT: port.toString(),
52646
+ PORTLESS_BASE_ORIGIN: packageOrigin,
52647
+ PORTLESS_ORIGIN: origin,
52648
+ VITE_PORTLESS_BASE_ORIGIN: packageOrigin,
52649
+ VITE_PORTLESS_ORIGIN: origin
52650
+ },
52651
+ name,
52652
+ origin,
52653
+ packageFolder: folder,
52654
+ packagePath,
52655
+ service,
52656
+ sessionId: `${packagePath}:${name}:${Date.now()}:${Math.random()}`
52657
+ }
52658
+ };
52659
+ });
52660
+ }), all);
52661
+ }))), all, map$4((routes) => flatten$3(routes).sort((left, right) => `${left.script.packagePath}:${left.script.name}`.localeCompare(`${right.script.packagePath}:${right.script.name}`))));
52662
+ });
52663
+ //#endregion
52664
+ //#region ../../packages/portless/src/http.ts
52665
+ const INJECTED_HEAD = `<script>
52666
+ (() => {
52667
+ if (window.__deslopBrowserBridge) return
52668
+ window.__deslopBrowserBridge = true
52669
+
52670
+ const serialize = value => {
52671
+ if (typeof value === 'string') return value
52672
+ try { return JSON.stringify(value) } catch { return String(value) }
52673
+ }
52674
+ const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
52675
+ const sendFavicon = () => {
52676
+ const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
52677
+ window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
52678
+ }
52679
+
52680
+ for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
52681
+ const original = console[level]
52682
+ console[level] = (...args) => {
52683
+ send(level, args.map(serialize).join(' '))
52684
+ original.apply(console, args)
52685
+ }
52686
+ }
52687
+
52688
+ window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
52689
+ window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
52690
+ window.addEventListener('message', event => {
52691
+ if (event.data?.__deslopBrowserClear !== true) return
52692
+ localStorage.clear()
52693
+ sessionStorage.clear()
52694
+ document.cookie.split(';').forEach(cookie => {
52695
+ document.cookie = cookie.replace(/^\\s*([^=]+)=.*$/, '$1=; Max-Age=0; Path=/')
52696
+ })
52697
+ caches?.keys?.().then(keys => Promise.all(keys.map(key => caches.delete(key))))
52698
+ navigator.serviceWorker?.getRegistrations?.().then(registrations => Promise.all(registrations.map(registration => registration.unregister())))
52699
+ location.reload()
52700
+ })
52701
+
52702
+ const sendLocation = () => window.parent?.postMessage({__deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
52703
+ const wrapHistory = name => {
52704
+ const original = history[name]
52705
+ history[name] = function(...args) {
52706
+ const result = original.apply(this, args)
52707
+ sendLocation()
52708
+ return result
52709
+ }
52710
+ }
52711
+ wrapHistory('pushState')
52712
+ wrapHistory('replaceState')
52713
+ window.addEventListener('popstate', sendLocation)
52714
+ window.addEventListener('hashchange', sendLocation)
52715
+
52716
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendFavicon, {once: true})
52717
+ else sendFavicon()
52718
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendLocation, {once: true})
52719
+ else sendLocation()
52720
+ })()
52721
+ <\/script>
52722
+ <script crossorigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" onload="window.reactScan?.({allowInIframe: true, _debug: 'verbose'})"><\/script>
52723
+ <script src="https://unpkg.com/react-grab/dist/index.global.js"><\/script>`;
52724
+ function injectScripts(html) {
52725
+ return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}\n${INJECTED_HEAD}`) : `${INJECTED_HEAD}\n${html}`;
53255
52726
  }
53256
- function isDescendant(pid, ancestorPid, parents) {
53257
- let current = pid;
53258
- const seen = /* @__PURE__ */ new Set();
53259
- while (!seen.has(current)) {
53260
- if (current === ancestorPid) return true;
53261
- seen.add(current);
53262
- const parent = parents.get(current);
53263
- if (!parent || parent === current) return false;
53264
- current = parent;
53265
- }
53266
- return false;
52727
+ const proxy = fnUntraced(function* (request, origin) {
52728
+ const webRequest = yield* toWeb(request);
52729
+ const [pathname = "/", search = ""] = request.url.split("?");
52730
+ const upstreamHeaders = new Headers(webRequest.headers);
52731
+ upstreamHeaders.set("host", new URL(origin).host);
52732
+ const upstreamRequest = new Request(`${origin}${pathname}${search ? `?${search}` : ""}`, {
52733
+ body: webRequest.body,
52734
+ headers: upstreamHeaders,
52735
+ method: webRequest.method,
52736
+ redirect: webRequest.redirect,
52737
+ signal: webRequest.signal
52738
+ });
52739
+ const upstreamResponse = yield* tryPromise(() => fetch(upstreamRequest));
52740
+ const headers = new Headers(upstreamResponse.headers);
52741
+ headers.delete("content-length");
52742
+ headers.delete("content-encoding");
52743
+ if (!(request.method === "GET" && (upstreamResponse.headers.get("content-type") ?? "").includes("text/html"))) return fromWeb(new Response(upstreamResponse.body, {
52744
+ headers,
52745
+ status: upstreamResponse.status,
52746
+ statusText: upstreamResponse.statusText
52747
+ }));
52748
+ const body = yield* tryPromise(() => upstreamResponse.text());
52749
+ headers.set("content-type", "text/html; charset=utf-8");
52750
+ return fromWeb(new Response(injectScripts(body), {
52751
+ headers,
52752
+ status: upstreamResponse.status,
52753
+ statusText: upstreamResponse.statusText
52754
+ }));
52755
+ });
52756
+ const proxyWebSocket = fnUntraced(function* (request, origin) {
52757
+ const [pathname = "/", search = ""] = request.url.split("?");
52758
+ const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((protocols) => pipe(protocols, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
52759
+ const inbound = yield* request.upgrade;
52760
+ const upstreamUrl = new URL(origin);
52761
+ upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
52762
+ upstreamUrl.pathname = pathname;
52763
+ upstreamUrl.search = search;
52764
+ const outbound = yield* makeWebSocket(upstreamUrl.toString(), { protocols: getOrUndefined$1(protocols) }).pipe(provide(layerWebSocketConstructorGlobal));
52765
+ const writeInbound = yield* inbound.writer;
52766
+ const writeOutbound = yield* outbound.writer;
52767
+ 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);
52768
+ yield* inbound.runRaw((message) => writeOutbound(isString(message) ? message : message.slice())).pipe(catch_$2(() => void_$1), ensuring$2(writeOutbound(new CloseEvent()).pipe(catch_$2(() => void_$1))));
52769
+ return empty();
52770
+ });
52771
+ function requestHostname(host) {
52772
+ return pipe(fromUndefinedOr(host), flatMap$6((host) => pipe(host, split$1(":"), head)));
53267
52773
  }
53268
- function descendantsOf(ancestorPid, parents) {
53269
- return pipe(fromIterable$2(parents.keys()), filter$2((pid) => pid !== ancestorPid && isDescendant(pid, ancestorPid, parents)));
52774
+ function isLocalHostname(hostname) {
52775
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
53270
52776
  }
53271
- const commandString = fnUntraced(function* (command, args, message) {
53272
- return yield* pipe((yield* ChildProcessSpawner.useSync((spawner) => spawner.string))(make$40(command, args)), mapError$2((cause) => new TerminalError({
53273
- cause,
53274
- message
53275
- })));
53276
- });
53277
- const readProcessParents = pipe(commandString("ps", ["-eo", "pid=,ppid="], "failed to list terminal processes"), map$4(parseProcessParents));
53278
- const readListeningPorts = pipe(commandString("ss", ["-H", "-ltnp"], "failed to list terminal ports"), map$4(parseListeningPorts));
52777
+ var Portless = class Portless extends Service()("@deslop/portless/Portless", { make: gen(function* () {
52778
+ const server = yield* HttpServer;
52779
+ const proxyPort = server.address._tag === "TcpAddress" ? server.address.port.toString() : yield* die$1(/* @__PURE__ */ new Error("portless requires a TCP HTTP server address"));
52780
+ const ports = /* @__PURE__ */ new Map();
52781
+ const routes = /* @__PURE__ */ new Map();
52782
+ function origin(host) {
52783
+ return `http://${host}:${proxyPort}`;
52784
+ }
52785
+ const middleware = fnUntraced(function* (app) {
52786
+ const request = yield* HttpServerRequest;
52787
+ const hostname = requestHostname(request.headers["host"]);
52788
+ if (isNone(hostname) || isLocalHostname(hostname.value)) return yield* app;
52789
+ if (!hostname.value.endsWith(".localhost")) return yield* app;
52790
+ const route = lookup(request.headers["host"]);
52791
+ if (isNone(route)) return empty({ status: 404 });
52792
+ if (request.headers["upgrade"]?.toLowerCase() === "websocket") return yield* proxyWebSocket(request, route.value);
52793
+ return yield* proxy(request, route.value);
52794
+ });
52795
+ function lookup(host) {
52796
+ return pipe(requestHostname(host), flatMap$6((hostname) => fromUndefinedOr(routes.get(hostname))));
52797
+ }
52798
+ const port = fnUntraced(function* (key) {
52799
+ const existing = ports.get(key);
52800
+ if (existing !== void 0) return existing;
52801
+ const reserved = new Set(ports.values());
52802
+ for (let port = 4e3; port <= 4999; port += 1) {
52803
+ const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${port}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
52804
+ if (!reserved.has(port) && !occupied) {
52805
+ ports.set(key, port);
52806
+ return port;
52807
+ }
52808
+ }
52809
+ throw new Error("no portless app ports available");
52810
+ });
52811
+ return {
52812
+ middleware,
52813
+ scripts: fnUntraced(function* (cwd) {
52814
+ return yield* pipe(discover(cwd, {
52815
+ origin,
52816
+ port: (sessionId) => port(`${cwd}:${sessionId}`)
52817
+ }), tap((discovered) => sync(() => {
52818
+ for (const route of discovered) routes.set(route.host, `http://127.0.0.1:${route.port}`);
52819
+ })), map$4((routes) => routes.map((route) => ({
52820
+ host: route.host,
52821
+ port: route.port,
52822
+ script: {
52823
+ ...route.script,
52824
+ preparedCommand: command(route.script, route.port)
52825
+ }
52826
+ }))));
52827
+ })
52828
+ };
52829
+ }) }) {
52830
+ static layer = effect(this, this.make);
52831
+ static middleware = fnUntraced(function* (app) {
52832
+ return yield* (yield* Portless).middleware(app);
52833
+ });
52834
+ };
52835
+ //#endregion
52836
+ //#region ../../packages/terminal/src/service.ts
53279
52837
  function snapshotEvents(data) {
53280
52838
  if (data === "") return empty$13();
53281
52839
  const events = [];
@@ -53285,9 +52843,6 @@ function snapshotEvents(data) {
53285
52843
  });
53286
52844
  return events;
53287
52845
  }
53288
- function samePorts(left, right) {
53289
- return left.length === right.length && every(left, (leftPort, index) => leftPort === right[index]);
53290
- }
53291
52846
  function parseTitleSignal(title) {
53292
52847
  const trimmed = trim(title);
53293
52848
  if (/^\[\s*[!.]\s*\]\s*Action Required\b/i.test(trimmed)) return {
@@ -53349,18 +52904,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53349
52904
  const screenLock = yield* make$47(1);
53350
52905
  const sequenceRef = yield* make$38(0);
53351
52906
  const signalBuffer = yield* make$38("");
53352
- const portOwners = yield* make$38(/* @__PURE__ */ new Map());
53353
52907
  const processRef = yield* make$38(void 0);
53354
52908
  const sizeRef = yield* make$38({
53355
52909
  cols: 120,
53356
52910
  rows: 32
53357
52911
  });
53358
52912
  const shell = yield* string("SHELL").pipe(orElseSucceed(() => "bash"));
53359
- const processCommand = config.command ?? shell;
53360
- const processArgs = config.args ?? [];
53361
- const autostart = config.command === void 0;
52913
+ const processCommand = config.preparedCommand?.command ?? config.command ?? shell;
52914
+ const processArgs = config.preparedCommand?.args ?? config.args ?? [];
52915
+ const autostart = config.command === void 0 && config.preparedCommand === void 0;
53362
52916
  const stateRef = yield* make$3({
53363
- ports: [],
53364
52917
  runId: 0,
53365
52918
  state: autostart ? "starting" : "idle",
53366
52919
  title: ""
@@ -53411,17 +52964,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53411
52964
  }
53412
52965
  const startRun = pipe(update(stateRef, (state) => ({
53413
52966
  ...state,
53414
- ports: [],
53415
52967
  runId: state.runId + 1,
53416
52968
  state: "starting",
53417
52969
  title: ""
53418
52970
  })), andThen(get(stateRef)));
53419
- function setPorts(ports) {
53420
- return updateSome(stateRef, (state) => samePorts(state.ports, ports) ? none() : some$1({
53421
- ...state,
53422
- ports: [...ports]
53423
- }));
53424
- }
53425
52971
  function readSignals(data) {
53426
52972
  for (const match of data.matchAll(/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) {
53427
52973
  const title = match[1];
@@ -53434,24 +52980,17 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53434
52980
  yield* set$4(signalBuffer, next.pending);
53435
52981
  readSignals(next.complete);
53436
52982
  });
53437
- const interruptProcessTree = fnUntraced(function* (subprocess, signal) {
53438
- 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())));
52983
+ const interruptProcess = fnUntraced(function* (subprocess, signal) {
53439
52984
  yield* sync(() => {
53440
- try {
53441
- if (nodeProcess.platform !== "win32") nodeProcess.kill(-subprocess.pid, signal);
53442
- } catch {}
53443
- for (const pid of descendants.toReversed()) try {
53444
- nodeProcess.kill(pid, signal);
53445
- } catch {}
53446
52985
  try {
53447
52986
  subprocess.kill(signal);
53448
52987
  } catch {}
53449
52988
  });
53450
52989
  });
53451
52990
  const terminateProcess = fnUntraced(function* (subprocess) {
53452
- yield* interruptProcessTree(subprocess, "SIGTERM");
52991
+ yield* interruptProcess(subprocess, "SIGTERM");
53453
52992
  yield* sleep("250 millis");
53454
- yield* interruptProcessTree(subprocess, "SIGKILL");
52993
+ yield* interruptProcess(subprocess, "SIGKILL");
53455
52994
  });
53456
52995
  const writeScreen = fnUntraced(function* (data) {
53457
52996
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
@@ -53465,8 +53004,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53465
53004
  });
53466
53005
  const clearProcess = fnUntraced(function* (handle) {
53467
53006
  yield* update$1(processRef, (current) => current === handle ? void 0 : current);
53468
- yield* set$4(portOwners, /* @__PURE__ */ new Map());
53469
- yield* setPorts([]);
53470
53007
  });
53471
53008
  const stopProcess = fnUntraced(function* (state) {
53472
53009
  const handle = yield* get$3(processRef);
@@ -53498,6 +53035,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53498
53035
  cwd: config.cwd,
53499
53036
  env: {
53500
53037
  ...process.env,
53038
+ ...config.env,
53501
53039
  TERM: "xterm-256color"
53502
53040
  },
53503
53041
  name: "xterm-256color",
@@ -53540,22 +53078,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53540
53078
  discard: true
53541
53079
  }));
53542
53080
  if (autostart) yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => setState("failed")));
53543
- yield* pipe(gen(function* () {
53544
- const process = yield* get$3(processRef);
53545
- if (!process?.process.pid) {
53546
- yield* set$4(portOwners, /* @__PURE__ */ new Map());
53547
- yield* setPorts([]);
53548
- return;
53549
- }
53550
- const [parents, listeningPorts] = yield* all([readProcessParents, readListeningPorts]);
53551
- const nextPortOwners = /* @__PURE__ */ new Map();
53552
- const nextPorts = pipe(listeningPorts, filter$2((port) => isDescendant(port.pid, process.process.pid, parents)), map$7((port) => {
53553
- nextPortOwners.set(port.port, port.pid);
53554
- return port.port;
53555
- }), dedupe, sort(Number$5));
53556
- yield* set$4(portOwners, nextPortOwners);
53557
- yield* setPorts(nextPorts);
53558
- }), ignore$1, repeat(spaced("1 second")), forkScoped);
53559
53081
  const resize = fnUntraced(function* (nextSize) {
53560
53082
  const size = yield* get$3(sizeRef);
53561
53083
  if (size.cols === nextSize.cols && size.rows === nextSize.rows) return;
@@ -53604,7 +53126,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53604
53126
  ...filter$2(pending, (event) => event.sequence > snapshot.sequence)
53605
53127
  ]), concat(fromEffectRepeat(take$2(subscription))));
53606
53128
  })));
53607
- const ports = pipe(changes(stateRef), map$2((state) => state.ports), changesWith(samePorts));
53608
53129
  const updates = merge$1(changes(stateRef).pipe(map$2((state) => ({
53609
53130
  state,
53610
53131
  type: "state"
@@ -53613,7 +53134,6 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53613
53134
  type: "event"
53614
53135
  }))));
53615
53136
  return {
53616
- ports,
53617
53137
  resize: fnUntraced(function* (size) {
53618
53138
  return yield* pipe(resize(size), andThen(get(stateRef)));
53619
53139
  }),
@@ -53633,70 +53153,12 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53633
53153
  static layer = flow(this.make, effect(this));
53634
53154
  };
53635
53155
  //#endregion
53636
- //#region ../../packages/terminal/src/utils.ts
53637
- function splitParallelCommands(script) {
53638
- const state = pipe(split$1("")(script), reduce({
53639
- commands: [],
53640
- current: "",
53641
- escaped: false,
53642
- skipNext: false
53643
- }, (state, char, index) => {
53644
- if (state.skipNext) return {
53645
- ...state,
53646
- skipNext: false
53647
- };
53648
- if (state.escaped) return {
53649
- ...state,
53650
- current: state.current + char,
53651
- escaped: false
53652
- };
53653
- if (char === "\\") return {
53654
- ...state,
53655
- current: state.current + char,
53656
- escaped: true
53657
- };
53658
- if (state.quote) return {
53659
- ...state,
53660
- current: state.current + char,
53661
- quote: char === state.quote ? void 0 : state.quote
53662
- };
53663
- if (char === "\"" || char === "'") return {
53664
- ...state,
53665
- current: state.current + char,
53666
- quote: char
53667
- };
53668
- if (char === "&" && script[index + 1] === "&") return {
53669
- ...state,
53670
- current: `${state.current}&&`,
53671
- skipNext: true
53672
- };
53673
- if (char !== "&") return {
53674
- ...state,
53675
- current: state.current + char
53676
- };
53677
- return pipe(liftPredicate(trim(state.current), isNonEmpty$1), match$5({
53678
- onNone: () => ({
53679
- ...state,
53680
- current: ""
53681
- }),
53682
- onSome: (command) => ({
53683
- ...state,
53684
- commands: [...state.commands, command],
53685
- current: ""
53686
- })
53687
- }));
53688
- }));
53689
- return pipe(liftPredicate(trim(state.current), isNonEmpty$1), match$5({
53690
- onNone: () => state.commands,
53691
- onSome: (command) => [...state.commands, command]
53692
- }));
53693
- }
53694
- //#endregion
53695
53156
  //#region src/rpcs/handlers.ts
53696
53157
  const TerminalSessionKey = Struct({
53697
53158
  args: optional(ArraySchema(String$1)),
53698
53159
  command: optional(String$1),
53699
53160
  cwd: String$1,
53161
+ env: optional(Record(String$1, String$1)),
53700
53162
  sessionId: optional(String$1)
53701
53163
  });
53702
53164
  const emptyReviewState = new ReviewState({
@@ -53724,7 +53186,45 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53724
53186
  const terminals = yield* TerminalSessions;
53725
53187
  const gitWorktrees = yield* GitWorktreeSessions;
53726
53188
  const fs = yield* FileSystem;
53189
+ const portless = yield* Portless;
53190
+ const portlessScripts = yield* make$38(empty$6());
53727
53191
  const reviewStore = toSchemaStore(yield* KeyValueStore, ReviewState);
53192
+ const portlessWorktrees = yield* make$46({
53193
+ idleTimeToLive: infinity,
53194
+ lookup: fnUntraced(function* (cwd) {
53195
+ const scripts = yield* pipe(portless.scripts(cwd), mapError$2((cause) => new TerminalError({
53196
+ cause,
53197
+ message: `failed to discover portless scripts in ${cwd}`
53198
+ })));
53199
+ yield* all(pipe(scripts, map$7((script) => update$1(portlessScripts, (current) => set$2(current, script.script.sessionId, script.script)))), { discard: true });
53200
+ return pipe(scripts, map$7((route) => ({
53201
+ baseOrigin: route.script.baseOrigin,
53202
+ command: route.script.command,
53203
+ cwd: route.script.cwd,
53204
+ name: route.script.name,
53205
+ origin: route.script.origin,
53206
+ packageFolder: route.script.packageFolder,
53207
+ packagePath: route.script.packagePath,
53208
+ portless: true,
53209
+ service: route.script.service,
53210
+ sessionId: route.script.sessionId
53211
+ })));
53212
+ })
53213
+ });
53214
+ const terminalSession = fnUntraced(function* (input) {
53215
+ if (input.sessionId === void 0 || input.command !== void 0) return input;
53216
+ const script = pipe(yield* get$3(portlessScripts), get$1(input.sessionId), getOrUndefined$1);
53217
+ if (script === void 0) return input;
53218
+ return {
53219
+ cwd: script.cwd,
53220
+ env: script.env,
53221
+ preparedCommand: script.preparedCommand,
53222
+ sessionId: script.sessionId
53223
+ };
53224
+ });
53225
+ const terminal = fnUntraced(function* (input) {
53226
+ return yield* pipe(terminalSession(input), flatMap$2((session) => get$6(terminals, session)));
53227
+ });
53728
53228
  const reviewStateKey = fnUntraced(function* (input) {
53729
53229
  const root = yield* pipe(fs.realPath(input.cwd), orElseSucceed(() => input.cwd));
53730
53230
  return Buffer.from(`${root}\u0000${input.base}`, "utf8").toString("base64url");
@@ -53791,7 +53291,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53791
53291
  "projects.branches": (payload) => git.branches(payload.cwd),
53792
53292
  "projects.createWorktree": (payload) => git.createWorktree(payload),
53793
53293
  "projects.deleteWorktree": (payload) => git.deleteWorktree(payload),
53794
- "projects.watch": () => unwrap$1(pipe(get(git.projects), map$4((projects) => pipe(make$43(projects), concat(drop(1)(changes(git.projects))))))),
53294
+ "projects.watch": () => unwrap$1(map$4(get(git.projects), (projects) => pipe(make$43(projects), concat(drop(1)(changes(git.projects)))))),
53795
53295
  "review.comments.resolve": (payload) => updateReviewState(payload, (state) => {
53796
53296
  const key = commentKey(payload);
53797
53297
  return new ReviewState({
@@ -53839,26 +53339,15 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53839
53339
  from: payload.from,
53840
53340
  to: payload.to
53841
53341
  })))),
53842
- "runs.scripts": (payload) => pipe(tryPromise({
53843
- catch: (cause) => new TerminalError({
53844
- cause,
53845
- message: `failed to read package.json in ${payload.cwd}`
53846
- }),
53847
- try: () => readFile(join(payload.cwd, "package.json"), "utf8")
53848
- }), map$4(decodeUnknownSync(fromJsonString(Struct({ scripts: optional(Record(String$1, String$1)) })))), map$4((packageJson) => pipe(packageJson.scripts ?? {}, toEntries, map$7(([name, command]) => ({
53849
- command,
53850
- name,
53851
- tasks: splitParallelCommands(command)
53852
- }))))),
53853
- "terminal.ports": (payload) => unwrap$1(pipe(get$6(terminals, TerminalSessionKey.make(payload)), map$4((terminal) => terminal.ports))),
53854
- "terminal.resize": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
53342
+ "runs.portless": (payload) => get$6(portlessWorktrees, payload.cwd),
53343
+ "terminal.resize": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
53855
53344
  cols: payload.cols,
53856
53345
  rows: payload.rows
53857
53346
  }))),
53858
- "terminal.restart": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.restart())),
53859
- "terminal.stop": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.stop())),
53860
- "terminal.watch": (payload) => unwrap$1(pipe(get$6(terminals, TerminalSessionKey.make(payload)), map$4((terminal) => terminal.updates))),
53861
- "terminal.write": (payload) => pipe(get$6(terminals, TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
53347
+ "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
53348
+ "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
53349
+ "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
53350
+ "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
53862
53351
  });
53863
53352
  }));
53864
53353
  //#endregion
@@ -70641,104 +70130,7 @@ function OtelLayer(serviceName) {
70641
70130
  }
70642
70131
  //#endregion
70643
70132
  //#region src/lib/serverRuntime.ts
70644
- 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));
70645
- //#endregion
70646
- //#region ../../packages/browser/src/http.ts
70647
- const INJECTED_HEAD = `<script>
70648
- (() => {
70649
- if (window.__deslopBrowserBridge) return
70650
- window.__deslopBrowserBridge = true
70651
-
70652
- const serialize = value => {
70653
- if (typeof value === 'string') return value
70654
- try { return JSON.stringify(value) } catch { return String(value) }
70655
- }
70656
- const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
70657
- const sendFavicon = () => {
70658
- const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
70659
- window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
70660
- }
70661
-
70662
- for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
70663
- const original = console[level]
70664
- console[level] = (...args) => {
70665
- send(level, args.map(serialize).join(' '))
70666
- original.apply(console, args)
70667
- }
70668
- }
70669
-
70670
- window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
70671
- window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
70672
- window.addEventListener('message', event => {
70673
- if (event.data?.__deslopBrowserClear !== true) return
70674
- localStorage.clear()
70675
- sessionStorage.clear()
70676
- document.cookie.split(';').forEach(cookie => {
70677
- document.cookie = cookie.replace(/^\\s*([^=]+)=.*$/, '$1=; Max-Age=0; Path=/')
70678
- })
70679
- caches?.keys?.().then(keys => Promise.all(keys.map(key => caches.delete(key))))
70680
- navigator.serviceWorker?.getRegistrations?.().then(registrations => Promise.all(registrations.map(registration => registration.unregister())))
70681
- location.reload()
70682
- })
70683
-
70684
- if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', sendFavicon, {once: true})
70685
- else sendFavicon()
70686
- })()
70687
- <\/script>
70688
- <script crossorigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" onload="window.reactScan?.({allowInIframe: true, _debug: 'verbose'})"><\/script>
70689
- <script src="https://unpkg.com/react-grab/dist/index.global.js"><\/script>`;
70690
- function injectScripts(html) {
70691
- return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}\n${INJECTED_HEAD}`) : `${INJECTED_HEAD}\n${html}`;
70692
- }
70693
- const proxy = fnUntraced(function* (request, port) {
70694
- const webRequest = yield* toWeb(request);
70695
- const [pathname = "/", search = ""] = request.url.split("?");
70696
- const upstreamHeaders = new Headers(webRequest.headers);
70697
- upstreamHeaders.set("host", `localhost:${port}`);
70698
- const upstreamRequest = new Request(`http://localhost:${port}${pathname}${search ? `?${search}` : ""}`, {
70699
- body: webRequest.body,
70700
- headers: upstreamHeaders,
70701
- method: webRequest.method,
70702
- redirect: webRequest.redirect,
70703
- signal: webRequest.signal
70704
- });
70705
- const upstreamResponse = yield* tryPromise(() => fetch(upstreamRequest));
70706
- const shouldRewriteHtml = request.method === "GET" && (upstreamResponse.headers.get("content-type") ?? "").includes("text/html");
70707
- const headers = new Headers(upstreamResponse.headers);
70708
- headers.delete("content-length");
70709
- headers.delete("content-encoding");
70710
- if (!shouldRewriteHtml) return fromWeb(new Response(upstreamResponse.body, {
70711
- headers,
70712
- status: upstreamResponse.status,
70713
- statusText: upstreamResponse.statusText
70714
- }));
70715
- const body = yield* tryPromise(() => upstreamResponse.text());
70716
- headers.set("content-type", "text/html; charset=utf-8");
70717
- return fromWeb(new Response(injectScripts(body), {
70718
- headers,
70719
- status: upstreamResponse.status,
70720
- statusText: upstreamResponse.statusText
70721
- }));
70722
- });
70723
- const proxyWebSocket = fnUntraced(function* (request, port) {
70724
- const [pathname = "/", search = ""] = request.url.split("?");
70725
- const protocols = request.headers["sec-websocket-protocol"]?.split(",").map((protocol) => protocol.trim()).filter((protocol) => protocol.length > 0);
70726
- const clientSocket = yield* request.upgrade;
70727
- const upstreamSocket = yield* makeWebSocket(`ws://localhost:${port}${pathname}${search ? `?${search}` : ""}`, { protocols }).pipe(provide(layerWebSocketConstructorGlobal));
70728
- const clientWriter = yield* clientSocket.writer;
70729
- const upstreamWriter = yield* upstreamSocket.writer;
70730
- yield* all([clientSocket.runRaw(upstreamWriter), upstreamSocket.runRaw(clientWriter)], { concurrency: "unbounded" }).pipe(scoped$3, catch_$2(() => void_$1));
70731
- return empty();
70732
- });
70733
- function BrowserProxyMiddleware(app) {
70734
- return gen(function* () {
70735
- const request = yield* HttpServerRequest;
70736
- const port = /^(\d+)\.localhost(?::\d+)?$/u.exec(request.headers["host"] ?? "")?.[1];
70737
- if (!port) return yield* app;
70738
- if (request.headers["upgrade"]?.toLowerCase() === "websocket") return yield* proxyWebSocket(request, port);
70739
- return yield* proxy(request, port);
70740
- });
70741
- }
70133
+ 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));
70742
70134
  //#endregion
70743
70135
  //#region src/main.server.ts
70744
70136
  runMain(pipe(serve(mergeAll$1(layerHttp({
@@ -70749,9 +70141,9 @@ runMain(pipe(serve(mergeAll$1(layerHttp({
70749
70141
  index: "index.html",
70750
70142
  root: fileURLToPath(new URL("./client", import.meta.url)),
70751
70143
  spa: true
70752
- }), middleware(BrowserProxyMiddleware, { global: true }), middleware(xForwardedHeaders, { global: true })), { disableLogger: true }), provide$2(LiveLayers), provide$2(layerConfig(createServer, {
70144
+ }), middleware(Portless.middleware, { global: true }), middleware(xForwardedHeaders, { global: true })), { disableLogger: true }), provide$2(LiveLayers), provide$2(layerConfig(createServer, {
70753
70145
  gracefulShutdownTimeout: succeed("1500 millis"),
70754
- port: port("PORT").pipe(withDefault(4010))
70146
+ port: port("PORT").pipe(withDefault(5010))
70755
70147
  })), provide$2(layer$6), launch));
70756
70148
  //#endregion
70757
70149
  export { __toCommonJS as a, __require as i, init_esm$2 as n, __commonJSMin as r, esm_exports$2 as t };