Files
Peter Steinberger c7cf69a110 fix(opencode): refresh hosted model catalogs (#121030)
* fix(opencode): refresh hosted model catalogs

Align Zen and Go availability, pricing, limits, transports, lifecycle metadata, and model-specific reasoning controls with current provider contracts.

Co-authored-by: samson1357924 <samson1357924@gmail.com>

Co-authored-by: xialonglee <li.xialong@xydigit.com>

* fix(opencode): align catalog metadata with runtime contracts

---------

Co-authored-by: xialonglee <li.xialong@xydigit.com>
2026-08-09 04:05:47 -07:00

51 lines
1.8 KiB
TypeScript

// Opencode API module exposes the plugin public contract.
import type {
ProviderDefaultThinkingPolicyContext,
ProviderThinkingProfile,
} from "openclaw/plugin-sdk/plugin-entry";
import { resolveClaudeThinkingProfile } from "openclaw/plugin-sdk/provider-model-shared";
const FIXED_REASONING_PROFILE = {
levels: [{ id: "off", label: "always on" }],
defaultLevel: "off",
} as const satisfies ProviderThinkingProfile;
const THINKING_LEVEL_IDS = new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
function resolveEffortThinkingProfile(
efforts: readonly string[] | null | undefined,
): ProviderThinkingProfile | undefined {
if (!efforts || efforts.length === 0) {
return undefined;
}
const acceptedLevelIds = ["off", ...efforts.map((effort) => (effort === "none" ? "off" : effort))]
.filter((id) => THINKING_LEVEL_IDS.has(id))
.filter((id, index, values) => values.indexOf(id) === index) as Array<
"off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
>;
const levels = acceptedLevelIds.map((id) => ({ id }));
const levelIdSet = new Set(acceptedLevelIds);
const defaultLevel = levelIdSet.has("medium")
? "medium"
: levelIdSet.has("high")
? "high"
: levelIdSet.has("low")
? "low"
: "off";
return { levels, defaultLevel };
}
export function resolveThinkingProfile(params: ProviderDefaultThinkingPolicyContext) {
const modelId = params.modelId.trim().toLowerCase();
if (modelId.startsWith("claude-")) {
return resolveClaudeThinkingProfile(modelId);
}
const effortProfile = resolveEffortThinkingProfile(params.compat?.supportedReasoningEfforts);
if (effortProfile) {
return effortProfile;
}
return params.reasoning === true && params.api !== "anthropic-messages"
? FIXED_REASONING_PROFILE
: undefined;
}