@fro.bot/space-bus 0.10.0 → 0.11.0
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 +22 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +765 -8
- package/dist/config.js +10 -8
- package/dist/contract.js +0 -3
- package/dist/core.js +0 -10
- package/dist/discovery.d.ts +7 -0
- package/dist/format.js +0 -3
- package/dist/index.js +1333 -1419
- package/dist/launchd.d.ts +108 -0
- package/dist/mcp.js +1338 -1424
- package/dist/server.js +10 -8
- package/dist/service.d.ts +105 -0
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** `bot.fro.space-bus.<rosterKey>` — one label per roster identity (R7). */
|
|
2
|
+
export declare function serviceLabel(rosterPath: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* `<baseDir>/<label>.plist`. Defaults to `~/Library/LaunchAgents` when
|
|
5
|
+
* `baseDir` is omitted — tests MUST pass an injected temp directory so
|
|
6
|
+
* writes never land in the operator's real LaunchAgents folder.
|
|
7
|
+
*/
|
|
8
|
+
export declare function plistPath(label: string, baseDir?: string): string;
|
|
9
|
+
export interface RenderPlistOpts {
|
|
10
|
+
runtime: string;
|
|
11
|
+
cliEntry: string;
|
|
12
|
+
rosterPath: string;
|
|
13
|
+
stateDir: string;
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Absolute `PATH` to pin into the launched process's sparse launchd
|
|
17
|
+
* environment. launchd agents don't inherit the login shell's PATH, so
|
|
18
|
+
* without this a mise/asdf-shim-resolved `runtime`/`cliEntry` absolute
|
|
19
|
+
* path is fine, but any subprocess *it* shells out to (or a future
|
|
20
|
+
* change resolving a bare command name) would silently resolve
|
|
21
|
+
* differently than at install time. Optional — omitted entirely from
|
|
22
|
+
* the plist when not supplied, since not every caller can safely derive
|
|
23
|
+
* a sane absolute PATH (tests, callers targeting an older contract).
|
|
24
|
+
*/
|
|
25
|
+
path?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Absolute `XDG_STATE_HOME` to pin into the launched environment when
|
|
28
|
+
* the installer resolved `stateDir` using an `XDG_STATE_HOME` override.
|
|
29
|
+
* Without this, `stateDirFor` inside the launchd-launched process (which
|
|
30
|
+
* runs under launchd's own sparse env, NOT the installer's shell env)
|
|
31
|
+
* falls back to `~/.local/state`, diverging from the installer's view of
|
|
32
|
+
* `stateDir` — the exact split this option exists to prevent. Caller
|
|
33
|
+
* (installService) is responsible for validating this is absolute
|
|
34
|
+
* before passing it in.
|
|
35
|
+
*/
|
|
36
|
+
xdgStateHome?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Renders the launchd agent plist XML for a roster. Pins absolute
|
|
40
|
+
* ProgramArguments (`[runtime, cliEntry, "serve", "--foreground"]`),
|
|
41
|
+
* restarts only on abnormal exit (`KeepAlive.SuccessfulExit=false`,
|
|
42
|
+
* consuming the existing 0/1 exit contract — R6), throttles restarts
|
|
43
|
+
* (R8), and routes stdout/stderr into the roster's state dir (R10). The
|
|
44
|
+
* environment carries `SPACE_BUS_CONFIG` plus, when supplied, `PATH` and
|
|
45
|
+
* `XDG_STATE_HOME` — never credentials (R12). All interpolated strings
|
|
46
|
+
* are XML-escaped.
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderPlist(opts: RenderPlistOpts): string;
|
|
49
|
+
export type WriteResult = {
|
|
50
|
+
ok: true;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Writes the plist atomically: a temp file (0644, since launchd — not just
|
|
57
|
+
* the owner — must be able to read it) in the same directory as the
|
|
58
|
+
* target, then rename over it. Mirrors `writeDiscovery`'s temp+rename
|
|
59
|
+
* pattern; final mode is 0644 (owner read/write, group/world read-only —
|
|
60
|
+
* never writable, per R15).
|
|
61
|
+
*/
|
|
62
|
+
export declare function writePlistAtomic(path: string, content: string): WriteResult;
|
|
63
|
+
export type PlistSafety = {
|
|
64
|
+
safe: true;
|
|
65
|
+
} | {
|
|
66
|
+
safe: false;
|
|
67
|
+
reason: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Refuses a plist that isn't owned by the current user or is
|
|
71
|
+
* group/world-writable — a tampered plist must never become login-time
|
|
72
|
+
* code execution (R15).
|
|
73
|
+
*/
|
|
74
|
+
export declare function verifyPlistSafe(path: string): PlistSafety;
|
|
75
|
+
export interface ExecResult {
|
|
76
|
+
code: number;
|
|
77
|
+
stdout: string;
|
|
78
|
+
stderr: string;
|
|
79
|
+
}
|
|
80
|
+
export type ExecSeam = (args: string[]) => Promise<ExecResult>;
|
|
81
|
+
/** Default `ExecSeam`: spawns the real `launchctl` binary. Never rejects —
|
|
82
|
+
* a spawn error or a timeout both resolve a `{code:-1,...}` ExecResult with
|
|
83
|
+
* an actionable stderr, so callers' no-throw-across-the-boundary contract
|
|
84
|
+
* holds even when the exec primitive itself misbehaves. */
|
|
85
|
+
export declare const defaultLaunchctl: ExecSeam;
|
|
86
|
+
export declare function bootstrap(uid: number, plist: string, exec: ExecSeam): Promise<ExecResult>;
|
|
87
|
+
export declare function bootout(uid: number, label: string, exec: ExecSeam): Promise<ExecResult>;
|
|
88
|
+
export declare function kickstart(uid: number, label: string, exec: ExecSeam): Promise<ExecResult>;
|
|
89
|
+
export type PrintJobResult = {
|
|
90
|
+
ok: true;
|
|
91
|
+
loaded: boolean;
|
|
92
|
+
pid?: number;
|
|
93
|
+
} | {
|
|
94
|
+
ok: false;
|
|
95
|
+
error: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Probes a launchd job by label. A zero exit is authoritative "loaded";
|
|
99
|
+
* a permissive `pid = (\d+)` match against stdout is best-effort only —
|
|
100
|
+
* an unparsable but zero-exit response is still `loaded: true` with
|
|
101
|
+
* `pid: undefined`, since `print`'s exact line format drifts across macOS
|
|
102
|
+
* versions. A non-zero exit is `loaded: false` ONLY when launchd's own
|
|
103
|
+
* "job not found" wording is present in the combined output; any other
|
|
104
|
+
* non-zero exit (permission denied, IO error, our own timeout/spawn-error
|
|
105
|
+
* synthetic result) is reported as `ok:false` so callers can fail honestly
|
|
106
|
+
* instead of silently treating a probe failure as "not loaded".
|
|
107
|
+
*/
|
|
108
|
+
export declare function printJob(uid: number, label: string, exec: ExecSeam): Promise<PrintJobResult>;
|