@vm0/cli 9.27.1 → 9.28.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 +411 -367
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ if (DSN) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
Sentry.setContext("cli", {
|
|
64
|
-
version: "9.
|
|
64
|
+
version: "9.28.0",
|
|
65
65
|
command: process.argv.slice(2).join(" ")
|
|
66
66
|
});
|
|
67
67
|
Sentry.setContext("runtime", {
|
|
@@ -292,22 +292,242 @@ var authCommand = new Command5().name("auth").description("Authenticate vm0").ad
|
|
|
292
292
|
|
|
293
293
|
// src/commands/info/index.ts
|
|
294
294
|
import { Command as Command6 } from "commander";
|
|
295
|
+
import chalk3 from "chalk";
|
|
296
|
+
import { existsSync as existsSync2 } from "fs";
|
|
297
|
+
import { homedir as homedir2, release as release2, type } from "os";
|
|
298
|
+
import { join as join2 } from "path";
|
|
299
|
+
|
|
300
|
+
// src/lib/utils/update-checker.ts
|
|
301
|
+
import { spawn } from "child_process";
|
|
295
302
|
import chalk2 from "chalk";
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
var PACKAGE_NAME = "@vm0/cli";
|
|
304
|
+
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
305
|
+
var TIMEOUT_MS = 5e3;
|
|
306
|
+
var pendingUpgrade = null;
|
|
307
|
+
function detectPackageManager() {
|
|
308
|
+
const execPath = process.argv[1] ?? "";
|
|
309
|
+
if (execPath.includes("pnpm")) {
|
|
310
|
+
return "pnpm";
|
|
311
|
+
}
|
|
312
|
+
if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
|
|
313
|
+
return "bun";
|
|
314
|
+
}
|
|
315
|
+
if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
|
|
316
|
+
return "yarn";
|
|
317
|
+
}
|
|
318
|
+
if (execPath.includes("/usr/local/") || // Homebrew on Intel Mac
|
|
319
|
+
execPath.includes("/opt/homebrew/") || // Homebrew on arm64 Mac
|
|
320
|
+
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
|
|
321
|
+
execPath.includes("\\nodejs\\")) {
|
|
322
|
+
return "npm";
|
|
323
|
+
}
|
|
324
|
+
return "unknown";
|
|
325
|
+
}
|
|
326
|
+
function isAutoUpgradeSupported(pm) {
|
|
327
|
+
return pm === "npm" || pm === "pnpm";
|
|
328
|
+
}
|
|
329
|
+
function getManualUpgradeCommand(pm) {
|
|
330
|
+
switch (pm) {
|
|
331
|
+
case "bun":
|
|
332
|
+
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
333
|
+
case "yarn":
|
|
334
|
+
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
335
|
+
case "pnpm":
|
|
336
|
+
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
337
|
+
case "npm":
|
|
338
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
339
|
+
case "unknown":
|
|
340
|
+
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function escapeForShell(str) {
|
|
344
|
+
return `"${str.replace(/"/g, '\\"')}"`;
|
|
345
|
+
}
|
|
346
|
+
function buildRerunCommand(prompt) {
|
|
347
|
+
if (prompt) {
|
|
348
|
+
return `vm0 cook ${escapeForShell(prompt)}`;
|
|
349
|
+
}
|
|
350
|
+
return "vm0 cook";
|
|
351
|
+
}
|
|
352
|
+
async function getLatestVersion() {
|
|
353
|
+
try {
|
|
354
|
+
const controller = new AbortController();
|
|
355
|
+
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
356
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
357
|
+
signal: controller.signal
|
|
358
|
+
});
|
|
359
|
+
clearTimeout(timeoutId);
|
|
360
|
+
if (!response.ok) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
const json = await response.json();
|
|
364
|
+
return json.version ?? null;
|
|
365
|
+
} catch {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function performUpgrade(packageManager) {
|
|
370
|
+
return new Promise((resolve) => {
|
|
371
|
+
const isWindows = process.platform === "win32";
|
|
372
|
+
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
373
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
374
|
+
const child = spawn(command, args, {
|
|
375
|
+
stdio: "inherit",
|
|
376
|
+
shell: isWindows
|
|
377
|
+
});
|
|
378
|
+
child.on("close", (code) => {
|
|
379
|
+
resolve(code === 0);
|
|
380
|
+
});
|
|
381
|
+
child.on("error", () => {
|
|
382
|
+
resolve(false);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async function checkAndUpgrade(currentVersion, prompt) {
|
|
387
|
+
const latestVersion = await getLatestVersion();
|
|
388
|
+
if (latestVersion === null) {
|
|
389
|
+
console.log(chalk2.yellow("\u26A0 Could not check for updates"));
|
|
390
|
+
console.log();
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
if (latestVersion === currentVersion) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
console.log(chalk2.yellow("vm0 is currently in beta."));
|
|
397
|
+
console.log(
|
|
398
|
+
chalk2.yellow(
|
|
399
|
+
`Current version: ${currentVersion} -> Latest version: ${latestVersion}`
|
|
400
|
+
)
|
|
401
|
+
);
|
|
402
|
+
console.log(
|
|
403
|
+
chalk2.yellow(
|
|
404
|
+
"Please always use the latest version for best compatibility."
|
|
405
|
+
)
|
|
406
|
+
);
|
|
407
|
+
console.log();
|
|
408
|
+
const packageManager = detectPackageManager();
|
|
409
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
410
|
+
if (packageManager === "unknown") {
|
|
411
|
+
console.log(
|
|
412
|
+
chalk2.yellow("Could not detect your package manager for auto-upgrade.")
|
|
413
|
+
);
|
|
414
|
+
} else {
|
|
415
|
+
console.log(
|
|
416
|
+
chalk2.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
console.log(chalk2.yellow("Please upgrade manually:"));
|
|
420
|
+
console.log(chalk2.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
421
|
+
console.log();
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
console.log(`Upgrading via ${packageManager}...`);
|
|
425
|
+
const success = await performUpgrade(packageManager);
|
|
426
|
+
if (success) {
|
|
427
|
+
console.log(chalk2.green(`Upgraded to ${latestVersion}`));
|
|
428
|
+
console.log();
|
|
429
|
+
console.log("To continue, run:");
|
|
430
|
+
console.log(chalk2.cyan(` ${buildRerunCommand(prompt)}`));
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
console.error();
|
|
434
|
+
console.error(chalk2.red("\u2717 Upgrade failed. Please run manually:"));
|
|
435
|
+
console.error(chalk2.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
436
|
+
console.error();
|
|
437
|
+
console.error("Then re-run:");
|
|
438
|
+
console.error(chalk2.cyan(` ${buildRerunCommand(prompt)}`));
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
async function startSilentUpgrade(currentVersion) {
|
|
442
|
+
pendingUpgrade = null;
|
|
443
|
+
const latestVersion = await getLatestVersion();
|
|
444
|
+
if (latestVersion === null || latestVersion === currentVersion) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const packageManager = detectPackageManager();
|
|
448
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const isWindows = process.platform === "win32";
|
|
452
|
+
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
453
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
454
|
+
const child = spawn(command, args, {
|
|
455
|
+
stdio: "pipe",
|
|
456
|
+
// Capture output instead of inheriting
|
|
457
|
+
shell: isWindows,
|
|
458
|
+
detached: !isWindows,
|
|
459
|
+
// Detach on non-Windows
|
|
460
|
+
windowsHide: true
|
|
461
|
+
});
|
|
462
|
+
const promise = new Promise((resolve) => {
|
|
463
|
+
child.on("close", (code) => resolve(code === 0));
|
|
464
|
+
child.on("error", () => resolve(false));
|
|
465
|
+
});
|
|
466
|
+
pendingUpgrade = { promise, child, packageManager };
|
|
467
|
+
}
|
|
468
|
+
async function waitForSilentUpgrade(timeout = TIMEOUT_MS) {
|
|
469
|
+
if (!pendingUpgrade) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const { promise, child, packageManager } = pendingUpgrade;
|
|
473
|
+
pendingUpgrade = null;
|
|
474
|
+
const result = await Promise.race([
|
|
475
|
+
promise,
|
|
476
|
+
new Promise((resolve) => {
|
|
477
|
+
setTimeout(() => {
|
|
478
|
+
child.kill();
|
|
479
|
+
resolve(false);
|
|
480
|
+
}, timeout);
|
|
481
|
+
})
|
|
482
|
+
]);
|
|
483
|
+
if (!result) {
|
|
484
|
+
console.log(
|
|
485
|
+
chalk2.yellow(
|
|
486
|
+
`
|
|
487
|
+
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
488
|
+
)
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/commands/info/index.ts
|
|
494
|
+
var CONFIG_PATH = join2(homedir2(), ".vm0", "config.json");
|
|
495
|
+
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
496
|
+
console.log(chalk3.bold(`VM0 CLI v${"9.28.0"}`));
|
|
497
|
+
console.log();
|
|
498
|
+
const config = await loadConfig();
|
|
499
|
+
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
500
|
+
const hasConfigToken = !!config.token;
|
|
501
|
+
const isAuthenticated2 = hasEnvToken || hasConfigToken;
|
|
502
|
+
console.log(chalk3.bold("Authentication:"));
|
|
503
|
+
if (isAuthenticated2) {
|
|
504
|
+
const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
|
|
505
|
+
console.log(` ${chalk3.green("\u2713")} Logged in (via ${tokenSource})`);
|
|
506
|
+
} else {
|
|
507
|
+
console.log(` ${chalk3.red("\u2717")} Not authenticated`);
|
|
508
|
+
}
|
|
509
|
+
const configExists = existsSync2(CONFIG_PATH);
|
|
510
|
+
const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
|
|
511
|
+
console.log(` Config: ${configDisplay}`);
|
|
512
|
+
console.log();
|
|
301
513
|
const apiUrl = await getApiUrl();
|
|
302
|
-
console.log(
|
|
514
|
+
console.log(chalk3.bold("API:"));
|
|
515
|
+
console.log(` Host: ${apiUrl}`);
|
|
516
|
+
console.log();
|
|
517
|
+
console.log(chalk3.bold("System:"));
|
|
518
|
+
console.log(` Node: ${process.version}`);
|
|
519
|
+
console.log(` Platform: ${process.platform} (${process.arch})`);
|
|
520
|
+
console.log(` OS: ${type()} ${release2()}`);
|
|
521
|
+
console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
|
|
522
|
+
console.log(` Package Manager: ${detectPackageManager()}`);
|
|
303
523
|
});
|
|
304
524
|
|
|
305
525
|
// src/commands/compose/index.ts
|
|
306
526
|
import { Command as Command7, Option } from "commander";
|
|
307
527
|
import chalk4 from "chalk";
|
|
308
528
|
import { readFile as readFile4, rm as rm3 } from "fs/promises";
|
|
309
|
-
import { existsSync as
|
|
310
|
-
import { dirname as dirname2, join as
|
|
529
|
+
import { existsSync as existsSync5 } from "fs";
|
|
530
|
+
import { dirname as dirname2, join as join7 } from "path";
|
|
311
531
|
import { parse as parseYaml2 } from "yaml";
|
|
312
532
|
|
|
313
533
|
// ../../packages/core/src/variable-expander.ts
|
|
@@ -2390,44 +2610,44 @@ var modelProviderTypeSchema = z16.enum([
|
|
|
2390
2610
|
"aws-bedrock"
|
|
2391
2611
|
]);
|
|
2392
2612
|
var modelProviderFrameworkSchema = z16.enum(["claude-code", "codex"]);
|
|
2393
|
-
function hasAuthMethods(
|
|
2394
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2613
|
+
function hasAuthMethods(type2) {
|
|
2614
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2395
2615
|
return "authMethods" in config;
|
|
2396
2616
|
}
|
|
2397
|
-
function getAuthMethodsForType(
|
|
2398
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2617
|
+
function getAuthMethodsForType(type2) {
|
|
2618
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2399
2619
|
return "authMethods" in config ? config.authMethods : void 0;
|
|
2400
2620
|
}
|
|
2401
|
-
function getDefaultAuthMethod(
|
|
2402
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2621
|
+
function getDefaultAuthMethod(type2) {
|
|
2622
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2403
2623
|
return "defaultAuthMethod" in config ? config.defaultAuthMethod : void 0;
|
|
2404
2624
|
}
|
|
2405
|
-
function getSecretsForAuthMethod(
|
|
2406
|
-
const authMethods = getAuthMethodsForType(
|
|
2625
|
+
function getSecretsForAuthMethod(type2, authMethod) {
|
|
2626
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
2407
2627
|
if (!authMethods || !(authMethod in authMethods)) {
|
|
2408
2628
|
return void 0;
|
|
2409
2629
|
}
|
|
2410
2630
|
const method = authMethods[authMethod];
|
|
2411
2631
|
return method?.secrets;
|
|
2412
2632
|
}
|
|
2413
|
-
function getModels(
|
|
2414
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2633
|
+
function getModels(type2) {
|
|
2634
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2415
2635
|
return "models" in config ? config.models : void 0;
|
|
2416
2636
|
}
|
|
2417
|
-
function getDefaultModel(
|
|
2418
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2637
|
+
function getDefaultModel(type2) {
|
|
2638
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2419
2639
|
return "defaultModel" in config ? config.defaultModel : void 0;
|
|
2420
2640
|
}
|
|
2421
|
-
function hasModelSelection(
|
|
2422
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2641
|
+
function hasModelSelection(type2) {
|
|
2642
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2423
2643
|
return "models" in config && config.models.length > 0 || "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2424
2644
|
}
|
|
2425
|
-
function allowsCustomModel(
|
|
2426
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2645
|
+
function allowsCustomModel(type2) {
|
|
2646
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2427
2647
|
return "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2428
2648
|
}
|
|
2429
|
-
function getCustomModelPlaceholder(
|
|
2430
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2649
|
+
function getCustomModelPlaceholder(type2) {
|
|
2650
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2431
2651
|
return "customModelPlaceholder" in config ? config.customModelPlaceholder : void 0;
|
|
2432
2652
|
}
|
|
2433
2653
|
var modelProviderResponseSchema = z16.object({
|
|
@@ -3263,8 +3483,8 @@ var CONNECTOR_TYPES = {
|
|
|
3263
3483
|
var connectorTypeSchema = z24.enum(["github"]);
|
|
3264
3484
|
function getConnectorDerivedNames(secretName) {
|
|
3265
3485
|
const allTypes = Object.keys(CONNECTOR_TYPES);
|
|
3266
|
-
for (const
|
|
3267
|
-
const config = CONNECTOR_TYPES[
|
|
3486
|
+
for (const type2 of allTypes) {
|
|
3487
|
+
const config = CONNECTOR_TYPES[type2];
|
|
3268
3488
|
const authMethods = config.authMethods;
|
|
3269
3489
|
let found = false;
|
|
3270
3490
|
for (const method of Object.values(authMethods)) {
|
|
@@ -4578,44 +4798,44 @@ async function upsertModelProvider(body) {
|
|
|
4578
4798
|
}
|
|
4579
4799
|
handleError(result, "Failed to set model provider");
|
|
4580
4800
|
}
|
|
4581
|
-
async function checkModelProviderSecret(
|
|
4801
|
+
async function checkModelProviderSecret(type2) {
|
|
4582
4802
|
const config = await getClientConfig();
|
|
4583
4803
|
const client = initClient9(modelProvidersCheckContract, config);
|
|
4584
4804
|
const result = await client.check({
|
|
4585
|
-
params: { type }
|
|
4805
|
+
params: { type: type2 }
|
|
4586
4806
|
});
|
|
4587
4807
|
if (result.status === 200) {
|
|
4588
4808
|
return result.body;
|
|
4589
4809
|
}
|
|
4590
4810
|
handleError(result, "Failed to check secret");
|
|
4591
4811
|
}
|
|
4592
|
-
async function deleteModelProvider(
|
|
4812
|
+
async function deleteModelProvider(type2) {
|
|
4593
4813
|
const config = await getClientConfig();
|
|
4594
4814
|
const client = initClient9(modelProvidersByTypeContract, config);
|
|
4595
4815
|
const result = await client.delete({
|
|
4596
|
-
params: { type }
|
|
4816
|
+
params: { type: type2 }
|
|
4597
4817
|
});
|
|
4598
4818
|
if (result.status === 204) {
|
|
4599
4819
|
return;
|
|
4600
4820
|
}
|
|
4601
|
-
handleError(result, `Model provider "${
|
|
4821
|
+
handleError(result, `Model provider "${type2}" not found`);
|
|
4602
4822
|
}
|
|
4603
|
-
async function setModelProviderDefault(
|
|
4823
|
+
async function setModelProviderDefault(type2) {
|
|
4604
4824
|
const config = await getClientConfig();
|
|
4605
4825
|
const client = initClient9(modelProvidersSetDefaultContract, config);
|
|
4606
4826
|
const result = await client.setDefault({
|
|
4607
|
-
params: { type }
|
|
4827
|
+
params: { type: type2 }
|
|
4608
4828
|
});
|
|
4609
4829
|
if (result.status === 200) {
|
|
4610
4830
|
return result.body;
|
|
4611
4831
|
}
|
|
4612
4832
|
handleError(result, "Failed to set default model provider");
|
|
4613
4833
|
}
|
|
4614
|
-
async function updateModelProviderModel(
|
|
4834
|
+
async function updateModelProviderModel(type2, selectedModel) {
|
|
4615
4835
|
const config = await getClientConfig();
|
|
4616
4836
|
const client = initClient9(modelProvidersUpdateModelContract, config);
|
|
4617
4837
|
const result = await client.updateModel({
|
|
4618
|
-
params: { type },
|
|
4838
|
+
params: { type: type2 },
|
|
4619
4839
|
body: { selectedModel }
|
|
4620
4840
|
});
|
|
4621
4841
|
if (result.status === 200) {
|
|
@@ -4635,22 +4855,22 @@ async function listConnectors() {
|
|
|
4635
4855
|
}
|
|
4636
4856
|
handleError(result, "Failed to list connectors");
|
|
4637
4857
|
}
|
|
4638
|
-
async function deleteConnector(
|
|
4858
|
+
async function deleteConnector(type2) {
|
|
4639
4859
|
const config = await getClientConfig();
|
|
4640
4860
|
const client = initClient10(connectorsByTypeContract, config);
|
|
4641
4861
|
const result = await client.delete({
|
|
4642
|
-
params: { type }
|
|
4862
|
+
params: { type: type2 }
|
|
4643
4863
|
});
|
|
4644
4864
|
if (result.status === 204) {
|
|
4645
4865
|
return;
|
|
4646
4866
|
}
|
|
4647
|
-
handleError(result, `Connector "${
|
|
4867
|
+
handleError(result, `Connector "${type2}" not found`);
|
|
4648
4868
|
}
|
|
4649
|
-
async function getConnector(
|
|
4869
|
+
async function getConnector(type2) {
|
|
4650
4870
|
const config = await getClientConfig();
|
|
4651
4871
|
const client = initClient10(connectorsByTypeContract, config);
|
|
4652
4872
|
const result = await client.get({
|
|
4653
|
-
params: { type }
|
|
4873
|
+
params: { type: type2 }
|
|
4654
4874
|
});
|
|
4655
4875
|
if (result.status === 200) {
|
|
4656
4876
|
return result.body;
|
|
@@ -4658,7 +4878,7 @@ async function getConnector(type) {
|
|
|
4658
4878
|
if (result.status === 404) {
|
|
4659
4879
|
return null;
|
|
4660
4880
|
}
|
|
4661
|
-
handleError(result, `Failed to get connector "${
|
|
4881
|
+
handleError(result, `Failed to get connector "${type2}"`);
|
|
4662
4882
|
}
|
|
4663
4883
|
|
|
4664
4884
|
// src/lib/api/domains/usage.ts
|
|
@@ -5472,188 +5692,6 @@ async function promptPassword(message) {
|
|
|
5472
5692
|
return response.value;
|
|
5473
5693
|
}
|
|
5474
5694
|
|
|
5475
|
-
// src/lib/utils/update-checker.ts
|
|
5476
|
-
import { spawn } from "child_process";
|
|
5477
|
-
import chalk3 from "chalk";
|
|
5478
|
-
var PACKAGE_NAME = "@vm0/cli";
|
|
5479
|
-
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;
|
|
5480
|
-
var TIMEOUT_MS = 5e3;
|
|
5481
|
-
function detectPackageManager() {
|
|
5482
|
-
const execPath = process.argv[1] ?? "";
|
|
5483
|
-
if (execPath.includes("pnpm")) {
|
|
5484
|
-
return "pnpm";
|
|
5485
|
-
}
|
|
5486
|
-
if (execPath.includes("/.bun/") || execPath.includes("/bun/")) {
|
|
5487
|
-
return "bun";
|
|
5488
|
-
}
|
|
5489
|
-
if (execPath.includes("/.yarn/") || execPath.includes("/yarn/")) {
|
|
5490
|
-
return "yarn";
|
|
5491
|
-
}
|
|
5492
|
-
if (execPath.includes("/usr/local/") || 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
|
|
5493
|
-
execPath.includes("\\nodejs\\")) {
|
|
5494
|
-
return "npm";
|
|
5495
|
-
}
|
|
5496
|
-
return "unknown";
|
|
5497
|
-
}
|
|
5498
|
-
function isAutoUpgradeSupported(pm) {
|
|
5499
|
-
return pm === "npm" || pm === "pnpm";
|
|
5500
|
-
}
|
|
5501
|
-
function getManualUpgradeCommand(pm) {
|
|
5502
|
-
switch (pm) {
|
|
5503
|
-
case "bun":
|
|
5504
|
-
return `bun add -g ${PACKAGE_NAME}@latest`;
|
|
5505
|
-
case "yarn":
|
|
5506
|
-
return `yarn global add ${PACKAGE_NAME}@latest`;
|
|
5507
|
-
case "pnpm":
|
|
5508
|
-
return `pnpm add -g ${PACKAGE_NAME}@latest`;
|
|
5509
|
-
case "npm":
|
|
5510
|
-
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
5511
|
-
case "unknown":
|
|
5512
|
-
return `npm install -g ${PACKAGE_NAME}@latest`;
|
|
5513
|
-
}
|
|
5514
|
-
}
|
|
5515
|
-
function escapeForShell(str) {
|
|
5516
|
-
return `"${str.replace(/"/g, '\\"')}"`;
|
|
5517
|
-
}
|
|
5518
|
-
function buildRerunCommand(prompt) {
|
|
5519
|
-
if (prompt) {
|
|
5520
|
-
return `vm0 cook ${escapeForShell(prompt)}`;
|
|
5521
|
-
}
|
|
5522
|
-
return "vm0 cook";
|
|
5523
|
-
}
|
|
5524
|
-
async function getLatestVersion() {
|
|
5525
|
-
try {
|
|
5526
|
-
const controller = new AbortController();
|
|
5527
|
-
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
5528
|
-
const response = await fetch(NPM_REGISTRY_URL, {
|
|
5529
|
-
signal: controller.signal
|
|
5530
|
-
});
|
|
5531
|
-
clearTimeout(timeoutId);
|
|
5532
|
-
if (!response.ok) {
|
|
5533
|
-
return null;
|
|
5534
|
-
}
|
|
5535
|
-
const json = await response.json();
|
|
5536
|
-
return json.version ?? null;
|
|
5537
|
-
} catch {
|
|
5538
|
-
return null;
|
|
5539
|
-
}
|
|
5540
|
-
}
|
|
5541
|
-
function performUpgrade(packageManager) {
|
|
5542
|
-
return new Promise((resolve) => {
|
|
5543
|
-
const isWindows = process.platform === "win32";
|
|
5544
|
-
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
5545
|
-
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
5546
|
-
const child = spawn(command, args, {
|
|
5547
|
-
stdio: "inherit",
|
|
5548
|
-
shell: isWindows
|
|
5549
|
-
});
|
|
5550
|
-
child.on("close", (code) => {
|
|
5551
|
-
resolve(code === 0);
|
|
5552
|
-
});
|
|
5553
|
-
child.on("error", () => {
|
|
5554
|
-
resolve(false);
|
|
5555
|
-
});
|
|
5556
|
-
});
|
|
5557
|
-
}
|
|
5558
|
-
async function checkAndUpgrade(currentVersion, prompt) {
|
|
5559
|
-
const latestVersion = await getLatestVersion();
|
|
5560
|
-
if (latestVersion === null) {
|
|
5561
|
-
console.log(chalk3.yellow("\u26A0 Could not check for updates"));
|
|
5562
|
-
console.log();
|
|
5563
|
-
return false;
|
|
5564
|
-
}
|
|
5565
|
-
if (latestVersion === currentVersion) {
|
|
5566
|
-
return false;
|
|
5567
|
-
}
|
|
5568
|
-
console.log(chalk3.yellow("vm0 is currently in beta."));
|
|
5569
|
-
console.log(
|
|
5570
|
-
chalk3.yellow(
|
|
5571
|
-
`Current version: ${currentVersion} -> Latest version: ${latestVersion}`
|
|
5572
|
-
)
|
|
5573
|
-
);
|
|
5574
|
-
console.log(
|
|
5575
|
-
chalk3.yellow(
|
|
5576
|
-
"Please always use the latest version for best compatibility."
|
|
5577
|
-
)
|
|
5578
|
-
);
|
|
5579
|
-
console.log();
|
|
5580
|
-
const packageManager = detectPackageManager();
|
|
5581
|
-
if (!isAutoUpgradeSupported(packageManager)) {
|
|
5582
|
-
if (packageManager === "unknown") {
|
|
5583
|
-
console.log(
|
|
5584
|
-
chalk3.yellow("Could not detect your package manager for auto-upgrade.")
|
|
5585
|
-
);
|
|
5586
|
-
} else {
|
|
5587
|
-
console.log(
|
|
5588
|
-
chalk3.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
|
|
5589
|
-
);
|
|
5590
|
-
}
|
|
5591
|
-
console.log(chalk3.yellow("Please upgrade manually:"));
|
|
5592
|
-
console.log(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
5593
|
-
console.log();
|
|
5594
|
-
return false;
|
|
5595
|
-
}
|
|
5596
|
-
console.log(`Upgrading via ${packageManager}...`);
|
|
5597
|
-
const success = await performUpgrade(packageManager);
|
|
5598
|
-
if (success) {
|
|
5599
|
-
console.log(chalk3.green(`Upgraded to ${latestVersion}`));
|
|
5600
|
-
console.log();
|
|
5601
|
-
console.log("To continue, run:");
|
|
5602
|
-
console.log(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
|
|
5603
|
-
return true;
|
|
5604
|
-
}
|
|
5605
|
-
console.error();
|
|
5606
|
-
console.error(chalk3.red("\u2717 Upgrade failed. Please run manually:"));
|
|
5607
|
-
console.error(chalk3.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
5608
|
-
console.error();
|
|
5609
|
-
console.error("Then re-run:");
|
|
5610
|
-
console.error(chalk3.cyan(` ${buildRerunCommand(prompt)}`));
|
|
5611
|
-
return true;
|
|
5612
|
-
}
|
|
5613
|
-
async function silentUpgradeAfterCommand(currentVersion) {
|
|
5614
|
-
const latestVersion = await getLatestVersion();
|
|
5615
|
-
if (latestVersion === null || latestVersion === currentVersion) {
|
|
5616
|
-
return;
|
|
5617
|
-
}
|
|
5618
|
-
const packageManager = detectPackageManager();
|
|
5619
|
-
if (!isAutoUpgradeSupported(packageManager)) {
|
|
5620
|
-
return;
|
|
5621
|
-
}
|
|
5622
|
-
const isWindows = process.platform === "win32";
|
|
5623
|
-
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
5624
|
-
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
5625
|
-
const upgradeResult = await new Promise((resolve) => {
|
|
5626
|
-
const child = spawn(command, args, {
|
|
5627
|
-
stdio: "pipe",
|
|
5628
|
-
// Capture output instead of inheriting
|
|
5629
|
-
shell: isWindows,
|
|
5630
|
-
detached: !isWindows,
|
|
5631
|
-
// Detach on non-Windows
|
|
5632
|
-
windowsHide: true
|
|
5633
|
-
});
|
|
5634
|
-
const timeoutId = setTimeout(() => {
|
|
5635
|
-
child.kill();
|
|
5636
|
-
resolve(false);
|
|
5637
|
-
}, TIMEOUT_MS);
|
|
5638
|
-
child.on("close", (code) => {
|
|
5639
|
-
clearTimeout(timeoutId);
|
|
5640
|
-
resolve(code === 0);
|
|
5641
|
-
});
|
|
5642
|
-
child.on("error", () => {
|
|
5643
|
-
clearTimeout(timeoutId);
|
|
5644
|
-
resolve(false);
|
|
5645
|
-
});
|
|
5646
|
-
});
|
|
5647
|
-
if (!upgradeResult) {
|
|
5648
|
-
console.log(
|
|
5649
|
-
chalk3.yellow(
|
|
5650
|
-
`
|
|
5651
|
-
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
5652
|
-
)
|
|
5653
|
-
);
|
|
5654
|
-
}
|
|
5655
|
-
}
|
|
5656
|
-
|
|
5657
5695
|
// src/commands/compose/index.ts
|
|
5658
5696
|
var DEFAULT_CONFIG_FILE = "vm0.yaml";
|
|
5659
5697
|
function isGitHubUrl(input) {
|
|
@@ -5665,7 +5703,7 @@ function getSecretsFromComposeContent(content) {
|
|
|
5665
5703
|
return new Set(grouped.secrets.map((r) => r.name));
|
|
5666
5704
|
}
|
|
5667
5705
|
async function loadAndValidateConfig(configFile, jsonMode) {
|
|
5668
|
-
if (!
|
|
5706
|
+
if (!existsSync5(configFile)) {
|
|
5669
5707
|
if (jsonMode) {
|
|
5670
5708
|
console.log(
|
|
5671
5709
|
JSON.stringify({ error: `Config file not found: ${configFile}` })
|
|
@@ -5922,7 +5960,7 @@ async function finalizeCompose(config, agent, variables, options) {
|
|
|
5922
5960
|
);
|
|
5923
5961
|
}
|
|
5924
5962
|
if (options.autoUpdate !== false) {
|
|
5925
|
-
await
|
|
5963
|
+
await waitForSilentUpgrade();
|
|
5926
5964
|
}
|
|
5927
5965
|
return result;
|
|
5928
5966
|
}
|
|
@@ -5931,9 +5969,9 @@ async function handleGitHubCompose(url, options) {
|
|
|
5931
5969
|
console.log(`Downloading from GitHub: ${url}`);
|
|
5932
5970
|
}
|
|
5933
5971
|
const { dir: downloadedDir, tempRoot } = await downloadGitHubDirectory(url);
|
|
5934
|
-
const configFile =
|
|
5972
|
+
const configFile = join7(downloadedDir, "vm0.yaml");
|
|
5935
5973
|
try {
|
|
5936
|
-
if (!
|
|
5974
|
+
if (!existsSync5(configFile)) {
|
|
5937
5975
|
if (options.json) {
|
|
5938
5976
|
console.log(
|
|
5939
5977
|
JSON.stringify({
|
|
@@ -6057,6 +6095,9 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
6057
6095
|
options.yes = true;
|
|
6058
6096
|
options.autoUpdate = false;
|
|
6059
6097
|
}
|
|
6098
|
+
if (options.autoUpdate !== false) {
|
|
6099
|
+
await startSilentUpgrade("9.28.0");
|
|
6100
|
+
}
|
|
6060
6101
|
try {
|
|
6061
6102
|
let result;
|
|
6062
6103
|
if (isGitHubUrl(resolvedConfigFile)) {
|
|
@@ -6935,16 +6976,16 @@ var CodexEventRenderer = class {
|
|
|
6935
6976
|
* Check if an event is a Codex event
|
|
6936
6977
|
*/
|
|
6937
6978
|
static isCodexEvent(event) {
|
|
6938
|
-
const
|
|
6939
|
-
return
|
|
6979
|
+
const type2 = event.type;
|
|
6980
|
+
return type2 === "thread.started" || type2 === "turn.started" || type2 === "turn.completed" || type2 === "turn.failed" || type2?.startsWith("item.") || type2 === "error";
|
|
6940
6981
|
}
|
|
6941
6982
|
/**
|
|
6942
6983
|
* Render a raw Codex event
|
|
6943
6984
|
*/
|
|
6944
6985
|
static render(rawEvent) {
|
|
6945
6986
|
const event = rawEvent;
|
|
6946
|
-
const
|
|
6947
|
-
switch (
|
|
6987
|
+
const type2 = event.type;
|
|
6988
|
+
switch (type2) {
|
|
6948
6989
|
case "thread.started":
|
|
6949
6990
|
this.renderThreadStarted(event);
|
|
6950
6991
|
break;
|
|
@@ -8276,6 +8317,9 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
8276
8317
|
).addOption(new Option2("--debug-no-mock-claude").hideHelp()).addOption(new Option2("--no-auto-update").hideHelp()).action(
|
|
8277
8318
|
async (identifier, prompt, options) => {
|
|
8278
8319
|
try {
|
|
8320
|
+
if (options.autoUpdate !== false) {
|
|
8321
|
+
await startSilentUpgrade("9.28.0");
|
|
8322
|
+
}
|
|
8279
8323
|
const { scope, name, version } = parseIdentifier(identifier);
|
|
8280
8324
|
if (scope && !options.experimentalSharedAgent) {
|
|
8281
8325
|
const userScope = await getScope();
|
|
@@ -8372,7 +8416,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
8372
8416
|
}
|
|
8373
8417
|
showNextSteps(result);
|
|
8374
8418
|
if (options.autoUpdate !== false) {
|
|
8375
|
-
await
|
|
8419
|
+
await waitForSilentUpgrade();
|
|
8376
8420
|
}
|
|
8377
8421
|
} catch (error) {
|
|
8378
8422
|
handleRunError(error, identifier);
|
|
@@ -8644,7 +8688,7 @@ import path6 from "path";
|
|
|
8644
8688
|
|
|
8645
8689
|
// src/lib/storage/storage-utils.ts
|
|
8646
8690
|
import { readFile as readFile5, writeFile as writeFile4, mkdir as mkdir4 } from "fs/promises";
|
|
8647
|
-
import { existsSync as
|
|
8691
|
+
import { existsSync as existsSync7 } from "fs";
|
|
8648
8692
|
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
8649
8693
|
import path5 from "path";
|
|
8650
8694
|
var CONFIG_DIR = ".vm0";
|
|
@@ -8660,9 +8704,9 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
8660
8704
|
const configPath = path5.join(basePath, CONFIG_DIR, CONFIG_FILE);
|
|
8661
8705
|
const legacyConfigPath = path5.join(basePath, CONFIG_DIR, "volume.yaml");
|
|
8662
8706
|
let actualPath = null;
|
|
8663
|
-
if (
|
|
8707
|
+
if (existsSync7(configPath)) {
|
|
8664
8708
|
actualPath = configPath;
|
|
8665
|
-
} else if (
|
|
8709
|
+
} else if (existsSync7(legacyConfigPath)) {
|
|
8666
8710
|
actualPath = legacyConfigPath;
|
|
8667
8711
|
}
|
|
8668
8712
|
if (!actualPath) {
|
|
@@ -8675,15 +8719,15 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
8675
8719
|
}
|
|
8676
8720
|
return config;
|
|
8677
8721
|
}
|
|
8678
|
-
async function writeStorageConfig(storageName, basePath = process.cwd(),
|
|
8722
|
+
async function writeStorageConfig(storageName, basePath = process.cwd(), type2 = "volume") {
|
|
8679
8723
|
const configDir = path5.join(basePath, CONFIG_DIR);
|
|
8680
8724
|
const configPath = path5.join(configDir, CONFIG_FILE);
|
|
8681
|
-
if (!
|
|
8725
|
+
if (!existsSync7(configDir)) {
|
|
8682
8726
|
await mkdir4(configDir, { recursive: true });
|
|
8683
8727
|
}
|
|
8684
8728
|
const config = {
|
|
8685
8729
|
name: storageName,
|
|
8686
|
-
type
|
|
8730
|
+
type: type2
|
|
8687
8731
|
};
|
|
8688
8732
|
const yamlContent = stringifyYaml(config);
|
|
8689
8733
|
await writeFile4(configPath, yamlContent, "utf8");
|
|
@@ -9015,8 +9059,8 @@ import path8 from "path";
|
|
|
9015
9059
|
import * as fs7 from "fs";
|
|
9016
9060
|
import * as os6 from "os";
|
|
9017
9061
|
import * as tar4 from "tar";
|
|
9018
|
-
async function cloneStorage(name,
|
|
9019
|
-
const typeLabel =
|
|
9062
|
+
async function cloneStorage(name, type2, destination, options = {}) {
|
|
9063
|
+
const typeLabel = type2 === "artifact" ? "artifact" : "volume";
|
|
9020
9064
|
const dirStatus = checkDirectoryStatus(destination);
|
|
9021
9065
|
if (dirStatus.exists && !dirStatus.empty) {
|
|
9022
9066
|
throw new Error(`Directory "${destination}" is not empty`);
|
|
@@ -9024,13 +9068,13 @@ async function cloneStorage(name, type, destination, options = {}) {
|
|
|
9024
9068
|
console.log(chalk20.dim(`Checking remote ${typeLabel}...`));
|
|
9025
9069
|
const downloadInfo = await getStorageDownload({
|
|
9026
9070
|
name,
|
|
9027
|
-
type,
|
|
9071
|
+
type: type2,
|
|
9028
9072
|
version: options.version
|
|
9029
9073
|
});
|
|
9030
9074
|
console.log(chalk20.dim(`Creating directory: ${destination}/`));
|
|
9031
9075
|
await fs7.promises.mkdir(destination, { recursive: true });
|
|
9032
9076
|
if ("empty" in downloadInfo) {
|
|
9033
|
-
await writeStorageConfig(name, destination,
|
|
9077
|
+
await writeStorageConfig(name, destination, type2);
|
|
9034
9078
|
console.log(chalk20.green(`\u2713 Cloned empty ${typeLabel}: ${name}`));
|
|
9035
9079
|
console.log(chalk20.dim(`\u2713 Initialized .vm0/storage.yaml`));
|
|
9036
9080
|
return {
|
|
@@ -9066,7 +9110,7 @@ async function cloneStorage(name, type, destination, options = {}) {
|
|
|
9066
9110
|
await fs7.promises.unlink(tarPath);
|
|
9067
9111
|
await fs7.promises.rmdir(tmpDir);
|
|
9068
9112
|
console.log(chalk20.green(`\u2713 Extracted ${files.length} files`));
|
|
9069
|
-
await writeStorageConfig(name, destination,
|
|
9113
|
+
await writeStorageConfig(name, destination, type2);
|
|
9070
9114
|
console.log(chalk20.green(`\u2713 Initialized .vm0/storage.yaml`));
|
|
9071
9115
|
return {
|
|
9072
9116
|
success: true,
|
|
@@ -9468,20 +9512,20 @@ var artifactCommand = new Command26().name("artifact").description("Manage artif
|
|
|
9468
9512
|
import { Command as Command27, Option as Option5 } from "commander";
|
|
9469
9513
|
import chalk29 from "chalk";
|
|
9470
9514
|
import { readFile as readFile7, mkdir as mkdir6 } from "fs/promises";
|
|
9471
|
-
import { existsSync as
|
|
9515
|
+
import { existsSync as existsSync10 } from "fs";
|
|
9472
9516
|
import path11 from "path";
|
|
9473
9517
|
import { parse as parseYaml4 } from "yaml";
|
|
9474
9518
|
|
|
9475
9519
|
// src/lib/domain/cook-state.ts
|
|
9476
|
-
import { homedir as
|
|
9477
|
-
import { join as
|
|
9520
|
+
import { homedir as homedir3 } from "os";
|
|
9521
|
+
import { join as join8 } from "path";
|
|
9478
9522
|
import { readFile as readFile6, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
9479
|
-
import { existsSync as
|
|
9480
|
-
var CONFIG_DIR2 =
|
|
9481
|
-
var COOK_STATE_FILE =
|
|
9523
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9524
|
+
var CONFIG_DIR2 = join8(homedir3(), ".vm0");
|
|
9525
|
+
var COOK_STATE_FILE = join8(CONFIG_DIR2, "cook.json");
|
|
9482
9526
|
var STALE_THRESHOLD_MS = 48 * 60 * 60 * 1e3;
|
|
9483
9527
|
async function loadCookStateFile() {
|
|
9484
|
-
if (!
|
|
9528
|
+
if (!existsSync8(COOK_STATE_FILE)) {
|
|
9485
9529
|
return { ppid: {} };
|
|
9486
9530
|
}
|
|
9487
9531
|
try {
|
|
@@ -9540,7 +9584,7 @@ async function saveCookState(state) {
|
|
|
9540
9584
|
// src/commands/cook/utils.ts
|
|
9541
9585
|
import chalk28 from "chalk";
|
|
9542
9586
|
import { spawn as spawn2 } from "child_process";
|
|
9543
|
-
import { existsSync as
|
|
9587
|
+
import { existsSync as existsSync9 } from "fs";
|
|
9544
9588
|
var CONFIG_FILE2 = "vm0.yaml";
|
|
9545
9589
|
var ARTIFACT_DIR = "artifact";
|
|
9546
9590
|
function printCommand(cmd) {
|
|
@@ -9643,7 +9687,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9643
9687
|
runOutput,
|
|
9644
9688
|
ARTIFACT_DIR
|
|
9645
9689
|
);
|
|
9646
|
-
if (serverVersion &&
|
|
9690
|
+
if (serverVersion && existsSync9(artifactDir)) {
|
|
9647
9691
|
console.log();
|
|
9648
9692
|
console.log(chalk28.bold("Pulling updated artifact:"));
|
|
9649
9693
|
printCommand(`cd ${ARTIFACT_DIR}`);
|
|
@@ -9666,7 +9710,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9666
9710
|
// src/commands/cook/cook.ts
|
|
9667
9711
|
async function loadAndValidateConfig2() {
|
|
9668
9712
|
console.log(chalk29.bold(`Reading config: ${CONFIG_FILE2}`));
|
|
9669
|
-
if (!
|
|
9713
|
+
if (!existsSync10(CONFIG_FILE2)) {
|
|
9670
9714
|
console.error(chalk29.red(`\u2717 Config file not found: ${CONFIG_FILE2}`));
|
|
9671
9715
|
process.exit(1);
|
|
9672
9716
|
}
|
|
@@ -9702,7 +9746,7 @@ async function processVolumes(config, cwd) {
|
|
|
9702
9746
|
console.log(chalk29.bold("Processing volumes:"));
|
|
9703
9747
|
for (const volumeConfig of Object.values(config.volumes)) {
|
|
9704
9748
|
const volumeDir = path11.join(cwd, volumeConfig.name);
|
|
9705
|
-
if (!
|
|
9749
|
+
if (!existsSync10(volumeDir)) {
|
|
9706
9750
|
console.error(chalk29.red(`\u2717 Directory not found: ${volumeConfig.name}`));
|
|
9707
9751
|
console.error(chalk29.dim(" Create the directory and add files first"));
|
|
9708
9752
|
process.exit(1);
|
|
@@ -9737,7 +9781,7 @@ async function processArtifact(cwd) {
|
|
|
9737
9781
|
console.log(chalk29.bold("Processing artifact:"));
|
|
9738
9782
|
const artifactDir = path11.join(cwd, ARTIFACT_DIR);
|
|
9739
9783
|
try {
|
|
9740
|
-
if (!
|
|
9784
|
+
if (!existsSync10(artifactDir)) {
|
|
9741
9785
|
printCommand(`mkdir ${ARTIFACT_DIR}`);
|
|
9742
9786
|
await mkdir6(artifactDir, { recursive: true });
|
|
9743
9787
|
}
|
|
@@ -9819,7 +9863,7 @@ var cookAction = new Command27().name("cook").description("Quick start: prepare,
|
|
|
9819
9863
|
).option("-y, --yes", "Skip confirmation prompts").option("-v, --verbose", "Show full tool inputs and outputs").addOption(new Option5("--debug-no-mock-claude").hideHelp()).addOption(new Option5("--no-auto-update").hideHelp()).action(
|
|
9820
9864
|
async (prompt, options) => {
|
|
9821
9865
|
if (options.autoUpdate !== false) {
|
|
9822
|
-
const shouldExit = await checkAndUpgrade("9.
|
|
9866
|
+
const shouldExit = await checkAndUpgrade("9.28.0", prompt);
|
|
9823
9867
|
if (shouldExit) {
|
|
9824
9868
|
process.exit(0);
|
|
9825
9869
|
}
|
|
@@ -10402,7 +10446,7 @@ import { Command as Command35 } from "commander";
|
|
|
10402
10446
|
import chalk36 from "chalk";
|
|
10403
10447
|
import { mkdtempSync as mkdtempSync5 } from "fs";
|
|
10404
10448
|
import { mkdir as mkdir7, writeFile as writeFile6, readdir, copyFile, rm as rm4 } from "fs/promises";
|
|
10405
|
-
import { join as
|
|
10449
|
+
import { join as join9, dirname as dirname3 } from "path";
|
|
10406
10450
|
import { tmpdir as tmpdir7 } from "os";
|
|
10407
10451
|
import * as tar6 from "tar";
|
|
10408
10452
|
import { stringify as yamlStringify } from "yaml";
|
|
@@ -10438,8 +10482,8 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10438
10482
|
throw new Error(`Failed to download instructions: ${response.status}`);
|
|
10439
10483
|
}
|
|
10440
10484
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10441
|
-
const tmpDir = mkdtempSync5(
|
|
10442
|
-
const tarPath =
|
|
10485
|
+
const tmpDir = mkdtempSync5(join9(tmpdir7(), "vm0-clone-"));
|
|
10486
|
+
const tarPath = join9(tmpDir, "archive.tar.gz");
|
|
10443
10487
|
await writeFile6(tarPath, buffer);
|
|
10444
10488
|
await tar6.extract({ file: tarPath, cwd: tmpDir, gzip: true });
|
|
10445
10489
|
const files = await readdir(tmpDir);
|
|
@@ -10449,9 +10493,9 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10449
10493
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10450
10494
|
return false;
|
|
10451
10495
|
}
|
|
10452
|
-
const destPath =
|
|
10496
|
+
const destPath = join9(destination, instructionsPath);
|
|
10453
10497
|
await mkdir7(dirname3(destPath), { recursive: true });
|
|
10454
|
-
await copyFile(
|
|
10498
|
+
await copyFile(join9(tmpDir, mdFile), destPath);
|
|
10455
10499
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10456
10500
|
return true;
|
|
10457
10501
|
}
|
|
@@ -10477,7 +10521,7 @@ var cloneCommand3 = new Command35().name("clone").description("Clone agent compo
|
|
|
10477
10521
|
const cleanedContent = cleanComposeContent(content);
|
|
10478
10522
|
const yamlContent = yamlStringify(cleanedContent);
|
|
10479
10523
|
await mkdir7(targetDir, { recursive: true });
|
|
10480
|
-
const yamlPath =
|
|
10524
|
+
const yamlPath = join9(targetDir, "vm0.yaml");
|
|
10481
10525
|
await writeFile6(yamlPath, yamlContent, "utf8");
|
|
10482
10526
|
console.log(chalk36.green("\u2713 Created vm0.yaml"));
|
|
10483
10527
|
const agentKey = Object.keys(content.agents)[0];
|
|
@@ -11002,11 +11046,11 @@ var permissionCommand = new Command42().name("experimental-permission").descript
|
|
|
11002
11046
|
)
|
|
11003
11047
|
);
|
|
11004
11048
|
for (const p of data.permissions) {
|
|
11005
|
-
const
|
|
11049
|
+
const type2 = p.granteeType.padEnd(7);
|
|
11006
11050
|
const email = (p.granteeEmail ?? "-").padEnd(29);
|
|
11007
11051
|
const permission = p.permission.padEnd(10);
|
|
11008
11052
|
const granted = formatRelativeTime(p.createdAt);
|
|
11009
|
-
console.log(`${
|
|
11053
|
+
console.log(`${type2} ${email} ${permission} ${granted}`);
|
|
11010
11054
|
}
|
|
11011
11055
|
} catch (error) {
|
|
11012
11056
|
console.error(chalk43.red("\u2717 Failed to list permissions"));
|
|
@@ -11024,7 +11068,7 @@ var agentCommand = new Command43().name("agent").description("Manage agent compo
|
|
|
11024
11068
|
import { Command as Command44 } from "commander";
|
|
11025
11069
|
import chalk44 from "chalk";
|
|
11026
11070
|
import path15 from "path";
|
|
11027
|
-
import { existsSync as
|
|
11071
|
+
import { existsSync as existsSync11 } from "fs";
|
|
11028
11072
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
11029
11073
|
var VM0_YAML_FILE = "vm0.yaml";
|
|
11030
11074
|
var AGENTS_MD_FILE = "AGENTS.md";
|
|
@@ -11056,8 +11100,8 @@ You are a HackerNews AI content curator.
|
|
|
11056
11100
|
}
|
|
11057
11101
|
function checkExistingFiles() {
|
|
11058
11102
|
const existingFiles = [];
|
|
11059
|
-
if (
|
|
11060
|
-
if (
|
|
11103
|
+
if (existsSync11(VM0_YAML_FILE)) existingFiles.push(VM0_YAML_FILE);
|
|
11104
|
+
if (existsSync11(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
|
|
11061
11105
|
return existingFiles;
|
|
11062
11106
|
}
|
|
11063
11107
|
var initCommand3 = new Command44().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(async (options) => {
|
|
@@ -11317,7 +11361,7 @@ function formatInTimezone(isoDate, timezone) {
|
|
|
11317
11361
|
minute: "2-digit",
|
|
11318
11362
|
hour12: false
|
|
11319
11363
|
}).formatToParts(date);
|
|
11320
|
-
const get = (
|
|
11364
|
+
const get = (type2) => parts.find((p) => p.type === type2)?.value ?? "";
|
|
11321
11365
|
return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}`;
|
|
11322
11366
|
}
|
|
11323
11367
|
function parseFrequencyFromCron(cron) {
|
|
@@ -12567,9 +12611,9 @@ function validateProviderType(typeStr) {
|
|
|
12567
12611
|
}
|
|
12568
12612
|
return typeStr;
|
|
12569
12613
|
}
|
|
12570
|
-
function validateModel(
|
|
12571
|
-
const models = getModels(
|
|
12572
|
-
if (allowsCustomModel(
|
|
12614
|
+
function validateModel(type2, modelStr) {
|
|
12615
|
+
const models = getModels(type2);
|
|
12616
|
+
if (allowsCustomModel(type2)) {
|
|
12573
12617
|
return modelStr;
|
|
12574
12618
|
}
|
|
12575
12619
|
if (models && !models.includes(modelStr)) {
|
|
@@ -12583,8 +12627,8 @@ function validateModel(type, modelStr) {
|
|
|
12583
12627
|
}
|
|
12584
12628
|
return modelStr;
|
|
12585
12629
|
}
|
|
12586
|
-
function validateAuthMethod(
|
|
12587
|
-
const authMethods = getAuthMethodsForType(
|
|
12630
|
+
function validateAuthMethod(type2, authMethodStr) {
|
|
12631
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12588
12632
|
if (!authMethods || !(authMethodStr in authMethods)) {
|
|
12589
12633
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethodStr}"`));
|
|
12590
12634
|
console.error();
|
|
@@ -12598,8 +12642,8 @@ function validateAuthMethod(type, authMethodStr) {
|
|
|
12598
12642
|
}
|
|
12599
12643
|
return authMethodStr;
|
|
12600
12644
|
}
|
|
12601
|
-
function parseSecrets(
|
|
12602
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12645
|
+
function parseSecrets(type2, authMethod, secretArgs) {
|
|
12646
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12603
12647
|
if (!secretsConfig) {
|
|
12604
12648
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12605
12649
|
process.exit(1);
|
|
@@ -12641,8 +12685,8 @@ function parseSecrets(type, authMethod, secretArgs) {
|
|
|
12641
12685
|
}
|
|
12642
12686
|
return secrets;
|
|
12643
12687
|
}
|
|
12644
|
-
function validateSecrets(
|
|
12645
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12688
|
+
function validateSecrets(type2, authMethod, secrets) {
|
|
12689
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12646
12690
|
if (!secretsConfig) {
|
|
12647
12691
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12648
12692
|
process.exit(1);
|
|
@@ -12674,23 +12718,23 @@ function validateSecrets(type, authMethod, secrets) {
|
|
|
12674
12718
|
}
|
|
12675
12719
|
}
|
|
12676
12720
|
function handleNonInteractiveMode(options) {
|
|
12677
|
-
const
|
|
12721
|
+
const type2 = validateProviderType(options.type);
|
|
12678
12722
|
let selectedModel;
|
|
12679
12723
|
if (options.model) {
|
|
12680
|
-
selectedModel = validateModel(
|
|
12681
|
-
} else if (hasModelSelection(
|
|
12682
|
-
const defaultModel = getDefaultModel(
|
|
12724
|
+
selectedModel = validateModel(type2, options.model);
|
|
12725
|
+
} else if (hasModelSelection(type2)) {
|
|
12726
|
+
const defaultModel = getDefaultModel(type2);
|
|
12683
12727
|
selectedModel = defaultModel || void 0;
|
|
12684
12728
|
}
|
|
12685
|
-
if (hasAuthMethods(
|
|
12729
|
+
if (hasAuthMethods(type2)) {
|
|
12686
12730
|
let authMethod;
|
|
12687
12731
|
if (options.authMethod) {
|
|
12688
|
-
authMethod = validateAuthMethod(
|
|
12732
|
+
authMethod = validateAuthMethod(type2, options.authMethod);
|
|
12689
12733
|
} else {
|
|
12690
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12691
|
-
const authMethods = getAuthMethodsForType(
|
|
12734
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12735
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12692
12736
|
if (!defaultAuthMethod || !authMethods) {
|
|
12693
|
-
console.error(chalk59.red(`\u2717 Provider "${
|
|
12737
|
+
console.error(chalk59.red(`\u2717 Provider "${type2}" requires --auth-method`));
|
|
12694
12738
|
process.exit(1);
|
|
12695
12739
|
}
|
|
12696
12740
|
const authMethodNames = Object.keys(authMethods);
|
|
@@ -12699,7 +12743,7 @@ function handleNonInteractiveMode(options) {
|
|
|
12699
12743
|
} else {
|
|
12700
12744
|
console.error(
|
|
12701
12745
|
chalk59.red(
|
|
12702
|
-
`\u2717 --auth-method is required for "${
|
|
12746
|
+
`\u2717 --auth-method is required for "${type2}" (multiple auth methods available)`
|
|
12703
12747
|
)
|
|
12704
12748
|
);
|
|
12705
12749
|
console.error();
|
|
@@ -12714,16 +12758,16 @@ function handleNonInteractiveMode(options) {
|
|
|
12714
12758
|
console.error("Example:");
|
|
12715
12759
|
console.error(
|
|
12716
12760
|
chalk59.cyan(
|
|
12717
|
-
` vm0 model-provider setup --type ${
|
|
12761
|
+
` vm0 model-provider setup --type ${type2} --auth-method ${authMethodNames[0]} --secret KEY=VALUE`
|
|
12718
12762
|
)
|
|
12719
12763
|
);
|
|
12720
12764
|
process.exit(1);
|
|
12721
12765
|
}
|
|
12722
12766
|
}
|
|
12723
|
-
const secrets = parseSecrets(
|
|
12724
|
-
validateSecrets(
|
|
12767
|
+
const secrets = parseSecrets(type2, authMethod, options.secret);
|
|
12768
|
+
validateSecrets(type2, authMethod, secrets);
|
|
12725
12769
|
return {
|
|
12726
|
-
type,
|
|
12770
|
+
type: type2,
|
|
12727
12771
|
authMethod,
|
|
12728
12772
|
secrets,
|
|
12729
12773
|
selectedModel,
|
|
@@ -12743,19 +12787,19 @@ function handleNonInteractiveMode(options) {
|
|
|
12743
12787
|
secret = firstArg;
|
|
12744
12788
|
}
|
|
12745
12789
|
return {
|
|
12746
|
-
type,
|
|
12790
|
+
type: type2,
|
|
12747
12791
|
secret,
|
|
12748
12792
|
selectedModel,
|
|
12749
12793
|
isInteractiveMode: false
|
|
12750
12794
|
};
|
|
12751
12795
|
}
|
|
12752
|
-
async function promptForModelSelection(
|
|
12753
|
-
if (!hasModelSelection(
|
|
12796
|
+
async function promptForModelSelection(type2) {
|
|
12797
|
+
if (!hasModelSelection(type2)) {
|
|
12754
12798
|
return void 0;
|
|
12755
12799
|
}
|
|
12756
|
-
const models = getModels(
|
|
12757
|
-
const defaultModel = getDefaultModel(
|
|
12758
|
-
const supportsCustomModel = allowsCustomModel(
|
|
12800
|
+
const models = getModels(type2) ?? [];
|
|
12801
|
+
const defaultModel = getDefaultModel(type2);
|
|
12802
|
+
const supportsCustomModel = allowsCustomModel(type2);
|
|
12759
12803
|
const modelChoices = [];
|
|
12760
12804
|
if (defaultModel === "") {
|
|
12761
12805
|
modelChoices.push({ title: "auto (Recommended)", value: "" });
|
|
@@ -12780,7 +12824,7 @@ async function promptForModelSelection(type) {
|
|
|
12780
12824
|
);
|
|
12781
12825
|
const selected = modelResponse.model;
|
|
12782
12826
|
if (selected === "__custom__") {
|
|
12783
|
-
const placeholder = getCustomModelPlaceholder(
|
|
12827
|
+
const placeholder = getCustomModelPlaceholder(type2);
|
|
12784
12828
|
if (placeholder) {
|
|
12785
12829
|
console.log(chalk59.dim(`Example: ${placeholder}`));
|
|
12786
12830
|
}
|
|
@@ -12797,9 +12841,9 @@ async function promptForModelSelection(type) {
|
|
|
12797
12841
|
}
|
|
12798
12842
|
return selected === "" ? void 0 : selected;
|
|
12799
12843
|
}
|
|
12800
|
-
async function promptForAuthMethod(
|
|
12801
|
-
const authMethods = getAuthMethodsForType(
|
|
12802
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12844
|
+
async function promptForAuthMethod(type2) {
|
|
12845
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12846
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12803
12847
|
if (!authMethods) {
|
|
12804
12848
|
return "default";
|
|
12805
12849
|
}
|
|
@@ -12824,8 +12868,8 @@ function isSensitiveSecret(name) {
|
|
|
12824
12868
|
(pattern) => name.toUpperCase().includes(pattern)
|
|
12825
12869
|
);
|
|
12826
12870
|
}
|
|
12827
|
-
async function promptForSecrets(
|
|
12828
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12871
|
+
async function promptForSecrets(type2, authMethod) {
|
|
12872
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12829
12873
|
if (!secretsConfig) {
|
|
12830
12874
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12831
12875
|
process.exit(1);
|
|
@@ -12879,9 +12923,9 @@ async function handleInteractiveMode() {
|
|
|
12879
12923
|
const { modelProviders: configuredProviders } = await listModelProviders();
|
|
12880
12924
|
const configuredTypes = new Set(configuredProviders.map((p) => p.type));
|
|
12881
12925
|
const annotatedChoices = Object.entries(MODEL_PROVIDER_TYPES).map(
|
|
12882
|
-
([
|
|
12883
|
-
const isConfigured = configuredTypes.has(
|
|
12884
|
-
const isExperimental = hasAuthMethods(
|
|
12926
|
+
([type3, config2]) => {
|
|
12927
|
+
const isConfigured = configuredTypes.has(type3);
|
|
12928
|
+
const isExperimental = hasAuthMethods(type3);
|
|
12885
12929
|
let title = config2.label;
|
|
12886
12930
|
if (isConfigured) {
|
|
12887
12931
|
title = `${title} \u2713`;
|
|
@@ -12891,7 +12935,7 @@ async function handleInteractiveMode() {
|
|
|
12891
12935
|
}
|
|
12892
12936
|
return {
|
|
12893
12937
|
title,
|
|
12894
|
-
value:
|
|
12938
|
+
value: type3
|
|
12895
12939
|
};
|
|
12896
12940
|
}
|
|
12897
12941
|
);
|
|
@@ -12904,11 +12948,11 @@ async function handleInteractiveMode() {
|
|
|
12904
12948
|
},
|
|
12905
12949
|
{ onCancel: () => process.exit(0) }
|
|
12906
12950
|
);
|
|
12907
|
-
const
|
|
12908
|
-
const checkResult = await checkModelProviderSecret(
|
|
12951
|
+
const type2 = typeResponse.type;
|
|
12952
|
+
const checkResult = await checkModelProviderSecret(type2);
|
|
12909
12953
|
if (checkResult.exists) {
|
|
12910
12954
|
console.log();
|
|
12911
|
-
console.log(`"${
|
|
12955
|
+
console.log(`"${type2}" is already configured`);
|
|
12912
12956
|
console.log();
|
|
12913
12957
|
const actionResponse = await prompts2(
|
|
12914
12958
|
{
|
|
@@ -12923,25 +12967,25 @@ async function handleInteractiveMode() {
|
|
|
12923
12967
|
{ onCancel: () => process.exit(0) }
|
|
12924
12968
|
);
|
|
12925
12969
|
if (actionResponse.action === "keep") {
|
|
12926
|
-
const selectedModel2 = await promptForModelSelection(
|
|
12970
|
+
const selectedModel2 = await promptForModelSelection(type2);
|
|
12927
12971
|
return {
|
|
12928
|
-
type,
|
|
12972
|
+
type: type2,
|
|
12929
12973
|
keepExistingSecret: true,
|
|
12930
12974
|
selectedModel: selectedModel2,
|
|
12931
12975
|
isInteractiveMode: true
|
|
12932
12976
|
};
|
|
12933
12977
|
}
|
|
12934
12978
|
}
|
|
12935
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
12979
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
12936
12980
|
console.log();
|
|
12937
12981
|
console.log(chalk59.dim(config.helpText));
|
|
12938
12982
|
console.log();
|
|
12939
|
-
if (hasAuthMethods(
|
|
12940
|
-
const authMethod = await promptForAuthMethod(
|
|
12941
|
-
const secrets = await promptForSecrets(
|
|
12942
|
-
const selectedModel2 = await promptForModelSelection(
|
|
12983
|
+
if (hasAuthMethods(type2)) {
|
|
12984
|
+
const authMethod = await promptForAuthMethod(type2);
|
|
12985
|
+
const secrets = await promptForSecrets(type2, authMethod);
|
|
12986
|
+
const selectedModel2 = await promptForModelSelection(type2);
|
|
12943
12987
|
return {
|
|
12944
|
-
type,
|
|
12988
|
+
type: type2,
|
|
12945
12989
|
authMethod,
|
|
12946
12990
|
secrets,
|
|
12947
12991
|
selectedModel: selectedModel2,
|
|
@@ -12959,8 +13003,8 @@ async function handleInteractiveMode() {
|
|
|
12959
13003
|
{ onCancel: () => process.exit(0) }
|
|
12960
13004
|
);
|
|
12961
13005
|
const secret = secretResponse.secret;
|
|
12962
|
-
const selectedModel = await promptForModelSelection(
|
|
12963
|
-
return { type, secret, selectedModel, isInteractiveMode: true };
|
|
13006
|
+
const selectedModel = await promptForModelSelection(type2);
|
|
13007
|
+
return { type: type2, secret, selectedModel, isInteractiveMode: true };
|
|
12964
13008
|
}
|
|
12965
13009
|
function handleSetupError2(error) {
|
|
12966
13010
|
if (error instanceof Error) {
|
|
@@ -12975,7 +13019,7 @@ function handleSetupError2(error) {
|
|
|
12975
13019
|
}
|
|
12976
13020
|
process.exit(1);
|
|
12977
13021
|
}
|
|
12978
|
-
async function promptSetAsDefault(
|
|
13022
|
+
async function promptSetAsDefault(type2, framework, isDefault) {
|
|
12979
13023
|
if (isDefault) return;
|
|
12980
13024
|
const response = await prompts2(
|
|
12981
13025
|
{
|
|
@@ -12987,8 +13031,8 @@ async function promptSetAsDefault(type, framework, isDefault) {
|
|
|
12987
13031
|
{ onCancel: () => process.exit(0) }
|
|
12988
13032
|
);
|
|
12989
13033
|
if (response.setDefault) {
|
|
12990
|
-
await setModelProviderDefault(
|
|
12991
|
-
console.log(chalk59.green(`\u2713 Default for ${framework} set to "${
|
|
13034
|
+
await setModelProviderDefault(type2);
|
|
13035
|
+
console.log(chalk59.green(`\u2713 Default for ${framework} set to "${type2}"`));
|
|
12992
13036
|
}
|
|
12993
13037
|
}
|
|
12994
13038
|
function collectSecrets(value, previous) {
|
|
@@ -13082,10 +13126,10 @@ var setupCommand2 = new Command62().name("setup").description("Configure a model
|
|
|
13082
13126
|
// src/commands/model-provider/delete.ts
|
|
13083
13127
|
import { Command as Command63 } from "commander";
|
|
13084
13128
|
import chalk60 from "chalk";
|
|
13085
|
-
var deleteCommand4 = new Command63().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (
|
|
13129
|
+
var deleteCommand4 = new Command63().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (type2) => {
|
|
13086
13130
|
try {
|
|
13087
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13088
|
-
console.error(chalk60.red(`\u2717 Invalid type "${
|
|
13131
|
+
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
13132
|
+
console.error(chalk60.red(`\u2717 Invalid type "${type2}"`));
|
|
13089
13133
|
console.log();
|
|
13090
13134
|
console.log("Valid types:");
|
|
13091
13135
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13093,12 +13137,12 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13093
13137
|
}
|
|
13094
13138
|
process.exit(1);
|
|
13095
13139
|
}
|
|
13096
|
-
await deleteModelProvider(
|
|
13097
|
-
console.log(chalk60.green(`\u2713 Model provider "${
|
|
13140
|
+
await deleteModelProvider(type2);
|
|
13141
|
+
console.log(chalk60.green(`\u2713 Model provider "${type2}" deleted`));
|
|
13098
13142
|
} catch (error) {
|
|
13099
13143
|
if (error instanceof Error) {
|
|
13100
13144
|
if (error.message.includes("not found")) {
|
|
13101
|
-
console.error(chalk60.red(`\u2717 Model provider "${
|
|
13145
|
+
console.error(chalk60.red(`\u2717 Model provider "${type2}" not found`));
|
|
13102
13146
|
} else if (error.message.includes("Not authenticated")) {
|
|
13103
13147
|
console.error(chalk60.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13104
13148
|
} else {
|
|
@@ -13114,10 +13158,10 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13114
13158
|
// src/commands/model-provider/set-default.ts
|
|
13115
13159
|
import { Command as Command64 } from "commander";
|
|
13116
13160
|
import chalk61 from "chalk";
|
|
13117
|
-
var setDefaultCommand = new Command64().name("set-default").description("Set a model provider as default for its framework").argument("<type>", "Model provider type to set as default").action(async (
|
|
13161
|
+
var setDefaultCommand = new Command64().name("set-default").description("Set a model provider as default for its framework").argument("<type>", "Model provider type to set as default").action(async (type2) => {
|
|
13118
13162
|
try {
|
|
13119
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13120
|
-
console.error(chalk61.red(`\u2717 Invalid type "${
|
|
13163
|
+
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
13164
|
+
console.error(chalk61.red(`\u2717 Invalid type "${type2}"`));
|
|
13121
13165
|
console.log();
|
|
13122
13166
|
console.log("Valid types:");
|
|
13123
13167
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13125,7 +13169,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13125
13169
|
}
|
|
13126
13170
|
process.exit(1);
|
|
13127
13171
|
}
|
|
13128
|
-
const provider = await setModelProviderDefault(
|
|
13172
|
+
const provider = await setModelProviderDefault(type2);
|
|
13129
13173
|
console.log(
|
|
13130
13174
|
chalk61.green(
|
|
13131
13175
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
@@ -13134,7 +13178,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13134
13178
|
} catch (error) {
|
|
13135
13179
|
if (error instanceof Error) {
|
|
13136
13180
|
if (error.message.includes("not found")) {
|
|
13137
|
-
console.error(chalk61.red(`\u2717 Model provider "${
|
|
13181
|
+
console.error(chalk61.red(`\u2717 Model provider "${type2}" not found`));
|
|
13138
13182
|
} else if (error.message.includes("Not authenticated")) {
|
|
13139
13183
|
console.error(chalk61.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13140
13184
|
} else {
|
|
@@ -13174,17 +13218,17 @@ async function getHeaders2() {
|
|
|
13174
13218
|
}
|
|
13175
13219
|
return headers;
|
|
13176
13220
|
}
|
|
13177
|
-
var connectCommand = new Command66().name("connect").description("Connect a third-party service (e.g., GitHub)").argument("<type>", "Connector type (e.g., github)").action(async (
|
|
13178
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13221
|
+
var connectCommand = new Command66().name("connect").description("Connect a third-party service (e.g., GitHub)").argument("<type>", "Connector type (e.g., github)").action(async (type2) => {
|
|
13222
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13179
13223
|
if (!parseResult.success) {
|
|
13180
|
-
console.error(chalk62.red(`\u2717 Unknown connector type: ${
|
|
13224
|
+
console.error(chalk62.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13181
13225
|
console.error("Available connectors: github");
|
|
13182
13226
|
process.exit(1);
|
|
13183
13227
|
}
|
|
13184
13228
|
const connectorType = parseResult.data;
|
|
13185
13229
|
const apiUrl = await getApiUrl();
|
|
13186
13230
|
const headers = await getHeaders2();
|
|
13187
|
-
console.log(`Connecting ${chalk62.cyan(
|
|
13231
|
+
console.log(`Connecting ${chalk62.cyan(type2)}...`);
|
|
13188
13232
|
const sessionsClient = initClient12(connectorSessionsContract, {
|
|
13189
13233
|
baseUrl: apiUrl,
|
|
13190
13234
|
baseHeaders: headers,
|
|
@@ -13241,7 +13285,7 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
13241
13285
|
case "complete":
|
|
13242
13286
|
console.log(chalk62.green(`
|
|
13243
13287
|
|
|
13244
|
-
${
|
|
13288
|
+
${type2} connected successfully!`));
|
|
13245
13289
|
return;
|
|
13246
13290
|
case "expired":
|
|
13247
13291
|
console.error(chalk62.red("\n\u2717 Session expired, please try again"));
|
|
@@ -13282,11 +13326,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13282
13326
|
"ACCOUNT"
|
|
13283
13327
|
].join(" ");
|
|
13284
13328
|
console.log(chalk63.dim(header));
|
|
13285
|
-
for (const
|
|
13286
|
-
const connector = connectedMap.get(
|
|
13329
|
+
for (const type2 of allTypes) {
|
|
13330
|
+
const connector = connectedMap.get(type2);
|
|
13287
13331
|
const status = connector ? chalk63.green("\u2713".padEnd(statusWidth)) : chalk63.dim("-".padEnd(statusWidth));
|
|
13288
13332
|
const account = connector?.externalUsername ? `@${connector.externalUsername}` : chalk63.dim("-");
|
|
13289
|
-
const row = [
|
|
13333
|
+
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
13290
13334
|
console.log(row);
|
|
13291
13335
|
}
|
|
13292
13336
|
console.log();
|
|
@@ -13310,11 +13354,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13310
13354
|
import { Command as Command68 } from "commander";
|
|
13311
13355
|
import chalk64 from "chalk";
|
|
13312
13356
|
var LABEL_WIDTH = 16;
|
|
13313
|
-
var statusCommand7 = new Command68().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(async (
|
|
13357
|
+
var statusCommand7 = new Command68().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(async (type2) => {
|
|
13314
13358
|
try {
|
|
13315
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13359
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13316
13360
|
if (!parseResult.success) {
|
|
13317
|
-
console.error(chalk64.red(`\u2717 Unknown connector type: ${
|
|
13361
|
+
console.error(chalk64.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13318
13362
|
console.error();
|
|
13319
13363
|
console.error("Available connectors:");
|
|
13320
13364
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13323,7 +13367,7 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13323
13367
|
process.exit(1);
|
|
13324
13368
|
}
|
|
13325
13369
|
const connector = await getConnector(parseResult.data);
|
|
13326
|
-
console.log(`Connector: ${chalk64.cyan(
|
|
13370
|
+
console.log(`Connector: ${chalk64.cyan(type2)}`);
|
|
13327
13371
|
console.log();
|
|
13328
13372
|
if (connector) {
|
|
13329
13373
|
console.log(
|
|
@@ -13350,14 +13394,14 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13350
13394
|
}
|
|
13351
13395
|
console.log();
|
|
13352
13396
|
console.log(chalk64.dim("To disconnect:"));
|
|
13353
|
-
console.log(chalk64.dim(` vm0 connector disconnect ${
|
|
13397
|
+
console.log(chalk64.dim(` vm0 connector disconnect ${type2}`));
|
|
13354
13398
|
} else {
|
|
13355
13399
|
console.log(
|
|
13356
13400
|
`${"Status:".padEnd(LABEL_WIDTH)}${chalk64.dim("not connected")}`
|
|
13357
13401
|
);
|
|
13358
13402
|
console.log();
|
|
13359
13403
|
console.log(chalk64.dim("To connect:"));
|
|
13360
|
-
console.log(chalk64.dim(` vm0 connector connect ${
|
|
13404
|
+
console.log(chalk64.dim(` vm0 connector connect ${type2}`));
|
|
13361
13405
|
}
|
|
13362
13406
|
} catch (error) {
|
|
13363
13407
|
if (error instanceof Error) {
|
|
@@ -13376,11 +13420,11 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13376
13420
|
// src/commands/connector/disconnect.ts
|
|
13377
13421
|
import { Command as Command69 } from "commander";
|
|
13378
13422
|
import chalk65 from "chalk";
|
|
13379
|
-
var disconnectCommand = new Command69().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(async (
|
|
13423
|
+
var disconnectCommand = new Command69().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(async (type2) => {
|
|
13380
13424
|
try {
|
|
13381
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13425
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13382
13426
|
if (!parseResult.success) {
|
|
13383
|
-
console.error(chalk65.red(`\u2717 Unknown connector type: ${
|
|
13427
|
+
console.error(chalk65.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13384
13428
|
console.error();
|
|
13385
13429
|
console.error("Available connectors:");
|
|
13386
13430
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13389,11 +13433,11 @@ var disconnectCommand = new Command69().name("disconnect").description("Disconne
|
|
|
13389
13433
|
process.exit(1);
|
|
13390
13434
|
}
|
|
13391
13435
|
await deleteConnector(parseResult.data);
|
|
13392
|
-
console.log(chalk65.green(`\u2713 Disconnected ${
|
|
13436
|
+
console.log(chalk65.green(`\u2713 Disconnected ${type2}`));
|
|
13393
13437
|
} catch (error) {
|
|
13394
13438
|
if (error instanceof Error) {
|
|
13395
13439
|
if (error.message.includes("not found")) {
|
|
13396
|
-
console.error(chalk65.red(`\u2717 Connector "${
|
|
13440
|
+
console.error(chalk65.red(`\u2717 Connector "${type2}" is not connected`));
|
|
13397
13441
|
} else if (error.message.includes("Not authenticated")) {
|
|
13398
13442
|
console.error(chalk65.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13399
13443
|
} else {
|
|
@@ -13413,7 +13457,7 @@ var connectorCommand = new Command70().name("connector").description("Manage thi
|
|
|
13413
13457
|
import { Command as Command71 } from "commander";
|
|
13414
13458
|
import chalk69 from "chalk";
|
|
13415
13459
|
import { mkdir as mkdir8 } from "fs/promises";
|
|
13416
|
-
import { existsSync as
|
|
13460
|
+
import { existsSync as existsSync12 } from "fs";
|
|
13417
13461
|
|
|
13418
13462
|
// src/lib/ui/welcome-box.ts
|
|
13419
13463
|
import chalk66 from "chalk";
|
|
@@ -13642,21 +13686,21 @@ async function checkModelProviderStatus() {
|
|
|
13642
13686
|
};
|
|
13643
13687
|
}
|
|
13644
13688
|
function getProviderChoices() {
|
|
13645
|
-
return ONBOARD_PROVIDER_TYPES.map((
|
|
13646
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
13689
|
+
return ONBOARD_PROVIDER_TYPES.map((type2) => {
|
|
13690
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
13647
13691
|
return {
|
|
13648
|
-
type,
|
|
13692
|
+
type: type2,
|
|
13649
13693
|
label: config.label,
|
|
13650
13694
|
helpText: config.helpText,
|
|
13651
13695
|
secretLabel: "secretLabel" in config ? config.secretLabel : "",
|
|
13652
|
-
models: getModels(
|
|
13653
|
-
defaultModel: getDefaultModel(
|
|
13696
|
+
models: getModels(type2),
|
|
13697
|
+
defaultModel: getDefaultModel(type2)
|
|
13654
13698
|
};
|
|
13655
13699
|
});
|
|
13656
13700
|
}
|
|
13657
|
-
async function setupModelProvider(
|
|
13701
|
+
async function setupModelProvider(type2, secret, options) {
|
|
13658
13702
|
const response = await upsertModelProvider({
|
|
13659
|
-
type,
|
|
13703
|
+
type: type2,
|
|
13660
13704
|
secret,
|
|
13661
13705
|
selectedModel: options?.selectedModel
|
|
13662
13706
|
});
|
|
@@ -13910,7 +13954,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13910
13954
|
process.exit(0);
|
|
13911
13955
|
}
|
|
13912
13956
|
agentName = inputName;
|
|
13913
|
-
if (
|
|
13957
|
+
if (existsSync12(agentName)) {
|
|
13914
13958
|
step.detail(
|
|
13915
13959
|
chalk69.yellow(`${agentName}/ already exists, choose another name`)
|
|
13916
13960
|
);
|
|
@@ -13927,7 +13971,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13927
13971
|
);
|
|
13928
13972
|
process.exit(1);
|
|
13929
13973
|
}
|
|
13930
|
-
if (
|
|
13974
|
+
if (existsSync12(agentName)) {
|
|
13931
13975
|
console.error(chalk69.red(`\u2717 ${agentName}/ already exists`));
|
|
13932
13976
|
console.error();
|
|
13933
13977
|
console.error("Remove it first or choose a different name:");
|
|
@@ -14217,7 +14261,7 @@ var devToolCommand = new Command75().name("dev-tool").description("Developer too
|
|
|
14217
14261
|
|
|
14218
14262
|
// src/index.ts
|
|
14219
14263
|
var program = new Command76();
|
|
14220
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.
|
|
14264
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.28.0");
|
|
14221
14265
|
program.addCommand(authCommand);
|
|
14222
14266
|
program.addCommand(infoCommand);
|
|
14223
14267
|
program.addCommand(composeCommand);
|