@deslop/workbench 0.0.321 → 0.0.327

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/client/assets/agent-CRsoHYEG.js +1 -0
  2. package/dist/client/assets/{agent-DAD7EQOa.js → agent-DYjX-Pzl.js} +2 -2
  3. package/dist/client/assets/{diff-HFsBcdrM.js → diff-C_X2wnRm.js} +2 -2
  4. package/dist/client/assets/{diff-BbjpVkn4.js → diff-hUFci-J4.js} +26 -26
  5. package/dist/client/assets/index-BX6N5TyF.css +2 -0
  6. package/dist/client/assets/{index-Ds4rq0zQ.js → index-DpbZkluz.js} +1 -1
  7. package/dist/client/assets/input-group-CAejCCyD.js +153 -0
  8. package/dist/client/assets/{portless-DFKFPX3Z.js → portless-D4NDzBYJ.js} +1 -1
  9. package/dist/client/assets/{portless-DexDlqwA.js → portless-D73tczCx.js} +2 -2
  10. package/dist/client/assets/{route-DOWKJR6H.js → route-0gFXuUyt.js} +2 -2
  11. package/dist/client/assets/{route-CUHeGENe.js → route-BcNQ-aN-.js} +1 -1
  12. package/dist/client/assets/{run-BvHiSlty.js → run-B5fcXFyP.js} +2 -2
  13. package/dist/client/assets/run-BzrHh2aK.js +1 -0
  14. package/dist/client/assets/state-C-LyNCwu.js +2 -0
  15. package/dist/client/assets/{terminal-t4CeG_V9.js → terminal-B3oT0xJm.js} +2 -2
  16. package/dist/client/assets/terminal-DgodR87i.js +145 -0
  17. package/dist/client/assets/terminal-EfiQ0Ote.js +1 -0
  18. package/dist/client/index.html +8 -8
  19. package/dist/server.js +1107 -311
  20. package/package.json +2 -2
  21. package/dist/client/assets/agent-DHWhwvQy.js +0 -1
  22. package/dist/client/assets/index-Ci3BZgXN.css +0 -2
  23. package/dist/client/assets/input-group-BtEJur4W.js +0 -153
  24. package/dist/client/assets/run-L2YCL4H0.js +0 -1
  25. package/dist/client/assets/state-T-ZhKyUm.js +0 -2
  26. package/dist/client/assets/terminal-CGe8qF7_.js +0 -1
  27. package/dist/client/assets/terminal-Ci9YBovb.js +0 -119
package/dist/server.js CHANGED
@@ -21,6 +21,8 @@ import * as NodeStreamP from "node:stream/promises";
21
21
  import { pipeline } from "node:stream/promises";
22
22
  import * as readline from "node:readline";
23
23
  import * as nodePty from "@lydell/node-pty";
24
+ import SerializeModule from "@xterm/addon-serialize";
25
+ import HeadlessModule from "@xterm/headless";
24
26
  //#region \0rolldown/runtime.js
25
27
  var __create = Object.create;
26
28
  var __defProp = Object.defineProperty;
@@ -4499,9 +4501,9 @@ const isArrayNonEmpty$1 = (self) => self.length > 0;
4499
4501
  /**
4500
4502
  * @since 2.0.0
4501
4503
  */
4502
- const TypeId$50 = "~effect/data/Option";
4504
+ const TypeId$52 = "~effect/data/Option";
4503
4505
  const CommonProto$1 = {
4504
- [TypeId$50]: { _A: (_) => _ },
4506
+ [TypeId$52]: { _A: (_) => _ },
4505
4507
  ...PipeInspectableProto,
4506
4508
  [Symbol.iterator]() {
4507
4509
  return new SingleShotGen(this);
@@ -4552,7 +4554,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
4552
4554
  }
4553
4555
  });
4554
4556
  /** @internal */
4555
- const isOption = (input) => hasProperty(input, TypeId$50);
4557
+ const isOption = (input) => hasProperty(input, TypeId$52);
4556
4558
  /** @internal */
4557
4559
  const isNone$1 = (fa) => fa._tag === "None";
4558
4560
  /** @internal */
@@ -4567,9 +4569,9 @@ const some$2 = (value) => {
4567
4569
  };
4568
4570
  //#endregion
4569
4571
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/result.js
4570
- const TypeId$49 = "~effect/data/Result";
4572
+ const TypeId$51 = "~effect/data/Result";
4571
4573
  const CommonProto = {
4572
- [TypeId$49]: {
4574
+ [TypeId$51]: {
4573
4575
  /* v8 ignore next 2 */
4574
4576
  _A: (_) => _,
4575
4577
  _E: (_) => _
@@ -4583,7 +4585,7 @@ const SuccessProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4583
4585
  _tag: "Success",
4584
4586
  _op: "Success",
4585
4587
  [symbol$2](that) {
4586
- return isResult(that) && isSuccess$2(that) && equals$2(this.success, that.success);
4588
+ return isResult$1(that) && isSuccess$2(that) && equals$2(this.success, that.success);
4587
4589
  },
4588
4590
  [symbol$3]() {
4589
4591
  return combine$1(hash(this._tag))(hash(this.success));
@@ -4603,7 +4605,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4603
4605
  _tag: "Failure",
4604
4606
  _op: "Failure",
4605
4607
  [symbol$2](that) {
4606
- return isResult(that) && isFailure$2(that) && equals$2(this.failure, that.failure);
4608
+ return isResult$1(that) && isFailure$2(that) && equals$2(this.failure, that.failure);
4607
4609
  },
4608
4610
  [symbol$3]() {
4609
4611
  return combine$1(hash(this._tag))(hash(this.failure));
@@ -4620,7 +4622,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
4620
4622
  }
4621
4623
  });
4622
4624
  /** @internal */
4623
- const isResult = (input) => hasProperty(input, TypeId$49);
4625
+ const isResult$1 = (input) => hasProperty(input, TypeId$51);
4624
4626
  /** @internal */
4625
4627
  const isFailure$2 = (result) => result._tag === "Failure";
4626
4628
  /** @internal */
@@ -5218,7 +5220,7 @@ const getOrElse$1 = /*#__PURE__*/ dual(2, (self, onNone) => isNone(self) ? onNon
5218
5220
  * @category error handling
5219
5221
  * @since 2.0.0
5220
5222
  */
5221
- const orElse$1 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self);
5223
+ const orElse$3 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self);
5222
5224
  /**
5223
5225
  * Converts a nullable value (`null` or `undefined`) into an `Option`.
5224
5226
  *
@@ -5530,6 +5532,36 @@ const fail$7 = fail$8;
5530
5532
  */
5531
5533
  const failVoid = /*#__PURE__*/ fail$7(void 0);
5532
5534
  /**
5535
+ * Checks whether a value is a `Result` (either `Success` or `Failure`).
5536
+ *
5537
+ * **When to use**
5538
+ *
5539
+ * Use to validate unknown input before operating on it as a `Result`.
5540
+ *
5541
+ * **Details**
5542
+ *
5543
+ * - Returns `true` for both `Success` and `Failure` variants
5544
+ * - Acts as a TypeScript type guard, narrowing to `Result<unknown, unknown>`
5545
+ *
5546
+ * **Example** (Checking if a value is a Result)
5547
+ *
5548
+ * ```ts
5549
+ * import { Result } from "effect"
5550
+ *
5551
+ * console.log(Result.isResult(Result.succeed(1)))
5552
+ * // Output: true
5553
+ *
5554
+ * console.log(Result.isResult({ value: 1 }))
5555
+ * // Output: false
5556
+ * ```
5557
+ *
5558
+ * @see {@link isSuccess} / {@link isFailure} to narrow to a specific variant
5559
+ *
5560
+ * @category guards
5561
+ * @since 4.0.0
5562
+ */
5563
+ const isResult = isResult$1;
5564
+ /**
5533
5565
  * Checks whether a `Result` is a `Failure`.
5534
5566
  *
5535
5567
  * **When to use**
@@ -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;
@@ -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`,
@@ -33875,7 +34270,7 @@ function makeClass(Inherited, identifier, struct$1, annotations, proto) {
33875
34270
  disableChecks: true
33876
34271
  });
33877
34272
  }
33878
- static [TypeId$23] = TypeId$23;
34273
+ static [TypeId$24] = TypeId$24;
33879
34274
  get [ClassTypeId]() {
33880
34275
  return ClassTypeId;
33881
34276
  }
@@ -34275,11 +34670,11 @@ function onSerializerEnsureArray(ast) {
34275
34670
  *
34276
34671
  * @since 4.0.0
34277
34672
  */
34278
- const TypeId$22 = "~effect/http/Cookies";
34673
+ const TypeId$23 = "~effect/http/Cookies";
34279
34674
  const CookieTypeId = "~effect/http/Cookies/Cookie";
34280
34675
  TaggedError("CookieError");
34281
34676
  const Proto$11 = {
34282
- [TypeId$22]: TypeId$22,
34677
+ [TypeId$23]: TypeId$23,
34283
34678
  ...BaseProto,
34284
34679
  toJSON() {
34285
34680
  return {
@@ -34604,10 +34999,10 @@ const tryDecodeURIComponent = (str) => {
34604
34999
  * @category type IDs
34605
35000
  * @since 4.0.0
34606
35001
  */
34607
- const TypeId$21 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
35002
+ const TypeId$22 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
34608
35003
  const Proto$10 = /*#__PURE__*/ Object.create(null);
34609
35004
  Object.defineProperties(Proto$10, {
34610
- [TypeId$21]: { value: TypeId$21 },
35005
+ [TypeId$22]: { value: TypeId$22 },
34611
35006
  [symbolRedactable]: { value(context) {
34612
35007
  return redact(this, get$9(context, CurrentRedactedNames));
34613
35008
  } },
@@ -34802,7 +35197,7 @@ const CurrentRedactedNames = /*#__PURE__*/ Reference("effect/Headers/CurrentReda
34802
35197
  *
34803
35198
  * @since 4.0.0
34804
35199
  */
34805
- const TypeId$20 = "~effect/http/HttpClientError";
35200
+ const TypeId$21 = "~effect/http/HttpClientError";
34806
35201
  /**
34807
35202
  * Error wrapper for HTTP client failures, exposing the failed request and the optional response through its `reason`.
34808
35203
  *
@@ -34822,7 +35217,7 @@ var HttpClientError = class extends TaggedError("HttpClientError") {
34822
35217
  *
34823
35218
  * @since 4.0.0
34824
35219
  */
34825
- [TypeId$20] = TypeId$20;
35220
+ [TypeId$21] = TypeId$21;
34826
35221
  /**
34827
35222
  * HTTP request associated with the client failure.
34828
35223
  *
@@ -34945,7 +35340,7 @@ var EmptyBodyError = class extends TaggedError("EmptyBodyError") {
34945
35340
  return formatMessage(formatReason(this._tag), this.description, info);
34946
35341
  }
34947
35342
  };
34948
- ErrorClass(TypeId$20)({
35343
+ ErrorClass(TypeId$21)({
34949
35344
  _tag: /*#__PURE__*/ tag("HttpError"),
34950
35345
  kind: /*#__PURE__*/ Literals([
34951
35346
  "EncodeError",
@@ -34997,10 +35392,10 @@ ErrorClass(TypeId$20)({
34997
35392
  *
34998
35393
  * @since 4.0.0
34999
35394
  */
35000
- const TypeId$19 = "~effect/http/UrlParams";
35395
+ const TypeId$20 = "~effect/http/UrlParams";
35001
35396
  const Proto$9 = {
35002
35397
  ...PipeInspectableProto,
35003
- [TypeId$19]: TypeId$19,
35398
+ [TypeId$20]: TypeId$20,
35004
35399
  [Symbol.iterator]() {
35005
35400
  return this.params[Symbol.iterator]();
35006
35401
  },
@@ -35198,12 +35593,12 @@ const baseUrl = () => {
35198
35593
  *
35199
35594
  * @since 4.0.0
35200
35595
  */
35201
- const TypeId$18 = "~effect/http/HttpBody";
35596
+ const TypeId$19 = "~effect/http/HttpBody";
35202
35597
  TaggedError("HttpBodyError");
35203
35598
  var Proto$8 = class {
35204
- [TypeId$18];
35599
+ [TypeId$19];
35205
35600
  constructor() {
35206
- this[TypeId$18] = TypeId$18;
35601
+ this[TypeId$19] = TypeId$19;
35207
35602
  }
35208
35603
  [NodeInspectSymbol]() {
35209
35604
  return this.toJSON();
@@ -35430,9 +35825,9 @@ const allShort = [
35430
35825
  ];
35431
35826
  //#endregion
35432
35827
  //#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";
35828
+ const TypeId$18 = "~effect/http/HttpClientRequest";
35434
35829
  const Proto$7 = {
35435
- [TypeId$17]: TypeId$17,
35830
+ [TypeId$18]: TypeId$18,
35436
35831
  ...BaseProto,
35437
35832
  toJSON() {
35438
35833
  return {
@@ -35615,7 +36010,7 @@ const setBody$1 = /*#__PURE__*/ dual(2, (self, body) => {
35615
36010
  * @category type IDs
35616
36011
  * @since 4.0.0
35617
36012
  */
35618
- const TypeId$16 = "~effect/http/HttpIncomingMessage";
36013
+ const TypeId$17 = "~effect/http/HttpIncomingMessage";
35619
36014
  /**
35620
36015
  * Context reference for the optional maximum size allowed when reading an incoming message body.
35621
36016
  *
@@ -35693,7 +36088,7 @@ const inspect = (self, that) => {
35693
36088
  * @category type IDs
35694
36089
  * @since 4.0.0
35695
36090
  */
35696
- const TypeId$15 = "~effect/http/HttpClientResponse";
36091
+ const TypeId$16 = "~effect/http/HttpClientResponse";
35697
36092
  /**
35698
36093
  * Wraps a Web `Response` and its original `HttpClientRequest` as an `HttpClientResponse`.
35699
36094
  *
@@ -35702,16 +36097,16 @@ const TypeId$15 = "~effect/http/HttpClientResponse";
35702
36097
  */
35703
36098
  const fromWeb$1 = (request, source) => new WebHttpClientResponse(request, source);
35704
36099
  var WebHttpClientResponse = class extends Class$2 {
36100
+ [TypeId$17];
35705
36101
  [TypeId$16];
35706
- [TypeId$15];
35707
36102
  request;
35708
36103
  source;
35709
36104
  constructor(request, source) {
35710
36105
  super();
35711
36106
  this.request = request;
35712
36107
  this.source = source;
36108
+ this[TypeId$17] = TypeId$17;
35713
36109
  this[TypeId$16] = TypeId$16;
35714
- this[TypeId$15] = TypeId$15;
35715
36110
  }
35716
36111
  toJSON() {
35717
36112
  return inspect(this, {
@@ -35953,7 +36348,7 @@ const w3c = (headers) => {
35953
36348
  };
35954
36349
  //#endregion
35955
36350
  //#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";
36351
+ const TypeId$15 = "~effect/http/HttpClient";
35957
36352
  /**
35958
36353
  * Service tag for the default outgoing HTTP client service.
35959
36354
  *
@@ -35993,7 +36388,7 @@ const makeWith = (postprocess, preprocess) => {
35993
36388
  return self;
35994
36389
  };
35995
36390
  const Proto$6 = {
35996
- [TypeId$14]: TypeId$14,
36391
+ [TypeId$15]: TypeId$15,
35997
36392
  pipe() {
35998
36393
  return pipeArguments(this, arguments);
35999
36394
  },
@@ -36130,8 +36525,8 @@ var InterruptibleResponse = class {
36130
36525
  this.original = original;
36131
36526
  this.controller = controller;
36132
36527
  }
36133
- [TypeId$15] = TypeId$15;
36134
36528
  [TypeId$16] = TypeId$16;
36529
+ [TypeId$17] = TypeId$17;
36135
36530
  applyInterrupt(effect) {
36136
36531
  return suspend$2(() => {
36137
36532
  responseRegistry.unregister(this.original);
@@ -36815,14 +37210,14 @@ const make$29 = make$30;
36815
37210
  const ignore = "~effect/ErrorReporter/ignore";
36816
37211
  //#endregion
36817
37212
  //#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";
37213
+ const TypeId$14 = "~effect/http/HttpServerResponse";
36819
37214
  /**
36820
37215
  * Returns `true` when the supplied value is an `HttpServerResponse`.
36821
37216
  *
36822
37217
  * @category guards
36823
37218
  * @since 4.0.0
36824
37219
  */
36825
- const isHttpServerResponse = (u) => hasProperty(u, TypeId$13);
37220
+ const isHttpServerResponse = (u) => hasProperty(u, TypeId$14);
36826
37221
  /**
36827
37222
  * Creates an empty HTTP response.
36828
37223
  *
@@ -36955,7 +37350,7 @@ const setBody = /*#__PURE__*/ dual(2, (self, body) => makeResponse({
36955
37350
  }));
36956
37351
  const Proto$5 = {
36957
37352
  ...PipeInspectableProto,
36958
- [TypeId$13]: TypeId$13,
37353
+ [TypeId$14]: TypeId$14,
36959
37354
  [ignore]: true,
36960
37355
  toJSON() {
36961
37356
  return {
@@ -37153,7 +37548,7 @@ const toResponseOrElseDefect = (u, orElse) => {
37153
37548
  *
37154
37549
  * @since 4.0.0
37155
37550
  */
37156
- const TypeId$12 = "~effect/http/HttpServerError";
37551
+ const TypeId$13 = "~effect/http/HttpServerError";
37157
37552
  /**
37158
37553
  * Tagged error for failures that occur while handling an HTTP server request.
37159
37554
  *
@@ -37174,7 +37569,7 @@ var HttpServerError = class extends TaggedError("HttpServerError") {
37174
37569
  });
37175
37570
  else super(props);
37176
37571
  }
37177
- [TypeId$12] = TypeId$12;
37572
+ [TypeId$13] = TypeId$13;
37178
37573
  stack = `${this.name}: ${this.message}`;
37179
37574
  get request() {
37180
37575
  return this.reason.request;
@@ -37450,7 +37845,7 @@ const exitResponse = (exit) => {
37450
37845
  *
37451
37846
  * @since 2.0.0
37452
37847
  */
37453
- const TypeId$11 = "~effect/FiberSet";
37848
+ const TypeId$12 = "~effect/FiberSet";
37454
37849
  /**
37455
37850
  * Checks whether a value is a FiberSet.
37456
37851
  *
@@ -37470,9 +37865,9 @@ const TypeId$11 = "~effect/FiberSet";
37470
37865
  * @category refinements
37471
37866
  * @since 2.0.0
37472
37867
  */
37473
- const isFiberSet = (u) => hasProperty(u, TypeId$11);
37868
+ const isFiberSet = (u) => hasProperty(u, TypeId$12);
37474
37869
  const Proto$4 = {
37475
- [TypeId$11]: TypeId$11,
37870
+ [TypeId$12]: TypeId$12,
37476
37871
  [Symbol.iterator]() {
37477
37872
  if (this.state._tag === "Closed") return empty$14();
37478
37873
  return this.state.backing[Symbol.iterator]();
@@ -37651,7 +38046,7 @@ const join = (self) => _await(self.deferred);
37651
38046
  * @category type IDs
37652
38047
  * @since 4.0.0
37653
38048
  */
37654
- const TypeId$10 = "~effect/socket/Socket";
38049
+ const TypeId$11 = "~effect/socket/Socket";
37655
38050
  /**
37656
38051
  * Service tag for bidirectional socket transports.
37657
38052
  *
@@ -37672,7 +38067,7 @@ const Socket = /*#__PURE__*/ Service("effect/socket/Socket");
37672
38067
  * @since 4.0.0
37673
38068
  */
37674
38069
  const make$27 = (options) => Socket.of({
37675
- [TypeId$10]: TypeId$10,
38070
+ [TypeId$11]: TypeId$11,
37676
38071
  runRaw: options.runRaw,
37677
38072
  run: options.run ?? ((handler, opts) => options.runRaw((data) => typeof data === "string" ? handler(encoder.encode(data)) : data instanceof Uint8Array ? handler(data) : handler(new Uint8Array(data)), opts)),
37678
38073
  runString: options.runString ?? (options.run ? (handler, opts) => options.run((data) => handler(decoder$1.decode(data)), opts) : (handler, opts) => options.runRaw((data) => typeof data === "string" ? handler(data) : data instanceof Uint8Array ? handler(decoder$1.decode(data)) : handler(decoder$1.decode(new Uint8Array(data))), opts)),
@@ -38919,7 +39314,7 @@ const decodeField = decodeField$1;
38919
39314
  * @category type IDs
38920
39315
  * @since 4.0.0
38921
39316
  */
38922
- const TypeId$9 = "~effect/http/Multipart";
39317
+ const TypeId$10 = "~effect/http/Multipart";
38923
39318
  const MultipartErrorTypeId = "~effect/http/Multipart/MultipartError";
38924
39319
  /**
38925
39320
  * Error reason carried by a `MultipartError`.
@@ -38994,10 +39389,10 @@ const makeConfig = (headers) => withFiber((fiber) => {
38994
39389
  });
38995
39390
  });
38996
39391
  var PartBase$1 = class extends Class$2 {
38997
- [TypeId$9];
39392
+ [TypeId$10];
38998
39393
  constructor() {
38999
39394
  super();
39000
- this[TypeId$9] = TypeId$9;
39395
+ this[TypeId$10] = TypeId$10;
39001
39396
  }
39002
39397
  };
39003
39398
  const defaultWriteFile = (path, file) => flatMap$2(FileSystem, (fs) => mapError$2(run$1(file.content, fs.sink(path)), (cause) => MultipartError.fromReason("InternalError", cause)));
@@ -39114,7 +39509,7 @@ const FieldMimeTypes = /*#__PURE__*/ Reference("effect/http/Multipart/FieldMimeT
39114
39509
  * @category type IDs
39115
39510
  * @since 4.0.0
39116
39511
  */
39117
- const TypeId$8 = "~effect/http/HttpServerRequest";
39512
+ const TypeId$9 = "~effect/http/HttpServerRequest";
39118
39513
  /**
39119
39514
  * Service tag for the active server-side HTTP request.
39120
39515
  *
@@ -39770,7 +40165,7 @@ const withLogAddress = (layer) => effectDiscard(logAddress).pipe(provideMerge(la
39770
40165
  *
39771
40166
  * @since 4.0.0
39772
40167
  */
39773
- const TypeId$7 = "~effect/http/HttpRouter";
40168
+ const TypeId$8 = "~effect/http/HttpRouter";
39774
40169
  /**
39775
40170
  * Service tag for the HTTP router used while constructing an HTTP application.
39776
40171
  * Route and middleware layers require this service to register themselves with
@@ -39817,7 +40212,7 @@ const make$19 = /*#__PURE__*/ gen(function* () {
39817
40212
  return void_$1;
39818
40213
  });
39819
40214
  return HttpRouter.of({
39820
- [TypeId$7]: TypeId$7,
40215
+ [TypeId$8]: TypeId$8,
39821
40216
  prefixed(prefix) {
39822
40217
  return HttpRouter.of({
39823
40218
  ...this,
@@ -40272,7 +40667,7 @@ var ClientAbort = class extends Service()("effect/rpc/RpcSchema/ClientAbort") {
40272
40667
  };
40273
40668
  //#endregion
40274
40669
  //#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";
40670
+ const TypeId$7 = "~effect/rpc/Rpc";
40276
40671
  /**
40277
40672
  * Represents server-side metadata for the client associated with an RPC request.
40278
40673
  *
@@ -40302,7 +40697,7 @@ var ServerClient = class {
40302
40697
  }
40303
40698
  };
40304
40699
  const Proto$3 = {
40305
- [TypeId$6]: TypeId$6,
40700
+ [TypeId$7]: TypeId$7,
40306
40701
  pipe() {
40307
40702
  return pipeArguments(this, arguments);
40308
40703
  },
@@ -43045,7 +43440,7 @@ const withRun = () => (f) => suspend$2(() => {
43045
43440
  * @category type IDs
43046
43441
  * @since 4.0.0
43047
43442
  */
43048
- const TypeId$5 = "~effect/Stdio";
43443
+ const TypeId$6 = "~effect/Stdio";
43049
43444
  /**
43050
43445
  * Service tag for process standard I/O.
43051
43446
  *
@@ -43060,7 +43455,7 @@ const TypeId$5 = "~effect/Stdio";
43060
43455
  * @category services
43061
43456
  * @since 4.0.0
43062
43457
  */
43063
- const Stdio = /*#__PURE__*/ Service(TypeId$5);
43458
+ const Stdio = /*#__PURE__*/ Service(TypeId$6);
43064
43459
  /**
43065
43460
  * Creates a `Stdio` service implementation from the provided fields and
43066
43461
  * attaches the `Stdio` type identifier.
@@ -43082,7 +43477,7 @@ const Stdio = /*#__PURE__*/ Service(TypeId$5);
43082
43477
  * @since 4.0.0
43083
43478
  */
43084
43479
  const make$17 = (options) => ({
43085
- [TypeId$5]: TypeId$5,
43480
+ [TypeId$6]: TypeId$6,
43086
43481
  ...options
43087
43482
  });
43088
43483
  //#endregion
@@ -43380,7 +43775,7 @@ const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
43380
43775
  }).pipe(provide$3(scope));
43381
43776
  yield* forkChild(whileLoop({
43382
43777
  while: constTrue,
43383
- body: constant(flatMap$2(take$1(disconnects), (clientId) => {
43778
+ body: constant(flatMap$2(take$2(disconnects), (clientId) => {
43384
43779
  clients.delete(clientId);
43385
43780
  return server.disconnect(clientId);
43386
43781
  })),
@@ -44274,7 +44669,7 @@ function trieNodeAt(root, path) {
44274
44669
  }
44275
44670
  //#endregion
44276
44671
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Config.js
44277
- const TypeId$4 = "~effect/Config";
44672
+ const TypeId$5 = "~effect/Config";
44278
44673
  /**
44279
44674
  * Returns `true` if `u` is a `Config` instance.
44280
44675
  *
@@ -44295,7 +44690,7 @@ const TypeId$4 = "~effect/Config";
44295
44690
  * @category guards
44296
44691
  * @since 2.0.0
44297
44692
  */
44298
- const isConfig = (u) => hasProperty(u, TypeId$4);
44693
+ const isConfig = (u) => hasProperty(u, TypeId$5);
44299
44694
  /**
44300
44695
  * Represents the error type produced when config loading or validation fails.
44301
44696
  *
@@ -44339,7 +44734,7 @@ const Proto$1 = {
44339
44734
  return this.parse(fiber.getRef(ConfigProvider));
44340
44735
  }
44341
44736
  }),
44342
- [TypeId$4]: TypeId$4,
44737
+ [TypeId$5]: TypeId$5,
44343
44738
  toJSON() {
44344
44739
  return { _id: "Config" };
44345
44740
  }
@@ -44448,7 +44843,7 @@ const map = /*#__PURE__*/ dual(2, (self, f) => {
44448
44843
  * @category combinators
44449
44844
  * @since 2.0.0
44450
44845
  */
44451
- const orElse = /*#__PURE__*/ dual(2, (self, that) => {
44846
+ const orElse$2 = /*#__PURE__*/ dual(2, (self, that) => {
44452
44847
  return make$13((provider) => catch_$2(self.parse(provider), (error) => that(error).parse(provider)));
44453
44848
  });
44454
44849
  function isMissingDataOnly(issue) {
@@ -44502,7 +44897,7 @@ function isMissingDataOnly(issue) {
44502
44897
  * @since 2.0.0
44503
44898
  */
44504
44899
  const withDefault = /*#__PURE__*/ dual(2, (self, defaultValue) => {
44505
- return orElse(self, (err) => {
44900
+ return orElse$2(self, (err) => {
44506
44901
  if (isSchemaError(err.cause)) {
44507
44902
  const issue = err.cause.issue;
44508
44903
  if (isMissingDataOnly(issue)) return succeed(defaultValue);
@@ -48857,13 +49252,13 @@ var NodeHttpIncomingMessage = class extends Class$2 {
48857
49252
  *
48858
49253
  * @since 4.0.0
48859
49254
  */
48860
- [TypeId$16];
49255
+ [TypeId$17];
48861
49256
  source;
48862
49257
  onError;
48863
49258
  remoteAddressOverride;
48864
49259
  constructor(source, onError, remoteAddressOverride) {
48865
49260
  super();
48866
- this[TypeId$16] = TypeId$16;
49261
+ this[TypeId$17] = TypeId$17;
48867
49262
  this.source = source;
48868
49263
  this.onError = onError;
48869
49264
  this.remoteAddressOverride = remoteAddressOverride;
@@ -49251,10 +49646,10 @@ const persisted = (source, headers) => toPersisted(stream(source, headers), (pat
49251
49646
  }));
49252
49647
  const convertPart = (part) => part._tag === "Field" ? new FieldImpl(part.info, part.value) : new FileImpl(part);
49253
49648
  var PartBase = class extends Class$2 {
49254
- [TypeId$9];
49649
+ [TypeId$10];
49255
49650
  constructor() {
49256
49651
  super();
49257
- this[TypeId$9] = TypeId$9;
49652
+ this[TypeId$10] = TypeId$10;
49258
49653
  }
49259
49654
  };
49260
49655
  var FieldImpl = class extends PartBase {
@@ -49376,7 +49771,7 @@ function convertError(cause) {
49376
49771
  *
49377
49772
  * @since 4.0.0
49378
49773
  */
49379
- const TypeId$3 = "~effect/platform/Crypto";
49774
+ const TypeId$4 = "~effect/platform/Crypto";
49380
49775
  /**
49381
49776
  * Service tag for platform cryptography.
49382
49777
  *
@@ -49443,7 +49838,7 @@ const make$10 = (impl) => {
49443
49838
  };
49444
49839
  const nextIntUnsafe = () => Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;
49445
49840
  return Crypto.of({
49446
- [TypeId$3]: TypeId$3,
49841
+ [TypeId$4]: TypeId$4,
49447
49842
  randomBytes,
49448
49843
  nextDoubleUnsafe,
49449
49844
  nextIntUnsafe,
@@ -49663,7 +50058,7 @@ const toFileUrl = (path) => try_({
49663
50058
  * @since 4.0.0
49664
50059
  */
49665
50060
  const layer$11 = /* @__PURE__ */ succeed$4(Path$1)({
49666
- [TypeId$26]: TypeId$26,
50061
+ [TypeId$27]: TypeId$27,
49667
50062
  ...Path,
49668
50063
  fromFileUrl,
49669
50064
  toFileUrl
@@ -49739,7 +50134,7 @@ const layer$9 = /* @__PURE__ */ succeed$4(Stdio, /*#__PURE__*/ make$17({
49739
50134
  }));
49740
50135
  //#endregion
49741
50136
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Terminal.js
49742
- const TypeId$2 = "~effect/platform/Terminal";
50137
+ const TypeId$3 = "~effect/platform/Terminal";
49743
50138
  ErrorClass("QuitError")({ _tag: /*#__PURE__*/ tag("QuitError") });
49744
50139
  /**
49745
50140
  * Service tag for command-line input and output services.
@@ -49773,7 +50168,7 @@ const Terminal$1 = /*#__PURE__*/ Service("effect/platform/Terminal");
49773
50168
  */
49774
50169
  const make$8 = (impl) => Terminal$1.of({
49775
50170
  ...impl,
49776
- [TypeId$2]: TypeId$2
50171
+ [TypeId$3]: TypeId$3
49777
50172
  });
49778
50173
  /**
49779
50174
  * Provides the default process-backed `Terminal` service, ending key input on
@@ -50013,7 +50408,7 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
50013
50408
  });
50014
50409
  };
50015
50410
  var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage {
50016
- [TypeId$8];
50411
+ [TypeId$9];
50017
50412
  response;
50018
50413
  upgradeEffect;
50019
50414
  url;
@@ -50023,7 +50418,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
50023
50418
  request: this,
50024
50419
  cause
50025
50420
  }) }), remoteAddressOverride);
50026
- this[TypeId$8] = TypeId$8;
50421
+ this[TypeId$9] = TypeId$9;
50027
50422
  this.response = response;
50028
50423
  this.upgradeEffect = upgradeEffect;
50029
50424
  this.url = url;
@@ -50739,6 +51134,280 @@ const layer$5 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntra
50739
51134
  for (const logger of loggers) currentLoggers.add(isEffect$1(logger) ? yield* logger : logger);
50740
51135
  return currentLoggers;
50741
51136
  })));
51137
+ const ValueMatcherProto = {
51138
+ ["~effect/match/Match/Matcher"]: {
51139
+ _input: identity,
51140
+ _filters: identity,
51141
+ _result: identity,
51142
+ _return: identity
51143
+ },
51144
+ _tag: "ValueMatcher",
51145
+ add(_case) {
51146
+ if (isSuccess$1(this.value)) return this;
51147
+ if (_case._tag === "When" && _case.guard(this.provided) === true) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51148
+ else if (_case._tag === "Not" && _case.guard(this.provided) === false) return makeValueMatcher(this.provided, succeed$7(_case.evaluate(this.provided)));
51149
+ return this;
51150
+ },
51151
+ pipe() {
51152
+ return pipeArguments(this, arguments);
51153
+ }
51154
+ };
51155
+ function makeValueMatcher(provided, value) {
51156
+ const matcher = Object.create(ValueMatcherProto);
51157
+ matcher.provided = provided;
51158
+ matcher.value = value;
51159
+ return matcher;
51160
+ }
51161
+ const makeWhen = (guard, evaluate) => ({
51162
+ _tag: "When",
51163
+ guard,
51164
+ evaluate
51165
+ });
51166
+ const makePredicate = (pattern) => {
51167
+ if (typeof pattern === "function") return pattern;
51168
+ else if (Array.isArray(pattern)) {
51169
+ const predicates = pattern.map(makePredicate);
51170
+ const len = predicates.length;
51171
+ return (u) => {
51172
+ if (!Array.isArray(u)) return false;
51173
+ for (let i = 0; i < len; i++) if (predicates[i](u[i]) === false) return false;
51174
+ return true;
51175
+ };
51176
+ } else if (pattern !== null && typeof pattern === "object") {
51177
+ const keysAndPredicates = Object.entries(pattern).map(([k, p]) => [k, makePredicate(p)]);
51178
+ const len = keysAndPredicates.length;
51179
+ return (u) => {
51180
+ if (typeof u !== "object" || u === null) return false;
51181
+ for (let i = 0; i < len; i++) {
51182
+ const [key, predicate] = keysAndPredicates[i];
51183
+ if (!(key in u) || predicate(u[key]) === false) return false;
51184
+ }
51185
+ return true;
51186
+ };
51187
+ }
51188
+ return (u) => u === pattern;
51189
+ };
51190
+ /** @internal */
51191
+ const value$1 = (i) => makeValueMatcher(i, fail$7(i));
51192
+ /** @internal */
51193
+ const when$1 = (pattern, f) => (self) => self.add(makeWhen(makePredicate(pattern), f));
51194
+ /** @internal */
51195
+ const orElse$1 = (f) => (self) => {
51196
+ const toResult = result(self);
51197
+ if (isResult(toResult)) return toResult._tag === "Success" ? toResult.success : f(toResult.failure);
51198
+ return (input) => {
51199
+ const a = toResult(input);
51200
+ return isSuccess$1(a) ? a.success : f(a.failure);
51201
+ };
51202
+ };
51203
+ /** @internal */
51204
+ const result = (self) => {
51205
+ if (self._tag === "ValueMatcher") return self.value;
51206
+ const len = self.cases.length;
51207
+ if (len === 1) {
51208
+ const _case = self.cases[0];
51209
+ return (input) => {
51210
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51211
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51212
+ return fail$7(input);
51213
+ };
51214
+ }
51215
+ return (input) => {
51216
+ for (let i = 0; i < len; i++) {
51217
+ const _case = self.cases[i];
51218
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed$7(_case.evaluate(input));
51219
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed$7(_case.evaluate(input));
51220
+ }
51221
+ return fail$7(input);
51222
+ };
51223
+ };
51224
+ //#endregion
51225
+ //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Match.js
51226
+ /**
51227
+ * Pattern matching for TypeScript values, predicates, and tagged unions.
51228
+ *
51229
+ * `Match` turns branching logic into a matcher that is built from ordered
51230
+ * cases and finished with an explicit finalizer. Use `Match.type` to define a
51231
+ * reusable matcher for a type, or `Match.value` to classify one value
51232
+ * immediately. Cases can match literal values, predicates, object patterns,
51233
+ * discriminators, tags, or negated patterns.
51234
+ *
51235
+ * **Mental model**
51236
+ *
51237
+ * A matcher checks cases in the order they are added and evaluates the handler
51238
+ * for the first match. Type matchers produce a function that can be reused with
51239
+ * different inputs, while value matchers already contain the input value. As
51240
+ * cases are added, the type system tracks which inputs remain unmatched, so
51241
+ * `Match.exhaustive` is only available when every remaining case has been
51242
+ * handled.
51243
+ *
51244
+ * **Common tasks**
51245
+ *
51246
+ * - Use `Match.type<Union>()` when a branch table should be reusable and
51247
+ * exhaustiveness-checked.
51248
+ * - Use `Match.value(value)` when a single value should be matched immediately.
51249
+ * - Use `Match.tag`, `Match.tags`, or `Match.discriminator` for discriminated
51250
+ * unions and domain objects with tag fields.
51251
+ * - Use `Match.orElse`, `Match.option`, or `Match.result` when unmatched input
51252
+ * should be handled explicitly instead of requiring full exhaustiveness.
51253
+ *
51254
+ * **Example** (Matching a tagged union)
51255
+ *
51256
+ * ```ts
51257
+ * import { Match } from "effect"
51258
+ *
51259
+ * type Event =
51260
+ * | { readonly _tag: "UserCreated"; readonly id: string }
51261
+ * | { readonly _tag: "UserDeleted"; readonly id: string }
51262
+ *
51263
+ * const describe = Match.type<Event>().pipe(
51264
+ * Match.tag("UserCreated", (event) => `created ${event.id}`),
51265
+ * Match.tag("UserDeleted", (event) => `deleted ${event.id}`),
51266
+ * Match.exhaustive
51267
+ * )
51268
+ * ```
51269
+ *
51270
+ * @since 4.0.0
51271
+ */
51272
+ /**
51273
+ * Creates a matcher from a specific value.
51274
+ *
51275
+ * **When to use**
51276
+ *
51277
+ * Use to match one concrete input immediately.
51278
+ *
51279
+ * **Details**
51280
+ *
51281
+ * This function allows you to define a `Matcher` directly from a given value,
51282
+ * rather than from a type. This is useful when working with known values,
51283
+ * enabling structured pattern matching on objects, primitives, or any data
51284
+ * structure.
51285
+ *
51286
+ * Once the matcher is created, you can use pattern-matching functions like
51287
+ * {@link when} to define how different cases should be handled.
51288
+ *
51289
+ * **Example** (Matching an Object by Property)
51290
+ *
51291
+ * ```ts
51292
+ * import { Match } from "effect"
51293
+ *
51294
+ * const input = { name: "John", age: 30 }
51295
+ *
51296
+ * // Create a matcher for the specific object
51297
+ * const result = Match.value(input).pipe(
51298
+ * // Match when the 'name' property is "John"
51299
+ * Match.when(
51300
+ * { name: "John" },
51301
+ * (user) => `${user.name} is ${user.age} years old`
51302
+ * ),
51303
+ * // Provide a fallback if no match is found
51304
+ * Match.orElse(() => "Oh, not John")
51305
+ * )
51306
+ *
51307
+ * console.log(result)
51308
+ * // Output: "John is 30 years old"
51309
+ * ```
51310
+ *
51311
+ * @see {@link type} for creating a matcher from a specific type.
51312
+ *
51313
+ * @category constructors
51314
+ * @since 4.0.0
51315
+ */
51316
+ const value = value$1;
51317
+ /**
51318
+ * Defines a condition for matching values.
51319
+ *
51320
+ * **When to use**
51321
+ *
51322
+ * Use to add one positive pattern case to a `Match.type` or `Match.value`
51323
+ * pipeline when a direct value, predicate, or structured object pattern should
51324
+ * run a handler for matching input.
51325
+ *
51326
+ * **Details**
51327
+ *
51328
+ * Supports both direct value comparisons and predicate functions. If the
51329
+ * pattern matches, the associated function is executed and the matched input is
51330
+ * removed from the remaining cases tracked by the matcher.
51331
+ *
51332
+ * **Example** (Matching with Values and Predicates)
51333
+ *
51334
+ * ```ts
51335
+ * import { Match } from "effect"
51336
+ *
51337
+ * // Create a matcher for objects with an "age" property
51338
+ * const match = Match.type<{ age: number }>().pipe(
51339
+ * // Match when age is greater than 18
51340
+ * Match.when(
51341
+ * { age: (age: number) => age > 18 },
51342
+ * (user: { age: number }) => `Age: ${user.age}`
51343
+ * ),
51344
+ * // Match when age is exactly 18
51345
+ * Match.when({ age: 18 }, () => "You can vote"),
51346
+ * // Fallback case for all other ages
51347
+ * Match.orElse((user: { age: number }) => `${user.age} is too young`)
51348
+ * )
51349
+ *
51350
+ * console.log(match({ age: 20 }))
51351
+ * // Output: "Age: 20"
51352
+ *
51353
+ * console.log(match({ age: 18 }))
51354
+ * // Output: "You can vote"
51355
+ *
51356
+ * console.log(match({ age: 4 }))
51357
+ * // Output: "4 is too young"
51358
+ * ```
51359
+ *
51360
+ * @see {@link whenOr} for handling any one of several patterns with the same handler
51361
+ * @see {@link whenAnd} for requiring all provided patterns to match before running a handler
51362
+ * @see {@link not} for handling inputs that do not match a pattern
51363
+ * @see {@link orElse} for providing a fallback when no pattern case matches
51364
+ *
51365
+ * @category Defining patterns
51366
+ * @since 4.0.0
51367
+ */
51368
+ const when = when$1;
51369
+ /**
51370
+ * Provides a fallback value when no patterns match.
51371
+ *
51372
+ * **When to use**
51373
+ *
51374
+ * Use to finalize a matcher with a fallback for unmatched input.
51375
+ *
51376
+ * **Details**
51377
+ *
51378
+ * This function ensures that a matcher always returns a valid result, even if
51379
+ * no defined patterns match. It acts as a default case, similar to the
51380
+ * `default` clause in a `switch` statement or the final `else` in an `if-else`
51381
+ * chain.
51382
+ *
51383
+ * **Example** (Providing a Default Value When No Patterns Match)
51384
+ *
51385
+ * ```ts
51386
+ * import { Match } from "effect"
51387
+ *
51388
+ * // Create a matcher for string or number values
51389
+ * const match = Match.type<string | number>().pipe(
51390
+ * // Match when the value is "a"
51391
+ * Match.when("a", () => "ok"),
51392
+ * // Fallback when no patterns match
51393
+ * Match.orElse(() => "fallback")
51394
+ * )
51395
+ *
51396
+ * console.log(match("a"))
51397
+ * // Output: "ok"
51398
+ *
51399
+ * console.log(match("b"))
51400
+ * // Output: "fallback"
51401
+ * ```
51402
+ *
51403
+ * @see {@link option} for finalizing unmatched input as `Option.none`
51404
+ * @see {@link result} for returning unmatched input as a `Result` failure
51405
+ * @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible
51406
+ *
51407
+ * @category completion
51408
+ * @since 4.0.0
51409
+ */
51410
+ const orElse = orElse$1;
50742
51411
  //#endregion
50743
51412
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Random.js
50744
51413
  /**
@@ -51623,23 +52292,11 @@ var TerminalError = class extends TaggedErrorClass()("TerminalError", {
51623
52292
  cause: optional(Defect),
51624
52293
  message: optional(String$1)
51625
52294
  }) {};
51626
- const TerminalEvent = Union([Struct({
52295
+ const TerminalEvent = Struct({
51627
52296
  data: String$1,
52297
+ sequence: Number$1,
51628
52298
  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
- ]);
52299
+ });
51643
52300
  const TerminalState = Struct({
51644
52301
  runId: Number$1,
51645
52302
  state: Literals([
@@ -51647,7 +52304,6 @@ const TerminalState = Struct({
51647
52304
  "starting",
51648
52305
  "running",
51649
52306
  "waiting",
51650
- "needs_input",
51651
52307
  "stopped",
51652
52308
  "exited",
51653
52309
  "failed"
@@ -51655,15 +52311,12 @@ const TerminalState = Struct({
51655
52311
  title: String$1
51656
52312
  });
51657
52313
  function terminalStateActive(state) {
51658
- return state === "idle" || state === "starting" || state === "running" || state === "waiting" || state === "needs_input";
52314
+ return state === "idle" || state === "starting" || state === "running" || state === "waiting";
51659
52315
  }
51660
52316
  const TerminalUpdate = Union([Struct({
51661
52317
  state: TerminalState,
51662
52318
  type: Literal("state")
51663
- }), Struct({
51664
- event: TerminalEvent,
51665
- type: Literal("event")
51666
- })]);
52319
+ }), TerminalEvent]);
51667
52320
  //#endregion
51668
52321
  //#region src/rpcs/contracts.ts
51669
52322
  const TerminalPayload = Struct({
@@ -51873,8 +52526,7 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51873
52526
  data: String$1,
51874
52527
  env: optional(Record(String$1, String$1)),
51875
52528
  sessionId: optional(String$1)
51876
- }),
51877
- success: TerminalState
52529
+ })
51878
52530
  }), make$18("terminal.resize", {
51879
52531
  error: TerminalError,
51880
52532
  payload: Struct({
@@ -51885,12 +52537,16 @@ var RpcContracts = class extends make$15(make$18("agents.create", {
51885
52537
  env: optional(Record(String$1, String$1)),
51886
52538
  rows: Number$1,
51887
52539
  sessionId: optional(String$1)
51888
- }),
51889
- success: TerminalState
52540
+ })
51890
52541
  }), make$18("terminal.restart", {
51891
52542
  error: TerminalError,
51892
52543
  payload: TerminalPayload,
51893
52544
  success: TerminalState
52545
+ }), make$18("terminal.state.watch", {
52546
+ error: TerminalError,
52547
+ payload: TerminalPayload,
52548
+ stream: true,
52549
+ success: TerminalState
51894
52550
  }), make$18("terminal.stop", {
51895
52551
  error: TerminalError,
51896
52552
  payload: TerminalPayload,
@@ -52834,24 +53490,94 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
52834
53490
  };
52835
53491
  //#endregion
52836
53492
  //#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
- }
53493
+ var import_addon_progress = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
53494
+ (function(e, t) {
53495
+ "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.ProgressAddon = t() : e.ProgressAddon = t();
53496
+ })(globalThis, (() => (() => {
53497
+ "use strict";
53498
+ var e = {};
53499
+ return (() => {
53500
+ var t = e;
53501
+ function s(e) {
53502
+ let t = 0;
53503
+ for (let s = 0; s < e.length; ++s) {
53504
+ const r = e.charCodeAt(s);
53505
+ if (r < 48 || 57 < r) return -1;
53506
+ t = 10 * t + r - 48;
53507
+ }
53508
+ return t;
53509
+ }
53510
+ Object.defineProperty(t, "__esModule", { value: !0 }), t.ProgressAddon = void 0, t.ProgressAddon = class {
53511
+ constructor() {
53512
+ this._st = 0, this._pr = 0;
53513
+ }
53514
+ dispose() {
53515
+ this._seqHandler?.dispose(), this._onChange?.dispose();
53516
+ }
53517
+ activate(e) {
53518
+ this._seqHandler = e.parser.registerOscHandler(9, ((e) => {
53519
+ if (!e.startsWith("4;")) return !1;
53520
+ const t = e.split(";");
53521
+ if (t.length > 3) return !0;
53522
+ 2 === t.length && t.push("");
53523
+ const r = s(t[1]), o = s(t[2]);
53524
+ switch (r) {
53525
+ case 0:
53526
+ this.progress = {
53527
+ state: r,
53528
+ value: 0
53529
+ };
53530
+ break;
53531
+ case 1:
53532
+ if (o < 0) return !0;
53533
+ this.progress = {
53534
+ state: r,
53535
+ value: o
53536
+ };
53537
+ break;
53538
+ case 2:
53539
+ case 4:
53540
+ if (o < 0) return !0;
53541
+ this.progress = {
53542
+ state: r,
53543
+ value: o || this._pr
53544
+ };
53545
+ break;
53546
+ case 3: this.progress = {
53547
+ state: r,
53548
+ value: this._pr
53549
+ };
53550
+ }
53551
+ return !0;
53552
+ })), this._onChange = new e._core._onData.constructor(), this.onChange = this._onChange.event;
53553
+ }
53554
+ get progress() {
53555
+ return {
53556
+ state: this._st,
53557
+ value: this._pr
53558
+ };
53559
+ }
53560
+ set progress(e) {
53561
+ e.state < 0 || e.state > 4 ? console.warn("progress state out of bounds, not applied") : (this._st = e.state, this._pr = Math.min(Math.max(e.value, 0), 100), this._onChange?.fire({
53562
+ state: this._st,
53563
+ value: this._pr
53564
+ }));
53565
+ }
53566
+ };
53567
+ })(), e;
53568
+ })()));
53569
+ })))(), 1);
53570
+ const eventBacklogCapacity = 512;
53571
+ const terminalReset = "\x1Bc";
52846
53572
  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
53573
+ const trimmed = title.trim();
53574
+ if (/^\[\s*[!.]\s*\]\s*Action Required\b/iu.test(trimmed)) return {
53575
+ state: "waiting",
53576
+ title: trimmed.replace(/^\[\s*[!.]\s*\]\s*/iu, "") || trimmed
52851
53577
  };
52852
53578
  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();
53579
+ const nextTitle = trimmed.replace(/^OC\s*\|\s*/iu, "").replace(/^π\s*-\s*/iu, "").replace(/^\[\s*[^\]]+\s*\]\s*/u, "").replace(/^(?:[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏|/\\-]\s*)+/u, "").replace(/^\|\s*/u, "").trim() || trimmed;
53580
+ const segment = /^(Idle|Ready|Starting|Working|Thinking|Waiting)\b/iu.exec(nextTitle)?.[1]?.toLowerCase();
52855
53581
  if (segment === "idle" || segment === "ready") return {
52856
53582
  state: "idle",
52857
53583
  title: nextTitle
@@ -52868,7 +53594,7 @@ function parseTitleSignal(title) {
52868
53594
  state: "running",
52869
53595
  title: nextTitle
52870
53596
  };
52871
- if (isNonEmpty$1(trimmed)) return {
53597
+ if (trimmed !== "") return {
52872
53598
  state: "idle",
52873
53599
  title: nextTitle
52874
53600
  };
@@ -52877,65 +53603,95 @@ function parseTitleSignal(title) {
52877
53603
  title: ""
52878
53604
  };
52879
53605
  }
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
- };
53606
+ function snapshotEvents(data, sequence) {
53607
+ if (data === "") return empty$13();
53608
+ const events = [];
53609
+ for (let index = 0; index < data.length; index += 256 * 1024) events.push({
53610
+ data: data.slice(index, index + 256 * 1024),
53611
+ sequence,
53612
+ type: "data"
53613
+ });
53614
+ return events;
53615
+ }
53616
+ function adjacentGroups(items, sameGroup, merge) {
53617
+ return pipe(items, reduce(empty$13(), (groups, item) => {
53618
+ const next = groups;
53619
+ const previous = groups.at(-1);
53620
+ if (!(previous && sameGroup(previous, item))) {
53621
+ next.push(item);
53622
+ return next;
53623
+ }
53624
+ next[next.length - 1] = merge(previous, item);
53625
+ return next;
53626
+ }));
53627
+ }
53628
+ function queuedDataGroups(items, merge) {
53629
+ return adjacentGroups(items, (previous, item) => previous.generation === item.generation, merge);
53630
+ }
53631
+ function mergeQueuedData(previous, item) {
52895
53632
  return {
52896
- complete: input.slice(0, start),
52897
- pending: tail
53633
+ data: `${previous.data}${item.data}`,
53634
+ generation: item.generation
52898
53635
  };
52899
53636
  }
53637
+ function queuedWriteGroups(items) {
53638
+ return adjacentGroups(items, (previous, item) => previous.process === item.process, (previous, item) => ({
53639
+ data: `${previous.data}${item.data}`,
53640
+ process: item.process
53641
+ }));
53642
+ }
52900
53643
  var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { make: fnUntraced(function* (config) {
52901
53644
  const dataQueue = yield* unbounded();
52902
- const events = yield* bounded$1({ capacity: 256 });
53645
+ const screenQueue = yield* unbounded();
53646
+ const writeQueue = yield* unbounded();
53647
+ const resizeQueue = yield* sliding(1);
53648
+ const events = yield* bounded$1({
53649
+ capacity: 1024,
53650
+ replay: eventBacklogCapacity
53651
+ });
52903
53652
  const lifecycleLock = yield* make$47(1);
52904
53653
  const screenLock = yield* make$47(1);
52905
- const sequenceRef = yield* make$38(0);
52906
- const signalBuffer = yield* make$38("");
53654
+ const eventSequenceRef = yield* make$38(0);
53655
+ const parsedSequenceRef = yield* make$38(0);
53656
+ const screenGenerationRef = yield* make$38(0);
52907
53657
  const processRef = yield* make$38(void 0);
52908
53658
  const sizeRef = yield* make$38({
52909
53659
  cols: 120,
52910
53660
  rows: 32
52911
53661
  });
52912
53662
  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;
53663
+ const processCommand = config.command?.command ?? shell;
53664
+ const processArgs = config.command?.args ?? [];
53665
+ const processEnv = config.command?.options.env ?? {};
53666
+ const autostart = config.command === void 0;
52916
53667
  const stateRef = yield* make$3({
52917
53668
  runId: 0,
52918
53669
  state: autostart ? "starting" : "idle",
52919
53670
  title: ""
52920
53671
  });
52921
- const screen = new (createRequire(import.meta.url)("@xterm/headless")).Terminal({
53672
+ const screen = new HeadlessModule.Terminal({
52922
53673
  allowProposedApi: true,
52923
53674
  cols: 120,
52924
53675
  rows: 32,
52925
53676
  scrollback: 1e4
52926
53677
  });
52927
- const serialize = new (createRequire(import.meta.url)("@xterm/addon-serialize")).SerializeAddon();
53678
+ const serialize = new SerializeModule.SerializeAddon();
53679
+ const progress = new import_addon_progress.ProgressAddon();
52928
53680
  screen.loadAddon(serialize);
52929
- const publish$1 = fnUntraced(function* (event) {
53681
+ screen.loadAddon(progress);
53682
+ const publish$1 = fnUntraced(function* (data) {
53683
+ const sequence = yield* updateAndGet(eventSequenceRef, (sequence) => sequence + 1);
52930
53684
  yield* publish(events, {
52931
- event,
52932
- sequence: yield* updateAndGet(sequenceRef, (sequence) => sequence + 1)
53685
+ data,
53686
+ sequence,
53687
+ type: "data"
52933
53688
  });
53689
+ return sequence;
52934
53690
  });
52935
53691
  const requestSnapshot = withPermit(screenLock, gen(function* () {
52936
53692
  return {
52937
53693
  data: serialize.serialize({ scrollback: 1e4 }),
52938
- sequence: yield* get$3(sequenceRef)
53694
+ sequence: yield* get$3(parsedSequenceRef)
52939
53695
  };
52940
53696
  }));
52941
53697
  function setState(state) {
@@ -52944,9 +53700,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52944
53700
  state
52945
53701
  }));
52946
53702
  }
52947
- function setActiveState(state) {
53703
+ function setProgressState(progress) {
52948
53704
  return update(stateRef, (current) => {
52949
- if (current.state !== "idle" && current.state !== "starting" && current.state !== "running") return current;
53705
+ if (current.state === "stopped" || current.state === "exited" || current.state === "failed") return current;
53706
+ const state = pipe(progress.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
52950
53707
  return {
52951
53708
  ...current,
52952
53709
  state
@@ -52968,17 +53725,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52968
53725
  state: "starting",
52969
53726
  title: ""
52970
53727
  })), 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);
53728
+ screen.parser.registerOscHandler(0, (title) => {
53729
+ runFork(setTitle(title));
53730
+ return false;
53731
+ });
53732
+ screen.parser.registerOscHandler(2, (title) => {
53733
+ runFork(setTitle(title));
53734
+ return false;
53735
+ });
53736
+ progress.onChange((nextProgress) => {
53737
+ runFork(setProgressState(nextProgress));
52982
53738
  });
52983
53739
  const interruptProcess = fnUntraced(function* (subprocess, signal) {
52984
53740
  yield* sync(() => {
@@ -52992,14 +53748,14 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
52992
53748
  yield* sleep("250 millis");
52993
53749
  yield* interruptProcess(subprocess, "SIGKILL");
52994
53750
  });
52995
- const writeScreen = fnUntraced(function* (data) {
53751
+ const writeScreen = fnUntraced(function* (input) {
53752
+ if ((yield* get$3(screenGenerationRef)) !== input.generation) return;
52996
53753
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
52997
- screen.write(data, () => {
53754
+ screen.write(input.data, () => {
52998
53755
  resume(void_$1);
52999
53756
  });
53000
- }), andThen(readBufferedSignals(data)), andThen(publish$1({
53001
- data,
53002
- type: "data"
53757
+ }), andThen(gen(function* () {
53758
+ if ((yield* get$3(screenGenerationRef)) === input.generation) yield* set$4(parsedSequenceRef, yield* publish$1(input.data));
53003
53759
  }))));
53004
53760
  });
53005
53761
  const clearProcess = fnUntraced(function* (handle) {
@@ -53020,9 +53776,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53020
53776
  if (state) yield* setState(state);
53021
53777
  });
53022
53778
  const spawnProcess = fnUntraced(function* () {
53779
+ const generation = yield* updateAndGet(screenGenerationRef, (generation) => generation + 1);
53023
53780
  yield* withPermit(screenLock, pipe(sync(() => {
53024
53781
  screen.reset();
53025
- }), andThen(publish$1({ type: "reset" }))));
53782
+ }), andThen(publish$1(terminalReset)), tap((sequence) => set$4(parsedSequenceRef, sequence))));
53026
53783
  yield* startRun;
53027
53784
  const size = yield* get$3(sizeRef);
53028
53785
  const subprocess = yield* try_({
@@ -53035,7 +53792,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53035
53792
  cwd: config.cwd,
53036
53793
  env: {
53037
53794
  ...process.env,
53038
- ...config.env,
53795
+ ...processEnv,
53039
53796
  TERM: "xterm-256color"
53040
53797
  },
53041
53798
  name: "xterm-256color",
@@ -53044,7 +53801,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53044
53801
  });
53045
53802
  const handle = {
53046
53803
  data: subprocess.onData((data) => {
53047
- offerUnsafe(dataQueue, data);
53804
+ offerUnsafe(dataQueue, {
53805
+ data,
53806
+ generation
53807
+ });
53048
53808
  }),
53049
53809
  exit: subprocess.onExit((event) => {
53050
53810
  runFork(withPermit(lifecycleLock, gen(function* () {
@@ -53067,18 +53827,25 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53067
53827
  yield* stopProcess();
53068
53828
  return yield* spawnProcess();
53069
53829
  });
53070
- yield* pipe(fromQueue(dataQueue), runForEach(writeScreen), forkScoped);
53830
+ yield* pipe(fromQueue(dataQueue), groupedWithin(256, millis(8)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), (item) => gen(function* () {
53831
+ if ((yield* get$3(screenGenerationRef)) !== item.generation) return;
53832
+ yield* offer(screenQueue, item);
53833
+ }), { discard: true })), forkScoped);
53834
+ yield* pipe(fromQueue(screenQueue), groupedWithin(256, millis(16)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), writeScreen, { discard: true })), forkScoped);
53071
53835
  yield* addFinalizer(() => all([
53072
53836
  stopProcess(),
53073
53837
  shutdown$1(events),
53074
53838
  shutdown(dataQueue),
53839
+ shutdown(screenQueue),
53840
+ shutdown(writeQueue),
53841
+ shutdown(resizeQueue),
53075
53842
  sync(() => screen.dispose())
53076
53843
  ], {
53077
53844
  concurrency: "unbounded",
53078
53845
  discard: true
53079
53846
  }));
53080
53847
  if (autostart) yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => setState("failed")));
53081
- const resize = fnUntraced(function* (nextSize) {
53848
+ const resizeProcess = fnUntraced(function* (nextSize) {
53082
53849
  const size = yield* get$3(sizeRef);
53083
53850
  if (size.cols === nextSize.cols && size.rows === nextSize.rows) return;
53084
53851
  yield* set$4(sizeRef, nextSize);
@@ -53097,56 +53864,65 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53097
53864
  }
53098
53865
  });
53099
53866
  });
53100
- const write = fnUntraced(function* (data) {
53101
- const process = yield* get$3(processRef);
53102
- if (!process) return;
53867
+ yield* pipe(fromQueue(resizeQueue), groupedWithin(32, millis(16)), runForEach((items) => pipe(last(fromIterable$2(items)), match$5({
53868
+ onNone: () => void_$1,
53869
+ onSome: resizeProcess
53870
+ }))), forkScoped);
53871
+ const writeProcess = fnUntraced(function* (input) {
53872
+ if ((yield* get$3(processRef)) !== input.process) return;
53103
53873
  yield* try_({
53104
53874
  catch: (cause) => new TerminalError({
53105
53875
  cause,
53106
53876
  message: "failed to write to terminal"
53107
53877
  }),
53108
53878
  try: () => {
53109
- process.process.write(data);
53879
+ input.process.process.write(input.data);
53110
53880
  }
53111
53881
  });
53112
53882
  });
53883
+ yield* pipe(fromQueue(writeQueue), groupedWithin(128, millis(4)), runForEach((items) => forEach$1(queuedWriteGroups(fromIterable$2(items)), writeProcess, { discard: true })), forkScoped);
53113
53884
  const eventsStream = scoped$1(unwrap$1(gen(function* () {
53114
53885
  const subscription = yield* subscribe(events);
53115
53886
  const snapshot = yield* requestSnapshot;
53116
53887
  const pending = yield* takeUpTo(subscription, Number.POSITIVE_INFINITY);
53888
+ const replay = filter$2(pending, (event) => event.sequence > snapshot.sequence);
53889
+ const replaySequence = replay.at(-1)?.sequence ?? snapshot.sequence;
53117
53890
  return pipe(fromIterable$1([
53118
53891
  {
53119
- event: { type: "reset" },
53120
- sequence: snapshot.sequence
53892
+ data: terminalReset,
53893
+ sequence: snapshot.sequence,
53894
+ type: "data"
53121
53895
  },
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))));
53896
+ ...snapshotEvents(snapshot.data, snapshot.sequence),
53897
+ ...replay,
53898
+ ...filter$2(pending, (event) => event.sequence > replaySequence)
53899
+ ]), concat(fromEffectRepeat(take$3(subscription))));
53128
53900
  })));
53129
- const updates = merge$1(changes(stateRef).pipe(map$2((state) => ({
53901
+ const stateUpdates = unwrap$1(pipe(get(stateRef), map$4((state) => concat(drop(1)(changes(stateRef)))(make$43(state)))));
53902
+ const updates = merge$1(stateUpdates.pipe(map$2((state) => ({
53130
53903
  state,
53131
53904
  type: "state"
53132
- }))), eventsStream.pipe(map$2((published) => ({
53133
- event: published.event,
53134
- type: "event"
53135
- }))));
53905
+ }))), eventsStream);
53136
53906
  return {
53137
53907
  resize: fnUntraced(function* (size) {
53138
- return yield* pipe(resize(size), andThen(get(stateRef)));
53908
+ yield* offer(resizeQueue, size);
53139
53909
  }),
53140
53910
  restart: fnUntraced(function* () {
53141
53911
  return yield* pipe(startProcess(), withPermit(lifecycleLock), catch_$2(() => pipe(setState("failed"), andThen(get(stateRef)))));
53142
53912
  }),
53913
+ stateUpdates,
53143
53914
  stop: fnUntraced(function* () {
53144
53915
  yield* pipe(stopProcess("stopped"), withPermit(lifecycleLock));
53145
53916
  return yield* get(stateRef);
53146
53917
  }),
53147
53918
  updates,
53148
53919
  write: fnUntraced(function* (data) {
53149
- return yield* pipe(write(data), andThen(get(stateRef)));
53920
+ if (data === "") return;
53921
+ const process = yield* get$3(processRef);
53922
+ if (process) yield* offer(writeQueue, {
53923
+ data,
53924
+ process
53925
+ });
53150
53926
  })
53151
53927
  };
53152
53928
  }) }) {
@@ -53216,14 +53992,33 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53216
53992
  const script = pipe(yield* get$3(portlessScripts), get$1(input.sessionId), getOrUndefined$1);
53217
53993
  if (script === void 0) return input;
53218
53994
  return {
53995
+ command: make$40(script.preparedCommand.command, script.preparedCommand.args, {
53996
+ ...script.preparedCommand.options,
53997
+ env: script.env
53998
+ }),
53219
53999
  cwd: script.cwd,
53220
- env: script.env,
53221
- preparedCommand: script.preparedCommand,
53222
54000
  sessionId: script.sessionId
53223
54001
  };
53224
54002
  });
54003
+ function terminalSessionInput(session) {
54004
+ if ("args" in session || "env" in session) return {
54005
+ command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
54006
+ cwd: session.cwd,
54007
+ sessionId: session.sessionId
54008
+ };
54009
+ if (typeof session.command === "string") return {
54010
+ command: make$40(session.command),
54011
+ cwd: session.cwd,
54012
+ sessionId: session.sessionId
54013
+ };
54014
+ return {
54015
+ command: session.command,
54016
+ cwd: session.cwd,
54017
+ sessionId: session.sessionId
54018
+ };
54019
+ }
53225
54020
  const terminal = fnUntraced(function* (input) {
53226
- return yield* pipe(terminalSession(input), flatMap$2((session) => get$6(terminals, session)));
54021
+ return yield* pipe(terminalSession(input), map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
53227
54022
  });
53228
54023
  const reviewStateKey = fnUntraced(function* (input) {
53229
54024
  const root = yield* pipe(fs.realPath(input.cwd), orElseSucceed(() => input.cwd));
@@ -53270,14 +54065,14 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53270
54065
  cwd: session.cwd,
53271
54066
  uuid: session.uuid
53272
54067
  }), session));
53273
- const terminal = yield* get$6(terminals, TerminalSessionKey.make({
54068
+ const terminal = yield* terminalSession(TerminalSessionKey.make({
53274
54069
  args: session.args,
53275
54070
  command: session.command,
53276
54071
  cwd: session.cwd,
53277
54072
  sessionId: session.uuid
53278
- }));
54073
+ })).pipe(map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
53279
54074
  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({
54075
+ yield* pipe(terminal.stateUpdates, map$2((state) => state.state), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (current) => remove$2(current, AgentSessionKey.make({
53281
54076
  cwd: session.cwd,
53282
54077
  uuid: session.uuid
53283
54078
  })))), forkDetach);
@@ -53345,6 +54140,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
53345
54140
  rows: payload.rows
53346
54141
  }))),
53347
54142
  "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
54143
+ "terminal.state.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stateUpdates)),
53348
54144
  "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
53349
54145
  "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
53350
54146
  "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
@@ -66844,7 +67640,7 @@ var OtelSpan = class {
66844
67640
  this.links = options.links;
66845
67641
  this.kind = options.kind;
66846
67642
  const active = contextApi.active();
66847
- this.parent = options.root !== true ? orElse$1(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
67643
+ this.parent = options.root !== true ? orElse$3(options.parent, () => getOtelParent(traceApi, active, options.annotations)) : options.parent;
66848
67644
  this.span = tracer.startSpan(options.name, {
66849
67645
  startTime: nanosToHrTime(options.startTime),
66850
67646
  links: options.links.length > 0 ? options.links.map((link) => ({