@vercel/factory 0.0.12 → 0.0.14

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 (57) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.mts +225 -0
  3. package/dist/api.mjs +312 -0
  4. package/dist/api.mjs.map +1 -0
  5. package/dist/{approval-DdvEKLiE.mjs → approval-JX2Px9IC.mjs} +2 -2
  6. package/dist/{approval-DdvEKLiE.mjs.map → approval-JX2Px9IC.mjs.map} +1 -1
  7. package/dist/blob/index.d.mts +4 -3
  8. package/dist/blob/index.mjs +21 -15
  9. package/dist/blob/index.mjs.map +1 -1
  10. package/dist/budget-DzSiIA4t.mjs +42 -0
  11. package/dist/budget-DzSiIA4t.mjs.map +1 -0
  12. package/dist/build-factory.d.mts +1 -1
  13. package/dist/build-factory.mjs +1 -1
  14. package/dist/change-D2U6v7Ek.mjs +554 -0
  15. package/dist/change-D2U6v7Ek.mjs.map +1 -0
  16. package/dist/communication-Kd9nU5RP.mjs +30 -0
  17. package/dist/communication-Kd9nU5RP.mjs.map +1 -0
  18. package/dist/connectors/index.d.mts +3 -2
  19. package/dist/connectors/index.mjs +53 -26
  20. package/dist/connectors/index.mjs.map +1 -1
  21. package/dist/connectors/slack.d.mts +17 -6
  22. package/dist/connectors/slack.mjs +99 -32
  23. package/dist/connectors/slack.mjs.map +1 -1
  24. package/dist/coordination-Cq08hb1l.mjs +76 -0
  25. package/dist/coordination-Cq08hb1l.mjs.map +1 -0
  26. package/dist/dispatch-BaZS3PT8.d.mts +76 -0
  27. package/dist/{driver-CrZsy7sm.d.mts → driver-BC0Mt5KG.d.mts} +2 -2
  28. package/dist/driver-Bbd25rNM.mjs.map +1 -1
  29. package/dist/engine-DFHU2Pe-.d.mts +781 -0
  30. package/dist/engine-WaUM2cGA.mjs +1068 -0
  31. package/dist/engine-WaUM2cGA.mjs.map +1 -0
  32. package/dist/eve/index.d.mts +289 -153
  33. package/dist/eve/index.mjs +378 -89
  34. package/dist/eve/index.mjs.map +1 -1
  35. package/dist/{factory-config-ifd3JxiU.mjs → factory-config-BoRXOw43.mjs} +23 -22
  36. package/dist/factory-config-BoRXOw43.mjs.map +1 -0
  37. package/dist/{factory-config-Bu4mklm9.d.mts → factory-config-D2yU3G0c.d.mts} +21 -2
  38. package/dist/{github-wThBfbm-.d.mts → github-C5HNBN6p.d.mts} +34 -3
  39. package/dist/github.d.mts +2 -2
  40. package/dist/github.mjs +61 -1
  41. package/dist/github.mjs.map +1 -1
  42. package/dist/{id-DwCihQr4.mjs → id-BLIkCVue.mjs} +4 -2
  43. package/dist/{id-DwCihQr4.mjs.map → id-BLIkCVue.mjs.map} +1 -1
  44. package/dist/index-Bw6hggoH.d.mts +40 -0
  45. package/dist/index.d.mts +291 -61
  46. package/dist/index.mjs +140 -783
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/postgres/index.d.mts +1 -1
  49. package/dist/task-CcOyOJ3k.mjs +154 -0
  50. package/dist/task-CcOyOJ3k.mjs.map +1 -0
  51. package/package.json +5 -1
  52. package/dist/approval-CIXB8IF8.d.mts +0 -522
  53. package/dist/change-CFNGXVqD.mjs +0 -230
  54. package/dist/change-CFNGXVqD.mjs.map +0 -1
  55. package/dist/factory-config-ifd3JxiU.mjs.map +0 -1
  56. package/dist/index-Cy4jfXh5.d.mts +0 -67
  57. package/dist/signal-CHVEmzvI.d.mts +0 -59
@@ -1,230 +0,0 @@
1
- import { a as repositoryIdsSchema, d as schemaVersionSchema, f as usdSchema, i as repositoryIdSchema, l as isoDateTimeSchema, o as signalIdSchema, p as vocabularySchema, s as taskIdSchema, t as changeIdSchema, u as replyToSchema } from "./id-DwCihQr4.mjs";
2
- import { n as RecordNotFoundError } from "./driver-Bbd25rNM.mjs";
3
- import { z } from "zod";
4
- //#region src/schema/task.ts
5
- /**
6
- * Kinds the standard loop understands. Any vocabulary value is valid; the
7
- * kind-scoped rules below apply only to these standard kinds.
8
- */
9
- const standardTaskKinds = [
10
- "coordination",
11
- "code_change",
12
- "verification",
13
- "investigation",
14
- "question"
15
- ];
16
- const taskKindSchema = vocabularySchema.describe("What kind of work this is, e.g. code_change, question, or a registered custom kind.");
17
- const taskStateSchema = z.enum([
18
- "queued",
19
- "running",
20
- "verifying",
21
- "succeeded",
22
- "failed",
23
- "needs_human",
24
- "cancelled"
25
- ]).describe("Lifecycle state. Transitions are fixed; see taskTransitions.");
26
- const taskApprovalSchema = z.enum([
27
- "required",
28
- "granted",
29
- "denied"
30
- ]).describe("Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator.");
31
- const taskExecutionRepositoryIdsSchema = z.tuple([repositoryIdSchema]).describe("The one repository used to execute a task.");
32
- const coordinationRepositoryIdsSchema = z.tuple([repositoryIdSchema, repositoryIdSchema]).rest(repositoryIdSchema).refine((repositoryIds) => new Set(repositoryIds).size === repositoryIds.length, { message: "Coordination tasks require distinct repositories." }).describe("The distinct repositories coordinated by a non-executable parent task.");
33
- const harnessSchema = z.string().min(1).describe("Coding harness used in the devbox, e.g. claude-code or codex.");
34
- const taskOriginSchema = z.strictObject({
35
- signalId: signalIdSchema.optional().describe("Signal that led to this task."),
36
- parentTaskId: taskIdSchema.optional().describe("Parent task that planned this child."),
37
- operator: z.string().min(1).optional().describe("Human operator who requested it.")
38
- }).refine((origin) => origin.signalId !== void 0 || origin.parentTaskId !== void 0 || origin.operator !== void 0, { message: "origin requires a signalId, parentTaskId, or operator" });
39
- const taskDevboxSchema = z.strictObject({
40
- devboxId: z.string().min(1).describe("Devbox running or having run this task."),
41
- remoteId: z.string().min(1).describe("Provider-side id of the execution."),
42
- harness: harnessSchema
43
- });
44
- const taskQuestionSchema = z.strictObject({
45
- text: z.string().min(1).describe("The question a human must answer."),
46
- options: z.array(z.string().min(1)).describe("Suggested answers; free-text is also allowed."),
47
- answer: z.string().min(1).optional(),
48
- answeredBy: z.string().min(1).optional().describe("Authenticated operator who answered.")
49
- });
50
- const taskSchema = z.strictObject({
51
- schemaVersion: schemaVersionSchema,
52
- id: taskIdSchema,
53
- repositoryIds: repositoryIdsSchema.describe("Repositories the task concerns."),
54
- kind: taskKindSchema,
55
- area: z.string().min(1).optional().describe("Investigation area, e.g. onboarding or security. Investigation tasks only."),
56
- state: taskStateSchema,
57
- approval: taskApprovalSchema.optional(),
58
- origin: taskOriginSchema,
59
- dependsOn: z.array(taskIdSchema).min(1).optional().describe("Sibling tasks that must produce a change before this one may run."),
60
- replyTo: replyToSchema,
61
- devbox: taskDevboxSchema.optional(),
62
- attempt: z.number().int().min(1).describe("Execution attempt, starting at 1; bumps on retry."),
63
- reservedUsd: usdSchema.optional().describe("Budget reserved before dispatch."),
64
- settledUsd: usdSchema.optional().describe("Measured cost settled after execution."),
65
- question: taskQuestionSchema.optional(),
66
- changeId: changeIdSchema.optional().describe("Change produced or verified by this task."),
67
- reportRef: z.string().min(1).optional().describe("Reference to the report artifact an investigation produced."),
68
- createdAt: isoDateTimeSchema,
69
- updatedAt: isoDateTimeSchema
70
- }).superRefine((task, ctx) => {
71
- if (task.kind === "coordination" && !coordinationRepositoryIdsSchema.safeParse(task.repositoryIds).success) ctx.addIssue({
72
- code: "custom",
73
- path: ["repositoryIds"],
74
- message: "coordination tasks require at least two distinct repositories"
75
- });
76
- if ((task.kind === "code_change" || task.kind === "verification") && task.repositoryIds.length !== 1) ctx.addIssue({
77
- code: "custom",
78
- path: ["repositoryIds"],
79
- message: `${task.kind} tasks require exactly one repository`
80
- });
81
- if (task.area !== void 0 && task.kind !== "investigation") ctx.addIssue({
82
- code: "custom",
83
- path: ["area"],
84
- message: "area is only valid on investigation tasks"
85
- });
86
- if (task.kind === "question") {
87
- if (task.question === void 0) ctx.addIssue({
88
- code: "custom",
89
- path: ["question"],
90
- message: "question tasks require a question"
91
- });
92
- if (task.devbox !== void 0) ctx.addIssue({
93
- code: "custom",
94
- path: ["devbox"],
95
- message: "question tasks never run in a devbox"
96
- });
97
- } else if (task.question !== void 0) ctx.addIssue({
98
- code: "custom",
99
- path: ["question"],
100
- message: "question is only valid on question tasks"
101
- });
102
- if (task.kind === "coordination" && task.devbox !== void 0) ctx.addIssue({
103
- code: "custom",
104
- path: ["devbox"],
105
- message: "coordination tasks never run in a devbox"
106
- });
107
- if (task.changeId !== void 0 && task.kind !== "code_change" && task.kind !== "verification") ctx.addIssue({
108
- code: "custom",
109
- path: ["changeId"],
110
- message: "changeId is only valid on code_change or verification tasks"
111
- });
112
- if (task.reportRef !== void 0 && task.kind !== "investigation") ctx.addIssue({
113
- code: "custom",
114
- path: ["reportRef"],
115
- message: "reportRef is only valid on investigation tasks"
116
- });
117
- });
118
- //#endregion
119
- //#region src/dispatch.ts
120
- var DispatchRefusedError = class extends Error {
121
- taskId;
122
- reason;
123
- constructor(taskId, reason) {
124
- super(`dispatch of "${taskId}" refused: ${reason}`);
125
- this.name = "DispatchRefusedError";
126
- this.taskId = taskId;
127
- this.reason = reason;
128
- }
129
- };
130
- const DEFAULT_MAX_LAUNCH_ATTEMPTS = 45;
131
- /**
132
- * The handshake between recorded work and execution: win the store-gated
133
- * transition (at most one dispatcher can succeed), then start the run. A
134
- * launch failure re-queues the task (bumping its attempt) until the attempt
135
- * limit, then fails it; a crash between the transition and the launch leaves
136
- * a running task with no execution, which the sweep reaps.
137
- */
138
- async function dispatchTask(stores, taskId, options) {
139
- const task = await stores.tasks.get(taskId);
140
- if (task === null) throw new RecordNotFoundError("tasks", taskId);
141
- if (task.kind === "question") throw new DispatchRefusedError(taskId, "question tasks are answered, not dispatched");
142
- if (task.kind === "coordination") throw new DispatchRefusedError(taskId, "coordination tasks are reconciled, not dispatched");
143
- if (!taskExecutionRepositoryIdsSchema.safeParse(task.repositoryIds).success) throw new DispatchRefusedError(taskId, "task execution requires exactly one repository");
144
- if (task.approval === "required") throw new DispatchRefusedError(taskId, "awaiting human approval");
145
- if (task.approval === "denied") throw new DispatchRefusedError(taskId, "approval was denied");
146
- for (const dependencyId of task.dependsOn ?? []) {
147
- const dependency = await stores.tasks.get(dependencyId);
148
- if (dependency === null) throw new DispatchRefusedError(taskId, `dependency "${dependencyId}" does not exist`);
149
- if (dependency.changeId === void 0) throw new DispatchRefusedError(taskId, `dependency "${dependencyId}" has not produced a change`);
150
- }
151
- const running = await stores.tasks.transition(taskId, "running");
152
- try {
153
- await options.launch(running);
154
- } catch (error) {
155
- const reason = (error instanceof Error ? error.message : String(error)).slice(0, 500);
156
- const limit = options.maxLaunchAttempts ?? 45;
157
- if (running.attempt < limit) {
158
- const retryReason = `launch failed (attempt ${running.attempt} of ${limit}), will retry: ${reason}`;
159
- await stores.tasks.transition(taskId, "queued", { reason: retryReason }).catch(() => void 0);
160
- if (running.repositoryIds !== void 0) await stores.receipts.append({
161
- repositoryIds: running.repositoryIds,
162
- taskId,
163
- kind: "task",
164
- state: "launch_retry",
165
- reason: retryReason,
166
- dedupeKey: `task:${taskId}:launch_retry:${running.attempt}`
167
- }).catch(() => void 0);
168
- } else await stores.tasks.transition(taskId, "failed", { reason: `launch failed after ${running.attempt} attempts: ${reason}` }).catch(() => void 0);
169
- throw error;
170
- }
171
- return running;
172
- }
173
- //#endregion
174
- //#region src/schema/change.ts
175
- const levelSchema = z.enum([
176
- "low",
177
- "medium",
178
- "high"
179
- ]);
180
- const changeStateSchema = z.enum([
181
- "verifying",
182
- "ready",
183
- "merged",
184
- "deployed",
185
- "rolled_out",
186
- "rolled_back",
187
- "closed"
188
- ]);
189
- const postMergeStates = [
190
- "merged",
191
- "deployed",
192
- "rolled_out",
193
- "rolled_back"
194
- ];
195
- const changeEvidenceSchema = z.strictObject({
196
- reproVerified: z.boolean(),
197
- testsAdded: z.number().int().min(0),
198
- checksGreen: z.boolean(),
199
- attackPassed: z.boolean(),
200
- scopeMatches: z.boolean(),
201
- previewUrl: z.url().optional()
202
- });
203
- const changeSchema = z.strictObject({
204
- schemaVersion: schemaVersionSchema,
205
- id: changeIdSchema,
206
- repositoryId: repositoryIdSchema,
207
- taskId: taskIdSchema.optional(),
208
- groupId: taskIdSchema.optional(),
209
- prNumber: z.number().int().min(1),
210
- prUrl: z.url(),
211
- author: z.string().min(1),
212
- risk: levelSchema,
213
- confidence: levelSchema,
214
- evidence: changeEvidenceSchema,
215
- state: changeStateSchema,
216
- mergeSha: z.string().regex(/^[0-9a-f]{40}$/).optional().describe("Merge commit sha recorded when the pull request merges, matched against production deployments."),
217
- decidedBy: z.string().min(1).optional(),
218
- createdAt: isoDateTimeSchema,
219
- updatedAt: isoDateTimeSchema
220
- }).superRefine((change, ctx) => {
221
- if (postMergeStates.includes(change.state) && change.decidedBy === void 0) ctx.addIssue({
222
- code: "custom",
223
- path: ["decidedBy"],
224
- message: `${change.state} changes require decidedBy`
225
- });
226
- });
227
- //#endregion
228
- export { taskSchema as _, DEFAULT_MAX_LAUNCH_ATTEMPTS as a, coordinationRepositoryIdsSchema as c, taskApprovalSchema as d, taskDevboxSchema as f, taskQuestionSchema as g, taskOriginSchema as h, levelSchema as i, harnessSchema as l, taskKindSchema as m, changeSchema as n, DispatchRefusedError as o, taskExecutionRepositoryIdsSchema as p, changeStateSchema as r, dispatchTask as s, changeEvidenceSchema as t, standardTaskKinds as u, taskStateSchema as v };
229
-
230
- //# sourceMappingURL=change-CFNGXVqD.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-CFNGXVqD.mjs","names":[],"sources":["../src/schema/task.ts","../src/dispatch.ts","../src/schema/change.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n isoDateTimeSchema,\n replyToSchema,\n schemaVersionSchema,\n usdSchema,\n vocabularySchema,\n} from \"./common\";\nimport {\n changeIdSchema,\n repositoryIdSchema,\n repositoryIdsSchema,\n signalIdSchema,\n taskIdSchema,\n} from \"./id\";\n\n/**\n * Kinds the standard loop understands. Any vocabulary value is valid; the\n * kind-scoped rules below apply only to these standard kinds.\n */\nexport const standardTaskKinds = [\n \"coordination\",\n \"code_change\",\n \"verification\",\n \"investigation\",\n \"question\",\n] as const;\n\nexport const taskKindSchema = vocabularySchema.describe(\n \"What kind of work this is, e.g. code_change, question, or a registered custom kind.\",\n);\n\nexport const taskStateSchema = z\n .enum([\"queued\", \"running\", \"verifying\", \"succeeded\", \"failed\", \"needs_human\", \"cancelled\"])\n .describe(\"Lifecycle state. Transitions are fixed; see taskTransitions.\");\n\nexport const taskApprovalSchema = z\n .enum([\"required\", \"granted\", \"denied\"])\n .describe(\n \"Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator.\",\n );\n\nexport const taskExecutionRepositoryIdsSchema = z\n .tuple([repositoryIdSchema])\n .describe(\"The one repository used to execute a task.\");\n\nexport const coordinationRepositoryIdsSchema = z\n .tuple([repositoryIdSchema, repositoryIdSchema])\n .rest(repositoryIdSchema)\n .refine((repositoryIds) => new Set(repositoryIds).size === repositoryIds.length, {\n message: \"Coordination tasks require distinct repositories.\",\n })\n .describe(\"The distinct repositories coordinated by a non-executable parent task.\");\n\nexport const harnessSchema = z\n .string()\n .min(1)\n .describe(\"Coding harness used in the devbox, e.g. claude-code or codex.\");\n\nexport const taskOriginSchema = z\n .strictObject({\n signalId: signalIdSchema.optional().describe(\"Signal that led to this task.\"),\n parentTaskId: taskIdSchema.optional().describe(\"Parent task that planned this child.\"),\n operator: z.string().min(1).optional().describe(\"Human operator who requested it.\"),\n })\n .refine(\n (origin) =>\n origin.signalId !== undefined ||\n origin.parentTaskId !== undefined ||\n origin.operator !== undefined,\n { message: \"origin requires a signalId, parentTaskId, or operator\" },\n );\n\nexport const taskDevboxSchema = z.strictObject({\n devboxId: z.string().min(1).describe(\"Devbox running or having run this task.\"),\n remoteId: z.string().min(1).describe(\"Provider-side id of the execution.\"),\n harness: harnessSchema,\n});\n\nexport const taskQuestionSchema = z.strictObject({\n text: z.string().min(1).describe(\"The question a human must answer.\"),\n options: z.array(z.string().min(1)).describe(\"Suggested answers; free-text is also allowed.\"),\n answer: z.string().min(1).optional(),\n answeredBy: z.string().min(1).optional().describe(\"Authenticated operator who answered.\"),\n});\n\nexport const taskSchema = z\n .strictObject({\n schemaVersion: schemaVersionSchema,\n id: taskIdSchema,\n repositoryIds: repositoryIdsSchema.describe(\"Repositories the task concerns.\"),\n kind: taskKindSchema,\n area: z\n .string()\n .min(1)\n .optional()\n .describe(\"Investigation area, e.g. onboarding or security. Investigation tasks only.\"),\n state: taskStateSchema,\n approval: taskApprovalSchema.optional(),\n origin: taskOriginSchema,\n dependsOn: z\n .array(taskIdSchema)\n .min(1)\n .optional()\n .describe(\"Sibling tasks that must produce a change before this one may run.\"),\n replyTo: replyToSchema,\n devbox: taskDevboxSchema.optional(),\n attempt: z\n .number()\n .int()\n .min(1)\n .describe(\"Execution attempt, starting at 1; bumps on retry.\"),\n reservedUsd: usdSchema.optional().describe(\"Budget reserved before dispatch.\"),\n settledUsd: usdSchema.optional().describe(\"Measured cost settled after execution.\"),\n question: taskQuestionSchema.optional(),\n changeId: changeIdSchema.optional().describe(\"Change produced or verified by this task.\"),\n reportRef: z\n .string()\n .min(1)\n .optional()\n .describe(\"Reference to the report artifact an investigation produced.\"),\n createdAt: isoDateTimeSchema,\n updatedAt: isoDateTimeSchema,\n })\n .superRefine((task, ctx) => {\n if (\n task.kind === \"coordination\" &&\n !coordinationRepositoryIdsSchema.safeParse(task.repositoryIds).success\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"repositoryIds\"],\n message: \"coordination tasks require at least two distinct repositories\",\n });\n }\n if (\n (task.kind === \"code_change\" || task.kind === \"verification\") &&\n task.repositoryIds.length !== 1\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"repositoryIds\"],\n message: `${task.kind} tasks require exactly one repository`,\n });\n }\n if (task.area !== undefined && task.kind !== \"investigation\") {\n ctx.addIssue({\n code: \"custom\",\n path: [\"area\"],\n message: \"area is only valid on investigation tasks\",\n });\n }\n if (task.kind === \"question\") {\n if (task.question === undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"question\"],\n message: \"question tasks require a question\",\n });\n }\n if (task.devbox !== undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"devbox\"],\n message: \"question tasks never run in a devbox\",\n });\n }\n } else if (task.question !== undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"question\"],\n message: \"question is only valid on question tasks\",\n });\n }\n if (task.kind === \"coordination\" && task.devbox !== undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"devbox\"],\n message: \"coordination tasks never run in a devbox\",\n });\n }\n if (\n task.changeId !== undefined &&\n task.kind !== \"code_change\" &&\n task.kind !== \"verification\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"changeId\"],\n message: \"changeId is only valid on code_change or verification tasks\",\n });\n }\n if (task.reportRef !== undefined && task.kind !== \"investigation\") {\n ctx.addIssue({\n code: \"custom\",\n path: [\"reportRef\"],\n message: \"reportRef is only valid on investigation tasks\",\n });\n }\n });\n\nexport type TaskApproval = z.infer<typeof taskApprovalSchema>;\nexport type TaskKind = z.infer<typeof taskKindSchema>;\nexport type TaskState = z.infer<typeof taskStateSchema>;\nexport type Task = z.infer<typeof taskSchema>;\n","import type { TaskId } from \"./schema/id\";\nimport { taskExecutionRepositoryIdsSchema, type Task } from \"./schema/task\";\nimport { RecordNotFoundError } from \"./store/driver\";\nimport type { FactoryStores } from \"./store/engine\";\n\nexport class DispatchRefusedError extends Error {\n readonly taskId: TaskId;\n readonly reason: string;\n\n constructor(taskId: TaskId, reason: string) {\n super(`dispatch of \"${taskId}\" refused: ${reason}`);\n this.name = \"DispatchRefusedError\";\n this.taskId = taskId;\n this.reason = reason;\n }\n}\n\nexport interface DispatchOptions {\n /**\n * Starts the durable execution for the task (an Eve agent run). Runs after\n * the task has won the queued -> running transition. The execution owns its\n * own provisioning: it creates its Devbox as its first step and patches the\n * task record with the result.\n */\n launch: (task: Task) => Promise<void>;\n /** How many launches to try before the task fails for good; a failure re-queues for the next sweep. */\n maxLaunchAttempts?: number;\n}\n\n// A fresh Vercel project rejects its own agents' sessions until its identity\n// finishes provisioning; at one sweep per minute the budget must outlast that.\nexport const DEFAULT_MAX_LAUNCH_ATTEMPTS = 45;\n\n/**\n * The handshake between recorded work and execution: win the store-gated\n * transition (at most one dispatcher can succeed), then start the run. A\n * launch failure re-queues the task (bumping its attempt) until the attempt\n * limit, then fails it; a crash between the transition and the launch leaves\n * a running task with no execution, which the sweep reaps.\n */\nexport async function dispatchTask(\n stores: FactoryStores,\n taskId: TaskId,\n options: DispatchOptions,\n): Promise<Task> {\n const task = await stores.tasks.get(taskId);\n if (task === null) {\n throw new RecordNotFoundError(\"tasks\", taskId);\n }\n if (task.kind === \"question\") {\n throw new DispatchRefusedError(taskId, \"question tasks are answered, not dispatched\");\n }\n if (task.kind === \"coordination\") {\n throw new DispatchRefusedError(taskId, \"coordination tasks are reconciled, not dispatched\");\n }\n if (!taskExecutionRepositoryIdsSchema.safeParse(task.repositoryIds).success) {\n throw new DispatchRefusedError(taskId, \"task execution requires exactly one repository\");\n }\n if (task.approval === \"required\") {\n throw new DispatchRefusedError(taskId, \"awaiting human approval\");\n }\n if (task.approval === \"denied\") {\n throw new DispatchRefusedError(taskId, \"approval was denied\");\n }\n for (const dependencyId of task.dependsOn ?? []) {\n const dependency = await stores.tasks.get(dependencyId);\n if (dependency === null) {\n throw new DispatchRefusedError(taskId, `dependency \"${dependencyId}\" does not exist`);\n }\n if (dependency.changeId === undefined) {\n throw new DispatchRefusedError(\n taskId,\n `dependency \"${dependencyId}\" has not produced a change`,\n );\n }\n }\n\n const running = await stores.tasks.transition(taskId, \"running\");\n try {\n await options.launch(running);\n } catch (error) {\n const reason = (error instanceof Error ? error.message : String(error)).slice(0, 500);\n const limit = options.maxLaunchAttempts ?? DEFAULT_MAX_LAUNCH_ATTEMPTS;\n if (running.attempt < limit) {\n const retryReason = `launch failed (attempt ${running.attempt} of ${limit}), will retry: ${reason}`;\n await stores.tasks.transition(taskId, \"queued\", { reason: retryReason }).catch(() => undefined);\n // The queued transition writes no receipt; leave one so the retry is visible.\n if (running.repositoryIds !== undefined) {\n await stores.receipts\n .append({\n repositoryIds: running.repositoryIds,\n taskId,\n kind: \"task\",\n state: \"launch_retry\",\n reason: retryReason,\n dedupeKey: `task:${taskId}:launch_retry:${running.attempt}`,\n })\n .catch(() => undefined);\n }\n } else {\n await stores.tasks\n .transition(taskId, \"failed\", { reason: `launch failed after ${running.attempt} attempts: ${reason}` })\n .catch(() => undefined);\n }\n throw error;\n }\n return running;\n}\n","import { z } from \"zod\";\nimport { isoDateTimeSchema, schemaVersionSchema } from \"./common\";\nimport { changeIdSchema, repositoryIdSchema, taskIdSchema } from \"./id\";\n\nexport const levelSchema = z.enum([\"low\", \"medium\", \"high\"]);\n\nexport const changeStateSchema = z.enum([\n \"verifying\",\n \"ready\",\n \"merged\",\n \"deployed\",\n \"rolled_out\",\n \"rolled_back\",\n \"closed\",\n]);\n\nconst postMergeStates: readonly string[] = [\"merged\", \"deployed\", \"rolled_out\", \"rolled_back\"];\n\nexport const changeEvidenceSchema = z.strictObject({\n reproVerified: z.boolean(),\n testsAdded: z.number().int().min(0),\n checksGreen: z.boolean(),\n attackPassed: z.boolean(),\n scopeMatches: z.boolean(),\n previewUrl: z.url().optional(),\n});\n\nexport const changeSchema = z\n .strictObject({\n schemaVersion: schemaVersionSchema,\n id: changeIdSchema,\n repositoryId: repositoryIdSchema,\n taskId: taskIdSchema.optional(),\n groupId: taskIdSchema.optional(),\n prNumber: z.number().int().min(1),\n prUrl: z.url(),\n author: z.string().min(1),\n risk: levelSchema,\n confidence: levelSchema,\n evidence: changeEvidenceSchema,\n state: changeStateSchema,\n mergeSha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .optional()\n .describe(\"Merge commit sha recorded when the pull request merges, matched against production deployments.\"),\n decidedBy: z.string().min(1).optional(),\n createdAt: isoDateTimeSchema,\n updatedAt: isoDateTimeSchema,\n })\n .superRefine((change, ctx) => {\n if (postMergeStates.includes(change.state) && change.decidedBy === undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"decidedBy\"],\n message: `${change.state} changes require decidedBy`,\n });\n }\n });\n\nexport type Level = z.infer<typeof levelSchema>;\nexport type ChangeState = z.infer<typeof changeStateSchema>;\nexport type ChangeEvidence = z.infer<typeof changeEvidenceSchema>;\nexport type Change = z.infer<typeof changeSchema>;\n"],"mappings":";;;;;;;;AAoBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAiB,iBAAiB,SAC7C,qFACF;AAEA,MAAa,kBAAkB,EAC5B,KAAK;CAAC;CAAU;CAAW;CAAa;CAAa;CAAU;CAAe;AAAW,CAAC,CAAC,CAC3F,SAAS,8DAA8D;AAE1E,MAAa,qBAAqB,EAC/B,KAAK;CAAC;CAAY;CAAW;AAAQ,CAAC,CAAC,CACvC,SACC,sIACF;AAEF,MAAa,mCAAmC,EAC7C,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAC3B,SAAS,4CAA4C;AAExD,MAAa,kCAAkC,EAC5C,MAAM,CAAC,oBAAoB,kBAAkB,CAAC,CAAC,CAC/C,KAAK,kBAAkB,CAAC,CACxB,QAAQ,kBAAkB,IAAI,IAAI,aAAa,CAAC,CAAC,SAAS,cAAc,QAAQ,EAC/E,SAAS,oDACX,CAAC,CAAC,CACD,SAAS,wEAAwE;AAEpF,MAAa,gBAAgB,EAC1B,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,+DAA+D;AAE3E,MAAa,mBAAmB,EAC7B,aAAa;CACZ,UAAU,eAAe,SAAS,CAAC,CAAC,SAAS,+BAA+B;CAC5E,cAAc,aAAa,SAAS,CAAC,CAAC,SAAS,sCAAsC;CACrF,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,kCAAkC;AACpF,CAAC,CAAC,CACD,QACE,WACC,OAAO,aAAa,KAAA,KACpB,OAAO,iBAAiB,KAAA,KACxB,OAAO,aAAa,KAAA,GACtB,EAAE,SAAS,wDAAwD,CACrE;AAEF,MAAa,mBAAmB,EAAE,aAAa;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,IAAI,CAAC;CAChC,OAAO,EAAE,IAAI;CACb,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACxB,MAAM;CACN,YAAY;CACZ,UAAU;CACV,OAAO;CACP,UAAU,EACP,OAAO,CAAC,CACR,MAAM,gBAAgB,CAAC,CACvB,SAAS,CAAC,CACV,SAAS,iGAAiG;CAC7G,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CACtC,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CACD,aAAa,QAAQ,QAAQ;CAC5B,IAAI,gBAAgB,SAAS,OAAO,KAAK,KAAK,OAAO,cAAc,KAAA,GACjE,IAAI,SAAS;EACX,MAAM;EACN,MAAM,CAAC,WAAW;EAClB,SAAS,GAAG,OAAO,MAAM;CAC3B,CAAC;AAEL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-config-ifd3JxiU.mjs","names":[],"sources":["../src/schema/repository.ts","../src/schema/factory-config.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isoDateTimeSchema, schemaVersionSchema } from \"./common\";\nimport { repositoryIdSchema } from \"./id\";\n\nexport const repositorySlugSchema = z\n .string()\n .regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?\\/[a-z0-9._-]+$/)\n .describe(\"owner/name, lowercase, e.g. acme/web.\");\n\nexport const repositorySchema = z.strictObject({\n schemaVersion: schemaVersionSchema,\n id: repositoryIdSchema,\n slug: repositorySlugSchema,\n defaultBranch: z.string().min(1).describe(\"Branch changes land on, usually main.\"),\n enabled: z.boolean().describe(\"Whether the factory may work on this repository.\"),\n dependsOn: z\n .array(repositorySlugSchema)\n .describe(\"Slugs of repositories this one consumes, for multi-repo work ordering.\"),\n devbox: z\n .strictObject({\n projectId: z.string().min(1),\n teamId: z.string().min(1),\n snapshot: z.string().min(1).optional().describe(\"Prebuilt snapshot to boot from.\"),\n })\n .optional()\n .describe(\"Devbox execution config. Absent when this repository never uses devboxes.\"),\n connectedAt: isoDateTimeSchema,\n});\n\nexport type RepositorySlug = z.infer<typeof repositorySlugSchema>;\nexport type Repository = z.infer<typeof repositorySchema>;\n","import { z } from \"zod\";\nimport { approvalPolicySchema, defaultApprovalPolicy } from \"../approval\";\nimport { repositorySlugSchema } from \"./repository\";\n\nexport const factoryConfigRepositorySchema = z.strictObject({\n slug: repositorySlugSchema.describe(\"Repository this factory may work on.\"),\n dependsOn: z\n .array(repositorySlugSchema)\n .default([])\n .describe(\"Repositories that must land changes before this repository.\"),\n});\n\nconst githubConnectorSchema = z.strictObject({\n owner: z\n .string()\n .regex(/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)\n .describe(\"GitHub user or organization that owns this connector installation.\"),\n connector: z\n .string()\n .regex(/^github\\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)\n .describe(\"Vercel Connect UID installed for this GitHub owner.\"),\n});\n\nconst slackConnectorSchema = z.strictObject({\n connector: z\n .string()\n .regex(/^slack\\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)\n .describe(\"Vercel Connect UID installed for this Slack app.\"),\n});\n\nexport const factoryConfigSchema = z.strictObject({\n connectors: z\n .strictObject({\n github: z\n .array(githubConnectorSchema)\n .refine(\n (connectors) => new Set(connectors.map(({ owner }) => owner)).size === connectors.length,\n \"GitHub connector owners must be unique.\",\n ),\n slack: z\n .array(slackConnectorSchema)\n .max(1, \"A factory may configure one Slack connector.\")\n .default([]),\n })\n .default({ github: [], slack: [] })\n .describe(\"Provider connections available to this factory.\"),\n repositories: z\n .array(factoryConfigRepositorySchema)\n .min(1)\n .describe(\"Repositories this factory is allowed to inspect and change.\"),\n operators: z\n .array(z.string().min(1))\n .min(1)\n .describe(\"Provider-qualified identities allowed to operate this factory.\"),\n approval: approvalPolicySchema\n .default(defaultApprovalPolicy)\n .describe(\"Which tasks wait for a human before they run. First match wins.\"),\n});\n\nexport type FactoryConfig = z.infer<typeof factoryConfigSchema>;\nexport type FactoryConfigInput = z.input<typeof factoryConfigSchema>;\n\nexport function defineFactory(config: FactoryConfigInput): FactoryConfig {\n return factoryConfigSchema.parse(config);\n}\n"],"mappings":";;;;AAIA,MAAa,uBAAuB,EACjC,OAAO,CAAC,CACR,MAAM,+CAA+C,CAAC,CACtD,SAAS,uCAAuC;AAEnD,MAAa,mBAAmB,EAAE,aAAa;CAC7C,eAAe;CACf,IAAI;CACJ,MAAM;CACN,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,uCAAuC;CACjF,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS,kDAAkD;CAChF,WAAW,EACR,MAAM,oBAAoB,CAAC,CAC3B,SAAS,wEAAwE;CACpF,QAAQ,EACL,aAAa;EACZ,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EAC3B,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EACxB,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,iCAAiC;CACnF,CAAC,CAAC,CACD,SAAS,CAAC,CACV,SAAS,2EAA2E;CACvF,aAAa;AACf,CAAC;;;ACvBD,MAAa,gCAAgC,EAAE,aAAa;CAC1D,MAAM,qBAAqB,SAAS,sCAAsC;CAC1E,WAAW,EACR,MAAM,oBAAoB,CAAC,CAC3B,QAAQ,CAAC,CAAC,CAAC,CACX,SAAS,6DAA6D;AAC3E,CAAC;AAED,MAAM,wBAAwB,EAAE,aAAa;CAC3C,OAAO,EACJ,OAAO,CAAC,CACR,MAAM,mCAAmC,CAAC,CAC1C,SAAS,oEAAoE;CAChF,WAAW,EACR,OAAO,CAAC,CACR,MAAM,2CAA2C,CAAC,CAClD,SAAS,qDAAqD;AACnE,CAAC;AAED,MAAM,uBAAuB,EAAE,aAAa,EAC1C,WAAW,EACR,OAAO,CAAC,CACR,MAAM,0CAA0C,CAAC,CACjD,SAAS,kDAAkD,EAChE,CAAC;AAED,MAAa,sBAAsB,EAAE,aAAa;CAChD,YAAY,EACT,aAAa;EACZ,QAAQ,EACL,MAAM,qBAAqB,CAAC,CAC5B,QACE,eAAe,IAAI,IAAI,WAAW,KAAK,EAAE,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,WAAW,QAClF,yCACF;EACF,OAAO,EACJ,MAAM,oBAAoB,CAAC,CAC3B,IAAI,GAAG,8CAA8C,CAAC,CACtD,QAAQ,CAAC,CAAC;CACf,CAAC,CAAC,CACD,QAAQ;EAAE,QAAQ,CAAC;EAAG,OAAO,CAAC;CAAE,CAAC,CAAC,CAClC,SAAS,iDAAiD;CAC7D,cAAc,EACX,MAAM,6BAA6B,CAAC,CACpC,IAAI,CAAC,CAAC,CACN,SAAS,6DAA6D;CACzE,WAAW,EACR,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACxB,IAAI,CAAC,CAAC,CACN,SAAS,gEAAgE;CAC5E,UAAU,qBACP,QAAQ,qBAAqB,CAAC,CAC9B,SAAS,iEAAiE;AAC/E,CAAC;AAKD,SAAgB,cAAc,QAA2C;CACvE,OAAO,oBAAoB,MAAM,MAAM;AACzC"}
@@ -1,67 +0,0 @@
1
- import { c as ReplyTo, r as SignalSource } from "./signal-CHVEmzvI.mjs";
2
- import { z } from "zod";
3
- //#region src/connectors/index.d.ts
4
- interface WebhookEvent {
5
- deliveryId: string;
6
- event: string;
7
- payload: unknown;
8
- }
9
- interface NormalizedSignal<TSource extends SignalSource = SignalSource> {
10
- source: TSource;
11
- deliveryId: string;
12
- replyTo: ReplyTo;
13
- payload: unknown;
14
- }
15
- type SignalNormalizer<TSignal extends NormalizedSignal = NormalizedSignal> = (event: WebhookEvent) => TSignal | null;
16
- declare const communicationOutcomes: readonly ["accepted", "started", "succeeded", "failed", "needs_human", "question", "digest", "rolled_back", "budget_warning", "budget_exhausted", "message"];
17
- declare const communicationOutcomeSchema: z.ZodEnum<{
18
- message: "message";
19
- succeeded: "succeeded";
20
- failed: "failed";
21
- needs_human: "needs_human";
22
- question: "question";
23
- accepted: "accepted";
24
- rolled_back: "rolled_back";
25
- started: "started";
26
- digest: "digest";
27
- budget_warning: "budget_warning";
28
- budget_exhausted: "budget_exhausted";
29
- }>;
30
- declare const communicationEventSchema: z.ZodObject<{
31
- eventId: z.ZodString;
32
- repositoryIds: z.ZodArray<z.ZodString>;
33
- taskId: z.ZodOptional<z.ZodString>;
34
- changeId: z.ZodOptional<z.ZodString>;
35
- replyTo: z.ZodObject<{
36
- channel: z.ZodString;
37
- address: z.ZodString;
38
- }, z.core.$strict>;
39
- outcome: z.ZodEnum<{
40
- message: "message";
41
- succeeded: "succeeded";
42
- failed: "failed";
43
- needs_human: "needs_human";
44
- question: "question";
45
- accepted: "accepted";
46
- rolled_back: "rolled_back";
47
- started: "started";
48
- digest: "digest";
49
- budget_warning: "budget_warning";
50
- budget_exhausted: "budget_exhausted";
51
- }>;
52
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
53
- }, z.core.$strict>;
54
- type CommunicationOutcome = z.infer<typeof communicationOutcomeSchema>;
55
- type CommunicationEvent = z.infer<typeof communicationEventSchema>;
56
- interface CommunicationAdapter {
57
- readonly channel: string;
58
- deliver(event: CommunicationEvent): Promise<void>;
59
- }
60
- interface CommunicationRouter {
61
- readonly channels: readonly string[];
62
- deliver(event: CommunicationEvent): Promise<void>;
63
- }
64
- declare function createCommunicationRouter(adapters: readonly CommunicationAdapter[]): CommunicationRouter;
65
- //#endregion
66
- export { NormalizedSignal as a, communicationEventSchema as c, createCommunicationRouter as d, CommunicationRouter as i, communicationOutcomeSchema as l, CommunicationEvent as n, SignalNormalizer as o, CommunicationOutcome as r, WebhookEvent as s, CommunicationAdapter as t, communicationOutcomes as u };
67
- //# sourceMappingURL=index-Cy4jfXh5.d.mts.map
@@ -1,59 +0,0 @@
1
- import { z } from "zod";
2
- //#region src/schema/common.d.ts
3
- declare const SCHEMA_VERSION = 1;
4
- declare const schemaVersionSchema: z.ZodLiteral<1>;
5
- declare const isoDateTimeSchema: z.ZodISODateTime;
6
- declare const usdSchema: z.ZodNumber;
7
- /**
8
- * Open vocabulary value. Standard values ship as exported constants; custom
9
- * values matching the pattern are equally valid.
10
- */
11
- declare const vocabularySchema: z.ZodString;
12
- declare const replyToSchema: z.ZodObject<{
13
- channel: z.ZodString;
14
- address: z.ZodString;
15
- }, z.core.$strict>;
16
- type ReplyTo = z.infer<typeof replyToSchema>;
17
- //#endregion
18
- //#region src/schema/signal.d.ts
19
- /** Sources used by the standard connectors. Any vocabulary value is valid. */
20
- declare const standardSignalSources: readonly ["github_issue", "github_pr", "github_pr_comment", "slack", "human", "github_ci_failure", "vercel_deploy_failure", "security_scan", "investigation", "api"];
21
- declare const signalSourceSchema: z.ZodString;
22
- declare const signalOutcomeSchema: z.ZodEnum<{
23
- accepted: "accepted";
24
- duplicate: "duplicate";
25
- unactionable: "unactionable";
26
- low_confidence: "low_confidence";
27
- ignored: "ignored";
28
- pending: "pending";
29
- }>;
30
- declare const signalSchema: z.ZodObject<{
31
- schemaVersion: z.ZodLiteral<1>;
32
- id: z.ZodString;
33
- repositoryId: z.ZodString;
34
- source: z.ZodString;
35
- deliveryId: z.ZodString;
36
- replyTo: z.ZodObject<{
37
- channel: z.ZodString;
38
- address: z.ZodString;
39
- }, z.core.$strict>;
40
- payload: z.ZodUnknown;
41
- receivedAt: z.ZodISODateTime;
42
- outcome: z.ZodEnum<{
43
- accepted: "accepted";
44
- duplicate: "duplicate";
45
- unactionable: "unactionable";
46
- low_confidence: "low_confidence";
47
- ignored: "ignored";
48
- pending: "pending";
49
- }>;
50
- detail: z.ZodOptional<z.ZodString>;
51
- reason: z.ZodOptional<z.ZodString>;
52
- decidedAt: z.ZodOptional<z.ZodISODateTime>;
53
- }, z.core.$strict>;
54
- type SignalSource = z.infer<typeof signalSourceSchema>;
55
- type SignalOutcome = z.infer<typeof signalOutcomeSchema>;
56
- type Signal = z.infer<typeof signalSchema>;
57
- //#endregion
58
- export { signalSchema as a, ReplyTo as c, replyToSchema as d, schemaVersionSchema as f, signalOutcomeSchema as i, SCHEMA_VERSION as l, vocabularySchema as m, SignalOutcome as n, signalSourceSchema as o, usdSchema as p, SignalSource as r, standardSignalSources as s, Signal as t, isoDateTimeSchema as u };
59
- //# sourceMappingURL=signal-CHVEmzvI.d.mts.map