@vercel/factory 0.0.1 → 0.0.3
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.
- package/README.md +5 -0
- package/dist/chunk-2JFES6BA.js +41 -0
- package/dist/chunk-2JFES6BA.js.map +1 -0
- package/dist/chunk-D2XMABG4.js +311 -0
- package/dist/chunk-D2XMABG4.js.map +1 -0
- package/dist/{chunk-LBEYCOSR.js → chunk-EFL4PDDE.js} +68 -94
- package/dist/chunk-EFL4PDDE.js.map +1 -0
- package/dist/connectors/index.d.ts +53 -0
- package/dist/connectors/index.js +64 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/eve/index.d.ts +92 -1
- package/dist/eve/index.js +226 -75
- package/dist/eve/index.js.map +1 -1
- package/dist/github.d.ts +139 -0
- package/dist/github.js +27 -0
- package/dist/github.js.map +1 -0
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
- package/dist/chunk-LBEYCOSR.js.map +0 -1
- package/dist/connectors/github.d.ts +0 -62
- package/dist/connectors/github.js +0 -112
- package/dist/connectors/github.js.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
changeIdSchema,
|
|
3
|
+
isoDateTimeSchema,
|
|
4
|
+
replyToSchema,
|
|
5
|
+
repositoryIdSchema,
|
|
6
|
+
repositoryIdsSchema,
|
|
7
|
+
schemaVersionSchema,
|
|
8
|
+
signalIdSchema,
|
|
9
|
+
taskIdSchema,
|
|
10
|
+
usdSchema,
|
|
11
|
+
vocabularySchema
|
|
12
|
+
} from "./chunk-2JFES6BA.js";
|
|
1
13
|
import {
|
|
2
14
|
RecordNotFoundError
|
|
3
15
|
} from "./chunk-CEF6VJZC.js";
|
|
4
16
|
|
|
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
17
|
// src/schema/finding.ts
|
|
18
18
|
import { createHash } from "crypto";
|
|
19
|
-
import { z
|
|
20
|
-
var findingPrioritySchema =
|
|
21
|
-
var findingCategorySchema =
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
var findingPrioritySchema = z.enum(["P0", "P1", "P2", "P3"]).describe("Urgency of a finding: P0 is drop-everything, P3 is nice-to-have.");
|
|
21
|
+
var findingCategorySchema = z.enum([
|
|
22
22
|
"security",
|
|
23
23
|
"correctness",
|
|
24
24
|
"reliability",
|
|
@@ -30,10 +30,10 @@ var findingCategorySchema = z2.enum([
|
|
|
30
30
|
"testing",
|
|
31
31
|
"usability"
|
|
32
32
|
]);
|
|
33
|
-
var findingVerificationLevelSchema =
|
|
33
|
+
var findingVerificationLevelSchema = z.enum(["unverified", "supported", "confirmed"]).describe(
|
|
34
34
|
"How sure the reporter is: unverified = suspected from reading; supported = evidence points to it; confirmed = demonstrated."
|
|
35
35
|
);
|
|
36
|
-
var findingVerificationMethodSchema =
|
|
36
|
+
var findingVerificationMethodSchema = z.enum([
|
|
37
37
|
"code_inspection",
|
|
38
38
|
"static_analysis",
|
|
39
39
|
"manual_reproduction",
|
|
@@ -43,23 +43,23 @@ var findingVerificationMethodSchema = z2.enum([
|
|
|
43
43
|
"runtime_observation",
|
|
44
44
|
"documentation"
|
|
45
45
|
]);
|
|
46
|
-
var findingVerificationSchema =
|
|
46
|
+
var findingVerificationSchema = z.strictObject({
|
|
47
47
|
level: findingVerificationLevelSchema,
|
|
48
48
|
method: findingVerificationMethodSchema,
|
|
49
|
-
summary:
|
|
50
|
-
limitations:
|
|
49
|
+
summary: z.string().min(1).max(2e3).describe("What was checked and what it showed."),
|
|
50
|
+
limitations: z.string().min(1).max(2e3).optional().describe("What could not be checked.")
|
|
51
51
|
});
|
|
52
|
-
var findingSchema =
|
|
53
|
-
title:
|
|
54
|
-
body:
|
|
55
|
-
path:
|
|
56
|
-
line:
|
|
57
|
-
endLine:
|
|
52
|
+
var findingSchema = z.strictObject({
|
|
53
|
+
title: z.string().min(1).max(200),
|
|
54
|
+
body: z.string().min(1).max(8e3).describe("The problem, its impact, and how to fix it. Markdown."),
|
|
55
|
+
path: z.string().min(1).max(500).optional().describe("Repository-relative file path."),
|
|
56
|
+
line: z.number().int().min(1).optional(),
|
|
57
|
+
endLine: z.number().int().min(1).optional(),
|
|
58
58
|
priority: findingPrioritySchema,
|
|
59
59
|
category: findingCategorySchema,
|
|
60
60
|
verification: findingVerificationSchema,
|
|
61
|
-
tool:
|
|
62
|
-
ruleId:
|
|
61
|
+
tool: z.string().min(1).max(100).optional().describe("Scanner that produced it, e.g. deepsec."),
|
|
62
|
+
ruleId: z.string().min(1).max(200).optional().describe("Scanner rule or check id, when there is one.")
|
|
63
63
|
});
|
|
64
64
|
function findingFingerprint(repositoryId, finding) {
|
|
65
65
|
const parts = finding.tool !== void 0 && finding.ruleId !== void 0 && finding.path !== void 0 ? [repositoryId, finding.tool, finding.ruleId, finding.path] : [
|
|
@@ -73,14 +73,14 @@ function findingFingerprint(repositoryId, finding) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// src/approval.ts
|
|
76
|
-
import { z as
|
|
77
|
-
var approvalRuleSchema =
|
|
76
|
+
import { z as z2 } from "zod";
|
|
77
|
+
var approvalRuleSchema = z2.strictObject({
|
|
78
78
|
source: vocabularySchema.optional().describe("Signal source, e.g. security_scan or github_issue."),
|
|
79
79
|
kind: vocabularySchema.optional().describe("Task kind, e.g. code_change."),
|
|
80
|
-
priority:
|
|
81
|
-
require:
|
|
80
|
+
priority: z2.array(findingPrioritySchema).min(1).optional().describe("Finding priorities the rule applies to."),
|
|
81
|
+
require: z2.boolean().describe("Whether matching tasks wait for a human before dispatch.")
|
|
82
82
|
});
|
|
83
|
-
var approvalPolicySchema =
|
|
83
|
+
var approvalPolicySchema = z2.array(approvalRuleSchema).describe("First-match rules deciding which tasks need a human before they run.");
|
|
84
84
|
var defaultApprovalPolicy = [
|
|
85
85
|
{ kind: "verification", require: false },
|
|
86
86
|
{ source: "security_scan", require: true },
|
|
@@ -98,19 +98,6 @@ function requiresApproval(policy, subject) {
|
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
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
101
|
// src/dispatch.ts
|
|
115
102
|
var DispatchRefusedError = class extends Error {
|
|
116
103
|
taskId;
|
|
@@ -160,9 +147,9 @@ async function dispatchTask(stores, taskId, options) {
|
|
|
160
147
|
}
|
|
161
148
|
|
|
162
149
|
// src/schema/change.ts
|
|
163
|
-
import { z as
|
|
164
|
-
var levelSchema =
|
|
165
|
-
var changeStateSchema =
|
|
150
|
+
import { z as z3 } from "zod";
|
|
151
|
+
var levelSchema = z3.enum(["low", "medium", "high"]);
|
|
152
|
+
var changeStateSchema = z3.enum([
|
|
166
153
|
"verifying",
|
|
167
154
|
"ready",
|
|
168
155
|
"merged",
|
|
@@ -172,28 +159,28 @@ var changeStateSchema = z5.enum([
|
|
|
172
159
|
"closed"
|
|
173
160
|
]);
|
|
174
161
|
var postMergeStates = ["merged", "deployed", "rolled_out", "rolled_back"];
|
|
175
|
-
var changeEvidenceSchema =
|
|
176
|
-
reproVerified:
|
|
177
|
-
testsAdded:
|
|
178
|
-
checksGreen:
|
|
179
|
-
attackPassed:
|
|
180
|
-
scopeMatches:
|
|
181
|
-
previewUrl:
|
|
162
|
+
var changeEvidenceSchema = z3.strictObject({
|
|
163
|
+
reproVerified: z3.boolean(),
|
|
164
|
+
testsAdded: z3.number().int().min(0),
|
|
165
|
+
checksGreen: z3.boolean(),
|
|
166
|
+
attackPassed: z3.boolean(),
|
|
167
|
+
scopeMatches: z3.boolean(),
|
|
168
|
+
previewUrl: z3.url().optional()
|
|
182
169
|
});
|
|
183
|
-
var changeSchema =
|
|
170
|
+
var changeSchema = z3.strictObject({
|
|
184
171
|
schemaVersion: schemaVersionSchema,
|
|
185
172
|
id: changeIdSchema,
|
|
186
173
|
repositoryId: repositoryIdSchema,
|
|
187
174
|
taskId: taskIdSchema.optional(),
|
|
188
175
|
groupId: taskIdSchema.optional(),
|
|
189
|
-
prNumber:
|
|
190
|
-
prUrl:
|
|
191
|
-
author:
|
|
176
|
+
prNumber: z3.number().int().min(1),
|
|
177
|
+
prUrl: z3.url(),
|
|
178
|
+
author: z3.string().min(1),
|
|
192
179
|
risk: levelSchema,
|
|
193
180
|
confidence: levelSchema,
|
|
194
181
|
evidence: changeEvidenceSchema,
|
|
195
182
|
state: changeStateSchema,
|
|
196
|
-
decidedBy:
|
|
183
|
+
decidedBy: z3.string().min(1).optional(),
|
|
197
184
|
createdAt: isoDateTimeSchema,
|
|
198
185
|
updatedAt: isoDateTimeSchema
|
|
199
186
|
}).superRefine((change, ctx) => {
|
|
@@ -207,7 +194,7 @@ var changeSchema = z5.strictObject({
|
|
|
207
194
|
});
|
|
208
195
|
|
|
209
196
|
// src/schema/task.ts
|
|
210
|
-
import { z as
|
|
197
|
+
import { z as z4 } from "zod";
|
|
211
198
|
var standardTaskKinds = [
|
|
212
199
|
"code_change",
|
|
213
200
|
"verification",
|
|
@@ -217,48 +204,48 @@ var standardTaskKinds = [
|
|
|
217
204
|
var taskKindSchema = vocabularySchema.describe(
|
|
218
205
|
"What kind of work this is, e.g. code_change, question, or a registered custom kind."
|
|
219
206
|
);
|
|
220
|
-
var taskStateSchema =
|
|
221
|
-
var taskApprovalSchema =
|
|
207
|
+
var taskStateSchema = z4.enum(["queued", "running", "verifying", "succeeded", "failed", "needs_human", "cancelled"]).describe("Lifecycle state. Transitions are fixed; see taskTransitions.");
|
|
208
|
+
var taskApprovalSchema = z4.enum(["required", "granted", "denied"]).describe(
|
|
222
209
|
"Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator."
|
|
223
210
|
);
|
|
224
|
-
var harnessSchema =
|
|
225
|
-
var taskOriginSchema =
|
|
211
|
+
var harnessSchema = z4.string().min(1).describe("Coding harness used in the devbox, e.g. claude-code or codex.");
|
|
212
|
+
var taskOriginSchema = z4.strictObject({
|
|
226
213
|
signalId: signalIdSchema.optional().describe("Signal that led to this task."),
|
|
227
214
|
parentTaskId: taskIdSchema.optional().describe("Parent task that planned this child."),
|
|
228
|
-
operator:
|
|
215
|
+
operator: z4.string().min(1).optional().describe("Human operator who requested it.")
|
|
229
216
|
}).refine(
|
|
230
217
|
(origin) => origin.signalId !== void 0 || origin.parentTaskId !== void 0 || origin.operator !== void 0,
|
|
231
218
|
{ message: "origin requires a signalId, parentTaskId, or operator" }
|
|
232
219
|
);
|
|
233
|
-
var taskDevboxSchema =
|
|
234
|
-
devboxId:
|
|
235
|
-
remoteId:
|
|
220
|
+
var taskDevboxSchema = z4.strictObject({
|
|
221
|
+
devboxId: z4.string().min(1).describe("Devbox running or having run this task."),
|
|
222
|
+
remoteId: z4.string().min(1).describe("Provider-side id of the execution."),
|
|
236
223
|
harness: harnessSchema
|
|
237
224
|
});
|
|
238
|
-
var taskQuestionSchema =
|
|
239
|
-
text:
|
|
240
|
-
options:
|
|
241
|
-
answer:
|
|
242
|
-
answeredBy:
|
|
225
|
+
var taskQuestionSchema = z4.strictObject({
|
|
226
|
+
text: z4.string().min(1).describe("The question a human must answer."),
|
|
227
|
+
options: z4.array(z4.string().min(1)).describe("Suggested answers; free-text is also allowed."),
|
|
228
|
+
answer: z4.string().min(1).optional(),
|
|
229
|
+
answeredBy: z4.string().min(1).optional().describe("Authenticated operator who answered.")
|
|
243
230
|
});
|
|
244
|
-
var taskSchema =
|
|
231
|
+
var taskSchema = z4.strictObject({
|
|
245
232
|
schemaVersion: schemaVersionSchema,
|
|
246
233
|
id: taskIdSchema,
|
|
247
234
|
repositoryIds: repositoryIdsSchema.optional().describe("Repositories the task works on; absent only on a multi-repo parent."),
|
|
248
235
|
kind: taskKindSchema,
|
|
249
|
-
area:
|
|
236
|
+
area: z4.string().min(1).optional().describe("Investigation area, e.g. onboarding or security. Investigation tasks only."),
|
|
250
237
|
state: taskStateSchema,
|
|
251
238
|
approval: taskApprovalSchema.optional(),
|
|
252
239
|
origin: taskOriginSchema,
|
|
253
|
-
dependsOn:
|
|
240
|
+
dependsOn: z4.array(taskIdSchema).min(1).optional().describe("Sibling tasks that must produce a change before this one may run."),
|
|
254
241
|
replyTo: replyToSchema,
|
|
255
242
|
devbox: taskDevboxSchema.optional(),
|
|
256
|
-
attempt:
|
|
243
|
+
attempt: z4.number().int().min(1).describe("Execution attempt, starting at 1; bumps on retry."),
|
|
257
244
|
reservedUsd: usdSchema.optional().describe("Budget reserved before dispatch."),
|
|
258
245
|
settledUsd: usdSchema.optional().describe("Measured cost settled after execution."),
|
|
259
246
|
question: taskQuestionSchema.optional(),
|
|
260
247
|
changeId: changeIdSchema.optional().describe("Change this code_change task produced."),
|
|
261
|
-
reportRef:
|
|
248
|
+
reportRef: z4.string().min(1).optional().describe("Reference to the report artifact an investigation produced."),
|
|
262
249
|
createdAt: isoDateTimeSchema,
|
|
263
250
|
updatedAt: isoDateTimeSchema
|
|
264
251
|
}).superRefine((task, ctx) => {
|
|
@@ -308,12 +295,6 @@ var taskSchema = z6.strictObject({
|
|
|
308
295
|
});
|
|
309
296
|
|
|
310
297
|
export {
|
|
311
|
-
SCHEMA_VERSION,
|
|
312
|
-
schemaVersionSchema,
|
|
313
|
-
isoDateTimeSchema,
|
|
314
|
-
usdSchema,
|
|
315
|
-
vocabularySchema,
|
|
316
|
-
replyToSchema,
|
|
317
298
|
findingPrioritySchema,
|
|
318
299
|
findingCategorySchema,
|
|
319
300
|
findingVerificationLevelSchema,
|
|
@@ -325,13 +306,6 @@ export {
|
|
|
325
306
|
approvalPolicySchema,
|
|
326
307
|
defaultApprovalPolicy,
|
|
327
308
|
requiresApproval,
|
|
328
|
-
factoryIdSchema,
|
|
329
|
-
repositoryIdSchema,
|
|
330
|
-
signalIdSchema,
|
|
331
|
-
taskIdSchema,
|
|
332
|
-
changeIdSchema,
|
|
333
|
-
receiptIdSchema,
|
|
334
|
-
repositoryIdsSchema,
|
|
335
309
|
DispatchRefusedError,
|
|
336
310
|
dispatchTask,
|
|
337
311
|
levelSchema,
|
|
@@ -348,4 +322,4 @@ export {
|
|
|
348
322
|
taskQuestionSchema,
|
|
349
323
|
taskSchema
|
|
350
324
|
};
|
|
351
|
-
//# sourceMappingURL=chunk-
|
|
325
|
+
//# sourceMappingURL=chunk-EFL4PDDE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/finding.ts","../src/approval.ts","../src/dispatch.ts","../src/schema/change.ts","../src/schema/task.ts"],"sourcesContent":["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 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,kBAAkB;AAC3B,SAAS,SAAS;AAEX,IAAM,wBAAwB,EAClC,KAAK,CAAC,MAAM,MAAM,MAAM,IAAI,CAAC,EAC7B,SAAS,kEAAkE;AAEvE,IAAM,wBAAwB,EAAE,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,iCAAiC,EAC3C,KAAK,CAAC,cAAc,aAAa,WAAW,CAAC,EAC7C;AAAA,EACC;AACF;AAEK,IAAM,kCAAkC,EAAE,KAAK;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,IAAM,4BAA4B,EAAE,aAAa;AAAA,EACtD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAI,EAAE,SAAS,sCAAsC;AAAA,EACpF,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,E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,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"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const communicationOutcomes: readonly ["accepted", "started", "succeeded", "failed", "needs_human", "question", "digest", "rolled_back", "budget_warning", "budget_exhausted", "message"];
|
|
4
|
+
declare const communicationOutcomeSchema: z.ZodEnum<{
|
|
5
|
+
accepted: "accepted";
|
|
6
|
+
started: "started";
|
|
7
|
+
succeeded: "succeeded";
|
|
8
|
+
failed: "failed";
|
|
9
|
+
needs_human: "needs_human";
|
|
10
|
+
question: "question";
|
|
11
|
+
digest: "digest";
|
|
12
|
+
rolled_back: "rolled_back";
|
|
13
|
+
budget_warning: "budget_warning";
|
|
14
|
+
budget_exhausted: "budget_exhausted";
|
|
15
|
+
message: "message";
|
|
16
|
+
}>;
|
|
17
|
+
declare const communicationEventSchema: z.ZodObject<{
|
|
18
|
+
eventId: z.ZodString;
|
|
19
|
+
repositoryId: z.ZodString;
|
|
20
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
changeId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
replyTo: z.ZodObject<{
|
|
23
|
+
channel: z.ZodString;
|
|
24
|
+
address: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
outcome: z.ZodEnum<{
|
|
27
|
+
accepted: "accepted";
|
|
28
|
+
started: "started";
|
|
29
|
+
succeeded: "succeeded";
|
|
30
|
+
failed: "failed";
|
|
31
|
+
needs_human: "needs_human";
|
|
32
|
+
question: "question";
|
|
33
|
+
digest: "digest";
|
|
34
|
+
rolled_back: "rolled_back";
|
|
35
|
+
budget_warning: "budget_warning";
|
|
36
|
+
budget_exhausted: "budget_exhausted";
|
|
37
|
+
message: "message";
|
|
38
|
+
}>;
|
|
39
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
type CommunicationOutcome = z.infer<typeof communicationOutcomeSchema>;
|
|
42
|
+
type CommunicationEvent = z.infer<typeof communicationEventSchema>;
|
|
43
|
+
interface CommunicationAdapter {
|
|
44
|
+
readonly channel: string;
|
|
45
|
+
deliver(event: CommunicationEvent): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
interface CommunicationRouter {
|
|
48
|
+
readonly channels: readonly string[];
|
|
49
|
+
deliver(event: CommunicationEvent): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
declare function createCommunicationRouter(adapters: readonly CommunicationAdapter[]): CommunicationRouter;
|
|
52
|
+
|
|
53
|
+
export { type CommunicationAdapter, type CommunicationEvent, type CommunicationOutcome, type CommunicationRouter, communicationEventSchema, communicationOutcomeSchema, communicationOutcomes, createCommunicationRouter };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
changeIdSchema,
|
|
3
|
+
replyToSchema,
|
|
4
|
+
repositoryIdSchema,
|
|
5
|
+
taskIdSchema
|
|
6
|
+
} from "../chunk-2JFES6BA.js";
|
|
7
|
+
|
|
8
|
+
// src/connectors/index.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var communicationOutcomes = [
|
|
11
|
+
"accepted",
|
|
12
|
+
"started",
|
|
13
|
+
"succeeded",
|
|
14
|
+
"failed",
|
|
15
|
+
"needs_human",
|
|
16
|
+
"question",
|
|
17
|
+
"digest",
|
|
18
|
+
"rolled_back",
|
|
19
|
+
"budget_warning",
|
|
20
|
+
"budget_exhausted",
|
|
21
|
+
"message"
|
|
22
|
+
];
|
|
23
|
+
var communicationOutcomeSchema = z.enum(communicationOutcomes).describe("Lifecycle outcome a connector should render and deliver.");
|
|
24
|
+
var communicationEventSchema = z.strictObject({
|
|
25
|
+
eventId: z.string().min(1).describe("Stable idempotency key for this delivery."),
|
|
26
|
+
repositoryId: repositoryIdSchema,
|
|
27
|
+
taskId: taskIdSchema.optional(),
|
|
28
|
+
changeId: changeIdSchema.optional(),
|
|
29
|
+
replyTo: replyToSchema,
|
|
30
|
+
outcome: communicationOutcomeSchema,
|
|
31
|
+
data: z.record(z.string(), z.unknown()).describe("Outcome-specific data rendered by the selected connector.")
|
|
32
|
+
});
|
|
33
|
+
function createCommunicationRouter(adapters) {
|
|
34
|
+
const byChannel = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const adapter of adapters) {
|
|
36
|
+
const channel = adapter.channel.trim();
|
|
37
|
+
if (channel.length === 0) {
|
|
38
|
+
throw new Error("Communication adapter channel is required.");
|
|
39
|
+
}
|
|
40
|
+
if (byChannel.has(channel)) {
|
|
41
|
+
throw new Error(`Communication adapter ${channel} is registered more than once.`);
|
|
42
|
+
}
|
|
43
|
+
byChannel.set(channel, adapter);
|
|
44
|
+
}
|
|
45
|
+
const channels = Object.freeze([...byChannel.keys()]);
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
channels,
|
|
48
|
+
async deliver(input) {
|
|
49
|
+
const event = communicationEventSchema.parse(input);
|
|
50
|
+
const adapter = byChannel.get(event.replyTo.channel);
|
|
51
|
+
if (adapter === void 0) {
|
|
52
|
+
throw new Error(`No communication adapter is registered for ${event.replyTo.channel}.`);
|
|
53
|
+
}
|
|
54
|
+
await adapter.deliver(event);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
communicationEventSchema,
|
|
60
|
+
communicationOutcomeSchema,
|
|
61
|
+
communicationOutcomes,
|
|
62
|
+
createCommunicationRouter
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/connectors/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { changeIdSchema, repositoryIdSchema, taskIdSchema } from \"../schema/id\";\nimport { replyToSchema } from \"../schema/common\";\n\nexport const communicationOutcomes = [\n \"accepted\",\n \"started\",\n \"succeeded\",\n \"failed\",\n \"needs_human\",\n \"question\",\n \"digest\",\n \"rolled_back\",\n \"budget_warning\",\n \"budget_exhausted\",\n \"message\",\n] as const;\n\nexport const communicationOutcomeSchema = z\n .enum(communicationOutcomes)\n .describe(\"Lifecycle outcome a connector should render and deliver.\");\n\nexport const communicationEventSchema = z.strictObject({\n eventId: z.string().min(1).describe(\"Stable idempotency key for this delivery.\"),\n repositoryId: repositoryIdSchema,\n taskId: taskIdSchema.optional(),\n changeId: changeIdSchema.optional(),\n replyTo: replyToSchema,\n outcome: communicationOutcomeSchema,\n data: z\n .record(z.string(), z.unknown())\n .describe(\"Outcome-specific data rendered by the selected connector.\"),\n});\n\nexport type CommunicationOutcome = z.infer<typeof communicationOutcomeSchema>;\nexport type CommunicationEvent = z.infer<typeof communicationEventSchema>;\n\nexport interface CommunicationAdapter {\n readonly channel: string;\n deliver(event: CommunicationEvent): Promise<void>;\n}\n\nexport interface CommunicationRouter {\n readonly channels: readonly string[];\n deliver(event: CommunicationEvent): Promise<void>;\n}\n\nexport function createCommunicationRouter(\n adapters: readonly CommunicationAdapter[],\n): CommunicationRouter {\n const byChannel = new Map<string, CommunicationAdapter>();\n for (const adapter of adapters) {\n const channel = adapter.channel.trim();\n if (channel.length === 0) {\n throw new Error(\"Communication adapter channel is required.\");\n }\n if (byChannel.has(channel)) {\n throw new Error(`Communication adapter ${channel} is registered more than once.`);\n }\n byChannel.set(channel, adapter);\n }\n const channels = Object.freeze([...byChannel.keys()]);\n\n return Object.freeze({\n channels,\n async deliver(input: CommunicationEvent): Promise<void> {\n const event = communicationEventSchema.parse(input);\n const adapter = byChannel.get(event.replyTo.channel);\n if (adapter === undefined) {\n throw new Error(`No communication adapter is registered for ${event.replyTo.channel}.`);\n }\n await adapter.deliver(event);\n },\n });\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,SAAS;AAIX,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,6BAA6B,EACvC,KAAK,qBAAqB,EAC1B,SAAS,0DAA0D;AAE/D,IAAM,2BAA2B,EAAE,aAAa;AAAA,EACrD,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,2CAA2C;AAAA,EAC/E,cAAc;AAAA,EACd,QAAQ,aAAa,SAAS;AAAA,EAC9B,UAAU,eAAe,SAAS;AAAA,EAClC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM,EACH,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAC9B,SAAS,2DAA2D;AACzE,CAAC;AAeM,SAAS,0BACd,UACqB;AACrB,QAAM,YAAY,oBAAI,IAAkC;AACxD,aAAW,WAAW,UAAU;AAC9B,UAAM,UAAU,QAAQ,QAAQ,KAAK;AACrC,QAAI,QAAQ,WAAW,GAAG;AACxB,YAAM,IAAI,MAAM,4CAA4C;AAAA,IAC9D;AACA,QAAI,UAAU,IAAI,OAAO,GAAG;AAC1B,YAAM,IAAI,MAAM,yBAAyB,OAAO,gCAAgC;AAAA,IAClF;AACA,cAAU,IAAI,SAAS,OAAO;AAAA,EAChC;AACA,QAAM,WAAW,OAAO,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;AAEpD,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,MAAM,QAAQ,OAA0C;AACtD,YAAM,QAAQ,yBAAyB,MAAM,KAAK;AAClD,YAAM,UAAU,UAAU,IAAI,MAAM,QAAQ,OAAO;AACnD,UAAI,YAAY,QAAW;AACzB,cAAM,IAAI,MAAM,8CAA8C,MAAM,QAAQ,OAAO,GAAG;AAAA,MACxF;AACA,YAAM,QAAQ,QAAQ,KAAK;AAAA,IAC7B;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/eve/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as eve_hooks from 'eve/hooks';
|
|
|
2
2
|
import * as eve_tools from 'eve/tools';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { F as FactoryStores, A as ApprovalPolicy, a as Finding } from '../approval-Z7iaWibT.js';
|
|
5
|
+
import { GitHubReviewComment } from '../github.js';
|
|
5
6
|
import '../common-CaHaEOAS.js';
|
|
6
7
|
import '../driver-tRNggCCJ.js';
|
|
7
8
|
|
|
@@ -58,6 +59,69 @@ declare function fetchPullRequestTool<S extends CommandSandbox>(stores: FactoryS
|
|
|
58
59
|
}, ctx: eve_tools.ToolContext): Promise<FetchPullRequestResult>;
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
declare const mergeConflictPayloadSchema: z.ZodObject<{
|
|
63
|
+
repository: z.ZodString;
|
|
64
|
+
prNumber: z.ZodNumber;
|
|
65
|
+
prUrl: z.ZodURL;
|
|
66
|
+
headBranch: z.ZodString;
|
|
67
|
+
headSha: z.ZodString;
|
|
68
|
+
baseBranch: z.ZodString;
|
|
69
|
+
baseSha: z.ZodString;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
type MergeConflictPayload = z.infer<typeof mergeConflictPayloadSchema>;
|
|
72
|
+
interface MergeConflictToolOptions<S extends CommandSandbox = CommandSandbox> {
|
|
73
|
+
withCredential: (sandbox: S, repository: string, command: string) => Promise<{
|
|
74
|
+
stdout: string;
|
|
75
|
+
stderr?: string;
|
|
76
|
+
exitCode?: number;
|
|
77
|
+
}>;
|
|
78
|
+
repoPath?: string;
|
|
79
|
+
}
|
|
80
|
+
declare function mergeConflictTools<S extends CommandSandbox>(stores: FactoryStores, options: MergeConflictToolOptions<S>): {
|
|
81
|
+
fetch_merge_conflict: eve_tools.ToolDefinition<{
|
|
82
|
+
taskId: string;
|
|
83
|
+
}, {
|
|
84
|
+
conflictedFiles: string[];
|
|
85
|
+
repository: string;
|
|
86
|
+
prNumber: number;
|
|
87
|
+
prUrl: string;
|
|
88
|
+
headBranch: string;
|
|
89
|
+
headSha: string;
|
|
90
|
+
baseBranch: string;
|
|
91
|
+
baseSha: string;
|
|
92
|
+
}> & {
|
|
93
|
+
execute(input: {
|
|
94
|
+
taskId: string;
|
|
95
|
+
}, ctx: eve_tools.ToolContext): Promise<{
|
|
96
|
+
conflictedFiles: string[];
|
|
97
|
+
repository: string;
|
|
98
|
+
prNumber: number;
|
|
99
|
+
prUrl: string;
|
|
100
|
+
headBranch: string;
|
|
101
|
+
headSha: string;
|
|
102
|
+
baseBranch: string;
|
|
103
|
+
baseSha: string;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
publish_merge_resolution: eve_tools.ToolDefinition<{
|
|
107
|
+
taskId: string;
|
|
108
|
+
summary: string;
|
|
109
|
+
}, {
|
|
110
|
+
updated: true;
|
|
111
|
+
prNumber: number;
|
|
112
|
+
prUrl: string;
|
|
113
|
+
}> & {
|
|
114
|
+
execute(input: {
|
|
115
|
+
taskId: string;
|
|
116
|
+
summary: string;
|
|
117
|
+
}, ctx: eve_tools.ToolContext): Promise<{
|
|
118
|
+
updated: true;
|
|
119
|
+
prNumber: number;
|
|
120
|
+
prUrl: string;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
61
125
|
interface RecordFindingOptions {
|
|
62
126
|
/** Signal source the findings are recorded under. Defaults to security_scan. */
|
|
63
127
|
source?: string;
|
|
@@ -314,6 +378,33 @@ declare function invokeAgentTool(stores: FactoryStores, options: InvokeAgentOpti
|
|
|
314
378
|
}>;
|
|
315
379
|
};
|
|
316
380
|
|
|
381
|
+
interface ReviewCommentToolOptions {
|
|
382
|
+
tokenForRepository: (repository: string) => Promise<string>;
|
|
383
|
+
fetch?: typeof globalThis.fetch;
|
|
384
|
+
}
|
|
385
|
+
declare function reviewCommentTools(stores: FactoryStores, options: ReviewCommentToolOptions): {
|
|
386
|
+
read_review_comment: eve_tools.ToolDefinition<{
|
|
387
|
+
changeId: string;
|
|
388
|
+
commentId: number;
|
|
389
|
+
}, GitHubReviewComment> & {
|
|
390
|
+
execute(input: {
|
|
391
|
+
changeId: string;
|
|
392
|
+
commentId: number;
|
|
393
|
+
}, ctx: eve_tools.ToolContext): Promise<GitHubReviewComment>;
|
|
394
|
+
};
|
|
395
|
+
answer_review_comment: eve_tools.ToolDefinition<{
|
|
396
|
+
changeId: string;
|
|
397
|
+
commentId: number;
|
|
398
|
+
body: string;
|
|
399
|
+
}, GitHubReviewComment> & {
|
|
400
|
+
execute(input: {
|
|
401
|
+
changeId: string;
|
|
402
|
+
commentId: number;
|
|
403
|
+
body: string;
|
|
404
|
+
}, ctx: eve_tools.ToolContext): Promise<GitHubReviewComment>;
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
|
|
317
408
|
/**
|
|
318
409
|
* The verifier's outcome tool. Writes evidence onto the change and moves it
|
|
319
410
|
* to ready only when the verdict is pass; a failed verdict leaves the change
|
|
@@ -959,4 +1050,4 @@ declare function factoryHooks(stores: FactoryStores): {
|
|
|
959
1050
|
};
|
|
960
1051
|
type FactoryHooks = ReturnType<typeof factoryHooks>;
|
|
961
1052
|
|
|
962
|
-
export { type CommandSandbox, type DeepsecScanOptions, type FactoryHooks, type FactoryTools, type FactoryToolsOptions, type FetchPullRequestOptions, type FetchPullRequestResult, type GateVerdict, type InvokeAgentOptions, type RecordChangeInput, type RecordFindingOptions, type RecordFindingResult, deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, recordFinding, recordFindingTool, recordVerificationTool };
|
|
1053
|
+
export { type CommandSandbox, type DeepsecScanOptions, type FactoryHooks, type FactoryTools, type FactoryToolsOptions, type FetchPullRequestOptions, type FetchPullRequestResult, type GateVerdict, type InvokeAgentOptions, type MergeConflictPayload, type MergeConflictToolOptions, type RecordChangeInput, type RecordFindingOptions, type RecordFindingResult, type ReviewCommentToolOptions, deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
|