UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

54 lines (53 loc) • 2.13 kB
//#region src/agents/defaults.ts const DEFAULT_PROVIDER = "openai"; const DEFAULT_MODEL = "gpt-6-astra"; const DEFAULT_CONTEXT_TOKENS = 2e5; /** Output-token cap used when no authored, provider, or catalog limit exists. */ const DEFAULT_MODEL_MAX_TOKENS = 32768; const DEFAULT_MODEL_MAX_TOKENS_FLOOR = 8192; /** * Resolves the invented output cap for a model whose real limit is unknown. * A known window keeps half its tokens for input, between the former 8192 * fallback and the 32768 default, and never exceeds the window itself. * Explicit limits never pass through here. */ function resolveDefaultModelMaxTokens(e) { if (e === void 0 || !Number.isFinite(e) || e <= 0) return DEFAULT_MODEL_MAX_TOKENS; const t = Math.max(1, Math.floor(e)); return Math.min(DEFAULT_MODEL_MAX_TOKENS, Math.max(Math.min(DEFAULT_MODEL_MAX_TOKENS_FLOOR, t), Math.floor(t / 2))); } /** Builds structural model metadata for a harness that resolves its real model natively. */ function createNativeModelOwnedRuntimeModel(e) { return { provider: e.provider, id: e.modelId, name: e.modelId, baseUrl: "", api: "openai-responses", reasoning: true, input: ["text", "image"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: DEFAULT_CONTEXT_TOKENS, maxTokens: DEFAULT_CONTEXT_TOKENS }; } /** * Returns the structural model when the selected plugin harness lists this exact model itself. * Native rows carry no host transport, so host model resolution cannot materialize them. */ function resolveNativeOwnedRuntimeModel(e) { const { catalog: t, provider: n, modelId: r, runtimeId: i } = e; if (!t || !i || i === "openclaw") return; const owned = (e) => e.provider === n && e.id === r && e.nativeRuntime === i; return t.entries.some(owned) || t.routeVariants.some(owned) ? createNativeModelOwnedRuntimeModel({ provider: n, modelId: r }) : void 0; } //#endregion export { createNativeModelOwnedRuntimeModel as a, DEFAULT_PROVIDER as i, DEFAULT_MODEL as n, resolveDefaultModelMaxTokens as o, DEFAULT_MODEL_MAX_TOKENS as r, resolveNativeOwnedRuntimeModel as s, DEFAULT_CONTEXT_TOKENS as t };