@axiom-lattice/core 4.2.6 → 4.2.8

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
@@ -222,22 +222,22 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
222
222
  * @param key Lattice键名
223
223
  * @param config 模型配置
224
224
  */
225
- registerLattice(key4, config) {
225
+ registerLattice(key5, config) {
226
226
  const client = new ModelLattice(config);
227
227
  const modelLattice = {
228
- key: key4,
228
+ key: key5,
229
229
  client
230
230
  };
231
- this.register(key4, modelLattice);
231
+ this.register(key5, modelLattice);
232
232
  }
233
233
  /**
234
234
  * 获取ModelLattice
235
235
  * @param key Lattice键名
236
236
  */
237
- getModelLattice(key4) {
238
- const modelLattice = this.get(key4);
237
+ getModelLattice(key5) {
238
+ const modelLattice = this.get(key5);
239
239
  if (!modelLattice) {
240
- throw new Error(`ModelLattice ${key4} not found`);
240
+ throw new Error(`ModelLattice ${key5} not found`);
241
241
  }
242
242
  return modelLattice;
243
243
  }
@@ -251,15 +251,15 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
251
251
  * 检查Lattice是否存在
252
252
  * @param key Lattice键名
253
253
  */
254
- hasLattice(key4) {
255
- return this.has(key4);
254
+ hasLattice(key5) {
255
+ return this.has(key5);
256
256
  }
257
257
  /**
258
258
  * 移除Lattice
259
259
  * @param key Lattice键名
260
260
  */
261
- removeLattice(key4) {
262
- return this.remove(key4);
261
+ removeLattice(key5) {
262
+ return this.remove(key5);
263
263
  }
264
264
  /**
265
265
  * 清空所有Lattice
@@ -281,8 +281,8 @@ var ModelLatticeManager = class _ModelLatticeManager extends BaseLatticeManager
281
281
  }
282
282
  };
283
283
  var modelLatticeManager = ModelLatticeManager.getInstance();
284
- var registerModelLattice = (key4, config) => modelLatticeManager.registerLattice(key4, config);
285
- var getModelLattice = (key4) => modelLatticeManager.getModelLattice(key4);
284
+ var registerModelLattice = (key5, config) => modelLatticeManager.registerLattice(key5, config);
285
+ var getModelLattice = (key5) => modelLatticeManager.getModelLattice(key5);
286
286
 
287
287
  // src/tool_lattice/get_current_date_time/index.ts
288
288
  import z from "zod";
@@ -347,7 +347,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
347
347
  * @param config 工具配置(定义)
348
348
  * @param executor 工具执行函数
349
349
  */
350
- registerLattice(key4, config, executor) {
350
+ registerLattice(key5, config, executor) {
351
351
  let toolExecutor;
352
352
  if (config.needUserApprove) {
353
353
  toolExecutor = createToolApproveWrapper(
@@ -361,18 +361,18 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
361
361
  };
362
362
  }
363
363
  const toolLattice = {
364
- key: key4,
364
+ key: key5,
365
365
  config,
366
366
  client: tool(toolExecutor, config)
367
367
  };
368
- this.register(key4, toolLattice);
368
+ this.register(key5, toolLattice);
369
369
  }
370
370
  /**
371
371
  * 获取ToolLattice
372
372
  * @param key Lattice键名
373
373
  */
374
- getToolLattice(key4) {
375
- return this.get(key4);
374
+ getToolLattice(key5) {
375
+ return this.get(key5);
376
376
  }
377
377
  /**
378
378
  * 获取所有Lattice
@@ -384,15 +384,15 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
384
384
  * 检查Lattice是否存在
385
385
  * @param key Lattice键名
386
386
  */
387
- hasLattice(key4) {
388
- return this.has(key4);
387
+ hasLattice(key5) {
388
+ return this.has(key5);
389
389
  }
390
390
  /**
391
391
  * 移除Lattice
392
392
  * @param key Lattice键名
393
393
  */
394
- removeLattice(key4) {
395
- return this.remove(key4);
394
+ removeLattice(key5) {
395
+ return this.remove(key5);
396
396
  }
397
397
  /**
398
398
  * 清空所有Lattice
@@ -416,10 +416,10 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
416
416
  * 获取工具定义
417
417
  * @param key Lattice键名
418
418
  */
419
- getToolDefinition(key4) {
420
- const toolLattice = this.getToolLattice(key4);
419
+ getToolDefinition(key5) {
420
+ const toolLattice = this.getToolLattice(key5);
421
421
  if (!toolLattice) {
422
- throw new Error(`ToolLattice ${key4} not found`);
422
+ throw new Error(`ToolLattice ${key5} not found`);
423
423
  }
424
424
  return toolLattice.config;
425
425
  }
@@ -427,10 +427,10 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
427
427
  * 获取工具客户端
428
428
  * @param key Lattice键名
429
429
  */
430
- getToolClient(key4) {
431
- const toolLattice = this.getToolLattice(key4);
430
+ getToolClient(key5) {
431
+ const toolLattice = this.getToolLattice(key5);
432
432
  if (!toolLattice) {
433
- throw new Error(`ToolLattice ${key4} not found`);
433
+ throw new Error(`ToolLattice ${key5} not found`);
434
434
  }
435
435
  return toolLattice.client;
436
436
  }
@@ -445,7 +445,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
445
445
  * @param key Lattice键名
446
446
  * @param tool 已有的StructuredTool实例
447
447
  */
448
- registerExistingTool(key4, tool69) {
448
+ registerExistingTool(key5, tool69) {
449
449
  const config = {
450
450
  name: tool69.name,
451
451
  description: tool69.description,
@@ -455,19 +455,19 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
455
455
  // MCP工具默认不需要用户批准
456
456
  };
457
457
  const toolLattice = {
458
- key: key4,
458
+ key: key5,
459
459
  config,
460
460
  client: tool69
461
461
  };
462
- this.register(key4, toolLattice);
462
+ this.register(key5, toolLattice);
463
463
  }
464
464
  /**
465
465
  * 验证工具输入参数
466
466
  * @param key Lattice键名
467
467
  * @param input 输入参数
468
468
  */
469
- validateToolInput(key4, input) {
470
- const toolLattice = this.getToolLattice(key4);
469
+ validateToolInput(key5, input) {
470
+ const toolLattice = this.getToolLattice(key5);
471
471
  if (!toolLattice) {
472
472
  return false;
473
473
  }
@@ -482,13 +482,13 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
482
482
  }
483
483
  };
484
484
  var toolLatticeManager = ToolLatticeManager.getInstance();
485
- var registerToolLattice = (key4, config, executor) => toolLatticeManager.registerLattice(key4, config, executor);
486
- var registerExistingTool = (key4, tool69) => toolLatticeManager.registerExistingTool(key4, tool69);
487
- var getToolLattice = (key4) => toolLatticeManager.getToolLattice(key4);
488
- var getToolDefinition = (key4) => toolLatticeManager.getToolDefinition(key4);
489
- var getToolClient = (key4) => toolLatticeManager.getToolClient(key4);
485
+ var registerToolLattice = (key5, config, executor) => toolLatticeManager.registerLattice(key5, config, executor);
486
+ var registerExistingTool = (key5, tool69) => toolLatticeManager.registerExistingTool(key5, tool69);
487
+ var getToolLattice = (key5) => toolLatticeManager.getToolLattice(key5);
488
+ var getToolDefinition = (key5) => toolLatticeManager.getToolDefinition(key5);
489
+ var getToolClient = (key5) => toolLatticeManager.getToolClient(key5);
490
490
  var getAllToolDefinitions = () => toolLatticeManager.getAllToolDefinitions();
491
- var validateToolInput = (key4, input) => toolLatticeManager.validateToolInput(key4, input);
491
+ var validateToolInput = (key5, input) => toolLatticeManager.validateToolInput(key5, input);
492
492
 
493
493
  // src/tool_lattice/get_current_date_time/index.ts
494
494
  registerToolLattice(
@@ -590,7 +590,7 @@ var InMemoryThreadStore = class {
590
590
  if (metadataFilter && Object.keys(metadataFilter).length > 0) {
591
591
  threads = threads.filter(
592
592
  (thread) => Object.entries(metadataFilter).every(
593
- ([key4, value]) => thread.metadata?.[key4] === value
593
+ ([key5, value]) => thread.metadata?.[key5] === value
594
594
  )
595
595
  );
596
596
  }
@@ -878,7 +878,7 @@ function parseFrontmatter(content) {
878
878
  if (currentKey === "metadata" && indent > metadataIndent) {
879
879
  const colonIndex2 = trimmed.indexOf(":");
880
880
  if (colonIndex2 !== -1) {
881
- const key5 = trimmed.substring(0, colonIndex2).trim();
881
+ const key6 = trimmed.substring(0, colonIndex2).trim();
882
882
  let value2 = trimmed.substring(colonIndex2 + 1).trim();
883
883
  if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
884
884
  value2 = value2.slice(1, -1);
@@ -886,7 +886,7 @@ function parseFrontmatter(content) {
886
886
  if (!frontmatter.metadata) {
887
887
  frontmatter.metadata = {};
888
888
  }
889
- frontmatter.metadata[key5] = value2;
889
+ frontmatter.metadata[key6] = value2;
890
890
  }
891
891
  continue;
892
892
  }
@@ -911,12 +911,12 @@ function parseFrontmatter(content) {
911
911
  if (colonIndex === -1) {
912
912
  continue;
913
913
  }
914
- const key4 = trimmed.substring(0, colonIndex).trim();
914
+ const key5 = trimmed.substring(0, colonIndex).trim();
915
915
  let value = trimmed.substring(colonIndex + 1).trim();
916
916
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
917
917
  value = value.slice(1, -1);
918
918
  }
919
- if (key4 === "metadata") {
919
+ if (key5 === "metadata") {
920
920
  if (value === "" || value === "{}") {
921
921
  if (i + 1 < lines.length) {
922
922
  const nextLine = lines[i + 1];
@@ -928,17 +928,17 @@ function parseFrontmatter(content) {
928
928
  continue;
929
929
  }
930
930
  }
931
- frontmatter[key4] = {};
931
+ frontmatter[key5] = {};
932
932
  } else if (value.startsWith("{")) {
933
933
  try {
934
- frontmatter[key4] = JSON.parse(value);
934
+ frontmatter[key5] = JSON.parse(value);
935
935
  } catch {
936
- frontmatter[key4] = {};
936
+ frontmatter[key5] = {};
937
937
  }
938
938
  } else {
939
- frontmatter[key4] = {};
939
+ frontmatter[key5] = {};
940
940
  }
941
- } else if (key4 === "subSkills") {
941
+ } else if (key5 === "subSkills") {
942
942
  if (value === "" || value === "[]") {
943
943
  if (i + 1 < lines.length) {
944
944
  const nextLine = lines[i + 1];
@@ -950,18 +950,18 @@ function parseFrontmatter(content) {
950
950
  continue;
951
951
  }
952
952
  }
953
- frontmatter[key4] = [];
953
+ frontmatter[key5] = [];
954
954
  } else if (value.startsWith("[")) {
955
955
  try {
956
- frontmatter[key4] = JSON.parse(value);
956
+ frontmatter[key5] = JSON.parse(value);
957
957
  } catch {
958
- frontmatter[key4] = [];
958
+ frontmatter[key5] = [];
959
959
  }
960
960
  } else {
961
- frontmatter[key4] = [];
961
+ frontmatter[key5] = [];
962
962
  }
963
963
  } else {
964
- frontmatter[key4] = value;
964
+ frontmatter[key5] = value;
965
965
  }
966
966
  }
967
967
  return { frontmatter, body };
@@ -978,8 +978,8 @@ function generateFrontmatter(data) {
978
978
  }
979
979
  if (data.metadata && Object.keys(data.metadata).length > 0) {
980
980
  lines.push("metadata:");
981
- for (const [key4, value] of Object.entries(data.metadata)) {
982
- lines.push(` ${key4}: ${value}`);
981
+ for (const [key5, value] of Object.entries(data.metadata)) {
982
+ lines.push(` ${key5}: ${value}`);
983
983
  }
984
984
  }
985
985
  if (data.subSkills && data.subSkills.length > 0) {
@@ -1423,8 +1423,8 @@ var InMemoryWorkspaceStore = class {
1423
1423
  );
1424
1424
  }
1425
1425
  async getWorkspaceById(tenantId2, id) {
1426
- const key4 = this.getKey(tenantId2, id);
1427
- return this.workspaces.get(key4) || null;
1426
+ const key5 = this.getKey(tenantId2, id);
1427
+ return this.workspaces.get(key5) || null;
1428
1428
  }
1429
1429
  async createWorkspace(tenantId2, id, data) {
1430
1430
  const now = /* @__PURE__ */ new Date();
@@ -1437,13 +1437,13 @@ var InMemoryWorkspaceStore = class {
1437
1437
  createdAt: now,
1438
1438
  updatedAt: now
1439
1439
  };
1440
- const key4 = this.getKey(tenantId2, id);
1441
- this.workspaces.set(key4, workspace);
1440
+ const key5 = this.getKey(tenantId2, id);
1441
+ this.workspaces.set(key5, workspace);
1442
1442
  return workspace;
1443
1443
  }
1444
1444
  async updateWorkspace(tenantId2, id, updates) {
1445
- const key4 = this.getKey(tenantId2, id);
1446
- const existing = this.workspaces.get(key4);
1445
+ const key5 = this.getKey(tenantId2, id);
1446
+ const existing = this.workspaces.get(key5);
1447
1447
  if (!existing) {
1448
1448
  return null;
1449
1449
  }
@@ -1452,12 +1452,12 @@ var InMemoryWorkspaceStore = class {
1452
1452
  ...updates,
1453
1453
  updatedAt: /* @__PURE__ */ new Date()
1454
1454
  };
1455
- this.workspaces.set(key4, updated);
1455
+ this.workspaces.set(key5, updated);
1456
1456
  return updated;
1457
1457
  }
1458
1458
  async deleteWorkspace(tenantId2, id) {
1459
- const key4 = this.getKey(tenantId2, id);
1460
- return this.workspaces.delete(key4);
1459
+ const key5 = this.getKey(tenantId2, id);
1460
+ return this.workspaces.delete(key5);
1461
1461
  }
1462
1462
  clear() {
1463
1463
  this.workspaces.clear();
@@ -1493,15 +1493,15 @@ var InMemoryCapabilityBundleCoordinator = class {
1493
1493
  }
1494
1494
  /** Records a tenant Bundle as present. */
1495
1495
  add(tenantId2, bundleId, revision = "") {
1496
- const key4 = this.key(tenantId2, bundleId);
1497
- this.bundleKeys.add(key4);
1498
- this.revisions.set(key4, revision);
1496
+ const key5 = this.key(tenantId2, bundleId);
1497
+ this.bundleKeys.add(key5);
1498
+ this.revisions.set(key5, revision);
1499
1499
  }
1500
1500
  /** Removes a tenant Bundle. */
1501
1501
  remove(tenantId2, bundleId) {
1502
- const key4 = this.key(tenantId2, bundleId);
1503
- this.bundleKeys.delete(key4);
1504
- this.revisions.delete(key4);
1502
+ const key5 = this.key(tenantId2, bundleId);
1503
+ this.bundleKeys.delete(key5);
1504
+ this.revisions.delete(key5);
1505
1505
  }
1506
1506
  /** Checks all requested Bundle IDs without yielding to another operation. */
1507
1507
  hasAll(tenantId2, bundleIds) {
@@ -1549,15 +1549,15 @@ var InMemoryProjectStore = class {
1549
1549
  );
1550
1550
  }
1551
1551
  async getProjectById(tenantId2, id) {
1552
- const key4 = this.getKey(tenantId2, id);
1553
- return this.projects.get(key4) || null;
1552
+ const key5 = this.getKey(tenantId2, id);
1553
+ return this.projects.get(key5) || null;
1554
1554
  }
1555
1555
  async createProject(tenantId2, workspaceId, id, data) {
1556
1556
  assertGenericProjectConfig(data.config);
1557
1557
  return this.capabilityBundles.runProjectUpdate(tenantId2, id, () => {
1558
1558
  const now = /* @__PURE__ */ new Date();
1559
- const key4 = this.getKey(tenantId2, id);
1560
- const existing = this.projects.get(key4);
1559
+ const key5 = this.getKey(tenantId2, id);
1560
+ const existing = this.projects.get(key5);
1561
1561
  const capabilityBundleIds = existing?.config && Object.prototype.hasOwnProperty.call(existing.config, "capabilityBundleIds") ? { capabilityBundleIds: existing.config.capabilityBundleIds } : {};
1562
1562
  const project = {
1563
1563
  id,
@@ -1569,7 +1569,7 @@ var InMemoryProjectStore = class {
1569
1569
  createdAt: existing?.createdAt ?? now,
1570
1570
  updatedAt: now
1571
1571
  };
1572
- this.projects.set(key4, project);
1572
+ this.projects.set(key5, project);
1573
1573
  return project;
1574
1574
  });
1575
1575
  }
@@ -1583,8 +1583,8 @@ var InMemoryProjectStore = class {
1583
1583
  async updateProject(tenantId2, id, updates) {
1584
1584
  assertGenericProjectConfig(updates.config);
1585
1585
  return this.capabilityBundles.runProjectUpdate(tenantId2, id, () => {
1586
- const key4 = this.getKey(tenantId2, id);
1587
- const existing = this.projects.get(key4);
1586
+ const key5 = this.getKey(tenantId2, id);
1587
+ const existing = this.projects.get(key5);
1588
1588
  if (!existing) return null;
1589
1589
  const updated = {
1590
1590
  ...existing,
@@ -1592,26 +1592,26 @@ var InMemoryProjectStore = class {
1592
1592
  ...updates.config === void 0 ? {} : { config: { ...updates.config, ...Object.prototype.hasOwnProperty.call(existing.config ?? {}, "capabilityBundleIds") ? { capabilityBundleIds: existing.config?.capabilityBundleIds } : {} } },
1593
1593
  updatedAt: /* @__PURE__ */ new Date()
1594
1594
  };
1595
- this.projects.set(key4, updated);
1595
+ this.projects.set(key5, updated);
1596
1596
  return updated;
1597
1597
  });
1598
1598
  }
1599
1599
  async deleteProject(tenantId2, id) {
1600
1600
  return this.capabilityBundles.runProjectUpdate(tenantId2, id, () => {
1601
- const key4 = this.getKey(tenantId2, id);
1602
- return this.projects.delete(key4);
1601
+ const key5 = this.getKey(tenantId2, id);
1602
+ return this.projects.delete(key5);
1603
1603
  });
1604
1604
  }
1605
1605
  async updateCapabilityBundleIds(tenantId2, projectId, bundleIds, expectedRevisions = {}) {
1606
1606
  return this.capabilityBundles.runProjectUpdate(tenantId2, projectId, () => {
1607
- const key4 = this.getKey(tenantId2, projectId);
1608
- const existing = this.projects.get(key4);
1607
+ const key5 = this.getKey(tenantId2, projectId);
1608
+ const existing = this.projects.get(key5);
1609
1609
  if (!existing) return { status: "project_not_found" };
1610
1610
  if (!this.capabilityBundles.hasAll(tenantId2, bundleIds)) return { status: "bundle_not_found" };
1611
1611
  if (!this.capabilityBundles.hasAllAtRevisions(tenantId2, bundleIds, expectedRevisions)) return { status: "bundle_conflict" };
1612
1612
  const config = existing.config && typeof existing.config === "object" && !Array.isArray(existing.config) ? existing.config : {};
1613
1613
  const updated = { ...existing, config: { ...config, capabilityBundleIds: [...bundleIds] }, updatedAt: /* @__PURE__ */ new Date() };
1614
- this.projects.set(key4, updated);
1614
+ this.projects.set(key5, updated);
1615
1615
  return { status: "updated", project: updated };
1616
1616
  });
1617
1617
  }
@@ -1660,15 +1660,15 @@ var InMemoryDatabaseConfigStore = class {
1660
1660
  * Get database configuration by ID
1661
1661
  */
1662
1662
  async getConfigById(tenantId2, id) {
1663
- const key4 = this.getKey(tenantId2, id);
1664
- return this.configs.get(key4) || null;
1663
+ const key5 = this.getKey(tenantId2, id);
1664
+ return this.configs.get(key5) || null;
1665
1665
  }
1666
1666
  /**
1667
1667
  * Get database configuration by business key
1668
1668
  */
1669
- async getConfigByKey(tenantId2, key4) {
1669
+ async getConfigByKey(tenantId2, key5) {
1670
1670
  const configs = await this.getAllConfigs(tenantId2);
1671
- return configs.find((config) => config.key === key4) || null;
1671
+ return configs.find((config) => config.key === key5) || null;
1672
1672
  }
1673
1673
  /**
1674
1674
  * Create a new database configuration
@@ -1693,8 +1693,8 @@ var InMemoryDatabaseConfigStore = class {
1693
1693
  * Update an existing database configuration
1694
1694
  */
1695
1695
  async updateConfig(tenantId2, id, updates) {
1696
- const key4 = this.getKey(tenantId2, id);
1697
- const existing = this.configs.get(key4);
1696
+ const key5 = this.getKey(tenantId2, id);
1697
+ const existing = this.configs.get(key5);
1698
1698
  if (!existing) {
1699
1699
  return null;
1700
1700
  }
@@ -1707,22 +1707,22 @@ var InMemoryDatabaseConfigStore = class {
1707
1707
  description: updates.description !== void 0 ? updates.description : existing.description,
1708
1708
  updatedAt: /* @__PURE__ */ new Date()
1709
1709
  };
1710
- this.configs.set(key4, updated);
1710
+ this.configs.set(key5, updated);
1711
1711
  return updated;
1712
1712
  }
1713
1713
  /**
1714
1714
  * Delete a database configuration by ID
1715
1715
  */
1716
1716
  async deleteConfig(tenantId2, id) {
1717
- const key4 = this.getKey(tenantId2, id);
1718
- return this.configs.delete(key4);
1717
+ const key5 = this.getKey(tenantId2, id);
1718
+ return this.configs.delete(key5);
1719
1719
  }
1720
1720
  /**
1721
1721
  * Check if configuration exists
1722
1722
  */
1723
1723
  async hasConfig(tenantId2, id) {
1724
- const key4 = this.getKey(tenantId2, id);
1725
- return this.configs.has(key4);
1724
+ const key5 = this.getKey(tenantId2, id);
1725
+ return this.configs.has(key5);
1726
1726
  }
1727
1727
  /**
1728
1728
  * Clear all configurations (useful for testing)
@@ -1734,9 +1734,9 @@ var InMemoryDatabaseConfigStore = class {
1734
1734
  * Clear configurations for a specific tenant
1735
1735
  */
1736
1736
  clearByTenant(tenantId2) {
1737
- for (const key4 of this.configs.keys()) {
1738
- if (key4.startsWith(`${tenantId2}:`)) {
1739
- this.configs.delete(key4);
1737
+ for (const key5 of this.configs.keys()) {
1738
+ if (key5.startsWith(`${tenantId2}:`)) {
1739
+ this.configs.delete(key5);
1740
1740
  }
1741
1741
  }
1742
1742
  }
@@ -1771,15 +1771,15 @@ var InMemoryMetricsServerConfigStore = class {
1771
1771
  * Get metrics server configuration by ID
1772
1772
  */
1773
1773
  async getConfigById(tenantId2, id) {
1774
- const key4 = this.getKey(tenantId2, id);
1775
- return this.configs.get(key4) || null;
1774
+ const key5 = this.getKey(tenantId2, id);
1775
+ return this.configs.get(key5) || null;
1776
1776
  }
1777
1777
  /**
1778
1778
  * Get metrics server configuration by business key
1779
1779
  */
1780
- async getConfigByKey(tenantId2, key4) {
1780
+ async getConfigByKey(tenantId2, key5) {
1781
1781
  const configs = await this.getAllConfigs(tenantId2);
1782
- return configs.find((config) => config.key === key4) || null;
1782
+ return configs.find((config) => config.key === key5) || null;
1783
1783
  }
1784
1784
  /**
1785
1785
  * Create a new metrics server configuration
@@ -1804,8 +1804,8 @@ var InMemoryMetricsServerConfigStore = class {
1804
1804
  * Update an existing metrics server configuration
1805
1805
  */
1806
1806
  async updateConfig(tenantId2, id, updates) {
1807
- const key4 = this.getKey(tenantId2, id);
1808
- const existing = this.configs.get(key4);
1807
+ const key5 = this.getKey(tenantId2, id);
1808
+ const existing = this.configs.get(key5);
1809
1809
  if (!existing) {
1810
1810
  return null;
1811
1811
  }
@@ -1818,22 +1818,22 @@ var InMemoryMetricsServerConfigStore = class {
1818
1818
  description: updates.description !== void 0 ? updates.description : existing.description,
1819
1819
  updatedAt: /* @__PURE__ */ new Date()
1820
1820
  };
1821
- this.configs.set(key4, updated);
1821
+ this.configs.set(key5, updated);
1822
1822
  return updated;
1823
1823
  }
1824
1824
  /**
1825
1825
  * Delete a metrics server configuration by ID
1826
1826
  */
1827
1827
  async deleteConfig(tenantId2, id) {
1828
- const key4 = this.getKey(tenantId2, id);
1829
- return this.configs.delete(key4);
1828
+ const key5 = this.getKey(tenantId2, id);
1829
+ return this.configs.delete(key5);
1830
1830
  }
1831
1831
  /**
1832
1832
  * Check if configuration exists
1833
1833
  */
1834
1834
  async hasConfig(tenantId2, id) {
1835
- const key4 = this.getKey(tenantId2, id);
1836
- return this.configs.has(key4);
1835
+ const key5 = this.getKey(tenantId2, id);
1836
+ return this.configs.has(key5);
1837
1837
  }
1838
1838
  /**
1839
1839
  * Clear all configurations (useful for testing)
@@ -1845,9 +1845,9 @@ var InMemoryMetricsServerConfigStore = class {
1845
1845
  * Clear configurations for a specific tenant
1846
1846
  */
1847
1847
  clearByTenant(tenantId2) {
1848
- for (const key4 of this.configs.keys()) {
1849
- if (key4.startsWith(`${tenantId2}:`)) {
1850
- this.configs.delete(key4);
1848
+ for (const key5 of this.configs.keys()) {
1849
+ if (key5.startsWith(`${tenantId2}:`)) {
1850
+ this.configs.delete(key5);
1851
1851
  }
1852
1852
  }
1853
1853
  }
@@ -1882,15 +1882,15 @@ var InMemoryMcpServerConfigStore = class {
1882
1882
  * Get MCP server configuration by ID
1883
1883
  */
1884
1884
  async getConfigById(tenantId2, id) {
1885
- const key4 = this.getKey(tenantId2, id);
1886
- return this.configs.get(key4) || null;
1885
+ const key5 = this.getKey(tenantId2, id);
1886
+ return this.configs.get(key5) || null;
1887
1887
  }
1888
1888
  /**
1889
1889
  * Get MCP server configuration by business key
1890
1890
  */
1891
- async getConfigByKey(tenantId2, key4) {
1891
+ async getConfigByKey(tenantId2, key5) {
1892
1892
  const configs = await this.getAllConfigs(tenantId2);
1893
- return configs.find((config) => config.key === key4) || null;
1893
+ return configs.find((config) => config.key === key5) || null;
1894
1894
  }
1895
1895
  /**
1896
1896
  * Create a new MCP server configuration
@@ -1918,8 +1918,8 @@ var InMemoryMcpServerConfigStore = class {
1918
1918
  * Update an existing MCP server configuration
1919
1919
  */
1920
1920
  async updateConfig(tenantId2, id, updates) {
1921
- const key4 = this.getKey(tenantId2, id);
1922
- const existing = this.configs.get(key4);
1921
+ const key5 = this.getKey(tenantId2, id);
1922
+ const existing = this.configs.get(key5);
1923
1923
  if (!existing) {
1924
1924
  return null;
1925
1925
  }
@@ -1934,22 +1934,22 @@ var InMemoryMcpServerConfigStore = class {
1934
1934
  status: updates.status !== void 0 ? updates.status : existing.status,
1935
1935
  updatedAt: /* @__PURE__ */ new Date()
1936
1936
  };
1937
- this.configs.set(key4, updated);
1937
+ this.configs.set(key5, updated);
1938
1938
  return updated;
1939
1939
  }
1940
1940
  /**
1941
1941
  * Delete a MCP server configuration by ID
1942
1942
  */
1943
1943
  async deleteConfig(tenantId2, id) {
1944
- const key4 = this.getKey(tenantId2, id);
1945
- return this.configs.delete(key4);
1944
+ const key5 = this.getKey(tenantId2, id);
1945
+ return this.configs.delete(key5);
1946
1946
  }
1947
1947
  /**
1948
1948
  * Check if configuration exists
1949
1949
  */
1950
1950
  async hasConfig(tenantId2, id) {
1951
- const key4 = this.getKey(tenantId2, id);
1952
- return this.configs.has(key4);
1951
+ const key5 = this.getKey(tenantId2, id);
1952
+ return this.configs.has(key5);
1953
1953
  }
1954
1954
  /**
1955
1955
  * Clear all configurations (useful for testing)
@@ -1961,9 +1961,9 @@ var InMemoryMcpServerConfigStore = class {
1961
1961
  * Clear configurations for a specific tenant
1962
1962
  */
1963
1963
  clearByTenant(tenantId2) {
1964
- for (const key4 of this.configs.keys()) {
1965
- if (key4.startsWith(`${tenantId2}:`)) {
1966
- this.configs.delete(key4);
1964
+ for (const key5 of this.configs.keys()) {
1965
+ if (key5.startsWith(`${tenantId2}:`)) {
1966
+ this.configs.delete(key5);
1967
1967
  }
1968
1968
  }
1969
1969
  }
@@ -2140,10 +2140,10 @@ var InMemoryCapabilityBundleStore = class {
2140
2140
  }
2141
2141
  async deleteIfUnreferenced(tenantId2, id) {
2142
2142
  return this.coordinator.runProjectUpdate(tenantId2, id, () => {
2143
- const key4 = this.key(tenantId2, id);
2144
- if (!this.bundles.has(key4)) return "not_found";
2143
+ const key5 = this.key(tenantId2, id);
2144
+ if (!this.bundles.has(key5)) return "not_found";
2145
2145
  if (this.projectStore.isCapabilityBundleReferencedSync(tenantId2, id)) return "in_use";
2146
- this.bundles.delete(key4);
2146
+ this.bundles.delete(key5);
2147
2147
  this.coordinator.remove(tenantId2, id);
2148
2148
  return "deleted";
2149
2149
  });
@@ -2677,6 +2677,19 @@ var InMemoryProjectRoomMessageStore = class {
2677
2677
  async findById(tenantId2, id) {
2678
2678
  return this.coordinator.runExclusive((transaction) => transaction.getMessage(tenantId2, id) ?? null);
2679
2679
  }
2680
+ /**
2681
+ * Counts messages created strictly after a horizon, optionally excluding one human author.
2682
+ *
2683
+ * @param input - Tenant/room scope, exclusive lower time bound, optional excluded human author.
2684
+ * @returns The number of matching messages.
2685
+ */
2686
+ async countAfter(input) {
2687
+ if (!validDate(input.after)) {
2688
+ throw new RangeError("Project room message count horizon date is invalid");
2689
+ }
2690
+ const horizon = Date.prototype.getTime.call(input.after);
2691
+ return this.coordinator.runExclusive((transaction) => transaction.getMessages().filter((message) => message.tenantId === input.tenantId && message.roomId === input.roomId && message.createdAt.getTime() > horizon).filter((message) => input.excludeAuthorUserId === void 0 || !(message.author.type === "human" && message.author.userId === input.excludeAuthorUserId)).length);
2692
+ }
2680
2693
  createInTransaction(transaction, input) {
2681
2694
  if (transaction.getMessage(input.tenantId, input.id) !== void 0) {
2682
2695
  throw new ProjectRoomMessageIdConflictError(input.tenantId, input.id);
@@ -2686,6 +2699,69 @@ var InMemoryProjectRoomMessageStore = class {
2686
2699
  return structuredClone(message);
2687
2700
  }
2688
2701
  };
2702
+ function validDate(value) {
2703
+ try {
2704
+ return typeof value === "object" && value !== null && Number.isFinite(Date.prototype.getTime.call(value));
2705
+ } catch {
2706
+ return false;
2707
+ }
2708
+ }
2709
+
2710
+ // src/store_lattice/InMemoryProjectRoomReadStateStore.ts
2711
+ var InMemoryProjectRoomReadStateStore = class {
2712
+ constructor() {
2713
+ this.states = /* @__PURE__ */ new Map();
2714
+ }
2715
+ /**
2716
+ * Returns a defensive copy of the user's read marker.
2717
+ *
2718
+ * @param tenantId - Tenant owning the room.
2719
+ * @param roomId - Room the marker applies to.
2720
+ * @param userId - User the marker belongs to.
2721
+ * @returns The stored read state, or `null` when never reported.
2722
+ */
2723
+ async get(tenantId2, roomId, userId) {
2724
+ const state = this.states.get(key(tenantId2, roomId, userId));
2725
+ return state ? structuredClone(state) : null;
2726
+ }
2727
+ /**
2728
+ * Upserts the marker with a monotonic lastReadAt and returns the stored state.
2729
+ *
2730
+ * @param input - Tenant/room/user scope and the read horizon to report.
2731
+ * @returns A defensive copy of the stored read state after the write.
2732
+ *
2733
+ * @remarks
2734
+ * `updatedAt` refreshes on every call — even when an older report does not
2735
+ * move the horizon — so it records the last report time, not the last change.
2736
+ */
2737
+ async markRead(input) {
2738
+ if (!validDate2(input.lastReadAt)) {
2739
+ throw new RangeError("Project room read state lastReadAt is invalid");
2740
+ }
2741
+ const reported = new Date(Date.prototype.getTime.call(input.lastReadAt));
2742
+ const existing = this.states.get(key(input.tenantId, input.roomId, input.userId));
2743
+ const lastReadAt = existing !== void 0 && existing.lastReadAt.getTime() > reported.getTime() ? existing.lastReadAt : reported;
2744
+ const next = {
2745
+ tenantId: input.tenantId,
2746
+ roomId: input.roomId,
2747
+ userId: input.userId,
2748
+ lastReadAt,
2749
+ updatedAt: /* @__PURE__ */ new Date()
2750
+ };
2751
+ this.states.set(key(next.tenantId, next.roomId, next.userId), next);
2752
+ return structuredClone(next);
2753
+ }
2754
+ };
2755
+ function key(tenantId2, roomId, userId) {
2756
+ return JSON.stringify([tenantId2, roomId, userId]);
2757
+ }
2758
+ function validDate2(value) {
2759
+ try {
2760
+ return typeof value === "object" && value !== null && Number.isFinite(Date.prototype.getTime.call(value));
2761
+ } catch {
2762
+ return false;
2763
+ }
2764
+ }
2689
2765
 
2690
2766
  // src/store_lattice/InMemoryUserStore.ts
2691
2767
  var InMemoryUserStore = class {
@@ -2821,8 +2897,8 @@ var InMemoryUserTenantLinkStore = class {
2821
2897
  );
2822
2898
  }
2823
2899
  async getLink(userId, tenantId2) {
2824
- const key4 = this.getKey(userId, tenantId2);
2825
- return this.links.get(key4) || null;
2900
+ const key5 = this.getKey(userId, tenantId2);
2901
+ return this.links.get(key5) || null;
2826
2902
  }
2827
2903
  async createLink(data) {
2828
2904
  const link = {
@@ -2832,29 +2908,29 @@ var InMemoryUserTenantLinkStore = class {
2832
2908
  joinedAt: /* @__PURE__ */ new Date(),
2833
2909
  metadata: data.metadata ?? {}
2834
2910
  };
2835
- const key4 = this.getKey(data.userId, data.tenantId);
2836
- this.links.set(key4, link);
2911
+ const key5 = this.getKey(data.userId, data.tenantId);
2912
+ this.links.set(key5, link);
2837
2913
  return link;
2838
2914
  }
2839
2915
  async updateLink(userId, tenantId2, updates) {
2840
- const key4 = this.getKey(userId, tenantId2);
2841
- const existing = this.links.get(key4);
2916
+ const key5 = this.getKey(userId, tenantId2);
2917
+ const existing = this.links.get(key5);
2842
2918
  if (!existing) return null;
2843
2919
  const updated = {
2844
2920
  ...existing,
2845
2921
  ...updates,
2846
2922
  metadata: updates.metadata ?? existing.metadata
2847
2923
  };
2848
- this.links.set(key4, updated);
2924
+ this.links.set(key5, updated);
2849
2925
  return updated;
2850
2926
  }
2851
2927
  async deleteLink(userId, tenantId2) {
2852
- const key4 = this.getKey(userId, tenantId2);
2853
- return this.links.delete(key4);
2928
+ const key5 = this.getKey(userId, tenantId2);
2929
+ return this.links.delete(key5);
2854
2930
  }
2855
2931
  async hasLink(userId, tenantId2) {
2856
- const key4 = this.getKey(userId, tenantId2);
2857
- return this.links.has(key4);
2932
+ const key5 = this.getKey(userId, tenantId2);
2933
+ return this.links.has(key5);
2858
2934
  }
2859
2935
  clear() {
2860
2936
  this.links.clear();
@@ -3521,9 +3597,9 @@ var InMemoryA2AApiKeyStore = class {
3521
3597
  constructor() {
3522
3598
  this.keys = /* @__PURE__ */ new Map();
3523
3599
  }
3524
- async findByKey(key4) {
3600
+ async findByKey(key5) {
3525
3601
  for (const record of this.keys.values()) {
3526
- if (record.key === key4 && record.enabled) return record;
3602
+ if (record.key === key5 && record.enabled) return record;
3527
3603
  }
3528
3604
  return null;
3529
3605
  }
@@ -3603,7 +3679,7 @@ function cloneTaskValue(value) {
3603
3679
  if (Array.isArray(value)) return value.map((entry) => cloneTaskValue(entry));
3604
3680
  if (value && typeof value === "object") {
3605
3681
  return Object.fromEntries(
3606
- Object.entries(value).map(([key4, entry]) => [key4, cloneTaskValue(entry)])
3682
+ Object.entries(value).map(([key5, entry]) => [key5, cloneTaskValue(entry)])
3607
3683
  );
3608
3684
  }
3609
3685
  return value;
@@ -3759,8 +3835,8 @@ var InMemoryTaskStore = class {
3759
3835
  if (filter2.parentId) results = results.filter((t) => t.parentId === filter2.parentId);
3760
3836
  if (filter2.sourceId) results = results.filter((t) => t.sourceId === filter2.sourceId);
3761
3837
  if (filter2.metadata) {
3762
- for (const [key4, value] of Object.entries(filter2.metadata)) {
3763
- results = results.filter((t) => t.metadata?.[key4] === value);
3838
+ for (const [key5, value] of Object.entries(filter2.metadata)) {
3839
+ results = results.filter((t) => t.metadata?.[key5] === value);
3764
3840
  }
3765
3841
  }
3766
3842
  results.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime() || b.id.localeCompare(a.id));
@@ -3978,12 +4054,12 @@ var InMemoryTaskWorkItemStore = class {
3978
4054
  }
3979
4055
  /** Atomically return an existing event or create it once. */
3980
4056
  async createIfAbsentByEventKey(params) {
3981
- const key4 = this.eventMapKey(params.tenantId, params.taskId, params.eventKey);
3982
- const existing = this.events.get(key4);
4057
+ const key5 = this.eventMapKey(params.tenantId, params.taskId, params.eventKey);
4058
+ const existing = this.events.get(key5);
3983
4059
  if (existing) return existing;
3984
4060
  const item = this.append(params);
3985
4061
  item.eventKey = params.eventKey;
3986
- this.events.set(key4, item);
4062
+ this.events.set(key5, item);
3987
4063
  return item;
3988
4064
  }
3989
4065
  /**
@@ -4149,8 +4225,8 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4149
4225
  * @param type Store type
4150
4226
  * @returns Composite key string
4151
4227
  */
4152
- getCompositeKey(key4, type) {
4153
- return `${key4}:${type}`;
4228
+ getCompositeKey(key5, type) {
4229
+ return `${key5}:${type}`;
4154
4230
  }
4155
4231
  /**
4156
4232
  * Register store Lattice with type safety
@@ -4159,13 +4235,13 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4159
4235
  * @param type Store type (e.g., "thread")
4160
4236
  * @param store Store implementation instance matching the type
4161
4237
  */
4162
- registerLattice(key4, type, store) {
4238
+ registerLattice(key5, type, store) {
4163
4239
  const storeLattice = {
4164
- key: key4,
4240
+ key: key5,
4165
4241
  type,
4166
4242
  store
4167
4243
  };
4168
- const compositeKey = this.getCompositeKey(key4, type);
4244
+ const compositeKey = this.getCompositeKey(key5, type);
4169
4245
  this.register(compositeKey, storeLattice);
4170
4246
  }
4171
4247
  /**
@@ -4175,15 +4251,15 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4175
4251
  * @param type Expected store type for type checking
4176
4252
  * @returns StoreLattice with typed store
4177
4253
  */
4178
- getStoreLattice(key4, type) {
4179
- const compositeKey = this.getCompositeKey(key4, type);
4254
+ getStoreLattice(key5, type) {
4255
+ const compositeKey = this.getCompositeKey(key5, type);
4180
4256
  const storeLattice = this.get(compositeKey);
4181
4257
  if (!storeLattice) {
4182
- throw new Error(`StoreLattice ${key4}:${type} not found`);
4258
+ throw new Error(`StoreLattice ${key5}:${type} not found`);
4183
4259
  }
4184
4260
  if (storeLattice.type !== type) {
4185
4261
  throw new Error(
4186
- `StoreLattice ${key4}:${type} has type "${storeLattice.type}", expected "${type}"`
4262
+ `StoreLattice ${key5}:${type} has type "${storeLattice.type}", expected "${type}"`
4187
4263
  );
4188
4264
  }
4189
4265
  return storeLattice;
@@ -4194,11 +4270,11 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4194
4270
  * @param type Store type
4195
4271
  * @returns StoreLattice (type may be unknown)
4196
4272
  */
4197
- getStoreLatticeUnsafe(key4, type) {
4198
- const compositeKey = this.getCompositeKey(key4, type);
4273
+ getStoreLatticeUnsafe(key5, type) {
4274
+ const compositeKey = this.getCompositeKey(key5, type);
4199
4275
  const storeLattice = this.get(compositeKey);
4200
4276
  if (!storeLattice) {
4201
- throw new Error(`StoreLattice ${key4}:${type} not found`);
4277
+ throw new Error(`StoreLattice ${key5}:${type} not found`);
4202
4278
  }
4203
4279
  return storeLattice;
4204
4280
  }
@@ -4214,8 +4290,8 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4214
4290
  * @param key Lattice key name
4215
4291
  * @param type Store type
4216
4292
  */
4217
- hasLattice(key4, type) {
4218
- const compositeKey = this.getCompositeKey(key4, type);
4293
+ hasLattice(key5, type) {
4294
+ const compositeKey = this.getCompositeKey(key5, type);
4219
4295
  return this.has(compositeKey);
4220
4296
  }
4221
4297
  /**
@@ -4224,8 +4300,8 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4224
4300
  * @param key Lattice key name
4225
4301
  * @param type Store type
4226
4302
  */
4227
- removeLattice(key4, type) {
4228
- const compositeKey = this.getCompositeKey(key4, type);
4303
+ removeLattice(key5, type) {
4304
+ const compositeKey = this.getCompositeKey(key5, type);
4229
4305
  return this.remove(compositeKey);
4230
4306
  }
4231
4307
  /**
@@ -4248,8 +4324,8 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
4248
4324
  }
4249
4325
  };
4250
4326
  var storeLatticeManager = StoreLatticeManager.getInstance();
4251
- var registerStoreLattice = (key4, type, store) => storeLatticeManager.registerLattice(key4, type, store);
4252
- var getStoreLattice = (key4, type) => storeLatticeManager.getStoreLattice(key4, type);
4327
+ var registerStoreLattice = (key5, type, store) => storeLatticeManager.registerLattice(key5, type, store);
4328
+ var getStoreLattice = (key5, type) => storeLatticeManager.getStoreLattice(key5, type);
4253
4329
  var defaultThreadStore = new InMemoryThreadStore();
4254
4330
  var defaultAssistantStore = new InMemoryAssistantStore();
4255
4331
  var defaultSkillStore = new FileSystemSkillStore();
@@ -4266,6 +4342,7 @@ var defaultProjectRoomStore = new InMemoryProjectRoomStore(defaultProjectRoomCoo
4266
4342
  var defaultProjectMembershipStore = new InMemoryProjectMembershipStore(defaultProjectRoomCoordinator);
4267
4343
  var defaultProjectBotMembershipStore = new InMemoryProjectBotMembershipStore(defaultProjectRoomCoordinator);
4268
4344
  var defaultProjectRoomMessageStore = new InMemoryProjectRoomMessageStore(defaultProjectRoomCoordinator);
4345
+ var defaultProjectRoomReadStateStore = new InMemoryProjectRoomReadStateStore();
4269
4346
  storeLatticeManager.registerLattice("default", "thread", defaultThreadStore);
4270
4347
  storeLatticeManager.registerLattice(
4271
4348
  "default",
@@ -4284,6 +4361,7 @@ storeLatticeManager.registerLattice("default", "projectRoom", defaultProjectRoom
4284
4361
  storeLatticeManager.registerLattice("default", "projectMembership", defaultProjectMembershipStore);
4285
4362
  storeLatticeManager.registerLattice("default", "projectBotMembership", defaultProjectBotMembershipStore);
4286
4363
  storeLatticeManager.registerLattice("default", "projectRoomMessage", defaultProjectRoomMessageStore);
4364
+ storeLatticeManager.registerLattice("default", "projectRoomReadState", defaultProjectRoomReadStateStore);
4287
4365
  var defaultUserStore = new InMemoryUserStore();
4288
4366
  var defaultTenantStore = new InMemoryTenantStore();
4289
4367
  var defaultUserTenantLinkStore = new InMemoryUserTenantLinkStore();
@@ -4853,7 +4931,7 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4853
4931
  * @param key - Unique identifier for the database within the tenant
4854
4932
  * @param config - Database configuration
4855
4933
  */
4856
- registerDatabase(tenantId2, key4, config) {
4934
+ registerDatabase(tenantId2, key5, config) {
4857
4935
  let database;
4858
4936
  switch (config.type) {
4859
4937
  case "postgres":
@@ -4868,9 +4946,9 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4868
4946
  throw new Error(`Unsupported database type: ${config.type}`);
4869
4947
  }
4870
4948
  const tenantDbs = this.getTenantDatabases(tenantId2);
4871
- tenantDbs.set(key4, database);
4949
+ tenantDbs.set(key5, database);
4872
4950
  if (!this.defaultDatabaseKeys.has(tenantId2)) {
4873
- this.defaultDatabaseKeys.set(tenantId2, key4);
4951
+ this.defaultDatabaseKeys.set(tenantId2, key5);
4874
4952
  }
4875
4953
  }
4876
4954
  /**
@@ -4878,12 +4956,12 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4878
4956
  * @param tenantId - Tenant identifier
4879
4957
  * @param key - Database key to set as default
4880
4958
  */
4881
- setDefaultDatabase(tenantId2, key4) {
4959
+ setDefaultDatabase(tenantId2, key5) {
4882
4960
  const tenantDbs = this.databases.get(tenantId2);
4883
- if (!tenantDbs || !tenantDbs.has(key4)) {
4884
- throw new Error(`Database '${key4}' not found for tenant '${tenantId2}'`);
4961
+ if (!tenantDbs || !tenantDbs.has(key5)) {
4962
+ throw new Error(`Database '${key5}' not found for tenant '${tenantId2}'`);
4885
4963
  }
4886
- this.defaultDatabaseKeys.set(tenantId2, key4);
4964
+ this.defaultDatabaseKeys.set(tenantId2, key5);
4887
4965
  }
4888
4966
  /**
4889
4967
  * Get a database by key for a specific tenant
@@ -4893,9 +4971,9 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4893
4971
  * @returns ISqlDatabase instance
4894
4972
  * @throws Error if tenant or database not found
4895
4973
  */
4896
- async getDatabase(tenantId2, key4) {
4974
+ async getDatabase(tenantId2, key5) {
4897
4975
  const tenantDbs = this.databases.get(tenantId2);
4898
- const dbKey = key4 || this.defaultDatabaseKeys.get(tenantId2);
4976
+ const dbKey = key5 || this.defaultDatabaseKeys.get(tenantId2);
4899
4977
  if (!dbKey) {
4900
4978
  throw new Error(`No default database set for tenant '${tenantId2}'`);
4901
4979
  }
@@ -4935,9 +5013,9 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4935
5013
  * @param key - Database key
4936
5014
  * @returns true if database exists for the tenant
4937
5015
  */
4938
- hasDatabase(tenantId2, key4) {
5016
+ hasDatabase(tenantId2, key5) {
4939
5017
  const tenantDbs = this.databases.get(tenantId2);
4940
- return tenantDbs ? tenantDbs.has(key4) : false;
5018
+ return tenantDbs ? tenantDbs.has(key5) : false;
4941
5019
  }
4942
5020
  /**
4943
5021
  * Get all registered database keys for a tenant
@@ -4953,14 +5031,14 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
4953
5031
  * @param tenantId - Tenant identifier
4954
5032
  * @param key - Database key
4955
5033
  */
4956
- async removeDatabase(tenantId2, key4) {
5034
+ async removeDatabase(tenantId2, key5) {
4957
5035
  const tenantDbs = this.databases.get(tenantId2);
4958
5036
  if (!tenantDbs) return;
4959
- const database = tenantDbs.get(key4);
5037
+ const database = tenantDbs.get(key5);
4960
5038
  if (database) {
4961
5039
  await database.disconnect();
4962
- tenantDbs.delete(key4);
4963
- if (this.defaultDatabaseKeys.get(tenantId2) === key4) {
5040
+ tenantDbs.delete(key5);
5041
+ if (this.defaultDatabaseKeys.get(tenantId2) === key5) {
4964
5042
  const remainingKeys = Array.from(tenantDbs.keys());
4965
5043
  if (remainingKeys.length > 0) {
4966
5044
  this.defaultDatabaseKeys.set(tenantId2, remainingKeys[0]);
@@ -5079,7 +5157,7 @@ function getEffectiveDatabaseKeys(exeConfig, staticDatabaseKeys) {
5079
5157
  const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "sql");
5080
5158
  if (runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "databaseKeys")) {
5081
5159
  const databaseKeys = runtimeConfig.databaseKeys;
5082
- if (Array.isArray(databaseKeys) && databaseKeys.every((key4) => typeof key4 === "string")) {
5160
+ if (Array.isArray(databaseKeys) && databaseKeys.every((key5) => typeof key5 === "string")) {
5083
5161
  return databaseKeys;
5084
5162
  }
5085
5163
  return [];
@@ -5098,7 +5176,7 @@ var createListTablesSqlTool = ({ databaseKeys, databaseDescriptions, getTenantId
5098
5176
 
5099
5177
  Available databases:
5100
5178
  ${databaseKeys.map(
5101
- (key4) => `- ${key4}${databaseDescriptions?.[key4] ? `: ${databaseDescriptions[key4]}` : ""}`
5179
+ (key5) => `- ${key5}${databaseDescriptions?.[key5] ? `: ${databaseDescriptions[key5]}` : ""}`
5102
5180
  ).join("\n")}` : "";
5103
5181
  return tool2(
5104
5182
  async ({ databaseKey }, _exeConfig) => {
@@ -5143,7 +5221,7 @@ var createInfoSqlTool = ({ databaseKeys, databaseDescriptions, getTenantId: getT
5143
5221
 
5144
5222
  Available databases:
5145
5223
  ${databaseKeys.map(
5146
- (key4) => `- ${key4}${databaseDescriptions?.[key4] ? `: ${databaseDescriptions[key4]}` : ""}`
5224
+ (key5) => `- ${key5}${databaseDescriptions?.[key5] ? `: ${databaseDescriptions[key5]}` : ""}`
5147
5225
  ).join("\n")}` : "";
5148
5226
  return tool3(
5149
5227
  async ({
@@ -5276,7 +5354,7 @@ var createQueryCheckerSqlTool = ({ databaseKeys, databaseDescriptions, getTenant
5276
5354
 
5277
5355
  Available databases:
5278
5356
  ${databaseKeys.map(
5279
- (key4) => `- ${key4}${databaseDescriptions?.[key4] ? `: ${databaseDescriptions[key4]}` : ""}`
5357
+ (key5) => `- ${key5}${databaseDescriptions?.[key5] ? `: ${databaseDescriptions[key5]}` : ""}`
5280
5358
  ).join("\n")}` : "";
5281
5359
  return tool4(
5282
5360
  async ({
@@ -5405,7 +5483,7 @@ var createQuerySqlTool = ({ databaseKeys, databaseDescriptions, getTenantId: get
5405
5483
 
5406
5484
  Available databases:
5407
5485
  ${databaseKeys.map(
5408
- (key4) => `- ${key4}${databaseDescriptions?.[key4] ? `: ${databaseDescriptions[key4]}` : ""}`
5486
+ (key5) => `- ${key5}${databaseDescriptions?.[key5] ? `: ${databaseDescriptions[key5]}` : ""}`
5409
5487
  ).join("\n")}` : "";
5410
5488
  return tool5(
5411
5489
  async ({
@@ -5450,7 +5528,7 @@ async function getEffectiveServerKeys(exeConfig, staticServerKeys, staticConnect
5450
5528
  const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "metrics");
5451
5529
  const hasRuntimeKeys = runtimeConfig !== void 0 && Object.prototype.hasOwnProperty.call(runtimeConfig, "serverKeys");
5452
5530
  const runtimeKeys = hasRuntimeKeys ? runtimeConfig.serverKeys : void 0;
5453
- const serverKeys = Array.isArray(runtimeKeys) && runtimeKeys.every((key4) => typeof key4 === "string") ? runtimeKeys : hasRuntimeKeys ? [] : staticServerKeys;
5531
+ const serverKeys = Array.isArray(runtimeKeys) && runtimeKeys.every((key5) => typeof key5 === "string") ? runtimeKeys : hasRuntimeKeys ? [] : staticServerKeys;
5454
5532
  const hasRuntimeConnectAll = runtimeConfig !== void 0 && Object.prototype.hasOwnProperty.call(runtimeConfig, "connectAll");
5455
5533
  const connectAll = hasRuntimeConnectAll ? runtimeConfig.connectAll === true && staticConnectAll !== false : staticConnectAll === true;
5456
5534
  if (requestedServerKey !== void 0) {
@@ -5460,7 +5538,7 @@ async function getEffectiveServerKeys(exeConfig, staticServerKeys, staticConnect
5460
5538
  return serverKeys.includes(requestedServerKey) ? [...serverKeys] : [requestedServerKey];
5461
5539
  }
5462
5540
  const availableKeys = (await manager.getServerKeys(tenantId2)).map((server) => server.key);
5463
- return connectAll ? availableKeys : serverKeys.filter((key4) => availableKeys.includes(key4));
5541
+ return connectAll ? availableKeys : serverKeys.filter((key5) => availableKeys.includes(key5));
5464
5542
  }
5465
5543
  function getTenantIdFromConfig2(exeConfig, getTenantId3) {
5466
5544
  const runConfig = exeConfig?.configurable?.runConfig || {};
@@ -5601,9 +5679,9 @@ var SemanticMetricsClient = class {
5601
5679
  });
5602
5680
  }
5603
5681
  if (options.labels) {
5604
- for (const [key4, value] of Object.entries(options.labels)) {
5682
+ for (const [key5, value] of Object.entries(options.labels)) {
5605
5683
  filters.push({
5606
- dimension: key4,
5684
+ dimension: key5,
5607
5685
  operator: "=",
5608
5686
  values: [value]
5609
5687
  });
@@ -5932,7 +6010,7 @@ var PrometheusClient = class {
5932
6010
  const step = options.step || 60;
5933
6011
  let query = metricName;
5934
6012
  if (options.labels && Object.keys(options.labels).length > 0) {
5935
- const labelSelectors = Object.entries(options.labels).map(([key4, value]) => `${key4}="${value}"`).join(",");
6013
+ const labelSelectors = Object.entries(options.labels).map(([key5, value]) => `${key5}="${value}"`).join(",");
5936
6014
  query = `${metricName}{${labelSelectors}}`;
5937
6015
  }
5938
6016
  try {
@@ -6137,47 +6215,47 @@ var MetricsServerManager = class _MetricsServerManager {
6137
6215
  * Resolve a server config for a tenant. Queries the store for freshness.
6138
6216
  * When store has no data, falls back to in-memory cache.
6139
6217
  */
6140
- async _resolveConfig(tenantId2, key4) {
6218
+ async _resolveConfig(tenantId2, key5) {
6141
6219
  try {
6142
6220
  const { store } = getStoreLattice("default", "metrics");
6143
6221
  const configStore = store;
6144
- const entry = await configStore.getConfigByKey(tenantId2, key4);
6222
+ const entry = await configStore.getConfigByKey(tenantId2, key5);
6145
6223
  if (entry) return entry.config;
6146
6224
  } catch {
6147
6225
  }
6148
6226
  const tenantConfigs = this.configs.get(tenantId2);
6149
- const cached = tenantConfigs?.get(key4);
6227
+ const cached = tenantConfigs?.get(key5);
6150
6228
  if (cached) return cached;
6151
- throw new Error(`Metrics server '${key4}' not found for tenant '${tenantId2}'`);
6229
+ throw new Error(`Metrics server '${key5}' not found for tenant '${tenantId2}'`);
6152
6230
  }
6153
6231
  /**
6154
6232
  * Register a metrics server for a tenant. Stores config in memory
6155
6233
  * for fallback / programmatic registration use.
6156
6234
  */
6157
- registerServer(tenantId2, key4, config) {
6235
+ registerServer(tenantId2, key5, config) {
6158
6236
  const tenantConfigs = this.getTenantConfigs(tenantId2);
6159
- tenantConfigs.set(key4, config);
6237
+ tenantConfigs.set(key5, config);
6160
6238
  if (!this.defaultServerKeys.has(tenantId2)) {
6161
- this.defaultServerKeys.set(tenantId2, key4);
6239
+ this.defaultServerKeys.set(tenantId2, key5);
6162
6240
  }
6163
6241
  }
6164
6242
  /**
6165
6243
  * Set the default metrics server for a tenant
6166
6244
  */
6167
- setDefaultServer(tenantId2, key4) {
6245
+ setDefaultServer(tenantId2, key5) {
6168
6246
  const tenantConfigs = this.configs.get(tenantId2);
6169
- if (!tenantConfigs || !tenantConfigs.has(key4)) {
6170
- throw new Error(`Metrics server '${key4}' not found for tenant '${tenantId2}'`);
6247
+ if (!tenantConfigs || !tenantConfigs.has(key5)) {
6248
+ throw new Error(`Metrics server '${key5}' not found for tenant '${tenantId2}'`);
6171
6249
  }
6172
- this.defaultServerKeys.set(tenantId2, key4);
6250
+ this.defaultServerKeys.set(tenantId2, key5);
6173
6251
  }
6174
6252
  /**
6175
6253
  * Get a metrics server client for a tenant.
6176
6254
  * Always queries the store for the latest config, creates a fresh client.
6177
6255
  * Falls back to in-memory cache when store is unavailable.
6178
6256
  */
6179
- async getClient(tenantId2, key4) {
6180
- const serverKey = key4 || this.defaultServerKeys.get(tenantId2);
6257
+ async getClient(tenantId2, key5) {
6258
+ const serverKey = key5 || this.defaultServerKeys.get(tenantId2);
6181
6259
  if (!serverKey) {
6182
6260
  throw new Error(`No default metrics server set for tenant '${tenantId2}'`);
6183
6261
  }
@@ -6189,8 +6267,8 @@ var MetricsServerManager = class _MetricsServerManager {
6189
6267
  * Always queries the store for freshness.
6190
6268
  * Falls back to in-memory cache when store is unavailable.
6191
6269
  */
6192
- async getConfig(tenantId2, key4) {
6193
- const serverKey = key4 || this.defaultServerKeys.get(tenantId2);
6270
+ async getConfig(tenantId2, key5) {
6271
+ const serverKey = key5 || this.defaultServerKeys.get(tenantId2);
6194
6272
  if (!serverKey) {
6195
6273
  throw new Error(`No default metrics server set for tenant '${tenantId2}'`);
6196
6274
  }
@@ -6200,9 +6278,9 @@ var MetricsServerManager = class _MetricsServerManager {
6200
6278
  * Check if a metrics server exists in the in-memory cache.
6201
6279
  * For store-backed existence checks, use getClient() or getConfig().
6202
6280
  */
6203
- hasServer(tenantId2, key4) {
6281
+ hasServer(tenantId2, key5) {
6204
6282
  const tenantConfigs = this.configs.get(tenantId2);
6205
- return tenantConfigs ? tenantConfigs.has(key4) : false;
6283
+ return tenantConfigs ? tenantConfigs.has(key5) : false;
6206
6284
  }
6207
6285
  /**
6208
6286
  * Get all registered metrics server keys for a tenant.
@@ -6221,22 +6299,22 @@ var MetricsServerManager = class _MetricsServerManager {
6221
6299
  }
6222
6300
  const tenantConfigs = this.configs.get(tenantId2);
6223
6301
  if (!tenantConfigs) return [];
6224
- return Array.from(tenantConfigs.entries()).map(([key4, config]) => ({
6225
- key: key4,
6302
+ return Array.from(tenantConfigs.entries()).map(([key5, config]) => ({
6303
+ key: key5,
6226
6304
  type: config.type
6227
6305
  }));
6228
6306
  }
6229
6307
  /**
6230
6308
  * Remove a metrics server for a tenant
6231
6309
  */
6232
- removeServer(tenantId2, key4) {
6310
+ removeServer(tenantId2, key5) {
6233
6311
  const tenantConfigs = this.configs.get(tenantId2);
6234
6312
  if (!tenantConfigs) return;
6235
- tenantConfigs.delete(key4);
6313
+ tenantConfigs.delete(key5);
6236
6314
  if (tenantConfigs.size === 0) {
6237
6315
  this.configs.delete(tenantId2);
6238
6316
  }
6239
- if (this.defaultServerKeys.get(tenantId2) === key4) {
6317
+ if (this.defaultServerKeys.get(tenantId2) === key5) {
6240
6318
  const remainingKeys = Array.from(tenantConfigs.keys());
6241
6319
  if (remainingKeys.length > 0) {
6242
6320
  this.defaultServerKeys.set(tenantId2, remainingKeys[0]);
@@ -6282,7 +6360,7 @@ var createListMetricsServersTool = ({ serverKeys, serverDescriptions, getTenantI
6282
6360
 
6283
6361
  Available metrics servers:
6284
6362
  ${serverKeys.map(
6285
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6363
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6286
6364
  ).join("\n")}` : "";
6287
6365
  return tool6(
6288
6366
  async (_input, _exeConfig) => {
@@ -6292,9 +6370,9 @@ ${serverKeys.map(
6292
6370
  if (servers.length === 0) {
6293
6371
  return "No metrics servers registered.";
6294
6372
  }
6295
- const lines = servers.map(({ key: key4, type }) => {
6296
- const desc = serverDescriptions?.[key4] ? ` - ${serverDescriptions[key4]}` : "";
6297
- return `- ${key4} (${type})${desc}`;
6373
+ const lines = servers.map(({ key: key5, type }) => {
6374
+ const desc = serverDescriptions?.[key5] ? ` - ${serverDescriptions[key5]}` : "";
6375
+ return `- ${key5} (${type})${desc}`;
6298
6376
  });
6299
6377
  return `Available metrics servers:
6300
6378
  ${lines.join("\n")}`;
@@ -6319,7 +6397,7 @@ var createListMetricsDataSourcesTool = ({ serverKeys, serverDescriptions, getTen
6319
6397
 
6320
6398
  Configured metrics servers:
6321
6399
  ${serverKeys.map(
6322
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6400
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6323
6401
  ).join("\n")}` : "";
6324
6402
  return tool7(
6325
6403
  async (_input, _exeConfig) => {
@@ -6437,7 +6515,7 @@ var createQueryMetricsListTool = ({ serverKeys, serverDescriptions, getTenantId:
6437
6515
 
6438
6516
  Available metrics servers:
6439
6517
  ${serverKeys.map(
6440
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6518
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6441
6519
  ).join("\n")}` : "";
6442
6520
  return tool8(
6443
6521
  async ({
@@ -6596,7 +6674,7 @@ var createQueryMetricDefinitionTool = ({ serverKeys, serverDescriptions, getTena
6596
6674
 
6597
6675
  Available metrics servers:
6598
6676
  ${serverKeys.map(
6599
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6677
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6600
6678
  ).join("\n")}` : "";
6601
6679
  return tool9(
6602
6680
  async ({
@@ -6831,7 +6909,7 @@ var createQuerySemanticMetricDataTool = ({ serverKeys, serverDescriptions, getTe
6831
6909
 
6832
6910
  Available metrics servers:
6833
6911
  ${serverKeys.map(
6834
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6912
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6835
6913
  ).join("\n")}` : "";
6836
6914
  return tool10(
6837
6915
  async ({
@@ -6918,7 +6996,7 @@ var createQueryTablesListTool = ({ serverKeys, serverDescriptions, getTenantId:
6918
6996
 
6919
6997
  Available metrics servers:
6920
6998
  ${serverKeys.map(
6921
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
6999
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
6922
7000
  ).join("\n")}` : "";
6923
7001
  return tool11(
6924
7002
  async ({
@@ -7024,7 +7102,7 @@ var createQueryTableDefinitionTool = ({ serverKeys, serverDescriptions, getTenan
7024
7102
 
7025
7103
  Available metrics servers:
7026
7104
  ${serverKeys.map(
7027
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
7105
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
7028
7106
  ).join("\n")}` : "";
7029
7107
  return tool12(
7030
7108
  async ({
@@ -7164,7 +7242,7 @@ var createExecuteSqlQueryTool = ({ serverKeys, serverDescriptions, getTenantId:
7164
7242
 
7165
7243
  Available metrics servers:
7166
7244
  ${serverKeys.map(
7167
- (key4) => `- ${key4}${serverDescriptions?.[key4] ? `: ${serverDescriptions[key4]}` : ""}`
7245
+ (key5) => `- ${key5}${serverDescriptions?.[key5] ? `: ${serverDescriptions[key5]}` : ""}`
7168
7246
  ).join("\n")}` : "";
7169
7247
  return tool13(
7170
7248
  async ({
@@ -7457,24 +7535,24 @@ var SandboxLatticeManager = class _SandboxLatticeManager extends BaseLatticeMana
7457
7535
  getLatticeType() {
7458
7536
  return "sandbox_manager";
7459
7537
  }
7460
- registerLattice(key4, provider) {
7461
- this.register(key4, provider);
7538
+ registerLattice(key5, provider) {
7539
+ this.register(key5, provider);
7462
7540
  }
7463
- getSandboxLattice(key4) {
7464
- const lattice = this.get(key4);
7541
+ getSandboxLattice(key5) {
7542
+ const lattice = this.get(key5);
7465
7543
  if (!lattice) {
7466
- throw new Error(`SandboxLattice ${key4} not found`);
7544
+ throw new Error(`SandboxLattice ${key5} not found`);
7467
7545
  }
7468
7546
  return lattice;
7469
7547
  }
7470
7548
  getAllLattices() {
7471
7549
  return this.getAll();
7472
7550
  }
7473
- hasLattice(key4) {
7474
- return this.has(key4);
7551
+ hasLattice(key5) {
7552
+ return this.has(key5);
7475
7553
  }
7476
- removeLattice(key4) {
7477
- return this.remove(key4);
7554
+ removeLattice(key5) {
7555
+ return this.remove(key5);
7478
7556
  }
7479
7557
  clearLattices() {
7480
7558
  this.clear();
@@ -7599,10 +7677,10 @@ var SandboxLatticeManager = class _SandboxLatticeManager extends BaseLatticeMana
7599
7677
  }
7600
7678
  };
7601
7679
  var sandboxLatticeManager = SandboxLatticeManager.getInstance();
7602
- var getSandBoxManager = (key4 = "default") => {
7603
- if (!sandboxLatticeManager.hasLattice(key4)) {
7680
+ var getSandBoxManager = (key5 = "default") => {
7681
+ if (!sandboxLatticeManager.hasLattice(key5)) {
7604
7682
  throw new Error(
7605
- `Sandbox ${key4} not configured. Ensure the sandbox provider is registered.`
7683
+ `Sandbox ${key5} not configured. Ensure the sandbox provider is registered.`
7606
7684
  );
7607
7685
  }
7608
7686
  return sandboxLatticeManager;
@@ -9298,8 +9376,8 @@ async function describeImage(options) {
9298
9376
  // src/stt_model_lattice/STTModelLattice.ts
9299
9377
  import { OpenAIClient, toFile } from "@langchain/openai";
9300
9378
  var STTModelLattice = class {
9301
- constructor(key4, config) {
9302
- this.key = key4;
9379
+ constructor(key5, config) {
9380
+ this.key = key5;
9303
9381
  this.config = config;
9304
9382
  this.client = this;
9305
9383
  const apiKey = config.apiKey || (config.apiKeyEnvName ? process.env[config.apiKeyEnvName] : void 0) || process.env.OPENAI_API_KEY || "";
@@ -9411,45 +9489,45 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
9411
9489
  * @param key - Lattice key name
9412
9490
  * @param config - STT provider configuration
9413
9491
  */
9414
- registerLattice(key4, config) {
9415
- const client = new STTModelLattice(key4, config);
9416
- const label = config.model || key4;
9492
+ registerLattice(key5, config) {
9493
+ const client = new STTModelLattice(key5, config);
9494
+ const label = config.model || key5;
9417
9495
  const sttLattice = {
9418
- key: key4,
9496
+ key: key5,
9419
9497
  client,
9420
9498
  config,
9421
9499
  label
9422
9500
  };
9423
- this.register(key4, sttLattice);
9501
+ this.register(key5, sttLattice);
9424
9502
  }
9425
9503
  /**
9426
9504
  * Get an STT model lattice by key.
9427
9505
  */
9428
- getSTTModelLattice(key4) {
9429
- const lattice = this.get(key4);
9506
+ getSTTModelLattice(key5) {
9507
+ const lattice = this.get(key5);
9430
9508
  if (!lattice) {
9431
- throw new Error(`STTModelLattice "${key4}" not found`);
9509
+ throw new Error(`STTModelLattice "${key5}" not found`);
9432
9510
  }
9433
9511
  return lattice;
9434
9512
  }
9435
9513
  /**
9436
9514
  * Get STT client instance by key (default tenant).
9437
9515
  */
9438
- getSTTClient(key4) {
9439
- return this.getSTTModelLattice(key4).client;
9516
+ getSTTClient(key5) {
9517
+ return this.getSTTModelLattice(key5).client;
9440
9518
  }
9441
9519
  /**
9442
9520
  * Get STT client instance by key and tenant.
9443
9521
  * @param tenantId - Tenant ID for isolation
9444
9522
  * @param key - Lattice key name
9445
9523
  */
9446
- getSTTClientWithTenant(tenantId2, key4) {
9447
- let lattice = this.getWithTenant(tenantId2, key4);
9524
+ getSTTClientWithTenant(tenantId2, key5) {
9525
+ let lattice = this.getWithTenant(tenantId2, key5);
9448
9526
  if (!lattice && tenantId2 !== "default") {
9449
- lattice = this.getWithTenant("default", key4);
9527
+ lattice = this.getWithTenant("default", key5);
9450
9528
  }
9451
9529
  if (!lattice) {
9452
- throw new Error(`STTModelLattice "${key4}" not found for tenant "${tenantId2}"`);
9530
+ throw new Error(`STTModelLattice "${key5}" not found for tenant "${tenantId2}"`);
9453
9531
  }
9454
9532
  return lattice.client;
9455
9533
  }
@@ -9467,11 +9545,11 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
9467
9545
  getAllLattices() {
9468
9546
  return this.getAll();
9469
9547
  }
9470
- hasLattice(key4) {
9471
- return this.has(key4);
9548
+ hasLattice(key5) {
9549
+ return this.has(key5);
9472
9550
  }
9473
- removeLattice(key4) {
9474
- return this.remove(key4);
9551
+ removeLattice(key5) {
9552
+ return this.remove(key5);
9475
9553
  }
9476
9554
  clearLattices() {
9477
9555
  this.clear();
@@ -9484,10 +9562,10 @@ var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeMa
9484
9562
  }
9485
9563
  };
9486
9564
  var sttModelLatticeManager = STTModelLatticeManager.getInstance();
9487
- var registerSTTModelLattice = (key4, config) => sttModelLatticeManager.registerLattice(key4, config);
9488
- var getSTTModelLattice = (key4) => sttModelLatticeManager.getSTTModelLattice(key4);
9489
- var getSTTClient = (key4) => sttModelLatticeManager.getSTTClient(key4);
9490
- var getSTTClientWithTenant = (tenantId2, key4) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key4);
9565
+ var registerSTTModelLattice = (key5, config) => sttModelLatticeManager.registerLattice(key5, config);
9566
+ var getSTTModelLattice = (key5) => sttModelLatticeManager.getSTTModelLattice(key5);
9567
+ var getSTTClient = (key5) => sttModelLatticeManager.getSTTClient(key5);
9568
+ var getSTTClientWithTenant = (tenantId2, key5) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key5);
9491
9569
 
9492
9570
  // src/deep_agent_new/backends/transcribeAudio.ts
9493
9571
  async function transcribeAudio(options) {
@@ -9510,19 +9588,19 @@ var FileDataSchema = z310.object({
9510
9588
  function fileDataReducer(left, right) {
9511
9589
  if (left === void 0) {
9512
9590
  const result2 = {};
9513
- for (const [key4, value] of Object.entries(right)) {
9591
+ for (const [key5, value] of Object.entries(right)) {
9514
9592
  if (value !== null) {
9515
- result2[key4] = value;
9593
+ result2[key5] = value;
9516
9594
  }
9517
9595
  }
9518
9596
  return result2;
9519
9597
  }
9520
9598
  const result = { ...left };
9521
- for (const [key4, value] of Object.entries(right)) {
9599
+ for (const [key5, value] of Object.entries(right)) {
9522
9600
  if (value === null) {
9523
- delete result[key4];
9601
+ delete result[key5];
9524
9602
  } else {
9525
- result[key4] = value;
9603
+ result[key5] = value;
9526
9604
  }
9527
9605
  }
9528
9606
  return result;
@@ -9558,7 +9636,11 @@ Path conventions:
9558
9636
  - edit_file: edit a file in the filesystem
9559
9637
  - delete_file: permanently and irreversibly delete an existing regular file from the filesystem
9560
9638
  - glob: find files matching a pattern (e.g., "/project/**/*.py")
9561
- - grep: search for text within files`;
9639
+ - grep: search for text within files
9640
+
9641
+ Output formatting:
9642
+ - When mentioning or listing sandbox file paths (e.g. /project/notes/index.md) in your reply, write them as plain markdown text (inline or as a bullet list) so the UI renders them as clickable file links.
9643
+ - Never put a list of file paths inside a fenced code block (triple backticks): paths inside code blocks are not rendered clickable.`;
9562
9644
  var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
9563
9645
  var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file. For image files (png, jpg, gif, webp, bmp, svg), returns a visual description when the current model supports vision; otherwise returns an error suggesting a vision-capable model. For audio files (webm, wav, mp3, m4a, ogg, flac, aac, wma, opus, amr), transcribes the content using the default STT model; if none is registered, returns an error with registration instructions.";
9564
9646
  var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
@@ -10599,8 +10681,8 @@ var LEGACY_BOOTSTRAP_OVERRIDE_PATHS = {
10599
10681
  };
10600
10682
  function buildScaffoldContent(bootstrapFiles = {}) {
10601
10683
  const scaffoldContent = { ...DEFAULT_MD_FIRST_CONTENT };
10602
- for (const [key4, filePath] of Object.entries(LEGACY_BOOTSTRAP_OVERRIDE_PATHS)) {
10603
- const override = bootstrapFiles[key4];
10684
+ for (const [key5, filePath] of Object.entries(LEGACY_BOOTSTRAP_OVERRIDE_PATHS)) {
10685
+ const override = bootstrapFiles[key5];
10604
10686
  if (filePath && override !== void 0) {
10605
10687
  scaffoldContent[filePath] = override;
10606
10688
  }
@@ -11143,8 +11225,8 @@ function isMissingManifestError(error) {
11143
11225
  if (record.statusCode === 404 || record.status === 404 || record.code === "ENOENT") {
11144
11226
  return true;
11145
11227
  }
11146
- for (const key4 of ["message", "error", "body", "cause"]) {
11147
- if (key4 in record) values.push(record[key4]);
11228
+ for (const key5 of ["message", "error", "body", "cause"]) {
11229
+ if (key5 in record) values.push(record[key5]);
11148
11230
  }
11149
11231
  }
11150
11232
  return false;
@@ -11180,13 +11262,13 @@ function parseSkillFrontmatter(content) {
11180
11262
  if (currentKey === "metadata" && indent > metadataIndent) {
11181
11263
  const colonIndex2 = trimmed.indexOf(":");
11182
11264
  if (colonIndex2 !== -1) {
11183
- const key5 = trimmed.substring(0, colonIndex2).trim();
11265
+ const key6 = trimmed.substring(0, colonIndex2).trim();
11184
11266
  let value2 = trimmed.substring(colonIndex2 + 1).trim();
11185
11267
  if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
11186
11268
  value2 = value2.slice(1, -1);
11187
11269
  }
11188
11270
  if (!meta.metadata) meta.metadata = {};
11189
- meta.metadata[key5] = value2;
11271
+ meta.metadata[key6] = value2;
11190
11272
  }
11191
11273
  continue;
11192
11274
  }
@@ -11207,12 +11289,12 @@ function parseSkillFrontmatter(content) {
11207
11289
  }
11208
11290
  const colonIndex = trimmed.indexOf(":");
11209
11291
  if (colonIndex === -1) continue;
11210
- const key4 = trimmed.substring(0, colonIndex).trim();
11292
+ const key5 = trimmed.substring(0, colonIndex).trim();
11211
11293
  let value = trimmed.substring(colonIndex + 1).trim();
11212
11294
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
11213
11295
  value = value.slice(1, -1);
11214
11296
  }
11215
- if (key4 === "metadata") {
11297
+ if (key5 === "metadata") {
11216
11298
  if (value === "" || value === "{}") {
11217
11299
  if (i + 1 < lines.length && (lines[i + 1].match(/^(\s*)/)?.[1].length || 0) > indent) {
11218
11300
  currentKey = "metadata";
@@ -11222,7 +11304,7 @@ function parseSkillFrontmatter(content) {
11222
11304
  }
11223
11305
  }
11224
11306
  meta.metadata = value.startsWith("{") ? safeJsonParse(value, {}) : {};
11225
- } else if (key4 === "subSkills") {
11307
+ } else if (key5 === "subSkills") {
11226
11308
  if (value === "" || value === "[]") {
11227
11309
  if (i + 1 < lines.length && (lines[i + 1].match(/^(\s*)/)?.[1].length || 0) > indent && lines[i + 1].trim().startsWith("-")) {
11228
11310
  currentKey = "subSkills";
@@ -11233,7 +11315,7 @@ function parseSkillFrontmatter(content) {
11233
11315
  }
11234
11316
  meta.subSkills = value.startsWith("[") ? safeJsonParse(value, []) : [];
11235
11317
  } else {
11236
- meta[key4] = value;
11318
+ meta[key5] = value;
11237
11319
  }
11238
11320
  }
11239
11321
  return { meta, body };
@@ -11253,8 +11335,8 @@ function buildSkillFile(meta, body) {
11253
11335
  }
11254
11336
  if (meta.metadata && Object.keys(meta.metadata).length > 0) {
11255
11337
  lines.push("metadata:");
11256
- for (const [key4, value] of Object.entries(meta.metadata)) {
11257
- lines.push(` ${key4}: ${value}`);
11338
+ for (const [key5, value] of Object.entries(meta.metadata)) {
11339
+ lines.push(` ${key5}: ${value}`);
11258
11340
  }
11259
11341
  }
11260
11342
  if (meta.subSkills && meta.subSkills.length > 0) {
@@ -11292,54 +11374,54 @@ function validateSkillName2(name, pluginType) {
11292
11374
  var PluginRegistry = class {
11293
11375
  /** Register a plugin (overwrites if type conflicts) */
11294
11376
  static register(plugin) {
11295
- const key4 = plugin.meta.type;
11296
- if (!key4 || typeof key4 !== "string") {
11377
+ const key5 = plugin.meta.type;
11378
+ if (!key5 || typeof key5 !== "string") {
11297
11379
  throw new Error("Plugin type must be a non-empty string");
11298
11380
  }
11299
11381
  if (plugin.skills) {
11300
- const prefix = `${key4}-`;
11382
+ const prefix = `${key5}-`;
11301
11383
  for (const [name, definition] of Object.entries(plugin.skills)) {
11302
- validateSkillName2(name, key4);
11384
+ validateSkillName2(name, key5);
11303
11385
  if (!name.startsWith(prefix)) {
11304
11386
  throw new Error(
11305
- `Plugin "${key4}": skill "${name}" must start with "${prefix}". Skill names must be prefixed with the plugin type followed by a hyphen.`
11387
+ `Plugin "${key5}": skill "${name}" must start with "${prefix}". Skill names must be prefixed with the plugin type followed by a hyphen.`
11306
11388
  );
11307
11389
  }
11308
11390
  const rawDefinition = definition;
11309
11391
  if (!isRecord2(rawDefinition) || typeof rawDefinition.version !== "string" || rawDefinition.version.trim().length === 0 || typeof rawDefinition.content !== "string") {
11310
- throw new Error(`Plugin "${key4}": skill "${name}" version and content must be a string`);
11392
+ throw new Error(`Plugin "${key5}": skill "${name}" version and content must be a string`);
11311
11393
  }
11312
11394
  const resources3 = rawDefinition.resources;
11313
11395
  if (resources3 !== void 0 && !isRecord2(resources3)) {
11314
- throw new Error(`Plugin "${key4}": skill "${name}" resources must be an object`);
11396
+ throw new Error(`Plugin "${key5}": skill "${name}" resources must be an object`);
11315
11397
  }
11316
11398
  for (const [path8, resource] of Object.entries(resources3 ?? {})) {
11317
11399
  try {
11318
11400
  validateRelativePath(path8, "resource");
11319
11401
  } catch {
11320
- throw new Error(`Plugin "${key4}": resource path "${path8}" must be a safe relative path`);
11402
+ throw new Error(`Plugin "${key5}": resource path "${path8}" must be a safe relative path`);
11321
11403
  }
11322
11404
  if (!isRecord2(resource) || typeof resource.content !== "string") {
11323
- throw new Error(`Plugin "${key4}": resource "${path8}" content must be a string`);
11405
+ throw new Error(`Plugin "${key5}": resource "${path8}" content must be a string`);
11324
11406
  }
11325
11407
  if (resource.mimeType !== void 0 && typeof resource.mimeType !== "string") {
11326
- throw new Error(`Plugin "${key4}": resource "${path8}" mimeType must be a string`);
11408
+ throw new Error(`Plugin "${key5}": resource "${path8}" mimeType must be a string`);
11327
11409
  }
11328
11410
  }
11329
11411
  }
11330
11412
  }
11331
- if (this.plugins.has(key4)) {
11332
- console.warn(`[PluginRegistry] "${key4}" overwritten`);
11413
+ if (this.plugins.has(key5)) {
11414
+ console.warn(`[PluginRegistry] "${key5}" overwritten`);
11333
11415
  }
11334
- this.plugins.set(key4, plugin);
11416
+ this.plugins.set(key5, plugin);
11335
11417
  }
11336
11418
  /** Unregister */
11337
- static unregister(key4) {
11338
- return this.plugins.delete(key4);
11419
+ static unregister(key5) {
11420
+ return this.plugins.delete(key5);
11339
11421
  }
11340
11422
  /** Get plugin instance */
11341
- static get(key4) {
11342
- return this.plugins.get(key4);
11423
+ static get(key5) {
11424
+ return this.plugins.get(key5);
11343
11425
  }
11344
11426
  /** Get a plugin skill definition and its owning plugin type. */
11345
11427
  static getSkill(name) {
@@ -11362,8 +11444,8 @@ var PluginRegistry = class {
11362
11444
  return definition ? { pluginType, definition } : void 0;
11363
11445
  }
11364
11446
  /** Check if registered */
11365
- static has(key4) {
11366
- return this.plugins.has(key4);
11447
+ static has(key5) {
11448
+ return this.plugins.has(key5);
11367
11449
  }
11368
11450
  /** List all registered plugin keys */
11369
11451
  static list() {
@@ -11421,14 +11503,14 @@ var CustomMiddlewareRegistry = class {
11421
11503
  * @param factory - Function that receives config (minus `key`) and returns an AgentMiddleware
11422
11504
  * @param deprecatedMeta - Optional metadata for API discovery
11423
11505
  */
11424
- static register(key4, factory, deprecatedMeta) {
11425
- this.factories.set(key4, factory);
11426
- const existing = PluginRegistry.get(key4);
11506
+ static register(key5, factory, deprecatedMeta) {
11507
+ this.factories.set(key5, factory);
11508
+ const existing = PluginRegistry.get(key5);
11427
11509
  if (existing) return;
11428
11510
  const plugin = {
11429
11511
  meta: {
11430
- type: key4,
11431
- name: deprecatedMeta?.name || key4,
11512
+ type: key5,
11513
+ name: deprecatedMeta?.name || key5,
11432
11514
  description: deprecatedMeta?.description || "",
11433
11515
  version: deprecatedMeta?.version,
11434
11516
  source: deprecatedMeta?.source,
@@ -11446,9 +11528,9 @@ var CustomMiddlewareRegistry = class {
11446
11528
  * @param key - The factory key to unregister
11447
11529
  * @returns `true` if a factory was removed, `false` if the key was not found
11448
11530
  */
11449
- static unregister(key4) {
11450
- PluginRegistry.unregister(key4);
11451
- return this.factories.delete(key4);
11531
+ static unregister(key5) {
11532
+ PluginRegistry.unregister(key5);
11533
+ return this.factories.delete(key5);
11452
11534
  }
11453
11535
  /**
11454
11536
  * Look up a factory by key.
@@ -11456,10 +11538,10 @@ var CustomMiddlewareRegistry = class {
11456
11538
  * @param key - The factory key
11457
11539
  * @returns The factory function, or `undefined` if not registered
11458
11540
  */
11459
- static get(key4) {
11460
- const factory = this.factories.get(key4);
11541
+ static get(key5) {
11542
+ const factory = this.factories.get(key5);
11461
11543
  if (factory) return factory;
11462
- const plugin = PluginRegistry.get(key4);
11544
+ const plugin = PluginRegistry.get(key5);
11463
11545
  if (plugin?.middleware) {
11464
11546
  return ((config) => plugin.middleware(config));
11465
11547
  }
@@ -11468,8 +11550,8 @@ var CustomMiddlewareRegistry = class {
11468
11550
  /**
11469
11551
  * Check whether a factory is registered under the given key.
11470
11552
  */
11471
- static has(key4) {
11472
- return this.factories.has(key4) || PluginRegistry.has(key4);
11553
+ static has(key5) {
11554
+ return this.factories.has(key5) || PluginRegistry.has(key5);
11473
11555
  }
11474
11556
  /**
11475
11557
  * Get all currently registered factory keys.
@@ -11491,21 +11573,21 @@ var ConnectionRegistry = class {
11491
11573
  this.ensureStore();
11492
11574
  return this.store.listByType(tenantId2, type);
11493
11575
  }
11494
- static async get(type, key4, tenantId2) {
11576
+ static async get(type, key5, tenantId2) {
11495
11577
  this.ensureStore();
11496
- return this.store.getByKey(tenantId2, type, key4);
11578
+ return this.store.getByKey(tenantId2, type, key5);
11497
11579
  }
11498
11580
  static async create(entry) {
11499
11581
  this.ensureStore();
11500
11582
  return this.store.create(entry);
11501
11583
  }
11502
- static async update(tenantId2, type, key4, updates) {
11584
+ static async update(tenantId2, type, key5, updates) {
11503
11585
  this.ensureStore();
11504
- return this.store.update(tenantId2, type, key4, updates);
11586
+ return this.store.update(tenantId2, type, key5, updates);
11505
11587
  }
11506
- static async delete(tenantId2, type, key4) {
11588
+ static async delete(tenantId2, type, key5) {
11507
11589
  this.ensureStore();
11508
- return this.store.delete(tenantId2, type, key4);
11590
+ return this.store.delete(tenantId2, type, key5);
11509
11591
  }
11510
11592
  static ensureStore() {
11511
11593
  if (!this.store) throw new Error("ConnectionStore not configured");
@@ -11792,7 +11874,7 @@ async function standardConnectionAllowed(request, capabilityType, config) {
11792
11874
  (connection2) => connection2.key === resource && connection2.type === capabilityType && connection2.tenantId === tenantId2
11793
11875
  );
11794
11876
  }
11795
- if (!Array.isArray(config.connections) || !config.connections.every((key4) => typeof key4 === "string")) {
11877
+ if (!Array.isArray(config.connections) || !config.connections.every((key5) => typeof key5 === "string")) {
11796
11878
  return false;
11797
11879
  }
11798
11880
  if (!config.connections.includes(resource)) return false;
@@ -11992,15 +12074,15 @@ function normalizeLegacyTaskMiddlewareTools(middlewareConfigs) {
11992
12074
  for (let keyIndex = 0; keyIndex < descriptorKeyCount; keyIndex += 1) {
11993
12075
  const keyElement = readOwnArrayElement(descriptorKeys, keyIndex);
11994
12076
  if (!keyElement.found) continue;
11995
- const key4 = keyElement.value;
11996
- if (typeof key4 !== "string" && typeof key4 !== "symbol") continue;
11997
- if (key4 === "allowedTools") continue;
11998
- const bagEntry = getOwnPropertyDescriptor(descriptors, key4);
12077
+ const key5 = keyElement.value;
12078
+ if (typeof key5 !== "string" && typeof key5 !== "symbol") continue;
12079
+ if (key5 === "allowedTools") continue;
12080
+ const bagEntry = getOwnPropertyDescriptor(descriptors, key5);
11999
12081
  const originalDescriptor = readOwnDescriptorField(bagEntry, "value");
12000
12082
  if (!originalDescriptor.found || !originalDescriptor.value) continue;
12001
12083
  defineProperty(
12002
12084
  clone3,
12003
- key4,
12085
+ key5,
12004
12086
  sanitizePropertyDescriptor(originalDescriptor.value)
12005
12087
  );
12006
12088
  }
@@ -12208,11 +12290,11 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
12208
12290
  case "custom":
12209
12291
  {
12210
12292
  const customConfig = config.config;
12211
- const { key: key4, ...rest } = customConfig;
12212
- const factory = CustomMiddlewareRegistry.get(key4);
12293
+ const { key: key5, ...rest } = customConfig;
12294
+ const factory = CustomMiddlewareRegistry.get(key5);
12213
12295
  if (factory) {
12214
12296
  if (rest.connections?.length && tenantId2) {
12215
- const resolved = await resolveConnections(key4, rest.connections, tenantId2);
12297
+ const resolved = await resolveConnections(key5, rest.connections, tenantId2);
12216
12298
  rest._resolvedConnections = resolved ?? [];
12217
12299
  }
12218
12300
  const middleware = factory(rest);
@@ -12222,7 +12304,7 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend, fsI
12222
12304
  );
12223
12305
  } else {
12224
12306
  console.warn(
12225
- `[custom middleware] No factory registered for key "${key4}". Use CustomMiddlewareRegistry.register("${key4}", factory) before building the agent.`
12307
+ `[custom middleware] No factory registered for key "${key5}". Use CustomMiddlewareRegistry.register("${key5}", factory) before building the agent.`
12226
12308
  );
12227
12309
  }
12228
12310
  }
@@ -12624,7 +12706,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
12624
12706
  * @param client Optional queue client. If not provided, will create based on config type.
12625
12707
  * For REDIS type, client must be provided (use @axiom-lattice/queue-redis).
12626
12708
  */
12627
- registerLattice(key4, config, client) {
12709
+ registerLattice(key5, config, client) {
12628
12710
  let queueClient;
12629
12711
  if (client) {
12630
12712
  queueClient = client;
@@ -12639,7 +12721,7 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
12639
12721
  }
12640
12722
  }
12641
12723
  const queueLattice = {
12642
- key: key4,
12724
+ key: key5,
12643
12725
  config,
12644
12726
  client: queueClient,
12645
12727
  push: async (item) => {
@@ -12652,16 +12734,16 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
12652
12734
  return queueClient.createQueue();
12653
12735
  } : void 0
12654
12736
  };
12655
- this.register(key4, queueLattice);
12737
+ this.register(key5, queueLattice);
12656
12738
  }
12657
12739
  /**
12658
12740
  * Get QueueLattice
12659
12741
  * @param key Lattice key name
12660
12742
  */
12661
- getQueueLattice(key4) {
12662
- const queueLattice = this.get(key4);
12743
+ getQueueLattice(key5) {
12744
+ const queueLattice = this.get(key5);
12663
12745
  if (!queueLattice) {
12664
- throw new Error(`QueueLattice ${key4} not found`);
12746
+ throw new Error(`QueueLattice ${key5} not found`);
12665
12747
  }
12666
12748
  return queueLattice;
12667
12749
  }
@@ -12675,15 +12757,15 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
12675
12757
  * Check if Lattice exists
12676
12758
  * @param key Lattice key name
12677
12759
  */
12678
- hasLattice(key4) {
12679
- return this.has(key4);
12760
+ hasLattice(key5) {
12761
+ return this.has(key5);
12680
12762
  }
12681
12763
  /**
12682
12764
  * Remove Lattice
12683
12765
  * @param key Lattice key name
12684
12766
  */
12685
- removeLattice(key4) {
12686
- return this.remove(key4);
12767
+ removeLattice(key5) {
12768
+ return this.remove(key5);
12687
12769
  }
12688
12770
  /**
12689
12771
  * Clear all Lattices
@@ -12705,8 +12787,8 @@ var QueueLatticeManager = class _QueueLatticeManager extends BaseLatticeManager
12705
12787
  }
12706
12788
  };
12707
12789
  var queueLatticeManager = QueueLatticeManager.getInstance();
12708
- var registerQueueLattice = (key4, config, client) => queueLatticeManager.registerLattice(key4, config, client);
12709
- var getQueueLattice = (key4) => queueLatticeManager.getQueueLattice(key4);
12790
+ var registerQueueLattice = (key5, config, client) => queueLatticeManager.registerLattice(key5, config, client);
12791
+ var getQueueLattice = (key5) => queueLatticeManager.getQueueLattice(key5);
12710
12792
 
12711
12793
  // src/services/event_bus.ts
12712
12794
  var EventBus = class {
@@ -13232,9 +13314,9 @@ var ChunkBufferLatticeManager = class _ChunkBufferLatticeManager extends BaseLat
13232
13314
  return "chunk_buffer";
13233
13315
  }
13234
13316
  };
13235
- var getChunkBuffer = (key4) => ChunkBufferLatticeManager.getInstance().get(key4);
13236
- var registerChunkBuffer = (key4, buffer2) => ChunkBufferLatticeManager.getInstance().register(key4, buffer2);
13237
- var hasChunkBuffer = (key4) => ChunkBufferLatticeManager.getInstance().has(key4);
13317
+ var getChunkBuffer = (key5) => ChunkBufferLatticeManager.getInstance().get(key5);
13318
+ var registerChunkBuffer = (key5, buffer2) => ChunkBufferLatticeManager.getInstance().register(key5, buffer2);
13319
+ var hasChunkBuffer = (key5) => ChunkBufferLatticeManager.getInstance().has(key5);
13238
13320
  var buffer = new InMemoryChunkBuffer({
13239
13321
  ttl: 60 * 60 * 1e3,
13240
13322
  // 1 hour TTL
@@ -13285,8 +13367,8 @@ var COMPOUND_CREDENTIAL_SUFFIXES = [
13285
13367
  "dbpassword",
13286
13368
  "clientsecret"
13287
13369
  ];
13288
- function isCredentialBearingKey(key4) {
13289
- const normalizedKey = key4.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
13370
+ function isCredentialBearingKey(key5) {
13371
+ const normalizedKey = key5.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
13290
13372
  if (normalizedKey.endsWith("credentialid") || normalizedKey.endsWith("credentialreference")) {
13291
13373
  return false;
13292
13374
  }
@@ -13377,21 +13459,21 @@ function validateConfigValue(value, path8, capabilityType, activeAncestors, stat
13377
13459
  return;
13378
13460
  }
13379
13461
  try {
13380
- for (const [key4, entry] of Object.entries(value)) {
13381
- const nextPath = pointer(path8, key4);
13382
- if (UNSAFE_KEYS.has(key4)) {
13462
+ for (const [key5, entry] of Object.entries(value)) {
13463
+ const nextPath = pointer(path8, key5);
13464
+ if (UNSAFE_KEYS.has(key5)) {
13383
13465
  throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_UNSAFE_KEY", `Unsafe key at ${nextPath}`, {
13384
13466
  capabilityType,
13385
13467
  fieldPath: nextPath
13386
13468
  });
13387
13469
  }
13388
- if (BUNDLE_REFERENCE_KEYS.has(key4)) {
13470
+ if (BUNDLE_REFERENCE_KEYS.has(key5)) {
13389
13471
  throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_NESTED_REFERENCE", `Nested bundle reference at ${nextPath}`, {
13390
13472
  capabilityType,
13391
13473
  fieldPath: nextPath
13392
13474
  });
13393
13475
  }
13394
- if (isCredentialBearingKey(key4)) {
13476
+ if (isCredentialBearingKey(key5)) {
13395
13477
  throw new CapabilityBundleValidationError(
13396
13478
  "CAPABILITY_BUNDLE_CREDENTIALS_FORBIDDEN",
13397
13479
  `Credential-like field is forbidden at ${nextPath}`,
@@ -13452,33 +13534,33 @@ function validateSchemaTypes(value, schema6, path8, capabilityType, isTopLevelCo
13452
13534
  if (type === "object" && typeof value === "object" && value !== null && !Array.isArray(value)) {
13453
13535
  const properties = schema6.properties && typeof schema6.properties === "object" ? schema6.properties : {};
13454
13536
  if (Array.isArray(schema6.required)) {
13455
- for (const key4 of schema6.required) {
13456
- if (typeof key4 === "string" && !Object.prototype.hasOwnProperty.call(value, key4)) {
13457
- throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_INVALID_CONFIG", `Required config value is missing at ${pointer(path8, key4)}`, {
13537
+ for (const key5 of schema6.required) {
13538
+ if (typeof key5 === "string" && !Object.prototype.hasOwnProperty.call(value, key5)) {
13539
+ throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_INVALID_CONFIG", `Required config value is missing at ${pointer(path8, key5)}`, {
13458
13540
  capabilityType,
13459
- fieldPath: pointer(path8, key4)
13541
+ fieldPath: pointer(path8, key5)
13460
13542
  });
13461
13543
  }
13462
13544
  }
13463
13545
  }
13464
13546
  if (schema6.additionalProperties === false) {
13465
- for (const key4 of Object.keys(value)) {
13466
- if (!Object.prototype.hasOwnProperty.call(properties, key4) && (!isTopLevelConfig || !Object.prototype.hasOwnProperty.call(STANDARD_CONFIG_TYPES, key4))) {
13467
- throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_INVALID_CONFIG", `Unknown config value at ${pointer(path8, key4)}`, {
13547
+ for (const key5 of Object.keys(value)) {
13548
+ if (!Object.prototype.hasOwnProperty.call(properties, key5) && (!isTopLevelConfig || !Object.prototype.hasOwnProperty.call(STANDARD_CONFIG_TYPES, key5))) {
13549
+ throw new CapabilityBundleValidationError("CAPABILITY_BUNDLE_INVALID_CONFIG", `Unknown config value at ${pointer(path8, key5)}`, {
13468
13550
  capabilityType,
13469
- fieldPath: pointer(path8, key4)
13551
+ fieldPath: pointer(path8, key5)
13470
13552
  });
13471
13553
  }
13472
13554
  }
13473
13555
  }
13474
13556
  }
13475
13557
  if (type === "object" && schema6.properties && typeof schema6.properties === "object" && typeof value === "object" && value !== null) {
13476
- for (const [key4, childSchema] of Object.entries(schema6.properties)) {
13477
- if (Object.prototype.hasOwnProperty.call(value, key4)) {
13558
+ for (const [key5, childSchema] of Object.entries(schema6.properties)) {
13559
+ if (Object.prototype.hasOwnProperty.call(value, key5)) {
13478
13560
  validateSchemaTypes(
13479
- value[key4],
13561
+ value[key5],
13480
13562
  childSchema,
13481
- pointer(path8, key4),
13563
+ pointer(path8, key5),
13482
13564
  capabilityType,
13483
13565
  false
13484
13566
  );
@@ -13494,11 +13576,11 @@ function validateKnownConfigTypes(config, capabilityType, path8) {
13494
13576
  ...LEGACY_PLUGIN_CONNECTION_FIELDS[capabilityType].allowAllField ? { [LEGACY_PLUGIN_CONNECTION_FIELDS[capabilityType].allowAllField]: "boolean" } : {}
13495
13577
  } : {}
13496
13578
  };
13497
- for (const [key4, expected] of Object.entries(expectedTypes)) {
13498
- const value = config[key4];
13579
+ for (const [key5, expected] of Object.entries(expectedTypes)) {
13580
+ const value = config[key5];
13499
13581
  const invalid = expected === "array" ? !Array.isArray(value) || value.some((entry) => typeof entry !== "string") : typeof value !== expected;
13500
- if (Object.prototype.hasOwnProperty.call(config, key4) && invalid) {
13501
- const fieldPath = pointer(path8, key4);
13582
+ if (Object.prototype.hasOwnProperty.call(config, key5) && invalid) {
13583
+ const fieldPath = pointer(path8, key5);
13502
13584
  throw new CapabilityBundleValidationError(
13503
13585
  "CAPABILITY_BUNDLE_INVALID_CONFIG",
13504
13586
  `Config value at ${fieldPath} does not match plugin schema`,
@@ -13526,19 +13608,19 @@ function validateCapability(value, index) {
13526
13608
  fieldPath: `/capabilities/${index}/type`
13527
13609
  });
13528
13610
  }
13529
- for (const key4 of Object.keys(capability)) {
13530
- if (isCredentialBearingKey(key4)) {
13611
+ for (const key5 of Object.keys(capability)) {
13612
+ if (isCredentialBearingKey(key5)) {
13531
13613
  throw new CapabilityBundleValidationError(
13532
13614
  "CAPABILITY_BUNDLE_CREDENTIALS_FORBIDDEN",
13533
- `Credential-like field is forbidden at /capabilities/${index}/${key4}`,
13534
- { capabilityType, fieldPath: `/capabilities/${index}/${key4}` }
13615
+ `Credential-like field is forbidden at /capabilities/${index}/${key5}`,
13616
+ { capabilityType, fieldPath: `/capabilities/${index}/${key5}` }
13535
13617
  );
13536
13618
  }
13537
- if (!CAPABILITY_FIELDS.has(key4)) {
13619
+ if (!CAPABILITY_FIELDS.has(key5)) {
13538
13620
  throw new CapabilityBundleValidationError(
13539
13621
  "CAPABILITY_BUNDLE_INVALID_CAPABILITY",
13540
- `Unknown capability field at /capabilities/${index}/${key4}`,
13541
- { capabilityType, fieldPath: `/capabilities/${index}/${key4}` }
13622
+ `Unknown capability field at /capabilities/${index}/${key5}`,
13623
+ { capabilityType, fieldPath: `/capabilities/${index}/${key5}` }
13542
13624
  );
13543
13625
  }
13544
13626
  }
@@ -13677,7 +13759,7 @@ var CapabilityBundleMergeError = class extends Error {
13677
13759
  function canonicalize(value) {
13678
13760
  if (Array.isArray(value)) return value.map(canonicalize);
13679
13761
  if (typeof value === "object" && value !== null) {
13680
- return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key4, entry]) => [key4, canonicalize(entry)]));
13762
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key5, entry]) => [key5, canonicalize(entry)]));
13681
13763
  }
13682
13764
  return value;
13683
13765
  }
@@ -13691,8 +13773,8 @@ function createCapabilityRevision(bundles, effectivePolicy) {
13691
13773
  var LEGACY_UNION_CONFIG_FIELDS = new Set(
13692
13774
  Object.values(LEGACY_PLUGIN_CONNECTION_FIELDS).map(({ selectorField }) => selectorField)
13693
13775
  );
13694
- function isStandardConfigField(key4) {
13695
- return key4 === "connections";
13776
+ function isStandardConfigField(key5) {
13777
+ return key5 === "connections";
13696
13778
  }
13697
13779
  var OR_CONFIG_FIELDS = /* @__PURE__ */ new Set(["connectAll", "readAll"]);
13698
13780
  var UNSAFE_CONFIG_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
@@ -13706,8 +13788,8 @@ function cloneValue(value) {
13706
13788
  }
13707
13789
  if (typeof value === "object" && value !== null) {
13708
13790
  const clone3 = {};
13709
- for (const [key4, entry] of Object.entries(value)) {
13710
- clone3[key4] = cloneValue(entry);
13791
+ for (const [key5, entry] of Object.entries(value)) {
13792
+ clone3[key5] = cloneValue(entry);
13711
13793
  }
13712
13794
  return clone3;
13713
13795
  }
@@ -13733,10 +13815,10 @@ function validateValue(value, bundleId, capabilityType, displayPath, fieldPath,
13733
13815
  return;
13734
13816
  }
13735
13817
  if (typeof value === "object") {
13736
- for (const [key4, entry] of Object.entries(value)) {
13737
- const nextDisplayPath = `${displayPath}.${key4}`;
13738
- const nextFieldPath = appendPointer(fieldPath, key4);
13739
- if (rejectUnsafeKeys && UNSAFE_CONFIG_KEYS.has(key4)) {
13818
+ for (const [key5, entry] of Object.entries(value)) {
13819
+ const nextDisplayPath = `${displayPath}.${key5}`;
13820
+ const nextFieldPath = appendPointer(fieldPath, key5);
13821
+ if (rejectUnsafeKeys && UNSAFE_CONFIG_KEYS.has(key5)) {
13740
13822
  throw new CapabilityBundleMergeError(
13741
13823
  "CAPABILITY_BUNDLE_UNSAFE_KEY",
13742
13824
  `Capability bundle '${bundleId}' contains unsafe key at ${nextDisplayPath}`,
@@ -13795,21 +13877,21 @@ function mergeUnion(current, next, sources, capabilityType, fieldPath, bundleId)
13795
13877
  return result;
13796
13878
  }
13797
13879
  function mergeObject(target, incoming, sources, overrides, capabilityType, bundleId, path8) {
13798
- for (const [key4, next] of Object.entries(incoming)) {
13880
+ for (const [key5, next] of Object.entries(incoming)) {
13799
13881
  if (next === void 0) continue;
13800
- const fieldPath = appendPointer(path8, key4);
13801
- const current = target[key4];
13802
- if (path8 === "/config" && (isStandardConfigField(key4) || LEGACY_UNION_CONFIG_FIELDS.has(key4)) && Array.isArray(next)) {
13803
- target[key4] = mergeUnion(current, next, sources, capabilityType, fieldPath, bundleId);
13882
+ const fieldPath = appendPointer(path8, key5);
13883
+ const current = target[key5];
13884
+ if (path8 === "/config" && (isStandardConfigField(key5) || LEGACY_UNION_CONFIG_FIELDS.has(key5)) && Array.isArray(next)) {
13885
+ target[key5] = mergeUnion(current, next, sources, capabilityType, fieldPath, bundleId);
13804
13886
  continue;
13805
13887
  }
13806
- if (path8 === "/config" && OR_CONFIG_FIELDS.has(key4) && typeof next === "boolean") {
13888
+ if (path8 === "/config" && OR_CONFIG_FIELDS.has(key5) && typeof next === "boolean") {
13807
13889
  if (next && current !== true) {
13808
13890
  setOrdinarySource(sources, capabilityType, fieldPath, bundleId, true);
13809
13891
  } else if (current === void 0) {
13810
13892
  setOrdinarySource(sources, capabilityType, fieldPath, bundleId, false);
13811
13893
  }
13812
- target[key4] = current === true || next;
13894
+ target[key5] = current === true || next;
13813
13895
  continue;
13814
13896
  }
13815
13897
  if (typeof next === "object" && next !== null && !Array.isArray(next)) {
@@ -13825,10 +13907,10 @@ function mergeObject(target, incoming, sources, overrides, capabilityType, bundl
13825
13907
  }
13826
13908
  if (!currentIsObject) {
13827
13909
  removeOrdinarySource(sources, capabilityType, fieldPath);
13828
- target[key4] = {};
13910
+ target[key5] = {};
13829
13911
  }
13830
13912
  mergeObject(
13831
- target[key4],
13913
+ target[key5],
13832
13914
  next,
13833
13915
  sources,
13834
13916
  overrides,
@@ -13847,7 +13929,7 @@ function mergeObject(target, incoming, sources, overrides, capabilityType, bundl
13847
13929
  sourceBundleId: bundleId
13848
13930
  });
13849
13931
  }
13850
- target[key4] = cloneValue(next);
13932
+ target[key5] = cloneValue(next);
13851
13933
  setOrdinarySource(sources, capabilityType, fieldPath, bundleId, next);
13852
13934
  }
13853
13935
  }
@@ -14265,8 +14347,8 @@ var CallerRunConfigValidationError = class extends Error {
14265
14347
  this.name = "CallerRunConfigValidationError";
14266
14348
  }
14267
14349
  };
14268
- function callerRunConfigPath(path8, key4) {
14269
- return `${path8}/${key4.replace(/~/g, "~0").replace(/\//g, "~1")}`;
14350
+ function callerRunConfigPath(path8, key5) {
14351
+ return `${path8}/${key5.replace(/~/g, "~0").replace(/\//g, "~1")}`;
14270
14352
  }
14271
14353
  function cloneRunConfig(value, stripReserved) {
14272
14354
  if (value === void 0 || value === null || typeof value !== "object") return {};
@@ -14306,26 +14388,26 @@ function cloneRunConfig(value, stripReserved) {
14306
14388
  }
14307
14389
  const clone4 = [];
14308
14390
  for (let index = 0; index < length; index += 1) {
14309
- const key4 = String(index);
14310
- const data = descriptorDataValue(descriptors[key4]);
14391
+ const key5 = String(index);
14392
+ const data = descriptorDataValue(descriptors[key5]);
14311
14393
  if (!data || data.value === void 0) {
14312
- throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key4}`);
14394
+ throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}/${key5}`);
14313
14395
  }
14314
- clone4.push(cloneAndStrip(data.value, `${path8}/${key4}`, true));
14396
+ clone4.push(cloneAndStrip(data.value, `${path8}/${key5}`, true));
14315
14397
  }
14316
- if (keys.some((key4) => typeof key4 !== "string" || key4 !== "length" && !/^(0|[1-9]\d*)$/.test(key4))) {
14398
+ if (keys.some((key5) => typeof key5 !== "string" || key5 !== "length" && !/^(0|[1-9]\d*)$/.test(key5))) {
14317
14399
  throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}`);
14318
14400
  }
14319
14401
  return clone4;
14320
14402
  }
14321
14403
  const clone3 = /* @__PURE__ */ Object.create(null);
14322
- for (const key4 of keys) {
14323
- if (typeof key4 !== "string") continue;
14324
- const fieldPath = callerRunConfigPath(path8, key4);
14325
- const data = descriptorDataValue(descriptors[key4]);
14404
+ for (const key5 of keys) {
14405
+ if (typeof key5 !== "string") continue;
14406
+ const fieldPath = callerRunConfigPath(path8, key5);
14407
+ const data = descriptorDataValue(descriptors[key5]);
14326
14408
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
14327
- if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key4) || data.value === void 0) continue;
14328
- Object.defineProperty(clone3, key4, {
14409
+ if (stripReserved && RESERVED_CALLER_RUN_KEYS.has(key5) || data.value === void 0) continue;
14410
+ Object.defineProperty(clone3, key5, {
14329
14411
  value: cloneAndStrip(data.value, fieldPath),
14330
14412
  enumerable: true,
14331
14413
  configurable: true,
@@ -14371,15 +14453,15 @@ function sanitizeCallerRunConfig(value, preserveDelegatedContext = true) {
14371
14453
  } catch {
14372
14454
  throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}`);
14373
14455
  }
14374
- for (const key4 of Reflect.ownKeys(descriptors)) {
14375
- if (typeof key4 !== "string") {
14456
+ for (const key5 of Reflect.ownKeys(descriptors)) {
14457
+ if (typeof key5 !== "string") {
14376
14458
  throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${path8}`);
14377
14459
  }
14378
- const fieldPath = callerRunConfigPath(path8, key4);
14379
- const descriptor = descriptors[key4];
14460
+ const fieldPath = callerRunConfigPath(path8, key5);
14461
+ const descriptor = descriptors[key5];
14380
14462
  const data = descriptorDataValue(descriptor);
14381
14463
  if (!data) throw new CallerRunConfigValidationError(`Unsupported caller run config value at ${fieldPath}`);
14382
- if (isCredentialBearingKey(key4)) {
14464
+ if (isCredentialBearingKey(key5)) {
14383
14465
  throw new CapabilityRuntimeResolutionError(
14384
14466
  "CAPABILITY_BUNDLE_CREDENTIALS_FORBIDDEN",
14385
14467
  `Credential-like caller field is forbidden at ${fieldPath}`,
@@ -14407,16 +14489,16 @@ function cloneExecutionRunConfigBase(value) {
14407
14489
  try {
14408
14490
  const descriptors = Object.getOwnPropertyDescriptors(value);
14409
14491
  const clone3 = /* @__PURE__ */ Object.create(null);
14410
- for (const key4 of Reflect.ownKeys(descriptors)) {
14411
- if (typeof key4 !== "string" && key4 !== DELEGATED_WORKER_SCOPE_TOKEN) {
14492
+ for (const key5 of Reflect.ownKeys(descriptors)) {
14493
+ if (typeof key5 !== "string" && key5 !== DELEGATED_WORKER_SCOPE_TOKEN) {
14412
14494
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
14413
14495
  }
14414
- const descriptor = descriptors[key4];
14496
+ const descriptor = descriptors[key5];
14415
14497
  const data = descriptorDataValue(descriptor);
14416
14498
  if (!data) {
14417
14499
  throw new CallerRunConfigValidationError("Unsupported caller run config value at /run_config");
14418
14500
  }
14419
- Object.defineProperty(clone3, key4, {
14501
+ Object.defineProperty(clone3, key5, {
14420
14502
  value: data.value,
14421
14503
  enumerable: true,
14422
14504
  configurable: true,
@@ -14495,10 +14577,10 @@ var DelegatedScopeNotQueueableError = class extends Error {
14495
14577
  this.name = "DelegatedScopeNotQueueableError";
14496
14578
  }
14497
14579
  };
14498
- function ownDataValue(value, key4) {
14580
+ function ownDataValue(value, key5) {
14499
14581
  if (typeof value !== "object" || value === null) return void 0;
14500
14582
  try {
14501
- return descriptorDataValue(Object.getOwnPropertyDescriptor(value, key4))?.value;
14583
+ return descriptorDataValue(Object.getOwnPropertyDescriptor(value, key5))?.value;
14502
14584
  } catch {
14503
14585
  return void 0;
14504
14586
  }
@@ -14514,7 +14596,7 @@ var QUEUE_PROCESSOR_RETRY_BASE_MS = 100;
14514
14596
  var QUEUE_PROCESSOR_MAX_RETRIES = 3;
14515
14597
  function hasExactKeys(record, required, optional = []) {
14516
14598
  const allowed = /* @__PURE__ */ new Set([...required, ...optional]);
14517
- return required.every((key4) => Object.prototype.hasOwnProperty.call(record, key4)) && Reflect.ownKeys(record).every((key4) => typeof key4 === "string" && allowed.has(key4));
14599
+ return required.every((key5) => Object.prototype.hasOwnProperty.call(record, key5)) && Reflect.ownKeys(record).every((key5) => typeof key5 === "string" && allowed.has(key5));
14518
14600
  }
14519
14601
  var Agent = class {
14520
14602
  /**
@@ -16106,29 +16188,29 @@ var AgentInstanceManager = class _AgentInstanceManager {
16106
16188
  * Ensures only one instance per thread exists
16107
16189
  */
16108
16190
  getAgent(params) {
16109
- const key4 = this.getKey(params);
16110
- if (!this.agents.has(key4)) {
16191
+ const key5 = this.getKey(params);
16192
+ if (!this.agents.has(key5)) {
16111
16193
  const agent = new Agent(params);
16112
- this.agents.set(key4, agent);
16194
+ this.agents.set(key5, agent);
16113
16195
  }
16114
- return this.agents.get(key4);
16196
+ return this.agents.get(key5);
16115
16197
  }
16116
16198
  /**
16117
16199
  * Check if an agent instance exists for the thread
16118
16200
  */
16119
16201
  hasAgent(params) {
16120
- const key4 = this.getKey(params);
16121
- return this.agents.has(key4);
16202
+ const key5 = this.getKey(params);
16203
+ return this.agents.has(key5);
16122
16204
  }
16123
16205
  /**
16124
16206
  * Remove agent instance (for cleanup)
16125
16207
  */
16126
16208
  removeAgent(params) {
16127
- const key4 = this.getKey(params);
16128
- const agent = this.agents.get(key4);
16209
+ const key5 = this.getKey(params);
16210
+ const agent = this.agents.get(key5);
16129
16211
  if (agent) {
16130
16212
  agent.stopQueueProcessor();
16131
- this.agents.delete(key4);
16213
+ this.agents.delete(key5);
16132
16214
  return true;
16133
16215
  }
16134
16216
  return false;
@@ -16346,9 +16428,9 @@ When NOT to use the task tool:
16346
16428
  - You should use the \`task\` tool whenever you have a complex task that will take multiple steps, and is independent from other tasks that the agent needs to complete. These agents are highly competent and efficient.`;
16347
16429
  function filterStateForSubagent(state) {
16348
16430
  const filtered = {};
16349
- for (const [key4, value] of Object.entries(state)) {
16350
- if (!EXCLUDED_STATE_KEYS.includes(key4)) {
16351
- filtered[key4] = value;
16431
+ for (const [key5, value] of Object.entries(state)) {
16432
+ if (!EXCLUDED_STATE_KEYS.includes(key5)) {
16433
+ filtered[key5] = value;
16352
16434
  }
16353
16435
  }
16354
16436
  return filtered;
@@ -17856,7 +17938,7 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
17856
17938
  * @param config Schedule configuration
17857
17939
  * @param client Optional schedule client. If not provided, will create based on config type.
17858
17940
  */
17859
- registerLattice(key4, config, client) {
17941
+ registerLattice(key5, config, client) {
17860
17942
  let scheduleClient;
17861
17943
  if (client) {
17862
17944
  scheduleClient = client;
@@ -17884,7 +17966,7 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
17884
17966
  }
17885
17967
  }
17886
17968
  const scheduleLattice = {
17887
- key: key4,
17969
+ key: key5,
17888
17970
  config,
17889
17971
  client: scheduleClient,
17890
17972
  // Handler registration
@@ -17941,16 +18023,16 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
17941
18023
  return scheduleClient.restore();
17942
18024
  }
17943
18025
  };
17944
- this.register(key4, scheduleLattice);
18026
+ this.register(key5, scheduleLattice);
17945
18027
  }
17946
18028
  /**
17947
18029
  * Get ScheduleLattice
17948
18030
  * @param key Lattice key name
17949
18031
  */
17950
- getScheduleLattice(key4) {
17951
- const scheduleLattice = this.get(key4);
18032
+ getScheduleLattice(key5) {
18033
+ const scheduleLattice = this.get(key5);
17952
18034
  if (!scheduleLattice) {
17953
- throw new Error(`ScheduleLattice ${key4} not found`);
18035
+ throw new Error(`ScheduleLattice ${key5} not found`);
17954
18036
  }
17955
18037
  return scheduleLattice;
17956
18038
  }
@@ -17964,15 +18046,15 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
17964
18046
  * Check if Lattice exists
17965
18047
  * @param key Lattice key name
17966
18048
  */
17967
- hasLattice(key4) {
17968
- return this.has(key4);
18049
+ hasLattice(key5) {
18050
+ return this.has(key5);
17969
18051
  }
17970
18052
  /**
17971
18053
  * Remove Lattice
17972
18054
  * @param key Lattice key name
17973
18055
  */
17974
- removeLattice(key4) {
17975
- return this.remove(key4);
18056
+ removeLattice(key5) {
18057
+ return this.remove(key5);
17976
18058
  }
17977
18059
  /**
17978
18060
  * Clear all Lattices
@@ -17994,8 +18076,8 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
17994
18076
  }
17995
18077
  };
17996
18078
  var scheduleLatticeManager = ScheduleLatticeManager.getInstance();
17997
- var registerScheduleLattice = (key4, config, client) => scheduleLatticeManager.registerLattice(key4, config, client);
17998
- var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key4);
18079
+ var registerScheduleLattice = (key5, config, client) => scheduleLatticeManager.registerLattice(key5, config, client);
18080
+ var getScheduleLattice = (key5) => scheduleLatticeManager.getScheduleLattice(key5);
17999
18081
 
18000
18082
  // src/deep_agent_new/middleware/scheduler.ts
18001
18083
  var SCHEDULE_LATTICE_KEY = "default";
@@ -18589,9 +18671,9 @@ var FilesystemBackend = class {
18589
18671
  * @returns Resolved absolute path string
18590
18672
  * @throws Error if path traversal detected or path outside root
18591
18673
  */
18592
- resolvePath(key4) {
18674
+ resolvePath(key5) {
18593
18675
  if (this.virtualMode) {
18594
- let normalizedKey = key4;
18676
+ let normalizedKey = key5;
18595
18677
  if (normalizedKey === "~" || normalizedKey === "~/") {
18596
18678
  normalizedKey = "/";
18597
18679
  } else if (normalizedKey.startsWith("~/")) {
@@ -18608,7 +18690,7 @@ var FilesystemBackend = class {
18608
18690
  }
18609
18691
  return full;
18610
18692
  }
18611
- let target = key4;
18693
+ let target = key5;
18612
18694
  if (target.startsWith("~/")) {
18613
18695
  target = `/${target.slice(2)}`;
18614
18696
  }
@@ -19188,15 +19270,15 @@ var CompositeBackend = class {
19188
19270
  * @returns Tuple of [backend, stripped_key] where stripped_key has the route
19189
19271
  * prefix removed (but keeps leading slash).
19190
19272
  */
19191
- getBackendAndKey(key4) {
19273
+ getBackendAndKey(key5) {
19192
19274
  for (const [prefix, backend] of this.sortedRoutes) {
19193
- if (key4.startsWith(prefix)) {
19194
- const suffix = key4.substring(prefix.length);
19275
+ if (key5.startsWith(prefix)) {
19276
+ const suffix = key5.substring(prefix.length);
19195
19277
  const strippedKey = suffix ? "/" + suffix : "/";
19196
19278
  return [backend, strippedKey];
19197
19279
  }
19198
19280
  }
19199
- return [this.default, key4];
19281
+ return [this.default, key5];
19200
19282
  }
19201
19283
  /**
19202
19284
  * List files and directories in the specified directory (non-recursive).
@@ -21743,9 +21825,9 @@ var _A2ARemoteClient = class _A2ARemoteClient {
21743
21825
  else terminalText = t;
21744
21826
  },
21745
21827
  onArtifact: (artifact, append) => {
21746
- const key4 = artifact.artifactId || artifact.name || `artifact-${artifactSequence}`;
21747
- const previous = artifacts.get(key4);
21748
- artifacts.set(key4, {
21828
+ const key5 = artifact.artifactId || artifact.name || `artifact-${artifactSequence}`;
21829
+ const previous = artifacts.get(key5);
21830
+ artifacts.set(key5, {
21749
21831
  name: artifact.name,
21750
21832
  text: append && previous ? previous.text + artifact.text : artifact.text,
21751
21833
  sequence: artifactSequence++
@@ -21981,9 +22063,9 @@ var WorkflowAgentGraphBuilder = class {
21981
22063
  }
21982
22064
  const isAsk = stepType === "ask";
21983
22065
  if (responseFormat) {
21984
- const key4 = (isAsk ? "ask:" : "agent:") + JSON.stringify(responseFormat);
21985
- console.log(`[WF BUILDER] resolveAgent: cacheKey=${key4.slice(0, 80)}... | cached=${agentCache.has(key4)}`);
21986
- if (!agentCache.has(key4)) {
22066
+ const key5 = (isAsk ? "ask:" : "agent:") + JSON.stringify(responseFormat);
22067
+ console.log(`[WF BUILDER] resolveAgent: cacheKey=${key5.slice(0, 80)}... | cached=${agentCache.has(key5)}`);
22068
+ if (!agentCache.has(key5)) {
21987
22069
  console.log(`[WF BUILDER] creating ${isAsk ? "ask" : "agent"} with responseFormat`);
21988
22070
  const agent = createAgent6({
21989
22071
  model: params.model,
@@ -21993,13 +22075,13 @@ var WorkflowAgentGraphBuilder = class {
21993
22075
  middleware: isAsk ? noWrapAskMiddlewares : noWrapMiddlewares,
21994
22076
  responseFormat
21995
22077
  });
21996
- agentCache.set(key4, agent);
22078
+ agentCache.set(key5, agent);
21997
22079
  }
21998
- return agentCache.get(key4);
22080
+ return agentCache.get(key5);
21999
22081
  }
22000
22082
  if (isAsk) {
22001
- const key4 = "ask:default";
22002
- if (!agentCache.has(key4)) {
22083
+ const key5 = "ask:default";
22084
+ if (!agentCache.has(key5)) {
22003
22085
  console.log(`[WF BUILDER] creating ask default agent`);
22004
22086
  const agent = createAgent6({
22005
22087
  model: params.model,
@@ -22008,9 +22090,9 @@ var WorkflowAgentGraphBuilder = class {
22008
22090
  checkpointer,
22009
22091
  middleware: askMiddlewares
22010
22092
  });
22011
- agentCache.set(key4, agent);
22093
+ agentCache.set(key5, agent);
22012
22094
  }
22013
- return agentCache.get(key4);
22095
+ return agentCache.get(key5);
22014
22096
  }
22015
22097
  console.log(`[WF BUILDER] resolveAgent: using defaultAgent`);
22016
22098
  return defaultAgent;
@@ -22164,12 +22246,12 @@ var NON_INHERITABLE_FIELDS = /* @__PURE__ */ new Set([
22164
22246
  ]);
22165
22247
  function mergeAgentConfig(parent, child) {
22166
22248
  const merged = { ...parent };
22167
- for (const [key4, value] of Object.entries(child)) {
22168
- if (NON_INHERITABLE_FIELDS.has(key4)) {
22249
+ for (const [key5, value] of Object.entries(child)) {
22250
+ if (NON_INHERITABLE_FIELDS.has(key5)) {
22169
22251
  continue;
22170
22252
  }
22171
22253
  if (value !== void 0) {
22172
- merged[key4] = value;
22254
+ merged[key5] = value;
22173
22255
  }
22174
22256
  }
22175
22257
  merged.key = child.key;
@@ -22291,14 +22373,14 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
22291
22373
  * @param embeddings Embeddings instance
22292
22374
  * @param label Optional display label (auto-derived if not provided)
22293
22375
  */
22294
- registerLattice(key4, embeddings, label) {
22295
- const displayLabel = label || embeddings.modelName || embeddings.model || embeddings.name || key4;
22376
+ registerLattice(key5, embeddings, label) {
22377
+ const displayLabel = label || embeddings.modelName || embeddings.model || embeddings.name || key5;
22296
22378
  const embeddingsLattice = {
22297
- key: key4,
22379
+ key: key5,
22298
22380
  client: embeddings,
22299
22381
  label: displayLabel
22300
22382
  };
22301
- this.register(key4, embeddingsLattice);
22383
+ this.register(key5, embeddingsLattice);
22302
22384
  }
22303
22385
  /**
22304
22386
  * Get all registered embeddings as { key, label } info list
@@ -22310,10 +22392,10 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
22310
22392
  * Get EmbeddingsLattice
22311
22393
  * @param key Lattice key name
22312
22394
  */
22313
- getEmbeddingsLattice(key4) {
22314
- const embeddingsLattice = this.get(key4);
22395
+ getEmbeddingsLattice(key5) {
22396
+ const embeddingsLattice = this.get(key5);
22315
22397
  if (!embeddingsLattice) {
22316
- throw new Error(`EmbeddingsLattice ${key4} not found`);
22398
+ throw new Error(`EmbeddingsLattice ${key5} not found`);
22317
22399
  }
22318
22400
  return embeddingsLattice;
22319
22401
  }
@@ -22327,15 +22409,15 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
22327
22409
  * Check if Lattice exists
22328
22410
  * @param key Lattice key name
22329
22411
  */
22330
- hasLattice(key4) {
22331
- return this.has(key4);
22412
+ hasLattice(key5) {
22413
+ return this.has(key5);
22332
22414
  }
22333
22415
  /**
22334
22416
  * Remove Lattice
22335
22417
  * @param key Lattice key name
22336
22418
  */
22337
- removeLattice(key4) {
22338
- return this.remove(key4);
22419
+ removeLattice(key5) {
22420
+ return this.remove(key5);
22339
22421
  }
22340
22422
  /**
22341
22423
  * Clear all Lattices
@@ -22359,15 +22441,15 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
22359
22441
  * Get embeddings client
22360
22442
  * @param key Lattice key name
22361
22443
  */
22362
- getEmbeddingsClient(key4) {
22363
- const embeddingsLattice = this.getEmbeddingsLattice(key4);
22444
+ getEmbeddingsClient(key5) {
22445
+ const embeddingsLattice = this.getEmbeddingsLattice(key5);
22364
22446
  return embeddingsLattice.client;
22365
22447
  }
22366
22448
  };
22367
22449
  var embeddingsLatticeManager = EmbeddingsLatticeManager.getInstance();
22368
- var registerEmbeddingsLattice = (key4, embeddings, label) => embeddingsLatticeManager.registerLattice(key4, embeddings, label);
22369
- var getEmbeddingsLattice = (key4) => embeddingsLatticeManager.getEmbeddingsLattice(key4);
22370
- var getEmbeddingsClient = (key4) => embeddingsLatticeManager.getEmbeddingsClient(key4);
22450
+ var registerEmbeddingsLattice = (key5, embeddings, label) => embeddingsLatticeManager.registerLattice(key5, embeddings, label);
22451
+ var getEmbeddingsLattice = (key5) => embeddingsLatticeManager.getEmbeddingsLattice(key5);
22452
+ var getEmbeddingsClient = (key5) => embeddingsLatticeManager.getEmbeddingsClient(key5);
22371
22453
 
22372
22454
  // src/vectorstore_lattice/VectorStoreProviderManager.ts
22373
22455
  var MemoryVectorStoreProvider = class {
@@ -22413,19 +22495,19 @@ var VectorStoreProviderManager = class _VectorStoreProviderManager extends BaseL
22413
22495
  * @param key Provider key name
22414
22496
  * @param provider VectorStoreProvider implementation
22415
22497
  */
22416
- registerProvider(key4, provider) {
22417
- const lattice = { key: key4, provider };
22418
- this.registerWithTenant("default", key4, lattice);
22498
+ registerProvider(key5, provider) {
22499
+ const lattice = { key: key5, provider };
22500
+ this.registerWithTenant("default", key5, lattice);
22419
22501
  }
22420
22502
  /**
22421
22503
  * Get a VectorStore provider by key
22422
22504
  * @param key Provider key name
22423
22505
  * @returns VectorStoreProvider instance
22424
22506
  */
22425
- getProvider(key4) {
22426
- const lattice = this.getWithTenant("default", key4);
22507
+ getProvider(key5) {
22508
+ const lattice = this.getWithTenant("default", key5);
22427
22509
  if (!lattice) {
22428
- throw new Error(`VectorStoreProvider "${key4}" not found. Register one first.`);
22510
+ throw new Error(`VectorStoreProvider "${key5}" not found. Register one first.`);
22429
22511
  }
22430
22512
  return lattice.provider;
22431
22513
  }
@@ -22438,20 +22520,20 @@ var VectorStoreProviderManager = class _VectorStoreProviderManager extends BaseL
22438
22520
  /**
22439
22521
  * Check if provider exists
22440
22522
  */
22441
- hasProvider(key4) {
22442
- return this.hasWithTenant("default", key4);
22523
+ hasProvider(key5) {
22524
+ return this.hasWithTenant("default", key5);
22443
22525
  }
22444
22526
  /**
22445
22527
  * Remove a provider
22446
22528
  */
22447
- removeProvider(key4) {
22448
- return this.removeWithTenant("default", key4);
22529
+ removeProvider(key5) {
22530
+ return this.removeWithTenant("default", key5);
22449
22531
  }
22450
22532
  };
22451
22533
  var vectorStoreProviderManager = VectorStoreProviderManager.getInstance();
22452
22534
  vectorStoreProviderManager.registerProvider("default", new MemoryVectorStoreProvider());
22453
- var registerVectorStoreProvider = (key4, provider) => vectorStoreProviderManager.registerProvider(key4, provider);
22454
- var getVectorStoreProvider = (key4) => vectorStoreProviderManager.getProvider(key4);
22535
+ var registerVectorStoreProvider = (key5, provider) => vectorStoreProviderManager.registerProvider(key5, provider);
22536
+ var getVectorStoreProvider = (key5) => vectorStoreProviderManager.getProvider(key5);
22455
22537
 
22456
22538
  // src/store_lattice/configureStores.ts
22457
22539
  var _disposables = [];
@@ -25043,7 +25125,7 @@ function parseFrontmatter2(content) {
25043
25125
  if (currentKey === "metadata" && indent > metadataIndent) {
25044
25126
  const colonIndex2 = trimmed.indexOf(":");
25045
25127
  if (colonIndex2 !== -1) {
25046
- const key5 = trimmed.substring(0, colonIndex2).trim();
25128
+ const key6 = trimmed.substring(0, colonIndex2).trim();
25047
25129
  let value2 = trimmed.substring(colonIndex2 + 1).trim();
25048
25130
  if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
25049
25131
  value2 = value2.slice(1, -1);
@@ -25051,7 +25133,7 @@ function parseFrontmatter2(content) {
25051
25133
  if (!frontmatter.metadata) {
25052
25134
  frontmatter.metadata = {};
25053
25135
  }
25054
- frontmatter.metadata[key5] = value2;
25136
+ frontmatter.metadata[key6] = value2;
25055
25137
  }
25056
25138
  continue;
25057
25139
  }
@@ -25076,12 +25158,12 @@ function parseFrontmatter2(content) {
25076
25158
  if (colonIndex === -1) {
25077
25159
  continue;
25078
25160
  }
25079
- const key4 = trimmed.substring(0, colonIndex).trim();
25161
+ const key5 = trimmed.substring(0, colonIndex).trim();
25080
25162
  let value = trimmed.substring(colonIndex + 1).trim();
25081
25163
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
25082
25164
  value = value.slice(1, -1);
25083
25165
  }
25084
- if (key4 === "metadata") {
25166
+ if (key5 === "metadata") {
25085
25167
  if (value === "" || value === "{}") {
25086
25168
  if (i + 1 < lines.length) {
25087
25169
  const nextLine = lines[i + 1];
@@ -25093,17 +25175,17 @@ function parseFrontmatter2(content) {
25093
25175
  continue;
25094
25176
  }
25095
25177
  }
25096
- frontmatter[key4] = {};
25178
+ frontmatter[key5] = {};
25097
25179
  } else if (value.startsWith("{")) {
25098
25180
  try {
25099
- frontmatter[key4] = JSON.parse(value);
25181
+ frontmatter[key5] = JSON.parse(value);
25100
25182
  } catch {
25101
- frontmatter[key4] = {};
25183
+ frontmatter[key5] = {};
25102
25184
  }
25103
25185
  } else {
25104
- frontmatter[key4] = {};
25186
+ frontmatter[key5] = {};
25105
25187
  }
25106
- } else if (key4 === "subSkills") {
25188
+ } else if (key5 === "subSkills") {
25107
25189
  if (value === "" || value === "[]") {
25108
25190
  if (i + 1 < lines.length) {
25109
25191
  const nextLine = lines[i + 1];
@@ -25115,18 +25197,18 @@ function parseFrontmatter2(content) {
25115
25197
  continue;
25116
25198
  }
25117
25199
  }
25118
- frontmatter[key4] = [];
25200
+ frontmatter[key5] = [];
25119
25201
  } else if (value.startsWith("[")) {
25120
25202
  try {
25121
- frontmatter[key4] = JSON.parse(value);
25203
+ frontmatter[key5] = JSON.parse(value);
25122
25204
  } catch {
25123
- frontmatter[key4] = [];
25205
+ frontmatter[key5] = [];
25124
25206
  }
25125
25207
  } else {
25126
- frontmatter[key4] = [];
25208
+ frontmatter[key5] = [];
25127
25209
  }
25128
25210
  } else {
25129
- frontmatter[key4] = value;
25211
+ frontmatter[key5] = value;
25130
25212
  }
25131
25213
  }
25132
25214
  return { frontmatter, body };
@@ -25143,8 +25225,8 @@ function generateFrontmatter2(data) {
25143
25225
  }
25144
25226
  if (data.metadata && Object.keys(data.metadata).length > 0) {
25145
25227
  lines.push("metadata:");
25146
- for (const [key4, value] of Object.entries(data.metadata)) {
25147
- lines.push(` ${key4}: ${value}`);
25228
+ for (const [key5, value] of Object.entries(data.metadata)) {
25229
+ lines.push(` ${key5}: ${value}`);
25148
25230
  }
25149
25231
  }
25150
25232
  if (data.subSkills && data.subSkills.length > 0) {
@@ -25708,12 +25790,12 @@ async function validateAgentReferences(input, tenantId2) {
25708
25790
  const availableTools = getAvailableTools().map((tool69) => tool69.key);
25709
25791
  const availableMiddlewareTypes = getAvailableMiddlewareTypes();
25710
25792
  const availableCustomMiddlewareKeys = CustomMiddlewareRegistry.list().filter(
25711
- (key4) => CustomMiddlewareRegistry.get(key4) !== void 0
25793
+ (key5) => CustomMiddlewareRegistry.get(key5) !== void 0
25712
25794
  );
25713
25795
  const availableModels = getAvailableModels().map((model) => model.key);
25714
- const invalidTools = input.tools?.filter((key4) => !availableTools.includes(key4)) ?? [];
25796
+ const invalidTools = input.tools?.filter((key5) => !availableTools.includes(key5)) ?? [];
25715
25797
  const invalidMiddlewareTypes = input.middleware?.map((middleware) => middleware.type).filter((type) => type !== "custom" && !availableMiddlewareTypes.includes(type)) ?? [];
25716
- const invalidCustomMiddlewareKeys = input.middleware?.filter((middleware) => middleware.type === "custom").map((middleware) => typeof middleware.config?.key === "string" ? middleware.config.key.trim() : "").filter((key4) => key4.length === 0 || !availableCustomMiddlewareKeys.includes(key4)) ?? [];
25798
+ const invalidCustomMiddlewareKeys = input.middleware?.filter((middleware) => middleware.type === "custom").map((middleware) => typeof middleware.config?.key === "string" ? middleware.config.key.trim() : "").filter((key5) => key5.length === 0 || !availableCustomMiddlewareKeys.includes(key5)) ?? [];
25717
25799
  const availableSubAgents = input.subAgents !== void 0 ? (await getAssistStore().getAllAssistants(tenantId2)).map((assistant) => assistant.id) : void 0;
25718
25800
  const invalidSubAgents = input.subAgents?.filter((id) => !availableSubAgents?.includes(id)) ?? [];
25719
25801
  const invalidModelKey = input.modelKey !== void 0 && !availableModels.includes(input.modelKey) ? input.modelKey : void 0;
@@ -26251,7 +26333,7 @@ registerToolLattice(
26251
26333
  changedKeys,
26252
26334
  markdown: `## Agent Configuration Update
26253
26335
 
26254
- Updated \`${input.id}\`: ${changedKeys.map((key4) => `\`${key4}\``).join(", ")}.`
26336
+ Updated \`${input.id}\`: ${changedKeys.map((key5) => `\`${key5}\``).join(", ")}.`
26255
26337
  },
26256
26338
  workspaceId: task.workspaceId,
26257
26339
  projectId: task.projectId
@@ -26704,8 +26786,8 @@ function ensurePluginAgentsForTenant(tenantId2) {
26704
26786
  for (const pluginType of pluginTypes) {
26705
26787
  const plugin = PluginRegistry.get(pluginType);
26706
26788
  if (!plugin?.agents) continue;
26707
- for (const [key4, config] of Object.entries(plugin.agents)) {
26708
- if (!agentLatticeManager.hasWithTenant(tenantId2, key4)) {
26789
+ for (const [key5, config] of Object.entries(plugin.agents)) {
26790
+ if (!agentLatticeManager.hasWithTenant(tenantId2, key5)) {
26709
26791
  agentLatticeManager.registerLatticeWithTenant(tenantId2, config);
26710
26792
  }
26711
26793
  }
@@ -26752,10 +26834,10 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26752
26834
  * @param key Agent键名
26753
26835
  * @returns AgentLattice或undefined
26754
26836
  */
26755
- async loadItemFromStore(tenantId2, key4) {
26837
+ async loadItemFromStore(tenantId2, key5) {
26756
26838
  try {
26757
26839
  const storeLattice = getStoreLattice("default", "assistant");
26758
- const assistant = await storeLattice.store.getAssistantById(tenantId2, key4);
26840
+ const assistant = await storeLattice.store.getAssistantById(tenantId2, key5);
26759
26841
  if (!assistant) {
26760
26842
  return void 0;
26761
26843
  }
@@ -26766,7 +26848,7 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26766
26848
  };
26767
26849
  return agentLattice;
26768
26850
  } catch (error) {
26769
- console.error(`Failed to load agent from store [tenant: ${tenantId2}, key: ${key4}]:`, error);
26851
+ console.error(`Failed to load agent from store [tenant: ${tenantId2}, key: ${key5}]:`, error);
26770
26852
  return void 0;
26771
26853
  }
26772
26854
  }
@@ -26840,12 +26922,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26840
26922
  * `null` when the key is not a suffixed GP key (including the bare
26841
26923
  * `general-purpose` key itself).
26842
26924
  */
26843
- generalPurposeParentKey(key4) {
26925
+ generalPurposeParentKey(key5) {
26844
26926
  const suffix = _AgentLatticeManager.GENERAL_PURPOSE_SUFFIX;
26845
- if (!key4.endsWith(suffix) || key4.length <= suffix.length) {
26927
+ if (!key5.endsWith(suffix) || key5.length <= suffix.length) {
26846
26928
  return null;
26847
26929
  }
26848
- return key4.slice(0, -suffix.length);
26930
+ return key5.slice(0, -suffix.length);
26849
26931
  }
26850
26932
  /**
26851
26933
  * 带租户注册Agent Lattice
@@ -26873,12 +26955,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26873
26955
  * @param tenantId 租户ID
26874
26956
  * @param key Lattice键名
26875
26957
  */
26876
- getAgentLatticeWithTenant(tenantId2, key4) {
26877
- const exact = this.getWithTenant(tenantId2, key4);
26958
+ getAgentLatticeWithTenant(tenantId2, key5) {
26959
+ const exact = this.getWithTenant(tenantId2, key5);
26878
26960
  if (exact) {
26879
26961
  return exact;
26880
26962
  }
26881
- const parentKey = this.generalPurposeParentKey(key4);
26963
+ const parentKey = this.generalPurposeParentKey(key5);
26882
26964
  if (!parentKey) {
26883
26965
  return void 0;
26884
26966
  }
@@ -26896,8 +26978,8 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26896
26978
  * @param tenantId 租户ID
26897
26979
  * @param key Lattice键名
26898
26980
  */
26899
- hasAgentLatticeWithTenant(tenantId2, key4) {
26900
- return this.hasWithTenant(tenantId2, key4);
26981
+ hasAgentLatticeWithTenant(tenantId2, key5) {
26982
+ return this.hasWithTenant(tenantId2, key5);
26901
26983
  }
26902
26984
  /**
26903
26985
  * 异步获取AgentLattice(内存未命中时尝试从store加载)
@@ -26911,12 +26993,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26911
26993
  * @param tenantId 租户ID
26912
26994
  * @param key Lattice键名
26913
26995
  */
26914
- async getOrLoadWithTenant(tenantId2, key4) {
26915
- const exact = await super.getOrLoadWithTenant(tenantId2, key4);
26996
+ async getOrLoadWithTenant(tenantId2, key5) {
26997
+ const exact = await super.getOrLoadWithTenant(tenantId2, key5);
26916
26998
  if (exact) {
26917
26999
  return exact;
26918
27000
  }
26919
- const parentKey = this.generalPurposeParentKey(key4);
27001
+ const parentKey = this.generalPurposeParentKey(key5);
26920
27002
  if (!parentKey) {
26921
27003
  return void 0;
26922
27004
  }
@@ -26927,8 +27009,8 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26927
27009
  * @param tenantId 租户ID
26928
27010
  * @param key Lattice键名
26929
27011
  */
26930
- removeAgentLatticeWithTenant(tenantId2, key4) {
26931
- return this.removeWithTenant(tenantId2, key4);
27012
+ removeAgentLatticeWithTenant(tenantId2, key5) {
27013
+ return this.removeWithTenant(tenantId2, key5);
26932
27014
  }
26933
27015
  /**
26934
27016
  * 获取指定租户的所有Agent Lattice
@@ -26949,8 +27031,8 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
26949
27031
  * @param tenantId 租户ID
26950
27032
  * @param key Lattice键名
26951
27033
  */
26952
- getAgentConfigWithTenant(tenantId2, key4) {
26953
- return this.getAgentLatticeWithTenant(tenantId2, key4)?.config;
27034
+ getAgentConfigWithTenant(tenantId2, key5) {
27035
+ return this.getAgentLatticeWithTenant(tenantId2, key5)?.config;
26954
27036
  }
26955
27037
  /**
26956
27038
  * 获取指定租户的所有Agent配置
@@ -27003,31 +27085,31 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27003
27085
  * @param client Pre-built AgentClient (ReactAgent or CompiledGraph)
27004
27086
  * @param tenantId Tenant ID (required)
27005
27087
  */
27006
- registerTeammateAgent(key4, client, tenantId2) {
27088
+ registerTeammateAgent(key5, client, tenantId2) {
27007
27089
  const agentLattice = {
27008
27090
  config: {
27009
- key: key4,
27010
- name: key4,
27011
- description: `Teammate agent: ${key4}`,
27091
+ key: key5,
27092
+ name: key5,
27093
+ description: `Teammate agent: ${key5}`,
27012
27094
  type: AgentType.REACT
27013
27095
  },
27014
27096
  client
27015
27097
  };
27016
- this.registerWithTenant(tenantId2, key4, agentLattice);
27098
+ this.registerWithTenant(tenantId2, key5, agentLattice);
27017
27099
  }
27018
27100
  /**
27019
27101
  * Unregister a teammate agent. Call when a team is done to clean up.
27020
27102
  */
27021
- unregisterTeammateAgent(key4) {
27022
- return this.remove(key4);
27103
+ unregisterTeammateAgent(key5) {
27104
+ return this.remove(key5);
27023
27105
  }
27024
27106
  /**
27025
27107
  * 获取AgentLattice(向后兼容,使用 "default" 租户)
27026
27108
  * @deprecated Use getAgentLatticeWithTenant(tenantId, key) instead
27027
27109
  * @param key Lattice键名
27028
27110
  */
27029
- getAgentLattice(key4) {
27030
- return this.get(key4);
27111
+ getAgentLattice(key5) {
27112
+ return this.get(key5);
27031
27113
  }
27032
27114
  /**
27033
27115
  * 获取所有Lattice
@@ -27040,24 +27122,24 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27040
27122
  * @deprecated Use hasAgentLatticeWithTenant(tenantId, key) instead
27041
27123
  * @param key Lattice键名
27042
27124
  */
27043
- hasLattice(key4) {
27044
- return this.has(key4);
27125
+ hasLattice(key5) {
27126
+ return this.has(key5);
27045
27127
  }
27046
27128
  /**
27047
27129
  * 移除Lattice(向后兼容,使用 "default" 租户)
27048
27130
  * @deprecated Use removeAgentLatticeWithTenant(tenantId, key) instead
27049
27131
  * @param key Lattice键名
27050
27132
  */
27051
- removeLattice(key4) {
27052
- return this.remove(key4);
27133
+ removeLattice(key5) {
27134
+ return this.remove(key5);
27053
27135
  }
27054
27136
  /**
27055
27137
  * 获取Agent配置(向后兼容,使用 "default" 租户)
27056
27138
  * @deprecated Use getAgentConfigWithTenant(tenantId, key) instead
27057
27139
  * @param key Lattice键名
27058
27140
  */
27059
- getAgentConfig(key4) {
27060
- return this.getAgentLatticeWithTenant("default", key4)?.config;
27141
+ getAgentConfig(key5) {
27142
+ return this.getAgentLatticeWithTenant("default", key5)?.config;
27061
27143
  }
27062
27144
  /**
27063
27145
  * 获取所有Agent配置
@@ -27072,8 +27154,8 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27072
27154
  * @param key Lattice键名
27073
27155
  * @param input 输入参数
27074
27156
  */
27075
- validateAgentInput(key4, input) {
27076
- const agentLattice = this.getAgentLattice(key4);
27157
+ validateAgentInput(key5, input) {
27158
+ const agentLattice = this.getAgentLattice(key5);
27077
27159
  if (!agentLattice) {
27078
27160
  return false;
27079
27161
  }
@@ -27129,9 +27211,9 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27129
27211
  */
27130
27212
  async buildAgentParams(agentLattice, options) {
27131
27213
  const tenantId2 = agentLattice.config.tenantId || "default";
27132
- const paramsBuilder = new AgentParamsBuilder(async (key4) => {
27133
- await this.initializeClientAsync(tenantId2, key4);
27134
- return this.getAgentLatticeWithTenant(tenantId2, key4);
27214
+ const paramsBuilder = new AgentParamsBuilder(async (key5) => {
27215
+ await this.initializeClientAsync(tenantId2, key5);
27216
+ return this.getAgentLatticeWithTenant(tenantId2, key5);
27135
27217
  });
27136
27218
  const params = await paramsBuilder.buildParams(agentLattice, options);
27137
27219
  return {
@@ -27167,12 +27249,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27167
27249
  * @param options 构建选项
27168
27250
  * @returns 返回CompiledGraph对象
27169
27251
  */
27170
- async initializeClient(tenantId2, key4, options) {
27171
- const buildKey3 = `${tenantId2}:${key4}`;
27252
+ async initializeClient(tenantId2, key5, options) {
27253
+ const buildKey3 = `${tenantId2}:${key5}`;
27172
27254
  const stack = this.buildContext.getStore() ?? [];
27173
27255
  if (stack.includes(buildKey3)) {
27174
27256
  throw new Error(
27175
- `Circular agent reference detected: agent "${key4}" (tenant: ${tenantId2}) is already being built. A workflow cannot reference itself directly or transitively.`
27257
+ `Circular agent reference detected: agent "${key5}" (tenant: ${tenantId2}) is already being built. A workflow cannot reference itself directly or transitively.`
27176
27258
  );
27177
27259
  }
27178
27260
  const inFlight2 = this.buildingKeys.get(buildKey3);
@@ -27180,9 +27262,9 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27180
27262
  return inFlight2;
27181
27263
  }
27182
27264
  const buildPromise = this.buildContext.run([...stack, buildKey3], async () => {
27183
- const agentLattice = this.getAgentLatticeWithTenant(tenantId2, key4);
27265
+ const agentLattice = this.getAgentLatticeWithTenant(tenantId2, key5);
27184
27266
  if (!agentLattice) {
27185
- throw new Error(`Agent Lattice "${key4}" \u4E0D\u5B58\u5728 (tenant: ${tenantId2})`);
27267
+ throw new Error(`Agent Lattice "${key5}" \u4E0D\u5B58\u5728 (tenant: ${tenantId2})`);
27186
27268
  }
27187
27269
  if (agentLattice.client) {
27188
27270
  return agentLattice.client;
@@ -27211,12 +27293,12 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27211
27293
  * @param options 构建选项
27212
27294
  * @returns 返回CompiledGraph对象
27213
27295
  */
27214
- async initializeClientAsync(tenantId2, key4, options) {
27215
- const buildKey3 = `${tenantId2}:${key4}`;
27296
+ async initializeClientAsync(tenantId2, key5, options) {
27297
+ const buildKey3 = `${tenantId2}:${key5}`;
27216
27298
  const stack = this.buildContext.getStore() ?? [];
27217
27299
  if (stack.includes(buildKey3)) {
27218
27300
  throw new Error(
27219
- `Circular agent reference detected: agent "${key4}" (tenant: ${tenantId2}) is already being built. A workflow cannot reference itself directly or transitively.`
27301
+ `Circular agent reference detected: agent "${key5}" (tenant: ${tenantId2}) is already being built. A workflow cannot reference itself directly or transitively.`
27220
27302
  );
27221
27303
  }
27222
27304
  const inFlight2 = this.buildingKeys.get(buildKey3);
@@ -27224,9 +27306,9 @@ var _AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
27224
27306
  return inFlight2;
27225
27307
  }
27226
27308
  const buildPromise = this.buildContext.run([...stack, buildKey3], async () => {
27227
- const agentLattice = await this.getOrLoadWithTenant(tenantId2, key4);
27309
+ const agentLattice = await this.getOrLoadWithTenant(tenantId2, key5);
27228
27310
  if (!agentLattice) {
27229
- throw new Error(`Agent Lattice "${key4}" \u4E0D\u5B58\u5728 (tenant: ${tenantId2})`);
27311
+ throw new Error(`Agent Lattice "${key5}" \u4E0D\u5B58\u5728 (tenant: ${tenantId2})`);
27230
27312
  }
27231
27313
  if (agentLattice.client) {
27232
27314
  return agentLattice.client;
@@ -27272,13 +27354,13 @@ var registerAgentLattices = (tenantId2, configs) => {
27272
27354
  agentLatticeManager.registerLatticeWithTenant(tenantId2, config);
27273
27355
  });
27274
27356
  };
27275
- var getAgentConfig = (key4) => agentLatticeManager.getAgentConfig(key4);
27357
+ var getAgentConfig = (key5) => agentLatticeManager.getAgentConfig(key5);
27276
27358
  var getAllAgentConfigs = () => agentLatticeManager.getAllAgentConfigs();
27277
- var validateAgentInput = (key4, input) => agentLatticeManager.validateAgentInput(key4, input);
27278
- var registerTeammateAgent = (key4, client, tenantId2) => agentLatticeManager.registerTeammateAgent(key4, client, tenantId2);
27279
- var unregisterTeammateAgent = (key4) => agentLatticeManager.unregisterTeammateAgent(key4);
27280
- var getAgentClient = (tenantId2, key4, options) => agentLatticeManager.initializeClient(tenantId2, key4, options);
27281
- var getAgentClientAsync = async (tenantId2, key4, options) => agentLatticeManager.initializeClientAsync(tenantId2, key4, options);
27359
+ var validateAgentInput = (key5, input) => agentLatticeManager.validateAgentInput(key5, input);
27360
+ var registerTeammateAgent = (key5, client, tenantId2) => agentLatticeManager.registerTeammateAgent(key5, client, tenantId2);
27361
+ var unregisterTeammateAgent = (key5) => agentLatticeManager.unregisterTeammateAgent(key5);
27362
+ var getAgentClient = (tenantId2, key5, options) => agentLatticeManager.initializeClient(tenantId2, key5, options);
27363
+ var getAgentClientAsync = async (tenantId2, key5, options) => agentLatticeManager.initializeClientAsync(tenantId2, key5, options);
27282
27364
  var createAgentClientFromAgentLattice = async (agentLattice, options) => await agentLatticeManager.createAgentClientFromConfig(agentLattice, options);
27283
27365
 
27284
27366
  // src/vectorstore_lattice/VectorStoreLatticeManager.ts
@@ -27303,21 +27385,21 @@ var VectorStoreLatticeManager = class _VectorStoreLatticeManager extends BaseLat
27303
27385
  * @param key Lattice key name
27304
27386
  * @param vectorStore VectorStore instance
27305
27387
  */
27306
- registerLattice(key4, vectorStore) {
27388
+ registerLattice(key5, vectorStore) {
27307
27389
  const vectorStoreLattice = {
27308
- key: key4,
27390
+ key: key5,
27309
27391
  client: vectorStore
27310
27392
  };
27311
- this.register(key4, vectorStoreLattice);
27393
+ this.register(key5, vectorStoreLattice);
27312
27394
  }
27313
27395
  /**
27314
27396
  * Get VectorStoreLattice
27315
27397
  * @param key Lattice key name
27316
27398
  */
27317
- getVectorStoreLattice(key4) {
27318
- const vectorStoreLattice = this.get(key4);
27399
+ getVectorStoreLattice(key5) {
27400
+ const vectorStoreLattice = this.get(key5);
27319
27401
  if (!vectorStoreLattice) {
27320
- throw new Error(`VectorStoreLattice ${key4} not found`);
27402
+ throw new Error(`VectorStoreLattice ${key5} not found`);
27321
27403
  }
27322
27404
  return vectorStoreLattice;
27323
27405
  }
@@ -27331,15 +27413,15 @@ var VectorStoreLatticeManager = class _VectorStoreLatticeManager extends BaseLat
27331
27413
  * Check if Lattice exists
27332
27414
  * @param key Lattice key name
27333
27415
  */
27334
- hasLattice(key4) {
27335
- return this.has(key4);
27416
+ hasLattice(key5) {
27417
+ return this.has(key5);
27336
27418
  }
27337
27419
  /**
27338
27420
  * Remove Lattice
27339
27421
  * @param key Lattice key name
27340
27422
  */
27341
- removeLattice(key4) {
27342
- return this.remove(key4);
27423
+ removeLattice(key5) {
27424
+ return this.remove(key5);
27343
27425
  }
27344
27426
  /**
27345
27427
  * Clear all Lattices
@@ -27363,15 +27445,15 @@ var VectorStoreLatticeManager = class _VectorStoreLatticeManager extends BaseLat
27363
27445
  * Get vector store client
27364
27446
  * @param key Lattice key name
27365
27447
  */
27366
- getVectorStoreClient(key4) {
27367
- const vectorStoreLattice = this.getVectorStoreLattice(key4);
27448
+ getVectorStoreClient(key5) {
27449
+ const vectorStoreLattice = this.getVectorStoreLattice(key5);
27368
27450
  return vectorStoreLattice.client;
27369
27451
  }
27370
27452
  };
27371
27453
  var vectorStoreLatticeManager = VectorStoreLatticeManager.getInstance();
27372
- var registerVectorStoreLattice = (key4, vectorStore) => vectorStoreLatticeManager.registerLattice(key4, vectorStore);
27373
- var getVectorStoreLattice = (key4) => vectorStoreLatticeManager.getVectorStoreLattice(key4);
27374
- var getVectorStoreClient = (key4) => vectorStoreLatticeManager.getVectorStoreClient(key4);
27454
+ var registerVectorStoreLattice = (key5, vectorStore) => vectorStoreLatticeManager.registerLattice(key5, vectorStore);
27455
+ var getVectorStoreLattice = (key5) => vectorStoreLatticeManager.getVectorStoreLattice(key5);
27456
+ var getVectorStoreClient = (key5) => vectorStoreLatticeManager.getVectorStoreClient(key5);
27375
27457
 
27376
27458
  // src/logger_lattice/LoggerLatticeManager.ts
27377
27459
  import {
@@ -27593,7 +27675,7 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
27593
27675
  * @param config Logger configuration
27594
27676
  * @param client Optional logger client. If not provided, will create based on config type.
27595
27677
  */
27596
- registerLattice(key4, config, client) {
27678
+ registerLattice(key5, config, client) {
27597
27679
  let loggerClient;
27598
27680
  if (client) {
27599
27681
  loggerClient = client;
@@ -27611,7 +27693,7 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
27611
27693
  }
27612
27694
  }
27613
27695
  const loggerLattice = {
27614
- key: key4,
27696
+ key: key5,
27615
27697
  config,
27616
27698
  client: loggerClient,
27617
27699
  // Logger operations
@@ -27634,16 +27716,16 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
27634
27716
  return loggerClient.child(options);
27635
27717
  } : void 0
27636
27718
  };
27637
- this.register(key4, loggerLattice);
27719
+ this.register(key5, loggerLattice);
27638
27720
  }
27639
27721
  /**
27640
27722
  * Get LoggerLattice
27641
27723
  * @param key Lattice key name
27642
27724
  */
27643
- getLoggerLattice(key4) {
27644
- const loggerLattice = this.get(key4);
27725
+ getLoggerLattice(key5) {
27726
+ const loggerLattice = this.get(key5);
27645
27727
  if (!loggerLattice) {
27646
- throw new Error(`LoggerLattice ${key4} not found`);
27728
+ throw new Error(`LoggerLattice ${key5} not found`);
27647
27729
  }
27648
27730
  return loggerLattice;
27649
27731
  }
@@ -27657,15 +27739,15 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
27657
27739
  * Check if Lattice exists
27658
27740
  * @param key Lattice key name
27659
27741
  */
27660
- hasLattice(key4) {
27661
- return this.has(key4);
27742
+ hasLattice(key5) {
27743
+ return this.has(key5);
27662
27744
  }
27663
27745
  /**
27664
27746
  * Remove Lattice
27665
27747
  * @param key Lattice key name
27666
27748
  */
27667
- removeLattice(key4) {
27668
- return this.remove(key4);
27749
+ removeLattice(key5) {
27750
+ return this.remove(key5);
27669
27751
  }
27670
27752
  /**
27671
27753
  * Clear all Lattices
@@ -27687,8 +27769,8 @@ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManage
27687
27769
  }
27688
27770
  };
27689
27771
  var loggerLatticeManager = LoggerLatticeManager.getInstance();
27690
- var registerLoggerLattice = (key4, config, client) => loggerLatticeManager.registerLattice(key4, config, client);
27691
- var getLoggerLattice = (key4) => loggerLatticeManager.getLoggerLattice(key4);
27772
+ var registerLoggerLattice = (key5, config, client) => loggerLatticeManager.registerLattice(key5, config, client);
27773
+ var getLoggerLattice = (key5) => loggerLatticeManager.getLoggerLattice(key5);
27692
27774
 
27693
27775
  // src/skill_lattice/SkillLatticeManager.ts
27694
27776
  var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager {
@@ -27761,7 +27843,7 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27761
27843
  * @param config Skill configuration
27762
27844
  * @param client Optional skill client implementation
27763
27845
  */
27764
- async registerLatticeWithTenant(tenantId2, key4, config, client) {
27846
+ async registerLatticeWithTenant(tenantId2, key5, config, client) {
27765
27847
  if (!config.name) {
27766
27848
  throw new Error("Skill name is required");
27767
27849
  }
@@ -27769,9 +27851,9 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27769
27851
  throw new Error("Skill description is required");
27770
27852
  }
27771
27853
  validateSkillName(config.name);
27772
- if (key4 !== config.name) {
27854
+ if (key5 !== config.name) {
27773
27855
  throw new Error(
27774
- `Skill key "${key4}" must equal name "${config.name}" (name is used for path addressing)`
27856
+ `Skill key "${key5}" must equal name "${config.name}" (name is used for path addressing)`
27775
27857
  );
27776
27858
  }
27777
27859
  const store = this.getStore();
@@ -27779,14 +27861,14 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27779
27861
  this.injectStoreIntoClient(client, store);
27780
27862
  }
27781
27863
  const skillLattice = {
27782
- key: key4,
27864
+ key: key5,
27783
27865
  config,
27784
27866
  client: client ?? null
27785
27867
  };
27786
- this.registerWithTenant(tenantId2, key4, skillLattice);
27868
+ this.registerWithTenant(tenantId2, key5, skillLattice);
27787
27869
  if (store) {
27788
27870
  try {
27789
- await store.createSkill(tenantId2, key4, {
27871
+ await store.createSkill(tenantId2, key5, {
27790
27872
  name: config.name,
27791
27873
  description: config.description,
27792
27874
  license: config.license,
@@ -27797,7 +27879,7 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27797
27879
  });
27798
27880
  } catch (error) {
27799
27881
  console.warn(
27800
- `Failed to persist skill ${key4} to store:`,
27882
+ `Failed to persist skill ${key5} to store:`,
27801
27883
  error instanceof Error ? error.message : String(error)
27802
27884
  );
27803
27885
  }
@@ -27810,24 +27892,24 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27810
27892
  * @param config Skill configuration
27811
27893
  * @param client Optional skill client implementation
27812
27894
  */
27813
- async registerLattice(key4, config, client) {
27814
- return this.registerLatticeWithTenant(this.getDefaultTenantId(), key4, config, client);
27895
+ async registerLattice(key5, config, client) {
27896
+ return this.registerLatticeWithTenant(this.getDefaultTenantId(), key5, config, client);
27815
27897
  }
27816
27898
  /**
27817
27899
  * Get skill Lattice by key with tenant
27818
27900
  * @param tenantId Tenant ID
27819
27901
  * @param key Lattice key name
27820
27902
  */
27821
- getSkillLatticeWithTenant(tenantId2, key4) {
27822
- return this.getWithTenant(tenantId2, key4);
27903
+ getSkillLatticeWithTenant(tenantId2, key5) {
27904
+ return this.getWithTenant(tenantId2, key5);
27823
27905
  }
27824
27906
  /**
27825
27907
  * Get skill Lattice by key (backward compatible, uses "default" tenant)
27826
27908
  * @deprecated Use getSkillLatticeWithTenant(tenantId, key) instead
27827
27909
  * @param key Lattice key name
27828
27910
  */
27829
- getSkillLattice(key4) {
27830
- return this.getWithTenant(this.getDefaultTenantId(), key4);
27911
+ getSkillLattice(key5) {
27912
+ return this.getWithTenant(this.getDefaultTenantId(), key5);
27831
27913
  }
27832
27914
  /**
27833
27915
  * Get all skill Lattices from store with tenant
@@ -27872,32 +27954,32 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27872
27954
  * @param tenantId Tenant ID
27873
27955
  * @param key Lattice key name
27874
27956
  */
27875
- hasLatticeWithTenant(tenantId2, key4) {
27876
- return this.hasWithTenant(tenantId2, key4);
27957
+ hasLatticeWithTenant(tenantId2, key5) {
27958
+ return this.hasWithTenant(tenantId2, key5);
27877
27959
  }
27878
27960
  /**
27879
27961
  * Check if Lattice exists (backward compatible, uses "default" tenant)
27880
27962
  * @deprecated Use hasLatticeWithTenant(tenantId, key) instead
27881
27963
  * @param key Lattice key name
27882
27964
  */
27883
- hasLattice(key4) {
27884
- return this.hasWithTenant(this.getDefaultTenantId(), key4);
27965
+ hasLattice(key5) {
27966
+ return this.hasWithTenant(this.getDefaultTenantId(), key5);
27885
27967
  }
27886
27968
  /**
27887
27969
  * Remove Lattice with tenant
27888
27970
  * @param tenantId Tenant ID
27889
27971
  * @param key Lattice key name
27890
27972
  */
27891
- async removeLatticeWithTenant(tenantId2, key4) {
27892
- const removed = this.removeWithTenant(tenantId2, key4);
27973
+ async removeLatticeWithTenant(tenantId2, key5) {
27974
+ const removed = this.removeWithTenant(tenantId2, key5);
27893
27975
  if (removed) {
27894
27976
  const store = this.getStore();
27895
27977
  if (store) {
27896
27978
  try {
27897
- await store.deleteSkill(tenantId2, key4);
27979
+ await store.deleteSkill(tenantId2, key5);
27898
27980
  } catch (error) {
27899
27981
  console.warn(
27900
- `Failed to remove skill ${key4} from store:`,
27982
+ `Failed to remove skill ${key5} from store:`,
27901
27983
  error instanceof Error ? error.message : String(error)
27902
27984
  );
27903
27985
  }
@@ -27910,8 +27992,8 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27910
27992
  * @deprecated Use removeLatticeWithTenant(tenantId, key) instead
27911
27993
  * @param key Lattice key name
27912
27994
  */
27913
- async removeLattice(key4) {
27914
- return this.removeLatticeWithTenant(this.getDefaultTenantId(), key4);
27995
+ async removeLattice(key5) {
27996
+ return this.removeLatticeWithTenant(this.getDefaultTenantId(), key5);
27915
27997
  }
27916
27998
  /**
27917
27999
  * Clear all Lattices
@@ -27935,10 +28017,10 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27935
28017
  * Get skill configuration
27936
28018
  * @param key Lattice key name
27937
28019
  */
27938
- getSkillConfig(key4) {
27939
- const skillLattice = this.getSkillLattice(key4);
28020
+ getSkillConfig(key5) {
28021
+ const skillLattice = this.getSkillLattice(key5);
27940
28022
  if (!skillLattice) {
27941
- throw new Error(`SkillLattice ${key4} not found`);
28023
+ throw new Error(`SkillLattice ${key5} not found`);
27942
28024
  }
27943
28025
  return skillLattice.config;
27944
28026
  }
@@ -27947,10 +28029,10 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
27947
28029
  * Ensures client has store access if store is configured
27948
28030
  * @param key Lattice key name
27949
28031
  */
27950
- getSkillClient(key4) {
27951
- const skillLattice = this.getSkillLattice(key4);
28032
+ getSkillClient(key5) {
28033
+ const skillLattice = this.getSkillLattice(key5);
27952
28034
  if (!skillLattice) {
27953
- throw new Error(`SkillLattice ${key4} not found`);
28035
+ throw new Error(`SkillLattice ${key5} not found`);
27954
28036
  }
27955
28037
  const client = skillLattice.client;
27956
28038
  if (!client) {
@@ -28033,21 +28115,21 @@ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager
28033
28115
  * @param key Skill key
28034
28116
  * @param updates Partial skill data to update
28035
28117
  */
28036
- async updateSkillInStore(key4, updates) {
28118
+ async updateSkillInStore(key5, updates) {
28037
28119
  const store = this.getStore();
28038
28120
  if (!store) {
28039
28121
  throw new Error("No store configured. Call configureStore() first.");
28040
28122
  }
28041
- const skillLattice = this.getSkillLattice(key4);
28123
+ const skillLattice = this.getSkillLattice(key5);
28042
28124
  if (!skillLattice) {
28043
- throw new Error(`SkillLattice ${key4} not found`);
28125
+ throw new Error(`SkillLattice ${key5} not found`);
28044
28126
  }
28045
28127
  const updatedConfig = {
28046
28128
  ...skillLattice.config,
28047
28129
  ...updates
28048
28130
  };
28049
28131
  skillLattice.config = updatedConfig;
28050
- await store.updateSkill(this.getDefaultTenantId(), key4, {
28132
+ await store.updateSkill(this.getDefaultTenantId(), key5, {
28051
28133
  name: updatedConfig.name,
28052
28134
  description: updatedConfig.description,
28053
28135
  license: updatedConfig.license,
@@ -28362,9 +28444,9 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
28362
28444
  unregisterServerTools(serverName) {
28363
28445
  const keys = this.registeredToolKeys.get(serverName);
28364
28446
  if (!keys || keys.length === 0) return;
28365
- for (const key4 of keys) {
28447
+ for (const key5 of keys) {
28366
28448
  try {
28367
- toolLatticeManager.removeWithTenant("default", key4);
28449
+ toolLatticeManager.removeWithTenant("default", key5);
28368
28450
  } catch {
28369
28451
  }
28370
28452
  }
@@ -30813,8 +30895,8 @@ var _LatticeEval = class _LatticeEval {
30813
30895
  return parts.length > 0 ? `(${parts.join(" ")})` : "";
30814
30896
  }
30815
30897
  buildFileEntries(files) {
30816
- return Object.keys(files).reduce((acc, key4) => {
30817
- acc[key4] = { content: files[key4].split("\n"), created_at: (/* @__PURE__ */ new Date()).toISOString(), modified_at: (/* @__PURE__ */ new Date()).toISOString() };
30898
+ return Object.keys(files).reduce((acc, key5) => {
30899
+ acc[key5] = { content: files[key5].split("\n"), created_at: (/* @__PURE__ */ new Date()).toISOString(), modified_at: (/* @__PURE__ */ new Date()).toISOString() };
30818
30900
  return acc;
30819
30901
  }, {});
30820
30902
  }
@@ -31056,8 +31138,8 @@ ${toolCallStr}` : toolCallStr;
31056
31138
  });
31057
31139
  const files = evalCase.input.files;
31058
31140
  const testCaseFilesContent = files ? Object.keys(files).map(
31059
- (key4) => `File name: ${key4}
31060
- File content: ${files[key4]}`
31141
+ (key5) => `File name: ${key5}
31142
+ File content: ${files[key5]}`
31061
31143
  ).join("\n\n") : "";
31062
31144
  const defaultRubrics = [
31063
31145
  {
@@ -31846,7 +31928,7 @@ function snapshotInput(input) {
31846
31928
  "targetAssistantId",
31847
31929
  "newThreadId"
31848
31930
  ];
31849
- if (!row || required.some((key4) => typeof row[key4] !== "string" || row[key4].length === 0) || row.expectedThreadId !== void 0 && (typeof row.expectedThreadId !== "string" || row.expectedThreadId.length === 0)) {
31931
+ if (!row || required.some((key5) => typeof row[key5] !== "string" || row[key5].length === 0) || row.expectedThreadId !== void 0 && (typeof row.expectedThreadId !== "string" || row.expectedThreadId.length === 0)) {
31850
31932
  throw new Error("Invalid Project task reassignment authorization input");
31851
31933
  }
31852
31934
  return {
@@ -31892,14 +31974,14 @@ var TaskLifecycleNotifier = class {
31892
31974
  */
31893
31975
  async publish(event) {
31894
31976
  const snapshot = snapshotNotification(event);
31895
- const key4 = `${snapshot.tenantId}:${snapshot.taskId}`;
31896
- const previous = this.tails.get(key4) ?? Promise.resolve();
31977
+ const key5 = `${snapshot.tenantId}:${snapshot.taskId}`;
31978
+ const previous = this.tails.get(key5) ?? Promise.resolve();
31897
31979
  const delivery = previous.catch(() => void 0).then(() => this.deliver(snapshot));
31898
- this.tails.set(key4, delivery);
31980
+ this.tails.set(key5, delivery);
31899
31981
  try {
31900
31982
  await delivery;
31901
31983
  } finally {
31902
- if (this.tails.get(key4) === delivery) this.tails.delete(key4);
31984
+ if (this.tails.get(key5) === delivery) this.tails.delete(key5);
31903
31985
  }
31904
31986
  }
31905
31987
  async deliver(snapshot) {
@@ -31976,14 +32058,14 @@ var ProjectTaskAdmissionNotifier = class {
31976
32058
  async publish(event) {
31977
32059
  const snapshot = snapshotNotification2(event);
31978
32060
  const listeners = [...this.listeners];
31979
- const key4 = `${snapshot.tenantId}\0${snapshot.taskId}`;
31980
- const previous = this.tails.get(key4) ?? Promise.resolve();
32061
+ const key5 = `${snapshot.tenantId}\0${snapshot.taskId}`;
32062
+ const previous = this.tails.get(key5) ?? Promise.resolve();
31981
32063
  const delivery = previous.catch(() => void 0).then(() => this.deliver(snapshot, listeners));
31982
- this.tails.set(key4, delivery);
32064
+ this.tails.set(key5, delivery);
31983
32065
  try {
31984
32066
  await delivery;
31985
32067
  } finally {
31986
- if (this.tails.get(key4) === delivery) this.tails.delete(key4);
32068
+ if (this.tails.get(key5) === delivery) this.tails.delete(key5);
31987
32069
  }
31988
32070
  }
31989
32071
  async deliver(snapshot, listeners) {
@@ -32059,22 +32141,22 @@ var ProjectMutationMutex = class {
32059
32141
  }
32060
32142
  /** Runs one mutation after all earlier mutations for the same Tenant and Project. */
32061
32143
  async runExclusive(scope, operation, signal) {
32062
- const key4 = projectKey(scope);
32063
- await this.acquire(key4, signal);
32144
+ const key5 = projectKey(scope);
32145
+ await this.acquire(key5, signal);
32064
32146
  try {
32065
32147
  return await operation();
32066
32148
  } finally {
32067
- this.release(key4);
32149
+ this.release(key5);
32068
32150
  }
32069
32151
  }
32070
32152
  /** Returns the number of operations queued behind the current holder. */
32071
32153
  pending(scope) {
32072
32154
  return this.queues.get(projectKey(scope))?.length ?? 0;
32073
32155
  }
32074
- acquire(key4, signal) {
32156
+ acquire(key5, signal) {
32075
32157
  if (signal?.aborted) return Promise.reject(new Error("Project mutation wait aborted"));
32076
- if (!this.active.has(key4)) {
32077
- this.active.add(key4);
32158
+ if (!this.active.has(key5)) {
32159
+ this.active.add(key5);
32078
32160
  return Promise.resolve();
32079
32161
  }
32080
32162
  return new Promise((resolve4, reject) => {
@@ -32086,28 +32168,28 @@ var ProjectMutationMutex = class {
32086
32168
  reject
32087
32169
  };
32088
32170
  waiter.onAbort = () => {
32089
- const queue2 = this.queues.get(key4);
32171
+ const queue2 = this.queues.get(key5);
32090
32172
  const index = queue2?.indexOf(waiter) ?? -1;
32091
32173
  if (!queue2 || index < 0) return;
32092
32174
  queue2.splice(index, 1);
32093
- if (queue2.length === 0) this.queues.delete(key4);
32175
+ if (queue2.length === 0) this.queues.delete(key5);
32094
32176
  reject(new Error("Project mutation wait aborted"));
32095
32177
  };
32096
32178
  signal?.addEventListener("abort", waiter.onAbort, { once: true });
32097
- const queue = this.queues.get(key4) ?? [];
32179
+ const queue = this.queues.get(key5) ?? [];
32098
32180
  queue.push(waiter);
32099
- this.queues.set(key4, queue);
32181
+ this.queues.set(key5, queue);
32100
32182
  });
32101
32183
  }
32102
- release(key4) {
32103
- const queue = this.queues.get(key4);
32184
+ release(key5) {
32185
+ const queue = this.queues.get(key5);
32104
32186
  const next = queue?.shift();
32105
- if (queue?.length === 0) this.queues.delete(key4);
32187
+ if (queue?.length === 0) this.queues.delete(key5);
32106
32188
  if (next) {
32107
32189
  next.start();
32108
32190
  return;
32109
32191
  }
32110
- this.active.delete(key4);
32192
+ this.active.delete(key5);
32111
32193
  }
32112
32194
  };
32113
32195
  var projectMutationMutex = new ProjectMutationMutex();
@@ -32232,7 +32314,7 @@ function exactValues(value, required, optional = []) {
32232
32314
  }
32233
32315
  function exactStringRecord(value, keys, message) {
32234
32316
  const values = exactValues(value, keys);
32235
- if (!values || keys.some((key4) => typeof values[key4] !== "string" || values[key4].length === 0)) throw new Error(message);
32317
+ if (!values || keys.some((key5) => typeof values[key5] !== "string" || values[key5].length === 0)) throw new Error(message);
32236
32318
  return values;
32237
32319
  }
32238
32320
  function date(value) {
@@ -32249,7 +32331,7 @@ function snapshotSource(value) {
32249
32331
  const content = exactValues(values?.content, ["type", "text"]);
32250
32332
  const createdAt = date(values?.createdAt);
32251
32333
  const mentions = snapshotMentions(values?.mentions);
32252
- if (!values || values.source !== "user" || author?.type !== "human" || typeof author.userId !== "string" || !author.userId || content?.type !== "text" || typeof content.text !== "string" || !mentions || !createdAt || ["id", "tenantId", "workspaceId", "projectId", "roomId"].some((key4) => typeof values[key4] !== "string" || !values[key4])) return void 0;
32334
+ if (!values || values.source !== "user" || author?.type !== "human" || typeof author.userId !== "string" || !author.userId || content?.type !== "text" || typeof content.text !== "string" || !mentions || !createdAt || ["id", "tenantId", "workspaceId", "projectId", "roomId"].some((key5) => typeof values[key5] !== "string" || !values[key5])) return void 0;
32253
32335
  return {
32254
32336
  id: values.id,
32255
32337
  tenantId: values.tenantId,
@@ -32284,7 +32366,7 @@ function snapshotMembership(value) {
32284
32366
  const values = exactValues(value, required, ["responsibility"]);
32285
32367
  const joinedAt = date(values?.joinedAt);
32286
32368
  const updatedAt = date(values?.updatedAt);
32287
- if (!values || required.slice(0, 7).some((key4) => typeof values[key4] !== "string" || !values[key4]) || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || !values.title || typeof values.mentionName !== "string" || !values.mentionName || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || !values.roomThreadId || values.responsibility !== void 0 && typeof values.responsibility !== "string" || !joinedAt || !updatedAt) return void 0;
32369
+ if (!values || required.slice(0, 7).some((key5) => typeof values[key5] !== "string" || !values[key5]) || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || !values.title || typeof values.mentionName !== "string" || !values.mentionName || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || !values.roomThreadId || values.responsibility !== void 0 && typeof values.responsibility !== "string" || !joinedAt || !updatedAt) return void 0;
32288
32370
  return { ...values, joinedAt, updatedAt };
32289
32371
  }
32290
32372
  function snapshotCanonical(value, expected) {
@@ -32421,12 +32503,12 @@ function sameRosterScope(membership, scope) {
32421
32503
  }
32422
32504
  function snapshotScope(value, keys) {
32423
32505
  const values = snapshotExactRecord6(value, keys);
32424
- if (!values || keys.some((key4) => !isNonemptyString(values[key4]))) return void 0;
32506
+ if (!values || keys.some((key5) => !isNonemptyString(values[key5]))) return void 0;
32425
32507
  return values;
32426
32508
  }
32427
32509
  function projectScope(scope, keys) {
32428
32510
  const projected = {};
32429
- for (const key4 of keys) projected[key4] = scope[key4];
32511
+ for (const key5 of keys) projected[key5] = scope[key5];
32430
32512
  return projected;
32431
32513
  }
32432
32514
  function snapshotMembership2(value) {
@@ -32668,7 +32750,7 @@ function detailOf(item) {
32668
32750
  return null;
32669
32751
  }
32670
32752
  const parsed = { key: impact.key, after: impact.after, basis: impact.basis };
32671
- if (Object.keys(impact).some((key4) => !(key4 in parsed))) return null;
32753
+ if (Object.keys(impact).some((key5) => !(key5 in parsed))) return null;
32672
32754
  beliefImpact.push(parsed);
32673
32755
  }
32674
32756
  let beliefOwner;
@@ -32834,17 +32916,17 @@ function clearInterruptionContext(current) {
32834
32916
  delete remaining.interruption;
32835
32917
  return Object.keys(remaining).length > 0 ? remaining : null;
32836
32918
  }
32837
- function withLifecycleAudit(current, key4, value) {
32919
+ function withLifecycleAudit(current, key5, value) {
32838
32920
  const context = clearInterruptionContext(current) ?? {};
32839
- return { ...context, [key4]: value };
32921
+ return { ...context, [key5]: value };
32840
32922
  }
32841
32923
  function withCompletionAudit(current, evidenceId, eventKey) {
32842
32924
  return { ...current ?? {}, lifecycle_completion_audit: { evidenceId, eventKey } };
32843
32925
  }
32844
- function withoutContextKey(current, key4) {
32926
+ function withoutContextKey(current, key5) {
32845
32927
  if (!current) return null;
32846
32928
  const remaining = { ...current };
32847
- delete remaining[key4];
32929
+ delete remaining[key5];
32848
32930
  return Object.keys(remaining).length > 0 ? remaining : null;
32849
32931
  }
32850
32932
  function preserveTargetContract(current, proposed) {
@@ -32868,9 +32950,9 @@ function changedBeliefKeys(left, right) {
32868
32950
  const leftByKey = new Map(left.map((entry) => [entry.key, entry]));
32869
32951
  const rightByKey = new Map(right.map((entry) => [entry.key, entry]));
32870
32952
  const keys = /* @__PURE__ */ new Set([...leftByKey.keys(), ...rightByKey.keys()]);
32871
- return [...keys].filter((key4) => {
32872
- const oldEntry = leftByKey.get(key4);
32873
- const newEntry = rightByKey.get(key4);
32953
+ return [...keys].filter((key5) => {
32954
+ const oldEntry = leftByKey.get(key5);
32955
+ const newEntry = rightByKey.get(key5);
32874
32956
  return !oldEntry || !newEntry || !taskBeliefStatesEqual(
32875
32957
  { entries: [oldEntry] },
32876
32958
  { entries: [newEntry] }
@@ -33888,7 +33970,7 @@ var TaskLifecycleService = class {
33888
33970
  const markdown = [
33889
33971
  "## Belief Reconciliation",
33890
33972
  "",
33891
- `Changed beliefs: ${changedKeys.map((key4) => `\`${key4}\``).join(", ")}.`
33973
+ `Changed beliefs: ${changedKeys.map((key5) => `\`${key5}\``).join(", ")}.`
33892
33974
  ].join("\n");
33893
33975
  try {
33894
33976
  await this.deps.workItemStore.createIfAbsentByEventKey({
@@ -34365,9 +34447,9 @@ var TaskLifecycleService = class {
34365
34447
  ]);
34366
34448
  let maxAttempt = 0;
34367
34449
  for (const item of [...decisions, ...evidence]) {
34368
- const key4 = typeof item.detail?.eventKey === "string" ? item.detail.eventKey : item.eventKey;
34369
- if (!key4 || baseAttemptEventKey(key4) !== baseEventKey) continue;
34370
- const match = key4.match(/:attempt:(\d+)$/);
34450
+ const key5 = typeof item.detail?.eventKey === "string" ? item.detail.eventKey : item.eventKey;
34451
+ if (!key5 || baseAttemptEventKey(key5) !== baseEventKey) continue;
34452
+ const match = key5.match(/:attempt:(\d+)$/);
34371
34453
  maxAttempt = Math.max(maxAttempt, match ? Number(match[1]) : 1);
34372
34454
  }
34373
34455
  return maxAttempt === 0 ? baseEventKey : `${baseEventKey}:attempt:${maxAttempt + 1}`;
@@ -34667,8 +34749,8 @@ var TaskLifecycleService = class {
34667
34749
  }
34668
34750
  return resumed;
34669
34751
  }
34670
- async clearAuditMarker(task, key4) {
34671
- const context = withoutContextKey(task.context, key4);
34752
+ async clearAuditMarker(task, key5) {
34753
+ const context = withoutContextKey(task.context, key5);
34672
34754
  try {
34673
34755
  return await this.deps.taskStore.updateIfStatusAndUpdatedAt(
34674
34756
  task.tenantId,
@@ -34820,16 +34902,16 @@ function serializedStringBytes(value) {
34820
34902
  }
34821
34903
  return typedArrayByteLength(encodeUtf8(stringifyJson(value)));
34822
34904
  }
34823
- function validatePropertyKey(key4) {
34824
- if (key4.length > JSON_SAFE_MAX_PROPERTY_KEY_LENGTH) {
34905
+ function validatePropertyKey(key5) {
34906
+ if (key5.length > JSON_SAFE_MAX_PROPERTY_KEY_LENGTH) {
34825
34907
  fail(
34826
34908
  "MAX_STRING_LENGTH",
34827
34909
  `JSON-safe property key exceeds ${JSON_SAFE_MAX_PROPERTY_KEY_LENGTH} characters`
34828
34910
  );
34829
34911
  }
34830
34912
  }
34831
- function chargePropertyKey(state, key4) {
34832
- state.propertyKeyBytes += typedArrayByteLength(encodeUtf8(key4));
34913
+ function chargePropertyKey(state, key5) {
34914
+ state.propertyKeyBytes += typedArrayByteLength(encodeUtf8(key5));
34833
34915
  if (state.propertyKeyBytes > JSON_SAFE_MAX_PROPERTY_KEY_BYTES) {
34834
34916
  fail(
34835
34917
  "MAX_PROPERTY_KEY_BYTES",
@@ -34849,8 +34931,8 @@ function chargeBytes(state, bytes) {
34849
34931
  function chargeString(state, value) {
34850
34932
  chargeBytes(state, serializedStringBytes(value));
34851
34933
  }
34852
- function objectPropertyPath(path8, key4) {
34853
- const boundedKey = key4.length > 128 ? `${stringSlice(key4, 0, 128)}...` : key4;
34934
+ function objectPropertyPath(path8, key5) {
34935
+ const boundedKey = key5.length > 128 ? `${stringSlice(key5, 0, 128)}...` : key5;
34854
34936
  return `${path8}[${stringifyJson(boundedKey)}]`;
34855
34937
  }
34856
34938
  function convertJsonValue(value, state, depth, inArray, path8) {
@@ -34953,27 +35035,27 @@ function convertJsonValue(value, state, depth, inArray, path8) {
34953
35035
  );
34954
35036
  }
34955
35037
  for (let index = 0; index < keys.length; index += 1) {
34956
- const key4 = keys[index];
34957
- if (typeof key4 !== "string") continue;
34958
- validatePropertyKey(key4);
34959
- chargePropertyKey(state, key4);
35038
+ const key5 = keys[index];
35039
+ if (typeof key5 !== "string") continue;
35040
+ validatePropertyKey(key5);
35041
+ chargePropertyKey(state, key5);
34960
35042
  }
34961
35043
  chargeBytes(state, 2);
34962
35044
  const result = objectCreate(null);
34963
35045
  let emittedProperties = 0;
34964
35046
  for (let index = 0; index < keys.length; index += 1) {
34965
- const key4 = keys[index];
34966
- const entryPath = typeof key4 === "string" ? objectPropertyPath(path8, key4) : path8;
35047
+ const key5 = keys[index];
35048
+ const entryPath = typeof key5 === "string" ? objectPropertyPath(path8, key5) : path8;
34967
35049
  const descriptor = propertyAccess(
34968
- () => reflectGetOwnPropertyDescriptor(value, key4),
35050
+ () => reflectGetOwnPropertyDescriptor(value, key5),
34969
35051
  entryPath
34970
35052
  );
34971
- if (typeof key4 !== "string" || !descriptor?.enumerable) continue;
34972
- const entry = propertyAccess(() => reflectGet(value, key4), entryPath);
35053
+ if (typeof key5 !== "string" || !descriptor?.enumerable) continue;
35054
+ const entry = propertyAccess(() => reflectGet(value, key5), entryPath);
34973
35055
  const converted = convertJsonValue(entry, state, depth + 1, false, entryPath);
34974
35056
  if (converted !== void 0) {
34975
- chargeBytes(state, serializedStringBytes(key4) + 1 + (emittedProperties === 0 ? 0 : 1));
34976
- propertyAccess(() => objectDefineProperty(result, key4, {
35057
+ chargeBytes(state, serializedStringBytes(key5) + 1 + (emittedProperties === 0 ? 0 : 1));
35058
+ propertyAccess(() => objectDefineProperty(result, key5, {
34977
35059
  value: converted,
34978
35060
  enumerable: true,
34979
35061
  configurable: true,
@@ -35419,16 +35501,16 @@ function getEncryptionKey() {
35419
35501
  if (cachedKey) {
35420
35502
  return cachedKey;
35421
35503
  }
35422
- const key4 = process.env.LATTICE_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
35423
- cachedKey = pbkdf2Sync(key4, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
35504
+ const key5 = process.env.LATTICE_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
35505
+ cachedKey = pbkdf2Sync(key5, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
35424
35506
  if (!keyValidated) {
35425
35507
  keyValidated = true;
35426
35508
  validateEncryptionKey();
35427
35509
  }
35428
35510
  return cachedKey;
35429
35511
  }
35430
- function encrypt(plaintext, key4) {
35431
- const actualKey = key4 || getEncryptionKey();
35512
+ function encrypt(plaintext, key5) {
35513
+ const actualKey = key5 || getEncryptionKey();
35432
35514
  const salt = randomBytes4(SALT_LENGTH);
35433
35515
  const iv = randomBytes4(IV_LENGTH);
35434
35516
  const derivedKey = pbkdf2Sync(actualKey, salt, ITERATIONS, 32, "sha256");
@@ -35437,8 +35519,8 @@ function encrypt(plaintext, key4) {
35437
35519
  const authTag = cipher.getAuthTag();
35438
35520
  return Buffer.concat([salt, iv, encrypted, authTag]).toString("base64");
35439
35521
  }
35440
- function decrypt(encrypted, key4) {
35441
- const actualKey = key4 || getEncryptionKey();
35522
+ function decrypt(encrypted, key5) {
35523
+ const actualKey = key5 || getEncryptionKey();
35442
35524
  const data = Buffer.from(encrypted, "base64");
35443
35525
  const salt = data.subarray(0, SALT_LENGTH);
35444
35526
  const iv = data.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
@@ -36082,15 +36164,15 @@ async function resolveClientFromConnections(connectionKey, buildResolved, runCon
36082
36164
  "No semantic-metrics connection is configured for this tenant. Add a connection of type 'semantic-metrics' for the tenant, then select it (connections) or enable connectAll in the agent's middleware config."
36083
36165
  );
36084
36166
  }
36085
- const key4 = connectionKey?.trim() || (resolved.length === 1 ? resolved[0].key : "");
36086
- if (!key4) {
36167
+ const key5 = connectionKey?.trim() || (resolved.length === 1 ? resolved[0].key : "");
36168
+ if (!key5) {
36087
36169
  throw new Error(
36088
36170
  `connectionKey is required. Available connections: ${available}`
36089
36171
  );
36090
36172
  }
36091
- const entry = resolved.find((c) => c.key === key4);
36173
+ const entry = resolved.find((c) => c.key === key5);
36092
36174
  if (!entry) {
36093
- throw new Error(`Connection "${key4}" not found. Available connections: ${available}`);
36175
+ throw new Error(`Connection "${key5}" not found. Available connections: ${available}`);
36094
36176
  }
36095
36177
  const config = entry.config;
36096
36178
  return new SemanticMetricsV2Client(config);
@@ -37355,7 +37437,7 @@ function getEffectiveCollectionScope(exeConfig, staticScope) {
37355
37437
  const runtimeConfig = getRuntimeCapabilityConfig(exeConfig, "collection");
37356
37438
  const hasRuntimeKeys = runtimeConfig !== void 0 && Object.prototype.hasOwnProperty.call(runtimeConfig, "collectionKeys");
37357
37439
  const runtimeKeys = hasRuntimeKeys ? runtimeConfig.collectionKeys : void 0;
37358
- const collectionKeys = Array.isArray(runtimeKeys) && runtimeKeys.every((key4) => typeof key4 === "string") ? runtimeKeys : hasRuntimeKeys ? [] : staticScope.collectionKeys;
37440
+ const collectionKeys = Array.isArray(runtimeKeys) && runtimeKeys.every((key5) => typeof key5 === "string") ? runtimeKeys : hasRuntimeKeys ? [] : staticScope.collectionKeys;
37359
37441
  const hasRuntimeConnectAll = runtimeConfig !== void 0 && Object.prototype.hasOwnProperty.call(runtimeConfig, "connectAll");
37360
37442
  const connectAll = !hasRuntimeKeys && (hasRuntimeConnectAll ? runtimeConfig.connectAll === true && staticScope.connectAll !== false : staticScope.connectAll === true);
37361
37443
  return { collectionKeys, connectAll };
@@ -37657,7 +37739,7 @@ var schema3 = z64.object({
37657
37739
  content: z64.string().describe("Entry content text"),
37658
37740
  metadata: z64.record(z64.unknown()).optional().describe("Metadata fields matching the collection schema")
37659
37741
  });
37660
- function key(t, n) {
37742
+ function key2(t, n) {
37661
37743
  return `${t}:${n}`;
37662
37744
  }
37663
37745
  var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => tool59(
@@ -37668,7 +37750,7 @@ var createAddEntryTool = (scope = { collectionKeys: [], connectAll: true }) => t
37668
37750
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
37669
37751
  let vs;
37670
37752
  try {
37671
- vs = vectorStoreLatticeManager.getVectorStoreClient(key(tenantId2, input.collection));
37753
+ vs = vectorStoreLatticeManager.getVectorStoreClient(key2(tenantId2, input.collection));
37672
37754
  } catch {
37673
37755
  const collection = await collectionLatticeManager.getCollection(tenantId2, input.collection);
37674
37756
  if (!collection) return `Collection "${input.collection}" not found.`;
@@ -37700,7 +37782,7 @@ var schema4 = z65.object({
37700
37782
  content: z65.string().optional().describe("New content"),
37701
37783
  metadata: z65.record(z65.unknown()).optional().describe("New metadata")
37702
37784
  });
37703
- function key2(t, n) {
37785
+ function key3(t, n) {
37704
37786
  return `${t}:${n}`;
37705
37787
  }
37706
37788
  var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) => tool60(
@@ -37709,7 +37791,7 @@ var createUpdateEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
37709
37791
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
37710
37792
  if (scopeError) return scopeError;
37711
37793
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
37712
- const vs = vectorStoreLatticeManager.getVectorStoreClient(key2(tenantId2, input.collection));
37794
+ const vs = vectorStoreLatticeManager.getVectorStoreClient(key3(tenantId2, input.collection));
37713
37795
  try {
37714
37796
  await vs.delete({ filter: { _id: input.entryId } });
37715
37797
  } catch {
@@ -37730,7 +37812,7 @@ var schema5 = z66.object({
37730
37812
  collection: z66.string().describe("Collection name"),
37731
37813
  entryId: z66.string().describe("Entry ID to delete")
37732
37814
  });
37733
- function key3(t, n) {
37815
+ function key4(t, n) {
37734
37816
  return `${t}:${n}`;
37735
37817
  }
37736
37818
  var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) => tool61(
@@ -37739,7 +37821,7 @@ var createDeleteEntryTool = (scope = { collectionKeys: [], connectAll: true }) =
37739
37821
  const scopeError = validateCollectionScope(input.collection, _exeConfig, scope);
37740
37822
  if (scopeError) return scopeError;
37741
37823
  const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
37742
- const vs = vectorStoreLatticeManager.getVectorStoreClient(key3(tenantId2, input.collection));
37824
+ const vs = vectorStoreLatticeManager.getVectorStoreClient(key4(tenantId2, input.collection));
37743
37825
  await vs.delete({ filter: { _id: input.entryId } });
37744
37826
  return `Entry ${input.entryId} deleted from "${input.collection}".`;
37745
37827
  } catch {
@@ -39031,7 +39113,7 @@ function serializeTaskMutationSuccess(taskId, task, mutationCommitted, metadata
39031
39113
  try {
39032
39114
  const normal = objectCreate2(null);
39033
39115
  normal.success = true;
39034
- for (const key4 of objectKeys(metadata)) normal[key4] = metadata[key4];
39116
+ for (const key5 of objectKeys(metadata)) normal[key5] = metadata[key5];
39035
39117
  normal.data = task;
39036
39118
  return stringifyJson2(normal);
39037
39119
  } catch {
@@ -39292,9 +39374,9 @@ function notifyProjectTaskAdmission(task) {
39292
39374
  function trustedSharedContext(context) {
39293
39375
  const snapshot = context === void 0 ? {} : safeDataValue(context);
39294
39376
  const safe = {};
39295
- for (const [key4, value] of Object.entries(snapshot)) {
39296
- if (key4 === "thread_id" || key4 === "interruption" || key4.endsWith("_audit")) continue;
39297
- safe[key4] = value;
39377
+ for (const [key5, value] of Object.entries(snapshot)) {
39378
+ if (key5 === "thread_id" || key5 === "interruption" || key5.endsWith("_audit")) continue;
39379
+ safe[key5] = value;
39298
39380
  }
39299
39381
  return safe;
39300
39382
  }
@@ -39304,11 +39386,11 @@ function safeDataValue(value, seen = /* @__PURE__ */ new Set()) {
39304
39386
  if (!value || typeof value !== "object" || seen.has(value)) throw new Error("Invalid trusted task row");
39305
39387
  seen.add(value);
39306
39388
  const descriptors = Object.getOwnPropertyDescriptors(value);
39307
- const entries = Object.entries(descriptors).filter(([key4]) => !(Array.isArray(value) && key4 === "length"));
39389
+ const entries = Object.entries(descriptors).filter(([key5]) => !(Array.isArray(value) && key5 === "length"));
39308
39390
  if (Object.getOwnPropertySymbols(value).length > 0 || entries.some(([, descriptor]) => !descriptor.enumerable || !("value" in descriptor))) {
39309
39391
  throw new Error("Invalid trusted task row");
39310
39392
  }
39311
- const clone3 = Array.isArray(value) ? entries.sort(([a], [b]) => Number(a) - Number(b)).map(([, descriptor]) => safeDataValue(descriptor.value, seen)) : Object.fromEntries(entries.map(([key4, descriptor]) => [key4, safeDataValue(descriptor.value, seen)]));
39393
+ const clone3 = Array.isArray(value) ? entries.sort(([a], [b]) => Number(a) - Number(b)).map(([, descriptor]) => safeDataValue(descriptor.value, seen)) : Object.fromEntries(entries.map(([key5, descriptor]) => [key5, safeDataValue(descriptor.value, seen)]));
39312
39394
  seen.delete(value);
39313
39395
  return clone3;
39314
39396
  }
@@ -39316,7 +39398,7 @@ function safeTrustedListTask(value, scope) {
39316
39398
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
39317
39399
  const descriptors = Object.getOwnPropertyDescriptors(value);
39318
39400
  const required = ["id", "tenantId", "workspaceId", "projectId", "ownerType", "ownerId", "title", "status", "priority", "createdAt", "updatedAt"];
39319
- if (required.some((key4) => !descriptors[key4]?.enumerable || !("value" in descriptors[key4]))) return void 0;
39401
+ if (required.some((key5) => !descriptors[key5]?.enumerable || !("value" in descriptors[key5]))) return void 0;
39320
39402
  let row;
39321
39403
  try {
39322
39404
  row = safeDataValue(value);
@@ -39717,7 +39799,7 @@ function canonicalValue(value) {
39717
39799
  if (value instanceof Date) return value.toISOString();
39718
39800
  if (Array.isArray(value)) return value.map(canonicalValue);
39719
39801
  if (!value || typeof value !== "object") return value;
39720
- return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key4, entry]) => [key4, canonicalValue(entry)]));
39802
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key5, entry]) => [key5, canonicalValue(entry)]));
39721
39803
  }
39722
39804
  function valuesEqual(left, right) {
39723
39805
  return JSON.stringify(canonicalValue(left)) === JSON.stringify(canonicalValue(right));
@@ -42416,7 +42498,7 @@ function createParseDocumentTool({
42416
42498
  const runtimeConnections = runtimeConfig && Object.prototype.hasOwnProperty.call(runtimeConfig, "connections") ? runtimeConfig.connections : void 0;
42417
42499
  const hasRuntimeConnections = runtimeConfig !== void 0 && Object.prototype.hasOwnProperty.call(runtimeConfig, "connections");
42418
42500
  const runtimeConnectAll = !hasRuntimeConnections && runtimeConfig?.connectAll === true && connectAll !== false;
42419
- const effectiveConnections = Array.isArray(runtimeConnections) && runtimeConnections.every((key4) => typeof key4 === "string") ? runtimeConnections : runtimeConnectAll ? [] : connections;
42501
+ const effectiveConnections = Array.isArray(runtimeConnections) && runtimeConnections.every((key5) => typeof key5 === "string") ? runtimeConnections : runtimeConnectAll ? [] : connections;
42420
42502
  const effectiveConnectAll = !hasRuntimeConnections && runtimeConfig && typeof runtimeConfig.connectAll === "boolean" ? runtimeConfig.connectAll && connectAll !== false : !hasRuntimeConnections && connectAll === true;
42421
42503
  if (hasRuntimeConnections || effectiveConnections.length > 0 || runtimeConfig?.connectAll === true) {
42422
42504
  resolvedBaseUrl = "";
@@ -42942,7 +43024,7 @@ function createDocumentParserMiddleware(config) {
42942
43024
  const connectAll = config.connectAll === true;
42943
43025
  const baseUrl = config.baseUrl || "";
42944
43026
  const apiKey = config.apiKey || "";
42945
- const connections = Array.isArray(config.connections) ? config.connections.filter((key4) => typeof key4 === "string") : [];
43027
+ const connections = Array.isArray(config.connections) ? config.connections.filter((key5) => typeof key5 === "string") : [];
42946
43028
  return createMiddleware25({
42947
43029
  name: "DocumentParser",
42948
43030
  contextSchema,
@@ -43088,10 +43170,10 @@ var postSchema = z73.object({
43088
43170
  text: z73.string().trim().min(1).max(2e4)
43089
43171
  }).strict();
43090
43172
  var listSchema = z73.object({}).strict();
43091
- function ownDataValue2(record, key4) {
43173
+ function ownDataValue2(record, key5) {
43092
43174
  if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
43093
43175
  try {
43094
- const descriptor = Object.getOwnPropertyDescriptor(record, key4);
43176
+ const descriptor = Object.getOwnPropertyDescriptor(record, key5);
43095
43177
  return descriptorDataValue2(descriptor)?.value;
43096
43178
  } catch {
43097
43179
  return void 0;
@@ -43141,7 +43223,7 @@ function snapshotMembership3(value) {
43141
43223
  const values = exactValues2(value, required, ["responsibility"]);
43142
43224
  const joinedAt = safeDate(values?.joinedAt);
43143
43225
  const updatedAt = safeDate(values?.updatedAt);
43144
- if (!values || !joinedAt || !updatedAt || required.slice(0, 6).some((key4) => typeof values[key4] !== "string" || values[key4] === "") || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || values.title === "" || typeof values.mentionName !== "string" || values.mentionName === "" || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || values.roomThreadId === "" || values.responsibility !== void 0 && typeof values.responsibility !== "string") return void 0;
43226
+ if (!values || !joinedAt || !updatedAt || required.slice(0, 6).some((key5) => typeof values[key5] !== "string" || values[key5] === "") || values.role !== "coordinator" && values.role !== "specialist" || typeof values.title !== "string" || values.title === "" || typeof values.mentionName !== "string" || values.mentionName === "" || !["active", "paused", "removed"].includes(values.status) || typeof values.roomThreadId !== "string" || values.roomThreadId === "" || values.responsibility !== void 0 && typeof values.responsibility !== "string") return void 0;
43145
43227
  return { ...values, joinedAt, updatedAt };
43146
43228
  }
43147
43229
  function snapshotRows(value) {
@@ -43618,8 +43700,8 @@ var IdRemapper = class {
43618
43700
  }
43619
43701
  if (typeof value === "object") {
43620
43702
  const result = {};
43621
- for (const [key4, val] of Object.entries(value)) {
43622
- result[key4] = this.remapReferences(val);
43703
+ for (const [key5, val] of Object.entries(value)) {
43704
+ result[key5] = this.remapReferences(val);
43623
43705
  }
43624
43706
  return result;
43625
43707
  }
@@ -43717,6 +43799,7 @@ export {
43717
43799
  InMemoryProjectMembershipStore,
43718
43800
  InMemoryProjectRoomCoordinator,
43719
43801
  InMemoryProjectRoomMessageStore,
43802
+ InMemoryProjectRoomReadStateStore,
43720
43803
  InMemoryProjectRoomStore,
43721
43804
  InMemoryTaskListStore,
43722
43805
  InMemoryTaskStore,