@axiom-lattice/core 6.3.0 → 6.3.1

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.mjs CHANGED
@@ -18552,12 +18552,47 @@ var Agent = class {
18552
18552
  id: interruptData.id,
18553
18553
  data: { content: interruptData.value }
18554
18554
  };
18555
+ await this.awaitDurableInterrupt(interruptData.id, signal);
18555
18556
  }
18556
18557
  if (data) {
18557
18558
  this.addChunk(data);
18558
18559
  }
18559
18560
  }
18560
18561
  }
18562
+ /**
18563
+ * Waits until the thread's durable checkpoint reports the given interrupt id.
18564
+ *
18565
+ * Reads {@link getCurrentState} (the checkpoint, i.e. the single source of
18566
+ * truth), never an in-memory status, so a `true` result guarantees a resume
18567
+ * against this thread will find the interrupt. Bounded so a broken
18568
+ * checkpointer cannot strand the stream; on timeout the interrupt is emitted
18569
+ * anyway and a warning is logged.
18570
+ *
18571
+ * @param interruptId - Interrupt id from the streamed `__interrupt__` update.
18572
+ * @param signal - Run abort signal; polling stops when aborted.
18573
+ * @param timeoutMs - Maximum time to wait for durable confirmation.
18574
+ */
18575
+ async awaitDurableInterrupt(interruptId, signal, timeoutMs = 5e3) {
18576
+ if (!interruptId) return;
18577
+ const deadline = Date.now() + timeoutMs;
18578
+ while (!signal?.aborted) {
18579
+ try {
18580
+ const state = await this.getCurrentState();
18581
+ const durable = (state?.tasks ?? []).some(
18582
+ (task) => (task.interrupts ?? []).some((interrupt5) => interrupt5.id === interruptId)
18583
+ );
18584
+ if (durable) return;
18585
+ } catch {
18586
+ }
18587
+ if (Date.now() >= deadline) {
18588
+ console.warn(
18589
+ `[Agent] interrupt ${interruptId} not durable within ${timeoutMs}ms on thread ${this.thread_id}; emitting without durable confirmation`
18590
+ );
18591
+ return;
18592
+ }
18593
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
18594
+ }
18595
+ }
18561
18596
  /**
18562
18597
  * Resume LangGraph execution from the last checkpoint.
18563
18598
  *