@deslop/scope 0.1.1267 → 0.1.1270

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 (28) hide show
  1. package/dist/client/assets/(home)-BA_NFUHC.js +1 -0
  2. package/dist/client/assets/effect-Dl27dPGW.js +15 -0
  3. package/dist/client/assets/index-DiziEtkV.js +3 -0
  4. package/dist/client/assets/index-vIq9ri0p.css +2 -0
  5. package/dist/client/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  6. package/dist/client/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  7. package/dist/client/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  8. package/dist/client/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  9. package/dist/client/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  10. package/dist/client/assets/{react-COyt-gOi.js → react-CYMlNKV3.js} +3 -3
  11. package/dist/client/index.html +4 -4
  12. package/dist/server.js +1558 -1609
  13. package/package.json +3 -2
  14. package/dist/client/assets/(home)-D5VX9C5w.js +0 -41
  15. package/dist/client/assets/effect-B9VWHDXW.js +0 -15
  16. package/dist/client/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  17. package/dist/client/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  18. package/dist/client/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  19. package/dist/client/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  20. package/dist/client/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  21. package/dist/client/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  22. package/dist/client/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  23. package/dist/client/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  24. package/dist/client/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  25. package/dist/client/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  26. package/dist/client/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  27. package/dist/client/assets/index-B2ODXREK.css +0 -2
  28. package/dist/client/assets/index-xyETCS2w.js +0 -3
package/dist/server.js CHANGED
@@ -4839,7 +4839,7 @@ const ServiceProto = {
4839
4839
  .../*#__PURE__*/ Prototype({
4840
4840
  label: "Service",
4841
4841
  evaluate(fiber) {
4842
- return exitSucceed(get$11(fiber.context, this));
4842
+ return exitSucceed(get$10(fiber.context, this));
4843
4843
  }
4844
4844
  }),
4845
4845
  toJSON() {
@@ -4855,10 +4855,10 @@ const ServiceProto = {
4855
4855
  return make$81(this, self);
4856
4856
  },
4857
4857
  use(f) {
4858
- return withFiber$1((fiber) => f(get$11(fiber.context, this)));
4858
+ return withFiber$1((fiber) => f(get$10(fiber.context, this)));
4859
4859
  },
4860
4860
  useSync(f) {
4861
- return withFiber$1((fiber) => exitSucceed(f(get$11(fiber.context, this))));
4861
+ return withFiber$1((fiber) => exitSucceed(f(get$10(fiber.context, this))));
4862
4862
  }
4863
4863
  };
4864
4864
  const cacheKeys = /*#__PURE__*/ new Set();
@@ -5237,7 +5237,7 @@ const getUnsafe$2 = /*#__PURE__*/ dual(2, (self, service) => {
5237
5237
  * @category getters
5238
5238
  * @since 2.0.0
5239
5239
  */
5240
- const get$11 = getUnsafe$2;
5240
+ const get$10 = getUnsafe$2;
5241
5241
  const defaultValueCacheKey = "~effect/Context/defaultValue";
5242
5242
  const getDefaultValue = (ref) => {
5243
5243
  if (defaultValueCacheKey in ref) return ref[defaultValueCacheKey];
@@ -6144,7 +6144,7 @@ const has$4 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key));
6144
6144
  * @category getters
6145
6145
  * @since 2.0.0
6146
6146
  */
6147
- const get$10 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
6147
+ const get$9 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
6148
6148
  /**
6149
6149
  * Maps a record into another record by applying a transformation function to each of its values.
6150
6150
  *
@@ -6670,7 +6670,7 @@ function isOutOfBounds(i, as) {
6670
6670
  * @category getters
6671
6671
  * @since 2.0.0
6672
6672
  */
6673
- const get$9 = /*#__PURE__*/ dual(2, (self, index) => {
6673
+ const get$8 = /*#__PURE__*/ dual(2, (self, index) => {
6674
6674
  const i = Math.floor(index);
6675
6675
  return isOutOfBounds(i, self) ? none() : some$1(self[i]);
6676
6676
  });
@@ -6731,7 +6731,7 @@ const getUnsafe$1 = /*#__PURE__*/ dual(2, (self, index) => {
6731
6731
  * @category getters
6732
6732
  * @since 2.0.0
6733
6733
  */
6734
- const head = /*#__PURE__*/ get$9(0);
6734
+ const head = /*#__PURE__*/ get$8(0);
6735
6735
  /**
6736
6736
  * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option`
6737
6737
  * wrapper).
@@ -9856,7 +9856,7 @@ var FiberImpl = class {
9856
9856
  return this._dispatcher ??= this.cache.scheduler.makeDispatcher();
9857
9857
  }
9858
9858
  getRef(ref) {
9859
- return get$11(this.context, ref);
9859
+ return get$10(this.context, ref);
9860
9860
  }
9861
9861
  addObserver(cb) {
9862
9862
  if (this._exit) {
@@ -10024,17 +10024,17 @@ var FiberImpl = class {
10024
10024
  const makeFiberContextCache = (context) => {
10025
10025
  const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
10026
10026
  return {
10027
- scheduler: get$11(context, Scheduler),
10027
+ scheduler: get$10(context, Scheduler),
10028
10028
  tracer: currentTracer,
10029
10029
  tracerContext: currentTracer ? currentTracer["context"] : void 0,
10030
- tracerEnabled: get$11(context, TracerEnabled),
10030
+ tracerEnabled: get$10(context, TracerEnabled),
10031
10031
  span: getOrUndefinedUnsafe(context, ParentSpanKey),
10032
- logLevel: get$11(context, CurrentLogLevel$1),
10033
- minimumLogLevel: get$11(context, MinimumLogLevel$1),
10034
- stackFrame: get$11(context, CurrentStackFrame),
10032
+ logLevel: get$10(context, CurrentLogLevel$1),
10033
+ minimumLogLevel: get$10(context, MinimumLogLevel$1),
10034
+ stackFrame: get$10(context, CurrentStackFrame),
10035
10035
  runtimeMetrics: getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey),
10036
- maxOpsBeforeYield: get$11(context, MaxOpsBeforeYield),
10037
- preventYield: get$11(context, PreventSchedulerYield)
10036
+ maxOpsBeforeYield: get$10(context, MaxOpsBeforeYield),
10037
+ preventYield: get$10(context, PreventSchedulerYield)
10038
10038
  };
10039
10039
  };
10040
10040
  const deferredInterruptCont = {
@@ -11551,11 +11551,11 @@ const NoopSpanProto = {
11551
11551
  const noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options);
11552
11552
  const filterDisablePropagation = (span) => {
11553
11553
  if (!span) return none();
11554
- return get$11(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some$1(span);
11554
+ return get$10(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some$1(span);
11555
11555
  };
11556
11556
  /** @internal */
11557
11557
  const makeSpanUnsafe = (fiber, name, options) => {
11558
- const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$11(options.annotations, DisablePropagation);
11558
+ const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$10(options.annotations, DisablePropagation);
11559
11559
  const parent = options?.parent !== void 0 ? some$1(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
11560
11560
  let span;
11561
11561
  if (disablePropagation) span = noopSpan({
@@ -14724,7 +14724,7 @@ const unwrapKey = /*#__PURE__*/ Service$2("effect/Layer/unwrap");
14724
14724
  * @category converting
14725
14725
  * @since 4.0.0
14726
14726
  */
14727
- const unwrap$7 = (self) => flatMap$4(effect(unwrapKey)(self), get$11(unwrapKey));
14727
+ const unwrap$7 = (self) => flatMap$4(effect(unwrapKey)(self), get$10(unwrapKey));
14728
14728
  const mergeAllEffect = (layers, memoMap, scope) => {
14729
14729
  const parentScope = forkUnsafe(scope, "parallel");
14730
14730
  return forEach$2(layers, (layer) => layer.build(memoMap, forkUnsafe(parentScope, "sequential")), { concurrency: layers.length }).pipe(map$7((context) => mergeAll$2(...context)));
@@ -16772,7 +16772,7 @@ const empty$9 = () => {
16772
16772
  * @category getters
16773
16773
  * @since 2.0.0
16774
16774
  */
16775
- const get$8 = /*#__PURE__*/ dual(2, (self, key) => {
16775
+ const get$7 = /*#__PURE__*/ dual(2, (self, key) => {
16776
16776
  if (self.backing.has(key)) return some$1(self.backing.get(key));
16777
16777
  else if (isSimpleKey(key)) return none();
16778
16778
  const hash$3 = hash(key);
@@ -29236,7 +29236,7 @@ var HashMapImpl = class {
29236
29236
  const thatImpl = that;
29237
29237
  if (this.size !== thatImpl.size) return false;
29238
29238
  for (const [key, value] of this) {
29239
- const otherValue = pipe(that, get$7(key));
29239
+ const otherValue = pipe(that, get$6(key));
29240
29240
  if (isNone(otherValue) || !equals$2(value, otherValue.value)) return false;
29241
29241
  }
29242
29242
  return true;
@@ -29282,7 +29282,7 @@ const fromIterable$5 = (entries) => {
29282
29282
  return new HashMapImpl(false, 0, root, size);
29283
29283
  };
29284
29284
  /** @internal */
29285
- const get$7 = /*#__PURE__*/ dual(2, (self, key) => {
29285
+ const get$6 = /*#__PURE__*/ dual(2, (self, key) => {
29286
29286
  return self._root.get(0, hash(key), key);
29287
29287
  });
29288
29288
  /** @internal */
@@ -30225,7 +30225,7 @@ const TypeId$50 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
30225
30225
  const Proto$18 = /*#__PURE__*/ Object.defineProperties(/*#__PURE__*/ Object.create(null), {
30226
30226
  [TypeId$50]: { value: TypeId$50 },
30227
30227
  [symbolRedactable]: { value(context) {
30228
- return redact$1(this, get$11(context, CurrentRedactedNames$1));
30228
+ return redact$1(this, get$10(context, CurrentRedactedNames$1));
30229
30229
  } },
30230
30230
  toJSON: { value() {
30231
30231
  return redact$2(this);
@@ -30648,7 +30648,7 @@ const Proto$17 = {
30648
30648
  [symbolRedactable](context) {
30649
30649
  return {
30650
30650
  _id: "UrlParams",
30651
- params: Object.fromEntries(redact(this, get$11(context, CurrentRedactedNames)))
30651
+ params: Object.fromEntries(redact(this, get$10(context, CurrentRedactedNames)))
30652
30652
  };
30653
30653
  },
30654
30654
  toJSON() {
@@ -30861,7 +30861,7 @@ const decodeQueryKey = (key) => {
30861
30861
  return key;
30862
30862
  }
30863
30863
  };
30864
- const currentRedactedNames = () => get$11(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentRedactedNames);
30864
+ const currentRedactedNames = () => get$10(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$14(), CurrentRedactedNames);
30865
30865
  /**
30866
30866
  * Query parameter names or patterns to redact in inspection, spans and errors.
30867
30867
  *
@@ -36924,32 +36924,6 @@ function toRepresentations(asts, options) {
36924
36924
  }
36925
36925
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Struct.js
36926
36926
  /**
36927
- * Retrieves the value at `key` from a struct.
36928
- *
36929
- * **When to use**
36930
- *
36931
- * Use to extract a single property from a struct in a pipeline.
36932
- *
36933
- * **Details**
36934
- *
36935
- * The return type is narrowed to `S[K]`.
36936
- *
36937
- * **Example** (Extracting a property in a pipeline)
36938
- *
36939
- * ```ts import.meta.vitest
36940
- * import { pipe, Struct } from "effect"
36941
- *
36942
- * pipe({ name: "Alice", age: 30 }, Struct.get("name")) // => "Alice"
36943
- * ```
36944
- *
36945
- * @see {@link keys} – list all string keys of a struct
36946
- * @see {@link pick} – extract multiple properties into a new struct
36947
- * @stability stable
36948
- * @category getters
36949
- * @since 2.0.0
36950
- */
36951
- const get$6 = /*#__PURE__*/ dual(2, (self, key) => self[key]);
36952
- /**
36953
36927
  * Creates a new struct containing only the specified keys.
36954
36928
  *
36955
36929
  * **When to use**
@@ -41572,7 +41546,7 @@ const publishUnsafe = /*#__PURE__*/ dual(2, (self, value) => {
41572
41546
  * @since 2.0.0
41573
41547
  */
41574
41548
  const subscribe = (self) => uninterruptible(contextWith((services) => {
41575
- const localScope = get$11(services, Scope);
41549
+ const localScope = get$10(services, Scope);
41576
41550
  const scope = forkUnsafe(self.scope);
41577
41551
  const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy, self.ended);
41578
41552
  return addFinalizer$1(scope, unsubscribe(subscription)).pipe(andThen(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
@@ -45598,7 +45572,7 @@ const makeUnsafe$3 = (options) => ({
45598
45572
  */
45599
45573
  const make$55 = (options) => withFiber((fiber) => {
45600
45574
  const context = fiber.context;
45601
- const scope = get$11(context, Scope);
45575
+ const scope = get$10(context, Scope);
45602
45576
  const self = makeUnsafe$3({
45603
45577
  lookup: options.lookup,
45604
45578
  context,
@@ -45665,7 +45639,7 @@ const get$4 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore)
45665
45639
  if (self.state._tag === "Closed") return interrupt$1;
45666
45640
  const state = self.state;
45667
45641
  const parent = getCurrent();
45668
- const o = get$8(state.map, key);
45642
+ const o = get$7(state.map, key);
45669
45643
  let entry;
45670
45644
  if (o._tag === "Some") {
45671
45645
  entry = o.value;
@@ -45699,7 +45673,7 @@ const get$4 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore)
45699
45673
  }));
45700
45674
  const removeInterrupted = (self, key, entry, context) => {
45701
45675
  if (self.state._tag === "Closed") return;
45702
- const o = get$8(self.state.map, key);
45676
+ const o = get$7(self.state.map, key);
45703
45677
  if (o._tag === "None" || o.value !== entry) return;
45704
45678
  remove$5(self.state.map, key);
45705
45679
  if (entry.refCount > 0) return;
@@ -45713,7 +45687,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
45713
45687
  entry.refCount--;
45714
45688
  if (entry.refCount > 0) return void_$1;
45715
45689
  else if (self.state._tag === "Closed") return closeEntry(entry);
45716
- const o = get$8(self.state.map, key);
45690
+ const o = get$7(self.state.map, key);
45717
45691
  if (o._tag === "None" || o.value !== entry) return closeEntry(entry);
45718
45692
  else if (isZero$1(entry.idleTimeToLive)) {
45719
45693
  remove$5(self.state.map, key);
@@ -45727,7 +45701,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
45727
45701
  const remaining = entry.expiresAt - now;
45728
45702
  if (remaining <= 0) {
45729
45703
  if (self.state._tag === "Closed" || entry.refCount > 0) return void_$1;
45730
- const o = get$8(self.state.map, key);
45704
+ const o = get$7(self.state.map, key);
45731
45705
  if (o._tag === "None" || o.value !== entry) return void_$1;
45732
45706
  remove$5(self.state.map, key);
45733
45707
  return ignoreCause(close(entry.scope, void_$2), {
@@ -45769,7 +45743,7 @@ var RcRefImpl = class {
45769
45743
  /** @internal */
45770
45744
  const make$54 = (options) => withFiber((fiber) => {
45771
45745
  const context = fiber.context;
45772
- const scope = get$11(context, Scope);
45746
+ const scope = get$10(context, Scope);
45773
45747
  const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== void 0 ? fromInputUnsafe$1(options.idleTimeToLive) : void 0);
45774
45748
  return as(addFinalizerExit(scope, () => {
45775
45749
  const state = ref.state;
@@ -53267,7 +53241,7 @@ const Strict = /*#__PURE__*/ Reference("effect/ai/Tool/Strict", { defaultValue:
53267
53241
  * @category getters
53268
53242
  * @since 4.0.0
53269
53243
  */
53270
- const getStrictMode = (tool) => get$11(tool.annotations, Strict);
53244
+ const getStrictMode = (tool) => get$10(tool.annotations, Strict);
53271
53245
  /**
53272
53246
  * Schema for denied or interrupted tool calls.
53273
53247
  *
@@ -60680,7 +60654,7 @@ const makeNoSerialization$1 = /*#__PURE__*/ fnUntraced(function* (group, options
60680
60654
  const disableTracing = options?.disableTracing ?? false;
60681
60655
  const generateRequestId = options?.generateRequestId ?? (() => requestIdCounter++);
60682
60656
  const services = yield* context();
60683
- const scope = get$11(services, Scope);
60657
+ const scope = get$10(services, Scope);
60684
60658
  const entries = /* @__PURE__ */ new Map();
60685
60659
  let isShutdown = false;
60686
60660
  yield* addFinalizer$1(scope, withFiber((parent) => {
@@ -61027,7 +61001,7 @@ const makeRpcSchemas = (codecFor) => {
61027
61001
  let entry = cache.get(rpc);
61028
61002
  if (entry !== void 0) return entry;
61029
61003
  const streamSchemas = getStreamSchemas(rpc.successSchema);
61030
- const parseOptions = get$11(rpc.annotations, ParseOptions);
61004
+ const parseOptions = get$10(rpc.annotations, ParseOptions);
61031
61005
  const exitSchema$2 = exitSchema(rpc);
61032
61006
  let decodeDiscardExit;
61033
61007
  entry = {
@@ -68122,7 +68096,7 @@ const isMultipartError = (u) => hasProperty(u, MultipartErrorTypeId);
68122
68096
  * @since 4.0.0
68123
68097
  */
68124
68098
  const makeConfig = (headers) => withFiber((fiber) => {
68125
- const mimeTypes = get$11(fiber.context, FieldMimeTypes);
68099
+ const mimeTypes = get$10(fiber.context, FieldMimeTypes);
68126
68100
  return succeed$5({
68127
68101
  headers,
68128
68102
  maxParts: fiber.getRef(MaxParts),
@@ -71464,7 +71438,7 @@ var MiddlewareImpl = class MiddlewareImpl {
71464
71438
  const stack = [getOrUndefinedUnsafe(context$3, fnContextKey)];
71465
71439
  if (this.dependencies) {
71466
71440
  const memoMap = yield* CurrentMemoMap;
71467
- const scope = get$11(context$3, Scope);
71441
+ const scope = get$10(context$3, Scope);
71468
71442
  const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope);
71469
71443
  stack.push(...getMiddleware$1(depsContext));
71470
71444
  }
@@ -71519,9 +71493,9 @@ const serve = (appLayer, options) => {
71519
71493
  const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$2(layer$18, succeed$6(RouterConfig)(options.routerConfig)) : layer$18);
71520
71494
  return contextWith((context) => {
71521
71495
  const memoMap = CurrentMemoMap.forkOrCreate(context);
71522
- return buildWithMemoMap(layerWithRouter, memoMap, get$11(context, Scope));
71496
+ return buildWithMemoMap(layerWithRouter, memoMap, get$10(context, Scope));
71523
71497
  }).pipe(map$5((context) => {
71524
- const handler = get$11(context, HttpRouter).asHttpEffect();
71498
+ const handler = get$10(context, HttpRouter).asHttpEffect();
71525
71499
  return merge$3(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
71526
71500
  }), unwrap$7, options?.disableListenLog ? identity : withLogAddress);
71527
71501
  };
@@ -71558,7 +71532,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
71558
71532
  const concurrency = options.concurrency ?? "unbounded";
71559
71533
  const disableFatalDefects = options.disableFatalDefects ?? false;
71560
71534
  const services = yield* context();
71561
- const scope = get$11(services, Scope);
71535
+ const scope = get$10(services, Scope);
71562
71536
  const trackFiber = runIn(forkUnsafe(scope, "parallel"));
71563
71537
  const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$72(concurrency);
71564
71538
  const clients = /* @__PURE__ */ new Map();
@@ -71799,7 +71773,7 @@ const rpcCodecs = (codecFor, rpc) => {
71799
71773
  let codecs = shared ? sharedRpcCodecs.get(rpc) : void 0;
71800
71774
  if (codecs === void 0) {
71801
71775
  const streamSchemas = getStreamSchemas(rpc.successSchema);
71802
- const parseOptions = get$11(rpc.annotations, ParseOptions);
71776
+ const parseOptions = get$10(rpc.annotations, ParseOptions);
71803
71777
  codecs = {
71804
71778
  decode: decodeUnknownEffect(codecFor(rpc.payloadSchema), parseOptions),
71805
71779
  encodeChunk: encodeUnknownEffect(codecFor(NonEmptyArray(isSome(streamSchemas) ? streamSchemas.value.success : Any)), parseOptions),
@@ -71924,7 +71898,7 @@ const make$13 = /*#__PURE__*/ fnUntraced(function* (group, options) {
71924
71898
  const exitSchema$1 = exitSchema(rpc);
71925
71899
  discardSchemas = {
71926
71900
  ...schemas,
71927
- encodeExit: encodeUnknownEffect(codecFor(Exit(Void, exitSchema$1.error, exitSchema$1.defect)), get$11(rpc.annotations, ParseOptions))
71901
+ encodeExit: encodeUnknownEffect(codecFor(Exit(Void, exitSchema$1.error, exitSchema$1.defect)), get$10(rpc.annotations, ParseOptions))
71928
71902
  };
71929
71903
  discardSchemasCache.set(rpc, discardSchemas);
71930
71904
  }
@@ -72491,7 +72465,7 @@ const runMiddleware = (handler, middleware, invocation, request) => {
72491
72465
  if (isSuccess$1(failure) && !hasDies(cause)) {
72492
72466
  const error = failure.success.error;
72493
72467
  if (isHidden(error)) return fail$7(error);
72494
- if (middleware.length === 0 || get$11(reasonAnnotations(failure.success), HandlerFailure)) return failCause$3(cause);
72468
+ if (middleware.length === 0 || get$10(reasonAnnotations(failure.success), HandlerFailure)) return failCause$3(cause);
72495
72469
  if (isMcpError(error)) return rejectWith(error);
72496
72470
  }
72497
72471
  return logError(cause).pipe(andThen(report(cause)), andThen(rejectWith(internalError)));
@@ -72580,7 +72554,7 @@ var McpServer = class McpServer extends (/*#__PURE__*/ Service$2()("effect/ai/Mc
72580
72554
  _tag: "Exit",
72581
72555
  exit: void_$2
72582
72556
  }));
72583
- const requestQueue = get$11(fiber.context, RequestNotificationQueue);
72557
+ const requestQueue = get$10(fiber.context, RequestNotificationQueue);
72584
72558
  if (requestQueue !== void 0 && queued.requestContext !== void 0 && isRequestNotification(notification)) {
72585
72559
  offerUnsafe(requestQueue, queued);
72586
72560
  return andThen(_await(delivered), acknowledge);
@@ -73538,7 +73512,7 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit) {
73538
73512
  const failure = findFail(cause);
73539
73513
  if (isSuccess$1(failure)) {
73540
73514
  const error = failure.success.error;
73541
- const origin = get$11(reasonAnnotations(failure.success), FailureOrigin);
73515
+ const origin = get$10(reasonAnnotations(failure.success), FailureOrigin);
73542
73516
  if (origin === "parameters" && isParameterValidationError(error)) return fail$7(new InvalidParams({ message: error.reason.message }));
73543
73517
  if (origin === "handler" && isDeclaredFailure(error)) return catchCause$2(declaredFailureResult(error), internalToolError);
73544
73518
  }
@@ -73553,10 +73527,10 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit) {
73553
73527
  outputSchema,
73554
73528
  annotations: {
73555
73529
  ...getOption(tool.annotations, Title).pipe(map$11((title) => ({ title })), getOrUndefined$1),
73556
- readOnlyHint: get$11(tool.annotations, Readonly),
73557
- destructiveHint: get$11(tool.annotations, Destructive),
73558
- idempotentHint: get$11(tool.annotations, Idempotent),
73559
- openWorldHint: get$11(tool.annotations, OpenWorld)
73530
+ readOnlyHint: get$10(tool.annotations, Readonly),
73531
+ destructiveHint: get$10(tool.annotations, Destructive),
73532
+ idempotentHint: get$10(tool.annotations, Idempotent),
73533
+ openWorldHint: get$10(tool.annotations, OpenWorld)
73560
73534
  },
73561
73535
  _meta: toolMeta
73562
73536
  });
@@ -73620,1021 +73594,412 @@ const makeUriMatcher = () => {
73620
73594
  };
73621
73595
  };
73622
73596
  const isProtocolVersion = (version) => version === "2024-11-05" || version === "2025-03-26" || version === "2025-06-18" || version === "2025-11-25" || version === "2026-07-28";
73597
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/process/CommandLine.js
73623
73598
  /**
73624
- * Service that derives bytes from a secret.
73599
+ * Builds command lines, the single strings that a shell or a Windows program
73600
+ * turns back into arguments, and argument lists from templates. It is
73601
+ * unrelated to `effect/cli`, which parses the arguments of your own program.
73625
73602
  *
73626
- * **Example** (Deriving a key with HKDF)
73603
+ * The rules depend on what parses the string, not on the platform that builds
73604
+ * it, so `quote`, `join` and `display` take an explicit `format`:
73627
73605
  *
73628
- * ```ts import.meta.vitest
73629
- * import { Effect } from "effect"
73630
- * import { Kdf } from "effect/crypto"
73606
+ * - `"posix"` (the default) for `sh`, `dash`, `bash` and `zsh`. Quoted output
73607
+ * is also read the same way by `fish`.
73608
+ * - `"powershell"` for PowerShell 7.3 or later.
73609
+ * - `"windows"` for the Microsoft C runtime rules that most Windows programs
73610
+ * use to split their command line.
73631
73611
  *
73632
- * const program = Effect.gen(function*() {
73633
- * const kdf = yield* Kdf.Kdf
73634
- * return yield* kdf.derive(Kdf.hkdfSha256, new Uint8Array(32), {
73635
- * salt: new Uint8Array(16),
73636
- * info: new TextEncoder().encode("encryption"),
73637
- * length: 32
73638
- * })
73639
- * })
73612
+ * SSH sends one command line to the login shell of the remote account, so the
73613
+ * format must match that shell. The remote shell must be a POSIX shell or
73614
+ * PowerShell: Windows OpenSSH uses `cmd.exe` by default, which no format
73615
+ * supports, so set its `DefaultShell` to PowerShell. Docker and Kubernetes exec
73616
+ * take argument lists and need no command line at all.
73640
73617
  *
73641
- * const bytes = await Effect.runPromise(program.pipe(Effect.provide(Kdf.layerWebCrypto)))
73642
- * bytes.length // => 32
73643
- * ```
73618
+ * Arguments can be `Redacted` strings. `quote` and `join` include their values,
73619
+ * because their output is meant to run, while `display` replaces them with
73620
+ * `<redacted>`.
73644
73621
  *
73645
73622
  * @stability unstable
73646
- * @category services
73647
- * @since 4.0.0
73623
+ * @since 4.0.7
73648
73624
  */
73649
- var Kdf = class extends (/*#__PURE__*/ Service$2()("effect/crypto/Kdf")) {};
73650
- const invalidArgument$1 = (description) => fail$6("Kdf", "derive", new InvalidArgument$1({ description }));
73651
- const isIntegerIn$1 = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;
73652
- const checkArguments = (algorithm, options) => {
73653
- if (algorithm._tag !== "Hkdf" && options.info !== void 0) return invalidArgument$1("info only applies to HKDF");
73654
- if (algorithm._tag === "Argon2id") return void 0;
73655
- if (algorithm.hash.name === "MD5") return invalidArgument$1(`${algorithm._tag} needs a SHA hash, not MD5`);
73656
- if (algorithm._tag === "Hkdf") {
73657
- const maxLength = 255 * algorithm.hash.outputLength;
73658
- return isIntegerIn$1(options.length, 1, maxLength) ? void 0 : invalidArgument$1(`length must be between 1 and ${maxLength} bytes for ${algorithm.name}`);
73659
- }
73660
- if (!isIntegerIn$1(algorithm.iterations, 1, 2147483647)) return invalidArgument$1("iterations must be between 1 and 2^31 - 1");
73661
- return isIntegerIn$1(options.length, 1, 536870911) ? void 0 : invalidArgument$1("length must be between 1 and 2^29 - 1 bytes");
73662
- };
73663
- const webCryptoParams = (algorithm, options) => algorithm._tag === "Hkdf" ? {
73664
- name: "HKDF",
73665
- hash: algorithm.hash.name,
73666
- salt: options.salt,
73667
- info: options.info ?? /* @__PURE__ */ new Uint8Array()
73668
- } : {
73669
- name: "PBKDF2",
73670
- hash: algorithm.hash.name,
73671
- salt: options.salt,
73672
- iterations: algorithm.iterations
73673
- };
73674
73625
  /**
73675
- * Layer that provides `Kdf` on the `WebCrypto` reference.
73626
+ * Error returned when a command line or a template cannot be built.
73676
73627
  *
73677
73628
  * **Details**
73678
73629
  *
73679
- * HKDF and PBKDF2 run on `crypto.subtle`, off the event loop where the runtime
73680
- * supports it. Argon2id fails with an `Unsupported` reason.
73630
+ * - `NulCharacter`: an argument passed to {@link quote} or {@link join}
73631
+ * contains a NUL character, which no command line can carry.
73632
+ * - `InvalidArgument`: the format cannot carry an argument: a Windows program
73633
+ * name with a double quote, or the argument `--%`, which PowerShell drops
73634
+ * when it calls a native program.
73635
+ * - `InvalidEscape`: template text ends with a backslash that escapes nothing,
73636
+ * or contains an invalid JavaScript escape sequence.
73637
+ * - `UnterminatedQuote`: a quoted section of a template is not closed.
73638
+ * - `UnsupportedSyntax`: template text contains shell syntax that cannot work
73639
+ * without a shell, such as operators, expansions, globs, comments or
73640
+ * variable assignments, or an interpolated array is not a separate argument.
73641
+ *
73642
+ * Messages never include the input, which may contain secrets.
73681
73643
  *
73682
73644
  * @stability unstable
73683
- * @category layers
73684
- * @since 4.0.0
73645
+ * @category errors
73646
+ * @since 4.0.7
73685
73647
  */
73686
- const layerWebCrypto = /*#__PURE__*/ effect(Kdf, /*#__PURE__*/ WebCrypto.use((crypto) => succeed$5(Kdf.of({ derive: (algorithm, secret, options) => suspend$2(() => {
73687
- const failure = checkArguments(algorithm, options);
73688
- if (failure !== void 0) return failure;
73689
- if (algorithm._tag === "Argon2id") return fail$6("Kdf", "derive", new Unsupported({ description: "Kdf.layerWebCrypto does not provide argon2id" }));
73690
- const name = algorithm._tag === "Hkdf" ? "HKDF" : "PBKDF2";
73691
- return run$6("Kdf", "derive", algorithm.name, crypto, async (subtle) => {
73692
- const handle = await subtle.importKey("raw", secret, name, false, ["deriveBits"]);
73693
- return new Uint8Array(await subtle.deriveBits(webCryptoParams(algorithm, options), handle, options.length * 8));
73694
- });
73695
- }) }))));
73696
- // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/FetchHttpClient.js
73648
+ var CommandLineError = class extends (/*#__PURE__*/ TaggedError$1("CommandLineError")) {};
73697
73649
  /**
73698
- * Fetch-based implementation of the Effect HTTP client service.
73699
- *
73700
- * This module provides an `HttpClient` layer that executes requests through a
73701
- * Web Fetch API implementation. It is the transport to use in browsers, edge
73702
- * runtimes, and Node.js environments where `globalThis.fetch` is available, or
73703
- * anywhere a compatible fetch function can be supplied.
73650
+ * Renders a command for logs and error messages.
73704
73651
  *
73705
- * Requests with an `Upgrade` header fail with `TransportError` before anything
73706
- * is sent because fetch cannot hand over the connection.
73652
+ * **When to use**
73707
73653
  *
73708
- * @stability unstable
73709
- * @since 4.0.0
73710
- */
73711
- /**
73712
- * Context reference for the `fetch` implementation used by the fetch-based HTTP client.
73654
+ * Use when you show a command to a person, for example in an error message,
73655
+ * and secrets and control characters must not reach the output.
73713
73656
  *
73714
73657
  * **Details**
73715
73658
  *
73716
- * Defaults to `globalThis.fetch`.
73659
+ * - Quotes like {@link join}, so commands without control characters or
73660
+ * secrets can be copied into a terminal of the given format.
73661
+ * - Replaces `Redacted` arguments with `<redacted>`.
73662
+ * - Writes control characters and Unicode line separators as escapes such as
73663
+ * `\n` or `\u001b`, so output cannot move the cursor or inject terminal
73664
+ * sequences.
73665
+ * - Never fails: input that {@link join} rejects is rendered anyway.
73717
73666
  *
73718
- * @stability unstable
73719
- * @category services
73720
- * @since 4.0.0
73721
- */
73722
- const Fetch = /*#__PURE__*/ Reference("effect/http/FetchHttpClient/Fetch", { defaultValue: () => globalThis.fetch });
73723
- /**
73724
- * Context reference controlling stream bodies when the runtime does not support streaming requests.
73667
+ * **Gotchas**
73725
73668
  *
73726
- * **Details**
73669
+ * The output is for reading only. It is not a reliable command line: escapes
73670
+ * and `<redacted>` change what a shell would run.
73727
73671
  *
73728
- * Defaults to `"error"`, which fails with an `EncodeError` without sending the
73729
- * request. Set to `"buffer"` to collect the entire stream in memory and send it
73730
- * as a single body instead. Runtimes with streaming support always send the stream.
73672
+ * **Example** (Showing a command with a secret)
73731
73673
  *
73732
- * **Gotchas**
73674
+ * ```ts import.meta.vitest
73675
+ * import { Redacted } from "effect"
73676
+ * import { CommandLine } from "effect/process"
73733
73677
  *
73734
- * Buffering keeps the entire upload in memory and can exhaust memory for large
73735
- * or unbounded uploads. Support is detected once, on the first stream body sent,
73736
- * using the global `Request` implementation even when a custom `Fetch` is provided.
73678
+ * const token = Redacted.make("hunter2")
73679
+ *
73680
+ * CommandLine.display(["curl", "-H", token, "https://x.dev/a b"]) // => "curl -H <redacted> 'https://x.dev/a b'"
73681
+ * ```
73682
+ *
73683
+ * @see {@link join} for building a command line to run
73737
73684
  *
73738
73685
  * @stability unstable
73739
- * @category services
73740
- * @since 4.0.0
73686
+ * @category encoding
73687
+ * @since 4.0.7
73741
73688
  */
73742
- const StreamBodyFallback = /*#__PURE__*/ Reference("effect/http/FetchHttpClient/StreamBodyFallback", { defaultValue: () => "error" });
73689
+ const display = (words, options) => {
73690
+ if (words.length === 0) return "";
73691
+ const format = options?.format ?? "posix";
73692
+ return joinWords(format, words.map((word, i) => isRedacted(word) ? "<redacted>" : escapeControlCharacters$1(quoteWord(format, word, i === 0))));
73693
+ };
73743
73694
  /**
73744
- * Service that contains default fetch options for the fetch-based HTTP client.
73695
+ * Builds an argument list from a template literal.
73745
73696
  *
73746
73697
  * **When to use**
73747
73698
  *
73748
- * Use to provide default credentials, cache, redirect, integrity, or other
73749
- * fetch options for outgoing HTTP requests.
73699
+ * Use to write a command as it would look in a shell while keeping every
73700
+ * interpolated value a literal argument.
73750
73701
  *
73751
73702
  * **Details**
73752
73703
  *
73753
- * Request-specific method, headers, body, and abort signal are supplied by the client when a request is executed.
73704
+ * - The template text is split into words as a POSIX shell does: spaces,
73705
+ * tabs and line breaks separate words, and quotes and backslash escapes are
73706
+ * removed. A long command can span several lines.
73707
+ * - Text that would need a shell fails with `UnsupportedSyntax`: operators
73708
+ * (`| & ; < > ( )`), expansions (`$NAME`, `${...}`, `$(...)`, backticks, a
73709
+ * leading `~`, braces such as `{a,b}`, and a leading `=` that `zsh`
73710
+ * expands), globs (`* ? [`), comments (`#` at the start of a word), and a
73711
+ * variable assignment in the program position. Quote such characters to
73712
+ * pass them literally.
73713
+ * - No shell runs, so a program such as `if` or `time` names an executable.
73714
+ * - Each `${}` value is inserted literally, without splitting or quote
73715
+ * processing. Next to other text or inside quotes, it becomes part of the
73716
+ * surrounding argument.
73717
+ * - An array adds one argument per element and must stand alone as a whole
73718
+ * argument.
73719
+ * - Numbers and booleans are converted with `String`.
73720
+ * - An argument that contains a `Redacted` value becomes `Redacted` as a
73721
+ * whole.
73754
73722
  *
73755
- * @see {@link HttpClient.followRedirects} for following redirects in the client, which needs `{ redirect: "manual" }` here
73723
+ * **Gotchas**
73724
+ *
73725
+ * - An invalid JavaScript escape sequence in the text, such as `\u` without
73726
+ * hex digits, fails with `InvalidEscape`. Use `String.raw` or a `${}` value
73727
+ * for backslashes.
73728
+ * - Neither the text nor the values are checked for NUL characters.
73729
+ * {@link join} and the child process spawners reject them where they would
73730
+ * truncate an argument.
73731
+ *
73732
+ * **Example** (Building arguments with interpolated values)
73733
+ *
73734
+ * ```ts import.meta.vitest
73735
+ * import { Redacted, Result } from "effect"
73736
+ * import { CommandLine } from "effect/process"
73737
+ *
73738
+ * const msg = "fix: handle $HOME"
73739
+ * const files = ["a.ts", "b.ts"]
73740
+ *
73741
+ * CommandLine.template`git commit -m ${msg} ${files}` // => Result.succeed(["git", "commit", "-m", msg, ...files])
73742
+ *
73743
+ * const password = Redacted.make("hunter2")
73744
+ * const words = Result.getOrThrow(CommandLine.template`psql "--password=${password}"`)
73745
+ *
73746
+ * CommandLine.display(words) // => "psql <redacted>"
73747
+ * ```
73756
73748
  *
73757
73749
  * @stability unstable
73758
- * @category services
73759
- * @since 4.0.0
73750
+ * @category constructors
73751
+ * @since 4.0.7
73760
73752
  */
73761
- var RequestInit = class extends (/*#__PURE__*/ Service$2()("effect/http/FetchHttpClient/RequestInit")) {};
73762
- let supportsStreamBody;
73763
- const detectStreamBodySupport = () => {
73764
- try {
73765
- let duplexAccessed = false;
73766
- const body = new ReadableStream();
73767
- const request = new Request("https://example.com", {
73768
- method: "POST",
73769
- body,
73770
- get duplex() {
73771
- duplexAccessed = true;
73772
- return "half";
73753
+ const template = (strings, ...expressions) => {
73754
+ const index = strings.findIndex((text) => text === void 0);
73755
+ if (index !== -1) return fail$12(new CommandLineError({
73756
+ reason: "InvalidEscape",
73757
+ message: `Template part ${index} contains an invalid escape sequence`
73758
+ }));
73759
+ return parseTemplate$1(strings, expressions);
73760
+ };
73761
+ const unwrap$1 = (item) => isRedacted(item) ? value$2(item) : String(item);
73762
+ const toWord = (item) => isRedacted(item) ? item : String(item);
73763
+ const reservedWords = /*#__PURE__*/ new Set([
73764
+ "!",
73765
+ "{",
73766
+ "}",
73767
+ "and",
73768
+ "begin",
73769
+ "case",
73770
+ "coproc",
73771
+ "do",
73772
+ "done",
73773
+ "elif",
73774
+ "else",
73775
+ "end",
73776
+ "esac",
73777
+ "fi",
73778
+ "for",
73779
+ "foreach",
73780
+ "function",
73781
+ "if",
73782
+ "in",
73783
+ "nocorrect",
73784
+ "not",
73785
+ "or",
73786
+ "repeat",
73787
+ "select",
73788
+ "switch",
73789
+ "then",
73790
+ "time",
73791
+ "until",
73792
+ "while"
73793
+ ]);
73794
+ const quoteWord = (format, value, program) => {
73795
+ switch (format) {
73796
+ case "posix": return program && reservedWords.has(value) ? `'${value}'` : quotePosix(value);
73797
+ case "powershell": return quotePowerShell(value);
73798
+ case "windows": return program && !value.includes("\"") ? quoteWindowsProgram(value) : quoteWindowsArgument(value);
73799
+ }
73800
+ };
73801
+ const joinWords = (format, quoted) => format === "powershell" ? `& ${quoted.join(" ")}` : quoted.join(" ");
73802
+ const posixSafe = /^[A-Za-z0-9_@+:,./-]+$/;
73803
+ const quotePosix = (value) => posixSafe.test(value) ? value : `'${value.replace(/['\\]/g, (char) => `'\\${char}'`)}'`;
73804
+ const quotePowerShell = (value) => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, "$&$&")}'`;
73805
+ const windowsNeedsQuotes = /[ \t\n\v"]/;
73806
+ const quoteWindowsArgument = (value) => {
73807
+ if (value.length > 0 && !windowsNeedsQuotes.test(value)) return value;
73808
+ let out = "\"";
73809
+ let backslashes = 0;
73810
+ for (const char of value) if (char === "\\") backslashes++;
73811
+ else if (char === "\"") {
73812
+ out += "\\".repeat(backslashes * 2 + 1) + "\"";
73813
+ backslashes = 0;
73814
+ } else {
73815
+ out += "\\".repeat(backslashes) + char;
73816
+ backslashes = 0;
73817
+ }
73818
+ return out + "\\".repeat(backslashes * 2) + "\"";
73819
+ };
73820
+ const quoteWindowsProgram = (value) => value.length > 0 && !/[ \t]/.test(value) ? value : `"${value}"`;
73821
+ const controlCharacters = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g;
73822
+ const controlEscapes = {
73823
+ "\n": "\\n",
73824
+ "\r": "\\r",
73825
+ " ": "\\t"
73826
+ };
73827
+ const escapeControlCharacters$1 = (value) => value.replace(controlCharacters, (char) => controlEscapes[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
73828
+ const operators = "|&;<>()";
73829
+ const globs = "*?[";
73830
+ const expansionStart = /[A-Za-z_0-9{(@*#?$!'"-]/;
73831
+ const quotedExpansionStart = /[A-Za-z_0-9{(@*#?$!-]/;
73832
+ const assignmentName = /^[A-Za-z_][A-Za-z0-9_]*\+?$/;
73833
+ const isBlank = (char) => char === " " || char === " " || char === "\n";
73834
+ const unsupportedSyntax = (char, next, wordStart) => {
73835
+ if (operators.includes(char)) return `The operator "${char}" needs a shell`;
73836
+ if (char === "`") return "Command substitution needs a shell";
73837
+ if (char === "$" && next !== void 0 && expansionStart.test(next)) return `The expansion "$${next}" needs a shell`;
73838
+ if (globs.includes(char)) return `The glob character "${char}" needs a shell`;
73839
+ if (!wordStart) return void 0;
73840
+ if (char === "#") return "A comment needs a shell";
73841
+ if (char === "~") return "Tilde expansion needs a shell";
73842
+ if (char === "=" && next !== void 0 && !isBlank(next)) return "A leading \"=\" is expanded by zsh";
73843
+ };
73844
+ const parseTemplate$1 = (texts, values) => {
73845
+ const words = [];
73846
+ let word = [];
73847
+ let plain = true;
73848
+ let braceDepth = 0;
73849
+ let quote = void 0;
73850
+ let quotePart = 0;
73851
+ let part = 0;
73852
+ const error = (reason, message, at = part) => fail$12(new CommandLineError({
73853
+ reason,
73854
+ message: `${message} in template part ${at}`
73855
+ }));
73856
+ const endWord = () => {
73857
+ if (word.length === 0) return;
73858
+ const value = word.map(unwrap$1).join("");
73859
+ words.push(word.length === 1 && isRedacted(word[0]) ? word[0] : word.some(isRedacted) ? make$65(value) : value);
73860
+ word = [];
73861
+ plain = true;
73862
+ braceDepth = 0;
73863
+ };
73864
+ const scan = (text) => {
73865
+ for (let i = 0; i < text.length; i++) {
73866
+ const char = text[i];
73867
+ const next = text[i + 1];
73868
+ if (quote === "'") {
73869
+ if (char === "'") quote = void 0;
73870
+ else word.push(char);
73871
+ } else if (quote === "\"") {
73872
+ if (char === "\"") quote = void 0;
73873
+ else if (char === "\\" && next !== void 0 && "$`\"\\\n".includes(next)) {
73874
+ if (next !== "\n") word.push(next);
73875
+ i++;
73876
+ } else if (char === "`") return error("UnsupportedSyntax", "Command substitution needs a shell");
73877
+ else if (char === "$" && next !== void 0 && quotedExpansionStart.test(next)) return error("UnsupportedSyntax", `The expansion "$${next}" needs a shell`);
73878
+ else word.push(char);
73879
+ } else if (isBlank(char)) endWord();
73880
+ else if (char === "\\") {
73881
+ if (next === void 0) return error("InvalidEscape", "A trailing backslash escapes nothing");
73882
+ if (next !== "\n") {
73883
+ word.push(next);
73884
+ plain = false;
73885
+ }
73886
+ i++;
73887
+ } else if (char === "'" || char === "\"") {
73888
+ quote = char;
73889
+ quotePart = part;
73890
+ word.push("");
73891
+ plain = false;
73892
+ } else {
73893
+ const unsupported = unsupportedSyntax(char, next, word.length === 0);
73894
+ if (unsupported !== void 0) return error("UnsupportedSyntax", unsupported);
73895
+ if (char === "{") braceDepth++;
73896
+ else if (char === "}") {
73897
+ if (braceDepth > 0) braceDepth--;
73898
+ } else if (braceDepth > 0 && (char === "," || char === "." && next === ".")) return error("UnsupportedSyntax", "Brace expansion needs a shell");
73899
+ else if (char === "=" && words.length === 0 && plain && assignmentName.test(word.join(""))) return error("UnsupportedSyntax", "A variable assignment needs a shell");
73900
+ word.push(char);
73773
73901
  }
73774
- });
73775
- return (duplexAccessed || request.body === body) && !request.headers.has("Content-Type");
73776
- } catch {
73777
- return false;
73902
+ }
73903
+ };
73904
+ for (; part < texts.length; part++) {
73905
+ const failure = scan(texts[part]);
73906
+ if (failure !== void 0) return failure;
73907
+ if (part === values.length) break;
73908
+ const expression = values[part];
73909
+ if (Array.isArray(expression)) {
73910
+ const after = texts[part + 1][0];
73911
+ if (word.length > 0 || (after === void 0 ? part + 1 < values.length : !isBlank(after))) return error("UnsupportedSyntax", "An interpolated array must be a separate argument");
73912
+ for (const item of expression) words.push(toWord(item));
73913
+ } else {
73914
+ word.push(toWord(expression));
73915
+ plain = false;
73916
+ }
73778
73917
  }
73918
+ if (quote !== void 0) return error("UnterminatedQuote", "The quote is not closed", quotePart);
73919
+ endWord();
73920
+ return succeed$10(words);
73779
73921
  };
73922
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/process/ChildProcess.js
73780
73923
  /**
73781
- * Layer that provides an `HttpClient` implementation backed by the configured
73782
- * `Fetch` function.
73924
+ * Describes child processes before they are started.
73783
73925
  *
73784
- * **When to use**
73926
+ * A `Command` stores the executable, arguments, environment, standard streams,
73927
+ * working directory, and other process options. Commands can also be piped
73928
+ * together. A command is an `Effect`; running it asks the
73929
+ * `ChildProcessSpawner` service to start the process and returns a
73930
+ * `ChildProcessHandle`.
73785
73931
  *
73786
- * Use when an Effect program should execute `HttpClient` requests through the
73787
- * platform `fetch` implementation, especially in browser, edge, or Node.js
73788
- * runtimes with `globalThis.fetch`.
73932
+ * @stability unstable
73933
+ * @since 4.0.0
73934
+ */
73935
+ const TypeId$5 = "~effect/process/ChildProcess";
73936
+ const Proto$3 = {
73937
+ .../*#__PURE__*/ Prototype({
73938
+ label: "Command",
73939
+ evaluate(fiber) {
73940
+ return getUnsafe$2(fiber.context, ChildProcessSpawner).spawn(this);
73941
+ }
73942
+ }),
73943
+ [TypeId$5]: TypeId$5
73944
+ };
73945
+ const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$3), {
73946
+ _tag: "StandardCommand",
73947
+ command,
73948
+ args,
73949
+ options
73950
+ });
73951
+ /**
73952
+ * Create a command from a template literal, options + template, or array form.
73789
73953
  *
73790
73954
  * **Details**
73791
73955
  *
73792
- * The layer uses the current `Fetch` reference and optional `RequestInit`
73793
- * service for each request. Request-specific method, headers, body, and abort
73794
- * signal are supplied by the client and override matching `RequestInit` fields.
73956
+ * This function supports three calling conventions:
73957
+ * 1. Template literal: `make\`npm run build\``
73958
+ * 2. Options + template literal: `make({ cwd: "/app" })\`npm run build\``
73959
+ * 3. Array form: `make("npm", ["run", "build"], options?)`
73960
+ *
73961
+ * Templates are split with `CommandLine.template`: quotes group words, each
73962
+ * `${}` value is one literal argument, and an argument that contains a
73963
+ * `Redacted` value stays `Redacted`. Arguments in the array form can be
73964
+ * `Redacted` too.
73965
+ *
73966
+ * With the `shell` option, the template text is the shell script and is kept
73967
+ * as written.
73795
73968
  *
73796
73969
  * **Gotchas**
73797
73970
  *
73798
- * Fetch behavior comes from the runtime's implementation, so CORS, cookies,
73799
- * redirects, abort handling, and streaming support can vary by platform.
73800
- * `fetch` follows redirects itself by default, so `HttpClient.followRedirects`
73801
- * has no effect unless `RequestInit` sets `redirect: "manual"`. Trace
73802
- * propagation is on by default, and a browser preflight fails unless the
73803
- * target allows `b3` and `traceparent`. Stream request bodies are sent as Web
73804
- * streams with `duplex: "half"` when the runtime supports it; see
73805
- * `StreamBodyFallback` for the unsupported case. Any `content-length` header is
73806
- * removed before calling `fetch`. Chrome passes the support check but rejects
73807
- * streaming uploads over HTTP/1.1, which surfaces as a `TransportError`, and
73808
- * browsers only deliver the response after the entire request body has been sent.
73971
+ * - A template is parsed when `make` is called. Shell syntax such as `|`,
73972
+ * `$HOME`, `*` or `~` throws a `CommandLine.CommandLineError`: quote it, or
73973
+ * pass the value with `${}`.
73974
+ * - A template with the `shell` option cannot contain `${}` values, because
73975
+ * their quoting depends on the shell. Build the script with
73976
+ * `CommandLine.quote` and pass it as a string.
73977
+ * - The program name, the first word, cannot be `Redacted`.
73978
+ * - A NUL character in the command, an argument or an `env` value fails with
73979
+ * a `BadArgument` error when the command is spawned.
73809
73980
  *
73810
- * @see {@link Fetch} for supplying the fetch implementation used by this layer
73811
- * @see {@link RequestInit} for default `RequestInit` options applied before request-specific fields
73812
- * @see {@link StreamBodyFallback} for opting into buffering on unsupported runtimes
73813
- * @see {@link HttpClient.TracerPropagationEnabled} for leaving `b3` and `traceparent` off a browser request
73981
+ * **Example** (Creating commands)
73982
+ *
73983
+ * ```ts import.meta.vitest
73984
+ * import { ChildProcess } from "effect/process"
73985
+ *
73986
+ * // Template literal form; quotes group words
73987
+ * const cmd1 = ChildProcess.make`echo "hello world"`
73988
+ *
73989
+ * // With options
73990
+ * const cmd2 = ChildProcess.make({ cwd: "/tmp" })`ls -la`
73991
+ *
73992
+ * // Array form
73993
+ * const cmd3 = ChildProcess.make("git", ["status"])
73994
+ *
73995
+ * const result = [cmd1.args[0], cmd2.options.cwd, cmd3.args[0]] // => ["hello world", "/tmp", "status"]
73996
+ * ```
73814
73997
  *
73815
73998
  * @stability unstable
73816
- * @category layers
73999
+ * @category constructors
73817
74000
  * @since 4.0.0
73818
74001
  */
73819
- const layer$16 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$5(/* @__PURE__ */ make$34((request, url, signal, fiber) => {
73820
- if (request.headers.upgrade !== void 0) return fail$7(new HttpClientError({ reason: new TransportError({
73821
- request,
73822
- description: "fetch cannot send an HTTP upgrade request"
73823
- }) }));
73824
- const fetch = fiber.getRef(Fetch);
73825
- const options = getOrUndefined(fiber.context, RequestInit) ?? {};
73826
- let headers = options.headers ? merge$2(fromInput$1(options.headers), request.headers) : request.headers;
73827
- if (headers["content-length"]) headers = remove$1(headers, "content-length");
73828
- let uploadController;
73829
- const stopUpload = sync(() => uploadController?.abort());
73830
- const send = (body) => map$5(tryPromise({
73831
- try: () => fetch(url, {
73832
- ...options,
73833
- method: request.method,
73834
- headers,
73835
- body,
73836
- duplex: typeof ReadableStream !== "undefined" && body instanceof ReadableStream ? "half" : void 0,
73837
- signal: uploadController ? AbortSignal.any([signal, uploadController.signal]) : signal
73838
- }),
73839
- catch: (cause) => new HttpClientError({ reason: new TransportError({
73840
- request,
73841
- cause
73842
- }) })
73843
- }), (response) => {
73844
- const original = fromWeb(request, response);
73845
- if (!uploadController) return original;
73846
- if (response.body === null) uploadController.abort();
73847
- return Object.create(original, {
73848
- ...Object.fromEntries([
73849
- "arrayBuffer",
73850
- "text",
73851
- "json",
73852
- "formData",
73853
- "urlParamsBody"
73854
- ].map((key) => [key, { get: () => ensuring$2(original[key], stopUpload) }])),
73855
- stream: { get: () => ensuring(original.stream, stopUpload) }
73856
- });
73857
- }).pipe(onError(() => stopUpload));
73858
- switch (request.body._tag) {
73859
- case "Raw":
73860
- case "Uint8Array": return send(request.body.body);
73861
- case "FormData": return send(request.body.formData);
73862
- case "Stream":
73863
- supportsStreamBody ??= detectStreamBodySupport();
73864
- if (supportsStreamBody) {
73865
- uploadController = new AbortController();
73866
- const uploadSignal = AbortSignal.any([signal, uploadController.signal]);
73867
- const stopped = callback$1((resume) => {
73868
- const onAbort = () => resume(interrupt$1);
73869
- if (uploadSignal.aborted) {
73870
- onAbort();
73871
- return;
73872
- }
73873
- uploadSignal.addEventListener("abort", onAbort, { once: true });
73874
- return sync(() => uploadSignal.removeEventListener("abort", onAbort));
73875
- });
73876
- return flatMap$3(toReadableStreamEffect(interruptWhen(request.body.stream, stopped)), send);
73877
- }
73878
- if (fiber.getRef(StreamBodyFallback) === "error") return fail$7(new HttpClientError({ reason: new EncodeError({
73879
- request,
73880
- description: "Streaming request bodies are not supported in this runtime"
73881
- }) }));
73882
- return mkArrayBuffer(request.body.stream).pipe(mapError$2((cause) => new HttpClientError({ reason: new EncodeError({
73883
- request,
73884
- cause
73885
- }) })), flatMap$3(send));
73886
- }
73887
- return send(void 0);
73888
- })));
73889
- // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/HttpStaticServer.js
73890
- /**
73891
- * Serves static files for Effect HTTP applications.
73892
- *
73893
- * `HttpStaticServer` turns request paths into file responses under a configured
73894
- * root directory. It can be used as an application value or mounted onto an
73895
- * `HttpRouter`, and it handles index files, optional single-page application
73896
- * fallback, MIME type headers, cache-control headers, byte ranges, and
73897
- * conditional `304 Not Modified` responses.
73898
- *
73899
- * @stability unstable
73900
- * @since 4.0.0
73901
- */
73902
- /**
73903
- * Creates an `HttpApp` that serves files from a directory.
73904
- *
73905
- * **Example** (Serving files from a directory)
73906
- *
73907
- * ```ts import.meta.vitest
73908
- * import { ByteSize, Effect, FileSystem, Layer, Path } from "effect"
73909
- * import {
73910
- * HttpEffect,
73911
- * HttpPlatform,
73912
- * HttpServerResponse,
73913
- * HttpStaticServer
73914
- * } from "effect/http"
73915
- *
73916
- * const TestFileSystem = FileSystem.layerNoop({
73917
- * stat: () =>
73918
- * Effect.succeed({
73919
- * type: "File",
73920
- * size: ByteSize.bytes(20)
73921
- * } as FileSystem.File.Info)
73922
- * })
73923
- * const TestHttpPlatform = Layer.succeed(
73924
- * HttpPlatform.HttpPlatform,
73925
- * HttpPlatform.HttpPlatform.of({
73926
- * platform: "web",
73927
- * fileResponse: (path) => Effect.succeed(HttpServerResponse.text(`Serving ${path}`)),
73928
- * fileWebResponse: () => Effect.die("unused")
73929
- * })
73930
- * )
73931
- * const TestServices = Layer.mergeAll(Path.layer, TestFileSystem, TestHttpPlatform)
73932
- *
73933
- * const program = Effect.gen(function*() {
73934
- * const app = yield* HttpStaticServer.make({ root: "/public" })
73935
- * const handler = HttpEffect.toWebHandler(app)
73936
- * const response = yield* Effect.promise(() => handler(new Request("http://localhost/guide.txt")))
73937
- * const body = yield* Effect.promise(() => response.text())
73938
- * return body
73939
- * }).pipe(Effect.provide(TestServices))
73940
- *
73941
- * await Effect.runPromise(program) // => "Serving /public/guide.txt"
73942
- * ```
73943
- *
73944
- * @stability unstable
73945
- * @category constructors
73946
- * @since 4.0.0
73947
- */
73948
- const make$12 = /*#__PURE__*/ fnUntraced(function* (options) {
73949
- const fileSystem = yield* FileSystem;
73950
- const path = yield* Path$1;
73951
- const platform = yield* HttpPlatform;
73952
- const resolvedRoot = path.resolve(options.root);
73953
- const index = "index" in options ? options.index : "index.html";
73954
- const spa = options.spa === true;
73955
- const cacheControl = options.cacheControl;
73956
- const mimeTypes = {
73957
- ...defaultMimeTypes,
73958
- ...options.mimeTypes
73959
- };
73960
- const setFileHeaders = (response, filePath) => {
73961
- let currentResponse = setHeaders(response, {
73962
- "Content-Type": resolveMimeType(path, filePath, mimeTypes),
73963
- "Accept-Ranges": "bytes"
73964
- });
73965
- if (cacheControl !== void 0) currentResponse = setHeader(currentResponse, "Cache-Control", cacheControl);
73966
- return currentResponse;
73967
- };
73968
- const serveFile = fnUntraced(function* (request, filePath, fileSize) {
73969
- const rangeHeader = request.method === "GET" ? request.headers["range"] : void 0;
73970
- const shouldEvaluateConditionals = request.headers["if-match"] !== void 0 || request.headers["if-unmodified-since"] !== void 0 || request.headers["if-none-match"] !== void 0 || request.headers["if-modified-since"] !== void 0;
73971
- let fullResponse;
73972
- const getFullResponse = () => fullResponse === void 0 ? map$5(handlePlatformError(request, platform.fileResponse(filePath)), (response) => setFileHeaders(response, filePath)) : succeed$5(fullResponse);
73973
- if (shouldEvaluateConditionals) {
73974
- fullResponse = yield* getFullResponse();
73975
- const conditionalResponse = evaluateConditionalRequest(request, fullResponse);
73976
- if (conditionalResponse !== void 0) return conditionalResponse;
73977
- }
73978
- if (rangeHeader === void 0) return yield* getFullResponse();
73979
- const ifRange = request.headers["if-range"];
73980
- if (ifRange !== void 0) {
73981
- fullResponse = yield* getFullResponse();
73982
- if (!matchesIfRange(ifRange, fullResponse.headers["etag"])) return fullResponse;
73983
- }
73984
- const resolvedFileSize = fileSize ?? (yield* handlePlatformError(request, fileSystem.stat(filePath))).size;
73985
- const parsedRange = parseRange(rangeHeader, resolvedFileSize);
73986
- if (parsedRange === void 0) return yield* getFullResponse();
73987
- if (parsedRange === "unsatisfiable") return empty({
73988
- status: 416,
73989
- headers: { "Content-Range": `bytes */${resolvedFileSize}` }
73990
- });
73991
- let response = setFileHeaders(yield* handlePlatformError(request, platform.fileResponse(filePath, {
73992
- status: 206,
73993
- offset: parsedRange.start,
73994
- bytesToRead: parsedRange.end - parsedRange.start + BigInt(1)
73995
- })), filePath);
73996
- response = setHeader(response, "Content-Range", `bytes ${parsedRange.start}-${parsedRange.end}/${resolvedFileSize}`);
73997
- return response;
73998
- });
73999
- return HttpServerRequest.use((request) => {
74000
- const resolvedPath = resolveFilePath(path, resolvedRoot, request.url);
74001
- if (resolvedPath === void 0) return fail$7(toRouteNotFoundError(request));
74002
- return matchEffect(fileSystem.stat(resolvedPath), {
74003
- onFailure: (error) => error.reason._tag === "NotFound" && spa && index !== void 0 && path.extname(resolvedPath) === "" && acceptsHtml(request.headers["accept"]) ? serveFile(request, path.join(resolvedRoot, index)) : error.reason._tag === "NotFound" ? fail$7(toRouteNotFoundError(request)) : fail$7(toInternalServerError(request, error)),
74004
- onSuccess(info) {
74005
- if (info.type === "File") return serveFile(request, resolvedPath, info.size);
74006
- if (info.type === "Directory" && index !== void 0) {
74007
- let originalUrl = request.originalUrl;
74008
- if (!originalUrl.startsWith("/")) {
74009
- const url = new URL(originalUrl);
74010
- originalUrl = url.pathname + url.search;
74011
- }
74012
- const pathname = stripQueryString(originalUrl);
74013
- if (!pathname.endsWith("/")) {
74014
- const location = pathname.replace(/^\/+/, "/").replace(/\\/g, "%5C");
74015
- return succeed$5(redirect(`${location}/${originalUrl.slice(pathname.length)}`, { status: 301 }));
74016
- }
74017
- return serveFile(request, path.join(resolvedPath, index));
74018
- }
74019
- return fail$7(toRouteNotFoundError(request));
74020
- }
74021
- });
74022
- });
74023
- });
74024
- /**
74025
- * Creates a layer that mounts static files on an `HttpRouter`.
74026
- *
74027
- * **Example** (Mounting static files on a router)
74028
- *
74029
- * ```ts import.meta.vitest
74030
- * import { Layer } from "effect"
74031
- * import { HttpRouter, HttpServerResponse, HttpStaticServer } from "effect/http"
74032
- *
74033
- * const ApiLayer = HttpRouter.add("GET", "/health", HttpServerResponse.text("ok"))
74034
- *
74035
- * const StaticFilesLayer = HttpStaticServer.layer({
74036
- * root: "./public",
74037
- * prefix: "/static"
74038
- * })
74039
- *
74040
- * const AppLayer = Layer.mergeAll(ApiLayer, StaticFilesLayer)
74041
- * Layer.isLayer(AppLayer) // => true
74042
- * ```
74043
- *
74044
- * @stability unstable
74045
- * @category layers
74046
- * @since 4.0.0
74047
- */
74048
- const layer$15 = (options) => effectDiscard(gen(function* () {
74049
- const router = yield* HttpRouter;
74050
- const handler = (yield* make$12(options)).pipe(catch_$2(toResponse));
74051
- if (options.prefix !== void 0) {
74052
- yield* router.prefixed(options.prefix).add("GET", "/*", handler);
74053
- return;
74054
- }
74055
- yield* router.add("GET", "/*", handler);
74056
- }));
74057
- const defaultMimeTypes = {
74058
- html: "text/html; charset=utf-8",
74059
- htm: "text/html; charset=utf-8",
74060
- css: "text/css; charset=utf-8",
74061
- js: "text/javascript; charset=utf-8",
74062
- mjs: "text/javascript; charset=utf-8",
74063
- json: "application/json; charset=utf-8",
74064
- xml: "application/xml; charset=utf-8",
74065
- txt: "text/plain; charset=utf-8",
74066
- csv: "text/csv; charset=utf-8",
74067
- md: "text/markdown; charset=utf-8",
74068
- yaml: "text/yaml; charset=utf-8",
74069
- yml: "text/yaml; charset=utf-8",
74070
- png: "image/png",
74071
- jpg: "image/jpeg",
74072
- jpeg: "image/jpeg",
74073
- gif: "image/gif",
74074
- svg: "image/svg+xml; charset=utf-8",
74075
- ico: "image/x-icon",
74076
- webp: "image/webp",
74077
- avif: "image/avif",
74078
- woff: "font/woff",
74079
- woff2: "font/woff2",
74080
- ttf: "font/ttf",
74081
- otf: "font/otf",
74082
- eot: "application/vnd.ms-fontobject",
74083
- mp3: "audio/mpeg",
74084
- mp4: "video/mp4",
74085
- webm: "video/webm",
74086
- ogg: "audio/ogg",
74087
- wav: "audio/wav",
74088
- flac: "audio/flac",
74089
- aac: "audio/aac",
74090
- pdf: "application/pdf",
74091
- zip: "application/zip",
74092
- gz: "application/gzip",
74093
- wasm: "application/wasm",
74094
- map: "application/json",
74095
- webmanifest: "application/manifest+json"
74096
- };
74097
- const stripQueryString = (url) => {
74098
- const queryIndex = url.indexOf("?");
74099
- return queryIndex === -1 ? url : url.slice(0, queryIndex);
74100
- };
74101
- const resolveMimeType = (path, filePath, mimeTypes) => {
74102
- const extension = path.extname(filePath).toLowerCase();
74103
- if (extension.length <= 1) return "application/octet-stream";
74104
- return mimeTypes[extension.slice(1)] ?? "application/octet-stream";
74105
- };
74106
- const parseInteger = (value) => {
74107
- if (!/^\d+$/.test(value)) return;
74108
- return BigInt(value);
74109
- };
74110
- const parseRange = (header, fileSize) => {
74111
- const value = header.trim();
74112
- if (!value.toLowerCase().startsWith("bytes=")) return;
74113
- const rangeValue = value.slice(6).trim();
74114
- if (rangeValue.length === 0 || rangeValue.includes(",")) return;
74115
- const separatorIndex = rangeValue.indexOf("-");
74116
- if (separatorIndex === -1) return;
74117
- const startPart = rangeValue.slice(0, separatorIndex).trim();
74118
- const endPart = rangeValue.slice(separatorIndex + 1).trim();
74119
- if (startPart === "" && endPart === "") return;
74120
- if (startPart === "") {
74121
- const suffixLength = parseInteger(endPart);
74122
- if (suffixLength === void 0) return;
74123
- if (suffixLength === BigInt(0) || fileSize === BigInt(0)) return "unsatisfiable";
74124
- return {
74125
- start: fileSize > suffixLength ? fileSize - suffixLength : BigInt(0),
74126
- end: fileSize - BigInt(1)
74127
- };
74128
- }
74129
- const start = parseInteger(startPart);
74130
- if (start === void 0) return;
74131
- if (endPart === "") {
74132
- if (start >= fileSize) return "unsatisfiable";
74133
- return {
74134
- start,
74135
- end: fileSize - BigInt(1)
74136
- };
74137
- }
74138
- const end = parseInteger(endPart);
74139
- if (end === void 0) return;
74140
- if (start > end || start >= fileSize) return "unsatisfiable";
74141
- return {
74142
- start,
74143
- end: end < fileSize ? end : fileSize - BigInt(1)
74144
- };
74145
- };
74146
- const resolveFilePath = (path, root, url) => {
74147
- const urlPath = stripQueryString(url);
74148
- let decodedPath;
74149
- try {
74150
- decodedPath = decodeURIComponent(urlPath);
74151
- } catch {
74152
- return;
74153
- }
74154
- if (decodedPath.includes("\0")) return;
74155
- const relativePath = decodedPath.replace(path.sep === "\\" ? /^[/\\]+/ : /^\/+/, "");
74156
- return getOrUndefined$1(path.resolveWithin(root, relativePath));
74157
- };
74158
- const toRouteNotFoundError = (request) => new HttpServerError({ reason: new RouteNotFound({ request }) });
74159
- const toInternalServerError = (request, cause) => new HttpServerError({ reason: new InternalError({
74160
- request,
74161
- cause
74162
- }) });
74163
- const handlePlatformError = (request, self) => catchIf(self, (error) => error.reason._tag === "NotFound", () => fail$7(toRouteNotFoundError(request)), (error) => fail$7(toInternalServerError(request, error)));
74164
- const acceptsHtml = (accept) => accept !== void 0 && accept.toLowerCase().includes("text/html");
74165
- const stripWeakEtagPrefix = (value) => {
74166
- const trimmed = value.trim();
74167
- return /^w\//i.test(trimmed) ? trimmed.slice(2) : trimmed;
74168
- };
74169
- const entityTagList = /^[\s,]*(?:(?:W\/)?"[^"]*"\s*(?:,[\s,]*|$))*$/;
74170
- const entityTag = /(?:W\/)?"[^"]*"/g;
74171
- const matchesIfMatch = (ifMatch, etag) => {
74172
- if (ifMatch.trim() === "*") return true;
74173
- if (etag === void 0 || !etag.startsWith("\"") || !entityTagList.test(ifMatch)) return false;
74174
- return ifMatch.match(entityTag)?.includes(etag) ?? false;
74175
- };
74176
- const matchesIfNoneMatch = (ifNoneMatch, etag) => {
74177
- const normalizedEtag = etag === void 0 ? void 0 : stripWeakEtagPrefix(etag);
74178
- for (const candidate of ifNoneMatch.split(",")) {
74179
- const value = candidate.trim();
74180
- if (value === "") continue;
74181
- if (value === "*") return true;
74182
- if (normalizedEtag !== void 0 && stripWeakEtagPrefix(value) === normalizedEtag) return true;
74183
- }
74184
- return false;
74185
- };
74186
- const isModifiedSince = (since, lastModified) => {
74187
- if (lastModified === void 0) return;
74188
- const sinceDate = parseHttpDate(since);
74189
- if (isFailure$1(sinceDate)) return;
74190
- const lastModifiedDate = parseHttpDate(lastModified);
74191
- return isSuccess$1(lastModifiedDate) ? toEpochMillis(lastModifiedDate.success) > toEpochMillis(sinceDate.success) : void 0;
74192
- };
74193
- const matchesIfRange = (ifRange, etag) => {
74194
- const value = ifRange.trim();
74195
- return value.startsWith("\"") && value === etag;
74196
- };
74197
- const notModifiedHeaders = [
74198
- "cache-control",
74199
- "content-location",
74200
- "date",
74201
- "etag",
74202
- "expires",
74203
- "last-modified",
74204
- "vary"
74205
- ];
74206
- const notModifiedResponse = (response) => {
74207
- const headers = {};
74208
- for (const name of notModifiedHeaders) {
74209
- const value = response.headers[name];
74210
- if (value !== void 0) headers[name] = value;
74211
- }
74212
- return empty({
74213
- status: 304,
74214
- headers
74215
- });
74216
- };
74217
- const evaluateConditionalRequest = (request, response) => {
74218
- const etag = response.headers["etag"];
74219
- const lastModified = response.headers["last-modified"];
74220
- const ifMatch = request.headers["if-match"];
74221
- if (ifMatch !== void 0) {
74222
- if (!matchesIfMatch(ifMatch, etag)) return empty({ status: 412 });
74223
- } else {
74224
- const ifUnmodifiedSince = request.headers["if-unmodified-since"];
74225
- if (ifUnmodifiedSince !== void 0 && isModifiedSince(ifUnmodifiedSince, lastModified) === true) return empty({ status: 412 });
74226
- }
74227
- const ifNoneMatch = request.headers["if-none-match"];
74228
- if (ifNoneMatch !== void 0) return matchesIfNoneMatch(ifNoneMatch, etag) ? notModifiedResponse(response) : void 0;
74229
- const ifModifiedSince = request.headers["if-modified-since"];
74230
- if (ifModifiedSince !== void 0 && isModifiedSince(ifModifiedSince, lastModified) === false) return notModifiedResponse(response);
74231
- };
74232
- // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/process/CommandLine.js
74233
- /**
74234
- * Builds command lines, the single strings that a shell or a Windows program
74235
- * turns back into arguments, and argument lists from templates. It is
74236
- * unrelated to `effect/cli`, which parses the arguments of your own program.
74237
- *
74238
- * The rules depend on what parses the string, not on the platform that builds
74239
- * it, so `quote`, `join` and `display` take an explicit `format`:
74240
- *
74241
- * - `"posix"` (the default) for `sh`, `dash`, `bash` and `zsh`. Quoted output
74242
- * is also read the same way by `fish`.
74243
- * - `"powershell"` for PowerShell 7.3 or later.
74244
- * - `"windows"` for the Microsoft C runtime rules that most Windows programs
74245
- * use to split their command line.
74246
- *
74247
- * SSH sends one command line to the login shell of the remote account, so the
74248
- * format must match that shell. The remote shell must be a POSIX shell or
74249
- * PowerShell: Windows OpenSSH uses `cmd.exe` by default, which no format
74250
- * supports, so set its `DefaultShell` to PowerShell. Docker and Kubernetes exec
74251
- * take argument lists and need no command line at all.
74252
- *
74253
- * Arguments can be `Redacted` strings. `quote` and `join` include their values,
74254
- * because their output is meant to run, while `display` replaces them with
74255
- * `<redacted>`.
74256
- *
74257
- * @stability unstable
74258
- * @since 4.0.7
74259
- */
74260
- /**
74261
- * Error returned when a command line or a template cannot be built.
74262
- *
74263
- * **Details**
74264
- *
74265
- * - `NulCharacter`: an argument passed to {@link quote} or {@link join}
74266
- * contains a NUL character, which no command line can carry.
74267
- * - `InvalidArgument`: the format cannot carry an argument: a Windows program
74268
- * name with a double quote, or the argument `--%`, which PowerShell drops
74269
- * when it calls a native program.
74270
- * - `InvalidEscape`: template text ends with a backslash that escapes nothing,
74271
- * or contains an invalid JavaScript escape sequence.
74272
- * - `UnterminatedQuote`: a quoted section of a template is not closed.
74273
- * - `UnsupportedSyntax`: template text contains shell syntax that cannot work
74274
- * without a shell, such as operators, expansions, globs, comments or
74275
- * variable assignments, or an interpolated array is not a separate argument.
74276
- *
74277
- * Messages never include the input, which may contain secrets.
74278
- *
74279
- * @stability unstable
74280
- * @category errors
74281
- * @since 4.0.7
74282
- */
74283
- var CommandLineError = class extends (/*#__PURE__*/ TaggedError$1("CommandLineError")) {};
74284
- /**
74285
- * Renders a command for logs and error messages.
74286
- *
74287
- * **When to use**
74288
- *
74289
- * Use when you show a command to a person, for example in an error message,
74290
- * and secrets and control characters must not reach the output.
74291
- *
74292
- * **Details**
74293
- *
74294
- * - Quotes like {@link join}, so commands without control characters or
74295
- * secrets can be copied into a terminal of the given format.
74296
- * - Replaces `Redacted` arguments with `<redacted>`.
74297
- * - Writes control characters and Unicode line separators as escapes such as
74298
- * `\n` or `\u001b`, so output cannot move the cursor or inject terminal
74299
- * sequences.
74300
- * - Never fails: input that {@link join} rejects is rendered anyway.
74301
- *
74302
- * **Gotchas**
74303
- *
74304
- * The output is for reading only. It is not a reliable command line: escapes
74305
- * and `<redacted>` change what a shell would run.
74306
- *
74307
- * **Example** (Showing a command with a secret)
74308
- *
74309
- * ```ts import.meta.vitest
74310
- * import { Redacted } from "effect"
74311
- * import { CommandLine } from "effect/process"
74312
- *
74313
- * const token = Redacted.make("hunter2")
74314
- *
74315
- * CommandLine.display(["curl", "-H", token, "https://x.dev/a b"]) // => "curl -H <redacted> 'https://x.dev/a b'"
74316
- * ```
74317
- *
74318
- * @see {@link join} for building a command line to run
74319
- *
74320
- * @stability unstable
74321
- * @category encoding
74322
- * @since 4.0.7
74323
- */
74324
- const display = (words, options) => {
74325
- if (words.length === 0) return "";
74326
- const format = options?.format ?? "posix";
74327
- return joinWords(format, words.map((word, i) => isRedacted(word) ? "<redacted>" : escapeControlCharacters$1(quoteWord(format, word, i === 0))));
74328
- };
74329
- /**
74330
- * Builds an argument list from a template literal.
74331
- *
74332
- * **When to use**
74333
- *
74334
- * Use to write a command as it would look in a shell while keeping every
74335
- * interpolated value a literal argument.
74336
- *
74337
- * **Details**
74338
- *
74339
- * - The template text is split into words as a POSIX shell does: spaces,
74340
- * tabs and line breaks separate words, and quotes and backslash escapes are
74341
- * removed. A long command can span several lines.
74342
- * - Text that would need a shell fails with `UnsupportedSyntax`: operators
74343
- * (`| & ; < > ( )`), expansions (`$NAME`, `${...}`, `$(...)`, backticks, a
74344
- * leading `~`, braces such as `{a,b}`, and a leading `=` that `zsh`
74345
- * expands), globs (`* ? [`), comments (`#` at the start of a word), and a
74346
- * variable assignment in the program position. Quote such characters to
74347
- * pass them literally.
74348
- * - No shell runs, so a program such as `if` or `time` names an executable.
74349
- * - Each `${}` value is inserted literally, without splitting or quote
74350
- * processing. Next to other text or inside quotes, it becomes part of the
74351
- * surrounding argument.
74352
- * - An array adds one argument per element and must stand alone as a whole
74353
- * argument.
74354
- * - Numbers and booleans are converted with `String`.
74355
- * - An argument that contains a `Redacted` value becomes `Redacted` as a
74356
- * whole.
74357
- *
74358
- * **Gotchas**
74359
- *
74360
- * - An invalid JavaScript escape sequence in the text, such as `\u` without
74361
- * hex digits, fails with `InvalidEscape`. Use `String.raw` or a `${}` value
74362
- * for backslashes.
74363
- * - Neither the text nor the values are checked for NUL characters.
74364
- * {@link join} and the child process spawners reject them where they would
74365
- * truncate an argument.
74366
- *
74367
- * **Example** (Building arguments with interpolated values)
74368
- *
74369
- * ```ts import.meta.vitest
74370
- * import { Redacted, Result } from "effect"
74371
- * import { CommandLine } from "effect/process"
74372
- *
74373
- * const msg = "fix: handle $HOME"
74374
- * const files = ["a.ts", "b.ts"]
74375
- *
74376
- * CommandLine.template`git commit -m ${msg} ${files}` // => Result.succeed(["git", "commit", "-m", msg, ...files])
74377
- *
74378
- * const password = Redacted.make("hunter2")
74379
- * const words = Result.getOrThrow(CommandLine.template`psql "--password=${password}"`)
74380
- *
74381
- * CommandLine.display(words) // => "psql <redacted>"
74382
- * ```
74383
- *
74384
- * @stability unstable
74385
- * @category constructors
74386
- * @since 4.0.7
74387
- */
74388
- const template = (strings, ...expressions) => {
74389
- const index = strings.findIndex((text) => text === void 0);
74390
- if (index !== -1) return fail$12(new CommandLineError({
74391
- reason: "InvalidEscape",
74392
- message: `Template part ${index} contains an invalid escape sequence`
74393
- }));
74394
- return parseTemplate$1(strings, expressions);
74395
- };
74396
- const unwrap$1 = (item) => isRedacted(item) ? value$2(item) : String(item);
74397
- const toWord = (item) => isRedacted(item) ? item : String(item);
74398
- const reservedWords = /*#__PURE__*/ new Set([
74399
- "!",
74400
- "{",
74401
- "}",
74402
- "and",
74403
- "begin",
74404
- "case",
74405
- "coproc",
74406
- "do",
74407
- "done",
74408
- "elif",
74409
- "else",
74410
- "end",
74411
- "esac",
74412
- "fi",
74413
- "for",
74414
- "foreach",
74415
- "function",
74416
- "if",
74417
- "in",
74418
- "nocorrect",
74419
- "not",
74420
- "or",
74421
- "repeat",
74422
- "select",
74423
- "switch",
74424
- "then",
74425
- "time",
74426
- "until",
74427
- "while"
74428
- ]);
74429
- const quoteWord = (format, value, program) => {
74430
- switch (format) {
74431
- case "posix": return program && reservedWords.has(value) ? `'${value}'` : quotePosix(value);
74432
- case "powershell": return quotePowerShell(value);
74433
- case "windows": return program && !value.includes("\"") ? quoteWindowsProgram(value) : quoteWindowsArgument(value);
74434
- }
74435
- };
74436
- const joinWords = (format, quoted) => format === "powershell" ? `& ${quoted.join(" ")}` : quoted.join(" ");
74437
- const posixSafe = /^[A-Za-z0-9_@+:,./-]+$/;
74438
- const quotePosix = (value) => posixSafe.test(value) ? value : `'${value.replace(/['\\]/g, (char) => `'\\${char}'`)}'`;
74439
- const quotePowerShell = (value) => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, "$&$&")}'`;
74440
- const windowsNeedsQuotes = /[ \t\n\v"]/;
74441
- const quoteWindowsArgument = (value) => {
74442
- if (value.length > 0 && !windowsNeedsQuotes.test(value)) return value;
74443
- let out = "\"";
74444
- let backslashes = 0;
74445
- for (const char of value) if (char === "\\") backslashes++;
74446
- else if (char === "\"") {
74447
- out += "\\".repeat(backslashes * 2 + 1) + "\"";
74448
- backslashes = 0;
74449
- } else {
74450
- out += "\\".repeat(backslashes) + char;
74451
- backslashes = 0;
74452
- }
74453
- return out + "\\".repeat(backslashes * 2) + "\"";
74454
- };
74455
- const quoteWindowsProgram = (value) => value.length > 0 && !/[ \t]/.test(value) ? value : `"${value}"`;
74456
- const controlCharacters = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g;
74457
- const controlEscapes = {
74458
- "\n": "\\n",
74459
- "\r": "\\r",
74460
- " ": "\\t"
74461
- };
74462
- const escapeControlCharacters$1 = (value) => value.replace(controlCharacters, (char) => controlEscapes[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
74463
- const operators = "|&;<>()";
74464
- const globs = "*?[";
74465
- const expansionStart = /[A-Za-z_0-9{(@*#?$!'"-]/;
74466
- const quotedExpansionStart = /[A-Za-z_0-9{(@*#?$!-]/;
74467
- const assignmentName = /^[A-Za-z_][A-Za-z0-9_]*\+?$/;
74468
- const isBlank = (char) => char === " " || char === " " || char === "\n";
74469
- const unsupportedSyntax = (char, next, wordStart) => {
74470
- if (operators.includes(char)) return `The operator "${char}" needs a shell`;
74471
- if (char === "`") return "Command substitution needs a shell";
74472
- if (char === "$" && next !== void 0 && expansionStart.test(next)) return `The expansion "$${next}" needs a shell`;
74473
- if (globs.includes(char)) return `The glob character "${char}" needs a shell`;
74474
- if (!wordStart) return void 0;
74475
- if (char === "#") return "A comment needs a shell";
74476
- if (char === "~") return "Tilde expansion needs a shell";
74477
- if (char === "=" && next !== void 0 && !isBlank(next)) return "A leading \"=\" is expanded by zsh";
74478
- };
74479
- const parseTemplate$1 = (texts, values) => {
74480
- const words = [];
74481
- let word = [];
74482
- let plain = true;
74483
- let braceDepth = 0;
74484
- let quote = void 0;
74485
- let quotePart = 0;
74486
- let part = 0;
74487
- const error = (reason, message, at = part) => fail$12(new CommandLineError({
74488
- reason,
74489
- message: `${message} in template part ${at}`
74490
- }));
74491
- const endWord = () => {
74492
- if (word.length === 0) return;
74493
- const value = word.map(unwrap$1).join("");
74494
- words.push(word.length === 1 && isRedacted(word[0]) ? word[0] : word.some(isRedacted) ? make$65(value) : value);
74495
- word = [];
74496
- plain = true;
74497
- braceDepth = 0;
74498
- };
74499
- const scan = (text) => {
74500
- for (let i = 0; i < text.length; i++) {
74501
- const char = text[i];
74502
- const next = text[i + 1];
74503
- if (quote === "'") {
74504
- if (char === "'") quote = void 0;
74505
- else word.push(char);
74506
- } else if (quote === "\"") {
74507
- if (char === "\"") quote = void 0;
74508
- else if (char === "\\" && next !== void 0 && "$`\"\\\n".includes(next)) {
74509
- if (next !== "\n") word.push(next);
74510
- i++;
74511
- } else if (char === "`") return error("UnsupportedSyntax", "Command substitution needs a shell");
74512
- else if (char === "$" && next !== void 0 && quotedExpansionStart.test(next)) return error("UnsupportedSyntax", `The expansion "$${next}" needs a shell`);
74513
- else word.push(char);
74514
- } else if (isBlank(char)) endWord();
74515
- else if (char === "\\") {
74516
- if (next === void 0) return error("InvalidEscape", "A trailing backslash escapes nothing");
74517
- if (next !== "\n") {
74518
- word.push(next);
74519
- plain = false;
74520
- }
74521
- i++;
74522
- } else if (char === "'" || char === "\"") {
74523
- quote = char;
74524
- quotePart = part;
74525
- word.push("");
74526
- plain = false;
74527
- } else {
74528
- const unsupported = unsupportedSyntax(char, next, word.length === 0);
74529
- if (unsupported !== void 0) return error("UnsupportedSyntax", unsupported);
74530
- if (char === "{") braceDepth++;
74531
- else if (char === "}") {
74532
- if (braceDepth > 0) braceDepth--;
74533
- } else if (braceDepth > 0 && (char === "," || char === "." && next === ".")) return error("UnsupportedSyntax", "Brace expansion needs a shell");
74534
- else if (char === "=" && words.length === 0 && plain && assignmentName.test(word.join(""))) return error("UnsupportedSyntax", "A variable assignment needs a shell");
74535
- word.push(char);
74536
- }
74537
- }
74538
- };
74539
- for (; part < texts.length; part++) {
74540
- const failure = scan(texts[part]);
74541
- if (failure !== void 0) return failure;
74542
- if (part === values.length) break;
74543
- const expression = values[part];
74544
- if (Array.isArray(expression)) {
74545
- const after = texts[part + 1][0];
74546
- if (word.length > 0 || (after === void 0 ? part + 1 < values.length : !isBlank(after))) return error("UnsupportedSyntax", "An interpolated array must be a separate argument");
74547
- for (const item of expression) words.push(toWord(item));
74548
- } else {
74549
- word.push(toWord(expression));
74550
- plain = false;
74551
- }
74552
- }
74553
- if (quote !== void 0) return error("UnterminatedQuote", "The quote is not closed", quotePart);
74554
- endWord();
74555
- return succeed$10(words);
74556
- };
74557
- // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/process/ChildProcess.js
74558
- /**
74559
- * Describes child processes before they are started.
74560
- *
74561
- * A `Command` stores the executable, arguments, environment, standard streams,
74562
- * working directory, and other process options. Commands can also be piped
74563
- * together. A command is an `Effect`; running it asks the
74564
- * `ChildProcessSpawner` service to start the process and returns a
74565
- * `ChildProcessHandle`.
74566
- *
74567
- * @stability unstable
74568
- * @since 4.0.0
74569
- */
74570
- const TypeId$5 = "~effect/process/ChildProcess";
74571
- const Proto$3 = {
74572
- .../*#__PURE__*/ Prototype({
74573
- label: "Command",
74574
- evaluate(fiber) {
74575
- return getUnsafe$2(fiber.context, ChildProcessSpawner).spawn(this);
74576
- }
74577
- }),
74578
- [TypeId$5]: TypeId$5
74579
- };
74580
- const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$3), {
74581
- _tag: "StandardCommand",
74582
- command,
74583
- args,
74584
- options
74585
- });
74586
- /**
74587
- * Create a command from a template literal, options + template, or array form.
74588
- *
74589
- * **Details**
74590
- *
74591
- * This function supports three calling conventions:
74592
- * 1. Template literal: `make\`npm run build\``
74593
- * 2. Options + template literal: `make({ cwd: "/app" })\`npm run build\``
74594
- * 3. Array form: `make("npm", ["run", "build"], options?)`
74595
- *
74596
- * Templates are split with `CommandLine.template`: quotes group words, each
74597
- * `${}` value is one literal argument, and an argument that contains a
74598
- * `Redacted` value stays `Redacted`. Arguments in the array form can be
74599
- * `Redacted` too.
74600
- *
74601
- * With the `shell` option, the template text is the shell script and is kept
74602
- * as written.
74603
- *
74604
- * **Gotchas**
74605
- *
74606
- * - A template is parsed when `make` is called. Shell syntax such as `|`,
74607
- * `$HOME`, `*` or `~` throws a `CommandLine.CommandLineError`: quote it, or
74608
- * pass the value with `${}`.
74609
- * - A template with the `shell` option cannot contain `${}` values, because
74610
- * their quoting depends on the shell. Build the script with
74611
- * `CommandLine.quote` and pass it as a string.
74612
- * - The program name, the first word, cannot be `Redacted`.
74613
- * - A NUL character in the command, an argument or an `env` value fails with
74614
- * a `BadArgument` error when the command is spawned.
74615
- *
74616
- * **Example** (Creating commands)
74617
- *
74618
- * ```ts import.meta.vitest
74619
- * import { ChildProcess } from "effect/process"
74620
- *
74621
- * // Template literal form; quotes group words
74622
- * const cmd1 = ChildProcess.make`echo "hello world"`
74623
- *
74624
- * // With options
74625
- * const cmd2 = ChildProcess.make({ cwd: "/tmp" })`ls -la`
74626
- *
74627
- * // Array form
74628
- * const cmd3 = ChildProcess.make("git", ["status"])
74629
- *
74630
- * const result = [cmd1.args[0], cmd2.options.cwd, cmd3.args[0]] // => ["hello world", "/tmp", "status"]
74631
- * ```
74632
- *
74633
- * @stability unstable
74634
- * @category constructors
74635
- * @since 4.0.0
74636
- */
74637
- const make$11 = function make(...args) {
74002
+ const make$12 = function make(...args) {
74638
74003
  if (isTemplateString(args[0])) {
74639
74004
  const [templates, ...expressions] = args;
74640
74005
  const [command, cmdArgs] = parseTemplate(templates, expressions);
@@ -75167,7 +74532,7 @@ const taskkill = (childProcess, onExit = () => {}) => {
75167
74532
  * @category layers
75168
74533
  * @since 4.0.0
75169
74534
  */
75170
- const layer$14 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(function* () {
74535
+ const layer$16 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(function* () {
75171
74536
  const fs = yield* FileSystem;
75172
74537
  const path = yield* Path$1;
75173
74538
  const resolveWorkingDirectory = fnUntraced(function* (options) {
@@ -75529,7 +74894,7 @@ const layer$14 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
75529
74894
  const stdinConfig = resolveStdinOption(command.options);
75530
74895
  const sourceStream = unwrap$3(succeed$5(getSourceStream(handles[handles.length - 1], options.from)));
75531
74896
  const toOption = options.to ?? "stdin";
75532
- if (toOption === "stdin") handles.push(yield* spawnCommand(make$11(command.command, command.args, {
74897
+ if (toOption === "stdin") handles.push(yield* spawnCommand(make$12(command.command, command.args, {
75533
74898
  ...command.options,
75534
74899
  stdin: {
75535
74900
  ...stdinConfig,
@@ -75549,14 +74914,14 @@ const layer$14 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
75549
74914
  type: "input",
75550
74915
  stream: sourceStream
75551
74916
  };
75552
- handles.push(yield* spawnCommand(make$11(command.command, command.args, {
74917
+ handles.push(yield* spawnCommand(make$12(command.command, command.args, {
75553
74918
  ...command.options,
75554
74919
  additionalFds: {
75555
74920
  ...existingFds,
75556
74921
  [fdName$1]: fdConfig
75557
74922
  }
75558
74923
  })));
75559
- } else handles.push(yield* spawnCommand(make$11(command.command, command.args, {
74924
+ } else handles.push(yield* spawnCommand(make$12(command.command, command.args, {
75560
74925
  ...command.options,
75561
74926
  stdin: {
75562
74927
  ...stdinConfig,
@@ -79504,6 +78869,79 @@ require_sender();
79504
78869
  require_subprotocol();
79505
78870
  require_websocket();
79506
78871
  var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
78872
+ /**
78873
+ * Service that derives bytes from a secret.
78874
+ *
78875
+ * **Example** (Deriving a key with HKDF)
78876
+ *
78877
+ * ```ts import.meta.vitest
78878
+ * import { Effect } from "effect"
78879
+ * import { Kdf } from "effect/crypto"
78880
+ *
78881
+ * const program = Effect.gen(function*() {
78882
+ * const kdf = yield* Kdf.Kdf
78883
+ * return yield* kdf.derive(Kdf.hkdfSha256, new Uint8Array(32), {
78884
+ * salt: new Uint8Array(16),
78885
+ * info: new TextEncoder().encode("encryption"),
78886
+ * length: 32
78887
+ * })
78888
+ * })
78889
+ *
78890
+ * const bytes = await Effect.runPromise(program.pipe(Effect.provide(Kdf.layerWebCrypto)))
78891
+ * bytes.length // => 32
78892
+ * ```
78893
+ *
78894
+ * @stability unstable
78895
+ * @category services
78896
+ * @since 4.0.0
78897
+ */
78898
+ var Kdf = class extends (/*#__PURE__*/ Service$2()("effect/crypto/Kdf")) {};
78899
+ const invalidArgument$1 = (description) => fail$6("Kdf", "derive", new InvalidArgument$1({ description }));
78900
+ const isIntegerIn$1 = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;
78901
+ const checkArguments = (algorithm, options) => {
78902
+ if (algorithm._tag !== "Hkdf" && options.info !== void 0) return invalidArgument$1("info only applies to HKDF");
78903
+ if (algorithm._tag === "Argon2id") return void 0;
78904
+ if (algorithm.hash.name === "MD5") return invalidArgument$1(`${algorithm._tag} needs a SHA hash, not MD5`);
78905
+ if (algorithm._tag === "Hkdf") {
78906
+ const maxLength = 255 * algorithm.hash.outputLength;
78907
+ return isIntegerIn$1(options.length, 1, maxLength) ? void 0 : invalidArgument$1(`length must be between 1 and ${maxLength} bytes for ${algorithm.name}`);
78908
+ }
78909
+ if (!isIntegerIn$1(algorithm.iterations, 1, 2147483647)) return invalidArgument$1("iterations must be between 1 and 2^31 - 1");
78910
+ return isIntegerIn$1(options.length, 1, 536870911) ? void 0 : invalidArgument$1("length must be between 1 and 2^29 - 1 bytes");
78911
+ };
78912
+ const webCryptoParams = (algorithm, options) => algorithm._tag === "Hkdf" ? {
78913
+ name: "HKDF",
78914
+ hash: algorithm.hash.name,
78915
+ salt: options.salt,
78916
+ info: options.info ?? /* @__PURE__ */ new Uint8Array()
78917
+ } : {
78918
+ name: "PBKDF2",
78919
+ hash: algorithm.hash.name,
78920
+ salt: options.salt,
78921
+ iterations: algorithm.iterations
78922
+ };
78923
+ /**
78924
+ * Layer that provides `Kdf` on the `WebCrypto` reference.
78925
+ *
78926
+ * **Details**
78927
+ *
78928
+ * HKDF and PBKDF2 run on `crypto.subtle`, off the event loop where the runtime
78929
+ * supports it. Argon2id fails with an `Unsupported` reason.
78930
+ *
78931
+ * @stability unstable
78932
+ * @category layers
78933
+ * @since 4.0.0
78934
+ */
78935
+ const layerWebCrypto = /*#__PURE__*/ effect(Kdf, /*#__PURE__*/ WebCrypto.use((crypto) => succeed$5(Kdf.of({ derive: (algorithm, secret, options) => suspend$2(() => {
78936
+ const failure = checkArguments(algorithm, options);
78937
+ if (failure !== void 0) return failure;
78938
+ if (algorithm._tag === "Argon2id") return fail$6("Kdf", "derive", new Unsupported({ description: "Kdf.layerWebCrypto does not provide argon2id" }));
78939
+ const name = algorithm._tag === "Hkdf" ? "HKDF" : "PBKDF2";
78940
+ return run$6("Kdf", "derive", algorithm.name, crypto, async (subtle) => {
78941
+ const handle = await subtle.importKey("raw", secret, name, false, ["deriveBits"]);
78942
+ return new Uint8Array(await subtle.deriveBits(webCryptoParams(algorithm, options), handle, options.length * 8));
78943
+ });
78944
+ }) }))));
79507
78945
  // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
79508
78946
  /**
79509
78947
  * Node.js layers for the `effect/crypto` modules, also used by Bun.
@@ -79667,7 +79105,7 @@ const concat = (parts) => {
79667
79105
  * @category layers
79668
79106
  * @since 4.0.0
79669
79107
  */
79670
- const layer$13 = /*#__PURE__*/ mergeAll$1(layerSecureRandom, layerDigest, layerMac, layerKdf, /* @__PURE__ */ layerWebCryptoWith$1(NodeCrypto.getCiphers().includes("chacha20-poly1305") ? { implementations: { chacha20Poly1305: {
79108
+ const layer$15 = /*#__PURE__*/ mergeAll$1(layerSecureRandom, layerDigest, layerMac, layerKdf, /* @__PURE__ */ layerWebCryptoWith$1(NodeCrypto.getCiphers().includes("chacha20-poly1305") ? { implementations: { chacha20Poly1305: {
79671
79109
  encrypt: (key, nonce, plaintext, aad) => {
79672
79110
  const cipher = NodeCrypto.createCipheriv("chacha20-poly1305", key, nonce, { authTagLength: 16 });
79673
79111
  cipher.setAAD(aad);
@@ -80131,7 +79569,7 @@ const makeFileSystem = /*#__PURE__*/ map$5(/*#__PURE__*/ serviceOption(WatchBack
80131
79569
  * @category layers
80132
79570
  * @since 4.0.0
80133
79571
  */
80134
- const layer$11 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
79572
+ const layer$13 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
80135
79573
  // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_redis@6.3.1/node_modules/@effect/platform-node/dist/NodeHttpIncomingMessage.js
80136
79574
  /**
80137
79575
  * Adapter base for exposing Node `http.IncomingMessage` values as Effect HTTP
@@ -80241,6 +79679,199 @@ var NodeHttpIncomingMessage = class extends Class$2 {
80241
79679
  return this.arrayBufferEffect;
80242
79680
  }
80243
79681
  };
79682
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/FetchHttpClient.js
79683
+ /**
79684
+ * Fetch-based implementation of the Effect HTTP client service.
79685
+ *
79686
+ * This module provides an `HttpClient` layer that executes requests through a
79687
+ * Web Fetch API implementation. It is the transport to use in browsers, edge
79688
+ * runtimes, and Node.js environments where `globalThis.fetch` is available, or
79689
+ * anywhere a compatible fetch function can be supplied.
79690
+ *
79691
+ * Requests with an `Upgrade` header fail with `TransportError` before anything
79692
+ * is sent because fetch cannot hand over the connection.
79693
+ *
79694
+ * @stability unstable
79695
+ * @since 4.0.0
79696
+ */
79697
+ /**
79698
+ * Context reference for the `fetch` implementation used by the fetch-based HTTP client.
79699
+ *
79700
+ * **Details**
79701
+ *
79702
+ * Defaults to `globalThis.fetch`.
79703
+ *
79704
+ * @stability unstable
79705
+ * @category services
79706
+ * @since 4.0.0
79707
+ */
79708
+ const Fetch = /*#__PURE__*/ Reference("effect/http/FetchHttpClient/Fetch", { defaultValue: () => globalThis.fetch });
79709
+ /**
79710
+ * Context reference controlling stream bodies when the runtime does not support streaming requests.
79711
+ *
79712
+ * **Details**
79713
+ *
79714
+ * Defaults to `"error"`, which fails with an `EncodeError` without sending the
79715
+ * request. Set to `"buffer"` to collect the entire stream in memory and send it
79716
+ * as a single body instead. Runtimes with streaming support always send the stream.
79717
+ *
79718
+ * **Gotchas**
79719
+ *
79720
+ * Buffering keeps the entire upload in memory and can exhaust memory for large
79721
+ * or unbounded uploads. Support is detected once, on the first stream body sent,
79722
+ * using the global `Request` implementation even when a custom `Fetch` is provided.
79723
+ *
79724
+ * @stability unstable
79725
+ * @category services
79726
+ * @since 4.0.0
79727
+ */
79728
+ const StreamBodyFallback = /*#__PURE__*/ Reference("effect/http/FetchHttpClient/StreamBodyFallback", { defaultValue: () => "error" });
79729
+ /**
79730
+ * Service that contains default fetch options for the fetch-based HTTP client.
79731
+ *
79732
+ * **When to use**
79733
+ *
79734
+ * Use to provide default credentials, cache, redirect, integrity, or other
79735
+ * fetch options for outgoing HTTP requests.
79736
+ *
79737
+ * **Details**
79738
+ *
79739
+ * Request-specific method, headers, body, and abort signal are supplied by the client when a request is executed.
79740
+ *
79741
+ * @see {@link HttpClient.followRedirects} for following redirects in the client, which needs `{ redirect: "manual" }` here
79742
+ *
79743
+ * @stability unstable
79744
+ * @category services
79745
+ * @since 4.0.0
79746
+ */
79747
+ var RequestInit = class extends (/*#__PURE__*/ Service$2()("effect/http/FetchHttpClient/RequestInit")) {};
79748
+ let supportsStreamBody;
79749
+ const detectStreamBodySupport = () => {
79750
+ try {
79751
+ let duplexAccessed = false;
79752
+ const body = new ReadableStream();
79753
+ const request = new Request("https://example.com", {
79754
+ method: "POST",
79755
+ body,
79756
+ get duplex() {
79757
+ duplexAccessed = true;
79758
+ return "half";
79759
+ }
79760
+ });
79761
+ return (duplexAccessed || request.body === body) && !request.headers.has("Content-Type");
79762
+ } catch {
79763
+ return false;
79764
+ }
79765
+ };
79766
+ /**
79767
+ * Layer that provides an `HttpClient` implementation backed by the configured
79768
+ * `Fetch` function.
79769
+ *
79770
+ * **When to use**
79771
+ *
79772
+ * Use when an Effect program should execute `HttpClient` requests through the
79773
+ * platform `fetch` implementation, especially in browser, edge, or Node.js
79774
+ * runtimes with `globalThis.fetch`.
79775
+ *
79776
+ * **Details**
79777
+ *
79778
+ * The layer uses the current `Fetch` reference and optional `RequestInit`
79779
+ * service for each request. Request-specific method, headers, body, and abort
79780
+ * signal are supplied by the client and override matching `RequestInit` fields.
79781
+ *
79782
+ * **Gotchas**
79783
+ *
79784
+ * Fetch behavior comes from the runtime's implementation, so CORS, cookies,
79785
+ * redirects, abort handling, and streaming support can vary by platform.
79786
+ * `fetch` follows redirects itself by default, so `HttpClient.followRedirects`
79787
+ * has no effect unless `RequestInit` sets `redirect: "manual"`. Trace
79788
+ * propagation is on by default, and a browser preflight fails unless the
79789
+ * target allows `b3` and `traceparent`. Stream request bodies are sent as Web
79790
+ * streams with `duplex: "half"` when the runtime supports it; see
79791
+ * `StreamBodyFallback` for the unsupported case. Any `content-length` header is
79792
+ * removed before calling `fetch`. Chrome passes the support check but rejects
79793
+ * streaming uploads over HTTP/1.1, which surfaces as a `TransportError`, and
79794
+ * browsers only deliver the response after the entire request body has been sent.
79795
+ *
79796
+ * @see {@link Fetch} for supplying the fetch implementation used by this layer
79797
+ * @see {@link RequestInit} for default `RequestInit` options applied before request-specific fields
79798
+ * @see {@link StreamBodyFallback} for opting into buffering on unsupported runtimes
79799
+ * @see {@link HttpClient.TracerPropagationEnabled} for leaving `b3` and `traceparent` off a browser request
79800
+ *
79801
+ * @stability unstable
79802
+ * @category layers
79803
+ * @since 4.0.0
79804
+ */
79805
+ const layer$12 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$5(/* @__PURE__ */ make$34((request, url, signal, fiber) => {
79806
+ if (request.headers.upgrade !== void 0) return fail$7(new HttpClientError({ reason: new TransportError({
79807
+ request,
79808
+ description: "fetch cannot send an HTTP upgrade request"
79809
+ }) }));
79810
+ const fetch = fiber.getRef(Fetch);
79811
+ const options = getOrUndefined(fiber.context, RequestInit) ?? {};
79812
+ let headers = options.headers ? merge$2(fromInput$1(options.headers), request.headers) : request.headers;
79813
+ if (headers["content-length"]) headers = remove$1(headers, "content-length");
79814
+ let uploadController;
79815
+ const stopUpload = sync(() => uploadController?.abort());
79816
+ const send = (body) => map$5(tryPromise({
79817
+ try: () => fetch(url, {
79818
+ ...options,
79819
+ method: request.method,
79820
+ headers,
79821
+ body,
79822
+ duplex: typeof ReadableStream !== "undefined" && body instanceof ReadableStream ? "half" : void 0,
79823
+ signal: uploadController ? AbortSignal.any([signal, uploadController.signal]) : signal
79824
+ }),
79825
+ catch: (cause) => new HttpClientError({ reason: new TransportError({
79826
+ request,
79827
+ cause
79828
+ }) })
79829
+ }), (response) => {
79830
+ const original = fromWeb(request, response);
79831
+ if (!uploadController) return original;
79832
+ if (response.body === null) uploadController.abort();
79833
+ return Object.create(original, {
79834
+ ...Object.fromEntries([
79835
+ "arrayBuffer",
79836
+ "text",
79837
+ "json",
79838
+ "formData",
79839
+ "urlParamsBody"
79840
+ ].map((key) => [key, { get: () => ensuring$2(original[key], stopUpload) }])),
79841
+ stream: { get: () => ensuring(original.stream, stopUpload) }
79842
+ });
79843
+ }).pipe(onError(() => stopUpload));
79844
+ switch (request.body._tag) {
79845
+ case "Raw":
79846
+ case "Uint8Array": return send(request.body.body);
79847
+ case "FormData": return send(request.body.formData);
79848
+ case "Stream":
79849
+ supportsStreamBody ??= detectStreamBodySupport();
79850
+ if (supportsStreamBody) {
79851
+ uploadController = new AbortController();
79852
+ const uploadSignal = AbortSignal.any([signal, uploadController.signal]);
79853
+ const stopped = callback$1((resume) => {
79854
+ const onAbort = () => resume(interrupt$1);
79855
+ if (uploadSignal.aborted) {
79856
+ onAbort();
79857
+ return;
79858
+ }
79859
+ uploadSignal.addEventListener("abort", onAbort, { once: true });
79860
+ return sync(() => uploadSignal.removeEventListener("abort", onAbort));
79861
+ });
79862
+ return flatMap$3(toReadableStreamEffect(interruptWhen(request.body.stream, stopped)), send);
79863
+ }
79864
+ if (fiber.getRef(StreamBodyFallback) === "error") return fail$7(new HttpClientError({ reason: new EncodeError({
79865
+ request,
79866
+ description: "Streaming request bodies are not supported in this runtime"
79867
+ }) }));
79868
+ return mkArrayBuffer(request.body.stream).pipe(mapError$2((cause) => new HttpClientError({ reason: new EncodeError({
79869
+ request,
79870
+ cause
79871
+ }) })), flatMap$3(send));
79872
+ }
79873
+ return send(void 0);
79874
+ })));
80244
79875
  // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_redis@6.3.1/node_modules/@effect/platform-node/dist/internal/upgrade.js
80245
79876
  /**
80246
79877
  * Wraps an upgraded connection. Acquiring the reader runs `open`; releasing
@@ -80412,7 +80043,7 @@ const compress = (data, algorithm, options) => callback$1((resume) => {
80412
80043
  * @category constructors
80413
80044
  * @since 4.0.0
80414
80045
  */
80415
- const make$9 = (fallback) => ({
80046
+ const make$10 = (fallback) => ({
80416
80047
  algorithms: fallback.algorithms,
80417
80048
  compressResponse(response, algorithm, options) {
80418
80049
  const body = response.body;
@@ -80498,9 +80129,9 @@ const compressedBody = (response, body) => removeHeader(setBody(response, body),
80498
80129
  * @category constructors
80499
80130
  * @since 4.0.0
80500
80131
  */
80501
- const make$8 = /*#__PURE__*/ make$26({
80132
+ const make$9 = /*#__PURE__*/ make$26({
80502
80133
  platform: "node",
80503
- compression: /* @__PURE__ */ make$9({
80134
+ compression: /* @__PURE__ */ make$10({
80504
80135
  algorithms,
80505
80136
  compressResponse(response, algorithm, options) {
80506
80137
  const body = response.body;
@@ -80555,7 +80186,7 @@ const make$8 = /*#__PURE__*/ make$26({
80555
80186
  * @category layers
80556
80187
  * @since 4.0.0
80557
80188
  */
80558
- const layer$10 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$8), /*#__PURE__*/ provide$2(layer$11), /*#__PURE__*/ provide$2(layer$20));
80189
+ const layer$11 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$9), /*#__PURE__*/ provide$2(layer$13), /*#__PURE__*/ provide$2(layer$20));
80559
80190
  // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_redis@6.3.1/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
80560
80191
  /**
80561
80192
  * Node.js streams adapter for the low-level multipart parser.
@@ -80656,7 +80287,7 @@ var MultipartStream = class extends Duplex {
80656
80287
  * @category constructors
80657
80288
  * @since 4.0.0
80658
80289
  */
80659
- const make$7 = (config) => new MultipartStream(config);
80290
+ const make$8 = (config) => new MultipartStream(config);
80660
80291
  /**
80661
80292
  * A readable stream containing a parsed multipart file.
80662
80293
  *
@@ -80704,7 +80335,7 @@ var FileStream = class extends Readable {
80704
80335
  */
80705
80336
  const stream = (source, headers) => makeConfig(headers).pipe(map$5((config) => fromReadable({
80706
80337
  evaluate() {
80707
- const parser = make$7(config);
80338
+ const parser = make$8(config);
80708
80339
  const cleanup = finished(source, {
80709
80340
  readable: true,
80710
80341
  writable: false
@@ -80857,7 +80488,7 @@ const fileUrlOps = (windows) => ({
80857
80488
  * @category layers
80858
80489
  * @since 4.0.0
80859
80490
  */
80860
- const layer$8 = /* @__PURE__ */ succeed$6(Path$1)(/*#__PURE__*/ make$50({
80491
+ const layer$9 = /* @__PURE__ */ succeed$6(Path$1)(/*#__PURE__*/ make$50({
80861
80492
  ...Path,
80862
80493
  .../*#__PURE__*/ fileUrlOps(void 0)
80863
80494
  }));
@@ -80881,7 +80512,7 @@ const layer$8 = /* @__PURE__ */ succeed$6(Path$1)(/*#__PURE__*/ make$50({
80881
80512
  * @category layers
80882
80513
  * @since 4.0.0
80883
80514
  */
80884
- const layer$6 = /* @__PURE__ */ succeed$6(Stdio, /*#__PURE__*/ make$42({
80515
+ const layer$7 = /* @__PURE__ */ succeed$6(Stdio, /*#__PURE__*/ make$42({
80885
80516
  args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
80886
80517
  stdinIsTerminal: /*#__PURE__*/ sync(() => process.stdin.isTTY === true),
80887
80518
  stdoutIsTerminal: /*#__PURE__*/ sync(() => process.stdout.isTTY === true),
@@ -80925,7 +80556,7 @@ const layer$6 = /* @__PURE__ */ succeed$6(Stdio, /*#__PURE__*/ make$42({
80925
80556
  * @category layers
80926
80557
  * @since 4.0.0
80927
80558
  */
80928
- const layer$5 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
80559
+ const layer$6 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
80929
80560
  const stdin = process.stdin;
80930
80561
  const stdout = process.stdout;
80931
80562
  const lines = yield* make$74();
@@ -81057,7 +80688,7 @@ function defaultShouldQuit(input) {
81057
80688
  * @category layers
81058
80689
  * @since 4.0.0
81059
80690
  */
81060
- const layer$3 = /*#__PURE__*/ provideMerge(layer$14, /*#__PURE__*/ mergeAll$1(layer$11, layer$8, layer$6, layer$5));
80691
+ const layer$4 = /*#__PURE__*/ provideMerge(layer$16, /*#__PURE__*/ mergeAll$1(layer$13, layer$9, layer$7, layer$6));
81061
80692
  // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_redis@6.3.1/node_modules/@effect/platform-node/dist/NodeHttpServer.js
81062
80693
  /**
81063
80694
  * Node.js implementation of the Effect `HttpServer`.
@@ -81135,7 +80766,7 @@ const layer$3 = /*#__PURE__*/ provideMerge(layer$14, /*#__PURE__*/ mergeAll$1(la
81135
80766
  * @category constructors
81136
80767
  * @since 4.0.0
81137
80768
  */
81138
- const make$5 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
80769
+ const make$6 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
81139
80770
  const scope$4 = yield* scope;
81140
80771
  const server = evaluate();
81141
80772
  let closing = false;
@@ -81520,7 +81151,7 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
81520
81151
  * @category layers
81521
81152
  * @since 4.0.0
81522
81153
  */
81523
- const layerHttpServices = /*#__PURE__*/ mergeAll$1(layer$10, layerWeak, layer$3);
81154
+ const layerHttpServices = /*#__PURE__*/ mergeAll$1(layer$11, layerWeak, layer$4);
81524
81155
  /**
81525
81156
  * Provides a Node `HttpServer` together with the Node HTTP platform, ETag,
81526
81157
  * and core Node platform services, reading the listen and shutdown options from
@@ -81530,7 +81161,7 @@ const layerHttpServices = /*#__PURE__*/ mergeAll$1(layer$10, layerWeak, layer$3)
81530
81161
  * @category layers
81531
81162
  * @since 4.0.0
81532
81163
  */
81533
- const layerConfig = (evaluate, options) => mergeAll$1(effect(HttpServer)(flatMap$3(unwrap$2(options), (options) => make$5(evaluate, options))), layerHttpServices);
81164
+ const layerConfig = (evaluate, options) => mergeAll$1(effect(HttpServer)(flatMap$3(unwrap$2(options), (options) => make$6(evaluate, options))), layerHttpServices);
81534
81165
  http.createServer;
81535
81166
  const closeCode = (exit) => isSuccess(exit) ? 1e3 : hasInterruptsOnly(exit.cause) ? 1001 : 1011;
81536
81167
  const upgradedResponse = /*#__PURE__*/ empty({ status: 101 });
@@ -85141,7 +84772,7 @@ const Formatter = /*#__PURE__*/ Reference("effect/cli/CliOutput", { defaultValue
85141
84772
  */
85142
84773
  const defaultPresenter = { present: /*#__PURE__*/ fnUntraced(function* (event) {
85143
84774
  const context$2 = yield* context();
85144
- const formatter = getOrUndefined(context$2, Formatter) ?? defaultFormatter({ colors: get$11(context$2, TerminalCapabilities).canColor });
84775
+ const formatter = getOrUndefined(context$2, Formatter) ?? defaultFormatter({ colors: get$10(context$2, TerminalCapabilities).canColor });
85145
84776
  switch (event._tag) {
85146
84777
  case "Help": return yield* log(formatter.formatHelpDoc(event.helpDoc));
85147
84778
  case "InvalidInvocation":
@@ -87536,7 +87167,7 @@ const defaults = { builtIns: BuiltIns };
87536
87167
  *
87537
87168
  * @internal
87538
87169
  */
87539
- const resolveFormatter = /*#__PURE__*/ contextWith((context) => succeed$5(getOrUndefined(context, Formatter) ?? defaultFormatter({ colors: get$11(context, TerminalCapabilities).canColor })));
87170
+ const resolveFormatter = /*#__PURE__*/ contextWith((context) => succeed$5(getOrUndefined(context, Formatter) ?? defaultFormatter({ colors: get$10(context, TerminalCapabilities).canColor })));
87540
87171
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/cli/internal/lexer.js
87541
87172
  /**
87542
87173
  * @internal
@@ -88457,7 +88088,7 @@ const isCommand = (u) => hasProperty(u, TypeId$1);
88457
88088
  * @category constructors
88458
88089
  * @since 4.0.0
88459
88090
  */
88460
- const make$4 = (name, config, handler) => {
88091
+ const make$5 = (name, config, handler) => {
88461
88092
  const parsedConfig = parseConfig(config ?? {});
88462
88093
  return makeCommand({
88463
88094
  name,
@@ -88907,115 +88538,458 @@ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => f
88907
88538
  * yield* runCommand(["--name", "Alice", "--count", "2"])
88908
88539
  * })
88909
88540
  *
88910
- * await Effect.runPromise(testProgram.pipe(Effect.provide(CliTestLayer)))
88911
- * output // => ["Hello, Alice!", "Hello, Alice!"]
88541
+ * await Effect.runPromise(testProgram.pipe(Effect.provide(CliTestLayer)))
88542
+ * output // => ["Hello, Alice!", "Hello, Alice!"]
88543
+ * ```
88544
+ *
88545
+ * @stability unstable
88546
+ * @category running
88547
+ * @since 4.0.0
88548
+ */
88549
+ const runWith = (command, config) => {
88550
+ const commandImpl = toImpl(command);
88551
+ return fnUntraced(function* (args) {
88552
+ const { builtIns } = yield* CliConfig;
88553
+ const { tokens, trailingOperands } = lex(args);
88554
+ const allFlags = getGlobalFlagsForCommandTree(command, builtIns);
88555
+ const allFlagParams = allFlags.flatMap((f) => extractSingleParams(f.flag));
88556
+ const globalRegistry = createFlagRegistry(allFlagParams.filter(isFlagParam));
88557
+ const { flagMap, remainder, errors: globalFlagErrors } = consumeGlobalFlags(tokens, command, globalRegistry);
88558
+ const emptyArgs = {
88559
+ flags: flagMap,
88560
+ arguments: []
88561
+ };
88562
+ const parsedArgs = yield* parseArgs({
88563
+ tokens: remainder,
88564
+ trailingOperands
88565
+ }, command);
88566
+ const commandPath = [command.name, ...getCommandPath(parsedArgs)];
88567
+ const toShowHelp = mapError$2((error) => error._tag === "ShowHelp" ? error : new ShowHelp({
88568
+ commandPath,
88569
+ errors: [error]
88570
+ }));
88571
+ const handlerCtx = {
88572
+ builtIns,
88573
+ command,
88574
+ commandPath,
88575
+ version: config.version
88576
+ };
88577
+ const activeFlags = getGlobalFlagsForCommandPath(command, commandPath, builtIns);
88578
+ const outOfScopeErrors = getOutOfScopeGlobalFlagErrors(allFlags, activeFlags, flagMap, commandPath);
88579
+ if (outOfScopeErrors.length > 0 || globalFlagErrors.length > 0) {
88580
+ const parseErrors = parsedArgs.errors ?? [];
88581
+ return yield* new ShowHelp({
88582
+ commandPath,
88583
+ errors: [
88584
+ ...globalFlagErrors,
88585
+ ...outOfScopeErrors,
88586
+ ...parseErrors
88587
+ ]
88588
+ });
88589
+ }
88590
+ for (const flag of activeFlags) {
88591
+ if (flag._tag !== "Action") continue;
88592
+ if (!extractSingleParams(flag.flag).some((s) => {
88593
+ const entries = flagMap[s.name];
88594
+ return entries !== void 0 && entries.length > 0;
88595
+ })) continue;
88596
+ const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp);
88597
+ if (flag === Wizard) {
88598
+ const { colors } = yield* Theme;
88599
+ return yield* gen(function* () {
88600
+ yield* log(renderIntroduction(command.name, config.version, command.description, colors));
88601
+ const prefix = [command.name, ...args.filter((arg) => arg !== "--wizard" && !arg.startsWith("--wizard="))];
88602
+ const wizardResult = yield* run$1(command, {
88603
+ commandPath,
88604
+ prefix
88605
+ });
88606
+ yield* log(renderCompletion(wizardResult.displayArgs, colors));
88607
+ if (yield* run$2(Toggle({
88608
+ message: "Run this command?",
88609
+ initial: true,
88610
+ active: "yes",
88611
+ inactive: "no"
88612
+ }))) {
88613
+ yield* log();
88614
+ yield* runWith(command, {
88615
+ ...config,
88616
+ renderErrors: false
88617
+ })(wizardResult.args.slice(1));
88618
+ }
88619
+ }).pipe(catchTag("QuitError", () => log(renderQuit(colors))));
88620
+ }
88621
+ yield* flag.run(value, handlerCtx);
88622
+ return;
88623
+ }
88624
+ if (parsedArgs.errors && parsedArgs.errors.length > 0) return yield* new ShowHelp({
88625
+ commandPath,
88626
+ errors: parsedArgs.errors
88627
+ });
88628
+ const input = yield* commandImpl.parse(parsedArgs).pipe(toShowHelp);
88629
+ let program = commandImpl.handle(input, [command.name]);
88630
+ const logLevel = activeFlags.includes(LogLevel) ? (yield* LogLevel.flag.parse(emptyArgs).pipe(toShowHelp))[1] : none();
88631
+ program = provideService(program, LogLevel, logLevel);
88632
+ for (const flag of activeFlags) {
88633
+ if (flag._tag !== "Setting" || flag === LogLevel) continue;
88634
+ const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp);
88635
+ program = provideService(program, flag, value);
88636
+ }
88637
+ const services = match$8(logLevel, {
88638
+ onNone: () => empty$14(),
88639
+ onSome: (level) => make$81(MinimumLogLevel, level)
88640
+ });
88641
+ yield* provideContext$2(program, services);
88642
+ }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$10(error) : fail$12(error), (error) => andThen(showHelp(command, error, config.renderErrors !== false), fail$7(error))), catchFilter((error) => {
88643
+ if (config.renderErrors === false || !isObjectKeyword(error)) return fail$12(error);
88644
+ const userMessage = getUserMessage(error);
88645
+ return userMessage === void 0 ? fail$12(error) : succeed$10({
88646
+ error,
88647
+ userMessage
88648
+ });
88649
+ }, ({ error, userMessage }) => andThen(showUserError(error, userMessage), fail$7(error))), catchFilter((e) => isQuitError(e) ? succeed$10(e) : fail$12(e), (_) => interrupt$1));
88650
+ };
88651
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/HttpStaticServer.js
88652
+ /**
88653
+ * Serves static files for Effect HTTP applications.
88654
+ *
88655
+ * `HttpStaticServer` turns request paths into file responses under a configured
88656
+ * root directory. It can be used as an application value or mounted onto an
88657
+ * `HttpRouter`, and it handles index files, optional single-page application
88658
+ * fallback, MIME type headers, cache-control headers, byte ranges, and
88659
+ * conditional `304 Not Modified` responses.
88660
+ *
88661
+ * @stability unstable
88662
+ * @since 4.0.0
88663
+ */
88664
+ /**
88665
+ * Creates an `HttpApp` that serves files from a directory.
88666
+ *
88667
+ * **Example** (Serving files from a directory)
88668
+ *
88669
+ * ```ts import.meta.vitest
88670
+ * import { ByteSize, Effect, FileSystem, Layer, Path } from "effect"
88671
+ * import {
88672
+ * HttpEffect,
88673
+ * HttpPlatform,
88674
+ * HttpServerResponse,
88675
+ * HttpStaticServer
88676
+ * } from "effect/http"
88677
+ *
88678
+ * const TestFileSystem = FileSystem.layerNoop({
88679
+ * stat: () =>
88680
+ * Effect.succeed({
88681
+ * type: "File",
88682
+ * size: ByteSize.bytes(20)
88683
+ * } as FileSystem.File.Info)
88684
+ * })
88685
+ * const TestHttpPlatform = Layer.succeed(
88686
+ * HttpPlatform.HttpPlatform,
88687
+ * HttpPlatform.HttpPlatform.of({
88688
+ * platform: "web",
88689
+ * fileResponse: (path) => Effect.succeed(HttpServerResponse.text(`Serving ${path}`)),
88690
+ * fileWebResponse: () => Effect.die("unused")
88691
+ * })
88692
+ * )
88693
+ * const TestServices = Layer.mergeAll(Path.layer, TestFileSystem, TestHttpPlatform)
88694
+ *
88695
+ * const program = Effect.gen(function*() {
88696
+ * const app = yield* HttpStaticServer.make({ root: "/public" })
88697
+ * const handler = HttpEffect.toWebHandler(app)
88698
+ * const response = yield* Effect.promise(() => handler(new Request("http://localhost/guide.txt")))
88699
+ * const body = yield* Effect.promise(() => response.text())
88700
+ * return body
88701
+ * }).pipe(Effect.provide(TestServices))
88702
+ *
88703
+ * await Effect.runPromise(program) // => "Serving /public/guide.txt"
88704
+ * ```
88705
+ *
88706
+ * @stability unstable
88707
+ * @category constructors
88708
+ * @since 4.0.0
88709
+ */
88710
+ const make$4 = /*#__PURE__*/ fnUntraced(function* (options) {
88711
+ const fileSystem = yield* FileSystem;
88712
+ const path = yield* Path$1;
88713
+ const platform = yield* HttpPlatform;
88714
+ const resolvedRoot = path.resolve(options.root);
88715
+ const index = "index" in options ? options.index : "index.html";
88716
+ const spa = options.spa === true;
88717
+ const cacheControl = options.cacheControl;
88718
+ const mimeTypes = {
88719
+ ...defaultMimeTypes,
88720
+ ...options.mimeTypes
88721
+ };
88722
+ const setFileHeaders = (response, filePath) => {
88723
+ let currentResponse = setHeaders(response, {
88724
+ "Content-Type": resolveMimeType(path, filePath, mimeTypes),
88725
+ "Accept-Ranges": "bytes"
88726
+ });
88727
+ if (cacheControl !== void 0) currentResponse = setHeader(currentResponse, "Cache-Control", cacheControl);
88728
+ return currentResponse;
88729
+ };
88730
+ const serveFile = fnUntraced(function* (request, filePath, fileSize) {
88731
+ const rangeHeader = request.method === "GET" ? request.headers["range"] : void 0;
88732
+ const shouldEvaluateConditionals = request.headers["if-match"] !== void 0 || request.headers["if-unmodified-since"] !== void 0 || request.headers["if-none-match"] !== void 0 || request.headers["if-modified-since"] !== void 0;
88733
+ let fullResponse;
88734
+ const getFullResponse = () => fullResponse === void 0 ? map$5(handlePlatformError(request, platform.fileResponse(filePath)), (response) => setFileHeaders(response, filePath)) : succeed$5(fullResponse);
88735
+ if (shouldEvaluateConditionals) {
88736
+ fullResponse = yield* getFullResponse();
88737
+ const conditionalResponse = evaluateConditionalRequest(request, fullResponse);
88738
+ if (conditionalResponse !== void 0) return conditionalResponse;
88739
+ }
88740
+ if (rangeHeader === void 0) return yield* getFullResponse();
88741
+ const ifRange = request.headers["if-range"];
88742
+ if (ifRange !== void 0) {
88743
+ fullResponse = yield* getFullResponse();
88744
+ if (!matchesIfRange(ifRange, fullResponse.headers["etag"])) return fullResponse;
88745
+ }
88746
+ const resolvedFileSize = fileSize ?? (yield* handlePlatformError(request, fileSystem.stat(filePath))).size;
88747
+ const parsedRange = parseRange(rangeHeader, resolvedFileSize);
88748
+ if (parsedRange === void 0) return yield* getFullResponse();
88749
+ if (parsedRange === "unsatisfiable") return empty({
88750
+ status: 416,
88751
+ headers: { "Content-Range": `bytes */${resolvedFileSize}` }
88752
+ });
88753
+ let response = setFileHeaders(yield* handlePlatformError(request, platform.fileResponse(filePath, {
88754
+ status: 206,
88755
+ offset: parsedRange.start,
88756
+ bytesToRead: parsedRange.end - parsedRange.start + BigInt(1)
88757
+ })), filePath);
88758
+ response = setHeader(response, "Content-Range", `bytes ${parsedRange.start}-${parsedRange.end}/${resolvedFileSize}`);
88759
+ return response;
88760
+ });
88761
+ return HttpServerRequest.use((request) => {
88762
+ const resolvedPath = resolveFilePath(path, resolvedRoot, request.url);
88763
+ if (resolvedPath === void 0) return fail$7(toRouteNotFoundError(request));
88764
+ return matchEffect(fileSystem.stat(resolvedPath), {
88765
+ onFailure: (error) => error.reason._tag === "NotFound" && spa && index !== void 0 && path.extname(resolvedPath) === "" && acceptsHtml(request.headers["accept"]) ? serveFile(request, path.join(resolvedRoot, index)) : error.reason._tag === "NotFound" ? fail$7(toRouteNotFoundError(request)) : fail$7(toInternalServerError(request, error)),
88766
+ onSuccess(info) {
88767
+ if (info.type === "File") return serveFile(request, resolvedPath, info.size);
88768
+ if (info.type === "Directory" && index !== void 0) {
88769
+ let originalUrl = request.originalUrl;
88770
+ if (!originalUrl.startsWith("/")) {
88771
+ const url = new URL(originalUrl);
88772
+ originalUrl = url.pathname + url.search;
88773
+ }
88774
+ const pathname = stripQueryString(originalUrl);
88775
+ if (!pathname.endsWith("/")) {
88776
+ const location = pathname.replace(/^\/+/, "/").replace(/\\/g, "%5C");
88777
+ return succeed$5(redirect(`${location}/${originalUrl.slice(pathname.length)}`, { status: 301 }));
88778
+ }
88779
+ return serveFile(request, path.join(resolvedPath, index));
88780
+ }
88781
+ return fail$7(toRouteNotFoundError(request));
88782
+ }
88783
+ });
88784
+ });
88785
+ });
88786
+ /**
88787
+ * Creates a layer that mounts static files on an `HttpRouter`.
88788
+ *
88789
+ * **Example** (Mounting static files on a router)
88790
+ *
88791
+ * ```ts import.meta.vitest
88792
+ * import { Layer } from "effect"
88793
+ * import { HttpRouter, HttpServerResponse, HttpStaticServer } from "effect/http"
88794
+ *
88795
+ * const ApiLayer = HttpRouter.add("GET", "/health", HttpServerResponse.text("ok"))
88796
+ *
88797
+ * const StaticFilesLayer = HttpStaticServer.layer({
88798
+ * root: "./public",
88799
+ * prefix: "/static"
88800
+ * })
88801
+ *
88802
+ * const AppLayer = Layer.mergeAll(ApiLayer, StaticFilesLayer)
88803
+ * Layer.isLayer(AppLayer) // => true
88912
88804
  * ```
88913
88805
  *
88914
88806
  * @stability unstable
88915
- * @category running
88807
+ * @category layers
88916
88808
  * @since 4.0.0
88917
88809
  */
88918
- const runWith = (command, config) => {
88919
- const commandImpl = toImpl(command);
88920
- return fnUntraced(function* (args) {
88921
- const { builtIns } = yield* CliConfig;
88922
- const { tokens, trailingOperands } = lex(args);
88923
- const allFlags = getGlobalFlagsForCommandTree(command, builtIns);
88924
- const allFlagParams = allFlags.flatMap((f) => extractSingleParams(f.flag));
88925
- const globalRegistry = createFlagRegistry(allFlagParams.filter(isFlagParam));
88926
- const { flagMap, remainder, errors: globalFlagErrors } = consumeGlobalFlags(tokens, command, globalRegistry);
88927
- const emptyArgs = {
88928
- flags: flagMap,
88929
- arguments: []
88810
+ const layer$2 = (options) => effectDiscard(gen(function* () {
88811
+ const router = yield* HttpRouter;
88812
+ const handler = (yield* make$4(options)).pipe(catch_$2(toResponse));
88813
+ if (options.prefix !== void 0) {
88814
+ yield* router.prefixed(options.prefix).add("GET", "/*", handler);
88815
+ return;
88816
+ }
88817
+ yield* router.add("GET", "/*", handler);
88818
+ }));
88819
+ const defaultMimeTypes = {
88820
+ html: "text/html; charset=utf-8",
88821
+ htm: "text/html; charset=utf-8",
88822
+ css: "text/css; charset=utf-8",
88823
+ js: "text/javascript; charset=utf-8",
88824
+ mjs: "text/javascript; charset=utf-8",
88825
+ json: "application/json; charset=utf-8",
88826
+ xml: "application/xml; charset=utf-8",
88827
+ txt: "text/plain; charset=utf-8",
88828
+ csv: "text/csv; charset=utf-8",
88829
+ md: "text/markdown; charset=utf-8",
88830
+ yaml: "text/yaml; charset=utf-8",
88831
+ yml: "text/yaml; charset=utf-8",
88832
+ png: "image/png",
88833
+ jpg: "image/jpeg",
88834
+ jpeg: "image/jpeg",
88835
+ gif: "image/gif",
88836
+ svg: "image/svg+xml; charset=utf-8",
88837
+ ico: "image/x-icon",
88838
+ webp: "image/webp",
88839
+ avif: "image/avif",
88840
+ woff: "font/woff",
88841
+ woff2: "font/woff2",
88842
+ ttf: "font/ttf",
88843
+ otf: "font/otf",
88844
+ eot: "application/vnd.ms-fontobject",
88845
+ mp3: "audio/mpeg",
88846
+ mp4: "video/mp4",
88847
+ webm: "video/webm",
88848
+ ogg: "audio/ogg",
88849
+ wav: "audio/wav",
88850
+ flac: "audio/flac",
88851
+ aac: "audio/aac",
88852
+ pdf: "application/pdf",
88853
+ zip: "application/zip",
88854
+ gz: "application/gzip",
88855
+ wasm: "application/wasm",
88856
+ map: "application/json",
88857
+ webmanifest: "application/manifest+json"
88858
+ };
88859
+ const stripQueryString = (url) => {
88860
+ const queryIndex = url.indexOf("?");
88861
+ return queryIndex === -1 ? url : url.slice(0, queryIndex);
88862
+ };
88863
+ const resolveMimeType = (path, filePath, mimeTypes) => {
88864
+ const extension = path.extname(filePath).toLowerCase();
88865
+ if (extension.length <= 1) return "application/octet-stream";
88866
+ return mimeTypes[extension.slice(1)] ?? "application/octet-stream";
88867
+ };
88868
+ const parseInteger = (value) => {
88869
+ if (!/^\d+$/.test(value)) return;
88870
+ return BigInt(value);
88871
+ };
88872
+ const parseRange = (header, fileSize) => {
88873
+ const value = header.trim();
88874
+ if (!value.toLowerCase().startsWith("bytes=")) return;
88875
+ const rangeValue = value.slice(6).trim();
88876
+ if (rangeValue.length === 0 || rangeValue.includes(",")) return;
88877
+ const separatorIndex = rangeValue.indexOf("-");
88878
+ if (separatorIndex === -1) return;
88879
+ const startPart = rangeValue.slice(0, separatorIndex).trim();
88880
+ const endPart = rangeValue.slice(separatorIndex + 1).trim();
88881
+ if (startPart === "" && endPart === "") return;
88882
+ if (startPart === "") {
88883
+ const suffixLength = parseInteger(endPart);
88884
+ if (suffixLength === void 0) return;
88885
+ if (suffixLength === BigInt(0) || fileSize === BigInt(0)) return "unsatisfiable";
88886
+ return {
88887
+ start: fileSize > suffixLength ? fileSize - suffixLength : BigInt(0),
88888
+ end: fileSize - BigInt(1)
88930
88889
  };
88931
- const parsedArgs = yield* parseArgs({
88932
- tokens: remainder,
88933
- trailingOperands
88934
- }, command);
88935
- const commandPath = [command.name, ...getCommandPath(parsedArgs)];
88936
- const toShowHelp = mapError$2((error) => error._tag === "ShowHelp" ? error : new ShowHelp({
88937
- commandPath,
88938
- errors: [error]
88939
- }));
88940
- const handlerCtx = {
88941
- builtIns,
88942
- command,
88943
- commandPath,
88944
- version: config.version
88890
+ }
88891
+ const start = parseInteger(startPart);
88892
+ if (start === void 0) return;
88893
+ if (endPart === "") {
88894
+ if (start >= fileSize) return "unsatisfiable";
88895
+ return {
88896
+ start,
88897
+ end: fileSize - BigInt(1)
88945
88898
  };
88946
- const activeFlags = getGlobalFlagsForCommandPath(command, commandPath, builtIns);
88947
- const outOfScopeErrors = getOutOfScopeGlobalFlagErrors(allFlags, activeFlags, flagMap, commandPath);
88948
- if (outOfScopeErrors.length > 0 || globalFlagErrors.length > 0) {
88949
- const parseErrors = parsedArgs.errors ?? [];
88950
- return yield* new ShowHelp({
88951
- commandPath,
88952
- errors: [
88953
- ...globalFlagErrors,
88954
- ...outOfScopeErrors,
88955
- ...parseErrors
88956
- ]
88957
- });
88958
- }
88959
- for (const flag of activeFlags) {
88960
- if (flag._tag !== "Action") continue;
88961
- if (!extractSingleParams(flag.flag).some((s) => {
88962
- const entries = flagMap[s.name];
88963
- return entries !== void 0 && entries.length > 0;
88964
- })) continue;
88965
- const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp);
88966
- if (flag === Wizard) {
88967
- const { colors } = yield* Theme;
88968
- return yield* gen(function* () {
88969
- yield* log(renderIntroduction(command.name, config.version, command.description, colors));
88970
- const prefix = [command.name, ...args.filter((arg) => arg !== "--wizard" && !arg.startsWith("--wizard="))];
88971
- const wizardResult = yield* run$1(command, {
88972
- commandPath,
88973
- prefix
88974
- });
88975
- yield* log(renderCompletion(wizardResult.displayArgs, colors));
88976
- if (yield* run$2(Toggle({
88977
- message: "Run this command?",
88978
- initial: true,
88979
- active: "yes",
88980
- inactive: "no"
88981
- }))) {
88982
- yield* log();
88983
- yield* runWith(command, {
88984
- ...config,
88985
- renderErrors: false
88986
- })(wizardResult.args.slice(1));
88987
- }
88988
- }).pipe(catchTag("QuitError", () => log(renderQuit(colors))));
88989
- }
88990
- yield* flag.run(value, handlerCtx);
88991
- return;
88992
- }
88993
- if (parsedArgs.errors && parsedArgs.errors.length > 0) return yield* new ShowHelp({
88994
- commandPath,
88995
- errors: parsedArgs.errors
88996
- });
88997
- const input = yield* commandImpl.parse(parsedArgs).pipe(toShowHelp);
88998
- let program = commandImpl.handle(input, [command.name]);
88999
- const logLevel = activeFlags.includes(LogLevel) ? (yield* LogLevel.flag.parse(emptyArgs).pipe(toShowHelp))[1] : none();
89000
- program = provideService(program, LogLevel, logLevel);
89001
- for (const flag of activeFlags) {
89002
- if (flag._tag !== "Setting" || flag === LogLevel) continue;
89003
- const [, value] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp);
89004
- program = provideService(program, flag, value);
89005
- }
89006
- const services = match$8(logLevel, {
89007
- onNone: () => empty$14(),
89008
- onSome: (level) => make$81(MinimumLogLevel, level)
89009
- });
89010
- yield* provideContext$2(program, services);
89011
- }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$10(error) : fail$12(error), (error) => andThen(showHelp(command, error, config.renderErrors !== false), fail$7(error))), catchFilter((error) => {
89012
- if (config.renderErrors === false || !isObjectKeyword(error)) return fail$12(error);
89013
- const userMessage = getUserMessage(error);
89014
- return userMessage === void 0 ? fail$12(error) : succeed$10({
89015
- error,
89016
- userMessage
89017
- });
89018
- }, ({ error, userMessage }) => andThen(showUserError(error, userMessage), fail$7(error))), catchFilter((e) => isQuitError(e) ? succeed$10(e) : fail$12(e), (_) => interrupt$1));
88899
+ }
88900
+ const end = parseInteger(endPart);
88901
+ if (end === void 0) return;
88902
+ if (start > end || start >= fileSize) return "unsatisfiable";
88903
+ return {
88904
+ start,
88905
+ end: end < fileSize ? end : fileSize - BigInt(1)
88906
+ };
88907
+ };
88908
+ const resolveFilePath = (path, root, url) => {
88909
+ const urlPath = stripQueryString(url);
88910
+ let decodedPath;
88911
+ try {
88912
+ decodedPath = decodeURIComponent(urlPath);
88913
+ } catch {
88914
+ return;
88915
+ }
88916
+ if (decodedPath.includes("\0")) return;
88917
+ const relativePath = decodedPath.replace(path.sep === "\\" ? /^[/\\]+/ : /^\/+/, "");
88918
+ return getOrUndefined$1(path.resolveWithin(root, relativePath));
88919
+ };
88920
+ const toRouteNotFoundError = (request) => new HttpServerError({ reason: new RouteNotFound({ request }) });
88921
+ const toInternalServerError = (request, cause) => new HttpServerError({ reason: new InternalError({
88922
+ request,
88923
+ cause
88924
+ }) });
88925
+ const handlePlatformError = (request, self) => catchIf(self, (error) => error.reason._tag === "NotFound", () => fail$7(toRouteNotFoundError(request)), (error) => fail$7(toInternalServerError(request, error)));
88926
+ const acceptsHtml = (accept) => accept !== void 0 && accept.toLowerCase().includes("text/html");
88927
+ const stripWeakEtagPrefix = (value) => {
88928
+ const trimmed = value.trim();
88929
+ return /^w\//i.test(trimmed) ? trimmed.slice(2) : trimmed;
88930
+ };
88931
+ const entityTagList = /^[\s,]*(?:(?:W\/)?"[^"]*"\s*(?:,[\s,]*|$))*$/;
88932
+ const entityTag = /(?:W\/)?"[^"]*"/g;
88933
+ const matchesIfMatch = (ifMatch, etag) => {
88934
+ if (ifMatch.trim() === "*") return true;
88935
+ if (etag === void 0 || !etag.startsWith("\"") || !entityTagList.test(ifMatch)) return false;
88936
+ return ifMatch.match(entityTag)?.includes(etag) ?? false;
88937
+ };
88938
+ const matchesIfNoneMatch = (ifNoneMatch, etag) => {
88939
+ const normalizedEtag = etag === void 0 ? void 0 : stripWeakEtagPrefix(etag);
88940
+ for (const candidate of ifNoneMatch.split(",")) {
88941
+ const value = candidate.trim();
88942
+ if (value === "") continue;
88943
+ if (value === "*") return true;
88944
+ if (normalizedEtag !== void 0 && stripWeakEtagPrefix(value) === normalizedEtag) return true;
88945
+ }
88946
+ return false;
88947
+ };
88948
+ const isModifiedSince = (since, lastModified) => {
88949
+ if (lastModified === void 0) return;
88950
+ const sinceDate = parseHttpDate(since);
88951
+ if (isFailure$1(sinceDate)) return;
88952
+ const lastModifiedDate = parseHttpDate(lastModified);
88953
+ return isSuccess$1(lastModifiedDate) ? toEpochMillis(lastModifiedDate.success) > toEpochMillis(sinceDate.success) : void 0;
88954
+ };
88955
+ const matchesIfRange = (ifRange, etag) => {
88956
+ const value = ifRange.trim();
88957
+ return value.startsWith("\"") && value === etag;
88958
+ };
88959
+ const notModifiedHeaders = [
88960
+ "cache-control",
88961
+ "content-location",
88962
+ "date",
88963
+ "etag",
88964
+ "expires",
88965
+ "last-modified",
88966
+ "vary"
88967
+ ];
88968
+ const notModifiedResponse = (response) => {
88969
+ const headers = {};
88970
+ for (const name of notModifiedHeaders) {
88971
+ const value = response.headers[name];
88972
+ if (value !== void 0) headers[name] = value;
88973
+ }
88974
+ return empty({
88975
+ status: 304,
88976
+ headers
88977
+ });
88978
+ };
88979
+ const evaluateConditionalRequest = (request, response) => {
88980
+ const etag = response.headers["etag"];
88981
+ const lastModified = response.headers["last-modified"];
88982
+ const ifMatch = request.headers["if-match"];
88983
+ if (ifMatch !== void 0) {
88984
+ if (!matchesIfMatch(ifMatch, etag)) return empty({ status: 412 });
88985
+ } else {
88986
+ const ifUnmodifiedSince = request.headers["if-unmodified-since"];
88987
+ if (ifUnmodifiedSince !== void 0 && isModifiedSince(ifUnmodifiedSince, lastModified) === true) return empty({ status: 412 });
88988
+ }
88989
+ const ifNoneMatch = request.headers["if-none-match"];
88990
+ if (ifNoneMatch !== void 0) return matchesIfNoneMatch(ifNoneMatch, etag) ? notModifiedResponse(response) : void 0;
88991
+ const ifModifiedSince = request.headers["if-modified-since"];
88992
+ if (ifModifiedSince !== void 0 && isModifiedSince(ifModifiedSince, lastModified) === false) return notModifiedResponse(response);
89019
88993
  };
89020
88994
  // ../../packages/runtime/src/auth/schema.ts
89021
88995
  var AuthError = class extends TaggedError()("AuthError", {
@@ -89026,7 +89000,6 @@ var AuthError = class extends TaggedError()("AuthError", {
89026
89000
  "invalid_client_metadata",
89027
89001
  "invalid_redirect_uri",
89028
89002
  "invalid_grant",
89029
- "invalid_target",
89030
89003
  "invalid_scope",
89031
89004
  "unsupported_grant_type",
89032
89005
  "unsupported_response_type",
@@ -89197,10 +89170,10 @@ const layerFlusher = /*#__PURE__*/ sync$1(Flusher, () => {
89197
89170
  */
89198
89171
  const make$3 = /*#__PURE__*/ fnUntraced(function* (options) {
89199
89172
  const services = yield* context();
89200
- const clock = get$11(services, Clock);
89201
- const scope = get$11(services, Scope);
89173
+ const clock = get$10(services, Clock);
89174
+ const scope = get$10(services, Scope);
89202
89175
  const exportInterval = max$1(fromInputUnsafe$1(options.exportInterval), zero$2);
89203
- const client = get$11(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_$1), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
89176
+ const client = get$10(services, HttpClient).pipe(tap((response) => ignore$1(response.arrayBuffer)), tapError((error) => error.response ? ignore$1(error.response.arrayBuffer) : void_$1), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
89204
89177
  schedule: policy,
89205
89178
  times: 3
89206
89179
  }));
@@ -89810,7 +89783,7 @@ function layerOtlp(serviceName, url, runtime, version) {
89810
89783
  "code_verifier",
89811
89784
  "session",
89812
89785
  "token"
89813
- ])), provide$2([layerJson, layer$16]));
89786
+ ])), provide$2([layerJson, layer$12]));
89814
89787
  })), catchCause$3((cause) => {
89815
89788
  if (hasInterrupts$1(cause)) return effectDiscard(interrupt$1);
89816
89789
  return effectDiscard(logWarning("Telemetry is unavailable"));
@@ -89819,6 +89792,12 @@ function layerOtlp(serviceName, url, runtime, version) {
89819
89792
  // ../../packages/runtime/src/auth/lib/utils.ts
89820
89793
  const ISSUER_PATH = "/api/auth";
89821
89794
  const APPS_PATH = "/api/apps";
89795
+ const COOKIE = {
89796
+ httpOnly: true,
89797
+ path: "/",
89798
+ sameSite: "lax",
89799
+ secure: true
89800
+ };
89822
89801
  const SESSION_COOKIE = "__Host-session";
89823
89802
  function matchingSessions(saved, userId) {
89824
89803
  return sort(filter$3(getSomes(saved), (session) => session.value.user.id === userId), mapInput(flip$2(Number$6), (session) => session.value.expiresAt));
@@ -90824,7 +90803,7 @@ var Sessions = class Sessions extends Service$2()("@deslop/runtime/auth/sessions
90824
90803
  return digest.digestHex(sha256, new TextEncoder().encode(id));
90825
90804
  }
90826
90805
  function lockOf(key) {
90827
- return getOrElse(get$8(locks, key), () => {
90806
+ return getOrElse(get$7(locks, key), () => {
90828
90807
  const lock = makeUnsafe$6(1);
90829
90808
  set$5(locks, key, lock);
90830
90809
  return lock;
@@ -90883,7 +90862,7 @@ var Sessions = class Sessions extends Service$2()("@deslop/runtime/auth/sessions
90883
90862
  if (is$2(AuthError)(renewed.failure) && renewed.failure.error === "temporarily_unavailable") return yield* renewed.failure;
90884
90863
  }
90885
90864
  const now = yield* currentTimeMillis;
90886
- const bearer = getOrUndefined$1(filter$5(get$8(bearers, userId), (access) => access.expiresAt >= now + 6e4));
90865
+ const bearer = getOrUndefined$1(filter$5(get$7(bearers, userId), (access) => access.expiresAt >= now + 6e4));
90887
90866
  if (bearer !== void 0) return bearer.token;
90888
90867
  remove$5(bearers, userId);
90889
90868
  return yield* AuthError.make({ message: `Open ${capitalize(split$2(new URL(app).hostname, ".")[0])} once so it can use AI for you` });
@@ -91039,13 +91018,6 @@ function layerMcpAuth(resource) {
91039
91018
  // ../../packages/runtime/src/server.ts
91040
91019
  const LOOPBACK = /^(?:localhost|\d{1,3}(?:\.\d{1,3}){3}|\[[\da-f:.]+\])$/iu;
91041
91020
  const OTLP = ["/v1/traces", "/v1/logs"];
91042
- const COOKIE = {
91043
- httpOnly: true,
91044
- path: "/",
91045
- sameSite: "lax",
91046
- secure: true
91047
- };
91048
- const SIGN_IN_COOKIE = "__Host-sign-in";
91049
91021
  const packageRoot = match$1(endsWith(".ts")(import.meta.url), {
91050
91022
  onFalse: () => fileURLToPath(new URL("..", import.meta.url)),
91051
91023
  onTrue: cwd
@@ -91180,112 +91152,6 @@ const layerRoutes = use((router) => gen(function* () {
91180
91152
  }, { headers: { "cache-control": "no-store" } });
91181
91153
  }));
91182
91154
  }));
91183
- const SignInState = fromJsonString(Struct({
91184
- next: String$6,
91185
- state: String$6,
91186
- verifier: String$6
91187
- }));
91188
- const CallbackParams = Struct({
91189
- code: optionalKey(String$6),
91190
- error: optionalKey(String$6),
91191
- iss: optionalKey(String$6),
91192
- state: optionalKey(String$6)
91193
- });
91194
- function signedOut(next, cause) {
91195
- return as(logWarning("The sign-in did not complete", cause), expireCookieUnsafe(redirect(next), SIGN_IN_COOKIE, COOKIE));
91196
- }
91197
- function layerSignIn(issuer) {
91198
- return use((router) => gen(function* () {
91199
- const sessions = yield* Sessions;
91200
- const random = yield* SecureRandom;
91201
- const digest = yield* Digest;
91202
- const canonical = new URL(yield* String$5("APP_URL")).origin;
91203
- const callback = new URL(CALLBACK_PATH, canonical).href;
91204
- const clientId = yield* cached(map$5(appName$1, (name) => clientIdOf({
91205
- name: capitalize(name),
91206
- redirects: [callback]
91207
- })));
91208
- function ended(headers) {
91209
- return match$8(sessionIdOf(headers), {
91210
- onNone: () => void_$1,
91211
- onSome: (id) => ignore$1(sessions.end(id), {
91212
- log: "Warn",
91213
- message: "The session could not be ended"
91214
- })
91215
- });
91216
- }
91217
- function toNext(handle) {
91218
- return flatMap$3(HttpServerRequest, (request) => match$8(filter$5(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (next) => next.origin === canonical), {
91219
- onNone: () => succeed$5(empty({ status: 400 })),
91220
- onSome: (next) => handle(request, next)
91221
- }));
91222
- }
91223
- yield* router.add("GET", "/auth/sign-in", toNext(fnUntraced(function* (_, next) {
91224
- const verifier = encode$1(yield* random.randomBytes(32));
91225
- const state = encode$1(yield* random.randomBytes(16));
91226
- const authorize = new URL(AUTHORIZE_PATH, issuer);
91227
- authorize.search = `${new URLSearchParams({
91228
- client_id: yield* clientId,
91229
- code_challenge: encode$1(yield* digest.digest(sha256, new TextEncoder().encode(verifier))),
91230
- code_challenge_method: "S256",
91231
- redirect_uri: callback,
91232
- response_type: "code",
91233
- scope: "deslop offline_access",
91234
- state
91235
- })}`;
91236
- return setCookieUnsafe(redirect(authorize.href), SIGN_IN_COOKIE, yield* encodeEffect(SignInState)({
91237
- next: next.href,
91238
- state,
91239
- verifier
91240
- }), {
91241
- ...COOKIE,
91242
- maxAge: "10 minutes"
91243
- });
91244
- })));
91245
- yield* router.add("GET", CALLBACK_PATH, gen(function* () {
91246
- const request = yield* HttpServerRequest;
91247
- return yield* match$8(yield* option$1(decodeUnknownEffect(SignInState)(request.cookies[SIGN_IN_COOKIE])), {
91248
- onNone: () => signedOut(canonical, "The sign-in expired or began in another browser"),
91249
- onSome: fnUntraced(function* (saved) {
91250
- const started = yield* result$1(gen(function* () {
91251
- const params = yield* schemaSearchParams(CallbackParams);
91252
- if (params.state !== saved.state) return yield* AuthError.make({ message: "The sign-in began in another browser" });
91253
- if (params.error !== void 0 || params.code === void 0) return yield* AuthError.make({ message: `Auth answered ${params.error ?? "without a code"}` });
91254
- if (params.iss !== new URL("/api/auth", issuer).href) return yield* AuthError.make({ message: "The answer came from another issuer" });
91255
- return yield* sessions.start({
91256
- client_id: yield* clientId,
91257
- code: params.code,
91258
- code_verifier: saved.verifier,
91259
- redirect_uri: callback
91260
- });
91261
- }));
91262
- if (isFailure$1(started)) return yield* signedOut(saved.next, started.failure);
91263
- return pipe(redirect(saved.next), expireCookieUnsafe(SIGN_IN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.success, {
91264
- ...COOKIE,
91265
- maxAge: "365 days"
91266
- }));
91267
- })
91268
- });
91269
- }));
91270
- yield* router.add("POST", "/auth/session", gen(function* () {
91271
- const started = yield* result$1(pipe(schemaBodyJson(CodeGrant), rejected("The sign-in request is invalid"), flatMap$3(sessions.start)));
91272
- if (isFailure$1(started)) return text$1(started.failure.message, failureOptions(started.failure, 400));
91273
- return yield* schemaJson(SessionHandle)({ session: started.success }, { headers: { "cache-control": "no-store" } });
91274
- }));
91275
- yield* router.add("GET", "/auth/sign-out", toNext((request, next) => as(ended(request.headers), expireCookieUnsafe(redirect(`${new URL("/", issuer).href}?${new URLSearchParams({
91276
- next: next.href,
91277
- "sign-out": ""
91278
- })}`), SESSION_COOKIE, COOKIE))));
91279
- yield* router.add("POST", "/auth/sign-out", as(flatMap$3(HttpServerRequest, (request) => ended(request.headers)), empty({ status: 204 })));
91280
- }));
91281
- }
91282
- const notConfigured = text$1("Sign-in is not configured for this app", { status: 503 });
91283
- const layerSessionRoutes = unwrap$7(gen(function* () {
91284
- return match$8(yield* option(String$5("AUTH_URL")), {
91285
- onNone: () => mergeAll$1(add("GET", "/auth/sign-in", notConfigured), add("GET", "/auth/sign-out", notConfigured)),
91286
- onSome: layerSignIn
91287
- });
91288
- }));
91289
91155
  const layerAnnounce = effectDiscard(gen(function* () {
91290
91156
  const origin = new URL(yield* String$5("APP_URL")).origin;
91291
91157
  const client = pipe(yield* HttpClient, filterStatusOk, timeout("10 seconds"), retryTransient({
@@ -91330,11 +91196,11 @@ const layerWeb = unwrap$7(gen(function* () {
91330
91196
  }, {
91331
91197
  contentType: "application/manifest+json",
91332
91198
  headers: { "cache-control": "no-cache" }
91333
- }))), layer$15({
91199
+ }))), layer$2({
91334
91200
  cacheControl: "public, max-age=31536000, immutable",
91335
91201
  prefix: "/assets",
91336
91202
  root: `${client}/assets`
91337
- }), layer$15({
91203
+ }), layer$2({
91338
91204
  cacheControl: "no-cache",
91339
91205
  index: "index.html",
91340
91206
  root: client,
@@ -91415,6 +91281,113 @@ var AiGateway = class AiGateway extends Service$2()("@deslop/runtime/ai/service/
91415
91281
  });
91416
91282
  }));
91417
91283
  };
91284
+ // ../../packages/runtime/src/auth/routes.ts
91285
+ const SIGN_IN_COOKIE = "__Host-sign-in";
91286
+ const SignInState = fromJsonString(Struct({
91287
+ next: String$6,
91288
+ state: String$6,
91289
+ verifier: String$6
91290
+ }));
91291
+ const CallbackParams = Struct({
91292
+ code: optionalKey(String$6),
91293
+ error: optionalKey(String$6),
91294
+ iss: optionalKey(String$6),
91295
+ state: optionalKey(String$6)
91296
+ });
91297
+ function signedOut(next, cause) {
91298
+ return as(logWarning("The sign-in did not complete", cause), expireCookieUnsafe(redirect(next), SIGN_IN_COOKIE, COOKIE));
91299
+ }
91300
+ function layerSignIn(issuer) {
91301
+ return use((router) => gen(function* () {
91302
+ const sessions = yield* Sessions;
91303
+ const random = yield* SecureRandom;
91304
+ const digest = yield* Digest;
91305
+ const canonical = new URL(yield* String$5("APP_URL")).origin;
91306
+ const callback = new URL(CALLBACK_PATH, canonical).href;
91307
+ const clientId = yield* cached(map$5(appName$1, (name) => clientIdOf({
91308
+ name: capitalize(name),
91309
+ redirects: [callback]
91310
+ })));
91311
+ function ended(headers) {
91312
+ return match$8(sessionIdOf(headers), {
91313
+ onNone: () => void_$1,
91314
+ onSome: (id) => ignore$1(sessions.end(id), {
91315
+ log: "Warn",
91316
+ message: "The session could not be ended"
91317
+ })
91318
+ });
91319
+ }
91320
+ function toNext(handle) {
91321
+ return flatMap$3(HttpServerRequest, (request) => match$8(filter$5(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (next) => next.origin === canonical), {
91322
+ onNone: () => succeed$5(empty({ status: 400 })),
91323
+ onSome: (next) => handle(request, next)
91324
+ }));
91325
+ }
91326
+ yield* router.add("GET", "/auth/sign-in", toNext(fnUntraced(function* (_, next) {
91327
+ const verifier = encode$1(yield* random.randomBytes(32));
91328
+ const state = encode$1(yield* random.randomBytes(16));
91329
+ const authorize = new URL(AUTHORIZE_PATH, issuer);
91330
+ authorize.search = `${new URLSearchParams({
91331
+ client_id: yield* clientId,
91332
+ code_challenge: encode$1(yield* digest.digest(sha256, new TextEncoder().encode(verifier))),
91333
+ code_challenge_method: "S256",
91334
+ redirect_uri: callback,
91335
+ response_type: "code",
91336
+ scope: "deslop offline_access",
91337
+ state
91338
+ })}`;
91339
+ return setCookieUnsafe(redirect(authorize.href), SIGN_IN_COOKIE, yield* encodeEffect(SignInState)({
91340
+ next: next.href,
91341
+ state,
91342
+ verifier
91343
+ }), {
91344
+ ...COOKIE,
91345
+ maxAge: "10 minutes"
91346
+ });
91347
+ })));
91348
+ yield* router.add("GET", CALLBACK_PATH, gen(function* () {
91349
+ const request = yield* HttpServerRequest;
91350
+ return yield* match$8(yield* option$1(decodeUnknownEffect(SignInState)(request.cookies[SIGN_IN_COOKIE])), {
91351
+ onNone: () => signedOut(canonical, "The sign-in expired or began in another browser"),
91352
+ onSome: fnUntraced(function* (saved) {
91353
+ const started = yield* result$1(gen(function* () {
91354
+ const params = yield* schemaSearchParams(CallbackParams);
91355
+ if (params.state !== saved.state) return yield* AuthError.make({ message: "The sign-in began in another browser" });
91356
+ if (params.error !== void 0 || params.code === void 0) return yield* AuthError.make({ message: `Auth answered ${params.error ?? "without a code"}` });
91357
+ if (params.iss !== new URL("/api/auth", issuer).href) return yield* AuthError.make({ message: "The answer came from another issuer" });
91358
+ return yield* sessions.start({
91359
+ client_id: yield* clientId,
91360
+ code: params.code,
91361
+ code_verifier: saved.verifier,
91362
+ redirect_uri: callback
91363
+ });
91364
+ }));
91365
+ if (isFailure$1(started)) return yield* signedOut(saved.next, started.failure);
91366
+ return pipe(redirect(saved.next), expireCookieUnsafe(SIGN_IN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.success, {
91367
+ ...COOKIE,
91368
+ maxAge: "365 days"
91369
+ }));
91370
+ })
91371
+ });
91372
+ }));
91373
+ yield* router.add("POST", "/auth/session", gen(function* () {
91374
+ const started = yield* result$1(pipe(schemaBodyJson(CodeGrant), rejected("The sign-in request is invalid"), flatMap$3(sessions.start)));
91375
+ if (isFailure$1(started)) return text$1(started.failure.message, failureOptions(started.failure, 400));
91376
+ return yield* schemaJson(SessionHandle)({ session: started.success }, { headers: { "cache-control": "no-store" } });
91377
+ }));
91378
+ yield* router.add("GET", "/auth/sign-out", toNext((request, next) => as(ended(request.headers), expireCookieUnsafe(redirect(`${new URL("/", issuer).href}?${new URLSearchParams({
91379
+ next: next.href,
91380
+ "sign-out": ""
91381
+ })}`), SESSION_COOKIE, COOKIE))));
91382
+ yield* router.add("POST", "/auth/sign-out", as(flatMap$3(HttpServerRequest, (request) => ended(request.headers)), empty({ status: 204 })));
91383
+ }));
91384
+ }
91385
+ const layerSessionRoutes = unwrap$7(gen(function* () {
91386
+ return match$8(yield* option(String$5("AUTH_URL")), {
91387
+ onNone: () => empty$10,
91388
+ onSome: layerSignIn
91389
+ });
91390
+ }));
91418
91391
  // ../../packages/runtime/src/cli/schema.ts
91419
91392
  var AppError = class extends TaggedError()("AppError", {
91420
91393
  cause: optional$8(Defect()),
@@ -91425,7 +91398,7 @@ function systemdArgument(value) {
91425
91398
  return `"${pipe(value, replaceAll("\\", "\\\\"), replaceAll("\"", "\\\""), replaceAll("%", "%%"), replaceAll("$", "$$$$"), replaceAll("\n", "\\n"), replaceAll("\r", "\\r"))}"`;
91426
91399
  }
91427
91400
  const execute = fnUntraced(function* (command, args) {
91428
- const process = yield* make$11(command, args, {
91401
+ const process = yield* make$12(command, args, {
91429
91402
  stderr: "pipe",
91430
91403
  stdout: "pipe"
91431
91404
  });
@@ -91579,7 +91552,7 @@ const configProvider = fnUntraced(function* (given, defaultPort) {
91579
91552
  PORT: port
91580
91553
  }), fromEnv());
91581
91554
  });
91582
- const layerPlatform = mergeAll$1(layer$3, layer$16, layer$13);
91555
+ const layerPlatform = mergeAll$1(layer$4, layer$12, layer$15);
91583
91556
  function server(app) {
91584
91557
  const routes = pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(match$8(fromUndefinedOr(app.middleware), {
91585
91558
  onNone: () => empty$10,
@@ -91612,10 +91585,10 @@ function runApp(app) {
91612
91585
  },
91613
91586
  ...app.settings
91614
91587
  };
91615
- const root = pipe(make$4(name), withSharedFlags(flagsOf(settings)));
91588
+ const root = pipe(make$5(name), withSharedFlags(flagsOf(settings)));
91616
91589
  const given = map$5(root, (input) => getSomes$1(input));
91617
- return yield* pipe(root, withHandler((input) => flatMap$3(configProvider(getSomes$1(input), metadata.config.port), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$4("service"), withSubcommands([
91618
- make$4("install", {}, fnUntraced(function* () {
91590
+ return yield* pipe(root, withHandler((input) => flatMap$3(configProvider(getSomes$1(input), metadata.config.port), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$5("service"), withSubcommands([
91591
+ make$5("install", {}, fnUntraced(function* () {
91619
91592
  const fs = yield* FileSystem;
91620
91593
  const path = yield* Path$1;
91621
91594
  const flags = yield* given;
@@ -91634,15 +91607,13 @@ function runApp(app) {
91634
91607
  "update"
91635
91608
  ]);
91636
91609
  })),
91637
- make$4("status", {}, () => flatMap$3(status(name), output)),
91638
- make$4("uninstall", {}, () => flatMap$3(uninstall(name), output)),
91639
- make$4("update", {}, () => flatMap$3(update(name), output))
91610
+ make$5("status", {}, () => flatMap$3(status(name), output)),
91611
+ make$5("uninstall", {}, () => flatMap$3(uninstall(name), output)),
91612
+ make$5("update", {}, () => flatMap$3(update(name), output))
91640
91613
  ]))]), run({ version: metadata.version }));
91641
91614
  });
91642
91615
  runMain(pipe(program, scoped, provide(layerPlatform), provideService(LogToStderr, true)));
91643
91616
  }
91644
- // src/routes/icon.svg
91645
- var icon_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" shape-rendering=\"crispEdges\"><path fill=\"#000\" fill-opacity=\".18\" d=\"M17 45h1v1h-1zM15 46h3v1h-3zM13 47h4v1h-4zM15 48h4v1h-4zM46 48h1v1h-1zM17 49h4v1h-4zM46 49h3v1h-3zM19 50h4v1h-4zM47 50h4v1h-4zM21 51h4v1h-4zM45 51h4v1h-4zM23 52h4v1h-4zM43 52h4v1h-4zM25 53h4v1h-4zM41 53h4v1h-4zM27 54h4v1h-4zM39 54h4v1h-4zM29 55h4v1h-4zM37 55h4v1h-4zM31 56h8v1h-8zM33 57h4v1h-4z\"/><path fill=\"#000\" fill-opacity=\".38\" d=\"M17 47h2v1h-2zM19 48h1v1h-1zM21 49h1v1h-1zM23 50h1v1h-1zM45 50h2v1h-2zM25 51h1v1h-1zM44 51h1v1h-1zM27 52h1v1h-1zM42 52h1v1h-1zM29 53h1v1h-1zM40 53h1v1h-1zM31 54h1v1h-1zM38 54h1v1h-1zM33 55h1v1h-1zM36 55h1v1h-1z\"/><path fill=\"#4e6f72\" d=\"M18 8h4v1h-4zM16 9h2v1h-2zM22 9h2v1h-2zM15 10h1v1h-1zM24 10h2v1h-2zM15 11h1v1h-1zM26 11h2v1h-2zM15 12h1v1h-1zM28 12h2v1h-2zM15 13h1v1h-1zM30 13h2v1h-2zM15 14h1v1h-1zM32 14h2v1h-2zM15 15h1v1h-1zM34 15h2v1h-2zM15 16h1v1h-1zM36 16h2v1h-2zM15 17h1v1h-1zM38 17h2v1h-2zM15 18h1v1h-1zM40 18h2v1h-2zM15 19h1v1h-1zM42 19h2v1h-2zM15 20h1v1h-1zM44 20h2v1h-2zM15 21h1v1h-1zM46 21h2v1h-2zM15 22h1v1h-1zM48 22h1v1h-1zM15 23h1v1h-1zM48 23h1v1h-1zM15 24h1v1h-1zM48 24h1v1h-1zM15 25h1v1h-1zM48 25h1v1h-1zM15 26h1v1h-1zM48 26h1v1h-1zM15 27h1v1h-1zM48 27h1v1h-1zM15 28h1v1h-1zM48 28h1v1h-1zM15 29h1v1h-1zM48 29h1v1h-1zM15 30h1v1h-1zM48 30h1v1h-1zM15 31h1v1h-1zM48 31h1v1h-1zM15 32h1v1h-1zM48 32h1v1h-1zM16 33h2v1h-2zM48 33h1v1h-1zM18 34h2v1h-2zM48 34h1v1h-1zM20 35h2v1h-2zM48 35h1v1h-1zM22 36h2v1h-2zM48 36h1v1h-1zM24 37h2v1h-2zM48 37h1v1h-1zM26 38h2v1h-2zM48 38h1v1h-1zM48 39h1v1h-1zM48 40h1v1h-1zM48 41h1v1h-1zM48 42h1v1h-1zM48 43h1v1h-1zM48 44h1v1h-1zM46 45h2v1h-2zM44 46h2v1h-2z\"/><path fill=\"#bce6e6\" d=\"M18 9h4v1h-4zM18 10h6v1h-6zM20 11h6v1h-6zM22 12h6v1h-6zM24 13h6v1h-6zM26 14h6v1h-6zM28 15h6v1h-6zM20 16h2v1h-2zM30 16h6v1h-6zM20 17h4v1h-4zM32 17h6v1h-6zM22 18h4v1h-4zM34 18h6v1h-6zM24 19h4v1h-4zM36 19h6v1h-6zM26 20h4v1h-4zM38 20h6v1h-6zM28 21h4v1h-4zM40 21h6v1h-6zM30 22h4v1h-4zM42 22h4v1h-4zM26 23h2v1h-2zM32 23h4v1h-4zM26 24h4v1h-4zM34 24h2v1h-2zM43 24h1v1h-1zM28 25h4v1h-4zM43 25h1v1h-1zM30 26h4v1h-4zM43 26h1v1h-1zM32 27h4v1h-4zM43 27h1v1h-1zM34 28h2v1h-2zM43 28h1v1h-1zM30 29h2v1h-2zM43 29h1v1h-1zM30 30h4v1h-4zM43 30h1v1h-1zM32 31h2v1h-2zM43 31h1v1h-1zM43 32h1v1h-1zM43 33h1v1h-1zM43 34h1v1h-1zM43 35h1v1h-1zM43 36h1v1h-1zM43 37h1v1h-1zM43 38h1v1h-1zM43 39h1v1h-1zM43 40h1v1h-1zM43 41h1v1h-1zM43 42h1v1h-1zM43 43h1v1h-1zM43 44h1v1h-1zM43 45h1v1h-1z\"/><path fill=\"#daf7f7\" d=\"M16 10h2v1h-2zM18 11h2v1h-2zM20 12h2v1h-2zM22 13h2v1h-2zM24 14h2v1h-2zM26 15h2v1h-2zM28 16h2v1h-2zM30 17h2v1h-2zM32 18h2v1h-2zM34 19h2v1h-2zM36 20h2v1h-2zM38 21h2v1h-2zM40 22h2v1h-2zM46 22h2v1h-2zM42 23h4v1h-4z\"/><path fill=\"#A3D4D5\" d=\"M16 11h2v1h-2zM16 12h4v1h-4zM16 13h6v1h-6zM16 14h2v1h-2zM20 14h4v1h-4zM16 15h2v1h-2zM22 15h4v1h-4zM16 16h2v1h-2zM24 16h4v1h-4zM16 17h2v1h-2zM26 17h4v1h-4zM16 18h2v1h-2zM28 18h4v1h-4zM16 19h2v1h-2zM30 19h4v1h-4zM16 20h2v1h-2zM32 20h4v1h-4zM16 21h2v1h-2zM34 21h4v1h-4zM16 22h2v1h-2zM36 22h4v1h-4zM16 23h2v1h-2zM38 23h4v1h-4zM16 24h2v1h-2zM40 24h3v1h-3zM16 25h2v1h-2zM42 25h1v1h-1zM16 26h2v1h-2zM42 26h1v1h-1zM16 27h2v1h-2zM42 27h1v1h-1zM16 28h2v1h-2zM42 28h1v1h-1zM16 29h2v1h-2zM42 29h1v1h-1zM16 30h4v1h-4zM42 30h1v1h-1zM16 31h6v1h-6zM42 31h1v1h-1zM16 32h8v1h-8zM42 32h1v1h-1zM18 33h8v1h-8zM42 33h1v1h-1zM20 34h8v1h-8zM42 34h1v1h-1zM22 35h8v1h-8zM42 35h1v1h-1zM24 36h8v1h-8zM42 36h1v1h-1zM26 37h8v1h-8zM42 37h1v1h-1zM28 38h8v1h-8zM42 38h1v1h-1zM30 39h8v1h-8zM42 39h1v1h-1zM32 40h8v1h-8zM42 40h1v1h-1zM34 41h9v1h-9zM36 42h7v1h-7zM38 43h5v1h-5zM40 44h3v1h-3zM42 45h1v1h-1z\"/><path fill=\"#16161D\" d=\"M18 14h2v1h-2zM18 15h4v1h-4zM18 16h2v1h-2zM22 16h2v1h-2zM18 17h2v1h-2zM24 17h2v1h-2zM18 18h4v1h-4zM26 18h2v1h-2zM18 19h6v1h-6zM28 19h2v1h-2zM18 20h8v1h-8zM30 20h2v1h-2zM18 21h10v1h-10zM32 21h2v1h-2zM18 22h12v1h-12zM34 22h2v1h-2zM18 23h8v1h-8zM28 23h4v1h-4zM36 23h2v1h-2zM18 24h8v1h-8zM30 24h4v1h-4zM36 24h4v1h-4zM18 25h10v1h-10zM32 25h10v1h-10zM18 26h12v1h-12zM34 26h8v1h-8zM18 27h14v1h-14zM36 27h6v1h-6zM18 28h16v1h-16zM36 28h6v1h-6zM18 29h12v1h-12zM32 29h10v1h-10zM20 30h10v1h-10zM34 30h8v1h-8zM22 31h10v1h-10zM34 31h8v1h-8zM24 32h18v1h-18zM26 33h16v1h-16zM28 34h14v1h-14zM30 35h12v1h-12zM32 36h10v1h-10zM34 37h8v1h-8zM36 38h2v1h-2zM40 38h2v1h-2zM38 39h4v1h-4zM40 40h2v1h-2z\"/><path fill=\"#77a4a7\" d=\"M46 23h2v1h-2zM44 24h4v1h-4zM44 25h4v1h-4zM44 26h4v1h-4zM44 27h4v1h-4zM44 28h4v1h-4zM44 29h4v1h-4zM44 30h4v1h-4zM44 31h4v1h-4zM44 32h4v1h-4zM44 33h4v1h-4zM44 34h4v1h-4zM44 35h4v1h-4zM44 36h4v1h-4zM44 37h4v1h-4zM44 38h4v1h-4zM44 39h4v1h-4zM44 40h4v1h-4zM44 41h4v1h-4zM44 42h4v1h-4zM44 43h4v1h-4zM44 44h4v1h-4zM44 45h2v1h-2z\"/><path fill=\"#F2D98C\" d=\"M38 38h2v1h-2z\"/><path fill=\"#565961\" d=\"M27 39h1v1h-1zM26 40h2v1h-2zM24 41h2v1h-2zM22 42h2v1h-2zM20 43h2v1h-2zM36 43h2v1h-2zM19 44h1v1h-1zM38 44h2v1h-2zM18 45h1v1h-1zM40 45h2v1h-2zM18 46h1v1h-1zM42 46h2v1h-2zM19 47h1v1h-1zM44 47h1v1h-1zM20 48h2v1h-2zM45 48h1v1h-1zM22 49h2v1h-2zM44 49h2v1h-2zM24 50h2v1h-2zM42 50h3v1h-3zM26 51h2v1h-2zM40 51h4v1h-4zM28 52h2v1h-2zM38 52h4v1h-4zM30 53h2v1h-2zM36 53h4v1h-4zM32 54h2v1h-2zM35 54h3v1h-3zM34 55h2v1h-2z\"/><path fill=\"#B4B8C4\" d=\"M28 39h2v1h-2zM28 40h4v1h-4zM28 41h4v1h-4zM28 42h4v1h-4zM28 43h4v1h-4zM28 44h4v1h-4zM19 45h1v1h-1zM28 45h4v1h-4zM20 46h2v1h-2zM28 46h4v1h-4zM22 47h2v1h-2zM30 47h2v1h-2zM24 48h2v1h-2zM26 49h2v1h-2zM28 50h2v1h-2zM30 51h2v1h-2zM32 52h2v1h-2zM34 53h1v1h-1z\"/><path fill=\"#c8cbd6\" d=\"M26 41h2v1h-2zM24 42h4v1h-4zM22 43h6v1h-6zM20 44h8v1h-8zM36 44h2v1h-2zM20 45h8v1h-8zM36 45h4v1h-4zM22 46h6v1h-6zM36 46h6v1h-6zM24 47h6v1h-6zM34 47h10v1h-10zM26 48h18v1h-18zM28 49h14v1h-14zM30 50h10v1h-10zM32 51h6v1h-6zM34 52h2v1h-2z\"/><path fill=\"#868a95\" d=\"M32 41h2v1h-2zM32 42h4v1h-4zM32 43h4v1h-4zM32 44h4v1h-4zM32 45h4v1h-4zM32 46h4v1h-4zM32 47h2v1h-2zM44 48h1v1h-1zM42 49h2v1h-2zM40 50h2v1h-2zM38 51h2v1h-2zM36 52h2v1h-2zM35 53h1v1h-1z\"/><path fill=\"#9ea2ad\" d=\"M19 46h1v1h-1zM20 47h2v1h-2zM22 48h2v1h-2zM24 49h2v1h-2zM26 50h2v1h-2zM28 51h2v1h-2zM30 52h2v1h-2zM32 53h2v1h-2zM34 54h1v1h-1z\"/></svg>";
91646
91617
  // src/services/telemetry/schema.ts
91647
91618
  var TelemetryError = class extends TaggedError()("TelemetryError", {
91648
91619
  cause: optional$8(Defect()),
@@ -91685,7 +91656,7 @@ const Log = StructWithRest(Struct({
91685
91656
  severityNumber: optionalKey(Int$1),
91686
91657
  severityText: optionalKey(String$6),
91687
91658
  spanId: optionalKey(Union([SpanId, Literal("")])),
91688
- timeUnixNano: optionalKey(Nano),
91659
+ timeUnixNano: Nano,
91689
91660
  traceId: optionalKey(Union([TraceId, Literal("")]))
91690
91661
  }), [JsonObject]);
91691
91662
  const TracesRequest = Struct({ resourceSpans: optionalKey(ArraySchema(StructWithRest(Struct({
@@ -91713,9 +91684,6 @@ const Entry = Struct({
91713
91684
  payload: JsonObject,
91714
91685
  receivedAt: optionalKey(Natural),
91715
91686
  resource: Resource,
91716
- resourceSchemaUrl: String$6,
91717
- scope: Resource,
91718
- scopeSchemaUrl: String$6,
91719
91687
  service: String$6,
91720
91688
  signal: Literals(["trace", "log"]),
91721
91689
  spanId: String$6,
@@ -91723,12 +91691,7 @@ const Entry = Struct({
91723
91691
  time: Nano,
91724
91692
  traceId: String$6
91725
91693
  });
91726
- const EntryItem = Entry.mapFields(omit([
91727
- "resource",
91728
- "resourceSchemaUrl",
91729
- "scope",
91730
- "scopeSchemaUrl"
91731
- ]));
91694
+ const EntryItem = Entry.mapFields(omit(["resource"]));
91732
91695
  const Query = Struct({
91733
91696
  errors: Boolean$5,
91734
91697
  from: Finite,
@@ -91809,10 +91772,7 @@ const Overview = Struct({ apps: ArraySchema(Struct({
91809
91772
  runtime: Runtime,
91810
91773
  traces: ArraySchema(Struct({
91811
91774
  durationMs: Finite,
91812
- failure: optionalKey(Struct({
91813
- message: String$6,
91814
- span: String$6
91815
- })),
91775
+ failure: optionalKey(Struct({ span: String$6 })),
91816
91776
  id: TraceId,
91817
91777
  time: Nano
91818
91778
  }))
@@ -91837,6 +91797,7 @@ const TraceSpan = Struct({
91837
91797
  });
91838
91798
  const Trace = Struct({
91839
91799
  durationMs: Finite,
91800
+ failureSpanId: optionalKey(String$6),
91840
91801
  id: TraceId,
91841
91802
  logs: ArraySchema(EntryItem),
91842
91803
  services: ArraySchema(Service),
@@ -91852,24 +91813,174 @@ const Filters = Struct({
91852
91813
  traceId: pipe(Query.fields.traceId, withDecodingDefaultTypeKey(succeed$5("")), annotateEncoded({ description: "Only entries of this trace." }))
91853
91814
  });
91854
91815
  const SortFilters = Struct({
91855
- ...Struct({
91856
- ...Filters.fields,
91857
- limit: pipe(Query.fields.limit, withDecodingDefaultTypeKey(succeed$5(20)), annotateEncoded({ description: "Page size, 1 to 1000." })),
91858
- offset: pipe(Query.fields.offset, withDecodingDefaultTypeKey(succeed$5(0)), annotateEncoded({ description: "Entries to skip, for the next page." }))
91859
- }).fields,
91816
+ ...Filters.fields,
91817
+ limit: pipe(Query.fields.limit, withDecodingDefaultTypeKey(succeed$5(20)), annotateEncoded({ description: "Page size, 1 to 1000." })),
91818
+ offset: pipe(Query.fields.offset, withDecodingDefaultTypeKey(succeed$5(0)), annotateEncoded({ description: "Entries to skip, for the next page." })),
91860
91819
  sort: pipe(Query.fields.sort, withDecodingDefaultTypeKey(succeed$5("recent")), annotateEncoded({ description: "\"recent\" puts the newest first, \"slowest\" the longest first." }))
91861
91820
  });
91862
- // src/rpcs/contracts.ts
91863
- var RpcContracts = class extends make$29(make$31("scope.overview", {
91864
- error: Union([AuthError, TelemetryError]),
91865
- stream: true,
91866
- success: Overview
91867
- }), make$31("scope.trace", {
91868
- error: Union([AuthError, TelemetryError]),
91869
- payload: Struct({ id: TraceId }),
91870
- success: Trace
91871
- })).middleware(RpcAuth) {};
91821
+ // src/services/github/lib/utils.ts
91822
+ function nanos(time) {
91823
+ return `${BigInt(toEpochMillis(makeUnsafe$5(time))) * 1000000n}`;
91824
+ }
91825
+ function hex(value, width) {
91826
+ return padStart(width, "0")(value.toString(16));
91827
+ }
91828
+ function traceIdOf(run, attempt) {
91829
+ return `${hex(run, 24)}${hex(attempt, 8)}`;
91830
+ }
91831
+ function runSpanId(run) {
91832
+ return `1${hex(run, 15)}`;
91833
+ }
91834
+ function jobSpanId(job) {
91835
+ return `2${hex(job, 15)}`;
91836
+ }
91837
+ function statusOf(conclusion, message) {
91838
+ if (conclusion === "failure" || conclusion === "timed_out" || conclusion === "startup_failure") return {
91839
+ code: 2,
91840
+ message
91841
+ };
91842
+ if (conclusion === "success") return {
91843
+ code: 1,
91844
+ message: ""
91845
+ };
91846
+ return {
91847
+ code: 0,
91848
+ message: ""
91849
+ };
91850
+ }
91851
+ function text(key, value) {
91852
+ return {
91853
+ key,
91854
+ value: { stringValue: value }
91855
+ };
91856
+ }
91857
+ function repositoryTraces(repository, spans) {
91858
+ return TracesRequest.make({ resourceSpans: [{
91859
+ resource: { attributes: [text("service.name", repository), text("scope.runtime", "ci")] },
91860
+ scopeSpans: [{
91861
+ scope: { name: "github-actions" },
91862
+ spans
91863
+ }]
91864
+ }] });
91865
+ }
91866
+ function runIds(event) {
91867
+ return {
91868
+ spanId: runSpanId(event.workflow_run.id),
91869
+ traceId: traceIdOf(event.workflow_run.id, event.workflow_run.run_attempt)
91870
+ };
91871
+ }
91872
+ function runTrace(event) {
91873
+ const run = event.workflow_run;
91874
+ return repositoryTraces(event.repository.full_name, [{
91875
+ attributes: [
91876
+ text("github.title", run.display_title),
91877
+ text("github.event", run.event),
91878
+ text("git.branch", run.head_branch ?? ""),
91879
+ text("git.commit", run.head_sha),
91880
+ text("github.conclusion", run.conclusion ?? ""),
91881
+ text("url.full", run.html_url)
91882
+ ],
91883
+ kind: 1,
91884
+ name: run.name ?? run.display_title,
91885
+ parentSpanId: "",
91886
+ startTimeUnixNano: nanos(run.run_started_at),
91887
+ status: statusOf(run.conclusion, `${run.display_title} failed`),
91888
+ ...runIds(event),
91889
+ ...match$8(liftPredicate(event.action, (action) => action === "completed"), {
91890
+ onNone: () => ({}),
91891
+ onSome: () => ({ endTimeUnixNano: nanos(run.updated_at) })
91892
+ })
91893
+ }]);
91894
+ }
91895
+ function jobTrace(event) {
91896
+ const job = event.workflow_job;
91897
+ const traceId = traceIdOf(job.run_id, job.run_attempt);
91898
+ const steps = getSomes(map$8(job.steps, (step) => pipe(all$4({
91899
+ completed: fromNullishOr(step.completed_at),
91900
+ started: fromNullishOr(step.started_at)
91901
+ }), map$11((times) => ({
91902
+ ...step,
91903
+ ...times
91904
+ })))));
91905
+ const failed = findFirst(steps, (step) => statusOf(step.conclusion, "").code === 2);
91906
+ return repositoryTraces(event.repository.full_name, [{
91907
+ attributes: [
91908
+ text("github.runner", job.runner_name ?? ""),
91909
+ text("github.conclusion", job.conclusion ?? ""),
91910
+ {
91911
+ key: "github.queued_ms",
91912
+ value: { intValue: `${toEpochMillis(makeUnsafe$5(job.started_at)) - toEpochMillis(makeUnsafe$5(job.created_at))}` }
91913
+ },
91914
+ text("url.full", job.html_url)
91915
+ ],
91916
+ endTimeUnixNano: nanos(job.completed_at ?? job.started_at),
91917
+ kind: 1,
91918
+ name: job.name,
91919
+ parentSpanId: runSpanId(job.run_id),
91920
+ spanId: jobSpanId(job.id),
91921
+ startTimeUnixNano: nanos(job.started_at),
91922
+ status: statusOf(job.conclusion, match$8(failed, {
91923
+ onNone: () => `${job.name} failed`,
91924
+ onSome: (step) => `${step.name} failed`
91925
+ })),
91926
+ traceId
91927
+ }, ...map$8(steps, (step) => ({
91928
+ attributes: [text("github.conclusion", step.conclusion ?? ""), text("url.full", `${job.html_url}#step:${step.number}:1`)],
91929
+ endTimeUnixNano: nanos(step.completed),
91930
+ kind: 1,
91931
+ name: step.name,
91932
+ parentSpanId: jobSpanId(job.id),
91933
+ spanId: `3${hex(job.id, 12)}${hex(step.number, 3)}`,
91934
+ startTimeUnixNano: nanos(step.started),
91935
+ status: statusOf(step.conclusion, `${step.name} failed`),
91936
+ traceId
91937
+ }))]);
91938
+ }
91939
+ // src/services/github/schema.ts
91940
+ const Repository = Struct({ full_name: String$6 });
91941
+ const Step = Struct({
91942
+ completed_at: NullOr(String$6),
91943
+ conclusion: NullOr(String$6),
91944
+ name: String$6,
91945
+ number: Int$1,
91946
+ started_at: NullOr(String$6)
91947
+ });
91948
+ const WorkflowJob = Struct({
91949
+ action: String$6,
91950
+ repository: Repository,
91951
+ workflow_job: Struct({
91952
+ completed_at: NullOr(String$6),
91953
+ conclusion: NullOr(String$6),
91954
+ created_at: String$6,
91955
+ html_url: String$6,
91956
+ id: Int$1,
91957
+ name: String$6,
91958
+ run_attempt: Int$1,
91959
+ run_id: Int$1,
91960
+ runner_name: NullOr(String$6),
91961
+ started_at: String$6,
91962
+ steps: ArraySchema(Step)
91963
+ })
91964
+ });
91965
+ const WorkflowRun = Struct({
91966
+ action: String$6,
91967
+ repository: Repository,
91968
+ workflow_run: Struct({
91969
+ conclusion: NullOr(String$6),
91970
+ display_title: String$6,
91971
+ event: String$6,
91972
+ head_branch: NullOr(String$6),
91973
+ head_sha: String$6,
91974
+ html_url: String$6,
91975
+ id: Int$1,
91976
+ name: NullOr(String$6),
91977
+ run_attempt: Int$1,
91978
+ run_started_at: String$6,
91979
+ updated_at: String$6
91980
+ })
91981
+ });
91872
91982
  // src/services/telemetry/lib/utils.ts
91983
+ const KEEP = 20;
91873
91984
  const byRelease = mapInput(Array_(Number$6), (version) => map$8(split$2(version, "."), (part) => getOrElse(parse$3(part), () => 0)));
91874
91985
  function queryOf(filters, now) {
91875
91986
  return {
@@ -91881,9 +91992,6 @@ function queryOf(filters, now) {
91881
91992
  to: now
91882
91993
  };
91883
91994
  }
91884
- function logTime(log, now) {
91885
- return pipe(findFirst([log.timeUnixNano, log.observedTimeUnixNano], (time) => time !== void 0 && time !== "0"), flatMap$8(fromUndefinedOr), getOrElse(() => now));
91886
- }
91887
91995
  function resourceString(resource, key) {
91888
91996
  return pipe(resource.attributes ?? [], findFirst((attribute) => attribute.key === key), flatMap$8((attribute) => liftPredicate(attribute.value["stringValue"], isString$1)), getOrElse(() => ""));
91889
91997
  }
@@ -91914,7 +92022,7 @@ function newestVersions(entries, known) {
91914
92022
  }
91915
92023
  function isSuperseded(entry, newest) {
91916
92024
  const version = releaseOf(entry);
91917
- return version !== "" && exists(get$10(newest, entry.service), (latest) => isLessThan$1(byRelease)(version, latest));
92025
+ return version !== "" && exists(get$9(newest, entry.service), (latest) => isLessThan$1(byRelease)(version, latest));
91918
92026
  }
91919
92027
  function retentionOf(current, newest, receivedAt, retentionMs) {
91920
92028
  const now = BigInt(receivedAt) * 1000000n;
@@ -91956,9 +92064,6 @@ function appName(service) {
91956
92064
  function runtime(resource) {
91957
92065
  const value = resourceString(resource, "scope.runtime");
91958
92066
  if (is$2(Runtime)(value)) return value;
91959
- const language = resourceString(resource, "telemetry.sdk.language");
91960
- if (language === "webjs") return "web";
91961
- if (language === "nodejs") return "server";
91962
92067
  return "unknown";
91963
92068
  }
91964
92069
  function started(resource) {
@@ -91997,18 +92102,18 @@ function durationMs(start, end) {
91997
92102
  if (BigInt(end) < BigInt(start)) return 0;
91998
92103
  return pipe(parse$3(`${BigInt(end) - BigInt(start)}`), getOrThrow$1) / 1e6;
91999
92104
  }
92105
+ function percentile(times, ratio) {
92106
+ return getOrElse(get$8(times, max(0, Math.ceil(times.length * ratio) - 1)), () => 0);
92107
+ }
92000
92108
  function summary(entries, query) {
92001
92109
  const times = sort(map$8(entries, (entry) => entry.durationMs), Number$6);
92002
- function percentile(ratio) {
92003
- return pipe(get$9(times, max(0, Math.ceil(times.length * ratio) - 1)), getOrElse(() => 0));
92004
- }
92005
92110
  return {
92006
92111
  count: entries.length,
92007
92112
  errors: countBy(entries, (entry) => entry.status === 2),
92008
92113
  from: query.from,
92009
- maxMs: percentile(1),
92010
- p50Ms: percentile(.5),
92011
- p95Ms: percentile(.95),
92114
+ maxMs: percentile(times, 1),
92115
+ p50Ms: percentile(times, .5),
92116
+ p95Ms: percentile(times, .95),
92012
92117
  to: query.to
92013
92118
  };
92014
92119
  }
@@ -92067,6 +92172,14 @@ function parentId(entry) {
92067
92172
  if (isString$1(entry.payload["parentSpanId"])) return toLowerCase(entry.payload["parentSpanId"]);
92068
92173
  return "";
92069
92174
  }
92175
+ function brokeAt(spans) {
92176
+ const failed = filter$3(spans, (span) => span.status === 2);
92177
+ const parents = fromIterable$2(map$8(failed, parentId));
92178
+ return match$6(filter$3(failed, (span) => !has(parents, span.spanId)), {
92179
+ onEmpty: () => none(),
92180
+ onNonEmpty: (candidates) => some$1(min(candidates, byStart))
92181
+ });
92182
+ }
92070
92183
  function traceView(entries, id) {
92071
92184
  const ordered = reverse(orderEntries(entries, "recent"));
92072
92185
  const spans = map$8(filter$3(ordered, (entry) => entry.signal === "trace"), (entry, index) => ({
@@ -92077,11 +92190,12 @@ function traceView(entries, id) {
92077
92190
  const timing = traceTiming(entries);
92078
92191
  const logs = filter$3(ordered, (entry) => entry.signal === "log");
92079
92192
  const bySpan = groupBy(logs, (log) => log.spanId);
92193
+ const broken = brokeAt(map$8(spans, (span) => span.entry));
92080
92194
  const tree = pipe(map$8(spans, (span) => {
92081
92195
  const ancestors = reverse(unfold({
92082
92196
  entry: span.entry,
92083
92197
  seen: make$66(span.entry.spanId)
92084
- }, (current) => pipe(get$10(byId, parentId(current.entry)), filter$5((parent) => !has(current.seen, parent.entry.spanId)), map$11((parent) => [parent, {
92198
+ }, (current) => pipe(get$9(byId, parentId(current.entry)), filter$5((parent) => !has(current.seen, parent.entry.spanId)), map$11((parent) => [parent, {
92085
92199
  entry: parent.entry,
92086
92200
  seen: add$1(current.seen, parent.entry.spanId)
92087
92201
  }]))));
@@ -92090,7 +92204,7 @@ function traceView(entries, id) {
92090
92204
  value: {
92091
92205
  ...span.entry,
92092
92206
  depth: ancestors.length,
92093
- logs: getOrElse(get$10(bySpan, span.entry.spanId), () => []),
92207
+ logs: getOrElse(get$9(bySpan, span.entry.spanId), () => []),
92094
92208
  offsetMs: durationMs(timing.time, span.entry.time),
92095
92209
  parentSpanId: parentId(span.entry),
92096
92210
  runtime: runtime(span.entry.resource)
@@ -92099,6 +92213,10 @@ function traceView(entries, id) {
92099
92213
  }), sort(Struct$1({ path: Array_(Number$6) })), map$8((node) => node.value));
92100
92214
  return {
92101
92215
  durationMs: timing.durationMs,
92216
+ ...match$8(broken, {
92217
+ onNone: () => ({}),
92218
+ onSome: (span) => ({ failureSpanId: span.spanId })
92219
+ }),
92102
92220
  id,
92103
92221
  logs: filter$3(logs, (log) => !has$4(byId, log.spanId)),
92104
92222
  services: dedupeWith(map$8([...tree, ...logs], (entry) => ({
@@ -92129,14 +92247,6 @@ function subscription(root, spans) {
92129
92247
  function failureCount(group) {
92130
92248
  return countBy(group, (item) => item.trace.failure !== void 0);
92131
92249
  }
92132
- function brokeAt(spans) {
92133
- const failed = filter$3(spans, (span) => span.status === 2);
92134
- const parents = fromIterable$2(map$8(failed, parentId));
92135
- return match$6(filter$3(failed, (span) => !has(parents, span.spanId)), {
92136
- onEmpty: () => none(),
92137
- onNonEmpty: (candidates) => some$1(min(candidates, byStart))
92138
- });
92139
- }
92140
92250
  function traced(records, now) {
92141
92251
  return flatMap$8(match$6(filter$3(records, (entry) => entry.signal === "trace"), {
92142
92252
  onEmpty: () => none(),
@@ -92154,10 +92264,7 @@ function traced(records, now) {
92154
92264
  durationMs: timing.durationMs,
92155
92265
  ...match$8(brokeAt(spans), {
92156
92266
  onNone: () => ({}),
92157
- onSome: (span) => ({ failure: {
92158
- message: pipe(fromNullishOr(span.payload["status"]), filter$5(isObject$2), flatMap$8((status) => fromNullishOr(get$6(status, "message"))), filter$5(isString$1), getOrElse(() => "")),
92159
- span: span.name
92160
- } })
92267
+ onSome: (span) => ({ failure: { span: span.name } })
92161
92268
  }),
92162
92269
  id: root.traceId,
92163
92270
  time: timing.time
@@ -92165,23 +92272,23 @@ function traced(records, now) {
92165
92272
  });
92166
92273
  });
92167
92274
  }
92168
- function operationsOf(group, keep) {
92169
- return sort(map$8(toEntries(groupBy(group, (item) => `${item.runtime} ${item.name}`)), (entry) => {
92275
+ function operationsOf(group) {
92276
+ return map$8(toEntries(groupBy(group, (item) => `${item.runtime} ${item.name}`)), (entry) => {
92170
92277
  const times = sort(map$8(entry[1], (item) => item.trace.durationMs), Number$6);
92171
92278
  return {
92172
92279
  count: entry[1].length,
92173
92280
  failures: failureCount(entry[1]),
92174
92281
  name: headNonEmpty(entry[1]).name,
92175
- p50Ms: getOrElse(get$9(times, max(0, Math.ceil(times.length / 2) - 1)), () => 0),
92282
+ p50Ms: percentile(times, .5),
92176
92283
  runtime: headNonEmpty(entry[1]).runtime,
92177
- traces: map$8(sort(take$3(dedupeWith([...take$3(sort(filter$3(entry[1], (item) => item.trace.failure !== void 0), flip$2(mapInput(byTime, (item) => item.trace.time))), keep / 2), ...sort(entry[1], mapInput(flip$2(Number$6), (item) => item.trace.durationMs))], (first, second) => first.trace.id === second.trace.id), keep), mapInput(flip$2(Number$6), (item) => item.trace.durationMs)), (item) => item.trace)
92284
+ traces: map$8(sort(take$3(dedupeWith([...take$3(sort(filter$3(entry[1], (item) => item.trace.failure !== void 0), flip$2(mapInput(byTime, (item) => item.trace.time))), KEEP / 2), ...sort(entry[1], mapInput(flip$2(Number$6), (item) => item.trace.durationMs))], (first, second) => first.trace.id === second.trace.id), KEEP), mapInput(flip$2(Number$6), (item) => item.trace.durationMs)), (item) => item.trace)
92178
92285
  };
92179
- }), combine$2(mapInput(flip$2(Number$6), (operation) => operation.failures), mapInput(flip$2(Number$6), (operation) => operation.count)));
92286
+ });
92180
92287
  }
92181
- function overview(entries, keep, now) {
92288
+ function overview(entries, now) {
92182
92289
  return { apps: map$8(sort(values$2(groupBy(getSomes(map$8(values$2(groupBy(filter$3(entries, (entry) => entry.traceId !== ""), (entry) => entry.traceId)), (records) => traced(records, now))), (item) => item.app)), combine$2(mapInput(flip$2(Number$6), (group) => failureCount(group)), mapInput(flip$2(Number$6), (group) => group.length))), (group) => ({
92183
92290
  name: headNonEmpty(group).app,
92184
- operations: operationsOf(group, keep)
92291
+ operations: operationsOf(group)
92185
92292
  })) };
92186
92293
  }
92187
92294
  // src/services/telemetry/service.ts
@@ -92263,7 +92370,7 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92263
92370
  }), flatMap$1(() => concat$1(fromEffect(pipe(all$1({
92264
92371
  entries: read,
92265
92372
  now: currentTimeMillis
92266
- }, { concurrency: "unbounded" }), map$5((current) => overview(current.entries, 20, current.now)))), drain(fromEffect(sleep("1 second"))))), share({
92373
+ }, { concurrency: "unbounded" }), map$5((current) => overview(current.entries, current.now)))), drain(fromEffect(sleep("1 second"))))), share({
92267
92374
  capacity: 1,
92268
92375
  replay: 1,
92269
92376
  strategy: "sliding"
@@ -92278,7 +92385,6 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92278
92385
  return {
92279
92386
  ingestLogs: fn("Telemetry.ingestLogs")(function* (payload) {
92280
92387
  const receivedAt = yield* currentTimeMillis;
92281
- const now = `${BigInt(receivedAt) * 1000000n}`;
92282
92388
  yield* save(yield* forEach$1(flatMap$6(payload.resourceLogs ?? [], (group) => flatMap$6(group.scopeLogs ?? [], (scope) => map$8(scope.logRecords ?? [], (log) => ({
92283
92389
  group,
92284
92390
  log,
@@ -92290,9 +92396,6 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92290
92396
  payload: item.log,
92291
92397
  receivedAt,
92292
92398
  resource: item.group.resource ?? {},
92293
- resourceSchemaUrl: item.group.schemaUrl ?? "",
92294
- scope: item.scope.scope ?? {},
92295
- scopeSchemaUrl: item.scope.schemaUrl ?? "",
92296
92399
  service: serviceName(item.group.resource ?? {}),
92297
92400
  signal: "log",
92298
92401
  spanId: toLowerCase(item.log.spanId ?? ""),
@@ -92300,7 +92403,7 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92300
92403
  onFalse: () => 0,
92301
92404
  onTrue: () => 2
92302
92405
  }),
92303
- time: logTime(item.log, now),
92406
+ time: item.log.timeUnixNano,
92304
92407
  traceId: toLowerCase(item.log.traceId ?? "")
92305
92408
  })), { concurrency: 1 }));
92306
92409
  }),
@@ -92313,9 +92416,6 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92313
92416
  payload: span,
92314
92417
  receivedAt,
92315
92418
  resource: group.resource ?? {},
92316
- resourceSchemaUrl: group.schemaUrl ?? "",
92317
- scope: scope.scope ?? {},
92318
- scopeSchemaUrl: scope.schemaUrl ?? "",
92319
92419
  service: serviceName(group.resource ?? {}),
92320
92420
  signal: "trace",
92321
92421
  spanId: toLowerCase(span.spanId),
@@ -92368,7 +92468,7 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92368
92468
  entries: map$8(take$3(drop$1(ordered, query.offset), query.limit), (found) => {
92369
92469
  const records = byTrace[found.id] ?? [];
92370
92470
  const view = traceView(records, found.id);
92371
- const root = getOrElse(head(view.spans), () => getOrThrow$1(head(records)));
92471
+ const root = getOrThrow$1(head(view.spans));
92372
92472
  return {
92373
92473
  durationMs: found.durationMs,
92374
92474
  errors: countBy(records, (entry) => entry.status === 2),
@@ -92388,215 +92488,7 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
92388
92488
  }, failed) }) {
92389
92489
  static layer = (directory) => pipe(effect(this, this.make(directory)), provide$2(layerKeyValueStore(directory)));
92390
92490
  };
92391
- // src/rpcs/handlers.ts
92392
- const RpcHandlers = RpcContracts.toLayer(gen(function* () {
92393
- const telemetry = yield* Telemetry;
92394
- return RpcContracts.of({
92395
- "scope.overview": () => telemetry.overview,
92396
- "scope.trace": (input) => telemetry.trace(input.id)
92397
- });
92398
- }));
92399
- // src/services/github/lib/utils.ts
92400
- function nanos(time) {
92401
- return `${BigInt(toEpochMillis(makeUnsafe$5(time))) * 1000000n}`;
92402
- }
92403
- function hex(value, width) {
92404
- return padStart(width, "0")(value.toString(16));
92405
- }
92406
- function traceIdOf(run, attempt) {
92407
- return `${hex(run, 24)}${hex(attempt, 8)}`;
92408
- }
92409
- function runSpanId(run) {
92410
- return `1${hex(run, 15)}`;
92411
- }
92412
- function jobSpanId(job) {
92413
- return `2${hex(job, 15)}`;
92414
- }
92415
- function statusOf(conclusion, message) {
92416
- if (conclusion === "failure" || conclusion === "timed_out" || conclusion === "startup_failure") return {
92417
- code: 2,
92418
- message
92419
- };
92420
- if (conclusion === "success") return {
92421
- code: 1,
92422
- message: ""
92423
- };
92424
- return {
92425
- code: 0,
92426
- message: ""
92427
- };
92428
- }
92429
- function text(key, value) {
92430
- return {
92431
- key,
92432
- value: { stringValue: value }
92433
- };
92434
- }
92435
- function repositoryTraces(repository, spans) {
92436
- return TracesRequest.make({ resourceSpans: [{
92437
- resource: { attributes: [text("service.name", repository), text("scope.runtime", "ci")] },
92438
- scopeSpans: [{
92439
- scope: { name: "github-actions" },
92440
- spans
92441
- }]
92442
- }] });
92443
- }
92444
- function runIds(event) {
92445
- return {
92446
- spanId: runSpanId(event.workflow_run.id),
92447
- traceId: traceIdOf(event.workflow_run.id, event.workflow_run.run_attempt)
92448
- };
92449
- }
92450
- function runTrace(event) {
92451
- const run = event.workflow_run;
92452
- return repositoryTraces(event.repository.full_name, [{
92453
- attributes: [
92454
- text("github.title", run.display_title),
92455
- text("github.event", run.event),
92456
- text("git.branch", run.head_branch ?? ""),
92457
- text("git.commit", run.head_sha),
92458
- text("github.conclusion", run.conclusion ?? ""),
92459
- text("url.full", run.html_url)
92460
- ],
92461
- kind: 1,
92462
- name: run.name ?? run.display_title,
92463
- parentSpanId: "",
92464
- startTimeUnixNano: nanos(run.run_started_at),
92465
- status: statusOf(run.conclusion, `${run.display_title} failed`),
92466
- ...runIds(event),
92467
- ...match$8(liftPredicate(event.action, (action) => action === "completed"), {
92468
- onNone: () => ({}),
92469
- onSome: () => ({ endTimeUnixNano: nanos(run.updated_at) })
92470
- })
92471
- }]);
92472
- }
92473
- function jobTrace(event) {
92474
- const job = event.workflow_job;
92475
- const traceId = traceIdOf(job.run_id, job.run_attempt);
92476
- const steps = getSomes(map$8(job.steps, (step) => pipe(all$4({
92477
- completed: fromNullishOr(step.completed_at),
92478
- started: fromNullishOr(step.started_at)
92479
- }), filter$5(() => step.conclusion !== "skipped"), map$11((times) => ({
92480
- ...step,
92481
- ...times
92482
- })))));
92483
- const failed = findFirst(steps, (step) => statusOf(step.conclusion, "").code === 2);
92484
- return repositoryTraces(event.repository.full_name, [{
92485
- attributes: [
92486
- text("github.runner", job.runner_name ?? ""),
92487
- text("github.conclusion", job.conclusion ?? ""),
92488
- {
92489
- key: "github.queued_ms",
92490
- value: { intValue: `${toEpochMillis(makeUnsafe$5(job.started_at)) - toEpochMillis(makeUnsafe$5(job.created_at))}` }
92491
- },
92492
- text("url.full", job.html_url)
92493
- ],
92494
- endTimeUnixNano: nanos(job.completed_at ?? job.started_at),
92495
- kind: 1,
92496
- name: job.name,
92497
- parentSpanId: runSpanId(job.run_id),
92498
- spanId: jobSpanId(job.id),
92499
- startTimeUnixNano: nanos(job.started_at),
92500
- status: statusOf(job.conclusion, match$8(failed, {
92501
- onNone: () => `${job.name} failed`,
92502
- onSome: (step) => `${step.name} failed`
92503
- })),
92504
- traceId
92505
- }, ...map$8(steps, (step) => ({
92506
- attributes: [text("github.conclusion", step.conclusion ?? ""), text("url.full", `${job.html_url}#step:${step.number}:1`)],
92507
- endTimeUnixNano: nanos(step.completed),
92508
- kind: 1,
92509
- name: step.name,
92510
- parentSpanId: jobSpanId(job.id),
92511
- spanId: `3${hex(job.id, 12)}${hex(step.number, 3)}`,
92512
- startTimeUnixNano: nanos(step.started),
92513
- status: statusOf(step.conclusion, `${step.name} failed`),
92514
- traceId
92515
- }))]);
92516
- }
92517
- // src/services/github/schema.ts
92518
- const Repository = Struct({ full_name: String$6 });
92519
- const Step = Struct({
92520
- completed_at: NullOr(String$6),
92521
- conclusion: NullOr(String$6),
92522
- name: String$6,
92523
- number: Int$1,
92524
- started_at: NullOr(String$6)
92525
- });
92526
- const WorkflowJob = Struct({
92527
- action: String$6,
92528
- repository: Repository,
92529
- workflow_job: Struct({
92530
- completed_at: NullOr(String$6),
92531
- conclusion: NullOr(String$6),
92532
- created_at: String$6,
92533
- html_url: String$6,
92534
- id: Int$1,
92535
- name: String$6,
92536
- run_attempt: Int$1,
92537
- run_id: Int$1,
92538
- runner_name: NullOr(String$6),
92539
- started_at: String$6,
92540
- steps: ArraySchema(Step)
92541
- })
92542
- });
92543
- const WorkflowRun = Struct({
92544
- action: String$6,
92545
- repository: Repository,
92546
- workflow_run: Struct({
92547
- conclusion: NullOr(String$6),
92548
- display_title: String$6,
92549
- event: String$6,
92550
- head_branch: NullOr(String$6),
92551
- head_sha: String$6,
92552
- html_url: String$6,
92553
- id: Int$1,
92554
- name: NullOr(String$6),
92555
- run_attempt: Int$1,
92556
- run_number: Int$1,
92557
- run_started_at: String$6,
92558
- updated_at: String$6
92559
- })
92560
- });
92561
- // src/tools/contracts.ts
92562
- const Tools = make$37(make$38("list_services", {
92563
- description: "Start here: each service with its latest run, release, last event and entry count, plus rejected exports. Only each service's newest release is kept, so nothing here predates it. A service missing here sent nothing in the last three days.",
92564
- failure: TelemetryError,
92565
- success: IngestionStatus
92566
- }).annotate(Readonly, true), make$38("find", {
92567
- description: "Find traces (one request or action each), single spans with their attributes, or logs, newest or slowest first; searches the latest run of each service unless runs is \"all\". Open a trace with read_trace.",
92568
- failure: TelemetryError,
92569
- parameters: Struct({
92570
- ...SortFilters.fields,
92571
- kind: Literals([
92572
- "traces",
92573
- "spans",
92574
- "logs"
92575
- ]).annotate({ description: "What to find." })
92576
- }),
92577
- success: Union([TracesPage, Page])
92578
- }).annotate(Readonly, true), make$38("read_trace", {
92579
- description: "One trace whole: every span in order with its depth, offset, duration and logs.",
92580
- failure: TelemetryError,
92581
- parameters: Struct({ id: pipe(TraceId, annotateEncoded({ description: "The 32-character id from find." })) }),
92582
- success: Trace
92583
- }).annotate(Readonly, true), make$38("measure_latency", {
92584
- description: "Count, errors and p50, p95 and max milliseconds of the matching spans; run it before and after a change to compare.",
92585
- failure: TelemetryError,
92586
- parameters: Filters,
92587
- success: Stats
92588
- }).annotate(Readonly, true));
92589
- // src/tools/handlers.ts
92590
- const ToolHandlers = Tools.toLayer(gen(function* () {
92591
- const telemetry = yield* Telemetry;
92592
- return Tools.of({
92593
- find: (input) => flatMap$3(currentTimeMillis, (now) => pipe(value(input.kind), when("traces", () => telemetry.traces(queryOf(input, now))), when("spans", () => telemetry.spans(queryOf(input, now))), when("logs", () => telemetry.logs(queryOf(input, now))), exhaustive)),
92594
- list_services: () => telemetry.services(),
92595
- measure_latency: (filters) => flatMap$3(currentTimeMillis, (now) => telemetry.stats(queryOf(filters, now))),
92596
- read_trace: (input) => telemetry.trace(input.id)
92597
- });
92598
- }));
92599
- // src/main.server.ts
92491
+ // src/http/handlers.ts
92600
92492
  const cors = cors$1({
92601
92493
  allowedHeaders: ["content-type"],
92602
92494
  allowedMethods: ["POST"]
@@ -92620,7 +92512,11 @@ function answer(schema, save) {
92620
92512
  }));
92621
92513
  });
92622
92514
  }
92623
- const receiver = use((router) => gen(function* () {
92515
+ const Signature = pipe(String$6, check(isPattern(/^sha256=[0-9a-f]{64}$/u)), decodeTo(Uint8ArrayFromHex, {
92516
+ decode: transform$3(slice$1(7)),
92517
+ encode: transform$3((tag) => `sha256=${tag}`)
92518
+ }));
92519
+ const HttpHandlers = use((router) => gen(function* () {
92624
92520
  const telemetry = yield* Telemetry;
92625
92521
  const ingest = fnUntraced(function* (route, schema, save) {
92626
92522
  const request = yield* HttpServerRequest;
@@ -92643,48 +92539,101 @@ const receiver = use((router) => gen(function* () {
92643
92539
  yield* router.add("POST", "/v1/logs", cors(ingest("/v1/logs", LogsRequest, telemetry.ingestLogs)));
92644
92540
  yield* router.add("OPTIONS", "/v1/*", cors(succeed$5(empty())));
92645
92541
  yield* router.add("GET", "/health", text$1("ready"));
92542
+ const mac = yield* Mac;
92543
+ yield* match$8(yield* option(Redacted("GITHUB_WEBHOOK_SECRET")), {
92544
+ onNone: () => void_$1,
92545
+ onSome: fnUntraced(function* (secret) {
92546
+ const key = yield* key$1(hmacSha256, new TextEncoder().encode(value$2(secret)));
92547
+ yield* router.add("POST", "/v1/github", catchTags(gen(function* () {
92548
+ const request = yield* HttpServerRequest;
92549
+ const body = new Uint8Array(yield* request.arrayBuffer);
92550
+ if (!(yield* match$8(decodeOption(Signature)(request.headers["x-hub-signature-256"] ?? ""), {
92551
+ onNone: () => succeed$5(false),
92552
+ onSome: (tag) => mac.verify(key, tag, body)
92553
+ }))) return empty({ status: 401 });
92554
+ const text = new TextDecoder().decode(body);
92555
+ if (request.headers["x-github-event"] === "workflow_run") {
92556
+ const event = yield* decodeEffect(fromJsonString(WorkflowRun))(text);
92557
+ const ids = runIds(event);
92558
+ const finished = yield* map$5(option$1(telemetry.trace(ids.traceId)), exists((trace) => some(trace.spans, (span) => span.spanId === ids.spanId && isString$2(span.payload["endTimeUnixNano"]))));
92559
+ if (event.action === "completed" || event.action === "in_progress" && !finished) yield* telemetry.ingestTraces(runTrace(event));
92560
+ }
92561
+ if (request.headers["x-github-event"] === "workflow_job") {
92562
+ const event = yield* decodeEffect(fromJsonString(WorkflowJob))(text);
92563
+ if (event.action === "completed" && event.workflow_job.conclusion !== "skipped") yield* telemetry.ingestTraces(jobTrace(event));
92564
+ }
92565
+ return empty({ status: 204 });
92566
+ }), {
92567
+ CryptoError: () => succeed$5(empty({ status: 401 })),
92568
+ HttpServerError: () => succeed$5(empty({ status: 400 })),
92569
+ SchemaError: (error) => succeed$5(text$1(error.message, { status: 400 })),
92570
+ TelemetryError: () => succeed$5(empty({ status: 503 }))
92571
+ }));
92572
+ })
92573
+ });
92646
92574
  }));
92647
- const Signature = pipe(String$6, check(isPattern(/^sha256=[0-9a-f]{64}$/u)), decodeTo(Uint8ArrayFromHex, {
92648
- decode: transform$3(slice$1(7)),
92649
- encode: transform$3((tag) => `sha256=${tag}`)
92575
+ // src/routes/icon.svg
92576
+ var icon_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" shape-rendering=\"crispEdges\"><path fill=\"#000\" fill-opacity=\".18\" d=\"M17 45h1v1h-1zM15 46h3v1h-3zM13 47h4v1h-4zM15 48h4v1h-4zM46 48h1v1h-1zM17 49h4v1h-4zM46 49h3v1h-3zM19 50h4v1h-4zM47 50h4v1h-4zM21 51h4v1h-4zM45 51h4v1h-4zM23 52h4v1h-4zM43 52h4v1h-4zM25 53h4v1h-4zM41 53h4v1h-4zM27 54h4v1h-4zM39 54h4v1h-4zM29 55h4v1h-4zM37 55h4v1h-4zM31 56h8v1h-8zM33 57h4v1h-4z\"/><path fill=\"#000\" fill-opacity=\".38\" d=\"M17 47h2v1h-2zM19 48h1v1h-1zM21 49h1v1h-1zM23 50h1v1h-1zM45 50h2v1h-2zM25 51h1v1h-1zM44 51h1v1h-1zM27 52h1v1h-1zM42 52h1v1h-1zM29 53h1v1h-1zM40 53h1v1h-1zM31 54h1v1h-1zM38 54h1v1h-1zM33 55h1v1h-1zM36 55h1v1h-1z\"/><path fill=\"#4e6f72\" d=\"M18 8h4v1h-4zM16 9h2v1h-2zM22 9h2v1h-2zM15 10h1v1h-1zM24 10h2v1h-2zM15 11h1v1h-1zM26 11h2v1h-2zM15 12h1v1h-1zM28 12h2v1h-2zM15 13h1v1h-1zM30 13h2v1h-2zM15 14h1v1h-1zM32 14h2v1h-2zM15 15h1v1h-1zM34 15h2v1h-2zM15 16h1v1h-1zM36 16h2v1h-2zM15 17h1v1h-1zM38 17h2v1h-2zM15 18h1v1h-1zM40 18h2v1h-2zM15 19h1v1h-1zM42 19h2v1h-2zM15 20h1v1h-1zM44 20h2v1h-2zM15 21h1v1h-1zM46 21h2v1h-2zM15 22h1v1h-1zM48 22h1v1h-1zM15 23h1v1h-1zM48 23h1v1h-1zM15 24h1v1h-1zM48 24h1v1h-1zM15 25h1v1h-1zM48 25h1v1h-1zM15 26h1v1h-1zM48 26h1v1h-1zM15 27h1v1h-1zM48 27h1v1h-1zM15 28h1v1h-1zM48 28h1v1h-1zM15 29h1v1h-1zM48 29h1v1h-1zM15 30h1v1h-1zM48 30h1v1h-1zM15 31h1v1h-1zM48 31h1v1h-1zM15 32h1v1h-1zM48 32h1v1h-1zM16 33h2v1h-2zM48 33h1v1h-1zM18 34h2v1h-2zM48 34h1v1h-1zM20 35h2v1h-2zM48 35h1v1h-1zM22 36h2v1h-2zM48 36h1v1h-1zM24 37h2v1h-2zM48 37h1v1h-1zM26 38h2v1h-2zM48 38h1v1h-1zM48 39h1v1h-1zM48 40h1v1h-1zM48 41h1v1h-1zM48 42h1v1h-1zM48 43h1v1h-1zM48 44h1v1h-1zM46 45h2v1h-2zM44 46h2v1h-2z\"/><path fill=\"#bce6e6\" d=\"M18 9h4v1h-4zM18 10h6v1h-6zM20 11h6v1h-6zM22 12h6v1h-6zM24 13h6v1h-6zM26 14h6v1h-6zM28 15h6v1h-6zM20 16h2v1h-2zM30 16h6v1h-6zM20 17h4v1h-4zM32 17h6v1h-6zM22 18h4v1h-4zM34 18h6v1h-6zM24 19h4v1h-4zM36 19h6v1h-6zM26 20h4v1h-4zM38 20h6v1h-6zM28 21h4v1h-4zM40 21h6v1h-6zM30 22h4v1h-4zM42 22h4v1h-4zM26 23h2v1h-2zM32 23h4v1h-4zM26 24h4v1h-4zM34 24h2v1h-2zM43 24h1v1h-1zM28 25h4v1h-4zM43 25h1v1h-1zM30 26h4v1h-4zM43 26h1v1h-1zM32 27h4v1h-4zM43 27h1v1h-1zM34 28h2v1h-2zM43 28h1v1h-1zM30 29h2v1h-2zM43 29h1v1h-1zM30 30h4v1h-4zM43 30h1v1h-1zM32 31h2v1h-2zM43 31h1v1h-1zM43 32h1v1h-1zM43 33h1v1h-1zM43 34h1v1h-1zM43 35h1v1h-1zM43 36h1v1h-1zM43 37h1v1h-1zM43 38h1v1h-1zM43 39h1v1h-1zM43 40h1v1h-1zM43 41h1v1h-1zM43 42h1v1h-1zM43 43h1v1h-1zM43 44h1v1h-1zM43 45h1v1h-1z\"/><path fill=\"#daf7f7\" d=\"M16 10h2v1h-2zM18 11h2v1h-2zM20 12h2v1h-2zM22 13h2v1h-2zM24 14h2v1h-2zM26 15h2v1h-2zM28 16h2v1h-2zM30 17h2v1h-2zM32 18h2v1h-2zM34 19h2v1h-2zM36 20h2v1h-2zM38 21h2v1h-2zM40 22h2v1h-2zM46 22h2v1h-2zM42 23h4v1h-4z\"/><path fill=\"#A3D4D5\" d=\"M16 11h2v1h-2zM16 12h4v1h-4zM16 13h6v1h-6zM16 14h2v1h-2zM20 14h4v1h-4zM16 15h2v1h-2zM22 15h4v1h-4zM16 16h2v1h-2zM24 16h4v1h-4zM16 17h2v1h-2zM26 17h4v1h-4zM16 18h2v1h-2zM28 18h4v1h-4zM16 19h2v1h-2zM30 19h4v1h-4zM16 20h2v1h-2zM32 20h4v1h-4zM16 21h2v1h-2zM34 21h4v1h-4zM16 22h2v1h-2zM36 22h4v1h-4zM16 23h2v1h-2zM38 23h4v1h-4zM16 24h2v1h-2zM40 24h3v1h-3zM16 25h2v1h-2zM42 25h1v1h-1zM16 26h2v1h-2zM42 26h1v1h-1zM16 27h2v1h-2zM42 27h1v1h-1zM16 28h2v1h-2zM42 28h1v1h-1zM16 29h2v1h-2zM42 29h1v1h-1zM16 30h4v1h-4zM42 30h1v1h-1zM16 31h6v1h-6zM42 31h1v1h-1zM16 32h8v1h-8zM42 32h1v1h-1zM18 33h8v1h-8zM42 33h1v1h-1zM20 34h8v1h-8zM42 34h1v1h-1zM22 35h8v1h-8zM42 35h1v1h-1zM24 36h8v1h-8zM42 36h1v1h-1zM26 37h8v1h-8zM42 37h1v1h-1zM28 38h8v1h-8zM42 38h1v1h-1zM30 39h8v1h-8zM42 39h1v1h-1zM32 40h8v1h-8zM42 40h1v1h-1zM34 41h9v1h-9zM36 42h7v1h-7zM38 43h5v1h-5zM40 44h3v1h-3zM42 45h1v1h-1z\"/><path fill=\"#16161D\" d=\"M18 14h2v1h-2zM18 15h4v1h-4zM18 16h2v1h-2zM22 16h2v1h-2zM18 17h2v1h-2zM24 17h2v1h-2zM18 18h4v1h-4zM26 18h2v1h-2zM18 19h6v1h-6zM28 19h2v1h-2zM18 20h8v1h-8zM30 20h2v1h-2zM18 21h10v1h-10zM32 21h2v1h-2zM18 22h12v1h-12zM34 22h2v1h-2zM18 23h8v1h-8zM28 23h4v1h-4zM36 23h2v1h-2zM18 24h8v1h-8zM30 24h4v1h-4zM36 24h4v1h-4zM18 25h10v1h-10zM32 25h10v1h-10zM18 26h12v1h-12zM34 26h8v1h-8zM18 27h14v1h-14zM36 27h6v1h-6zM18 28h16v1h-16zM36 28h6v1h-6zM18 29h12v1h-12zM32 29h10v1h-10zM20 30h10v1h-10zM34 30h8v1h-8zM22 31h10v1h-10zM34 31h8v1h-8zM24 32h18v1h-18zM26 33h16v1h-16zM28 34h14v1h-14zM30 35h12v1h-12zM32 36h10v1h-10zM34 37h8v1h-8zM36 38h2v1h-2zM40 38h2v1h-2zM38 39h4v1h-4zM40 40h2v1h-2z\"/><path fill=\"#77a4a7\" d=\"M46 23h2v1h-2zM44 24h4v1h-4zM44 25h4v1h-4zM44 26h4v1h-4zM44 27h4v1h-4zM44 28h4v1h-4zM44 29h4v1h-4zM44 30h4v1h-4zM44 31h4v1h-4zM44 32h4v1h-4zM44 33h4v1h-4zM44 34h4v1h-4zM44 35h4v1h-4zM44 36h4v1h-4zM44 37h4v1h-4zM44 38h4v1h-4zM44 39h4v1h-4zM44 40h4v1h-4zM44 41h4v1h-4zM44 42h4v1h-4zM44 43h4v1h-4zM44 44h4v1h-4zM44 45h2v1h-2z\"/><path fill=\"#F2D98C\" d=\"M38 38h2v1h-2z\"/><path fill=\"#565961\" d=\"M27 39h1v1h-1zM26 40h2v1h-2zM24 41h2v1h-2zM22 42h2v1h-2zM20 43h2v1h-2zM36 43h2v1h-2zM19 44h1v1h-1zM38 44h2v1h-2zM18 45h1v1h-1zM40 45h2v1h-2zM18 46h1v1h-1zM42 46h2v1h-2zM19 47h1v1h-1zM44 47h1v1h-1zM20 48h2v1h-2zM45 48h1v1h-1zM22 49h2v1h-2zM44 49h2v1h-2zM24 50h2v1h-2zM42 50h3v1h-3zM26 51h2v1h-2zM40 51h4v1h-4zM28 52h2v1h-2zM38 52h4v1h-4zM30 53h2v1h-2zM36 53h4v1h-4zM32 54h2v1h-2zM35 54h3v1h-3zM34 55h2v1h-2z\"/><path fill=\"#B4B8C4\" d=\"M28 39h2v1h-2zM28 40h4v1h-4zM28 41h4v1h-4zM28 42h4v1h-4zM28 43h4v1h-4zM28 44h4v1h-4zM19 45h1v1h-1zM28 45h4v1h-4zM20 46h2v1h-2zM28 46h4v1h-4zM22 47h2v1h-2zM30 47h2v1h-2zM24 48h2v1h-2zM26 49h2v1h-2zM28 50h2v1h-2zM30 51h2v1h-2zM32 52h2v1h-2zM34 53h1v1h-1z\"/><path fill=\"#c8cbd6\" d=\"M26 41h2v1h-2zM24 42h4v1h-4zM22 43h6v1h-6zM20 44h8v1h-8zM36 44h2v1h-2zM20 45h8v1h-8zM36 45h4v1h-4zM22 46h6v1h-6zM36 46h6v1h-6zM24 47h6v1h-6zM34 47h10v1h-10zM26 48h18v1h-18zM28 49h14v1h-14zM30 50h10v1h-10zM32 51h6v1h-6zM34 52h2v1h-2z\"/><path fill=\"#868a95\" d=\"M32 41h2v1h-2zM32 42h4v1h-4zM32 43h4v1h-4zM32 44h4v1h-4zM32 45h4v1h-4zM32 46h4v1h-4zM32 47h2v1h-2zM44 48h1v1h-1zM42 49h2v1h-2zM40 50h2v1h-2zM38 51h2v1h-2zM36 52h2v1h-2zM35 53h1v1h-1z\"/><path fill=\"#9ea2ad\" d=\"M19 46h1v1h-1zM20 47h2v1h-2zM22 48h2v1h-2zM24 49h2v1h-2zM26 50h2v1h-2zM28 51h2v1h-2zM30 52h2v1h-2zM32 53h2v1h-2zM34 54h1v1h-1z\"/></svg>";
92577
+ // src/rpcs/contracts.ts
92578
+ var RpcContracts = class extends make$29(make$31("scope.overview", {
92579
+ error: Union([AuthError, TelemetryError]),
92580
+ stream: true,
92581
+ success: Overview
92582
+ }), make$31("scope.trace", {
92583
+ error: Union([AuthError, TelemetryError]),
92584
+ payload: Struct({ id: TraceId }),
92585
+ success: Trace
92586
+ })).middleware(RpcAuth) {};
92587
+ // src/rpcs/handlers.ts
92588
+ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
92589
+ const telemetry = yield* Telemetry;
92590
+ return RpcContracts.of({
92591
+ "scope.overview": () => telemetry.overview,
92592
+ "scope.trace": (input) => telemetry.trace(input.id)
92593
+ });
92650
92594
  }));
92595
+ // src/tools/contracts.ts
92596
+ const Tools = make$37(make$38("list_services", {
92597
+ description: "Start here: each service with its latest run, release, last event and entry count, plus rejected exports. Only each service's newest release is kept, so nothing here predates it. A service missing here sent nothing in the last three days.",
92598
+ failure: TelemetryError,
92599
+ success: IngestionStatus
92600
+ }).annotate(Readonly, true), make$38("find", {
92601
+ description: "Find traces (one request or action each), single spans with their attributes, or logs, newest or slowest first; searches the latest run of each service unless runs is \"all\". Open a trace with read_trace.",
92602
+ failure: TelemetryError,
92603
+ parameters: Struct({
92604
+ ...SortFilters.fields,
92605
+ kind: Literals([
92606
+ "traces",
92607
+ "spans",
92608
+ "logs"
92609
+ ]).annotate({ description: "What to find." })
92610
+ }),
92611
+ success: Union([TracesPage, Page])
92612
+ }).annotate(Readonly, true), make$38("read_trace", {
92613
+ description: "One trace whole: every span in order with its depth, offset, duration and logs.",
92614
+ failure: TelemetryError,
92615
+ parameters: Struct({ id: pipe(TraceId, annotateEncoded({ description: "The 32-character id from find." })) }),
92616
+ success: Trace
92617
+ }).annotate(Readonly, true), make$38("measure_latency", {
92618
+ description: "Count, errors and p50, p95 and max milliseconds of the matching spans; run it before and after a change to compare.",
92619
+ failure: TelemetryError,
92620
+ parameters: Filters,
92621
+ success: Stats
92622
+ }).annotate(Readonly, true));
92623
+ // src/tools/handlers.ts
92624
+ const ToolHandlers = Tools.toLayer(gen(function* () {
92625
+ const telemetry = yield* Telemetry;
92626
+ return Tools.of({
92627
+ find: (input) => flatMap$3(currentTimeMillis, (now) => pipe(value(input.kind), when("traces", () => telemetry.traces(queryOf(input, now))), when("spans", () => telemetry.spans(queryOf(input, now))), when("logs", () => telemetry.logs(queryOf(input, now))), exhaustive)),
92628
+ list_services: () => telemetry.services(),
92629
+ measure_latency: (filters) => flatMap$3(currentTimeMillis, (now) => telemetry.stats(queryOf(filters, now))),
92630
+ read_trace: (input) => telemetry.trace(input.id)
92631
+ });
92632
+ }));
92633
+ // src/main.server.ts
92651
92634
  runApp({
92652
92635
  icon: icon_default,
92653
- routes: pipe(mergeAll$1(receiver, use((router) => gen(function* () {
92654
- const telemetry = yield* Telemetry;
92655
- const mac = yield* Mac;
92656
- yield* match$8(yield* option(Redacted("GITHUB_WEBHOOK_SECRET")), {
92657
- onNone: () => void_$1,
92658
- onSome: fnUntraced(function* (secret) {
92659
- const key = yield* key$1(hmacSha256, new TextEncoder().encode(value$2(secret)));
92660
- yield* router.add("POST", "/v1/github", catchTags(gen(function* () {
92661
- const request = yield* HttpServerRequest;
92662
- const body = new Uint8Array(yield* request.arrayBuffer);
92663
- if (!(yield* match$8(decodeOption(Signature)(request.headers["x-hub-signature-256"] ?? ""), {
92664
- onNone: () => succeed$5(false),
92665
- onSome: (tag) => mac.verify(key, tag, body)
92666
- }))) return empty({ status: 401 });
92667
- const text = new TextDecoder().decode(body);
92668
- if (request.headers["x-github-event"] === "workflow_run") {
92669
- const event = yield* decodeEffect(fromJsonString(WorkflowRun))(text);
92670
- const ids = runIds(event);
92671
- const finished = yield* map$5(option$1(telemetry.trace(ids.traceId)), exists((trace) => some(trace.spans, (span) => span.spanId === ids.spanId && isString$2(span.payload["endTimeUnixNano"]))));
92672
- if (event.action === "completed" || event.action === "in_progress" && !finished) yield* telemetry.ingestTraces(runTrace(event));
92673
- }
92674
- if (request.headers["x-github-event"] === "workflow_job") {
92675
- const event = yield* decodeEffect(fromJsonString(WorkflowJob))(text);
92676
- if (event.action === "completed" && event.workflow_job.conclusion !== "skipped") yield* telemetry.ingestTraces(jobTrace(event));
92677
- }
92678
- return empty({ status: 204 });
92679
- }), {
92680
- CryptoError: () => succeed$5(empty({ status: 401 })),
92681
- HttpServerError: () => succeed$5(empty({ status: 400 })),
92682
- SchemaError: (error) => succeed$5(text$1(error.message, { status: 400 })),
92683
- TelemetryError: () => succeed$5(empty({ status: 503 }))
92684
- }));
92685
- })
92686
- });
92687
- })), layerRpc({
92636
+ routes: pipe(mergeAll$1(HttpHandlers, layerRpc({
92688
92637
  group: RpcContracts,
92689
92638
  handlers: RpcHandlers
92690
92639
  }), layerMcp({