@deslop/deploy 0.1.1310 → 0.1.1312

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
@@ -6389,6 +6389,54 @@ const empty$16 = () => ({});
6389
6389
  */
6390
6390
  const isEmptyRecord = (self) => Object.keys(self).length === 0;
6391
6391
  /**
6392
+ * Takes an iterable and a projection function and returns a record.
6393
+ * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.
6394
+ *
6395
+ * **Example** (Building a record from mapped iterable values)
6396
+ *
6397
+ * ```ts import.meta.vitest
6398
+ * import { Record } from "effect"
6399
+ *
6400
+ * Record.fromIterableWith([1, 2, 3, 4], (a) => [String(a), a * 2]) // => { "1": 2, "2": 4, "3": 6, "4": 8 }
6401
+ * ```
6402
+ *
6403
+ * @stability stable
6404
+ * @category constructors
6405
+ * @since 2.0.0
6406
+ */
6407
+ const fromIterableWith = /*#__PURE__*/ dual(2, (self, f) => {
6408
+ const out = empty$16();
6409
+ for (const a of self) {
6410
+ const [k, b] = f(a);
6411
+ assignProperty(out, k, b);
6412
+ }
6413
+ return out;
6414
+ });
6415
+ /**
6416
+ * Creates a new record from an iterable, utilizing the provided function to determine the key for each element.
6417
+ *
6418
+ * **Example** (Building a record keyed by iterable values)
6419
+ *
6420
+ * ```ts import.meta.vitest
6421
+ * import { Record } from "effect"
6422
+ *
6423
+ * const users = [
6424
+ * { id: "2", name: "name2" },
6425
+ * { id: "1", name: "name1" }
6426
+ * ]
6427
+ *
6428
+ * Record.fromIterableBy(
6429
+ * users,
6430
+ * (user) => user.id
6431
+ * ) // => { "1": { id: "1", name: "name1" }, "2": { id: "2", name: "name2" } }
6432
+ * ```
6433
+ *
6434
+ * @stability stable
6435
+ * @category constructors
6436
+ * @since 2.0.0
6437
+ */
6438
+ const fromIterableBy = /*#__PURE__*/ dual(2, (items, f) => fromIterableWith(items, (a) => [f(a), a]));
6439
+ /**
6392
6440
  * Builds a record from an iterable of key-value pairs.
6393
6441
  *
6394
6442
  * **Details**
@@ -16854,7 +16902,27 @@ const round = /*#__PURE__*/ dual(2, (self, precision) => {
16854
16902
  const factor = Math.pow(10, precision);
16855
16903
  return Math.round(self * factor) / factor;
16856
16904
  });
16857
- globalThis.String;
16905
+ // ../../node_modules/.pnpm/effect@4.1.4/node_modules/effect/dist/String.js
16906
+ /**
16907
+ * Exposes the global string constructor.
16908
+ *
16909
+ * **When to use**
16910
+ *
16911
+ * Use to access native JavaScript string coercion or constructor behavior from
16912
+ * the Effect module namespace.
16913
+ *
16914
+ * **Gotchas**
16915
+ *
16916
+ * Calling `String(value)` returns a primitive string. Calling
16917
+ * `new String(value)` creates a boxed `String` object.
16918
+ *
16919
+ * @see {@link isString} for checking whether a value is a primitive string
16920
+ *
16921
+ * @stability stable
16922
+ * @category constructors
16923
+ * @since 4.0.0
16924
+ */
16925
+ const String$9 = globalThis.String;
16858
16926
  /**
16859
16927
  * Checks whether a value is a `string`.
16860
16928
  *
@@ -109169,7 +109237,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
109169
109237
  });
109170
109238
  const granted = fnUntraced(function* (params) {
109171
109239
  const response = yield* post$1(TOKEN_PATH, params);
109172
- if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse$1(() => "Auth refused the sign-in")) });
109240
+ if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse$1(constant("Auth refused the sign-in"))) });
109173
109241
  return yield* schemaBodyJson$1(TokenResponse)(yield* filterStatusOk$1(response));
109174
109242
  });
109175
109243
  const sessionOf = fnUntraced(function* (tokens, clientId, idHash) {
@@ -109253,7 +109321,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
109253
109321
  for (const session of yield* findSessionsOf(userId)) {
109254
109322
  if (yield* fresh(session)) return value$2(session.access);
109255
109323
  const renewed = yield* result$1(asAuthError("AI access is temporarily unavailable")(refreshed(session.idHash)));
109256
- if (renewed._tag === "Success") return value$2(renewed.success.access);
109324
+ if (isSuccess$1(renewed)) return value$2(renewed.success.access);
109257
109325
  if (is$2(AuthError)(renewed.failure) && renewed.failure.error === "temporarily_unavailable") return yield* renewed.failure;
109258
109326
  }
109259
109327
  const now$3 = yield* now;
@@ -109327,7 +109395,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
109327
109395
  issuer: new URL(ISSUER_PATH, issuer).href,
109328
109396
  typ: "at+jwt"
109329
109397
  }), provideService$2(Jwks, jwks), provideService$2(Signature, signature), mapError$2((cause) => {
109330
- if (isJoseError(cause) && cause.reason._tag === "KeySetUnavailable") return AuthError.make({
109398
+ if (isJoseError(cause) && cause.reason instanceof KeySetUnavailable) return AuthError.make({
109331
109399
  cause,
109332
109400
  error: "temporarily_unavailable",
109333
109401
  message: "The authorization service is temporarily unavailable"
@@ -110762,8 +110830,8 @@ const installService = fnUntraced(function* (name, command, options) {
110762
110830
  yield* systemctl("daemon-reload");
110763
110831
  yield* systemctl("enable", unit);
110764
110832
  yield* systemctl(match(options?.restart === false, {
110765
- onFalse: () => "restart",
110766
- onTrue: () => "start"
110833
+ onFalse: constant("restart"),
110834
+ onTrue: constant("start")
110767
110835
  }), unit);
110768
110836
  return `${unit} installed\n`;
110769
110837
  });
@@ -110872,7 +110940,7 @@ function layerSignIn(issuer) {
110872
110940
  const started = yield* result$1(gen(function* () {
110873
110941
  const params = yield* schemaSearchParams(CallbackParams);
110874
110942
  if (!contains$1(params.state, saved.state)) return yield* AuthError.make({ message: "The sign-in began in another browser" });
110875
- if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse$1(params.error, () => "without a code")}` });
110943
+ if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse$1(params.error, constant("without a code"))}` });
110876
110944
  if (!contains$1(params.iss, new URL("/api/auth", issuer).href)) return yield* AuthError.make({ message: "The answer came from another issuer" });
110877
110945
  return yield* sessions.start({
110878
110946
  client_id: yield* clientId,
@@ -111083,7 +111151,7 @@ const CpuTime$1 = Struct$2({
111083
111151
  });
111084
111152
  const TextFromEmpty = pipe(String$6, decodeTo(Option(String$6), {
111085
111153
  decode: transform$4((value) => liftPredicate(value, isNonEmpty$1)),
111086
- encode: transform$4((value) => getOrElse$1(value, () => ""))
111154
+ encode: transform$4((value) => getOrElse$1(value, constant("")))
111087
111155
  }));
111088
111156
  const OptionalTextFromEmpty = pipe(OptionFromOptionalKey(String$6), decodeTo(Option(String$6), {
111089
111157
  decode: transform$4((value) => filter$7(value, isNonEmpty$1)),
@@ -111659,23 +111727,23 @@ function failureReason(result, status, ran) {
111659
111727
  return pipe(value(result), when("exit-code", () => match$7(fromUndefinedOr(SIGNALS[status - 128]), {
111660
111728
  onNone: () => `Exited with code ${status}`,
111661
111729
  onSome: (name) => `Exited with code ${status} (${name})`
111662
- })), when("signal", () => `Killed by ${signal}`), when("core-dump", () => `Crashed with ${signal}`), when("oom-kill", () => "Killed for running out of memory"), when("timeout", () => "Timed out"), when("watchdog", () => "Stopped answering its watchdog"), when("start-limit-hit", () => "Restarted too often"), orElse(() => `Failed: ${result}`));
111730
+ })), when("signal", () => `Killed by ${signal}`), when("core-dump", () => `Crashed with ${signal}`), when("oom-kill", constant("Killed for running out of memory")), when("timeout", constant("Timed out")), when("watchdog", constant("Stopped answering its watchdog")), when("start-limit-hit", constant("Restarted too often")), orElse(() => `Failed: ${result}`));
111663
111731
  }
111664
111732
  function exitFailure(status) {
111665
111733
  if (status < 0) return failureReason("signal", -status, true);
111666
111734
  return failureReason("exit-code", status, true);
111667
111735
  }
111668
111736
  function unitFailures(text) {
111669
- return fromEntries(pipe(trim(text), split$2(/\n\s*\n/u), filter$5(isNonEmpty$1), map$10((block) => {
111670
- const fields = fromEntries(pipe(block, split$2("\n"), filter$5(includes("=")), map$10((line) => {
111737
+ return pipe(trim(text), split$2(/\n\s*\n/u), filter$5(isNonEmpty$1), fromIterableWith((block) => {
111738
+ const fields = pipe(block, split$2("\n"), filter$5(includes("=")), fromIterableWith((line) => {
111671
111739
  const [key, ...value] = split$2(line, "=");
111672
111740
  return [key, join$4(value, "=")];
111673
- })));
111741
+ }));
111674
111742
  return [UnitId.make(fields["Id"] ?? ""), {
111675
111743
  at: map$13(parse$3(replace(/^@/u, "")(fields["StateChangeTimestamp"] ?? "")), (seconds) => mapEpochMillis(makeUnsafe$5(0), () => seconds * 1e3)),
111676
- reason: failureReason(fields["Result"] ?? "", getOrElse$1(parse$3(fields["ExecMainStatus"] ?? ""), () => 0), fields["ExecMainCode"] !== "0")
111744
+ reason: failureReason(fields["Result"] ?? "", getOrElse$1(parse$3(fields["ExecMainStatus"] ?? ""), constant(0)), fields["ExecMainCode"] !== "0")
111677
111745
  }];
111678
- })));
111746
+ }));
111679
111747
  }
111680
111748
  // src/services/inventory/lib/launchd.ts
111681
111749
  const launchAgents = fnUntraced(function* (text) {
@@ -111766,12 +111834,12 @@ function flagParts(token) {
111766
111834
  });
111767
111835
  }
111768
111836
  function alias(value$4) {
111769
- return pipe(value(value$4), when("vite-plus", () => "vp"), orElse(() => value$4));
111837
+ return pipe(value(value$4), when("vite-plus", constant("vp")), orElse(() => value$4));
111770
111838
  }
111771
111839
  function shellRest(tokens) {
111772
- const script = pipe(tokens, get$11(2), getOrElse$1(() => ""));
111840
+ const script = pipe(tokens, get$11(2), getOrElse$1(constant("")));
111773
111841
  const shifts = match$7(match$2(/\bshift\b/gu)(script), {
111774
- onNone: () => 0,
111842
+ onNone: constant(0),
111775
111843
  onSome: (matches) => matches.length
111776
111844
  });
111777
111845
  if (includes("exec \"$@\"")(script)) return drop$1(tokens, 4 + shifts);
@@ -111779,7 +111847,7 @@ function shellRest(tokens) {
111779
111847
  return pipe(findFirst(segments, (words) => words[0] === "exec"), map$13((words) => drop$1(words, 1)), orElse$3(() => findFirst(segments, (words) => !contains(SETUP, words[0] ?? ""))), getOrElse$1(() => take$3(tokens, 1)));
111780
111848
  }
111781
111849
  function unwrapTokens(tokens, cwd) {
111782
- const name = basename(getOrElse$1(head(tokens), () => ""));
111850
+ const name = basename(getOrElse$1(head(tokens), constant("")));
111783
111851
  if (contains(WRAPPERS, name)) return unwrapTokens(pipe(findFirstIndex(tokens, (token) => token === "--"), filter$7((index) => index > 0), match$7({
111784
111852
  onNone: () => {
111785
111853
  const tail = drop$1(tokens, 1);
@@ -111790,11 +111858,11 @@ function unwrapTokens(tokens, cwd) {
111790
111858
  },
111791
111859
  onSome: (index) => drop$1(tokens, index + 1)
111792
111860
  })), cwd);
111793
- if (contains(SHELLS, name) && pipe(tokens, get$11(1), getOrElse$1(() => "")) === "-c") return unwrapTokens(shellRest(tokens), cwd);
111861
+ if (contains(SHELLS, name) && pipe(tokens, get$11(1), getOrElse$1(constant(""))) === "-c") return unwrapTokens(shellRest(tokens), cwd);
111794
111862
  if (contains(RUNTIMES, name)) return pipe(tokens, findFirstIndex((token, index) => index > 0 && !isFlag(token)), match$7({
111795
111863
  onNone: () => tokens,
111796
111864
  onSome: (index) => {
111797
- const script = pipe(tokens, get$11(index), getOrElse$1(() => ""));
111865
+ const script = pipe(tokens, get$11(index), getOrElse$1(constant("")));
111798
111866
  const pkg = capture(/.*node_modules\/((?:@[^/]+\/)?[^/.][^/]*)\//u, script);
111799
111867
  const app = orElse$3(capture(/\.deslop\/([^/]+)\//u, script), () => flatMap$8(cwd, (value) => capture(/\/apps\/([^/]+)$/u, value)));
111800
111868
  return [pipe(pkg, orElse$3(() => app), getOrElse$1(() => basename(script))), ...drop$1(tokens, index + 1)];
@@ -111805,9 +111873,9 @@ function unwrapTokens(tokens, cwd) {
111805
111873
  function unwrap(argv, cwd) {
111806
111874
  const tokens = match(length$2(argv) === 1, {
111807
111875
  onFalse: () => argv,
111808
- onTrue: () => pipe(head(argv), getOrElse$1(() => ""), split$2(/\s+/u), filter$5(isNonEmpty$1))
111876
+ onTrue: () => pipe(head(argv), getOrElse$1(constant("")), split$2(/\s+/u), filter$5(isNonEmpty$1))
111809
111877
  });
111810
- return unwrapTokens([replace(/:$/u, "")(getOrElse$1(head(tokens), () => "")), ...drop$1(tokens, 1)], cwd);
111878
+ return unwrapTokens([replace(/:$/u, "")(getOrElse$1(head(tokens), constant(""))), ...drop$1(tokens, 1)], cwd);
111811
111879
  }
111812
111880
  function scan(name, subject, args, words, values) {
111813
111881
  return match$7(head(args), {
@@ -111858,7 +111926,7 @@ function commandLabel(argv, cwd) {
111858
111926
  const subject = pipe(SUBJECT, get$12(name), getOrElse$1(() => empty$15()));
111859
111927
  const scanned = scan(name, subject, args, [], {});
111860
111928
  if (contains(SHELLS, name) && isReadonlyArrayEmpty(scanned.words)) return {
111861
- detail: pipe(cwd, map$13(basename), getOrElse$1(() => "")),
111929
+ detail: pipe(cwd, map$13(basename), getOrElse$1(constant(""))),
111862
111930
  name
111863
111931
  };
111864
111932
  return match$7(scanned.ssh, {
@@ -111870,7 +111938,7 @@ function commandLabel(argv, cwd) {
111870
111938
  const remote = commandLabel(ssh.remote, none());
111871
111939
  return {
111872
111940
  detail: pipe([ssh.host, match(isNonEmpty$1(remote.name), {
111873
- onFalse: () => "",
111941
+ onFalse: constant(""),
111874
111942
  onTrue: () => `→ ${remote.name}`
111875
111943
  })], filter$5(isNonEmpty$1), join$4(" ")),
111876
111944
  name
@@ -111889,8 +111957,8 @@ function processOwner(cgroup) {
111889
111957
  const service = findLastIndex(segments, endsWith(".service"));
111890
111958
  const userService = findFirstIndex(segments, (segment) => isSome(match$2(/^user@[0-9]+\.service$/u)(segment)));
111891
111959
  return pipe(userService, filter$7((index) => !exists(service, (last) => last > index)), flatMap$8((index) => pipe(segments, drop$1(index + 1), findFirst((segment) => match$2(/^app-(.+)\.slice$/u)(segment)))), map$13((match) => AppId.make(`service:user:${match[1]}.service`)), orElse$3(() => map$13(service, (index) => AppId.make(`service:${pipe(userService, exists((first) => index > first), match({
111892
- onFalse: () => "system",
111893
- onTrue: () => "user"
111960
+ onFalse: constant("system"),
111961
+ onTrue: constant("user")
111894
111962
  }))}:${segments[index]}`))));
111895
111963
  }
111896
111964
  function loopbackPort(item) {
@@ -111912,8 +111980,8 @@ function ports(items) {
111912
111980
  return pipe(items, filter$5((item) => appPort(item) && contains$1(item.http, true)), sort(mapInput(String$10, (item) => `${item.worker}:${getOrUndefined$1(item.port)}:${getOrUndefined$1(item.address)}`)), dedupeWith((a, b) => a.worker === b.worker && makeEquivalence$5((x, y) => x === y)(a.port, b.port)));
111913
111981
  }
111914
111982
  function itemOwner(item) {
111915
- if (item.kind === "container") return AppId.make(`container:${slice$1(0, 12)(getOrElse$1(last$1(split$2(item.id, ":docker:")), () => ""))}`);
111916
- return AppId.make(`service:${getOrElse$1(item.scope, () => "system")}:${item.name}`);
111983
+ if (item.kind === "container") return AppId.make(`container:${slice$1(0, 12)(getOrElse$1(last$1(split$2(item.id, ":docker:")), constant("")))}`);
111984
+ return AppId.make(`service:${getOrElse$1(item.scope, constant("system"))}:${item.name}`);
111917
111985
  }
111918
111986
  function fullName(item) {
111919
111987
  if (item.kind === "port") return getOrElse$1(item.process, () => item.name);
@@ -111943,7 +112011,7 @@ function socket(worker, binding) {
111943
112011
  function workloads(items) {
111944
112012
  const listeners = filter$5(items, (item) => item.kind === "port");
111945
112013
  const byUnit = pipe(listeners, groupBy((listener) => listener.worker), map$11((worker) => groupBy(worker, (listener) => match$7(listener.unit, {
111946
- onNone: () => "none",
112014
+ onNone: constant("none"),
111947
112015
  onSome: (unit) => `unit:${unit}`
111948
112016
  }))));
111949
112017
  const bySocket = fromIterable$5(map$10(reverse(filter$5(listeners, (listener) => !contains$1(listener.address, "container"))), (listener) => [socket(listener.worker, listener), listener]));
@@ -111986,7 +112054,7 @@ function workloads(items) {
111986
112054
  const exposuresBySocket = pipe(exposures, map$10((item, index) => ({
111987
112055
  index,
111988
112056
  item
111989
- })), groupBy((entry) => `${entry.item.worker}:${getOrElse$1(entry.item.port, () => 0)}`));
112057
+ })), groupBy((entry) => `${entry.item.worker}:${getOrElse$1(entry.item.port, constant(0))}`));
111990
112058
  const linked = map$10(rows, (row) => {
111991
112059
  const reachable = dedupe(pipe(row.listeners, filter$5((listener) => exists(listener.port, (port) => sameSocket(listener, {
111992
112060
  address: `127.0.0.1:${port}`,
@@ -112067,11 +112135,11 @@ function fold(node) {
112067
112135
  }
112068
112136
  function processTree(rows) {
112069
112137
  const pids = fromIterable(map$10(rows, (row) => row.pid));
112070
- const children = reduce(rows, empty$11(), (all, row) => set$3(all, row.parent, [...pipe(all, get$8(row.parent), getOrElse$1(empty$15)), row]));
112138
+ const children = groupBy(rows, (row) => String$9(row.parent));
112071
112139
  const visited = empty$5();
112072
112140
  function build(row) {
112073
112141
  add$1(visited, row.pid);
112074
- const below = pipe(children, get$8(row.pid), getOrElse$1(empty$15), filter$5((child) => !has(visited, child.pid)), map$10(build));
112142
+ const below = pipe(get$12(children, `${row.pid}`), getOrElse$1(empty$15), filter$5((child) => !has(visited, child.pid)), map$10(build));
112075
112143
  const self = {
112076
112144
  children: [],
112077
112145
  command: row.command,
@@ -112151,8 +112219,8 @@ function appOf(row, withProcesses) {
112151
112219
  function exposureOf(item) {
112152
112220
  return {
112153
112221
  access: pipe(item.publicAccess, contains$1(true), match({
112154
- onFalse: () => "tailnet",
112155
- onTrue: () => "public"
112222
+ onFalse: constant("tailnet"),
112223
+ onTrue: constant("public")
112156
112224
  })),
112157
112225
  id: item.id,
112158
112226
  name: ExposureName.make(item.name),
@@ -112204,12 +112272,12 @@ function listApps(snapshot, input) {
112204
112272
  }
112205
112273
  function ownerNames(snapshot) {
112206
112274
  const byWorker = groupBy(snapshot.items, (item) => item.worker);
112207
- return fromEntries(map$10(workerNames(snapshot), (worker) => [worker, fromEntries(pipe(byWorker[worker] ?? empty$15(), filter$5((item) => item.kind === "service" || item.kind === "container"), flatMap$6((item) => [[itemOwner(item), workloadName(item)]])))]));
112275
+ return fromIterableWith(workerNames(snapshot), (worker) => [worker, pipe(byWorker[worker] ?? empty$15(), filter$5((item) => item.kind === "service" || item.kind === "container"), fromIterableWith((item) => [itemOwner(item), workloadName(item)]))]);
112208
112276
  }
112209
112277
  function requestOf(item) {
112210
112278
  return {
112211
112279
  name: UnitId.make(item.name),
112212
- scope: getOrElse$1(item.scope, () => "system"),
112280
+ scope: getOrElse$1(item.scope, constant("system")),
112213
112281
  worker: item.worker
112214
112282
  };
112215
112283
  }
@@ -112223,10 +112291,10 @@ const jobRequest = fnUntraced(function* (snapshot, input) {
112223
112291
  const SECRET = /(?:token|secret|passw(?:or)?d|key|auth|credential|cookie|session)/iu;
112224
112292
  const PROCESS_INTERVAL = seconds(2);
112225
112293
  function processStatus(status) {
112226
- const values = fromEntries(pipe(trim(status), split$2("\n"), map$10((line) => {
112294
+ const values = pipe(trim(status), split$2("\n"), fromIterableWith((line) => {
112227
112295
  const at = getOrThrow$1(indexOf(":")(line));
112228
112296
  return [slice$1(0, at)(line), trim(slice$1(at + 1)(line))];
112229
- })));
112297
+ }));
112230
112298
  return {
112231
112299
  memory: decodeSync(ResidentMemoryFromKiB)(split$2(values["VmRSS"] ?? "", /\s+/u)[0] || "0"),
112232
112300
  name: values["Name"] ?? "",
@@ -112336,7 +112404,7 @@ function launchdProcesses(text, agents) {
112336
112404
  1: match[1],
112337
112405
  2: match[2] ?? "",
112338
112406
  3: match[3] ?? ""
112339
- })), map$13((fields) => pipe(hours(getOrElse$1(fields[1], () => 0)), sum(minutes(fields[2])), sum(seconds(fields[3])))), filter$7(isFinite$1))
112407
+ })), map$13((fields) => pipe(hours(getOrElse$1(fields[1], constant(0))), sum(minutes(fields[2])), sum(seconds(fields[3])))), filter$7(isFinite$1))
112340
112408
  }), (times) => {
112341
112409
  const command = commandArgs(pipe(trim(row.args), split$2(/\s+/u), join$4("\0")));
112342
112410
  return {
@@ -112346,7 +112414,7 @@ function launchdProcesses(text, agents) {
112346
112414
  cpu: none(),
112347
112415
  label: commandLabel(command, none()),
112348
112416
  memory: row.memory,
112349
- name: pipe(head(command), flatMap$8((head) => last$1(split$2(head, "/"))), getOrElse$1(() => "")),
112417
+ name: pipe(head(command), flatMap$8((head) => last$1(split$2(head, "/"))), getOrElse$1(constant(""))),
112350
112418
  parent: row.parent,
112351
112419
  pid: row.pid
112352
112420
  }),
@@ -112390,8 +112458,8 @@ function socketLine(line) {
112390
112458
  function lsofSocket(file) {
112391
112459
  if (includes("->")(file.address) || !contains(["TCP", "UDP"], file.protocol)) return none();
112392
112460
  const address = replace(/^\*:/u, match(file.type === "IPv4", {
112393
- onFalse: () => "*:",
112394
- onTrue: () => "0.0.0.0:"
112461
+ onFalse: constant("*:"),
112462
+ onTrue: constant("0.0.0.0:")
112395
112463
  }))(file.address);
112396
112464
  return flatMap$8(file.pid, (pid) => map$13(portOf(address), (port) => ({
112397
112465
  address,
@@ -112402,7 +112470,7 @@ function lsofSocket(file) {
112402
112470
  }),
112403
112471
  protocol: toLowerCase(file.protocol),
112404
112472
  state: match(file.protocol === "TCP", {
112405
- onFalse: () => "UNCONN",
112473
+ onFalse: constant("UNCONN"),
112406
112474
  onTrue: () => replace(/^ST=/u, "")(file.state) || "LISTEN"
112407
112475
  })
112408
112476
  })));
@@ -112505,7 +112573,7 @@ function portItems(sockets, worker, http, origin) {
112505
112573
  }), liftPredicate(isNonEmpty$1));
112506
112574
  })
112507
112575
  });
112508
- const response = yield* match(probeSocket(socket, getOrElse$1(process, () => "")), {
112576
+ const response = yield* match(probeSocket(socket, getOrElse$1(process, constant(""))), {
112509
112577
  onFalse: () => succeed$5(none()),
112510
112578
  onTrue: fnUntraced(function* () {
112511
112579
  return yield* pipe(http.head(`http://127.0.0.1:${socket.port}/`, { headers: toHeaders(new NativeSpan({
@@ -112524,7 +112592,7 @@ function portItems(sockets, worker, http, origin) {
112524
112592
  });
112525
112593
  return InventoryItem.make({
112526
112594
  address: some$1(socket.address),
112527
- detail: `${socket.address} · ${getOrElse$1(process, () => "process unavailable")}`,
112595
+ detail: `${socket.address} · ${getOrElse$1(process, constant("process unavailable"))}`,
112528
112596
  http: some$1(exists(response, (value) => value.http)),
112529
112597
  id: ItemId.make(`${worker}:port:${socket.protocol}:${socket.address}`),
112530
112598
  kind: "port",
@@ -112532,8 +112600,8 @@ function portItems(sockets, worker, http, origin) {
112532
112600
  port: some$1(socket.port),
112533
112601
  process,
112534
112602
  protocol: some$1(match(socket.protocol === "udp", {
112535
- onFalse: () => "tcp",
112536
- onTrue: () => "udp"
112603
+ onFalse: constant("tcp"),
112604
+ onTrue: constant("udp")
112537
112605
  })),
112538
112606
  state: socket.state,
112539
112607
  ui: some$1(exists(response, (value) => value.ui)),
@@ -112577,8 +112645,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112577
112645
  const processState = yield* make$54(none());
112578
112646
  const units = fnUntraced(function* (system) {
112579
112647
  const scope = match(system, {
112580
- onFalse: () => "user",
112581
- onTrue: () => "system"
112648
+ onFalse: constant("user"),
112649
+ onTrue: constant("system")
112582
112650
  });
112583
112651
  const scopeFlags = match(system, {
112584
112652
  onFalse: () => ["--user"],
@@ -112613,8 +112681,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112613
112681
  detail: `${scope} · ${row.description}`,
112614
112682
  failure: get$12(failures, row.unit),
112615
112683
  health: match(row.active === "failed", {
112616
- onFalse: () => "quiet",
112617
- onTrue: () => "error"
112684
+ onFalse: constant("quiet"),
112685
+ onTrue: constant("error")
112618
112686
  }),
112619
112687
  id: ItemId.make(`${worker}:${scope}:${row.unit}`),
112620
112688
  kind: "service",
@@ -112642,33 +112710,33 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112642
112710
  "restarting",
112643
112711
  "paused"
112644
112712
  ], row.State),
112645
- bindings: some$1([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, () => ""))), (match) => ({
112713
+ bindings: some$1([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => ({
112646
112714
  address: "container",
112647
- port: getOrElse$1(parse$3(match[1] ?? ""), () => 0),
112715
+ port: getOrElse$1(parse$3(match[1] ?? ""), constant(0)),
112648
112716
  protocol: "tcp"
112649
112717
  })), ...map$10(fromIterable$8(matchAll(/((?:[0-9.]+|\[::\])):([0-9]+)->[0-9]+\/(tcp|udp)/gu)(row.Ports)), (match$8) => ({
112650
112718
  address: `${match$8[1]}:${match$8[2]}`,
112651
- port: getOrElse$1(parse$3(match$8[2] ?? ""), () => 0),
112719
+ port: getOrElse$1(parse$3(match$8[2] ?? ""), constant(0)),
112652
112720
  protocol: match(match$8[3] === "udp", {
112653
- onFalse: () => "tcp",
112654
- onTrue: () => "udp"
112721
+ onFalse: constant("tcp"),
112722
+ onTrue: constant("udp")
112655
112723
  })
112656
112724
  }))]),
112657
112725
  detail: row.Status,
112658
112726
  health: match(includes("unhealthy")(row.Status) || isSome(match$2(/Exited \([1-9]/u)(row.Status)), {
112659
112727
  onFalse: () => match(row.State === "restarting", {
112660
- onFalse: () => "quiet",
112661
- onTrue: () => "warning"
112728
+ onFalse: constant("quiet"),
112729
+ onTrue: constant("warning")
112662
112730
  }),
112663
- onTrue: () => "error"
112731
+ onTrue: constant("error")
112664
112732
  }),
112665
112733
  id: ItemId.make(`${worker}:docker:${row.ID}`),
112666
112734
  kind: "container",
112667
- links: some$1(dedupe(map$10(fromIterable$8(matchAll(/Host\(`([^`]+)`\)/gu)(getOrElse$1(row.Labels, () => ""))), (match) => `https://${match[1]}`))),
112735
+ links: some$1(dedupe(map$10(fromIterable$8(matchAll(/Host\(`([^`]+)`\)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => `https://${match[1]}`))),
112668
112736
  name: row.Names,
112669
112737
  state: match(includes("unhealthy")(row.Status), {
112670
112738
  onFalse: () => row.State,
112671
- onTrue: () => "unhealthy"
112739
+ onTrue: constant("unhealthy")
112672
112740
  }),
112673
112741
  url: none(),
112674
112742
  worker
@@ -112684,7 +112752,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112684
112752
  collect("Docker", docker),
112685
112753
  collect("Listening ports", flatMap$3(command("ss", ["-H", "-lntup"]), (text) => portItems(getSomes(pipe(trim(text), split$2("\n"), map$10(socketLine))), worker, http, {
112686
112754
  cwd: (processId) => option$1(fs.readLink(`/proc/${processId}/cwd`)),
112687
- unit: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/cgroup`)), (cgroup) => socketUnit(getOrElse$1(cgroup, () => "")))
112755
+ unit: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/cgroup`)), (cgroup) => socketUnit(getOrElse$1(cgroup, constant(""))))
112688
112756
  })))
112689
112757
  ]
112690
112758
  });
@@ -112720,8 +112788,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112720
112788
  reason: exitFailure(status)
112721
112789
  }))),
112722
112790
  health: match(isNone(agent.pid) && agent.status !== 0, {
112723
- onFalse: () => "quiet",
112724
- onTrue: () => "error"
112791
+ onFalse: constant("quiet"),
112792
+ onTrue: constant("error")
112725
112793
  }),
112726
112794
  id: ItemId.make(`${worker}:user:${agent.label}`),
112727
112795
  kind: "service",
@@ -112730,10 +112798,10 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112730
112798
  scope: some$1("user"),
112731
112799
  state: match$7(agent.pid, {
112732
112800
  onNone: () => match(agent.status === 0, {
112733
- onFalse: () => "failed · failed",
112734
- onTrue: () => "inactive · dead"
112801
+ onFalse: constant("failed · failed"),
112802
+ onTrue: constant("inactive · dead")
112735
112803
  }),
112736
- onSome: () => "running"
112804
+ onSome: constant("running")
112737
112805
  }),
112738
112806
  url: none(),
112739
112807
  worker
@@ -112755,7 +112823,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112755
112823
  "-d",
112756
112824
  "cwd",
112757
112825
  "-Fn"
112758
- ])), getOrElse$1(() => ""), split$2("\n"), findFirst(startsWith("n")), map$13(slice$1(1)));
112826
+ ])), getOrElse$1(constant("")), split$2("\n"), findFirst(startsWith("n")), map$13(slice$1(1)));
112759
112827
  }),
112760
112828
  unit: (processId) => succeed$5(pipe(owned, findFirst((record) => record.process.pid === processId), map$13((record) => record.unit)))
112761
112829
  })))]
@@ -112815,8 +112883,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112815
112883
  name: peer.HostName,
112816
112884
  self: some$1(true),
112817
112885
  state: match(peer.Online, {
112818
- onFalse: () => "offline",
112819
- onTrue: () => "online"
112886
+ onFalse: constant("offline"),
112887
+ onTrue: constant("online")
112820
112888
  }),
112821
112889
  url: none(),
112822
112890
  worker
@@ -112827,12 +112895,12 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112827
112895
  "--json"
112828
112896
  ]), flatMap$3(decodeEffect(fromJsonString(Serve))), map$7((status) => flatMap$6(toEntries(getOrElse$1(status.Web, () => ({}))), (site) => map$10(toEntries(site[1].Handlers), (handler) => InventoryItem.make({
112829
112897
  detail: `${pipe(status.AllowFunnel, exists((permissions) => permissions[site[0]] === true), match({
112830
- onFalse: () => "tailnet",
112831
- onTrue: () => "Funnel permitted (public)"
112832
- }))} → ${getOrElse$1(handler[1].Proxy, () => "non-proxy handler")}`,
112898
+ onFalse: constant("tailnet"),
112899
+ onTrue: constant("Funnel permitted (public)")
112900
+ }))} → ${getOrElse$1(handler[1].Proxy, constant("non-proxy handler"))}`,
112833
112901
  health: pipe(status.AllowFunnel, exists((permissions) => permissions[site[0]] === true), match({
112834
- onFalse: () => "quiet",
112835
- onTrue: () => "warning"
112902
+ onFalse: constant("quiet"),
112903
+ onTrue: constant("warning")
112836
112904
  })),
112837
112905
  id: ItemId.make(`${worker}:tailscale:${site[0]}:${handler[0]}`),
112838
112906
  kind: "exposure",
@@ -112890,7 +112958,7 @@ const SERIES = {
112890
112958
  10080: hours(1)
112891
112959
  };
112892
112960
  function counters(stat, uptime, time) {
112893
- const values = decodeSync(CpuCounters)(pipe(stat, split$2("\n"), head, getOrElse$1(() => ""), trim, split$2(/\s+/u), drop$1(1), take$3(8)));
112961
+ const values = decodeSync(CpuCounters)(pipe(stat, split$2("\n"), head, getOrElse$1(constant("")), trim, split$2(/\s+/u), drop$1(1), take$3(8)));
112894
112962
  return {
112895
112963
  cpuIdle: millis$1(((values[3] ?? 0) + (values[4] ?? 0)) * 10),
112896
112964
  cpuTotal: millis$1(sumAll(values) * 10),
@@ -112919,7 +112987,7 @@ function cpuCounters(cpus, uptime, time) {
112919
112987
  }
112920
112988
  function vmStatMemory(text, total) {
112921
112989
  const pages = fromEntries(getSomes(pipe(text, split$2("\n"), map$10((line) => map$13(match$2(/^"?([^":]+)"?:\s+([0-9]+)\.$/u)(trim(line)), (match) => [match[1] ?? "", match[2] ?? ""])))));
112922
- const page = decodeSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), map$13((match) => match[1] ?? ""), getOrElse$1(() => "")));
112990
+ const page = decodeSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), map$13((match) => match[1] ?? ""), getOrElse$1(constant(""))));
112923
112991
  function count(name) {
112924
112992
  return decodeSync(FiniteFromString)(pages[name] ?? "");
112925
112993
  }
@@ -112972,10 +113040,10 @@ function reading(current, memory, disks, load, previous) {
112972
113040
  };
112973
113041
  }
112974
113042
  function sample(current, memory, disk, previous, load) {
112975
- const values = fromEntries(pipe(trim(memory), split$2("\n"), map$10((line) => {
113043
+ const values = pipe(trim(memory), split$2("\n"), fromIterableWith((line) => {
112976
113044
  const fields = split$2(line, /\s+/u);
112977
113045
  return [fields[0], decodeSync(FiniteFromString)(fields[1] ?? "") * 1024];
112978
- })));
113046
+ }));
112979
113047
  return reading(current, {
112980
113048
  total: values["MemTotal:"] ?? 0,
112981
113049
  used: (values["MemTotal:"] ?? 0) - (values["MemAvailable:"] ?? 0)
@@ -112986,7 +113054,7 @@ function sample(current, memory, disk, previous, load) {
112986
113054
  mount: fields[0],
112987
113055
  total: decodeSync(FiniteFromString)(fields[1] ?? ""),
112988
113056
  used: decodeSync(FiniteFromString)(fields[2] ?? "")
112989
- }))), decodeSync(LoadAverages)(pipe(getOrElse$1(load, () => ""), trim, split$2(/\s+/u), filter$5(isNonEmpty$1), take$3(3))), previous);
113057
+ }))), decodeSync(LoadAverages)(pipe(getOrElse$1(load, constant("")), trim, split$2(/\s+/u), filter$5(isNonEmpty$1), take$3(3))), previous);
112990
113058
  }
112991
113059
  function resolution(range) {
112992
113060
  return divideUnsafe(range, 60);
@@ -113010,7 +113078,7 @@ function mean(bucket, read) {
113010
113078
  function merge(bucket) {
113011
113079
  if (bucket.length === 1) return bucket[0];
113012
113080
  const reported = filter$5(bucket, (point) => isSome(point.apps));
113013
- const appsById = map$10(reported, (point) => fromEntries(pipe(point.apps, getOrElse$1(empty$15), map$10((app) => [app.id, app]))));
113081
+ const appsById = map$10(reported, (point) => pipe(point.apps, getOrElse$1(empty$15), fromIterableBy((app) => app.id)));
113014
113082
  function appMean(id, read) {
113015
113083
  return mean(reported, (_point, index) => match$7(fromUndefinedOr(appsById[index]?.[id]), {
113016
113084
  onNone: () => some$1(0),
@@ -113029,7 +113097,7 @@ function merge(bucket) {
113029
113097
  onNonEmpty: () => some$1(map$10(dedupe(flatMap$6(reported, (point) => pipe(point.apps, getOrElse$1(empty$15), map$10((app) => app.id)))), (id) => ({
113030
113098
  cpu: appMean(id, (app) => app.cpu),
113031
113099
  id,
113032
- memory: pipe(appMean(id, (app) => some$1(app.memory)), getOrElse$1(() => 0), round(0))
113100
+ memory: pipe(appMean(id, (app) => some$1(app.memory)), getOrElse$1(constant(0)), round(0))
113033
113101
  })))
113034
113102
  }),
113035
113103
  cpu: mean(bucket, (point) => point.cpu),
@@ -113071,7 +113139,7 @@ function bandName(id, labels) {
113071
113139
  return pipe(labels, get$12(id), getOrElse$1(() => replaceAll(/^service:[a-z]+:(?:deslop-)?|\.service$/gu, "")(replace(/^container:/u, "container ")(id))));
113072
113140
  }
113073
113141
  function appCgroup(path, siblings) {
113074
- const name = getOrElse$1(last$1(split$2(path, "/")), () => "");
113142
+ const name = getOrElse$1(last$1(split$2(path, "/")), constant(""));
113075
113143
  if (isSome(match$2(/^docker-[a-f0-9]{12,64}\.scope$/u)(name))) return true;
113076
113144
  if (endsWith(".service")(name)) return isNone(match$2(/^user@[0-9]+\.service$/u)(name));
113077
113145
  return exists(match$2(/\/user@[0-9]+\.service\/app\.slice\/app-([^/]+)\.slice$/u)(path), (match) => contains(siblings, `${match[1]}.service`));
@@ -113122,10 +113190,10 @@ function diskTotal(machine) {
113122
113190
  function series(machine, minutes, read) {
113123
113191
  const start = chartWindow(minutes, machine.time).start;
113124
113192
  const slot = resolution(minutes);
113125
- const bySlot = fromEntries(map$10(machine.samples, (point) => [`${clamp(Math.ceil(toMillis(distance(start, point.time)) / toMillis(slot)) - 1, {
113193
+ const bySlot = fromIterableWith(machine.samples, (point) => [`${clamp(Math.ceil(toMillis(distance(start, point.time)) / toMillis(slot)) - 1, {
113126
113194
  maximum: 59,
113127
113195
  minimum: 0
113128
- })}`, point]));
113196
+ })}`, point]);
113129
113197
  return makeBy(60, (index) => pipe(fromUndefinedOr(bySlot[`${index}`]), flatMap$8(read), map$13((value) => round(value, 1))));
113130
113198
  }
113131
113199
  function appsOf(labels, latest) {
@@ -113251,7 +113319,7 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
113251
113319
  cpu: fs.readFileString(`${CGROUP}${path}/cpu.stat`),
113252
113320
  memory: fs.readFileString(`${CGROUP}${path}/memory.stat`)
113253
113321
  }, { concurrency: "unbounded" }), catchTag("PlatformError", (cause) => {
113254
- if (cause.reason._tag === "NotFound") return undefined_$1;
113322
+ if (isTagged(cause.reason, "NotFound")) return undefined_$1;
113255
113323
  return fail$7(cause);
113256
113324
  }), flatMap$3((stats) => {
113257
113325
  if (stats === void 0) return succeedNone;
@@ -113470,8 +113538,8 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
113470
113538
  const clients = yield* forEach$1(workers, (worker) => gen(function* () {
113471
113539
  const url = new URL(RPC_PATH, worker.url);
113472
113540
  url.protocol = match(new URL(worker.url).protocol === "http:", {
113473
- onFalse: () => "wss:",
113474
- onTrue: () => "ws:"
113541
+ onFalse: constant("wss:"),
113542
+ onTrue: constant("ws:")
113475
113543
  });
113476
113544
  const protocol = yield* build(pipe(layerProtocolSocket({ pingTimeout: seconds(15) }), provide$2(layerWebSocket(url.href)), provide$2(layerSchemaBinary()), provideMerge(layerRpcStreamClient)));
113477
113545
  return [worker.name, yield* provideContext$2(makeRemoteClient, protocol)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/deploy",
3
- "version": "0.1.1310",
3
+ "version": "0.1.1312",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -40,5 +40,5 @@
40
40
  "engines": {
41
41
  "node": ">=26"
42
42
  },
43
- "fingerprint": "91b909b317bde5f71dc7e0b0908e9359f04c69716b76e5eddfda4b542c70c97d"
43
+ "fingerprint": "fbf894cfa2b2149588959d0543f48ee6ef8707097ed38a618a7352416eaf417b"
44
44
  }