kill-switch-mcp 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/dist/server.js +28 -25
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -150,7 +150,7 @@ class BotSDK {
150
150
  const status = await this.checkBotStatus();
151
151
  const shouldLaunch = this.shouldLaunchBrowser(status);
152
152
  if (shouldLaunch) {
153
- console.log(`[BotSDK] Launching browser...`);
153
+ console.error(`[BotSDK] Launching browser...`);
154
154
  this.browserLaunched = true;
155
155
  await this.launchBrowser();
156
156
  await this.waitForBotConnection();
@@ -212,7 +212,7 @@ class BotSDK {
212
212
  this.browserLaunched = false;
213
213
  }
214
214
  this.waitForReady(15000).then(() => {
215
- console.log("[BotSDK] Connected and game state ready");
215
+ console.error("[BotSDK] Connected and game state ready");
216
216
  resolve();
217
217
  }).catch((error) => {
218
218
  console.warn("[BotSDK] Connected but game state not ready:", error.message);
@@ -246,21 +246,21 @@ class BotSDK {
246
246
  }
247
247
  scheduleReconnect() {
248
248
  if (this.reconnectAttempt >= this.config.reconnectMaxRetries) {
249
- console.log(`[BotSDK] Max reconnection attempts (${this.config.reconnectMaxRetries}) reached, giving up`);
249
+ console.error(`[BotSDK] Max reconnection attempts (${this.config.reconnectMaxRetries}) reached, giving up`);
250
250
  this.setConnectionState("disconnected");
251
251
  return;
252
252
  }
253
253
  this.reconnectAttempt++;
254
254
  this.setConnectionState("reconnecting", this.reconnectAttempt);
255
255
  const delay = Math.min(this.config.reconnectBaseDelay * Math.pow(2, this.reconnectAttempt - 1), this.config.reconnectMaxDelay);
256
- console.log(`[BotSDK] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempt})`);
256
+ console.error(`[BotSDK] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempt})`);
257
257
  this.reconnectTimer = setTimeout(async () => {
258
258
  this.reconnectTimer = null;
259
259
  try {
260
260
  await this.connect();
261
- console.log(`[BotSDK] Reconnected successfully after ${this.reconnectAttempt} attempt(s)`);
261
+ console.error(`[BotSDK] Reconnected successfully after ${this.reconnectAttempt} attempt(s)`);
262
262
  } catch (e) {
263
- console.log(`[BotSDK] Reconnection attempt ${this.reconnectAttempt} failed`);
263
+ console.error(`[BotSDK] Reconnection attempt ${this.reconnectAttempt} failed`);
264
264
  }
265
265
  }, delay);
266
266
  }
@@ -304,17 +304,17 @@ class BotSDK {
304
304
  async checkBotStatus() {
305
305
  const statusUrl = this.getStatusUrl();
306
306
  try {
307
- console.log(`[BotSDK] Checking bot status via URL: ${statusUrl}`);
307
+ console.error(`[BotSDK] Checking bot status via URL: ${statusUrl}`);
308
308
  const response = await fetch(statusUrl);
309
309
  if (!response.ok) {
310
- console.log(`[BotSDK] Status check HTTP error: ${response.status} ${response.statusText} (URL: ${statusUrl})`);
310
+ console.error(`[BotSDK] Status check HTTP error: ${response.status} ${response.statusText} (URL: ${statusUrl})`);
311
311
  throw new Error(`Status check failed: ${response.status}`);
312
312
  }
313
313
  const data = await response.json();
314
314
  return data;
315
315
  } catch (error) {
316
316
  const errorMsg = error instanceof Error ? error.message : String(error);
317
- console.log(`[BotSDK] Status check failed: ${errorMsg} (URL: ${statusUrl})`);
317
+ console.error(`[BotSDK] Status check failed: ${errorMsg} (URL: ${statusUrl})`);
318
318
  return {
319
319
  status: "dead",
320
320
  inGame: false,
@@ -334,15 +334,15 @@ class BotSDK {
334
334
  return false;
335
335
  }
336
336
  if (status.status === "dead") {
337
- console.log(`[BotSDK] Bot not connected`);
337
+ console.error(`[BotSDK] Bot not connected`);
338
338
  return true;
339
339
  }
340
- console.log(`[BotSDK] Active client detected, skipping browser launch`);
340
+ console.error(`[BotSDK] Active client detected, skipping browser launch`);
341
341
  return false;
342
342
  }
343
343
  async launchBrowser() {
344
344
  const url = this.buildClientUrl();
345
- console.log(`[BotSDK] Opening browser: ${url}`);
345
+ console.error(`[BotSDK] Opening browser: ${url}`);
346
346
  const { exec } = await import("child_process");
347
347
  const command = process.platform === "darwin" ? `open "${url}"` : process.platform === "win32" ? `start "" "${url}"` : `xdg-open "${url}"`;
348
348
  return new Promise((resolve, reject) => {
@@ -360,14 +360,14 @@ class BotSDK {
360
360
  const startTime = Date.now();
361
361
  const pollInterval = 500;
362
362
  let attemptCount = 0;
363
- console.log(`[BotSDK] Waiting for bot to connect and load game (timeout: ${timeoutMs}ms)...`);
363
+ console.error(`[BotSDK] Waiting for bot to connect and load game (timeout: ${timeoutMs}ms)...`);
364
364
  while (Date.now() - startTime < timeoutMs) {
365
365
  attemptCount++;
366
366
  const elapsed = Date.now() - startTime;
367
367
  const status = await this.checkBotStatus();
368
- console.log(`[BotSDK] Poll attempt ${attemptCount} (${elapsed}ms): status="${status.status}", inGame=${status.inGame}, controllers=${status.controllers.length}, observers=${status.observers.length}`);
368
+ console.error(`[BotSDK] Poll attempt ${attemptCount} (${elapsed}ms): status="${status.status}", inGame=${status.inGame}, controllers=${status.controllers.length}, observers=${status.observers.length}`);
369
369
  if (status.status !== "dead" && status.inGame) {
370
- console.log(`[BotSDK] Bot connected and in-game!`);
370
+ console.error(`[BotSDK] Bot connected and in-game!`);
371
371
  return;
372
372
  }
373
373
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
@@ -402,7 +402,7 @@ class BotSDK {
402
402
  username: this.config.botUsername,
403
403
  password: this.config.password
404
404
  }));
405
- console.log(`[BotSDK] Sent login command for ${this.config.botUsername} through gateway`);
405
+ console.error(`[BotSDK] Sent login command for ${this.config.botUsername} through gateway`);
406
406
  }
407
407
  async waitForConnection(timeout = 60000) {
408
408
  if (this.isConnected()) {
@@ -573,7 +573,7 @@ class BotSDK {
573
573
  }
574
574
  async sendAction(action) {
575
575
  if (this.connectionState === "reconnecting") {
576
- console.log(`[BotSDK] Waiting for reconnection before sending action: ${action.type}`);
576
+ console.error(`[BotSDK] Waiting for reconnection before sending action: ${action.type}`);
577
577
  await this.waitForConnection();
578
578
  }
579
579
  if (!this.isConnected()) {
@@ -723,7 +723,7 @@ class BotSDK {
723
723
  }
724
724
  async sendScreenshot(timeout = 1e4) {
725
725
  if (this.connectionState === "reconnecting") {
726
- console.log(`[BotSDK] Waiting for reconnection before requesting screenshot`);
726
+ console.error(`[BotSDK] Waiting for reconnection before requesting screenshot`);
727
727
  await this.waitForConnection();
728
728
  }
729
729
  if (!this.isConnected()) {
@@ -765,22 +765,22 @@ class BotSDK {
765
765
  return this.findPath(destX, destZ, maxWaypoints);
766
766
  }
767
767
  async waitForReady(timeout = 15000) {
768
- console.log("[BotSDK] Waiting for game state to be ready...");
768
+ console.error("[BotSDK] Waiting for game state to be ready...");
769
769
  try {
770
770
  const state = await this.waitForCondition((s) => {
771
771
  const validPosition = !!(s.player && s.player.worldX !== 0 && s.player.worldZ !== 0);
772
772
  const inGame = s.inGame;
773
773
  const hasEntities = s.nearbyNpcs.length > 0 || s.nearbyLocs.length > 0 || s.groundItems.length > 0;
774
774
  if (!validPosition) {
775
- console.log(`[BotSDK] Waiting - invalid position: (${s.player?.worldX}, ${s.player?.worldZ})`);
775
+ console.error(`[BotSDK] Waiting - invalid position: (${s.player?.worldX}, ${s.player?.worldZ})`);
776
776
  } else if (!inGame) {
777
- console.log("[BotSDK] Waiting - not in game");
777
+ console.error("[BotSDK] Waiting - not in game");
778
778
  } else if (!hasEntities) {
779
- console.log("[BotSDK] Waiting - no entities loaded yet");
779
+ console.error("[BotSDK] Waiting - no entities loaded yet");
780
780
  }
781
781
  return inGame && validPosition && hasEntities;
782
782
  }, timeout);
783
- console.log("[BotSDK] Game state ready!");
783
+ console.error("[BotSDK] Game state ready!");
784
784
  return state;
785
785
  } catch (error) {
786
786
  console.error("[BotSDK] Timeout waiting for game state to be ready");
@@ -1721,7 +1721,7 @@ class BotActions {
1721
1721
  if (!blockedDoors.has(key)) {
1722
1722
  blockedDoors.add(key);
1723
1723
  blockDoor(level, nearest.x, nearest.z);
1724
- console.log(`[walkTo] Blocked impassable door at (${nearest.x}, ${nearest.z}) — re-routing`);
1724
+ console.error(`[walkTo] Blocked impassable door at (${nearest.x}, ${nearest.z}) — re-routing`);
1725
1725
  }
1726
1726
  }
1727
1727
  return false;
@@ -1761,7 +1761,7 @@ class BotActions {
1761
1761
  blockedDoors.add(doorKey);
1762
1762
  blockDoor(door.level, door.x, door.z);
1763
1763
  requiredDoorKeys.delete(doorKey);
1764
- console.log(`[walkTo] Blocked impassable door at (${door.x}, ${door.z}) — re-routing`);
1764
+ console.error(`[walkTo] Blocked impassable door at (${door.x}, ${door.z}) — re-routing`);
1765
1765
  break;
1766
1766
  }
1767
1767
  break;
@@ -5147,6 +5147,9 @@ function errorResponse(message) {
5147
5147
  isError: true
5148
5148
  };
5149
5149
  }
5150
+ process.on("unhandledRejection", (reason) => {
5151
+ console.error("[Kill Switch MCP] Unhandled rejection (suppressed):", reason instanceof Error ? reason.message : reason);
5152
+ });
5150
5153
  async function main() {
5151
5154
  console.error("[Kill Switch MCP] Starting Kill Switch MCP server v3.0...");
5152
5155
  console.error(`[Kill Switch MCP] Game server: ${SERVER_URL2}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kill-switch-mcp",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Kill Switch MCP Server — AI battle royale powered by Claude Code",
5
5
  "type": "module",
6
6
  "bin": {