@deslop/deploy 0.1.1331 → 0.1.1333
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/README.md +1 -1
- package/dist/client/assets/(home)-BDvqkF2z.js +61 -0
- package/dist/client/assets/{dropdown-menu-cRw2SEct.js → dropdown-menu-CYOanbDJ.js} +1 -1
- package/dist/client/assets/{index-C4GhaOw9.js → index-CTldnN8v.js} +2 -2
- package/dist/client/assets/{result-error-81kSogyD.js → result-error-d7x0fvzb.js} +1 -1
- package/dist/client/assets/{route-LleaLyMb.js → route-BIbCPeuW.js} +1 -1
- package/dist/client/assets/{schema-CppyNRe0.js → schema-D8D8ZFxG.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server.js +266 -46
- package/package.json +2 -2
- package/dist/client/assets/(home)-De3qFnVL.js +0 -61
package/dist/server.js
CHANGED
|
@@ -3526,6 +3526,8 @@ 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));
|
|
3529
3531
|
// ../../node_modules/.pnpm/effect@4.1.4/node_modules/effect/dist/Order.js
|
|
3530
3532
|
/**
|
|
3531
3533
|
* Defines comparison functions for ordered values.
|
|
@@ -5683,6 +5685,39 @@ const succeed$10 = succeed$11;
|
|
|
5683
5685
|
* @since 4.0.0
|
|
5684
5686
|
*/
|
|
5685
5687
|
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;
|
|
5686
5721
|
const try_$2 = (evaluate) => {
|
|
5687
5722
|
if (isFunction(evaluate)) try {
|
|
5688
5723
|
return succeed$10(evaluate());
|
|
@@ -12008,6 +12043,19 @@ const all$2 = (arg, options) => {
|
|
|
12008
12043
|
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));
|
|
12009
12044
|
};
|
|
12010
12045
|
/** @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 */
|
|
12011
12059
|
const whileLoop$1 = /*#__PURE__*/ makePrimitive$1({
|
|
12012
12060
|
op: "While",
|
|
12013
12061
|
[contA](value, fiber) {
|
|
@@ -18516,6 +18564,26 @@ const isEffect = isEffect$1;
|
|
|
18516
18564
|
*/
|
|
18517
18565
|
const all$1 = all$2;
|
|
18518
18566
|
/**
|
|
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
|
+
/**
|
|
18519
18587
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
18520
18588
|
*
|
|
18521
18589
|
* **When to use**
|
|
@@ -111727,6 +111795,15 @@ const retiredSessions = effectDiscard(make$18({})({
|
|
|
111727
111795
|
loader: fromRecord({ "0002_drop_sessions": flatMap$3(SqlClient, (sql) => sql`DROP TABLE IF EXISTS sessions`) }),
|
|
111728
111796
|
table: "sessions_migrations"
|
|
111729
111797
|
}));
|
|
111798
|
+
const tuned = effectDiscard(gen(function* () {
|
|
111799
|
+
const sql = yield* SqlClient;
|
|
111800
|
+
yield* sql`PRAGMA auto_vacuum = INCREMENTAL`;
|
|
111801
|
+
yield* sql`PRAGMA synchronous = NORMAL`;
|
|
111802
|
+
yield* pipe(sql`PRAGMA incremental_vacuum`, andThen(sql`PRAGMA optimize`), withSpan("Store.maintain"), ignore$1({
|
|
111803
|
+
log: "Warn",
|
|
111804
|
+
message: "The database could not be compacted"
|
|
111805
|
+
}), schedule(spaced(hours(1))), forkScoped);
|
|
111806
|
+
}));
|
|
111730
111807
|
function layerDataStore(directory) {
|
|
111731
111808
|
return unwrap$8(gen(function* () {
|
|
111732
111809
|
const fs = yield* FileSystem;
|
|
@@ -111739,7 +111816,7 @@ function layerDataStore(directory) {
|
|
|
111739
111816
|
flag: "a",
|
|
111740
111817
|
mode: 384
|
|
111741
111818
|
});
|
|
111742
|
-
return provideMerge(retiredSessions, merge$4(layer({ filename }), layer$22));
|
|
111819
|
+
return provideMerge(retiredSessions, provideMerge(tuned, merge$4(layer({ filename }), layer$22)));
|
|
111743
111820
|
}));
|
|
111744
111821
|
}
|
|
111745
111822
|
// ../../packages/runtime/src/server/process.ts
|
|
@@ -112319,13 +112396,15 @@ const TimeFrame = Literals([
|
|
|
112319
112396
|
"10m",
|
|
112320
112397
|
"1h",
|
|
112321
112398
|
"24h",
|
|
112322
|
-
"7d"
|
|
112399
|
+
"7d",
|
|
112400
|
+
"30d"
|
|
112323
112401
|
]);
|
|
112324
112402
|
const TIME_FRAME_DURATIONS = {
|
|
112325
112403
|
"1h": hours(1),
|
|
112326
112404
|
"7d": days(7),
|
|
112327
112405
|
"10m": minutes(10),
|
|
112328
|
-
"24h": days(1)
|
|
112406
|
+
"24h": days(1),
|
|
112407
|
+
"30d": days(30)
|
|
112329
112408
|
};
|
|
112330
112409
|
function timeFrameDuration(frame) {
|
|
112331
112410
|
return TIME_FRAME_DURATIONS[frame];
|
|
@@ -112667,8 +112746,7 @@ const AppSample = Struct$2({
|
|
|
112667
112746
|
id: AppId,
|
|
112668
112747
|
memory: Finite
|
|
112669
112748
|
});
|
|
112670
|
-
var
|
|
112671
|
-
apps: FieldOption(JsonFromString(ArraySchema(AppSample))),
|
|
112749
|
+
var MachineSample = class extends Class("MachineSample")({
|
|
112672
112750
|
cpu: FieldOption(Finite),
|
|
112673
112751
|
memoryTotal: Finite,
|
|
112674
112752
|
memoryUsed: Finite,
|
|
@@ -112679,15 +112757,31 @@ var Sample = class extends Class("Sample")({
|
|
|
112679
112757
|
}) {
|
|
112680
112758
|
static table = "samples";
|
|
112681
112759
|
};
|
|
112760
|
+
var AppHistory = class extends Class("AppHistory")({
|
|
112761
|
+
app: AppId,
|
|
112762
|
+
cpu: FieldOption(Finite),
|
|
112763
|
+
memory: Finite,
|
|
112764
|
+
since: MachineSample.fields.since,
|
|
112765
|
+
step: MachineSample.fields.step
|
|
112766
|
+
}) {
|
|
112767
|
+
static table = "app_samples";
|
|
112768
|
+
};
|
|
112769
|
+
var Sample = class extends Class("Sample")({
|
|
112770
|
+
...MachineSample.fields,
|
|
112771
|
+
apps: FieldOption(JsonFromString(ArraySchema(AppSample)))
|
|
112772
|
+
}) {};
|
|
112682
112773
|
Struct$2(omit(Sample.fields, ["since", "step"]));
|
|
112774
|
+
const Disk = Struct$2({
|
|
112775
|
+
mount: String$6,
|
|
112776
|
+
total: Finite,
|
|
112777
|
+
used: Finite
|
|
112778
|
+
});
|
|
112779
|
+
const Platform = Literals(["linux", "darwin"]);
|
|
112683
112780
|
const MachineHistory = Struct$2({
|
|
112684
|
-
disks: ArraySchema(
|
|
112685
|
-
mount: String$6,
|
|
112686
|
-
total: Finite,
|
|
112687
|
-
used: Finite
|
|
112688
|
-
})),
|
|
112781
|
+
disks: ArraySchema(Disk),
|
|
112689
112782
|
error: TextFromEmpty,
|
|
112690
112783
|
load: ArraySchema(Finite),
|
|
112784
|
+
platform: OptionFromOptionalKey(Platform),
|
|
112691
112785
|
samples: ArraySchema(Sample.json),
|
|
112692
112786
|
stale: Boolean$5,
|
|
112693
112787
|
time: DateTimeUtcFromFiniteMillis,
|
|
@@ -112958,6 +113052,15 @@ function unitFailures(text) {
|
|
|
112958
113052
|
}));
|
|
112959
113053
|
}
|
|
112960
113054
|
// src/services/inventory/lib/launchd.ts
|
|
113055
|
+
function applicationBundle(path) {
|
|
113056
|
+
return pipe(match$2(/^(\/[^\n]*?\.app)(?:\/|$)/u)(path), map$13((match) => match[1] ?? ""), filter$7(isNonEmpty$1));
|
|
113057
|
+
}
|
|
113058
|
+
function launchProgram(text) {
|
|
113059
|
+
return pipe(match$2(/^\tprogram = (\/[^\n]+)$/mu)(text), map$13((match) => match[1] ?? ""), filter$7(isNonEmpty$1));
|
|
113060
|
+
}
|
|
113061
|
+
function systemProgram(path) {
|
|
113062
|
+
return isSome(match$2(/^(?:\/System|\/usr|\/bin|\/sbin|\/Library\/Apple)(?:\/|$)/u)(path));
|
|
113063
|
+
}
|
|
112961
113064
|
function launchAgents(text) {
|
|
112962
113065
|
return getSomes(pipe(text, split$1("\n"), map$10((line) => {
|
|
112963
113066
|
const [pid, status = "", label = ""] = split$1(trim(line), " ");
|
|
@@ -112965,34 +113068,56 @@ function launchAgents(text) {
|
|
|
112965
113068
|
const processId = filter$7(decodeOption(ProcessIdFromString)(pid), (value) => value > 0);
|
|
112966
113069
|
if (isNone(processId) && pid !== "-") return none();
|
|
112967
113070
|
return some$1({
|
|
113071
|
+
bundle: none(),
|
|
112968
113072
|
detail: "user · launch agent",
|
|
112969
113073
|
label: UnitId.make(label),
|
|
113074
|
+
name: label,
|
|
112970
113075
|
pid: processId,
|
|
112971
113076
|
status: parse$2(status)
|
|
112972
113077
|
});
|
|
112973
113078
|
})));
|
|
112974
113079
|
}
|
|
112975
|
-
function dockApplications(text) {
|
|
113080
|
+
function dockApplications(text, agentBundles = []) {
|
|
112976
113081
|
return getSomes(pipe(text, split$1(/\n(?=\s*[0-9]+\))/u), map$10((block) => {
|
|
113082
|
+
const bundle = flatMap$8(match$2(/^\s+bundle path="([^"\n]+)"\s*$/mu)(block), (match) => applicationBundle(match[1] ?? ""));
|
|
113083
|
+
const agentApplication = exists(bundle, (value) => contains$1(agentBundles, value));
|
|
112977
113084
|
const name = pipe(match$2(/^\s*[0-9]+\) "(.+)" ASN:/u)(block), map$13((match) => match[1] ?? ""), filter$7(isNonEmpty$1));
|
|
112978
|
-
const pid = pipe(match$2(/^\s+pid = ([0-9]+) .*\btype="Foreground"(?:\s|$)/mu)(block), flatMap$8((match) => decodeOption(ProcessIdFromString)(match[1] ?? "")), filter$7((value) => value > 0));
|
|
113085
|
+
const pid = pipe(match$2(/^\s+pid = ([0-9]+) .*\btype="(Foreground|UIElement)"(?:\s|$)/mu)(block), filter$7((match) => match[2] === "Foreground" || agentApplication), flatMap$8((match) => decodeOption(ProcessIdFromString)(match[1] ?? "")), filter$7((value) => value > 0));
|
|
112979
113086
|
return map$13(all$4({
|
|
112980
113087
|
name,
|
|
112981
113088
|
pid
|
|
112982
113089
|
}), (app) => ({
|
|
113090
|
+
bundle,
|
|
112983
113091
|
detail: "user · application",
|
|
112984
113092
|
label: UnitId.make(app.name),
|
|
113093
|
+
name: app.name,
|
|
112985
113094
|
pid: app.pid
|
|
112986
113095
|
}));
|
|
112987
113096
|
})));
|
|
112988
113097
|
}
|
|
112989
113098
|
function macApplications(agents, applications) {
|
|
112990
|
-
const running =
|
|
112991
|
-
|
|
112992
|
-
label: agent.label,
|
|
113099
|
+
const running = pipe(agents, map$10((agent) => map$13(agent.pid, (pid) => ({
|
|
113100
|
+
...agent,
|
|
112993
113101
|
pid
|
|
112994
|
-
}))));
|
|
112995
|
-
return
|
|
113102
|
+
}))), getSomes);
|
|
113103
|
+
return pipe([...applications, ...running], map$10((app) => {
|
|
113104
|
+
const dock = findFirst(applications, (candidate) => candidate.pid === app.pid || exists(app.bundle, (bundle) => contains$2(candidate.bundle, bundle)));
|
|
113105
|
+
return {
|
|
113106
|
+
...app,
|
|
113107
|
+
detail: match$8(dock, {
|
|
113108
|
+
onNone: () => app.detail,
|
|
113109
|
+
onSome: (candidate) => candidate.detail
|
|
113110
|
+
}),
|
|
113111
|
+
label: UnitId.make(getOrElse$1(app.bundle, () => pipe(dock, map$13((candidate) => candidate.label), getOrElse$1(() => app.label)))),
|
|
113112
|
+
name: pipe(running, findFirst((candidate) => exists(app.bundle, (bundle) => contains$2(candidate.bundle, bundle))), match$8({
|
|
113113
|
+
onNone: () => match$8(dock, {
|
|
113114
|
+
onNone: () => app.name,
|
|
113115
|
+
onSome: (candidate) => candidate.name
|
|
113116
|
+
}),
|
|
113117
|
+
onSome: (agent) => agent.name
|
|
113118
|
+
}))
|
|
113119
|
+
};
|
|
113120
|
+
}), dedupeWith((left, right) => left.pid === right.pid));
|
|
112996
113121
|
}
|
|
112997
113122
|
// src/services/inventory/lib/command.ts
|
|
112998
113123
|
const WRAPPERS = [
|
|
@@ -113214,9 +113339,13 @@ function important(item) {
|
|
|
113214
113339
|
function ports(items) {
|
|
113215
113340
|
return pipe(items, filter$5((item) => appPort(item) && contains$2(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)));
|
|
113216
113341
|
}
|
|
113342
|
+
function serviceUnit(item) {
|
|
113343
|
+
if (item.kind === "service") return getOrElse$1(item.unit, () => item.name);
|
|
113344
|
+
return UnitId.make(item.name);
|
|
113345
|
+
}
|
|
113217
113346
|
function itemOwner(item) {
|
|
113218
113347
|
if (item.kind === "container") return AppId.make(`container:${slice(0, 12)(getOrElse$1(last$1(split$1(item.id, ":docker:")), constant("")))}`);
|
|
113219
|
-
return AppId.make(`service:${getOrElse$1(item.scope, constant("system"))}:${item
|
|
113348
|
+
return AppId.make(`service:${getOrElse$1(item.scope, constant("system"))}:${serviceUnit(item)}`);
|
|
113220
113349
|
}
|
|
113221
113350
|
function fullName(item) {
|
|
113222
113351
|
if (item.kind === "port") return getOrElse$1(item.process, () => item.name);
|
|
@@ -113251,7 +113380,8 @@ function workloads(items) {
|
|
|
113251
113380
|
}))));
|
|
113252
113381
|
const bySocket = fromIterable$5(map$10(reverse(filter$5(listeners, (listener) => !contains$2(listener.address, "container"))), (listener) => [socket(listener.worker, listener), listener]));
|
|
113253
113382
|
const grouped = pipe(items, filter$5((item) => item.kind === "service" || item.kind === "container"), map$10((item) => {
|
|
113254
|
-
const
|
|
113383
|
+
const unit = serviceUnit(item);
|
|
113384
|
+
const attached = filter$5(byUnit[item.worker]?.[`unit:${unit}`] ?? [], (listener) => contains$2(listener.unit, unit));
|
|
113255
113385
|
const bindings = pipe(item.bindings, getOrElse$1(empty$15), map$10((binding) => ({
|
|
113256
113386
|
...item,
|
|
113257
113387
|
...pipe(get$8(bySocket, socket(item.worker, {
|
|
@@ -113266,7 +113396,7 @@ function workloads(items) {
|
|
|
113266
113396
|
port: some$1(binding.port),
|
|
113267
113397
|
process: some$1(item.name),
|
|
113268
113398
|
protocol: some$1(binding.protocol),
|
|
113269
|
-
unit: pipe(item, liftPredicate((owner) => owner.kind === "service"), map$13(
|
|
113399
|
+
unit: pipe(item, liftPredicate((owner) => owner.kind === "service"), map$13(serviceUnit)),
|
|
113270
113400
|
url: none()
|
|
113271
113401
|
})));
|
|
113272
113402
|
return {
|
|
@@ -113274,7 +113404,7 @@ function workloads(items) {
|
|
|
113274
113404
|
listeners: [...attached, ...bindings]
|
|
113275
113405
|
};
|
|
113276
113406
|
}));
|
|
113277
|
-
const services = fromIterable$3(pipe(grouped, filter$5((row) => row.item.kind === "service"), map$10((row) => make$92(row.item.worker, row.item
|
|
113407
|
+
const services = fromIterable$3(pipe(grouped, filter$5((row) => row.item.kind === "service"), map$10((row) => make$92(row.item.worker, serviceUnit(row.item)))));
|
|
113278
113408
|
const represented = fromIterable$3(flatMap$6(grouped, (row) => pipe(row.listeners, filter$5((binding) => !contains$2(binding.address, "container")), map$10((binding) => socket(row.item.worker, {
|
|
113279
113409
|
address: binding.address,
|
|
113280
113410
|
port: binding.port,
|
|
@@ -113990,9 +114120,36 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
|
|
|
113990
114120
|
]
|
|
113991
114121
|
});
|
|
113992
114122
|
const darwin = gen(function* () {
|
|
113993
|
-
const
|
|
113994
|
-
|
|
113995
|
-
|
|
114123
|
+
const namedAgents = gen(function* () {
|
|
114124
|
+
return getSomes(yield* forEach$1(launchAgents(yield* command("launchctl", ["list"])), fnUntraced(function* (agent) {
|
|
114125
|
+
if (startsWith("deslop-")(agent.label)) return some$1(agent);
|
|
114126
|
+
const program = flatMap$8(yield* option$1(command("launchctl", ["print", `gui/${userInfo().uid}/${agent.label}`])), launchProgram);
|
|
114127
|
+
if (exists(program, systemProgram)) return none();
|
|
114128
|
+
return yield* pipe(program, flatMap$8(applicationBundle), match$8({
|
|
114129
|
+
onNone: () => succeedSome(agent),
|
|
114130
|
+
onSome: fnUntraced(function* (bundle) {
|
|
114131
|
+
const name = yield* findFirstFilter(["CFBundleDisplayName", "CFBundleName"], (key) => pipe(command("/usr/bin/plutil", [
|
|
114132
|
+
"-extract",
|
|
114133
|
+
key,
|
|
114134
|
+
"raw",
|
|
114135
|
+
"-expect",
|
|
114136
|
+
"string",
|
|
114137
|
+
"-o",
|
|
114138
|
+
"-",
|
|
114139
|
+
`${bundle}/Contents/Info.plist`
|
|
114140
|
+
]), option$1, map$7((value) => pipe(value, map$13(trim), filter$7(isNonEmpty$1), fromOption$2(constUndefined)))));
|
|
114141
|
+
return some$1({
|
|
114142
|
+
...agent,
|
|
114143
|
+
bundle: some$1(bundle),
|
|
114144
|
+
name: getOrElse$1(name, () => pipe(bundle, split$1("/"), last$1, getOrElse$1(constant("")), slice(0, -4)))
|
|
114145
|
+
});
|
|
114146
|
+
})
|
|
114147
|
+
}));
|
|
114148
|
+
}), { concurrency: 4 }));
|
|
114149
|
+
});
|
|
114150
|
+
const collected = yield* all$1({
|
|
114151
|
+
agents: result$1(namedAgents),
|
|
114152
|
+
applications: result$1(command("/usr/bin/lsappinfo", ["list"])),
|
|
113996
114153
|
table: result$1(command("env", [
|
|
113997
114154
|
"LC_ALL=C",
|
|
113998
114155
|
"ps",
|
|
@@ -114001,22 +114158,27 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
|
|
|
114001
114158
|
"pid=,ppid=,rss=,time=,lstart=,args="
|
|
114002
114159
|
]))
|
|
114003
114160
|
}, { concurrency: "unbounded" });
|
|
114161
|
+
const launchd = {
|
|
114162
|
+
...collected,
|
|
114163
|
+
applications: map$12(collected.applications, (text) => dockApplications(text, pipe(getOrElse(collected.agents, () => []), map$10((agent) => agent.bundle), getSomes)))
|
|
114164
|
+
};
|
|
114004
114165
|
const time = yield* now;
|
|
114005
|
-
const total =
|
|
114166
|
+
const total = pipe(cpus(), flatMap$6((cpu) => values(cpu.times)), sumAll, millis);
|
|
114006
114167
|
const apps = macApplications(getOrElse(launchd.agents, () => []), getOrElse(launchd.applications, () => []));
|
|
114007
114168
|
function appItems(found) {
|
|
114008
|
-
return
|
|
114169
|
+
return pipe(found, dedupeWith((left, right) => left.label === right.label), map$10((app) => InventoryItem.make({
|
|
114009
114170
|
active: true,
|
|
114010
114171
|
detail: app.detail,
|
|
114011
114172
|
id: ItemId.make(`${worker}:user:${app.label}`),
|
|
114012
114173
|
kind: "service",
|
|
114013
|
-
name: app.
|
|
114174
|
+
name: UnitId.make(app.name),
|
|
114014
114175
|
running: true,
|
|
114015
114176
|
scope: some$1("user"),
|
|
114016
114177
|
state: "running",
|
|
114178
|
+
unit: some$1(app.label),
|
|
114017
114179
|
url: none(),
|
|
114018
114180
|
worker
|
|
114019
|
-
}));
|
|
114181
|
+
})));
|
|
114020
114182
|
}
|
|
114021
114183
|
const records = map$12(launchd.table, (text) => {
|
|
114022
114184
|
const agents = fromIterable$5(map$10(apps, (app) => [app.pid, app.label]));
|
|
@@ -114030,9 +114192,9 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
|
|
|
114030
114192
|
total
|
|
114031
114193
|
})),
|
|
114032
114194
|
sources: [
|
|
114033
|
-
collect("Launch agents", map$7(fromResult(launchd.agents), (agents) => pipe(agents, filter$5((agent) => match$8(agent.pid, {
|
|
114195
|
+
collect("Launch agents", map$7(fromResult(launchd.agents), (agents) => [...appItems(filter$5(apps, (app) => app.detail === "user · launch agent")), ...pipe(agents, filter$5((agent) => match$8(agent.pid, {
|
|
114034
114196
|
onNone: () => exists(agent.status, (status) => status !== 0),
|
|
114035
|
-
onSome:
|
|
114197
|
+
onSome: constFalse$1
|
|
114036
114198
|
})), map$10((agent) => InventoryItem.make({
|
|
114037
114199
|
active: isSome(agent.pid),
|
|
114038
114200
|
detail: agent.detail,
|
|
@@ -114046,7 +114208,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
|
|
|
114046
114208
|
}),
|
|
114047
114209
|
id: ItemId.make(`${worker}:user:${agent.label}`),
|
|
114048
114210
|
kind: "service",
|
|
114049
|
-
name: agent.
|
|
114211
|
+
name: UnitId.make(agent.name),
|
|
114050
114212
|
running: isSome(agent.pid),
|
|
114051
114213
|
scope: some$1("user"),
|
|
114052
114214
|
state: match$8(agent.pid, {
|
|
@@ -114055,8 +114217,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
|
|
|
114055
114217
|
}),
|
|
114056
114218
|
url: none(),
|
|
114057
114219
|
worker
|
|
114058
|
-
}))))),
|
|
114059
|
-
collect("Applications", map$7(fromResult(launchd.applications), appItems)),
|
|
114220
|
+
})))])),
|
|
114221
|
+
collect("Applications", map$7(fromResult(launchd.applications), () => appItems(filter$5(apps, (app) => app.detail === "user · application")))),
|
|
114060
114222
|
collect("Listening ports", flatMap$3(command("lsof", [
|
|
114061
114223
|
"-nP",
|
|
114062
114224
|
"+c0",
|
|
@@ -114207,7 +114369,8 @@ const SERIES = {
|
|
|
114207
114369
|
10: seconds(10),
|
|
114208
114370
|
60: minutes(1),
|
|
114209
114371
|
1440: minutes(15),
|
|
114210
|
-
10080: hours(1)
|
|
114372
|
+
10080: hours(1),
|
|
114373
|
+
43200: hours(6)
|
|
114211
114374
|
};
|
|
114212
114375
|
function counters(stat, uptime, time) {
|
|
114213
114376
|
const values = decodeSync(CpuCounters)(pipe(stat, split$1("\n"), head, getOrElse$1(constant("")), trim, split$1(/\s+/u), drop$1(1), take$3(8)));
|
|
@@ -114363,7 +114526,8 @@ function rollup(point, stored) {
|
|
|
114363
114526
|
SERIES[10],
|
|
114364
114527
|
SERIES[60],
|
|
114365
114528
|
SERIES[1440],
|
|
114366
|
-
SERIES[10080]
|
|
114529
|
+
SERIES[10080],
|
|
114530
|
+
SERIES[43200]
|
|
114367
114531
|
], (step) => {
|
|
114368
114532
|
const fresh = {
|
|
114369
114533
|
...point,
|
|
@@ -114522,17 +114686,44 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114522
114686
|
const fs = yield* FileSystem;
|
|
114523
114687
|
const sql = yield* SqlClient;
|
|
114524
114688
|
const worker = yield* decodeEffect(WorkerId)(hostname());
|
|
114689
|
+
const joinedSamples = sql`SELECT s.*,
|
|
114690
|
+
CASE WHEN COUNT(a.app) = 0 THEN NULL ELSE
|
|
114691
|
+
json_group_array(json_patch('{}', json_object('id', a.app, 'cpu', a.cpu, 'memory', a.memory)))
|
|
114692
|
+
END AS apps
|
|
114693
|
+
FROM ${sql(MachineSample.table)} s
|
|
114694
|
+
LEFT JOIN ${sql(AppHistory.table)} a ON a.step = s.step AND a.since = s.since`;
|
|
114525
114695
|
const listBuckets = findAll({
|
|
114526
114696
|
Request: Sample.fields.time,
|
|
114527
114697
|
Result: Sample,
|
|
114528
|
-
execute: (time) => sql
|
|
114698
|
+
execute: (time) => sql`${joinedSamples} WHERE ${sql.or(map$10(values(SERIES), (spacing) => {
|
|
114529
114699
|
const step = toMillis(spacing);
|
|
114530
|
-
return sql`(step = ${step} AND since >= ${Math.floor(time / step) * step} AND since < ${(Math.floor(time / step) + 1) * step})`;
|
|
114531
|
-
}))}`
|
|
114700
|
+
return sql`(s.step = ${step} AND s.since >= ${Math.floor(time / step) * step} AND s.since < ${(Math.floor(time / step) + 1) * step})`;
|
|
114701
|
+
}))} GROUP BY s.step, s.since`
|
|
114702
|
+
});
|
|
114703
|
+
const saveMachineSamples = void_({
|
|
114704
|
+
Request: NonEmptyArray(MachineSample.insert),
|
|
114705
|
+
execute: (rows) => sql`INSERT OR REPLACE INTO ${sql(MachineSample.table)} ${sql.insert(rows)}`
|
|
114706
|
+
});
|
|
114707
|
+
const deleteAppSamples = void_({
|
|
114708
|
+
Request: NonEmptyArray(MachineSample.insert),
|
|
114709
|
+
execute: (rows) => sql`DELETE FROM ${sql(AppHistory.table)} WHERE ${sql.or(map$10(rows, (row) => sql`(step = ${row.step} AND since = ${row.since})`))}`
|
|
114532
114710
|
});
|
|
114533
|
-
const
|
|
114534
|
-
Request: NonEmptyArray(
|
|
114535
|
-
execute: (rows) => sql`INSERT
|
|
114711
|
+
const saveAppSamples = void_({
|
|
114712
|
+
Request: NonEmptyArray(AppHistory.insert),
|
|
114713
|
+
execute: (rows) => sql`INSERT INTO ${sql(AppHistory.table)} ${sql.insert(rows)}`
|
|
114714
|
+
});
|
|
114715
|
+
const saveSamples = fnUntraced(function* (rows) {
|
|
114716
|
+
const machines = map$10(rows, (row) => omit(row, ["apps"]));
|
|
114717
|
+
yield* saveMachineSamples(machines);
|
|
114718
|
+
yield* deleteAppSamples(machines);
|
|
114719
|
+
const apps = flatMap$6(rows, (row) => pipe(row.apps, getOrElse$1(empty$15), map$10((app) => ({
|
|
114720
|
+
app: app.id,
|
|
114721
|
+
cpu: app.cpu,
|
|
114722
|
+
memory: app.memory,
|
|
114723
|
+
since: row.since,
|
|
114724
|
+
step: row.step
|
|
114725
|
+
}))));
|
|
114726
|
+
if (isReadonlyArrayNonEmpty(apps)) yield* saveAppSamples(apps);
|
|
114536
114727
|
});
|
|
114537
114728
|
const listSeries = findAll({
|
|
114538
114729
|
Request: Struct$2({
|
|
@@ -114540,11 +114731,11 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114540
114731
|
step: Sample.fields.step
|
|
114541
114732
|
}),
|
|
114542
114733
|
Result: Sample,
|
|
114543
|
-
execute: (query) => sql
|
|
114734
|
+
execute: (query) => sql`${joinedSamples} WHERE s.step = ${query.step} AND s.since > ${query.after} GROUP BY s.step, s.since ORDER BY s.since`
|
|
114544
114735
|
});
|
|
114545
114736
|
const deleteExpired = void_({
|
|
114546
114737
|
Request: Sample.fields.time,
|
|
114547
|
-
execute: (now) => sql`DELETE FROM ${sql(
|
|
114738
|
+
execute: (now) => forEach$1([AppHistory.table, MachineSample.table], (table) => sql`DELETE FROM ${sql(table)} WHERE ${sql.or(map$10(toEntries(SERIES), (entry) => sql`(step = ${toMillis(entry[1])} AND since < ${now - pipe(entry[0], parse$2, getOrThrow$1, minutes, toMillis) - toMillis(entry[1])})`))}`, { concurrency: 1 })
|
|
114548
114739
|
});
|
|
114549
114740
|
const previous = yield* make$56(none());
|
|
114550
114741
|
const lastApps = yield* make$56(none());
|
|
@@ -114660,7 +114851,7 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114660
114851
|
});
|
|
114661
114852
|
yield* set(failure, none());
|
|
114662
114853
|
}), withSpan("Metrics.collect", { attributes: { worker } }), tapError$3((cause) => logWarning("Metrics could not be sampled", cause)), catch_$2((cause) => set(failure, some$1(cause.message))));
|
|
114663
|
-
const prune = pipe(now, flatMap$3(deleteExpired), asDeployError$1, withSpan("Metrics.prune", { attributes: { worker } }));
|
|
114854
|
+
const prune = pipe(now, flatMap$3(deleteExpired), sql.withTransaction, asDeployError$1, withSpan("Metrics.prune", { attributes: { worker } }));
|
|
114664
114855
|
yield* prune;
|
|
114665
114856
|
yield* refreshStorage;
|
|
114666
114857
|
yield* collect;
|
|
@@ -114686,6 +114877,10 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114686
114877
|
disks: now$2.disks,
|
|
114687
114878
|
error: yield* get$2(failure),
|
|
114688
114879
|
load: now$2.load,
|
|
114880
|
+
platform: some$1(match(platform === "darwin", {
|
|
114881
|
+
onFalse: constant("linux"),
|
|
114882
|
+
onTrue: constant("darwin")
|
|
114883
|
+
})),
|
|
114689
114884
|
samples: history(samples, query.minutes, time),
|
|
114690
114885
|
stale: match$8(last$1(samples), {
|
|
114691
114886
|
onNone: constTrue,
|
|
@@ -114697,7 +114892,8 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114697
114892
|
}) };
|
|
114698
114893
|
}) }) {
|
|
114699
114894
|
static migrations = effectDiscard(make$18({})({
|
|
114700
|
-
loader: fromRecord({
|
|
114895
|
+
loader: fromRecord({
|
|
114896
|
+
"0001_metrics": flatMap$3(SqlClient, (sql) => sql`
|
|
114701
114897
|
CREATE TABLE samples (
|
|
114702
114898
|
step INTEGER NOT NULL,
|
|
114703
114899
|
since INTEGER NOT NULL,
|
|
@@ -114709,7 +114905,30 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
|
|
|
114709
114905
|
apps TEXT,
|
|
114710
114906
|
PRIMARY KEY (step, since)
|
|
114711
114907
|
) STRICT
|
|
114712
|
-
`)
|
|
114908
|
+
`),
|
|
114909
|
+
"0002_app_samples": gen(function* () {
|
|
114910
|
+
const sql = yield* SqlClient;
|
|
114911
|
+
yield* sql`
|
|
114912
|
+
CREATE TABLE app_samples (
|
|
114913
|
+
step INTEGER NOT NULL,
|
|
114914
|
+
since INTEGER NOT NULL,
|
|
114915
|
+
app TEXT NOT NULL,
|
|
114916
|
+
cpu REAL,
|
|
114917
|
+
memory REAL NOT NULL,
|
|
114918
|
+
PRIMARY KEY (step, since, app)
|
|
114919
|
+
) STRICT, WITHOUT ROWID
|
|
114920
|
+
`;
|
|
114921
|
+
yield* sql`
|
|
114922
|
+
INSERT INTO app_samples (step, since, app, cpu, memory)
|
|
114923
|
+
SELECT samples.step, samples.since,
|
|
114924
|
+
json_extract(app.value, '$.id'), json_extract(app.value, '$.cpu'), json_extract(app.value, '$.memory')
|
|
114925
|
+
FROM samples, json_each(samples.apps) app
|
|
114926
|
+
`;
|
|
114927
|
+
yield* sql`ALTER TABLE samples DROP COLUMN apps`;
|
|
114928
|
+
yield* sql`DELETE FROM app_samples WHERE step = 1000`;
|
|
114929
|
+
yield* sql`DELETE FROM samples WHERE step = 1000`;
|
|
114930
|
+
})
|
|
114931
|
+
}),
|
|
114713
114932
|
table: "metrics_migrations"
|
|
114714
114933
|
}));
|
|
114715
114934
|
static layer = provide$2(effect(this, this.make), this.migrations);
|
|
@@ -114742,6 +114961,7 @@ function cachedHistory(query, time, saved) {
|
|
|
114742
114961
|
onNone: () => [],
|
|
114743
114962
|
onSome: (machine) => machine.load
|
|
114744
114963
|
}),
|
|
114964
|
+
platform: flatMap$8(saved, (machine) => machine.platform),
|
|
114745
114965
|
samples: history(match$8(saved, {
|
|
114746
114966
|
onNone: () => [],
|
|
114747
114967
|
onSome: (machine) => machine.samples
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deslop/deploy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1333",
|
|
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": "
|
|
43
|
+
"fingerprint": "499766795c104dd1cc9b7bf9be349d28a794cf0d8208493ff14136e645fb7582"
|
|
44
44
|
}
|