@mutagent/cli 0.1.226 → 0.1.228
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/dist/bin/cli.js +452 -2
- package/dist/bin/cli.js.map +6 -4
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -2253,6 +2253,442 @@ import { Provider as ProviderCatalogId } from "@mutagent/sdk/models";
|
|
|
2253
2253
|
init_sdk_client();
|
|
2254
2254
|
import chalk8 from "chalk";
|
|
2255
2255
|
init_errors();
|
|
2256
|
+
|
|
2257
|
+
// src/lib/api-format.ts
|
|
2258
|
+
init_errors();
|
|
2259
|
+
|
|
2260
|
+
// ../mutagent/src/modules/tenancy/providers/catalog.ts
|
|
2261
|
+
var apiKeyField = (description) => ({
|
|
2262
|
+
name: "apiKey",
|
|
2263
|
+
label: "API key",
|
|
2264
|
+
required: true,
|
|
2265
|
+
treatment: "secret",
|
|
2266
|
+
validation: { rule: "non-empty-string", minLength: 8 },
|
|
2267
|
+
description
|
|
2268
|
+
});
|
|
2269
|
+
var baseUrlOverrideField = {
|
|
2270
|
+
name: "baseUrl",
|
|
2271
|
+
label: "Base URL override",
|
|
2272
|
+
required: false,
|
|
2273
|
+
treatment: "plain",
|
|
2274
|
+
validation: { rule: "https-url" },
|
|
2275
|
+
description: "Route requests through a proxy or a regional endpoint instead of the default one."
|
|
2276
|
+
};
|
|
2277
|
+
var modelAllowListField = {
|
|
2278
|
+
name: "modelAllowList",
|
|
2279
|
+
label: "Model allow-list",
|
|
2280
|
+
required: false,
|
|
2281
|
+
treatment: "plain",
|
|
2282
|
+
validation: { rule: "string-list" },
|
|
2283
|
+
description: "Narrow the models this configuration offers. Entries outside the provider policy are ignored."
|
|
2284
|
+
};
|
|
2285
|
+
var directApiKeyFields = (keyDescription) => [
|
|
2286
|
+
apiKeyField(keyDescription),
|
|
2287
|
+
baseUrlOverrideField,
|
|
2288
|
+
modelAllowListField
|
|
2289
|
+
];
|
|
2290
|
+
var azureFields = [
|
|
2291
|
+
{
|
|
2292
|
+
name: "resourceEndpoint",
|
|
2293
|
+
label: "Resource endpoint",
|
|
2294
|
+
required: true,
|
|
2295
|
+
treatment: "plain",
|
|
2296
|
+
validation: { rule: "https-url" },
|
|
2297
|
+
description: "The Azure resource endpoint, e.g. https://my-resource.openai.azure.com."
|
|
2298
|
+
},
|
|
2299
|
+
apiKeyField("The key issued for the Azure resource."),
|
|
2300
|
+
{
|
|
2301
|
+
name: "deploymentName",
|
|
2302
|
+
label: "Deployment name",
|
|
2303
|
+
required: true,
|
|
2304
|
+
treatment: "plain",
|
|
2305
|
+
validation: { rule: "non-empty-string", minLength: 1 },
|
|
2306
|
+
description: "Azure addresses a model by the name given to its deployment, not by model id."
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
name: "apiVersion",
|
|
2310
|
+
label: "API version",
|
|
2311
|
+
required: false,
|
|
2312
|
+
treatment: "plain",
|
|
2313
|
+
validation: {
|
|
2314
|
+
rule: "pattern",
|
|
2315
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}(-preview)?$",
|
|
2316
|
+
hint: "An ISO date, optionally suffixed -preview.",
|
|
2317
|
+
examples: ["2024-08-01-preview", "2023-06-01", "2025-01-01"],
|
|
2318
|
+
counterExamples: ["2024-8-1", "24-08-01", "2024-08-01-beta", "latest"]
|
|
2319
|
+
},
|
|
2320
|
+
description: "Pin the Azure API version. Defaults to the current stable version when omitted."
|
|
2321
|
+
}
|
|
2322
|
+
];
|
|
2323
|
+
var vertexFields = [
|
|
2324
|
+
{
|
|
2325
|
+
name: "projectId",
|
|
2326
|
+
label: "Project ID",
|
|
2327
|
+
required: true,
|
|
2328
|
+
treatment: "plain",
|
|
2329
|
+
validation: {
|
|
2330
|
+
rule: "pattern",
|
|
2331
|
+
pattern: "^[a-z][a-z0-9-]{4,28}[a-z0-9]$",
|
|
2332
|
+
hint: "A Google Cloud project ID: 6 to 30 lowercase characters, starting with a letter.",
|
|
2333
|
+
examples: ["my-project-123", "abcdef", "my-gcp-project"],
|
|
2334
|
+
counterExamples: ["ab", "My-Project", "1project", "my_project"]
|
|
2335
|
+
},
|
|
2336
|
+
description: "The Google Cloud project that holds the Vertex AI entitlement."
|
|
2337
|
+
},
|
|
2338
|
+
{
|
|
2339
|
+
name: "region",
|
|
2340
|
+
label: "Region",
|
|
2341
|
+
required: true,
|
|
2342
|
+
treatment: "plain",
|
|
2343
|
+
validation: {
|
|
2344
|
+
rule: "pattern",
|
|
2345
|
+
pattern: "^(global|(?:us|europe|asia|australia|northamerica|southamerica|africa|me)-[a-z]+\\d+)$",
|
|
2346
|
+
hint: "A Vertex location: a continent prefix, a direction and an index — or `global`.",
|
|
2347
|
+
examples: [
|
|
2348
|
+
"us-central1",
|
|
2349
|
+
"europe-west4",
|
|
2350
|
+
"europe-west12",
|
|
2351
|
+
"asia-northeast1",
|
|
2352
|
+
"northamerica-northeast1",
|
|
2353
|
+
"southamerica-east1",
|
|
2354
|
+
"australia-southeast1",
|
|
2355
|
+
"africa-south1",
|
|
2356
|
+
"me-central2",
|
|
2357
|
+
"global"
|
|
2358
|
+
],
|
|
2359
|
+
counterExamples: ["zz-qqqqqq9", "us-central", "US-CENTRAL1", "us_central1", "1-west1"]
|
|
2360
|
+
},
|
|
2361
|
+
description: "The Vertex location the models are served from."
|
|
2362
|
+
},
|
|
2363
|
+
{
|
|
2364
|
+
name: "serviceAccountKey",
|
|
2365
|
+
label: "Service-account credential",
|
|
2366
|
+
required: true,
|
|
2367
|
+
treatment: "secret",
|
|
2368
|
+
validation: { rule: "json-object" },
|
|
2369
|
+
description: "The service-account key JSON granting Vertex AI access to the project."
|
|
2370
|
+
},
|
|
2371
|
+
modelAllowListField
|
|
2372
|
+
];
|
|
2373
|
+
var PROVIDER_CATALOG = [
|
|
2374
|
+
{
|
|
2375
|
+
id: "openai",
|
|
2376
|
+
label: "OpenAI",
|
|
2377
|
+
kind: "direct",
|
|
2378
|
+
credentialFields: directApiKeyFields("An OpenAI API key, issued from the OpenAI platform."),
|
|
2379
|
+
modelPolicy: {
|
|
2380
|
+
mode: "floor",
|
|
2381
|
+
floor: "5.5",
|
|
2382
|
+
knownMembers: ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5"],
|
|
2383
|
+
summary: "GPT models at or above 5.5. FR-CORE-008 states the floor and then enumerates the members current at writing; the floor is the rule, the enumeration is the snapshot."
|
|
2384
|
+
},
|
|
2385
|
+
description: "GPT models served directly by OpenAI."
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
id: "anthropic",
|
|
2389
|
+
label: "Anthropic",
|
|
2390
|
+
kind: "direct",
|
|
2391
|
+
credentialFields: directApiKeyFields("An Anthropic API key, issued from the Anthropic console."),
|
|
2392
|
+
modelPolicy: {
|
|
2393
|
+
mode: "explicit",
|
|
2394
|
+
models: [
|
|
2395
|
+
"claude-opus-5",
|
|
2396
|
+
"claude-sonnet-5",
|
|
2397
|
+
"claude-fable-5",
|
|
2398
|
+
"claude-opus-4-8",
|
|
2399
|
+
"claude-haiku-4-5"
|
|
2400
|
+
],
|
|
2401
|
+
summary: "The Claude 5 family, plus Opus 4.8 and Haiku 4.5."
|
|
2402
|
+
},
|
|
2403
|
+
description: "Claude models served directly by Anthropic."
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
id: "google",
|
|
2407
|
+
label: "Google Gemini",
|
|
2408
|
+
kind: "direct",
|
|
2409
|
+
credentialFields: directApiKeyFields("A Google AI Studio API key."),
|
|
2410
|
+
modelPolicy: {
|
|
2411
|
+
mode: "floor",
|
|
2412
|
+
floor: "3.1",
|
|
2413
|
+
summary: "Gemini 3.1 Pro and above. The floor is 3.1; nothing older is offered."
|
|
2414
|
+
},
|
|
2415
|
+
description: "Gemini models served directly by Google AI Studio."
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
id: "moonshot",
|
|
2419
|
+
label: "Moonshot AI",
|
|
2420
|
+
kind: "direct",
|
|
2421
|
+
credentialFields: directApiKeyFields("A Moonshot AI platform API key."),
|
|
2422
|
+
modelPolicy: {
|
|
2423
|
+
mode: "explicit",
|
|
2424
|
+
models: ["kimi-k3"],
|
|
2425
|
+
summary: "Kimi K3, the 1M-context model. The 256K models are all K2-generation and are not offered."
|
|
2426
|
+
},
|
|
2427
|
+
description: "Kimi models served directly by Moonshot AI."
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
id: "glm",
|
|
2431
|
+
label: "z.ai (GLM)",
|
|
2432
|
+
kind: "direct",
|
|
2433
|
+
credentialFields: directApiKeyFields("A z.ai API key."),
|
|
2434
|
+
modelPolicy: {
|
|
2435
|
+
mode: "explicit",
|
|
2436
|
+
models: ["glm-5.2"],
|
|
2437
|
+
summary: "GLM-5.2."
|
|
2438
|
+
},
|
|
2439
|
+
description: "GLM models served directly by z.ai."
|
|
2440
|
+
},
|
|
2441
|
+
{
|
|
2442
|
+
id: "deepseek",
|
|
2443
|
+
label: "DeepSeek",
|
|
2444
|
+
kind: "direct",
|
|
2445
|
+
credentialFields: directApiKeyFields("A DeepSeek platform API key."),
|
|
2446
|
+
modelPolicy: {
|
|
2447
|
+
mode: "explicit",
|
|
2448
|
+
models: ["deepseek-v4-flash", "deepseek-v4-pro"],
|
|
2449
|
+
summary: "The DeepSeek V4 pair — Flash and Pro."
|
|
2450
|
+
},
|
|
2451
|
+
description: "DeepSeek models served directly by DeepSeek."
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
id: "xai",
|
|
2455
|
+
label: "xAI",
|
|
2456
|
+
kind: "direct",
|
|
2457
|
+
credentialFields: directApiKeyFields("An xAI API key."),
|
|
2458
|
+
modelPolicy: {
|
|
2459
|
+
mode: "floor",
|
|
2460
|
+
floor: "4.5",
|
|
2461
|
+
summary: "Grok 4.5 and above. The floor is 4.5; nothing older is offered."
|
|
2462
|
+
},
|
|
2463
|
+
description: "Grok models served directly by xAI."
|
|
2464
|
+
},
|
|
2465
|
+
{
|
|
2466
|
+
id: "azure",
|
|
2467
|
+
label: "Azure",
|
|
2468
|
+
kind: "gateway",
|
|
2469
|
+
hostedFamilies: ["openai", "anthropic"],
|
|
2470
|
+
credentialFields: azureFields,
|
|
2471
|
+
modelPolicy: {
|
|
2472
|
+
mode: "derived",
|
|
2473
|
+
from: ["openai", "anthropic"],
|
|
2474
|
+
addressing: {
|
|
2475
|
+
openai: {
|
|
2476
|
+
scheme: "deployment-name",
|
|
2477
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$",
|
|
2478
|
+
examples: ["my-gpt-5-6-deployment", "prod_gpt", "gpt56sol"],
|
|
2479
|
+
counterExamples: ["gpt-5.6-sol", "claude-opus-5@20260115", "has space", ""]
|
|
2480
|
+
},
|
|
2481
|
+
anthropic: {
|
|
2482
|
+
scheme: "deployment-name",
|
|
2483
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$",
|
|
2484
|
+
examples: ["my-claude-deployment", "prod_claude"],
|
|
2485
|
+
counterExamples: ["claude-opus-5@20260115", "gpt-5.6-sol", "has space", ""]
|
|
2486
|
+
}
|
|
2487
|
+
},
|
|
2488
|
+
summary: "The OpenAI and Anthropic rosters, each model addressed by the name of its Azure deployment."
|
|
2489
|
+
},
|
|
2490
|
+
description: "Azure AI Foundry, hosting OpenAI and Anthropic models. One configuration per hosted family."
|
|
2491
|
+
},
|
|
2492
|
+
{
|
|
2493
|
+
id: "vertex",
|
|
2494
|
+
label: "Google Vertex",
|
|
2495
|
+
kind: "gateway",
|
|
2496
|
+
hostedFamilies: ["gemini", "anthropic"],
|
|
2497
|
+
credentialFields: vertexFields,
|
|
2498
|
+
modelPolicy: {
|
|
2499
|
+
mode: "derived",
|
|
2500
|
+
from: ["gemini", "anthropic"],
|
|
2501
|
+
addressing: {
|
|
2502
|
+
gemini: {
|
|
2503
|
+
scheme: "plain",
|
|
2504
|
+
pattern: "^(?!.*@)[a-zA-Z0-9][a-zA-Z0-9.\\-]*$",
|
|
2505
|
+
examples: ["gemini-3.1-pro", "gemini-3.1-flash", "gemini-3.1-pro-preview"],
|
|
2506
|
+
counterExamples: [
|
|
2507
|
+
"gemini-3.1-pro@20260115",
|
|
2508
|
+
"us.anthropic.claude-opus-5-v1:0",
|
|
2509
|
+
"has space",
|
|
2510
|
+
""
|
|
2511
|
+
]
|
|
2512
|
+
},
|
|
2513
|
+
anthropic: {
|
|
2514
|
+
scheme: "dated",
|
|
2515
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9.\\-]*@\\d{8}$",
|
|
2516
|
+
examples: ["claude-opus-5@20260115", "claude-sonnet-5@20251022"],
|
|
2517
|
+
counterExamples: [
|
|
2518
|
+
"claude-opus-5",
|
|
2519
|
+
"claude-opus-5@",
|
|
2520
|
+
"claude-opus-5@2026",
|
|
2521
|
+
"gemini-3.1-pro"
|
|
2522
|
+
]
|
|
2523
|
+
}
|
|
2524
|
+
},
|
|
2525
|
+
summary: "The Gemini and Anthropic rosters. Anthropic models are @-dated on Vertex; Gemini models are not."
|
|
2526
|
+
},
|
|
2527
|
+
description: "Google Vertex AI, hosting Gemini and Anthropic models. One configuration per hosted family."
|
|
2528
|
+
},
|
|
2529
|
+
{
|
|
2530
|
+
id: "bedrock",
|
|
2531
|
+
label: "AWS Bedrock",
|
|
2532
|
+
kind: "gateway",
|
|
2533
|
+
hostedFamilies: ["anthropic"],
|
|
2534
|
+
credentialFields: [
|
|
2535
|
+
{
|
|
2536
|
+
name: "region",
|
|
2537
|
+
label: "Region",
|
|
2538
|
+
required: true,
|
|
2539
|
+
treatment: "plain",
|
|
2540
|
+
validation: {
|
|
2541
|
+
rule: "pattern",
|
|
2542
|
+
pattern: "^[a-z]{2}(-gov)?-[a-z]+-\\d+$",
|
|
2543
|
+
hint: "An AWS region: a two-letter geography, a direction and an index.",
|
|
2544
|
+
examples: [
|
|
2545
|
+
"us-east-1",
|
|
2546
|
+
"eu-central-1",
|
|
2547
|
+
"ap-southeast-1",
|
|
2548
|
+
"sa-east-1",
|
|
2549
|
+
"me-south-1",
|
|
2550
|
+
"af-south-1",
|
|
2551
|
+
"il-central-1",
|
|
2552
|
+
"mx-central-1",
|
|
2553
|
+
"us-gov-west-1"
|
|
2554
|
+
],
|
|
2555
|
+
counterExamples: ["us-east", "US-EAST-1", "useast1", "europe-west4"]
|
|
2556
|
+
},
|
|
2557
|
+
description: "The AWS region the Bedrock models are invoked in."
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
name: "apiKey",
|
|
2561
|
+
label: "Bearer API key",
|
|
2562
|
+
required: true,
|
|
2563
|
+
treatment: "secret",
|
|
2564
|
+
validation: {
|
|
2565
|
+
rule: "pattern",
|
|
2566
|
+
pattern: "^(?!AKIA)[^\\s:]+$",
|
|
2567
|
+
hint: "A single opaque bearer token. Long-lived AWS access key and secret pairs are not accepted.",
|
|
2568
|
+
examples: ["bedrock-api-key-abc123", "ABSKQmVkcm9ja0FQSUtleQ=="],
|
|
2569
|
+
counterExamples: [
|
|
2570
|
+
"AKIAIOSFODNN7EXAMPLE",
|
|
2571
|
+
"AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG",
|
|
2572
|
+
"someid:somesecret",
|
|
2573
|
+
"has space"
|
|
2574
|
+
]
|
|
2575
|
+
},
|
|
2576
|
+
description: "A Bedrock bearer API key. This is the only credential type Bedrock accepts here."
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
name: "inferenceProfile",
|
|
2580
|
+
label: "Inference profile",
|
|
2581
|
+
required: false,
|
|
2582
|
+
treatment: "plain",
|
|
2583
|
+
validation: { rule: "non-empty-string", minLength: 1 },
|
|
2584
|
+
description: "Pin a cross-region inference profile. Defaults to the profile for the configured region."
|
|
2585
|
+
}
|
|
2586
|
+
],
|
|
2587
|
+
modelPolicy: {
|
|
2588
|
+
mode: "derived",
|
|
2589
|
+
from: ["anthropic"],
|
|
2590
|
+
addressing: {
|
|
2591
|
+
anthropic: {
|
|
2592
|
+
scheme: "inference-profile",
|
|
2593
|
+
pattern: "^(us|eu|apac)\\.[a-z0-9-]+\\.[a-zA-Z0-9.\\-]+(:\\d+)?$",
|
|
2594
|
+
examples: [
|
|
2595
|
+
"us.anthropic.claude-opus-5-v1:0",
|
|
2596
|
+
"eu.anthropic.claude-sonnet-5-v1:0",
|
|
2597
|
+
"apac.anthropic.claude-haiku-4-5-v1:0"
|
|
2598
|
+
],
|
|
2599
|
+
counterExamples: [
|
|
2600
|
+
"anthropic.claude-opus-5-v1:0",
|
|
2601
|
+
"claude-opus-5",
|
|
2602
|
+
"claude-opus-5@20260115"
|
|
2603
|
+
]
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
summary: "The Anthropic roster, addressed as region-prefixed inference-profile IDs."
|
|
2607
|
+
},
|
|
2608
|
+
description: "AWS Bedrock, hosting Anthropic models. Bearer API key only."
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
id: "custom",
|
|
2612
|
+
label: "Custom (OpenAI or Anthropic compatible)",
|
|
2613
|
+
kind: "direct",
|
|
2614
|
+
credentialFields: [
|
|
2615
|
+
{
|
|
2616
|
+
name: "baseUrl",
|
|
2617
|
+
label: "Base URL",
|
|
2618
|
+
required: true,
|
|
2619
|
+
treatment: "plain",
|
|
2620
|
+
validation: { rule: "https-url" },
|
|
2621
|
+
description: "The endpoint serving the API. Pick its wire format below."
|
|
2622
|
+
},
|
|
2623
|
+
apiKeyField("The key the endpoint expects, sent as a bearer token."),
|
|
2624
|
+
{
|
|
2625
|
+
name: "wireFormat",
|
|
2626
|
+
label: "Wire format",
|
|
2627
|
+
required: false,
|
|
2628
|
+
treatment: "plain",
|
|
2629
|
+
validation: { rule: "one-of", values: ["openai", "anthropic"] },
|
|
2630
|
+
description: "Whether the endpoint speaks the OpenAI or the Anthropic request shape. Defaults to OpenAI when left unset — an endpoint that expects Anthropic's shape needs this set to 'anthropic'."
|
|
2631
|
+
},
|
|
2632
|
+
modelAllowListField
|
|
2633
|
+
],
|
|
2634
|
+
modelPolicy: {
|
|
2635
|
+
mode: "open",
|
|
2636
|
+
summary: "Whatever the configured endpoint publishes."
|
|
2637
|
+
},
|
|
2638
|
+
description: "Any endpoint speaking an OpenAI-compatible or Anthropic-compatible API — self-hosted or third-party."
|
|
2639
|
+
}
|
|
2640
|
+
];
|
|
2641
|
+
var CATALOG_BY_ID = new Map(PROVIDER_CATALOG.map((entry) => [entry.id, entry]));
|
|
2642
|
+
function getProviderCatalogEntry(id) {
|
|
2643
|
+
return CATALOG_BY_ID.get(id);
|
|
2644
|
+
}
|
|
2645
|
+
function getCredentialField(entry, name) {
|
|
2646
|
+
return entry.credentialFields.find((field) => field.name === name);
|
|
2647
|
+
}
|
|
2648
|
+
// src/lib/api-format.ts
|
|
2649
|
+
var API_FORMAT_WIRE_NAME = "wireFormat";
|
|
2650
|
+
function apiFormatValuesFor(providerType) {
|
|
2651
|
+
const entry = getProviderCatalogEntry(providerType);
|
|
2652
|
+
if (!entry)
|
|
2653
|
+
return;
|
|
2654
|
+
const field = getCredentialField(entry, API_FORMAT_WIRE_NAME);
|
|
2655
|
+
if (!field)
|
|
2656
|
+
return;
|
|
2657
|
+
return field.validation.rule === "one-of" ? field.validation.values : undefined;
|
|
2658
|
+
}
|
|
2659
|
+
function providerAcceptsApiFormat(providerType) {
|
|
2660
|
+
const entry = getProviderCatalogEntry(providerType);
|
|
2661
|
+
return entry !== undefined && entryAcceptsApiFormat(entry);
|
|
2662
|
+
}
|
|
2663
|
+
function entryAcceptsApiFormat(entry) {
|
|
2664
|
+
return getCredentialField(entry, API_FORMAT_WIRE_NAME) !== undefined;
|
|
2665
|
+
}
|
|
2666
|
+
function providersAcceptingApiFormat(catalog = PROVIDER_CATALOG) {
|
|
2667
|
+
return catalog.filter(entryAcceptsApiFormat).map((entry) => entry.id);
|
|
2668
|
+
}
|
|
2669
|
+
function apiFormatHelpText() {
|
|
2670
|
+
const accepting = providersAcceptingApiFormat();
|
|
2671
|
+
if (accepting.length === 0) {
|
|
2672
|
+
return "API format spoken by the endpoint (no catalog entry currently declares one)";
|
|
2673
|
+
}
|
|
2674
|
+
const values = [...new Set(accepting.flatMap((id) => apiFormatValuesFor(id) ?? []))];
|
|
2675
|
+
const scope = `${accepting.join(", ")} only`;
|
|
2676
|
+
return values.length > 0 ? `API format the endpoint speaks — ${scope}: ${values.join(", ")}` : `API format the endpoint speaks — ${scope}`;
|
|
2677
|
+
}
|
|
2678
|
+
function validateApiFormat(providerType, value) {
|
|
2679
|
+
if (!providerAcceptsApiFormat(providerType)) {
|
|
2680
|
+
const accepting = providersAcceptingApiFormat();
|
|
2681
|
+
throw new MutagentError("API_FORMAT_NOT_APPLICABLE", accepting.length > 0 ? `--api-format applies only to ${accepting.join(", ")}. '${providerType}' speaks its own API.` : `--api-format applies to no provider in the catalog. '${providerType}' speaks its own API.`, accepting.length > 0 ? `Remove --api-format, or use --provider ${accepting.join(" | ")}` : "Remove --api-format");
|
|
2682
|
+
}
|
|
2683
|
+
const values = apiFormatValuesFor(providerType);
|
|
2684
|
+
if (!values)
|
|
2685
|
+
return;
|
|
2686
|
+
if (!values.includes(value)) {
|
|
2687
|
+
throw new MutagentError("INVALID_API_FORMAT", `'${value}' is not an API format that '${providerType}' speaks.`, `${providerType} accepts: ${values.join(", ")}`);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
// src/commands/providers/add.ts
|
|
2256
2692
|
var GATEWAY_HOSTED_FAMILIES = {
|
|
2257
2693
|
azure: ["openai", "anthropic"],
|
|
2258
2694
|
vertex: ["gemini", "anthropic"],
|
|
@@ -2277,10 +2713,12 @@ function collectCredentialFields(options) {
|
|
|
2277
2713
|
fields.projectId = options.projectId;
|
|
2278
2714
|
if (options.region)
|
|
2279
2715
|
fields.region = options.region;
|
|
2716
|
+
if (options.apiFormat)
|
|
2717
|
+
fields[API_FORMAT_WIRE_NAME] = options.apiFormat;
|
|
2280
2718
|
return fields;
|
|
2281
2719
|
}
|
|
2282
2720
|
function registerAddCommand(parent) {
|
|
2283
|
-
parent.command("add").description("Add a new provider configuration").requiredOption("-p, --provider <type>", "Provider type (openai, anthropic, azure, ...)").requiredOption("-n, --name <name>", "Display name for this provider").option("-k, --api-key <key>", "API key for the provider (every entry except Google Vertex)").option("--service-account-key <json>", "Google Vertex service-account credential JSON").option("--hosted-family <family>", `Hosted model family for gateway providers: ${HOSTED_FAMILIES.join(", ")}`).option("--base-url <url>", "Custom base URL for the provider API").option("--resource-endpoint <url>", "Azure resource endpoint").option("--deployment-name <name>", "Azure deployment name").option("--api-version <version>", "Azure API version (e.g. 2024-08-01-preview)").option("--project-id <id>", "Google Vertex project ID").option("--region <region>", "Region (Vertex location, or AWS Bedrock region)").option("--set-default", "Set as the default provider of its kind").addHelpText("after", `
|
|
2721
|
+
parent.command("add").description("Add a new provider configuration").requiredOption("-p, --provider <type>", "Provider type (openai, anthropic, azure, ...)").requiredOption("-n, --name <name>", "Display name for this provider").option("-k, --api-key <key>", "API key for the provider (every entry except Google Vertex)").option("--service-account-key <json>", "Google Vertex service-account credential JSON").option("--hosted-family <family>", `Hosted model family for gateway providers: ${HOSTED_FAMILIES.join(", ")}`).option("--base-url <url>", "Custom base URL for the provider API").option("--api-format <format>", apiFormatHelpText()).option("--resource-endpoint <url>", "Azure resource endpoint").option("--deployment-name <name>", "Azure deployment name").option("--api-version <version>", "Azure API version (e.g. 2024-08-01-preview)").option("--project-id <id>", "Google Vertex project ID").option("--region <region>", "Region (Vertex location, or AWS Bedrock region)").option("--set-default", "Set as the default provider of its kind").addHelpText("after", `
|
|
2284
2722
|
Examples:
|
|
2285
2723
|
${chalk8.dim("$")} mutagent providers add --provider openai --name "My OpenAI" --api-key $OPENAI_API_KEY
|
|
2286
2724
|
${chalk8.dim("$")} mutagent providers add --provider azure --name "Azure GPT" --api-key $KEY \\
|
|
@@ -2288,10 +2726,16 @@ Examples:
|
|
|
2288
2726
|
${chalk8.dim("$")} mutagent providers add --provider bedrock --name "Bedrock Claude" --api-key $KEY \\
|
|
2289
2727
|
--hosted-family anthropic --region us-east-1
|
|
2290
2728
|
${chalk8.dim("$")} mutagent providers add --provider custom --name "Ollama" --api-key none --base-url https://ollama.internal --json
|
|
2729
|
+
${chalk8.dim("$")} mutagent providers add --provider custom --name "Claude-compatible" --api-key $KEY \\
|
|
2730
|
+
--base-url https://llm.internal --api-format anthropic
|
|
2291
2731
|
|
|
2292
2732
|
Gateway providers (${[...GATEWAY_PROVIDERS].join(", ")}) serve another vendor's models and
|
|
2293
2733
|
require --hosted-family. Direct providers must not set it.
|
|
2294
2734
|
|
|
2735
|
+
${apiFormatHelpText()}. An endpoint speaking the Anthropic request shape needs
|
|
2736
|
+
--api-format anthropic; left unset, the server's default applies. Passing it to a
|
|
2737
|
+
provider that speaks its own API is an error, not a silent no-op.
|
|
2738
|
+
|
|
2295
2739
|
Providers are configured for your workspace. Set the target with:
|
|
2296
2740
|
${chalk8.dim("$")} mutagent config set workspace <workspace-id>
|
|
2297
2741
|
|
|
@@ -2326,6 +2770,9 @@ AI Agent Directive:
|
|
|
2326
2770
|
} else if (isGateway && allowedFamilies.length > 1) {
|
|
2327
2771
|
throw new MutagentError("MISSING_HOSTED_FAMILY", `'${providerType}' is a gateway and needs to know which model family it serves.`, `Add --hosted-family <${allowedFamilies.join("|")}>`);
|
|
2328
2772
|
}
|
|
2773
|
+
if (options.apiFormat) {
|
|
2774
|
+
validateApiFormat(providerType, options.apiFormat);
|
|
2775
|
+
}
|
|
2329
2776
|
const client = await getSDKClient();
|
|
2330
2777
|
const workspaceId = client.requireUnambiguousWorkspace();
|
|
2331
2778
|
const credentialFields = collectCredentialFields(options);
|
|
@@ -2357,6 +2804,9 @@ AI Agent Directive:
|
|
|
2357
2804
|
if (options.hostedFamily) {
|
|
2358
2805
|
console.log(` Serves: ${options.hostedFamily}`);
|
|
2359
2806
|
}
|
|
2807
|
+
if (options.apiFormat) {
|
|
2808
|
+
console.log(` API format: ${options.apiFormat}`);
|
|
2809
|
+
}
|
|
2360
2810
|
console.log(` Workspace: ${workspaceId}`);
|
|
2361
2811
|
console.log(` URL: ${providerLink(created.id)}`);
|
|
2362
2812
|
if (options.setDefault) {
|
|
@@ -5134,5 +5584,5 @@ program.addCommand(createInstallCommand());
|
|
|
5134
5584
|
program.addCommand(createFeedbackCommand());
|
|
5135
5585
|
program.parse();
|
|
5136
5586
|
|
|
5137
|
-
//# debugId=
|
|
5587
|
+
//# debugId=67EF27735DAD427E64756E2164756E21
|
|
5138
5588
|
//# sourceMappingURL=cli.js.map
|