@getpochi/cli 0.6.4 → 0.6.5
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/cli.js +54 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -493638,7 +493638,7 @@ class BrowserSessionStore {
|
|
|
493638
493638
|
// package.json
|
|
493639
493639
|
var package_default = {
|
|
493640
493640
|
name: "@getpochi/cli",
|
|
493641
|
-
version: "0.6.
|
|
493641
|
+
version: "0.6.5",
|
|
493642
493642
|
devDependencies: {
|
|
493643
493643
|
"@commander-js/extra-typings": "^14.0.0",
|
|
493644
493644
|
"@getpochi/common": "workspace:*",
|
|
@@ -545458,6 +545458,26 @@ import {
|
|
|
545458
545458
|
exec as exec9
|
|
545459
545459
|
} from "node:child_process";
|
|
545460
545460
|
import * as path36 from "node:path";
|
|
545461
|
+
class ExecuteCommandError extends Error {
|
|
545462
|
+
code;
|
|
545463
|
+
stdout;
|
|
545464
|
+
stderr;
|
|
545465
|
+
constructor({
|
|
545466
|
+
message,
|
|
545467
|
+
code: code4,
|
|
545468
|
+
stdout: stdout5,
|
|
545469
|
+
stderr: stderr7
|
|
545470
|
+
}) {
|
|
545471
|
+
super(message);
|
|
545472
|
+
this.name = "ExecuteCommandError";
|
|
545473
|
+
this.code = code4;
|
|
545474
|
+
this.stdout = stdout5;
|
|
545475
|
+
this.stderr = stderr7;
|
|
545476
|
+
}
|
|
545477
|
+
asOutput() {
|
|
545478
|
+
return processCommandOutput(this.stdout, this.stderr, this.message);
|
|
545479
|
+
}
|
|
545480
|
+
}
|
|
545461
545481
|
var executeCommand2 = () => async ({ command, cwd: cwd3 = ".", timeout: timeout5 = 120 }, { abortSignal, cwd: workspaceDir, envs }) => {
|
|
545462
545482
|
if (!command) {
|
|
545463
545483
|
throw new Error("Command is required to execute.");
|
|
@@ -545469,27 +545489,20 @@ var executeCommand2 = () => async ({ command, cwd: cwd3 = ".", timeout: timeout5
|
|
|
545469
545489
|
resolvedCwd = path36.normalize(path36.join(workspaceDir, cwd3));
|
|
545470
545490
|
}
|
|
545471
545491
|
try {
|
|
545472
|
-
const {
|
|
545473
|
-
code: code4,
|
|
545474
|
-
stdout: stdout5 = "",
|
|
545475
|
-
stderr: stderr7 = ""
|
|
545476
|
-
} = await execWithExitCode(timeout5, command, {
|
|
545492
|
+
const { stdout: stdout5 = "", stderr: stderr7 = "" } = await execWithExitCode(command, {
|
|
545477
545493
|
shell: getShellPath(),
|
|
545478
545494
|
timeout: timeout5 * 1000,
|
|
545479
545495
|
cwd: resolvedCwd,
|
|
545480
545496
|
signal: abortSignal,
|
|
545481
545497
|
env: { ...process.env, ...envs, ...getTerminalEnv() }
|
|
545482
545498
|
});
|
|
545483
|
-
|
|
545484
|
-
return {
|
|
545485
|
-
output,
|
|
545486
|
-
isTruncated
|
|
545487
|
-
};
|
|
545499
|
+
return processCommandOutput(stdout5, stderr7);
|
|
545488
545500
|
} catch (error48) {
|
|
545489
|
-
if (error48 instanceof
|
|
545490
|
-
|
|
545491
|
-
|
|
545492
|
-
|
|
545501
|
+
if (error48 instanceof ExecuteCommandError) {
|
|
545502
|
+
throw error48;
|
|
545503
|
+
}
|
|
545504
|
+
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
545505
|
+
throw new Error("Command execution was aborted");
|
|
545493
545506
|
}
|
|
545494
545507
|
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
545495
545508
|
throw new Error(errorMessage);
|
|
@@ -545498,7 +545511,7 @@ var executeCommand2 = () => async ({ command, cwd: cwd3 = ".", timeout: timeout5
|
|
|
545498
545511
|
function isExecException(error48) {
|
|
545499
545512
|
return error48 instanceof Error && "cmd" in error48 && "killed" in error48 && "code" in error48 && "signal" in error48;
|
|
545500
545513
|
}
|
|
545501
|
-
async function execWithExitCode(
|
|
545514
|
+
async function execWithExitCode(command, options14) {
|
|
545502
545515
|
return await new Promise((resolve25, reject3) => {
|
|
545503
545516
|
const child = exec9(command, options14, (err3, stdout5 = "", stderr7 = "") => {
|
|
545504
545517
|
if (!err3) {
|
|
@@ -545510,15 +545523,21 @@ async function execWithExitCode(timeout5, command, options14) {
|
|
|
545510
545523
|
return;
|
|
545511
545524
|
}
|
|
545512
545525
|
if (isExecException(err3)) {
|
|
545513
|
-
if (err3.signal === "SIGTERM" && err3.killed) {
|
|
545514
|
-
reject3(new
|
|
545526
|
+
if (err3.signal === "SIGTERM" && err3.killed && options14.timeout && options14.timeout > 0) {
|
|
545527
|
+
reject3(new ExecuteCommandError({
|
|
545528
|
+
message: `Command execution timed out after ${options14.timeout / 1000} seconds.`,
|
|
545529
|
+
stdout: err3.stdout ?? stdout5 ?? "",
|
|
545530
|
+
stderr: err3.stderr ?? stderr7 ?? "",
|
|
545531
|
+
code: err3.code ?? 1
|
|
545532
|
+
}));
|
|
545515
545533
|
return;
|
|
545516
545534
|
}
|
|
545517
|
-
|
|
545518
|
-
|
|
545519
|
-
|
|
545520
|
-
|
|
545521
|
-
|
|
545535
|
+
reject3(new ExecuteCommandError({
|
|
545536
|
+
message: `Command exited with code ${err3.code ?? 1}`,
|
|
545537
|
+
stdout: err3.stdout ?? stdout5 ?? "",
|
|
545538
|
+
stderr: err3.stderr ?? stderr7 ?? "",
|
|
545539
|
+
code: err3.code ?? 1
|
|
545540
|
+
}));
|
|
545522
545541
|
return;
|
|
545523
545542
|
}
|
|
545524
545543
|
reject3(err3);
|
|
@@ -545526,14 +545545,17 @@ async function execWithExitCode(timeout5, command, options14) {
|
|
|
545526
545545
|
child.stdin?.end();
|
|
545527
545546
|
});
|
|
545528
545547
|
}
|
|
545529
|
-
function processCommandOutput(stdout5, stderr7,
|
|
545530
|
-
|
|
545531
|
-
if (code4 !== 0) {
|
|
545532
|
-
fullOutput += `
|
|
545533
|
-
Command exited with code ${code4}`;
|
|
545534
|
-
}
|
|
545548
|
+
function processCommandOutput(stdout5, stderr7, errorMessage) {
|
|
545549
|
+
const fullOutput = fixExecuteCommandOutput(stdout5 + stderr7);
|
|
545535
545550
|
const isTruncated = fullOutput.length > MaxTerminalOutputSize;
|
|
545536
545551
|
const output = isTruncated ? fullOutput.slice(-MaxTerminalOutputSize) : fullOutput;
|
|
545552
|
+
if (errorMessage) {
|
|
545553
|
+
return {
|
|
545554
|
+
output,
|
|
545555
|
+
isTruncated,
|
|
545556
|
+
error: errorMessage
|
|
545557
|
+
};
|
|
545558
|
+
}
|
|
545537
545559
|
return { output, isTruncated };
|
|
545538
545560
|
}
|
|
545539
545561
|
|
|
@@ -545846,6 +545868,9 @@ async function executeToolCall(tool2, options14, cwd3, abortSignal, contentType,
|
|
|
545846
545868
|
envs
|
|
545847
545869
|
});
|
|
545848
545870
|
} catch (e9) {
|
|
545871
|
+
if (e9 instanceof ExecuteCommandError) {
|
|
545872
|
+
return e9.asOutput();
|
|
545873
|
+
}
|
|
545849
545874
|
return {
|
|
545850
545875
|
error: toErrorMessage(e9)
|
|
545851
545876
|
};
|