@vm0/cli 3.3.0 → 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 +74 -8
- 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();
|
|
@@ -13100,6 +13120,19 @@ function collectVolumeVersions(value, previous) {
|
|
|
13100
13120
|
function isUUID(str) {
|
|
13101
13121
|
return /^[0-9a-f-]{36}$/i.test(str);
|
|
13102
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
|
+
}
|
|
13103
13136
|
var DEFAULT_TIMEOUT_SECONDS = 120;
|
|
13104
13137
|
async function pollEvents(runId, timeoutSeconds, options) {
|
|
13105
13138
|
let nextSequence = -1;
|
|
@@ -13166,7 +13199,7 @@ ${action}...`));
|
|
|
13166
13199
|
}
|
|
13167
13200
|
var runCmd = new Command2().name("run").description("Execute an agent").argument(
|
|
13168
13201
|
"<identifier>",
|
|
13169
|
-
"Agent name
|
|
13202
|
+
"Agent name, config ID, or name:version (e.g., 'my-agent', 'my-agent:abc123', 'my-agent:latest')"
|
|
13170
13203
|
).argument("<prompt>", "Prompt for the agent").option(
|
|
13171
13204
|
"--vars <KEY=value>",
|
|
13172
13205
|
"Template variables for config placeholders (repeatable)",
|
|
@@ -13208,25 +13241,26 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13208
13241
|
}
|
|
13209
13242
|
const verbose = options.verbose;
|
|
13210
13243
|
try {
|
|
13244
|
+
const { name, version: version2 } = parseIdentifier(identifier);
|
|
13211
13245
|
let composeId;
|
|
13212
|
-
if (isUUID(
|
|
13213
|
-
composeId =
|
|
13246
|
+
if (isUUID(name)) {
|
|
13247
|
+
composeId = name;
|
|
13214
13248
|
if (verbose) {
|
|
13215
13249
|
console.log(chalk4.gray(` Using compose ID: ${composeId}`));
|
|
13216
13250
|
}
|
|
13217
13251
|
} else {
|
|
13218
13252
|
if (verbose) {
|
|
13219
|
-
console.log(chalk4.gray(` Resolving agent name: ${
|
|
13253
|
+
console.log(chalk4.gray(` Resolving agent name: ${name}`));
|
|
13220
13254
|
}
|
|
13221
13255
|
try {
|
|
13222
|
-
const compose = await apiClient.getComposeByName(
|
|
13256
|
+
const compose = await apiClient.getComposeByName(name);
|
|
13223
13257
|
composeId = compose.id;
|
|
13224
13258
|
if (verbose) {
|
|
13225
13259
|
console.log(chalk4.gray(` Resolved to compose ID: ${composeId}`));
|
|
13226
13260
|
}
|
|
13227
13261
|
} catch (error43) {
|
|
13228
13262
|
if (error43 instanceof Error) {
|
|
13229
|
-
console.error(chalk4.red(`\u2717 Agent not found: ${
|
|
13263
|
+
console.error(chalk4.red(`\u2717 Agent not found: ${name}`));
|
|
13230
13264
|
console.error(
|
|
13231
13265
|
chalk4.gray(
|
|
13232
13266
|
" Make sure you've built the agent with: vm0 build"
|
|
@@ -13236,9 +13270,40 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13236
13270
|
process.exit(1);
|
|
13237
13271
|
}
|
|
13238
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
|
+
}
|
|
13239
13303
|
if (verbose) {
|
|
13240
13304
|
logVerbosePreFlight("Creating agent run", [
|
|
13241
13305
|
{ label: "Prompt", value: prompt },
|
|
13306
|
+
{ label: "Version", value: version2 || "latest (HEAD)" },
|
|
13242
13307
|
{
|
|
13243
13308
|
label: "Variables",
|
|
13244
13309
|
value: Object.keys(options.vars).length > 0 ? JSON.stringify(options.vars) : void 0
|
|
@@ -13253,7 +13318,8 @@ var runCmd = new Command2().name("run").description("Execute an agent").argument
|
|
|
13253
13318
|
]);
|
|
13254
13319
|
}
|
|
13255
13320
|
const response = await apiClient.createRun({
|
|
13256
|
-
agentComposeId
|
|
13321
|
+
// Use agentComposeVersionId if resolved, otherwise use agentComposeId (resolves to HEAD)
|
|
13322
|
+
...agentComposeVersionId ? { agentComposeVersionId } : { agentComposeId: composeId },
|
|
13257
13323
|
prompt,
|
|
13258
13324
|
templateVars: Object.keys(options.vars).length > 0 ? options.vars : void 0,
|
|
13259
13325
|
artifactName: options.artifactName,
|
|
@@ -14140,7 +14206,7 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
|
|
|
14140
14206
|
|
|
14141
14207
|
// src/index.ts
|
|
14142
14208
|
var program = new Command11();
|
|
14143
|
-
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");
|
|
14144
14210
|
program.command("hello").description("Say hello from the App").action(() => {
|
|
14145
14211
|
console.log(chalk11.blue("Welcome to the VM0 CLI!"));
|
|
14146
14212
|
console.log(chalk11.green(`Core says: ${FOO}`));
|