@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.d.mts CHANGED
@@ -9471,6 +9471,20 @@ declare class Agent {
9471
9471
  private queueScope;
9472
9472
  private agentStreamExecutor;
9473
9473
  private consumeAgentStream;
9474
+ /**
9475
+ * Waits until the thread's durable checkpoint reports the given interrupt id.
9476
+ *
9477
+ * Reads {@link getCurrentState} (the checkpoint, i.e. the single source of
9478
+ * truth), never an in-memory status, so a `true` result guarantees a resume
9479
+ * against this thread will find the interrupt. Bounded so a broken
9480
+ * checkpointer cannot strand the stream; on timeout the interrupt is emitted
9481
+ * anyway and a warning is logged.
9482
+ *
9483
+ * @param interruptId - Interrupt id from the streamed `__interrupt__` update.
9484
+ * @param signal - Run abort signal; polling stops when aborted.
9485
+ * @param timeoutMs - Maximum time to wait for durable confirmation.
9486
+ */
9487
+ private awaitDurableInterrupt;
9474
9488
  /**
9475
9489
  * Resume LangGraph execution from the last checkpoint.
9476
9490
  *
package/dist/index.d.ts CHANGED
@@ -9471,6 +9471,20 @@ declare class Agent {
9471
9471
  private queueScope;
9472
9472
  private agentStreamExecutor;
9473
9473
  private consumeAgentStream;
9474
+ /**
9475
+ * Waits until the thread's durable checkpoint reports the given interrupt id.
9476
+ *
9477
+ * Reads {@link getCurrentState} (the checkpoint, i.e. the single source of
9478
+ * truth), never an in-memory status, so a `true` result guarantees a resume
9479
+ * against this thread will find the interrupt. Bounded so a broken
9480
+ * checkpointer cannot strand the stream; on timeout the interrupt is emitted
9481
+ * anyway and a warning is logged.
9482
+ *
9483
+ * @param interruptId - Interrupt id from the streamed `__interrupt__` update.
9484
+ * @param signal - Run abort signal; polling stops when aborted.
9485
+ * @param timeoutMs - Maximum time to wait for durable confirmation.
9486
+ */
9487
+ private awaitDurableInterrupt;
9474
9488
  /**
9475
9489
  * Resume LangGraph execution from the last checkpoint.
9476
9490
  *
package/dist/index.js CHANGED
@@ -20538,12 +20538,47 @@ var Agent = class {
20538
20538
  id: interruptData.id,
20539
20539
  data: { content: interruptData.value }
20540
20540
  };
20541
+ await this.awaitDurableInterrupt(interruptData.id, signal);
20541
20542
  }
20542
20543
  if (data) {
20543
20544
  this.addChunk(data);
20544
20545
  }
20545
20546
  }
20546
20547
  }
20548
+ /**
20549
+ * Waits until the thread's durable checkpoint reports the given interrupt id.
20550
+ *
20551
+ * Reads {@link getCurrentState} (the checkpoint, i.e. the single source of
20552
+ * truth), never an in-memory status, so a `true` result guarantees a resume
20553
+ * against this thread will find the interrupt. Bounded so a broken
20554
+ * checkpointer cannot strand the stream; on timeout the interrupt is emitted
20555
+ * anyway and a warning is logged.
20556
+ *
20557
+ * @param interruptId - Interrupt id from the streamed `__interrupt__` update.
20558
+ * @param signal - Run abort signal; polling stops when aborted.
20559
+ * @param timeoutMs - Maximum time to wait for durable confirmation.
20560
+ */
20561
+ async awaitDurableInterrupt(interruptId, signal, timeoutMs = 5e3) {
20562
+ if (!interruptId) return;
20563
+ const deadline = Date.now() + timeoutMs;
20564
+ while (!signal?.aborted) {
20565
+ try {
20566
+ const state = await this.getCurrentState();
20567
+ const durable = (state?.tasks ?? []).some(
20568
+ (task) => (task.interrupts ?? []).some((interrupt5) => interrupt5.id === interruptId)
20569
+ );
20570
+ if (durable) return;
20571
+ } catch {
20572
+ }
20573
+ if (Date.now() >= deadline) {
20574
+ console.warn(
20575
+ `[Agent] interrupt ${interruptId} not durable within ${timeoutMs}ms on thread ${this.thread_id}; emitting without durable confirmation`
20576
+ );
20577
+ return;
20578
+ }
20579
+ await new Promise((resolve4) => setTimeout(resolve4, 20));
20580
+ }
20581
+ }
20547
20582
  /**
20548
20583
  * Resume LangGraph execution from the last checkpoint.
20549
20584
  *