@axiom-lattice/core 8.0.0 → 8.0.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
@@ -31313,6 +31313,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
31313
31313
  * {@link buildingKeys}.
31314
31314
  */
31315
31315
  this.buildContext = new AsyncLocalStorage();
31316
+ /**
31317
+ * Store-backed assistant ids previously reconciled per tenant. Used to
31318
+ * unregister assistants that were deleted on another replica without
31319
+ * touching built-in / plugin agents (which are re-ensured on every reload).
31320
+ */
31321
+ this.storedAssistantKeys = /* @__PURE__ */ new Map();
31316
31322
  this.subscribeToAssistantEvents();
31317
31323
  }
31318
31324
  /**
@@ -31541,11 +31547,29 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
31541
31547
  try {
31542
31548
  const storeLattice = getStoreLattice("default", "assistant");
31543
31549
  const assistants = await storeLattice.store.getAllAssistants(tenantId2);
31550
+ const currentIds = /* @__PURE__ */ new Set();
31544
31551
  for (const assistant of assistants) {
31545
- if (this.hasAgentLatticeWithTenant(tenantId2, assistant.id)) continue;
31552
+ currentIds.add(assistant.id);
31546
31553
  const config = assistantToConfig(assistant);
31547
- this.registerLatticeWithTenant(tenantId2, config);
31554
+ const existing = this.getAgentConfigWithTenant(tenantId2, assistant.id);
31555
+ if (existing === void 0) {
31556
+ this.registerLatticeWithTenant(tenantId2, config);
31557
+ continue;
31558
+ }
31559
+ if (JSON.stringify(existing) !== JSON.stringify(config)) {
31560
+ this.removeWithTenant(tenantId2, assistant.id);
31561
+ this.registerLatticeWithTenant(tenantId2, config);
31562
+ }
31563
+ }
31564
+ const previousIds = this.storedAssistantKeys.get(tenantId2);
31565
+ if (previousIds) {
31566
+ for (const id of previousIds) {
31567
+ if (!currentIds.has(id)) {
31568
+ this.removeWithTenant(tenantId2, id);
31569
+ }
31570
+ }
31548
31571
  }
31572
+ this.storedAssistantKeys.set(tenantId2, currentIds);
31549
31573
  } catch (error) {
31550
31574
  console.error(`Failed to initialize stored assistants for tenant ${tenantId2}:`, error);
31551
31575
  }