@vercel/factory 0.0.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,350 @@
1
+ import { R as ReplyTo } from './common-CaHaEOAS.js';
2
+ import { z } from 'zod';
3
+ import { S as StoreDriver } from './driver-tRNggCCJ.js';
4
+
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
+
19
+ declare const levelSchema: z.ZodEnum<{
20
+ low: "low";
21
+ medium: "medium";
22
+ high: "high";
23
+ }>;
24
+ declare const changeStateSchema: z.ZodEnum<{
25
+ verifying: "verifying";
26
+ ready: "ready";
27
+ merged: "merged";
28
+ deployed: "deployed";
29
+ rolled_out: "rolled_out";
30
+ rolled_back: "rolled_back";
31
+ closed: "closed";
32
+ }>;
33
+ declare const changeEvidenceSchema: z.ZodObject<{
34
+ reproVerified: z.ZodBoolean;
35
+ testsAdded: z.ZodNumber;
36
+ checksGreen: z.ZodBoolean;
37
+ attackPassed: z.ZodBoolean;
38
+ scopeMatches: z.ZodBoolean;
39
+ previewUrl: z.ZodOptional<z.ZodURL>;
40
+ }, z.core.$strict>;
41
+ declare const changeSchema: z.ZodObject<{
42
+ schemaVersion: z.ZodLiteral<1>;
43
+ id: z.ZodString;
44
+ repositoryId: z.ZodString;
45
+ taskId: z.ZodOptional<z.ZodString>;
46
+ groupId: z.ZodOptional<z.ZodString>;
47
+ prNumber: z.ZodNumber;
48
+ prUrl: z.ZodURL;
49
+ author: z.ZodString;
50
+ risk: z.ZodEnum<{
51
+ low: "low";
52
+ medium: "medium";
53
+ high: "high";
54
+ }>;
55
+ confidence: z.ZodEnum<{
56
+ low: "low";
57
+ medium: "medium";
58
+ high: "high";
59
+ }>;
60
+ evidence: z.ZodObject<{
61
+ reproVerified: z.ZodBoolean;
62
+ testsAdded: z.ZodNumber;
63
+ checksGreen: z.ZodBoolean;
64
+ attackPassed: z.ZodBoolean;
65
+ scopeMatches: z.ZodBoolean;
66
+ previewUrl: z.ZodOptional<z.ZodURL>;
67
+ }, z.core.$strict>;
68
+ state: z.ZodEnum<{
69
+ verifying: "verifying";
70
+ ready: "ready";
71
+ merged: "merged";
72
+ deployed: "deployed";
73
+ rolled_out: "rolled_out";
74
+ rolled_back: "rolled_back";
75
+ closed: "closed";
76
+ }>;
77
+ decidedBy: z.ZodOptional<z.ZodString>;
78
+ createdAt: z.ZodISODateTime;
79
+ updatedAt: z.ZodISODateTime;
80
+ }, z.core.$strict>;
81
+ type Level = z.infer<typeof levelSchema>;
82
+ type ChangeState = z.infer<typeof changeStateSchema>;
83
+ type ChangeEvidence = z.infer<typeof changeEvidenceSchema>;
84
+ type Change = z.infer<typeof changeSchema>;
85
+
86
+ /** States the engine writes on transitions. Any vocabulary value is valid. */
87
+ declare const standardReceiptStates: readonly ["dispatched", "succeeded", "failed", "needs_human", "cancelled", "settled", "merged", "deployed", "rolled_out", "rolled_back"];
88
+ /** Phases the standard loop uses. Any vocabulary value is valid. */
89
+ declare const standardReceiptPhases: readonly ["budget", "dispatch", "implementation", "verification", "pull_request", "cleanup"];
90
+ /** Kinds the standard loop writes: the standard task kinds plus "change". */
91
+ declare const standardReceiptKinds: readonly ["code_change", "verification", "investigation", "question", "change"];
92
+ declare const receiptStateSchema: z.ZodString;
93
+ declare const receiptPhaseSchema: z.ZodString;
94
+ declare const receiptKindSchema: z.ZodString;
95
+ declare const costSchema: z.ZodObject<{
96
+ totalUsd: z.ZodNumber;
97
+ }, z.core.$strict>;
98
+ declare const receiptSchema: z.ZodObject<{
99
+ schemaVersion: z.ZodLiteral<1>;
100
+ receiptId: z.ZodString;
101
+ repositoryIds: z.ZodArray<z.ZodString>;
102
+ taskId: z.ZodOptional<z.ZodString>;
103
+ changeId: z.ZodOptional<z.ZodString>;
104
+ kind: z.ZodString;
105
+ state: z.ZodString;
106
+ phase: z.ZodOptional<z.ZodString>;
107
+ reason: z.ZodOptional<z.ZodString>;
108
+ attempt: z.ZodNumber;
109
+ cost: z.ZodOptional<z.ZodObject<{
110
+ totalUsd: z.ZodNumber;
111
+ }, z.core.$strict>>;
112
+ decidedBy: z.ZodOptional<z.ZodString>;
113
+ recordedAt: z.ZodISODateTime;
114
+ }, z.core.$strict>;
115
+ type ReceiptState = z.infer<typeof receiptStateSchema>;
116
+ type ReceiptPhase = z.infer<typeof receiptPhaseSchema>;
117
+ type ReceiptKind = z.infer<typeof receiptKindSchema>;
118
+ type Cost = z.infer<typeof costSchema>;
119
+ type Receipt = z.infer<typeof receiptSchema>;
120
+
121
+ declare const repositorySlugSchema: z.ZodString;
122
+ declare const repositorySchema: z.ZodObject<{
123
+ schemaVersion: z.ZodLiteral<1>;
124
+ id: z.ZodString;
125
+ slug: z.ZodString;
126
+ defaultBranch: z.ZodString;
127
+ enabled: z.ZodBoolean;
128
+ dependsOn: z.ZodArray<z.ZodString>;
129
+ devbox: z.ZodOptional<z.ZodObject<{
130
+ projectId: z.ZodString;
131
+ teamId: z.ZodString;
132
+ snapshot: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strict>>;
134
+ connectedAt: z.ZodISODateTime;
135
+ }, z.core.$strict>;
136
+ type RepositorySlug = z.infer<typeof repositorySlugSchema>;
137
+ type Repository = z.infer<typeof repositorySchema>;
138
+
139
+ /** Sources used by the standard connectors. Any vocabulary value is valid. */
140
+ declare const standardSignalSources: readonly ["github_issue", "github_pr", "github_pr_comment", "slack", "human", "github_ci_failure", "vercel_deploy_failure", "investigation", "api"];
141
+ declare const signalSourceSchema: z.ZodString;
142
+ declare const signalOutcomeSchema: z.ZodEnum<{
143
+ pending: "pending";
144
+ accepted: "accepted";
145
+ duplicate: "duplicate";
146
+ unactionable: "unactionable";
147
+ low_confidence: "low_confidence";
148
+ ignored: "ignored";
149
+ }>;
150
+ declare const signalSchema: z.ZodObject<{
151
+ schemaVersion: z.ZodLiteral<1>;
152
+ id: z.ZodString;
153
+ repositoryId: z.ZodString;
154
+ source: z.ZodString;
155
+ deliveryId: z.ZodString;
156
+ replyTo: z.ZodObject<{
157
+ channel: z.ZodString;
158
+ address: z.ZodString;
159
+ }, z.core.$strict>;
160
+ payload: z.ZodUnknown;
161
+ receivedAt: z.ZodISODateTime;
162
+ outcome: z.ZodEnum<{
163
+ pending: "pending";
164
+ accepted: "accepted";
165
+ duplicate: "duplicate";
166
+ unactionable: "unactionable";
167
+ low_confidence: "low_confidence";
168
+ ignored: "ignored";
169
+ }>;
170
+ detail: z.ZodOptional<z.ZodString>;
171
+ reason: z.ZodOptional<z.ZodString>;
172
+ decidedAt: z.ZodOptional<z.ZodISODateTime>;
173
+ }, z.core.$strict>;
174
+ type SignalSource = z.infer<typeof signalSourceSchema>;
175
+ type SignalOutcome = z.infer<typeof signalOutcomeSchema>;
176
+ type Signal = z.infer<typeof signalSchema>;
177
+
178
+ /**
179
+ * Kinds the standard loop understands. Any vocabulary value is valid; the
180
+ * kind-scoped rules below apply only to these standard kinds.
181
+ */
182
+ declare const standardTaskKinds: readonly ["code_change", "verification", "investigation", "question"];
183
+ declare const taskKindSchema: z.ZodString;
184
+ declare const taskStateSchema: z.ZodEnum<{
185
+ queued: "queued";
186
+ running: "running";
187
+ verifying: "verifying";
188
+ succeeded: "succeeded";
189
+ failed: "failed";
190
+ needs_human: "needs_human";
191
+ cancelled: "cancelled";
192
+ }>;
193
+ declare const harnessSchema: z.ZodString;
194
+ declare const taskOriginSchema: z.ZodObject<{
195
+ signalId: z.ZodOptional<z.ZodString>;
196
+ parentTaskId: z.ZodOptional<z.ZodString>;
197
+ operator: z.ZodOptional<z.ZodString>;
198
+ }, z.core.$strict>;
199
+ declare const taskDevboxSchema: z.ZodObject<{
200
+ devboxId: z.ZodString;
201
+ remoteId: z.ZodString;
202
+ harness: z.ZodString;
203
+ }, z.core.$strict>;
204
+ declare const taskQuestionSchema: z.ZodObject<{
205
+ text: z.ZodString;
206
+ options: z.ZodArray<z.ZodString>;
207
+ answer: z.ZodOptional<z.ZodString>;
208
+ answeredBy: z.ZodOptional<z.ZodString>;
209
+ }, z.core.$strict>;
210
+ declare const taskSchema: z.ZodObject<{
211
+ schemaVersion: z.ZodLiteral<1>;
212
+ id: z.ZodString;
213
+ repositoryIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
+ kind: z.ZodString;
215
+ area: z.ZodOptional<z.ZodString>;
216
+ state: z.ZodEnum<{
217
+ queued: "queued";
218
+ running: "running";
219
+ verifying: "verifying";
220
+ succeeded: "succeeded";
221
+ failed: "failed";
222
+ needs_human: "needs_human";
223
+ cancelled: "cancelled";
224
+ }>;
225
+ origin: z.ZodObject<{
226
+ signalId: z.ZodOptional<z.ZodString>;
227
+ parentTaskId: z.ZodOptional<z.ZodString>;
228
+ operator: z.ZodOptional<z.ZodString>;
229
+ }, z.core.$strict>;
230
+ dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
231
+ replyTo: z.ZodObject<{
232
+ channel: z.ZodString;
233
+ address: z.ZodString;
234
+ }, z.core.$strict>;
235
+ devbox: z.ZodOptional<z.ZodObject<{
236
+ devboxId: z.ZodString;
237
+ remoteId: z.ZodString;
238
+ harness: z.ZodString;
239
+ }, z.core.$strict>>;
240
+ attempt: z.ZodNumber;
241
+ reservedUsd: z.ZodOptional<z.ZodNumber>;
242
+ settledUsd: z.ZodOptional<z.ZodNumber>;
243
+ question: z.ZodOptional<z.ZodObject<{
244
+ text: z.ZodString;
245
+ options: z.ZodArray<z.ZodString>;
246
+ answer: z.ZodOptional<z.ZodString>;
247
+ answeredBy: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strict>>;
249
+ changeId: z.ZodOptional<z.ZodString>;
250
+ reportRef: z.ZodOptional<z.ZodString>;
251
+ createdAt: z.ZodISODateTime;
252
+ updatedAt: z.ZodISODateTime;
253
+ }, z.core.$strict>;
254
+ type TaskKind = z.infer<typeof taskKindSchema>;
255
+ type TaskState = z.infer<typeof taskStateSchema>;
256
+ type Task = z.infer<typeof taskSchema>;
257
+
258
+ interface CreateSignalInput {
259
+ repositoryId: RepositoryId;
260
+ source: SignalSource;
261
+ deliveryId: string;
262
+ replyTo: ReplyTo;
263
+ payload: unknown;
264
+ }
265
+ interface DecideSignalOptions {
266
+ detail?: string;
267
+ reason?: string;
268
+ }
269
+ interface CreateTaskInput {
270
+ repositoryIds: RepositoryId[];
271
+ kind: Task["kind"];
272
+ origin: Task["origin"];
273
+ replyTo: ReplyTo;
274
+ area?: string;
275
+ dependsOn?: TaskId[];
276
+ question?: Task["question"];
277
+ }
278
+ type TaskPatch = Partial<Pick<Task, "devbox" | "changeId" | "reportRef" | "reservedUsd" | "settledUsd" | "question">>;
279
+ interface TaskTransitionOptions {
280
+ patch?: TaskPatch;
281
+ reason?: string;
282
+ }
283
+ interface CreateChangeInput {
284
+ repositoryId: RepositoryId;
285
+ taskId?: TaskId;
286
+ groupId?: TaskId;
287
+ prNumber: number;
288
+ prUrl: string;
289
+ author: string;
290
+ risk: Level;
291
+ confidence: Level;
292
+ evidence: Change["evidence"];
293
+ }
294
+ type ChangePatch = Partial<Pick<Change, "confidence" | "evidence" | "decidedBy">>;
295
+ interface ChangeTransitionOptions {
296
+ patch?: ChangePatch;
297
+ reason?: string;
298
+ }
299
+ interface AppendReceiptInput {
300
+ repositoryIds: RepositoryId[];
301
+ taskId?: TaskId;
302
+ changeId?: ChangeId;
303
+ kind: string;
304
+ state: string;
305
+ phase?: string;
306
+ reason?: string;
307
+ attempt?: number;
308
+ cost?: Cost;
309
+ decidedBy?: string;
310
+ /** Same key twice appends one receipt and returns the existing one. */
311
+ dedupeKey?: string;
312
+ }
313
+ interface FactoryStores {
314
+ driverName: string;
315
+ repositories: {
316
+ put(repository: Repository): Promise<Repository>;
317
+ get(id: RepositoryId): Promise<Repository | null>;
318
+ list(): Promise<Repository[]>;
319
+ };
320
+ signals: {
321
+ create(input: CreateSignalInput): Promise<Signal>;
322
+ get(id: SignalId): Promise<Signal | null>;
323
+ decide(id: SignalId, outcome: SignalOutcome, options?: DecideSignalOptions): Promise<Signal>;
324
+ list(): Promise<Signal[]>;
325
+ };
326
+ tasks: {
327
+ create(input: CreateTaskInput): Promise<Task>;
328
+ get(id: TaskId): Promise<Task | null>;
329
+ transition(id: TaskId, to: TaskState, options?: TaskTransitionOptions): Promise<Task>;
330
+ list(): Promise<Task[]>;
331
+ };
332
+ changes: {
333
+ create(input: CreateChangeInput): Promise<Change>;
334
+ get(id: ChangeId): Promise<Change | null>;
335
+ transition(id: ChangeId, to: ChangeState, options?: ChangeTransitionOptions): Promise<Change>;
336
+ list(): Promise<Change[]>;
337
+ };
338
+ receipts: {
339
+ append(input: AppendReceiptInput): Promise<Receipt>;
340
+ get(id: string): Promise<Receipt | null>;
341
+ list(): Promise<Receipt[]>;
342
+ };
343
+ }
344
+ interface CreateStoresOptions {
345
+ driver: StoreDriver;
346
+ now?: () => string;
347
+ }
348
+ declare function createStores(options: CreateStoresOptions): FactoryStores;
349
+
350
+ export { signalOutcomeSchema as $, type AppendReceiptInput as A, changeEvidenceSchema as B, type ChangeState as C, type DecideSignalOptions as D, changeIdSchema as E, type FactoryStores as F, changeSchema as G, changeStateSchema as H, costSchema as I, createStores as J, factoryIdSchema as K, type Level as L, harnessSchema as M, levelSchema as N, receiptIdSchema as O, receiptKindSchema as P, receiptPhaseSchema as Q, type Receipt as R, type SignalOutcome as S, type Task as T, receiptSchema as U, receiptStateSchema as V, repositoryIdSchema as W, repositoryIdsSchema as X, repositorySchema as Y, repositorySlugSchema as Z, signalIdSchema as _, type TaskId as a, signalSchema as a0, signalSourceSchema as a1, standardReceiptKinds as a2, standardReceiptPhases as a3, standardReceiptStates as a4, standardSignalSources as a5, standardTaskKinds as a6, taskDevboxSchema as a7, taskIdSchema as a8, taskKindSchema as a9, taskOriginSchema as aa, taskQuestionSchema as ab, taskSchema as ac, taskStateSchema as ad, type TaskState as b, type Change as c, type ChangeEvidence as d, type ChangeId as e, type ChangePatch as f, type ChangeTransitionOptions as g, type Cost as h, type CreateChangeInput as i, type CreateSignalInput as j, type CreateStoresOptions as k, type CreateTaskInput as l, type FactoryId as m, type ReceiptId as n, type ReceiptKind as o, type ReceiptPhase as p, type ReceiptState as q, type Repository as r, type RepositoryId as s, type RepositorySlug as t, type Signal as u, type SignalId as v, type SignalSource as w, type TaskKind as x, type TaskPatch as y, type TaskTransitionOptions as z };