@fro.bot/space-bus 0.8.0 → 0.8.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/cli.js +33 -0
- package/dist/index.js +33 -0
- package/dist/mcp.js +34 -1
- package/dist/server.d.ts +36 -0
- package/dist/server.js +34 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -565,6 +565,16 @@ function signalGroup(pid, sig) {
|
|
|
565
565
|
} catch {}
|
|
566
566
|
return false;
|
|
567
567
|
}
|
|
568
|
+
function signalGroupOnly(pid, sig) {
|
|
569
|
+
if (pid <= 1)
|
|
570
|
+
return false;
|
|
571
|
+
try {
|
|
572
|
+
process.kill(-pid, sig);
|
|
573
|
+
return true;
|
|
574
|
+
} catch {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
568
578
|
function killIdentifiedProcess(pid, identity) {
|
|
569
579
|
try {
|
|
570
580
|
if (identity !== null && identity !== undefined && identity !== "") {
|
|
@@ -821,6 +831,7 @@ async function stopServer(rosterPath) {
|
|
|
821
831
|
if (!discovery)
|
|
822
832
|
return { stopped: false };
|
|
823
833
|
if (!verifyIdentity(discovery.pid, discovery.identity)) {
|
|
834
|
+
await reapSurvivingGroup(discovery.pid);
|
|
824
835
|
removeDiscovery(rosterPath);
|
|
825
836
|
return { stopped: false };
|
|
826
837
|
}
|
|
@@ -855,6 +866,27 @@ async function stopServer(rosterPath) {
|
|
|
855
866
|
}
|
|
856
867
|
return { stopped: false };
|
|
857
868
|
}
|
|
869
|
+
async function reapSurvivingGroup(pid) {
|
|
870
|
+
try {
|
|
871
|
+
if (isAlive(pid))
|
|
872
|
+
return;
|
|
873
|
+
let groupAlive;
|
|
874
|
+
try {
|
|
875
|
+
process.kill(-pid, 0);
|
|
876
|
+
groupAlive = true;
|
|
877
|
+
} catch {
|
|
878
|
+
groupAlive = false;
|
|
879
|
+
}
|
|
880
|
+
if (!groupAlive)
|
|
881
|
+
return;
|
|
882
|
+
if (!signalGroupOnly(pid, "SIGTERM"))
|
|
883
|
+
return;
|
|
884
|
+
if (await waitForGroupDeath(pid, STOP_GRACE_MS))
|
|
885
|
+
return;
|
|
886
|
+
signalGroupOnly(pid, "SIGKILL");
|
|
887
|
+
await waitForGroupDeath(pid, STOP_GRACE_MS);
|
|
888
|
+
} catch {}
|
|
889
|
+
}
|
|
858
890
|
async function stopForHung(tick) {
|
|
859
891
|
try {
|
|
860
892
|
await tick.stop(tick.rosterPath);
|
|
@@ -864,6 +896,7 @@ async function stopForHung(tick) {
|
|
|
864
896
|
async function superviseTick(tick, state) {
|
|
865
897
|
const st = tick.status(tick.rosterPath);
|
|
866
898
|
if (!st.running) {
|
|
899
|
+
await reapSurvivingGroup(tick.handle.pid);
|
|
867
900
|
return { kind: "outcome", outcome: { reason: "died" } };
|
|
868
901
|
}
|
|
869
902
|
const probeOutcome = await tick.probe(tick.handle.baseUrl, tick.password);
|
package/dist/index.js
CHANGED
|
@@ -1149,6 +1149,16 @@ function signalGroup(pid, sig) {
|
|
|
1149
1149
|
} catch {}
|
|
1150
1150
|
return false;
|
|
1151
1151
|
}
|
|
1152
|
+
function signalGroupOnly(pid, sig) {
|
|
1153
|
+
if (pid <= 1)
|
|
1154
|
+
return false;
|
|
1155
|
+
try {
|
|
1156
|
+
process.kill(-pid, sig);
|
|
1157
|
+
return true;
|
|
1158
|
+
} catch {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1152
1162
|
function killIdentifiedProcess(pid, identity) {
|
|
1153
1163
|
try {
|
|
1154
1164
|
if (identity !== null && identity !== undefined && identity !== "") {
|
|
@@ -1405,6 +1415,7 @@ async function stopServer(rosterPath) {
|
|
|
1405
1415
|
if (!discovery)
|
|
1406
1416
|
return { stopped: false };
|
|
1407
1417
|
if (!verifyIdentity(discovery.pid, discovery.identity)) {
|
|
1418
|
+
await reapSurvivingGroup(discovery.pid);
|
|
1408
1419
|
removeDiscovery(rosterPath);
|
|
1409
1420
|
return { stopped: false };
|
|
1410
1421
|
}
|
|
@@ -1439,6 +1450,27 @@ async function stopServer(rosterPath) {
|
|
|
1439
1450
|
}
|
|
1440
1451
|
return { stopped: false };
|
|
1441
1452
|
}
|
|
1453
|
+
async function reapSurvivingGroup(pid) {
|
|
1454
|
+
try {
|
|
1455
|
+
if (isAlive(pid))
|
|
1456
|
+
return;
|
|
1457
|
+
let groupAlive;
|
|
1458
|
+
try {
|
|
1459
|
+
process.kill(-pid, 0);
|
|
1460
|
+
groupAlive = true;
|
|
1461
|
+
} catch {
|
|
1462
|
+
groupAlive = false;
|
|
1463
|
+
}
|
|
1464
|
+
if (!groupAlive)
|
|
1465
|
+
return;
|
|
1466
|
+
if (!signalGroupOnly(pid, "SIGTERM"))
|
|
1467
|
+
return;
|
|
1468
|
+
if (await waitForGroupDeath(pid, STOP_GRACE_MS))
|
|
1469
|
+
return;
|
|
1470
|
+
signalGroupOnly(pid, "SIGKILL");
|
|
1471
|
+
await waitForGroupDeath(pid, STOP_GRACE_MS);
|
|
1472
|
+
} catch {}
|
|
1473
|
+
}
|
|
1442
1474
|
async function stopForHung(tick) {
|
|
1443
1475
|
try {
|
|
1444
1476
|
await tick.stop(tick.rosterPath);
|
|
@@ -1448,6 +1480,7 @@ async function stopForHung(tick) {
|
|
|
1448
1480
|
async function superviseTick(tick, state) {
|
|
1449
1481
|
const st = tick.status(tick.rosterPath);
|
|
1450
1482
|
if (!st.running) {
|
|
1483
|
+
await reapSurvivingGroup(tick.handle.pid);
|
|
1451
1484
|
return { kind: "outcome", outcome: { reason: "died" } };
|
|
1452
1485
|
}
|
|
1453
1486
|
const probeOutcome = await tick.probe(tick.handle.baseUrl, tick.password);
|
package/dist/mcp.js
CHANGED
|
@@ -1150,6 +1150,16 @@ function signalGroup(pid, sig) {
|
|
|
1150
1150
|
} catch {}
|
|
1151
1151
|
return false;
|
|
1152
1152
|
}
|
|
1153
|
+
function signalGroupOnly(pid, sig) {
|
|
1154
|
+
if (pid <= 1)
|
|
1155
|
+
return false;
|
|
1156
|
+
try {
|
|
1157
|
+
process.kill(-pid, sig);
|
|
1158
|
+
return true;
|
|
1159
|
+
} catch {
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1153
1163
|
function killIdentifiedProcess(pid, identity) {
|
|
1154
1164
|
try {
|
|
1155
1165
|
if (identity !== null && identity !== undefined && identity !== "") {
|
|
@@ -1406,6 +1416,7 @@ async function stopServer(rosterPath) {
|
|
|
1406
1416
|
if (!discovery)
|
|
1407
1417
|
return { stopped: false };
|
|
1408
1418
|
if (!verifyIdentity(discovery.pid, discovery.identity)) {
|
|
1419
|
+
await reapSurvivingGroup(discovery.pid);
|
|
1409
1420
|
removeDiscovery(rosterPath);
|
|
1410
1421
|
return { stopped: false };
|
|
1411
1422
|
}
|
|
@@ -1440,6 +1451,27 @@ async function stopServer(rosterPath) {
|
|
|
1440
1451
|
}
|
|
1441
1452
|
return { stopped: false };
|
|
1442
1453
|
}
|
|
1454
|
+
async function reapSurvivingGroup(pid) {
|
|
1455
|
+
try {
|
|
1456
|
+
if (isAlive(pid))
|
|
1457
|
+
return;
|
|
1458
|
+
let groupAlive;
|
|
1459
|
+
try {
|
|
1460
|
+
process.kill(-pid, 0);
|
|
1461
|
+
groupAlive = true;
|
|
1462
|
+
} catch {
|
|
1463
|
+
groupAlive = false;
|
|
1464
|
+
}
|
|
1465
|
+
if (!groupAlive)
|
|
1466
|
+
return;
|
|
1467
|
+
if (!signalGroupOnly(pid, "SIGTERM"))
|
|
1468
|
+
return;
|
|
1469
|
+
if (await waitForGroupDeath(pid, STOP_GRACE_MS))
|
|
1470
|
+
return;
|
|
1471
|
+
signalGroupOnly(pid, "SIGKILL");
|
|
1472
|
+
await waitForGroupDeath(pid, STOP_GRACE_MS);
|
|
1473
|
+
} catch {}
|
|
1474
|
+
}
|
|
1443
1475
|
async function stopForHung(tick) {
|
|
1444
1476
|
try {
|
|
1445
1477
|
await tick.stop(tick.rosterPath);
|
|
@@ -1449,6 +1481,7 @@ async function stopForHung(tick) {
|
|
|
1449
1481
|
async function superviseTick(tick, state) {
|
|
1450
1482
|
const st = tick.status(tick.rosterPath);
|
|
1451
1483
|
if (!st.running) {
|
|
1484
|
+
await reapSurvivingGroup(tick.handle.pid);
|
|
1452
1485
|
return { kind: "outcome", outcome: { reason: "died" } };
|
|
1453
1486
|
}
|
|
1454
1487
|
const probeOutcome = await tick.probe(tick.handle.baseUrl, tick.password);
|
|
@@ -1664,7 +1697,7 @@ async function mcpLoadContext() {
|
|
|
1664
1697
|
}
|
|
1665
1698
|
return loadContext();
|
|
1666
1699
|
}
|
|
1667
|
-
var version = "0.8.
|
|
1700
|
+
var version = "0.8.1";
|
|
1668
1701
|
var server = new McpServer({
|
|
1669
1702
|
name: "space-bus",
|
|
1670
1703
|
version
|
package/dist/server.d.ts
CHANGED
|
@@ -69,6 +69,42 @@ export declare function serverStatus(rosterPath: string): ServerStatus;
|
|
|
69
69
|
export declare function stopServer(rosterPath: string): Promise<{
|
|
70
70
|
stopped: boolean;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Best-effort reap of a surviving process group whose leader has died —
|
|
74
|
+
* the died-path fix for the wrapper-only-death orphan (issue #49 Layer B
|
|
75
|
+
* follow-up). Guarded so it can NEVER signal a process that recycled the
|
|
76
|
+
* leader's pid:
|
|
77
|
+
*
|
|
78
|
+
* - If `pid` is still alive, do nothing. Either it's still our (running)
|
|
79
|
+
* wrapper — shouldn't happen on the died path — or it's an unrelated
|
|
80
|
+
* process that recycled the pid. Never signal a live leader here.
|
|
81
|
+
* - If `pid` is dead, check group liveness (`process.kill(-pid, 0)`). If
|
|
82
|
+
* the whole group is already gone (ESRCH), it's a clean crash — no-op.
|
|
83
|
+
* - If the leader is dead but the group still has live members, so this
|
|
84
|
+
* is, in practice, still our group (a live group's pgid is not reused
|
|
85
|
+
* while any member holds it — a strong practical guard, not an absolute
|
|
86
|
+
* proof: a narrow TOCTOU remains if the whole original group exits and
|
|
87
|
+
* the pgid is recycled between this check and the signal, the same
|
|
88
|
+
* residual race stopServer's verify→signal path carries): SIGTERM the
|
|
89
|
+
* group via `signalGroupOnly` (never falls back to a bare-pid signal —
|
|
90
|
+
* the recycled bare pid could be a stranger), wait a bounded grace,
|
|
91
|
+
* escalate to SIGKILL if members survive.
|
|
92
|
+
*
|
|
93
|
+
* Known limitation (zombie leader): the `isAlive(pid)` guard above is
|
|
94
|
+
* deliberately safe-biased — it errs toward NOT reaping. On Linux, a
|
|
95
|
+
* freshly-exited-but-unreaped ZOMBIE leader still passes `isAlive`
|
|
96
|
+
* (`kill(pid, 0)` succeeds for a zombie until reaped by its parent), so if
|
|
97
|
+
* the died path is ever reached while our wrapper is a zombie with a
|
|
98
|
+
* still-live child, the reap is skipped and the child leaks until a later
|
|
99
|
+
* tick observes the pid absent. This is a narrow race — normally the
|
|
100
|
+
* zombie's identity still matches, so `serverStatus` reports running and
|
|
101
|
+
* the died path isn't reached at all — accepted as a known limitation
|
|
102
|
+
* under the same-user trust boundary; tracked as a follow-up.
|
|
103
|
+
*
|
|
104
|
+
* Never throws — this runs on the fail-closed exit path and must not break
|
|
105
|
+
* it (mirrors the swallow style of `stopForHung`/`removeDiscoveryIfMatches`).
|
|
106
|
+
*/
|
|
107
|
+
export declare function reapSurvivingGroup(pid: number): Promise<void>;
|
|
72
108
|
export type SuperviseOutcome = {
|
|
73
109
|
reason: "signal";
|
|
74
110
|
} | {
|
package/dist/server.js
CHANGED
|
@@ -564,6 +564,16 @@ function signalGroup(pid, sig) {
|
|
|
564
564
|
} catch {}
|
|
565
565
|
return false;
|
|
566
566
|
}
|
|
567
|
+
function signalGroupOnly(pid, sig) {
|
|
568
|
+
if (pid <= 1)
|
|
569
|
+
return false;
|
|
570
|
+
try {
|
|
571
|
+
process.kill(-pid, sig);
|
|
572
|
+
return true;
|
|
573
|
+
} catch {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
567
577
|
function killIdentifiedProcess(pid, identity) {
|
|
568
578
|
try {
|
|
569
579
|
if (identity !== null && identity !== undefined && identity !== "") {
|
|
@@ -820,6 +830,7 @@ async function stopServer(rosterPath) {
|
|
|
820
830
|
if (!discovery)
|
|
821
831
|
return { stopped: false };
|
|
822
832
|
if (!verifyIdentity(discovery.pid, discovery.identity)) {
|
|
833
|
+
await reapSurvivingGroup(discovery.pid);
|
|
823
834
|
removeDiscovery(rosterPath);
|
|
824
835
|
return { stopped: false };
|
|
825
836
|
}
|
|
@@ -854,6 +865,27 @@ async function stopServer(rosterPath) {
|
|
|
854
865
|
}
|
|
855
866
|
return { stopped: false };
|
|
856
867
|
}
|
|
868
|
+
async function reapSurvivingGroup(pid) {
|
|
869
|
+
try {
|
|
870
|
+
if (isAlive(pid))
|
|
871
|
+
return;
|
|
872
|
+
let groupAlive;
|
|
873
|
+
try {
|
|
874
|
+
process.kill(-pid, 0);
|
|
875
|
+
groupAlive = true;
|
|
876
|
+
} catch {
|
|
877
|
+
groupAlive = false;
|
|
878
|
+
}
|
|
879
|
+
if (!groupAlive)
|
|
880
|
+
return;
|
|
881
|
+
if (!signalGroupOnly(pid, "SIGTERM"))
|
|
882
|
+
return;
|
|
883
|
+
if (await waitForGroupDeath(pid, STOP_GRACE_MS))
|
|
884
|
+
return;
|
|
885
|
+
signalGroupOnly(pid, "SIGKILL");
|
|
886
|
+
await waitForGroupDeath(pid, STOP_GRACE_MS);
|
|
887
|
+
} catch {}
|
|
888
|
+
}
|
|
857
889
|
async function stopForHung(tick) {
|
|
858
890
|
try {
|
|
859
891
|
await tick.stop(tick.rosterPath);
|
|
@@ -863,6 +895,7 @@ async function stopForHung(tick) {
|
|
|
863
895
|
async function superviseTick(tick, state) {
|
|
864
896
|
const st = tick.status(tick.rosterPath);
|
|
865
897
|
if (!st.running) {
|
|
898
|
+
await reapSurvivingGroup(tick.handle.pid);
|
|
866
899
|
return { kind: "outcome", outcome: { reason: "died" } };
|
|
867
900
|
}
|
|
868
901
|
const probeOutcome = await tick.probe(tick.handle.baseUrl, tick.password);
|
|
@@ -954,6 +987,7 @@ export {
|
|
|
954
987
|
stopServer,
|
|
955
988
|
serverStatus,
|
|
956
989
|
redactSensitive,
|
|
990
|
+
reapSurvivingGroup,
|
|
957
991
|
probe,
|
|
958
992
|
ensureServer,
|
|
959
993
|
attachServer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fro.bot/space-bus",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Space Bus — workspace agent bus for OpenCode. One control agent tasking per-project agents over the OpenCode server API, with an MCP facade for Claude Desktop.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|