/** * Claude Code CLI backend plugin. * 通过 `claude` 命令驱动 agent,stream-json 模式。 */ import { CliAgentBackend, type BaseCliSession, type ParsedOutput } from "../agent/cli-base.js"; import type { SessionConfig, ExecHooks } from "../agent/types.js"; interface ClaudeSession extends BaseCliSession { permissionMode: string; /** 推理强度(--effort 透传) */ reasoningEffort?: string; } export interface ClaudeBackendOptions { permissionMode?: string; } export default class ClaudeBackend extends CliAgentBackend { private permissionMode; constructor(options?: ClaudeBackendOptions); command(): string; needsStableUserPrefix(): boolean; buildSession(config: SessionConfig): ClaudeSession; buildInput(session: ClaudeSession, message: string): { args: string[]; stdin?: string; }; parseOutput(stdout: string, session: ClaudeSession): ParsedOutput; protected loadSessionTranscript(session: ClaudeSession): Promise<{ sources: { path: string; role: string; }[]; backend: string; agentSessionId: string; events: Iterable | AsyncIterable; }>; /** * 增量扫描 Claude Code session JSONL,提取主 agent 信息。 * model 从 system/init 事件获取,usage 从最后一条 assistant message 获取。 */ private scanJsonl; /** 构造 Claude Code session JSONL 文件路径(需与 Claude Code 的 project key 算法一致) */ private getJsonlPath; protected getExecHooks(session: ClaudeSession): ExecHooks; protected probeSessionFileMtime(session: ClaudeSession): number | null; protected agentEnv(): Record; } export {};