mock.ts 521 B

123456789101112131415
  1. type Hit = { body: Record<string, unknown> }
  2. export function bodyText(hit: Hit) {
  3. return JSON.stringify(hit.body)
  4. }
  5. /**
  6. * Match requests whose body contains the exact serialized tool input.
  7. * The seed prompts embed JSON.stringify(input) in the prompt text, which
  8. * gets escaped again inside the JSON body — so we double-escape to match.
  9. */
  10. export function inputMatch(input: unknown) {
  11. const escaped = JSON.stringify(JSON.stringify(input)).slice(1, -1)
  12. return (hit: Hit) => bodyText(hit).includes(escaped)
  13. }