/** * Cursor Agent CLI backend plugin. * 通过 `cursor-agent -p` 命令驱动 agent,stream-json 输出。 */ import { CliAgentBackend, type BaseCliSession, type ParsedOutput } from "../agent/cli-base.js"; import type { AgentSession, AgentSessionActivity, ExecHooks, SessionConfig } from "../agent/types.js"; interface CursorAgentSession extends BaseCliSession { sessionLogPath?: string; /** stream init 事件解析到的实际模型名(session.model 未配置时用于 footer 显示) */ resolvedModel?: string; } export default class CursorAgentBackend extends CliAgentBackend { constructor(); needsStableUserPrefix(): boolean; needsCompactRecoveryReminder(): boolean; command(): string; createSession(config: SessionConfig): Promise; buildSession(config: SessionConfig): CursorAgentSession; buildInput(session: CursorAgentSession, message: string): { args: string[]; stdin?: string; }; parseOutput(stdout: string, session: CursorAgentSession): ParsedOutput; protected loadSessionTranscript(session: CursorAgentSession): Promise<{ sources: { path: string; role: string; }[]; backend: string; agentSessionId: string; events: Iterable | AsyncIterable; }>; protected getExecHooks(session: CursorAgentSession): ExecHooks; protected refreshActivity(sessionId: string, activity: AgentSessionActivity): void; protected probeSessionFileMtime(session: CursorAgentSession): number | null; protected probeSessionLastLine(session: CursorAgentSession): string | null; private getCursorDataDir; private getJsonlPath; /** Cursor 可能用嵌套或扁平两种 jsonl 布局,project slug 也可能与 resolve 结果不一致。 */ private findJsonlPath; private buildJsonlCandidates; private scanProjectsForJsonl; private getCursorProjectKey; /** 从文件尾部倒读,获取最后 N 个完整行。 */ private readLastLines; } export {};