/** * Per-task prewalk-suitability classifier for `prewalk.auto`. * * Asks the native System One judge one choice question about where a request's * expensive reasoning belongs: up front (`prewalk`: the active model * investigates and plans, the cheap target finishes), throughout (`primary`: * stay on the active model), or nowhere (`direct`: nothing worth handing off * from). This is not a difficulty classifier (see `auto-thinking/classifier.ts`) * and it trusts only the calibrated native probabilities, so a prompted chat or * on-device model never stands in for the native judge. * * Resolves `undefined` when there is nothing to judge: no native backend, or a * low-signal request ("ok", "thanks"). Throws on every other failure (no key, * malformed answer, abort, timeout); the caller treats both as "do not arm". */ import type { AgentMessage, AgentTelemetryConfig } from "@oh-my-pi/pi-agent-core"; import type { ModelRegistry } from "../config/model-registry.js"; import type { Settings } from "../config/settings.js"; import { type JudgmentUsage } from "../judgment/index.js"; export type PrewalkRoute = "prewalk" | "primary" | "direct"; /** `P(prewalk)` a task needs before auto-prewalk arms: a wrong hand-off costs more than a missed one. */ export declare const AUTO_PREWALK_MIN_PROBABILITY = 0.7; /** A judgment slower than this gives way to the unmodified turn; an optimization never makes the user wait longer. */ export declare const AUTO_PREWALK_TIMEOUT_MS = 4000; /** The turn to classify. */ export interface AutoPrewalkInput { /** The expanded prompt the agent is about to act on. */ request: string; /** Transcript before `request`; only its latest request/reply pair reaches the judge, to resolve follow-ups. */ history: readonly AgentMessage[]; } export interface AutoPrewalkDecision { /** The judge's winning route. */ route: PrewalkRoute; /** Every route's probability; sums to 1. */ probabilities: Record; /** Concentration of the distribution, 0–1. */ confidence: number; /** Whether to arm prewalk: `prewalk` won with `P(prewalk) >= `{@link AUTO_PREWALK_MIN_PROBABILITY}. */ arm: boolean; } export interface ClassifyAutoPrewalkDeps { settings: Settings; registry: ModelRegistry; sessionId?: string; signal?: AbortSignal; onUsage?: (usage: JudgmentUsage) => void; telemetry?: AgentTelemetryConfig; } /** * Classify where `input.request`'s reasoning belongs. * @returns `undefined` when the request is low-signal or the `judge` role does not resolve first to a native * System One backend. * @throws when the judge cannot produce a usable answer within {@link AUTO_PREWALK_TIMEOUT_MS}. */ export declare function classifyAutoPrewalk(input: AutoPrewalkInput, deps: ClassifyAutoPrewalkDeps): Promise;