/**
 * Agent harness mode handler — compiles AgentHarnessTaskDefinition into Promptfoo config.
 *
 * @see docs/archive/exec-plans/architecture-overhaul/phase-4-agent-harness.md
 * @see packages/core/src/types/generalized-task.ts — AgentHarnessTaskDefinition
 */
import { compileAgentHarnessTask } from "./compiler.js";
import { AGENT_HARNESS_PROMPT_TEMPLATES } from "./prompts.js";
// Re-export public API
export { AGENT_HARNESS_PROMPT_TEMPLATES } from "./prompts.js";
export { TOOL_PRESETS } from "./tool-presets.js";
export { validateAgentHarnessTask } from "./validation.js";
export { mapAgentAssertion, buildFileExistsAssertion, buildFileContainsAssertion, buildCommandSucceedsAssertion, buildDiffMatchesAssertion, } from "./assertions.js";
export { buildLifecycleExtensions, buildBeforeEachHook, buildAfterEachHook, buildSandboxConfig, } from "./sandbox.js";
export { compileAgentHarnessTask, buildAgentProvider, buildAgentPrompts, buildAgentTestCases, } from "./compiler.js";
// ---------------------------------------------------------------------------
// ModeHandler adapter — wraps compileAgentHarnessTask for registry dispatch
// ---------------------------------------------------------------------------
/** ModeHandler-conformant export for the agent-harness evaluation mode. */
export const handler = {
    getPrompts() {
        return AGENT_HARNESS_PROMPT_TEMPLATES;
    },
    compileTask(task, ctx) {
        if (!("mode" in task) || task.mode !== "agent-harness") {
            throw new Error(`Agent harness handler received task with mode "${task.mode ?? "undefined"}" — expected "agent-harness"`);
        }
        const result = compileAgentHarnessTask(task, {
            graderProvider: ctx.graderProvider,
            rootDir: ctx.rootDir,
            rubricConfig: ctx.rubricConfig,
        });
        return {
            providers: result.providers,
            tests: result.tests,
            prompts: result.prompts,
            warnings: result.warnings,
            extras: {
                extensions: result.extensions,
                sandboxConfig: result.sandboxConfig,
            },
        };
    },
};
