import type { SandboxMode } from "./session-spawner.js"; /** Sanitized bug detail returned by getBugDetail (see buildSafeBugDetail). */ interface ZenTaoBugDetail { id: number; title?: string; status?: string; severity?: string | number; pri?: string | number; type?: string; resolution?: string; steps?: string; description?: string; comment?: string; files?: Array>; attachments?: Array>; openedFiles?: Array>; [key: string]: unknown; } interface ZenTaoGetBugDetailResult { id: number; found: boolean; bug: ZenTaoBugDetail | null; activation?: unknown; images?: string[]; raw?: Record; } interface ZenTaoClient { getBugDetail(params: { id: number | string; }): Promise; resolveBug(params: { id: number | string; resolution?: string; resolvedBuild?: string; solutionModules: { rootCause: string; fixApproach: string; logicChange: string; impact: string; }; solution?: string; comment?: string; }): Promise; downloadFile(params: { fileId: number; savePath: string; }): Promise<{ fileId: number; savedTo: string; size: number; contentType: string; }>; } export declare function currentAiwsVersion(): string; /** * Classic worker-pool concurrency limiter: at most `parallel` invocations of * `fn` run at once; finished workers pull the next queued item. */ export declare function runWithConcurrency(items: T[], parallel: number, fn: (item: T) => Promise): Promise; /** * Failure classification matrix: * - retry_count >= 3 → needs_human (give up on this bug) * - transient infra error (timeout/tmux/killed/cancelled/missing done.signal) * WITHOUT evidence → transient (nothing was produced to salvage) * - API 4xx/5xx or reasoning_content error (P4) → transient (upstream hiccup; * the request never reached completion) * - transient infra error WITH evidence → failed (no blind retry — the session * did real work before dying, so a retry risks duplicating the fix) * - anything else (missing evidence, explicit build/test failure) → failed */ export declare function classifyFailure(err: unknown, hasEvidence: boolean, retryCount: number): "transient" | "failed" | "needs_human"; /** Fetch the full bug detail (JSON is the single source of truth) into bug/zentao-bug-.json. */ export declare function intakeBugDetail(client: ZenTaoClient, bugId: number, cDir: string): Promise; export declare function validateBugDetail(detail: unknown, expectedBugId: number): string | null; export declare function resolveBug(client: ZenTaoClient, bugId: number, solutionModules: Record): Promise; export interface DoneSignal { kind: "complete" | "skipped" | "needs_human"; reason: string; } /** * Read the sub-session's done.signal. Signal contract (full ws-bugfix handoff): * - `complete` — only after `aiws change finish` succeeded AND bugfix-state * phase=done AND clean worktree; the batch validates this claim itself * - `skipped: <原因>` — requirement unclear / out of capability; no changes made * - `needs_human: <原因>` — partial work done but blocked on a human * * Empty / missing file → needs_human with reason "无信号" (session died without * ever signalling; the caller then falls back to evidence-based classification). */ export declare function parseDoneSignal(cDir: string, taskId: string): Promise; /** * Verify the sub-session's `complete` claim before trusting it (§2.1/3): * - bugfix-state.json phase === "done" * - current branch is back on baseBranch (finish checked it out) * - change/ is an ancestor of HEAD — the merge is visible from the * worktree (git merge-base --is-ancestor exit code 0) * Any step failing → false (caller downgrades complete → skipped). */ export declare function verifyMergedDone(root: string, changeId: string, baseBranch: string): Promise; export interface BatchRunOptions { parallel?: number; yes?: boolean; timeoutMin?: number; dryRun?: boolean; cliCommand?: string; readyMode?: "tui" | "none"; sandbox?: SandboxMode; sandboxImage?: string; sandboxNetwork?: "default" | "none"; /** undefined = new default split layout; false = explicit --no-split fallback. */ split?: boolean; splitLayout?: "h" | "v"; } interface CrashResidue { dirtyWorktree: boolean; resumeBugs: number[]; orphanSessions: number; } /** * Detect crash residue (PROB-BATCH-CRASH-RECOVERY): leftover change branches * from an interrupted run, a dirty worktree, and orphan aiws-task-* tmux * sessions. Read-only — never mutates batch state or branches. */ export declare function detectCrashResidue(root: string, queue: Array<{ bug_id: number; }>): Promise; export declare function bugfixBatchRunCommand(batchId: string, options?: BatchRunOptions): Promise; export {};