@zswarm/core 0.2.2 → 0.2.4
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/assets/host-install.sh +36 -2
- package/assets/host-report.sh +15 -1
- package/assets/slot.py +35 -1
- package/dist/harness.d.ts +20 -0
- package/dist/harness.js +64 -1
- package/dist/host/cli.js +78 -4
- package/dist/host/crew.d.ts +2 -0
- package/dist/host/crew.js +13 -0
- package/dist/host/host.js +13 -0
- package/dist/host/lease.d.ts +68 -0
- package/dist/host/lease.js +138 -0
- package/dist/host/relay.d.ts +80 -1
- package/dist/host/relay.js +291 -9
- package/dist/host/services.d.ts +9 -2
- package/dist/host/services.js +105 -9
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/ops/delivery.d.ts +51 -2
- package/dist/ops/delivery.js +162 -31
- package/dist/ops/dispatch.js +151 -14
- package/dist/ops/util.d.ts +9 -0
- package/dist/ops/util.js +24 -0
- package/dist/schema.js +50 -3
- package/dist/state.d.ts +20 -0
- package/dist/state.js +20 -0
- package/dist/zellij/args.d.ts +1 -1
- package/dist/zellij/args.js +3 -1
- package/dist/zellij/bus.js +1 -0
- package/dist/zellij/client.d.ts +2 -0
- package/dist/zellij/client.js +17 -1
- package/dist/zellij/panes.d.ts +1 -0
- package/dist/zellij/panes.js +3 -0
- package/dist/zellij/session.d.ts +11 -0
- package/dist/zellij/session.js +35 -3
- package/package.json +1 -1
package/dist/zellij/session.js
CHANGED
|
@@ -13,6 +13,34 @@ export function resolveSelfPaneId(env = process.env) {
|
|
|
13
13
|
return raw.toLowerCase();
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
+
const AGE_UNITS = [
|
|
17
|
+
[/^years?$|^yrs?$|^y$/, 31_536_000],
|
|
18
|
+
[/^months?$|^mons?$|^mo$/, 2_592_000],
|
|
19
|
+
[/^days?$|^d$/, 86_400],
|
|
20
|
+
[/^hours?$|^hrs?$|^h$/, 3_600],
|
|
21
|
+
[/^minutes?$|^mins?$|^m$/, 60],
|
|
22
|
+
[/^seconds?$|^secs?$|^s$/, 1],
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Zellij's human created age (`"1month 16days 2h 30m 5s ago"`) as seconds.
|
|
26
|
+
* Handles the units Zellij prints (s, m, h, days, months, years, singular and
|
|
27
|
+
* plural) with or without spaces between the pairs. Returns null when no
|
|
28
|
+
* number+unit pair is present (e.g. a bare `"demo"` listing).
|
|
29
|
+
*/
|
|
30
|
+
export function parseCreatedAge(text) {
|
|
31
|
+
const re = /(\d+)\s*(years?|yrs?|y|months?|mons?|mo|days?|d|hours?|hrs?|h|minutes?|mins?|m|seconds?|secs?|s)/g;
|
|
32
|
+
let total = 0;
|
|
33
|
+
let found = false;
|
|
34
|
+
for (const match of String(text).toLowerCase().matchAll(re)) {
|
|
35
|
+
const unit = match[2];
|
|
36
|
+
const seconds = AGE_UNITS.find(([pattern]) => pattern.test(unit))?.[1];
|
|
37
|
+
if (seconds === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
total += Number(match[1]) * seconds;
|
|
40
|
+
found = true;
|
|
41
|
+
}
|
|
42
|
+
return found ? total : null;
|
|
43
|
+
}
|
|
16
44
|
/**
|
|
17
45
|
* Parse `list-sessions --no-formatting` output.
|
|
18
46
|
*
|
|
@@ -21,9 +49,9 @@ export function resolveSelfPaneId(env = process.env) {
|
|
|
21
49
|
*/
|
|
22
50
|
export function parseSessionList(stdout) {
|
|
23
51
|
const sessions = [];
|
|
24
|
-
for (const
|
|
52
|
+
for (const entry of stdout.split(/\r?\n/)) {
|
|
25
53
|
// Drop ANSI in case a caller forgot --no-formatting.
|
|
26
|
-
const line =
|
|
54
|
+
const line = entry.replace(/\x1B\[[0-9;]*m/g, "").trim();
|
|
27
55
|
if (!line)
|
|
28
56
|
continue;
|
|
29
57
|
const created = line.indexOf(" [Created ");
|
|
@@ -32,15 +60,19 @@ export function parseSessionList(stdout) {
|
|
|
32
60
|
if (!name)
|
|
33
61
|
continue;
|
|
34
62
|
const suffix = line.slice(created);
|
|
63
|
+
const raw = (/\[Created ([^\]]*)\]/.exec(suffix)?.[1] ?? "").trim();
|
|
64
|
+
const age = raw ? raw.replace(/\s*ago\s*$/i, "").trim() || null : null;
|
|
35
65
|
sessions.push({
|
|
36
66
|
name,
|
|
37
67
|
exited: /\(EXITED\b/i.test(suffix),
|
|
38
68
|
current: /\(current\)/i.test(suffix),
|
|
69
|
+
age,
|
|
70
|
+
ageSeconds: raw ? parseCreatedAge(raw) : null,
|
|
39
71
|
});
|
|
40
72
|
continue;
|
|
41
73
|
}
|
|
42
74
|
// Bare name from --short or a mock.
|
|
43
|
-
sessions.push({ name: line, exited: false, current: false });
|
|
75
|
+
sessions.push({ name: line, exited: false, current: false, age: null, ageSeconds: null });
|
|
44
76
|
}
|
|
45
77
|
return sessions;
|
|
46
78
|
}
|