import type { Logger } from 'pino';
import type { ReviewJob } from '../../frameworks/queue/pQueueAdapter.js';
import type { ReviewProgress, ProgressEvent } from '../../modules/review-execution/entities/progress/progress.type.js';
import { FileSystemReviewRequestTrackingGateway } from '../../modules/tracking/interface-adapters/gateways/fileSystem/reviewRequestTracking.fileSystem.js';
import { GitLabDiffStatsFetchGateway } from '../../modules/statistics-insights/interface-adapters/gateways/diffStatsFetch.gitlab.gateway.js';
import { GitHubDiffStatsFetchGateway } from '../../modules/statistics-insights/interface-adapters/gateways/diffStatsFetch.github.gateway.js';
import type { ClaudeModelName } from '../../modules/review-execution/entities/modelRouting/modelRouting.schema.js';
import type { TokenUsage } from '../../modules/token-accounting/entities/tokenUsage/tokenUsage.schema.js';
import { SelectModelForReviewUseCase } from '../../modules/review-execution/usecases/selectModelForReview/selectModelForReview.usecase.js';
import { ProjectConfigRoutingPolicyGateway } from '../../modules/review-execution/interface-adapters/gateways/projectConfig/routingPolicy.projectConfig.gateway.js';
import { TrackTokenUsageUseCase } from '../../modules/token-accounting/usecases/trackTokenUsage/trackTokenUsage.usecase.js';
import { GetBudgetStatusUseCase } from '../../modules/token-accounting/usecases/getBudgetStatus/getBudgetStatus.usecase.js';
import { BudgetStatusPresenter, type BudgetStatusViewModel } from '../../modules/token-accounting/interface-adapters/presenters/budgetStatus.presenter.js';
import { type ClaudeProcessRunner } from '../../modules/claude-invocation/interface-adapters/gateways/claudeSession.cli.gateway.js';
import type { ClaudeSessionGateway } from '../../modules/claude-invocation/entities/claudeSession/claudeSession.gateway.js';
import type { McpCompletionBridge } from '../../modules/claude-invocation/entities/sessionCompletion/mcpCompletion.gateway.js';
import type { ReviewReportGateway } from '../../modules/claude-invocation/entities/sessionCompletion/reviewReport.gateway.js';
import type { BillingStateGateway } from '../../modules/claude-invocation/entities/billingState/billingState.gateway.js';
import type { EnvironmentGateway } from '../../modules/claude-invocation/entities/billingState/environment.gateway.js';
import type { WorktreeGateway } from '../../modules/worktree-management/entities/worktree/worktree.gateway.js';
import type { GitCommandExecutor } from '../../modules/worktree-management/entities/gitCommand/gitCommand.gateway.js';
/**
 * Bundle of gateways needed by runClaudeReviewJob. Built in the composition
 * root so the Fastify process, the supervisor/billing timers, and the MCP
 * completion bridge can share the same instances.
 */
export interface ClaudeInvocationDeps {
    sessionGateway: ClaudeSessionGateway;
    completionBridge: McpCompletionBridge;
    reportGateway: ReviewReportGateway;
    billingState: BillingStateGateway;
    environment: EnvironmentGateway;
    timeoutMs: number;
    pollIntervalMs: number;
}
/**
 * Gateways and use cases required by invokeClaudeReview. Extracted from the
 * function body so production wiring stays in the composition root and tests
 * can inject stubs without mocking the entire function.
 */
export interface ClaudeInvokerDependencies {
    diffStatsFetchFactory: (platform: 'gitlab' | 'github') => GitLabDiffStatsFetchGateway | GitHubDiffStatsFetchGateway;
    routingPolicyGateway: ProjectConfigRoutingPolicyGateway;
    selectModelForReview: SelectModelForReviewUseCase;
    trackingGateway: FileSystemReviewRequestTrackingGateway;
    trackTokenUsage: TrackTokenUsageUseCase;
    getBudgetStatus: GetBudgetStatusUseCase;
    budgetStatusPresenter: BudgetStatusPresenter;
    broadcastBudgetStatus: (viewModel: BudgetStatusViewModel) => void;
    getEnabledLocalPaths?: () => string[];
    invocation: ClaudeInvocationDeps;
    worktreeGateway: WorktreeGateway;
    gitExecutor: GitCommandExecutor;
}
/**
 * Default wiring used when invokeClaudeReview is called without explicit deps.
 *
 * Production (the HTTP daemon) MUST override `broadcastBudgetStatus` and
 * `getEnabledLocalPaths` from the composition root in `main/routes.ts`,
 * otherwise the live budget broadcast and the multi-localPath sum are lost.
 * The no-op `broadcastBudgetStatus` here is intentional for tests and CLI
 * one-shots where there is no WebSocket fanout to perform.
 */
/**
 * Build the environment for spawning a Claude child process.
 *
 * Strips CLAUDECODE so a Claude-launched ReviewFlow does not leak its parent
 * session marker into the child, and forces TERM=dumb + CI=true to keep the
 * child in non-interactive mode.
 */
export declare function buildSpawnEnv(processEnv: NodeJS.ProcessEnv, override?: Record<string, string>): NodeJS.ProcessEnv;
/**
 * Default process runner used by createDefaultClaudeInvocationDeps when the
 * composition root does not provide one. Wraps node:child_process.spawn so
 * tests can inject a fake runner instead.
 */
export declare function defaultProcessRunner(): ClaudeProcessRunner;
export declare function createDefaultClaudeInvocationDeps(): ClaudeInvocationDeps;
export declare function createDefaultClaudeInvokerDependencies(): ClaudeInvokerDependencies;
export declare function resolveMcpServerPath(): string;
export declare function writeMcpContext(job: ReviewJob): void;
/**
 * Build MCP config JSON for --mcp-config flag.
 * Returns a self-contained JSON string with ONLY the review-progress server.
 * Used with --strict-mcp-config to isolate reviews from project .mcp.json
 * (which may contain other MCP servers that cause timeouts).
 */
export declare function buildMcpConfigJson(): string;
export declare function cleanupMcpContext(jobId: string): void;
export interface InvocationResult {
    success: boolean;
    exitCode: number | null;
    stdout: string;
    stderr: string;
    durationMs: number;
    finalProgress?: ReviewProgress;
    cancelled?: boolean;
    usage?: TokenUsage | null;
    selectedModel?: ClaudeModelName;
}
export type ProgressCallback = (progress: ReviewProgress, event?: ProgressEvent) => void;
/**
 * Build MCP system prompt for progress tracking
 * This instruction is AUTHORITATIVE and forces Claude to use MCP tools
 */
export declare function buildMcpSystemPrompt(job: ReviewJob): string;
/**
 * Invoke Claude Code CLI for a review job
 * @param job - The review job to execute
 * @param logger - Pino logger instance
 * @param onProgress - Optional callback for progress updates
 * @param signal - Optional AbortSignal to cancel the review
 */
export declare function invokeClaudeReview(job: ReviewJob, logger: Logger, onProgress?: ProgressCallback, signal?: AbortSignal, deps?: ClaudeInvokerDependencies): Promise<InvocationResult>;
/**
 * Send desktop notification
 */
export declare function sendNotification(title: string, message: string, logger: Logger): void;
//# sourceMappingURL=claudeInvoker.d.ts.map