@deslop/workbench 0.0.320 → 0.0.327

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 (27) hide show
  1. package/dist/client/assets/agent-CRsoHYEG.js +1 -0
  2. package/dist/client/assets/{agent-DAD7EQOa.js → agent-DYjX-Pzl.js} +2 -2
  3. package/dist/client/assets/{diff-HFsBcdrM.js → diff-C_X2wnRm.js} +2 -2
  4. package/dist/client/assets/{diff-BbjpVkn4.js → diff-hUFci-J4.js} +26 -26
  5. package/dist/client/assets/index-BX6N5TyF.css +2 -0
  6. package/dist/client/assets/{index-Ds4rq0zQ.js → index-DpbZkluz.js} +1 -1
  7. package/dist/client/assets/input-group-CAejCCyD.js +153 -0
  8. package/dist/client/assets/{portless-DFKFPX3Z.js → portless-D4NDzBYJ.js} +1 -1
  9. package/dist/client/assets/{portless-DexDlqwA.js → portless-D73tczCx.js} +2 -2
  10. package/dist/client/assets/{route-DOWKJR6H.js → route-0gFXuUyt.js} +2 -2
  11. package/dist/client/assets/{route-CUHeGENe.js → route-BcNQ-aN-.js} +1 -1
  12. package/dist/client/assets/{run-BvHiSlty.js → run-B5fcXFyP.js} +2 -2
  13. package/dist/client/assets/run-BzrHh2aK.js +1 -0
  14. package/dist/client/assets/state-C-LyNCwu.js +2 -0
  15. package/dist/client/assets/{terminal-t4CeG_V9.js → terminal-B3oT0xJm.js} +2 -2
  16. package/dist/client/assets/terminal-DgodR87i.js +145 -0
  17. package/dist/client/assets/terminal-EfiQ0Ote.js +1 -0
  18. package/dist/client/index.html +8 -8
  19. package/dist/server.js +1287 -354
  20. package/package.json +2 -2
  21. package/dist/client/assets/agent-DHWhwvQy.js +0 -1
  22. package/dist/client/assets/index-Ci3BZgXN.css +0 -2
  23. package/dist/client/assets/input-group-BtEJur4W.js +0 -153
  24. package/dist/client/assets/run-L2YCL4H0.js +0 -1
  25. package/dist/client/assets/state-T-ZhKyUm.js +0 -2
  26. package/dist/client/assets/terminal-CGe8qF7_.js +0 -1
  27. package/dist/client/assets/terminal-Ci9YBovb.js +0 -119
package/dist/server.js CHANGED
@@ -21,6 +21,8 @@ import * as NodeStreamP from "node:stream/promises";
21
21
  import { pipeline } from "node:stream/promises";
22
22
  import * as readline from "node:readline";
23
23
  import * as nodePty from "@lydell/node-pty";
24
+ import SerializeModule from "@xterm/addon-serialize";
25
+ import HeadlessModule from "@xterm/headless";
24
26
  //#region \0rolldown/runtime.js
25
27
  var __create = Object.create;
26
28
  var __defProp = Object.defineProperty;
@@ -4499,9 +4501,9 @@ const isArrayNonEmpty$1 = (self) => self.length > 0;
4499
4501
  /**
4500
4502
  * @since 2.0.0
4501
4503
  */
4502
- const TypeId$50 = "~effect/data/Option";
4504
+ const TypeId$52 = "~effect/data/Option";
4503
4505
  const CommonProto$1 = {
4504
- [TypeId$50]: { _A: (_) => _ },
4506
+ [TypeId$52]: { _A: (_) => _ },
4505
4507
  ...PipeInspectableProto,
4506
4508
  [Symbol.iterator]() {
4507
4509
  return new SingleShotGen(this);
@@ -4552,7 +4554,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
4552
4554
  }
4553
4555
  });
4554
4556
  /** @internal */
4555
- const isOption = (input) => hasProperty(input, TypeId$50);
4557
+ const isOption = (input) => hasProperty(input, TypeId$52);
4556
4558
  /** @internal */
4557
4559
  const isNone$1 = (fa) => fa._tag === "None";
4558
4560
  /** @internal */
@@ -4567,9 +4569,9 @@ const some$2 = (value) => {
4567
4569
  };
4568
4570
  //#endregion
4569
4571
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/result.js
4570
- const TypeId$49 = "~effect/data/Result";
4572
+ const TypeId$51 = "~effect/data/Result";
4571
4573
  const CommonProto = {
4572
- [TypeId$49]: {
4574
+ [TypeId$51]: {
4573
4575
  /* v8 ignore next 2 */
4574
4576
  _A: (_) => _,
4575
4577
  _E: (_) => _
@@ -4583,7 +4585,7 @@ const SuccessProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4583
4585
  _tag: "Success",
4584
4586
  _op: "Success",
4585
4587
  [symbol$2](that) {
4586
- return isResult(that) && isSuccess$2(that) && equals$2(this.success, that.success);
4588
+ return isResult$1(that) && isSuccess$2(that) && equals$2(this.success, that.success);
4587
4589
  },
4588
4590
  [symbol$3]() {
4589
4591
  return combine$1(hash(this._tag))(hash(this.success));
@@ -4603,7 +4605,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4603
4605
  _tag: "Failure",
4604
4606
  _op: "Failure",
4605
4607
  [symbol$2](that) {
4606
- return isResult(that) && isFailure$2(that) && equals$2(this.failure, that.failure);
4608
+ return isResult$1(that) && isFailure$2(that) && equals$2(this.failure, that.failure);
4607
4609
  },
4608
4610
  [symbol$3]() {
4609
4611
  return combine$1(hash(this._tag))(hash(this.failure));
@@ -4620,7 +4622,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4620
4622
  }
4621
4623
  });
4622
4624
  /** @internal */
4623
- const isResult = (input) => hasProperty(input, TypeId$49);
4625
+ const isResult$1 = (input) => hasProperty(input, TypeId$51);
4624
4626
  /** @internal */
4625
4627
  const isFailure$2 = (result) => result._tag === "Failure";
4626
4628
  /** @internal */
@@ -5218,7 +5220,7 @@ const getOrElse$1 = /*#__PURE__*/ dual(2, (self, onNone) => isNone(self) ? onNon
5218
5220
  * @category error handling
5219
5221
  * @since 2.0.0
5220
5222
  */
5221
- const orElse$1 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self);
5223
+ const orElse$3 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self);
5222
5224
  /**
5223
5225
  * Converts a nullable value (`null` or `undefined`) into an `Option`.
5224
5226
  *
@@ -5530,6 +5532,36 @@ const fail$7 = fail$8;
5530
5532
  */
5531
5533
  const failVoid = /*#__PURE__*/ fail$7(void 0);
5532
5534
  /**
5535
+ * Checks whether a value is a `Result` (either `Success` or `Failure`).
5536
+ *
5537
+ * **When to use**
5538
+ *
5539
+ * Use to validate unknown input before operating on it as a `Result`.
5540
+ *
5541
+ * **Details**
5542
+ *
5543
+ * - Returns `true` for both `Success` and `Failure` variants
5544
+ * - Acts as a TypeScript type guard, narrowing to `Result<unknown, unknown>`
5545
+ *
5546
+ * **Example** (Checking if a value is a Result)
5547
+ *
5548
+ * ```ts
5549
+ * import { Result } from "effect"
5550
+ *
5551
+ * console.log(Result.isResult(Result.succeed(1)))
5552
+ * // Output: true
5553
+ *
5554
+ * console.log(Result.isResult({ value: 1 }))
5555
+ * // Output: false
5556
+ * ```
5557
+ *
5558
+ * @see {@link isSuccess} / {@link isFailure} to narrow to a specific variant
5559
+ *
5560
+ * @category guards
5561
+ * @since 4.0.0
5562
+ */
5563
+ const isResult = isResult$1;
5564
+ /**
5533
5565
  * Checks whether a `Result` is a `Failure`.
5534
5566
  *
5535
5567
  * **When to use**
@@ -6250,6 +6282,96 @@ function isOutOfBounds(i, as) {
6250
6282
  }
6251
6283
  const clamp = (i, as) => Math.floor(Math.min(Math.max(0, i), as.length));
6252
6284
  /**
6285
+ * Reads an element at the given index safely, returning `Option.some` or
6286
+ * `Option.none` if the index is out of bounds.
6287
+ *
6288
+ * **When to use**
6289
+ *
6290
+ * Use when you need to read an array element by index and handle an
6291
+ * out-of-bounds index as `Option.none`.
6292
+ *
6293
+ * **Details**
6294
+ *
6295
+ * - The index is floored to an integer.
6296
+ * - Never throws.
6297
+ *
6298
+ * **Example** (Safe index access)
6299
+ *
6300
+ * ```ts
6301
+ * import { Array } from "effect"
6302
+ *
6303
+ * console.log(Array.get([1, 2, 3], 1)) // Some(2)
6304
+ * console.log(Array.get([1, 2, 3], 10)) // None
6305
+ * ```
6306
+ *
6307
+ * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds
6308
+ * @see {@link head} for reading the first element as an `Option`
6309
+ * @see {@link last} for reading the last element as an `Option`
6310
+ *
6311
+ * @category getters
6312
+ * @since 2.0.0
6313
+ */
6314
+ const get$10 = /*#__PURE__*/ dual(2, (self, index) => {
6315
+ const i = Math.floor(index);
6316
+ return isOutOfBounds(i, self) ? none() : some$1(self[i]);
6317
+ });
6318
+ /**
6319
+ * Reads an element at the given index, throwing if the index is out of bounds.
6320
+ *
6321
+ * **When to use**
6322
+ *
6323
+ * Use to read an element at a known valid index when out-of-bounds would be a
6324
+ * programming error.
6325
+ *
6326
+ * **Details**
6327
+ *
6328
+ * - Throws an `Error` with the message `"Index out of bounds: <i>"`.
6329
+ * - Prefer {@link get} for safe access.
6330
+ *
6331
+ * **Example** (Unsafe index access)
6332
+ *
6333
+ * ```ts
6334
+ * import { Array } from "effect"
6335
+ *
6336
+ * console.log(Array.getUnsafe([1, 2, 3], 1)) // 2
6337
+ * // Array.getUnsafe([1, 2, 3], 10) // throws Error
6338
+ * ```
6339
+ *
6340
+ * @see {@link get} — safe version returning `Option`
6341
+ *
6342
+ * @category unsafe
6343
+ * @since 4.0.0
6344
+ */
6345
+ const getUnsafe$1 = /*#__PURE__*/ dual(2, (self, index) => {
6346
+ const i = Math.floor(index);
6347
+ if (isOutOfBounds(i, self)) throw new Error(`Index out of bounds: ${i}`);
6348
+ return self[i];
6349
+ });
6350
+ /**
6351
+ * Returns the first element of an array safely wrapped in `Option.some`, or
6352
+ * `Option.none` if the array is empty.
6353
+ *
6354
+ * **When to use**
6355
+ *
6356
+ * Use to safely get the first element of an array that may be empty.
6357
+ *
6358
+ * **Example** (Getting the first element)
6359
+ *
6360
+ * ```ts
6361
+ * import { Array } from "effect"
6362
+ *
6363
+ * console.log(Array.head([1, 2, 3])) // Some(1)
6364
+ * console.log(Array.head([])) // None
6365
+ * ```
6366
+ *
6367
+ * @see {@link headNonEmpty} — direct access when array is known non-empty
6368
+ * @see {@link last} — get the last element
6369
+ *
6370
+ * @category getters
6371
+ * @since 2.0.0
6372
+ */
6373
+ const head = /*#__PURE__*/ get$10(0);
6374
+ /**
6253
6375
  * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option`
6254
6376
  * wrapper).
6255
6377
  *
@@ -6271,11 +6393,7 @@ const clamp = (i, as) => Math.floor(Math.min(Math.max(0, i), as.length));
6271
6393
  * @category getters
6272
6394
  * @since 2.0.0
6273
6395
  */
6274
- const headNonEmpty = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, index) => {
6275
- const i = Math.floor(index);
6276
- if (isOutOfBounds(i, self)) throw new Error(`Index out of bounds: ${i}`);
6277
- return self[i];
6278
- }))(0);
6396
+ const headNonEmpty = /*#__PURE__*/ getUnsafe$1(0);
6279
6397
  /**
6280
6398
  * Returns the last element of an array safely wrapped in `Option.some`, or
6281
6399
  * `Option.none` if the array is empty.
@@ -7059,7 +7177,7 @@ const ServiceProto = {
7059
7177
  }
7060
7178
  };
7061
7179
  const ReferenceTypeId = "~effect/Context/Reference";
7062
- const TypeId$48 = "~effect/Context";
7180
+ const TypeId$50 = "~effect/Context";
7063
7181
  /**
7064
7182
  * Creates a `Context` from an existing service map without validating or
7065
7183
  * copying it.
@@ -7094,7 +7212,7 @@ const makeUnsafe$8 = (mapUnsafe) => {
7094
7212
  };
7095
7213
  const Proto$15 = {
7096
7214
  ...PipeInspectableProto,
7097
- [TypeId$48]: { _Services: (_) => _ },
7215
+ [TypeId$50]: { _Services: (_) => _ },
7098
7216
  toJSON() {
7099
7217
  return {
7100
7218
  _id: "Context",
@@ -7146,7 +7264,7 @@ const Proto$15 = {
7146
7264
  * @category guards
7147
7265
  * @since 2.0.0
7148
7266
  */
7149
- const isContext = (u) => hasProperty(u, TypeId$48);
7267
+ const isContext = (u) => hasProperty(u, TypeId$50);
7150
7268
  /**
7151
7269
  * Checks whether the provided argument is a `Reference`.
7152
7270
  *
@@ -7650,7 +7768,7 @@ const withMapUnsafe = (self, f) => {
7650
7768
  const Reference = Service;
7651
7769
  //#endregion
7652
7770
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Duration.js
7653
- const TypeId$47 = "~effect/time/Duration";
7771
+ const TypeId$49 = "~effect/time/Duration";
7654
7772
  const bigint0$2 = /*#__PURE__*/ BigInt(0);
7655
7773
  const bigint1e3 = /*#__PURE__*/ BigInt(1e3);
7656
7774
  const bigint1e6 = /*#__PURE__*/ BigInt(1e6);
@@ -7709,7 +7827,7 @@ const fromInputUnsafe = (input) => {
7709
7827
  }
7710
7828
  case "object": {
7711
7829
  if (input === null) break;
7712
- if (TypeId$47 in input) return input;
7830
+ if (TypeId$49 in input) return input;
7713
7831
  if (Array.isArray(input)) {
7714
7832
  if (input.length !== 2 || !input.every(isNumber)) return invalid(input);
7715
7833
  if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$1;
@@ -7744,7 +7862,7 @@ const zeroDurationValue = {
7744
7862
  const infinityDurationValue = { _tag: "Infinity" };
7745
7863
  const negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
7746
7864
  const DurationProto = {
7747
- [TypeId$47]: TypeId$47,
7865
+ [TypeId$49]: TypeId$49,
7748
7866
  [symbol$3]() {
7749
7867
  return structure(this.value);
7750
7868
  },
@@ -7822,7 +7940,7 @@ const make$61 = (input) => {
7822
7940
  * @category guards
7823
7941
  * @since 2.0.0
7824
7942
  */
7825
- const isDuration = (u) => hasProperty(u, TypeId$47);
7943
+ const isDuration = (u) => hasProperty(u, TypeId$49);
7826
7944
  /**
7827
7945
  * Checks whether a Duration is finite (not infinite).
7828
7946
  *
@@ -9669,7 +9787,7 @@ const provideServiceImpl = (self, service, implementation) => updateContext$1(se
9669
9787
  return add(s, service, implementation);
9670
9788
  });
9671
9789
  /** @internal */
9672
- const when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$4(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
9790
+ const when$3 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$4(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
9673
9791
  /** @internal */
9674
9792
  const forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9675
9793
  while: constTrue,
@@ -9757,7 +9875,7 @@ const option$2 = (self) => match$1(self, {
9757
9875
  onSuccess: some$1
9758
9876
  });
9759
9877
  /** @internal */
9760
- const result = (self) => matchEager(self, {
9878
+ const result$1 = (self) => matchEager(self, {
9761
9879
  onFailure: fail$7,
9762
9880
  onSuccess: succeed$7
9763
9881
  });
@@ -10041,11 +10159,11 @@ const interruptibleMask$1 = (f) => withFiber$1((fiber) => {
10041
10159
  });
10042
10160
  /** @internal */
10043
10161
  const all$1 = (arg, options) => {
10044
- if (isIterable(arg)) return options?.mode === "result" ? forEach$2(arg, result, options) : forEach$2(arg, identity, options);
10045
- else if (options?.discard) return options.mode === "result" ? forEach$2(Object.values(arg), result, options) : forEach$2(Object.values(arg), identity, options);
10162
+ if (isIterable(arg)) return options?.mode === "result" ? forEach$2(arg, result$1, options) : forEach$2(arg, identity, options);
10163
+ else if (options?.discard) return options.mode === "result" ? forEach$2(Object.values(arg), result$1, options) : forEach$2(Object.values(arg), identity, options);
10046
10164
  return suspend$3(() => {
10047
10165
  const out = {};
10048
- return as$1(forEach$2(Object.entries(arg), ([key, effect]) => map$6(options?.mode === "result" ? result(effect) : effect, (value) => {
10166
+ return as$1(forEach$2(Object.entries(arg), ([key, effect]) => map$6(options?.mode === "result" ? result$1(effect) : effect, (value) => {
10049
10167
  out[key] = value;
10050
10168
  }), {
10051
10169
  discard: true,
@@ -10699,7 +10817,7 @@ const reportCauseUnsafe = (fiber, cause, defectsOnly) => {
10699
10817
  };
10700
10818
  //#endregion
10701
10819
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Deferred.js
10702
- const TypeId$46 = "~effect/Deferred";
10820
+ const TypeId$48 = "~effect/Deferred";
10703
10821
  /**
10704
10822
  * Checks whether a value is a `Deferred`.
10705
10823
  *
@@ -10711,9 +10829,9 @@ const TypeId$46 = "~effect/Deferred";
10711
10829
  * @category guards
10712
10830
  * @since 4.0.0
10713
10831
  */
10714
- const isDeferred = (u) => hasProperty(u, TypeId$46);
10832
+ const isDeferred = (u) => hasProperty(u, TypeId$48);
10715
10833
  const DeferredProto = {
10716
- [TypeId$46]: {
10834
+ [TypeId$48]: {
10717
10835
  _A: identity,
10718
10836
  _E: identity
10719
10837
  },
@@ -11755,14 +11873,14 @@ const close = scopeClose;
11755
11873
  const closeUnsafe = scopeCloseUnsafe;
11756
11874
  //#endregion
11757
11875
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Layer.js
11758
- const TypeId$45 = "~effect/Layer";
11876
+ const TypeId$47 = "~effect/Layer";
11759
11877
  const MemoMapTypeId = "~effect/Layer/MemoMap";
11760
11878
  const memoMapReuse = (entry, scope) => {
11761
11879
  entry.observers++;
11762
11880
  return andThen$1(scopeAddFinalizerExit(scope, (exit) => entry.finalizer(exit)), entry.effect);
11763
11881
  };
11764
11882
  const LayerProto = {
11765
- [TypeId$45]: {
11883
+ [TypeId$47]: {
11766
11884
  _ROut: identity,
11767
11885
  _E: identity,
11768
11886
  _RIn: identity
@@ -13557,11 +13675,11 @@ const Clock = ClockRef;
13557
13675
  //#endregion
13558
13676
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/dateTime.js
13559
13677
  /** @internal */
13560
- const TypeId$44 = "~effect/time/DateTime";
13678
+ const TypeId$46 = "~effect/time/DateTime";
13561
13679
  /** @internal */
13562
13680
  const TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
13563
13681
  const Proto$14 = {
13564
- [TypeId$44]: TypeId$44,
13682
+ [TypeId$46]: TypeId$46,
13565
13683
  pipe() {
13566
13684
  return pipeArguments(this, arguments);
13567
13685
  },
@@ -14005,6 +14123,243 @@ const matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$
14005
14123
  return !isFailure$1(halt) ? options.onDone(halt.success.value) : options.onFailure(halt.failure);
14006
14124
  }
14007
14125
  }));
14126
+ const ScheduleProto = {
14127
+ ["~effect/Schedule"]: {
14128
+ _Out: identity,
14129
+ _In: identity,
14130
+ _Env: identity
14131
+ },
14132
+ pipe() {
14133
+ return pipeArguments(this, arguments);
14134
+ }
14135
+ };
14136
+ /**
14137
+ * Creates a Schedule from a step function that returns a Pull.
14138
+ *
14139
+ * **Example** (Creating a custom schedule from a step function)
14140
+ *
14141
+ * ```ts
14142
+ * import { Cause, Duration, Effect, Schedule } from "effect"
14143
+ *
14144
+ * const schedule = Schedule.fromStep(Effect.sync(() => {
14145
+ * let count = 0
14146
+ *
14147
+ * return (_now: number, _input: string) => {
14148
+ * if (count >= 3) {
14149
+ * return Cause.done(count)
14150
+ * }
14151
+ * return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
14152
+ * }
14153
+ * }))
14154
+ * ```
14155
+ *
14156
+ * @category constructors
14157
+ * @since 4.0.0
14158
+ */
14159
+ const fromStep = (step) => {
14160
+ const self = Object.create(ScheduleProto);
14161
+ self.step = step;
14162
+ return self;
14163
+ };
14164
+ const metadataFn = () => {
14165
+ let n = 0;
14166
+ let previous;
14167
+ let start;
14168
+ return (now, input) => {
14169
+ if (start === void 0) start = now;
14170
+ const elapsed = now - start;
14171
+ const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
14172
+ previous = now;
14173
+ return {
14174
+ input,
14175
+ attempt: ++n,
14176
+ start,
14177
+ now,
14178
+ elapsed,
14179
+ elapsedSincePrevious
14180
+ };
14181
+ };
14182
+ };
14183
+ /**
14184
+ * Creates a Schedule from a step function that receives metadata about the schedule's execution.
14185
+ *
14186
+ * **Example** (Creating a metadata-aware schedule)
14187
+ *
14188
+ * ```ts
14189
+ * import { Cause, Duration, Effect, Schedule } from "effect"
14190
+ *
14191
+ * const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
14192
+ * if (metadata.attempt > 3) {
14193
+ * return Cause.done("finished")
14194
+ * }
14195
+ *
14196
+ * return Effect.succeed([
14197
+ * `attempt ${metadata.attempt}: ${metadata.input}`,
14198
+ * Duration.millis(250)
14199
+ * ] as [string, Duration.Duration])
14200
+ * }))
14201
+ * ```
14202
+ *
14203
+ * @category constructors
14204
+ * @since 4.0.0
14205
+ */
14206
+ const fromStepWithMetadata = (step) => fromStep(map$6(step, (f) => {
14207
+ const meta = metadataFn();
14208
+ return (now, input) => f(meta(now, input));
14209
+ }));
14210
+ /**
14211
+ * Extracts the step function from a Schedule.
14212
+ *
14213
+ * **Example** (Extracting a schedule step function)
14214
+ *
14215
+ * ```ts
14216
+ * import { Effect, Schedule } from "effect"
14217
+ *
14218
+ * // Extract step function from an existing schedule
14219
+ * const schedule = Schedule.exponential("100 millis").pipe(Schedule.take(3))
14220
+ *
14221
+ * const program = Effect.gen(function*() {
14222
+ * const stepFn = yield* Schedule.toStep(schedule)
14223
+ *
14224
+ * // Use the step function directly for custom logic. The timestamp is
14225
+ * // supplied by the caller, so tests can pass a deterministic value.
14226
+ * const now = 0
14227
+ * const result = yield* stepFn(now, "input")
14228
+ *
14229
+ * console.log(`Step result: ${result}`)
14230
+ * })
14231
+ * ```
14232
+ *
14233
+ * @category destructors
14234
+ * @since 4.0.0
14235
+ */
14236
+ const toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$6(() => failCause$5(cause)));
14237
+ /**
14238
+ * Extracts a step function from a `Schedule` that sleeps for each computed
14239
+ * delay and returns metadata for the completed step.
14240
+ *
14241
+ * **When to use**
14242
+ *
14243
+ * Use to drive a schedule manually while preserving the computed output,
14244
+ * delay, input, attempt, and elapsed timing metadata for each step.
14245
+ *
14246
+ * **Details**
14247
+ *
14248
+ * The returned step reads the current time from `Clock` when invoked, calls the
14249
+ * schedule step with that timestamp and input, sleeps for the returned
14250
+ * duration, and then yields `Metadata`.
14251
+ *
14252
+ * @see {@link toStep} for manually supplying the timestamp and handling the returned delay yourself
14253
+ * @see {@link toStepWithSleep} for the same automatic sleeping behavior when only the schedule output is needed
14254
+ *
14255
+ * @category destructors
14256
+ * @since 4.0.0
14257
+ */
14258
+ const toStepWithMetadata = (schedule) => clockWith$1((clock) => map$6(toStep(schedule), (step) => {
14259
+ const metaFn = metadataFn();
14260
+ return (input) => suspend$3(() => {
14261
+ const now = clock.currentTimeMillisUnsafe();
14262
+ return flatMap$4(step(now, input), ([output, duration]) => {
14263
+ const meta = metaFn(now, input);
14264
+ meta.output = output;
14265
+ meta.duration = duration;
14266
+ return as$1(sleep$1(duration), meta);
14267
+ });
14268
+ });
14269
+ }));
14270
+ /**
14271
+ * Extracts a step function from a Schedule that automatically handles sleep delays.
14272
+ *
14273
+ * **Example** (Extracting a sleeping step function)
14274
+ *
14275
+ * ```ts
14276
+ * import { Effect, Schedule } from "effect"
14277
+ *
14278
+ * // Convert schedule to step function with automatic sleeping
14279
+ * const schedule = Schedule.spaced("1 second").pipe(Schedule.take(3))
14280
+ *
14281
+ * const program = Effect.gen(function*() {
14282
+ * const stepWithSleep = yield* Schedule.toStepWithSleep(schedule)
14283
+ *
14284
+ * // Each call will automatically sleep for the scheduled delay
14285
+ * console.log("Starting...")
14286
+ * const result1 = yield* stepWithSleep("first")
14287
+ * console.log(`First result: ${result1}`)
14288
+ *
14289
+ * const result2 = yield* stepWithSleep("second")
14290
+ * console.log(`Second result: ${result2}`)
14291
+ *
14292
+ * const result3 = yield* stepWithSleep("third")
14293
+ * console.log(`Third result: ${result3}`)
14294
+ * })
14295
+ * ```
14296
+ *
14297
+ * @category destructors
14298
+ * @since 4.0.0
14299
+ */
14300
+ const toStepWithSleep = (schedule) => map$6(toStepWithMetadata(schedule), (step) => (input) => map$6(step(input), (meta) => meta.output));
14301
+ /**
14302
+ * Returns a schedule that recurs continuously, each repetition spaced the
14303
+ * specified duration from the last run.
14304
+ *
14305
+ * **When to use**
14306
+ *
14307
+ * Use when each delay should start after the previous action
14308
+ * completes. Use `fixed` when recurrences should stay aligned to a regular
14309
+ * cadence.
14310
+ *
14311
+ * **Example** (Repeating with fixed spacing)
14312
+ *
14313
+ * ```ts
14314
+ * import { Console, Effect, Schedule } from "effect"
14315
+ *
14316
+ * // Basic spaced schedule - runs every 2 seconds
14317
+ * const everyTwoSeconds = Schedule.spaced("2 seconds")
14318
+ *
14319
+ * // Heartbeat that runs indefinitely with fixed spacing
14320
+ * const heartbeat = Effect.gen(function*() {
14321
+ * yield* Console.log("Heartbeat")
14322
+ * }).pipe(
14323
+ * Effect.repeat(everyTwoSeconds)
14324
+ * )
14325
+ *
14326
+ * // Limited repeat - run only 5 times with 1-second spacing
14327
+ * const limitedTask = Effect.gen(function*() {
14328
+ * yield* Console.log("Executing scheduled task...")
14329
+ * yield* Effect.sleep("500 millis") // simulate work
14330
+ * return "Task completed"
14331
+ * }).pipe(
14332
+ * Effect.repeat(
14333
+ * Schedule.spaced("1 second").pipe(Schedule.take(5))
14334
+ * )
14335
+ * )
14336
+ *
14337
+ * // Simple spaced schedule with limited repetitions
14338
+ * const limitedSpaced = Schedule.spaced("100 millis").pipe(
14339
+ * Schedule.both(Schedule.recurs(5)) // at most 5 times
14340
+ * )
14341
+ *
14342
+ * const program = Effect.gen(function*() {
14343
+ * yield* Console.log("Starting spaced execution...")
14344
+ *
14345
+ * yield* Effect.repeat(
14346
+ * Effect.succeed("work item"),
14347
+ * limitedSpaced
14348
+ * )
14349
+ *
14350
+ * yield* Console.log("Completed executions")
14351
+ * })
14352
+ * ```
14353
+ *
14354
+ * @see {@link fixed} for recurrence aligned to a regular cadence
14355
+ *
14356
+ * @category constructors
14357
+ * @since 2.0.0
14358
+ */
14359
+ const spaced = (duration) => {
14360
+ const decoded = fromInputUnsafe(duration);
14361
+ return fromStepWithMetadata(succeed$6((meta) => succeed$6([meta.attempt - 1, decoded])));
14362
+ };
14008
14363
  //#endregion
14009
14364
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/layer.js
14010
14365
  const provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$4(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$3(self, context)));
@@ -16012,7 +16367,7 @@ const raceFirst = raceFirst$1;
16012
16367
  * @category conditional operators
16013
16368
  * @since 2.0.0
16014
16369
  */
16015
- const when = when$1;
16370
+ const when$2 = when$3;
16016
16371
  /**
16017
16372
  * Handles success or failure eagerly with effectful handlers when the effect is already resolved.
16018
16373
  *
@@ -18202,7 +18557,7 @@ const redactedRegistry = /*#__PURE__*/ new WeakMap();
18202
18557
  *
18203
18558
  * @since 3.3.0
18204
18559
  */
18205
- const TypeId$43 = "~effect/data/Redacted";
18560
+ const TypeId$44 = "~effect/data/Redacted";
18206
18561
  /**
18207
18562
  * Returns `true` if a value is a `Redacted` wrapper.
18208
18563
  *
@@ -18230,7 +18585,7 @@ const TypeId$43 = "~effect/data/Redacted";
18230
18585
  * @category refinements
18231
18586
  * @since 3.3.0
18232
18587
  */
18233
- const isRedacted = (u) => hasProperty(u, TypeId$43);
18588
+ const isRedacted = (u) => hasProperty(u, TypeId$44);
18234
18589
  /**
18235
18590
  * Creates a `Redacted` wrapper for a sensitive value.
18236
18591
  *
@@ -18263,7 +18618,7 @@ const make$56 = (value, options) => {
18263
18618
  return self;
18264
18619
  };
18265
18620
  const Proto$13 = {
18266
- [TypeId$43]: { _A: (_) => _ },
18621
+ [TypeId$44]: { _A: (_) => _ },
18267
18622
  label: void 0,
18268
18623
  ...PipeInspectableProto,
18269
18624
  toJSON() {
@@ -18281,7 +18636,7 @@ const Proto$13 = {
18281
18636
  };
18282
18637
  //#endregion
18283
18638
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/SchemaIssue.js
18284
- const TypeId$42 = "~effect/SchemaIssue/Issue";
18639
+ const TypeId$43 = "~effect/SchemaIssue/Issue";
18285
18640
  /**
18286
18641
  * Returns `true` if the given value is an {@link Issue}.
18287
18642
  *
@@ -18312,10 +18667,10 @@ const TypeId$42 = "~effect/SchemaIssue/Issue";
18312
18667
  * @since 4.0.0
18313
18668
  */
18314
18669
  function isIssue(u) {
18315
- return hasProperty(u, TypeId$42);
18670
+ return hasProperty(u, TypeId$43);
18316
18671
  }
18317
18672
  var Base$1 = class {
18318
- [TypeId$42] = TypeId$42;
18673
+ [TypeId$43] = TypeId$43;
18319
18674
  toString() {
18320
18675
  return defaultFormatter(this);
18321
18676
  }
@@ -19443,9 +19798,9 @@ function split(options) {
19443
19798
  *
19444
19799
  * @since 2.0.0
19445
19800
  */
19446
- const TypeId$41 = "~effect/BigDecimal";
19801
+ const TypeId$42 = "~effect/BigDecimal";
19447
19802
  const BigDecimalProto = {
19448
- [TypeId$41]: TypeId$41,
19803
+ [TypeId$42]: TypeId$42,
19449
19804
  [symbol$3]() {
19450
19805
  const normalized = normalize(this);
19451
19806
  return combine$1(hash(normalized.value), number$1(normalized.scale));
@@ -19491,7 +19846,7 @@ const BigDecimalProto = {
19491
19846
  * @category guards
19492
19847
  * @since 2.0.0
19493
19848
  */
19494
- const isBigDecimal = (u) => hasProperty(u, TypeId$41);
19849
+ const isBigDecimal = (u) => hasProperty(u, TypeId$42);
19495
19850
  /**
19496
19851
  * Creates a `BigDecimal` from a `bigint` value and a scale.
19497
19852
  *
@@ -19826,7 +20181,7 @@ const isZero = (n) => n.value === bigint0;
19826
20181
  const isNegative = (n) => n.value < bigint0;
19827
20182
  //#endregion
19828
20183
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/SchemaTransformation.js
19829
- const TypeId$40 = "~effect/SchemaTransformation/Transformation";
20184
+ const TypeId$41 = "~effect/SchemaTransformation/Transformation";
19830
20185
  /**
19831
20186
  * Represents a bidirectional transformation between a decoded type `T` and an encoded
19832
20187
  * type `E`, built from a pair of `Getter`s.
@@ -19869,7 +20224,7 @@ const TypeId$40 = "~effect/SchemaTransformation/Transformation";
19869
20224
  * @since 4.0.0
19870
20225
  */
19871
20226
  var Transformation = class Transformation {
19872
- [TypeId$40] = TypeId$40;
20227
+ [TypeId$41] = TypeId$41;
19873
20228
  _tag = "Transformation";
19874
20229
  decode;
19875
20230
  encode;
@@ -19915,7 +20270,7 @@ var Transformation = class Transformation {
19915
20270
  * @since 4.0.0
19916
20271
  */
19917
20272
  function isTransformation(u) {
19918
- return hasProperty(u, TypeId$40);
20273
+ return hasProperty(u, TypeId$41);
19919
20274
  }
19920
20275
  /**
19921
20276
  * Constructs a `Transformation` from an object with `decode` and `encode`
@@ -20297,7 +20652,7 @@ var Context = class {
20297
20652
  this.annotations = annotations;
20298
20653
  }
20299
20654
  };
20300
- const TypeId$39 = "~effect/Schema";
20655
+ const TypeId$40 = "~effect/Schema";
20301
20656
  /**
20302
20657
  * Represents the abstract base class for all {@link AST} node variants.
20303
20658
  *
@@ -20319,7 +20674,7 @@ const TypeId$39 = "~effect/Schema";
20319
20674
  * @since 4.0.0
20320
20675
  */
20321
20676
  var Base = class {
20322
- [TypeId$39] = TypeId$39;
20677
+ [TypeId$40] = TypeId$40;
20323
20678
  annotations;
20324
20679
  checks;
20325
20680
  encoding;
@@ -22082,7 +22437,7 @@ function nominal() {
22082
22437
  *
22083
22438
  * @since 4.0.0
22084
22439
  */
22085
- const TypeId$38 = "~effect/platform/PlatformError";
22440
+ const TypeId$39 = "~effect/platform/PlatformError";
22086
22441
  /**
22087
22442
  * Error data for an invalid argument passed to a platform API.
22088
22443
  *
@@ -22192,7 +22547,7 @@ var PlatformError = class extends TaggedError("PlatformError") {
22192
22547
  *
22193
22548
  * @since 4.0.0
22194
22549
  */
22195
- [TypeId$38] = TypeId$38;
22550
+ [TypeId$39] = TypeId$39;
22196
22551
  get message() {
22197
22552
  return this.reason.message;
22198
22553
  }
@@ -22854,7 +23209,7 @@ const takeAll$2 = (self) => takeN(self, self.length);
22854
23209
  * @category elements
22855
23210
  * @since 4.0.0
22856
23211
  */
22857
- const take$3 = (self) => {
23212
+ const take$4 = (self) => {
22858
23213
  if (!self.head) return Empty$2;
22859
23214
  const message = self.head.array[self.head.offset];
22860
23215
  if (self.head.mutable) self.head.array[self.head.offset] = void 0;
@@ -22977,9 +23332,9 @@ const filter$1 = (self, f) => {
22977
23332
  const remove$5 = (self, value) => filter$1(self, (v) => v !== value);
22978
23333
  //#endregion
22979
23334
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/MutableRef.js
22980
- const TypeId$37 = "~effect/MutableRef";
23335
+ const TypeId$38 = "~effect/MutableRef";
22981
23336
  const MutableRefProto = {
22982
- [TypeId$37]: TypeId$37,
23337
+ [TypeId$38]: TypeId$38,
22983
23338
  ...PipeInspectableProto,
22984
23339
  toJSON() {
22985
23340
  return {
@@ -23165,7 +23520,7 @@ const set$6 = /*#__PURE__*/ dual(2, (self, value) => {
23165
23520
  *
23166
23521
  * @since 2.0.0
23167
23522
  */
23168
- const TypeId$36 = "~effect/PubSub";
23523
+ const TypeId$37 = "~effect/PubSub";
23169
23524
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
23170
23525
  /**
23171
23526
  * Creates a PubSub with a custom atomic implementation and strategy.
@@ -23356,7 +23711,7 @@ const makeAtomicUnbounded = (options) => new UnboundedPubSub(options?.replay ? n
23356
23711
  */
23357
23712
  const shutdown$1 = (self) => uninterruptible(withFiber((fiber) => {
23358
23713
  set$6(self.shutdownFlag, true);
23359
- return close(self.scope, interrupt$2(fiber.id)).pipe(andThen(self.strategy.shutdown), when(self.shutdownHook.open), asVoid);
23714
+ return close(self.scope, interrupt$2(fiber.id)).pipe(andThen(self.strategy.shutdown), when$2(self.shutdownHook.open), asVoid);
23360
23715
  }));
23361
23716
  /**
23362
23717
  * Publishes a message to the `PubSub` as an `Effect`, returning whether the
@@ -23521,7 +23876,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
23521
23876
  self.subscribers.delete(self.subscription);
23522
23877
  self.subscription.unsubscribe();
23523
23878
  self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
23524
- })), when(self.shutdownHook.open), asVoid);
23879
+ })), when$2(self.shutdownHook.open), asVoid);
23525
23880
  }));
23526
23881
  /**
23527
23882
  * Takes a single message from the subscription. If no messages are available,
@@ -23556,7 +23911,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
23556
23911
  * @category subscriptions
23557
23912
  * @since 4.0.0
23558
23913
  */
23559
- const take$2 = (self) => suspend$2(() => {
23914
+ const take$3 = (self) => suspend$2(() => {
23560
23915
  if (self.shutdownFlag.current) return interrupt$1;
23561
23916
  if (self.replayWindow.remaining > 0) return succeed$3(self.replayWindow.take());
23562
23917
  const message = self.pollers.length === 0 ? self.subscription.poll() : Empty$2;
@@ -24231,7 +24586,7 @@ var SubscriptionImpl = class {
24231
24586
  }
24232
24587
  };
24233
24588
  var PubSubImpl = class {
24234
- [TypeId$36] = { _A: identity };
24589
+ [TypeId$37] = { _A: identity };
24235
24590
  pubsub;
24236
24591
  subscribers;
24237
24592
  scope;
@@ -24302,7 +24657,7 @@ var BackPressureStrategy = class {
24302
24657
  onPubSubEmptySpaceUnsafe(pubsub, subscribers) {
24303
24658
  let keepPolling = true;
24304
24659
  while (keepPolling && !pubsub.isFull()) {
24305
- const publisher = take$3(this.publishers);
24660
+ const publisher = take$4(this.publishers);
24306
24661
  if (publisher === Empty$2) keepPolling = false;
24307
24662
  else {
24308
24663
  const [value, deferred] = publisher;
@@ -24414,7 +24769,7 @@ var DroppingStrategy = class {
24414
24769
  const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
24415
24770
  let keepPolling = true;
24416
24771
  while (keepPolling && !subscription.isEmpty()) {
24417
- const poller = take$3(pollers);
24772
+ const poller = take$4(pollers);
24418
24773
  if (poller === Empty$2) {
24419
24774
  removeSubscribers(subscribers, subscription, pollers);
24420
24775
  if (pollers.length === 0) keepPolling = false;
@@ -24578,7 +24933,7 @@ const emptyReplayWindow = {
24578
24933
  *
24579
24934
  * @since 3.8.0
24580
24935
  */
24581
- const TypeId$35 = "~effect/Queue";
24936
+ const TypeId$36 = "~effect/Queue";
24582
24937
  const EnqueueTypeId = "~effect/Queue/Enqueue";
24583
24938
  const DequeueTypeId = "~effect/Queue/Dequeue";
24584
24939
  const variance$1 = {
@@ -24586,7 +24941,7 @@ const variance$1 = {
24586
24941
  _E: identity
24587
24942
  };
24588
24943
  const QueueProto = {
24589
- [TypeId$35]: variance$1,
24944
+ [TypeId$36]: variance$1,
24590
24945
  [EnqueueTypeId]: variance$1,
24591
24946
  [DequeueTypeId]: variance$1,
24592
24947
  ...PipeInspectableProto,
@@ -24685,6 +25040,43 @@ const make$48 = (options) => withFiber$1((fiber) => {
24685
25040
  */
24686
25041
  const bounded = (capacity) => make$48({ capacity });
24687
25042
  /**
25043
+ * Creates a bounded queue with sliding strategy. When the queue reaches capacity,
25044
+ * new elements are added and the oldest elements are dropped.
25045
+ *
25046
+ * **When to use**
25047
+ *
25048
+ * Use when producers should not block and message loss is acceptable.
25049
+ * Useful when you want to maintain a rolling window of the most recent messages.
25050
+ *
25051
+ * **Example** (Creating sliding queues)
25052
+ *
25053
+ * ```ts
25054
+ * import { Effect, Queue } from "effect"
25055
+ *
25056
+ * const program = Effect.gen(function*() {
25057
+ * const queue = yield* Queue.sliding<number>(3)
25058
+ *
25059
+ * // Fill the queue to capacity
25060
+ * yield* Queue.offer(queue, 1)
25061
+ * yield* Queue.offer(queue, 2)
25062
+ * yield* Queue.offer(queue, 3)
25063
+ *
25064
+ * // This will succeed, dropping the oldest element (1)
25065
+ * yield* Queue.offer(queue, 4)
25066
+ *
25067
+ * const all = yield* Queue.takeAll(queue)
25068
+ * console.log(all) // [2, 3, 4] - oldest element (1) was dropped
25069
+ * })
25070
+ * ```
25071
+ *
25072
+ * @category constructors
25073
+ * @since 2.0.0
25074
+ */
25075
+ const sliding = (capacity) => make$48({
25076
+ capacity,
25077
+ strategy: "sliding"
25078
+ });
25079
+ /**
24688
25080
  * Creates an unbounded queue that can grow to any size without blocking producers.
24689
25081
  *
24690
25082
  * **When to use**
@@ -24763,7 +25155,7 @@ const offer = (self, message) => suspend$3(() => {
24763
25155
  }
24764
25156
  return offerRemainingSingle(self, message);
24765
25157
  case "sliding":
24766
- take$3(self.messages);
25158
+ take$4(self.messages);
24767
25159
  append(self.messages, message);
24768
25160
  return exitTrue;
24769
25161
  }
@@ -24806,7 +25198,7 @@ const offerUnsafe = (self, message) => {
24806
25198
  if (self.state._tag !== "Open") return false;
24807
25199
  else if (self.messages.length >= self.capacity) {
24808
25200
  if (self.strategy === "sliding") {
24809
- take$3(self.messages);
25201
+ take$4(self.messages);
24810
25202
  append(self.messages, message);
24811
25203
  return true;
24812
25204
  } else if (self.capacity <= 0 && self.state.takers.size > 0) {
@@ -25169,7 +25561,7 @@ const takeBetween = (self, min, max) => suspend$3(() => takeBetweenUnsafe(self,
25169
25561
  * @category taking
25170
25562
  * @since 2.0.0
25171
25563
  */
25172
- const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self), take$1(self)));
25564
+ const take$2 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self), take$2(self)));
25173
25565
  /**
25174
25566
  * Attempts to take one message from the queue synchronously.
25175
25567
  *
@@ -25211,14 +25603,14 @@ const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake
25211
25603
  const takeUnsafe = (self) => {
25212
25604
  if (self.state._tag === "Done") return self.state.exit;
25213
25605
  if (self.messages.length > 0) {
25214
- const message = take$3(self.messages);
25606
+ const message = take$4(self.messages);
25215
25607
  releaseCapacity(self);
25216
25608
  return exitSucceed(message);
25217
25609
  } else if (self.capacity <= 0 && self.state.offers.size > 0) {
25218
25610
  self.capacity = 1;
25219
25611
  releaseCapacity(self);
25220
25612
  self.capacity = 0;
25221
- const message = take$3(self.messages);
25613
+ const message = take$4(self.messages);
25222
25614
  releaseCapacity(self);
25223
25615
  return exitSucceed(message);
25224
25616
  }
@@ -25290,7 +25682,7 @@ const takeBetweenUnsafe = (self, min, max) => {
25290
25682
  self.capacity = 1;
25291
25683
  releaseCapacity(self);
25292
25684
  self.capacity = 0;
25293
- const messages = [take$3(self.messages)];
25685
+ const messages = [take$4(self.messages)];
25294
25686
  releaseCapacity(self);
25295
25687
  return exitSucceed(messages);
25296
25688
  }
@@ -25612,7 +26004,7 @@ const withPermit = (self, effect) => {
25612
26004
  * @category type IDs
25613
26005
  * @since 4.0.0
25614
26006
  */
25615
- const TypeId$34 = "~effect/Channel";
26007
+ const TypeId$35 = "~effect/Channel";
25616
26008
  /**
25617
26009
  * Checks whether a value is a `Channel`.
25618
26010
  *
@@ -25629,9 +26021,9 @@ const TypeId$34 = "~effect/Channel";
25629
26021
  * @category guards
25630
26022
  * @since 3.5.4
25631
26023
  */
25632
- const isChannel = (u) => hasProperty(u, TypeId$34);
26024
+ const isChannel = (u) => hasProperty(u, TypeId$35);
25633
26025
  const ChannelProto = {
25634
- [TypeId$34]: {
26026
+ [TypeId$35]: {
25635
26027
  _Env: identity,
25636
26028
  _InErr: identity,
25637
26029
  _InElem: identity,
@@ -26449,7 +26841,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26449
26841
  } else {
26450
26842
  const effects = yield* bounded(concurrencyN - 2);
26451
26843
  yield* addFinalizer$1(forkedScope, shutdown(queue));
26452
- yield* take$1(effects).pipe(flatten$1, flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$1((cause) => failCause$1(queue, cause)), forkIn(forkedScope));
26844
+ yield* take$2(effects).pipe(flatten$1, flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$1((cause) => failCause$1(queue, cause)), forkIn(forkedScope));
26453
26845
  let errorCause;
26454
26846
  const onExit = (exit) => {
26455
26847
  if (exit._tag === "Success") return;
@@ -26464,7 +26856,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26464
26856
  return offer(effects, join$1(fiber));
26465
26857
  }), forever({ disableYield: true }), catchCause$1((cause) => offer(effects, failCause$3(cause)).pipe(andThen(failCause$1(effects, cause)))), forkIn(forkedScope));
26466
26858
  }
26467
- return take$1(queue);
26859
+ return take$2(queue);
26468
26860
  }));
26469
26861
  /**
26470
26862
  * Maps each output element to a channel and flattens the child channel
@@ -26615,26 +27007,6 @@ const filterArray = /*#__PURE__*/ dual(2, (self, predicate) => transformPull$1(s
26615
27007
  return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
26616
27008
  }))));
26617
27009
  /**
26618
- * Filters and maps each element inside emitted non-empty arrays using a
26619
- * `Filter`.
26620
- *
26621
- * **Details**
26622
- *
26623
- * Successful filter results are kept as mapped values. Failed filter results
26624
- * are removed from the array. Arrays that become empty are discarded.
26625
- *
26626
- * @category filtering
26627
- * @since 4.0.0
26628
- */
26629
- const filterMapArray = /*#__PURE__*/ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$2(pull, function loop(arr) {
26630
- const passes = [];
26631
- for (let i = 0; i < arr.length; i++) {
26632
- const result = filter(arr[i]);
26633
- if (isSuccess$1(result)) passes.push(result.success);
26634
- }
26635
- return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
26636
- }))));
26637
- /**
26638
27010
  * Catches any cause of failure from the channel and allows recovery by
26639
27011
  * creating a new channel based on the caught cause.
26640
27012
  *
@@ -26803,7 +27175,7 @@ const mergeAll = /*#__PURE__*/ dual(2, (channels, { bufferSize = 16, concurrency
26803
27175
  fibers.add(fiber);
26804
27176
  }
26805
27177
  }).pipe(catchCause$1((cause) => doneLatch.whenOpen(failCause$1(queue, cause))), forkIn(forkedScope));
26806
- return take$1(queue);
27178
+ return take$2(queue);
26807
27179
  })));
26808
27180
  /**
26809
27181
  * Returns a new channel, which is the merge of this channel and the specified
@@ -26852,7 +27224,7 @@ const merge$2 = /*#__PURE__*/ dual((args) => isChannel(args[0]) && isChannel(arg
26852
27224
  const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap$2((pull) => pull.pipe(flatMap$2((value) => offer(queue, value)), forever)), onError((cause) => andThen(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn(forkedScope));
26853
27225
  yield* runSide("left", left, forkUnsafe(forkedScope));
26854
27226
  yield* runSide("right", right, forkUnsafe(forkedScope));
26855
- return take$1(queue);
27227
+ return take$2(queue);
26856
27228
  })));
26857
27229
  /**
26858
27230
  * Splits upstream string chunks into lines, recognizing `\n`, `\r\n`, and
@@ -27211,14 +27583,14 @@ const runFold = /*#__PURE__*/ dual(3, (self, initial, f) => suspend$2(() => {
27211
27583
  const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
27212
27584
  //#endregion
27213
27585
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/stream.js
27214
- const TypeId$33 = "~effect/Stream";
27586
+ const TypeId$34 = "~effect/Stream";
27215
27587
  const streamVariance = {
27216
27588
  _R: identity,
27217
27589
  _E: identity,
27218
27590
  _A: identity
27219
27591
  };
27220
27592
  const StreamProto = {
27221
- [TypeId$33]: streamVariance,
27593
+ [TypeId$34]: streamVariance,
27222
27594
  pipe() {
27223
27595
  return pipeArguments(this, arguments);
27224
27596
  }
@@ -27231,7 +27603,7 @@ const fromChannel$2 = (channel) => {
27231
27603
  };
27232
27604
  //#endregion
27233
27605
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Sink.js
27234
- const TypeId$32 = "~effect/Sink";
27606
+ const TypeId$33 = "~effect/Sink";
27235
27607
  const endVoid = /*#__PURE__*/ succeed$3([void 0]);
27236
27608
  const sinkVariance = {
27237
27609
  _A: identity,
@@ -27241,7 +27613,7 @@ const sinkVariance = {
27241
27613
  _R: identity
27242
27614
  };
27243
27615
  const SinkProto = {
27244
- [TypeId$32]: sinkVariance,
27616
+ [TypeId$33]: sinkVariance,
27245
27617
  pipe() {
27246
27618
  return pipeArguments(this, arguments);
27247
27619
  }
@@ -27264,7 +27636,7 @@ const SinkProto = {
27264
27636
  * @category guards
27265
27637
  * @since 4.0.0
27266
27638
  */
27267
- const isSink = (u) => hasProperty(u, TypeId$32);
27639
+ const isSink = (u) => hasProperty(u, TypeId$33);
27268
27640
  /**
27269
27641
  * Creates a sink from a `Channel`.
27270
27642
  *
@@ -27328,6 +27700,38 @@ const toChannel$1 = (self) => fromTransform$1((upstream, scope) => succeed$3(fla
27328
27700
  */
27329
27701
  const drain = /*#__PURE__*/ fromTransform((upstream) => catchDone(forever(upstream, { disableYield: true }), () => endVoid));
27330
27702
  /**
27703
+ * Collects up to `n` input elements into an array.
27704
+ *
27705
+ * **Details**
27706
+ *
27707
+ * If `n` is less than or equal to zero, the sink completes with an empty array.
27708
+ * If more elements are pulled than needed, the remaining elements from the same
27709
+ * array are returned as leftovers.
27710
+ *
27711
+ * @category collecting
27712
+ * @since 2.0.0
27713
+ */
27714
+ const take$1 = (n) => fromTransform((upstream) => {
27715
+ const taken = [];
27716
+ if (n <= 0) return succeed$3([taken]);
27717
+ let leftover = void 0;
27718
+ return upstream.pipe(flatMap$2((arr) => {
27719
+ if (taken.length + arr.length <= n) {
27720
+ taken.push(...arr);
27721
+ if (taken.length === n) return done();
27722
+ return void_$1;
27723
+ }
27724
+ for (let i = 0; i < arr.length; i++) {
27725
+ taken.push(arr[i]);
27726
+ if (taken.length === n) {
27727
+ if (i + 1 < arr.length) leftover = arr.slice(i + 1);
27728
+ return done();
27729
+ }
27730
+ }
27731
+ return void_$1;
27732
+ }), forever({ disableYield: true }), catchDone(() => succeed$3([taken, leftover])));
27733
+ });
27734
+ /**
27331
27735
  * A sink that executes the provided effectful function for every item fed
27332
27736
  * to it.
27333
27737
  *
@@ -27413,9 +27817,9 @@ const forEachArray = (f) => fromTransform((upstream) => upstream.pipe(flatMap$2(
27413
27817
  const unwrap$2 = (effect) => fromChannel$1(unwrap$3(map$4(effect, toChannel$1)));
27414
27818
  //#endregion
27415
27819
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/MutableHashMap.js
27416
- const TypeId$31 = "~effect/collections/MutableHashMap";
27820
+ const TypeId$32 = "~effect/collections/MutableHashMap";
27417
27821
  const MutableHashMapProto = {
27418
- [TypeId$31]: TypeId$31,
27822
+ [TypeId$32]: TypeId$32,
27419
27823
  [Symbol.iterator]() {
27420
27824
  return this.backing[Symbol.iterator]();
27421
27825
  },
@@ -27783,9 +28187,9 @@ const size = (self) => self.backing.size;
27783
28187
  *
27784
28188
  * @since 3.5.0
27785
28189
  */
27786
- const TypeId$30 = "~effect/RcMap";
28190
+ const TypeId$31 = "~effect/RcMap";
27787
28191
  const makeUnsafe$2 = (options) => ({
27788
- [TypeId$30]: TypeId$30,
28192
+ [TypeId$31]: TypeId$31,
27789
28193
  lookup: options.lookup,
27790
28194
  context: options.context,
27791
28195
  scope: options.scope,
@@ -27962,7 +28366,7 @@ const release = (self, key, entry) => withFiber((fiber) => {
27962
28366
  });
27963
28367
  //#endregion
27964
28368
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/rcRef.js
27965
- const TypeId$29 = "~effect/RcRef";
28369
+ const TypeId$30 = "~effect/RcRef";
27966
28370
  const stateEmpty = { _tag: "Empty" };
27967
28371
  const stateClosed = { _tag: "Closed" };
27968
28372
  const variance = {
@@ -27970,7 +28374,7 @@ const variance = {
27970
28374
  _E: identity
27971
28375
  };
27972
28376
  var RcRefImpl = class {
27973
- [TypeId$29] = variance;
28377
+ [TypeId$30] = variance;
27974
28378
  pipe() {
27975
28379
  return pipeArguments(this, arguments);
27976
28380
  }
@@ -28235,7 +28639,7 @@ const get$4 = get$5;
28235
28639
  * @category type IDs
28236
28640
  * @since 4.0.0
28237
28641
  */
28238
- const TypeId$28 = "~effect/Stream";
28642
+ const TypeId$29 = "~effect/Stream";
28239
28643
  /**
28240
28644
  * Checks whether a value is a Stream.
28241
28645
  *
@@ -28260,7 +28664,7 @@ const TypeId$28 = "~effect/Stream";
28260
28664
  * @category guards
28261
28665
  * @since 4.0.0
28262
28666
  */
28263
- const isStream = (u) => hasProperty(u, TypeId$28);
28667
+ const isStream = (u) => hasProperty(u, TypeId$29);
28264
28668
  /**
28265
28669
  * Creates a stream from a array-emitting `Channel`.
28266
28670
  *
@@ -28933,26 +29337,6 @@ const merge$1 = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[
28933
29337
  * @since 2.0.0
28934
29338
  */
28935
29339
  const filter = /*#__PURE__*/ dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
28936
- /**
28937
- * Filters and maps stream elements in one pass using a `Filter`.
28938
- *
28939
- * **When to use**
28940
- *
28941
- * Use to keep only stream elements accepted by a `Filter` and emit each filter
28942
- * success value.
28943
- *
28944
- * **Details**
28945
- *
28946
- * `Result.succeed` values are emitted and `Result.fail` values are skipped.
28947
- *
28948
- * @see {@link filter} for keeping original elements with a boolean predicate or refinement
28949
- * @see {@link filterMapEffect} for an effectful `Filter`
28950
- * @see {@link partition} for consuming both filter success and failure values
28951
- *
28952
- * @category filtering
28953
- * @since 2.0.0
28954
- */
28955
- const filterMap = /*#__PURE__*/ dual(2, (self, filter) => fromChannel(filterMapArray(toChannel(self), filter)));
28956
29340
  const catch_ = /*#__PURE__*/ dual(2, (self, f) => fromChannel(catch_$1(self.channel, (error) => f(error).channel)));
28957
29341
  /**
28958
29342
  * Turns typed failures into defects, making the stream infallible.
@@ -29156,6 +29540,31 @@ const debounce = /*#__PURE__*/ dual(2, (self, duration) => transformPull(self, f
29156
29540
  });
29157
29541
  })));
29158
29542
  /**
29543
+ * Partitions the stream into arrays, emitting when the chunk size is reached
29544
+ * or the duration passes.
29545
+ *
29546
+ * **Example** (Grouping elements by size or time)
29547
+ *
29548
+ * ```ts
29549
+ * import { Console, Effect, Stream } from "effect"
29550
+ *
29551
+ * const program = Effect.gen(function*() {
29552
+ * const values = yield* Stream.make(1, 2, 3).pipe(
29553
+ * Stream.groupedWithin(2, "5 seconds"),
29554
+ * Stream.runCollect
29555
+ * )
29556
+ * yield* Console.log(values)
29557
+ * })
29558
+ *
29559
+ * Effect.runPromise(program)
29560
+ * // Output: [ [ 1, 2 ], [ 3 ] ]
29561
+ * ```
29562
+ *
29563
+ * @category grouping
29564
+ * @since 2.0.0
29565
+ */
29566
+ const groupedWithin = /*#__PURE__*/ dual(3, (self, chunkSize, duration) => aggregateWithin(self, take$1(chunkSize), spaced(duration)));
29567
+ /**
29159
29568
  * Applies a sink transducer to the stream and emits each sink result.
29160
29569
  *
29161
29570
  * **Example** (Transducing with a sink)
@@ -29198,6 +29607,78 @@ const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (ups
29198
29607
  return suspend$2(() => done$5 ? done$5 : pull);
29199
29608
  })));
29200
29609
  /**
29610
+ * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
29611
+ *
29612
+ * **Details**
29613
+ *
29614
+ * The schedule can flush the current aggregation even if the sink has not finished.
29615
+ *
29616
+ * **Example** (Aggregating with a sink and schedule)
29617
+ *
29618
+ * ```ts
29619
+ * import { Console, Effect, Schedule, Sink, Stream } from "effect"
29620
+ *
29621
+ * Effect.runPromise(Effect.gen(function* () {
29622
+ * const aggregated = yield* Stream.runCollect(
29623
+ * Stream.make(1, 2, 3, 4, 5, 6).pipe(
29624
+ * Stream.aggregateWithin(
29625
+ * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
29626
+ * Schedule.spaced("1 minute")
29627
+ * )
29628
+ * )
29629
+ * )
29630
+ * yield* Console.log(aggregated)
29631
+ * }))
29632
+ * // Output: [ 6, 15 ]
29633
+ * ```
29634
+ *
29635
+ * @category Aggregation
29636
+ * @since 2.0.0
29637
+ */
29638
+ const aggregateWithin = /*#__PURE__*/ dual(3, (self, sink, schedule) => fromChannel(fromTransformBracket(fnUntraced(function* (_upstream, _, scope) {
29639
+ const pull = yield* toPullScoped(self.channel, _);
29640
+ const pullLatch = makeUnsafe$4(false);
29641
+ const scheduleStep = Symbol();
29642
+ const buffer = yield* make$48({ capacity: 0 });
29643
+ yield* pull.pipe(pullLatch.whenOpen, flatMap$2((arr) => {
29644
+ pullLatch.closeUnsafe();
29645
+ return offer(buffer, arr);
29646
+ }), forever, catchCause$1((cause) => failCause$1(buffer, cause)), forkIn(scope));
29647
+ let lastOutput = none();
29648
+ let leftover;
29649
+ let sinkHasInput = false;
29650
+ const step = yield* toStepWithSleep(schedule);
29651
+ const stepToBuffer = suspend$2(function loop() {
29652
+ return step(lastOutput).pipe(flatMap$2(() => !sinkHasInput ? loop() : offer(buffer, scheduleStep)), flatMap$2(() => never$1), catchDone(() => done()));
29653
+ });
29654
+ const pullFromBuffer = take$2(buffer).pipe(flatMap$2((arr) => {
29655
+ if (arr === scheduleStep) return done();
29656
+ sinkHasInput = true;
29657
+ return succeed$3(arr);
29658
+ }));
29659
+ const sinkUpstream = suspend$2(() => {
29660
+ if (leftover !== void 0) {
29661
+ const chunk = leftover;
29662
+ leftover = void 0;
29663
+ sinkHasInput = true;
29664
+ return succeed$3(chunk);
29665
+ }
29666
+ pullLatch.openUnsafe();
29667
+ return pullFromBuffer;
29668
+ });
29669
+ const catchSinkHalt = flatMap$2(([value, leftover_]) => {
29670
+ if (!sinkHasInput && buffer.state._tag === "Done") return done();
29671
+ lastOutput = some$1(value);
29672
+ leftover = leftover_;
29673
+ return succeed$3(of(value));
29674
+ });
29675
+ return suspend$2(() => {
29676
+ if (buffer.state._tag === "Done" && leftover === void 0) return buffer.state.exit;
29677
+ sinkHasInput = leftover !== void 0;
29678
+ return succeed$3(suspend$2(() => sink.transform(sinkUpstream, scope)));
29679
+ }).pipe(flatMap$2((pull) => raceFirst(catchSinkHalt(pull), stepToBuffer)));
29680
+ }))));
29681
+ /**
29201
29682
  * Returns a stream that only emits elements that are not equal to the previously emitted element, as determined by the specified predicate.
29202
29683
  *
29203
29684
  * **Example** (Emitting values that changed by equivalence)
@@ -29636,7 +30117,7 @@ const toReadableStreamEffect = /*#__PURE__*/ dual((args) => isStream(args[0]), (
29636
30117
  *
29637
30118
  * @since 4.0.0
29638
30119
  */
29639
- const TypeId$27 = "~effect/platform/FileSystem";
30120
+ const TypeId$28 = "~effect/platform/FileSystem";
29640
30121
  /**
29641
30122
  * Creates a `Size` from various numeric input types.
29642
30123
  *
@@ -29746,7 +30227,7 @@ const FileSystem = /*#__PURE__*/ Service("effect/platform/FileSystem");
29746
30227
  */
29747
30228
  const make$42 = (impl) => FileSystem.of({
29748
30229
  ...impl,
29749
- [TypeId$27]: TypeId$27,
30230
+ [TypeId$28]: TypeId$28,
29750
30231
  exists: (path) => pipe(impl.access(path), as(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed$3(false) : fail$3(e))),
29751
30232
  readFileString: (path, encoding) => flatMap$2(impl.readFile(path), (_) => try_({
29752
30233
  try: () => new TextDecoder(encoding).decode(_),
@@ -29920,7 +30401,7 @@ var WatchBackend = class extends Service()("effect/platform/FileSystem/WatchBack
29920
30401
  * @category type IDs
29921
30402
  * @since 4.0.0
29922
30403
  */
29923
- const TypeId$26 = "~effect/platform/Path";
30404
+ const TypeId$27 = "~effect/platform/Path";
29924
30405
  /**
29925
30406
  * Service tag for accessing the current `Path` implementation.
29926
30407
  *
@@ -30113,7 +30594,7 @@ var ChildProcessSpawner = class extends Service()("effect/process/ChildProcessSp
30113
30594
  *
30114
30595
  * @since 4.0.0
30115
30596
  */
30116
- const TypeId$25 = "~effect/unstable/process/ChildProcess";
30597
+ const TypeId$26 = "~effect/unstable/process/ChildProcess";
30117
30598
  const Proto$12 = {
30118
30599
  .../*#__PURE__*/ Prototype({
30119
30600
  label: "Command",
@@ -30121,7 +30602,7 @@ const Proto$12 = {
30121
30602
  return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this);
30122
30603
  }
30123
30604
  }),
30124
- [TypeId$25]: TypeId$25
30605
+ [TypeId$26]: TypeId$26
30125
30606
  };
30126
30607
  const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$12), {
30127
30608
  _tag: "StandardCommand",
@@ -32223,6 +32704,28 @@ function decodeUnknownEffect$1(schema, options) {
32223
32704
  return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
32224
32705
  }
32225
32706
  /**
32707
+ * Creates a decoder for `unknown` input that returns an `Option` safely.
32708
+ *
32709
+ * **When to use**
32710
+ *
32711
+ * Use when you need a synchronous yes/no decode from untyped input and do not
32712
+ * need schema issue details.
32713
+ *
32714
+ * **Details**
32715
+ *
32716
+ * The returned function produces `Option.some` with the decoded `Type` on success
32717
+ * or `Option.none` on failure, discarding issue details.
32718
+ *
32719
+ * @see {@link decodeOption} for input already typed as the schema's `Encoded` type
32720
+ * @see {@link decodeUnknownResult} for retaining schema issues as data
32721
+ *
32722
+ * @category decoding
32723
+ * @since 3.10.0
32724
+ */
32725
+ function decodeUnknownOption$1(schema, options) {
32726
+ return asOption(decodeUnknownEffect$1(schema, options));
32727
+ }
32728
+ /**
32226
32729
  * Creates an effectful encoder for `unknown` input.
32227
32730
  *
32228
32731
  * **When to use**
@@ -32306,6 +32809,11 @@ function run(ast) {
32306
32809
  function asExit(parser) {
32307
32810
  return (input, options) => runSyncExit(parser(input, options));
32308
32811
  }
32812
+ /** @internal */
32813
+ function asOption(parser) {
32814
+ const parserExit = asExit(parser);
32815
+ return (input, options) => getSuccess(parserExit(input, options));
32816
+ }
32309
32817
  function asSync(parser) {
32310
32818
  return (input, options) => runSync(mapErrorEager(parser(input, options), (issue) => new Error(issue.toString(), { cause: issue })));
32311
32819
  }
@@ -32368,9 +32876,9 @@ const recur$1 = /*#__PURE__*/ memoize((ast) => {
32368
32876
  //#endregion
32369
32877
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/schema/schema.js
32370
32878
  /** @internal */
32371
- const TypeId$24 = "~effect/Schema/Schema";
32879
+ const TypeId$25 = "~effect/Schema/Schema";
32372
32880
  const SchemaProto = {
32373
- [TypeId$24]: TypeId$24,
32881
+ [TypeId$25]: TypeId$25,
32374
32882
  pipe() {
32375
32883
  return pipeArguments(this, arguments);
32376
32884
  },
@@ -32441,7 +32949,7 @@ function makeReorder(getPriority) {
32441
32949
  }
32442
32950
  //#endregion
32443
32951
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Schema.js
32444
- const TypeId$23 = TypeId$24;
32952
+ const TypeId$24 = TypeId$25;
32445
32953
  /**
32446
32954
  * Creates a schema for a **parametric** type (a generic container such as
32447
32955
  * `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
@@ -32597,6 +33105,26 @@ function decodeUnknownEffect(schema, options) {
32597
33105
  */
32598
33106
  const decodeEffect = decodeUnknownEffect;
32599
33107
  /**
33108
+ * Decodes an `unknown` input against a schema, returning an `Option` that is
33109
+ * `Some` with the decoded value on success or `None` on failure.
33110
+ *
33111
+ * **When to use**
33112
+ *
33113
+ * Use when the input type is not statically known and you only need to know
33114
+ * whether decoding succeeded.
33115
+ *
33116
+ * **Details**
33117
+ *
33118
+ * Prefer this over {@link decodeUnknownExit} or {@link decodeUnknownEffect}
33119
+ * when you don't need error details. For typed input use {@link decodeOption}.
33120
+ * Options may be provided either when creating the decoder or when applying it;
33121
+ * application options override creation options.
33122
+ *
33123
+ * @category decoding
33124
+ * @since 3.10.0
33125
+ */
33126
+ const decodeUnknownOption = decodeUnknownOption$1;
33127
+ /**
32600
33128
  * Encodes an `unknown` input against a schema, returning an `Effect` that
32601
33129
  * succeeds with the encoded value or fails with a {@link SchemaError}.
32602
33130
  *
@@ -32694,7 +33222,7 @@ const make$35 = make$36;
32694
33222
  * @since 3.10.0
32695
33223
  */
32696
33224
  function isSchema(u) {
32697
- return hasProperty(u, TypeId$23) && u[TypeId$23] === TypeId$23;
33225
+ return hasProperty(u, TypeId$24) && u[TypeId$24] === TypeId$24;
32698
33226
  }
32699
33227
  /**
32700
33228
  * Creates an exact optional key schema for struct fields. Unlike `optional`,
@@ -33742,7 +34270,7 @@ function makeClass(Inherited, identifier, struct$1, annotations, proto) {
33742
34270
  disableChecks: true
33743
34271
  });
33744
34272
  }
33745
- static [TypeId$23] = TypeId$23;
34273
+ static [TypeId$24] = TypeId$24;
33746
34274
  get [ClassTypeId]() {
33747
34275
  return ClassTypeId;
33748
34276
  }
@@ -34142,11 +34670,11 @@ function onSerializerEnsureArray(ast) {
34142
34670
  *
34143
34671
  * @since 4.0.0
34144
34672
  */
34145
- const TypeId$22 = "~effect/http/Cookies";
34673
+ const TypeId$23 = "~effect/http/Cookies";
34146
34674
  const CookieTypeId = "~effect/http/Cookies/Cookie";
34147
34675
  TaggedError("CookieError");
34148
34676
  const Proto$11 = {
34149
- [TypeId$22]: TypeId$22,
34677
+ [TypeId$23]: TypeId$23,
34150
34678
  ...BaseProto,
34151
34679
  toJSON() {
34152
34680
  return {
@@ -34471,10 +34999,10 @@ const tryDecodeURIComponent = (str) => {
34471
34999
  * @category type IDs
34472
35000
  * @since 4.0.0
34473
35001
  */
34474
- const TypeId$21 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
35002
+ const TypeId$22 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
34475
35003
  const Proto$10 = /*#__PURE__*/ Object.create(null);
34476
35004
  Object.defineProperties(Proto$10, {
34477
- [TypeId$21]: { value: TypeId$21 },
35005
+ [TypeId$22]: { value: TypeId$22 },
34478
35006
  [symbolRedactable]: { value(context) {
34479
35007
  return redact(this, get$9(context, CurrentRedactedNames));
34480
35008
  } },
@@ -34669,7 +35197,7 @@ const CurrentRedactedNames = /*#__PURE__*/ Reference("effect/Headers/CurrentReda
34669
35197
  *
34670
35198
  * @since 4.0.0
34671
35199
  */
34672
- const TypeId$20 = "~effect/http/HttpClientError";
35200
+ const TypeId$21 = "~effect/http/HttpClientError";
34673
35201
  /**
34674
35202
  * Error wrapper for HTTP client failures, exposing the failed request and the optional response through its `reason`.
34675
35203
  *
@@ -34689,7 +35217,7 @@ var HttpClientError = class extends TaggedError("HttpClientError") {
34689
35217
  *
34690
35218
  * @since 4.0.0
34691
35219
  */
34692
- [TypeId$20] = TypeId$20;
35220
+ [TypeId$21] = TypeId$21;
34693
35221
  /**
34694
35222
  * HTTP request associated with the client failure.
34695
35223
  *
@@ -34812,7 +35340,7 @@ var EmptyBodyError = class extends TaggedError("EmptyBodyError") {
34812
35340
  return formatMessage(formatReason(this._tag), this.description, info);
34813
35341
  }
34814
35342
  };
34815
- ErrorClass(TypeId$20)({
35343
+ ErrorClass(TypeId$21)({
34816
35344
  _tag: /*#__PURE__*/ tag("HttpError"),
34817
35345
  kind: /*#__PURE__*/ Literals([
34818
35346
  "EncodeError",
@@ -34864,10 +35392,10 @@ ErrorClass(TypeId$20)({
34864
35392
  *
34865
35393
  * @since 4.0.0
34866
35394
  */
34867
- const TypeId$19 = "~effect/http/UrlParams";
35395
+ const TypeId$20 = "~effect/http/UrlParams";
34868
35396
  const Proto$9 = {
34869
35397
  ...PipeInspectableProto,
34870
- [TypeId$19]: TypeId$19,
35398
+ [TypeId$20]: TypeId$20,
34871
35399
  [Symbol.iterator]() {
34872
35400
  return this.params[Symbol.iterator]();
34873
35401
  },
@@ -35065,12 +35593,12 @@ const baseUrl = () => {
35065
35593
  *
35066
35594
  * @since 4.0.0
35067
35595
  */
35068
- const TypeId$18 = "~effect/http/HttpBody";
35596
+ const TypeId$19 = "~effect/http/HttpBody";
35069
35597
  TaggedError("HttpBodyError");
35070
35598
  var Proto$8 = class {
35071
- [TypeId$18];
35599
+ [TypeId$19];
35072
35600
  constructor() {
35073
- this[TypeId$18] = TypeId$18;
35601
+ this[TypeId$19] = TypeId$19;
35074
35602
  }
35075
35603
  [NodeInspectSymbol]() {
35076
35604
  return this.toJSON();
@@ -35297,9 +35825,9 @@ const allShort = [
35297
35825
  ];
35298
35826
  //#endregion
35299
35827
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpClientRequest.js
35300
- const TypeId$17 = "~effect/http/HttpClientRequest";
35828
+ const TypeId$18 = "~effect/http/HttpClientRequest";
35301
35829
  const Proto$7 = {
35302
- [TypeId$17]: TypeId$17,
35830
+ [TypeId$18]: TypeId$18,
35303
35831
  ...BaseProto,
35304
35832
  toJSON() {
35305
35833
  return {
@@ -35482,7 +36010,7 @@ const setBody$1 = /*#__PURE__*/ dual(2, (self, body) => {
35482
36010
  * @category type IDs
35483
36011
  * @since 4.0.0
35484
36012
  */
35485
- const TypeId$16 = "~effect/http/HttpIncomingMessage";
36013
+ const TypeId$17 = "~effect/http/HttpIncomingMessage";
35486
36014
  /**
35487
36015
  * Context reference for the optional maximum size allowed when reading an incoming message body.
35488
36016
  *
@@ -35560,7 +36088,7 @@ const inspect = (self, that) => {
35560
36088
  * @category type IDs
35561
36089
  * @since 4.0.0
35562
36090
  */
35563
- const TypeId$15 = "~effect/http/HttpClientResponse";
36091
+ const TypeId$16 = "~effect/http/HttpClientResponse";
35564
36092
  /**
35565
36093
  * Wraps a Web `Response` and its original `HttpClientRequest` as an `HttpClientResponse`.
35566
36094
  *
@@ -35569,16 +36097,16 @@ const TypeId$15 = "~effect/http/HttpClientResponse";
35569
36097
  */
35570
36098
  const fromWeb$1 = (request, source) => new WebHttpClientResponse(request, source);
35571
36099
  var WebHttpClientResponse = class extends Class$2 {
36100
+ [TypeId$17];
35572
36101
  [TypeId$16];
35573
- [TypeId$15];
35574
36102
  request;
35575
36103
  source;
35576
36104
  constructor(request, source) {
35577
36105
  super();
35578
36106
  this.request = request;
35579
36107
  this.source = source;
36108
+ this[TypeId$17] = TypeId$17;
35580
36109
  this[TypeId$16] = TypeId$16;
35581
- this[TypeId$15] = TypeId$15;
35582
36110
  }
35583
36111
  toJSON() {
35584
36112
  return inspect(this, {
@@ -35820,7 +36348,7 @@ const w3c = (headers) => {
35820
36348
  };
35821
36349
  //#endregion
35822
36350
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpClient.js
35823
- const TypeId$14 = "~effect/http/HttpClient";
36351
+ const TypeId$15 = "~effect/http/HttpClient";
35824
36352
  /**
35825
36353
  * Service tag for the default outgoing HTTP client service.
35826
36354
  *
@@ -35860,7 +36388,7 @@ const makeWith = (postprocess, preprocess) => {
35860
36388
  return self;
35861
36389
  };
35862
36390
  const Proto$6 = {
35863
- [TypeId$14]: TypeId$14,
36391
+ [TypeId$15]: TypeId$15,
35864
36392
  pipe() {
35865
36393
  return pipeArguments(this, arguments);
35866
36394
  },
@@ -35997,8 +36525,8 @@ var InterruptibleResponse = class {
35997
36525
  this.original = original;
35998
36526
  this.controller = controller;
35999
36527
  }
36000
- [TypeId$15] = TypeId$15;
36001
36528
  [TypeId$16] = TypeId$16;
36529
+ [TypeId$17] = TypeId$17;
36002
36530
  applyInterrupt(effect) {
36003
36531
  return suspend$2(() => {
36004
36532
  responseRegistry.unregister(this.original);
@@ -36682,14 +37210,14 @@ const make$29 = make$30;
36682
37210
  const ignore = "~effect/ErrorReporter/ignore";
36683
37211
  //#endregion
36684
37212
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpServerResponse.js
36685
- const TypeId$13 = "~effect/http/HttpServerResponse";
37213
+ const TypeId$14 = "~effect/http/HttpServerResponse";
36686
37214
  /**
36687
37215
  * Returns `true` when the supplied value is an `HttpServerResponse`.
36688
37216
  *
36689
37217
  * @category guards
36690
37218
  * @since 4.0.0
36691
37219
  */
36692
- const isHttpServerResponse = (u) => hasProperty(u, TypeId$13);
37220
+ const isHttpServerResponse = (u) => hasProperty(u, TypeId$14);
36693
37221
  /**
36694
37222
  * Creates an empty HTTP response.
36695
37223
  *
@@ -36822,7 +37350,7 @@ const setBody = /*#__PURE__*/ dual(2, (self, body) => makeResponse({
36822
37350
  }));
36823
37351
  const Proto$5 = {
36824
37352
  ...PipeInspectableProto,
36825
- [TypeId$13]: TypeId$13,
37353
+ [TypeId$14]: TypeId$14,
36826
37354
  [ignore]: true,
36827
37355
  toJSON() {
36828
37356
  return {
@@ -37020,7 +37548,7 @@ const toResponseOrElseDefect = (u, orElse) => {
37020
37548
  *
37021
37549
  * @since 4.0.0
37022
37550
  */
37023
- const TypeId$12 = "~effect/http/HttpServerError";
37551
+ const TypeId$13 = "~effect/http/HttpServerError";
37024
37552
  /**
37025
37553
  * Tagged error for failures that occur while handling an HTTP server request.
37026
37554
  *
@@ -37041,7 +37569,7 @@ var HttpServerError = class extends TaggedError("HttpServerError") {
37041
37569
  });
37042
37570
  else super(props);
37043
37571
  }
37044
- [TypeId$12] = TypeId$12;
37572
+ [TypeId$13] = TypeId$13;
37045
37573
  stack = `${this.name}: ${this.message}`;
37046
37574
  get request() {
37047
37575
  return this.reason.request;
@@ -37317,7 +37845,7 @@ const exitResponse = (exit) => {
37317
37845
  *
37318
37846
  * @since 2.0.0
37319
37847
  */
37320
- const TypeId$11 = "~effect/FiberSet";
37848
+ const TypeId$12 = "~effect/FiberSet";
37321
37849
  /**
37322
37850
  * Checks whether a value is a FiberSet.
37323
37851
  *
@@ -37337,9 +37865,9 @@ const TypeId$11 = "~effect/FiberSet";
37337
37865
  * @category refinements
37338
37866
  * @since 2.0.0
37339
37867
  */
37340
- const isFiberSet = (u) => hasProperty(u, TypeId$11);
37868
+ const isFiberSet = (u) => hasProperty(u, TypeId$12);
37341
37869
  const Proto$4 = {
37342
- [TypeId$11]: TypeId$11,
37870
+ [TypeId$12]: TypeId$12,
37343
37871
  [Symbol.iterator]() {
37344
37872
  if (this.state._tag === "Closed") return empty$14();
37345
37873
  return this.state.backing[Symbol.iterator]();
@@ -37518,7 +38046,7 @@ const join = (self) => _await(self.deferred);
37518
38046
  * @category type IDs
37519
38047
  * @since 4.0.0
37520
38048
  */
37521
- const TypeId$10 = "~effect/socket/Socket";
38049
+ const TypeId$11 = "~effect/socket/Socket";
37522
38050
  /**
37523
38051
  * Service tag for bidirectional socket transports.
37524
38052
  *
@@ -37539,7 +38067,7 @@ const Socket = /*#__PURE__*/ Service("effect/socket/Socket");
37539
38067
  * @since 4.0.0
37540
38068
  */
37541
38069
  const make$27 = (options) => Socket.of({
37542
- [TypeId$10]: TypeId$10,
38070
+ [TypeId$11]: TypeId$11,
37543
38071
  runRaw: options.runRaw,
37544
38072
  run: options.run ?? ((handler, opts) => options.runRaw((data) => typeof data === "string" ? handler(encoder.encode(data)) : data instanceof Uint8Array ? handler(data) : handler(new Uint8Array(data)), opts)),
37545
38073
  runString: options.runString ?? (options.run ? (handler, opts) => options.run((data) => handler(decoder$1.decode(data)), opts) : (handler, opts) => options.runRaw((data) => typeof data === "string" ? handler(data) : data instanceof Uint8Array ? handler(decoder$1.decode(data)) : handler(decoder$1.decode(new Uint8Array(data))), opts)),
@@ -38786,7 +39314,7 @@ const decodeField = decodeField$1;
38786
39314
  * @category type IDs
38787
39315
  * @since 4.0.0
38788
39316
  */
38789
- const TypeId$9 = "~effect/http/Multipart";
39317
+ const TypeId$10 = "~effect/http/Multipart";
38790
39318
  const MultipartErrorTypeId = "~effect/http/Multipart/MultipartError";
38791
39319
  /**
38792
39320
  * Error reason carried by a `MultipartError`.
@@ -38861,10 +39389,10 @@ const makeConfig = (headers) => withFiber((fiber) => {
38861
39389
  });
38862
39390
  });
38863
39391
  var PartBase$1 = class extends Class$2 {
38864
- [TypeId$9];
39392
+ [TypeId$10];
38865
39393
  constructor() {
38866
39394
  super();
38867
- this[TypeId$9] = TypeId$9;
39395
+ this[TypeId$10] = TypeId$10;
38868
39396
  }
38869
39397
  };
38870
39398
  const defaultWriteFile = (path, file) => flatMap$2(FileSystem, (fs) => mapError$2(run$1(file.content, fs.sink(path)), (cause) => MultipartError.fromReason("InternalError", cause)));
@@ -38981,7 +39509,7 @@ const FieldMimeTypes = /*#__PURE__*/ Reference("effect/http/Multipart/FieldMimeT
38981
39509
  * @category type IDs
38982
39510
  * @since 4.0.0
38983
39511
  */
38984
- const TypeId$8 = "~effect/http/HttpServerRequest";
39512
+ const TypeId$9 = "~effect/http/HttpServerRequest";
38985
39513
  /**
38986
39514
  * Service tag for the active server-side HTTP request.
38987
39515
  *
@@ -39637,7 +40165,7 @@ const withLogAddress = (layer) => effectDiscard(logAddress).pipe(provideMerge(la
39637
40165
  *
39638
40166
  * @since 4.0.0
39639
40167
  */
39640
- const TypeId$7 = "~effect/http/HttpRouter";
40168
+ const TypeId$8 = "~effect/http/HttpRouter";
39641
40169
  /**
39642
40170
  * Service tag for the HTTP router used while constructing an HTTP application.
39643
40171
  * Route and middleware layers require this service to register themselves with
@@ -39684,7 +40212,7 @@ const make$19 = /*#__PURE__*/ gen(function* () {
39684
40212
  return void_$1;
39685
40213
  });
39686
40214
  return HttpRouter.of({
39687
- [TypeId$7]: TypeId$7,
40215
+ [TypeId$8]: TypeId$8,
39688
40216
  prefixed(prefix) {
39689
40217
  return HttpRouter.of({
39690
40218
  ...this,
@@ -40139,7 +40667,7 @@ var ClientAbort = class extends Service()("effect/rpc/RpcSchema/ClientAbort") {
40139
40667
  };
40140
40668
  //#endregion
40141
40669
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/rpc/Rpc.js
40142
- const TypeId$6 = "~effect/rpc/Rpc";
40670
+ const TypeId$7 = "~effect/rpc/Rpc";
40143
40671
  /**
40144
40672
  * Represents server-side metadata for the client associated with an RPC request.
40145
40673
  *
@@ -40169,7 +40697,7 @@ var ServerClient = class {
40169
40697
  }
40170
40698
  };
40171
40699
  const Proto$3 = {
40172
- [TypeId$6]: TypeId$6,
40700
+ [TypeId$7]: TypeId$7,
40173
40701
  pipe() {
40174
40702
  return pipeArguments(this, arguments);
40175
40703
  },
@@ -42912,7 +43440,7 @@ const withRun = () => (f) => suspend$2(() => {
42912
43440
  * @category type IDs
42913
43441
  * @since 4.0.0
42914
43442
  */
42915
- const TypeId$5 = "~effect/Stdio";
43443
+ const TypeId$6 = "~effect/Stdio";
42916
43444
  /**
42917
43445
  * Service tag for process standard I/O.
42918
43446
  *
@@ -42927,7 +43455,7 @@ const TypeId$5 = "~effect/Stdio";
42927
43455
  * @category services
42928
43456
  * @since 4.0.0
42929
43457
  */
42930
- const Stdio = /*#__PURE__*/ Service(TypeId$5);
43458
+ const Stdio = /*#__PURE__*/ Service(TypeId$6);
42931
43459
  /**
42932
43460
  * Creates a `Stdio` service implementation from the provided fields and
42933
43461
  * attaches the `Stdio` type identifier.
@@ -42949,7 +43477,7 @@ const Stdio = /*#__PURE__*/ Service(TypeId$5);
42949
43477
  * @since 4.0.0
42950
43478
  */
42951
43479
  const make$17 = (options) => ({
42952
- [TypeId$5]: TypeId$5,
43480
+ [TypeId$6]: TypeId$6,
42953
43481
  ...options
42954
43482
  });
42955
43483
  //#endregion
@@ -43247,7 +43775,7 @@ const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
43247
43775
  }).pipe(provide$3(scope));
43248
43776
  yield* forkChild(whileLoop({
43249
43777
  while: constTrue,
43250
- body: constant(flatMap$2(take$1(disconnects), (clientId) => {
43778
+ body: constant(flatMap$2(take$2(disconnects), (clientId) => {
43251
43779
  clients.delete(clientId);
43252
43780
  return server.disconnect(clientId);
43253
43781
  })),
@@ -44141,7 +44669,7 @@ function trieNodeAt(root, path) {
44141
44669
  }
44142
44670
  //#endregion
44143
44671
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Config.js
44144
- const TypeId$4 = "~effect/Config";
44672
+ const TypeId$5 = "~effect/Config";
44145
44673
  /**
44146
44674
  * Returns `true` if `u` is a `Config` instance.
44147
44675
  *
@@ -44162,7 +44690,7 @@ const TypeId$4 = "~effect/Config";
44162
44690
  * @category guards
44163
44691
  * @since 2.0.0
44164
44692
  */
44165
- const isConfig = (u) => hasProperty(u, TypeId$4);
44693
+ const isConfig = (u) => hasProperty(u, TypeId$5);
44166
44694
  /**
44167
44695
  * Represents the error type produced when config loading or validation fails.
44168
44696
  *
@@ -44206,7 +44734,7 @@ const Proto$1 = {
44206
44734
  return this.parse(fiber.getRef(ConfigProvider));
44207
44735
  }
44208
44736
  }),
44209
- [TypeId$4]: TypeId$4,
44737
+ [TypeId$5]: TypeId$5,
44210
44738
  toJSON() {
44211
44739
  return { _id: "Config" };
44212
44740
  }
@@ -44315,7 +44843,7 @@ const map = /*#__PURE__*/ dual(2, (self, f) => {
44315
44843
  * @category combinators
44316
44844
  * @since 2.0.0
44317
44845
  */
44318
- const orElse = /*#__PURE__*/ dual(2, (self, that) => {
44846
+ const orElse$2 = /*#__PURE__*/ dual(2, (self, that) => {
44319
44847
  return make$13((provider) => catch_$2(self.parse(provider), (error) => that(error).parse(provider)));
44320
44848
  });
44321
44849
  function isMissingDataOnly(issue) {
@@ -44369,7 +44897,7 @@ function isMissingDataOnly(issue) {
44369
44897
  * @since 2.0.0
44370
44898
  */
44371
44899
  const withDefault = /*#__PURE__*/ dual(2, (self, defaultValue) => {
44372
- return orElse(self, (err) => {
44900
+ return orElse$2(self, (err) => {
44373
44901
  if (isSchemaError(err.cause)) {
44374
44902
  const issue = err.cause.issue;
44375
44903
  if (isMissingDataOnly(issue)) return succeed(defaultValue);
@@ -48724,13 +49252,13 @@ var NodeHttpIncomingMessage = class extends Class$2 {
48724
49252
  *
48725
49253
  * @since 4.0.0
48726
49254
  */
48727
- [TypeId$16];
49255
+ [TypeId$17];
48728
49256
  source;
48729
49257
  onError;
48730
49258
  remoteAddressOverride;
48731
49259
  constructor(source, onError, remoteAddressOverride) {
48732
49260
  super();
48733
- this[TypeId$16] = TypeId$16;
49261
+ this[TypeId$17] = TypeId$17;
48734
49262
  this.source = source;
48735
49263
  this.onError = onError;
48736
49264
  this.remoteAddressOverride = remoteAddressOverride;
@@ -49118,10 +49646,10 @@ const persisted = (source, headers) => toPersisted(stream(source, headers), (pat
49118
49646
  }));
49119
49647
  const convertPart = (part) => part._tag === "Field" ? new FieldImpl(part.info, part.value) : new FileImpl(part);
49120
49648
  var PartBase = class extends Class$2 {
49121
- [TypeId$9];
49649
+ [TypeId$10];
49122
49650
  constructor() {
49123
49651
  super();
49124
- this[TypeId$9] = TypeId$9;
49652
+ this[TypeId$10] = TypeId$10;
49125
49653
  }
49126
49654
  };
49127
49655
  var FieldImpl = class extends PartBase {
@@ -49243,7 +49771,7 @@ function convertError(cause) {
49243
49771
  *
49244
49772
  * @since 4.0.0
49245
49773
  */
49246
- const TypeId$3 = "~effect/platform/Crypto";
49774
+ const TypeId$4 = "~effect/platform/Crypto";
49247
49775
  /**
49248
49776
  * Service tag for platform cryptography.
49249
49777
  *
@@ -49310,7 +49838,7 @@ const make$10 = (impl) => {
49310
49838
  };
49311
49839
  const nextIntUnsafe = () => Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;
49312
49840
  return Crypto.of({
49313
- [TypeId$3]: TypeId$3,
49841
+ [TypeId$4]: TypeId$4,
49314
49842
  randomBytes,
49315
49843
  nextDoubleUnsafe,
49316
49844
  nextIntUnsafe,
@@ -49530,7 +50058,7 @@ const toFileUrl = (path) => try_({
49530
50058
  * @since 4.0.0
49531
50059
  */
49532
50060
  const layer$11 = /* @__PURE__ */ succeed$4(Path$1)({
49533
- [TypeId$26]: TypeId$26,
50061
+ [TypeId$27]: TypeId$27,
49534
50062
  ...Path,
49535
50063
  fromFileUrl,
49536
50064
  toFileUrl
@@ -49606,7 +50134,7 @@ const layer$9 = /* @__PURE__ */ succeed$4(Stdio, /*#__PURE__*/ make$17({
49606
50134
  }));
49607
50135
  //#endregion
49608
50136
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Terminal.js
49609
- const TypeId$2 = "~effect/platform/Terminal";
50137
+ const TypeId$3 = "~effect/platform/Terminal";
49610
50138
  ErrorClass("QuitError")({ _tag: /*#__PURE__*/ tag("QuitError") });
49611
50139
  /**
49612
50140
  * Service tag for command-line input and output services.
@@ -49640,7 +50168,7 @@ const Terminal$1 = /*#__PURE__*/ Service("effect/platform/Terminal");
49640
50168
  */
49641
50169
  const make$8 = (impl) => Terminal$1.of({
49642
50170
  ...impl,
49643
- [TypeId$2]: TypeId$2
50171
+ [TypeId$3]: TypeId$3
49644
50172
  });
49645
50173
  /**
49646
50174
  * Provides the default process-backed `Terminal` service, ending key input on
@@ -49880,7 +50408,7 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
49880
50408
  });
49881
50409
  };
49882
50410
  var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage {
49883
- [TypeId$8];
50411
+ [TypeId$9];
49884
50412
  response;
49885
50413
  upgradeEffect;
49886
50414
  url;
@@ -49890,7 +50418,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
49890
50418
  request: this,
49891
50419
  cause
49892
50420
  }) }), remoteAddressOverride);
49893
- this[TypeId$8] = TypeId$8;
50421
+ this[TypeId$9] = TypeId$9;
49894
50422
  this.response = response;
49895
50423
  this.upgradeEffect = upgradeEffect;
49896
50424
  this.url = url;
@@ -50606,6 +51134,280 @@ const layer$5 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntra
50606
51134
  for (const logger of loggers) currentLoggers.add(isEffect$1(logger) ? yield* logger : logger);
50607
51135
  return currentLoggers;
50608
51136
  })));
51137
+ const ValueMatcherProto = {
51138
+ ["~effect/match/Match/Matcher"]: {
51139
+ _input: identity,
51140
+ _filters: identity,
51141
+ _result: identity,
51142
+ _return: identity
51143
+ },
51144
+ _tag: "ValueMatcher",
51145
+ add(_case) {
51146
+ if (isSuccess$1(this.value)) return this;
51147
+ if (_case._tag === "When" && _case.guard(this.provided) === true) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51148
+ else if (_case._tag === "Not" && _case.guard(this.provided) === false) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51149
+ return this;
51150
+ },
51151
+ pipe() {
51152
+ return pipeArguments(this, arguments);
51153
+ }
51154
+ };
51155
+ function makeValueMatcher(provided, value) {
51156
+ const matcher = Object.create(ValueMatcherProto);
51157
+ matcher.provided = provided;
51158
+ matcher.value = value;
51159
+ return matcher;
51160
+ }
51161
+ const makeWhen = (guard, evaluate) => ({
51162
+ _tag: "When",
51163
+ guard,
51164
+ evaluate
51165
+ });
51166
+ const makePredicate = (pattern) => {
51167
+ if (typeof pattern === "function") return pattern;
51168
+ else if (Array.isArray(pattern)) {
51169
+ const predicates = pattern.map(makePredicate);
51170
+ const len = predicates.length;
51171
+ return (u) => {
51172
+ if (!Array.isArray(u)) return false;
51173
+ for (let i = 0; i < len; i++) if (predicates[i](u[i]) === false) return false;
51174
+ return true;
51175
+ };
51176
+ } else if (pattern !== null && typeof pattern === "object") {
51177
+ const keysAndPredicates = Object.entries(pattern).map(([k, p]) => [k, makePredicate(p)]);
51178
+ const len = keysAndPredicates.length;
51179
+ return (u) => {
51180
+ if (typeof u !== "object" || u === null) return false;
51181
+ for (let i = 0; i < len; i++) {
51182
+ const [key, predicate] = keysAndPredicates[i];
51183
+ if (!(key in u) || predicate(u[key]) === false) return false;
51184
+ }
51185
+ return true;
51186
+ };
51187
+ }
51188
+ return (u) => u === pattern;
51189
+ };
51190
+ /** @internal */
51191
+ const value$1 = (i) => makeValueMatcher(i, fail$7(i));
51192
+ /** @internal */
51193
+ const when$1 = (pattern, f) => (self) => self.add(makeWhen(makePredicate(pattern), f));
51194
+ /** @internal */
51195
+ const orElse$1 = (f) => (self) => {
51196
+ const toResult = result(self);
51197
+ if (isResult(toResult)) return toResult._tag === "Success" ? toResult.success : f(toResult.failure);
51198
+ return (input) => {
51199
+ const a = toResult(input);
51200
+ return isSuccess$1(a) ? a.success : f(a.failure);
51201
+ };
51202
+ };
51203
+ /** @internal */
51204
+ const result = (self) => {
51205
+ if (self._tag === "ValueMatcher") return self.value;
51206
+ const len = self.cases.length;
51207
+ if (len === 1) {
51208
+ const _case = self.cases[0];
51209
+ return (input) => {
51210
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51211
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51212
+ return fail$7(input);
51213
+ };
51214
+ }
51215
+ return (input) => {
51216
+ for (let i = 0; i < len; i++) {
51217
+ const _case = self.cases[i];
51218
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51219
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51220
+ }
51221
+ return fail$7(input);
51222
+ };
51223
+ };
51224
+ //#endregion
51225
+ //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Match.js
51226
+ /**
51227
+ * Pattern matching for TypeScript values, predicates, and tagged unions.
51228
+ *
51229
+ * `Match` turns branching logic into a matcher that is built from ordered
51230
+ * cases and finished with an explicit finalizer. Use `Match.type` to define a
51231
+ * reusable matcher for a type, or `Match.value` to classify one value
51232
+ * immediately. Cases can match literal values, predicates, object patterns,
51233
+ * discriminators, tags, or negated patterns.
51234
+ *
51235
+ * **Mental model**
51236
+ *
51237
+ * A matcher checks cases in the order they are added and evaluates the handler
51238
+ * for the first match. Type matchers produce a function that can be reused with
51239
+ * different inputs, while value matchers already contain the input value. As
51240
+ * cases are added, the type system tracks which inputs remain unmatched, so
51241
+ * `Match.exhaustive` is only available when every remaining case has been
51242
+ * handled.
51243
+ *
51244
+ * **Common tasks**
51245
+ *
51246
+ * - Use `Match.type<Union>()` when a branch table should be reusable and
51247
+ * exhaustiveness-checked.
51248
+ * - Use `Match.value(value)` when a single value should be matched immediately.
51249
+ * - Use `Match.tag`, `Match.tags`, or `Match.discriminator` for discriminated
51250
+ * unions and domain objects with tag fields.
51251
+ * - Use `Match.orElse`, `Match.option`, or `Match.result` when unmatched input
51252
+ * should be handled explicitly instead of requiring full exhaustiveness.
51253
+ *
51254
+ * **Example** (Matching a tagged union)
51255
+ *
51256
+ * ```ts
51257
+ * import { Match } from "effect"
51258
+ *
51259
+ * type Event =
51260
+ * | { readonly _tag: "UserCreated"; readonly id: string }
51261
+ * | { readonly _tag: "UserDeleted"; readonly id: string }
51262
+ *
51263
+ * const describe = Match.type<Event>().pipe(
51264
+ * Match.tag("UserCreated", (event) => `created ${event.id}`),
51265
+ * Match.tag("UserDeleted", (event) => `deleted ${event.id}`),
51266
+ * Match.exhaustive
51267
+ * )
51268
+ * ```
51269
+ *
51270
+ * @since 4.0.0
51271
+ */
51272
+ /**
51273
+ * Creates a matcher from a specific value.
51274
+ *
51275
+ * **When to use**
51276
+ *
51277
+ * Use to match one concrete input immediately.
51278
+ *
51279
+ * **Details**
51280
+ *
51281
+ * This function allows you to define a `Matcher` directly from a given value,
51282
+ * rather than from a type. This is useful when working with known values,
51283
+ * enabling structured pattern matching on objects, primitives, or any data
51284
+ * structure.
51285
+ *
51286
+ * Once the matcher is created, you can use pattern-matching functions like
51287
+ * {@link when} to define how different cases should be handled.
51288
+ *
51289
+ * **Example** (Matching an Object by Property)
51290
+ *
51291
+ * ```ts
51292
+ * import { Match } from "effect"
51293
+ *
51294
+ * const input = { name: "John", age: 30 }
51295
+ *
51296
+ * // Create a matcher for the specific object
51297
+ * const result = Match.value(input).pipe(
51298
+ * // Match when the 'name' property is "John"
51299
+ * Match.when(
51300
+ * { name: "John" },
51301
+ * (user) => `${user.name} is ${user.age} years old`
51302
+ * ),
51303
+ * // Provide a fallback if no match is found
51304
+ * Match.orElse(() => "Oh, not John")
51305
+ * )
51306
+ *
51307
+ * console.log(result)
51308
+ * // Output: "John is 30 years old"
51309
+ * ```
51310
+ *
51311
+ * @see {@link type} for creating a matcher from a specific type.
51312
+ *
51313
+ * @category constructors
51314
+ * @since 4.0.0
51315
+ */
51316
+ const value = value$1;
51317
+ /**
51318
+ * Defines a condition for matching values.
51319
+ *
51320
+ * **When to use**
51321
+ *
51322
+ * Use to add one positive pattern case to a `Match.type` or `Match.value`
51323
+ * pipeline when a direct value, predicate, or structured object pattern should
51324
+ * run a handler for matching input.
51325
+ *
51326
+ * **Details**
51327
+ *
51328
+ * Supports both direct value comparisons and predicate functions. If the
51329
+ * pattern matches, the associated function is executed and the matched input is
51330
+ * removed from the remaining cases tracked by the matcher.
51331
+ *
51332
+ * **Example** (Matching with Values and Predicates)
51333
+ *
51334
+ * ```ts
51335
+ * import { Match } from "effect"
51336
+ *
51337
+ * // Create a matcher for objects with an "age" property
51338
+ * const match = Match.type<{ age: number }>().pipe(
51339
+ * // Match when age is greater than 18
51340
+ * Match.when(
51341
+ * { age: (age: number) => age > 18 },
51342
+ * (user: { age: number }) => `Age: ${user.age}`
51343
+ * ),
51344
+ * // Match when age is exactly 18
51345
+ * Match.when({ age: 18 }, () => "You can vote"),
51346
+ * // Fallback case for all other ages
51347
+ * Match.orElse((user: { age: number }) => `${user.age} is too young`)
51348
+ * )
51349
+ *
51350
+ * console.log(match({ age: 20 }))
51351
+ * // Output: "Age: 20"
51352
+ *
51353
+ * console.log(match({ age: 18 }))
51354
+ * // Output: "You can vote"
51355
+ *
51356
+ * console.log(match({ age: 4 }))
51357
+ * // Output: "4 is too young"
51358
+ * ```
51359
+ *
51360
+ * @see {@link whenOr} for handling any one of several patterns with the same handler
51361
+ * @see {@link whenAnd} for requiring all provided patterns to match before running a handler
51362
+ * @see {@link not} for handling inputs that do not match a pattern
51363
+ * @see {@link orElse} for providing a fallback when no pattern case matches
51364
+ *
51365
+ * @category Defining patterns
51366
+ * @since 4.0.0
51367
+ */
51368
+ const when = when$1;
51369
+ /**
51370
+ * Provides a fallback value when no patterns match.
51371
+ *
51372
+ * **When to use**
51373
+ *
51374
+ * Use to finalize a matcher with a fallback for unmatched input.
51375
+ *
51376
+ * **Details**
51377
+ *
51378
+ * This function ensures that a matcher always returns a valid result, even if
51379
+ * no defined patterns match. It acts as a default case, similar to the
51380
+ * `default` clause in a `switch` statement or the final `else` in an `if-else`
51381
+ * chain.
51382
+ *
51383
+ * **Example** (Providing a Default Value When No Patterns Match)
51384
+ *
51385
+ * ```ts
51386
+ * import { Match } from "effect"
51387
+ *
51388
+ * // Create a matcher for string or number values
51389
+ * const match = Match.type<string | number>().pipe(
51390
+ * // Match when the value is "a"
51391
+ * Match.when("a", () => "ok"),
51392
+ * // Fallback when no patterns match
51393
+ * Match.orElse(() => "fallback")
51394
+ * )
51395
+ *
51396
+ * console.log(match("a"))
51397
+ * // Output: "ok"
51398
+ *
51399
+ * console.log(match("b"))
51400
+ * // Output: "fallback"
51401
+ * ```
51402
+ *
51403
+ * @see {@link option} for finalizing unmatched input as `Option.none`
51404
+ * @see {@link result} for returning unmatched input as a `Result` failure
51405
+ * @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible
51406
+ *
51407
+ * @category completion
51408
+ * @since 4.0.0
51409
+ */
51410
+ const orElse = orElse$1;
50609
51411
  //#endregion
50610
51412
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Random.js
50611
51413
  /**
@@ -51490,23 +52292,11 @@ var TerminalError = class extends TaggedErrorClass()("TerminalError", {
51490
52292
  cause: optional(Defect),
51491
52293
  message: optional(String$1)
51492
52294
  }) {};
51493
- const TerminalEvent = Union([Struct({
52295
+ const TerminalEvent = Struct({
51494
52296
  data: String$1,
52297
+ sequence: Number$1,
51495
52298
  type: Literal("data")
51496
- }), Struct({ type: Literal("reset") })]);
51497
- Union([
51498
- Struct({
51499
- data: String$1,
51500
- type: Literal("write")
51501
- }),
51502
- Struct({
51503
- cols: Number$1,
51504
- rows: Number$1,
51505
- type: Literal("resize")
51506
- }),
51507
- Struct({ type: Literal("restart") }),
51508
- Struct({ type: Literal("stop") })
51509
- ]);
52299
+ });
51510
52300
  const TerminalState = Struct({
51511
52301
  runId: Number$1,
51512
52302
  state: Literals([
@@ -51514,7 +52304,6 @@ const TerminalState = Struct({
51514
52304
  "starting",
51515
52305
  "running",
51516
52306
  "waiting",
51517
- "needs_input",
51518
52307
  "stopped",
51519
52308
  "exited",
51520
52309
  "failed"
@@ -51522,15 +52311,12 @@ const TerminalState = Struct({
51522
52311
  title: String$1
51523
52312
  });
51524
52313
  function terminalStateActive(state) {
51525
- return state === "idle" || state === "starting" || state === "running" || state === "waiting" || state === "needs_input";
52314
+ return state === "idle" || state === "starting" || state === "running" || state === "waiting";
51526
52315
  }
51527
52316
  const TerminalUpdate = Union([Struct({
51528
52317
  state: TerminalState,
51529
52318
  type: Literal("state")
51530
- }), Struct({
51531
- event: TerminalEvent,
51532
- type: Literal("event")
51533
- })]);
52319
+ }), TerminalEvent]);
51534
52320
  //#endregion
51535
52321
  //#region src/rpcs/contracts.ts
51536
52322
  const TerminalPayload = Struct({
@@ -51740,8 +52526,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51740
52526
  data: String$1,
51741
52527
  env: optional(Record(String$1, String$1)),
51742
52528
  sessionId: optional(String$1)
51743
- }),
51744
- success: TerminalState
52529
+ })
51745
52530
  }), make$18("terminal.resize", {
51746
52531
  error: TerminalError,
51747
52532
  payload: Struct({
@@ -51752,12 +52537,16 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51752
52537
  env: optional(Record(String$1, String$1)),
51753
52538
  rows: Number$1,
51754
52539
  sessionId: optional(String$1)
51755
- }),
51756
- success: TerminalState
52540
+ })
51757
52541
  }), make$18("terminal.restart", {
51758
52542
  error: TerminalError,
51759
52543
  payload: TerminalPayload,
51760
52544
  success: TerminalState
52545
+ }), make$18("terminal.state.watch", {
52546
+ error: TerminalError,
52547
+ payload: TerminalPayload,
52548
+ stream: true,
52549
+ success: TerminalState
51761
52550
  }), make$18("terminal.stop", {
51762
52551
  error: TerminalError,
51763
52552
  payload: TerminalPayload,
@@ -52449,6 +53238,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52449
53238
  };
52450
53239
  //#endregion
52451
53240
  //#region ../../packages/portless/src/lib/utils.ts
53241
+ const PackageJson = Struct({ scripts: optional(Record(String$1, String$1)) });
52452
53242
  function command(script, port) {
52453
53243
  return make$40("vp", [
52454
53244
  "run",
@@ -52474,23 +53264,23 @@ const discover = fnUntraced(function* (cwd, input) {
52474
53264
  "package.json",
52475
53265
  "**/package.json"
52476
53266
  ], { cwd }));
52477
- return yield* pipe(pipe(split$1("\n")(output), filter$2((path) => path === "package.json" || endsWith("/package.json")(path))), map$7((packagePath) => pipe(pipe(fs.readFileString(path.join(cwd, packagePath)), map$4((source) => ({
52478
- packageJson: JSON.parse(source),
52479
- packagePath
52480
- })), catch_$2(() => succeed$3(void 0))), flatMap$2((result) => {
52481
- if (result === void 0) return succeed$3([]);
52482
- const packageDirectory = result.packagePath === "package.json" ? cwd : path.join(cwd, path.dirname(result.packagePath));
53267
+ 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_({
53268
+ catch: (error) => error,
53269
+ try: () => pipe(JSON.parse(source), decodeUnknownOption(PackageJson))
53270
+ })), catch_$2(() => succeed$3(none())), flatMap$2((packageJson) => {
53271
+ if (isNone(packageJson)) return succeed$3([]);
53272
+ const packageDirectory = packagePath === "package.json" ? cwd : path.join(cwd, path.dirname(packagePath));
52483
53273
  const folder = path.basename(packageDirectory);
52484
- const scriptEntries = pipe(Object.entries(result.packageJson.scripts ?? {}), filter$2((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
52485
- const packageOrigin = `http://${[
53274
+ const scriptEntries = pipe(Object.entries(packageJson.value.scripts ?? {}), filter$2((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
53275
+ const packageOrigin = input.origin([
52486
53276
  folder,
52487
53277
  path.basename(cwd),
52488
53278
  "localhost"
52489
- ].join(".")}:${input.proxyPort}`;
53279
+ ].join("."));
52490
53280
  return pipe(scriptEntries, map$7((entry) => {
52491
53281
  const name = entry[0];
52492
53282
  const scriptCommand = entry[1];
52493
- return map$4(input.port(`${result.packagePath}:${name}`), (port) => {
53283
+ return map$4(input.port(`${packagePath}:${name}`), (port) => {
52494
53284
  const service = /^dev:(.+)$/u.exec(name)?.[1] ?? "dev";
52495
53285
  const host = [
52496
53286
  service,
@@ -52498,7 +53288,7 @@ const discover = fnUntraced(function* (cwd, input) {
52498
53288
  path.basename(cwd),
52499
53289
  "localhost"
52500
53290
  ].join(".");
52501
- const origin = `http://${host}:${input.proxyPort}`;
53291
+ const origin = input.origin(host);
52502
53292
  return {
52503
53293
  host,
52504
53294
  port,
@@ -52517,9 +53307,9 @@ const discover = fnUntraced(function* (cwd, input) {
52517
53307
  name,
52518
53308
  origin,
52519
53309
  packageFolder: folder,
52520
- packagePath: result.packagePath,
53310
+ packagePath,
52521
53311
  service,
52522
- sessionId: `${result.packagePath}:${name}:${Date.now()}:${Math.random()}`
53312
+ sessionId: `${packagePath}:${name}:${Date.now()}:${Math.random()}`
52523
53313
  }
52524
53314
  };
52525
53315
  });
@@ -52587,9 +53377,9 @@ const INJECTED_HEAD = `<script>
52587
53377
  <\/script>
52588
53378
  <script crossorigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js" onload="window.reactScan?.({allowInIframe: true, _debug: 'verbose'})"><\/script>
52589
53379
  <script src="https://unpkg.com/react-grab/dist/index.global.js"><\/script>`;
52590
- const injectScripts = fnUntraced(function* (html) {
53380
+ function injectScripts(html) {
52591
53381
  return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (match) => `${match}\n${INJECTED_HEAD}`) : `${INJECTED_HEAD}\n${html}`;
52592
- });
53382
+ }
52593
53383
  const proxy = fnUntraced(function* (request, origin) {
52594
53384
  const webRequest = yield* toWeb(request);
52595
53385
  const [pathname = "/", search = ""] = request.url.split("?");
@@ -52613,7 +53403,7 @@ const proxy = fnUntraced(function* (request, origin) {
52613
53403
  }));
52614
53404
  const body = yield* tryPromise(() => upstreamResponse.text());
52615
53405
  headers.set("content-type", "text/html; charset=utf-8");
52616
- return fromWeb(new Response(yield* injectScripts(body), {
53406
+ return fromWeb(new Response(injectScripts(body), {
52617
53407
  headers,
52618
53408
  status: upstreamResponse.status,
52619
53409
  statusText: upstreamResponse.statusText
@@ -52621,41 +53411,46 @@ const proxy = fnUntraced(function* (request, origin) {
52621
53411
  });
52622
53412
  const proxyWebSocket = fnUntraced(function* (request, origin) {
52623
53413
  const [pathname = "/", search = ""] = request.url.split("?");
52624
- const protocols = request.headers["sec-websocket-protocol"]?.split(",").map((protocol) => protocol.trim()).filter((protocol) => protocol.length > 0);
53414
+ const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((protocols) => pipe(protocols, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
52625
53415
  const inbound = yield* request.upgrade;
52626
53416
  const upstreamUrl = new URL(origin);
52627
53417
  upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
52628
53418
  upstreamUrl.pathname = pathname;
52629
53419
  upstreamUrl.search = search;
52630
- const outbound = yield* makeWebSocket(upstreamUrl.toString(), { protocols }).pipe(provide(layerWebSocketConstructorGlobal));
53420
+ const outbound = yield* makeWebSocket(upstreamUrl.toString(), { protocols: getOrUndefined$1(protocols) }).pipe(provide(layerWebSocketConstructorGlobal));
52631
53421
  const writeInbound = yield* inbound.writer;
52632
53422
  const writeOutbound = yield* outbound.writer;
52633
53423
  yield* outbound.runRaw((message) => writeInbound(message)).pipe(catchReason("SocketError", "SocketCloseError", (reason) => writeInbound(new CloseEvent(reason.code, reason.closeReason)).pipe(catch_$2(() => void_$1))), catch_$2(() => writeInbound(new CloseEvent(1011, "proxy error")).pipe(catch_$2(() => void_$1))), forkScoped);
52634
- yield* inbound.runRaw((message) => writeOutbound(typeof message === "string" ? message : message.slice())).pipe(catch_$2(() => void_$1), ensuring$2(writeOutbound(new CloseEvent()).pipe(catch_$2(() => void_$1))));
53424
+ 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))));
52635
53425
  return empty();
52636
53426
  });
52637
- const requestHostname = fnUntraced(function* (host) {
52638
- return fromUndefinedOr(host?.split(":")[0]);
52639
- });
53427
+ function requestHostname(host) {
53428
+ return pipe(fromUndefinedOr(host), flatMap$6((host) => pipe(host, split$1(":"), head)));
53429
+ }
52640
53430
  function isLocalHostname(hostname) {
52641
53431
  return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
52642
53432
  }
52643
- var Portless = class Portless extends Service()("@deslop/portless/Portless", { make: sync(() => {
53433
+ var Portless = class Portless extends Service()("@deslop/portless/Portless", { make: gen(function* () {
53434
+ const server = yield* HttpServer;
53435
+ const proxyPort = server.address._tag === "TcpAddress" ? server.address.port.toString() : yield* die$1(/* @__PURE__ */ new Error("portless requires a TCP HTTP server address"));
52644
53436
  const ports = /* @__PURE__ */ new Map();
52645
53437
  const routes = /* @__PURE__ */ new Map();
53438
+ function origin(host) {
53439
+ return `http://${host}:${proxyPort}`;
53440
+ }
52646
53441
  const middleware = fnUntraced(function* (app) {
52647
53442
  const request = yield* HttpServerRequest;
52648
- const hostname = yield* requestHostname(request.headers["host"]);
53443
+ const hostname = requestHostname(request.headers["host"]);
52649
53444
  if (isNone(hostname) || isLocalHostname(hostname.value)) return yield* app;
52650
53445
  if (!hostname.value.endsWith(".localhost")) return yield* app;
52651
- const route = yield* lookup(request.headers["host"]);
53446
+ const route = lookup(request.headers["host"]);
52652
53447
  if (isNone(route)) return empty({ status: 404 });
52653
53448
  if (request.headers["upgrade"]?.toLowerCase() === "websocket") return yield* proxyWebSocket(request, route.value);
52654
53449
  return yield* proxy(request, route.value);
52655
53450
  });
52656
- const lookup = fnUntraced(function* (host) {
52657
- return pipe(yield* requestHostname(host), flatMap$6((hostname) => fromUndefinedOr(routes.get(hostname))));
52658
- });
53451
+ function lookup(host) {
53452
+ return pipe(requestHostname(host), flatMap$6((hostname) => fromUndefinedOr(routes.get(hostname))));
53453
+ }
52659
53454
  const port = fnUntraced(function* (key) {
52660
53455
  const existing = ports.get(key);
52661
53456
  if (existing !== void 0) return existing;
@@ -52671,15 +53466,13 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52671
53466
  });
52672
53467
  return {
52673
53468
  middleware,
52674
- port,
52675
- register: fnUntraced(function* (host, port) {
52676
- routes.set(host, `http://127.0.0.1:${port}`);
52677
- }),
52678
- scripts: fnUntraced(function* (cwd, input) {
53469
+ scripts: fnUntraced(function* (cwd) {
52679
53470
  return yield* pipe(discover(cwd, {
52680
- port: (sessionId) => port(`${cwd}:${sessionId}`),
52681
- proxyPort: input.proxyPort
52682
- }), map$4((routes) => routes.map((route) => ({
53471
+ origin,
53472
+ port: (sessionId) => port(`${cwd}:${sessionId}`)
53473
+ }), tap((discovered) => sync(() => {
53474
+ for (const route of discovered) routes.set(route.host, `http://127.0.0.1:${route.port}`);
53475
+ })), map$4((routes) => routes.map((route) => ({
52683
53476
  host: route.host,
52684
53477
  port: route.port,
52685
53478
  script: {
@@ -52697,24 +53490,94 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52697
53490
  };
52698
53491
  //#endregion
52699
53492
  //#region ../../packages/terminal/src/service.ts
52700
- function snapshotEvents(data) {
52701
- if (data === "") return empty$13();
52702
- const events = [];
52703
- for (let index = 0; index < data.length; index += 64 * 1024) events.push({
52704
- data: data.slice(index, index + 64 * 1024),
52705
- type: "data"
52706
- });
52707
- return events;
52708
- }
53493
+ var import_addon_progress = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
53494
+ (function(e, t) {
53495
+ "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.ProgressAddon = t() : e.ProgressAddon = t();
53496
+ })(globalThis, (() => (() => {
53497
+ "use strict";
53498
+ var e = {};
53499
+ return (() => {
53500
+ var t = e;
53501
+ function s(e) {
53502
+ let t = 0;
53503
+ for (let s = 0; s < e.length; ++s) {
53504
+ const r = e.charCodeAt(s);
53505
+ if (r < 48 || 57 < r) return -1;
53506
+ t = 10 * t + r - 48;
53507
+ }
53508
+ return t;
53509
+ }
53510
+ Object.defineProperty(t, "__esModule", { value: !0 }), t.ProgressAddon = void 0, t.ProgressAddon = class {
53511
+ constructor() {
53512
+ this._st = 0, this._pr = 0;
53513
+ }
53514
+ dispose() {
53515
+ this._seqHandler?.dispose(), this._onChange?.dispose();
53516
+ }
53517
+ activate(e) {
53518
+ this._seqHandler = e.parser.registerOscHandler(9, ((e) => {
53519
+ if (!e.startsWith("4;")) return !1;
53520
+ const t = e.split(";");
53521
+ if (t.length > 3) return !0;
53522
+ 2 === t.length && t.push("");
53523
+ const r = s(t[1]), o = s(t[2]);
53524
+ switch (r) {
53525
+ case 0:
53526
+ this.progress = {
53527
+ state: r,
53528
+ value: 0
53529
+ };
53530
+ break;
53531
+ case 1:
53532
+ if (o < 0) return !0;
53533
+ this.progress = {
53534
+ state: r,
53535
+ value: o
53536
+ };
53537
+ break;
53538
+ case 2:
53539
+ case 4:
53540
+ if (o < 0) return !0;
53541
+ this.progress = {
53542
+ state: r,
53543
+ value: o || this._pr
53544
+ };
53545
+ break;
53546
+ case 3: this.progress = {
53547
+ state: r,
53548
+ value: this._pr
53549
+ };
53550
+ }
53551
+ return !0;
53552
+ })), this._onChange = new e._core._onData.constructor(), this.onChange = this._onChange.event;
53553
+ }
53554
+ get progress() {
53555
+ return {
53556
+ state: this._st,
53557
+ value: this._pr
53558
+ };
53559
+ }
53560
+ set progress(e) {
53561
+ e.state < 0 || e.state > 4 ? console.warn("progress state out of bounds, not applied") : (this._st = e.state, this._pr = Math.min(Math.max(e.value, 0), 100), this._onChange?.fire({
53562
+ state: this._st,
53563
+ value: this._pr
53564
+ }));
53565
+ }
53566
+ };
53567
+ })(), e;
53568
+ })()));
53569
+ })))(), 1);
53570
+ const eventBacklogCapacity = 512;
53571
+ const terminalReset = "\x1Bc";
52709
53572
  function parseTitleSignal(title) {
52710
- const trimmed = trim(title);
52711
- if (/^\[\s*[!.]\s*\]\s*Action Required\b/i.test(trimmed)) return {
52712
- state: "needs_input",
52713
- title: trimmed.replace(/^\[\s*[!.]\s*\]\s*/i, "") || trimmed
53573
+ const trimmed = title.trim();
53574
+ if (/^\[\s*[!.]\s*\]\s*Action Required\b/iu.test(trimmed)) return {
53575
+ state: "waiting",
53576
+ title: trimmed.replace(/^\[\s*[!.]\s*\]\s*/iu, "") || trimmed
52714
53577
  };
52715
53578
  const spinner = /^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-])(?:\s|\s*\|)/u.test(trimmed);
52716
- const nextTitle = trimmed.replace(/^OC\s*\|\s*/i, "").replace(/^π\s*-\s*/i, "").replace(/^\[\s*[^\]]+\s*\]\s*/, "").replace(/^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-]\s*)+/, "").replace(/^\|\s*/, "").trim() || trimmed;
52717
- const segment = nextTitle.match(/^(Idle|Ready|Starting|Working|Thinking|Waiting)\b/i)?.[1]?.toLowerCase();
53579
+ const nextTitle = trimmed.replace(/^OC\s*\|\s*/iu, "").replace(/^π\s*-\s*/iu, "").replace(/^\[\s*[^\]]+\s*\]\s*/u, "").replace(/^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-]\s*)+/u, "").replace(/^\|\s*/u, "").trim() || trimmed;
53580
+ const segment = /^(Idle|Ready|Starting|Working|Thinking|Waiting)\b/iu.exec(nextTitle)?.[1]?.toLowerCase();
52718
53581
  if (segment === "idle" || segment === "ready") return {
52719
53582
  state: "idle",
52720
53583
  title: nextTitle
@@ -52731,7 +53594,7 @@ function parseTitleSignal(title) {
52731
53594
  state: "running",
52732
53595
  title: nextTitle
52733
53596
  };
52734
- if (isNonEmpty$1(trimmed)) return {
53597
+ if (trimmed !== "") return {
52735
53598
  state: "idle",
52736
53599
  title: nextTitle
52737
53600
  };
@@ -52740,65 +53603,95 @@ function parseTitleSignal(title) {
52740
53603
  title: ""
52741
53604
  };
52742
53605
  }
52743
- function completeSignalData(input) {
52744
- if (input.endsWith("\x1B")) return {
52745
- complete: input.slice(0, -1),
52746
- pending: "\x1B"
52747
- };
52748
- const start = input.lastIndexOf("\x1B]");
52749
- if (start === -1) return {
52750
- complete: input,
52751
- pending: ""
52752
- };
52753
- const tail = input.slice(start);
52754
- if (tail.includes("\x07") || tail.includes("\x1B\\")) return {
52755
- complete: input,
52756
- pending: ""
52757
- };
53606
+ function snapshotEvents(data, sequence) {
53607
+ if (data === "") return empty$13();
53608
+ const events = [];
53609
+ for (let index = 0; index < data.length; index += 256 * 1024) events.push({
53610
+ data: data.slice(index, index + 256 * 1024),
53611
+ sequence,
53612
+ type: "data"
53613
+ });
53614
+ return events;
53615
+ }
53616
+ function adjacentGroups(items, sameGroup, merge) {
53617
+ return pipe(items, reduce(empty$13(), (groups, item) => {
53618
+ const next = groups;
53619
+ const previous = groups.at(-1);
53620
+ if (!(previous && sameGroup(previous, item))) {
53621
+ next.push(item);
53622
+ return next;
53623
+ }
53624
+ next[next.length - 1] = merge(previous, item);
53625
+ return next;
53626
+ }));
53627
+ }
53628
+ function queuedDataGroups(items, merge) {
53629
+ return adjacentGroups(items, (previous, item) => previous.generation === item.generation, merge);
53630
+ }
53631
+ function mergeQueuedData(previous, item) {
52758
53632
  return {
52759
- complete: input.slice(0, start),
52760
- pending: tail
53633
+ data: `${previous.data}${item.data}`,
53634
+ generation: item.generation
52761
53635
  };
52762
53636
  }
53637
+ function queuedWriteGroups(items) {
53638
+ return adjacentGroups(items, (previous, item) => previous.process === item.process, (previous, item) => ({
53639
+ data: `${previous.data}${item.data}`,
53640
+ process: item.process
53641
+ }));
53642
+ }
52763
53643
  var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { make: fnUntraced(function* (config) {
52764
53644
  const dataQueue = yield* unbounded();
52765
- const events = yield* bounded$1({ capacity: 256 });
53645
+ const screenQueue = yield* unbounded();
53646
+ const writeQueue = yield* unbounded();
53647
+ const resizeQueue = yield* sliding(1);
53648
+ const events = yield* bounded$1({
53649
+ capacity: 1024,
53650
+ replay: eventBacklogCapacity
53651
+ });
52766
53652
  const lifecycleLock = yield* make$47(1);
52767
53653
  const screenLock = yield* make$47(1);
52768
- const sequenceRef = yield* make$38(0);
52769
- const signalBuffer = yield* make$38("");
53654
+ const eventSequenceRef = yield* make$38(0);
53655
+ const parsedSequenceRef = yield* make$38(0);
53656
+ const screenGenerationRef = yield* make$38(0);
52770
53657
  const processRef = yield* make$38(void 0);
52771
53658
  const sizeRef = yield* make$38({
52772
53659
  cols: 120,
52773
53660
  rows: 32
52774
53661
  });
52775
53662
  const shell = yield* string("SHELL").pipe(orElseSucceed(() => "bash"));
52776
- const processCommand = config.preparedCommand?.command ?? config.command ?? shell;
52777
- const processArgs = config.preparedCommand?.args ?? config.args ?? [];
52778
- const autostart = config.command === void 0 && config.preparedCommand === void 0;
53663
+ const processCommand = config.command?.command ?? shell;
53664
+ const processArgs = config.command?.args ?? [];
53665
+ const processEnv = config.command?.options.env ?? {};
53666
+ const autostart = config.command === void 0;
52779
53667
  const stateRef = yield* make$3({
52780
53668
  runId: 0,
52781
53669
  state: autostart ? "starting" : "idle",
52782
53670
  title: ""
52783
53671
  });
52784
- const screen = new (createRequire(import.meta.url)("@xterm/headless")).Terminal({
53672
+ const screen = new HeadlessModule.Terminal({
52785
53673
  allowProposedApi: true,
52786
53674
  cols: 120,
52787
53675
  rows: 32,
52788
53676
  scrollback: 1e4
52789
53677
  });
52790
- const serialize = new (createRequire(import.meta.url)("@xterm/addon-serialize")).SerializeAddon();
53678
+ const serialize = new SerializeModule.SerializeAddon();
53679
+ const progress = new import_addon_progress.ProgressAddon();
52791
53680
  screen.loadAddon(serialize);
52792
- const publish$1 = fnUntraced(function* (event) {
53681
+ screen.loadAddon(progress);
53682
+ const publish$1 = fnUntraced(function* (data) {
53683
+ const sequence = yield* updateAndGet(eventSequenceRef, (sequence) => sequence + 1);
52793
53684
  yield* publish(events, {
52794
- event,
52795
- sequence: yield* updateAndGet(sequenceRef, (sequence) => sequence + 1)
53685
+ data,
53686
+ sequence,
53687
+ type: "data"
52796
53688
  });
53689
+ return sequence;
52797
53690
  });
52798
53691
  const requestSnapshot = withPermit(screenLock, gen(function* () {
52799
53692
  return {
52800
53693
  data: serialize.serialize({ scrollback: 1e4 }),
52801
- sequence: yield* get$3(sequenceRef)
53694
+ sequence: yield* get$3(parsedSequenceRef)
52802
53695
  };
52803
53696
  }));
52804
53697
  function setState(state) {
@@ -52807,9 +53700,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52807
53700
  state
52808
53701
  }));
52809
53702
  }
52810
- function setActiveState(state) {
53703
+ function setProgressState(progress) {
52811
53704
  return update(stateRef, (current) => {
52812
- if (current.state !== "idle" && current.state !== "starting" && current.state !== "running") return current;
53705
+ if (current.state === "stopped" || current.state === "exited" || current.state === "failed") return current;
53706
+ const state = pipe(progress.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
52813
53707
  return {
52814
53708
  ...current,
52815
53709
  state
@@ -52831,17 +53725,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52831
53725
  state: "starting",
52832
53726
  title: ""
52833
53727
  })), andThen(get(stateRef)));
52834
- function readSignals(data) {
52835
- for (const match of data.matchAll(/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) {
52836
- const title = match[1];
52837
- if (title !== void 0) runFork(setTitle(title));
52838
- }
52839
- for (const match of data.matchAll(/\x1b\]9;4;([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) runFork(setActiveState(match[1] === "0" ? "idle" : "running"));
52840
- }
52841
- const readBufferedSignals = fnUntraced(function* (data) {
52842
- const next = completeSignalData(`${yield* get$3(signalBuffer)}${data}`);
52843
- yield* set$4(signalBuffer, next.pending);
52844
- readSignals(next.complete);
53728
+ screen.parser.registerOscHandler(0, (title) => {
53729
+ runFork(setTitle(title));
53730
+ return false;
53731
+ });
53732
+ screen.parser.registerOscHandler(2, (title) => {
53733
+ runFork(setTitle(title));
53734
+ return false;
53735
+ });
53736
+ progress.onChange((nextProgress) => {
53737
+ runFork(setProgressState(nextProgress));
52845
53738
  });
52846
53739
  const interruptProcess = fnUntraced(function* (subprocess, signal) {
52847
53740
  yield* sync(() => {
@@ -52855,14 +53748,14 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52855
53748
  yield* sleep("250 millis");
52856
53749
  yield* interruptProcess(subprocess, "SIGKILL");
52857
53750
  });
52858
- const writeScreen = fnUntraced(function* (data) {
53751
+ const writeScreen = fnUntraced(function* (input) {
53752
+ if ((yield* get$3(screenGenerationRef)) !== input.generation) return;
52859
53753
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
52860
- screen.write(data, () => {
53754
+ screen.write(input.data, () => {
52861
53755
  resume(void_$1);
52862
53756
  });
52863
- }), andThen(readBufferedSignals(data)), andThen(publish$1({
52864
- data,
52865
- type: "data"
53757
+ }), andThen(gen(function* () {
53758
+ if ((yield* get$3(screenGenerationRef)) === input.generation) yield* set$4(parsedSequenceRef, yield* publish$1(input.data));
52866
53759
  }))));
52867
53760
  });
52868
53761
  const clearProcess = fnUntraced(function* (handle) {
@@ -52883,9 +53776,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52883
53776
  if (state) yield* setState(state);
52884
53777
  });
52885
53778
  const spawnProcess = fnUntraced(function* () {
53779
+ const generation = yield* updateAndGet(screenGenerationRef, (generation) => generation + 1);
52886
53780
  yield* withPermit(screenLock, pipe(sync(() => {
52887
53781
  screen.reset();
52888
- }), andThen(publish$1({ type: "reset" }))));
53782
+ }), andThen(publish$1(terminalReset)), tap((sequence) => set$4(parsedSequenceRef, sequence))));
52889
53783
  yield* startRun;
52890
53784
  const size = yield* get$3(sizeRef);
52891
53785
  const subprocess = yield* try_({
@@ -52898,7 +53792,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52898
53792
  cwd: config.cwd,
52899
53793
  env: {
52900
53794
  ...process.env,
52901
- ...config.env,
53795
+ ...processEnv,
52902
53796
  TERM: "xterm-256color"
52903
53797
  },
52904
53798
  name: "xterm-256color",
@@ -52907,7 +53801,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52907
53801
  });
52908
53802
  const handle = {
52909
53803
  data: subprocess.onData((data) => {
52910
- offerUnsafe(dataQueue, data);
53804
+ offerUnsafe(dataQueue, {
53805
+ data,
53806
+ generation
53807
+ });
52911
53808
  }),
52912
53809
  exit: subprocess.onExit((event) => {
52913
53810
  runFork(withPermit(lifecycleLock, gen(function* () {
@@ -52930,18 +53827,25 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52930
53827
  yield* stopProcess();
52931
53828
  return yield* spawnProcess();
52932
53829
  });
52933
- yield* pipe(fromQueue(dataQueue), runForEach(writeScreen), forkScoped);
53830
+ yield* pipe(fromQueue(dataQueue), groupedWithin(256, millis(8)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), (item) => gen(function* () {
53831
+ if ((yield* get$3(screenGenerationRef)) !== item.generation) return;
53832
+ yield* offer(screenQueue, item);
53833
+ }), { discard: true })), forkScoped);
53834
+ yield* pipe(fromQueue(screenQueue), groupedWithin(256, millis(16)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), writeScreen, { discard: true })), forkScoped);
52934
53835
  yield* addFinalizer(() => all([
52935
53836
  stopProcess(),
52936
53837
  shutdown$1(events),
52937
53838
  shutdown(dataQueue),
53839
+ shutdown(screenQueue),
53840
+ shutdown(writeQueue),
53841
+ shutdown(resizeQueue),
52938
53842
  sync(() => screen.dispose())
52939
53843
  ], {
52940
53844
  concurrency: "unbounded",
52941
53845
  discard: true
52942
53846
  }));
52943
53847
  if (autostart) yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => setState("failed")));
52944
- const resize = fnUntraced(function* (nextSize) {
53848
+ const resizeProcess = fnUntraced(function* (nextSize) {
52945
53849
  const size = yield* get$3(sizeRef);
52946
53850
  if (size.cols === nextSize.cols && size.rows === nextSize.rows) return;
52947
53851
  yield* set$4(sizeRef, nextSize);
@@ -52960,56 +53864,65 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52960
53864
  }
52961
53865
  });
52962
53866
  });
52963
- const write = fnUntraced(function* (data) {
52964
- const process = yield* get$3(processRef);
52965
- if (!process) return;
53867
+ yield* pipe(fromQueue(resizeQueue), groupedWithin(32, millis(16)), runForEach((items) => pipe(last(fromIterable$2(items)), match$5({
53868
+ onNone: () => void_$1,
53869
+ onSome: resizeProcess
53870
+ }))), forkScoped);
53871
+ const writeProcess = fnUntraced(function* (input) {
53872
+ if ((yield* get$3(processRef)) !== input.process) return;
52966
53873
  yield* try_({
52967
53874
  catch: (cause) => new TerminalError({
52968
53875
  cause,
52969
53876
  message: "failed to write to terminal"
52970
53877
  }),
52971
53878
  try: () => {
52972
- process.process.write(data);
53879
+ input.process.process.write(input.data);
52973
53880
  }
52974
53881
  });
52975
53882
  });
53883
+ yield* pipe(fromQueue(writeQueue), groupedWithin(128, millis(4)), runForEach((items) => forEach$1(queuedWriteGroups(fromIterable$2(items)), writeProcess, { discard: true })), forkScoped);
52976
53884
  const eventsStream = scoped$1(unwrap$1(gen(function* () {
52977
53885
  const subscription = yield* subscribe(events);
52978
53886
  const snapshot = yield* requestSnapshot;
52979
53887
  const pending = yield* takeUpTo(subscription, Number.POSITIVE_INFINITY);
53888
+ const replay = filter$2(pending, (event) => event.sequence > snapshot.sequence);
53889
+ const replaySequence = replay.at(-1)?.sequence ?? snapshot.sequence;
52980
53890
  return pipe(fromIterable$1([
52981
53891
  {
52982
- event: { type: "reset" },
52983
- sequence: snapshot.sequence
53892
+ data: terminalReset,
53893
+ sequence: snapshot.sequence,
53894
+ type: "data"
52984
53895
  },
52985
- ...map$7(snapshotEvents(snapshot.data), (event) => ({
52986
- event,
52987
- sequence: snapshot.sequence
52988
- })),
52989
- ...filter$2(pending, (event) => event.sequence > snapshot.sequence)
52990
- ]), concat(fromEffectRepeat(take$2(subscription))));
53896
+ ...snapshotEvents(snapshot.data, snapshot.sequence),
53897
+ ...replay,
53898
+ ...filter$2(pending, (event) => event.sequence > replaySequence)
53899
+ ]), concat(fromEffectRepeat(take$3(subscription))));
52991
53900
  })));
52992
- const updates = merge$1(changes(stateRef).pipe(map$2((state) => ({
53901
+ const stateUpdates = unwrap$1(pipe(get(stateRef), map$4((state) => concat(drop(1)(changes(stateRef)))(make$43(state)))));
53902
+ const updates = merge$1(stateUpdates.pipe(map$2((state) => ({
52993
53903
  state,
52994
53904
  type: "state"
52995
- }))), eventsStream.pipe(map$2((published) => ({
52996
- event: published.event,
52997
- type: "event"
52998
- }))));
53905
+ }))), eventsStream);
52999
53906
  return {
53000
53907
  resize: fnUntraced(function* (size) {
53001
- return yield* pipe(resize(size), andThen(get(stateRef)));
53908
+ yield* offer(resizeQueue, size);
53002
53909
  }),
53003
53910
  restart: fnUntraced(function* () {
53004
53911
  return yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => pipe(setState("failed"), andThen(get(stateRef)))));
53005
53912
  }),
53913
+ stateUpdates,
53006
53914
  stop: fnUntraced(function* () {
53007
53915
  yield* pipe(stopProcess("stopped"), withPermit(lifecycleLock));
53008
53916
  return yield* get(stateRef);
53009
53917
  }),
53010
53918
  updates,
53011
53919
  write: fnUntraced(function* (data) {
53012
- return yield* pipe(write(data), andThen(get(stateRef)));
53920
+ if (data === "") return;
53921
+ const process = yield* get$3(processRef);
53922
+ if (process) yield* offer(writeQueue, {
53923
+ data,
53924
+ process
53925
+ });
53013
53926
  })
53014
53927
  };
53015
53928
  }) }) {
@@ -53055,11 +53968,11 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53055
53968
  const portlessWorktrees = yield* make$46({
53056
53969
  idleTimeToLive: infinity,
53057
53970
  lookup: fnUntraced(function* (cwd) {
53058
- const scripts = yield* pipe(portless.scripts(cwd, { proxyPort: process.env["PORT"] ?? "4010" }), mapError$2((cause) => new TerminalError({
53971
+ const scripts = yield* pipe(portless.scripts(cwd), mapError$2((cause) => new TerminalError({
53059
53972
  cause,
53060
53973
  message: `failed to discover portless scripts in ${cwd}`
53061
53974
  })));
53062
- yield* all(pipe(scripts, map$7((script) => all([portless.register(script.host, script.port), update$1(portlessScripts, (current) => set$2(current, script.script.sessionId, script.script))], { discard: true }))), { discard: true });
53975
+ yield* all(pipe(scripts, map$7((script) => update$1(portlessScripts, (current) => set$2(current, script.script.sessionId, script.script)))), { discard: true });
53063
53976
  return pipe(scripts, map$7((route) => ({
53064
53977
  baseOrigin: route.script.baseOrigin,
53065
53978
  command: route.script.command,
@@ -53079,14 +53992,33 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53079
53992
  const script = pipe(yield* get$3(portlessScripts), get$1(input.sessionId), getOrUndefined$1);
53080
53993
  if (script === void 0) return input;
53081
53994
  return {
53995
+ command: make$40(script.preparedCommand.command, script.preparedCommand.args, {
53996
+ ...script.preparedCommand.options,
53997
+ env: script.env
53998
+ }),
53082
53999
  cwd: script.cwd,
53083
- env: script.env,
53084
- preparedCommand: script.preparedCommand,
53085
54000
  sessionId: script.sessionId
53086
54001
  };
53087
54002
  });
54003
+ function terminalSessionInput(session) {
54004
+ if ("args" in session || "env" in session) return {
54005
+ command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
54006
+ cwd: session.cwd,
54007
+ sessionId: session.sessionId
54008
+ };
54009
+ if (typeof session.command === "string") return {
54010
+ command: make$40(session.command),
54011
+ cwd: session.cwd,
54012
+ sessionId: session.sessionId
54013
+ };
54014
+ return {
54015
+ command: session.command,
54016
+ cwd: session.cwd,
54017
+ sessionId: session.sessionId
54018
+ };
54019
+ }
53088
54020
  const terminal = fnUntraced(function* (input) {
53089
- return yield* pipe(terminalSession(input), flatMap$2((session) => get$6(terminals, session)));
54021
+ return yield* pipe(terminalSession(input), map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
53090
54022
  });
53091
54023
  const reviewStateKey = fnUntraced(function* (input) {
53092
54024
  const root = yield* pipe(fs.realPath(input.cwd), orElseSucceed(() => input.cwd));
@@ -53133,14 +54065,14 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53133
54065
  cwd: session.cwd,
53134
54066
  uuid: session.uuid
53135
54067
  }), session));
53136
- const terminal = yield* get$6(terminals, TerminalSessionKey.make({
54068
+ const terminal = yield* terminalSession(TerminalSessionKey.make({
53137
54069
  args: session.args,
53138
54070
  command: session.command,
53139
54071
  cwd: session.cwd,
53140
54072
  sessionId: session.uuid
53141
- }));
54073
+ })).pipe(map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
53142
54074
  yield* terminal.restart();
53143
- yield* pipe(terminal.updates, filterMap((update) => update.type === "state" ? succeed$7(update.state.state) : failVoid), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (current) => remove$2(current, AgentSessionKey.make({
54075
+ yield* pipe(terminal.stateUpdates, map$2((state) => state.state), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (current) => remove$2(current, AgentSessionKey.make({
53144
54076
  cwd: session.cwd,
53145
54077
  uuid: session.uuid
53146
54078
  })))), forkDetach);
@@ -53208,6 +54140,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53208
54140
  rows: payload.rows
53209
54141
  }))),
53210
54142
  "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
54143
+ "terminal.state.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stateUpdates)),
53211
54144
  "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
53212
54145
  "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
53213
54146
  "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
@@ -66707,7 +67640,7 @@ var OtelSpan = class {
66707
67640
  this.links = options.links;
66708
67641
  this.kind = options.kind;
66709
67642
  const active = contextApi.active();
66710
- this.parent = options.root !== true ? orElse$1(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
67643
+ this.parent = options.root !== true ? orElse$3(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
66711
67644
  this.span = tracer.startSpan(options.name, {
66712
67645
  startTime: nanosToHrTime(options.startTime),
66713
67646
  links: options.links.length > 0 ? options.links.map((link) => ({