// src/layer/adapters/passthrough.ts
//
// Fallback ToolResultAdapter. Always matches; returns the raw content
// unchanged with zero bytes saved and zero kb entries.
//
// MUST be registered LAST in AdapterRegistry — it is the safety net that
// guarantees AdapterRegistry.dispatch() never throws "no adapter matched"
// at runtime.
//
// See ./types.ts for the contract and the load-bearing invariants
// (Rule A: frozen bytes; Rule B: latest-turn only; determinism).

import type { ToolResult } from "../../provider/canonical.ts";
import type { ToolResultAdapter, CompressedResult } from "./types.ts";

export const passthroughAdapter: ToolResultAdapter = {
  id: "passthrough",
  match(_r: ToolResult): boolean {
    return true;
  },
  compress(r: ToolResult): CompressedResult {
    const raw: string =
      typeof r.content === "string" ? r.content : JSON.stringify(r.content);
    return {
      preview: raw,
      kbEntries: [],
      bytesSaved: 0,
    };
  },
};
