import { ClientSideConnection, type SessionNotification } from "@oh-my-pi/pi-utils/acp"; import type { Context, Model, ProviderSessionState } from "../../types.js"; import { type JsonSchemaValidationResult } from "../../utils/schema/json-schema-validator.js"; import { type McpCallHandler, type McpToolDefinition } from "./mcp-bridge.js"; import type { StepWriter } from "./step-writer.js"; /** Per-step request settings. */ export interface AgyStepOptions { cwd?: string; reasoning?: string; signal?: AbortSignal; /** Non-secret credential revision; a changed revision restarts agy's native token cache. */ credentialVersion?: string; } /** ACP operations required by the host; injectable without module or environment mutation. */ export type AgyConnection = Pick; /** Owned process/connection resources. close must terminate the transport and is idempotent. */ export interface AgyTransport { connection: AgyConnection; exited: Promise; close(): void; } /** Arguments for the production transport or an isolated test transport. */ export interface AgyTransportOptions { geminiDir: string; cwd: string; tools: readonly McpToolDefinition[]; signal: AbortSignal; onCall: McpCallHandler; onUpdate(notification: SessionNotification): void; } /** A scheduled host deadline; cancellation must be idempotent. */ export interface AgyTimer { cancel(): void; } /** Clock seam keeps lifecycle tests isolated from global timers. */ export type AgyScheduler = (delayMs: number, callback: () => void) => AgyTimer; /** Dependency seam for deterministic ACP lifecycle tests, not an alternative inference API. */ export interface AgyHostOptions { startTransport?: (options: AgyTransportOptions) => Promise; holdLimitMs?: number; cancelTimeoutMs?: number; announcementTimeoutMs?: number; startupTimeoutMs?: number; schedule?: AgyScheduler; } /** Owns one ACP process and its live ledger; callers must retain it between tool steps. */ export declare class AgyHost implements ProviderSessionState { #private; /** geminiDir is the account-scoped agy configuration and conversation directory. */ constructor(geminiDir: string, options?: AgyHostOptions); /** Stable identity for retaining a host when a caller omitted providerSessionState. */ get conversationId(): string | undefined; /** True while inference or an unresolved tool result still belongs to this host. */ get hasPendingTurn(): boolean; /** Emit one assistant step, parking at a tool call or finishing at the ACP turn end. */ step(model: Model, context: Context, options: AgyStepOptions, writer: StepWriter): Promise; /** Immediately stop all work and settle promises/timers; retained disk history can still be forked. */ close(): void; /** Stop first, await process exit, then remove only conversations this host created (never fork sources). */ dispose(): Promise; } /** Explains rejected arguments with the failing paths and the tool's expected schema. */ export declare function describeToolArguments(tool: McpToolDefinition, args: unknown, validation?: JsonSchemaValidationResult): string;