mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 18:21:39 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
/**
|
|
* Claude CLI provider discovery descriptor. It exposes subscription-backed
|
|
* synthetic auth for catalog/runtime discovery without full Anthropic registration.
|
|
*/
|
|
import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared";
|
|
import { readClaudeCliCredentialsForRuntime } from "./cli-auth-seam.js";
|
|
|
|
const CLAUDE_CLI_BACKEND_ID = "claude-cli";
|
|
|
|
function resolveClaudeCliSyntheticAuth() {
|
|
const credential = readClaudeCliCredentialsForRuntime();
|
|
if (!credential) {
|
|
return undefined;
|
|
}
|
|
return credential.type === "oauth"
|
|
? {
|
|
apiKey: credential.access,
|
|
source: "Claude CLI native auth",
|
|
mode: "oauth" as const,
|
|
expiresAt: credential.expires,
|
|
}
|
|
: {
|
|
apiKey: credential.token,
|
|
source: "Claude CLI native auth",
|
|
mode: "token" as const,
|
|
expiresAt: credential.expires,
|
|
};
|
|
}
|
|
|
|
const anthropicProviderDiscovery: ProviderPlugin = {
|
|
id: CLAUDE_CLI_BACKEND_ID,
|
|
label: "Claude CLI",
|
|
docsPath: "/providers/models",
|
|
auth: [],
|
|
resolveSyntheticAuth: ({ provider }) =>
|
|
provider === CLAUDE_CLI_BACKEND_ID ? resolveClaudeCliSyntheticAuth() : undefined,
|
|
};
|
|
|
|
export default anthropicProviderDiscovery;
|