export type HarnessStateName = "intake" | "planning" | "context-selection" | "model-call" | "tool-call" | "patch-proposal" | "verification" | "reporting" | "completed" | "cancelled" | "failed" | "limit-exceeded";
export type TerminalState = "completed" | "cancelled" | "failed" | "limit-exceeded";
export declare const TERMINAL_STATES: ReadonlySet<HarnessStateName>;
export interface StateTransition {
    readonly from: HarnessStateName;
    readonly to: HarnessStateName;
    readonly reason: string;
}
export interface HarnessLimits {
    readonly maxIterations: number;
    readonly maxModelCalls: number;
    readonly maxToolCalls: number;
    readonly maxCommandExecutions: number;
    readonly maxContextBytes: number;
    readonly maxPatchBytes: number;
    readonly maxWallTimeMs: number;
    readonly maxFailureAttempts: number;
}
export declare const DEFAULT_LIMITS: HarnessLimits;
export declare const HARNESS_VERSION = "0.1.7";
export type TaskType = "generate-unit-tests" | "investigate-bug" | "explain-plan" | "verify";
export interface GenerateUnitTestsInput {
    readonly filePath: string;
    readonly targetFunction?: string | undefined;
    readonly context?: string | undefined;
}
export interface InvestigateBugInput {
    readonly description: string;
    readonly filePaths?: readonly string[] | undefined;
    readonly context?: string | undefined;
}
export interface ExplainPlanInput {
    readonly filePath: string;
    readonly question?: string | undefined;
    readonly context?: string | undefined;
}
export interface VerifyInput {
    readonly workspaceRoot: string;
    readonly targetFiles?: readonly string[] | undefined;
}
export type TaskInput = {
    readonly taskType: "generate-unit-tests";
    readonly input: GenerateUnitTestsInput;
} | {
    readonly taskType: "investigate-bug";
    readonly input: InvestigateBugInput;
} | {
    readonly taskType: "explain-plan";
    readonly input: ExplainPlanInput;
} | {
    readonly taskType: "verify";
    readonly input: VerifyInput;
};
export interface RunCounters {
    iterations: number;
    modelCalls: number;
    toolCalls: number;
    commandExecutions: number;
    failureAttempts: number;
    browserNavigations: number;
}
export type RunOutcome = "completed" | "cancelled" | "failed" | "limit-exceeded";
export interface RunResult {
    readonly runId: string;
    readonly fingerprint: string;
    readonly outcome: RunOutcome;
    readonly taskType: TaskType;
    readonly report?: string | undefined;
    readonly patchDiff?: string | undefined;
    readonly failure?: HarnessFailure | undefined;
    readonly startedAt: number;
    readonly finishedAt: number;
    readonly events: readonly HarnessEvent[];
}
export interface RunManifest {
    readonly runId: string;
    readonly fingerprint: string;
    readonly harnessVersion: string;
    readonly taskType: TaskType;
    readonly taskInput: TaskInput;
    readonly limits: HarnessLimits;
    readonly modelId: string;
    readonly workingDirectory: string;
    readonly dryRun: boolean;
    readonly startedAt: string;
    readonly events: readonly HarnessEvent[];
}
export declare const HARNESS_CODES: {
    readonly LIMIT_ITERATIONS: "HARNESS_LIMIT_ITERATIONS";
    readonly LIMIT_MODEL_CALLS: "HARNESS_LIMIT_MODEL_CALLS";
    readonly LIMIT_TOOL_CALLS: "HARNESS_LIMIT_TOOL_CALLS";
    readonly LIMIT_COMMAND_EXEC: "HARNESS_LIMIT_COMMAND_EXECUTIONS";
    readonly LIMIT_CONTEXT_SIZE: "HARNESS_LIMIT_CONTEXT_SIZE";
    readonly LIMIT_PATCH_SIZE: "HARNESS_LIMIT_PATCH_SIZE";
    readonly LIMIT_WALL_TIME: "HARNESS_LIMIT_WALL_TIME";
    readonly LIMIT_FAILURE_ATTEMPTS: "HARNESS_LIMIT_FAILURE_ATTEMPTS";
    readonly MODEL_ERROR: "HARNESS_MODEL_ERROR";
    readonly TOOL_ERROR: "HARNESS_TOOL_ERROR";
    readonly INTERNAL: "HARNESS_INTERNAL";
};
export type HarnessCode = (typeof HARNESS_CODES)[keyof typeof HARNESS_CODES];
export interface HarnessFailure {
    readonly category: HarnessCode;
    readonly message: string;
    readonly detail?: string | undefined;
}
interface BaseEvent {
    readonly schemaVersion: "1";
    readonly runId: string;
    readonly fingerprint: string;
    readonly seq: number;
    readonly ts: number;
}
export interface RunStartedEvent extends BaseEvent {
    readonly type: "run:started";
    readonly taskType: TaskType;
    readonly modelId: string;
    readonly limits: HarnessLimits;
}
export interface StateTransitionEvent extends BaseEvent {
    readonly type: "state:transition";
    readonly from: HarnessStateName;
    readonly to: HarnessStateName;
    readonly reason: string;
}
export interface ModelCallStartedEvent extends BaseEvent {
    readonly type: "model:call:started";
    readonly modelId: string;
    readonly messageCount: number;
    readonly contextBytes: number;
}
export interface ModelCallCompletedEvent extends BaseEvent {
    readonly type: "model:call:completed";
    readonly modelId: string;
    readonly finishReason: string;
    readonly toolCallCount: number;
    readonly usage: {
        readonly requestId: string;
        readonly promptTokens: number;
        readonly completionTokens: number;
        readonly latencyMs: number;
    };
}
export interface ModelCallFailedEvent extends BaseEvent {
    readonly type: "model:call:failed";
    readonly modelId: string;
    readonly errorCode: string;
    readonly message: string;
}
export interface ToolCallStartedEvent extends BaseEvent {
    readonly type: "tool:call:started";
    readonly toolName: string;
    readonly toolCallId: string;
}
export interface ToolCallCompletedEvent extends BaseEvent {
    readonly type: "tool:call:completed";
    readonly toolName: string;
    readonly toolCallId: string;
    readonly durationMs: number;
}
export interface ToolCallFailedEvent extends BaseEvent {
    readonly type: "tool:call:failed";
    readonly toolName: string;
    readonly toolCallId: string;
    readonly errorCode: string;
    readonly message: string;
}
export interface CommandExecutedEvent extends BaseEvent {
    readonly type: "command:executed";
    readonly executable: string;
    readonly argCount: number;
    readonly exitCode: number | null;
    readonly timedOut: boolean;
    readonly durationMs: number;
}
export interface SandboxConfiguredEvent extends BaseEvent {
    readonly type: "sandbox:configured";
    readonly envAllowlist: readonly string[];
    readonly network: "inherit" | "none";
    readonly maxOutputBytes: number;
    readonly timeoutMs: number;
    readonly terminationGraceMs: number;
    readonly cwdRequested: boolean;
}
export interface PatchAppliedEvent extends BaseEvent {
    readonly type: "patch:applied";
    readonly changedFiles: number;
    readonly created: number;
    readonly deleted: number;
}
export interface ReasoningTraceEvent extends BaseEvent {
    readonly type: "reasoning:trace";
    readonly phase: HarnessStateName;
    readonly rationale: string;
    readonly modelResponse?: string | undefined;
}
export interface PatchProposedEvent extends BaseEvent {
    readonly type: "patch:proposed";
    readonly targetFile: string;
    readonly patchBytes: number;
    readonly diff: string;
}
export interface VerificationResultEvent extends BaseEvent {
    readonly type: "verification:result";
    readonly passed: boolean;
    readonly detail: string;
}
export interface RunCompletedEvent extends BaseEvent {
    readonly type: "run:completed";
    readonly report: string;
    readonly patchDiff?: string | undefined;
}
export interface RunCancelledEvent extends BaseEvent {
    readonly type: "run:cancelled";
    readonly reason?: string | undefined;
    readonly atState: HarnessStateName;
}
export interface RunFailedEvent extends BaseEvent {
    readonly type: "run:failed";
    readonly failure: HarnessFailure;
    readonly atState: HarnessStateName;
}
export type BrowserSessionCloseReason = "explicit" | "process-exit" | "chrome-disconnected" | "idle-timeout";
export interface BrowserSessionOpenedEvent extends BaseEvent {
    readonly type: "browser:session-opened";
    readonly sessionId: string;
    readonly cdpPort: number;
    readonly targetId: string;
}
export interface BrowserNavigatedEvent extends BaseEvent {
    readonly type: "browser:navigated";
    readonly sessionId: string;
    readonly originOnly: string;
    readonly httpStatus: number | null;
}
export interface BrowserScreenshotCapturedEvent extends BaseEvent {
    readonly type: "browser:screenshot-captured";
    readonly sessionId: string;
    readonly captureSeq: number;
    readonly persisted: boolean;
    readonly viewportPx: {
        readonly width: number;
        readonly height: number;
    };
    readonly path?: string | undefined;
}
export interface BrowserPageContentCapturedEvent extends BaseEvent {
    readonly type: "browser:page-content-captured";
    readonly sessionId: string;
    readonly captureSeq: number;
    readonly byteLength: number;
}
export interface BrowserSessionClosedEvent extends BaseEvent {
    readonly type: "browser:session-closed";
    readonly sessionId: string;
    readonly reason: BrowserSessionCloseReason;
}
export interface BrowserTrustWarningEvent extends BaseEvent {
    readonly type: "browser:trust-warning";
    readonly sessionId: string;
    readonly warning: string;
}
export interface BrowserErrorEvent extends BaseEvent {
    readonly type: "browser:error";
    readonly sessionId: string;
    readonly code: string;
    readonly message: string;
}
export type BrowserEvent = BrowserSessionOpenedEvent | BrowserNavigatedEvent | BrowserScreenshotCapturedEvent | BrowserPageContentCapturedEvent | BrowserSessionClosedEvent | BrowserTrustWarningEvent | BrowserErrorEvent;
export type HarnessEvent = RunStartedEvent | StateTransitionEvent | ModelCallStartedEvent | ModelCallCompletedEvent | ModelCallFailedEvent | ToolCallStartedEvent | ToolCallCompletedEvent | ToolCallFailedEvent | CommandExecutedEvent | SandboxConfiguredEvent | PatchAppliedEvent | ReasoningTraceEvent | PatchProposedEvent | VerificationResultEvent | RunCompletedEvent | RunCancelledEvent | RunFailedEvent | BrowserEvent;
export {};
//# sourceMappingURL=harness.d.ts.map