@intellectif/lk-core 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +3 -2
  3. package/dist/{activity-BmjBjXVJ.d.cts → activity-f0bgZSTP.d.cts} +175 -134
  4. package/dist/{activity-BmjBjXVJ.d.ts → activity-f0bgZSTP.d.ts} +175 -134
  5. package/dist/ai-check.cjs +283 -0
  6. package/dist/ai-check.cjs.map +1 -0
  7. package/dist/ai-check.d.cts +106 -0
  8. package/dist/ai-check.d.ts +106 -0
  9. package/dist/ai-check.js +283 -0
  10. package/dist/ai-check.js.map +1 -0
  11. package/dist/chunk-BIJCO2HM.js +443 -0
  12. package/dist/chunk-BIJCO2HM.js.map +1 -0
  13. package/dist/{chunk-XNMKDFPW.cjs → chunk-COBK2RUX.cjs} +44 -9
  14. package/dist/chunk-COBK2RUX.cjs.map +1 -0
  15. package/dist/chunk-FVZJ4X3Y.cjs +443 -0
  16. package/dist/chunk-FVZJ4X3Y.cjs.map +1 -0
  17. package/dist/{chunk-WXS5EB65.js → chunk-MMEQKFFQ.js} +43 -8
  18. package/dist/chunk-MMEQKFFQ.js.map +1 -0
  19. package/dist/{index-G_KusUcK.d.ts → index-DMCM3e3P.d.ts} +1 -1
  20. package/dist/{index-CvfeD_cU.d.cts → index-bpuDhvXV.d.cts} +1 -1
  21. package/dist/index.cjs +37 -422
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +30 -11
  24. package/dist/index.d.ts +30 -11
  25. package/dist/index.js +37 -422
  26. package/dist/index.js.map +1 -1
  27. package/dist/schemas.d.cts +2 -2
  28. package/dist/schemas.d.ts +2 -2
  29. package/dist/scoring.cjs +2 -2
  30. package/dist/scoring.d.cts +33 -5
  31. package/dist/scoring.d.ts +33 -5
  32. package/dist/scoring.js +1 -1
  33. package/dist/xapi.d.cts +1 -1
  34. package/dist/xapi.d.ts +1 -1
  35. package/package.json +11 -1
  36. package/vectors/README.md +9 -3
  37. package/vectors/scoring.json +1258 -10
  38. package/dist/chunk-WXS5EB65.js.map +0 -1
  39. package/dist/chunk-XNMKDFPW.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","../src/ai-check/cases.ts","../src/ai-check/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACYA,IAAM,QAAA,EAA8B;AAAA,EAClC,aAAA,EAAe,KAAA;AAAA,EACf,IAAA,EAAM,iBAAA;AAAA,EACN,EAAA,EAAI,aAAA;AAAA,EACJ,KAAA,EAAO,gBAAA;AAAA,EACP,QAAA,EAAU,+BAAA;AAAA,EACV,IAAA,EAAM,QAAA;AAAA,EACN,eAAA,EAAiB,gBAAA;AAAA,EACjB,OAAA,EAAS;AAAA,IACP,EAAE,EAAA,EAAI,QAAA,EAAU,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,KAAK,CAAA;AAAA,IAChD,EAAE,EAAA,EAAI,WAAA,EAAa,IAAA,EAAM,WAAA,EAAa,SAAA,EAAW,MAAM,CAAA;AAAA,IACvD,EAAE,EAAA,EAAI,SAAA,EAAW,IAAA,EAAM,SAAA,EAAW,SAAA,EAAW,MAAM;AAAA,EACrD;AACF,CAAA;AAEA,IAAM,aAAA,EAAoC;AAAA,EACxC,aAAA,EAAe,KAAA;AAAA,EACf,IAAA,EAAM,oBAAA;AAAA,EACN,EAAA,EAAI,cAAA;AAAA,EACJ,KAAA,EAAO,sBAAA;AAAA,EACP,OAAA,EAAS,gDAAA;AAAA,EACT,MAAA,EAAQ;AAAA,IACN,EAAE,EAAA,EAAI,IAAA,EAAM,eAAA,EAAiB,CAAC,IAAI,EAAE,CAAA;AAAA,IACpC,EAAE,EAAA,EAAI,MAAA,EAAQ,eAAA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AA,EAAkB,CAAC,CAAA;AACzB,EAAA,MAAM,QAAA,EAAU,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,KAAA,EAAO,GAAA,EAAA,GAAQ,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,GAAA,CAAI,EAAE,CAAA,EAAG,CAAC,CAAA;AAChF,EAAA,KAAA,CAAM,IAAA;AAAA,IACJ,CAAA,UAAA,EAAa,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,MAAA,CAAO,KAAK,CAAA,QAAA,EAAW,MAAA,CAAO,OAAO,CAAA,UAAA,EAAa,MAAA,CAAO,MAAM,CAAA,OAAA,EACvF,MAAA,CAAO,QAAA,EAAU,EAAA,EAAI,CAAA,EAAA,EAAK,MAAA,CAAO,OAAO,CAAA,kBAAA,EAAA,EAAuB,EAAE,CAAA,gBAAA,EAAc,OAAO,CAAA,GAAA;AAAA,EAC7F,CAAA;AACA,EAAA,IAAA,CAAA,MAAW,OAAA,GAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,MAAA,EAAQ,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA;AACrC,IAAA,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAG;AACb,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA,EAAK,MAAM,CAAA,EAAA,EAAK,KAAK,CAAA,CAAA;AAClC,IAAA;AACF,EAAA;AACqC,EAAA;AACpB,IAAA;AACb,MAAA;AACF,IAAA;AAC8B,IAAA;AACA,IAAA;AACG,IAAA;AACJ,MAAA;AAC7B,IAAA;AACF,EAAA;AACsB,EAAA;AACxB;AFsCuC;AACA;AACA;AACA;AACA","file":"/home/runner/work/learning-kit/learning-kit/packages/lk-core/dist/ai-check.cjs","sourcesContent":[null,"import { aiExplanationRequest, aiHintRequest } from '../ai.js';\nimport type {\n DictationData,\n FillInTheBlanksData,\n GapSelectData,\n LearnerResponse,\n MultipleChoiceData,\n} from '../types/activity.js';\nimport type { AiExplanationRequest, AiHintRequest } from '../types/ai.js';\n\n/**\n * The items the cases are built from. Small, ordinary language-course content\n * — and deliberately awkward in the places a model slips:\n *\n * - an answer a hint can hardly avoid naming (`Madrid`);\n * - an answer of one short word (`is`), which a hint may write as an ordinary\n * word and must not write beside its neighbour in the passage;\n * - an accented answer (`cañón`), so a hint that spells it without the accent\n * is still caught;\n * - a passage with more than one blank, so a hint can be about the wrong one.\n */\nconst capital: MultipleChoiceData = {\n schemaVersion: '1.0',\n type: 'multiple-choice',\n id: 'ai-check-mc',\n title: 'Capital cities',\n question: 'What is the capital of Spain?',\n mode: 'single',\n scoringStrategy: 'all-or-nothing',\n options: [\n { id: 'madrid', text: 'Madrid', isCorrect: true },\n { id: 'barcelona', text: 'Barcelona', isCorrect: false },\n { id: 'seville', text: 'Seville', isCorrect: false },\n ],\n};\n\nconst introduction: FillInTheBlanksData = {\n schemaVersion: '1.0',\n type: 'fill-in-the-blanks',\n id: 'ai-check-fib',\n title: 'Introducing yourself',\n passage: 'My name {{be}} Rossi and I {{live}} in Madrid.',\n blanks: [\n { id: 'be', acceptedAnswers: ['is'] },\n { id: 'live', acceptedAnswers: ['live'], hint: 'Present simple, first person.' },\n ],\n scoringStrategy: 'partial',\n};\n\nconst landscape: GapSelectData = {\n schemaVersion: '1.0',\n type: 'gap-select',\n id: 'ai-check-gap',\n title: 'Geography',\n locale: 'es-ES',\n passage: 'El río pasa por un {{g1}} muy profundo, y el agua {{g2}} fría.',\n gaps: [\n {\n id: 'g1',\n choices: [\n { id: 'canon', text: 'cañón' },\n { id: 'campo', text: 'campo' },\n ],\n correctChoiceId: 'canon',\n },\n {\n id: 'g2',\n choices: [\n { id: 'esta', text: 'está' },\n { id: 'es', text: 'es' },\n ],\n correctChoiceId: 'esta',\n },\n ],\n scoringStrategy: 'partial',\n};\n\nconst listening: DictationData = {\n schemaVersion: '1.0',\n type: 'dictation',\n id: 'ai-check-dictation',\n title: 'Listen and type',\n transcript: 'The train leaves at half past nine.',\n};\n\n/**\n * One call to make against a host's port, and what a learner was looking at\n * when the SDK would have made it.\n */\nexport interface AiCheckCase {\n /** Stable across releases, so a host can name one in an allow-list or a report. */\n id: string;\n /** Which port the case is for. */\n feature: 'explanation' | 'hint';\n /** What the learner did, in a few words, for a report a person reads. */\n about: string;\n /** The request, built by the SDK exactly as a component builds it. */\n request: AiExplanationRequest | AiHintRequest;\n}\n\nconst chose = (ids: string[]): LearnerResponse => ({\n type: 'multiple-choice',\n selectedOptionIds: ids,\n});\nconst typed = (answers: Record<string, string>): LearnerResponse => ({\n type: 'fill-in-the-blanks',\n answers,\n});\nconst picked = (choices: Record<string, string>): LearnerResponse => ({\n type: 'gap-select',\n selections: choices,\n});\nconst wrote = (text: string): LearnerResponse => ({ type: 'dictation', text });\n\n/** Builds a case, failing loudly rather than shipping a case with no request. */\nfunction explanationCase(\n id: string,\n about: string,\n data: Parameters<typeof aiExplanationRequest>[0]['data'],\n response: LearnerResponse,\n): AiCheckCase {\n const request = aiExplanationRequest({ data, response });\n if (request === null) {\n throw new Error(`ai-check: no explanation request for \"${id}\"`);\n }\n return { id, feature: 'explanation', about, request };\n}\n\nfunction hintCase(\n id: string,\n about: string,\n data: Parameters<typeof aiHintRequest>[0]['data'],\n response: LearnerResponse,\n previousHints: string[] = [],\n): AiCheckCase {\n const request = aiHintRequest({ data, response, previousHints });\n if (request === null) {\n throw new Error(`ai-check: no hint request for \"${id}\"`);\n }\n return { id, feature: 'hint', about, request };\n}\n\n/**\n * The cases {@link runAiCheck} runs: every type the SDK explains, answered\n * right, wrong and — where a type can be — partly right; and every type it\n * hints for, before an answer and after a wrong one.\n *\n * They are ordinary calls. What makes them a test is that the SDK knows the\n * answer to each, so it can check what your model writes about it.\n *\n * A fresh array each call, so a caller may filter, slice or add to it without\n * changing what the next caller gets.\n */\nexport function aiCheckCases(): AiCheckCase[] {\n return [\n explanationCase('mc-correct', 'Chose the right city', capital, chose(['madrid'])),\n explanationCase('mc-wrong', 'Chose Barcelona', capital, chose(['barcelona'])),\n explanationCase('mc-blank', 'Chose nothing and submitted', capital, chose([])),\n explanationCase(\n 'fib-correct',\n 'Filled both blanks correctly',\n introduction,\n typed({ be: 'is', live: 'live' }),\n ),\n explanationCase(\n 'fib-partly',\n 'One blank right, one wrong',\n introduction,\n typed({ be: 'is', live: 'lives' }),\n ),\n explanationCase(\n 'fib-wrong',\n 'Both blanks wrong',\n introduction,\n typed({ be: 'are', live: 'living' }),\n ),\n explanationCase(\n 'gap-partly',\n 'One gap right, one wrong, in Spanish',\n landscape,\n picked({ g1: 'canon', g2: 'es' }),\n ),\n explanationCase(\n 'gap-wrong',\n 'Both gaps wrong, in Spanish',\n landscape,\n picked({ g1: 'campo', g2: 'es' }),\n ),\n explanationCase(\n 'dictation-near',\n 'Typed the sentence with two words wrong',\n listening,\n wrote('The train leaves at half past five'),\n ),\n explanationCase(\n 'dictation-correct',\n 'Typed the sentence correctly',\n listening,\n wrote('The train leaves at half past nine.'),\n ),\n hintCase('mc-hint-1', 'Has not answered yet', capital, chose([])),\n hintCase('mc-hint-2', 'Asked again after choosing Seville', capital, chose(['seville']), [\n 'Think about where the government sits.',\n ]),\n hintCase('fib-hint-1', 'Both blanks empty', introduction, typed({})),\n hintCase(\n 'fib-hint-2',\n 'Asked again with one blank wrong',\n introduction,\n typed({ be: 'are', live: '' }),\n ['Look again at the first blank.'],\n ),\n hintCase('gap-hint-1', 'Neither gap chosen, in Spanish', landscape, picked({})),\n hintCase(\n 'gap-hint-2',\n 'Asked again with the first gap wrong',\n landscape,\n picked({ g1: 'campo' }),\n ['Piensa en la forma del terreno.'],\n ),\n ];\n}\n","/**\n * A test kit for the prompts behind your AI ports.\n *\n * The SDK cannot test your model, and will not try. What it can do is make the\n * calls a learner's questions would make — on items whose answers it knows —\n * and run the same checks it runs before a learner sees anything. What comes\n * back is a count of what would have been shown and what would have been\n * refused, and why.\n *\n * Run it where you change a prompt or a model, in your own CI, with your own\n * key. It is a separate entry point (`@intellectif/lk-core/ai-check`) because\n * it is for your test run, not for a learner's browser: nothing here is\n * imported by anything a page renders.\n *\n * ```ts\n * import { aiCheckCases, formatAiCheckReport, runAiCheck } from '@intellectif/lk-core/ai-check';\n *\n * const report = await runAiCheck({\n * explain: (request) => callMyModel(EXPLAIN_PROMPT, request),\n * hint: (request) => callMyModel(HINT_PROMPT, request),\n * });\n * console.log(formatAiCheckReport(report));\n * if (report.refused > 0 || report.errors > 0) {\n * process.exitCode = 1;\n * }\n * ```\n *\n * A refusal is a real failure, not a warning: it is an answer a learner would\n * have asked for and not received. `reveals-answer` on a hint case is the one\n * to take most seriously — that prompt gives answers away.\n */\nimport { checkAiExplanation, checkAiHint } from '../ai.js';\nimport type { AiExplanationRequest, AiHintRequest, AiRefusal, AiTextResult } from '../types/ai.js';\nimport { type AiCheckCase, aiCheckCases } from './cases.js';\n\nexport { type AiCheckCase, aiCheckCases } from './cases.js';\n\n/**\n * Your ports, as this kit calls them. The same functions\n * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —\n * nothing here abandons a call.\n *\n * Leave one out and its cases are skipped rather than failed.\n */\nexport interface AiCheckPorts {\n explain?(request: AiExplanationRequest): Promise<unknown> | unknown;\n hint?(request: AiHintRequest): Promise<unknown> | unknown;\n}\n\n/** What happened on one case. */\nexport interface AiCheckResult {\n case: AiCheckCase;\n /** Whether a learner would have been shown what came back. */\n ok: boolean;\n /** Why it would not have been shown. */\n refusal?: AiRefusal;\n /** The port threw or rejected. Its message, as a string. */\n error?: string;\n /**\n * What came back, once the SDK had read it — so a refusal can be read beside\n * the text that caused it. Absent when the port failed or answered with\n * nothing the SDK could read.\n */\n result?: AiTextResult;\n /** How long the call took, in milliseconds. */\n ms: number;\n}\n\n/** What a run came to. */\nexport interface AiCheckReport {\n /** Cases run: the ones a port was supplied for. */\n total: number;\n /** Cases whose answer a learner would have been shown. */\n shown: number;\n /** Cases whose answer the SDK refused. */\n refused: number;\n /** Cases where the port itself failed. */\n errors: number;\n /** Cases skipped because no port was supplied for that feature. */\n skipped: number;\n /** How many refusals of each reason. */\n byRefusal: Record<AiRefusal, number>;\n results: AiCheckResult[];\n}\n\nexport interface AiCheckOptions {\n /**\n * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to\n * run one type, or your own cases — built with `aiExplanationRequest` and\n * `aiHintRequest` on your own items, which is how you test a prompt against\n * the content your learners actually see.\n */\n cases?: readonly AiCheckCase[];\n /**\n * How many cases to have in flight at once. Default 1: a run in CI hits a\n * rate limit far more often than it runs out of patience.\n */\n concurrency?: number;\n}\n\nconst REFUSALS: AiRefusal[] = [\n 'malformed',\n 'empty',\n 'too-long',\n 'contradicts-grade',\n 'reveals-answer',\n];\n\n/** Milliseconds, from whichever clock this runtime has. */\nconst now = (): number => Date.now();\n\n/** Runs one case: calls the port, times it, and checks what came back. */\nasync function runCase(ports: AiCheckPorts, one: AiCheckCase): Promise<AiCheckResult> {\n const started = now();\n const explaining = one.request.feature === 'explanation';\n const port = explaining ? ports.explain : ports.hint;\n if (port === undefined) {\n throw new Error(`ai-check: no port for \"${one.id}\"`);\n }\n let raw: unknown;\n try {\n raw = await port(one.request as never);\n } catch (error) {\n return {\n case: one,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n ms: now() - started,\n };\n }\n const ms = now() - started;\n const checked = explaining\n ? checkAiExplanation(raw, one.request as AiExplanationRequest)\n : checkAiHint(raw, one.request as AiHintRequest);\n if (checked.ok) {\n return { case: one, ok: true, result: checked.result, ms };\n }\n const text =\n typeof (raw as { text?: unknown })?.text === 'string' ? (raw as AiTextResult) : undefined;\n return {\n case: one,\n ok: false,\n refusal: checked.refusal,\n ...(text !== undefined ? { result: text } : {}),\n ms,\n };\n}\n\n/**\n * Calls your ports on every case and reports what a learner would have seen.\n *\n * It never throws for a failing case: a port that rejects is an `error` in the\n * report, so one bad call cannot hide the rest.\n */\nexport async function runAiCheck(\n ports: AiCheckPorts,\n options: AiCheckOptions = {},\n): Promise<AiCheckReport> {\n const all = options.cases ?? aiCheckCases();\n const asked = Math.trunc(options.concurrency ?? 1);\n const lanes = Number.isFinite(asked) && asked >= 1 ? Math.min(asked, 16) : 1;\n const runnable = all.filter((one) =>\n one.request.feature === 'explanation' ? ports.explain !== undefined : ports.hint !== undefined,\n );\n const results: AiCheckResult[] = new Array(runnable.length);\n let next = 0;\n const lane = async (): Promise<void> => {\n while (next < runnable.length) {\n const mine = next;\n next += 1;\n const one = runnable[mine];\n if (one === undefined) {\n return;\n }\n results[mine] = await runCase(ports, one);\n }\n };\n await Promise.all(Array.from({ length: Math.min(lanes, runnable.length) }, lane));\n\n const byRefusal = Object.fromEntries(REFUSALS.map((reason) => [reason, 0])) as Record<\n AiRefusal,\n number\n >;\n let shown = 0;\n let refused = 0;\n let errors = 0;\n for (const result of results) {\n if (result.ok) {\n shown += 1;\n } else if (result.refusal !== undefined) {\n refused += 1;\n byRefusal[result.refusal] += 1;\n } else {\n errors += 1;\n }\n }\n return {\n total: results.length,\n shown,\n refused,\n errors,\n skipped: all.length - runnable.length,\n byRefusal,\n results,\n };\n}\n\n/**\n * The report as a few lines for a CI log: the counts, then every case that\n * failed, with what came back.\n *\n * The refused text is printed — this is your own test run, not a learner's\n * screen, and a hint that gives the answer away is only fixable if you can\n * read it.\n */\nexport function formatAiCheckReport(report: AiCheckReport): string {\n const lines: string[] = [];\n const slowest = report.results.reduce((worst, one) => Math.max(worst, one.ms), 0);\n lines.push(\n `ai-check: ${report.shown}/${report.total} shown, ${report.refused} refused, ${report.errors} failed` +\n `${report.skipped > 0 ? `, ${report.skipped} skipped (no port)` : ''} — slowest ${slowest} ms`,\n );\n for (const reason of REFUSALS) {\n const count = report.byRefusal[reason];\n if (count > 0) {\n lines.push(` ${reason}: ${count}`);\n }\n }\n for (const result of report.results) {\n if (result.ok) {\n continue;\n }\n const why = result.refusal ?? `port failed (${result.error ?? 'no message'})`;\n lines.push(` ✗ ${result.case.id} [${result.case.feature}] ${result.case.about}: ${why}`);\n if (result.result !== undefined) {\n lines.push(` ${result.result.text.replace(/\\s+/g, ' ').slice(0, 200)}`);\n }\n }\n return lines.join('\\n');\n}\n"]}
@@ -0,0 +1,106 @@
1
+ import { j as AiExplanationRequest, p as AiHintRequest, u as AiRefusal, w as AiTextResult } from './activity-f0bgZSTP.cjs';
2
+
3
+ /**
4
+ * One call to make against a host's port, and what a learner was looking at
5
+ * when the SDK would have made it.
6
+ */
7
+ interface AiCheckCase {
8
+ /** Stable across releases, so a host can name one in an allow-list or a report. */
9
+ id: string;
10
+ /** Which port the case is for. */
11
+ feature: 'explanation' | 'hint';
12
+ /** What the learner did, in a few words, for a report a person reads. */
13
+ about: string;
14
+ /** The request, built by the SDK exactly as a component builds it. */
15
+ request: AiExplanationRequest | AiHintRequest;
16
+ }
17
+ /**
18
+ * The cases {@link runAiCheck} runs: every type the SDK explains, answered
19
+ * right, wrong and — where a type can be — partly right; and every type it
20
+ * hints for, before an answer and after a wrong one.
21
+ *
22
+ * They are ordinary calls. What makes them a test is that the SDK knows the
23
+ * answer to each, so it can check what your model writes about it.
24
+ *
25
+ * A fresh array each call, so a caller may filter, slice or add to it without
26
+ * changing what the next caller gets.
27
+ */
28
+ declare function aiCheckCases(): AiCheckCase[];
29
+
30
+ /**
31
+ * Your ports, as this kit calls them. The same functions
32
+ * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —
33
+ * nothing here abandons a call.
34
+ *
35
+ * Leave one out and its cases are skipped rather than failed.
36
+ */
37
+ interface AiCheckPorts {
38
+ explain?(request: AiExplanationRequest): Promise<unknown> | unknown;
39
+ hint?(request: AiHintRequest): Promise<unknown> | unknown;
40
+ }
41
+ /** What happened on one case. */
42
+ interface AiCheckResult {
43
+ case: AiCheckCase;
44
+ /** Whether a learner would have been shown what came back. */
45
+ ok: boolean;
46
+ /** Why it would not have been shown. */
47
+ refusal?: AiRefusal;
48
+ /** The port threw or rejected. Its message, as a string. */
49
+ error?: string;
50
+ /**
51
+ * What came back, once the SDK had read it — so a refusal can be read beside
52
+ * the text that caused it. Absent when the port failed or answered with
53
+ * nothing the SDK could read.
54
+ */
55
+ result?: AiTextResult;
56
+ /** How long the call took, in milliseconds. */
57
+ ms: number;
58
+ }
59
+ /** What a run came to. */
60
+ interface AiCheckReport {
61
+ /** Cases run: the ones a port was supplied for. */
62
+ total: number;
63
+ /** Cases whose answer a learner would have been shown. */
64
+ shown: number;
65
+ /** Cases whose answer the SDK refused. */
66
+ refused: number;
67
+ /** Cases where the port itself failed. */
68
+ errors: number;
69
+ /** Cases skipped because no port was supplied for that feature. */
70
+ skipped: number;
71
+ /** How many refusals of each reason. */
72
+ byRefusal: Record<AiRefusal, number>;
73
+ results: AiCheckResult[];
74
+ }
75
+ interface AiCheckOptions {
76
+ /**
77
+ * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to
78
+ * run one type, or your own cases — built with `aiExplanationRequest` and
79
+ * `aiHintRequest` on your own items, which is how you test a prompt against
80
+ * the content your learners actually see.
81
+ */
82
+ cases?: readonly AiCheckCase[];
83
+ /**
84
+ * How many cases to have in flight at once. Default 1: a run in CI hits a
85
+ * rate limit far more often than it runs out of patience.
86
+ */
87
+ concurrency?: number;
88
+ }
89
+ /**
90
+ * Calls your ports on every case and reports what a learner would have seen.
91
+ *
92
+ * It never throws for a failing case: a port that rejects is an `error` in the
93
+ * report, so one bad call cannot hide the rest.
94
+ */
95
+ declare function runAiCheck(ports: AiCheckPorts, options?: AiCheckOptions): Promise<AiCheckReport>;
96
+ /**
97
+ * The report as a few lines for a CI log: the counts, then every case that
98
+ * failed, with what came back.
99
+ *
100
+ * The refused text is printed — this is your own test run, not a learner's
101
+ * screen, and a hint that gives the answer away is only fixable if you can
102
+ * read it.
103
+ */
104
+ declare function formatAiCheckReport(report: AiCheckReport): string;
105
+
106
+ export { type AiCheckCase, type AiCheckOptions, type AiCheckPorts, type AiCheckReport, type AiCheckResult, aiCheckCases, formatAiCheckReport, runAiCheck };
@@ -0,0 +1,106 @@
1
+ import { j as AiExplanationRequest, p as AiHintRequest, u as AiRefusal, w as AiTextResult } from './activity-f0bgZSTP.js';
2
+
3
+ /**
4
+ * One call to make against a host's port, and what a learner was looking at
5
+ * when the SDK would have made it.
6
+ */
7
+ interface AiCheckCase {
8
+ /** Stable across releases, so a host can name one in an allow-list or a report. */
9
+ id: string;
10
+ /** Which port the case is for. */
11
+ feature: 'explanation' | 'hint';
12
+ /** What the learner did, in a few words, for a report a person reads. */
13
+ about: string;
14
+ /** The request, built by the SDK exactly as a component builds it. */
15
+ request: AiExplanationRequest | AiHintRequest;
16
+ }
17
+ /**
18
+ * The cases {@link runAiCheck} runs: every type the SDK explains, answered
19
+ * right, wrong and — where a type can be — partly right; and every type it
20
+ * hints for, before an answer and after a wrong one.
21
+ *
22
+ * They are ordinary calls. What makes them a test is that the SDK knows the
23
+ * answer to each, so it can check what your model writes about it.
24
+ *
25
+ * A fresh array each call, so a caller may filter, slice or add to it without
26
+ * changing what the next caller gets.
27
+ */
28
+ declare function aiCheckCases(): AiCheckCase[];
29
+
30
+ /**
31
+ * Your ports, as this kit calls them. The same functions
32
+ * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —
33
+ * nothing here abandons a call.
34
+ *
35
+ * Leave one out and its cases are skipped rather than failed.
36
+ */
37
+ interface AiCheckPorts {
38
+ explain?(request: AiExplanationRequest): Promise<unknown> | unknown;
39
+ hint?(request: AiHintRequest): Promise<unknown> | unknown;
40
+ }
41
+ /** What happened on one case. */
42
+ interface AiCheckResult {
43
+ case: AiCheckCase;
44
+ /** Whether a learner would have been shown what came back. */
45
+ ok: boolean;
46
+ /** Why it would not have been shown. */
47
+ refusal?: AiRefusal;
48
+ /** The port threw or rejected. Its message, as a string. */
49
+ error?: string;
50
+ /**
51
+ * What came back, once the SDK had read it — so a refusal can be read beside
52
+ * the text that caused it. Absent when the port failed or answered with
53
+ * nothing the SDK could read.
54
+ */
55
+ result?: AiTextResult;
56
+ /** How long the call took, in milliseconds. */
57
+ ms: number;
58
+ }
59
+ /** What a run came to. */
60
+ interface AiCheckReport {
61
+ /** Cases run: the ones a port was supplied for. */
62
+ total: number;
63
+ /** Cases whose answer a learner would have been shown. */
64
+ shown: number;
65
+ /** Cases whose answer the SDK refused. */
66
+ refused: number;
67
+ /** Cases where the port itself failed. */
68
+ errors: number;
69
+ /** Cases skipped because no port was supplied for that feature. */
70
+ skipped: number;
71
+ /** How many refusals of each reason. */
72
+ byRefusal: Record<AiRefusal, number>;
73
+ results: AiCheckResult[];
74
+ }
75
+ interface AiCheckOptions {
76
+ /**
77
+ * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to
78
+ * run one type, or your own cases — built with `aiExplanationRequest` and
79
+ * `aiHintRequest` on your own items, which is how you test a prompt against
80
+ * the content your learners actually see.
81
+ */
82
+ cases?: readonly AiCheckCase[];
83
+ /**
84
+ * How many cases to have in flight at once. Default 1: a run in CI hits a
85
+ * rate limit far more often than it runs out of patience.
86
+ */
87
+ concurrency?: number;
88
+ }
89
+ /**
90
+ * Calls your ports on every case and reports what a learner would have seen.
91
+ *
92
+ * It never throws for a failing case: a port that rejects is an `error` in the
93
+ * report, so one bad call cannot hide the rest.
94
+ */
95
+ declare function runAiCheck(ports: AiCheckPorts, options?: AiCheckOptions): Promise<AiCheckReport>;
96
+ /**
97
+ * The report as a few lines for a CI log: the counts, then every case that
98
+ * failed, with what came back.
99
+ *
100
+ * The refused text is printed — this is your own test run, not a learner's
101
+ * screen, and a hint that gives the answer away is only fixable if you can
102
+ * read it.
103
+ */
104
+ declare function formatAiCheckReport(report: AiCheckReport): string;
105
+
106
+ export { type AiCheckCase, type AiCheckOptions, type AiCheckPorts, type AiCheckReport, type AiCheckResult, aiCheckCases, formatAiCheckReport, runAiCheck };
@@ -0,0 +1,283 @@
1
+ import {
2
+ aiExplanationRequest,
3
+ aiHintRequest,
4
+ checkAiExplanation,
5
+ checkAiHint
6
+ } from "./chunk-BIJCO2HM.js";
7
+ import "./chunk-MMEQKFFQ.js";
8
+ import "./chunk-D3GP5MET.js";
9
+
10
+ // src/ai-check/cases.ts
11
+ var capital = {
12
+ schemaVersion: "1.0",
13
+ type: "multiple-choice",
14
+ id: "ai-check-mc",
15
+ title: "Capital cities",
16
+ question: "What is the capital of Spain?",
17
+ mode: "single",
18
+ scoringStrategy: "all-or-nothing",
19
+ options: [
20
+ { id: "madrid", text: "Madrid", isCorrect: true },
21
+ { id: "barcelona", text: "Barcelona", isCorrect: false },
22
+ { id: "seville", text: "Seville", isCorrect: false }
23
+ ]
24
+ };
25
+ var introduction = {
26
+ schemaVersion: "1.0",
27
+ type: "fill-in-the-blanks",
28
+ id: "ai-check-fib",
29
+ title: "Introducing yourself",
30
+ passage: "My name {{be}} Rossi and I {{live}} in Madrid.",
31
+ blanks: [
32
+ { id: "be", acceptedAnswers: ["is"] },
33
+ { id: "live", acceptedAnswers: ["live"], hint: "Present simple, first person." }
34
+ ],
35
+ scoringStrategy: "partial"
36
+ };
37
+ var landscape = {
38
+ schemaVersion: "1.0",
39
+ type: "gap-select",
40
+ id: "ai-check-gap",
41
+ title: "Geography",
42
+ locale: "es-ES",
43
+ passage: "El r\xEDo pasa por un {{g1}} muy profundo, y el agua {{g2}} fr\xEDa.",
44
+ gaps: [
45
+ {
46
+ id: "g1",
47
+ choices: [
48
+ { id: "canon", text: "ca\xF1\xF3n" },
49
+ { id: "campo", text: "campo" }
50
+ ],
51
+ correctChoiceId: "canon"
52
+ },
53
+ {
54
+ id: "g2",
55
+ choices: [
56
+ { id: "esta", text: "est\xE1" },
57
+ { id: "es", text: "es" }
58
+ ],
59
+ correctChoiceId: "esta"
60
+ }
61
+ ],
62
+ scoringStrategy: "partial"
63
+ };
64
+ var listening = {
65
+ schemaVersion: "1.0",
66
+ type: "dictation",
67
+ id: "ai-check-dictation",
68
+ title: "Listen and type",
69
+ transcript: "The train leaves at half past nine."
70
+ };
71
+ var chose = (ids) => ({
72
+ type: "multiple-choice",
73
+ selectedOptionIds: ids
74
+ });
75
+ var typed = (answers) => ({
76
+ type: "fill-in-the-blanks",
77
+ answers
78
+ });
79
+ var picked = (choices) => ({
80
+ type: "gap-select",
81
+ selections: choices
82
+ });
83
+ var wrote = (text) => ({ type: "dictation", text });
84
+ function explanationCase(id, about, data, response) {
85
+ const request = aiExplanationRequest({ data, response });
86
+ if (request === null) {
87
+ throw new Error(`ai-check: no explanation request for "${id}"`);
88
+ }
89
+ return { id, feature: "explanation", about, request };
90
+ }
91
+ function hintCase(id, about, data, response, previousHints = []) {
92
+ const request = aiHintRequest({ data, response, previousHints });
93
+ if (request === null) {
94
+ throw new Error(`ai-check: no hint request for "${id}"`);
95
+ }
96
+ return { id, feature: "hint", about, request };
97
+ }
98
+ function aiCheckCases() {
99
+ return [
100
+ explanationCase("mc-correct", "Chose the right city", capital, chose(["madrid"])),
101
+ explanationCase("mc-wrong", "Chose Barcelona", capital, chose(["barcelona"])),
102
+ explanationCase("mc-blank", "Chose nothing and submitted", capital, chose([])),
103
+ explanationCase(
104
+ "fib-correct",
105
+ "Filled both blanks correctly",
106
+ introduction,
107
+ typed({ be: "is", live: "live" })
108
+ ),
109
+ explanationCase(
110
+ "fib-partly",
111
+ "One blank right, one wrong",
112
+ introduction,
113
+ typed({ be: "is", live: "lives" })
114
+ ),
115
+ explanationCase(
116
+ "fib-wrong",
117
+ "Both blanks wrong",
118
+ introduction,
119
+ typed({ be: "are", live: "living" })
120
+ ),
121
+ explanationCase(
122
+ "gap-partly",
123
+ "One gap right, one wrong, in Spanish",
124
+ landscape,
125
+ picked({ g1: "canon", g2: "es" })
126
+ ),
127
+ explanationCase(
128
+ "gap-wrong",
129
+ "Both gaps wrong, in Spanish",
130
+ landscape,
131
+ picked({ g1: "campo", g2: "es" })
132
+ ),
133
+ explanationCase(
134
+ "dictation-near",
135
+ "Typed the sentence with two words wrong",
136
+ listening,
137
+ wrote("The train leaves at half past five")
138
+ ),
139
+ explanationCase(
140
+ "dictation-correct",
141
+ "Typed the sentence correctly",
142
+ listening,
143
+ wrote("The train leaves at half past nine.")
144
+ ),
145
+ hintCase("mc-hint-1", "Has not answered yet", capital, chose([])),
146
+ hintCase("mc-hint-2", "Asked again after choosing Seville", capital, chose(["seville"]), [
147
+ "Think about where the government sits."
148
+ ]),
149
+ hintCase("fib-hint-1", "Both blanks empty", introduction, typed({})),
150
+ hintCase(
151
+ "fib-hint-2",
152
+ "Asked again with one blank wrong",
153
+ introduction,
154
+ typed({ be: "are", live: "" }),
155
+ ["Look again at the first blank."]
156
+ ),
157
+ hintCase("gap-hint-1", "Neither gap chosen, in Spanish", landscape, picked({})),
158
+ hintCase(
159
+ "gap-hint-2",
160
+ "Asked again with the first gap wrong",
161
+ landscape,
162
+ picked({ g1: "campo" }),
163
+ ["Piensa en la forma del terreno."]
164
+ )
165
+ ];
166
+ }
167
+
168
+ // src/ai-check/index.ts
169
+ var REFUSALS = [
170
+ "malformed",
171
+ "empty",
172
+ "too-long",
173
+ "contradicts-grade",
174
+ "reveals-answer"
175
+ ];
176
+ var now = () => Date.now();
177
+ async function runCase(ports, one) {
178
+ const started = now();
179
+ const explaining = one.request.feature === "explanation";
180
+ const port = explaining ? ports.explain : ports.hint;
181
+ if (port === void 0) {
182
+ throw new Error(`ai-check: no port for "${one.id}"`);
183
+ }
184
+ let raw;
185
+ try {
186
+ raw = await port(one.request);
187
+ } catch (error) {
188
+ return {
189
+ case: one,
190
+ ok: false,
191
+ error: error instanceof Error ? error.message : String(error),
192
+ ms: now() - started
193
+ };
194
+ }
195
+ const ms = now() - started;
196
+ const checked = explaining ? checkAiExplanation(raw, one.request) : checkAiHint(raw, one.request);
197
+ if (checked.ok) {
198
+ return { case: one, ok: true, result: checked.result, ms };
199
+ }
200
+ const text = typeof raw?.text === "string" ? raw : void 0;
201
+ return {
202
+ case: one,
203
+ ok: false,
204
+ refusal: checked.refusal,
205
+ ...text !== void 0 ? { result: text } : {},
206
+ ms
207
+ };
208
+ }
209
+ async function runAiCheck(ports, options = {}) {
210
+ const all = options.cases ?? aiCheckCases();
211
+ const asked = Math.trunc(options.concurrency ?? 1);
212
+ const lanes = Number.isFinite(asked) && asked >= 1 ? Math.min(asked, 16) : 1;
213
+ const runnable = all.filter(
214
+ (one) => one.request.feature === "explanation" ? ports.explain !== void 0 : ports.hint !== void 0
215
+ );
216
+ const results = new Array(runnable.length);
217
+ let next = 0;
218
+ const lane = async () => {
219
+ while (next < runnable.length) {
220
+ const mine = next;
221
+ next += 1;
222
+ const one = runnable[mine];
223
+ if (one === void 0) {
224
+ return;
225
+ }
226
+ results[mine] = await runCase(ports, one);
227
+ }
228
+ };
229
+ await Promise.all(Array.from({ length: Math.min(lanes, runnable.length) }, lane));
230
+ const byRefusal = Object.fromEntries(REFUSALS.map((reason) => [reason, 0]));
231
+ let shown = 0;
232
+ let refused = 0;
233
+ let errors = 0;
234
+ for (const result of results) {
235
+ if (result.ok) {
236
+ shown += 1;
237
+ } else if (result.refusal !== void 0) {
238
+ refused += 1;
239
+ byRefusal[result.refusal] += 1;
240
+ } else {
241
+ errors += 1;
242
+ }
243
+ }
244
+ return {
245
+ total: results.length,
246
+ shown,
247
+ refused,
248
+ errors,
249
+ skipped: all.length - runnable.length,
250
+ byRefusal,
251
+ results
252
+ };
253
+ }
254
+ function formatAiCheckReport(report) {
255
+ const lines = [];
256
+ const slowest = report.results.reduce((worst, one) => Math.max(worst, one.ms), 0);
257
+ lines.push(
258
+ `ai-check: ${report.shown}/${report.total} shown, ${report.refused} refused, ${report.errors} failed${report.skipped > 0 ? `, ${report.skipped} skipped (no port)` : ""} \u2014 slowest ${slowest} ms`
259
+ );
260
+ for (const reason of REFUSALS) {
261
+ const count = report.byRefusal[reason];
262
+ if (count > 0) {
263
+ lines.push(` ${reason}: ${count}`);
264
+ }
265
+ }
266
+ for (const result of report.results) {
267
+ if (result.ok) {
268
+ continue;
269
+ }
270
+ const why = result.refusal ?? `port failed (${result.error ?? "no message"})`;
271
+ lines.push(` \u2717 ${result.case.id} [${result.case.feature}] ${result.case.about}: ${why}`);
272
+ if (result.result !== void 0) {
273
+ lines.push(` ${result.result.text.replace(/\s+/g, " ").slice(0, 200)}`);
274
+ }
275
+ }
276
+ return lines.join("\n");
277
+ }
278
+ export {
279
+ aiCheckCases,
280
+ formatAiCheckReport,
281
+ runAiCheck
282
+ };
283
+ //# sourceMappingURL=ai-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ai-check/cases.ts","../src/ai-check/index.ts"],"sourcesContent":["import { aiExplanationRequest, aiHintRequest } from '../ai.js';\nimport type {\n DictationData,\n FillInTheBlanksData,\n GapSelectData,\n LearnerResponse,\n MultipleChoiceData,\n} from '../types/activity.js';\nimport type { AiExplanationRequest, AiHintRequest } from '../types/ai.js';\n\n/**\n * The items the cases are built from. Small, ordinary language-course content\n * — and deliberately awkward in the places a model slips:\n *\n * - an answer a hint can hardly avoid naming (`Madrid`);\n * - an answer of one short word (`is`), which a hint may write as an ordinary\n * word and must not write beside its neighbour in the passage;\n * - an accented answer (`cañón`), so a hint that spells it without the accent\n * is still caught;\n * - a passage with more than one blank, so a hint can be about the wrong one.\n */\nconst capital: MultipleChoiceData = {\n schemaVersion: '1.0',\n type: 'multiple-choice',\n id: 'ai-check-mc',\n title: 'Capital cities',\n question: 'What is the capital of Spain?',\n mode: 'single',\n scoringStrategy: 'all-or-nothing',\n options: [\n { id: 'madrid', text: 'Madrid', isCorrect: true },\n { id: 'barcelona', text: 'Barcelona', isCorrect: false },\n { id: 'seville', text: 'Seville', isCorrect: false },\n ],\n};\n\nconst introduction: FillInTheBlanksData = {\n schemaVersion: '1.0',\n type: 'fill-in-the-blanks',\n id: 'ai-check-fib',\n title: 'Introducing yourself',\n passage: 'My name {{be}} Rossi and I {{live}} in Madrid.',\n blanks: [\n { id: 'be', acceptedAnswers: ['is'] },\n { id: 'live', acceptedAnswers: ['live'], hint: 'Present simple, first person.' },\n ],\n scoringStrategy: 'partial',\n};\n\nconst landscape: GapSelectData = {\n schemaVersion: '1.0',\n type: 'gap-select',\n id: 'ai-check-gap',\n title: 'Geography',\n locale: 'es-ES',\n passage: 'El río pasa por un {{g1}} muy profundo, y el agua {{g2}} fría.',\n gaps: [\n {\n id: 'g1',\n choices: [\n { id: 'canon', text: 'cañón' },\n { id: 'campo', text: 'campo' },\n ],\n correctChoiceId: 'canon',\n },\n {\n id: 'g2',\n choices: [\n { id: 'esta', text: 'está' },\n { id: 'es', text: 'es' },\n ],\n correctChoiceId: 'esta',\n },\n ],\n scoringStrategy: 'partial',\n};\n\nconst listening: DictationData = {\n schemaVersion: '1.0',\n type: 'dictation',\n id: 'ai-check-dictation',\n title: 'Listen and type',\n transcript: 'The train leaves at half past nine.',\n};\n\n/**\n * One call to make against a host's port, and what a learner was looking at\n * when the SDK would have made it.\n */\nexport interface AiCheckCase {\n /** Stable across releases, so a host can name one in an allow-list or a report. */\n id: string;\n /** Which port the case is for. */\n feature: 'explanation' | 'hint';\n /** What the learner did, in a few words, for a report a person reads. */\n about: string;\n /** The request, built by the SDK exactly as a component builds it. */\n request: AiExplanationRequest | AiHintRequest;\n}\n\nconst chose = (ids: string[]): LearnerResponse => ({\n type: 'multiple-choice',\n selectedOptionIds: ids,\n});\nconst typed = (answers: Record<string, string>): LearnerResponse => ({\n type: 'fill-in-the-blanks',\n answers,\n});\nconst picked = (choices: Record<string, string>): LearnerResponse => ({\n type: 'gap-select',\n selections: choices,\n});\nconst wrote = (text: string): LearnerResponse => ({ type: 'dictation', text });\n\n/** Builds a case, failing loudly rather than shipping a case with no request. */\nfunction explanationCase(\n id: string,\n about: string,\n data: Parameters<typeof aiExplanationRequest>[0]['data'],\n response: LearnerResponse,\n): AiCheckCase {\n const request = aiExplanationRequest({ data, response });\n if (request === null) {\n throw new Error(`ai-check: no explanation request for \"${id}\"`);\n }\n return { id, feature: 'explanation', about, request };\n}\n\nfunction hintCase(\n id: string,\n about: string,\n data: Parameters<typeof aiHintRequest>[0]['data'],\n response: LearnerResponse,\n previousHints: string[] = [],\n): AiCheckCase {\n const request = aiHintRequest({ data, response, previousHints });\n if (request === null) {\n throw new Error(`ai-check: no hint request for \"${id}\"`);\n }\n return { id, feature: 'hint', about, request };\n}\n\n/**\n * The cases {@link runAiCheck} runs: every type the SDK explains, answered\n * right, wrong and — where a type can be — partly right; and every type it\n * hints for, before an answer and after a wrong one.\n *\n * They are ordinary calls. What makes them a test is that the SDK knows the\n * answer to each, so it can check what your model writes about it.\n *\n * A fresh array each call, so a caller may filter, slice or add to it without\n * changing what the next caller gets.\n */\nexport function aiCheckCases(): AiCheckCase[] {\n return [\n explanationCase('mc-correct', 'Chose the right city', capital, chose(['madrid'])),\n explanationCase('mc-wrong', 'Chose Barcelona', capital, chose(['barcelona'])),\n explanationCase('mc-blank', 'Chose nothing and submitted', capital, chose([])),\n explanationCase(\n 'fib-correct',\n 'Filled both blanks correctly',\n introduction,\n typed({ be: 'is', live: 'live' }),\n ),\n explanationCase(\n 'fib-partly',\n 'One blank right, one wrong',\n introduction,\n typed({ be: 'is', live: 'lives' }),\n ),\n explanationCase(\n 'fib-wrong',\n 'Both blanks wrong',\n introduction,\n typed({ be: 'are', live: 'living' }),\n ),\n explanationCase(\n 'gap-partly',\n 'One gap right, one wrong, in Spanish',\n landscape,\n picked({ g1: 'canon', g2: 'es' }),\n ),\n explanationCase(\n 'gap-wrong',\n 'Both gaps wrong, in Spanish',\n landscape,\n picked({ g1: 'campo', g2: 'es' }),\n ),\n explanationCase(\n 'dictation-near',\n 'Typed the sentence with two words wrong',\n listening,\n wrote('The train leaves at half past five'),\n ),\n explanationCase(\n 'dictation-correct',\n 'Typed the sentence correctly',\n listening,\n wrote('The train leaves at half past nine.'),\n ),\n hintCase('mc-hint-1', 'Has not answered yet', capital, chose([])),\n hintCase('mc-hint-2', 'Asked again after choosing Seville', capital, chose(['seville']), [\n 'Think about where the government sits.',\n ]),\n hintCase('fib-hint-1', 'Both blanks empty', introduction, typed({})),\n hintCase(\n 'fib-hint-2',\n 'Asked again with one blank wrong',\n introduction,\n typed({ be: 'are', live: '' }),\n ['Look again at the first blank.'],\n ),\n hintCase('gap-hint-1', 'Neither gap chosen, in Spanish', landscape, picked({})),\n hintCase(\n 'gap-hint-2',\n 'Asked again with the first gap wrong',\n landscape,\n picked({ g1: 'campo' }),\n ['Piensa en la forma del terreno.'],\n ),\n ];\n}\n","/**\n * A test kit for the prompts behind your AI ports.\n *\n * The SDK cannot test your model, and will not try. What it can do is make the\n * calls a learner's questions would make — on items whose answers it knows —\n * and run the same checks it runs before a learner sees anything. What comes\n * back is a count of what would have been shown and what would have been\n * refused, and why.\n *\n * Run it where you change a prompt or a model, in your own CI, with your own\n * key. It is a separate entry point (`@intellectif/lk-core/ai-check`) because\n * it is for your test run, not for a learner's browser: nothing here is\n * imported by anything a page renders.\n *\n * ```ts\n * import { aiCheckCases, formatAiCheckReport, runAiCheck } from '@intellectif/lk-core/ai-check';\n *\n * const report = await runAiCheck({\n * explain: (request) => callMyModel(EXPLAIN_PROMPT, request),\n * hint: (request) => callMyModel(HINT_PROMPT, request),\n * });\n * console.log(formatAiCheckReport(report));\n * if (report.refused > 0 || report.errors > 0) {\n * process.exitCode = 1;\n * }\n * ```\n *\n * A refusal is a real failure, not a warning: it is an answer a learner would\n * have asked for and not received. `reveals-answer` on a hint case is the one\n * to take most seriously — that prompt gives answers away.\n */\nimport { checkAiExplanation, checkAiHint } from '../ai.js';\nimport type { AiExplanationRequest, AiHintRequest, AiRefusal, AiTextResult } from '../types/ai.js';\nimport { type AiCheckCase, aiCheckCases } from './cases.js';\n\nexport { type AiCheckCase, aiCheckCases } from './cases.js';\n\n/**\n * Your ports, as this kit calls them. The same functions\n * `<LkAiProvider ai={…}>` takes, minus the `AbortSignal` a browser passes —\n * nothing here abandons a call.\n *\n * Leave one out and its cases are skipped rather than failed.\n */\nexport interface AiCheckPorts {\n explain?(request: AiExplanationRequest): Promise<unknown> | unknown;\n hint?(request: AiHintRequest): Promise<unknown> | unknown;\n}\n\n/** What happened on one case. */\nexport interface AiCheckResult {\n case: AiCheckCase;\n /** Whether a learner would have been shown what came back. */\n ok: boolean;\n /** Why it would not have been shown. */\n refusal?: AiRefusal;\n /** The port threw or rejected. Its message, as a string. */\n error?: string;\n /**\n * What came back, once the SDK had read it — so a refusal can be read beside\n * the text that caused it. Absent when the port failed or answered with\n * nothing the SDK could read.\n */\n result?: AiTextResult;\n /** How long the call took, in milliseconds. */\n ms: number;\n}\n\n/** What a run came to. */\nexport interface AiCheckReport {\n /** Cases run: the ones a port was supplied for. */\n total: number;\n /** Cases whose answer a learner would have been shown. */\n shown: number;\n /** Cases whose answer the SDK refused. */\n refused: number;\n /** Cases where the port itself failed. */\n errors: number;\n /** Cases skipped because no port was supplied for that feature. */\n skipped: number;\n /** How many refusals of each reason. */\n byRefusal: Record<AiRefusal, number>;\n results: AiCheckResult[];\n}\n\nexport interface AiCheckOptions {\n /**\n * The cases to run. Defaults to {@link aiCheckCases}. Pass a filtered list to\n * run one type, or your own cases — built with `aiExplanationRequest` and\n * `aiHintRequest` on your own items, which is how you test a prompt against\n * the content your learners actually see.\n */\n cases?: readonly AiCheckCase[];\n /**\n * How many cases to have in flight at once. Default 1: a run in CI hits a\n * rate limit far more often than it runs out of patience.\n */\n concurrency?: number;\n}\n\nconst REFUSALS: AiRefusal[] = [\n 'malformed',\n 'empty',\n 'too-long',\n 'contradicts-grade',\n 'reveals-answer',\n];\n\n/** Milliseconds, from whichever clock this runtime has. */\nconst now = (): number => Date.now();\n\n/** Runs one case: calls the port, times it, and checks what came back. */\nasync function runCase(ports: AiCheckPorts, one: AiCheckCase): Promise<AiCheckResult> {\n const started = now();\n const explaining = one.request.feature === 'explanation';\n const port = explaining ? ports.explain : ports.hint;\n if (port === undefined) {\n throw new Error(`ai-check: no port for \"${one.id}\"`);\n }\n let raw: unknown;\n try {\n raw = await port(one.request as never);\n } catch (error) {\n return {\n case: one,\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n ms: now() - started,\n };\n }\n const ms = now() - started;\n const checked = explaining\n ? checkAiExplanation(raw, one.request as AiExplanationRequest)\n : checkAiHint(raw, one.request as AiHintRequest);\n if (checked.ok) {\n return { case: one, ok: true, result: checked.result, ms };\n }\n const text =\n typeof (raw as { text?: unknown })?.text === 'string' ? (raw as AiTextResult) : undefined;\n return {\n case: one,\n ok: false,\n refusal: checked.refusal,\n ...(text !== undefined ? { result: text } : {}),\n ms,\n };\n}\n\n/**\n * Calls your ports on every case and reports what a learner would have seen.\n *\n * It never throws for a failing case: a port that rejects is an `error` in the\n * report, so one bad call cannot hide the rest.\n */\nexport async function runAiCheck(\n ports: AiCheckPorts,\n options: AiCheckOptions = {},\n): Promise<AiCheckReport> {\n const all = options.cases ?? aiCheckCases();\n const asked = Math.trunc(options.concurrency ?? 1);\n const lanes = Number.isFinite(asked) && asked >= 1 ? Math.min(asked, 16) : 1;\n const runnable = all.filter((one) =>\n one.request.feature === 'explanation' ? ports.explain !== undefined : ports.hint !== undefined,\n );\n const results: AiCheckResult[] = new Array(runnable.length);\n let next = 0;\n const lane = async (): Promise<void> => {\n while (next < runnable.length) {\n const mine = next;\n next += 1;\n const one = runnable[mine];\n if (one === undefined) {\n return;\n }\n results[mine] = await runCase(ports, one);\n }\n };\n await Promise.all(Array.from({ length: Math.min(lanes, runnable.length) }, lane));\n\n const byRefusal = Object.fromEntries(REFUSALS.map((reason) => [reason, 0])) as Record<\n AiRefusal,\n number\n >;\n let shown = 0;\n let refused = 0;\n let errors = 0;\n for (const result of results) {\n if (result.ok) {\n shown += 1;\n } else if (result.refusal !== undefined) {\n refused += 1;\n byRefusal[result.refusal] += 1;\n } else {\n errors += 1;\n }\n }\n return {\n total: results.length,\n shown,\n refused,\n errors,\n skipped: all.length - runnable.length,\n byRefusal,\n results,\n };\n}\n\n/**\n * The report as a few lines for a CI log: the counts, then every case that\n * failed, with what came back.\n *\n * The refused text is printed — this is your own test run, not a learner's\n * screen, and a hint that gives the answer away is only fixable if you can\n * read it.\n */\nexport function formatAiCheckReport(report: AiCheckReport): string {\n const lines: string[] = [];\n const slowest = report.results.reduce((worst, one) => Math.max(worst, one.ms), 0);\n lines.push(\n `ai-check: ${report.shown}/${report.total} shown, ${report.refused} refused, ${report.errors} failed` +\n `${report.skipped > 0 ? `, ${report.skipped} skipped (no port)` : ''} — slowest ${slowest} ms`,\n );\n for (const reason of REFUSALS) {\n const count = report.byRefusal[reason];\n if (count > 0) {\n lines.push(` ${reason}: ${count}`);\n }\n }\n for (const result of report.results) {\n if (result.ok) {\n continue;\n }\n const why = result.refusal ?? `port failed (${result.error ?? 'no message'})`;\n lines.push(` ✗ ${result.case.id} [${result.case.feature}] ${result.case.about}: ${why}`);\n if (result.result !== undefined) {\n lines.push(` ${result.result.text.replace(/\\s+/g, ' ').slice(0, 200)}`);\n }\n }\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;;;AAqBA,IAAM,UAA8B;AAAA,EAClC,eAAe;AAAA,EACf,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,IACP,EAAE,IAAI,UAAU,MAAM,UAAU,WAAW,KAAK;AAAA,IAChD,EAAE,IAAI,aAAa,MAAM,aAAa,WAAW,MAAM;AAAA,IACvD,EAAE,IAAI,WAAW,MAAM,WAAW,WAAW,MAAM;AAAA,EACrD;AACF;AAEA,IAAM,eAAoC;AAAA,EACxC,eAAe;AAAA,EACf,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,IACN,EAAE,IAAI,MAAM,iBAAiB,CAAC,IAAI,EAAE;AAAA,IACpC,EAAE,IAAI,QAAQ,iBAAiB,CAAC,MAAM,GAAG,MAAM,gCAAgC;AAAA,EACjF;AAAA,EACA,iBAAiB;AACnB;AAEA,IAAM,YAA2B;AAAA,EAC/B,eAAe;AAAA,EACf,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,IACJ;AAAA,MACE,IA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