@vm0/cli 9.244.3 → 9.244.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/{agent-VMCUKZ77.js → agent-NQVS6VCY.js} +5 -5
- package/{banking-GDCYMV63.js → banking-U5U2G6QH.js} +3 -3
- package/{chat-GG5VC4L3.js → chat-BGF7IB3O.js} +4 -4
- package/{chunk-K56QC4XU.js → chunk-4V373IPM.js} +2 -2
- package/{chunk-6JBCB25F.js → chunk-624QMD56.js} +2 -2
- package/{chunk-DYO55E7U.js → chunk-KS62N6VR.js} +20 -78
- package/{chunk-DYO55E7U.js.map → chunk-KS62N6VR.js.map} +1 -1
- package/{chunk-AWYBT46E.js → chunk-MKPBFN7W.js} +2 -2
- package/{chunk-IRPVCBEV.js → chunk-NOUED6XP.js} +2 -2
- package/{chunk-44MXI6U3.js → chunk-PBFD5MP4.js} +3 -3
- package/{chunk-QWSA4UPI.js → chunk-SBH7L4UT.js} +4 -4
- package/{chunk-VGLTHIKS.js → chunk-UEGRDQR3.js} +2 -2
- package/{chunk-VGLTHIKS.js.map → chunk-UEGRDQR3.js.map} +1 -1
- package/{chunk-RIOGI6WE.js → chunk-VUUGKMER.js} +2 -2
- package/chunk-VUUGKMER.js.map +1 -0
- package/{chunk-JOBVE3UL.js → chunk-ZMTKJ4VW.js} +4 -4
- package/{computer-use-UWLPLYNT.js → computer-use-F4VFLO6X.js} +3 -3
- package/{connector-IAV2HAD3.js → connector-SWU3H7YL.js} +6 -6
- package/{credit-JYOB7KNE.js → credit-ZMXGA5CQ.js} +4 -4
- package/{developer-support-OGHIECZV.js → developer-support-IOTX3JWR.js} +3 -3
- package/{doctor-IBOADXQJ.js → doctor-DTMFWDXL.js} +3 -3
- package/{generate-5LOGYZX5.js → generate-IQUCOIYW.js} +4 -4
- package/{github-D7OXHFVK.js → github-AJT3E56L.js} +3 -3
- package/{goal-ZRXFDP3P.js → goal-NCK5T57P.js} +3 -3
- package/{host-X3L2I27V.js → host-BRKGWZLP.js} +3 -3
- package/index.js +174 -383
- package/index.js.map +1 -1
- package/{logs-6FL5TYUR.js → logs-WZVT4BS7.js} +5 -5
- package/{mail-OOTL5BQV.js → mail-QS4HABXH.js} +5 -5
- package/{maps-72KAMGLV.js → maps-3X6V34JQ.js} +3 -3
- package/{model-TZQDDCI4.js → model-6ETRDASM.js} +4 -4
- package/{model-provider-DZQ2LOIX.js → model-provider-XEKOLWZY.js} +4 -4
- package/{org-OPQT5ABR.js → org-DKGPME4L.js} +3 -3
- package/package.json +1 -1
- package/{phone-NGCOFB6A.js → phone-6455TFON.js} +3 -3
- package/{preference-GMDQ56WR.js → preference-2XMANS52.js} +3 -3
- package/{resource-S6BFXUN4.js → resource-MIFLTTK6.js} +3 -3
- package/{scrape-O42KQAA2.js → scrape-CIP2FZED.js} +3 -3
- package/{search-CXBQKE3F.js → search-GCQ55FYS.js} +5 -5
- package/{secret-7POSV4X6.js → secret-NVLEVYXQ.js} +3 -3
- package/{slack-KK4MB2CG.js → slack-EGYW76W2.js} +3 -3
- package/{teams-44GCGRZI.js → teams-2D63XX2R.js} +3 -3
- package/{telegram-EA7E4DDC.js → telegram-GQARG3MD.js} +3 -3
- package/{variable-WPLNUUKW.js → variable-WMKLX7TF.js} +3 -3
- package/{video-HUOPH4WL.js → video-NAUNUYGP.js} +2 -2
- package/{web-Q4AM57LW.js → web-7U3YS3KP.js} +3 -3
- package/{web-search-7FUND7UG.js → web-search-EIO3GVKH.js} +3 -3
- package/{whoami-TQ3YG2FR.js → whoami-QZJAGTDW.js} +5 -5
- package/{workflow-TATKRDOV.js → workflow-RMJIYOUB.js} +3 -3
- package/zero.js +35 -35
- package/chunk-RIOGI6WE.js.map +0 -1
- /package/{agent-VMCUKZ77.js.map → agent-NQVS6VCY.js.map} +0 -0
- /package/{banking-GDCYMV63.js.map → banking-U5U2G6QH.js.map} +0 -0
- /package/{chat-GG5VC4L3.js.map → chat-BGF7IB3O.js.map} +0 -0
- /package/{chunk-K56QC4XU.js.map → chunk-4V373IPM.js.map} +0 -0
- /package/{chunk-6JBCB25F.js.map → chunk-624QMD56.js.map} +0 -0
- /package/{chunk-AWYBT46E.js.map → chunk-MKPBFN7W.js.map} +0 -0
- /package/{chunk-IRPVCBEV.js.map → chunk-NOUED6XP.js.map} +0 -0
- /package/{chunk-44MXI6U3.js.map → chunk-PBFD5MP4.js.map} +0 -0
- /package/{chunk-QWSA4UPI.js.map → chunk-SBH7L4UT.js.map} +0 -0
- /package/{chunk-JOBVE3UL.js.map → chunk-ZMTKJ4VW.js.map} +0 -0
- /package/{computer-use-UWLPLYNT.js.map → computer-use-F4VFLO6X.js.map} +0 -0
- /package/{connector-IAV2HAD3.js.map → connector-SWU3H7YL.js.map} +0 -0
- /package/{credit-JYOB7KNE.js.map → credit-ZMXGA5CQ.js.map} +0 -0
- /package/{developer-support-OGHIECZV.js.map → developer-support-IOTX3JWR.js.map} +0 -0
- /package/{doctor-IBOADXQJ.js.map → doctor-DTMFWDXL.js.map} +0 -0
- /package/{generate-5LOGYZX5.js.map → generate-IQUCOIYW.js.map} +0 -0
- /package/{github-D7OXHFVK.js.map → github-AJT3E56L.js.map} +0 -0
- /package/{goal-ZRXFDP3P.js.map → goal-NCK5T57P.js.map} +0 -0
- /package/{host-X3L2I27V.js.map → host-BRKGWZLP.js.map} +0 -0
- /package/{logs-6FL5TYUR.js.map → logs-WZVT4BS7.js.map} +0 -0
- /package/{mail-OOTL5BQV.js.map → mail-QS4HABXH.js.map} +0 -0
- /package/{maps-72KAMGLV.js.map → maps-3X6V34JQ.js.map} +0 -0
- /package/{model-TZQDDCI4.js.map → model-6ETRDASM.js.map} +0 -0
- /package/{model-provider-DZQ2LOIX.js.map → model-provider-XEKOLWZY.js.map} +0 -0
- /package/{org-OPQT5ABR.js.map → org-DKGPME4L.js.map} +0 -0
- /package/{phone-NGCOFB6A.js.map → phone-6455TFON.js.map} +0 -0
- /package/{preference-GMDQ56WR.js.map → preference-2XMANS52.js.map} +0 -0
- /package/{resource-S6BFXUN4.js.map → resource-MIFLTTK6.js.map} +0 -0
- /package/{scrape-O42KQAA2.js.map → scrape-CIP2FZED.js.map} +0 -0
- /package/{search-CXBQKE3F.js.map → search-GCQ55FYS.js.map} +0 -0
- /package/{secret-7POSV4X6.js.map → secret-NVLEVYXQ.js.map} +0 -0
- /package/{slack-KK4MB2CG.js.map → slack-EGYW76W2.js.map} +0 -0
- /package/{teams-44GCGRZI.js.map → teams-2D63XX2R.js.map} +0 -0
- /package/{telegram-EA7E4DDC.js.map → telegram-GQARG3MD.js.map} +0 -0
- /package/{variable-WPLNUUKW.js.map → variable-WMKLX7TF.js.map} +0 -0
- /package/{video-HUOPH4WL.js.map → video-NAUNUYGP.js.map} +0 -0
- /package/{web-Q4AM57LW.js.map → web-7U3YS3KP.js.map} +0 -0
- /package/{web-search-7FUND7UG.js.map → web-search-EIO3GVKH.js.map} +0 -0
- /package/{whoami-TQ3YG2FR.js.map → whoami-QZJAGTDW.js.map} +0 -0
- /package/{workflow-TATKRDOV.js.map → workflow-RMJIYOUB.js.map} +0 -0
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
renderRunCreated,
|
|
37
37
|
require_dist,
|
|
38
38
|
showNextSteps
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-KS62N6VR.js";
|
|
40
40
|
import {
|
|
41
41
|
Qn,
|
|
42
42
|
So
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
prepareStorage,
|
|
75
75
|
searchLogs,
|
|
76
76
|
volumeConfigSchema
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-VUUGKMER.js";
|
|
78
78
|
import "./chunk-LTDQISD7.js";
|
|
79
79
|
import {
|
|
80
80
|
ApiRequestError,
|
|
@@ -88,10 +88,10 @@ import {
|
|
|
88
88
|
saveConfig,
|
|
89
89
|
source_default,
|
|
90
90
|
withErrorHandler
|
|
91
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-UEGRDQR3.js";
|
|
92
92
|
import {
|
|
93
93
|
configureGlobalProxyFromEnv
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-PBFD5MP4.js";
|
|
95
95
|
import "./chunk-LRHXR7JT.js";
|
|
96
96
|
import {
|
|
97
97
|
Command,
|
|
@@ -277,192 +277,11 @@ var setupTokenCommand = new Command().name("setup-token").description("Output au
|
|
|
277
277
|
// src/commands/auth/index.ts
|
|
278
278
|
var authCommand = new Command().name("auth").description("Authenticate vm0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(statusCommand).addCommand(setupTokenCommand);
|
|
279
279
|
|
|
280
|
-
// src/commands/info/index.ts
|
|
281
|
-
init_esm_shims();
|
|
282
|
-
import { existsSync } from "fs";
|
|
283
|
-
import * as os from "os";
|
|
284
|
-
import { join } from "path";
|
|
285
|
-
|
|
286
|
-
// src/lib/utils/update-checker.ts
|
|
287
|
-
init_esm_shims();
|
|
288
|
-
|
|
289
|
-
// src/lib/utils/spawn.ts
|
|
290
|
-
init_esm_shims();
|
|
291
|
-
import { spawn } from "child_process";
|
|
292
|
-
function safeSpawn(command, args, options) {
|
|
293
|
-
const isWindows = process.platform === "win32";
|
|
294
|
-
const resolvedCommand = isWindows ? `${command}.cmd` : command;
|
|
295
|
-
return spawn(resolvedCommand, args, {
|
|
296
|
-
...options,
|
|
297
|
-
shell: isWindows
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/lib/utils/update-checker.ts
|
|
302
|
-
var PACKAGE_NAME = "@vm0/cli";
|
|
303
|
-
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
304
|
-
var TIMEOUT_MS = 5e3;
|
|
305
|
-
var pendingUpgrade = null;
|
|
306
|
-
function detectPackageManager() {
|
|
307
|
-
const execPath = process.argv[1] ?? "";
|
|
308
|
-
if (execPath.includes("pnpm")) {
|
|
309
|
-
return "pnpm";
|
|
310
|
-
}
|
|
311
|
-
if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
|
|
312
|
-
return "bun";
|
|
313
|
-
}
|
|
314
|
-
if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
|
|
315
|
-
return "yarn";
|
|
316
|
-
}
|
|
317
|
-
if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
|
|
318
|
-
execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
|
|
319
|
-
execPath.includes("/.nvm/") || execPath.includes("/.fnm/") || execPath.includes("/.volta/") || execPath.includes("/.nodenv/") || execPath.includes("/.n/") || execPath.includes("/node_modules/") || execPath.includes("\\npm\\") || // Windows: AppData\Roaming\npm
|
|
320
|
-
execPath.includes("\\nodejs\\")) {
|
|
321
|
-
return "npm";
|
|
322
|
-
}
|
|
323
|
-
return "unknown";
|
|
324
|
-
}
|
|
325
|
-
function isAutoUpgradeSupported(pm) {
|
|
326
|
-
return pm === "npm" || pm === "pnpm";
|
|
327
|
-
}
|
|
328
|
-
function getManualUpgradeCommand(pm) {
|
|
329
|
-
switch (pm) {
|
|
330
|
-
case "bun":
|
|
331
|
-
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
332
|
-
case "yarn":
|
|
333
|
-
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
334
|
-
case "pnpm":
|
|
335
|
-
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
336
|
-
case "npm":
|
|
337
|
-
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
338
|
-
case "unknown":
|
|
339
|
-
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
async function getLatestVersion() {
|
|
343
|
-
try {
|
|
344
|
-
const controller = new AbortController();
|
|
345
|
-
const timeoutId = setTimeout(() => {
|
|
346
|
-
return controller.abort();
|
|
347
|
-
}, TIMEOUT_MS);
|
|
348
|
-
const response = await fetch(NPM_REGISTRY_URL, {
|
|
349
|
-
signal: controller.signal
|
|
350
|
-
});
|
|
351
|
-
clearTimeout(timeoutId);
|
|
352
|
-
if (!response.ok) {
|
|
353
|
-
return null;
|
|
354
|
-
}
|
|
355
|
-
const json = await response.json();
|
|
356
|
-
return json.version ?? null;
|
|
357
|
-
} catch {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
function performUpgrade(packageManager) {
|
|
362
|
-
return new Promise((resolve) => {
|
|
363
|
-
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
364
|
-
const child = safeSpawn(packageManager, args, {
|
|
365
|
-
stdio: "inherit"
|
|
366
|
-
});
|
|
367
|
-
child.on("close", (code) => {
|
|
368
|
-
resolve(code === 0);
|
|
369
|
-
});
|
|
370
|
-
child.on("error", () => {
|
|
371
|
-
resolve(false);
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
async function startSilentUpgrade(currentVersion) {
|
|
376
|
-
pendingUpgrade = null;
|
|
377
|
-
const latestVersion = await getLatestVersion();
|
|
378
|
-
if (latestVersion === null || latestVersion === currentVersion) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const packageManager = detectPackageManager();
|
|
382
|
-
if (!isAutoUpgradeSupported(packageManager)) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
const isWindows = process.platform === "win32";
|
|
386
|
-
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
387
|
-
const child = safeSpawn(packageManager, args, {
|
|
388
|
-
stdio: "pipe",
|
|
389
|
-
detached: !isWindows,
|
|
390
|
-
windowsHide: true
|
|
391
|
-
});
|
|
392
|
-
const promise = new Promise((resolve) => {
|
|
393
|
-
child.on("close", (code) => {
|
|
394
|
-
return resolve(code === 0);
|
|
395
|
-
});
|
|
396
|
-
child.on("error", () => {
|
|
397
|
-
return resolve(false);
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
pendingUpgrade = { promise, child, packageManager };
|
|
401
|
-
}
|
|
402
|
-
async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
|
|
403
|
-
if (!pendingUpgrade) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
const { promise, child, packageManager } = pendingUpgrade;
|
|
407
|
-
pendingUpgrade = null;
|
|
408
|
-
const result = await Promise.race([
|
|
409
|
-
promise,
|
|
410
|
-
new Promise((resolve) => {
|
|
411
|
-
setTimeout(() => {
|
|
412
|
-
child.kill();
|
|
413
|
-
resolve(false);
|
|
414
|
-
}, timeout);
|
|
415
|
-
})
|
|
416
|
-
]);
|
|
417
|
-
if (!result) {
|
|
418
|
-
console.log(
|
|
419
|
-
source_default.yellow(
|
|
420
|
-
`
|
|
421
|
-
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
422
|
-
)
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/commands/info/index.ts
|
|
428
|
-
function getConfigPath() {
|
|
429
|
-
return join(os.homedir(), ".vm0", "config.json");
|
|
430
|
-
}
|
|
431
|
-
var infoCommand = new Command().name("info").description("Display environment and debug information").action(async () => {
|
|
432
|
-
console.log(source_default.bold(`VM0 CLI v${"9.244.3"}`));
|
|
433
|
-
console.log();
|
|
434
|
-
const config = await loadConfig();
|
|
435
|
-
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
436
|
-
const hasConfigToken = !!config.token;
|
|
437
|
-
const isAuthenticated = hasEnvToken || hasConfigToken;
|
|
438
|
-
console.log(source_default.bold("Authentication:"));
|
|
439
|
-
if (isAuthenticated) {
|
|
440
|
-
const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
|
|
441
|
-
console.log(` ${source_default.green("\u2713")} Logged in (via ${tokenSource})`);
|
|
442
|
-
} else {
|
|
443
|
-
console.log(` ${source_default.red("\u2717")} Not authenticated`);
|
|
444
|
-
}
|
|
445
|
-
const configExists = existsSync(getConfigPath());
|
|
446
|
-
const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
|
|
447
|
-
console.log(` Config: ${configDisplay}`);
|
|
448
|
-
console.log();
|
|
449
|
-
const apiUrl = await getApiUrl();
|
|
450
|
-
console.log(source_default.bold("API:"));
|
|
451
|
-
console.log(` Host: ${apiUrl}`);
|
|
452
|
-
console.log();
|
|
453
|
-
console.log(source_default.bold("System:"));
|
|
454
|
-
console.log(` Node: ${process.version}`);
|
|
455
|
-
console.log(` Platform: ${process.platform} (${process.arch})`);
|
|
456
|
-
console.log(` OS: ${os.type()} ${os.release()}`);
|
|
457
|
-
console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
|
|
458
|
-
console.log(` Package Manager: ${detectPackageManager()}`);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
280
|
// src/commands/compose/index.ts
|
|
462
281
|
init_esm_shims();
|
|
463
282
|
var import_yaml = __toESM(require_dist(), 1);
|
|
464
283
|
import { readFile as readFile2 } from "fs/promises";
|
|
465
|
-
import { existsSync as
|
|
284
|
+
import { existsSync as existsSync2 } from "fs";
|
|
466
285
|
import { dirname } from "path";
|
|
467
286
|
|
|
468
287
|
// src/lib/domain/yaml-validator.ts
|
|
@@ -526,30 +345,30 @@ var cliComposeSchema = external_exports.object({
|
|
|
526
345
|
}
|
|
527
346
|
}
|
|
528
347
|
});
|
|
529
|
-
function formatInvalidTypeIssue(
|
|
348
|
+
function formatInvalidTypeIssue(path9, issue) {
|
|
530
349
|
const runtimeReceived = Reflect.get(issue, "received");
|
|
531
350
|
const received = typeof runtimeReceived === "string" ? runtimeReceived : void 0;
|
|
532
351
|
const isMissing = received === "undefined" || issue.message.includes("received undefined") || issue.message === "Required";
|
|
533
|
-
if (
|
|
352
|
+
if (path9 === "version" && isMissing) {
|
|
534
353
|
return "Missing config.version";
|
|
535
354
|
}
|
|
536
|
-
if (
|
|
355
|
+
if (path9 === "agents" && isMissing) {
|
|
537
356
|
return "Missing agents object in config";
|
|
538
357
|
}
|
|
539
|
-
if (
|
|
540
|
-
const volumeKey =
|
|
358
|
+
if (path9.startsWith("volumes.") && path9.endsWith(".name")) {
|
|
359
|
+
const volumeKey = path9.split(".")[1];
|
|
541
360
|
return `Volume "${volumeKey}" must have a 'name' field (string)`;
|
|
542
361
|
}
|
|
543
|
-
if (
|
|
544
|
-
const volumeKey =
|
|
362
|
+
if (path9.startsWith("volumes.") && path9.endsWith(".version")) {
|
|
363
|
+
const volumeKey = path9.split(".")[1];
|
|
545
364
|
return `Volume "${volumeKey}" must have a 'version' field (string)`;
|
|
546
365
|
}
|
|
547
366
|
if (issue.expected === "array") {
|
|
548
|
-
const fieldName =
|
|
367
|
+
const fieldName = path9.replace(/^agents\.[^.]+\./, "agent.");
|
|
549
368
|
return `${fieldName} must be an array`;
|
|
550
369
|
}
|
|
551
370
|
if (issue.expected === "string" && received === "number") {
|
|
552
|
-
const fieldName =
|
|
371
|
+
const fieldName = path9.replace(/^agents\.[^.]+\./, "agent.");
|
|
553
372
|
const match = fieldName.match(/^(agent\.[^.]+)\.\d+$/);
|
|
554
373
|
if (match) {
|
|
555
374
|
return `Each entry in ${match[1]?.replace("agent.", "")} must be a string`;
|
|
@@ -560,24 +379,24 @@ function formatInvalidTypeIssue(path10, issue) {
|
|
|
560
379
|
function formatZodError(error) {
|
|
561
380
|
const issue = error.issues[0];
|
|
562
381
|
if (!issue) return "Validation failed";
|
|
563
|
-
const
|
|
382
|
+
const path9 = issue.path.join(".");
|
|
564
383
|
const message = issue.message;
|
|
565
|
-
if (!
|
|
384
|
+
if (!path9) return message;
|
|
566
385
|
if (issue.code === "invalid_type") {
|
|
567
|
-
const formatted = formatInvalidTypeIssue(
|
|
386
|
+
const formatted = formatInvalidTypeIssue(path9, issue);
|
|
568
387
|
if (formatted) return formatted;
|
|
569
388
|
}
|
|
570
|
-
if (issue.code === "invalid_key" &&
|
|
389
|
+
if (issue.code === "invalid_key" && path9.startsWith("agents.")) {
|
|
571
390
|
return "Invalid agent name format. Must be 3-64 characters, letters, numbers, and hyphens only. Must start and end with letter or number.";
|
|
572
391
|
}
|
|
573
|
-
if (message === "Invalid key in record" &&
|
|
392
|
+
if (message === "Invalid key in record" && path9.startsWith("agents.")) {
|
|
574
393
|
return "Invalid agent name format. Must be 3-64 characters, letters, numbers, and hyphens only. Must start and end with letter or number.";
|
|
575
394
|
}
|
|
576
395
|
if (issue.code === "custom") {
|
|
577
396
|
return message;
|
|
578
397
|
}
|
|
579
|
-
if (
|
|
580
|
-
const cleanPath =
|
|
398
|
+
if (path9.startsWith("agents.")) {
|
|
399
|
+
const cleanPath = path9.replace(/^agents\.[^.]+\./, "agent.");
|
|
581
400
|
if (message.startsWith("Invalid input:")) {
|
|
582
401
|
const match = message.match(/expected (\w+), received (\w+)/);
|
|
583
402
|
if (match && match[1] === "string" && match[2] === "number") {
|
|
@@ -589,10 +408,7 @@ function formatZodError(error) {
|
|
|
589
408
|
}
|
|
590
409
|
return `${cleanPath}: ${message}`;
|
|
591
410
|
}
|
|
592
|
-
return `${
|
|
593
|
-
}
|
|
594
|
-
function validateAgentName(name) {
|
|
595
|
-
return cliAgentNameSchema.safeParse(name).success;
|
|
411
|
+
return `${path9}: ${message}`;
|
|
596
412
|
}
|
|
597
413
|
var KNOWN_AGENT_FIELDS = Object.keys(agentDefinitionSchema.shape);
|
|
598
414
|
function levenshteinDistance(a, b) {
|
|
@@ -710,14 +526,14 @@ function validateAgentCompose(config) {
|
|
|
710
526
|
init_esm_shims();
|
|
711
527
|
import * as fs2 from "fs/promises";
|
|
712
528
|
import * as path2 from "path";
|
|
713
|
-
import * as
|
|
529
|
+
import * as os2 from "os";
|
|
714
530
|
|
|
715
531
|
// src/lib/storage/direct-upload.ts
|
|
716
532
|
init_esm_shims();
|
|
717
533
|
import { createHash } from "crypto";
|
|
718
534
|
import * as fs from "fs";
|
|
719
535
|
import * as path from "path";
|
|
720
|
-
import * as
|
|
536
|
+
import * as os from "os";
|
|
721
537
|
async function hashFileStream(filePath) {
|
|
722
538
|
return new Promise((resolve, reject) => {
|
|
723
539
|
const hash = createHash("sha256");
|
|
@@ -770,7 +586,7 @@ async function collectFileMetadata(cwd, files, onProgress) {
|
|
|
770
586
|
return fileEntries;
|
|
771
587
|
}
|
|
772
588
|
async function createArchive(cwd, files) {
|
|
773
|
-
const tmpDir = fs.mkdtempSync(path.join(
|
|
589
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "vm0-"));
|
|
774
590
|
const tarPath = path.join(tmpDir, "archive.tar.gz");
|
|
775
591
|
try {
|
|
776
592
|
const relativePaths = files.map((file) => {
|
|
@@ -924,7 +740,7 @@ async function uploadInstructions(agentName, instructionsFilePath, basePath, fra
|
|
|
924
740
|
const storageName = getInstructionsStorageName(agentName.toLowerCase());
|
|
925
741
|
const absolutePath = path2.isAbsolute(instructionsFilePath) ? instructionsFilePath : path2.join(basePath, instructionsFilePath);
|
|
926
742
|
const content = await fs2.readFile(absolutePath, "utf8");
|
|
927
|
-
const tmpDir = await fs2.mkdtemp(path2.join(
|
|
743
|
+
const tmpDir = await fs2.mkdtemp(path2.join(os2.tmpdir(), "vm0-instructions-"));
|
|
928
744
|
const instructionsDir = path2.join(tmpDir, "instructions");
|
|
929
745
|
await fs2.mkdir(instructionsDir);
|
|
930
746
|
const filename = getInstructionsFilename(framework);
|
|
@@ -941,6 +757,133 @@ async function uploadInstructions(agentName, instructionsFilePath, basePath, fra
|
|
|
941
757
|
}
|
|
942
758
|
}
|
|
943
759
|
|
|
760
|
+
// src/lib/utils/update-checker.ts
|
|
761
|
+
init_esm_shims();
|
|
762
|
+
|
|
763
|
+
// src/lib/utils/spawn.ts
|
|
764
|
+
init_esm_shims();
|
|
765
|
+
import { spawn } from "child_process";
|
|
766
|
+
function safeSpawn(command, args, options) {
|
|
767
|
+
const isWindows = process.platform === "win32";
|
|
768
|
+
const resolvedCommand = isWindows ? `${command}.cmd` : command;
|
|
769
|
+
return spawn(resolvedCommand, args, {
|
|
770
|
+
...options,
|
|
771
|
+
shell: isWindows
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// src/lib/utils/update-checker.ts
|
|
776
|
+
var PACKAGE_NAME = "@vm0/cli";
|
|
777
|
+
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
778
|
+
var TIMEOUT_MS = 5e3;
|
|
779
|
+
var pendingUpgrade = null;
|
|
780
|
+
function detectPackageManager() {
|
|
781
|
+
const execPath = process.argv[1] ?? "";
|
|
782
|
+
if (execPath.includes("pnpm")) {
|
|
783
|
+
return "pnpm";
|
|
784
|
+
}
|
|
785
|
+
if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
|
|
786
|
+
return "bun";
|
|
787
|
+
}
|
|
788
|
+
if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
|
|
789
|
+
return "yarn";
|
|
790
|
+
}
|
|
791
|
+
if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
|
|
792
|
+
execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
|
|
793
|
+
execPath.includes("/.nvm/") || execPath.includes("/.fnm/") || execPath.includes("/.volta/") || execPath.includes("/.nodenv/") || execPath.includes("/.n/") || execPath.includes("/node_modules/") || execPath.includes("\\npm\\") || // Windows: AppData\Roaming\npm
|
|
794
|
+
execPath.includes("\\nodejs\\")) {
|
|
795
|
+
return "npm";
|
|
796
|
+
}
|
|
797
|
+
return "unknown";
|
|
798
|
+
}
|
|
799
|
+
function isAutoUpgradeSupported(pm) {
|
|
800
|
+
return pm === "npm" || pm === "pnpm";
|
|
801
|
+
}
|
|
802
|
+
function getManualUpgradeCommand(pm) {
|
|
803
|
+
switch (pm) {
|
|
804
|
+
case "bun":
|
|
805
|
+
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
806
|
+
case "yarn":
|
|
807
|
+
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
808
|
+
case "pnpm":
|
|
809
|
+
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
810
|
+
case "npm":
|
|
811
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
812
|
+
case "unknown":
|
|
813
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
async function getLatestVersion() {
|
|
817
|
+
try {
|
|
818
|
+
const controller = new AbortController();
|
|
819
|
+
const timeoutId = setTimeout(() => {
|
|
820
|
+
return controller.abort();
|
|
821
|
+
}, TIMEOUT_MS);
|
|
822
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
823
|
+
signal: controller.signal
|
|
824
|
+
});
|
|
825
|
+
clearTimeout(timeoutId);
|
|
826
|
+
if (!response.ok) {
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
const json = await response.json();
|
|
830
|
+
return json.version ?? null;
|
|
831
|
+
} catch {
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async function startSilentUpgrade(currentVersion) {
|
|
836
|
+
pendingUpgrade = null;
|
|
837
|
+
const latestVersion = await getLatestVersion();
|
|
838
|
+
if (latestVersion === null || latestVersion === currentVersion) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const packageManager = detectPackageManager();
|
|
842
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const isWindows = process.platform === "win32";
|
|
846
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
847
|
+
const child = safeSpawn(packageManager, args, {
|
|
848
|
+
stdio: "pipe",
|
|
849
|
+
detached: !isWindows,
|
|
850
|
+
windowsHide: true
|
|
851
|
+
});
|
|
852
|
+
const promise = new Promise((resolve) => {
|
|
853
|
+
child.on("close", (code) => {
|
|
854
|
+
return resolve(code === 0);
|
|
855
|
+
});
|
|
856
|
+
child.on("error", () => {
|
|
857
|
+
return resolve(false);
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
pendingUpgrade = { promise, child, packageManager };
|
|
861
|
+
}
|
|
862
|
+
async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
|
|
863
|
+
if (!pendingUpgrade) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
const { promise, child, packageManager } = pendingUpgrade;
|
|
867
|
+
pendingUpgrade = null;
|
|
868
|
+
const result = await Promise.race([
|
|
869
|
+
promise,
|
|
870
|
+
new Promise((resolve) => {
|
|
871
|
+
setTimeout(() => {
|
|
872
|
+
child.kill();
|
|
873
|
+
resolve(false);
|
|
874
|
+
}, timeout);
|
|
875
|
+
})
|
|
876
|
+
]);
|
|
877
|
+
if (!result) {
|
|
878
|
+
console.log(
|
|
879
|
+
source_default.yellow(
|
|
880
|
+
`
|
|
881
|
+
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
882
|
+
)
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
944
887
|
// src/commands/compose/index.ts
|
|
945
888
|
var DEFAULT_CONFIG_FILE = "vm0.yaml";
|
|
946
889
|
function getSecretsFromComposeContent(content) {
|
|
@@ -960,7 +903,7 @@ function getVarsFromComposeContent(content) {
|
|
|
960
903
|
);
|
|
961
904
|
}
|
|
962
905
|
async function loadAndValidateConfig(configFile) {
|
|
963
|
-
if (!
|
|
906
|
+
if (!existsSync2(configFile)) {
|
|
964
907
|
throw new Error(`Config file not found: ${configFile}`);
|
|
965
908
|
}
|
|
966
909
|
const content = await readFile2(configFile, "utf8");
|
|
@@ -1132,7 +1075,7 @@ var composeCommand = new Command().name("compose").description("Create or update
|
|
|
1132
1075
|
options.autoUpdate = false;
|
|
1133
1076
|
}
|
|
1134
1077
|
if (options.autoUpdate !== false) {
|
|
1135
|
-
await startSilentUpgrade("9.244.
|
|
1078
|
+
await startSilentUpgrade("9.244.5");
|
|
1136
1079
|
}
|
|
1137
1080
|
try {
|
|
1138
1081
|
const { config, agentName, agent, basePath } = await loadAndValidateConfig(resolvedConfigFile);
|
|
@@ -1229,7 +1172,7 @@ var mainRunCommand = new Command().name("run").description("Run an agent").argum
|
|
|
1229
1172
|
withErrorHandler(
|
|
1230
1173
|
async (identifier, prompt, options) => {
|
|
1231
1174
|
if (options.autoUpdate !== false) {
|
|
1232
|
-
await startSilentUpgrade("9.244.
|
|
1175
|
+
await startSilentUpgrade("9.244.5");
|
|
1233
1176
|
}
|
|
1234
1177
|
const { name, version } = parseIdentifier(identifier);
|
|
1235
1178
|
let composeId;
|
|
@@ -1720,7 +1663,7 @@ import path4 from "path";
|
|
|
1720
1663
|
init_esm_shims();
|
|
1721
1664
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
1722
1665
|
import { readFile as readFile3, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
1723
|
-
import { existsSync as
|
|
1666
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1724
1667
|
import path3 from "path";
|
|
1725
1668
|
var CONFIG_DIR = ".vm0";
|
|
1726
1669
|
var CONFIG_FILE = "storage.yaml";
|
|
@@ -1735,9 +1678,9 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
1735
1678
|
const configPath = path3.join(basePath, CONFIG_DIR, CONFIG_FILE);
|
|
1736
1679
|
const legacyConfigPath = path3.join(basePath, CONFIG_DIR, "volume.yaml");
|
|
1737
1680
|
let actualPath = null;
|
|
1738
|
-
if (
|
|
1681
|
+
if (existsSync3(configPath)) {
|
|
1739
1682
|
actualPath = configPath;
|
|
1740
|
-
} else if (
|
|
1683
|
+
} else if (existsSync3(legacyConfigPath)) {
|
|
1741
1684
|
actualPath = legacyConfigPath;
|
|
1742
1685
|
}
|
|
1743
1686
|
if (!actualPath) {
|
|
@@ -1750,15 +1693,15 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
1750
1693
|
}
|
|
1751
1694
|
return config;
|
|
1752
1695
|
}
|
|
1753
|
-
async function writeStorageConfig(storageName, basePath = process.cwd(),
|
|
1696
|
+
async function writeStorageConfig(storageName, basePath = process.cwd(), type = "volume") {
|
|
1754
1697
|
const configDir = path3.join(basePath, CONFIG_DIR);
|
|
1755
1698
|
const configPath = path3.join(configDir, CONFIG_FILE);
|
|
1756
|
-
if (!
|
|
1699
|
+
if (!existsSync3(configDir)) {
|
|
1757
1700
|
await mkdir2(configDir, { recursive: true });
|
|
1758
1701
|
}
|
|
1759
1702
|
const config = {
|
|
1760
1703
|
name: storageName,
|
|
1761
|
-
type
|
|
1704
|
+
type
|
|
1762
1705
|
};
|
|
1763
1706
|
const yamlContent = (0, import_yaml2.stringify)(config);
|
|
1764
1707
|
await writeFile2(configPath, yamlContent, "utf8");
|
|
@@ -1860,7 +1803,7 @@ var pushCommand = new Command().name("push").description("Push local files to cl
|
|
|
1860
1803
|
init_esm_shims();
|
|
1861
1804
|
import path5 from "path";
|
|
1862
1805
|
import * as fs3 from "fs";
|
|
1863
|
-
import * as
|
|
1806
|
+
import * as os3 from "os";
|
|
1864
1807
|
|
|
1865
1808
|
// src/lib/storage/pull-utils.ts
|
|
1866
1809
|
init_esm_shims();
|
|
@@ -1911,7 +1854,7 @@ var pullCommand = new Command().name("pull").description("Pull cloud files to lo
|
|
|
1911
1854
|
const arrayBuffer = await s3Response.arrayBuffer();
|
|
1912
1855
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
1913
1856
|
console.log(source_default.green(`\u2713 Downloaded ${formatBytes(tarBuffer.length)}`));
|
|
1914
|
-
const tmpDir = fs3.mkdtempSync(path5.join(
|
|
1857
|
+
const tmpDir = fs3.mkdtempSync(path5.join(os3.tmpdir(), "vm0-"));
|
|
1915
1858
|
const tarPath = path5.join(tmpDir, "volume.tar.gz");
|
|
1916
1859
|
await fs3.promises.writeFile(tarPath, tarBuffer);
|
|
1917
1860
|
console.log(source_default.dim("Syncing local files..."));
|
|
@@ -2039,9 +1982,9 @@ init_esm_shims();
|
|
|
2039
1982
|
init_esm_shims();
|
|
2040
1983
|
import path6 from "path";
|
|
2041
1984
|
import * as fs4 from "fs";
|
|
2042
|
-
import * as
|
|
2043
|
-
async function cloneStorage(name,
|
|
2044
|
-
const typeLabel =
|
|
1985
|
+
import * as os4 from "os";
|
|
1986
|
+
async function cloneStorage(name, type, destination, options = {}) {
|
|
1987
|
+
const typeLabel = type;
|
|
2045
1988
|
const dirStatus = checkDirectoryStatus(destination);
|
|
2046
1989
|
if (dirStatus.exists && !dirStatus.empty) {
|
|
2047
1990
|
throw new Error(`Directory "${destination}" is not empty`);
|
|
@@ -2049,13 +1992,13 @@ async function cloneStorage(name, type2, destination, options = {}) {
|
|
|
2049
1992
|
console.log(source_default.dim(`Checking remote ${typeLabel}...`));
|
|
2050
1993
|
const downloadInfo = await getStorageDownload({
|
|
2051
1994
|
name,
|
|
2052
|
-
type
|
|
1995
|
+
type,
|
|
2053
1996
|
version: options.version
|
|
2054
1997
|
});
|
|
2055
1998
|
console.log(source_default.dim(`Creating directory: ${destination}/`));
|
|
2056
1999
|
await fs4.promises.mkdir(destination, { recursive: true });
|
|
2057
2000
|
if ("empty" in downloadInfo) {
|
|
2058
|
-
await writeStorageConfig(name, destination,
|
|
2001
|
+
await writeStorageConfig(name, destination, type);
|
|
2059
2002
|
console.log(source_default.green(`\u2713 Cloned empty ${typeLabel}: ${name}`));
|
|
2060
2003
|
console.log(source_default.dim(`\u2713 Initialized .vm0/storage.yaml`));
|
|
2061
2004
|
return {
|
|
@@ -2078,7 +2021,7 @@ async function cloneStorage(name, type2, destination, options = {}) {
|
|
|
2078
2021
|
const arrayBuffer = await s3Response.arrayBuffer();
|
|
2079
2022
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
2080
2023
|
console.log(source_default.green(`\u2713 Downloaded ${formatBytes(tarBuffer.length)}`));
|
|
2081
|
-
const tmpDir = fs4.mkdtempSync(path6.join(
|
|
2024
|
+
const tmpDir = fs4.mkdtempSync(path6.join(os4.tmpdir(), "vm0-clone-"));
|
|
2082
2025
|
const tarPath = path6.join(tmpDir, "archive.tar.gz");
|
|
2083
2026
|
await fs4.promises.writeFile(tarPath, tarBuffer);
|
|
2084
2027
|
const files = await listTarFiles(tarPath);
|
|
@@ -2091,7 +2034,7 @@ async function cloneStorage(name, type2, destination, options = {}) {
|
|
|
2091
2034
|
await fs4.promises.unlink(tarPath);
|
|
2092
2035
|
await fs4.promises.rmdir(tmpDir);
|
|
2093
2036
|
console.log(source_default.green(`\u2713 Extracted ${files.length} files`));
|
|
2094
|
-
await writeStorageConfig(name, destination,
|
|
2037
|
+
await writeStorageConfig(name, destination, type);
|
|
2095
2038
|
console.log(source_default.green(`\u2713 Initialized .vm0/storage.yaml`));
|
|
2096
2039
|
return {
|
|
2097
2040
|
success: true,
|
|
@@ -2242,7 +2185,7 @@ var pushCommand2 = new Command().name("push").description("Push local files to c
|
|
|
2242
2185
|
init_esm_shims();
|
|
2243
2186
|
import path8 from "path";
|
|
2244
2187
|
import * as fs5 from "fs";
|
|
2245
|
-
import * as
|
|
2188
|
+
import * as os5 from "os";
|
|
2246
2189
|
var pullCommand2 = new Command().name("pull").description("Pull cloud artifact to local directory").argument("[versionId]", "Version ID to pull (default: latest)").action(
|
|
2247
2190
|
withErrorHandler(async (versionId) => {
|
|
2248
2191
|
const cwd = process.cwd();
|
|
@@ -2285,7 +2228,7 @@ var pullCommand2 = new Command().name("pull").description("Pull cloud artifact t
|
|
|
2285
2228
|
const arrayBuffer = await s3Response.arrayBuffer();
|
|
2286
2229
|
const tarBuffer = Buffer.from(arrayBuffer);
|
|
2287
2230
|
console.log(source_default.green(`\u2713 Downloaded ${formatBytes(tarBuffer.length)}`));
|
|
2288
|
-
const tmpDir = fs5.mkdtempSync(path8.join(
|
|
2231
|
+
const tmpDir = fs5.mkdtempSync(path8.join(os5.tmpdir(), "vm0-"));
|
|
2289
2232
|
const tarPath = path8.join(tmpDir, "artifact.tar.gz");
|
|
2290
2233
|
await fs5.promises.writeFile(tarPath, tarBuffer);
|
|
2291
2234
|
console.log(source_default.dim("Syncing local files..."));
|
|
@@ -2990,155 +2933,6 @@ async function showNetworkLogs(runId, options) {
|
|
|
2990
2933
|
}
|
|
2991
2934
|
}
|
|
2992
2935
|
|
|
2993
|
-
// src/commands/init/index.ts
|
|
2994
|
-
init_esm_shims();
|
|
2995
|
-
import path9 from "path";
|
|
2996
|
-
import { existsSync as existsSync5 } from "fs";
|
|
2997
|
-
import { writeFile as writeFile3 } from "fs/promises";
|
|
2998
|
-
var VM0_YAML_FILE = "vm0.yaml";
|
|
2999
|
-
var AGENTS_MD_FILE = "AGENTS.md";
|
|
3000
|
-
function generateVm0Yaml(agentName) {
|
|
3001
|
-
return `version: "1.0"
|
|
3002
|
-
|
|
3003
|
-
agents:
|
|
3004
|
-
${agentName}:
|
|
3005
|
-
framework: claude-code
|
|
3006
|
-
# Build agentic workflow using natural language
|
|
3007
|
-
instructions: AGENTS.md
|
|
3008
|
-
`;
|
|
3009
|
-
}
|
|
3010
|
-
function generateAgentsMd() {
|
|
3011
|
-
return `# Agent Instructions
|
|
3012
|
-
|
|
3013
|
-
You are a HackerNews AI content curator.
|
|
3014
|
-
|
|
3015
|
-
## Workflow
|
|
3016
|
-
|
|
3017
|
-
1. Go to HackerNews and read the top 10 articles
|
|
3018
|
-
2. Find and extract AI-related content from these articles
|
|
3019
|
-
3. Summarize the findings into a X (Twitter) post format
|
|
3020
|
-
4. Write the summary to content.md
|
|
3021
|
-
`;
|
|
3022
|
-
}
|
|
3023
|
-
function checkExistingFiles() {
|
|
3024
|
-
const existingFiles = [];
|
|
3025
|
-
if (existsSync5(VM0_YAML_FILE)) existingFiles.push(VM0_YAML_FILE);
|
|
3026
|
-
if (existsSync5(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
|
|
3027
|
-
return existingFiles;
|
|
3028
|
-
}
|
|
3029
|
-
var initCommand3 = new Command().name("init").description("Initialize a new VM0 project in the current directory").option("-f, --force", "Overwrite existing files").option("-n, --name <name>", "Agent name (required in non-interactive mode)").action(
|
|
3030
|
-
withErrorHandler(async (options) => {
|
|
3031
|
-
const existingFiles = checkExistingFiles();
|
|
3032
|
-
if (existingFiles.length > 0 && !options.force) {
|
|
3033
|
-
throw new Error(`${existingFiles.join(", ")} already exists`, {
|
|
3034
|
-
cause: new Error("To overwrite: vm0 init --force")
|
|
3035
|
-
});
|
|
3036
|
-
}
|
|
3037
|
-
let agentName;
|
|
3038
|
-
if (options.name) {
|
|
3039
|
-
agentName = options.name.trim();
|
|
3040
|
-
} else if (!isInteractive()) {
|
|
3041
|
-
throw new Error("--name flag is required in non-interactive mode", {
|
|
3042
|
-
cause: new Error("Usage: vm0 init --name <agent-name>")
|
|
3043
|
-
});
|
|
3044
|
-
} else {
|
|
3045
|
-
const dirName = path9.basename(process.cwd());
|
|
3046
|
-
const defaultName = validateAgentName(dirName) ? dirName : void 0;
|
|
3047
|
-
const name = await promptText(
|
|
3048
|
-
"Enter agent name",
|
|
3049
|
-
defaultName,
|
|
3050
|
-
(value) => {
|
|
3051
|
-
if (!validateAgentName(value)) {
|
|
3052
|
-
return "Must be 3-64 characters, alphanumeric and hyphens, start/end with letter or number";
|
|
3053
|
-
}
|
|
3054
|
-
return true;
|
|
3055
|
-
}
|
|
3056
|
-
);
|
|
3057
|
-
if (name === void 0) {
|
|
3058
|
-
console.log(source_default.dim("Cancelled"));
|
|
3059
|
-
return;
|
|
3060
|
-
}
|
|
3061
|
-
agentName = name;
|
|
3062
|
-
}
|
|
3063
|
-
if (!agentName || !validateAgentName(agentName)) {
|
|
3064
|
-
throw new Error("Invalid agent name", {
|
|
3065
|
-
cause: new Error(
|
|
3066
|
-
"Must be 3-64 characters, alphanumeric and hyphens only, start and end with letter or number"
|
|
3067
|
-
)
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
await writeFile3(VM0_YAML_FILE, generateVm0Yaml(agentName));
|
|
3071
|
-
const vm0Status = existingFiles.includes(VM0_YAML_FILE) ? " (overwritten)" : "";
|
|
3072
|
-
console.log(source_default.green(`\u2713 Created ${VM0_YAML_FILE}${vm0Status}`));
|
|
3073
|
-
await writeFile3(AGENTS_MD_FILE, generateAgentsMd());
|
|
3074
|
-
const agentsStatus = existingFiles.includes(AGENTS_MD_FILE) ? " (overwritten)" : "";
|
|
3075
|
-
console.log(source_default.green(`\u2713 Created ${AGENTS_MD_FILE}${agentsStatus}`));
|
|
3076
|
-
console.log();
|
|
3077
|
-
console.log("Next steps:");
|
|
3078
|
-
console.log(` 1. Log in to VM0: ${source_default.cyan("vm0 auth login")}`);
|
|
3079
|
-
console.log(
|
|
3080
|
-
` 2. Edit ${source_default.cyan("AGENTS.md")} to customize your agent's workflow`
|
|
3081
|
-
);
|
|
3082
|
-
console.log(
|
|
3083
|
-
` 3. Run your agent: ${source_default.cyan(`vm0 run --secrets CLAUDE_CODE_OAUTH_TOKEN=<token> "let's start working"`)}`
|
|
3084
|
-
);
|
|
3085
|
-
})
|
|
3086
|
-
);
|
|
3087
|
-
|
|
3088
|
-
// src/commands/upgrade/index.ts
|
|
3089
|
-
init_esm_shims();
|
|
3090
|
-
var upgradeCommand = new Command().name("upgrade").description("Upgrade vm0 CLI to the latest version").action(
|
|
3091
|
-
withErrorHandler(async () => {
|
|
3092
|
-
console.log("Checking for updates...");
|
|
3093
|
-
const latestVersion = await getLatestVersion();
|
|
3094
|
-
if (latestVersion === null) {
|
|
3095
|
-
throw new Error("Could not check for updates. Please try again later.");
|
|
3096
|
-
}
|
|
3097
|
-
if (latestVersion === "9.244.3") {
|
|
3098
|
-
console.log(source_default.green(`\u2713 Already up to date (${"9.244.3"})`));
|
|
3099
|
-
return;
|
|
3100
|
-
}
|
|
3101
|
-
console.log(
|
|
3102
|
-
source_default.yellow(
|
|
3103
|
-
`Current version: ${"9.244.3"} -> Latest version: ${latestVersion}`
|
|
3104
|
-
)
|
|
3105
|
-
);
|
|
3106
|
-
console.log();
|
|
3107
|
-
const packageManager = detectPackageManager();
|
|
3108
|
-
if (!isAutoUpgradeSupported(packageManager)) {
|
|
3109
|
-
if (packageManager === "unknown") {
|
|
3110
|
-
console.log(
|
|
3111
|
-
source_default.yellow(
|
|
3112
|
-
"Could not detect your package manager for auto-upgrade."
|
|
3113
|
-
)
|
|
3114
|
-
);
|
|
3115
|
-
} else {
|
|
3116
|
-
console.log(
|
|
3117
|
-
source_default.yellow(
|
|
3118
|
-
`Auto-upgrade is not supported for ${packageManager}.`
|
|
3119
|
-
)
|
|
3120
|
-
);
|
|
3121
|
-
}
|
|
3122
|
-
console.log(source_default.yellow("Please upgrade manually:"));
|
|
3123
|
-
console.log(source_default.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
3124
|
-
return;
|
|
3125
|
-
}
|
|
3126
|
-
console.log(`Upgrading via ${packageManager}...`);
|
|
3127
|
-
const success = await performUpgrade(packageManager);
|
|
3128
|
-
if (success) {
|
|
3129
|
-
console.log(
|
|
3130
|
-
source_default.green(`\u2713 Upgraded from ${"9.244.3"} to ${latestVersion}`)
|
|
3131
|
-
);
|
|
3132
|
-
return;
|
|
3133
|
-
}
|
|
3134
|
-
throw new Error("Upgrade failed", {
|
|
3135
|
-
cause: new Error(
|
|
3136
|
-
`Please run manually: ${getManualUpgradeCommand(packageManager)}`
|
|
3137
|
-
)
|
|
3138
|
-
});
|
|
3139
|
-
})
|
|
3140
|
-
);
|
|
3141
|
-
|
|
3142
2936
|
// src/commands/whoami.ts
|
|
3143
2937
|
init_esm_shims();
|
|
3144
2938
|
function isInsideSandbox() {
|
|
@@ -3194,16 +2988,13 @@ var whoamiCommand = new Command().name("whoami").description("Show current ident
|
|
|
3194
2988
|
|
|
3195
2989
|
// src/index.ts
|
|
3196
2990
|
var program = new Command();
|
|
3197
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.244.
|
|
2991
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.244.5");
|
|
3198
2992
|
program.addCommand(authCommand);
|
|
3199
|
-
program.addCommand(infoCommand);
|
|
3200
2993
|
program.addCommand(composeCommand);
|
|
3201
2994
|
program.addCommand(runCommand);
|
|
3202
2995
|
program.addCommand(volumeCommand);
|
|
3203
2996
|
program.addCommand(artifactCommand);
|
|
3204
2997
|
program.addCommand(logsCommand);
|
|
3205
|
-
program.addCommand(initCommand3);
|
|
3206
|
-
program.addCommand(upgradeCommand);
|
|
3207
2998
|
program.addCommand(whoamiCommand);
|
|
3208
2999
|
if (process.argv[1]?.endsWith("index.js") || process.argv[1]?.endsWith("index.ts") || process.argv[1]?.endsWith("vm0")) {
|
|
3209
3000
|
await configureGlobalProxyFromEnv();
|