@vercel/factory 0.0.11 → 0.0.13
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/dist/approval-CwhTP1XB.mjs +269 -0
- package/dist/approval-CwhTP1XB.mjs.map +1 -0
- package/dist/blob/index.d.mts +1 -1
- package/dist/build-factory.d.mts +1 -1
- package/dist/build-factory.mjs +1 -1
- package/dist/change-CzEAoFVE.mjs +620 -0
- package/dist/change-CzEAoFVE.mjs.map +1 -0
- package/dist/connectors/slack.d.mts +4 -4
- package/dist/connectors/slack.mjs +81 -30
- package/dist/connectors/slack.mjs.map +1 -1
- package/dist/{approval-CDiBco2V.d.mts → dispatch-B77cuPxh.d.mts} +293 -99
- package/dist/{driver-CrZsy7sm.d.mts → driver-BJutB0PE.d.mts} +2 -2
- package/dist/driver-Bbd25rNM.mjs.map +1 -1
- package/dist/eve/index.d.mts +546 -120
- package/dist/eve/index.mjs +358 -82
- package/dist/eve/index.mjs.map +1 -1
- package/dist/{factory-config-ifd3JxiU.mjs → factory-config-BJcjsPKl.mjs} +42 -5
- package/dist/factory-config-BJcjsPKl.mjs.map +1 -0
- package/dist/{factory-config-Bu4mklm9.d.mts → factory-config-D2yU3G0c.d.mts} +21 -2
- package/dist/{github-wThBfbm-.d.mts → github-DXsxboUL.d.mts} +25 -2
- package/dist/github.d.mts +2 -2
- package/dist/github.mjs +47 -1
- package/dist/github.mjs.map +1 -1
- package/dist/index.d.mts +129 -59
- package/dist/index.mjs +336 -333
- package/dist/index.mjs.map +1 -1
- package/dist/postgres/index.d.mts +1 -1
- package/package.json +1 -1
- package/dist/approval-DdvEKLiE.mjs +0 -132
- package/dist/approval-DdvEKLiE.mjs.map +0 -1
- package/dist/change-BPYhWKuL.mjs +0 -230
- package/dist/change-BPYhWKuL.mjs.map +0 -1
- package/dist/factory-config-ifd3JxiU.mjs.map +0 -1
|
@@ -1,6 +1,133 @@
|
|
|
1
|
-
import { i as StoreDriver } from "./driver-
|
|
1
|
+
import { i as StoreDriver } from "./driver-BJutB0PE.mjs";
|
|
2
2
|
import { c as ReplyTo, n as SignalOutcome, r as SignalSource, t as Signal } from "./signal-CHVEmzvI.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
//#region src/schema/task.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Kinds the standard loop understands. Any vocabulary value is valid; the
|
|
7
|
+
* kind-scoped rules below apply only to these standard kinds.
|
|
8
|
+
*/
|
|
9
|
+
declare const standardTaskKinds: readonly ["coordination", "code_change", "verification", "investigation", "question"];
|
|
10
|
+
declare const taskKindSchema: z.ZodString;
|
|
11
|
+
declare const taskStateSchema: z.ZodEnum<{
|
|
12
|
+
queued: "queued";
|
|
13
|
+
running: "running";
|
|
14
|
+
stalled: "stalled";
|
|
15
|
+
verifying: "verifying";
|
|
16
|
+
succeeded: "succeeded";
|
|
17
|
+
failed: "failed";
|
|
18
|
+
needs_human: "needs_human";
|
|
19
|
+
cancelled: "cancelled";
|
|
20
|
+
}>;
|
|
21
|
+
declare const taskApprovalSchema: z.ZodEnum<{
|
|
22
|
+
required: "required";
|
|
23
|
+
granted: "granted";
|
|
24
|
+
denied: "denied";
|
|
25
|
+
}>;
|
|
26
|
+
declare const taskExecutionRepositoryIdsSchema: z.ZodTuple<[z.ZodString], null>;
|
|
27
|
+
declare const coordinationRepositoryIdsSchema: z.ZodTuple<[z.ZodString, z.ZodString], z.ZodString>;
|
|
28
|
+
declare const taskOriginSchema: z.ZodObject<{
|
|
29
|
+
signalId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
parentTaskId: z.ZodOptional<z.ZodString>;
|
|
31
|
+
operator: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
declare const harnessSchema: z.ZodString;
|
|
34
|
+
/**
|
|
35
|
+
* The provider's handle on the current attempt's execution. Opaque to the
|
|
36
|
+
* lifecycle: Factory records it so the execution can be inspected or
|
|
37
|
+
* cancelled, never to mirror the provider's own state machine.
|
|
38
|
+
*/
|
|
39
|
+
declare const executionReferenceSchema: z.ZodObject<{
|
|
40
|
+
provider: z.ZodString;
|
|
41
|
+
sessionId: z.ZodString;
|
|
42
|
+
environmentId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
harness: z.ZodOptional<z.ZodString>;
|
|
44
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
declare const taskUsageSchema: z.ZodObject<{
|
|
47
|
+
costUsd: z.ZodNumber;
|
|
48
|
+
inputTokens: z.ZodNumber;
|
|
49
|
+
outputTokens: z.ZodNumber;
|
|
50
|
+
cacheReadTokens: z.ZodNumber;
|
|
51
|
+
cacheWriteTokens: z.ZodNumber;
|
|
52
|
+
steps: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
declare const taskQuestionSchema: z.ZodObject<{
|
|
55
|
+
text: z.ZodString;
|
|
56
|
+
options: z.ZodArray<z.ZodString>;
|
|
57
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
58
|
+
answeredBy: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
declare const taskSchema: z.ZodObject<{
|
|
61
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
repositoryIds: z.ZodArray<z.ZodString>;
|
|
64
|
+
kind: z.ZodString;
|
|
65
|
+
area: z.ZodOptional<z.ZodString>;
|
|
66
|
+
state: z.ZodEnum<{
|
|
67
|
+
queued: "queued";
|
|
68
|
+
running: "running";
|
|
69
|
+
stalled: "stalled";
|
|
70
|
+
verifying: "verifying";
|
|
71
|
+
succeeded: "succeeded";
|
|
72
|
+
failed: "failed";
|
|
73
|
+
needs_human: "needs_human";
|
|
74
|
+
cancelled: "cancelled";
|
|
75
|
+
}>;
|
|
76
|
+
approval: z.ZodOptional<z.ZodEnum<{
|
|
77
|
+
required: "required";
|
|
78
|
+
granted: "granted";
|
|
79
|
+
denied: "denied";
|
|
80
|
+
}>>;
|
|
81
|
+
origin: z.ZodObject<{
|
|
82
|
+
signalId: z.ZodOptional<z.ZodString>;
|
|
83
|
+
parentTaskId: z.ZodOptional<z.ZodString>;
|
|
84
|
+
operator: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
replyTo: z.ZodObject<{
|
|
88
|
+
channel: z.ZodString;
|
|
89
|
+
address: z.ZodString;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
attempt: z.ZodNumber;
|
|
92
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
provider: z.ZodString;
|
|
94
|
+
sessionId: z.ZodString;
|
|
95
|
+
environmentId: z.ZodOptional<z.ZodString>;
|
|
96
|
+
harness: z.ZodOptional<z.ZodString>;
|
|
97
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
lastProgressAt: z.ZodOptional<z.ZodISODateTime>;
|
|
100
|
+
stalledAt: z.ZodOptional<z.ZodISODateTime>;
|
|
101
|
+
stalledReason: z.ZodOptional<z.ZodString>;
|
|
102
|
+
reservedUsd: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
reservedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
104
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
costUsd: z.ZodNumber;
|
|
106
|
+
inputTokens: z.ZodNumber;
|
|
107
|
+
outputTokens: z.ZodNumber;
|
|
108
|
+
cacheReadTokens: z.ZodNumber;
|
|
109
|
+
cacheWriteTokens: z.ZodNumber;
|
|
110
|
+
steps: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
111
|
+
}, z.core.$strict>>;
|
|
112
|
+
settledUsd: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
question: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
text: z.ZodString;
|
|
115
|
+
options: z.ZodArray<z.ZodString>;
|
|
116
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
117
|
+
answeredBy: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strict>>;
|
|
119
|
+
changeId: z.ZodOptional<z.ZodString>;
|
|
120
|
+
reportRef: z.ZodOptional<z.ZodString>;
|
|
121
|
+
createdAt: z.ZodISODateTime;
|
|
122
|
+
updatedAt: z.ZodISODateTime;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
type TaskApproval = z.infer<typeof taskApprovalSchema>;
|
|
125
|
+
type TaskKind = z.infer<typeof taskKindSchema>;
|
|
126
|
+
type TaskState = z.infer<typeof taskStateSchema>;
|
|
127
|
+
type TaskUsage = z.infer<typeof taskUsageSchema>;
|
|
128
|
+
type ExecutionReference = z.infer<typeof executionReferenceSchema>;
|
|
129
|
+
type Task = z.infer<typeof taskSchema>;
|
|
130
|
+
//#endregion
|
|
4
131
|
//#region src/schema/id.d.ts
|
|
5
132
|
declare const factoryIdSchema: z.ZodString;
|
|
6
133
|
declare const repositoryIdSchema: z.ZodString;
|
|
@@ -16,6 +143,34 @@ type TaskId = z.infer<typeof taskIdSchema>;
|
|
|
16
143
|
type ChangeId = z.infer<typeof changeIdSchema>;
|
|
17
144
|
type ReceiptId = z.infer<typeof receiptIdSchema>;
|
|
18
145
|
//#endregion
|
|
146
|
+
//#region src/schema/budget.d.ts
|
|
147
|
+
declare const budgetMonthSchema: z.ZodString;
|
|
148
|
+
declare const budgetLimitsSchema: z.ZodObject<{
|
|
149
|
+
totalUsd: z.ZodNumber;
|
|
150
|
+
investigationUsd: z.ZodNumber;
|
|
151
|
+
perTaskReservationUsd: z.ZodNumber;
|
|
152
|
+
warningPercent: z.ZodNumber;
|
|
153
|
+
perRepositoryUsd: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
declare const budgetSchema: z.ZodObject<{
|
|
156
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
157
|
+
factoryId: z.ZodString;
|
|
158
|
+
month: z.ZodString;
|
|
159
|
+
limits: z.ZodObject<{
|
|
160
|
+
totalUsd: z.ZodNumber;
|
|
161
|
+
investigationUsd: z.ZodNumber;
|
|
162
|
+
perTaskReservationUsd: z.ZodNumber;
|
|
163
|
+
warningPercent: z.ZodNumber;
|
|
164
|
+
perRepositoryUsd: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
165
|
+
}, z.core.$strict>;
|
|
166
|
+
notices: z.ZodObject<{
|
|
167
|
+
warningAt: z.ZodOptional<z.ZodISODateTime>;
|
|
168
|
+
exhaustedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
169
|
+
}, z.core.$strict>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
type BudgetLimits = z.infer<typeof budgetLimitsSchema>;
|
|
172
|
+
type Budget = z.infer<typeof budgetSchema>;
|
|
173
|
+
//#endregion
|
|
19
174
|
//#region src/schema/change.d.ts
|
|
20
175
|
declare const levelSchema: z.ZodEnum<{
|
|
21
176
|
low: "low";
|
|
@@ -87,7 +242,7 @@ type Change = z.infer<typeof changeSchema>;
|
|
|
87
242
|
//#endregion
|
|
88
243
|
//#region src/schema/receipt.d.ts
|
|
89
244
|
/** States the engine writes on transitions. Any vocabulary value is valid. */
|
|
90
|
-
declare const standardReceiptStates: readonly ["approved", "rejected", "dispatched", "succeeded", "failed", "needs_human", "cancelled", "settled", "ready", "merged", "deployed", "rolled_out", "rolled_back"];
|
|
245
|
+
declare const standardReceiptStates: readonly ["approved", "rejected", "dispatched", "stalled", "succeeded", "failed", "needs_human", "cancelled", "settled", "ready", "merged", "deployed", "rolled_out", "rolled_back"];
|
|
91
246
|
/** Phases the standard loop uses. Any vocabulary value is valid. */
|
|
92
247
|
declare const standardReceiptPhases: readonly ["approval", "budget", "dispatch", "implementation", "verification", "pull_request", "cleanup"];
|
|
93
248
|
/** Kinds the standard loop writes: the standard task kinds plus "change". */
|
|
@@ -140,100 +295,6 @@ declare const repositorySchema: z.ZodObject<{
|
|
|
140
295
|
type RepositorySlug = z.infer<typeof repositorySlugSchema>;
|
|
141
296
|
type Repository = z.infer<typeof repositorySchema>;
|
|
142
297
|
//#endregion
|
|
143
|
-
//#region src/schema/task.d.ts
|
|
144
|
-
/**
|
|
145
|
-
* Kinds the standard loop understands. Any vocabulary value is valid; the
|
|
146
|
-
* kind-scoped rules below apply only to these standard kinds.
|
|
147
|
-
*/
|
|
148
|
-
declare const standardTaskKinds: readonly ["coordination", "code_change", "verification", "investigation", "question"];
|
|
149
|
-
declare const taskKindSchema: z.ZodString;
|
|
150
|
-
declare const taskStateSchema: z.ZodEnum<{
|
|
151
|
-
queued: "queued";
|
|
152
|
-
running: "running";
|
|
153
|
-
verifying: "verifying";
|
|
154
|
-
succeeded: "succeeded";
|
|
155
|
-
failed: "failed";
|
|
156
|
-
needs_human: "needs_human";
|
|
157
|
-
cancelled: "cancelled";
|
|
158
|
-
}>;
|
|
159
|
-
declare const taskApprovalSchema: z.ZodEnum<{
|
|
160
|
-
required: "required";
|
|
161
|
-
granted: "granted";
|
|
162
|
-
denied: "denied";
|
|
163
|
-
}>;
|
|
164
|
-
declare const taskExecutionRepositoryIdsSchema: z.ZodTuple<[z.ZodString], null>;
|
|
165
|
-
declare const coordinationRepositoryIdsSchema: z.ZodTuple<[z.ZodString, z.ZodString], z.ZodString>;
|
|
166
|
-
declare const harnessSchema: z.ZodString;
|
|
167
|
-
declare const taskOriginSchema: z.ZodObject<{
|
|
168
|
-
signalId: z.ZodOptional<z.ZodString>;
|
|
169
|
-
parentTaskId: z.ZodOptional<z.ZodString>;
|
|
170
|
-
operator: z.ZodOptional<z.ZodString>;
|
|
171
|
-
}, z.core.$strict>;
|
|
172
|
-
declare const taskDevboxSchema: z.ZodObject<{
|
|
173
|
-
devboxId: z.ZodString;
|
|
174
|
-
remoteId: z.ZodString;
|
|
175
|
-
harness: z.ZodString;
|
|
176
|
-
}, z.core.$strict>;
|
|
177
|
-
declare const taskQuestionSchema: z.ZodObject<{
|
|
178
|
-
text: z.ZodString;
|
|
179
|
-
options: z.ZodArray<z.ZodString>;
|
|
180
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
181
|
-
answeredBy: z.ZodOptional<z.ZodString>;
|
|
182
|
-
}, z.core.$strict>;
|
|
183
|
-
declare const taskSchema: z.ZodObject<{
|
|
184
|
-
schemaVersion: z.ZodLiteral<1>;
|
|
185
|
-
id: z.ZodString;
|
|
186
|
-
repositoryIds: z.ZodArray<z.ZodString>;
|
|
187
|
-
kind: z.ZodString;
|
|
188
|
-
area: z.ZodOptional<z.ZodString>;
|
|
189
|
-
state: z.ZodEnum<{
|
|
190
|
-
queued: "queued";
|
|
191
|
-
running: "running";
|
|
192
|
-
verifying: "verifying";
|
|
193
|
-
succeeded: "succeeded";
|
|
194
|
-
failed: "failed";
|
|
195
|
-
needs_human: "needs_human";
|
|
196
|
-
cancelled: "cancelled";
|
|
197
|
-
}>;
|
|
198
|
-
approval: z.ZodOptional<z.ZodEnum<{
|
|
199
|
-
required: "required";
|
|
200
|
-
granted: "granted";
|
|
201
|
-
denied: "denied";
|
|
202
|
-
}>>;
|
|
203
|
-
origin: z.ZodObject<{
|
|
204
|
-
signalId: z.ZodOptional<z.ZodString>;
|
|
205
|
-
parentTaskId: z.ZodOptional<z.ZodString>;
|
|
206
|
-
operator: z.ZodOptional<z.ZodString>;
|
|
207
|
-
}, z.core.$strict>;
|
|
208
|
-
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
209
|
-
replyTo: z.ZodObject<{
|
|
210
|
-
channel: z.ZodString;
|
|
211
|
-
address: z.ZodString;
|
|
212
|
-
}, z.core.$strict>;
|
|
213
|
-
devbox: z.ZodOptional<z.ZodObject<{
|
|
214
|
-
devboxId: z.ZodString;
|
|
215
|
-
remoteId: z.ZodString;
|
|
216
|
-
harness: z.ZodString;
|
|
217
|
-
}, z.core.$strict>>;
|
|
218
|
-
attempt: z.ZodNumber;
|
|
219
|
-
reservedUsd: z.ZodOptional<z.ZodNumber>;
|
|
220
|
-
settledUsd: z.ZodOptional<z.ZodNumber>;
|
|
221
|
-
question: z.ZodOptional<z.ZodObject<{
|
|
222
|
-
text: z.ZodString;
|
|
223
|
-
options: z.ZodArray<z.ZodString>;
|
|
224
|
-
answer: z.ZodOptional<z.ZodString>;
|
|
225
|
-
answeredBy: z.ZodOptional<z.ZodString>;
|
|
226
|
-
}, z.core.$strict>>;
|
|
227
|
-
changeId: z.ZodOptional<z.ZodString>;
|
|
228
|
-
reportRef: z.ZodOptional<z.ZodString>;
|
|
229
|
-
createdAt: z.ZodISODateTime;
|
|
230
|
-
updatedAt: z.ZodISODateTime;
|
|
231
|
-
}, z.core.$strict>;
|
|
232
|
-
type TaskApproval = z.infer<typeof taskApprovalSchema>;
|
|
233
|
-
type TaskKind = z.infer<typeof taskKindSchema>;
|
|
234
|
-
type TaskState = z.infer<typeof taskStateSchema>;
|
|
235
|
-
type Task = z.infer<typeof taskSchema>;
|
|
236
|
-
//#endregion
|
|
237
298
|
//#region src/store/engine.d.ts
|
|
238
299
|
/** An approval decision that does not apply to the task's current approval or state. */
|
|
239
300
|
declare class ApprovalError extends Error {
|
|
@@ -241,6 +302,12 @@ declare class ApprovalError extends Error {
|
|
|
241
302
|
readonly reason: string;
|
|
242
303
|
constructor(taskId: TaskId, reason: string);
|
|
243
304
|
}
|
|
305
|
+
/** A settlement that does not apply to the task's current state. */
|
|
306
|
+
declare class SettlementError extends Error {
|
|
307
|
+
readonly taskId: TaskId;
|
|
308
|
+
readonly reason: string;
|
|
309
|
+
constructor(taskId: TaskId, reason: string);
|
|
310
|
+
}
|
|
244
311
|
declare class ChangeAssociationError extends Error {
|
|
245
312
|
readonly taskId: TaskId;
|
|
246
313
|
readonly repositoryId: RepositoryId;
|
|
@@ -263,7 +330,10 @@ interface CreateTaskInput {
|
|
|
263
330
|
kind: Task["kind"];
|
|
264
331
|
origin: Task["origin"];
|
|
265
332
|
replyTo: ReplyTo;
|
|
333
|
+
/** Same key creates one task and returns it on workflow retries. */
|
|
334
|
+
dedupeKey?: string;
|
|
266
335
|
area?: string;
|
|
336
|
+
changeId?: ChangeId;
|
|
267
337
|
dependsOn?: TaskId[];
|
|
268
338
|
question?: Task["question"];
|
|
269
339
|
/** Stamp the task as needing a human decision before dispatch. */
|
|
@@ -274,10 +344,26 @@ interface ApprovalDecision {
|
|
|
274
344
|
by: string;
|
|
275
345
|
reason?: string;
|
|
276
346
|
}
|
|
277
|
-
type TaskPatch = Partial<Pick<Task, "
|
|
347
|
+
type TaskPatch = Partial<Pick<Task, "changeId" | "reportRef" | "reservedUsd" | "reservedAt" | "question">>;
|
|
348
|
+
/** One completed model step's usage, as eve's step.completed event carries it. */
|
|
349
|
+
interface StepUsage {
|
|
350
|
+
turnId: string;
|
|
351
|
+
stepIndex: number;
|
|
352
|
+
costUsd?: number;
|
|
353
|
+
inputTokens?: number;
|
|
354
|
+
outputTokens?: number;
|
|
355
|
+
cacheReadTokens?: number;
|
|
356
|
+
cacheWriteTokens?: number;
|
|
357
|
+
}
|
|
278
358
|
interface TaskTransitionOptions {
|
|
279
359
|
patch?: TaskPatch;
|
|
280
360
|
reason?: string;
|
|
361
|
+
/**
|
|
362
|
+
* Refuse unless the task is in this state at write time. Closes
|
|
363
|
+
* check-then-act races where the transition would also be legal from the
|
|
364
|
+
* state a concurrent writer moved the task into.
|
|
365
|
+
*/
|
|
366
|
+
expectFrom?: TaskState;
|
|
281
367
|
}
|
|
282
368
|
interface CreateChangeInput {
|
|
283
369
|
repositoryId: RepositoryId;
|
|
@@ -295,6 +381,14 @@ interface ChangeTransitionOptions {
|
|
|
295
381
|
patch?: ChangePatch;
|
|
296
382
|
reason?: string;
|
|
297
383
|
}
|
|
384
|
+
interface EnsureBudgetInput {
|
|
385
|
+
factoryId: FactoryId;
|
|
386
|
+
month: string;
|
|
387
|
+
limits: Budget["limits"];
|
|
388
|
+
}
|
|
389
|
+
interface SettleTaskOptions {
|
|
390
|
+
reason?: string;
|
|
391
|
+
}
|
|
298
392
|
interface AppendReceiptInput {
|
|
299
393
|
repositoryIds: RepositoryId[];
|
|
300
394
|
taskId?: TaskId;
|
|
@@ -330,6 +424,18 @@ interface FactoryStores {
|
|
|
330
424
|
approve(id: TaskId, decision: ApprovalDecision): Promise<Task>;
|
|
331
425
|
/** Deny a required approval. The task is cancelled with the reason. */
|
|
332
426
|
reject(id: TaskId, decision: ApprovalDecision): Promise<Task>;
|
|
427
|
+
/**
|
|
428
|
+
* Record the provider's handle on the running attempt's execution, so the
|
|
429
|
+
* reconciler can inspect or cancel it. Refused unless the task is running.
|
|
430
|
+
*/
|
|
431
|
+
recordExecution(id: TaskId, execution: ExecutionReference): Promise<Task>;
|
|
432
|
+
/** Add one model step's usage to the task. Idempotent per (turnId, stepIndex). Never settles. */
|
|
433
|
+
recordUsage(id: TaskId, step: StepUsage): Promise<Task>;
|
|
434
|
+
/**
|
|
435
|
+
* Record measured cost on a terminal task. Idempotent: an already settled
|
|
436
|
+
* task returns unchanged and writes no second receipt.
|
|
437
|
+
*/
|
|
438
|
+
settle(id: TaskId, cost: Cost, options?: SettleTaskOptions): Promise<Task>;
|
|
333
439
|
list(): Promise<Task[]>;
|
|
334
440
|
};
|
|
335
441
|
changes: {
|
|
@@ -343,6 +449,22 @@ interface FactoryStores {
|
|
|
343
449
|
get(id: string): Promise<Receipt | null>;
|
|
344
450
|
list(): Promise<Receipt[]>;
|
|
345
451
|
};
|
|
452
|
+
budgets: {
|
|
453
|
+
/**
|
|
454
|
+
* Insert-once per month; refreshes limits when configuration changed and
|
|
455
|
+
* preserves notices. Safe under concurrent sweeps.
|
|
456
|
+
*/
|
|
457
|
+
ensure(input: EnsureBudgetInput): Promise<Budget>;
|
|
458
|
+
get(month: string): Promise<Budget | null>;
|
|
459
|
+
/**
|
|
460
|
+
* Write-once notice stamp. `stamped` is false when the notice was already
|
|
461
|
+
* set or a concurrent stamp won, so callers notify at most once.
|
|
462
|
+
*/
|
|
463
|
+
stampNotice(month: string, notice: "warning" | "exhausted"): Promise<{
|
|
464
|
+
budget: Budget;
|
|
465
|
+
stamped: boolean;
|
|
466
|
+
}>;
|
|
467
|
+
};
|
|
346
468
|
}
|
|
347
469
|
interface CreateStoresOptions {
|
|
348
470
|
driver: StoreDriver;
|
|
@@ -515,5 +637,77 @@ interface ApprovalSubject {
|
|
|
515
637
|
*/
|
|
516
638
|
declare function requiresApproval(policy: ApprovalPolicy, subject: ApprovalSubject): boolean;
|
|
517
639
|
//#endregion
|
|
518
|
-
|
|
519
|
-
|
|
640
|
+
//#region src/agent-routes.d.ts
|
|
641
|
+
declare const agentRouteSchema: z.ZodObject<{
|
|
642
|
+
id: z.ZodString;
|
|
643
|
+
agent: z.ZodString;
|
|
644
|
+
taskKind: z.ZodString;
|
|
645
|
+
description: z.ZodString;
|
|
646
|
+
permissions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
647
|
+
}, z.core.$strict>;
|
|
648
|
+
type AgentRoute = z.infer<typeof agentRouteSchema>;
|
|
649
|
+
type AgentRouteInput = z.input<typeof agentRouteSchema>;
|
|
650
|
+
interface AgentRouteRegistry {
|
|
651
|
+
readonly routes: readonly AgentRoute[];
|
|
652
|
+
get(id: string): AgentRoute | undefined;
|
|
653
|
+
forTaskKind(kind: string): AgentRoute | undefined;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Define the application-owned routes an agent or workflow may select. Route
|
|
657
|
+
* descriptions inform judgment; this validated registry remains the authority.
|
|
658
|
+
*/
|
|
659
|
+
declare function defineAgentRoutes(inputs: readonly AgentRouteInput[]): AgentRouteRegistry;
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/dispatch.d.ts
|
|
662
|
+
declare class DispatchRefusedError extends Error {
|
|
663
|
+
readonly taskId: TaskId;
|
|
664
|
+
readonly reason: string;
|
|
665
|
+
constructor(taskId: TaskId, reason: string);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* An exhausted budget is definitive, not a retryable refusal: the task has
|
|
669
|
+
* already been failed and receipted when this throws, so it never re-enters
|
|
670
|
+
* the sweep. Operator retry recovers it once budget frees up.
|
|
671
|
+
*/
|
|
672
|
+
declare class BudgetExhaustedError extends Error {
|
|
673
|
+
readonly taskId: TaskId;
|
|
674
|
+
readonly month: string;
|
|
675
|
+
readonly spendUsd: number;
|
|
676
|
+
constructor(taskId: TaskId, month: string, spendUsd: number);
|
|
677
|
+
}
|
|
678
|
+
interface DispatchBudget {
|
|
679
|
+
limits: Pick<BudgetLimits, "totalUsd" | "perTaskReservationUsd">;
|
|
680
|
+
/** Defaults to the current UTC month. */
|
|
681
|
+
month?: string;
|
|
682
|
+
now?: () => Date;
|
|
683
|
+
}
|
|
684
|
+
interface DispatchOptions {
|
|
685
|
+
/**
|
|
686
|
+
* Starts the durable execution for the task (an Eve agent run). Runs after
|
|
687
|
+
* the task has won the queued -> running transition. Returning the
|
|
688
|
+
* provider's execution reference records it on the task so the reconciler
|
|
689
|
+
* can find the run; returning nothing leaves the task reachable only by the
|
|
690
|
+
* stall window.
|
|
691
|
+
*/
|
|
692
|
+
launch: (task: Task) => Promise<ExecutionReference | void>;
|
|
693
|
+
/** How many launches to try before the task fails for good; a failure re-queues for the next sweep. */
|
|
694
|
+
maxLaunchAttempts?: number;
|
|
695
|
+
/**
|
|
696
|
+
* Reserve-before-execution. When set, dispatch refuses definitively once
|
|
697
|
+
* the month's derived spend cannot fit another reservation, and otherwise
|
|
698
|
+
* stamps the reservation in the same write that wins queued -> running.
|
|
699
|
+
*/
|
|
700
|
+
budget?: DispatchBudget;
|
|
701
|
+
}
|
|
702
|
+
declare const DEFAULT_MAX_LAUNCH_ATTEMPTS = 45;
|
|
703
|
+
/**
|
|
704
|
+
* The handshake between recorded work and execution: win the store-gated
|
|
705
|
+
* transition (at most one dispatcher can succeed), then start the run. A
|
|
706
|
+
* launch failure re-queues the task (bumping its attempt) until the attempt
|
|
707
|
+
* limit, then fails it; a crash between the transition and the launch leaves
|
|
708
|
+
* a running task with no execution, which the sweep reaps.
|
|
709
|
+
*/
|
|
710
|
+
declare function dispatchTask(stores: FactoryStores, taskId: TaskId, options: DispatchOptions): Promise<Task>;
|
|
711
|
+
//#endregion
|
|
712
|
+
export { Cost as $, taskSchema as $t, AppendReceiptInput as A, TaskId as At, DecideSignalOptions as B, TaskApproval as Bt, findingCategorySchema as C, budgetMonthSchema as Ct, findingVerificationLevelSchema as D, ReceiptId as Dt, findingSchema as E, FactoryId as Et, ChangeTransitionOptions as F, repositoryIdsSchema as Ft, StepUsage as G, executionReferenceSchema as Gt, FactoryStores as H, TaskState as Ht, CreateChangeInput as I, signalIdSchema as It, createStores as J, taskApprovalSchema as Jt, TaskPatch as K, harnessSchema as Kt, CreateSignalInput as L, taskIdSchema as Lt, ApprovalError as M, factoryIdSchema as Mt, ChangeAssociationError as N, receiptIdSchema as Nt, findingVerificationMethodSchema as O, RepositoryId as Ot, ChangePatch as P, repositoryIdSchema as Pt, repositorySlugSchema as Q, taskQuestionSchema as Qt, CreateStoresOptions as R, ExecutionReference as Rt, FindingVerification as S, budgetLimitsSchema as St, findingPrioritySchema as T, ChangeId as Tt, SettleTaskOptions as U, TaskUsage as Ut, EnsureBudgetInput as V, TaskKind as Vt, SettlementError as W, coordinationRepositoryIdsSchema as Wt, RepositorySlug as X, taskKindSchema as Xt, Repository as Y, taskExecutionRepositoryIdsSchema as Yt, repositorySchema as Z, taskOriginSchema as Zt, defaultApprovalPolicy as _, changeSchema as _t, DispatchRefusedError as a, receiptKindSchema as at, FindingCategory as b, Budget as bt, AgentRouteInput as c, receiptStateSchema as ct, defineAgentRoutes as d, standardReceiptStates as dt, taskStateSchema as en, Receipt as et, ApprovalPolicy as f, Change as ft, approvalRuleSchema as g, changeEvidenceSchema as gt, approvalPolicySchema as h, Level as ht, DispatchOptions as i, costSchema as it, ApprovalDecision as j, changeIdSchema as jt, findingVerificationSchema as k, SignalId as kt, AgentRouteRegistry as l, standardReceiptKinds as lt, ApprovalSubject as m, ChangeState as mt, DEFAULT_MAX_LAUNCH_ATTEMPTS as n, ReceiptPhase as nt, dispatchTask as o, receiptPhaseSchema as ot, ApprovalRule as p, ChangeEvidence as pt, TaskTransitionOptions as q, standardTaskKinds as qt, DispatchBudget as r, ReceiptState as rt, AgentRoute as s, receiptSchema as st, BudgetExhaustedError as t, taskUsageSchema as tn, ReceiptKind as tt, agentRouteSchema as u, standardReceiptPhases as ut, requiresApproval as v, changeStateSchema as vt, findingFingerprint as w, budgetSchema as wt, FindingPriority as x, BudgetLimits as xt, Finding as y, levelSchema as yt, CreateTaskInput as z, Task as zt };
|
|
713
|
+
//# sourceMappingURL=dispatch-B77cuPxh.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/store/driver.d.ts
|
|
2
|
-
type CollectionName = "repositories" | "signals" | "tasks" | "changes" | "receipts";
|
|
2
|
+
type CollectionName = "repositories" | "signals" | "tasks" | "changes" | "receipts" | "budgets";
|
|
3
3
|
interface StoredRecord {
|
|
4
4
|
readonly value: unknown;
|
|
5
5
|
readonly version: number;
|
|
@@ -31,4 +31,4 @@ interface StoreDriver {
|
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
33
|
export { StoredEntry as a, StoreDriver as i, RecordExistsError as n, StoredRecord as o, RecordNotFoundError as r, VersionConflictError as s, CollectionName as t };
|
|
34
|
-
//# sourceMappingURL=driver-
|
|
34
|
+
//# sourceMappingURL=driver-BJutB0PE.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver-Bbd25rNM.mjs","names":[],"sources":["../src/store/driver.ts"],"sourcesContent":["export type CollectionName
|
|
1
|
+
{"version":3,"file":"driver-Bbd25rNM.mjs","names":[],"sources":["../src/store/driver.ts"],"sourcesContent":["export type CollectionName =\n | \"repositories\"\n | \"signals\"\n | \"tasks\"\n | \"changes\"\n | \"receipts\"\n | \"budgets\";\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":";AAkBA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,uBAAuB,WAAW,EAAE;EACxD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,kBAAkB,WAAW,EAAE;EACnD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,YAA4B,IAAY,iBAAyB;EAC3E,MACE,WAAW,GAAG,QAAQ,WAAW,0BAA0B,gBAAgB,UAC7E;EACA,KAAK,OAAO;CACd;AACF"}
|