@axlsdk/axl 0.13.8 → 0.14.0

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
@@ -4229,6 +4229,9 @@ var MemoryStore = class {
4229
4229
  const result = limit ? sorted.slice(0, limit) : sorted;
4230
4230
  return result.map((e) => structuredClone(e));
4231
4231
  }
4232
+ async deleteEvalResult(id) {
4233
+ return this.evalHistory.delete(id);
4234
+ }
4232
4235
  // ── Sessions (Studio introspection) ─────────────────────────────────
4233
4236
  async listSessions() {
4234
4237
  return [...this.sessions.keys()];
@@ -4537,6 +4540,10 @@ var SQLiteStore = class {
4537
4540
  data: safeJsonParse(r.data)
4538
4541
  }));
4539
4542
  }
4543
+ async deleteEvalResult(id) {
4544
+ const result = this.db.prepare("DELETE FROM eval_history WHERE id = ?").run(id);
4545
+ return result.changes > 0;
4546
+ }
4540
4547
  // ── Sessions (Studio introspection) ────────────────────────────────────
4541
4548
  async listSessions() {
4542
4549
  const rows = this.db.prepare("SELECT session_id FROM sessions").all();
@@ -6022,6 +6029,24 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
6022
6029
  await this.stateStore.saveEvalResult(entry);
6023
6030
  }
6024
6031
  }
6032
+ /**
6033
+ * Delete an eval history entry by id. Removes from in-memory cache and
6034
+ * the configured StateStore. Returns true if an entry was actually removed.
6035
+ *
6036
+ * Ensures lazy-loaded history is loaded first so the in-memory cache and
6037
+ * the store can't drift apart on the deletion path.
6038
+ */
6039
+ async deleteEvalResult(id) {
6040
+ await this.getEvalHistory();
6041
+ const beforeLength = this.evalHistory.length;
6042
+ this.evalHistory = this.evalHistory.filter((e) => e.id !== id);
6043
+ const removedFromMemory = this.evalHistory.length < beforeLength;
6044
+ let removedFromStore = false;
6045
+ if (this.stateStore.deleteEvalResult) {
6046
+ removedFromStore = await this.stateStore.deleteEvalResult(id);
6047
+ }
6048
+ return removedFromMemory || removedFromStore;
6049
+ }
6025
6050
  /** Get eval result history (most recent first). */
6026
6051
  async getEvalHistory() {
6027
6052
  if (!this.evalHistoryLoadPromise && this.stateStore.listEvalResults) {
@@ -6197,6 +6222,7 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
6197
6222
  parent: parentScope
6198
6223
  };
6199
6224
  const modelCalls = /* @__PURE__ */ new Map();
6225
+ const workflowCalls = /* @__PURE__ */ new Map();
6200
6226
  const tokens = { input: 0, output: 0, reasoning: 0 };
6201
6227
  let agentCalls = 0;
6202
6228
  const listener = (event) => {
@@ -6211,6 +6237,18 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
6211
6237
  tokens.reasoning += event.tokens.reasoning ?? 0;
6212
6238
  }
6213
6239
  }
6240
+ let workflowName;
6241
+ if (event.type === "workflow_start" && event.workflow) {
6242
+ workflowName = event.workflow;
6243
+ } else if (event.type === "log" && event.data && typeof event.data === "object") {
6244
+ const d = event.data;
6245
+ if (d.event === "workflow_start" && typeof d.workflow === "string") {
6246
+ workflowName = d.workflow;
6247
+ }
6248
+ }
6249
+ if (workflowName) {
6250
+ workflowCalls.set(workflowName, (workflowCalls.get(workflowName) ?? 0) + 1);
6251
+ }
6214
6252
  };
6215
6253
  this.setMaxListeners(this.getMaxListeners() + 1);
6216
6254
  this.on("trace", listener);
@@ -6223,7 +6261,9 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
6223
6261
  models: [...modelCalls.keys()],
6224
6262
  modelCallCounts: modelCalls.size > 0 ? Object.fromEntries(modelCalls) : void 0,
6225
6263
  tokens,
6226
- agentCalls
6264
+ agentCalls,
6265
+ workflows: [...workflowCalls.keys()],
6266
+ workflowCallCounts: workflowCalls.size > 0 ? Object.fromEntries(workflowCalls) : void 0
6227
6267
  }
6228
6268
  };
6229
6269
  } finally {
@@ -6501,6 +6541,11 @@ var RedisStore = class _RedisStore {
6501
6541
  entries.sort((a, b) => b.timestamp - a.timestamp);
6502
6542
  return limit ? entries.slice(0, limit) : entries;
6503
6543
  }
6544
+ async deleteEvalResult(id) {
6545
+ await this.client.sRem(this.evalHistorySetKey(), id);
6546
+ const deleted = await this.client.del(this.evalHistoryKey(id));
6547
+ return deleted > 0;
6548
+ }
6504
6549
  // ── Sessions (Studio introspection) ────────────────────────────────────
6505
6550
  async listSessions() {
6506
6551
  return this.client.sMembers("axl:session-ids");