@abraca/mcp 2.49.0 → 2.51.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.
|
@@ -12967,6 +12967,7 @@ var HookBridge = class {
|
|
|
12967
12967
|
this.server = server;
|
|
12968
12968
|
this.httpServer = null;
|
|
12969
12969
|
this._port = null;
|
|
12970
|
+
this.portFileTimer = null;
|
|
12970
12971
|
this.portFilePath = process.env.ABRA_HOOK_PORT_FILE || path.join(os.homedir(), ".abracadabra-mcp-hook.port");
|
|
12971
12972
|
}
|
|
12972
12973
|
get port() {
|
|
@@ -12989,19 +12990,30 @@ var HookBridge = class {
|
|
|
12989
12990
|
}
|
|
12990
12991
|
this._port = addr.port;
|
|
12991
12992
|
this.httpServer = srv;
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
|
|
12996
|
-
}
|
|
12993
|
+
this.writePortFile();
|
|
12994
|
+
this.portFileTimer = setInterval(() => this.writePortFile(), 2e3);
|
|
12995
|
+
this.portFileTimer.unref?.();
|
|
12997
12996
|
console.error(`[hook-bridge] Listening on 127.0.0.1:${this._port}`);
|
|
12998
12997
|
console.error(`[hook-bridge] Port file: ${this.portFilePath}`);
|
|
12999
12998
|
resolve(this._port);
|
|
13000
12999
|
});
|
|
13001
13000
|
});
|
|
13002
13001
|
}
|
|
13002
|
+
/** Write the current listening port to the shared port file (best-effort). */
|
|
13003
|
+
writePortFile() {
|
|
13004
|
+
if (this._port == null) return;
|
|
13005
|
+
try {
|
|
13006
|
+
fs.writeFileSync(this.portFilePath, String(this._port), "utf-8");
|
|
13007
|
+
} catch (err) {
|
|
13008
|
+
console.error(`[hook-bridge] Warning: could not write port file: ${err.message}`);
|
|
13009
|
+
}
|
|
13010
|
+
}
|
|
13003
13011
|
/** Shut down the HTTP server and remove the port file. */
|
|
13004
13012
|
async destroy() {
|
|
13013
|
+
if (this.portFileTimer) {
|
|
13014
|
+
clearInterval(this.portFileTimer);
|
|
13015
|
+
this.portFileTimer = null;
|
|
13016
|
+
}
|
|
13005
13017
|
if (this.httpServer) {
|
|
13006
13018
|
await new Promise((resolve) => {
|
|
13007
13019
|
this.httpServer.close(() => resolve());
|
|
@@ -13009,7 +13021,7 @@ var HookBridge = class {
|
|
|
13009
13021
|
this.httpServer = null;
|
|
13010
13022
|
}
|
|
13011
13023
|
try {
|
|
13012
|
-
fs.unlinkSync(this.portFilePath);
|
|
13024
|
+
if (fs.readFileSync(this.portFilePath, "utf-8").trim() === String(this._port)) fs.unlinkSync(this.portFilePath);
|
|
13013
13025
|
} catch {}
|
|
13014
13026
|
this._port = null;
|
|
13015
13027
|
console.error("[hook-bridge] Shut down");
|