@todoforai/edge 0.12.13 → 0.12.14
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 +56 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50906,8 +50906,10 @@ async function readFileContent(filePath, rootPath, fallbackRootPaths) {
|
|
|
50906
50906
|
import os5 from "os";
|
|
50907
50907
|
import fs8 from "fs";
|
|
50908
50908
|
import path5 from "path";
|
|
50909
|
+
import { spawn as nodeSpawn } from "child_process";
|
|
50909
50910
|
var IS_WIN = os5.platform() === "win32";
|
|
50910
|
-
var
|
|
50911
|
+
var HAS_BUN = typeof globalThis.Bun !== "undefined";
|
|
50912
|
+
var HAS_BUN_TERMINAL = HAS_BUN && typeof Bun.Terminal === "function";
|
|
50911
50913
|
function whichSync(name) {
|
|
50912
50914
|
const dirs = (process.env.PATH || "").split(path5.delimiter);
|
|
50913
50915
|
const exts = IS_WIN ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
@@ -51011,6 +51013,13 @@ ${this.lastPart}`;
|
|
|
51011
51013
|
}
|
|
51012
51014
|
const all = current ? [...this.savedSegments, current] : [...this.savedSegments];
|
|
51013
51015
|
return all.join(`
|
|
51016
|
+
`);
|
|
51017
|
+
}
|
|
51018
|
+
getRawIfComplete() {
|
|
51019
|
+
if (this.truncated)
|
|
51020
|
+
return null;
|
|
51021
|
+
const all = this.firstPart ? [...this.savedSegments, this.firstPart] : [...this.savedSegments];
|
|
51022
|
+
return all.join(`
|
|
51014
51023
|
`);
|
|
51015
51024
|
}
|
|
51016
51025
|
}
|
|
@@ -51134,29 +51143,51 @@ async function executeBlock(blockId, content, send, todoId, messageId, timeout,
|
|
|
51134
51143
|
});
|
|
51135
51144
|
};
|
|
51136
51145
|
const spawnWithPipes = () => {
|
|
51137
|
-
|
|
51138
|
-
|
|
51139
|
-
|
|
51140
|
-
|
|
51141
|
-
|
|
51142
|
-
|
|
51143
|
-
|
|
51144
|
-
|
|
51145
|
-
|
|
51146
|
-
|
|
51147
|
-
|
|
51148
|
-
|
|
51149
|
-
|
|
51150
|
-
|
|
51151
|
-
|
|
51152
|
-
await
|
|
51153
|
-
|
|
51154
|
-
|
|
51155
|
-
|
|
51156
|
-
|
|
51157
|
-
|
|
51158
|
-
|
|
51159
|
-
|
|
51146
|
+
if (HAS_BUN) {
|
|
51147
|
+
const proc = Bun.spawn([sc2.shell, ...sc2.args], {
|
|
51148
|
+
cwd,
|
|
51149
|
+
env,
|
|
51150
|
+
stdin: "pipe",
|
|
51151
|
+
stdout: "pipe",
|
|
51152
|
+
stderr: "pipe"
|
|
51153
|
+
});
|
|
51154
|
+
const handle = { proc, pid: proc.pid };
|
|
51155
|
+
processes.set(blockId, handle);
|
|
51156
|
+
const timer = startTimeout();
|
|
51157
|
+
const pipeStream = async (stream) => {
|
|
51158
|
+
if (!stream)
|
|
51159
|
+
return;
|
|
51160
|
+
const decoder = new TextDecoder;
|
|
51161
|
+
for await (const chunk of stream) {
|
|
51162
|
+
await onData(decoder.decode(chunk, { stream: true }));
|
|
51163
|
+
}
|
|
51164
|
+
};
|
|
51165
|
+
Promise.all([
|
|
51166
|
+
pipeStream(proc.stdout),
|
|
51167
|
+
pipeStream(proc.stderr),
|
|
51168
|
+
proc.exited
|
|
51169
|
+
]).then(([, , code]) => onExit(code ?? -1, timer)).catch(() => onExit(-1, timer));
|
|
51170
|
+
} else {
|
|
51171
|
+
const proc = nodeSpawn(sc2.shell, sc2.args, {
|
|
51172
|
+
cwd,
|
|
51173
|
+
env,
|
|
51174
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
51175
|
+
});
|
|
51176
|
+
const handle = { proc, pid: proc.pid ?? -1 };
|
|
51177
|
+
processes.set(blockId, handle);
|
|
51178
|
+
const timer = startTimeout();
|
|
51179
|
+
let exited = false;
|
|
51180
|
+
const exit = (code) => {
|
|
51181
|
+
if (!exited) {
|
|
51182
|
+
exited = true;
|
|
51183
|
+
onExit(code, timer);
|
|
51184
|
+
}
|
|
51185
|
+
};
|
|
51186
|
+
proc.stdout?.on("data", (chunk) => onData(chunk.toString()));
|
|
51187
|
+
proc.stderr?.on("data", (chunk) => onData(chunk.toString()));
|
|
51188
|
+
proc.on("close", (code) => exit(code ?? -1));
|
|
51189
|
+
proc.on("error", () => exit(-1));
|
|
51190
|
+
}
|
|
51160
51191
|
};
|
|
51161
51192
|
if (HAS_BUN_TERMINAL) {
|
|
51162
51193
|
try {
|
|
@@ -52355,7 +52386,7 @@ function killExistingEdge(lp2) {
|
|
|
52355
52386
|
} catch {
|
|
52356
52387
|
break;
|
|
52357
52388
|
}
|
|
52358
|
-
|
|
52389
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|
|
52359
52390
|
}
|
|
52360
52391
|
try {
|
|
52361
52392
|
process.kill(pid, "SIGKILL");
|