@raysonmeng/agentbridge 0.1.9 → 0.1.11
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/.claude-plugin/marketplace.json +1 -1
- package/README.md +5 -3
- package/dist/cli.js +410 -236
- package/dist/daemon.js +41 -32
- package/package.json +1 -1
- package/plugins/agentbridge/.claude-plugin/plugin.json +1 -1
- package/plugins/agentbridge/server/bridge-server.js +41 -32
- package/plugins/agentbridge/server/daemon.js +41 -32
package/dist/daemon.js
CHANGED
|
@@ -17,8 +17,8 @@ function defineNumber(value, fallback) {
|
|
|
17
17
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
18
18
|
}
|
|
19
19
|
var BUILD_INFO = Object.freeze({
|
|
20
|
-
version: defineString("0.1.
|
|
21
|
-
commit: defineString("
|
|
20
|
+
version: defineString("0.1.11", "0.0.0-source"),
|
|
21
|
+
commit: defineString("48eb0ed", "source"),
|
|
22
22
|
bundle: defineBundle("dist"),
|
|
23
23
|
contractVersion: defineNumber(1, CONTRACT_VERSION)
|
|
24
24
|
});
|
|
@@ -2225,7 +2225,7 @@ class TuiConnectionState {
|
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
2227
|
// src/daemon-lifecycle.ts
|
|
2228
|
-
import { spawn as spawn2
|
|
2228
|
+
import { spawn as spawn2 } from "child_process";
|
|
2229
2229
|
import { existsSync as existsSync3, readFileSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync, openSync, closeSync, constants } from "fs";
|
|
2230
2230
|
import { fileURLToPath } from "url";
|
|
2231
2231
|
|
|
@@ -2242,6 +2242,41 @@ function parsePositiveIntEnv(name, fallback, log = () => {}, env = process.env)
|
|
|
2242
2242
|
return parsed;
|
|
2243
2243
|
}
|
|
2244
2244
|
|
|
2245
|
+
// src/process-lifecycle.ts
|
|
2246
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
2247
|
+
function commandForPid(pid) {
|
|
2248
|
+
try {
|
|
2249
|
+
return execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2250
|
+
} catch {
|
|
2251
|
+
return null;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function pidLooksAlive(pid) {
|
|
2255
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
2256
|
+
return false;
|
|
2257
|
+
try {
|
|
2258
|
+
process.kill(pid, 0);
|
|
2259
|
+
return true;
|
|
2260
|
+
} catch (err) {
|
|
2261
|
+
return err?.code === "EPERM";
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
var isProcessAlive = pidLooksAlive;
|
|
2265
|
+
function isAgentBridgeDaemon(pid, lookup = commandForPid) {
|
|
2266
|
+
const cmd = lookup(pid);
|
|
2267
|
+
if (cmd === null)
|
|
2268
|
+
return false;
|
|
2269
|
+
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
2270
|
+
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2271
|
+
return hasDaemonEntry && hasAgentbridge;
|
|
2272
|
+
}
|
|
2273
|
+
function isAgentBridgeProcess(pid, lookup = commandForPid) {
|
|
2274
|
+
const cmd = lookup(pid);
|
|
2275
|
+
if (cmd === null)
|
|
2276
|
+
return false;
|
|
2277
|
+
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2245
2280
|
// src/daemon-lifecycle.ts
|
|
2246
2281
|
var DEFAULT_DAEMON_ENTRY = import.meta.url.endsWith(".ts") ? "./daemon.ts" : "./daemon.js";
|
|
2247
2282
|
var DAEMON_ENTRY = process.env.AGENTBRIDGE_DAEMON_ENTRY || DEFAULT_DAEMON_ENTRY;
|
|
@@ -2341,7 +2376,7 @@ class DaemonLifecycle {
|
|
|
2341
2376
|
const existingPid = this.readPid();
|
|
2342
2377
|
if (existingPid) {
|
|
2343
2378
|
if (isProcessAlive(existingPid)) {
|
|
2344
|
-
if (
|
|
2379
|
+
if (isAgentBridgeDaemon(existingPid)) {
|
|
2345
2380
|
try {
|
|
2346
2381
|
await this.waitForReady(REUSE_READY_RETRIES, REUSE_READY_DELAY_MS);
|
|
2347
2382
|
return;
|
|
@@ -2552,7 +2587,7 @@ class DaemonLifecycle {
|
|
|
2552
2587
|
this.releaseLock();
|
|
2553
2588
|
return this.acquireLockStrict(true);
|
|
2554
2589
|
}
|
|
2555
|
-
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !
|
|
2590
|
+
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !isAgentBridgeProcess(holderPid)) {
|
|
2556
2591
|
this.log(`Startup lock is ${Math.round(this.lockAgeMs() / 1000)}s old and holder pid ${holderPid} ` + `is an unrelated process (pid recycled), reclaiming`);
|
|
2557
2592
|
this.releaseLock();
|
|
2558
2593
|
return this.acquireLockStrict(true);
|
|
@@ -2573,14 +2608,6 @@ class DaemonLifecycle {
|
|
|
2573
2608
|
return 0;
|
|
2574
2609
|
}
|
|
2575
2610
|
}
|
|
2576
|
-
isAgentBridgeProcess(pid) {
|
|
2577
|
-
try {
|
|
2578
|
-
const cmd = execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2579
|
-
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2580
|
-
} catch {
|
|
2581
|
-
return false;
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
2611
|
releaseLock() {
|
|
2585
2612
|
try {
|
|
2586
2613
|
unlinkSync2(this.stateDir.lockFile);
|
|
@@ -2598,7 +2625,7 @@ class DaemonLifecycle {
|
|
|
2598
2625
|
this.cleanup();
|
|
2599
2626
|
return false;
|
|
2600
2627
|
}
|
|
2601
|
-
if (!
|
|
2628
|
+
if (!isAgentBridgeDaemon(pid)) {
|
|
2602
2629
|
this.log(`Pid ${pid} is alive but is NOT an AgentBridge daemon \u2014 refusing to kill. Cleaning up stale pid file.`);
|
|
2603
2630
|
this.cleanup();
|
|
2604
2631
|
return false;
|
|
@@ -2626,16 +2653,6 @@ class DaemonLifecycle {
|
|
|
2626
2653
|
this.cleanup();
|
|
2627
2654
|
return true;
|
|
2628
2655
|
}
|
|
2629
|
-
isDaemonProcess(pid) {
|
|
2630
|
-
try {
|
|
2631
|
-
const cmd = execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2632
|
-
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
2633
|
-
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2634
|
-
return hasDaemonEntry && hasAgentbridge;
|
|
2635
|
-
} catch {
|
|
2636
|
-
return false;
|
|
2637
|
-
}
|
|
2638
|
-
}
|
|
2639
2656
|
cleanup() {
|
|
2640
2657
|
this.removePidFile();
|
|
2641
2658
|
this.removeStatusFile();
|
|
@@ -2650,14 +2667,6 @@ async function fetchWithTimeout(url, timeoutMs = HEALTH_FETCH_TIMEOUT_MS) {
|
|
|
2650
2667
|
clearTimeout(timer);
|
|
2651
2668
|
}
|
|
2652
2669
|
}
|
|
2653
|
-
function isProcessAlive(pid) {
|
|
2654
|
-
try {
|
|
2655
|
-
process.kill(pid, 0);
|
|
2656
|
-
return true;
|
|
2657
|
-
} catch {
|
|
2658
|
-
return false;
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
2670
|
|
|
2662
2671
|
// src/config-service.ts
|
|
2663
2672
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync4 } from "fs";
|
package/package.json
CHANGED
|
@@ -14227,8 +14227,8 @@ function defineNumber(value, fallback) {
|
|
|
14227
14227
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
14228
14228
|
}
|
|
14229
14229
|
var BUILD_INFO = Object.freeze({
|
|
14230
|
-
version: defineString("0.1.
|
|
14231
|
-
commit: defineString("
|
|
14230
|
+
version: defineString("0.1.11", "0.0.0-source"),
|
|
14231
|
+
commit: defineString("48eb0ed", "source"),
|
|
14232
14232
|
bundle: defineBundle("plugin"),
|
|
14233
14233
|
contractVersion: defineNumber(1, CONTRACT_VERSION)
|
|
14234
14234
|
});
|
|
@@ -14485,7 +14485,7 @@ class DaemonClient extends EventEmitter2 {
|
|
|
14485
14485
|
}
|
|
14486
14486
|
|
|
14487
14487
|
// src/daemon-lifecycle.ts
|
|
14488
|
-
import { spawn
|
|
14488
|
+
import { spawn } from "child_process";
|
|
14489
14489
|
import { existsSync as existsSync3, readFileSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync, openSync, closeSync, constants } from "fs";
|
|
14490
14490
|
import { fileURLToPath } from "url";
|
|
14491
14491
|
|
|
@@ -14502,6 +14502,41 @@ function parsePositiveIntEnv(name, fallback, log = () => {}, env = process.env)
|
|
|
14502
14502
|
return parsed;
|
|
14503
14503
|
}
|
|
14504
14504
|
|
|
14505
|
+
// src/process-lifecycle.ts
|
|
14506
|
+
import { execFileSync } from "child_process";
|
|
14507
|
+
function commandForPid(pid) {
|
|
14508
|
+
try {
|
|
14509
|
+
return execFileSync("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
14510
|
+
} catch {
|
|
14511
|
+
return null;
|
|
14512
|
+
}
|
|
14513
|
+
}
|
|
14514
|
+
function pidLooksAlive(pid) {
|
|
14515
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
14516
|
+
return false;
|
|
14517
|
+
try {
|
|
14518
|
+
process.kill(pid, 0);
|
|
14519
|
+
return true;
|
|
14520
|
+
} catch (err) {
|
|
14521
|
+
return err?.code === "EPERM";
|
|
14522
|
+
}
|
|
14523
|
+
}
|
|
14524
|
+
var isProcessAlive = pidLooksAlive;
|
|
14525
|
+
function isAgentBridgeDaemon(pid, lookup = commandForPid) {
|
|
14526
|
+
const cmd = lookup(pid);
|
|
14527
|
+
if (cmd === null)
|
|
14528
|
+
return false;
|
|
14529
|
+
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
14530
|
+
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
14531
|
+
return hasDaemonEntry && hasAgentbridge;
|
|
14532
|
+
}
|
|
14533
|
+
function isAgentBridgeProcess(pid, lookup = commandForPid) {
|
|
14534
|
+
const cmd = lookup(pid);
|
|
14535
|
+
if (cmd === null)
|
|
14536
|
+
return false;
|
|
14537
|
+
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
14538
|
+
}
|
|
14539
|
+
|
|
14505
14540
|
// src/daemon-lifecycle.ts
|
|
14506
14541
|
var DEFAULT_DAEMON_ENTRY = import.meta.url.endsWith(".ts") ? "./daemon.ts" : "./daemon.js";
|
|
14507
14542
|
var DAEMON_ENTRY = process.env.AGENTBRIDGE_DAEMON_ENTRY || DEFAULT_DAEMON_ENTRY;
|
|
@@ -14601,7 +14636,7 @@ class DaemonLifecycle {
|
|
|
14601
14636
|
const existingPid = this.readPid();
|
|
14602
14637
|
if (existingPid) {
|
|
14603
14638
|
if (isProcessAlive(existingPid)) {
|
|
14604
|
-
if (
|
|
14639
|
+
if (isAgentBridgeDaemon(existingPid)) {
|
|
14605
14640
|
try {
|
|
14606
14641
|
await this.waitForReady(REUSE_READY_RETRIES, REUSE_READY_DELAY_MS);
|
|
14607
14642
|
return;
|
|
@@ -14812,7 +14847,7 @@ class DaemonLifecycle {
|
|
|
14812
14847
|
this.releaseLock();
|
|
14813
14848
|
return this.acquireLockStrict(true);
|
|
14814
14849
|
}
|
|
14815
|
-
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !
|
|
14850
|
+
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !isAgentBridgeProcess(holderPid)) {
|
|
14816
14851
|
this.log(`Startup lock is ${Math.round(this.lockAgeMs() / 1000)}s old and holder pid ${holderPid} ` + `is an unrelated process (pid recycled), reclaiming`);
|
|
14817
14852
|
this.releaseLock();
|
|
14818
14853
|
return this.acquireLockStrict(true);
|
|
@@ -14833,14 +14868,6 @@ class DaemonLifecycle {
|
|
|
14833
14868
|
return 0;
|
|
14834
14869
|
}
|
|
14835
14870
|
}
|
|
14836
|
-
isAgentBridgeProcess(pid) {
|
|
14837
|
-
try {
|
|
14838
|
-
const cmd = execFileSync("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
14839
|
-
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
14840
|
-
} catch {
|
|
14841
|
-
return false;
|
|
14842
|
-
}
|
|
14843
|
-
}
|
|
14844
14871
|
releaseLock() {
|
|
14845
14872
|
try {
|
|
14846
14873
|
unlinkSync2(this.stateDir.lockFile);
|
|
@@ -14858,7 +14885,7 @@ class DaemonLifecycle {
|
|
|
14858
14885
|
this.cleanup();
|
|
14859
14886
|
return false;
|
|
14860
14887
|
}
|
|
14861
|
-
if (!
|
|
14888
|
+
if (!isAgentBridgeDaemon(pid)) {
|
|
14862
14889
|
this.log(`Pid ${pid} is alive but is NOT an AgentBridge daemon \u2014 refusing to kill. Cleaning up stale pid file.`);
|
|
14863
14890
|
this.cleanup();
|
|
14864
14891
|
return false;
|
|
@@ -14886,16 +14913,6 @@ class DaemonLifecycle {
|
|
|
14886
14913
|
this.cleanup();
|
|
14887
14914
|
return true;
|
|
14888
14915
|
}
|
|
14889
|
-
isDaemonProcess(pid) {
|
|
14890
|
-
try {
|
|
14891
|
-
const cmd = execFileSync("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
14892
|
-
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
14893
|
-
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
14894
|
-
return hasDaemonEntry && hasAgentbridge;
|
|
14895
|
-
} catch {
|
|
14896
|
-
return false;
|
|
14897
|
-
}
|
|
14898
|
-
}
|
|
14899
14916
|
cleanup() {
|
|
14900
14917
|
this.removePidFile();
|
|
14901
14918
|
this.removeStatusFile();
|
|
@@ -14910,14 +14927,6 @@ async function fetchWithTimeout(url, timeoutMs = HEALTH_FETCH_TIMEOUT_MS) {
|
|
|
14910
14927
|
clearTimeout(timer);
|
|
14911
14928
|
}
|
|
14912
14929
|
}
|
|
14913
|
-
function isProcessAlive(pid) {
|
|
14914
|
-
try {
|
|
14915
|
-
process.kill(pid, 0);
|
|
14916
|
-
return true;
|
|
14917
|
-
} catch {
|
|
14918
|
-
return false;
|
|
14919
|
-
}
|
|
14920
|
-
}
|
|
14921
14930
|
|
|
14922
14931
|
// src/config-service.ts
|
|
14923
14932
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync4 } from "fs";
|
|
@@ -17,8 +17,8 @@ function defineNumber(value, fallback) {
|
|
|
17
17
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
18
18
|
}
|
|
19
19
|
var BUILD_INFO = Object.freeze({
|
|
20
|
-
version: defineString("0.1.
|
|
21
|
-
commit: defineString("
|
|
20
|
+
version: defineString("0.1.11", "0.0.0-source"),
|
|
21
|
+
commit: defineString("48eb0ed", "source"),
|
|
22
22
|
bundle: defineBundle("plugin"),
|
|
23
23
|
contractVersion: defineNumber(1, CONTRACT_VERSION)
|
|
24
24
|
});
|
|
@@ -2225,7 +2225,7 @@ class TuiConnectionState {
|
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
2227
|
// src/daemon-lifecycle.ts
|
|
2228
|
-
import { spawn as spawn2
|
|
2228
|
+
import { spawn as spawn2 } from "child_process";
|
|
2229
2229
|
import { existsSync as existsSync3, readFileSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync, openSync, closeSync, constants } from "fs";
|
|
2230
2230
|
import { fileURLToPath } from "url";
|
|
2231
2231
|
|
|
@@ -2242,6 +2242,41 @@ function parsePositiveIntEnv(name, fallback, log = () => {}, env = process.env)
|
|
|
2242
2242
|
return parsed;
|
|
2243
2243
|
}
|
|
2244
2244
|
|
|
2245
|
+
// src/process-lifecycle.ts
|
|
2246
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
2247
|
+
function commandForPid(pid) {
|
|
2248
|
+
try {
|
|
2249
|
+
return execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2250
|
+
} catch {
|
|
2251
|
+
return null;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function pidLooksAlive(pid) {
|
|
2255
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
2256
|
+
return false;
|
|
2257
|
+
try {
|
|
2258
|
+
process.kill(pid, 0);
|
|
2259
|
+
return true;
|
|
2260
|
+
} catch (err) {
|
|
2261
|
+
return err?.code === "EPERM";
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
var isProcessAlive = pidLooksAlive;
|
|
2265
|
+
function isAgentBridgeDaemon(pid, lookup = commandForPid) {
|
|
2266
|
+
const cmd = lookup(pid);
|
|
2267
|
+
if (cmd === null)
|
|
2268
|
+
return false;
|
|
2269
|
+
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
2270
|
+
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2271
|
+
return hasDaemonEntry && hasAgentbridge;
|
|
2272
|
+
}
|
|
2273
|
+
function isAgentBridgeProcess(pid, lookup = commandForPid) {
|
|
2274
|
+
const cmd = lookup(pid);
|
|
2275
|
+
if (cmd === null)
|
|
2276
|
+
return false;
|
|
2277
|
+
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2245
2280
|
// src/daemon-lifecycle.ts
|
|
2246
2281
|
var DEFAULT_DAEMON_ENTRY = import.meta.url.endsWith(".ts") ? "./daemon.ts" : "./daemon.js";
|
|
2247
2282
|
var DAEMON_ENTRY = process.env.AGENTBRIDGE_DAEMON_ENTRY || DEFAULT_DAEMON_ENTRY;
|
|
@@ -2341,7 +2376,7 @@ class DaemonLifecycle {
|
|
|
2341
2376
|
const existingPid = this.readPid();
|
|
2342
2377
|
if (existingPid) {
|
|
2343
2378
|
if (isProcessAlive(existingPid)) {
|
|
2344
|
-
if (
|
|
2379
|
+
if (isAgentBridgeDaemon(existingPid)) {
|
|
2345
2380
|
try {
|
|
2346
2381
|
await this.waitForReady(REUSE_READY_RETRIES, REUSE_READY_DELAY_MS);
|
|
2347
2382
|
return;
|
|
@@ -2552,7 +2587,7 @@ class DaemonLifecycle {
|
|
|
2552
2587
|
this.releaseLock();
|
|
2553
2588
|
return this.acquireLockStrict(true);
|
|
2554
2589
|
}
|
|
2555
|
-
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !
|
|
2590
|
+
if (Number.isFinite(holderPid) && this.lockAgeMs() > LOCK_IDENTITY_GRACE_MS && !isAgentBridgeProcess(holderPid)) {
|
|
2556
2591
|
this.log(`Startup lock is ${Math.round(this.lockAgeMs() / 1000)}s old and holder pid ${holderPid} ` + `is an unrelated process (pid recycled), reclaiming`);
|
|
2557
2592
|
this.releaseLock();
|
|
2558
2593
|
return this.acquireLockStrict(true);
|
|
@@ -2573,14 +2608,6 @@ class DaemonLifecycle {
|
|
|
2573
2608
|
return 0;
|
|
2574
2609
|
}
|
|
2575
2610
|
}
|
|
2576
|
-
isAgentBridgeProcess(pid) {
|
|
2577
|
-
try {
|
|
2578
|
-
const cmd = execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2579
|
-
return cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2580
|
-
} catch {
|
|
2581
|
-
return false;
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
2611
|
releaseLock() {
|
|
2585
2612
|
try {
|
|
2586
2613
|
unlinkSync2(this.stateDir.lockFile);
|
|
@@ -2598,7 +2625,7 @@ class DaemonLifecycle {
|
|
|
2598
2625
|
this.cleanup();
|
|
2599
2626
|
return false;
|
|
2600
2627
|
}
|
|
2601
|
-
if (!
|
|
2628
|
+
if (!isAgentBridgeDaemon(pid)) {
|
|
2602
2629
|
this.log(`Pid ${pid} is alive but is NOT an AgentBridge daemon \u2014 refusing to kill. Cleaning up stale pid file.`);
|
|
2603
2630
|
this.cleanup();
|
|
2604
2631
|
return false;
|
|
@@ -2626,16 +2653,6 @@ class DaemonLifecycle {
|
|
|
2626
2653
|
this.cleanup();
|
|
2627
2654
|
return true;
|
|
2628
2655
|
}
|
|
2629
|
-
isDaemonProcess(pid) {
|
|
2630
|
-
try {
|
|
2631
|
-
const cmd = execFileSync2("ps", ["-p", String(pid), "-o", "command="], { encoding: "utf-8" }).trim();
|
|
2632
|
-
const hasDaemonEntry = /(?:^|[\s/\\])[\w.-]*-?daemon\.(?:ts|js)(?:\s|$)/.test(cmd);
|
|
2633
|
-
const hasAgentbridge = cmd.includes("agentbridge") || cmd.includes("agent_bridge");
|
|
2634
|
-
return hasDaemonEntry && hasAgentbridge;
|
|
2635
|
-
} catch {
|
|
2636
|
-
return false;
|
|
2637
|
-
}
|
|
2638
|
-
}
|
|
2639
2656
|
cleanup() {
|
|
2640
2657
|
this.removePidFile();
|
|
2641
2658
|
this.removeStatusFile();
|
|
@@ -2650,14 +2667,6 @@ async function fetchWithTimeout(url, timeoutMs = HEALTH_FETCH_TIMEOUT_MS) {
|
|
|
2650
2667
|
clearTimeout(timer);
|
|
2651
2668
|
}
|
|
2652
2669
|
}
|
|
2653
|
-
function isProcessAlive(pid) {
|
|
2654
|
-
try {
|
|
2655
|
-
process.kill(pid, 0);
|
|
2656
|
-
return true;
|
|
2657
|
-
} catch {
|
|
2658
|
-
return false;
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
2670
|
|
|
2662
2671
|
// src/config-service.ts
|
|
2663
2672
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, existsSync as existsSync4 } from "fs";
|