@vm0/cli 3.2.2 → 3.4.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 +81 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12352,6 +12352,26 @@ var ApiClient = class {
|
|
|
12352
12352
|
}
|
|
12353
12353
|
return await response.json();
|
|
12354
12354
|
}
|
|
12355
|
+
/**
|
|
12356
|
+
* Resolve a version specifier to a full version ID
|
|
12357
|
+
* Supports: "latest", full hash (64 chars), or hash prefix (8+ chars)
|
|
12358
|
+
*/
|
|
12359
|
+
async getComposeVersion(composeId, version2) {
|
|
12360
|
+
const baseUrl = await this.getBaseUrl();
|
|
12361
|
+
const headers = await this.getHeaders();
|
|
12362
|
+
const response = await fetch(
|
|
12363
|
+
`${baseUrl}/api/agent/composes/versions?composeId=${encodeURIComponent(composeId)}&version=${encodeURIComponent(version2)}`,
|
|
12364
|
+
{
|
|
12365
|
+
method: "GET",
|
|
12366
|
+
headers
|
|
12367
|
+
}
|
|
12368
|
+
);
|
|
12369
|
+
if (!response.ok) {
|
|
12370
|
+
const error43 = await response.json();
|
|
12371
|
+
throw new Error(error43.error?.message || `Version not found: ${version2}`);
|
|
12372
|
+
}
|
|
12373
|
+
return await response.json();
|
|
12374
|
+
}
|
|
12355
12375
|
async createOrUpdateCompose(body) {
|
|
12356
12376
|
const baseUrl = await this.getBaseUrl();
|
|
12357
12377
|
const headers = await this.getHeaders();
|
|
@@ -12678,13 +12698,17 @@ var buildCommand = new Command().name("build").description("Create or update age
|
|
|
12678
12698
|
process.exit(1);
|
|
12679
12699
|
}
|
|
12680
12700
|
console.log(chalk2.blue("Uploading compose..."));
|
|
12681
|
-
const response = await apiClient.createOrUpdateCompose({
|
|
12701
|
+
const response = await apiClient.createOrUpdateCompose({
|
|
12702
|
+
content: config2
|
|
12703
|
+
});
|
|
12704
|
+
const shortVersionId = response.versionId.slice(0, 8);
|
|
12682
12705
|
if (response.action === "created") {
|
|
12683
12706
|
console.log(chalk2.green(`\u2713 Compose created: ${response.name}`));
|
|
12684
12707
|
} else {
|
|
12685
|
-
console.log(chalk2.green(`\u2713 Compose
|
|
12708
|
+
console.log(chalk2.green(`\u2713 Compose version exists: ${response.name}`));
|
|
12686
12709
|
}
|
|
12687
12710
|
console.log(chalk2.gray(` Compose ID: ${response.composeId}`));
|
|
12711
|
+
console.log(chalk2.gray(` Version: ${shortVersionId}`));
|
|
12688
12712
|
console.log();
|
|
12689
12713
|
console.log(" Run your agent:");
|
|
12690
12714
|
console.log(
|
|
@@ -12828,7 +12852,7 @@ var ClaudeEventParser = class {
|
|
|
12828
12852
|
// Use client receive time for consistent elapsed calculation
|
|
12829
12853
|
data: {
|
|
12830
12854
|
runId: event.runId,
|
|
12831
|
-
|
|
12855
|
+
agentComposeVersionId: event.agentComposeVersionId,
|
|
12832
12856
|
agentName: event.agentName,
|
|
12833
12857
|
prompt: event.prompt,
|
|
12834
12858
|
templateVars: event.templateVars,
|
|
@@ -13096,6 +13120,19 @@ function collectVolumeVersions(value, previous) {
|
|
|
13096
13120
|
function isUUID(str) {
|
|
13097
13121
|
return /^[0-9a-f-]{36}$/i.test(str);
|
|
13098
13122
|
}
|
|
13123
|
+
function parseIdentifier(identifier) {
|
|
13124
|
+
if (isUUID(identifier)) {
|
|
13125
|
+
return { name: identifier };
|
|
13126
|
+
}
|
|
13127
|
+
const colonIndex = identifier.lastIndexOf(":");
|
|
13128
|
+
if (colonIndex > 0 && colonIndex < identifier.length - 1) {
|
|
13129
|
+
return {
|
|
13130
|
+
name: identifier.slice(0, colonIndex),
|
|
13131
|
+
version: identifier.slice(colonIndex + 1)
|
|
13132
|
+
};
|
|
13133
|
+
}
|
|
13134
|
+
return { name: identifier };
|
|
13135
|
+
}
|
|
13099
13136
|
var DEFAULT_TIMEOUT_SECONDS = 120;
|
|
13100
13137
|
async function pollEvents(runId, timeoutSeconds, options) {
|
|
13101
13138
|
let nextSequence = -1;
|
|
@@ -13162,7 +13199,7 @@ ${action}...`));
|
|
|
13162
13199
|
}
|
|
13163
13200
|
var runCmd = new Command2().name("run").description("Execute an agent").argument(
|
|
13164
13201
|
"<identifier>",
|
|
13165
|
-
"Agent name
|
|
13202
|
+
"Agent name, config ID, or name:version (e.g., 'my-agent', 'my-agent:abc123', 'my-agent:latest')"
|
|
13166
13203
|
).argument("<prompt>", "Prompt for the agent").option(
|
|
13167
13204
|
"--vars <KEY=value>",
|
|
13168
13205
|
"Template variables for config placeholders (repeatable)",
|
|
@@ -13204,25 +13241,26 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13204
13241
|
}
|
|
13205
13242
|
const verbose = options.verbose;
|
|
13206
13243
|
try {
|
|
13244
|
+
const { name, version: version2 } = parseIdentifier(identifier);
|
|
13207
13245
|
let composeId;
|
|
13208
|
-
if (isUUID(
|
|
13209
|
-
composeId =
|
|
13246
|
+
if (isUUID(name)) {
|
|
13247
|
+
composeId = name;
|
|
13210
13248
|
if (verbose) {
|
|
13211
13249
|
console.log(chalk4.gray(` Using compose ID: ${composeId}`));
|
|
13212
13250
|
}
|
|
13213
13251
|
} else {
|
|
13214
13252
|
if (verbose) {
|
|
13215
|
-
console.log(chalk4.gray(` Resolving agent name: ${
|
|
13253
|
+
console.log(chalk4.gray(` Resolving agent name: ${name}`));
|
|
13216
13254
|
}
|
|
13217
13255
|
try {
|
|
13218
|
-
const compose = await apiClient.getComposeByName(
|
|
13256
|
+
const compose = await apiClient.getComposeByName(name);
|
|
13219
13257
|
composeId = compose.id;
|
|
13220
13258
|
if (verbose) {
|
|
13221
13259
|
console.log(chalk4.gray(` Resolved to compose ID: ${composeId}`));
|
|
13222
13260
|
}
|
|
13223
13261
|
} catch (error43) {
|
|
13224
13262
|
if (error43 instanceof Error) {
|
|
13225
|
-
console.error(chalk4.red(`\u2717 Agent not found: ${
|
|
13263
|
+
console.error(chalk4.red(`\u2717 Agent not found: ${name}`));
|
|
13226
13264
|
console.error(
|
|
13227
13265
|
chalk4.gray(
|
|
13228
13266
|
" Make sure you've built the agent with: vm0 build"
|
|
@@ -13232,9 +13270,40 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13232
13270
|
process.exit(1);
|
|
13233
13271
|
}
|
|
13234
13272
|
}
|
|
13273
|
+
let agentComposeVersionId;
|
|
13274
|
+
if (version2 && version2 !== "latest") {
|
|
13275
|
+
if (verbose) {
|
|
13276
|
+
console.log(chalk4.gray(` Resolving version: ${version2}`));
|
|
13277
|
+
}
|
|
13278
|
+
try {
|
|
13279
|
+
const versionInfo = await apiClient.getComposeVersion(
|
|
13280
|
+
composeId,
|
|
13281
|
+
version2
|
|
13282
|
+
);
|
|
13283
|
+
agentComposeVersionId = versionInfo.versionId;
|
|
13284
|
+
if (verbose) {
|
|
13285
|
+
console.log(
|
|
13286
|
+
chalk4.gray(
|
|
13287
|
+
` Resolved to version ID: ${agentComposeVersionId.slice(0, 8)}...`
|
|
13288
|
+
)
|
|
13289
|
+
);
|
|
13290
|
+
}
|
|
13291
|
+
} catch (error43) {
|
|
13292
|
+
if (error43 instanceof Error) {
|
|
13293
|
+
console.error(chalk4.red(`\u2717 Version not found: ${version2}`));
|
|
13294
|
+
console.error(
|
|
13295
|
+
chalk4.gray(
|
|
13296
|
+
" Make sure the version hash exists. Use 'vm0 build' to see available versions."
|
|
13297
|
+
)
|
|
13298
|
+
);
|
|
13299
|
+
}
|
|
13300
|
+
process.exit(1);
|
|
13301
|
+
}
|
|
13302
|
+
}
|
|
13235
13303
|
if (verbose) {
|
|
13236
13304
|
logVerbosePreFlight("Creating agent run", [
|
|
13237
13305
|
{ label: "Prompt", value: prompt },
|
|
13306
|
+
{ label: "Version", value: version2 || "latest (HEAD)" },
|
|
13238
13307
|
{
|
|
13239
13308
|
label: "Variables",
|
|
13240
13309
|
value: Object.keys(options.vars).length > 0 ? JSON.stringify(options.vars) : void 0
|
|
@@ -13249,7 +13318,8 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13249
13318
|
]);
|
|
13250
13319
|
}
|
|
13251
13320
|
const response = await apiClient.createRun({
|
|
13252
|
-
agentComposeId
|
|
13321
|
+
// Use agentComposeVersionId if resolved, otherwise use agentComposeId (resolves to HEAD)
|
|
13322
|
+
...agentComposeVersionId ? { agentComposeVersionId } : { agentComposeId: composeId },
|
|
13253
13323
|
prompt,
|
|
13254
13324
|
templateVars: Object.keys(options.vars).length > 0 ? options.vars : void 0,
|
|
13255
13325
|
artifactName: options.artifactName,
|
|
@@ -14136,7 +14206,7 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
|
|
|
14136
14206
|
|
|
14137
14207
|
// src/index.ts
|
|
14138
14208
|
var program = new Command11();
|
|
14139
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.
|
|
14209
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("3.4.0");
|
|
14140
14210
|
program.command("hello").description("Say hello from the App").action(() => {
|
|
14141
14211
|
console.log(chalk11.blue("Welcome to the VM0 CLI!"));
|
|
14142
14212
|
console.log(chalk11.green(`Core says: ${FOO}`));
|