import type { TrajectoryStep } from '../../../types/index.js'; import { BaseConnector } from '../../../services/connectors/base/BaseConnector.js'; import type { ConnectorAuth, ConnectorRequest, ConnectorResponse, ConnectorProgressCallback, ConnectorRawEventCallback, SubprocessConfig, ConnectorProtocol } from '../../../services/connectors/types.js'; /** * Subprocess Connector for CLI tools * Spawns a child process and captures output */ export declare class SubprocessConnector extends BaseConnector { readonly type: ConnectorProtocol; readonly name: string; readonly supportsStreaming = true; /** * Default trace-context strategy for subprocess agents: propagate via the * W3C TRACEPARENT env var. Subclasses (Claude Code, Kiro, Pi) override * `serviceName` to point at their OpenSearch service.name for Strategy C. */ traceContext: { propagateEnv: boolean; }; protected config: SubprocessConfig; constructor(config?: Partial); /** * Build input for the subprocess */ buildPayload(request: ConnectorRequest): string; /** * Execute subprocess and capture output */ execute(endpoint: string, // For subprocess, this is the command name request: ConnectorRequest, auth: ConnectorAuth, onProgress?: ConnectorProgressCallback, onRawEvent?: ConnectorRawEventCallback): Promise; /** Buffer of clean stdout lines accumulated during streaming. * Used by onBeforeStreamEnd() to emit a consolidated `response` step. */ private streamBuffer; /** * Parse a stderr chunk in streaming mode. Default is a no-op. * * Override in subclasses for CLIs that carry tool-event markers on stderr. * Implementations should buffer partial lines (chunks rarely align with * line boundaries) and emit steps via `onProgress` AND push them onto * `trajectory` so they appear in the final response. */ protected parseStderrChunk(_chunk: string, _trajectory: TrajectoryStep[], _onProgress?: ConnectorProgressCallback): void; /** * Subclass hook: extra protocol-specific fields to merge into the * connector result `metadata`. Default: none. Claude Code overrides this to * surface the captured `sessionId` (Strategy D trace correlation). */ protected extraResultMetadata(): Record; /** * Parse streaming output and emit steps in real-time. * * For plain-text CLIs (Kiro etc.) we: * 1. strip ANSI escape codes (color, cursor moves, spinner frames) * 2. drop lines that are empty / pure control characters / spinner glyphs * 3. emit each surviving line as an `assistant` step immediately * 4. buffer the cleaned text so `onBeforeStreamEnd()` can emit a final * `response` step containing the full coherent answer (good for the * judge) — without losing the live stream. */ protected parseStreamingOutput(chunk: string, trajectory: TrajectoryStep[], onProgress?: ConnectorProgressCallback): void; /** * On stream end: emit a consolidated `response` step containing the full * clean output. Streaming gave the user real-time visibility; this final * step gives the judge a single coherent answer to grade against. */ protected onBeforeStreamEnd(trajectory: TrajectoryStep[], onProgress?: ConnectorProgressCallback): void; /** * Parse final subprocess output */ parseResponse(data: { stdout: string; stderr: string; exitCode: number; }): TrajectoryStep[]; /** * Parse JSON output into trajectory steps */ protected parseJsonOutput(data: any): TrajectoryStep[]; /** * Health check - verify command exists */ healthCheck(endpoint: string, auth: ConnectorAuth): Promise; } /** * Default instance for convenience */ export declare const subprocessConnector: SubprocessConnector; //# sourceMappingURL=SubprocessConnector.d.ts.map