@deslop/deploy 0.1.1268 → 0.1.1272
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/client/assets/(home)-Chh1tVyT.js +1 -0
- package/dist/client/assets/-expose-CaBLYX-o.js +1 -0
- package/dist/client/assets/effect-CHi49DOw.js +16 -0
- package/dist/client/assets/index-BugYPIWZ.css +2 -0
- package/dist/client/assets/index-C4b76k1l.js +2 -0
- package/dist/client/assets/{react-COyt-gOi.js → react-CYMlNKV3.js} +3 -3
- package/dist/client/assets/route-9_-C5HUC.js +1 -0
- package/dist/client/assets/schema-CKc7QdS-.js +2 -0
- package/dist/client/index.html +6 -6
- package/dist/server.js +230 -213
- package/package.json +2 -2
- package/dist/client/assets/(home)-CllRMHQ-.js +0 -1
- package/dist/client/assets/-expose-CfKGc7Gu.js +0 -1
- package/dist/client/assets/effect-B8IRCFNP.js +0 -16
- package/dist/client/assets/index-4tD2Ehhk.css +0 -2
- package/dist/client/assets/index-pk7d-Wmy.js +0 -2
- package/dist/client/assets/route-Buz3wuJA.js +0 -1
- package/dist/client/assets/schema-D7z9iJBO.js +0 -2
package/dist/server.js
CHANGED
|
@@ -16090,6 +16090,23 @@ const startsWith = (searchString, position) => (self) => self.startsWith(searchS
|
|
|
16090
16090
|
*/
|
|
16091
16091
|
const endsWith = (searchString, position) => (self) => self.endsWith(searchString, position);
|
|
16092
16092
|
/**
|
|
16093
|
+
* Returns the index of the first occurrence of a substring safely, or `None` if not found.
|
|
16094
|
+
*
|
|
16095
|
+
* **Example** (Finding the first substring index)
|
|
16096
|
+
*
|
|
16097
|
+
* ```ts import.meta.vitest
|
|
16098
|
+
* import { Option, pipe, String } from "effect"
|
|
16099
|
+
*
|
|
16100
|
+
* pipe("abbbc", String.indexOf("b")) // => Option.some(1)
|
|
16101
|
+
* pipe("abbbc", String.indexOf("z")) // => Option.none()
|
|
16102
|
+
* ```
|
|
16103
|
+
*
|
|
16104
|
+
* @stability stable
|
|
16105
|
+
* @category searching
|
|
16106
|
+
* @since 2.0.0
|
|
16107
|
+
*/
|
|
16108
|
+
const indexOf = (searchString) => (self) => filter$5(some$1(self.indexOf(searchString)), isGreaterThanOrEqualTo$2(0));
|
|
16109
|
+
/**
|
|
16093
16110
|
* Returns the index of the last occurrence of a substring safely, or `None` if not found.
|
|
16094
16111
|
*
|
|
16095
16112
|
* **Example** (Finding the last substring index)
|
|
@@ -89358,7 +89375,6 @@ var AuthError = class extends TaggedError()("AuthError", {
|
|
|
89358
89375
|
"invalid_client_metadata",
|
|
89359
89376
|
"invalid_redirect_uri",
|
|
89360
89377
|
"invalid_grant",
|
|
89361
|
-
"invalid_target",
|
|
89362
89378
|
"invalid_scope",
|
|
89363
89379
|
"unsupported_grant_type",
|
|
89364
89380
|
"unsupported_response_type",
|
|
@@ -90151,6 +90167,12 @@ function layerOtlp(serviceName, url, runtime, version) {
|
|
|
90151
90167
|
// ../../packages/runtime/src/auth/lib/utils.ts
|
|
90152
90168
|
const ISSUER_PATH = "/api/auth";
|
|
90153
90169
|
const APPS_PATH = "/api/apps";
|
|
90170
|
+
const COOKIE = {
|
|
90171
|
+
httpOnly: true,
|
|
90172
|
+
path: "/",
|
|
90173
|
+
sameSite: "lax",
|
|
90174
|
+
secure: true
|
|
90175
|
+
};
|
|
90154
90176
|
const SESSION_COOKIE = "__Host-session";
|
|
90155
90177
|
function matchingSessions(saved, userId) {
|
|
90156
90178
|
return sort(filter$3(getSomes(saved), (session) => session.value.user.id === userId), mapInput(flip$1(Number$6), (session) => session.value.expiresAt));
|
|
@@ -91371,13 +91393,6 @@ function layerMcpAuth(resource) {
|
|
|
91371
91393
|
// ../../packages/runtime/src/server.ts
|
|
91372
91394
|
const LOOPBACK = /^(?:localhost|\d{1,3}(?:\.\d{1,3}){3}|\[[\da-f:.]+\])$/iu;
|
|
91373
91395
|
const OTLP = ["/v1/traces", "/v1/logs"];
|
|
91374
|
-
const COOKIE = {
|
|
91375
|
-
httpOnly: true,
|
|
91376
|
-
path: "/",
|
|
91377
|
-
sameSite: "lax",
|
|
91378
|
-
secure: true
|
|
91379
|
-
};
|
|
91380
|
-
const SIGN_IN_COOKIE = "__Host-sign-in";
|
|
91381
91396
|
const packageRoot = match$1(endsWith(".ts")(import.meta.url), {
|
|
91382
91397
|
onFalse: () => fileURLToPath(new URL("..", import.meta.url)),
|
|
91383
91398
|
onTrue: cwd
|
|
@@ -91512,112 +91527,6 @@ const layerRoutes = use((router) => gen(function* () {
|
|
|
91512
91527
|
}, { headers: { "cache-control": "no-store" } });
|
|
91513
91528
|
}));
|
|
91514
91529
|
}));
|
|
91515
|
-
const SignInState = fromJsonString(Struct({
|
|
91516
|
-
next: String$6,
|
|
91517
|
-
state: String$6,
|
|
91518
|
-
verifier: String$6
|
|
91519
|
-
}));
|
|
91520
|
-
const CallbackParams = Struct({
|
|
91521
|
-
code: optionalKey(String$6),
|
|
91522
|
-
error: optionalKey(String$6),
|
|
91523
|
-
iss: optionalKey(String$6),
|
|
91524
|
-
state: optionalKey(String$6)
|
|
91525
|
-
});
|
|
91526
|
-
function signedOut(next, cause) {
|
|
91527
|
-
return as(logWarning("The sign-in did not complete", cause), expireCookieUnsafe(redirect(next), SIGN_IN_COOKIE, COOKIE));
|
|
91528
|
-
}
|
|
91529
|
-
function layerSignIn(issuer) {
|
|
91530
|
-
return use((router) => gen(function* () {
|
|
91531
|
-
const sessions = yield* Sessions;
|
|
91532
|
-
const random = yield* SecureRandom;
|
|
91533
|
-
const digest = yield* Digest;
|
|
91534
|
-
const canonical = new URL(yield* String$5("APP_URL")).origin;
|
|
91535
|
-
const callback = new URL(CALLBACK_PATH, canonical).href;
|
|
91536
|
-
const clientId = yield* cached(map$5(appName, (name) => clientIdOf({
|
|
91537
|
-
name: capitalize(name),
|
|
91538
|
-
redirects: [callback]
|
|
91539
|
-
})));
|
|
91540
|
-
function ended(headers) {
|
|
91541
|
-
return match$8(sessionIdOf(headers), {
|
|
91542
|
-
onNone: () => void_$1,
|
|
91543
|
-
onSome: (id) => ignore$1(sessions.end(id), {
|
|
91544
|
-
log: "Warn",
|
|
91545
|
-
message: "The session could not be ended"
|
|
91546
|
-
})
|
|
91547
|
-
});
|
|
91548
|
-
}
|
|
91549
|
-
function toNext(handle) {
|
|
91550
|
-
return flatMap$2(HttpServerRequest, (request) => match$8(filter$5(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (next) => next.origin === canonical), {
|
|
91551
|
-
onNone: () => succeed$5(empty({ status: 400 })),
|
|
91552
|
-
onSome: (next) => handle(request, next)
|
|
91553
|
-
}));
|
|
91554
|
-
}
|
|
91555
|
-
yield* router.add("GET", "/auth/sign-in", toNext(fnUntraced(function* (_, next) {
|
|
91556
|
-
const verifier = encode$1(yield* random.randomBytes(32));
|
|
91557
|
-
const state = encode$1(yield* random.randomBytes(16));
|
|
91558
|
-
const authorize = new URL(AUTHORIZE_PATH, issuer);
|
|
91559
|
-
authorize.search = `${new URLSearchParams({
|
|
91560
|
-
client_id: yield* clientId,
|
|
91561
|
-
code_challenge: encode$1(yield* digest.digest(sha256, new TextEncoder().encode(verifier))),
|
|
91562
|
-
code_challenge_method: "S256",
|
|
91563
|
-
redirect_uri: callback,
|
|
91564
|
-
response_type: "code",
|
|
91565
|
-
scope: "deslop offline_access",
|
|
91566
|
-
state
|
|
91567
|
-
})}`;
|
|
91568
|
-
return setCookieUnsafe(redirect(authorize.href), SIGN_IN_COOKIE, yield* encodeEffect(SignInState)({
|
|
91569
|
-
next: next.href,
|
|
91570
|
-
state,
|
|
91571
|
-
verifier
|
|
91572
|
-
}), {
|
|
91573
|
-
...COOKIE,
|
|
91574
|
-
maxAge: "10 minutes"
|
|
91575
|
-
});
|
|
91576
|
-
})));
|
|
91577
|
-
yield* router.add("GET", CALLBACK_PATH, gen(function* () {
|
|
91578
|
-
const request = yield* HttpServerRequest;
|
|
91579
|
-
return yield* match$8(yield* option$1(decodeUnknownEffect(SignInState)(request.cookies[SIGN_IN_COOKIE])), {
|
|
91580
|
-
onNone: () => signedOut(canonical, "The sign-in expired or began in another browser"),
|
|
91581
|
-
onSome: fnUntraced(function* (saved) {
|
|
91582
|
-
const started = yield* result$1(gen(function* () {
|
|
91583
|
-
const params = yield* schemaSearchParams(CallbackParams);
|
|
91584
|
-
if (params.state !== saved.state) return yield* AuthError.make({ message: "The sign-in began in another browser" });
|
|
91585
|
-
if (params.error !== void 0 || params.code === void 0) return yield* AuthError.make({ message: `Auth answered ${params.error ?? "without a code"}` });
|
|
91586
|
-
if (params.iss !== new URL("/api/auth", issuer).href) return yield* AuthError.make({ message: "The answer came from another issuer" });
|
|
91587
|
-
return yield* sessions.start({
|
|
91588
|
-
client_id: yield* clientId,
|
|
91589
|
-
code: params.code,
|
|
91590
|
-
code_verifier: saved.verifier,
|
|
91591
|
-
redirect_uri: callback
|
|
91592
|
-
});
|
|
91593
|
-
}));
|
|
91594
|
-
if (isFailure$1(started)) return yield* signedOut(saved.next, started.failure);
|
|
91595
|
-
return pipe(redirect(saved.next), expireCookieUnsafe(SIGN_IN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.success, {
|
|
91596
|
-
...COOKIE,
|
|
91597
|
-
maxAge: "365 days"
|
|
91598
|
-
}));
|
|
91599
|
-
})
|
|
91600
|
-
});
|
|
91601
|
-
}));
|
|
91602
|
-
yield* router.add("POST", "/auth/session", gen(function* () {
|
|
91603
|
-
const started = yield* result$1(pipe(schemaBodyJson(CodeGrant), rejected("The sign-in request is invalid"), flatMap$2(sessions.start)));
|
|
91604
|
-
if (isFailure$1(started)) return text(started.failure.message, failureOptions(started.failure, 400));
|
|
91605
|
-
return yield* schemaJson(SessionHandle)({ session: started.success }, { headers: { "cache-control": "no-store" } });
|
|
91606
|
-
}));
|
|
91607
|
-
yield* router.add("GET", "/auth/sign-out", toNext((request, next) => as(ended(request.headers), expireCookieUnsafe(redirect(`${new URL("/", issuer).href}?${new URLSearchParams({
|
|
91608
|
-
next: next.href,
|
|
91609
|
-
"sign-out": ""
|
|
91610
|
-
})}`), SESSION_COOKIE, COOKIE))));
|
|
91611
|
-
yield* router.add("POST", "/auth/sign-out", as(flatMap$2(HttpServerRequest, (request) => ended(request.headers)), empty({ status: 204 })));
|
|
91612
|
-
}));
|
|
91613
|
-
}
|
|
91614
|
-
const notConfigured = text("Sign-in is not configured for this app", { status: 503 });
|
|
91615
|
-
const layerSessionRoutes = unwrap$8(gen(function* () {
|
|
91616
|
-
return match$8(yield* option(String$5("AUTH_URL")), {
|
|
91617
|
-
onNone: () => mergeAll$1(add("GET", "/auth/sign-in", notConfigured), add("GET", "/auth/sign-out", notConfigured)),
|
|
91618
|
-
onSome: layerSignIn
|
|
91619
|
-
});
|
|
91620
|
-
}));
|
|
91621
91530
|
const layerAnnounce = effectDiscard(gen(function* () {
|
|
91622
91531
|
const origin = new URL(yield* String$5("APP_URL")).origin;
|
|
91623
91532
|
const client = pipe(yield* HttpClient, filterStatusOk, timeout("10 seconds"), retryTransient({
|
|
@@ -91747,6 +91656,113 @@ var AiGateway = class AiGateway extends Service$1()("@deslop/runtime/ai/service/
|
|
|
91747
91656
|
});
|
|
91748
91657
|
}));
|
|
91749
91658
|
};
|
|
91659
|
+
// ../../packages/runtime/src/auth/routes.ts
|
|
91660
|
+
const SIGN_IN_COOKIE = "__Host-sign-in";
|
|
91661
|
+
const SignInState = fromJsonString(Struct({
|
|
91662
|
+
next: String$6,
|
|
91663
|
+
state: String$6,
|
|
91664
|
+
verifier: String$6
|
|
91665
|
+
}));
|
|
91666
|
+
const CallbackParams = Struct({
|
|
91667
|
+
code: optionalKey(String$6),
|
|
91668
|
+
error: optionalKey(String$6),
|
|
91669
|
+
iss: optionalKey(String$6),
|
|
91670
|
+
state: optionalKey(String$6)
|
|
91671
|
+
});
|
|
91672
|
+
function signedOut(next, cause) {
|
|
91673
|
+
return as(logWarning("The sign-in did not complete", cause), expireCookieUnsafe(redirect(next), SIGN_IN_COOKIE, COOKIE));
|
|
91674
|
+
}
|
|
91675
|
+
function layerSignIn(issuer) {
|
|
91676
|
+
return use((router) => gen(function* () {
|
|
91677
|
+
const sessions = yield* Sessions;
|
|
91678
|
+
const random = yield* SecureRandom;
|
|
91679
|
+
const digest = yield* Digest;
|
|
91680
|
+
const canonical = new URL(yield* String$5("APP_URL")).origin;
|
|
91681
|
+
const callback = new URL(CALLBACK_PATH, canonical).href;
|
|
91682
|
+
const clientId = yield* cached(map$5(appName, (name) => clientIdOf({
|
|
91683
|
+
name: capitalize(name),
|
|
91684
|
+
redirects: [callback]
|
|
91685
|
+
})));
|
|
91686
|
+
function ended(headers) {
|
|
91687
|
+
return match$8(sessionIdOf(headers), {
|
|
91688
|
+
onNone: () => void_$1,
|
|
91689
|
+
onSome: (id) => ignore$1(sessions.end(id), {
|
|
91690
|
+
log: "Warn",
|
|
91691
|
+
message: "The session could not be ended"
|
|
91692
|
+
})
|
|
91693
|
+
});
|
|
91694
|
+
}
|
|
91695
|
+
function toNext(handle) {
|
|
91696
|
+
return flatMap$2(HttpServerRequest, (request) => match$8(filter$5(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (next) => next.origin === canonical), {
|
|
91697
|
+
onNone: () => succeed$5(empty({ status: 400 })),
|
|
91698
|
+
onSome: (next) => handle(request, next)
|
|
91699
|
+
}));
|
|
91700
|
+
}
|
|
91701
|
+
yield* router.add("GET", "/auth/sign-in", toNext(fnUntraced(function* (_, next) {
|
|
91702
|
+
const verifier = encode$1(yield* random.randomBytes(32));
|
|
91703
|
+
const state = encode$1(yield* random.randomBytes(16));
|
|
91704
|
+
const authorize = new URL(AUTHORIZE_PATH, issuer);
|
|
91705
|
+
authorize.search = `${new URLSearchParams({
|
|
91706
|
+
client_id: yield* clientId,
|
|
91707
|
+
code_challenge: encode$1(yield* digest.digest(sha256, new TextEncoder().encode(verifier))),
|
|
91708
|
+
code_challenge_method: "S256",
|
|
91709
|
+
redirect_uri: callback,
|
|
91710
|
+
response_type: "code",
|
|
91711
|
+
scope: "deslop offline_access",
|
|
91712
|
+
state
|
|
91713
|
+
})}`;
|
|
91714
|
+
return setCookieUnsafe(redirect(authorize.href), SIGN_IN_COOKIE, yield* encodeEffect(SignInState)({
|
|
91715
|
+
next: next.href,
|
|
91716
|
+
state,
|
|
91717
|
+
verifier
|
|
91718
|
+
}), {
|
|
91719
|
+
...COOKIE,
|
|
91720
|
+
maxAge: "10 minutes"
|
|
91721
|
+
});
|
|
91722
|
+
})));
|
|
91723
|
+
yield* router.add("GET", CALLBACK_PATH, gen(function* () {
|
|
91724
|
+
const request = yield* HttpServerRequest;
|
|
91725
|
+
return yield* match$8(yield* option$1(decodeUnknownEffect(SignInState)(request.cookies[SIGN_IN_COOKIE])), {
|
|
91726
|
+
onNone: () => signedOut(canonical, "The sign-in expired or began in another browser"),
|
|
91727
|
+
onSome: fnUntraced(function* (saved) {
|
|
91728
|
+
const started = yield* result$1(gen(function* () {
|
|
91729
|
+
const params = yield* schemaSearchParams(CallbackParams);
|
|
91730
|
+
if (params.state !== saved.state) return yield* AuthError.make({ message: "The sign-in began in another browser" });
|
|
91731
|
+
if (params.error !== void 0 || params.code === void 0) return yield* AuthError.make({ message: `Auth answered ${params.error ?? "without a code"}` });
|
|
91732
|
+
if (params.iss !== new URL("/api/auth", issuer).href) return yield* AuthError.make({ message: "The answer came from another issuer" });
|
|
91733
|
+
return yield* sessions.start({
|
|
91734
|
+
client_id: yield* clientId,
|
|
91735
|
+
code: params.code,
|
|
91736
|
+
code_verifier: saved.verifier,
|
|
91737
|
+
redirect_uri: callback
|
|
91738
|
+
});
|
|
91739
|
+
}));
|
|
91740
|
+
if (isFailure$1(started)) return yield* signedOut(saved.next, started.failure);
|
|
91741
|
+
return pipe(redirect(saved.next), expireCookieUnsafe(SIGN_IN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.success, {
|
|
91742
|
+
...COOKIE,
|
|
91743
|
+
maxAge: "365 days"
|
|
91744
|
+
}));
|
|
91745
|
+
})
|
|
91746
|
+
});
|
|
91747
|
+
}));
|
|
91748
|
+
yield* router.add("POST", "/auth/session", gen(function* () {
|
|
91749
|
+
const started = yield* result$1(pipe(schemaBodyJson(CodeGrant), rejected("The sign-in request is invalid"), flatMap$2(sessions.start)));
|
|
91750
|
+
if (isFailure$1(started)) return text(started.failure.message, failureOptions(started.failure, 400));
|
|
91751
|
+
return yield* schemaJson(SessionHandle)({ session: started.success }, { headers: { "cache-control": "no-store" } });
|
|
91752
|
+
}));
|
|
91753
|
+
yield* router.add("GET", "/auth/sign-out", toNext((request, next) => as(ended(request.headers), expireCookieUnsafe(redirect(`${new URL("/", issuer).href}?${new URLSearchParams({
|
|
91754
|
+
next: next.href,
|
|
91755
|
+
"sign-out": ""
|
|
91756
|
+
})}`), SESSION_COOKIE, COOKIE))));
|
|
91757
|
+
yield* router.add("POST", "/auth/sign-out", as(flatMap$2(HttpServerRequest, (request) => ended(request.headers)), empty({ status: 204 })));
|
|
91758
|
+
}));
|
|
91759
|
+
}
|
|
91760
|
+
const layerSessionRoutes = unwrap$8(gen(function* () {
|
|
91761
|
+
return match$8(yield* option(String$5("AUTH_URL")), {
|
|
91762
|
+
onNone: () => empty$10,
|
|
91763
|
+
onSome: layerSignIn
|
|
91764
|
+
});
|
|
91765
|
+
}));
|
|
91750
91766
|
// ../../packages/runtime/src/cli/schema.ts
|
|
91751
91767
|
var AppError = class extends TaggedError()("AppError", {
|
|
91752
91768
|
cause: optional$8(Defect()),
|
|
@@ -92365,6 +92381,38 @@ var Exposures = class Exposures extends Service$1()("@deslop/deploy/services/exp
|
|
|
92365
92381
|
});
|
|
92366
92382
|
}));
|
|
92367
92383
|
};
|
|
92384
|
+
// src/services/inventory/lib/failures.ts
|
|
92385
|
+
const SIGNALS = {
|
|
92386
|
+
1: "SIGHUP",
|
|
92387
|
+
2: "SIGINT",
|
|
92388
|
+
6: "SIGABRT",
|
|
92389
|
+
9: "SIGKILL",
|
|
92390
|
+
11: "SIGSEGV",
|
|
92391
|
+
15: "SIGTERM"
|
|
92392
|
+
};
|
|
92393
|
+
function failureReason(result, status, ran) {
|
|
92394
|
+
if (result === "exit-code" && !ran) return "Failed before starting";
|
|
92395
|
+
const signal = SIGNALS[status] ?? `signal ${status}`;
|
|
92396
|
+
return pipe(value(result), when("exit-code", () => match$8(fromUndefinedOr(SIGNALS[status - 128]), {
|
|
92397
|
+
onNone: () => `Exited with code ${status}`,
|
|
92398
|
+
onSome: (name) => `Exited with code ${status} (${name})`
|
|
92399
|
+
})), 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}`));
|
|
92400
|
+
}
|
|
92401
|
+
function unitFailures(text) {
|
|
92402
|
+
return fromEntries(map$8(filter$3(split$2(trim(text), /\n\s*\n/u), isNonEmpty$1), (block) => {
|
|
92403
|
+
const fields = fromEntries(map$8(filter$3(split$2(block, "\n"), includes("=")), (line) => {
|
|
92404
|
+
const [key, ...value] = split$2(line, "=");
|
|
92405
|
+
return [key, join$2(value, "=")];
|
|
92406
|
+
}));
|
|
92407
|
+
return [fields["Id"] ?? "", {
|
|
92408
|
+
...match$8(parse$3(replace(/^@/u, "")(fields["StateChangeTimestamp"] ?? "")), {
|
|
92409
|
+
onNone: () => ({}),
|
|
92410
|
+
onSome: (seconds) => ({ at: seconds * 1e3 })
|
|
92411
|
+
}),
|
|
92412
|
+
reason: failureReason(fields["Result"] ?? "", getOrElse(parse$3(fields["ExecMainStatus"] ?? ""), () => 0), fields["ExecMainCode"] !== "0")
|
|
92413
|
+
}];
|
|
92414
|
+
}));
|
|
92415
|
+
}
|
|
92368
92416
|
// src/services/inventory/lib/command.ts
|
|
92369
92417
|
const WRAPPERS = [
|
|
92370
92418
|
"env",
|
|
@@ -92552,65 +92600,7 @@ function commandLabel(argv, cwd) {
|
|
|
92552
92600
|
}
|
|
92553
92601
|
});
|
|
92554
92602
|
}
|
|
92555
|
-
// src/services/inventory/lib/
|
|
92556
|
-
const SIGNALS = {
|
|
92557
|
-
1: "SIGHUP",
|
|
92558
|
-
2: "SIGINT",
|
|
92559
|
-
6: "SIGABRT",
|
|
92560
|
-
9: "SIGKILL",
|
|
92561
|
-
11: "SIGSEGV",
|
|
92562
|
-
15: "SIGTERM"
|
|
92563
|
-
};
|
|
92564
|
-
function socketLine(line) {
|
|
92565
|
-
const fields = split$2(trim(line), /\s+/u);
|
|
92566
|
-
const address = fields[4] ?? "";
|
|
92567
|
-
return map$11(parse$3(getOrElse(last(split$2(address, ":")), () => "")), (port) => ({
|
|
92568
|
-
address,
|
|
92569
|
-
pid: map$11(match$3(/pid=([0-9]+)/u)(line), (match) => match[1]),
|
|
92570
|
-
port,
|
|
92571
|
-
process: map$11(match$3(/users:\(\("([^"]+)",pid=([0-9]+)/u)(line), (match) => ({
|
|
92572
|
-
name: match[1] ?? "",
|
|
92573
|
-
pid: match[2]
|
|
92574
|
-
})),
|
|
92575
|
-
protocol: fields[0],
|
|
92576
|
-
state: fields[1] ?? "listening"
|
|
92577
|
-
}));
|
|
92578
|
-
}
|
|
92579
|
-
function socketUnit(cgroup) {
|
|
92580
|
-
return getOrElse(map$11(findLast$1(matchAll(/\/([^/]+\.service)(?=\/|\n|$)/gu)(cgroup), () => true), (match) => match[1] ?? ""), () => "");
|
|
92581
|
-
}
|
|
92582
|
-
function socketProcess(name, cwd) {
|
|
92583
|
-
return match$8(match$3(/\/apps\/([^/]+)(?:\/|$)/u)(cwd), {
|
|
92584
|
-
onNone: () => name,
|
|
92585
|
-
onSome: (app) => app[1] ?? ""
|
|
92586
|
-
});
|
|
92587
|
-
}
|
|
92588
|
-
function probeSocket(listener, process) {
|
|
92589
|
-
return listener.protocol === "tcp" && listener.port >= 1024 && isSome(match$3(/^(?:127\.0\.0\.1|0\.0\.0\.0):/u)(listener.address)) && isNone(match$3(/^(?:postgres|redis|ssh|cloudflared|tailscaled|caddy)$/u)(process));
|
|
92590
|
-
}
|
|
92591
|
-
function failureReason(result, status, ran) {
|
|
92592
|
-
if (result === "exit-code" && !ran) return "Failed before starting";
|
|
92593
|
-
const signal = SIGNALS[status] ?? `signal ${status}`;
|
|
92594
|
-
return pipe(value(result), when("exit-code", () => match$8(fromUndefinedOr(SIGNALS[status - 128]), {
|
|
92595
|
-
onNone: () => `Exited with code ${status}`,
|
|
92596
|
-
onSome: (name) => `Exited with code ${status} (${name})`
|
|
92597
|
-
})), 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}`));
|
|
92598
|
-
}
|
|
92599
|
-
function unitFailures(text) {
|
|
92600
|
-
return fromEntries(map$8(filter$3(split$2(trim(text), /\n\s*\n/u), isNonEmpty$1), (block) => {
|
|
92601
|
-
const fields = fromEntries(map$8(filter$3(split$2(block, "\n"), includes("=")), (line) => {
|
|
92602
|
-
const [key, ...value] = split$2(line, "=");
|
|
92603
|
-
return [key, join$2(value, "=")];
|
|
92604
|
-
}));
|
|
92605
|
-
return [fields["Id"] ?? "", {
|
|
92606
|
-
...match$8(parse$3(replace(/^@/u, "")(fields["StateChangeTimestamp"] ?? "")), {
|
|
92607
|
-
onNone: () => ({}),
|
|
92608
|
-
onSome: (seconds) => ({ at: seconds * 1e3 })
|
|
92609
|
-
}),
|
|
92610
|
-
reason: failureReason(fields["Result"] ?? "", getOrElse(parse$3(fields["ExecMainStatus"] ?? ""), () => 0), fields["ExecMainCode"] !== "0")
|
|
92611
|
-
}];
|
|
92612
|
-
}));
|
|
92613
|
-
}
|
|
92603
|
+
// src/services/inventory/lib/owners.ts
|
|
92614
92604
|
function processOwner(cgroup) {
|
|
92615
92605
|
const container = getOrUndefined$1(match$3(/\/(?:docker-|docker\/)([a-f0-9]{12,64})(?:\.scope)?(?:\/|\n|$)/u)(cgroup))?.[1];
|
|
92616
92606
|
if (container !== void 0) return `container:${slice$1(0, 12)(container)}`;
|
|
@@ -92625,6 +92615,7 @@ function processOwner(cgroup) {
|
|
|
92625
92615
|
onSome: (match) => `service:user:${match[1]}.service`
|
|
92626
92616
|
});
|
|
92627
92617
|
}
|
|
92618
|
+
// src/services/inventory/lib/utils.ts
|
|
92628
92619
|
function itemOwner(item) {
|
|
92629
92620
|
if (item.kind === "container") return `container:${slice$1(0, 12)(getOrElse(last(split$2(item.id, ":docker:")), () => ""))}`;
|
|
92630
92621
|
return `service:${item.scope ?? "system"}:${item.name}`;
|
|
@@ -92633,14 +92624,15 @@ function itemOwner(item) {
|
|
|
92633
92624
|
const PROCESS_INTERVAL = 2e3;
|
|
92634
92625
|
const SECRET = /(?:token|secret|passw(?:or)?d|key|auth|credential|cookie|session)/iu;
|
|
92635
92626
|
function processStatus(status) {
|
|
92636
|
-
|
|
92637
|
-
|
|
92638
|
-
|
|
92627
|
+
const values = fromEntries(map$8(split$2(trim(status), "\n"), (line) => {
|
|
92628
|
+
const at = getOrElse(indexOf(":")(line), () => -1);
|
|
92629
|
+
return [slice$1(0, at)(line), trim(slice$1(at + 1)(line))];
|
|
92630
|
+
}));
|
|
92639
92631
|
return {
|
|
92640
|
-
memory: decodeSync(FiniteFromString)(split$2(
|
|
92641
|
-
name:
|
|
92642
|
-
parent: decodeSync(FiniteFromString.check(isInt()))(
|
|
92643
|
-
pid: decodeSync(FiniteFromString.check(isInt()))(
|
|
92632
|
+
memory: decodeSync(FiniteFromString)(split$2(values["VmRSS"] ?? "", /\s+/u)[0] || "0") * 1024,
|
|
92633
|
+
name: values["Name"] ?? "",
|
|
92634
|
+
parent: decodeSync(FiniteFromString.check(isInt()))(values["PPid"] ?? ""),
|
|
92635
|
+
pid: decodeSync(FiniteFromString.check(isInt()))(values["Pid"] ?? "")
|
|
92644
92636
|
};
|
|
92645
92637
|
}
|
|
92646
92638
|
function commandArgs(cmdline) {
|
|
@@ -92746,13 +92738,40 @@ function attachProcesses(items, records) {
|
|
|
92746
92738
|
}), (record) => record.process)
|
|
92747
92739
|
}));
|
|
92748
92740
|
}
|
|
92741
|
+
// src/services/inventory/lib/sockets.ts
|
|
92742
|
+
function socketLine(line) {
|
|
92743
|
+
const fields = split$2(trim(line), /\s+/u);
|
|
92744
|
+
const address = fields[4] ?? "";
|
|
92745
|
+
return map$11(parse$3(getOrElse(last(split$2(address, ":")), () => "")), (port) => ({
|
|
92746
|
+
address,
|
|
92747
|
+
port,
|
|
92748
|
+
process: map$11(match$3(/users:\(\("([^"]+)",pid=([0-9]+)/u)(line), (match) => ({
|
|
92749
|
+
name: match[1] ?? "",
|
|
92750
|
+
pid: match[2]
|
|
92751
|
+
})),
|
|
92752
|
+
protocol: fields[0],
|
|
92753
|
+
state: fields[1] ?? "listening"
|
|
92754
|
+
}));
|
|
92755
|
+
}
|
|
92756
|
+
function socketUnit(cgroup) {
|
|
92757
|
+
return getOrElse(map$11(findLast$1(matchAll(/\/([^/]+\.service)(?=\/|\n|$)/gu)(cgroup), () => true), (match) => match[1] ?? ""), () => "");
|
|
92758
|
+
}
|
|
92759
|
+
function socketProcess(name, cwd) {
|
|
92760
|
+
return match$8(match$3(/\/apps\/([^/]+)(?:\/|$)/u)(cwd), {
|
|
92761
|
+
onNone: () => name,
|
|
92762
|
+
onSome: (app) => app[1] ?? ""
|
|
92763
|
+
});
|
|
92764
|
+
}
|
|
92765
|
+
function probeSocket(listener, process) {
|
|
92766
|
+
return listener.protocol === "tcp" && listener.port >= 1024 && isSome(match$3(/^(?:127\.0\.0\.1|0\.0\.0\.0):/u)(listener.address)) && isNone(match$3(/^(?:postgres|redis|ssh|cloudflared|tailscaled|caddy)$/u)(process));
|
|
92767
|
+
}
|
|
92749
92768
|
// src/services/inventory/service.ts
|
|
92750
92769
|
function portItems(text, worker, fs, http) {
|
|
92751
92770
|
return forEach$1(getSomes(map$8(split$2(trim(text), "\n"), socketLine)), fnUntraced(function* (socket) {
|
|
92752
|
-
const unit = socketUnit(yield* match$8(socket.
|
|
92771
|
+
const unit = socketUnit(yield* match$8(socket.process, {
|
|
92753
92772
|
onNone: () => succeed$5(""),
|
|
92754
|
-
onSome: fnUntraced(function* (
|
|
92755
|
-
return getOrElse(yield* option$1(fs.readFileString(`/proc/${pid}/cgroup`)), () => "");
|
|
92773
|
+
onSome: fnUntraced(function* (match) {
|
|
92774
|
+
return getOrElse(yield* option$1(fs.readFileString(`/proc/${match.pid}/cgroup`)), () => "");
|
|
92756
92775
|
})
|
|
92757
92776
|
}));
|
|
92758
92777
|
const process = yield* match$8(socket.process, {
|
|
@@ -93199,8 +93218,13 @@ function compact(samples, now) {
|
|
|
93199
93218
|
return `${tier.every}:${Math.floor(value.time / tier.every)}`;
|
|
93200
93219
|
}), values, map$8(merge), sort(mapInput(Number$6, (value) => value.time)));
|
|
93201
93220
|
}
|
|
93221
|
+
function usedStorage(point) {
|
|
93222
|
+
return getOrElse(fromUndefinedOr(point.storageUsed), () => reduce(point.disks, 0, (sum, disk) => sum + disk.used));
|
|
93223
|
+
}
|
|
93202
93224
|
function history(samples, minutes, now) {
|
|
93203
|
-
const
|
|
93225
|
+
const window = chartWindow(minutes, now);
|
|
93226
|
+
const slot = resolution(minutes);
|
|
93227
|
+
const selected = pipe(filter$3(samples, (value) => value.time > window.start && value.time <= now), groupBy((value) => `${clamp(Math.ceil((value.time - window.start) / slot) - 1, {
|
|
93204
93228
|
maximum: 59,
|
|
93205
93229
|
minimum: 0
|
|
93206
93230
|
})}`), values, map$8(merge));
|
|
@@ -93209,7 +93233,7 @@ function history(samples, minutes, now) {
|
|
|
93209
93233
|
return {
|
|
93210
93234
|
...pipe(value, omit(["load", "uptime"])),
|
|
93211
93235
|
disks: [],
|
|
93212
|
-
storageUsed:
|
|
93236
|
+
storageUsed: usedStorage(value)
|
|
93213
93237
|
};
|
|
93214
93238
|
});
|
|
93215
93239
|
}
|
|
@@ -93227,7 +93251,7 @@ function compactHistory(machine, minutes) {
|
|
|
93227
93251
|
memoryUsed: map$8(machine.samples, (value) => value.memoryUsed),
|
|
93228
93252
|
networkReceive: map$8(machine.samples, (value) => map$11(fromUndefinedOr(value.networkReceive), round(0))),
|
|
93229
93253
|
networkSend: map$8(machine.samples, (value) => map$11(fromUndefinedOr(value.networkSend), round(0))),
|
|
93230
|
-
storageUsed: map$8(machine.samples,
|
|
93254
|
+
storageUsed: map$8(machine.samples, usedStorage),
|
|
93231
93255
|
swapUsed: map$8(machine.samples, (value) => value.swapUsed),
|
|
93232
93256
|
time: map$8(machine.samples, (value) => value.time)
|
|
93233
93257
|
},
|
|
@@ -93295,25 +93319,17 @@ var Metrics = class Metrics extends Service$1()("@deslop/deploy/services/metrics
|
|
|
93295
93319
|
const dirty = yield* make$44(empty$11());
|
|
93296
93320
|
const collectError = yield* make$44("");
|
|
93297
93321
|
const persistError = yield* make$44("");
|
|
93298
|
-
|
|
93299
|
-
|
|
93300
|
-
|
|
93301
|
-
|
|
93322
|
+
function walk(pending, found) {
|
|
93323
|
+
if (isReadonlyArrayEmpty(pending)) return succeed$5(found);
|
|
93324
|
+
return flatMap$2(forEach$1(pending, (path) => option$1(map$5(fs.readDirectory(`${CGROUP}${path}`), (names) => map$8(filter$3(names, (name) => isSome(match$3(/\.(?:slice|scope|service)$/u)(name))), (name) => ({
|
|
93325
|
+
app: appCgroup(`${path}/${name}`, names),
|
|
93326
|
+
path: `${path}/${name}`
|
|
93327
|
+
})))), { concurrency: "unbounded" }), (levels) => {
|
|
93328
|
+
const children = flatten$3(getSomes(levels));
|
|
93329
|
+
return walk(map$8(filter$3(children, (child) => !child.app && isSome(match$3(/(?:\.slice|\/user@[0-9]+\.service)$/u)(child.path))), (child) => child.path), [...found, ...map$8(filter$3(children, (child) => child.app), (child) => child.path)]);
|
|
93302
93330
|
});
|
|
93303
|
-
|
|
93304
|
-
|
|
93305
|
-
const children = flatMap$5(getSomes(yield* forEach$1(level.pending, (path) => option$1(map$5(fs.readDirectory(`${CGROUP}${path}`), (names) => map$8(filter$3(names, (name) => isSome(match$3(/\.(?:slice|scope|service)$/u)(name))), (name) => ({
|
|
93306
|
-
app: appCgroup(`${path}/${name}`, names),
|
|
93307
|
-
path: `${path}/${name}`
|
|
93308
|
-
})))), { concurrency: "unbounded" })), identity);
|
|
93309
|
-
const next = {
|
|
93310
|
-
found: [...level.found, ...map$8(filter$3(children, (child) => child.app), (child) => child.path)],
|
|
93311
|
-
pending: map$8(filter$3(children, (child) => !child.app && isSome(match$3(/(?:\.slice|\/user@[0-9]+\.service)$/u)(child.path))), (child) => child.path)
|
|
93312
|
-
};
|
|
93313
|
-
yield* set$1(walk, next);
|
|
93314
|
-
return next;
|
|
93315
|
-
}), { until: (next) => isReadonlyArrayEmpty(next.pending) })).found;
|
|
93316
|
-
});
|
|
93331
|
+
}
|
|
93332
|
+
const appCgroups = walk([""], []);
|
|
93317
93333
|
const apps = gen(function* () {
|
|
93318
93334
|
const readings = yield* forEach$1(yield* appCgroups, (path) => pipe(all$1({
|
|
93319
93335
|
cpu: fs.readFileString(`${CGROUP}${path}/cpu.stat`),
|
|
@@ -93467,6 +93483,13 @@ function changeFailed(effect) {
|
|
|
93467
93483
|
});
|
|
93468
93484
|
});
|
|
93469
93485
|
}
|
|
93486
|
+
function cachedHistory(query, time, saved) {
|
|
93487
|
+
return {
|
|
93488
|
+
...getSomes$1({ cpuModel: fromUndefinedOr(saved?.cpuModel) }),
|
|
93489
|
+
samples: history(saved?.samples ?? [], query.minutes, time),
|
|
93490
|
+
time
|
|
93491
|
+
};
|
|
93492
|
+
}
|
|
93470
93493
|
var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/service/Fleet") {
|
|
93471
93494
|
static layer = effect(this, gen(function* () {
|
|
93472
93495
|
const inventory = yield* Inventory;
|
|
@@ -93513,11 +93536,9 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
|
|
|
93513
93536
|
return [own, ...map$8(workers, (worker) => {
|
|
93514
93537
|
const saved = cached[`${worker.name}:${query.minutes}`];
|
|
93515
93538
|
return {
|
|
93516
|
-
...
|
|
93539
|
+
...cachedHistory(query, time, saved),
|
|
93517
93540
|
error: saved?.error ?? "Waiting for worker",
|
|
93518
|
-
samples: history(saved?.samples ?? [], query.minutes, time),
|
|
93519
93541
|
stale: saved === void 0 || saved.stale || time - saved.time > 9e4,
|
|
93520
|
-
time,
|
|
93521
93542
|
worker: worker.name
|
|
93522
93543
|
};
|
|
93523
93544
|
})];
|
|
@@ -93537,14 +93558,10 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
|
|
|
93537
93558
|
...value,
|
|
93538
93559
|
worker: worker.name
|
|
93539
93560
|
})), catch_$2(fnUntraced(function* (cause) {
|
|
93540
|
-
const time = yield* currentTimeMillis;
|
|
93541
|
-
const all = yield* get$1(lastMetrics);
|
|
93542
93561
|
return {
|
|
93543
|
-
...
|
|
93562
|
+
...cachedHistory(query, yield* currentTimeMillis, (yield* get$1(lastMetrics))[`${worker.name}:${query.minutes}`]),
|
|
93544
93563
|
error: cause.message,
|
|
93545
|
-
samples: history(all[`${worker.name}:${query.minutes}`]?.samples ?? [], query.minutes, time),
|
|
93546
93564
|
stale: true,
|
|
93547
|
-
time,
|
|
93548
93565
|
worker: worker.name
|
|
93549
93566
|
};
|
|
93550
93567
|
})), tap$1((value) => update$1(lastMetrics, (all) => set$6(all, `${worker.name}:${query.minutes}`, value)))), { concurrency: "unbounded" })];
|
|
@@ -93660,7 +93677,7 @@ const ToolHandlers = Tools.toLayer(map$5(Fleet, (fleet) => Tools.of({
|
|
|
93660
93677
|
})
|
|
93661
93678
|
})));
|
|
93662
93679
|
// src/main.server.ts
|
|
93663
|
-
const layerServices = pipe(Fleet.layer, provideMerge(
|
|
93680
|
+
const layerServices = pipe(Fleet.layer, provideMerge(mergeAll$1(Inventory.layer, Metrics.layer, unwrap$8(map$5(dataDirectory, Exposures.layer)))), provide$2(ToolPath.layer));
|
|
93664
93681
|
runApp({
|
|
93665
93682
|
icon: icon_default,
|
|
93666
93683
|
routes: pipe(mergeAll$1(layerRpc({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deslop/deploy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1272",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/MP281X/deslop.git",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=26"
|
|
40
40
|
},
|
|
41
|
-
"fingerprint": "
|
|
41
|
+
"fingerprint": "cea9fe34bfd037aeadd2ee9b54555842a795b1964043e46cfeb60d2275c916c7"
|
|
42
42
|
}
|