@crowandraven/evalkeeper 0.10.0 → 0.11.1

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 (241) hide show
  1. package/README.md +1 -2
  2. package/dist/ai-sdk/decide.d.ts +35 -0
  3. package/dist/ai-sdk/decide.js +36 -0
  4. package/dist/ai-sdk/decide.js.map +1 -0
  5. package/dist/ai-sdk/hash.d.ts +50 -0
  6. package/dist/ai-sdk/hash.js +59 -0
  7. package/dist/ai-sdk/hash.js.map +1 -0
  8. package/dist/ai-sdk/index.d.ts +15 -0
  9. package/dist/ai-sdk/index.js +16 -0
  10. package/dist/ai-sdk/index.js.map +1 -0
  11. package/dist/ai-sdk/judge.d.ts +69 -0
  12. package/dist/ai-sdk/judge.js +105 -0
  13. package/dist/ai-sdk/judge.js.map +1 -0
  14. package/dist/ai-sdk/usage.d.ts +18 -0
  15. package/dist/ai-sdk/usage.js +19 -0
  16. package/dist/ai-sdk/usage.js.map +1 -0
  17. package/dist/board.d.ts +5 -0
  18. package/dist/cli/addPages.d.ts +6 -1
  19. package/dist/cli/addPages.js +14 -8
  20. package/dist/cli/addPages.js.map +1 -1
  21. package/dist/cli/main.d.ts +19 -5
  22. package/dist/cli/main.js +100 -4
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/migration.d.ts +95 -0
  25. package/dist/cli/migration.js +247 -0
  26. package/dist/cli/migration.js.map +1 -0
  27. package/dist/feedback.d.ts +1 -1
  28. package/dist/glossary.d.ts +8 -1
  29. package/dist/glossary.js +8 -1
  30. package/dist/glossary.js.map +1 -1
  31. package/dist/inInstructions.d.ts +1 -1
  32. package/dist/inInstructions.js +1 -1
  33. package/dist/next/RefreshWhile.d.ts +11 -0
  34. package/dist/next/RefreshWhile.js +28 -0
  35. package/dist/next/RefreshWhile.js.map +1 -0
  36. package/dist/next/actions.d.ts +14 -0
  37. package/dist/next/actions.js +332 -0
  38. package/dist/next/actions.js.map +1 -0
  39. package/dist/next/components.d.ts +9 -0
  40. package/dist/next/components.js +27 -0
  41. package/dist/next/components.js.map +1 -0
  42. package/dist/next/cron.d.ts +9 -0
  43. package/dist/next/cron.js +17 -0
  44. package/dist/next/cron.js.map +1 -0
  45. package/dist/next/index.d.ts +15 -0
  46. package/dist/next/index.js +16 -0
  47. package/dist/next/index.js.map +1 -0
  48. package/dist/next/pages.d.ts +70 -0
  49. package/dist/next/pages.js +77 -0
  50. package/dist/next/pages.js.map +1 -0
  51. package/dist/next/route.d.ts +19 -0
  52. package/dist/next/route.js +31 -0
  53. package/dist/next/route.js.map +1 -0
  54. package/dist/next/weekly.d.ts +20 -0
  55. package/dist/next/weekly.js +55 -0
  56. package/dist/next/weekly.js.map +1 -0
  57. package/dist/next/wiring.d.ts +19 -0
  58. package/dist/next/wiring.js +2 -0
  59. package/dist/next/wiring.js.map +1 -0
  60. package/dist/prisma/contracts.d.ts +74 -0
  61. package/dist/prisma/contracts.js +178 -0
  62. package/dist/prisma/contracts.js.map +1 -0
  63. package/dist/prisma/index.d.ts +423 -0
  64. package/dist/prisma/index.js +622 -0
  65. package/dist/prisma/index.js.map +1 -0
  66. package/dist/prisma/mapping.d.ts +63 -0
  67. package/dist/prisma/mapping.js +111 -0
  68. package/dist/prisma/mapping.js.map +1 -0
  69. package/dist/prisma/moveIn.d.ts +106 -0
  70. package/dist/prisma/moveIn.js +299 -0
  71. package/dist/prisma/moveIn.js.map +1 -0
  72. package/dist/prune.d.ts +45 -0
  73. package/dist/prune.js +32 -0
  74. package/dist/prune.js.map +1 -1
  75. package/dist/react/AddCase.d.ts +10 -0
  76. package/dist/react/AddCase.js +19 -0
  77. package/dist/react/AddCase.js.map +1 -0
  78. package/dist/react/AnswerKey.d.ts +22 -0
  79. package/dist/react/AnswerKey.js +83 -0
  80. package/dist/react/AnswerKey.js.map +1 -0
  81. package/dist/react/CaseMenu.d.ts +17 -0
  82. package/dist/react/CaseMenu.js +41 -0
  83. package/dist/react/CaseMenu.js.map +1 -0
  84. package/dist/react/CompareView.d.ts +14 -0
  85. package/dist/react/CompareView.js +51 -0
  86. package/dist/react/CompareView.js.map +1 -0
  87. package/dist/react/ConfirmAnswer.d.ts +13 -0
  88. package/dist/react/ConfirmAnswer.js +27 -0
  89. package/dist/react/ConfirmAnswer.js.map +1 -0
  90. package/dist/react/DisagreementChip.d.ts +10 -0
  91. package/dist/react/DisagreementChip.js +21 -0
  92. package/dist/react/DisagreementChip.js.map +1 -0
  93. package/dist/react/FeedbackView.d.ts +10 -0
  94. package/dist/react/FeedbackView.js +26 -0
  95. package/dist/react/FeedbackView.js.map +1 -0
  96. package/dist/react/Fields.d.ts +32 -0
  97. package/dist/react/Fields.js +33 -0
  98. package/dist/react/Fields.js.map +1 -0
  99. package/dist/react/HubSections.d.ts +78 -0
  100. package/dist/react/HubSections.js +124 -0
  101. package/dist/react/HubSections.js.map +1 -0
  102. package/dist/react/ModelMenu.d.ts +16 -0
  103. package/dist/react/ModelMenu.js +38 -0
  104. package/dist/react/ModelMenu.js.map +1 -0
  105. package/dist/react/RateView.d.ts +18 -0
  106. package/dist/react/RateView.js +30 -0
  107. package/dist/react/RateView.js.map +1 -0
  108. package/dist/react/ReadableOutput.d.ts +3 -0
  109. package/dist/react/ReadableOutput.js +50 -0
  110. package/dist/react/ReadableOutput.js.map +1 -0
  111. package/dist/react/RollBack.d.ts +17 -0
  112. package/dist/react/RollBack.js +26 -0
  113. package/dist/react/RollBack.js.map +1 -0
  114. package/dist/react/RunView.d.ts +9 -0
  115. package/dist/react/RunView.js +41 -0
  116. package/dist/react/RunView.js.map +1 -0
  117. package/dist/react/SettingsHistory.d.ts +33 -0
  118. package/dist/react/SettingsHistory.js +79 -0
  119. package/dist/react/SettingsHistory.js.map +1 -0
  120. package/dist/react/SideBySideView.d.ts +14 -0
  121. package/dist/react/SideBySideView.js +67 -0
  122. package/dist/react/SideBySideView.js.map +1 -0
  123. package/dist/react/SuiteSections.d.ts +111 -0
  124. package/dist/react/SuiteSections.js +224 -0
  125. package/dist/react/SuiteSections.js.map +1 -0
  126. package/dist/react/Tabs.d.ts +15 -0
  127. package/dist/react/Tabs.js +18 -0
  128. package/dist/react/Tabs.js.map +1 -0
  129. package/dist/react/Thumbs.d.ts +13 -0
  130. package/dist/react/Thumbs.js +54 -0
  131. package/dist/react/Thumbs.js.map +1 -0
  132. package/dist/react/WeeklyCheck.d.ts +11 -0
  133. package/dist/react/WeeklyCheck.js +19 -0
  134. package/dist/react/WeeklyCheck.js.map +1 -0
  135. package/dist/react/app.d.ts +118 -0
  136. package/dist/react/app.js +87 -0
  137. package/dist/react/app.js.map +1 -0
  138. package/dist/react/format.d.ts +27 -0
  139. package/dist/react/format.js +38 -0
  140. package/dist/react/format.js.map +1 -0
  141. package/dist/react/index.d.ts +31 -0
  142. package/dist/react/index.js +32 -0
  143. package/dist/react/index.js.map +1 -0
  144. package/dist/react/pieces.d.ts +191 -0
  145. package/dist/react/pieces.js +191 -0
  146. package/dist/react/pieces.js.map +1 -0
  147. package/dist/readCheck.d.ts +1 -1
  148. package/dist/runner.d.ts +62 -2
  149. package/dist/runner.js +123 -3
  150. package/dist/runner.js.map +1 -1
  151. package/dist/settings.d.ts +1 -1
  152. package/dist/store.d.ts +1 -1
  153. package/dist/suggest.d.ts +1 -1
  154. package/dist/suggest.js +7 -7
  155. package/dist/suggest.js.map +1 -1
  156. package/dist/suiteContract.d.ts +3 -3
  157. package/dist/suiteContract.js +20 -16
  158. package/dist/suiteContract.js.map +1 -1
  159. package/dist/testing.d.ts +2 -2
  160. package/dist/testing.js +1 -1
  161. package/dist/types.js +1 -1
  162. package/dist/types.js.map +1 -1
  163. package/package.json +56 -6
  164. package/schema/evalkeeper.prisma +196 -0
  165. package/src/ai-sdk/decide.ts +57 -0
  166. package/src/ai-sdk/hash.ts +74 -0
  167. package/src/ai-sdk/index.ts +15 -0
  168. package/src/ai-sdk/judge.ts +163 -0
  169. package/src/ai-sdk/usage.ts +31 -0
  170. package/src/board.ts +5 -0
  171. package/src/cli/addPages.ts +15 -7
  172. package/src/cli/main.ts +135 -9
  173. package/src/cli/migration.ts +349 -0
  174. package/src/feedback.ts +1 -1
  175. package/src/glossary.ts +16 -2
  176. package/src/inInstructions.ts +1 -1
  177. package/{templates/components/evalkeeper → src/next}/RefreshWhile.tsx +2 -2
  178. package/src/next/actions.ts +389 -0
  179. package/src/next/components.ts +31 -0
  180. package/{templates/lib/evalkeeper/cronAuth.ts → src/next/cron.ts} +3 -0
  181. package/src/next/index.ts +15 -0
  182. package/src/next/pages.tsx +106 -0
  183. package/src/next/route.ts +35 -0
  184. package/src/next/weekly.ts +70 -0
  185. package/src/next/wiring.ts +18 -0
  186. package/src/prisma/contracts.ts +249 -0
  187. package/src/prisma/index.ts +1169 -0
  188. package/src/prisma/mapping.ts +147 -0
  189. package/src/prisma/moveIn.ts +502 -0
  190. package/src/prune.ts +77 -0
  191. package/{templates/components/evalkeeper → src/react}/AddCase.tsx +6 -6
  192. package/{templates/components/evalkeeper → src/react}/AnswerKey.tsx +92 -61
  193. package/{templates/components/evalkeeper → src/react}/CaseMenu.tsx +9 -8
  194. package/src/react/CompareView.tsx +270 -0
  195. package/{templates/components/evalkeeper → src/react}/ConfirmAnswer.tsx +6 -3
  196. package/{templates/components/evalkeeper → src/react}/DisagreementChip.tsx +2 -3
  197. package/src/react/FeedbackView.tsx +230 -0
  198. package/{templates/components/evalkeeper → src/react}/Fields.tsx +6 -6
  199. package/src/react/HubSections.tsx +446 -0
  200. package/src/react/ModelMenu.tsx +89 -0
  201. package/src/react/RateView.tsx +143 -0
  202. package/{templates/components/evalkeeper → src/react}/ReadableOutput.tsx +1 -1
  203. package/{templates/components/evalkeeper → src/react}/RollBack.tsx +9 -10
  204. package/src/react/RunView.tsx +151 -0
  205. package/{templates/components/evalkeeper → src/react}/SettingsHistory.tsx +16 -9
  206. package/src/react/SideBySideView.tsx +307 -0
  207. package/src/react/SuiteSections.tsx +925 -0
  208. package/src/react/Tabs.tsx +61 -0
  209. package/{templates/components/evalkeeper → src/react}/Thumbs.tsx +7 -6
  210. package/{templates/components/evalkeeper → src/react}/WeeklyCheck.tsx +31 -20
  211. package/src/react/app.ts +173 -0
  212. package/src/react/format.ts +45 -0
  213. package/src/react/index.ts +31 -0
  214. package/src/react/pieces.tsx +412 -0
  215. package/src/readCheck.ts +1 -1
  216. package/src/runner.ts +167 -3
  217. package/src/settings.ts +1 -1
  218. package/src/store.ts +1 -1
  219. package/src/suggest.ts +7 -7
  220. package/src/suiteContract.ts +35 -28
  221. package/src/testing.ts +2 -2
  222. package/src/types.ts +2 -2
  223. package/starter/index.ts +22 -8
  224. package/templates/app/api/cron/evals-weekly/route.ts +5 -15
  225. package/templates/app/evals/[suite]/compare/page.tsx +6 -383
  226. package/templates/app/evals/[suite]/page.tsx +7 -685
  227. package/templates/app/evals/[suite]/rate/page.tsx +6 -151
  228. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +6 -174
  229. package/templates/app/evals/[suite]/side-by-side/page.tsx +6 -318
  230. package/templates/app/evals/feedback/page.tsx +6 -227
  231. package/templates/app/evals/layout.tsx +10 -0
  232. package/templates/app/evals/page.tsx +7 -397
  233. package/templates/lib/evalkeeper/actions.ts +34 -317
  234. package/templates/lib/evalkeeper/appComponents.tsx +21 -0
  235. package/templates/lib/evalkeeper/evals.ts +14 -0
  236. package/templates/lib/evalkeeper/paths.ts +2 -7
  237. package/templates/components/evalkeeper/Submit.tsx +0 -67
  238. package/templates/components/evalkeeper/Tip.tsx +0 -98
  239. package/templates/components/evalkeeper/ui.tsx +0 -105
  240. package/templates/lib/evalkeeper/time.ts +0 -4
  241. package/templates/lib/evalkeeper/weekly.ts +0 -74
@@ -0,0 +1,423 @@
1
+ import type { FeedbackStore, EvalStore, ChangeKind, SettingsStore } from "../index.js";
2
+ import { type ColumnMap } from "./mapping.js";
3
+ export type { ColumnMap } from "./mapping.js";
4
+ export * from "./contracts.js";
5
+ /**
6
+ * An EvalStore on your Prisma client, using the models in
7
+ * schema/evalkeeper.prisma. Pass the client you already have:
8
+ *
9
+ * const store = prismaStore(prisma);
10
+ *
11
+ * The client is typed by the rows it returns, not by Prisma's generated
12
+ * types, so this package works with any client generated from the schema.
13
+ */
14
+ /** A stored JSON value, as Prisma returns it. */
15
+ type Json = unknown;
16
+ /** The rows of Evalkeeper's tables, as the schema defines them. */
17
+ export type EvalCaseRow = {
18
+ id: string;
19
+ suite: string;
20
+ input: Json;
21
+ tags: Json;
22
+ split: string;
23
+ status: string;
24
+ source: string;
25
+ sourceRef: string | null;
26
+ note: string | null;
27
+ createdAt: Date;
28
+ updatedAt: Date;
29
+ };
30
+ /** An EvalCaseLabel row. */
31
+ export type EvalCaseLabelRow = {
32
+ id: string;
33
+ caseId: string;
34
+ kind: string;
35
+ status: string;
36
+ value: Json;
37
+ raterRole: string;
38
+ raterId: string | null;
39
+ note: string | null;
40
+ createdAt: Date;
41
+ updatedAt: Date;
42
+ };
43
+ /** An EvalRun row. */
44
+ export type EvalRunRow = {
45
+ id: string;
46
+ suite: string;
47
+ model: string;
48
+ promptVersion: string;
49
+ reasoningEffort: string | null;
50
+ temperature: number | null;
51
+ maxOutputTokens: number | null;
52
+ set: string;
53
+ repeats: number;
54
+ datasetVersion: string | null;
55
+ graderVersion: string;
56
+ status: string;
57
+ metrics: Json;
58
+ error: string | null;
59
+ estimatedCostUsd: number | null;
60
+ startedBy: string | null;
61
+ startedAt: Date;
62
+ finishedAt: Date | null;
63
+ };
64
+ /** An EvalOutput row. */
65
+ export type EvalOutputRow = {
66
+ id: string;
67
+ runId: string;
68
+ caseId: string;
69
+ repeat: number;
70
+ requestHash: string;
71
+ output: Json;
72
+ error: string | null;
73
+ scores: Json;
74
+ costUsd: number;
75
+ ms: number;
76
+ reused: boolean;
77
+ createdAt: Date;
78
+ };
79
+ /** An EvalJudgment row. */
80
+ export type EvalJudgmentRow = {
81
+ key: string;
82
+ value: Json;
83
+ model: string;
84
+ createdAt: Date;
85
+ };
86
+ /** The methods of a Prisma model delegate this package calls. */
87
+ type Delegate<Row> = {
88
+ findMany(args: object): PromiseLike<Row[]>;
89
+ findFirst(args: object): PromiseLike<Row | null>;
90
+ findUnique(args: object): PromiseLike<Row | null>;
91
+ create(args: object): PromiseLike<Row>;
92
+ update(args: object): PromiseLike<Row>;
93
+ updateMany(args: object): PromiseLike<{
94
+ count: number;
95
+ }>;
96
+ };
97
+ /** The part of a generated Prisma client Evalkeeper uses. */
98
+ export type PrismaEvalClient = {
99
+ evalCase: Delegate<EvalCaseRow>;
100
+ evalCaseLabel: Delegate<EvalCaseLabelRow>;
101
+ evalRun: Delegate<EvalRunRow>;
102
+ evalOutput: Delegate<EvalOutputRow>;
103
+ evalJudgment: Delegate<EvalJudgmentRow>;
104
+ };
105
+ /** Evalkeeper's eval tables, by the names its schema gives them. */
106
+ export type EvalTable = "evalCase" | "evalCaseLabel" | "evalRun" | "evalOutput" | "evalJudgment";
107
+ /**
108
+ * How Evalkeeper's eval tables map onto an app's own, for an app that had
109
+ * eval tables before Evalkeeper. Pass it to `prismaStore` and
110
+ * `prismaJudgmentCache`; leave out anything named the same.
111
+ *
112
+ * Types convert on their own: Decimal columns read as numbers, enum
113
+ * columns as their names, and `tags` may be a `String[]` or a `Json`
114
+ * column. Columns Evalkeeper doesn't know (a creator, a legacy results
115
+ * column) are left alone, so they need a default or to be nullable.
116
+ */
117
+ export type PrismaStoreMap = {
118
+ /**
119
+ * Each table's model on the Prisma client, as the client spells it
120
+ * (`prisma.goldCase` is `"goldCase"`).
121
+ */
122
+ models?: Partial<Record<EvalTable, string>>;
123
+ /**
124
+ * Column names per table, keyed by Evalkeeper's field name. `null`
125
+ * says the table has no such column (for nullable fields only): reads
126
+ * give null, and writing a value fails rather than losing it.
127
+ */
128
+ fields?: {
129
+ /** `labels` is the relation from a case to its answers. */
130
+ evalCase?: ColumnMap<EvalCaseRow & {
131
+ labels: unknown;
132
+ }>;
133
+ evalCaseLabel?: ColumnMap<EvalCaseLabelRow>;
134
+ evalRun?: ColumnMap<EvalRunRow>;
135
+ evalOutput?: ColumnMap<EvalOutputRow>;
136
+ evalJudgment?: ColumnMap<EvalJudgmentRow>;
137
+ };
138
+ };
139
+ /**
140
+ * An EvalStore on your Prisma client, using the models in
141
+ * `schema/evalkeeper.prisma`.
142
+ *
143
+ * @param db - Your Prisma client.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * import { prismaStore } from "@crowandraven/evalkeeper/prisma";
148
+ * const store = prismaStore(prisma);
149
+ * const runner = createRunner({ store, suites, models, promptVersion });
150
+ * ```
151
+ */
152
+ export declare function prismaStore(db: PrismaEvalClient): EvalStore;
153
+ /**
154
+ * An EvalStore on your own eval tables, through a mapping (see
155
+ * `PrismaStoreMap`), for an app that had eval tables before Evalkeeper.
156
+ *
157
+ * @param db - Your Prisma client.
158
+ * @param map - Where your tables differ from Evalkeeper's.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * const store = prismaStore(prisma, {
163
+ * fields: {
164
+ * evalCaseLabel: { note: "rationale" },
165
+ * evalRun: { set: "split", startedBy: "startedById" },
166
+ * },
167
+ * });
168
+ * ```
169
+ */
170
+ export declare function prismaStore(db: object, map: PrismaStoreMap): EvalStore;
171
+ /**
172
+ * A judgment cache on the EvalJudgment table, for
173
+ * `@crowandraven/evalkeeper/ai-sdk`.
174
+ *
175
+ * @param db - Your Prisma client.
176
+ */
177
+ export declare function prismaJudgmentCache(db: PrismaEvalClient): PrismaJudgmentCache;
178
+ /**
179
+ * A judgment cache on your own judgment table, through a mapping.
180
+ *
181
+ * @param db - Your Prisma client.
182
+ * @param map - The mapping you pass `prismaStore`; only `evalJudgment` is
183
+ * used.
184
+ */
185
+ export declare function prismaJudgmentCache(db: object, map: PrismaStoreMap): PrismaJudgmentCache;
186
+ /** Where a judge model's answers are kept, so none is paid for twice. */
187
+ export type PrismaJudgmentCache = {
188
+ get(key: string): Promise<unknown>;
189
+ set(key: string, value: unknown, model: string): Promise<void>;
190
+ };
191
+ /** An EvalFeedback row. */
192
+ export type EvalFeedbackRow = {
193
+ id: string;
194
+ operation: string;
195
+ targetId: string;
196
+ raterId: string;
197
+ rating: string;
198
+ reason: string | null;
199
+ excerpt: string | null;
200
+ input: Json;
201
+ output: Json;
202
+ status: string;
203
+ caseId: string | null;
204
+ createdAt: Date;
205
+ updatedAt: Date;
206
+ };
207
+ /** The part of a generated Prisma client the feedback store uses. */
208
+ export type PrismaFeedbackClient = {
209
+ evalFeedback: Delegate<EvalFeedbackRow> & {
210
+ upsert(args: object): PromiseLike<EvalFeedbackRow>;
211
+ deleteMany(args: object): PromiseLike<{
212
+ count: number;
213
+ }>;
214
+ };
215
+ };
216
+ /** What the rating column holds for a thumbs up and a thumbs down. */
217
+ export type RatingValues = {
218
+ UP: string;
219
+ DOWN: string;
220
+ };
221
+ /**
222
+ * Column names for the feedback table, keyed by Evalkeeper's field. Like
223
+ * `ColumnMap`, and `status` may be `null` too: a table without it reads
224
+ * every rating as OPEN.
225
+ */
226
+ export type FeedbackColumnMap = ColumnMap<Omit<EvalFeedbackRow, "status"> & {
227
+ status: string | null;
228
+ }>;
229
+ /**
230
+ * How Evalkeeper's feedback table maps onto an app's own thumbs table, for
231
+ * an app that recorded thumbs up and down before Evalkeeper. Pass it to
232
+ * `prismaFeedbackStore` (and `deleteScopedRows`); leave out anything
233
+ * named the same.
234
+ *
235
+ * A table without `input` (most thumbs tables never kept inputs) still
236
+ * gives the weekly summary's thumbs-down alerts and the hub's counts,
237
+ * which need only the rating, feature, and time; its ratings can't become
238
+ * cases, and `whyNotACase` says so.
239
+ */
240
+ export type PrismaFeedbackMap = {
241
+ /**
242
+ * The table's model on the Prisma client, as the client spells it
243
+ * (`prisma.aiFeedback` is `"aiFeedback"`).
244
+ */
245
+ models?: {
246
+ evalFeedback?: string;
247
+ };
248
+ /**
249
+ * Column names, keyed by Evalkeeper's field (`raterId: "userId"`).
250
+ * `null` says the table has no such column (`reason`, `excerpt`,
251
+ * `input`, `output`, `status`, or `caseId`): reads give null (a status,
252
+ * OPEN), and writing a value fails rather than losing it.
253
+ */
254
+ fields?: {
255
+ evalFeedback?: FeedbackColumnMap;
256
+ };
257
+ /**
258
+ * What your rating column holds for each, when it isn't UP and DOWN (an
259
+ * enum with other names, say `{ UP: "up", DOWN: "down" }`). A value
260
+ * that's neither reads as a thumbs up.
261
+ */
262
+ ratings?: RatingValues;
263
+ };
264
+ /**
265
+ * A FeedbackStore on the EvalFeedback table.
266
+ *
267
+ * @param db - Your Prisma client.
268
+ */
269
+ export declare function prismaFeedbackStore(db: PrismaFeedbackClient): FeedbackStore;
270
+ /**
271
+ * A FeedbackStore on your own thumbs table, through a map (see
272
+ * `PrismaFeedbackMap`), so the weekly summary's alerts and the hub's
273
+ * counts read the ratings your app already keeps.
274
+ *
275
+ * @param db - Your Prisma client.
276
+ * @param map - Where your table differs from Evalkeeper's.
277
+ *
278
+ * @example
279
+ * An `aiFeedback` table with a `userId` column, a rating enum of UP and
280
+ * DOWN, a reason, an excerpt, and times, that never kept inputs:
281
+ * ```ts
282
+ * const feedbackStore = prismaFeedbackStore(prisma, {
283
+ * models: { evalFeedback: "aiFeedback" },
284
+ * fields: {
285
+ * evalFeedback: {
286
+ * raterId: "userId",
287
+ * input: null,
288
+ * output: null,
289
+ * status: null,
290
+ * caseId: null,
291
+ * },
292
+ * },
293
+ * });
294
+ * ```
295
+ */
296
+ export declare function prismaFeedbackStore(db: object, map: PrismaFeedbackMap): FeedbackStore;
297
+ /** An EvalSettingsVersion row. */
298
+ export type EvalSettingsVersionRow = {
299
+ id: string;
300
+ operation: string;
301
+ number: number;
302
+ model: string;
303
+ fallbackModel: string | null;
304
+ reasoningEffort: string | null;
305
+ maxOutputTokens: number | null;
306
+ temperature: number | null;
307
+ promptVersion: string | null;
308
+ createdAt: Date;
309
+ };
310
+ /** An EvalSettingsLive row. */
311
+ export type EvalSettingsLiveRow = {
312
+ operation: string;
313
+ versionId: string;
314
+ updatedAt: Date;
315
+ };
316
+ /** An EvalSettingsChange row. */
317
+ export type EvalSettingsChangeRow = {
318
+ id: string;
319
+ operation: string;
320
+ kind: string;
321
+ fromVersionId: string | null;
322
+ toVersionId: string;
323
+ reason: string | null;
324
+ by: string | null;
325
+ evidence: Json;
326
+ createdAt: Date;
327
+ };
328
+ /** The settings tables, inside or outside a transaction. */
329
+ export type PrismaSettingsTables = {
330
+ evalSettingsVersion: Delegate<EvalSettingsVersionRow>;
331
+ evalSettingsLive: Delegate<EvalSettingsLiveRow>;
332
+ evalSettingsChange: Delegate<EvalSettingsChangeRow>;
333
+ };
334
+ /** The part of a generated Prisma client the settings store uses. */
335
+ export type PrismaSettingsClient = PrismaSettingsTables & {
336
+ $transaction<T>(fn: (tx: PrismaSettingsTables) => Promise<T>): Promise<T>;
337
+ };
338
+ /** Evalkeeper's settings tables, by the names its schema gives them. */
339
+ export type SettingsTable = "evalSettingsVersion" | "evalSettingsLive" | "evalSettingsChange";
340
+ /**
341
+ * How Evalkeeper's settings tables map onto an app's own versions tables,
342
+ * so Evalkeeper's rollback and history pages read the same history as the
343
+ * app's own model admin page. Leave out anything named the same.
344
+ */
345
+ export type PrismaSettingsMap = {
346
+ /** Each table's model on the Prisma client, as the client spells it. */
347
+ models?: Partial<Record<SettingsTable, string>>;
348
+ /**
349
+ * Column names per table, keyed by Evalkeeper's field name. `null`
350
+ * says the table has no such column (for nullable fields only): reads
351
+ * give null, and saving a version that sets it fails rather than losing
352
+ * the setting.
353
+ */
354
+ fields?: {
355
+ evalSettingsVersion?: ColumnMap<EvalSettingsVersionRow>;
356
+ evalSettingsLive?: ColumnMap<EvalSettingsLiveRow>;
357
+ evalSettingsChange?: ColumnMap<EvalSettingsChangeRow>;
358
+ };
359
+ /**
360
+ * The kinds your change log's kind column can hold, when it's an enum
361
+ * made before some kinds existed (OUTSIDE and INSTRUCTIONS came later).
362
+ * A kind not listed is stored as CHANGE, with the real kind and the
363
+ * evidence kept in the evidence column (as `{ evalkeeperKind, evidence }`),
364
+ * and read back as itself. Leave it out for a text column or an enum
365
+ * with every kind.
366
+ */
367
+ kinds?: readonly ChangeKind[];
368
+ /**
369
+ * For a table that keeps who made a change as something other than
370
+ * the `by` your pages pass (a user id with a foreign key, say). Each is
371
+ * called only for a value that isn't null.
372
+ */
373
+ by?: {
374
+ /** What to store for `by` (e.g. the user id for a name). */
375
+ toColumn(by: string): string | null | Promise<string | null>;
376
+ /** What to show for a stored value (e.g. the name for a user id). */
377
+ fromColumn(stored: string): string | null | Promise<string | null>;
378
+ };
379
+ };
380
+ /** A Prisma client that runs a function in a transaction, as every one does. */
381
+ export type PrismaTransactionClient = {
382
+ $transaction<T>(fn: (tx: object) => Promise<T>): Promise<T>;
383
+ };
384
+ /**
385
+ * A SettingsStore on the EvalSettings tables. Each switch runs in one
386
+ * transaction, and moves the live pointer only if it still points at the
387
+ * version the switch was decided against, so concurrent saves can't
388
+ * silently overwrite each other.
389
+ *
390
+ * @param db - Your Prisma client.
391
+ */
392
+ export declare function prismaSettingsStore(db: PrismaSettingsClient): SettingsStore;
393
+ /**
394
+ * A SettingsStore on your own versions tables, through a mapping (see
395
+ * `PrismaSettingsMap`), so Evalkeeper's pages and your own read the same
396
+ * history.
397
+ *
398
+ * @param db - Your Prisma client.
399
+ * @param map - Where your tables differ from Evalkeeper's.
400
+ *
401
+ * @example
402
+ * Your own versions tables, with a user id for who changed what:
403
+ * ```ts
404
+ * const settingsStore = prismaSettingsStore(prisma, {
405
+ * models: {
406
+ * evalSettingsVersion: "operationVersion",
407
+ * evalSettingsLive: "operationLive",
408
+ * evalSettingsChange: "operationChange",
409
+ * },
410
+ * fields: {
411
+ * evalSettingsVersion: { temperature: null },
412
+ * evalSettingsChange: { by: "userId" },
413
+ * },
414
+ * by: {
415
+ * toColumn: (by) => by, // your pages pass the admin's id
416
+ * fromColumn: async (id) =>
417
+ * (await prisma.user.findUnique({ where: { id } }))?.name ?? null,
418
+ * },
419
+ * });
420
+ * ```
421
+ */
422
+ export declare function prismaSettingsStore(db: PrismaTransactionClient, map: PrismaSettingsMap): SettingsStore;
423
+ export * from "./moveIn.js";