import { ModelRegistry, type AgentSession } from "@earendil-works/pi-coding-agent"; import { BossmodeResourceLoader, type McpRuntimeSettings } from "./resources.js"; import { ModelCredentialBinding } from "../../config/pi-adapt/credentials.js"; import type { AgentRuntime, AgentHandle, AgentStreamEvent, CreateAgentOpts, ContextUsage, MemberActiveToolInfo, RuntimePromptOptions } from "../types.js"; export declare class PiSdkAgentHandle implements AgentHandle { private session; private modelRegistry; private credentials; private resourceLoader; private onSessionMaterialized?; private modelRef; private credentialId; private listeners; private mcpConfig?; private unsubscribeSession; private promptAttempt; /** Outlives SDK preflight, where Agent.abort() has no active controller yet. */ private promptAbortIntent; private compactAttempts; private manualCompactionOutcome; private destroyed; private destroyPromise; /** Called once only after every SDK teardown surface succeeded. */ private onTeardownSuccess; private sessionReferencePublished; /** Live set of bossmode custom tool names (from createBossmodeSdkTools) — sole source for "bossmode" classification. */ private bossmodeToolNames; private executionOwner; constructor(session: AgentSession, modelRegistry: ModelRegistry, credentials: ModelCredentialBinding, resourceLoader: BossmodeResourceLoader, modelRef: string, credentialId: string, bossmodeToolNames: Iterable, executionOwner: { memberId: string; resolveSourceRef: () => string | null; }, onTeardownSuccess?: () => void, onSessionMaterialized?: ((session: { sessionId?: string; sessionFile?: string; }) => void) | undefined, initialMcpConfig?: McpRuntimeSettings); private dispatchExecution; private observeExecutionEvidence; private interruptAttempts; private dispatchCompact; private publishSessionReferenceIfMaterialized; private emit; subscribe(fn: (event: AgentStreamEvent) => void): () => void; private promptOperation; prompt(message: string, options?: RuntimePromptOptions): Promise; private promptInternal; abort(options?: { preserveCompaction?: boolean; }): void; destroy(): void; /** Idempotent awaitable teardown: every caller awaits the SAME settlement * (repeated calls wait for the first, they never return early while the * first teardown is still in flight). Collection covers every surface the * SDK actually exposes: the session's own abort (which awaits waitForIdle), * extension session_shutdown handler failures (delivered via onError — * emit() catches handler throws and never rejects), emit failure itself, * and the synchronous dispose (registered resource cleanups, e.g. provider * session caches — AggregateError on failure). Each stage runs even when an * earlier one fails; all errors are aggregated into one throw at the end. */ destroyAndWait(): Promise; private runTeardown; waitForIdle(): Promise; refreshModelRegistry(_opts?: { allowNetwork?: boolean; }): Promise; private refreshModelRegistryInternal; setModel(modelRef: string, credentialId: string): Promise; private setModelInternal; setThinkingLevel(level: string): void; getContextUsage(): Promise; isDestroyed(): boolean; readSystemPrompt(): Promise; getActiveTools(): MemberActiveToolInfo[]; /** Called by the owner at the idle boundary before the next prompt. */ refreshPrompt(opts: { agentPrompt: string; appendSystemPrompt: string[]; }): void; private resourceOperations; private trackResourceOperation; compact(): Promise<{ aborted: boolean; }>; private compactInternal; } export declare class PiSdkRuntime implements AgentRuntime { readonly name = "pi-cli"; private handles; private creationCleanupFailures; /** Shared shutdown settlement: concurrent shutdownAll calls await the same teardown. */ private shutdownSettlement; createAgent(opts: CreateAgentOpts): Promise; private createAgentInternal; shutdownMember(memberId: string): Promise; shutdownAll(): Promise; } //# sourceMappingURL=pi.d.ts.map