@vm0/cli 3.1.0 → 3.2.1
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 +57 -33
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12336,11 +12336,11 @@ var ApiClient = class {
|
|
|
12336
12336
|
}
|
|
12337
12337
|
return apiUrl;
|
|
12338
12338
|
}
|
|
12339
|
-
async
|
|
12339
|
+
async getComposeByName(name) {
|
|
12340
12340
|
const baseUrl = await this.getBaseUrl();
|
|
12341
12341
|
const headers = await this.getHeaders();
|
|
12342
12342
|
const response = await fetch(
|
|
12343
|
-
`${baseUrl}/api/agent/
|
|
12343
|
+
`${baseUrl}/api/agent/composes?name=${encodeURIComponent(name)}`,
|
|
12344
12344
|
{
|
|
12345
12345
|
method: "GET",
|
|
12346
12346
|
headers
|
|
@@ -12348,21 +12348,21 @@ var ApiClient = class {
|
|
|
12348
12348
|
);
|
|
12349
12349
|
if (!response.ok) {
|
|
12350
12350
|
const error43 = await response.json();
|
|
12351
|
-
throw new Error(error43.error?.message || `
|
|
12351
|
+
throw new Error(error43.error?.message || `Compose not found: ${name}`);
|
|
12352
12352
|
}
|
|
12353
12353
|
return await response.json();
|
|
12354
12354
|
}
|
|
12355
|
-
async
|
|
12355
|
+
async createOrUpdateCompose(body) {
|
|
12356
12356
|
const baseUrl = await this.getBaseUrl();
|
|
12357
12357
|
const headers = await this.getHeaders();
|
|
12358
|
-
const response = await fetch(`${baseUrl}/api/agent/
|
|
12358
|
+
const response = await fetch(`${baseUrl}/api/agent/composes`, {
|
|
12359
12359
|
method: "POST",
|
|
12360
12360
|
headers,
|
|
12361
12361
|
body: JSON.stringify(body)
|
|
12362
12362
|
});
|
|
12363
12363
|
if (!response.ok) {
|
|
12364
12364
|
const error43 = await response.json();
|
|
12365
|
-
throw new Error(error43.error?.message || "Failed to create
|
|
12365
|
+
throw new Error(error43.error?.message || "Failed to create compose");
|
|
12366
12366
|
}
|
|
12367
12367
|
return await response.json();
|
|
12368
12368
|
}
|
|
@@ -12480,7 +12480,7 @@ function validateVolumeConfig(volumeKey, volumeConfig) {
|
|
|
12480
12480
|
}
|
|
12481
12481
|
return null;
|
|
12482
12482
|
}
|
|
12483
|
-
function
|
|
12483
|
+
function validateAgentCompose(config2) {
|
|
12484
12484
|
if (!config2 || typeof config2 !== "object") {
|
|
12485
12485
|
return { valid: false, error: "Config must be an object" };
|
|
12486
12486
|
}
|
|
@@ -12637,7 +12637,7 @@ function expandEnvVarsInObject(obj) {
|
|
|
12637
12637
|
}
|
|
12638
12638
|
|
|
12639
12639
|
// src/commands/build.ts
|
|
12640
|
-
var buildCommand = new Command().name("build").description("Create or update agent
|
|
12640
|
+
var buildCommand = new Command().name("build").description("Create or update agent compose").argument("<config-file>", "Path to config YAML file").action(async (configFile) => {
|
|
12641
12641
|
try {
|
|
12642
12642
|
if (!existsSync2(configFile)) {
|
|
12643
12643
|
console.error(chalk2.red(`\u2717 Config file not found: ${configFile}`));
|
|
@@ -12672,19 +12672,19 @@ var buildCommand = new Command().name("build").description("Create or update age
|
|
|
12672
12672
|
process.exit(1);
|
|
12673
12673
|
}
|
|
12674
12674
|
config2 = expandEnvVarsInObject(config2);
|
|
12675
|
-
const validation =
|
|
12675
|
+
const validation = validateAgentCompose(config2);
|
|
12676
12676
|
if (!validation.valid) {
|
|
12677
12677
|
console.error(chalk2.red(`\u2717 ${validation.error}`));
|
|
12678
12678
|
process.exit(1);
|
|
12679
12679
|
}
|
|
12680
|
-
console.log(chalk2.blue("Uploading
|
|
12681
|
-
const response = await apiClient.
|
|
12680
|
+
console.log(chalk2.blue("Uploading compose..."));
|
|
12681
|
+
const response = await apiClient.createOrUpdateCompose({ config: config2 });
|
|
12682
12682
|
if (response.action === "created") {
|
|
12683
|
-
console.log(chalk2.green(`\u2713
|
|
12683
|
+
console.log(chalk2.green(`\u2713 Compose created: ${response.name}`));
|
|
12684
12684
|
} else {
|
|
12685
|
-
console.log(chalk2.green(`\u2713
|
|
12685
|
+
console.log(chalk2.green(`\u2713 Compose updated: ${response.name}`));
|
|
12686
12686
|
}
|
|
12687
|
-
console.log(chalk2.gray(`
|
|
12687
|
+
console.log(chalk2.gray(` Compose ID: ${response.composeId}`));
|
|
12688
12688
|
console.log();
|
|
12689
12689
|
console.log(" Run your agent:");
|
|
12690
12690
|
console.log(
|
|
@@ -12696,11 +12696,11 @@ var buildCommand = new Command().name("build").description("Create or update age
|
|
|
12696
12696
|
if (error43 instanceof Error) {
|
|
12697
12697
|
if (error43.message.includes("Not authenticated")) {
|
|
12698
12698
|
console.error(chalk2.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
12699
|
-
} else if (error43.message.includes("Failed to create
|
|
12700
|
-
console.error(chalk2.red("\u2717 Failed to create
|
|
12699
|
+
} else if (error43.message.includes("Failed to create compose")) {
|
|
12700
|
+
console.error(chalk2.red("\u2717 Failed to create compose"));
|
|
12701
12701
|
console.error(chalk2.gray(` ${error43.message}`));
|
|
12702
12702
|
} else {
|
|
12703
|
-
console.error(chalk2.red("\u2717 Failed to create
|
|
12703
|
+
console.error(chalk2.red("\u2717 Failed to create compose"));
|
|
12704
12704
|
console.error(chalk2.gray(` ${error43.message}`));
|
|
12705
12705
|
}
|
|
12706
12706
|
} else {
|
|
@@ -12824,10 +12824,11 @@ var ClaudeEventParser = class {
|
|
|
12824
12824
|
static parseVm0StartEvent(event) {
|
|
12825
12825
|
return {
|
|
12826
12826
|
type: "vm0_start",
|
|
12827
|
-
timestamp: new Date(
|
|
12827
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
12828
|
+
// Use client receive time for consistent elapsed calculation
|
|
12828
12829
|
data: {
|
|
12829
12830
|
runId: event.runId,
|
|
12830
|
-
|
|
12831
|
+
agentComposeId: event.agentComposeId,
|
|
12831
12832
|
agentName: event.agentName,
|
|
12832
12833
|
prompt: event.prompt,
|
|
12833
12834
|
templateVars: event.templateVars,
|
|
@@ -12841,7 +12842,8 @@ var ClaudeEventParser = class {
|
|
|
12841
12842
|
static parseVm0ResultEvent(event) {
|
|
12842
12843
|
return {
|
|
12843
12844
|
type: "vm0_result",
|
|
12844
|
-
timestamp: new Date(
|
|
12845
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
12846
|
+
// Use client receive time for consistent elapsed calculation
|
|
12845
12847
|
data: {
|
|
12846
12848
|
runId: event.runId,
|
|
12847
12849
|
checkpointId: event.checkpointId,
|
|
@@ -12855,7 +12857,8 @@ var ClaudeEventParser = class {
|
|
|
12855
12857
|
static parseVm0ErrorEvent(event) {
|
|
12856
12858
|
return {
|
|
12857
12859
|
type: "vm0_error",
|
|
12858
|
-
timestamp: new Date(
|
|
12860
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
12861
|
+
// Use client receive time for consistent elapsed calculation
|
|
12859
12862
|
data: {
|
|
12860
12863
|
runId: event.runId,
|
|
12861
12864
|
error: event.error,
|
|
@@ -13097,6 +13100,7 @@ var DEFAULT_TIMEOUT_SECONDS = 120;
|
|
|
13097
13100
|
async function pollEvents(runId, timeoutSeconds, options) {
|
|
13098
13101
|
let nextSequence = -1;
|
|
13099
13102
|
let complete = false;
|
|
13103
|
+
let runSucceeded = true;
|
|
13100
13104
|
const pollIntervalMs = 500;
|
|
13101
13105
|
const timeoutMs = timeoutSeconds * 1e3;
|
|
13102
13106
|
const startTime = Date.now();
|
|
@@ -13128,8 +13132,12 @@ async function pollEvents(runId, timeoutSeconds, options) {
|
|
|
13128
13132
|
startTimestamp
|
|
13129
13133
|
});
|
|
13130
13134
|
previousTimestamp = parsed.timestamp;
|
|
13131
|
-
if (parsed.type === "vm0_result"
|
|
13135
|
+
if (parsed.type === "vm0_result") {
|
|
13136
|
+
complete = true;
|
|
13137
|
+
runSucceeded = true;
|
|
13138
|
+
} else if (parsed.type === "vm0_error") {
|
|
13132
13139
|
complete = true;
|
|
13140
|
+
runSucceeded = false;
|
|
13133
13141
|
}
|
|
13134
13142
|
}
|
|
13135
13143
|
}
|
|
@@ -13138,6 +13146,7 @@ async function pollEvents(runId, timeoutSeconds, options) {
|
|
|
13138
13146
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
13139
13147
|
}
|
|
13140
13148
|
}
|
|
13149
|
+
return runSucceeded;
|
|
13141
13150
|
}
|
|
13142
13151
|
function logVerbosePreFlight(action, details) {
|
|
13143
13152
|
console.log(chalk4.blue(`
|
|
@@ -13194,21 +13203,21 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13194
13203
|
}
|
|
13195
13204
|
const verbose = options.verbose;
|
|
13196
13205
|
try {
|
|
13197
|
-
let
|
|
13206
|
+
let composeId;
|
|
13198
13207
|
if (isUUID(identifier)) {
|
|
13199
|
-
|
|
13208
|
+
composeId = identifier;
|
|
13200
13209
|
if (verbose) {
|
|
13201
|
-
console.log(chalk4.gray(` Using
|
|
13210
|
+
console.log(chalk4.gray(` Using compose ID: ${composeId}`));
|
|
13202
13211
|
}
|
|
13203
13212
|
} else {
|
|
13204
13213
|
if (verbose) {
|
|
13205
13214
|
console.log(chalk4.gray(` Resolving agent name: ${identifier}`));
|
|
13206
13215
|
}
|
|
13207
13216
|
try {
|
|
13208
|
-
const
|
|
13209
|
-
|
|
13217
|
+
const compose = await apiClient.getComposeByName(identifier);
|
|
13218
|
+
composeId = compose.id;
|
|
13210
13219
|
if (verbose) {
|
|
13211
|
-
console.log(chalk4.gray(` Resolved to
|
|
13220
|
+
console.log(chalk4.gray(` Resolved to compose ID: ${composeId}`));
|
|
13212
13221
|
}
|
|
13213
13222
|
} catch (error43) {
|
|
13214
13223
|
if (error43 instanceof Error) {
|
|
@@ -13239,7 +13248,7 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13239
13248
|
]);
|
|
13240
13249
|
}
|
|
13241
13250
|
const response = await apiClient.createRun({
|
|
13242
|
-
|
|
13251
|
+
agentComposeId: composeId,
|
|
13243
13252
|
prompt,
|
|
13244
13253
|
templateVars: Object.keys(options.vars).length > 0 ? options.vars : void 0,
|
|
13245
13254
|
artifactName: options.artifactName,
|
|
@@ -13247,7 +13256,12 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13247
13256
|
volumeVersions: Object.keys(options.volumeVersion).length > 0 ? options.volumeVersion : void 0,
|
|
13248
13257
|
conversationId: options.conversation
|
|
13249
13258
|
});
|
|
13250
|
-
await pollEvents(response.runId, timeoutSeconds, {
|
|
13259
|
+
const succeeded = await pollEvents(response.runId, timeoutSeconds, {
|
|
13260
|
+
verbose
|
|
13261
|
+
});
|
|
13262
|
+
if (!succeeded) {
|
|
13263
|
+
process.exit(1);
|
|
13264
|
+
}
|
|
13251
13265
|
} catch (error43) {
|
|
13252
13266
|
if (error43 instanceof Error) {
|
|
13253
13267
|
if (error43.message.includes("Not authenticated")) {
|
|
@@ -13313,7 +13327,12 @@ runCmd.command("resume").description("Resume an agent run from a checkpoint (use
|
|
|
13313
13327
|
prompt,
|
|
13314
13328
|
volumeVersions: Object.keys(allOpts.volumeVersion).length > 0 ? allOpts.volumeVersion : void 0
|
|
13315
13329
|
});
|
|
13316
|
-
await pollEvents(response.runId, timeoutSeconds, {
|
|
13330
|
+
const succeeded = await pollEvents(response.runId, timeoutSeconds, {
|
|
13331
|
+
verbose
|
|
13332
|
+
});
|
|
13333
|
+
if (!succeeded) {
|
|
13334
|
+
process.exit(1);
|
|
13335
|
+
}
|
|
13317
13336
|
} catch (error43) {
|
|
13318
13337
|
if (error43 instanceof Error) {
|
|
13319
13338
|
if (error43.message.includes("Not authenticated")) {
|
|
@@ -13379,7 +13398,12 @@ runCmd.command("continue").description(
|
|
|
13379
13398
|
prompt,
|
|
13380
13399
|
volumeVersions: Object.keys(allOpts.volumeVersion).length > 0 ? allOpts.volumeVersion : void 0
|
|
13381
13400
|
});
|
|
13382
|
-
await pollEvents(response.runId, timeoutSeconds, {
|
|
13401
|
+
const succeeded = await pollEvents(response.runId, timeoutSeconds, {
|
|
13402
|
+
verbose
|
|
13403
|
+
});
|
|
13404
|
+
if (!succeeded) {
|
|
13405
|
+
process.exit(1);
|
|
13406
|
+
}
|
|
13383
13407
|
} catch (error43) {
|
|
13384
13408
|
if (error43 instanceof Error) {
|
|
13385
13409
|
if (error43.message.includes("Not authenticated")) {
|
|
@@ -14106,7 +14130,7 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
|
|
|
14106
14130
|
|
|
14107
14131
|
// src/index.ts
|
|
14108
14132
|
var program = new Command11();
|
|
14109
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.1
|
|
14133
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.2.1");
|
|
14110
14134
|
program.command("hello").description("Say hello from the App").action(() => {
|
|
14111
14135
|
console.log(chalk11.blue("Welcome to the VM0 CLI!"));
|
|
14112
14136
|
console.log(chalk11.green(`Core says: ${FOO}`));
|