@todoforai/edge 0.12.15 → 0.12.17
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/index.js +26 -9
- 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" ? ["
|
|
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,14 +49218,26 @@ function findFileRecursive(dir, names) {
|
|
|
49218
49218
|
return null;
|
|
49219
49219
|
}
|
|
49220
49220
|
function installWithNpm(name, pkg) {
|
|
49221
|
-
const
|
|
49221
|
+
const TIMEOUT_MS = 120000;
|
|
49222
49222
|
log2("info", `Installing ${name} via npm (${pkg})`);
|
|
49223
|
-
const result = spawnSync(npm, ["install", "--prefix", TOOLS_DIR, pkg], {
|
|
49223
|
+
const result = spawnSync("npm", ["install", "--prefix", TOOLS_DIR, pkg], {
|
|
49224
49224
|
stdio: "pipe",
|
|
49225
|
-
timeout:
|
|
49225
|
+
timeout: TIMEOUT_MS,
|
|
49226
|
+
shell: true
|
|
49226
49227
|
});
|
|
49228
|
+
const stderr = result.stderr?.toString().trim() || "";
|
|
49229
|
+
const stdout = result.stdout?.toString().trim() || "";
|
|
49230
|
+
if (result.error) {
|
|
49231
|
+
throw new Error(`npm install failed: ${result.error.message} | stderr: ${stderr || "(empty)"} | stdout: ${stdout || "(empty)"}`);
|
|
49232
|
+
}
|
|
49233
|
+
if (result.signal) {
|
|
49234
|
+
throw new Error(`npm install killed by ${result.signal}${result.signal === "SIGTERM" ? ` (likely timed out after ${TIMEOUT_MS / 1000}s)` : ""} | stderr: ${stderr || "(empty)"}`);
|
|
49235
|
+
}
|
|
49236
|
+
if (result.status === null) {
|
|
49237
|
+
throw new Error(`npm install: null exit code (likely timed out after ${TIMEOUT_MS / 1000}s on Windows, signal not propagated through cmd.exe) | stderr: ${stderr || "(empty)"} | stdout: ${stdout || "(empty)"}`);
|
|
49238
|
+
}
|
|
49227
49239
|
if (result.status !== 0) {
|
|
49228
|
-
throw new Error(`npm install failed
|
|
49240
|
+
throw new Error(`npm install failed (exit ${result.status}) | stderr: ${stderr || "(empty)"} | stdout: ${stdout || "(empty)"}`);
|
|
49229
49241
|
}
|
|
49230
49242
|
}
|
|
49231
49243
|
function installWithPip(name, pkg) {
|
|
@@ -49282,7 +49294,9 @@ function installWithPip(name, pkg) {
|
|
|
49282
49294
|
log2("info", `Installing ${name} via pip (${pkg})`);
|
|
49283
49295
|
const args = useVenv ? ["-m", "pip", "install", pkg] : ["-m", "pip", "install", "--user", pkg];
|
|
49284
49296
|
const result = spawnSync(python, args, { stdio: "pipe", timeout: 120000 });
|
|
49285
|
-
if (result.
|
|
49297
|
+
if (result.signal) {
|
|
49298
|
+
log2("error", `Failed to install ${name}: killed by ${result.signal}${result.signal === "SIGTERM" ? " (likely timed out after 120s)" : ""}`);
|
|
49299
|
+
} else if (result.status !== 0) {
|
|
49286
49300
|
log2("error", `Failed to install ${name}: ${result.stderr?.toString() || result.stdout?.toString()}`);
|
|
49287
49301
|
}
|
|
49288
49302
|
}
|
|
@@ -49334,8 +49348,7 @@ function uninstallTool(name) {
|
|
|
49334
49348
|
fs3.unlinkSync(p);
|
|
49335
49349
|
}
|
|
49336
49350
|
} else if (installerType === "npm") {
|
|
49337
|
-
|
|
49338
|
-
spawnSync(npm, ["uninstall", "--prefix", TOOLS_DIR, pkg], { stdio: "pipe", timeout: 30000 });
|
|
49351
|
+
spawnSync("npm", ["uninstall", "--prefix", TOOLS_DIR, pkg], { stdio: "pipe", timeout: 30000, shell: true });
|
|
49339
49352
|
} else if (installerType === "pip") {
|
|
49340
49353
|
const venvPython = os3.platform() === "win32" ? path3.join(TOOLS_DIR, "venv", "Scripts", "python.exe") : path3.join(TOOLS_DIR, "venv", "bin", "python");
|
|
49341
49354
|
const python = fs3.existsSync(venvPython) ? venvPython : "python3";
|
|
@@ -52303,6 +52316,10 @@ class TODOforAIEdge {
|
|
|
52303
52316
|
console.log(`[info] WebSocket closed code=${code} clean=${clean} reason=${reasonText}`);
|
|
52304
52317
|
if (code === 4001) {
|
|
52305
52318
|
console.log(`\x1B[33m[info] ${reasonText}. Not reconnecting.\x1B[0m`);
|
|
52319
|
+
console.log(`\x1B[33m[info] To replace the existing connection, restart with: todoforai-edge --kill\x1B[0m`);
|
|
52320
|
+
reject(new ServerError(reasonText));
|
|
52321
|
+
} else if (code === 4002) {
|
|
52322
|
+
console.log(`\x1B[33m[info] ${reasonText}. This instance was replaced by a new connection.\x1B[0m`);
|
|
52306
52323
|
reject(new ServerError(reasonText));
|
|
52307
52324
|
} else {
|
|
52308
52325
|
resolve();
|
|
@@ -52473,7 +52490,7 @@ async function main() {
|
|
|
52473
52490
|
await edge.ensureApiKey(true);
|
|
52474
52491
|
const lp2 = lockPath(config.apiUrl, edge.userId);
|
|
52475
52492
|
if (!acquireLock(lp2, config.kill)) {
|
|
52476
|
-
console.error(
|
|
52493
|
+
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
52494
|
process.exit(1);
|
|
52478
52495
|
}
|
|
52479
52496
|
let cleaned = false;
|