EDlabsEDcheck

See what is happening

Optional hooks to know when EDcheck calls the AI, what it answered, or if it failed.

EDcheck does not write to the console. If you want logs or traces, you attach them with hooks.

There are three: onRequest, onResponse, and onError. Each one runs once per provider request. If a parse does not need the AI (because Zod already rejected everything), none of them run.

Simple example

const edcheck = createEDcheck({  provider,  hooks: {    onRequest: (event) => {      console.log("asking", event.ruleIds);    },    onResponse: (event) => {      console.log("done", event.outcomes, event.durationMs);    },    onError: (event) => {      console.log("failed", event.kind);    },  },});

What each event carries

FieldMeaning
parseIdOne id per safeParse.
requestIdOne id per provider call.
requestIndex / requestCountThis is request 1 of N for that parse.
providerThe name (typesafe, gateway, mock).
entryobject or node, depending on how you validated.
ruleIdsWhich rules went in this request.
durationMsHow long it took (on the response or the error).
outcomespass / warning / fail per rule, before issues are built.
kindOn onError: provider, abort, or unexpected.

Two things to watch

  • If your hook throws, EDcheck swallows it and will not tell you. Test your hooks.
  • The event includes the full request, including state. If you export this to a logger, strip sensitive data first.

If a parse opens several requests, wait for requestCount terminal events (onResponse or onError) with the same parseId. Then you know that parse is done talking to the AI.