import { type ModelRegistry, type ThinkingLevel } from "@earendil-works/pi-coding-agent"; import { type Model } from "@earendil-works/pi-ai"; import type { BuildWorkerAdapter, BuildWorkerRequest } from "./buildWorker.js"; export interface PiNestedSession { prompt(text: string, options?: Readonly<{ expandPromptTemplates?: boolean; source?: "interactive" | "rpc" | "extension"; }>): Promise; waitForIdle(): Promise; abort(): Promise; dispose(): void; subscribe(listener: (event: unknown) => void): () => void; getSessionStats(): { tokens: { input: number; output: number; }; cost: number; }; readonly isIdle: boolean; readonly state?: Readonly<{ messages?: readonly unknown[]; }>; } export interface PiNestedSessionInput { cwd: string; model: Readonly; thinkingLevel: ThinkingLevel; modelRegistry: ModelRegistry; authStorage: ModelRegistry["authStorage"]; tools: readonly string[]; toolPolicy: BuildWorkerRequest["toolPolicy"]; declaredWriteSet: readonly string[]; protectedWorkspacePaths: readonly string[]; onResult(value: unknown): void; } export interface PiNestedSessionFactory { create(input: Readonly): Promise>; } export interface PiBuildWorkerAdapterOptions { repositoryRoot: string; model: Readonly; thinkingLevel: ThinkingLevel; modelRegistry: ModelRegistry; now(): string; family?: string; protectedWorkspacePaths: readonly string[]; sessionFactory?: Readonly; } /** Opaque full Pi model object. Only provider/id are inspected; every other * runtime field is preserved and passed through to createAgentSession. */ export type PiBuildModel = Readonly>; /** * Create an isolated in-memory Pi worker. The nested session reuses the exact * trusted outer registry/model/auth objects, disables recursive resource * discovery, exposes only the immutable request's tools plus one terminating * result tool, and is always disposed. */ export declare function createPiBuildWorkerAdapter(options: Readonly): Readonly; export declare function buildWorkerOutputArtifactPath(request: Pick, contractId: string): string; export declare function buildWorkerToolDefinitions(input: Readonly): unknown[]; export declare function createWorkspaceReadGuard(cwdValue: string, protectedWorkspacePaths?: readonly string[]): (path: string) => string;