@vm0/cli 9.27.0 → 9.27.2
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 +398 -424
- 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.27.
|
|
64
|
+
version: "9.27.2",
|
|
65
65
|
command: process.argv.slice(2).join(" ")
|
|
66
66
|
});
|
|
67
67
|
Sentry.setContext("runtime", {
|
|
@@ -292,22 +292,233 @@ 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
|
+
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
|
+
function escapeForShell(str) {
|
|
343
|
+
return `"${str.replace(/"/g, '\\"')}"`;
|
|
344
|
+
}
|
|
345
|
+
function buildRerunCommand(prompt) {
|
|
346
|
+
if (prompt) {
|
|
347
|
+
return `vm0 cook ${escapeForShell(prompt)}`;
|
|
348
|
+
}
|
|
349
|
+
return "vm0 cook";
|
|
350
|
+
}
|
|
351
|
+
async function getLatestVersion() {
|
|
352
|
+
try {
|
|
353
|
+
const controller = new AbortController();
|
|
354
|
+
const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
355
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
356
|
+
signal: controller.signal
|
|
357
|
+
});
|
|
358
|
+
clearTimeout(timeoutId);
|
|
359
|
+
if (!response.ok) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
const json = await response.json();
|
|
363
|
+
return json.version ?? null;
|
|
364
|
+
} catch {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function performUpgrade(packageManager) {
|
|
369
|
+
return new Promise((resolve) => {
|
|
370
|
+
const isWindows = process.platform === "win32";
|
|
371
|
+
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
372
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
373
|
+
const child = spawn(command, args, {
|
|
374
|
+
stdio: "inherit",
|
|
375
|
+
shell: isWindows
|
|
376
|
+
});
|
|
377
|
+
child.on("close", (code) => {
|
|
378
|
+
resolve(code === 0);
|
|
379
|
+
});
|
|
380
|
+
child.on("error", () => {
|
|
381
|
+
resolve(false);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
async function checkAndUpgrade(currentVersion, prompt) {
|
|
386
|
+
const latestVersion = await getLatestVersion();
|
|
387
|
+
if (latestVersion === null) {
|
|
388
|
+
console.log(chalk2.yellow("\u26A0 Could not check for updates"));
|
|
389
|
+
console.log();
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
if (latestVersion === currentVersion) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
console.log(chalk2.yellow("vm0 is currently in beta."));
|
|
396
|
+
console.log(
|
|
397
|
+
chalk2.yellow(
|
|
398
|
+
`Current version: ${currentVersion} -> Latest version: ${latestVersion}`
|
|
399
|
+
)
|
|
400
|
+
);
|
|
401
|
+
console.log(
|
|
402
|
+
chalk2.yellow(
|
|
403
|
+
"Please always use the latest version for best compatibility."
|
|
404
|
+
)
|
|
405
|
+
);
|
|
406
|
+
console.log();
|
|
407
|
+
const packageManager = detectPackageManager();
|
|
408
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
409
|
+
if (packageManager === "unknown") {
|
|
410
|
+
console.log(
|
|
411
|
+
chalk2.yellow("Could not detect your package manager for auto-upgrade.")
|
|
412
|
+
);
|
|
413
|
+
} else {
|
|
414
|
+
console.log(
|
|
415
|
+
chalk2.yellow(`Auto-upgrade is not supported for ${packageManager}.`)
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
console.log(chalk2.yellow("Please upgrade manually:"));
|
|
419
|
+
console.log(chalk2.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
420
|
+
console.log();
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
console.log(`Upgrading via ${packageManager}...`);
|
|
424
|
+
const success = await performUpgrade(packageManager);
|
|
425
|
+
if (success) {
|
|
426
|
+
console.log(chalk2.green(`Upgraded to ${latestVersion}`));
|
|
427
|
+
console.log();
|
|
428
|
+
console.log("To continue, run:");
|
|
429
|
+
console.log(chalk2.cyan(` ${buildRerunCommand(prompt)}`));
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
console.error();
|
|
433
|
+
console.error(chalk2.red("\u2717 Upgrade failed. Please run manually:"));
|
|
434
|
+
console.error(chalk2.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
435
|
+
console.error();
|
|
436
|
+
console.error("Then re-run:");
|
|
437
|
+
console.error(chalk2.cyan(` ${buildRerunCommand(prompt)}`));
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
async function silentUpgradeAfterCommand(currentVersion) {
|
|
441
|
+
const latestVersion = await getLatestVersion();
|
|
442
|
+
if (latestVersion === null || latestVersion === currentVersion) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const packageManager = detectPackageManager();
|
|
446
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const isWindows = process.platform === "win32";
|
|
450
|
+
const command = isWindows ? `${packageManager}.cmd` : packageManager;
|
|
451
|
+
const args = packageManager === "pnpm" ? ["add", "-g", `${PACKAGE_NAME}@latest`] : ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
452
|
+
const upgradeResult = await new Promise((resolve) => {
|
|
453
|
+
const child = spawn(command, args, {
|
|
454
|
+
stdio: "pipe",
|
|
455
|
+
// Capture output instead of inheriting
|
|
456
|
+
shell: isWindows,
|
|
457
|
+
detached: !isWindows,
|
|
458
|
+
// Detach on non-Windows
|
|
459
|
+
windowsHide: true
|
|
460
|
+
});
|
|
461
|
+
const timeoutId = setTimeout(() => {
|
|
462
|
+
child.kill();
|
|
463
|
+
resolve(false);
|
|
464
|
+
}, TIMEOUT_MS);
|
|
465
|
+
child.on("close", (code) => {
|
|
466
|
+
clearTimeout(timeoutId);
|
|
467
|
+
resolve(code === 0);
|
|
468
|
+
});
|
|
469
|
+
child.on("error", () => {
|
|
470
|
+
clearTimeout(timeoutId);
|
|
471
|
+
resolve(false);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
if (!upgradeResult) {
|
|
475
|
+
console.log(
|
|
476
|
+
chalk2.yellow(
|
|
477
|
+
`
|
|
478
|
+
\u26A0 vm0 auto upgrade failed. Please run: ${getManualUpgradeCommand(packageManager)}`
|
|
479
|
+
)
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/commands/info/index.ts
|
|
485
|
+
var CONFIG_PATH = join2(homedir2(), ".vm0", "config.json");
|
|
486
|
+
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
487
|
+
console.log(chalk3.bold(`VM0 CLI v${"9.27.2"}`));
|
|
488
|
+
console.log();
|
|
489
|
+
const config = await loadConfig();
|
|
490
|
+
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
491
|
+
const hasConfigToken = !!config.token;
|
|
492
|
+
const isAuthenticated2 = hasEnvToken || hasConfigToken;
|
|
493
|
+
console.log(chalk3.bold("Authentication:"));
|
|
494
|
+
if (isAuthenticated2) {
|
|
495
|
+
const tokenSource = hasEnvToken ? "VM0_TOKEN env var" : "config file";
|
|
496
|
+
console.log(` ${chalk3.green("\u2713")} Logged in (via ${tokenSource})`);
|
|
497
|
+
} else {
|
|
498
|
+
console.log(` ${chalk3.red("\u2717")} Not authenticated`);
|
|
499
|
+
}
|
|
500
|
+
const configExists = existsSync2(CONFIG_PATH);
|
|
501
|
+
const configDisplay = configExists ? `~/.vm0/config.json` : `~/.vm0/config.json (not found)`;
|
|
502
|
+
console.log(` Config: ${configDisplay}`);
|
|
503
|
+
console.log();
|
|
301
504
|
const apiUrl = await getApiUrl();
|
|
302
|
-
console.log(
|
|
505
|
+
console.log(chalk3.bold("API:"));
|
|
506
|
+
console.log(` Host: ${apiUrl}`);
|
|
507
|
+
console.log();
|
|
508
|
+
console.log(chalk3.bold("System:"));
|
|
509
|
+
console.log(` Node: ${process.version}`);
|
|
510
|
+
console.log(` Platform: ${process.platform} (${process.arch})`);
|
|
511
|
+
console.log(` OS: ${type()} ${release2()}`);
|
|
512
|
+
console.log(` Shell: ${process.env.SHELL ?? "unknown"}`);
|
|
513
|
+
console.log(` Package Manager: ${detectPackageManager()}`);
|
|
303
514
|
});
|
|
304
515
|
|
|
305
516
|
// src/commands/compose/index.ts
|
|
306
517
|
import { Command as Command7, Option } from "commander";
|
|
307
518
|
import chalk4 from "chalk";
|
|
308
519
|
import { readFile as readFile4, rm as rm3 } from "fs/promises";
|
|
309
|
-
import { existsSync as
|
|
310
|
-
import { dirname as dirname2, join as
|
|
520
|
+
import { existsSync as existsSync5 } from "fs";
|
|
521
|
+
import { dirname as dirname2, join as join7 } from "path";
|
|
311
522
|
import { parse as parseYaml2 } from "yaml";
|
|
312
523
|
|
|
313
524
|
// ../../packages/core/src/variable-expander.ts
|
|
@@ -2390,44 +2601,44 @@ var modelProviderTypeSchema = z16.enum([
|
|
|
2390
2601
|
"aws-bedrock"
|
|
2391
2602
|
]);
|
|
2392
2603
|
var modelProviderFrameworkSchema = z16.enum(["claude-code", "codex"]);
|
|
2393
|
-
function hasAuthMethods(
|
|
2394
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2604
|
+
function hasAuthMethods(type2) {
|
|
2605
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2395
2606
|
return "authMethods" in config;
|
|
2396
2607
|
}
|
|
2397
|
-
function getAuthMethodsForType(
|
|
2398
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2608
|
+
function getAuthMethodsForType(type2) {
|
|
2609
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2399
2610
|
return "authMethods" in config ? config.authMethods : void 0;
|
|
2400
2611
|
}
|
|
2401
|
-
function getDefaultAuthMethod(
|
|
2402
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2612
|
+
function getDefaultAuthMethod(type2) {
|
|
2613
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2403
2614
|
return "defaultAuthMethod" in config ? config.defaultAuthMethod : void 0;
|
|
2404
2615
|
}
|
|
2405
|
-
function getSecretsForAuthMethod(
|
|
2406
|
-
const authMethods = getAuthMethodsForType(
|
|
2616
|
+
function getSecretsForAuthMethod(type2, authMethod) {
|
|
2617
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
2407
2618
|
if (!authMethods || !(authMethod in authMethods)) {
|
|
2408
2619
|
return void 0;
|
|
2409
2620
|
}
|
|
2410
2621
|
const method = authMethods[authMethod];
|
|
2411
2622
|
return method?.secrets;
|
|
2412
2623
|
}
|
|
2413
|
-
function getModels(
|
|
2414
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2624
|
+
function getModels(type2) {
|
|
2625
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2415
2626
|
return "models" in config ? config.models : void 0;
|
|
2416
2627
|
}
|
|
2417
|
-
function getDefaultModel(
|
|
2418
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2628
|
+
function getDefaultModel(type2) {
|
|
2629
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2419
2630
|
return "defaultModel" in config ? config.defaultModel : void 0;
|
|
2420
2631
|
}
|
|
2421
|
-
function hasModelSelection(
|
|
2422
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2632
|
+
function hasModelSelection(type2) {
|
|
2633
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2423
2634
|
return "models" in config && config.models.length > 0 || "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2424
2635
|
}
|
|
2425
|
-
function allowsCustomModel(
|
|
2426
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2636
|
+
function allowsCustomModel(type2) {
|
|
2637
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2427
2638
|
return "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2428
2639
|
}
|
|
2429
|
-
function getCustomModelPlaceholder(
|
|
2430
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
2640
|
+
function getCustomModelPlaceholder(type2) {
|
|
2641
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2431
2642
|
return "customModelPlaceholder" in config ? config.customModelPlaceholder : void 0;
|
|
2432
2643
|
}
|
|
2433
2644
|
var modelProviderResponseSchema = z16.object({
|
|
@@ -3263,8 +3474,8 @@ var CONNECTOR_TYPES = {
|
|
|
3263
3474
|
var connectorTypeSchema = z24.enum(["github"]);
|
|
3264
3475
|
function getConnectorDerivedNames(secretName) {
|
|
3265
3476
|
const allTypes = Object.keys(CONNECTOR_TYPES);
|
|
3266
|
-
for (const
|
|
3267
|
-
const config = CONNECTOR_TYPES[
|
|
3477
|
+
for (const type2 of allTypes) {
|
|
3478
|
+
const config = CONNECTOR_TYPES[type2];
|
|
3268
3479
|
const authMethods = config.authMethods;
|
|
3269
3480
|
let found = false;
|
|
3270
3481
|
for (const method of Object.values(authMethods)) {
|
|
@@ -4578,44 +4789,44 @@ async function upsertModelProvider(body) {
|
|
|
4578
4789
|
}
|
|
4579
4790
|
handleError(result, "Failed to set model provider");
|
|
4580
4791
|
}
|
|
4581
|
-
async function checkModelProviderSecret(
|
|
4792
|
+
async function checkModelProviderSecret(type2) {
|
|
4582
4793
|
const config = await getClientConfig();
|
|
4583
4794
|
const client = initClient9(modelProvidersCheckContract, config);
|
|
4584
4795
|
const result = await client.check({
|
|
4585
|
-
params: { type }
|
|
4796
|
+
params: { type: type2 }
|
|
4586
4797
|
});
|
|
4587
4798
|
if (result.status === 200) {
|
|
4588
4799
|
return result.body;
|
|
4589
4800
|
}
|
|
4590
4801
|
handleError(result, "Failed to check secret");
|
|
4591
4802
|
}
|
|
4592
|
-
async function deleteModelProvider(
|
|
4803
|
+
async function deleteModelProvider(type2) {
|
|
4593
4804
|
const config = await getClientConfig();
|
|
4594
4805
|
const client = initClient9(modelProvidersByTypeContract, config);
|
|
4595
4806
|
const result = await client.delete({
|
|
4596
|
-
params: { type }
|
|
4807
|
+
params: { type: type2 }
|
|
4597
4808
|
});
|
|
4598
4809
|
if (result.status === 204) {
|
|
4599
4810
|
return;
|
|
4600
4811
|
}
|
|
4601
|
-
handleError(result, `Model provider "${
|
|
4812
|
+
handleError(result, `Model provider "${type2}" not found`);
|
|
4602
4813
|
}
|
|
4603
|
-
async function setModelProviderDefault(
|
|
4814
|
+
async function setModelProviderDefault(type2) {
|
|
4604
4815
|
const config = await getClientConfig();
|
|
4605
4816
|
const client = initClient9(modelProvidersSetDefaultContract, config);
|
|
4606
4817
|
const result = await client.setDefault({
|
|
4607
|
-
params: { type }
|
|
4818
|
+
params: { type: type2 }
|
|
4608
4819
|
});
|
|
4609
4820
|
if (result.status === 200) {
|
|
4610
4821
|
return result.body;
|
|
4611
4822
|
}
|
|
4612
4823
|
handleError(result, "Failed to set default model provider");
|
|
4613
4824
|
}
|
|
4614
|
-
async function updateModelProviderModel(
|
|
4825
|
+
async function updateModelProviderModel(type2, selectedModel) {
|
|
4615
4826
|
const config = await getClientConfig();
|
|
4616
4827
|
const client = initClient9(modelProvidersUpdateModelContract, config);
|
|
4617
4828
|
const result = await client.updateModel({
|
|
4618
|
-
params: { type },
|
|
4829
|
+
params: { type: type2 },
|
|
4619
4830
|
body: { selectedModel }
|
|
4620
4831
|
});
|
|
4621
4832
|
if (result.status === 200) {
|
|
@@ -4635,22 +4846,22 @@ async function listConnectors() {
|
|
|
4635
4846
|
}
|
|
4636
4847
|
handleError(result, "Failed to list connectors");
|
|
4637
4848
|
}
|
|
4638
|
-
async function deleteConnector(
|
|
4849
|
+
async function deleteConnector(type2) {
|
|
4639
4850
|
const config = await getClientConfig();
|
|
4640
4851
|
const client = initClient10(connectorsByTypeContract, config);
|
|
4641
4852
|
const result = await client.delete({
|
|
4642
|
-
params: { type }
|
|
4853
|
+
params: { type: type2 }
|
|
4643
4854
|
});
|
|
4644
4855
|
if (result.status === 204) {
|
|
4645
4856
|
return;
|
|
4646
4857
|
}
|
|
4647
|
-
handleError(result, `Connector "${
|
|
4858
|
+
handleError(result, `Connector "${type2}" not found`);
|
|
4648
4859
|
}
|
|
4649
|
-
async function getConnector(
|
|
4860
|
+
async function getConnector(type2) {
|
|
4650
4861
|
const config = await getClientConfig();
|
|
4651
4862
|
const client = initClient10(connectorsByTypeContract, config);
|
|
4652
4863
|
const result = await client.get({
|
|
4653
|
-
params: { type }
|
|
4864
|
+
params: { type: type2 }
|
|
4654
4865
|
});
|
|
4655
4866
|
if (result.status === 200) {
|
|
4656
4867
|
return result.body;
|
|
@@ -4658,7 +4869,7 @@ async function getConnector(type) {
|
|
|
4658
4869
|
if (result.status === 404) {
|
|
4659
4870
|
return null;
|
|
4660
4871
|
}
|
|
4661
|
-
handleError(result, `Failed to get connector "${
|
|
4872
|
+
handleError(result, `Failed to get connector "${type2}"`);
|
|
4662
4873
|
}
|
|
4663
4874
|
|
|
4664
4875
|
// src/lib/api/domains/usage.ts
|
|
@@ -5472,188 +5683,6 @@ async function promptPassword(message) {
|
|
|
5472
5683
|
return response.value;
|
|
5473
5684
|
}
|
|
5474
5685
|
|
|
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
5686
|
// src/commands/compose/index.ts
|
|
5658
5687
|
var DEFAULT_CONFIG_FILE = "vm0.yaml";
|
|
5659
5688
|
function isGitHubUrl(input) {
|
|
@@ -5665,7 +5694,7 @@ function getSecretsFromComposeContent(content) {
|
|
|
5665
5694
|
return new Set(grouped.secrets.map((r) => r.name));
|
|
5666
5695
|
}
|
|
5667
5696
|
async function loadAndValidateConfig(configFile, jsonMode) {
|
|
5668
|
-
if (!
|
|
5697
|
+
if (!existsSync5(configFile)) {
|
|
5669
5698
|
if (jsonMode) {
|
|
5670
5699
|
console.log(
|
|
5671
5700
|
JSON.stringify({ error: `Config file not found: ${configFile}` })
|
|
@@ -5922,7 +5951,7 @@ async function finalizeCompose(config, agent, variables, options) {
|
|
|
5922
5951
|
);
|
|
5923
5952
|
}
|
|
5924
5953
|
if (options.autoUpdate !== false) {
|
|
5925
|
-
await silentUpgradeAfterCommand("9.27.
|
|
5954
|
+
await silentUpgradeAfterCommand("9.27.2");
|
|
5926
5955
|
}
|
|
5927
5956
|
return result;
|
|
5928
5957
|
}
|
|
@@ -5931,9 +5960,9 @@ async function handleGitHubCompose(url, options) {
|
|
|
5931
5960
|
console.log(`Downloading from GitHub: ${url}`);
|
|
5932
5961
|
}
|
|
5933
5962
|
const { dir: downloadedDir, tempRoot } = await downloadGitHubDirectory(url);
|
|
5934
|
-
const configFile =
|
|
5963
|
+
const configFile = join7(downloadedDir, "vm0.yaml");
|
|
5935
5964
|
try {
|
|
5936
|
-
if (!
|
|
5965
|
+
if (!existsSync5(configFile)) {
|
|
5937
5966
|
if (options.json) {
|
|
5938
5967
|
console.log(
|
|
5939
5968
|
JSON.stringify({
|
|
@@ -6935,16 +6964,16 @@ var CodexEventRenderer = class {
|
|
|
6935
6964
|
* Check if an event is a Codex event
|
|
6936
6965
|
*/
|
|
6937
6966
|
static isCodexEvent(event) {
|
|
6938
|
-
const
|
|
6939
|
-
return
|
|
6967
|
+
const type2 = event.type;
|
|
6968
|
+
return type2 === "thread.started" || type2 === "turn.started" || type2 === "turn.completed" || type2 === "turn.failed" || type2?.startsWith("item.") || type2 === "error";
|
|
6940
6969
|
}
|
|
6941
6970
|
/**
|
|
6942
6971
|
* Render a raw Codex event
|
|
6943
6972
|
*/
|
|
6944
6973
|
static render(rawEvent) {
|
|
6945
6974
|
const event = rawEvent;
|
|
6946
|
-
const
|
|
6947
|
-
switch (
|
|
6975
|
+
const type2 = event.type;
|
|
6976
|
+
switch (type2) {
|
|
6948
6977
|
case "thread.started":
|
|
6949
6978
|
this.renderThreadStarted(event);
|
|
6950
6979
|
break;
|
|
@@ -8372,7 +8401,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
8372
8401
|
}
|
|
8373
8402
|
showNextSteps(result);
|
|
8374
8403
|
if (options.autoUpdate !== false) {
|
|
8375
|
-
await silentUpgradeAfterCommand("9.27.
|
|
8404
|
+
await silentUpgradeAfterCommand("9.27.2");
|
|
8376
8405
|
}
|
|
8377
8406
|
} catch (error) {
|
|
8378
8407
|
handleRunError(error, identifier);
|
|
@@ -8644,7 +8673,7 @@ import path6 from "path";
|
|
|
8644
8673
|
|
|
8645
8674
|
// src/lib/storage/storage-utils.ts
|
|
8646
8675
|
import { readFile as readFile5, writeFile as writeFile4, mkdir as mkdir4 } from "fs/promises";
|
|
8647
|
-
import { existsSync as
|
|
8676
|
+
import { existsSync as existsSync7 } from "fs";
|
|
8648
8677
|
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
8649
8678
|
import path5 from "path";
|
|
8650
8679
|
var CONFIG_DIR = ".vm0";
|
|
@@ -8660,9 +8689,9 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
8660
8689
|
const configPath = path5.join(basePath, CONFIG_DIR, CONFIG_FILE);
|
|
8661
8690
|
const legacyConfigPath = path5.join(basePath, CONFIG_DIR, "volume.yaml");
|
|
8662
8691
|
let actualPath = null;
|
|
8663
|
-
if (
|
|
8692
|
+
if (existsSync7(configPath)) {
|
|
8664
8693
|
actualPath = configPath;
|
|
8665
|
-
} else if (
|
|
8694
|
+
} else if (existsSync7(legacyConfigPath)) {
|
|
8666
8695
|
actualPath = legacyConfigPath;
|
|
8667
8696
|
}
|
|
8668
8697
|
if (!actualPath) {
|
|
@@ -8675,15 +8704,15 @@ async function readStorageConfig(basePath = process.cwd()) {
|
|
|
8675
8704
|
}
|
|
8676
8705
|
return config;
|
|
8677
8706
|
}
|
|
8678
|
-
async function writeStorageConfig(storageName, basePath = process.cwd(),
|
|
8707
|
+
async function writeStorageConfig(storageName, basePath = process.cwd(), type2 = "volume") {
|
|
8679
8708
|
const configDir = path5.join(basePath, CONFIG_DIR);
|
|
8680
8709
|
const configPath = path5.join(configDir, CONFIG_FILE);
|
|
8681
|
-
if (!
|
|
8710
|
+
if (!existsSync7(configDir)) {
|
|
8682
8711
|
await mkdir4(configDir, { recursive: true });
|
|
8683
8712
|
}
|
|
8684
8713
|
const config = {
|
|
8685
8714
|
name: storageName,
|
|
8686
|
-
type
|
|
8715
|
+
type: type2
|
|
8687
8716
|
};
|
|
8688
8717
|
const yamlContent = stringifyYaml(config);
|
|
8689
8718
|
await writeFile4(configPath, yamlContent, "utf8");
|
|
@@ -9015,8 +9044,8 @@ import path8 from "path";
|
|
|
9015
9044
|
import * as fs7 from "fs";
|
|
9016
9045
|
import * as os6 from "os";
|
|
9017
9046
|
import * as tar4 from "tar";
|
|
9018
|
-
async function cloneStorage(name,
|
|
9019
|
-
const typeLabel =
|
|
9047
|
+
async function cloneStorage(name, type2, destination, options = {}) {
|
|
9048
|
+
const typeLabel = type2 === "artifact" ? "artifact" : "volume";
|
|
9020
9049
|
const dirStatus = checkDirectoryStatus(destination);
|
|
9021
9050
|
if (dirStatus.exists && !dirStatus.empty) {
|
|
9022
9051
|
throw new Error(`Directory "${destination}" is not empty`);
|
|
@@ -9024,13 +9053,13 @@ async function cloneStorage(name, type, destination, options = {}) {
|
|
|
9024
9053
|
console.log(chalk20.dim(`Checking remote ${typeLabel}...`));
|
|
9025
9054
|
const downloadInfo = await getStorageDownload({
|
|
9026
9055
|
name,
|
|
9027
|
-
type,
|
|
9056
|
+
type: type2,
|
|
9028
9057
|
version: options.version
|
|
9029
9058
|
});
|
|
9030
9059
|
console.log(chalk20.dim(`Creating directory: ${destination}/`));
|
|
9031
9060
|
await fs7.promises.mkdir(destination, { recursive: true });
|
|
9032
9061
|
if ("empty" in downloadInfo) {
|
|
9033
|
-
await writeStorageConfig(name, destination,
|
|
9062
|
+
await writeStorageConfig(name, destination, type2);
|
|
9034
9063
|
console.log(chalk20.green(`\u2713 Cloned empty ${typeLabel}: ${name}`));
|
|
9035
9064
|
console.log(chalk20.dim(`\u2713 Initialized .vm0/storage.yaml`));
|
|
9036
9065
|
return {
|
|
@@ -9066,7 +9095,7 @@ async function cloneStorage(name, type, destination, options = {}) {
|
|
|
9066
9095
|
await fs7.promises.unlink(tarPath);
|
|
9067
9096
|
await fs7.promises.rmdir(tmpDir);
|
|
9068
9097
|
console.log(chalk20.green(`\u2713 Extracted ${files.length} files`));
|
|
9069
|
-
await writeStorageConfig(name, destination,
|
|
9098
|
+
await writeStorageConfig(name, destination, type2);
|
|
9070
9099
|
console.log(chalk20.green(`\u2713 Initialized .vm0/storage.yaml`));
|
|
9071
9100
|
return {
|
|
9072
9101
|
success: true,
|
|
@@ -9468,21 +9497,20 @@ var artifactCommand = new Command26().name("artifact").description("Manage artif
|
|
|
9468
9497
|
import { Command as Command27, Option as Option5 } from "commander";
|
|
9469
9498
|
import chalk29 from "chalk";
|
|
9470
9499
|
import { readFile as readFile7, mkdir as mkdir6 } from "fs/promises";
|
|
9471
|
-
import { existsSync as
|
|
9500
|
+
import { existsSync as existsSync10 } from "fs";
|
|
9472
9501
|
import path11 from "path";
|
|
9473
9502
|
import { parse as parseYaml4 } from "yaml";
|
|
9474
|
-
import { config as dotenvConfig2 } from "dotenv";
|
|
9475
9503
|
|
|
9476
9504
|
// src/lib/domain/cook-state.ts
|
|
9477
|
-
import { homedir as
|
|
9478
|
-
import { join as
|
|
9505
|
+
import { homedir as homedir3 } from "os";
|
|
9506
|
+
import { join as join8 } from "path";
|
|
9479
9507
|
import { readFile as readFile6, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
9480
|
-
import { existsSync as
|
|
9481
|
-
var CONFIG_DIR2 =
|
|
9482
|
-
var COOK_STATE_FILE =
|
|
9508
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9509
|
+
var CONFIG_DIR2 = join8(homedir3(), ".vm0");
|
|
9510
|
+
var COOK_STATE_FILE = join8(CONFIG_DIR2, "cook.json");
|
|
9483
9511
|
var STALE_THRESHOLD_MS = 48 * 60 * 60 * 1e3;
|
|
9484
9512
|
async function loadCookStateFile() {
|
|
9485
|
-
if (!
|
|
9513
|
+
if (!existsSync8(COOK_STATE_FILE)) {
|
|
9486
9514
|
return { ppid: {} };
|
|
9487
9515
|
}
|
|
9488
9516
|
try {
|
|
@@ -9541,7 +9569,7 @@ async function saveCookState(state) {
|
|
|
9541
9569
|
// src/commands/cook/utils.ts
|
|
9542
9570
|
import chalk28 from "chalk";
|
|
9543
9571
|
import { spawn as spawn2 } from "child_process";
|
|
9544
|
-
import { existsSync as
|
|
9572
|
+
import { existsSync as existsSync9 } from "fs";
|
|
9545
9573
|
var CONFIG_FILE2 = "vm0.yaml";
|
|
9546
9574
|
var ARTIFACT_DIR = "artifact";
|
|
9547
9575
|
function printCommand(cmd) {
|
|
@@ -9644,7 +9672,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9644
9672
|
runOutput,
|
|
9645
9673
|
ARTIFACT_DIR
|
|
9646
9674
|
);
|
|
9647
|
-
if (serverVersion &&
|
|
9675
|
+
if (serverVersion && existsSync9(artifactDir)) {
|
|
9648
9676
|
console.log();
|
|
9649
9677
|
console.log(chalk28.bold("Pulling updated artifact:"));
|
|
9650
9678
|
printCommand(`cd ${ARTIFACT_DIR}`);
|
|
@@ -9665,37 +9693,9 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9665
9693
|
}
|
|
9666
9694
|
|
|
9667
9695
|
// src/commands/cook/cook.ts
|
|
9668
|
-
function extractRequiredVarNames(config) {
|
|
9669
|
-
const refs = extractVariableReferences(config);
|
|
9670
|
-
const grouped = groupVariablesBySource(refs);
|
|
9671
|
-
const varNames = grouped.vars.map((r) => r.name);
|
|
9672
|
-
const secretNames = grouped.secrets.map((r) => r.name);
|
|
9673
|
-
return [.../* @__PURE__ */ new Set([...varNames, ...secretNames])];
|
|
9674
|
-
}
|
|
9675
|
-
function checkMissingVariables(varNames, envFilePath) {
|
|
9676
|
-
let fileValues = {};
|
|
9677
|
-
if (envFilePath) {
|
|
9678
|
-
if (!existsSync9(envFilePath)) {
|
|
9679
|
-
throw new Error(`Environment file not found: ${envFilePath}`);
|
|
9680
|
-
}
|
|
9681
|
-
const result = dotenvConfig2({ path: envFilePath, quiet: true });
|
|
9682
|
-
if (result.parsed) {
|
|
9683
|
-
fileValues = result.parsed;
|
|
9684
|
-
}
|
|
9685
|
-
}
|
|
9686
|
-
const missing = [];
|
|
9687
|
-
for (const name of varNames) {
|
|
9688
|
-
const inEnv = process.env[name] !== void 0;
|
|
9689
|
-
const inFile = fileValues[name] !== void 0;
|
|
9690
|
-
if (!inEnv && !inFile) {
|
|
9691
|
-
missing.push(name);
|
|
9692
|
-
}
|
|
9693
|
-
}
|
|
9694
|
-
return missing;
|
|
9695
|
-
}
|
|
9696
9696
|
async function loadAndValidateConfig2() {
|
|
9697
9697
|
console.log(chalk29.bold(`Reading config: ${CONFIG_FILE2}`));
|
|
9698
|
-
if (!
|
|
9698
|
+
if (!existsSync10(CONFIG_FILE2)) {
|
|
9699
9699
|
console.error(chalk29.red(`\u2717 Config file not found: ${CONFIG_FILE2}`));
|
|
9700
9700
|
process.exit(1);
|
|
9701
9701
|
}
|
|
@@ -9723,33 +9723,6 @@ async function loadAndValidateConfig2() {
|
|
|
9723
9723
|
);
|
|
9724
9724
|
return { config, agentName, volumeCount };
|
|
9725
9725
|
}
|
|
9726
|
-
function validateEnvVariables(config, envFile) {
|
|
9727
|
-
const requiredVarNames = extractRequiredVarNames(config);
|
|
9728
|
-
if (requiredVarNames.length === 0) {
|
|
9729
|
-
return;
|
|
9730
|
-
}
|
|
9731
|
-
try {
|
|
9732
|
-
const missingVars = checkMissingVariables(requiredVarNames, envFile);
|
|
9733
|
-
if (missingVars.length > 0) {
|
|
9734
|
-
console.error();
|
|
9735
|
-
console.error(chalk29.red("\u2717 Missing required variables:"));
|
|
9736
|
-
for (const varName of missingVars) {
|
|
9737
|
-
console.error(chalk29.red(` ${varName}`));
|
|
9738
|
-
}
|
|
9739
|
-
console.error(
|
|
9740
|
-
chalk29.dim(
|
|
9741
|
-
"\n Provide via --env-file, or set as environment variables"
|
|
9742
|
-
)
|
|
9743
|
-
);
|
|
9744
|
-
process.exit(1);
|
|
9745
|
-
}
|
|
9746
|
-
} catch (error) {
|
|
9747
|
-
if (error instanceof Error) {
|
|
9748
|
-
console.error(chalk29.red(`\u2717 ${error.message}`));
|
|
9749
|
-
}
|
|
9750
|
-
process.exit(1);
|
|
9751
|
-
}
|
|
9752
|
-
}
|
|
9753
9726
|
async function processVolumes(config, cwd) {
|
|
9754
9727
|
if (!config.volumes || Object.keys(config.volumes).length === 0) {
|
|
9755
9728
|
return;
|
|
@@ -9758,7 +9731,7 @@ async function processVolumes(config, cwd) {
|
|
|
9758
9731
|
console.log(chalk29.bold("Processing volumes:"));
|
|
9759
9732
|
for (const volumeConfig of Object.values(config.volumes)) {
|
|
9760
9733
|
const volumeDir = path11.join(cwd, volumeConfig.name);
|
|
9761
|
-
if (!
|
|
9734
|
+
if (!existsSync10(volumeDir)) {
|
|
9762
9735
|
console.error(chalk29.red(`\u2717 Directory not found: ${volumeConfig.name}`));
|
|
9763
9736
|
console.error(chalk29.dim(" Create the directory and add files first"));
|
|
9764
9737
|
process.exit(1);
|
|
@@ -9793,7 +9766,7 @@ async function processArtifact(cwd) {
|
|
|
9793
9766
|
console.log(chalk29.bold("Processing artifact:"));
|
|
9794
9767
|
const artifactDir = path11.join(cwd, ARTIFACT_DIR);
|
|
9795
9768
|
try {
|
|
9796
|
-
if (!
|
|
9769
|
+
if (!existsSync10(artifactDir)) {
|
|
9797
9770
|
printCommand(`mkdir ${ARTIFACT_DIR}`);
|
|
9798
9771
|
await mkdir6(artifactDir, { recursive: true });
|
|
9799
9772
|
}
|
|
@@ -9850,6 +9823,7 @@ async function runAgent(agentName, artifactDir, prompt, cwd, options) {
|
|
|
9850
9823
|
agentName,
|
|
9851
9824
|
"--artifact-name",
|
|
9852
9825
|
ARTIFACT_DIR,
|
|
9826
|
+
...options.envFile ? ["--env-file", options.envFile] : [],
|
|
9853
9827
|
...options.verbose ? ["--verbose"] : [],
|
|
9854
9828
|
...options.debugNoMockClaude ? ["--debug-no-mock-claude"] : [],
|
|
9855
9829
|
prompt
|
|
@@ -9874,19 +9848,19 @@ var cookAction = new Command27().name("cook").description("Quick start: prepare,
|
|
|
9874
9848
|
).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(
|
|
9875
9849
|
async (prompt, options) => {
|
|
9876
9850
|
if (options.autoUpdate !== false) {
|
|
9877
|
-
const shouldExit = await checkAndUpgrade("9.27.
|
|
9851
|
+
const shouldExit = await checkAndUpgrade("9.27.2", prompt);
|
|
9878
9852
|
if (shouldExit) {
|
|
9879
9853
|
process.exit(0);
|
|
9880
9854
|
}
|
|
9881
9855
|
}
|
|
9882
9856
|
const cwd = process.cwd();
|
|
9883
9857
|
const { config, agentName } = await loadAndValidateConfig2();
|
|
9884
|
-
validateEnvVariables(config, options.envFile);
|
|
9885
9858
|
await processVolumes(config, cwd);
|
|
9886
9859
|
const artifactDir = await processArtifact(cwd);
|
|
9887
9860
|
await composeAgent(cwd, options.yes ?? false);
|
|
9888
9861
|
if (prompt) {
|
|
9889
9862
|
await runAgent(agentName, artifactDir, prompt, cwd, {
|
|
9863
|
+
envFile: options.envFile,
|
|
9890
9864
|
verbose: options.verbose,
|
|
9891
9865
|
debugNoMockClaude: options.debugNoMockClaude
|
|
9892
9866
|
});
|
|
@@ -10457,7 +10431,7 @@ import { Command as Command35 } from "commander";
|
|
|
10457
10431
|
import chalk36 from "chalk";
|
|
10458
10432
|
import { mkdtempSync as mkdtempSync5 } from "fs";
|
|
10459
10433
|
import { mkdir as mkdir7, writeFile as writeFile6, readdir, copyFile, rm as rm4 } from "fs/promises";
|
|
10460
|
-
import { join as
|
|
10434
|
+
import { join as join9, dirname as dirname3 } from "path";
|
|
10461
10435
|
import { tmpdir as tmpdir7 } from "os";
|
|
10462
10436
|
import * as tar6 from "tar";
|
|
10463
10437
|
import { stringify as yamlStringify } from "yaml";
|
|
@@ -10493,8 +10467,8 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10493
10467
|
throw new Error(`Failed to download instructions: ${response.status}`);
|
|
10494
10468
|
}
|
|
10495
10469
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10496
|
-
const tmpDir = mkdtempSync5(
|
|
10497
|
-
const tarPath =
|
|
10470
|
+
const tmpDir = mkdtempSync5(join9(tmpdir7(), "vm0-clone-"));
|
|
10471
|
+
const tarPath = join9(tmpDir, "archive.tar.gz");
|
|
10498
10472
|
await writeFile6(tarPath, buffer);
|
|
10499
10473
|
await tar6.extract({ file: tarPath, cwd: tmpDir, gzip: true });
|
|
10500
10474
|
const files = await readdir(tmpDir);
|
|
@@ -10504,9 +10478,9 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10504
10478
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10505
10479
|
return false;
|
|
10506
10480
|
}
|
|
10507
|
-
const destPath =
|
|
10481
|
+
const destPath = join9(destination, instructionsPath);
|
|
10508
10482
|
await mkdir7(dirname3(destPath), { recursive: true });
|
|
10509
|
-
await copyFile(
|
|
10483
|
+
await copyFile(join9(tmpDir, mdFile), destPath);
|
|
10510
10484
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10511
10485
|
return true;
|
|
10512
10486
|
}
|
|
@@ -10532,7 +10506,7 @@ var cloneCommand3 = new Command35().name("clone").description("Clone agent compo
|
|
|
10532
10506
|
const cleanedContent = cleanComposeContent(content);
|
|
10533
10507
|
const yamlContent = yamlStringify(cleanedContent);
|
|
10534
10508
|
await mkdir7(targetDir, { recursive: true });
|
|
10535
|
-
const yamlPath =
|
|
10509
|
+
const yamlPath = join9(targetDir, "vm0.yaml");
|
|
10536
10510
|
await writeFile6(yamlPath, yamlContent, "utf8");
|
|
10537
10511
|
console.log(chalk36.green("\u2713 Created vm0.yaml"));
|
|
10538
10512
|
const agentKey = Object.keys(content.agents)[0];
|
|
@@ -11057,11 +11031,11 @@ var permissionCommand = new Command42().name("experimental-permission").descript
|
|
|
11057
11031
|
)
|
|
11058
11032
|
);
|
|
11059
11033
|
for (const p of data.permissions) {
|
|
11060
|
-
const
|
|
11034
|
+
const type2 = p.granteeType.padEnd(7);
|
|
11061
11035
|
const email = (p.granteeEmail ?? "-").padEnd(29);
|
|
11062
11036
|
const permission = p.permission.padEnd(10);
|
|
11063
11037
|
const granted = formatRelativeTime(p.createdAt);
|
|
11064
|
-
console.log(`${
|
|
11038
|
+
console.log(`${type2} ${email} ${permission} ${granted}`);
|
|
11065
11039
|
}
|
|
11066
11040
|
} catch (error) {
|
|
11067
11041
|
console.error(chalk43.red("\u2717 Failed to list permissions"));
|
|
@@ -11079,7 +11053,7 @@ var agentCommand = new Command43().name("agent").description("Manage agent compo
|
|
|
11079
11053
|
import { Command as Command44 } from "commander";
|
|
11080
11054
|
import chalk44 from "chalk";
|
|
11081
11055
|
import path15 from "path";
|
|
11082
|
-
import { existsSync as
|
|
11056
|
+
import { existsSync as existsSync11 } from "fs";
|
|
11083
11057
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
11084
11058
|
var VM0_YAML_FILE = "vm0.yaml";
|
|
11085
11059
|
var AGENTS_MD_FILE = "AGENTS.md";
|
|
@@ -11111,8 +11085,8 @@ You are a HackerNews AI content curator.
|
|
|
11111
11085
|
}
|
|
11112
11086
|
function checkExistingFiles() {
|
|
11113
11087
|
const existingFiles = [];
|
|
11114
|
-
if (
|
|
11115
|
-
if (
|
|
11088
|
+
if (existsSync11(VM0_YAML_FILE)) existingFiles.push(VM0_YAML_FILE);
|
|
11089
|
+
if (existsSync11(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
|
|
11116
11090
|
return existingFiles;
|
|
11117
11091
|
}
|
|
11118
11092
|
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) => {
|
|
@@ -11372,7 +11346,7 @@ function formatInTimezone(isoDate, timezone) {
|
|
|
11372
11346
|
minute: "2-digit",
|
|
11373
11347
|
hour12: false
|
|
11374
11348
|
}).formatToParts(date);
|
|
11375
|
-
const get = (
|
|
11349
|
+
const get = (type2) => parts.find((p) => p.type === type2)?.value ?? "";
|
|
11376
11350
|
return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}`;
|
|
11377
11351
|
}
|
|
11378
11352
|
function parseFrequencyFromCron(cron) {
|
|
@@ -12622,9 +12596,9 @@ function validateProviderType(typeStr) {
|
|
|
12622
12596
|
}
|
|
12623
12597
|
return typeStr;
|
|
12624
12598
|
}
|
|
12625
|
-
function validateModel(
|
|
12626
|
-
const models = getModels(
|
|
12627
|
-
if (allowsCustomModel(
|
|
12599
|
+
function validateModel(type2, modelStr) {
|
|
12600
|
+
const models = getModels(type2);
|
|
12601
|
+
if (allowsCustomModel(type2)) {
|
|
12628
12602
|
return modelStr;
|
|
12629
12603
|
}
|
|
12630
12604
|
if (models && !models.includes(modelStr)) {
|
|
@@ -12638,8 +12612,8 @@ function validateModel(type, modelStr) {
|
|
|
12638
12612
|
}
|
|
12639
12613
|
return modelStr;
|
|
12640
12614
|
}
|
|
12641
|
-
function validateAuthMethod(
|
|
12642
|
-
const authMethods = getAuthMethodsForType(
|
|
12615
|
+
function validateAuthMethod(type2, authMethodStr) {
|
|
12616
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12643
12617
|
if (!authMethods || !(authMethodStr in authMethods)) {
|
|
12644
12618
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethodStr}"`));
|
|
12645
12619
|
console.error();
|
|
@@ -12653,8 +12627,8 @@ function validateAuthMethod(type, authMethodStr) {
|
|
|
12653
12627
|
}
|
|
12654
12628
|
return authMethodStr;
|
|
12655
12629
|
}
|
|
12656
|
-
function parseSecrets(
|
|
12657
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12630
|
+
function parseSecrets(type2, authMethod, secretArgs) {
|
|
12631
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12658
12632
|
if (!secretsConfig) {
|
|
12659
12633
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12660
12634
|
process.exit(1);
|
|
@@ -12696,8 +12670,8 @@ function parseSecrets(type, authMethod, secretArgs) {
|
|
|
12696
12670
|
}
|
|
12697
12671
|
return secrets;
|
|
12698
12672
|
}
|
|
12699
|
-
function validateSecrets(
|
|
12700
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12673
|
+
function validateSecrets(type2, authMethod, secrets) {
|
|
12674
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12701
12675
|
if (!secretsConfig) {
|
|
12702
12676
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12703
12677
|
process.exit(1);
|
|
@@ -12729,23 +12703,23 @@ function validateSecrets(type, authMethod, secrets) {
|
|
|
12729
12703
|
}
|
|
12730
12704
|
}
|
|
12731
12705
|
function handleNonInteractiveMode(options) {
|
|
12732
|
-
const
|
|
12706
|
+
const type2 = validateProviderType(options.type);
|
|
12733
12707
|
let selectedModel;
|
|
12734
12708
|
if (options.model) {
|
|
12735
|
-
selectedModel = validateModel(
|
|
12736
|
-
} else if (hasModelSelection(
|
|
12737
|
-
const defaultModel = getDefaultModel(
|
|
12709
|
+
selectedModel = validateModel(type2, options.model);
|
|
12710
|
+
} else if (hasModelSelection(type2)) {
|
|
12711
|
+
const defaultModel = getDefaultModel(type2);
|
|
12738
12712
|
selectedModel = defaultModel || void 0;
|
|
12739
12713
|
}
|
|
12740
|
-
if (hasAuthMethods(
|
|
12714
|
+
if (hasAuthMethods(type2)) {
|
|
12741
12715
|
let authMethod;
|
|
12742
12716
|
if (options.authMethod) {
|
|
12743
|
-
authMethod = validateAuthMethod(
|
|
12717
|
+
authMethod = validateAuthMethod(type2, options.authMethod);
|
|
12744
12718
|
} else {
|
|
12745
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12746
|
-
const authMethods = getAuthMethodsForType(
|
|
12719
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12720
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12747
12721
|
if (!defaultAuthMethod || !authMethods) {
|
|
12748
|
-
console.error(chalk59.red(`\u2717 Provider "${
|
|
12722
|
+
console.error(chalk59.red(`\u2717 Provider "${type2}" requires --auth-method`));
|
|
12749
12723
|
process.exit(1);
|
|
12750
12724
|
}
|
|
12751
12725
|
const authMethodNames = Object.keys(authMethods);
|
|
@@ -12754,7 +12728,7 @@ function handleNonInteractiveMode(options) {
|
|
|
12754
12728
|
} else {
|
|
12755
12729
|
console.error(
|
|
12756
12730
|
chalk59.red(
|
|
12757
|
-
`\u2717 --auth-method is required for "${
|
|
12731
|
+
`\u2717 --auth-method is required for "${type2}" (multiple auth methods available)`
|
|
12758
12732
|
)
|
|
12759
12733
|
);
|
|
12760
12734
|
console.error();
|
|
@@ -12769,16 +12743,16 @@ function handleNonInteractiveMode(options) {
|
|
|
12769
12743
|
console.error("Example:");
|
|
12770
12744
|
console.error(
|
|
12771
12745
|
chalk59.cyan(
|
|
12772
|
-
` vm0 model-provider setup --type ${
|
|
12746
|
+
` vm0 model-provider setup --type ${type2} --auth-method ${authMethodNames[0]} --secret KEY=VALUE`
|
|
12773
12747
|
)
|
|
12774
12748
|
);
|
|
12775
12749
|
process.exit(1);
|
|
12776
12750
|
}
|
|
12777
12751
|
}
|
|
12778
|
-
const secrets = parseSecrets(
|
|
12779
|
-
validateSecrets(
|
|
12752
|
+
const secrets = parseSecrets(type2, authMethod, options.secret);
|
|
12753
|
+
validateSecrets(type2, authMethod, secrets);
|
|
12780
12754
|
return {
|
|
12781
|
-
type,
|
|
12755
|
+
type: type2,
|
|
12782
12756
|
authMethod,
|
|
12783
12757
|
secrets,
|
|
12784
12758
|
selectedModel,
|
|
@@ -12798,19 +12772,19 @@ function handleNonInteractiveMode(options) {
|
|
|
12798
12772
|
secret = firstArg;
|
|
12799
12773
|
}
|
|
12800
12774
|
return {
|
|
12801
|
-
type,
|
|
12775
|
+
type: type2,
|
|
12802
12776
|
secret,
|
|
12803
12777
|
selectedModel,
|
|
12804
12778
|
isInteractiveMode: false
|
|
12805
12779
|
};
|
|
12806
12780
|
}
|
|
12807
|
-
async function promptForModelSelection(
|
|
12808
|
-
if (!hasModelSelection(
|
|
12781
|
+
async function promptForModelSelection(type2) {
|
|
12782
|
+
if (!hasModelSelection(type2)) {
|
|
12809
12783
|
return void 0;
|
|
12810
12784
|
}
|
|
12811
|
-
const models = getModels(
|
|
12812
|
-
const defaultModel = getDefaultModel(
|
|
12813
|
-
const supportsCustomModel = allowsCustomModel(
|
|
12785
|
+
const models = getModels(type2) ?? [];
|
|
12786
|
+
const defaultModel = getDefaultModel(type2);
|
|
12787
|
+
const supportsCustomModel = allowsCustomModel(type2);
|
|
12814
12788
|
const modelChoices = [];
|
|
12815
12789
|
if (defaultModel === "") {
|
|
12816
12790
|
modelChoices.push({ title: "auto (Recommended)", value: "" });
|
|
@@ -12835,7 +12809,7 @@ async function promptForModelSelection(type) {
|
|
|
12835
12809
|
);
|
|
12836
12810
|
const selected = modelResponse.model;
|
|
12837
12811
|
if (selected === "__custom__") {
|
|
12838
|
-
const placeholder = getCustomModelPlaceholder(
|
|
12812
|
+
const placeholder = getCustomModelPlaceholder(type2);
|
|
12839
12813
|
if (placeholder) {
|
|
12840
12814
|
console.log(chalk59.dim(`Example: ${placeholder}`));
|
|
12841
12815
|
}
|
|
@@ -12852,9 +12826,9 @@ async function promptForModelSelection(type) {
|
|
|
12852
12826
|
}
|
|
12853
12827
|
return selected === "" ? void 0 : selected;
|
|
12854
12828
|
}
|
|
12855
|
-
async function promptForAuthMethod(
|
|
12856
|
-
const authMethods = getAuthMethodsForType(
|
|
12857
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12829
|
+
async function promptForAuthMethod(type2) {
|
|
12830
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12831
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12858
12832
|
if (!authMethods) {
|
|
12859
12833
|
return "default";
|
|
12860
12834
|
}
|
|
@@ -12879,8 +12853,8 @@ function isSensitiveSecret(name) {
|
|
|
12879
12853
|
(pattern) => name.toUpperCase().includes(pattern)
|
|
12880
12854
|
);
|
|
12881
12855
|
}
|
|
12882
|
-
async function promptForSecrets(
|
|
12883
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12856
|
+
async function promptForSecrets(type2, authMethod) {
|
|
12857
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12884
12858
|
if (!secretsConfig) {
|
|
12885
12859
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12886
12860
|
process.exit(1);
|
|
@@ -12934,9 +12908,9 @@ async function handleInteractiveMode() {
|
|
|
12934
12908
|
const { modelProviders: configuredProviders } = await listModelProviders();
|
|
12935
12909
|
const configuredTypes = new Set(configuredProviders.map((p) => p.type));
|
|
12936
12910
|
const annotatedChoices = Object.entries(MODEL_PROVIDER_TYPES).map(
|
|
12937
|
-
([
|
|
12938
|
-
const isConfigured = configuredTypes.has(
|
|
12939
|
-
const isExperimental = hasAuthMethods(
|
|
12911
|
+
([type3, config2]) => {
|
|
12912
|
+
const isConfigured = configuredTypes.has(type3);
|
|
12913
|
+
const isExperimental = hasAuthMethods(type3);
|
|
12940
12914
|
let title = config2.label;
|
|
12941
12915
|
if (isConfigured) {
|
|
12942
12916
|
title = `${title} \u2713`;
|
|
@@ -12946,7 +12920,7 @@ async function handleInteractiveMode() {
|
|
|
12946
12920
|
}
|
|
12947
12921
|
return {
|
|
12948
12922
|
title,
|
|
12949
|
-
value:
|
|
12923
|
+
value: type3
|
|
12950
12924
|
};
|
|
12951
12925
|
}
|
|
12952
12926
|
);
|
|
@@ -12959,11 +12933,11 @@ async function handleInteractiveMode() {
|
|
|
12959
12933
|
},
|
|
12960
12934
|
{ onCancel: () => process.exit(0) }
|
|
12961
12935
|
);
|
|
12962
|
-
const
|
|
12963
|
-
const checkResult = await checkModelProviderSecret(
|
|
12936
|
+
const type2 = typeResponse.type;
|
|
12937
|
+
const checkResult = await checkModelProviderSecret(type2);
|
|
12964
12938
|
if (checkResult.exists) {
|
|
12965
12939
|
console.log();
|
|
12966
|
-
console.log(`"${
|
|
12940
|
+
console.log(`"${type2}" is already configured`);
|
|
12967
12941
|
console.log();
|
|
12968
12942
|
const actionResponse = await prompts2(
|
|
12969
12943
|
{
|
|
@@ -12978,25 +12952,25 @@ async function handleInteractiveMode() {
|
|
|
12978
12952
|
{ onCancel: () => process.exit(0) }
|
|
12979
12953
|
);
|
|
12980
12954
|
if (actionResponse.action === "keep") {
|
|
12981
|
-
const selectedModel2 = await promptForModelSelection(
|
|
12955
|
+
const selectedModel2 = await promptForModelSelection(type2);
|
|
12982
12956
|
return {
|
|
12983
|
-
type,
|
|
12957
|
+
type: type2,
|
|
12984
12958
|
keepExistingSecret: true,
|
|
12985
12959
|
selectedModel: selectedModel2,
|
|
12986
12960
|
isInteractiveMode: true
|
|
12987
12961
|
};
|
|
12988
12962
|
}
|
|
12989
12963
|
}
|
|
12990
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
12964
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
12991
12965
|
console.log();
|
|
12992
12966
|
console.log(chalk59.dim(config.helpText));
|
|
12993
12967
|
console.log();
|
|
12994
|
-
if (hasAuthMethods(
|
|
12995
|
-
const authMethod = await promptForAuthMethod(
|
|
12996
|
-
const secrets = await promptForSecrets(
|
|
12997
|
-
const selectedModel2 = await promptForModelSelection(
|
|
12968
|
+
if (hasAuthMethods(type2)) {
|
|
12969
|
+
const authMethod = await promptForAuthMethod(type2);
|
|
12970
|
+
const secrets = await promptForSecrets(type2, authMethod);
|
|
12971
|
+
const selectedModel2 = await promptForModelSelection(type2);
|
|
12998
12972
|
return {
|
|
12999
|
-
type,
|
|
12973
|
+
type: type2,
|
|
13000
12974
|
authMethod,
|
|
13001
12975
|
secrets,
|
|
13002
12976
|
selectedModel: selectedModel2,
|
|
@@ -13014,8 +12988,8 @@ async function handleInteractiveMode() {
|
|
|
13014
12988
|
{ onCancel: () => process.exit(0) }
|
|
13015
12989
|
);
|
|
13016
12990
|
const secret = secretResponse.secret;
|
|
13017
|
-
const selectedModel = await promptForModelSelection(
|
|
13018
|
-
return { type, secret, selectedModel, isInteractiveMode: true };
|
|
12991
|
+
const selectedModel = await promptForModelSelection(type2);
|
|
12992
|
+
return { type: type2, secret, selectedModel, isInteractiveMode: true };
|
|
13019
12993
|
}
|
|
13020
12994
|
function handleSetupError2(error) {
|
|
13021
12995
|
if (error instanceof Error) {
|
|
@@ -13030,7 +13004,7 @@ function handleSetupError2(error) {
|
|
|
13030
13004
|
}
|
|
13031
13005
|
process.exit(1);
|
|
13032
13006
|
}
|
|
13033
|
-
async function promptSetAsDefault(
|
|
13007
|
+
async function promptSetAsDefault(type2, framework, isDefault) {
|
|
13034
13008
|
if (isDefault) return;
|
|
13035
13009
|
const response = await prompts2(
|
|
13036
13010
|
{
|
|
@@ -13042,8 +13016,8 @@ async function promptSetAsDefault(type, framework, isDefault) {
|
|
|
13042
13016
|
{ onCancel: () => process.exit(0) }
|
|
13043
13017
|
);
|
|
13044
13018
|
if (response.setDefault) {
|
|
13045
|
-
await setModelProviderDefault(
|
|
13046
|
-
console.log(chalk59.green(`\u2713 Default for ${framework} set to "${
|
|
13019
|
+
await setModelProviderDefault(type2);
|
|
13020
|
+
console.log(chalk59.green(`\u2713 Default for ${framework} set to "${type2}"`));
|
|
13047
13021
|
}
|
|
13048
13022
|
}
|
|
13049
13023
|
function collectSecrets(value, previous) {
|
|
@@ -13137,10 +13111,10 @@ var setupCommand2 = new Command62().name("setup").description("Configure a model
|
|
|
13137
13111
|
// src/commands/model-provider/delete.ts
|
|
13138
13112
|
import { Command as Command63 } from "commander";
|
|
13139
13113
|
import chalk60 from "chalk";
|
|
13140
|
-
var deleteCommand4 = new Command63().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (
|
|
13114
|
+
var deleteCommand4 = new Command63().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (type2) => {
|
|
13141
13115
|
try {
|
|
13142
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13143
|
-
console.error(chalk60.red(`\u2717 Invalid type "${
|
|
13116
|
+
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
13117
|
+
console.error(chalk60.red(`\u2717 Invalid type "${type2}"`));
|
|
13144
13118
|
console.log();
|
|
13145
13119
|
console.log("Valid types:");
|
|
13146
13120
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13148,12 +13122,12 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13148
13122
|
}
|
|
13149
13123
|
process.exit(1);
|
|
13150
13124
|
}
|
|
13151
|
-
await deleteModelProvider(
|
|
13152
|
-
console.log(chalk60.green(`\u2713 Model provider "${
|
|
13125
|
+
await deleteModelProvider(type2);
|
|
13126
|
+
console.log(chalk60.green(`\u2713 Model provider "${type2}" deleted`));
|
|
13153
13127
|
} catch (error) {
|
|
13154
13128
|
if (error instanceof Error) {
|
|
13155
13129
|
if (error.message.includes("not found")) {
|
|
13156
|
-
console.error(chalk60.red(`\u2717 Model provider "${
|
|
13130
|
+
console.error(chalk60.red(`\u2717 Model provider "${type2}" not found`));
|
|
13157
13131
|
} else if (error.message.includes("Not authenticated")) {
|
|
13158
13132
|
console.error(chalk60.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13159
13133
|
} else {
|
|
@@ -13169,10 +13143,10 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13169
13143
|
// src/commands/model-provider/set-default.ts
|
|
13170
13144
|
import { Command as Command64 } from "commander";
|
|
13171
13145
|
import chalk61 from "chalk";
|
|
13172
|
-
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 (
|
|
13146
|
+
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) => {
|
|
13173
13147
|
try {
|
|
13174
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13175
|
-
console.error(chalk61.red(`\u2717 Invalid type "${
|
|
13148
|
+
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
13149
|
+
console.error(chalk61.red(`\u2717 Invalid type "${type2}"`));
|
|
13176
13150
|
console.log();
|
|
13177
13151
|
console.log("Valid types:");
|
|
13178
13152
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13180,7 +13154,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13180
13154
|
}
|
|
13181
13155
|
process.exit(1);
|
|
13182
13156
|
}
|
|
13183
|
-
const provider = await setModelProviderDefault(
|
|
13157
|
+
const provider = await setModelProviderDefault(type2);
|
|
13184
13158
|
console.log(
|
|
13185
13159
|
chalk61.green(
|
|
13186
13160
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
@@ -13189,7 +13163,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13189
13163
|
} catch (error) {
|
|
13190
13164
|
if (error instanceof Error) {
|
|
13191
13165
|
if (error.message.includes("not found")) {
|
|
13192
|
-
console.error(chalk61.red(`\u2717 Model provider "${
|
|
13166
|
+
console.error(chalk61.red(`\u2717 Model provider "${type2}" not found`));
|
|
13193
13167
|
} else if (error.message.includes("Not authenticated")) {
|
|
13194
13168
|
console.error(chalk61.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13195
13169
|
} else {
|
|
@@ -13229,17 +13203,17 @@ async function getHeaders2() {
|
|
|
13229
13203
|
}
|
|
13230
13204
|
return headers;
|
|
13231
13205
|
}
|
|
13232
|
-
var connectCommand = new Command66().name("connect").description("Connect a third-party service (e.g., GitHub)").argument("<type>", "Connector type (e.g., github)").action(async (
|
|
13233
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13206
|
+
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) => {
|
|
13207
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13234
13208
|
if (!parseResult.success) {
|
|
13235
|
-
console.error(chalk62.red(`\u2717 Unknown connector type: ${
|
|
13209
|
+
console.error(chalk62.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13236
13210
|
console.error("Available connectors: github");
|
|
13237
13211
|
process.exit(1);
|
|
13238
13212
|
}
|
|
13239
13213
|
const connectorType = parseResult.data;
|
|
13240
13214
|
const apiUrl = await getApiUrl();
|
|
13241
13215
|
const headers = await getHeaders2();
|
|
13242
|
-
console.log(`Connecting ${chalk62.cyan(
|
|
13216
|
+
console.log(`Connecting ${chalk62.cyan(type2)}...`);
|
|
13243
13217
|
const sessionsClient = initClient12(connectorSessionsContract, {
|
|
13244
13218
|
baseUrl: apiUrl,
|
|
13245
13219
|
baseHeaders: headers,
|
|
@@ -13296,7 +13270,7 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
13296
13270
|
case "complete":
|
|
13297
13271
|
console.log(chalk62.green(`
|
|
13298
13272
|
|
|
13299
|
-
${
|
|
13273
|
+
${type2} connected successfully!`));
|
|
13300
13274
|
return;
|
|
13301
13275
|
case "expired":
|
|
13302
13276
|
console.error(chalk62.red("\n\u2717 Session expired, please try again"));
|
|
@@ -13337,11 +13311,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13337
13311
|
"ACCOUNT"
|
|
13338
13312
|
].join(" ");
|
|
13339
13313
|
console.log(chalk63.dim(header));
|
|
13340
|
-
for (const
|
|
13341
|
-
const connector = connectedMap.get(
|
|
13314
|
+
for (const type2 of allTypes) {
|
|
13315
|
+
const connector = connectedMap.get(type2);
|
|
13342
13316
|
const status = connector ? chalk63.green("\u2713".padEnd(statusWidth)) : chalk63.dim("-".padEnd(statusWidth));
|
|
13343
13317
|
const account = connector?.externalUsername ? `@${connector.externalUsername}` : chalk63.dim("-");
|
|
13344
|
-
const row = [
|
|
13318
|
+
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
13345
13319
|
console.log(row);
|
|
13346
13320
|
}
|
|
13347
13321
|
console.log();
|
|
@@ -13365,11 +13339,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13365
13339
|
import { Command as Command68 } from "commander";
|
|
13366
13340
|
import chalk64 from "chalk";
|
|
13367
13341
|
var LABEL_WIDTH = 16;
|
|
13368
|
-
var statusCommand7 = new Command68().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(async (
|
|
13342
|
+
var statusCommand7 = new Command68().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(async (type2) => {
|
|
13369
13343
|
try {
|
|
13370
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13344
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13371
13345
|
if (!parseResult.success) {
|
|
13372
|
-
console.error(chalk64.red(`\u2717 Unknown connector type: ${
|
|
13346
|
+
console.error(chalk64.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13373
13347
|
console.error();
|
|
13374
13348
|
console.error("Available connectors:");
|
|
13375
13349
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13378,7 +13352,7 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13378
13352
|
process.exit(1);
|
|
13379
13353
|
}
|
|
13380
13354
|
const connector = await getConnector(parseResult.data);
|
|
13381
|
-
console.log(`Connector: ${chalk64.cyan(
|
|
13355
|
+
console.log(`Connector: ${chalk64.cyan(type2)}`);
|
|
13382
13356
|
console.log();
|
|
13383
13357
|
if (connector) {
|
|
13384
13358
|
console.log(
|
|
@@ -13405,14 +13379,14 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13405
13379
|
}
|
|
13406
13380
|
console.log();
|
|
13407
13381
|
console.log(chalk64.dim("To disconnect:"));
|
|
13408
|
-
console.log(chalk64.dim(` vm0 connector disconnect ${
|
|
13382
|
+
console.log(chalk64.dim(` vm0 connector disconnect ${type2}`));
|
|
13409
13383
|
} else {
|
|
13410
13384
|
console.log(
|
|
13411
13385
|
`${"Status:".padEnd(LABEL_WIDTH)}${chalk64.dim("not connected")}`
|
|
13412
13386
|
);
|
|
13413
13387
|
console.log();
|
|
13414
13388
|
console.log(chalk64.dim("To connect:"));
|
|
13415
|
-
console.log(chalk64.dim(` vm0 connector connect ${
|
|
13389
|
+
console.log(chalk64.dim(` vm0 connector connect ${type2}`));
|
|
13416
13390
|
}
|
|
13417
13391
|
} catch (error) {
|
|
13418
13392
|
if (error instanceof Error) {
|
|
@@ -13431,11 +13405,11 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13431
13405
|
// src/commands/connector/disconnect.ts
|
|
13432
13406
|
import { Command as Command69 } from "commander";
|
|
13433
13407
|
import chalk65 from "chalk";
|
|
13434
|
-
var disconnectCommand = new Command69().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(async (
|
|
13408
|
+
var disconnectCommand = new Command69().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(async (type2) => {
|
|
13435
13409
|
try {
|
|
13436
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13410
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13437
13411
|
if (!parseResult.success) {
|
|
13438
|
-
console.error(chalk65.red(`\u2717 Unknown connector type: ${
|
|
13412
|
+
console.error(chalk65.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13439
13413
|
console.error();
|
|
13440
13414
|
console.error("Available connectors:");
|
|
13441
13415
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13444,11 +13418,11 @@ var disconnectCommand = new Command69().name("disconnect").description("Disconne
|
|
|
13444
13418
|
process.exit(1);
|
|
13445
13419
|
}
|
|
13446
13420
|
await deleteConnector(parseResult.data);
|
|
13447
|
-
console.log(chalk65.green(`\u2713 Disconnected ${
|
|
13421
|
+
console.log(chalk65.green(`\u2713 Disconnected ${type2}`));
|
|
13448
13422
|
} catch (error) {
|
|
13449
13423
|
if (error instanceof Error) {
|
|
13450
13424
|
if (error.message.includes("not found")) {
|
|
13451
|
-
console.error(chalk65.red(`\u2717 Connector "${
|
|
13425
|
+
console.error(chalk65.red(`\u2717 Connector "${type2}" is not connected`));
|
|
13452
13426
|
} else if (error.message.includes("Not authenticated")) {
|
|
13453
13427
|
console.error(chalk65.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13454
13428
|
} else {
|
|
@@ -13468,7 +13442,7 @@ var connectorCommand = new Command70().name("connector").description("Manage thi
|
|
|
13468
13442
|
import { Command as Command71 } from "commander";
|
|
13469
13443
|
import chalk69 from "chalk";
|
|
13470
13444
|
import { mkdir as mkdir8 } from "fs/promises";
|
|
13471
|
-
import { existsSync as
|
|
13445
|
+
import { existsSync as existsSync12 } from "fs";
|
|
13472
13446
|
|
|
13473
13447
|
// src/lib/ui/welcome-box.ts
|
|
13474
13448
|
import chalk66 from "chalk";
|
|
@@ -13697,21 +13671,21 @@ async function checkModelProviderStatus() {
|
|
|
13697
13671
|
};
|
|
13698
13672
|
}
|
|
13699
13673
|
function getProviderChoices() {
|
|
13700
|
-
return ONBOARD_PROVIDER_TYPES.map((
|
|
13701
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
13674
|
+
return ONBOARD_PROVIDER_TYPES.map((type2) => {
|
|
13675
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
13702
13676
|
return {
|
|
13703
|
-
type,
|
|
13677
|
+
type: type2,
|
|
13704
13678
|
label: config.label,
|
|
13705
13679
|
helpText: config.helpText,
|
|
13706
13680
|
secretLabel: "secretLabel" in config ? config.secretLabel : "",
|
|
13707
|
-
models: getModels(
|
|
13708
|
-
defaultModel: getDefaultModel(
|
|
13681
|
+
models: getModels(type2),
|
|
13682
|
+
defaultModel: getDefaultModel(type2)
|
|
13709
13683
|
};
|
|
13710
13684
|
});
|
|
13711
13685
|
}
|
|
13712
|
-
async function setupModelProvider(
|
|
13686
|
+
async function setupModelProvider(type2, secret, options) {
|
|
13713
13687
|
const response = await upsertModelProvider({
|
|
13714
|
-
type,
|
|
13688
|
+
type: type2,
|
|
13715
13689
|
secret,
|
|
13716
13690
|
selectedModel: options?.selectedModel
|
|
13717
13691
|
});
|
|
@@ -13965,7 +13939,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13965
13939
|
process.exit(0);
|
|
13966
13940
|
}
|
|
13967
13941
|
agentName = inputName;
|
|
13968
|
-
if (
|
|
13942
|
+
if (existsSync12(agentName)) {
|
|
13969
13943
|
step.detail(
|
|
13970
13944
|
chalk69.yellow(`${agentName}/ already exists, choose another name`)
|
|
13971
13945
|
);
|
|
@@ -13982,7 +13956,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13982
13956
|
);
|
|
13983
13957
|
process.exit(1);
|
|
13984
13958
|
}
|
|
13985
|
-
if (
|
|
13959
|
+
if (existsSync12(agentName)) {
|
|
13986
13960
|
console.error(chalk69.red(`\u2717 ${agentName}/ already exists`));
|
|
13987
13961
|
console.error();
|
|
13988
13962
|
console.error("Remove it first or choose a different name:");
|
|
@@ -14272,7 +14246,7 @@ var devToolCommand = new Command75().name("dev-tool").description("Developer too
|
|
|
14272
14246
|
|
|
14273
14247
|
// src/index.ts
|
|
14274
14248
|
var program = new Command76();
|
|
14275
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.27.
|
|
14249
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.27.2");
|
|
14276
14250
|
program.addCommand(authCommand);
|
|
14277
14251
|
program.addCommand(infoCommand);
|
|
14278
14252
|
program.addCommand(composeCommand);
|