import { spawn } from "node:child_process"; import { type ProbeDeps } from "./probe.js"; import { type EngineAdapter, type EngineRunOptions, type EngineRunResult } from "./engine.js"; import type { RuntimeModule, RuntimeProbe, RuntimeUsage } from "../types.js"; export interface DeepseekAdapterDeps { binary?: string; /** 测试注入:使用现成的兼容 server,不 spawn `deepseek`。 */ serverUrl?: string; authToken?: string; fetchFn?: typeof fetch; spawnFn?: typeof spawn; /** External servers must explicitly attest compatible progress tool events. */ progressEventMapping?: boolean; } /** 解析 PATH 上的 `deepseek` dispatcher CLI。 */ export declare function resolveDeepseekCommand(deps?: ProbeDeps): string | null; export declare function probeDeepseekTui(deps?: ProbeDeps): RuntimeProbe; /** * DeepSeek TUI 引擎。驱动 `deepseek serve --http` 暴露的 headless runtime * API(HTTP/SSE),不是交互式 TUI 也不是 ACP —— HTTP/SSE 是其文档化的完整 * runtime 面;ACP 目前只是保守的编辑器基线。 * * 权限姿态:course run 在 owner 本机的隔离工作区执行,线程一律 * `allow_shell/trust_mode/auto_approve = true`(owner 信任,无审批人可交互)。 */ export declare class DeepseekTuiAdapter implements EngineAdapter { readonly id: "deepseek-tui"; private readonly explicitBinary; private readonly explicitServerUrl; private readonly explicitAuthToken; private readonly fetchFn; private readonly spawnFn; readonly progressEventMappingEnabled: boolean; readonly progressPromptInjectionEnabled: boolean; private resolvedBinary; constructor(deps?: DeepseekAdapterDeps); run(opts: EngineRunOptions): Promise; private resolveBinary; private acquireHandle; /** * BYOA continues to use the user's default DeepSeek state directory. Managed mode * pins the durable RuntimeThreadStore to the RuntimeSession workspace even though * the credential-bearing server process is still reclaimed after every activation. */ private spawnEnv; private prepareManagedRuntimeDir; private compactionMarkerPath; private compactionRequired; private markCompactionRequired; private clearCompactionRequired; private managedActivationId; private createThread; private logAppliedServerPrompt; private patchThreadSettings; private compactThread; private runtimeSystemContext; private startTurnAndReadEvents; private interruptTurn; private readEvents; private requestJson; } /** 仅测试用:清空进程池。 */ export declare function __resetDeepseekTuiPoolForTests(): void; /** Accept both OpenAI-compatible and canonical usage fields from terminal SSE frames. */ export declare function extractDeepseekUsage(payload: any): RuntimeUsage | undefined; export declare const deepseekTuiModule: RuntimeModule;