@sentropic/h2a-runtime 0.89.0 → 0.90.1
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/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +223 -46
- package/dist/index.js.map +1 -1
- package/dist/relaunch.d.ts +20 -1
- package/dist/relaunch.d.ts.map +1 -1
- package/dist/relaunch.js +31 -10
- package/dist/relaunch.js.map +1 -1
- package/dist/tmux.d.ts +40 -1
- package/dist/tmux.d.ts.map +1 -1
- package/dist/tmux.js +130 -6
- package/dist/tmux.js.map +1 -1
- package/package.json +1 -1
package/dist/relaunch.d.ts
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
* convId (from the registry), never "most recent", so the N sessions that share
|
|
11
11
|
* a cwd never collide on one .jsonl.
|
|
12
12
|
*/
|
|
13
|
+
export type ResumeLaunch = {
|
|
14
|
+
command: string;
|
|
15
|
+
args: string[];
|
|
16
|
+
display: string;
|
|
17
|
+
};
|
|
18
|
+
/** Structured argv for resuming a conversation, safe to hand to a new tmux session. */
|
|
19
|
+
export declare function resumeLaunchFor(profile: string, convId: string): ResumeLaunch | undefined;
|
|
13
20
|
/** The shell command that resumes `convId` for `profile`, or undefined if the */
|
|
14
21
|
/** profile has no resume form (e.g. shell). */
|
|
15
22
|
export declare function resumeCommandFor(profile: string, convId: string): string | undefined;
|
|
@@ -23,6 +30,8 @@ export type RelaunchCandidate = {
|
|
|
23
30
|
idle: boolean;
|
|
24
31
|
/** this session's own conversation id, from the registry */
|
|
25
32
|
convId?: string;
|
|
33
|
+
/** why its registry row cannot safely produce a resume conversation */
|
|
34
|
+
unresumableReason?: string;
|
|
26
35
|
};
|
|
27
36
|
export type RelaunchAction = {
|
|
28
37
|
slug: string;
|
|
@@ -31,6 +40,9 @@ export type RelaunchAction = {
|
|
|
31
40
|
convId: string;
|
|
32
41
|
/** the command to run in the session (e.g. `claude --resume <id>`) */
|
|
33
42
|
cmd: string;
|
|
43
|
+
/** structured launch command, never execute `cmd` as a shell string */
|
|
44
|
+
command: string;
|
|
45
|
+
args: string[];
|
|
34
46
|
};
|
|
35
47
|
export type RelaunchSkip = {
|
|
36
48
|
slug: string;
|
|
@@ -40,6 +52,13 @@ export type RelaunchPlan = {
|
|
|
40
52
|
actions: RelaunchAction[];
|
|
41
53
|
skipped: RelaunchSkip[];
|
|
42
54
|
};
|
|
55
|
+
export type PlanRelaunchOptions = {
|
|
56
|
+
/** A forced restart may replace a CLI that is still running. */
|
|
57
|
+
force?: boolean;
|
|
58
|
+
/** Bulk operations must leave human-facing agent CLIs alone unless opted in. */
|
|
59
|
+
excludeInteractiveAgents?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare function isInteractiveAgentProfile(profile: string): boolean;
|
|
43
62
|
/**
|
|
44
63
|
* Decide what to relaunch. Pure: takes fully-resolved candidates (idle flag +
|
|
45
64
|
* convId already gathered) so it is unit-testable without tmux/registry I/O.
|
|
@@ -48,5 +67,5 @@ export type RelaunchPlan = {
|
|
|
48
67
|
* profiles with no resume form. Also refuses to point two sessions at the SAME
|
|
49
68
|
* convId (defensive: the registry should already be 1:1).
|
|
50
69
|
*/
|
|
51
|
-
export declare function planRelaunch(candidates: ReadonlyArray<RelaunchCandidate
|
|
70
|
+
export declare function planRelaunch(candidates: ReadonlyArray<RelaunchCandidate>, options?: PlanRelaunchOptions): RelaunchPlan;
|
|
52
71
|
//# sourceMappingURL=relaunch.d.ts.map
|
package/dist/relaunch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaunch.d.ts","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,iFAAiF;AACjF,+CAA+C;AAC/C,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"rela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AO,EAAE,YAAY,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAqEd"}
|
package/dist/relaunch.js
CHANGED
|
@@ -11,16 +11,27 @@
|
|
|
11
11
|
* a cwd never collide on one .jsonl.
|
|
12
12
|
*/
|
|
13
13
|
import { isCliProfile, resolveProfile, resumeArgsFor } from "./profiles.js";
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
export function resumeCommandFor(profile, convId) {
|
|
14
|
+
/** Structured argv for resuming a conversation, safe to hand to a new tmux session. */
|
|
15
|
+
export function resumeLaunchFor(profile, convId) {
|
|
17
16
|
if (!isCliProfile(profile))
|
|
18
17
|
return undefined;
|
|
19
18
|
const cfg = resolveProfile(profile);
|
|
20
19
|
const args = resumeArgsFor(cfg, convId);
|
|
21
20
|
if (args.length === 0)
|
|
22
21
|
return undefined;
|
|
23
|
-
return
|
|
22
|
+
return {
|
|
23
|
+
command: cfg.command,
|
|
24
|
+
args,
|
|
25
|
+
display: [cfg.command, ...args].join(" "),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** The shell command that resumes `convId` for `profile`, or undefined if the */
|
|
29
|
+
/** profile has no resume form (e.g. shell). */
|
|
30
|
+
export function resumeCommandFor(profile, convId) {
|
|
31
|
+
return resumeLaunchFor(profile, convId)?.display;
|
|
32
|
+
}
|
|
33
|
+
export function isInteractiveAgentProfile(profile) {
|
|
34
|
+
return ["claude", "claude-code", "codex", "agy", "antigravity"].includes(profile);
|
|
24
35
|
}
|
|
25
36
|
/**
|
|
26
37
|
* Decide what to relaunch. Pure: takes fully-resolved candidates (idle flag +
|
|
@@ -30,7 +41,7 @@ export function resumeCommandFor(profile, convId) {
|
|
|
30
41
|
* profiles with no resume form. Also refuses to point two sessions at the SAME
|
|
31
42
|
* convId (defensive: the registry should already be 1:1).
|
|
32
43
|
*/
|
|
33
|
-
export function planRelaunch(candidates) {
|
|
44
|
+
export function planRelaunch(candidates, options = {}) {
|
|
34
45
|
const actions = [];
|
|
35
46
|
const skipped = [];
|
|
36
47
|
const claimed = new Map(); // convId -> slug that took it
|
|
@@ -50,14 +61,22 @@ export function planRelaunch(candidates) {
|
|
|
50
61
|
});
|
|
51
62
|
continue;
|
|
52
63
|
}
|
|
53
|
-
if (
|
|
64
|
+
if (options.excludeInteractiveAgents && isInteractiveAgentProfile(c.profile)) {
|
|
65
|
+
skipped.push({
|
|
66
|
+
slug: c.slug,
|
|
67
|
+
reason: `interactive agent CLI (${c.profile}) excluded by default; pass --include-agents`,
|
|
68
|
+
});
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (!options.force && !c.idle) {
|
|
54
72
|
skipped.push({ slug: c.slug, reason: "CLI is running — left alone" });
|
|
55
73
|
continue;
|
|
56
74
|
}
|
|
57
75
|
if (!c.convId) {
|
|
58
76
|
skipped.push({
|
|
59
77
|
slug: c.slug,
|
|
60
|
-
reason:
|
|
78
|
+
reason: c.unresumableReason ??
|
|
79
|
+
"no convId in the registry — relaunch manually",
|
|
61
80
|
});
|
|
62
81
|
continue;
|
|
63
82
|
}
|
|
@@ -69,8 +88,8 @@ export function planRelaunch(candidates) {
|
|
|
69
88
|
});
|
|
70
89
|
continue;
|
|
71
90
|
}
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
91
|
+
const launch = resumeLaunchFor(c.profile, c.convId);
|
|
92
|
+
if (!launch) {
|
|
74
93
|
skipped.push({
|
|
75
94
|
slug: c.slug,
|
|
76
95
|
reason: `profile "${c.profile}" has no resume form`,
|
|
@@ -83,7 +102,9 @@ export function planRelaunch(candidates) {
|
|
|
83
102
|
name: c.name,
|
|
84
103
|
profile: c.profile,
|
|
85
104
|
convId: c.convId,
|
|
86
|
-
cmd,
|
|
105
|
+
cmd: launch.display,
|
|
106
|
+
command: launch.command,
|
|
107
|
+
args: launch.args,
|
|
87
108
|
});
|
|
88
109
|
}
|
|
89
110
|
return { actions, skipped };
|
package/dist/relaunch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaunch.js","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"relaunch.js","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQ5E,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,MAAc;IAEd,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI;QACJ,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;KAC1C,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,+CAA+C;AAC/C,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,M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AAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,GAAG,EAAE,MAAM,CAAC,OAAO;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/tmux.d.ts
CHANGED
|
@@ -319,7 +319,28 @@ export declare function sessionWindowNames(session: string): string[];
|
|
|
319
319
|
export declare function addSessionWindow(session: string, windowName: string, cwd: string, commandLine: string, agentPane?: string): boolean;
|
|
320
320
|
/** Is `cmd` resolvable in PATH (login shell, same as the tmux windows use)? */
|
|
321
321
|
export declare function commandAvailable(cmd: string): boolean;
|
|
322
|
-
|
|
322
|
+
/** Directory under the h2a root where the bar writer publishes per-session text. */
|
|
323
|
+
export declare const STATUS_BAR_DIR = "status-bar";
|
|
324
|
+
/** Directory holding the writer lease and every per-session bar file. */
|
|
325
|
+
export declare function statusBarRoot(root?: string): string;
|
|
326
|
+
/**
|
|
327
|
+
* Filesystem-safe, collision-free per-session bar file pair. The sanitized
|
|
328
|
+
* name keeps files greppable; the hash keeps two sessions whose names differ
|
|
329
|
+
* only by an unsafe character from sharing a file.
|
|
330
|
+
*/
|
|
331
|
+
export declare function statusBarFilesForSession(session: string, root?: string): {
|
|
332
|
+
readonly left: string;
|
|
333
|
+
readonly right: string;
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* The 2026-07-31 spawn-storm rule: tmux re-runs every #(...) here once per
|
|
337
|
+
* status-interval for EVERY installed session, so nothing in these options may
|
|
338
|
+
* start a process heavier than a file read. The bar text is produced by the
|
|
339
|
+
* single background writer (h2a status --write-bars); when the writer or its
|
|
340
|
+
* file is absent the bar falls back to a static placeholder and spawns
|
|
341
|
+
* nothing heavier than the same cat.
|
|
342
|
+
*/
|
|
343
|
+
export declare function h2aStatusSurfaceOptions(_previousRight?: string, session?: string): ReadonlyArray<readonly [string, string]>;
|
|
323
344
|
export interface H2aStatusOptionAccess {
|
|
324
345
|
readonly read: (session: string, option: string) => string | undefined;
|
|
325
346
|
readonly set: (session: string, option: string, value: string) => boolean;
|
|
@@ -332,6 +353,24 @@ export declare function uninstallH2aStatusSurfaceWithAccess(session: string, acc
|
|
|
332
353
|
* tests. No live option changes until all six prior values are captured.
|
|
333
354
|
*/
|
|
334
355
|
export declare function installH2aStatusSurfaceWithAccess(session: string, access: H2aStatusOptionAccess): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Start the single background bar writer when none is alive. Idempotent and
|
|
358
|
+
* fail-safe: the spawned writer exits immediately if another one holds the
|
|
359
|
+
* lease, and when no writer can start at all the installed bar shows its
|
|
360
|
+
* static placeholders instead of ever spawning per refresh.
|
|
361
|
+
*/
|
|
362
|
+
export declare function ensureStatusBarWriter(root?: string): void;
|
|
363
|
+
export interface StatusBarTarget {
|
|
364
|
+
readonly session: string;
|
|
365
|
+
readonly ownerInstance?: string;
|
|
366
|
+
readonly clientWidth?: number;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Managed sessions whose installed surface expects bar files. One bounded
|
|
370
|
+
* tmux call for sessions plus one for client widths, regardless of session
|
|
371
|
+
* count — the writer must never pay a per-session subprocess per tick.
|
|
372
|
+
*/
|
|
373
|
+
export declare function listStatusBarTargets(): StatusBarTarget[];
|
|
335
374
|
/** Install the composable 5-second status projection on one exact session. */
|
|
336
375
|
export declare function installH2aStatusSurface(session: string): boolean;
|
|
337
376
|
/** Restore every user option captured on first install. */
|
package/dist/tmux.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../src/tmux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../src/tmux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqBH,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,yEAAyE;AACzE,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAMjD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;CA0BtB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,aAAa,ySAIiC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,qCACpB,CAAC;AAElB;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,mYASwC,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,UAAU,GAAE,aAAa,CAAC,MAAM,CAAM,GACrC,MAAM,CASR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAGlE;AAgBD,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,4HAErB,CAAC;AAElB;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,sBAAsB,eAAe,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MnE;AA8BD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CASvD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9D;AAuBD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAmE7E"}
|
package/dist/tmux.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* middle — this is what fixes "I can't copy the code claude printed".
|
|
12
12
|
*/
|
|
13
13
|
import { spawn, spawnSync } from "node:child_process";
|
|
14
|
-
import { randomUUID } from "node:crypto";
|
|
14
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
15
15
|
import { getTmuxProfileConfig } from "./config.js";
|
|
16
|
+
import { defaultLocalH2aRoot } from "./h2a-bridge.js";
|
|
16
17
|
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
17
18
|
import { basename, join } from "node:path";
|
|
18
19
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -1008,7 +1009,52 @@ function setSessionOption(session, option, value) {
|
|
|
1008
1009
|
function unsetSessionOption(session, option) {
|
|
1009
1010
|
return spawnSync(TMUX, ["set-option", "-u", "-t", exactSessionTarget(session), option], { stdio: "ignore" }).status === 0;
|
|
1010
1011
|
}
|
|
1011
|
-
|
|
1012
|
+
/** Directory under the h2a root where the bar writer publishes per-session text. */
|
|
1013
|
+
export const STATUS_BAR_DIR = "status-bar";
|
|
1014
|
+
/**
|
|
1015
|
+
* Lock file the bar writer holds inside the status-bar directory. The writer
|
|
1016
|
+
* side of this contract lives in @sentropic/h2a (status-bar-writer.ts); the
|
|
1017
|
+
* name is duplicated there because the CLI is a peer, not an import.
|
|
1018
|
+
*/
|
|
1019
|
+
const STATUS_BAR_WRITER_LOCK = "writer.lock";
|
|
1020
|
+
const STATUS_BAR_WRITER_STALE_MS = 60_000;
|
|
1021
|
+
function h2aRootForStatusBar(root) {
|
|
1022
|
+
return root ?? process.env.H2A_ROOT ?? defaultLocalH2aRoot();
|
|
1023
|
+
}
|
|
1024
|
+
/** Directory holding the writer lease and every per-session bar file. */
|
|
1025
|
+
export function statusBarRoot(root) {
|
|
1026
|
+
return join(h2aRootForStatusBar(root), STATUS_BAR_DIR);
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Filesystem-safe, collision-free per-session bar file pair. The sanitized
|
|
1030
|
+
* name keeps files greppable; the hash keeps two sessions whose names differ
|
|
1031
|
+
* only by an unsafe character from sharing a file.
|
|
1032
|
+
*/
|
|
1033
|
+
export function statusBarFilesForSession(session, root) {
|
|
1034
|
+
const safe = session.replace(/[^A-Za-z0-9_.-]/g, "_");
|
|
1035
|
+
const hash = createHash("sha256").update(session).digest("hex").slice(0, 8);
|
|
1036
|
+
const base = join(statusBarRoot(root), `${safe}-${hash}`);
|
|
1037
|
+
return { left: `${base}.left`, right: `${base}.right` };
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Embed a path in a status option: single-quoted for the /bin/sh that runs
|
|
1041
|
+
* #() commands, with tmux format (#) and strftime (%) expansion escaped. The
|
|
1042
|
+
* escape only matters for exotic H2A_ROOT values — session file names are
|
|
1043
|
+
* sanitized to characters both layers pass through verbatim.
|
|
1044
|
+
*/
|
|
1045
|
+
function statusOptionPath(path) {
|
|
1046
|
+
return shellSingleQuote(path).replace(/#/g, "##").replace(/%/g, "%%");
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* The 2026-07-31 spawn-storm rule: tmux re-runs every #(...) here once per
|
|
1050
|
+
* status-interval for EVERY installed session, so nothing in these options may
|
|
1051
|
+
* start a process heavier than a file read. The bar text is produced by the
|
|
1052
|
+
* single background writer (h2a status --write-bars); when the writer or its
|
|
1053
|
+
* file is absent the bar falls back to a static placeholder and spawns
|
|
1054
|
+
* nothing heavier than the same cat.
|
|
1055
|
+
*/
|
|
1056
|
+
export function h2aStatusSurfaceOptions(_previousRight = "%H:%M", session = "") {
|
|
1057
|
+
const files = statusBarFilesForSession(session);
|
|
1012
1058
|
return [
|
|
1013
1059
|
["status", "on"],
|
|
1014
1060
|
["status-interval", "5"],
|
|
@@ -1016,7 +1062,7 @@ export function h2aStatusSurfaceOptions(_previousRight = "%H:%M") {
|
|
|
1016
1062
|
["status-right-length", "200"],
|
|
1017
1063
|
[
|
|
1018
1064
|
"status-left",
|
|
1019
|
-
|
|
1065
|
+
`[h2a] #(cat ${statusOptionPath(files.left)} 2>/dev/null || echo 'h2a ?') `,
|
|
1020
1066
|
],
|
|
1021
1067
|
[
|
|
1022
1068
|
"status-right",
|
|
@@ -1024,7 +1070,7 @@ export function h2aStatusSurfaceOptions(_previousRight = "%H:%M") {
|
|
|
1024
1070
|
// embed it in the active bar: tmux formats can expand pane/session
|
|
1025
1071
|
// titles supplied by a host and bypass the status renderer's cap and
|
|
1026
1072
|
// control/bidi stripping. The fixed clock is bounded, trusted text.
|
|
1027
|
-
|
|
1073
|
+
`#(cat ${statusOptionPath(files.right)} 2>/dev/null || echo 'gw ?') %H:%M`,
|
|
1028
1074
|
],
|
|
1029
1075
|
];
|
|
1030
1076
|
}
|
|
@@ -1111,7 +1157,7 @@ export function installH2aStatusSurfaceWithAccess(session, access) {
|
|
|
1111
1157
|
if (previousRight === undefined)
|
|
1112
1158
|
return false;
|
|
1113
1159
|
let applied = true;
|
|
1114
|
-
for (const [option, value] of h2aStatusSurfaceOptions(previousRight)) {
|
|
1160
|
+
for (const [option, value] of h2aStatusSurfaceOptions(previousRight, session)) {
|
|
1115
1161
|
applied = access.set(session, option, value) && applied;
|
|
1116
1162
|
}
|
|
1117
1163
|
applied = access.set(session, H2A_STATUS_INSTALLED_OPTION, "v1") && applied;
|
|
@@ -1122,13 +1168,91 @@ export function installH2aStatusSurfaceWithAccess(session, access) {
|
|
|
1122
1168
|
uninstallH2aStatusSurfaceWithAccess(session, access);
|
|
1123
1169
|
return false;
|
|
1124
1170
|
}
|
|
1171
|
+
function statusBarWriterAlive(dir) {
|
|
1172
|
+
try {
|
|
1173
|
+
const lockPath = join(dir, STATUS_BAR_WRITER_LOCK);
|
|
1174
|
+
if (Date.now() - statSync(lockPath).mtimeMs > STATUS_BAR_WRITER_STALE_MS) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
const holder = JSON.parse(readFileSync(lockPath, "utf8"));
|
|
1178
|
+
if (typeof holder.pid !== "number")
|
|
1179
|
+
return false;
|
|
1180
|
+
process.kill(holder.pid, 0);
|
|
1181
|
+
return true;
|
|
1182
|
+
}
|
|
1183
|
+
catch {
|
|
1184
|
+
return false;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Start the single background bar writer when none is alive. Idempotent and
|
|
1189
|
+
* fail-safe: the spawned writer exits immediately if another one holds the
|
|
1190
|
+
* lease, and when no writer can start at all the installed bar shows its
|
|
1191
|
+
* static placeholders instead of ever spawning per refresh.
|
|
1192
|
+
*/
|
|
1193
|
+
export function ensureStatusBarWriter(root) {
|
|
1194
|
+
const resolvedRoot = h2aRootForStatusBar(root);
|
|
1195
|
+
try {
|
|
1196
|
+
if (statusBarWriterAlive(statusBarRoot(resolvedRoot)))
|
|
1197
|
+
return;
|
|
1198
|
+
const child = spawn("h2a", ["status", "--write-bars", "--root", resolvedRoot], { detached: true, stdio: "ignore" });
|
|
1199
|
+
child.on("error", () => { });
|
|
1200
|
+
child.unref();
|
|
1201
|
+
}
|
|
1202
|
+
catch {
|
|
1203
|
+
// Fail safe: without a writer the bar keeps its static placeholders.
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Managed sessions whose installed surface expects bar files. One bounded
|
|
1208
|
+
* tmux call for sessions plus one for client widths, regardless of session
|
|
1209
|
+
* count — the writer must never pay a per-session subprocess per tick.
|
|
1210
|
+
*/
|
|
1211
|
+
export function listStatusBarTargets() {
|
|
1212
|
+
const sessions = spawnSync(TMUX, [
|
|
1213
|
+
"list-sessions",
|
|
1214
|
+
"-F",
|
|
1215
|
+
`#{session_name}\t#{${H2A_STATUS_INSTALLED_OPTION}}\t#{@h2a_owner_instance}`,
|
|
1216
|
+
], { encoding: "utf8" });
|
|
1217
|
+
if (sessions.status !== 0 || !sessions.stdout)
|
|
1218
|
+
return [];
|
|
1219
|
+
const widths = new Map();
|
|
1220
|
+
const clients = spawnSync(TMUX, ["list-clients", "-F", "#{client_session}\t#{client_width}"], { encoding: "utf8" });
|
|
1221
|
+
if (clients.status === 0 && clients.stdout) {
|
|
1222
|
+
for (const line of clients.stdout.split("\n")) {
|
|
1223
|
+
const [session, width] = line.split("\t");
|
|
1224
|
+
const value = Number(width);
|
|
1225
|
+
if (session && Number.isFinite(value) && value > 0) {
|
|
1226
|
+
widths.set(session, Math.max(widths.get(session) ?? 0, value));
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
const targets = [];
|
|
1231
|
+
for (const line of sessions.stdout.split("\n")) {
|
|
1232
|
+
if (!line)
|
|
1233
|
+
continue;
|
|
1234
|
+
const [name, marker, owner] = line.split("\t");
|
|
1235
|
+
if (!name || marker !== "v1" || !parseManagedSessionName(name))
|
|
1236
|
+
continue;
|
|
1237
|
+
const width = widths.get(name);
|
|
1238
|
+
targets.push({
|
|
1239
|
+
session: name,
|
|
1240
|
+
...(owner ? { ownerInstance: owner } : {}),
|
|
1241
|
+
...(width ? { clientWidth: width } : {}),
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
return targets;
|
|
1245
|
+
}
|
|
1125
1246
|
/** Install the composable 5-second status projection on one exact session. */
|
|
1126
1247
|
export function installH2aStatusSurface(session) {
|
|
1127
1248
|
if (!parseManagedSessionName(session))
|
|
1128
1249
|
return false;
|
|
1129
1250
|
if (!listLocalSessions().some((item) => item.name === session))
|
|
1130
1251
|
return false;
|
|
1131
|
-
|
|
1252
|
+
const installed = installH2aStatusSurfaceWithAccess(session, TMUX_STATUS_OPTION_ACCESS);
|
|
1253
|
+
if (installed)
|
|
1254
|
+
ensureStatusBarWriter();
|
|
1255
|
+
return installed;
|
|
1132
1256
|
}
|
|
1133
1257
|
/** Restore every user option captured on first install. */
|
|
1134
1258
|
export function uninstallH2aStatusSurface(session) {
|