stitchkit 0.65.1 → 0.66.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.
Files changed (32) hide show
  1. package/dist/agent-runtime/coordinator.d.ts +8 -5
  2. package/dist/agent-runtime/coordinator.d.ts.map +1 -1
  3. package/dist/agent-runtime/events.d.ts +36 -30
  4. package/dist/agent-runtime/events.d.ts.map +1 -1
  5. package/dist/agent-runtime/injection.d.ts +28 -0
  6. package/dist/agent-runtime/injection.d.ts.map +1 -0
  7. package/dist/agent-runtime/observability.d.ts +22 -20
  8. package/dist/agent-runtime/observability.d.ts.map +1 -1
  9. package/dist/agent-runtime/prompt.d.ts +11 -1
  10. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  11. package/dist/agent-runtime/run-execution.d.ts +11 -0
  12. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  13. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
  14. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  15. package/dist/agent-runtime/schemas.d.ts +75 -21
  16. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  17. package/dist/agent-runtime/store-driver.d.ts +21 -15
  18. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  19. package/dist/agent-runtime/store.d.ts +280 -46
  20. package/dist/agent-runtime/store.d.ts.map +1 -1
  21. package/dist/agent-runtime/terminal-commit.d.ts +33 -3
  22. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  23. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  24. package/dist/agent-runtime-openrouter.js +1 -1
  25. package/dist/agent-runtime.d.ts +1 -1
  26. package/dist/agent-runtime.d.ts.map +1 -1
  27. package/dist/agent-runtime.js +384 -97
  28. package/dist/{index-sbkyvacf.js → index-fhsmrzj7.js} +45 -5
  29. package/dist/testing/agent-store-conformance.d.ts.map +1 -1
  30. package/dist/testing.js +149 -1
  31. package/llms-full.txt +251 -18
  32. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { type AgentSnapshot } from './schemas';
2
+ import { type AgentRun, type AgentSnapshot } from './schemas';
3
3
  export declare const AgentStoreConflictSchema: z.ZodObject<{
4
4
  outcome: z.ZodLiteral<"conflict">;
5
5
  actualVersion: z.ZodInt;
@@ -113,6 +113,7 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
113
113
  fencingToken: z.ZodOptional<z.ZodInt>;
114
114
  terminalReason: z.ZodOptional<z.ZodEnum<{
115
115
  abandoned: "abandoned";
116
+ absorbed: "absorbed";
116
117
  cancelled: "cancelled";
117
118
  context_overflow: "context_overflow";
118
119
  interrupted: "interrupted";
@@ -125,9 +126,10 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
125
126
  timeout: "timeout";
126
127
  }>>;
127
128
  terminalPolicyName: z.ZodOptional<z.ZodString>;
129
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
128
130
  usage: z.ZodOptional<z.ZodObject<{
129
131
  inputTokens: z.ZodObject<{
130
- value: z.ZodOptional<z.ZodNumber>;
132
+ value: z.ZodOptional<z.ZodInt>;
131
133
  provenance: z.ZodEnum<{
132
134
  computed: "computed";
133
135
  estimated: "estimated";
@@ -136,7 +138,7 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
136
138
  }>;
137
139
  }, z.core.$strip>;
138
140
  outputTokens: z.ZodObject<{
139
- value: z.ZodOptional<z.ZodNumber>;
141
+ value: z.ZodOptional<z.ZodInt>;
140
142
  provenance: z.ZodEnum<{
141
143
  computed: "computed";
142
144
  estimated: "estimated";
@@ -145,7 +147,7 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
145
147
  }>;
146
148
  }, z.core.$strip>;
147
149
  reasoningTokens: z.ZodOptional<z.ZodObject<{
148
- value: z.ZodOptional<z.ZodNumber>;
150
+ value: z.ZodOptional<z.ZodInt>;
149
151
  provenance: z.ZodEnum<{
150
152
  computed: "computed";
151
153
  estimated: "estimated";
@@ -154,7 +156,7 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
154
156
  }>;
155
157
  }, z.core.$strip>>;
156
158
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
157
- value: z.ZodOptional<z.ZodNumber>;
159
+ value: z.ZodOptional<z.ZodInt>;
158
160
  provenance: z.ZodEnum<{
159
161
  computed: "computed";
160
162
  estimated: "estimated";
@@ -163,7 +165,7 @@ export declare const AgentStoreAppliedSchema: z.ZodObject<{
163
165
  }>;
164
166
  }, z.core.$strip>>;
165
167
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
166
- value: z.ZodOptional<z.ZodNumber>;
168
+ value: z.ZodOptional<z.ZodInt>;
167
169
  provenance: z.ZodEnum<{
168
170
  computed: "computed";
169
171
  estimated: "estimated";
@@ -292,6 +294,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
292
294
  fencingToken: z.ZodOptional<z.ZodInt>;
293
295
  terminalReason: z.ZodOptional<z.ZodEnum<{
294
296
  abandoned: "abandoned";
297
+ absorbed: "absorbed";
295
298
  cancelled: "cancelled";
296
299
  context_overflow: "context_overflow";
297
300
  interrupted: "interrupted";
@@ -304,9 +307,10 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
304
307
  timeout: "timeout";
305
308
  }>>;
306
309
  terminalPolicyName: z.ZodOptional<z.ZodString>;
310
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
307
311
  usage: z.ZodOptional<z.ZodObject<{
308
312
  inputTokens: z.ZodObject<{
309
- value: z.ZodOptional<z.ZodNumber>;
313
+ value: z.ZodOptional<z.ZodInt>;
310
314
  provenance: z.ZodEnum<{
311
315
  computed: "computed";
312
316
  estimated: "estimated";
@@ -315,7 +319,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
315
319
  }>;
316
320
  }, z.core.$strip>;
317
321
  outputTokens: z.ZodObject<{
318
- value: z.ZodOptional<z.ZodNumber>;
322
+ value: z.ZodOptional<z.ZodInt>;
319
323
  provenance: z.ZodEnum<{
320
324
  computed: "computed";
321
325
  estimated: "estimated";
@@ -324,7 +328,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
324
328
  }>;
325
329
  }, z.core.$strip>;
326
330
  reasoningTokens: z.ZodOptional<z.ZodObject<{
327
- value: z.ZodOptional<z.ZodNumber>;
331
+ value: z.ZodOptional<z.ZodInt>;
328
332
  provenance: z.ZodEnum<{
329
333
  computed: "computed";
330
334
  estimated: "estimated";
@@ -333,7 +337,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
333
337
  }>;
334
338
  }, z.core.$strip>>;
335
339
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
336
- value: z.ZodOptional<z.ZodNumber>;
340
+ value: z.ZodOptional<z.ZodInt>;
337
341
  provenance: z.ZodEnum<{
338
342
  computed: "computed";
339
343
  estimated: "estimated";
@@ -342,7 +346,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
342
346
  }>;
343
347
  }, z.core.$strip>>;
344
348
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
345
- value: z.ZodOptional<z.ZodNumber>;
349
+ value: z.ZodOptional<z.ZodInt>;
346
350
  provenance: z.ZodEnum<{
347
351
  computed: "computed";
348
352
  estimated: "estimated";
@@ -546,6 +550,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
546
550
  fencingToken: z.ZodOptional<z.ZodInt>;
547
551
  terminalReason: z.ZodOptional<z.ZodEnum<{
548
552
  abandoned: "abandoned";
553
+ absorbed: "absorbed";
549
554
  cancelled: "cancelled";
550
555
  context_overflow: "context_overflow";
551
556
  interrupted: "interrupted";
@@ -558,9 +563,10 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
558
563
  timeout: "timeout";
559
564
  }>>;
560
565
  terminalPolicyName: z.ZodOptional<z.ZodString>;
566
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
561
567
  usage: z.ZodOptional<z.ZodObject<{
562
568
  inputTokens: z.ZodObject<{
563
- value: z.ZodOptional<z.ZodNumber>;
569
+ value: z.ZodOptional<z.ZodInt>;
564
570
  provenance: z.ZodEnum<{
565
571
  computed: "computed";
566
572
  estimated: "estimated";
@@ -569,7 +575,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
569
575
  }>;
570
576
  }, z.core.$strip>;
571
577
  outputTokens: z.ZodObject<{
572
- value: z.ZodOptional<z.ZodNumber>;
578
+ value: z.ZodOptional<z.ZodInt>;
573
579
  provenance: z.ZodEnum<{
574
580
  computed: "computed";
575
581
  estimated: "estimated";
@@ -578,7 +584,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
578
584
  }>;
579
585
  }, z.core.$strip>;
580
586
  reasoningTokens: z.ZodOptional<z.ZodObject<{
581
- value: z.ZodOptional<z.ZodNumber>;
587
+ value: z.ZodOptional<z.ZodInt>;
582
588
  provenance: z.ZodEnum<{
583
589
  computed: "computed";
584
590
  estimated: "estimated";
@@ -587,7 +593,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
587
593
  }>;
588
594
  }, z.core.$strip>>;
589
595
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
590
- value: z.ZodOptional<z.ZodNumber>;
596
+ value: z.ZodOptional<z.ZodInt>;
591
597
  provenance: z.ZodEnum<{
592
598
  computed: "computed";
593
599
  estimated: "estimated";
@@ -596,7 +602,7 @@ export declare const AgentStoreDuplicateSchema: z.ZodObject<{
596
602
  }>;
597
603
  }, z.core.$strip>>;
598
604
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
599
- value: z.ZodOptional<z.ZodNumber>;
605
+ value: z.ZodOptional<z.ZodInt>;
600
606
  provenance: z.ZodEnum<{
601
607
  computed: "computed";
602
608
  estimated: "estimated";
@@ -726,6 +732,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
726
732
  fencingToken: z.ZodOptional<z.ZodInt>;
727
733
  terminalReason: z.ZodOptional<z.ZodEnum<{
728
734
  abandoned: "abandoned";
735
+ absorbed: "absorbed";
729
736
  cancelled: "cancelled";
730
737
  context_overflow: "context_overflow";
731
738
  interrupted: "interrupted";
@@ -738,9 +745,10 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
738
745
  timeout: "timeout";
739
746
  }>>;
740
747
  terminalPolicyName: z.ZodOptional<z.ZodString>;
748
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
741
749
  usage: z.ZodOptional<z.ZodObject<{
742
750
  inputTokens: z.ZodObject<{
743
- value: z.ZodOptional<z.ZodNumber>;
751
+ value: z.ZodOptional<z.ZodInt>;
744
752
  provenance: z.ZodEnum<{
745
753
  computed: "computed";
746
754
  estimated: "estimated";
@@ -749,7 +757,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
749
757
  }>;
750
758
  }, z.core.$strip>;
751
759
  outputTokens: z.ZodObject<{
752
- value: z.ZodOptional<z.ZodNumber>;
760
+ value: z.ZodOptional<z.ZodInt>;
753
761
  provenance: z.ZodEnum<{
754
762
  computed: "computed";
755
763
  estimated: "estimated";
@@ -758,7 +766,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
758
766
  }>;
759
767
  }, z.core.$strip>;
760
768
  reasoningTokens: z.ZodOptional<z.ZodObject<{
761
- value: z.ZodOptional<z.ZodNumber>;
769
+ value: z.ZodOptional<z.ZodInt>;
762
770
  provenance: z.ZodEnum<{
763
771
  computed: "computed";
764
772
  estimated: "estimated";
@@ -767,7 +775,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
767
775
  }>;
768
776
  }, z.core.$strip>>;
769
777
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
770
- value: z.ZodOptional<z.ZodNumber>;
778
+ value: z.ZodOptional<z.ZodInt>;
771
779
  provenance: z.ZodEnum<{
772
780
  computed: "computed";
773
781
  estimated: "estimated";
@@ -776,7 +784,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
776
784
  }>;
777
785
  }, z.core.$strip>>;
778
786
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
779
- value: z.ZodOptional<z.ZodNumber>;
787
+ value: z.ZodOptional<z.ZodInt>;
780
788
  provenance: z.ZodEnum<{
781
789
  computed: "computed";
782
790
  estimated: "estimated";
@@ -904,6 +912,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
904
912
  fencingToken: z.ZodOptional<z.ZodInt>;
905
913
  terminalReason: z.ZodOptional<z.ZodEnum<{
906
914
  abandoned: "abandoned";
915
+ absorbed: "absorbed";
907
916
  cancelled: "cancelled";
908
917
  context_overflow: "context_overflow";
909
918
  interrupted: "interrupted";
@@ -916,9 +925,10 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
916
925
  timeout: "timeout";
917
926
  }>>;
918
927
  terminalPolicyName: z.ZodOptional<z.ZodString>;
928
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
919
929
  usage: z.ZodOptional<z.ZodObject<{
920
930
  inputTokens: z.ZodObject<{
921
- value: z.ZodOptional<z.ZodNumber>;
931
+ value: z.ZodOptional<z.ZodInt>;
922
932
  provenance: z.ZodEnum<{
923
933
  computed: "computed";
924
934
  estimated: "estimated";
@@ -927,7 +937,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
927
937
  }>;
928
938
  }, z.core.$strip>;
929
939
  outputTokens: z.ZodObject<{
930
- value: z.ZodOptional<z.ZodNumber>;
940
+ value: z.ZodOptional<z.ZodInt>;
931
941
  provenance: z.ZodEnum<{
932
942
  computed: "computed";
933
943
  estimated: "estimated";
@@ -936,7 +946,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
936
946
  }>;
937
947
  }, z.core.$strip>;
938
948
  reasoningTokens: z.ZodOptional<z.ZodObject<{
939
- value: z.ZodOptional<z.ZodNumber>;
949
+ value: z.ZodOptional<z.ZodInt>;
940
950
  provenance: z.ZodEnum<{
941
951
  computed: "computed";
942
952
  estimated: "estimated";
@@ -945,7 +955,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
945
955
  }>;
946
956
  }, z.core.$strip>>;
947
957
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
948
- value: z.ZodOptional<z.ZodNumber>;
958
+ value: z.ZodOptional<z.ZodInt>;
949
959
  provenance: z.ZodEnum<{
950
960
  computed: "computed";
951
961
  estimated: "estimated";
@@ -954,7 +964,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
954
964
  }>;
955
965
  }, z.core.$strip>>;
956
966
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
957
- value: z.ZodOptional<z.ZodNumber>;
967
+ value: z.ZodOptional<z.ZodInt>;
958
968
  provenance: z.ZodEnum<{
959
969
  computed: "computed";
960
970
  estimated: "estimated";
@@ -1158,6 +1168,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1158
1168
  fencingToken: z.ZodOptional<z.ZodInt>;
1159
1169
  terminalReason: z.ZodOptional<z.ZodEnum<{
1160
1170
  abandoned: "abandoned";
1171
+ absorbed: "absorbed";
1161
1172
  cancelled: "cancelled";
1162
1173
  context_overflow: "context_overflow";
1163
1174
  interrupted: "interrupted";
@@ -1170,9 +1181,10 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1170
1181
  timeout: "timeout";
1171
1182
  }>>;
1172
1183
  terminalPolicyName: z.ZodOptional<z.ZodString>;
1184
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
1173
1185
  usage: z.ZodOptional<z.ZodObject<{
1174
1186
  inputTokens: z.ZodObject<{
1175
- value: z.ZodOptional<z.ZodNumber>;
1187
+ value: z.ZodOptional<z.ZodInt>;
1176
1188
  provenance: z.ZodEnum<{
1177
1189
  computed: "computed";
1178
1190
  estimated: "estimated";
@@ -1181,7 +1193,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1181
1193
  }>;
1182
1194
  }, z.core.$strip>;
1183
1195
  outputTokens: z.ZodObject<{
1184
- value: z.ZodOptional<z.ZodNumber>;
1196
+ value: z.ZodOptional<z.ZodInt>;
1185
1197
  provenance: z.ZodEnum<{
1186
1198
  computed: "computed";
1187
1199
  estimated: "estimated";
@@ -1190,7 +1202,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1190
1202
  }>;
1191
1203
  }, z.core.$strip>;
1192
1204
  reasoningTokens: z.ZodOptional<z.ZodObject<{
1193
- value: z.ZodOptional<z.ZodNumber>;
1205
+ value: z.ZodOptional<z.ZodInt>;
1194
1206
  provenance: z.ZodEnum<{
1195
1207
  computed: "computed";
1196
1208
  estimated: "estimated";
@@ -1199,7 +1211,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1199
1211
  }>;
1200
1212
  }, z.core.$strip>>;
1201
1213
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
1202
- value: z.ZodOptional<z.ZodNumber>;
1214
+ value: z.ZodOptional<z.ZodInt>;
1203
1215
  provenance: z.ZodEnum<{
1204
1216
  computed: "computed";
1205
1217
  estimated: "estimated";
@@ -1208,7 +1220,7 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1208
1220
  }>;
1209
1221
  }, z.core.$strip>>;
1210
1222
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
1211
- value: z.ZodOptional<z.ZodNumber>;
1223
+ value: z.ZodOptional<z.ZodInt>;
1212
1224
  provenance: z.ZodEnum<{
1213
1225
  computed: "computed";
1214
1226
  estimated: "estimated";
@@ -1238,6 +1250,196 @@ export declare const AgentStoreMutationResultSchema: z.ZodDiscriminatedUnion<[z.
1238
1250
  outcome: z.ZodLiteral<"not_found">;
1239
1251
  }, z.core.$strip>], "outcome">;
1240
1252
  export type AgentStoreMutationResult = z.infer<typeof AgentStoreMutationResultSchema>;
1253
+ /**
1254
+ * One run, read without reading the conversation it belongs to.
1255
+ *
1256
+ * `loadSnapshot` was the only way to resolve a `runId`, and most of the runtime
1257
+ * only ever wanted the run: the fencing check that runs before **every tool
1258
+ * call** loaded every message in the conversation to compare two numbers. A
1259
+ * twenty-tool run in a five-thousand-message conversation read a hundred
1260
+ * thousand messages to learn nothing about any of them.
1261
+ *
1262
+ * `assistant` is the retained terminal message, so it is present exactly when
1263
+ * the run is terminal — which is when anything asks for it.
1264
+ */
1265
+ export declare const AgentRunViewSchema: z.ZodObject<{
1266
+ snapshotVersion: z.ZodInt;
1267
+ run: z.ZodObject<{
1268
+ schemaVersion: z.ZodLiteral<1>;
1269
+ id: z.ZodString;
1270
+ conversationId: z.ZodString;
1271
+ inputMessageIds: z.ZodArray<z.ZodString>;
1272
+ assistantMessageId: z.ZodString;
1273
+ state: z.ZodEnum<{
1274
+ abandoned: "abandoned";
1275
+ cancelled: "cancelled";
1276
+ completed: "completed";
1277
+ failed: "failed";
1278
+ interrupt_requested: "interrupt_requested";
1279
+ interrupted: "interrupted";
1280
+ queued: "queued";
1281
+ running: "running";
1282
+ superseded: "superseded";
1283
+ }>;
1284
+ revision: z.ZodInt;
1285
+ ownerId: z.ZodOptional<z.ZodString>;
1286
+ fencingToken: z.ZodOptional<z.ZodInt>;
1287
+ terminalReason: z.ZodOptional<z.ZodEnum<{
1288
+ abandoned: "abandoned";
1289
+ absorbed: "absorbed";
1290
+ cancelled: "cancelled";
1291
+ context_overflow: "context_overflow";
1292
+ interrupted: "interrupted";
1293
+ policy_stop: "policy_stop";
1294
+ provider_failure: "provider_failure";
1295
+ provider_stop: "provider_stop";
1296
+ shutdown: "shutdown";
1297
+ success: "success";
1298
+ superseded: "superseded";
1299
+ timeout: "timeout";
1300
+ }>>;
1301
+ terminalPolicyName: z.ZodOptional<z.ZodString>;
1302
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
1303
+ usage: z.ZodOptional<z.ZodObject<{
1304
+ inputTokens: z.ZodObject<{
1305
+ value: z.ZodOptional<z.ZodInt>;
1306
+ provenance: z.ZodEnum<{
1307
+ computed: "computed";
1308
+ estimated: "estimated";
1309
+ "provider-reported": "provider-reported";
1310
+ unavailable: "unavailable";
1311
+ }>;
1312
+ }, z.core.$strip>;
1313
+ outputTokens: z.ZodObject<{
1314
+ value: z.ZodOptional<z.ZodInt>;
1315
+ provenance: z.ZodEnum<{
1316
+ computed: "computed";
1317
+ estimated: "estimated";
1318
+ "provider-reported": "provider-reported";
1319
+ unavailable: "unavailable";
1320
+ }>;
1321
+ }, z.core.$strip>;
1322
+ reasoningTokens: z.ZodOptional<z.ZodObject<{
1323
+ value: z.ZodOptional<z.ZodInt>;
1324
+ provenance: z.ZodEnum<{
1325
+ computed: "computed";
1326
+ estimated: "estimated";
1327
+ "provider-reported": "provider-reported";
1328
+ unavailable: "unavailable";
1329
+ }>;
1330
+ }, z.core.$strip>>;
1331
+ cacheReadTokens: z.ZodOptional<z.ZodObject<{
1332
+ value: z.ZodOptional<z.ZodInt>;
1333
+ provenance: z.ZodEnum<{
1334
+ computed: "computed";
1335
+ estimated: "estimated";
1336
+ "provider-reported": "provider-reported";
1337
+ unavailable: "unavailable";
1338
+ }>;
1339
+ }, z.core.$strip>>;
1340
+ cacheWriteTokens: z.ZodOptional<z.ZodObject<{
1341
+ value: z.ZodOptional<z.ZodInt>;
1342
+ provenance: z.ZodEnum<{
1343
+ computed: "computed";
1344
+ estimated: "estimated";
1345
+ "provider-reported": "provider-reported";
1346
+ unavailable: "unavailable";
1347
+ }>;
1348
+ }, z.core.$strip>>;
1349
+ cost: z.ZodOptional<z.ZodObject<{
1350
+ value: z.ZodOptional<z.ZodNumber>;
1351
+ currency: z.ZodOptional<z.ZodString>;
1352
+ provenance: z.ZodEnum<{
1353
+ computed: "computed";
1354
+ estimated: "estimated";
1355
+ "provider-reported": "provider-reported";
1356
+ unavailable: "unavailable";
1357
+ }>;
1358
+ }, z.core.$strip>>;
1359
+ }, z.core.$strip>>;
1360
+ createdAt: z.ZodISODateTime;
1361
+ updatedAt: z.ZodISODateTime;
1362
+ }, z.core.$strip>;
1363
+ assistant: z.ZodOptional<z.ZodObject<{
1364
+ schemaVersion: z.ZodLiteral<1>;
1365
+ id: z.ZodString;
1366
+ conversationId: z.ZodString;
1367
+ runId: z.ZodOptional<z.ZodString>;
1368
+ role: z.ZodEnum<{
1369
+ assistant: "assistant";
1370
+ summary: "summary";
1371
+ system: "system";
1372
+ user: "user";
1373
+ }>;
1374
+ status: z.ZodEnum<{
1375
+ committed: "committed";
1376
+ completed: "completed";
1377
+ failed: "failed";
1378
+ interrupted: "interrupted";
1379
+ streaming: "streaming";
1380
+ superseded: "superseded";
1381
+ }>;
1382
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1383
+ type: z.ZodLiteral<"text">;
1384
+ text: z.ZodString;
1385
+ }, z.core.$strip>, z.ZodObject<{
1386
+ type: z.ZodLiteral<"reasoning">;
1387
+ text: z.ZodString;
1388
+ provider: z.ZodOptional<z.ZodObject<{
1389
+ schemaVersion: z.ZodInt;
1390
+ provider: z.ZodString;
1391
+ data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
1392
+ }, z.core.$strip>>;
1393
+ }, z.core.$strip>, z.ZodObject<{
1394
+ type: z.ZodLiteral<"file">;
1395
+ mediaType: z.ZodString;
1396
+ reference: z.ZodString;
1397
+ filename: z.ZodOptional<z.ZodString>;
1398
+ }, z.core.$strip>, z.ZodObject<{
1399
+ type: z.ZodLiteral<"source">;
1400
+ sourceId: z.ZodString;
1401
+ url: z.ZodOptional<z.ZodURL>;
1402
+ title: z.ZodOptional<z.ZodString>;
1403
+ }, z.core.$strip>, z.ZodObject<{
1404
+ type: z.ZodLiteral<"tool-call">;
1405
+ callId: z.ZodString;
1406
+ toolName: z.ZodString;
1407
+ input: z.ZodJSONSchema;
1408
+ provider: z.ZodOptional<z.ZodObject<{
1409
+ schemaVersion: z.ZodInt;
1410
+ provider: z.ZodString;
1411
+ data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
1412
+ }, z.core.$strip>>;
1413
+ }, z.core.$strip>, z.ZodObject<{
1414
+ type: z.ZodLiteral<"tool-result">;
1415
+ callId: z.ZodString;
1416
+ toolName: z.ZodString;
1417
+ outcome: z.ZodEnum<{
1418
+ error: "error";
1419
+ interrupted: "interrupted";
1420
+ success: "success";
1421
+ }>;
1422
+ output: z.ZodOptional<z.ZodJSONSchema>;
1423
+ }, z.core.$strip>, z.ZodObject<{
1424
+ type: z.ZodLiteral<"provider">;
1425
+ envelope: z.ZodObject<{
1426
+ schemaVersion: z.ZodInt;
1427
+ provider: z.ZodString;
1428
+ data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
1429
+ }, z.core.$strip>;
1430
+ }, z.core.$strip>, z.ZodObject<{
1431
+ type: z.ZodLiteral<"control">;
1432
+ reason: z.ZodEnum<{
1433
+ "run-interrupted": "run-interrupted";
1434
+ "stale-run": "stale-run";
1435
+ }>;
1436
+ }, z.core.$strip>], "type">>;
1437
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
1438
+ createdAt: z.ZodISODateTime;
1439
+ updatedAt: z.ZodISODateTime;
1440
+ }, z.core.$strip>>;
1441
+ }, z.core.$strip>;
1442
+ export type AgentRunView = z.infer<typeof AgentRunViewSchema>;
1241
1443
  export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1242
1444
  idempotencyKey: z.ZodString;
1243
1445
  expectedVersion: z.ZodOptional<z.ZodInt>;
@@ -1341,6 +1543,7 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1341
1543
  fencingToken: z.ZodOptional<z.ZodInt>;
1342
1544
  terminalReason: z.ZodOptional<z.ZodEnum<{
1343
1545
  abandoned: "abandoned";
1546
+ absorbed: "absorbed";
1344
1547
  cancelled: "cancelled";
1345
1548
  context_overflow: "context_overflow";
1346
1549
  interrupted: "interrupted";
@@ -1353,9 +1556,10 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1353
1556
  timeout: "timeout";
1354
1557
  }>>;
1355
1558
  terminalPolicyName: z.ZodOptional<z.ZodString>;
1559
+ absorbedIntoRunId: z.ZodOptional<z.ZodString>;
1356
1560
  usage: z.ZodOptional<z.ZodObject<{
1357
1561
  inputTokens: z.ZodObject<{
1358
- value: z.ZodOptional<z.ZodNumber>;
1562
+ value: z.ZodOptional<z.ZodInt>;
1359
1563
  provenance: z.ZodEnum<{
1360
1564
  computed: "computed";
1361
1565
  estimated: "estimated";
@@ -1364,7 +1568,7 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1364
1568
  }>;
1365
1569
  }, z.core.$strip>;
1366
1570
  outputTokens: z.ZodObject<{
1367
- value: z.ZodOptional<z.ZodNumber>;
1571
+ value: z.ZodOptional<z.ZodInt>;
1368
1572
  provenance: z.ZodEnum<{
1369
1573
  computed: "computed";
1370
1574
  estimated: "estimated";
@@ -1373,7 +1577,7 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1373
1577
  }>;
1374
1578
  }, z.core.$strip>;
1375
1579
  reasoningTokens: z.ZodOptional<z.ZodObject<{
1376
- value: z.ZodOptional<z.ZodNumber>;
1580
+ value: z.ZodOptional<z.ZodInt>;
1377
1581
  provenance: z.ZodEnum<{
1378
1582
  computed: "computed";
1379
1583
  estimated: "estimated";
@@ -1382,7 +1586,7 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1382
1586
  }>;
1383
1587
  }, z.core.$strip>>;
1384
1588
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
1385
- value: z.ZodOptional<z.ZodNumber>;
1589
+ value: z.ZodOptional<z.ZodInt>;
1386
1590
  provenance: z.ZodEnum<{
1387
1591
  computed: "computed";
1388
1592
  estimated: "estimated";
@@ -1391,7 +1595,7 @@ export declare const AcceptInputAndAssignRunSchema: z.ZodObject<{
1391
1595
  }>;
1392
1596
  }, z.core.$strip>>;
1393
1597
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
1394
- value: z.ZodOptional<z.ZodNumber>;
1598
+ value: z.ZodOptional<z.ZodInt>;
1395
1599
  provenance: z.ZodEnum<{
1396
1600
  computed: "computed";
1397
1601
  estimated: "estimated";
@@ -1507,7 +1711,7 @@ export declare const CheckpointRunAssistantSchema: z.ZodObject<{
1507
1711
  }, z.core.$strip>;
1508
1712
  usage: z.ZodOptional<z.ZodObject<{
1509
1713
  inputTokens: z.ZodObject<{
1510
- value: z.ZodOptional<z.ZodNumber>;
1714
+ value: z.ZodOptional<z.ZodInt>;
1511
1715
  provenance: z.ZodEnum<{
1512
1716
  computed: "computed";
1513
1717
  estimated: "estimated";
@@ -1516,7 +1720,7 @@ export declare const CheckpointRunAssistantSchema: z.ZodObject<{
1516
1720
  }>;
1517
1721
  }, z.core.$strip>;
1518
1722
  outputTokens: z.ZodObject<{
1519
- value: z.ZodOptional<z.ZodNumber>;
1723
+ value: z.ZodOptional<z.ZodInt>;
1520
1724
  provenance: z.ZodEnum<{
1521
1725
  computed: "computed";
1522
1726
  estimated: "estimated";
@@ -1525,7 +1729,7 @@ export declare const CheckpointRunAssistantSchema: z.ZodObject<{
1525
1729
  }>;
1526
1730
  }, z.core.$strip>;
1527
1731
  reasoningTokens: z.ZodOptional<z.ZodObject<{
1528
- value: z.ZodOptional<z.ZodNumber>;
1732
+ value: z.ZodOptional<z.ZodInt>;
1529
1733
  provenance: z.ZodEnum<{
1530
1734
  computed: "computed";
1531
1735
  estimated: "estimated";
@@ -1534,7 +1738,7 @@ export declare const CheckpointRunAssistantSchema: z.ZodObject<{
1534
1738
  }>;
1535
1739
  }, z.core.$strip>>;
1536
1740
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
1537
- value: z.ZodOptional<z.ZodNumber>;
1741
+ value: z.ZodOptional<z.ZodInt>;
1538
1742
  provenance: z.ZodEnum<{
1539
1743
  computed: "computed";
1540
1744
  estimated: "estimated";
@@ -1543,7 +1747,7 @@ export declare const CheckpointRunAssistantSchema: z.ZodObject<{
1543
1747
  }>;
1544
1748
  }, z.core.$strip>>;
1545
1749
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
1546
- value: z.ZodOptional<z.ZodNumber>;
1750
+ value: z.ZodOptional<z.ZodInt>;
1547
1751
  provenance: z.ZodEnum<{
1548
1752
  computed: "computed";
1549
1753
  estimated: "estimated";
@@ -1649,6 +1853,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1649
1853
  }, z.core.$strip>;
1650
1854
  reason: z.ZodEnum<{
1651
1855
  abandoned: "abandoned";
1856
+ absorbed: "absorbed";
1652
1857
  cancelled: "cancelled";
1653
1858
  context_overflow: "context_overflow";
1654
1859
  interrupted: "interrupted";
@@ -1663,7 +1868,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1663
1868
  policyName: z.ZodOptional<z.ZodString>;
1664
1869
  usage: z.ZodOptional<z.ZodObject<{
1665
1870
  inputTokens: z.ZodObject<{
1666
- value: z.ZodOptional<z.ZodNumber>;
1871
+ value: z.ZodOptional<z.ZodInt>;
1667
1872
  provenance: z.ZodEnum<{
1668
1873
  computed: "computed";
1669
1874
  estimated: "estimated";
@@ -1672,7 +1877,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1672
1877
  }>;
1673
1878
  }, z.core.$strip>;
1674
1879
  outputTokens: z.ZodObject<{
1675
- value: z.ZodOptional<z.ZodNumber>;
1880
+ value: z.ZodOptional<z.ZodInt>;
1676
1881
  provenance: z.ZodEnum<{
1677
1882
  computed: "computed";
1678
1883
  estimated: "estimated";
@@ -1681,7 +1886,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1681
1886
  }>;
1682
1887
  }, z.core.$strip>;
1683
1888
  reasoningTokens: z.ZodOptional<z.ZodObject<{
1684
- value: z.ZodOptional<z.ZodNumber>;
1889
+ value: z.ZodOptional<z.ZodInt>;
1685
1890
  provenance: z.ZodEnum<{
1686
1891
  computed: "computed";
1687
1892
  estimated: "estimated";
@@ -1690,7 +1895,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1690
1895
  }>;
1691
1896
  }, z.core.$strip>>;
1692
1897
  cacheReadTokens: z.ZodOptional<z.ZodObject<{
1693
- value: z.ZodOptional<z.ZodNumber>;
1898
+ value: z.ZodOptional<z.ZodInt>;
1694
1899
  provenance: z.ZodEnum<{
1695
1900
  computed: "computed";
1696
1901
  estimated: "estimated";
@@ -1699,7 +1904,7 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1699
1904
  }>;
1700
1905
  }, z.core.$strip>>;
1701
1906
  cacheWriteTokens: z.ZodOptional<z.ZodObject<{
1702
- value: z.ZodOptional<z.ZodNumber>;
1907
+ value: z.ZodOptional<z.ZodInt>;
1703
1908
  provenance: z.ZodEnum<{
1704
1909
  computed: "computed";
1705
1910
  estimated: "estimated";
@@ -1718,6 +1923,10 @@ export declare const CommitRunTerminalSchema: z.ZodObject<{
1718
1923
  }>;
1719
1924
  }, z.core.$strip>>;
1720
1925
  }, z.core.$strip>>;
1926
+ absorb: z.ZodOptional<z.ZodArray<z.ZodObject<{
1927
+ runId: z.ZodString;
1928
+ inputMessageIds: z.ZodArray<z.ZodString>;
1929
+ }, z.core.$strip>>>;
1721
1930
  }, z.core.$strip>;
1722
1931
  export declare const RequestRunInterruptSchema: z.ZodObject<{
1723
1932
  conversationId: z.ZodString;
@@ -1825,7 +2034,32 @@ export type RequestRunInterrupt = z.infer<typeof RequestRunInterruptSchema>;
1825
2034
  export type RecoverAgentRun = z.infer<typeof RecoverAgentRunSchema>;
1826
2035
  export type ReplaceCompactedRange = z.infer<typeof ReplaceCompactedRangeSchema>;
1827
2036
  export interface AgentRuntimeStore {
2037
+ /**
2038
+ * The whole conversation — every message and every run.
2039
+ *
2040
+ * Unbounded by construction, and the only read that is. Ask for it when you
2041
+ * need the conversation: composing a prompt, or compacting. To resolve a
2042
+ * `runId`, or to ask what is in flight, use `loadRun` / `listActiveRuns` —
2043
+ * they read one record and are the calls the runtime itself uses. See
2044
+ * "Reading a conversation" in the agent-runtime guide for what this costs and
2045
+ * what bounds it.
2046
+ */
1828
2047
  loadSnapshot(conversationId: string): Promise<AgentSnapshot>;
2048
+ /** One run by id. `undefined` if this conversation has no such run. */
2049
+ loadRun(input: {
2050
+ conversationId: string;
2051
+ runId: string;
2052
+ }): Promise<AgentRunView | undefined>;
2053
+ /**
2054
+ * Every run of this conversation that has not reached a terminal state,
2055
+ * oldest first by `createdAt` and then by `id`.
2056
+ *
2057
+ * Deliberately a weaker order than `AgentSnapshot.runs`, which breaks a
2058
+ * `createdAt` tie by where the run sits in the conversation's history. That
2059
+ * tiebreak needs the history, and reading it is the cost this call exists to
2060
+ * avoid.
2061
+ */
2062
+ listActiveRuns(conversationId: string): Promise<readonly AgentRun[]>;
1829
2063
  acceptInputAndAssignRun(input: AcceptInputAndAssignRun): Promise<AgentStoreMutationResult>;
1830
2064
  acquireRun(input: AcquireAgentRun): Promise<AgentStoreMutationResult>;
1831
2065
  checkpointRunAssistant(input: CheckpointRunAssistant): Promise<AgentStoreMutationResult>;