/**
 * TraceAdapter — the per-mode seam onto the mode-agnostic trace model (D0088).
 *
 * Each evaluation mode supplies a thin `TraceAdapter` that normalizes its
 * native per-step output into the collector's `RawTraceInput`. The collector
 * (`collectTrace`), `mergeTraces`, and `redactTrace` stay mode-agnostic;
 * adding a future mode means adding an adapter here, not touching the
 * collector or storage.
 *
 *   native result ──adapter.toRawTrace──▶ RawTraceInput ──collectTrace──▶ EvalTrace
 *
 * @see docs/decisions/D0088-unified-agentic-trace-model.md
 * @see docs/design-docs/unified-agentic-trace-model.md
 */
import { agentHarnessTraceAdapter } from "./adapters/agent-harness-trace-adapter.js";
import { literacyTraceAdapter } from "./adapters/literacy-trace-adapter.js";
import { mcpTraceAdapter } from "./adapters/mcp-trace-adapter.js";
import { collectTrace } from "./trace-collector.js";
/**
 * Run a native result through its adapter and the mode-agnostic collector to
 * produce an `EvalTrace`. Redaction is applied separately, before any write
 * (`redactTrace`), per D0088.
 */
export function buildEvalTrace(adapter, native, ctx) {
    return collectTrace(adapter.toRawTrace(native, ctx), {
        runId: ctx.runId,
        mode: adapter.mode,
        taskId: ctx.taskId,
        testCaseIndex: ctx.testCaseIndex,
        modelId: ctx.modelId,
    });
}
// ---------------------------------------------------------------------------
// Adapter registry
// ---------------------------------------------------------------------------
/**
 * Runtime mode string → adapter.
 *
 * The key is the mode string the pipeline actually runs an eval step under —
 * which is NOT uniform across modes. MCP runs under its canonical `EvalMode`
 * (`mcp-server`), but literacy runs under a *variant* string, and only the
 * `agentic` variant uses the rich tool-loop provider (`agentic-provider.ts`)
 * that captures a transcript + HTTP log. `baseline` / `observed` produce no
 * transcript, so they stay unregistered. The literacy adapter therefore keys
 * on `agentic` while tagging its trace with the canonical `literacy` mode.
 *
 * Agent-harness (slice 3) keys on its canonical `agent-harness` mode — the
 * `claude-agent-sdk` provider returns `response.metadata.toolCalls` directly,
 * so no variant indirection is needed. Modes absent here emit no traces —
 * `traceAdapterForMode` returns `undefined`.
 */
const TRACE_ADAPTERS = {
    "mcp-server": mcpTraceAdapter,
    agentic: literacyTraceAdapter,
    "agent-harness": agentHarnessTraceAdapter,
};
/**
 * Resolve the trace adapter for the runtime mode string. Returns `undefined`
 * for any mode without a registered adapter — including the canonical
 * `literacy` (which never runs as a step), the non-`agentic` literacy
 * variants, and the per-variant `gold` / `baseline` artifact-axis values.
 */
export function traceAdapterForMode(mode) {
    return TRACE_ADAPTERS[mode];
}
