@hasna/switcher 0.1.5 → 0.1.7
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/README.md +23 -0
- package/dist/catalog.d.ts +1 -0
- package/dist/claude-context.d.ts +5 -0
- package/dist/cli/index.js +519 -32
- package/dist/credentials.d.ts +12 -0
- package/dist/domain.d.ts +103 -1
- package/dist/generated/api.d.ts +47 -0
- package/dist/index.js +13 -2
- package/dist/mcp/index.js +8 -2
- package/dist/presets.d.ts +14 -0
- package/dist/provider-error.d.ts +2 -0
- package/dist/sdk.d.ts +74 -0
- package/dist/sdk.js +13 -2
- package/dist/serve/index.js +311 -20
- package/openapi.json +268 -2
- package/package.json +1 -1
package/dist/serve/index.js
CHANGED
|
@@ -62,7 +62,7 @@ function canonicalPolicyJSON(value) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// src/domain.ts
|
|
65
|
-
var VERSION = "0.1.
|
|
65
|
+
var VERSION = "0.1.7";
|
|
66
66
|
var harnessSchema = z2.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
67
67
|
var protocolSchema = z2.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
68
68
|
var idSchema = z2.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
@@ -87,11 +87,16 @@ var urlSchema = z2.string().max(2000).superRefine((v, ctx) => {
|
|
|
87
87
|
ctx.addIssue({ code: "custom", message: "Invalid endpoint URL" });
|
|
88
88
|
}
|
|
89
89
|
}).transform(endpoint);
|
|
90
|
+
var expiresOnSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => {
|
|
91
|
+
const day = new Date(`${value}T00:00:00.000Z`);
|
|
92
|
+
return Number.isFinite(day.getTime()) && day.toISOString().slice(0, 10) === value;
|
|
93
|
+
}, "Use a real calendar date in YYYY-MM-DD format.");
|
|
90
94
|
var modelSchema = z2.object({
|
|
91
95
|
id: z2.string().min(1).max(300),
|
|
92
96
|
name: label,
|
|
93
97
|
description: z2.string().max(8000).optional(),
|
|
94
98
|
available: z2.boolean().optional(),
|
|
99
|
+
expiresOn: expiresOnSchema.optional(),
|
|
95
100
|
contextWindow: z2.number().int().positive().optional(),
|
|
96
101
|
maxOutputTokens: z2.number().int().positive().optional(),
|
|
97
102
|
inputModalities: z2.array(z2.string().max(50)).max(20).optional(),
|
|
@@ -112,7 +117,8 @@ var providerInputSchema = z2.object({
|
|
|
112
117
|
catalogCredentialEnv: envRef.optional(),
|
|
113
118
|
catalogAccountId: z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/).optional(),
|
|
114
119
|
modelsPath: z2.string().regex(/^[a-zA-Z0-9_/-]+$/).max(200).default("models"),
|
|
115
|
-
manualModels: z2.array(modelSchema).max(1e4).default([])
|
|
120
|
+
manualModels: z2.array(modelSchema).max(1e4).default([]),
|
|
121
|
+
additionalModels: z2.array(modelSchema).max(1e4).optional()
|
|
116
122
|
}).strict().refine((p) => !p.modelsPath.split("/").includes("..") && !p.modelsPath.startsWith("/"), "modelsPath must be relative");
|
|
117
123
|
var providerPresetSchema = z2.object({
|
|
118
124
|
id: idSchema,
|
|
@@ -187,11 +193,14 @@ function validateHarnessProvider(harness, provider) {
|
|
|
187
193
|
if (harness === "gemini" && provider.authStyle !== "x-api-key")
|
|
188
194
|
throw new Fault(422, "auth_mismatch", "Gemini CLI requires x-api-key authentication for its native generateContent protocol.");
|
|
189
195
|
}
|
|
196
|
+
function modelExpired(model, now = new Date) {
|
|
197
|
+
return model.expiresOn !== undefined && now.toISOString().slice(0, 10) > model.expiresOn;
|
|
198
|
+
}
|
|
190
199
|
function codingEligible(model) {
|
|
191
|
-
return model.available !== false && (!model.supportedGenerationMethods || model.supportedGenerationMethods.includes("generateContent")) && (!model.outputModalities || model.outputModalities.includes("text")) && (!model.supportedParameters || model.supportedParameters.includes("tools"));
|
|
200
|
+
return !modelExpired(model) && model.available !== false && (!model.supportedGenerationMethods || model.supportedGenerationMethods.includes("generateContent")) && (!model.outputModalities || model.outputModalities.includes("text")) && (!model.supportedParameters || model.supportedParameters.includes("tools"));
|
|
192
201
|
}
|
|
193
202
|
function harnessEligible(model, harness) {
|
|
194
|
-
return harness === "aider" ? model.available !== false && (!model.supportedGenerationMethods || model.supportedGenerationMethods.includes("generateContent")) && (!model.inputModalities || model.inputModalities.includes("text")) && (!model.outputModalities || model.outputModalities.includes("text")) : codingEligible(model);
|
|
203
|
+
return !modelExpired(model) && (harness === "aider" ? model.available !== false && (!model.supportedGenerationMethods || model.supportedGenerationMethods.includes("generateContent")) && (!model.inputModalities || model.inputModalities.includes("text")) && (!model.outputModalities || model.outputModalities.includes("text")) : codingEligible(model));
|
|
195
204
|
}
|
|
196
205
|
|
|
197
206
|
// src/store.ts
|
|
@@ -465,7 +474,7 @@ async function fetchCatalogPage(url, headers, deadline) {
|
|
|
465
474
|
await waitForCatalogRetry(delay ?? 100 * 2 ** retry, deadline);
|
|
466
475
|
}
|
|
467
476
|
}
|
|
468
|
-
async function
|
|
477
|
+
async function discoverBase(provider, env = process.env, resolveCredential) {
|
|
469
478
|
const refreshedAt = new Date().toISOString();
|
|
470
479
|
if (provider.manualModels.length)
|
|
471
480
|
return { models: provider.manualModels, source: "manual", refreshedAt };
|
|
@@ -523,6 +532,7 @@ async function discover(provider, env = process.env, resolveCredential) {
|
|
|
523
532
|
id,
|
|
524
533
|
name: row.displayName ?? row.name ?? row.display_name ?? id,
|
|
525
534
|
available: provider.catalogFormat === "mistral" && typeof row.archived === "boolean" ? !row.archived : undefined,
|
|
535
|
+
expiresOn: row.expiresOn ?? row.expires_on,
|
|
526
536
|
description: typeof row.description === "string" ? row.description.slice(0, 8000) : undefined,
|
|
527
537
|
contextWindow: positive(row.context_length ?? row.context_window ?? row.contextLength ?? row.inputTokenLimit ?? row.model_info?.context_window ?? (provider.catalogFormat === "mistral" ? row.max_context_length : undefined)),
|
|
528
538
|
maxOutputTokens: positive(row.top_provider?.max_completion_tokens ?? row.max_output_tokens ?? row.outputTokenLimit ?? row.model_info?.max_output_tokens),
|
|
@@ -649,6 +659,15 @@ async function discover(provider, env = process.env, resolveCredential) {
|
|
|
649
659
|
}
|
|
650
660
|
throw new Fault(502, "catalog_too_large", "Provider catalog pagination exceeded 100 pages.");
|
|
651
661
|
}
|
|
662
|
+
async function discover(provider, env = process.env, resolveCredential) {
|
|
663
|
+
const catalog = await discoverBase(provider, env, resolveCredential);
|
|
664
|
+
const models = new Map(catalog.models.map((model) => [model.id, model]));
|
|
665
|
+
for (const additional of provider.additionalModels ?? [])
|
|
666
|
+
models.set(additional.id, { ...models.get(additional.id), ...additional });
|
|
667
|
+
if (models.size > 1e4)
|
|
668
|
+
throw new Fault(502, "catalog_too_large", "Combined catalog exceeds 10,000 models.");
|
|
669
|
+
return { ...catalog, models: [...models.values()] };
|
|
670
|
+
}
|
|
652
671
|
|
|
653
672
|
// src/model-policy.ts
|
|
654
673
|
import { createHash } from "crypto";
|
|
@@ -664,9 +683,15 @@ function stable(value) {
|
|
|
664
683
|
}
|
|
665
684
|
function compileModelPolicy(model, catalog, policy) {
|
|
666
685
|
const selected = id(model, "model");
|
|
667
|
-
const available = new Set(catalog.filter((m) => m.available !== false).map((m) => m.id));
|
|
668
|
-
|
|
669
|
-
|
|
686
|
+
const available = new Set(catalog.filter((m) => m.available !== false && !modelExpired(m)).map((m) => m.id));
|
|
687
|
+
const expired = new Set(catalog.filter((m) => modelExpired(m)).map((m) => m.id));
|
|
688
|
+
const requireAvailable = (value, message) => {
|
|
689
|
+
if (expired.has(value))
|
|
690
|
+
throw new Fault(422, "model_expired", "A selected model has passed its configured expiry date. Select an unexpired model.");
|
|
691
|
+
if (!available.has(value))
|
|
692
|
+
throw new Fault(422, "model_unavailable", message);
|
|
693
|
+
};
|
|
694
|
+
requireAvailable(selected, "Selected model is not present in the eligible catalog.");
|
|
670
695
|
if (policy && policy.version !== undefined && policy.version !== 1)
|
|
671
696
|
throw new Fault(400, "invalid_model_policy", "Unsupported model policy version.");
|
|
672
697
|
const p = parse(modelPolicySchema, policy ?? {});
|
|
@@ -675,14 +700,12 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
675
700
|
throw new Fault(400, "invalid_model_policy", "Unknown model policy role.");
|
|
676
701
|
const compiledRoles = Object.fromEntries(roles.map((role) => [role, id(roleInput[role] ?? selected, `roles.${role}`)]));
|
|
677
702
|
for (const value of Object.values(compiledRoles))
|
|
678
|
-
|
|
679
|
-
throw new Fault(422, "model_unavailable", "A model policy role is not present in the eligible catalog.");
|
|
703
|
+
requireAvailable(value, "A model policy role is not present in the eligible catalog.");
|
|
680
704
|
const explicitAllowed = (p.allowedModels ?? []).map((v, i) => id(v, `allowedModels[${i}]`));
|
|
681
705
|
if (explicitAllowed.length > 500)
|
|
682
706
|
throw new Fault(400, "invalid_model_policy", "Model policy allowedModels is too large.");
|
|
683
707
|
for (const value of explicitAllowed)
|
|
684
|
-
|
|
685
|
-
throw new Fault(422, "model_unavailable", "An allowed model is not present in the eligible catalog.");
|
|
708
|
+
requireAvailable(value, "An allowed model is not present in the eligible catalog.");
|
|
686
709
|
const aliases = Object.create(null);
|
|
687
710
|
for (const [name, target] of Object.entries(p.aliases ?? {})) {
|
|
688
711
|
if (Object.keys(aliases).length >= 200 || !/^[A-Za-z0-9._/-]{1,120}$/.test(name) || ["__proto__", "prototype", "constructor"].includes(name))
|
|
@@ -690,8 +713,7 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
690
713
|
const canonical = id(target, `aliases.${name}`);
|
|
691
714
|
if (available.has(name) && name !== canonical)
|
|
692
715
|
throw new Fault(400, "invalid_model_policy", "A model alias cannot shadow a real model ID.");
|
|
693
|
-
|
|
694
|
-
throw new Fault(422, "model_unavailable", "A model alias target is not present in the eligible catalog.");
|
|
716
|
+
requireAvailable(canonical, "A model alias target is not present in the eligible catalog.");
|
|
695
717
|
aliases[name] = canonical;
|
|
696
718
|
}
|
|
697
719
|
const fallbacks = Object.create(null);
|
|
@@ -700,8 +722,8 @@ function compileModelPolicy(model, catalog, policy) {
|
|
|
700
722
|
if (!allowedSources.has(source) || !available.has(source) || !Array.isArray(targets) || Object.keys(fallbacks).length >= 200 || targets.length > 20)
|
|
701
723
|
throw new Fault(400, "invalid_model_policy", "Fallback source or list is invalid.");
|
|
702
724
|
const values = targets.map((v, i) => id(v, `fallbacks.${source}[${i}]`));
|
|
703
|
-
|
|
704
|
-
|
|
725
|
+
for (const value of values)
|
|
726
|
+
requireAvailable(value, "A fallback model is not present in the eligible catalog.");
|
|
705
727
|
if (values.includes(source))
|
|
706
728
|
throw new Fault(400, "invalid_model_policy", "A model cannot fall back to itself.");
|
|
707
729
|
fallbacks[source] = uniq(values);
|
|
@@ -808,7 +830,7 @@ var openapi_default = {
|
|
|
808
830
|
openapi: "3.0.3",
|
|
809
831
|
info: {
|
|
810
832
|
title: "Switcher API",
|
|
811
|
-
version: "0.1.
|
|
833
|
+
version: "0.1.7",
|
|
812
834
|
description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
|
|
813
835
|
},
|
|
814
836
|
security: [
|
|
@@ -2209,6 +2231,10 @@ var openapi_default = {
|
|
|
2209
2231
|
available: {
|
|
2210
2232
|
type: "boolean"
|
|
2211
2233
|
},
|
|
2234
|
+
expiresOn: {
|
|
2235
|
+
type: "string",
|
|
2236
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2237
|
+
},
|
|
2212
2238
|
contextWindow: {
|
|
2213
2239
|
type: "integer",
|
|
2214
2240
|
exclusiveMinimum: true,
|
|
@@ -2261,6 +2287,84 @@ var openapi_default = {
|
|
|
2261
2287
|
},
|
|
2262
2288
|
maxItems: 1e4,
|
|
2263
2289
|
default: []
|
|
2290
|
+
},
|
|
2291
|
+
additionalModels: {
|
|
2292
|
+
type: "array",
|
|
2293
|
+
items: {
|
|
2294
|
+
type: "object",
|
|
2295
|
+
properties: {
|
|
2296
|
+
id: {
|
|
2297
|
+
type: "string",
|
|
2298
|
+
minLength: 1,
|
|
2299
|
+
maxLength: 300
|
|
2300
|
+
},
|
|
2301
|
+
name: {
|
|
2302
|
+
type: "string",
|
|
2303
|
+
minLength: 1,
|
|
2304
|
+
maxLength: 200
|
|
2305
|
+
},
|
|
2306
|
+
description: {
|
|
2307
|
+
type: "string",
|
|
2308
|
+
maxLength: 8000
|
|
2309
|
+
},
|
|
2310
|
+
available: {
|
|
2311
|
+
type: "boolean"
|
|
2312
|
+
},
|
|
2313
|
+
expiresOn: {
|
|
2314
|
+
type: "string",
|
|
2315
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2316
|
+
},
|
|
2317
|
+
contextWindow: {
|
|
2318
|
+
type: "integer",
|
|
2319
|
+
exclusiveMinimum: true,
|
|
2320
|
+
minimum: 0
|
|
2321
|
+
},
|
|
2322
|
+
maxOutputTokens: {
|
|
2323
|
+
type: "integer",
|
|
2324
|
+
exclusiveMinimum: true,
|
|
2325
|
+
minimum: 0
|
|
2326
|
+
},
|
|
2327
|
+
inputModalities: {
|
|
2328
|
+
type: "array",
|
|
2329
|
+
items: {
|
|
2330
|
+
type: "string",
|
|
2331
|
+
maxLength: 50
|
|
2332
|
+
},
|
|
2333
|
+
maxItems: 20
|
|
2334
|
+
},
|
|
2335
|
+
outputModalities: {
|
|
2336
|
+
type: "array",
|
|
2337
|
+
items: {
|
|
2338
|
+
type: "string",
|
|
2339
|
+
maxLength: 50
|
|
2340
|
+
},
|
|
2341
|
+
maxItems: 20
|
|
2342
|
+
},
|
|
2343
|
+
supportedParameters: {
|
|
2344
|
+
type: "array",
|
|
2345
|
+
items: {
|
|
2346
|
+
type: "string",
|
|
2347
|
+
maxLength: 100
|
|
2348
|
+
},
|
|
2349
|
+
maxItems: 100
|
|
2350
|
+
},
|
|
2351
|
+
supportedGenerationMethods: {
|
|
2352
|
+
type: "array",
|
|
2353
|
+
items: {
|
|
2354
|
+
type: "string",
|
|
2355
|
+
minLength: 1,
|
|
2356
|
+
maxLength: 100
|
|
2357
|
+
},
|
|
2358
|
+
maxItems: 100
|
|
2359
|
+
}
|
|
2360
|
+
},
|
|
2361
|
+
required: [
|
|
2362
|
+
"id",
|
|
2363
|
+
"name"
|
|
2364
|
+
],
|
|
2365
|
+
additionalProperties: false
|
|
2366
|
+
},
|
|
2367
|
+
maxItems: 1e4
|
|
2264
2368
|
}
|
|
2265
2369
|
},
|
|
2266
2370
|
required: [
|
|
@@ -2371,6 +2475,10 @@ var openapi_default = {
|
|
|
2371
2475
|
available: {
|
|
2372
2476
|
type: "boolean"
|
|
2373
2477
|
},
|
|
2478
|
+
expiresOn: {
|
|
2479
|
+
type: "string",
|
|
2480
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2481
|
+
},
|
|
2374
2482
|
contextWindow: {
|
|
2375
2483
|
type: "integer",
|
|
2376
2484
|
exclusiveMinimum: true,
|
|
@@ -2424,6 +2532,84 @@ var openapi_default = {
|
|
|
2424
2532
|
maxItems: 1e4,
|
|
2425
2533
|
default: []
|
|
2426
2534
|
},
|
|
2535
|
+
additionalModels: {
|
|
2536
|
+
type: "array",
|
|
2537
|
+
items: {
|
|
2538
|
+
type: "object",
|
|
2539
|
+
properties: {
|
|
2540
|
+
id: {
|
|
2541
|
+
type: "string",
|
|
2542
|
+
minLength: 1,
|
|
2543
|
+
maxLength: 300
|
|
2544
|
+
},
|
|
2545
|
+
name: {
|
|
2546
|
+
type: "string",
|
|
2547
|
+
minLength: 1,
|
|
2548
|
+
maxLength: 200
|
|
2549
|
+
},
|
|
2550
|
+
description: {
|
|
2551
|
+
type: "string",
|
|
2552
|
+
maxLength: 8000
|
|
2553
|
+
},
|
|
2554
|
+
available: {
|
|
2555
|
+
type: "boolean"
|
|
2556
|
+
},
|
|
2557
|
+
expiresOn: {
|
|
2558
|
+
type: "string",
|
|
2559
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2560
|
+
},
|
|
2561
|
+
contextWindow: {
|
|
2562
|
+
type: "integer",
|
|
2563
|
+
exclusiveMinimum: true,
|
|
2564
|
+
minimum: 0
|
|
2565
|
+
},
|
|
2566
|
+
maxOutputTokens: {
|
|
2567
|
+
type: "integer",
|
|
2568
|
+
exclusiveMinimum: true,
|
|
2569
|
+
minimum: 0
|
|
2570
|
+
},
|
|
2571
|
+
inputModalities: {
|
|
2572
|
+
type: "array",
|
|
2573
|
+
items: {
|
|
2574
|
+
type: "string",
|
|
2575
|
+
maxLength: 50
|
|
2576
|
+
},
|
|
2577
|
+
maxItems: 20
|
|
2578
|
+
},
|
|
2579
|
+
outputModalities: {
|
|
2580
|
+
type: "array",
|
|
2581
|
+
items: {
|
|
2582
|
+
type: "string",
|
|
2583
|
+
maxLength: 50
|
|
2584
|
+
},
|
|
2585
|
+
maxItems: 20
|
|
2586
|
+
},
|
|
2587
|
+
supportedParameters: {
|
|
2588
|
+
type: "array",
|
|
2589
|
+
items: {
|
|
2590
|
+
type: "string",
|
|
2591
|
+
maxLength: 100
|
|
2592
|
+
},
|
|
2593
|
+
maxItems: 100
|
|
2594
|
+
},
|
|
2595
|
+
supportedGenerationMethods: {
|
|
2596
|
+
type: "array",
|
|
2597
|
+
items: {
|
|
2598
|
+
type: "string",
|
|
2599
|
+
minLength: 1,
|
|
2600
|
+
maxLength: 100
|
|
2601
|
+
},
|
|
2602
|
+
maxItems: 100
|
|
2603
|
+
}
|
|
2604
|
+
},
|
|
2605
|
+
required: [
|
|
2606
|
+
"id",
|
|
2607
|
+
"name"
|
|
2608
|
+
],
|
|
2609
|
+
additionalProperties: false
|
|
2610
|
+
},
|
|
2611
|
+
maxItems: 1e4
|
|
2612
|
+
},
|
|
2427
2613
|
version: {
|
|
2428
2614
|
type: "integer",
|
|
2429
2615
|
exclusiveMinimum: true,
|
|
@@ -2771,6 +2957,10 @@ var openapi_default = {
|
|
|
2771
2957
|
available: {
|
|
2772
2958
|
type: "boolean"
|
|
2773
2959
|
},
|
|
2960
|
+
expiresOn: {
|
|
2961
|
+
type: "string",
|
|
2962
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2963
|
+
},
|
|
2774
2964
|
contextWindow: {
|
|
2775
2965
|
type: "integer",
|
|
2776
2966
|
exclusiveMinimum: true,
|
|
@@ -3015,6 +3205,10 @@ var openapi_default = {
|
|
|
3015
3205
|
available: {
|
|
3016
3206
|
type: "boolean"
|
|
3017
3207
|
},
|
|
3208
|
+
expiresOn: {
|
|
3209
|
+
type: "string",
|
|
3210
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3211
|
+
},
|
|
3018
3212
|
contextWindow: {
|
|
3019
3213
|
type: "integer",
|
|
3020
3214
|
exclusiveMinimum: true,
|
|
@@ -3060,12 +3254,16 @@ var openapi_default = {
|
|
|
3060
3254
|
},
|
|
3061
3255
|
codingEligible: {
|
|
3062
3256
|
type: "boolean"
|
|
3257
|
+
},
|
|
3258
|
+
expired: {
|
|
3259
|
+
type: "boolean"
|
|
3063
3260
|
}
|
|
3064
3261
|
},
|
|
3065
3262
|
required: [
|
|
3066
3263
|
"id",
|
|
3067
3264
|
"name",
|
|
3068
|
-
"codingEligible"
|
|
3265
|
+
"codingEligible",
|
|
3266
|
+
"expired"
|
|
3069
3267
|
],
|
|
3070
3268
|
additionalProperties: false
|
|
3071
3269
|
}
|
|
@@ -3125,6 +3323,10 @@ var openapi_default = {
|
|
|
3125
3323
|
available: {
|
|
3126
3324
|
type: "boolean"
|
|
3127
3325
|
},
|
|
3326
|
+
expiresOn: {
|
|
3327
|
+
type: "string",
|
|
3328
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3329
|
+
},
|
|
3128
3330
|
contextWindow: {
|
|
3129
3331
|
type: "integer",
|
|
3130
3332
|
exclusiveMinimum: true,
|
|
@@ -3297,6 +3499,10 @@ var openapi_default = {
|
|
|
3297
3499
|
available: {
|
|
3298
3500
|
type: "boolean"
|
|
3299
3501
|
},
|
|
3502
|
+
expiresOn: {
|
|
3503
|
+
type: "string",
|
|
3504
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3505
|
+
},
|
|
3300
3506
|
contextWindow: {
|
|
3301
3507
|
type: "integer",
|
|
3302
3508
|
exclusiveMinimum: true,
|
|
@@ -3350,6 +3556,84 @@ var openapi_default = {
|
|
|
3350
3556
|
maxItems: 1e4,
|
|
3351
3557
|
default: []
|
|
3352
3558
|
},
|
|
3559
|
+
additionalModels: {
|
|
3560
|
+
type: "array",
|
|
3561
|
+
items: {
|
|
3562
|
+
type: "object",
|
|
3563
|
+
properties: {
|
|
3564
|
+
id: {
|
|
3565
|
+
type: "string",
|
|
3566
|
+
minLength: 1,
|
|
3567
|
+
maxLength: 300
|
|
3568
|
+
},
|
|
3569
|
+
name: {
|
|
3570
|
+
type: "string",
|
|
3571
|
+
minLength: 1,
|
|
3572
|
+
maxLength: 200
|
|
3573
|
+
},
|
|
3574
|
+
description: {
|
|
3575
|
+
type: "string",
|
|
3576
|
+
maxLength: 8000
|
|
3577
|
+
},
|
|
3578
|
+
available: {
|
|
3579
|
+
type: "boolean"
|
|
3580
|
+
},
|
|
3581
|
+
expiresOn: {
|
|
3582
|
+
type: "string",
|
|
3583
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3584
|
+
},
|
|
3585
|
+
contextWindow: {
|
|
3586
|
+
type: "integer",
|
|
3587
|
+
exclusiveMinimum: true,
|
|
3588
|
+
minimum: 0
|
|
3589
|
+
},
|
|
3590
|
+
maxOutputTokens: {
|
|
3591
|
+
type: "integer",
|
|
3592
|
+
exclusiveMinimum: true,
|
|
3593
|
+
minimum: 0
|
|
3594
|
+
},
|
|
3595
|
+
inputModalities: {
|
|
3596
|
+
type: "array",
|
|
3597
|
+
items: {
|
|
3598
|
+
type: "string",
|
|
3599
|
+
maxLength: 50
|
|
3600
|
+
},
|
|
3601
|
+
maxItems: 20
|
|
3602
|
+
},
|
|
3603
|
+
outputModalities: {
|
|
3604
|
+
type: "array",
|
|
3605
|
+
items: {
|
|
3606
|
+
type: "string",
|
|
3607
|
+
maxLength: 50
|
|
3608
|
+
},
|
|
3609
|
+
maxItems: 20
|
|
3610
|
+
},
|
|
3611
|
+
supportedParameters: {
|
|
3612
|
+
type: "array",
|
|
3613
|
+
items: {
|
|
3614
|
+
type: "string",
|
|
3615
|
+
maxLength: 100
|
|
3616
|
+
},
|
|
3617
|
+
maxItems: 100
|
|
3618
|
+
},
|
|
3619
|
+
supportedGenerationMethods: {
|
|
3620
|
+
type: "array",
|
|
3621
|
+
items: {
|
|
3622
|
+
type: "string",
|
|
3623
|
+
minLength: 1,
|
|
3624
|
+
maxLength: 100
|
|
3625
|
+
},
|
|
3626
|
+
maxItems: 100
|
|
3627
|
+
}
|
|
3628
|
+
},
|
|
3629
|
+
required: [
|
|
3630
|
+
"id",
|
|
3631
|
+
"name"
|
|
3632
|
+
],
|
|
3633
|
+
additionalProperties: false
|
|
3634
|
+
},
|
|
3635
|
+
maxItems: 1e4
|
|
3636
|
+
},
|
|
3353
3637
|
version: {
|
|
3354
3638
|
type: "integer",
|
|
3355
3639
|
exclusiveMinimum: true,
|
|
@@ -3553,6 +3837,10 @@ var openapi_default = {
|
|
|
3553
3837
|
available: {
|
|
3554
3838
|
type: "boolean"
|
|
3555
3839
|
},
|
|
3840
|
+
expiresOn: {
|
|
3841
|
+
type: "string",
|
|
3842
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3843
|
+
},
|
|
3556
3844
|
contextWindow: {
|
|
3557
3845
|
type: "integer",
|
|
3558
3846
|
exclusiveMinimum: true,
|
|
@@ -4332,7 +4620,7 @@ function createHandler(store, apiKey, providerEnv = process.env, resolveCredenti
|
|
|
4332
4620
|
const catalog = await store.get("catalogs", id2);
|
|
4333
4621
|
const p = page();
|
|
4334
4622
|
const filtered = catalog.models.filter((m) => [m.id, m.name].some((s) => s.toLowerCase().includes(p.search.toLowerCase())));
|
|
4335
|
-
return json({ ...catalog, models: undefined, data: filtered.slice(p.offset, p.offset + p.limit).map((m) => ({ ...m, codingEligible: codingEligible(m) })), total: filtered.length, ...p });
|
|
4623
|
+
return json({ ...catalog, models: undefined, data: filtered.slice(p.offset, p.offset + p.limit).map((m) => ({ ...m, codingEligible: codingEligible(m), expired: modelExpired(m) })), total: filtered.length, ...p });
|
|
4336
4624
|
}
|
|
4337
4625
|
throw new Fault(404, "not_found", "Route was not found.");
|
|
4338
4626
|
}
|
|
@@ -4418,9 +4706,11 @@ function createHandler(store, apiKey, providerEnv = process.env, resolveCredenti
|
|
|
4418
4706
|
const selected = catalog.models.find((m) => m.id === profile.model);
|
|
4419
4707
|
if (!selected)
|
|
4420
4708
|
throw new Fault(422, "model_missing", "Selected model is not in the provider catalog.");
|
|
4709
|
+
if (modelExpired(selected))
|
|
4710
|
+
throw new Fault(422, "model_expired", "Selected model has passed its configured expiry date. Select an unexpired model.");
|
|
4421
4711
|
if (!harnessEligible(selected, profile.harness))
|
|
4422
4712
|
throw new Fault(422, "model_ineligible", "Selected model is unavailable or explicitly lacks a required generation method, text output or tool support.");
|
|
4423
|
-
compileModelPolicy(profile.model, catalog.models.filter((model) => harnessEligible(model, profile.harness)), profile.modelPolicy);
|
|
4713
|
+
compileModelPolicy(profile.model, catalog.models.filter((model) => modelExpired(model) || harnessEligible(model, profile.harness)), profile.modelPolicy);
|
|
4424
4714
|
const warnings = [];
|
|
4425
4715
|
if (profile.harness !== "aider" && !selected.supportedParameters)
|
|
4426
4716
|
warnings.push("Provider does not declare tool capabilities; execution compatibility is unverified.");
|
|
@@ -4452,6 +4742,7 @@ function createHandler(store, apiKey, providerEnv = process.env, resolveCredenti
|
|
|
4452
4742
|
}
|
|
4453
4743
|
if (profile.harness !== input.harness || profile.model !== input.model || canonicalPolicyJSON(profile.modelPolicy ?? null) !== canonicalPolicyJSON(input.modelPolicy ?? profile.modelPolicy ?? null) || snapshot(profile, provider, catalog) !== input.planToken)
|
|
4454
4744
|
throw new Fault(409, "plan_changed", "Provider, profile, model policy or catalog changed; request a fresh launch plan.");
|
|
4745
|
+
compileModelPolicy(profile.model, catalog.models.filter((model) => modelExpired(model) || harnessEligible(model, profile.harness)), profile.modelPolicy);
|
|
4455
4746
|
return store.put("runs", { ...input, modelPolicy: profile.modelPolicy, providerId: provider.id, providerVersion: provider.version, profileVersion: profile.version, id: crypto.randomUUID(), status: "running", startedAt: new Date().toISOString() }, undefined, db);
|
|
4456
4747
|
}
|
|
4457
4748
|
if (resource === "runs" && id2 && request.method === "PATCH" && parts.length === 3) {
|