mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
750a64e7cd
Stop OpenClaw from copying or refreshing Claude CLI OAuth tokens. Claude CLI now owns native login and refresh state; Doctor removes retired copies while preserving CLI routing. Co-authored-by: Ayaan Zaidi <hi@obviy.us>
67 lines
2.8 KiB
TypeScript
67 lines
2.8 KiB
TypeScript
/**
|
|
* Shared Claude CLI constants. These identify the synthetic backend, default
|
|
* model refs, aliases, and session-id fields used across runtime and setup.
|
|
*/
|
|
/** Synthetic provider/backend id for Claude Code CLI-backed Anthropic models. */
|
|
export const CLAUDE_CLI_BACKEND_ID = "claude-cli";
|
|
/** Non-secret marker telling OpenClaw that the installed Claude CLI owns auth. */
|
|
export const CLAUDE_CLI_NATIVE_AUTH_MARKER = ["openclaw", "claude-cli-native-auth"].join(":");
|
|
/** Default Claude CLI model ref for agent defaults and live tests. */
|
|
export const CLAUDE_CLI_DEFAULT_MODEL_REF = `${CLAUDE_CLI_BACKEND_ID}/claude-opus-5`;
|
|
/** Provider-relative model id for Anthropic runtime-policy resolution. */
|
|
const CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_ID = CLAUDE_CLI_DEFAULT_MODEL_REF.slice(
|
|
CLAUDE_CLI_BACKEND_ID.length + 1,
|
|
);
|
|
/** Canonical model ref routed to the Claude CLI backend by Anthropic setup. */
|
|
export const CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_REF = `anthropic/${CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_ID}`;
|
|
/** Default Claude CLI models allowed when setup seeds the model allowlist. */
|
|
export const CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS = [
|
|
CLAUDE_CLI_DEFAULT_MODEL_REF,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-sonnet-5`,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-fable-5`,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-opus-4-8`,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-opus-4-7`,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-sonnet-4-6`,
|
|
`${CLAUDE_CLI_BACKEND_ID}/claude-opus-4-6`,
|
|
] as const;
|
|
|
|
/**
|
|
* Claude CLI model ids probed when detecting an existing CLI route, canonical
|
|
* default first. Route detection must not depend on which model is currently
|
|
* the default: existing configs route older Claude models, so probing only the
|
|
* default would stop advertising session creation after a default bump.
|
|
*/
|
|
export const CLAUDE_CLI_ROUTE_PROBE_MODEL_IDS = CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS.map((ref) =>
|
|
ref.slice(CLAUDE_CLI_BACKEND_ID.length + 1),
|
|
);
|
|
|
|
/** User-facing Claude CLI model aliases normalized before execution. */
|
|
export const CLAUDE_CLI_MODEL_ALIASES: Record<string, string> = {
|
|
opus: "opus",
|
|
"opus-5": "claude-opus-5",
|
|
"opus-4.8": "claude-opus-4-8",
|
|
"opus-4.7": "claude-opus-4-7",
|
|
"opus-4.6": "claude-opus-4-6",
|
|
"claude-opus-5": "claude-opus-5",
|
|
"claude-opus-4-8": "claude-opus-4-8",
|
|
"claude-opus-4-7": "claude-opus-4-7",
|
|
"claude-opus-4-6": "claude-opus-4-6",
|
|
sonnet: "sonnet",
|
|
"sonnet-5": "claude-sonnet-5",
|
|
"claude-sonnet-5": "claude-sonnet-5",
|
|
"sonnet-4.6": "claude-sonnet-4-6",
|
|
"claude-sonnet-4-6": "claude-sonnet-4-6",
|
|
fable: "fable",
|
|
"fable-5": "claude-fable-5",
|
|
"claude-fable-5": "claude-fable-5",
|
|
haiku: "haiku",
|
|
};
|
|
|
|
/** JSONL fields that may contain Claude CLI session ids. */
|
|
export const CLAUDE_CLI_SESSION_ID_FIELDS = [
|
|
"session_id",
|
|
"sessionId",
|
|
"conversation_id",
|
|
"conversationId",
|
|
] as const;
|