@dudousxd/nestjs-durable-core 0.85.8 → 0.85.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4800,6 +4800,7 @@ var ANNOUNCED_ROUTES_TTL_MS = 5e3;
4800
4800
  var VERSION_UNDECLARED_TAG = "version:undeclared";
4801
4801
  var versionKey = /* @__PURE__ */ __name((name, version) => `${name}@${version}`, "versionKey");
4802
4802
  var STEP_FAN_CHUNK = 200;
4803
+ var FAN_REREAD_CHUNK = 1e3;
4803
4804
  var PARENT_NOTIFY_ATTEMPTS = 4;
4804
4805
  var PARENT_NOTIFY_BACKOFF_MS = 250;
4805
4806
  var LEASE_RECHECK_MAX_MS = 2e3;
@@ -7236,8 +7237,7 @@ var WorkflowEngine = class {
7236
7237
  */
7237
7238
  async redriveSettledSteps(runId, seqs) {
7238
7239
  for (const seq of seqs) {
7239
- const cp = await this.store.getCheckpoint(runId, seq);
7240
- if (cp && (cp.status === "completed" || cp.status === "failed")) {
7240
+ if (await this.stepSettled(runId, seq)) {
7241
7241
  if (this.settledHere.has(`${runId}:${seq}`)) return;
7242
7242
  const nowMs = this.clock();
7243
7243
  if (!await this.store.tryLockRun(runId, this.instanceId, nowMs + this.leaseMs, nowMs)) {
@@ -7253,6 +7253,17 @@ var WorkflowEngine = class {
7253
7253
  }
7254
7254
  }
7255
7255
  }
7256
+ /** Whether the step at `seq` is settled: a `COUNT` when the store has one, else its checkpoint. */
7257
+ async stepSettled(runId, seq) {
7258
+ if (this.store.countCheckpoints) {
7259
+ return await this.store.countCheckpoints(runId, seq, seq, [
7260
+ "completed",
7261
+ "failed"
7262
+ ]) > 0;
7263
+ }
7264
+ const cp = await this.store.getCheckpoint(runId, seq);
7265
+ return cp?.status === "completed" || cp?.status === "failed";
7266
+ }
7256
7267
  /**
7257
7268
  * {@link redriveSettledSteps} for a step fan: once the turn that suspended on it released its lease,
7258
7269
  * re-drive the run if no step of the fan is still `pending` — the last result landed on another
@@ -8724,7 +8735,7 @@ ${run.workflowVersion}`;
8724
8735
  }
8725
8736
  const wfPlan = await this.planRoute(tenantGroup(sanitizeQueueToken(remote.group), void 0), registered.requires);
8726
8737
  if (wfPlan?.status === "blocked") return this.parkBlocked(run, wfPlan);
8727
- const checkpoints = await this.store.listCheckpoints(run.id);
8738
+ const checkpoints = await this.replayCheckpoints(run.id);
8728
8739
  await this.deliverFinishedChildren(run.id, checkpoints);
8729
8740
  await this.deliverFinishedChildWaiters(run.id, checkpoints);
8730
8741
  const handoff = liveHandoff(run.id, checkpoints);
@@ -9000,6 +9011,37 @@ ${run.workflowVersion}`;
9000
9011
  * throttle for {@link rearmStepLease}, the step-scoped sibling of {@link decisionDeadlineRearms}. */
9001
9012
  stepLeaseRearms = /* @__PURE__ */ new Map();
9002
9013
  /**
9014
+ * {@link stepLeaseRearms} for the steps of a fan this instance sent, by run: one entry per sent
9015
+ * block of consecutive seqs instead of one per step, since they share the lease stamped at send.
9016
+ */
9017
+ fanLeaseRearms = /* @__PURE__ */ new Map();
9018
+ noteFanLease(runId, seqs, lease) {
9019
+ if (this.remoteRedispatchMs == null || seqs.length === 0) return;
9020
+ let from = seqs[0];
9021
+ let to = from;
9022
+ for (const seq of seqs) {
9023
+ if (seq < from) from = seq;
9024
+ if (seq > to) to = seq;
9025
+ }
9026
+ if (to - from + 1 !== seqs.length) return;
9027
+ if (this.fanLeaseRearms.size > 1024) this.fanLeaseRearms.clear();
9028
+ const blocks = this.fanLeaseRearms.get(runId) ?? [];
9029
+ blocks.push({
9030
+ from,
9031
+ to,
9032
+ lookAgainAt: lease - Math.ceil(this.remoteRedispatchMs / 2)
9033
+ });
9034
+ this.fanLeaseRearms.set(runId, blocks);
9035
+ }
9036
+ fanLeaseLookAgainAt(runId, seq, now) {
9037
+ const blocks = this.fanLeaseRearms.get(runId);
9038
+ if (!blocks) return void 0;
9039
+ const live = blocks.filter((b) => now < b.lookAgainAt);
9040
+ if (live.length === 0) this.fanLeaseRearms.delete(runId);
9041
+ else if (live.length < blocks.length) this.fanLeaseRearms.set(runId, live);
9042
+ return live.find((b) => seq >= b.from && seq <= b.to)?.lookAgainAt;
9043
+ }
9044
+ /**
9003
9045
  * A step-scoped heartbeat for a durably-suspended remote step: push its LEASE forward so a worker
9004
9046
  * that is still working on it is never presumed dead and double-dispatched. The durable counterpart
9005
9047
  * of {@link callRemoteInMemory}'s in-memory `heartbeatResets` rearm (which only exists on the
@@ -9028,7 +9070,7 @@ ${run.workflowVersion}`;
9028
9070
  if (this.remoteRedispatchMs == null) return;
9029
9071
  const id = stepId(runId, seq);
9030
9072
  const now = this.clock();
9031
- const lookAgainAt = this.stepLeaseRearms.get(id);
9073
+ const lookAgainAt = this.stepLeaseRearms.get(id) ?? this.fanLeaseLookAgainAt(runId, seq, now);
9032
9074
  if (lookAgainAt !== void 0 && now < lookAgainAt) return;
9033
9075
  try {
9034
9076
  const cp = await this.store.getCheckpoint(runId, seq);
@@ -9351,7 +9393,7 @@ ${run.workflowVersion}`;
9351
9393
  return this.singletonWaitResult(run);
9352
9394
  }
9353
9395
  const compensations = [];
9354
- const snapshot = await this.store.listCheckpoints(run.id);
9396
+ const snapshot = await this.replayCheckpoints(run.id);
9355
9397
  await this.deliverFinishedChildren(run.id, snapshot);
9356
9398
  const replay = /* @__PURE__ */ new Map();
9357
9399
  for (const cp of snapshot) replay.set(cp.seq, cp);
@@ -9681,7 +9723,7 @@ ${run.workflowVersion}`;
9681
9723
  }), "callRemote"),
9682
9724
  callRemoteAll: /* @__PURE__ */ __name((runId, positions, step, inputs, opts) => this.callRemoteAll(runId, positions, step, inputs, opts, {
9683
9725
  namespace: parentNamespace
9684
- }), "callRemoteAll"),
9726
+ }, replay), "callRemoteAll"),
9685
9727
  // Defer so a fast child can't reentrantly resume a still-running parent. Stamp the child with
9686
9728
  // the PARENT run's namespace (not this engine's) so a child belongs to the tenant/partition of
9687
9729
  // the run it was spawned from — even when an operator (namespace: undefined, drives every
@@ -10038,7 +10080,7 @@ ${run.workflowVersion}`;
10038
10080
  * concurrently with this one finds them already sent instead of sending them again. The join
10039
10081
  * barrier ({@link stepFanStillRunning}) then wakes the parent once per wave, not once per result.
10040
10082
  */
10041
- async callRemoteAll(runId, positions, step, inputs, opts, routing) {
10083
+ async callRemoteAll(runId, positions, step, inputs, opts, routing, replay) {
10042
10084
  if (step.timeoutMs) {
10043
10085
  throw new Error(`ctx.all: step "${step.name}" has a liveness timeoutMs; a step fan needs durable steps`);
10044
10086
  }
@@ -10049,10 +10091,7 @@ ${run.workflowVersion}`;
10049
10091
  const first = positions[0];
10050
10092
  const last = positions[positions.length - 1];
10051
10093
  const group = stepFanGroup(first, positions.length, opts.mode);
10052
- const bySeq = /* @__PURE__ */ new Map();
10053
- for (const cp of await this.store.listCheckpoints(runId)) {
10054
- if (cp.seq >= first && cp.seq <= last) bySeq.set(cp.seq, cp);
10055
- }
10094
+ const bySeq = await this.fanCheckpoints(runId, positions, replay);
10056
10095
  const outputs = new Array(inputs.length);
10057
10096
  const failures = [];
10058
10097
  const unsent = [];
@@ -10109,7 +10148,13 @@ ${run.workflowVersion}`;
10109
10148
  }
10110
10149
  if (inFlight === 0 && highest >= 0) this.turnSettledFans.get(runId)?.set(first, highest);
10111
10150
  const batch = inFlight > 0 ? [] : opts.concurrency === void 0 ? unsent : unsent.slice(0, opts.concurrency);
10112
- if (batch.length > 0) await this.sendStepFan(runId, positions, step, inputs, batch, group, opts, routing);
10151
+ if (batch.length > 0) {
10152
+ const lease = await this.sendStepFan(runId, positions, step, inputs, batch, group, opts, routing);
10153
+ if (lease !== void 0) {
10154
+ const at = this.stepLeaseWakeAt(lease);
10155
+ wakeAt = Math.min(wakeAt ?? at, at);
10156
+ }
10157
+ }
10113
10158
  if (inFlight + batch.length > 0) {
10114
10159
  this.awaitedStepFans.get(runId)?.push({
10115
10160
  from: first,
@@ -10139,6 +10184,34 @@ ${run.workflowVersion}`;
10139
10184
  return outputs;
10140
10185
  }
10141
10186
  /**
10187
+ * The checkpoints of a step fan's seqs, by seq. A settled one is taken from the turn's snapshot
10188
+ * (`replay`), since nothing but a turn of the run changes it once settled; one the snapshot holds
10189
+ * `pending`, or does not hold, is read again, as {@link callRemote} does for a single step: its
10190
+ * result may have landed since. The fan's last turn so reads nothing it already read.
10191
+ */
10192
+ async fanCheckpoints(runId, positions, replay) {
10193
+ const bySeq = /* @__PURE__ */ new Map();
10194
+ const reread = [];
10195
+ for (const seq of positions) {
10196
+ const cp = replay?.get(seq);
10197
+ if (cp && (cp.status === "completed" || cp.status === "failed")) bySeq.set(seq, cp);
10198
+ else reread.push(seq);
10199
+ }
10200
+ if (reread.length === 0) return bySeq;
10201
+ if (reread.length === positions.length || !this.store.getCheckpoints) {
10202
+ const wanted = new Set(reread);
10203
+ for (const cp of await this.store.listCheckpoints(runId)) {
10204
+ if (wanted.has(cp.seq)) bySeq.set(cp.seq, cp);
10205
+ }
10206
+ return bySeq;
10207
+ }
10208
+ for (let at = 0; at < reread.length; at += FAN_REREAD_CHUNK) {
10209
+ const read = await this.store.getCheckpoints(runId, reread.slice(at, at + FAN_REREAD_CHUNK));
10210
+ for (const cp of read) bySeq.set(cp.seq, cp);
10211
+ }
10212
+ return bySeq;
10213
+ }
10214
+ /**
10142
10215
  * Write the `pending` checkpoints of a step fan's new steps, then dispatch them: one
10143
10216
  * {@link StateStore.saveCheckpoints} call and one {@link TransportPool.dispatchMany} for the
10144
10217
  * batch, where the store and transport have them.
@@ -10147,6 +10220,7 @@ ${run.workflowVersion}`;
10147
10220
  const workerGroup = stepGroup(step, routing?.namespace);
10148
10221
  await this.ensureRoutable(workerGroup, step.requires);
10149
10222
  const enqueuedAt = /* @__PURE__ */ new Date();
10223
+ const lease = this.remoteRedispatchMs == null ? void 0 : this.clock() + this.remoteRedispatchMs;
10150
10224
  const checkpoints = batch.map((i) => {
10151
10225
  const seq = positions[i];
10152
10226
  return {
@@ -10162,7 +10236,10 @@ ${run.workflowVersion}`;
10162
10236
  parallelGroup: group,
10163
10237
  enqueuedAt,
10164
10238
  startedAt: enqueuedAt,
10165
- finishedAt: enqueuedAt
10239
+ finishedAt: enqueuedAt,
10240
+ ...lease !== void 0 ? {
10241
+ wakeAt: lease
10242
+ } : {}
10166
10243
  };
10167
10244
  });
10168
10245
  if (this.store.saveCheckpoints) {
@@ -10195,20 +10272,36 @@ ${run.workflowVersion}`;
10195
10272
  kind: "remote"
10196
10273
  });
10197
10274
  }
10275
+ if (lease !== void 0) {
10276
+ this.noteFanLease(runId, checkpoints.map((cp) => cp.seq), lease);
10277
+ }
10278
+ return lease;
10198
10279
  }
10199
10280
  /** Remember a step settled here, forgetting entries older than a lease so the map stays small. */
10200
10281
  noteSettledHere(key) {
10201
10282
  this.noteRecent(this.settledHere, key);
10202
10283
  }
10203
- /** Record `key` in a "happened here recently" map, pruning entries older than a lease. */
10284
+ /**
10285
+ * Record `key` in a "happened here recently" map and drop the entries older than a lease. A key is
10286
+ * re-inserted at the end, so the map stays in the order its keys were noted and the stale ones are
10287
+ * all at its front: pruning stops at the first fresh entry instead of walking the whole map.
10288
+ */
10204
10289
  noteRecent(map, key) {
10205
10290
  const now = this.clock();
10291
+ map.delete(key);
10206
10292
  map.set(key, now);
10207
- if (map.size < 1024) return;
10208
10293
  for (const [k, at] of map) {
10209
- if (now - at > this.leaseMs) map.delete(k);
10294
+ if (now - at <= this.leaseMs) break;
10295
+ map.delete(k);
10210
10296
  }
10211
10297
  }
10298
+ /**
10299
+ * The run's checkpoints as a turn replays them: {@link StateStore.listCheckpointsForReplay} when
10300
+ * the store has it (no input on a completed row), else {@link StateStore.listCheckpoints}.
10301
+ */
10302
+ replayCheckpoints(runId) {
10303
+ return this.store.listCheckpointsForReplay ? this.store.listCheckpointsForReplay(runId) : this.store.listCheckpoints(runId);
10304
+ }
10212
10305
  /** {@link StateStore.saveCheckpointIfPending}, or a plain save on a store without it. */
10213
10306
  async savePendingCheckpoint(checkpoint) {
10214
10307
  if (this.store.saveCheckpointIfPending) return this.store.saveCheckpointIfPending(checkpoint);
@@ -10235,11 +10328,59 @@ ${run.workflowVersion}`;
10235
10328
  });
10236
10329
  }
10237
10330
  /**
10331
+ * Settle steps of one run at distinct seqs from their results ({@link StepSettlement}s, `settled[i]`
10332
+ * being the `pending` row `settlements[i]` settles): one
10333
+ * {@link StateStore.settleCheckpointsIfPending} call when the store has it, which writes only what
10334
+ * a result changes, else the whole rows through {@link savePendingCheckpoints}. Never rejects as a
10335
+ * whole, the same way.
10336
+ */
10337
+ async settlePendingCheckpoints(settlements, settled) {
10338
+ const settle = this.store.settleCheckpointsIfPending?.bind(this.store);
10339
+ if (!settle) {
10340
+ return this.savePendingCheckpoints(settlements.map((s, i) => ({
10341
+ ...settled[i],
10342
+ ...s
10343
+ })));
10344
+ }
10345
+ if (settlements.length > 1) {
10346
+ try {
10347
+ const wrote = await settle(settlements);
10348
+ return settlements.map((_, i) => wrote[i] === true);
10349
+ } catch {
10350
+ }
10351
+ }
10352
+ const one = await Promise.allSettled(settlements.map((s) => settle([
10353
+ s
10354
+ ])));
10355
+ return one.map((s) => s.status === "fulfilled" ? s.value[0] === true : {
10356
+ error: s.reason
10357
+ });
10358
+ }
10359
+ /**
10238
10360
  * The checkpoints of one run at distinct `seqs`, each as its own outcome: one
10239
10361
  * {@link StateStore.getCheckpoints} call when the store has it, else one read each. The batch
10240
10362
  * call rejecting falls back to one read each, so a failing read fails only its own entry.
10241
10363
  */
10242
10364
  async readCheckpoints(runId, seqs) {
10365
+ const forSettle = this.store.settleCheckpointsIfPending ? this.store.getCheckpointsForSettle?.bind(this.store) : void 0;
10366
+ if (forSettle) {
10367
+ if (seqs.length > 1) {
10368
+ try {
10369
+ const bySeq = new Map((await forSettle(runId, seqs)).map((cp) => [
10370
+ cp.seq,
10371
+ cp
10372
+ ]));
10373
+ return seqs.map((seq) => ({
10374
+ status: "fulfilled",
10375
+ value: bySeq.get(seq) ?? null
10376
+ }));
10377
+ } catch {
10378
+ }
10379
+ }
10380
+ return Promise.allSettled(seqs.map(async (seq) => (await forSettle(runId, [
10381
+ seq
10382
+ ]))[0] ?? null));
10383
+ }
10243
10384
  if (seqs.length > 1 && this.store.getCheckpoints) {
10244
10385
  try {
10245
10386
  const bySeq = new Map((await this.store.getCheckpoints(runId, seqs)).map((cp) => [
@@ -10388,10 +10529,11 @@ ${run.workflowVersion}`;
10388
10529
  const run = await this.store.getRun(runId);
10389
10530
  if (run && (run.status === "cancelled" || run.status === "completed")) return outcomes;
10390
10531
  const finishedAt = /* @__PURE__ */ new Date();
10391
- const writes = pending.map(({ index, cp }) => {
10532
+ const settlements = pending.map(({ index, cp }) => {
10392
10533
  const result = results[index];
10393
10534
  return {
10394
- ...cp,
10535
+ runId,
10536
+ seq: cp.seq,
10395
10537
  status: result.status,
10396
10538
  output: result.status === "completed" ? result.output : cp.output,
10397
10539
  error: result.error,
@@ -10400,7 +10542,7 @@ ${run.workflowVersion}`;
10400
10542
  finishedAt
10401
10543
  };
10402
10544
  });
10403
- const claims = await this.savePendingCheckpoints(writes);
10545
+ const claims = await this.settlePendingCheckpoints(settlements, pending.map(({ cp }) => cp));
10404
10546
  const settled = [];
10405
10547
  claims.forEach((claim, k) => {
10406
10548
  const { index, cp } = pending[k];
@@ -10414,7 +10556,7 @@ ${run.workflowVersion}`;
10414
10556
  };
10415
10557
  });
10416
10558
  for (const { cp, result } of settled) {
10417
- this.noteSettledHere(`${runId}:${result.seq}`);
10559
+ if (!parseStepFanGroup(cp.parallelGroup)) this.noteSettledHere(`${runId}:${result.seq}`);
10418
10560
  const startedAt = result.startedAt ? new Date(result.startedAt) : cp.startedAt;
10419
10561
  this.emit({
10420
10562
  type: result.status === "completed" ? "step.completed" : "step.failed",
@@ -11313,8 +11455,16 @@ var CodecStateStore = class {
11313
11455
  saveCheckpointIfPending;
11314
11456
  /** Encodes each checkpoint like {@link saveCheckpoint}. Bound only when the inner store has it. */
11315
11457
  saveCheckpointsIfPending;
11458
+ /** Encodes each settlement's payloads like {@link saveCheckpoint}. Bound only when the inner store
11459
+ * has it, so the engine's whole-row fallback still kicks in through the wrapper. */
11460
+ settleCheckpointsIfPending;
11316
11461
  /** Encodes each checkpoint written. Bound only when the inner store has it. */
11317
11462
  saveCheckpoints;
11463
+ /** Decodes each checkpoint read like {@link listCheckpoints}. Bound only when the inner store has
11464
+ * it, so the engine's full-read fallback still kicks in through the wrapper. */
11465
+ listCheckpointsForReplay;
11466
+ /** Decodes each checkpoint read. Bound only when the inner store has it. */
11467
+ getCheckpointsForSettle;
11318
11468
  /** Decodes each checkpoint read. Bound only when the inner store has it. */
11319
11469
  getCheckpoints;
11320
11470
  /** Forwarded verbatim — a count reads no payload. Bound only when the inner store has it. */
@@ -11367,8 +11517,14 @@ var CodecStateStore = class {
11367
11517
  if (saveIfPending) this.saveCheckpointIfPending = (cp) => saveIfPending.call(inner, this.encCp(cp));
11368
11518
  const saveManyIfPending = inner.saveCheckpointsIfPending;
11369
11519
  if (saveManyIfPending) this.saveCheckpointsIfPending = (cps) => saveManyIfPending.call(inner, cps.map((cp) => this.encCp(cp)));
11520
+ const settleMany = inner.settleCheckpointsIfPending;
11521
+ if (settleMany) this.settleCheckpointsIfPending = (settlements) => settleMany.call(inner, settlements.map((s) => this.encSettlement(s)));
11370
11522
  const saveMany = inner.saveCheckpoints;
11371
11523
  if (saveMany) this.saveCheckpoints = (cps) => saveMany.call(inner, cps.map((cp) => this.encCp(cp)));
11524
+ const listForReplay = inner.listCheckpointsForReplay;
11525
+ if (listForReplay) this.listCheckpointsForReplay = async (runId) => (await listForReplay.call(inner, runId)).map((cp) => this.decCp(cp));
11526
+ const getForSettle = inner.getCheckpointsForSettle;
11527
+ if (getForSettle) this.getCheckpointsForSettle = async (runId, seqs) => (await getForSettle.call(inner, runId, seqs)).map((cp) => this.decCp(cp));
11372
11528
  const getMany = inner.getCheckpoints;
11373
11529
  if (getMany) this.getCheckpoints = async (runId, seqs) => (await getMany.call(inner, runId, seqs)).map((cp) => this.decCp(cp));
11374
11530
  const countCps = inner.countCheckpoints;
@@ -11460,6 +11616,21 @@ var CodecStateStore = class {
11460
11616
  }
11461
11617
  return next;
11462
11618
  }
11619
+ encSettlement(settlement) {
11620
+ const next = {
11621
+ ...settlement,
11622
+ output: this.enc(settlement.output)
11623
+ };
11624
+ if (this.extended) {
11625
+ if (settlement.events !== void 0) {
11626
+ next.events = this.enc(settlement.events);
11627
+ }
11628
+ if (settlement.error !== void 0) {
11629
+ next.error = this.enc(settlement.error);
11630
+ }
11631
+ }
11632
+ return next;
11633
+ }
11463
11634
  decCp(cp) {
11464
11635
  if (!cp) return cp;
11465
11636
  const next = {
@@ -12019,6 +12190,18 @@ var InMemoryStateStore = class {
12019
12190
  ] : [];
12020
12191
  });
12021
12192
  }
12193
+ async getCheckpointsForSettle(runId, seqs) {
12194
+ return [
12195
+ ...new Set(seqs)
12196
+ ].sort((a, b) => a - b).flatMap((seq) => {
12197
+ const cp = this.checkpoints.get(this.key(runId, seq));
12198
+ if (!cp) return [];
12199
+ const { input: _input, ...rest } = cp;
12200
+ return [
12201
+ rest
12202
+ ];
12203
+ });
12204
+ }
12022
12205
  async saveCheckpoint(checkpoint) {
12023
12206
  this.checkpoints.set(this.key(checkpoint.runId, checkpoint.seq), {
12024
12207
  ...checkpoint
@@ -12049,6 +12232,18 @@ var InMemoryStateStore = class {
12049
12232
  return true;
12050
12233
  });
12051
12234
  }
12235
+ async settleCheckpointsIfPending(settlements) {
12236
+ return settlements.map((settlement) => {
12237
+ const key = this.key(settlement.runId, settlement.seq);
12238
+ const cp = this.checkpoints.get(key);
12239
+ if (cp?.status !== "pending") return false;
12240
+ this.checkpoints.set(key, {
12241
+ ...cp,
12242
+ ...settlement
12243
+ });
12244
+ return true;
12245
+ });
12246
+ }
12052
12247
  async listOrphanedRuns(nowMs, limit, namespace, ownedBy) {
12053
12248
  return [
12054
12249
  ...this.runs.values()
@@ -12365,6 +12560,13 @@ var InMemoryStateStore = class {
12365
12560
  this.checkpointRowsRead += rows.length;
12366
12561
  return rows;
12367
12562
  }
12563
+ async listCheckpointsForReplay(runId) {
12564
+ return (await this.listCheckpoints(runId)).map((cp) => {
12565
+ if (cp.status !== "completed") return cp;
12566
+ const { input: _input, ...rest } = cp;
12567
+ return rest;
12568
+ });
12569
+ }
12368
12570
  runCheckpoints(runId) {
12369
12571
  return [
12370
12572
  ...this.checkpoints.values()