@axlsdk/axl 0.17.3 → 0.17.4

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.cts CHANGED
@@ -2597,6 +2597,10 @@ declare class AxlRuntime extends EventEmitter {
2597
2597
  * the instance so per-event onTrace handlers don't reach into
2598
2598
  * `this.config.state` on every emission. */
2599
2599
  private readonly maxEventsPerExecution;
2600
+ /** Tracks executionIds for which we've already warned about a malformed
2601
+ * `events` field — keeps the log to one line per row instead of one per
2602
+ * rebuild tick. */
2603
+ private warnedMalformedExecutions;
2600
2604
  constructor(config?: AxlConfig);
2601
2605
  /**
2602
2606
  * Whether `config.trace.redact` is enabled on this runtime. A narrow
@@ -2717,6 +2721,14 @@ declare class AxlRuntime extends EventEmitter {
2717
2721
  captureTraces?: boolean;
2718
2722
  }): Promise<unknown>;
2719
2723
  /** Get all execution info (running + completed + historical). */
2724
+ /** Normalize an `ExecutionInfo` loaded from a `StateStore` so the
2725
+ * `events: AxlEvent[]` type contract holds for downstream consumers
2726
+ * (Studio aggregators, REST routes, redaction). Custom or legacy stores
2727
+ * may persist rows without `events` (or with a non-array value) — without
2728
+ * this guard, a single malformed row crashes every iterator over
2729
+ * `exec.events` and takes down dependent features. Mutates the row
2730
+ * in place; logs at most one warning per `executionId`. */
2731
+ private normalizeStoredExecution;
2720
2732
  getExecutions(): Promise<ExecutionInfo[]>;
2721
2733
  /**
2722
2734
  * Create a WorkflowContext for ad-hoc use (evals, tool testing, prototyping).
package/dist/index.d.ts CHANGED
@@ -2597,6 +2597,10 @@ declare class AxlRuntime extends EventEmitter {
2597
2597
  * the instance so per-event onTrace handlers don't reach into
2598
2598
  * `this.config.state` on every emission. */
2599
2599
  private readonly maxEventsPerExecution;
2600
+ /** Tracks executionIds for which we've already warned about a malformed
2601
+ * `events` field — keeps the log to one line per row instead of one per
2602
+ * rebuild tick. */
2603
+ private warnedMalformedExecutions;
2600
2604
  constructor(config?: AxlConfig);
2601
2605
  /**
2602
2606
  * Whether `config.trace.redact` is enabled on this runtime. A narrow
@@ -2717,6 +2721,14 @@ declare class AxlRuntime extends EventEmitter {
2717
2721
  captureTraces?: boolean;
2718
2722
  }): Promise<unknown>;
2719
2723
  /** Get all execution info (running + completed + historical). */
2724
+ /** Normalize an `ExecutionInfo` loaded from a `StateStore` so the
2725
+ * `events: AxlEvent[]` type contract holds for downstream consumers
2726
+ * (Studio aggregators, REST routes, redaction). Custom or legacy stores
2727
+ * may persist rows without `events` (or with a non-array value) — without
2728
+ * this guard, a single malformed row crashes every iterator over
2729
+ * `exec.events` and takes down dependent features. Mutates the row
2730
+ * in place; logs at most one warning per `executionId`. */
2731
+ private normalizeStoredExecution;
2720
2732
  getExecutions(): Promise<ExecutionInfo[]>;
2721
2733
  /**
2722
2734
  * Create a WorkflowContext for ad-hoc use (evals, tool testing, prototyping).
package/dist/index.js CHANGED
@@ -7485,6 +7485,10 @@ var AxlRuntime = class extends EventEmitter2 {
7485
7485
  * the instance so per-event onTrace handlers don't reach into
7486
7486
  * `this.config.state` on every emission. */
7487
7487
  maxEventsPerExecution;
7488
+ /** Tracks executionIds for which we've already warned about a malformed
7489
+ * `events` field — keeps the log to one line per row instead of one per
7490
+ * rebuild tick. */
7491
+ warnedMalformedExecutions = /* @__PURE__ */ new Set();
7488
7492
  constructor(config) {
7489
7493
  super();
7490
7494
  this.config = resolveConfig(config ?? {});
@@ -7778,12 +7782,31 @@ var AxlRuntime = class extends EventEmitter2 {
7778
7782
  return result;
7779
7783
  }
7780
7784
  /** Get all execution info (running + completed + historical). */
7785
+ /** Normalize an `ExecutionInfo` loaded from a `StateStore` so the
7786
+ * `events: AxlEvent[]` type contract holds for downstream consumers
7787
+ * (Studio aggregators, REST routes, redaction). Custom or legacy stores
7788
+ * may persist rows without `events` (or with a non-array value) — without
7789
+ * this guard, a single malformed row crashes every iterator over
7790
+ * `exec.events` and takes down dependent features. Mutates the row
7791
+ * in place; logs at most one warning per `executionId`. */
7792
+ normalizeStoredExecution(exec) {
7793
+ if (!Array.isArray(exec.events)) {
7794
+ if (!this.warnedMalformedExecutions.has(exec.executionId)) {
7795
+ this.warnedMalformedExecutions.add(exec.executionId);
7796
+ console.warn(
7797
+ `[axl] StateStore returned execution ${exec.executionId} with non-array events (got ${exec.events === null ? "null" : typeof exec.events}); coercing to []`
7798
+ );
7799
+ }
7800
+ exec.events = [];
7801
+ }
7802
+ return exec;
7803
+ }
7781
7804
  async getExecutions() {
7782
7805
  if (!this.historicalExecutionsLoadPromise && this.stateStore.listExecutions) {
7783
7806
  this.historicalExecutionsLoadPromise = this.stateStore.listExecutions().then((stored) => {
7784
7807
  for (const exec of stored) {
7785
7808
  if (!this.executions.has(exec.executionId) && !this.historicalExecutions.has(exec.executionId)) {
7786
- this.historicalExecutions.set(exec.executionId, exec);
7809
+ this.historicalExecutions.set(exec.executionId, this.normalizeStoredExecution(exec));
7787
7810
  }
7788
7811
  }
7789
7812
  }).catch(() => {
@@ -8154,8 +8177,9 @@ var AxlRuntime = class extends EventEmitter2 {
8154
8177
  if (this.stateStore.getExecution) {
8155
8178
  const stored = await this.stateStore.getExecution(executionId);
8156
8179
  if (stored) {
8157
- this.historicalExecutions.set(executionId, stored);
8158
- return stored;
8180
+ const normalized = this.normalizeStoredExecution(stored);
8181
+ this.historicalExecutions.set(executionId, normalized);
8182
+ return normalized;
8159
8183
  }
8160
8184
  }
8161
8185
  return void 0;