@dudousxd/nestjs-durable-core 0.106.1 → 0.106.2

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.cjs CHANGED
@@ -13180,6 +13180,20 @@ var WorkflowEngine = class _WorkflowEngine {
13180
13180
  ];
13181
13181
  }
13182
13182
  /**
13183
+ * Whether a streamed step event comes from the turn its run awaits. A dispatched turn that went
13184
+ * quiet past the silence window is dispatched again, but its first worker may still be replaying it
13185
+ * and streaming its steps; written unchecked, those would put a stale turn's output under the live
13186
+ * turn's checkpoint. An event without a `taskId` (a worker from before the field) is kept.
13187
+ */
13188
+ async stepEventFromAwaitedTurn(event) {
13189
+ if (event.taskId === void 0) return true;
13190
+ const run = await this.store.getRun(event.runId);
13191
+ if (!run) return false;
13192
+ return awaitsDecision(run, {
13193
+ taskId: event.taskId
13194
+ });
13195
+ }
13196
+ /**
13183
13197
  * Persist a streamed local-step lifecycle event from a remote workflow worker (see
13184
13198
  * {@link WorkflowStepEvent}). A Python `@workflow` runs its `ctx.step`s inline over one turn that
13185
13199
  * can last minutes; the worker streams each step's start/finish so the engine checkpoints it LIVE —
@@ -13189,6 +13203,7 @@ var WorkflowEngine = class _WorkflowEngine {
13189
13203
  * idempotently, so this is purely additive observability and never changes the run's outcome.
13190
13204
  */
13191
13205
  async persistStepEvent(event) {
13206
+ if (!await this.stepEventFromAwaitedTurn(event)) return;
13192
13207
  const startedAt = new Date(event.startedAt);
13193
13208
  if (event.phase === "running") {
13194
13209
  await this.store.saveCheckpoint(stepCheckpoint({