import { createHash } from "node:crypto";
function hashPrompt(prompt) {
  const normalized = prompt.replace(/\s+/g, " ").trim();
  return createHash("sha256").update(normalized).digest("hex");
}
function hashSchema(schema) {
  return createHash("sha256").update(stableStringify(schema)).digest("hex");
}
function stableStringify(value) {
  if (value === null || typeof value !== "object") {
    return JSON.stringify(value);
  }
  if (Array.isArray(value)) {
    return "[" + value.map(stableStringify).join(",") + "]";
  }
  const keys = Object.keys(value).sort();
  const parts = keys.map(
    (k) => JSON.stringify(k) + ":" + stableStringify(value[k])
  );
  return "{" + parts.join(",") + "}";
}
export {
  hashPrompt,
  hashSchema
};
//# sourceMappingURL=hash.js.map