openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
653 lines (652 loc) • 17 kB
JavaScript
//#region extensions/anthropic/openclaw.plugin.json
var modelCatalog = {
"modelsDev": { "anthropic": "anthropic" },
"providers": {
"claude-cli": { "models": [
{
"id": "claude-haiku-5-5",
"name": "Claude Haiku 5.5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-opus-5-5",
"name": "Claude Opus 5.5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-opus-5",
"name": "Claude Opus 5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-sonnet-5-5",
"name": "Claude Sonnet 5.5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-sonnet-5",
"name": "Claude Sonnet 5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-fable-5-1",
"name": "Claude Fable 5.1 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-fable-5",
"name": "Claude Fable 5 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3
},
{
"id": "claude-opus-4-8",
"name": "Claude Opus 4.8 (Claude CLI)",
"status": "deprecated",
"replacedBy": "claude-opus-5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 2e5,
"maxTokens": 128e3
},
{
"id": "claude-opus-4-7",
"name": "Claude Opus 4.7 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 2e5,
"maxTokens": 128e3
},
{
"id": "claude-sonnet-4-6",
"name": "Claude Sonnet 4.6 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 1568,
"preferredSidePx": 1568,
"tokenMode": "provider"
} },
"contextWindow": 2e5,
"maxTokens": 128e3
},
{
"id": "claude-opus-4-6",
"name": "Claude Opus 4.6 (Claude CLI)",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 1568,
"preferredSidePx": 1568,
"tokenMode": "provider"
} },
"contextWindow": 2e5,
"maxTokens": 128e3
}
] },
"anthropic": {
"baseUrl": "https://api.anthropic.com",
"api": "anthropic-messages",
"defaultUtilityModel": "claude-haiku-5-5",
"models": [
{
"id": "claude-haiku-5-5",
"name": "Claude Haiku 5.5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": .1,
"output": .5,
"cacheRead": .01,
"cacheWrite": .125,
"tieredPricing": [{
"range": [0, 100001],
"input": .1,
"output": .5,
"cacheRead": .01,
"cacheWrite": .125
}, {
"range": [100001],
"input": .5,
"output": 2.5,
"cacheRead": .05,
"cacheWrite": .625
}]
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "capable" }
},
{
"id": "claude-opus-5-5",
"name": "Claude Opus 5.5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 4,
"output": 20,
"cacheRead": .2,
"cacheWrite": 5
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-fable-5-1",
"name": "Claude Fable 5.1",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 10,
"output": 50,
"cacheRead": .25,
"cacheWrite": 12.5
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-fable-5",
"name": "Claude Fable 5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 10,
"output": 50,
"cacheRead": 1,
"cacheWrite": 12.5
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-opus-5",
"name": "Claude Opus 5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 5,
"output": 25,
"cacheRead": .5,
"cacheWrite": 6.25
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-sonnet-5-5",
"name": "Claude Sonnet 5.5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 2,
"output": 10,
"cacheRead": .2,
"cacheWrite": 2.5
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-sonnet-5",
"name": "Claude Sonnet 5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 2,
"output": 10,
"cacheRead": .2,
"cacheWrite": 2.5
},
"contextWindow": 1e6,
"contextWindows": [{
"id": "200k",
"label": "200K",
"contextWindow": 2e5
}, {
"id": "1m",
"label": "1M",
"contextWindow": 1e6
}],
"contextWindowDefault": "1m",
"maxTokens": 128e3,
"thinkingLevelMap": {
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-mythos-5",
"name": "Claude Mythos 5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"cost": {
"input": 10,
"output": 50,
"cacheRead": 1,
"cacheWrite": 12.5
},
"contextWindow": 1e6,
"maxTokens": 128e3,
"thinkingLevelMap": {
"minimal": "low",
"xhigh": "xhigh",
"max": "max"
},
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-opus-4-8",
"name": "Claude Opus 4.8",
"status": "deprecated",
"replacedBy": "claude-opus-5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 2576,
"preferredSidePx": 2576,
"tokenMode": "provider"
} },
"contextWindow": 1e6,
"maxTokens": 128e3,
"compat": { "codeMode": "preferred" }
},
{
"id": "claude-haiku-4-5",
"name": "Claude Haiku 4.5",
"reasoning": true,
"input": ["text", "image"],
"mediaInput": { "image": {
"maxSidePx": 1568,
"preferredSidePx": 1568,
"tokenMode": "provider"
} },
"contextWindow": 2e5,
"maxTokens": 64e3,
"compat": { "codeMode": "capable" }
}
]
}
},
"discovery": {
"claude-cli": "static",
"anthropic": "refreshable"
}
};
var modelIdNormalization = { "providers": { "anthropic": { "aliases": {
"fable": "claude-fable-5-1",
"fable-5": "claude-fable-5",
"fable-5.1": "claude-fable-5-1",
"fable-5-1": "claude-fable-5-1",
"haiku": "claude-haiku-5-5",
"haiku-5.5": "claude-haiku-5-5",
"haiku-5-5": "claude-haiku-5-5",
"opus-5.5": "claude-opus-5-5",
"opus-5-5": "claude-opus-5-5",
"opus-5": "claude-opus-5",
"opus": "claude-opus-5-5",
"opus-4.8": "claude-opus-4-8",
"opus-4.7": "claude-opus-4-7",
"opus-4.6": "claude-opus-4-6",
"mythos-5": "claude-mythos-5",
"sonnet-5.5": "claude-sonnet-5-5",
"sonnet-5-5": "claude-sonnet-5-5",
"sonnet-5": "claude-sonnet-5",
"sonnet": "claude-sonnet-5-5",
"sonnet-4.6": "claude-sonnet-4-6"
} } } };
//#endregion
//#region extensions/anthropic/cli-constants.ts
const CLAUDE_CLI_BACKEND_ID = "claude-cli";
/** Retired OpenClaw auth profile replaced by Claude CLI's native login. */
const CLAUDE_CLI_PROFILE_ID = `anthropic:${CLAUDE_CLI_BACKEND_ID}`;
/** Explicit thinking opt-out for Claude CLI routes unsupported by Claude Code. */
const CLAUDE_CLI_OFF_THINKING_PROFILE = {
levels: [{ id: "off" }],
defaultLevel: "off"
};
/** Non-secret marker telling OpenClaw that the installed Claude CLI owns auth. */
const CLAUDE_CLI_NATIVE_AUTH_MARKER = ["openclaw", "claude-cli-native-auth"].join(":");
const CLAUDE_CLI_CLEAR_ENV = [
"ANTHROPIC_API_KEY",
"ANTHROPIC_API_KEY_OLD",
"ANTHROPIC_API_TOKEN",
"ANTHROPIC_AUTH_TOKEN",
"ANTHROPIC_BASE_URL",
"ANTHROPIC_CUSTOM_HEADERS",
"ANTHROPIC_OAUTH_TOKEN",
"ANTHROPIC_UNIX_SOCKET",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW",
"CLAUDE_CODE_DISABLE_1M_CONTEXT",
"CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING",
"MAX_THINKING_TOKENS",
"CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",
"CLAUDE_CODE_ENTRYPOINT",
"CLAUDE_CODE_OAUTH_REFRESH_TOKEN",
"CLAUDE_CODE_OAUTH_SCOPES",
"CLAUDE_CODE_OAUTH_TOKEN",
"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",
"CLAUDE_CODE_PLUGIN_CACHE_DIR",
"CLAUDE_CODE_PLUGIN_SEED_DIR",
"CLAUDE_CODE_REMOTE",
"CLAUDE_CODE_USE_COWORK_PLUGINS",
"CLAUDE_CODE_USE_BEDROCK",
"CLAUDE_CODE_USE_FOUNDRY",
"CLAUDE_CODE_USE_VERTEX",
"OTEL_EXPORTER_OTLP_ENDPOINT",
"OTEL_EXPORTER_OTLP_HEADERS",
"OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
"OTEL_EXPORTER_OTLP_LOGS_HEADERS",
"OTEL_EXPORTER_OTLP_LOGS_PROTOCOL",
"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT",
"OTEL_EXPORTER_OTLP_METRICS_HEADERS",
"OTEL_EXPORTER_OTLP_METRICS_PROTOCOL",
"OTEL_EXPORTER_OTLP_PROTOCOL",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
"OTEL_EXPORTER_OTLP_TRACES_HEADERS",
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL",
"OTEL_LOGS_EXPORTER",
"OTEL_METRICS_EXPORTER",
"OTEL_SDK_DISABLED",
"OTEL_TRACES_EXPORTER"
];
const CLAUDE_CLI_DEFAULT_MODEL_REF = `${CLAUDE_CLI_BACKEND_ID}/claude-opus-5-5`;
/** Canonical model ref routed to the Claude CLI backend by Anthropic setup. */
const CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_REF = `anthropic/${CLAUDE_CLI_DEFAULT_MODEL_REF.slice(11)}`;
const CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS = modelCatalog.providers[CLAUDE_CLI_BACKEND_ID].models.map(({ id }) => `${CLAUDE_CLI_BACKEND_ID}/${id}`);
/**
* 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.
*/
const CLAUDE_CLI_ROUTE_PROBE_MODEL_IDS = CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS.map((ref) => ref.slice(11));
const CLAUDE_CLI_CANONICAL_ALLOWLIST_REFS = CLAUDE_CLI_ROUTE_PROBE_MODEL_IDS.map((id) => `anthropic/${id}`);
/** Provider-owned aliases shared by setup, pricing, and native CLI selectors. */
const CLAUDE_MODEL_ID_ALIASES = new Map(Object.entries(modelIdNormalization.providers.anthropic.aliases));
const CLAUDE_CLI_MODEL_ALIASES = {
...Object.fromEntries(CLAUDE_MODEL_ID_ALIASES),
...Object.fromEntries(CLAUDE_CLI_ROUTE_PROBE_MODEL_IDS.map((id) => [id, id])),
opus: "opus",
sonnet: "sonnet",
fable: "fable",
haiku: "haiku"
};
const CLAUDE_CLI_SESSION_ID_FIELDS = [
"session_id",
"sessionId",
"conversation_id",
"conversationId"
];
//#endregion
export { CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS as a, CLAUDE_CLI_NATIVE_AUTH_MARKER as c, CLAUDE_CLI_ROUTE_PROBE_MODEL_IDS as d, CLAUDE_CLI_SESSION_ID_FIELDS as f, CLAUDE_CLI_CLEAR_ENV as i, CLAUDE_CLI_OFF_THINKING_PROFILE as l, modelCatalog as m, CLAUDE_CLI_CANONICAL_ALLOWLIST_REFS as n, CLAUDE_CLI_DEFAULT_MODEL_REF as o, CLAUDE_MODEL_ID_ALIASES as p, CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_REF as r, CLAUDE_CLI_MODEL_ALIASES as s, CLAUDE_CLI_BACKEND_ID as t, CLAUDE_CLI_PROFILE_ID as u };