import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent"; import type { MergedConfig } from "../../config/config-layer.js"; import { type SubagentResult } from "../../forge-subagent.js"; import { attachViewportObserver } from "../../viewport/events.js"; import { type PhaseDescriptor } from "../run-task.js"; import type { BugRecord } from "./bug-id.js"; import type { RunBugPipelineOptions, RunBugPipelineResult } from "./run-bug-types.js"; export interface BugPhaseDispatchParams { opts: RunBugPipelineOptions; phase: PhaseDescriptor; bugId: string; cwd: string; ctx: ExtensionCommandContext; storeCli: string; currentPhaseIndex: number; iterationCounts: Record; dispatchCounts: Record; modelRoutingConfig: MergedConfig; registry: RunBugPipelineOptions["registry"]; /** Whether this is a new bug — only used to decide the triage-prefix body. */ isNewBug: boolean | undefined; originalArg: string | undefined; /** Raw sub-workflow markdown already loaded + marker/audience-checked by the caller. */ subWorkflowMd: string; /** Bug record read before this phase (status used for compose + cache key). */ bugRecordBefore: BugRecord | null; bugStatusBeforePhase: string | undefined; /** True when bugId is still a PENDING- placeholder (triage of a new bug). */ pendingBugId: boolean; } export type BugPhaseDispatchOutcome = { kind: "return"; result: RunBugPipelineResult; } | { kind: "ok"; result: SubagentResult; finishPhaseNode: (status: "completed" | "failed" | "escalated") => void; observer: ReturnType; phaseStart: number; writeDebug: (rec: Record) => void; toolExecutionEvents: Array<{ toolName?: string; result?: unknown; }>; debugLogPath: string | null; debugLogDisabled: boolean; }; /** * Run a single bug phase's subagent dispatch and classify the immediate outcome * (persona-load failure, subagent throw, cancellation, or non-zero exit) into a * discriminated result. On success returns `kind: "ok"` with the live locals the * caller's loop needs for bugId capture / verdict / advance handling. */ export declare function dispatchBugPhase(p: BugPhaseDispatchParams): Promise;