openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
63 lines (62 loc) • 2.93 kB
JavaScript
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs";
import { n as MODEL_DATA_THINKING_FORMATS, r as MODEL_DATA_THINKING_LEVELS, t as MODEL_DATA_APIS } from "./model-data-DbiYhCxI.mjs";
//#region packages/model-catalog-core/src/model-catalog-types.ts
const OPENAI_ULTRAFAST_CONTEXT_TOKENS = 26e4;
/** Prompt capacity for models served through a context-limited processing tier. */
function resolveModelServiceTierContextTokens(e, t) {
return e === "openai" && t === "ultrafast" ? OPENAI_ULTRAFAST_CONTEXT_TOKENS : void 0;
}
const MODEL_CATALOG_APIS = [...MODEL_DATA_APIS];
const MODEL_CATALOG_THINKING_FORMATS = [...MODEL_DATA_THINKING_FORMATS];
function isModelCatalogThinkingFormat(e) {
return MODEL_CATALOG_THINKING_FORMATS.includes(e);
}
const MODEL_FAMILY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
const MODEL_FAMILY_MAX_LENGTH = 64;
/**
* Canonical model family: the developer lineage a catalog declares for a model, such as
* `anthropic`. Callers pass only provider or catalog metadata, never a model id or name.
*/
function normalizeModelFamily(e) {
if (typeof e !== "string") return;
const t = e.trim().toLowerCase();
return t.length <= MODEL_FAMILY_MAX_LENGTH && MODEL_FAMILY_PATTERN.test(t) ? t : void 0;
}
const MODEL_CATALOG_INPUTS = [
"text",
"image",
"video",
"document"
];
const MODEL_CATALOG_THINKING_LEVELS = [...MODEL_DATA_THINKING_LEVELS];
const OPENAI_THINKING_APIS = /* @__PURE__ */ new Set([
"openai-completions",
"openai-responses",
"openai-chatgpt-responses",
"azure-openai-responses"
]);
/** Managed API aliases retain the source adapter's reasoning contract. */
function resolveOpenAIThinkingApi(e) {
if (typeof e !== "string") return;
const t = e.replace(/^openclaw-(.+)-transport$/u, "$1");
return OPENAI_THINKING_APIS.has(t) ? t : void 0;
}
/** Map keys describe logical choices; provider-native values retain their spelling. */
function listMappedModelThinkingLevels(e) {
const t = asOptionalRecord(e.compat);
const n = t?.supportedReasoningEfforts;
const r = resolveOpenAIThinkingApi(e.api);
const i = t?.thinkingFormat;
if (!r || r === "openai-completions" && (i === "qwen" || i === "qwen-chat-template" || i === "zai") || t?.supportsReasoningEffort === false || Array.isArray(n) && n.length === 0) return [];
const a = asOptionalRecord(t?.reasoningEffortMap);
const o = new Set(Object.entries(a ?? {}).flatMap(([e, t]) => typeof t === "string" && t.trim() ? [e.trim().toLowerCase()] : []));
return MODEL_CATALOG_THINKING_LEVELS.filter((e) => o.has(e));
}
const MODEL_CATALOG_STATUSES = [
"available",
"preview",
"deprecated",
"disabled"
];
//#endregion
export { isModelCatalogThinkingFormat as a, resolveModelServiceTierContextTokens as c, MODEL_CATALOG_THINKING_LEVELS as i, resolveOpenAIThinkingApi as l, MODEL_CATALOG_INPUTS as n, listMappedModelThinkingLevels as o, MODEL_CATALOG_STATUSES as r, normalizeModelFamily as s, MODEL_CATALOG_APIS as t };