@vm0/cli 9.27.1 → 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 +396 -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.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,20 +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
9503
|
|
|
9475
9504
|
// src/lib/domain/cook-state.ts
|
|
9476
|
-
import { homedir as
|
|
9477
|
-
import { join as
|
|
9505
|
+
import { homedir as homedir3 } from "os";
|
|
9506
|
+
import { join as join8 } from "path";
|
|
9478
9507
|
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 =
|
|
9508
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9509
|
+
var CONFIG_DIR2 = join8(homedir3(), ".vm0");
|
|
9510
|
+
var COOK_STATE_FILE = join8(CONFIG_DIR2, "cook.json");
|
|
9482
9511
|
var STALE_THRESHOLD_MS = 48 * 60 * 60 * 1e3;
|
|
9483
9512
|
async function loadCookStateFile() {
|
|
9484
|
-
if (!
|
|
9513
|
+
if (!existsSync8(COOK_STATE_FILE)) {
|
|
9485
9514
|
return { ppid: {} };
|
|
9486
9515
|
}
|
|
9487
9516
|
try {
|
|
@@ -9540,7 +9569,7 @@ async function saveCookState(state) {
|
|
|
9540
9569
|
// src/commands/cook/utils.ts
|
|
9541
9570
|
import chalk28 from "chalk";
|
|
9542
9571
|
import { spawn as spawn2 } from "child_process";
|
|
9543
|
-
import { existsSync as
|
|
9572
|
+
import { existsSync as existsSync9 } from "fs";
|
|
9544
9573
|
var CONFIG_FILE2 = "vm0.yaml";
|
|
9545
9574
|
var ARTIFACT_DIR = "artifact";
|
|
9546
9575
|
function printCommand(cmd) {
|
|
@@ -9643,7 +9672,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9643
9672
|
runOutput,
|
|
9644
9673
|
ARTIFACT_DIR
|
|
9645
9674
|
);
|
|
9646
|
-
if (serverVersion &&
|
|
9675
|
+
if (serverVersion && existsSync9(artifactDir)) {
|
|
9647
9676
|
console.log();
|
|
9648
9677
|
console.log(chalk28.bold("Pulling updated artifact:"));
|
|
9649
9678
|
printCommand(`cd ${ARTIFACT_DIR}`);
|
|
@@ -9666,7 +9695,7 @@ async function autoPullArtifact(runOutput, artifactDir) {
|
|
|
9666
9695
|
// src/commands/cook/cook.ts
|
|
9667
9696
|
async function loadAndValidateConfig2() {
|
|
9668
9697
|
console.log(chalk29.bold(`Reading config: ${CONFIG_FILE2}`));
|
|
9669
|
-
if (!
|
|
9698
|
+
if (!existsSync10(CONFIG_FILE2)) {
|
|
9670
9699
|
console.error(chalk29.red(`\u2717 Config file not found: ${CONFIG_FILE2}`));
|
|
9671
9700
|
process.exit(1);
|
|
9672
9701
|
}
|
|
@@ -9702,7 +9731,7 @@ async function processVolumes(config, cwd) {
|
|
|
9702
9731
|
console.log(chalk29.bold("Processing volumes:"));
|
|
9703
9732
|
for (const volumeConfig of Object.values(config.volumes)) {
|
|
9704
9733
|
const volumeDir = path11.join(cwd, volumeConfig.name);
|
|
9705
|
-
if (!
|
|
9734
|
+
if (!existsSync10(volumeDir)) {
|
|
9706
9735
|
console.error(chalk29.red(`\u2717 Directory not found: ${volumeConfig.name}`));
|
|
9707
9736
|
console.error(chalk29.dim(" Create the directory and add files first"));
|
|
9708
9737
|
process.exit(1);
|
|
@@ -9737,7 +9766,7 @@ async function processArtifact(cwd) {
|
|
|
9737
9766
|
console.log(chalk29.bold("Processing artifact:"));
|
|
9738
9767
|
const artifactDir = path11.join(cwd, ARTIFACT_DIR);
|
|
9739
9768
|
try {
|
|
9740
|
-
if (!
|
|
9769
|
+
if (!existsSync10(artifactDir)) {
|
|
9741
9770
|
printCommand(`mkdir ${ARTIFACT_DIR}`);
|
|
9742
9771
|
await mkdir6(artifactDir, { recursive: true });
|
|
9743
9772
|
}
|
|
@@ -9819,7 +9848,7 @@ var cookAction = new Command27().name("cook").description("Quick start: prepare,
|
|
|
9819
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(
|
|
9820
9849
|
async (prompt, options) => {
|
|
9821
9850
|
if (options.autoUpdate !== false) {
|
|
9822
|
-
const shouldExit = await checkAndUpgrade("9.27.
|
|
9851
|
+
const shouldExit = await checkAndUpgrade("9.27.2", prompt);
|
|
9823
9852
|
if (shouldExit) {
|
|
9824
9853
|
process.exit(0);
|
|
9825
9854
|
}
|
|
@@ -10402,7 +10431,7 @@ import { Command as Command35 } from "commander";
|
|
|
10402
10431
|
import chalk36 from "chalk";
|
|
10403
10432
|
import { mkdtempSync as mkdtempSync5 } from "fs";
|
|
10404
10433
|
import { mkdir as mkdir7, writeFile as writeFile6, readdir, copyFile, rm as rm4 } from "fs/promises";
|
|
10405
|
-
import { join as
|
|
10434
|
+
import { join as join9, dirname as dirname3 } from "path";
|
|
10406
10435
|
import { tmpdir as tmpdir7 } from "os";
|
|
10407
10436
|
import * as tar6 from "tar";
|
|
10408
10437
|
import { stringify as yamlStringify } from "yaml";
|
|
@@ -10438,8 +10467,8 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10438
10467
|
throw new Error(`Failed to download instructions: ${response.status}`);
|
|
10439
10468
|
}
|
|
10440
10469
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10441
|
-
const tmpDir = mkdtempSync5(
|
|
10442
|
-
const tarPath =
|
|
10470
|
+
const tmpDir = mkdtempSync5(join9(tmpdir7(), "vm0-clone-"));
|
|
10471
|
+
const tarPath = join9(tmpDir, "archive.tar.gz");
|
|
10443
10472
|
await writeFile6(tarPath, buffer);
|
|
10444
10473
|
await tar6.extract({ file: tarPath, cwd: tmpDir, gzip: true });
|
|
10445
10474
|
const files = await readdir(tmpDir);
|
|
@@ -10449,9 +10478,9 @@ async function downloadInstructions(agentName, instructionsPath, destination) {
|
|
|
10449
10478
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10450
10479
|
return false;
|
|
10451
10480
|
}
|
|
10452
|
-
const destPath =
|
|
10481
|
+
const destPath = join9(destination, instructionsPath);
|
|
10453
10482
|
await mkdir7(dirname3(destPath), { recursive: true });
|
|
10454
|
-
await copyFile(
|
|
10483
|
+
await copyFile(join9(tmpDir, mdFile), destPath);
|
|
10455
10484
|
await rm4(tmpDir, { recursive: true, force: true });
|
|
10456
10485
|
return true;
|
|
10457
10486
|
}
|
|
@@ -10477,7 +10506,7 @@ var cloneCommand3 = new Command35().name("clone").description("Clone agent compo
|
|
|
10477
10506
|
const cleanedContent = cleanComposeContent(content);
|
|
10478
10507
|
const yamlContent = yamlStringify(cleanedContent);
|
|
10479
10508
|
await mkdir7(targetDir, { recursive: true });
|
|
10480
|
-
const yamlPath =
|
|
10509
|
+
const yamlPath = join9(targetDir, "vm0.yaml");
|
|
10481
10510
|
await writeFile6(yamlPath, yamlContent, "utf8");
|
|
10482
10511
|
console.log(chalk36.green("\u2713 Created vm0.yaml"));
|
|
10483
10512
|
const agentKey = Object.keys(content.agents)[0];
|
|
@@ -11002,11 +11031,11 @@ var permissionCommand = new Command42().name("experimental-permission").descript
|
|
|
11002
11031
|
)
|
|
11003
11032
|
);
|
|
11004
11033
|
for (const p of data.permissions) {
|
|
11005
|
-
const
|
|
11034
|
+
const type2 = p.granteeType.padEnd(7);
|
|
11006
11035
|
const email = (p.granteeEmail ?? "-").padEnd(29);
|
|
11007
11036
|
const permission = p.permission.padEnd(10);
|
|
11008
11037
|
const granted = formatRelativeTime(p.createdAt);
|
|
11009
|
-
console.log(`${
|
|
11038
|
+
console.log(`${type2} ${email} ${permission} ${granted}`);
|
|
11010
11039
|
}
|
|
11011
11040
|
} catch (error) {
|
|
11012
11041
|
console.error(chalk43.red("\u2717 Failed to list permissions"));
|
|
@@ -11024,7 +11053,7 @@ var agentCommand = new Command43().name("agent").description("Manage agent compo
|
|
|
11024
11053
|
import { Command as Command44 } from "commander";
|
|
11025
11054
|
import chalk44 from "chalk";
|
|
11026
11055
|
import path15 from "path";
|
|
11027
|
-
import { existsSync as
|
|
11056
|
+
import { existsSync as existsSync11 } from "fs";
|
|
11028
11057
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
11029
11058
|
var VM0_YAML_FILE = "vm0.yaml";
|
|
11030
11059
|
var AGENTS_MD_FILE = "AGENTS.md";
|
|
@@ -11056,8 +11085,8 @@ You are a HackerNews AI content curator.
|
|
|
11056
11085
|
}
|
|
11057
11086
|
function checkExistingFiles() {
|
|
11058
11087
|
const existingFiles = [];
|
|
11059
|
-
if (
|
|
11060
|
-
if (
|
|
11088
|
+
if (existsSync11(VM0_YAML_FILE)) existingFiles.push(VM0_YAML_FILE);
|
|
11089
|
+
if (existsSync11(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
|
|
11061
11090
|
return existingFiles;
|
|
11062
11091
|
}
|
|
11063
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) => {
|
|
@@ -11317,7 +11346,7 @@ function formatInTimezone(isoDate, timezone) {
|
|
|
11317
11346
|
minute: "2-digit",
|
|
11318
11347
|
hour12: false
|
|
11319
11348
|
}).formatToParts(date);
|
|
11320
|
-
const get = (
|
|
11349
|
+
const get = (type2) => parts.find((p) => p.type === type2)?.value ?? "";
|
|
11321
11350
|
return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}`;
|
|
11322
11351
|
}
|
|
11323
11352
|
function parseFrequencyFromCron(cron) {
|
|
@@ -12567,9 +12596,9 @@ function validateProviderType(typeStr) {
|
|
|
12567
12596
|
}
|
|
12568
12597
|
return typeStr;
|
|
12569
12598
|
}
|
|
12570
|
-
function validateModel(
|
|
12571
|
-
const models = getModels(
|
|
12572
|
-
if (allowsCustomModel(
|
|
12599
|
+
function validateModel(type2, modelStr) {
|
|
12600
|
+
const models = getModels(type2);
|
|
12601
|
+
if (allowsCustomModel(type2)) {
|
|
12573
12602
|
return modelStr;
|
|
12574
12603
|
}
|
|
12575
12604
|
if (models && !models.includes(modelStr)) {
|
|
@@ -12583,8 +12612,8 @@ function validateModel(type, modelStr) {
|
|
|
12583
12612
|
}
|
|
12584
12613
|
return modelStr;
|
|
12585
12614
|
}
|
|
12586
|
-
function validateAuthMethod(
|
|
12587
|
-
const authMethods = getAuthMethodsForType(
|
|
12615
|
+
function validateAuthMethod(type2, authMethodStr) {
|
|
12616
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12588
12617
|
if (!authMethods || !(authMethodStr in authMethods)) {
|
|
12589
12618
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethodStr}"`));
|
|
12590
12619
|
console.error();
|
|
@@ -12598,8 +12627,8 @@ function validateAuthMethod(type, authMethodStr) {
|
|
|
12598
12627
|
}
|
|
12599
12628
|
return authMethodStr;
|
|
12600
12629
|
}
|
|
12601
|
-
function parseSecrets(
|
|
12602
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12630
|
+
function parseSecrets(type2, authMethod, secretArgs) {
|
|
12631
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12603
12632
|
if (!secretsConfig) {
|
|
12604
12633
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12605
12634
|
process.exit(1);
|
|
@@ -12641,8 +12670,8 @@ function parseSecrets(type, authMethod, secretArgs) {
|
|
|
12641
12670
|
}
|
|
12642
12671
|
return secrets;
|
|
12643
12672
|
}
|
|
12644
|
-
function validateSecrets(
|
|
12645
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12673
|
+
function validateSecrets(type2, authMethod, secrets) {
|
|
12674
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12646
12675
|
if (!secretsConfig) {
|
|
12647
12676
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12648
12677
|
process.exit(1);
|
|
@@ -12674,23 +12703,23 @@ function validateSecrets(type, authMethod, secrets) {
|
|
|
12674
12703
|
}
|
|
12675
12704
|
}
|
|
12676
12705
|
function handleNonInteractiveMode(options) {
|
|
12677
|
-
const
|
|
12706
|
+
const type2 = validateProviderType(options.type);
|
|
12678
12707
|
let selectedModel;
|
|
12679
12708
|
if (options.model) {
|
|
12680
|
-
selectedModel = validateModel(
|
|
12681
|
-
} else if (hasModelSelection(
|
|
12682
|
-
const defaultModel = getDefaultModel(
|
|
12709
|
+
selectedModel = validateModel(type2, options.model);
|
|
12710
|
+
} else if (hasModelSelection(type2)) {
|
|
12711
|
+
const defaultModel = getDefaultModel(type2);
|
|
12683
12712
|
selectedModel = defaultModel || void 0;
|
|
12684
12713
|
}
|
|
12685
|
-
if (hasAuthMethods(
|
|
12714
|
+
if (hasAuthMethods(type2)) {
|
|
12686
12715
|
let authMethod;
|
|
12687
12716
|
if (options.authMethod) {
|
|
12688
|
-
authMethod = validateAuthMethod(
|
|
12717
|
+
authMethod = validateAuthMethod(type2, options.authMethod);
|
|
12689
12718
|
} else {
|
|
12690
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12691
|
-
const authMethods = getAuthMethodsForType(
|
|
12719
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12720
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12692
12721
|
if (!defaultAuthMethod || !authMethods) {
|
|
12693
|
-
console.error(chalk59.red(`\u2717 Provider "${
|
|
12722
|
+
console.error(chalk59.red(`\u2717 Provider "${type2}" requires --auth-method`));
|
|
12694
12723
|
process.exit(1);
|
|
12695
12724
|
}
|
|
12696
12725
|
const authMethodNames = Object.keys(authMethods);
|
|
@@ -12699,7 +12728,7 @@ function handleNonInteractiveMode(options) {
|
|
|
12699
12728
|
} else {
|
|
12700
12729
|
console.error(
|
|
12701
12730
|
chalk59.red(
|
|
12702
|
-
`\u2717 --auth-method is required for "${
|
|
12731
|
+
`\u2717 --auth-method is required for "${type2}" (multiple auth methods available)`
|
|
12703
12732
|
)
|
|
12704
12733
|
);
|
|
12705
12734
|
console.error();
|
|
@@ -12714,16 +12743,16 @@ function handleNonInteractiveMode(options) {
|
|
|
12714
12743
|
console.error("Example:");
|
|
12715
12744
|
console.error(
|
|
12716
12745
|
chalk59.cyan(
|
|
12717
|
-
` vm0 model-provider setup --type ${
|
|
12746
|
+
` vm0 model-provider setup --type ${type2} --auth-method ${authMethodNames[0]} --secret KEY=VALUE`
|
|
12718
12747
|
)
|
|
12719
12748
|
);
|
|
12720
12749
|
process.exit(1);
|
|
12721
12750
|
}
|
|
12722
12751
|
}
|
|
12723
|
-
const secrets = parseSecrets(
|
|
12724
|
-
validateSecrets(
|
|
12752
|
+
const secrets = parseSecrets(type2, authMethod, options.secret);
|
|
12753
|
+
validateSecrets(type2, authMethod, secrets);
|
|
12725
12754
|
return {
|
|
12726
|
-
type,
|
|
12755
|
+
type: type2,
|
|
12727
12756
|
authMethod,
|
|
12728
12757
|
secrets,
|
|
12729
12758
|
selectedModel,
|
|
@@ -12743,19 +12772,19 @@ function handleNonInteractiveMode(options) {
|
|
|
12743
12772
|
secret = firstArg;
|
|
12744
12773
|
}
|
|
12745
12774
|
return {
|
|
12746
|
-
type,
|
|
12775
|
+
type: type2,
|
|
12747
12776
|
secret,
|
|
12748
12777
|
selectedModel,
|
|
12749
12778
|
isInteractiveMode: false
|
|
12750
12779
|
};
|
|
12751
12780
|
}
|
|
12752
|
-
async function promptForModelSelection(
|
|
12753
|
-
if (!hasModelSelection(
|
|
12781
|
+
async function promptForModelSelection(type2) {
|
|
12782
|
+
if (!hasModelSelection(type2)) {
|
|
12754
12783
|
return void 0;
|
|
12755
12784
|
}
|
|
12756
|
-
const models = getModels(
|
|
12757
|
-
const defaultModel = getDefaultModel(
|
|
12758
|
-
const supportsCustomModel = allowsCustomModel(
|
|
12785
|
+
const models = getModels(type2) ?? [];
|
|
12786
|
+
const defaultModel = getDefaultModel(type2);
|
|
12787
|
+
const supportsCustomModel = allowsCustomModel(type2);
|
|
12759
12788
|
const modelChoices = [];
|
|
12760
12789
|
if (defaultModel === "") {
|
|
12761
12790
|
modelChoices.push({ title: "auto (Recommended)", value: "" });
|
|
@@ -12780,7 +12809,7 @@ async function promptForModelSelection(type) {
|
|
|
12780
12809
|
);
|
|
12781
12810
|
const selected = modelResponse.model;
|
|
12782
12811
|
if (selected === "__custom__") {
|
|
12783
|
-
const placeholder = getCustomModelPlaceholder(
|
|
12812
|
+
const placeholder = getCustomModelPlaceholder(type2);
|
|
12784
12813
|
if (placeholder) {
|
|
12785
12814
|
console.log(chalk59.dim(`Example: ${placeholder}`));
|
|
12786
12815
|
}
|
|
@@ -12797,9 +12826,9 @@ async function promptForModelSelection(type) {
|
|
|
12797
12826
|
}
|
|
12798
12827
|
return selected === "" ? void 0 : selected;
|
|
12799
12828
|
}
|
|
12800
|
-
async function promptForAuthMethod(
|
|
12801
|
-
const authMethods = getAuthMethodsForType(
|
|
12802
|
-
const defaultAuthMethod = getDefaultAuthMethod(
|
|
12829
|
+
async function promptForAuthMethod(type2) {
|
|
12830
|
+
const authMethods = getAuthMethodsForType(type2);
|
|
12831
|
+
const defaultAuthMethod = getDefaultAuthMethod(type2);
|
|
12803
12832
|
if (!authMethods) {
|
|
12804
12833
|
return "default";
|
|
12805
12834
|
}
|
|
@@ -12824,8 +12853,8 @@ function isSensitiveSecret(name) {
|
|
|
12824
12853
|
(pattern) => name.toUpperCase().includes(pattern)
|
|
12825
12854
|
);
|
|
12826
12855
|
}
|
|
12827
|
-
async function promptForSecrets(
|
|
12828
|
-
const secretsConfig = getSecretsForAuthMethod(
|
|
12856
|
+
async function promptForSecrets(type2, authMethod) {
|
|
12857
|
+
const secretsConfig = getSecretsForAuthMethod(type2, authMethod);
|
|
12829
12858
|
if (!secretsConfig) {
|
|
12830
12859
|
console.error(chalk59.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
12831
12860
|
process.exit(1);
|
|
@@ -12879,9 +12908,9 @@ async function handleInteractiveMode() {
|
|
|
12879
12908
|
const { modelProviders: configuredProviders } = await listModelProviders();
|
|
12880
12909
|
const configuredTypes = new Set(configuredProviders.map((p) => p.type));
|
|
12881
12910
|
const annotatedChoices = Object.entries(MODEL_PROVIDER_TYPES).map(
|
|
12882
|
-
([
|
|
12883
|
-
const isConfigured = configuredTypes.has(
|
|
12884
|
-
const isExperimental = hasAuthMethods(
|
|
12911
|
+
([type3, config2]) => {
|
|
12912
|
+
const isConfigured = configuredTypes.has(type3);
|
|
12913
|
+
const isExperimental = hasAuthMethods(type3);
|
|
12885
12914
|
let title = config2.label;
|
|
12886
12915
|
if (isConfigured) {
|
|
12887
12916
|
title = `${title} \u2713`;
|
|
@@ -12891,7 +12920,7 @@ async function handleInteractiveMode() {
|
|
|
12891
12920
|
}
|
|
12892
12921
|
return {
|
|
12893
12922
|
title,
|
|
12894
|
-
value:
|
|
12923
|
+
value: type3
|
|
12895
12924
|
};
|
|
12896
12925
|
}
|
|
12897
12926
|
);
|
|
@@ -12904,11 +12933,11 @@ async function handleInteractiveMode() {
|
|
|
12904
12933
|
},
|
|
12905
12934
|
{ onCancel: () => process.exit(0) }
|
|
12906
12935
|
);
|
|
12907
|
-
const
|
|
12908
|
-
const checkResult = await checkModelProviderSecret(
|
|
12936
|
+
const type2 = typeResponse.type;
|
|
12937
|
+
const checkResult = await checkModelProviderSecret(type2);
|
|
12909
12938
|
if (checkResult.exists) {
|
|
12910
12939
|
console.log();
|
|
12911
|
-
console.log(`"${
|
|
12940
|
+
console.log(`"${type2}" is already configured`);
|
|
12912
12941
|
console.log();
|
|
12913
12942
|
const actionResponse = await prompts2(
|
|
12914
12943
|
{
|
|
@@ -12923,25 +12952,25 @@ async function handleInteractiveMode() {
|
|
|
12923
12952
|
{ onCancel: () => process.exit(0) }
|
|
12924
12953
|
);
|
|
12925
12954
|
if (actionResponse.action === "keep") {
|
|
12926
|
-
const selectedModel2 = await promptForModelSelection(
|
|
12955
|
+
const selectedModel2 = await promptForModelSelection(type2);
|
|
12927
12956
|
return {
|
|
12928
|
-
type,
|
|
12957
|
+
type: type2,
|
|
12929
12958
|
keepExistingSecret: true,
|
|
12930
12959
|
selectedModel: selectedModel2,
|
|
12931
12960
|
isInteractiveMode: true
|
|
12932
12961
|
};
|
|
12933
12962
|
}
|
|
12934
12963
|
}
|
|
12935
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
12964
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
12936
12965
|
console.log();
|
|
12937
12966
|
console.log(chalk59.dim(config.helpText));
|
|
12938
12967
|
console.log();
|
|
12939
|
-
if (hasAuthMethods(
|
|
12940
|
-
const authMethod = await promptForAuthMethod(
|
|
12941
|
-
const secrets = await promptForSecrets(
|
|
12942
|
-
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);
|
|
12943
12972
|
return {
|
|
12944
|
-
type,
|
|
12973
|
+
type: type2,
|
|
12945
12974
|
authMethod,
|
|
12946
12975
|
secrets,
|
|
12947
12976
|
selectedModel: selectedModel2,
|
|
@@ -12959,8 +12988,8 @@ async function handleInteractiveMode() {
|
|
|
12959
12988
|
{ onCancel: () => process.exit(0) }
|
|
12960
12989
|
);
|
|
12961
12990
|
const secret = secretResponse.secret;
|
|
12962
|
-
const selectedModel = await promptForModelSelection(
|
|
12963
|
-
return { type, secret, selectedModel, isInteractiveMode: true };
|
|
12991
|
+
const selectedModel = await promptForModelSelection(type2);
|
|
12992
|
+
return { type: type2, secret, selectedModel, isInteractiveMode: true };
|
|
12964
12993
|
}
|
|
12965
12994
|
function handleSetupError2(error) {
|
|
12966
12995
|
if (error instanceof Error) {
|
|
@@ -12975,7 +13004,7 @@ function handleSetupError2(error) {
|
|
|
12975
13004
|
}
|
|
12976
13005
|
process.exit(1);
|
|
12977
13006
|
}
|
|
12978
|
-
async function promptSetAsDefault(
|
|
13007
|
+
async function promptSetAsDefault(type2, framework, isDefault) {
|
|
12979
13008
|
if (isDefault) return;
|
|
12980
13009
|
const response = await prompts2(
|
|
12981
13010
|
{
|
|
@@ -12987,8 +13016,8 @@ async function promptSetAsDefault(type, framework, isDefault) {
|
|
|
12987
13016
|
{ onCancel: () => process.exit(0) }
|
|
12988
13017
|
);
|
|
12989
13018
|
if (response.setDefault) {
|
|
12990
|
-
await setModelProviderDefault(
|
|
12991
|
-
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}"`));
|
|
12992
13021
|
}
|
|
12993
13022
|
}
|
|
12994
13023
|
function collectSecrets(value, previous) {
|
|
@@ -13082,10 +13111,10 @@ var setupCommand2 = new Command62().name("setup").description("Configure a model
|
|
|
13082
13111
|
// src/commands/model-provider/delete.ts
|
|
13083
13112
|
import { Command as Command63 } from "commander";
|
|
13084
13113
|
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 (
|
|
13114
|
+
var deleteCommand4 = new Command63().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(async (type2) => {
|
|
13086
13115
|
try {
|
|
13087
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13088
|
-
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}"`));
|
|
13089
13118
|
console.log();
|
|
13090
13119
|
console.log("Valid types:");
|
|
13091
13120
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13093,12 +13122,12 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13093
13122
|
}
|
|
13094
13123
|
process.exit(1);
|
|
13095
13124
|
}
|
|
13096
|
-
await deleteModelProvider(
|
|
13097
|
-
console.log(chalk60.green(`\u2713 Model provider "${
|
|
13125
|
+
await deleteModelProvider(type2);
|
|
13126
|
+
console.log(chalk60.green(`\u2713 Model provider "${type2}" deleted`));
|
|
13098
13127
|
} catch (error) {
|
|
13099
13128
|
if (error instanceof Error) {
|
|
13100
13129
|
if (error.message.includes("not found")) {
|
|
13101
|
-
console.error(chalk60.red(`\u2717 Model provider "${
|
|
13130
|
+
console.error(chalk60.red(`\u2717 Model provider "${type2}" not found`));
|
|
13102
13131
|
} else if (error.message.includes("Not authenticated")) {
|
|
13103
13132
|
console.error(chalk60.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13104
13133
|
} else {
|
|
@@ -13114,10 +13143,10 @@ var deleteCommand4 = new Command63().name("delete").description("Delete a model
|
|
|
13114
13143
|
// src/commands/model-provider/set-default.ts
|
|
13115
13144
|
import { Command as Command64 } from "commander";
|
|
13116
13145
|
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 (
|
|
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) => {
|
|
13118
13147
|
try {
|
|
13119
|
-
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(
|
|
13120
|
-
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}"`));
|
|
13121
13150
|
console.log();
|
|
13122
13151
|
console.log("Valid types:");
|
|
13123
13152
|
for (const [t, config] of Object.entries(MODEL_PROVIDER_TYPES)) {
|
|
@@ -13125,7 +13154,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13125
13154
|
}
|
|
13126
13155
|
process.exit(1);
|
|
13127
13156
|
}
|
|
13128
|
-
const provider = await setModelProviderDefault(
|
|
13157
|
+
const provider = await setModelProviderDefault(type2);
|
|
13129
13158
|
console.log(
|
|
13130
13159
|
chalk61.green(
|
|
13131
13160
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
@@ -13134,7 +13163,7 @@ var setDefaultCommand = new Command64().name("set-default").description("Set a m
|
|
|
13134
13163
|
} catch (error) {
|
|
13135
13164
|
if (error instanceof Error) {
|
|
13136
13165
|
if (error.message.includes("not found")) {
|
|
13137
|
-
console.error(chalk61.red(`\u2717 Model provider "${
|
|
13166
|
+
console.error(chalk61.red(`\u2717 Model provider "${type2}" not found`));
|
|
13138
13167
|
} else if (error.message.includes("Not authenticated")) {
|
|
13139
13168
|
console.error(chalk61.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13140
13169
|
} else {
|
|
@@ -13174,17 +13203,17 @@ async function getHeaders2() {
|
|
|
13174
13203
|
}
|
|
13175
13204
|
return headers;
|
|
13176
13205
|
}
|
|
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(
|
|
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);
|
|
13179
13208
|
if (!parseResult.success) {
|
|
13180
|
-
console.error(chalk62.red(`\u2717 Unknown connector type: ${
|
|
13209
|
+
console.error(chalk62.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13181
13210
|
console.error("Available connectors: github");
|
|
13182
13211
|
process.exit(1);
|
|
13183
13212
|
}
|
|
13184
13213
|
const connectorType = parseResult.data;
|
|
13185
13214
|
const apiUrl = await getApiUrl();
|
|
13186
13215
|
const headers = await getHeaders2();
|
|
13187
|
-
console.log(`Connecting ${chalk62.cyan(
|
|
13216
|
+
console.log(`Connecting ${chalk62.cyan(type2)}...`);
|
|
13188
13217
|
const sessionsClient = initClient12(connectorSessionsContract, {
|
|
13189
13218
|
baseUrl: apiUrl,
|
|
13190
13219
|
baseHeaders: headers,
|
|
@@ -13241,7 +13270,7 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
13241
13270
|
case "complete":
|
|
13242
13271
|
console.log(chalk62.green(`
|
|
13243
13272
|
|
|
13244
|
-
${
|
|
13273
|
+
${type2} connected successfully!`));
|
|
13245
13274
|
return;
|
|
13246
13275
|
case "expired":
|
|
13247
13276
|
console.error(chalk62.red("\n\u2717 Session expired, please try again"));
|
|
@@ -13282,11 +13311,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13282
13311
|
"ACCOUNT"
|
|
13283
13312
|
].join(" ");
|
|
13284
13313
|
console.log(chalk63.dim(header));
|
|
13285
|
-
for (const
|
|
13286
|
-
const connector = connectedMap.get(
|
|
13314
|
+
for (const type2 of allTypes) {
|
|
13315
|
+
const connector = connectedMap.get(type2);
|
|
13287
13316
|
const status = connector ? chalk63.green("\u2713".padEnd(statusWidth)) : chalk63.dim("-".padEnd(statusWidth));
|
|
13288
13317
|
const account = connector?.externalUsername ? `@${connector.externalUsername}` : chalk63.dim("-");
|
|
13289
|
-
const row = [
|
|
13318
|
+
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
13290
13319
|
console.log(row);
|
|
13291
13320
|
}
|
|
13292
13321
|
console.log();
|
|
@@ -13310,11 +13339,11 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
13310
13339
|
import { Command as Command68 } from "commander";
|
|
13311
13340
|
import chalk64 from "chalk";
|
|
13312
13341
|
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 (
|
|
13342
|
+
var statusCommand7 = new Command68().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(async (type2) => {
|
|
13314
13343
|
try {
|
|
13315
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13344
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13316
13345
|
if (!parseResult.success) {
|
|
13317
|
-
console.error(chalk64.red(`\u2717 Unknown connector type: ${
|
|
13346
|
+
console.error(chalk64.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13318
13347
|
console.error();
|
|
13319
13348
|
console.error("Available connectors:");
|
|
13320
13349
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13323,7 +13352,7 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13323
13352
|
process.exit(1);
|
|
13324
13353
|
}
|
|
13325
13354
|
const connector = await getConnector(parseResult.data);
|
|
13326
|
-
console.log(`Connector: ${chalk64.cyan(
|
|
13355
|
+
console.log(`Connector: ${chalk64.cyan(type2)}`);
|
|
13327
13356
|
console.log();
|
|
13328
13357
|
if (connector) {
|
|
13329
13358
|
console.log(
|
|
@@ -13350,14 +13379,14 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13350
13379
|
}
|
|
13351
13380
|
console.log();
|
|
13352
13381
|
console.log(chalk64.dim("To disconnect:"));
|
|
13353
|
-
console.log(chalk64.dim(` vm0 connector disconnect ${
|
|
13382
|
+
console.log(chalk64.dim(` vm0 connector disconnect ${type2}`));
|
|
13354
13383
|
} else {
|
|
13355
13384
|
console.log(
|
|
13356
13385
|
`${"Status:".padEnd(LABEL_WIDTH)}${chalk64.dim("not connected")}`
|
|
13357
13386
|
);
|
|
13358
13387
|
console.log();
|
|
13359
13388
|
console.log(chalk64.dim("To connect:"));
|
|
13360
|
-
console.log(chalk64.dim(` vm0 connector connect ${
|
|
13389
|
+
console.log(chalk64.dim(` vm0 connector connect ${type2}`));
|
|
13361
13390
|
}
|
|
13362
13391
|
} catch (error) {
|
|
13363
13392
|
if (error instanceof Error) {
|
|
@@ -13376,11 +13405,11 @@ var statusCommand7 = new Command68().name("status").description("Show detailed s
|
|
|
13376
13405
|
// src/commands/connector/disconnect.ts
|
|
13377
13406
|
import { Command as Command69 } from "commander";
|
|
13378
13407
|
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 (
|
|
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) => {
|
|
13380
13409
|
try {
|
|
13381
|
-
const parseResult = connectorTypeSchema.safeParse(
|
|
13410
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
13382
13411
|
if (!parseResult.success) {
|
|
13383
|
-
console.error(chalk65.red(`\u2717 Unknown connector type: ${
|
|
13412
|
+
console.error(chalk65.red(`\u2717 Unknown connector type: ${type2}`));
|
|
13384
13413
|
console.error();
|
|
13385
13414
|
console.error("Available connectors:");
|
|
13386
13415
|
for (const [t, config] of Object.entries(CONNECTOR_TYPES)) {
|
|
@@ -13389,11 +13418,11 @@ var disconnectCommand = new Command69().name("disconnect").description("Disconne
|
|
|
13389
13418
|
process.exit(1);
|
|
13390
13419
|
}
|
|
13391
13420
|
await deleteConnector(parseResult.data);
|
|
13392
|
-
console.log(chalk65.green(`\u2713 Disconnected ${
|
|
13421
|
+
console.log(chalk65.green(`\u2713 Disconnected ${type2}`));
|
|
13393
13422
|
} catch (error) {
|
|
13394
13423
|
if (error instanceof Error) {
|
|
13395
13424
|
if (error.message.includes("not found")) {
|
|
13396
|
-
console.error(chalk65.red(`\u2717 Connector "${
|
|
13425
|
+
console.error(chalk65.red(`\u2717 Connector "${type2}" is not connected`));
|
|
13397
13426
|
} else if (error.message.includes("Not authenticated")) {
|
|
13398
13427
|
console.error(chalk65.red("\u2717 Not authenticated. Run: vm0 auth login"));
|
|
13399
13428
|
} else {
|
|
@@ -13413,7 +13442,7 @@ var connectorCommand = new Command70().name("connector").description("Manage thi
|
|
|
13413
13442
|
import { Command as Command71 } from "commander";
|
|
13414
13443
|
import chalk69 from "chalk";
|
|
13415
13444
|
import { mkdir as mkdir8 } from "fs/promises";
|
|
13416
|
-
import { existsSync as
|
|
13445
|
+
import { existsSync as existsSync12 } from "fs";
|
|
13417
13446
|
|
|
13418
13447
|
// src/lib/ui/welcome-box.ts
|
|
13419
13448
|
import chalk66 from "chalk";
|
|
@@ -13642,21 +13671,21 @@ async function checkModelProviderStatus() {
|
|
|
13642
13671
|
};
|
|
13643
13672
|
}
|
|
13644
13673
|
function getProviderChoices() {
|
|
13645
|
-
return ONBOARD_PROVIDER_TYPES.map((
|
|
13646
|
-
const config = MODEL_PROVIDER_TYPES[
|
|
13674
|
+
return ONBOARD_PROVIDER_TYPES.map((type2) => {
|
|
13675
|
+
const config = MODEL_PROVIDER_TYPES[type2];
|
|
13647
13676
|
return {
|
|
13648
|
-
type,
|
|
13677
|
+
type: type2,
|
|
13649
13678
|
label: config.label,
|
|
13650
13679
|
helpText: config.helpText,
|
|
13651
13680
|
secretLabel: "secretLabel" in config ? config.secretLabel : "",
|
|
13652
|
-
models: getModels(
|
|
13653
|
-
defaultModel: getDefaultModel(
|
|
13681
|
+
models: getModels(type2),
|
|
13682
|
+
defaultModel: getDefaultModel(type2)
|
|
13654
13683
|
};
|
|
13655
13684
|
});
|
|
13656
13685
|
}
|
|
13657
|
-
async function setupModelProvider(
|
|
13686
|
+
async function setupModelProvider(type2, secret, options) {
|
|
13658
13687
|
const response = await upsertModelProvider({
|
|
13659
|
-
type,
|
|
13688
|
+
type: type2,
|
|
13660
13689
|
secret,
|
|
13661
13690
|
selectedModel: options?.selectedModel
|
|
13662
13691
|
});
|
|
@@ -13910,7 +13939,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13910
13939
|
process.exit(0);
|
|
13911
13940
|
}
|
|
13912
13941
|
agentName = inputName;
|
|
13913
|
-
if (
|
|
13942
|
+
if (existsSync12(agentName)) {
|
|
13914
13943
|
step.detail(
|
|
13915
13944
|
chalk69.yellow(`${agentName}/ already exists, choose another name`)
|
|
13916
13945
|
);
|
|
@@ -13927,7 +13956,7 @@ async function handleAgentCreation(ctx) {
|
|
|
13927
13956
|
);
|
|
13928
13957
|
process.exit(1);
|
|
13929
13958
|
}
|
|
13930
|
-
if (
|
|
13959
|
+
if (existsSync12(agentName)) {
|
|
13931
13960
|
console.error(chalk69.red(`\u2717 ${agentName}/ already exists`));
|
|
13932
13961
|
console.error();
|
|
13933
13962
|
console.error("Remove it first or choose a different name:");
|
|
@@ -14217,7 +14246,7 @@ var devToolCommand = new Command75().name("dev-tool").description("Developer too
|
|
|
14217
14246
|
|
|
14218
14247
|
// src/index.ts
|
|
14219
14248
|
var program = new Command76();
|
|
14220
|
-
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");
|
|
14221
14250
|
program.addCommand(authCommand);
|
|
14222
14251
|
program.addCommand(infoCommand);
|
|
14223
14252
|
program.addCommand(composeCommand);
|