mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 00:11:19 +00:00
* feat(models): add Claude Sonnet 5 support Co-authored-by: Ariel Bravy <ariel@vortexradar.com> * fix(models): align Sonnet 5 validation baselines * fix(models): satisfy Sonnet 5 CI contracts * fix(models): enforce Sonnet 5 provider contracts * docs(changelog): defer Sonnet 5 release note --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Ariel Bravy <ariel@vortexradar.com>
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
/**
|
|
* Claude CLI model catalog entries. Subscription-backed CLI models use picker
|
|
* metadata and do not require API-key auth rows.
|
|
*/
|
|
import type { ModelCatalogEntry } from "openclaw/plugin-sdk/agent-runtime";
|
|
import { CLAUDE_CLI_BACKEND_ID, CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS } from "./cli-constants.js";
|
|
|
|
// Claude CLI auth is subscription-backed, so catalog rows only need picker metadata.
|
|
const CLAUDE_CLI_DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
const CLAUDE_CLI_CONTEXT_WINDOWS: Record<string, number> = {
|
|
"claude-opus-4-8": 1_048_576,
|
|
"claude-sonnet-5": 1_000_000,
|
|
};
|
|
|
|
const CLAUDE_CLI_MODEL_LABELS: Record<string, string> = {
|
|
"claude-opus-4-8": "Claude Opus 4.8 (Claude CLI)",
|
|
"claude-opus-4-7": "Claude Opus 4.7 (Claude CLI)",
|
|
"claude-opus-4-6": "Claude Opus 4.6 (Claude CLI)",
|
|
"claude-sonnet-5": "Claude Sonnet 5 (Claude CLI)",
|
|
"claude-sonnet-4-6": "Claude Sonnet 4.6 (Claude CLI)",
|
|
};
|
|
|
|
function resolveClaudeCliImageMediaInput(id: string): ModelCatalogEntry["mediaInput"] {
|
|
const maxSidePx =
|
|
id === "claude-opus-4-8" || id === "claude-opus-4-7" || id === "claude-sonnet-5" ? 2576 : 1568;
|
|
return {
|
|
image: {
|
|
maxSidePx,
|
|
preferredSidePx: maxSidePx,
|
|
tokenMode: "provider",
|
|
},
|
|
};
|
|
}
|
|
|
|
function extractClaudeCliModelIds(): string[] {
|
|
const ids: string[] = [];
|
|
const seen = new Set<string>();
|
|
for (const ref of CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS) {
|
|
if (!ref.startsWith(`${CLAUDE_CLI_BACKEND_ID}/`)) {
|
|
continue;
|
|
}
|
|
const id = ref.slice(CLAUDE_CLI_BACKEND_ID.length + 1);
|
|
if (id.length === 0 || seen.has(id)) {
|
|
continue;
|
|
}
|
|
seen.add(id);
|
|
ids.push(id);
|
|
}
|
|
return ids;
|
|
}
|
|
|
|
/** Build catalog entries for the default Claude CLI allowlist. */
|
|
export function buildClaudeCliCatalogEntries(): ModelCatalogEntry[] {
|
|
return extractClaudeCliModelIds().map((id) => {
|
|
return {
|
|
id,
|
|
name: CLAUDE_CLI_MODEL_LABELS[id] ?? `${id} (Claude CLI)`,
|
|
provider: CLAUDE_CLI_BACKEND_ID,
|
|
reasoning: true,
|
|
input: ["text", "image"],
|
|
mediaInput: resolveClaudeCliImageMediaInput(id),
|
|
contextWindow: CLAUDE_CLI_CONTEXT_WINDOWS[id] ?? CLAUDE_CLI_DEFAULT_CONTEXT_WINDOW,
|
|
};
|
|
});
|
|
}
|