@todoforai/edge 0.12.15 → 0.12.16

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/index.js +19 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -49110,7 +49110,7 @@ function buildEnvWithTools() {
49110
49110
  }
49111
49111
  function whichWithTools(name) {
49112
49112
  const dirs = [...toolPathEntries(), ...(process.env.PATH || "").split(path3.delimiter)];
49113
- const exts = os3.platform() === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
49113
+ const exts = os3.platform() === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
49114
49114
  for (const dir of dirs) {
49115
49115
  for (const ext of exts) {
49116
49116
  const full = path3.join(dir, name + ext);
@@ -49218,12 +49218,18 @@ function findFileRecursive(dir, names) {
49218
49218
  return null;
49219
49219
  }
49220
49220
  function installWithNpm(name, pkg) {
49221
- const npm = whichWithTools("npm") || "npm";
49222
49221
  log2("info", `Installing ${name} via npm (${pkg})`);
49223
- const result = spawnSync(npm, ["install", "--prefix", TOOLS_DIR, pkg], {
49222
+ const result = spawnSync("npm", ["install", "--prefix", TOOLS_DIR, pkg], {
49224
49223
  stdio: "pipe",
49225
- timeout: 120000
49224
+ timeout: 120000,
49225
+ shell: true
49226
49226
  });
49227
+ if (result.error) {
49228
+ throw new Error(`npm install failed: ${result.error.message}`);
49229
+ }
49230
+ if (result.signal) {
49231
+ throw new Error(`npm install killed by ${result.signal}${result.signal === "SIGTERM" ? " (likely timed out after 120s)" : ""}`);
49232
+ }
49227
49233
  if (result.status !== 0) {
49228
49234
  throw new Error(`npm install failed: ${result.stderr?.toString() || result.stdout?.toString() || `exit code ${result.status}`}`);
49229
49235
  }
@@ -49282,7 +49288,9 @@ function installWithPip(name, pkg) {
49282
49288
  log2("info", `Installing ${name} via pip (${pkg})`);
49283
49289
  const args = useVenv ? ["-m", "pip", "install", pkg] : ["-m", "pip", "install", "--user", pkg];
49284
49290
  const result = spawnSync(python, args, { stdio: "pipe", timeout: 120000 });
49285
- if (result.status !== 0) {
49291
+ if (result.signal) {
49292
+ log2("error", `Failed to install ${name}: killed by ${result.signal}${result.signal === "SIGTERM" ? " (likely timed out after 120s)" : ""}`);
49293
+ } else if (result.status !== 0) {
49286
49294
  log2("error", `Failed to install ${name}: ${result.stderr?.toString() || result.stdout?.toString()}`);
49287
49295
  }
49288
49296
  }
@@ -49334,8 +49342,7 @@ function uninstallTool(name) {
49334
49342
  fs3.unlinkSync(p);
49335
49343
  }
49336
49344
  } else if (installerType === "npm") {
49337
- const npm = whichWithTools("npm") || "npm";
49338
- spawnSync(npm, ["uninstall", "--prefix", TOOLS_DIR, pkg], { stdio: "pipe", timeout: 30000 });
49345
+ spawnSync("npm", ["uninstall", "--prefix", TOOLS_DIR, pkg], { stdio: "pipe", timeout: 30000, shell: true });
49339
49346
  } else if (installerType === "pip") {
49340
49347
  const venvPython = os3.platform() === "win32" ? path3.join(TOOLS_DIR, "venv", "Scripts", "python.exe") : path3.join(TOOLS_DIR, "venv", "bin", "python");
49341
49348
  const python = fs3.existsSync(venvPython) ? venvPython : "python3";
@@ -52303,6 +52310,10 @@ class TODOforAIEdge {
52303
52310
  console.log(`[info] WebSocket closed code=${code} clean=${clean} reason=${reasonText}`);
52304
52311
  if (code === 4001) {
52305
52312
  console.log(`\x1B[33m[info] ${reasonText}. Not reconnecting.\x1B[0m`);
52313
+ console.log(`\x1B[33m[info] To replace the existing connection, restart with: todoforai-edge --kill\x1B[0m`);
52314
+ reject(new ServerError(reasonText));
52315
+ } else if (code === 4002) {
52316
+ console.log(`\x1B[33m[info] ${reasonText}. This instance was replaced by a new connection.\x1B[0m`);
52306
52317
  reject(new ServerError(reasonText));
52307
52318
  } else {
52308
52319
  resolve();
@@ -52473,7 +52484,7 @@ async function main() {
52473
52484
  await edge.ensureApiKey(true);
52474
52485
  const lp2 = lockPath(config.apiUrl, edge.userId);
52475
52486
  if (!acquireLock(lp2, config.kill)) {
52476
- console.error("\x1B[31mAnother edge is already running for this user+server. Use --kill to replace it.\x1B[0m");
52487
+ console.error(`\x1B[31mAnother edge is already running for this user+server. Use --kill to replace it, or delete the lock file: ${lp2}\x1B[0m`);
52477
52488
  process.exit(1);
52478
52489
  }
52479
52490
  let cleaned = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/edge",
3
- "version": "0.12.15",
3
+ "version": "0.12.16",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "todoforai-edge": "dist/index.js"