refactor(open-sse): add provider/model schema skeleton (C-prep)

New unwired modules providers/schema.js + models/schema.js with PROVIDER_DEFAULTS,
ENDPOINT_DEFAULTS, resolveProvider, MODEL_DEFAULTS, resolveModel (3-tier merge).
Foundation for upcoming registry tasks; no runtime wiring yet.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decolua
2026-06-13 17:05:42 +07:00
parent 17202f7111
commit 34ea763d80
2 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
// Model schema (Mongoose-lite): central defaults + normalizer + 3-tier resolver (skeleton, not wired)
// Centralized model defaults (caps declares positive capabilities)
export const MODEL_DEFAULTS = {
type: "llm",
quotaFamily: "normal",
strip: [],
targetFormat: null,
caps: { vision: false, audioIn: false, thinking: false }
};
// Normalize a raw model entry over defaults (deep-merge caps)
export function normalizeModel(raw) {
return {
...MODEL_DEFAULTS,
...raw,
caps: { ...MODEL_DEFAULTS.caps, ...raw.caps },
upstreamModelId: raw.upstreamModelId || raw.id
};
}
// 3-tier fallback: defaults -> catalog canonical -> provider inline override (wins)
export function resolveModel(catalog, ref) {
const raw = typeof ref === "string" ? { id: ref } : ref;
return {
...MODEL_DEFAULTS,
...catalog[raw.id],
...raw,
caps: { ...MODEL_DEFAULTS.caps, ...catalog[raw.id]?.caps, ...raw.caps },
upstreamModelId: raw.upstreamModelId || catalog[raw.id]?.upstreamModelId || raw.id
};
}