@deslop/deploy 0.1.1342 → 0.1.1345

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -3526,8 +3526,6 @@ SuccessImpl.prototype = SuccessProto;
3526
3526
  const succeed$11 = (success) => new SuccessImpl(success);
3527
3527
  /** @internal */
3528
3528
  const getSuccess$1 = (self) => isFailure$2(self) ? none$1 : some$2(self.success);
3529
- /** @internal */
3530
- const fromOption$3 = /*#__PURE__*/ dual(2, (self, onNone) => isNone$1(self) ? fail$12(onNone()) : succeed$11(self.value));
3531
3529
  // ../../node_modules/.pnpm/effect@4.1.4/node_modules/effect/dist/Order.js
3532
3530
  /**
3533
3531
  * Defines comparison functions for ordered values.
@@ -5685,39 +5683,6 @@ const succeed$10 = succeed$11;
5685
5683
  * @since 4.0.0
5686
5684
  */
5687
5685
  const fail$11 = fail$12;
5688
- /**
5689
- * Converts an `Option<A>` into a `Result<A, E>`.
5690
- *
5691
- * **When to use**
5692
- *
5693
- * Use when an existing `Option` should become a `Result`, preserving `Some` as
5694
- * success and turning `None` into a caller-provided failure.
5695
- *
5696
- * **Details**
5697
- *
5698
- * - `Some<A>` becomes `Success<A>`
5699
- * - `None` becomes `Failure<E>` using the provided function
5700
- * - Supports both data-first and data-last (piped) usage
5701
- *
5702
- * **Example** (Converting an Option to a Result)
5703
- *
5704
- * ```ts import.meta.vitest
5705
- * import { Option, Result } from "effect"
5706
- *
5707
- * Result.fromOption(Option.some(1), () => "missing") // => Result.succeed(1)
5708
- *
5709
- * Result.fromOption(Option.none(), () => "missing") // => Result.fail("missing")
5710
- * ```
5711
- *
5712
- * @see {@link getSuccess} to extract the success value as an Option
5713
- * @see {@link getFailure} to extract the failure value as an Option
5714
- * @see {@link fromNullishOr} to build a Result from nullable values
5715
- *
5716
- * @stability stable
5717
- * @category constructors
5718
- * @since 2.0.0
5719
- */
5720
- const fromOption$2 = fromOption$3;
5721
5686
  const try_$2 = (evaluate) => {
5722
5687
  if (isFunction(evaluate)) try {
5723
5688
  return succeed$10(evaluate());
@@ -11507,6 +11472,8 @@ const provideService$3 = function() {
11507
11472
  };
11508
11473
  const provideServiceImpl = (self, service, implementation) => updateContext$1(self, add$2(service, implementation));
11509
11474
  /** @internal */
11475
+ const provideServiceEffect$1 = /*#__PURE__*/ dual(3, (self, service, acquire) => flatMap$5(acquire, (implementation) => provideService$3(self, service, implementation)));
11476
+ /** @internal */
11510
11477
  const zipWith$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[1]), (self, that, f, options) => options?.concurrent ? map$9(all$2([self, that], { concurrency: 2 }), ([a, a2]) => f(a, a2)) : flatMap$5(self, (a) => map$9(that, (a2) => f(a, a2))));
11511
11478
  /** @internal */
11512
11479
  const filterOrFail$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, orFailWith ? (a) => fail$10(orFailWith(a)) : () => fail$10(new NoSuchElementError())));
@@ -12043,19 +12010,6 @@ const all$2 = (arg, options) => {
12043
12010
  return suspend$4(() => map$9(forEach$2(Object.entries(arg), ([key, effect]) => map$9(options?.mode === "result" ? result$2(effect) : effect, (value) => [key, value]), { concurrency: options?.concurrency }), Object.fromEntries));
12044
12011
  };
12045
12012
  /** @internal */
12046
- const findFirstFilter$1 = /*#__PURE__*/ dual((args) => isIterable(args[0]) && !isEffect$1(args[0]), (elements, filter) => suspend$4(() => {
12047
- const iterator = elements[Symbol.iterator]();
12048
- const next = iterator.next();
12049
- if (!next.done) return findFirstFilterLoop(iterator, 0, filter, next.value);
12050
- return succeed$9(none());
12051
- }));
12052
- const findFirstFilterLoop = (iterator, index, filter, value) => flatMap$5(filter(value, index), (result) => {
12053
- if (isSuccess$1(result)) return succeed$9(some$1(result.success));
12054
- const next = iterator.next();
12055
- if (!next.done) return findFirstFilterLoop(iterator, index + 1, filter, next.value);
12056
- return succeed$9(none());
12057
- });
12058
- /** @internal */
12059
12013
  const whileLoop$1 = /*#__PURE__*/ makePrimitive$1({
12060
12014
  op: "While",
12061
12015
  [contA](value, fiber) {
@@ -13431,6 +13385,51 @@ const filterInterruptors = causeFilterInterruptors;
13431
13385
  */
13432
13386
  const prettyErrors = causePrettyErrors;
13433
13387
  /**
13388
+ * Formats a `Cause` as a human-readable string for logging or debugging.
13389
+ *
13390
+ * **When to use**
13391
+ *
13392
+ * Use to render a whole cause as one human-readable string for logs or
13393
+ * diagnostics.
13394
+ *
13395
+ * **Details**
13396
+ *
13397
+ * Delegates to {@link prettyErrors} to convert each reason to an `Error`,
13398
+ * then joins their stack traces with newlines. Nested `Error.cause` chains
13399
+ * are rendered inline with indentation:
13400
+ *
13401
+ * ```text
13402
+ * ErrorName: message
13403
+ * at ...
13404
+ * at ... {
13405
+ * [cause]: NestedError: message
13406
+ * at ...
13407
+ * }
13408
+ * ```
13409
+ *
13410
+ * Span annotations are appended to the relevant stack frames when available.
13411
+ *
13412
+ * **Gotchas**
13413
+ *
13414
+ * Rendering an empty cause produces an empty string because there are no
13415
+ * errors to render.
13416
+ *
13417
+ * **Example** (Rendering a cause)
13418
+ *
13419
+ * ```ts import.meta.vitest
13420
+ * import { Cause } from "effect"
13421
+ *
13422
+ * Cause.pretty(Cause.fail("something went wrong")).includes("something went wrong") // => true
13423
+ * ```
13424
+ *
13425
+ * @see {@link prettyErrors} — get the individual `Error` instances
13426
+ *
13427
+ * @stability stable
13428
+ * @category formatting
13429
+ * @since 2.0.0
13430
+ */
13431
+ const pretty = causePretty;
13432
+ /**
13434
13433
  * Checks whether an arbitrary value is a `NoSuchElementError`.
13435
13434
  *
13436
13435
  * **Example** (Checking the runtime type)
@@ -18564,26 +18563,6 @@ const isEffect = isEffect$1;
18564
18563
  */
18565
18564
  const all$1 = all$2;
18566
18565
  /**
18567
- * Returns the first value that passes an effectful `FilterEffect`.
18568
- *
18569
- * **When to use**
18570
- *
18571
- * Use when you need to find the first element that satisfies an effectful
18572
- * filter returning a `Result`, which also transforms the matching element.
18573
- *
18574
- * **Details**
18575
- *
18576
- * The filter receives the element and index. Evaluation short-circuits on the
18577
- * first `Result.succeed` and returns the transformed value in `Option.some`.
18578
- *
18579
- * @see {@link findFirst} for the simpler effectful predicate-based variant
18580
- *
18581
- * @stability stable
18582
- * @category collecting
18583
- * @since 4.0.0
18584
- */
18585
- const findFirstFilter = findFirstFilter$1;
18586
- /**
18587
18566
  * Executes an effectful operation for each element in an `Iterable`.
18588
18567
  *
18589
18568
  * **When to use**
@@ -21643,6 +21622,63 @@ const updateService = updateService$1;
21643
21622
  */
21644
21623
  const provideService$2 = provideService$3;
21645
21624
  /**
21625
+ * Provides one service to an effect using an effectful acquisition.
21626
+ *
21627
+ * **When to use**
21628
+ *
21629
+ * Use when the service implementation must be created by an effect and its
21630
+ * acquisition failure should remain in the returned effect.
21631
+ *
21632
+ * **Details**
21633
+ *
21634
+ * `provideServiceEffect` runs the acquisition effect to produce the service
21635
+ * implementation, removes that service from the wrapped effect's requirements,
21636
+ * and leaves any other requirements to be provided later. Acquisition failures
21637
+ * are included in the returned effect's error channel.
21638
+ *
21639
+ * **Example** (Providing a service with an effect)
21640
+ *
21641
+ * ```ts import.meta.vitest
21642
+ * import { Context, Effect } from "effect"
21643
+ * const output: Array<unknown> = []
21644
+ *
21645
+ * // Define a database connection service
21646
+ * interface DatabaseConnection {
21647
+ * readonly query: (sql: string) => Effect.Effect<string>
21648
+ * }
21649
+ * const Database = Context.Service<DatabaseConnection>("Database")
21650
+ *
21651
+ * // Effect that creates a database connection
21652
+ * const createConnection = Effect.gen(function*() {
21653
+ * yield* Effect.sync(() => { output.push("Establishing database connection...") })
21654
+ * yield* Effect.sync(() => { output.push("Database connected!") })
21655
+ * return {
21656
+ * query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
21657
+ * }
21658
+ * })
21659
+ *
21660
+ * const program = Effect.gen(function*() {
21661
+ * const db = yield* Effect.service(Database)
21662
+ * return yield* db.query("SELECT * FROM users")
21663
+ * })
21664
+ *
21665
+ * // Provide the service through an effect
21666
+ * const withDatabase = Effect.provideServiceEffect(
21667
+ * program,
21668
+ * Database,
21669
+ * createConnection
21670
+ * )
21671
+ *
21672
+ * void output.push(await Effect.runPromise(withDatabase))
21673
+ * output // => ["Establishing database connection...", "Database connected!", "Result for: SELECT * FROM users"]
21674
+ * ```
21675
+ *
21676
+ * @stability stable
21677
+ * @category providing services
21678
+ * @since 2.0.0
21679
+ */
21680
+ const provideServiceEffect = provideServiceEffect$1;
21681
+ /**
21646
21682
  * Returns the current scope for resource management.
21647
21683
  *
21648
21684
  * **Example** (Accessing the current scope)
@@ -53879,30 +53915,31 @@ const make$55 = /*#__PURE__*/ sync(() => {
53879
53915
  });
53880
53916
  var PendingInvalidation = class extends (/*#__PURE__*/ Service$1()("effect/reactivity/Reactivity/PendingInvalidation")) {};
53881
53917
  /**
53882
- * Wraps an effect so the supplied keys are invalidated after the effect succeeds.
53918
+ * Runs an effect as a stream of query results tied to the supplied invalidation
53919
+ * keys.
53883
53920
  *
53884
- * **Gotchas**
53921
+ * **Details**
53885
53922
  *
53886
- * If the effect fails, the keys are not invalidated.
53923
+ * The effect runs initially and reruns whenever the keys are invalidated.
53887
53924
  *
53888
53925
  * @stability unstable
53889
53926
  * @category accessors
53890
53927
  * @since 4.0.0
53891
53928
  */
53892
- const mutation = /*#__PURE__*/ dual(2, (effect, keys) => Reactivity.use((_) => _.mutation(keys, effect)));
53929
+ const stream$3 = /*#__PURE__*/ dual(2, (effect, keys) => Reactivity.use((r) => r.query(keys, effect)).pipe(map$7(fromQueue), unwrap$4));
53893
53930
  /**
53894
- * Runs an effect as a stream of query results tied to the supplied invalidation
53895
- * keys.
53931
+ * Invalidates the supplied keys through the `Reactivity` service.
53896
53932
  *
53897
53933
  * **Details**
53898
53934
  *
53899
- * The effect runs initially and reruns whenever the keys are invalidated.
53935
+ * Registered queries for matching keys are rerun immediately, or collected until
53936
+ * the enclosing reactivity batch completes.
53900
53937
  *
53901
53938
  * @stability unstable
53902
53939
  * @category accessors
53903
53940
  * @since 4.0.0
53904
53941
  */
53905
- const stream$3 = /*#__PURE__*/ dual(2, (effect, keys) => Reactivity.use((r) => r.query(keys, effect)).pipe(map$7(fromQueue), unwrap$4));
53942
+ const invalidate = (keys) => Reactivity.use((r) => r.invalidate(keys));
53906
53943
  /**
53907
53944
  * The default layer that provides an in-memory `Reactivity` service.
53908
53945
  *
@@ -84463,7 +84500,7 @@ const fromDuplex = (open, options) => withFiber((fiber) => {
84463
84500
  writer
84464
84501
  }));
84465
84502
  });
84466
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js
84503
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js
84467
84504
  var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84468
84505
  const BINARY_TYPES = [
84469
84506
  "nodebuffer",
@@ -84485,7 +84522,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84485
84522
  NOOP: () => {}
84486
84523
  };
84487
84524
  }));
84488
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js
84525
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js
84489
84526
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84490
84527
  const { websocketMask, websocketUnmask } = __require("http");
84491
84528
  const { EMPTY_BUFFER } = require_constants();
@@ -84593,7 +84630,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84593
84630
  };
84594
84631
  } catch (e) {}
84595
84632
  }));
84596
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js
84633
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/limiter.js
84597
84634
  var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84598
84635
  const kDone = Symbol("kDone");
84599
84636
  const kRun = Symbol("kRun");
@@ -84643,7 +84680,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84643
84680
  };
84644
84681
  module.exports = Limiter;
84645
84682
  }));
84646
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js
84683
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js
84647
84684
  var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84648
84685
  const zlib = __require("zlib");
84649
84686
  const bufferUtil = require_buffer_util();
@@ -84978,7 +85015,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
84978
85015
  this[kCallback](err);
84979
85016
  }
84980
85017
  }));
84981
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js
85018
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js
84982
85019
  var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
84983
85020
  const { isUtf8 } = __require("buffer");
84984
85021
  const { hasBlob } = require_constants();
@@ -85173,7 +85210,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
85173
85210
  };
85174
85211
  } catch (e) {}
85175
85212
  }));
85176
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js
85213
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js
85177
85214
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
85178
85215
  const { Writable } = __require("stream");
85179
85216
  const PerMessageDeflate = require_permessage_deflate();
@@ -85636,7 +85673,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
85636
85673
  };
85637
85674
  module.exports = Receiver;
85638
85675
  }));
85639
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js
85676
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js
85640
85677
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
85641
85678
  const { Duplex } = __require("stream");
85642
85679
  const { randomFillSync } = __require("crypto");
@@ -86134,7 +86171,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86134
86171
  sender.onerror(err);
86135
86172
  }
86136
86173
  }));
86137
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js
86174
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js
86138
86175
  var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86139
86176
  const { kForOnEventAttribute, kListener } = require_constants();
86140
86177
  const kCode = Symbol("kCode");
@@ -86364,7 +86401,7 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86364
86401
  else listener.call(thisArg, event);
86365
86402
  }
86366
86403
  }));
86367
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js
86404
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js
86368
86405
  var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86369
86406
  const { tokenChars } = require_validation();
86370
86407
  /**
@@ -86509,7 +86546,7 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86509
86546
  parse
86510
86547
  };
86511
86548
  }));
86512
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js
86549
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js
86513
86550
  var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86514
86551
  const EventEmitter = __require("events");
86515
86552
  const https = __require("https");
@@ -86582,12 +86619,15 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
86582
86619
  else protocols = [options.protocols];
86583
86620
  } else protocols = [protocols];
86584
86621
  }
86585
- initAsClient(this, address, protocols, options);
86586
- } else {
86587
- this._autoPong = options.autoPong;
86588
- this._closeTimeout = options.closeTimeout;
86589
- this._isServer = true;
86622
+ options = initAsClient(this, address, protocols, options);
86623
+ } else this._isServer = true;
86624
+ if (options.autoPong) {
86625
+ this._autoPong = true;
86626
+ this._autoPongComplete = () => autoPongComplete(this);
86627
+ this._pendingAutoPongs = 0;
86628
+ this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
86590
86629
  }
86630
+ this._closeTimeout = options.closeTimeout;
86591
86631
  }
86592
86632
  /**
86593
86633
  * For historical reasons, the custom "nodebuffer" type is used by the default
@@ -87028,6 +87068,8 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87028
87068
  * fragments
87029
87069
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
87030
87070
  * size
87071
+ * @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
87072
+ * pending automatic pongs
87031
87073
  * @param {Number} [options.maxRedirects=10] The maximum number of redirects
87032
87074
  * allowed
87033
87075
  * @param {String} [options.origin] Value of the `Origin` or
@@ -87038,6 +87080,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87038
87080
  * `Sec-WebSocket-Version` header
87039
87081
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
87040
87082
  * not to skip UTF-8 validation for text and close messages
87083
+ * @return {Object} The resolved options object used for initialization
87041
87084
  * @private
87042
87085
  */
87043
87086
  function initAsClient(websocket, address, protocols, options) {
@@ -87049,6 +87092,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87049
87092
  maxBufferedChunks: 262144,
87050
87093
  maxFragments: 16384,
87051
87094
  maxPayload: 104857600,
87095
+ maxPendingAutoPongs: 60,
87052
87096
  skipUTF8Validation: false,
87053
87097
  perMessageDeflate: true,
87054
87098
  followRedirects: false,
@@ -87064,8 +87108,6 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87064
87108
  path: void 0,
87065
87109
  port: void 0
87066
87110
  };
87067
- websocket._autoPong = opts.autoPong;
87068
- websocket._closeTimeout = opts.closeTimeout;
87069
87111
  if (!protocolVersions.includes(opts.protocolVersion)) throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`);
87070
87112
  let parsedUrl;
87071
87113
  if (address instanceof URL) parsedUrl = address;
@@ -87255,6 +87297,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87255
87297
  });
87256
87298
  if (opts.finishRequest) opts.finishRequest(req, websocket);
87257
87299
  else req.end();
87300
+ return opts;
87258
87301
  }
87259
87302
  /**
87260
87303
  * Emit the `'error'` and `'close'` events.
@@ -87411,10 +87454,25 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87411
87454
  */
87412
87455
  function receiverOnPing(data) {
87413
87456
  const websocket = this[kWebSocket];
87414
- if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);
87457
+ if (websocket._autoPong && websocket.readyState === WebSocket.OPEN) {
87458
+ if (websocket._maxPendingAutoPongs > 0 && websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs) websocket.terminate();
87459
+ else {
87460
+ websocket._pendingAutoPongs++;
87461
+ websocket.pong(data, !this._isServer, websocket._autoPongComplete);
87462
+ }
87463
+ }
87415
87464
  websocket.emit("ping", data);
87416
87465
  }
87417
87466
  /**
87467
+ * The callback for automatic pong responses.
87468
+ *
87469
+ * @param {WebSocket} websocket The WebSocket instance
87470
+ * @private
87471
+ */
87472
+ function autoPongComplete(websocket) {
87473
+ websocket._pendingAutoPongs--;
87474
+ }
87475
+ /**
87418
87476
  * The listener of the `Receiver` `'pong'` event.
87419
87477
  *
87420
87478
  * @param {Buffer} data The data included in the pong frame
@@ -87519,7 +87577,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87519
87577
  }
87520
87578
  }
87521
87579
  }));
87522
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js
87580
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js
87523
87581
  var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87524
87582
  require_websocket();
87525
87583
  const { Duplex } = __require("stream");
@@ -87634,7 +87692,7 @@ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87634
87692
  }
87635
87693
  module.exports = createWebSocketStream;
87636
87694
  }));
87637
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js
87695
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js
87638
87696
  var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87639
87697
  const { tokenChars } = require_validation();
87640
87698
  /**
@@ -87672,7 +87730,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87672
87730
  }
87673
87731
  module.exports = { parse };
87674
87732
  }));
87675
- // ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js
87733
+ // ../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js
87676
87734
  var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87677
87735
  const EventEmitter = __require("events");
87678
87736
  const http = __require("http");
@@ -87717,6 +87775,8 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
87717
87775
  * fragments
87718
87776
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
87719
87777
  * size
87778
+ * @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
87779
+ * pending automatic pongs
87720
87780
  * @param {Boolean} [options.noServer=false] Enable no server mode
87721
87781
  * @param {String} [options.path] Accept only connections matching this path
87722
87782
  * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
@@ -87739,6 +87799,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
87739
87799
  maxBufferedChunks: 262144,
87740
87800
  maxFragments: 16384,
87741
87801
  maxPayload: 104857600,
87802
+ maxPendingAutoPongs: 60,
87742
87803
  skipUTF8Validation: false,
87743
87804
  perMessageDeflate: false,
87744
87805
  handleProtocols: null,
@@ -111774,7 +111835,7 @@ const void_ = (options) => {
111774
111835
  // ../../packages/runtime/src/server/store.ts
111775
111836
  const checkoutRoot = fnUntraced(function* (directory) {
111776
111837
  const path = yield* Path$1;
111777
- if (getOrElse$1(yield* option$1((yield* FileSystem).exists(path.join(directory, "pnpm-workspace.yaml"))), constFalse$1)) return some$1(directory);
111838
+ if (yield* (yield* FileSystem).exists(path.join(directory, "pnpm-workspace.yaml"))) return some$1(directory);
111778
111839
  if (path.dirname(directory) === directory) return none();
111779
111840
  return yield* checkoutRoot(path.dirname(directory));
111780
111841
  });
@@ -112065,16 +112126,27 @@ const updateRelease = fnUntraced(function* (name) {
112065
112126
  "--registry=https://registry.npmjs.org",
112066
112127
  `@deslop/${name}@${latest}`
112067
112128
  ]), "5 minutes");
112068
- const previous = yield* option$1(fs.readLink(path.join(root, "current")));
112069
- yield* activateRelease(name, path.join(directory, "node_modules", "@deslop", name));
112070
- yield* restartService(name);
112071
- const kept = [latest, ...toArray(map$13(previous, (link) => path.basename(path.resolve(link, "../../.."))))];
112129
+ const previous = yield* fs.readLink(path.join(root, "current"));
112130
+ yield* uninterruptible(gen(function* () {
112131
+ yield* activateRelease(name, path.join(directory, "node_modules", "@deslop", name));
112132
+ const restarted = yield* exit(restartService(name));
112133
+ if (isSuccess(restarted)) return;
112134
+ const restored = yield* exit(activateRelease(name, previous));
112135
+ return yield* AppError.make({
112136
+ cause: restarted.cause,
112137
+ message: `Restart failed: ${pretty(restarted.cause)}. ${match$3(restored, {
112138
+ onFailure: (cause) => `The previous current link could not be restored: ${pretty(cause)}`,
112139
+ onSuccess: constant("The previous current link was restored; service state is unknown")
112140
+ })}`
112141
+ });
112142
+ }));
112143
+ const kept = [latest, path.basename(path.resolve(root, previous, "../../.."))];
112072
112144
  yield* pipe(yield* fs.readDirectory(path.join(root, "releases")), difference(kept), forEach$1((entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 }));
112073
112145
  return `Updated ${name} from ${running} to ${latest}\n`;
112074
112146
  });
112075
112147
  // ../../packages/runtime/src/server/cli.ts
112076
112148
  const DEFAULT_HOST = "127.0.0.1";
112077
- const TailnetSelf = Struct$2({ Self: Struct$2({ DNSName: String$6 }) });
112149
+ const TailnetSelf = Struct$2({ Self: Struct$2({ DNSName: NonEmptyString }) });
112078
112150
  const SETTINGS = {
112079
112151
  DOMAIN: {
112080
112152
  description: "Parent domain for Deslop apps; without it every caller is the developer",
@@ -112090,13 +112162,9 @@ const SETTINGS = {
112090
112162
  const configProvider = fnUntraced(function* (given, defaultPort) {
112091
112163
  const port = given["PORT"] ?? `${defaultPort}`;
112092
112164
  const name = yield* appName;
112093
- const tailnet = yield* pipe(executeProcess("tailscale", ["status", "--json"]), flatMap$3(decodeUnknownEffect(fromJsonString(TailnetSelf))), map$7((status) => replace(/\.$/u, "")(status.Self.DNSName)), timeout("5 seconds"), option$1);
112094
- const urls = match$8(fromUndefinedOr(given["DOMAIN"]), {
112095
- onNone: () => ({ APP_URL: pipe(tailnet, filter$7(isNonEmpty$1), match$8({
112096
- onNone: () => `http://localhost:${port}`,
112097
- onSome: (host) => `https://${host}:${port}`
112098
- })) }),
112099
- onSome: (domain) => ({
112165
+ const urls = yield* match$8(fromUndefinedOr(given["DOMAIN"]), {
112166
+ onNone: () => pipe(executeProcess("tailscale", ["status", "--json"]), flatMap$3(decodeUnknownEffect(fromJsonString(TailnetSelf))), map$7((status) => ({ APP_URL: `https://${replace(/\.$/u, "")(status.Self.DNSName)}:${port}` })), timeout("5 seconds")),
112167
+ onSome: (domain) => succeed$5({
112100
112168
  APP_URL: `https://${name}.${domain}`,
112101
112169
  AUTH_URL: `https://auth.${domain}`,
112102
112170
  GATEWAY_URL: `https://gateway.${domain}`,
@@ -112162,7 +112230,7 @@ function runApp(app) {
112162
112230
  return pipe(String$1(setting.flag), withSchema(setting.schema), withFallbackConfig(schema$1(setting.schema, env)), withDescription(`${setting.description} [${env}]`), optional);
112163
112231
  }));
112164
112232
  const given = map$7(root, (input) => getSomes$1(input));
112165
- return yield* pipe(root, withHandler((input) => flatMap$3(configProvider(getSomes$1(input), metadata.config.port), (values) => provideService$2(server(app), ConfigProvider, values))), withSubcommands([withSubcommands(make$12("service"), [
112233
+ return yield* pipe(root, withHandler((input) => provideServiceEffect(server(app), ConfigProvider, configProvider(getSomes$1(input), metadata.config.port))), withSubcommands([withSubcommands(make$12("service"), [
112166
112234
  make$12("install", {}, fnUntraced(function* () {
112167
112235
  const fs = yield* FileSystem;
112168
112236
  const path = yield* Path$1;
@@ -112419,16 +112487,25 @@ const TIME_FRAME_DURATIONS = {
112419
112487
  function timeFrameDuration(frame) {
112420
112488
  return TIME_FRAME_DURATIONS[frame];
112421
112489
  }
112422
- const DateTimeUtcFromFiniteMillis = pipe(Finite, decodeTo(DateTimeUtc, {
112490
+ const DateTimeUtcFromFiniteMillis = pipe(Finite.check(isBetween({
112491
+ maximum: 864e13,
112492
+ minimum: -864e13
112493
+ })), decodeTo(DateTimeUtc, {
112423
112494
  decode: transform$3((value) => mapEpochMillis(makeUnsafe$5(0), () => value)),
112424
112495
  encode: transform$3(toEpochMillis)
112425
112496
  }));
112426
112497
  const DurationFromFiniteMillis = pipe(Finite, decodeTo(DurationFromMillis));
112427
- pipe(Finite, decodeTo(DateTimeUtc, {
112498
+ pipe(Finite.check(isBetween({
112499
+ maximum: 864e10,
112500
+ minimum: -864e10
112501
+ })), decodeTo(DateTimeUtc, {
112428
112502
  decode: transform$3((seconds) => mapEpochMillis(makeUnsafe$5(0), () => seconds * 1e3)),
112429
112503
  encode: transform$3((at) => toEpochMillis(at) / 1e3)
112430
112504
  }));
112431
- pipe(Int$1, decodeTo(DateTimeUtc, {
112505
+ pipe(Int$1.check(isBetween({
112506
+ maximum: 864e10,
112507
+ minimum: -864e10
112508
+ })), decodeTo(DateTimeUtc, {
112432
112509
  decode: transform$3((value) => makeUnsafe$5(value * 1e3)),
112433
112510
  encode: transform$3(toEpochSeconds)
112434
112511
  }));
@@ -112797,6 +112874,12 @@ const MachineHistory = Struct$2({
112797
112874
  time: DateTimeUtcFromFiniteMillis,
112798
112875
  worker: WorkerId
112799
112876
  });
112877
+ const VmStatPages = Struct$2({
112878
+ "Anonymous pages": FiniteFromString,
112879
+ "Pages occupied by compressor": FiniteFromString,
112880
+ "Pages purgeable": FiniteFromString,
112881
+ "Pages wired down": FiniteFromString
112882
+ });
112800
112883
  // src/rpcs/contracts.ts
112801
112884
  var PeerRpcAuth = class extends Service()("@deslop/deploy/rpcs/PeerRpcAuth", { error: AuthError }) {};
112802
112885
  var RpcContracts = class extends make$27(make$29("metrics.watch", {
@@ -113050,16 +113133,20 @@ function exitFailure(status) {
113050
113133
  return failureReason("exit-code", status, true);
113051
113134
  }
113052
113135
  function unitFailures(text) {
113053
- return pipe(trim(text), split$1(/\n\s*\n/u), filter$5(isNonEmpty$1), fromIterableWith((block) => {
113136
+ return pipe(trim(text), split$1(/\n\s*\n/u), filter$5(isNonEmpty$1), flatMap$6((block) => {
113054
113137
  const fields = pipe(block, split$1("\n"), filter$5(includes("=")), fromIterableWith((line) => {
113055
113138
  const [key, ...value] = split$1(line, "=");
113056
113139
  return [key, join$4(value, "=")];
113057
113140
  }));
113058
- return [UnitId.make(fields["Id"] ?? ""), {
113141
+ const id = fields["Id"] ?? "";
113142
+ const result = fields["Result"] ?? "";
113143
+ const status = parse$2(fields["ExecMainStatus"] ?? "");
113144
+ if (!isNonEmpty$1(id) || !isNonEmpty$1(result) || isNone(status) || !isNonEmpty$1(fields["ExecMainCode"] ?? "")) return [];
113145
+ return [[UnitId.make(id), {
113059
113146
  at: map$13(parse$2(replace(/^@/u, "")(fields["StateChangeTimestamp"] ?? "")), (seconds) => mapEpochMillis(makeUnsafe$5(0), () => seconds * 1e3)),
113060
- reason: failureReason(fields["Result"] ?? "", getOrElse$1(parse$2(fields["ExecMainStatus"] ?? ""), constant(0)), fields["ExecMainCode"] !== "0")
113061
- }];
113062
- }));
113147
+ reason: failureReason(result, getOrThrow$1(status), fields["ExecMainCode"] !== "0")
113148
+ }]];
113149
+ }), fromEntries);
113063
113150
  }
113064
113151
  // src/services/inventory/lib/launchd.ts
113065
113152
  function applicationBundle(path) {
@@ -113666,11 +113753,14 @@ function processStatus(status) {
113666
113753
  const at = getOrThrow$1(indexOf(":")(line));
113667
113754
  return [slice(0, at)(line), trim(slice(at + 1)(line))];
113668
113755
  }));
113756
+ function field(name) {
113757
+ return pipe(get$12(values, name), filter$7(isNonEmpty$1), getOrUndefined$1);
113758
+ }
113669
113759
  return {
113670
113760
  memory: decodeSync(ResidentMemoryFromKiB)(split$1(values["VmRSS"] ?? "", /\s+/u)[0] || "0"),
113671
113761
  name: values["Name"] ?? "",
113672
- parent: decodeSync(ProcessIdFromString)(values["PPid"] ?? ""),
113673
- pid: decodeSync(ProcessIdFromString)(values["Pid"] ?? "")
113762
+ parent: decodeUnknownSync(ProcessIdFromString)(field("PPid")),
113763
+ pid: decodeUnknownSync(ProcessIdFromString)(field("Pid"))
113674
113764
  };
113675
113765
  }
113676
113766
  function commandArgs(cmdline) {
@@ -113817,6 +113907,8 @@ function portOf(address) {
113817
113907
  function socketLine(line) {
113818
113908
  const fields = split$1(trim(line), /\s+/u);
113819
113909
  const address = fields[4] ?? "";
113910
+ const state = fields[1] ?? "";
113911
+ if (!contains$1(["tcp", "udp"], fields[0]) || !isNonEmpty$1(state) || !isNonEmpty$1(address)) return none();
113820
113912
  return map$13(portOf(address), (port) => ({
113821
113913
  address,
113822
113914
  port,
@@ -113825,7 +113917,7 @@ function socketLine(line) {
113825
113917
  pid
113826
113918
  }))),
113827
113919
  protocol: fields[0],
113828
- state: fields[1] ?? "listening"
113920
+ state
113829
113921
  }));
113830
113922
  }
113831
113923
  function lsofSocket(file) {
@@ -113930,59 +114022,65 @@ function probeSocket(listener, process) {
113930
114022
  return listener.protocol === "tcp" && listener.port >= 1024 && isSome(match$2(/^(?:127\.0\.0\.1|0\.0\.0\.0):/u)(listener.address)) && isNone(match$2(/^(?:postgres|redis|ssh|cloudflared|tailscaled|caddy)$/u)(process));
113931
114023
  }
113932
114024
  // src/services/inventory/service.ts
113933
- function portItems(sockets, worker, http, origin) {
113934
- return forEach$1(sockets, fnUntraced(function* (socket) {
113935
- const unit = yield* match$8(socket.process, {
113936
- onNone: () => succeedNone,
113937
- onSome: (match) => origin.unit(match.pid)
113938
- });
113939
- const process = yield* match$8(socket.process, {
113940
- onNone: () => succeedNone,
113941
- onSome: fnUntraced(function* (match) {
114025
+ function portItems(sockets, worker, http, source) {
114026
+ return gen(function* () {
114027
+ const metadata = fromIterable$5(yield* pipe(getSomes(map$10(sockets, (socket) => socket.process)), dedupeWith((left, right) => left.pid === right.pid), forEach$1(fnUntraced(function* (process) {
114028
+ return [process.pid, {
114029
+ cwd: yield* match(startsWith("node")(process.name), {
114030
+ onFalse: () => succeedNone,
114031
+ onTrue: () => source.cwd(process.pid)
114032
+ }),
114033
+ unit: yield* source.unit(process.pid)
114034
+ }];
114035
+ }), { concurrency: 8 })));
114036
+ return yield* forEach$1(sockets, fnUntraced(function* (socket) {
114037
+ const origin = flatMap$8(socket.process, (process) => get$8(metadata, process.pid));
114038
+ const unit = flatMap$8(origin, (process) => process.unit);
114039
+ const process = flatMap$8(socket.process, (match) => {
113942
114040
  if (!startsWith("node")(match.name)) return liftPredicate(match.name, isNonEmpty$1);
113943
- return pipe(yield* origin.cwd(match.pid), match$8({
114041
+ return pipe(flatMap$8(origin, (reading) => reading.cwd), match$8({
113944
114042
  onNone: () => match.name,
113945
114043
  onSome: (cwd) => socketProcess(match.name, cwd)
113946
114044
  }), liftPredicate(isNonEmpty$1));
113947
- })
113948
- });
113949
- const response = yield* match(probeSocket(socket, getOrElse$1(process, constant(""))), {
113950
- onFalse: () => succeed$5(none()),
113951
- onTrue: fnUntraced(function* () {
113952
- return yield* pipe(http.head(`http://127.0.0.1:${socket.port}/`, { headers: toHeaders(new NativeSpan({
113953
- annotations: empty$18(),
113954
- kind: "internal",
113955
- links: [],
113956
- name: "Deploy.probe",
113957
- parent: none(),
113958
- sampled: false,
113959
- startTime: 0n
113960
- })) }), map$7((value) => ({
113961
- http: true,
113962
- ui: value.status >= 200 && value.status < 400 && includes("text/html")(value.headers["content-type"] ?? "")
113963
- })), provideService$2(RequestInit, { redirect: "manual" }), provideService$2(TracerDisabledWhen, constTrue), timeout(millis(700)), option$1);
113964
- })
113965
- });
113966
- return InventoryItem.make({
113967
- address: some$1(socket.address),
113968
- detail: `${socket.address} · ${getOrElse$1(process, constant("process unavailable"))}`,
113969
- http: some$1(exists(response, (value) => value.http)),
113970
- id: ItemId.make(`${worker}:port:${socket.protocol}:${socket.address}`),
113971
- kind: "port",
113972
- name: socket.address,
113973
- port: some$1(socket.port),
113974
- process,
113975
- protocol: some$1(match(socket.protocol === "udp", {
113976
- onFalse: constant("tcp"),
113977
- onTrue: constant("udp")
113978
- })),
113979
- state: socket.state,
113980
- ui: some$1(exists(response, (value) => value.ui)),
113981
- unit,
113982
- url: none(),
113983
- worker
113984
- });
113985
- }), { concurrency: 8 });
114045
+ });
114046
+ const response = yield* match(probeSocket(socket, getOrElse$1(process, constant(""))), {
114047
+ onFalse: () => succeed$5(none()),
114048
+ onTrue: fnUntraced(function* () {
114049
+ return yield* pipe(http.head(`http://127.0.0.1:${socket.port}/`, { headers: toHeaders(new NativeSpan({
114050
+ annotations: empty$18(),
114051
+ kind: "internal",
114052
+ links: [],
114053
+ name: "Deploy.probe",
114054
+ parent: none(),
114055
+ sampled: false,
114056
+ startTime: 0n
114057
+ })) }), map$7((value) => ({
114058
+ http: true,
114059
+ ui: value.status >= 200 && value.status < 400 && includes("text/html")(value.headers["content-type"] ?? "")
114060
+ })), provideService$2(RequestInit, { redirect: "manual" }), provideService$2(TracerDisabledWhen, constTrue), timeout(millis(700)), option$1);
114061
+ })
114062
+ });
114063
+ return InventoryItem.make({
114064
+ address: some$1(socket.address),
114065
+ detail: `${socket.address} · ${getOrElse$1(process, constant("process unavailable"))}`,
114066
+ http: some$1(exists(response, (value) => value.http)),
114067
+ id: ItemId.make(`${worker}:port:${socket.protocol}:${socket.address}`),
114068
+ kind: "port",
114069
+ name: socket.address,
114070
+ port: some$1(socket.port),
114071
+ process,
114072
+ protocol: some$1(match(socket.protocol === "udp", {
114073
+ onFalse: constant("tcp"),
114074
+ onTrue: constant("udp")
114075
+ })),
114076
+ state: socket.state,
114077
+ ui: some$1(exists(response, (value) => value.ui)),
114078
+ unit,
114079
+ url: none(),
114080
+ worker
114081
+ });
114082
+ }), { concurrency: 8 });
114083
+ });
113986
114084
  }
113987
114085
  function collect(name, effect) {
113988
114086
  return pipe(effect, timeout(seconds(10)), withSpan("Inventory.collect", { attributes: { source: name } }), match$1({
@@ -114002,6 +114100,9 @@ function collect(name, effect) {
114002
114100
  })
114003
114101
  }));
114004
114102
  }
114103
+ function containerRows(listing) {
114104
+ return pipe(listing, split$1("\n"), filter$5(isNonEmpty$1), map$10((line) => decodeOption(fromJsonString(Container))(line)), getSomes);
114105
+ }
114005
114106
  var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/service/Inventory") {
114006
114107
  static layer = effect(this, gen(function* () {
114007
114108
  const fs = yield* FileSystem;
@@ -114013,6 +114114,9 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114013
114114
  message: cause.message
114014
114115
  })), provideService$2(ChildProcessSpawner, spawner));
114015
114116
  }
114117
+ function systemctlRows(args, row) {
114118
+ return pipe(command("systemctl", args), flatMap$3(decodeUnknownEffect(fromJsonString(ArraySchema(Unknown)))), map$7((rows) => getSomes(map$10(rows, (item) => decodeUnknownOption(row)(item)))));
114119
+ }
114016
114120
  const worker = yield* decodeEffect(WorkerId)(hostname());
114017
114121
  const selfProcess = yield* decodeEffect(ProcessId)(pid);
114018
114122
  const processState = yield* make$56(none());
@@ -114026,21 +114130,21 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114026
114130
  onTrue: () => []
114027
114131
  });
114028
114132
  const listed = yield* all$1({
114029
- rows: flatMap$3(command("systemctl", [
114133
+ rows: systemctlRows([
114030
114134
  ...scopeFlags,
114031
114135
  "list-units",
114032
114136
  "--all",
114033
114137
  "--type=service",
114034
114138
  "--output=json",
114035
114139
  "--no-pager"
114036
- ]), decodeUnknownEffect(fromJsonString(ArraySchema(Unit)))),
114037
- timers: flatMap$3(command("systemctl", [
114140
+ ], Unit),
114141
+ timers: systemctlRows([
114038
114142
  ...scopeFlags,
114039
114143
  "list-timers",
114040
114144
  "--all",
114041
114145
  "--output=json",
114042
114146
  "--no-pager"
114043
- ]), decodeUnknownEffect(fromJsonString(ArraySchema(Timer))))
114147
+ ], Timer)
114044
114148
  }, { concurrency: "unbounded" });
114045
114149
  const scheduled = fromIterable$5(getSomes(map$10(listed.timers, (timer) => map$13(timer.activates, (unit) => [unit, map$13(timer.next, (next) => mapEpochMillis(next, Math.floor))]))));
114046
114150
  const failed = pipe(listed.rows, filter$5((row) => row.active === "failed"), map$10((row) => row.unit));
@@ -114080,13 +114184,13 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114080
114184
  "--all",
114081
114185
  "--format",
114082
114186
  "{{json .}}"
114083
- ]), flatMap$3((text) => pipe(text, split$1("\n"), filter$5(isNonEmpty$1), forEach$1((line) => decodeEffect(fromJsonString(Container))(line), { concurrency: 1 }))), map$7((rows) => map$10(rows, (row) => InventoryItem.make({
114187
+ ]), map$7(containerRows), map$7((rows) => map$10(rows, (row) => InventoryItem.make({
114084
114188
  active: contains$1([
114085
114189
  "running",
114086
114190
  "restarting",
114087
114191
  "paused"
114088
114192
  ], row.State),
114089
- bindings: some$1([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => ({
114193
+ bindings: some$1(filter$5([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => ({
114090
114194
  address: "container",
114091
114195
  port: getOrElse$1(parse$2(match[1] ?? ""), constant(0)),
114092
114196
  protocol: "tcp"
@@ -114097,7 +114201,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114097
114201
  onFalse: constant("tcp"),
114098
114202
  onTrue: constant("udp")
114099
114203
  })
114100
- }))]),
114204
+ }))], (binding) => binding.port > 0 && binding.port <= 65535)),
114101
114205
  detail: row.Status,
114102
114206
  health: match(includes("unhealthy")(row.Status) || isSome(match$2(/Exited \([1-9]/u)(row.Status)), {
114103
114207
  onFalse: () => match(row.State === "restarting", {
@@ -114134,23 +114238,30 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114134
114238
  });
114135
114239
  const darwin = gen(function* () {
114136
114240
  const namedAgents = gen(function* () {
114137
- return getSomes(yield* forEach$1(launchAgents(yield* command("launchctl", ["list"])), fnUntraced(function* (agent) {
114241
+ const agents = launchAgents(yield* command("launchctl", ["list"]));
114242
+ const bundleNames = yield* make$71({
114243
+ capacity: agents.length + 1,
114244
+ lookup: fnUntraced(function* (bundle) {
114245
+ return yield* pipe(command("/usr/bin/plutil", [
114246
+ "-convert",
114247
+ "json",
114248
+ "-o",
114249
+ "-",
114250
+ `${bundle}/Contents/Info.plist`
114251
+ ]), flatMap$3(decodeEffect(fromJsonString(Struct$2({
114252
+ CFBundleDisplayName: optionalKey(Unknown),
114253
+ CFBundleName: optionalKey(Unknown)
114254
+ })))), map$7((fields) => pipe([fields.CFBundleDisplayName, fields.CFBundleName], filter$5(isString$1), map$10(trim), findFirst(isNonEmpty$1))), option$1, map$7(flatten$6));
114255
+ })
114256
+ });
114257
+ return getSomes(yield* forEach$1(agents, fnUntraced(function* (agent) {
114138
114258
  if (startsWith("deslop-")(agent.label)) return some$1(agent);
114139
114259
  const program = flatMap$8(yield* option$1(command("launchctl", ["print", `gui/${userInfo().uid}/${agent.label}`])), launchProgram);
114140
114260
  if (exists(program, systemProgram)) return none();
114141
114261
  return yield* pipe(program, flatMap$8(applicationBundle), match$8({
114142
114262
  onNone: () => succeedSome(agent),
114143
114263
  onSome: fnUntraced(function* (bundle) {
114144
- const name = yield* findFirstFilter(["CFBundleDisplayName", "CFBundleName"], (key) => pipe(command("/usr/bin/plutil", [
114145
- "-extract",
114146
- key,
114147
- "raw",
114148
- "-expect",
114149
- "string",
114150
- "-o",
114151
- "-",
114152
- `${bundle}/Contents/Info.plist`
114153
- ]), option$1, map$7((value) => pipe(value, map$13(trim), filter$7(isNonEmpty$1), fromOption$2(constUndefined)))));
114264
+ const name = yield* get$7(bundleNames, bundle);
114154
114265
  return some$1({
114155
114266
  ...agent,
114156
114267
  bundle: some$1(bundle),
@@ -114371,8 +114482,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
114371
114482
  return {
114372
114483
  refresh,
114373
114484
  run: fn("Inventory.run")(function* (input) {
114374
- yield* start(input);
114375
- yield* refresh;
114485
+ yield* onExit$1(start(input), () => refresh);
114376
114486
  }),
114377
114487
  snapshot: get$1(snapshot)
114378
114488
  };
@@ -114389,7 +114499,7 @@ const SERIES = {
114389
114499
  function counters(stat, uptime, time) {
114390
114500
  const values = decodeSync(CpuCounters)(pipe(stat, split$1("\n"), head, getOrElse$1(constant("")), trim, split$1(/\s+/u), drop$1(1), take$3(8)));
114391
114501
  return {
114392
- cpuIdle: millis(((values[3] ?? 0) + (values[4] ?? 0)) * 10),
114502
+ cpuIdle: millis((getOrThrow$1(get$11(values, 3)) + getOrThrow$1(get$11(values, 4))) * 10),
114393
114503
  cpuTotal: millis(sumAll(values) * 10),
114394
114504
  time,
114395
114505
  uptime: seconds(decodeSync(FiniteFromString)(split$1(uptime, " ")[0]))
@@ -114416,13 +114526,11 @@ function cpuCounters(cpus, uptime, time) {
114416
114526
  }
114417
114527
  function vmStatMemory(text, total) {
114418
114528
  const pages = fromEntries(getSomes(pipe(text, split$1("\n"), map$10((line) => map$13(match$2(/^"?([^":]+)"?:\s+([0-9]+)\.$/u)(trim(line)), (match) => [match[1] ?? "", match[2] ?? ""])))));
114419
- const page = decodeSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), map$13((match) => match[1] ?? ""), getOrElse$1(constant(""))));
114420
- function count(name) {
114421
- return decodeSync(FiniteFromString)(pages[name] ?? "");
114422
- }
114529
+ const page = decodeUnknownSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), flatMap$8(get$11(1)), getOrUndefined$1));
114530
+ const counts = decodeUnknownSync(VmStatPages)(pages);
114423
114531
  return {
114424
114532
  total,
114425
- used: clamp((count("Anonymous pages") - count("Pages purgeable") + count("Pages wired down") + count("Pages occupied by compressor")) * page, {
114533
+ used: clamp((counts["Anonymous pages"] - counts["Pages purgeable"] + counts["Pages wired down"] + counts["Pages occupied by compressor"]) * page, {
114426
114534
  maximum: total,
114427
114535
  minimum: 0
114428
114536
  })
@@ -114474,8 +114582,8 @@ function sample(current, memory, disk, previous, load) {
114474
114582
  return [fields[0], decodeSync(FiniteFromString)(fields[1] ?? "") * 1024];
114475
114583
  }));
114476
114584
  return reading(current, {
114477
- total: values["MemTotal:"] ?? 0,
114478
- used: (values["MemTotal:"] ?? 0) - (values["MemAvailable:"] ?? 0)
114585
+ total: decodeUnknownSync(Finite)(values["MemTotal:"]),
114586
+ used: decodeUnknownSync(Finite)(values["MemTotal:"]) - decodeUnknownSync(Finite)(values["MemAvailable:"])
114479
114587
  }, pipe(disk, match$8({
114480
114588
  onNone: () => [],
114481
114589
  onSome: diskRows
@@ -114761,11 +114869,14 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
114761
114869
  const failure = yield* make$56(none());
114762
114870
  function walk(pending, found) {
114763
114871
  if (isReadonlyArrayEmpty(pending)) return succeed$5(found);
114764
- return pipe(pending, forEach$1((path) => option$1(map$7(fs.readDirectory(`${CGROUP}${path}`), (names) => pipe(names, filter$5((name) => isSome(match$2(/\.(?:slice|scope|service)$/u)(name))), map$10((name) => ({
114872
+ return pipe(pending, forEach$1((path) => pipe(fs.readDirectory(`${CGROUP}${path}`), catchTag("PlatformError", (cause) => {
114873
+ if (isTagged(cause.reason, "NotFound")) return succeed$5(empty$15());
114874
+ return fail$6(cause);
114875
+ }), map$7((names) => pipe(names, filter$5((name) => isSome(match$2(/\.(?:slice|scope|service)$/u)(name))), map$10((name) => ({
114765
114876
  app: appCgroup(`${path}/${name}`, names),
114766
114877
  path: CgroupPath.make(`${path}/${name}`)
114767
114878
  }))))), { concurrency: "unbounded" }), flatMap$3((levels) => {
114768
- const children = flatten$4(getSomes(levels));
114879
+ const children = flatten$4(levels);
114769
114880
  return walk(pipe(children, filter$5((child) => !child.app && isSome(match$2(/(?:\.slice|\/user@[0-9]+\.service)$/u)(child.path))), map$10((child) => child.path)), [...found, ...pipe(children, filter$5((child) => child.app), map$10((child) => child.path))]);
114770
114881
  }));
114771
114882
  }
@@ -115082,17 +115193,17 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
115082
115193
  exposure: input.name,
115083
115194
  worker: input.worker
115084
115195
  });
115085
- if (input.worker === localWorker) return yield* tap$2(exposures.expose(omit(input, ["worker"])), () => inventory.refresh);
115196
+ if (input.worker === localWorker) return yield* onExit$1(exposures.expose(omit(input, ["worker"])), () => inventory.refresh);
115086
115197
  return yield* remote(yield* selectedWorker(input.worker), (client) => client("exposures.apply", omit(input, ["worker"])));
115087
- }, tap$2(() => reactivity.invalidate(["deployInventory"])), asDeployError),
115198
+ }, onExit$1(() => reactivity.invalidate(["deployInventory"])), asDeployError),
115088
115199
  hide: fn("Fleet.hide")(function* (input) {
115089
115200
  yield* annotateCurrentSpan({
115090
115201
  exposure: input.name,
115091
115202
  worker: input.worker
115092
115203
  });
115093
- if (input.worker === localWorker) return yield* tap$2(exposures.hide(input.name), () => inventory.refresh);
115204
+ if (input.worker === localWorker) return yield* onExit$1(exposures.hide(input.name), () => inventory.refresh);
115094
115205
  return yield* remote(yield* selectedWorker(input.worker), (client) => client("exposures.remove", { name: input.name }));
115095
- }, tap$2(() => reactivity.invalidate(["deployInventory"])), asDeployError),
115206
+ }, onExit$1(() => reactivity.invalidate(["deployInventory"])), asDeployError),
115096
115207
  history: fn("Fleet.history")(function* (query) {
115097
115208
  yield* annotateCurrentSpan("minutes", toMinutes(query.minutes));
115098
115209
  return yield* metrics.read(query);
@@ -115103,7 +115214,7 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
115103
115214
  minutes: toMinutes(query.minutes),
115104
115215
  workers: workers.length + 1
115105
115216
  });
115106
- return [yield* metrics.read(query), ...yield* forEach$1(workers, (worker) => pipe(remote(worker, (client) => client("metrics.history", query)), timeout(seconds(2)), map$7((value) => ({
115217
+ yield* forEach$1(workers, (worker) => pipe(remote(worker, (client) => client("metrics.history", query)), timeout(seconds(2)), map$7((value) => ({
115107
115218
  ...value,
115108
115219
  worker: worker.name
115109
115220
  })), tapError$3((cause) => logWarning("A worker history could not be read", cause)), catch_$2(fnUntraced(function* (cause) {
@@ -115113,7 +115224,7 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
115113
115224
  stale: true,
115114
115225
  worker: worker.name
115115
115226
  };
115116
- })), tap$2((value) => update(lastMetrics, (all) => set$3(all, [worker.name, query.minutes], value)))), { concurrency: "unbounded" })];
115227
+ })), tap$2((value) => update(lastMetrics, (all) => set$3(all, [worker.name, query.minutes], value)))), { concurrency: "unbounded" });
115117
115228
  }),
115118
115229
  run: fn("Fleet.run")(function* (input) {
115119
115230
  yield* annotateCurrentSpan({
@@ -115122,7 +115233,7 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
115122
115233
  });
115123
115234
  if (input.worker === localWorker) return yield* inventory.run(omit(input, ["worker"]));
115124
115235
  return yield* remote(yield* selectedWorker(input.worker), (client) => client("inventory.start", omit(input, ["worker"])));
115125
- }, tap$2(() => reactivity.invalidate(["deployInventory"])), mapError$2((cause) => {
115236
+ }, onExit$1(() => reactivity.invalidate(["deployInventory"])), mapError$2((cause) => {
115126
115237
  if (is$2(DeployError)(cause)) return cause;
115127
115238
  return DeployError.make({
115128
115239
  cause,
@@ -115177,7 +115288,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
115177
115288
  capacity: size$4(SERIES),
115178
115289
  lookup: (minutes) => {
115179
115290
  const query = { minutes };
115180
- return pipe(fromEffect(fleet.current(query)), concat$1(fromEffect(fleet.metrics(query))), concat$1(merge$1(fromEffectSchedule(fleet.current(query), spaced(min$1(resolution(minutes), seconds(30)))), drain(fromEffectSchedule(fleet.metrics(query), spaced(clamp$1(resolution(minutes), {
115291
+ return pipe(fromEffect(fleet.current(query)), concat$1(fromEffect(andThen(fleet.metrics(query), fleet.current(query)))), concat$1(merge$1(fromEffectSchedule(fleet.current(query), spaced(min$1(resolution(minutes), seconds(30)))), drain(fromEffectSchedule(fleet.metrics(query), spaced(clamp$1(resolution(minutes), {
115181
115292
  maximum: seconds(30),
115182
115293
  minimum: seconds(5)
115183
115294
  })))))), share({
@@ -115189,19 +115300,16 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
115189
115300
  });
115190
115301
  return RpcContracts.of({
115191
115302
  "exposures.apply": fnUntraced(function* (input) {
115192
- const url = yield* exposures.expose(input);
115193
- yield* localInventory.refresh;
115194
- return url;
115195
- }, mutation(["deployInventory"])),
115303
+ return yield* onExit$1(exposures.expose(input), () => localInventory.refresh);
115304
+ }, onExit$1(() => invalidate(["deployInventory"]))),
115196
115305
  "exposures.expose": fleet.expose,
115197
115306
  "exposures.hide": fleet.hide,
115198
115307
  "exposures.remove": fnUntraced(function* (input) {
115199
- yield* exposures.hide(input.name);
115200
- yield* localInventory.refresh;
115201
- }, mutation(["deployInventory"])),
115308
+ yield* onExit$1(exposures.hide(input.name), () => localInventory.refresh);
115309
+ }, onExit$1(() => invalidate(["deployInventory"]))),
115202
115310
  "inventory.run": fleet.run,
115203
115311
  "inventory.snapshot": () => fleet.local,
115204
- "inventory.start": (input) => mutation(localInventory.run(input), ["deployInventory"]),
115312
+ "inventory.start": (input) => onExit$1(localInventory.run(input), () => invalidate(["deployInventory"])),
115205
115313
  "inventory.watch": () => inventory,
115206
115314
  "metrics.history": fleet.history,
115207
115315
  "metrics.watch": (query) => unwrap$4(get$7(metrics, query.minutes))
@@ -115385,7 +115493,7 @@ const ToolHandlers = ToolContracts.toLayer(map$7(Fleet, (fleet) => ToolContracts
115385
115493
  }),
115386
115494
  read_resource_history: fnUntraced(function* (input) {
115387
115495
  const value = yield* all$1({
115388
- machines: fleet.metrics({ minutes: input.minutes }),
115496
+ machines: andThen(fleet.metrics({ minutes: input.minutes }), fleet.current({ minutes: input.minutes })),
115389
115497
  snapshot: fleet.snapshot
115390
115498
  }, { concurrency: "unbounded" });
115391
115499
  yield* checkWorker(value.snapshot, input.worker);