@hasna/switcher 0.1.9 → 0.2.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/README.md +84 -5
- package/dist/cli/index.js +701 -69
- package/dist/domain.d.ts +1 -1
- package/dist/gemini-bridge.d.ts +2 -1
- package/dist/harnesses.d.ts +6 -0
- package/dist/hermes-backend.d.ts +2 -1
- package/dist/index.js +5 -0
- package/dist/inference-gateway.d.ts +2 -1
- package/dist/lib/local-opt-in.d.ts +30 -0
- package/dist/mcp/index.js +4866 -25
- package/dist/opencode.d.ts +30 -0
- package/dist/provider-request.d.ts +15 -0
- package/dist/provider-stream.d.ts +3 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/sdk.js +5 -0
- package/dist/serve/index.js +9 -3
- package/openapi.json +1 -1
- package/package.json +5 -3
package/dist/mcp/index.js
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
// src/mcp.ts
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
-
import { z as
|
|
7
|
+
import { z as z5 } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/runtime.ts
|
|
10
|
+
import { randomBytes } from "crypto";
|
|
11
|
+
import { mkdir as mkdir2, lstat } from "fs/promises";
|
|
12
|
+
import { homedir as homedir2 } from "os";
|
|
13
|
+
import { isAbsolute, join, resolve as resolve2 } from "path";
|
|
8
14
|
|
|
9
15
|
// src/domain.ts
|
|
10
16
|
import { z as z3 } from "zod";
|
|
@@ -58,9 +64,12 @@ var routingEventSchema = z2.object({
|
|
|
58
64
|
upstreamStatus: z2.number().int().min(100).max(599).optional()
|
|
59
65
|
}).strict();
|
|
60
66
|
var routingEventsSchema = z2.array(routingEventSchema).max(1000);
|
|
67
|
+
function canonicalPolicyJSON(value) {
|
|
68
|
+
return JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
|
|
69
|
+
}
|
|
61
70
|
|
|
62
71
|
// src/domain.ts
|
|
63
|
-
var VERSION = "0.1
|
|
72
|
+
var VERSION = "0.2.1";
|
|
64
73
|
var harnessSchema = z3.enum(["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]);
|
|
65
74
|
var protocolSchema = z3.enum(["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]);
|
|
66
75
|
var idSchema = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
|
|
@@ -175,6 +184,32 @@ function parse(schema, value) {
|
|
|
175
184
|
throw new Fault(400, "invalid_request", result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; "));
|
|
176
185
|
return result.data;
|
|
177
186
|
}
|
|
187
|
+
function compatible(harness, protocol) {
|
|
188
|
+
if (harness === "claude")
|
|
189
|
+
return protocol === "anthropic-messages";
|
|
190
|
+
if (harness === "codex")
|
|
191
|
+
return protocol === "openai-responses";
|
|
192
|
+
if (harness === "gemini")
|
|
193
|
+
return protocol === "gemini-generate-content";
|
|
194
|
+
if (protocol === "gemini-generate-content")
|
|
195
|
+
return false;
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
function validateHarnessProvider(harness, provider) {
|
|
199
|
+
if (!compatible(harness, provider.protocol))
|
|
200
|
+
throw new Fault(422, "protocol_mismatch", "Harness does not support this provider protocol.");
|
|
201
|
+
if (harness === "gemini" && provider.authStyle !== "x-api-key")
|
|
202
|
+
throw new Fault(422, "auth_mismatch", "Gemini CLI requires x-api-key authentication for its native generateContent protocol.");
|
|
203
|
+
}
|
|
204
|
+
function modelExpired(model, now = new Date) {
|
|
205
|
+
return model.expiresOn !== undefined && now.toISOString().slice(0, 10) > model.expiresOn;
|
|
206
|
+
}
|
|
207
|
+
function codingEligible(model) {
|
|
208
|
+
return !modelExpired(model) && model.available !== false && (!model.supportedGenerationMethods || model.supportedGenerationMethods.includes("generateContent")) && (!model.outputModalities || model.outputModalities.includes("text")) && (!model.supportedParameters || model.supportedParameters.includes("tools"));
|
|
209
|
+
}
|
|
210
|
+
function harnessEligible(model, harness) {
|
|
211
|
+
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));
|
|
212
|
+
}
|
|
178
213
|
|
|
179
214
|
// src/http.ts
|
|
180
215
|
var MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -233,6 +268,11 @@ var preset = (id, name, protocols, sources, alias) => parse(providerPresetSchema
|
|
|
233
268
|
verification: "documented"
|
|
234
269
|
});
|
|
235
270
|
var providerPresets = [
|
|
271
|
+
...["opencode", "opencode-go"].map((id) => preset(id, id === "opencode" ? "OpenCode Zen" : "OpenCode Go", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, id === "opencode" ? "https://opencode.ai/zen/v1" : "https://opencode.ai/zen/go/v1", {
|
|
272
|
+
authStyle: protocol === "anthropic-messages" ? "x-api-key" : "bearer",
|
|
273
|
+
catalogAuthStyle: "none",
|
|
274
|
+
notes: ["Discovers the full live catalog. Claude requests are adapted to each model's documented native endpoint. Other harnesses require models compatible with their selected protocol. Go requires an active subscription and coding-agent session headers."]
|
|
275
|
+
})), ["https://opencode.ai/docs/zen/", "https://opencode.ai/docs/go/"], "OPENCODE_API_KEY")),
|
|
236
276
|
preset("deepseek", "DeepSeek", [
|
|
237
277
|
route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
|
|
238
278
|
route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
|
|
@@ -298,6 +338,12 @@ var providerPresets = [
|
|
|
298
338
|
preset("siliconflow", "SiliconFlow", [route("openai-chat", "https://api.siliconflow.cn/v1", { catalogBaseUrl: "https://api.siliconflow.cn/v1", catalogFormat: "openai", notes: ["The official SiliconCloud OpenAPI contract defines GET /models with Bearer auth and data[] model rows; optional type and sub_type filters are available at the upstream endpoint."] })], ["https://github.com/siliconflow/siliconcloud/blob/main/openapi.yaml", "https://docs.siliconflow.cn/docs/userguide/quickstart", "https://docs.siliconflow.cn/docs/api/chat-completions-post"], "SILICONFLOW_API_KEY"),
|
|
299
339
|
...["anthropic-messages", "openai-responses", "openai-chat"].map((protocol) => preset(`generic-${protocol}`, `Custom ${protocol}`, [route(protocol)], []))
|
|
300
340
|
];
|
|
341
|
+
function getProviderPreset(id) {
|
|
342
|
+
const entry = providerPresets.find((p) => p.id === id);
|
|
343
|
+
if (!entry)
|
|
344
|
+
throw new Fault(404, "preset_not_found", "Unknown provider preset. Use switcher providers presets to list available presets.");
|
|
345
|
+
return structuredClone(entry);
|
|
346
|
+
}
|
|
301
347
|
// src/desktop-apps.ts
|
|
302
348
|
import { execFile } from "child_process";
|
|
303
349
|
import { access, stat } from "fs/promises";
|
|
@@ -543,9 +589,4796 @@ function clientFromEnv(env = process.env, options = {}) {
|
|
|
543
589
|
return SwitcherClient.fromEnvironment(env, options);
|
|
544
590
|
}
|
|
545
591
|
|
|
592
|
+
// src/store.ts
|
|
593
|
+
var {SQL } = globalThis.Bun;
|
|
594
|
+
import { chmod, mkdir } from "fs/promises";
|
|
595
|
+
import { dirname, resolve } from "path";
|
|
596
|
+
class Store {
|
|
597
|
+
tail = Promise.resolve();
|
|
598
|
+
async exclusive(action) {
|
|
599
|
+
if (this.engine !== "sqlite")
|
|
600
|
+
return action();
|
|
601
|
+
const next = this.tail.then(action, action);
|
|
602
|
+
this.tail = next.catch(() => {});
|
|
603
|
+
return next;
|
|
604
|
+
}
|
|
605
|
+
sql;
|
|
606
|
+
engine;
|
|
607
|
+
constructor(sql, engine) {
|
|
608
|
+
this.sql = sql;
|
|
609
|
+
this.engine = engine;
|
|
610
|
+
}
|
|
611
|
+
static async open(config) {
|
|
612
|
+
if (!!config.databaseUrl === !!config.sqlitePath)
|
|
613
|
+
throw new Fault(500, "storage_config", "Choose exactly one PostgreSQL URL or SQLite path.");
|
|
614
|
+
const engine = config.databaseUrl ? "postgresql" : "sqlite";
|
|
615
|
+
if (config.databaseUrl && !/^postgres(ql)?:\/\//.test(config.databaseUrl))
|
|
616
|
+
throw new Fault(500, "storage_config", "Database URL must use PostgreSQL.");
|
|
617
|
+
const file = config.sqlitePath;
|
|
618
|
+
if (engine === "sqlite" && file !== ":memory:")
|
|
619
|
+
await mkdir(dirname(resolve(file)), { recursive: true, mode: 448 });
|
|
620
|
+
const deadline = Date.now() + 1e4;
|
|
621
|
+
for (let attempt = 0;; attempt++) {
|
|
622
|
+
let sql;
|
|
623
|
+
try {
|
|
624
|
+
sql = engine === "postgresql" ? new SQL(config.databaseUrl) : new SQL({ adapter: "sqlite", filename: file });
|
|
625
|
+
if (engine === "sqlite") {
|
|
626
|
+
await sql.unsafe("PRAGMA busy_timeout = 5000");
|
|
627
|
+
await sql.unsafe("PRAGMA foreign_keys = ON");
|
|
628
|
+
await sql.unsafe("PRAGMA journal_mode = WAL");
|
|
629
|
+
if (file !== ":memory:")
|
|
630
|
+
await chmod(file, 384);
|
|
631
|
+
}
|
|
632
|
+
const store = new Store(sql, engine);
|
|
633
|
+
await store.migrate();
|
|
634
|
+
return store;
|
|
635
|
+
} catch (error) {
|
|
636
|
+
await sql?.close().catch(() => {});
|
|
637
|
+
const code = error?.code;
|
|
638
|
+
if (engine === "sqlite" && ["SQLITE_BUSY", "SQLITE_BUSY_SNAPSHOT", "SQLITE_LOCKED"].includes(code ?? "") && Date.now() < deadline) {
|
|
639
|
+
await new Promise((resolve2) => setTimeout(resolve2, Math.min(200, 20 * (attempt + 1))));
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
throw new Fault(500, "storage_unavailable", "Database startup failed; check configuration, permissions and other database users.");
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
async migrate() {
|
|
647
|
+
await this.sql.begin(async (tx) => {
|
|
648
|
+
if (this.engine === "postgresql")
|
|
649
|
+
await tx.unsafe("SELECT pg_advisory_xact_lock(782034215)");
|
|
650
|
+
await tx.unsafe("CREATE TABLE IF NOT EXISTS switcher_migrations (version INTEGER PRIMARY KEY)");
|
|
651
|
+
const versions = await tx.unsafe("SELECT version FROM switcher_migrations ORDER BY version");
|
|
652
|
+
if (versions.some((v) => v.version > 1))
|
|
653
|
+
throw new Error("Newer database schema");
|
|
654
|
+
if (versions.length)
|
|
655
|
+
return;
|
|
656
|
+
await tx.unsafe("CREATE TABLE switcher_providers (id TEXT PRIMARY KEY, version INTEGER NOT NULL, updated_at TEXT NOT NULL, payload TEXT NOT NULL)");
|
|
657
|
+
await tx.unsafe("CREATE TABLE switcher_profiles (id TEXT PRIMARY KEY, provider_id TEXT NOT NULL REFERENCES switcher_providers(id), version INTEGER NOT NULL, updated_at TEXT NOT NULL, payload TEXT NOT NULL)");
|
|
658
|
+
await tx.unsafe("CREATE TABLE switcher_catalogs (id TEXT PRIMARY KEY REFERENCES switcher_providers(id) ON DELETE CASCADE, version INTEGER NOT NULL, updated_at TEXT NOT NULL, payload TEXT NOT NULL)");
|
|
659
|
+
await tx.unsafe("CREATE TABLE switcher_runs (id TEXT PRIMARY KEY, profile_id TEXT NOT NULL REFERENCES switcher_profiles(id), version INTEGER NOT NULL, updated_at TEXT NOT NULL, payload TEXT NOT NULL)");
|
|
660
|
+
await tx.unsafe("CREATE TABLE switcher_idempotency (key TEXT PRIMARY KEY, fingerprint TEXT NOT NULL, payload TEXT NOT NULL, created_at TEXT NOT NULL)");
|
|
661
|
+
await tx.unsafe("INSERT INTO switcher_migrations(version) VALUES (1)");
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
async ready() {
|
|
665
|
+
await this.exclusive(async () => {
|
|
666
|
+
await this.sql.unsafe("SELECT 1");
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
async close() {
|
|
670
|
+
await this.tail;
|
|
671
|
+
await this.sql.close();
|
|
672
|
+
}
|
|
673
|
+
async get(kind, id, db = this.sql) {
|
|
674
|
+
if (db === this.sql && this.engine === "sqlite")
|
|
675
|
+
return this.exclusive(() => this.read(kind, id, db));
|
|
676
|
+
return this.read(kind, id, db);
|
|
677
|
+
}
|
|
678
|
+
async read(kind, id, db) {
|
|
679
|
+
const rows = await db.unsafe(`SELECT payload FROM switcher_${kind} WHERE id = $1`, [id]);
|
|
680
|
+
if (!rows.length)
|
|
681
|
+
throw new Fault(404, "not_found", `${kind} entry was not found.`);
|
|
682
|
+
return JSON.parse(rows[0].payload);
|
|
683
|
+
}
|
|
684
|
+
async list(kind, { limit = 100, offset = 0, search = "" } = {}) {
|
|
685
|
+
return this.exclusive(async () => {
|
|
686
|
+
const name = this.engine === "sqlite" ? "json_extract(payload, '$.name')" : "payload::jsonb->>'name'";
|
|
687
|
+
const pattern = `%${search.toLowerCase().replace(/[!%_]/g, (c) => "!" + c)}%`;
|
|
688
|
+
const where = `LOWER(id) LIKE $1 ESCAPE '!' OR LOWER(COALESCE(${name}, '')) LIKE $1 ESCAPE '!'`;
|
|
689
|
+
const total = await this.sql.unsafe(`SELECT COUNT(*) AS total FROM switcher_${kind} WHERE ${where}`, [pattern]);
|
|
690
|
+
const rows = await this.sql.unsafe(`SELECT payload FROM switcher_${kind} WHERE ${where} ORDER BY id LIMIT $2 OFFSET $3`, [pattern, limit, offset]);
|
|
691
|
+
return { data: rows.map((r) => JSON.parse(r.payload)), total: Number(total[0].total), limit, offset };
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
async put(kind, input, expectedVersion, db) {
|
|
695
|
+
const now = new Date().toISOString();
|
|
696
|
+
const value = { ...input, version: expectedVersion === undefined ? 1 : expectedVersion + 1, updatedAt: now };
|
|
697
|
+
if (expectedVersion === undefined) {
|
|
698
|
+
const extraColumn = kind === "profiles" ? ", provider_id" : kind === "runs" ? ", profile_id" : "";
|
|
699
|
+
const extraValue = kind === "profiles" ? input.providerId : kind === "runs" ? input.profileId : undefined;
|
|
700
|
+
await db.unsafe(`INSERT INTO switcher_${kind} (id, version, updated_at, payload${extraColumn}) VALUES ($1, $2, $3, $4${extraColumn ? ", $5" : ""})`, [input.id, value.version, now, JSON.stringify(value), ...extraColumn ? [extraValue] : []]);
|
|
701
|
+
} else {
|
|
702
|
+
const extra = kind === "profiles" ? ", provider_id = $4" : "";
|
|
703
|
+
const rows = await db.unsafe(`UPDATE switcher_${kind} SET version = $1, updated_at = $2, payload = $3${extra} WHERE id = $${extra ? 5 : 4} AND version = $${extra ? 6 : 5} RETURNING id`, [value.version, now, JSON.stringify(value), ...extra ? [input.providerId] : [], input.id, expectedVersion]);
|
|
704
|
+
if (!rows.length)
|
|
705
|
+
throw new Fault(409, "version_conflict", "Entry changed or is missing; reload before retrying.");
|
|
706
|
+
}
|
|
707
|
+
return value;
|
|
708
|
+
}
|
|
709
|
+
async remove(kind, id, version, db) {
|
|
710
|
+
const rows = await db.unsafe(`DELETE FROM switcher_${kind} WHERE id = $1 AND version = $2 RETURNING id`, [id, version]);
|
|
711
|
+
if (!rows.length)
|
|
712
|
+
throw new Fault(409, "version_conflict", "Entry changed or is missing; reload before retrying.");
|
|
713
|
+
return { deleted: id };
|
|
714
|
+
}
|
|
715
|
+
async mutate(key, fingerprint, action) {
|
|
716
|
+
return this.exclusive(() => this.transaction(key, fingerprint, action));
|
|
717
|
+
}
|
|
718
|
+
async replay(key, fingerprint) {
|
|
719
|
+
return this.exclusive(async () => {
|
|
720
|
+
const rows = await this.sql.unsafe("SELECT fingerprint, payload FROM switcher_idempotency WHERE key = $1", [key]);
|
|
721
|
+
if (!rows.length)
|
|
722
|
+
return { found: false };
|
|
723
|
+
if (rows[0].fingerprint !== fingerprint)
|
|
724
|
+
throw new Fault(409, "idempotency_conflict", "Idempotency key was already used for a different request.");
|
|
725
|
+
return { found: true, value: JSON.parse(rows[0].payload) };
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
async transaction(key, fingerprint, action) {
|
|
729
|
+
try {
|
|
730
|
+
return await this.sql.begin(async (tx) => {
|
|
731
|
+
const inserted = await tx.unsafe("INSERT INTO switcher_idempotency (key, fingerprint, payload, created_at) VALUES ($1, $2, '', $3) ON CONFLICT (key) DO NOTHING RETURNING key", [key, fingerprint, new Date().toISOString()]);
|
|
732
|
+
if (!inserted.length) {
|
|
733
|
+
const rows = await tx.unsafe("SELECT fingerprint, payload FROM switcher_idempotency WHERE key = $1", [key]);
|
|
734
|
+
if (rows[0].fingerprint !== fingerprint)
|
|
735
|
+
throw new Fault(409, "idempotency_conflict", "Idempotency key was already used for a different request.");
|
|
736
|
+
return JSON.parse(rows[0].payload);
|
|
737
|
+
}
|
|
738
|
+
const value = await action(tx);
|
|
739
|
+
await tx.unsafe("UPDATE switcher_idempotency SET payload = $1 WHERE key = $2", [JSON.stringify(value), key]);
|
|
740
|
+
return value;
|
|
741
|
+
});
|
|
742
|
+
} catch (error) {
|
|
743
|
+
if (error instanceof Fault)
|
|
744
|
+
throw error;
|
|
745
|
+
const code = String(this.engine === "postgresql" ? error?.errno : error?.code);
|
|
746
|
+
if (["23505", "23503", "SQLITE_CONSTRAINT", "SQLITE_CONSTRAINT_PRIMARYKEY", "SQLITE_CONSTRAINT_FOREIGNKEY"].includes(code))
|
|
747
|
+
throw new Fault(409, "conflict", "Duplicate entry or an entry still referenced by another resource.");
|
|
748
|
+
throw new Fault(503, "storage_unavailable", "Storage operation failed.");
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/service.ts
|
|
754
|
+
import { createHash as createHash2, timingSafeEqual } from "crypto";
|
|
755
|
+
import { z as z4 } from "zod";
|
|
756
|
+
|
|
757
|
+
// src/auth.ts
|
|
758
|
+
function authHeader(style, credential) {
|
|
759
|
+
if (/[^\x20-\x7e]/.test(credential))
|
|
760
|
+
throw new Error("Provider credential contains invalid header characters.");
|
|
761
|
+
return style === "bearer" ? ["authorization", `Bearer ${credential}`] : [style, credential];
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// src/catalog.ts
|
|
765
|
+
var positive = (v) => typeof v === "number" && Number.isInteger(v) && v > 0 ? v : undefined;
|
|
766
|
+
var strings = (v) => Array.isArray(v) && v.every((i) => typeof i === "string") ? v : undefined;
|
|
767
|
+
var modalities = (v) => {
|
|
768
|
+
if (v === undefined)
|
|
769
|
+
return;
|
|
770
|
+
if (!Array.isArray(v) || !v.every((i) => typeof i === "string"))
|
|
771
|
+
throw new Fault(502, "invalid_catalog", "Provider returned malformed modality metadata.");
|
|
772
|
+
return v.map((i) => i.toLowerCase());
|
|
773
|
+
};
|
|
774
|
+
var CATALOG_REQUEST_TIMEOUT_MS = 20000;
|
|
775
|
+
var CATALOG_REFRESH_DEADLINE_MS = 60000;
|
|
776
|
+
var CATALOG_MAX_RETRIES = 2;
|
|
777
|
+
var TRANSIENT_CATALOG_STATUSES = new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
778
|
+
function retryAfterMs(value) {
|
|
779
|
+
if (!value)
|
|
780
|
+
return;
|
|
781
|
+
const trimmed = value.trim();
|
|
782
|
+
if (/^\d+$/.test(trimmed)) {
|
|
783
|
+
try {
|
|
784
|
+
const milliseconds = BigInt(trimmed) * 1000n;
|
|
785
|
+
if (milliseconds > BigInt(Number.MAX_SAFE_INTEGER))
|
|
786
|
+
return Number.POSITIVE_INFINITY;
|
|
787
|
+
return Number(milliseconds);
|
|
788
|
+
} catch {
|
|
789
|
+
return Number.POSITIVE_INFINITY;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
const date = Date.parse(trimmed);
|
|
793
|
+
return Number.isNaN(date) ? undefined : Math.max(0, date - Date.now());
|
|
794
|
+
}
|
|
795
|
+
function catalogDeadlineFault() {
|
|
796
|
+
return new Fault(502, "provider_unavailable", "Provider catalog refresh exceeded its bounded deadline.");
|
|
797
|
+
}
|
|
798
|
+
async function waitForCatalogRetry(delayMs, deadline) {
|
|
799
|
+
if (Date.now() + delayMs > deadline)
|
|
800
|
+
throw catalogDeadlineFault();
|
|
801
|
+
if (delayMs > 0)
|
|
802
|
+
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
803
|
+
}
|
|
804
|
+
async function fetchCatalogPage(url, headers, deadline) {
|
|
805
|
+
for (let retry = 0;; retry++) {
|
|
806
|
+
const remaining = deadline - Date.now();
|
|
807
|
+
if (remaining <= 0)
|
|
808
|
+
throw catalogDeadlineFault();
|
|
809
|
+
let response;
|
|
810
|
+
try {
|
|
811
|
+
response = await fetch(url, {
|
|
812
|
+
headers,
|
|
813
|
+
redirect: "manual",
|
|
814
|
+
signal: AbortSignal.timeout(Math.max(1, Math.min(CATALOG_REQUEST_TIMEOUT_MS, remaining)))
|
|
815
|
+
});
|
|
816
|
+
} catch {
|
|
817
|
+
if (retry >= CATALOG_MAX_RETRIES)
|
|
818
|
+
throw new Fault(502, "provider_unavailable", "Provider catalog request failed.");
|
|
819
|
+
await waitForCatalogRetry(100 * 2 ** retry, deadline);
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
if (response.ok)
|
|
823
|
+
return response;
|
|
824
|
+
const retryable = TRANSIENT_CATALOG_STATUSES.has(response.status);
|
|
825
|
+
await response.body?.cancel().catch(() => {});
|
|
826
|
+
if (!retryable || retry >= CATALOG_MAX_RETRIES)
|
|
827
|
+
throw new Fault(502, "provider_rejected", `Provider catalog returned HTTP ${response.status}.`);
|
|
828
|
+
const delay = retryAfterMs(response.headers.get("retry-after"));
|
|
829
|
+
await waitForCatalogRetry(delay ?? 100 * 2 ** retry, deadline);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
async function discoverBase(provider, env = process.env, resolveCredential) {
|
|
833
|
+
const refreshedAt = new Date().toISOString();
|
|
834
|
+
if (provider.manualModels.length)
|
|
835
|
+
return { models: provider.manualModels, source: "manual", refreshedAt };
|
|
836
|
+
if (provider.catalogFormat === "none")
|
|
837
|
+
throw new Fault(422, "catalog_unsupported", "This provider has no documented model-list contract; configure manual models or an explicit catalog URL and parser.");
|
|
838
|
+
const headers = { accept: "application/json", "user-agent": `hasna-switcher/${VERSION}` };
|
|
839
|
+
if (provider.catalogFormat === "fireworks" && !provider.catalogBaseUrl && !provider.catalogAccountId)
|
|
840
|
+
throw new Fault(422, "catalog_account_required", "Fireworks model discovery requires a catalog account ID or an explicit catalog URL.");
|
|
841
|
+
if (provider.catalogFormat === "fireworks" && !provider.catalogBaseUrl && new URL(provider.baseUrl).origin !== "https://api.fireworks.ai")
|
|
842
|
+
throw new Fault(422, "catalog_url_required", "A custom Fireworks inference authority requires an explicit catalog URL; its deployment prefix cannot be inferred.");
|
|
843
|
+
const catalogRoot = provider.catalogBaseUrl ?? (provider.catalogFormat === "fireworks" ? `https://api.fireworks.ai/v1/accounts/${encodeURIComponent(provider.catalogAccountId)}` : provider.baseUrl);
|
|
844
|
+
const url = new URL(`${catalogRoot}/${provider.modelsPath}`);
|
|
845
|
+
if (provider.catalogFormat === "fireworks")
|
|
846
|
+
url.searchParams.set("pageSize", "200");
|
|
847
|
+
const authStyle = provider.catalogAuthStyle ?? provider.authStyle;
|
|
848
|
+
const credentialEnv = provider.catalogCredentialEnv ?? provider.credentialEnv;
|
|
849
|
+
if (authStyle !== "none" && credentialEnv) {
|
|
850
|
+
if (url.origin !== new URL(provider.baseUrl).origin && !provider.catalogCredentialEnv)
|
|
851
|
+
throw new Fault(422, "catalog_credential_authority", "A different catalog origin requires an explicit catalog credential reference or catalogAuthStyle: none.");
|
|
852
|
+
const credential = resolveCredential ? await resolveCredential({ ...provider, baseUrl: provider.catalogBaseUrl ?? provider.baseUrl, credentialEnv }) : env[credentialEnv];
|
|
853
|
+
if (!credential)
|
|
854
|
+
throw new Fault(422, "credential_missing", "Provider credential environment variable is not available on the server.");
|
|
855
|
+
if (/[\r\n]/.test(credential))
|
|
856
|
+
throw new Fault(422, "credential_invalid", "Catalog credential contains invalid header characters.");
|
|
857
|
+
const [header, value] = authHeader(authStyle, credential);
|
|
858
|
+
headers[provider.catalogFormat === "gemini" && header === "x-api-key" ? "x-goog-api-key" : header] = value;
|
|
859
|
+
}
|
|
860
|
+
if (provider.protocol === "anthropic-messages" && url.hostname !== "openrouter.ai")
|
|
861
|
+
headers["anthropic-version"] = "2023-06-01";
|
|
862
|
+
if (url.hostname === "openrouter.ai")
|
|
863
|
+
url.searchParams.set("output_modalities", "all");
|
|
864
|
+
const models = new Map;
|
|
865
|
+
const seenCursors = new Set;
|
|
866
|
+
const seenPages = new Set([url.href]);
|
|
867
|
+
const deadline = Date.now() + CATALOG_REFRESH_DEADLINE_MS;
|
|
868
|
+
let fireworksTotal;
|
|
869
|
+
for (let page = 0;page < 100; page++) {
|
|
870
|
+
const response = await fetchCatalogPage(url, headers, deadline);
|
|
871
|
+
const data = await boundedJson(response);
|
|
872
|
+
if (provider.catalogFormat === "fireworks" && data?.totalSize !== undefined) {
|
|
873
|
+
if (typeof data.totalSize !== "number" || !Number.isInteger(data.totalSize) || data.totalSize < 0)
|
|
874
|
+
throw new Fault(502, "invalid_catalog", "Fireworks catalog count metadata is malformed.");
|
|
875
|
+
if (fireworksTotal !== undefined && fireworksTotal !== data.totalSize)
|
|
876
|
+
throw new Fault(502, "incomplete_catalog", "Provider catalog count changed during pagination; retry the refresh.");
|
|
877
|
+
fireworksTotal = data.totalSize;
|
|
878
|
+
}
|
|
879
|
+
const rows = provider.catalogFormat === "together" ? data : provider.catalogFormat === "ollama" ? data?.models : provider.catalogFormat === "fireworks" || provider.catalogFormat === "gemini" ? data?.models : provider.catalogFormat === "dashscope" ? data?.output?.models : data?.data;
|
|
880
|
+
if (!Array.isArray(rows))
|
|
881
|
+
throw new Fault(502, "invalid_catalog", "Expected a provider catalog with a model array matching its configured format.");
|
|
882
|
+
for (const row of rows) {
|
|
883
|
+
const id = provider.catalogFormat === "ollama" ? row?.model ?? row?.name : provider.catalogFormat === "fireworks" ? row?.name : provider.catalogFormat === "gemini" ? typeof row?.name === "string" ? row.name.replace(/^models\//, "") : undefined : provider.catalogFormat === "dashscope" ? row?.model : row?.id;
|
|
884
|
+
if (typeof id !== "string")
|
|
885
|
+
throw new Fault(502, "invalid_catalog", "Catalog entry is missing a model ID.");
|
|
886
|
+
const candidate = {
|
|
887
|
+
id,
|
|
888
|
+
name: row.displayName ?? row.name ?? row.display_name ?? id,
|
|
889
|
+
available: provider.catalogFormat === "mistral" && typeof row.archived === "boolean" ? !row.archived : undefined,
|
|
890
|
+
expiresOn: row.expiresOn ?? row.expires_on,
|
|
891
|
+
description: typeof row.description === "string" ? row.description.slice(0, 8000) : undefined,
|
|
892
|
+
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)),
|
|
893
|
+
maxOutputTokens: positive(row.top_provider?.max_completion_tokens ?? row.max_output_tokens ?? row.outputTokenLimit ?? row.model_info?.max_output_tokens),
|
|
894
|
+
inputModalities: strings(row.architecture?.input_modalities ?? row.input_modalities) ?? modalities(row.inference_metadata?.request_modality),
|
|
895
|
+
outputModalities: strings(row.architecture?.output_modalities ?? row.output_modalities) ?? modalities(row.inference_metadata?.response_modality),
|
|
896
|
+
supportedParameters: strings(row.supported_parameters),
|
|
897
|
+
reasoningEfforts: row.reasoning?.supported_efforts,
|
|
898
|
+
...provider.catalogFormat === "gemini" && row.supportedGenerationMethods !== undefined ? { supportedGenerationMethods: row.supportedGenerationMethods } : {}
|
|
899
|
+
};
|
|
900
|
+
if (provider.catalogFormat === "mistral") {
|
|
901
|
+
const capabilities = row.capabilities;
|
|
902
|
+
if (typeof capabilities?.function_calling === "boolean")
|
|
903
|
+
candidate.supportedParameters = capabilities.function_calling ? ["tools"] : [];
|
|
904
|
+
if (typeof capabilities?.vision === "boolean")
|
|
905
|
+
candidate.inputModalities = capabilities.vision ? ["text", "image"] : ["text"];
|
|
906
|
+
if (typeof capabilities?.completion_chat === "boolean")
|
|
907
|
+
candidate.outputModalities = capabilities.completion_chat ? ["text"] : [];
|
|
908
|
+
}
|
|
909
|
+
if (provider.catalogFormat === "together") {
|
|
910
|
+
const modalities2 = { chat: ["text"], language: ["text"], code: ["text"], image: ["image"], audio: ["audio"], video: ["video"], embedding: ["embedding"], rerank: ["rerank"], moderation: ["classification"] };
|
|
911
|
+
candidate.outputModalities = modalities2[row.type];
|
|
912
|
+
}
|
|
913
|
+
if (provider.catalogFormat === "fireworks") {
|
|
914
|
+
if (row.supportsImageInput === true)
|
|
915
|
+
candidate.inputModalities = ["text", "image"];
|
|
916
|
+
if (typeof row.supportsTools === "boolean")
|
|
917
|
+
candidate.supportedParameters = row.supportsTools ? ["tools"] : [];
|
|
918
|
+
}
|
|
919
|
+
if (provider.catalogFormat === "dashscope") {
|
|
920
|
+
if (row.features !== undefined && !Array.isArray(row.features))
|
|
921
|
+
throw new Fault(502, "invalid_catalog", "DashScope model features metadata is malformed.");
|
|
922
|
+
if (Array.isArray(row.features))
|
|
923
|
+
candidate.supportedParameters = row.features.includes("function-calling") ? ["tools"] : [];
|
|
924
|
+
}
|
|
925
|
+
const parsed = modelSchema.safeParse(candidate);
|
|
926
|
+
if (!parsed.success)
|
|
927
|
+
throw new Fault(502, "invalid_catalog", "Provider returned malformed model metadata.");
|
|
928
|
+
models.set(candidate.id, parsed.data);
|
|
929
|
+
if (models.size > 1e4)
|
|
930
|
+
throw new Fault(502, "catalog_too_large", "Catalog exceeds 10,000 models; configure a narrower endpoint.");
|
|
931
|
+
}
|
|
932
|
+
const next = data.links?.next;
|
|
933
|
+
if (next !== undefined && next !== null) {
|
|
934
|
+
if (typeof next !== "string" || !next || next.length > 2000)
|
|
935
|
+
throw new Fault(502, "invalid_catalog", "Provider returned an invalid catalog continuation link.");
|
|
936
|
+
let target;
|
|
937
|
+
try {
|
|
938
|
+
target = new URL(next, url);
|
|
939
|
+
} catch {
|
|
940
|
+
throw new Fault(502, "invalid_catalog", "Provider returned an invalid catalog continuation link.");
|
|
941
|
+
}
|
|
942
|
+
if (target.origin !== url.origin || target.pathname !== url.pathname || target.username || target.password || target.hash)
|
|
943
|
+
throw new Fault(502, "catalog_credential_authority", "Catalog pagination must stay on its original origin and path.");
|
|
944
|
+
if (url.searchParams.has("output_modalities"))
|
|
945
|
+
target.searchParams.set("output_modalities", url.searchParams.get("output_modalities"));
|
|
946
|
+
if (seenPages.has(target.href))
|
|
947
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
948
|
+
seenPages.add(target.href);
|
|
949
|
+
url.href = target.href;
|
|
950
|
+
continue;
|
|
951
|
+
}
|
|
952
|
+
if (provider.catalogFormat === "fireworks" && data.nextPageToken !== undefined && data.nextPageToken !== null) {
|
|
953
|
+
if (typeof data.nextPageToken !== "string" || data.nextPageToken.length > 2000)
|
|
954
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
955
|
+
if (data.nextPageToken) {
|
|
956
|
+
if (seenCursors.has(data.nextPageToken))
|
|
957
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
958
|
+
seenCursors.add(data.nextPageToken);
|
|
959
|
+
url.searchParams.set("pageToken", data.nextPageToken);
|
|
960
|
+
url.searchParams.set("pageSize", "200");
|
|
961
|
+
continue;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (provider.catalogFormat === "fireworks") {
|
|
965
|
+
if (fireworksTotal !== undefined && fireworksTotal !== models.size)
|
|
966
|
+
throw new Fault(502, "incomplete_catalog", "Provider catalog count does not match the collected models; retry the refresh.");
|
|
967
|
+
return { models: [...models.values()], source: "remote", refreshedAt };
|
|
968
|
+
}
|
|
969
|
+
if (provider.catalogFormat === "gemini") {
|
|
970
|
+
const nextPageToken = data.nextPageToken;
|
|
971
|
+
if (nextPageToken !== undefined && nextPageToken !== null) {
|
|
972
|
+
if (typeof nextPageToken !== "string" || nextPageToken.length > 2000)
|
|
973
|
+
throw new Fault(502, "invalid_catalog", "Gemini catalog pagination token is malformed.");
|
|
974
|
+
if (nextPageToken) {
|
|
975
|
+
if (seenCursors.has(nextPageToken))
|
|
976
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
977
|
+
seenCursors.add(nextPageToken);
|
|
978
|
+
url.searchParams.set("pageToken", nextPageToken);
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return { models: [...models.values()], source: "remote", refreshedAt };
|
|
983
|
+
}
|
|
984
|
+
if (provider.catalogFormat === "dashscope") {
|
|
985
|
+
const output = data.output;
|
|
986
|
+
const total = output?.total;
|
|
987
|
+
const pageNo = output?.page_no;
|
|
988
|
+
const pageSize = output?.page_size;
|
|
989
|
+
if (typeof total !== "number" || !Number.isInteger(total) || total < 0 || typeof pageNo !== "number" || !Number.isInteger(pageNo) || pageNo < 1 || typeof pageSize !== "number" || !Number.isInteger(pageSize) || pageSize < 1)
|
|
990
|
+
throw new Fault(502, "invalid_catalog", "DashScope catalog pagination metadata is malformed.");
|
|
991
|
+
if (models.size < total && pageNo * pageSize < total) {
|
|
992
|
+
const nextPage = pageNo + 1;
|
|
993
|
+
if (seenCursors.has(String(nextPage)))
|
|
994
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
995
|
+
seenCursors.add(String(nextPage));
|
|
996
|
+
url.searchParams.set("page_no", String(nextPage));
|
|
997
|
+
url.searchParams.set("page_size", String(pageSize));
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
1000
|
+
if (models.size !== total)
|
|
1001
|
+
throw new Fault(502, "incomplete_catalog", "Provider catalog count does not match the collected models; retry the refresh.");
|
|
1002
|
+
return { models: [...models.values()], source: "remote", refreshedAt };
|
|
1003
|
+
}
|
|
1004
|
+
if (provider.catalogFormat === "together" || !data.has_more) {
|
|
1005
|
+
if (typeof data.total_count === "number" && data.total_count !== models.size)
|
|
1006
|
+
throw new Fault(502, "incomplete_catalog", "Provider catalog count does not match the collected models; retry the refresh.");
|
|
1007
|
+
return { models: [...models.values()], source: "remote", refreshedAt };
|
|
1008
|
+
}
|
|
1009
|
+
const cursor = data.last_id;
|
|
1010
|
+
if (typeof cursor !== "string" || seenCursors.has(cursor))
|
|
1011
|
+
throw new Fault(502, "invalid_catalog", "Provider catalog pagination did not advance.");
|
|
1012
|
+
seenCursors.add(cursor);
|
|
1013
|
+
url.searchParams.set("after_id", cursor);
|
|
1014
|
+
url.searchParams.set("limit", "1000");
|
|
1015
|
+
}
|
|
1016
|
+
throw new Fault(502, "catalog_too_large", "Provider catalog pagination exceeded 100 pages.");
|
|
1017
|
+
}
|
|
1018
|
+
async function discover(provider, env = process.env, resolveCredential) {
|
|
1019
|
+
const catalog = await discoverBase(provider, env, resolveCredential);
|
|
1020
|
+
const models = new Map(catalog.models.map((model) => [model.id, model]));
|
|
1021
|
+
for (const additional of provider.additionalModels ?? [])
|
|
1022
|
+
models.set(additional.id, { ...models.get(additional.id), ...additional });
|
|
1023
|
+
if (models.size > 1e4)
|
|
1024
|
+
throw new Fault(502, "catalog_too_large", "Combined catalog exceeds 10,000 models.");
|
|
1025
|
+
return { ...catalog, models: [...models.values()] };
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/model-policy.ts
|
|
1029
|
+
import { createHash } from "crypto";
|
|
1030
|
+
var roles = ["subagent", "fast", "planning", "review", "summary", "compaction", "weak", "editor"];
|
|
1031
|
+
var id = (v, label2) => {
|
|
1032
|
+
if (typeof v !== "string" || !v || v.length > 300 || /[\u0000-\u001f\u007f]/.test(v))
|
|
1033
|
+
throw new Fault(400, "invalid_model_policy", `${label2} is invalid.`);
|
|
1034
|
+
return v;
|
|
1035
|
+
};
|
|
1036
|
+
var uniq = (xs) => [...new Set(xs)];
|
|
1037
|
+
function stable(value) {
|
|
1038
|
+
return JSON.stringify(value, (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b))) : v);
|
|
1039
|
+
}
|
|
1040
|
+
function compileModelPolicy(model, catalog, policy) {
|
|
1041
|
+
const selected = id(model, "model");
|
|
1042
|
+
const available = new Set(catalog.filter((m) => m.available !== false && !modelExpired(m)).map((m) => m.id));
|
|
1043
|
+
const expired = new Set(catalog.filter((m) => modelExpired(m)).map((m) => m.id));
|
|
1044
|
+
const requireAvailable = (value, message) => {
|
|
1045
|
+
if (expired.has(value))
|
|
1046
|
+
throw new Fault(422, "model_expired", "A selected model has passed its configured expiry date. Select an unexpired model.");
|
|
1047
|
+
if (!available.has(value))
|
|
1048
|
+
throw new Fault(422, "model_unavailable", message);
|
|
1049
|
+
};
|
|
1050
|
+
requireAvailable(selected, "Selected model is not present in the eligible catalog.");
|
|
1051
|
+
if (policy && policy.version !== undefined && policy.version !== 1)
|
|
1052
|
+
throw new Fault(400, "invalid_model_policy", "Unsupported model policy version.");
|
|
1053
|
+
const p = parse(modelPolicySchema, policy ?? {});
|
|
1054
|
+
const roleInput = p.roles ?? {};
|
|
1055
|
+
if (Object.keys(roleInput).some((k) => !roles.includes(k)))
|
|
1056
|
+
throw new Fault(400, "invalid_model_policy", "Unknown model policy role.");
|
|
1057
|
+
const compiledRoles = Object.fromEntries(roles.map((role) => [role, id(roleInput[role] ?? selected, `roles.${role}`)]));
|
|
1058
|
+
for (const value of Object.values(compiledRoles))
|
|
1059
|
+
requireAvailable(value, "A model policy role is not present in the eligible catalog.");
|
|
1060
|
+
const explicitAllowed = (p.allowedModels ?? []).map((v, i) => id(v, `allowedModels[${i}]`));
|
|
1061
|
+
if (explicitAllowed.length > 500)
|
|
1062
|
+
throw new Fault(400, "invalid_model_policy", "Model policy allowedModels is too large.");
|
|
1063
|
+
for (const value of explicitAllowed)
|
|
1064
|
+
requireAvailable(value, "An allowed model is not present in the eligible catalog.");
|
|
1065
|
+
const aliases = Object.create(null);
|
|
1066
|
+
for (const [name, target] of Object.entries(p.aliases ?? {})) {
|
|
1067
|
+
if (Object.keys(aliases).length >= 200 || !/^[A-Za-z0-9._/-]{1,120}$/.test(name) || ["__proto__", "prototype", "constructor"].includes(name))
|
|
1068
|
+
throw new Fault(400, "invalid_model_policy", "A model alias is invalid or too numerous.");
|
|
1069
|
+
const canonical = id(target, `aliases.${name}`);
|
|
1070
|
+
if (available.has(name) && name !== canonical)
|
|
1071
|
+
throw new Fault(400, "invalid_model_policy", "A model alias cannot shadow a real model ID.");
|
|
1072
|
+
requireAvailable(canonical, "A model alias target is not present in the eligible catalog.");
|
|
1073
|
+
aliases[name] = canonical;
|
|
1074
|
+
}
|
|
1075
|
+
const fallbacks = Object.create(null);
|
|
1076
|
+
const allowedSources = new Set([selected, ...Object.values(compiledRoles), ...explicitAllowed]);
|
|
1077
|
+
for (const [source, targets] of Object.entries(p.fallbacks ?? {})) {
|
|
1078
|
+
if (!allowedSources.has(source) || !available.has(source) || !Array.isArray(targets) || Object.keys(fallbacks).length >= 200 || targets.length > 20)
|
|
1079
|
+
throw new Fault(400, "invalid_model_policy", "Fallback source or list is invalid.");
|
|
1080
|
+
const values = targets.map((v, i) => id(v, `fallbacks.${source}[${i}]`));
|
|
1081
|
+
for (const value of values)
|
|
1082
|
+
requireAvailable(value, "A fallback model is not present in the eligible catalog.");
|
|
1083
|
+
if (values.includes(source))
|
|
1084
|
+
throw new Fault(400, "invalid_model_policy", "A model cannot fall back to itself.");
|
|
1085
|
+
fallbacks[source] = uniq(values);
|
|
1086
|
+
}
|
|
1087
|
+
const allowedModels = uniq([selected, ...Object.values(compiledRoles), ...explicitAllowed, ...Object.values(fallbacks).flat()]).sort();
|
|
1088
|
+
if (Object.values(aliases).some((value) => !allowedModels.includes(value)))
|
|
1089
|
+
throw new Fault(422, "model_not_allowed", "A model alias target must be explicitly allowed by the launch policy.");
|
|
1090
|
+
const result = { version: 1, model: selected, roles: compiledRoles, allowedModels, aliases, fallbacks };
|
|
1091
|
+
return { ...result, digest: createHash("sha256").update(stable(result)).digest("hex") };
|
|
1092
|
+
}
|
|
1093
|
+
// openapi.json
|
|
1094
|
+
var openapi_default = {
|
|
1095
|
+
openapi: "3.0.3",
|
|
1096
|
+
info: {
|
|
1097
|
+
title: "Switcher API",
|
|
1098
|
+
version: "0.2.1",
|
|
1099
|
+
description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
|
|
1100
|
+
},
|
|
1101
|
+
security: [
|
|
1102
|
+
{
|
|
1103
|
+
bearerAuth: []
|
|
1104
|
+
}
|
|
1105
|
+
],
|
|
1106
|
+
paths: {
|
|
1107
|
+
"/v1/providers": {
|
|
1108
|
+
get: {
|
|
1109
|
+
operationId: "listProviders",
|
|
1110
|
+
parameters: [
|
|
1111
|
+
{
|
|
1112
|
+
name: "limit",
|
|
1113
|
+
in: "query",
|
|
1114
|
+
schema: {
|
|
1115
|
+
type: "integer",
|
|
1116
|
+
minimum: 1,
|
|
1117
|
+
maximum: 1000,
|
|
1118
|
+
default: 100
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
name: "offset",
|
|
1123
|
+
in: "query",
|
|
1124
|
+
schema: {
|
|
1125
|
+
type: "integer",
|
|
1126
|
+
minimum: 0,
|
|
1127
|
+
default: 0
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "search",
|
|
1132
|
+
in: "query",
|
|
1133
|
+
schema: {
|
|
1134
|
+
type: "string"
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
],
|
|
1138
|
+
responses: {
|
|
1139
|
+
"200": {
|
|
1140
|
+
description: "Success",
|
|
1141
|
+
content: {
|
|
1142
|
+
"application/json": {
|
|
1143
|
+
schema: {
|
|
1144
|
+
type: "object",
|
|
1145
|
+
required: [
|
|
1146
|
+
"data",
|
|
1147
|
+
"total",
|
|
1148
|
+
"limit",
|
|
1149
|
+
"offset"
|
|
1150
|
+
],
|
|
1151
|
+
properties: {
|
|
1152
|
+
data: {
|
|
1153
|
+
type: "array",
|
|
1154
|
+
items: {
|
|
1155
|
+
$ref: "#/components/schemas/Provider"
|
|
1156
|
+
}
|
|
1157
|
+
},
|
|
1158
|
+
total: {
|
|
1159
|
+
type: "integer"
|
|
1160
|
+
},
|
|
1161
|
+
limit: {
|
|
1162
|
+
type: "integer"
|
|
1163
|
+
},
|
|
1164
|
+
offset: {
|
|
1165
|
+
type: "integer"
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1172
|
+
default: {
|
|
1173
|
+
description: "Structured error",
|
|
1174
|
+
content: {
|
|
1175
|
+
"application/json": {
|
|
1176
|
+
schema: {
|
|
1177
|
+
$ref: "#/components/schemas/Error"
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
post: {
|
|
1185
|
+
operationId: "createProvider",
|
|
1186
|
+
parameters: [
|
|
1187
|
+
{
|
|
1188
|
+
name: "Idempotency-Key",
|
|
1189
|
+
in: "header",
|
|
1190
|
+
required: true,
|
|
1191
|
+
schema: {
|
|
1192
|
+
type: "string",
|
|
1193
|
+
minLength: 8,
|
|
1194
|
+
maxLength: 128
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
],
|
|
1198
|
+
requestBody: {
|
|
1199
|
+
required: true,
|
|
1200
|
+
content: {
|
|
1201
|
+
"application/json": {
|
|
1202
|
+
schema: {
|
|
1203
|
+
$ref: "#/components/schemas/ProviderInput"
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
responses: {
|
|
1209
|
+
"201": {
|
|
1210
|
+
description: "Success",
|
|
1211
|
+
content: {
|
|
1212
|
+
"application/json": {
|
|
1213
|
+
schema: {
|
|
1214
|
+
$ref: "#/components/schemas/Provider"
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
default: {
|
|
1220
|
+
description: "Structured error",
|
|
1221
|
+
content: {
|
|
1222
|
+
"application/json": {
|
|
1223
|
+
schema: {
|
|
1224
|
+
$ref: "#/components/schemas/Error"
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
"/v1/providers/{id}": {
|
|
1233
|
+
get: {
|
|
1234
|
+
operationId: "getProvider",
|
|
1235
|
+
parameters: [
|
|
1236
|
+
{
|
|
1237
|
+
name: "id",
|
|
1238
|
+
in: "path",
|
|
1239
|
+
required: true,
|
|
1240
|
+
schema: {
|
|
1241
|
+
type: "string"
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
],
|
|
1245
|
+
responses: {
|
|
1246
|
+
"200": {
|
|
1247
|
+
description: "Success",
|
|
1248
|
+
content: {
|
|
1249
|
+
"application/json": {
|
|
1250
|
+
schema: {
|
|
1251
|
+
$ref: "#/components/schemas/Provider"
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
default: {
|
|
1257
|
+
description: "Structured error",
|
|
1258
|
+
content: {
|
|
1259
|
+
"application/json": {
|
|
1260
|
+
schema: {
|
|
1261
|
+
$ref: "#/components/schemas/Error"
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
put: {
|
|
1269
|
+
operationId: "updateProvider",
|
|
1270
|
+
parameters: [
|
|
1271
|
+
{
|
|
1272
|
+
name: "id",
|
|
1273
|
+
in: "path",
|
|
1274
|
+
required: true,
|
|
1275
|
+
schema: {
|
|
1276
|
+
type: "string"
|
|
1277
|
+
}
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
name: "Idempotency-Key",
|
|
1281
|
+
in: "header",
|
|
1282
|
+
required: true,
|
|
1283
|
+
schema: {
|
|
1284
|
+
type: "string",
|
|
1285
|
+
minLength: 8,
|
|
1286
|
+
maxLength: 128
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
name: "If-Match",
|
|
1291
|
+
in: "header",
|
|
1292
|
+
required: true,
|
|
1293
|
+
schema: {
|
|
1294
|
+
type: "integer",
|
|
1295
|
+
minimum: 1
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
],
|
|
1299
|
+
requestBody: {
|
|
1300
|
+
required: true,
|
|
1301
|
+
content: {
|
|
1302
|
+
"application/json": {
|
|
1303
|
+
schema: {
|
|
1304
|
+
$ref: "#/components/schemas/ProviderInput"
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
responses: {
|
|
1310
|
+
"200": {
|
|
1311
|
+
description: "Success",
|
|
1312
|
+
content: {
|
|
1313
|
+
"application/json": {
|
|
1314
|
+
schema: {
|
|
1315
|
+
$ref: "#/components/schemas/Provider"
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
},
|
|
1320
|
+
default: {
|
|
1321
|
+
description: "Structured error",
|
|
1322
|
+
content: {
|
|
1323
|
+
"application/json": {
|
|
1324
|
+
schema: {
|
|
1325
|
+
$ref: "#/components/schemas/Error"
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
delete: {
|
|
1333
|
+
operationId: "deleteProvider",
|
|
1334
|
+
parameters: [
|
|
1335
|
+
{
|
|
1336
|
+
name: "id",
|
|
1337
|
+
in: "path",
|
|
1338
|
+
required: true,
|
|
1339
|
+
schema: {
|
|
1340
|
+
type: "string"
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
{
|
|
1344
|
+
name: "Idempotency-Key",
|
|
1345
|
+
in: "header",
|
|
1346
|
+
required: true,
|
|
1347
|
+
schema: {
|
|
1348
|
+
type: "string",
|
|
1349
|
+
minLength: 8,
|
|
1350
|
+
maxLength: 128
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
name: "If-Match",
|
|
1355
|
+
in: "header",
|
|
1356
|
+
required: true,
|
|
1357
|
+
schema: {
|
|
1358
|
+
type: "integer",
|
|
1359
|
+
minimum: 1
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
],
|
|
1363
|
+
responses: {
|
|
1364
|
+
"200": {
|
|
1365
|
+
description: "Success",
|
|
1366
|
+
content: {
|
|
1367
|
+
"application/json": {
|
|
1368
|
+
schema: {
|
|
1369
|
+
type: "object",
|
|
1370
|
+
properties: {
|
|
1371
|
+
deleted: {
|
|
1372
|
+
type: "string"
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
required: [
|
|
1376
|
+
"deleted"
|
|
1377
|
+
]
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
default: {
|
|
1383
|
+
description: "Structured error",
|
|
1384
|
+
content: {
|
|
1385
|
+
"application/json": {
|
|
1386
|
+
schema: {
|
|
1387
|
+
$ref: "#/components/schemas/Error"
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
"/v1/profiles": {
|
|
1396
|
+
get: {
|
|
1397
|
+
operationId: "listProfiles",
|
|
1398
|
+
parameters: [
|
|
1399
|
+
{
|
|
1400
|
+
name: "limit",
|
|
1401
|
+
in: "query",
|
|
1402
|
+
schema: {
|
|
1403
|
+
type: "integer",
|
|
1404
|
+
minimum: 1,
|
|
1405
|
+
maximum: 1000,
|
|
1406
|
+
default: 100
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
name: "offset",
|
|
1411
|
+
in: "query",
|
|
1412
|
+
schema: {
|
|
1413
|
+
type: "integer",
|
|
1414
|
+
minimum: 0,
|
|
1415
|
+
default: 0
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
name: "search",
|
|
1420
|
+
in: "query",
|
|
1421
|
+
schema: {
|
|
1422
|
+
type: "string"
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
],
|
|
1426
|
+
responses: {
|
|
1427
|
+
"200": {
|
|
1428
|
+
description: "Success",
|
|
1429
|
+
content: {
|
|
1430
|
+
"application/json": {
|
|
1431
|
+
schema: {
|
|
1432
|
+
type: "object",
|
|
1433
|
+
required: [
|
|
1434
|
+
"data",
|
|
1435
|
+
"total",
|
|
1436
|
+
"limit",
|
|
1437
|
+
"offset"
|
|
1438
|
+
],
|
|
1439
|
+
properties: {
|
|
1440
|
+
data: {
|
|
1441
|
+
type: "array",
|
|
1442
|
+
items: {
|
|
1443
|
+
$ref: "#/components/schemas/Profile"
|
|
1444
|
+
}
|
|
1445
|
+
},
|
|
1446
|
+
total: {
|
|
1447
|
+
type: "integer"
|
|
1448
|
+
},
|
|
1449
|
+
limit: {
|
|
1450
|
+
type: "integer"
|
|
1451
|
+
},
|
|
1452
|
+
offset: {
|
|
1453
|
+
type: "integer"
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
},
|
|
1460
|
+
default: {
|
|
1461
|
+
description: "Structured error",
|
|
1462
|
+
content: {
|
|
1463
|
+
"application/json": {
|
|
1464
|
+
schema: {
|
|
1465
|
+
$ref: "#/components/schemas/Error"
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
},
|
|
1472
|
+
post: {
|
|
1473
|
+
operationId: "createProfile",
|
|
1474
|
+
parameters: [
|
|
1475
|
+
{
|
|
1476
|
+
name: "Idempotency-Key",
|
|
1477
|
+
in: "header",
|
|
1478
|
+
required: true,
|
|
1479
|
+
schema: {
|
|
1480
|
+
type: "string",
|
|
1481
|
+
minLength: 8,
|
|
1482
|
+
maxLength: 128
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
],
|
|
1486
|
+
requestBody: {
|
|
1487
|
+
required: true,
|
|
1488
|
+
content: {
|
|
1489
|
+
"application/json": {
|
|
1490
|
+
schema: {
|
|
1491
|
+
$ref: "#/components/schemas/ProfileInput"
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
},
|
|
1496
|
+
responses: {
|
|
1497
|
+
"201": {
|
|
1498
|
+
description: "Success",
|
|
1499
|
+
content: {
|
|
1500
|
+
"application/json": {
|
|
1501
|
+
schema: {
|
|
1502
|
+
$ref: "#/components/schemas/Profile"
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
default: {
|
|
1508
|
+
description: "Structured error",
|
|
1509
|
+
content: {
|
|
1510
|
+
"application/json": {
|
|
1511
|
+
schema: {
|
|
1512
|
+
$ref: "#/components/schemas/Error"
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
"/v1/profiles/{id}": {
|
|
1521
|
+
get: {
|
|
1522
|
+
operationId: "getProfile",
|
|
1523
|
+
parameters: [
|
|
1524
|
+
{
|
|
1525
|
+
name: "id",
|
|
1526
|
+
in: "path",
|
|
1527
|
+
required: true,
|
|
1528
|
+
schema: {
|
|
1529
|
+
type: "string"
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
],
|
|
1533
|
+
responses: {
|
|
1534
|
+
"200": {
|
|
1535
|
+
description: "Success",
|
|
1536
|
+
content: {
|
|
1537
|
+
"application/json": {
|
|
1538
|
+
schema: {
|
|
1539
|
+
$ref: "#/components/schemas/Profile"
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1544
|
+
default: {
|
|
1545
|
+
description: "Structured error",
|
|
1546
|
+
content: {
|
|
1547
|
+
"application/json": {
|
|
1548
|
+
schema: {
|
|
1549
|
+
$ref: "#/components/schemas/Error"
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
},
|
|
1556
|
+
put: {
|
|
1557
|
+
operationId: "updateProfile",
|
|
1558
|
+
parameters: [
|
|
1559
|
+
{
|
|
1560
|
+
name: "id",
|
|
1561
|
+
in: "path",
|
|
1562
|
+
required: true,
|
|
1563
|
+
schema: {
|
|
1564
|
+
type: "string"
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
name: "Idempotency-Key",
|
|
1569
|
+
in: "header",
|
|
1570
|
+
required: true,
|
|
1571
|
+
schema: {
|
|
1572
|
+
type: "string",
|
|
1573
|
+
minLength: 8,
|
|
1574
|
+
maxLength: 128
|
|
1575
|
+
}
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
name: "If-Match",
|
|
1579
|
+
in: "header",
|
|
1580
|
+
required: true,
|
|
1581
|
+
schema: {
|
|
1582
|
+
type: "integer",
|
|
1583
|
+
minimum: 1
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
],
|
|
1587
|
+
requestBody: {
|
|
1588
|
+
required: true,
|
|
1589
|
+
content: {
|
|
1590
|
+
"application/json": {
|
|
1591
|
+
schema: {
|
|
1592
|
+
$ref: "#/components/schemas/ProfileInput"
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
},
|
|
1597
|
+
responses: {
|
|
1598
|
+
"200": {
|
|
1599
|
+
description: "Success",
|
|
1600
|
+
content: {
|
|
1601
|
+
"application/json": {
|
|
1602
|
+
schema: {
|
|
1603
|
+
$ref: "#/components/schemas/Profile"
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
default: {
|
|
1609
|
+
description: "Structured error",
|
|
1610
|
+
content: {
|
|
1611
|
+
"application/json": {
|
|
1612
|
+
schema: {
|
|
1613
|
+
$ref: "#/components/schemas/Error"
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
},
|
|
1620
|
+
delete: {
|
|
1621
|
+
operationId: "deleteProfile",
|
|
1622
|
+
parameters: [
|
|
1623
|
+
{
|
|
1624
|
+
name: "id",
|
|
1625
|
+
in: "path",
|
|
1626
|
+
required: true,
|
|
1627
|
+
schema: {
|
|
1628
|
+
type: "string"
|
|
1629
|
+
}
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
name: "Idempotency-Key",
|
|
1633
|
+
in: "header",
|
|
1634
|
+
required: true,
|
|
1635
|
+
schema: {
|
|
1636
|
+
type: "string",
|
|
1637
|
+
minLength: 8,
|
|
1638
|
+
maxLength: 128
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
name: "If-Match",
|
|
1643
|
+
in: "header",
|
|
1644
|
+
required: true,
|
|
1645
|
+
schema: {
|
|
1646
|
+
type: "integer",
|
|
1647
|
+
minimum: 1
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
],
|
|
1651
|
+
responses: {
|
|
1652
|
+
"200": {
|
|
1653
|
+
description: "Success",
|
|
1654
|
+
content: {
|
|
1655
|
+
"application/json": {
|
|
1656
|
+
schema: {
|
|
1657
|
+
type: "object",
|
|
1658
|
+
properties: {
|
|
1659
|
+
deleted: {
|
|
1660
|
+
type: "string"
|
|
1661
|
+
}
|
|
1662
|
+
},
|
|
1663
|
+
required: [
|
|
1664
|
+
"deleted"
|
|
1665
|
+
]
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
default: {
|
|
1671
|
+
description: "Structured error",
|
|
1672
|
+
content: {
|
|
1673
|
+
"application/json": {
|
|
1674
|
+
schema: {
|
|
1675
|
+
$ref: "#/components/schemas/Error"
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
},
|
|
1683
|
+
"/v1/provider-presets": {
|
|
1684
|
+
get: {
|
|
1685
|
+
operationId: "listProviderPresets",
|
|
1686
|
+
parameters: [],
|
|
1687
|
+
responses: {
|
|
1688
|
+
"200": {
|
|
1689
|
+
description: "Success",
|
|
1690
|
+
content: {
|
|
1691
|
+
"application/json": {
|
|
1692
|
+
schema: {
|
|
1693
|
+
type: "object",
|
|
1694
|
+
required: [
|
|
1695
|
+
"data"
|
|
1696
|
+
],
|
|
1697
|
+
properties: {
|
|
1698
|
+
data: {
|
|
1699
|
+
type: "array",
|
|
1700
|
+
items: {
|
|
1701
|
+
$ref: "#/components/schemas/ProviderPreset"
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
default: {
|
|
1710
|
+
description: "Structured error",
|
|
1711
|
+
content: {
|
|
1712
|
+
"application/json": {
|
|
1713
|
+
schema: {
|
|
1714
|
+
$ref: "#/components/schemas/Error"
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
},
|
|
1722
|
+
"/v1/provider-presets/{id}": {
|
|
1723
|
+
get: {
|
|
1724
|
+
operationId: "getProviderPreset",
|
|
1725
|
+
parameters: [
|
|
1726
|
+
{
|
|
1727
|
+
name: "id",
|
|
1728
|
+
in: "path",
|
|
1729
|
+
required: true,
|
|
1730
|
+
schema: {
|
|
1731
|
+
type: "string"
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
],
|
|
1735
|
+
responses: {
|
|
1736
|
+
"200": {
|
|
1737
|
+
description: "Success",
|
|
1738
|
+
content: {
|
|
1739
|
+
"application/json": {
|
|
1740
|
+
schema: {
|
|
1741
|
+
$ref: "#/components/schemas/ProviderPreset"
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
},
|
|
1746
|
+
default: {
|
|
1747
|
+
description: "Structured error",
|
|
1748
|
+
content: {
|
|
1749
|
+
"application/json": {
|
|
1750
|
+
schema: {
|
|
1751
|
+
$ref: "#/components/schemas/Error"
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
"/v1/providers/{id}/models": {
|
|
1760
|
+
get: {
|
|
1761
|
+
operationId: "listModels",
|
|
1762
|
+
parameters: [
|
|
1763
|
+
{
|
|
1764
|
+
name: "id",
|
|
1765
|
+
in: "path",
|
|
1766
|
+
required: true,
|
|
1767
|
+
schema: {
|
|
1768
|
+
type: "string"
|
|
1769
|
+
}
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
name: "limit",
|
|
1773
|
+
in: "query",
|
|
1774
|
+
schema: {
|
|
1775
|
+
type: "integer",
|
|
1776
|
+
minimum: 1,
|
|
1777
|
+
maximum: 1000,
|
|
1778
|
+
default: 100
|
|
1779
|
+
}
|
|
1780
|
+
},
|
|
1781
|
+
{
|
|
1782
|
+
name: "offset",
|
|
1783
|
+
in: "query",
|
|
1784
|
+
schema: {
|
|
1785
|
+
type: "integer",
|
|
1786
|
+
minimum: 0,
|
|
1787
|
+
default: 0
|
|
1788
|
+
}
|
|
1789
|
+
},
|
|
1790
|
+
{
|
|
1791
|
+
name: "search",
|
|
1792
|
+
in: "query",
|
|
1793
|
+
schema: {
|
|
1794
|
+
type: "string"
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
],
|
|
1798
|
+
responses: {
|
|
1799
|
+
"200": {
|
|
1800
|
+
description: "Success",
|
|
1801
|
+
content: {
|
|
1802
|
+
"application/json": {
|
|
1803
|
+
schema: {
|
|
1804
|
+
$ref: "#/components/schemas/ModelPage"
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
},
|
|
1809
|
+
default: {
|
|
1810
|
+
description: "Structured error",
|
|
1811
|
+
content: {
|
|
1812
|
+
"application/json": {
|
|
1813
|
+
schema: {
|
|
1814
|
+
$ref: "#/components/schemas/Error"
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
},
|
|
1822
|
+
"/v1/providers/{id}/refresh": {
|
|
1823
|
+
post: {
|
|
1824
|
+
operationId: "refreshModels",
|
|
1825
|
+
parameters: [
|
|
1826
|
+
{
|
|
1827
|
+
name: "id",
|
|
1828
|
+
in: "path",
|
|
1829
|
+
required: true,
|
|
1830
|
+
schema: {
|
|
1831
|
+
type: "string"
|
|
1832
|
+
}
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
name: "Idempotency-Key",
|
|
1836
|
+
in: "header",
|
|
1837
|
+
required: true,
|
|
1838
|
+
schema: {
|
|
1839
|
+
type: "string",
|
|
1840
|
+
minLength: 8,
|
|
1841
|
+
maxLength: 128
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
],
|
|
1845
|
+
requestBody: {
|
|
1846
|
+
required: true,
|
|
1847
|
+
content: {
|
|
1848
|
+
"application/json": {
|
|
1849
|
+
schema: {
|
|
1850
|
+
$ref: "#/components/schemas/Empty"
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
},
|
|
1855
|
+
responses: {
|
|
1856
|
+
"200": {
|
|
1857
|
+
description: "Success",
|
|
1858
|
+
content: {
|
|
1859
|
+
"application/json": {
|
|
1860
|
+
schema: {
|
|
1861
|
+
$ref: "#/components/schemas/Catalog"
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
},
|
|
1866
|
+
default: {
|
|
1867
|
+
description: "Structured error",
|
|
1868
|
+
content: {
|
|
1869
|
+
"application/json": {
|
|
1870
|
+
schema: {
|
|
1871
|
+
$ref: "#/components/schemas/Error"
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
},
|
|
1879
|
+
"/v1/launch-plans": {
|
|
1880
|
+
post: {
|
|
1881
|
+
operationId: "launchPlan",
|
|
1882
|
+
parameters: [
|
|
1883
|
+
{
|
|
1884
|
+
name: "Idempotency-Key",
|
|
1885
|
+
in: "header",
|
|
1886
|
+
required: true,
|
|
1887
|
+
schema: {
|
|
1888
|
+
type: "string",
|
|
1889
|
+
minLength: 8,
|
|
1890
|
+
maxLength: 128
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
],
|
|
1894
|
+
requestBody: {
|
|
1895
|
+
required: true,
|
|
1896
|
+
content: {
|
|
1897
|
+
"application/json": {
|
|
1898
|
+
schema: {
|
|
1899
|
+
$ref: "#/components/schemas/LaunchInput"
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
},
|
|
1904
|
+
responses: {
|
|
1905
|
+
"200": {
|
|
1906
|
+
description: "Success",
|
|
1907
|
+
content: {
|
|
1908
|
+
"application/json": {
|
|
1909
|
+
schema: {
|
|
1910
|
+
$ref: "#/components/schemas/LaunchPlan"
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
},
|
|
1915
|
+
default: {
|
|
1916
|
+
description: "Structured error",
|
|
1917
|
+
content: {
|
|
1918
|
+
"application/json": {
|
|
1919
|
+
schema: {
|
|
1920
|
+
$ref: "#/components/schemas/Error"
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
},
|
|
1928
|
+
"/v1/runs": {
|
|
1929
|
+
get: {
|
|
1930
|
+
operationId: "listRuns",
|
|
1931
|
+
parameters: [
|
|
1932
|
+
{
|
|
1933
|
+
name: "limit",
|
|
1934
|
+
in: "query",
|
|
1935
|
+
schema: {
|
|
1936
|
+
type: "integer",
|
|
1937
|
+
minimum: 1,
|
|
1938
|
+
maximum: 1000,
|
|
1939
|
+
default: 100
|
|
1940
|
+
}
|
|
1941
|
+
},
|
|
1942
|
+
{
|
|
1943
|
+
name: "offset",
|
|
1944
|
+
in: "query",
|
|
1945
|
+
schema: {
|
|
1946
|
+
type: "integer",
|
|
1947
|
+
minimum: 0,
|
|
1948
|
+
default: 0
|
|
1949
|
+
}
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
name: "search",
|
|
1953
|
+
in: "query",
|
|
1954
|
+
schema: {
|
|
1955
|
+
type: "string"
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
],
|
|
1959
|
+
responses: {
|
|
1960
|
+
"200": {
|
|
1961
|
+
description: "Success",
|
|
1962
|
+
content: {
|
|
1963
|
+
"application/json": {
|
|
1964
|
+
schema: {
|
|
1965
|
+
type: "object",
|
|
1966
|
+
required: [
|
|
1967
|
+
"data",
|
|
1968
|
+
"total",
|
|
1969
|
+
"limit",
|
|
1970
|
+
"offset"
|
|
1971
|
+
],
|
|
1972
|
+
properties: {
|
|
1973
|
+
data: {
|
|
1974
|
+
type: "array",
|
|
1975
|
+
items: {
|
|
1976
|
+
$ref: "#/components/schemas/Run"
|
|
1977
|
+
}
|
|
1978
|
+
},
|
|
1979
|
+
total: {
|
|
1980
|
+
type: "integer"
|
|
1981
|
+
},
|
|
1982
|
+
limit: {
|
|
1983
|
+
type: "integer"
|
|
1984
|
+
},
|
|
1985
|
+
offset: {
|
|
1986
|
+
type: "integer"
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
},
|
|
1993
|
+
default: {
|
|
1994
|
+
description: "Structured error",
|
|
1995
|
+
content: {
|
|
1996
|
+
"application/json": {
|
|
1997
|
+
schema: {
|
|
1998
|
+
$ref: "#/components/schemas/Error"
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
},
|
|
2005
|
+
post: {
|
|
2006
|
+
operationId: "createRun",
|
|
2007
|
+
parameters: [
|
|
2008
|
+
{
|
|
2009
|
+
name: "Idempotency-Key",
|
|
2010
|
+
in: "header",
|
|
2011
|
+
required: true,
|
|
2012
|
+
schema: {
|
|
2013
|
+
type: "string",
|
|
2014
|
+
minLength: 8,
|
|
2015
|
+
maxLength: 128
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
],
|
|
2019
|
+
requestBody: {
|
|
2020
|
+
required: true,
|
|
2021
|
+
content: {
|
|
2022
|
+
"application/json": {
|
|
2023
|
+
schema: {
|
|
2024
|
+
$ref: "#/components/schemas/RunInput"
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
},
|
|
2029
|
+
responses: {
|
|
2030
|
+
"201": {
|
|
2031
|
+
description: "Success",
|
|
2032
|
+
content: {
|
|
2033
|
+
"application/json": {
|
|
2034
|
+
schema: {
|
|
2035
|
+
$ref: "#/components/schemas/Run"
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
},
|
|
2040
|
+
default: {
|
|
2041
|
+
description: "Structured error",
|
|
2042
|
+
content: {
|
|
2043
|
+
"application/json": {
|
|
2044
|
+
schema: {
|
|
2045
|
+
$ref: "#/components/schemas/Error"
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
},
|
|
2053
|
+
"/v1/runs/{id}": {
|
|
2054
|
+
get: {
|
|
2055
|
+
operationId: "getRun",
|
|
2056
|
+
parameters: [
|
|
2057
|
+
{
|
|
2058
|
+
name: "id",
|
|
2059
|
+
in: "path",
|
|
2060
|
+
required: true,
|
|
2061
|
+
schema: {
|
|
2062
|
+
type: "string"
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
],
|
|
2066
|
+
responses: {
|
|
2067
|
+
"200": {
|
|
2068
|
+
description: "Success",
|
|
2069
|
+
content: {
|
|
2070
|
+
"application/json": {
|
|
2071
|
+
schema: {
|
|
2072
|
+
$ref: "#/components/schemas/Run"
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
2077
|
+
default: {
|
|
2078
|
+
description: "Structured error",
|
|
2079
|
+
content: {
|
|
2080
|
+
"application/json": {
|
|
2081
|
+
schema: {
|
|
2082
|
+
$ref: "#/components/schemas/Error"
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
patch: {
|
|
2090
|
+
operationId: "finishRun",
|
|
2091
|
+
parameters: [
|
|
2092
|
+
{
|
|
2093
|
+
name: "id",
|
|
2094
|
+
in: "path",
|
|
2095
|
+
required: true,
|
|
2096
|
+
schema: {
|
|
2097
|
+
type: "string"
|
|
2098
|
+
}
|
|
2099
|
+
},
|
|
2100
|
+
{
|
|
2101
|
+
name: "Idempotency-Key",
|
|
2102
|
+
in: "header",
|
|
2103
|
+
required: true,
|
|
2104
|
+
schema: {
|
|
2105
|
+
type: "string",
|
|
2106
|
+
minLength: 8,
|
|
2107
|
+
maxLength: 128
|
|
2108
|
+
}
|
|
2109
|
+
},
|
|
2110
|
+
{
|
|
2111
|
+
name: "If-Match",
|
|
2112
|
+
in: "header",
|
|
2113
|
+
required: true,
|
|
2114
|
+
schema: {
|
|
2115
|
+
type: "integer",
|
|
2116
|
+
minimum: 1
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
],
|
|
2120
|
+
requestBody: {
|
|
2121
|
+
required: true,
|
|
2122
|
+
content: {
|
|
2123
|
+
"application/json": {
|
|
2124
|
+
schema: {
|
|
2125
|
+
$ref: "#/components/schemas/RunUpdate"
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
},
|
|
2130
|
+
responses: {
|
|
2131
|
+
"200": {
|
|
2132
|
+
description: "Success",
|
|
2133
|
+
content: {
|
|
2134
|
+
"application/json": {
|
|
2135
|
+
schema: {
|
|
2136
|
+
$ref: "#/components/schemas/Run"
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
},
|
|
2141
|
+
default: {
|
|
2142
|
+
description: "Structured error",
|
|
2143
|
+
content: {
|
|
2144
|
+
"application/json": {
|
|
2145
|
+
schema: {
|
|
2146
|
+
$ref: "#/components/schemas/Error"
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
},
|
|
2154
|
+
"/health": {
|
|
2155
|
+
get: {
|
|
2156
|
+
operationId: "health",
|
|
2157
|
+
parameters: [],
|
|
2158
|
+
responses: {
|
|
2159
|
+
"200": {
|
|
2160
|
+
description: "Success",
|
|
2161
|
+
content: {
|
|
2162
|
+
"application/json": {
|
|
2163
|
+
schema: {
|
|
2164
|
+
$ref: "#/components/schemas/Health"
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
},
|
|
2169
|
+
default: {
|
|
2170
|
+
description: "Structured error",
|
|
2171
|
+
content: {
|
|
2172
|
+
"application/json": {
|
|
2173
|
+
schema: {
|
|
2174
|
+
$ref: "#/components/schemas/Error"
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
},
|
|
2180
|
+
security: []
|
|
2181
|
+
}
|
|
2182
|
+
},
|
|
2183
|
+
"/ready": {
|
|
2184
|
+
get: {
|
|
2185
|
+
operationId: "ready",
|
|
2186
|
+
parameters: [],
|
|
2187
|
+
responses: {
|
|
2188
|
+
"200": {
|
|
2189
|
+
description: "Success",
|
|
2190
|
+
content: {
|
|
2191
|
+
"application/json": {
|
|
2192
|
+
schema: {
|
|
2193
|
+
$ref: "#/components/schemas/Ready"
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
},
|
|
2198
|
+
default: {
|
|
2199
|
+
description: "Structured error",
|
|
2200
|
+
content: {
|
|
2201
|
+
"application/json": {
|
|
2202
|
+
schema: {
|
|
2203
|
+
$ref: "#/components/schemas/Error"
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
security: []
|
|
2210
|
+
}
|
|
2211
|
+
},
|
|
2212
|
+
"/version": {
|
|
2213
|
+
get: {
|
|
2214
|
+
operationId: "version",
|
|
2215
|
+
parameters: [],
|
|
2216
|
+
responses: {
|
|
2217
|
+
"200": {
|
|
2218
|
+
description: "Success",
|
|
2219
|
+
content: {
|
|
2220
|
+
"application/json": {
|
|
2221
|
+
schema: {
|
|
2222
|
+
$ref: "#/components/schemas/Version"
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
},
|
|
2227
|
+
default: {
|
|
2228
|
+
description: "Structured error",
|
|
2229
|
+
content: {
|
|
2230
|
+
"application/json": {
|
|
2231
|
+
schema: {
|
|
2232
|
+
$ref: "#/components/schemas/Error"
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
},
|
|
2238
|
+
security: []
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
"/v1/openapi.json": {
|
|
2242
|
+
get: {
|
|
2243
|
+
operationId: "openApi",
|
|
2244
|
+
parameters: [],
|
|
2245
|
+
responses: {
|
|
2246
|
+
"200": {
|
|
2247
|
+
description: "Success",
|
|
2248
|
+
content: {
|
|
2249
|
+
"application/json": {
|
|
2250
|
+
schema: {
|
|
2251
|
+
type: "object",
|
|
2252
|
+
additionalProperties: true
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
},
|
|
2257
|
+
default: {
|
|
2258
|
+
description: "Structured error",
|
|
2259
|
+
content: {
|
|
2260
|
+
"application/json": {
|
|
2261
|
+
schema: {
|
|
2262
|
+
$ref: "#/components/schemas/Error"
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
},
|
|
2271
|
+
components: {
|
|
2272
|
+
securitySchemes: {
|
|
2273
|
+
bearerAuth: {
|
|
2274
|
+
type: "http",
|
|
2275
|
+
scheme: "bearer"
|
|
2276
|
+
}
|
|
2277
|
+
},
|
|
2278
|
+
schemas: {
|
|
2279
|
+
ProviderPreset: {
|
|
2280
|
+
type: "object",
|
|
2281
|
+
properties: {
|
|
2282
|
+
id: {
|
|
2283
|
+
type: "string",
|
|
2284
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
2285
|
+
},
|
|
2286
|
+
name: {
|
|
2287
|
+
type: "string",
|
|
2288
|
+
minLength: 1,
|
|
2289
|
+
maxLength: 200
|
|
2290
|
+
},
|
|
2291
|
+
credentialEnv: {
|
|
2292
|
+
type: "string",
|
|
2293
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
2294
|
+
},
|
|
2295
|
+
credentialAliases: {
|
|
2296
|
+
type: "array",
|
|
2297
|
+
items: {
|
|
2298
|
+
type: "string",
|
|
2299
|
+
pattern: "^[A-Z][A-Z0-9_]+$"
|
|
2300
|
+
}
|
|
2301
|
+
},
|
|
2302
|
+
protocols: {
|
|
2303
|
+
type: "array",
|
|
2304
|
+
items: {
|
|
2305
|
+
type: "object",
|
|
2306
|
+
properties: {
|
|
2307
|
+
protocol: {
|
|
2308
|
+
type: "string",
|
|
2309
|
+
enum: [
|
|
2310
|
+
"anthropic-messages",
|
|
2311
|
+
"openai-responses",
|
|
2312
|
+
"openai-chat",
|
|
2313
|
+
"gemini-generate-content"
|
|
2314
|
+
]
|
|
2315
|
+
},
|
|
2316
|
+
baseUrl: {
|
|
2317
|
+
type: "string",
|
|
2318
|
+
maxLength: 2000
|
|
2319
|
+
},
|
|
2320
|
+
authStyle: {
|
|
2321
|
+
type: "string",
|
|
2322
|
+
enum: [
|
|
2323
|
+
"bearer",
|
|
2324
|
+
"x-api-key",
|
|
2325
|
+
"api-key"
|
|
2326
|
+
]
|
|
2327
|
+
},
|
|
2328
|
+
catalogBaseUrl: {
|
|
2329
|
+
type: "string",
|
|
2330
|
+
maxLength: 2000
|
|
2331
|
+
},
|
|
2332
|
+
catalogFormat: {
|
|
2333
|
+
type: "string",
|
|
2334
|
+
enum: [
|
|
2335
|
+
"openai",
|
|
2336
|
+
"ollama",
|
|
2337
|
+
"mistral",
|
|
2338
|
+
"together",
|
|
2339
|
+
"fireworks",
|
|
2340
|
+
"dashscope",
|
|
2341
|
+
"gemini",
|
|
2342
|
+
"none"
|
|
2343
|
+
]
|
|
2344
|
+
},
|
|
2345
|
+
catalogAuthStyle: {
|
|
2346
|
+
type: "string",
|
|
2347
|
+
enum: [
|
|
2348
|
+
"bearer",
|
|
2349
|
+
"x-api-key",
|
|
2350
|
+
"api-key",
|
|
2351
|
+
"none"
|
|
2352
|
+
]
|
|
2353
|
+
},
|
|
2354
|
+
modelsPath: {
|
|
2355
|
+
type: "string"
|
|
2356
|
+
},
|
|
2357
|
+
notes: {
|
|
2358
|
+
type: "array",
|
|
2359
|
+
items: {
|
|
2360
|
+
type: "string"
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
},
|
|
2364
|
+
required: [
|
|
2365
|
+
"protocol",
|
|
2366
|
+
"authStyle",
|
|
2367
|
+
"catalogFormat",
|
|
2368
|
+
"modelsPath",
|
|
2369
|
+
"notes"
|
|
2370
|
+
],
|
|
2371
|
+
additionalProperties: false
|
|
2372
|
+
},
|
|
2373
|
+
minItems: 1
|
|
2374
|
+
},
|
|
2375
|
+
sources: {
|
|
2376
|
+
type: "array",
|
|
2377
|
+
items: {
|
|
2378
|
+
type: "string",
|
|
2379
|
+
format: "uri"
|
|
2380
|
+
}
|
|
2381
|
+
},
|
|
2382
|
+
verification: {
|
|
2383
|
+
type: "string",
|
|
2384
|
+
enum: [
|
|
2385
|
+
"documented"
|
|
2386
|
+
]
|
|
2387
|
+
}
|
|
2388
|
+
},
|
|
2389
|
+
required: [
|
|
2390
|
+
"id",
|
|
2391
|
+
"name",
|
|
2392
|
+
"credentialAliases",
|
|
2393
|
+
"protocols",
|
|
2394
|
+
"sources",
|
|
2395
|
+
"verification"
|
|
2396
|
+
],
|
|
2397
|
+
additionalProperties: false
|
|
2398
|
+
},
|
|
2399
|
+
ProviderInput: {
|
|
2400
|
+
type: "object",
|
|
2401
|
+
properties: {
|
|
2402
|
+
id: {
|
|
2403
|
+
type: "string",
|
|
2404
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
2405
|
+
},
|
|
2406
|
+
name: {
|
|
2407
|
+
type: "string",
|
|
2408
|
+
minLength: 1,
|
|
2409
|
+
maxLength: 200
|
|
2410
|
+
},
|
|
2411
|
+
baseUrl: {
|
|
2412
|
+
type: "string",
|
|
2413
|
+
maxLength: 2000
|
|
2414
|
+
},
|
|
2415
|
+
protocol: {
|
|
2416
|
+
type: "string",
|
|
2417
|
+
enum: [
|
|
2418
|
+
"anthropic-messages",
|
|
2419
|
+
"openai-responses",
|
|
2420
|
+
"openai-chat",
|
|
2421
|
+
"gemini-generate-content"
|
|
2422
|
+
]
|
|
2423
|
+
},
|
|
2424
|
+
credentialEnv: {
|
|
2425
|
+
type: "string",
|
|
2426
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
2427
|
+
},
|
|
2428
|
+
authStyle: {
|
|
2429
|
+
type: "string",
|
|
2430
|
+
enum: [
|
|
2431
|
+
"bearer",
|
|
2432
|
+
"x-api-key",
|
|
2433
|
+
"api-key"
|
|
2434
|
+
],
|
|
2435
|
+
default: "bearer"
|
|
2436
|
+
},
|
|
2437
|
+
catalogBaseUrl: {
|
|
2438
|
+
type: "string",
|
|
2439
|
+
maxLength: 2000
|
|
2440
|
+
},
|
|
2441
|
+
catalogFormat: {
|
|
2442
|
+
type: "string",
|
|
2443
|
+
enum: [
|
|
2444
|
+
"openai",
|
|
2445
|
+
"ollama",
|
|
2446
|
+
"mistral",
|
|
2447
|
+
"together",
|
|
2448
|
+
"fireworks",
|
|
2449
|
+
"dashscope",
|
|
2450
|
+
"gemini",
|
|
2451
|
+
"none"
|
|
2452
|
+
]
|
|
2453
|
+
},
|
|
2454
|
+
catalogAuthStyle: {
|
|
2455
|
+
type: "string",
|
|
2456
|
+
enum: [
|
|
2457
|
+
"bearer",
|
|
2458
|
+
"x-api-key",
|
|
2459
|
+
"api-key",
|
|
2460
|
+
"none"
|
|
2461
|
+
]
|
|
2462
|
+
},
|
|
2463
|
+
catalogCredentialEnv: {
|
|
2464
|
+
type: "string",
|
|
2465
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
2466
|
+
},
|
|
2467
|
+
catalogAccountId: {
|
|
2468
|
+
type: "string",
|
|
2469
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
2470
|
+
},
|
|
2471
|
+
modelsPath: {
|
|
2472
|
+
type: "string",
|
|
2473
|
+
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
2474
|
+
maxLength: 200,
|
|
2475
|
+
default: "models"
|
|
2476
|
+
},
|
|
2477
|
+
manualModels: {
|
|
2478
|
+
type: "array",
|
|
2479
|
+
items: {
|
|
2480
|
+
type: "object",
|
|
2481
|
+
properties: {
|
|
2482
|
+
id: {
|
|
2483
|
+
type: "string",
|
|
2484
|
+
minLength: 1,
|
|
2485
|
+
maxLength: 300
|
|
2486
|
+
},
|
|
2487
|
+
name: {
|
|
2488
|
+
type: "string",
|
|
2489
|
+
minLength: 1,
|
|
2490
|
+
maxLength: 200
|
|
2491
|
+
},
|
|
2492
|
+
description: {
|
|
2493
|
+
type: "string",
|
|
2494
|
+
maxLength: 8000
|
|
2495
|
+
},
|
|
2496
|
+
available: {
|
|
2497
|
+
type: "boolean"
|
|
2498
|
+
},
|
|
2499
|
+
expiresOn: {
|
|
2500
|
+
type: "string",
|
|
2501
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2502
|
+
},
|
|
2503
|
+
contextWindow: {
|
|
2504
|
+
type: "integer",
|
|
2505
|
+
exclusiveMinimum: true,
|
|
2506
|
+
minimum: 0
|
|
2507
|
+
},
|
|
2508
|
+
maxOutputTokens: {
|
|
2509
|
+
type: "integer",
|
|
2510
|
+
exclusiveMinimum: true,
|
|
2511
|
+
minimum: 0
|
|
2512
|
+
},
|
|
2513
|
+
inputModalities: {
|
|
2514
|
+
type: "array",
|
|
2515
|
+
items: {
|
|
2516
|
+
type: "string",
|
|
2517
|
+
maxLength: 50
|
|
2518
|
+
},
|
|
2519
|
+
maxItems: 20
|
|
2520
|
+
},
|
|
2521
|
+
outputModalities: {
|
|
2522
|
+
type: "array",
|
|
2523
|
+
items: {
|
|
2524
|
+
type: "string",
|
|
2525
|
+
maxLength: 50
|
|
2526
|
+
},
|
|
2527
|
+
maxItems: 20
|
|
2528
|
+
},
|
|
2529
|
+
supportedParameters: {
|
|
2530
|
+
type: "array",
|
|
2531
|
+
items: {
|
|
2532
|
+
type: "string",
|
|
2533
|
+
maxLength: 100
|
|
2534
|
+
},
|
|
2535
|
+
maxItems: 100
|
|
2536
|
+
},
|
|
2537
|
+
reasoningEfforts: {
|
|
2538
|
+
type: "array",
|
|
2539
|
+
items: {
|
|
2540
|
+
type: "string",
|
|
2541
|
+
enum: [
|
|
2542
|
+
"none",
|
|
2543
|
+
"minimal",
|
|
2544
|
+
"low",
|
|
2545
|
+
"medium",
|
|
2546
|
+
"high",
|
|
2547
|
+
"xhigh",
|
|
2548
|
+
"max",
|
|
2549
|
+
"ultra"
|
|
2550
|
+
]
|
|
2551
|
+
},
|
|
2552
|
+
maxItems: 8
|
|
2553
|
+
},
|
|
2554
|
+
supportedGenerationMethods: {
|
|
2555
|
+
type: "array",
|
|
2556
|
+
items: {
|
|
2557
|
+
type: "string",
|
|
2558
|
+
minLength: 1,
|
|
2559
|
+
maxLength: 100
|
|
2560
|
+
},
|
|
2561
|
+
maxItems: 100
|
|
2562
|
+
}
|
|
2563
|
+
},
|
|
2564
|
+
required: [
|
|
2565
|
+
"id",
|
|
2566
|
+
"name"
|
|
2567
|
+
],
|
|
2568
|
+
additionalProperties: false
|
|
2569
|
+
},
|
|
2570
|
+
maxItems: 1e4,
|
|
2571
|
+
default: []
|
|
2572
|
+
},
|
|
2573
|
+
additionalModels: {
|
|
2574
|
+
type: "array",
|
|
2575
|
+
items: {
|
|
2576
|
+
type: "object",
|
|
2577
|
+
properties: {
|
|
2578
|
+
id: {
|
|
2579
|
+
type: "string",
|
|
2580
|
+
minLength: 1,
|
|
2581
|
+
maxLength: 300
|
|
2582
|
+
},
|
|
2583
|
+
name: {
|
|
2584
|
+
type: "string",
|
|
2585
|
+
minLength: 1,
|
|
2586
|
+
maxLength: 200
|
|
2587
|
+
},
|
|
2588
|
+
description: {
|
|
2589
|
+
type: "string",
|
|
2590
|
+
maxLength: 8000
|
|
2591
|
+
},
|
|
2592
|
+
available: {
|
|
2593
|
+
type: "boolean"
|
|
2594
|
+
},
|
|
2595
|
+
expiresOn: {
|
|
2596
|
+
type: "string",
|
|
2597
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2598
|
+
},
|
|
2599
|
+
contextWindow: {
|
|
2600
|
+
type: "integer",
|
|
2601
|
+
exclusiveMinimum: true,
|
|
2602
|
+
minimum: 0
|
|
2603
|
+
},
|
|
2604
|
+
maxOutputTokens: {
|
|
2605
|
+
type: "integer",
|
|
2606
|
+
exclusiveMinimum: true,
|
|
2607
|
+
minimum: 0
|
|
2608
|
+
},
|
|
2609
|
+
inputModalities: {
|
|
2610
|
+
type: "array",
|
|
2611
|
+
items: {
|
|
2612
|
+
type: "string",
|
|
2613
|
+
maxLength: 50
|
|
2614
|
+
},
|
|
2615
|
+
maxItems: 20
|
|
2616
|
+
},
|
|
2617
|
+
outputModalities: {
|
|
2618
|
+
type: "array",
|
|
2619
|
+
items: {
|
|
2620
|
+
type: "string",
|
|
2621
|
+
maxLength: 50
|
|
2622
|
+
},
|
|
2623
|
+
maxItems: 20
|
|
2624
|
+
},
|
|
2625
|
+
supportedParameters: {
|
|
2626
|
+
type: "array",
|
|
2627
|
+
items: {
|
|
2628
|
+
type: "string",
|
|
2629
|
+
maxLength: 100
|
|
2630
|
+
},
|
|
2631
|
+
maxItems: 100
|
|
2632
|
+
},
|
|
2633
|
+
reasoningEfforts: {
|
|
2634
|
+
type: "array",
|
|
2635
|
+
items: {
|
|
2636
|
+
type: "string",
|
|
2637
|
+
enum: [
|
|
2638
|
+
"none",
|
|
2639
|
+
"minimal",
|
|
2640
|
+
"low",
|
|
2641
|
+
"medium",
|
|
2642
|
+
"high",
|
|
2643
|
+
"xhigh",
|
|
2644
|
+
"max",
|
|
2645
|
+
"ultra"
|
|
2646
|
+
]
|
|
2647
|
+
},
|
|
2648
|
+
maxItems: 8
|
|
2649
|
+
},
|
|
2650
|
+
supportedGenerationMethods: {
|
|
2651
|
+
type: "array",
|
|
2652
|
+
items: {
|
|
2653
|
+
type: "string",
|
|
2654
|
+
minLength: 1,
|
|
2655
|
+
maxLength: 100
|
|
2656
|
+
},
|
|
2657
|
+
maxItems: 100
|
|
2658
|
+
}
|
|
2659
|
+
},
|
|
2660
|
+
required: [
|
|
2661
|
+
"id",
|
|
2662
|
+
"name"
|
|
2663
|
+
],
|
|
2664
|
+
additionalProperties: false
|
|
2665
|
+
},
|
|
2666
|
+
maxItems: 1e4
|
|
2667
|
+
}
|
|
2668
|
+
},
|
|
2669
|
+
required: [
|
|
2670
|
+
"id",
|
|
2671
|
+
"name",
|
|
2672
|
+
"baseUrl",
|
|
2673
|
+
"protocol"
|
|
2674
|
+
],
|
|
2675
|
+
additionalProperties: false
|
|
2676
|
+
},
|
|
2677
|
+
Provider: {
|
|
2678
|
+
type: "object",
|
|
2679
|
+
properties: {
|
|
2680
|
+
id: {
|
|
2681
|
+
type: "string",
|
|
2682
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
2683
|
+
},
|
|
2684
|
+
name: {
|
|
2685
|
+
type: "string",
|
|
2686
|
+
minLength: 1,
|
|
2687
|
+
maxLength: 200
|
|
2688
|
+
},
|
|
2689
|
+
baseUrl: {
|
|
2690
|
+
type: "string",
|
|
2691
|
+
maxLength: 2000
|
|
2692
|
+
},
|
|
2693
|
+
protocol: {
|
|
2694
|
+
type: "string",
|
|
2695
|
+
enum: [
|
|
2696
|
+
"anthropic-messages",
|
|
2697
|
+
"openai-responses",
|
|
2698
|
+
"openai-chat",
|
|
2699
|
+
"gemini-generate-content"
|
|
2700
|
+
]
|
|
2701
|
+
},
|
|
2702
|
+
credentialEnv: {
|
|
2703
|
+
type: "string",
|
|
2704
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
2705
|
+
},
|
|
2706
|
+
authStyle: {
|
|
2707
|
+
type: "string",
|
|
2708
|
+
enum: [
|
|
2709
|
+
"bearer",
|
|
2710
|
+
"x-api-key",
|
|
2711
|
+
"api-key"
|
|
2712
|
+
],
|
|
2713
|
+
default: "bearer"
|
|
2714
|
+
},
|
|
2715
|
+
catalogBaseUrl: {
|
|
2716
|
+
type: "string",
|
|
2717
|
+
maxLength: 2000
|
|
2718
|
+
},
|
|
2719
|
+
catalogFormat: {
|
|
2720
|
+
type: "string",
|
|
2721
|
+
enum: [
|
|
2722
|
+
"openai",
|
|
2723
|
+
"ollama",
|
|
2724
|
+
"mistral",
|
|
2725
|
+
"together",
|
|
2726
|
+
"fireworks",
|
|
2727
|
+
"dashscope",
|
|
2728
|
+
"gemini",
|
|
2729
|
+
"none"
|
|
2730
|
+
]
|
|
2731
|
+
},
|
|
2732
|
+
catalogAuthStyle: {
|
|
2733
|
+
type: "string",
|
|
2734
|
+
enum: [
|
|
2735
|
+
"bearer",
|
|
2736
|
+
"x-api-key",
|
|
2737
|
+
"api-key",
|
|
2738
|
+
"none"
|
|
2739
|
+
]
|
|
2740
|
+
},
|
|
2741
|
+
catalogCredentialEnv: {
|
|
2742
|
+
type: "string",
|
|
2743
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
2744
|
+
},
|
|
2745
|
+
catalogAccountId: {
|
|
2746
|
+
type: "string",
|
|
2747
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
2748
|
+
},
|
|
2749
|
+
modelsPath: {
|
|
2750
|
+
type: "string",
|
|
2751
|
+
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
2752
|
+
maxLength: 200,
|
|
2753
|
+
default: "models"
|
|
2754
|
+
},
|
|
2755
|
+
manualModels: {
|
|
2756
|
+
type: "array",
|
|
2757
|
+
items: {
|
|
2758
|
+
type: "object",
|
|
2759
|
+
properties: {
|
|
2760
|
+
id: {
|
|
2761
|
+
type: "string",
|
|
2762
|
+
minLength: 1,
|
|
2763
|
+
maxLength: 300
|
|
2764
|
+
},
|
|
2765
|
+
name: {
|
|
2766
|
+
type: "string",
|
|
2767
|
+
minLength: 1,
|
|
2768
|
+
maxLength: 200
|
|
2769
|
+
},
|
|
2770
|
+
description: {
|
|
2771
|
+
type: "string",
|
|
2772
|
+
maxLength: 8000
|
|
2773
|
+
},
|
|
2774
|
+
available: {
|
|
2775
|
+
type: "boolean"
|
|
2776
|
+
},
|
|
2777
|
+
expiresOn: {
|
|
2778
|
+
type: "string",
|
|
2779
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2780
|
+
},
|
|
2781
|
+
contextWindow: {
|
|
2782
|
+
type: "integer",
|
|
2783
|
+
exclusiveMinimum: true,
|
|
2784
|
+
minimum: 0
|
|
2785
|
+
},
|
|
2786
|
+
maxOutputTokens: {
|
|
2787
|
+
type: "integer",
|
|
2788
|
+
exclusiveMinimum: true,
|
|
2789
|
+
minimum: 0
|
|
2790
|
+
},
|
|
2791
|
+
inputModalities: {
|
|
2792
|
+
type: "array",
|
|
2793
|
+
items: {
|
|
2794
|
+
type: "string",
|
|
2795
|
+
maxLength: 50
|
|
2796
|
+
},
|
|
2797
|
+
maxItems: 20
|
|
2798
|
+
},
|
|
2799
|
+
outputModalities: {
|
|
2800
|
+
type: "array",
|
|
2801
|
+
items: {
|
|
2802
|
+
type: "string",
|
|
2803
|
+
maxLength: 50
|
|
2804
|
+
},
|
|
2805
|
+
maxItems: 20
|
|
2806
|
+
},
|
|
2807
|
+
supportedParameters: {
|
|
2808
|
+
type: "array",
|
|
2809
|
+
items: {
|
|
2810
|
+
type: "string",
|
|
2811
|
+
maxLength: 100
|
|
2812
|
+
},
|
|
2813
|
+
maxItems: 100
|
|
2814
|
+
},
|
|
2815
|
+
reasoningEfforts: {
|
|
2816
|
+
type: "array",
|
|
2817
|
+
items: {
|
|
2818
|
+
type: "string",
|
|
2819
|
+
enum: [
|
|
2820
|
+
"none",
|
|
2821
|
+
"minimal",
|
|
2822
|
+
"low",
|
|
2823
|
+
"medium",
|
|
2824
|
+
"high",
|
|
2825
|
+
"xhigh",
|
|
2826
|
+
"max",
|
|
2827
|
+
"ultra"
|
|
2828
|
+
]
|
|
2829
|
+
},
|
|
2830
|
+
maxItems: 8
|
|
2831
|
+
},
|
|
2832
|
+
supportedGenerationMethods: {
|
|
2833
|
+
type: "array",
|
|
2834
|
+
items: {
|
|
2835
|
+
type: "string",
|
|
2836
|
+
minLength: 1,
|
|
2837
|
+
maxLength: 100
|
|
2838
|
+
},
|
|
2839
|
+
maxItems: 100
|
|
2840
|
+
}
|
|
2841
|
+
},
|
|
2842
|
+
required: [
|
|
2843
|
+
"id",
|
|
2844
|
+
"name"
|
|
2845
|
+
],
|
|
2846
|
+
additionalProperties: false
|
|
2847
|
+
},
|
|
2848
|
+
maxItems: 1e4,
|
|
2849
|
+
default: []
|
|
2850
|
+
},
|
|
2851
|
+
additionalModels: {
|
|
2852
|
+
type: "array",
|
|
2853
|
+
items: {
|
|
2854
|
+
type: "object",
|
|
2855
|
+
properties: {
|
|
2856
|
+
id: {
|
|
2857
|
+
type: "string",
|
|
2858
|
+
minLength: 1,
|
|
2859
|
+
maxLength: 300
|
|
2860
|
+
},
|
|
2861
|
+
name: {
|
|
2862
|
+
type: "string",
|
|
2863
|
+
minLength: 1,
|
|
2864
|
+
maxLength: 200
|
|
2865
|
+
},
|
|
2866
|
+
description: {
|
|
2867
|
+
type: "string",
|
|
2868
|
+
maxLength: 8000
|
|
2869
|
+
},
|
|
2870
|
+
available: {
|
|
2871
|
+
type: "boolean"
|
|
2872
|
+
},
|
|
2873
|
+
expiresOn: {
|
|
2874
|
+
type: "string",
|
|
2875
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
2876
|
+
},
|
|
2877
|
+
contextWindow: {
|
|
2878
|
+
type: "integer",
|
|
2879
|
+
exclusiveMinimum: true,
|
|
2880
|
+
minimum: 0
|
|
2881
|
+
},
|
|
2882
|
+
maxOutputTokens: {
|
|
2883
|
+
type: "integer",
|
|
2884
|
+
exclusiveMinimum: true,
|
|
2885
|
+
minimum: 0
|
|
2886
|
+
},
|
|
2887
|
+
inputModalities: {
|
|
2888
|
+
type: "array",
|
|
2889
|
+
items: {
|
|
2890
|
+
type: "string",
|
|
2891
|
+
maxLength: 50
|
|
2892
|
+
},
|
|
2893
|
+
maxItems: 20
|
|
2894
|
+
},
|
|
2895
|
+
outputModalities: {
|
|
2896
|
+
type: "array",
|
|
2897
|
+
items: {
|
|
2898
|
+
type: "string",
|
|
2899
|
+
maxLength: 50
|
|
2900
|
+
},
|
|
2901
|
+
maxItems: 20
|
|
2902
|
+
},
|
|
2903
|
+
supportedParameters: {
|
|
2904
|
+
type: "array",
|
|
2905
|
+
items: {
|
|
2906
|
+
type: "string",
|
|
2907
|
+
maxLength: 100
|
|
2908
|
+
},
|
|
2909
|
+
maxItems: 100
|
|
2910
|
+
},
|
|
2911
|
+
reasoningEfforts: {
|
|
2912
|
+
type: "array",
|
|
2913
|
+
items: {
|
|
2914
|
+
type: "string",
|
|
2915
|
+
enum: [
|
|
2916
|
+
"none",
|
|
2917
|
+
"minimal",
|
|
2918
|
+
"low",
|
|
2919
|
+
"medium",
|
|
2920
|
+
"high",
|
|
2921
|
+
"xhigh",
|
|
2922
|
+
"max",
|
|
2923
|
+
"ultra"
|
|
2924
|
+
]
|
|
2925
|
+
},
|
|
2926
|
+
maxItems: 8
|
|
2927
|
+
},
|
|
2928
|
+
supportedGenerationMethods: {
|
|
2929
|
+
type: "array",
|
|
2930
|
+
items: {
|
|
2931
|
+
type: "string",
|
|
2932
|
+
minLength: 1,
|
|
2933
|
+
maxLength: 100
|
|
2934
|
+
},
|
|
2935
|
+
maxItems: 100
|
|
2936
|
+
}
|
|
2937
|
+
},
|
|
2938
|
+
required: [
|
|
2939
|
+
"id",
|
|
2940
|
+
"name"
|
|
2941
|
+
],
|
|
2942
|
+
additionalProperties: false
|
|
2943
|
+
},
|
|
2944
|
+
maxItems: 1e4
|
|
2945
|
+
},
|
|
2946
|
+
version: {
|
|
2947
|
+
type: "integer",
|
|
2948
|
+
exclusiveMinimum: true,
|
|
2949
|
+
minimum: 0
|
|
2950
|
+
},
|
|
2951
|
+
updatedAt: {
|
|
2952
|
+
type: "string"
|
|
2953
|
+
}
|
|
2954
|
+
},
|
|
2955
|
+
required: [
|
|
2956
|
+
"id",
|
|
2957
|
+
"name",
|
|
2958
|
+
"baseUrl",
|
|
2959
|
+
"protocol",
|
|
2960
|
+
"version",
|
|
2961
|
+
"updatedAt"
|
|
2962
|
+
],
|
|
2963
|
+
additionalProperties: false
|
|
2964
|
+
},
|
|
2965
|
+
ProfileInput: {
|
|
2966
|
+
type: "object",
|
|
2967
|
+
properties: {
|
|
2968
|
+
id: {
|
|
2969
|
+
type: "string",
|
|
2970
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
2971
|
+
},
|
|
2972
|
+
name: {
|
|
2973
|
+
type: "string",
|
|
2974
|
+
minLength: 1,
|
|
2975
|
+
maxLength: 200
|
|
2976
|
+
},
|
|
2977
|
+
providerId: {
|
|
2978
|
+
type: "string",
|
|
2979
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
2980
|
+
},
|
|
2981
|
+
harness: {
|
|
2982
|
+
type: "string",
|
|
2983
|
+
enum: [
|
|
2984
|
+
"claude",
|
|
2985
|
+
"codex",
|
|
2986
|
+
"grok",
|
|
2987
|
+
"opencode",
|
|
2988
|
+
"opencode2",
|
|
2989
|
+
"pi",
|
|
2990
|
+
"omp",
|
|
2991
|
+
"dsh",
|
|
2992
|
+
"cline",
|
|
2993
|
+
"hermes",
|
|
2994
|
+
"prime-agent",
|
|
2995
|
+
"gemini",
|
|
2996
|
+
"aider",
|
|
2997
|
+
"kilo"
|
|
2998
|
+
]
|
|
2999
|
+
},
|
|
3000
|
+
model: {
|
|
3001
|
+
type: "string",
|
|
3002
|
+
minLength: 1,
|
|
3003
|
+
maxLength: 300
|
|
3004
|
+
},
|
|
3005
|
+
modelPolicy: {
|
|
3006
|
+
type: "object",
|
|
3007
|
+
properties: {
|
|
3008
|
+
version: {
|
|
3009
|
+
type: "number",
|
|
3010
|
+
enum: [
|
|
3011
|
+
1
|
|
3012
|
+
],
|
|
3013
|
+
default: 1
|
|
3014
|
+
},
|
|
3015
|
+
roles: {
|
|
3016
|
+
type: "object",
|
|
3017
|
+
properties: {
|
|
3018
|
+
subagent: {
|
|
3019
|
+
type: "string",
|
|
3020
|
+
minLength: 1,
|
|
3021
|
+
maxLength: 300,
|
|
3022
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3023
|
+
},
|
|
3024
|
+
fast: {
|
|
3025
|
+
type: "string",
|
|
3026
|
+
minLength: 1,
|
|
3027
|
+
maxLength: 300,
|
|
3028
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3029
|
+
},
|
|
3030
|
+
planning: {
|
|
3031
|
+
type: "string",
|
|
3032
|
+
minLength: 1,
|
|
3033
|
+
maxLength: 300,
|
|
3034
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3035
|
+
},
|
|
3036
|
+
review: {
|
|
3037
|
+
type: "string",
|
|
3038
|
+
minLength: 1,
|
|
3039
|
+
maxLength: 300,
|
|
3040
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3041
|
+
},
|
|
3042
|
+
summary: {
|
|
3043
|
+
type: "string",
|
|
3044
|
+
minLength: 1,
|
|
3045
|
+
maxLength: 300,
|
|
3046
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3047
|
+
},
|
|
3048
|
+
compaction: {
|
|
3049
|
+
type: "string",
|
|
3050
|
+
minLength: 1,
|
|
3051
|
+
maxLength: 300,
|
|
3052
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3053
|
+
},
|
|
3054
|
+
weak: {
|
|
3055
|
+
type: "string",
|
|
3056
|
+
minLength: 1,
|
|
3057
|
+
maxLength: 300,
|
|
3058
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3059
|
+
},
|
|
3060
|
+
editor: {
|
|
3061
|
+
type: "string",
|
|
3062
|
+
minLength: 1,
|
|
3063
|
+
maxLength: 300,
|
|
3064
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3065
|
+
}
|
|
3066
|
+
},
|
|
3067
|
+
additionalProperties: false
|
|
3068
|
+
},
|
|
3069
|
+
allowedModels: {
|
|
3070
|
+
type: "array",
|
|
3071
|
+
items: {
|
|
3072
|
+
type: "string",
|
|
3073
|
+
minLength: 1,
|
|
3074
|
+
maxLength: 300,
|
|
3075
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3076
|
+
},
|
|
3077
|
+
maxItems: 500
|
|
3078
|
+
},
|
|
3079
|
+
aliases: {
|
|
3080
|
+
type: "object",
|
|
3081
|
+
additionalProperties: {
|
|
3082
|
+
type: "string",
|
|
3083
|
+
minLength: 1,
|
|
3084
|
+
maxLength: 300,
|
|
3085
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3086
|
+
}
|
|
3087
|
+
},
|
|
3088
|
+
fallbacks: {
|
|
3089
|
+
type: "object",
|
|
3090
|
+
additionalProperties: {
|
|
3091
|
+
type: "array",
|
|
3092
|
+
items: {
|
|
3093
|
+
type: "string",
|
|
3094
|
+
minLength: 1,
|
|
3095
|
+
maxLength: 300,
|
|
3096
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3097
|
+
},
|
|
3098
|
+
maxItems: 20
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
},
|
|
3102
|
+
additionalProperties: false
|
|
3103
|
+
}
|
|
3104
|
+
},
|
|
3105
|
+
required: [
|
|
3106
|
+
"id",
|
|
3107
|
+
"name",
|
|
3108
|
+
"providerId",
|
|
3109
|
+
"harness",
|
|
3110
|
+
"model"
|
|
3111
|
+
],
|
|
3112
|
+
additionalProperties: false
|
|
3113
|
+
},
|
|
3114
|
+
Profile: {
|
|
3115
|
+
type: "object",
|
|
3116
|
+
properties: {
|
|
3117
|
+
id: {
|
|
3118
|
+
type: "string",
|
|
3119
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
3120
|
+
},
|
|
3121
|
+
name: {
|
|
3122
|
+
type: "string",
|
|
3123
|
+
minLength: 1,
|
|
3124
|
+
maxLength: 200
|
|
3125
|
+
},
|
|
3126
|
+
providerId: {
|
|
3127
|
+
type: "string",
|
|
3128
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
3129
|
+
},
|
|
3130
|
+
harness: {
|
|
3131
|
+
type: "string",
|
|
3132
|
+
enum: [
|
|
3133
|
+
"claude",
|
|
3134
|
+
"codex",
|
|
3135
|
+
"grok",
|
|
3136
|
+
"opencode",
|
|
3137
|
+
"opencode2",
|
|
3138
|
+
"pi",
|
|
3139
|
+
"omp",
|
|
3140
|
+
"dsh",
|
|
3141
|
+
"cline",
|
|
3142
|
+
"hermes",
|
|
3143
|
+
"prime-agent",
|
|
3144
|
+
"gemini",
|
|
3145
|
+
"aider",
|
|
3146
|
+
"kilo"
|
|
3147
|
+
]
|
|
3148
|
+
},
|
|
3149
|
+
model: {
|
|
3150
|
+
type: "string",
|
|
3151
|
+
minLength: 1,
|
|
3152
|
+
maxLength: 300
|
|
3153
|
+
},
|
|
3154
|
+
modelPolicy: {
|
|
3155
|
+
type: "object",
|
|
3156
|
+
properties: {
|
|
3157
|
+
version: {
|
|
3158
|
+
type: "number",
|
|
3159
|
+
enum: [
|
|
3160
|
+
1
|
|
3161
|
+
],
|
|
3162
|
+
default: 1
|
|
3163
|
+
},
|
|
3164
|
+
roles: {
|
|
3165
|
+
type: "object",
|
|
3166
|
+
properties: {
|
|
3167
|
+
subagent: {
|
|
3168
|
+
type: "string",
|
|
3169
|
+
minLength: 1,
|
|
3170
|
+
maxLength: 300,
|
|
3171
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3172
|
+
},
|
|
3173
|
+
fast: {
|
|
3174
|
+
type: "string",
|
|
3175
|
+
minLength: 1,
|
|
3176
|
+
maxLength: 300,
|
|
3177
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3178
|
+
},
|
|
3179
|
+
planning: {
|
|
3180
|
+
type: "string",
|
|
3181
|
+
minLength: 1,
|
|
3182
|
+
maxLength: 300,
|
|
3183
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3184
|
+
},
|
|
3185
|
+
review: {
|
|
3186
|
+
type: "string",
|
|
3187
|
+
minLength: 1,
|
|
3188
|
+
maxLength: 300,
|
|
3189
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3190
|
+
},
|
|
3191
|
+
summary: {
|
|
3192
|
+
type: "string",
|
|
3193
|
+
minLength: 1,
|
|
3194
|
+
maxLength: 300,
|
|
3195
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3196
|
+
},
|
|
3197
|
+
compaction: {
|
|
3198
|
+
type: "string",
|
|
3199
|
+
minLength: 1,
|
|
3200
|
+
maxLength: 300,
|
|
3201
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3202
|
+
},
|
|
3203
|
+
weak: {
|
|
3204
|
+
type: "string",
|
|
3205
|
+
minLength: 1,
|
|
3206
|
+
maxLength: 300,
|
|
3207
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3208
|
+
},
|
|
3209
|
+
editor: {
|
|
3210
|
+
type: "string",
|
|
3211
|
+
minLength: 1,
|
|
3212
|
+
maxLength: 300,
|
|
3213
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3214
|
+
}
|
|
3215
|
+
},
|
|
3216
|
+
additionalProperties: false
|
|
3217
|
+
},
|
|
3218
|
+
allowedModels: {
|
|
3219
|
+
type: "array",
|
|
3220
|
+
items: {
|
|
3221
|
+
type: "string",
|
|
3222
|
+
minLength: 1,
|
|
3223
|
+
maxLength: 300,
|
|
3224
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3225
|
+
},
|
|
3226
|
+
maxItems: 500
|
|
3227
|
+
},
|
|
3228
|
+
aliases: {
|
|
3229
|
+
type: "object",
|
|
3230
|
+
additionalProperties: {
|
|
3231
|
+
type: "string",
|
|
3232
|
+
minLength: 1,
|
|
3233
|
+
maxLength: 300,
|
|
3234
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3235
|
+
}
|
|
3236
|
+
},
|
|
3237
|
+
fallbacks: {
|
|
3238
|
+
type: "object",
|
|
3239
|
+
additionalProperties: {
|
|
3240
|
+
type: "array",
|
|
3241
|
+
items: {
|
|
3242
|
+
type: "string",
|
|
3243
|
+
minLength: 1,
|
|
3244
|
+
maxLength: 300,
|
|
3245
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3246
|
+
},
|
|
3247
|
+
maxItems: 20
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
},
|
|
3251
|
+
additionalProperties: false
|
|
3252
|
+
},
|
|
3253
|
+
version: {
|
|
3254
|
+
type: "integer",
|
|
3255
|
+
exclusiveMinimum: true,
|
|
3256
|
+
minimum: 0
|
|
3257
|
+
},
|
|
3258
|
+
updatedAt: {
|
|
3259
|
+
type: "string"
|
|
3260
|
+
}
|
|
3261
|
+
},
|
|
3262
|
+
required: [
|
|
3263
|
+
"id",
|
|
3264
|
+
"name",
|
|
3265
|
+
"providerId",
|
|
3266
|
+
"harness",
|
|
3267
|
+
"model",
|
|
3268
|
+
"version",
|
|
3269
|
+
"updatedAt"
|
|
3270
|
+
],
|
|
3271
|
+
additionalProperties: false
|
|
3272
|
+
},
|
|
3273
|
+
Model: {
|
|
3274
|
+
type: "object",
|
|
3275
|
+
properties: {
|
|
3276
|
+
id: {
|
|
3277
|
+
type: "string",
|
|
3278
|
+
minLength: 1,
|
|
3279
|
+
maxLength: 300
|
|
3280
|
+
},
|
|
3281
|
+
name: {
|
|
3282
|
+
type: "string",
|
|
3283
|
+
minLength: 1,
|
|
3284
|
+
maxLength: 200
|
|
3285
|
+
},
|
|
3286
|
+
description: {
|
|
3287
|
+
type: "string",
|
|
3288
|
+
maxLength: 8000
|
|
3289
|
+
},
|
|
3290
|
+
available: {
|
|
3291
|
+
type: "boolean"
|
|
3292
|
+
},
|
|
3293
|
+
expiresOn: {
|
|
3294
|
+
type: "string",
|
|
3295
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3296
|
+
},
|
|
3297
|
+
contextWindow: {
|
|
3298
|
+
type: "integer",
|
|
3299
|
+
exclusiveMinimum: true,
|
|
3300
|
+
minimum: 0
|
|
3301
|
+
},
|
|
3302
|
+
maxOutputTokens: {
|
|
3303
|
+
type: "integer",
|
|
3304
|
+
exclusiveMinimum: true,
|
|
3305
|
+
minimum: 0
|
|
3306
|
+
},
|
|
3307
|
+
inputModalities: {
|
|
3308
|
+
type: "array",
|
|
3309
|
+
items: {
|
|
3310
|
+
type: "string",
|
|
3311
|
+
maxLength: 50
|
|
3312
|
+
},
|
|
3313
|
+
maxItems: 20
|
|
3314
|
+
},
|
|
3315
|
+
outputModalities: {
|
|
3316
|
+
type: "array",
|
|
3317
|
+
items: {
|
|
3318
|
+
type: "string",
|
|
3319
|
+
maxLength: 50
|
|
3320
|
+
},
|
|
3321
|
+
maxItems: 20
|
|
3322
|
+
},
|
|
3323
|
+
supportedParameters: {
|
|
3324
|
+
type: "array",
|
|
3325
|
+
items: {
|
|
3326
|
+
type: "string",
|
|
3327
|
+
maxLength: 100
|
|
3328
|
+
},
|
|
3329
|
+
maxItems: 100
|
|
3330
|
+
},
|
|
3331
|
+
reasoningEfforts: {
|
|
3332
|
+
type: "array",
|
|
3333
|
+
items: {
|
|
3334
|
+
type: "string",
|
|
3335
|
+
enum: [
|
|
3336
|
+
"none",
|
|
3337
|
+
"minimal",
|
|
3338
|
+
"low",
|
|
3339
|
+
"medium",
|
|
3340
|
+
"high",
|
|
3341
|
+
"xhigh",
|
|
3342
|
+
"max",
|
|
3343
|
+
"ultra"
|
|
3344
|
+
]
|
|
3345
|
+
},
|
|
3346
|
+
maxItems: 8
|
|
3347
|
+
},
|
|
3348
|
+
supportedGenerationMethods: {
|
|
3349
|
+
type: "array",
|
|
3350
|
+
items: {
|
|
3351
|
+
type: "string",
|
|
3352
|
+
minLength: 1,
|
|
3353
|
+
maxLength: 100
|
|
3354
|
+
},
|
|
3355
|
+
maxItems: 100
|
|
3356
|
+
}
|
|
3357
|
+
},
|
|
3358
|
+
required: [
|
|
3359
|
+
"id",
|
|
3360
|
+
"name"
|
|
3361
|
+
],
|
|
3362
|
+
additionalProperties: false
|
|
3363
|
+
},
|
|
3364
|
+
ModelPolicy: {
|
|
3365
|
+
type: "object",
|
|
3366
|
+
properties: {
|
|
3367
|
+
version: {
|
|
3368
|
+
type: "number",
|
|
3369
|
+
enum: [
|
|
3370
|
+
1
|
|
3371
|
+
],
|
|
3372
|
+
default: 1
|
|
3373
|
+
},
|
|
3374
|
+
roles: {
|
|
3375
|
+
type: "object",
|
|
3376
|
+
properties: {
|
|
3377
|
+
subagent: {
|
|
3378
|
+
type: "string",
|
|
3379
|
+
minLength: 1,
|
|
3380
|
+
maxLength: 300,
|
|
3381
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3382
|
+
},
|
|
3383
|
+
fast: {
|
|
3384
|
+
type: "string",
|
|
3385
|
+
minLength: 1,
|
|
3386
|
+
maxLength: 300,
|
|
3387
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3388
|
+
},
|
|
3389
|
+
planning: {
|
|
3390
|
+
type: "string",
|
|
3391
|
+
minLength: 1,
|
|
3392
|
+
maxLength: 300,
|
|
3393
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3394
|
+
},
|
|
3395
|
+
review: {
|
|
3396
|
+
type: "string",
|
|
3397
|
+
minLength: 1,
|
|
3398
|
+
maxLength: 300,
|
|
3399
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3400
|
+
},
|
|
3401
|
+
summary: {
|
|
3402
|
+
type: "string",
|
|
3403
|
+
minLength: 1,
|
|
3404
|
+
maxLength: 300,
|
|
3405
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3406
|
+
},
|
|
3407
|
+
compaction: {
|
|
3408
|
+
type: "string",
|
|
3409
|
+
minLength: 1,
|
|
3410
|
+
maxLength: 300,
|
|
3411
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3412
|
+
},
|
|
3413
|
+
weak: {
|
|
3414
|
+
type: "string",
|
|
3415
|
+
minLength: 1,
|
|
3416
|
+
maxLength: 300,
|
|
3417
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3418
|
+
},
|
|
3419
|
+
editor: {
|
|
3420
|
+
type: "string",
|
|
3421
|
+
minLength: 1,
|
|
3422
|
+
maxLength: 300,
|
|
3423
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3424
|
+
}
|
|
3425
|
+
},
|
|
3426
|
+
additionalProperties: false
|
|
3427
|
+
},
|
|
3428
|
+
allowedModels: {
|
|
3429
|
+
type: "array",
|
|
3430
|
+
items: {
|
|
3431
|
+
type: "string",
|
|
3432
|
+
minLength: 1,
|
|
3433
|
+
maxLength: 300,
|
|
3434
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3435
|
+
},
|
|
3436
|
+
maxItems: 500
|
|
3437
|
+
},
|
|
3438
|
+
aliases: {
|
|
3439
|
+
type: "object",
|
|
3440
|
+
additionalProperties: {
|
|
3441
|
+
type: "string",
|
|
3442
|
+
minLength: 1,
|
|
3443
|
+
maxLength: 300,
|
|
3444
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3445
|
+
}
|
|
3446
|
+
},
|
|
3447
|
+
fallbacks: {
|
|
3448
|
+
type: "object",
|
|
3449
|
+
additionalProperties: {
|
|
3450
|
+
type: "array",
|
|
3451
|
+
items: {
|
|
3452
|
+
type: "string",
|
|
3453
|
+
minLength: 1,
|
|
3454
|
+
maxLength: 300,
|
|
3455
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3456
|
+
},
|
|
3457
|
+
maxItems: 20
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
},
|
|
3461
|
+
additionalProperties: false
|
|
3462
|
+
},
|
|
3463
|
+
RoutingEvent: {
|
|
3464
|
+
type: "object",
|
|
3465
|
+
properties: {
|
|
3466
|
+
at: {
|
|
3467
|
+
type: "string",
|
|
3468
|
+
format: "date-time"
|
|
3469
|
+
},
|
|
3470
|
+
requestId: {
|
|
3471
|
+
type: "string",
|
|
3472
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
|
3473
|
+
},
|
|
3474
|
+
requestedModel: {
|
|
3475
|
+
type: "string",
|
|
3476
|
+
minLength: 1,
|
|
3477
|
+
maxLength: 300,
|
|
3478
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3479
|
+
},
|
|
3480
|
+
resolvedModel: {
|
|
3481
|
+
type: "string",
|
|
3482
|
+
minLength: 1,
|
|
3483
|
+
maxLength: 300,
|
|
3484
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3485
|
+
},
|
|
3486
|
+
reportedModel: {
|
|
3487
|
+
type: "string",
|
|
3488
|
+
minLength: 1,
|
|
3489
|
+
maxLength: 300,
|
|
3490
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
3491
|
+
},
|
|
3492
|
+
reasoningEffort: {
|
|
3493
|
+
type: "string",
|
|
3494
|
+
enum: [
|
|
3495
|
+
"none",
|
|
3496
|
+
"minimal",
|
|
3497
|
+
"low",
|
|
3498
|
+
"medium",
|
|
3499
|
+
"high",
|
|
3500
|
+
"xhigh",
|
|
3501
|
+
"max",
|
|
3502
|
+
"ultra"
|
|
3503
|
+
]
|
|
3504
|
+
},
|
|
3505
|
+
decision: {
|
|
3506
|
+
type: "string",
|
|
3507
|
+
enum: [
|
|
3508
|
+
"allow",
|
|
3509
|
+
"alias",
|
|
3510
|
+
"reject",
|
|
3511
|
+
"fallback"
|
|
3512
|
+
]
|
|
3513
|
+
},
|
|
3514
|
+
role: {
|
|
3515
|
+
type: "string",
|
|
3516
|
+
enum: [
|
|
3517
|
+
"main",
|
|
3518
|
+
"subagent",
|
|
3519
|
+
"fast",
|
|
3520
|
+
"planning",
|
|
3521
|
+
"review",
|
|
3522
|
+
"summary",
|
|
3523
|
+
"compaction",
|
|
3524
|
+
"weak",
|
|
3525
|
+
"editor"
|
|
3526
|
+
]
|
|
3527
|
+
},
|
|
3528
|
+
reason: {
|
|
3529
|
+
type: "string",
|
|
3530
|
+
pattern: "^[a-z][a-z0-9_]{0,63}$"
|
|
3531
|
+
},
|
|
3532
|
+
upstreamStatus: {
|
|
3533
|
+
type: "integer",
|
|
3534
|
+
minimum: 100,
|
|
3535
|
+
maximum: 599
|
|
3536
|
+
}
|
|
3537
|
+
},
|
|
3538
|
+
required: [
|
|
3539
|
+
"at",
|
|
3540
|
+
"requestId",
|
|
3541
|
+
"requestedModel",
|
|
3542
|
+
"decision"
|
|
3543
|
+
],
|
|
3544
|
+
additionalProperties: false
|
|
3545
|
+
},
|
|
3546
|
+
ModelPage: {
|
|
3547
|
+
type: "object",
|
|
3548
|
+
properties: {
|
|
3549
|
+
data: {
|
|
3550
|
+
type: "array",
|
|
3551
|
+
items: {
|
|
3552
|
+
type: "object",
|
|
3553
|
+
properties: {
|
|
3554
|
+
id: {
|
|
3555
|
+
type: "string",
|
|
3556
|
+
minLength: 1,
|
|
3557
|
+
maxLength: 300
|
|
3558
|
+
},
|
|
3559
|
+
name: {
|
|
3560
|
+
type: "string",
|
|
3561
|
+
minLength: 1,
|
|
3562
|
+
maxLength: 200
|
|
3563
|
+
},
|
|
3564
|
+
description: {
|
|
3565
|
+
type: "string",
|
|
3566
|
+
maxLength: 8000
|
|
3567
|
+
},
|
|
3568
|
+
available: {
|
|
3569
|
+
type: "boolean"
|
|
3570
|
+
},
|
|
3571
|
+
expiresOn: {
|
|
3572
|
+
type: "string",
|
|
3573
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3574
|
+
},
|
|
3575
|
+
contextWindow: {
|
|
3576
|
+
type: "integer",
|
|
3577
|
+
exclusiveMinimum: true,
|
|
3578
|
+
minimum: 0
|
|
3579
|
+
},
|
|
3580
|
+
maxOutputTokens: {
|
|
3581
|
+
type: "integer",
|
|
3582
|
+
exclusiveMinimum: true,
|
|
3583
|
+
minimum: 0
|
|
3584
|
+
},
|
|
3585
|
+
inputModalities: {
|
|
3586
|
+
type: "array",
|
|
3587
|
+
items: {
|
|
3588
|
+
type: "string",
|
|
3589
|
+
maxLength: 50
|
|
3590
|
+
},
|
|
3591
|
+
maxItems: 20
|
|
3592
|
+
},
|
|
3593
|
+
outputModalities: {
|
|
3594
|
+
type: "array",
|
|
3595
|
+
items: {
|
|
3596
|
+
type: "string",
|
|
3597
|
+
maxLength: 50
|
|
3598
|
+
},
|
|
3599
|
+
maxItems: 20
|
|
3600
|
+
},
|
|
3601
|
+
supportedParameters: {
|
|
3602
|
+
type: "array",
|
|
3603
|
+
items: {
|
|
3604
|
+
type: "string",
|
|
3605
|
+
maxLength: 100
|
|
3606
|
+
},
|
|
3607
|
+
maxItems: 100
|
|
3608
|
+
},
|
|
3609
|
+
reasoningEfforts: {
|
|
3610
|
+
type: "array",
|
|
3611
|
+
items: {
|
|
3612
|
+
type: "string",
|
|
3613
|
+
enum: [
|
|
3614
|
+
"none",
|
|
3615
|
+
"minimal",
|
|
3616
|
+
"low",
|
|
3617
|
+
"medium",
|
|
3618
|
+
"high",
|
|
3619
|
+
"xhigh",
|
|
3620
|
+
"max",
|
|
3621
|
+
"ultra"
|
|
3622
|
+
]
|
|
3623
|
+
},
|
|
3624
|
+
maxItems: 8
|
|
3625
|
+
},
|
|
3626
|
+
supportedGenerationMethods: {
|
|
3627
|
+
type: "array",
|
|
3628
|
+
items: {
|
|
3629
|
+
type: "string",
|
|
3630
|
+
minLength: 1,
|
|
3631
|
+
maxLength: 100
|
|
3632
|
+
},
|
|
3633
|
+
maxItems: 100
|
|
3634
|
+
},
|
|
3635
|
+
codingEligible: {
|
|
3636
|
+
type: "boolean"
|
|
3637
|
+
},
|
|
3638
|
+
expired: {
|
|
3639
|
+
type: "boolean"
|
|
3640
|
+
}
|
|
3641
|
+
},
|
|
3642
|
+
required: [
|
|
3643
|
+
"id",
|
|
3644
|
+
"name",
|
|
3645
|
+
"codingEligible",
|
|
3646
|
+
"expired"
|
|
3647
|
+
],
|
|
3648
|
+
additionalProperties: false
|
|
3649
|
+
}
|
|
3650
|
+
},
|
|
3651
|
+
total: {
|
|
3652
|
+
type: "integer"
|
|
3653
|
+
},
|
|
3654
|
+
limit: {
|
|
3655
|
+
type: "integer"
|
|
3656
|
+
},
|
|
3657
|
+
offset: {
|
|
3658
|
+
type: "integer"
|
|
3659
|
+
},
|
|
3660
|
+
refreshedAt: {
|
|
3661
|
+
type: "string"
|
|
3662
|
+
},
|
|
3663
|
+
source: {
|
|
3664
|
+
type: "string",
|
|
3665
|
+
enum: [
|
|
3666
|
+
"remote",
|
|
3667
|
+
"manual"
|
|
3668
|
+
]
|
|
3669
|
+
}
|
|
3670
|
+
},
|
|
3671
|
+
required: [
|
|
3672
|
+
"data",
|
|
3673
|
+
"total",
|
|
3674
|
+
"limit",
|
|
3675
|
+
"offset",
|
|
3676
|
+
"refreshedAt",
|
|
3677
|
+
"source"
|
|
3678
|
+
],
|
|
3679
|
+
additionalProperties: false
|
|
3680
|
+
},
|
|
3681
|
+
Catalog: {
|
|
3682
|
+
type: "object",
|
|
3683
|
+
properties: {
|
|
3684
|
+
models: {
|
|
3685
|
+
type: "array",
|
|
3686
|
+
items: {
|
|
3687
|
+
type: "object",
|
|
3688
|
+
properties: {
|
|
3689
|
+
id: {
|
|
3690
|
+
type: "string",
|
|
3691
|
+
minLength: 1,
|
|
3692
|
+
maxLength: 300
|
|
3693
|
+
},
|
|
3694
|
+
name: {
|
|
3695
|
+
type: "string",
|
|
3696
|
+
minLength: 1,
|
|
3697
|
+
maxLength: 200
|
|
3698
|
+
},
|
|
3699
|
+
description: {
|
|
3700
|
+
type: "string",
|
|
3701
|
+
maxLength: 8000
|
|
3702
|
+
},
|
|
3703
|
+
available: {
|
|
3704
|
+
type: "boolean"
|
|
3705
|
+
},
|
|
3706
|
+
expiresOn: {
|
|
3707
|
+
type: "string",
|
|
3708
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3709
|
+
},
|
|
3710
|
+
contextWindow: {
|
|
3711
|
+
type: "integer",
|
|
3712
|
+
exclusiveMinimum: true,
|
|
3713
|
+
minimum: 0
|
|
3714
|
+
},
|
|
3715
|
+
maxOutputTokens: {
|
|
3716
|
+
type: "integer",
|
|
3717
|
+
exclusiveMinimum: true,
|
|
3718
|
+
minimum: 0
|
|
3719
|
+
},
|
|
3720
|
+
inputModalities: {
|
|
3721
|
+
type: "array",
|
|
3722
|
+
items: {
|
|
3723
|
+
type: "string",
|
|
3724
|
+
maxLength: 50
|
|
3725
|
+
},
|
|
3726
|
+
maxItems: 20
|
|
3727
|
+
},
|
|
3728
|
+
outputModalities: {
|
|
3729
|
+
type: "array",
|
|
3730
|
+
items: {
|
|
3731
|
+
type: "string",
|
|
3732
|
+
maxLength: 50
|
|
3733
|
+
},
|
|
3734
|
+
maxItems: 20
|
|
3735
|
+
},
|
|
3736
|
+
supportedParameters: {
|
|
3737
|
+
type: "array",
|
|
3738
|
+
items: {
|
|
3739
|
+
type: "string",
|
|
3740
|
+
maxLength: 100
|
|
3741
|
+
},
|
|
3742
|
+
maxItems: 100
|
|
3743
|
+
},
|
|
3744
|
+
reasoningEfforts: {
|
|
3745
|
+
type: "array",
|
|
3746
|
+
items: {
|
|
3747
|
+
type: "string",
|
|
3748
|
+
enum: [
|
|
3749
|
+
"none",
|
|
3750
|
+
"minimal",
|
|
3751
|
+
"low",
|
|
3752
|
+
"medium",
|
|
3753
|
+
"high",
|
|
3754
|
+
"xhigh",
|
|
3755
|
+
"max",
|
|
3756
|
+
"ultra"
|
|
3757
|
+
]
|
|
3758
|
+
},
|
|
3759
|
+
maxItems: 8
|
|
3760
|
+
},
|
|
3761
|
+
supportedGenerationMethods: {
|
|
3762
|
+
type: "array",
|
|
3763
|
+
items: {
|
|
3764
|
+
type: "string",
|
|
3765
|
+
minLength: 1,
|
|
3766
|
+
maxLength: 100
|
|
3767
|
+
},
|
|
3768
|
+
maxItems: 100
|
|
3769
|
+
}
|
|
3770
|
+
},
|
|
3771
|
+
required: [
|
|
3772
|
+
"id",
|
|
3773
|
+
"name"
|
|
3774
|
+
],
|
|
3775
|
+
additionalProperties: false
|
|
3776
|
+
}
|
|
3777
|
+
},
|
|
3778
|
+
refreshedAt: {
|
|
3779
|
+
type: "string"
|
|
3780
|
+
},
|
|
3781
|
+
source: {
|
|
3782
|
+
type: "string",
|
|
3783
|
+
enum: [
|
|
3784
|
+
"remote",
|
|
3785
|
+
"manual"
|
|
3786
|
+
]
|
|
3787
|
+
}
|
|
3788
|
+
},
|
|
3789
|
+
required: [
|
|
3790
|
+
"models",
|
|
3791
|
+
"refreshedAt",
|
|
3792
|
+
"source"
|
|
3793
|
+
],
|
|
3794
|
+
additionalProperties: false
|
|
3795
|
+
},
|
|
3796
|
+
LaunchPlan: {
|
|
3797
|
+
type: "object",
|
|
3798
|
+
properties: {
|
|
3799
|
+
provider: {
|
|
3800
|
+
type: "object",
|
|
3801
|
+
properties: {
|
|
3802
|
+
id: {
|
|
3803
|
+
type: "string",
|
|
3804
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
3805
|
+
},
|
|
3806
|
+
name: {
|
|
3807
|
+
type: "string",
|
|
3808
|
+
minLength: 1,
|
|
3809
|
+
maxLength: 200
|
|
3810
|
+
},
|
|
3811
|
+
baseUrl: {
|
|
3812
|
+
type: "string",
|
|
3813
|
+
maxLength: 2000
|
|
3814
|
+
},
|
|
3815
|
+
protocol: {
|
|
3816
|
+
type: "string",
|
|
3817
|
+
enum: [
|
|
3818
|
+
"anthropic-messages",
|
|
3819
|
+
"openai-responses",
|
|
3820
|
+
"openai-chat",
|
|
3821
|
+
"gemini-generate-content"
|
|
3822
|
+
]
|
|
3823
|
+
},
|
|
3824
|
+
credentialEnv: {
|
|
3825
|
+
type: "string",
|
|
3826
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
3827
|
+
},
|
|
3828
|
+
authStyle: {
|
|
3829
|
+
type: "string",
|
|
3830
|
+
enum: [
|
|
3831
|
+
"bearer",
|
|
3832
|
+
"x-api-key",
|
|
3833
|
+
"api-key"
|
|
3834
|
+
],
|
|
3835
|
+
default: "bearer"
|
|
3836
|
+
},
|
|
3837
|
+
catalogBaseUrl: {
|
|
3838
|
+
type: "string",
|
|
3839
|
+
maxLength: 2000
|
|
3840
|
+
},
|
|
3841
|
+
catalogFormat: {
|
|
3842
|
+
type: "string",
|
|
3843
|
+
enum: [
|
|
3844
|
+
"openai",
|
|
3845
|
+
"ollama",
|
|
3846
|
+
"mistral",
|
|
3847
|
+
"together",
|
|
3848
|
+
"fireworks",
|
|
3849
|
+
"dashscope",
|
|
3850
|
+
"gemini",
|
|
3851
|
+
"none"
|
|
3852
|
+
]
|
|
3853
|
+
},
|
|
3854
|
+
catalogAuthStyle: {
|
|
3855
|
+
type: "string",
|
|
3856
|
+
enum: [
|
|
3857
|
+
"bearer",
|
|
3858
|
+
"x-api-key",
|
|
3859
|
+
"api-key",
|
|
3860
|
+
"none"
|
|
3861
|
+
]
|
|
3862
|
+
},
|
|
3863
|
+
catalogCredentialEnv: {
|
|
3864
|
+
type: "string",
|
|
3865
|
+
pattern: "^SWITCHER_PROVIDER_[A-Z0-9_]+$"
|
|
3866
|
+
},
|
|
3867
|
+
catalogAccountId: {
|
|
3868
|
+
type: "string",
|
|
3869
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
|
3870
|
+
},
|
|
3871
|
+
modelsPath: {
|
|
3872
|
+
type: "string",
|
|
3873
|
+
pattern: "^[a-zA-Z0-9_/-]+$",
|
|
3874
|
+
maxLength: 200,
|
|
3875
|
+
default: "models"
|
|
3876
|
+
},
|
|
3877
|
+
manualModels: {
|
|
3878
|
+
type: "array",
|
|
3879
|
+
items: {
|
|
3880
|
+
type: "object",
|
|
3881
|
+
properties: {
|
|
3882
|
+
id: {
|
|
3883
|
+
type: "string",
|
|
3884
|
+
minLength: 1,
|
|
3885
|
+
maxLength: 300
|
|
3886
|
+
},
|
|
3887
|
+
name: {
|
|
3888
|
+
type: "string",
|
|
3889
|
+
minLength: 1,
|
|
3890
|
+
maxLength: 200
|
|
3891
|
+
},
|
|
3892
|
+
description: {
|
|
3893
|
+
type: "string",
|
|
3894
|
+
maxLength: 8000
|
|
3895
|
+
},
|
|
3896
|
+
available: {
|
|
3897
|
+
type: "boolean"
|
|
3898
|
+
},
|
|
3899
|
+
expiresOn: {
|
|
3900
|
+
type: "string",
|
|
3901
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3902
|
+
},
|
|
3903
|
+
contextWindow: {
|
|
3904
|
+
type: "integer",
|
|
3905
|
+
exclusiveMinimum: true,
|
|
3906
|
+
minimum: 0
|
|
3907
|
+
},
|
|
3908
|
+
maxOutputTokens: {
|
|
3909
|
+
type: "integer",
|
|
3910
|
+
exclusiveMinimum: true,
|
|
3911
|
+
minimum: 0
|
|
3912
|
+
},
|
|
3913
|
+
inputModalities: {
|
|
3914
|
+
type: "array",
|
|
3915
|
+
items: {
|
|
3916
|
+
type: "string",
|
|
3917
|
+
maxLength: 50
|
|
3918
|
+
},
|
|
3919
|
+
maxItems: 20
|
|
3920
|
+
},
|
|
3921
|
+
outputModalities: {
|
|
3922
|
+
type: "array",
|
|
3923
|
+
items: {
|
|
3924
|
+
type: "string",
|
|
3925
|
+
maxLength: 50
|
|
3926
|
+
},
|
|
3927
|
+
maxItems: 20
|
|
3928
|
+
},
|
|
3929
|
+
supportedParameters: {
|
|
3930
|
+
type: "array",
|
|
3931
|
+
items: {
|
|
3932
|
+
type: "string",
|
|
3933
|
+
maxLength: 100
|
|
3934
|
+
},
|
|
3935
|
+
maxItems: 100
|
|
3936
|
+
},
|
|
3937
|
+
reasoningEfforts: {
|
|
3938
|
+
type: "array",
|
|
3939
|
+
items: {
|
|
3940
|
+
type: "string",
|
|
3941
|
+
enum: [
|
|
3942
|
+
"none",
|
|
3943
|
+
"minimal",
|
|
3944
|
+
"low",
|
|
3945
|
+
"medium",
|
|
3946
|
+
"high",
|
|
3947
|
+
"xhigh",
|
|
3948
|
+
"max",
|
|
3949
|
+
"ultra"
|
|
3950
|
+
]
|
|
3951
|
+
},
|
|
3952
|
+
maxItems: 8
|
|
3953
|
+
},
|
|
3954
|
+
supportedGenerationMethods: {
|
|
3955
|
+
type: "array",
|
|
3956
|
+
items: {
|
|
3957
|
+
type: "string",
|
|
3958
|
+
minLength: 1,
|
|
3959
|
+
maxLength: 100
|
|
3960
|
+
},
|
|
3961
|
+
maxItems: 100
|
|
3962
|
+
}
|
|
3963
|
+
},
|
|
3964
|
+
required: [
|
|
3965
|
+
"id",
|
|
3966
|
+
"name"
|
|
3967
|
+
],
|
|
3968
|
+
additionalProperties: false
|
|
3969
|
+
},
|
|
3970
|
+
maxItems: 1e4,
|
|
3971
|
+
default: []
|
|
3972
|
+
},
|
|
3973
|
+
additionalModels: {
|
|
3974
|
+
type: "array",
|
|
3975
|
+
items: {
|
|
3976
|
+
type: "object",
|
|
3977
|
+
properties: {
|
|
3978
|
+
id: {
|
|
3979
|
+
type: "string",
|
|
3980
|
+
minLength: 1,
|
|
3981
|
+
maxLength: 300
|
|
3982
|
+
},
|
|
3983
|
+
name: {
|
|
3984
|
+
type: "string",
|
|
3985
|
+
minLength: 1,
|
|
3986
|
+
maxLength: 200
|
|
3987
|
+
},
|
|
3988
|
+
description: {
|
|
3989
|
+
type: "string",
|
|
3990
|
+
maxLength: 8000
|
|
3991
|
+
},
|
|
3992
|
+
available: {
|
|
3993
|
+
type: "boolean"
|
|
3994
|
+
},
|
|
3995
|
+
expiresOn: {
|
|
3996
|
+
type: "string",
|
|
3997
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
3998
|
+
},
|
|
3999
|
+
contextWindow: {
|
|
4000
|
+
type: "integer",
|
|
4001
|
+
exclusiveMinimum: true,
|
|
4002
|
+
minimum: 0
|
|
4003
|
+
},
|
|
4004
|
+
maxOutputTokens: {
|
|
4005
|
+
type: "integer",
|
|
4006
|
+
exclusiveMinimum: true,
|
|
4007
|
+
minimum: 0
|
|
4008
|
+
},
|
|
4009
|
+
inputModalities: {
|
|
4010
|
+
type: "array",
|
|
4011
|
+
items: {
|
|
4012
|
+
type: "string",
|
|
4013
|
+
maxLength: 50
|
|
4014
|
+
},
|
|
4015
|
+
maxItems: 20
|
|
4016
|
+
},
|
|
4017
|
+
outputModalities: {
|
|
4018
|
+
type: "array",
|
|
4019
|
+
items: {
|
|
4020
|
+
type: "string",
|
|
4021
|
+
maxLength: 50
|
|
4022
|
+
},
|
|
4023
|
+
maxItems: 20
|
|
4024
|
+
},
|
|
4025
|
+
supportedParameters: {
|
|
4026
|
+
type: "array",
|
|
4027
|
+
items: {
|
|
4028
|
+
type: "string",
|
|
4029
|
+
maxLength: 100
|
|
4030
|
+
},
|
|
4031
|
+
maxItems: 100
|
|
4032
|
+
},
|
|
4033
|
+
reasoningEfforts: {
|
|
4034
|
+
type: "array",
|
|
4035
|
+
items: {
|
|
4036
|
+
type: "string",
|
|
4037
|
+
enum: [
|
|
4038
|
+
"none",
|
|
4039
|
+
"minimal",
|
|
4040
|
+
"low",
|
|
4041
|
+
"medium",
|
|
4042
|
+
"high",
|
|
4043
|
+
"xhigh",
|
|
4044
|
+
"max",
|
|
4045
|
+
"ultra"
|
|
4046
|
+
]
|
|
4047
|
+
},
|
|
4048
|
+
maxItems: 8
|
|
4049
|
+
},
|
|
4050
|
+
supportedGenerationMethods: {
|
|
4051
|
+
type: "array",
|
|
4052
|
+
items: {
|
|
4053
|
+
type: "string",
|
|
4054
|
+
minLength: 1,
|
|
4055
|
+
maxLength: 100
|
|
4056
|
+
},
|
|
4057
|
+
maxItems: 100
|
|
4058
|
+
}
|
|
4059
|
+
},
|
|
4060
|
+
required: [
|
|
4061
|
+
"id",
|
|
4062
|
+
"name"
|
|
4063
|
+
],
|
|
4064
|
+
additionalProperties: false
|
|
4065
|
+
},
|
|
4066
|
+
maxItems: 1e4
|
|
4067
|
+
},
|
|
4068
|
+
version: {
|
|
4069
|
+
type: "integer",
|
|
4070
|
+
exclusiveMinimum: true,
|
|
4071
|
+
minimum: 0
|
|
4072
|
+
},
|
|
4073
|
+
updatedAt: {
|
|
4074
|
+
type: "string"
|
|
4075
|
+
}
|
|
4076
|
+
},
|
|
4077
|
+
required: [
|
|
4078
|
+
"id",
|
|
4079
|
+
"name",
|
|
4080
|
+
"baseUrl",
|
|
4081
|
+
"protocol",
|
|
4082
|
+
"version",
|
|
4083
|
+
"updatedAt"
|
|
4084
|
+
],
|
|
4085
|
+
additionalProperties: false
|
|
4086
|
+
},
|
|
4087
|
+
profile: {
|
|
4088
|
+
type: "object",
|
|
4089
|
+
properties: {
|
|
4090
|
+
id: {
|
|
4091
|
+
type: "string",
|
|
4092
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4093
|
+
},
|
|
4094
|
+
name: {
|
|
4095
|
+
type: "string",
|
|
4096
|
+
minLength: 1,
|
|
4097
|
+
maxLength: 200
|
|
4098
|
+
},
|
|
4099
|
+
providerId: {
|
|
4100
|
+
type: "string",
|
|
4101
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4102
|
+
},
|
|
4103
|
+
harness: {
|
|
4104
|
+
type: "string",
|
|
4105
|
+
enum: [
|
|
4106
|
+
"claude",
|
|
4107
|
+
"codex",
|
|
4108
|
+
"grok",
|
|
4109
|
+
"opencode",
|
|
4110
|
+
"opencode2",
|
|
4111
|
+
"pi",
|
|
4112
|
+
"omp",
|
|
4113
|
+
"dsh",
|
|
4114
|
+
"cline",
|
|
4115
|
+
"hermes",
|
|
4116
|
+
"prime-agent",
|
|
4117
|
+
"gemini",
|
|
4118
|
+
"aider",
|
|
4119
|
+
"kilo"
|
|
4120
|
+
]
|
|
4121
|
+
},
|
|
4122
|
+
model: {
|
|
4123
|
+
type: "string",
|
|
4124
|
+
minLength: 1,
|
|
4125
|
+
maxLength: 300
|
|
4126
|
+
},
|
|
4127
|
+
modelPolicy: {
|
|
4128
|
+
type: "object",
|
|
4129
|
+
properties: {
|
|
4130
|
+
version: {
|
|
4131
|
+
type: "number",
|
|
4132
|
+
enum: [
|
|
4133
|
+
1
|
|
4134
|
+
],
|
|
4135
|
+
default: 1
|
|
4136
|
+
},
|
|
4137
|
+
roles: {
|
|
4138
|
+
type: "object",
|
|
4139
|
+
properties: {
|
|
4140
|
+
subagent: {
|
|
4141
|
+
type: "string",
|
|
4142
|
+
minLength: 1,
|
|
4143
|
+
maxLength: 300,
|
|
4144
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4145
|
+
},
|
|
4146
|
+
fast: {
|
|
4147
|
+
type: "string",
|
|
4148
|
+
minLength: 1,
|
|
4149
|
+
maxLength: 300,
|
|
4150
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4151
|
+
},
|
|
4152
|
+
planning: {
|
|
4153
|
+
type: "string",
|
|
4154
|
+
minLength: 1,
|
|
4155
|
+
maxLength: 300,
|
|
4156
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4157
|
+
},
|
|
4158
|
+
review: {
|
|
4159
|
+
type: "string",
|
|
4160
|
+
minLength: 1,
|
|
4161
|
+
maxLength: 300,
|
|
4162
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4163
|
+
},
|
|
4164
|
+
summary: {
|
|
4165
|
+
type: "string",
|
|
4166
|
+
minLength: 1,
|
|
4167
|
+
maxLength: 300,
|
|
4168
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4169
|
+
},
|
|
4170
|
+
compaction: {
|
|
4171
|
+
type: "string",
|
|
4172
|
+
minLength: 1,
|
|
4173
|
+
maxLength: 300,
|
|
4174
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4175
|
+
},
|
|
4176
|
+
weak: {
|
|
4177
|
+
type: "string",
|
|
4178
|
+
minLength: 1,
|
|
4179
|
+
maxLength: 300,
|
|
4180
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4181
|
+
},
|
|
4182
|
+
editor: {
|
|
4183
|
+
type: "string",
|
|
4184
|
+
minLength: 1,
|
|
4185
|
+
maxLength: 300,
|
|
4186
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4187
|
+
}
|
|
4188
|
+
},
|
|
4189
|
+
additionalProperties: false
|
|
4190
|
+
},
|
|
4191
|
+
allowedModels: {
|
|
4192
|
+
type: "array",
|
|
4193
|
+
items: {
|
|
4194
|
+
type: "string",
|
|
4195
|
+
minLength: 1,
|
|
4196
|
+
maxLength: 300,
|
|
4197
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4198
|
+
},
|
|
4199
|
+
maxItems: 500
|
|
4200
|
+
},
|
|
4201
|
+
aliases: {
|
|
4202
|
+
type: "object",
|
|
4203
|
+
additionalProperties: {
|
|
4204
|
+
type: "string",
|
|
4205
|
+
minLength: 1,
|
|
4206
|
+
maxLength: 300,
|
|
4207
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4208
|
+
}
|
|
4209
|
+
},
|
|
4210
|
+
fallbacks: {
|
|
4211
|
+
type: "object",
|
|
4212
|
+
additionalProperties: {
|
|
4213
|
+
type: "array",
|
|
4214
|
+
items: {
|
|
4215
|
+
type: "string",
|
|
4216
|
+
minLength: 1,
|
|
4217
|
+
maxLength: 300,
|
|
4218
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4219
|
+
},
|
|
4220
|
+
maxItems: 20
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
},
|
|
4224
|
+
additionalProperties: false
|
|
4225
|
+
},
|
|
4226
|
+
version: {
|
|
4227
|
+
type: "integer",
|
|
4228
|
+
exclusiveMinimum: true,
|
|
4229
|
+
minimum: 0
|
|
4230
|
+
},
|
|
4231
|
+
updatedAt: {
|
|
4232
|
+
type: "string"
|
|
4233
|
+
}
|
|
4234
|
+
},
|
|
4235
|
+
required: [
|
|
4236
|
+
"id",
|
|
4237
|
+
"name",
|
|
4238
|
+
"providerId",
|
|
4239
|
+
"harness",
|
|
4240
|
+
"model",
|
|
4241
|
+
"version",
|
|
4242
|
+
"updatedAt"
|
|
4243
|
+
],
|
|
4244
|
+
additionalProperties: false
|
|
4245
|
+
},
|
|
4246
|
+
catalog: {
|
|
4247
|
+
type: "object",
|
|
4248
|
+
properties: {
|
|
4249
|
+
models: {
|
|
4250
|
+
type: "array",
|
|
4251
|
+
items: {
|
|
4252
|
+
type: "object",
|
|
4253
|
+
properties: {
|
|
4254
|
+
id: {
|
|
4255
|
+
type: "string",
|
|
4256
|
+
minLength: 1,
|
|
4257
|
+
maxLength: 300
|
|
4258
|
+
},
|
|
4259
|
+
name: {
|
|
4260
|
+
type: "string",
|
|
4261
|
+
minLength: 1,
|
|
4262
|
+
maxLength: 200
|
|
4263
|
+
},
|
|
4264
|
+
description: {
|
|
4265
|
+
type: "string",
|
|
4266
|
+
maxLength: 8000
|
|
4267
|
+
},
|
|
4268
|
+
available: {
|
|
4269
|
+
type: "boolean"
|
|
4270
|
+
},
|
|
4271
|
+
expiresOn: {
|
|
4272
|
+
type: "string",
|
|
4273
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
4274
|
+
},
|
|
4275
|
+
contextWindow: {
|
|
4276
|
+
type: "integer",
|
|
4277
|
+
exclusiveMinimum: true,
|
|
4278
|
+
minimum: 0
|
|
4279
|
+
},
|
|
4280
|
+
maxOutputTokens: {
|
|
4281
|
+
type: "integer",
|
|
4282
|
+
exclusiveMinimum: true,
|
|
4283
|
+
minimum: 0
|
|
4284
|
+
},
|
|
4285
|
+
inputModalities: {
|
|
4286
|
+
type: "array",
|
|
4287
|
+
items: {
|
|
4288
|
+
type: "string",
|
|
4289
|
+
maxLength: 50
|
|
4290
|
+
},
|
|
4291
|
+
maxItems: 20
|
|
4292
|
+
},
|
|
4293
|
+
outputModalities: {
|
|
4294
|
+
type: "array",
|
|
4295
|
+
items: {
|
|
4296
|
+
type: "string",
|
|
4297
|
+
maxLength: 50
|
|
4298
|
+
},
|
|
4299
|
+
maxItems: 20
|
|
4300
|
+
},
|
|
4301
|
+
supportedParameters: {
|
|
4302
|
+
type: "array",
|
|
4303
|
+
items: {
|
|
4304
|
+
type: "string",
|
|
4305
|
+
maxLength: 100
|
|
4306
|
+
},
|
|
4307
|
+
maxItems: 100
|
|
4308
|
+
},
|
|
4309
|
+
reasoningEfforts: {
|
|
4310
|
+
type: "array",
|
|
4311
|
+
items: {
|
|
4312
|
+
type: "string",
|
|
4313
|
+
enum: [
|
|
4314
|
+
"none",
|
|
4315
|
+
"minimal",
|
|
4316
|
+
"low",
|
|
4317
|
+
"medium",
|
|
4318
|
+
"high",
|
|
4319
|
+
"xhigh",
|
|
4320
|
+
"max",
|
|
4321
|
+
"ultra"
|
|
4322
|
+
]
|
|
4323
|
+
},
|
|
4324
|
+
maxItems: 8
|
|
4325
|
+
},
|
|
4326
|
+
supportedGenerationMethods: {
|
|
4327
|
+
type: "array",
|
|
4328
|
+
items: {
|
|
4329
|
+
type: "string",
|
|
4330
|
+
minLength: 1,
|
|
4331
|
+
maxLength: 100
|
|
4332
|
+
},
|
|
4333
|
+
maxItems: 100
|
|
4334
|
+
}
|
|
4335
|
+
},
|
|
4336
|
+
required: [
|
|
4337
|
+
"id",
|
|
4338
|
+
"name"
|
|
4339
|
+
],
|
|
4340
|
+
additionalProperties: false
|
|
4341
|
+
}
|
|
4342
|
+
},
|
|
4343
|
+
refreshedAt: {
|
|
4344
|
+
type: "string"
|
|
4345
|
+
},
|
|
4346
|
+
source: {
|
|
4347
|
+
type: "string",
|
|
4348
|
+
enum: [
|
|
4349
|
+
"remote",
|
|
4350
|
+
"manual"
|
|
4351
|
+
]
|
|
4352
|
+
}
|
|
4353
|
+
},
|
|
4354
|
+
required: [
|
|
4355
|
+
"models",
|
|
4356
|
+
"refreshedAt",
|
|
4357
|
+
"source"
|
|
4358
|
+
],
|
|
4359
|
+
additionalProperties: false
|
|
4360
|
+
},
|
|
4361
|
+
planToken: {
|
|
4362
|
+
type: "string"
|
|
4363
|
+
},
|
|
4364
|
+
warnings: {
|
|
4365
|
+
type: "array",
|
|
4366
|
+
items: {
|
|
4367
|
+
type: "string"
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
},
|
|
4371
|
+
required: [
|
|
4372
|
+
"provider",
|
|
4373
|
+
"profile",
|
|
4374
|
+
"catalog",
|
|
4375
|
+
"planToken",
|
|
4376
|
+
"warnings"
|
|
4377
|
+
],
|
|
4378
|
+
additionalProperties: false
|
|
4379
|
+
},
|
|
4380
|
+
RunInput: {
|
|
4381
|
+
type: "object",
|
|
4382
|
+
properties: {
|
|
4383
|
+
modelPolicyVersion: {
|
|
4384
|
+
type: "number",
|
|
4385
|
+
enum: [
|
|
4386
|
+
1
|
|
4387
|
+
]
|
|
4388
|
+
},
|
|
4389
|
+
profileId: {
|
|
4390
|
+
type: "string",
|
|
4391
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4392
|
+
},
|
|
4393
|
+
harness: {
|
|
4394
|
+
type: "string",
|
|
4395
|
+
enum: [
|
|
4396
|
+
"claude",
|
|
4397
|
+
"codex",
|
|
4398
|
+
"grok",
|
|
4399
|
+
"opencode",
|
|
4400
|
+
"opencode2",
|
|
4401
|
+
"pi",
|
|
4402
|
+
"omp",
|
|
4403
|
+
"dsh",
|
|
4404
|
+
"cline",
|
|
4405
|
+
"hermes",
|
|
4406
|
+
"prime-agent",
|
|
4407
|
+
"gemini",
|
|
4408
|
+
"aider",
|
|
4409
|
+
"kilo"
|
|
4410
|
+
]
|
|
4411
|
+
},
|
|
4412
|
+
model: {
|
|
4413
|
+
type: "string",
|
|
4414
|
+
minLength: 1,
|
|
4415
|
+
maxLength: 300
|
|
4416
|
+
},
|
|
4417
|
+
modelPolicy: {
|
|
4418
|
+
type: "object",
|
|
4419
|
+
properties: {
|
|
4420
|
+
version: {
|
|
4421
|
+
type: "number",
|
|
4422
|
+
enum: [
|
|
4423
|
+
1
|
|
4424
|
+
],
|
|
4425
|
+
default: 1
|
|
4426
|
+
},
|
|
4427
|
+
roles: {
|
|
4428
|
+
type: "object",
|
|
4429
|
+
properties: {
|
|
4430
|
+
subagent: {
|
|
4431
|
+
type: "string",
|
|
4432
|
+
minLength: 1,
|
|
4433
|
+
maxLength: 300,
|
|
4434
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4435
|
+
},
|
|
4436
|
+
fast: {
|
|
4437
|
+
type: "string",
|
|
4438
|
+
minLength: 1,
|
|
4439
|
+
maxLength: 300,
|
|
4440
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4441
|
+
},
|
|
4442
|
+
planning: {
|
|
4443
|
+
type: "string",
|
|
4444
|
+
minLength: 1,
|
|
4445
|
+
maxLength: 300,
|
|
4446
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4447
|
+
},
|
|
4448
|
+
review: {
|
|
4449
|
+
type: "string",
|
|
4450
|
+
minLength: 1,
|
|
4451
|
+
maxLength: 300,
|
|
4452
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4453
|
+
},
|
|
4454
|
+
summary: {
|
|
4455
|
+
type: "string",
|
|
4456
|
+
minLength: 1,
|
|
4457
|
+
maxLength: 300,
|
|
4458
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4459
|
+
},
|
|
4460
|
+
compaction: {
|
|
4461
|
+
type: "string",
|
|
4462
|
+
minLength: 1,
|
|
4463
|
+
maxLength: 300,
|
|
4464
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4465
|
+
},
|
|
4466
|
+
weak: {
|
|
4467
|
+
type: "string",
|
|
4468
|
+
minLength: 1,
|
|
4469
|
+
maxLength: 300,
|
|
4470
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4471
|
+
},
|
|
4472
|
+
editor: {
|
|
4473
|
+
type: "string",
|
|
4474
|
+
minLength: 1,
|
|
4475
|
+
maxLength: 300,
|
|
4476
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4477
|
+
}
|
|
4478
|
+
},
|
|
4479
|
+
additionalProperties: false
|
|
4480
|
+
},
|
|
4481
|
+
allowedModels: {
|
|
4482
|
+
type: "array",
|
|
4483
|
+
items: {
|
|
4484
|
+
type: "string",
|
|
4485
|
+
minLength: 1,
|
|
4486
|
+
maxLength: 300,
|
|
4487
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4488
|
+
},
|
|
4489
|
+
maxItems: 500
|
|
4490
|
+
},
|
|
4491
|
+
aliases: {
|
|
4492
|
+
type: "object",
|
|
4493
|
+
additionalProperties: {
|
|
4494
|
+
type: "string",
|
|
4495
|
+
minLength: 1,
|
|
4496
|
+
maxLength: 300,
|
|
4497
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4498
|
+
}
|
|
4499
|
+
},
|
|
4500
|
+
fallbacks: {
|
|
4501
|
+
type: "object",
|
|
4502
|
+
additionalProperties: {
|
|
4503
|
+
type: "array",
|
|
4504
|
+
items: {
|
|
4505
|
+
type: "string",
|
|
4506
|
+
minLength: 1,
|
|
4507
|
+
maxLength: 300,
|
|
4508
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4509
|
+
},
|
|
4510
|
+
maxItems: 20
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
},
|
|
4514
|
+
additionalProperties: false
|
|
4515
|
+
},
|
|
4516
|
+
planToken: {
|
|
4517
|
+
type: "string",
|
|
4518
|
+
pattern: "^[a-f0-9]{64}$"
|
|
4519
|
+
}
|
|
4520
|
+
},
|
|
4521
|
+
required: [
|
|
4522
|
+
"modelPolicyVersion",
|
|
4523
|
+
"profileId",
|
|
4524
|
+
"harness",
|
|
4525
|
+
"model",
|
|
4526
|
+
"planToken"
|
|
4527
|
+
],
|
|
4528
|
+
additionalProperties: false
|
|
4529
|
+
},
|
|
4530
|
+
RunUpdate: {
|
|
4531
|
+
type: "object",
|
|
4532
|
+
properties: {
|
|
4533
|
+
status: {
|
|
4534
|
+
type: "string",
|
|
4535
|
+
enum: [
|
|
4536
|
+
"exited",
|
|
4537
|
+
"failed",
|
|
4538
|
+
"interrupted"
|
|
4539
|
+
]
|
|
4540
|
+
},
|
|
4541
|
+
exitCode: {
|
|
4542
|
+
type: "integer",
|
|
4543
|
+
minimum: 0,
|
|
4544
|
+
maximum: 255
|
|
4545
|
+
},
|
|
4546
|
+
routingEvents: {
|
|
4547
|
+
type: "array",
|
|
4548
|
+
items: {
|
|
4549
|
+
type: "object",
|
|
4550
|
+
properties: {
|
|
4551
|
+
at: {
|
|
4552
|
+
type: "string",
|
|
4553
|
+
format: "date-time"
|
|
4554
|
+
},
|
|
4555
|
+
requestId: {
|
|
4556
|
+
type: "string",
|
|
4557
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
|
4558
|
+
},
|
|
4559
|
+
requestedModel: {
|
|
4560
|
+
type: "string",
|
|
4561
|
+
minLength: 1,
|
|
4562
|
+
maxLength: 300,
|
|
4563
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4564
|
+
},
|
|
4565
|
+
resolvedModel: {
|
|
4566
|
+
type: "string",
|
|
4567
|
+
minLength: 1,
|
|
4568
|
+
maxLength: 300,
|
|
4569
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4570
|
+
},
|
|
4571
|
+
reportedModel: {
|
|
4572
|
+
type: "string",
|
|
4573
|
+
minLength: 1,
|
|
4574
|
+
maxLength: 300,
|
|
4575
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4576
|
+
},
|
|
4577
|
+
reasoningEffort: {
|
|
4578
|
+
type: "string",
|
|
4579
|
+
enum: [
|
|
4580
|
+
"none",
|
|
4581
|
+
"minimal",
|
|
4582
|
+
"low",
|
|
4583
|
+
"medium",
|
|
4584
|
+
"high",
|
|
4585
|
+
"xhigh",
|
|
4586
|
+
"max",
|
|
4587
|
+
"ultra"
|
|
4588
|
+
]
|
|
4589
|
+
},
|
|
4590
|
+
decision: {
|
|
4591
|
+
type: "string",
|
|
4592
|
+
enum: [
|
|
4593
|
+
"allow",
|
|
4594
|
+
"alias",
|
|
4595
|
+
"reject",
|
|
4596
|
+
"fallback"
|
|
4597
|
+
]
|
|
4598
|
+
},
|
|
4599
|
+
role: {
|
|
4600
|
+
type: "string",
|
|
4601
|
+
enum: [
|
|
4602
|
+
"main",
|
|
4603
|
+
"subagent",
|
|
4604
|
+
"fast",
|
|
4605
|
+
"planning",
|
|
4606
|
+
"review",
|
|
4607
|
+
"summary",
|
|
4608
|
+
"compaction",
|
|
4609
|
+
"weak",
|
|
4610
|
+
"editor"
|
|
4611
|
+
]
|
|
4612
|
+
},
|
|
4613
|
+
reason: {
|
|
4614
|
+
type: "string",
|
|
4615
|
+
pattern: "^[a-z][a-z0-9_]{0,63}$"
|
|
4616
|
+
},
|
|
4617
|
+
upstreamStatus: {
|
|
4618
|
+
type: "integer",
|
|
4619
|
+
minimum: 100,
|
|
4620
|
+
maximum: 599
|
|
4621
|
+
}
|
|
4622
|
+
},
|
|
4623
|
+
required: [
|
|
4624
|
+
"at",
|
|
4625
|
+
"requestId",
|
|
4626
|
+
"requestedModel",
|
|
4627
|
+
"decision"
|
|
4628
|
+
],
|
|
4629
|
+
additionalProperties: false
|
|
4630
|
+
},
|
|
4631
|
+
maxItems: 1000
|
|
4632
|
+
},
|
|
4633
|
+
routingEventsDropped: {
|
|
4634
|
+
type: "integer",
|
|
4635
|
+
minimum: 0,
|
|
4636
|
+
maximum: 1e6
|
|
4637
|
+
}
|
|
4638
|
+
},
|
|
4639
|
+
required: [
|
|
4640
|
+
"status",
|
|
4641
|
+
"exitCode"
|
|
4642
|
+
],
|
|
4643
|
+
additionalProperties: false
|
|
4644
|
+
},
|
|
4645
|
+
Run: {
|
|
4646
|
+
type: "object",
|
|
4647
|
+
properties: {
|
|
4648
|
+
modelPolicyVersion: {
|
|
4649
|
+
type: "number",
|
|
4650
|
+
enum: [
|
|
4651
|
+
1
|
|
4652
|
+
]
|
|
4653
|
+
},
|
|
4654
|
+
profileId: {
|
|
4655
|
+
type: "string",
|
|
4656
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4657
|
+
},
|
|
4658
|
+
harness: {
|
|
4659
|
+
type: "string",
|
|
4660
|
+
enum: [
|
|
4661
|
+
"claude",
|
|
4662
|
+
"codex",
|
|
4663
|
+
"grok",
|
|
4664
|
+
"opencode",
|
|
4665
|
+
"opencode2",
|
|
4666
|
+
"pi",
|
|
4667
|
+
"omp",
|
|
4668
|
+
"dsh",
|
|
4669
|
+
"cline",
|
|
4670
|
+
"hermes",
|
|
4671
|
+
"prime-agent",
|
|
4672
|
+
"gemini",
|
|
4673
|
+
"aider",
|
|
4674
|
+
"kilo"
|
|
4675
|
+
]
|
|
4676
|
+
},
|
|
4677
|
+
model: {
|
|
4678
|
+
type: "string",
|
|
4679
|
+
minLength: 1,
|
|
4680
|
+
maxLength: 300
|
|
4681
|
+
},
|
|
4682
|
+
modelPolicy: {
|
|
4683
|
+
type: "object",
|
|
4684
|
+
properties: {
|
|
4685
|
+
version: {
|
|
4686
|
+
type: "number",
|
|
4687
|
+
enum: [
|
|
4688
|
+
1
|
|
4689
|
+
],
|
|
4690
|
+
default: 1
|
|
4691
|
+
},
|
|
4692
|
+
roles: {
|
|
4693
|
+
type: "object",
|
|
4694
|
+
properties: {
|
|
4695
|
+
subagent: {
|
|
4696
|
+
type: "string",
|
|
4697
|
+
minLength: 1,
|
|
4698
|
+
maxLength: 300,
|
|
4699
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4700
|
+
},
|
|
4701
|
+
fast: {
|
|
4702
|
+
type: "string",
|
|
4703
|
+
minLength: 1,
|
|
4704
|
+
maxLength: 300,
|
|
4705
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4706
|
+
},
|
|
4707
|
+
planning: {
|
|
4708
|
+
type: "string",
|
|
4709
|
+
minLength: 1,
|
|
4710
|
+
maxLength: 300,
|
|
4711
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4712
|
+
},
|
|
4713
|
+
review: {
|
|
4714
|
+
type: "string",
|
|
4715
|
+
minLength: 1,
|
|
4716
|
+
maxLength: 300,
|
|
4717
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4718
|
+
},
|
|
4719
|
+
summary: {
|
|
4720
|
+
type: "string",
|
|
4721
|
+
minLength: 1,
|
|
4722
|
+
maxLength: 300,
|
|
4723
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4724
|
+
},
|
|
4725
|
+
compaction: {
|
|
4726
|
+
type: "string",
|
|
4727
|
+
minLength: 1,
|
|
4728
|
+
maxLength: 300,
|
|
4729
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4730
|
+
},
|
|
4731
|
+
weak: {
|
|
4732
|
+
type: "string",
|
|
4733
|
+
minLength: 1,
|
|
4734
|
+
maxLength: 300,
|
|
4735
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4736
|
+
},
|
|
4737
|
+
editor: {
|
|
4738
|
+
type: "string",
|
|
4739
|
+
minLength: 1,
|
|
4740
|
+
maxLength: 300,
|
|
4741
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4742
|
+
}
|
|
4743
|
+
},
|
|
4744
|
+
additionalProperties: false
|
|
4745
|
+
},
|
|
4746
|
+
allowedModels: {
|
|
4747
|
+
type: "array",
|
|
4748
|
+
items: {
|
|
4749
|
+
type: "string",
|
|
4750
|
+
minLength: 1,
|
|
4751
|
+
maxLength: 300,
|
|
4752
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4753
|
+
},
|
|
4754
|
+
maxItems: 500
|
|
4755
|
+
},
|
|
4756
|
+
aliases: {
|
|
4757
|
+
type: "object",
|
|
4758
|
+
additionalProperties: {
|
|
4759
|
+
type: "string",
|
|
4760
|
+
minLength: 1,
|
|
4761
|
+
maxLength: 300,
|
|
4762
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4763
|
+
}
|
|
4764
|
+
},
|
|
4765
|
+
fallbacks: {
|
|
4766
|
+
type: "object",
|
|
4767
|
+
additionalProperties: {
|
|
4768
|
+
type: "array",
|
|
4769
|
+
items: {
|
|
4770
|
+
type: "string",
|
|
4771
|
+
minLength: 1,
|
|
4772
|
+
maxLength: 300,
|
|
4773
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4774
|
+
},
|
|
4775
|
+
maxItems: 20
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
},
|
|
4779
|
+
additionalProperties: false
|
|
4780
|
+
},
|
|
4781
|
+
planToken: {
|
|
4782
|
+
type: "string",
|
|
4783
|
+
pattern: "^[a-f0-9]{64}$"
|
|
4784
|
+
},
|
|
4785
|
+
version: {
|
|
4786
|
+
type: "integer",
|
|
4787
|
+
exclusiveMinimum: true,
|
|
4788
|
+
minimum: 0
|
|
4789
|
+
},
|
|
4790
|
+
updatedAt: {
|
|
4791
|
+
type: "string"
|
|
4792
|
+
},
|
|
4793
|
+
providerId: {
|
|
4794
|
+
type: "string",
|
|
4795
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4796
|
+
},
|
|
4797
|
+
providerVersion: {
|
|
4798
|
+
type: "integer",
|
|
4799
|
+
exclusiveMinimum: true,
|
|
4800
|
+
minimum: 0
|
|
4801
|
+
},
|
|
4802
|
+
profileVersion: {
|
|
4803
|
+
type: "integer",
|
|
4804
|
+
exclusiveMinimum: true,
|
|
4805
|
+
minimum: 0
|
|
4806
|
+
},
|
|
4807
|
+
id: {
|
|
4808
|
+
type: "string",
|
|
4809
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
4810
|
+
},
|
|
4811
|
+
status: {
|
|
4812
|
+
type: "string",
|
|
4813
|
+
enum: [
|
|
4814
|
+
"running",
|
|
4815
|
+
"exited",
|
|
4816
|
+
"failed",
|
|
4817
|
+
"interrupted"
|
|
4818
|
+
]
|
|
4819
|
+
},
|
|
4820
|
+
startedAt: {
|
|
4821
|
+
type: "string"
|
|
4822
|
+
},
|
|
4823
|
+
endedAt: {
|
|
4824
|
+
type: "string"
|
|
4825
|
+
},
|
|
4826
|
+
exitCode: {
|
|
4827
|
+
type: "integer"
|
|
4828
|
+
},
|
|
4829
|
+
routingEvents: {
|
|
4830
|
+
type: "array",
|
|
4831
|
+
items: {
|
|
4832
|
+
type: "object",
|
|
4833
|
+
properties: {
|
|
4834
|
+
at: {
|
|
4835
|
+
type: "string",
|
|
4836
|
+
format: "date-time"
|
|
4837
|
+
},
|
|
4838
|
+
requestId: {
|
|
4839
|
+
type: "string",
|
|
4840
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
|
4841
|
+
},
|
|
4842
|
+
requestedModel: {
|
|
4843
|
+
type: "string",
|
|
4844
|
+
minLength: 1,
|
|
4845
|
+
maxLength: 300,
|
|
4846
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4847
|
+
},
|
|
4848
|
+
resolvedModel: {
|
|
4849
|
+
type: "string",
|
|
4850
|
+
minLength: 1,
|
|
4851
|
+
maxLength: 300,
|
|
4852
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4853
|
+
},
|
|
4854
|
+
reportedModel: {
|
|
4855
|
+
type: "string",
|
|
4856
|
+
minLength: 1,
|
|
4857
|
+
maxLength: 300,
|
|
4858
|
+
pattern: "^[^\\u0000-\\u001f\\u007f]+$"
|
|
4859
|
+
},
|
|
4860
|
+
reasoningEffort: {
|
|
4861
|
+
type: "string",
|
|
4862
|
+
enum: [
|
|
4863
|
+
"none",
|
|
4864
|
+
"minimal",
|
|
4865
|
+
"low",
|
|
4866
|
+
"medium",
|
|
4867
|
+
"high",
|
|
4868
|
+
"xhigh",
|
|
4869
|
+
"max",
|
|
4870
|
+
"ultra"
|
|
4871
|
+
]
|
|
4872
|
+
},
|
|
4873
|
+
decision: {
|
|
4874
|
+
type: "string",
|
|
4875
|
+
enum: [
|
|
4876
|
+
"allow",
|
|
4877
|
+
"alias",
|
|
4878
|
+
"reject",
|
|
4879
|
+
"fallback"
|
|
4880
|
+
]
|
|
4881
|
+
},
|
|
4882
|
+
role: {
|
|
4883
|
+
type: "string",
|
|
4884
|
+
enum: [
|
|
4885
|
+
"main",
|
|
4886
|
+
"subagent",
|
|
4887
|
+
"fast",
|
|
4888
|
+
"planning",
|
|
4889
|
+
"review",
|
|
4890
|
+
"summary",
|
|
4891
|
+
"compaction",
|
|
4892
|
+
"weak",
|
|
4893
|
+
"editor"
|
|
4894
|
+
]
|
|
4895
|
+
},
|
|
4896
|
+
reason: {
|
|
4897
|
+
type: "string",
|
|
4898
|
+
pattern: "^[a-z][a-z0-9_]{0,63}$"
|
|
4899
|
+
},
|
|
4900
|
+
upstreamStatus: {
|
|
4901
|
+
type: "integer",
|
|
4902
|
+
minimum: 100,
|
|
4903
|
+
maximum: 599
|
|
4904
|
+
}
|
|
4905
|
+
},
|
|
4906
|
+
required: [
|
|
4907
|
+
"at",
|
|
4908
|
+
"requestId",
|
|
4909
|
+
"requestedModel",
|
|
4910
|
+
"decision"
|
|
4911
|
+
],
|
|
4912
|
+
additionalProperties: false
|
|
4913
|
+
},
|
|
4914
|
+
maxItems: 1000
|
|
4915
|
+
},
|
|
4916
|
+
routingEventsDropped: {
|
|
4917
|
+
type: "integer",
|
|
4918
|
+
minimum: 0,
|
|
4919
|
+
maximum: 1e6
|
|
4920
|
+
}
|
|
4921
|
+
},
|
|
4922
|
+
required: [
|
|
4923
|
+
"profileId",
|
|
4924
|
+
"harness",
|
|
4925
|
+
"model",
|
|
4926
|
+
"planToken",
|
|
4927
|
+
"version",
|
|
4928
|
+
"updatedAt",
|
|
4929
|
+
"providerId",
|
|
4930
|
+
"providerVersion",
|
|
4931
|
+
"profileVersion",
|
|
4932
|
+
"id",
|
|
4933
|
+
"status",
|
|
4934
|
+
"startedAt"
|
|
4935
|
+
],
|
|
4936
|
+
additionalProperties: false
|
|
4937
|
+
},
|
|
4938
|
+
Health: {
|
|
4939
|
+
type: "object",
|
|
4940
|
+
properties: {
|
|
4941
|
+
status: {
|
|
4942
|
+
type: "string",
|
|
4943
|
+
enum: [
|
|
4944
|
+
"ok",
|
|
4945
|
+
"degraded",
|
|
4946
|
+
"unavailable"
|
|
4947
|
+
]
|
|
4948
|
+
},
|
|
4949
|
+
version: {
|
|
4950
|
+
type: "string"
|
|
4951
|
+
},
|
|
4952
|
+
backend: {
|
|
4953
|
+
type: "string",
|
|
4954
|
+
enum: [
|
|
4955
|
+
"sqlite",
|
|
4956
|
+
"postgresql"
|
|
4957
|
+
]
|
|
4958
|
+
}
|
|
4959
|
+
},
|
|
4960
|
+
required: [
|
|
4961
|
+
"status",
|
|
4962
|
+
"version",
|
|
4963
|
+
"backend"
|
|
4964
|
+
],
|
|
4965
|
+
additionalProperties: false
|
|
4966
|
+
},
|
|
4967
|
+
Ready: {
|
|
4968
|
+
type: "object",
|
|
4969
|
+
properties: {
|
|
4970
|
+
ready: {
|
|
4971
|
+
type: "boolean"
|
|
4972
|
+
},
|
|
4973
|
+
reason: {
|
|
4974
|
+
type: "string"
|
|
4975
|
+
}
|
|
4976
|
+
},
|
|
4977
|
+
required: [
|
|
4978
|
+
"ready"
|
|
4979
|
+
],
|
|
4980
|
+
additionalProperties: false
|
|
4981
|
+
},
|
|
4982
|
+
Version: {
|
|
4983
|
+
type: "object",
|
|
4984
|
+
properties: {
|
|
4985
|
+
version: {
|
|
4986
|
+
type: "string"
|
|
4987
|
+
}
|
|
4988
|
+
},
|
|
4989
|
+
required: [
|
|
4990
|
+
"version"
|
|
4991
|
+
],
|
|
4992
|
+
additionalProperties: false
|
|
4993
|
+
},
|
|
4994
|
+
LaunchInput: {
|
|
4995
|
+
type: "object",
|
|
4996
|
+
properties: {
|
|
4997
|
+
profileId: {
|
|
4998
|
+
type: "string",
|
|
4999
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$"
|
|
5000
|
+
}
|
|
5001
|
+
},
|
|
5002
|
+
required: [
|
|
5003
|
+
"profileId"
|
|
5004
|
+
],
|
|
5005
|
+
additionalProperties: false
|
|
5006
|
+
},
|
|
5007
|
+
Empty: {
|
|
5008
|
+
type: "object",
|
|
5009
|
+
properties: {},
|
|
5010
|
+
additionalProperties: false
|
|
5011
|
+
},
|
|
5012
|
+
Error: {
|
|
5013
|
+
type: "object",
|
|
5014
|
+
properties: {
|
|
5015
|
+
error: {
|
|
5016
|
+
type: "object",
|
|
5017
|
+
properties: {
|
|
5018
|
+
code: {
|
|
5019
|
+
type: "string"
|
|
5020
|
+
},
|
|
5021
|
+
message: {
|
|
5022
|
+
type: "string"
|
|
5023
|
+
},
|
|
5024
|
+
requestId: {
|
|
5025
|
+
type: "string"
|
|
5026
|
+
}
|
|
5027
|
+
},
|
|
5028
|
+
required: [
|
|
5029
|
+
"code",
|
|
5030
|
+
"message",
|
|
5031
|
+
"requestId"
|
|
5032
|
+
],
|
|
5033
|
+
additionalProperties: false
|
|
5034
|
+
}
|
|
5035
|
+
},
|
|
5036
|
+
required: [
|
|
5037
|
+
"error"
|
|
5038
|
+
],
|
|
5039
|
+
additionalProperties: false
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
};
|
|
5044
|
+
|
|
5045
|
+
// src/service.ts
|
|
5046
|
+
var snapshot = (profile, provider, catalog) => createHash2("sha256").update(JSON.stringify([profile, provider, { models: catalog.models, source: catalog.source }])).digest("hex");
|
|
5047
|
+
var hash = (s) => createHash2("sha256").update(s).digest();
|
|
5048
|
+
function createHandler(store, apiKey, providerEnv = process.env, resolveCredential) {
|
|
5049
|
+
if (!apiKey || apiKey.length < 24)
|
|
5050
|
+
throw new Fault(500, "auth_config", "Set HASNA_SWITCHER_API_KEY to a random token of at least 24 characters.");
|
|
5051
|
+
const expected = hash(`Bearer ${apiKey}`);
|
|
5052
|
+
return async (request) => {
|
|
5053
|
+
const requestId = crypto.randomUUID();
|
|
5054
|
+
const json = (body, status = 200) => Response.json(body, { status, headers: { "x-request-id": requestId, "cache-control": "no-store", "x-content-type-options": "nosniff" } });
|
|
5055
|
+
try {
|
|
5056
|
+
const url = new URL(request.url);
|
|
5057
|
+
const route2 = url.pathname.replace(/\/$/, "");
|
|
5058
|
+
if (request.method === "GET" && route2 === "/health")
|
|
5059
|
+
return json({ status: "ok", version: VERSION, backend: store.engine });
|
|
5060
|
+
if (request.method === "GET" && route2 === "/version")
|
|
5061
|
+
return json({ version: VERSION });
|
|
5062
|
+
if (request.method === "GET" && route2 === "/ready") {
|
|
5063
|
+
try {
|
|
5064
|
+
await store.ready();
|
|
5065
|
+
return json({ ready: true });
|
|
5066
|
+
} catch {
|
|
5067
|
+
return json({ ready: false, reason: "Storage is unavailable." }, 503);
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
if (!timingSafeEqual(expected, hash(request.headers.get("authorization") ?? "")))
|
|
5071
|
+
throw new Fault(401, "unauthorized", "A valid API bearer token is required.");
|
|
5072
|
+
if (request.method === "GET" && ["/v1/openapi.json", "/openapi.json"].includes(route2))
|
|
5073
|
+
return json(openapi_default);
|
|
5074
|
+
const parts = route2.split("/").filter(Boolean);
|
|
5075
|
+
if (parts[0] !== "v1")
|
|
5076
|
+
throw new Fault(404, "not_found", "Route was not found.");
|
|
5077
|
+
const resource = parts[1];
|
|
5078
|
+
const id2 = parts[2];
|
|
5079
|
+
if (id2)
|
|
5080
|
+
parse(idSchema, id2);
|
|
5081
|
+
const page = () => parse(z4.object({
|
|
5082
|
+
limit: z4.coerce.number().int().min(1).max(1000).default(100),
|
|
5083
|
+
offset: z4.coerce.number().int().min(0).max(1e6).default(0),
|
|
5084
|
+
search: z4.string().max(200).default("")
|
|
5085
|
+
}).strict(), Object.fromEntries(url.searchParams));
|
|
5086
|
+
if (request.method === "GET") {
|
|
5087
|
+
if (resource === "provider-presets" && parts.length <= 3)
|
|
5088
|
+
return json(id2 ? getProviderPreset(id2) : { data: providerPresets });
|
|
5089
|
+
if (["providers", "profiles", "runs"].includes(resource) && parts.length <= 3) {
|
|
5090
|
+
const kind = resource;
|
|
5091
|
+
return json(id2 ? await store.get(kind, id2) : await store.list(kind, page()));
|
|
5092
|
+
}
|
|
5093
|
+
if (resource === "providers" && id2 && parts[3] === "models" && parts.length === 4) {
|
|
5094
|
+
const catalog = await store.get("catalogs", id2);
|
|
5095
|
+
const p = page();
|
|
5096
|
+
const filtered = catalog.models.filter((m) => [m.id, m.name].some((s) => s.toLowerCase().includes(p.search.toLowerCase())));
|
|
5097
|
+
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 });
|
|
5098
|
+
}
|
|
5099
|
+
throw new Fault(404, "not_found", "Route was not found.");
|
|
5100
|
+
}
|
|
5101
|
+
if (!["POST", "PUT", "PATCH", "DELETE"].includes(request.method))
|
|
5102
|
+
throw new Fault(405, "method_not_allowed", "Method is not supported.");
|
|
5103
|
+
const key = request.headers.get("idempotency-key");
|
|
5104
|
+
if (!key || !/^[a-zA-Z0-9._:-]{8,128}$/.test(key))
|
|
5105
|
+
throw new Fault(400, "idempotency_required", "Supply an Idempotency-Key of 8\u2013128 ASCII letters, digits, dots, colons, underscores or dashes.");
|
|
5106
|
+
let body = {};
|
|
5107
|
+
if (request.method !== "DELETE") {
|
|
5108
|
+
if (!request.headers.get("content-type")?.startsWith("application/json"))
|
|
5109
|
+
throw new Fault(415, "content_type", "Send application/json.");
|
|
5110
|
+
try {
|
|
5111
|
+
body = await boundedJson(request, 1024 * 1024);
|
|
5112
|
+
} catch {
|
|
5113
|
+
throw new Fault(400, "invalid_json", "Request must contain valid JSON under 1 MiB.");
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
const fingerprint = hash(JSON.stringify([request.method, route2, body, request.headers.get("if-match")])).toString("hex");
|
|
5117
|
+
const version = () => {
|
|
5118
|
+
const v = request.headers.get("if-match");
|
|
5119
|
+
if (!v || !/^[1-9]\d*$/.test(v))
|
|
5120
|
+
throw new Fault(428, "version_required", "Supply the current numeric version in If-Match.");
|
|
5121
|
+
return Number(v);
|
|
5122
|
+
};
|
|
5123
|
+
const replay = await store.replay(key, fingerprint);
|
|
5124
|
+
if (replay.found)
|
|
5125
|
+
return json(replay.value, request.method === "POST" && ["providers", "profiles", "runs"].includes(resource) && !id2 ? 201 : 200);
|
|
5126
|
+
let refreshed;
|
|
5127
|
+
if (resource === "providers" && id2 && parts[3] === "refresh" && parts.length === 4 && request.method === "POST") {
|
|
5128
|
+
parse(z4.object({}).strict(), body);
|
|
5129
|
+
const provider = await store.get("providers", id2);
|
|
5130
|
+
refreshed = { provider, catalog: await discover(provider, providerEnv, resolveCredential) };
|
|
5131
|
+
}
|
|
5132
|
+
const result = await store.mutate(key, fingerprint, async (db) => {
|
|
5133
|
+
if ((resource === "providers" || resource === "profiles") && parts.length <= 3) {
|
|
5134
|
+
if (request.method === "DELETE" && id2)
|
|
5135
|
+
return store.remove(resource, id2, version(), db);
|
|
5136
|
+
if (request.method === "POST" && !id2 || request.method === "PUT" && id2) {
|
|
5137
|
+
const value = resource === "providers" ? parse(providerInputSchema, body) : parse(profileInputSchema, body);
|
|
5138
|
+
if (id2 && value.id !== id2)
|
|
5139
|
+
throw new Fault(400, "id_mismatch", "Path and body IDs must match.");
|
|
5140
|
+
if (resource === "profiles") {
|
|
5141
|
+
const profile = value;
|
|
5142
|
+
const provider = await store.get("providers", profile.providerId, db);
|
|
5143
|
+
validateHarnessProvider(profile.harness, provider);
|
|
5144
|
+
}
|
|
5145
|
+
const saved = await store.put(resource, value, id2 ? version() : undefined, db);
|
|
5146
|
+
if (resource === "providers" && id2)
|
|
5147
|
+
await db.unsafe("DELETE FROM switcher_catalogs WHERE id = $1", [id2]);
|
|
5148
|
+
return saved;
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
if (resource === "providers" && id2 && parts[3] === "refresh" && parts.length === 4 && request.method === "POST") {
|
|
5152
|
+
if (store.engine === "postgresql")
|
|
5153
|
+
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR SHARE", [id2]);
|
|
5154
|
+
const provider = await store.get("providers", id2, db);
|
|
5155
|
+
if (!refreshed || provider.version !== refreshed.provider.version)
|
|
5156
|
+
throw new Fault(409, "provider_changed", "Provider changed during discovery; refresh again.");
|
|
5157
|
+
const catalog = refreshed.catalog;
|
|
5158
|
+
let old;
|
|
5159
|
+
try {
|
|
5160
|
+
old = await store.get("catalogs", id2, db);
|
|
5161
|
+
} catch (e) {
|
|
5162
|
+
if (!(e instanceof Fault && e.status === 404))
|
|
5163
|
+
throw e;
|
|
5164
|
+
}
|
|
5165
|
+
return store.put("catalogs", { id: id2, ...catalog }, old?.version, db);
|
|
5166
|
+
}
|
|
5167
|
+
if (resource === "launch-plans" && !id2 && request.method === "POST") {
|
|
5168
|
+
const { profileId } = parse(z4.object({ profileId: idSchema }).strict(), body);
|
|
5169
|
+
const profile = await store.get("profiles", profileId, db);
|
|
5170
|
+
const provider = await store.get("providers", profile.providerId, db);
|
|
5171
|
+
validateHarnessProvider(profile.harness, provider);
|
|
5172
|
+
let catalog;
|
|
5173
|
+
try {
|
|
5174
|
+
catalog = await store.get("catalogs", provider.id, db);
|
|
5175
|
+
} catch (e) {
|
|
5176
|
+
if (e instanceof Fault && e.status === 404)
|
|
5177
|
+
throw new Fault(422, "catalog_missing", "Refresh the provider catalog before launching.");
|
|
5178
|
+
throw e;
|
|
5179
|
+
}
|
|
5180
|
+
const selected = catalog.models.find((m) => m.id === profile.model);
|
|
5181
|
+
if (!selected)
|
|
5182
|
+
throw new Fault(422, "model_missing", "Selected model is not in the provider catalog.");
|
|
5183
|
+
if (modelExpired(selected))
|
|
5184
|
+
throw new Fault(422, "model_expired", "Selected model has passed its configured expiry date. Select an unexpired model.");
|
|
5185
|
+
if (!harnessEligible(selected, profile.harness))
|
|
5186
|
+
throw new Fault(422, "model_ineligible", "Selected model is unavailable or explicitly lacks a required generation method, text output or tool support.");
|
|
5187
|
+
compileModelPolicy(profile.model, catalog.models.filter((model) => modelExpired(model) || harnessEligible(model, profile.harness)), profile.modelPolicy);
|
|
5188
|
+
const warnings = [];
|
|
5189
|
+
if (profile.harness !== "aider" && !selected.supportedParameters)
|
|
5190
|
+
warnings.push("Provider does not declare tool capabilities; execution compatibility is unverified.");
|
|
5191
|
+
if (profile.harness === "claude" && !/claude/i.test(profile.model))
|
|
5192
|
+
warnings.push("Anthropic does not support non-Claude models in Claude Code; this combination is experimental.");
|
|
5193
|
+
if (Date.now() - Date.parse(catalog.refreshedAt) > 300000)
|
|
5194
|
+
warnings.push("Catalog snapshot is older than five minutes; refresh before launching.");
|
|
5195
|
+
return { profile, provider, catalog, warnings, planToken: snapshot(profile, provider, catalog) };
|
|
5196
|
+
}
|
|
5197
|
+
if (resource === "runs" && !id2 && request.method === "POST") {
|
|
5198
|
+
if (body?.modelPolicyVersion !== 1)
|
|
5199
|
+
throw new Fault(409, "launcher_upgrade_required", "This API requires a launcher with automatic model policy version 1; upgrade the Switcher CLI/SDK.");
|
|
5200
|
+
const input = parse(runInputSchema, body);
|
|
5201
|
+
if (store.engine === "postgresql")
|
|
5202
|
+
await db.unsafe("SELECT id FROM switcher_profiles WHERE id = $1 FOR SHARE", [input.profileId]);
|
|
5203
|
+
const profile = await store.get("profiles", input.profileId, db);
|
|
5204
|
+
if (store.engine === "postgresql") {
|
|
5205
|
+
await db.unsafe("SELECT id FROM switcher_providers WHERE id = $1 FOR SHARE", [profile.providerId]);
|
|
5206
|
+
await db.unsafe("SELECT id FROM switcher_catalogs WHERE id = $1 FOR SHARE", [profile.providerId]);
|
|
5207
|
+
}
|
|
5208
|
+
const provider = await store.get("providers", profile.providerId, db);
|
|
5209
|
+
let catalog;
|
|
5210
|
+
try {
|
|
5211
|
+
catalog = await store.get("catalogs", profile.providerId, db);
|
|
5212
|
+
} catch (error) {
|
|
5213
|
+
if (error instanceof Fault && error.status === 404)
|
|
5214
|
+
throw new Fault(409, "plan_changed", "Catalog changed; request a fresh launch plan.");
|
|
5215
|
+
throw error;
|
|
5216
|
+
}
|
|
5217
|
+
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)
|
|
5218
|
+
throw new Fault(409, "plan_changed", "Provider, profile, model policy or catalog changed; request a fresh launch plan.");
|
|
5219
|
+
compileModelPolicy(profile.model, catalog.models.filter((model) => modelExpired(model) || harnessEligible(model, profile.harness)), profile.modelPolicy);
|
|
5220
|
+
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);
|
|
5221
|
+
}
|
|
5222
|
+
if (resource === "runs" && id2 && request.method === "PATCH" && parts.length === 3) {
|
|
5223
|
+
const input = parse(runUpdateSchema, body);
|
|
5224
|
+
const run = await store.get("runs", id2, db);
|
|
5225
|
+
if (run.status !== "running")
|
|
5226
|
+
throw new Fault(409, "run_finished", "Run has already finished.");
|
|
5227
|
+
return store.put("runs", { ...run, ...input, endedAt: new Date().toISOString() }, version(), db);
|
|
5228
|
+
}
|
|
5229
|
+
throw new Fault(404, "not_found", "Route was not found.");
|
|
5230
|
+
});
|
|
5231
|
+
return json(result, request.method === "POST" && ["providers", "profiles", "runs"].includes(resource) && !id2 ? 201 : 200);
|
|
5232
|
+
} catch (error) {
|
|
5233
|
+
const safe = error instanceof Fault ? error : new Fault(500, "internal_error", "Request failed.");
|
|
5234
|
+
return json({ error: { code: safe.code, message: safe.message, requestId } }, safe.status);
|
|
5235
|
+
}
|
|
5236
|
+
};
|
|
5237
|
+
}
|
|
5238
|
+
|
|
5239
|
+
// src/server.ts
|
|
5240
|
+
async function startServer(options) {
|
|
5241
|
+
const port = options.port ?? 0;
|
|
5242
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
5243
|
+
throw new Fault(400, "invalid_port", "Port must be an integer between 0 and 65535.");
|
|
5244
|
+
if (options.apiKey.length < 24 || /[\r\n]/.test(options.apiKey))
|
|
5245
|
+
throw new Fault(500, "auth_config", "Use a random operator token of at least 24 characters.");
|
|
5246
|
+
const store = await Store.open({ databaseUrl: options.databaseUrl, sqlitePath: options.sqlitePath });
|
|
5247
|
+
let server;
|
|
5248
|
+
try {
|
|
5249
|
+
server = Bun.serve({
|
|
5250
|
+
hostname: options.hostname ?? "127.0.0.1",
|
|
5251
|
+
port,
|
|
5252
|
+
maxRequestBodySize: 1024 * 1024,
|
|
5253
|
+
idleTimeout: 60,
|
|
5254
|
+
fetch: createHandler(store, options.apiKey, options.providerEnv, options.resolveCredential)
|
|
5255
|
+
});
|
|
5256
|
+
await store.ready();
|
|
5257
|
+
} catch (error) {
|
|
5258
|
+
await server?.stop(true);
|
|
5259
|
+
await store.close();
|
|
5260
|
+
throw error;
|
|
5261
|
+
}
|
|
5262
|
+
const listener = server;
|
|
5263
|
+
let closing;
|
|
5264
|
+
return {
|
|
5265
|
+
url: listener.url.href,
|
|
5266
|
+
storage: store.engine,
|
|
5267
|
+
close() {
|
|
5268
|
+
return closing ??= (async () => {
|
|
5269
|
+
try {
|
|
5270
|
+
await listener.stop(true);
|
|
5271
|
+
} finally {
|
|
5272
|
+
await store.close();
|
|
5273
|
+
}
|
|
5274
|
+
})();
|
|
5275
|
+
}
|
|
5276
|
+
};
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5279
|
+
// src/runtime.ts
|
|
5280
|
+
import { resolveCredential as resolveClientCredential, clientTransportEnvKeys as clientTransportEnvKeys2, appConfigDiskValue, keychainConfigValue } from "@hasna/contracts/client";
|
|
5281
|
+
|
|
5282
|
+
// src/lib/local-opt-in.ts
|
|
5283
|
+
import {
|
|
5284
|
+
clientTransportEnvKeys,
|
|
5285
|
+
credentialDiskSources,
|
|
5286
|
+
credentialOverrideEnvKey,
|
|
5287
|
+
credentialPointerEnvKey,
|
|
5288
|
+
CREDENTIAL_PROFILE_ENV_KEY
|
|
5289
|
+
} from "@hasna/contracts/client";
|
|
5290
|
+
var SWITCHER_LOCAL_OPT_IN_ENV_KEYS = ["HASNA_SWITCHER_LOCAL", "SWITCHER_LOCAL"];
|
|
5291
|
+
var SWITCHER_KEYCHAIN_ITEM = "hasna.credentials.switcher.api-key";
|
|
5292
|
+
var SWITCHER_CREDENTIALS_FILE = "~/.hasna/switcher/config/credentials";
|
|
5293
|
+
function isSwitcherLocalOptIn(env = process.env) {
|
|
5294
|
+
return SWITCHER_LOCAL_OPT_IN_ENV_KEYS.some((key) => (env[key] ?? "").trim() !== "");
|
|
5295
|
+
}
|
|
5296
|
+
function switcherAuthorityEnvKeys() {
|
|
5297
|
+
const keys = clientTransportEnvKeys("switcher");
|
|
5298
|
+
return [
|
|
5299
|
+
...keys.apiUrlKeys,
|
|
5300
|
+
...keys.apiKeyKeys,
|
|
5301
|
+
credentialOverrideEnvKey("switcher"),
|
|
5302
|
+
credentialPointerEnvKey("switcher"),
|
|
5303
|
+
CREDENTIAL_PROFILE_ENV_KEY
|
|
5304
|
+
];
|
|
5305
|
+
}
|
|
5306
|
+
function hasSwitcherEnvAuthorityIntent(env = process.env) {
|
|
5307
|
+
return switcherAuthorityEnvKeys().some((key) => env[key] !== undefined);
|
|
5308
|
+
}
|
|
5309
|
+
function switcherCredentialSources(env = process.env) {
|
|
5310
|
+
const disk = credentialDiskSources("switcher", env)[0];
|
|
5311
|
+
return [
|
|
5312
|
+
`Keychain item ${SWITCHER_KEYCHAIN_ITEM}`,
|
|
5313
|
+
disk ? `${SWITCHER_CREDENTIALS_FILE} (${disk})` : SWITCHER_CREDENTIALS_FILE,
|
|
5314
|
+
`${clientTransportEnvKeys("switcher").apiKeyKeys[0] ?? "HASNA_SWITCHER_API_KEY"} in the environment`
|
|
5315
|
+
];
|
|
5316
|
+
}
|
|
5317
|
+
function remoteConfigMissingMessage(env = process.env) {
|
|
5318
|
+
return `No Switcher API credential is configured; consulted ${switcherCredentialSources(env).join(", ")}. ` + `Configure one of them, or set ${SWITCHER_LOCAL_OPT_IN_ENV_KEYS[0]}=1 (alias ${SWITCHER_LOCAL_OPT_IN_ENV_KEYS[1]}=1) to deliberately use the on-box local store. Nothing was read or created locally.`;
|
|
5319
|
+
}
|
|
5320
|
+
var announced = false;
|
|
5321
|
+
function announceSwitcherLocalMode(home, write = (line) => {
|
|
5322
|
+
process.stderr.write(line);
|
|
5323
|
+
}) {
|
|
5324
|
+
if (announced)
|
|
5325
|
+
return;
|
|
5326
|
+
announced = true;
|
|
5327
|
+
write(`switcher: LOCAL mode \u2014 using the on-box store under ${home} behind an owned per-process loopback API, not a hosted Switcher API (${SWITCHER_LOCAL_OPT_IN_ENV_KEYS[0]} is set; a configured API URL or key would outrank it).
|
|
5328
|
+
`);
|
|
5329
|
+
}
|
|
5330
|
+
|
|
5331
|
+
// src/runtime.ts
|
|
5332
|
+
var REMOTE_API_CONFIG_MISSING = "remote_api_config_missing";
|
|
5333
|
+
function switcherHome(env = process.env) {
|
|
5334
|
+
const override = env.HASNA_HOME?.trim();
|
|
5335
|
+
const root = override && isAbsolute(override) ? override : join(env.HOME?.trim() || homedir2(), ".hasna");
|
|
5336
|
+
return resolve2(env.HASNA_SWITCHER_HOME ?? join(root, "switcher"));
|
|
5337
|
+
}
|
|
5338
|
+
async function privateDirectory(path) {
|
|
5339
|
+
await mkdir2(path, { recursive: true, mode: 448 });
|
|
5340
|
+
const info = await lstat(path);
|
|
5341
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
5342
|
+
throw new Fault(500, "home_permissions", "Switcher data directory must be a real directory.");
|
|
5343
|
+
if (process.platform !== "win32" && ((info.mode & 63) !== 0 || info.uid !== process.getuid?.()))
|
|
5344
|
+
throw new Fault(500, "home_permissions", "Switcher data directory must be owned by this user and accessible only to its owner (mode 0700).");
|
|
5345
|
+
}
|
|
5346
|
+
async function openCliRuntime(env = process.env, resolveCredential) {
|
|
5347
|
+
const providerEnv = Object.fromEntries(Object.entries(env).filter(([name]) => name.startsWith("SWITCHER_PROVIDER_")));
|
|
5348
|
+
const remote = () => ({ client: clientFromEnv(env), mode: "remote", providerEnv, close: async () => {} });
|
|
5349
|
+
if (hasSwitcherEnvAuthorityIntent(env))
|
|
5350
|
+
return remote();
|
|
5351
|
+
if (!isSwitcherLocalOptIn(env)) {
|
|
5352
|
+
const keys = clientTransportEnvKeys2("switcher");
|
|
5353
|
+
const configured = resolveClientCredential("switcher", env) || keychainConfigValue("switcher", env) || appConfigDiskValue("switcher", env, keys.apiUrlKeys);
|
|
5354
|
+
if (configured)
|
|
5355
|
+
return remote();
|
|
5356
|
+
throw new Fault(401, REMOTE_API_CONFIG_MISSING, remoteConfigMissingMessage(env));
|
|
5357
|
+
}
|
|
5358
|
+
const home = switcherHome(env);
|
|
5359
|
+
announceSwitcherLocalMode(home);
|
|
5360
|
+
if (!env.HASNA_SWITCHER_DATABASE_URL && !env.HASNA_SWITCHER_SQLITE_PATH)
|
|
5361
|
+
await privateDirectory(home);
|
|
5362
|
+
const apiKey = randomBytes(32).toString("base64url");
|
|
5363
|
+
const service = await startServer({
|
|
5364
|
+
apiKey,
|
|
5365
|
+
databaseUrl: env.HASNA_SWITCHER_DATABASE_URL,
|
|
5366
|
+
sqlitePath: env.HASNA_SWITCHER_SQLITE_PATH ?? (env.HASNA_SWITCHER_DATABASE_URL ? undefined : join(home, "switcher.db")),
|
|
5367
|
+
providerEnv,
|
|
5368
|
+
resolveCredential
|
|
5369
|
+
});
|
|
5370
|
+
return { client: new SwitcherClient({ baseUrl: service.url, apiKey }), mode: "local", providerEnv, close: service.close };
|
|
5371
|
+
}
|
|
5372
|
+
|
|
546
5373
|
// src/mcp.ts
|
|
547
5374
|
var server = new McpServer({ name: "switcher", version: VERSION });
|
|
548
|
-
var
|
|
5375
|
+
var runtime;
|
|
5376
|
+
var clientFromEnv2 = () => {
|
|
5377
|
+
if (!runtime)
|
|
5378
|
+
throw new Fault(503, "unavailable", "Switcher API runtime is not open.");
|
|
5379
|
+
return runtime.client;
|
|
5380
|
+
};
|
|
5381
|
+
var page = { limit: z5.number().int().min(1).max(1000).optional(), offset: z5.number().int().nonnegative().optional(), search: z5.string().optional() };
|
|
549
5382
|
function tool(name, description, schema, run) {
|
|
550
5383
|
server.tool(name, description, schema, async (input) => {
|
|
551
5384
|
try {
|
|
@@ -555,30 +5388,38 @@ function tool(name, description, schema, run) {
|
|
|
555
5388
|
}
|
|
556
5389
|
});
|
|
557
5390
|
}
|
|
558
|
-
tool("providers_list", "List provider profiles.", page, (p) =>
|
|
559
|
-
tool("providers_get", "Get a provider.", { id:
|
|
560
|
-
tool("providers_create", "Create a provider using credential environment references only.", providerInputSchema.innerType().shape, (p) =>
|
|
561
|
-
tool("providers_update", "Replace a provider at its current version.", { provider: providerInputSchema, version:
|
|
562
|
-
tool("providers_delete", "Delete an unreferenced provider.", { id:
|
|
563
|
-
tool("models_list", "List catalog with capability information.", { id:
|
|
564
|
-
const { id, ...rest } = p;
|
|
565
|
-
return
|
|
5391
|
+
tool("providers_list", "List provider profiles.", page, (p) => clientFromEnv2().listProviders(p));
|
|
5392
|
+
tool("providers_get", "Get a provider.", { id: z5.string() }, (p) => clientFromEnv2().getProvider(p.id));
|
|
5393
|
+
tool("providers_create", "Create a provider using credential environment references only.", providerInputSchema.innerType().shape, (p) => clientFromEnv2().createProvider(p));
|
|
5394
|
+
tool("providers_update", "Replace a provider at its current version.", { provider: providerInputSchema, version: z5.number().int() }, (p) => clientFromEnv2().updateProvider(p.provider, p.version));
|
|
5395
|
+
tool("providers_delete", "Delete an unreferenced provider.", { id: z5.string(), version: z5.number().int() }, (p) => clientFromEnv2().deleteProvider(p.id, p.version));
|
|
5396
|
+
tool("models_list", "List catalog with capability information.", { id: z5.string(), ...page }, (p) => {
|
|
5397
|
+
const { id: id2, ...rest } = p;
|
|
5398
|
+
return clientFromEnv2().listModels(id2, rest);
|
|
566
5399
|
});
|
|
567
|
-
tool("models_add", "Add saved model metadata; discovery stays active unless the provider uses a manual catalog.", { providerId:
|
|
568
|
-
tool("models_update", "Replace all saved metadata for a configured model.", { providerId:
|
|
569
|
-
tool("models_remove", "Remove saved model metadata; upstream catalog entries remain.", { providerId:
|
|
570
|
-
tool("models_refresh", "Discover provider models.", { id:
|
|
571
|
-
tool("profiles_list", "List harness launch profiles.", page, (p) =>
|
|
572
|
-
tool("profiles_get", "Get a harness profile.", { id:
|
|
573
|
-
tool("profiles_create", "Create a harness launch profile.", profileInputSchema.shape, (p) =>
|
|
574
|
-
tool("profiles_update", "Replace a harness profile at its version.", { profile: profileInputSchema, version:
|
|
575
|
-
tool("profiles_delete", "Delete a profile without run history.", { id:
|
|
576
|
-
tool("launch_plan", "Validate a local launch plan; does not execute a remote process.", { profileId:
|
|
577
|
-
tool("runs_list", "List launch metadata.", page, (p) =>
|
|
578
|
-
tool("runs_get", "Get launch metadata.", { id:
|
|
5400
|
+
tool("models_add", "Add saved model metadata; discovery stays active unless the provider uses a manual catalog.", { providerId: z5.string(), model: modelSchema }, (p) => clientFromEnv2().addModel(p.providerId, p.model));
|
|
5401
|
+
tool("models_update", "Replace all saved metadata for a configured model.", { providerId: z5.string(), model: modelSchema }, (p) => clientFromEnv2().updateModel(p.providerId, p.model));
|
|
5402
|
+
tool("models_remove", "Remove saved model metadata; upstream catalog entries remain.", { providerId: z5.string(), modelId: modelSchema.shape.id }, (p) => clientFromEnv2().removeModel(p.providerId, p.modelId));
|
|
5403
|
+
tool("models_refresh", "Discover provider models.", { id: z5.string() }, (p) => clientFromEnv2().refreshModels(p.id));
|
|
5404
|
+
tool("profiles_list", "List harness launch profiles.", page, (p) => clientFromEnv2().listProfiles(p));
|
|
5405
|
+
tool("profiles_get", "Get a harness profile.", { id: z5.string() }, (p) => clientFromEnv2().getProfile(p.id));
|
|
5406
|
+
tool("profiles_create", "Create a harness launch profile.", profileInputSchema.shape, (p) => clientFromEnv2().createProfile(p));
|
|
5407
|
+
tool("profiles_update", "Replace a harness profile at its version.", { profile: profileInputSchema, version: z5.number().int() }, (p) => clientFromEnv2().updateProfile(p.profile, p.version));
|
|
5408
|
+
tool("profiles_delete", "Delete a profile without run history.", { id: z5.string(), version: z5.number().int() }, (p) => clientFromEnv2().deleteProfile(p.id, p.version));
|
|
5409
|
+
tool("launch_plan", "Validate a local launch plan; does not execute a remote process.", { profileId: z5.string() }, (p) => clientFromEnv2().launchPlan(p.profileId));
|
|
5410
|
+
tool("runs_list", "List launch metadata.", page, (p) => clientFromEnv2().listRuns(p));
|
|
5411
|
+
tool("runs_get", "Get launch metadata.", { id: z5.string() }, (p) => clientFromEnv2().getRun(p.id));
|
|
579
5412
|
if (process.argv.includes("--version"))
|
|
580
5413
|
console.log(VERSION);
|
|
581
5414
|
else if (process.argv.includes("--help"))
|
|
582
|
-
console.log("switcher-mcp: authenticated Switcher API tools over MCP stdio. Resolves API URL/key through @hasna/contracts (Keychain, canonical config/credentials, or environment).");
|
|
583
|
-
else
|
|
5415
|
+
console.log("switcher-mcp: authenticated Switcher API tools over MCP stdio. Resolves API URL/key through @hasna/contracts (Keychain, canonical config/credentials, or environment). With nothing configured it exits 1 before answering initialize and names those sources; HASNA_SWITCHER_LOCAL=1 deliberately serves the on-box store instead.");
|
|
5416
|
+
else {
|
|
5417
|
+
try {
|
|
5418
|
+
runtime = await openCliRuntime(process.env);
|
|
5419
|
+
} catch (error) {
|
|
5420
|
+
const code = error instanceof Fault ? error.code : "remote_api_config_error";
|
|
5421
|
+
console.error(`${code.toUpperCase()}: ${error instanceof Error ? error.message : "Switcher API configuration could not be resolved."}`);
|
|
5422
|
+
process.exit(1);
|
|
5423
|
+
}
|
|
584
5424
|
await server.connect(new StdioServerTransport);
|
|
5425
|
+
}
|