import {
  __export
} from "./chunk-NSBPE2FW.js";

// src/benchmarks/index.ts
var benchmarks_exports = {};
__export(benchmarks_exports, {
  BENCHMARK_SPLIT_SEED: () => BENCHMARK_SPLIT_SEED,
  deterministicSplit: () => deterministicSplit,
  routing: () => routing_exports
});

// src/benchmarks/routing/index.ts
var routing_exports = {};
__export(routing_exports, {
  ROUTING_DATASET: () => ROUTING_DATASET,
  RoutingAdapter: () => RoutingAdapter,
  assignSplit: () => assignSplit,
  evaluate: () => evaluate,
  extractRouteTokens: () => extractRouteTokens,
  loadDataset: () => loadDataset
});

// src/benchmarks/types.ts
function fnv1a32(input) {
  let h = 2166136261;
  for (let i = 0; i < input.length; i++) {
    h ^= input.charCodeAt(i) & 255;
    h = h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24)) >>> 0;
  }
  return h >>> 0;
}
var BENCHMARK_SPLIT_SEED = "agent-eval-v1";
function deterministicSplit(itemId, seed = BENCHMARK_SPLIT_SEED) {
  const h = fnv1a32(`${seed}::${itemId}`);
  const pos = h / 4294967296;
  if (pos < 0.6) return "search";
  if (pos < 0.8) return "dev";
  return "holdout";
}

// src/benchmarks/routing/dataset.ts
var ROUTING_DATASET = [
  {
    id: "file_001",
    category: "file",
    prompt: "Save the meeting notes to /tmp/notes-2025-04.md as markdown.",
    route: "fs.write",
    synonyms: ["filesystem.write", "write_file"],
    hardNegatives: ["fs.read", "chat.reply"]
  },
  {
    id: "file_002",
    category: "file",
    prompt: "Read the contents of /etc/hosts and summarize the entries.",
    route: "fs.read",
    synonyms: ["filesystem.read", "read_file"],
    hardNegatives: ["fs.write", "search.web"]
  },
  {
    id: "file_003",
    category: "file",
    prompt: "List every Python file under src/ recursively.",
    route: "fs.list",
    synonyms: ["filesystem.list", "list_files"],
    hardNegatives: ["fs.read", "search.code"]
  },
  {
    id: "file_004",
    category: "file",
    prompt: "Delete the cached build at .turbo/cache.",
    route: "fs.delete",
    synonyms: ["filesystem.delete", "remove_file"],
    hardNegatives: ["fs.write", "fs.list"]
  },
  {
    id: "math_001",
    category: "math",
    prompt: "What is the integral of 3x^2 + 2x from 0 to 5?",
    route: "math.integral",
    synonyms: ["calculator.integral", "math.solve"],
    hardNegatives: ["math.derivative", "chat.reply"]
  },
  {
    id: "math_002",
    category: "math",
    prompt: "Compute the derivative of sin(x) * cos(x).",
    route: "math.derivative",
    synonyms: ["calculator.derivative", "math.solve"],
    hardNegatives: ["math.integral", "math.algebra"]
  },
  {
    id: "math_003",
    category: "math",
    prompt: "Solve 2x + 7 = 19 for x.",
    route: "math.algebra",
    synonyms: ["calculator.algebra", "math.solve"],
    hardNegatives: ["math.derivative", "math.integral"]
  },
  {
    id: "math_004",
    category: "math",
    prompt: "What is the prime factorization of 360?",
    route: "math.numbertheory",
    synonyms: ["calculator.factor", "math.solve"],
    hardNegatives: ["math.algebra", "search.web"]
  },
  {
    id: "search_001",
    category: "search",
    prompt: "Find recent papers on agent prompt optimization with held-out promotion gates.",
    route: "search.web",
    synonyms: ["web.search", "search.papers"],
    hardNegatives: ["search.code", "chat.reply"]
  },
  {
    id: "search_002",
    category: "search",
    prompt: "Search the codebase for every call site of `runProposeReview`.",
    route: "search.code",
    synonyms: ["code.search", "grep"],
    hardNegatives: ["search.web", "fs.read"]
  },
  {
    id: "search_003",
    category: "search",
    prompt: "What is the latest release of the Tangle network on GitHub?",
    route: "search.web",
    synonyms: ["web.search", "github.releases"],
    hardNegatives: ["search.code", "chat.reply"]
  },
  {
    id: "search_004",
    category: "search",
    prompt: "Find all TODO comments in the agent-eval src tree.",
    route: "search.code",
    synonyms: ["code.search", "grep"],
    hardNegatives: ["search.web", "fs.list"]
  },
  {
    id: "chat_001",
    category: "chat",
    prompt: "Hi there, how are you doing today?",
    route: "chat.reply",
    synonyms: ["conversation.reply"],
    hardNegatives: ["search.web", "fs.read"]
  },
  {
    id: "chat_002",
    category: "chat",
    prompt: "Please explain the difference between an LLM and a foundation model.",
    route: "chat.reply",
    synonyms: ["conversation.reply", "qa.answer"],
    hardNegatives: ["search.web", "math.algebra"]
  },
  {
    id: "chat_003",
    category: "chat",
    prompt: "Tell me a short joke about distributed systems.",
    route: "chat.reply",
    synonyms: ["conversation.reply"],
    hardNegatives: ["search.web", "fs.read"]
  },
  {
    id: "chat_004",
    category: "chat",
    prompt: "Acknowledge my last message with a thumbs up.",
    route: "chat.reply",
    synonyms: ["conversation.reply", "react"],
    hardNegatives: ["fs.write", "search.web"]
  }
];

// src/benchmarks/routing/index.ts
var RoutingAdapter = class {
  async loadDataset(split) {
    return ROUTING_DATASET.map((item) => ({ id: item.id, payload: item })).filter(
      (it) => assignSplitImpl(it.id) === split
    );
  }
  async evaluate(item, response) {
    const tokens = extractRouteTokens(response);
    const correct = new Set(
      [item.payload.route, ...item.payload.synonyms].map((s) => s.toLowerCase())
    );
    const hardNeg = new Set(item.payload.hardNegatives.map((s) => s.toLowerCase()));
    const firstMatch = tokens.find((t) => correct.has(t.toLowerCase())) ?? null;
    const firstHardNeg = tokens.find((t) => hardNeg.has(t.toLowerCase())) ?? null;
    const score = firstMatch ? 1 : 0;
    return {
      score,
      raw: {
        firstToken: tokens[0] ?? null,
        matchedRoute: firstMatch,
        hitHardNegative: Boolean(firstHardNeg),
        hardNegativeRoute: firstHardNeg,
        category: item.payload.category
      }
    };
  }
  assignSplit(itemId) {
    return assignSplitImpl(itemId);
  }
};
function assignSplitImpl(itemId) {
  return deterministicSplit(`routing::${itemId}`);
}
function extractRouteTokens(response) {
  const matches = response.match(/[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*/gi);
  return matches ?? [];
}
var adapter = new RoutingAdapter();
var loadDataset = adapter.loadDataset.bind(adapter);
var evaluate = adapter.evaluate.bind(adapter);
var assignSplit = adapter.assignSplit.bind(adapter);

export {
  BENCHMARK_SPLIT_SEED,
  deterministicSplit,
  routing_exports,
  benchmarks_exports
};
//# sourceMappingURL=chunk-MHQPVHXU.js.map