ai-runtime-engine 2.7.0 → 2.8.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,627 @@
1
+ /**
2
+ * Persisted agent tasks (Phase 3.5) — the schema, and the ONE way anything reads them back.
3
+ *
4
+ * An `Execution` is a JSON file in the user's home. Invariant 21 says persisted agent state is
5
+ * schema-validated on read, and the reason is concrete: a record's `innerPlan` is EXECUTED on resume and
6
+ * its hashes decide whether completed work may be reused, so a malformed record is not a display problem
7
+ * — it is an execution problem. Validation is fail-closed per record: anything that does not parse is
8
+ * dropped whole and counted, never coerced or half-read.
9
+ *
10
+ * READING IS NOT WRITING. `parseAgentTasks` returns a filtered VIEW and never touches the stored record,
11
+ * so merely listing or acquiring an execution cannot destroy tasks it could not parse. The dropped count
12
+ * travels with the view so a silently shrinking list is visible instead of inferred.
13
+ */
14
+ import { z } from 'zod';
15
+ import type { Execution } from './execution.js';
16
+ import type { AgentTaskRecord } from '../agents/task.js';
17
+ /**
18
+ * The record schema. `v` is a LITERAL: a record written by a future, wider version is dropped rather
19
+ * than parsed as this shape — reinterpreting an unknown layout is how a resume executes something its
20
+ * author never wrote.
21
+ */
22
+ export declare const persistedAgentTask: z.ZodObject<{
23
+ v: z.ZodLiteral<1>;
24
+ agentTaskId: z.ZodString;
25
+ agentId: z.ZodString;
26
+ stepId: z.ZodString;
27
+ state: z.ZodEnum<["created", "queued", "running", "completed", "failed", "cancelled", "waiting_for_input", "waiting_for_clarification", "paused"]>;
28
+ createdAt: z.ZodNumber;
29
+ updatedAt: z.ZodNumber;
30
+ startedAt: z.ZodOptional<z.ZodNumber>;
31
+ endedAt: z.ZodOptional<z.ZodNumber>;
32
+ interruption: z.ZodOptional<z.ZodObject<{
33
+ kind: z.ZodEnum<["crash", "pause", "parent-cancel"]>;
34
+ at: z.ZodNumber;
35
+ detail: z.ZodOptional<z.ZodString>;
36
+ }, "strict", z.ZodTypeAny, {
37
+ at: number;
38
+ kind: "pause" | "crash" | "parent-cancel";
39
+ detail?: string | undefined;
40
+ }, {
41
+ at: number;
42
+ kind: "pause" | "crash" | "parent-cancel";
43
+ detail?: string | undefined;
44
+ }>>;
45
+ provenance: z.ZodObject<{
46
+ executionId: z.ZodOptional<z.ZodString>;
47
+ planVersion: z.ZodNumber;
48
+ }, "strict", z.ZodTypeAny, {
49
+ planVersion: number;
50
+ executionId?: string | undefined;
51
+ }, {
52
+ planVersion: number;
53
+ executionId?: string | undefined;
54
+ }>;
55
+ agentDefHash: z.ZodString;
56
+ envelopeHash: z.ZodString;
57
+ stepInputHash: z.ZodString;
58
+ attempt: z.ZodNumber;
59
+ innerPlanVersion: z.ZodOptional<z.ZodNumber>;
60
+ innerPlan: z.ZodOptional<z.ZodObject<{
61
+ id: z.ZodString;
62
+ goal: z.ZodString;
63
+ version: z.ZodNumber;
64
+ steps: z.ZodArray<z.ZodObject<{
65
+ id: z.ZodString;
66
+ description: z.ZodString;
67
+ skill: z.ZodOptional<z.ZodString>;
68
+ tool: z.ZodOptional<z.ZodString>;
69
+ agent: z.ZodOptional<z.ZodString>;
70
+ motivatedBy: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
71
+ input: z.ZodOptional<z.ZodUnknown>;
72
+ dependsOn: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
+ status: z.ZodEnum<["pending", "running", "succeeded", "failed", "skipped"]>;
74
+ }, "strict", z.ZodTypeAny, {
75
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
76
+ id: string;
77
+ description: string;
78
+ input?: unknown;
79
+ agent?: string | undefined;
80
+ skill?: string | undefined;
81
+ tool?: string | undefined;
82
+ motivatedBy?: string[] | undefined;
83
+ dependsOn?: string[] | undefined;
84
+ }, {
85
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
86
+ id: string;
87
+ description: string;
88
+ input?: unknown;
89
+ agent?: string | undefined;
90
+ skill?: string | undefined;
91
+ tool?: string | undefined;
92
+ motivatedBy?: string[] | undefined;
93
+ dependsOn?: string[] | undefined;
94
+ }>, "many">;
95
+ reason: z.ZodOptional<z.ZodString>;
96
+ }, "strict", z.ZodTypeAny, {
97
+ id: string;
98
+ version: number;
99
+ steps: {
100
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
101
+ id: string;
102
+ description: string;
103
+ input?: unknown;
104
+ agent?: string | undefined;
105
+ skill?: string | undefined;
106
+ tool?: string | undefined;
107
+ motivatedBy?: string[] | undefined;
108
+ dependsOn?: string[] | undefined;
109
+ }[];
110
+ goal: string;
111
+ reason?: string | undefined;
112
+ }, {
113
+ id: string;
114
+ version: number;
115
+ steps: {
116
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
117
+ id: string;
118
+ description: string;
119
+ input?: unknown;
120
+ agent?: string | undefined;
121
+ skill?: string | undefined;
122
+ tool?: string | undefined;
123
+ motivatedBy?: string[] | undefined;
124
+ dependsOn?: string[] | undefined;
125
+ }[];
126
+ goal: string;
127
+ reason?: string | undefined;
128
+ }>>;
129
+ innerCompletedSteps: z.ZodArray<z.ZodString, "many">;
130
+ innerObservations: z.ZodArray<z.ZodObject<{
131
+ stepId: z.ZodString;
132
+ skill: z.ZodOptional<z.ZodString>;
133
+ tool: z.ZodOptional<z.ZodString>;
134
+ agent: z.ZodOptional<z.ZodString>;
135
+ agentTaskId: z.ZodOptional<z.ZodString>;
136
+ ok: z.ZodBoolean;
137
+ output: z.ZodOptional<z.ZodString>;
138
+ error: z.ZodOptional<z.ZodString>;
139
+ code: z.ZodOptional<z.ZodString>;
140
+ data: z.ZodOptional<z.ZodUnknown>;
141
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
142
+ callsUsed: z.ZodOptional<z.ZodNumber>;
143
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
144
+ stepId: z.ZodString;
145
+ skill: z.ZodOptional<z.ZodString>;
146
+ tool: z.ZodOptional<z.ZodString>;
147
+ agent: z.ZodOptional<z.ZodString>;
148
+ agentTaskId: z.ZodOptional<z.ZodString>;
149
+ ok: z.ZodBoolean;
150
+ output: z.ZodOptional<z.ZodString>;
151
+ error: z.ZodOptional<z.ZodString>;
152
+ code: z.ZodOptional<z.ZodString>;
153
+ data: z.ZodOptional<z.ZodUnknown>;
154
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
155
+ callsUsed: z.ZodOptional<z.ZodNumber>;
156
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
157
+ stepId: z.ZodString;
158
+ skill: z.ZodOptional<z.ZodString>;
159
+ tool: z.ZodOptional<z.ZodString>;
160
+ agent: z.ZodOptional<z.ZodString>;
161
+ agentTaskId: z.ZodOptional<z.ZodString>;
162
+ ok: z.ZodBoolean;
163
+ output: z.ZodOptional<z.ZodString>;
164
+ error: z.ZodOptional<z.ZodString>;
165
+ code: z.ZodOptional<z.ZodString>;
166
+ data: z.ZodOptional<z.ZodUnknown>;
167
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
168
+ callsUsed: z.ZodOptional<z.ZodNumber>;
169
+ }, z.ZodTypeAny, "passthrough">>, "many">;
170
+ innerObservationsOmitted: z.ZodNumber;
171
+ innerCheckpoint: z.ZodOptional<z.ZodObject<{
172
+ at: z.ZodNumber;
173
+ planVersion: z.ZodNumber;
174
+ gitHead: z.ZodOptional<z.ZodString>;
175
+ fileHashes: z.ZodRecord<z.ZodString, z.ZodString>;
176
+ configHash: z.ZodOptional<z.ZodString>;
177
+ skillVersions: z.ZodRecord<z.ZodString, z.ZodString>;
178
+ completedSteps: z.ZodArray<z.ZodString, "many">;
179
+ mcpTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
180
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
181
+ at: z.ZodNumber;
182
+ planVersion: z.ZodNumber;
183
+ gitHead: z.ZodOptional<z.ZodString>;
184
+ fileHashes: z.ZodRecord<z.ZodString, z.ZodString>;
185
+ configHash: z.ZodOptional<z.ZodString>;
186
+ skillVersions: z.ZodRecord<z.ZodString, z.ZodString>;
187
+ completedSteps: z.ZodArray<z.ZodString, "many">;
188
+ mcpTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
189
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
190
+ at: z.ZodNumber;
191
+ planVersion: z.ZodNumber;
192
+ gitHead: z.ZodOptional<z.ZodString>;
193
+ fileHashes: z.ZodRecord<z.ZodString, z.ZodString>;
194
+ configHash: z.ZodOptional<z.ZodString>;
195
+ skillVersions: z.ZodRecord<z.ZodString, z.ZodString>;
196
+ completedSteps: z.ZodArray<z.ZodString, "many">;
197
+ mcpTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
198
+ }, z.ZodTypeAny, "passthrough">>>;
199
+ pendingInner: z.ZodOptional<z.ZodObject<{
200
+ kind: z.ZodLiteral<"clarification">;
201
+ question: z.ZodString;
202
+ at: z.ZodNumber;
203
+ }, "strict", z.ZodTypeAny, {
204
+ at: number;
205
+ kind: "clarification";
206
+ question: string;
207
+ }, {
208
+ at: number;
209
+ kind: "clarification";
210
+ question: string;
211
+ }>>;
212
+ innerSteps: z.ZodObject<{
213
+ total: z.ZodNumber;
214
+ succeeded: z.ZodNumber;
215
+ }, "strict", z.ZodTypeAny, {
216
+ succeeded: number;
217
+ total: number;
218
+ }, {
219
+ succeeded: number;
220
+ total: number;
221
+ }>;
222
+ callsReserved: z.ZodNumber;
223
+ callsUsed: z.ZodNumber;
224
+ callsRefunded: z.ZodNumber;
225
+ toolCallsUsed: z.ZodNumber;
226
+ findings: z.ZodArray<z.ZodObject<{
227
+ id: z.ZodString;
228
+ agentId: z.ZodString;
229
+ agentTaskId: z.ZodString;
230
+ type: z.ZodString;
231
+ subject: z.ZodOptional<z.ZodString>;
232
+ claim: z.ZodString;
233
+ verdict: z.ZodOptional<z.ZodString>;
234
+ executionCoverage: z.ZodNumber;
235
+ confidence: z.ZodNumber;
236
+ evidence: z.ZodArray<z.ZodObject<{
237
+ kind: z.ZodString;
238
+ ref: z.ZodOptional<z.ZodString>;
239
+ detail: z.ZodOptional<z.ZodString>;
240
+ stepId: z.ZodOptional<z.ZodString>;
241
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
242
+ kind: z.ZodString;
243
+ ref: z.ZodOptional<z.ZodString>;
244
+ detail: z.ZodOptional<z.ZodString>;
245
+ stepId: z.ZodOptional<z.ZodString>;
246
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
247
+ kind: z.ZodString;
248
+ ref: z.ZodOptional<z.ZodString>;
249
+ detail: z.ZodOptional<z.ZodString>;
250
+ stepId: z.ZodOptional<z.ZodString>;
251
+ }, z.ZodTypeAny, "passthrough">>, "many">;
252
+ artifacts: z.ZodArray<z.ZodUnknown, "many">;
253
+ sourceSteps: z.ZodArray<z.ZodString, "many">;
254
+ provenance: z.ZodObject<{
255
+ executionId: z.ZodOptional<z.ZodString>;
256
+ planVersion: z.ZodNumber;
257
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
258
+ executionId: z.ZodOptional<z.ZodString>;
259
+ planVersion: z.ZodNumber;
260
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
261
+ executionId: z.ZodOptional<z.ZodString>;
262
+ planVersion: z.ZodNumber;
263
+ }, z.ZodTypeAny, "passthrough">>;
264
+ status: z.ZodEnum<["active", "superseded", "contradicted"]>;
265
+ supersededBy: z.ZodOptional<z.ZodString>;
266
+ createdAt: z.ZodNumber;
267
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
268
+ id: z.ZodString;
269
+ agentId: z.ZodString;
270
+ agentTaskId: z.ZodString;
271
+ type: z.ZodString;
272
+ subject: z.ZodOptional<z.ZodString>;
273
+ claim: z.ZodString;
274
+ verdict: z.ZodOptional<z.ZodString>;
275
+ executionCoverage: z.ZodNumber;
276
+ confidence: z.ZodNumber;
277
+ evidence: z.ZodArray<z.ZodObject<{
278
+ kind: z.ZodString;
279
+ ref: z.ZodOptional<z.ZodString>;
280
+ detail: z.ZodOptional<z.ZodString>;
281
+ stepId: z.ZodOptional<z.ZodString>;
282
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
283
+ kind: z.ZodString;
284
+ ref: z.ZodOptional<z.ZodString>;
285
+ detail: z.ZodOptional<z.ZodString>;
286
+ stepId: z.ZodOptional<z.ZodString>;
287
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
288
+ kind: z.ZodString;
289
+ ref: z.ZodOptional<z.ZodString>;
290
+ detail: z.ZodOptional<z.ZodString>;
291
+ stepId: z.ZodOptional<z.ZodString>;
292
+ }, z.ZodTypeAny, "passthrough">>, "many">;
293
+ artifacts: z.ZodArray<z.ZodUnknown, "many">;
294
+ sourceSteps: z.ZodArray<z.ZodString, "many">;
295
+ provenance: z.ZodObject<{
296
+ executionId: z.ZodOptional<z.ZodString>;
297
+ planVersion: z.ZodNumber;
298
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
299
+ executionId: z.ZodOptional<z.ZodString>;
300
+ planVersion: z.ZodNumber;
301
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
302
+ executionId: z.ZodOptional<z.ZodString>;
303
+ planVersion: z.ZodNumber;
304
+ }, z.ZodTypeAny, "passthrough">>;
305
+ status: z.ZodEnum<["active", "superseded", "contradicted"]>;
306
+ supersededBy: z.ZodOptional<z.ZodString>;
307
+ createdAt: z.ZodNumber;
308
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
309
+ id: z.ZodString;
310
+ agentId: z.ZodString;
311
+ agentTaskId: z.ZodString;
312
+ type: z.ZodString;
313
+ subject: z.ZodOptional<z.ZodString>;
314
+ claim: z.ZodString;
315
+ verdict: z.ZodOptional<z.ZodString>;
316
+ executionCoverage: z.ZodNumber;
317
+ confidence: z.ZodNumber;
318
+ evidence: z.ZodArray<z.ZodObject<{
319
+ kind: z.ZodString;
320
+ ref: z.ZodOptional<z.ZodString>;
321
+ detail: z.ZodOptional<z.ZodString>;
322
+ stepId: z.ZodOptional<z.ZodString>;
323
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
324
+ kind: z.ZodString;
325
+ ref: z.ZodOptional<z.ZodString>;
326
+ detail: z.ZodOptional<z.ZodString>;
327
+ stepId: z.ZodOptional<z.ZodString>;
328
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
329
+ kind: z.ZodString;
330
+ ref: z.ZodOptional<z.ZodString>;
331
+ detail: z.ZodOptional<z.ZodString>;
332
+ stepId: z.ZodOptional<z.ZodString>;
333
+ }, z.ZodTypeAny, "passthrough">>, "many">;
334
+ artifacts: z.ZodArray<z.ZodUnknown, "many">;
335
+ sourceSteps: z.ZodArray<z.ZodString, "many">;
336
+ provenance: z.ZodObject<{
337
+ executionId: z.ZodOptional<z.ZodString>;
338
+ planVersion: z.ZodNumber;
339
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
340
+ executionId: z.ZodOptional<z.ZodString>;
341
+ planVersion: z.ZodNumber;
342
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
343
+ executionId: z.ZodOptional<z.ZodString>;
344
+ planVersion: z.ZodNumber;
345
+ }, z.ZodTypeAny, "passthrough">>;
346
+ status: z.ZodEnum<["active", "superseded", "contradicted"]>;
347
+ supersededBy: z.ZodOptional<z.ZodString>;
348
+ createdAt: z.ZodNumber;
349
+ }, z.ZodTypeAny, "passthrough">>, "many">;
350
+ diagnostics: z.ZodArray<z.ZodUnknown, "many">;
351
+ failure: z.ZodOptional<z.ZodObject<{
352
+ code: z.ZodString;
353
+ message: z.ZodString;
354
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
355
+ code: z.ZodString;
356
+ message: z.ZodString;
357
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
358
+ code: z.ZodString;
359
+ message: z.ZodString;
360
+ }, z.ZodTypeAny, "passthrough">>>;
361
+ }, "strict", z.ZodTypeAny, {
362
+ v: 1;
363
+ state: "running" | "failed" | "completed" | "waiting_for_clarification" | "cancelled" | "paused" | "waiting_for_input" | "created" | "queued";
364
+ createdAt: number;
365
+ updatedAt: number;
366
+ stepId: string;
367
+ agentTaskId: string;
368
+ callsUsed: number;
369
+ envelopeHash: string;
370
+ agentId: string;
371
+ provenance: {
372
+ planVersion: number;
373
+ executionId?: string | undefined;
374
+ };
375
+ agentDefHash: string;
376
+ stepInputHash: string;
377
+ attempt: number;
378
+ innerCompletedSteps: string[];
379
+ innerObservations: z.objectOutputType<{
380
+ stepId: z.ZodString;
381
+ skill: z.ZodOptional<z.ZodString>;
382
+ tool: z.ZodOptional<z.ZodString>;
383
+ agent: z.ZodOptional<z.ZodString>;
384
+ agentTaskId: z.ZodOptional<z.ZodString>;
385
+ ok: z.ZodBoolean;
386
+ output: z.ZodOptional<z.ZodString>;
387
+ error: z.ZodOptional<z.ZodString>;
388
+ code: z.ZodOptional<z.ZodString>;
389
+ data: z.ZodOptional<z.ZodUnknown>;
390
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
391
+ callsUsed: z.ZodOptional<z.ZodNumber>;
392
+ }, z.ZodTypeAny, "passthrough">[];
393
+ innerObservationsOmitted: number;
394
+ innerSteps: {
395
+ succeeded: number;
396
+ total: number;
397
+ };
398
+ callsReserved: number;
399
+ callsRefunded: number;
400
+ toolCallsUsed: number;
401
+ findings: z.objectOutputType<{
402
+ id: z.ZodString;
403
+ agentId: z.ZodString;
404
+ agentTaskId: z.ZodString;
405
+ type: z.ZodString;
406
+ subject: z.ZodOptional<z.ZodString>;
407
+ claim: z.ZodString;
408
+ verdict: z.ZodOptional<z.ZodString>;
409
+ executionCoverage: z.ZodNumber;
410
+ confidence: z.ZodNumber;
411
+ evidence: z.ZodArray<z.ZodObject<{
412
+ kind: z.ZodString;
413
+ ref: z.ZodOptional<z.ZodString>;
414
+ detail: z.ZodOptional<z.ZodString>;
415
+ stepId: z.ZodOptional<z.ZodString>;
416
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
417
+ kind: z.ZodString;
418
+ ref: z.ZodOptional<z.ZodString>;
419
+ detail: z.ZodOptional<z.ZodString>;
420
+ stepId: z.ZodOptional<z.ZodString>;
421
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
422
+ kind: z.ZodString;
423
+ ref: z.ZodOptional<z.ZodString>;
424
+ detail: z.ZodOptional<z.ZodString>;
425
+ stepId: z.ZodOptional<z.ZodString>;
426
+ }, z.ZodTypeAny, "passthrough">>, "many">;
427
+ artifacts: z.ZodArray<z.ZodUnknown, "many">;
428
+ sourceSteps: z.ZodArray<z.ZodString, "many">;
429
+ provenance: z.ZodObject<{
430
+ executionId: z.ZodOptional<z.ZodString>;
431
+ planVersion: z.ZodNumber;
432
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
433
+ executionId: z.ZodOptional<z.ZodString>;
434
+ planVersion: z.ZodNumber;
435
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
436
+ executionId: z.ZodOptional<z.ZodString>;
437
+ planVersion: z.ZodNumber;
438
+ }, z.ZodTypeAny, "passthrough">>;
439
+ status: z.ZodEnum<["active", "superseded", "contradicted"]>;
440
+ supersededBy: z.ZodOptional<z.ZodString>;
441
+ createdAt: z.ZodNumber;
442
+ }, z.ZodTypeAny, "passthrough">[];
443
+ diagnostics: unknown[];
444
+ innerPlan?: {
445
+ id: string;
446
+ version: number;
447
+ steps: {
448
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
449
+ id: string;
450
+ description: string;
451
+ input?: unknown;
452
+ agent?: string | undefined;
453
+ skill?: string | undefined;
454
+ tool?: string | undefined;
455
+ motivatedBy?: string[] | undefined;
456
+ dependsOn?: string[] | undefined;
457
+ }[];
458
+ goal: string;
459
+ reason?: string | undefined;
460
+ } | undefined;
461
+ startedAt?: number | undefined;
462
+ endedAt?: number | undefined;
463
+ interruption?: {
464
+ at: number;
465
+ kind: "pause" | "crash" | "parent-cancel";
466
+ detail?: string | undefined;
467
+ } | undefined;
468
+ innerPlanVersion?: number | undefined;
469
+ innerCheckpoint?: z.objectOutputType<{
470
+ at: z.ZodNumber;
471
+ planVersion: z.ZodNumber;
472
+ gitHead: z.ZodOptional<z.ZodString>;
473
+ fileHashes: z.ZodRecord<z.ZodString, z.ZodString>;
474
+ configHash: z.ZodOptional<z.ZodString>;
475
+ skillVersions: z.ZodRecord<z.ZodString, z.ZodString>;
476
+ completedSteps: z.ZodArray<z.ZodString, "many">;
477
+ mcpTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
478
+ }, z.ZodTypeAny, "passthrough"> | undefined;
479
+ pendingInner?: {
480
+ at: number;
481
+ kind: "clarification";
482
+ question: string;
483
+ } | undefined;
484
+ failure?: z.objectOutputType<{
485
+ code: z.ZodString;
486
+ message: z.ZodString;
487
+ }, z.ZodTypeAny, "passthrough"> | undefined;
488
+ }, {
489
+ v: 1;
490
+ state: "running" | "failed" | "completed" | "waiting_for_clarification" | "cancelled" | "paused" | "waiting_for_input" | "created" | "queued";
491
+ createdAt: number;
492
+ updatedAt: number;
493
+ stepId: string;
494
+ agentTaskId: string;
495
+ callsUsed: number;
496
+ envelopeHash: string;
497
+ agentId: string;
498
+ provenance: {
499
+ planVersion: number;
500
+ executionId?: string | undefined;
501
+ };
502
+ agentDefHash: string;
503
+ stepInputHash: string;
504
+ attempt: number;
505
+ innerCompletedSteps: string[];
506
+ innerObservations: z.objectInputType<{
507
+ stepId: z.ZodString;
508
+ skill: z.ZodOptional<z.ZodString>;
509
+ tool: z.ZodOptional<z.ZodString>;
510
+ agent: z.ZodOptional<z.ZodString>;
511
+ agentTaskId: z.ZodOptional<z.ZodString>;
512
+ ok: z.ZodBoolean;
513
+ output: z.ZodOptional<z.ZodString>;
514
+ error: z.ZodOptional<z.ZodString>;
515
+ code: z.ZodOptional<z.ZodString>;
516
+ data: z.ZodOptional<z.ZodUnknown>;
517
+ artifacts: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
518
+ callsUsed: z.ZodOptional<z.ZodNumber>;
519
+ }, z.ZodTypeAny, "passthrough">[];
520
+ innerObservationsOmitted: number;
521
+ innerSteps: {
522
+ succeeded: number;
523
+ total: number;
524
+ };
525
+ callsReserved: number;
526
+ callsRefunded: number;
527
+ toolCallsUsed: number;
528
+ findings: z.objectInputType<{
529
+ id: z.ZodString;
530
+ agentId: z.ZodString;
531
+ agentTaskId: z.ZodString;
532
+ type: z.ZodString;
533
+ subject: z.ZodOptional<z.ZodString>;
534
+ claim: z.ZodString;
535
+ verdict: z.ZodOptional<z.ZodString>;
536
+ executionCoverage: z.ZodNumber;
537
+ confidence: z.ZodNumber;
538
+ evidence: z.ZodArray<z.ZodObject<{
539
+ kind: z.ZodString;
540
+ ref: z.ZodOptional<z.ZodString>;
541
+ detail: z.ZodOptional<z.ZodString>;
542
+ stepId: z.ZodOptional<z.ZodString>;
543
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
544
+ kind: z.ZodString;
545
+ ref: z.ZodOptional<z.ZodString>;
546
+ detail: z.ZodOptional<z.ZodString>;
547
+ stepId: z.ZodOptional<z.ZodString>;
548
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
549
+ kind: z.ZodString;
550
+ ref: z.ZodOptional<z.ZodString>;
551
+ detail: z.ZodOptional<z.ZodString>;
552
+ stepId: z.ZodOptional<z.ZodString>;
553
+ }, z.ZodTypeAny, "passthrough">>, "many">;
554
+ artifacts: z.ZodArray<z.ZodUnknown, "many">;
555
+ sourceSteps: z.ZodArray<z.ZodString, "many">;
556
+ provenance: z.ZodObject<{
557
+ executionId: z.ZodOptional<z.ZodString>;
558
+ planVersion: z.ZodNumber;
559
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
560
+ executionId: z.ZodOptional<z.ZodString>;
561
+ planVersion: z.ZodNumber;
562
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
563
+ executionId: z.ZodOptional<z.ZodString>;
564
+ planVersion: z.ZodNumber;
565
+ }, z.ZodTypeAny, "passthrough">>;
566
+ status: z.ZodEnum<["active", "superseded", "contradicted"]>;
567
+ supersededBy: z.ZodOptional<z.ZodString>;
568
+ createdAt: z.ZodNumber;
569
+ }, z.ZodTypeAny, "passthrough">[];
570
+ diagnostics: unknown[];
571
+ innerPlan?: {
572
+ id: string;
573
+ version: number;
574
+ steps: {
575
+ status: "pending" | "running" | "succeeded" | "failed" | "skipped";
576
+ id: string;
577
+ description: string;
578
+ input?: unknown;
579
+ agent?: string | undefined;
580
+ skill?: string | undefined;
581
+ tool?: string | undefined;
582
+ motivatedBy?: string[] | undefined;
583
+ dependsOn?: string[] | undefined;
584
+ }[];
585
+ goal: string;
586
+ reason?: string | undefined;
587
+ } | undefined;
588
+ startedAt?: number | undefined;
589
+ endedAt?: number | undefined;
590
+ interruption?: {
591
+ at: number;
592
+ kind: "pause" | "crash" | "parent-cancel";
593
+ detail?: string | undefined;
594
+ } | undefined;
595
+ innerPlanVersion?: number | undefined;
596
+ innerCheckpoint?: z.objectInputType<{
597
+ at: z.ZodNumber;
598
+ planVersion: z.ZodNumber;
599
+ gitHead: z.ZodOptional<z.ZodString>;
600
+ fileHashes: z.ZodRecord<z.ZodString, z.ZodString>;
601
+ configHash: z.ZodOptional<z.ZodString>;
602
+ skillVersions: z.ZodRecord<z.ZodString, z.ZodString>;
603
+ completedSteps: z.ZodArray<z.ZodString, "many">;
604
+ mcpTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
605
+ }, z.ZodTypeAny, "passthrough"> | undefined;
606
+ pendingInner?: {
607
+ at: number;
608
+ kind: "clarification";
609
+ question: string;
610
+ } | undefined;
611
+ failure?: z.objectInputType<{
612
+ code: z.ZodString;
613
+ message: z.ZodString;
614
+ }, z.ZodTypeAny, "passthrough"> | undefined;
615
+ }>;
616
+ export interface AgentTaskView {
617
+ tasks: AgentTaskRecord[];
618
+ /** Records that failed validation and were left out of the view (still on disk, untouched). */
619
+ dropped: number;
620
+ }
621
+ /**
622
+ * Validate the agent tasks on an execution. Pure: it reads, it never writes. Callers that then persist
623
+ * the execution are choosing to drop the unparseable records — reading alone never does.
624
+ */
625
+ export declare function parseAgentTasks(exec: Pick<Execution, 'agentTasks'>): AgentTaskView;
626
+ /** One task by id, validated — the lookup every resume path uses. */
627
+ export declare function findAgentTask(exec: Pick<Execution, 'agentTasks'>, agentTaskId: string): AgentTaskRecord | undefined;