import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
import { type ForgeToolDefs } from "../forge-tools.js";
import { getSessionRegistry } from "../session-registry.js";
import { type PhaseDescriptor } from "./run-task.js";
export declare const BUG_PHASES: PhaseDescriptor[];
export { BUG_SUMMARY_KEY_BY_ROLE } from "../subagent/phase-summary-map.js";
export declare const BUG_TYPE_TOKENS: Record<string, {
    pass: string;
    fail: string;
}>;
export interface RunBugState {
    bugId: string;
    phaseIndex: number;
    iterationCounts: Record<string, number>;
    halted: boolean;
    /** Set on cancellation so the resume prompt says "cancelled" vs "halted". */
    status?: "cancelled" | "halted" | "running";
    lastError?: string;
    savedAt: string;
}
export declare function readBugState(cwd: string, bugId: string, sessionId?: string): RunBugState | null;
export declare function writeBugState(cwd: string, state: RunBugState): void;
export declare function deleteBugState(cwd: string, bugId: string): void;
export declare function isBugStateStale(state: RunBugState): boolean;
export interface BugRecord {
    bugId?: string;
    status?: string;
    summaries?: Record<string, unknown>;
    [key: string]: unknown;
}
export declare function readBugRecord(bugId: string, storeCli: string, cwd: string): BugRecord | null;
export declare function computeNextBugId(bugIds: string[], prefix: string): string;
export declare function assignNextBugId(storeCli: string, cwd: string, prefix?: string): string;
export declare function extractBugIdFromReportText(text: string, prefix: string): string | null;
export declare function preCreateBug(bugId: string, title: string, storeCli: string, cwd: string): boolean;
type BugVerdict = "approved" | "revision" | "n/a" | "missing";
export declare function readBugVerdict(bugRecord: BugRecord | null, phaseRole: string, summaryKeyByRole: Record<string, string | null>): BugVerdict;
export declare function composeBugBody(subWorkflowMd: string, bugId: string, phaseRole: string, bugStatusBeforePhase?: string, summariesBlock?: string): string;
/**
 * Scan tool_execution_end events to extract the bugId written by a triage
 * subagent. Returns the LAST matching tool call's bugId, or null if none found.
 *
 * In pi runtime, the forge_store tool is registered as "forge_store" (not
 * "store-cli"). In Claude Code runtime, subagents may shell out via Bash.
 * This function covers all three paths.
 */
export declare function extractBugIdFromEvents(events: Array<{
    toolName?: string;
    result?: unknown;
}>, prefix?: string): string | null;
export type RunBugPipelineStatus = "completed" | "halted" | "escalated" | "failed" | "cancelled";
export interface RunBugPipelineResult {
    status: RunBugPipelineStatus;
    lastPhaseIndex: number;
    iterationCounts: Record<string, number>;
    lastError?: string;
    model?: string;
    provider?: string;
    /**
     * Project-local orchestrator JSONL path for this run. Callers hand it to
     * archiveRun() to mirror the run into the central transcript archive.
     * Unset only when the pipeline returned before the writer was created.
     */
    orchestratorTranscriptPath?: string;
}
export interface RunBugPipelineOptions {
    bugId: string;
    /** Original free-form text argument when creating a new bug (not a FORGE-BUG-NNN ID).
     *  Passed to triage-phase subagent so it can create the bug with a meaningful description. */
    originalArg?: string;
    /** Whether this is a new bug (free-form text) vs. an existing FORGE-BUG-NNN ID. */
    isNewBug?: boolean;
    cwd: string;
    ctx: ExtensionCommandContext;
    forgeRoot: string;
    storeCli: string;
    preflightGate: string;
    registry: ReturnType<typeof getSessionRegistry>;
    resumeFromState?: RunBugState;
    /**
     * Optional AbortSignal from SessionRegistry. When provided, the pipeline
     * checks signal.aborted between phases and passes the signal to
     * runForgeSubagent so in-flight subagents can be aborted.
     */
    signal?: AbortSignal;
    forgeToolDefs?: ForgeToolDefs;
}
export declare function runBugPipeline(opts: RunBugPipelineOptions): Promise<RunBugPipelineResult>;
export interface RegisterFixBugOptions {
    cwd?: string;
    forgeToolDefs?: ForgeToolDefs;
}
export declare function registerFixBug(pi: ExtensionAPI, options?: RegisterFixBugOptions): void;
