@vm0/cli 9.14.1 → 9.15.1
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 +430 -35
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1969,6 +1969,71 @@ var MODEL_PROVIDER_TYPES = {
|
|
|
1969
1969
|
},
|
|
1970
1970
|
models: ["MiniMax-M2.1"],
|
|
1971
1971
|
defaultModel: "MiniMax-M2.1"
|
|
1972
|
+
},
|
|
1973
|
+
"aws-bedrock": {
|
|
1974
|
+
framework: "claude-code",
|
|
1975
|
+
label: "AWS Bedrock",
|
|
1976
|
+
helpText: "Run Claude on AWS Bedrock.\nSetup guide: https://docs.anthropic.com/en/docs/claude-code/bedrock",
|
|
1977
|
+
authMethods: {
|
|
1978
|
+
"api-key": {
|
|
1979
|
+
label: "Bedrock API Key",
|
|
1980
|
+
helpText: "Use a Bedrock API key for authentication",
|
|
1981
|
+
credentials: {
|
|
1982
|
+
AWS_BEARER_TOKEN_BEDROCK: {
|
|
1983
|
+
label: "AWS_BEARER_TOKEN_BEDROCK",
|
|
1984
|
+
required: true,
|
|
1985
|
+
helpText: "Bedrock API key from AWS console"
|
|
1986
|
+
},
|
|
1987
|
+
AWS_REGION: {
|
|
1988
|
+
label: "AWS_REGION",
|
|
1989
|
+
required: true,
|
|
1990
|
+
placeholder: "us-east-1",
|
|
1991
|
+
helpText: "e.g., us-east-1, us-west-2"
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
},
|
|
1995
|
+
"access-keys": {
|
|
1996
|
+
label: "IAM Access Keys",
|
|
1997
|
+
helpText: "Use IAM access key credentials",
|
|
1998
|
+
credentials: {
|
|
1999
|
+
AWS_ACCESS_KEY_ID: {
|
|
2000
|
+
label: "AWS_ACCESS_KEY_ID",
|
|
2001
|
+
required: true,
|
|
2002
|
+
helpText: "IAM access key ID"
|
|
2003
|
+
},
|
|
2004
|
+
AWS_SECRET_ACCESS_KEY: {
|
|
2005
|
+
label: "AWS_SECRET_ACCESS_KEY",
|
|
2006
|
+
required: true,
|
|
2007
|
+
helpText: "IAM secret access key"
|
|
2008
|
+
},
|
|
2009
|
+
AWS_SESSION_TOKEN: {
|
|
2010
|
+
label: "AWS_SESSION_TOKEN",
|
|
2011
|
+
required: false,
|
|
2012
|
+
helpText: "Optional, for temporary credentials"
|
|
2013
|
+
},
|
|
2014
|
+
AWS_REGION: {
|
|
2015
|
+
label: "AWS_REGION",
|
|
2016
|
+
required: true,
|
|
2017
|
+
placeholder: "us-east-1",
|
|
2018
|
+
helpText: "e.g., us-east-1, us-west-2"
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
},
|
|
2023
|
+
defaultAuthMethod: "api-key",
|
|
2024
|
+
environmentMapping: {
|
|
2025
|
+
CLAUDE_CODE_USE_BEDROCK: "1",
|
|
2026
|
+
AWS_REGION: "$credentials.AWS_REGION",
|
|
2027
|
+
AWS_BEARER_TOKEN_BEDROCK: "$credentials.AWS_BEARER_TOKEN_BEDROCK",
|
|
2028
|
+
AWS_ACCESS_KEY_ID: "$credentials.AWS_ACCESS_KEY_ID",
|
|
2029
|
+
AWS_SECRET_ACCESS_KEY: "$credentials.AWS_SECRET_ACCESS_KEY",
|
|
2030
|
+
AWS_SESSION_TOKEN: "$credentials.AWS_SESSION_TOKEN",
|
|
2031
|
+
ANTHROPIC_MODEL: "$model"
|
|
2032
|
+
},
|
|
2033
|
+
models: [],
|
|
2034
|
+
defaultModel: "",
|
|
2035
|
+
allowCustomModel: true,
|
|
2036
|
+
customModelPlaceholder: "anthropic.claude-sonnet-4-20250514-v1:0"
|
|
1972
2037
|
}
|
|
1973
2038
|
};
|
|
1974
2039
|
var modelProviderTypeSchema = z14.enum([
|
|
@@ -1976,9 +2041,30 @@ var modelProviderTypeSchema = z14.enum([
|
|
|
1976
2041
|
"anthropic-api-key",
|
|
1977
2042
|
"openrouter-api-key",
|
|
1978
2043
|
"moonshot-api-key",
|
|
1979
|
-
"minimax-api-key"
|
|
2044
|
+
"minimax-api-key",
|
|
2045
|
+
"aws-bedrock"
|
|
1980
2046
|
]);
|
|
1981
2047
|
var modelProviderFrameworkSchema = z14.enum(["claude-code", "codex"]);
|
|
2048
|
+
function hasAuthMethods(type) {
|
|
2049
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
2050
|
+
return "authMethods" in config;
|
|
2051
|
+
}
|
|
2052
|
+
function getAuthMethodsForType(type) {
|
|
2053
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
2054
|
+
return "authMethods" in config ? config.authMethods : void 0;
|
|
2055
|
+
}
|
|
2056
|
+
function getDefaultAuthMethod(type) {
|
|
2057
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
2058
|
+
return "defaultAuthMethod" in config ? config.defaultAuthMethod : void 0;
|
|
2059
|
+
}
|
|
2060
|
+
function getCredentialsForAuthMethod(type, authMethod) {
|
|
2061
|
+
const authMethods = getAuthMethodsForType(type);
|
|
2062
|
+
if (!authMethods || !(authMethod in authMethods)) {
|
|
2063
|
+
return void 0;
|
|
2064
|
+
}
|
|
2065
|
+
const method = authMethods[authMethod];
|
|
2066
|
+
return method?.credentials;
|
|
2067
|
+
}
|
|
1982
2068
|
function getModels(type) {
|
|
1983
2069
|
const config = MODEL_PROVIDER_TYPES[type];
|
|
1984
2070
|
return "models" in config ? config.models : void 0;
|
|
@@ -1989,13 +2075,26 @@ function getDefaultModel(type) {
|
|
|
1989
2075
|
}
|
|
1990
2076
|
function hasModelSelection(type) {
|
|
1991
2077
|
const config = MODEL_PROVIDER_TYPES[type];
|
|
1992
|
-
return "models" in config && config.models.length > 0;
|
|
2078
|
+
return "models" in config && config.models.length > 0 || "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2079
|
+
}
|
|
2080
|
+
function allowsCustomModel(type) {
|
|
2081
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
2082
|
+
return "allowCustomModel" in config && config.allowCustomModel === true;
|
|
2083
|
+
}
|
|
2084
|
+
function getCustomModelPlaceholder(type) {
|
|
2085
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
2086
|
+
return "customModelPlaceholder" in config ? config.customModelPlaceholder : void 0;
|
|
1993
2087
|
}
|
|
1994
2088
|
var modelProviderResponseSchema = z14.object({
|
|
1995
2089
|
id: z14.string().uuid(),
|
|
1996
2090
|
type: modelProviderTypeSchema,
|
|
1997
2091
|
framework: modelProviderFrameworkSchema,
|
|
1998
|
-
credentialName: z14.string(),
|
|
2092
|
+
credentialName: z14.string().nullable(),
|
|
2093
|
+
// Legacy single-credential (deprecated for multi-auth)
|
|
2094
|
+
authMethod: z14.string().nullable(),
|
|
2095
|
+
// For multi-auth providers
|
|
2096
|
+
credentialNames: z14.array(z14.string()).nullable(),
|
|
2097
|
+
// For multi-auth providers
|
|
1999
2098
|
isDefault: z14.boolean(),
|
|
2000
2099
|
selectedModel: z14.string().nullable(),
|
|
2001
2100
|
createdAt: z14.string(),
|
|
@@ -2006,7 +2105,12 @@ var modelProviderListResponseSchema = z14.object({
|
|
|
2006
2105
|
});
|
|
2007
2106
|
var upsertModelProviderRequestSchema = z14.object({
|
|
2008
2107
|
type: modelProviderTypeSchema,
|
|
2009
|
-
credential: z14.string().min(1
|
|
2108
|
+
credential: z14.string().min(1).optional(),
|
|
2109
|
+
// Legacy single credential
|
|
2110
|
+
authMethod: z14.string().optional(),
|
|
2111
|
+
// For multi-auth providers
|
|
2112
|
+
credentials: z14.record(z14.string(), z14.string()).optional(),
|
|
2113
|
+
// For multi-auth providers
|
|
2010
2114
|
convert: z14.boolean().optional(),
|
|
2011
2115
|
selectedModel: z14.string().optional()
|
|
2012
2116
|
});
|
|
@@ -3318,7 +3422,7 @@ var FEATURE_SWITCHES = {
|
|
|
3318
3422
|
},
|
|
3319
3423
|
["platformAgents" /* PlatformAgents */]: {
|
|
3320
3424
|
maintainer: "ethan@vm0.ai",
|
|
3321
|
-
enabled:
|
|
3425
|
+
enabled: true
|
|
3322
3426
|
},
|
|
3323
3427
|
["platformSecrets" /* PlatformSecrets */]: {
|
|
3324
3428
|
maintainer: "ethan@vm0.ai",
|
|
@@ -4933,7 +5037,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
4933
5037
|
)
|
|
4934
5038
|
);
|
|
4935
5039
|
if (options.autoUpdate !== false) {
|
|
4936
|
-
await silentUpgradeAfterCommand("9.
|
|
5040
|
+
await silentUpgradeAfterCommand("9.15.1");
|
|
4937
5041
|
}
|
|
4938
5042
|
} catch (error) {
|
|
4939
5043
|
if (error instanceof Error) {
|
|
@@ -7164,7 +7268,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
7164
7268
|
}
|
|
7165
7269
|
showNextSteps(result);
|
|
7166
7270
|
if (options.autoUpdate !== false) {
|
|
7167
|
-
await silentUpgradeAfterCommand("9.
|
|
7271
|
+
await silentUpgradeAfterCommand("9.15.1");
|
|
7168
7272
|
}
|
|
7169
7273
|
} catch (error) {
|
|
7170
7274
|
handleRunError(error, identifier);
|
|
@@ -8670,7 +8774,7 @@ var cookAction = new Command27().name("cook").description("Quick start: prepare,
|
|
|
8670
8774
|
).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(
|
|
8671
8775
|
async (prompt, options) => {
|
|
8672
8776
|
if (options.autoUpdate !== false) {
|
|
8673
|
-
const shouldExit = await checkAndUpgrade("9.
|
|
8777
|
+
const shouldExit = await checkAndUpgrade("9.15.1", prompt);
|
|
8674
8778
|
if (shouldExit) {
|
|
8675
8779
|
process.exit(0);
|
|
8676
8780
|
}
|
|
@@ -11212,6 +11316,9 @@ function validateProviderType(typeStr) {
|
|
|
11212
11316
|
}
|
|
11213
11317
|
function validateModel(type, modelStr) {
|
|
11214
11318
|
const models = getModels(type);
|
|
11319
|
+
if (allowsCustomModel(type)) {
|
|
11320
|
+
return modelStr;
|
|
11321
|
+
}
|
|
11215
11322
|
if (models && !models.includes(modelStr)) {
|
|
11216
11323
|
console.error(chalk52.red(`\u2717 Invalid model "${modelStr}"`));
|
|
11217
11324
|
console.log();
|
|
@@ -11223,6 +11330,98 @@ function validateModel(type, modelStr) {
|
|
|
11223
11330
|
}
|
|
11224
11331
|
return modelStr;
|
|
11225
11332
|
}
|
|
11333
|
+
function validateAuthMethod(type, authMethodStr) {
|
|
11334
|
+
const authMethods = getAuthMethodsForType(type);
|
|
11335
|
+
if (!authMethods || !(authMethodStr in authMethods)) {
|
|
11336
|
+
console.error(chalk52.red(`\u2717 Invalid auth method "${authMethodStr}"`));
|
|
11337
|
+
console.log();
|
|
11338
|
+
console.log("Valid auth methods:");
|
|
11339
|
+
if (authMethods) {
|
|
11340
|
+
for (const [method, config] of Object.entries(authMethods)) {
|
|
11341
|
+
console.log(` ${chalk52.cyan(method)} - ${config.label}`);
|
|
11342
|
+
}
|
|
11343
|
+
}
|
|
11344
|
+
process.exit(1);
|
|
11345
|
+
}
|
|
11346
|
+
return authMethodStr;
|
|
11347
|
+
}
|
|
11348
|
+
function parseCredentials(type, authMethod, credentialArgs) {
|
|
11349
|
+
const credentialsConfig = getCredentialsForAuthMethod(type, authMethod);
|
|
11350
|
+
if (!credentialsConfig) {
|
|
11351
|
+
console.error(chalk52.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
11352
|
+
process.exit(1);
|
|
11353
|
+
}
|
|
11354
|
+
const credentialNames = Object.keys(credentialsConfig);
|
|
11355
|
+
const firstArg = credentialArgs[0];
|
|
11356
|
+
if (credentialArgs.length === 1 && firstArg && !firstArg.includes("=")) {
|
|
11357
|
+
if (credentialNames.length !== 1) {
|
|
11358
|
+
console.error(
|
|
11359
|
+
chalk52.red(
|
|
11360
|
+
"\u2717 Must use KEY=VALUE format for multi-credential auth methods"
|
|
11361
|
+
)
|
|
11362
|
+
);
|
|
11363
|
+
console.log();
|
|
11364
|
+
console.log("Required credentials:");
|
|
11365
|
+
for (const [name, fieldConfig] of Object.entries(credentialsConfig)) {
|
|
11366
|
+
const requiredNote = fieldConfig.required ? " (required)" : "";
|
|
11367
|
+
console.log(` ${chalk52.cyan(name)}${requiredNote}`);
|
|
11368
|
+
}
|
|
11369
|
+
process.exit(1);
|
|
11370
|
+
}
|
|
11371
|
+
const firstCredentialName = credentialNames[0];
|
|
11372
|
+
if (!firstCredentialName) {
|
|
11373
|
+
console.error(chalk52.red("\u2717 No credentials defined for this auth method"));
|
|
11374
|
+
process.exit(1);
|
|
11375
|
+
}
|
|
11376
|
+
return { [firstCredentialName]: firstArg };
|
|
11377
|
+
}
|
|
11378
|
+
const credentials = {};
|
|
11379
|
+
for (const arg of credentialArgs) {
|
|
11380
|
+
const eqIndex = arg.indexOf("=");
|
|
11381
|
+
if (eqIndex === -1) {
|
|
11382
|
+
console.error(chalk52.red(`\u2717 Invalid credential format "${arg}"`));
|
|
11383
|
+
console.log();
|
|
11384
|
+
console.log("Use KEY=VALUE format (e.g., AWS_REGION=us-east-1)");
|
|
11385
|
+
process.exit(1);
|
|
11386
|
+
}
|
|
11387
|
+
const key = arg.slice(0, eqIndex);
|
|
11388
|
+
const value = arg.slice(eqIndex + 1);
|
|
11389
|
+
credentials[key] = value;
|
|
11390
|
+
}
|
|
11391
|
+
return credentials;
|
|
11392
|
+
}
|
|
11393
|
+
function validateCredentials(type, authMethod, credentials) {
|
|
11394
|
+
const credentialsConfig = getCredentialsForAuthMethod(type, authMethod);
|
|
11395
|
+
if (!credentialsConfig) {
|
|
11396
|
+
console.error(chalk52.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
11397
|
+
process.exit(1);
|
|
11398
|
+
}
|
|
11399
|
+
for (const [name, fieldConfig] of Object.entries(credentialsConfig)) {
|
|
11400
|
+
if (fieldConfig.required && !credentials[name]) {
|
|
11401
|
+
console.error(chalk52.red(`\u2717 Missing required credential: ${name}`));
|
|
11402
|
+
console.log();
|
|
11403
|
+
console.log("Required credentials:");
|
|
11404
|
+
for (const [n, fc] of Object.entries(credentialsConfig)) {
|
|
11405
|
+
if (fc.required) {
|
|
11406
|
+
console.log(` ${chalk52.cyan(n)} - ${fc.label}`);
|
|
11407
|
+
}
|
|
11408
|
+
}
|
|
11409
|
+
process.exit(1);
|
|
11410
|
+
}
|
|
11411
|
+
}
|
|
11412
|
+
for (const name of Object.keys(credentials)) {
|
|
11413
|
+
if (!(name in credentialsConfig)) {
|
|
11414
|
+
console.error(chalk52.red(`\u2717 Unknown credential: ${name}`));
|
|
11415
|
+
console.log();
|
|
11416
|
+
console.log("Valid credentials:");
|
|
11417
|
+
for (const [n, fc] of Object.entries(credentialsConfig)) {
|
|
11418
|
+
const requiredNote = fc.required ? " (required)" : " (optional)";
|
|
11419
|
+
console.log(` ${chalk52.cyan(n)}${requiredNote}`);
|
|
11420
|
+
}
|
|
11421
|
+
process.exit(1);
|
|
11422
|
+
}
|
|
11423
|
+
}
|
|
11424
|
+
}
|
|
11226
11425
|
function handleNonInteractiveMode(options) {
|
|
11227
11426
|
const type = validateProviderType(options.type);
|
|
11228
11427
|
let selectedModel;
|
|
@@ -11232,9 +11431,69 @@ function handleNonInteractiveMode(options) {
|
|
|
11232
11431
|
const defaultModel = getDefaultModel(type);
|
|
11233
11432
|
selectedModel = defaultModel || void 0;
|
|
11234
11433
|
}
|
|
11434
|
+
if (hasAuthMethods(type)) {
|
|
11435
|
+
let authMethod;
|
|
11436
|
+
if (options.authMethod) {
|
|
11437
|
+
authMethod = validateAuthMethod(type, options.authMethod);
|
|
11438
|
+
} else {
|
|
11439
|
+
const defaultAuthMethod = getDefaultAuthMethod(type);
|
|
11440
|
+
const authMethods = getAuthMethodsForType(type);
|
|
11441
|
+
if (!defaultAuthMethod || !authMethods) {
|
|
11442
|
+
console.error(chalk52.red(`\u2717 Provider "${type}" requires --auth-method`));
|
|
11443
|
+
process.exit(1);
|
|
11444
|
+
}
|
|
11445
|
+
const authMethodNames = Object.keys(authMethods);
|
|
11446
|
+
if (authMethodNames.length === 1) {
|
|
11447
|
+
authMethod = authMethodNames[0];
|
|
11448
|
+
} else {
|
|
11449
|
+
console.error(
|
|
11450
|
+
chalk52.red(
|
|
11451
|
+
`\u2717 --auth-method is required for "${type}" (multiple auth methods available)`
|
|
11452
|
+
)
|
|
11453
|
+
);
|
|
11454
|
+
console.log();
|
|
11455
|
+
console.log("Available auth methods:");
|
|
11456
|
+
for (const [method, config] of Object.entries(authMethods)) {
|
|
11457
|
+
const defaultNote = method === defaultAuthMethod ? " (default)" : "";
|
|
11458
|
+
console.log(
|
|
11459
|
+
` ${chalk52.cyan(method)} - ${config.label}${defaultNote}`
|
|
11460
|
+
);
|
|
11461
|
+
}
|
|
11462
|
+
console.log();
|
|
11463
|
+
console.log("Example:");
|
|
11464
|
+
console.log(
|
|
11465
|
+
chalk52.cyan(
|
|
11466
|
+
` vm0 model-provider setup --type ${type} --auth-method ${authMethodNames[0]} --credential KEY=VALUE`
|
|
11467
|
+
)
|
|
11468
|
+
);
|
|
11469
|
+
process.exit(1);
|
|
11470
|
+
}
|
|
11471
|
+
}
|
|
11472
|
+
const credentials = parseCredentials(type, authMethod, options.credential);
|
|
11473
|
+
validateCredentials(type, authMethod, credentials);
|
|
11474
|
+
return {
|
|
11475
|
+
type,
|
|
11476
|
+
authMethod,
|
|
11477
|
+
credentials,
|
|
11478
|
+
selectedModel,
|
|
11479
|
+
isInteractiveMode: false
|
|
11480
|
+
};
|
|
11481
|
+
}
|
|
11482
|
+
const credentialArgs = options.credential;
|
|
11483
|
+
const firstArg = credentialArgs[0];
|
|
11484
|
+
if (!firstArg) {
|
|
11485
|
+
console.error(chalk52.red("\u2717 Credential is required"));
|
|
11486
|
+
process.exit(1);
|
|
11487
|
+
}
|
|
11488
|
+
let credential;
|
|
11489
|
+
if (firstArg.includes("=")) {
|
|
11490
|
+
credential = firstArg.slice(firstArg.indexOf("=") + 1);
|
|
11491
|
+
} else {
|
|
11492
|
+
credential = firstArg;
|
|
11493
|
+
}
|
|
11235
11494
|
return {
|
|
11236
11495
|
type,
|
|
11237
|
-
credential
|
|
11496
|
+
credential,
|
|
11238
11497
|
selectedModel,
|
|
11239
11498
|
isInteractiveMode: false
|
|
11240
11499
|
};
|
|
@@ -11245,13 +11504,20 @@ async function promptForModelSelection(type) {
|
|
|
11245
11504
|
}
|
|
11246
11505
|
const models = getModels(type) ?? [];
|
|
11247
11506
|
const defaultModel = getDefaultModel(type);
|
|
11248
|
-
const
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11507
|
+
const supportsCustomModel = allowsCustomModel(type);
|
|
11508
|
+
const modelChoices = [];
|
|
11509
|
+
if (defaultModel === "") {
|
|
11510
|
+
modelChoices.push({ title: "auto (Recommended)", value: "" });
|
|
11511
|
+
}
|
|
11512
|
+
for (const model of models) {
|
|
11513
|
+
modelChoices.push({
|
|
11514
|
+
title: model === defaultModel ? `${model} (Recommended)` : model,
|
|
11515
|
+
value: model
|
|
11516
|
+
});
|
|
11517
|
+
}
|
|
11518
|
+
if (supportsCustomModel) {
|
|
11519
|
+
modelChoices.push({ title: "Custom model ID", value: "__custom__" });
|
|
11520
|
+
}
|
|
11255
11521
|
const modelResponse = await prompts2(
|
|
11256
11522
|
{
|
|
11257
11523
|
type: "select",
|
|
@@ -11262,8 +11528,93 @@ async function promptForModelSelection(type) {
|
|
|
11262
11528
|
{ onCancel: () => process.exit(0) }
|
|
11263
11529
|
);
|
|
11264
11530
|
const selected = modelResponse.model;
|
|
11531
|
+
if (selected === "__custom__") {
|
|
11532
|
+
const placeholder = getCustomModelPlaceholder(type);
|
|
11533
|
+
if (placeholder) {
|
|
11534
|
+
console.log(chalk52.dim(`Example: ${placeholder}`));
|
|
11535
|
+
}
|
|
11536
|
+
const customResponse = await prompts2(
|
|
11537
|
+
{
|
|
11538
|
+
type: "text",
|
|
11539
|
+
name: "customModel",
|
|
11540
|
+
message: "Enter model ID:",
|
|
11541
|
+
validate: (value) => value.length > 0 || "Model ID is required"
|
|
11542
|
+
},
|
|
11543
|
+
{ onCancel: () => process.exit(0) }
|
|
11544
|
+
);
|
|
11545
|
+
return customResponse.customModel;
|
|
11546
|
+
}
|
|
11265
11547
|
return selected === "" ? void 0 : selected;
|
|
11266
11548
|
}
|
|
11549
|
+
async function promptForAuthMethod(type) {
|
|
11550
|
+
const authMethods = getAuthMethodsForType(type);
|
|
11551
|
+
const defaultAuthMethod = getDefaultAuthMethod(type);
|
|
11552
|
+
if (!authMethods) {
|
|
11553
|
+
return "default";
|
|
11554
|
+
}
|
|
11555
|
+
const choices = Object.entries(authMethods).map(([method, config]) => ({
|
|
11556
|
+
title: method === defaultAuthMethod ? `${config.label} (Recommended)` : config.label,
|
|
11557
|
+
value: method
|
|
11558
|
+
}));
|
|
11559
|
+
const response = await prompts2(
|
|
11560
|
+
{
|
|
11561
|
+
type: "select",
|
|
11562
|
+
name: "authMethod",
|
|
11563
|
+
message: "Select authentication method:",
|
|
11564
|
+
choices
|
|
11565
|
+
},
|
|
11566
|
+
{ onCancel: () => process.exit(0) }
|
|
11567
|
+
);
|
|
11568
|
+
return response.authMethod;
|
|
11569
|
+
}
|
|
11570
|
+
function isSecretCredential(name) {
|
|
11571
|
+
const nonSecretPatterns = ["REGION", "ENDPOINT", "URL"];
|
|
11572
|
+
return !nonSecretPatterns.some(
|
|
11573
|
+
(pattern) => name.toUpperCase().includes(pattern)
|
|
11574
|
+
);
|
|
11575
|
+
}
|
|
11576
|
+
async function promptForCredentials(type, authMethod) {
|
|
11577
|
+
const credentialsConfig = getCredentialsForAuthMethod(type, authMethod);
|
|
11578
|
+
if (!credentialsConfig) {
|
|
11579
|
+
console.error(chalk52.red(`\u2717 Invalid auth method "${authMethod}"`));
|
|
11580
|
+
process.exit(1);
|
|
11581
|
+
}
|
|
11582
|
+
const credentials = {};
|
|
11583
|
+
for (const [name, fieldConfig] of Object.entries(credentialsConfig)) {
|
|
11584
|
+
if (fieldConfig.helpText) {
|
|
11585
|
+
console.log(chalk52.dim(fieldConfig.helpText));
|
|
11586
|
+
}
|
|
11587
|
+
const isSecret = isSecretCredential(name);
|
|
11588
|
+
const placeholder = "placeholder" in fieldConfig ? fieldConfig.placeholder : "";
|
|
11589
|
+
if (fieldConfig.required) {
|
|
11590
|
+
const response = await prompts2(
|
|
11591
|
+
{
|
|
11592
|
+
type: isSecret ? "password" : "text",
|
|
11593
|
+
name: "value",
|
|
11594
|
+
message: `${fieldConfig.label}:`,
|
|
11595
|
+
initial: placeholder ? "" : void 0,
|
|
11596
|
+
validate: (value) => value.length > 0 || `${fieldConfig.label} is required`
|
|
11597
|
+
},
|
|
11598
|
+
{ onCancel: () => process.exit(0) }
|
|
11599
|
+
);
|
|
11600
|
+
credentials[name] = response.value;
|
|
11601
|
+
} else {
|
|
11602
|
+
const response = await prompts2(
|
|
11603
|
+
{
|
|
11604
|
+
type: isSecret ? "password" : "text",
|
|
11605
|
+
name: "value",
|
|
11606
|
+
message: `${fieldConfig.label} (optional):`
|
|
11607
|
+
},
|
|
11608
|
+
{ onCancel: () => process.exit(0) }
|
|
11609
|
+
);
|
|
11610
|
+
const value = response.value;
|
|
11611
|
+
if (value && value.trim()) {
|
|
11612
|
+
credentials[name] = value.trim();
|
|
11613
|
+
}
|
|
11614
|
+
}
|
|
11615
|
+
}
|
|
11616
|
+
return credentials;
|
|
11617
|
+
}
|
|
11267
11618
|
async function handleInteractiveMode() {
|
|
11268
11619
|
if (!isInteractive()) {
|
|
11269
11620
|
console.error(chalk52.red("\u2717 Interactive mode requires a TTY"));
|
|
@@ -11279,10 +11630,21 @@ async function handleInteractiveMode() {
|
|
|
11279
11630
|
const { modelProviders: configuredProviders } = await listModelProviders();
|
|
11280
11631
|
const configuredTypes = new Set(configuredProviders.map((p) => p.type));
|
|
11281
11632
|
const annotatedChoices = Object.entries(MODEL_PROVIDER_TYPES).map(
|
|
11282
|
-
([type2, config2]) =>
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11633
|
+
([type2, config2]) => {
|
|
11634
|
+
const isConfigured = configuredTypes.has(type2);
|
|
11635
|
+
const isExperimental = hasAuthMethods(type2);
|
|
11636
|
+
let title = config2.label;
|
|
11637
|
+
if (isConfigured) {
|
|
11638
|
+
title = `${title} \u2713`;
|
|
11639
|
+
}
|
|
11640
|
+
if (isExperimental) {
|
|
11641
|
+
title = `${title} ${chalk52.dim("(experimental)")}`;
|
|
11642
|
+
}
|
|
11643
|
+
return {
|
|
11644
|
+
title,
|
|
11645
|
+
value: type2
|
|
11646
|
+
};
|
|
11647
|
+
}
|
|
11286
11648
|
);
|
|
11287
11649
|
const typeResponse = await prompts2(
|
|
11288
11650
|
{
|
|
@@ -11349,12 +11711,25 @@ async function handleInteractiveMode() {
|
|
|
11349
11711
|
console.log();
|
|
11350
11712
|
console.log(chalk52.dim(config.helpText));
|
|
11351
11713
|
console.log();
|
|
11714
|
+
if (hasAuthMethods(type)) {
|
|
11715
|
+
const authMethod = await promptForAuthMethod(type);
|
|
11716
|
+
const credentials = await promptForCredentials(type, authMethod);
|
|
11717
|
+
const selectedModel2 = await promptForModelSelection(type);
|
|
11718
|
+
return {
|
|
11719
|
+
type,
|
|
11720
|
+
authMethod,
|
|
11721
|
+
credentials,
|
|
11722
|
+
selectedModel: selectedModel2,
|
|
11723
|
+
isInteractiveMode: true
|
|
11724
|
+
};
|
|
11725
|
+
}
|
|
11726
|
+
const credentialLabel = "credentialLabel" in config ? config.credentialLabel : "credential";
|
|
11352
11727
|
const credentialResponse = await prompts2(
|
|
11353
11728
|
{
|
|
11354
11729
|
type: "password",
|
|
11355
11730
|
name: "credential",
|
|
11356
|
-
message: `Enter your ${
|
|
11357
|
-
validate: (value) => value.length > 0 || `${
|
|
11731
|
+
message: `Enter your ${credentialLabel}:`,
|
|
11732
|
+
validate: (value) => value.length > 0 || `${credentialLabel} is required`
|
|
11358
11733
|
},
|
|
11359
11734
|
{ onCancel: () => process.exit(0) }
|
|
11360
11735
|
);
|
|
@@ -11395,21 +11770,31 @@ async function promptSetAsDefault(type, framework, isDefault) {
|
|
|
11395
11770
|
console.log(chalk52.green(`\u2713 Default for ${framework} set to "${type}"`));
|
|
11396
11771
|
}
|
|
11397
11772
|
}
|
|
11773
|
+
function collectCredentials(value, previous) {
|
|
11774
|
+
return previous.concat([value]);
|
|
11775
|
+
}
|
|
11398
11776
|
var setupCommand2 = new Command53().name("setup").description("Configure a model provider").option("-t, --type <type>", "Provider type (for non-interactive mode)").option(
|
|
11399
|
-
"-c, --credential <
|
|
11400
|
-
"Credential value (
|
|
11777
|
+
"-c, --credential <value>",
|
|
11778
|
+
"Credential value (can be used multiple times, supports VALUE or KEY=VALUE format)",
|
|
11779
|
+
collectCredentials,
|
|
11780
|
+
[]
|
|
11781
|
+
).option(
|
|
11782
|
+
"-a, --auth-method <method>",
|
|
11783
|
+
"Auth method (required for multi-auth providers like aws-bedrock)"
|
|
11401
11784
|
).option("-m, --model <model>", "Model selection (for non-interactive mode)").option("--convert", "Convert existing user credential to model provider").action(
|
|
11402
11785
|
async (options) => {
|
|
11403
11786
|
try {
|
|
11404
11787
|
let input;
|
|
11405
11788
|
const shouldConvert = options.convert ?? false;
|
|
11406
|
-
|
|
11789
|
+
const credentialArgs = options.credential ?? [];
|
|
11790
|
+
if (options.type && credentialArgs.length > 0) {
|
|
11407
11791
|
input = handleNonInteractiveMode({
|
|
11408
11792
|
type: options.type,
|
|
11409
|
-
credential:
|
|
11793
|
+
credential: credentialArgs,
|
|
11794
|
+
authMethod: options.authMethod,
|
|
11410
11795
|
model: options.model
|
|
11411
11796
|
});
|
|
11412
|
-
} else if (options.type ||
|
|
11797
|
+
} else if (options.type || credentialArgs.length > 0) {
|
|
11413
11798
|
console.error(
|
|
11414
11799
|
chalk52.red("\u2717 Both --type and --credential are required")
|
|
11415
11800
|
);
|
|
@@ -11451,6 +11836,8 @@ var setupCommand2 = new Command53().name("setup").description("Configure a model
|
|
|
11451
11836
|
const { provider, created } = await upsertModelProvider({
|
|
11452
11837
|
type: input.type,
|
|
11453
11838
|
credential: input.credential,
|
|
11839
|
+
authMethod: input.authMethod,
|
|
11840
|
+
credentials: input.credentials,
|
|
11454
11841
|
convert: shouldConvert,
|
|
11455
11842
|
selectedModel: input.selectedModel
|
|
11456
11843
|
});
|
|
@@ -11763,6 +12150,13 @@ async function runAuthFlow(callbacks, apiUrl) {
|
|
|
11763
12150
|
}
|
|
11764
12151
|
|
|
11765
12152
|
// src/lib/domain/onboard/model-provider.ts
|
|
12153
|
+
var ONBOARD_PROVIDER_TYPES = [
|
|
12154
|
+
"claude-code-oauth-token",
|
|
12155
|
+
"anthropic-api-key",
|
|
12156
|
+
"openrouter-api-key",
|
|
12157
|
+
"moonshot-api-key",
|
|
12158
|
+
"minimax-api-key"
|
|
12159
|
+
];
|
|
11766
12160
|
async function checkModelProviderStatus() {
|
|
11767
12161
|
const response = await listModelProviders();
|
|
11768
12162
|
return {
|
|
@@ -11771,16 +12165,17 @@ async function checkModelProviderStatus() {
|
|
|
11771
12165
|
};
|
|
11772
12166
|
}
|
|
11773
12167
|
function getProviderChoices() {
|
|
11774
|
-
return
|
|
11775
|
-
|
|
12168
|
+
return ONBOARD_PROVIDER_TYPES.map((type) => {
|
|
12169
|
+
const config = MODEL_PROVIDER_TYPES[type];
|
|
12170
|
+
return {
|
|
11776
12171
|
type,
|
|
11777
|
-
label:
|
|
11778
|
-
helpText:
|
|
11779
|
-
credentialLabel:
|
|
12172
|
+
label: config.label,
|
|
12173
|
+
helpText: config.helpText,
|
|
12174
|
+
credentialLabel: "credentialLabel" in config ? config.credentialLabel : "",
|
|
11780
12175
|
models: getModels(type),
|
|
11781
12176
|
defaultModel: getDefaultModel(type)
|
|
11782
|
-
}
|
|
11783
|
-
);
|
|
12177
|
+
};
|
|
12178
|
+
});
|
|
11784
12179
|
}
|
|
11785
12180
|
async function setupModelProvider(type, credential, options) {
|
|
11786
12181
|
const response = await upsertModelProvider({
|
|
@@ -12162,7 +12557,7 @@ var setupClaudeCommand = new Command58().name("setup-claude").description("Insta
|
|
|
12162
12557
|
|
|
12163
12558
|
// src/index.ts
|
|
12164
12559
|
var program = new Command59();
|
|
12165
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.
|
|
12560
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.15.1");
|
|
12166
12561
|
program.addCommand(authCommand);
|
|
12167
12562
|
program.addCommand(infoCommand);
|
|
12168
12563
|
program.addCommand(composeCommand);
|