@vercel/factory 0.0.2 → 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 (63) 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 +28 -21
  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-CEF6VJZC.js +0 -28
  42. package/dist/chunk-CEF6VJZC.js.map +0 -1
  43. package/dist/chunk-LBEYCOSR.js +0 -351
  44. package/dist/chunk-LBEYCOSR.js.map +0 -1
  45. package/dist/common-CaHaEOAS.d.ts +0 -18
  46. package/dist/connectors/github.d.ts +0 -62
  47. package/dist/connectors/github.js +0 -112
  48. package/dist/connectors/github.js.map +0 -1
  49. package/dist/driver-tRNggCCJ.d.ts +0 -32
  50. package/dist/eve/index.d.ts +0 -962
  51. package/dist/eve/index.js +0 -601
  52. package/dist/eve/index.js.map +0 -1
  53. package/dist/index.d.ts +0 -164
  54. package/dist/index.js +0 -938
  55. package/dist/index.js.map +0 -1
  56. package/dist/next-page.d.ts +0 -5
  57. package/dist/next-page.js +0 -75
  58. package/dist/next-page.js.map +0 -1
  59. package/dist/next.d.ts +0 -12
  60. package/dist/next.js.map +0 -1
  61. package/dist/postgres/index.d.ts +0 -137
  62. package/dist/postgres/index.js +0 -118
  63. package/dist/postgres/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/blob/index.ts"],"sourcesContent":["import { get, head, list, put } from \"@vercel/blob\";\nimport {\n RecordExistsError,\n RecordNotFoundError,\n VersionConflictError,\n type CollectionName,\n type StoredEntry,\n type StoreDriver,\n} from \"../store/driver\";\n\n/** The narrow blob operations the driver needs; injectable for tests. */\nexport interface BlobClient {\n read(pathname: string): Promise<string | null>;\n /** Must reject with an already-exists error when overwrite is false and the path exists. */\n write(pathname: string, body: string, overwrite: boolean): Promise<void>;\n listPaths(prefix: string): Promise<string[]>;\n}\n\n// @vercel/blob throws BlobNotFoundError with the message\n// \"Vercel Blob: The requested blob does not exist\".\nfunction isNotFoundError(error: unknown): boolean {\n return (\n error instanceof Error &&\n (error.name === \"BlobNotFoundError\" ||\n /does not exist|not.?found|404/iu.test(error.message))\n );\n}\n\nfunction isAlreadyExistsError(error: unknown): boolean {\n return (\n error instanceof Error &&\n /already exists|not allowed to overwrite|overwrite/iu.test(error.message)\n );\n}\n\nexport const vercelBlobClient: BlobClient = {\n async read(pathname) {\n let url: string;\n try {\n url = (await head(pathname)).url;\n } catch (error) {\n if (isNotFoundError(error)) {\n return null;\n }\n throw error;\n }\n const result = await get(url, { access: \"private\" });\n if (result === null) {\n return null;\n }\n return new Response(result.stream).text();\n },\n\n async write(pathname, body, overwrite) {\n await put(pathname, body, {\n access: \"private\",\n allowOverwrite: overwrite,\n contentType: \"application/json\",\n });\n },\n\n async listPaths(prefix) {\n const paths: string[] = [];\n let cursor: string | undefined;\n do {\n const page = await list({ prefix, cursor, limit: 1000 });\n paths.push(...page.blobs.map((blob) => blob.pathname));\n cursor = page.hasMore ? page.cursor : undefined;\n } while (cursor !== undefined);\n return paths;\n },\n};\n\nexport interface BlobDriverOptions {\n client?: BlobClient;\n /** Path prefix inside the blob store; defaults to \"factory\". */\n prefix?: string;\n}\n\n/**\n * Store driver on Vercel Blob: durable and dependency-free (one Blob store on\n * the project, no database). Inserts and receipts are exactly as safe as on\n * Postgres (create-if-absent is atomic). The compare-and-swap update is\n * BEST-EFFORT: the version check reads then writes without a lock, so two\n * simultaneous writers can race. Acceptable for low-volume factories; use the\n * Postgres driver when concurrent dispatchers are expected.\n */\nexport function createBlobDriver(options: BlobDriverOptions = {}): StoreDriver {\n const client = options.client ?? vercelBlobClient;\n const prefix = options.prefix ?? \"factory\";\n\n function pathFor(collection: CollectionName, id: string): string {\n return `${prefix}/${collection}/${id}.json`;\n }\n\n async function readRecord(\n collection: CollectionName,\n id: string,\n ): Promise<{ value: unknown; version: number } | null> {\n let text: string | null;\n try {\n text = await client.read(pathFor(collection, id));\n } catch (error) {\n if (isNotFoundError(error)) {\n return null;\n }\n throw error;\n }\n if (text === null) {\n return null;\n }\n const parsed = JSON.parse(text) as { value: unknown; version: number };\n if (typeof parsed.version !== \"number\") {\n throw new Error(`malformed stored record at ${pathFor(collection, id)}`);\n }\n return parsed;\n }\n\n return {\n name: \"blob\",\n\n get(collection, id) {\n return readRecord(collection, id);\n },\n\n async insert(collection, id, value) {\n try {\n await client.write(\n pathFor(collection, id),\n JSON.stringify({ value, version: 1 }),\n false,\n );\n } catch (error) {\n if (isAlreadyExistsError(error)) {\n throw new RecordExistsError(collection, id);\n }\n throw error;\n }\n },\n\n async update(collection, id, value, expectedVersion) {\n const existing = await readRecord(collection, id);\n if (existing === null) {\n throw new RecordNotFoundError(collection, id);\n }\n if (existing.version !== expectedVersion) {\n throw new VersionConflictError(collection, id, expectedVersion);\n }\n await client.write(\n pathFor(collection, id),\n JSON.stringify({ value, version: expectedVersion + 1 }),\n true,\n );\n },\n\n async list(collection) {\n const dir = `${prefix}/${collection}/`;\n const paths = await client.listPaths(dir);\n const entries: StoredEntry[] = [];\n for (const pathname of paths) {\n const id = pathname.slice(dir.length).replace(/\\.json$/u, \"\");\n const record = await readRecord(collection, id);\n if (record !== null) {\n entries.push({ id, record });\n }\n }\n return entries;\n },\n };\n}\n"],"mappings":";;;;;;;AAAA,SAAS,KAAK,MAAM,MAAM,WAAW;AAoBrC,SAAS,gBAAgB,OAAyB;AAChD,SACE,iBAAiB,UAChB,MAAM,SAAS,uBACd,kCAAkC,KAAK,MAAM,OAAO;AAE1D;AAEA,SAAS,qBAAqB,OAAyB;AACrD,SACE,iBAAiB,SACjB,sDAAsD,KAAK,MAAM,OAAO;AAE5E;AAEO,IAAM,mBAA+B;AAAA,EAC1C,MAAM,KAAK,UAAU;AACnB,QAAI;AACJ,QAAI;AACF,aAAO,MAAM,KAAK,QAAQ,GAAG;AAAA,IAC/B,SAAS,OAAO;AACd,UAAI,gBAAgB,KAAK,GAAG;AAC1B,eAAO;AAAA,MACT;AACA,YAAM;AAAA,IACR;AACA,UAAM,SAAS,MAAM,IAAI,KAAK,EAAE,QAAQ,UAAU,CAAC;AACnD,QAAI,WAAW,MAAM;AACnB,aAAO;AAAA,IACT;AACA,WAAO,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AA,IAClC;AAAA,IAEA,MAAM,OAAO,YAAY,IAAI,OAAO;AAClC,UAAI;AACF,cAAM,OAAO;AAAA,UACX,QAAQ,YAAY,EAAE;AAAA,UACtB,KAAK,UAAU,EAAE,OAAO,SAAS,EAAE,CAAC;AAAA,UACpC;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,YAAI,qBAAqB,KAAK,GAAG;AAC/B,gBAAM,IAAI,kBAAkB,YAAY,EAAE;AAAA,QAC5C;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,MAAM,OAAO,YAAY,IAAI,OAAO,iBAAiB;AACnD,YAAM,WAAW,MAAM,WAAW,YAAY,EAAE;AAChD,UAAI,aAAa,MAAM;AACrB,cAAM,IAAI,oBAAoB,YAAY,EAAE;AAAA,MAC9C;AACA,UAAI,SAAS,YAAY,iBAAiB;AACxC,cAAM,IAAI,qBAAqB,YAAY,IAAI,eAAe;AAAA,MAChE;AACA,YAAM,OAAO;AAAA,QACX,QAAQ,YAAY,EAAE;AAAA,QACtB,KAAK,UAAU,EAAE,OAAO,SAAS,kBAAkB,EAAE,CAAC;AAAA,QACtD;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,KAAK,YAAY;AACrB,YAAM,MAAM,GAAG,MAAM,IAAI,UAAU;AACnC,YAAM,QAAQ,MAAM,OAAO,UAAU,GAAG;AACxC,YAAM,UAAyB,CAAC;AAChC,iBAAW,YAAY,OAAO;AAC5B,cAAM,KAAK,SAAS,MAAM,IAAI,MAAM,EAAE,QAAQ,YAAY,EAAE;AAC5D,cAAM,SAAS,MAAM,WAAW,YAAY,EAAE;AAC9C,YAAI,WAAW,MAAM;AACnB,kBAAQ,KAAK,EAAE,IAAI,OAAO,CAAC;AAAA,QAC7B;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1,28 +0,0 @@
1
- // src/store/driver.ts
2
- var RecordExistsError = class extends Error {
3
- constructor(collection, id) {
4
- super(`record "${id}" already exists in "${collection}"`);
5
- this.name = "RecordExistsError";
6
- }
7
- };
8
- var RecordNotFoundError = class extends Error {
9
- constructor(collection, id) {
10
- super(`record "${id}" not found in "${collection}"`);
11
- this.name = "RecordNotFoundError";
12
- }
13
- };
14
- var VersionConflictError = class extends Error {
15
- constructor(collection, id, expectedVersion) {
16
- super(
17
- `record "${id}" in "${collection}" changed since version ${expectedVersion} was read`
18
- );
19
- this.name = "VersionConflictError";
20
- }
21
- };
22
-
23
- export {
24
- RecordExistsError,
25
- RecordNotFoundError,
26
- VersionConflictError
27
- };
28
- //# sourceMappingURL=chunk-CEF6VJZC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/store/driver.ts"],"sourcesContent":["export type CollectionName = \"repositories\" | \"signals\" | \"tasks\" | \"changes\" | \"receipts\";\n\nexport interface StoredRecord {\n readonly value: unknown;\n readonly version: number;\n}\n\nexport interface StoredEntry {\n readonly id: string;\n readonly record: StoredRecord;\n}\n\nexport class RecordExistsError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" already exists in \"${collection}\"`);\n this.name = \"RecordExistsError\";\n }\n}\n\nexport class RecordNotFoundError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" not found in \"${collection}\"`);\n this.name = \"RecordNotFoundError\";\n }\n}\n\nexport class VersionConflictError extends Error {\n constructor(collection: CollectionName, id: string, expectedVersion: number) {\n super(\n `record \"${id}\" in \"${collection}\" changed since version ${expectedVersion} was read`,\n );\n this.name = \"VersionConflictError\";\n }\n}\n\n/**\n * Raw persistence contract. Drivers store opaque values and enforce nothing\n * about their content; every invariant lives in the engine above. `update`\n * must be an atomic compare-and-swap on `expectedVersion`.\n */\nexport interface StoreDriver {\n readonly name: string;\n get(collection: CollectionName, id: string): Promise<StoredRecord | null>;\n insert(collection: CollectionName, id: string, value: unknown): Promise<void>;\n update(\n collection: CollectionName,\n id: string,\n value: unknown,\n expectedVersion: number,\n ): Promise<void>;\n list(collection: CollectionName): Promise<readonly StoredEntry[]>;\n}\n"],"mappings":";AAYO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAAY,YAA4B,IAAY;AAClD,UAAM,WAAW,EAAE,wBAAwB,UAAU,GAAG;AACxD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7C,YAAY,YAA4B,IAAY;AAClD,UAAM,WAAW,EAAE,mBAAmB,UAAU,GAAG;AACnD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,YAAY,YAA4B,IAAY,iBAAyB;AAC3E;AAAA,MACE,WAAW,EAAE,SAAS,UAAU,2BAA2B,eAAe;AAAA,IAC5E;AACA,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,351 +0,0 @@
1
- import {
2
- RecordNotFoundError
3
- } from "./chunk-CEF6VJZC.js";
4
-
5
- // src/schema/common.ts
6
- import { z } from "zod";
7
- var SCHEMA_VERSION = 1;
8
- var schemaVersionSchema = z.literal(SCHEMA_VERSION).describe("Version of the entity schema this row was written with.");
9
- var isoDateTimeSchema = z.iso.datetime().describe("UTC timestamp in ISO 8601 format, e.g. 2026-08-26T12:00:00Z.");
10
- var usdSchema = z.number().finite().nonnegative().describe("Amount in US dollars.");
11
- var vocabularySchema = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/, "must be lowercase snake_case starting with a letter").describe("Lowercase snake_case name, e.g. github_issue or sentry_alert.");
12
- var replyToSchema = z.strictObject({
13
- channel: z.string().min(1).describe("Connector that should carry replies, e.g. github or slack."),
14
- address: z.string().min(1).describe("Connector-specific reply address, e.g. acme/web#41 or a Slack thread id.")
15
- });
16
-
17
- // src/schema/finding.ts
18
- import { createHash } from "crypto";
19
- import { z as z2 } from "zod";
20
- var findingPrioritySchema = z2.enum(["P0", "P1", "P2", "P3"]).describe("Urgency of a finding: P0 is drop-everything, P3 is nice-to-have.");
21
- var findingCategorySchema = z2.enum([
22
- "security",
23
- "correctness",
24
- "reliability",
25
- "performance",
26
- "compatibility",
27
- "accessibility",
28
- "documentation",
29
- "maintainability",
30
- "testing",
31
- "usability"
32
- ]);
33
- var findingVerificationLevelSchema = z2.enum(["unverified", "supported", "confirmed"]).describe(
34
- "How sure the reporter is: unverified = suspected from reading; supported = evidence points to it; confirmed = demonstrated."
35
- );
36
- var findingVerificationMethodSchema = z2.enum([
37
- "code_inspection",
38
- "static_analysis",
39
- "manual_reproduction",
40
- "unit_test",
41
- "integration_test",
42
- "e2e_test",
43
- "runtime_observation",
44
- "documentation"
45
- ]);
46
- var findingVerificationSchema = z2.strictObject({
47
- level: findingVerificationLevelSchema,
48
- method: findingVerificationMethodSchema,
49
- summary: z2.string().min(1).max(2e3).describe("What was checked and what it showed."),
50
- limitations: z2.string().min(1).max(2e3).optional().describe("What could not be checked.")
51
- });
52
- var findingSchema = z2.strictObject({
53
- title: z2.string().min(1).max(200),
54
- body: z2.string().min(1).max(8e3).describe("The problem, its impact, and how to fix it. Markdown."),
55
- path: z2.string().min(1).max(500).optional().describe("Repository-relative file path."),
56
- line: z2.number().int().min(1).optional(),
57
- endLine: z2.number().int().min(1).optional(),
58
- priority: findingPrioritySchema,
59
- category: findingCategorySchema,
60
- verification: findingVerificationSchema,
61
- tool: z2.string().min(1).max(100).optional().describe("Scanner that produced it, e.g. deepsec."),
62
- ruleId: z2.string().min(1).max(200).optional().describe("Scanner rule or check id, when there is one.")
63
- });
64
- function findingFingerprint(repositoryId, finding) {
65
- const parts = finding.tool !== void 0 && finding.ruleId !== void 0 && finding.path !== void 0 ? [repositoryId, finding.tool, finding.ruleId, finding.path] : [
66
- repositoryId,
67
- finding.tool ?? "",
68
- finding.ruleId ?? "",
69
- finding.path ?? "",
70
- finding.title.trim().toLowerCase().replaceAll(/\s+/gu, " ")
71
- ];
72
- return createHash("sha256").update(parts.join(" ")).digest("hex").slice(0, 32);
73
- }
74
-
75
- // src/approval.ts
76
- import { z as z3 } from "zod";
77
- var approvalRuleSchema = z3.strictObject({
78
- source: vocabularySchema.optional().describe("Signal source, e.g. security_scan or github_issue."),
79
- kind: vocabularySchema.optional().describe("Task kind, e.g. code_change."),
80
- priority: z3.array(findingPrioritySchema).min(1).optional().describe("Finding priorities the rule applies to."),
81
- require: z3.boolean().describe("Whether matching tasks wait for a human before dispatch.")
82
- });
83
- var approvalPolicySchema = z3.array(approvalRuleSchema).describe("First-match rules deciding which tasks need a human before they run.");
84
- var defaultApprovalPolicy = [
85
- { kind: "verification", require: false },
86
- { source: "security_scan", require: true },
87
- { require: false }
88
- ];
89
- function requiresApproval(policy, subject) {
90
- for (const rule of policy) {
91
- if (rule.source !== void 0 && rule.source !== subject.source) continue;
92
- if (rule.kind !== void 0 && rule.kind !== subject.kind) continue;
93
- if (rule.priority !== void 0) {
94
- if (subject.priority === void 0 || !rule.priority.includes(subject.priority)) continue;
95
- }
96
- return rule.require;
97
- }
98
- return false;
99
- }
100
-
101
- // src/schema/id.ts
102
- import { z as z4 } from "zod";
103
- function idSchema(prefix) {
104
- return z4.string().regex(new RegExp(`^${prefix}_[a-z0-9]{6,64}$`));
105
- }
106
- var factoryIdSchema = idSchema("fac");
107
- var repositoryIdSchema = idSchema("repo");
108
- var signalIdSchema = idSchema("sig");
109
- var taskIdSchema = idSchema("task");
110
- var changeIdSchema = idSchema("chg");
111
- var receiptIdSchema = idSchema("rcpt");
112
- var repositoryIdsSchema = z4.array(repositoryIdSchema).min(1);
113
-
114
- // src/dispatch.ts
115
- var DispatchRefusedError = class extends Error {
116
- taskId;
117
- reason;
118
- constructor(taskId, reason) {
119
- super(`dispatch of "${taskId}" refused: ${reason}`);
120
- this.name = "DispatchRefusedError";
121
- this.taskId = taskId;
122
- this.reason = reason;
123
- }
124
- };
125
- async function dispatchTask(stores, taskId, options) {
126
- const task = await stores.tasks.get(taskId);
127
- if (task === null) {
128
- throw new RecordNotFoundError("tasks", taskId);
129
- }
130
- if (task.kind === "question") {
131
- throw new DispatchRefusedError(taskId, "question tasks are answered, not dispatched");
132
- }
133
- if (task.approval === "required") {
134
- throw new DispatchRefusedError(taskId, "awaiting human approval");
135
- }
136
- if (task.approval === "denied") {
137
- throw new DispatchRefusedError(taskId, "approval was denied");
138
- }
139
- for (const dependencyId of task.dependsOn ?? []) {
140
- const dependency = await stores.tasks.get(dependencyId);
141
- if (dependency === null) {
142
- throw new DispatchRefusedError(taskId, `dependency "${dependencyId}" does not exist`);
143
- }
144
- if (dependency.changeId === void 0) {
145
- throw new DispatchRefusedError(
146
- taskId,
147
- `dependency "${dependencyId}" has not produced a change`
148
- );
149
- }
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
- await stores.tasks.transition(taskId, "failed", { reason: `launch failed: ${reason}` }).catch(() => void 0);
157
- throw error;
158
- }
159
- return running;
160
- }
161
-
162
- // src/schema/change.ts
163
- import { z as z5 } from "zod";
164
- var levelSchema = z5.enum(["low", "medium", "high"]);
165
- var changeStateSchema = z5.enum([
166
- "verifying",
167
- "ready",
168
- "merged",
169
- "deployed",
170
- "rolled_out",
171
- "rolled_back",
172
- "closed"
173
- ]);
174
- var postMergeStates = ["merged", "deployed", "rolled_out", "rolled_back"];
175
- var changeEvidenceSchema = z5.strictObject({
176
- reproVerified: z5.boolean(),
177
- testsAdded: z5.number().int().min(0),
178
- checksGreen: z5.boolean(),
179
- attackPassed: z5.boolean(),
180
- scopeMatches: z5.boolean(),
181
- previewUrl: z5.url().optional()
182
- });
183
- var changeSchema = z5.strictObject({
184
- schemaVersion: schemaVersionSchema,
185
- id: changeIdSchema,
186
- repositoryId: repositoryIdSchema,
187
- taskId: taskIdSchema.optional(),
188
- groupId: taskIdSchema.optional(),
189
- prNumber: z5.number().int().min(1),
190
- prUrl: z5.url(),
191
- author: z5.string().min(1),
192
- risk: levelSchema,
193
- confidence: levelSchema,
194
- evidence: changeEvidenceSchema,
195
- state: changeStateSchema,
196
- decidedBy: z5.string().min(1).optional(),
197
- createdAt: isoDateTimeSchema,
198
- updatedAt: isoDateTimeSchema
199
- }).superRefine((change, ctx) => {
200
- if (postMergeStates.includes(change.state) && change.decidedBy === void 0) {
201
- ctx.addIssue({
202
- code: "custom",
203
- path: ["decidedBy"],
204
- message: `${change.state} changes require decidedBy`
205
- });
206
- }
207
- });
208
-
209
- // src/schema/task.ts
210
- import { z as z6 } from "zod";
211
- var standardTaskKinds = [
212
- "code_change",
213
- "verification",
214
- "investigation",
215
- "question"
216
- ];
217
- var taskKindSchema = vocabularySchema.describe(
218
- "What kind of work this is, e.g. code_change, question, or a registered custom kind."
219
- );
220
- var taskStateSchema = z6.enum(["queued", "running", "verifying", "succeeded", "failed", "needs_human", "cancelled"]).describe("Lifecycle state. Transitions are fixed; see taskTransitions.");
221
- var taskApprovalSchema = z6.enum(["required", "granted", "denied"]).describe(
222
- "Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator."
223
- );
224
- var harnessSchema = z6.string().min(1).describe("Coding harness used in the devbox, e.g. claude-code or codex.");
225
- var taskOriginSchema = z6.strictObject({
226
- signalId: signalIdSchema.optional().describe("Signal that led to this task."),
227
- parentTaskId: taskIdSchema.optional().describe("Parent task that planned this child."),
228
- operator: z6.string().min(1).optional().describe("Human operator who requested it.")
229
- }).refine(
230
- (origin) => origin.signalId !== void 0 || origin.parentTaskId !== void 0 || origin.operator !== void 0,
231
- { message: "origin requires a signalId, parentTaskId, or operator" }
232
- );
233
- var taskDevboxSchema = z6.strictObject({
234
- devboxId: z6.string().min(1).describe("Devbox running or having run this task."),
235
- remoteId: z6.string().min(1).describe("Provider-side id of the execution."),
236
- harness: harnessSchema
237
- });
238
- var taskQuestionSchema = z6.strictObject({
239
- text: z6.string().min(1).describe("The question a human must answer."),
240
- options: z6.array(z6.string().min(1)).describe("Suggested answers; free-text is also allowed."),
241
- answer: z6.string().min(1).optional(),
242
- answeredBy: z6.string().min(1).optional().describe("Authenticated operator who answered.")
243
- });
244
- var taskSchema = z6.strictObject({
245
- schemaVersion: schemaVersionSchema,
246
- id: taskIdSchema,
247
- repositoryIds: repositoryIdsSchema.optional().describe("Repositories the task works on; absent only on a multi-repo parent."),
248
- kind: taskKindSchema,
249
- area: z6.string().min(1).optional().describe("Investigation area, e.g. onboarding or security. Investigation tasks only."),
250
- state: taskStateSchema,
251
- approval: taskApprovalSchema.optional(),
252
- origin: taskOriginSchema,
253
- dependsOn: z6.array(taskIdSchema).min(1).optional().describe("Sibling tasks that must produce a change before this one may run."),
254
- replyTo: replyToSchema,
255
- devbox: taskDevboxSchema.optional(),
256
- attempt: z6.number().int().min(1).describe("Execution attempt, starting at 1; bumps on retry."),
257
- reservedUsd: usdSchema.optional().describe("Budget reserved before dispatch."),
258
- settledUsd: usdSchema.optional().describe("Measured cost settled after execution."),
259
- question: taskQuestionSchema.optional(),
260
- changeId: changeIdSchema.optional().describe("Change this code_change task produced."),
261
- reportRef: z6.string().min(1).optional().describe("Reference to the report artifact an investigation produced."),
262
- createdAt: isoDateTimeSchema,
263
- updatedAt: isoDateTimeSchema
264
- }).superRefine((task, ctx) => {
265
- if (task.area !== void 0 && task.kind !== "investigation") {
266
- ctx.addIssue({
267
- code: "custom",
268
- path: ["area"],
269
- message: "area is only valid on investigation tasks"
270
- });
271
- }
272
- if (task.kind === "question") {
273
- if (task.question === void 0) {
274
- ctx.addIssue({
275
- code: "custom",
276
- path: ["question"],
277
- message: "question tasks require a question"
278
- });
279
- }
280
- if (task.devbox !== void 0) {
281
- ctx.addIssue({
282
- code: "custom",
283
- path: ["devbox"],
284
- message: "question tasks never run in a devbox"
285
- });
286
- }
287
- } else if (task.question !== void 0) {
288
- ctx.addIssue({
289
- code: "custom",
290
- path: ["question"],
291
- message: "question is only valid on question tasks"
292
- });
293
- }
294
- if (task.changeId !== void 0 && task.kind !== "code_change") {
295
- ctx.addIssue({
296
- code: "custom",
297
- path: ["changeId"],
298
- message: "changeId is only valid on code_change tasks"
299
- });
300
- }
301
- if (task.reportRef !== void 0 && task.kind !== "investigation") {
302
- ctx.addIssue({
303
- code: "custom",
304
- path: ["reportRef"],
305
- message: "reportRef is only valid on investigation tasks"
306
- });
307
- }
308
- });
309
-
310
- export {
311
- SCHEMA_VERSION,
312
- schemaVersionSchema,
313
- isoDateTimeSchema,
314
- usdSchema,
315
- vocabularySchema,
316
- replyToSchema,
317
- findingPrioritySchema,
318
- findingCategorySchema,
319
- findingVerificationLevelSchema,
320
- findingVerificationMethodSchema,
321
- findingVerificationSchema,
322
- findingSchema,
323
- findingFingerprint,
324
- approvalRuleSchema,
325
- approvalPolicySchema,
326
- defaultApprovalPolicy,
327
- requiresApproval,
328
- factoryIdSchema,
329
- repositoryIdSchema,
330
- signalIdSchema,
331
- taskIdSchema,
332
- changeIdSchema,
333
- receiptIdSchema,
334
- repositoryIdsSchema,
335
- DispatchRefusedError,
336
- dispatchTask,
337
- levelSchema,
338
- changeStateSchema,
339
- changeEvidenceSchema,
340
- changeSchema,
341
- standardTaskKinds,
342
- taskKindSchema,
343
- taskStateSchema,
344
- taskApprovalSchema,
345
- harnessSchema,
346
- taskOriginSchema,
347
- taskDevboxSchema,
348
- taskQuestionSchema,
349
- taskSchema
350
- };
351
- //# sourceMappingURL=chunk-LBEYCOSR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schema/common.ts","../src/schema/finding.ts","../src/approval.ts","../src/schema/id.ts","../src/dispatch.ts","../src/schema/change.ts","../src/schema/task.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const SCHEMA_VERSION = 1;\n\nexport const schemaVersionSchema = z\n .literal(SCHEMA_VERSION)\n .describe(\"Version of the entity schema this row was written with.\");\n\nexport const isoDateTimeSchema = z.iso\n .datetime()\n .describe(\"UTC timestamp in ISO 8601 format, e.g. 2026-08-26T12:00:00Z.\");\n\nexport const usdSchema = z.number().finite().nonnegative().describe(\"Amount in US dollars.\");\n\n/**\n * Open vocabulary value. Standard values ship as exported constants; custom\n * values matching the pattern are equally valid.\n */\nexport const vocabularySchema = z\n .string()\n .regex(/^[a-z][a-z0-9_]{0,63}$/, \"must be lowercase snake_case starting with a letter\")\n .describe(\"Lowercase snake_case name, e.g. github_issue or sentry_alert.\");\n\nexport const replyToSchema = z.strictObject({\n channel: z\n .string()\n .min(1)\n .describe(\"Connector that should carry replies, e.g. github or slack.\"),\n address: z\n .string()\n .min(1)\n .describe(\"Connector-specific reply address, e.g. acme/web#41 or a Slack thread id.\"),\n});\n\nexport type ReplyTo = z.infer<typeof replyToSchema>;\n","import { createHash } from \"node:crypto\";\nimport { z } from \"zod\";\n\nexport const findingPrioritySchema = z\n .enum([\"P0\", \"P1\", \"P2\", \"P3\"])\n .describe(\"Urgency of a finding: P0 is drop-everything, P3 is nice-to-have.\");\n\nexport const findingCategorySchema = z.enum([\n \"security\",\n \"correctness\",\n \"reliability\",\n \"performance\",\n \"compatibility\",\n \"accessibility\",\n \"documentation\",\n \"maintainability\",\n \"testing\",\n \"usability\",\n]);\n\nexport const findingVerificationLevelSchema = z\n .enum([\"unverified\", \"supported\", \"confirmed\"])\n .describe(\n \"How sure the reporter is: unverified = suspected from reading; supported = evidence points to it; confirmed = demonstrated.\",\n );\n\nexport const findingVerificationMethodSchema = z.enum([\n \"code_inspection\",\n \"static_analysis\",\n \"manual_reproduction\",\n \"unit_test\",\n \"integration_test\",\n \"e2e_test\",\n \"runtime_observation\",\n \"documentation\",\n]);\n\n/**\n * What was done to check the finding. Forces a reporter to distinguish \"I\n * think this is a problem\" from \"I demonstrated it\", which is the axis a human\n * approving fixes cares about most.\n */\nexport const findingVerificationSchema = z.strictObject({\n level: findingVerificationLevelSchema,\n method: findingVerificationMethodSchema,\n summary: z.string().min(1).max(2000).describe(\"What was checked and what it showed.\"),\n limitations: z.string().min(1).max(2000).optional().describe(\"What could not be checked.\"),\n});\n\n/** A single problem found in a repository, as a scanner or agent reports it. */\nexport const findingSchema = z.strictObject({\n title: z.string().min(1).max(200),\n body: z.string().min(1).max(8000).describe(\"The problem, its impact, and how to fix it. Markdown.\"),\n path: z.string().min(1).max(500).optional().describe(\"Repository-relative file path.\"),\n line: z.number().int().min(1).optional(),\n endLine: z.number().int().min(1).optional(),\n priority: findingPrioritySchema,\n category: findingCategorySchema,\n verification: findingVerificationSchema,\n tool: z.string().min(1).max(100).optional().describe(\"Scanner that produced it, e.g. deepsec.\"),\n ruleId: z.string().min(1).max(200).optional().describe(\"Scanner rule or check id, when there is one.\"),\n});\n\nexport type FindingPriority = z.infer<typeof findingPrioritySchema>;\nexport type FindingCategory = z.infer<typeof findingCategorySchema>;\nexport type FindingVerification = z.infer<typeof findingVerificationSchema>;\nexport type Finding = z.infer<typeof findingSchema>;\n\n/**\n * Stable identity of a finding across scans, used as the signal's delivery id\n * so re-reporting is a no-op instead of a second task. A scanner finding is\n * the same problem when the same tool reports the same rule on the same file;\n * its title is model-written prose and changes between runs, so it is left\n * out. Without a rule id the title is all there is, normalised.\n */\nexport function findingFingerprint(repositoryId: string, finding: Finding): string {\n const parts =\n finding.tool !== undefined && finding.ruleId !== undefined && finding.path !== undefined\n ? [repositoryId, finding.tool, finding.ruleId, finding.path]\n : [\n repositoryId,\n finding.tool ?? \"\",\n finding.ruleId ?? \"\",\n finding.path ?? \"\",\n finding.title.trim().toLowerCase().replaceAll(/\\s+/gu, \" \"),\n ];\n return createHash(\"sha256\").update(parts.join(\" \")).digest(\"hex\").slice(0, 32);\n}\n","import { z } from \"zod\";\nimport { vocabularySchema } from \"./schema/common\";\nimport { findingPrioritySchema, type FindingPriority } from \"./schema/finding\";\n\n/**\n * One approval rule. Every listed field must match for the rule to apply;\n * absent fields match anything. Rules are evaluated first-match.\n */\nexport const approvalRuleSchema = z.strictObject({\n source: vocabularySchema.optional().describe(\"Signal source, e.g. security_scan or github_issue.\"),\n kind: vocabularySchema.optional().describe(\"Task kind, e.g. code_change.\"),\n priority: z\n .array(findingPrioritySchema)\n .min(1)\n .optional()\n .describe(\"Finding priorities the rule applies to.\"),\n require: z.boolean().describe(\"Whether matching tasks wait for a human before dispatch.\"),\n});\n\nexport const approvalPolicySchema = z\n .array(approvalRuleSchema)\n .describe(\"First-match rules deciding which tasks need a human before they run.\");\n\nexport type ApprovalRule = z.infer<typeof approvalRuleSchema>;\nexport type ApprovalPolicy = z.infer<typeof approvalPolicySchema>;\n\n/**\n * The default: fixes for security findings wait for a human; everything else\n * runs as it always has. Handoffs between agents (verification) never wait,\n * because a human already approved the work they continue.\n */\nexport const defaultApprovalPolicy: ApprovalPolicy = [\n { kind: \"verification\", require: false },\n { source: \"security_scan\", require: true },\n { require: false },\n];\n\nexport interface ApprovalSubject {\n source?: string;\n kind: string;\n priority?: FindingPriority;\n}\n\n/**\n * Decide at task-creation time whether a task needs approval. Pure: the answer\n * is stamped on the task and never re-evaluated, so a later policy change\n * cannot silently release work a human was expecting to see.\n */\nexport function requiresApproval(policy: ApprovalPolicy, subject: ApprovalSubject): boolean {\n for (const rule of policy) {\n if (rule.source !== undefined && rule.source !== subject.source) continue;\n if (rule.kind !== undefined && rule.kind !== subject.kind) continue;\n if (rule.priority !== undefined) {\n if (subject.priority === undefined || !rule.priority.includes(subject.priority)) continue;\n }\n return rule.require;\n }\n return false;\n}\n","import { z } from \"zod\";\n\nfunction idSchema(prefix: string) {\n return z.string().regex(new RegExp(`^${prefix}_[a-z0-9]{6,64}$`));\n}\n\nexport const factoryIdSchema = idSchema(\"fac\");\nexport const repositoryIdSchema = idSchema(\"repo\");\nexport const signalIdSchema = idSchema(\"sig\");\nexport const taskIdSchema = idSchema(\"task\");\nexport const changeIdSchema = idSchema(\"chg\");\nexport const receiptIdSchema = idSchema(\"rcpt\");\n\nexport const repositoryIdsSchema = z.array(repositoryIdSchema).min(1);\n\nexport type FactoryId = z.infer<typeof factoryIdSchema>;\nexport type RepositoryId = z.infer<typeof repositoryIdSchema>;\nexport type SignalId = z.infer<typeof signalIdSchema>;\nexport type TaskId = z.infer<typeof taskIdSchema>;\nexport type ChangeId = z.infer<typeof changeIdSchema>;\nexport type ReceiptId = z.infer<typeof receiptIdSchema>;\n","import type { TaskId } from \"./schema/id\";\nimport 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}\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 moves the task to failed; a crash between the transition and\n * the launch leaves 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.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 await stores.tasks\n .transition(taskId, \"failed\", { reason: `launch failed: ${reason}` })\n .catch(() => undefined);\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 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","import { z } from \"zod\";\nimport {\n isoDateTimeSchema,\n replyToSchema,\n schemaVersionSchema,\n usdSchema,\n vocabularySchema,\n} from \"./common\";\nimport { changeIdSchema, repositoryIdsSchema, signalIdSchema, taskIdSchema } 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 \"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 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\n .optional()\n .describe(\"Repositories the task works on; absent only on a multi-repo parent.\"),\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 this code_change task produced.\"),\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 (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.changeId !== undefined && task.kind !== \"code_change\") {\n ctx.addIssue({\n code: \"custom\",\n path: [\"changeId\"],\n message: \"changeId is only valid on code_change 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"],"mappings":";;;;;AAAA,SAAS,SAAS;AAEX,IAAM,iBAAiB;AAEvB,IAAM,sBAAsB,EAChC,QAAQ,cAAc,EACtB,SAAS,yDAAyD;AAE9D,IAAM,oBAAoB,EAAE,IAChC,SAAS,EACT,SAAS,8DAA8D;AAEnE,IAAM,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,uBAAuB;AAMpF,IAAM,mBAAmB,EAC7B,OAAO,EACP,MAAM,0BAA0B,qDAAqD,EACrF,SAAS,+DAA+D;AAEpE,IAAM,gBAAgB,EAAE,aAAa;AAAA,EAC1C,SAAS,EACN,OAAO,EACP,IAAI,CAAC,EACL,SAAS,4DAA4D;AAAA,EACxE,SAAS,EACN,OAAO,EACP,IAAI,CAAC,EACL,SAAS,0EAA0E;AACxF,CAAC;;;AChCD,SAAS,kBAAkB;AAC3B,SAAS,KAAAA,UAAS;AAEX,IAAM,wBAAwBA,GAClC,KAAK,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC,EAC7B,SAAS,kEAAkE;AAEvE,IAAM,wBAAwBA,GAAE,KAAK;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,iCAAiCA,GAC3C,KAAK,CAAC,cAAc,aAAa,WAAW,CAAC,EAC7C;AAAA,EACC;AACF;AAEK,IAAM,kCAAkCA,GAAE,KAAK;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,IAAM,4B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AAS;AAAA,MACX,MAAM;AAAA,MACN,MAAM,CAAC,MAAM;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,MAAI,KAAK,SAAS,YAAY;AAC5B,QAAI,KAAK,aAAa,QAAW;AAC/B,UAAI,SAAS;AAAA,QACX,MAAM;AAAA,QACN,MAAM,CAAC,UAAU;AAAA,QACjB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AACA,QAAI,KAAK,WAAW,QAAW;AAC7B,UAAI,SAAS;AAAA,QACX,MAAM;AAAA,QACN,MAAM,CAAC,QAAQ;AAAA,QACf,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,WAAW,KAAK,aAAa,QAAW;AACtC,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,MAAM,CAAC,UAAU;AAAA,MACjB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,MAAI,KAAK,aAAa,UAAa,KAAK,SAAS,eAAe;AAC9D,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,MAAM,CAAC,UAAU;AAAA,MACjB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,MAAI,KAAK,cAAc,UAAa,KAAK,SAAS,iBAAiB;AACjE,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,MAAM,CAAC,WAAW;AAAA,MAClB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF,CAAC;","names":["z","z","z","z","z","z","z","z"]}
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
-
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
-
18
- export { type ReplyTo as R, SCHEMA_VERSION as S, isoDateTimeSchema as i, replyToSchema as r, schemaVersionSchema as s, usdSchema as u, vocabularySchema as v };
@@ -1,62 +0,0 @@
1
- import { R as ReplyTo } from '../common-CaHaEOAS.js';
2
- import 'zod';
3
-
4
- /**
5
- * Verify a GitHub webhook HMAC signature (the x-hub-signature-256 header)
6
- * against the raw request body. Returns false for missing or malformed
7
- * signatures instead of throwing.
8
- */
9
- declare function verifyGitHubSignature(options: {
10
- secret: string;
11
- payload: string;
12
- signature: string | null;
13
- }): boolean;
14
- interface GitHubIssueSignal {
15
- source: "github_issue";
16
- deliveryId: string;
17
- repositorySlug: string;
18
- replyTo: ReplyTo;
19
- issue: {
20
- number: number;
21
- title: string;
22
- body: string | null;
23
- };
24
- payload: unknown;
25
- }
26
- interface GitHubCIFailureSignal {
27
- source: "github_ci_failure";
28
- deliveryId: string;
29
- repositoryDefaultBranch: string;
30
- repositorySlug: string;
31
- replyTo: ReplyTo;
32
- workflowRun: {
33
- id: number;
34
- name: string;
35
- trigger: string;
36
- branch: string | null;
37
- headRepositorySlug: string | null;
38
- headSha: string;
39
- url: string;
40
- conclusion: string;
41
- attempt: number;
42
- };
43
- payload: unknown;
44
- }
45
- /**
46
- * Normalize a GitHub issues webhook into the factory's signal shape. Returns
47
- * null for payloads that are not an opened issue. The caller supplies the
48
- * repository id; the payload stays untrusted data.
49
- */
50
- declare function normalizeGitHubIssueOpened(options: {
51
- deliveryId: string;
52
- event: string;
53
- payload: unknown;
54
- }): GitHubIssueSignal | null;
55
- /** Normalize a completed, unsuccessful GitHub Actions run into a CI failure signal. */
56
- declare function normalizeGitHubWorkflowRunFailure(options: {
57
- deliveryId: string;
58
- event: string;
59
- payload: unknown;
60
- }): GitHubCIFailureSignal | null;
61
-
62
- export { type GitHubCIFailureSignal, type GitHubIssueSignal, normalizeGitHubIssueOpened, normalizeGitHubWorkflowRunFailure, verifyGitHubSignature };
@@ -1,112 +0,0 @@
1
- // src/connectors/github.ts
2
- import { createHmac, timingSafeEqual } from "crypto";
3
- import { z } from "zod";
4
- function verifyGitHubSignature(options) {
5
- const { secret, payload, signature } = options;
6
- if (signature === null || !signature.startsWith("sha256=")) {
7
- return false;
8
- }
9
- const expected = createHmac("sha256", secret).update(payload).digest("hex");
10
- const provided = signature.slice("sha256=".length);
11
- if (provided.length !== expected.length) {
12
- return false;
13
- }
14
- return timingSafeEqual(Buffer.from(provided, "hex"), Buffer.from(expected, "hex"));
15
- }
16
- var issueEventSchema = z.looseObject({
17
- action: z.string(),
18
- issue: z.looseObject({
19
- number: z.number().int().min(1),
20
- title: z.string(),
21
- body: z.string().nullable()
22
- }),
23
- repository: z.looseObject({
24
- full_name: z.string().min(1)
25
- })
26
- });
27
- var failedWorkflowConclusions = /* @__PURE__ */ new Set([
28
- "action_required",
29
- "failure",
30
- "stale",
31
- "startup_failure",
32
- "timed_out"
33
- ]);
34
- var workflowRunEventSchema = z.looseObject({
35
- action: z.string(),
36
- repository: z.looseObject({
37
- default_branch: z.string().min(1),
38
- full_name: z.string().min(1)
39
- }),
40
- workflow_run: z.looseObject({
41
- id: z.number().int().min(1),
42
- name: z.string().min(1),
43
- event: z.string().min(1),
44
- head_branch: z.string().min(1).nullable(),
45
- head_repository: z.looseObject({
46
- full_name: z.string().min(1)
47
- }).nullable(),
48
- head_sha: z.string().min(1),
49
- html_url: z.url(),
50
- conclusion: z.string().nullable(),
51
- run_attempt: z.number().int().min(1)
52
- })
53
- });
54
- function normalizeGitHubIssueOpened(options) {
55
- if (options.event !== "issues") {
56
- return null;
57
- }
58
- const parsed = issueEventSchema.safeParse(options.payload);
59
- if (!parsed.success || parsed.data.action !== "opened") {
60
- return null;
61
- }
62
- const slug = parsed.data.repository.full_name.toLowerCase();
63
- const { number, title, body } = parsed.data.issue;
64
- return {
65
- source: "github_issue",
66
- deliveryId: options.deliveryId,
67
- repositorySlug: slug,
68
- replyTo: { channel: "github", address: `${slug}#${number}` },
69
- issue: { number, title, body },
70
- payload: options.payload
71
- };
72
- }
73
- function normalizeGitHubWorkflowRunFailure(options) {
74
- if (options.event !== "workflow_run") {
75
- return null;
76
- }
77
- const parsed = workflowRunEventSchema.safeParse(options.payload);
78
- if (!parsed.success || parsed.data.action !== "completed") {
79
- return null;
80
- }
81
- const run = parsed.data.workflow_run;
82
- const conclusion = run.conclusion;
83
- if (conclusion === null || !failedWorkflowConclusions.has(conclusion)) {
84
- return null;
85
- }
86
- const slug = parsed.data.repository.full_name.toLowerCase();
87
- return {
88
- source: "github_ci_failure",
89
- deliveryId: options.deliveryId,
90
- repositoryDefaultBranch: parsed.data.repository.default_branch,
91
- repositorySlug: slug,
92
- replyTo: { channel: "github", address: `${slug}/actions/runs/${run.id}` },
93
- workflowRun: {
94
- id: run.id,
95
- name: run.name,
96
- trigger: run.event,
97
- branch: run.head_branch,
98
- headRepositorySlug: run.head_repository?.full_name.toLowerCase() ?? null,
99
- headSha: run.head_sha,
100
- url: run.html_url,
101
- conclusion,
102
- attempt: run.run_attempt
103
- },
104
- payload: options.payload
105
- };
106
- }
107
- export {
108
- normalizeGitHubIssueOpened,
109
- normalizeGitHubWorkflowRunFailure,
110
- verifyGitHubSignature
111
- };
112
- //# sourceMappingURL=github.js.map