@fro.bot/space-bus 0.5.0 → 0.6.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 +38 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +961 -0
- package/dist/config.d.ts +34 -1
- package/dist/config.js +425 -17
- package/dist/contract.d.ts +1 -0
- package/dist/contract.js +8 -1
- package/dist/core.js +7 -2
- package/dist/discovery.d.ts +126 -0
- package/dist/index.js +803 -151
- package/dist/mcp.js +825 -166
- package/dist/server.d.ts +65 -0
- package/dist/server.js +816 -0
- package/dist/tools/shared.d.ts +2 -0
- package/package.json +8 -3
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface EnsureServerOptions {
|
|
2
|
+
/** Bounds the readiness probe loop after spawning. Default 15s. */
|
|
3
|
+
readinessBudgetMs?: number;
|
|
4
|
+
/** Bounds how long a lock waiter polls for the winner's discovery file. Default 15s. */
|
|
5
|
+
lockWaitBudgetMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ServerHandle {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
credentials: {
|
|
10
|
+
username?: string;
|
|
11
|
+
password?: string;
|
|
12
|
+
};
|
|
13
|
+
pid: number;
|
|
14
|
+
port: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ServerStatus {
|
|
17
|
+
running: boolean;
|
|
18
|
+
port?: number;
|
|
19
|
+
pid?: number;
|
|
20
|
+
configDrift?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Redacts the raw password AND the exact base64 Basic-auth token payload
|
|
24
|
+
* from a log tail. The readiness probe sends
|
|
25
|
+
* `Authorization: Basic base64("opencode:"+password)`; if the child
|
|
26
|
+
* happens to log request headers, the raw-password redaction alone would
|
|
27
|
+
* miss the still-sensitive base64 encoding of it. Redaction here is a
|
|
28
|
+
* backup — the primary guarantee is that we never log the password
|
|
29
|
+
* ourselves.
|
|
30
|
+
*/
|
|
31
|
+
export declare function redactSensitive(tail: string, password: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Attach-only: reads discovery, verifies the recorded pid is alive with a
|
|
34
|
+
* matching identity, and that the discovered baseUrl passes the loopback
|
|
35
|
+
* guard. Never spawns. Delegates to discovery.ts's pure read-path (also
|
|
36
|
+
* used directly by config.ts's managed loadContext, to avoid a
|
|
37
|
+
* config->server->config cycle since server.ts imports config.ts already).
|
|
38
|
+
*/
|
|
39
|
+
export declare function attachServer(rosterPath: string): ServerHandle | null;
|
|
40
|
+
/**
|
|
41
|
+
* Ensures a managed server is running for the roster and returns a handle
|
|
42
|
+
* to it. Fast-paths to an existing live discovery; otherwise races for the
|
|
43
|
+
* spawn lock — the winner spawns, losers poll for the discovery file until
|
|
44
|
+
* `LOCK_WAIT_BUDGET_MS`. Never steals a live owner's lock. Throws on
|
|
45
|
+
* externally-managed rosters (nothing to ensure).
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureServer(rosterPath: string, options?: EnsureServerOptions): Promise<ServerHandle>;
|
|
48
|
+
/**
|
|
49
|
+
* Reports whether a managed server is currently live for the roster, plus
|
|
50
|
+
* whether the roster's `managed` config has drifted from the spawnConfig
|
|
51
|
+
* recorded at spawn time (R5b) — surfaced, not auto-corrected.
|
|
52
|
+
*/
|
|
53
|
+
export declare function serverStatus(rosterPath: string): ServerStatus;
|
|
54
|
+
/**
|
|
55
|
+
* Stops a managed server: identity-verified SIGTERM, then polls for actual
|
|
56
|
+
* death (bounded by STOP_GRACE_MS) before escalating to SIGKILL and polling
|
|
57
|
+
* again. The discovery file is removed ONLY once the process is confirmed
|
|
58
|
+
* dead (or was never verified-live/already gone) — a process that ignores
|
|
59
|
+
* both signals is reported as not stopped and the discovery file is left in
|
|
60
|
+
* place, so credentials aren't silently discarded while the server still
|
|
61
|
+
* holds the port. OS-authz only (R7b) — no additional permission model.
|
|
62
|
+
*/
|
|
63
|
+
export declare function stopServer(rosterPath: string): Promise<{
|
|
64
|
+
stopped: boolean;
|
|
65
|
+
}>;
|