import { type Options as SdkOptions } from "@anthropic-ai/claude-agent-sdk"; export type ClaudeRunErrorCode = "CLAUDE_CLI_MISSING" | "CLAUDE_TIMEOUT" | "CLAUDE_CLI_FAILED" | "CLAUDE_EMPTY_RESULT"; export declare class ClaudeRunError extends Error { readonly code: ClaudeRunErrorCode; constructor(message: string, code: ClaudeRunErrorCode); } export interface RunClaudePrintOptions { cwd?: string; timeoutMs: number; /** Optional Claude model id / alias. Empty or "default" keeps Claude Code's own default. */ model?: string; /** Optional adaptive-thinking effort, aligned with the active Claude session. */ effort?: SdkOptions["effort"]; /** * 用户偏好的回复语言(取自 config.language)。传进来时会以 * `appendSystemPrompt` 形式灌给 Claude,保证 quick-commit / prompt-optimizer * 这种一次性调用也跟用户主会话同语言——之前 wand 的 git commit message 会 * 莫名其妙变中英混搭,根因就在这。 */ language?: string; } /** * 解析 SDK 应使用的 claude binary:**优先系统安装的 claude,回退 SDK 内置 native binary**。 * * 优先系统版的原因:node_modules 里的内置 binary 版本在装包那刻就钉死了,会随时间 * 越来越旧,最终可能被 API 端拒绝(实测内置 2.1.138 对部分端点持续 502 重试到超时, * 而系统侧日常更新的 2.1.170 正常)。系统 claude 跟交互式 PTY 会话同源,用户平时 * 一直在用、一直在更新,是最可靠的选择。 * * 内置 binary 仅作兜底(系统没装 claude 时仍可用)。Linux 上必须显式按 libc 选包: * SDK 默认解析在 glibc 系统上可能错选 musl 包直接抛 "native binary not found"。 */ export declare function resolveSdkClaudeBinary(): string | undefined; /** * 用 `@anthropic-ai/claude-agent-sdk` 跑一次"prompt → 单段纯文本"调用, * 等价以前的 `claude -p --output-format text`。 * * 行为对齐 Claude Code 默认: * - 不指定 model / appendSystemPrompt / agent / mcpServers / hooks 等覆盖项, * 完全由 `~/.claude/settings.json`、OAuth 凭据、`CLAUDE_*` 环境变量等 * 用户侧配置接管,与 Claude Code 自身一致。 * - `tools: []` 关掉所有内置工具:这两个调用点(commit message / prompt 优化) * 本质就是"纯文本生成",关掉工具能 (1) 防止 Claude 随手开个工具卡住权限询问; * (2) 避免一次性短调用还顺便加载文件 / 跑 bash 这种副作用。 * - `mcpServers: {}` + `strictMcpConfig: true` 跳过用户配置的全部 MCP 服务器: * 纯文本生成用不上 MCP,但不禁的话每次调用都要连接 MCP(启动慢好几秒)、 * 还把所有 MCP 工具 schema 灌进 system prompt(实测一次多写 1.6 万 token 的 * prompt cache,白花钱)。 * - `persistSession: false`:这些 ephemeral 调用不应该污染 `~/.claude/projects/` * 的会话历史;用户在 wand UI 里也压根看不到这些"虚拟会话"。 * * binary 解析见 `resolveSdkClaudeBinary()`:优先系统 claude(与 PTY 会话同源、 * 版本新),回退 SDK 内置 native binary(系统没装时的零 PATH 依赖兜底)。 */ export declare function runClaudePrint(prompt: string, options: RunClaudePrintOptions): Promise;