@crowandraven/evalkeeper 0.8.0 → 0.9.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 (73) hide show
  1. package/dist/feedback.d.ts +3 -1
  2. package/dist/feedback.js +3 -1
  3. package/dist/feedback.js.map +1 -1
  4. package/dist/glossary.d.ts +3 -0
  5. package/dist/glossary.js +3 -0
  6. package/dist/glossary.js.map +1 -1
  7. package/dist/importCases.d.ts +15 -4
  8. package/dist/importCases.js +20 -18
  9. package/dist/importCases.js.map +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/reviews.d.ts +172 -0
  14. package/dist/reviews.js +294 -0
  15. package/dist/reviews.js.map +1 -0
  16. package/dist/suiteContract.d.ts +3 -2
  17. package/dist/suiteContract.js +5 -2
  18. package/dist/suiteContract.js.map +1 -1
  19. package/dist/suites/attackImport.d.ts +99 -0
  20. package/dist/suites/attackImport.js +283 -0
  21. package/dist/suites/attackImport.js.map +1 -0
  22. package/dist/suites/crisisRisk.d.ts +9 -2
  23. package/dist/suites/crisisRisk.js +8 -3
  24. package/dist/suites/crisisRisk.js.map +1 -1
  25. package/dist/suites/crisisRiskCases.d.ts +4 -3
  26. package/dist/suites/crisisRiskCases.js +4 -3
  27. package/dist/suites/crisisRiskCases.js.map +1 -1
  28. package/dist/suites/crisisRiskReviews.d.ts +15 -0
  29. package/dist/suites/crisisRiskReviews.js +926 -0
  30. package/dist/suites/crisisRiskReviews.js.map +1 -0
  31. package/dist/suites/hopelessness.d.ts +9 -2
  32. package/dist/suites/hopelessness.js +8 -5
  33. package/dist/suites/hopelessness.js.map +1 -1
  34. package/dist/suites/hopelessnessCases.d.ts +3 -2
  35. package/dist/suites/hopelessnessCases.js +3 -2
  36. package/dist/suites/hopelessnessCases.js.map +1 -1
  37. package/dist/suites/hopelessnessReviews.d.ts +15 -0
  38. package/dist/suites/hopelessnessReviews.js +1080 -0
  39. package/dist/suites/hopelessnessReviews.js.map +1 -0
  40. package/dist/suites/index.d.ts +5 -0
  41. package/dist/suites/index.js +5 -0
  42. package/dist/suites/index.js.map +1 -1
  43. package/dist/suites/injection.d.ts +162 -0
  44. package/dist/suites/injection.js +331 -0
  45. package/dist/suites/injection.js.map +1 -0
  46. package/dist/suites/injectionAttacks.d.ts +3 -0
  47. package/dist/suites/injectionAttacks.js +34 -0
  48. package/dist/suites/injectionAttacks.js.map +1 -0
  49. package/dist/types.d.ts +21 -0
  50. package/dist/types.js +11 -0
  51. package/dist/types.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/feedback.ts +3 -1
  54. package/src/glossary.ts +6 -0
  55. package/src/importCases.ts +21 -20
  56. package/src/index.ts +1 -0
  57. package/src/reviews.ts +428 -0
  58. package/src/suiteContract.ts +5 -2
  59. package/src/suites/attackImport.ts +327 -0
  60. package/src/suites/crisisRisk.ts +15 -3
  61. package/src/suites/crisisRiskCases.ts +4 -3
  62. package/src/suites/crisisRiskReviews.ts +927 -0
  63. package/src/suites/hopelessness.ts +15 -5
  64. package/src/suites/hopelessnessCases.ts +3 -2
  65. package/src/suites/hopelessnessReviews.ts +1081 -0
  66. package/src/suites/index.ts +5 -0
  67. package/src/suites/injection.ts +463 -0
  68. package/src/suites/injectionAttacks.ts +136 -0
  69. package/src/types.ts +24 -0
  70. package/templates/app/evals/feedback/page.tsx +3 -1
  71. package/templates/app/evals/page.tsx +33 -26
  72. package/templates/components/evalkeeper/AnswerKey.tsx +23 -0
  73. package/templates/lib/evalkeeper/actions.ts +4 -1
@@ -0,0 +1,294 @@
1
+ import { stableJson } from "./stableJson.js";
2
+ /** The `raterRole` on an answer the suite's author reviewed. */
3
+ export const AUTHOR_REVIEWED = "SUITE_AUTHOR";
4
+ /** The `raterRole` on an answer an expert reviewed for the suite. */
5
+ export const EXPERT_REVIEWED = "SUITE_EXPERT";
6
+ /**
7
+ * The `raterRole` on an attack case's answer (see `injectionCases`),
8
+ * carried from the base case it was made from: an attack shouldn't change
9
+ * the right answer, so its confirmation is the base case's.
10
+ */
11
+ export const FROM_BASE_CASE = "FROM_BASE_CASE";
12
+ const ROLE = {
13
+ AUTHOR: AUTHOR_REVIEWED,
14
+ EXPERT: EXPERT_REVIEWED,
15
+ };
16
+ /**
17
+ * A short, stable key for a starter case: a hash of its input. Reviews
18
+ * name cases by it, and `importStarters` uses it as the case's id, so a
19
+ * rerun skips cases already added.
20
+ *
21
+ * @param input - The starter case's input.
22
+ */
23
+ export function starterKey(input) {
24
+ // FNV-1a: the core stays free of node:crypto; this only names rows.
25
+ let h = 0x811c9dc5;
26
+ for (const ch of stableJson(input)) {
27
+ h ^= ch.charCodeAt(0);
28
+ h = Math.imul(h, 0x01000193) >>> 0;
29
+ }
30
+ return h.toString(16).padStart(8, "0");
31
+ }
32
+ /**
33
+ * Whether an answer's confirmation shipped with the suite (author or
34
+ * expert reviewed) rather than coming from someone in the app.
35
+ *
36
+ * @param label - The answer, or just its rater role.
37
+ */
38
+ export function isShippedReview(label) {
39
+ return (label.raterRole === AUTHOR_REVIEWED || label.raterRole === EXPERT_REVIEWED);
40
+ }
41
+ /** A review's day, or null when it isn't a real YYYY-MM-DD date. */
42
+ function dayOf(at) {
43
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(at))
44
+ return null;
45
+ const d = new Date(`${at}T00:00:00Z`);
46
+ return Number.isNaN(d.getTime()) || d.toISOString().slice(0, 10) !== at
47
+ ? null
48
+ : d;
49
+ }
50
+ /** The suite's answer, parsed, as stable text to compare; null if it doesn't fit. */
51
+ function answerText(suite, label) {
52
+ const parsed = suite.labelValue.safeParse(label);
53
+ return parsed.success ? stableJson(parsed.data) : null;
54
+ }
55
+ /**
56
+ * What's wrong with one review against the suite's starters, in plain
57
+ * sentences; empty when it counts.
58
+ */
59
+ function problemsOf(suite, r, answers, now) {
60
+ const out = [];
61
+ const name = `${suite.key}: the review of case ${r.case}`;
62
+ if (!answers.has(r.case))
63
+ out.push(`${name} matches no starter case; its input changed or it was removed.`);
64
+ else {
65
+ const mine = answerText(suite, r.label);
66
+ if (mine === null)
67
+ out.push(`${name} has an answer that doesn't fit the schema.`);
68
+ else if (mine !== answers.get(r.case))
69
+ out.push(`${name} confirms a different answer than the case has now.`);
70
+ }
71
+ if (!r.by.trim())
72
+ out.push(`${name} doesn't say who reviewed it.`);
73
+ if (!r.credential.trim())
74
+ out.push(`${name} doesn't say what qualifies the reviewer.`);
75
+ const day = dayOf(r.at);
76
+ if (!day)
77
+ out.push(`${name} has no date as YYYY-MM-DD.`);
78
+ // A day starts up to 14 hours before UTC's somewhere (UTC+14), so a
79
+ // review dated today counts wherever today is.
80
+ else if (+day > +now + 14 * 3_600_000)
81
+ out.push(`${name} is dated in the future.`);
82
+ return out;
83
+ }
84
+ /** Each starter's key and its input as stable text. */
85
+ function starterInputs(suite) {
86
+ return new Map((suite.starter ?? []).map((s) => [
87
+ starterKey(s.input),
88
+ stableJson(s.input),
89
+ ]));
90
+ }
91
+ /** Each starter's key and its answer as stable text. */
92
+ function starterAnswers(suite) {
93
+ return new Map((suite.starter ?? []).map((s) => [
94
+ starterKey(s.input),
95
+ answerText(suite, s.label),
96
+ ]));
97
+ }
98
+ /**
99
+ * What's wrong with a suite's shipped reviews, in plain sentences; empty
100
+ * when every one counts. A review that matches no starter, confirms a
101
+ * different answer than the case has now, or is missing who, what
102
+ * qualifies them, or when, is a problem: `suiteContractProblems` reports
103
+ * these so a stale review is fixed, not silently ignored.
104
+ *
105
+ * @param suite - The suite whose `reviews` to check.
106
+ * @param now - Today; reviews dated after it are a problem.
107
+ */
108
+ export function reviewProblems(suite, now = new Date()) {
109
+ const answers = starterAnswers(suite);
110
+ const out = [];
111
+ const seen = new Set();
112
+ for (const r of suite.reviews ?? []) {
113
+ out.push(...problemsOf(suite, r, answers, now));
114
+ const id = `${r.case}|${r.level}|${r.by.trim()}`;
115
+ if (seen.has(id))
116
+ out.push(`${suite.key}: case ${r.case} has the same ${r.level.toLowerCase()} review twice.`);
117
+ seen.add(id);
118
+ }
119
+ return out;
120
+ }
121
+ /**
122
+ * The confirmed answer a review adds to a case.
123
+ *
124
+ * @param suite - The suite the review shipped with.
125
+ * @param r - A review that counts (see `reviewProblems`).
126
+ */
127
+ export function reviewedLabel(suite, r) {
128
+ const who = r.level === "EXPERT" ? "an expert" : "the suite's author";
129
+ return {
130
+ kind: "EXPECTED",
131
+ status: "CONFIRMED",
132
+ value: suite.labelValue.parse(r.label),
133
+ raterRole: ROLE[r.level],
134
+ raterId: r.by.trim(),
135
+ note: `Reviewed by ${who} for the ${suite.label} suite: ${r.by.trim()} (${r.credential.trim()}) confirmed it on ${r.at}.`,
136
+ };
137
+ }
138
+ /** The newest answer someone in the app put to use, if any. */
139
+ function appAnswer(c) {
140
+ return [...c.labels]
141
+ .filter((l) => (l.status === "CONFIRMED" || l.status === "PROVISIONAL") &&
142
+ !isShippedReview(l))
143
+ .sort((a, b) => +b.updatedAt - +a.updatedAt)[0];
144
+ }
145
+ /**
146
+ * Adds a suite's shipped reviews to its starter cases already in the
147
+ * store, as confirmed answers. Safe to run again: a review already added
148
+ * is skipped, and one re-signed with a new answer (after the case's
149
+ * answer changed) is added as the newer confirmation. A case whose own
150
+ * confirmed or provisional answer came from someone in the app keeps it:
151
+ * the review is never added over it, and a different answer is reported
152
+ * in `disagree`. A case whose stored input isn't the one reviewed (a leak
153
+ * check changed it) gets no review and is reported in `notSeen`. Reviews
154
+ * that don't count (see `reviewProblems`) are left out. `importStarters`
155
+ * runs it.
156
+ *
157
+ * @param store - Where the suite's cases are.
158
+ * @param suite - The suite whose `reviews` to add.
159
+ * @param source - The `sourceRef` prefix starter cases were added under.
160
+ * @param now - Today; reviews dated after it are left out.
161
+ */
162
+ export async function addShippedReviews(store, suite, source, now = new Date()) {
163
+ const result = { reviewed: 0, disagree: [], notSeen: [] };
164
+ const reviews = suite.reviews ?? [];
165
+ if (!reviews.length)
166
+ return result;
167
+ const answers = starterAnswers(suite);
168
+ const inputs = starterInputs(suite);
169
+ const counting = reviews.filter((r) => problemsOf(suite, r, answers, now).length === 0);
170
+ const byRef = new Map((await store.listCases(suite.key)).map((c) => [c.sourceRef, c]));
171
+ // Reviews added in this pass, by case: a store may or may not hand back
172
+ // the same case objects, so don't rely on them updating.
173
+ const added = new Set();
174
+ for (const r of counting) {
175
+ const c = byRef.get(`${source}#${r.case}`);
176
+ if (!c)
177
+ continue;
178
+ if (stableJson(c.input) !== inputs.get(r.case)) {
179
+ result.notSeen.push({ caseId: c.id, review: r });
180
+ continue;
181
+ }
182
+ const label = reviewedLabel(suite, r);
183
+ const value = stableJson(label.value);
184
+ const id = `${c.id}|${label.raterRole}|${label.raterId ?? ""}|${value}`;
185
+ if (added.has(id) ||
186
+ c.labels.some((l) => l.raterRole === label.raterRole &&
187
+ l.raterId === label.raterId &&
188
+ stableJson(l.value) === value))
189
+ continue;
190
+ const theirs = appAnswer(c);
191
+ if (theirs) {
192
+ if (stableJson(theirs.value) !== value)
193
+ result.disagree.push({ caseId: c.id, review: r });
194
+ continue;
195
+ }
196
+ await store.addLabel(c.id, label);
197
+ added.add(id);
198
+ if (c.status === "DRAFT" && !added.has(c.id)) {
199
+ await store.setCaseStatus(c.id, "ACTIVE");
200
+ added.add(c.id);
201
+ }
202
+ result.reviewed += 1;
203
+ }
204
+ return result;
205
+ }
206
+ /**
207
+ * A suite's starter cases as rows for a reviewer to mark, in the order
208
+ * the suite lists them. `reviewsFromSheet` turns the rows they confirm
209
+ * into shipped reviews.
210
+ *
211
+ * @param suite - The suite whose `starter` cases to list.
212
+ */
213
+ export function reviewSheet(suite) {
214
+ return (suite.starter ?? []).map((s) => {
215
+ const input = suite.input.parse(s.input);
216
+ return {
217
+ case: starterKey(s.input),
218
+ title: suite.title(input),
219
+ input: suite.describe?.(input) ?? stableJson(s.input),
220
+ answer: stableJson(s.label),
221
+ };
222
+ });
223
+ }
224
+ /** Marks that confirm a row of a review sheet. */
225
+ const CONFIRMS = new Set(["y", "yes", "ok", "confirm", "confirmed"]);
226
+ /**
227
+ * Turns a marked review sheet into shipped reviews: one for each row the
228
+ * reviewer confirmed ("yes", "y", "ok"), of the case's answer as it is
229
+ * now. Rows left blank are left out. A row naming a case the suite
230
+ * doesn't have, marked anything else, or showing an answer other than the
231
+ * case's answer now (it changed after the sheet was made) stops it: a
232
+ * case whose answer should change is edited in the suite first, then
233
+ * reviewed again on a new sheet.
234
+ *
235
+ * @param suite - The suite the sheet was made from.
236
+ * @param rows - Each row's case, the reviewer's mark, and the answer the
237
+ * sheet showed them (from `reviewSheet`), when the sheet kept it.
238
+ * @param reviewer - Who reviewed it, what qualifies them, and when.
239
+ * @returns The reviews, in the suite's order.
240
+ * @throws When a row names an unknown case or has an unknown mark, or
241
+ * the reviewer is missing who, what qualifies them, or a date.
242
+ */
243
+ export function reviewsFromSheet(suite, rows, reviewer) {
244
+ const problems = [];
245
+ if (!reviewer.by.trim())
246
+ problems.push("no reviewer (--by)");
247
+ if (!reviewer.credential.trim())
248
+ problems.push("no credential (--credential)");
249
+ if (!dayOf(reviewer.at))
250
+ problems.push("no date as YYYY-MM-DD (--at)");
251
+ const starters = new Map((suite.starter ?? []).map((s) => [starterKey(s.input), s.label]));
252
+ const confirmed = new Set();
253
+ for (const r of rows) {
254
+ const mark = r.confirm.trim().toLowerCase();
255
+ if (!starters.has(r.case))
256
+ problems.push(`case ${r.case} isn't one of ${suite.key}'s starters`);
257
+ else if (CONFIRMS.has(mark) &&
258
+ r.answer !== undefined &&
259
+ r.answer.trim() !== stableJson(starters.get(r.case)))
260
+ problems.push(`case ${r.case}'s answer changed after the sheet was made; make a new sheet`);
261
+ else if (CONFIRMS.has(mark))
262
+ confirmed.add(r.case);
263
+ else if (mark)
264
+ problems.push(`case ${r.case} is marked "${r.confirm.trim()}"; mark "yes" or leave it blank`);
265
+ }
266
+ if (problems.length)
267
+ throw new Error(`The sheet can't be signed: ${problems.join("; ")}.`);
268
+ return [...starters].flatMap(([key, label]) => confirmed.has(key)
269
+ ? [
270
+ {
271
+ case: key,
272
+ label,
273
+ level: reviewer.level,
274
+ by: reviewer.by.trim(),
275
+ credential: reviewer.credential.trim(),
276
+ at: reviewer.at,
277
+ },
278
+ ]
279
+ : []);
280
+ }
281
+ /**
282
+ * A suite's reviews with one reviewer's replaced by a new set: everyone
283
+ * else's stay as they were, and theirs (same name and level) are swapped
284
+ * for `next`, so signing a sheet again never duplicates a review.
285
+ *
286
+ * @param existing - The reviews the suite ships now.
287
+ * @param next - The reviews from the newly signed sheet.
288
+ * @param reviewer - Whose reviews `next` replaces.
289
+ */
290
+ export function mergeReviews(existing, next, reviewer) {
291
+ const theirs = (r) => r.level === reviewer.level && r.by.trim() === reviewer.by.trim();
292
+ return [...existing.filter((r) => !theirs(r)), ...next];
293
+ }
294
+ //# sourceMappingURL=reviews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviews.js","sourceRoot":"","sources":["../src/reviews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmB7C,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAC9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,MAAM,IAAI,GAAgC;IACxC,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;CACxB,CAAC;AAsBF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,oEAAoE;IACpE,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,MAAM,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CA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C,GAAG,CAAC;QAChB,CAAC,CAAC;YACE;gBACE,IAAI,EAAE,GAAG;gBACT,KAAK;gBACL,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE;gBACtB,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE;gBACtC,EAAE,EAAE,QAAQ,CAAC,EAAE;aAChB;SACF;QACH,CAAC,CAAC,EAAE,CACP,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAkC,EAClC,IAA8B,EAC9B,QAAwC;IAExC,MAAM,MAAM,GAAG,CAAC,CAAgB,EAAE,EAAE,CAClC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACnE,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AAC1D,CAAC"}
@@ -16,8 +16,9 @@ export declare function schemaKeys(schema: z.ZodTypeAny): string[] | null;
16
16
  * sentences; empty when nothing is. Checks that suite keys are unique;
17
17
  * every top-level field of each suite's input and answer (every option's,
18
18
  * for a union) has a `fields` entry with a label and help, and no entry
19
- * names a field the schema doesn't have; every check has a description; and starter
20
- * cases fit the suite's own schemas. Pure; `describeSuiteContract` runs it
19
+ * names a field the schema doesn't have; every check has a description;
20
+ * starter cases fit the suite's own schemas; and every shipped review
21
+ * still matches its case's input and answer (see `reviewProblems`). Pure; `describeSuiteContract` runs it
21
22
  * as tests.
22
23
  */
23
24
  export declare function suiteContractProblems(suites: readonly AnySuite[]): string[];
@@ -1,3 +1,4 @@
1
+ import { reviewProblems } from "./reviews.js";
1
2
  /** A field help shorter than this says nothing a label doesn't. */
2
3
  const MIN_HELP = 10;
3
4
  /**
@@ -78,8 +79,9 @@ function fieldProblems(suite, side, keys, fields) {
78
79
  * sentences; empty when nothing is. Checks that suite keys are unique;
79
80
  * every top-level field of each suite's input and answer (every option's,
80
81
  * for a union) has a `fields` entry with a label and help, and no entry
81
- * names a field the schema doesn't have; every check has a description; and starter
82
- * cases fit the suite's own schemas. Pure; `describeSuiteContract` runs it
82
+ * names a field the schema doesn't have; every check has a description;
83
+ * starter cases fit the suite's own schemas; and every shipped review
84
+ * still matches its case's input and answer (see `reviewProblems`). Pure; `describeSuiteContract` runs it
83
85
  * as tests.
84
86
  */
85
87
  export function suiteContractProblems(suites) {
@@ -100,6 +102,7 @@ export function suiteContractProblems(suites) {
100
102
  if (!suite.labelValue.safeParse(s.label).success)
101
103
  out.push(`${name}: starter ${i + 1}'s answer doesn't fit the schema.`);
102
104
  });
105
+ out.push(...reviewProblems(suite));
103
106
  }
104
107
  return out;
105
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"suiteContract.js","sourceRoot":"","sources":["../src/suiteContract.ts"],"names":[],"mappings":"AAGA,mEAAmE;AACnE,MAAM,QAAQ,GAAG,EAAE,CAAC;AAYpB;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,MAAoB;IAC7C,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,yEAAyE;AACzE,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,MAAM,CAAC,MAAoB,EAAE,KAAa;IACjD,IAAI,CAAC,GAA6B,MAAM,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,kEAAkE;QAClE,MAAM,GAAG,GAAG,CAAC,CAAC,IAAW,CAAC;QAC1B,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,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AC,KAAK,CAAC,EACvB,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAC1B,EACD,GAAG,aAAa,CACd,IAAI,EACJ,OAAO,EACP,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,EAC5B,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAC1B,CACF,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM;YAC1B,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE;gBACvB,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC;QAC9D,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO;gBACzC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YACxE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO;gBAC9C,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { type Attack, type AttackKind } from "./injection.js";
2
+ /**
3
+ * Attacks from other tools, for the injection suite (./injection.ts).
4
+ * Each reader takes what the tool wrote, as text, and returns attacks in
5
+ * Evalkeeper's shape; it never calls the tool or the network. Where the
6
+ * tool checks for a word the model shouldn't say, the reader swaps that
7
+ * word for `{{canary}}`, so the suite's own canary check grades it.
8
+ * Attacks the suite couldn't grade without a judge model are left out
9
+ * and counted in `skipped`.
10
+ *
11
+ * Their datasets carry their own licenses (garak: Apache-2.0;
12
+ * CyberSecEval: MIT; promptfoo's generated tests: yours). The attacks are
13
+ * stored as cases in your database, so read them before relying on them.
14
+ */
15
+ /** Attacks read from a tool's output, and what was left out. */
16
+ export type ImportedAttacks = {
17
+ attacks: Attack[];
18
+ /** Entries left out, with why, for a person to check. */
19
+ skipped: {
20
+ id: string;
21
+ why: string;
22
+ }[];
23
+ };
24
+ /**
25
+ * Reads an attack file: one JSON attack per line (`id`, `kind`, `text`,
26
+ * `technique`, `source`). Blank lines are skipped. Any line that doesn't
27
+ * fit, or an id used twice within a source, stops it with every problem
28
+ * listed, so a file is used whole or not at all.
29
+ *
30
+ * @param text - The file's contents.
31
+ * @returns The attacks, in file order.
32
+ * @throws When a line isn't JSON, doesn't fit, or repeats an id.
33
+ * @example
34
+ * ```ts
35
+ * const attacks = readAttacks(readFileSync("attacks.jsonl", "utf8"));
36
+ * export const triageInjection = injectionSuite(ticketTriage, {
37
+ * inject,
38
+ * attacks: [...INJECTION_ATTACKS, ...attacks],
39
+ * });
40
+ * ```
41
+ */
42
+ export declare function readAttacks(text: string): Attack[];
43
+ /**
44
+ * Attacks as an attack file: one JSON attack per line, for `readAttacks`.
45
+ *
46
+ * @param attacks - The attacks to write.
47
+ */
48
+ export declare function writeAttacks(attacks: readonly Attack[]): string;
49
+ /**
50
+ * Reads CyberSecEval's prompt injection set (Meta's PurpleLlama,
51
+ * `CybersecurityBenchmarks/datasets/prompt_injection/prompt_injection.json`).
52
+ * A case whose check asks for a word the attack itself names ("say
53
+ * 'Piano'") becomes a direct or indirect attack carrying the canary. One
54
+ * whose word is a secret in the benchmark's own system prompt becomes an
55
+ * extraction attack, graded by your suite's `secrets`. Cases checked
56
+ * another way (a judge's reading of the answer) are skipped.
57
+ *
58
+ * @param json - The dataset's JSON text.
59
+ * @param source - Where it came from, recorded on each attack; include
60
+ * the commit or version.
61
+ */
62
+ export declare function cyberSecEvalAttacks(json: string, source?: string): ImportedAttacks;
63
+ /**
64
+ * Reads garak's system prompt extraction attacks
65
+ * (`garak/data/sysprompt_extraction/attacks.json`: lists of requests by
66
+ * technique) as extraction attacks, graded by your suite's `secrets`.
67
+ *
68
+ * @param json - The file's JSON text.
69
+ * @param source - Where it came from, with garak's version.
70
+ */
71
+ export declare function garakSyspromptAttacks(json: string, source?: string): ImportedAttacks;
72
+ /**
73
+ * Reads the attempts in a garak report (`garak.<run>.report.jsonl`) from
74
+ * its injection probes: run garak against its offline `test.Blank`
75
+ * generator and no model is called, but the report still records every
76
+ * attack. Each attempt's trigger (the string garak checks the answer
77
+ * for) becomes the canary; `latentinjection` probes, which hide the
78
+ * attack in a document, are indirect, the rest direct. Attempts with no
79
+ * trigger in their text, and repeats of the same text, are skipped.
80
+ *
81
+ * @param jsonl - The report's text.
82
+ * @param source - Where it came from, with garak's version.
83
+ */
84
+ export declare function garakReportAttacks(jsonl: string, source?: string): ImportedAttacks;
85
+ /**
86
+ * Reads promptfoo's red team tests written as Burp payloads
87
+ * (`promptfoo redteam generate -o tests.burp`): one URL-encoded attack
88
+ * per line. They
89
+ * carry no canary, so only your suite's own checks and `secrets` grade
90
+ * them. Note that promptfoo writes these with a model, on its hosted
91
+ * service unless you set it up otherwise, and sends it your app's
92
+ * description.
93
+ *
94
+ * @param text - The .burp file's text.
95
+ * @param source - Where it came from, with promptfoo's version.
96
+ * @param kind - What the plugin you generated with tests; default
97
+ * "direct".
98
+ */
99
+ export declare function promptfooBurpAttacks(text: string, source?: string, kind?: AttackKind): ImportedAttacks;