@vercel/factory 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,507 @@
1
+ import * as eve_tools from 'eve/tools';
2
+ import { F as FactoryStores } from '../engine-BXVTLiXU.js';
3
+ import '../common-CaHaEOAS.js';
4
+ import 'zod';
5
+ import '../driver-tRNggCCJ.js';
6
+
7
+ /**
8
+ * The factory's store operations wrapped as eve tools. Expose a tool to an
9
+ * agent by re-exporting it from a file under agent/tools/, e.g.
10
+ * `export default factoryTools(stores).get_task;`. Every write goes through
11
+ * the engine, so agents inherit transition legality and receipts.
12
+ */
13
+ declare function factoryTools(stores: FactoryStores): {
14
+ get_task: eve_tools.ToolDefinition<{
15
+ taskId: string;
16
+ }, {
17
+ schemaVersion: 1;
18
+ id: string;
19
+ kind: string;
20
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
21
+ origin: {
22
+ signalId?: string | undefined;
23
+ parentTaskId?: string | undefined;
24
+ operator?: string | undefined;
25
+ };
26
+ replyTo: {
27
+ channel: string;
28
+ address: string;
29
+ };
30
+ attempt: number;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ repositoryIds?: string[] | undefined;
34
+ area?: string | undefined;
35
+ dependsOn?: string[] | undefined;
36
+ devbox?: {
37
+ devboxId: string;
38
+ remoteId: string;
39
+ harness: string;
40
+ } | undefined;
41
+ reservedUsd?: number | undefined;
42
+ settledUsd?: number | undefined;
43
+ question?: {
44
+ text: string;
45
+ options: string[];
46
+ answer?: string | undefined;
47
+ answeredBy?: string | undefined;
48
+ } | undefined;
49
+ changeId?: string | undefined;
50
+ reportRef?: string | undefined;
51
+ } | {
52
+ found: false;
53
+ taskId: string;
54
+ }> & {
55
+ execute(input: {
56
+ taskId: string;
57
+ }, ctx: eve_tools.ToolContext): Promise<{
58
+ schemaVersion: 1;
59
+ id: string;
60
+ kind: string;
61
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
62
+ origin: {
63
+ signalId?: string | undefined;
64
+ parentTaskId?: string | undefined;
65
+ operator?: string | undefined;
66
+ };
67
+ replyTo: {
68
+ channel: string;
69
+ address: string;
70
+ };
71
+ attempt: number;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ repositoryIds?: string[] | undefined;
75
+ area?: string | undefined;
76
+ dependsOn?: string[] | undefined;
77
+ devbox?: {
78
+ devboxId: string;
79
+ remoteId: string;
80
+ harness: string;
81
+ } | undefined;
82
+ reservedUsd?: number | undefined;
83
+ settledUsd?: number | undefined;
84
+ question?: {
85
+ text: string;
86
+ options: string[];
87
+ answer?: string | undefined;
88
+ answeredBy?: string | undefined;
89
+ } | undefined;
90
+ changeId?: string | undefined;
91
+ reportRef?: string | undefined;
92
+ } | {
93
+ found: false;
94
+ taskId: string;
95
+ }>;
96
+ };
97
+ decide_signal: eve_tools.ToolDefinition<{
98
+ signalId: string;
99
+ outcome: "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored";
100
+ reason: string;
101
+ detail?: string | undefined;
102
+ }, {
103
+ schemaVersion: 1;
104
+ id: string;
105
+ repositoryId: string;
106
+ source: string;
107
+ deliveryId: string;
108
+ replyTo: {
109
+ channel: string;
110
+ address: string;
111
+ };
112
+ payload: unknown;
113
+ receivedAt: string;
114
+ outcome: "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored" | "pending";
115
+ detail?: string | undefined;
116
+ reason?: string | undefined;
117
+ decidedAt?: string | undefined;
118
+ }> & {
119
+ execute(input: {
120
+ signalId: string;
121
+ outcome: "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored";
122
+ reason: string;
123
+ detail?: string | undefined;
124
+ }, ctx: eve_tools.ToolContext): Promise<{
125
+ schemaVersion: 1;
126
+ id: string;
127
+ repositoryId: string;
128
+ source: string;
129
+ deliveryId: string;
130
+ replyTo: {
131
+ channel: string;
132
+ address: string;
133
+ };
134
+ payload: unknown;
135
+ receivedAt: string;
136
+ outcome: "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored" | "pending";
137
+ detail?: string | undefined;
138
+ reason?: string | undefined;
139
+ decidedAt?: string | undefined;
140
+ }>;
141
+ };
142
+ record_change: eve_tools.ToolDefinition<{
143
+ taskId: string;
144
+ repositoryId: string;
145
+ prNumber: number;
146
+ prUrl: string;
147
+ risk: "low" | "medium" | "high";
148
+ confidence: "low" | "medium" | "high";
149
+ summary: string;
150
+ }, {
151
+ change: {
152
+ schemaVersion: 1;
153
+ id: string;
154
+ repositoryId: string;
155
+ prNumber: number;
156
+ prUrl: string;
157
+ author: string;
158
+ risk: "low" | "medium" | "high";
159
+ confidence: "low" | "medium" | "high";
160
+ evidence: {
161
+ reproVerified: boolean;
162
+ testsAdded: number;
163
+ checksGreen: boolean;
164
+ attackPassed: boolean;
165
+ scopeMatches: boolean;
166
+ previewUrl?: string | undefined;
167
+ };
168
+ state: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
169
+ createdAt: string;
170
+ updatedAt: string;
171
+ taskId?: string | undefined;
172
+ groupId?: string | undefined;
173
+ decidedBy?: string | undefined;
174
+ };
175
+ task: {
176
+ schemaVersion: 1;
177
+ id: string;
178
+ kind: string;
179
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
180
+ origin: {
181
+ signalId?: string | undefined;
182
+ parentTaskId?: string | undefined;
183
+ operator?: string | undefined;
184
+ };
185
+ replyTo: {
186
+ channel: string;
187
+ address: string;
188
+ };
189
+ attempt: number;
190
+ createdAt: string;
191
+ updatedAt: string;
192
+ repositoryIds?: string[] | undefined;
193
+ area?: string | undefined;
194
+ dependsOn?: string[] | undefined;
195
+ devbox?: {
196
+ devboxId: string;
197
+ remoteId: string;
198
+ harness: string;
199
+ } | undefined;
200
+ reservedUsd?: number | undefined;
201
+ settledUsd?: number | undefined;
202
+ question?: {
203
+ text: string;
204
+ options: string[];
205
+ answer?: string | undefined;
206
+ answeredBy?: string | undefined;
207
+ } | undefined;
208
+ changeId?: string | undefined;
209
+ reportRef?: string | undefined;
210
+ };
211
+ }> & {
212
+ execute(input: {
213
+ taskId: string;
214
+ repositoryId: string;
215
+ prNumber: number;
216
+ prUrl: string;
217
+ risk: "low" | "medium" | "high";
218
+ confidence: "low" | "medium" | "high";
219
+ summary: string;
220
+ }, ctx: eve_tools.ToolContext): Promise<{
221
+ change: {
222
+ schemaVersion: 1;
223
+ id: string;
224
+ repositoryId: string;
225
+ prNumber: number;
226
+ prUrl: string;
227
+ author: string;
228
+ risk: "low" | "medium" | "high";
229
+ confidence: "low" | "medium" | "high";
230
+ evidence: {
231
+ reproVerified: boolean;
232
+ testsAdded: number;
233
+ checksGreen: boolean;
234
+ attackPassed: boolean;
235
+ scopeMatches: boolean;
236
+ previewUrl?: string | undefined;
237
+ };
238
+ state: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
239
+ createdAt: string;
240
+ updatedAt: string;
241
+ taskId?: string | undefined;
242
+ groupId?: string | undefined;
243
+ decidedBy?: string | undefined;
244
+ };
245
+ task: {
246
+ schemaVersion: 1;
247
+ id: string;
248
+ kind: string;
249
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
250
+ origin: {
251
+ signalId?: string | undefined;
252
+ parentTaskId?: string | undefined;
253
+ operator?: string | undefined;
254
+ };
255
+ replyTo: {
256
+ channel: string;
257
+ address: string;
258
+ };
259
+ attempt: number;
260
+ createdAt: string;
261
+ updatedAt: string;
262
+ repositoryIds?: string[] | undefined;
263
+ area?: string | undefined;
264
+ dependsOn?: string[] | undefined;
265
+ devbox?: {
266
+ devboxId: string;
267
+ remoteId: string;
268
+ harness: string;
269
+ } | undefined;
270
+ reservedUsd?: number | undefined;
271
+ settledUsd?: number | undefined;
272
+ question?: {
273
+ text: string;
274
+ options: string[];
275
+ answer?: string | undefined;
276
+ answeredBy?: string | undefined;
277
+ } | undefined;
278
+ changeId?: string | undefined;
279
+ reportRef?: string | undefined;
280
+ };
281
+ }>;
282
+ };
283
+ report_blocked: eve_tools.ToolDefinition<{
284
+ taskId: string;
285
+ reason: string;
286
+ }, {
287
+ schemaVersion: 1;
288
+ id: string;
289
+ kind: string;
290
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
291
+ origin: {
292
+ signalId?: string | undefined;
293
+ parentTaskId?: string | undefined;
294
+ operator?: string | undefined;
295
+ };
296
+ replyTo: {
297
+ channel: string;
298
+ address: string;
299
+ };
300
+ attempt: number;
301
+ createdAt: string;
302
+ updatedAt: string;
303
+ repositoryIds?: string[] | undefined;
304
+ area?: string | undefined;
305
+ dependsOn?: string[] | undefined;
306
+ devbox?: {
307
+ devboxId: string;
308
+ remoteId: string;
309
+ harness: string;
310
+ } | undefined;
311
+ reservedUsd?: number | undefined;
312
+ settledUsd?: number | undefined;
313
+ question?: {
314
+ text: string;
315
+ options: string[];
316
+ answer?: string | undefined;
317
+ answeredBy?: string | undefined;
318
+ } | undefined;
319
+ changeId?: string | undefined;
320
+ reportRef?: string | undefined;
321
+ }> & {
322
+ execute(input: {
323
+ taskId: string;
324
+ reason: string;
325
+ }, ctx: eve_tools.ToolContext): Promise<{
326
+ schemaVersion: 1;
327
+ id: string;
328
+ kind: string;
329
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
330
+ origin: {
331
+ signalId?: string | undefined;
332
+ parentTaskId?: string | undefined;
333
+ operator?: string | undefined;
334
+ };
335
+ replyTo: {
336
+ channel: string;
337
+ address: string;
338
+ };
339
+ attempt: number;
340
+ createdAt: string;
341
+ updatedAt: string;
342
+ repositoryIds?: string[] | undefined;
343
+ area?: string | undefined;
344
+ dependsOn?: string[] | undefined;
345
+ devbox?: {
346
+ devboxId: string;
347
+ remoteId: string;
348
+ harness: string;
349
+ } | undefined;
350
+ reservedUsd?: number | undefined;
351
+ settledUsd?: number | undefined;
352
+ question?: {
353
+ text: string;
354
+ options: string[];
355
+ answer?: string | undefined;
356
+ answeredBy?: string | undefined;
357
+ } | undefined;
358
+ changeId?: string | undefined;
359
+ reportRef?: string | undefined;
360
+ }>;
361
+ };
362
+ ask_question: eve_tools.ToolDefinition<{
363
+ repositoryIds: string[];
364
+ channel: string;
365
+ address: string;
366
+ question: {
367
+ text: string;
368
+ options: string[];
369
+ };
370
+ parentTaskId?: string | undefined;
371
+ }, {
372
+ schemaVersion: 1;
373
+ id: string;
374
+ kind: string;
375
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
376
+ origin: {
377
+ signalId?: string | undefined;
378
+ parentTaskId?: string | undefined;
379
+ operator?: string | undefined;
380
+ };
381
+ replyTo: {
382
+ channel: string;
383
+ address: string;
384
+ };
385
+ attempt: number;
386
+ createdAt: string;
387
+ updatedAt: string;
388
+ repositoryIds?: string[] | undefined;
389
+ area?: string | undefined;
390
+ dependsOn?: string[] | undefined;
391
+ devbox?: {
392
+ devboxId: string;
393
+ remoteId: string;
394
+ harness: string;
395
+ } | undefined;
396
+ reservedUsd?: number | undefined;
397
+ settledUsd?: number | undefined;
398
+ question?: {
399
+ text: string;
400
+ options: string[];
401
+ answer?: string | undefined;
402
+ answeredBy?: string | undefined;
403
+ } | undefined;
404
+ changeId?: string | undefined;
405
+ reportRef?: string | undefined;
406
+ }> & {
407
+ execute(input: {
408
+ repositoryIds: string[];
409
+ channel: string;
410
+ address: string;
411
+ question: {
412
+ text: string;
413
+ options: string[];
414
+ };
415
+ parentTaskId?: string | undefined;
416
+ }, ctx: eve_tools.ToolContext): Promise<{
417
+ schemaVersion: 1;
418
+ id: string;
419
+ kind: string;
420
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
421
+ origin: {
422
+ signalId?: string | undefined;
423
+ parentTaskId?: string | undefined;
424
+ operator?: string | undefined;
425
+ };
426
+ replyTo: {
427
+ channel: string;
428
+ address: string;
429
+ };
430
+ attempt: number;
431
+ createdAt: string;
432
+ updatedAt: string;
433
+ repositoryIds?: string[] | undefined;
434
+ area?: string | undefined;
435
+ dependsOn?: string[] | undefined;
436
+ devbox?: {
437
+ devboxId: string;
438
+ remoteId: string;
439
+ harness: string;
440
+ } | undefined;
441
+ reservedUsd?: number | undefined;
442
+ settledUsd?: number | undefined;
443
+ question?: {
444
+ text: string;
445
+ options: string[];
446
+ answer?: string | undefined;
447
+ answeredBy?: string | undefined;
448
+ } | undefined;
449
+ changeId?: string | undefined;
450
+ reportRef?: string | undefined;
451
+ }>;
452
+ };
453
+ append_receipt: eve_tools.ToolDefinition<{
454
+ repositoryIds: string[];
455
+ kind: string;
456
+ state: string;
457
+ taskId?: string | undefined;
458
+ changeId?: string | undefined;
459
+ reason?: string | undefined;
460
+ dedupeKey?: string | undefined;
461
+ }, {
462
+ schemaVersion: 1;
463
+ receiptId: string;
464
+ repositoryIds: string[];
465
+ kind: string;
466
+ state: string;
467
+ attempt: number;
468
+ recordedAt: string;
469
+ taskId?: string | undefined;
470
+ changeId?: string | undefined;
471
+ phase?: string | undefined;
472
+ reason?: string | undefined;
473
+ cost?: {
474
+ totalUsd: number;
475
+ } | undefined;
476
+ decidedBy?: string | undefined;
477
+ }> & {
478
+ execute(input: {
479
+ repositoryIds: string[];
480
+ kind: string;
481
+ state: string;
482
+ taskId?: string | undefined;
483
+ changeId?: string | undefined;
484
+ reason?: string | undefined;
485
+ dedupeKey?: string | undefined;
486
+ }, ctx: eve_tools.ToolContext): Promise<{
487
+ schemaVersion: 1;
488
+ receiptId: string;
489
+ repositoryIds: string[];
490
+ kind: string;
491
+ state: string;
492
+ attempt: number;
493
+ recordedAt: string;
494
+ taskId?: string | undefined;
495
+ changeId?: string | undefined;
496
+ phase?: string | undefined;
497
+ reason?: string | undefined;
498
+ cost?: {
499
+ totalUsd: number;
500
+ } | undefined;
501
+ decidedBy?: string | undefined;
502
+ }>;
503
+ };
504
+ };
505
+ type FactoryTools = ReturnType<typeof factoryTools>;
506
+
507
+ export { type FactoryTools, factoryTools };
@@ -0,0 +1,128 @@
1
+ import {
2
+ changeIdSchema,
3
+ levelSchema,
4
+ repositoryIdSchema,
5
+ signalIdSchema,
6
+ taskIdSchema,
7
+ taskQuestionSchema,
8
+ vocabularySchema
9
+ } from "../chunk-BSDWPFKE.js";
10
+
11
+ // src/eve/index.ts
12
+ import { defineTool } from "eve/tools";
13
+ import { z } from "zod";
14
+ var decidedOutcomeSchema = z.enum([
15
+ "accepted",
16
+ "duplicate",
17
+ "unactionable",
18
+ "low_confidence",
19
+ "ignored"
20
+ ]);
21
+ function factoryTools(stores) {
22
+ return {
23
+ get_task: defineTool({
24
+ description: "Read one factory task by id: its kind, state, repositories, origin, and results.",
25
+ inputSchema: z.object({ taskId: taskIdSchema }),
26
+ async execute({ taskId }) {
27
+ const task = await stores.tasks.get(taskId);
28
+ return task ?? { found: false, taskId };
29
+ }
30
+ }),
31
+ decide_signal: defineTool({
32
+ description: "Record the triage decision for a pending signal. A signal is decided exactly once.",
33
+ inputSchema: z.object({
34
+ signalId: signalIdSchema,
35
+ outcome: decidedOutcomeSchema,
36
+ reason: z.string().min(1).describe("Why this outcome was chosen."),
37
+ detail: z.string().min(1).optional().describe("Severity if accepted, or the duplicate-of signal id.")
38
+ }),
39
+ execute({ signalId, outcome, reason, detail }) {
40
+ return stores.signals.decide(signalId, outcome, { reason, detail });
41
+ }
42
+ }),
43
+ record_change: defineTool({
44
+ description: "Record the pull request produced for a code_change task. Creates the change, links it to the task, and moves the task to verifying.",
45
+ inputSchema: z.object({
46
+ taskId: taskIdSchema,
47
+ repositoryId: repositoryIdSchema,
48
+ prNumber: z.number().int().min(1),
49
+ prUrl: z.url(),
50
+ risk: levelSchema.describe("Blast radius of the change if it is wrong."),
51
+ confidence: levelSchema.describe("How certain you are the change is correct."),
52
+ summary: z.string().min(1).describe("One-sentence description of the change.")
53
+ }),
54
+ async execute({ taskId, repositoryId, prNumber, prUrl, risk, confidence, summary }) {
55
+ const change = await stores.changes.create({
56
+ repositoryId,
57
+ taskId,
58
+ prNumber,
59
+ prUrl,
60
+ author: "factory",
61
+ risk,
62
+ confidence,
63
+ evidence: {
64
+ reproVerified: false,
65
+ testsAdded: 0,
66
+ checksGreen: false,
67
+ attackPassed: false,
68
+ scopeMatches: false
69
+ }
70
+ });
71
+ const task = await stores.tasks.transition(taskId, "verifying", {
72
+ patch: { changeId: change.id },
73
+ reason: summary
74
+ });
75
+ return { change, task };
76
+ }
77
+ }),
78
+ report_blocked: defineTool({
79
+ description: "Mark a running task as needing a human because the work cannot continue without help.",
80
+ inputSchema: z.object({
81
+ taskId: taskIdSchema,
82
+ reason: z.string().min(1).describe("What is blocking, written for the human.")
83
+ }),
84
+ execute({ taskId, reason }) {
85
+ return stores.tasks.transition(taskId, "needs_human", { reason });
86
+ }
87
+ }),
88
+ ask_question: defineTool({
89
+ description: "Raise a question a human operator must answer. Creates a question task that waits for the answer.",
90
+ inputSchema: z.object({
91
+ repositoryIds: z.array(repositoryIdSchema).min(1),
92
+ parentTaskId: taskIdSchema.optional().describe("Task the answer unblocks, when there is one."),
93
+ channel: z.string().min(1).describe("Reply connector, e.g. github."),
94
+ address: z.string().min(1).describe("Reply address, e.g. acme/web#41."),
95
+ question: taskQuestionSchema.omit({ answer: true, answeredBy: true })
96
+ }),
97
+ async execute({ repositoryIds, parentTaskId, channel, address, question }) {
98
+ const task = await stores.tasks.create({
99
+ repositoryIds,
100
+ kind: "question",
101
+ origin: parentTaskId === void 0 ? { operator: "factory" } : { parentTaskId },
102
+ replyTo: { channel, address },
103
+ question
104
+ });
105
+ return stores.tasks.transition(task.id, "needs_human");
106
+ }
107
+ }),
108
+ append_receipt: defineTool({
109
+ description: "Append one immutable audit receipt for an event worth remembering. Receipts can never be edited or deleted.",
110
+ inputSchema: z.object({
111
+ repositoryIds: z.array(repositoryIdSchema).min(1),
112
+ taskId: taskIdSchema.optional(),
113
+ changeId: changeIdSchema.optional(),
114
+ kind: vocabularySchema.describe("What the receipt is about, e.g. investigation."),
115
+ state: vocabularySchema.describe("What happened, e.g. flag_ramped."),
116
+ reason: z.string().min(1).max(2e3).optional(),
117
+ dedupeKey: z.string().min(1).optional().describe("Same key twice records one receipt instead of two.")
118
+ }),
119
+ execute(input) {
120
+ return stores.receipts.append(input);
121
+ }
122
+ })
123
+ };
124
+ }
125
+ export {
126
+ factoryTools
127
+ };
128
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/eve/index.ts"],"sourcesContent":["import { defineTool } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { changeIdSchema, repositoryIdSchema, signalIdSchema, taskIdSchema } from \"../schema/id\";\nimport { levelSchema } from \"../schema/change\";\nimport { vocabularySchema } from \"../schema/common\";\nimport { taskQuestionSchema } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\n\nconst decidedOutcomeSchema = z.enum([\n \"accepted\",\n \"duplicate\",\n \"unactionable\",\n \"low_confidence\",\n \"ignored\",\n]);\n\n/**\n * The factory's store operations wrapped as eve tools. Expose a tool to an\n * agent by re-exporting it from a file under agent/tools/, e.g.\n * `export default factoryTools(stores).get_task;`. Every write goes through\n * the engine, so agents inherit transition legality and receipts.\n */\nexport function factoryTools(stores: FactoryStores) {\n return {\n get_task: defineTool({\n description:\n \"Read one factory task by id: its kind, state, repositories, origin, and results.\",\n inputSchema: z.object({ taskId: taskIdSchema }),\n async execute({ taskId }) {\n const task = await stores.tasks.get(taskId);\n return task ?? { found: false as const, taskId };\n },\n }),\n\n decide_signal: defineTool({\n description:\n \"Record the triage decision for a pending signal. A signal is decided exactly once.\",\n inputSchema: z.object({\n signalId: signalIdSchema,\n outcome: decidedOutcomeSchema,\n reason: z.string().min(1).describe(\"Why this outcome was chosen.\"),\n detail: z\n .string()\n .min(1)\n .optional()\n .describe(\"Severity if accepted, or the duplicate-of signal id.\"),\n }),\n execute({ signalId, outcome, reason, detail }) {\n return stores.signals.decide(signalId, outcome, { reason, detail });\n },\n }),\n\n record_change: defineTool({\n description:\n \"Record the pull request produced for a code_change task. Creates the change, links it to the task, and moves the task to verifying.\",\n inputSchema: z.object({\n taskId: taskIdSchema,\n repositoryId: repositoryIdSchema,\n prNumber: z.number().int().min(1),\n prUrl: z.url(),\n risk: levelSchema.describe(\"Blast radius of the change if it is wrong.\"),\n confidence: levelSchema.describe(\"How certain you are the change is correct.\"),\n summary: z.string().min(1).describe(\"One-sentence description of the change.\"),\n }),\n async execute({ taskId, repositoryId, prNumber, prUrl, risk, confidence, summary }) {\n const change = await stores.changes.create({\n repositoryId,\n taskId,\n prNumber,\n prUrl,\n author: \"factory\",\n risk,\n confidence,\n evidence: {\n reproVerified: false,\n testsAdded: 0,\n checksGreen: false,\n attackPassed: false,\n scopeMatches: false,\n },\n });\n const task = await stores.tasks.transition(taskId, \"verifying\", {\n patch: { changeId: change.id },\n reason: summary,\n });\n return { change, task };\n },\n }),\n\n report_blocked: defineTool({\n description:\n \"Mark a running task as needing a human because the work cannot continue without help.\",\n inputSchema: z.object({\n taskId: taskIdSchema,\n reason: z.string().min(1).describe(\"What is blocking, written for the human.\"),\n }),\n execute({ taskId, reason }) {\n return stores.tasks.transition(taskId, \"needs_human\", { reason });\n },\n }),\n\n ask_question: defineTool({\n description:\n \"Raise a question a human operator must answer. Creates a question task that waits for the answer.\",\n inputSchema: z.object({\n repositoryIds: z.array(repositoryIdSchema).min(1),\n parentTaskId: taskIdSchema\n .optional()\n .describe(\"Task the answer unblocks, when there is one.\"),\n channel: z.string().min(1).describe(\"Reply connector, e.g. github.\"),\n address: z.string().min(1).describe(\"Reply address, e.g. acme/web#41.\"),\n question: taskQuestionSchema.omit({ answer: true, answeredBy: true }),\n }),\n async execute({ repositoryIds, parentTaskId, channel, address, question }) {\n const task = await stores.tasks.create({\n repositoryIds,\n kind: \"question\",\n origin: parentTaskId === undefined ? { operator: \"factory\" } : { parentTaskId },\n replyTo: { channel, address },\n question,\n });\n return stores.tasks.transition(task.id, \"needs_human\");\n },\n }),\n\n append_receipt: defineTool({\n description:\n \"Append one immutable audit receipt for an event worth remembering. Receipts can never be edited or deleted.\",\n inputSchema: z.object({\n repositoryIds: z.array(repositoryIdSchema).min(1),\n taskId: taskIdSchema.optional(),\n changeId: changeIdSchema.optional(),\n kind: vocabularySchema.describe(\"What the receipt is about, e.g. investigation.\"),\n state: vocabularySchema.describe(\"What happened, e.g. flag_ramped.\"),\n reason: z.string().min(1).max(2000).optional(),\n dedupeKey: z\n .string()\n .min(1)\n .optional()\n .describe(\"Same key twice records one receipt instead of two.\"),\n }),\n execute(input) {\n return stores.receipts.append(input);\n },\n }),\n };\n}\n\nexport type FactoryTools = ReturnType<typeof factoryTools>;\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAOlB,IAAM,uBAAuB,EAAE,KAAK;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAQM,SAAS,aAAa,QAAuB;AAClD,SAAO;AAAA,IACL,UAAU,WAAW;AAAA,MACnB,aACE;AAAA,MACF,aAAa,EAAE,OAAO,EAAE,QAAQ,aAAa,CAAC;AAAA,MAC9C,MAAM,QAAQ,EAAE,OAAO,GAAG;AACxB,cAAM,OAAO,MAAM,OAAO,MAAM,IAAI,MAAM;AAC1C,eAAO,QAAQ,EAAE,OAAO,OAAgB,OAAO;AAAA,MACjD;AAAA,IACF,CAAC;AAAA,IAED,eAAe,WAAW;AAAA,MACxB,aACE;AAAA,MACF,aAAa,EAAE,OAAO;AAAA,QACpB,UAAU;AAAA,QACV,SAAS;AAAA,QACT,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,8BAA8B;AAAA,QACjE,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL,SAAS,EACT,SAAS,sDAAsD;AAAA,MACpE,CAAC;AAAA,MACD,QAAQ,EAAE,UAAU,SAAS,QAAQ,OAAO,GAAG;AAC7C,eAAO,OAAO,QAAQ,OAAO,UAAU,S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