@vm0/cli 1.5.0 → 1.6.0
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/index.js +63 -39
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12821,9 +12821,7 @@ var EventRenderer = class {
|
|
|
12821
12821
|
if (input && typeof input === "object") {
|
|
12822
12822
|
for (const [key, value] of Object.entries(input)) {
|
|
12823
12823
|
if (value !== void 0 && value !== null) {
|
|
12824
|
-
|
|
12825
|
-
const displayValue = valueStr.length > 100 ? valueStr.substring(0, 100) + "..." : valueStr;
|
|
12826
|
-
console.log(` ${key}: ${chalk3.gray(displayValue)}`);
|
|
12824
|
+
console.log(` ${key}: ${chalk3.gray(String(value))}`);
|
|
12827
12825
|
}
|
|
12828
12826
|
}
|
|
12829
12827
|
}
|
|
@@ -12834,8 +12832,7 @@ var EventRenderer = class {
|
|
|
12834
12832
|
const color = isError ? chalk3.red : chalk3.green;
|
|
12835
12833
|
console.log(color("[tool_result]") + " " + status);
|
|
12836
12834
|
const result = String(event.data.result || "");
|
|
12837
|
-
|
|
12838
|
-
console.log(` ${chalk3.gray(displayResult)}`);
|
|
12835
|
+
console.log(` ${chalk3.gray(result)}`);
|
|
12839
12836
|
}
|
|
12840
12837
|
static renderResult(event) {
|
|
12841
12838
|
const success2 = Boolean(event.data.success);
|
|
@@ -12872,8 +12869,7 @@ var EventRenderer = class {
|
|
|
12872
12869
|
console.log(` Run ID: ${chalk3.gray(String(event.data.runId))}`);
|
|
12873
12870
|
}
|
|
12874
12871
|
const prompt = String(event.data.prompt || "");
|
|
12875
|
-
|
|
12876
|
-
console.log(` Prompt: ${chalk3.gray(displayPrompt)}`);
|
|
12872
|
+
console.log(` Prompt: ${chalk3.gray(prompt)}`);
|
|
12877
12873
|
if (event.data.agentName) {
|
|
12878
12874
|
console.log(` Agent: ${chalk3.gray(String(event.data.agentName))}`);
|
|
12879
12875
|
}
|
|
@@ -12920,18 +12916,20 @@ function collectEnvVars(value, previous) {
|
|
|
12920
12916
|
function isUUID(str) {
|
|
12921
12917
|
return /^[0-9a-f-]{36}$/i.test(str);
|
|
12922
12918
|
}
|
|
12923
|
-
|
|
12919
|
+
var DEFAULT_TIMEOUT_SECONDS = 60;
|
|
12920
|
+
async function pollEvents(runId, timeoutSeconds) {
|
|
12924
12921
|
let nextSequence = -1;
|
|
12925
12922
|
let complete = false;
|
|
12926
12923
|
const pollIntervalMs = 500;
|
|
12927
|
-
const timeoutMs =
|
|
12924
|
+
const timeoutMs = timeoutSeconds * 1e3;
|
|
12928
12925
|
const startTime = Date.now();
|
|
12929
12926
|
while (!complete) {
|
|
12930
12927
|
const elapsed = Date.now() - startTime;
|
|
12931
12928
|
if (elapsed > timeoutMs) {
|
|
12932
12929
|
console.error(
|
|
12933
12930
|
chalk4.red(
|
|
12934
|
-
|
|
12931
|
+
`
|
|
12932
|
+
\u2717 Agent execution timed out after ${timeoutSeconds} seconds without receiving events`
|
|
12935
12933
|
)
|
|
12936
12934
|
);
|
|
12937
12935
|
throw new Error("Agent execution timed out");
|
|
@@ -12967,8 +12965,19 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
12967
12965
|
).option(
|
|
12968
12966
|
"-a, --artifact <key>",
|
|
12969
12967
|
"Artifact key to mount (for VM0 driver artifacts)"
|
|
12968
|
+
).option(
|
|
12969
|
+
"-t, --timeout <seconds>",
|
|
12970
|
+
"Polling timeout in seconds (default: 60)",
|
|
12971
|
+
String(DEFAULT_TIMEOUT_SECONDS)
|
|
12970
12972
|
).action(
|
|
12971
12973
|
async (identifier, prompt, options) => {
|
|
12974
|
+
const timeoutSeconds = parseInt(options.timeout, 10);
|
|
12975
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
12976
|
+
console.error(
|
|
12977
|
+
chalk4.red("\u2717 Invalid timeout value. Must be a positive number.")
|
|
12978
|
+
);
|
|
12979
|
+
process.exit(1);
|
|
12980
|
+
}
|
|
12972
12981
|
try {
|
|
12973
12982
|
let configId;
|
|
12974
12983
|
if (isUUID(identifier)) {
|
|
@@ -13011,7 +13020,7 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13011
13020
|
dynamicVars: Object.keys(options.env).length > 0 ? options.env : void 0,
|
|
13012
13021
|
artifactKey: options.artifact
|
|
13013
13022
|
});
|
|
13014
|
-
await pollEvents(response.runId);
|
|
13023
|
+
await pollEvents(response.runId, timeoutSeconds);
|
|
13015
13024
|
} catch (error43) {
|
|
13016
13025
|
if (error43 instanceof Error) {
|
|
13017
13026
|
if (error43.message.includes("Not authenticated")) {
|
|
@@ -13034,42 +13043,57 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13034
13043
|
}
|
|
13035
13044
|
}
|
|
13036
13045
|
);
|
|
13037
|
-
runCmd.command("resume").description("Resume an agent run from a checkpoint").argument("<checkpointId>", "Checkpoint ID to resume from").argument("<prompt>", "Prompt for the resumed agent").
|
|
13038
|
-
|
|
13039
|
-
|
|
13046
|
+
runCmd.command("resume").description("Resume an agent run from a checkpoint").argument("<checkpointId>", "Checkpoint ID to resume from").argument("<prompt>", "Prompt for the resumed agent").option(
|
|
13047
|
+
"-t, --timeout <seconds>",
|
|
13048
|
+
"Polling timeout in seconds (default: 60)",
|
|
13049
|
+
String(DEFAULT_TIMEOUT_SECONDS)
|
|
13050
|
+
).action(
|
|
13051
|
+
async (checkpointId, prompt, options) => {
|
|
13052
|
+
const timeoutSeconds = parseInt(options.timeout, 10);
|
|
13053
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
13040
13054
|
console.error(
|
|
13041
|
-
chalk4.red(
|
|
13055
|
+
chalk4.red("\u2717 Invalid timeout value. Must be a positive number.")
|
|
13042
13056
|
);
|
|
13043
|
-
console.error(chalk4.gray(" Checkpoint ID must be a valid UUID"));
|
|
13044
13057
|
process.exit(1);
|
|
13045
13058
|
}
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13059
|
+
try {
|
|
13060
|
+
if (!isUUID(checkpointId)) {
|
|
13061
|
+
console.error(
|
|
13062
|
+
chalk4.red(`\u2717 Invalid checkpoint ID format: ${checkpointId}`)
|
|
13063
|
+
);
|
|
13064
|
+
console.error(chalk4.gray(" Checkpoint ID must be a valid UUID"));
|
|
13065
|
+
process.exit(1);
|
|
13066
|
+
}
|
|
13067
|
+
console.log(chalk4.blue("\nResuming agent run from checkpoint..."));
|
|
13068
|
+
console.log(chalk4.gray(` Checkpoint ID: ${checkpointId}`));
|
|
13069
|
+
console.log(chalk4.gray(` Prompt: ${prompt}`));
|
|
13070
|
+
console.log();
|
|
13071
|
+
console.log(chalk4.blue("Executing in sandbox..."));
|
|
13072
|
+
console.log();
|
|
13073
|
+
const response = await apiClient.resumeRun({
|
|
13074
|
+
checkpointId,
|
|
13075
|
+
prompt
|
|
13076
|
+
});
|
|
13077
|
+
await pollEvents(response.runId, timeoutSeconds);
|
|
13078
|
+
} catch (error43) {
|
|
13079
|
+
if (error43 instanceof Error) {
|
|
13080
|
+
if (error43.message.includes("Not authenticated")) {
|
|
13081
|
+
console.error(
|
|
13082
|
+
chalk4.red("\u2717 Not authenticated. Run: vm0 auth login")
|
|
13083
|
+
);
|
|
13084
|
+
} else if (error43.message.includes("not found")) {
|
|
13085
|
+
console.error(chalk4.red(`\u2717 Checkpoint not found: ${checkpointId}`));
|
|
13086
|
+
} else {
|
|
13087
|
+
console.error(chalk4.red("\u2717 Resume failed"));
|
|
13088
|
+
console.error(chalk4.gray(` ${error43.message}`));
|
|
13089
|
+
}
|
|
13063
13090
|
} else {
|
|
13064
|
-
console.error(chalk4.red("\u2717
|
|
13065
|
-
console.error(chalk4.gray(` ${error43.message}`));
|
|
13091
|
+
console.error(chalk4.red("\u2717 An unexpected error occurred"));
|
|
13066
13092
|
}
|
|
13067
|
-
|
|
13068
|
-
console.error(chalk4.red("\u2717 An unexpected error occurred"));
|
|
13093
|
+
process.exit(1);
|
|
13069
13094
|
}
|
|
13070
|
-
process.exit(1);
|
|
13071
13095
|
}
|
|
13072
|
-
|
|
13096
|
+
);
|
|
13073
13097
|
var runCommand = runCmd;
|
|
13074
13098
|
|
|
13075
13099
|
// src/commands/volume/index.ts
|