/** * BaseProgrammaticAdapter — abstract base class for programmatic (SDK) adapters. * * Provides shared utilities for direct SDK integration without subprocess * or network communication. */ import type { AgentName, AgentCapabilities, ModelCapabilities, AgentConfig, AgentConfigSchema, AuthState, AuthSetupGuidance, Session, InstalledPlugin, PluginInstallOptions, PluginSearchOptions, PluginListing, RunOptions, AgentEvent, ProgrammaticAdapter, CostRecord, SpawnArgs, ParseContext } from '@a5c-ai/comm-adapter'; /** * Abstract base class for programmatic adapters. Provides shared utilities * for direct SDK integration and common functionality. */ export declare abstract class BaseProgrammaticAdapter implements ProgrammaticAdapter { readonly adapterType: "programmatic"; readonly cliCommand = "[programmatic]"; buildSpawnArgs(_options: RunOptions): SpawnArgs; parseEvent(_line: string, _context: ParseContext): AgentEvent | AgentEvent[] | null; abstract readonly agent: AgentName; abstract readonly displayName: string; abstract readonly minVersion?: string; abstract readonly capabilities: AgentCapabilities; abstract readonly models: ModelCapabilities[]; abstract readonly defaultModelId?: string; abstract readonly configSchema: AgentConfigSchema; abstract execute(options: RunOptions): AsyncIterableIterator; abstract detectAuth(): Promise; abstract getAuthGuidance(): AuthSetupGuidance; abstract sessionDir(cwd?: string): string; abstract parseSessionFile(filePath: string): Promise; abstract listSessionFiles(cwd?: string): Promise; abstract readConfig(cwd?: string): Promise; abstract writeConfig(config: Partial, cwd?: string): Promise; readonly hostEnvSignals?: readonly string[]; listPlugins?(): Promise; installPlugin?(pluginId: string, options?: PluginInstallOptions): Promise; uninstallPlugin?(pluginId: string): Promise; searchPlugins?(query: string, options?: PluginSearchOptions): Promise; readHostMetadata?(env: NodeJS.ProcessEnv): Record; /** * Generate a unique run ID for this execution. */ protected generateRunId(): string; /** * Create base event structure with common fields. */ protected createBaseEvent(type: string, runId: string): Record; /** * Helper to create text delta events. */ protected createTextDeltaEvent(runId: string, delta: string, accumulated?: string): AgentEvent; /** * Helper to create tool call start events. */ protected createToolCallStartEvent(runId: string, toolCallId: string, toolName: string, inputAccumulated: string): AgentEvent; /** * Helper to create tool result events. */ protected createToolResultEvent(runId: string, toolCallId: string, toolName: string, output: unknown, durationMs?: number): AgentEvent; /** * Helper to create cost events. */ protected createCostEvent(runId: string, cost: CostRecord): AgentEvent; /** * Helper to create error events. */ protected createErrorEvent(runId: string, code: string, message: string, recoverable?: boolean): AgentEvent; /** * Helper to create message stop events. */ protected createMessageStopEvent(runId: string, text: string): AgentEvent; /** * Validate that required options are present. */ protected validateRunOptions(options: RunOptions): void; /** * Get the model to use for this run, with fallback to default. */ protected resolveModel(options: RunOptions): string; /** * Extract cost information from SDK response. * Subclasses can override this to handle provider-specific cost formats. */ protected extractCostFromResponse(response: unknown): Record | null; /** * Convert provider-specific prompt format to standard format. */ protected normalizePrompt(prompt: string | string[]): string; }