@vercel/factory 0.0.3 → 0.0.4

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 (70) hide show
  1. package/dist/approval-h5aj8HYN.d.mts +510 -0
  2. package/dist/blob/index.d.mts +32 -0
  3. package/dist/blob/index.mjs +141 -0
  4. package/dist/blob/index.mjs.map +1 -0
  5. package/dist/connectors/index.d.mts +2 -0
  6. package/dist/connectors/index.mjs +49 -0
  7. package/dist/connectors/index.mjs.map +1 -0
  8. package/dist/driver-Bbd25rNM.mjs +23 -0
  9. package/dist/driver-Bbd25rNM.mjs.map +1 -0
  10. package/dist/driver-CrZsy7sm.d.mts +34 -0
  11. package/dist/eve/index.d.mts +1057 -0
  12. package/dist/eve/index.mjs +777 -0
  13. package/dist/eve/index.mjs.map +1 -0
  14. package/dist/github-5qQPCaXj.d.mts +123 -0
  15. package/dist/github.d.mts +2 -0
  16. package/dist/github.mjs +286 -0
  17. package/dist/github.mjs.map +1 -0
  18. package/dist/id-DwCihQr4.mjs +31 -0
  19. package/dist/id-DwCihQr4.mjs.map +1 -0
  20. package/dist/index-WNGZJRRH.d.mts +67 -0
  21. package/dist/index.d.mts +175 -0
  22. package/dist/index.mjs +882 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/next-page.d.mts +5 -0
  25. package/dist/next-page.mjs +71 -0
  26. package/dist/next-page.mjs.map +1 -0
  27. package/dist/next.d.mts +12 -0
  28. package/dist/{next.js → next.mjs} +13 -14
  29. package/dist/next.mjs.map +1 -0
  30. package/dist/postgres/index.d.mts +137 -0
  31. package/dist/postgres/index.mjs +96 -0
  32. package/dist/postgres/index.mjs.map +1 -0
  33. package/dist/signal-CHVEmzvI.d.mts +59 -0
  34. package/dist/task-Cj7Ei9Nh.mjs +336 -0
  35. package/dist/task-Cj7Ei9Nh.mjs.map +1 -0
  36. package/package.json +25 -22
  37. package/dist/approval-Z7iaWibT.d.ts +0 -541
  38. package/dist/blob/index.d.ts +0 -26
  39. package/dist/blob/index.js +0 -127
  40. package/dist/blob/index.js.map +0 -1
  41. package/dist/chunk-2JFES6BA.js +0 -41
  42. package/dist/chunk-2JFES6BA.js.map +0 -1
  43. package/dist/chunk-CEF6VJZC.js +0 -28
  44. package/dist/chunk-CEF6VJZC.js.map +0 -1
  45. package/dist/chunk-D2XMABG4.js +0 -311
  46. package/dist/chunk-D2XMABG4.js.map +0 -1
  47. package/dist/chunk-EFL4PDDE.js +0 -325
  48. package/dist/chunk-EFL4PDDE.js.map +0 -1
  49. package/dist/common-CaHaEOAS.d.ts +0 -18
  50. package/dist/connectors/index.d.ts +0 -53
  51. package/dist/connectors/index.js +0 -64
  52. package/dist/connectors/index.js.map +0 -1
  53. package/dist/driver-tRNggCCJ.d.ts +0 -32
  54. package/dist/eve/index.d.ts +0 -1053
  55. package/dist/eve/index.js +0 -752
  56. package/dist/eve/index.js.map +0 -1
  57. package/dist/github.d.ts +0 -139
  58. package/dist/github.js +0 -27
  59. package/dist/github.js.map +0 -1
  60. package/dist/index.d.ts +0 -164
  61. package/dist/index.js +0 -940
  62. package/dist/index.js.map +0 -1
  63. package/dist/next-page.d.ts +0 -5
  64. package/dist/next-page.js +0 -75
  65. package/dist/next-page.js.map +0 -1
  66. package/dist/next.d.ts +0 -12
  67. package/dist/next.js.map +0 -1
  68. package/dist/postgres/index.d.ts +0 -137
  69. package/dist/postgres/index.js +0 -118
  70. package/dist/postgres/index.js.map +0 -1
@@ -0,0 +1,510 @@
1
+ import { i as StoreDriver } from "./driver-CrZsy7sm.mjs";
2
+ import { c as ReplyTo, n as SignalOutcome, r as SignalSource, t as Signal } from "./signal-CHVEmzvI.mjs";
3
+ import { z } from "zod";
4
+ //#region src/schema/id.d.ts
5
+ declare const factoryIdSchema: z.ZodString;
6
+ declare const repositoryIdSchema: z.ZodString;
7
+ declare const signalIdSchema: z.ZodString;
8
+ declare const taskIdSchema: z.ZodString;
9
+ declare const changeIdSchema: z.ZodString;
10
+ declare const receiptIdSchema: z.ZodString;
11
+ declare const repositoryIdsSchema: z.ZodArray<z.ZodString>;
12
+ type FactoryId = z.infer<typeof factoryIdSchema>;
13
+ type RepositoryId = z.infer<typeof repositoryIdSchema>;
14
+ type SignalId = z.infer<typeof signalIdSchema>;
15
+ type TaskId = z.infer<typeof taskIdSchema>;
16
+ type ChangeId = z.infer<typeof changeIdSchema>;
17
+ type ReceiptId = z.infer<typeof receiptIdSchema>;
18
+ //#endregion
19
+ //#region src/schema/change.d.ts
20
+ declare const levelSchema: z.ZodEnum<{
21
+ low: "low";
22
+ medium: "medium";
23
+ high: "high";
24
+ }>;
25
+ declare const changeStateSchema: z.ZodEnum<{
26
+ verifying: "verifying";
27
+ ready: "ready";
28
+ merged: "merged";
29
+ deployed: "deployed";
30
+ rolled_out: "rolled_out";
31
+ rolled_back: "rolled_back";
32
+ closed: "closed";
33
+ }>;
34
+ declare const changeEvidenceSchema: z.ZodObject<{
35
+ reproVerified: z.ZodBoolean;
36
+ testsAdded: z.ZodNumber;
37
+ checksGreen: z.ZodBoolean;
38
+ attackPassed: z.ZodBoolean;
39
+ scopeMatches: z.ZodBoolean;
40
+ previewUrl: z.ZodOptional<z.ZodURL>;
41
+ }, z.core.$strict>;
42
+ declare const changeSchema: z.ZodObject<{
43
+ schemaVersion: z.ZodLiteral<1>;
44
+ id: z.ZodString;
45
+ repositoryId: z.ZodString;
46
+ taskId: z.ZodOptional<z.ZodString>;
47
+ groupId: z.ZodOptional<z.ZodString>;
48
+ prNumber: z.ZodNumber;
49
+ prUrl: z.ZodURL;
50
+ author: z.ZodString;
51
+ risk: z.ZodEnum<{
52
+ low: "low";
53
+ medium: "medium";
54
+ high: "high";
55
+ }>;
56
+ confidence: z.ZodEnum<{
57
+ low: "low";
58
+ medium: "medium";
59
+ high: "high";
60
+ }>;
61
+ evidence: z.ZodObject<{
62
+ reproVerified: z.ZodBoolean;
63
+ testsAdded: z.ZodNumber;
64
+ checksGreen: z.ZodBoolean;
65
+ attackPassed: z.ZodBoolean;
66
+ scopeMatches: z.ZodBoolean;
67
+ previewUrl: z.ZodOptional<z.ZodURL>;
68
+ }, z.core.$strict>;
69
+ state: z.ZodEnum<{
70
+ verifying: "verifying";
71
+ ready: "ready";
72
+ merged: "merged";
73
+ deployed: "deployed";
74
+ rolled_out: "rolled_out";
75
+ rolled_back: "rolled_back";
76
+ closed: "closed";
77
+ }>;
78
+ decidedBy: z.ZodOptional<z.ZodString>;
79
+ createdAt: z.ZodISODateTime;
80
+ updatedAt: z.ZodISODateTime;
81
+ }, z.core.$strict>;
82
+ type Level = z.infer<typeof levelSchema>;
83
+ type ChangeState = z.infer<typeof changeStateSchema>;
84
+ type ChangeEvidence = z.infer<typeof changeEvidenceSchema>;
85
+ type Change = z.infer<typeof changeSchema>;
86
+ //#endregion
87
+ //#region src/schema/receipt.d.ts
88
+ /** States the engine writes on transitions. Any vocabulary value is valid. */
89
+ declare const standardReceiptStates: readonly ["approved", "rejected", "dispatched", "succeeded", "failed", "needs_human", "cancelled", "settled", "merged", "deployed", "rolled_out", "rolled_back"];
90
+ /** Phases the standard loop uses. Any vocabulary value is valid. */
91
+ declare const standardReceiptPhases: readonly ["approval", "budget", "dispatch", "implementation", "verification", "pull_request", "cleanup"];
92
+ /** Kinds the standard loop writes: the standard task kinds plus "change". */
93
+ declare const standardReceiptKinds: readonly ["code_change", "verification", "investigation", "question", "change"];
94
+ declare const receiptStateSchema: z.ZodString;
95
+ declare const receiptPhaseSchema: z.ZodString;
96
+ declare const receiptKindSchema: z.ZodString;
97
+ declare const costSchema: z.ZodObject<{
98
+ totalUsd: z.ZodNumber;
99
+ }, z.core.$strict>;
100
+ declare const receiptSchema: z.ZodObject<{
101
+ schemaVersion: z.ZodLiteral<1>;
102
+ receiptId: z.ZodString;
103
+ repositoryIds: z.ZodArray<z.ZodString>;
104
+ taskId: z.ZodOptional<z.ZodString>;
105
+ changeId: z.ZodOptional<z.ZodString>;
106
+ kind: z.ZodString;
107
+ state: z.ZodString;
108
+ phase: z.ZodOptional<z.ZodString>;
109
+ reason: z.ZodOptional<z.ZodString>;
110
+ attempt: z.ZodNumber;
111
+ cost: z.ZodOptional<z.ZodObject<{
112
+ totalUsd: z.ZodNumber;
113
+ }, z.core.$strict>>;
114
+ decidedBy: z.ZodOptional<z.ZodString>;
115
+ recordedAt: z.ZodISODateTime;
116
+ }, z.core.$strict>;
117
+ type ReceiptState = z.infer<typeof receiptStateSchema>;
118
+ type ReceiptPhase = z.infer<typeof receiptPhaseSchema>;
119
+ type ReceiptKind = z.infer<typeof receiptKindSchema>;
120
+ type Cost = z.infer<typeof costSchema>;
121
+ type Receipt = z.infer<typeof receiptSchema>;
122
+ //#endregion
123
+ //#region src/schema/repository.d.ts
124
+ declare const repositorySlugSchema: z.ZodString;
125
+ declare const repositorySchema: z.ZodObject<{
126
+ schemaVersion: z.ZodLiteral<1>;
127
+ id: z.ZodString;
128
+ slug: z.ZodString;
129
+ defaultBranch: z.ZodString;
130
+ enabled: z.ZodBoolean;
131
+ dependsOn: z.ZodArray<z.ZodString>;
132
+ devbox: z.ZodOptional<z.ZodObject<{
133
+ projectId: z.ZodString;
134
+ teamId: z.ZodString;
135
+ snapshot: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strict>>;
137
+ connectedAt: z.ZodISODateTime;
138
+ }, z.core.$strict>;
139
+ type RepositorySlug = z.infer<typeof repositorySlugSchema>;
140
+ type Repository = z.infer<typeof repositorySchema>;
141
+ //#endregion
142
+ //#region src/schema/task.d.ts
143
+ /**
144
+ * Kinds the standard loop understands. Any vocabulary value is valid; the
145
+ * kind-scoped rules below apply only to these standard kinds.
146
+ */
147
+ declare const standardTaskKinds: readonly ["code_change", "verification", "investigation", "question"];
148
+ declare const taskKindSchema: z.ZodString;
149
+ declare const taskStateSchema: z.ZodEnum<{
150
+ queued: "queued";
151
+ running: "running";
152
+ verifying: "verifying";
153
+ succeeded: "succeeded";
154
+ failed: "failed";
155
+ needs_human: "needs_human";
156
+ cancelled: "cancelled";
157
+ }>;
158
+ declare const taskApprovalSchema: z.ZodEnum<{
159
+ required: "required";
160
+ granted: "granted";
161
+ denied: "denied";
162
+ }>;
163
+ declare const harnessSchema: z.ZodString;
164
+ declare const taskOriginSchema: z.ZodObject<{
165
+ signalId: z.ZodOptional<z.ZodString>;
166
+ parentTaskId: z.ZodOptional<z.ZodString>;
167
+ operator: z.ZodOptional<z.ZodString>;
168
+ }, z.core.$strict>;
169
+ declare const taskDevboxSchema: z.ZodObject<{
170
+ devboxId: z.ZodString;
171
+ remoteId: z.ZodString;
172
+ harness: z.ZodString;
173
+ }, z.core.$strict>;
174
+ declare const taskQuestionSchema: z.ZodObject<{
175
+ text: z.ZodString;
176
+ options: z.ZodArray<z.ZodString>;
177
+ answer: z.ZodOptional<z.ZodString>;
178
+ answeredBy: z.ZodOptional<z.ZodString>;
179
+ }, z.core.$strict>;
180
+ declare const taskSchema: z.ZodObject<{
181
+ schemaVersion: z.ZodLiteral<1>;
182
+ id: z.ZodString;
183
+ repositoryIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
184
+ kind: z.ZodString;
185
+ area: z.ZodOptional<z.ZodString>;
186
+ state: z.ZodEnum<{
187
+ queued: "queued";
188
+ running: "running";
189
+ verifying: "verifying";
190
+ succeeded: "succeeded";
191
+ failed: "failed";
192
+ needs_human: "needs_human";
193
+ cancelled: "cancelled";
194
+ }>;
195
+ approval: z.ZodOptional<z.ZodEnum<{
196
+ required: "required";
197
+ granted: "granted";
198
+ denied: "denied";
199
+ }>>;
200
+ origin: z.ZodObject<{
201
+ signalId: z.ZodOptional<z.ZodString>;
202
+ parentTaskId: z.ZodOptional<z.ZodString>;
203
+ operator: z.ZodOptional<z.ZodString>;
204
+ }, z.core.$strict>;
205
+ dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
206
+ replyTo: z.ZodObject<{
207
+ channel: z.ZodString;
208
+ address: z.ZodString;
209
+ }, z.core.$strict>;
210
+ devbox: z.ZodOptional<z.ZodObject<{
211
+ devboxId: z.ZodString;
212
+ remoteId: z.ZodString;
213
+ harness: z.ZodString;
214
+ }, z.core.$strict>>;
215
+ attempt: z.ZodNumber;
216
+ reservedUsd: z.ZodOptional<z.ZodNumber>;
217
+ settledUsd: z.ZodOptional<z.ZodNumber>;
218
+ question: z.ZodOptional<z.ZodObject<{
219
+ text: z.ZodString;
220
+ options: z.ZodArray<z.ZodString>;
221
+ answer: z.ZodOptional<z.ZodString>;
222
+ answeredBy: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$strict>>;
224
+ changeId: z.ZodOptional<z.ZodString>;
225
+ reportRef: z.ZodOptional<z.ZodString>;
226
+ createdAt: z.ZodISODateTime;
227
+ updatedAt: z.ZodISODateTime;
228
+ }, z.core.$strict>;
229
+ type TaskApproval = z.infer<typeof taskApprovalSchema>;
230
+ type TaskKind = z.infer<typeof taskKindSchema>;
231
+ type TaskState = z.infer<typeof taskStateSchema>;
232
+ type Task = z.infer<typeof taskSchema>;
233
+ //#endregion
234
+ //#region src/store/engine.d.ts
235
+ /** An approval decision that does not apply to the task's current approval or state. */
236
+ declare class ApprovalError extends Error {
237
+ readonly taskId: TaskId;
238
+ readonly reason: string;
239
+ constructor(taskId: TaskId, reason: string);
240
+ }
241
+ interface CreateSignalInput {
242
+ repositoryId: RepositoryId;
243
+ source: SignalSource;
244
+ deliveryId: string;
245
+ replyTo: ReplyTo;
246
+ payload: unknown;
247
+ }
248
+ interface DecideSignalOptions {
249
+ detail?: string;
250
+ reason?: string;
251
+ }
252
+ interface CreateTaskInput {
253
+ repositoryIds: RepositoryId[];
254
+ kind: Task["kind"];
255
+ origin: Task["origin"];
256
+ replyTo: ReplyTo;
257
+ area?: string;
258
+ dependsOn?: TaskId[];
259
+ question?: Task["question"];
260
+ /** Stamp the task as needing a human decision before dispatch. */
261
+ approval?: "required";
262
+ }
263
+ interface ApprovalDecision {
264
+ /** Authenticated operator making the decision. */
265
+ by: string;
266
+ reason?: string;
267
+ }
268
+ type TaskPatch = Partial<Pick<Task, "devbox" | "changeId" | "reportRef" | "reservedUsd" | "settledUsd" | "question">>;
269
+ interface TaskTransitionOptions {
270
+ patch?: TaskPatch;
271
+ reason?: string;
272
+ }
273
+ interface CreateChangeInput {
274
+ repositoryId: RepositoryId;
275
+ taskId?: TaskId;
276
+ groupId?: TaskId;
277
+ prNumber: number;
278
+ prUrl: string;
279
+ author: string;
280
+ risk: Level;
281
+ confidence: Level;
282
+ evidence: Change["evidence"];
283
+ }
284
+ type ChangePatch = Partial<Pick<Change, "confidence" | "evidence" | "decidedBy">>;
285
+ interface ChangeTransitionOptions {
286
+ patch?: ChangePatch;
287
+ reason?: string;
288
+ }
289
+ interface AppendReceiptInput {
290
+ repositoryIds: RepositoryId[];
291
+ taskId?: TaskId;
292
+ changeId?: ChangeId;
293
+ kind: string;
294
+ state: string;
295
+ phase?: string;
296
+ reason?: string;
297
+ attempt?: number;
298
+ cost?: Cost;
299
+ decidedBy?: string;
300
+ /** Same key twice appends one receipt and returns the existing one. */
301
+ dedupeKey?: string;
302
+ }
303
+ interface FactoryStores {
304
+ driverName: string;
305
+ repositories: {
306
+ put(repository: Repository): Promise<Repository>;
307
+ get(id: RepositoryId): Promise<Repository | null>;
308
+ list(): Promise<Repository[]>;
309
+ };
310
+ signals: {
311
+ create(input: CreateSignalInput): Promise<Signal>;
312
+ get(id: SignalId): Promise<Signal | null>;
313
+ decide(id: SignalId, outcome: SignalOutcome, options?: DecideSignalOptions): Promise<Signal>;
314
+ list(): Promise<Signal[]>;
315
+ };
316
+ tasks: {
317
+ create(input: CreateTaskInput): Promise<Task>;
318
+ get(id: TaskId): Promise<Task | null>;
319
+ transition(id: TaskId, to: TaskState, options?: TaskTransitionOptions): Promise<Task>;
320
+ /** Grant a required approval. The task stays queued; dispatch may now take it. */
321
+ approve(id: TaskId, decision: ApprovalDecision): Promise<Task>;
322
+ /** Deny a required approval. The task is cancelled with the reason. */
323
+ reject(id: TaskId, decision: ApprovalDecision): Promise<Task>;
324
+ list(): Promise<Task[]>;
325
+ };
326
+ changes: {
327
+ create(input: CreateChangeInput): Promise<Change>;
328
+ get(id: ChangeId): Promise<Change | null>;
329
+ transition(id: ChangeId, to: ChangeState, options?: ChangeTransitionOptions): Promise<Change>;
330
+ list(): Promise<Change[]>;
331
+ };
332
+ receipts: {
333
+ append(input: AppendReceiptInput): Promise<Receipt>;
334
+ get(id: string): Promise<Receipt | null>;
335
+ list(): Promise<Receipt[]>;
336
+ };
337
+ }
338
+ interface CreateStoresOptions {
339
+ driver: StoreDriver;
340
+ now?: () => string;
341
+ }
342
+ declare function createStores(options: CreateStoresOptions): FactoryStores;
343
+ //#endregion
344
+ //#region src/schema/finding.d.ts
345
+ declare const findingPrioritySchema: z.ZodEnum<{
346
+ P0: "P0";
347
+ P1: "P1";
348
+ P2: "P2";
349
+ P3: "P3";
350
+ }>;
351
+ declare const findingCategorySchema: z.ZodEnum<{
352
+ security: "security";
353
+ correctness: "correctness";
354
+ reliability: "reliability";
355
+ performance: "performance";
356
+ compatibility: "compatibility";
357
+ accessibility: "accessibility";
358
+ documentation: "documentation";
359
+ maintainability: "maintainability";
360
+ testing: "testing";
361
+ usability: "usability";
362
+ }>;
363
+ declare const findingVerificationLevelSchema: z.ZodEnum<{
364
+ unverified: "unverified";
365
+ supported: "supported";
366
+ confirmed: "confirmed";
367
+ }>;
368
+ declare const findingVerificationMethodSchema: z.ZodEnum<{
369
+ documentation: "documentation";
370
+ code_inspection: "code_inspection";
371
+ static_analysis: "static_analysis";
372
+ manual_reproduction: "manual_reproduction";
373
+ unit_test: "unit_test";
374
+ integration_test: "integration_test";
375
+ e2e_test: "e2e_test";
376
+ runtime_observation: "runtime_observation";
377
+ }>;
378
+ /**
379
+ * What was done to check the finding. Forces a reporter to distinguish "I
380
+ * think this is a problem" from "I demonstrated it", which is the axis a human
381
+ * approving fixes cares about most.
382
+ */
383
+ declare const findingVerificationSchema: z.ZodObject<{
384
+ level: z.ZodEnum<{
385
+ unverified: "unverified";
386
+ supported: "supported";
387
+ confirmed: "confirmed";
388
+ }>;
389
+ method: z.ZodEnum<{
390
+ documentation: "documentation";
391
+ code_inspection: "code_inspection";
392
+ static_analysis: "static_analysis";
393
+ manual_reproduction: "manual_reproduction";
394
+ unit_test: "unit_test";
395
+ integration_test: "integration_test";
396
+ e2e_test: "e2e_test";
397
+ runtime_observation: "runtime_observation";
398
+ }>;
399
+ summary: z.ZodString;
400
+ limitations: z.ZodOptional<z.ZodString>;
401
+ }, z.core.$strict>;
402
+ /** A single problem found in a repository, as a scanner or agent reports it. */
403
+ declare const findingSchema: z.ZodObject<{
404
+ title: z.ZodString;
405
+ body: z.ZodString;
406
+ path: z.ZodOptional<z.ZodString>;
407
+ line: z.ZodOptional<z.ZodNumber>;
408
+ endLine: z.ZodOptional<z.ZodNumber>;
409
+ priority: z.ZodEnum<{
410
+ P0: "P0";
411
+ P1: "P1";
412
+ P2: "P2";
413
+ P3: "P3";
414
+ }>;
415
+ category: z.ZodEnum<{
416
+ security: "security";
417
+ correctness: "correctness";
418
+ reliability: "reliability";
419
+ performance: "performance";
420
+ compatibility: "compatibility";
421
+ accessibility: "accessibility";
422
+ documentation: "documentation";
423
+ maintainability: "maintainability";
424
+ testing: "testing";
425
+ usability: "usability";
426
+ }>;
427
+ verification: z.ZodObject<{
428
+ level: z.ZodEnum<{
429
+ unverified: "unverified";
430
+ supported: "supported";
431
+ confirmed: "confirmed";
432
+ }>;
433
+ method: z.ZodEnum<{
434
+ documentation: "documentation";
435
+ code_inspection: "code_inspection";
436
+ static_analysis: "static_analysis";
437
+ manual_reproduction: "manual_reproduction";
438
+ unit_test: "unit_test";
439
+ integration_test: "integration_test";
440
+ e2e_test: "e2e_test";
441
+ runtime_observation: "runtime_observation";
442
+ }>;
443
+ summary: z.ZodString;
444
+ limitations: z.ZodOptional<z.ZodString>;
445
+ }, z.core.$strict>;
446
+ tool: z.ZodOptional<z.ZodString>;
447
+ ruleId: z.ZodOptional<z.ZodString>;
448
+ }, z.core.$strict>;
449
+ type FindingPriority = z.infer<typeof findingPrioritySchema>;
450
+ type FindingCategory = z.infer<typeof findingCategorySchema>;
451
+ type FindingVerification = z.infer<typeof findingVerificationSchema>;
452
+ type Finding = z.infer<typeof findingSchema>;
453
+ /**
454
+ * Stable identity of a finding across scans, used as the signal's delivery id
455
+ * so re-reporting is a no-op instead of a second task. A scanner finding is
456
+ * the same problem when the same tool reports the same rule on the same file;
457
+ * its title is model-written prose and changes between runs, so it is left
458
+ * out. Without a rule id the title is all there is, normalised.
459
+ */
460
+ declare function findingFingerprint(repositoryId: string, finding: Finding): string;
461
+ //#endregion
462
+ //#region src/approval.d.ts
463
+ /**
464
+ * One approval rule. Every listed field must match for the rule to apply;
465
+ * absent fields match anything. Rules are evaluated first-match.
466
+ */
467
+ declare const approvalRuleSchema: z.ZodObject<{
468
+ source: z.ZodOptional<z.ZodString>;
469
+ kind: z.ZodOptional<z.ZodString>;
470
+ priority: z.ZodOptional<z.ZodArray<z.ZodEnum<{
471
+ P0: "P0";
472
+ P1: "P1";
473
+ P2: "P2";
474
+ P3: "P3";
475
+ }>>>;
476
+ require: z.ZodBoolean;
477
+ }, z.core.$strict>;
478
+ declare const approvalPolicySchema: z.ZodArray<z.ZodObject<{
479
+ source: z.ZodOptional<z.ZodString>;
480
+ kind: z.ZodOptional<z.ZodString>;
481
+ priority: z.ZodOptional<z.ZodArray<z.ZodEnum<{
482
+ P0: "P0";
483
+ P1: "P1";
484
+ P2: "P2";
485
+ P3: "P3";
486
+ }>>>;
487
+ require: z.ZodBoolean;
488
+ }, z.core.$strict>>;
489
+ type ApprovalRule = z.infer<typeof approvalRuleSchema>;
490
+ type ApprovalPolicy = z.infer<typeof approvalPolicySchema>;
491
+ /**
492
+ * The default: fixes for security findings wait for a human; everything else
493
+ * runs as it always has. Handoffs between agents (verification) never wait,
494
+ * because a human already approved the work they continue.
495
+ */
496
+ declare const defaultApprovalPolicy: ApprovalPolicy;
497
+ interface ApprovalSubject {
498
+ source?: string;
499
+ kind: string;
500
+ priority?: FindingPriority;
501
+ }
502
+ /**
503
+ * Decide at task-creation time whether a task needs approval. Pure: the answer
504
+ * is stamped on the task and never re-evaluated, so a later policy change
505
+ * cannot silently release work a human was expecting to see.
506
+ */
507
+ declare function requiresApproval(policy: ApprovalPolicy, subject: ApprovalSubject): boolean;
508
+ //#endregion
509
+ export { ReceiptPhase as $, TaskPatch as A, taskDevboxSchema as B, ChangeTransitionOptions as C, changeIdSchema as Ct, CreateTaskInput as D, repositoryIdsSchema as Dt, CreateStoresOptions as E, repositoryIdSchema as Et, TaskKind as F, taskStateSchema as G, taskOriginSchema as H, TaskState as I, repositorySchema as J, Repository as K, harnessSchema as L, createStores as M, Task as N, DecideSignalOptions as O, signalIdSchema as Ot, TaskApproval as P, ReceiptKind as Q, standardTaskKinds as R, ChangePatch as S, TaskId as St, CreateSignalInput as T, receiptIdSchema as Tt, taskQuestionSchema as U, taskKindSchema as V, taskSchema as W, Cost as X, repositorySlugSchema as Y, Receipt as Z, findingVerificationMethodSchema as _, ChangeId as _t, approvalRuleSchema as a, receiptStateSchema as at, ApprovalDecision as b, RepositoryId as bt, Finding as c, standardReceiptStates as ct, FindingVerification as d, ChangeState as dt, ReceiptState as et, findingCategorySchema as f, Level as ft, findingVerificationLevelSchema as g, levelSchema as gt, findingSchema as h, changeStateSchema as ht, approvalPolicySchema as i, receiptSchema as it, TaskTransitionOptions as j, FactoryStores as k, taskIdSchema as kt, FindingCategory as l, Change as lt, findingPrioritySchema as m, changeSchema as mt, ApprovalRule as n, receiptKindSchema as nt, defaultApprovalPolicy as o, standardReceiptKinds as ot, findingFingerprint as p, changeEvidenceSchema as pt, RepositorySlug as q, ApprovalSubject as r, receiptPhaseSchema as rt, requiresApproval as s, standardReceiptPhases as st, ApprovalPolicy as t, costSchema as tt, FindingPriority as u, ChangeEvidence as ut, findingVerificationSchema as v, FactoryId as vt, CreateChangeInput as w, factoryIdSchema as wt, ApprovalError as x, SignalId as xt, AppendReceiptInput as y, ReceiptId as yt, taskApprovalSchema as z };
510
+ //# sourceMappingURL=approval-h5aj8HYN.d.mts.map
@@ -0,0 +1,32 @@
1
+ import { i as StoreDriver } from "../driver-CrZsy7sm.mjs";
2
+ //#region src/blob/index.d.ts
3
+ interface BlobObject {
4
+ body: string;
5
+ etag: string;
6
+ }
7
+ /** The narrow blob operations the driver needs; injectable for tests. */
8
+ interface BlobClient {
9
+ /** Must return the latest content, never a cached copy. */
10
+ read(pathname: string): Promise<BlobObject | null>;
11
+ /** Must reject if overwrite is false and the path exists, or if ifMatch is given and the ETag differs. */
12
+ write(pathname: string, body: string, overwrite: boolean, ifMatch?: string): Promise<void>;
13
+ listPaths(prefix: string): Promise<string[]>;
14
+ }
15
+ declare const vercelBlobClient: BlobClient;
16
+ interface BlobDriverOptions {
17
+ client?: BlobClient;
18
+ /** Path prefix inside the blob store; defaults to "factory". */
19
+ prefix?: string;
20
+ }
21
+ /**
22
+ * Store driver on Vercel Blob: durable and dependency-free (one Blob store on
23
+ * the project, no database). Inserts and receipts are exactly as safe as on
24
+ * Postgres (create-if-absent is atomic). Updates read the latest content,
25
+ * bypassing Blob's CDN cache, and write with an ETag precondition, so a
26
+ * writer that lost a race gets a VersionConflictError rather than
27
+ * overwriting the winner.
28
+ */
29
+ declare function createBlobDriver(options?: BlobDriverOptions): StoreDriver;
30
+ //#endregion
31
+ export { BlobClient, BlobDriverOptions, BlobObject, createBlobDriver, vercelBlobClient };
32
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,141 @@
1
+ import { n as RecordNotFoundError, r as VersionConflictError, t as RecordExistsError } from "../driver-Bbd25rNM.mjs";
2
+ import { get, list, put } from "@vercel/blob";
3
+ //#region src/blob/index.ts
4
+ function isNotFoundError(error) {
5
+ return error instanceof Error && (error.name === "BlobNotFoundError" || /does not exist|not.?found|404/iu.test(error.message));
6
+ }
7
+ function isAlreadyExistsError(error) {
8
+ return error instanceof Error && /already exists|not allowed to overwrite|overwrite/iu.test(error.message);
9
+ }
10
+ function isPreconditionError(error) {
11
+ return error instanceof Error && (error.name === "BlobPreconditionFailedError" || /precondition|etag|412/iu.test(error.message));
12
+ }
13
+ const vercelBlobClient = {
14
+ async read(pathname) {
15
+ let result;
16
+ try {
17
+ result = await get(pathname, {
18
+ access: "private",
19
+ useCache: false
20
+ });
21
+ } catch (error) {
22
+ if (isNotFoundError(error)) return null;
23
+ throw error;
24
+ }
25
+ if (result === null || result.stream === null) return null;
26
+ return {
27
+ body: await new Response(result.stream).text(),
28
+ etag: result.blob.etag
29
+ };
30
+ },
31
+ async write(pathname, body, overwrite, ifMatch) {
32
+ await put(pathname, body, {
33
+ access: "private",
34
+ allowOverwrite: overwrite,
35
+ contentType: "application/json",
36
+ ...ifMatch === void 0 ? {} : { ifMatch }
37
+ });
38
+ },
39
+ async listPaths(prefix) {
40
+ const paths = [];
41
+ let cursor;
42
+ do {
43
+ const page = await list({
44
+ prefix,
45
+ cursor,
46
+ limit: 1e3
47
+ });
48
+ paths.push(...page.blobs.map((blob) => blob.pathname));
49
+ cursor = page.hasMore ? page.cursor : void 0;
50
+ } while (cursor !== void 0);
51
+ return paths;
52
+ }
53
+ };
54
+ /**
55
+ * Store driver on Vercel Blob: durable and dependency-free (one Blob store on
56
+ * the project, no database). Inserts and receipts are exactly as safe as on
57
+ * Postgres (create-if-absent is atomic). Updates read the latest content,
58
+ * bypassing Blob's CDN cache, and write with an ETag precondition, so a
59
+ * writer that lost a race gets a VersionConflictError rather than
60
+ * overwriting the winner.
61
+ */
62
+ function createBlobDriver(options = {}) {
63
+ const client = options.client ?? vercelBlobClient;
64
+ const prefix = options.prefix ?? "factory";
65
+ function pathFor(collection, id) {
66
+ return `${prefix}/${collection}/${id}.json`;
67
+ }
68
+ async function readRecord(collection, id) {
69
+ let object;
70
+ try {
71
+ object = await client.read(pathFor(collection, id));
72
+ } catch (error) {
73
+ if (isNotFoundError(error)) return null;
74
+ throw error;
75
+ }
76
+ if (object === null) return null;
77
+ const parsed = JSON.parse(object.body);
78
+ if (typeof parsed.version !== "number") throw new Error(`malformed stored record at ${pathFor(collection, id)}`);
79
+ return {
80
+ value: parsed.value,
81
+ version: parsed.version,
82
+ etag: object.etag
83
+ };
84
+ }
85
+ return {
86
+ name: "blob",
87
+ async get(collection, id) {
88
+ const record = await readRecord(collection, id);
89
+ return record === null ? null : {
90
+ value: record.value,
91
+ version: record.version
92
+ };
93
+ },
94
+ async insert(collection, id, value) {
95
+ try {
96
+ await client.write(pathFor(collection, id), JSON.stringify({
97
+ value,
98
+ version: 1
99
+ }), false);
100
+ } catch (error) {
101
+ if (isAlreadyExistsError(error)) throw new RecordExistsError(collection, id);
102
+ throw error;
103
+ }
104
+ },
105
+ async update(collection, id, value, expectedVersion) {
106
+ const existing = await readRecord(collection, id);
107
+ if (existing === null) throw new RecordNotFoundError(collection, id);
108
+ if (existing.version !== expectedVersion) throw new VersionConflictError(collection, id, expectedVersion);
109
+ try {
110
+ await client.write(pathFor(collection, id), JSON.stringify({
111
+ value,
112
+ version: expectedVersion + 1
113
+ }), true, existing.etag.replace(/^W\//u, ""));
114
+ } catch (error) {
115
+ if (isPreconditionError(error)) throw new VersionConflictError(collection, id, expectedVersion);
116
+ throw error;
117
+ }
118
+ },
119
+ async list(collection) {
120
+ const dir = `${prefix}/${collection}/`;
121
+ const paths = await client.listPaths(dir);
122
+ const entries = [];
123
+ for (const pathname of paths) {
124
+ const id = pathname.slice(dir.length).replace(/\.json$/u, "");
125
+ const record = await readRecord(collection, id);
126
+ if (record !== null) entries.push({
127
+ id,
128
+ record: {
129
+ value: record.value,
130
+ version: record.version
131
+ }
132
+ });
133
+ }
134
+ return entries;
135
+ }
136
+ };
137
+ }
138
+ //#endregion
139
+ export { createBlobDriver, vercelBlobClient };
140
+
141
+ //# sourceMappingURL=index.mjs.map