@axiom-lattice/core 8.0.0 → 8.0.2

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
@@ -2274,6 +2274,12 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
2274
2274
  * @param tenantId 租户ID
2275
2275
  */
2276
2276
  getAllAgentConfigsByTenant(tenantId: string): Promise<AgentConfig[]>;
2277
+ /**
2278
+ * Store-backed assistant ids previously reconciled per tenant. Used to
2279
+ * unregister assistants that were deleted on another replica without
2280
+ * touching built-in / plugin agents (which are re-ensured on every reload).
2281
+ */
2282
+ private storedAssistantKeys;
2277
2283
  /**
2278
2284
  * 从数据库加载指定租户的存储助手
2279
2285
  * @param tenantId 租户ID
package/dist/index.d.ts CHANGED
@@ -2274,6 +2274,12 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
2274
2274
  * @param tenantId 租户ID
2275
2275
  */
2276
2276
  getAllAgentConfigsByTenant(tenantId: string): Promise<AgentConfig[]>;
2277
+ /**
2278
+ * Store-backed assistant ids previously reconciled per tenant. Used to
2279
+ * unregister assistants that were deleted on another replica without
2280
+ * touching built-in / plugin agents (which are re-ensured on every reload).
2281
+ */
2282
+ private storedAssistantKeys;
2277
2283
  /**
2278
2284
  * 从数据库加载指定租户的存储助手
2279
2285
  * @param tenantId 租户ID
package/dist/index.js CHANGED
@@ -23902,7 +23902,7 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
23902
23902
  import_protocols13.MessageChunkTypes.THREAD_IDLE
23903
23903
  ];
23904
23904
  const typesToStop = stopTypes ?? defaultStopTypes;
23905
- let startIndex = 0;
23905
+ let startIndex = buffer2.chunks.length;
23906
23906
  for (let i = buffer2.chunks.length - 1; i >= 0; i--) {
23907
23907
  if (buffer2.chunks[i].data?.id === messageId) {
23908
23908
  startIndex = i;
@@ -33340,6 +33340,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
33340
33340
  * {@link buildingKeys}.
33341
33341
  */
33342
33342
  this.buildContext = new import_async_hooks.AsyncLocalStorage();
33343
+ /**
33344
+ * Store-backed assistant ids previously reconciled per tenant. Used to
33345
+ * unregister assistants that were deleted on another replica without
33346
+ * touching built-in / plugin agents (which are re-ensured on every reload).
33347
+ */
33348
+ this.storedAssistantKeys = /* @__PURE__ */ new Map();
33343
33349
  this.subscribeToAssistantEvents();
33344
33350
  }
33345
33351
  /**
@@ -33568,11 +33574,29 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
33568
33574
  try {
33569
33575
  const storeLattice = getStoreLattice("default", "assistant");
33570
33576
  const assistants = await storeLattice.store.getAllAssistants(tenantId2);
33577
+ const currentIds = /* @__PURE__ */ new Set();
33571
33578
  for (const assistant of assistants) {
33572
- if (this.hasAgentLatticeWithTenant(tenantId2, assistant.id)) continue;
33579
+ currentIds.add(assistant.id);
33573
33580
  const config = assistantToConfig(assistant);
33574
- this.registerLatticeWithTenant(tenantId2, config);
33581
+ const existing = this.getAgentConfigWithTenant(tenantId2, assistant.id);
33582
+ if (existing === void 0) {
33583
+ this.registerLatticeWithTenant(tenantId2, config);
33584
+ continue;
33585
+ }
33586
+ if (JSON.stringify(existing) !== JSON.stringify(config)) {
33587
+ this.removeWithTenant(tenantId2, assistant.id);
33588
+ this.registerLatticeWithTenant(tenantId2, config);
33589
+ }
33590
+ }
33591
+ const previousIds = this.storedAssistantKeys.get(tenantId2);
33592
+ if (previousIds) {
33593
+ for (const id of previousIds) {
33594
+ if (!currentIds.has(id)) {
33595
+ this.removeWithTenant(tenantId2, id);
33596
+ }
33597
+ }
33575
33598
  }
33599
+ this.storedAssistantKeys.set(tenantId2, currentIds);
33576
33600
  } catch (error) {
33577
33601
  console.error(`Failed to initialize stored assistants for tenant ${tenantId2}:`, error);
33578
33602
  }