agentlife 2.4.5 → 2.4.6

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1550,6 +1550,15 @@ function recordSurfaceEvent(state, surfaceId, event, dsl, agentId, metadata) {
1550
1550
  console.warn("[agentlife] failed to record surface event:", err?.message);
1551
1551
  }
1552
1552
  }
1553
+ function purgeSurfaceHistory(state, surfaceId) {
1554
+ try {
1555
+ const db = getOrCreateHistoryDb(state);
1556
+ db.prepare("DELETE FROM surface_events WHERE surfaceId = ?").run(surfaceId);
1557
+ db.prepare("DELETE FROM surface_usage WHERE surfaceId = ?").run(surfaceId);
1558
+ } catch (err) {
1559
+ console.warn("[agentlife] failed to purge surface history:", err?.message);
1560
+ }
1561
+ }
1553
1562
  function recordActivity(state, event, sessionKey, agentId, opts) {
1554
1563
  try {
1555
1564
  getOrCreateHistoryDb(state).prepare("INSERT INTO activity_log (ts,sessionKey,agentId,event,toolName,summary,data,runId) VALUES (?,?,?,?,?,?,?,?)").run(Date.now(), sessionKey ?? null, agentId ?? null, event, opts?.toolName ?? null, opts?.summary ?? null, opts?.data ?? null, opts?.runId ?? null);
@@ -2507,7 +2516,7 @@ function processDslBlock(state, dsl) {
2507
2516
  const sid2 = firstLine.slice(7).trim();
2508
2517
  if (sid2) {
2509
2518
  state.surfaceDb.delete(sid2);
2510
- recordSurfaceEvent(state, sid2, "deleted");
2519
+ purgeSurfaceHistory(state, sid2);
2511
2520
  results.push({ surfaceId: sid2, isNew: false, followupChanged: false, followupRemoved: false, stateTransition: null });
2512
2521
  }
2513
2522
  continue;
@@ -2671,7 +2680,7 @@ function sweepExpired(state) {
2671
2680
  for (const [surfaceId, meta] of state.surfaceDb.entries()) {
2672
2681
  if (isPastGrace(meta, now)) {
2673
2682
  state.surfaceDb.delete(surfaceId);
2674
- recordSurfaceEvent(state, surfaceId, "expired");
2683
+ purgeSurfaceHistory(state, surfaceId);
2675
2684
  removeFollowup(state, surfaceId);
2676
2685
  purgedIds.push(surfaceId);
2677
2686
  } else if (isExpired(meta, now) && !meta.expiredSince) {
@@ -2797,6 +2806,7 @@ function deleteWelcomeWidget(state, log) {
2797
2806
  for (const id of [WELCOME_SURFACE_ID, WELCOME_INPUT_SURFACE_ID]) {
2798
2807
  if (state.surfaceDb?.has(id)) {
2799
2808
  state.surfaceDb.delete(id);
2809
+ purgeSurfaceHistory(state, id);
2800
2810
  broadcastDelete(id);
2801
2811
  log(`[render-widgets] deleted ${id}`);
2802
2812
  }
@@ -2916,6 +2926,7 @@ function registerSurfacesService(api, state) {
2916
2926
  if (onboarding)
2917
2927
  continue;
2918
2928
  state.surfaceDb.delete(surfaceId);
2929
+ purgeSurfaceHistory(state, surfaceId);
2919
2930
  inputPurged++;
2920
2931
  }
2921
2932
  if (inputPurged > 0) {
@@ -3229,6 +3240,7 @@ async function cleanupSupervisorLegacyState(state) {
3229
3240
  if (state.surfaceDb?.has(STALE_SUPERVISOR_SURFACE)) {
3230
3241
  removeFollowup(state, STALE_SUPERVISOR_SURFACE);
3231
3242
  state.surfaceDb.delete(STALE_SUPERVISOR_SURFACE);
3243
+ purgeSurfaceHistory(state, STALE_SUPERVISOR_SURFACE);
3232
3244
  broadcastDelete(STALE_SUPERVISOR_SURFACE);
3233
3245
  actions.push(`deleted surface ${STALE_SUPERVISOR_SURFACE} + cancelled followup`);
3234
3246
  }
@@ -3565,7 +3577,6 @@ function notifyWidgetEvent(_state, event, surfaceId, title, body) {
3565
3577
  // hooks/activity-hooks.ts
3566
3578
  var sessionContext = new Map;
3567
3579
  var pendingSnapshots = new Map;
3568
- var lastRetry = new Map;
3569
3580
  var agentHealth = new Map;
3570
3581
  var lastGlobalSupervisorRun = 0;
3571
3582
  var PATHOLOGY = process.env.PATHOLOGY_TEST_MODE === "1";
@@ -4159,10 +4170,6 @@ function processPendingQualityChecks(state) {
4159
4170
  processed++;
4160
4171
  if (isTerminal)
4161
4172
  continue;
4162
- const cooldownMs = 5 * 60 * 1000;
4163
- const lastRetryTime = lastRetry.get(row.agentId) ?? 0;
4164
- if (now - lastRetryTime < cooldownMs)
4165
- continue;
4166
4173
  const pushed = db.prepare("SELECT COUNT(*) as c FROM surface_events WHERE event IN ('created','updated') AND createdAt > ? AND (agentId = ? OR agentId IS NULL)").get(row.runStart, row.agentId);
4167
4174
  if ((pushed?.c ?? 0) > 0)
4168
4175
  continue;
@@ -4170,16 +4177,7 @@ function processPendingQualityChecks(state) {
4170
4177
  runId: row.runId,
4171
4178
  data: JSON.stringify({ issue: "no_widget_pushed", trigger: row.trigger })
4172
4179
  });
4173
- console.log("[agentlife:quality] %s ended without pushing a widget sending retry (cooldown 5m)", row.agentId);
4174
- lastRetry.set(row.agentId, now);
4175
- if (state.runCommand) {
4176
- const chatParams = JSON.stringify({
4177
- sessionKey: row.sessionKey,
4178
- message: "[system] Quality: you received a user request but did not push a widget. Chat text is invisible to the user. Push the appropriate widget now.",
4179
- idempotencyKey: `retry-${row.runId ?? now}`
4180
- });
4181
- state.runCommand(["openclaw", "gateway", "call", "chat.send", "--params", chatParams], { timeoutMs: 30000 }).then((r) => console.log("[agentlife:quality] retry sent: code=%s", r?.code ?? "?")).catch((e) => console.warn("[agentlife:quality] retry send failed:", e?.message));
4182
- }
4180
+ console.log("[agentlife:quality] %s ended without pushing a widget (warning only; no auto-retry)", row.agentId);
4183
4181
  } catch (e) {
4184
4182
  console.warn("[agentlife:quality] pending check row %d failed: %s", row.id, e?.message);
4185
4183
  try {
@@ -6731,6 +6729,7 @@ function registerSurfacesGateway(api, state2) {
6731
6729
  } catch {}
6732
6730
  guidedDismissSent.delete(surfaceId);
6733
6731
  state2.surfaceDb.delete(surfaceId);
6732
+ purgeSurfaceHistory(state2, surfaceId);
6734
6733
  broadcastDelete(surfaceId);
6735
6734
  try {
6736
6735
  enqueueCleanupTasks(state2, surfaceId, agentId, cronId, automations);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlife",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "bun build index.ts --outfile dist/index.js --target node --external openclaw/plugin-sdk",