import { createHash } from "node:crypto";
import type { FlockQuoteInput } from "@/workers/rpa/flock/types";

/** Flock 输入稳定哈希（含 provider 前缀，避免与 MotherShip 串缓存） */
export function hashFlockInput(input: FlockQuoteInput): string {
  const payload = { provider: "flock", ...input };
  const stable = JSON.stringify(payload, Object.keys(payload).sort());
  return `flock_${createHash("sha256").update(stable).digest("hex").slice(0, 26)}`;
}
