@axiom-lattice/gateway 4.10.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{OrphanRecoveryRuntime-BEFILJMU.mjs → OrphanRecoveryRuntime-T4T5NOZU.mjs} +2 -2
  2. package/dist/{a2a-standard-PBYPNHOA.mjs → a2a-standard-3OZFXDCW.mjs} +1 -1
  3. package/dist/a2a-standard-3OZFXDCW.mjs.map +1 -0
  4. package/dist/{chunk-ZBTG3T7K.mjs → chunk-NZXKECNN.mjs} +4 -19
  5. package/dist/{chunk-ZBTG3T7K.mjs.map → chunk-NZXKECNN.mjs.map} +1 -1
  6. package/dist/embed/{embed-page-AgentDetailSideApp-2M4MLVQQ.js → embed-page-AgentDetailSideApp-XCP4LY7Y.js} +1 -1
  7. package/dist/embed/{embed-page-AgentGovernanceWorkbench-KEVBIQP6.js → embed-page-AgentGovernanceWorkbench-BBDKEIBI.js} +1 -1
  8. package/dist/embed/{embed-page-MessageGraph-PRBUQINR.js → embed-page-MessageGraph-D77CYFAG.js} +1 -1
  9. package/dist/embed/{embed-page-ReactChart-V6JJXCEV.js → embed-page-ReactChart-TBDJOTZ5.js} +1 -1
  10. package/dist/embed/{embed-page-SkillFlow-6LPE2VG3.js → embed-page-SkillFlow-NDAK3GAD.js} +1 -1
  11. package/dist/embed/{embed-page-TasksSideApp-OFZI54MF.js → embed-page-TasksSideApp-BVCIAE24.js} +5 -5
  12. package/dist/embed/{embed-page-TeamWorkspace-QSSAF3AA.js → embed-page-TeamWorkspace-JFEKNVFP.js} +1 -1
  13. package/dist/embed/{embed-page-TopologyRuntimeView-PHULW2NG.js → embed-page-TopologyRuntimeView-42TN76MK.js} +1 -1
  14. package/dist/embed/{embed-page-WorkflowAutomationView-LQS6H7X6.js → embed-page-WorkflowAutomationView-JLP4UHPP.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-O44JEYLD.js → embed-page-chunk-2PFKLMTR.js} +5 -5
  16. package/dist/embed/{embed-page-chunk-IJ2YWGKU.js → embed-page-chunk-5NJ3O2GK.js} +1 -1
  17. package/dist/embed/{embed-page-chunk-D5EY6ASK.js → embed-page-chunk-GUSAII2D.js} +1 -1
  18. package/dist/embed/{embed-page-chunk-SSWDAKQU.js → embed-page-chunk-H64UEFHS.js} +1 -1
  19. package/dist/embed/{embed-page-chunk-PFCR6CFL.js → embed-page-chunk-I3OONX3N.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-YNHKD2CY.js → embed-page-chunk-K2U3JD67.js} +1 -1
  21. package/dist/embed/{embed-page-chunk-7PNQFZMK.js → embed-page-chunk-YYDZ6ZBV.js} +307 -191
  22. package/dist/embed/{embed-page-en-PQZ2ZCEH.js → embed-page-en-GLT2HEZZ.js} +1 -1
  23. package/dist/embed/{embed-page-zh-D3EX4GW4.js → embed-page-zh-XMEJPDMF.js} +1 -1
  24. package/dist/embed/embed-page.js +1 -1
  25. package/dist/index.d.mts +20 -7
  26. package/dist/index.d.ts +20 -7
  27. package/dist/index.js +853 -736
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +420 -291
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +7 -7
  32. package/dist/a2a-standard-PBYPNHOA.mjs.map +0 -1
  33. /package/dist/{OrphanRecoveryRuntime-BEFILJMU.mjs.map → OrphanRecoveryRuntime-T4T5NOZU.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -38,21 +38,21 @@ __export(collection_service_exports, {
38
38
  function getTenantId5(request) {
39
39
  return request.user?.tenantId || request.headers["x-tenant-id"] || "default";
40
40
  }
41
- var import_uuid2, import_documents, import_core11, CollectionService;
41
+ var import_uuid2, import_documents, import_core12, CollectionService;
42
42
  var init_collection_service = __esm({
43
43
  "src/services/collection_service.ts"() {
44
44
  "use strict";
45
45
  import_uuid2 = require("uuid");
46
46
  import_documents = require("@langchain/core/documents");
47
- import_core11 = require("@axiom-lattice/core");
47
+ import_core12 = require("@axiom-lattice/core");
48
48
  CollectionService = class {
49
49
  // ─── Collection CRUD ──────────────────────────────────────────
50
50
  async getAllCollections(request) {
51
51
  const tenantId = getTenantId5(request);
52
- const collections = await import_core11.collectionLatticeManager.getAllCollections(tenantId);
52
+ const collections = await import_core12.collectionLatticeManager.getAllCollections(tenantId);
53
53
  for (const c2 of collections) {
54
54
  try {
55
- c2._entryCount = await (0, import_core11.getCollectionEntryCount)(c2.name, c2.embeddingKey, c2.tenantId);
55
+ c2._entryCount = await (0, import_core12.getCollectionEntryCount)(c2.name, c2.embeddingKey, c2.tenantId);
56
56
  } catch {
57
57
  c2._entryCount = 0;
58
58
  }
@@ -61,13 +61,13 @@ var init_collection_service = __esm({
61
61
  }
62
62
  async getCollectionByName(request, name) {
63
63
  const tenantId = getTenantId5(request);
64
- return import_core11.collectionLatticeManager.getCollection(tenantId, name);
64
+ return import_core12.collectionLatticeManager.getCollection(tenantId, name);
65
65
  }
66
66
  async createCollection(request, data) {
67
67
  const tenantId = getTenantId5(request);
68
- const collection = await import_core11.collectionLatticeManager.registerCollection(tenantId, data);
68
+ const collection = await import_core12.collectionLatticeManager.registerCollection(tenantId, data);
69
69
  try {
70
- await (0, import_core11.getOrCreateCollectionVectorStore)(data.name, data.embeddingKey, tenantId);
70
+ await (0, import_core12.getOrCreateCollectionVectorStore)(data.name, data.embeddingKey, tenantId);
71
71
  } catch (err) {
72
72
  console.warn(`[CollectionService] Failed to init vector store for ${data.name}:`, err);
73
73
  }
@@ -75,18 +75,18 @@ var init_collection_service = __esm({
75
75
  }
76
76
  async updateCollection(request, name, updates) {
77
77
  const tenantId = getTenantId5(request);
78
- return import_core11.collectionLatticeManager.updateCollection(tenantId, name, updates);
78
+ return import_core12.collectionLatticeManager.updateCollection(tenantId, name, updates);
79
79
  }
80
80
  async deleteCollection(request, name) {
81
81
  const tenantId = getTenantId5(request);
82
- await (0, import_core11.removeCollectionVectorStore)(name, tenantId);
83
- return import_core11.collectionLatticeManager.removeCollection(tenantId, name);
82
+ await (0, import_core12.removeCollectionVectorStore)(name, tenantId);
83
+ return import_core12.collectionLatticeManager.removeCollection(tenantId, name);
84
84
  }
85
85
  // ─── Entry CRUD ───────────────────────────────────────────────
86
86
  async getEntries(request, collectionName) {
87
87
  const collection = await this.getCollectionByName(request, collectionName);
88
88
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
89
- const docs = await (0, import_core11.listCollectionEntries)(collectionName, collection.embeddingKey, collection.tenantId);
89
+ const docs = await (0, import_core12.listCollectionEntries)(collectionName, collection.embeddingKey, collection.tenantId);
90
90
  return docs.map((doc) => ({
91
91
  id: doc.metadata._id || "",
92
92
  content: doc.pageContent,
@@ -98,7 +98,7 @@ var init_collection_service = __esm({
98
98
  async createEntry(request, collectionName, data) {
99
99
  const collection = await this.getCollectionByName(request, collectionName);
100
100
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
101
- const vectorStore = await (0, import_core11.getOrCreateCollectionVectorStore)(
101
+ const vectorStore = await (0, import_core12.getOrCreateCollectionVectorStore)(
102
102
  collectionName,
103
103
  collection.embeddingKey,
104
104
  collection.tenantId
@@ -120,7 +120,7 @@ var init_collection_service = __esm({
120
120
  async getEntry(request, collectionName, entryId) {
121
121
  const collection = await this.getCollectionByName(request, collectionName);
122
122
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
123
- const docs = await (0, import_core11.listCollectionEntries)(collectionName, collection.embeddingKey, collection.tenantId);
123
+ const docs = await (0, import_core12.listCollectionEntries)(collectionName, collection.embeddingKey, collection.tenantId);
124
124
  const doc = docs.find((d) => d.metadata._id === entryId);
125
125
  if (!doc) return null;
126
126
  return {
@@ -136,7 +136,7 @@ var init_collection_service = __esm({
136
136
  if (!existing) return null;
137
137
  const collection = await this.getCollectionByName(request, collectionName);
138
138
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
139
- const vectorStore = await (0, import_core11.getOrCreateCollectionVectorStore)(
139
+ const vectorStore = await (0, import_core12.getOrCreateCollectionVectorStore)(
140
140
  collectionName,
141
141
  collection.embeddingKey,
142
142
  collection.tenantId
@@ -157,7 +157,7 @@ var init_collection_service = __esm({
157
157
  async deleteEntry(request, collectionName, entryId) {
158
158
  const collection = await this.getCollectionByName(request, collectionName);
159
159
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
160
- const vectorStore = await (0, import_core11.getOrCreateCollectionVectorStore)(
160
+ const vectorStore = await (0, import_core12.getOrCreateCollectionVectorStore)(
161
161
  collectionName,
162
162
  collection.embeddingKey,
163
163
  collection.tenantId
@@ -172,16 +172,16 @@ var init_collection_service = __esm({
172
172
  async searchEntries(request, collectionName, params) {
173
173
  const collection = await this.getCollectionByName(request, collectionName);
174
174
  if (!collection) throw new Error(`Collection "${collectionName}" not found`);
175
- const vectorStore = await (0, import_core11.getOrCreateCollectionVectorStore)(
175
+ const vectorStore = await (0, import_core12.getOrCreateCollectionVectorStore)(
176
176
  collectionName,
177
177
  collection.embeddingKey,
178
178
  collection.tenantId
179
179
  );
180
180
  let embeddings;
181
181
  try {
182
- embeddings = import_core11.embeddingsLatticeManager.getEmbeddingsClient(collection.embeddingKey);
182
+ embeddings = import_core12.embeddingsLatticeManager.getEmbeddingsClient(collection.embeddingKey);
183
183
  } catch {
184
- embeddings = import_core11.embeddingsLatticeManager.getEmbeddingsClient("default");
184
+ embeddings = import_core12.embeddingsLatticeManager.getEmbeddingsClient("default");
185
185
  }
186
186
  const queryVector = await embeddings.embedQuery(params.query);
187
187
  const results = await vectorStore.similaritySearchVectorWithScore(
@@ -318,7 +318,7 @@ function secret() {
318
318
  function signOpenToken(payload) {
319
319
  const data = { ...payload, exp: payload.exp ?? Date.now() + 15 * 60 * 1e3 };
320
320
  const encoded = Buffer.from(JSON.stringify(data)).toString("base64url");
321
- const sig = (0, import_crypto5.createHmac)("sha256", secret()).update(encoded).digest("base64url");
321
+ const sig = (0, import_crypto4.createHmac)("sha256", secret()).update(encoded).digest("base64url");
322
322
  return `${encoded}.${sig}`;
323
323
  }
324
324
  function verifyOpenToken(bearer) {
@@ -330,8 +330,8 @@ function verifyOpenToken(bearer) {
330
330
  try {
331
331
  const actual = Buffer.from(sigStr, "base64url");
332
332
  if (actual.toString("base64url") !== sigStr) return null;
333
- const expected = (0, import_crypto5.createHmac)("sha256", secret()).update(encoded).digest();
334
- if (actual.length !== expected.length || !(0, import_crypto5.timingSafeEqual)(actual, expected)) return null;
333
+ const expected = (0, import_crypto4.createHmac)("sha256", secret()).update(encoded).digest();
334
+ if (actual.length !== expected.length || !(0, import_crypto4.timingSafeEqual)(actual, expected)) return null;
335
335
  const payload = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
336
336
  if (typeof payload !== "object" || payload === null) return null;
337
337
  const p = payload;
@@ -343,11 +343,11 @@ function verifyOpenToken(bearer) {
343
343
  return null;
344
344
  }
345
345
  }
346
- var import_crypto5;
346
+ var import_crypto4;
347
347
  var init_openToken = __esm({
348
348
  "src/services/open/openToken.ts"() {
349
349
  "use strict";
350
- import_crypto5 = require("crypto");
350
+ import_crypto4 = require("crypto");
351
351
  }
352
352
  });
353
353
 
@@ -415,8 +415,8 @@ function filesystemRootDirectory(tenantId, workspaceId, projectId) {
415
415
  return `/lattice_store/tenants/${tenantId}/workspaces/${workspaceId}/${projectId}`;
416
416
  }
417
417
  async function saveProjectFile(params) {
418
- const workspaceStore = (0, import_core24.getStoreLattice)("default", "workspace").store;
419
- const projectStore = (0, import_core24.getStoreLattice)("default", "project").store;
418
+ const workspaceStore = (0, import_core25.getStoreLattice)("default", "workspace").store;
419
+ const projectStore = (0, import_core25.getStoreLattice)("default", "project").store;
420
420
  let workspaceId = params.workspaceId;
421
421
  if (!workspaceId) {
422
422
  const project = await projectStore.getProjectById(
@@ -442,7 +442,7 @@ async function saveProjectFile(params) {
442
442
  throw new ProjectFileValidationError("Invalid filename");
443
443
  }
444
444
  if (workspace.storageType === "sandbox") {
445
- const sandboxManager = (0, import_core24.getSandBoxManager)();
445
+ const sandboxManager = (0, import_core25.getSandBoxManager)();
446
446
  const volumeConfig = {
447
447
  assistant_id: params.assistantId || "",
448
448
  thread_id: "",
@@ -495,13 +495,13 @@ async function saveProjectFile(params) {
495
495
  const uri = path3.posix.join("/", relativeDirectory, filename);
496
496
  return { uri, name: filename, size: stat3.size };
497
497
  }
498
- var fs3, path3, import_core24, BINARY_EXTENSIONS, ProjectFileValidationError;
498
+ var fs3, path3, import_core25, BINARY_EXTENSIONS, ProjectFileValidationError;
499
499
  var init_workspace_file_service = __esm({
500
500
  "src/services/workspace-file-service.ts"() {
501
501
  "use strict";
502
502
  fs3 = __toESM(require("fs/promises"));
503
503
  path3 = __toESM(require("path"));
504
- import_core24 = require("@axiom-lattice/core");
504
+ import_core25 = require("@axiom-lattice/core");
505
505
  init_path_containment();
506
506
  BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
507
507
  "pdf",
@@ -573,13 +573,13 @@ async function invokePluginTool(deps, tenantId, pluginType, name, args, runConte
573
573
  maxResultBytes: tool.maxResultBytes
574
574
  });
575
575
  if (!result.ok) throw new Error(result.error ?? "sandbox plugin execution failed");
576
- return result.result === void 0 ? (0, import_core35.handlerResultText)(result) : result.result;
576
+ return result.result === void 0 ? (0, import_core36.handlerResultText)(result) : result.result;
577
577
  }
578
- var import_core35, PluginToolScopeError;
578
+ var import_core36, PluginToolScopeError;
579
579
  var init_pluginToolExecution = __esm({
580
580
  "src/services/plugins/pluginToolExecution.ts"() {
581
581
  "use strict";
582
- import_core35 = require("@axiom-lattice/core");
582
+ import_core36 = require("@axiom-lattice/core");
583
583
  PluginToolScopeError = class extends Error {
584
584
  /**
585
585
  * @param name - Rejected tool name.
@@ -1145,8 +1145,8 @@ async function refreshStoreKeyMap() {
1145
1145
  function broadcastA2AKeyChanged(tenantId) {
1146
1146
  if (!tenantId) return;
1147
1147
  try {
1148
- const outbox = (0, import_core58.getStoreLattice)("default", "outbox").store;
1149
- void publishA2AKeyChanged(outbox, (0, import_core58.getReplicaId)(), tenantId);
1148
+ const outbox = (0, import_core59.getStoreLattice)("default", "outbox").store;
1149
+ void publishA2AKeyChanged(outbox, (0, import_core59.getReplicaId)(), tenantId);
1150
1150
  } catch {
1151
1151
  }
1152
1152
  }
@@ -1322,11 +1322,11 @@ function registerA2ARoutes(app2) {
1322
1322
  );
1323
1323
  }
1324
1324
  }
1325
- var import_core58, _a2aKeyStore, _a2aAuthService;
1325
+ var import_core59, _a2aKeyStore, _a2aAuthService;
1326
1326
  var init_a2a = __esm({
1327
1327
  "src/routes/a2a.ts"() {
1328
1328
  "use strict";
1329
- import_core58 = require("@axiom-lattice/core");
1329
+ import_core59 = require("@axiom-lattice/core");
1330
1330
  init_A2AAuthService();
1331
1331
  init_a2aKeySync();
1332
1332
  _a2aKeyStore = null;
@@ -1543,25 +1543,14 @@ function createTaskRunLiveness() {
1543
1543
  } catch {
1544
1544
  return void 0;
1545
1545
  }
1546
- return async (task) => {
1547
- try {
1548
- const store2 = import_core77.storeLatticeManager.getStoreLattice("default", "lease").store;
1549
- if (await store2.get((0, import_core77.taskRunLeaseKey)(task.id))) return true;
1550
- const threadId = typeof task.context?.thread_id === "string" ? task.context.thread_id : void 0;
1551
- if (threadId && task.ownerId) {
1552
- if (await store2.get((0, import_core77.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
1553
- }
1554
- return false;
1555
- } catch {
1556
- return true;
1557
- }
1558
- };
1546
+ return (task) => (0, import_core78.isTaskRunLeaseHeld)(task);
1559
1547
  }
1560
- var import_core77;
1548
+ var import_core77, import_core78;
1561
1549
  var init_taskRunLiveness = __esm({
1562
1550
  "src/services/collaboration/taskRunLiveness.ts"() {
1563
1551
  "use strict";
1564
1552
  import_core77 = require("@axiom-lattice/core");
1553
+ import_core78 = require("@axiom-lattice/core");
1565
1554
  }
1566
1555
  });
1567
1556
 
@@ -1571,7 +1560,7 @@ __export(OrphanRecoveryRuntime_exports, {
1571
1560
  createOrphanRecoveryRuntime: () => createOrphanRecoveryRuntime
1572
1561
  });
1573
1562
  function createOrphanRecoveryRuntime(deps) {
1574
- const lifecycle = deps.lifecycle ?? (0, import_core78.createTaskLifecycleService)({
1563
+ const lifecycle = deps.lifecycle ?? (0, import_core79.createTaskLifecycleService)({
1575
1564
  taskStore: deps.taskStore,
1576
1565
  workItemStore: deps.workItemStore
1577
1566
  });
@@ -1579,7 +1568,7 @@ function createOrphanRecoveryRuntime(deps) {
1579
1568
  async recoverAll() {
1580
1569
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1581
1570
  return runOrphanRecovery({
1582
- reconcile: () => (0, import_core78.reconcileAllTenantTaskRuns)({
1571
+ reconcile: () => (0, import_core79.reconcileAllTenantTaskRuns)({
1583
1572
  actor: "system:orphan-recovery",
1584
1573
  tenantStore: {
1585
1574
  listTenants: async () => (await deps.tenantStore.getAllTenants()).map((tenant2) => ({ id: tenant2.id }))
@@ -1605,7 +1594,7 @@ function createOrphanRecoveryRuntime(deps) {
1605
1594
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1606
1595
  return recoverTask(task, {
1607
1596
  lifecycle,
1608
- registry: import_core78.taskRunRegistry,
1597
+ registry: import_core79.taskRunRegistry,
1609
1598
  orphans,
1610
1599
  callerFor: deps.callerFor,
1611
1600
  resume: deps.resume,
@@ -1614,11 +1603,11 @@ function createOrphanRecoveryRuntime(deps) {
1614
1603
  }
1615
1604
  };
1616
1605
  }
1617
- var import_core78;
1606
+ var import_core79;
1618
1607
  var init_OrphanRecoveryRuntime = __esm({
1619
1608
  "src/services/collaboration/OrphanRecoveryRuntime.ts"() {
1620
1609
  "use strict";
1621
- import_core78 = require("@axiom-lattice/core");
1610
+ import_core79 = require("@axiom-lattice/core");
1622
1611
  init_TopCallerRecovery();
1623
1612
  init_projectTaskScope();
1624
1613
  init_taskRunLiveness();
@@ -1634,12 +1623,12 @@ function createRecoveryCallerDeps() {
1634
1623
  return {
1635
1624
  callerFor: async (top, tenantId) => {
1636
1625
  if (!top.assistantId) return void 0;
1637
- const load = import_core79.getAgentClientAsync ?? import_core79.getAgentClient;
1626
+ const load = import_core80.getAgentClientAsync ?? import_core80.getAgentClient;
1638
1627
  const client = await load(tenantId, top.assistantId);
1639
1628
  const config = { configurable: { thread_id: top.threadId, runConfig: { tenantId, assistant_id: top.assistantId } } };
1640
1629
  let agent;
1641
1630
  try {
1642
- agent = import_core79.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1631
+ agent = import_core80.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1643
1632
  } catch {
1644
1633
  }
1645
1634
  return agent ? { client, config, agent } : { client, config };
@@ -1656,11 +1645,11 @@ function createRecoveryCallerDeps() {
1656
1645
  }
1657
1646
  };
1658
1647
  }
1659
- var import_core79;
1648
+ var import_core80;
1660
1649
  var init_RecoveryCallerDeps = __esm({
1661
1650
  "src/services/collaboration/RecoveryCallerDeps.ts"() {
1662
1651
  "use strict";
1663
- import_core79 = require("@axiom-lattice/core");
1652
+ import_core80 = require("@axiom-lattice/core");
1664
1653
  }
1665
1654
  });
1666
1655
 
@@ -2079,13 +2068,13 @@ function isA2ATaskSnapshot(value) {
2079
2068
  function snapshotSequence(value) {
2080
2069
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
2081
2070
  }
2082
- var import_node_crypto31, import_node_util, import_core80, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2071
+ var import_node_crypto31, import_node_util, import_core81, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2083
2072
  var init_A2ATaskStoreAdapter = __esm({
2084
2073
  "src/services/a2a/A2ATaskStoreAdapter.ts"() {
2085
2074
  "use strict";
2086
2075
  import_node_crypto31 = require("crypto");
2087
2076
  import_node_util = require("util");
2088
- import_core80 = require("@axiom-lattice/core");
2077
+ import_core81 = require("@axiom-lattice/core");
2089
2078
  TASK_STATUS_TO_A2A_STATE = {
2090
2079
  pending: "submitted",
2091
2080
  in_progress: "working",
@@ -2111,7 +2100,7 @@ var init_A2ATaskStoreAdapter = __esm({
2111
2100
  this.workItemStore = options.workItemStore;
2112
2101
  this.lifecycle = options.lifecycle;
2113
2102
  this.scope = options.scope;
2114
- this.runBridge = (0, import_core80.createTaskRunBridge)({
2103
+ this.runBridge = (0, import_core81.createTaskRunBridge)({
2115
2104
  lifecycle: this.lifecycle,
2116
2105
  taskStore: this.taskStore,
2117
2106
  workItemStore: this.workItemStore
@@ -2462,12 +2451,12 @@ function assistantHasGovernedTask(assistant) {
2462
2451
  const allowedTools = taskMiddleware?.allowedTools;
2463
2452
  return !!taskMiddleware && (allowedTools === void 0 || Array.isArray(allowedTools) && (allowedTools.length === 0 || allowedTools.includes("manage_task")));
2464
2453
  }
2465
- var import_uuid11, import_core81, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2454
+ var import_uuid11, import_core82, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2466
2455
  var init_AxiomAgentExecutor = __esm({
2467
2456
  "src/services/a2a/AxiomAgentExecutor.ts"() {
2468
2457
  "use strict";
2469
2458
  import_uuid11 = require("uuid");
2470
- import_core81 = require("@axiom-lattice/core");
2459
+ import_core82 = require("@axiom-lattice/core");
2471
2460
  import_protocols35 = require("@axiom-lattice/protocols");
2472
2461
  init_a2aFileRefs();
2473
2462
  init_task_file_refs();
@@ -2564,7 +2553,7 @@ var init_AxiomAgentExecutor = __esm({
2564
2553
  await this.taskStore.save(initialTask);
2565
2554
  bus.publish(initialTask);
2566
2555
  try {
2567
- const agent = import_core81.agentInstanceManager.getAgent(this.agentParams(threadId));
2556
+ const agent = import_core82.agentInstanceManager.getAgent(this.agentParams(threadId));
2568
2557
  const requestText = inputFiles.length > 0 ? `${text}
2569
2558
 
2570
2559
  ${formatFileRefsSection(inputFiles)}` : text;
@@ -2752,7 +2741,7 @@ ${formatFileRefsSection(inputFiles)}` : text;
2752
2741
  const threadId = task ? asString2(task.metadata?.threadId) : void 0;
2753
2742
  if (threadId) {
2754
2743
  try {
2755
- const agent = import_core81.agentInstanceManager.getAgent(this.agentParams(threadId));
2744
+ const agent = import_core82.agentInstanceManager.getAgent(this.agentParams(threadId));
2756
2745
  await agent.abort();
2757
2746
  } catch (err) {
2758
2747
  console.warn({
@@ -3126,10 +3115,10 @@ function isAsyncGenerator(value) {
3126
3115
  }
3127
3116
  function registerA2AStandardRoutes(app2, deps) {
3128
3117
  const authService = deps.authService;
3129
- const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core82.getStoreLattice)("default", "task").store);
3130
- const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core82.getStoreLattice)("default", "taskWorkItem").store);
3131
- const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core82.getStoreLattice)("default", "assistant").store);
3132
- const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core82.getStoreLattice)("default", "project").store);
3118
+ const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core83.getStoreLattice)("default", "task").store);
3119
+ const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core83.getStoreLattice)("default", "taskWorkItem").store);
3120
+ const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core83.getStoreLattice)("default", "assistant").store);
3121
+ const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core83.getStoreLattice)("default", "project").store);
3133
3122
  const runtimeRegistry = deps.runtimeRegistry ?? new A2ARuntimeRegistry();
3134
3123
  app2.addHook("onClose", async () => {
3135
3124
  runtimeRegistry.close();
@@ -3212,7 +3201,7 @@ function registerA2AStandardRoutes(app2, deps) {
3212
3201
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
3213
3202
  taskStore: internalTasks,
3214
3203
  workItemStore: workItems,
3215
- lifecycle: (0, import_core82.createTaskLifecycleService)({
3204
+ lifecycle: (0, import_core83.createTaskLifecycleService)({
3216
3205
  taskStore: internalTasks,
3217
3206
  workItemStore: workItems
3218
3207
  }),
@@ -3331,7 +3320,7 @@ data: ${JSON.stringify(errorResponse)}
3331
3320
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
3332
3321
  taskStore: internalTasks,
3333
3322
  workItemStore: workItems,
3334
- lifecycle: (0, import_core82.createTaskLifecycleService)({
3323
+ lifecycle: (0, import_core83.createTaskLifecycleService)({
3335
3324
  taskStore: internalTasks,
3336
3325
  workItemStore: workItems
3337
3326
  }),
@@ -3386,13 +3375,13 @@ data: ${JSON.stringify(data)}
3386
3375
  }
3387
3376
  );
3388
3377
  }
3389
- var import_uuid12, import_server2, import_core82, SSE_HEADERS;
3378
+ var import_uuid12, import_server2, import_core83, SSE_HEADERS;
3390
3379
  var init_a2a_standard = __esm({
3391
3380
  "src/routes/a2a-standard.ts"() {
3392
3381
  "use strict";
3393
3382
  import_uuid12 = require("uuid");
3394
3383
  import_server2 = require("@a2a-js/sdk/server");
3395
- import_core82 = require("@axiom-lattice/core");
3384
+ import_core83 = require("@axiom-lattice/core");
3396
3385
  init_A2AAuthService();
3397
3386
  init_A2AAgentCardBuilder();
3398
3387
  init_A2ATaskStoreAdapter();
@@ -3848,7 +3837,7 @@ async function buildSessionServer(options) {
3848
3837
  }
3849
3838
  const transport = new import_streamableHttp.StreamableHTTPServerTransport({
3850
3839
  sessionIdGenerator: () => {
3851
- const sessionId = (0, import_crypto13.randomUUID)();
3840
+ const sessionId = (0, import_crypto12.randomUUID)();
3852
3841
  void registerSession(
3853
3842
  sessionId,
3854
3843
  { credentialId: credential.credentialId, kind: credential.kind },
@@ -3865,13 +3854,13 @@ async function buildSessionServer(options) {
3865
3854
  });
3866
3855
  return { server, transport, tools: catalog };
3867
3856
  }
3868
- var import_mcp, import_streamableHttp, import_crypto13, OPEN_MCP_SERVER_INFO;
3857
+ var import_mcp, import_streamableHttp, import_crypto12, OPEN_MCP_SERVER_INFO;
3869
3858
  var init_openMcpServer = __esm({
3870
3859
  "src/services/open/openMcpServer.ts"() {
3871
3860
  "use strict";
3872
3861
  import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
3873
3862
  import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
3874
- import_crypto13 = require("crypto");
3863
+ import_crypto12 = require("crypto");
3875
3864
  init_mcpTransportRegistry();
3876
3865
  OPEN_MCP_SERVER_INFO = {
3877
3866
  name: "axiom-open",
@@ -3959,8 +3948,8 @@ function exposedDeclarations(plugin) {
3959
3948
  return (plugin.meta.tools ?? []).filter((t2) => t2.expose);
3960
3949
  }
3961
3950
  async function registerExposedPluginTools() {
3962
- for (const key of import_core83.PluginRegistry.list()) {
3963
- const plugin = import_core83.PluginRegistry.get(key);
3951
+ for (const key of import_core84.PluginRegistry.list()) {
3952
+ const plugin = import_core84.PluginRegistry.get(key);
3964
3953
  if (!plugin?.middleware) continue;
3965
3954
  const exposed = exposedDeclarations(plugin);
3966
3955
  if (exposed.length === 0) continue;
@@ -3995,8 +3984,8 @@ async function registerExposedPluginTools() {
3995
3984
  }
3996
3985
  function collectExposedPluginUiResources(grants) {
3997
3986
  const resources = /* @__PURE__ */ new Map();
3998
- for (const type of import_core83.PluginRegistry.list()) {
3999
- const plugin = import_core83.PluginRegistry.get(type);
3987
+ for (const type of import_core84.PluginRegistry.list()) {
3988
+ const plugin = import_core84.PluginRegistry.get(type);
4000
3989
  if (!plugin?.middleware) continue;
4001
3990
  const exposedNames = new Set(exposedDeclarations(plugin).map((d) => d.name));
4002
3991
  if (exposedNames.size === 0) continue;
@@ -4020,11 +4009,11 @@ function collectExposedPluginUiResources(grants) {
4020
4009
  }
4021
4010
  return resources;
4022
4011
  }
4023
- var import_core83;
4012
+ var import_core84;
4024
4013
  var init_registerExposedPlugins = __esm({
4025
4014
  "src/services/open/registerExposedPlugins.ts"() {
4026
4015
  "use strict";
4027
- import_core83 = require("@axiom-lattice/core");
4016
+ import_core84 = require("@axiom-lattice/core");
4028
4017
  init_openLattice();
4029
4018
  init_pluginExposeAdapter();
4030
4019
  }
@@ -4039,14 +4028,14 @@ function toText(result) {
4039
4028
  }
4040
4029
  function defaultCatalog() {
4041
4030
  return {
4042
- getValidatedManifest: (tenantId, type) => (0, import_core84.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
4043
- getExecutor: () => (0, import_core84.getSandboxPluginCatalog)().getExecutor(),
4044
- readPluginFile: (tenantId, type, relPath) => (0, import_core84.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
4031
+ getValidatedManifest: (tenantId, type) => (0, import_core85.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
4032
+ getExecutor: () => (0, import_core85.getSandboxPluginCatalog)().getExecutor(),
4033
+ readPluginFile: (tenantId, type, relPath) => (0, import_core85.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
4045
4034
  };
4046
4035
  }
4047
4036
  async function defaultResolveConnections(pluginType, ctx) {
4048
4037
  try {
4049
- return await (0, import_core84.resolveSandboxPluginConnections)(
4038
+ return await (0, import_core85.resolveSandboxPluginConnections)(
4050
4039
  pluginType,
4051
4040
  { connectAll: true },
4052
4041
  {
@@ -4075,7 +4064,7 @@ function mergeOpenCatalog(globalCatalog, tenantTools) {
4075
4064
  async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4076
4065
  const catalog = deps.catalog ?? defaultCatalog();
4077
4066
  const listPlugins = deps.listPlugins ?? (async (tenant2) => {
4078
- const snapshot = await (0, import_core84.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4067
+ const snapshot = await (0, import_core85.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4079
4068
  return { plugins: snapshot.plugins, diagnostics: snapshot.diagnostics };
4080
4069
  });
4081
4070
  const resolveConnections = deps.resolveConnections ?? defaultResolveConnections;
@@ -4117,7 +4106,7 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4117
4106
  domain,
4118
4107
  action: tool.name,
4119
4108
  description: tool.description,
4120
- schema: (0, import_core84.jsonSchemaToZod)(tool.schema),
4109
+ schema: (0, import_core85.jsonSchemaToZod)(tool.schema),
4121
4110
  annotations: {
4122
4111
  readOnlyHint: tool.readOnly ?? false,
4123
4112
  destructiveHint: tool.destructive ?? false
@@ -4168,11 +4157,11 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4168
4157
  }
4169
4158
  };
4170
4159
  }
4171
- var import_core84;
4160
+ var import_core85;
4172
4161
  var init_tenantOpenPlugins = __esm({
4173
4162
  "src/services/open/tenantOpenPlugins.ts"() {
4174
4163
  "use strict";
4175
- import_core84 = require("@axiom-lattice/core");
4164
+ import_core85 = require("@axiom-lattice/core");
4176
4165
  init_openLattice();
4177
4166
  init_pluginToolExecution();
4178
4167
  }
@@ -4209,13 +4198,13 @@ function emptyTenantPlugins() {
4209
4198
  }
4210
4199
  function registerOpenRoutes(app2, deps = {}) {
4211
4200
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4212
- (0, import_core85.getStoreLattice)("default", "a2aApiKey").store,
4213
- (0, import_core85.getStoreLattice)("default", "project").store
4201
+ (0, import_core86.getStoreLattice)("default", "a2aApiKey").store,
4202
+ (0, import_core86.getStoreLattice)("default", "project").store
4214
4203
  );
4215
4204
  const grantsSource = deps.grantsSource ?? ((ctx) => ctx.grants);
4216
4205
  const audit = deps.audit ?? (() => {
4217
4206
  try {
4218
- const store2 = (0, import_core85.getStoreLattice)("default", "openAudit").store;
4207
+ const store2 = (0, import_core86.getStoreLattice)("default", "openAudit").store;
4219
4208
  return new OpenAuditService(store2);
4220
4209
  } catch {
4221
4210
  return void 0;
@@ -4370,12 +4359,12 @@ function registerOpenRoutes(app2, deps = {}) {
4370
4359
  }
4371
4360
  );
4372
4361
  }
4373
- var import_types, import_core85, RPC_ERROR;
4362
+ var import_types, import_core86, RPC_ERROR;
4374
4363
  var init_open = __esm({
4375
4364
  "src/routes/open.ts"() {
4376
4365
  "use strict";
4377
4366
  import_types = require("@modelcontextprotocol/sdk/types.js");
4378
- import_core85 = require("@axiom-lattice/core");
4367
+ import_core86 = require("@axiom-lattice/core");
4379
4368
  init_openCredentialService();
4380
4369
  init_openAuditService();
4381
4370
  init_openRateLimiter();
@@ -4408,7 +4397,7 @@ function registerOpenSessionRoutes(app2) {
4408
4397
  if (typeof shareToken !== "string" || shareToken.length === 0) {
4409
4398
  return reply.status(400).send({ error: "SHARE_TOKEN_REQUIRED" });
4410
4399
  }
4411
- const store2 = (0, import_core86.getStoreLattice)("default", "sharedResource").store;
4400
+ const store2 = (0, import_core87.getStoreLattice)("default", "sharedResource").store;
4412
4401
  const record = await store2.findByToken(shareToken);
4413
4402
  if (!record || record.revoked) {
4414
4403
  return reply.status(404).send({ error: "SHARE_NOT_FOUND" });
@@ -4433,11 +4422,11 @@ function registerOpenSessionRoutes(app2) {
4433
4422
  }
4434
4423
  );
4435
4424
  }
4436
- var import_core86;
4425
+ var import_core87;
4437
4426
  var init_open_session = __esm({
4438
4427
  "src/routes/open-session.ts"() {
4439
4428
  "use strict";
4440
- import_core86 = require("@axiom-lattice/core");
4429
+ import_core87 = require("@axiom-lattice/core");
4441
4430
  init_openToken();
4442
4431
  init_previewToken();
4443
4432
  init_openLattice();
@@ -4446,13 +4435,13 @@ var init_open_session = __esm({
4446
4435
 
4447
4436
  // src/services/open/openCatalogService.ts
4448
4437
  async function defaultListTenantPlugins(tenantId) {
4449
- return (await (0, import_core87.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4438
+ return (await (0, import_core88.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4450
4439
  }
4451
- var import_core87, OpenCatalogService;
4440
+ var import_core88, OpenCatalogService;
4452
4441
  var init_openCatalogService = __esm({
4453
4442
  "src/services/open/openCatalogService.ts"() {
4454
4443
  "use strict";
4455
- import_core87 = require("@axiom-lattice/core");
4444
+ import_core88 = require("@axiom-lattice/core");
4456
4445
  init_openLattice();
4457
4446
  OpenCatalogService = class {
4458
4447
  constructor(assistantStore, lattice = openLattice, listTenantPlugins2 = defaultListTenantPlugins) {
@@ -4527,17 +4516,17 @@ function registerOpenCatalogRoutes(app2) {
4527
4516
  if (!tenantId) {
4528
4517
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4529
4518
  }
4530
- const assistantStore = (0, import_core88.getStoreLattice)("default", "assistant").store;
4519
+ const assistantStore = (0, import_core89.getStoreLattice)("default", "assistant").store;
4531
4520
  const service2 = new OpenCatalogService(assistantStore);
4532
4521
  const catalog = await service2.buildForTenant(tenantId);
4533
4522
  return reply.status(200).send({ success: true, data: catalog });
4534
4523
  });
4535
4524
  }
4536
- var import_core88;
4525
+ var import_core89;
4537
4526
  var init_open_catalog = __esm({
4538
4527
  "src/routes/open-catalog.ts"() {
4539
4528
  "use strict";
4540
- import_core88 = require("@axiom-lattice/core");
4529
+ import_core89 = require("@axiom-lattice/core");
4541
4530
  init_openCatalogService();
4542
4531
  }
4543
4532
  });
@@ -4552,11 +4541,11 @@ async function resolveContextSandbox(ctx) {
4552
4541
  const sandboxName = ctx.runConfig?.sandboxName;
4553
4542
  if (typeof sandboxName === "string" && sandboxName.length > 0) {
4554
4543
  try {
4555
- return await import_core89.sandboxLatticeManager.getSandbox(sandboxName);
4544
+ return await import_core90.sandboxLatticeManager.getSandbox(sandboxName);
4556
4545
  } catch {
4557
4546
  }
4558
4547
  }
4559
- return import_core89.sandboxLatticeManager.getSandboxFromConfig({
4548
+ return import_core90.sandboxLatticeManager.getSandboxFromConfig({
4560
4549
  assistant_id: "",
4561
4550
  thread_id: "",
4562
4551
  tenantId: ctx.tenantId,
@@ -4654,12 +4643,12 @@ ${truncated}`
4654
4643
  }
4655
4644
  };
4656
4645
  }
4657
- var import_zod22, import_core89, MAX_OUTPUT_BYTES;
4646
+ var import_zod22, import_core90, MAX_OUTPUT_BYTES;
4658
4647
  var init_sandboxProvider = __esm({
4659
4648
  "src/services/open/providers/sandboxProvider.ts"() {
4660
4649
  "use strict";
4661
4650
  import_zod22 = require("zod");
4662
- import_core89 = require("@axiom-lattice/core");
4651
+ import_core90 = require("@axiom-lattice/core");
4663
4652
  MAX_OUTPUT_BYTES = 64e3;
4664
4653
  }
4665
4654
  });
@@ -4681,12 +4670,12 @@ function safePath(raw) {
4681
4670
  }
4682
4671
  function registerOpenFilesRoutes(app2, deps = {}) {
4683
4672
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4684
- (0, import_core90.getStoreLattice)("default", "a2aApiKey").store,
4685
- (0, import_core90.getStoreLattice)("default", "project").store
4673
+ (0, import_core91.getStoreLattice)("default", "a2aApiKey").store,
4674
+ (0, import_core91.getStoreLattice)("default", "project").store
4686
4675
  );
4687
4676
  const audit = deps.audit ?? (() => {
4688
4677
  try {
4689
- const store2 = (0, import_core90.getStoreLattice)("default", "openAudit").store;
4678
+ const store2 = (0, import_core91.getStoreLattice)("default", "openAudit").store;
4690
4679
  return new OpenAuditService(store2);
4691
4680
  } catch {
4692
4681
  return void 0;
@@ -4796,11 +4785,11 @@ function registerOpenFilesRoutes(app2, deps = {}) {
4796
4785
  }
4797
4786
  });
4798
4787
  }
4799
- var import_core90;
4788
+ var import_core91;
4800
4789
  var init_open_files = __esm({
4801
4790
  "src/routes/open-files.ts"() {
4802
4791
  "use strict";
4803
- import_core90 = require("@axiom-lattice/core");
4792
+ import_core91 = require("@axiom-lattice/core");
4804
4793
  init_openCredentialService();
4805
4794
  init_openLattice();
4806
4795
  init_sandboxProvider();
@@ -4822,7 +4811,7 @@ function registerOpenAuditRoutes(app2) {
4822
4811
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4823
4812
  }
4824
4813
  const status = request.query.status === "ok" || request.query.status === "error" ? request.query.status : void 0;
4825
- const store2 = (0, import_core91.getStoreLattice)("default", "openAudit").store;
4814
+ const store2 = (0, import_core92.getStoreLattice)("default", "openAudit").store;
4826
4815
  const records = await store2.query({
4827
4816
  tenantId,
4828
4817
  credentialId: request.query.credentialId,
@@ -4837,11 +4826,11 @@ function registerOpenAuditRoutes(app2) {
4837
4826
  }
4838
4827
  );
4839
4828
  }
4840
- var import_core91;
4829
+ var import_core92;
4841
4830
  var init_open_audit = __esm({
4842
4831
  "src/routes/open-audit.ts"() {
4843
4832
  "use strict";
4844
- import_core91 = require("@axiom-lattice/core");
4833
+ import_core92 = require("@axiom-lattice/core");
4845
4834
  }
4846
4835
  });
4847
4836
 
@@ -4858,7 +4847,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4858
4847
  if (!tenantId) {
4859
4848
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4860
4849
  }
4861
- const keyStore = (0, import_core92.getStoreLattice)("default", "a2aApiKey").store;
4850
+ const keyStore = (0, import_core93.getStoreLattice)("default", "a2aApiKey").store;
4862
4851
  const record = await keyStore.findById(request.params.id);
4863
4852
  if (!record || record.tenantId !== tenantId) {
4864
4853
  return reply.status(404).send({ success: false, error: "Key not found" });
@@ -4892,7 +4881,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4892
4881
  hasUi: Boolean(t2.ui)
4893
4882
  }));
4894
4883
  const agentGrant = grants.find((g) => g.domain === "agent");
4895
- const assistantStore = (0, import_core92.getStoreLattice)("default", "assistant").store;
4884
+ const assistantStore = (0, import_core93.getStoreLattice)("default", "assistant").store;
4896
4885
  const agents = [];
4897
4886
  for (const assistantId of agentGrant?.items ?? []) {
4898
4887
  const assistant = await assistantStore.getAssistantById(
@@ -4927,11 +4916,11 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4927
4916
  }
4928
4917
  );
4929
4918
  }
4930
- var import_core92, import_protocols38;
4919
+ var import_core93, import_protocols38;
4931
4920
  var init_open_exposure = __esm({
4932
4921
  "src/routes/open-exposure.ts"() {
4933
4922
  "use strict";
4934
- import_core92 = require("@axiom-lattice/core");
4923
+ import_core93 = require("@axiom-lattice/core");
4935
4924
  import_protocols38 = require("@axiom-lattice/protocols");
4936
4925
  init_openLattice();
4937
4926
  init_tenantOpenPlugins();
@@ -5051,7 +5040,7 @@ function createAgentProvider(deps = {}) {
5051
5040
  } catch {
5052
5041
  }
5053
5042
  }
5054
- const agent = import_core93.agentInstanceManager.getAgent({
5043
+ const agent = import_core94.agentInstanceManager.getAgent({
5055
5044
  tenant_id: ctx.tenantId,
5056
5045
  assistant_id: assistantId,
5057
5046
  thread_id: threadId,
@@ -5076,12 +5065,12 @@ function createAgentProvider(deps = {}) {
5076
5065
  }
5077
5066
  };
5078
5067
  }
5079
- var import_zod24, import_core93, import_protocols39, STOP_TYPES;
5068
+ var import_zod24, import_core94, import_protocols39, STOP_TYPES;
5080
5069
  var init_agentProvider = __esm({
5081
5070
  "src/services/open/providers/agentProvider.ts"() {
5082
5071
  "use strict";
5083
5072
  import_zod24 = require("zod");
5084
- import_core93 = require("@axiom-lattice/core");
5073
+ import_core94 = require("@axiom-lattice/core");
5085
5074
  import_protocols39 = require("@axiom-lattice/protocols");
5086
5075
  STOP_TYPES = [import_protocols39.MessageChunkTypes.MESSAGE_COMPLETED];
5087
5076
  }
@@ -5184,11 +5173,11 @@ async function resolveAgentOpenGrants(tenantId, assistantId, deps) {
5184
5173
  }
5185
5174
  }
5186
5175
  function createDefaultAgentReflectionDeps(tenantId) {
5187
- (0, import_core94.ensureBuiltinAgentsForTenant)(tenantId);
5176
+ (0, import_core95.ensureBuiltinAgentsForTenant)(tenantId);
5188
5177
  return {
5189
- ensure: (t2) => import_core94.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5178
+ ensure: (t2) => import_core95.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5190
5179
  getAgentConfig: (t2, assistantId) => {
5191
- const config = import_core94.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5180
+ const config = import_core95.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5192
5181
  if (!config) return void 0;
5193
5182
  return {
5194
5183
  middleware: extractMiddleware(config),
@@ -5196,16 +5185,16 @@ function createDefaultAgentReflectionDeps(tenantId) {
5196
5185
  };
5197
5186
  },
5198
5187
  getAssistantMiddleware: async (t2, assistantId) => {
5199
- const store2 = (0, import_core94.getStoreLattice)("default", "assistant").store;
5188
+ const store2 = (0, import_core95.getStoreLattice)("default", "assistant").store;
5200
5189
  const assistant = await store2.getAssistantById(t2, assistantId);
5201
5190
  return extractMiddleware(assistant?.graphDefinition);
5202
5191
  },
5203
5192
  exposedActionsByType: (type) => {
5204
- const plugin = import_core94.PluginRegistry.get(type);
5193
+ const plugin = import_core95.PluginRegistry.get(type);
5205
5194
  return plugin ? normalizeOpenExpose(plugin.meta.openExpose) : [];
5206
5195
  },
5207
5196
  resolvableAssistants: async (t2) => new Set(
5208
- import_core94.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5197
+ import_core95.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5209
5198
  )
5210
5199
  };
5211
5200
  }
@@ -5270,30 +5259,30 @@ function buildTenantExposedGrants(manifests) {
5270
5259
  }
5271
5260
  function createDefaultPluginReflectionDeps() {
5272
5261
  return {
5273
- ensure: (tenantId) => import_core94.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5262
+ ensure: (tenantId) => import_core95.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5274
5263
  globalExposedDomains: () => {
5275
5264
  const grants = [];
5276
- for (const type of import_core94.PluginRegistry.list()) {
5277
- const plugin = import_core94.PluginRegistry.get(type);
5265
+ for (const type of import_core95.PluginRegistry.list()) {
5266
+ const plugin = import_core95.PluginRegistry.get(type);
5278
5267
  const items = normalizeOpenExpose(plugin?.meta.openExpose);
5279
5268
  if (items.length > 0) grants.push({ domain: type, items });
5280
5269
  }
5281
5270
  return grants;
5282
5271
  },
5283
5272
  tenantExposedDomains: async (tenantId) => {
5284
- const { manifests } = await (0, import_core94.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5273
+ const { manifests } = await (0, import_core95.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5285
5274
  return buildTenantExposedGrants(Object.values(manifests));
5286
5275
  },
5287
5276
  resolvableAssistants: async (tenantId) => new Set(
5288
- import_core94.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5277
+ import_core95.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5289
5278
  )
5290
5279
  };
5291
5280
  }
5292
- var import_core94, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5281
+ var import_core95, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5293
5282
  var init_sandboxOpenReflection = __esm({
5294
5283
  "src/services/open/sandboxOpenReflection.ts"() {
5295
5284
  "use strict";
5296
- import_core94 = require("@axiom-lattice/core");
5285
+ import_core95 = require("@axiom-lattice/core");
5297
5286
  AGENT_REFLECTION_CACHE_TTL_MS = 6e4;
5298
5287
  cache = /* @__PURE__ */ new Map();
5299
5288
  PLUGIN_REFLECTION_CACHE_TTL_MS = 6e4;
@@ -5339,7 +5328,7 @@ function createSandboxOpenCredentialProvider(options) {
5339
5328
  };
5340
5329
  }
5341
5330
  function registerGatewaySandboxOpenCredentialProvider(onError) {
5342
- return (0, import_core95.registerSandboxOpenCredentialProvider)(
5331
+ return (0, import_core96.registerSandboxOpenCredentialProvider)(
5343
5332
  createSandboxOpenCredentialProvider({
5344
5333
  gatewayUrl: process.env.PUBLIC_GATEWAY_URL?.trim() || void 0,
5345
5334
  onError
@@ -5347,11 +5336,11 @@ function registerGatewaySandboxOpenCredentialProvider(onError) {
5347
5336
  { onError }
5348
5337
  );
5349
5338
  }
5350
- var import_core95, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5339
+ var import_core96, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5351
5340
  var init_sandboxOpenCredentialProvider = __esm({
5352
5341
  "src/services/open/sandboxOpenCredentialProvider.ts"() {
5353
5342
  "use strict";
5354
- import_core95 = require("@axiom-lattice/core");
5343
+ import_core96 = require("@axiom-lattice/core");
5355
5344
  init_openToken();
5356
5345
  init_sandboxOpenReflection();
5357
5346
  DEFAULT_SANDBOX_OPEN_GRANTS = [
@@ -5388,12 +5377,12 @@ var resources_exports = {};
5388
5377
  __export(resources_exports, {
5389
5378
  ResourceController: () => ResourceController
5390
5379
  });
5391
- var import_bcryptjs, import_core96, ResourceController;
5380
+ var import_bcryptjs, import_core97, ResourceController;
5392
5381
  var init_resources = __esm({
5393
5382
  "src/controllers/resources.ts"() {
5394
5383
  "use strict";
5395
5384
  import_bcryptjs = __toESM(require("bcryptjs"));
5396
- import_core96 = require("@axiom-lattice/core");
5385
+ import_core97 = require("@axiom-lattice/core");
5397
5386
  init_mime();
5398
5387
  init_http_range();
5399
5388
  init_sandboxGrants();
@@ -5410,14 +5399,14 @@ var init_resources = __esm({
5410
5399
  if (!workspaceId || !projectId) {
5411
5400
  return reply.status(400).send({ error: "x-workspace-id and x-project-id headers required" });
5412
5401
  }
5413
- const payload = (0, import_core96.createSharePayload)(
5402
+ const payload = (0, import_core97.createSharePayload)(
5414
5403
  tenantId,
5415
5404
  workspaceId,
5416
5405
  projectId,
5417
5406
  userId,
5418
5407
  body
5419
5408
  );
5420
- const token = (0, import_core96.generateToken)();
5409
+ const token = (0, import_core97.generateToken)();
5421
5410
  try {
5422
5411
  await this.deps.store.create({ ...payload, token });
5423
5412
  this.deps.logger.info(
@@ -5569,7 +5558,7 @@ var init_resources = __esm({
5569
5558
  resourcePath: subPath
5570
5559
  }, subPath, ext, request, reply);
5571
5560
  }
5572
- const volume = (0, import_core96.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5561
+ const volume = (0, import_core97.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5573
5562
  return this._resolveAndServe(
5574
5563
  volume,
5575
5564
  subPath,
@@ -7654,6 +7643,9 @@ var setQueueServiceType = (type) => {
7654
7643
  }
7655
7644
  (0, import_core8.registerQueueLattice)(DEFAULT_QUEUE_KEY, config, client);
7656
7645
  };
7646
+ var getQueueServiceType = () => {
7647
+ return queueServiceType;
7648
+ };
7657
7649
  var getQueueService = () => {
7658
7650
  if (!import_core8.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
7659
7651
  setQueueServiceType(queueServiceType);
@@ -7851,6 +7843,66 @@ async function updateModels(request, reply) {
7851
7843
  }
7852
7844
  }
7853
7845
 
7846
+ // src/services/multiReplicaReadiness.ts
7847
+ var import_core10 = require("@axiom-lattice/core");
7848
+ var SHARED_STORE_KINDS = [
7849
+ "lease",
7850
+ "outbox",
7851
+ "threadMessageQueue",
7852
+ "task",
7853
+ "taskWorkItem",
7854
+ "channelInstallation"
7855
+ ];
7856
+ function isMultiReplicaDeclared() {
7857
+ return typeof process.env.AXIOM_REPLICA_ID === "string" && process.env.AXIOM_REPLICA_ID.trim() !== "";
7858
+ }
7859
+ function storeClassName(kind) {
7860
+ try {
7861
+ return (0, import_core10.getStoreLattice)("default", kind).store.constructor?.name;
7862
+ } catch {
7863
+ return void 0;
7864
+ }
7865
+ }
7866
+ function computeMultiReplicaReadiness() {
7867
+ const multiReplicaDeclared = isMultiReplicaDeclared();
7868
+ const warnings = [];
7869
+ if (!multiReplicaDeclared) {
7870
+ return { multiReplicaDeclared, ok: true, warnings };
7871
+ }
7872
+ for (const kind of SHARED_STORE_KINDS) {
7873
+ const name = storeClassName(kind);
7874
+ if (name === void 0 || !name.startsWith("InMemory")) continue;
7875
+ warnings.push(`Multi-replica: store '${kind}' is ${name} (not shared); configure a shared store`);
7876
+ }
7877
+ if (!process.env.AUTH_TOKEN_SECRET?.trim() && !process.env.JWT_SECRET?.trim()) {
7878
+ warnings.push(
7879
+ "Multi-replica: AUTH_TOKEN_SECRET/JWT_SECRET unset; console sessions are signed per-process and will not verify across replicas"
7880
+ );
7881
+ }
7882
+ if (!process.env.LATTICE_ENCRYPTION_KEY?.trim()) {
7883
+ warnings.push(
7884
+ "Multi-replica: LATTICE_ENCRYPTION_KEY unset; stored credentials use the shared dev default and may not decrypt across differing keys"
7885
+ );
7886
+ }
7887
+ if (getQueueServiceType() !== "redis") {
7888
+ warnings.push(
7889
+ "Multi-replica: task queue service is 'memory' (not shared); set QUEUE_SERVICE_TYPE=redis so queued work is visible across replicas"
7890
+ );
7891
+ }
7892
+ return { multiReplicaDeclared, ok: warnings.length === 0, warnings };
7893
+ }
7894
+ function warnMultiReplicaReadiness(logger9) {
7895
+ const { multiReplicaDeclared, warnings } = computeMultiReplicaReadiness();
7896
+ if (!multiReplicaDeclared) return;
7897
+ for (const message of warnings) {
7898
+ logger9.warn(message, { phase: "multi_replica_readiness" });
7899
+ }
7900
+ logger9.warn(
7901
+ "Multi-replica: agent run SSE and resume_stream are process-local; route a thread's follow-up runs to the replica streaming it (sticky routing) or share the stream/queue state",
7902
+ { phase: "multi_replica_readiness", feature: "agent-run-sse" }
7903
+ );
7904
+ }
7905
+
7854
7906
  // src/controllers/health.ts
7855
7907
  async function getHealth(request, reply) {
7856
7908
  try {
@@ -7859,7 +7911,8 @@ async function getHealth(request, reply) {
7859
7911
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7860
7912
  uptime: process.uptime(),
7861
7913
  service: "lattice-gateway",
7862
- version: process.env.npm_package_version || "1.0.0"
7914
+ version: process.env.npm_package_version || "1.0.0",
7915
+ readiness: computeMultiReplicaReadiness()
7863
7916
  };
7864
7917
  return reply.send({
7865
7918
  success: true,
@@ -7875,7 +7928,7 @@ async function getHealth(request, reply) {
7875
7928
  }
7876
7929
 
7877
7930
  // src/services/skill_service.ts
7878
- var import_core10 = require("@axiom-lattice/core");
7931
+ var import_core11 = require("@axiom-lattice/core");
7879
7932
  var PLUGIN_SKILL_SOURCE = "builtin-plugin";
7880
7933
  function getTenantId4(request) {
7881
7934
  return request.user?.tenantId || request.headers["x-tenant-id"] || "default";
@@ -7910,7 +7963,7 @@ function pluginSkillToSkill(item, tenantId, content) {
7910
7963
  }
7911
7964
  var SkillService = class {
7912
7965
  constructor() {
7913
- this.store = new import_core10.SandboxSkillStore();
7966
+ this.store = new import_core11.SandboxSkillStore();
7914
7967
  }
7915
7968
  /**
7916
7969
  * Read the read-only skills contributed by the tenant's sandbox plugins.
@@ -7920,10 +7973,10 @@ var SkillService = class {
7920
7973
  async tenantPluginSkills(tenantId) {
7921
7974
  const items = [];
7922
7975
  try {
7923
- const loaded = await (0, import_core10.getSandboxPluginCatalog)().ensureLoaded(tenantId);
7976
+ const loaded = await (0, import_core11.getSandboxPluginCatalog)().ensureLoaded(tenantId);
7924
7977
  for (const plugin of loaded.plugins) {
7925
7978
  for (const [name, definition] of Object.entries(plugin.skills ?? {})) {
7926
- const { meta } = (0, import_core10.parseSkillFrontmatter)(definition.content);
7979
+ const { meta } = (0, import_core11.parseSkillFrontmatter)(definition.content);
7927
7980
  items.push({
7928
7981
  id: name,
7929
7982
  name: meta.name || name,
@@ -7949,7 +8002,7 @@ var SkillService = class {
7949
8002
  for (const skill of storeSkills) {
7950
8003
  merged.set(skill.id, skill);
7951
8004
  }
7952
- for (const item of import_core10.PluginRegistry.listSkills()) {
8005
+ for (const item of import_core11.PluginRegistry.listSkills()) {
7953
8006
  merged.set(item.id, pluginSkillToSkill(item, tenantId));
7954
8007
  }
7955
8008
  for (const item of await this.tenantPluginSkills(tenantId)) {
@@ -7959,10 +8012,10 @@ var SkillService = class {
7959
8012
  }
7960
8013
  async getSkillById(request, id3) {
7961
8014
  const tenantId = getTenantId4(request);
7962
- const plugin = import_core10.PluginRegistry.getSkill(id3);
8015
+ const plugin = import_core11.PluginRegistry.getSkill(id3);
7963
8016
  if (plugin) {
7964
8017
  const { definition } = plugin;
7965
- const item = import_core10.PluginRegistry.listSkills().find((entry) => entry.id === id3);
8018
+ const item = import_core11.PluginRegistry.listSkills().find((entry) => entry.id === id3);
7966
8019
  if (item) {
7967
8020
  return pluginSkillToSkill(item, tenantId, definition.content);
7968
8021
  }
@@ -8015,7 +8068,7 @@ var SkillService = class {
8015
8068
  * existing "built-in skill" -> 403 mapping applies.
8016
8069
  */
8017
8070
  assertNotPluginSkill(id3, action) {
8018
- if (import_core10.PluginRegistry.getSkill(id3)) {
8071
+ if (import_core11.PluginRegistry.getSkill(id3)) {
8019
8072
  throw new Error(`Skill "${id3}" is a built-in skill and cannot be ${action}`);
8020
8073
  }
8021
8074
  }
@@ -8338,10 +8391,10 @@ async function deleteCollection(request, reply) {
8338
8391
  }
8339
8392
 
8340
8393
  // src/controllers/embeddings.ts
8341
- var import_core12 = require("@axiom-lattice/core");
8394
+ var import_core13 = require("@axiom-lattice/core");
8342
8395
  async function listEmbeddings(_request, _reply) {
8343
8396
  try {
8344
- const info = import_core12.embeddingsLatticeManager.getAllEmbeddingsInfo();
8397
+ const info = import_core13.embeddingsLatticeManager.getAllEmbeddingsInfo();
8345
8398
  return {
8346
8399
  success: true,
8347
8400
  message: "Successfully retrieved embedding models",
@@ -8486,7 +8539,7 @@ async function searchEntries(request, reply) {
8486
8539
  }
8487
8540
 
8488
8541
  // src/controllers/tools.ts
8489
- var import_core13 = require("@axiom-lattice/core");
8542
+ var import_core14 = require("@axiom-lattice/core");
8490
8543
  function serializeSchema(schema) {
8491
8544
  if (!schema) {
8492
8545
  return void 0;
@@ -8532,10 +8585,10 @@ async function getToolConfigs(request, reply) {
8532
8585
  try {
8533
8586
  const tenantId = request.user?.tenantId || request.headers["x-tenant-id"] || "default";
8534
8587
  const byKey = /* @__PURE__ */ new Map();
8535
- for (const lattice of import_core13.toolLatticeManager.getAllByTenant("default")) {
8588
+ for (const lattice of import_core14.toolLatticeManager.getAllByTenant("default")) {
8536
8589
  byKey.set(lattice.key, lattice);
8537
8590
  }
8538
- for (const lattice of import_core13.toolLatticeManager.getAllByTenant(tenantId)) {
8591
+ for (const lattice of import_core14.toolLatticeManager.getAllByTenant(tenantId)) {
8539
8592
  byKey.set(lattice.key, lattice);
8540
8593
  }
8541
8594
  const allLattices = [...byKey.values()];
@@ -8576,7 +8629,7 @@ async function getToolConfigs(request, reply) {
8576
8629
  }
8577
8630
 
8578
8631
  // src/controllers/data-query.ts
8579
- var import_core14 = require("@axiom-lattice/core");
8632
+ var import_core15 = require("@axiom-lattice/core");
8580
8633
  function getTenantId6(request) {
8581
8634
  return request.headers["x-tenant-id"] || "default";
8582
8635
  }
@@ -8607,7 +8660,7 @@ async function executeDataQuery(request, reply) {
8607
8660
  message: "Cannot provide both metrics and customSql. Use one query type only."
8608
8661
  };
8609
8662
  }
8610
- const storeLattice = (0, import_core14.getStoreLattice)("default", "metrics");
8663
+ const storeLattice = (0, import_core15.getStoreLattice)("default", "metrics");
8611
8664
  const store2 = storeLattice.store;
8612
8665
  if (!body.serverKey) {
8613
8666
  reply.code(400);
@@ -8640,7 +8693,7 @@ async function executeDataQuery(request, reply) {
8640
8693
  }
8641
8694
  let client;
8642
8695
  try {
8643
- client = await import_core14.metricsServerManager.getClient(tenantId, body.serverKey);
8696
+ client = await import_core15.metricsServerManager.getClient(tenantId, body.serverKey);
8644
8697
  } catch {
8645
8698
  reply.code(400);
8646
8699
  return {
@@ -8715,7 +8768,7 @@ async function executeSqlQuery(client, body, reply) {
8715
8768
  }
8716
8769
 
8717
8770
  // src/controllers/workflow-tracking.ts
8718
- var import_core15 = require("@axiom-lattice/core");
8771
+ var import_core16 = require("@axiom-lattice/core");
8719
8772
  var import_protocols4 = require("@axiom-lattice/protocols");
8720
8773
  function getTenantId7(request) {
8721
8774
  const userTenantId = request.user?.tenantId;
@@ -8724,7 +8777,7 @@ function getTenantId7(request) {
8724
8777
  }
8725
8778
  function getTrackingStore() {
8726
8779
  try {
8727
- const storeLattice = (0, import_core15.getStoreLattice)("default", "workflowTracking");
8780
+ const storeLattice = (0, import_core16.getStoreLattice)("default", "workflowTracking");
8728
8781
  return storeLattice.store;
8729
8782
  } catch {
8730
8783
  return null;
@@ -8732,7 +8785,7 @@ function getTrackingStore() {
8732
8785
  }
8733
8786
  async function getDefinitionsFromAssistants(tenantId) {
8734
8787
  try {
8735
- const storeLattice = (0, import_core15.getStoreLattice)("default", "assistant");
8788
+ const storeLattice = (0, import_core16.getStoreLattice)("default", "assistant");
8736
8789
  const assistantStore = storeLattice.store;
8737
8790
  const assistants = await assistantStore.getAllAssistants(tenantId);
8738
8791
  const results = [];
@@ -8812,7 +8865,7 @@ async function getAllWorkflowRuns(request, reply) {
8812
8865
  }
8813
8866
  const nameMap = {};
8814
8867
  try {
8815
- const asStoreLattice = (0, import_core15.getStoreLattice)("default", "assistant");
8868
+ const asStoreLattice = (0, import_core16.getStoreLattice)("default", "assistant");
8816
8869
  const assistantStore = asStoreLattice.store;
8817
8870
  const assistants = await assistantStore.getAllAssistants(tenantId);
8818
8871
  for (const a of assistants) {
@@ -8865,7 +8918,7 @@ async function getInboxItems(request, reply) {
8865
8918
  }
8866
8919
  const nameMap = {};
8867
8920
  try {
8868
- const asStoreLattice = (0, import_core15.getStoreLattice)("default", "assistant");
8921
+ const asStoreLattice = (0, import_core16.getStoreLattice)("default", "assistant");
8869
8922
  const assistantStore = asStoreLattice.store;
8870
8923
  const assistants = await assistantStore.getAllAssistants(tenantId);
8871
8924
  for (const a of assistants) {
@@ -8904,7 +8957,7 @@ async function getInboxItems(request, reply) {
8904
8957
  store2.getRunSteps(r.id).catch(() => []),
8905
8958
  (async () => {
8906
8959
  try {
8907
- return import_core15.agentInstanceManager.getAgentForRead({
8960
+ return import_core16.agentInstanceManager.getAgentForRead({
8908
8961
  assistant_id: r.assistantId,
8909
8962
  thread_id: r.threadId,
8910
8963
  tenant_id: r.tenantId
@@ -9046,7 +9099,7 @@ async function deleteWorkflowRun(request, reply) {
9046
9099
  try {
9047
9100
  const workspace_id = request.headers["x-workspace-id"];
9048
9101
  const project_id = request.headers["x-project-id"];
9049
- const agent = import_core15.agentInstanceManager.getAgent({
9102
+ const agent = import_core16.agentInstanceManager.getAgent({
9050
9103
  assistant_id: run2.assistantId,
9051
9104
  thread_id: run2.threadId,
9052
9105
  tenant_id: tenantId,
@@ -9133,7 +9186,7 @@ async function replyInboxTask(request, reply) {
9133
9186
  }
9134
9187
  const workspace_id = request.headers["x-workspace-id"];
9135
9188
  const project_id = request.headers["x-project-id"];
9136
- const agent = import_core15.agentInstanceManager.getAgent({
9189
+ const agent = import_core16.agentInstanceManager.getAgent({
9137
9190
  assistant_id: run2.assistantId,
9138
9191
  thread_id: run2.threadId,
9139
9192
  tenant_id: tenantId,
@@ -9141,7 +9194,7 @@ async function replyInboxTask(request, reply) {
9141
9194
  project_id
9142
9195
  });
9143
9196
  const runStatus = await agent.getRunStatus();
9144
- if (runStatus !== import_core15.ThreadStatus.INTERRUPTED) {
9197
+ if (runStatus !== import_core16.ThreadStatus.INTERRUPTED) {
9145
9198
  return reply.status(409).send({
9146
9199
  success: false,
9147
9200
  message: `Cannot resume: graph is not interrupted (current status: ${runStatus})`,
@@ -9215,7 +9268,7 @@ async function abortWorkflowRun(request, reply) {
9215
9268
  });
9216
9269
  const workspace_id = request.headers["x-workspace-id"];
9217
9270
  const project_id = request.headers["x-project-id"];
9218
- const agent = import_core15.agentInstanceManager.getAgent({
9271
+ const agent = import_core16.agentInstanceManager.getAgent({
9219
9272
  assistant_id: run2.assistantId,
9220
9273
  thread_id: run2.threadId,
9221
9274
  tenant_id: tenantId,
@@ -9223,7 +9276,7 @@ async function abortWorkflowRun(request, reply) {
9223
9276
  project_id
9224
9277
  });
9225
9278
  await agent.abort();
9226
- (0, import_core15.abortWorkflowRun)(runId);
9279
+ (0, import_core16.abortWorkflowRun)(runId);
9227
9280
  return reply.status(200).send({
9228
9281
  success: true,
9229
9282
  message: "Workflow aborted",
@@ -9239,7 +9292,7 @@ async function abortWorkflowRun(request, reply) {
9239
9292
  }
9240
9293
 
9241
9294
  // src/controllers/personal-assistant.ts
9242
- var import_core16 = require("@axiom-lattice/core");
9295
+ var import_core17 = require("@axiom-lattice/core");
9243
9296
  var import_crypto3 = require("crypto");
9244
9297
  function getWorkspaceId2(request) {
9245
9298
  return request.headers["x-workspace-id"] || "default";
@@ -9255,13 +9308,13 @@ function getUserId3(request) {
9255
9308
  return userId;
9256
9309
  }
9257
9310
  function getLinkStore() {
9258
- return (0, import_core16.getStoreLattice)("default", "userTenantLink").store;
9311
+ return (0, import_core17.getStoreLattice)("default", "userTenantLink").store;
9259
9312
  }
9260
9313
  function getAssistantStore() {
9261
- return (0, import_core16.getStoreLattice)("default", "assistant").store;
9314
+ return (0, import_core17.getStoreLattice)("default", "assistant").store;
9262
9315
  }
9263
9316
  function getProjectStore() {
9264
- return (0, import_core16.getStoreLattice)("default", "project").store;
9317
+ return (0, import_core17.getStoreLattice)("default", "project").store;
9265
9318
  }
9266
9319
  async function getLinkMeta(userId, tenantId) {
9267
9320
  const link = await getLinkStore().getLink(userId, tenantId);
@@ -9291,9 +9344,9 @@ async function createPersonalAssistant(request, reply) {
9291
9344
  description: "Personal workspace for your assistant",
9292
9345
  kind: "personal"
9293
9346
  });
9294
- const config = import_core16.PersonalAssistantConfig.get();
9347
+ const config = import_core17.PersonalAssistantConfig.get();
9295
9348
  config.key = assistantId;
9296
- import_core16.PersonalAssistantConfig.render(config, name, personality);
9349
+ import_core17.PersonalAssistantConfig.render(config, name, personality);
9297
9350
  const data = { name, graphDefinition: config, ownerUserId: userId };
9298
9351
  const assistant = await store2.createAssistant(tenantId, assistantId, data);
9299
9352
  const meta = await getLinkMeta(userId, tenantId);
@@ -9336,8 +9389,8 @@ async function deletePersonalAssistant(request, reply) {
9336
9389
  if (!deleted) {
9337
9390
  return reply.status(500).send({ success: false, message: "Failed to delete personal assistant" });
9338
9391
  }
9339
- import_core16.eventBus.publish("assistant:deleted", { id: assistant.id, tenantId });
9340
- const threadStore = (0, import_core16.getStoreLattice)("default", "thread").store;
9392
+ import_core17.eventBus.publish("assistant:deleted", { id: assistant.id, tenantId });
9393
+ const threadStore = (0, import_core17.getStoreLattice)("default", "thread").store;
9341
9394
  try {
9342
9395
  const threads = await threadStore.getThreadsByAssistantId(tenantId, assistant.id);
9343
9396
  for (const t2 of threads) {
@@ -9362,41 +9415,30 @@ async function deletePersonalAssistant(request, reply) {
9362
9415
  }
9363
9416
 
9364
9417
  // src/services/ExportImportService.ts
9365
- var import_core17 = require("@axiom-lattice/core");
9366
- var import_crypto4 = require("crypto");
9418
+ var import_core18 = require("@axiom-lattice/core");
9367
9419
  var fs = __toESM(require("fs/promises"));
9368
9420
  var os = __toESM(require("os"));
9369
9421
  var path = __toESM(require("path"));
9370
9422
  var tar = __toESM(require("tar"));
9371
9423
  var zlib = __toESM(require("zlib"));
9372
- var exportJobs = /* @__PURE__ */ new Map();
9373
- var JOB_TTL_MS = 60 * 60 * 1e3;
9374
9424
  var MAX_ARCHIVE_ENTRIES = 1e4;
9375
9425
  var MAX_ARCHIVE_FILE_BYTES = 100 * 1024 * 1024;
9376
9426
  var MAX_ARCHIVE_TOTAL_BYTES = 512 * 1024 * 1024;
9377
- function cleanExpiredJobs() {
9378
- const now = Date.now();
9379
- for (const [id3, entry] of exportJobs) {
9380
- if (now - entry.createdAt > JOB_TTL_MS) {
9381
- exportJobs.delete(id3);
9382
- }
9383
- }
9384
- }
9385
9427
  function archiveFileKey(entityType, entityId, relPath) {
9386
9428
  return `files/${entityType}/${entityId}/${relPath}`;
9387
9429
  }
9388
9430
  var ExportImportService = class {
9389
9431
  constructor() {
9390
- this.registry = import_core17.ExportableEntityRegistry.getInstance();
9432
+ this.registry = import_core18.ExportableEntityRegistry.getInstance();
9391
9433
  }
9392
9434
  /**
9393
9435
  * Preview an export: check which types would be auto-included, which dependencies are missing.
9394
9436
  */
9395
9437
  async exportPreview(tenantId, selectedTypes, entityIds, context) {
9396
9438
  const allDefs = this.registry.getAll();
9397
- const expanded = import_core17.DependencyResolver.expandCascade(allDefs, selectedTypes);
9439
+ const expanded = import_core18.DependencyResolver.expandCascade(allDefs, selectedTypes);
9398
9440
  const cascadeAdditions = expanded.filter((t2) => !selectedTypes.includes(t2));
9399
- const deps = import_core17.DependencyResolver.computeDependencies(allDefs, expanded);
9441
+ const deps = import_core18.DependencyResolver.computeDependencies(allDefs, expanded);
9400
9442
  const registeredTypes = new Set(allDefs.map((d) => d.entityType));
9401
9443
  const missingDependencies = deps.missing.filter((t2) => registeredTypes.has(t2));
9402
9444
  await this.resolveExportSelection(tenantId, selectedTypes, entityIds, context);
@@ -9404,7 +9446,8 @@ var ExportImportService = class {
9404
9446
  }
9405
9447
  /**
9406
9448
  * Generate a full export (bundle + file content) for the given tenant and entity types.
9407
- * Stores the data in-memory and returns a jobId for download.
9449
+ * The result is returned directly so the caller can pack and stream it in the same
9450
+ * request, with no process-local job state that would break across Gateway replicas.
9408
9451
  */
9409
9452
  async export(tenantId, entityTypes, entityIds, context) {
9410
9453
  const { dependencyOrder, entities: rawEntities } = await this.resolveExportSelection(
@@ -9463,18 +9506,7 @@ var ExportImportService = class {
9463
9506
  dependencyOrder,
9464
9507
  _warning: "This file contains plaintext secrets (passwords, API keys, tokens). Store it securely and delete after import."
9465
9508
  };
9466
- const jobId = (0, import_crypto4.randomUUID)();
9467
- exportJobs.set(jobId, { data: { bundle, files }, tenantId, createdAt: Date.now() });
9468
- return { jobId, data: { bundle, files } };
9469
- }
9470
- /**
9471
- * Retrieve a previously generated export job data by jobId with tenant validation.
9472
- */
9473
- getExportJob(jobId, tenantId) {
9474
- cleanExpiredJobs();
9475
- const entry = exportJobs.get(jobId);
9476
- if (!entry || entry.tenantId !== tenantId) return void 0;
9477
- return entry.data;
9509
+ return { bundle, files };
9478
9510
  }
9479
9511
  /**
9480
9512
  * Pack an ExportJobData into a tar.gz buffer.
@@ -9692,14 +9724,14 @@ var ExportImportService = class {
9692
9724
  for (const entity of skillEntities) {
9693
9725
  const subSkills = entity.data.subSkills;
9694
9726
  if (!Array.isArray(subSkills)) continue;
9695
- const unresolved = subSkills.find((id3) => typeof id3 === "string" && !skillSourceToTarget.has(id3) && !(0, import_core17.isBuiltInSkill)(id3));
9727
+ const unresolved = subSkills.find((id3) => typeof id3 === "string" && !skillSourceToTarget.has(id3) && !(0, import_core18.isBuiltInSkill)(id3));
9696
9728
  if (unresolved) unresolvedSkillReferences.set(entity._exportId, unresolved);
9697
9729
  }
9698
9730
  for (const entityType of dependencyOrder) {
9699
9731
  const entities = bundle.entities[entityType];
9700
9732
  if (!entities || entities.length === 0) continue;
9701
9733
  const def = this.registry.get(entityType);
9702
- const remapper = new import_core17.IdRemapper(idMap);
9734
+ const remapper = new import_core18.IdRemapper(idMap);
9703
9735
  let insertions = /* @__PURE__ */ new Set();
9704
9736
  let conflicts = /* @__PURE__ */ new Set();
9705
9737
  let conflictByExportId = /* @__PURE__ */ new Map();
@@ -9795,7 +9827,7 @@ var ExportImportService = class {
9795
9827
  }
9796
9828
  }
9797
9829
  if (entityType === "agent" && Object.keys(skillIdRemap).length > 0) {
9798
- const skillRemapper = new import_core17.IdRemapper({});
9830
+ const skillRemapper = new import_core18.IdRemapper({});
9799
9831
  remappedData.graphDefinition = skillRemapper.remapSkillIds(
9800
9832
  remappedData.graphDefinition || {},
9801
9833
  skillIdRemap
@@ -9873,10 +9905,10 @@ var ExportImportService = class {
9873
9905
  throw new Error(`Exportable entity type is not registered: "${type}"`);
9874
9906
  }
9875
9907
  }
9876
- const expanded = import_core17.DependencyResolver.expandCascade(allDefs, entityTypes);
9877
- const dependencies = import_core17.DependencyResolver.computeDependencies(allDefs, expanded).missing;
9908
+ const expanded = import_core18.DependencyResolver.expandCascade(allDefs, entityTypes);
9909
+ const dependencies = import_core18.DependencyResolver.computeDependencies(allDefs, expanded).missing;
9878
9910
  const finalTypeSet = /* @__PURE__ */ new Set([...expanded, ...dependencies]);
9879
- const dependencyOrder = import_core17.DependencyResolver.resolveOrder(
9911
+ const dependencyOrder = import_core18.DependencyResolver.resolveOrder(
9880
9912
  allDefs.filter((def) => finalTypeSet.has(def.entityType))
9881
9913
  );
9882
9914
  const availableByType = /* @__PURE__ */ new Map();
@@ -9916,7 +9948,7 @@ var ExportImportService = class {
9916
9948
  const targetEntities = availableByType.get(referencedType);
9917
9949
  const explicitSelection = entityIds && Object.prototype.hasOwnProperty.call(entityIds, referencedType) ? new Set(entityIds[referencedType]) : void 0;
9918
9950
  for (const id3 of new Set(ids)) {
9919
- if (referencedType === "skill" && (0, import_core17.isBuiltInSkill)(id3)) continue;
9951
+ if (referencedType === "skill" && (0, import_core18.isBuiltInSkill)(id3)) continue;
9920
9952
  if (explicitSelection && !explicitSelection.has(id3)) {
9921
9953
  throw new Error(
9922
9954
  `Required reference from ${type} to ${referencedType} "${id3}" is omitted by entityIds.${referencedType}`
@@ -10002,7 +10034,7 @@ var ExportImportService = class {
10002
10034
  }
10003
10035
  }
10004
10036
  const typeSet = new Set(entityTypes);
10005
- const canonicalOrder = import_core17.DependencyResolver.resolveOrder(
10037
+ const canonicalOrder = import_core18.DependencyResolver.resolveOrder(
10006
10038
  this.registry.getAll().filter((def) => typeSet.has(def.entityType))
10007
10039
  );
10008
10040
  if (canonicalOrder.length !== bundle.dependencyOrder.length || canonicalOrder.some((type, index) => bundle.dependencyOrder[index] !== type)) {
@@ -10022,7 +10054,7 @@ var ExportImportService = class {
10022
10054
  };
10023
10055
 
10024
10056
  // src/controllers/export-import.ts
10025
- var import_core18 = require("@axiom-lattice/core");
10057
+ var import_core19 = require("@axiom-lattice/core");
10026
10058
  var service = new ExportImportService();
10027
10059
  var TenantScopeError = class extends Error {
10028
10060
  constructor() {
@@ -10059,6 +10091,12 @@ function safeArchiveFilename(sourceTenantId) {
10059
10091
  const safeTenantId = sourceTenantId.replace(/[^A-Za-z0-9._-]/g, "_");
10060
10092
  return `tenant-export-${safeTenantId}.tar.gz`;
10061
10093
  }
10094
+ async function sendArchive(reply, data) {
10095
+ const tarGz = await service.packTarGz(data);
10096
+ reply.type("application/gzip");
10097
+ reply.header("Content-Disposition", `attachment; filename="${safeArchiveFilename(data.bundle.sourceTenantId)}"`);
10098
+ reply.send(tarGz);
10099
+ }
10062
10100
  function assertCompleteFile(file) {
10063
10101
  if (file.truncated) {
10064
10102
  throw new Error("Uploaded file was truncated because it exceeds the configured file size limit");
@@ -10146,37 +10184,21 @@ async function exportConfig(request, reply) {
10146
10184
  }
10147
10185
  });
10148
10186
  }
10149
- const { jobId, data } = await service.export(tenantId, entityTypes, entityIds, getContext(request));
10150
- return reply.send({
10151
- success: true,
10152
- data: {
10153
- jobId,
10154
- summary: Object.fromEntries(
10155
- Object.entries(data.bundle.entities).map(([type, entities]) => [type, entities.length])
10156
- )
10157
- }
10158
- });
10187
+ const data = await service.export(tenantId, entityTypes, entityIds, getContext(request));
10188
+ return sendArchive(reply, data);
10159
10189
  }
10160
10190
  async function exportConfigConfirm(request, reply) {
10161
10191
  const tenantId = resolveTenantId(request, request.params.tenantId);
10162
10192
  const { entityTypes, entityIds } = request.body;
10163
- const { jobId, data } = await service.export(tenantId, entityTypes, entityIds, getContext(request));
10164
- return reply.send({
10165
- success: true,
10166
- data: {
10167
- jobId,
10168
- summary: Object.fromEntries(
10169
- Object.entries(data.bundle.entities).map(([type, entities]) => [type, entities.length])
10170
- )
10171
- }
10172
- });
10193
+ const data = await service.export(tenantId, entityTypes, entityIds, getContext(request));
10194
+ return sendArchive(reply, data);
10173
10195
  }
10174
10196
  async function previewEntities(request, reply) {
10175
10197
  const tenantId = resolveTenantId(request, request.params.tenantId);
10176
10198
  const { entityTypes } = request.body;
10177
10199
  const context = getContext(request);
10178
10200
  try {
10179
- const registry = import_core18.ExportableEntityRegistry.getInstance();
10201
+ const registry = import_core19.ExportableEntityRegistry.getInstance();
10180
10202
  const result = {};
10181
10203
  for (const type of entityTypes) {
10182
10204
  const def = registry.get(type);
@@ -10192,18 +10214,6 @@ async function previewEntities(request, reply) {
10192
10214
  return reply.status(400).send({ success: false, message: err.message });
10193
10215
  }
10194
10216
  }
10195
- async function downloadExport(request, reply) {
10196
- const tenantId = resolveTenantId(request, request.params.tenantId);
10197
- const data = service.getExportJob(request.params.jobId, tenantId);
10198
- if (!data) {
10199
- return reply.status(404).send({ success: false, message: "Export job not found or expired" });
10200
- }
10201
- const tarGz = await service.packTarGz(data);
10202
- const filename = safeArchiveFilename(data.bundle.sourceTenantId);
10203
- reply.type("application/gzip");
10204
- reply.header("Content-Disposition", `attachment; filename="${filename}"`);
10205
- return reply.send(tarGz);
10206
- }
10207
10217
  async function importPreview(request, reply) {
10208
10218
  const tenantId = resolveTenantId(request, request.params.tenantId);
10209
10219
  try {
@@ -10234,17 +10244,17 @@ async function importApply(request, reply) {
10234
10244
  }
10235
10245
 
10236
10246
  // src/controllers/middleware-types.ts
10237
- var import_core20 = require("@axiom-lattice/core");
10247
+ var import_core21 = require("@axiom-lattice/core");
10238
10248
 
10239
10249
  // src/services/plugins/tenantPluginResolver.ts
10240
- var import_core19 = require("@axiom-lattice/core");
10250
+ var import_core20 = require("@axiom-lattice/core");
10241
10251
  async function resolveTenantPluginByType(tenantId, type) {
10242
- return (await (0, import_core19.listTenantPlugins)(tenantId)).find((p) => p.meta.type === type);
10252
+ return (await (0, import_core20.listTenantPlugins)(tenantId)).find((p) => p.meta.type === type);
10243
10253
  }
10244
10254
 
10245
10255
  // src/controllers/middleware-types.ts
10246
10256
  async function collectMiddlewareMetas(tenantId) {
10247
- return (await (0, import_core19.listTenantPlugins)(tenantId)).map(import_core20.serializePluginMeta);
10257
+ return (await (0, import_core20.listTenantPlugins)(tenantId)).map(import_core21.serializePluginMeta);
10248
10258
  }
10249
10259
  function middlewareTypesRoutes(fastify2) {
10250
10260
  fastify2.get("/api/middleware-types", async (request, reply) => {
@@ -10620,7 +10630,15 @@ var getHealthSchema = {
10620
10630
  timestamp: { type: "string" },
10621
10631
  uptime: { type: "number" },
10622
10632
  service: { type: "string" },
10623
- version: { type: "string" }
10633
+ version: { type: "string" },
10634
+ readiness: {
10635
+ type: "object",
10636
+ properties: {
10637
+ multiReplicaDeclared: { type: "boolean" },
10638
+ ok: { type: "boolean" },
10639
+ warnings: { type: "array", items: { type: "string" } }
10640
+ }
10641
+ }
10624
10642
  }
10625
10643
  }
10626
10644
  }
@@ -10637,7 +10655,7 @@ var getHealthSchema = {
10637
10655
  };
10638
10656
 
10639
10657
  // src/controllers/thread_status.ts
10640
- var import_core21 = require("@axiom-lattice/core");
10658
+ var import_core22 = require("@axiom-lattice/core");
10641
10659
  async function removePendingMessageHandler(request, reply) {
10642
10660
  try {
10643
10661
  const { assistant_id, thread_id, message_id } = request.params;
@@ -10650,7 +10668,7 @@ async function removePendingMessageHandler(request, reply) {
10650
10668
  if (!assistant_id) {
10651
10669
  return reply.code(400).send({ error: "Missing assistant_id parameter" });
10652
10670
  }
10653
- const agent = import_core21.agentInstanceManager.getAgent({
10671
+ const agent = import_core22.agentInstanceManager.getAgent({
10654
10672
  assistant_id,
10655
10673
  thread_id,
10656
10674
  tenant_id,
@@ -10684,7 +10702,7 @@ async function removePendingMessageHandler(request, reply) {
10684
10702
  }
10685
10703
 
10686
10704
  // src/services/sandbox_service.ts
10687
- var import_core22 = require("@axiom-lattice/core");
10705
+ var import_core23 = require("@axiom-lattice/core");
10688
10706
  var ERROR_HTML = `<!DOCTYPE html>
10689
10707
  <html lang="zh-CN">
10690
10708
  <head>
@@ -10796,7 +10814,7 @@ var ERROR_HTML = `<!DOCTYPE html>
10796
10814
  </html>`;
10797
10815
  var SandboxService = class {
10798
10816
  getFilesystemVmIsolation(tenantId, assistantId) {
10799
- const agentLattice = import_core22.agentLatticeManager.getAgentLatticeWithTenant(tenantId, assistantId);
10817
+ const agentLattice = import_core23.agentLatticeManager.getAgentLatticeWithTenant(tenantId, assistantId);
10800
10818
  if (!agentLattice) {
10801
10819
  return null;
10802
10820
  }
@@ -10810,9 +10828,9 @@ var SandboxService = class {
10810
10828
  computeSandboxName(assistantId, threadId, vmIsolation, tenantId, workspaceId, projectId) {
10811
10829
  switch (vmIsolation) {
10812
10830
  case "agent":
10813
- return (0, import_core22.normalizeSandboxName)(`${tenantId ?? "default"}-${assistantId}`);
10831
+ return (0, import_core23.normalizeSandboxName)(`${tenantId ?? "default"}-${assistantId}`);
10814
10832
  case "project":
10815
- return (0, import_core22.normalizeSandboxName)(
10833
+ return (0, import_core23.normalizeSandboxName)(
10816
10834
  `${tenantId ?? "default"}-${workspaceId ?? "default"}-${projectId ?? "default"}`
10817
10835
  );
10818
10836
  case "global":
@@ -10868,7 +10886,7 @@ var SandboxService = class {
10868
10886
  var sandboxService = new SandboxService();
10869
10887
 
10870
10888
  // src/controllers/sandbox.ts
10871
- var import_core23 = require("@axiom-lattice/core");
10889
+ var import_core24 = require("@axiom-lattice/core");
10872
10890
  init_mime();
10873
10891
  init_http_range();
10874
10892
  function registerSandboxProxyRoutes(app2) {
@@ -10884,7 +10902,7 @@ function registerSandboxProxyRoutes(app2) {
10884
10902
  }
10885
10903
  const workspaceId = request.headers["x-workspace-id"];
10886
10904
  const projectId = request.headers["x-project-id"];
10887
- const sandboxManager = (0, import_core23.getSandBoxManager)();
10905
+ const sandboxManager = (0, import_core24.getSandBoxManager)();
10888
10906
  const sandbox = await sandboxManager.getSandboxFromConfig({
10889
10907
  assistant_id: assistantId,
10890
10908
  thread_id: threadId,
@@ -10932,7 +10950,7 @@ function registerSandboxProxyRoutes(app2) {
10932
10950
  }
10933
10951
  const workspaceId = request.headers["x-workspace-id"];
10934
10952
  const projectId = request.headers["x-project-id"];
10935
- const sandboxManager = (0, import_core23.getSandBoxManager)();
10953
+ const sandboxManager = (0, import_core24.getSandBoxManager)();
10936
10954
  const sandbox = await sandboxManager.getSandboxFromConfig({
10937
10955
  assistant_id: assistantId,
10938
10956
  thread_id: threadId,
@@ -10968,9 +10986,9 @@ var fs4 = __toESM(require("fs/promises"));
10968
10986
  var path4 = __toESM(require("path"));
10969
10987
  var import_fs = require("fs");
10970
10988
  var os2 = __toESM(require("os"));
10971
- var import_core27 = require("@axiom-lattice/core");
10972
10989
  var import_core28 = require("@axiom-lattice/core");
10973
10990
  var import_core29 = require("@axiom-lattice/core");
10991
+ var import_core30 = require("@axiom-lattice/core");
10974
10992
  var import_uuid3 = require("uuid");
10975
10993
  init_mime();
10976
10994
  init_http_range();
@@ -10979,12 +10997,12 @@ init_workspace_file_service();
10979
10997
  init_path_containment();
10980
10998
 
10981
10999
  // src/services/collaboration/RoomCoordinatorProvisioner.ts
10982
- var import_core25 = require("@axiom-lattice/core");
11000
+ var import_core26 = require("@axiom-lattice/core");
10983
11001
  var ROOM_COORDINATOR_KEY = "room-coordinator";
10984
11002
  var ROOM_COORDINATOR_ASSISTANT_INPUT = {
10985
11003
  name: "Room Coordinator",
10986
11004
  description: "Coordinates project room conversations and organizes room work.",
10987
- graphDefinition: import_core25.roomCoordinatorConfig
11005
+ graphDefinition: import_core26.roomCoordinatorConfig
10988
11006
  };
10989
11007
  function needsConfigRepair(assistant) {
10990
11008
  const graph = assistant.graphDefinition;
@@ -11029,7 +11047,7 @@ var RoomCoordinatorProvisioner = class {
11029
11047
  var import_node_crypto = require("crypto");
11030
11048
 
11031
11049
  // src/services/collaboration/ProjectMutationMutex.ts
11032
- var import_core26 = require("@axiom-lattice/core");
11050
+ var import_core27 = require("@axiom-lattice/core");
11033
11051
 
11034
11052
  // src/services/collaboration/RoomPresenceThread.ts
11035
11053
  var ROOM_PRESENCE_METADATA_KEYS = ["source", "kind", "workspaceId", "projectId", "roomId", "membershipId", "assistantId"];
@@ -11063,7 +11081,7 @@ var RoomCoordinatorEnsurer = class {
11063
11081
  /** Creates the ensurer from explicitly injected stores and provisioner. */
11064
11082
  constructor(deps) {
11065
11083
  this.deps = deps;
11066
- this.mutex = deps.mutationMutex ?? import_core26.projectMutationMutex;
11084
+ this.mutex = deps.mutationMutex ?? import_core27.projectMutationMutex;
11067
11085
  this.idFactory = deps.idFactory ?? import_node_crypto.randomUUID;
11068
11086
  }
11069
11087
  /**
@@ -11350,13 +11368,13 @@ function createProjectCollaborationInitializer(deps) {
11350
11368
  var WorkspaceController = class {
11351
11369
  constructor(projectCollaboration) {
11352
11370
  this.projectCollaboration = projectCollaboration;
11353
- this.workspaceStore = (0, import_core27.getStoreLattice)("default", "workspace").store;
11354
- this.projectStore = (0, import_core27.getStoreLattice)("default", "project").store;
11355
- const roomStore = (0, import_core27.getStoreLattice)("default", "projectRoom").store;
11356
- const botMembershipStore = (0, import_core27.getStoreLattice)("default", "projectBotMembership").store;
11357
- const assistantStore = (0, import_core27.getStoreLattice)("default", "assistant").store;
11358
- const threadStore = (0, import_core27.getStoreLattice)("default", "thread").store;
11359
- const tenantStore = (0, import_core27.getStoreLattice)("default", "tenant").store;
11371
+ this.workspaceStore = (0, import_core28.getStoreLattice)("default", "workspace").store;
11372
+ this.projectStore = (0, import_core28.getStoreLattice)("default", "project").store;
11373
+ const roomStore = (0, import_core28.getStoreLattice)("default", "projectRoom").store;
11374
+ const botMembershipStore = (0, import_core28.getStoreLattice)("default", "projectBotMembership").store;
11375
+ const assistantStore = (0, import_core28.getStoreLattice)("default", "assistant").store;
11376
+ const threadStore = (0, import_core28.getStoreLattice)("default", "thread").store;
11377
+ const tenantStore = (0, import_core28.getStoreLattice)("default", "tenant").store;
11360
11378
  const coordinatorProvisioner = new RoomCoordinatorProvisioner({
11361
11379
  getAssistantById: assistantStore.getAssistantById.bind(assistantStore),
11362
11380
  createAssistant: assistantStore.createAssistant.bind(assistantStore),
@@ -11633,7 +11651,7 @@ var WorkspaceController = class {
11633
11651
  }
11634
11652
  console.log(`[getBackend] storageType=${workspace.storageType} filePath=${filePath}`);
11635
11653
  if (workspace.storageType === "sandbox") {
11636
- const sandboxManager = (0, import_core29.getSandBoxManager)();
11654
+ const sandboxManager = (0, import_core30.getSandBoxManager)();
11637
11655
  const volumeConfig = {
11638
11656
  assistant_id: assistantId || "",
11639
11657
  thread_id: "",
@@ -11651,7 +11669,7 @@ var WorkspaceController = class {
11651
11669
  const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
11652
11670
  console.log(`[getBackend] sandbox acquired, name=${sandbox.name || "unknown"}`);
11653
11671
  return {
11654
- backend: new import_core28.SandboxFilesystem({
11672
+ backend: new import_core29.SandboxFilesystem({
11655
11673
  sandboxInstance: sandbox
11656
11674
  }),
11657
11675
  workspace
@@ -11664,7 +11682,7 @@ var WorkspaceController = class {
11664
11682
  );
11665
11683
  console.log(`[getBackend] using FilesystemBackend rootDir=${rootDir}`);
11666
11684
  return {
11667
- backend: new import_core28.FilesystemBackend({
11685
+ backend: new import_core29.FilesystemBackend({
11668
11686
  rootDir,
11669
11687
  virtualMode: true
11670
11688
  }),
@@ -11683,7 +11701,7 @@ var WorkspaceController = class {
11683
11701
  const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
11684
11702
  const resolvedPath = filePath;
11685
11703
  if (workspace.storageType === "sandbox") {
11686
- const sandboxManager = (0, import_core29.getSandBoxManager)();
11704
+ const sandboxManager = (0, import_core30.getSandBoxManager)();
11687
11705
  const volumeConfig = {
11688
11706
  assistant_id: assistantId || "",
11689
11707
  thread_id: "",
@@ -11744,7 +11762,7 @@ var WorkspaceController = class {
11744
11762
  throw new FolderDownloadError(404, "PROJECT_NOT_FOUND", "Project not found");
11745
11763
  }
11746
11764
  if (storedWorkspace.storageType === "sandbox") {
11747
- const sandboxManager = (0, import_core29.getSandBoxManager)();
11765
+ const sandboxManager = (0, import_core30.getSandBoxManager)();
11748
11766
  const volumeConfig = {
11749
11767
  assistant_id: assistantId || "",
11750
11768
  thread_id: "",
@@ -11810,7 +11828,7 @@ var WorkspaceController = class {
11810
11828
  throw new FolderDownloadError(400, "NOT_A_FOLDER", "Path is not a folder");
11811
11829
  }
11812
11830
  } else if (folderPath) {
11813
- const sandboxManager = (0, import_core29.getSandBoxManager)();
11831
+ const sandboxManager = (0, import_core30.getSandBoxManager)();
11814
11832
  const volumeConfig = {
11815
11833
  assistant_id: assistantId || "",
11816
11834
  thread_id: "",
@@ -12025,7 +12043,7 @@ var WorkspaceController = class {
12025
12043
  const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
12026
12044
  const resolvedPath = filePath;
12027
12045
  if (workspace.storageType === "sandbox") {
12028
- const sandboxManager = (0, import_core29.getSandBoxManager)();
12046
+ const sandboxManager = (0, import_core30.getSandBoxManager)();
12029
12047
  const volumeConfig = {
12030
12048
  assistant_id: assistantId || "",
12031
12049
  thread_id: "",
@@ -12517,8 +12535,8 @@ var ProjectAccessService = class {
12517
12535
  };
12518
12536
 
12519
12537
  // src/controllers/database-configs.ts
12520
- var import_core30 = require("@axiom-lattice/core");
12521
- var import_crypto6 = require("crypto");
12538
+ var import_core31 = require("@axiom-lattice/core");
12539
+ var import_crypto5 = require("crypto");
12522
12540
  function getTenantId9(request) {
12523
12541
  const userTenantId = request.user?.tenantId;
12524
12542
  if (userTenantId) {
@@ -12529,7 +12547,7 @@ function getTenantId9(request) {
12529
12547
  async function getDatabaseConfigList(request, reply) {
12530
12548
  const tenantId = getTenantId9(request);
12531
12549
  try {
12532
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12550
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12533
12551
  const store2 = storeLattice.store;
12534
12552
  const configs = await store2.getAllConfigs(tenantId);
12535
12553
  console.log("Backend: getAllConfigs returned:", configs);
@@ -12560,7 +12578,7 @@ async function getDatabaseConfig(request, reply) {
12560
12578
  const tenantId = getTenantId9(request);
12561
12579
  const { key } = request.params;
12562
12580
  try {
12563
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12581
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12564
12582
  const store2 = storeLattice.store;
12565
12583
  const config = await store2.getConfigByKey(tenantId, key);
12566
12584
  if (!config) {
@@ -12586,7 +12604,7 @@ async function createDatabaseConfig(request, reply) {
12586
12604
  const tenantId = getTenantId9(request);
12587
12605
  const body = request.body;
12588
12606
  try {
12589
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12607
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12590
12608
  const store2 = storeLattice.store;
12591
12609
  const existing = await store2.getConfigByKey(tenantId, body.key);
12592
12610
  if (existing) {
@@ -12596,10 +12614,10 @@ async function createDatabaseConfig(request, reply) {
12596
12614
  message: "Database configuration with this key already exists"
12597
12615
  };
12598
12616
  }
12599
- const id3 = body.id || (0, import_crypto6.randomUUID)();
12617
+ const id3 = body.id || (0, import_crypto5.randomUUID)();
12600
12618
  const config = await store2.createConfig(tenantId, id3, body);
12601
12619
  try {
12602
- import_core30.sqlDatabaseManager.registerDatabase(tenantId, config.key, config.config);
12620
+ import_core31.sqlDatabaseManager.registerDatabase(tenantId, config.key, config.config);
12603
12621
  } catch (error) {
12604
12622
  console.warn("Failed to auto-register database:", error);
12605
12623
  }
@@ -12622,7 +12640,7 @@ async function updateDatabaseConfig(request, reply) {
12622
12640
  const { key } = request.params;
12623
12641
  const updates = request.body;
12624
12642
  try {
12625
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12643
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12626
12644
  const store2 = storeLattice.store;
12627
12645
  const existing = await store2.getConfigByKey(tenantId, key);
12628
12646
  if (!existing) {
@@ -12641,7 +12659,7 @@ async function updateDatabaseConfig(request, reply) {
12641
12659
  }
12642
12660
  if (updates.config) {
12643
12661
  try {
12644
- import_core30.sqlDatabaseManager.registerDatabase(tenantId, updated.key, updated.config);
12662
+ import_core31.sqlDatabaseManager.registerDatabase(tenantId, updated.key, updated.config);
12645
12663
  } catch (error) {
12646
12664
  console.warn("Failed to re-register database:", error);
12647
12665
  }
@@ -12663,7 +12681,7 @@ async function deleteDatabaseConfig(request, reply) {
12663
12681
  const tenantId = getTenantId9(request);
12664
12682
  const { keyOrId } = request.params;
12665
12683
  try {
12666
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12684
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12667
12685
  const store2 = storeLattice.store;
12668
12686
  console.log("Delete request - keyOrId:", keyOrId);
12669
12687
  let config = await store2.getConfigByKey(tenantId, keyOrId);
@@ -12690,8 +12708,8 @@ async function deleteDatabaseConfig(request, reply) {
12690
12708
  };
12691
12709
  }
12692
12710
  try {
12693
- if (import_core30.sqlDatabaseManager.hasDatabase(tenantId, configKey)) {
12694
- await import_core30.sqlDatabaseManager.removeDatabase(tenantId, configKey);
12711
+ if (import_core31.sqlDatabaseManager.hasDatabase(tenantId, configKey)) {
12712
+ await import_core31.sqlDatabaseManager.removeDatabase(tenantId, configKey);
12695
12713
  }
12696
12714
  } catch (error) {
12697
12715
  console.warn("Failed to remove from SqlDatabaseManager:", error);
@@ -12712,7 +12730,7 @@ async function testDatabaseConnection(request, reply) {
12712
12730
  const tenantId = getTenantId9(request);
12713
12731
  const { key } = request.params;
12714
12732
  try {
12715
- const storeLattice = (0, import_core30.getStoreLattice)("default", "database");
12733
+ const storeLattice = (0, import_core31.getStoreLattice)("default", "database");
12716
12734
  const store2 = storeLattice.store;
12717
12735
  const config = await store2.getConfigByKey(tenantId, key);
12718
12736
  if (!config) {
@@ -12723,16 +12741,16 @@ async function testDatabaseConnection(request, reply) {
12723
12741
  };
12724
12742
  }
12725
12743
  const testKey = `__test_${key}_${Date.now()}`;
12726
- import_core30.sqlDatabaseManager.registerDatabase(tenantId, testKey, config.config);
12744
+ import_core31.sqlDatabaseManager.registerDatabase(tenantId, testKey, config.config);
12727
12745
  const startTime = Date.now();
12728
- const db = await import_core30.sqlDatabaseManager.getDatabase(tenantId, testKey);
12746
+ const db = await import_core31.sqlDatabaseManager.getDatabase(tenantId, testKey);
12729
12747
  try {
12730
12748
  await db.connect();
12731
12749
  await db.listTables();
12732
12750
  const latency = Date.now() - startTime;
12733
12751
  await new Promise((resolve4) => setTimeout(resolve4, 100));
12734
12752
  await db.disconnect();
12735
- await import_core30.sqlDatabaseManager.removeDatabase(tenantId, testKey);
12753
+ await import_core31.sqlDatabaseManager.removeDatabase(tenantId, testKey);
12736
12754
  return {
12737
12755
  success: true,
12738
12756
  message: "Connection test successful",
@@ -12744,7 +12762,7 @@ async function testDatabaseConnection(request, reply) {
12744
12762
  } catch (error) {
12745
12763
  try {
12746
12764
  await db.disconnect();
12747
- await import_core30.sqlDatabaseManager.removeDatabase(tenantId, testKey);
12765
+ await import_core31.sqlDatabaseManager.removeDatabase(tenantId, testKey);
12748
12766
  } catch {
12749
12767
  }
12750
12768
  return {
@@ -12796,8 +12814,8 @@ function registerDatabaseConfigRoutes(app2) {
12796
12814
  }
12797
12815
 
12798
12816
  // src/controllers/metrics-configs.ts
12799
- var import_core31 = require("@axiom-lattice/core");
12800
- var import_crypto7 = require("crypto");
12817
+ var import_core32 = require("@axiom-lattice/core");
12818
+ var import_crypto6 = require("crypto");
12801
12819
  function getTenantId10(request) {
12802
12820
  const userTenantId = request.user?.tenantId;
12803
12821
  if (userTenantId) {
@@ -12808,7 +12826,7 @@ function getTenantId10(request) {
12808
12826
  async function getMetricsServerConfigList(request, reply) {
12809
12827
  const tenantId = getTenantId10(request);
12810
12828
  try {
12811
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
12829
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
12812
12830
  const store2 = storeLattice.store;
12813
12831
  const configs = await store2.getAllConfigs(tenantId);
12814
12832
  return {
@@ -12835,7 +12853,7 @@ async function getMetricsServerConfig(request, reply) {
12835
12853
  const tenantId = getTenantId10(request);
12836
12854
  const { key } = request.params;
12837
12855
  try {
12838
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
12856
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
12839
12857
  const store2 = storeLattice.store;
12840
12858
  const config = await store2.getConfigByKey(tenantId, key);
12841
12859
  if (!config) {
@@ -12861,7 +12879,7 @@ async function createMetricsServerConfig(request, reply) {
12861
12879
  const tenantId = getTenantId10(request);
12862
12880
  const body = request.body;
12863
12881
  try {
12864
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
12882
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
12865
12883
  const store2 = storeLattice.store;
12866
12884
  const existing = await store2.getConfigByKey(tenantId, body.key);
12867
12885
  if (existing) {
@@ -12878,7 +12896,7 @@ async function createMetricsServerConfig(request, reply) {
12878
12896
  message: "selectedDataSources is required for semantic metrics servers"
12879
12897
  };
12880
12898
  }
12881
- const id3 = body.id || (0, import_crypto7.randomUUID)();
12899
+ const id3 = body.id || (0, import_crypto6.randomUUID)();
12882
12900
  const configData = {
12883
12901
  key: body.key,
12884
12902
  name: body.name,
@@ -12890,7 +12908,7 @@ async function createMetricsServerConfig(request, reply) {
12890
12908
  };
12891
12909
  const config = await store2.createConfig(tenantId, id3, configData);
12892
12910
  try {
12893
- import_core31.metricsServerManager.registerServer(tenantId, config.key, config.config);
12911
+ import_core32.metricsServerManager.registerServer(tenantId, config.key, config.config);
12894
12912
  } catch (error) {
12895
12913
  console.warn("Failed to auto-register metrics server:", error);
12896
12914
  }
@@ -12913,7 +12931,7 @@ async function updateMetricsServerConfig(request, reply) {
12913
12931
  const { key } = request.params;
12914
12932
  const updates = request.body;
12915
12933
  try {
12916
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
12934
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
12917
12935
  const store2 = storeLattice.store;
12918
12936
  const existing = await store2.getConfigByKey(tenantId, key);
12919
12937
  if (!existing) {
@@ -12941,7 +12959,7 @@ async function updateMetricsServerConfig(request, reply) {
12941
12959
  }
12942
12960
  if (updates.config) {
12943
12961
  try {
12944
- import_core31.metricsServerManager.registerServer(tenantId, updated.key, updated.config);
12962
+ import_core32.metricsServerManager.registerServer(tenantId, updated.key, updated.config);
12945
12963
  } catch (error) {
12946
12964
  console.warn("Failed to re-register metrics server:", error);
12947
12965
  }
@@ -12963,7 +12981,7 @@ async function deleteMetricsServerConfig(request, reply) {
12963
12981
  const tenantId = getTenantId10(request);
12964
12982
  const { keyOrId } = request.params;
12965
12983
  try {
12966
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
12984
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
12967
12985
  const store2 = storeLattice.store;
12968
12986
  let config = await store2.getConfigByKey(tenantId, keyOrId);
12969
12987
  let configKey = keyOrId;
@@ -12988,8 +13006,8 @@ async function deleteMetricsServerConfig(request, reply) {
12988
13006
  };
12989
13007
  }
12990
13008
  try {
12991
- if (import_core31.metricsServerManager.hasServer(tenantId, configKey)) {
12992
- import_core31.metricsServerManager.removeServer(tenantId, configKey);
13009
+ if (import_core32.metricsServerManager.hasServer(tenantId, configKey)) {
13010
+ import_core32.metricsServerManager.removeServer(tenantId, configKey);
12993
13011
  }
12994
13012
  } catch (error) {
12995
13013
  console.warn("Failed to remove from MetricsServerManager:", error);
@@ -13010,7 +13028,7 @@ async function testMetricsServerConnection(request, reply) {
13010
13028
  const tenantId = getTenantId10(request);
13011
13029
  const { key } = request.params;
13012
13030
  try {
13013
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13031
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13014
13032
  const store2 = storeLattice.store;
13015
13033
  const config = await store2.getConfigByKey(tenantId, key);
13016
13034
  if (!config) {
@@ -13021,11 +13039,11 @@ async function testMetricsServerConnection(request, reply) {
13021
13039
  };
13022
13040
  }
13023
13041
  const testKey = `__test_${key}_${Date.now()}`;
13024
- import_core31.metricsServerManager.registerServer(tenantId, testKey, config.config);
13042
+ import_core32.metricsServerManager.registerServer(tenantId, testKey, config.config);
13025
13043
  try {
13026
- const client = await import_core31.metricsServerManager.getClient(tenantId, testKey);
13044
+ const client = await import_core32.metricsServerManager.getClient(tenantId, testKey);
13027
13045
  const result = await client.testConnection();
13028
- import_core31.metricsServerManager.removeServer(tenantId, testKey);
13046
+ import_core32.metricsServerManager.removeServer(tenantId, testKey);
13029
13047
  return {
13030
13048
  success: true,
13031
13049
  message: result.connected ? "Connection test successful" : "Connection test failed",
@@ -13033,7 +13051,7 @@ async function testMetricsServerConnection(request, reply) {
13033
13051
  };
13034
13052
  } catch (error) {
13035
13053
  try {
13036
- import_core31.metricsServerManager.removeServer(tenantId, testKey);
13054
+ import_core32.metricsServerManager.removeServer(tenantId, testKey);
13037
13055
  } catch {
13038
13056
  }
13039
13057
  return {
@@ -13061,7 +13079,7 @@ async function listAvailableMetrics(request, reply) {
13061
13079
  const tenantId = getTenantId10(request);
13062
13080
  const { key } = request.params;
13063
13081
  try {
13064
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13082
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13065
13083
  const store2 = storeLattice.store;
13066
13084
  const config = await store2.getConfigByKey(tenantId, key);
13067
13085
  if (!config) {
@@ -13071,10 +13089,10 @@ async function listAvailableMetrics(request, reply) {
13071
13089
  message: "Metrics server configuration not found"
13072
13090
  };
13073
13091
  }
13074
- if (!import_core31.metricsServerManager.hasServer(tenantId, key)) {
13075
- import_core31.metricsServerManager.registerServer(tenantId, key, config.config);
13092
+ if (!import_core32.metricsServerManager.hasServer(tenantId, key)) {
13093
+ import_core32.metricsServerManager.registerServer(tenantId, key, config.config);
13076
13094
  }
13077
- const client = await import_core31.metricsServerManager.getClient(tenantId, key);
13095
+ const client = await import_core32.metricsServerManager.getClient(tenantId, key);
13078
13096
  const metrics = await client.listMetrics();
13079
13097
  return {
13080
13098
  success: true,
@@ -13100,7 +13118,7 @@ async function queryMetricsData(request, reply) {
13100
13118
  const { key } = request.params;
13101
13119
  const { metricName, startTime, endTime, step, labels } = request.body;
13102
13120
  try {
13103
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13121
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13104
13122
  const store2 = storeLattice.store;
13105
13123
  const config = await store2.getConfigByKey(tenantId, key);
13106
13124
  if (!config) {
@@ -13117,10 +13135,10 @@ async function queryMetricsData(request, reply) {
13117
13135
  message: "metricName is required"
13118
13136
  };
13119
13137
  }
13120
- if (!import_core31.metricsServerManager.hasServer(tenantId, key)) {
13121
- import_core31.metricsServerManager.registerServer(tenantId, key, config.config);
13138
+ if (!import_core32.metricsServerManager.hasServer(tenantId, key)) {
13139
+ import_core32.metricsServerManager.registerServer(tenantId, key, config.config);
13122
13140
  }
13123
- const client = await import_core31.metricsServerManager.getClient(tenantId, key);
13141
+ const client = await import_core32.metricsServerManager.getClient(tenantId, key);
13124
13142
  const result = await client.queryMetricData(metricName, {
13125
13143
  startTime,
13126
13144
  endTime,
@@ -13147,7 +13165,7 @@ async function getDataSources(request, reply) {
13147
13165
  const tenantId = getTenantId10(request);
13148
13166
  const { key } = request.params;
13149
13167
  try {
13150
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13168
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13151
13169
  const store2 = storeLattice.store;
13152
13170
  const config = await store2.getConfigByKey(tenantId, key);
13153
13171
  if (!config) {
@@ -13165,7 +13183,7 @@ async function getDataSources(request, reply) {
13165
13183
  };
13166
13184
  }
13167
13185
  const semanticConfig = config.config;
13168
- const client = new import_core31.SemanticMetricsClient(semanticConfig);
13186
+ const client = new import_core32.SemanticMetricsClient(semanticConfig);
13169
13187
  const allDatasources = await client.getDataSources();
13170
13188
  const selectedIds = semanticConfig.selectedDataSources || [];
13171
13189
  const filteredDatasources = selectedIds.length > 0 ? allDatasources.filter((ds) => selectedIds.includes(String(ds.id))) : allDatasources;
@@ -13188,7 +13206,7 @@ async function getDatasourceMetrics(request, reply) {
13188
13206
  const tenantId = getTenantId10(request);
13189
13207
  const { key, datasourceId } = request.params;
13190
13208
  try {
13191
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13209
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13192
13210
  const store2 = storeLattice.store;
13193
13211
  const config = await store2.getConfigByKey(tenantId, key);
13194
13212
  if (!config) {
@@ -13206,7 +13224,7 @@ async function getDatasourceMetrics(request, reply) {
13206
13224
  };
13207
13225
  }
13208
13226
  const semanticConfig = config.config;
13209
- const client = new import_core31.SemanticMetricsClient(semanticConfig);
13227
+ const client = new import_core32.SemanticMetricsClient(semanticConfig);
13210
13228
  const metrics = await client.getDatasourceMetrics(datasourceId);
13211
13229
  return {
13212
13230
  success: true,
@@ -13226,7 +13244,7 @@ async function querySemanticMetrics(request, reply) {
13226
13244
  const { key } = request.params;
13227
13245
  const body = request.body;
13228
13246
  try {
13229
- const storeLattice = (0, import_core31.getStoreLattice)("default", "metrics");
13247
+ const storeLattice = (0, import_core32.getStoreLattice)("default", "metrics");
13230
13248
  const store2 = storeLattice.store;
13231
13249
  const config = await store2.getConfigByKey(tenantId, key);
13232
13250
  if (!config) {
@@ -13251,7 +13269,7 @@ async function querySemanticMetrics(request, reply) {
13251
13269
  };
13252
13270
  }
13253
13271
  const semanticConfig = config.config;
13254
- const client = new import_core31.SemanticMetricsClient(semanticConfig);
13272
+ const client = new import_core32.SemanticMetricsClient(semanticConfig);
13255
13273
  const result = await client.semanticQuery(body);
13256
13274
  const columnNames = result.columns.map((col) => col.name);
13257
13275
  const allDataPoints = [];
@@ -13311,7 +13329,7 @@ async function testSemanticDataSources(request, reply) {
13311
13329
  password: body.password,
13312
13330
  headers: body.headers
13313
13331
  };
13314
- const client = new import_core31.SemanticMetricsClient(testConfig);
13332
+ const client = new import_core32.SemanticMetricsClient(testConfig);
13315
13333
  const datasources = await client.getDataSources();
13316
13334
  return {
13317
13335
  success: true,
@@ -13347,7 +13365,7 @@ async function testDatasourceMetrics(request, reply) {
13347
13365
  password: body.password,
13348
13366
  headers: body.headers
13349
13367
  };
13350
- const client = new import_core31.SemanticMetricsClient(testConfig);
13368
+ const client = new import_core32.SemanticMetricsClient(testConfig);
13351
13369
  const metrics = await client.getDatasourceMetrics(datasourceId);
13352
13370
  return {
13353
13371
  success: true,
@@ -13379,13 +13397,13 @@ function registerMetricsServerConfigRoutes(app2) {
13379
13397
  }
13380
13398
 
13381
13399
  // src/controllers/connections.ts
13382
- var import_core33 = require("@axiom-lattice/core");
13400
+ var import_core34 = require("@axiom-lattice/core");
13383
13401
  var import_zod2 = require("zod");
13384
13402
 
13385
13403
  // src/services/plugins/connectionSecretFields.ts
13386
- var import_core32 = require("@axiom-lattice/core");
13404
+ var import_core33 = require("@axiom-lattice/core");
13387
13405
  function secretFieldsForConnection(plugin) {
13388
- const keys2 = (0, import_core32.connectionSecretFields)(plugin);
13406
+ const keys2 = (0, import_core33.connectionSecretFields)(plugin);
13389
13407
  return keys2.length > 0 ? keys2 : void 0;
13390
13408
  }
13391
13409
 
@@ -13413,7 +13431,7 @@ async function getTenantPlugin(request, type) {
13413
13431
  }
13414
13432
  async function resolveConfig(type, body, tenantId) {
13415
13433
  if (body.key) {
13416
- const entry = await import_core33.ConnectionRegistry.get(type, body.key, tenantId);
13434
+ const entry = await import_core34.ConnectionRegistry.get(type, body.key, tenantId);
13417
13435
  if (!entry) throw { status: 404, error: `Connection "${body.key}" not found` };
13418
13436
  return entry.config;
13419
13437
  }
@@ -13424,7 +13442,7 @@ function connectionRoutes(fastify2) {
13424
13442
  fastify2.get("/api/connections", async (request, reply) => {
13425
13443
  const { type } = request.query;
13426
13444
  if (!type) return reply.status(400).send({ error: "query 'type' required" });
13427
- const entries = await import_core33.ConnectionRegistry.list(type, getTenant(request));
13445
+ const entries = await import_core34.ConnectionRegistry.list(type, getTenant(request));
13428
13446
  return reply.send({
13429
13447
  success: true,
13430
13448
  data: { records: entries, total: entries.length }
@@ -13433,7 +13451,7 @@ function connectionRoutes(fastify2) {
13433
13451
  fastify2.post("/api/connections", async (request, reply) => {
13434
13452
  const parsed = createBody.parse(request.body);
13435
13453
  const plugin = await getTenantPlugin(request, parsed.type);
13436
- const entry = await import_core33.ConnectionRegistry.create({
13454
+ const entry = await import_core34.ConnectionRegistry.create({
13437
13455
  tenantId: getTenant(request),
13438
13456
  type: parsed.type,
13439
13457
  key: parsed.key,
@@ -13453,7 +13471,7 @@ function connectionRoutes(fastify2) {
13453
13471
  const { key } = request.params;
13454
13472
  const body = request.body;
13455
13473
  const tenantId = getTenant(request);
13456
- const existing = await import_core33.ConnectionRegistry.get(type, key, tenantId);
13474
+ const existing = await import_core34.ConnectionRegistry.get(type, key, tenantId);
13457
13475
  if (!existing) return reply.status(404).send({ error: "not found" });
13458
13476
  const plugin = await getTenantPlugin(request, type);
13459
13477
  const updates = {};
@@ -13463,7 +13481,7 @@ function connectionRoutes(fastify2) {
13463
13481
  updates.config = { ...existing.config, ...body.config };
13464
13482
  updates.secretFields = secretFieldsForConnection(plugin);
13465
13483
  }
13466
- const entry = await import_core33.ConnectionRegistry.update(tenantId, type, key, updates);
13484
+ const entry = await import_core34.ConnectionRegistry.update(tenantId, type, key, updates);
13467
13485
  return reply.send({
13468
13486
  success: true,
13469
13487
  data: entry
@@ -13473,7 +13491,7 @@ function connectionRoutes(fastify2) {
13473
13491
  const { type } = request.query;
13474
13492
  if (!type) return reply.status(400).send({ error: "query 'type' required" });
13475
13493
  const { key } = request.params;
13476
- const ok = await import_core33.ConnectionRegistry.delete(getTenant(request), type, key);
13494
+ const ok = await import_core34.ConnectionRegistry.delete(getTenant(request), type, key);
13477
13495
  return reply.send({ success: ok });
13478
13496
  });
13479
13497
  fastify2.post("/api/connections/test", async (request, reply) => {
@@ -13534,8 +13552,8 @@ function connectionRoutes(fastify2) {
13534
13552
  }
13535
13553
 
13536
13554
  // src/controllers/mcp-configs.ts
13537
- var import_core34 = require("@axiom-lattice/core");
13538
- var import_crypto8 = require("crypto");
13555
+ var import_core35 = require("@axiom-lattice/core");
13556
+ var import_crypto7 = require("crypto");
13539
13557
 
13540
13558
  // src/services/mcpConfigSync.ts
13541
13559
  var MCP_CONFIG_CHANGED_TOPIC = "mcp-config-changed";
@@ -13583,15 +13601,15 @@ function getTenantId11(request) {
13583
13601
  function broadcastMcpConfigChanged(tenantId, serverKey) {
13584
13602
  if (!tenantId || !serverKey) return;
13585
13603
  try {
13586
- const outbox = (0, import_core34.getStoreLattice)("default", "outbox").store;
13587
- void publishMcpConfigChanged(outbox, (0, import_core34.getReplicaId)(), tenantId, serverKey);
13604
+ const outbox = (0, import_core35.getStoreLattice)("default", "outbox").store;
13605
+ void publishMcpConfigChanged(outbox, (0, import_core35.getReplicaId)(), tenantId, serverKey);
13588
13606
  } catch {
13589
13607
  }
13590
13608
  }
13591
13609
  async function getMcpServerConfigList(request, reply) {
13592
13610
  const tenantId = getTenantId11(request);
13593
13611
  try {
13594
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13612
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13595
13613
  const store2 = storeLattice.store;
13596
13614
  const configs = await store2.getAllConfigs(tenantId);
13597
13615
  return {
@@ -13618,7 +13636,7 @@ async function getMcpServerConfig(request, reply) {
13618
13636
  const tenantId = getTenantId11(request);
13619
13637
  const { key } = request.params;
13620
13638
  try {
13621
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13639
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13622
13640
  const store2 = storeLattice.store;
13623
13641
  const config = await store2.getConfigByKey(tenantId, key);
13624
13642
  if (!config) {
@@ -13644,7 +13662,7 @@ async function createMcpServerConfig(request, reply) {
13644
13662
  const tenantId = getTenantId11(request);
13645
13663
  const body = request.body;
13646
13664
  try {
13647
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13665
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13648
13666
  const store2 = storeLattice.store;
13649
13667
  const existing = await store2.getConfigByKey(tenantId, body.key);
13650
13668
  if (existing) {
@@ -13654,7 +13672,7 @@ async function createMcpServerConfig(request, reply) {
13654
13672
  message: "MCP server configuration with this key already exists"
13655
13673
  };
13656
13674
  }
13657
- const id3 = body.id || (0, import_crypto8.randomUUID)();
13675
+ const id3 = body.id || (0, import_crypto7.randomUUID)();
13658
13676
  const config = await store2.createConfig(tenantId, id3, body);
13659
13677
  try {
13660
13678
  await connectAndRegisterTools(config);
@@ -13685,7 +13703,7 @@ async function updateMcpServerConfig(request, reply) {
13685
13703
  const { key } = request.params;
13686
13704
  const updates = request.body;
13687
13705
  try {
13688
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13706
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13689
13707
  const store2 = storeLattice.store;
13690
13708
  const existing = await store2.getConfigByKey(tenantId, key);
13691
13709
  if (!existing) {
@@ -13707,13 +13725,13 @@ async function updateMcpServerConfig(request, reply) {
13707
13725
  }
13708
13726
  if (configChanged) {
13709
13727
  try {
13710
- const connection = (0, import_core34.convertToConnection)(updated.config);
13711
- import_core34.mcpManager.registerServer(tenantId, key, connection, {
13728
+ const connection = (0, import_core35.convertToConnection)(updated.config);
13729
+ import_core35.mcpManager.registerServer(tenantId, key, connection, {
13712
13730
  timeoutMs: updated.config.timeout,
13713
13731
  maxAttempts: updated.config.retryAttempts
13714
13732
  });
13715
- await import_core34.mcpManager.ensureConnected(tenantId, key);
13716
- await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13733
+ await import_core35.mcpManager.ensureConnected(tenantId, key);
13734
+ await import_core35.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13717
13735
  await store2.updateConfig(tenantId, existing.id, { status: "connected" });
13718
13736
  updated.status = "connected";
13719
13737
  } catch (error) {
@@ -13721,16 +13739,16 @@ async function updateMcpServerConfig(request, reply) {
13721
13739
  await store2.updateConfig(tenantId, existing.id, { status: "error" });
13722
13740
  updated.status = "error";
13723
13741
  }
13724
- } else if (toolsChanged && import_core34.mcpManager.hasServer(tenantId, key)) {
13742
+ } else if (toolsChanged && import_core35.mcpManager.hasServer(tenantId, key)) {
13725
13743
  try {
13726
- await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13744
+ await import_core35.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13727
13745
  } catch (error) {
13728
13746
  console.warn("Failed to re-register MCP tools:", error);
13729
13747
  }
13730
13748
  }
13731
- if (statusChanged && updated.status !== "connected" && import_core34.mcpManager.hasServer(tenantId, key)) {
13749
+ if (statusChanged && updated.status !== "connected" && import_core35.mcpManager.hasServer(tenantId, key)) {
13732
13750
  try {
13733
- await import_core34.mcpManager.removeServer(tenantId, key);
13751
+ await import_core35.mcpManager.removeServer(tenantId, key);
13734
13752
  } catch (error) {
13735
13753
  console.warn("Failed to remove MCP server:", error);
13736
13754
  }
@@ -13755,7 +13773,7 @@ async function deleteMcpServerConfig(request, reply) {
13755
13773
  const tenantId = getTenantId11(request);
13756
13774
  const { keyOrId } = request.params;
13757
13775
  try {
13758
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13776
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13759
13777
  const store2 = storeLattice.store;
13760
13778
  let config = await store2.getConfigByKey(tenantId, keyOrId);
13761
13779
  let configKey = keyOrId;
@@ -13773,8 +13791,8 @@ async function deleteMcpServerConfig(request, reply) {
13773
13791
  };
13774
13792
  }
13775
13793
  try {
13776
- if (import_core34.mcpManager.hasServer(tenantId, configKey)) {
13777
- await import_core34.mcpManager.removeServer(tenantId, configKey);
13794
+ if (import_core35.mcpManager.hasServer(tenantId, configKey)) {
13795
+ await import_core35.mcpManager.removeServer(tenantId, configKey);
13778
13796
  }
13779
13797
  } catch (error) {
13780
13798
  console.warn("Failed to remove from MCP manager:", error);
@@ -13803,7 +13821,7 @@ async function testMcpServerConnection(request, reply) {
13803
13821
  const tenantId = getTenantId11(request);
13804
13822
  const { key } = request.params;
13805
13823
  try {
13806
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13824
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13807
13825
  const store2 = storeLattice.store;
13808
13826
  const config = await store2.getConfigByKey(tenantId, key);
13809
13827
  if (!config) {
@@ -13815,8 +13833,8 @@ async function testMcpServerConnection(request, reply) {
13815
13833
  }
13816
13834
  try {
13817
13835
  const testKey = `__test_${key}_${Date.now()}`;
13818
- const connection = (0, import_core34.convertToConnection)(config.config);
13819
- const { latency } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
13836
+ const connection = (0, import_core35.convertToConnection)(config.config);
13837
+ const { latency } = await import_core35.McpLatticeManager.testConnection(testKey, connection);
13820
13838
  return {
13821
13839
  success: true,
13822
13840
  message: "Connection test successful",
@@ -13851,7 +13869,7 @@ async function listMcpServerTools(request, reply) {
13851
13869
  const tenantId = getTenantId11(request);
13852
13870
  const { key } = request.params;
13853
13871
  try {
13854
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13872
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13855
13873
  const store2 = storeLattice.store;
13856
13874
  const config = await store2.getConfigByKey(tenantId, key);
13857
13875
  if (!config) {
@@ -13861,7 +13879,7 @@ async function listMcpServerTools(request, reply) {
13861
13879
  message: "MCP server configuration not found"
13862
13880
  };
13863
13881
  }
13864
- const wasConnected = import_core34.mcpManager.isServerConnected(tenantId, key);
13882
+ const wasConnected = import_core35.mcpManager.isServerConnected(tenantId, key);
13865
13883
  if (!wasConnected) {
13866
13884
  await connectAndRegisterTools(config);
13867
13885
  }
@@ -13872,7 +13890,7 @@ async function listMcpServerTools(request, reply) {
13872
13890
  if (!wasConnected || statusStale) {
13873
13891
  broadcastMcpConfigChanged(tenantId, key);
13874
13892
  }
13875
- const tools = await import_core34.mcpManager.getServerTools(tenantId, key);
13893
+ const tools = await import_core35.mcpManager.getServerTools(tenantId, key);
13876
13894
  return {
13877
13895
  success: true,
13878
13896
  message: "Tools retrieved successfully",
@@ -13892,7 +13910,7 @@ async function connectMcpServer(request, reply) {
13892
13910
  const tenantId = getTenantId11(request);
13893
13911
  const { key } = request.params;
13894
13912
  try {
13895
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13913
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13896
13914
  const store2 = storeLattice.store;
13897
13915
  const config = await store2.getConfigByKey(tenantId, key);
13898
13916
  if (!config) {
@@ -13914,7 +13932,7 @@ async function connectMcpServer(request, reply) {
13914
13932
  };
13915
13933
  } catch (error) {
13916
13934
  console.error("Failed to connect MCP server:", error);
13917
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13935
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13918
13936
  const store2 = storeLattice.store;
13919
13937
  const config = await store2.getConfigByKey(tenantId, key);
13920
13938
  if (config) {
@@ -13931,7 +13949,7 @@ async function disconnectMcpServer(request, reply) {
13931
13949
  const tenantId = getTenantId11(request);
13932
13950
  const { key } = request.params;
13933
13951
  try {
13934
- const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13952
+ const storeLattice = (0, import_core35.getStoreLattice)("default", "mcp");
13935
13953
  const store2 = storeLattice.store;
13936
13954
  const config = await store2.getConfigByKey(tenantId, key);
13937
13955
  if (!config) {
@@ -13941,8 +13959,8 @@ async function disconnectMcpServer(request, reply) {
13941
13959
  message: "MCP server configuration not found"
13942
13960
  };
13943
13961
  }
13944
- if (import_core34.mcpManager.hasServer(tenantId, key)) {
13945
- await import_core34.mcpManager.removeServer(tenantId, key);
13962
+ if (import_core35.mcpManager.hasServer(tenantId, key)) {
13963
+ await import_core35.mcpManager.removeServer(tenantId, key);
13946
13964
  }
13947
13965
  const updated = await store2.updateConfig(tenantId, config.id, {
13948
13966
  status: "disconnected"
@@ -13972,8 +13990,8 @@ async function testMcpServerTools(request, reply) {
13972
13990
  };
13973
13991
  }
13974
13992
  const testKey = `__test_${Date.now()}`;
13975
- const connection = (0, import_core34.convertToConnection)(body.config);
13976
- const { tools } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
13993
+ const connection = (0, import_core35.convertToConnection)(body.config);
13994
+ const { tools } = await import_core35.McpLatticeManager.testConnection(testKey, connection);
13977
13995
  return {
13978
13996
  success: true,
13979
13997
  message: "Tools retrieved successfully",
@@ -13990,14 +14008,14 @@ async function testMcpServerTools(request, reply) {
13990
14008
  }
13991
14009
  }
13992
14010
  async function connectAndRegisterTools(config) {
13993
- const connection = (0, import_core34.convertToConnection)(config.config);
13994
- import_core34.mcpManager.registerServer(config.tenantId, config.key, connection, {
14011
+ const connection = (0, import_core35.convertToConnection)(config.config);
14012
+ import_core35.mcpManager.registerServer(config.tenantId, config.key, connection, {
13995
14013
  timeoutMs: config.config.timeout,
13996
14014
  maxAttempts: config.config.retryAttempts,
13997
14015
  selectedTools: config.selectedTools
13998
14016
  });
13999
- await import_core34.mcpManager.ensureConnected(config.tenantId, config.key);
14000
- await import_core34.mcpManager.registerToolsToToolLattice(
14017
+ await import_core35.mcpManager.ensureConnected(config.tenantId, config.key);
14018
+ await import_core35.mcpManager.registerToolsToToolLattice(
14001
14019
  config.tenantId,
14002
14020
  config.key,
14003
14021
  config.selectedTools
@@ -14018,7 +14036,7 @@ function registerMcpServerConfigRoutes(app2) {
14018
14036
 
14019
14037
  // src/routes/mcp-apps.ts
14020
14038
  var import_protocols6 = require("@axiom-lattice/protocols");
14021
- var import_core36 = require("@axiom-lattice/core");
14039
+ var import_core37 = require("@axiom-lattice/core");
14022
14040
 
14023
14041
  // src/services/mcp-ui/UiResourceResolver.ts
14024
14042
  var import_node_crypto5 = require("crypto");
@@ -14074,6 +14092,17 @@ var UiResourceResolver = class {
14074
14092
  async invalidate(tenantId, ref) {
14075
14093
  await this.deps.store.delete(this.fullKey(tenantId, ref));
14076
14094
  }
14095
+ /**
14096
+ * Evict every cached plugin UI resource for a tenant.
14097
+ *
14098
+ * @param tenantId Tenant whose plugin UI resources to drop.
14099
+ * @remarks Called when a tenant's plugin catalog changes so an edited
14100
+ * `ui/*.html` is re-fetched instead of being served from the TTL cache
14101
+ * (which is keyed by ref identity, not content).
14102
+ */
14103
+ async invalidateTenantPlugins(tenantId) {
14104
+ await this.deps.store.deleteByPrefix(`${tenantId}\0plugin\0`);
14105
+ }
14077
14106
  async fetchAndCache(tenantId, ref, key, cached) {
14078
14107
  try {
14079
14108
  const fresh = ref.kind === "mcp" ? await this.deps.fetchMcp(tenantId, ref.serverKey, ref.resourceUri) : await this.deps.fetchPlugin(tenantId, ref.pluginType, ref.resource);
@@ -14393,26 +14422,31 @@ function createDefaultPluginBackend() {
14393
14422
  return {
14394
14423
  resolvePlugin: (tenantId, type) => resolveTenantPluginByType(tenantId, type),
14395
14424
  catalog: {
14396
- readPluginFile: (tenantId, pluginType, relPath) => (0, import_core36.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14397
- getValidatedManifest: (tenantId, pluginType) => (0, import_core36.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14398
- getExecutor: () => (0, import_core36.getSandboxPluginCatalog)().getExecutor()
14425
+ readPluginFile: (tenantId, pluginType, relPath) => (0, import_core37.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14426
+ getValidatedManifest: (tenantId, pluginType) => (0, import_core37.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14427
+ getExecutor: () => (0, import_core37.getSandboxPluginCatalog)().getExecutor()
14399
14428
  }
14400
14429
  };
14401
14430
  }
14431
+ var uiResourceResolverSingleton;
14432
+ function getMcpUiResourceResolver() {
14433
+ return uiResourceResolverSingleton;
14434
+ }
14402
14435
  function resolveMcpAppDeps(pluginBackend = createDefaultPluginBackend()) {
14403
14436
  const uiResourceResolver = new UiResourceResolver({
14404
14437
  store: new InMemoryMcpUiResourceCacheStore(),
14405
- fetchMcp: (tenantId, serverKey, resourceUri) => import_core36.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14438
+ fetchMcp: (tenantId, serverKey, resourceUri) => import_core37.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14406
14439
  fetchPlugin: (tenantId, pluginType, resource) => fetchPluginUiResource(pluginBackend, tenantId, pluginType, resource)
14407
14440
  });
14441
+ uiResourceResolverSingleton = uiResourceResolver;
14408
14442
  return {
14409
14443
  resolveUiResource: (tenantId, ref) => uiResourceResolver.resolve(tenantId, ref),
14410
- callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core36.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
14444
+ callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core37.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
14411
14445
  // Plugin refs reach these only after `tools/call`; the handler treats the
14412
14446
  // rejection as an unsupported method (403). The branches are live because
14413
14447
  // the pure handler deliberately delegates method policy to the deps.
14414
- readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core36.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14415
- listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core36.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14448
+ readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core37.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14449
+ listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core37.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14416
14450
  };
14417
14451
  }
14418
14452
  function firstHeader(request, name) {
@@ -14456,12 +14490,12 @@ function registerMcpAppRoutes(fastify2) {
14456
14490
  }
14457
14491
 
14458
14492
  // src/controllers/eval.ts
14459
- var import_core38 = require("@axiom-lattice/core");
14493
+ var import_core39 = require("@axiom-lattice/core");
14460
14494
  var import_uuid5 = require("uuid");
14461
14495
 
14462
14496
  // src/services/eval-runner.ts
14463
14497
  var import_events = require("events");
14464
- var import_core37 = require("@axiom-lattice/core");
14498
+ var import_core38 = require("@axiom-lattice/core");
14465
14499
  var import_uuid4 = require("uuid");
14466
14500
  var TERMINAL_PERSIST_ATTEMPTS = 2;
14467
14501
  function mapLogs(logs) {
@@ -14571,14 +14605,14 @@ var EvalRunner = class {
14571
14605
  const judgeModelKey = judgeCfg.modelKey || "";
14572
14606
  let resolvedJudgeModelKey;
14573
14607
  if (judgeModelKey) {
14574
- if (!await (0, import_core37.hasModelLatticeForTenant)(tenantId, judgeModelKey)) {
14608
+ if (!await (0, import_core38.hasModelLatticeForTenant)(tenantId, judgeModelKey)) {
14575
14609
  throw new Error(`Judge model "${judgeModelKey}" is not registered`);
14576
14610
  }
14577
14611
  resolvedJudgeModelKey = judgeModelKey;
14578
14612
  } else {
14579
14613
  resolvedJudgeModelKey = "default";
14580
- if (!await (0, import_core37.hasModelLatticeForTenant)(tenantId, resolvedJudgeModelKey)) {
14581
- const models = (0, import_core37.listModelLatticesForTenant)(tenantId);
14614
+ if (!await (0, import_core38.hasModelLatticeForTenant)(tenantId, resolvedJudgeModelKey)) {
14615
+ const models = (0, import_core38.listModelLatticesForTenant)(tenantId);
14582
14616
  resolvedJudgeModelKey = models[0]?.key ?? "";
14583
14617
  if (!resolvedJudgeModelKey) {
14584
14618
  throw new Error("No model registered \u2014 cannot run eval without a judge model");
@@ -14684,7 +14718,7 @@ var EvalRunner = class {
14684
14718
  };
14685
14719
  const runPromise = (async () => {
14686
14720
  try {
14687
- const evalProject = new import_core37.LatticeEvalProject(projectConfig, onCaseComplete);
14721
+ const evalProject = new import_core38.LatticeEvalProject(projectConfig, onCaseComplete);
14688
14722
  const calibration = await evalProject.calibrateJudge();
14689
14723
  if (!calibration.ok && !calibration.bypassed) {
14690
14724
  throw new Error(`Judge calibration failed: ${calibration.reason}`);
@@ -14788,7 +14822,7 @@ var EvalRunner = class {
14788
14822
  return ctx !== void 0 && !ctx.terminal.workerSettled && (tenantId === void 0 || ctx.tenantId === tenantId);
14789
14823
  }
14790
14824
  getEvalStore() {
14791
- return (0, import_core37.getStoreLattice)("default", "eval").store;
14825
+ return (0, import_core38.getStoreLattice)("default", "eval").store;
14792
14826
  }
14793
14827
  releaseProjectLease(leaseKey, leaseToken) {
14794
14828
  if (this.projectLeases.get(leaseKey) === leaseToken) this.projectLeases.delete(leaseKey);
@@ -14805,7 +14839,7 @@ function getTenantId12(request) {
14805
14839
  return request.headers["x-tenant-id"] || "default";
14806
14840
  }
14807
14841
  function getEvalStore() {
14808
- return (0, import_core38.getStoreLattice)("default", "eval").store;
14842
+ return (0, import_core39.getStoreLattice)("default", "eval").store;
14809
14843
  }
14810
14844
  async function getOwnedSuite(store2, tenantId, projectId, suiteId) {
14811
14845
  const project = await store2.getProjectById(tenantId, projectId);
@@ -14836,7 +14870,7 @@ async function createProject(request, reply) {
14836
14870
  const judgeCfg = data.judgeModelConfig || {};
14837
14871
  const modelKey2 = judgeCfg.modelKey || "";
14838
14872
  if (modelKey2) {
14839
- if (!await (0, import_core38.hasModelLatticeForTenant)(tenantId, modelKey2)) {
14873
+ if (!await (0, import_core39.hasModelLatticeForTenant)(tenantId, modelKey2)) {
14840
14874
  return reply.status(400).send({ success: false, message: `Judge model "${modelKey2}" is not registered` });
14841
14875
  }
14842
14876
  }
@@ -14882,7 +14916,7 @@ async function listProjects(request, reply) {
14882
14916
  let projects = await store2.getProjectsByTenant(tenantId);
14883
14917
  if (projects.length === 0) {
14884
14918
  try {
14885
- const models = import_core38.modelLatticeManager.getAllLattices();
14919
+ const models = import_core39.modelLatticeManager.getAllLattices();
14886
14920
  const first = models[0];
14887
14921
  const judgeModel = first ? { modelKey: first.key } : {};
14888
14922
  const host = request.hostname || "localhost";
@@ -14950,7 +14984,7 @@ async function updateProject(request, reply) {
14950
14984
  const judgeCfg = body.judgeModelConfig || {};
14951
14985
  const modelKey2 = judgeCfg.modelKey || "";
14952
14986
  if (modelKey2) {
14953
- if (!import_core38.modelLatticeManager.hasLattice(modelKey2)) {
14987
+ if (!import_core39.modelLatticeManager.hasLattice(modelKey2)) {
14954
14988
  return reply.status(400).send({ success: false, message: `Judge model "${modelKey2}" is not registered` });
14955
14989
  }
14956
14990
  }
@@ -15332,11 +15366,11 @@ data: ${JSON.stringify(event.data)}
15332
15366
  }
15333
15367
 
15334
15368
  // src/controllers/users.ts
15335
- var import_core39 = require("@axiom-lattice/core");
15369
+ var import_core40 = require("@axiom-lattice/core");
15336
15370
  var import_uuid6 = require("uuid");
15337
15371
  var UsersController = class {
15338
15372
  constructor() {
15339
- this.userStore = (0, import_core39.getStoreLattice)("default", "user").store;
15373
+ this.userStore = (0, import_core40.getStoreLattice)("default", "user").store;
15340
15374
  }
15341
15375
  async listUsers(request, reply) {
15342
15376
  const { email } = request.query;
@@ -15414,11 +15448,11 @@ function registerUserRoutes(app2) {
15414
15448
  }
15415
15449
 
15416
15450
  // src/controllers/tenants.ts
15417
- var import_core40 = require("@axiom-lattice/core");
15451
+ var import_core41 = require("@axiom-lattice/core");
15418
15452
  var import_uuid7 = require("uuid");
15419
15453
  var TenantsController = class {
15420
15454
  constructor() {
15421
- this.tenantStore = (0, import_core40.getStoreLattice)("default", "tenant").store;
15455
+ this.tenantStore = (0, import_core41.getStoreLattice)("default", "tenant").store;
15422
15456
  }
15423
15457
  // ==================== Tenant CRUD ====================
15424
15458
  async listTenants(request, reply) {
@@ -15482,7 +15516,7 @@ function registerTenantRoutes(app2) {
15482
15516
  }
15483
15517
 
15484
15518
  // src/controllers/auth.ts
15485
- var import_core41 = require("@axiom-lattice/core");
15519
+ var import_core42 = require("@axiom-lattice/core");
15486
15520
  var import_uuid8 = require("uuid");
15487
15521
  var import_node_crypto6 = require("crypto");
15488
15522
  var defaultAuthConfig = {
@@ -15492,9 +15526,9 @@ var defaultAuthConfig = {
15492
15526
  };
15493
15527
  var AuthController = class {
15494
15528
  constructor(config = {}) {
15495
- this.userStore = (0, import_core41.getStoreLattice)("default", "user").store;
15496
- this.tenantStore = (0, import_core41.getStoreLattice)("default", "tenant").store;
15497
- this.userTenantLinkStore = (0, import_core41.getStoreLattice)("default", "userTenantLink").store;
15529
+ this.userStore = (0, import_core42.getStoreLattice)("default", "user").store;
15530
+ this.tenantStore = (0, import_core42.getStoreLattice)("default", "tenant").store;
15531
+ this.userTenantLinkStore = (0, import_core42.getStoreLattice)("default", "userTenantLink").store;
15498
15532
  this.config = { ...defaultAuthConfig, ...config };
15499
15533
  }
15500
15534
  async register(request, reply) {
@@ -15653,7 +15687,7 @@ var AuthController = class {
15653
15687
  const linkMeta = link?.metadata || {};
15654
15688
  let personalAssistant = null;
15655
15689
  if (linkMeta.personalAssistantId) {
15656
- const assistantStore = (0, import_core41.getStoreLattice)("default", "assistant").store;
15690
+ const assistantStore = (0, import_core42.getStoreLattice)("default", "assistant").store;
15657
15691
  const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
15658
15692
  if (exists) {
15659
15693
  personalAssistant = {
@@ -16170,7 +16204,7 @@ var larkChannelAdapter = {
16170
16204
  };
16171
16205
 
16172
16206
  // src/channels/lark/verification.ts
16173
- var import_crypto9 = __toESM(require("crypto"));
16207
+ var import_crypto8 = __toESM(require("crypto"));
16174
16208
  function parseLarkRequestBody(body, encryptKey) {
16175
16209
  const parsed = body || {};
16176
16210
  if (encryptKey && typeof parsed.encrypt === "string") {
@@ -16179,11 +16213,11 @@ function parseLarkRequestBody(body, encryptKey) {
16179
16213
  return parsed;
16180
16214
  }
16181
16215
  function decryptLarkPayload(encryptKey, encryptedPayload) {
16182
- const key = import_crypto9.default.createHash("sha256").update(encryptKey).digest();
16216
+ const key = import_crypto8.default.createHash("sha256").update(encryptKey).digest();
16183
16217
  const buffer = Buffer.from(encryptedPayload, "base64");
16184
16218
  const iv = buffer.subarray(0, 16);
16185
16219
  const ciphertext = buffer.subarray(16);
16186
- const decipher = import_crypto9.default.createDecipheriv("aes-256-cbc", key, iv);
16220
+ const decipher = import_crypto8.default.createDecipheriv("aes-256-cbc", key, iv);
16187
16221
  const plaintext = Buffer.concat([
16188
16222
  decipher.update(ciphertext),
16189
16223
  decipher.final()
@@ -16220,13 +16254,13 @@ function verifyLarkRequestSignature(request, config) {
16220
16254
  return false;
16221
16255
  }
16222
16256
  const content = timestamp + nonce + config.encryptKey + JSON.stringify(request.body ?? {});
16223
- const expected = import_crypto9.default.createHash("sha256").update(content).digest("hex");
16257
+ const expected = import_crypto8.default.createHash("sha256").update(content).digest("hex");
16224
16258
  const expectedBuffer = Buffer.from(expected, "utf8");
16225
16259
  const actualBuffer = Buffer.from(signature, "utf8");
16226
16260
  if (actualBuffer.length !== expectedBuffer.length) {
16227
16261
  return false;
16228
16262
  }
16229
- return import_crypto9.default.timingSafeEqual(actualBuffer, expectedBuffer);
16263
+ return import_crypto8.default.timingSafeEqual(actualBuffer, expectedBuffer);
16230
16264
  }
16231
16265
 
16232
16266
  // src/channels/lark/controller.ts
@@ -16348,9 +16382,9 @@ function registerChannelRoutes(app2, dependencies) {
16348
16382
  }
16349
16383
 
16350
16384
  // src/controllers/channel-installations.ts
16351
- var import_crypto10 = require("crypto");
16385
+ var import_crypto9 = require("crypto");
16352
16386
  var import_protocols7 = require("@axiom-lattice/protocols");
16353
- var import_core42 = require("@axiom-lattice/core");
16387
+ var import_core43 = require("@axiom-lattice/core");
16354
16388
  var _adapterRegistry;
16355
16389
  var _router;
16356
16390
  function setChannelControllerDeps(deps) {
@@ -16481,7 +16515,7 @@ function snapshotPlainObject(value) {
16481
16515
  }
16482
16516
  }
16483
16517
  async function getInstallationStore() {
16484
- const store2 = (0, import_core42.getStoreLattice)("default", "channelInstallation").store;
16518
+ const store2 = (0, import_core43.getStoreLattice)("default", "channelInstallation").store;
16485
16519
  if (store2) return store2;
16486
16520
  const { PostgreSQLChannelInstallationStore } = await import("@axiom-lattice/pg-stores");
16487
16521
  const databaseUrl = process.env.DATABASE_URL;
@@ -16557,7 +16591,7 @@ async function createChannelInstallation(request, reply) {
16557
16591
  };
16558
16592
  }
16559
16593
  const store2 = await getInstallationStore();
16560
- const installationId = (0, import_crypto10.randomUUID)();
16594
+ const installationId = (0, import_crypto9.randomUUID)();
16561
16595
  const createInput = {
16562
16596
  channel: body.channel,
16563
16597
  name: body.name,
@@ -16797,7 +16831,7 @@ function registerChannelInstallationRoutes(app2) {
16797
16831
 
16798
16832
  // src/controllers/channel-bindings.ts
16799
16833
  var import_protocols8 = require("@axiom-lattice/protocols");
16800
- var import_core43 = require("@axiom-lattice/core");
16834
+ var import_core44 = require("@axiom-lattice/core");
16801
16835
  function getTenantId14(request) {
16802
16836
  const userTenantId = request.user?.tenantId;
16803
16837
  if (typeof userTenantId === "string" && userTenantId) return userTenantId;
@@ -16855,7 +16889,7 @@ function snapshotPublicUpdate(value) {
16855
16889
  return body;
16856
16890
  }
16857
16891
  function getInstallationStore2() {
16858
- return (0, import_core43.getStoreLattice)("default", "channelInstallation").store;
16892
+ return (0, import_core44.getStoreLattice)("default", "channelInstallation").store;
16859
16893
  }
16860
16894
  async function isValidPublicInstallation(tenantId, channelInstallationId, channel) {
16861
16895
  const installation = await getInstallationStore2().getInstallationById(channelInstallationId);
@@ -16874,7 +16908,7 @@ async function getBindingList(request, _reply) {
16874
16908
  const tenantId = getTenantId14(request);
16875
16909
  const { channel, agentId, channelInstallationId, limit, offset } = request.query;
16876
16910
  try {
16877
- const registry = (0, import_core43.getBindingRegistry)();
16911
+ const registry = (0, import_core44.getBindingRegistry)();
16878
16912
  const bindings = await registry.list({
16879
16913
  channel,
16880
16914
  agentId,
@@ -16893,7 +16927,7 @@ async function getBindingList(request, _reply) {
16893
16927
  async function getBinding(request, reply) {
16894
16928
  const tenantId = getTenantId14(request);
16895
16929
  try {
16896
- const registry = (0, import_core43.getBindingRegistry)();
16930
+ const registry = (0, import_core44.getBindingRegistry)();
16897
16931
  const binding = await registry.findById(tenantId, request.params.id);
16898
16932
  if (!binding || isInternalBinding(binding)) {
16899
16933
  reply.status(404);
@@ -16915,7 +16949,7 @@ async function createBinding(request, reply) {
16915
16949
  input.channelInstallationId,
16916
16950
  input.channel
16917
16951
  )) return invalidPublicInstallation(reply);
16918
- const registry = (0, import_core43.getBindingRegistry)();
16952
+ const registry = (0, import_core44.getBindingRegistry)();
16919
16953
  const binding = await registry.create({ ...input, tenantId });
16920
16954
  reply.status(201);
16921
16955
  return { success: true, message: "Binding created", data: binding };
@@ -16932,7 +16966,7 @@ async function createBinding(request, reply) {
16932
16966
  async function updateBinding(request, reply) {
16933
16967
  try {
16934
16968
  const tenantId = getTenantId14(request);
16935
- const registry = (0, import_core43.getBindingRegistry)();
16969
+ const registry = (0, import_core44.getBindingRegistry)();
16936
16970
  const existing = await registry.findById(tenantId, request.params.id);
16937
16971
  if (!existing || isInternalBinding(existing)) {
16938
16972
  reply.status(404);
@@ -16959,7 +16993,7 @@ async function updateBinding(request, reply) {
16959
16993
  async function deleteBinding(request, reply) {
16960
16994
  try {
16961
16995
  const tenantId = getTenantId14(request);
16962
- const registry = (0, import_core43.getBindingRegistry)();
16996
+ const registry = (0, import_core44.getBindingRegistry)();
16963
16997
  const existing = await registry.findById(tenantId, request.params.id);
16964
16998
  if (!existing || isInternalBinding(existing)) {
16965
16999
  reply.status(404);
@@ -16981,7 +17015,7 @@ async function resolveBinding(request, _reply) {
16981
17015
  return { success: false, message: "No binding found", data: null };
16982
17016
  }
16983
17017
  try {
16984
- const registry = (0, import_core43.getBindingRegistry)();
17018
+ const registry = (0, import_core44.getBindingRegistry)();
16985
17019
  const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
16986
17020
  if (!binding) {
16987
17021
  return { success: false, message: "No binding found", data: null };
@@ -17004,7 +17038,7 @@ function registerChannelBindingRoutes(app2) {
17004
17038
  }
17005
17039
 
17006
17040
  // src/controllers/menu-items.ts
17007
- var import_core44 = require("@axiom-lattice/core");
17041
+ var import_core45 = require("@axiom-lattice/core");
17008
17042
  function getTenantId15(request) {
17009
17043
  const userTenantId = request.user?.tenantId;
17010
17044
  if (userTenantId) return userTenantId;
@@ -17016,7 +17050,7 @@ function errorMessage(err) {
17016
17050
  async function getMenuItemList(request, _reply) {
17017
17051
  const tenantId = getTenantId15(request);
17018
17052
  try {
17019
- const registry = (0, import_core44.getMenuRegistry)();
17053
+ const registry = (0, import_core45.getMenuRegistry)();
17020
17054
  const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
17021
17055
  return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
17022
17056
  } catch (error) {
@@ -17028,7 +17062,7 @@ async function getMenuItemList(request, _reply) {
17028
17062
  async function getMenuItem(request, reply) {
17029
17063
  const tenantId = getTenantId15(request);
17030
17064
  try {
17031
- const registry = (0, import_core44.getMenuRegistry)();
17065
+ const registry = (0, import_core45.getMenuRegistry)();
17032
17066
  const item = await registry.getById(request.params.id);
17033
17067
  if (!item || item.tenantId !== tenantId) {
17034
17068
  reply.status(404);
@@ -17045,7 +17079,7 @@ async function getMenuItem(request, reply) {
17045
17079
  async function createMenuItem(request, reply) {
17046
17080
  const tenantId = getTenantId15(request);
17047
17081
  try {
17048
- const registry = (0, import_core44.getMenuRegistry)();
17082
+ const registry = (0, import_core45.getMenuRegistry)();
17049
17083
  const item = await registry.create({ ...request.body, tenantId });
17050
17084
  reply.status(201);
17051
17085
  return { success: true, message: "Menu item created", data: item };
@@ -17059,7 +17093,7 @@ async function createMenuItem(request, reply) {
17059
17093
  async function updateMenuItem(request, reply) {
17060
17094
  try {
17061
17095
  const tenantId = getTenantId15(request);
17062
- const registry = (0, import_core44.getMenuRegistry)();
17096
+ const registry = (0, import_core45.getMenuRegistry)();
17063
17097
  const existing = await registry.getById(request.params.id);
17064
17098
  if (!existing || existing.tenantId !== tenantId) {
17065
17099
  reply.status(404);
@@ -17077,7 +17111,7 @@ async function updateMenuItem(request, reply) {
17077
17111
  async function deleteMenuItem(request, reply) {
17078
17112
  try {
17079
17113
  const tenantId = getTenantId15(request);
17080
- const registry = (0, import_core44.getMenuRegistry)();
17114
+ const registry = (0, import_core45.getMenuRegistry)();
17081
17115
  const existing = await registry.getById(request.params.id);
17082
17116
  if (!existing || existing.tenantId !== tenantId) {
17083
17117
  reply.status(404);
@@ -17277,7 +17311,7 @@ function registerA2ABridgeRoutes(app2) {
17277
17311
  }
17278
17312
 
17279
17313
  // src/routes/stt.ts
17280
- var import_core45 = require("@axiom-lattice/core");
17314
+ var import_core46 = require("@axiom-lattice/core");
17281
17315
  var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17282
17316
  "webm",
17283
17317
  "wav",
@@ -17290,7 +17324,7 @@ var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17290
17324
  var MAX_AUDIO_FILE_SIZE = 25 * 1024 * 1024;
17291
17325
  var registerSTTRoutes = (app2) => {
17292
17326
  app2.get("/api/stt/models", async (_request, reply) => {
17293
- const models = import_core45.sttModelLatticeManager.getAllSTTModelInfo();
17327
+ const models = import_core46.sttModelLatticeManager.getAllSTTModelInfo();
17294
17328
  return reply.send({ models });
17295
17329
  });
17296
17330
  app2.post(
@@ -17333,7 +17367,7 @@ var registerSTTRoutes = (app2) => {
17333
17367
  try {
17334
17368
  let client;
17335
17369
  try {
17336
- client = (0, import_core45.getSTTClient)(modelKey2);
17370
+ client = (0, import_core46.getSTTClient)(modelKey2);
17337
17371
  } catch {
17338
17372
  return reply.status(404).send({ error: `STT model "${modelKey2}" not found` });
17339
17373
  }
@@ -17355,7 +17389,7 @@ var registerSTTRoutes = (app2) => {
17355
17389
  };
17356
17390
 
17357
17391
  // src/controllers/local-a2a.ts
17358
- var import_core46 = require("@axiom-lattice/core");
17392
+ var import_core47 = require("@axiom-lattice/core");
17359
17393
  var import_protocols9 = require("@axiom-lattice/protocols");
17360
17394
  function getTenantId16(request) {
17361
17395
  const userTenantId = request.user?.tenantId;
@@ -17369,7 +17403,7 @@ function getLocalRuntime(assistant) {
17369
17403
  return graphDefinition.localRuntime;
17370
17404
  }
17371
17405
  async function getLocalA2AAssistants(tenantId) {
17372
- const storeLattice = (0, import_core46.getStoreLattice)("default", "assistant");
17406
+ const storeLattice = (0, import_core47.getStoreLattice)("default", "assistant");
17373
17407
  const assistants = await storeLattice.store.getAllAssistants(tenantId);
17374
17408
  const results = [];
17375
17409
  for (const assistant of assistants) {
@@ -17381,7 +17415,7 @@ async function getLocalA2AAssistants(tenantId) {
17381
17415
  return results;
17382
17416
  }
17383
17417
  async function getLocalA2AAssistant(tenantId, assistantId) {
17384
- const storeLattice = (0, import_core46.getStoreLattice)("default", "assistant");
17418
+ const storeLattice = (0, import_core47.getStoreLattice)("default", "assistant");
17385
17419
  const assistant = await storeLattice.store.getAssistantById(tenantId, assistantId);
17386
17420
  if (!assistant) return null;
17387
17421
  const runtime = getLocalRuntime(assistant);
@@ -17623,11 +17657,11 @@ function registerTaskRoutes(app2, controller) {
17623
17657
  }
17624
17658
 
17625
17659
  // src/routes/index.ts
17626
- var import_core57 = require("@axiom-lattice/core");
17660
+ var import_core58 = require("@axiom-lattice/core");
17627
17661
 
17628
17662
  // src/controllers/tasks.ts
17629
17663
  var import_protocols13 = require("@axiom-lattice/protocols");
17630
- var import_core48 = require("@axiom-lattice/core");
17664
+ var import_core49 = require("@axiom-lattice/core");
17631
17665
 
17632
17666
  // src/services/collaboration/ProjectTaskThreadService.ts
17633
17667
  var import_protocols11 = require("@axiom-lattice/protocols");
@@ -17947,7 +17981,7 @@ var import_node_crypto9 = require("crypto");
17947
17981
 
17948
17982
  // src/services/collaboration/ProjectTaskExecutionService.ts
17949
17983
  var import_node_crypto8 = require("crypto");
17950
- var import_core47 = require("@axiom-lattice/core");
17984
+ var import_core48 = require("@axiom-lattice/core");
17951
17985
  var import_protocols12 = require("@axiom-lattice/protocols");
17952
17986
  init_projectTaskScope();
17953
17987
 
@@ -18011,7 +18045,7 @@ var ProjectTaskExecutionService = class {
18011
18045
  if (!Number.isFinite(options.lifecycleSettlementTimeoutMs) || options.lifecycleSettlementTimeoutMs <= 0) {
18012
18046
  throw new Error("Project task lifecycle settlement timeout must be positive");
18013
18047
  }
18014
- this.runBridge = (0, import_core47.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
18048
+ this.runBridge = (0, import_core48.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
18015
18049
  }
18016
18050
  /** Validates, atomically starts, dispatches, and settles a pending Project Task. */
18017
18051
  async start(input, signal) {
@@ -18214,15 +18248,15 @@ var ProjectTaskExecutionService = class {
18214
18248
  settlement.cleanup();
18215
18249
  return { kind: "deferred", task: input.task, thread: input.thread, messageId: input.inputMessageId };
18216
18250
  }
18217
- if (resumed.status === import_core47.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18251
+ if (resumed.status === import_core48.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18218
18252
  settlement.cleanup();
18219
18253
  const outcome2 = await this.settleInterruptedEvent(input.task, input.thread, input.inputMessageId);
18220
18254
  settlement.resolve(outcome2);
18221
18255
  return outcome2;
18222
18256
  }
18223
- if ((resumed.status === import_core47.ThreadStatus.IDLE || resumed.status === import_core47.ThreadStatus.ERROR) && settlement.tryClaim()) {
18257
+ if ((resumed.status === import_core48.ThreadStatus.IDLE || resumed.status === import_core48.ThreadStatus.ERROR) && settlement.tryClaim()) {
18224
18258
  settlement.cleanup();
18225
- const reason = resumed.status === import_core47.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18259
+ const reason = resumed.status === import_core48.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18226
18260
  const outcome2 = await this.settleEndedRecovery(input, reason);
18227
18261
  settlement.resolve(outcome2);
18228
18262
  return outcome2;
@@ -19292,7 +19326,7 @@ function withErrors(handler) {
19292
19326
  if (error instanceof HttpTaskError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19293
19327
  if (error instanceof TaskCommandError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19294
19328
  if (error instanceof ProjectCollaborationError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19295
- if (error instanceof import_core48.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19329
+ if (error instanceof import_core49.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19296
19330
  if (error instanceof ProjectTaskThreadError) return reply.code(409).send({ success: false, code: error.code, error: error.message });
19297
19331
  request.log.error({ error }, "Task route failed");
19298
19332
  return reply.code(500).send({ success: false, code: "TASK_INTERNAL_ERROR", error: "Task operation failed" });
@@ -19369,7 +19403,7 @@ async function validateReferences(store2, task, parentId, dependencies) {
19369
19403
  }
19370
19404
  }
19371
19405
  function createTaskController(deps) {
19372
- const mutationMutex = deps.projectMutationMutex ?? import_core26.projectMutationMutex;
19406
+ const mutationMutex = deps.projectMutationMutex ?? import_core27.projectMutationMutex;
19373
19407
  const authorize = async (request, projectId, capability2) => deps.access.requireProjectAccess({
19374
19408
  tenantId: getTenantId17(request),
19375
19409
  userId: getUserId4(request),
@@ -19933,7 +19967,7 @@ var import_zod6 = require("zod");
19933
19967
  // src/services/agent-web-app/AgentWebAppRuntimeService.ts
19934
19968
  var import_node_crypto10 = require("crypto");
19935
19969
  var import_protocols14 = require("@axiom-lattice/protocols");
19936
- var import_core49 = require("@axiom-lattice/core");
19970
+ var import_core50 = require("@axiom-lattice/core");
19937
19971
  init_task_file_refs();
19938
19972
  function isRecord2(value) {
19939
19973
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -20104,12 +20138,12 @@ var AgentWebAppRuntimeService = class {
20104
20138
  const runtime = await this.resolveRuntime(webAppId, selection);
20105
20139
  await this.requireOwnedThread(runtime, userId, threadId);
20106
20140
  if (process.env.AXIOM_REPLICA_ID) {
20107
- const owner = await (0, import_core49.getThreadRunOwner)({
20141
+ const owner = await (0, import_core50.getThreadRunOwner)({
20108
20142
  tenantId: runtime.webApp.tenantId,
20109
20143
  assistantId: runtime.webApp.assistantId,
20110
20144
  threadId
20111
20145
  });
20112
- if (owner && owner !== (0, import_core49.getReplicaId)()) {
20146
+ if (owner && owner !== (0, import_core50.getReplicaId)()) {
20113
20147
  return {
20114
20148
  stream: (async function* () {
20115
20149
  yield (0, import_protocols14.buildAffinityMissChunk)(owner, threadId);
@@ -20462,7 +20496,7 @@ async function verifyWebAppToken(token, issuer, options = {}) {
20462
20496
 
20463
20497
  // src/routes/agent-web-app-runtime.ts
20464
20498
  var import_protocols15 = require("@axiom-lattice/protocols");
20465
- var import_core50 = require("@axiom-lattice/core");
20499
+ var import_core51 = require("@axiom-lattice/core");
20466
20500
  var idSchema = import_zod6.z.string().min(1).max(128);
20467
20501
  var paramsSchema = import_zod6.z.object({ webAppId: idSchema }).strict();
20468
20502
  var threadParamsSchema = import_zod6.z.object({ webAppId: idSchema, threadId: idSchema }).strict();
@@ -20896,7 +20930,7 @@ function registerAgentWebAppRuntimeRoutes(app2, deps) {
20896
20930
  if (!threadId) throw new AgentWebAppRuntimeError("INVALID_REQUEST", 400, "thread_id is required");
20897
20931
  const content = body.messages.map((message) => message.content).join("\n");
20898
20932
  const { messageId } = await deps.service.enqueueMessage(webAppId, identity.userId, threadId, content, { projectId: body.projectId, modelKey: body.modelKey });
20899
- reply.header(import_protocols15.REPLICA_HEADER, (0, import_core50.getReplicaId)());
20933
+ reply.header(import_protocols15.REPLICA_HEADER, (0, import_core51.getReplicaId)());
20900
20934
  for (const [name, value] of Object.entries((0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER]))) {
20901
20935
  reply.header(name, value);
20902
20936
  }
@@ -20982,7 +21016,7 @@ function beginSse(reply, request) {
20982
21016
  "X-Accel-Buffering": "no",
20983
21017
  "Access-Control-Allow-Origin": "*",
20984
21018
  "Access-Control-Expose-Headers": `${import_protocols15.REPLICA_HEADER}, ${import_protocols15.AFFINITY_ECHO_HEADER}`,
20985
- [import_protocols15.REPLICA_HEADER]: (0, import_core50.getReplicaId)(),
21019
+ [import_protocols15.REPLICA_HEADER]: (0, import_core51.getReplicaId)(),
20986
21020
  ...(0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER])
20987
21021
  });
20988
21022
  }
@@ -21219,7 +21253,7 @@ var import_zod9 = require("zod");
21219
21253
 
21220
21254
  // src/services/capability/CapabilityBundleService.ts
21221
21255
  var import_zod8 = require("zod");
21222
- var import_core51 = require("@axiom-lattice/core");
21256
+ var import_core52 = require("@axiom-lattice/core");
21223
21257
  var CapabilityBundleServiceError = class extends Error {
21224
21258
  constructor(code, message, statusCode) {
21225
21259
  super(message);
@@ -21260,7 +21294,7 @@ function projectBundleIds(config) {
21260
21294
  return [...value];
21261
21295
  }
21262
21296
  function issue(error) {
21263
- if (error instanceof import_core51.CapabilityBundleMergeError || error instanceof import_core51.CapabilityBundleValidationError) return { code: error instanceof import_core51.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core51.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
21297
+ if (error instanceof import_core52.CapabilityBundleMergeError || error instanceof import_core52.CapabilityBundleValidationError) return { code: error instanceof import_core52.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core52.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
21264
21298
  return { code: "CAPABILITY_BUNDLE_CONFIGURATION_ERROR", message: error instanceof Error ? error.message : "Invalid capability bundle configuration" };
21265
21299
  }
21266
21300
  var CapabilityBundleService = class {
@@ -21273,7 +21307,7 @@ var CapabilityBundleService = class {
21273
21307
  const errors = [];
21274
21308
  for (const value of values) {
21275
21309
  try {
21276
- (0, import_core51.validateCapabilityBundleInput)(value);
21310
+ (0, import_core52.validateCapabilityBundleInput)(value);
21277
21311
  bundles.push(value);
21278
21312
  } catch {
21279
21313
  errors.push({ bundleId: value.id, code: "INVALID_BUNDLE_CONFIG", message: "Capability bundle record is invalid" });
@@ -21285,7 +21319,7 @@ var CapabilityBundleService = class {
21285
21319
  const value = await this.deps.bundleStore.getById(tenantId, id3);
21286
21320
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21287
21321
  try {
21288
- (0, import_core51.validateCapabilityBundleInput)(value);
21322
+ (0, import_core52.validateCapabilityBundleInput)(value);
21289
21323
  } catch {
21290
21324
  throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "Capability bundle record is invalid", 422);
21291
21325
  }
@@ -21293,7 +21327,7 @@ var CapabilityBundleService = class {
21293
21327
  }
21294
21328
  async create(tenantId, input) {
21295
21329
  rejectStableKey(input);
21296
- (0, import_core51.validateCapabilityBundleInput)(input);
21330
+ (0, import_core52.validateCapabilityBundleInput)(input);
21297
21331
  const value = input;
21298
21332
  const name = value.name.trim();
21299
21333
  const base = slugify(name);
@@ -21304,10 +21338,10 @@ var CapabilityBundleService = class {
21304
21338
  let suffix = 2;
21305
21339
  while (keys2.has(key)) key = `${base}-${suffix++}`;
21306
21340
  const normalized = { ...value, key, name };
21307
- (0, import_core51.validateCapabilityBundleInput)(normalized);
21341
+ (0, import_core52.validateCapabilityBundleInput)(normalized);
21308
21342
  try {
21309
21343
  const result = await this.deps.bundleStore.create(tenantId, normalized);
21310
- (0, import_core51.validateCapabilityBundleInput)(result);
21344
+ (0, import_core52.validateCapabilityBundleInput)(result);
21311
21345
  return result;
21312
21346
  } catch (error) {
21313
21347
  if (!isDuplicate(error)) throw error;
@@ -21318,16 +21352,16 @@ var CapabilityBundleService = class {
21318
21352
  }
21319
21353
  async update(tenantId, id3, input) {
21320
21354
  rejectStableKey(input);
21321
- (0, import_core51.validateCapabilityBundleInput)(input, { partial: true });
21355
+ (0, import_core52.validateCapabilityBundleInput)(input, { partial: true });
21322
21356
  if (!input || typeof input !== "object" || Array.isArray(input) || typeof input.expectedUpdatedAt !== "string" || !input.expectedUpdatedAt.trim()) throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "expectedUpdatedAt is required for capability bundle updates", 400);
21323
21357
  const value = input;
21324
21358
  const normalized = { ...value, ...value.name === void 0 ? {} : { name: value.name.trim() }, ...Object.prototype.hasOwnProperty.call(value, "description") ? { description: value.description?.trim() || void 0 } : {} };
21325
- (0, import_core51.validateCapabilityBundleInput)(normalized, { partial: true });
21359
+ (0, import_core52.validateCapabilityBundleInput)(normalized, { partial: true });
21326
21360
  try {
21327
21361
  const result = await this.deps.bundleStore.update(tenantId, id3, normalized);
21328
21362
  if (!result) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21329
21363
  if ("status" in result && result.status === "conflict") throw new CapabilityBundleServiceError("BUNDLE_CONFLICT", "Capability bundle changed after it was loaded; reload before saving", 409);
21330
- (0, import_core51.validateCapabilityBundleInput)(result);
21364
+ (0, import_core52.validateCapabilityBundleInput)(result);
21331
21365
  return result;
21332
21366
  } catch (error) {
21333
21367
  if (error instanceof CapabilityBundleServiceError) throw error;
@@ -21362,8 +21396,8 @@ var CapabilityBundleService = class {
21362
21396
  if (missing.length > 0) return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: missing.map((id3) => ({ code: "BUNDLE_NOT_FOUND", message: `Persisted capability bundle '${id3}' is missing`, bundleId: id3 })), revision: "" };
21363
21397
  try {
21364
21398
  const ordered = ids.map((id3) => byId.get(id3));
21365
- ordered.forEach((bundle) => (0, import_core51.validateCapabilityBundleInput)(bundle));
21366
- return (0, import_core51.mergeCapabilityBundles)(ordered);
21399
+ ordered.forEach((bundle) => (0, import_core52.validateCapabilityBundleInput)(bundle));
21400
+ return (0, import_core52.mergeCapabilityBundles)(ordered);
21367
21401
  } catch (error) {
21368
21402
  return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21369
21403
  }
@@ -21396,7 +21430,7 @@ var CapabilityBundleService = class {
21396
21430
  return ids.map((id3) => {
21397
21431
  const value = byId.get(id3);
21398
21432
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21399
- (0, import_core51.validateCapabilityBundleInput)(value);
21433
+ (0, import_core52.validateCapabilityBundleInput)(value);
21400
21434
  return value;
21401
21435
  });
21402
21436
  }
@@ -21411,7 +21445,7 @@ var CapabilityBundleService = class {
21411
21445
  continue;
21412
21446
  }
21413
21447
  try {
21414
- (0, import_core51.validateCapabilityBundleInput)(bundle);
21448
+ (0, import_core52.validateCapabilityBundleInput)(bundle);
21415
21449
  valid.push(bundle);
21416
21450
  } catch (error) {
21417
21451
  errors.push({ ...issue(error), bundleId: id3 });
@@ -21419,7 +21453,7 @@ var CapabilityBundleService = class {
21419
21453
  }
21420
21454
  let preview;
21421
21455
  try {
21422
- preview = (0, import_core51.mergeCapabilityBundles)(valid);
21456
+ preview = (0, import_core52.mergeCapabilityBundles)(valid);
21423
21457
  } catch (error) {
21424
21458
  preview = { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21425
21459
  }
@@ -21571,7 +21605,7 @@ var import_zod11 = require("zod");
21571
21605
  // src/services/model-provider/ModelProviderService.ts
21572
21606
  var import_node_crypto14 = require("crypto");
21573
21607
  var import_protocols16 = require("@axiom-lattice/protocols");
21574
- var import_core52 = require("@axiom-lattice/core");
21608
+ var import_core53 = require("@axiom-lattice/core");
21575
21609
 
21576
21610
  // src/services/model-provider/errors.ts
21577
21611
  var ModelProviderServiceError = class extends Error {
@@ -22327,9 +22361,9 @@ var ModelProviderService = class {
22327
22361
  */
22328
22362
  buildLlmConfig(provider, model) {
22329
22363
  try {
22330
- return (0, import_core52.buildModelLlmConfig)(provider, model);
22364
+ return (0, import_core53.buildModelLlmConfig)(provider, model);
22331
22365
  } catch (error) {
22332
- if (error instanceof import_core52.UnsupportedModelProviderError) {
22366
+ if (error instanceof import_core53.UnsupportedModelProviderError) {
22333
22367
  throw new ModelProviderServiceError(
22334
22368
  "UNSUPPORTED_PROTOCOL",
22335
22369
  400,
@@ -22458,9 +22492,9 @@ var ModelProviderService = class {
22458
22492
  */
22459
22493
  async assertSafeUrl(baseURL) {
22460
22494
  try {
22461
- await (0, import_core52.assertSafeUpstreamUrl)(baseURL);
22495
+ await (0, import_core53.assertSafeUpstreamUrl)(baseURL);
22462
22496
  } catch (error) {
22463
- if (error instanceof import_core52.UnsafeUpstreamUrlError) {
22497
+ if (error instanceof import_core53.UnsafeUpstreamUrlError) {
22464
22498
  throw new ModelProviderServiceError(
22465
22499
  unsafeReasonToErrorCode[error.reason],
22466
22500
  400,
@@ -22930,7 +22964,7 @@ var ProjectMembershipService = class {
22930
22964
  constructor(deps) {
22931
22965
  this.deps = deps;
22932
22966
  this.idFactory = deps.idFactory ?? import_node_crypto16.randomUUID;
22933
- this.mutationMutex = deps.projectMutationMutex ?? import_core26.projectMutationMutex;
22967
+ this.mutationMutex = deps.projectMutationMutex ?? import_core27.projectMutationMutex;
22934
22968
  }
22935
22969
  async list(actor3) {
22936
22970
  await this.deps.accessService.requireRosterAccess(actor3);
@@ -23083,7 +23117,7 @@ var ProjectRosterService = class {
23083
23117
  constructor(deps) {
23084
23118
  this.deps = deps;
23085
23119
  this.idFactory = deps.idFactory ?? import_node_crypto17.randomUUID;
23086
- this.mutationMutex = deps.projectMutationMutex ?? import_core26.projectMutationMutex;
23120
+ this.mutationMutex = deps.projectMutationMutex ?? import_core27.projectMutationMutex;
23087
23121
  }
23088
23122
  /**
23089
23123
  * Lists the bot members visible to a project reader.
@@ -24256,7 +24290,7 @@ async function execute(reply, operation) {
24256
24290
  // src/routes/cospace.ts
24257
24291
  var import_node_crypto20 = require("crypto");
24258
24292
  var import_zod15 = require("zod");
24259
- var import_core53 = require("@axiom-lattice/core");
24293
+ var import_core54 = require("@axiom-lattice/core");
24260
24294
  var import_protocols19 = require("@axiom-lattice/protocols");
24261
24295
  var CoSpaceAuthError = class extends Error {
24262
24296
  constructor() {
@@ -24441,14 +24475,14 @@ function registerCoSpaceRoutes(app2, deps) {
24441
24475
  }
24442
24476
  let projectId;
24443
24477
  if (body.type === "human") {
24444
- projectId = (0, import_core53.generateDirectHumanProjectId)(
24478
+ projectId = (0, import_core54.generateDirectHumanProjectId)(
24445
24479
  actor3.tenantId,
24446
24480
  params.workspaceId,
24447
24481
  actor3.userId,
24448
24482
  body.targetUserId
24449
24483
  );
24450
24484
  } else {
24451
- projectId = (0, import_core53.generateDirectBotProjectId)(
24485
+ projectId = (0, import_core54.generateDirectBotProjectId)(
24452
24486
  actor3.tenantId,
24453
24487
  params.workspaceId,
24454
24488
  actor3.userId,
@@ -24655,7 +24689,7 @@ function registerCoSpaceRoutes(app2, deps) {
24655
24689
  );
24656
24690
  const bots = [];
24657
24691
  for (const assistant of assistants) {
24658
- const directProjectId = (0, import_core53.generateDirectBotProjectId)(
24692
+ const directProjectId = (0, import_core54.generateDirectBotProjectId)(
24659
24693
  actor3.tenantId,
24660
24694
  params.workspaceId,
24661
24695
  actor3.userId,
@@ -24717,7 +24751,7 @@ function registerCoSpaceRoutes(app2, deps) {
24717
24751
  if (link.userId === actor3.userId) continue;
24718
24752
  const user = await deps.userStore.getUserById(link.userId);
24719
24753
  if (!user) continue;
24720
- const directProjectId = (0, import_core53.generateDirectHumanProjectId)(
24754
+ const directProjectId = (0, import_core54.generateDirectHumanProjectId)(
24721
24755
  actor3.tenantId,
24722
24756
  params.workspaceId,
24723
24757
  actor3.userId,
@@ -25546,7 +25580,7 @@ function createRoomMessageRetentionJob(input) {
25546
25580
 
25547
25581
  // src/services/collaboration/ProjectTaskExecutionMutex.ts
25548
25582
  var import_protocols22 = require("@axiom-lattice/protocols");
25549
- var import_core54 = require("@axiom-lattice/core");
25583
+ var import_core55 = require("@axiom-lattice/core");
25550
25584
  var MACHINE_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
25551
25585
  function machineKey(scope) {
25552
25586
  const snapshot = (0, import_protocols22.snapshotExactRecord)(scope, ["tenantId", "assistantId", "projectId"]);
@@ -25574,9 +25608,9 @@ var ProjectTaskExecutionMutex = class {
25574
25608
  const leaseKey = `project-task-machine:${encodeURIComponent(scope.tenantId)}:${encodeURIComponent(scope.assistantId)}:${encodeURIComponent(scope.projectId)}`;
25575
25609
  await this.acquire(key, signal);
25576
25610
  try {
25577
- const store2 = (0, import_core54.getCoordinationLeaseStore)();
25611
+ const store2 = (0, import_core55.getCoordinationLeaseStore)();
25578
25612
  if (!store2) return await operation();
25579
- return await (0, import_core54.withLease)(store2, leaseKey, (0, import_core54.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25613
+ return await (0, import_core55.withLease)(store2, leaseKey, (0, import_core55.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25580
25614
  } finally {
25581
25615
  this.release(key);
25582
25616
  }
@@ -25677,7 +25711,7 @@ var TaskInterruptCardProjector = class {
25677
25711
 
25678
25712
  // src/services/collaboration/ProjectTaskObserver.ts
25679
25713
  var import_node_crypto22 = require("crypto");
25680
- var import_core55 = require("@axiom-lattice/core");
25714
+ var import_core56 = require("@axiom-lattice/core");
25681
25715
  var import_protocols23 = require("@axiom-lattice/protocols");
25682
25716
 
25683
25717
  // src/services/collaboration/projectTaskDispatchMarker.ts
@@ -25714,7 +25748,7 @@ var ProjectTaskObserver = class {
25714
25748
  throw new Error(`Invalid Project task observer bound: ${name}`);
25715
25749
  }
25716
25750
  }
25717
- this.runBridge = (0, import_core55.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25751
+ this.runBridge = (0, import_core56.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25718
25752
  }
25719
25753
  /** Fire-and-forget notifier adapter that never waits for observer work or machine acquisition. */
25720
25754
  async listener(event) {
@@ -26930,7 +26964,7 @@ function isRecord3(value) {
26930
26964
  init_projectTaskScope();
26931
26965
 
26932
26966
  // src/services/collaboration/ProjectRoomRealtimeRuntime.ts
26933
- var import_core56 = require("@axiom-lattice/core");
26967
+ var import_core57 = require("@axiom-lattice/core");
26934
26968
 
26935
26969
  // src/services/collaboration/ProjectRoomEventBroker.ts
26936
26970
  var import_node_crypto24 = require("crypto");
@@ -27705,7 +27739,7 @@ function createProjectRoomRealtimeRuntime(deps) {
27705
27739
  broker,
27706
27740
  publisher,
27707
27741
  subscriber,
27708
- subscribe: (listener) => import_core56.taskLifecycleNotifier.subscribe(listener),
27742
+ subscribe: (listener) => import_core57.taskLifecycleNotifier.subscribe(listener),
27709
27743
  log: deps.log,
27710
27744
  shutdownTimeoutMs: deps.shutdownTimeoutMs
27711
27745
  });
@@ -28442,35 +28476,35 @@ function hookErrorMessage(error) {
28442
28476
  function wrapReassignmentThreadError(error) {
28443
28477
  if (error instanceof ProjectTaskThreadError) {
28444
28478
  if (error.code === "PROJECT_TASK_THREAD_SCOPE_INVALID") {
28445
- return new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
28479
+ return new import_core58.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
28446
28480
  hint: "Project task, room, or roster scope changed; re-read the task and retry."
28447
28481
  });
28448
28482
  }
28449
28483
  if (error.code === "PROJECT_TASK_THREAD_OWNER_INVALID") {
28450
- return new import_core57.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
28484
+ return new import_core58.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
28451
28485
  hint: "The target already owns this task; re-read before dispatching."
28452
28486
  });
28453
28487
  }
28454
- return new import_core57.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
28488
+ return new import_core58.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
28455
28489
  hint: "Task Thread changed concurrently; re-read the task and retry."
28456
28490
  });
28457
28491
  }
28458
- return new import_core57.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
28492
+ return new import_core58.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
28459
28493
  hint: "Re-read the task and retry the dispatch."
28460
28494
  });
28461
28495
  }
28462
28496
  function wrapReassignmentAuthorizationError(error) {
28463
- if (error instanceof import_core57.ProjectTaskOwnerPolicyError) {
28497
+ if (error instanceof import_core58.ProjectTaskOwnerPolicyError) {
28464
28498
  if (error.code === "PROJECT_TASK_CALLER_INACTIVE") {
28465
- return new import_core57.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
28499
+ return new import_core58.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
28466
28500
  hint: "Dispatch from an active Project Room member bot."
28467
28501
  });
28468
28502
  }
28469
- return new import_core57.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
28503
+ return new import_core58.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
28470
28504
  hint: "Dispatch to an active bot in this Project's roster."
28471
28505
  });
28472
28506
  }
28473
- return new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
28507
+ return new import_core58.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
28474
28508
  hint: "Re-read the task and roster, then retry the dispatch."
28475
28509
  });
28476
28510
  }
@@ -28499,43 +28533,43 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28499
28533
  const agentId = options?.agentId;
28500
28534
  if (!agentId || agentId === task.ownerId) return void 0;
28501
28535
  if (!task.workspaceId || !task.projectId) {
28502
- throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
28536
+ throw new import_core58.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
28503
28537
  hint: "Dispatch governed tasks from a trusted Project run; ordinary tasks execute immediately."
28504
28538
  });
28505
28539
  }
28506
28540
  return deps.mutex.runExclusive({ tenantId: task.tenantId, projectId: task.projectId }, async () => {
28507
28541
  const current = await deps.tasks.getById(task.tenantId, task.id);
28508
28542
  if (!current || !isProjectLifecycleTask(current) || current.workspaceId !== task.workspaceId || current.projectId !== task.projectId) {
28509
- throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
28543
+ throw new import_core58.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
28510
28544
  hint: "Re-read the task and confirm it still belongs to this Project before dispatching."
28511
28545
  });
28512
28546
  }
28513
28547
  if (current.ownerType !== "agent") {
28514
- throw new import_core57.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
28548
+ throw new import_core58.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
28515
28549
  hint: "Assign the task to an Agent before dispatching."
28516
28550
  });
28517
28551
  }
28518
28552
  if (current.status !== "pending") {
28519
- throw new import_core57.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
28553
+ throw new import_core58.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
28520
28554
  hint: `This task is '${current.status}'. Resolve it or create a new task before dispatching.`
28521
28555
  });
28522
28556
  }
28523
28557
  if (agentId === current.ownerId) return current;
28524
28558
  const room = await deps.rooms.getMainRoom(current.tenantId, current.projectId);
28525
28559
  if (!room || room.tenantId !== current.tenantId || room.workspaceId !== current.workspaceId || room.projectId !== current.projectId || room.type !== "main") {
28526
- throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
28560
+ throw new import_core58.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
28527
28561
  hint: "Open or repair the Project Room before dispatching."
28528
28562
  });
28529
28563
  }
28530
28564
  const target = await deps.botMemberships.findByAssistant(current.tenantId, current.projectId, agentId);
28531
28565
  if (!target || target.status !== "active" || target.tenantId !== current.tenantId || target.workspaceId !== current.workspaceId || target.projectId !== current.projectId || target.assistantId !== agentId || target.roomId !== room.id) {
28532
- throw new import_core57.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
28566
+ throw new import_core58.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
28533
28567
  hint: "Dispatch to an active bot in this Project's roster."
28534
28568
  });
28535
28569
  }
28536
28570
  const caller = options?.callerMembershipId ? await deps.botMemberships.findById(current.tenantId, options.callerMembershipId) : null;
28537
28571
  if (!caller || !options?.callerAssistantId || caller.id !== options.callerMembershipId || caller.assistantId !== options.callerAssistantId || caller.status !== "active" || caller.tenantId !== current.tenantId || caller.workspaceId !== current.workspaceId || caller.projectId !== current.projectId || caller.roomId !== room.id) {
28538
- throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
28572
+ throw new import_core58.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
28539
28573
  hint: "Dispatch from an active Project Room member bot."
28540
28574
  });
28541
28575
  }
@@ -28570,7 +28604,7 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28570
28604
  actor: `agent:${caller.assistantId}`
28571
28605
  });
28572
28606
  if (!result.success) {
28573
- throw new import_core57.ManagedTaskStartError(result.code, result.error, {
28607
+ throw new import_core58.ManagedTaskStartError(result.code, result.error, {
28574
28608
  hint: result.hint ?? reassignmentFailureHint(result.code),
28575
28609
  ...result.retryable !== void 0 ? { retryable: result.retryable } : {}
28576
28610
  });
@@ -28581,25 +28615,25 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28581
28615
  function broadcastModelProviderChanged(tenantId, providerId2) {
28582
28616
  if (!tenantId) return;
28583
28617
  try {
28584
- const outbox = (0, import_core57.getStoreLattice)("default", "outbox").store;
28585
- void publishModelProviderChanged(outbox, (0, import_core57.getReplicaId)(), tenantId, providerId2);
28618
+ const outbox = (0, import_core58.getStoreLattice)("default", "outbox").store;
28619
+ void publishModelProviderChanged(outbox, (0, import_core58.getReplicaId)(), tenantId, providerId2);
28586
28620
  } catch {
28587
28621
  }
28588
28622
  }
28589
28623
  var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28590
- const webAppStore = (0, import_core57.getStoreLattice)("default", "agentWebApp").store;
28591
- const assistantStore = (0, import_core57.getStoreLattice)("default", "assistant").store;
28592
- const projectStore = (0, import_core57.getStoreLattice)("default", "project").store;
28593
- const projectMembershipStore = (0, import_core57.getStoreLattice)("default", "projectMembership").store;
28594
- const userTenantLinkStore = (0, import_core57.getStoreLattice)("default", "userTenantLink").store;
28595
- const projectRoomStore = (0, import_core57.getStoreLattice)("default", "projectRoom").store;
28596
- const projectBotMembershipStore = (0, import_core57.getStoreLattice)("default", "projectBotMembership").store;
28597
- const projectRoomMessageStore = (0, import_core57.getStoreLattice)("default", "projectRoomMessage").store;
28598
- const projectRoomReadStateStore = (0, import_core57.getStoreLattice)("default", "projectRoomReadState").store;
28599
- const userPushSubscriptionStore = (0, import_core57.getStoreLattice)("default", "userPushSubscription").store;
28600
- const threadStore = (0, import_core57.getStoreLattice)("default", "thread").store;
28601
- const taskStore = (0, import_core57.getStoreLattice)("default", "task").store;
28602
- const taskWorkItemStore = (0, import_core57.getStoreLattice)("default", "taskWorkItem").store;
28624
+ const webAppStore = (0, import_core58.getStoreLattice)("default", "agentWebApp").store;
28625
+ const assistantStore = (0, import_core58.getStoreLattice)("default", "assistant").store;
28626
+ const projectStore = (0, import_core58.getStoreLattice)("default", "project").store;
28627
+ const projectMembershipStore = (0, import_core58.getStoreLattice)("default", "projectMembership").store;
28628
+ const userTenantLinkStore = (0, import_core58.getStoreLattice)("default", "userTenantLink").store;
28629
+ const projectRoomStore = (0, import_core58.getStoreLattice)("default", "projectRoom").store;
28630
+ const projectBotMembershipStore = (0, import_core58.getStoreLattice)("default", "projectBotMembership").store;
28631
+ const projectRoomMessageStore = (0, import_core58.getStoreLattice)("default", "projectRoomMessage").store;
28632
+ const projectRoomReadStateStore = (0, import_core58.getStoreLattice)("default", "projectRoomReadState").store;
28633
+ const userPushSubscriptionStore = (0, import_core58.getStoreLattice)("default", "userPushSubscription").store;
28634
+ const threadStore = (0, import_core58.getStoreLattice)("default", "thread").store;
28635
+ const taskStore = (0, import_core58.getStoreLattice)("default", "task").store;
28636
+ const taskWorkItemStore = (0, import_core58.getStoreLattice)("default", "taskWorkItem").store;
28603
28637
  const projectTaskEnabled = options.projectTaskEnabled ?? process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false";
28604
28638
  const accessService = new ProjectAccessService({ projectStore, membershipStore: projectMembershipStore, userTenantLinkStore });
28605
28639
  const realtimeMode = resolveProjectRoomRealtimeMode();
@@ -28665,7 +28699,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28665
28699
  updateAssistant: assistantStore.updateAssistant.bind(assistantStore)
28666
28700
  });
28667
28701
  const resolveCoordinatorMentionName = async (tenantId) => {
28668
- const tenant2 = await (0, import_core57.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28702
+ const tenant2 = await (0, import_core58.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28669
28703
  const value = tenant2?.metadata?.coordinatorMentionName;
28670
28704
  return typeof value === "string" && value.length > 0 ? value : void 0;
28671
28705
  };
@@ -28683,7 +28717,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28683
28717
  ensureCoordinator: (scope) => coordinatorEnsurer.ensure(scope),
28684
28718
  log: realtimeLog
28685
28719
  });
28686
- const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core57.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
28720
+ const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core58.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
28687
28721
  const rosterService = new ProjectRosterService({
28688
28722
  accessService,
28689
28723
  roomService,
@@ -28695,7 +28729,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28695
28729
  assistantStore,
28696
28730
  taskStore,
28697
28731
  bindingLifecycle,
28698
- projectMutationMutex: import_core57.projectMutationMutex,
28732
+ projectMutationMutex: import_core58.projectMutationMutex,
28699
28733
  realtime,
28700
28734
  onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:roster-realtime-failed", { code, membershipId }) : void 0
28701
28735
  });
@@ -28770,9 +28804,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28770
28804
  }
28771
28805
  if (projectTaskComposition) app2.addHook("onClose", async () => projectTaskComposition.lease.release());
28772
28806
  const taskThreadService = projectTaskComposition?.lease.runtime.threads ?? new ProjectTaskThreadService({ threads: threadStore, idFactory: import_node_crypto26.randomUUID });
28773
- const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core57.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28774
- const reassignmentAuthorizer = (0, import_core57.createProjectTaskReassignmentAuthorizer)(
28775
- new import_core57.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28807
+ const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core58.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28808
+ const reassignmentAuthorizer = (0, import_core58.createProjectTaskReassignmentAuthorizer)(
28809
+ new import_core58.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28776
28810
  (input) => validateReassignmentThread(threadStore, input)
28777
28811
  );
28778
28812
  const taskCommandService = new TaskCommandService({
@@ -28781,7 +28815,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28781
28815
  lifecycle: taskLifecycle,
28782
28816
  execution: projectTaskComposition?.lease.runtime.execution,
28783
28817
  threads: taskThreadService,
28784
- agents: { getAgent: (params) => import_core57.agentInstanceManager.getAgent(params) },
28818
+ agents: { getAgent: (params) => import_core58.agentInstanceManager.getAgent(params) },
28785
28819
  taskScope: (task) => resolveCommandTaskScope(task, {
28786
28820
  rooms: projectRoomStore,
28787
28821
  bots: projectBotMembershipStore,
@@ -28798,7 +28832,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28798
28832
  return membership !== null && membership.projectId === projectId ? membership : null;
28799
28833
  },
28800
28834
  getThreadStatus: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28801
- const agent = import_core57.agentInstanceManager.getAgent({
28835
+ const agent = import_core58.agentInstanceManager.getAgent({
28802
28836
  tenant_id: tenantId,
28803
28837
  assistant_id: assistantId,
28804
28838
  thread_id: threadId,
@@ -28808,7 +28842,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28808
28842
  return String(await agent.getRunStatus());
28809
28843
  },
28810
28844
  getThreadState: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28811
- const agent = import_core57.agentInstanceManager.getAgent({
28845
+ const agent = import_core58.agentInstanceManager.getAgent({
28812
28846
  tenant_id: tenantId,
28813
28847
  assistant_id: assistantId,
28814
28848
  thread_id: threadId,
@@ -28817,7 +28851,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28817
28851
  });
28818
28852
  return agent.getCurrentState();
28819
28853
  },
28820
- dispatcher: (0, import_core57.createTrustedAgentMessageDispatcher)((scope) => import_core57.agentInstanceManager.getAgent(scope)),
28854
+ dispatcher: (0, import_core58.createTrustedAgentMessageDispatcher)((scope) => import_core58.agentInstanceManager.getAgent(scope)),
28821
28855
  projects: projectStore,
28822
28856
  tasks: taskStore,
28823
28857
  execution: projectTaskComposition?.lease.runtime.execution
@@ -28852,7 +28886,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28852
28886
  readStateService,
28853
28887
  interruptService: roomInterruptService,
28854
28888
  userDirectory: {
28855
- getUserById: (id3) => (0, import_core57.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28889
+ getUserById: (id3) => (0, import_core58.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28856
28890
  }
28857
28891
  });
28858
28892
  registerProjectRosterRoutes(app2, { service: rosterService });
@@ -28863,7 +28897,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28863
28897
  createProject: projectStore.createProject.bind(projectStore)
28864
28898
  },
28865
28899
  workspaceStore: {
28866
- getWorkspaceById: (tenantId, id3) => (0, import_core57.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28900
+ getWorkspaceById: (tenantId, id3) => (0, import_core58.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28867
28901
  },
28868
28902
  membershipStore: {
28869
28903
  list: projectMembershipStore.list.bind(projectMembershipStore),
@@ -28886,7 +28920,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28886
28920
  getUsersByTenant: userTenantLinkStore.getUsersByTenant.bind(userTenantLinkStore)
28887
28921
  },
28888
28922
  userStore: {
28889
- getUserById: (id3) => (0, import_core57.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28923
+ getUserById: (id3) => (0, import_core58.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28890
28924
  },
28891
28925
  assistantStore: {
28892
28926
  getAssistantById: assistantStore.getAssistantById.bind(assistantStore),
@@ -28908,26 +28942,26 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28908
28942
  }
28909
28943
  });
28910
28944
  registerCapabilityBundleRoutes(app2, new CapabilityBundleController({
28911
- bundleStore: (0, import_core57.getStoreLattice)("default", "capabilityBundle").store,
28945
+ bundleStore: (0, import_core58.getStoreLattice)("default", "capabilityBundle").store,
28912
28946
  projectStore
28913
28947
  }, { authRequired: process.env.AUTH_REQUIRED === "true" }));
28914
28948
  const modelProviderController = new ModelProviderController({
28915
- providerStore: (0, import_core57.getStoreLattice)("default", "modelProvider").store,
28949
+ providerStore: (0, import_core58.getStoreLattice)("default", "modelProvider").store,
28916
28950
  userTenantLinkStore,
28917
28951
  registry: {
28918
- register: (tenantId, modelKey2, config) => import_core57.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28919
- has: (tenantId, modelKey2) => import_core57.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28920
- remove: (tenantId, modelKey2) => import_core57.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28952
+ register: (tenantId, modelKey2, config) => import_core58.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28953
+ has: (tenantId, modelKey2) => import_core58.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28954
+ remove: (tenantId, modelKey2) => import_core58.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28921
28955
  listRegistered: (tenantId) => (
28922
28956
  // The config comes along so the catalog can name these rows: a bare
28923
28957
  // registry key is not something to offer a user. Same call the legacy
28924
28958
  // `GET /api/models` made.
28925
- import_core57.modelLatticeManager.getAllLatticesByTenant(tenantId).map((lattice) => ({
28959
+ import_core58.modelLatticeManager.getAllLatticesByTenant(tenantId).map((lattice) => ({
28926
28960
  modelKey: lattice.key,
28927
28961
  config: lattice.client.getConfig()
28928
28962
  }))
28929
28963
  ),
28930
- forgetTenantDefaultMiss: (tenantId) => import_core57.modelLatticeManager.forgetTenantDefaultMiss(tenantId)
28964
+ forgetTenantDefaultMiss: (tenantId) => import_core58.modelLatticeManager.forgetTenantDefaultMiss(tenantId)
28931
28965
  },
28932
28966
  onChanged: (tenantId, providerId2) => broadcastModelProviderChanged(tenantId, providerId2)
28933
28967
  }, { authRequired: process.env.AUTH_REQUIRED === "true" });
@@ -28939,11 +28973,11 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28939
28973
  assistantStore,
28940
28974
  projectStore,
28941
28975
  modelRegistry: {
28942
- has: (tenantId, key) => (0, import_core57.hasModelLatticeForTenant)(tenantId, key)
28976
+ has: (tenantId, key) => (0, import_core58.hasModelLatticeForTenant)(tenantId, key)
28943
28977
  },
28944
28978
  configuredAgentResolver: createConfiguredAgentResolver({
28945
- hydrate: (tenantId) => import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28946
- has: (tenantId, assistantId) => import_core57.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28979
+ hydrate: (tenantId) => import_core58.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28980
+ has: (tenantId, assistantId) => import_core58.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28947
28981
  })
28948
28982
  })
28949
28983
  });
@@ -28980,28 +29014,28 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28980
29014
  },
28981
29015
  tasks: taskStore,
28982
29016
  workItems: taskWorkItemStore,
28983
- projectMutationMutex: import_core57.projectMutationMutex,
29017
+ projectMutationMutex: import_core58.projectMutationMutex,
28984
29018
  ...projectTaskComposition ? { commands: taskCommandService } : {}
28985
29019
  }),
28986
29020
  service: new AgentWebAppRuntimeService({
28987
29021
  webAppStore,
28988
- threadStore: (0, import_core57.getStoreLattice)("default", "thread").store,
29022
+ threadStore: (0, import_core58.getStoreLattice)("default", "thread").store,
28989
29023
  projectStore,
28990
29024
  assistantResolver: {
28991
29025
  resolve: async (tenantId, assistantId) => {
28992
29026
  const stored = await assistantStore.getAssistantById(tenantId, assistantId);
28993
29027
  if (stored) return { id: stored.id, name: stored.name, description: stored.description };
28994
- await import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
28995
- const config = import_core57.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
29028
+ await import_core58.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
29029
+ const config = import_core58.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
28996
29030
  return config ? { id: assistantId, name: config.name, description: config.description } : null;
28997
29031
  }
28998
29032
  },
28999
29033
  modelRegistry: {
29000
- has: (tenantId, key) => (0, import_core57.hasModelLatticeForTenant)(tenantId, key),
29001
- label: async (tenantId, key) => (await (0, import_core57.resolveModelLatticeForTenant)(tenantId, key))?.client.getConfig().displayName ?? key
29034
+ has: (tenantId, key) => (0, import_core58.hasModelLatticeForTenant)(tenantId, key),
29035
+ label: async (tenantId, key) => (await (0, import_core58.resolveModelLatticeForTenant)(tenantId, key))?.client.getConfig().displayName ?? key
29002
29036
  },
29003
29037
  messageReader: {
29004
- getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core57.agentInstanceManager.getAgentForRead({
29038
+ getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core58.agentInstanceManager.getAgentForRead({
29005
29039
  tenant_id: tenantId,
29006
29040
  assistant_id: assistantId,
29007
29041
  thread_id: threadId,
@@ -29010,7 +29044,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29010
29044
  }).getCurrentMessages()
29011
29045
  },
29012
29046
  agentResolver: {
29013
- getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core57.agentInstanceManager.getAgent({
29047
+ getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core58.agentInstanceManager.getAgent({
29014
29048
  tenant_id: tenantId,
29015
29049
  assistant_id: assistantId,
29016
29050
  thread_id: threadId,
@@ -29028,8 +29062,8 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29028
29062
  if (webApp.tenantId !== preview.tenantId) return false;
29029
29063
  const assistant = await assistantStore.getAssistantById(preview.tenantId, webApp.assistantId);
29030
29064
  if (assistant) return !assistant.ownerUserId || assistant.ownerUserId === preview.userId;
29031
- await import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
29032
- return import_core57.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
29065
+ await import_core58.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
29066
+ return import_core58.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
29033
29067
  }
29034
29068
  })
29035
29069
  });
@@ -29086,14 +29120,14 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29086
29120
  app2.post("/api/personal-assistant", createPersonalAssistant);
29087
29121
  app2.get("/api/personal-assistant", getPersonalAssistant);
29088
29122
  app2.delete("/api/personal-assistant", deletePersonalAssistant);
29089
- import_core57.executionAuthorityRegistry.register({
29123
+ import_core58.executionAuthorityRegistry.register({
29090
29124
  id: "project-lifecycle",
29091
29125
  matches: isProjectLifecycleTask,
29092
29126
  code: "PROJECT_TASK_EXECUTION_MANAGED",
29093
29127
  message: "Project tasks are executed by the durable Project queue runtime",
29094
29128
  onManagedStart: async (task, options2) => {
29095
29129
  if (!projectTaskComposition && options2?.agentId && options2.agentId !== task.ownerId) {
29096
- throw new import_core57.ManagedTaskStartError(
29130
+ throw new import_core58.ManagedTaskStartError(
29097
29131
  "PROJECT_TASK_RUNTIME_UNAVAILABLE",
29098
29132
  "Project task ownership transfer requires the Project task runtime.",
29099
29133
  { hint: "Project task execution is disabled; enable the Project task runtime or dispatch to the current owner." }
@@ -29106,7 +29140,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29106
29140
  threads: taskThreadService,
29107
29141
  reassignmentAuthorizer,
29108
29142
  lifecycle: taskLifecycle,
29109
- mutex: import_core57.projectMutationMutex
29143
+ mutex: import_core58.projectMutationMutex
29110
29144
  }) : void 0;
29111
29145
  const admitted = transferred ?? task;
29112
29146
  if (!admitted.workspaceId || !admitted.projectId) return;
@@ -29114,7 +29148,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29114
29148
  context: withExecutionRequest(admitted.context, (/* @__PURE__ */ new Date()).toISOString())
29115
29149
  }).catch(() => null);
29116
29150
  const eventTask = markerUpdated ?? admitted;
29117
- void import_core57.projectTaskAdmissionNotifier.publish({
29151
+ void import_core58.projectTaskAdmissionNotifier.publish({
29118
29152
  tenantId: eventTask.tenantId,
29119
29153
  workspaceId: eventTask.workspaceId,
29120
29154
  projectId: eventTask.projectId,
@@ -29128,7 +29162,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29128
29162
  access: accessService,
29129
29163
  tasks: taskStore,
29130
29164
  workItems: taskWorkItemStore,
29131
- projectMutationMutex: import_core57.projectMutationMutex,
29165
+ projectMutationMutex: import_core58.projectMutationMutex,
29132
29166
  commands: taskCommandService,
29133
29167
  readableProjects: async ({ tenantId, userId, workspaceId }) => {
29134
29168
  const projects = await projectStore.getProjectsByWorkspace(tenantId, workspaceId);
@@ -29375,10 +29409,6 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
29375
29409
  "/api/tenants/:tenantId/export/entities",
29376
29410
  previewEntities
29377
29411
  );
29378
- app2.get(
29379
- "/api/tenants/:tenantId/export/:jobId/download",
29380
- downloadExport
29381
- );
29382
29412
  app2.post(
29383
29413
  "/api/tenants/:tenantId/import/preview",
29384
29414
  importPreview
@@ -29411,9 +29441,9 @@ function tryCreateProjectTaskRuntime(input) {
29411
29441
  let stores;
29412
29442
  try {
29413
29443
  stores = {
29414
- tenants: (0, import_core57.getStoreLattice)("default", "tenant").store,
29415
- workspaces: (0, import_core57.getStoreLattice)("default", "workspace").store,
29416
- queue: (0, import_core57.getStoreLattice)("default", "threadMessageQueue").store
29444
+ tenants: (0, import_core58.getStoreLattice)("default", "tenant").store,
29445
+ workspaces: (0, import_core58.getStoreLattice)("default", "workspace").store,
29446
+ queue: (0, import_core58.getStoreLattice)("default", "threadMessageQueue").store
29417
29447
  };
29418
29448
  const missing = missingRuntimeMethod(input, stores);
29419
29449
  if (missing) return { reason: missing };
@@ -29445,7 +29475,7 @@ function createRuntime(input, stores, log2) {
29445
29475
  const controller = new AbortController();
29446
29476
  const mutex = new ProjectTaskExecutionMutex();
29447
29477
  const threads = new ProjectTaskThreadService({ threads: input.threadStore, idFactory: import_node_crypto26.randomUUID });
29448
- const lifecycle = (0, import_core57.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
29478
+ const lifecycle = (0, import_core58.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
29449
29479
  const projection = new RoomProjectionService({
29450
29480
  messages: input.projectRoomMessageStore,
29451
29481
  events: input.taskWorkItemStore,
@@ -29455,7 +29485,7 @@ function createRuntime(input, stores, log2) {
29455
29485
  realtime: input.realtime,
29456
29486
  idFactory: import_node_crypto26.randomUUID
29457
29487
  });
29458
- const agentFor = (task, thread) => import_core57.agentInstanceManager.getAgent({
29488
+ const agentFor = (task, thread) => import_core58.agentInstanceManager.getAgent({
29459
29489
  tenant_id: task.tenantId,
29460
29490
  assistant_id: task.ownerId,
29461
29491
  thread_id: thread.id,
@@ -29470,7 +29500,7 @@ function createRuntime(input, stores, log2) {
29470
29500
  bots: input.projectBotMembershipStore,
29471
29501
  threads,
29472
29502
  lifecycle,
29473
- dispatcher: (0, import_core57.createTrustedAgentMessageDispatcher)((scope) => import_core57.agentInstanceManager.getAgent(scope)),
29503
+ dispatcher: (0, import_core58.createTrustedAgentMessageDispatcher)((scope) => import_core58.agentInstanceManager.getAgent(scope)),
29474
29504
  queue: stores.queue,
29475
29505
  agentFor,
29476
29506
  ...input.ensurePublicOwner === void 0 ? {} : { ensurePublicOwner: input.ensurePublicOwner },
@@ -29501,8 +29531,8 @@ function createRuntime(input, stores, log2) {
29501
29531
  const taskLifecycleListener = ((event) => {
29502
29532
  void observer.listener(event);
29503
29533
  });
29504
- const unsubscribe = import_core57.taskLifecycleNotifier.subscribe(taskLifecycleListener);
29505
- const unsubscribeAdmission = import_core57.projectTaskAdmissionNotifier.subscribe((event, signal) => {
29534
+ const unsubscribe = import_core58.taskLifecycleNotifier.subscribe(taskLifecycleListener);
29535
+ const unsubscribeAdmission = import_core58.projectTaskAdmissionNotifier.subscribe((event, signal) => {
29506
29536
  observer.admit(event, signal);
29507
29537
  });
29508
29538
  let reconciliationWork;
@@ -29653,12 +29683,12 @@ function registerResourceRoutes(app2, controller) {
29653
29683
  }
29654
29684
 
29655
29685
  // src/export_registrations/index.ts
29656
- var import_core69 = require("@axiom-lattice/core");
29686
+ var import_core70 = require("@axiom-lattice/core");
29657
29687
 
29658
29688
  // src/export_registrations/skill.registration.ts
29659
- var import_core59 = require("@axiom-lattice/core");
29689
+ var import_core60 = require("@axiom-lattice/core");
29660
29690
  function getStore(context) {
29661
- return new import_core59.SandboxSkillStore({
29691
+ return new import_core60.SandboxSkillStore({
29662
29692
  workspaceId: context?.workspaceId,
29663
29693
  projectId: context?.projectId
29664
29694
  });
@@ -29676,7 +29706,7 @@ var skillRegistration = {
29676
29706
  async listForExport(tenantId, context) {
29677
29707
  const store2 = getStore(context);
29678
29708
  const skills = await store2.getAllSkills(tenantId, toStoreContext(context));
29679
- return skills.filter((s) => !(0, import_core59.isBuiltInSkill)(s.id)).map((s) => ({
29709
+ return skills.filter((s) => !(0, import_core60.isBuiltInSkill)(s.id)).map((s) => ({
29680
29710
  _exportId: "",
29681
29711
  data: {
29682
29712
  id: s.id,
@@ -29741,7 +29771,7 @@ var skillRegistration = {
29741
29771
  const insertions = [];
29742
29772
  for (const entity of entities) {
29743
29773
  const id3 = entity.data.id;
29744
- if ((0, import_core59.isBuiltInSkill)(id3)) continue;
29774
+ if ((0, import_core60.isBuiltInSkill)(id3)) continue;
29745
29775
  if (existingIds.has(id3)) {
29746
29776
  conflicts.push({
29747
29777
  _exportId: entity._exportId,
@@ -29800,9 +29830,9 @@ var skillRegistration = {
29800
29830
  };
29801
29831
 
29802
29832
  // src/export_registrations/agent.registration.ts
29803
- var import_core60 = require("@axiom-lattice/core");
29833
+ var import_core61 = require("@axiom-lattice/core");
29804
29834
  function getStore2() {
29805
- return (0, import_core60.getStoreLattice)("default", "assistant").store;
29835
+ return (0, import_core61.getStoreLattice)("default", "assistant").store;
29806
29836
  }
29807
29837
  var agentRegistration = {
29808
29838
  entityType: "agent",
@@ -29882,9 +29912,9 @@ var agentRegistration = {
29882
29912
  };
29883
29913
 
29884
29914
  // src/export_registrations/database-config.registration.ts
29885
- var import_core61 = require("@axiom-lattice/core");
29915
+ var import_core62 = require("@axiom-lattice/core");
29886
29916
  function getStore3() {
29887
- return (0, import_core61.getStoreLattice)("default", "database").store;
29917
+ return (0, import_core62.getStoreLattice)("default", "database").store;
29888
29918
  }
29889
29919
  var databaseConfigRegistration = {
29890
29920
  entityType: "database_config",
@@ -29964,9 +29994,9 @@ var databaseConfigRegistration = {
29964
29994
  };
29965
29995
 
29966
29996
  // src/export_registrations/metrics-config.registration.ts
29967
- var import_core62 = require("@axiom-lattice/core");
29997
+ var import_core63 = require("@axiom-lattice/core");
29968
29998
  function getStore4() {
29969
- return (0, import_core62.getStoreLattice)("default", "metrics").store;
29999
+ return (0, import_core63.getStoreLattice)("default", "metrics").store;
29970
30000
  }
29971
30001
  var metricsConfigRegistration = {
29972
30002
  entityType: "metrics_config",
@@ -30046,9 +30076,9 @@ var metricsConfigRegistration = {
30046
30076
  };
30047
30077
 
30048
30078
  // src/export_registrations/mcp-config.registration.ts
30049
- var import_core63 = require("@axiom-lattice/core");
30079
+ var import_core64 = require("@axiom-lattice/core");
30050
30080
  function getStore5() {
30051
- return (0, import_core63.getStoreLattice)("default", "mcp").store;
30081
+ return (0, import_core64.getStoreLattice)("default", "mcp").store;
30052
30082
  }
30053
30083
  var mcpConfigRegistration = {
30054
30084
  entityType: "mcp_config",
@@ -30131,9 +30161,9 @@ var mcpConfigRegistration = {
30131
30161
  };
30132
30162
 
30133
30163
  // src/export_registrations/connection.registration.ts
30134
- var import_core64 = require("@axiom-lattice/core");
30164
+ var import_core65 = require("@axiom-lattice/core");
30135
30165
  function getStore6() {
30136
- return (0, import_core64.getStoreLattice)("default", "connection").store;
30166
+ return (0, import_core65.getStoreLattice)("default", "connection").store;
30137
30167
  }
30138
30168
  async function listAllConnections(tenantId) {
30139
30169
  const store2 = getStore6();
@@ -30218,9 +30248,9 @@ var connectionRegistration = {
30218
30248
  };
30219
30249
 
30220
30250
  // src/export_registrations/collection.registration.ts
30221
- var import_core65 = require("@axiom-lattice/core");
30251
+ var import_core66 = require("@axiom-lattice/core");
30222
30252
  function getStore7() {
30223
- return (0, import_core65.getStoreLattice)("default", "collection").store;
30253
+ return (0, import_core66.getStoreLattice)("default", "collection").store;
30224
30254
  }
30225
30255
  var collectionRegistration = {
30226
30256
  entityType: "collection",
@@ -30291,8 +30321,8 @@ var collectionRegistration = {
30291
30321
  };
30292
30322
 
30293
30323
  // src/export_registrations/channel-installation.registration.ts
30294
- var import_core66 = require("@axiom-lattice/core");
30295
- var import_crypto11 = require("crypto");
30324
+ var import_core67 = require("@axiom-lattice/core");
30325
+ var import_crypto10 = require("crypto");
30296
30326
  var UUID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
30297
30327
  var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat", "wecom"]);
30298
30328
  function isPublicChannel(channel) {
@@ -30328,7 +30358,7 @@ function validateImportData(data) {
30328
30358
  };
30329
30359
  }
30330
30360
  function getStore8() {
30331
- return (0, import_core66.getStoreLattice)("default", "channelInstallation").store;
30361
+ return (0, import_core67.getStoreLattice)("default", "channelInstallation").store;
30332
30362
  }
30333
30363
  function getOverwriteError(tenantId, incomingChannel, existing) {
30334
30364
  if (!existing) return "Channel installation overwrite target must exist";
@@ -30454,7 +30484,7 @@ var channelInstallationRegistration = {
30454
30484
  }
30455
30485
  id3 = sourceId;
30456
30486
  } else {
30457
- id3 = (0, import_crypto11.randomUUID)();
30487
+ id3 = (0, import_crypto10.randomUUID)();
30458
30488
  }
30459
30489
  await store2.createInstallation(tenantId, id3, createInput);
30460
30490
  return { newId: id3 };
@@ -30462,9 +30492,9 @@ var channelInstallationRegistration = {
30462
30492
  };
30463
30493
 
30464
30494
  // src/export_registrations/menu.registration.ts
30465
- var import_core67 = require("@axiom-lattice/core");
30495
+ var import_core68 = require("@axiom-lattice/core");
30466
30496
  function getStore9() {
30467
- return (0, import_core67.getStoreLattice)("default", "menu").store;
30497
+ return (0, import_core68.getStoreLattice)("default", "menu").store;
30468
30498
  }
30469
30499
  var menuRegistration = {
30470
30500
  entityType: "menu",
@@ -30542,9 +30572,9 @@ var menuRegistration = {
30542
30572
  };
30543
30573
 
30544
30574
  // src/export_registrations/eval.registration.ts
30545
- var import_core68 = require("@axiom-lattice/core");
30575
+ var import_core69 = require("@axiom-lattice/core");
30546
30576
  function getStore10() {
30547
- return (0, import_core68.getStoreLattice)("default", "eval").store;
30577
+ return (0, import_core69.getStoreLattice)("default", "eval").store;
30548
30578
  }
30549
30579
  var evalRegistration = {
30550
30580
  entityType: "eval",
@@ -30870,7 +30900,7 @@ var evalRegistration = {
30870
30900
 
30871
30901
  // src/export_registrations/index.ts
30872
30902
  function registerAllBuiltinEntities() {
30873
- const registry = import_core69.ExportableEntityRegistry.getInstance();
30903
+ const registry = import_core70.ExportableEntityRegistry.getInstance();
30874
30904
  registry.register(skillRegistration);
30875
30905
  registry.register(agentRegistration);
30876
30906
  registry.register(databaseConfigRegistration);
@@ -31001,7 +31031,7 @@ function createAuditLoggerMiddleware() {
31001
31031
  }
31002
31032
 
31003
31033
  // src/index.ts
31004
- var import_core97 = require("@axiom-lattice/core");
31034
+ var import_core98 = require("@axiom-lattice/core");
31005
31035
 
31006
31036
  // src/channels/wecom/WecomChannelAdapter.ts
31007
31037
  var import_node_crypto27 = require("crypto");
@@ -31040,6 +31070,25 @@ var wecomConfigSchema = import_zod17.z.object({
31040
31070
  var RECONNECT_BASE_MS = 5e3;
31041
31071
  var RECONNECT_MAX_MS = 6e4;
31042
31072
  var activeConnections2 = /* @__PURE__ */ new Map();
31073
+ var streamIdsByReqId = /* @__PURE__ */ new Map();
31074
+ var MAX_TRACKED_STREAMS = 1e3;
31075
+ function streamKeyOf(replyTarget) {
31076
+ const frame = replyTarget.rawTarget.frame;
31077
+ return frame?.headers?.req_id ?? replyTarget.channelInstallationId;
31078
+ }
31079
+ function streamIdFor(replyTarget) {
31080
+ const key = streamKeyOf(replyTarget);
31081
+ let streamId = streamIdsByReqId.get(key);
31082
+ if (!streamId) {
31083
+ streamId = (0, import_node_crypto27.randomUUID)();
31084
+ streamIdsByReqId.set(key, streamId);
31085
+ if (streamIdsByReqId.size > MAX_TRACKED_STREAMS) {
31086
+ const oldest = streamIdsByReqId.keys().next().value;
31087
+ if (oldest !== void 0) streamIdsByReqId.delete(oldest);
31088
+ }
31089
+ }
31090
+ return streamId;
31091
+ }
31043
31092
  var wecomChannelAdapter = {
31044
31093
  channel: "wecom",
31045
31094
  configSchema: wecomConfigSchema,
@@ -31081,14 +31130,41 @@ var wecomChannelAdapter = {
31081
31130
  });
31082
31131
  return;
31083
31132
  }
31133
+ const key = streamKeyOf(replyTarget);
31084
31134
  connection.client.reply(replyTarget.rawTarget.frame, {
31085
31135
  msgtype: "stream",
31086
31136
  stream: {
31087
- id: (0, import_node_crypto27.randomUUID)(),
31137
+ id: streamIdFor(replyTarget),
31088
31138
  finish: true,
31089
31139
  content: message.text
31090
31140
  }
31091
31141
  });
31142
+ streamIdsByReqId.delete(key);
31143
+ },
31144
+ /**
31145
+ * 流式回复:同一入站消息复用同一个 `stream.id`,增量刷新内容。
31146
+ *
31147
+ * 微信的 `stream` 是"刷新语义"(`content` 为累计全文),所以 `text` 直接用
31148
+ * 调用方给的累计值即可。失败只记日志,不打断派发链路(最终由 `reply:ready`
31149
+ * 的那次 `done: true` 兜底)。
31150
+ */
31151
+ async sendStreamChunk(replyTarget, chunk, installation) {
31152
+ const connection = activeConnections2.get(installation.id);
31153
+ if (!connection) {
31154
+ logger6.warn("WeCom bot not connected, cannot stream reply", {
31155
+ installationId: installation.id
31156
+ });
31157
+ return;
31158
+ }
31159
+ connection.client.reply(replyTarget.rawTarget.frame, {
31160
+ msgtype: "stream",
31161
+ stream: {
31162
+ id: streamIdFor(replyTarget),
31163
+ finish: chunk.done,
31164
+ content: chunk.text
31165
+ }
31166
+ });
31167
+ if (chunk.done) streamIdsByReqId.delete(streamKeyOf(replyTarget));
31092
31168
  },
31093
31169
  resolveThreadId(message, binding) {
31094
31170
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
@@ -31258,7 +31334,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
31258
31334
 
31259
31335
  // src/services/agent_task_consumer.ts
31260
31336
  var import_node_crypto28 = require("crypto");
31261
- var import_core70 = require("@axiom-lattice/core");
31337
+ var import_core71 = require("@axiom-lattice/core");
31262
31338
  var import_protocols32 = require("@axiom-lattice/protocols");
31263
31339
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
31264
31340
  const {
@@ -31278,7 +31354,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
31278
31354
  `\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
31279
31355
  );
31280
31356
  const scope = (0, import_protocols32.resolveRunScope)(runConfig);
31281
- const agent = import_core70.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
31357
+ const agent = import_core71.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
31282
31358
  if (callback_event) {
31283
31359
  const callbackEvent = callback_event;
31284
31360
  const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto28.randomUUID)();
@@ -31299,13 +31375,13 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
31299
31375
  const onCompleted = (evt) => {
31300
31376
  if (!belongsToMessage(evt)) return;
31301
31377
  settle(() => {
31302
- import_core70.eventBus.publish(callbackEvent, {
31378
+ import_core71.eventBus.publish(callbackEvent, {
31303
31379
  success: true,
31304
31380
  state: evt.state
31305
31381
  });
31306
31382
  if (main_thread_id && main_tenant_id) {
31307
31383
  try {
31308
- const mainAgent = import_core70.agentInstanceManager.getAgent({
31384
+ const mainAgent = import_core71.agentInstanceManager.getAgent({
31309
31385
  assistant_id: main_assistant_id ?? assistant_id,
31310
31386
  thread_id: main_thread_id,
31311
31387
  tenant_id: main_tenant_id,
@@ -31338,7 +31414,7 @@ ${summary}`
31338
31414
  const onInterrupted = (evt) => {
31339
31415
  if (!belongsToMessage(evt)) return;
31340
31416
  settle(() => {
31341
- import_core70.eventBus.publish(callbackEvent, {
31417
+ import_core71.eventBus.publish(callbackEvent, {
31342
31418
  success: true,
31343
31419
  state: evt.state
31344
31420
  });
@@ -31347,7 +31423,7 @@ ${summary}`
31347
31423
  const onFailed = (evt) => {
31348
31424
  if (!belongsToMessage(evt)) return;
31349
31425
  settle(() => {
31350
- import_core70.eventBus.publish(callbackEvent, {
31426
+ import_core71.eventBus.publish(callbackEvent, {
31351
31427
  success: false,
31352
31428
  error: evt?.error instanceof Error ? evt.error.message : typeof evt?.error === "string" ? evt.error : "Agent execution failed"
31353
31429
  });
@@ -31362,13 +31438,13 @@ ${summary}`
31362
31438
  agent.subscribe("message:interrupted", onInterrupted);
31363
31439
  agent.subscribe("message:failed", onFailed);
31364
31440
  try {
31365
- await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core70.QueueMode.STEER);
31441
+ await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core71.QueueMode.STEER);
31366
31442
  } catch (error) {
31367
31443
  dispose();
31368
31444
  throw error;
31369
31445
  }
31370
31446
  } else {
31371
- await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core70.QueueMode.STEER);
31447
+ await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core71.QueueMode.STEER);
31372
31448
  }
31373
31449
  return true;
31374
31450
  } catch (error) {
@@ -31387,7 +31463,7 @@ ${summary}`
31387
31463
  return handleAgentTask(taskRequest, nextRetryCount);
31388
31464
  }
31389
31465
  if (callback_event) {
31390
- import_core70.eventBus.publish(callback_event, {
31466
+ import_core71.eventBus.publish(callback_event, {
31391
31467
  success: false,
31392
31468
  error: error instanceof Error ? error.message : String(error)
31393
31469
  });
@@ -31424,7 +31500,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
31424
31500
  * 初始化事件监听和队列轮询
31425
31501
  */
31426
31502
  initialize() {
31427
- import_core70.eventBus.subscribe(import_core70.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
31503
+ import_core71.eventBus.subscribe(import_core71.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
31428
31504
  this.startPollingQueue();
31429
31505
  console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
31430
31506
  }
@@ -31543,7 +31619,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
31543
31619
  handleAgentTask(taskRequest).catch((error) => {
31544
31620
  console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
31545
31621
  if (taskRequest.callback_event) {
31546
- import_core70.eventBus.publish(taskRequest.callback_event, {
31622
+ import_core71.eventBus.publish(taskRequest.callback_event, {
31547
31623
  success: false,
31548
31624
  error: error instanceof Error ? error.message : String(error)
31549
31625
  });
@@ -31592,15 +31668,15 @@ function createGracefulShutdown(options) {
31592
31668
  }
31593
31669
 
31594
31670
  // src/index.ts
31595
- var import_core98 = require("@axiom-lattice/core");
31671
+ var import_core99 = require("@axiom-lattice/core");
31596
31672
 
31597
31673
  // src/channels/ChannelInfrastructure.ts
31598
- var import_core72 = require("@axiom-lattice/core");
31674
+ var import_core73 = require("@axiom-lattice/core");
31599
31675
 
31600
31676
  // src/router/MessageRouter.ts
31601
- var import_core71 = require("@axiom-lattice/core");
31677
+ var import_core72 = require("@axiom-lattice/core");
31602
31678
  var import_protocols33 = require("@axiom-lattice/protocols");
31603
- var import_crypto12 = require("crypto");
31679
+ var import_crypto11 = require("crypto");
31604
31680
  var BindingNotFoundError = class extends Error {
31605
31681
  constructor(message) {
31606
31682
  super(message);
@@ -31613,6 +31689,15 @@ var ChannelInstallationNotFoundError = class extends Error {
31613
31689
  this.name = "ChannelInstallationNotFoundError";
31614
31690
  }
31615
31691
  };
31692
+ var DEFAULT_STREAM_PLACEHOLDER = "\u6B63\u5728\u5904\u7406\u2026";
31693
+ function streamPlaceholderFor(installation) {
31694
+ const config = installation?.config;
31695
+ if (config !== null && typeof config === "object" && !Array.isArray(config)) {
31696
+ const value = config.streamPlaceholder;
31697
+ if (typeof value === "string") return value;
31698
+ }
31699
+ return DEFAULT_STREAM_PLACEHOLDER;
31700
+ }
31616
31701
  var InvalidChannelInstallationError = class extends Error {
31617
31702
  constructor(message = "Channel installation is not valid for this message") {
31618
31703
  super(message);
@@ -31710,7 +31795,7 @@ function correlatedRoomReplyTarget(replyTarget, inputMessageId) {
31710
31795
  }
31711
31796
  };
31712
31797
  }
31713
- var MessageRouter = class {
31798
+ var _MessageRouter = class _MessageRouter {
31714
31799
  constructor(config) {
31715
31800
  this.replySubscriptions = /* @__PURE__ */ new Set();
31716
31801
  /** Recent answer-by-message resumes per presence thread (first answer wins). */
@@ -31884,7 +31969,7 @@ var MessageRouter = class {
31884
31969
  channel: message.channel,
31885
31970
  adapterChannel: adapter.channel
31886
31971
  }, "Thread resolved by adapter strategy");
31887
- const threadStore = (0, import_core71.getStoreLattice)("default", "thread").store;
31972
+ const threadStore = (0, import_core72.getStoreLattice)("default", "thread").store;
31888
31973
  try {
31889
31974
  await threadStore.createThread(
31890
31975
  tenantId,
@@ -31921,8 +32006,8 @@ var MessageRouter = class {
31921
32006
  }
31922
32007
  }
31923
32008
  if (!threadId) {
31924
- const threadStore = (0, import_core71.getStoreLattice)("default", "thread").store;
31925
- const newThreadId = (0, import_crypto12.randomUUID)();
32009
+ const threadStore = (0, import_core72.getStoreLattice)("default", "thread").store;
32010
+ const newThreadId = (0, import_crypto11.randomUUID)();
31926
32011
  console.log({
31927
32012
  event: "dispatch:thread:create",
31928
32013
  agentId,
@@ -31961,14 +32046,14 @@ var MessageRouter = class {
31961
32046
  senderId: message.sender.id,
31962
32047
  contentLength: message.content.text.length
31963
32048
  }, "Dispatching to agent");
31964
- const agent = import_core71.agentInstanceManager.getAgent({
32049
+ const agent = import_core72.agentInstanceManager.getAgent({
31965
32050
  tenant_id: tenantId,
31966
32051
  assistant_id: agentId,
31967
32052
  thread_id: threadId,
31968
32053
  workspace_id: binding?.workspaceId || "",
31969
32054
  project_id: binding?.projectId || ""
31970
32055
  });
31971
- const inputMessageId = (0, import_crypto12.randomUUID)();
32056
+ const inputMessageId = (0, import_crypto11.randomUUID)();
31972
32057
  const replyTarget = internalRoom ? correlatedRoomReplyTarget(message.replyTarget, inputMessageId) : message.replyTarget;
31973
32058
  const replyAdapter = replyTarget ? this.adapterRegistry.get(replyTarget.adapterChannel) : void 0;
31974
32059
  if (options.trustedMessageOptions && (!this.trustedDispatcher || !replyTarget || !replyAdapter)) {
@@ -32013,6 +32098,7 @@ var MessageRouter = class {
32013
32098
  },
32014
32099
  ...resumeCommand ? { command: resumeCommand } : {}
32015
32100
  };
32101
+ const streamState = { finished: false };
32016
32102
  let cleanupReplySubscription;
32017
32103
  if (replyTarget && replyAdapter) {
32018
32104
  let cleaned = false;
@@ -32023,10 +32109,11 @@ var MessageRouter = class {
32023
32109
  if (cleaned || !event.consumedInputMessageIds.includes(inputMessageId)) return;
32024
32110
  cleanup();
32025
32111
  if (event.inputMessageId !== inputMessageId) return;
32026
- void replyAdapter.sendReply(replyTarget, {
32112
+ const delivery = replyAdapter.sendStreamChunk ? streamState.finished ? void 0 : replyAdapter.sendStreamChunk(replyTarget, { text: event.outputText, done: true }, installation) : replyAdapter.sendReply(replyTarget, {
32027
32113
  text: event.outputText,
32028
32114
  metadata: { inputMessageId, outputMessageId: event.outputMessageId }
32029
- }, installation).catch((error) => console.error({ event: "dispatch:reply:failed", error }));
32115
+ }, installation);
32116
+ void delivery?.catch((error) => console.error({ event: "dispatch:reply:failed", error }));
32030
32117
  };
32031
32118
  const timer = setTimeout(() => {
32032
32119
  console.warn({
@@ -32088,6 +32175,16 @@ var MessageRouter = class {
32088
32175
  cleanupReplySubscription?.();
32089
32176
  throw error;
32090
32177
  }
32178
+ if (addResult && replyTarget && replyAdapter?.sendStreamChunk) {
32179
+ void this.streamAgentOutputToChannel({
32180
+ agent,
32181
+ adapter: replyAdapter,
32182
+ replyTarget,
32183
+ installation,
32184
+ inputMessageId,
32185
+ state: streamState
32186
+ });
32187
+ }
32091
32188
  console.log({
32092
32189
  event: "dispatch:complete",
32093
32190
  agentId,
@@ -32123,6 +32220,64 @@ var MessageRouter = class {
32123
32220
  };
32124
32221
  return dispatch(0);
32125
32222
  }
32223
+ /**
32224
+ * 消费 agent 的逐块输出,把**中途**内容推给支持流式的渠道适配器。
32225
+ *
32226
+ * @remarks
32227
+ * 纯加法、best-effort:不抛错,也**不发最终内容** —— 最终由
32228
+ * `reply:ready` → `sendStreamChunk({ done: true })` 收尾。未实现
32229
+ * `sendStreamChunk` 的适配器不会走到这里,行为完全不变。
32230
+ */
32231
+ async streamAgentOutputToChannel(input) {
32232
+ const { agent, adapter, replyTarget, installation, inputMessageId, state } = input;
32233
+ const send = adapter.sendStreamChunk;
32234
+ if (!send) return;
32235
+ let started = false;
32236
+ let accumulated = "";
32237
+ let lastSentText = "";
32238
+ let lastSentAt = 0;
32239
+ let sent = 0;
32240
+ const warn = (event, error) => console.warn({ event, inputMessageId, error: error instanceof Error ? error.message : String(error) });
32241
+ const push = (text, done) => send.call(adapter, replyTarget, { text, done }, installation).catch((error) => warn("dispatch:stream:failed", error));
32242
+ const placeholder = streamPlaceholderFor(installation);
32243
+ try {
32244
+ if (placeholder) await push(placeholder, false);
32245
+ const stream = agent.chunkStream(inputMessageId, []);
32246
+ for await (const chunk of stream) {
32247
+ if (!started) {
32248
+ if (chunk?.type === import_protocols33.MessageChunkTypes.HUMAN && chunk?.data?.id === inputMessageId) {
32249
+ started = true;
32250
+ }
32251
+ continue;
32252
+ }
32253
+ if (chunk?.type === import_protocols33.MessageChunkTypes.MESSAGE_COMPLETED || chunk?.type === import_protocols33.MessageChunkTypes.MESSAGE_FAILED || chunk?.type === import_protocols33.MessageChunkTypes.INTERRUPT) {
32254
+ if (chunk.type !== import_protocols33.MessageChunkTypes.MESSAGE_COMPLETED) {
32255
+ const text2 = accumulated || placeholder;
32256
+ if (text2) {
32257
+ await push(text2, true);
32258
+ state.finished = true;
32259
+ }
32260
+ }
32261
+ break;
32262
+ }
32263
+ if (chunk?.type !== import_protocols33.MessageChunkTypes.AI) continue;
32264
+ const text = typeof chunk.data?.content === "string" ? chunk.data.content : void 0;
32265
+ if (!text) continue;
32266
+ accumulated += text;
32267
+ if (accumulated === lastSentText) continue;
32268
+ const now = Date.now();
32269
+ if (sent >= _MessageRouter.MAX_STREAM_CHUNKS || now - lastSentAt < _MessageRouter.STREAM_CHUNK_INTERVAL_MS) {
32270
+ continue;
32271
+ }
32272
+ lastSentAt = now;
32273
+ lastSentText = accumulated;
32274
+ sent += 1;
32275
+ await push(accumulated, false);
32276
+ }
32277
+ } catch (error) {
32278
+ warn("dispatch:stream:error", error);
32279
+ }
32280
+ }
32126
32281
  /**
32127
32282
  * Projects a pending HITL interrupt into the room as an independent bot message.
32128
32283
  *
@@ -32146,6 +32301,10 @@ var MessageRouter = class {
32146
32301
  }
32147
32302
  }
32148
32303
  };
32304
+ /** 流式中途刷新的节流间隔与上限(微信单会话 30 条/分钟,留余量)。 */
32305
+ _MessageRouter.STREAM_CHUNK_INTERVAL_MS = 800;
32306
+ _MessageRouter.MAX_STREAM_CHUNKS = 60;
32307
+ var MessageRouter = _MessageRouter;
32149
32308
 
32150
32309
  // src/channels/room/RoomChannelAdapter.ts
32151
32310
  var import_zod18 = require("zod");
@@ -32247,7 +32406,7 @@ function createChannelInfrastructure(deps) {
32247
32406
  onMessageCommitted: deps.onMessageCommitted ?? (deps.realtime ? (message) => deps.realtime?.messageCreated(message) : void 0),
32248
32407
  onCallbackFailure: (event) => deps.warn("project-room:message-commit-callback-failed", event)
32249
32408
  };
32250
- deps.adapterRegistry.register(createRoomChannelAdapter(new import_core72.RoomAgentMessageService(writerDeps)));
32409
+ deps.adapterRegistry.register(createRoomChannelAdapter(new import_core73.RoomAgentMessageService(writerDeps)));
32251
32410
  } catch (error) {
32252
32411
  deps.warn("Room channel unavailable", { error: error instanceof Error ? error.message : String(error) });
32253
32412
  }
@@ -32268,11 +32427,11 @@ async function prepareProjectTaskRuntime(runtime, log2) {
32268
32427
  }
32269
32428
 
32270
32429
  // src/services/plugins/PluginDeploymentRuntimeStartup.ts
32271
- var import_core74 = require("@axiom-lattice/core");
32430
+ var import_core75 = require("@axiom-lattice/core");
32272
32431
 
32273
32432
  // src/services/plugins/PluginDeploymentService.ts
32274
32433
  var import_node_crypto30 = require("crypto");
32275
- var import_core73 = require("@axiom-lattice/core");
32434
+ var import_core74 = require("@axiom-lattice/core");
32276
32435
 
32277
32436
  // src/services/plugins/pluginDeploymentNaming.ts
32278
32437
  var import_node_crypto29 = require("crypto");
@@ -32290,7 +32449,7 @@ function pluginSandboxName(tenantId, pluginType) {
32290
32449
  }
32291
32450
 
32292
32451
  // src/services/plugins/PluginDeploymentService.ts
32293
- var PLUGIN_HOST_SERVER_PATH = `${import_core73.PLUGIN_HOST_DIR}/server.js`;
32452
+ var PLUGIN_HOST_SERVER_PATH = `${import_core74.PLUGIN_HOST_DIR}/server.js`;
32294
32453
  var DEFAULT_PLUGIN_IDLE_TIMEOUT_MS = 15 * 60 * 1e3;
32295
32454
  var DEFAULT_PLUGIN_HEALTH_TIMEOUT_MS = 3e4;
32296
32455
  var DEFAULT_PLUGIN_HEALTH_POLL_INTERVAL_MS = 500;
@@ -32329,7 +32488,7 @@ var PluginDeploymentService = class {
32329
32488
  this.catalog = deps.catalog;
32330
32489
  this.installPluginHost = deps.installPluginHost;
32331
32490
  this.lease = deps.lease;
32332
- this.registry = deps.registry ?? new import_core73.PluginDeploymentRuntimeRegistry({ now: deps.clock ?? Date.now });
32491
+ this.registry = deps.registry ?? new import_core74.PluginDeploymentRuntimeRegistry({ now: deps.clock ?? Date.now });
32333
32492
  this.now = deps.clock ?? Date.now;
32334
32493
  this.logger = deps.logger ?? { info: () => void 0 };
32335
32494
  this.limits = deps.limits ?? {};
@@ -33046,7 +33205,7 @@ function startPluginDeploymentRuntime(options) {
33046
33205
  );
33047
33206
  return { reconcile: Promise.resolve(), dispose: async () => void 0 };
33048
33207
  }
33049
- const register = options.register ?? ((service3) => (0, import_core74.setPluginDeploymentService)(service3));
33208
+ const register = options.register ?? ((service3) => (0, import_core75.setPluginDeploymentService)(service3));
33050
33209
  const setIntervalFn = options.setIntervalFn ?? setInterval;
33051
33210
  const clearIntervalFn = options.clearIntervalFn ?? clearInterval;
33052
33211
  const watchdogIntervalMs = options.watchdogIntervalMs ?? DEFAULT_PLUGIN_WATCHDOG_INTERVAL_MS;
@@ -33190,51 +33349,6 @@ function errorMessage5(error) {
33190
33349
  return error instanceof Error ? error.message : String(error);
33191
33350
  }
33192
33351
 
33193
- // src/services/multiReplicaReadiness.ts
33194
- var import_core75 = require("@axiom-lattice/core");
33195
- var SHARED_STORE_KINDS = [
33196
- "lease",
33197
- "outbox",
33198
- "threadMessageQueue",
33199
- "task",
33200
- "taskWorkItem",
33201
- "channelInstallation"
33202
- ];
33203
- function storeClassName(kind) {
33204
- try {
33205
- return (0, import_core75.getStoreLattice)("default", kind).store.constructor?.name;
33206
- } catch {
33207
- return void 0;
33208
- }
33209
- }
33210
- function warnMultiReplicaReadiness(logger9) {
33211
- if (typeof process.env.AXIOM_REPLICA_ID !== "string" || process.env.AXIOM_REPLICA_ID.trim() === "") return;
33212
- for (const kind of SHARED_STORE_KINDS) {
33213
- const name = storeClassName(kind);
33214
- if (name === void 0 || !name.startsWith("InMemory")) continue;
33215
- logger9.warn(`Multi-replica: store '${kind}' is ${name} (not shared); configure a shared store`, {
33216
- phase: "multi_replica_readiness",
33217
- store: kind
33218
- });
33219
- }
33220
- if (!process.env.AUTH_TOKEN_SECRET?.trim() && !process.env.JWT_SECRET?.trim()) {
33221
- logger9.warn(
33222
- "Multi-replica: AUTH_TOKEN_SECRET/JWT_SECRET unset; console sessions are signed per-process and will not verify across replicas",
33223
- { phase: "multi_replica_readiness", env: "AUTH_TOKEN_SECRET" }
33224
- );
33225
- }
33226
- if (!process.env.LATTICE_ENCRYPTION_KEY?.trim()) {
33227
- logger9.warn(
33228
- "Multi-replica: LATTICE_ENCRYPTION_KEY unset; stored credentials use the shared dev default and may not decrypt across differing keys",
33229
- { phase: "multi_replica_readiness", env: "LATTICE_ENCRYPTION_KEY" }
33230
- );
33231
- }
33232
- logger9.warn(
33233
- "Multi-replica: agent run SSE and resume_stream are process-local; route a thread's follow-up runs to the replica streaming it (sticky routing) or share the stream/queue state",
33234
- { phase: "multi_replica_readiness", feature: "agent-run-sse" }
33235
- );
33236
- }
33237
-
33238
33352
  // src/services/OutboxRetentionJob.ts
33239
33353
  var HOUR_MS = 60 * 60 * 1e3;
33240
33354
  var DEFAULT_INTERVAL_MS2 = 6 * HOUR_MS;
@@ -33374,15 +33488,15 @@ var DEFAULT_LOGGER_CONFIG = {
33374
33488
  var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
33375
33489
  var logger8 = loggerLattice.client;
33376
33490
  function initializeLogger(config) {
33377
- if (import_core98.loggerLatticeManager.hasLattice("default")) {
33378
- import_core98.loggerLatticeManager.removeLattice("default");
33491
+ if (import_core99.loggerLatticeManager.hasLattice("default")) {
33492
+ import_core99.loggerLatticeManager.removeLattice("default");
33379
33493
  }
33380
- (0, import_core98.registerLoggerLattice)("default", config);
33381
- return (0, import_core98.getLoggerLattice)("default");
33494
+ (0, import_core99.registerLoggerLattice)("default", config);
33495
+ return (0, import_core99.getLoggerLattice)("default");
33382
33496
  }
33383
33497
  var app = (0, import_fastify.default)({
33384
33498
  logger: false,
33385
- bodyLimit: Number(process.env.BODY_LIMIT) || 50 * 1024 * 1024,
33499
+ bodyLimit: Number(process.env.BODY_LIMIT) || 100 * 1024 * 1024,
33386
33500
  // Composite subagent thread IDs ({mainThread}____{assistant}-general-purpose_{toolCallId})
33387
33501
  // can exceed the 100-char default, which makes the router 404 before any
33388
33502
  // handler runs. Allow the longest IDs the conventions can produce.
@@ -33445,7 +33559,7 @@ app.register(import_cors.default, {
33445
33559
  app.register(import_sensible.default);
33446
33560
  app.register(import_multipart.default, {
33447
33561
  limits: {
33448
- fileSize: Number(process.env.BODY_LIMIT) || 50 * 1024 * 1024
33562
+ fileSize: Number(process.env.BODY_LIMIT) || 100 * 1024 * 1024
33449
33563
  }
33450
33564
  });
33451
33565
  app.register(import_websocket.default);
@@ -33476,7 +33590,7 @@ app.setErrorHandler((error, request, reply) => {
33476
33590
  var shutdownHandlersInstalled = false;
33477
33591
  function getConfiguredSandboxProvider() {
33478
33592
  const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
33479
- return (0, import_core98.createSandboxProvider)({
33593
+ return (0, import_core99.createSandboxProvider)({
33480
33594
  type: sandboxProviderType,
33481
33595
  remoteBaseURL: process.env.SANDBOX_BASE_URL,
33482
33596
  microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
@@ -33492,7 +33606,7 @@ function getConfiguredSandboxProvider() {
33492
33606
  }
33493
33607
  async function restoreMcpConnections() {
33494
33608
  try {
33495
- const storeLattice = (0, import_core98.getStoreLattice)("default", "mcp");
33609
+ const storeLattice = (0, import_core99.getStoreLattice)("default", "mcp");
33496
33610
  const store2 = storeLattice.store;
33497
33611
  if (!store2) {
33498
33612
  logger8.info("MCP store not configured, skipping connection restoration");
@@ -33505,8 +33619,8 @@ async function restoreMcpConnections() {
33505
33619
  logger8.info(`Restoring ${configs.length} MCP server connections...`);
33506
33620
  const deps = {
33507
33621
  store: store2,
33508
- manager: import_core98.mcpManager,
33509
- convertToConnection: import_core98.convertToConnection
33622
+ manager: import_core99.mcpManager,
33623
+ convertToConnection: import_core99.convertToConnection
33510
33624
  };
33511
33625
  const results = await Promise.allSettled(
33512
33626
  configs.map(
@@ -33547,9 +33661,9 @@ var start = async (config) => {
33547
33661
  let projectRoomRealtimeRuntime;
33548
33662
  if (projectRoomRealtimeMode === "single-gateway") {
33549
33663
  projectRoomRealtimeRuntime = createProjectRoomRealtimeRuntime({
33550
- tasks: (0, import_core98.getStoreLattice)("default", "task").store,
33551
- rooms: (0, import_core98.getStoreLattice)("default", "projectRoom").store,
33552
- memberships: (0, import_core98.getStoreLattice)("default", "projectBotMembership").store,
33664
+ tasks: (0, import_core99.getStoreLattice)("default", "task").store,
33665
+ rooms: (0, import_core99.getStoreLattice)("default", "projectRoom").store,
33666
+ memberships: (0, import_core99.getStoreLattice)("default", "projectBotMembership").store,
33553
33667
  log: { warn: (message, context) => logger8.warn(message, context) }
33554
33668
  });
33555
33669
  }
@@ -33562,8 +33676,8 @@ var start = async (config) => {
33562
33676
  try {
33563
33677
  const infrastructure = createChannelInfrastructure({
33564
33678
  adapterRegistry,
33565
- getStore: ((kind) => (0, import_core98.getStoreLattice)("default", kind).store),
33566
- trustedDispatcher: (0, import_core98.createTrustedAgentMessageDispatcher)((scope) => import_core98.agentInstanceManager.getAgent(scope)),
33679
+ getStore: ((kind) => (0, import_core99.getStoreLattice)("default", kind).store),
33680
+ trustedDispatcher: (0, import_core99.createTrustedAgentMessageDispatcher)((scope) => import_core99.agentInstanceManager.getAgent(scope)),
33567
33681
  middlewares: [
33568
33682
  createDeduplicationMiddleware(),
33569
33683
  createRateLimitMiddleware(),
@@ -33574,7 +33688,7 @@ var start = async (config) => {
33574
33688
  });
33575
33689
  const bindingStore = infrastructure.bindingRegistry;
33576
33690
  const installationStore = infrastructure.installationStore;
33577
- (0, import_core97.setBindingRegistry)(bindingStore);
33691
+ (0, import_core98.setBindingRegistry)(bindingStore);
33578
33692
  const router = infrastructure.router;
33579
33693
  app.addHook("onClose", async () => router.dispose());
33580
33694
  channelDeps = {
@@ -33590,10 +33704,10 @@ var start = async (config) => {
33590
33704
  error: err instanceof Error ? err.message : String(err)
33591
33705
  });
33592
33706
  }
33593
- (0, import_core97.setEvalRunService)(evalRunner);
33707
+ (0, import_core98.setEvalRunService)(evalRunner);
33594
33708
  try {
33595
- const menuStore = (0, import_core98.getStoreLattice)("default", "menu").store;
33596
- (0, import_core97.setMenuRegistry)(menuStore);
33709
+ const menuStore = (0, import_core99.getStoreLattice)("default", "menu").store;
33710
+ (0, import_core98.setMenuRegistry)(menuStore);
33597
33711
  logger8.info("Menu registry initialized");
33598
33712
  } catch {
33599
33713
  }
@@ -33610,10 +33724,10 @@ var start = async (config) => {
33610
33724
  const { A2AAuthService: A2AAuthService2, parseEnvKeys: parseEnvKeys2 } = await Promise.resolve().then(() => (init_A2AAuthService(), A2AAuthService_exports));
33611
33725
  const { registerA2AStandardRoutes: registerA2AStandardRoutes2 } = await Promise.resolve().then(() => (init_a2a_standard(), a2a_standard_exports));
33612
33726
  const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
33613
- const a2aKeyStore = (0, import_core98.getStoreLattice)("default", "a2aApiKey").store;
33614
- const assistantStore = (0, import_core98.getStoreLattice)("default", "assistant").store;
33615
- const projectStore = (0, import_core98.getStoreLattice)("default", "project").store;
33616
- const taskStore = (0, import_core98.getStoreLattice)("default", "task").store;
33727
+ const a2aKeyStore = (0, import_core99.getStoreLattice)("default", "a2aApiKey").store;
33728
+ const assistantStore = (0, import_core99.getStoreLattice)("default", "assistant").store;
33729
+ const projectStore = (0, import_core99.getStoreLattice)("default", "project").store;
33730
+ const taskStore = (0, import_core99.getStoreLattice)("default", "task").store;
33617
33731
  const authService = new A2AAuthService2({
33618
33732
  keyStore: a2aKeyStore,
33619
33733
  assistantStore,
@@ -33653,8 +33767,8 @@ var start = async (config) => {
33653
33767
  const { CollectionService: CollectionService2 } = await Promise.resolve().then(() => (init_collection_service(), collection_service_exports));
33654
33768
  openLattice2.register(createKbProvider2(new CollectionService2()));
33655
33769
  openLattice2.register(createOpenSandboxProvider2());
33656
- const threadStore = (0, import_core98.getStoreLattice)("default", "thread").store;
33657
- const assistantStore = (0, import_core98.getStoreLattice)("default", "assistant").store;
33770
+ const threadStore = (0, import_core99.getStoreLattice)("default", "thread").store;
33771
+ const assistantStore = (0, import_core99.getStoreLattice)("default", "assistant").store;
33658
33772
  openLattice2.register(
33659
33773
  createAgentProvider2({
33660
33774
  threadStore,
@@ -33699,15 +33813,15 @@ var start = async (config) => {
33699
33813
  error: err instanceof Error ? err.message : String(err)
33700
33814
  });
33701
33815
  }
33702
- if (!import_core98.sandboxLatticeManager.hasLattice("default")) {
33703
- import_core98.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
33816
+ if (!import_core99.sandboxLatticeManager.hasLattice("default")) {
33817
+ import_core99.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
33704
33818
  logger8.info("Registered sandbox manager from env configuration");
33705
33819
  }
33706
33820
  if (isPluginDeploymentRuntimeEnabled()) {
33707
33821
  try {
33708
- const pluginDeploymentStore = (0, import_core98.getStoreLattice)("default", "pluginDeployment").store;
33709
- const tenantStore = (0, import_core98.getStoreLattice)("default", "tenant").store;
33710
- const leaseStore2 = (0, import_core98.getStoreLattice)("default", "lease").store;
33822
+ const pluginDeploymentStore = (0, import_core99.getStoreLattice)("default", "pluginDeployment").store;
33823
+ const tenantStore = (0, import_core99.getStoreLattice)("default", "tenant").store;
33824
+ const leaseStore2 = (0, import_core99.getStoreLattice)("default", "lease").store;
33711
33825
  const listAllDeployments = async () => {
33712
33826
  const tenants = await tenantStore.getAllTenants();
33713
33827
  const lists = await Promise.all(
@@ -33720,9 +33834,9 @@ var start = async (config) => {
33720
33834
  const pluginDeploymentRuntime = startPluginDeploymentRuntime({
33721
33835
  wiring: {
33722
33836
  store: pluginDeploymentStore,
33723
- sandboxManager: (0, import_core98.getSandBoxManager)(),
33724
- catalog: (0, import_core98.getSandboxPluginCatalog)(),
33725
- installPluginHost: import_core98.installPluginHost,
33837
+ sandboxManager: (0, import_core99.getSandBoxManager)(),
33838
+ catalog: (0, import_core99.getSandboxPluginCatalog)(),
33839
+ installPluginHost: import_core99.installPluginHost,
33726
33840
  limits: readPluginDeploymentLimits(),
33727
33841
  serviceKey: process.env.MICROSANDBOX_API_KEY,
33728
33842
  listAllDeployments,
@@ -33734,7 +33848,7 @@ var start = async (config) => {
33734
33848
  }
33735
33849
  },
33736
33850
  lease: leaseStore2,
33737
- holder: (0, import_core98.getReplicaId)(),
33851
+ holder: (0, import_core99.getReplicaId)(),
33738
33852
  logger: logger8
33739
33853
  });
33740
33854
  app.addHook("onClose", async () => {
@@ -33749,11 +33863,11 @@ var start = async (config) => {
33749
33863
  }
33750
33864
  try {
33751
33865
  const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
33752
- const sharedResourceStore = (0, import_core98.getStoreLattice)("default", "sharedResource").store;
33753
- const cache2 = new import_core98.TokenCache();
33866
+ const sharedResourceStore = (0, import_core99.getStoreLattice)("default", "sharedResource").store;
33867
+ const cache2 = new import_core99.TokenCache();
33754
33868
  const resourceController = new ResourceController2({
33755
33869
  store: sharedResourceStore,
33756
- sandboxManager: import_core98.sandboxLatticeManager,
33870
+ sandboxManager: import_core99.sandboxLatticeManager,
33757
33871
  cache: cache2,
33758
33872
  logger: logger8
33759
33873
  });
@@ -33766,13 +33880,13 @@ var start = async (config) => {
33766
33880
  }
33767
33881
  if (channelDeps && process.env.CHANNELS_ENABLED !== "false") {
33768
33882
  try {
33769
- const channelLeader = new import_core98.ChannelConnectionLeader({
33770
- leaseStore: (0, import_core98.getStoreLattice)("default", "lease").store,
33771
- owner: (0, import_core98.getReplicaId)(),
33772
- connect: () => (0, import_core98.connectAllChannels)((channel) => adapterRegistry.get(channel), {
33883
+ const channelLeader = new import_core99.ChannelConnectionLeader({
33884
+ leaseStore: (0, import_core99.getStoreLattice)("default", "lease").store,
33885
+ owner: (0, import_core99.getReplicaId)(),
33886
+ connect: () => (0, import_core99.connectAllChannels)((channel) => adapterRegistry.get(channel), {
33773
33887
  deps: { router: channelDeps.router }
33774
33888
  }),
33775
- disconnect: () => (0, import_core98.disconnectAllChannels)((channel) => adapterRegistry.get(channel)),
33889
+ disconnect: () => (0, import_core99.disconnectAllChannels)((channel) => adapterRegistry.get(channel)),
33776
33890
  log: { warn: (message, context) => logger8.warn(message, context) }
33777
33891
  });
33778
33892
  app.addHook("onClose", async () => {
@@ -33786,40 +33900,43 @@ var start = async (config) => {
33786
33900
  }
33787
33901
  }
33788
33902
  const target_port = config?.port || Number(process.env.PORT) || 4001;
33789
- (0, import_core98.configureCoordinationLeaseStore)((0, import_core98.getStoreLattice)("default", "lease").store);
33790
- const outboxStore = (0, import_core98.getStoreLattice)("default", "outbox").store;
33791
- import_core98.taskLifecycleNotifier.setOutbox(outboxStore);
33792
- import_core98.projectTaskAdmissionNotifier.setOutbox(outboxStore);
33793
- (0, import_core98.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core98.getReplicaId)() });
33903
+ (0, import_core99.configureCoordinationLeaseStore)((0, import_core99.getStoreLattice)("default", "lease").store);
33904
+ const outboxStore = (0, import_core99.getStoreLattice)("default", "outbox").store;
33905
+ import_core99.taskLifecycleNotifier.setOutbox(outboxStore);
33906
+ import_core99.projectTaskAdmissionNotifier.setOutbox(outboxStore);
33907
+ (0, import_core99.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core99.getReplicaId)() });
33794
33908
  bridgeAssistantEvents(
33795
- (event, cb) => import_core98.eventBus.subscribe(event, cb),
33909
+ (event, cb) => import_core99.eventBus.subscribe(event, cb),
33796
33910
  outboxStore,
33797
- (0, import_core98.getReplicaId)()
33911
+ (0, import_core99.getReplicaId)()
33798
33912
  );
33799
33913
  if (projectRoomRealtimeRuntime) {
33800
33914
  projectRoomRealtimeRuntime.broker.setBroadcastHook((scope, serialized, sourceKey) => {
33801
- void publishRoomEvent(outboxStore, (0, import_core98.getReplicaId)(), scope, serialized, sourceKey);
33915
+ void publishRoomEvent(outboxStore, (0, import_core99.getReplicaId)(), scope, serialized, sourceKey);
33802
33916
  });
33803
33917
  }
33804
- const outboxPoller = new import_core98.OutboxPoller({
33918
+ const outboxPoller = new import_core99.OutboxPoller({
33805
33919
  store: outboxStore,
33806
- owner: (0, import_core98.getReplicaId)(),
33920
+ owner: (0, import_core99.getReplicaId)(),
33807
33921
  handlers: {
33808
- "task-lifecycle": (payload) => import_core98.taskLifecycleNotifier.deliverFromOutbox(payload),
33809
- "project-task-admission": (payload) => import_core98.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
33922
+ "task-lifecycle": (payload) => import_core99.taskLifecycleNotifier.deliverFromOutbox(payload),
33923
+ "project-task-admission": (payload) => import_core99.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
33810
33924
  [ROOM_EVENT_TOPIC]: async (payload) => {
33811
33925
  if (projectRoomRealtimeRuntime) ingestRoomEvent(payload, projectRoomRealtimeRuntime.broker);
33812
33926
  },
33813
- "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core98.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
33927
+ "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core99.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
33814
33928
  [A2A_KEY_CHANGED_TOPIC]: (payload) => handleA2AKeyChanged(payload, () => refreshStoreKeyMap()),
33815
33929
  [MCP_CONFIG_CHANGED_TOPIC]: (payload) => reconcileMcpConfigChange(payload, {
33816
- store: (0, import_core98.getStoreLattice)("default", "mcp").store,
33817
- manager: import_core98.mcpManager,
33818
- convertToConnection: import_core98.convertToConnection
33930
+ store: (0, import_core99.getStoreLattice)("default", "mcp").store,
33931
+ manager: import_core99.mcpManager,
33932
+ convertToConnection: import_core99.convertToConnection
33819
33933
  }),
33820
- [import_core98.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
33934
+ [import_core99.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
33821
33935
  const tenantId = payload?.tenantId;
33822
- if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core98.getSandboxPluginCatalog)().invalidate(tenantId);
33936
+ if (typeof tenantId === "string" && tenantId.length > 0) {
33937
+ (0, import_core99.getSandboxPluginCatalog)().invalidate(tenantId);
33938
+ await getMcpUiResourceResolver()?.invalidateTenantPlugins(tenantId);
33939
+ }
33823
33940
  },
33824
33941
  [MODEL_PROVIDER_CHANGED_TOPIC]: async (payload) => {
33825
33942
  const controller = routes.modelProviderController;
@@ -33834,7 +33951,7 @@ var start = async (config) => {
33834
33951
  } catch (err) {
33835
33952
  logger8.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
33836
33953
  }
33837
- const leaseStore = (0, import_core98.getStoreLattice)("default", "lease").store;
33954
+ const leaseStore = (0, import_core99.getStoreLattice)("default", "lease").store;
33838
33955
  if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
33839
33956
  logger8.warn(
33840
33957
  "Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
@@ -33842,7 +33959,7 @@ var start = async (config) => {
33842
33959
  );
33843
33960
  }
33844
33961
  warnMultiReplicaReadiness(logger8);
33845
- const startup = await (0, import_core98.runAsLeader)(leaseStore, "startup-recovery", async () => {
33962
+ const startup = await (0, import_core99.runAsLeader)(leaseStore, "startup-recovery", async () => {
33846
33963
  if (routes.projectTaskRuntime) {
33847
33964
  await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger8);
33848
33965
  }
@@ -33851,9 +33968,9 @@ var start = async (config) => {
33851
33968
  const { createOrphanRecoveryRuntime: createOrphanRecoveryRuntime2 } = await Promise.resolve().then(() => (init_OrphanRecoveryRuntime(), OrphanRecoveryRuntime_exports));
33852
33969
  const { createRecoveryCallerDeps: createRecoveryCallerDeps2 } = await Promise.resolve().then(() => (init_RecoveryCallerDeps(), RecoveryCallerDeps_exports));
33853
33970
  const runtime = createOrphanRecoveryRuntime2({
33854
- taskStore: (0, import_core98.getStoreLattice)("default", "task").store,
33855
- workItemStore: (0, import_core98.getStoreLattice)("default", "taskWorkItem").store,
33856
- tenantStore: (0, import_core98.getStoreLattice)("default", "tenant").store,
33971
+ taskStore: (0, import_core99.getStoreLattice)("default", "task").store,
33972
+ workItemStore: (0, import_core99.getStoreLattice)("default", "taskWorkItem").store,
33973
+ tenantStore: (0, import_core99.getStoreLattice)("default", "tenant").store,
33857
33974
  ...createRecoveryCallerDeps2(),
33858
33975
  log: logger8
33859
33976
  });
@@ -33862,9 +33979,9 @@ var start = async (config) => {
33862
33979
  logger8.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
33863
33980
  }
33864
33981
  }
33865
- if (import_core98.scheduleLatticeManager.hasLattice("default")) {
33982
+ if (import_core99.scheduleLatticeManager.hasLattice("default")) {
33866
33983
  try {
33867
- const restored = await import_core98.scheduleLatticeManager.getScheduleLattice("default").restore();
33984
+ const restored = await import_core99.scheduleLatticeManager.getScheduleLattice("default").restore();
33868
33985
  logger8.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
33869
33986
  } catch (err) {
33870
33987
  logger8.warn("Scheduled task restore failed", {
@@ -33907,7 +34024,7 @@ var start = async (config) => {
33907
34024
  steps: [
33908
34025
  async () => {
33909
34026
  await Promise.all(
33910
- import_core98.agentInstanceManager.getAllAgents().map((agent) => agent.abort().catch(() => void 0))
34027
+ import_core99.agentInstanceManager.getAllAgents().map((agent) => agent.abort().catch(() => void 0))
33911
34028
  );
33912
34029
  },
33913
34030
  () => agentTaskConsumer?.stopPollingQueue(),