import { Capability } from '../capabilities.js'; import type { AgentAdapter, AgentSpawnConfig, Backend } from '../types.js'; import type { PIProviderDiscovery } from './discovery.js'; import { type PIAgentProcess, type SpawnFn, type SwitchResult } from './session-support.js'; export type { PIAgentProcess } from './session-support.js'; /** Collaborators the daemon owns and a trial replaces. Both are injected rather than defaulted so * the host PI home and its auth mirroring are not reachable from this module (§13 A1, A6). */ export interface PIAdapterHooks { /** `PI_CODING_AGENT_DIR` for every session this instance spawns (§13 P4). */ agentDir?: string; /** Run before spawn with the resolved agent dir: the daemon mirrors the host credential here, a * trial writes its dummy token. Never a module default (§13 A5/A6). */ prepareAgentDir?: (agentDir: string) => void; /** The user's PI catalog (`~/.pi/agent/models.json`), source of user-defined provider * definitions. Injected, never defaulted: reading the host PI home is exactly the ambient reach * a trial must not have (§13 A1). Left unset, no custom provider is mirrored. */ userModelsPath?: string; } export declare class PIAdapter implements AgentAdapter { readonly backend: Backend; readonly capabilities: Set; private readonly sessions; private readonly spawner; private readonly providerDiscovery; private readonly configuredProviderOverrides; private readonly sessionPathRegistry; /** Injected PI home, or undefined when the caller left it to the daemon default. */ private readonly configuredAgentDir; private readonly prepareAgentDir; /** Injected user catalog path, or undefined when this instance mirrors no custom provider. */ private readonly userModelsPath; /** sessionDir for the .jsonl path convention. Exposed for tests. */ readonly sessionDir: string; constructor(spawner?: SpawnFn, sessionDir?: string, providerDiscovery?: PIProviderDiscovery, hooks?: PIAdapterHooks); private gatewayOverrides; spawn(config: AgentSpawnConfig): PIAgentProcess; /** Record the exact transcript path restored by rewind before the next resume spawn. */ registerSessionPath(sessionId: string, sessionPath: string): void; /** * Resolve an existing JSONL path from the live registry or filename-only disk discovery. * Stale and synthesized registry entries are evicted before discovery. */ resolveSessionPath(sessionId: string): string | null; /** * Switch an existing subprocess (identified by onSessionKey) to serve a different PI session. * Returns {ok:false, cancelled:false} if the session key or target session ID is unknown. * NTH-1: onSessionKey routes the switch to the correct subprocess (spec done-when #1 omits it, * but it is architecturally required for multi-session adapters). */ switchSession(sessionId: string, onSessionKey: string): Promise; close(sessionKey: string): Promise; kill(sessionKey: string): boolean; listSessions(): string[]; }