import { spawn } from "node:child_process"; import { type ThinkingLevel } from "../thinking-level.js"; import { type ReviewNetworkMode } from "./isolation.js"; import { type ReviewReportReservation } from "./report-output.js"; import { type ReviewResumeArchive } from "./resume-archive.js"; import { type ReviewWorkLog } from "./work-log.js"; export interface ReviewRequest { readonly extensions?: boolean; readonly sourceDir: string; readonly prompt: string; readonly model?: string; readonly thinking?: ThinkingLevel; readonly piHomeSource?: string; readonly piHomeIncludes?: readonly string[]; readonly allowReadPaths?: readonly string[]; readonly allowWritePaths?: readonly string[]; readonly reportPath?: string; readonly workLogPath?: string; readonly onWorkLogReady?: (path: string) => void; readonly network?: ReviewNetworkMode; readonly allowUnsandboxedWindows?: boolean; readonly timeoutMs?: number; readonly maxRpcOutputBytes?: number; readonly resumable?: boolean; readonly onReportReady?: (path: string) => void; readonly gitTargets?: readonly string[]; /** * Directory holding this run's controller-only scratch. Defaults to the platform's short * shared temporary directory, which keeps the Linux proxy bridge socket inside `sun_path`. * A caller that supplies one owns its safety, so it is validated against the same ownership * chain and broad-or-protected rules as the eval controller scratch base. */ readonly controllerScratchBase?: string; } export interface ReviewResult { readonly report: string; readonly model?: string; readonly thinking?: ThinkingLevel; readonly sandboxed: boolean; readonly warning?: string; readonly cleanupError?: string; readonly reportWriteError?: string; readonly workLogWriteError?: string; readonly workLogPath: string; readonly reportPath: string; readonly resumeToken?: string; } export interface ResumeReviewRequest { readonly resumeToken: string; readonly timeoutMs?: number; readonly maxRpcOutputBytes?: number; readonly reportPath?: string; readonly workLogPath?: string; readonly onWorkLogReady?: (path: string) => void; readonly onReportReady?: (path: string) => void; readonly allowUnsandboxedWindows?: boolean; /** Carried across a resume so a caller keeps controller files where it put them. */ readonly controllerScratchBase?: string; } type ReviewExecutionOutcome = Readonly<{ result: ReviewResult; failure?: never; }> | Readonly<{ failure: Error; result?: never; }>; export declare function finalizeReviewWorkLog(workLog: ReviewWorkLog, outcome: ReviewExecutionOutcome): ReviewResult; export declare function markReviewCleanupFailure(result: ReviewResult): ReviewResult; export declare function cleanupCompletedReviewResumeArchive(archive: ReviewResumeArchive, removeArchive?: (archive: ReviewResumeArchive) => Promise, releaseArchive?: (archive: ReviewResumeArchive) => Promise): Promise; export declare function cleanupUnavailableReviewResumeArchive(archive: ReviewResumeArchive, removeArchive?: (archive: ReviewResumeArchive) => Promise): Promise; export declare function shouldHandleReviewResumeFailure(alreadyHandled: boolean): boolean; export type ReviewResumeFailureKind = "containment" | "in_use" | "prompt_rejected" | "retainable" | "rollback" | "unavailable"; export declare function reviewResumeFailureKind(failure: Error): ReviewResumeFailureKind; export declare function annotateHandledReviewResumeFailure(failure: Error, token: string): Error; export declare function canonicalReviewPiHomeSource(source: string): Promise; export declare function validateProspectiveDefaultReviewOutputs(request: ReviewRequest, piHomeSource: string, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): Promise; export interface RunReviewRpcOptions { readonly workLog?: ReviewWorkLog; readonly heartbeatMs?: number; readonly sensitiveValues?: readonly string[]; readonly terminateProcess?: (child: ReturnType) => void; readonly escalateProcess?: (child: ReturnType) => void; readonly startupFailureGraceMs?: number; readonly maxRpcOutputBytes?: number; } interface ReviewPromptWriter { write(chunk: string): unknown; } export declare function reviewTools(platform?: NodeJS.Platform): readonly string[]; export declare function requestedModelForWorkLog(requestedModel: string | undefined, prompt: string): string; export declare function readinessMetadataForWorkLog(readiness: Readonly<{ version?: string; resolvedModel?: string; }>, prompt: string): Readonly<{ piVersion: string; model: string; }>; export declare function sourcePathForWorkLog(sourcePath: string, prompt: string): string; export declare function sendReviewPrompt(writer: ReviewPromptWriter, prompt: string, startupFailure: Error | undefined): boolean; export declare function shouldSchedulePipeCloseFallback(settled: boolean, alreadyScheduled: boolean): boolean; export declare function createReviewScratchDirectory(scratchBase: string, afterCreate?: (scratch: string) => void | Promise, removeScratch?: (scratch: string) => Promise): Promise; export declare function requiresGitInspection(prompt: string): boolean; export declare function buildReviewPrompt(sourceDir: string, scratchDir: string | undefined, requestPrompt: string, gitContext?: string): string; export declare function piRuntimePaths(executable: string): Promise; export declare function reviewProcessEnvironment(sandboxEnvironment: Readonly>, piEnvironment: Readonly>, runtimeEnvironment?: Readonly): NodeJS.ProcessEnv; export declare function persistReviewReport(report: string, reportPath: string | undefined, reservation?: ReviewReportReservation): Promise; export declare function pruneValidatedReviewResumeArchives(validated: boolean, root?: string): Promise; export declare function runReviewRpc(argv: readonly [string, ...string[]], cwd: string, environment: NodeJS.ProcessEnv, prompt: string, timeoutMs: number, options?: RunReviewRpcOptions): Promise; export declare function runReview(request: ReviewRequest): Promise; export declare function resumeReview(request: ResumeReviewRequest): Promise; export declare function assertReviewResumeOutputsOutsideArchive(archiveDir: string, outputs: Pick, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): Promise; export declare function assertReviewResumeOutputsOutsideStorage(archive: Pick, outputs: Pick, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string): Promise; export declare function assertReviewResumeStateIsRecoverable(state: string): void; export {}; //# sourceMappingURL=runner.d.ts.map