@deslop/portfolio 0.1.1248 → 0.1.1249

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.
package/dist/server.js CHANGED
@@ -5034,41 +5034,6 @@ const mergeAll$2 = (...ctxs) => {
5034
5034
  return makeUnsafe$9(map);
5035
5035
  };
5036
5036
  /**
5037
- * Returns a new `Context` with the specified service keys removed.
5038
- *
5039
- * **When to use**
5040
- *
5041
- * Use when you want to remove a denylist of services from a `Context`.
5042
- *
5043
- * **Example** (Omitting services from a context)
5044
- *
5045
- * ```ts import.meta.vitest
5046
- * import { Context, Option, pipe } from "effect"
5047
- *
5048
- * const Port = Context.Service<{ PORT: number }>("Port")
5049
- * const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
5050
- *
5051
- * const someContext = pipe(
5052
- * Context.make(Port, { PORT: 8080 }),
5053
- * Context.add(Timeout, { TIMEOUT: 5000 })
5054
- * )
5055
- *
5056
- * const context = pipe(someContext, Context.omit(Timeout))
5057
- *
5058
- * Context.getOption(context, Port) // => Option.some({ PORT: 8080 })
5059
- * Context.getOption(context, Timeout) // => Option.none()
5060
- * ```
5061
- *
5062
- * @see {@link pick} for keeping selected services
5063
- *
5064
- * @stability stable
5065
- * @category filtering
5066
- * @since 2.0.0
5067
- */
5068
- const omit$1 = (...keys) => (self) => withFlat(self, (map) => {
5069
- for (let i = 0; i < keys.length; i++) map.delete(keys[i].key);
5070
- });
5071
- /**
5072
5037
  * Creates a context key with a default value.
5073
5038
  *
5074
5039
  * **When to use**
@@ -9696,7 +9661,7 @@ const forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, optio
9696
9661
  step: constVoid
9697
9662
  }));
9698
9663
  /** @internal */
9699
- const catchCause$2 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
9664
+ const catchCause$3 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
9700
9665
  const OnFailureProto = /*#__PURE__*/ makePrimitiveProto({
9701
9666
  op: "OnFailure",
9702
9667
  [evaluate$1]: evaluateCont
@@ -9707,7 +9672,7 @@ const OnFailureImpl = function(self, f) {
9707
9672
  };
9708
9673
  OnFailureImpl.prototype = OnFailureProto;
9709
9674
  /** @internal */
9710
- const catchCauseFilter$1 = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(self, (cause) => {
9675
+ const catchCauseFilter$1 = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$3(self, (cause) => {
9711
9676
  const eb = filter(cause);
9712
9677
  return isFailure$1(eb) ? failCause$5(eb.failure) : f(eb.success, cause);
9713
9678
  }));
@@ -9716,9 +9681,9 @@ const catch_$2 = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter$1(self, fin
9716
9681
  /** @internal */
9717
9682
  const catchDefect$1 = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter$1(self, findDefect, f));
9718
9683
  /** @internal */
9719
- const tapCause$1 = /*#__PURE__*/ dual(2, (self, f) => catchCause$2(self, (cause) => andThen$1(f(cause), failCause$5(cause))));
9684
+ const tapCause$1 = /*#__PURE__*/ dual(2, (self, f) => catchCause$3(self, (cause) => andThen$1(f(cause), failCause$5(cause))));
9720
9685
  /** @internal */
9721
- const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(self, (cause) => {
9686
+ const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$3(self, (cause) => {
9722
9687
  const result = filter(cause);
9723
9688
  if (isFailure$1(result)) return failCause$5(cause);
9724
9689
  return andThen$1(f(result.success, cause), failCause$5(cause));
@@ -9726,14 +9691,14 @@ const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(s
9726
9691
  /** @internal */
9727
9692
  const tapError$4 = /*#__PURE__*/ dual(2, (self, f) => tapCauseFilter(self, findError, (e) => f(e)));
9728
9693
  /** @internal */
9729
- const catchIf$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, f, orElse) => catchCause$2(self, (cause) => {
9694
+ const catchIf$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, f, orElse) => catchCause$3(self, (cause) => {
9730
9695
  const error = findRecoverableError(cause);
9731
9696
  if (isFailure$1(error)) return failCause$5(error.failure);
9732
9697
  if (!predicate(error.success)) return orElse ? orElse(error.success) : failCause$5(cause);
9733
9698
  return f(error.success);
9734
9699
  }));
9735
9700
  /** @internal */
9736
- const catchFilter$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, filter, f, orElse) => catchCause$2(self, (cause) => {
9701
+ const catchFilter$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, filter, f, orElse) => catchCause$3(self, (cause) => {
9737
9702
  const error = findRecoverableError(cause);
9738
9703
  if (isFailure$1(error)) return failCause$5(error.failure);
9739
9704
  const result = filter(error.success);
@@ -9760,7 +9725,7 @@ const catchReason$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, e
9760
9725
  return orElse ? orElse(reason, e) : fail$11(e);
9761
9726
  }));
9762
9727
  /** @internal */
9763
- const mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catchCause$2(self, (cause) => failCause$5(causeMap(cause, f))));
9728
+ const mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catchCause$3(self, (cause) => failCause$5(causeMap(cause, f))));
9764
9729
  /** @internal */
9765
9730
  const mapBoth = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(self, {
9766
9731
  onFailure: (cause) => failCause$5(causeMap(cause, options.onFailure)),
@@ -9888,9 +9853,9 @@ const delay$1 = /*#__PURE__*/ dual(2, (self, duration) => andThen$1(sleep$1(dura
9888
9853
  /** @internal */
9889
9854
  const timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$4(timeoutOption$1(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$9(option.value)));
9890
9855
  /** @internal */
9891
- const timeoutErrorFromDuration = (duration) => new TimeoutError(`Operation timed out after '${format$1(duration)}'`);
9856
+ const timeoutErrorFromDuration = (duration) => new TimeoutError$1(`Operation timed out after '${format$1(duration)}'`);
9892
9857
  /** @internal */
9893
- const timeout$1 = /*#__PURE__*/ dual(2, (self, duration) => {
9858
+ const timeout$2 = /*#__PURE__*/ dual(2, (self, duration) => {
9894
9859
  const decoded = fromInputUnsafe$1(duration);
9895
9860
  return timeoutOrElse$1(self, {
9896
9861
  duration: decoded,
@@ -9932,7 +9897,7 @@ const runFinalizer = (finalizer, exit_) => {
9932
9897
  return exitDie(defect);
9933
9898
  }
9934
9899
  };
9935
- const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause$2(finalizer, (cause) => failCause$5(causeElectDefects(causeCombine(exit_.cause, cause))));
9900
+ const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause$3(finalizer, (cause) => failCause$5(causeElectDefects(causeCombine(exit_.cause, cause))));
9936
9901
  const scopeCloseFinalizers = /*#__PURE__*/ fnUntraced$1(function* (self, finalizers, exit_) {
9937
9902
  let exits = [];
9938
9903
  const fibers = [];
@@ -10680,6 +10645,15 @@ const withSpan$1 = function() {
10680
10645
  return (self, ...args) => useSpan$1(name, fnArg ? fnArg(...args) : options, (span) => withParentSpan$1(self, span, traceOptions));
10681
10646
  };
10682
10647
  /** @internal */
10648
+ const annotateCurrentSpan$1 = (...args) => withFiber$1((fiber) => {
10649
+ const span = fiber.currentSpanLocal;
10650
+ if (span && span.status._tag !== "Ended") {
10651
+ if (args.length === 1) for (const [key, value] of Object.entries(args[0])) span.attribute(key, value);
10652
+ else span.attribute(args[0], args[1]);
10653
+ }
10654
+ return void_$3;
10655
+ });
10656
+ /** @internal */
10683
10657
  const ClockRef = /*#__PURE__*/ Reference("effect/Clock", { defaultValue: () => new ClockImpl() });
10684
10658
  const MAX_TIMER_MILLIS = 2 ** 31 - 1;
10685
10659
  var ClockImpl = class {
@@ -10747,7 +10721,7 @@ const TimeoutErrorTypeId = "~effect/Cause/TimeoutError";
10747
10721
  /** @internal */
10748
10722
  const isTimeoutError$1 = (u) => hasProperty(u, TimeoutErrorTypeId);
10749
10723
  /** @internal */
10750
- var TimeoutError = class extends (/*#__PURE__*/ TaggedError$2("TimeoutError")) {
10724
+ var TimeoutError$1 = class extends (/*#__PURE__*/ TaggedError$2("TimeoutError")) {
10751
10725
  [TimeoutErrorTypeId] = TimeoutErrorTypeId;
10752
10726
  constructor(message) {
10753
10727
  super({ message });
@@ -11578,6 +11552,22 @@ const done$2 = done$3;
11578
11552
  */
11579
11553
  const isTimeoutError = isTimeoutError$1;
11580
11554
  /**
11555
+ * Constructs a `TimeoutError` with an optional message.
11556
+ *
11557
+ * **Example** (Creating a TimeoutError)
11558
+ *
11559
+ * ```ts import.meta.vitest
11560
+ * import { Cause } from "effect"
11561
+ *
11562
+ * new Cause.TimeoutError("Operation timed out").message // => "Operation timed out"
11563
+ * ```
11564
+ *
11565
+ * @stability stable
11566
+ * @category constructors
11567
+ * @since 4.0.0
11568
+ */
11569
+ const TimeoutError = TimeoutError$1;
11570
+ /**
11581
11571
  * Constructs an `IllegalArgumentError` with an optional message.
11582
11572
  *
11583
11573
  * **Example** (Creating an IllegalArgumentError)
@@ -13917,6 +13907,63 @@ const provideMerge = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, tha
13917
13907
  */
13918
13908
  const flatMap$3 = /*#__PURE__*/ dual(2, (self, f) => fromBuild((memoMap, scope) => flatMap$4(self.build(memoMap, scope), (context) => f(context).build(memoMap, scope))));
13919
13909
  /**
13910
+ * Recovers from any failure cause by switching to another layer.
13911
+ *
13912
+ * **When to use**
13913
+ *
13914
+ * Use when you need `Layer` recovery to inspect more than the typed error,
13915
+ * such as defects or interruption information.
13916
+ *
13917
+ * **Details**
13918
+ *
13919
+ * The handler receives the full `Cause` of the failed layer, including typed
13920
+ * errors, unexpected defects, and interruption information, and returns the
13921
+ * fallback layer to build instead. Finalizers for resources acquired by the
13922
+ * failed layer are still run before the fallback layer is acquired.
13923
+ *
13924
+ * **Example** (Recovering from layer failures by cause)
13925
+ *
13926
+ * ```ts import.meta.vitest
13927
+ * import { Context, Data, Effect, Layer } from "effect"
13928
+ *
13929
+ * class DatabaseError extends Data.TaggedError("DatabaseError")<{
13930
+ * message: string
13931
+ * }> {}
13932
+ *
13933
+ * class Database extends Context.Service<Database, {
13934
+ * readonly query: (sql: string) => Effect.Effect<string>
13935
+ * }>()("Database") {}
13936
+ *
13937
+ * const primaryDatabaseLayer = Layer.effect(Database,
13938
+ * Effect.fail(new DatabaseError({ message: "Primary DB unreachable" }))
13939
+ * )
13940
+ *
13941
+ * const databaseWithFallback = primaryDatabaseLayer.pipe(
13942
+ * Layer.catchCause(() => {
13943
+ * return Layer.succeed(Database, {
13944
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Memory: ${sql}`))
13945
+ * })
13946
+ * })
13947
+ * )
13948
+ *
13949
+ * const program = Effect.gen(function*() {
13950
+ * const database = yield* Database
13951
+ * return yield* database.query("SELECT * FROM users")
13952
+ * }).pipe(
13953
+ * Effect.provide(databaseWithFallback)
13954
+ * )
13955
+ *
13956
+ * await Effect.runPromise(program) // => "Memory: SELECT * FROM users"
13957
+ * ```
13958
+ *
13959
+ * @see {@link catchTag} for recovering from specific tagged errors
13960
+ *
13961
+ * @stability stable
13962
+ * @category error handling
13963
+ * @since 4.0.0
13964
+ */
13965
+ const catchCause$2 = /*#__PURE__*/ dual(2, (self, onError) => fromBuildUnsafe((memoMap, scope) => catchCause$3(self.build(memoMap, scope), (cause) => onError(cause).build(memoMap, scope))));
13966
+ /**
13920
13967
  * Builds this layer and keeps it alive until the returned effect is interrupted.
13921
13968
  *
13922
13969
  * **When to use**
@@ -14579,6 +14626,23 @@ globalThis.String;
14579
14626
  */
14580
14627
  const toUpperCase = (self) => self.toUpperCase();
14581
14628
  /**
14629
+ * Converts a string to lowercase.
14630
+ *
14631
+ * **Example** (Converting strings to lowercase)
14632
+ *
14633
+ * ```ts import.meta.vitest
14634
+ * import { pipe, String } from "effect"
14635
+ *
14636
+ * pipe("A", String.toLowerCase) // => "a"
14637
+ * String.toLowerCase("HELLO") // => "hello"
14638
+ * ```
14639
+ *
14640
+ * @stability stable
14641
+ * @category transforming
14642
+ * @since 2.0.0
14643
+ */
14644
+ const toLowerCase = (self) => self.toLowerCase();
14645
+ /**
14582
14646
  * Capitalizes the first character (Unicode code point) of a string.
14583
14647
  *
14584
14648
  * **Example** (Capitalizing a string)
@@ -14643,6 +14707,23 @@ const split$1 = /*#__PURE__*/ dual(2, (self, separator) => {
14643
14707
  return isArrayNonEmpty$1(out) ? out : [self];
14644
14708
  });
14645
14709
  /**
14710
+ * Returns `true` if the string starts with the specified search string.
14711
+ *
14712
+ * **Example** (Checking string prefixes)
14713
+ *
14714
+ * ```ts import.meta.vitest
14715
+ * import { pipe, String } from "effect"
14716
+ *
14717
+ * pipe("hello world", String.startsWith("hello")) // => true
14718
+ * pipe("hello world", String.startsWith("world")) // => false
14719
+ * ```
14720
+ *
14721
+ * @stability stable
14722
+ * @category predicates
14723
+ * @since 2.0.0
14724
+ */
14725
+ const startsWith = (searchString, position) => (self) => self.startsWith(searchString, position);
14726
+ /**
14646
14727
  * Returns `true` if the string ends with the specified search string.
14647
14728
  *
14648
14729
  * **Example** (Checking string suffixes)
@@ -15052,7 +15133,7 @@ const fromStepWithMetadata = (step) => fromStep(map$7(step, (f) => {
15052
15133
  * @category destructors
15053
15134
  * @since 4.0.0
15054
15135
  */
15055
- const toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$9(() => failCause$5(cause)));
15136
+ const toStep = (schedule) => catchCause$3(schedule.step, (cause) => succeed$9(() => failCause$5(cause)));
15056
15137
  /**
15057
15138
  * Extracts a step function from a `Schedule` that sleeps for each computed
15058
15139
  * delay and returns metadata for the completed step.
@@ -16905,7 +16986,7 @@ const catchReason = catchReason$1;
16905
16986
  * @category error handling
16906
16987
  * @since 4.0.0
16907
16988
  */
16908
- const catchCause$1 = catchCause$2;
16989
+ const catchCause$1 = catchCause$3;
16909
16990
  /**
16910
16991
  * Recovers from defects using a provided recovery function.
16911
16992
  *
@@ -17411,7 +17492,7 @@ const orElseSucceed = orElseSucceed$1;
17411
17492
  * @category delays & timeouts
17412
17493
  * @since 2.0.0
17413
17494
  */
17414
- const timeout = timeout$1;
17495
+ const timeout$1 = timeout$2;
17415
17496
  /**
17416
17497
  * Runs an effect with a time limit and represents only the timeout case as
17417
17498
  * `Option.none`.
@@ -18819,6 +18900,31 @@ const repeat = repeat$1;
18819
18900
  */
18820
18901
  const withTracerEnabled = withTracerEnabled$1;
18821
18902
  /**
18903
+ * Adds an annotation to the current span if available.
18904
+ *
18905
+ * **Example** (Annotating the current span)
18906
+ *
18907
+ * ```ts import.meta.vitest
18908
+ * import { Effect } from "effect"
18909
+ *
18910
+ * const program = Effect.gen(function*() {
18911
+ * yield* Effect.annotateCurrentSpan("userId", "123")
18912
+ * yield* Effect.annotateCurrentSpan({
18913
+ * operation: "user-lookup"
18914
+ * })
18915
+ * return "success"
18916
+ * })
18917
+ *
18918
+ * const traced = Effect.withSpan(program, "user-operation")
18919
+ * Effect.runSync(traced) // => "success"
18920
+ * ```
18921
+ *
18922
+ * @stability stable
18923
+ * @category tracing
18924
+ * @since 2.0.0
18925
+ */
18926
+ const annotateCurrentSpan = annotateCurrentSpan$1;
18927
+ /**
18822
18928
  * Create a new span for tracing, and automatically close it when the effect
18823
18929
  * completes.
18824
18930
  *
@@ -19534,6 +19640,31 @@ const log$1 = /*#__PURE__*/ logWithLevel();
19534
19640
  */
19535
19641
  const logFatal = /*#__PURE__*/ logWithLevel("Fatal");
19536
19642
  /**
19643
+ * Logs one or more messages at the WARNING level.
19644
+ *
19645
+ * **Example** (Logging warnings)
19646
+ *
19647
+ * ```ts import.meta.vitest
19648
+ * import { Effect, Logger } from "effect"
19649
+ * const output: Array<unknown> = []
19650
+ *
19651
+ * const program = Effect.gen(function*() {
19652
+ * yield* Effect.logWarning("API rate limit approaching")
19653
+ * })
19654
+ *
19655
+ * const logger = Logger.make<unknown, void>(({ logLevel, message }) => {
19656
+ * void output.push(`${logLevel}: ${Array.isArray(message) ? message.map(String).join(" ") : String(message)}`)
19657
+ * })
19658
+ * Effect.runSync(Effect.provide(program, Logger.layer([logger])))
19659
+ * output // => ["Warn: API rate limit approaching"]
19660
+ * ```
19661
+ *
19662
+ * @stability stable
19663
+ * @category logging
19664
+ * @since 2.0.0
19665
+ */
19666
+ const logWarning = /*#__PURE__*/ logWithLevel("Warn");
19667
+ /**
19537
19668
  * Logs one or more messages at the ERROR level.
19538
19669
  *
19539
19670
  * **Example** (Logging errors)
@@ -27817,7 +27948,7 @@ const compose = /*#__PURE__*/ dual(2, (self, other) => {
27817
27948
  if (other._tag === "Passthrough") return self;
27818
27949
  switch (self._tag) {
27819
27950
  case "Transform": switch (other._tag) {
27820
- case "Transform": return transform$2((input) => other.transform(self.transform(input)));
27951
+ case "Transform": return transform$3((input) => other.transform(self.transform(input)));
27821
27952
  case "TransformOptional": return transformOptional((input) => other.transform(map$11(input, self.transform)));
27822
27953
  case "TransformEffect": return transformEffect$1((input, options) => other.transform(self.transform(input), options));
27823
27954
  case "TransformOptionalEffect": return composeOptionalEffect(self, other);
@@ -27879,7 +28010,7 @@ function passthrough$1() {
27879
28010
  * @category transforming
27880
28011
  * @since 4.0.0
27881
28012
  */
27882
- function transform$2(f) {
28013
+ function transform$3(f) {
27883
28014
  return makeGetter({
27884
28015
  _tag: "Transform",
27885
28016
  transform: f
@@ -28006,7 +28137,7 @@ function transformOptionalEffect(f) {
28006
28137
  * @since 4.0.0
28007
28138
  */
28008
28139
  function String$8() {
28009
- return transform$2(globalThis.String);
28140
+ return transform$3(globalThis.String);
28010
28141
  }
28011
28142
  /**
28012
28143
  * Coerces any value to a `number` using the global `Number()` constructor.
@@ -28037,7 +28168,7 @@ function String$8() {
28037
28168
  * @since 4.0.0
28038
28169
  */
28039
28170
  function Number$4() {
28040
- return transform$2(globalThis.Number);
28171
+ return transform$3(globalThis.Number);
28041
28172
  }
28042
28173
  function parseJson(options) {
28043
28174
  return transformEffect$1((input, parseOptions) => try_({
@@ -28127,7 +28258,7 @@ function splitKeyValue$1(options) {
28127
28258
  const keyValueSeparator = options?.keyValueSeparator ?? "=";
28128
28259
  const trim = options?.trim ?? false;
28129
28260
  const keepEmptyValues = options?.keepEmptyValues ?? false;
28130
- return transform$2((input) => input.split(separator).reduce((acc, pair) => {
28261
+ return transform$3((input) => input.split(separator).reduce((acc, pair) => {
28131
28262
  let key;
28132
28263
  let value;
28133
28264
  if (keyValueSeparator === "") {
@@ -28181,7 +28312,7 @@ function splitKeyValue$1(options) {
28181
28312
  function joinKeyValue(options) {
28182
28313
  const separator = options?.separator ?? ",";
28183
28314
  const keyValueSeparator = options?.keyValueSeparator ?? "=";
28184
- return transform$2((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
28315
+ return transform$3((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
28185
28316
  }
28186
28317
  /**
28187
28318
  * Splits a string into an array of strings by a separator.
@@ -28214,7 +28345,7 @@ function joinKeyValue(options) {
28214
28345
  */
28215
28346
  function split(options) {
28216
28347
  const separator = options?.separator ?? ",";
28217
- return transform$2((input) => input === "" ? [] : input.split(separator));
28348
+ return transform$3((input) => input === "" ? [] : input.split(separator));
28218
28349
  }
28219
28350
  /**
28220
28351
  * Encodes a `Uint8Array` or string to a Base64 string.
@@ -28242,7 +28373,7 @@ function split(options) {
28242
28373
  * @since 4.0.0
28243
28374
  */
28244
28375
  function encodeBase64() {
28245
- return transform$2(encode);
28376
+ return transform$3(encode);
28246
28377
  }
28247
28378
  /**
28248
28379
  * Decodes a Base64 string to a `Uint8Array`.
@@ -28297,7 +28428,7 @@ function decodeBase64() {
28297
28428
  * @since 4.0.0
28298
28429
  */
28299
28430
  function encodeUriComponent() {
28300
- return transform$2(encodeURIComponent);
28431
+ return transform$3(encodeURIComponent);
28301
28432
  }
28302
28433
  /**
28303
28434
  * Decodes a URI component encoded string using `decodeURIComponent`.
@@ -28538,8 +28669,8 @@ function transformEffect(options) {
28538
28669
  * @category transforming
28539
28670
  * @since 3.10.0
28540
28671
  */
28541
- function transform$1(options) {
28542
- return new Transformation(transform$2(options.decode), transform$2(options.encode));
28672
+ function transform$2(options) {
28673
+ return new Transformation(transform$3(options.decode), transform$3(options.encode));
28543
28674
  }
28544
28675
  /**
28545
28676
  * Transforms a string into a record of key-value pairs and
@@ -28663,7 +28794,7 @@ const makeEncodeDefect = (options) => {
28663
28794
  };
28664
28795
  const decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input;
28665
28796
  /** @internal */
28666
- const defectFromJson = (options) => transform$1({
28797
+ const defectFromJson = (options) => transform$2({
28667
28798
  decode: decodeDefect,
28668
28799
  encode: makeEncodeDefect(options)
28669
28800
  });
@@ -29104,7 +29235,7 @@ const Undefined$1 = class extends ASTNodeImpl {
29104
29235
  return "undefined";
29105
29236
  }
29106
29237
  };
29107
- const undefinedToNull = /*#__PURE__*/ new Link(null_, /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2(() => void 0), /*#__PURE__*/ transform$2(() => null)));
29238
+ const undefinedToNull = /*#__PURE__*/ new Link(null_, /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3(() => void 0), /*#__PURE__*/ transform$3(() => null)));
29108
29239
  const undefined_ = /*#__PURE__*/ new Undefined$1();
29109
29240
  /**
29110
29241
  * Constructs a {@link Void}.
@@ -29268,7 +29399,7 @@ const Literal$1 = class extends ASTNodeImpl {
29268
29399
  };
29269
29400
  function literalToString(ast) {
29270
29401
  const literalAsString = globalThis.String(ast.literal);
29271
- return replaceEncoding(ast, [new Link(new Literal$1(literalAsString), new Transformation(transform$2(() => ast.literal), transform$2(() => literalAsString)))]);
29402
+ return replaceEncoding(ast, [new Link(new Literal$1(literalAsString), new Transformation(transform$3(() => ast.literal), transform$3(() => literalAsString)))]);
29272
29403
  }
29273
29404
  /**
29274
29405
  * Constructs a {@link String}.
@@ -30335,7 +30466,7 @@ function isFinite(annotations) {
30335
30466
  }
30336
30467
  /** @internal */
30337
30468
  const finite = /*#__PURE__*/ appendChecks(number, [/*#__PURE__*/ isFinite()]);
30338
- const numberToJson = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([finite, nonFiniteLiterals]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ Number$4(), /*#__PURE__*/ transform$2((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
30469
+ const numberToJson = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([finite, nonFiniteLiterals]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ Number$4(), /*#__PURE__*/ transform$3((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
30339
30470
  /**
30340
30471
  * Creates a {@link Filter} that validates strings by running `RegExp.test`.
30341
30472
  *
@@ -31567,9 +31698,9 @@ function toCodecStringTreeASTStep(ast, recur, onMissingAnnotation) {
31567
31698
  }
31568
31699
  return ast;
31569
31700
  }
31570
- const nullToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Literal$1("null"), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2(() => null), /*#__PURE__*/ transform$2(() => "null")));
31571
- const booleanToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([/*#__PURE__*/ new Literal$1("true"), /*#__PURE__*/ new Literal$1("false")]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2((s) => s === "true"), /*#__PURE__*/ String$8()));
31572
- const arrayFromSingleTransformation = /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2((input) => typeof input === "string" ? [input] : input), /*#__PURE__*/ passthrough$1());
31701
+ const nullToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Literal$1("null"), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3(() => null), /*#__PURE__*/ transform$3(() => "null")));
31702
+ const booleanToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([/*#__PURE__*/ new Literal$1("true"), /*#__PURE__*/ new Literal$1("false")]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3((s) => s === "true"), /*#__PURE__*/ String$8()));
31703
+ const arrayFromSingleTransformation = /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3((input) => typeof input === "string" ? [input] : input), /*#__PURE__*/ passthrough$1());
31573
31704
  const isCodecArrayFromSingleLink = (link) => link.transformation === arrayFromSingleTransformation;
31574
31705
  const toCodecStringTreeAST = /*#__PURE__*/ makeCodecDerivation((ast, recur) => toCodecStringTreeASTStep(ast, recur, (ast) => {
31575
31706
  throw new globalThis.Error("Missing structural codec for StringTree", { cause: ast });
@@ -32894,8 +33025,8 @@ function Literal(literal) {
32894
33025
  literal,
32895
33026
  transform(to) {
32896
33027
  return out.pipe(decodeTo(Literal(to), {
32897
- decode: transform$2(() => to),
32898
- encode: transform$2(() => literal)
33028
+ decode: transform$3(() => to),
33029
+ encode: transform$3(() => literal)
32899
33030
  }));
32900
33031
  }
32901
33032
  });
@@ -33278,7 +33409,7 @@ const FalseLiterals = /*#__PURE__*/ Literals([
33278
33409
  "n"
33279
33410
  ]);
33280
33411
  /** @internal */
33281
- const BooleanLiterals = /*#__PURE__*/ Literals([...TrueLiterals.literals, ...FalseLiterals.literals]).pipe(/*#__PURE__*/ decodeTo(Boolean$5, /*#__PURE__*/ transform$1({
33412
+ const BooleanLiterals = /*#__PURE__*/ Literals([...TrueLiterals.literals, ...FalseLiterals.literals]).pipe(/*#__PURE__*/ decodeTo(Boolean$5, /*#__PURE__*/ transform$2({
33282
33413
  decode: (value) => value === "true" || value === "yes" || value === "on" || value === "1" || value === "y",
33283
33414
  encode: (value) => value ? "true" : "false"
33284
33415
  })));
@@ -34111,7 +34242,7 @@ function CauseReason(error, defect) {
34111
34242
  _tag: Literal("Interrupt"),
34112
34243
  fiberId: UndefinedOr(Finite)
34113
34244
  })
34114
- ]), transform$1({
34245
+ ]), transform$2({
34115
34246
  decode: (e) => {
34116
34247
  switch (e._tag) {
34117
34248
  case "Fail": return makeFailReason(e.error);
@@ -34185,7 +34316,7 @@ function Cause(error, defect) {
34185
34316
  importDeclarations: [`import * as Cause from "effect/Cause"`]
34186
34317
  }),
34187
34318
  expected: "Cause",
34188
- toCodec: ([error, defect]) => link$1()(ArraySchema(CauseReason(error, defect)), transform$1({
34319
+ toCodec: ([error, defect]) => link$1()(ArraySchema(CauseReason(error, defect)), transform$2({
34189
34320
  decode: fromReasons,
34190
34321
  encode: ({ reasons: failures }) => failures
34191
34322
  }))
@@ -34245,7 +34376,7 @@ function Exit(value, error, defect) {
34245
34376
  }), Struct({
34246
34377
  _tag: Literal("Failure"),
34247
34378
  cause: Cause(error, defect)
34248
- })]), transform$1({
34379
+ })]), transform$2({
34249
34380
  decode: (e) => e._tag === "Success" ? succeed$8(e.value) : failCause$4(e.cause),
34250
34381
  encode: (exit) => isSuccess(exit) ? {
34251
34382
  _tag: "Success",
@@ -34345,7 +34476,7 @@ function makeClassTrusted(self, fields) {
34345
34476
  } });
34346
34477
  }
34347
34478
  function getClassTransformation(self) {
34348
- return new Transformation(transform$2((input) => makeClassTrusted(self, input)), passthrough$1());
34479
+ return new Transformation(transform$3((input) => makeClassTrusted(self, input)), passthrough$1());
34349
34480
  }
34350
34481
  function getClassTypeId(identifier) {
34351
34482
  return `~effect/Schema/Class/${identifier}`;
@@ -41224,7 +41355,7 @@ function Array$1(value, pathOrOptions, options) {
41224
41355
  const separator = resolvedOptions?.separator ?? ",";
41225
41356
  return schema$1(Union([String$6.pipe(decodeTo(toCodecStringTree(array), {
41226
41357
  decode: split(resolvedOptions),
41227
- encode: compose(passthrough$1({ strict: false }), transform$2((input) => input.join(separator)))
41358
+ encode: compose(passthrough$1({ strict: false }), transform$3((input) => input.join(separator)))
41228
41359
  })), array]), hasPath ? pathOrOptions : void 0);
41229
41360
  }
41230
41361
  function Record(key, value, pathOrOptions, options) {
@@ -45584,6 +45715,18 @@ const TypeId$13 = "~effect/http/HttpClient";
45584
45715
  */
45585
45716
  const HttpClient = /*#__PURE__*/ Service$1("effect/HttpClient");
45586
45717
  /**
45718
+ * Transforms a client by wrapping the response effect for each request.
45719
+ *
45720
+ * **Details**
45721
+ *
45722
+ * The transformation receives both the response effect and the original request, allowing it to change success, error, and environment behavior.
45723
+ *
45724
+ * @stability unstable
45725
+ * @category mapping
45726
+ * @since 4.0.0
45727
+ */
45728
+ const transform$1 = /*#__PURE__*/ dual(2, (self, f) => makeWith(flatMap$2((request) => f(self.postprocess(succeed$5(request)), request)), self.preprocess));
45729
+ /**
45587
45730
  * Transforms a client by applying an effectful transformation to each response effect.
45588
45731
  *
45589
45732
  * @stability unstable
@@ -45737,6 +45880,77 @@ const retryTransient = /*#__PURE__*/ dual(2, (self, options) => {
45737
45880
  times
45738
45881
  })));
45739
45882
  });
45883
+ /**
45884
+ * Fails requests that do not receive a response within the given duration.
45885
+ *
45886
+ * **When to use**
45887
+ *
45888
+ * Use to configure a timeout once on the client, for example when providing
45889
+ * the `HttpClient` service, while keeping the standard `HttpClientError` error
45890
+ * model.
45891
+ *
45892
+ * **Details**
45893
+ *
45894
+ * A timed out request is interrupted and fails with an `HttpClientError` whose
45895
+ * reason is a `TransportError` with a `Cause.TimeoutError` cause.
45896
+ * `retryTransient` treats it as transient. Interrupting a request aborts the
45897
+ * underlying transport, unless the request is attached to a scope with
45898
+ * `withScope`, in which case it stays open until the scope closes.
45899
+ *
45900
+ * The timer starts after request preprocessing and covers everything the
45901
+ * wrapped client does to produce a response. For a plain client this ends when
45902
+ * the response headers arrive, but response middleware applied before
45903
+ * `timeout`, such as `tap` or `retryTransient`, runs inside the budget,
45904
+ * including any body reads it performs. Composition order therefore decides
45905
+ * how it interacts with retries: applying `timeout` before `retryTransient`
45906
+ * gives each attempt its own budget, while applying it after bounds the whole
45907
+ * retry loop.
45908
+ *
45909
+ * **Gotchas**
45910
+ *
45911
+ * Body reads outside the timed client are not covered, including those made
45912
+ * by response middleware applied after `timeout` and by consumers of the
45913
+ * `HttpClient` service. Apply a separate timeout to body reads such as
45914
+ * `response.json` or `response.stream` when needed.
45915
+ *
45916
+ * **Example** (Timing out each attempt)
45917
+ *
45918
+ * ```ts
45919
+ * import { Effect, Layer } from "effect"
45920
+ * import { FetchHttpClient, HttpClient } from "effect/http"
45921
+ *
45922
+ * const TimedHttpClient = Layer.effect(
45923
+ * HttpClient.HttpClient,
45924
+ * Effect.map(
45925
+ * HttpClient.HttpClient,
45926
+ * HttpClient.timeout("5 seconds")
45927
+ * )
45928
+ * ).pipe(Layer.provide(FetchHttpClient.layer))
45929
+ *
45930
+ * const program = Effect.gen(function*() {
45931
+ * const client = (yield* HttpClient.HttpClient).pipe(
45932
+ * HttpClient.retryTransient({ times: 3 })
45933
+ * )
45934
+ * return yield* client.get("https://example.com")
45935
+ * }).pipe(Effect.provide(TimedHttpClient))
45936
+ * ```
45937
+ *
45938
+ * @stability unstable
45939
+ * @category error handling
45940
+ * @since 4.1.0
45941
+ */
45942
+ const timeout = /*#__PURE__*/ dual(2, (self, duration) => {
45943
+ const decoded = fromInputUnsafe$1(duration);
45944
+ const description = `timed out after ${format$1(decoded)}`;
45945
+ return transform$1(self, (effect, request) => timeoutOrElse(effect, {
45946
+ duration: decoded,
45947
+ orElse: () => fail$7(new HttpClientError({ reason: new TransportError({
45948
+ request,
45949
+ cause: new TimeoutError(`Operation ${description}`),
45950
+ description
45951
+ }) }))
45952
+ }));
45953
+ });
45740
45954
  const parseRetryAfter = (nowMillis, value) => {
45741
45955
  if (value === void 0) return;
45742
45956
  const retryAfter = parseRetryAfter$1(value);
@@ -54589,7 +54803,7 @@ function withCycleGuard(target) {
54589
54803
  return decodeTo(declareConstructor()([type], ([type]) => (input, ast, options) => {
54590
54804
  if (isObjectOrArray(input) && decoded.delete(input)) return succeed$5(input);
54591
54805
  return isCyclic(input) ? fail$7(new InvalidType(ast, input, options)) : decodeUnknownEffect$1(type)(input, options);
54592
- }, { identifier: "acyclic value" }), transform$1({
54806
+ }, { identifier: "acyclic value" }), transform$2({
54593
54807
  decode: (value) => {
54594
54808
  if (isObjectOrArray(value)) decoded.add(value);
54595
54809
  return value;
@@ -69706,7 +69920,7 @@ const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exist
69706
69920
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
69707
69921
  const RUNTIME_PATH = "/api/runtime";
69708
69922
  const RuntimeConfig = Struct({
69709
- auth: optionalKey(String$6),
69923
+ auth: optionalKey(Origin),
69710
69924
  name: String$6,
69711
69925
  traces: String$6,
69712
69926
  version: AppVersion
@@ -69772,20 +69986,6 @@ const Service = () => (id, options) => {
69772
69986
  ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
69773
69987
  return ServiceClass;
69774
69988
  };
69775
- /**
69776
- * Provides the client-side implementation for an RPC middleware service,
69777
- * capturing the layer's environment and merging it into each middleware
69778
- * invocation.
69779
- *
69780
- * @stability unstable
69781
- * @category layers
69782
- * @since 4.0.0
69783
- */
69784
- const layerClient = (tag, service) => effectContext(gen(function* () {
69785
- const services = (yield* context()).pipe(omit$1(Scope));
69786
- const middleware = isEffect(service) ? yield* service : service;
69787
- return makeUnsafe$9(/* @__PURE__ */ new Map([[`${tag.key}/Client`, (options) => updateContext(middleware(options), (requestContext) => merge$4(services, requestContext))]]));
69788
- }));
69789
69989
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/observability/OtlpExporter.js
69790
69990
  /**
69791
69991
  * Shared batch exporter for OTLP/HTTP observability modules.
@@ -70470,8 +70670,9 @@ const SpanKind = {
70470
70670
  };
70471
70671
  // ../../packages/runtime/src/telemetry.ts
70472
70672
  function layerOtlp(serviceName, url, runtime, version) {
70473
- return unwrap$7(gen(function* () {
70673
+ return pipe(unwrap$7(gen(function* () {
70474
70674
  const start = `${yield* currentTimeNanos}`;
70675
+ const redacted = yield* CurrentRedactedNames;
70475
70676
  const resource = {
70476
70677
  attributes: {
70477
70678
  "scope.run.started_unix_nano": start,
@@ -70482,14 +70683,28 @@ function layerOtlp(serviceName, url, runtime, version) {
70482
70683
  serviceVersion: getOrUndefined$1(liftPredicate(version, (current) => current !== "0.1.0"))
70483
70684
  };
70484
70685
  return pipe(mergeAll$1(layer({
70485
- exportInterval: "250 millis",
70486
70686
  resource,
70487
70687
  url: new URL("/v1/traces", url).href
70488
70688
  }), layer$1({
70489
- exportInterval: "250 millis",
70490
70689
  resource,
70491
70690
  url: new URL("/v1/logs", url).href
70492
- })), provide$2([layerJson, layer$12]));
70691
+ }), succeed$6(CurrentRedactedNames)([
70692
+ ...redacted,
70693
+ "code",
70694
+ "state",
70695
+ "request",
70696
+ "access_token",
70697
+ "refresh_token",
70698
+ "id_token",
70699
+ "client_secret",
70700
+ "client_assertion",
70701
+ "code_verifier",
70702
+ "session",
70703
+ "token"
70704
+ ])), provide$2([layerJson, layer$12]));
70705
+ })), catchCause$2((cause) => {
70706
+ if (hasInterrupts(cause)) return effectDiscard(interrupt$1);
70707
+ return effectDiscard(logWarning("Telemetry is unavailable"));
70493
70708
  }));
70494
70709
  }
70495
70710
  // ../../packages/runtime/src/auth/lib/utils.ts
@@ -70506,15 +70721,15 @@ gen(function* () {
70506
70721
  if (yield* localAuth) return yield* withDefault$2(listed, ["0"]);
70507
70722
  return yield* listed;
70508
70723
  });
70724
+ function failureOptions(error, status) {
70725
+ if (is(AuthError)(error) && error.error === "temporarily_unavailable") return {
70726
+ headers: { "retry-after": "5" },
70727
+ status: 503
70728
+ };
70729
+ return { status };
70730
+ }
70509
70731
  var CurrentUser = class extends Service$1()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
70510
- var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
70511
- static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
70512
- return yield* options.next({
70513
- ...options.request,
70514
- headers: set$1(options.request.headers, "authorization", `Bearer ${yield* token}`)
70515
- });
70516
- }));
70517
- };
70732
+ var RpcAuth = class extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {};
70518
70733
  // ../../packages/runtime/src/auth/service.ts
70519
70734
  function rejected(message) {
70520
70735
  return mapError$2((cause) => {
@@ -70538,7 +70753,10 @@ const unavailable = text("The authorization service is temporarily unavailable;
70538
70753
  status: 503
70539
70754
  });
70540
70755
  var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
70541
- static makeContext = (auth) => pipe(make$70(Auth, auth), add$1(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$2((user) => raceFirst(provideService(effect, CurrentUser, user), pipe(delay(auth.user(request.headers), "5 minutes"), retry({ while: (error) => error.error === "temporarily_unavailable" }), forever)))))));
70756
+ static makeContext = (auth) => pipe(make$70(Auth, auth), add$1(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), tap$1(() => {
70757
+ if (isStreamSchema(request.rpc.successSchema)) return annotateCurrentSpan("rpc.stream", true);
70758
+ return void_$1;
70759
+ }), flatMap$2((user) => raceFirst(provideService(effect, CurrentUser, user), pipe(delay(auth.user(request.headers), "5 minutes"), retry({ while: (error) => error.error === "temporarily_unavailable" }), forever)))))));
70542
70760
  static layer = effectContext(gen(function* () {
70543
70761
  if (yield* localAuth) return Auth.makeContext(Auth.of({
70544
70762
  access: developer,
@@ -70551,13 +70769,13 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
70551
70769
  return yield* pipe(client.get(new URL(VERIFY_PATH, issuer).href, {
70552
70770
  headers: { authorization: headers["authorization"] ?? "" },
70553
70771
  urlParams: { resource: audience }
70554
- }), flatMap$2(schemaBodyJson(User)), timeout("10 seconds"));
70772
+ }), flatMap$2(schemaBodyJson(User)), timeout$1("10 seconds"));
70555
70773
  }, rejected("Sign in first"));
70556
70774
  return Auth.makeContext(Auth.of({
70557
70775
  access,
70558
70776
  user: fn("Auth.user")(function* (headers) {
70559
70777
  if (isSome(get$3(headers, "authorization"))) return yield* access(headers, canonical);
70560
- return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$2(schemaBodyJson(User)), timeout("10 seconds"));
70778
+ return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$2(schemaBodyJson(User)), timeout$1("10 seconds"));
70561
70779
  }, rejected("Sign in first"))
70562
70780
  }));
70563
70781
  }));
@@ -70604,7 +70822,7 @@ const dataDirectory = gen(function* () {
70604
70822
  });
70605
70823
  return directory;
70606
70824
  });
70607
- fnUntraced(function* (name) {
70825
+ const tool = fnUntraced(function* (name) {
70608
70826
  const fs = yield* FileSystem;
70609
70827
  const path = yield* Path$1;
70610
70828
  const version = (yield* packageMetadata).version;
@@ -70621,6 +70839,9 @@ fnUntraced(function* (name) {
70621
70839
  yield* forEach$1(filter$2(yield* fs.readDirectory(tools), (entry) => entry !== version), (entry) => fs.remove(path.join(tools, entry), { recursive: true }), { concurrency: 1 });
70622
70840
  return target;
70623
70841
  });
70842
+ var ToolPath = class extends Service$1()("@deslop/runtime/server/ToolPath") {
70843
+ static layer = succeed$6(this, tool);
70844
+ };
70624
70845
  const guard = make$19((app) => gen(function* () {
70625
70846
  const request = yield* HttpServerRequest;
70626
70847
  const host = request.headers["host"] ?? "";
@@ -70654,7 +70875,7 @@ function layerKeyValueStore(directory) {
70654
70875
  return pipe(gen(function* () {
70655
70876
  if (isString$2(value)) yield* fs.writeFileString(`${target}.tmp`, value, { mode: 384 });
70656
70877
  else yield* fs.writeFile(`${target}.tmp`, value, { mode: 384 });
70657
- }), andThen(fs.rename(`${target}.tmp`, target)), withPermit(writes), uninterruptible, mapError$2((cause) => new KeyValueStoreError({
70878
+ }), andThen(fs.rename(`${target}.tmp`, target)), uninterruptible, withPermit(writes), mapError$2((cause) => new KeyValueStoreError({
70658
70879
  cause,
70659
70880
  key,
70660
70881
  message: "Cannot save the value",
@@ -70665,7 +70886,15 @@ function layerKeyValueStore(directory) {
70665
70886
  })), provide$2(layerFileSystem(directory)));
70666
70887
  }
70667
70888
  unwrap$7(map$5(dataDirectory, layerKeyValueStore));
70668
- const layerProtocol = mergeAll$1(layerSchemaBinary(), succeed$6(MaxBodySize)(mebibytes(10)));
70889
+ const layerProtocol = mergeAll$1(layerSchemaBinary(), succeed$6(MaxBodySize)(mebibytes(10)), effect(TracerDisabledWhen, map$5(TracerDisabledWhen, (previous) => (request) => {
70890
+ const path = headNonEmpty(split$1(request.url, "?"));
70891
+ return previous(request) || path === "/api/rpc" && toLowerCase(request.headers["upgrade"] ?? "") === "websocket" || startsWith("/assets/")(path) || contains([
70892
+ "/icon",
70893
+ "/favicon.ico",
70894
+ "/apple-touch-icon.png",
70895
+ "/manifest.webmanifest"
70896
+ ], path);
70897
+ })));
70669
70898
  const layerTelemetry = unwrap$7(gen(function* () {
70670
70899
  const metadata = yield* packageMetadata;
70671
70900
  return match$7(yield* option(String$5("OTEL_URL")), {
@@ -70678,6 +70907,7 @@ const layerRoutes = use((router) => gen(function* () {
70678
70907
  const canonical = new URL(yield* String$5("APP_URL")).origin;
70679
70908
  const issuer = yield* option(String$5("AUTH_URL"));
70680
70909
  const traces = yield* pipe(String$5("OTEL_URL"), withDefault$2(""));
70910
+ const metadata = yield* cached(packageMetadata);
70681
70911
  const toIssuer = fnUntraced(function* (search) {
70682
70912
  const request = yield* HttpServerRequest;
70683
70913
  const next = filter$3(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (url) => url.origin === canonical);
@@ -70693,21 +70923,22 @@ const layerRoutes = use((router) => gen(function* () {
70693
70923
  });
70694
70924
  });
70695
70925
  yield* router.add("GET", RUNTIME_PATH, gen(function* () {
70926
+ const release = yield* metadata;
70696
70927
  return yield* schemaJson(RuntimeConfig)({
70697
70928
  ...match$7(issuer, {
70698
70929
  onNone: () => ({}),
70699
70930
  onSome: (origin) => ({ auth: origin })
70700
70931
  }),
70701
- name: yield* appName,
70932
+ name: replace("@deslop/", "")(release.name),
70702
70933
  traces,
70703
- version: (yield* packageMetadata).version
70934
+ version: release.version
70704
70935
  });
70705
70936
  }));
70706
70937
  yield* router.add("GET", "/auth/sign-in", toIssuer({}));
70707
70938
  yield* router.add("GET", "/auth/sign-out", toIssuer({ "sign-out": "" }));
70708
70939
  yield* router.add("GET", "/auth/user", gen(function* () {
70709
70940
  const user = yield* result(auth.user((yield* HttpServerRequest).headers));
70710
- if (isFailure$1(user)) return empty({ status: 401 });
70941
+ if (isFailure$1(user)) return empty(failureOptions(user.failure, 401));
70711
70942
  return yield* schemaJson(Account)({
70712
70943
  ...user.success,
70713
70944
  signOut: isSome(issuer)
@@ -70716,14 +70947,14 @@ const layerRoutes = use((router) => gen(function* () {
70716
70947
  }));
70717
70948
  const layerAnnounce = effectDiscard(gen(function* () {
70718
70949
  const origin = new URL(yield* String$5("APP_URL")).origin;
70719
- const client = filterStatusOk(yield* HttpClient);
70950
+ const client = pipe(yield* HttpClient, filterStatusOk, timeout("10 seconds"), retryTransient({
70951
+ schedule: spaced("1 minute"),
70952
+ times: 60
70953
+ }));
70720
70954
  yield* match$7(yield* option(String$5("AUTH_URL")), {
70721
70955
  onNone: () => void_$1,
70722
70956
  onSome: fnUntraced(function* (issuer) {
70723
- yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
70724
- schedule: spaced("1 minute"),
70725
- times: 60
70726
- }), ignore$1({
70957
+ yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), ignore$1({
70727
70958
  log: "Warn",
70728
70959
  message: "Auth did not list this app"
70729
70960
  }), forkScoped);
@@ -70742,11 +70973,10 @@ const layerWeb = unwrap$7(gen(function* () {
70742
70973
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$8;
70743
70974
  const name = capitalize(yield* appName);
70744
70975
  return mergeAll$1(add("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
70745
- background_color: "#0a0a0a",
70976
+ background_color: "#0d0c0c",
70746
70977
  display: "standalone",
70747
70978
  icons: [{
70748
70979
  purpose: "any",
70749
- sizes: "512x512",
70750
70980
  src: "/apple-touch-icon.png",
70751
70981
  type: "image/png"
70752
70982
  }],
@@ -70755,7 +70985,7 @@ const layerWeb = unwrap$7(gen(function* () {
70755
70985
  scope: "/",
70756
70986
  short_name: name,
70757
70987
  start_url: "/",
70758
- theme_color: "#0a0a0a"
70988
+ theme_color: "#0d0c0c"
70759
70989
  }, {
70760
70990
  contentType: "application/manifest+json",
70761
70991
  headers: { "cache-control": "no-cache" }
@@ -70804,7 +71034,7 @@ const execute = fnUntraced(function* (command, args) {
70804
71034
  }, { concurrency: "unbounded" });
70805
71035
  if (result.code !== 0) return yield* AppError.make({ message: `${command} failed: ${result.stderr}` });
70806
71036
  return result.stdout;
70807
- });
71037
+ }, scoped);
70808
71038
  function systemctl(...args) {
70809
71039
  return execute("systemctl", ["--user", ...args]);
70810
71040
  }
@@ -70854,7 +71084,7 @@ function status(name) {
70854
71084
  return systemctl("show", `deslop-${name}.service`, "--property=LoadState,ActiveState,SubState,MainPID");
70855
71085
  }
70856
71086
  function restart(name) {
70857
- return pipe(systemctl("restart", `deslop-${name}.service`), timeout("30 seconds"));
71087
+ return pipe(systemctl("restart", `deslop-${name}.service`), timeout$1("30 seconds"));
70858
71088
  }
70859
71089
  // ../../packages/runtime/src/cli/update.ts
70860
71090
  const serviceDirectory = fnUntraced(function* (name) {
@@ -70878,7 +71108,7 @@ const update$1 = fnUntraced(function* (name) {
70878
71108
  const path = yield* Path$1;
70879
71109
  const root = yield* serviceDirectory(name);
70880
71110
  const running = (yield* decodeEffect(fromJsonString(Struct({ version: AppVersion })))(yield* fs.readFileString(path.join(root, "current", "package.json")))).version;
70881
- const latest = (yield* pipe(filterStatusOk(yield* HttpClient).get(`https://registry.npmjs.org/@deslop%2f${name}/latest`), flatMap$2(schemaBodyJson(Struct({ version: AppVersion }))), timeout("15 seconds"))).version;
71111
+ const latest = (yield* pipe(filterStatusOk(yield* HttpClient).get(`https://registry.npmjs.org/@deslop%2f${name}/latest`), flatMap$2(schemaBodyJson(Struct({ version: AppVersion }))), timeout$1("15 seconds"))).version;
70882
71112
  if (latest === running) return `${name} ${running} is current\n`;
70883
71113
  const npm = path.resolve(path.dirname(execPath), "../lib/node_modules/npm/bin/npm-cli.js");
70884
71114
  if (!(yield* fs.exists(npm))) return yield* AppError.make({ message: "This Node runtime does not include npm; install Node with Vite+" });
@@ -70895,7 +71125,7 @@ const update$1 = fnUntraced(function* (name) {
70895
71125
  "--prefer-online",
70896
71126
  "--registry=https://registry.npmjs.org",
70897
71127
  `@deslop/${name}@${latest}`
70898
- ]), timeout("5 minutes"));
71128
+ ]), timeout$1("5 minutes"));
70899
71129
  const previous = yield* option$1(fs.readLink(path.join(root, "current")));
70900
71130
  yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
70901
71131
  yield* restart(name);
@@ -70904,6 +71134,7 @@ const update$1 = fnUntraced(function* (name) {
70904
71134
  return `Updated ${name} from ${running} to ${latest}\n`;
70905
71135
  });
70906
71136
  // ../../packages/runtime/src/cli.ts
71137
+ const DEFAULT_HOST = "127.0.0.1";
70907
71138
  const SETTINGS = {
70908
71139
  APP_URL: {
70909
71140
  description: "Canonical origin, such as the HTTPS name a proxy serves",
@@ -70916,7 +71147,7 @@ const SETTINGS = {
70916
71147
  schema: SecureOrigin
70917
71148
  },
70918
71149
  HOST: {
70919
- description: "Listen address; defaults to 127.0.0.1",
71150
+ description: `Listen address; defaults to ${DEFAULT_HOST}`,
70920
71151
  flag: "host",
70921
71152
  schema: NonEmptyString
70922
71153
  },
@@ -70924,23 +71155,18 @@ const SETTINGS = {
70924
71155
  description: "Scope origin to export traces and logs to",
70925
71156
  flag: "traces",
70926
71157
  schema: Origin
70927
- },
70928
- PORT: {
70929
- description: "Listen port; defaults to the package's config.port",
70930
- flag: "port",
70931
- schema: Port
70932
71158
  }
70933
71159
  };
70934
71160
  String$6.check(isPattern(/^\d+(?:,\d+)*$/u));
70935
71161
  function flagsOf(settings) {
70936
- return map$9(settings, (setting, key) => pipe(String$1(setting.flag), withSchema(setting.schema), withFallbackConfig(schema$1(setting.schema, key)), withDescription(setting.description), optional));
71162
+ return map$9(settings, (setting, key) => pipe(String$1(setting.flag), withSchema(setting.schema), withFallbackConfig(schema$1(setting.schema, key)), withDescription(`${setting.description} [${key}]`), optional));
70937
71163
  }
70938
- const provider = fnUntraced(function* (given) {
70939
- const port = given["PORT"] ?? `${(yield* packageMetadata).config.port}`;
71164
+ const provider = fnUntraced(function* (given, defaultPort) {
71165
+ const port = given["PORT"] ?? `${defaultPort}`;
70940
71166
  const url = given["APP_URL"] ?? `http://localhost:${port}`;
70941
71167
  if (given["AUTH_URL"] !== void 0 && new URL(url).protocol !== "https:") return yield* AppError.make({ message: "With --auth, set --url to the app's HTTPS origin" });
70942
71168
  return orElse(fromUnknown({
70943
- HOST: "127.0.0.1",
71169
+ HOST: DEFAULT_HOST,
70944
71170
  ...given,
70945
71171
  APP_URL: url,
70946
71172
  PORT: port
@@ -70948,9 +71174,12 @@ const provider = fnUntraced(function* (given) {
70948
71174
  });
70949
71175
  const layerPlatform = mergeAll$1(layer$4, layer$12, layer$15);
70950
71176
  function server(app) {
70951
- return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(Auth.layer)), {
71177
+ return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(match$7(fromUndefinedOr(app.middleware), {
71178
+ onNone: () => empty$8,
71179
+ onSome: (middleware$1) => middleware()(middleware$1).layer
71180
+ })), provide$2(Auth.layer)), {
70952
71181
  disableLogger: true,
70953
- middleware: (http) => guard(app.middleware?.(http) ?? http)
71182
+ middleware: guard
70954
71183
  }), provide$2(mergeAll$1(layerProtocol, match(app.telemetry === false, {
70955
71184
  onFalse: () => layerTelemetry,
70956
71185
  onTrue: () => empty$8
@@ -70960,21 +71189,26 @@ function output(text) {
70960
71189
  return flatMap$2(Stdio, (stdio) => run$4(make$44(text), stdio.stdout()));
70961
71190
  }
70962
71191
  function runApp(app) {
70963
- const settings = {
70964
- ...SETTINGS,
70965
- ...app.settings
70966
- };
70967
71192
  const program = gen(function* () {
70968
71193
  const metadata = yield* packageMetadata;
70969
71194
  const name = yield* appName;
71195
+ const settings = {
71196
+ ...SETTINGS,
71197
+ PORT: {
71198
+ description: `Listen port; defaults to ${metadata.config.port}`,
71199
+ flag: "port",
71200
+ schema: Port
71201
+ },
71202
+ ...app.settings
71203
+ };
70970
71204
  const root = pipe(make$8(name), withSharedFlags(flagsOf(settings)));
70971
71205
  const given = map$5(root, (input) => getSomes(input));
70972
- return yield* pipe(root, withHandler((input) => flatMap$2(provider(getSomes(input)), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$8("service"), withSubcommands([
71206
+ return yield* pipe(root, withHandler((input) => flatMap$2(provider(getSomes(input), metadata.config.port), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$8("service"), withSubcommands([
70973
71207
  make$8("install", {}, fnUntraced(function* () {
70974
71208
  const fs = yield* FileSystem;
70975
71209
  const path = yield* Path$1;
70976
71210
  const flags = yield* given;
70977
- yield* provider(flags);
71211
+ yield* provider(flags, metadata.config.port);
70978
71212
  const entry = path.join(yield* activate(name, yield* fs.realPath(packageRoot)), "dist", "server.js");
70979
71213
  const args = flatten$3(collect$1(flags, (key, value) => [`--${settings[key]?.flag ?? key}`, value]));
70980
71214
  yield* output(yield* install(name, [
@@ -71022,15 +71256,19 @@ const PortfolioVisitor = Struct({
71022
71256
  });
71023
71257
  const PortfolioVisitors = ArraySchema(PortfolioVisitor);
71024
71258
  // src/rpcs/contracts.ts
71259
+ const Guest = PortfolioVisitor.mapFields((fields) => ({
71260
+ ...fields,
71261
+ id: fields.id.check(isPattern(/^(?!server-)/u))
71262
+ }));
71025
71263
  var RpcContracts = class extends make$14(make$16("portfolio.join", {
71026
- payload: Struct(pipe(PortfolioVisitor.fields, pick([
71264
+ payload: Struct(pipe(Guest.fields, pick([
71027
71265
  "color",
71028
71266
  "id",
71029
71267
  "name"
71030
71268
  ]))),
71031
71269
  stream: true,
71032
71270
  success: PortfolioVisitors
71033
- }), make$16("portfolio.move", { payload: Struct(pipe(PortfolioVisitor.fields, pick([
71271
+ }), make$16("portfolio.move", { payload: Struct(pipe(Guest.fields, pick([
71034
71272
  "color",
71035
71273
  "id",
71036
71274
  "x",
@@ -78442,7 +78680,7 @@ runApp({
78442
78680
  handlers: RpcContracts.toLayer(gen(function* () {
78443
78681
  const presence = yield* Presence;
78444
78682
  return RpcContracts.of({
78445
- "portfolio.join": presence.join,
78683
+ "portfolio.join": (input) => onStart(presence.join(input), annotateCurrentSpan("rpc.stream", true)),
78446
78684
  "portfolio.move": presence.move
78447
78685
  });
78448
78686
  }))