@deslop/workbench 0.0.321 → 0.0.330

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 (43) hide show
  1. package/dist/client/assets/agent-BAplunWJ.js +1 -0
  2. package/dist/client/assets/agent-DORiXY9q.js +2 -0
  3. package/dist/client/assets/button-DJfQFnBl.js +16 -0
  4. package/dist/client/assets/{diff-HFsBcdrM.js → diff-5y5Ly0fZ.js} +2 -2
  5. package/dist/client/assets/diff-Cu8yhVQs.js +217 -0
  6. package/dist/client/assets/{external-link-CTjuCORn.js → external-link-DSkEzLiB.js} +1 -1
  7. package/dist/client/assets/{fallbacks-DZ7ciusO.js → fallbacks-2XEEl4BI.js} +1 -1
  8. package/dist/client/assets/index-BX6N5TyF.css +2 -0
  9. package/dist/client/assets/{index-Ds4rq0zQ.js → index-CU4FmmbE.js} +3 -3
  10. package/dist/client/assets/input-group-tkTwlIFp.js +153 -0
  11. package/dist/client/assets/loader-circle-vwjgn9E1.js +1 -0
  12. package/dist/client/assets/portless-Cn_0jtX4.js +2 -0
  13. package/dist/client/assets/portless-DRWo8KFX.js +1 -0
  14. package/dist/client/assets/{resizable-B1fIW9sm.js → resizable-BICft2JP.js} +1 -1
  15. package/dist/client/assets/route-D-VRm0UM.js +2 -0
  16. package/dist/client/assets/route-DAzFV54O.js +45 -0
  17. package/dist/client/assets/run-C08WVAIM.js +1 -0
  18. package/dist/client/assets/run-Dx2tn3Qe.js +2 -0
  19. package/dist/client/assets/state-DrPxOHMO.js +2 -0
  20. package/dist/client/assets/terminal-BGn5gevX.js +2 -0
  21. package/dist/client/assets/terminal-BTXMxFEq.js +1 -0
  22. package/dist/client/assets/terminal-CPpKsotd.js +145 -0
  23. package/dist/client/assets/{triangle-alert-CGj-8H_a.js → triangle-alert-DrGIVhEI.js} +1 -1
  24. package/dist/client/index.html +12 -12
  25. package/dist/server.js +1248 -406
  26. package/package.json +2 -2
  27. package/dist/client/assets/agent-DAD7EQOa.js +0 -2
  28. package/dist/client/assets/agent-DHWhwvQy.js +0 -1
  29. package/dist/client/assets/button-fe_R2wzr.js +0 -16
  30. package/dist/client/assets/diff-BbjpVkn4.js +0 -217
  31. package/dist/client/assets/index-Ci3BZgXN.css +0 -2
  32. package/dist/client/assets/input-group-BtEJur4W.js +0 -153
  33. package/dist/client/assets/loader-circle-B1mHTP2Y.js +0 -1
  34. package/dist/client/assets/portless-DFKFPX3Z.js +0 -1
  35. package/dist/client/assets/portless-DexDlqwA.js +0 -2
  36. package/dist/client/assets/route-CUHeGENe.js +0 -45
  37. package/dist/client/assets/route-DOWKJR6H.js +0 -2
  38. package/dist/client/assets/run-BvHiSlty.js +0 -2
  39. package/dist/client/assets/run-L2YCL4H0.js +0 -1
  40. package/dist/client/assets/state-T-ZhKyUm.js +0 -2
  41. package/dist/client/assets/terminal-CGe8qF7_.js +0 -1
  42. package/dist/client/assets/terminal-Ci9YBovb.js +0 -119
  43. package/dist/client/assets/terminal-t4CeG_V9.js +0 -2
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**
@@ -7145,7 +7177,7 @@ const ServiceProto = {
7145
7177
  }
7146
7178
  };
7147
7179
  const ReferenceTypeId = "~effect/Context/Reference";
7148
- const TypeId$48 = "~effect/Context";
7180
+ const TypeId$50 = "~effect/Context";
7149
7181
  /**
7150
7182
  * Creates a `Context` from an existing service map without validating or
7151
7183
  * copying it.
@@ -7180,7 +7212,7 @@ const makeUnsafe$8 = (mapUnsafe) => {
7180
7212
  };
7181
7213
  const Proto$15 = {
7182
7214
  ...PipeInspectableProto,
7183
- [TypeId$48]: { _Services: (_) => _ },
7215
+ [TypeId$50]: { _Services: (_) => _ },
7184
7216
  toJSON() {
7185
7217
  return {
7186
7218
  _id: "Context",
@@ -7232,7 +7264,7 @@ const Proto$15 = {
7232
7264
  * @category guards
7233
7265
  * @since 2.0.0
7234
7266
  */
7235
- const isContext = (u) => hasProperty(u, TypeId$48);
7267
+ const isContext = (u) => hasProperty(u, TypeId$50);
7236
7268
  /**
7237
7269
  * Checks whether the provided argument is a `Reference`.
7238
7270
  *
@@ -7736,7 +7768,7 @@ const withMapUnsafe = (self, f) => {
7736
7768
  const Reference = Service;
7737
7769
  //#endregion
7738
7770
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Duration.js
7739
- const TypeId$47 = "~effect/time/Duration";
7771
+ const TypeId$49 = "~effect/time/Duration";
7740
7772
  const bigint0$2 = /*#__PURE__*/ BigInt(0);
7741
7773
  const bigint1e3 = /*#__PURE__*/ BigInt(1e3);
7742
7774
  const bigint1e6 = /*#__PURE__*/ BigInt(1e6);
@@ -7795,7 +7827,7 @@ const fromInputUnsafe = (input) => {
7795
7827
  }
7796
7828
  case "object": {
7797
7829
  if (input === null) break;
7798
- if (TypeId$47 in input) return input;
7830
+ if (TypeId$49 in input) return input;
7799
7831
  if (Array.isArray(input)) {
7800
7832
  if (input.length !== 2 || !input.every(isNumber)) return invalid(input);
7801
7833
  if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$1;
@@ -7830,7 +7862,7 @@ const zeroDurationValue = {
7830
7862
  const infinityDurationValue = { _tag: "Infinity" };
7831
7863
  const negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
7832
7864
  const DurationProto = {
7833
- [TypeId$47]: TypeId$47,
7865
+ [TypeId$49]: TypeId$49,
7834
7866
  [symbol$3]() {
7835
7867
  return structure(this.value);
7836
7868
  },
@@ -7908,7 +7940,7 @@ const make$61 = (input) => {
7908
7940
  * @category guards
7909
7941
  * @since 2.0.0
7910
7942
  */
7911
- const isDuration = (u) => hasProperty(u, TypeId$47);
7943
+ const isDuration = (u) => hasProperty(u, TypeId$49);
7912
7944
  /**
7913
7945
  * Checks whether a Duration is finite (not infinite).
7914
7946
  *
@@ -9755,7 +9787,7 @@ const provideServiceImpl = (self, service, implementation) => updateContext$1(se
9755
9787
  return add(s, service, implementation);
9756
9788
  });
9757
9789
  /** @internal */
9758
- 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));
9759
9791
  /** @internal */
9760
9792
  const forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
9761
9793
  while: constTrue,
@@ -9843,7 +9875,7 @@ const option$2 = (self) => match$1(self, {
9843
9875
  onSuccess: some$1
9844
9876
  });
9845
9877
  /** @internal */
9846
- const result = (self) => matchEager(self, {
9878
+ const result$1 = (self) => matchEager(self, {
9847
9879
  onFailure: fail$7,
9848
9880
  onSuccess: succeed$7
9849
9881
  });
@@ -10127,11 +10159,11 @@ const interruptibleMask$1 = (f) => withFiber$1((fiber) => {
10127
10159
  });
10128
10160
  /** @internal */
10129
10161
  const all$1 = (arg, options) => {
10130
- if (isIterable(arg)) return options?.mode === "result" ? forEach$2(arg, result, options) : forEach$2(arg, identity, options);
10131
- 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);
10132
10164
  return suspend$3(() => {
10133
10165
  const out = {};
10134
- 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) => {
10135
10167
  out[key] = value;
10136
10168
  }), {
10137
10169
  discard: true,
@@ -10785,7 +10817,7 @@ const reportCauseUnsafe = (fiber, cause, defectsOnly) => {
10785
10817
  };
10786
10818
  //#endregion
10787
10819
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Deferred.js
10788
- const TypeId$46 = "~effect/Deferred";
10820
+ const TypeId$48 = "~effect/Deferred";
10789
10821
  /**
10790
10822
  * Checks whether a value is a `Deferred`.
10791
10823
  *
@@ -10797,9 +10829,9 @@ const TypeId$46 = "~effect/Deferred";
10797
10829
  * @category guards
10798
10830
  * @since 4.0.0
10799
10831
  */
10800
- const isDeferred = (u) => hasProperty(u, TypeId$46);
10832
+ const isDeferred = (u) => hasProperty(u, TypeId$48);
10801
10833
  const DeferredProto = {
10802
- [TypeId$46]: {
10834
+ [TypeId$48]: {
10803
10835
  _A: identity,
10804
10836
  _E: identity
10805
10837
  },
@@ -11841,14 +11873,14 @@ const close = scopeClose;
11841
11873
  const closeUnsafe = scopeCloseUnsafe;
11842
11874
  //#endregion
11843
11875
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Layer.js
11844
- const TypeId$45 = "~effect/Layer";
11876
+ const TypeId$47 = "~effect/Layer";
11845
11877
  const MemoMapTypeId = "~effect/Layer/MemoMap";
11846
11878
  const memoMapReuse = (entry, scope) => {
11847
11879
  entry.observers++;
11848
11880
  return andThen$1(scopeAddFinalizerExit(scope, (exit) => entry.finalizer(exit)), entry.effect);
11849
11881
  };
11850
11882
  const LayerProto = {
11851
- [TypeId$45]: {
11883
+ [TypeId$47]: {
11852
11884
  _ROut: identity,
11853
11885
  _E: identity,
11854
11886
  _RIn: identity
@@ -13643,11 +13675,11 @@ const Clock = ClockRef;
13643
13675
  //#endregion
13644
13676
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/dateTime.js
13645
13677
  /** @internal */
13646
- const TypeId$44 = "~effect/time/DateTime";
13678
+ const TypeId$46 = "~effect/time/DateTime";
13647
13679
  /** @internal */
13648
13680
  const TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
13649
13681
  const Proto$14 = {
13650
- [TypeId$44]: TypeId$44,
13682
+ [TypeId$46]: TypeId$46,
13651
13683
  pipe() {
13652
13684
  return pipeArguments(this, arguments);
13653
13685
  },
@@ -14091,6 +14123,243 @@ const matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$
14091
14123
  return !isFailure$1(halt) ? options.onDone(halt.success.value) : options.onFailure(halt.failure);
14092
14124
  }
14093
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
+ };
14094
14363
  //#endregion
14095
14364
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/layer.js
14096
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)));
@@ -16098,7 +16367,7 @@ const raceFirst = raceFirst$1;
16098
16367
  * @category conditional operators
16099
16368
  * @since 2.0.0
16100
16369
  */
16101
- const when = when$1;
16370
+ const when$2 = when$3;
16102
16371
  /**
16103
16372
  * Handles success or failure eagerly with effectful handlers when the effect is already resolved.
16104
16373
  *
@@ -18288,7 +18557,7 @@ const redactedRegistry = /*#__PURE__*/ new WeakMap();
18288
18557
  *
18289
18558
  * @since 3.3.0
18290
18559
  */
18291
- const TypeId$43 = "~effect/data/Redacted";
18560
+ const TypeId$44 = "~effect/data/Redacted";
18292
18561
  /**
18293
18562
  * Returns `true` if a value is a `Redacted` wrapper.
18294
18563
  *
@@ -18316,7 +18585,7 @@ const TypeId$43 = "~effect/data/Redacted";
18316
18585
  * @category refinements
18317
18586
  * @since 3.3.0
18318
18587
  */
18319
- const isRedacted = (u) => hasProperty(u, TypeId$43);
18588
+ const isRedacted = (u) => hasProperty(u, TypeId$44);
18320
18589
  /**
18321
18590
  * Creates a `Redacted` wrapper for a sensitive value.
18322
18591
  *
@@ -18349,7 +18618,7 @@ const make$56 = (value, options) => {
18349
18618
  return self;
18350
18619
  };
18351
18620
  const Proto$13 = {
18352
- [TypeId$43]: { _A: (_) => _ },
18621
+ [TypeId$44]: { _A: (_) => _ },
18353
18622
  label: void 0,
18354
18623
  ...PipeInspectableProto,
18355
18624
  toJSON() {
@@ -18367,7 +18636,7 @@ const Proto$13 = {
18367
18636
  };
18368
18637
  //#endregion
18369
18638
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/SchemaIssue.js
18370
- const TypeId$42 = "~effect/SchemaIssue/Issue";
18639
+ const TypeId$43 = "~effect/SchemaIssue/Issue";
18371
18640
  /**
18372
18641
  * Returns `true` if the given value is an {@link Issue}.
18373
18642
  *
@@ -18398,10 +18667,10 @@ const TypeId$42 = "~effect/SchemaIssue/Issue";
18398
18667
  * @since 4.0.0
18399
18668
  */
18400
18669
  function isIssue(u) {
18401
- return hasProperty(u, TypeId$42);
18670
+ return hasProperty(u, TypeId$43);
18402
18671
  }
18403
18672
  var Base$1 = class {
18404
- [TypeId$42] = TypeId$42;
18673
+ [TypeId$43] = TypeId$43;
18405
18674
  toString() {
18406
18675
  return defaultFormatter(this);
18407
18676
  }
@@ -19529,9 +19798,9 @@ function split(options) {
19529
19798
  *
19530
19799
  * @since 2.0.0
19531
19800
  */
19532
- const TypeId$41 = "~effect/BigDecimal";
19801
+ const TypeId$42 = "~effect/BigDecimal";
19533
19802
  const BigDecimalProto = {
19534
- [TypeId$41]: TypeId$41,
19803
+ [TypeId$42]: TypeId$42,
19535
19804
  [symbol$3]() {
19536
19805
  const normalized = normalize(this);
19537
19806
  return combine$1(hash(normalized.value), number$1(normalized.scale));
@@ -19577,7 +19846,7 @@ const BigDecimalProto = {
19577
19846
  * @category guards
19578
19847
  * @since 2.0.0
19579
19848
  */
19580
- const isBigDecimal = (u) => hasProperty(u, TypeId$41);
19849
+ const isBigDecimal = (u) => hasProperty(u, TypeId$42);
19581
19850
  /**
19582
19851
  * Creates a `BigDecimal` from a `bigint` value and a scale.
19583
19852
  *
@@ -19912,7 +20181,7 @@ const isZero = (n) => n.value === bigint0;
19912
20181
  const isNegative = (n) => n.value < bigint0;
19913
20182
  //#endregion
19914
20183
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/SchemaTransformation.js
19915
- const TypeId$40 = "~effect/SchemaTransformation/Transformation";
20184
+ const TypeId$41 = "~effect/SchemaTransformation/Transformation";
19916
20185
  /**
19917
20186
  * Represents a bidirectional transformation between a decoded type `T` and an encoded
19918
20187
  * type `E`, built from a pair of `Getter`s.
@@ -19955,7 +20224,7 @@ const TypeId$40 = "~effect/SchemaTransformation/Transformation";
19955
20224
  * @since 4.0.0
19956
20225
  */
19957
20226
  var Transformation = class Transformation {
19958
- [TypeId$40] = TypeId$40;
20227
+ [TypeId$41] = TypeId$41;
19959
20228
  _tag = "Transformation";
19960
20229
  decode;
19961
20230
  encode;
@@ -20001,7 +20270,7 @@ var Transformation = class Transformation {
20001
20270
  * @since 4.0.0
20002
20271
  */
20003
20272
  function isTransformation(u) {
20004
- return hasProperty(u, TypeId$40);
20273
+ return hasProperty(u, TypeId$41);
20005
20274
  }
20006
20275
  /**
20007
20276
  * Constructs a `Transformation` from an object with `decode` and `encode`
@@ -20383,7 +20652,7 @@ var Context = class {
20383
20652
  this.annotations = annotations;
20384
20653
  }
20385
20654
  };
20386
- const TypeId$39 = "~effect/Schema";
20655
+ const TypeId$40 = "~effect/Schema";
20387
20656
  /**
20388
20657
  * Represents the abstract base class for all {@link AST} node variants.
20389
20658
  *
@@ -20405,7 +20674,7 @@ const TypeId$39 = "~effect/Schema";
20405
20674
  * @since 4.0.0
20406
20675
  */
20407
20676
  var Base = class {
20408
- [TypeId$39] = TypeId$39;
20677
+ [TypeId$40] = TypeId$40;
20409
20678
  annotations;
20410
20679
  checks;
20411
20680
  encoding;
@@ -20479,7 +20748,7 @@ var Declaration = class Declaration extends Base {
20479
20748
  * @category models
20480
20749
  * @since 4.0.0
20481
20750
  */
20482
- var Null = class extends Base {
20751
+ var Null$1 = class extends Base {
20483
20752
  _tag = "Null";
20484
20753
  /** @internal */
20485
20754
  getParser() {
@@ -20490,7 +20759,7 @@ var Null = class extends Base {
20490
20759
  return "null";
20491
20760
  }
20492
20761
  };
20493
- const null_ = /*#__PURE__*/ new Null();
20762
+ const null_ = /*#__PURE__*/ new Null$1();
20494
20763
  /**
20495
20764
  * AST node matching the `undefined` value.
20496
20765
  *
@@ -22168,7 +22437,7 @@ function nominal() {
22168
22437
  *
22169
22438
  * @since 4.0.0
22170
22439
  */
22171
- const TypeId$38 = "~effect/platform/PlatformError";
22440
+ const TypeId$39 = "~effect/platform/PlatformError";
22172
22441
  /**
22173
22442
  * Error data for an invalid argument passed to a platform API.
22174
22443
  *
@@ -22278,7 +22547,7 @@ var PlatformError = class extends TaggedError("PlatformError") {
22278
22547
  *
22279
22548
  * @since 4.0.0
22280
22549
  */
22281
- [TypeId$38] = TypeId$38;
22550
+ [TypeId$39] = TypeId$39;
22282
22551
  get message() {
22283
22552
  return this.reason.message;
22284
22553
  }
@@ -22940,7 +23209,7 @@ const takeAll$2 = (self) => takeN(self, self.length);
22940
23209
  * @category elements
22941
23210
  * @since 4.0.0
22942
23211
  */
22943
- const take$3 = (self) => {
23212
+ const take$4 = (self) => {
22944
23213
  if (!self.head) return Empty$2;
22945
23214
  const message = self.head.array[self.head.offset];
22946
23215
  if (self.head.mutable) self.head.array[self.head.offset] = void 0;
@@ -23063,9 +23332,9 @@ const filter$1 = (self, f) => {
23063
23332
  const remove$5 = (self, value) => filter$1(self, (v) => v !== value);
23064
23333
  //#endregion
23065
23334
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/MutableRef.js
23066
- const TypeId$37 = "~effect/MutableRef";
23335
+ const TypeId$38 = "~effect/MutableRef";
23067
23336
  const MutableRefProto = {
23068
- [TypeId$37]: TypeId$37,
23337
+ [TypeId$38]: TypeId$38,
23069
23338
  ...PipeInspectableProto,
23070
23339
  toJSON() {
23071
23340
  return {
@@ -23251,7 +23520,7 @@ const set$6 = /*#__PURE__*/ dual(2, (self, value) => {
23251
23520
  *
23252
23521
  * @since 2.0.0
23253
23522
  */
23254
- const TypeId$36 = "~effect/PubSub";
23523
+ const TypeId$37 = "~effect/PubSub";
23255
23524
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
23256
23525
  /**
23257
23526
  * Creates a PubSub with a custom atomic implementation and strategy.
@@ -23442,7 +23711,7 @@ const makeAtomicUnbounded = (options) => new UnboundedPubSub(options?.replay ? n
23442
23711
  */
23443
23712
  const shutdown$1 = (self) => uninterruptible(withFiber((fiber) => {
23444
23713
  set$6(self.shutdownFlag, true);
23445
- 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);
23446
23715
  }));
23447
23716
  /**
23448
23717
  * Publishes a message to the `PubSub` as an `Effect`, returning whether the
@@ -23607,7 +23876,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
23607
23876
  self.subscribers.delete(self.subscription);
23608
23877
  self.subscription.unsubscribe();
23609
23878
  self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
23610
- })), when(self.shutdownHook.open), asVoid);
23879
+ })), when$2(self.shutdownHook.open), asVoid);
23611
23880
  }));
23612
23881
  /**
23613
23882
  * Takes a single message from the subscription. If no messages are available,
@@ -23642,7 +23911,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
23642
23911
  * @category subscriptions
23643
23912
  * @since 4.0.0
23644
23913
  */
23645
- const take$2 = (self) => suspend$2(() => {
23914
+ const take$3 = (self) => suspend$2(() => {
23646
23915
  if (self.shutdownFlag.current) return interrupt$1;
23647
23916
  if (self.replayWindow.remaining > 0) return succeed$3(self.replayWindow.take());
23648
23917
  const message = self.pollers.length === 0 ? self.subscription.poll() : Empty$2;
@@ -24317,7 +24586,7 @@ var SubscriptionImpl = class {
24317
24586
  }
24318
24587
  };
24319
24588
  var PubSubImpl = class {
24320
- [TypeId$36] = { _A: identity };
24589
+ [TypeId$37] = { _A: identity };
24321
24590
  pubsub;
24322
24591
  subscribers;
24323
24592
  scope;
@@ -24388,7 +24657,7 @@ var BackPressureStrategy = class {
24388
24657
  onPubSubEmptySpaceUnsafe(pubsub, subscribers) {
24389
24658
  let keepPolling = true;
24390
24659
  while (keepPolling && !pubsub.isFull()) {
24391
- const publisher = take$3(this.publishers);
24660
+ const publisher = take$4(this.publishers);
24392
24661
  if (publisher === Empty$2) keepPolling = false;
24393
24662
  else {
24394
24663
  const [value, deferred] = publisher;
@@ -24500,7 +24769,7 @@ var DroppingStrategy = class {
24500
24769
  const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
24501
24770
  let keepPolling = true;
24502
24771
  while (keepPolling && !subscription.isEmpty()) {
24503
- const poller = take$3(pollers);
24772
+ const poller = take$4(pollers);
24504
24773
  if (poller === Empty$2) {
24505
24774
  removeSubscribers(subscribers, subscription, pollers);
24506
24775
  if (pollers.length === 0) keepPolling = false;
@@ -24664,7 +24933,7 @@ const emptyReplayWindow = {
24664
24933
  *
24665
24934
  * @since 3.8.0
24666
24935
  */
24667
- const TypeId$35 = "~effect/Queue";
24936
+ const TypeId$36 = "~effect/Queue";
24668
24937
  const EnqueueTypeId = "~effect/Queue/Enqueue";
24669
24938
  const DequeueTypeId = "~effect/Queue/Dequeue";
24670
24939
  const variance$1 = {
@@ -24672,7 +24941,7 @@ const variance$1 = {
24672
24941
  _E: identity
24673
24942
  };
24674
24943
  const QueueProto = {
24675
- [TypeId$35]: variance$1,
24944
+ [TypeId$36]: variance$1,
24676
24945
  [EnqueueTypeId]: variance$1,
24677
24946
  [DequeueTypeId]: variance$1,
24678
24947
  ...PipeInspectableProto,
@@ -24771,6 +25040,43 @@ const make$48 = (options) => withFiber$1((fiber) => {
24771
25040
  */
24772
25041
  const bounded = (capacity) => make$48({ capacity });
24773
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
+ /**
24774
25080
  * Creates an unbounded queue that can grow to any size without blocking producers.
24775
25081
  *
24776
25082
  * **When to use**
@@ -24849,7 +25155,7 @@ const offer = (self, message) => suspend$3(() => {
24849
25155
  }
24850
25156
  return offerRemainingSingle(self, message);
24851
25157
  case "sliding":
24852
- take$3(self.messages);
25158
+ take$4(self.messages);
24853
25159
  append(self.messages, message);
24854
25160
  return exitTrue;
24855
25161
  }
@@ -24892,7 +25198,7 @@ const offerUnsafe = (self, message) => {
24892
25198
  if (self.state._tag !== "Open") return false;
24893
25199
  else if (self.messages.length >= self.capacity) {
24894
25200
  if (self.strategy === "sliding") {
24895
- take$3(self.messages);
25201
+ take$4(self.messages);
24896
25202
  append(self.messages, message);
24897
25203
  return true;
24898
25204
  } else if (self.capacity <= 0 && self.state.takers.size > 0) {
@@ -25255,7 +25561,7 @@ const takeBetween = (self, min, max) => suspend$3(() => takeBetweenUnsafe(self,
25255
25561
  * @category taking
25256
25562
  * @since 2.0.0
25257
25563
  */
25258
- 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)));
25259
25565
  /**
25260
25566
  * Attempts to take one message from the queue synchronously.
25261
25567
  *
@@ -25297,14 +25603,14 @@ const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake
25297
25603
  const takeUnsafe = (self) => {
25298
25604
  if (self.state._tag === "Done") return self.state.exit;
25299
25605
  if (self.messages.length > 0) {
25300
- const message = take$3(self.messages);
25606
+ const message = take$4(self.messages);
25301
25607
  releaseCapacity(self);
25302
25608
  return exitSucceed(message);
25303
25609
  } else if (self.capacity <= 0 && self.state.offers.size > 0) {
25304
25610
  self.capacity = 1;
25305
25611
  releaseCapacity(self);
25306
25612
  self.capacity = 0;
25307
- const message = take$3(self.messages);
25613
+ const message = take$4(self.messages);
25308
25614
  releaseCapacity(self);
25309
25615
  return exitSucceed(message);
25310
25616
  }
@@ -25376,7 +25682,7 @@ const takeBetweenUnsafe = (self, min, max) => {
25376
25682
  self.capacity = 1;
25377
25683
  releaseCapacity(self);
25378
25684
  self.capacity = 0;
25379
- const messages = [take$3(self.messages)];
25685
+ const messages = [take$4(self.messages)];
25380
25686
  releaseCapacity(self);
25381
25687
  return exitSucceed(messages);
25382
25688
  }
@@ -25698,7 +26004,7 @@ const withPermit = (self, effect) => {
25698
26004
  * @category type IDs
25699
26005
  * @since 4.0.0
25700
26006
  */
25701
- const TypeId$34 = "~effect/Channel";
26007
+ const TypeId$35 = "~effect/Channel";
25702
26008
  /**
25703
26009
  * Checks whether a value is a `Channel`.
25704
26010
  *
@@ -25715,9 +26021,9 @@ const TypeId$34 = "~effect/Channel";
25715
26021
  * @category guards
25716
26022
  * @since 3.5.4
25717
26023
  */
25718
- const isChannel = (u) => hasProperty(u, TypeId$34);
26024
+ const isChannel = (u) => hasProperty(u, TypeId$35);
25719
26025
  const ChannelProto = {
25720
- [TypeId$34]: {
26026
+ [TypeId$35]: {
25721
26027
  _Env: identity,
25722
26028
  _InErr: identity,
25723
26029
  _InElem: identity,
@@ -26535,7 +26841,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26535
26841
  } else {
26536
26842
  const effects = yield* bounded(concurrencyN - 2);
26537
26843
  yield* addFinalizer$1(forkedScope, shutdown(queue));
26538
- 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));
26539
26845
  let errorCause;
26540
26846
  const onExit = (exit) => {
26541
26847
  if (exit._tag === "Success") return;
@@ -26550,7 +26856,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26550
26856
  return offer(effects, join$1(fiber));
26551
26857
  }), forever({ disableYield: true }), catchCause$1((cause) => offer(effects, failCause$3(cause)).pipe(andThen(failCause$1(effects, cause)))), forkIn(forkedScope));
26552
26858
  }
26553
- return take$1(queue);
26859
+ return take$2(queue);
26554
26860
  }));
26555
26861
  /**
26556
26862
  * Maps each output element to a channel and flattens the child channel
@@ -26701,26 +27007,6 @@ const filterArray = /*#__PURE__*/ dual(2, (self, predicate) => transformPull$1(s
26701
27007
  return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
26702
27008
  }))));
26703
27009
  /**
26704
- * Filters and maps each element inside emitted non-empty arrays using a
26705
- * `Filter`.
26706
- *
26707
- * **Details**
26708
- *
26709
- * Successful filter results are kept as mapped values. Failed filter results
26710
- * are removed from the array. Arrays that become empty are discarded.
26711
- *
26712
- * @category filtering
26713
- * @since 4.0.0
26714
- */
26715
- const filterMapArray = /*#__PURE__*/ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$2(pull, function loop(arr) {
26716
- const passes = [];
26717
- for (let i = 0; i < arr.length; i++) {
26718
- const result = filter(arr[i]);
26719
- if (isSuccess$1(result)) passes.push(result.success);
26720
- }
26721
- return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
26722
- }))));
26723
- /**
26724
27010
  * Catches any cause of failure from the channel and allows recovery by
26725
27011
  * creating a new channel based on the caught cause.
26726
27012
  *
@@ -26889,7 +27175,7 @@ const mergeAll = /*#__PURE__*/ dual(2, (channels, { bufferSize = 16, concurrency
26889
27175
  fibers.add(fiber);
26890
27176
  }
26891
27177
  }).pipe(catchCause$1((cause) => doneLatch.whenOpen(failCause$1(queue, cause))), forkIn(forkedScope));
26892
- return take$1(queue);
27178
+ return take$2(queue);
26893
27179
  })));
26894
27180
  /**
26895
27181
  * Returns a new channel, which is the merge of this channel and the specified
@@ -26938,7 +27224,7 @@ const merge$2 = /*#__PURE__*/ dual((args) => isChannel(args[0]) && isChannel(arg
26938
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));
26939
27225
  yield* runSide("left", left, forkUnsafe(forkedScope));
26940
27226
  yield* runSide("right", right, forkUnsafe(forkedScope));
26941
- return take$1(queue);
27227
+ return take$2(queue);
26942
27228
  })));
26943
27229
  /**
26944
27230
  * Splits upstream string chunks into lines, recognizing `\n`, `\r\n`, and
@@ -27297,14 +27583,14 @@ const runFold = /*#__PURE__*/ dual(3, (self, initial, f) => suspend$2(() => {
27297
27583
  const toPullScoped = (self, scope) => toTransform(self)(done(), scope);
27298
27584
  //#endregion
27299
27585
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/stream.js
27300
- const TypeId$33 = "~effect/Stream";
27586
+ const TypeId$34 = "~effect/Stream";
27301
27587
  const streamVariance = {
27302
27588
  _R: identity,
27303
27589
  _E: identity,
27304
27590
  _A: identity
27305
27591
  };
27306
27592
  const StreamProto = {
27307
- [TypeId$33]: streamVariance,
27593
+ [TypeId$34]: streamVariance,
27308
27594
  pipe() {
27309
27595
  return pipeArguments(this, arguments);
27310
27596
  }
@@ -27317,7 +27603,7 @@ const fromChannel$2 = (channel) => {
27317
27603
  };
27318
27604
  //#endregion
27319
27605
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Sink.js
27320
- const TypeId$32 = "~effect/Sink";
27606
+ const TypeId$33 = "~effect/Sink";
27321
27607
  const endVoid = /*#__PURE__*/ succeed$3([void 0]);
27322
27608
  const sinkVariance = {
27323
27609
  _A: identity,
@@ -27327,7 +27613,7 @@ const sinkVariance = {
27327
27613
  _R: identity
27328
27614
  };
27329
27615
  const SinkProto = {
27330
- [TypeId$32]: sinkVariance,
27616
+ [TypeId$33]: sinkVariance,
27331
27617
  pipe() {
27332
27618
  return pipeArguments(this, arguments);
27333
27619
  }
@@ -27350,7 +27636,7 @@ const SinkProto = {
27350
27636
  * @category guards
27351
27637
  * @since 4.0.0
27352
27638
  */
27353
- const isSink = (u) => hasProperty(u, TypeId$32);
27639
+ const isSink = (u) => hasProperty(u, TypeId$33);
27354
27640
  /**
27355
27641
  * Creates a sink from a `Channel`.
27356
27642
  *
@@ -27414,6 +27700,38 @@ const toChannel$1 = (self) => fromTransform$1((upstream, scope) => succeed$3(fla
27414
27700
  */
27415
27701
  const drain = /*#__PURE__*/ fromTransform((upstream) => catchDone(forever(upstream, { disableYield: true }), () => endVoid));
27416
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
+ /**
27417
27735
  * A sink that executes the provided effectful function for every item fed
27418
27736
  * to it.
27419
27737
  *
@@ -27499,9 +27817,9 @@ const forEachArray = (f) => fromTransform((upstream) => upstream.pipe(flatMap$2(
27499
27817
  const unwrap$2 = (effect) => fromChannel$1(unwrap$3(map$4(effect, toChannel$1)));
27500
27818
  //#endregion
27501
27819
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/MutableHashMap.js
27502
- const TypeId$31 = "~effect/collections/MutableHashMap";
27820
+ const TypeId$32 = "~effect/collections/MutableHashMap";
27503
27821
  const MutableHashMapProto = {
27504
- [TypeId$31]: TypeId$31,
27822
+ [TypeId$32]: TypeId$32,
27505
27823
  [Symbol.iterator]() {
27506
27824
  return this.backing[Symbol.iterator]();
27507
27825
  },
@@ -27869,9 +28187,9 @@ const size = (self) => self.backing.size;
27869
28187
  *
27870
28188
  * @since 3.5.0
27871
28189
  */
27872
- const TypeId$30 = "~effect/RcMap";
28190
+ const TypeId$31 = "~effect/RcMap";
27873
28191
  const makeUnsafe$2 = (options) => ({
27874
- [TypeId$30]: TypeId$30,
28192
+ [TypeId$31]: TypeId$31,
27875
28193
  lookup: options.lookup,
27876
28194
  context: options.context,
27877
28195
  scope: options.scope,
@@ -28048,7 +28366,7 @@ const release = (self, key, entry) => withFiber((fiber) => {
28048
28366
  });
28049
28367
  //#endregion
28050
28368
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/rcRef.js
28051
- const TypeId$29 = "~effect/RcRef";
28369
+ const TypeId$30 = "~effect/RcRef";
28052
28370
  const stateEmpty = { _tag: "Empty" };
28053
28371
  const stateClosed = { _tag: "Closed" };
28054
28372
  const variance = {
@@ -28056,7 +28374,7 @@ const variance = {
28056
28374
  _E: identity
28057
28375
  };
28058
28376
  var RcRefImpl = class {
28059
- [TypeId$29] = variance;
28377
+ [TypeId$30] = variance;
28060
28378
  pipe() {
28061
28379
  return pipeArguments(this, arguments);
28062
28380
  }
@@ -28321,7 +28639,7 @@ const get$4 = get$5;
28321
28639
  * @category type IDs
28322
28640
  * @since 4.0.0
28323
28641
  */
28324
- const TypeId$28 = "~effect/Stream";
28642
+ const TypeId$29 = "~effect/Stream";
28325
28643
  /**
28326
28644
  * Checks whether a value is a Stream.
28327
28645
  *
@@ -28346,7 +28664,7 @@ const TypeId$28 = "~effect/Stream";
28346
28664
  * @category guards
28347
28665
  * @since 4.0.0
28348
28666
  */
28349
- const isStream = (u) => hasProperty(u, TypeId$28);
28667
+ const isStream = (u) => hasProperty(u, TypeId$29);
28350
28668
  /**
28351
28669
  * Creates a stream from a array-emitting `Channel`.
28352
28670
  *
@@ -29019,26 +29337,6 @@ const merge$1 = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[
29019
29337
  * @since 2.0.0
29020
29338
  */
29021
29339
  const filter = /*#__PURE__*/ dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
29022
- /**
29023
- * Filters and maps stream elements in one pass using a `Filter`.
29024
- *
29025
- * **When to use**
29026
- *
29027
- * Use to keep only stream elements accepted by a `Filter` and emit each filter
29028
- * success value.
29029
- *
29030
- * **Details**
29031
- *
29032
- * `Result.succeed` values are emitted and `Result.fail` values are skipped.
29033
- *
29034
- * @see {@link filter} for keeping original elements with a boolean predicate or refinement
29035
- * @see {@link filterMapEffect} for an effectful `Filter`
29036
- * @see {@link partition} for consuming both filter success and failure values
29037
- *
29038
- * @category filtering
29039
- * @since 2.0.0
29040
- */
29041
- const filterMap = /*#__PURE__*/ dual(2, (self, filter) => fromChannel(filterMapArray(toChannel(self), filter)));
29042
29340
  const catch_ = /*#__PURE__*/ dual(2, (self, f) => fromChannel(catch_$1(self.channel, (error) => f(error).channel)));
29043
29341
  /**
29044
29342
  * Turns typed failures into defects, making the stream infallible.
@@ -29242,6 +29540,31 @@ const debounce = /*#__PURE__*/ dual(2, (self, duration) => transformPull(self, f
29242
29540
  });
29243
29541
  })));
29244
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
+ /**
29245
29568
  * Applies a sink transducer to the stream and emits each sink result.
29246
29569
  *
29247
29570
  * **Example** (Transducing with a sink)
@@ -29284,6 +29607,78 @@ const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (ups
29284
29607
  return suspend$2(() => done$5 ? done$5 : pull);
29285
29608
  })));
29286
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
+ /**
29287
29682
  * Returns a stream that only emits elements that are not equal to the previously emitted element, as determined by the specified predicate.
29288
29683
  *
29289
29684
  * **Example** (Emitting values that changed by equivalence)
@@ -29722,7 +30117,7 @@ const toReadableStreamEffect = /*#__PURE__*/ dual((args) => isStream(args[0]), (
29722
30117
  *
29723
30118
  * @since 4.0.0
29724
30119
  */
29725
- const TypeId$27 = "~effect/platform/FileSystem";
30120
+ const TypeId$28 = "~effect/platform/FileSystem";
29726
30121
  /**
29727
30122
  * Creates a `Size` from various numeric input types.
29728
30123
  *
@@ -29832,7 +30227,7 @@ const FileSystem = /*#__PURE__*/ Service("effect/platform/FileSystem");
29832
30227
  */
29833
30228
  const make$42 = (impl) => FileSystem.of({
29834
30229
  ...impl,
29835
- [TypeId$27]: TypeId$27,
30230
+ [TypeId$28]: TypeId$28,
29836
30231
  exists: (path) => pipe(impl.access(path), as(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed$3(false) : fail$3(e))),
29837
30232
  readFileString: (path, encoding) => flatMap$2(impl.readFile(path), (_) => try_({
29838
30233
  try: () => new TextDecoder(encoding).decode(_),
@@ -30006,7 +30401,7 @@ var WatchBackend = class extends Service()("effect/platform/FileSystem/WatchBack
30006
30401
  * @category type IDs
30007
30402
  * @since 4.0.0
30008
30403
  */
30009
- const TypeId$26 = "~effect/platform/Path";
30404
+ const TypeId$27 = "~effect/platform/Path";
30010
30405
  /**
30011
30406
  * Service tag for accessing the current `Path` implementation.
30012
30407
  *
@@ -30199,7 +30594,7 @@ var ChildProcessSpawner = class extends Service()("effect/process/ChildProcessSp
30199
30594
  *
30200
30595
  * @since 4.0.0
30201
30596
  */
30202
- const TypeId$25 = "~effect/unstable/process/ChildProcess";
30597
+ const TypeId$26 = "~effect/unstable/process/ChildProcess";
30203
30598
  const Proto$12 = {
30204
30599
  .../*#__PURE__*/ Prototype({
30205
30600
  label: "Command",
@@ -30207,7 +30602,7 @@ const Proto$12 = {
30207
30602
  return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this);
30208
30603
  }
30209
30604
  }),
30210
- [TypeId$25]: TypeId$25
30605
+ [TypeId$26]: TypeId$26
30211
30606
  };
30212
30607
  const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$12), {
30213
30608
  _tag: "StandardCommand",
@@ -32481,9 +32876,9 @@ const recur$1 = /*#__PURE__*/ memoize((ast) => {
32481
32876
  //#endregion
32482
32877
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/schema/schema.js
32483
32878
  /** @internal */
32484
- const TypeId$24 = "~effect/Schema/Schema";
32879
+ const TypeId$25 = "~effect/Schema/Schema";
32485
32880
  const SchemaProto = {
32486
- [TypeId$24]: TypeId$24,
32881
+ [TypeId$25]: TypeId$25,
32487
32882
  pipe() {
32488
32883
  return pipeArguments(this, arguments);
32489
32884
  },
@@ -32554,7 +32949,7 @@ function makeReorder(getPriority) {
32554
32949
  }
32555
32950
  //#endregion
32556
32951
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Schema.js
32557
- const TypeId$23 = TypeId$24;
32952
+ const TypeId$24 = TypeId$25;
32558
32953
  /**
32559
32954
  * Creates a schema for a **parametric** type (a generic container such as
32560
32955
  * `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
@@ -32827,7 +33222,7 @@ const make$35 = make$36;
32827
33222
  * @since 3.10.0
32828
33223
  */
32829
33224
  function isSchema(u) {
32830
- return hasProperty(u, TypeId$23) && u[TypeId$23] === TypeId$23;
33225
+ return hasProperty(u, TypeId$24) && u[TypeId$24] === TypeId$24;
32831
33226
  }
32832
33227
  /**
32833
33228
  * Creates an exact optional key schema for struct fields. Unlike `optional`,
@@ -32936,6 +33331,14 @@ const Any = /*#__PURE__*/ make$35(any);
32936
33331
  */
32937
33332
  const Unknown = /*#__PURE__*/ make$35(unknown);
32938
33333
  /**
33334
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
33335
+ *
33336
+ * @see {@link NullOr} for a union with another schema.
33337
+ * @category schemas
33338
+ * @since 3.10.0
33339
+ */
33340
+ const Null = /*#__PURE__*/ make$35(null_);
33341
+ /**
32939
33342
  * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
32940
33343
  *
32941
33344
  * @see {@link UndefinedOr} for a union with another schema.
@@ -33141,6 +33544,13 @@ function Literals(literals) {
33141
33544
  });
33142
33545
  }
33143
33546
  /**
33547
+ * Creates a union schema of `S | null`.
33548
+ *
33549
+ * @category constructors
33550
+ * @since 3.10.0
33551
+ */
33552
+ const NullOr = /*#__PURE__*/ lambda((self) => Union([self, Null]));
33553
+ /**
33144
33554
  * Creates a union schema of `S | undefined`.
33145
33555
  *
33146
33556
  * @category constructors
@@ -33875,7 +34285,7 @@ function makeClass(Inherited, identifier, struct$1, annotations, proto) {
33875
34285
  disableChecks: true
33876
34286
  });
33877
34287
  }
33878
- static [TypeId$23] = TypeId$23;
34288
+ static [TypeId$24] = TypeId$24;
33879
34289
  get [ClassTypeId]() {
33880
34290
  return ClassTypeId;
33881
34291
  }
@@ -34275,11 +34685,11 @@ function onSerializerEnsureArray(ast) {
34275
34685
  *
34276
34686
  * @since 4.0.0
34277
34687
  */
34278
- const TypeId$22 = "~effect/http/Cookies";
34688
+ const TypeId$23 = "~effect/http/Cookies";
34279
34689
  const CookieTypeId = "~effect/http/Cookies/Cookie";
34280
34690
  TaggedError("CookieError");
34281
34691
  const Proto$11 = {
34282
- [TypeId$22]: TypeId$22,
34692
+ [TypeId$23]: TypeId$23,
34283
34693
  ...BaseProto,
34284
34694
  toJSON() {
34285
34695
  return {
@@ -34604,10 +35014,10 @@ const tryDecodeURIComponent = (str) => {
34604
35014
  * @category type IDs
34605
35015
  * @since 4.0.0
34606
35016
  */
34607
- const TypeId$21 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
35017
+ const TypeId$22 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
34608
35018
  const Proto$10 = /*#__PURE__*/ Object.create(null);
34609
35019
  Object.defineProperties(Proto$10, {
34610
- [TypeId$21]: { value: TypeId$21 },
35020
+ [TypeId$22]: { value: TypeId$22 },
34611
35021
  [symbolRedactable]: { value(context) {
34612
35022
  return redact(this, get$9(context, CurrentRedactedNames));
34613
35023
  } },
@@ -34802,7 +35212,7 @@ const CurrentRedactedNames = /*#__PURE__*/ Reference("effect/Headers/CurrentReda
34802
35212
  *
34803
35213
  * @since 4.0.0
34804
35214
  */
34805
- const TypeId$20 = "~effect/http/HttpClientError";
35215
+ const TypeId$21 = "~effect/http/HttpClientError";
34806
35216
  /**
34807
35217
  * Error wrapper for HTTP client failures, exposing the failed request and the optional response through its `reason`.
34808
35218
  *
@@ -34822,7 +35232,7 @@ var HttpClientError = class extends TaggedError("HttpClientError") {
34822
35232
  *
34823
35233
  * @since 4.0.0
34824
35234
  */
34825
- [TypeId$20] = TypeId$20;
35235
+ [TypeId$21] = TypeId$21;
34826
35236
  /**
34827
35237
  * HTTP request associated with the client failure.
34828
35238
  *
@@ -34945,7 +35355,7 @@ var EmptyBodyError = class extends TaggedError("EmptyBodyError") {
34945
35355
  return formatMessage(formatReason(this._tag), this.description, info);
34946
35356
  }
34947
35357
  };
34948
- ErrorClass(TypeId$20)({
35358
+ ErrorClass(TypeId$21)({
34949
35359
  _tag: /*#__PURE__*/ tag("HttpError"),
34950
35360
  kind: /*#__PURE__*/ Literals([
34951
35361
  "EncodeError",
@@ -34997,10 +35407,10 @@ ErrorClass(TypeId$20)({
34997
35407
  *
34998
35408
  * @since 4.0.0
34999
35409
  */
35000
- const TypeId$19 = "~effect/http/UrlParams";
35410
+ const TypeId$20 = "~effect/http/UrlParams";
35001
35411
  const Proto$9 = {
35002
35412
  ...PipeInspectableProto,
35003
- [TypeId$19]: TypeId$19,
35413
+ [TypeId$20]: TypeId$20,
35004
35414
  [Symbol.iterator]() {
35005
35415
  return this.params[Symbol.iterator]();
35006
35416
  },
@@ -35198,12 +35608,12 @@ const baseUrl = () => {
35198
35608
  *
35199
35609
  * @since 4.0.0
35200
35610
  */
35201
- const TypeId$18 = "~effect/http/HttpBody";
35611
+ const TypeId$19 = "~effect/http/HttpBody";
35202
35612
  TaggedError("HttpBodyError");
35203
35613
  var Proto$8 = class {
35204
- [TypeId$18];
35614
+ [TypeId$19];
35205
35615
  constructor() {
35206
- this[TypeId$18] = TypeId$18;
35616
+ this[TypeId$19] = TypeId$19;
35207
35617
  }
35208
35618
  [NodeInspectSymbol]() {
35209
35619
  return this.toJSON();
@@ -35430,9 +35840,9 @@ const allShort = [
35430
35840
  ];
35431
35841
  //#endregion
35432
35842
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpClientRequest.js
35433
- const TypeId$17 = "~effect/http/HttpClientRequest";
35843
+ const TypeId$18 = "~effect/http/HttpClientRequest";
35434
35844
  const Proto$7 = {
35435
- [TypeId$17]: TypeId$17,
35845
+ [TypeId$18]: TypeId$18,
35436
35846
  ...BaseProto,
35437
35847
  toJSON() {
35438
35848
  return {
@@ -35615,7 +36025,7 @@ const setBody$1 = /*#__PURE__*/ dual(2, (self, body) => {
35615
36025
  * @category type IDs
35616
36026
  * @since 4.0.0
35617
36027
  */
35618
- const TypeId$16 = "~effect/http/HttpIncomingMessage";
36028
+ const TypeId$17 = "~effect/http/HttpIncomingMessage";
35619
36029
  /**
35620
36030
  * Context reference for the optional maximum size allowed when reading an incoming message body.
35621
36031
  *
@@ -35693,7 +36103,7 @@ const inspect = (self, that) => {
35693
36103
  * @category type IDs
35694
36104
  * @since 4.0.0
35695
36105
  */
35696
- const TypeId$15 = "~effect/http/HttpClientResponse";
36106
+ const TypeId$16 = "~effect/http/HttpClientResponse";
35697
36107
  /**
35698
36108
  * Wraps a Web `Response` and its original `HttpClientRequest` as an `HttpClientResponse`.
35699
36109
  *
@@ -35702,16 +36112,16 @@ const TypeId$15 = "~effect/http/HttpClientResponse";
35702
36112
  */
35703
36113
  const fromWeb$1 = (request, source) => new WebHttpClientResponse(request, source);
35704
36114
  var WebHttpClientResponse = class extends Class$2 {
36115
+ [TypeId$17];
35705
36116
  [TypeId$16];
35706
- [TypeId$15];
35707
36117
  request;
35708
36118
  source;
35709
36119
  constructor(request, source) {
35710
36120
  super();
35711
36121
  this.request = request;
35712
36122
  this.source = source;
36123
+ this[TypeId$17] = TypeId$17;
35713
36124
  this[TypeId$16] = TypeId$16;
35714
- this[TypeId$15] = TypeId$15;
35715
36125
  }
35716
36126
  toJSON() {
35717
36127
  return inspect(this, {
@@ -35953,7 +36363,7 @@ const w3c = (headers) => {
35953
36363
  };
35954
36364
  //#endregion
35955
36365
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpClient.js
35956
- const TypeId$14 = "~effect/http/HttpClient";
36366
+ const TypeId$15 = "~effect/http/HttpClient";
35957
36367
  /**
35958
36368
  * Service tag for the default outgoing HTTP client service.
35959
36369
  *
@@ -35993,7 +36403,7 @@ const makeWith = (postprocess, preprocess) => {
35993
36403
  return self;
35994
36404
  };
35995
36405
  const Proto$6 = {
35996
- [TypeId$14]: TypeId$14,
36406
+ [TypeId$15]: TypeId$15,
35997
36407
  pipe() {
35998
36408
  return pipeArguments(this, arguments);
35999
36409
  },
@@ -36130,8 +36540,8 @@ var InterruptibleResponse = class {
36130
36540
  this.original = original;
36131
36541
  this.controller = controller;
36132
36542
  }
36133
- [TypeId$15] = TypeId$15;
36134
36543
  [TypeId$16] = TypeId$16;
36544
+ [TypeId$17] = TypeId$17;
36135
36545
  applyInterrupt(effect) {
36136
36546
  return suspend$2(() => {
36137
36547
  responseRegistry.unregister(this.original);
@@ -36815,14 +37225,14 @@ const make$29 = make$30;
36815
37225
  const ignore = "~effect/ErrorReporter/ignore";
36816
37226
  //#endregion
36817
37227
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/http/HttpServerResponse.js
36818
- const TypeId$13 = "~effect/http/HttpServerResponse";
37228
+ const TypeId$14 = "~effect/http/HttpServerResponse";
36819
37229
  /**
36820
37230
  * Returns `true` when the supplied value is an `HttpServerResponse`.
36821
37231
  *
36822
37232
  * @category guards
36823
37233
  * @since 4.0.0
36824
37234
  */
36825
- const isHttpServerResponse = (u) => hasProperty(u, TypeId$13);
37235
+ const isHttpServerResponse = (u) => hasProperty(u, TypeId$14);
36826
37236
  /**
36827
37237
  * Creates an empty HTTP response.
36828
37238
  *
@@ -36955,7 +37365,7 @@ const setBody = /*#__PURE__*/ dual(2, (self, body) => makeResponse({
36955
37365
  }));
36956
37366
  const Proto$5 = {
36957
37367
  ...PipeInspectableProto,
36958
- [TypeId$13]: TypeId$13,
37368
+ [TypeId$14]: TypeId$14,
36959
37369
  [ignore]: true,
36960
37370
  toJSON() {
36961
37371
  return {
@@ -37153,7 +37563,7 @@ const toResponseOrElseDefect = (u, orElse) => {
37153
37563
  *
37154
37564
  * @since 4.0.0
37155
37565
  */
37156
- const TypeId$12 = "~effect/http/HttpServerError";
37566
+ const TypeId$13 = "~effect/http/HttpServerError";
37157
37567
  /**
37158
37568
  * Tagged error for failures that occur while handling an HTTP server request.
37159
37569
  *
@@ -37174,7 +37584,7 @@ var HttpServerError = class extends TaggedError("HttpServerError") {
37174
37584
  });
37175
37585
  else super(props);
37176
37586
  }
37177
- [TypeId$12] = TypeId$12;
37587
+ [TypeId$13] = TypeId$13;
37178
37588
  stack = `${this.name}: ${this.message}`;
37179
37589
  get request() {
37180
37590
  return this.reason.request;
@@ -37450,7 +37860,7 @@ const exitResponse = (exit) => {
37450
37860
  *
37451
37861
  * @since 2.0.0
37452
37862
  */
37453
- const TypeId$11 = "~effect/FiberSet";
37863
+ const TypeId$12 = "~effect/FiberSet";
37454
37864
  /**
37455
37865
  * Checks whether a value is a FiberSet.
37456
37866
  *
@@ -37470,9 +37880,9 @@ const TypeId$11 = "~effect/FiberSet";
37470
37880
  * @category refinements
37471
37881
  * @since 2.0.0
37472
37882
  */
37473
- const isFiberSet = (u) => hasProperty(u, TypeId$11);
37883
+ const isFiberSet = (u) => hasProperty(u, TypeId$12);
37474
37884
  const Proto$4 = {
37475
- [TypeId$11]: TypeId$11,
37885
+ [TypeId$12]: TypeId$12,
37476
37886
  [Symbol.iterator]() {
37477
37887
  if (this.state._tag === "Closed") return empty$14();
37478
37888
  return this.state.backing[Symbol.iterator]();
@@ -37651,7 +38061,7 @@ const join = (self) => _await(self.deferred);
37651
38061
  * @category type IDs
37652
38062
  * @since 4.0.0
37653
38063
  */
37654
- const TypeId$10 = "~effect/socket/Socket";
38064
+ const TypeId$11 = "~effect/socket/Socket";
37655
38065
  /**
37656
38066
  * Service tag for bidirectional socket transports.
37657
38067
  *
@@ -37672,7 +38082,7 @@ const Socket = /*#__PURE__*/ Service("effect/socket/Socket");
37672
38082
  * @since 4.0.0
37673
38083
  */
37674
38084
  const make$27 = (options) => Socket.of({
37675
- [TypeId$10]: TypeId$10,
38085
+ [TypeId$11]: TypeId$11,
37676
38086
  runRaw: options.runRaw,
37677
38087
  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)),
37678
38088
  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)),
@@ -38919,7 +39329,7 @@ const decodeField = decodeField$1;
38919
39329
  * @category type IDs
38920
39330
  * @since 4.0.0
38921
39331
  */
38922
- const TypeId$9 = "~effect/http/Multipart";
39332
+ const TypeId$10 = "~effect/http/Multipart";
38923
39333
  const MultipartErrorTypeId = "~effect/http/Multipart/MultipartError";
38924
39334
  /**
38925
39335
  * Error reason carried by a `MultipartError`.
@@ -38994,10 +39404,10 @@ const makeConfig = (headers) => withFiber((fiber) => {
38994
39404
  });
38995
39405
  });
38996
39406
  var PartBase$1 = class extends Class$2 {
38997
- [TypeId$9];
39407
+ [TypeId$10];
38998
39408
  constructor() {
38999
39409
  super();
39000
- this[TypeId$9] = TypeId$9;
39410
+ this[TypeId$10] = TypeId$10;
39001
39411
  }
39002
39412
  };
39003
39413
  const defaultWriteFile = (path, file) => flatMap$2(FileSystem, (fs) => mapError$2(run$1(file.content, fs.sink(path)), (cause) => MultipartError.fromReason("InternalError", cause)));
@@ -39114,7 +39524,7 @@ const FieldMimeTypes = /*#__PURE__*/ Reference("effect/http/Multipart/FieldMimeT
39114
39524
  * @category type IDs
39115
39525
  * @since 4.0.0
39116
39526
  */
39117
- const TypeId$8 = "~effect/http/HttpServerRequest";
39527
+ const TypeId$9 = "~effect/http/HttpServerRequest";
39118
39528
  /**
39119
39529
  * Service tag for the active server-side HTTP request.
39120
39530
  *
@@ -39770,7 +40180,7 @@ const withLogAddress = (layer) => effectDiscard(logAddress).pipe(provideMerge(la
39770
40180
  *
39771
40181
  * @since 4.0.0
39772
40182
  */
39773
- const TypeId$7 = "~effect/http/HttpRouter";
40183
+ const TypeId$8 = "~effect/http/HttpRouter";
39774
40184
  /**
39775
40185
  * Service tag for the HTTP router used while constructing an HTTP application.
39776
40186
  * Route and middleware layers require this service to register themselves with
@@ -39817,7 +40227,7 @@ const make$19 = /*#__PURE__*/ gen(function* () {
39817
40227
  return void_$1;
39818
40228
  });
39819
40229
  return HttpRouter.of({
39820
- [TypeId$7]: TypeId$7,
40230
+ [TypeId$8]: TypeId$8,
39821
40231
  prefixed(prefix) {
39822
40232
  return HttpRouter.of({
39823
40233
  ...this,
@@ -40272,7 +40682,7 @@ var ClientAbort = class extends Service()("effect/rpc/RpcSchema/ClientAbort") {
40272
40682
  };
40273
40683
  //#endregion
40274
40684
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/unstable/rpc/Rpc.js
40275
- const TypeId$6 = "~effect/rpc/Rpc";
40685
+ const TypeId$7 = "~effect/rpc/Rpc";
40276
40686
  /**
40277
40687
  * Represents server-side metadata for the client associated with an RPC request.
40278
40688
  *
@@ -40302,7 +40712,7 @@ var ServerClient = class {
40302
40712
  }
40303
40713
  };
40304
40714
  const Proto$3 = {
40305
- [TypeId$6]: TypeId$6,
40715
+ [TypeId$7]: TypeId$7,
40306
40716
  pipe() {
40307
40717
  return pipeArguments(this, arguments);
40308
40718
  },
@@ -43045,7 +43455,7 @@ const withRun = () => (f) => suspend$2(() => {
43045
43455
  * @category type IDs
43046
43456
  * @since 4.0.0
43047
43457
  */
43048
- const TypeId$5 = "~effect/Stdio";
43458
+ const TypeId$6 = "~effect/Stdio";
43049
43459
  /**
43050
43460
  * Service tag for process standard I/O.
43051
43461
  *
@@ -43060,7 +43470,7 @@ const TypeId$5 = "~effect/Stdio";
43060
43470
  * @category services
43061
43471
  * @since 4.0.0
43062
43472
  */
43063
- const Stdio = /*#__PURE__*/ Service(TypeId$5);
43473
+ const Stdio = /*#__PURE__*/ Service(TypeId$6);
43064
43474
  /**
43065
43475
  * Creates a `Stdio` service implementation from the provided fields and
43066
43476
  * attaches the `Stdio` type identifier.
@@ -43082,7 +43492,7 @@ const Stdio = /*#__PURE__*/ Service(TypeId$5);
43082
43492
  * @since 4.0.0
43083
43493
  */
43084
43494
  const make$17 = (options) => ({
43085
- [TypeId$5]: TypeId$5,
43495
+ [TypeId$6]: TypeId$6,
43086
43496
  ...options
43087
43497
  });
43088
43498
  //#endregion
@@ -43380,7 +43790,7 @@ const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
43380
43790
  }).pipe(provide$3(scope));
43381
43791
  yield* forkChild(whileLoop({
43382
43792
  while: constTrue,
43383
- body: constant(flatMap$2(take$1(disconnects), (clientId) => {
43793
+ body: constant(flatMap$2(take$2(disconnects), (clientId) => {
43384
43794
  clients.delete(clientId);
43385
43795
  return server.disconnect(clientId);
43386
43796
  })),
@@ -44274,7 +44684,7 @@ function trieNodeAt(root, path) {
44274
44684
  }
44275
44685
  //#endregion
44276
44686
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Config.js
44277
- const TypeId$4 = "~effect/Config";
44687
+ const TypeId$5 = "~effect/Config";
44278
44688
  /**
44279
44689
  * Returns `true` if `u` is a `Config` instance.
44280
44690
  *
@@ -44295,7 +44705,7 @@ const TypeId$4 = "~effect/Config";
44295
44705
  * @category guards
44296
44706
  * @since 2.0.0
44297
44707
  */
44298
- const isConfig = (u) => hasProperty(u, TypeId$4);
44708
+ const isConfig = (u) => hasProperty(u, TypeId$5);
44299
44709
  /**
44300
44710
  * Represents the error type produced when config loading or validation fails.
44301
44711
  *
@@ -44339,7 +44749,7 @@ const Proto$1 = {
44339
44749
  return this.parse(fiber.getRef(ConfigProvider));
44340
44750
  }
44341
44751
  }),
44342
- [TypeId$4]: TypeId$4,
44752
+ [TypeId$5]: TypeId$5,
44343
44753
  toJSON() {
44344
44754
  return { _id: "Config" };
44345
44755
  }
@@ -44448,7 +44858,7 @@ const map = /*#__PURE__*/ dual(2, (self, f) => {
44448
44858
  * @category combinators
44449
44859
  * @since 2.0.0
44450
44860
  */
44451
- const orElse = /*#__PURE__*/ dual(2, (self, that) => {
44861
+ const orElse$2 = /*#__PURE__*/ dual(2, (self, that) => {
44452
44862
  return make$13((provider) => catch_$2(self.parse(provider), (error) => that(error).parse(provider)));
44453
44863
  });
44454
44864
  function isMissingDataOnly(issue) {
@@ -44502,7 +44912,7 @@ function isMissingDataOnly(issue) {
44502
44912
  * @since 2.0.0
44503
44913
  */
44504
44914
  const withDefault = /*#__PURE__*/ dual(2, (self, defaultValue) => {
44505
- return orElse(self, (err) => {
44915
+ return orElse$2(self, (err) => {
44506
44916
  if (isSchemaError(err.cause)) {
44507
44917
  const issue = err.cause.issue;
44508
44918
  if (isMissingDataOnly(issue)) return succeed(defaultValue);
@@ -48857,13 +49267,13 @@ var NodeHttpIncomingMessage = class extends Class$2 {
48857
49267
  *
48858
49268
  * @since 4.0.0
48859
49269
  */
48860
- [TypeId$16];
49270
+ [TypeId$17];
48861
49271
  source;
48862
49272
  onError;
48863
49273
  remoteAddressOverride;
48864
49274
  constructor(source, onError, remoteAddressOverride) {
48865
49275
  super();
48866
- this[TypeId$16] = TypeId$16;
49276
+ this[TypeId$17] = TypeId$17;
48867
49277
  this.source = source;
48868
49278
  this.onError = onError;
48869
49279
  this.remoteAddressOverride = remoteAddressOverride;
@@ -49251,10 +49661,10 @@ const persisted = (source, headers) => toPersisted(stream(source, headers), (pat
49251
49661
  }));
49252
49662
  const convertPart = (part) => part._tag === "Field" ? new FieldImpl(part.info, part.value) : new FileImpl(part);
49253
49663
  var PartBase = class extends Class$2 {
49254
- [TypeId$9];
49664
+ [TypeId$10];
49255
49665
  constructor() {
49256
49666
  super();
49257
- this[TypeId$9] = TypeId$9;
49667
+ this[TypeId$10] = TypeId$10;
49258
49668
  }
49259
49669
  };
49260
49670
  var FieldImpl = class extends PartBase {
@@ -49376,7 +49786,7 @@ function convertError(cause) {
49376
49786
  *
49377
49787
  * @since 4.0.0
49378
49788
  */
49379
- const TypeId$3 = "~effect/platform/Crypto";
49789
+ const TypeId$4 = "~effect/platform/Crypto";
49380
49790
  /**
49381
49791
  * Service tag for platform cryptography.
49382
49792
  *
@@ -49443,7 +49853,7 @@ const make$10 = (impl) => {
49443
49853
  };
49444
49854
  const nextIntUnsafe = () => Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;
49445
49855
  return Crypto.of({
49446
- [TypeId$3]: TypeId$3,
49856
+ [TypeId$4]: TypeId$4,
49447
49857
  randomBytes,
49448
49858
  nextDoubleUnsafe,
49449
49859
  nextIntUnsafe,
@@ -49663,7 +50073,7 @@ const toFileUrl = (path) => try_({
49663
50073
  * @since 4.0.0
49664
50074
  */
49665
50075
  const layer$11 = /* @__PURE__ */ succeed$4(Path$1)({
49666
- [TypeId$26]: TypeId$26,
50076
+ [TypeId$27]: TypeId$27,
49667
50077
  ...Path,
49668
50078
  fromFileUrl,
49669
50079
  toFileUrl
@@ -49739,7 +50149,7 @@ const layer$9 = /* @__PURE__ */ succeed$4(Stdio, /*#__PURE__*/ make$17({
49739
50149
  }));
49740
50150
  //#endregion
49741
50151
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Terminal.js
49742
- const TypeId$2 = "~effect/platform/Terminal";
50152
+ const TypeId$3 = "~effect/platform/Terminal";
49743
50153
  ErrorClass("QuitError")({ _tag: /*#__PURE__*/ tag("QuitError") });
49744
50154
  /**
49745
50155
  * Service tag for command-line input and output services.
@@ -49773,7 +50183,7 @@ const Terminal$1 = /*#__PURE__*/ Service("effect/platform/Terminal");
49773
50183
  */
49774
50184
  const make$8 = (impl) => Terminal$1.of({
49775
50185
  ...impl,
49776
- [TypeId$2]: TypeId$2
50186
+ [TypeId$3]: TypeId$3
49777
50187
  });
49778
50188
  /**
49779
50189
  * Provides the default process-backed `Terminal` service, ending key input on
@@ -50013,7 +50423,7 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
50013
50423
  });
50014
50424
  };
50015
50425
  var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage {
50016
- [TypeId$8];
50426
+ [TypeId$9];
50017
50427
  response;
50018
50428
  upgradeEffect;
50019
50429
  url;
@@ -50023,7 +50433,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
50023
50433
  request: this,
50024
50434
  cause
50025
50435
  }) }), remoteAddressOverride);
50026
- this[TypeId$8] = TypeId$8;
50436
+ this[TypeId$9] = TypeId$9;
50027
50437
  this.response = response;
50028
50438
  this.upgradeEffect = upgradeEffect;
50029
50439
  this.url = url;
@@ -50739,6 +51149,280 @@ const layer$5 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntra
50739
51149
  for (const logger of loggers) currentLoggers.add(isEffect$1(logger) ? yield* logger : logger);
50740
51150
  return currentLoggers;
50741
51151
  })));
51152
+ const ValueMatcherProto = {
51153
+ ["~effect/match/Match/Matcher"]: {
51154
+ _input: identity,
51155
+ _filters: identity,
51156
+ _result: identity,
51157
+ _return: identity
51158
+ },
51159
+ _tag: "ValueMatcher",
51160
+ add(_case) {
51161
+ if (isSuccess$1(this.value)) return this;
51162
+ if (_case._tag === "When" && _case.guard(this.provided) === true) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51163
+ else if (_case._tag === "Not" && _case.guard(this.provided) === false) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51164
+ return this;
51165
+ },
51166
+ pipe() {
51167
+ return pipeArguments(this, arguments);
51168
+ }
51169
+ };
51170
+ function makeValueMatcher(provided, value) {
51171
+ const matcher = Object.create(ValueMatcherProto);
51172
+ matcher.provided = provided;
51173
+ matcher.value = value;
51174
+ return matcher;
51175
+ }
51176
+ const makeWhen = (guard, evaluate) => ({
51177
+ _tag: "When",
51178
+ guard,
51179
+ evaluate
51180
+ });
51181
+ const makePredicate = (pattern) => {
51182
+ if (typeof pattern === "function") return pattern;
51183
+ else if (Array.isArray(pattern)) {
51184
+ const predicates = pattern.map(makePredicate);
51185
+ const len = predicates.length;
51186
+ return (u) => {
51187
+ if (!Array.isArray(u)) return false;
51188
+ for (let i = 0; i < len; i++) if (predicates[i](u[i]) === false) return false;
51189
+ return true;
51190
+ };
51191
+ } else if (pattern !== null && typeof pattern === "object") {
51192
+ const keysAndPredicates = Object.entries(pattern).map(([k, p]) => [k, makePredicate(p)]);
51193
+ const len = keysAndPredicates.length;
51194
+ return (u) => {
51195
+ if (typeof u !== "object" || u === null) return false;
51196
+ for (let i = 0; i < len; i++) {
51197
+ const [key, predicate] = keysAndPredicates[i];
51198
+ if (!(key in u) || predicate(u[key]) === false) return false;
51199
+ }
51200
+ return true;
51201
+ };
51202
+ }
51203
+ return (u) => u === pattern;
51204
+ };
51205
+ /** @internal */
51206
+ const value$1 = (i) => makeValueMatcher(i, fail$7(i));
51207
+ /** @internal */
51208
+ const when$1 = (pattern, f) => (self) => self.add(makeWhen(makePredicate(pattern), f));
51209
+ /** @internal */
51210
+ const orElse$1 = (f) => (self) => {
51211
+ const toResult = result(self);
51212
+ if (isResult(toResult)) return toResult._tag === "Success" ? toResult.success : f(toResult.failure);
51213
+ return (input) => {
51214
+ const a = toResult(input);
51215
+ return isSuccess$1(a) ? a.success : f(a.failure);
51216
+ };
51217
+ };
51218
+ /** @internal */
51219
+ const result = (self) => {
51220
+ if (self._tag === "ValueMatcher") return self.value;
51221
+ const len = self.cases.length;
51222
+ if (len === 1) {
51223
+ const _case = self.cases[0];
51224
+ return (input) => {
51225
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51226
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51227
+ return fail$7(input);
51228
+ };
51229
+ }
51230
+ return (input) => {
51231
+ for (let i = 0; i < len; i++) {
51232
+ const _case = self.cases[i];
51233
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51234
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51235
+ }
51236
+ return fail$7(input);
51237
+ };
51238
+ };
51239
+ //#endregion
51240
+ //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Match.js
51241
+ /**
51242
+ * Pattern matching for TypeScript values, predicates, and tagged unions.
51243
+ *
51244
+ * `Match` turns branching logic into a matcher that is built from ordered
51245
+ * cases and finished with an explicit finalizer. Use `Match.type` to define a
51246
+ * reusable matcher for a type, or `Match.value` to classify one value
51247
+ * immediately. Cases can match literal values, predicates, object patterns,
51248
+ * discriminators, tags, or negated patterns.
51249
+ *
51250
+ * **Mental model**
51251
+ *
51252
+ * A matcher checks cases in the order they are added and evaluates the handler
51253
+ * for the first match. Type matchers produce a function that can be reused with
51254
+ * different inputs, while value matchers already contain the input value. As
51255
+ * cases are added, the type system tracks which inputs remain unmatched, so
51256
+ * `Match.exhaustive` is only available when every remaining case has been
51257
+ * handled.
51258
+ *
51259
+ * **Common tasks**
51260
+ *
51261
+ * - Use `Match.type<Union>()` when a branch table should be reusable and
51262
+ * exhaustiveness-checked.
51263
+ * - Use `Match.value(value)` when a single value should be matched immediately.
51264
+ * - Use `Match.tag`, `Match.tags`, or `Match.discriminator` for discriminated
51265
+ * unions and domain objects with tag fields.
51266
+ * - Use `Match.orElse`, `Match.option`, or `Match.result` when unmatched input
51267
+ * should be handled explicitly instead of requiring full exhaustiveness.
51268
+ *
51269
+ * **Example** (Matching a tagged union)
51270
+ *
51271
+ * ```ts
51272
+ * import { Match } from "effect"
51273
+ *
51274
+ * type Event =
51275
+ * | { readonly _tag: "UserCreated"; readonly id: string }
51276
+ * | { readonly _tag: "UserDeleted"; readonly id: string }
51277
+ *
51278
+ * const describe = Match.type<Event>().pipe(
51279
+ * Match.tag("UserCreated", (event) => `created ${event.id}`),
51280
+ * Match.tag("UserDeleted", (event) => `deleted ${event.id}`),
51281
+ * Match.exhaustive
51282
+ * )
51283
+ * ```
51284
+ *
51285
+ * @since 4.0.0
51286
+ */
51287
+ /**
51288
+ * Creates a matcher from a specific value.
51289
+ *
51290
+ * **When to use**
51291
+ *
51292
+ * Use to match one concrete input immediately.
51293
+ *
51294
+ * **Details**
51295
+ *
51296
+ * This function allows you to define a `Matcher` directly from a given value,
51297
+ * rather than from a type. This is useful when working with known values,
51298
+ * enabling structured pattern matching on objects, primitives, or any data
51299
+ * structure.
51300
+ *
51301
+ * Once the matcher is created, you can use pattern-matching functions like
51302
+ * {@link when} to define how different cases should be handled.
51303
+ *
51304
+ * **Example** (Matching an Object by Property)
51305
+ *
51306
+ * ```ts
51307
+ * import { Match } from "effect"
51308
+ *
51309
+ * const input = { name: "John", age: 30 }
51310
+ *
51311
+ * // Create a matcher for the specific object
51312
+ * const result = Match.value(input).pipe(
51313
+ * // Match when the 'name' property is "John"
51314
+ * Match.when(
51315
+ * { name: "John" },
51316
+ * (user) => `${user.name} is ${user.age} years old`
51317
+ * ),
51318
+ * // Provide a fallback if no match is found
51319
+ * Match.orElse(() => "Oh, not John")
51320
+ * )
51321
+ *
51322
+ * console.log(result)
51323
+ * // Output: "John is 30 years old"
51324
+ * ```
51325
+ *
51326
+ * @see {@link type} for creating a matcher from a specific type.
51327
+ *
51328
+ * @category constructors
51329
+ * @since 4.0.0
51330
+ */
51331
+ const value = value$1;
51332
+ /**
51333
+ * Defines a condition for matching values.
51334
+ *
51335
+ * **When to use**
51336
+ *
51337
+ * Use to add one positive pattern case to a `Match.type` or `Match.value`
51338
+ * pipeline when a direct value, predicate, or structured object pattern should
51339
+ * run a handler for matching input.
51340
+ *
51341
+ * **Details**
51342
+ *
51343
+ * Supports both direct value comparisons and predicate functions. If the
51344
+ * pattern matches, the associated function is executed and the matched input is
51345
+ * removed from the remaining cases tracked by the matcher.
51346
+ *
51347
+ * **Example** (Matching with Values and Predicates)
51348
+ *
51349
+ * ```ts
51350
+ * import { Match } from "effect"
51351
+ *
51352
+ * // Create a matcher for objects with an "age" property
51353
+ * const match = Match.type<{ age: number }>().pipe(
51354
+ * // Match when age is greater than 18
51355
+ * Match.when(
51356
+ * { age: (age: number) => age > 18 },
51357
+ * (user: { age: number }) => `Age: ${user.age}`
51358
+ * ),
51359
+ * // Match when age is exactly 18
51360
+ * Match.when({ age: 18 }, () => "You can vote"),
51361
+ * // Fallback case for all other ages
51362
+ * Match.orElse((user: { age: number }) => `${user.age} is too young`)
51363
+ * )
51364
+ *
51365
+ * console.log(match({ age: 20 }))
51366
+ * // Output: "Age: 20"
51367
+ *
51368
+ * console.log(match({ age: 18 }))
51369
+ * // Output: "You can vote"
51370
+ *
51371
+ * console.log(match({ age: 4 }))
51372
+ * // Output: "4 is too young"
51373
+ * ```
51374
+ *
51375
+ * @see {@link whenOr} for handling any one of several patterns with the same handler
51376
+ * @see {@link whenAnd} for requiring all provided patterns to match before running a handler
51377
+ * @see {@link not} for handling inputs that do not match a pattern
51378
+ * @see {@link orElse} for providing a fallback when no pattern case matches
51379
+ *
51380
+ * @category Defining patterns
51381
+ * @since 4.0.0
51382
+ */
51383
+ const when = when$1;
51384
+ /**
51385
+ * Provides a fallback value when no patterns match.
51386
+ *
51387
+ * **When to use**
51388
+ *
51389
+ * Use to finalize a matcher with a fallback for unmatched input.
51390
+ *
51391
+ * **Details**
51392
+ *
51393
+ * This function ensures that a matcher always returns a valid result, even if
51394
+ * no defined patterns match. It acts as a default case, similar to the
51395
+ * `default` clause in a `switch` statement or the final `else` in an `if-else`
51396
+ * chain.
51397
+ *
51398
+ * **Example** (Providing a Default Value When No Patterns Match)
51399
+ *
51400
+ * ```ts
51401
+ * import { Match } from "effect"
51402
+ *
51403
+ * // Create a matcher for string or number values
51404
+ * const match = Match.type<string | number>().pipe(
51405
+ * // Match when the value is "a"
51406
+ * Match.when("a", () => "ok"),
51407
+ * // Fallback when no patterns match
51408
+ * Match.orElse(() => "fallback")
51409
+ * )
51410
+ *
51411
+ * console.log(match("a"))
51412
+ * // Output: "ok"
51413
+ *
51414
+ * console.log(match("b"))
51415
+ * // Output: "fallback"
51416
+ * ```
51417
+ *
51418
+ * @see {@link option} for finalizing unmatched input as `Option.none`
51419
+ * @see {@link result} for returning unmatched input as a `Result` failure
51420
+ * @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible
51421
+ *
51422
+ * @category completion
51423
+ * @since 4.0.0
51424
+ */
51425
+ const orElse = orElse$1;
50742
51426
  //#endregion
50743
51427
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Random.js
50744
51428
  /**
@@ -51588,6 +52272,22 @@ var GitHubReviewThread = class extends Class("GitHubReviewThread")({
51588
52272
  side: optional(Literals(["additions", "deletions"])),
51589
52273
  url: optional(String$1)
51590
52274
  }) {};
52275
+ const GitHubRepositoryResponse = Struct({
52276
+ name: String$1,
52277
+ owner: Struct({ login: String$1 })
52278
+ });
52279
+ const GitHubReviewThreadsResponse = Struct({ data: optional(Struct({ repository: optional(Struct({ pullRequest: optional(Struct({ reviewThreads: optional(Struct({ nodes: ArraySchema(Struct({
52280
+ comments: Struct({ nodes: ArraySchema(Struct({
52281
+ body: String$1,
52282
+ line: optional(NullOr(Number$1)),
52283
+ originalLine: optional(NullOr(Number$1)),
52284
+ path: String$1,
52285
+ url: optional(String$1)
52286
+ })) }),
52287
+ diffSide: optional(String$1),
52288
+ id: String$1,
52289
+ isResolved: Boolean$1
52290
+ })) })) })) })) })) });
51591
52291
  var GitRepository = class extends Class("GitRepository")({
51592
52292
  gitDirectory: String$1,
51593
52293
  root: String$1
@@ -51623,23 +52323,11 @@ var TerminalError = class extends TaggedErrorClass()("TerminalError", {
51623
52323
  cause: optional(Defect),
51624
52324
  message: optional(String$1)
51625
52325
  }) {};
51626
- const TerminalEvent = Union([Struct({
52326
+ const TerminalEvent = Struct({
51627
52327
  data: String$1,
52328
+ sequence: Number$1,
51628
52329
  type: Literal("data")
51629
- }), Struct({ type: Literal("reset") })]);
51630
- Union([
51631
- Struct({
51632
- data: String$1,
51633
- type: Literal("write")
51634
- }),
51635
- Struct({
51636
- cols: Number$1,
51637
- rows: Number$1,
51638
- type: Literal("resize")
51639
- }),
51640
- Struct({ type: Literal("restart") }),
51641
- Struct({ type: Literal("stop") })
51642
- ]);
52330
+ });
51643
52331
  const TerminalState = Struct({
51644
52332
  runId: Number$1,
51645
52333
  state: Literals([
@@ -51647,7 +52335,6 @@ const TerminalState = Struct({
51647
52335
  "starting",
51648
52336
  "running",
51649
52337
  "waiting",
51650
- "needs_input",
51651
52338
  "stopped",
51652
52339
  "exited",
51653
52340
  "failed"
@@ -51655,15 +52342,12 @@ const TerminalState = Struct({
51655
52342
  title: String$1
51656
52343
  });
51657
52344
  function terminalStateActive(state) {
51658
- return state === "idle" || state === "starting" || state === "running" || state === "waiting" || state === "needs_input";
52345
+ return state === "idle" || state === "starting" || state === "running" || state === "waiting";
51659
52346
  }
51660
52347
  const TerminalUpdate = Union([Struct({
51661
52348
  state: TerminalState,
51662
52349
  type: Literal("state")
51663
- }), Struct({
51664
- event: TerminalEvent,
51665
- type: Literal("event")
51666
- })]);
52350
+ }), TerminalEvent]);
51667
52351
  //#endregion
51668
52352
  //#region src/rpcs/contracts.ts
51669
52353
  const TerminalPayload = Struct({
@@ -51873,8 +52557,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51873
52557
  data: String$1,
51874
52558
  env: optional(Record(String$1, String$1)),
51875
52559
  sessionId: optional(String$1)
51876
- }),
51877
- success: TerminalState
52560
+ })
51878
52561
  }), make$18("terminal.resize", {
51879
52562
  error: TerminalError,
51880
52563
  payload: Struct({
@@ -51885,12 +52568,16 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51885
52568
  env: optional(Record(String$1, String$1)),
51886
52569
  rows: Number$1,
51887
52570
  sessionId: optional(String$1)
51888
- }),
51889
- success: TerminalState
52571
+ })
51890
52572
  }), make$18("terminal.restart", {
51891
52573
  error: TerminalError,
51892
52574
  payload: TerminalPayload,
51893
52575
  success: TerminalState
52576
+ }), make$18("terminal.state.watch", {
52577
+ error: TerminalError,
52578
+ payload: TerminalPayload,
52579
+ stream: true,
52580
+ success: TerminalState
51894
52581
  }), make$18("terminal.stop", {
51895
52582
  error: TerminalError,
51896
52583
  payload: TerminalPayload,
@@ -51914,6 +52601,26 @@ const makeGitExecutor = gen(function* () {
51914
52601
  })
51915
52602
  };
51916
52603
  });
52604
+ function toArgs(to) {
52605
+ return to.type === "ref" ? [to.ref] : empty$13();
52606
+ }
52607
+ function segmentsByFile(segments) {
52608
+ return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52609
+ }
52610
+ function diffFromPatchChunk(chunk, segments) {
52611
+ const deleted = /^deleted file mode /mu.test(chunk);
52612
+ const filePath = (deleted ? chunk.match(/^--- a\/(.+)$/mu)?.[1] : void 0) ?? chunk.match(/^\+\+\+ b\/(.+)$/mu)?.[1] ?? chunk.match(/^--- a\/(.+)$/mu)?.[1] ?? chunk.match(/^diff --git a\/.+ b\/(.+)$/mu)?.[1] ?? "";
52613
+ const status = value(chunk).pipe(when((value) => /^new file mode /mu.test(value), () => "added"), when(() => deleted, () => "deleted"), when((value) => /^rename (from|to) /mu.test(value), () => "renamed"), orElse(() => "modified"));
52614
+ return new GitDiff({
52615
+ filePath,
52616
+ patch: chunk,
52617
+ segments: getOrElse$1(get$1(segments, filePath), () => empty$13()),
52618
+ status
52619
+ });
52620
+ }
52621
+ function isWipSubject(subject) {
52622
+ return subject === "wip" || startsWith("wip: ")(subject);
52623
+ }
51917
52624
  var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", { make: gen(function* () {
51918
52625
  const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
51919
52626
  const git = yield* makeGitExecutor;
@@ -51959,25 +52666,28 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
51959
52666
  const collectRepositoriesFromRoots = fnUntraced(function* (roots, repositories) {
51960
52667
  return yield* match$3(roots, {
51961
52668
  onEmpty: () => succeed$3(repositories),
51962
- onNonEmpty: (roots) => pipe(fs.readDirectory(roots[0]), orElseSucceed(() => empty$13()), flatMap$2((entries) => {
51963
- if (contains(entries, ".git")) return pipe(git.string(roots[0], [
51964
- "rev-parse",
51965
- "--path-format=absolute",
51966
- "--git-common-dir"
51967
- ]), map$4(trim), map$4((gitDirectory) => succeed$7(new GitRepository({
51968
- gitDirectory,
51969
- root: roots[0]
51970
- }))), orElseSucceed(() => failVoid), flatMap$2((repository) => collectRepositoriesFromRoots(drop$1(roots, 1), append$1(repositories, repository))));
51971
- return pipe(entries, filter$2((entry) => !(new Set([
51972
- ".git",
51973
- ".next",
51974
- ".turbo",
51975
- "build",
51976
- "coverage",
51977
- "dist",
51978
- "node_modules"
51979
- ]).has(entry) || startsWith(".")(entry) && entry !== ".git")), forEach$1((entry) => pipe(fs.stat(path.join(roots[0], entry)), map$4((info) => info.type === "Directory" ? path.join(roots[0], entry) : ""), orElseSucceed(() => ""))), flatMap$2((nextRoots) => collectRepositoriesFromRoots(pipe(nextRoots, filter$2(isNonEmpty$1), appendAll(drop$1(roots, 1))), repositories)));
51980
- }))
52669
+ onNonEmpty: (remainingRoots) => {
52670
+ const root = remainingRoots[0];
52671
+ return pipe(fs.readDirectory(root), orElseSucceed(() => empty$13()), flatMap$2((entries) => {
52672
+ if (contains(entries, ".git")) return pipe(git.string(root, [
52673
+ "rev-parse",
52674
+ "--path-format=absolute",
52675
+ "--git-common-dir"
52676
+ ]), map$4(trim), map$4((gitDirectory) => succeed$7(new GitRepository({
52677
+ gitDirectory,
52678
+ root
52679
+ }))), orElseSucceed(() => failVoid), flatMap$2((repository) => collectRepositoriesFromRoots(drop$1(remainingRoots, 1), append$1(repositories, repository))));
52680
+ return pipe(entries, filter$2((entry) => !(new Set([
52681
+ ".git",
52682
+ ".next",
52683
+ ".turbo",
52684
+ "build",
52685
+ "coverage",
52686
+ "dist",
52687
+ "node_modules"
52688
+ ]).has(entry) || startsWith(".")(entry) && entry !== ".git")), forEach$1((entry) => pipe(fs.stat(path.join(root, entry)), map$4((info) => info.type === "Directory" ? path.join(root, entry) : ""), orElseSucceed(() => ""))), flatMap$2((nextRoots) => collectRepositoriesFromRoots(pipe(nextRoots, filter$2(isNonEmpty$1), appendAll(drop$1(roots, 1))), repositories)));
52689
+ }));
52690
+ }
51981
52691
  });
51982
52692
  });
51983
52693
  const listWorktrees = fnUntraced(function* (cwd) {
@@ -52038,7 +52748,11 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52038
52748
  yield* set(projects, yield* listProjectsFrom(home));
52039
52749
  });
52040
52750
  yield* refreshProjects();
52041
- yield* acquireRelease(sync(() => NFS.watch(home, () => run(refreshProjects()))), (watcher) => sync(() => watcher.close()));
52751
+ yield* acquireRelease(sync(() => NFS.watch(home, () => {
52752
+ run(refreshProjects());
52753
+ })), (watcher) => sync(() => {
52754
+ watcher.close();
52755
+ }));
52042
52756
  return {
52043
52757
  branches: fnUntraced(function* (cwd) {
52044
52758
  return new GitBranchesSnapshot({
@@ -52160,7 +52874,7 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52160
52874
  ...input.force ? ["--force"] : [],
52161
52875
  input.cwd
52162
52876
  ]), asVoid);
52163
- if (worktree.branch !== void 0) yield* pipe(git.string(worktree.mainRoot, [
52877
+ if (isNotUndefined(worktree.branch)) yield* pipe(git.string(worktree.mainRoot, [
52164
52878
  "branch",
52165
52879
  "-D",
52166
52880
  worktree.branch
@@ -52189,23 +52903,6 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52189
52903
  "HEAD"
52190
52904
  ]), map$4(trim));
52191
52905
  });
52192
- function toArgs(to) {
52193
- return to.type === "ref" ? [to.ref] : empty$13();
52194
- }
52195
- function segmentsByFile(segments) {
52196
- return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52197
- }
52198
- function diffFromPatchChunk(chunk, segments) {
52199
- const deleted = /^deleted file mode /mu.test(chunk);
52200
- const filePath = (deleted ? chunk.match(/^--- a\/(.+)$/mu)?.[1] : void 0) ?? chunk.match(/^\+\+\+ b\/(.+)$/mu)?.[1] ?? chunk.match(/^--- a\/(.+)$/mu)?.[1] ?? chunk.match(/^diff --git a\/.+ b\/(.+)$/mu)?.[1] ?? "";
52201
- const status = /^new file mode /mu.test(chunk) ? "added" : deleted ? "deleted" : /^rename (from|to) /mu.test(chunk) ? "renamed" : "modified";
52202
- return new GitDiff({
52203
- filePath,
52204
- patch: chunk,
52205
- segments: getOrElse$1(get$1(segments, filePath), () => empty$13()),
52206
- status
52207
- });
52208
- }
52209
52906
  function diffsFromPatch(patch, segments) {
52210
52907
  const groupedSegments = segmentsByFile(segments);
52211
52908
  return pipe(patch.split(/(?=^diff --git )/mu), filter$2(isNonEmpty$1), map$7((chunk) => diffFromPatchChunk(chunk, groupedSegments)));
@@ -52257,9 +52954,9 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52257
52954
  `${input.from}..${input.to}`
52258
52955
  ])).split("\0DESLOP-COMMIT\0"), filter$2(isNonEmpty$1), flatMap$5((entry) => {
52259
52956
  const lines = split$1("\n")(entry);
52260
- const header = lines[0] ?? "";
52957
+ const header = lines[0];
52261
52958
  const parts = split$1("\0")(header);
52262
- const commit = parts[0] ?? "";
52959
+ const commit = parts[0];
52263
52960
  const id = `${pipe(parts[1] ?? "", split$1(" "), filter$2(isNonEmpty$1))[0] ?? `${commit}^`}->${commit}`;
52264
52961
  return pipe(drop$1(lines, 1), filter$2(isNonEmpty$1), map$7((filePath) => new GitDiffSegment({
52265
52962
  filePath,
@@ -52337,14 +53034,11 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52337
53034
  "--jq",
52338
53035
  ".url"
52339
53036
  ]), map$4(trim), map$4((url) => isNonEmpty$1(url) ? some$1(url) : none()), catchTag("GitError", () => succeed$3(none())));
52340
- function isWipSubject(subject) {
52341
- return subject === "wip" || startsWith("wip: ")(subject);
52342
- }
52343
53037
  function commitFromLogLine(line) {
52344
53038
  const parts = split$1("\0")(line);
52345
53039
  const subject = parts[2] ?? "";
52346
53040
  return new GitCommit({
52347
- hash: parts[0] ?? "",
53041
+ hash: parts[0],
52348
53042
  parents: pipe(parts[3] ?? "", split$1(" "), filter$2(isNonEmpty$1)),
52349
53043
  shortHash: parts[1] ?? "",
52350
53044
  subject,
@@ -52429,7 +53123,10 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52429
53123
  "view",
52430
53124
  "--json",
52431
53125
  "owner,name"
52432
- ]), map$4((output) => JSON.parse(output)));
53126
+ ]), flatMap$2(decodeUnknownEffect(fromJsonString(GitHubRepositoryResponse))), mapError$2((cause) => new GitError({
53127
+ cause,
53128
+ message: "Failed to parse GitHub repository."
53129
+ })));
52433
53130
  const response = yield* ghString([
52434
53131
  "api",
52435
53132
  "graphql",
@@ -52464,12 +53161,15 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52464
53161
  "-F",
52465
53162
  `number=${pr}`
52466
53163
  ]);
52467
- return pipe(JSON.parse(response).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], filter$2((thread) => thread.id !== void 0), flatMap$5((thread) => pipe(thread.comments?.nodes ?? [], filter$2((comment) => comment.body !== void 0 && comment.path !== void 0), map$7((comment) => new GitHubReviewThread({
52468
- body: comment.body ?? "",
52469
- filePath: comment.path ?? "",
52470
- id: thread.id ?? "",
53164
+ return pipe((yield* pipe(decodeUnknownEffect(fromJsonString(GitHubReviewThreadsResponse))(response), mapError$2((cause) => new GitError({
53165
+ cause,
53166
+ message: "Failed to parse GitHub review threads."
53167
+ })))).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], flatMap$5((thread) => pipe(thread.comments.nodes, map$7((comment) => new GitHubReviewThread({
53168
+ body: comment.body,
53169
+ filePath: comment.path,
53170
+ id: thread.id,
52471
53171
  lineNumber: comment.line ?? comment.originalLine ?? 1,
52472
- resolved: thread.isResolved === true,
53172
+ resolved: thread.isResolved,
52473
53173
  side: thread.diffSide === "LEFT" ? "deletions" : "additions",
52474
53174
  url: comment.url
52475
53175
  })))));
@@ -52499,7 +53199,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52499
53199
  createWipCommit: fnUntraced(function* (message) {
52500
53200
  if (!(yield* hasWorktreeChanges)) return yield* new GitError({ message: "No changes to commit." });
52501
53201
  yield* pipe(git.string(config.cwd, ["add", "-A"]), asVoid);
52502
- const subject = pipe(message, trim, (message) => isEmpty$1(message) ? "wip" : `wip: ${message}`);
53202
+ const subject = pipe(message, trim, (value) => isEmpty$1(value) ? "wip" : `wip: ${value}`);
52503
53203
  yield* pipe(git.string(config.cwd, [
52504
53204
  "commit",
52505
53205
  "-m",
@@ -52575,7 +53275,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52575
53275
  filePath
52576
53276
  ]), asVoid);
52577
53277
  }),
52578
- watchReviewRangeDiffs: (input) => pipe(worktreeChanges, mapEffect(() => pipe(reviewRangeDiffs(input), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => right[index] !== void 0 && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch)))
53278
+ watchReviewRangeDiffs: (input) => pipe(worktreeChanges, mapEffect(() => pipe(reviewRangeDiffs(input), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => isNotUndefined(right[index]) && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch)))
52579
53279
  };
52580
53280
  }) }) {
52581
53281
  static layer = flow(this.make, effect(this));
@@ -52608,7 +53308,7 @@ const discover = fnUntraced(function* (cwd, input) {
52608
53308
  "package.json",
52609
53309
  "**/package.json"
52610
53310
  ], { cwd }));
52611
- return yield* pipe(pipe(split$1("\n")(output), filter$2((path) => path === "package.json" || endsWith("/package.json")(path))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
53311
+ return yield* pipe(pipe(split$1("\n")(output), filter$2((packagePath) => packagePath === "package.json" || endsWith("/package.json")(packagePath))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
52612
53312
  catch: (error) => error,
52613
53313
  try: () => pipe(JSON.parse(source), decodeUnknownOption(PackageJson))
52614
53314
  })), catch_$2(() => succeed$3(none())), flatMap$2((packageJson) => {
@@ -52671,10 +53371,10 @@ const INJECTED_HEAD = `<script>
52671
53371
  if (typeof value === 'string') return value
52672
53372
  try { return JSON.stringify(value) } catch { return String(value) }
52673
53373
  }
52674
- const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
53374
+ const send = (level, message) => window.parent?.postMessage({deslopBrowserLog: true, level, message}, '*')
52675
53375
  const sendFavicon = () => {
52676
53376
  const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
52677
- window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
53377
+ window.parent?.postMessage({deslopBrowserFavicon: true, href: icon?.href}, '*')
52678
53378
  }
52679
53379
 
52680
53380
  for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
@@ -52688,7 +53388,7 @@ const INJECTED_HEAD = `<script>
52688
53388
  window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
52689
53389
  window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
52690
53390
  window.addEventListener('message', event => {
52691
- if (event.data?.__deslopBrowserClear !== true) return
53391
+ if (event.data?.deslopBrowserClear !== true) return
52692
53392
  localStorage.clear()
52693
53393
  sessionStorage.clear()
52694
53394
  document.cookie.split(';').forEach(cookie => {
@@ -52699,7 +53399,7 @@ const INJECTED_HEAD = `<script>
52699
53399
  location.reload()
52700
53400
  })
52701
53401
 
52702
- const sendLocation = () => window.parent?.postMessage({__deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
53402
+ const sendLocation = () => window.parent?.postMessage({deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
52703
53403
  const wrapHistory = name => {
52704
53404
  const original = history[name]
52705
53405
  history[name] = function(...args) {
@@ -52755,7 +53455,7 @@ const proxy = fnUntraced(function* (request, origin) {
52755
53455
  });
52756
53456
  const proxyWebSocket = fnUntraced(function* (request, origin) {
52757
53457
  const [pathname = "/", search = ""] = request.url.split("?");
52758
- const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((protocols) => pipe(protocols, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
53458
+ const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((header) => pipe(header, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
52759
53459
  const inbound = yield* request.upgrade;
52760
53460
  const upstreamUrl = new URL(origin);
52761
53461
  upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
@@ -52769,7 +53469,7 @@ const proxyWebSocket = fnUntraced(function* (request, origin) {
52769
53469
  return empty();
52770
53470
  });
52771
53471
  function requestHostname(host) {
52772
- return pipe(fromUndefinedOr(host), flatMap$6((host) => pipe(host, split$1(":"), head)));
53472
+ return pipe(fromUndefinedOr(host), flatMap$6((value) => pipe(value, split$1(":"), head)));
52773
53473
  }
52774
53474
  function isLocalHostname(hostname) {
52775
53475
  return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
@@ -52799,11 +53499,11 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52799
53499
  const existing = ports.get(key);
52800
53500
  if (existing !== void 0) return existing;
52801
53501
  const reserved = new Set(ports.values());
52802
- for (let port = 4e3; port <= 4999; port += 1) {
52803
- const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${port}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
52804
- if (!reserved.has(port) && !occupied) {
52805
- ports.set(key, port);
52806
- return port;
53502
+ for (let candidatePort = 4e3; candidatePort <= 4999; candidatePort += 1) {
53503
+ const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${candidatePort}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
53504
+ if (!reserved.has(candidatePort) && !occupied) {
53505
+ ports.set(key, candidatePort);
53506
+ return candidatePort;
52807
53507
  }
52808
53508
  }
52809
53509
  throw new Error("no portless app ports available");
@@ -52816,7 +53516,7 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52816
53516
  port: (sessionId) => port(`${cwd}:${sessionId}`)
52817
53517
  }), tap((discovered) => sync(() => {
52818
53518
  for (const route of discovered) routes.set(route.host, `http://127.0.0.1:${route.port}`);
52819
- })), map$4((routes) => routes.map((route) => ({
53519
+ })), map$4((discovered) => discovered.map((route) => ({
52820
53520
  host: route.host,
52821
53521
  port: route.port,
52822
53522
  script: {
@@ -52834,24 +53534,94 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52834
53534
  };
52835
53535
  //#endregion
52836
53536
  //#region ../../packages/terminal/src/service.ts
52837
- function snapshotEvents(data) {
52838
- if (data === "") return empty$13();
52839
- const events = [];
52840
- for (let index = 0; index < data.length; index += 64 * 1024) events.push({
52841
- data: data.slice(index, index + 64 * 1024),
52842
- type: "data"
52843
- });
52844
- return events;
52845
- }
53537
+ var import_addon_progress = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
53538
+ (function(e, t) {
53539
+ "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();
53540
+ })(globalThis, (() => (() => {
53541
+ "use strict";
53542
+ var e = {};
53543
+ return (() => {
53544
+ var t = e;
53545
+ function s(e) {
53546
+ let t = 0;
53547
+ for (let s = 0; s < e.length; ++s) {
53548
+ const r = e.charCodeAt(s);
53549
+ if (r < 48 || 57 < r) return -1;
53550
+ t = 10 * t + r - 48;
53551
+ }
53552
+ return t;
53553
+ }
53554
+ Object.defineProperty(t, "__esModule", { value: !0 }), t.ProgressAddon = void 0, t.ProgressAddon = class {
53555
+ constructor() {
53556
+ this._st = 0, this._pr = 0;
53557
+ }
53558
+ dispose() {
53559
+ this._seqHandler?.dispose(), this._onChange?.dispose();
53560
+ }
53561
+ activate(e) {
53562
+ this._seqHandler = e.parser.registerOscHandler(9, ((e) => {
53563
+ if (!e.startsWith("4;")) return !1;
53564
+ const t = e.split(";");
53565
+ if (t.length > 3) return !0;
53566
+ 2 === t.length && t.push("");
53567
+ const r = s(t[1]), o = s(t[2]);
53568
+ switch (r) {
53569
+ case 0:
53570
+ this.progress = {
53571
+ state: r,
53572
+ value: 0
53573
+ };
53574
+ break;
53575
+ case 1:
53576
+ if (o < 0) return !0;
53577
+ this.progress = {
53578
+ state: r,
53579
+ value: o
53580
+ };
53581
+ break;
53582
+ case 2:
53583
+ case 4:
53584
+ if (o < 0) return !0;
53585
+ this.progress = {
53586
+ state: r,
53587
+ value: o || this._pr
53588
+ };
53589
+ break;
53590
+ case 3: this.progress = {
53591
+ state: r,
53592
+ value: this._pr
53593
+ };
53594
+ }
53595
+ return !0;
53596
+ })), this._onChange = new e._core._onData.constructor(), this.onChange = this._onChange.event;
53597
+ }
53598
+ get progress() {
53599
+ return {
53600
+ state: this._st,
53601
+ value: this._pr
53602
+ };
53603
+ }
53604
+ set progress(e) {
53605
+ 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({
53606
+ state: this._st,
53607
+ value: this._pr
53608
+ }));
53609
+ }
53610
+ };
53611
+ })(), e;
53612
+ })()));
53613
+ })))(), 1);
53614
+ const eventBacklogCapacity = 512;
53615
+ const terminalReset = "\x1Bc";
52846
53616
  function parseTitleSignal(title) {
52847
- const trimmed = trim(title);
52848
- if (/^\[\s*[!.]\s*\]\s*Action Required\b/i.test(trimmed)) return {
52849
- state: "needs_input",
52850
- title: trimmed.replace(/^\[\s*[!.]\s*\]\s*/i, "") || trimmed
53617
+ const trimmed = title.trim();
53618
+ if (/^\[\s*[!.]\s*\]\s*Action Required\b/iu.test(trimmed)) return {
53619
+ state: "waiting",
53620
+ title: trimmed.replace(/^\[\s*[!.]\s*\]\s*/iu, "") || trimmed
52851
53621
  };
52852
53622
  const spinner = /^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-])(?:\s|\s*\|)/u.test(trimmed);
52853
- const nextTitle = trimmed.replace(/^OC\s*\|\s*/i, "").replace(/^π\s*-\s*/i, "").replace(/^\[\s*[^\]]+\s*\]\s*/, "").replace(/^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-]\s*)+/, "").replace(/^\|\s*/, "").trim() || trimmed;
52854
- const segment = nextTitle.match(/^(Idle|Ready|Starting|Working|Thinking|Waiting)\b/i)?.[1]?.toLowerCase();
53623
+ 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;
53624
+ const segment = /^(Idle|Ready|Starting|Working|Thinking|Waiting)\b/iu.exec(nextTitle)?.[1]?.toLowerCase();
52855
53625
  if (segment === "idle" || segment === "ready") return {
52856
53626
  state: "idle",
52857
53627
  title: nextTitle
@@ -52868,7 +53638,7 @@ function parseTitleSignal(title) {
52868
53638
  state: "running",
52869
53639
  title: nextTitle
52870
53640
  };
52871
- if (isNonEmpty$1(trimmed)) return {
53641
+ if (trimmed !== "") return {
52872
53642
  state: "idle",
52873
53643
  title: nextTitle
52874
53644
  };
@@ -52877,65 +53647,95 @@ function parseTitleSignal(title) {
52877
53647
  title: ""
52878
53648
  };
52879
53649
  }
52880
- function completeSignalData(input) {
52881
- if (input.endsWith("\x1B")) return {
52882
- complete: input.slice(0, -1),
52883
- pending: "\x1B"
52884
- };
52885
- const start = input.lastIndexOf("\x1B]");
52886
- if (start === -1) return {
52887
- complete: input,
52888
- pending: ""
52889
- };
52890
- const tail = input.slice(start);
52891
- if (tail.includes("\x07") || tail.includes("\x1B\\")) return {
52892
- complete: input,
52893
- pending: ""
52894
- };
53650
+ function snapshotEvents(data, sequence) {
53651
+ if (data === "") return empty$13();
53652
+ const events = [];
53653
+ for (let index = 0; index < data.length; index += 256 * 1024) events.push({
53654
+ data: data.slice(index, index + 256 * 1024),
53655
+ sequence,
53656
+ type: "data"
53657
+ });
53658
+ return events;
53659
+ }
53660
+ function adjacentGroups(items, sameGroup, merge) {
53661
+ return pipe(items, reduce(empty$13(), (groups, item) => {
53662
+ const next = groups;
53663
+ const previous = groups.at(-1);
53664
+ if (previous === void 0 || !sameGroup(previous, item)) {
53665
+ next.push(item);
53666
+ return next;
53667
+ }
53668
+ next[next.length - 1] = merge(previous, item);
53669
+ return next;
53670
+ }));
53671
+ }
53672
+ function queuedDataGroups(items, merge) {
53673
+ return adjacentGroups(items, (previous, item) => previous.generation === item.generation, merge);
53674
+ }
53675
+ function mergeQueuedData(previous, item) {
52895
53676
  return {
52896
- complete: input.slice(0, start),
52897
- pending: tail
53677
+ data: `${previous.data}${item.data}`,
53678
+ generation: item.generation
52898
53679
  };
52899
53680
  }
53681
+ function queuedWriteGroups(items) {
53682
+ return adjacentGroups(items, (previous, item) => previous.process === item.process, (previous, item) => ({
53683
+ data: `${previous.data}${item.data}`,
53684
+ process: item.process
53685
+ }));
53686
+ }
52900
53687
  var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { make: fnUntraced(function* (config) {
52901
53688
  const dataQueue = yield* unbounded();
52902
- const events = yield* bounded$1({ capacity: 256 });
53689
+ const screenQueue = yield* unbounded();
53690
+ const writeQueue = yield* unbounded();
53691
+ const resizeQueue = yield* sliding(1);
53692
+ const events = yield* bounded$1({
53693
+ capacity: 1024,
53694
+ replay: eventBacklogCapacity
53695
+ });
52903
53696
  const lifecycleLock = yield* make$47(1);
52904
53697
  const screenLock = yield* make$47(1);
52905
- const sequenceRef = yield* make$38(0);
52906
- const signalBuffer = yield* make$38("");
53698
+ const eventSequenceRef = yield* make$38(0);
53699
+ const parsedSequenceRef = yield* make$38(0);
53700
+ const screenGenerationRef = yield* make$38(0);
52907
53701
  const processRef = yield* make$38(void 0);
52908
53702
  const sizeRef = yield* make$38({
52909
53703
  cols: 120,
52910
53704
  rows: 32
52911
53705
  });
52912
53706
  const shell = yield* string("SHELL").pipe(orElseSucceed(() => "bash"));
52913
- const processCommand = config.preparedCommand?.command ?? config.command ?? shell;
52914
- const processArgs = config.preparedCommand?.args ?? config.args ?? [];
52915
- const autostart = config.command === void 0 && config.preparedCommand === void 0;
53707
+ const processCommand = config.command?.command ?? shell;
53708
+ const processArgs = config.command?.args ?? [];
53709
+ const processEnv = config.command?.options.env ?? {};
53710
+ const autostart = config.command === void 0;
52916
53711
  const stateRef = yield* make$3({
52917
53712
  runId: 0,
52918
53713
  state: autostart ? "starting" : "idle",
52919
53714
  title: ""
52920
53715
  });
52921
- const screen = new (createRequire(import.meta.url)("@xterm/headless")).Terminal({
53716
+ const screen = new HeadlessModule.Terminal({
52922
53717
  allowProposedApi: true,
52923
53718
  cols: 120,
52924
53719
  rows: 32,
52925
53720
  scrollback: 1e4
52926
53721
  });
52927
- const serialize = new (createRequire(import.meta.url)("@xterm/addon-serialize")).SerializeAddon();
53722
+ const serialize = new SerializeModule.SerializeAddon();
53723
+ const progressAddon = new import_addon_progress.ProgressAddon();
52928
53724
  screen.loadAddon(serialize);
52929
- const publish$1 = fnUntraced(function* (event) {
53725
+ screen.loadAddon(progressAddon);
53726
+ const publish$1 = fnUntraced(function* (data) {
53727
+ const sequence = yield* updateAndGet(eventSequenceRef, (current) => current + 1);
52930
53728
  yield* publish(events, {
52931
- event,
52932
- sequence: yield* updateAndGet(sequenceRef, (sequence) => sequence + 1)
53729
+ data,
53730
+ sequence,
53731
+ type: "data"
52933
53732
  });
53733
+ return sequence;
52934
53734
  });
52935
53735
  const requestSnapshot = withPermit(screenLock, gen(function* () {
52936
53736
  return {
52937
53737
  data: serialize.serialize({ scrollback: 1e4 }),
52938
- sequence: yield* get$3(sequenceRef)
53738
+ sequence: yield* get$3(parsedSequenceRef)
52939
53739
  };
52940
53740
  }));
52941
53741
  function setState(state) {
@@ -52944,9 +53744,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52944
53744
  state
52945
53745
  }));
52946
53746
  }
52947
- function setActiveState(state) {
53747
+ function setProgressState(progressState) {
52948
53748
  return update(stateRef, (current) => {
52949
- if (current.state !== "idle" && current.state !== "starting" && current.state !== "running") return current;
53749
+ if (current.state === "stopped" || current.state === "exited" || current.state === "failed") return current;
53750
+ const state = pipe(progressState.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
52950
53751
  return {
52951
53752
  ...current,
52952
53753
  state
@@ -52968,17 +53769,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52968
53769
  state: "starting",
52969
53770
  title: ""
52970
53771
  })), andThen(get(stateRef)));
52971
- function readSignals(data) {
52972
- for (const match of data.matchAll(/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) {
52973
- const title = match[1];
52974
- if (title !== void 0) runFork(setTitle(title));
52975
- }
52976
- for (const match of data.matchAll(/\x1b\]9;4;([^\x07\x1b]*)(?:\x07|\x1b\\)/gu)) runFork(setActiveState(match[1] === "0" ? "idle" : "running"));
52977
- }
52978
- const readBufferedSignals = fnUntraced(function* (data) {
52979
- const next = completeSignalData(`${yield* get$3(signalBuffer)}${data}`);
52980
- yield* set$4(signalBuffer, next.pending);
52981
- readSignals(next.complete);
53772
+ screen.parser.registerOscHandler(0, (title) => {
53773
+ runFork(setTitle(title));
53774
+ return false;
53775
+ });
53776
+ screen.parser.registerOscHandler(2, (title) => {
53777
+ runFork(setTitle(title));
53778
+ return false;
53779
+ });
53780
+ progressAddon.onChange((nextProgress) => {
53781
+ runFork(setProgressState(nextProgress));
52982
53782
  });
52983
53783
  const interruptProcess = fnUntraced(function* (subprocess, signal) {
52984
53784
  yield* sync(() => {
@@ -52992,14 +53792,14 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52992
53792
  yield* sleep("250 millis");
52993
53793
  yield* interruptProcess(subprocess, "SIGKILL");
52994
53794
  });
52995
- const writeScreen = fnUntraced(function* (data) {
53795
+ const writeScreen = fnUntraced(function* (input) {
53796
+ if ((yield* get$3(screenGenerationRef)) !== input.generation) return;
52996
53797
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
52997
- screen.write(data, () => {
52998
- resume(void_$1);
53798
+ screen.write(input.data, () => {
53799
+ resume(succeed$3(void 0));
52999
53800
  });
53000
- }), andThen(readBufferedSignals(data)), andThen(publish$1({
53001
- data,
53002
- type: "data"
53801
+ }), andThen(gen(function* () {
53802
+ if ((yield* get$3(screenGenerationRef)) === input.generation) yield* set$4(parsedSequenceRef, yield* publish$1(input.data));
53003
53803
  }))));
53004
53804
  });
53005
53805
  const clearProcess = fnUntraced(function* (handle) {
@@ -53020,9 +53820,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53020
53820
  if (state) yield* setState(state);
53021
53821
  });
53022
53822
  const spawnProcess = fnUntraced(function* () {
53823
+ const generation = yield* updateAndGet(screenGenerationRef, (current) => current + 1);
53023
53824
  yield* withPermit(screenLock, pipe(sync(() => {
53024
53825
  screen.reset();
53025
- }), andThen(publish$1({ type: "reset" }))));
53826
+ }), andThen(publish$1(terminalReset)), tap((sequence) => set$4(parsedSequenceRef, sequence))));
53026
53827
  yield* startRun;
53027
53828
  const size = yield* get$3(sizeRef);
53028
53829
  const subprocess = yield* try_({
@@ -53035,7 +53836,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53035
53836
  cwd: config.cwd,
53036
53837
  env: {
53037
53838
  ...process.env,
53038
- ...config.env,
53839
+ ...processEnv,
53039
53840
  TERM: "xterm-256color"
53040
53841
  },
53041
53842
  name: "xterm-256color",
@@ -53043,8 +53844,11 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53043
53844
  })
53044
53845
  });
53045
53846
  const handle = {
53046
- data: subprocess.onData((data) => {
53047
- offerUnsafe(dataQueue, data);
53847
+ data: subprocess.onData((chunk) => {
53848
+ offerUnsafe(dataQueue, {
53849
+ data: chunk,
53850
+ generation
53851
+ });
53048
53852
  }),
53049
53853
  exit: subprocess.onExit((event) => {
53050
53854
  runFork(withPermit(lifecycleLock, gen(function* () {
@@ -53067,18 +53871,27 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53067
53871
  yield* stopProcess();
53068
53872
  return yield* spawnProcess();
53069
53873
  });
53070
- yield* pipe(fromQueue(dataQueue), runForEach(writeScreen), forkScoped);
53874
+ yield* pipe(fromQueue(dataQueue), groupedWithin(256, millis(8)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), (item) => gen(function* () {
53875
+ if ((yield* get$3(screenGenerationRef)) !== item.generation) return;
53876
+ yield* offer(screenQueue, item);
53877
+ }), { discard: true })), forkScoped);
53878
+ yield* pipe(fromQueue(screenQueue), groupedWithin(256, millis(16)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), writeScreen, { discard: true })), forkScoped);
53071
53879
  yield* addFinalizer(() => all([
53072
53880
  stopProcess(),
53073
53881
  shutdown$1(events),
53074
53882
  shutdown(dataQueue),
53075
- sync(() => screen.dispose())
53883
+ shutdown(screenQueue),
53884
+ shutdown(writeQueue),
53885
+ shutdown(resizeQueue),
53886
+ sync(() => {
53887
+ screen.dispose();
53888
+ })
53076
53889
  ], {
53077
53890
  concurrency: "unbounded",
53078
53891
  discard: true
53079
53892
  }));
53080
53893
  if (autostart) yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => setState("failed")));
53081
- const resize = fnUntraced(function* (nextSize) {
53894
+ const resizeProcess = fnUntraced(function* (nextSize) {
53082
53895
  const size = yield* get$3(sizeRef);
53083
53896
  if (size.cols === nextSize.cols && size.rows === nextSize.rows) return;
53084
53897
  yield* set$4(sizeRef, nextSize);
@@ -53097,56 +53910,65 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53097
53910
  }
53098
53911
  });
53099
53912
  });
53100
- const write = fnUntraced(function* (data) {
53101
- const process = yield* get$3(processRef);
53102
- if (!process) return;
53913
+ yield* pipe(fromQueue(resizeQueue), groupedWithin(32, millis(16)), runForEach((items) => pipe(last(fromIterable$2(items)), match$5({
53914
+ onNone: () => void_$1,
53915
+ onSome: resizeProcess
53916
+ }))), forkScoped);
53917
+ const writeProcess = fnUntraced(function* (input) {
53918
+ if ((yield* get$3(processRef)) !== input.process) return;
53103
53919
  yield* try_({
53104
53920
  catch: (cause) => new TerminalError({
53105
53921
  cause,
53106
53922
  message: "failed to write to terminal"
53107
53923
  }),
53108
53924
  try: () => {
53109
- process.process.write(data);
53925
+ input.process.process.write(input.data);
53110
53926
  }
53111
53927
  });
53112
53928
  });
53929
+ yield* pipe(fromQueue(writeQueue), groupedWithin(128, millis(4)), runForEach((items) => forEach$1(queuedWriteGroups(fromIterable$2(items)), writeProcess, { discard: true })), forkScoped);
53113
53930
  const eventsStream = scoped$1(unwrap$1(gen(function* () {
53114
53931
  const subscription = yield* subscribe(events);
53115
53932
  const snapshot = yield* requestSnapshot;
53116
53933
  const pending = yield* takeUpTo(subscription, Number.POSITIVE_INFINITY);
53934
+ const replay = filter$2(pending, (event) => event.sequence > snapshot.sequence);
53935
+ const replaySequence = replay.at(-1)?.sequence ?? snapshot.sequence;
53117
53936
  return pipe(fromIterable$1([
53118
53937
  {
53119
- event: { type: "reset" },
53120
- sequence: snapshot.sequence
53938
+ data: terminalReset,
53939
+ sequence: snapshot.sequence,
53940
+ type: "data"
53121
53941
  },
53122
- ...map$7(snapshotEvents(snapshot.data), (event) => ({
53123
- event,
53124
- sequence: snapshot.sequence
53125
- })),
53126
- ...filter$2(pending, (event) => event.sequence > snapshot.sequence)
53127
- ]), concat(fromEffectRepeat(take$2(subscription))));
53942
+ ...snapshotEvents(snapshot.data, snapshot.sequence),
53943
+ ...replay,
53944
+ ...filter$2(pending, (event) => event.sequence > replaySequence)
53945
+ ]), concat(fromEffectRepeat(take$3(subscription))));
53128
53946
  })));
53129
- const updates = merge$1(changes(stateRef).pipe(map$2((state) => ({
53947
+ const stateUpdates = unwrap$1(pipe(get(stateRef), map$4((state) => concat(drop(1)(changes(stateRef)))(make$43(state)))));
53948
+ const updates = merge$1(stateUpdates.pipe(map$2((state) => ({
53130
53949
  state,
53131
53950
  type: "state"
53132
- }))), eventsStream.pipe(map$2((published) => ({
53133
- event: published.event,
53134
- type: "event"
53135
- }))));
53951
+ }))), eventsStream);
53136
53952
  return {
53137
53953
  resize: fnUntraced(function* (size) {
53138
- return yield* pipe(resize(size), andThen(get(stateRef)));
53954
+ yield* offer(resizeQueue, size);
53139
53955
  }),
53140
53956
  restart: fnUntraced(function* () {
53141
53957
  return yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => pipe(setState("failed"), andThen(get(stateRef)))));
53142
53958
  }),
53959
+ stateUpdates,
53143
53960
  stop: fnUntraced(function* () {
53144
53961
  yield* pipe(stopProcess("stopped"), withPermit(lifecycleLock));
53145
53962
  return yield* get(stateRef);
53146
53963
  }),
53147
53964
  updates,
53148
53965
  write: fnUntraced(function* (data) {
53149
- return yield* pipe(write(data), andThen(get(stateRef)));
53966
+ if (data === "") return;
53967
+ const process = yield* get$3(processRef);
53968
+ if (process) yield* offer(writeQueue, {
53969
+ data,
53970
+ process
53971
+ });
53150
53972
  })
53151
53973
  };
53152
53974
  }) }) {
@@ -53169,6 +53991,29 @@ const AgentSessionKey = Struct({
53169
53991
  cwd: String$1,
53170
53992
  uuid: String$1
53171
53993
  });
53994
+ function terminalSessionInput(session) {
53995
+ if ("args" in session || "env" in session) return {
53996
+ command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
53997
+ cwd: session.cwd,
53998
+ sessionId: session.sessionId
53999
+ };
54000
+ if (typeof session.command === "string") return {
54001
+ command: make$40(session.command),
54002
+ cwd: session.cwd,
54003
+ sessionId: session.sessionId
54004
+ };
54005
+ return {
54006
+ command: session.command,
54007
+ cwd: session.cwd,
54008
+ sessionId: session.sessionId
54009
+ };
54010
+ }
54011
+ function commentKey(input) {
54012
+ return `${input.filePath}:${input.side ?? "additions"}:${input.lineNumber}`;
54013
+ }
54014
+ function markKey(input) {
54015
+ return `${input.filePath}:${input.segmentId}:${input.fingerprint}`;
54016
+ }
53172
54017
  const TerminalSessions = make$46({
53173
54018
  idleTimeToLive: infinity,
53174
54019
  lookup: fnUntraced(function* (config) {
@@ -53216,14 +54061,16 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53216
54061
  const script = pipe(yield* get$3(portlessScripts), get$1(input.sessionId), getOrUndefined$1);
53217
54062
  if (script === void 0) return input;
53218
54063
  return {
54064
+ command: make$40(script.preparedCommand.command, script.preparedCommand.args, {
54065
+ ...script.preparedCommand.options,
54066
+ env: script.env
54067
+ }),
53219
54068
  cwd: script.cwd,
53220
- env: script.env,
53221
- preparedCommand: script.preparedCommand,
53222
54069
  sessionId: script.sessionId
53223
54070
  };
53224
54071
  });
53225
- const terminal = fnUntraced(function* (input) {
53226
- return yield* pipe(terminalSession(input), flatMap$2((session) => get$6(terminals, session)));
54072
+ const getTerminal = fnUntraced(function* (input) {
54073
+ return yield* pipe(terminalSession(input), map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
53227
54074
  });
53228
54075
  const reviewStateKey = fnUntraced(function* (input) {
53229
54076
  const root = yield* pipe(fs.realPath(input.cwd), orElseSucceed(() => input.cwd));
@@ -53248,17 +54095,11 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53248
54095
  yield* reviewStore.set(`review-state/${key}`, state);
53249
54096
  })), mapError$2((cause) => new GitError({ cause })));
53250
54097
  });
53251
- function commentKey(input) {
53252
- return `${input.filePath}:${input.side ?? "additions"}:${input.lineNumber}`;
53253
- }
53254
- function markKey(input) {
53255
- return `${input.filePath}:${input.segmentId}:${input.fingerprint}`;
53256
- }
53257
54098
  const agents = yield* make$3(empty$6());
53258
54099
  return RpcContracts.of({
53259
54100
  "agents.create": (payload) => gen(function* () {
53260
- const labelCount = pipe(fromIterable$2(values(yield* get(agents))), filter$2((session) => session.cwd === payload.cwd && session.command === payload.command), length);
53261
- const session = {
54101
+ const labelCount = pipe(fromIterable$2(values(yield* get(agents))), filter$2((agentSession) => agentSession.cwd === payload.cwd && agentSession.command === payload.command), length);
54102
+ const agentSession = {
53262
54103
  args: [...payload.args],
53263
54104
  command: payload.command,
53264
54105
  cwd: payload.cwd,
@@ -53267,21 +54108,21 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53267
54108
  uuid: randomUUID()
53268
54109
  };
53269
54110
  yield* update(agents, (sessions) => set$2(sessions, AgentSessionKey.make({
53270
- cwd: session.cwd,
53271
- uuid: session.uuid
53272
- }), session));
53273
- const terminal = yield* get$6(terminals, TerminalSessionKey.make({
53274
- args: session.args,
53275
- command: session.command,
53276
- cwd: session.cwd,
53277
- sessionId: session.uuid
53278
- }));
53279
- yield* terminal.restart();
53280
- 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({
53281
- cwd: session.cwd,
53282
- uuid: session.uuid
54111
+ cwd: agentSession.cwd,
54112
+ uuid: agentSession.uuid
54113
+ }), agentSession));
54114
+ const sessionTerminal = yield* terminalSession(TerminalSessionKey.make({
54115
+ args: agentSession.args,
54116
+ command: agentSession.command,
54117
+ cwd: agentSession.cwd,
54118
+ sessionId: agentSession.uuid
54119
+ })).pipe(map$4(terminalSessionInput), flatMap$2((input) => get$6(terminals, input)));
54120
+ yield* sessionTerminal.restart();
54121
+ yield* pipe(sessionTerminal.stateUpdates, map$2((state) => state.state), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (sessions) => remove$2(sessions, AgentSessionKey.make({
54122
+ cwd: agentSession.cwd,
54123
+ uuid: agentSession.uuid
53283
54124
  })))), forkDetach);
53284
- return session;
54125
+ return agentSession;
53285
54126
  }),
53286
54127
  "agents.remove": (payload) => update(agents, (current) => remove$2(current, AgentSessionKey.make({
53287
54128
  cwd: payload.cwd,
@@ -53340,14 +54181,15 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53340
54181
  to: payload.to
53341
54182
  })))),
53342
54183
  "runs.portless": (payload) => get$6(portlessWorktrees, payload.cwd),
53343
- "terminal.resize": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
54184
+ "terminal.resize": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.resize({
53344
54185
  cols: payload.cols,
53345
54186
  rows: payload.rows
53346
54187
  }))),
53347
- "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
53348
- "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
53349
- "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
53350
- "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
54188
+ "terminal.restart": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.restart()),
54189
+ "terminal.state.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stateUpdates)),
54190
+ "terminal.stop": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stop()),
54191
+ "terminal.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.updates)),
54192
+ "terminal.write": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.write(payload.data)))
53351
54193
  });
53352
54194
  }));
53353
54195
  //#endregion
@@ -66844,7 +67686,7 @@ var OtelSpan = class {
66844
67686
  this.links = options.links;
66845
67687
  this.kind = options.kind;
66846
67688
  const active = contextApi.active();
66847
- this.parent = options.root !== true ? orElse$1(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
67689
+ this.parent = options.root !== true ? orElse$3(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
66848
67690
  this.span = tracer.startSpan(options.name, {
66849
67691
  startTime: nanosToHrTime(options.startTime),
66850
67692
  links: options.links.length > 0 ? options.links.map((link) => ({