import type { Agent, AgentMessage, AgentTurnEndContext } from "@oh-my-pi/pi-agent-core"; import type { Model } from "@oh-my-pi/pi-ai"; import type { AutoPrewalkDecision } from "../auto-prewalk/classifier.js"; import type { Settings } from "../config/settings.js"; import type { LocalProtocolOptions } from "../internal-urls/index.js"; import type { PlanModeState } from "../plan-mode/state.js"; import { type ConfiguredThinkingLevel } from "@oh-my-pi/pi-tui/thinking"; import type { PlanProposalHandler } from "../tools/resolve.js"; import type { PlanYolo, Prewalk } from "./agent-session-types.js"; import type { SessionManager } from "./session-manager.js"; /** Hidden plan steering is consumed within the live run and must not reappear after a context rebuild. */ export declare function isPrewalkPlanNudge(message: AgentMessage): boolean; /** Capabilities the prewalk coordinator borrows from its owning session. */ export interface PrewalkCoordinatorHost { agent: Agent; sessionManager: SessionManager; settings: Settings; model(): Model | undefined; configuredThinkingLevel(): ConfiguredThinkingLevel | undefined; restoreThinkingLevel(level: ConfiguredThinkingLevel | undefined): void; resolveDefaultPrewalk(): Prewalk | undefined; /** Resolves `prewalk.autoTarget`; warns and returns undefined when it cannot be used. */ resolveAutoPrewalkTarget(): Prewalk | undefined; /** Judges a new task for `prewalk.auto`; undefined when there is nothing to judge. */ classifyAutoPrewalk(request: string, signal: AbortSignal): Promise; emitNotice(level: "info" | "warning" | "error", message: string, source?: string): void; setModelTemporary(model: Model, thinkingLevel?: ConfiguredThinkingLevel): Promise; setActiveToolsByName(names: string[]): Promise; restoreNonMCPToolPresentation(nonMCPToolNames: string[], nonMCPMountedToolNames: string[], registeredToolNames: readonly string[]): Promise; getAllToolNames(): string[]; getActiveToolNames(): string[]; getEnabledToolNames(): string[]; getMountedXdevToolNames(): string[]; hasBuiltInTool(name: string): boolean; getPlanModeState(): PlanModeState | undefined; setPlanModeState(state: PlanModeState | undefined): void; getPlanReferencePath(): string; setPlanProposalHandler(handler: PlanProposalHandler | null): void; waitForSessionMessagePersistence(message: AgentMessage): Promise; localProtocolOptions(): LocalProtocolOptions; } /** Initial state for prewalk and plan-yolo startup flows. */ export interface PrewalkCoordinatorOptions { prewalk?: Prewalk; planYolo?: PlanYolo; /** Keep `prewalk.auto` away from this session until `/new` (`--no-prewalk`). */ suppressAutoPrewalk?: boolean; } /** Coordinates one-way model prewalks and automatic plan-yolo handoffs. */ export type PrewalkRestartResult = "armed" | "reset" | "rejected"; export declare class PrewalkCoordinator { #private; constructor(host: PrewalkCoordinatorHost, options?: PrewalkCoordinatorOptions); /** Current prewalk target, if the one-way switch remains armed. */ get state(): Prewalk | undefined; /** Whether the armed prewalk would perform a model or thinking-level handoff. */ get willHandoff(): boolean; /** A later model/effort selection owns the active model, even if its identity is unchanged. */ releaseHandoff(): void; /** Retire the outgoing cycle and prepare a configured prewalk for a fresh main session. */ resetForNewSession(enabled: boolean): Promise; /** `/prewalk off`: keep auto-prewalk out of this session until `/new`. */ suppressAuto(): void; /** * Starts a new user task under `prewalk.auto: on`. An auto handoff belongs to the task that armed it, so the * session returns to that task's planning model unless a later explicit selection took ownership. An auto arm * the previous task never used is dropped so this task is judged on its own. Manual and configured arms stay. */ beginAutoTask(): Promise; /** * Starts judging a new user task. Undefined when auto-prewalk is off for this turn or an arm already owns it. * Never rejects: a failed judgment resolves undefined, so the turn proceeds as if auto-prewalk were off. */ classifyAuto(request: string, signal: AbortSignal): Promise | undefined; /** * Applies a decision right before its task is dispatched; synchronous, so nothing can interleave before the * request carries it. `suggest` reports the decision. Under `on`, a confident prewalk arms a handoff from the * active model to the auto target and returns the plan nudge for the caller to deliver with the task. */ applyAuto(decision: AutoPrewalkDecision | undefined): AgentMessage | undefined; /** Advances the one-way prewalk switch at a completed assistant-turn boundary. */ advanceAtTurnEnd(liveMessages: AgentMessage[], context: AgentTurnEndContext | undefined): Promise; /** Drops a pending prewalk hand-off (e.g. `prewalk.enabled` turned off); no-op when none is armed. */ disarm(): void; /** Arms a prewalk immediately for an explicit slash-command request; it takes over a matching auto arm. */ arm(target: Model, thinkingLevel?: ConfiguredThinkingLevel): boolean; /** * Restores the planning model and reuses or creates the requested one-shot handoff. * A different active arm rejects the restart before the current model changes. */ restart(source: Model, sourceThinkingLevel: ConfiguredThinkingLevel | undefined, target: Model, targetThinkingLevel: ConfiguredThinkingLevel | undefined): Promise; /** Lazily enables plan-yolo's plan phase before the first prompt is built. */ armPlanYoloIfNeeded(): Promise; }