@open-cr-agent/cloud-contract 0.0.0-stage → 0.5.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.
@@ -0,0 +1,499 @@
1
+ import { z } from "zod";
2
+ export declare const cloudModelSchema: z.ZodString;
3
+ /** A failback chain: up to MAX_CHAIN models, or one model on its own. */
4
+ export declare const modelChainSchema: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>;
5
+ export declare const modelChainsSchema: z.ZodPipe<z.ZodObject<{
6
+ top: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
7
+ standard: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
8
+ light: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
9
+ }, z.core.$strip>, z.ZodTransform<{
10
+ top?: string[];
11
+ standard?: string[];
12
+ light?: string[];
13
+ }, {
14
+ top?: string[] | null | undefined;
15
+ standard?: string[] | null | undefined;
16
+ light?: string[] | null | undefined;
17
+ }>>;
18
+ export type ModelChains = z.output<typeof modelChainsSchema>;
19
+ export declare const agentPrefsSchema: z.ZodPipe<z.ZodObject<{
20
+ effort: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
21
+ top: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
22
+ high: "high";
23
+ low: "low";
24
+ medium: "medium";
25
+ minimal: "minimal";
26
+ none: "none";
27
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
28
+ standard: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
29
+ high: "high";
30
+ low: "low";
31
+ medium: "medium";
32
+ minimal: "minimal";
33
+ none: "none";
34
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
35
+ light: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
36
+ high: "high";
37
+ low: "low";
38
+ medium: "medium";
39
+ minimal: "minimal";
40
+ none: "none";
41
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
42
+ }, z.core.$strip>>>, z.ZodTransform<{
43
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
44
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
45
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
46
+ }, {
47
+ top: "high" | "low" | "medium" | "minimal" | "none" | undefined;
48
+ standard: "high" | "low" | "medium" | "minimal" | "none" | undefined;
49
+ light: "high" | "low" | "medium" | "minimal" | "none" | undefined;
50
+ } | null | undefined>>;
51
+ reviewers: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
52
+ enabled: z.ZodOptional<z.ZodBoolean>;
53
+ models: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
54
+ effort: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
55
+ high: "high";
56
+ low: "low";
57
+ medium: "medium";
58
+ minimal: "minimal";
59
+ none: "none";
60
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
61
+ }, z.core.$strip>>>, z.ZodTransform<{
62
+ enabled?: NonNullable<boolean | undefined>;
63
+ models?: string[];
64
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
65
+ }, {
66
+ enabled?: boolean | undefined;
67
+ models?: string[] | null | undefined;
68
+ effort: "high" | "low" | "medium" | "minimal" | "none" | undefined;
69
+ } | null | undefined>>>>>, z.ZodTransform<{
70
+ [x: string]: {
71
+ enabled?: NonNullable<boolean | undefined>;
72
+ models?: string[];
73
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
74
+ } | undefined;
75
+ }, Record<string, {
76
+ enabled?: NonNullable<boolean | undefined>;
77
+ models?: string[];
78
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
79
+ }> | null | undefined>>;
80
+ roles: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodEnum<{
81
+ helper: "helper";
82
+ judge: "judge";
83
+ verifier: "verifier";
84
+ }> & z.core.$partial, z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
85
+ models: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
86
+ effort: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
87
+ high: "high";
88
+ low: "low";
89
+ medium: "medium";
90
+ minimal: "minimal";
91
+ none: "none";
92
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
93
+ }, z.core.$strip>>>, z.ZodTransform<{
94
+ models?: string[];
95
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
96
+ }, {
97
+ models?: string[] | null | undefined;
98
+ effort: "high" | "low" | "medium" | "minimal" | "none" | undefined;
99
+ } | null | undefined>>>>>, z.ZodTransform<{
100
+ helper?: {
101
+ models?: string[];
102
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
103
+ };
104
+ judge?: {
105
+ models?: string[];
106
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
107
+ };
108
+ verifier?: {
109
+ models?: string[];
110
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
111
+ };
112
+ }, Partial<Record<"helper" | "judge" | "verifier", {
113
+ models?: string[];
114
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
115
+ }>> | null | undefined>>;
116
+ }, z.core.$strip>, z.ZodTransform<{
117
+ effort?: {
118
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
119
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
120
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
121
+ };
122
+ reviewers?: {
123
+ [x: string]: {
124
+ enabled?: NonNullable<boolean | undefined>;
125
+ models?: string[];
126
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
127
+ } | undefined;
128
+ };
129
+ roles?: {
130
+ helper?: {
131
+ models?: string[];
132
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
133
+ };
134
+ judge?: {
135
+ models?: string[];
136
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
137
+ };
138
+ verifier?: {
139
+ models?: string[];
140
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
141
+ };
142
+ };
143
+ }, {
144
+ effort: {
145
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
146
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
147
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
148
+ };
149
+ reviewers: {
150
+ [x: string]: {
151
+ enabled?: NonNullable<boolean | undefined>;
152
+ models?: string[];
153
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
154
+ } | undefined;
155
+ };
156
+ roles: {
157
+ helper?: {
158
+ models?: string[];
159
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
160
+ };
161
+ judge?: {
162
+ models?: string[];
163
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
164
+ };
165
+ verifier?: {
166
+ models?: string[];
167
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
168
+ };
169
+ };
170
+ }>>;
171
+ export type AgentPrefs = z.output<typeof agentPrefsSchema>;
172
+ /** The review's data settings an account may hold, with the configuration file's bounds. */
173
+ export declare const reviewSettingsSchema: z.ZodPipe<z.ZodObject<{
174
+ ultra: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
175
+ concurrency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
176
+ taskTimeoutMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
177
+ runTimeoutMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
178
+ maxCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
179
+ maxTasks: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
180
+ verify: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
181
+ judge: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
182
+ sampling: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
183
+ temperature: z.ZodOptional<z.ZodNumber>;
184
+ seed: z.ZodOptional<z.ZodNumber>;
185
+ }, z.core.$strict>>>, z.ZodTransform<{
186
+ temperature?: number;
187
+ seed?: number;
188
+ } | null | undefined, {
189
+ temperature?: number | undefined;
190
+ seed?: number | undefined;
191
+ } | null | undefined>>;
192
+ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
193
+ exclude: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
194
+ rules: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
195
+ path: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
196
+ rule: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
197
+ }, z.core.$strict>>>>;
198
+ plugins: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>, z.ZodTransform<string[] | null | undefined, string[] | null | undefined>>;
199
+ pluginSettings: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
200
+ }, z.core.$strict>, z.ZodTransform<{
201
+ ultra?: NonNullable<boolean | null | undefined>;
202
+ concurrency?: number;
203
+ taskTimeoutMinutes?: number;
204
+ runTimeoutMinutes?: number;
205
+ maxCostUsd?: number;
206
+ maxTasks?: number;
207
+ verify?: NonNullable<boolean | null | undefined>;
208
+ judge?: NonNullable<boolean | null | undefined>;
209
+ sampling?: {
210
+ temperature?: number;
211
+ seed?: number;
212
+ };
213
+ include?: string[];
214
+ exclude?: string[];
215
+ rules?: {
216
+ path: string | string[];
217
+ rule: string;
218
+ }[];
219
+ plugins?: string[];
220
+ pluginSettings?: Record<string, unknown>;
221
+ }, {
222
+ ultra?: boolean | null | undefined;
223
+ concurrency?: number | null | undefined;
224
+ taskTimeoutMinutes?: number | null | undefined;
225
+ runTimeoutMinutes?: number | null | undefined;
226
+ maxCostUsd?: number | null | undefined;
227
+ maxTasks?: number | null | undefined;
228
+ verify?: boolean | null | undefined;
229
+ judge?: boolean | null | undefined;
230
+ sampling: {
231
+ temperature?: number;
232
+ seed?: number;
233
+ } | null | undefined;
234
+ include?: string[] | null | undefined;
235
+ exclude?: string[] | null | undefined;
236
+ rules?: {
237
+ path: string | string[];
238
+ rule: string;
239
+ }[] | null | undefined;
240
+ plugins: string[] | null | undefined;
241
+ pluginSettings?: Record<string, unknown> | null | undefined;
242
+ }>>;
243
+ export type ReviewSettings = z.output<typeof reviewSettingsSchema>;
244
+ /**
245
+ * PUT /api/preferences. A part the body leaves out keeps its saved value;
246
+ * null clears it. `baseVersion` is the version the web's draft started
247
+ * from: a save from a stale tab answers `stale`. A body without it (the
248
+ * CLI) saves.
249
+ */
250
+ export declare const preferencesUpdateSchema: z.ZodObject<{
251
+ runtime: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
252
+ direct: "direct";
253
+ opencode: "opencode";
254
+ }>>>;
255
+ models: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
256
+ top: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
257
+ standard: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
258
+ light: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
259
+ }, z.core.$strip>, z.ZodTransform<{
260
+ top?: string[];
261
+ standard?: string[];
262
+ light?: string[];
263
+ }, {
264
+ top?: string[] | null | undefined;
265
+ standard?: string[] | null | undefined;
266
+ light?: string[] | null | undefined;
267
+ }>>>>;
268
+ agents: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
269
+ effort: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
270
+ top: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
271
+ high: "high";
272
+ low: "low";
273
+ medium: "medium";
274
+ minimal: "minimal";
275
+ none: "none";
276
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
277
+ standard: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
278
+ high: "high";
279
+ low: "low";
280
+ medium: "medium";
281
+ minimal: "minimal";
282
+ none: "none";
283
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
284
+ light: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
285
+ high: "high";
286
+ low: "low";
287
+ medium: "medium";
288
+ minimal: "minimal";
289
+ none: "none";
290
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
291
+ }, z.core.$strip>>>, z.ZodTransform<{
292
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
293
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
294
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
295
+ }, {
296
+ top: "high" | "low" | "medium" | "minimal" | "none" | undefined;
297
+ standard: "high" | "low" | "medium" | "minimal" | "none" | undefined;
298
+ light: "high" | "low" | "medium" | "minimal" | "none" | undefined;
299
+ } | null | undefined>>;
300
+ reviewers: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
301
+ enabled: z.ZodOptional<z.ZodBoolean>;
302
+ models: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
303
+ effort: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
304
+ high: "high";
305
+ low: "low";
306
+ medium: "medium";
307
+ minimal: "minimal";
308
+ none: "none";
309
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
310
+ }, z.core.$strip>>>, z.ZodTransform<{
311
+ enabled?: NonNullable<boolean | undefined>;
312
+ models?: string[];
313
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
314
+ }, {
315
+ enabled?: boolean | undefined;
316
+ models?: string[] | null | undefined;
317
+ effort: "high" | "low" | "medium" | "minimal" | "none" | undefined;
318
+ } | null | undefined>>>>>, z.ZodTransform<{
319
+ [x: string]: {
320
+ enabled?: NonNullable<boolean | undefined>;
321
+ models?: string[];
322
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
323
+ } | undefined;
324
+ }, Record<string, {
325
+ enabled?: NonNullable<boolean | undefined>;
326
+ models?: string[];
327
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
328
+ }> | null | undefined>>;
329
+ roles: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodEnum<{
330
+ helper: "helper";
331
+ judge: "judge";
332
+ verifier: "verifier";
333
+ }> & z.core.$partial, z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
334
+ models: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>>;
335
+ effort: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
336
+ high: "high";
337
+ low: "low";
338
+ medium: "medium";
339
+ minimal: "minimal";
340
+ none: "none";
341
+ }>, z.ZodLiteral<"">, z.ZodNull]>>, z.ZodTransform<"high" | "low" | "medium" | "minimal" | "none" | undefined, "" | "high" | "low" | "medium" | "minimal" | "none" | null | undefined>>;
342
+ }, z.core.$strip>>>, z.ZodTransform<{
343
+ models?: string[];
344
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
345
+ }, {
346
+ models?: string[] | null | undefined;
347
+ effort: "high" | "low" | "medium" | "minimal" | "none" | undefined;
348
+ } | null | undefined>>>>>, z.ZodTransform<{
349
+ helper?: {
350
+ models?: string[];
351
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
352
+ };
353
+ judge?: {
354
+ models?: string[];
355
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
356
+ };
357
+ verifier?: {
358
+ models?: string[];
359
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
360
+ };
361
+ }, Partial<Record<"helper" | "judge" | "verifier", {
362
+ models?: string[];
363
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
364
+ }>> | null | undefined>>;
365
+ }, z.core.$strip>, z.ZodTransform<{
366
+ effort?: {
367
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
368
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
369
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
370
+ };
371
+ reviewers?: {
372
+ [x: string]: {
373
+ enabled?: NonNullable<boolean | undefined>;
374
+ models?: string[];
375
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
376
+ } | undefined;
377
+ };
378
+ roles?: {
379
+ helper?: {
380
+ models?: string[];
381
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
382
+ };
383
+ judge?: {
384
+ models?: string[];
385
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
386
+ };
387
+ verifier?: {
388
+ models?: string[];
389
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
390
+ };
391
+ };
392
+ }, {
393
+ effort: {
394
+ top?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
395
+ standard?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
396
+ light?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
397
+ };
398
+ reviewers: {
399
+ [x: string]: {
400
+ enabled?: NonNullable<boolean | undefined>;
401
+ models?: string[];
402
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
403
+ } | undefined;
404
+ };
405
+ roles: {
406
+ helper?: {
407
+ models?: string[];
408
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
409
+ };
410
+ judge?: {
411
+ models?: string[];
412
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
413
+ };
414
+ verifier?: {
415
+ models?: string[];
416
+ effort?: NonNullable<"high" | "low" | "medium" | "minimal" | "none" | undefined>;
417
+ };
418
+ };
419
+ }>>>>;
420
+ settings: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
421
+ ultra: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
422
+ concurrency: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
423
+ taskTimeoutMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
424
+ runTimeoutMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
425
+ maxCostUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
426
+ maxTasks: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
427
+ verify: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
428
+ judge: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
429
+ sampling: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodObject<{
430
+ temperature: z.ZodOptional<z.ZodNumber>;
431
+ seed: z.ZodOptional<z.ZodNumber>;
432
+ }, z.core.$strict>>>, z.ZodTransform<{
433
+ temperature?: number;
434
+ seed?: number;
435
+ } | null | undefined, {
436
+ temperature?: number | undefined;
437
+ seed?: number | undefined;
438
+ } | null | undefined>>;
439
+ include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
440
+ exclude: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
441
+ rules: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
442
+ path: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
443
+ rule: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
444
+ }, z.core.$strict>>>>;
445
+ plugins: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>, z.ZodTransform<string[] | null | undefined, string[] | null | undefined>>;
446
+ pluginSettings: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
447
+ }, z.core.$strict>, z.ZodTransform<{
448
+ ultra?: NonNullable<boolean | null | undefined>;
449
+ concurrency?: number;
450
+ taskTimeoutMinutes?: number;
451
+ runTimeoutMinutes?: number;
452
+ maxCostUsd?: number;
453
+ maxTasks?: number;
454
+ verify?: NonNullable<boolean | null | undefined>;
455
+ judge?: NonNullable<boolean | null | undefined>;
456
+ sampling?: {
457
+ temperature?: number;
458
+ seed?: number;
459
+ };
460
+ include?: string[];
461
+ exclude?: string[];
462
+ rules?: {
463
+ path: string | string[];
464
+ rule: string;
465
+ }[];
466
+ plugins?: string[];
467
+ pluginSettings?: Record<string, unknown>;
468
+ }, {
469
+ ultra?: boolean | null | undefined;
470
+ concurrency?: number | null | undefined;
471
+ taskTimeoutMinutes?: number | null | undefined;
472
+ runTimeoutMinutes?: number | null | undefined;
473
+ maxCostUsd?: number | null | undefined;
474
+ maxTasks?: number | null | undefined;
475
+ verify?: boolean | null | undefined;
476
+ judge?: boolean | null | undefined;
477
+ sampling: {
478
+ temperature?: number;
479
+ seed?: number;
480
+ } | null | undefined;
481
+ include?: string[] | null | undefined;
482
+ exclude?: string[] | null | undefined;
483
+ rules?: {
484
+ path: string | string[];
485
+ rule: string;
486
+ }[] | null | undefined;
487
+ plugins: string[] | null | undefined;
488
+ pluginSettings?: Record<string, unknown> | null | undefined;
489
+ }>>>>;
490
+ baseVersion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
491
+ }, z.core.$strip>;
492
+ export type PreferencesUpdate = z.input<typeof preferencesUpdateSchema>;
493
+ /**
494
+ * GET /api/preferences: `runtime`, `models`, `agents`, `settings`,
495
+ * `updatedAt` and `version` (null before the first save). A client reads
496
+ * it key by key, so a key it does not know never breaks it.
497
+ */
498
+ export declare const preferencesAnswerSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
499
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1,151 @@
1
+ import { z } from "zod";
2
+ import { MAX_CHAIN } from "./limits.js";
3
+ import { CLOUD_PREFIX, isCloudModel } from "./providers.js";
4
+ import { AGENT_ROLES, agentRoleSchema, effortSchema, REVIEWER_ID, runtimeSchema, } from "./vocabulary.js";
5
+ // The account's settings (ADR-0025, ADR-0027): what the web saves with
6
+ // PUT /api/preferences and a CLI layers under a repository's
7
+ // configuration. Never providers, extends or botLogin: those can move code
8
+ // or keys, and only a configuration file may set them.
9
+ //
10
+ // A value of null, "" or [] sets nothing. ocra Cloud also refuses a model
11
+ // whose provider has no OpenAI-compatible chat route, which it alone knows.
12
+ // Drops the keys that set nothing.
13
+ function present(value) {
14
+ return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined &&
15
+ v !== null &&
16
+ !(Array.isArray(v) && v.length === 0) &&
17
+ !(typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0)));
18
+ }
19
+ // null or absent sets nothing, typed as the object it stands for.
20
+ function presentOrNone(value) {
21
+ return present(value ?? {});
22
+ }
23
+ export const cloudModelSchema = z
24
+ .string()
25
+ .refine(isCloudModel, `a model is ${CLOUD_PREFIX}<provider>/<model>`);
26
+ /** A failback chain: up to MAX_CHAIN models, or one model on its own. */
27
+ export const modelChainSchema = z
28
+ .union([z.array(z.string()), z.string()])
29
+ .transform((v) => (Array.isArray(v) ? v : [v]).filter((m) => m !== ""))
30
+ .pipe(z.array(cloudModelSchema).max(MAX_CHAIN));
31
+ const chain = modelChainSchema.nullish();
32
+ const effort = z
33
+ .union([effortSchema, z.literal(""), z.null()])
34
+ .optional()
35
+ .transform((v) => v || undefined);
36
+ export const modelChainsSchema = z
37
+ .object({ top: chain, standard: chain, light: chain })
38
+ .transform(present);
39
+ const reviewerSchema = z
40
+ .object({ enabled: z.boolean().optional(), models: chain, effort })
41
+ .nullish()
42
+ .transform((v) => presentOrNone(v));
43
+ const roleSchema = z
44
+ .object({ models: chain, effort })
45
+ .nullish()
46
+ .transform((v) => presentOrNone(v));
47
+ export const agentPrefsSchema = z
48
+ .object({
49
+ effort: z
50
+ .object({ top: effort, standard: effort, light: effort })
51
+ .nullish()
52
+ .transform((v) => presentOrNone(v)),
53
+ reviewers: z
54
+ .record(z
55
+ .string()
56
+ .regex(REVIEWER_ID)
57
+ .refine((id) => !AGENT_ROLES.includes(id), "a role, not a reviewer"), reviewerSchema)
58
+ .refine((r) => Object.keys(r).length <= 30, "at most 30 reviewers")
59
+ .nullish()
60
+ .transform((v) => presentOrNone(v)),
61
+ roles: z
62
+ .partialRecord(agentRoleSchema, roleSchema)
63
+ .nullish()
64
+ .transform((v) => presentOrNone(v)),
65
+ })
66
+ .transform(present);
67
+ const GLOB = /^[^\n\r\0]{1,300}$/;
68
+ // An npm package name, scoped or not; versions are pinned on each machine.
69
+ const PACKAGE = /^(@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/;
70
+ const MAX_PLUGIN_SETTINGS_JSON = 16_384;
71
+ const globs = z.array(z.string().regex(GLOB)).max(100);
72
+ const minutes = z.number().gt(0).max(600);
73
+ const ruleSchema = z.strictObject({
74
+ path: z.union([z.string().regex(GLOB), z.array(z.string().regex(GLOB)).min(1).max(20)]),
75
+ rule: z
76
+ .string()
77
+ .max(2_000)
78
+ .transform((r) => r.trim())
79
+ .pipe(z.string().min(1)),
80
+ });
81
+ /** The review's data settings an account may hold, with the configuration file's bounds. */
82
+ export const reviewSettingsSchema = z
83
+ .strictObject({
84
+ ultra: z.boolean().nullish(),
85
+ concurrency: z.number().int().min(1).max(32).nullish(),
86
+ taskTimeoutMinutes: minutes.nullish(),
87
+ runTimeoutMinutes: minutes.nullish(),
88
+ maxCostUsd: z.number().gt(0).max(1000).nullish(),
89
+ maxTasks: z.number().int().min(1).max(1000).nullish(),
90
+ verify: z.boolean().nullish(),
91
+ judge: z.boolean().nullish(),
92
+ sampling: z
93
+ .strictObject({
94
+ temperature: z.number().min(0).max(2).optional(),
95
+ seed: z
96
+ .number()
97
+ .int()
98
+ .min(0)
99
+ .max(2 ** 31 - 1)
100
+ .optional(),
101
+ })
102
+ .nullish()
103
+ .transform((v) => (v ? present(v) : v)),
104
+ include: globs.nullish(),
105
+ exclude: globs.nullish(),
106
+ rules: z.array(ruleSchema).max(50).nullish(),
107
+ plugins: z
108
+ .array(z.string().max(214).regex(PACKAGE))
109
+ .max(20)
110
+ .nullish()
111
+ .transform((v) => (v ? [...new Set(v)] : v)),
112
+ // Only for plugins the account lists (ADR-0027); a repository plugin's
113
+ // settings come from the repository alone.
114
+ pluginSettings: z
115
+ .record(z.string(), z.unknown())
116
+ .refine((s) => JSON.stringify(s).length <= MAX_PLUGIN_SETTINGS_JSON, `at most ${MAX_PLUGIN_SETTINGS_JSON} characters of JSON`)
117
+ .nullish(),
118
+ })
119
+ .superRefine((s, ctx) => {
120
+ const listed = new Set(s.plugins ?? []);
121
+ for (const name of Object.keys(s.pluginSettings ?? {})) {
122
+ if (!listed.has(name)) {
123
+ ctx.addIssue({
124
+ code: "custom",
125
+ path: ["pluginSettings", name],
126
+ message: "settings for a plugin the account does not list",
127
+ });
128
+ }
129
+ }
130
+ })
131
+ .transform(present);
132
+ /**
133
+ * PUT /api/preferences. A part the body leaves out keeps its saved value;
134
+ * null clears it. `baseVersion` is the version the web's draft started
135
+ * from: a save from a stale tab answers `stale`. A body without it (the
136
+ * CLI) saves.
137
+ */
138
+ export const preferencesUpdateSchema = z.object({
139
+ runtime: runtimeSchema.nullish(),
140
+ models: modelChainsSchema.nullish(),
141
+ agents: agentPrefsSchema.nullish(),
142
+ settings: reviewSettingsSchema.nullish(),
143
+ baseVersion: z.string().nullish(),
144
+ });
145
+ /**
146
+ * GET /api/preferences: `runtime`, `models`, `agents`, `settings`,
147
+ * `updatedAt` and `version` (null before the first save). A client reads
148
+ * it key by key, so a key it does not know never breaks it.
149
+ */
150
+ export const preferencesAnswerSchema = z.record(z.string(), z.unknown());
151
+ //# sourceMappingURL=preferences.js.map