openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
534 lines (533 loc) • 19.7 kB
JavaScript
import { i as CLAUDE_CLI_MODEL_ALIASES, n as CLAUDE_CLI_CLEAR_ENV, o as CLAUDE_CLI_SESSION_ID_FIELDS, r as CLAUDE_CLI_DEFAULT_MODEL_REF, s as OPENCLAW_MCP_TOOL_PREFIX, t as CLAUDE_CLI_BACKEND_ID } from "./.setup/cli-constants-D8BFCp6p.mjs";
import { i as parseClaudeCliJsonlLifecycleEvent, r as parseClaudeCliJsonlEvent, t as classifyClaudeCliErrorCode } from "./.setup/cli-output-CjgZis4O.mjs";
import { isRecord, normalizeOptionalLowercaseString, normalizeSortedUniqueTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
import { requiresClaudeMandatoryAdaptiveThinking, resolveClaudeHaiku55ModelIdentity } from "openclaw/plugin-sdk/claude-model-runtime";
import { createHmac, randomBytes } from "node:crypto";
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
import { resolveExecModePolicy } from "openclaw/plugin-sdk/exec-approvals-runtime";
//#region extensions/anthropic/cli-shared.ts
const CLAUDE_LEGACY_SKIP_PERMISSIONS_ARG = "--dangerously-skip-permissions";
const CLAUDE_PERMISSION_MODE_ARG = "--permission-mode";
const CLAUDE_SETTING_SOURCES_ARG = "--setting-sources";
const CLAUDE_EXCLUDE_DYNAMIC_SYSTEM_PROMPT_SECTIONS_ARG = "--exclude-dynamic-system-prompt-sections";
const CLAUDE_SETTINGS_ARG = "--settings";
const CLAUDE_EFFORT_ARG = "--effort";
const CLAUDE_BARE_ARG = "--bare";
const CLAUDE_SAFE_MODE_ARG = "--safe-mode";
const CLAUDE_DISABLE_SLASH_COMMANDS_ARG = "--disable-slash-commands";
const CLAUDE_NO_CHROME_ARG = "--no-chrome";
const CLAUDE_TOOLS_ARG = "--tools";
const CLAUDE_ALLOWED_TOOLS_ARG = "--allowedTools";
const CLAUDE_DISALLOWED_TOOLS_ARG = "--disallowedTools";
const CLAUDE_STRICT_MCP_CONFIG_ARG = "--strict-mcp-config";
const CLAUDE_NO_SESSION_PERSISTENCE_ARG = "--no-session-persistence";
const CLAUDE_MAX_TURNS_ARG = "--max-turns";
const CLAUDE_SAFE_SETTING_SOURCES = "user";
const CLAUDE_DENY_MCP_TOOLS_VALUE = "mcp__*";
const CLAUDE_RESTRICTED_SETTINGS = "{\"disableAllHooks\":true,\"enabledPlugins\":{},\"autoMemoryEnabled\":false,\"claudeMdExcludes\":[\"**/CLAUDE.md\",\"**/CLAUDE.local.md\",\"**/.claude/rules/**\"]}";
/** Map OpenClaw's effective context budget to Claude Code's native compactor. */
function resolveClaudeCliAutoCompactEnv(e) {
if (typeof e !== "number" || !Number.isFinite(e)) return;
const t = Math.floor(e);
if (t <= 0) return;
return { CLAUDE_CODE_AUTO_COMPACT_WINDOW: String(t) };
}
/**
* Map OpenClaw's fixed thinking levels to Claude Code's per-process budget.
*
* Claude Code 2.x reads MAX_THINKING_TOKENS for print-mode runs and a positive
* integer requests that fixed token budget. Mandatory-adaptive models ignore
* that projection, so they retain adaptive thinking and use --effort instead.
* These fixed budgets match OpenClaw's canonical provider defaults in
* packages/ai/src/providers/simple-options.ts.
*/
function resolveClaudeCliThinkingEnv(e, t) {
if (requiresClaudeMandatoryAdaptiveThinking({ id: t }) || e !== "off" && resolveClaudeHaiku55ModelIdentity({ id: t })) return;
switch (e) {
case "off": return { MAX_THINKING_TOKENS: "0" };
case "minimal": return {
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING: "1",
MAX_THINKING_TOKENS: "1024"
};
case "low": return {
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING: "1",
MAX_THINKING_TOKENS: "2048"
};
case "medium": return {
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING: "1",
MAX_THINKING_TOKENS: "8192"
};
case "high":
case "xhigh": return {
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING: "1",
MAX_THINKING_TOKENS: "16384"
};
case "max": return {
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING: "1",
MAX_THINKING_TOKENS: "32768"
};
case "adaptive":
case void 0: return;
default: return e;
}
}
function isOpenClawRequestedYolo(e) {
const t = (e.agentId ? resolveAgentConfig(e.config ?? {}, e.agentId)?.tools?.exec : void 0) ?? e.config?.tools?.exec;
return resolveExecModePolicy({
mode: t?.mode,
security: t?.security ?? "full",
ask: t?.ask ?? "off"
}).mode === "full";
}
/** Keep filesystem settings user-scoped and normalize native permission flags together. */
function normalizeClaudeBackendArgs(e) {
const t = e.baseArgs;
const n = [];
let r = false;
let i = false;
for (let e = 0; e < t.length; e += 1) {
const a = t[e] ?? "";
if (a === CLAUDE_LEGACY_SKIP_PERMISSIONS_ARG) continue;
if (a === CLAUDE_PERMISSION_MODE_ARG || a === CLAUDE_SETTING_SOURCES_ARG) {
const o = t[e + 1];
if (typeof o === "string" && o.trim().length > 0 && !o.startsWith("-")) {
if (a === CLAUDE_PERMISSION_MODE_ARG) {
r = true;
n.push(a, o);
} else {
i = true;
n.push(a, CLAUDE_SAFE_SETTING_SOURCES);
}
e += 1;
}
continue;
}
if (a.startsWith(`${CLAUDE_PERMISSION_MODE_ARG}=`)) {
const e = a.slice(`${CLAUDE_PERMISSION_MODE_ARG}=`.length).trim();
if (e.length > 0 && !e.startsWith("-")) {
r = true;
n.push(`${CLAUDE_PERMISSION_MODE_ARG}=${e}`);
}
continue;
}
if (a.startsWith(`${CLAUDE_SETTING_SOURCES_ARG}=`)) {
i = true;
n.push(`${CLAUDE_SETTING_SOURCES_ARG}=${CLAUDE_SAFE_SETTING_SOURCES}`);
continue;
}
n.push(a);
}
if (!i) n.push(CLAUDE_SETTING_SOURCES_ARG, CLAUDE_SAFE_SETTING_SOURCES);
if (!r && e.controlOperation !== "compact" && isOpenClawRequestedYolo(e)) n.push(CLAUDE_PERMISSION_MODE_ARG, "bypassPermissions");
return n;
}
function applyClaudeCliEffortArgs(e, t, n) {
const r = normalizeOptionalLowercaseString(t);
switch (r) {
case "off": return requiresClaudeMandatoryAdaptiveThinking({ id: n }) ? [
...stripClaudeEffortArgs(e),
CLAUDE_EFFORT_ARG,
"low"
] : [...e];
case "minimal":
case "low": return [
...stripClaudeEffortArgs(e),
CLAUDE_EFFORT_ARG,
"low"
];
case "adaptive": return stripClaudeEffortArgs(e);
case "medium":
case "high":
case "xhigh":
case "max": return [
...stripClaudeEffortArgs(e),
CLAUDE_EFFORT_ARG,
r
];
default: return [...e];
}
}
function stripClaudeEffortArgs(e) {
const t = [];
for (let n = 0; n < e.length; n += 1) {
const r = e[n] ?? "";
if (r === CLAUDE_EFFORT_ARG) {
const t = e[n + 1];
if (typeof t === "string" && t.trim().length > 0 && !t.startsWith("-")) n += 1;
continue;
}
if (r.startsWith(`${CLAUDE_EFFORT_ARG}=`)) continue;
t.push(r);
}
return t;
}
const CLAUDE_SIDE_QUESTION_VARIADIC_VALUE_ARGS = /* @__PURE__ */ new Set([
CLAUDE_ALLOWED_TOOLS_ARG,
"--allowed-tools",
CLAUDE_DISALLOWED_TOOLS_ARG,
"--disallowed-tools",
CLAUDE_TOOLS_ARG,
"--mcp-config"
]);
const CLAUDE_RESTRICTED_VARIADIC_VALUE_ARGS = /* @__PURE__ */ new Set([
.../* @__PURE__ */ new Set([
CLAUDE_TOOLS_ARG,
CLAUDE_ALLOWED_TOOLS_ARG,
"--allowed-tools",
CLAUDE_DISALLOWED_TOOLS_ARG,
"--disallowed-tools"
]),
"--add-dir",
"--file"
]);
const CLAUDE_RESTRICTED_VALUE_ARGS = /* @__PURE__ */ new Set([
CLAUDE_PERMISSION_MODE_ARG,
CLAUDE_SETTING_SOURCES_ARG,
CLAUDE_SETTINGS_ARG,
"--agent",
"--agents",
"--managed-settings",
"--plugin-dir",
"--plugin-dir-no-mcp",
"--plugin-url",
"--system-prompt",
"--system-prompt-file",
"--append-system-prompt",
"--append-system-prompt-file"
]);
const CLAUDE_RESTRICTED_BARE_ARGS = /* @__PURE__ */ new Set([
CLAUDE_BARE_ARG,
CLAUDE_SAFE_MODE_ARG,
CLAUDE_DISABLE_SLASH_COMMANDS_ARG,
"--chrome",
CLAUDE_NO_CHROME_ARG,
CLAUDE_STRICT_MCP_CONFIG_ARG,
CLAUDE_LEGACY_SKIP_PERMISSIONS_ARG,
"--allow-dangerously-skip-permissions",
"--ide"
]);
const CLAUDE_SIDE_QUESTION_VALUE_ARGS = /* @__PURE__ */ new Set([
CLAUDE_PERMISSION_MODE_ARG,
"--session-id",
"--resume",
"--resume-session-at",
"-r",
CLAUDE_MAX_TURNS_ARG
]);
const CLAUDE_SIDE_QUESTION_BARE_ARGS = /* @__PURE__ */ new Set([
"--continue",
"-c",
"--fork-session",
CLAUDE_BARE_ARG,
CLAUDE_SAFE_MODE_ARG,
CLAUDE_STRICT_MCP_CONFIG_ARG,
CLAUDE_NO_SESSION_PERSISTENCE_ARG
]);
function stripClaudeArgs(e, t) {
const n = [];
for (let r = 0; r < e.length; r += 1) {
const i = e[r] ?? "";
const a = i.indexOf("=");
const o = a > 0 ? i.slice(0, a) : i;
if (t.bare?.has(o)) continue;
if (t.variadicValue?.has(o)) {
if (a < 0) while (typeof e[r + 1] === "string" && !e[r + 1]?.startsWith("-")) r += 1;
continue;
}
if (t.value?.has(o)) {
if (a < 0) {
const t = e[r + 1];
if (typeof t === "string" && !t.startsWith("-")) r += 1;
}
continue;
}
n.push(i);
}
return n;
}
function resolveClaudeCliSideQuestionExecutionArgs(e) {
return [
...stripClaudeArgs(stripClaudeEffortArgs(e), {
bare: CLAUDE_SIDE_QUESTION_BARE_ARGS,
variadicValue: CLAUDE_SIDE_QUESTION_VARIADIC_VALUE_ARGS,
value: CLAUDE_SIDE_QUESTION_VALUE_ARGS
}),
CLAUDE_SAFE_MODE_ARG,
CLAUDE_TOOLS_ARG,
"",
CLAUDE_DISALLOWED_TOOLS_ARG,
CLAUDE_DENY_MCP_TOOLS_VALUE,
CLAUDE_STRICT_MCP_CONFIG_ARG,
CLAUDE_NO_SESSION_PERSISTENCE_ARG,
CLAUDE_MAX_TURNS_ARG,
"1",
CLAUDE_PERMISSION_MODE_ARG,
"default"
];
}
function readClaudeToolDenials(e) {
const t = [];
for (let n = 0; n < e.length; n += 1) {
const r = e[n] ?? "";
if (r === CLAUDE_DISALLOWED_TOOLS_ARG || r === "--disallowed-tools") while (typeof e[n + 1] === "string" && !e[n + 1]?.startsWith("-")) {
n += 1;
t.push(...(e[n] ?? "").split(","));
}
else if (r.startsWith(`${CLAUDE_DISALLOWED_TOOLS_ARG}=`) || r.startsWith("--disallowed-tools=")) t.push(...r.slice(r.indexOf("=") + 1).split(","));
}
return t;
}
function resolveClaudeCliRestrictedExecutionArgs(e, t) {
const n = readClaudeToolDenials(e);
const r = stripClaudeArgs(e, {
bare: CLAUDE_RESTRICTED_BARE_ARGS,
variadicValue: CLAUDE_RESTRICTED_VARIADIC_VALUE_ARGS,
value: CLAUDE_RESTRICTED_VALUE_ARGS
});
r.push(CLAUDE_SETTING_SOURCES_ARG, "", CLAUDE_SETTINGS_ARG, CLAUDE_RESTRICTED_SETTINGS, CLAUDE_DISABLE_SLASH_COMMANDS_ARG, CLAUDE_NO_CHROME_ARG, CLAUDE_STRICT_MCP_CONFIG_ARG, CLAUDE_TOOLS_ARG, [...t.native, ...t.discovery ?? []].join(","));
if (t.openClaw.length > 0) r.push(CLAUDE_ALLOWED_TOOLS_ARG, t.openClaw.map((e) => `${OPENCLAW_MCP_TOOL_PREFIX}${e}`).join(","));
const i = normalizeSortedUniqueTrimmedStringList([...n, ...t.openClaw.length === 0 ? [CLAUDE_DENY_MCP_TOOLS_VALUE] : []]);
if (i.length > 0) r.push(CLAUDE_DISALLOWED_TOOLS_ARG, i.join(","));
return r;
}
function resolveClaudeCliExecutionArgs(e, t = {}) {
const n = normalizeClaudeBackendArgs(e);
const r = e.hostOwnedTools?.includes("exec") ? [
...stripClaudeArgs(n, { variadicValue: /* @__PURE__ */ new Set([CLAUDE_DISALLOWED_TOOLS_ARG, "--disallowed-tools"]) }),
CLAUDE_DISALLOWED_TOOLS_ARG,
[.../* @__PURE__ */ new Set([...readClaudeToolDenials(n), "Bash"])].join(",")
] : n;
const i = e.executionMode === "side-question" ? resolveClaudeCliSideQuestionExecutionArgs(r) : applyClaudeCliEffortArgs(r, e.thinkingLevel, e.modelId);
const a = e.toolAvailability ? resolveClaudeCliRestrictedExecutionArgs(i, e.toolAvailability) : i;
return t.excludeDynamicSystemPromptSections && e.executionMode !== "side-question" ? [...a, CLAUDE_EXCLUDE_DYNAMIC_SYSTEM_PROMPT_SECTIONS_ARG] : a;
}
function normalizeClaudeBackendConfig(e) {
const t = e.output ?? "jsonl";
const n = e.input ?? "stdin";
return {
...e,
output: t,
liveSession: e.liveSession ?? (t === "jsonl" && n === "stdin" ? "claude-stdio" : void 0),
input: n
};
}
//#endregion
//#region extensions/anthropic/cli-tool-naming.ts
const CLAUDE_CLI_TOOL_NAMING_HEADING = "## OpenClaw tool names in Claude Code";
const CLAUDE_CLI_TOOL_NAMING_SECTION = [CLAUDE_CLI_TOOL_NAMING_HEADING, `OpenClaw MCP: \`${OPENCLAW_MCP_TOOL_PREFIX}<name>\`. Deferred: ToolSearch \`select:${OPENCLAW_MCP_TOOL_PREFIX}<name>\` first.`].join("\n");
const CLAUDE_CLI_MESSAGE_TOOL_GUIDANCE = `Tool-only replies: \`${OPENCLAW_MCP_TOOL_PREFIX}message(action=send)\`. Native \`SendMessage\`/\`PushNotification\` cannot deliver OpenClaw replies.`;
function appendClaudeCliToolNamingGuidance(e, t = []) {
if (t.length === 0 || !e.trim() || e.includes(CLAUDE_CLI_TOOL_NAMING_HEADING)) return e;
const n = t.includes("message") ? `\n${CLAUDE_CLI_MESSAGE_TOOL_GUIDANCE}` : "";
return `${e}\n\n${CLAUDE_CLI_TOOL_NAMING_SECTION}${n}\n`;
}
//#endregion
//#region extensions/anthropic/cli-backend.ts
const CLAUDE_CLI_CREDENTIAL_FINGERPRINT_KEY = randomBytes(32);
const CLAUDE_CLI_DEFAULT_ARGS = [
"-p",
"--output-format",
"stream-json",
"--include-partial-messages",
"--verbose",
"--setting-sources",
"user",
"--allowedTools",
"mcp__openclaw__*",
"--disallowedTools",
"ScheduleWakeup,CronCreate,CronList,Bash(run_in_background:true),Monitor"
];
const CLAUDE_NATIVE_TOOL_CAPABILITIES = {
read: "read",
grep: "read",
write: "write",
edit: "edit",
bash: "exec",
webfetch: "web_fetch",
websearch: "web_search",
askuserquestion: "ask_user"
};
function projectClaudeNativeToolAuthority(e) {
const t = new Set(e.map((e) => e.trim().toLowerCase()));
return [...new Set(Object.entries(CLAUDE_NATIVE_TOOL_CAPABILITIES).filter(([e]) => t.has(e)).map(([, e]) => e))];
}
const CLAUDE_MANAGED_NATIVE_TOOLS = ["Agent", "Workflow"];
/** Operator selection under `plugins.entries.anthropic.config.managedNativeTools`. */
function resolveClaudeManagedNativeTools(e) {
const t = e.config?.plugins?.entries?.anthropic?.config;
const n = isRecord(t) ? t.managedNativeTools : void 0;
if (!isRecord(n)) return [];
const r = isRecord(n.agents) ? n.agents : void 0;
const i = Object.hasOwn(r ?? {}, e.agentId) ? r?.[e.agentId] : n.default;
return Array.isArray(i) ? CLAUDE_MANAGED_NATIVE_TOOLS.filter((e) => i.includes(e)) : [];
}
function createClaudeCliAuthInput(e) {
const t = e.value.trim();
if (!t) return;
const n = Buffer.from(t, "utf8");
let r = false;
return {
env: { [e.envName]: "3" },
clearEnv: [...CLAUDE_CLI_CLEAR_ENV],
secretInput: {
fd: 3,
fingerprint: createHmac("sha256", CLAUDE_CLI_CREDENTIAL_FINGERPRINT_KEY).update(n).digest("hex"),
createData: () => {
if (r) throw new Error("Claude CLI credential input is no longer available");
return Buffer.from(n);
}
},
cleanup: async () => {
r = true;
n.fill(0);
}
};
}
function resolveClaudeCliAuthInput(e, t) {
if (e?.type === "oauth" && "access" in e) {
const t = "expires" in e ? e.expires : void 0;
if (typeof t !== "number" || !Number.isFinite(t) || t <= Date.now()) throw new Error("Selected Claude CLI OAuth credential is expired or invalid. Re-authenticate the selected profile and retry. OpenClaw did not start the run.");
if (typeof e.access !== "string") return;
return createClaudeCliAuthInput({
envName: "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",
value: e.access
});
}
if (e?.type === "token" && "token" in e && typeof e.token === "string") return createClaudeCliAuthInput({
envName: "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",
value: e.token
});
if (e?.type === "api_key" && "key" in e && typeof e.key === "string") return createClaudeCliAuthInput({
envName: t(e.key) ? "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR" : "CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",
value: e.key
});
}
function buildAnthropicCliBackend(e = {}) {
return {
id: CLAUDE_CLI_BACKEND_ID,
modelProvider: "anthropic",
liveTest: {
defaultModelRef: CLAUDE_CLI_DEFAULT_MODEL_REF,
defaultImageProbe: true,
defaultMcpProbe: true,
docker: {
npmPackage: "@anthropic-ai/claude-code",
binaryName: "claude"
}
},
runtimeArtifact: {
kind: "bundled-package-tree",
packageName: "@anthropic-ai/claude-code",
entrypoint: "command",
nativeExecutableNames: ["claude", "claude.exe"]
},
bundleMcp: true,
bundleMcpMode: "claude-config-file",
nativeToolMode: "selectable",
hostOwnedTools: ["exec", "process"],
toolAvailabilityEnforcement: "execution-args",
transformSystemPrompt: ({ systemPrompt: e, openClawMcpToolNames: t }) => appendClaudeCliToolNamingGuidance(e, t),
projectNativeToolAuthority: projectClaudeNativeToolAuthority,
resolveManagedNativeTools: resolveClaudeManagedNativeTools,
nativeToolSearch: "ToolSearch",
sideQuestionToolMode: "disabled",
ownsNativeCompaction: true,
manualCompaction: {
buildPrompt: (e) => {
const t = e?.trim();
return t ? `/compact ${t}` : "/compact";
},
input: "arg",
validateOutput: (e) => {
for (const t of e.split("\n")) try {
const e = JSON.parse(t);
if (e.compact_result === "success" || e.type === "system" && e.subtype === "compact_boundary") return { ok: true };
} catch {}
return {
ok: false,
reason: "Claude CLI did not confirm that native compaction ran."
};
}
},
subscriptionAuthDispatch: true,
config: {
command: "claude",
args: [...CLAUDE_CLI_DEFAULT_ARGS],
resumeArgs: [
...CLAUDE_CLI_DEFAULT_ARGS,
"--resume",
"{sessionId}"
],
forkArg: "--fork-session",
resumeAtArg: "--resume-session-at",
output: "jsonl",
liveSession: "claude-stdio",
input: "stdin",
modelArg: "--model",
modelAliases: CLAUDE_CLI_MODEL_ALIASES,
imageArg: "@",
imagePathScope: "workspace",
sessionArgs: ["--session-id", "{sessionId}"],
sessionMode: "always",
reseedFromRawTranscriptWhenUncompacted: true,
freshSessionRecovery: "invalidated-only",
sessionIdFields: [...CLAUDE_CLI_SESSION_ID_FIELDS],
systemPromptFileArg: "--append-system-prompt-file",
systemPromptMode: "append",
systemPromptWhen: "always",
clearEnv: [...CLAUDE_CLI_CLEAR_ENV],
serialize: true
},
normalizeConfig: normalizeClaudeBackendConfig,
resolveModelId: ({ modelId: e, contextWindow: t }) => t === "1m" ? `${e}[1m]` : e,
authEpochMode: "profile-only",
autoSelectAuthProfile: false,
prepareExecution: (t) => {
const n = t;
const prepare = (e = () => false) => {
const r = resolveClaudeCliAuthInput(n.authCredential, e);
const i = n.isolatedCompletionPrompt !== void 0;
const a = !i && t.executionMode === "agent" ? { async *execute(e) {
const { executeClaudeCli: t } = await import("./.setup/cli.runtime-COSGmpo0.mjs");
e.assertCurrent?.();
yield* t(e, r?.secretInput);
} } : void 0;
return {
env: {
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS: "1",
...t.toolAvailability ? { ENABLE_TOOL_SEARCH: t.toolAvailability.discovery?.includes("ToolSearch") || t.toolAvailability.native.includes("ToolSearch") ? "true" : "false" } : {},
...resolveClaudeCliAutoCompactEnv(t.contextTokenBudget),
...t.contextWindow === "200k" ? { CLAUDE_CODE_DISABLE_1M_CONTEXT: "1" } : {},
...resolveClaudeCliThinkingEnv(t.thinkingLevel, t.modelId),
...r?.env
},
...i ? { isolatedCompletionEnforced: true } : {},
...r?.clearEnv ? { clearEnv: r.clearEnv } : {},
...r?.secretInput ? { secretInput: r.secretInput } : {},
...r?.cleanup ? { cleanup: r.cleanup } : {},
...a
};
};
const r = e.ensureDynamicSystemPromptSectionsSupport?.();
const i = n.authCredential?.type === "api_key" ? import("openclaw/plugin-sdk/provider-stream-shared").then((e) => e.isAnthropicOAuthApiKey) : void 0;
return r || i ? Promise.all([r, i]).then(([, e]) => prepare(e)) : prepare();
},
parseJsonlEvent: parseClaudeCliJsonlEvent,
classifyErrorCode: classifyClaudeCliErrorCode,
parseJsonlLifecycleEvent: parseClaudeCliJsonlLifecycleEvent,
resolveExecutionArgs: (t) => resolveClaudeCliExecutionArgs(t, { excludeDynamicSystemPromptSections: e.supportsDynamicSystemPromptSections?.() })
};
}
//#endregion
//#region extensions/anthropic/setup-api.ts
var setup_api_default = definePluginEntry({
id: "anthropic",
name: "Anthropic Setup",
description: "Lightweight Anthropic setup hooks",
register(e) {
e.registerCliBackend(buildAnthropicCliBackend());
}
});
//#endregion
export { setup_api_default as default };