import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent"; import type { PhaseRole } from "../../subagent/caller-context.js"; import type { MergedConfig } from "../../config/config-layer.js"; import { type SubagentResult } from "../../forge-subagent.js"; import { getSubagentTools } from "../../forge-tools.js"; import { resolveModelForPhase } from "../../config/model-resolver.js"; import type { RunInitOptions } from "./run-init-types.js"; /** * Inputs required by dispatchSingleAgent. Carries only what one subagent * dispatch needs — no phase descriptor (the step table owns routing). */ export interface InitDispatchParams { opts: RunInitOptions; cwd: string; ctx: ExtensionCommandContext; /** Absolute path to the vendored bundle root (contains init/phases/ + base-pack). */ bundleRoot: string; /** Merged model-routing config from layered config. */ modelRoutingConfig: MergedConfig; /** Raw forge tool definitions (optional — carries forge_ask_user). */ forgeToolDefs?: Parameters[0]; /** * Per-dispatch attempt counter keyed by sub-role label, for OrchestratorTree * node identity (`::`). Mutated by * dispatchSingleAgent so re-dispatches (retries) land on distinct nodes. */ dispatchCounts: Record; /** Ordering hint (wave index) for SessionRegistry.startPhase. */ orderHint: number; } /** * Read the phase prompt from the bundled init/phases/ directory. * Throws on missing file — caller catches and returns failure. */ export declare function readInitPhasePrompt(bundleRoot: string, phaseNum: 1 | 2): string; /** * Read the shared Phase-2 KB-doc generation procedure (Slice 2 / FORGE-S35-T03). * This is `init/generation/generate-kb-doc.md` — the write path, confidence * header, verify-back, and not-applicable stub format shared by EVERY Phase-2 * subagent. It forms the base of every kb-doc / index / context prompt; the * per-step substance fragment and the AGENT PARAMS block are appended by the * pipeline. Throws on missing file — caller catches and returns failure (IL7). */ export declare function readInitSharedProcedure(bundleRoot: string): string; /** * Read one per-step substance fragment from `init/phases/phase-2/.md` * (Slice 2 / FORGE-S35-T03). `name` is a KB_DOC_ID basename (e.g. "stack", * "domain-model") or one of "index" / "context". Each fragment carries only its * own docId's topic focus, discovery input, required output, and not-applicable * stub — so a subagent never sees a sibling's work. Throws a descriptive error * on missing file (naming the fragment) — caller catches and returns failure. */ export declare function readInitPhase2Fragment(bundleRoot: string, name: string): string; /** * Resolve model for a sub-role within the init pipeline. Reads the intended * tier from ROLE_TIER[modelRole] ("sonnet" / "haiku") and resolves the concrete * {provider, model} via resolveModelForPhase, using modelRole as the phase key * and the given personaNoun (matching task-phase-dispatch, which passes the * role — never a display label — as the phase key). The tier is returned * alongside the resolution so callers can surface it via notify. Concrete model * still comes from config; resolution is "inherit" (undefined model) when config * specifies nothing for the role. */ export declare function resolveInitModel(modelRole: string, personaNoun: string, modelRoutingConfig: MergedConfig): ReturnType & { tier: "sonnet" | "haiku" | undefined; }; /** * Dispatch a single subagent for the init pipeline and return its SubagentResult. * All runForgeSubagent calls are wrapped in CallerContextStore.asSubagent + * AskBroker.withUI (IL10 / FORGE-BUG-040 parity). This is the sole subagent * runner invoked by the step machine's subagent steps. */ export declare function dispatchSingleAgent(subLabel: string, subRole: PhaseRole, modelRole: string, prompt: string, _schema: object | undefined, personaNoun: string, p: InitDispatchParams): Promise;