@namzu/sdk 20.1.0 → 20.3.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.
- package/CHANGELOG.md +90 -0
- package/dist/manager/run/persistence.d.ts +2 -2
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +14 -5
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +1 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts +20 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +47 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/context.d.ts +2 -0
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +1 -0
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/index.d.ts +11 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/run/disk.d.ts +10 -8
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/listing.d.ts.map +1 -1
- package/dist/store/run/listing.js +65 -6
- package/dist/store/run/listing.js.map +1 -1
- package/dist/store/run/memory.d.ts +46 -0
- package/dist/store/run/memory.d.ts.map +1 -0
- package/dist/store/run/memory.js +104 -0
- package/dist/store/run/memory.js.map +1 -0
- package/dist/types/hitl/index.d.ts +27 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/run/checkpoint-store.d.ts +69 -19
- package/dist/types/run/checkpoint-store.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +12 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/index.d.ts +1 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +1 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/store.d.ts +103 -0
- package/dist/types/run/store.d.ts.map +1 -0
- package/dist/types/run/store.js +30 -0
- package/dist/types/run/store.js.map +1 -0
- package/package.json +1 -1
- package/src/manager/run/persistence.ts +17 -7
- package/src/public-runtime.ts +1 -0
- package/src/runtime/query/checkpoint.ts +51 -0
- package/src/runtime/query/context.ts +3 -0
- package/src/runtime/query/index.ts +13 -0
- package/src/store/index.ts +1 -0
- package/src/store/run/disk.ts +10 -8
- package/src/store/run/listing.ts +84 -6
- package/src/store/run/memory.ts +121 -0
- package/src/types/hitl/index.ts +28 -0
- package/src/types/run/checkpoint-store.ts +72 -19
- package/src/types/run/config.ts +13 -0
- package/src/types/run/index.ts +1 -0
- package/src/types/run/store.ts +112 -0
|
@@ -217,6 +217,33 @@ export interface IterationCheckpoint {
|
|
|
217
217
|
* @deprecated No producer. Removed in the next major.
|
|
218
218
|
*/
|
|
219
219
|
planStatus?: PlanStatus;
|
|
220
|
+
/**
|
|
221
|
+
* When the RUN was attributed — not when this checkpoint was written.
|
|
222
|
+
* See {@link IterationCheckpoint.createdAt} for the latter.
|
|
223
|
+
*
|
|
224
|
+
* Denormalized onto every checkpoint of the run, identically, and that
|
|
225
|
+
* repetition is the whole point. A listing above the run needs a key it
|
|
226
|
+
* can order by, and a key a paging caller can trust is one that cannot
|
|
227
|
+
* MOVE. Every other time a checkpoint store can derive per run moves: the
|
|
228
|
+
* newest checkpoint's `createdAt` advances every time the run checkpoints
|
|
229
|
+
* again, and the oldest one's advances every time `prune` deletes
|
|
230
|
+
* oldest-first. Carried on all of them, this one survives both — pruning
|
|
231
|
+
* cannot reach a value every survivor also holds.
|
|
232
|
+
*
|
|
233
|
+
* `readonly`, and written exactly once per run by
|
|
234
|
+
* {@link import('../../runtime/query/checkpoint.js').CheckpointManager},
|
|
235
|
+
* which settles it on whichever comes first — adopting it from the
|
|
236
|
+
* checkpoint a resume restores, or minting it from the run's own start
|
|
237
|
+
* instant — and never reassigns after. A field that COULD be updated is
|
|
238
|
+
* one edit away from moving again, which would put the ordering back
|
|
239
|
+
* where it started.
|
|
240
|
+
*
|
|
241
|
+
* Absent on checkpoints written before this existed. That absence is
|
|
242
|
+
* information, not a gap: a run with no stamp on any of its checkpoints
|
|
243
|
+
* was attributed before the stamp existed, and therefore before every
|
|
244
|
+
* run that has one.
|
|
245
|
+
*/
|
|
246
|
+
readonly runCreatedAt?: number;
|
|
220
247
|
/**
|
|
221
248
|
* Present when the run parked at this checkpoint awaiting a human.
|
|
222
249
|
* See {@link PendingDecision}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,MAAM,MAAM,kBAAkB,GAC3B;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GACtB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM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AAY,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,QAAQ,CAAA;IAClB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IAEvB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAE9B;;;OAGG;IACH,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,UAAU,EAAE;QACX,cAAc,EAAE,MAAM,CAAA;QACtB,SAAS,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;IAEjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEzC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAA;IAEnC;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACpC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAwB5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"AAwRA,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC9D,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,eAAe;YACnB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;QACnD,KAAK,aAAa;YACjB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;QACpD,KAAK,sBAAsB;YAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAC/C,KAAK,eAAe;YACnB,2DAA2D;YAC3D,yDAAyD;YACzD,6DAA6D;YAC7D,uCAAuC;YACvC,OAAO,OAAO,CAAC,OAAO,CAAC;gBACtB,MAAM,EAAE,iBAAiB;gBACzB,iBAAiB,EAAE,EAAE;gBACrB,QAAQ,EAAE,mEAAmE;gBAC7E,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU;aACvC,CAAC,CAAA;QACH,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,OAAO,CAAA;YAClC,MAAM,IAAI,KAAK,CAAC,gCAAiC,WAAmC,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7F,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -145,6 +145,20 @@ export interface ParkSummary {
|
|
|
145
145
|
* scope, intersect with the host's own run records, resume the difference.
|
|
146
146
|
*/
|
|
147
147
|
export interface DurableRunEntry extends CheckpointRunScope {
|
|
148
|
+
/**
|
|
149
|
+
* When the run was attributed. Absent when it was never recorded.
|
|
150
|
+
*
|
|
151
|
+
* The only per-run key this store holds that does not move, which is why
|
|
152
|
+
* it is the one an oldest-first listing can page over — see
|
|
153
|
+
* {@link CheckpointStore.listDurableRuns} and
|
|
154
|
+
* `IterationCheckpoint.runCreatedAt`.
|
|
155
|
+
*
|
|
156
|
+
* **Absent means "not recorded", and a caller should render it that way
|
|
157
|
+
* rather than as a date it invents.** Every run checkpointed by a build
|
|
158
|
+
* carrying the stamp has one; a run that has none was checkpointed
|
|
159
|
+
* before the stamp existed.
|
|
160
|
+
*/
|
|
161
|
+
readonly runCreatedAt?: number;
|
|
148
162
|
/** How many checkpoints the run has right now. Pruning lowers it. */
|
|
149
163
|
readonly checkpointCount: number;
|
|
150
164
|
/** Newest checkpoint by `createdAt` — the one a resume restores by default. */
|
|
@@ -154,8 +168,44 @@ export interface DurableRunEntry extends CheckpointRunScope {
|
|
|
154
168
|
/** Absent when the run has never parked. */
|
|
155
169
|
readonly park?: ParkSummary;
|
|
156
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Which order a listing comes back in.
|
|
173
|
+
*
|
|
174
|
+
* Explicit rather than implied, because the two available orders answer
|
|
175
|
+
* different questions and neither is right for both. "Show me every run
|
|
176
|
+
* waiting on a human" wants stable paging; "show me the one that has been
|
|
177
|
+
* waiting longest" wants chronology. A listing that silently picked one
|
|
178
|
+
* would be the same ambiguity the scope type removed by splitting.
|
|
179
|
+
*/
|
|
180
|
+
export type DurableRunOrder =
|
|
181
|
+
/**
|
|
182
|
+
* By `runId` ascending. Stable and total, and meaningless as chronology —
|
|
183
|
+
* run ids carry no timestamp. The default, because it is what shipped.
|
|
184
|
+
*/
|
|
185
|
+
'runId'
|
|
186
|
+
/**
|
|
187
|
+
* Oldest first, by {@link DurableRunEntry.runCreatedAt} then `runId`.
|
|
188
|
+
* This is the triage order: it answers which run has been waiting
|
|
189
|
+
* longest. Safe to page over, because the stamp is recorded once at
|
|
190
|
+
* attribution and never rewritten.
|
|
191
|
+
*
|
|
192
|
+
* **Runs whose creation was never recorded come FIRST**, ordered among
|
|
193
|
+
* themselves by `runId`. That is not a guess dressed up as a date: the
|
|
194
|
+
* stamp is written by the checkpoint manager, so a run lacking it on
|
|
195
|
+
* every checkpoint was checkpointed by a build that predates the stamp,
|
|
196
|
+
* and therefore predates every run that has one. Their
|
|
197
|
+
* `runCreatedAt` is absent on the row, so a caller can render "unknown"
|
|
198
|
+
* instead of a date nobody recorded.
|
|
199
|
+
*/
|
|
200
|
+
| 'createdAt';
|
|
157
201
|
/** Filters and paging for {@link CheckpointStore.listDurableRuns}. */
|
|
158
202
|
export interface ListDurableRunsOptions {
|
|
203
|
+
/**
|
|
204
|
+
* Ordering, and therefore what the cursor is a position in. Defaults to
|
|
205
|
+
* `'runId'`. A cursor is only meaningful within one order — do not carry
|
|
206
|
+
* one across a change of `orderBy`.
|
|
207
|
+
*/
|
|
208
|
+
readonly orderBy?: DurableRunOrder;
|
|
159
209
|
/**
|
|
160
210
|
* Keep only runs whose park is in one of these states. A run that never
|
|
161
211
|
* parked has no state and is excluded by ANY value here; omit the filter
|
|
@@ -239,30 +289,30 @@ export interface CheckpointStore {
|
|
|
239
289
|
* for an unanswered park, and until this existed the sweep had no way to
|
|
240
290
|
* enumerate what to sweep.
|
|
241
291
|
*
|
|
242
|
-
* ### Ordering
|
|
292
|
+
* ### Ordering
|
|
243
293
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
294
|
+
* Two orders, named by `options.orderBy`, and the cursor is a position in
|
|
295
|
+
* whichever one was asked for. See {@link DurableRunOrder}.
|
|
246
296
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
297
|
+
* Both sort on a key that cannot MOVE, which is the property a cursor
|
|
298
|
+
* needs — sort on a moving key and a paging caller skips rows and repeats
|
|
299
|
+
* rows. That rules out every time a checkpoint store can derive on its
|
|
300
|
+
* own: the newest checkpoint's timestamp advances whenever the run
|
|
301
|
+
* checkpoints again, and the oldest one's advances whenever
|
|
302
|
+
* `CheckpointManager.prune` deletes oldest-first, which is what pruning
|
|
303
|
+
* does. It leaves `runId`, which is immutable and unique but carries no
|
|
304
|
+
* timestamp, and `runCreatedAt`, which is recorded once at attribution
|
|
305
|
+
* and denormalized onto every checkpoint so pruning cannot reach it.
|
|
256
306
|
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
307
|
+
* `'runId'` alone is already a total order. `'createdAt'` tiebreaks on
|
|
308
|
+
* `runId`, which is the rule `orderChildren` follows: sort on a key that
|
|
309
|
+
* cannot move, make the order total with an id.
|
|
260
310
|
*
|
|
261
311
|
* A run whose FIRST checkpoint is written after paging began may be
|
|
262
|
-
* missed by that pass — it lands
|
|
263
|
-
* behind the cursor. That is the right trade for a queue:
|
|
264
|
-
* again and picks it up next pass, whereas a moving sort
|
|
265
|
-
* that already existed.
|
|
312
|
+
* missed by that pass, in either order — it lands wherever its key puts
|
|
313
|
+
* it, possibly behind the cursor. That is the right trade for a queue:
|
|
314
|
+
* the sweep runs again and picks it up next pass, whereas a moving sort
|
|
315
|
+
* key loses runs that already existed.
|
|
266
316
|
*
|
|
267
317
|
* @param scope contiguous prefix; `tenantId` required. Implementations
|
|
268
318
|
* reject a hole (`sessionId` with no `projectId`) rather than guessing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-store.d.ts","sourceRoot":"","sources":["../../../src/types/run/checkpoint-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC,2CAA2C;IAC3C,QAAQ,EAAE,QAAQ,CAAA;IAClB,gDAAgD;IAChD,SAAS,EAAE,SAAS,CAAA;IACpB,wCAAwC;IACxC,SAAS,EAAE,SAAS,CAAA;IACpB,2CAA2C;IAC3C,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,sBAAsB;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;IAC9B,mDAAmD;IACnD,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,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAA;IAEtC;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAE1E,wEAAwE;IACxE,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,eAAe,CAAC,CACf,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAAA;CAC1B"}
|
|
@@ -125,6 +125,18 @@ export interface RunPersistenceConfig {
|
|
|
125
125
|
* hosts inject a scope-keyed backend (e.g. Postgres) here.
|
|
126
126
|
*/
|
|
127
127
|
checkpointStore?: CheckpointStore;
|
|
128
|
+
/**
|
|
129
|
+
* Optional run-evidence persistence override. Defaults to the disk layout
|
|
130
|
+
* under `outputDir` (a
|
|
131
|
+
* {@link import('../../store/run/disk.js').RunDiskStore}); hosts inject
|
|
132
|
+
* their own backend here.
|
|
133
|
+
*
|
|
134
|
+
* The sibling of `checkpointStore`, and it should have been one from the
|
|
135
|
+
* start: checkpoints got an injectable seam while the run record, its
|
|
136
|
+
* messages, its transcript and its report did not, so the evidence was
|
|
137
|
+
* the one part of a run that could not leave the local filesystem.
|
|
138
|
+
*/
|
|
139
|
+
runStore?: import('./store.js').RunStore;
|
|
128
140
|
}
|
|
129
141
|
export interface RunStoreConfig {
|
|
130
142
|
baseDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/types/run/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EA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,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,sBAAsB,EAAE,MAAM,CAAA;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzF,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzF,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/types/run/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './prepare-step.js';
|
|
|
3
3
|
export * from './stop-reason.js';
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './checkpoint-store.js';
|
|
6
|
+
export * from './store.js';
|
|
6
7
|
export * from './entity.js';
|
|
7
8
|
export * from './replay.js';
|
|
8
9
|
// Domain `RunStatus` (session-hierarchy.md §4.6 state machine). Safe to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,sBAAsB;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAQ1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,sBAAsB;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAQ1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunStore — persistence contract for a run's own evidence.
|
|
3
|
+
*
|
|
4
|
+
* The checkpoint store got an injectable seam and this did not, which left
|
|
5
|
+
* the run record, its messages, its transcript and its report reachable only
|
|
6
|
+
* through a concrete filesystem class. For a kernel whose stated purpose is
|
|
7
|
+
* auditable evidence, the evidence was the one thing that could not be
|
|
8
|
+
* pointed at durable storage: on ephemeral infrastructure the transcript dies
|
|
9
|
+
* with the container, and behind a load balancer two replicas write two
|
|
10
|
+
* disjoint run trees for one tenant.
|
|
11
|
+
*
|
|
12
|
+
* The location was already injectable through a path builder — but that
|
|
13
|
+
* returns filesystem path strings, so it relocates the directory without
|
|
14
|
+
* changing the medium.
|
|
15
|
+
*
|
|
16
|
+
* ## Bound to one run, unlike {@link CheckpointStore}
|
|
17
|
+
*
|
|
18
|
+
* Every accessor here addresses the run the store was bound to by
|
|
19
|
+
* {@link RunStore.initRun}, where a `CheckpointStore` takes an explicit scope
|
|
20
|
+
* per call. That asymmetry is inherited rather than chosen: this contract is
|
|
21
|
+
* extracted from a class the runtime already constructs per run and holds for
|
|
22
|
+
* the run's lifetime, and re-keying it would change every call site in the
|
|
23
|
+
* same change that introduces the seam — two risks where one will do.
|
|
24
|
+
*
|
|
25
|
+
* A host implementing a shared backend therefore keys its rows by the
|
|
26
|
+
* attribution it was constructed with plus the bound run id. If this is later
|
|
27
|
+
* re-keyed per call, it happens once, deliberately, as its own change.
|
|
28
|
+
*/
|
|
29
|
+
import type { Run } from './entity.js';
|
|
30
|
+
import type { RunEvent } from './events.js';
|
|
31
|
+
/**
|
|
32
|
+
* One finished tool call, recovered from the run's own transcript.
|
|
33
|
+
*
|
|
34
|
+
* Re-declared here rather than imported from the disk store so the contract
|
|
35
|
+
* does not depend on an implementation of itself.
|
|
36
|
+
*/
|
|
37
|
+
export interface CompletedToolRecord {
|
|
38
|
+
readonly toolUseId: string;
|
|
39
|
+
readonly toolName: string;
|
|
40
|
+
readonly result: string;
|
|
41
|
+
readonly isError: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface RunStore {
|
|
44
|
+
/**
|
|
45
|
+
* Bind this store to a run, before any other call.
|
|
46
|
+
*
|
|
47
|
+
* Returns a location when the backend has one — the built-in disk store
|
|
48
|
+
* returns the run's directory — and `null` when it does not. A caller
|
|
49
|
+
* that renders the value must treat `null` as "this run is not on a
|
|
50
|
+
* filesystem" rather than as an error: an in-memory or object-storage
|
|
51
|
+
* backend has nothing to print, and inventing a path for it would put a
|
|
52
|
+
* directory that does not exist in front of an operator.
|
|
53
|
+
*/
|
|
54
|
+
initRun(runId: string, parentRunId?: string): Promise<string | null>;
|
|
55
|
+
/** Persist the run record: status, metadata, usage, timings. */
|
|
56
|
+
writeRunMeta(run: Run): Promise<void>;
|
|
57
|
+
/** Persist the run's full message history. */
|
|
58
|
+
writeMessages(run: Run): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Append one event to the run's durable event log.
|
|
61
|
+
*
|
|
62
|
+
* High-frequency streaming deltas are excluded before they reach here —
|
|
63
|
+
* that exclusion is a deliberate trade and belongs to the emitter, not to
|
|
64
|
+
* the backend, so a store must not re-filter.
|
|
65
|
+
*/
|
|
66
|
+
appendEvent(event: RunEvent): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Persist the run's final report. Returns a location, or `null` when the
|
|
69
|
+
* backend has none. See {@link RunStore.initRun}.
|
|
70
|
+
*/
|
|
71
|
+
writeReport(content: string): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Every tool call this run has already finished, keyed by `toolUseId`.
|
|
74
|
+
*
|
|
75
|
+
* A batch's results reach the message history only once the WHOLE batch
|
|
76
|
+
* settles, so a hard kill part-way through loses every result that had
|
|
77
|
+
* already come back, and the resumed run re-executes those calls. For a
|
|
78
|
+
* file write that is waste; for a payment or an email it is a second one.
|
|
79
|
+
*
|
|
80
|
+
* A backend that does not retain individual events answers with an empty
|
|
81
|
+
* map, which costs re-execution and is honest. It must not answer with a
|
|
82
|
+
* PARTIAL map: a caller reads a present entry as "this call is already
|
|
83
|
+
* answered", so a half-remembered batch is worse than a forgotten one.
|
|
84
|
+
*/
|
|
85
|
+
readCompletedTools(): Promise<Map<string, CompletedToolRecord>>;
|
|
86
|
+
/**
|
|
87
|
+
* Where this run's evidence lives, or `null` when it is not on a
|
|
88
|
+
* filesystem. Valid only after {@link RunStore.initRun}.
|
|
89
|
+
*/
|
|
90
|
+
getRunDir(): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Record the run in a browsable catalogue of runs. OPTIONAL.
|
|
93
|
+
*
|
|
94
|
+
* Optional because it is the one method here that is not evidence: it
|
|
95
|
+
* maintains a convenience listing for a human reading the directory, and
|
|
96
|
+
* a backend whose runs are already queryable has nothing to add. The
|
|
97
|
+
* programmatic answer to "which runs are there" is
|
|
98
|
+
* `CheckpointStore.listDurableRuns`, which carries attribution and
|
|
99
|
+
* includes sub-runs; this does neither.
|
|
100
|
+
*/
|
|
101
|
+
addToIndex?(run: Run): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/types/run/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,QAAQ;IACxB;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEpE,gEAAgE;IAChE,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAErC,8CAA8C;IAC9C,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtC;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3C;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEpD;;;;;;;;;;;;OAYG;IACH,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;IAE/D;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI,CAAA;IAE1B;;;;;;;;;OASG;IACH,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunStore — persistence contract for a run's own evidence.
|
|
3
|
+
*
|
|
4
|
+
* The checkpoint store got an injectable seam and this did not, which left
|
|
5
|
+
* the run record, its messages, its transcript and its report reachable only
|
|
6
|
+
* through a concrete filesystem class. For a kernel whose stated purpose is
|
|
7
|
+
* auditable evidence, the evidence was the one thing that could not be
|
|
8
|
+
* pointed at durable storage: on ephemeral infrastructure the transcript dies
|
|
9
|
+
* with the container, and behind a load balancer two replicas write two
|
|
10
|
+
* disjoint run trees for one tenant.
|
|
11
|
+
*
|
|
12
|
+
* The location was already injectable through a path builder — but that
|
|
13
|
+
* returns filesystem path strings, so it relocates the directory without
|
|
14
|
+
* changing the medium.
|
|
15
|
+
*
|
|
16
|
+
* ## Bound to one run, unlike {@link CheckpointStore}
|
|
17
|
+
*
|
|
18
|
+
* Every accessor here addresses the run the store was bound to by
|
|
19
|
+
* {@link RunStore.initRun}, where a `CheckpointStore` takes an explicit scope
|
|
20
|
+
* per call. That asymmetry is inherited rather than chosen: this contract is
|
|
21
|
+
* extracted from a class the runtime already constructs per run and holds for
|
|
22
|
+
* the run's lifetime, and re-keying it would change every call site in the
|
|
23
|
+
* same change that introduces the seam — two risks where one will do.
|
|
24
|
+
*
|
|
25
|
+
* A host implementing a shared backend therefore keys its rows by the
|
|
26
|
+
* attribution it was constructed with plus the bound run id. If this is later
|
|
27
|
+
* re-keyed per call, it happens once, deliberately, as its own change.
|
|
28
|
+
*/
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/types/run/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import type { ProviderErrorInfo } from '../../types/provider/index.js'
|
|
|
9
9
|
import type { CheckpointRunScope, CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
10
10
|
import type { EmergencySaveData } from '../../types/run/emergency.js'
|
|
11
11
|
import type { Run, RunPersistenceConfig, StepResult, StopReason } from '../../types/run/index.js'
|
|
12
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
12
13
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
13
14
|
import { type ModelPricing, ZERO_COST, accumulateCost } from '../../utils/cost.js'
|
|
14
15
|
import { generateEmergencySaveId } from '../../utils/id.js'
|
|
@@ -16,7 +17,7 @@ import type { Logger } from '../../utils/logger.js'
|
|
|
16
17
|
|
|
17
18
|
export class RunPersistence {
|
|
18
19
|
private run: Run
|
|
19
|
-
private runStore:
|
|
20
|
+
private runStore: RunStore
|
|
20
21
|
private checkpointStore: CheckpointStore
|
|
21
22
|
private pricing?: ModelPricing
|
|
22
23
|
|
|
@@ -38,10 +39,17 @@ export class RunPersistence {
|
|
|
38
39
|
this._tenantId = config.tenantId
|
|
39
40
|
this._projectId = config.projectId
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// The run's own evidence goes through the same kind of injectable seam
|
|
43
|
+
// the checkpoint store already had. Without it the transcript, the run
|
|
44
|
+
// record and the report could only ever live on a local filesystem —
|
|
45
|
+
// which for a kernel whose purpose is auditable evidence made the
|
|
46
|
+
// evidence the one thing that could not be pointed at durable storage.
|
|
47
|
+
this.runStore =
|
|
48
|
+
config.runStore ??
|
|
49
|
+
new RunDiskStore({
|
|
50
|
+
baseDir: config.outputDir,
|
|
51
|
+
logger: config.log,
|
|
52
|
+
})
|
|
45
53
|
|
|
46
54
|
// Checkpoints go through the injectable seam; the disk layout under
|
|
47
55
|
// `outputDir` (same tree the runStore writes to) stays the default.
|
|
@@ -137,7 +145,7 @@ export class RunPersistence {
|
|
|
137
145
|
return this.run
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
getRunStore():
|
|
148
|
+
getRunStore(): RunStore {
|
|
141
149
|
return this.runStore
|
|
142
150
|
}
|
|
143
151
|
|
|
@@ -457,7 +465,9 @@ export class RunPersistence {
|
|
|
457
465
|
async persist(): Promise<void> {
|
|
458
466
|
await this.runStore.writeRunMeta(this.run)
|
|
459
467
|
await this.runStore.writeMessages(this.run)
|
|
460
|
-
|
|
468
|
+
// Optional on the contract: a backend whose runs are already queryable
|
|
469
|
+
// has no browsable directory to add a row to.
|
|
470
|
+
await this.runStore.addToIndex?.(this.run)
|
|
461
471
|
|
|
462
472
|
if (this.run.result) {
|
|
463
473
|
await this.runStore.writeReport(this.run.result)
|
package/src/public-runtime.ts
CHANGED
|
@@ -51,6 +51,12 @@ export function projectEmergencyToCheckpoint(dump: EmergencySaveData): Iteration
|
|
|
51
51
|
return {
|
|
52
52
|
id: `cp_emergency_${emergencySuffix}` as CheckpointId,
|
|
53
53
|
runId: dump.runId,
|
|
54
|
+
// The dump records the run's start, so this projection carries the
|
|
55
|
+
// same stamp an ordinary checkpoint of that run would — a run whose
|
|
56
|
+
// only surviving record is an emergency dump still has a real
|
|
57
|
+
// attribution instant, and dropping it here would put that run in the
|
|
58
|
+
// "never recorded" bucket for no reason.
|
|
59
|
+
runCreatedAt: dump.startedAt,
|
|
54
60
|
iteration: dump.currentIteration,
|
|
55
61
|
messages: dump.messages,
|
|
56
62
|
tokenUsage: dump.tokenUsage,
|
|
@@ -148,6 +154,27 @@ export class CheckpointManager {
|
|
|
148
154
|
/** See {@link setParkTtl}. */
|
|
149
155
|
private parkTtlMs?: number
|
|
150
156
|
|
|
157
|
+
/**
|
|
158
|
+
* The run's attribution instant, stamped onto every checkpoint this
|
|
159
|
+
* manager writes.
|
|
160
|
+
*
|
|
161
|
+
* Settled exactly once, by whichever of two things happens first, and
|
|
162
|
+
* never reassigned — every write to it below is `??=`, and there are only
|
|
163
|
+
* two:
|
|
164
|
+
*
|
|
165
|
+
* - `restore` ADOPTS it from the checkpoint a resume came back through.
|
|
166
|
+
* A resumed run is the same run, and its creation is already on the
|
|
167
|
+
* record; a fresh process minting a new one would move the key that
|
|
168
|
+
* exists specifically because it does not move.
|
|
169
|
+
* - `create` MINTS it from the run's own start instant when nothing was
|
|
170
|
+
* adopted, which is the fresh-run case.
|
|
171
|
+
*
|
|
172
|
+
* Restore runs during run setup, before the first iteration and therefore
|
|
173
|
+
* before the first `create`, so the adopt always wins on the resume path
|
|
174
|
+
* without either site needing to know which path it is on.
|
|
175
|
+
*/
|
|
176
|
+
private runCreatedAt?: number
|
|
177
|
+
|
|
151
178
|
/**
|
|
152
179
|
* @param store scope-keyed checkpoint persistence. The default query
|
|
153
180
|
* pipeline passes the run's disk-backed store
|
|
@@ -182,9 +209,17 @@ export class CheckpointManager {
|
|
|
182
209
|
workingState?: WorkingStateSnapshot
|
|
183
210
|
},
|
|
184
211
|
): Promise<IterationCheckpoint> {
|
|
212
|
+
// The run's own start, not `Date.now()`. This is meant to say when the
|
|
213
|
+
// run was attributed; taking the clock at the first checkpoint would
|
|
214
|
+
// say when it first became durable, which is a different and later
|
|
215
|
+
// fact, and naming it after the earlier one would make it wrong in
|
|
216
|
+
// exactly the way that is hard to notice.
|
|
217
|
+
this.runCreatedAt ??= runMgr.getSession().startedAt ?? Date.now()
|
|
218
|
+
|
|
185
219
|
const checkpoint: IterationCheckpoint = {
|
|
186
220
|
id: generateCheckpointId(),
|
|
187
221
|
runId: runMgr.id,
|
|
222
|
+
runCreatedAt: this.runCreatedAt,
|
|
188
223
|
iteration,
|
|
189
224
|
messages: [...runMgr.messages],
|
|
190
225
|
tokenUsage: { ...runMgr.tokenUsage },
|
|
@@ -342,6 +377,22 @@ export class CheckpointManager {
|
|
|
342
377
|
details: { checkpointId, runId: this.scope.runId },
|
|
343
378
|
})
|
|
344
379
|
}
|
|
380
|
+
|
|
381
|
+
// Adopt the run's recorded attribution. A resumed run is the SAME run
|
|
382
|
+
// under the same id, and its creation is already on the record; a
|
|
383
|
+
// fresh process minting a new one would step the stamp forward on
|
|
384
|
+
// every resume, which is the motion it exists to avoid.
|
|
385
|
+
//
|
|
386
|
+
// This needs no "is it really my run" guard, and one was written and
|
|
387
|
+
// removed: `readCheckpoint` is keyed by THIS manager's scope, so the
|
|
388
|
+
// only checkpoints reachable here are the ones belonging to
|
|
389
|
+
// `scope.runId`. A replay fork never arrives here at all — it reads
|
|
390
|
+
// its origin through the SOURCE scope in `prepareReplayState` and
|
|
391
|
+
// starts a fresh run, so it mints its own stamp rather than claiming
|
|
392
|
+
// its origin's age. A guard that no input can trip would have read as
|
|
393
|
+
// protection and been none.
|
|
394
|
+
this.runCreatedAt ??= checkpoint.runCreatedAt
|
|
395
|
+
|
|
345
396
|
return checkpoint
|
|
346
397
|
}
|
|
347
398
|
|
|
@@ -17,6 +17,7 @@ import type { PermissionMode } from '../../types/permission/index.js'
|
|
|
17
17
|
import type { LLMProvider } from '../../types/provider/index.js'
|
|
18
18
|
import type { CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
19
19
|
import type { AgentRunConfig } from '../../types/run/index.js'
|
|
20
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
20
21
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
21
22
|
import type { ModelPricing } from '../../utils/cost.js'
|
|
22
23
|
import { generateRunId } from '../../utils/id.js'
|
|
@@ -62,6 +63,7 @@ export interface RunContextConfig {
|
|
|
62
63
|
* output directory.
|
|
63
64
|
*/
|
|
64
65
|
checkpointStore?: CheckpointStore
|
|
66
|
+
runStore?: RunStore
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Optional injected migrator — tests pass a stub; production code relies
|
|
@@ -186,6 +188,7 @@ export class RunContextFactory {
|
|
|
186
188
|
parentRunId: config.parentRunId,
|
|
187
189
|
depth: config.depth,
|
|
188
190
|
checkpointStore: config.checkpointStore,
|
|
191
|
+
runStore: config.runStore,
|
|
189
192
|
})
|
|
190
193
|
|
|
191
194
|
const trackingConfig = resolveActivityTracking(permissionMode, config.enableActivityTracking)
|
|
@@ -70,6 +70,7 @@ import type {
|
|
|
70
70
|
} from '../../types/run/index.js'
|
|
71
71
|
import type { PromoteMemory } from '../../types/run/memory-promotion.js'
|
|
72
72
|
import { memoryCandidateFor } from '../../types/run/memory-promotion.js'
|
|
73
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
73
74
|
import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
|
|
74
75
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
75
76
|
import type { Skill } from '../../types/skills/index.js'
|
|
@@ -412,6 +413,17 @@ export interface QueryParams {
|
|
|
412
413
|
*/
|
|
413
414
|
checkpointStore?: CheckpointStore
|
|
414
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Where this run records its own evidence — the run record, its messages,
|
|
418
|
+
* its transcript and its report. Defaults to the disk layout under the
|
|
419
|
+
* resolved output directory.
|
|
420
|
+
*
|
|
421
|
+
* The sibling of {@link QueryParams.checkpointStore}, and it should always
|
|
422
|
+
* have been one: checkpoints could be pointed at durable storage and the
|
|
423
|
+
* evidence could not.
|
|
424
|
+
*/
|
|
425
|
+
runStore?: RunStore
|
|
426
|
+
|
|
415
427
|
runId?: RunId
|
|
416
428
|
|
|
417
429
|
parentRunId?: RunId
|
|
@@ -610,6 +622,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
610
622
|
tenantId: params.tenantId,
|
|
611
623
|
pathBuilder: params.pathBuilder,
|
|
612
624
|
checkpointStore: params.checkpointStore,
|
|
625
|
+
runStore: params.runStore,
|
|
613
626
|
runId: params.runId,
|
|
614
627
|
parentRunId: params.parentRunId,
|
|
615
628
|
depth: params.depth,
|
package/src/store/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { InMemoryStore } from './InMemoryStore.js'
|
|
|
2
2
|
export type { Identifiable, Timestamped } from './InMemoryStore.js'
|
|
3
3
|
|
|
4
4
|
export { RunDiskStore } from './run/disk.js'
|
|
5
|
+
export { InMemoryRunStore } from './run/memory.js'
|
|
5
6
|
export { DiskCheckpointStore } from './run/checkpoint-disk.js'
|
|
6
7
|
export type { DiskCheckpointStoreAttribution } from './run/checkpoint-disk.js'
|
|
7
8
|
export { InMemoryCheckpointStore } from './run/checkpoint-memory.js'
|